OrbitDocs

cancel_vault

Subscriber deletes the vault for one merchant, so no further pulls can happen.

Edit this page on GitHub
pub fn cancel_vault(env: Env, user: Address, merchant: Address)

Auth: user.require_auth(). Only the subscriber can cancel. The merchant cannot call this entrypoint for them.

Preview. cancel_vault is in the contract source on main but not yet in the testnet deployment CAZBZBUW...CDYQNG. It becomes callable there after the next redeploy.

Parameters

userAddressrequired

The subscriber who owns the vault. Must sign.

merchantAddressrequired

The merchant the vault pays. Together with user, it forms the vault key.

Execution

user.require_auth();

let key = VaultKey { user, merchant };
assert!(storage.has(&key), "Vault does not exist");

storage.remove(&key);
env.events().publish((Symbol::new(&env, "vault_cancelled"), user, merchant), ());

Effects

  • Removes the VaultKey { user, merchant } entry from persistent storage, along with the per-pair state the contract keeps next to it.
  • Publishes a vault_cancelled event with user and merchant as topics and an empty payload.
  • After it succeeds, get_vault returns None for the pair and pull_funds fails with Vault does not exist.

cancel_vault does not revoke the token allowance. Orbit cannot pull without a vault, but the approval the subscriber gave Orbit on the token stays in place until it expires or the subscriber sets it to 0 with approve. If the subscriber wants nothing left behind, they should revoke the allowance in a separate call.

To start billing the same merchant again, the subscriber runs create_vault for the pair. The new vault starts with last_pull_timestamp = 0, so the merchant can pull right away.

Errors

MessageCauseFix
Vault does not existNo vault for this (user, merchant), or it was already cancelledCheck with get_vault before cancelling
Auth erroruser did not signSign with the subscriber's key

See contract errors for the full list.

Example

stellar contract invoke --id $ORBIT --source subscriber --network testnet -- \
  cancel_vault --user $SUBSCRIBER --merchant $MERCHANT

To also revoke the allowance, set it to 0 on the token:

stellar contract invoke --id $USDC --source subscriber --network testnet -- \
  approve --from $SUBSCRIBER --spender $ORBIT --amount 0 --expiration_ledger 0

On this page