Concordium / concordium-rust-smart-contracts

Libraries and tools for writing and testing smart contracts on Concordium
https://docs.rs/concordium-std/latest/concordium_std/
Mozilla Public License 2.0
57 stars 36 forks source link

Add smart contract wallet #413

Closed DOBEN closed 4 months ago

DOBEN commented 5 months ago

Purpose

closes https://github.com/Concordium/concordium-rust-smart-contracts/issues/412

Next: Update the CIS5 standard proposal document to match the reference implementation: https://github.com/Concordium/concordium-update-proposals/pull/60 e.g. the service fee is deposited to the public_key of the service fee recipient in this implementation to avoid too much dust amounts being sent to addresses.

Changes

Add smart contract wallet reference implementation.

DOBEN commented 5 months ago

I decided to change the from_address in the receiveHook function call in the cis2_multi contract. This chain seems to make more sense in terms of the token being moved from one address/public_key to another. The DepositCIs2TokensEvent is logged before the MintEvent but both events are in the same atomic transaction.

Event flow of depositing cis2 tokens into the smart contract wallet is as follows now:

MintEvent (in cis2_multi contract) -> to to_address DepositCIs2TokensEvent (in smart_contract_wallet contract) -> from to_address to alice_public_key. https://github.com/Concordium/concordium-rust-smart-contracts/blob/e5f590fc38c78fa560055ddaec1884262a77cc31/examples/cis2-multi/src/lib.rs#L1044