Skip to main content
After this page, you can replace the rule document of an account, resolve a stale parent, stop payments, and remove the permission of the adapter. You also know what the activity feed and the read-back show for a payment that is in flight at that time.

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 pair commitments(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" }). update requires the module to be enabled already, else the SDK throws Safe ... has not enabled adapter .... write: "arm" also works on an armed Safe: it then enables nothing.
  • ERC20Allow: stageErc20AllowDsl({ ..., parent }). There is no write field. A new token in the document adds an approval prompt at the commit.
Use a new salt for each commit. The same salt and the same text give the same commitment, which links the two commits.
3

Commit

  • Safe: commitStagedDsl({ staged }), one prompt. Or call commitDslFromSafe(...) for the stage and the commit in one call.
  • ERC20Allow: commitStagedErc20AllowDsl({ staged }).

Stale parent: 409 and how to rebase

To rebase:
  1. Read the document that the chain holds now: compare error.current.hash with the commitment of a document that you stored, or read it with recover.
  2. Apply your change again on top of that document. Do not overwrite the newer document with your old copy.
  3. Stage with parent: error.current and a new salt.
  4. 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 }):
  1. Checks that adapter is 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.
  2. 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.
  3. For a relayed revoke, requires the adapter to be listed in the registry, else it throws and names the owner-sent path.
  4. Checks threshold 1 and the owner.
  5. Reads the module list with getModulesPaginated and finds the module before the adapter in the list (0x0000000000000000000000000000000000000001 when the adapter is first). It throws when the adapter is not enabled.
  6. Builds Safe.disableModule(prevModule, adapter) and lands it as one Safe transaction: an EIP-712 SafeTx prompt with POST /api/wallets/{safe}/safe/sponsor_exec, or one transaction prompt from the owner address.
The result is { txHash, success, confirmedBlock }. success: false means the Safe refused the transaction, and the module is still enabled.

ERC20Allow

revokeErc20Allowances({ account, adapter, onStep?, onConfirmed? }):
  1. Reads, at one tip block, the allowance to the adapter of each token in the erc20s table of the config.
  2. 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.
It uses no Anafi API. With no allowance to remove, it sends nothing and 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.

Example

This example uses the client of the Quickstart.