@ouronet/ouronet-core 4.3.6

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +3043 -0
  2. package/README.md +1940 -0
  3. package/dist/codex/codec.d.ts +77 -0
  4. package/dist/codex/codec.js +123 -0
  5. package/dist/codex/errors.d.ts +14 -0
  6. package/dist/codex/errors.js +20 -0
  7. package/dist/codex/index.d.ts +27 -0
  8. package/dist/codex/index.js +25 -0
  9. package/dist/codex/seedTypeMigration.d.ts +35 -0
  10. package/dist/codex/seedTypeMigration.js +45 -0
  11. package/dist/codex/types.d.ts +100 -0
  12. package/dist/codex/types.js +19 -0
  13. package/dist/constants/index.d.ts +2 -0
  14. package/dist/constants/index.js +3 -0
  15. package/dist/constants/ouronet.d.ts +33 -0
  16. package/dist/constants/ouronet.js +59 -0
  17. package/dist/constants/tokenIds.d.ts +13 -0
  18. package/dist/constants/tokenIds.js +21 -0
  19. package/dist/index.d.ts +18 -0
  20. package/dist/index.js +1 -0
  21. package/dist/interactions/activateFunctions.d.ts +67 -0
  22. package/dist/interactions/activateFunctions.js +154 -0
  23. package/dist/interactions/addLiquidityFunctions.d.ts +140 -0
  24. package/dist/interactions/addLiquidityFunctions.js +485 -0
  25. package/dist/interactions/coilFunctions.d.ts +73 -0
  26. package/dist/interactions/coilFunctions.js +213 -0
  27. package/dist/interactions/crossChainFunctions.d.ts +211 -0
  28. package/dist/interactions/crossChainFunctions.js +463 -0
  29. package/dist/interactions/dexAcquisitionPoolFunctions.d.ts +18 -0
  30. package/dist/interactions/dexAcquisitionPoolFunctions.js +18 -0
  31. package/dist/interactions/dexCollectablesFunctions.d.ts +28 -0
  32. package/dist/interactions/dexCollectablesFunctions.js +227 -0
  33. package/dist/interactions/dexFunctions.d.ts +23 -0
  34. package/dist/interactions/dexFunctions.js +23 -0
  35. package/dist/interactions/dexOrtoFungibleFunctions.d.ts +33 -0
  36. package/dist/interactions/dexOrtoFungibleFunctions.js +171 -0
  37. package/dist/interactions/dexParseFunctions.d.ts +150 -0
  38. package/dist/interactions/dexParseFunctions.js +316 -0
  39. package/dist/interactions/dexSwapPairAdminFunctions.d.ts +75 -0
  40. package/dist/interactions/dexSwapPairAdminFunctions.js +255 -0
  41. package/dist/interactions/dexSwapPairCalcFunctions.d.ts +55 -0
  42. package/dist/interactions/dexSwapPairCalcFunctions.js +218 -0
  43. package/dist/interactions/dexSwapPairDashboardFunctions.d.ts +47 -0
  44. package/dist/interactions/dexSwapPairDashboardFunctions.js +179 -0
  45. package/dist/interactions/dexSwapPairExecuteFunctions.d.ts +40 -0
  46. package/dist/interactions/dexSwapPairExecuteFunctions.js +301 -0
  47. package/dist/interactions/dexSwapPairSmartSwapFunctions.d.ts +25 -0
  48. package/dist/interactions/dexSwapPairSmartSwapFunctions.js +166 -0
  49. package/dist/interactions/dexTrueFungibleFunctions.d.ts +52 -0
  50. package/dist/interactions/dexTrueFungibleFunctions.js +220 -0
  51. package/dist/interactions/dexTypes.d.ts +465 -0
  52. package/dist/interactions/dexTypes.js +6 -0
  53. package/dist/interactions/errors.d.ts +12 -0
  54. package/dist/interactions/errors.js +13 -0
  55. package/dist/interactions/guardFunctions.d.ts +33 -0
  56. package/dist/interactions/guardFunctions.js +110 -0
  57. package/dist/interactions/index.d.ts +1 -0
  58. package/dist/interactions/index.js +20 -0
  59. package/dist/interactions/infoOneFunctions.d.ts +133 -0
  60. package/dist/interactions/infoOneFunctions.js +566 -0
  61. package/dist/interactions/kadenaFunctions.d.ts +11 -0
  62. package/dist/interactions/kadenaFunctions.js +40 -0
  63. package/dist/interactions/kpayFunctions.d.ts +45 -0
  64. package/dist/interactions/kpayFunctions.js +191 -0
  65. package/dist/interactions/ouroAccountFunctions.d.ts +64 -0
  66. package/dist/interactions/ouroAccountFunctions.js +229 -0
  67. package/dist/interactions/ouroBalanceFunctions.d.ts +39 -0
  68. package/dist/interactions/ouroBalanceFunctions.js +100 -0
  69. package/dist/interactions/ouroCoilFunctions.d.ts +33 -0
  70. package/dist/interactions/ouroCoilFunctions.js +190 -0
  71. package/dist/interactions/ouroFunctions.d.ts +23 -0
  72. package/dist/interactions/ouroFunctions.js +23 -0
  73. package/dist/interactions/ouroMovieBoosterFunctions.d.ts +18 -0
  74. package/dist/interactions/ouroMovieBoosterFunctions.js +203 -0
  75. package/dist/interactions/ouroPriceFunctions.d.ts +38 -0
  76. package/dist/interactions/ouroPriceFunctions.js +96 -0
  77. package/dist/interactions/ouroPrimordialsFunctions.d.ts +10 -0
  78. package/dist/interactions/ouroPrimordialsFunctions.js +480 -0
  79. package/dist/interactions/ouroRotateFunctions.d.ts +22 -0
  80. package/dist/interactions/ouroRotateFunctions.js +114 -0
  81. package/dist/interactions/ouroSubCompressFunctions.d.ts +23 -0
  82. package/dist/interactions/ouroSubCompressFunctions.js +191 -0
  83. package/dist/interactions/ouroTransferFunctions.d.ts +14 -0
  84. package/dist/interactions/ouroTransferFunctions.js +87 -0
  85. package/dist/interactions/ouroTypes.d.ts +113 -0
  86. package/dist/interactions/ouroTypes.js +6 -0
  87. package/dist/interactions/ouroUrStoaFunctions.d.ts +16 -0
  88. package/dist/interactions/ouroUrStoaFunctions.js +121 -0
  89. package/dist/interactions/ouroWrapFunctions.d.ts +22 -0
  90. package/dist/interactions/ouroWrapFunctions.js +234 -0
  91. package/dist/interactions/pensionFunctions.d.ts +12 -0
  92. package/dist/interactions/pensionFunctions.js +127 -0
  93. package/dist/interactions/urStoaFunctions.d.ts +104 -0
  94. package/dist/interactions/urStoaFunctions.js +475 -0
  95. package/dist/interactions/wrapFunctions.d.ts +46 -0
  96. package/dist/interactions/wrapFunctions.js +221 -0
  97. package/dist/pact/cfmBuilders.d.ts +807 -0
  98. package/dist/pact/cfmBuilders.js +812 -0
  99. package/dist/pact/index.d.ts +1 -0
  100. package/dist/pact/index.js +10 -0
  101. package/package.json +64 -0
@@ -0,0 +1,213 @@
1
+ import { KADENA_CHAIN_ID, KADENA_NAMESPACE, STOA_AUTONOMIC_OURONETGASSTATION, KADENA_NETWORK, } from "../constants/index.js";
2
+ import { Pact } from "@stoachain/kadena-stoic-legacy/client";
3
+ import { getFailoverClient } from "@stoachain/stoa-core/network";
4
+ import { pactRead } from "@stoachain/stoa-core/reads";
5
+ import { formatDecimalForPact, safeCreationTime } from "@stoachain/stoa-core/pact";
6
+ import { universalSignTransaction, fromKeypair } from "@stoachain/stoa-core/signing";
7
+ import { getLogger } from "@stoachain/stoa-core/observability";
8
+ const coilPatternCache = new Map();
9
+ function getCoilPatterns(targetTokenName) {
10
+ const cached = coilPatternCache.get(targetTokenName);
11
+ if (cached)
12
+ return cached;
13
+ const eliteHyphen = targetTokenName.replace("ELITE", "ELITE-");
14
+ const eliteSpace = targetTokenName.replace("ELITE", "Elite ");
15
+ const tail = targetTokenName.slice(-4);
16
+ const built = {
17
+ generates: [
18
+ new RegExp(`generates\\s+([\\d.]+)\\s+${targetTokenName}`, "i"),
19
+ new RegExp(`generates\\s+([\\d.]+)\\s+${eliteHyphen}`, "i"),
20
+ new RegExp(`generates\\s+([\\d.]+)\\s+${eliteSpace}`, "i"),
21
+ new RegExp(`generates\\s+([\\d.]+)\\s+\\w*${tail}\\w*`, "i"),
22
+ ],
23
+ generating: [
24
+ new RegExp(`generating\\s+([\\d.]+)\\s+${targetTokenName}`, "i"),
25
+ new RegExp(`generating\\s+([\\d.]+)\\s+${eliteHyphen}`, "i"),
26
+ new RegExp(`generating\\s+([\\d.]+)\\s+${eliteSpace}`, "i"),
27
+ new RegExp(`generating\\s+([\\d.]+)\\s+\\w*${tail}\\w*`, "i"),
28
+ ],
29
+ };
30
+ coilPatternCache.set(targetTokenName, built);
31
+ return built;
32
+ }
33
+ // Coiling configurations for each token pair
34
+ export const COIL_CONFIGS = {
35
+ ouroToAuryn: {
36
+ atsPair: "Auryndex-O136CBn22ncY",
37
+ sourceToken: "OURO-8Nh-JO8JO4F5",
38
+ targetToken: "AURYN-8Nh-JO8JO4F5",
39
+ previewCommand: "Auryndex-O136CBn22ncY"
40
+ },
41
+ aurynToElite: {
42
+ atsPair: "EliteAuryndex-O136CBn22ncY",
43
+ sourceToken: "AURYN-8Nh-JO8JO4F5",
44
+ targetToken: "ELITEAURYN-8Nh-JO8JO4F5",
45
+ previewCommand: "EliteAuryndex-O136CBn22ncY"
46
+ },
47
+ wkdaToLkda: {
48
+ atsPair: "SilverStoaPillar-O136CBn22ncY",
49
+ sourceToken: "WSTOA-8Nh-JO8JO4F5",
50
+ targetToken: "SSTOA-8Nh-JO8JO4F5",
51
+ previewCommand: "SilverStoaPillar-O136CBn22ncY"
52
+ }
53
+ };
54
+ // Generic coil preview function
55
+ export async function getCoilPreviewGeneric(amount, config) {
56
+ try {
57
+ const decimalAmount = formatDecimalForPact(amount);
58
+ const executionString = `(${KADENA_NAMESPACE}.INFO-ONE.ATS|INFO_Coil "preview" "preview" "${config.atsPair}" "${config.sourceToken}" ${decimalAmount})`;
59
+ const response = await pactRead(executionString, { tier: "T2" });
60
+ if (!response?.result?.status || response.result.status !== "success") {
61
+ throw new Error("Failed to get coil preview");
62
+ }
63
+ const data = response.result.data;
64
+ // Extract target token amount from text arrays (like original getCoilPreview)
65
+ let targetAmount = 0;
66
+ const targetTokenName = config.targetToken.replace('-8Nh-JO8JO4F5', ''); // ELITEAURYN, SSTOA, etc
67
+ // v3.3.6 (F-PERF-003): pull the 8 RegExp instances from the
68
+ // per-targetTokenName memoization cache instead of compiling them
69
+ // 8x per call. Behaviorally identical — same patterns, same order.
70
+ const patterns = getCoilPatterns(targetTokenName);
71
+ // Check pre-text array for target token amount
72
+ if (data && data['pre-text']) {
73
+ for (const text of data['pre-text']) {
74
+ for (const pattern of patterns.generates) {
75
+ const tokenMatch = text.match(pattern);
76
+ if (tokenMatch) {
77
+ targetAmount = parseFloat(tokenMatch[1]);
78
+ break;
79
+ }
80
+ }
81
+ if (targetAmount > 0)
82
+ break;
83
+ }
84
+ }
85
+ // Fallback: check post-text array
86
+ if (!targetAmount && data && data['post-text']) {
87
+ for (const text of data['post-text']) {
88
+ for (const pattern of patterns.generating) {
89
+ const tokenMatch = text.match(pattern);
90
+ if (tokenMatch) {
91
+ targetAmount = parseFloat(tokenMatch[1]);
92
+ break;
93
+ }
94
+ }
95
+ if (targetAmount > 0)
96
+ break;
97
+ }
98
+ }
99
+ // Final fallback: try parsing data[0] if no text match found
100
+ if (!targetAmount && data && Array.isArray(data) && data.length > 0) {
101
+ const fallbackAmount = parseFloat(data[0]);
102
+ if (!isNaN(fallbackAmount) && fallbackAmount > 0) {
103
+ targetAmount = fallbackAmount;
104
+ }
105
+ }
106
+ const result = {
107
+ targetAmount,
108
+ fee: 0, // Like original, always 0
109
+ kadenaInfo: {
110
+ text: data?.kadena?.[`kadena-text`] || "Kadena fee information not available",
111
+ discount: data?.kadena?.[`kadena-discount`] || 1,
112
+ full: data?.kadena?.[`kadena-full`] || 0,
113
+ need: data?.kadena?.[`kadena-need`] || 0,
114
+ }
115
+ };
116
+ return result;
117
+ }
118
+ catch (error) {
119
+ getLogger().error("Error getting coil preview:", error);
120
+ throw error;
121
+ }
122
+ }
123
+ // Generic coil transaction function
124
+ export async function coilTokensGeneric(ouroAccount, kadenaAccount, guard, targetAccount, amount, config) {
125
+ const keysetName = `ks`;
126
+ // Ensure amount is formatted as decimal
127
+ const decimalAmount = formatDecimalForPact(amount);
128
+ let gasLimit = 70000; // Default gas limit
129
+ // Coiling operation initiated
130
+ const buildTransaction = (gasLimitOverride) => {
131
+ return Pact.builder
132
+ .execution(`(${KADENA_NAMESPACE}.TS01-C2.ATS|C_Coil "${ouroAccount.address}" "${targetAccount}" "${config.atsPair}" "${config.sourceToken}" ${decimalAmount})`)
133
+ .addData(keysetName, {
134
+ keys: [guard.publicKey],
135
+ pred: "keys-all",
136
+ })
137
+ .setMeta({
138
+ senderAccount: STOA_AUTONOMIC_OURONETGASSTATION,
139
+ creationTime: safeCreationTime(),
140
+ chainId: KADENA_CHAIN_ID,
141
+ gasLimit: gasLimitOverride || gasLimit,
142
+ })
143
+ .setNetworkId(KADENA_NETWORK)
144
+ .addSigner(kadenaAccount.publicKey, (withCapability) => [
145
+ withCapability(`${KADENA_NAMESPACE}.DALOS.GAS_PAYER`, "", { int: 0 }, { decimal: "0.0" }),
146
+ ])
147
+ .addSigner(guard.publicKey)
148
+ .createTransaction();
149
+ };
150
+ const { dirtyRead, submit } = getFailoverClient(KADENA_CHAIN_ID);
151
+ // First do a simulation to check gas
152
+ let transaction = buildTransaction();
153
+ const simulation = await dirtyRead(transaction);
154
+ // Simulation completed successfully
155
+ // Check if simulation failed
156
+ if (simulation.result.status === "failure") {
157
+ const errorMessage = simulation.result.error?.message || "Transaction simulation failed";
158
+ throw new Error(`Simulation failed: ${errorMessage}`);
159
+ }
160
+ // Check if we need to adjust gas limit
161
+ const requiredGas = simulation.gas;
162
+ if (requiredGas && requiredGas > gasLimit) {
163
+ // Rebuild transaction with adjusted gas limit (20% buffer)
164
+ gasLimit = Math.ceil(requiredGas * 1.2);
165
+ // Gas limit adjusted based on simulation
166
+ transaction = buildTransaction(gasLimit);
167
+ }
168
+ // Sign and submit the transaction
169
+ const signedTransaction = await universalSignTransaction(transaction, [
170
+ fromKeypair(kadenaAccount),
171
+ fromKeypair(guard),
172
+ ]);
173
+ // Submit the signed transaction
174
+ const result = await submit(signedTransaction);
175
+ return result;
176
+ }
177
+ // Specific functions for each coiling operation
178
+ // OURO → AURYN (backward compatibility)
179
+ export async function getCoilPreview(ouroAmount) {
180
+ const result = await getCoilPreviewGeneric(ouroAmount, COIL_CONFIGS.ouroToAuryn);
181
+ return {
182
+ auryn: result.targetAmount,
183
+ fee: result.fee,
184
+ kadenaInfo: result.kadenaInfo
185
+ };
186
+ }
187
+ export async function coilOuroToAuryn(ouroAccount, kadenaAccount, guard, targetAccount, ouroAmount) {
188
+ return coilTokensGeneric(ouroAccount, kadenaAccount, guard, targetAccount, ouroAmount, COIL_CONFIGS.ouroToAuryn);
189
+ }
190
+ // AURYN → Elite-AURYN
191
+ export async function getAurynCoilPreview(aurynAmount) {
192
+ const result = await getCoilPreviewGeneric(aurynAmount, COIL_CONFIGS.aurynToElite);
193
+ return {
194
+ eliteAuryn: result.targetAmount,
195
+ fee: result.fee,
196
+ kadenaInfo: result.kadenaInfo
197
+ };
198
+ }
199
+ export async function coilAurynToElite(ouroAccount, kadenaAccount, guard, targetAccount, aurynAmount) {
200
+ return coilTokensGeneric(ouroAccount, kadenaAccount, guard, targetAccount, aurynAmount, COIL_CONFIGS.aurynToElite);
201
+ }
202
+ // WSTOA → SSTOA
203
+ export async function getWkdaCoilPreview(wkdaAmount) {
204
+ const result = await getCoilPreviewGeneric(wkdaAmount, COIL_CONFIGS.wkdaToLkda);
205
+ return {
206
+ lkda: result.targetAmount,
207
+ fee: result.fee,
208
+ kadenaInfo: result.kadenaInfo
209
+ };
210
+ }
211
+ export async function coilWkdaToLkda(ouroAccount, kadenaAccount, guard, targetAccount, wkdaAmount) {
212
+ return coilTokensGeneric(ouroAccount, kadenaAccount, guard, targetAccount, wkdaAmount, COIL_CONFIGS.wkdaToLkda);
213
+ }
@@ -0,0 +1,211 @@
1
+ import { ITransactionDescriptor } from "@stoachain/kadena-stoic-legacy/client";
2
+ /**
3
+ * Get KDA balance for an account on a specific chain.
4
+ * exists=false means the account row does not exist on that chain (not just zero balance).
5
+ */
6
+ export declare function getBalanceOnChain(account: string, chainId: string, tier?: "T1" | "T2" | "T3"): Promise<{
7
+ balance: string;
8
+ exists: boolean;
9
+ error?: string;
10
+ }>;
11
+ export interface CrossChainTransferParams {
12
+ sender: string;
13
+ receiver: string;
14
+ receiverGuard: {
15
+ keys: string[];
16
+ pred: "keys-all" | "keys-any" | "keys-2";
17
+ };
18
+ amount: string;
19
+ sourceChain: string;
20
+ targetChain: string;
21
+ senderPublicKey: string;
22
+ }
23
+ export interface TransferStatus {
24
+ status: "pending" | "success" | "failure" | "not-found";
25
+ continuation?: {
26
+ pactId: string;
27
+ step: number;
28
+ stepHasRollback: boolean;
29
+ };
30
+ result?: any;
31
+ error?: string;
32
+ }
33
+ /**
34
+ * Build a cross-chain transfer transaction (step 1)
35
+ * This creates a transaction that needs to be signed and submitted
36
+ */
37
+ export declare function buildCrossChainTransfer(params: CrossChainTransferParams): any;
38
+ export interface CTransferAcrossParams {
39
+ sender: string;
40
+ receiver: string;
41
+ receiverGuard: {
42
+ keys: string[];
43
+ pred: string;
44
+ };
45
+ amount: string;
46
+ sourceChain: string;
47
+ targetChain: string;
48
+ senderPublicKey: string;
49
+ /** Required for chain 0 — Ouronet Gas Station pub key */
50
+ gasStationPublicKey?: string;
51
+ }
52
+ /**
53
+ * Build a coin.C_TransferAcross transaction (step 0 of cross-chain transfer).
54
+ *
55
+ * Chain 0: Gas paid by Ouronet Gas Station (DALOS.GAS_PAYER).
56
+ * Other chains: Gas paid by kadena-xchain-gas (unsigned).
57
+ */
58
+ export declare function buildCTransferAcross(params: CTransferAcrossParams): any;
59
+ /**
60
+ * Submit a cross-chain transfer and get the request key.
61
+ *
62
+ * Resolves to the chainweb `ITransactionDescriptor` (request key + chain id +
63
+ * network id) for the submitted transaction. Caller is responsible for
64
+ * persisting the descriptor — it's the only handle for `pollTransactionStatus`,
65
+ * `fetchSpvProof`, and `submitContinuation` later in the cross-chain flow.
66
+ *
67
+ * **Error contract** (closes audit finding F-ERR-001 — v3.2.3):
68
+ *
69
+ * Unlike its sibling `pollTransactionStatus` (which catches errors and
70
+ * returns `{ status: "pending", error: ... }` — the codebase's discriminated-
71
+ * union convention), this function deliberately propagates errors rather
72
+ * than swallowing them. A failed submit is not a transient state to poll
73
+ * past — it means the transaction did NOT land on chain, and the caller's
74
+ * UI must surface that as a hard failure (refund the user's escrowed gas
75
+ * estimate, present a retry button, etc.). Wrapping the throw in an
76
+ * envelope would mask the failure.
77
+ *
78
+ * @throws {SigningError} with `code: "TIMEOUT"` if the underlying
79
+ * `submit()` exceeds the per-tier deadline (default 60s for submit).
80
+ * See `runWithTimeout` in `src/network/failoverClient.ts`.
81
+ * @throws {Error} On network failure that survives both the primary and
82
+ * fallback node attempts. Both errors propagate verbatim from
83
+ * `getFailoverClient`'s submit method — the caller's catch block
84
+ * should distinguish via `error instanceof SigningError && error.code === "TIMEOUT"`.
85
+ */
86
+ export declare function submitCrossChainTransfer(signedTransaction: any, sourceChain: string): Promise<ITransactionDescriptor>;
87
+ /**
88
+ * Poll for transaction status on source chain
89
+ */
90
+ export declare function pollTransactionStatus(requestKey: string, chainId: string): Promise<TransferStatus>;
91
+ /**
92
+ * Fetch SPV proof for a cross-chain transfer.
93
+ *
94
+ * Requires waiting for block finality (~100-120 seconds). The on-chain
95
+ * proof becomes available a few blocks after the source-chain submit
96
+ * commits; before that, the chainweb node returns `400 not available`.
97
+ *
98
+ * v3.2.3 (closes audit finding F-BUG-004): wrapped in `withFailover` and
99
+ * `AbortSignal.timeout(SPV_PROOF_TIMEOUT_MS)`. Pre-v3.2.3, this was the
100
+ * only chain-RPC function in the entire codebase that called raw `fetch()`
101
+ * without either guard:
102
+ *
103
+ * - No `AbortController`: a wedged primary node (slow, not erroring)
104
+ * would hang the `await fetch(...)` indefinitely. The outer
105
+ * `pollSpvProof` retry loop never advanced because each attempt
106
+ * awaited the hung fetch.
107
+ *
108
+ * - No `withFailover`: even if the primary node returned an error or
109
+ * timed out, traffic stayed pinned to the primary; the consumer's
110
+ * subsequent attempts hit the same wedged node forever.
111
+ *
112
+ * - Combined consequence: the user's KDA was committed to
113
+ * `kadena-xchain-gas` escrow on the source chain (step 1 succeeded),
114
+ * but step 2's SPV proof retrieval hung silently with the UI showing
115
+ * a perpetual "Waiting for SPV proof..." spinner and no recovery
116
+ * path. This is the highest-impact bug surfaced by the 2026-05-05
117
+ * audit.
118
+ *
119
+ * Post-v3.2.3 behaviour: each attempt has a hard 30s deadline; on timeout
120
+ * (or any network-class error on the primary node), `withFailover`
121
+ * switches to the fallback node and retries once. The outer
122
+ * `pollSpvProof` loop then re-invokes this function after the configured
123
+ * `delayMs` (default 5s), so a stuck primary surfaces as ~30s of
124
+ * waiting, then automatic fallback, then continued polling — never an
125
+ * infinite hang.
126
+ */
127
+ export declare function fetchSpvProof(requestKey: string, sourceChain: string, targetChain: string): Promise<{
128
+ proof: string | null;
129
+ error?: string;
130
+ }>;
131
+ /**
132
+ * Poll for SPV proof with retry logic
133
+ * Will retry until proof is available or max attempts reached
134
+ */
135
+ export declare function pollSpvProof(requestKey: string, sourceChain: string, targetChain: string, maxAttempts?: number, delayMs?: number, onProgress?: (attempt: number, maxAttempts: number) => void): Promise<{
136
+ proof: string | null;
137
+ error?: string;
138
+ }>;
139
+ /**
140
+ * Build a continuation transaction for step 2 of cross-chain transfer
141
+ * This can be executed by anyone - no signature required from original sender
142
+ */
143
+ export declare function buildContinuationTransaction(pactId: string, proof: string, targetChain: string, gasPayerAccount?: string): any;
144
+ /**
145
+ * Submit a continuation transaction.
146
+ *
147
+ * Note: for the public gas station path (chain 0 + DALOS.GAS_PAYER), no
148
+ * signature is needed — the caller passes the unsigned `transaction`
149
+ * directly. For user-paid-gas paths the transaction MUST be signed before
150
+ * this function is called; the function itself does not sign.
151
+ *
152
+ * **Error contract** (closes audit finding F-ERR-001 — v3.2.3): same
153
+ * propagating-throw pattern as `submitCrossChainTransfer`. A failed
154
+ * continuation submit is a hard failure, not a transient state — surface
155
+ * to the user, don't swallow.
156
+ *
157
+ * @throws {SigningError} with `code: "TIMEOUT"` if `submit()` exceeds
158
+ * the per-tier deadline.
159
+ * @throws {Error} On network failure surviving both primary and fallback
160
+ * node attempts.
161
+ */
162
+ export declare function submitContinuation(transaction: any, targetChain: string): Promise<ITransactionDescriptor>;
163
+ /**
164
+ * Listen for transaction completion (long-poll for chainweb inclusion).
165
+ *
166
+ * Resolves to the chainweb command-result envelope when the transaction
167
+ * is included in a block (~30-180s on mainnet depending on block density).
168
+ *
169
+ * **Error contract** (closes audit finding F-ERR-001 — v3.2.3): a thrown
170
+ * error from this function is **NOT** a definitive failure. The chainweb
171
+ * `listen` endpoint times out after a per-tier deadline (default 180s,
172
+ * approximately 6 Kadena blocks); if the deadline fires, the transaction
173
+ * may still complete on chain — it just hasn't been included yet by the
174
+ * time this function gives up. Callers should treat a `SigningError(code:
175
+ * "TIMEOUT")` from this function as `status: "pending"` (poll again
176
+ * later via `pollTransactionStatus`), NOT as `status: "failed"` (do not
177
+ * retry the submit; it would double-pay gas for a transaction that may
178
+ * already be confirmed). This is the exact pattern that audit finding
179
+ * F-ERR-014 surfaced for the multi-step add-liquidity flow before that
180
+ * surface was deleted in v3.2.2.
181
+ *
182
+ * @throws {SigningError} with `code: "TIMEOUT"` if `listen()` exceeds
183
+ * the 180s deadline. **Treat as pending, not failed.**
184
+ * @throws {Error} On network failure surviving both primary and fallback
185
+ * node attempts.
186
+ */
187
+ export declare function listenForCompletion(requestKey: string, chainId: string): Promise<any>;
188
+ /**
189
+ * Simulate a Pact code execution to check if it will succeed.
190
+ *
191
+ * Public-API break (v1.8): the first parameter is now the raw Pact code string
192
+ * rather than a built transaction. Consumers that previously held the built
193
+ * transaction now hold the pact-code string they fed into `.execution(...)`.
194
+ */
195
+ export declare function simulateTransaction(pactCode: string, chainId: string): Promise<{
196
+ success: boolean;
197
+ result?: any;
198
+ error?: string;
199
+ gas?: number;
200
+ }>;
201
+ /**
202
+ * Get pending cross-chain transfers for an account
203
+ * Checks for continuation status
204
+ */
205
+ export declare function getContinuationStatus(requestKey: string, sourceChain: string): Promise<{
206
+ exists: boolean;
207
+ completed: boolean;
208
+ pactId?: string;
209
+ step?: number;
210
+ error?: string;
211
+ }>;