Chain helpers, errors, aborts
Results of executed transactions, read-only calls, the SDK's error type and the Move abort map.
Signatures below are copied from the source; descriptions are the source's own doc comments.
From chain.ts#
Exported by index.ts.
Landed#
export type Landed = {
ok: boolean;
digest: string;
status: unknown;
objectTypes: Record<string, string>;
events: { eventType: string; json?: unknown }[];
/** Set when the chain refused the transaction; it still landed and its digest is real. */
abort?: Abort;
/**
* Whether the read-back wait found the transaction. False means it landed anyway and indexError says what the wait
* hit; undefined means no wait was made (landedOf reads a transaction already on chain).
*/
indexed?: boolean;
indexError?: string;
};GasMode#
address-balance: gas from the sender's address balance (fund it with 0x2::coin::send_funds), so every SUI coin it holds stays usable; coins: gas from one of its SUI coins, the usual wallet setup.
export type GasMode = "address-balance" | "coins";ChainEvent#
export type ChainEvent = {
txDigest: string;
seq: number;
type: string;
sender: string;
json: Record<string, unknown>;
timestampMs?: number;
};EventSource#
export type EventSource = (moveEventType: string, sender?: string | null) => Promise<ChainEvent[]>;EventReader#
Up to pages pages of events after after (null: from the first); cursor resumes after the last one read.
export type EventReader = (
moveEventType: string,
sender: string | null,
after: unknown,
pages: number,
) => Promise<EventPages>;TouchReader#
Every event of every transaction that touched an object, oldest first: at most pages requests and pages x 50 events.
export type TouchReader = (objectId: string, after: unknown, pages: number) => Promise<EventPages>;Simulated#
export type Simulated = { ok: true; values: Uint8Array[][] } | { ok: false; status: unknown };landedOf#
A transaction someone else executed, read back in executeAsAgent's shape.
export async function landedOf(client: SuiGrpcClient, digest: string): Promise<Landed>createdOf#
export function createdOf(landed: { objectTypes?: Record<string, string> }, fragment: string): string[]oneCreated#
export function oneCreated(
landed: { digest: string; objectTypes?: Record<string, string> },
fragment: string,
)simulate#
Read-only Move calls (the reader, quote_bps, owed, ltv_bps): simulated, never signed.
export async function simulate(
client: SuiGrpcClient,
sender: string,
build: (tx: Transaction) => void,
): Promise<Simulated>From errors.ts#
Exported by index.ts.
ESSEY_ERROR_CODES#
export const ESSEY_ERROR_CODES = [
"NETWORK_REFUSED",
"KEY_FILE_REFUSED",
"KEYS_NOT_SEPARATE",
"OWNER_CAP_PUBLIC",
"OWNER_CAP_UNVERIFIABLE",
"AGENT_CAP_MISMATCH",
"NOT_SET_UP",
"NO_POOL",
"NO_ACCESS",
"NO_CASH_TREASURY",
"NO_COINS",
"NOT_FOUND",
"READ_FAILED",
"INVALID_ARGUMENT",
"PROOF_BUNDLE_REFUSED",
"NOT_INDEXED",
"SERVICE_REFUSED",
"INDEX_LOADING",
"NOT_AGENT_CALL",
"NOT_OWNER_TX",
"SETUP_MISMATCH",
"SELLER_CANNOT_BID",
"OVER_GAS_CAP",
"WOULD_ABORT",
"OVER_MANDATE_CAP",
"LENDER_SHORT",
] as const;EsseyErrorCode#
Stable names; new codes may be added, existing ones are never renamed. KEYS_NOT_SEPARATE, OWNER_CAP_PUBLIC, OWNER_CAP_UNVERIFIABLE and AGENT_CAP_MISMATCH come from the key-separation check and mean nothing was signed.
export type EsseyErrorCode = (typeof ESSEY_ERROR_CODES)[number];EsseyError#
export class EsseyError extends ErrorisEsseyError#
export const isEsseyError = (err: unknown, code?: EsseyErrorCode): err is EsseyError => …From aborts.ts#
Exported by index.ts.
Abort#
export type Abort =
| { kind: "move-abort"; module: string; fn: string; code: number; name: string | null }
| { kind: "other"; message: string };MOVE_ABORTS#
essey_sui's abort constants by module and code; test/aborts.test.ts holds this equal to the Move sources.
export const MOVE_ABORTS: Record<string, Record<number, string>> = {
borrower: { 1: "EWrongCash", 2: "ENoDeed" },
loan: {
1: "EWrongDeed",
2: "ENotOpen",
3: "EOverMarketLtv",
4: "EUnderpaid",
5: "EHealthy",
6: "ESolvent",
7: "EBelowFloor",
8: "EOverOwed",
9: "EWrongLender",
10: "EZeroAmount",
12: "ETicketMismatch",
13: "ENotOfferLoan",
17: "ENotClosed",
19: "ENotPoolLoan",
20: "ENotDue",
21: "EWrongClaim",
},
loan_room: {
1: "ENotBorrower",
2: "ENotOpen",
3: "EBadRoom",
4: "EClosed",
5: "EBadCiphertext",
6: "EBadCommitment",
7: "ENotClosed",
8: "ESettleWindowClosed",
9: "ENoSuchOffer",
10: "EOverMaxRate",
11: "ECommitmentMismatch",
12: "EWrongMarket",
13: "ESettleWindowOpen",
14: "ENoAccess",
},
private_room: {
1: "ENotBorrower",
2: "EBadState",
3: "EBadParams",
4: "EWrongPool",
5: "EWrongMarket",
6: "ENotMember",
7: "EDuplicateTag",
8: "EOfferWindowClosed",
9: "ENotClosed",
10: "ESettleWindowClosed",
11: "EBadReveal",
12: "ENoWinner",
13: "ETooManyOffers",
14: "EOverLtv",
15: "ENotUnderwater",
16: "ENotDue",
17: "EUnderpaid",
18: "ENoAccess",
19: "EBorrowerIsLender",
20: "ENotCancellable",
21: "EBadCommit",
},
market: {
1: "EMarketExists",
2: "EBadParams",
3: "ENoPending",
4: "ETimelock",
5: "EWrongFeed",
6: "EDeprecationOrder",
},
offer: {
1: "EWrongTreasury",
2: "EWrongCap",
3: "EOfferExpired",
4: "EFillOutOfBounds",
5: "EOverSize",
6: "EOverLtv",
},
pool: {
1: "EBadCurve",
2: "EZeroAmount",
3: "EZeroShares",
4: "EWrongPool",
5: "EInsufficientCash",
6: "EOverShares",
},
price: { 1: "EStale", 2: "EWideConfidence", 3: "ENonPositive", 4: "EBadExponent" },
treasury: {
1: "EWrongTreasury",
2: "ECapRevoked",
3: "ECapExpired",
4: "EOverPerTx",
5: "EOverPerDay",
6: "ERecipientNotAllowed",
7: "EBadLimits",
8: "EZeroAmount",
9: "EInsufficientFunds",
10: "EBadRecipients",
11: "ENoMandate",
12: "EBadMandate",
13: "EOverTotalCap",
14: "EFillOutOfBounds",
15: "ECollateralNotAllowed",
16: "EOverLtv",
17: "ERateBelowFloor",
18: "EDurationNotAllowed",
19: "ETakerNotAllowed",
20: "EOfferExpiry",
21: "EBadConsent",
22: "ENoConsent",
23: "ENoBorrowMandate",
24: "ERateAboveCeiling",
25: "ETermTooShort",
26: "EPastRepayBy",
27: "EPoolNotAllowed",
28: "ECashNotAllowed",
29: "EOverAllowance",
},
};parseAbort#
export function parseAbort(status: unknown): Abort