Replace the rule document
A commit replaces the whole document. To change one rule, change it inside the full document and commit the full document again.splitDocument and assembleDocument take a document apart by rule and put it together again. See Documents.
The parent identity
The DSL registry holds, for each account, the paircommitments(account) = (hash, version). version is 0 before the first commit and goes up by 1 at each commit. The SDK reads the pair as an OnChainDsl ({ hash, version }), or null for version 0.
Each stage names the identity that the new document was built on: the parent. The engine refuses the stage when the chain no longer holds that parent. The attestation of the engine also binds the next version, so a commit that lands between your stage and your commit makes your attestation invalid on chain.
Steps
1
Read the parent
const parent = await anafi.readDslCommitment(account). Get the plaintext of that document from your own store, or with recover.2
Stage the new document
- Safe:
stageDsl({ ..., parent, write: "update" }).updaterequires the module to be enabled already, else the SDK throwsSafe ... has not enabled adapter ....write: "arm"also works on an armed Safe: it then enables nothing. - ERC20Allow:
stageErc20AllowDsl({ ..., parent }). There is nowritefield. A new token in the document adds an approval prompt at the commit.
3
Commit
- Safe:
commitStagedDsl({ staged }), one prompt. Or callcommitDslFromSafe(...)for the stage and the commit in one call. - ERC20Allow:
commitStagedErc20AllowDsl({ staged }).
Stale parent: 409 and how to rebase
To rebase:
- Read the document that the chain holds now: compare
error.current.hashwith the commitment of a document that you stored, or read it withrecover. - Apply your change again on top of that document. Do not overwrite the newer document with your old copy.
- Stage with
parent: error.currentand a new salt. - Commit.
Pause
The block switch acts on chain at once and does not need the engine.
setBlocked(false) ends the block on chain. When the engine sees the block, or a cap with no room, it parks the account, so commit the document again after you clear the cause. See the parked reasons in Read-back. See Rule language: document for enabled, start and expiry.
Revoke
Safe
disableSafeModule({ safe, eoa, adapter }):
- Checks that
adapteris the Safe adapter of the config and that it admits the Safe. It does not require the adapter to be listed in the registry for an owner-sent revoke. - Reads
GET /api/wallets/{safe}/sponsorship. When the read fails, it selects the owner-sent path, and refuses only when the owner address holds no gas. - For a relayed revoke, requires the adapter to be listed in the registry, else it throws and names the owner-sent path.
- Checks threshold 1 and the owner.
- Reads the module list with
getModulesPaginatedand finds the module before the adapter in the list (0x0000000000000000000000000000000000000001when the adapter is first). It throws when the adapter is not enabled. - Builds
Safe.disableModule(prevModule, adapter)and lands it as one Safe transaction: an EIP-712SafeTxprompt withPOST /api/wallets/{safe}/safe/sponsor_exec, or one transaction prompt from the owner address.
{ txHash, success, confirmedBlock }. success: false means the Safe refused the transaction, and the module is still enabled.
ERC20Allow
revokeErc20Allowances({ account, adapter, onStep?, onConfirmed? }):
- Reads, at one tip block, the allowance to the adapter of each token in the
erc20stable of the config. - Sends
token.approve(adapter, 0)for each token with an allowance above 0, in table order. Each is one transaction prompt. Each waits for its receipt.
txHashes is empty. A token that is not in your erc20s table is not covered: remove that allowance with a plain approve(adapter, 0).
For a stop in one transaction, call setErc20AllowBlocked({ ..., blocked: true }). It keeps the allowances.
Revoke without Anafi
The owner can revoke from any wallet, with no Anafi service. These are plain contract calls.Payments in flight
A payment that the engine signed before your change carries a firing nonce and a deadline,validUntil. See Redeem for what the contracts do with such a payment after each change, and Redeem: nonce and deadline for the deadline.
What the public statuses show:
To start again after a revoke, grant the permission and commit a document. For a Safe,
stageDsl with write: "arm" does both in one transaction. See Activity and Read-back.