@pushchain/core 6.0.20 → 6.0.21
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/CHANGELOG.md +48 -0
- package/package.json +1 -1
- package/src/lib/cache/cache.js +2 -0
- package/src/lib/constants/abi/index.d.ts +1 -0
- package/src/lib/constants/abi/index.js +8 -1
- package/src/lib/constants/abi/pc20.evm.d.ts +217 -0
- package/src/lib/constants/abi/pc20.evm.js +150 -0
- package/src/lib/constants/abi/prc20.evm.d.ts +172 -0
- package/src/lib/constants/abi/prc20.evm.js +97 -0
- package/src/lib/constants/abi/universalGatewayV0.json +1 -1
- package/src/lib/constants/chain.js +38 -8
- package/src/lib/constants/selectors.js +2 -2
- package/src/lib/constants/tokens.js +4 -3
- package/src/lib/formatters.js +16 -6
- package/src/lib/generated/uexecutor/v1/query.js +2 -4
- package/src/lib/generated/uexecutor/v1/types.d.ts +14 -0
- package/src/lib/generated/uexecutor/v1/types.js +90 -47
- package/src/lib/generated/uexecutor/v2/query.js +2 -4
- package/src/lib/generated/uexecutor/v2/types.d.ts +20 -0
- package/src/lib/generated/uexecutor/v2/types.js +49 -33
- package/src/lib/generated/v1/tx.js +30 -37
- package/src/lib/index.d.ts +3 -0
- package/src/lib/index.js +21 -3
- package/src/lib/internal/buffer.js +1 -2
- package/src/lib/orchestrator/cea-utils.js +73 -83
- package/src/lib/orchestrator/internals/account-manager.js +130 -139
- package/src/lib/orchestrator/internals/cascade.d.ts +0 -6
- package/src/lib/orchestrator/internals/cascade.js +1184 -1059
- package/src/lib/orchestrator/internals/confirmation.js +138 -148
- package/src/lib/orchestrator/internals/error-decoder.js +1 -1
- package/src/lib/orchestrator/internals/errors.js +12 -3
- package/src/lib/orchestrator/internals/execute-funds-only.d.ts +2 -2
- package/src/lib/orchestrator/internals/execute-funds-only.js +297 -259
- package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +2 -2
- package/src/lib/orchestrator/internals/execute-funds-payload.js +220 -220
- package/src/lib/orchestrator/internals/execute-standard.d.ts +0 -8
- package/src/lib/orchestrator/internals/execute-standard.js +339 -342
- package/src/lib/orchestrator/internals/gas-calculator.js +497 -520
- package/src/lib/orchestrator/internals/gas-usd-sizer.js +101 -110
- package/src/lib/orchestrator/internals/gateway-client.js +102 -103
- package/src/lib/orchestrator/internals/helpers.js +30 -27
- package/src/lib/orchestrator/internals/inbound-tracker.js +234 -238
- package/src/lib/orchestrator/internals/outbound-sync.js +463 -452
- package/src/lib/orchestrator/internals/outbound-tracker.js +27 -34
- package/src/lib/orchestrator/internals/payload-builder.d.ts +2 -2
- package/src/lib/orchestrator/internals/payload-builder.js +119 -100
- package/src/lib/orchestrator/internals/pc-usd-oracle.js +121 -129
- package/src/lib/orchestrator/internals/pc20/address-codec.d.ts +31 -0
- package/src/lib/orchestrator/internals/pc20/address-codec.js +124 -0
- package/src/lib/orchestrator/internals/pc20/chain-namespace.d.ts +68 -0
- package/src/lib/orchestrator/internals/pc20/chain-namespace.js +136 -0
- package/src/lib/orchestrator/internals/pc20/errors.d.ts +160 -0
- package/src/lib/orchestrator/internals/pc20/errors.js +236 -0
- package/src/lib/orchestrator/internals/pc20/export.d.ts +172 -0
- package/src/lib/orchestrator/internals/pc20/export.js +412 -0
- package/src/lib/orchestrator/internals/pc20/gate.d.ts +67 -0
- package/src/lib/orchestrator/internals/pc20/gate.js +184 -0
- package/src/lib/orchestrator/internals/pc20/resolver.d.ts +187 -0
- package/src/lib/orchestrator/internals/pc20/resolver.js +658 -0
- package/src/lib/orchestrator/internals/pc20/svm.d.ts +189 -0
- package/src/lib/orchestrator/internals/pc20/svm.js +286 -0
- package/src/lib/orchestrator/internals/pc20/tracking.d.ts +46 -0
- package/src/lib/orchestrator/internals/pc20/tracking.js +109 -0
- package/src/lib/orchestrator/internals/preflight.js +1 -1
- package/src/lib/orchestrator/internals/progress-route-hooks.js +2 -2
- package/src/lib/orchestrator/internals/push-chain-tx.js +319 -329
- package/src/lib/orchestrator/internals/quote.js +90 -94
- package/src/lib/orchestrator/internals/rescue.js +76 -79
- package/src/lib/orchestrator/internals/response-builder.d.ts +28 -1
- package/src/lib/orchestrator/internals/response-builder.js +817 -701
- package/src/lib/orchestrator/internals/route-handlers.d.ts +7 -15
- package/src/lib/orchestrator/internals/route-handlers.js +1512 -1178
- package/src/lib/orchestrator/internals/signing.js +78 -83
- package/src/lib/orchestrator/internals/svm-bridge.d.ts +2 -2
- package/src/lib/orchestrator/internals/svm-bridge.js +161 -93
- package/src/lib/orchestrator/internals/svm-helpers.d.ts +15 -1
- package/src/lib/orchestrator/internals/svm-helpers.js +68 -24
- package/src/lib/orchestrator/internals/svm-rent.d.ts +19 -1
- package/src/lib/orchestrator/internals/svm-rent.js +163 -141
- package/src/lib/orchestrator/internals/tx-transformer.js +26 -23
- package/src/lib/orchestrator/internals/uea-manager.js +89 -86
- package/src/lib/orchestrator/max-pc-for-gas.js +5 -6
- package/src/lib/orchestrator/orchestrator.js +217 -200
- package/src/lib/orchestrator/orchestrator.types.d.ts +121 -1
- package/src/lib/orchestrator/orchestrator.types.js +19 -0
- package/src/lib/orchestrator/payload-builders.d.ts +2 -2
- package/src/lib/orchestrator/payload-builders.js +26 -24
- package/src/lib/orchestrator/route-detector.js +26 -9
- package/src/lib/orchestrator/svm-idl/ix-encoder.js +1 -2
- package/src/lib/orchestrator/svm-idl/normalize-address.js +2 -2
- package/src/lib/orchestrator/svm-idl/resolve.js +1 -2
- package/src/lib/price-fetch/price-fetch.js +67 -68
- package/src/lib/progress-hook/progress-hook.js +124 -72
- package/src/lib/push-chain/push-chain.js +171 -153
- package/src/lib/push-client/push-client.js +223 -237
- package/src/lib/universal/account/account.js +349 -365
- package/src/lib/universal/signer/signer.js +306 -294
- package/src/lib/universal-tx-detector/auto-detect.js +55 -60
- package/src/lib/universal-tx-detector/cascade.js +160 -172
- package/src/lib/universal-tx-detector/child-inbounds.js +67 -75
- package/src/lib/universal-tx-detector/classify.js +2 -3
- package/src/lib/universal-tx-detector/detector-svm.js +139 -147
- package/src/lib/universal-tx-detector/detector.js +145 -157
- package/src/lib/universal-tx-detector/normalize.js +7 -7
- package/src/lib/utils/external-tx-hash.js +1 -2
- package/src/lib/utils.d.ts +44 -0
- package/src/lib/utils.js +762 -683
- package/src/lib/vm-client/evm-client.js +186 -202
- package/src/lib/vm-client/svm-client.d.ts +1 -1
- package/src/lib/vm-client/svm-client.js +220 -224
- package/src/lib/vm-client/vm-client.types.d.ts +14 -2
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.waitForEvmConfirmationsWithCountdown = waitForEvmConfirmationsWithCountdown;
|
|
7
7
|
exports.waitForSvmConfirmationsWithCountdown = waitForSvmConfirmationsWithCountdown;
|
|
8
8
|
exports.waitForLockerFeeConfirmation = waitForLockerFeeConfirmation;
|
|
9
|
-
const tslib_1 = require("tslib");
|
|
10
9
|
const bs58_1 = require("../../internal/bs58");
|
|
11
10
|
const viem_1 = require("viem");
|
|
12
11
|
const chain_1 = require("../../constants/chain");
|
|
@@ -18,180 +17,171 @@ const context_2 = require("./context");
|
|
|
18
17
|
const EVM_RECEIPT_POLL_MS = 3000;
|
|
19
18
|
const EVM_RECEIPT_NOT_FOUND_RE = /not found|TransactionNotFound|TransactionReceiptNotFound|could not be found|No transaction found/i;
|
|
20
19
|
function getErrorMessage(err) {
|
|
21
|
-
var _a, _b;
|
|
22
20
|
if (err instanceof Error)
|
|
23
21
|
return err.message;
|
|
24
22
|
if (typeof err === 'object' && err !== null) {
|
|
25
23
|
const maybe = err;
|
|
26
|
-
return String(
|
|
24
|
+
return String(maybe.shortMessage ?? maybe.message ?? err);
|
|
27
25
|
}
|
|
28
26
|
return String(err);
|
|
29
27
|
}
|
|
30
|
-
function waitForEvmReceipt(evmClient, txHash, timeoutMs) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
throw err;
|
|
45
|
-
}
|
|
46
|
-
yield new Promise((r) => setTimeout(r, EVM_RECEIPT_POLL_MS));
|
|
28
|
+
async function waitForEvmReceipt(evmClient, txHash, timeoutMs) {
|
|
29
|
+
const start = Date.now();
|
|
30
|
+
// eslint-disable-next-line no-constant-condition
|
|
31
|
+
while (true) {
|
|
32
|
+
try {
|
|
33
|
+
return await evmClient.publicClient.getTransactionReceipt({
|
|
34
|
+
hash: txHash,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
const msg = getErrorMessage(err);
|
|
39
|
+
const retryable = EVM_RECEIPT_NOT_FOUND_RE.test(msg);
|
|
40
|
+
if (!retryable || Date.now() - start > timeoutMs) {
|
|
41
|
+
throw err;
|
|
47
42
|
}
|
|
43
|
+
await new Promise((r) => setTimeout(r, EVM_RECEIPT_POLL_MS));
|
|
48
44
|
}
|
|
49
|
-
}
|
|
45
|
+
}
|
|
50
46
|
}
|
|
51
|
-
function waitForEvmConfirmationsWithCountdown(ctx, evmClient, txHash, confirmations, timeoutMs) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
async function waitForEvmConfirmationsWithCountdown(ctx, evmClient, txHash, confirmations, timeoutMs) {
|
|
48
|
+
if (confirmations <= 0) {
|
|
49
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, 0, 0, txHash);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03, confirmations, txHash);
|
|
53
|
+
const start = Date.now();
|
|
54
|
+
const receipt = await waitForEvmReceipt(evmClient, txHash, timeoutMs);
|
|
55
|
+
const targetBlock = receipt.blockNumber + BigInt(confirmations);
|
|
56
|
+
let lastEmitted = 0;
|
|
57
|
+
// eslint-disable-next-line no-constant-condition
|
|
58
|
+
while (true) {
|
|
59
|
+
const currentBlock = await evmClient.publicClient.getBlockNumber();
|
|
60
|
+
if (currentBlock >= targetBlock) {
|
|
61
|
+
if (lastEmitted < confirmations) {
|
|
62
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, confirmations, confirmations, txHash);
|
|
63
|
+
}
|
|
55
64
|
return;
|
|
56
65
|
}
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (currentBlock >= targetBlock) {
|
|
66
|
-
if (lastEmitted < confirmations) {
|
|
67
|
-
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, confirmations, confirmations, txHash);
|
|
68
|
-
}
|
|
66
|
+
const remaining = Number(targetBlock - currentBlock);
|
|
67
|
+
const completed = Math.max(1, confirmations - remaining + 1);
|
|
68
|
+
if (completed > lastEmitted) {
|
|
69
|
+
(0, context_2.fireProgressHook)(ctx, completed >= confirmations
|
|
70
|
+
? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02
|
|
71
|
+
: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01, completed, confirmations, txHash);
|
|
72
|
+
lastEmitted = completed;
|
|
73
|
+
if (completed >= confirmations)
|
|
69
74
|
return;
|
|
75
|
+
}
|
|
76
|
+
if (Date.now() - start > timeoutMs) {
|
|
77
|
+
throw new Error(`Timeout: transaction ${txHash} not confirmed with ${confirmations} confirmations within ${timeoutMs} ms`);
|
|
78
|
+
}
|
|
79
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function waitForSvmConfirmationsWithCountdown(ctx, svmClient, txSignature, confirmations, timeoutMs) {
|
|
83
|
+
if (confirmations <= 0) {
|
|
84
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, 0, 0, txSignature);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03, confirmations, txSignature);
|
|
88
|
+
const start = Date.now();
|
|
89
|
+
let lastConfirmed = 0;
|
|
90
|
+
// eslint-disable-next-line no-constant-condition
|
|
91
|
+
while (true) {
|
|
92
|
+
const connection = svmClient.connections[svmClient.currentConnectionIndex];
|
|
93
|
+
const { value } = await connection.getSignatureStatuses([txSignature]);
|
|
94
|
+
const status = value[0];
|
|
95
|
+
if (status) {
|
|
96
|
+
if (status.err) {
|
|
97
|
+
throw new Error(`SVM transaction ${txSignature} failed: ${JSON.stringify(status.err)}`);
|
|
70
98
|
}
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
99
|
+
const rawConfirmations = status.confirmations;
|
|
100
|
+
const hasNumericConfirmations = rawConfirmations != null;
|
|
101
|
+
const currentConfirms = hasNumericConfirmations ? rawConfirmations : 0;
|
|
102
|
+
const isFinalized = status.err === null &&
|
|
103
|
+
(status.confirmationStatus === 'finalized' || status.confirmations === null);
|
|
104
|
+
const hasEnoughConfirmations = hasNumericConfirmations && currentConfirms >= confirmations;
|
|
105
|
+
if (currentConfirms > lastConfirmed) {
|
|
106
|
+
const clamped = currentConfirms >= confirmations ? confirmations : currentConfirms;
|
|
107
|
+
(0, context_2.fireProgressHook)(ctx, clamped >= confirmations
|
|
75
108
|
? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02
|
|
76
|
-
: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01,
|
|
77
|
-
|
|
78
|
-
if (completed >= confirmations)
|
|
79
|
-
return;
|
|
109
|
+
: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01, Math.max(1, clamped), confirmations, txSignature);
|
|
110
|
+
lastConfirmed = currentConfirms;
|
|
80
111
|
}
|
|
81
|
-
if (
|
|
82
|
-
|
|
112
|
+
if (hasEnoughConfirmations || isFinalized) {
|
|
113
|
+
if (lastConfirmed < confirmations) {
|
|
114
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, confirmations, confirmations, txSignature);
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
83
117
|
}
|
|
84
|
-
yield new Promise((r) => setTimeout(r, 3000));
|
|
85
118
|
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
function waitForSvmConfirmationsWithCountdown(ctx, svmClient, txSignature, confirmations, timeoutMs) {
|
|
89
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
if (confirmations <= 0) {
|
|
91
|
-
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, 0, 0, txSignature);
|
|
92
|
-
return;
|
|
119
|
+
if (Date.now() - start > timeoutMs) {
|
|
120
|
+
throw new Error(`Timeout: transaction ${txSignature} not confirmed with ${confirmations} confirmations within ${timeoutMs} ms`);
|
|
93
121
|
}
|
|
94
|
-
(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
if (hasEnoughConfirmations || isFinalized) {
|
|
120
|
-
if (lastConfirmed < confirmations) {
|
|
121
|
-
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, confirmations, confirmations, txSignature);
|
|
122
|
-
}
|
|
122
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function waitForLockerFeeConfirmation(ctx, txHashBytes) {
|
|
126
|
+
const chain = ctx.universalSigner.account.chain;
|
|
127
|
+
const { vm, defaultRPC, fastConfirmations, timeout } = chain_1.CHAIN_INFO[chain];
|
|
128
|
+
// Poll silently — the fee-lock path fires SEND-TX-105-02 as its terminal
|
|
129
|
+
// confirmation marker; emitting 106-xx here would leak funds-bridge hooks
|
|
130
|
+
// into a non-funds-bridge path. Uses the same underlying RPC wait as the
|
|
131
|
+
// funds-bridge confirmation helpers but without the 106-03 / 106-03-02
|
|
132
|
+
// emissions.
|
|
133
|
+
switch (vm) {
|
|
134
|
+
case enums_1.VM.EVM: {
|
|
135
|
+
const evmClient = (0, context_1.getOriginEvmClient)(ctx);
|
|
136
|
+
const txHash = (0, viem_1.bytesToHex)(txHashBytes);
|
|
137
|
+
const receipt = await waitForEvmReceipt(evmClient, txHash, timeout);
|
|
138
|
+
if (fastConfirmations <= 1)
|
|
139
|
+
return;
|
|
140
|
+
const targetBlock = receipt.blockNumber + BigInt(fastConfirmations);
|
|
141
|
+
const start = Date.now();
|
|
142
|
+
// eslint-disable-next-line no-constant-condition
|
|
143
|
+
while (true) {
|
|
144
|
+
const currentBlock = await evmClient.publicClient.getBlockNumber();
|
|
145
|
+
if (currentBlock >= targetBlock)
|
|
123
146
|
return;
|
|
147
|
+
if (Date.now() - start > timeout) {
|
|
148
|
+
throw new Error(`Timeout: fee-lock tx ${txHash} not confirmed with ${fastConfirmations} confirmations within ${timeout} ms`);
|
|
124
149
|
}
|
|
150
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
125
151
|
}
|
|
126
|
-
if (Date.now() - start > timeoutMs) {
|
|
127
|
-
throw new Error(`Timeout: transaction ${txSignature} not confirmed with ${confirmations} confirmations within ${timeoutMs} ms`);
|
|
128
|
-
}
|
|
129
|
-
yield new Promise((r) => setTimeout(r, 500));
|
|
130
152
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (fastConfirmations <= 1)
|
|
148
|
-
return;
|
|
149
|
-
const targetBlock = receipt.blockNumber + BigInt(fastConfirmations);
|
|
150
|
-
const start = Date.now();
|
|
151
|
-
// eslint-disable-next-line no-constant-condition
|
|
152
|
-
while (true) {
|
|
153
|
-
const currentBlock = yield evmClient.publicClient.getBlockNumber();
|
|
154
|
-
if (currentBlock >= targetBlock)
|
|
155
|
-
return;
|
|
156
|
-
if (Date.now() - start > timeout) {
|
|
157
|
-
throw new Error(`Timeout: fee-lock tx ${txHash} not confirmed with ${fastConfirmations} confirmations within ${timeout} ms`);
|
|
153
|
+
case enums_1.VM.SVM: {
|
|
154
|
+
const rpcUrls = ctx.rpcUrls[chain] || defaultRPC;
|
|
155
|
+
const svmClient = new svm_client_1.SvmClient({ rpcUrls });
|
|
156
|
+
const signature = bs58_1.bs58.encode(Buffer.from(txHashBytes));
|
|
157
|
+
const start = Date.now();
|
|
158
|
+
// eslint-disable-next-line no-constant-condition
|
|
159
|
+
while (true) {
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
|
+
const connection = svmClient.connections[
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
163
|
+
svmClient.currentConnectionIndex];
|
|
164
|
+
const { value } = await connection.getSignatureStatuses([signature]);
|
|
165
|
+
const status = value[0];
|
|
166
|
+
if (status) {
|
|
167
|
+
if (status.err) {
|
|
168
|
+
throw new Error(`SVM fee-lock tx ${signature} failed: ${JSON.stringify(status.err)}`);
|
|
158
169
|
}
|
|
159
|
-
|
|
170
|
+
const isFinalized = status.confirmationStatus === 'finalized' ||
|
|
171
|
+
status.confirmations === null;
|
|
172
|
+
const hasEnough = status.confirmations != null &&
|
|
173
|
+
status.confirmations >= fastConfirmations;
|
|
174
|
+
if (isFinalized || hasEnough)
|
|
175
|
+
return;
|
|
160
176
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const rpcUrls = ctx.rpcUrls[chain] || defaultRPC;
|
|
164
|
-
const svmClient = new svm_client_1.SvmClient({ rpcUrls });
|
|
165
|
-
const signature = bs58_1.bs58.encode(Buffer.from(txHashBytes));
|
|
166
|
-
const start = Date.now();
|
|
167
|
-
// eslint-disable-next-line no-constant-condition
|
|
168
|
-
while (true) {
|
|
169
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
170
|
-
const connection = svmClient.connections[
|
|
171
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
172
|
-
svmClient.currentConnectionIndex];
|
|
173
|
-
const { value } = yield connection.getSignatureStatuses([signature]);
|
|
174
|
-
const status = value[0];
|
|
175
|
-
if (status) {
|
|
176
|
-
if (status.err) {
|
|
177
|
-
throw new Error(`SVM fee-lock tx ${signature} failed: ${JSON.stringify(status.err)}`);
|
|
178
|
-
}
|
|
179
|
-
const isFinalized = status.confirmationStatus === 'finalized' ||
|
|
180
|
-
status.confirmations === null;
|
|
181
|
-
const hasEnough = status.confirmations != null &&
|
|
182
|
-
status.confirmations >= fastConfirmations;
|
|
183
|
-
if (isFinalized || hasEnough)
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (Date.now() - start > timeout) {
|
|
187
|
-
throw new Error(`Timeout: fee-lock tx ${signature} not confirmed with ${fastConfirmations} confirmations within ${timeout} ms`);
|
|
188
|
-
}
|
|
189
|
-
yield new Promise((r) => setTimeout(r, 500));
|
|
177
|
+
if (Date.now() - start > timeout) {
|
|
178
|
+
throw new Error(`Timeout: fee-lock tx ${signature} not confirmed with ${fastConfirmations} confirmations within ${timeout} ms`);
|
|
190
179
|
}
|
|
180
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
191
181
|
}
|
|
192
|
-
default:
|
|
193
|
-
throw new Error(`Unsupported VM for tx confirmation: ${vm}`);
|
|
194
182
|
}
|
|
195
|
-
|
|
183
|
+
default:
|
|
184
|
+
throw new Error(`Unsupported VM for tx confirmation: ${vm}`);
|
|
185
|
+
}
|
|
196
186
|
}
|
|
197
187
|
//# sourceMappingURL=confirmation.js.map
|
|
@@ -28,9 +28,11 @@ const formatters_1 = require("../../formatters");
|
|
|
28
28
|
* consumers don't have to parse the message string.
|
|
29
29
|
*/
|
|
30
30
|
class PushChainExecutionError extends Error {
|
|
31
|
+
code = 'PUSH_CHAIN_EXECUTION_FAILED';
|
|
32
|
+
gatewayTxHash;
|
|
33
|
+
decodedError;
|
|
31
34
|
constructor(message, opts = {}) {
|
|
32
35
|
super((0, formatters_1.normalizePublicErrorMessage)(message));
|
|
33
|
-
this.code = 'PUSH_CHAIN_EXECUTION_FAILED';
|
|
34
36
|
this.name = 'PushChainExecutionError';
|
|
35
37
|
this.gatewayTxHash = opts.gatewayTxHash;
|
|
36
38
|
this.decodedError = opts.decodedError;
|
|
@@ -44,9 +46,16 @@ exports.PushChainExecutionError = PushChainExecutionError;
|
|
|
44
46
|
* inside Uniswap with `Error("STF")`.
|
|
45
47
|
*/
|
|
46
48
|
class InsufficientUEABalanceError extends PushChainExecutionError {
|
|
49
|
+
required;
|
|
50
|
+
available;
|
|
51
|
+
shortfall;
|
|
52
|
+
ueaAddress;
|
|
53
|
+
pathTag;
|
|
54
|
+
reason;
|
|
55
|
+
burnToken;
|
|
56
|
+
segmentIndex;
|
|
47
57
|
constructor(opts) {
|
|
48
|
-
|
|
49
|
-
const reason = (_a = opts.reason) !== null && _a !== void 0 ? _a : 'NATIVE';
|
|
58
|
+
const reason = opts.reason ?? 'NATIVE';
|
|
50
59
|
const segLabel = opts.segmentIndex !== undefined ? `:seg${opts.segmentIndex}` : '';
|
|
51
60
|
const tokenSuffix = reason === 'PRC20' && opts.burnToken
|
|
52
61
|
? ` of token ${opts.burnToken}`
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* for both EVM and SVM origin chains.
|
|
6
6
|
*/
|
|
7
7
|
import { ProgressEvent } from '../../progress-hook/progress-hook.types';
|
|
8
|
-
import type {
|
|
8
|
+
import type { LegacyExecuteParams, UniversalTxResponse } from '../orchestrator.types';
|
|
9
9
|
import type { OrchestratorContext } from './context';
|
|
10
10
|
import type { ResponseBuilderCallbacks } from './response-builder';
|
|
11
|
-
export declare function executeFundsOnly(ctx: OrchestratorContext, execute:
|
|
11
|
+
export declare function executeFundsOnly(ctx: OrchestratorContext, execute: LegacyExecuteParams, eventBuffer: ProgressEvent[], getResponseCallbacks: () => ResponseBuilderCallbacks): Promise<UniversalTxResponse>;
|