UNPKG

@xcapit/shelter-sdk

Version:

SDK for Shelter smart contracts on Stellar

325 lines (324 loc) 13.5 kB
import { Buffer } from "buffer"; import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, MethodOptions } from '@stellar/stellar-sdk/contract'; import type { u64, i128 } from '@stellar/stellar-sdk/contract'; export * from '@stellar/stellar-sdk'; export * as contract from '@stellar/stellar-sdk/contract'; export * as rpc from '@stellar/stellar-sdk/rpc'; export type Gate = { tag: "Open"; values: void; } | { tag: "Guarded"; values: void; } | { tag: "Sealed"; values: void; }; export interface Pass { public_key: Buffer; signature: Buffer; } export interface AidDataKey { recipient: Buffer; token: string; } export interface AidValue { amount: i128; expiration: u64; } export type DataKey = { tag: "Aid"; values: readonly [AidDataKey]; } | { tag: "AssignedAid"; values: readonly [string]; } | { tag: "Steward"; values: void; } | { tag: "ReleaseKey"; values: void; } | { tag: "GateState"; values: void; }; export declare const Errors: { 1: { message: string; }; 2: { message: string; }; 3: { message: string; }; 4: { message: string; }; 5: { message: string; }; 6: { message: string; }; 7: { message: string; }; }; export interface Client { /** * Construct and simulate a update_release_key transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ update_release_key: ({ steward_key }: { steward_key: Buffer; }, options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<null>>; /** * Construct and simulate a open transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ open: (options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<null>>; /** * Construct and simulate a guard transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ guard: (options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<null>>; /** * Construct and simulate a seal transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ seal: (options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<null>>; /** * Construct and simulate a release_key transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ release_key: (options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<Buffer>>; /** * Construct and simulate a steward transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ steward: (options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<string>>; /** * Construct and simulate a update_steward transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ update_steward: ({ new_steward }: { new_steward: string; }, options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<null>>; /** * Construct and simulate a bound_aid transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ bound_aid: ({ recipient, token, amount, expiration }: { recipient: Buffer; token: string; amount: i128; expiration: u64; }, options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<null>>; /** * Construct and simulate a unbound_aid transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ unbound_aid: ({ recipient, token }: { recipient: Buffer; token: string; }, options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<null>>; /** * Construct and simulate a aid_of transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ aid_of: ({ recipient, token }: { recipient: Buffer; token: string; }, options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<AidValue>>; /** * Construct and simulate a assigned_aid_of transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ assigned_aid_of: ({ token }: { token: string; }, options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<i128>>; /** * Construct and simulate a available_aid_of transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ available_aid_of: ({ token }: { token: string; }, options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise<AssembledTransaction<i128>>; } export declare class Client extends ContractClient { readonly options: ContractClientOptions; static deploy<T = Client>( /** Constructor/Initialization Args for the contract's `__constructor` method */ { steward }: { steward: string; }, /** Options for initalizing a Client as well as for calling a method, with extras specific to deploying. */ options: MethodOptions & Omit<ContractClientOptions, "contractId"> & { /** The hash of the Wasm blob, which must already be installed on-chain. */ wasmHash: Buffer | string; /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */ salt?: Buffer | Uint8Array; /** The format used to decode `wasmHash`, if it's provided as a string. */ format?: "hex" | "base64"; }): Promise<AssembledTransaction<T>>; constructor(options: ContractClientOptions); readonly fromJSON: { update_release_key: (json: string) => AssembledTransaction<null>; open: (json: string) => AssembledTransaction<null>; guard: (json: string) => AssembledTransaction<null>; seal: (json: string) => AssembledTransaction<null>; release_key: (json: string) => AssembledTransaction<Buffer<ArrayBufferLike>>; steward: (json: string) => AssembledTransaction<string>; update_steward: (json: string) => AssembledTransaction<null>; bound_aid: (json: string) => AssembledTransaction<null>; unbound_aid: (json: string) => AssembledTransaction<null>; aid_of: (json: string) => AssembledTransaction<AidValue>; assigned_aid_of: (json: string) => AssembledTransaction<bigint>; available_aid_of: (json: string) => AssembledTransaction<bigint>; }; }