@integraledger/lcp/casper
The exports of @integraledger/lcp/casper.
Interfaces
CasperCall
One executed contract call, as the reader reports it.
Properties
CasperChoice
Properties
| Property | Type |
|---|---|
accepted | PaymentRequirements |
from | string |
now | number |
required | PaymentRequired |
CasperReader
Bounded, read-only calls against one network's node. Every failure rejects with ReaderError.
Properties
Methods
transaction()
transaction(
hash):Promise<CasperCall|null>
info_get_transaction, as a Version1 transaction and then as a Deploy; null when the node knows neither.
Parameters
| Parameter | Type |
|---|---|
hash | string |
Returns
Promise<CasperCall | null>
CasperRef
The read keys recorded at claim.
Properties
| Property | Type |
|---|---|
asset | string |
idDigest | `0x${string}` |
network | `casper:${string}` |
settleBy | number |
transaction? | string |
CasperUnsigned
Properties
| Property | Type |
|---|---|
request | object |
request.kind | "casper-eip712" |
request.typedData | Cep3009TypedData |
Methods
complete()
complete(
publicKey,signature):Refusal|CasperPaymentPayload
Both arguments are hex with a one-byte algorithm tag: 01 ed25519, 02 secp256k1.
Parameters
| Parameter | Type |
|---|---|
publicKey | string |
signature | string |
Returns
Refusal | CasperPaymentPayload
Cep3009TypedData
Properties
| Property | Type | Description |
|---|---|---|
domain | object | - |
domain.chain_name | `casper:${string}` | - |
domain.contract_package_hash | string | - |
domain.name | string | - |
domain.version | string | - |
message | object | - |
message.from | string | - |
message.nonce | string | 64 hex digits, no prefix. |
message.to | string | - |
message.validAfter | bigint | - |
message.validBefore | bigint | - |
message.value | bigint | - |
primaryType | "TransferWithAuthorization" | - |
types | object | - |
types.EIP712Domain | Field[] | - |
types.TransferWithAuthorization | Field[] | - |
Type Aliases
CasperAddress
CasperAddress =
string
66 hex digits, no prefix: tag 00 (account hash) or 01 (package hash), then 32 bytes.
CasperAuthorization
CasperAuthorization =
object
Properties
CasperNetwork
CasperNetwork =
`casper:${string}`
CAIP-2: casper: and the chainspec name.
CasperPaymentPayload
CasperPaymentPayload =
object
Properties
| Property | Type |
|---|---|
accepted | PaymentRequirements |
extensions? | PaymentRequired["extensions"] |
payload | object |
payload.authorization | CasperAuthorization |
payload.publicKey | string |
payload.signature | string |
resource? | PaymentRequired["resource"] |
x402Version | 2 |
CasperStatus
CasperStatus = {
blockHeight:bigint;finality:"finalized";state:"settled"; } | {state:"pending";why:"not-found"|"not-executed"|"unreadable"; } | {state:"failed";why:"reverted"|"not-this-instrument"; }
PackageHash
PackageHash =
string
64 hex digits, no prefix.
Variables
CASPER_DOMAIN_TYPEHASH
constCASPER_DOMAIN_TYPEHASH:"0xe20dd13933eeb9d6099b53d5ffd59cfd50fe774983038681a378371664fad4fb"
keccak256("EIP712Domain(string name,string version,string chain_name,bytes32 contract_package_hash)")
exactCasper
constexactCasper:Readonly<{advertise:X402Advertise;bound: (presented) =>Promise<`0x${string}`|Refusal>;build: (c,h) =>Promise<Refusal|CasperUnsigned>;claims:boolean;id:"x402/exact/casper";pattern:LcpPattern;read: (doc) =>Refusal|X402Read;recover: (ref,reader) =>Promise<`0x${string}`|Refusal>;reference: (presented) =>Promise<Refusal|CasperRef>;status: (ref,reader) =>Promise<CasperStatus>;tie: (accepts,request) => ["x402", {accepts: readonlyPaymentRequirements[];request:RequestCommitment; }];unplaced: (option) =>PaymentRequirements; }>
Functions
casperIdDigest()
casperIdDigest(
from,to,value):Promise<`0x${string}`|Refusal>
SHA-256 over the 33 + 33 bytes of the two addresses and the value as a 32-byte big-endian integer.
Parameters
| Parameter | Type |
|---|---|
from | string |
to | string |
value | bigint |
Returns
Promise<`0x${string}` | Refusal>
casperOption()
casperOption(
o):o is PaymentRequirements
The pairing's filter: an exact option on a casper: network that build can turn into typed data.
Parameters
| Parameter | Type |
|---|---|
o | unknown |
Returns
o is PaymentRequirements
casperRecover()
casperRecover(
ref,reader):Promise<`0x${string}`|Refusal>
The hash from a settlement transaction alone: the nonce argument of the executed authorization call on asset.
Parameters
| Parameter | Type |
|---|---|
ref | { asset: string; network: `casper:${string}`; transaction: string; } |
ref.asset | string |
ref.network | `casper:${string}` |
ref.transaction | string |
reader | CasperReader |
Returns
Promise<`0x${string}` | Refusal>
casperStatus()
casperStatus(
ref,reader):Promise<CasperStatus>
Reads the named transaction. Settled, at the height of its block, when it executed without error as a call to
ref.asset's transfer_with_authorization or receive_with_authorization whose nonce argument is h and whose
from, to and value hash to ref.idDigest. A failed read, or a reader for another network, is pending.
Parameters
| Parameter | Type |
|---|---|
ref | CasperRef & object |
reader | CasperReader |
Returns
Promise<CasperStatus>
cep3009TypedData()
cep3009TypedData(
a):Refusal|Cep3009TypedData
The CEP-3009 typed data for TransferWithAuthorization, with validAfter 0 and the hash as the nonce.
Parameters
| Parameter | Type |
|---|---|
a | { asset: string; from: string; name: string; network: `casper:${string}`; nonce: `0x${string}`; to: string; validBefore: bigint; value: string; version: string; } |
a.asset | string |
a.from | string |
a.name | string |
a.network | `casper:${string}` |
a.nonce | `0x${string}` |
a.to | string |
a.validBefore | bigint |
a.value | string |
a.version | string |
Returns
Last updated on