@integraledger/lcp/aptos
The exports of @integraledger/lcp/aptos.
Interfaces
AptosCommitted
A committed user transaction as the REST API returns it.
Properties
AptosInstrument
The transfer the payer signed, in one normal form shared by the signed bytes and the chain's REST answer.
Properties
| Property | Type |
|---|---|
arguments | readonly string[] |
chainId | number |
expiresAt | bigint |
function | string |
sender | `0x${string}` |
sequenceNumber | bigint |
typeArguments | readonly string[] |
AptosPaymentPayload
Properties
| Property | Type |
|---|---|
accepted | PaymentRequirements |
extensions? | object |
payload | object |
payload.transaction | string |
resource? | object |
resource.url | string |
x402Version | 2 |
AptosReader
Bounded, read-only calls against one network's REST endpoint. Every failure rejects with ReaderError.
Properties
Methods
byHash()
byHash(
hash):Promise<AptosCommitted| {type:"pending_transaction"; } |null>
GET /v1/transactions/by_hash/{hash}; null on 404.
Parameters
| Parameter | Type |
|---|---|
hash | `0x${string}` |
Returns
Promise<AptosCommitted | { type: "pending_transaction"; } | null>
bySequence()
bySequence(
sender,n):Promise<AptosCommitted|null>
GET /v1/accounts/{sender}/transactions?start=n&limit=1, kept only when its sequence_number is n.
Parameters
| Parameter | Type |
|---|---|
sender | `0x${string}` |
n | bigint |
Returns
Promise<AptosCommitted | null>
ledger()
ledger():
Promise<{chainId:number;timestampUsecs:bigint; }>
GET /v1.
Returns
Promise<{ chainId: number; timestampUsecs: bigint; }>
AptosRef
Properties
AptosUnsigned
Properties
| Property | Type |
|---|---|
request | object |
request.accepted | PaymentRequirements |
request.kind | "aptos-transaction" |
Methods
complete()
complete(
signed):Refusal|AptosPaymentPayload
Parameters
| Parameter | Type |
|---|---|
signed | { transaction: string; } |
signed.transaction | string |
Returns
Type Aliases
AptosNetwork
AptosNetwork =
`aptos:${number}`
CAIP-2: aptos: and the numeric chain id.
AptosStatus
AptosStatus = {
state:"settled";transaction:Hex;version:bigint; } | {state:"pending";why:"not-found"|"in-mempool"|"unreadable"; } | {state:"failed";why:"aborted"|"superseded"|"expired"; }
Variables
exactAptos
constexactAptos:Readonly<{advertise: (doc,h,link,offer,agreementUrl?) =>Refusal|PaymentRequired;bound: (presented) =>Promise<`0x${string}`|Refusal>;build: (choice,h) =>Promise<Refusal|AptosUnsigned>;carrier:null;claims:boolean;id:"x402/exact/aptos";pattern:LcpPattern;read: (doc) =>Refusal|X402Read;reference: (presented) =>Promise<Refusal|AptosRef>;status: (ref,reader) =>Promise<AptosStatus>;tie: (accepts,request) => ["x402", {accepts: readonlyPaymentRequirements[];request:RequestCommitment; }];unplaced: (option) =>PaymentRequirements; }>
Functions
aptosIdDigest()
aptosIdDigest(
i):Promise<`0x${string}`|Refusal>
SHA-256 over the RFC 8785 form of {sender, sequenceNumber, function, typeArguments, arguments}.
Parameters
| Parameter | Type |
|---|---|
i | AptosInstrument |
Returns
Promise<`0x${string}` | Refusal>
aptosOptionCheck()
aptosOptionCheck(
option):Refusal|undefined
The pairing's filter: undefined for an option this pairing can pay, or the refusal naming why not.
Parameters
| Parameter | Type |
|---|---|
option | unknown |
Returns
Refusal | undefined
aptosPairingOf()
aptosPairingOf(
option):"x402/exact/aptos"|undefined
This pairing's id for an option it can pay, or undefined.
Parameters
| Parameter | Type |
|---|---|
option | PaymentRequirements |
Returns
"x402/exact/aptos" | undefined
aptosStatus()
aptosStatus(
ref,reader):Promise<AptosStatus>
Finds the payer's transaction by the facilitator's hash when named, else by sender and sequence number, and
identifies it by the transfer's digest. Only success decides a committed, matching transaction. A failed read,
or a reader for another network, is pending. At most three calls.
Parameters
| Parameter | Type |
|---|---|
ref | AptosRef |
reader | AptosReader |
Returns
Promise<AptosStatus>
committedInstrument()
committedInstrument(
t,chainId):Refusal|AptosInstrument
The REST answer in the normal form: every address as 0x and 64 lowercase hex, {"inner": a} as a, and the
amount as its decimal string. The REST answer carries no chain id, so the caller supplies the ledger's.
Parameters
| Parameter | Type |
|---|---|
t | AptosCommitted |
chainId | number |
Returns
decodeAptosTx()
decodeAptosTx(
transaction):Refusal|AptosInstrument
Reads the RawTransaction prefix of a base64 transaction, in either wire form: the scheme's BCS bytes, or x402's
reference form, base64 of the JSON {"transaction": [bytes], "senderAuthenticator": [bytes]}. Only an entry
function call to a framework fungible-asset transfer is accepted.
Parameters
| Parameter | Type |
|---|---|
transaction | string |
Returns
Last updated on