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

Separate tokenReceived for Stellar Asset Contract #139

Merged
merged 2 commits into from
Oct 21, 2024
Merged

Conversation

thpani
Copy link
Collaborator

@thpani thpani commented Oct 17, 2024

This is a delta to #135.

While working on #133, I realized that Stellar Asset Contracts use a different storage layout than the soroban-examples/token contract (in particular, they keep a struct inside the Balance storage, not just an i128 amount).

In this PR, we

  • move the tokenTransferred condition that only applies to soroban-examples/token out of Solarkraft, and into verify_js_example.ts
  • provide a CAP-46-compatible version of tokenTransferred instead
  • add a CAP-46-compatible condition tokenReceived, that checks only the receiver part of tokenTransferred

tokenReceived is necessary, because there may not be a sender balance recorded in contract storage of the SAC if the sender is transferring native tokens.

@thpani thpani added this to the M6: DevRel and case studies milestone Oct 17, 2024
@thpani thpani requested a review from konnov October 17, 2024 15:03
Base automatically changed from th/js-monitors to main October 18, 2024 08:20
Copy link
Contributor

@konnov konnov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I've left a few comments

solarkraft/src/verify_js.ts Show resolved Hide resolved
): Condition {
const oldTokenStorage = env.oldStorage(token).persistent()
const tokenStorage = env.storage(token).persistent()
return every(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would not the && work just as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would, but using every() allows us to inform the user which conjunct failed.

solarkraft/test/unit/verify_js.test.ts Show resolved Hide resolved
@thpani thpani merged commit 677275b into main Oct 21, 2024
3 checks passed
@thpani thpani deleted the th/tokenreceived-sac branch October 21, 2024 15:27
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.

2 participants