You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: source/CIS/cis-5.rst
+39-16
Original file line number
Diff line number
Diff line change
@@ -359,20 +359,23 @@ Requirements
359
359
``withdrawNativeCurrency``
360
360
^^^^^^^^^^^^^^^^^^^^^^^^^^
361
361
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.
363
363
When transferring CCD to a contract address, a ccd receive hook function MUST be triggered.
364
364
365
-
366
365
Parameter
367
366
~~~~~~~~~
368
367
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.
370
371
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``),
372
373
a :ref:`CIS-5-TimeStamp` (``expiryTime``), a :ref:`CIS-5-Nonce` (``nonce``), a :ref:`CIS-5-CCDAmount` (``serviceFee``), an :ref:`CIS-5-Address` (``serviceFeeRecipient``),
373
374
the receiving address :ref:`CIS-2-Receiver` (``to``), a :ref:`CIS-5-CCDAmount` (``ccdAmount``), and some additional data :ref:`CIS-2-AdditionalData` (``data``)::
@@ -389,15 +392,16 @@ It is serialized as: a :ref:`CIS-5-CCDAmount` (``ccdAmount``), a :ref:`CIS-5-Pub
389
392
Requirements
390
393
~~~~~~~~~~~~
391
394
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.
397
401
- A withdrawal back to this contract into the ``depositNativeCurrency`` entrypoint MUST be executed as a normal withdrawal.
398
402
- A withdrawal of a CCD amount of zero MUST be executed as a normal withdrawal.
399
403
- 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.
401
405
- The balance of a public key not owning any CCD amount SHOULD be treated as having a balance of zero.
402
406
403
407
.. warning::
@@ -411,18 +415,37 @@ Requirements
411
415
``withdrawCis2Tokens``
412
416
^^^^^^^^^^^^^^^^^^^^^^
413
417
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
+
414
421
Parameter
415
422
~~~~~~~~~
416
423
424
+
The parameter is a list of withdrawals.
417
425
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.
420
427
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``)::
- 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.
0 commit comments