@outpost-protocol/core 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/cert0.d.ts +12 -0
- package/dist/cert0.js +125 -0
- package/dist/contracts.d.ts +256 -0
- package/dist/contracts.js +665 -0
- package/dist/coordinators.d.ts +131 -0
- package/dist/coordinators.js +457 -0
- package/dist/hw.d.ts +243 -0
- package/dist/hw.js +858 -0
- package/dist/hwClient.d.ts +270 -0
- package/dist/hwClient.js +794 -0
- package/dist/hwTransport.d.ts +173 -0
- package/dist/hwTransport.js +431 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/wallet.d.ts +43 -4
- package/dist/wallet.js +136 -5
- package/dist/walletStorage.d.ts +128 -0
- package/dist/walletStorage.js +399 -0
- package/dist/wire.d.ts +10 -0
- package/dist/wire.js +31 -0
- package/dist/witnessClient.d.ts +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,9 @@ npm install @outpost-protocol/core
|
|
|
14
14
|
|
|
15
15
|
- **Wire Codecs (`SREQ1`, `SMESHI1`, `SMESHC1`, `SMESHD1`, `SMESHF1`, BC-UR)** — strict `BigInt` asset-agnostic encoding/decoding with CRC-32C framing, canonical Base32, and cross-language golden-vector parity with Soroban & Rust (`outpost-wire`).
|
|
16
16
|
- **Cryptographic Digests & Vault Derivation** — cofactorless RFC 8032 Ed25519 helpers, canonical `UserVault` deterministic ID derivation, and domain-separated `GENESIS` / `INTENT` / `WITNESS_LOCK` / `WITNESS_CERT` preimages.
|
|
17
|
-
- **
|
|
17
|
+
- **Soroban Contract Call Builders (`0.2.0+`)** — browser/WebView-safe `buildCreateVaultOp`, `buildDepositOp`, `buildSettleDelegatedOp`, `buildClosePocketCooperativeOp`, `buildRequestExitOp`, `buildFinalizeExitOp`, `buildClaimCreditOp`, plus view builders and `decodePocketStateScVal`.
|
|
18
|
+
- **Multi-Witness Coordinators (`0.2.0+`)** — `coordinateInitGenesis` (`cert_0` assembly + propagation), `coordinateRefreshFreshness` (`fresh_cert` assembly + propagation), and `coordinateCloseCooperative` (verified close signatures).
|
|
19
|
+
- **Non-Custodial `OfflineWallet` & `JsonWalletStorage`** — per-pocket async mutex, burn-before-display monotonic `localSeq`, running pocket budget enforcement (`getPocketBudget`), portable JSON state persistence (`JsonWalletStorage` / `serializeWalletState`), asset-agnostic untrusted `SREQ1.tip` caps, duplicate `(recipient, orderId)` retry protection, and authenticated `SEQ_TOO_LOW` resync.
|
|
18
20
|
- **Direct & Classic Settlement Builders** — `order_id`-bound CAP-0046-11 `relay_direct` (`SMESHD1`) and hardened CAP-0015 `FeeBumpTransaction` (`SMESHF1`).
|
|
19
21
|
- **Station Transports** — `WitnessClient` (LAN/WAN HTTP) and `BleWitnessClient` (`OUTPOST_BLE_V1` GATT framing for internet-free mobile/POS witnessing).
|
|
20
22
|
|
package/dist/cert0.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EpochGenesisCert } from "./wire.js";
|
|
2
|
+
/**
|
|
3
|
+
* Encode `EpochGenesisCert` (`cert_0`) into the exact binary layout specified by
|
|
4
|
+
* `WIRE-FORMAT-v1.2.md §4.5` (identical to the embedded `cert_0` suffix of `SMESHC1`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function encodeCert0Bytes(cert0: EpochGenesisCert): Uint8Array;
|
|
7
|
+
/**
|
|
8
|
+
* Decode binary `EpochGenesisCert` (`cert_0`) bytes (`WIRE-FORMAT-v1.2.md §4.5`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function decodeCert0Bytes(raw: Uint8Array): EpochGenesisCert;
|
|
11
|
+
export declare function encodeCert0Hex(cert0: EpochGenesisCert): string;
|
|
12
|
+
export declare function decodeCert0Hex(hex: string): EpochGenesisCert;
|
package/dist/cert0.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { assertBigInt, assertBytesLength, assertSortedUniqueWitnesses, assertU32, assertU8, concatBytes, decodeU32Be, decodeU64Be, encodeU32Be, encodeU64Be, encodeU8, MAX_U64, MAX_WITNESSES, } from "./digest.js";
|
|
2
|
+
import { bytesToHex, hexToBytes } from "./witnessClient.js";
|
|
3
|
+
import { decodeWireToken, encodeWireToken } from "./xdr.js";
|
|
4
|
+
/**
|
|
5
|
+
* Encode `EpochGenesisCert` (`cert_0`) into the exact binary layout specified by
|
|
6
|
+
* `WIRE-FORMAT-v1.2.md §4.5` (identical to the embedded `cert_0` suffix of `SMESHC1`).
|
|
7
|
+
*/
|
|
8
|
+
export function encodeCert0Bytes(cert0) {
|
|
9
|
+
assertBytesLength(cert0.devicePubkey, 32, "cert0.devicePubkey");
|
|
10
|
+
assertBigInt(cert0.epochTotalDeposited, "cert0.epochTotalDeposited");
|
|
11
|
+
if (cert0.epochTotalDeposited <= 0n || cert0.epochTotalDeposited > MAX_U64) {
|
|
12
|
+
throw new Error(`cert0.epochTotalDeposited out of u64 (>0) range: ${cert0.epochTotalDeposited}`);
|
|
13
|
+
}
|
|
14
|
+
assertBigInt(cert0.exitDelaySecs, "cert0.exitDelaySecs");
|
|
15
|
+
assertBigInt(cert0.syncedAtTs, "cert0.syncedAtTs");
|
|
16
|
+
assertU32(cert0.syncedLedgerSeq, "cert0.syncedLedgerSeq");
|
|
17
|
+
assertSortedUniqueWitnesses(cert0.witnesses);
|
|
18
|
+
const n = cert0.witnesses.length;
|
|
19
|
+
assertU8(cert0.witnessThreshold, "cert0.witnessThreshold");
|
|
20
|
+
if (cert0.witnessThreshold < 1 || cert0.witnessThreshold > n || cert0.witnessThreshold * 2 <= n) {
|
|
21
|
+
throw new Error(`cert0.witnessThreshold (${cert0.witnessThreshold}) must satisfy 0 < t <= n and 2t > n`);
|
|
22
|
+
}
|
|
23
|
+
if (cert0.genesisSigs.length < 1 || cert0.genesisSigs.length > n) {
|
|
24
|
+
throw new Error(`cert0.genesisSigs count must be in 1..=${n}`);
|
|
25
|
+
}
|
|
26
|
+
let prevIdx = -1;
|
|
27
|
+
const parts = [
|
|
28
|
+
encodeWireToken(cert0.token),
|
|
29
|
+
cert0.devicePubkey,
|
|
30
|
+
encodeU64Be(cert0.epochTotalDeposited, "cert0.epochTotalDeposited"),
|
|
31
|
+
encodeU64Be(cert0.exitDelaySecs, "cert0.exitDelaySecs"),
|
|
32
|
+
encodeU64Be(cert0.syncedAtTs, "cert0.syncedAtTs"),
|
|
33
|
+
encodeU32Be(cert0.syncedLedgerSeq, "cert0.syncedLedgerSeq"),
|
|
34
|
+
encodeU8(cert0.witnessThreshold, "cert0.witnessThreshold"),
|
|
35
|
+
encodeU8(n, "n_witnesses"),
|
|
36
|
+
...cert0.witnesses,
|
|
37
|
+
encodeU8(cert0.genesisSigs.length, "genesis_sig_count"),
|
|
38
|
+
];
|
|
39
|
+
for (const sig of cert0.genesisSigs) {
|
|
40
|
+
if (!Number.isInteger(sig.index) || sig.index < 0 || sig.index >= n || sig.index <= prevIdx) {
|
|
41
|
+
throw new Error("cert0.genesisSigs indices must be strictly ascending and in bounds");
|
|
42
|
+
}
|
|
43
|
+
assertBytesLength(sig.signature, 64, "cert0.genesisSig.signature");
|
|
44
|
+
prevIdx = sig.index;
|
|
45
|
+
parts.push(encodeU8(sig.index, "genesisSig.index"), sig.signature);
|
|
46
|
+
}
|
|
47
|
+
return concatBytes(...parts);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Decode binary `EpochGenesisCert` (`cert_0`) bytes (`WIRE-FORMAT-v1.2.md §4.5`).
|
|
51
|
+
*/
|
|
52
|
+
export function decodeCert0Bytes(raw) {
|
|
53
|
+
let offset = 0;
|
|
54
|
+
const { token, bytesRead: tokenBytes } = decodeWireToken(raw, offset);
|
|
55
|
+
offset += tokenBytes;
|
|
56
|
+
if (offset + 62 > raw.length) {
|
|
57
|
+
throw new Error("Truncated cert_0 binary payload");
|
|
58
|
+
}
|
|
59
|
+
const devicePubkey = raw.slice(offset, offset + 32);
|
|
60
|
+
offset += 32;
|
|
61
|
+
const epochTotalDeposited = decodeU64Be(raw, offset);
|
|
62
|
+
offset += 8;
|
|
63
|
+
if (epochTotalDeposited <= 0n) {
|
|
64
|
+
throw new Error(`cert_0 epochTotalDeposited must be > 0, got ${epochTotalDeposited}`);
|
|
65
|
+
}
|
|
66
|
+
const exitDelaySecs = decodeU64Be(raw, offset);
|
|
67
|
+
offset += 8;
|
|
68
|
+
const syncedAtTs = decodeU64Be(raw, offset);
|
|
69
|
+
offset += 8;
|
|
70
|
+
const syncedLedgerSeq = decodeU32Be(raw, offset);
|
|
71
|
+
offset += 4;
|
|
72
|
+
const witnessThreshold = raw[offset++];
|
|
73
|
+
const nWitnesses = raw[offset++];
|
|
74
|
+
if (nWitnesses < 1 || nWitnesses > MAX_WITNESSES) {
|
|
75
|
+
throw new Error(`Invalid cert_0 n_witnesses: ${nWitnesses}`);
|
|
76
|
+
}
|
|
77
|
+
if (witnessThreshold < 1 || witnessThreshold > nWitnesses || witnessThreshold * 2 <= nWitnesses) {
|
|
78
|
+
throw new Error(`Invalid cert_0 witnessThreshold=${witnessThreshold} for n=${nWitnesses}`);
|
|
79
|
+
}
|
|
80
|
+
if (offset + nWitnesses * 32 + 1 > raw.length) {
|
|
81
|
+
throw new Error("Truncated cert_0 witnesses list");
|
|
82
|
+
}
|
|
83
|
+
const witnesses = [];
|
|
84
|
+
for (let i = 0; i < nWitnesses; i++) {
|
|
85
|
+
witnesses.push(raw.slice(offset, offset + 32));
|
|
86
|
+
offset += 32;
|
|
87
|
+
}
|
|
88
|
+
assertSortedUniqueWitnesses(witnesses);
|
|
89
|
+
const genesisSigCount = raw[offset++];
|
|
90
|
+
if (genesisSigCount < 1 || genesisSigCount > nWitnesses) {
|
|
91
|
+
throw new Error(`Invalid cert_0 genesis_sig_count: ${genesisSigCount}`);
|
|
92
|
+
}
|
|
93
|
+
if (offset + genesisSigCount * 65 !== raw.length) {
|
|
94
|
+
throw new Error("Truncated or trailing bytes in cert_0 genesis_sigs");
|
|
95
|
+
}
|
|
96
|
+
const genesisSigs = [];
|
|
97
|
+
let prevIdx = -1;
|
|
98
|
+
for (let i = 0; i < genesisSigCount; i++) {
|
|
99
|
+
const index = raw[offset++];
|
|
100
|
+
const signature = raw.slice(offset, offset + 64);
|
|
101
|
+
offset += 64;
|
|
102
|
+
if (index >= nWitnesses || index <= prevIdx) {
|
|
103
|
+
throw new Error("cert_0 genesis_sigs indices must be strictly ascending and in bounds");
|
|
104
|
+
}
|
|
105
|
+
prevIdx = index;
|
|
106
|
+
genesisSigs.push({ index, signature });
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
token,
|
|
110
|
+
devicePubkey,
|
|
111
|
+
epochTotalDeposited,
|
|
112
|
+
exitDelaySecs,
|
|
113
|
+
syncedAtTs,
|
|
114
|
+
syncedLedgerSeq,
|
|
115
|
+
witnessThreshold,
|
|
116
|
+
witnesses,
|
|
117
|
+
genesisSigs,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export function encodeCert0Hex(cert0) {
|
|
121
|
+
return bytesToHex(encodeCert0Bytes(cert0));
|
|
122
|
+
}
|
|
123
|
+
export function decodeCert0Hex(hex) {
|
|
124
|
+
return decodeCert0Bytes(hexToBytes(hex));
|
|
125
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Soroban Contract Call Operation Builders for Outpost v1.2 (`VaultFactory` & `UserVault`).
|
|
3
|
+
*
|
|
4
|
+
* Pure browser/WebView/Node compatible (uses `Uint8Array`, zero Node `Buffer` dependencies)
|
|
5
|
+
* and 100% asset-agnostic across all Stellar SAC and SEP-41 token contracts.
|
|
6
|
+
*/
|
|
7
|
+
import * as StellarSdk from "@stellar/stellar-sdk";
|
|
8
|
+
import { type HwKind, type HwProof } from "./hw.js";
|
|
9
|
+
import { type IndexedWitnessSignature, type Smeshc1Packet } from "./wire.js";
|
|
10
|
+
import { type WireAddress } from "./xdr.js";
|
|
11
|
+
/**
|
|
12
|
+
* Low-level Soroban `InvokeHostFunctionOp` (`HostFunctionType::InvokeContract`) builder.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildContractCallOp(contractId: string | WireAddress | Uint8Array, method: string, args: readonly StellarSdk.xdr.ScVal[], auth?: readonly StellarSdk.xdr.SorobanAuthorizationEntry[]): StellarSdk.xdr.Operation;
|
|
15
|
+
export interface CreateVaultOpParams {
|
|
16
|
+
readonly factoryId: string | WireAddress | Uint8Array;
|
|
17
|
+
readonly owner: WireAddress | string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build `VaultFactory.create_vault(owner: Address) -> Address`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildCreateVaultOp(params: CreateVaultOpParams): StellarSdk.xdr.Operation;
|
|
23
|
+
/**
|
|
24
|
+
* Build read-only view call `VaultFactory.expected_vault(owner: Address) -> Address`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildExpectedVaultOp(params: CreateVaultOpParams): StellarSdk.xdr.Operation;
|
|
27
|
+
/**
|
|
28
|
+
* Build read-only view call `VaultFactory.user_vault_wasm_hash() -> BytesN<32>`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildUserVaultWasmHashOp(params: {
|
|
31
|
+
readonly factoryId: string | WireAddress | Uint8Array;
|
|
32
|
+
}): StellarSdk.xdr.Operation;
|
|
33
|
+
/**
|
|
34
|
+
* Decode the `Address` (`C...`) returned by `VaultFactory.create_vault` or `expected_vault`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseCreateVaultResult(retval: StellarSdk.xdr.ScVal): string;
|
|
37
|
+
export interface DepositOpParams {
|
|
38
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
39
|
+
readonly pocketId: number;
|
|
40
|
+
/** Any Stellar SAC or SEP-41 token contract ID (`C...`, 32B raw, or contract `WireAddress`). */
|
|
41
|
+
readonly token: string | WireAddress | Uint8Array;
|
|
42
|
+
readonly amount: bigint;
|
|
43
|
+
/** 32-byte Ed25519 device public key (or 64-char hex). */
|
|
44
|
+
readonly devicePubkey: Uint8Array | string;
|
|
45
|
+
/**
|
|
46
|
+
* 1..=7 witness Ed25519 public keys (32B `Uint8Array` or 64-char hex) in **strictly ascending
|
|
47
|
+
* lexicographical order** (`sortWitnesses()`).
|
|
48
|
+
*/
|
|
49
|
+
readonly witnesses: readonly (Uint8Array | string)[];
|
|
50
|
+
readonly witnessThreshold: number;
|
|
51
|
+
/** Unilateral exit delay in seconds (`259_200..=2_592_000`, i.e., 72h..30d). */
|
|
52
|
+
readonly exitDelaySecs: bigint | number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build `UserVault.deposit(pocket_id, token, amount, device_pubkey, witnesses, witness_threshold, exit_delay_secs)`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildDepositOp(params: DepositOpParams): StellarSdk.xdr.Operation;
|
|
58
|
+
export interface SettleDelegatedFromCertParams {
|
|
59
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
60
|
+
/** Decoded `Smeshc1Packet` or framed `"SMESHC1..."` certificate string. */
|
|
61
|
+
readonly cert: Smeshc1Packet | string;
|
|
62
|
+
/** Gateway / fee-sponsor address receiving `actualTip` (for self-settlement with `actualTip = 0n`, pass recipient or submitter). */
|
|
63
|
+
readonly gateway: WireAddress | string;
|
|
64
|
+
/** Actual tip paid to `gateway` (`0n <= actualTip <= cert.intent.maxTip`, defaults to `0n`). */
|
|
65
|
+
readonly actualTip?: bigint;
|
|
66
|
+
}
|
|
67
|
+
export interface SettleDelegatedExplicitParams {
|
|
68
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
69
|
+
readonly pocketId: number;
|
|
70
|
+
readonly epoch: number;
|
|
71
|
+
readonly seq: number;
|
|
72
|
+
readonly to: WireAddress | string;
|
|
73
|
+
readonly amount: bigint;
|
|
74
|
+
readonly maxTip: bigint;
|
|
75
|
+
readonly actualTip: bigint;
|
|
76
|
+
readonly gateway: WireAddress | string;
|
|
77
|
+
readonly expiryTs: bigint | number;
|
|
78
|
+
readonly expiryLedger: number;
|
|
79
|
+
readonly orderId: bigint;
|
|
80
|
+
readonly cumulativeSpent: bigint;
|
|
81
|
+
readonly deviceSig: Uint8Array | string;
|
|
82
|
+
readonly witnessSigs: readonly (IndexedWitnessSignature | {
|
|
83
|
+
readonly index: number;
|
|
84
|
+
readonly signature: Uint8Array | string;
|
|
85
|
+
})[];
|
|
86
|
+
}
|
|
87
|
+
export type SettleDelegatedOpParams = SettleDelegatedFromCertParams | SettleDelegatedExplicitParams;
|
|
88
|
+
/**
|
|
89
|
+
* Build `UserVault.settle_delegated(...)` either directly from a `SMESHC1` certificate or from
|
|
90
|
+
* explicit fields.
|
|
91
|
+
*/
|
|
92
|
+
export declare function buildSettleDelegatedOp(params: SettleDelegatedOpParams): StellarSdk.xdr.Operation;
|
|
93
|
+
export interface ClosePocketCooperativeOpParams {
|
|
94
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
95
|
+
readonly pocketId: number;
|
|
96
|
+
/** Destination address receiving unspent pocket funds (`G...` or `C...`, cannot equal `vaultId`). */
|
|
97
|
+
readonly toAlt: WireAddress | string;
|
|
98
|
+
/** Strictly ascending unique witness signatures over `"SMW1_CLOSE"` (from `coordinateCloseCooperative`). */
|
|
99
|
+
readonly witnessSigs: readonly (IndexedWitnessSignature | {
|
|
100
|
+
readonly index: number;
|
|
101
|
+
readonly signature: Uint8Array | string;
|
|
102
|
+
})[];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Build `UserVault.close_pocket_cooperative(pocket_id, to_alt, witness_sigs)`.
|
|
106
|
+
*/
|
|
107
|
+
export declare function buildClosePocketCooperativeOp(params: ClosePocketCooperativeOpParams): StellarSdk.xdr.Operation;
|
|
108
|
+
export interface RequestExitOpParams {
|
|
109
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
110
|
+
readonly pocketId: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Build `UserVault.request_exit(pocket_id)` — initiates unilateral timelocked exit (`exit_delay_secs`).
|
|
114
|
+
*/
|
|
115
|
+
export declare function buildRequestExitOp(params: RequestExitOpParams): StellarSdk.xdr.Operation;
|
|
116
|
+
export interface FinalizeExitOpParams {
|
|
117
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
118
|
+
readonly pocketId: number;
|
|
119
|
+
/** Destination address receiving remaining pocket funds (`G...` or `C...`, cannot equal `vaultId`). */
|
|
120
|
+
readonly toAlt: WireAddress | string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Build `UserVault.finalize_exit(pocket_id, to_alt)` — sweeps pocket after `pending_exit_ts` elapses.
|
|
124
|
+
*/
|
|
125
|
+
export declare function buildFinalizeExitOp(params: FinalizeExitOpParams): StellarSdk.xdr.Operation;
|
|
126
|
+
export interface ClaimCreditOpParams {
|
|
127
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
128
|
+
/** Original recipient address that holds the parked credit (must authorize the tx). */
|
|
129
|
+
readonly recipient: WireAddress | string;
|
|
130
|
+
/** Parked token contract ID (`C...`, asset-agnostic SAC or SEP-41). */
|
|
131
|
+
readonly token: string | WireAddress | Uint8Array;
|
|
132
|
+
/** Destination address receiving the claimed credit (`G...` or `C...`, cannot equal `vaultId`). */
|
|
133
|
+
readonly toAlt: WireAddress | string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Build `UserVault.claim_credit(recipient, token, to_alt)` — claims parked credits when a classic
|
|
137
|
+
* trustline or SAC transfer previously bounced during `settle_delegated`.
|
|
138
|
+
*/
|
|
139
|
+
export declare function buildClaimCreditOp(params: ClaimCreditOpParams): StellarSdk.xdr.Operation;
|
|
140
|
+
/**
|
|
141
|
+
* Build read-only view call `UserVault.pocket_of(pocket_id: u32) -> Option<PocketState>`.
|
|
142
|
+
*/
|
|
143
|
+
export declare function buildPocketOfOp(params: {
|
|
144
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
145
|
+
readonly pocketId: number;
|
|
146
|
+
}): StellarSdk.xdr.Operation;
|
|
147
|
+
/**
|
|
148
|
+
* Build read-only view call `UserVault.credit_of(recipient: Address, token: Address) -> i128`.
|
|
149
|
+
*/
|
|
150
|
+
export declare function buildCreditOfOp(params: {
|
|
151
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
152
|
+
readonly recipient: WireAddress | string;
|
|
153
|
+
readonly token: string | WireAddress | Uint8Array;
|
|
154
|
+
}): StellarSdk.xdr.Operation;
|
|
155
|
+
/**
|
|
156
|
+
* Build read-only view call `UserVault.is_settled(pocket_id: u32, epoch: u32, seq: u32) -> bool`.
|
|
157
|
+
*/
|
|
158
|
+
export declare function buildIsSettledOp(params: {
|
|
159
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
160
|
+
readonly pocketId: number;
|
|
161
|
+
readonly epoch: number;
|
|
162
|
+
readonly seq: number;
|
|
163
|
+
}): StellarSdk.xdr.Operation;
|
|
164
|
+
export interface OnChainPocketState {
|
|
165
|
+
readonly token: string;
|
|
166
|
+
readonly balance: bigint;
|
|
167
|
+
readonly epochTotalDeposited: bigint;
|
|
168
|
+
readonly devicePubkey: Uint8Array;
|
|
169
|
+
readonly witnesses: readonly Uint8Array[];
|
|
170
|
+
readonly witnessThreshold: number;
|
|
171
|
+
readonly exitDelaySecs: bigint;
|
|
172
|
+
readonly pendingExitTs: bigint;
|
|
173
|
+
readonly epoch: number;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Decode `Option<PocketState>` returned by `UserVault.pocket_of(pocket_id)` simulation.
|
|
177
|
+
* Returns `null` when `ScVal` is `scvVoid` (`None`).
|
|
178
|
+
*/
|
|
179
|
+
export declare function decodePocketStateScVal(scVal: StellarSdk.xdr.ScVal): OnChainPocketState | null;
|
|
180
|
+
/** Encodes a v2 [`HwProof`] into its exact Soroban `ScVal` enum representation (`scvVec`). */
|
|
181
|
+
export declare function encodeHwProofScVal(proof: HwProof): StellarSdk.xdr.ScVal;
|
|
182
|
+
/** Build `UserVault.deposit_hw(...)` Soroban operation (v2 Hardware Roaming Pocket). */
|
|
183
|
+
export declare function buildDepositHwOp(params: {
|
|
184
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
185
|
+
readonly pocketId: number;
|
|
186
|
+
readonly token: string | WireAddress | Uint8Array;
|
|
187
|
+
readonly amount: bigint;
|
|
188
|
+
readonly hwKind: HwKind;
|
|
189
|
+
readonly maxSeq: number;
|
|
190
|
+
readonly hwAnchor: Uint8Array | string;
|
|
191
|
+
readonly appIdHash: Uint8Array | string;
|
|
192
|
+
readonly attestationDigest: Uint8Array | string;
|
|
193
|
+
readonly exitDelaySecs: bigint | number;
|
|
194
|
+
}): StellarSdk.xdr.Operation;
|
|
195
|
+
/** Build permissionless `UserVault.settle_hw(...)` Soroban operation. */
|
|
196
|
+
export declare function buildSettleHwOp(params: {
|
|
197
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
198
|
+
readonly pocketId: number;
|
|
199
|
+
readonly epoch: number;
|
|
200
|
+
readonly seq: number;
|
|
201
|
+
readonly to: WireAddress | string;
|
|
202
|
+
readonly amount: bigint;
|
|
203
|
+
readonly maxTip: bigint;
|
|
204
|
+
readonly actualTip: bigint;
|
|
205
|
+
readonly gateway: WireAddress | string;
|
|
206
|
+
readonly expiryTs: bigint | number;
|
|
207
|
+
readonly expiryLedger: number;
|
|
208
|
+
readonly orderId: bigint | number;
|
|
209
|
+
readonly cumulativeSpent: bigint;
|
|
210
|
+
readonly hwProof: HwProof;
|
|
211
|
+
}): StellarSdk.xdr.Operation;
|
|
212
|
+
/** Build `UserVault.void_hw_seqs(pocket_id, void_proofs)` Soroban operation. */
|
|
213
|
+
export declare function buildVoidHwSeqsOp(params: {
|
|
214
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
215
|
+
readonly pocketId: number;
|
|
216
|
+
readonly voidProofs: readonly {
|
|
217
|
+
readonly seq: number;
|
|
218
|
+
readonly proof: HwProof;
|
|
219
|
+
}[];
|
|
220
|
+
}): StellarSdk.xdr.Operation;
|
|
221
|
+
/** Build `UserVault.close_hw_instant(pocket_id, to_alt, void_proofs)` Soroban operation. */
|
|
222
|
+
export declare function buildCloseHwInstantOp(params: {
|
|
223
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
224
|
+
readonly pocketId: number;
|
|
225
|
+
readonly toAlt: WireAddress | string;
|
|
226
|
+
readonly voidProofs: readonly {
|
|
227
|
+
readonly seq: number;
|
|
228
|
+
readonly proof: HwProof;
|
|
229
|
+
}[];
|
|
230
|
+
}): StellarSdk.xdr.Operation;
|
|
231
|
+
/** Build `UserVault.request_hw_exit(pocket_id)` Soroban operation. */
|
|
232
|
+
export declare function buildRequestHwExitOp(params: {
|
|
233
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
234
|
+
readonly pocketId: number;
|
|
235
|
+
}): StellarSdk.xdr.Operation;
|
|
236
|
+
/** Build `UserVault.finalize_hw_exit(pocket_id, to_alt)` Soroban operation. */
|
|
237
|
+
export declare function buildFinalizeHwExitOp(params: {
|
|
238
|
+
readonly vaultId: string | WireAddress | Uint8Array;
|
|
239
|
+
readonly pocketId: number;
|
|
240
|
+
readonly toAlt: WireAddress | string;
|
|
241
|
+
}): StellarSdk.xdr.Operation;
|
|
242
|
+
export interface OnChainHwPocketState {
|
|
243
|
+
readonly token: string;
|
|
244
|
+
readonly balance: bigint;
|
|
245
|
+
readonly epochTotalDeposited: bigint;
|
|
246
|
+
readonly hwKind: HwKind;
|
|
247
|
+
readonly maxSeq: number;
|
|
248
|
+
readonly hwAnchor: Uint8Array;
|
|
249
|
+
readonly appIdHash: Uint8Array;
|
|
250
|
+
readonly attestationDigest: Uint8Array;
|
|
251
|
+
readonly exitDelaySecs: bigint;
|
|
252
|
+
readonly pendingExitTs: bigint;
|
|
253
|
+
readonly epoch: number;
|
|
254
|
+
}
|
|
255
|
+
/** Decode `Option<HwPocketState>` returned by `UserVault.hw_pocket_of(pocket_id)` or `getLedgerEntries`. */
|
|
256
|
+
export declare function decodeHwPocketStateScVal(scVal: StellarSdk.xdr.ScVal): OnChainHwPocketState | null;
|