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

feat: decode sc metadata #5274

Merged
merged 20 commits into from Nov 25, 2022
Merged

feat: decode sc metadata #5274

merged 20 commits into from Nov 25, 2022

Conversation

Tuditi
Copy link
Contributor

@Tuditi Tuditi commented Nov 22, 2022

Summary

This PR adds functionality to parse metadata relevant to a smart contract call in a human friendly format

...

Changelog

- Add parseLayer2MetadataForTransfer()
- Add tests for parseLayer2MetadataForTransfer()
- Correctly set allowance
- Fix sending native tokens to L2
- Add dictionary for contract functions
- Add dictionary for target contracts

Relevant Issues

closes: #5216

Testing

Platforms

Please select any platforms where your changes have been tested.

  • Desktop
    • MacOS
    • Linux
    • Windows
  • Mobile
    • iOS
    • Android

Instructions

Please describe the specific instructions, configurations, and/or test cases necessary to test and verify that your changes work as intended.

...

Checklist

Please tick all of the following boxes that are relevant to your changes.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or modified tests that prove my changes work as intended
  • I have verified that new and existing unit tests pass locally with my changes
  • I have verified that my latest changes pass CI workflows for testing and linting
  • I have made corresponding changes to the documentation

@Tuditi Tuditi changed the title Feat/decode sc metadata feat: decode sc metadata Nov 22, 2022
@Tuditi Tuditi linked an issue Nov 23, 2022 that may be closed by this pull request
3 tasks
@Tuditi Tuditi marked this pull request as ready for review November 24, 2022 11:07
Copy link
Contributor

@MarkNerdi996 MarkNerdi996 left a comment

Choose a reason for hiding this comment

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

1 question + 1 code change

Comment on lines +24 to +25
const ethereumAddress = '0x' + smartContractParameters['a'].substring(2)
const forceOpenAccount = smartContractParameters['c'] === FORCE_OPEN_ACCOUNT
Copy link
Contributor

Choose a reason for hiding this comment

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

not related to your PR, but why are those fields called "a" and "c"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are kind of arbitrary, but not something that will be changed before the release.
You can find a list for the parameter calls the accounts contract here: https://github.com/iotaledger/wasp/blob/gpa/packages/vm/core/accounts/interface.go#L62-L76

const gasBudget = readStream.readUInt64('gasBudget')

const smartContractParameters = parseSmartContractParameters(readStream)
const { baseTokenAmount, nativeTokens } = parseAllowance(readStream)
Copy link
Contributor

Choose a reason for hiding this comment

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

this throws an error if parseAllowance(readStream) returns undefined

Copy link
Contributor

@MarkNerdi996 MarkNerdi996 left a comment

Choose a reason for hiding this comment

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

LGTM, gj!

@Tuditi Tuditi merged commit 2c82db1 into stardust-develop Nov 25, 2022
@Tuditi Tuditi deleted the feat/decode-sc-metadata branch November 25, 2022 08:04
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.

[Task]: Deciper layer 2 metadata
2 participants