UNPKG

wowok

Version:

Wowok Blockchain TypeScript API

362 lines (361 loc) 11.7 kB
import type { SerializedTransactionDataV2, TransactionPlugin } from "../transactions/index.js"; import type { ClientCache } from "./cache.js"; import type { Experimental_BaseClient } from "./client.js"; export type WowClientRegistration<T extends Experimental_BaseClient = Experimental_BaseClient, Name extends string = string, Extension = unknown> = { readonly name: Name; readonly register: (client: T) => Extension; }; export type ClientWithExtensions<T, Base extends Experimental_BaseClient = Experimental_BaseClient> = Base & T; export declare namespace Experimental_WowClientTypes { type Network = "mainnet" | "testnet" | "devnet" | "localnet" | (string & {}); interface WowClientOptions { network: Network; base?: Experimental_BaseClient; cache?: ClientCache; } interface CoreClientMethodOptions { signal?: AbortSignal; } interface TransportMethods { getObjects: (options: GetObjectsOptions) => Promise<GetObjectsResponse>; getOwnedObjects: (options: GetOwnedObjectsOptions) => Promise<GetOwnedObjectsResponse>; getCoins: (options: GetCoinsOptions) => Promise<GetCoinsResponse>; getDynamicFields: (options: GetDynamicFieldsOptions) => Promise<GetDynamicFieldsResponse>; getDynamicField: (options: GetDynamicFieldOptions) => Promise<GetDynamicFieldResponse>; } interface GetObjectsOptions extends CoreClientMethodOptions { objectIds: string[]; } interface GetObjectOptions extends CoreClientMethodOptions { objectId: string; } interface GetOwnedObjectsOptions extends CoreClientMethodOptions { address: string; limit?: number; cursor?: string | null; type?: string; } interface GetCoinsOptions extends CoreClientMethodOptions { address: string; coinType: string; limit?: number; cursor?: string | null; } interface GetDynamicFieldsOptions extends CoreClientMethodOptions { parentId: string; limit?: number; cursor?: string | null; } interface GetDynamicFieldOptions extends CoreClientMethodOptions { parentId: string; name: DynamicFieldName; } interface GetObjectsResponse { objects: (ObjectResponse | Error)[]; } interface GetObjectResponse { object: ObjectResponse; } interface GetOwnedObjectsResponse { objects: ObjectResponse[]; hasNextPage: boolean; cursor: string | null; } interface GetCoinsResponse { objects: CoinResponse[]; hasNextPage: boolean; cursor: string | null; } interface ObjectResponse { id: string; version: string; digest: string; owner: ObjectOwner; type: string; content: PromiseLike<Uint8Array>; previousTransaction: string | null; } interface CoinResponse extends ObjectResponse { balance: string; } interface GetDynamicFieldsResponse { hasNextPage: boolean; cursor: string | null; dynamicFields: { id: string; type: string; name: DynamicFieldName; }[]; } interface GetDynamicFieldResponse { dynamicField: { name: DynamicFieldName; value: DynamicFieldValue; id: string; version: string; digest: string; type: string; previousTransaction: string | null; }; } interface DynamicFieldName { type: string; bcs: Uint8Array; } interface DynamicFieldValue { type: string; bcs: Uint8Array; } interface TransportMethods { getBalance: (options: GetBalanceOptions) => Promise<GetBalanceResponse>; getAllBalances: (options: GetAllBalancesOptions) => Promise<GetAllBalancesResponse>; } interface GetBalanceOptions extends CoreClientMethodOptions { address: string; coinType: string; } interface CoinBalance { coinType: string; balance: string; } interface GetBalanceResponse { balance: CoinBalance; } interface GetAllBalancesOptions extends CoreClientMethodOptions { address: string; limit?: number; cursor?: string | null; } interface GetAllBalancesResponse { balances: CoinBalance[]; hasNextPage: boolean; cursor: string | null; } interface TransportMethods { getTransaction: (options: GetTransactionOptions) => Promise<GetTransactionResponse>; executeTransaction: (options: ExecuteTransactionOptions) => Promise<ExecuteTransactionResponse>; dryRunTransaction: (options: DryRunTransactionOptions) => Promise<DryRunTransactionResponse>; resolveTransactionPlugin: () => TransactionPlugin; } interface TransactionResponse { digest: string; signatures: string[]; epoch: string | null; effects: TransactionEffects; objectTypes: PromiseLike<Record<string, string>>; transaction: TransactionData; balanceChanges: BalanceChange[]; } interface BalanceChange { coinType: string; address: string; amount: string; } interface TransactionData extends SerializedTransactionDataV2 { bcs: Uint8Array; } interface GetTransactionOptions extends CoreClientMethodOptions { digest: string; } interface GetTransactionResponse { transaction: TransactionResponse; } interface ExecuteTransactionOptions extends CoreClientMethodOptions { transaction: Uint8Array; signatures: string[]; } interface DryRunTransactionOptions extends CoreClientMethodOptions { transaction: Uint8Array; } interface DryRunTransactionResponse { transaction: TransactionResponse; } interface ExecuteTransactionResponse { transaction: TransactionResponse; } interface GetReferenceGasPriceOptions extends CoreClientMethodOptions { } interface TransportMethods { getReferenceGasPrice?: (options?: GetReferenceGasPriceOptions) => Promise<GetReferenceGasPriceResponse>; } interface GetReferenceGasPriceResponse { referenceGasPrice: string; } interface TransportMethods { getMoveFunction: (options: GetMoveFunctionOptions) => Promise<GetMoveFunctionResponse>; } interface GetMovePackageOptions extends CoreClientMethodOptions { packageId: string; } interface GetMovePackageResponse { package: PackageResponse; } interface PackageResponse { storageId: string; originalId: string; version: string; modules: ModuleResponse[]; } interface ModuleResponse { name: string; datatypes: DatatypeResponse[]; functions: FunctionResponse[]; } type DatatypeResponse = { $kind: "struct"; typeName: string; definingId: string; moduleName: string; name: string; abilities: Ability[]; typeParameters: TypeParameter[]; fields: FieldDescriptor[]; } | { $kind: "enum"; typeName: string; definingId: string; moduleName: string; name: string; abilities: Ability[]; typeParameters: TypeParameter[]; variants: VariantDescriptor[]; }; type Ability = "copy" | "drop" | "store" | "key" | "unknown"; type DatatypeKind = "struct" | "enum" | "unknown"; interface TypeParameter { constraints: Ability[]; isPhantom: boolean; } interface FieldDescriptor { name: string; position: number; type: OpenSignatureBody; } interface VariantDescriptor { name: string; position: number; fields: FieldDescriptor[]; } interface GetMoveFunctionOptions extends CoreClientMethodOptions { packageId: string; moduleName: string; name: string; } interface GetMoveFunctionResponse { function: FunctionResponse; } interface GetMoveDatatypeOptions extends CoreClientMethodOptions { packageId: string; moduleName: string; name: string; } interface GetMoveDatatypeResponse { datatype: DatatypeResponse; } type Visibility = "public" | "friend" | "private" | "unknown"; interface FunctionResponse { packageId: string; moduleName: string; name: string; visibility: Visibility; isEntry: boolean; typeParameters: TypeParameter[]; parameters: OpenSignature[]; returns: OpenSignature[]; } type ReferenceType = "mutable" | "immutable" | "unknown"; type OpenSignature = { reference: ReferenceType | null; body: OpenSignatureBody; }; type OpenSignatureBody = { $kind: "u8" | "u16" | "u32" | "u64" | "u128" | "u256" | "bool" | "address" | "unknown"; } | { $kind: "vector"; vector: OpenSignatureBody; } | { $kind: "datatype"; datatype: { typeName: string; typeParameters: OpenSignatureBody[]; }; } | { $kind: "typeParameter"; index: number; }; interface AddressOwner { $kind: "AddressOwner"; AddressOwner: string; } interface ParentOwner { $kind: "ObjectOwner"; ObjectOwner: string; } interface SharedOwner { $kind: "Shared"; Shared: { initialSharedVersion: string; }; } interface ImmutableOwner { $kind: "Immutable"; Immutable: true; } interface ConsensusAddressOwner { $kind: "ConsensusAddressOwner"; ConsensusAddressOwner: { owner: string; startVersion: string; }; } interface UnknownOwner { $kind: "Unknown"; } type ObjectOwner = AddressOwner | ParentOwner | SharedOwner | ImmutableOwner | ConsensusAddressOwner | UnknownOwner; interface TransactionEffects { bcs: Uint8Array | null; digest: string; version: number; status: ExecutionStatus; gasUsed: GasCostSummary; transactionDigest: string; gasObject: ChangedObject | null; eventsDigest: string | null; dependencies: string[]; lamportVersion: string | null; changedObjects: ChangedObject[]; unchangedConsensusObjects: UnchangedConsensusObject[]; auxiliaryDataDigest: string | null; } interface ChangedObject { id: string; inputState: "Unknown" | "DoesNotExist" | "Exists"; inputVersion: string | null; inputDigest: string | null; inputOwner: ObjectOwner | null; outputState: "Unknown" | "DoesNotExist" | "ObjectWrite" | "PackageWrite"; outputVersion: string | null; outputDigest: string | null; outputOwner: ObjectOwner | null; idOperation: "Unknown" | "None" | "Created" | "Deleted"; } interface GasCostSummary { computationCost: string; storageCost: string; storageRebate: string; nonRefundableStorageFee: string; } type ExecutionStatus = { success: true; error: null; } | { success: false; error: string; }; interface UnchangedConsensusObject { kind: "Unknown" | "ReadOnlyRoot" | "MutateConsensusStreamEnded" | "ReadConsensusStreamEnded" | "Cancelled" | "PerEpochConfig"; objectId: string; version: string | null; digest: string | null; } }