Skip to content
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

Merged
merged 9 commits into from
Apr 29, 2024
Merged

add ability to query for token details #612

merged 9 commits into from
Apr 29, 2024

Conversation

arner
Copy link
Contributor

@arner arner commented Apr 24, 2024

This PR:

  • Adds the ability to query for token with details, to allow the user to enrich the data about a transaction
  • Splits the Raw Owner into its two components for more efficient queries. This can later be extended to the Owner struct in the Token (replacing the raw version)
  • Stores the ApplicationMetadata as a separate field of the token request and adds it to retrieved transactions (where they are usually used)
  • Returns owners when doing GetToken
  • Simplifies the code of the querybuilder a bit

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)
Copy link
Contributor

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"

@@ -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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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? :)

@arner arner force-pushed the f-token-details branch 2 times, most recently from 34ee6ce to 3c89451 Compare April 24, 2024 12:27
…nd movements in sql driver

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>
@adecaro adecaro merged commit 298a6a9 into main Apr 29, 2024
37 checks passed
@adecaro adecaro deleted the f-token-details branch April 29, 2024 14:25
@adecaro adecaro restored the f-token-details branch April 29, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants