-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add ability to query for token details #612
Conversation
token/services/tokens/storage.go
Outdated
id, err := identity.UnmarshalTypedIdentity(tok.Owner.Raw) | ||
if err != nil { | ||
logger.Errorf("could not unmarshal identity when storing token: %s", err.Error()) | ||
return fmt.Errorf("could not unmarshal identity when storing token: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, use "github.com/pkg/errors"
token/services/tokens/storage.go
Outdated
@@ -114,12 +113,20 @@ func (t *transaction) AppendToken( | |||
if err != nil { | |||
return errors.Wrapf(err, "cannot covert [%s] with precision [%d]", tok.Quantity, precision) | |||
} | |||
id, err := identity.UnmarshalTypedIdentity(tok.Owner.Raw) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering: Should we replace this with an unmarshaller
that given in input the raw []bytes gives the type and the identity?
It is just to detach the tokens package from the identity package.
In theory, the content of an identity is driver dependant, but we can make in a future PR explicit the presence of the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of decoupling them on this level, but where should the unmarshaler be? Let me know if you have an example that I can reuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in storage.go
we could introduce an interface like
type OwnerTypeExtractor interface {
Extract(tmsID token.TMSID, raw []byte) (string, []byte, error)
}
An instance of which is taken in input by the Manager
and propagated until the Transaction
struct.
In sdk.go, we implement and provide the struct implementing the interface to the manager.
What do you think? :)
34ee6ce
to
3c89451
Compare
…nd movements in sql driver Signed-off-by: Arne Rutjes <arne123@gmail.com>
Signed-off-by: Arne Rutjes <arne123@gmail.com>
Signed-off-by: Arne Rutjes <arne123@gmail.com>
…lation with output token Signed-off-by: Arne Rutjes <arne123@gmail.com>
Signed-off-by: Arne Rutjes <arne123@gmail.com>
Signed-off-by: Arne Rutjes <arne123@gmail.com>
Signed-off-by: Arne Rutjes <arne123@gmail.com>
Signed-off-by: Arne Rutjes <arne123@gmail.com>
Signed-off-by: Arne Rutjes <arne123@gmail.com>
This PR: