-
Notifications
You must be signed in to change notification settings - Fork 9
[WAL-1471] Add support for sponsored transactions #659
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
base: p10-updates
Are you sure you want to change the base?
Conversation
All changes I have at the moment
Disable TS checks
Changed TokenHolder to CborAccountAddress Updated sponsored transactions UI according to design Fixed transaction handler functions Removed TS ignore
Fix lint error
Update CHANGELOG.md
soerenbf
left a comment
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 would suggest applying the changes suggested here, but otherwise it looks good to me and works with the example.
Great job! 🥇
| type: LaxNumberEnumValue<AccountTransactionType.Transfer>, | ||
| payload: SignableTransaction |
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.
Is there a good reason to have the type as an argument as well? It's used in sendTransaction to give better type information with regards to which payload is supported for a transaction type. In the case of the SignableTransaction the transaction type is already available in the payload of the transaction.
| type: LaxNumberEnumValue<AccountTransactionType.Transfer>, | |
| payload: SignableTransaction | |
| payload: SignableTransaction |
See
| type: AccountTransactionType, | ||
| payload: SignableTransaction | ||
| ): Promise<string> { | ||
| const response = await this.messageHandler.sendMessage<MessageStatusWrapper<string>>( | ||
| MessageType.SendSponsoredTransaction, | ||
| { | ||
| type, | ||
| accountAddress, | ||
| payload: stringify(payload), | ||
| } | ||
| ); |
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.
Would change to
| type: AccountTransactionType, | |
| payload: SignableTransaction | |
| ): Promise<string> { | |
| const response = await this.messageHandler.sendMessage<MessageStatusWrapper<string>>( | |
| MessageType.SendSponsoredTransaction, | |
| { | |
| type, | |
| accountAddress, | |
| payload: stringify(payload), | |
| } | |
| ); | |
| transaction: SignableTransaction | |
| ): Promise<string> { | |
| const response = await this.messageHandler.sendMessage<MessageStatusWrapper<string>>( | |
| MessageType.SendSponsoredTransaction, | |
| { | |
| accountAddress, | |
| transaction: stringify(Transaction.toJSON(transaction)), | |
| } | |
| ); |
| const sponsorResponse = await submitPayloadToSponsor( | ||
| AccountAddress.fromBase58(currentAccountAddress), | ||
| Transaction.toJSON(transaction) | ||
| ); | ||
|
|
||
| console.log('sponsorResponse', sponsorResponse); | ||
|
|
||
| return provider | ||
| .sendSponsoredTransaction(currentAccountAddress, 3, sponsorResponse) | ||
| .then((sig) => alert(JSON.stringify(sig))) | ||
| .catch(alert); |
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.
And consequently
| const sponsorResponse = await submitPayloadToSponsor( | |
| AccountAddress.fromBase58(currentAccountAddress), | |
| Transaction.toJSON(transaction) | |
| ); | |
| console.log('sponsorResponse', sponsorResponse); | |
| return provider | |
| .sendSponsoredTransaction(currentAccountAddress, 3, sponsorResponse) | |
| .then((sig) => alert(JSON.stringify(sig))) | |
| .catch(alert); | |
| const sponsorResponse = await submitPayloadToSponsor( | |
| AccountAddress.fromBase58(currentAccountAddress), | |
| Transaction.toJSON(transaction) | |
| ); | |
| const sponsoredParsed = Transaction.signableFromJSON(sponsorResponse); | |
| console.log('sponsorResponse', sponsorResponse); | |
| return provider | |
| .sendSponsoredTransaction(currentAccountAddress, sponsoredParsed) | |
| .then((sig) => alert(JSON.stringify(sig))) | |
| .catch(alert); |
| const sponsorResponse = await submitPayloadToSponsor( | ||
| AccountAddress.fromBase58(currentAccountAddress), | ||
| Transaction.toJSON(transaction) | ||
| ); | ||
|
|
||
| console.log('sponsorResponse', sponsorResponse); | ||
|
|
||
| return provider | ||
| .sendSponsoredTransaction(currentAccountAddress, 27, sponsorResponse) | ||
| .then((sig) => alert(JSON.stringify(sig))) | ||
| .catch(alert); |
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.
And here
| const sponsorResponse = await submitPayloadToSponsor( | |
| AccountAddress.fromBase58(currentAccountAddress), | |
| Transaction.toJSON(transaction) | |
| ); | |
| console.log('sponsorResponse', sponsorResponse); | |
| return provider | |
| .sendSponsoredTransaction(currentAccountAddress, 27, sponsorResponse) | |
| .then((sig) => alert(JSON.stringify(sig))) | |
| .catch(alert); | |
| const sponsorResponse = await submitPayloadToSponsor( | |
| AccountAddress.fromBase58(currentAccountAddress), | |
| Transaction.toJSON(transaction) | |
| ); | |
| console.log('sponsorResponse', sponsorResponse); | |
| const sponsoredParsed = Transaction.signableFromJSON(sponsorResponse); | |
| return provider | |
| .sendSponsoredTransaction(currentAccountAddress, sponsoredParsed) | |
| .then((sig) => alert(JSON.stringify(sig))) | |
| .catch(alert); |
|
|
||
| ## Unreleased | ||
|
|
||
| - Added support for Sponsored Transactions handling. With new method `sendSponsoredTransaction` in wallet-api. |
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.
| - Added support for Sponsored Transactions handling. With new method `sendSponsoredTransaction` in wallet-api. | |
| ## 2.7.1 | |
| - Added support for Sponsored Transactions handling. With new method `sendSponsoredTransaction` in wallet-api. |
Update transaction type parse from, sponsored transaction
Purpose
_Describe the purpose of the pull request, link to issue describing the problem, etc.
Changes
All changes I have at the moment
Checklist
hard-to-understand areas.
CLA acceptance
_Remove if not applicable.
By submitting the contribution I accept the terms and conditions of the
Contributor License Agreement v1.0
link: https://developers.concordium.com/CLAs/Contributor-License-Agreement-v1.0.pdf
I accept the above linked CLA.