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: added cryptoTransfer to CryptoAllowance to showcase support in HIP906 #800

Merged
merged 11 commits into from
Jun 17, 2024

Conversation

quiet-node
Copy link
Member

@quiet-node quiet-node commented Jun 10, 2024

Description:

  • renamed IHRC contracts to IHRC719 as IHRC632 is being included
  • included IHRC632. IHRC632 allows an EOA to act as an SC with IHRC632 interface, walletAIHrc632 = new Contract(walletA.address, IHRC632, walletA);. This will make it possible for the EOA to directly make calls to the HAS precompile contracts, hence making the EOA top level caller of the transaction without any help from a third party like another SC account. That's when Hip-906 kicks in and allow hbar owner, top level caller, grant an hbar allowance to a spender.
  • added cyprtoTransfer to CryptoAllowance to showcase support in HIP906

Related issue(s):

Fixes #797

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Copy link

github-actions bot commented Jun 10, 2024

Test Results

  17 files  +  3    86 suites  +16   7m 54s ⏱️ + 1m 18s
254 tests +19  246 ✔️ +17    7 💤 +1  1 +1 
286 runs  +51  275 ✔️ +46  10 💤 +4  1 +1 

For more details on these failures, see this check.

Results for commit 18f0900. ± Comparison against base commit 024064d.

♻️ This comment has been updated with latest results.

@quiet-node quiet-node marked this pull request as draft June 11, 2024 01:05
Copy link
Collaborator

@AlfredoG87 AlfredoG87 left a comment

Choose a reason for hiding this comment

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

overall looks good, leaved some nits and comments.

Also, I would like to see the test cases defined as:

  1. Grant Allowance (approve) from EOA to EOA
  2. Grant Allowance (approve) from EOA to Contract
  3. Grant Allowance (approve) from Contract to EOA
  4. Grant Allowance (approve) from Contract to Contract
  5. Get Current Allowance from owner account to another Account
  6. Get Current Allowance from owner account to an Smart Contract

I also think that the correct resolution of these scenarios will need for the EOA to call the system contract directly. due to Security model limitations.

Finally, not sure why are we adding this examples and tests as part of the HTS-Precompile folder, since is not related to HTS transfers but I would place it in its own folder called HAS-SystemContract (Hedera Account Service System Contract)

.github/workflows/tests.yml Show resolved Hide resolved
test/hts-precompile/utils.js Outdated Show resolved Hide resolved
test/hts-precompile/crypto-allowance/cryptoAllowance.js Outdated Show resolved Hide resolved
test/hts-precompile/crypto-allowance/cryptoAllowance.js Outdated Show resolved Hide resolved
expect(logs.args[2]).to.eq(amount);
});

it('Should NOT allow an approval on behalf of hbar owner WINTHOUT its signature', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: WINTHOUT -> WITHOUT

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@AlfredoG87 AlfredoG87 changed the title feat: added cyprtoTransfer to CryptoAllowance to showcase support in HIP906 feat: added cryptoTransfer to CryptoAllowance to showcase support in HIP906 Jun 12, 2024
lukelee-sl
lukelee-sl previously approved these changes Jun 13, 2024
Copy link
Member

@lukelee-sl lukelee-sl left a comment

Choose a reason for hiding this comment

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

LGTM. tyvm!

@quiet-node
Copy link
Member Author

quiet-node commented Jun 13, 2024

overall looks good, leaved some nits and comments.

Also, I would like to see the test cases defined as:

  1. Grant Allowance (approve) from EOA to EOA
  2. Grant Allowance (approve) from EOA to Contract
  3. Grant Allowance (approve) from Contract to EOA
  4. Grant Allowance (approve) from Contract to Contract
  5. Get Current Allowance from owner account to another Account
  6. Get Current Allowance from owner account to an Smart Contract

I also think that the correct resolution of these scenarios will need for the EOA to call the system contract directly. due to Security model limitations.

Finally, not sure why are we adding this examples and tests as part of the HTS-Precompile folder, since is not related to HTS transfers but I would place it in its own folder called HAS-SystemContract (Hedera Account Service System Contract)

@AlfredoG87

  1. Grant Allowance (approve) from EOA to EOA

  2. Grant Allowance (approve) from EOA to Contract

  3. Grant Allowance (approve) from Contract to EOA

  4. Grant Allowance (approve) from Contract to Contract

  5. Get Current Allowance from owner account to another Account

  6. Get Current Allowance from owner account to an Smart Contract

Copy link
Collaborator

@AlfredoG87 AlfredoG87 left a comment

Choose a reason for hiding this comment

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

LGTM

@quiet-node quiet-node force-pushed the 797-create-tests-for-hip-206906-part-2 branch from 33aba67 to 2c264cd Compare June 14, 2024 21:17
Copy link
Member

@lukelee-sl lukelee-sl left a comment

Choose a reason for hiding this comment

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

LGTM

quiet-node and others added 9 commits June 17, 2024 13:49
Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
…ar allowance to another contract

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>

Co-authored-by: lukelee-sl <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
@quiet-node quiet-node force-pushed the 797-create-tests-for-hip-206906-part-2 branch from 2c264cd to 18f0900 Compare June 17, 2024 17:49
@quiet-node quiet-node marked this pull request as ready for review June 17, 2024 17:49
@quiet-node quiet-node merged commit 4241394 into main Jun 17, 2024
26 of 27 checks passed
@quiet-node quiet-node deleted the 797-create-tests-for-hip-206906-part-2 branch June 17, 2024 18:15
marcin-piela-ariane pushed a commit to marcin-piela-ariane/hedera-smart-contracts that referenced this pull request Jun 24, 2024
…HIP906 (hashgraph#800)

* feat: added CryptoAllowance wrapper example contract

Signed-off-by: Logan Nguyen <[email protected]>

* test: added test coverage for CryptoAllowance

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed IHRC to IHRC719

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added IHRC632

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added cyprtoTransfer to CryptoAllowance to showcase support in HIP906

Signed-off-by: Logan Nguyen <[email protected]>

* feat: added use case to showcase the support for contract granting hbar allowance to another contract

Signed-off-by: Logan Nguyen <[email protected]>

* ci: added CryptoAllowance to PublishResults

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added return statements for hbarAllowancePublic

Signed-off-by: Logan Nguyen <[email protected]>

* fix: stored SC addresses into constants

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed typo

Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed typo

Signed-off-by: Logan Nguyen <[email protected]>

Co-authored-by: lukelee-sl <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
Co-authored-by: lukelee-sl <[email protected]>
@quiet-node quiet-node added this to the 0.8.0 milestone Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create tests for HIP 206/906
3 participants