concordium-rust-smart-contracts icon indicating copy to clipboard operation
concordium-rust-smart-contracts copied to clipboard

Feedback/Improvements on the smart-contract-wallet implementation

Open DOBEN opened this issue 10 months ago • 5 comments

Task description

kudos to @soerenbf for his great input.

Sub-tasks "Naming improvements to shorten/simplify the terminology"

  • [x] nativeCurrency rename to CCD.
  • [x] internalTransfer rename to transfer.
  • [x] view functions for hashes rename to getCis2TransferMessageHash/getCCDTransferMessageHash/getCis2WithdrawMessageHash/getCCDWithdrawMessageHash.
  • [x] balanceOfCis2Tokens rename to Cis2BalanceOf/CCDBalanceOf.

Sub-tasks "Adding serde feature to simplify parsing the type as JSON value between front end and back end"

  • [x] Smart contract wallet: add serde to all parameter types of the internalTransfer/withdraw/deposit functions.
  • [x] CIS2-library: add serde to the TokenAmount and TokenID types, and all parameter types of transfer/updateOperator functions.
  • [x] wherever this type lives: add serde to type PublicKeyEd25519.

DOBEN avatar Apr 22 '24 08:04 DOBEN

Using transfer instead of internalTransfer makes the CIS-5 standard incompatible with CIS-2, so I would suggest using some other name.

limemloh avatar Apr 22 '24 08:04 limemloh

Using transfer instead of internalTransfer makes the CIS-5 standard incompatible with CIS-2, so I would suggest using some other name.

Ah, right.. didn't think of that! Good point 👍

If the purpose is that these can be mixed, then maybe the transfer function should be prefixed with something that identifies this as a sc-wallet transfer? Can't figure out the best name just off the top of my head

soerenbf avatar Apr 22 '24 08:04 soerenbf

Suggestion: cis5Transfer for the name.

update: After a discussion, we realized that there is no function name overlap between CIS-2 and CIS-5. CIS-5 will use as function names transferCCD /transferCIS2Token.

DOBEN avatar Apr 22 '24 09:04 DOBEN

It seems that the tests rely on cis2-multi being compiled into ../cis2-multi/concordium-out/module.wasm.v1. Maybe this should be added as a step in a build.rs file when building tests? I don't know how well this plays with cargo-concordium though.

lassemoldrup avatar Apr 26 '24 14:04 lassemoldrup

It seems that the tests rely on cis2-multi being compiled into ../cis2-multi/concordium-out/module.wasm.v1. Maybe this should be added as a step in a build.rs file when building tests? I don't know how well this plays with cargo-concordium though.

Let's discuss and create a separate issue for it. There are 3 contracts that have tests that depend on other contracts currently:

  • sponsored-tx-enabled-auction
  • cis5-smart-contract-wallet
  • smart-contract-upgrade V1

The 'sponsored-tx-enabled-auction' and 'cis5-smart-contract-wallet' examples need the wasm module cis2-multi for its tests. https://github.com/Concordium/concordium-rust-smart-contracts/blob/main/.github/workflows/linter.yml#L901

The 'smart-contract-upgrade' example has a v1 and v2 contract and the tests in v1 needs the wasm module from v2 for upgrading. https://github.com/Concordium/concordium-rust-smart-contracts/blob/main/.github/workflows/linter.yml#L896

DOBEN avatar Apr 26 '24 15:04 DOBEN