Skip to content

Commit fb33efb

Browse files
committed
Add withdrawCis2Tokens function
1 parent 7ac6483 commit fb33efb

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
lines changed

source/CIS/cis-5.rst

+39-16
Original file line numberDiff line numberDiff line change
@@ -359,20 +359,23 @@ Requirements
359359
``withdrawNativeCurrency``
360360
^^^^^^^^^^^^^^^^^^^^^^^^^^
361361

362-
Executes a withdrawal of CCDs (native currency) to a native account or smart contract out of the smart contract wallet.
362+
Executes a list of token withdrawals of CCDs (native currency) to native accounts and/or smart contracts out of the smart contract wallet.
363363
When transferring CCD to a contract address, a ccd receive hook function MUST be triggered.
364364

365-
366365
Parameter
367366
~~~~~~~~~
368367

369-
The parameter is the ``NativeCurrencyWithdrawParameter``.
368+
The parameter is a list of withdrawals.
369+
370+
It is serialized as: 2 bytes representing the number of withdrawals (``n``) followed by the bytes for this number of withdrawals.
370371

371-
It is serialized as: a :ref:`CIS-5-PublicKeyEd25519` (``signer``), a :ref:`CIS-5-SignatureEd25519` (``signature``),
372+
Each withdrawal is serialized as: a :ref:`CIS-5-PublicKeyEd25519` (``signer``), a :ref:`CIS-5-SignatureEd25519` (``signature``),
372373
a :ref:`CIS-5-TimeStamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-CCDAmount` (``serviceFee``), an :ref:`CIS-5-Address` (``serviceFeeRecipient``),
373374
the receiving address :ref:`CIS-2-Receiver` (``to``), a :ref:`CIS-5-CCDAmount` (``ccdAmount``), and some additional data :ref:`CIS-2-AdditionalData` (``data``)::
374375

375-
NativeCurrencyWithdrawParameter ::= (signer: PublicKeyEd25519) (signature: SignatureEd25519) (expiryTime: TimeStamp) (nonce: u64) (serviceFee: CCDAmount) (serviceFeeRecipient: Address) (to: Receiver) (ccdAmount: CCDAmount) (data: AdditionalData)
376+
NativeCurrencyWithdrawal ::= (signer: PublicKeyEd25519) (signature: SignatureEd25519) (expiryTime: TimeStamp) (nonce: u64) (serviceFee: CCDAmount) (serviceFeeRecipient: Address) (to: Receiver) (ccdAmount: CCDAmount) (data: AdditionalData)
377+
378+
NativeCurrencyWithdrawParameter ::= (n: Byte²) (withdrawal: NativeCurrencyWithdrawalⁿ)
376379

377380
.. _CIS-5-functions-transfer-ccd-receive-hook-parameter:
378381

@@ -389,15 +392,16 @@ It is serialized as: a :ref:`CIS-5-CCDAmount` (``ccdAmount``), a :ref:`CIS-5-Pub
389392
Requirements
390393
~~~~~~~~~~~~
391394

392-
- The function MUST emit a ``NonceEvent`` and a ``WithdrawNativeCurrencyEvent``.
393-
- The function MUST reject if the signature verification fails.
394-
395-
- The withdrawal MUST fail, if the CCD balance of the ``signer`` is insufficient to do the withdrawal.
396-
- A withdrawal MUST non-strictly decrease the CCD balance of the ``signer`` public key and non-strictly increase the balance of the ``to`` address or fail.
395+
- The list of withdrawals MUST be executed in order.
396+
- The contract function MUST reject if any of the withdrawals fail to be executed.
397+
- The function MUST emit a ``NonceEvent`` and a ``WithdrawNativeCurrencyEvent`` for every withdrawal.
398+
- The function MUST reject if the signature verification fails for any withdrawal.
399+
- The function MUST fail, if the CCD balance of the ``signer`` is insufficient to do the withdrawal for any withdrawal.
400+
- A function MUST non-strictly decrease the CCD balance of the ``signer`` public key and non-strictly increase the balance of the ``to`` address or fail for any withdrawal.
397401
- A withdrawal back to this contract into the ``depositNativeCurrency`` entrypoint MUST be executed as a normal withdrawal.
398402
- A withdrawal of a CCD amount of zero MUST be executed as a normal withdrawal.
399403
- A withdrawal of any amount of CCD to a contract address MUST call a ccd receive hook function on the receiving smart contract with a :ref:`ccd receive hook parameter<CIS-5-functions-transfer-ccd-receive-hook-parameter>`.
400-
- The contract function MUST reject if the ccd receive hook function called on the contract receiving CCDs rejects.
404+
- The contract function MUST reject if the ccd receive hook function called on the contract receiving CCDs rejects for any withdrawal.
401405
- The balance of a public key not owning any CCD amount SHOULD be treated as having a balance of zero.
402406

403407
.. warning::
@@ -411,18 +415,37 @@ Requirements
411415
``withdrawCis2Tokens``
412416
^^^^^^^^^^^^^^^^^^^^^^
413417

418+
Executes a list of token withdrawals to native accounts and/or smart contracts out of the smart contract wallet.
419+
This function MUST call the ``transfer`` function on the CIS-2 token contract for every withdrawal.
420+
414421
Parameter
415422
~~~~~~~~~
416423

424+
The parameter is a list of withdrawals.
417425

418-
Requirements
419-
~~~~~~~~~~~~
426+
It is serialized as: 2 bytes representing the number of withdrawals (``n``) followed by the bytes for this number of withdrawals.
420427

421-
- The function MUST emit a ``NonceEvent`` and a ``WithdrawCis2TokensEvent``.
422-
- The function MUST reject if the signature verification fails.
423-
- This function has to call a ``transfer`` function on the cis2 token contract.
428+
Each withdrawal is serialized as: a :ref:`CIS-5-PublicKeyEd25519` (``signer``), a :ref:`CIS-5-SignatureEd25519` (``signature``),
429+
a :ref:`CIS-5-TimeStamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-CCDAmount` (``serviceFee``), an :ref:`CIS-5-Address` (``serviceFeeRecipient``),
430+
the receiving address :ref:`CIS-2-Receiver` (``to``), a :ref:`CIS-5-TokenAmount` (``tokenAmount``), a :ref:`CIS-5-TokenID` (``tokenID``), a :ref:`CIS-5-ContractAddress` (``cis2TokenContractAddress``), and some additional data :ref:`CIS-2-AdditionalData` (``data``)::
431+
432+
Cis2TokensWithdrawal ::= (signer: PublicKeyEd25519) (signature: SignatureEd25519) (expiryTime: TimeStamp) (nonce: u64) (serviceFee: CCDAmount) (serviceFeeRecipient: Address) (to: Receiver) (tokenAmount: tokenAmount) (tokenId: tokenID) (cis2TokenContractAddress: ContractAddress) (data: AdditionalData)
424433

434+
Cis2TokensWithdrawParameter ::= (n: Byte²) (withdrawal: Cis2TokensWithdrawalⁿ)
435+
436+
Requirements
437+
~~~~~~~~~~~~
425438

439+
- The list of withdrawals MUST be executed in order.
440+
- The contract function MUST reject if any of the withdrawals fail to be executed.
441+
- The function MUST emit a ``NonceEvent`` and a ``WithdrawCis2TokensEvent`` for every withdrawal.
442+
- The function MUST reject if the signature verification fails for any withdrawal.
443+
- This function MUST call the ``transfer`` function on the CIS-2 token contract for every withdrawal.
444+
- The function MUST fail, if the token balance of the ``signer`` is insufficient to do the withdrawal for any withdrawal.
445+
- A function MUST non-strictly decrease the token balance of the ``signer`` public key and non-strictly increase the balance of the ``to`` address or fail for any withdrawal.
446+
- A withdrawal back to this contract into the ``depositCis2Tokens`` entrypoint MUST be executed as a normal withdrawal.
447+
- A withdrawal of a token amount of zero MUST be executed as a normal withdrawal.
448+
- The balance of a public key not owning any tokens SHOULD be treated as having a balance of zero.
426449

427450
.. _CIS-5-functions-internalNativeCurrencyTransfer:
428451

source/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ Concordium Interoperability Specifications
2121
CIS/cis-2
2222
CIS/cis-3
2323
CIS/cis-4
24-
CIS/cis-5
24+
CIS/cis-5
2525
ID/concordium-did.rst

0 commit comments

Comments
 (0)