account library

The shared on-chain account primitive — package:deepbook/account.dart.

Mirrors the official @mysten/deepbook-v3/account subpath: the primitive is shared infrastructure (DeepBook's core account wrapper and DeepBook Predict both build on the same Move package), so it lives alongside spot and margin rather than in either consumer. Like the official subpath, this entry point is a separate library: importing it does not load spot or margin code, and package:deepbook/deepbook.dart is unchanged.

NOTE: the Account BCS struct exported here is the account primitive's custody account (account::account::Account). It is a DIFFERENT type from the Account exported by package:deepbook/deepbook.dart (@deepbook/core::account::Account, the per-pool trading account) and the two have unrelated layouts. Keep them separated by import, or import this library with a prefix.

Classes

AccountContract
AccountContract — the reusable on-chain account primitive (packages/account).
AccountIds
Ids for the shared account primitive.
DeploymentInfo
Which on-chain deployment a set of ids came from.
DeploymentUnits
Scale constants the deployment owns rather than the SDK.

Constants

TESTNET_DEPLOYMENT → const DeploymentInfo
Which on-chain deployment the ids below came from.
TESTNET_UNITS → const DeploymentUnits
Scale constants the deployment owns rather than the SDK.

Properties

Account → BcsType<Map<String, dynamic>, dynamic>
final
AccountAdminCap → BcsType<Map<String, dynamic>, dynamic>
final
AccountCreated → BcsType<Map<String, dynamic>, dynamic>
final
AccountKey → BcsType<List, List>
final
AccountRegistry → BcsType<Map<String, dynamic>, dynamic>
final
AccountWrapper → BcsType<Map<String, dynamic>, dynamic>
final
AccountWrapperKey → BcsType<List, List>
final
AppAuthorized → BcsType<Map<String, dynamic>, dynamic>
final
AppDeauthorized → BcsType<Map<String, dynamic>, dynamic>
final
AppKey → BcsType<List, List>
final
Auth → BcsType<Map<String, dynamic>, dynamic>
final
CoinKey → BcsType<List, List>
final
DataKey → BcsType<List, List>
final
Deposited → BcsType<Map<String, dynamic>, dynamic>
final
FundsSettled → BcsType<Map<String, dynamic>, dynamic>
final
Withdrawn → BcsType<Map<String, dynamic>, dynamic>
final

Functions

accountId({required dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Returns the canonical account ID.
assertAppIsAuthorized({dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Aborts unless App is currently authorized for app-driven account access.
attach({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Attach an app's Data under its witness namespace. Requires Permit<App>. Aborts if App already has data attached.
authorizeApp({dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Globally authorizes App to request mutable authority for account wrappers.
balance({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Returns the total balance of T available to the account, including funds delivered through the ambient accumulator but not yet settled into the account.
borrowData({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Borrow an app's attached Data. Open (no witness): the slot is namespaced by App and on-chain state is public, so composing apps can read it. Aborts if nothing is attached.
borrowDataMut({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Mutably borrow an app's attached Data. Requires Permit<App>. Aborts if nothing is attached.
deauthorizeApp({dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Revokes App from requesting new mutable account authority.
deposit({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Deposits into stored balance only; callers that include accumulator funds must settle through the wrapper first.
depositFunds({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
PTB entrypoint that settles accumulator funds, consumes authority, and deposits into stored balance in one call.
derivedAddress({dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Returns the deterministic canonical account address for external discovery and PTB construction.
derivedExists({dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Returns whether the canonical account identity has been claimed.
derivedWrapperAddress({dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Returns the deterministic wrapper address for external discovery, accumulator delivery, and PTB construction.
derivedWrapperExists({dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Returns whether the canonical wrapper has been claimed.
detach({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Detach and return an app's Data. Requires Permit<App>. Aborts if nothing is attached.
generateAuth({String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Creates owner authority bound to the transaction sender.
generateAuthAsApp({dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Generates full mutable account authority after checking the global app whitelist. Permit<App> restricts the request to the module that defines App; the returned authority is not bound to an owner, wrapper, or operation.
generateAuthAsObject({required dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Creates owner authority bound to an owning object's address.
getAccountConfig(String network) → AccountConfig
The deployed account ids for network, so a caller does not transcribe them. Generated from the deploy manifest — see lib/src/deployments/.
getDeployment(String network) → DeploymentInfo
Which deployment the ids on network came from — its name and the deepbookv3 commit they were generated at. Useful when a bug report needs to say which on-chain deployment an SDK build was pinned to.
getUnits(String network) → DeploymentUnits
Scale constants for network — lot size, fixed-point scale, and coin decimals. Deployment-wide, so any subsystem formatting a custody balance can read them rather than hardcoding 6.
hasData({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Whether App has data attached to this account.
id({required dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Returns the wrapper object ID.
isAppAuthorized({dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Returns whether App may request package-issued mutable account authority.
loadAccount({required dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Borrows the wrapped account for read-only composition.
loadAccountMut({required dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Consumes owner or app authority and returns the account's full mutable surface. Owner authority must match the stored owner; app authority is package-issued after registry authorization and carries no owner or operation restriction.
new_({dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Creates the sender's canonical account and wrapper, aborting if either derived ID is already claimed.
newSelfOwned({dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Creates the canonical account owned by owner_uid's object address, aborting if either derived ID is already claimed.
newWithReferrer({dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Creates the sender's canonical account and permanently records the supplied wrapper's account identity and receive address as its referrer.
owner({required dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Returns the account owner address. This may be an EOA address or an object-ID-as-address.
receiveAddress({required dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Returns the accumulator receive address for this account (the wrapper address).
referrerAccountId({required dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Returns the canonical referrer account ID recorded at creation for external Move composition.
referrerReceiveAddress({required dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Returns the referrer's accumulator receive address for external Move composition.
settle({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Permissionlessly folds accumulator-delivered T at the wrapper address into stored account balance. The per-coin timestamp is latched before reading the accumulator, preventing duplicate withdrawal and same-timestamp double counting even when no funds are available. Only the wrapper UID can authenticate the address-balance withdrawal; value leaving the account still requires a mutable borrow through Auth.
share({required dynamic arguments, String? package, Map<String, dynamic>? config}) → MoveCallBuilder
Shares a newly created account wrapper.
withdraw({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
Withdraws from stored balance only; callers that include accumulator funds must settle through the wrapper first.
withdrawFunds({required dynamic arguments, String? package, List<String> typeArguments = const [], Map<String, dynamic>? config}) → MoveCallBuilder
PTB entrypoint that settles accumulator funds, consumes authority, and withdraws from stored balance in one call.

Typedefs

AccountConfig = AccountIds
The deployed ids of the shared account package this contract builds against.

Exceptions / Errors

ConfigurationError
Thrown when configuration is invalid or missing.
DeepBookError
Base class for DeepBook errors.
ValidationError
Thrown when transaction validation fails.