-
Notifications
You must be signed in to change notification settings - Fork 37
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
Smart Contract transfer and execute #340
Conversation
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.
Very nice 🎉 🚀
src/tokens.ts
Outdated
} | ||
} | ||
|
||
export class TokenTransfer { |
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.
Here we'll have an issue 🙈
https://github.com/multiversx/mx-sdk-js-core/blob/main/src/tokenTransfer.ts
Let's brainstorm how to tackle this. Perhaps we can define a new sub-package, next
, or perhaps we should use namespacing instead.
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 am using namespacing now. Let me know what you think about it.
} | ||
} | ||
|
||
function decodeUnsignedNumber(arg: Buffer): number { |
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.
Can be moved near the other codec functions? Can also stay here for now, actually. We'll move it later, when / if needed.
receiver = options.sender; | ||
} | ||
} | ||
else if (numberOfTokens > 1) { |
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.
Else, without if (also for py). Also, formatting / (braces & newlines).
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.
As it is now, it doesn't properly work without else if
. The code checks if someone provides a native token amount and custom token transfers but does not check if neither is provided. And it shouldn't check because you can simply call a contract function without doing any transfers. We check if the numberOfTokens == 1
, but then if we use a simple else
, and numberOfTokens = 0
, the else branch get's executed and we don't want that since we don't have any transfers.
this.token = token; | ||
this.amount = amount; | ||
} | ||
export class NextTokenTransfer { |
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.
✔️
Implemented the factory based on the specifications.