Skip to content

Aptos.ts

This module handles Aptos chain functionality.

Added in v2.0.0

Signature

export interface AptosBrowserWallet {
onDisconnect: () => void
disconnect: () => Promise<void>
isConnected: () => Promise<boolean>
connect: () => Promise<AptosPublicAccountInfo>
account: () => Promise<AptosPublicAccountInfo>
getAccount: () => Promise<AptosPublicAccountInfo>
network: () => Promise<Capitalize<AptosNetwork>>
getNetwork: () => Promise<AptosNetworkInfo>
onAccountChange: (callback: (account: AptosPublicAccountInfo & { type?: unknown }) => void) => void
onNetworkChange: (callback: (network: AptosNetworkInfo) => void) => void
/**
* @note
* for some reason, aptos wallets use snake case for tx payload params
* whereas aptos sdk uses camel case
*
* @warn don't go this route, just `signAndSubmitTransaction` to preserve your well-being
*/
signTransaction: (args: {
payload: AptosWalletTransactionPayload
options?: Prettify<KeysToSnakeCase<InputGenerateTransactionOptions>>
}) => Promise<{ accountAuthenticator: AccountAuthenticator; rawTxn: RawTransaction }>
signAndSubmitTransaction: (args: { payload: AptosWalletTransactionPayload }) => Promise<UserTransactionResponse>
}

Source: src/Aptos.ts:68

Added in v2.0.0

Signature

export interface AptosWalletTransactionPayload {
function: string
type_info?: string
type_arguments: Array<string>
arguments: Array<string | [string]>
}

Source: src/Aptos.ts:57

Added in v2.0.0

Signature

export type AuthAccess = "key" | "wallet"

Source: src/Aptos.ts:49

Added in v2.0.0

Signature

export type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}`
? `${T extends Capitalize<T> ? "_" : ""}${Lowercase<T>}${CamelToSnakeCase<U>}`
: S

Source: src/Aptos.ts:28

Added in v2.0.0

Signature

export type KeysToSnakeCase<T extends object> = {
[K in keyof T as CamelToSnakeCase<K & string>]: T[K]
}

Source: src/Aptos.ts:36

Added in v2.0.0

Signature

export type Prettify<T> = { [K in keyof T]: T[K] } & {}

Source: src/Aptos.ts:22

Added in v2.0.0