@pushchain/core 6.0.20 → 6.0.22

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 (113) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/package.json +8 -2
  3. package/src/lib/cache/cache.js +2 -0
  4. package/src/lib/constants/abi/erc20.evm.d.ts +30 -0
  5. package/src/lib/constants/abi/erc20.evm.js +21 -0
  6. package/src/lib/constants/abi/index.d.ts +1 -0
  7. package/src/lib/constants/abi/index.js +7 -1
  8. package/src/lib/constants/abi/pc20.evm.d.ts +192 -0
  9. package/src/lib/constants/abi/pc20.evm.js +134 -0
  10. package/src/lib/constants/abi/prc20.evm.d.ts +172 -0
  11. package/src/lib/constants/abi/prc20.evm.js +97 -0
  12. package/src/lib/constants/abi/universalGatewayV0.json +1 -1
  13. package/src/lib/constants/chain.js +38 -8
  14. package/src/lib/constants/selectors.js +2 -2
  15. package/src/lib/constants/tokens.js +4 -3
  16. package/src/lib/formatters.js +16 -6
  17. package/src/lib/generated/uexecutor/v1/query.js +2 -4
  18. package/src/lib/generated/uexecutor/v1/types.d.ts +14 -0
  19. package/src/lib/generated/uexecutor/v1/types.js +90 -47
  20. package/src/lib/generated/uexecutor/v2/query.js +2 -4
  21. package/src/lib/generated/uexecutor/v2/types.d.ts +20 -0
  22. package/src/lib/generated/uexecutor/v2/types.js +49 -33
  23. package/src/lib/generated/v1/tx.js +30 -37
  24. package/src/lib/index.d.ts +3 -0
  25. package/src/lib/index.js +21 -3
  26. package/src/lib/internal/buffer.js +1 -2
  27. package/src/lib/orchestrator/cea-utils.js +89 -83
  28. package/src/lib/orchestrator/internals/account-manager.js +130 -139
  29. package/src/lib/orchestrator/internals/cascade.d.ts +0 -6
  30. package/src/lib/orchestrator/internals/cascade.js +1184 -1059
  31. package/src/lib/orchestrator/internals/confirmation.js +138 -148
  32. package/src/lib/orchestrator/internals/error-decoder.js +1 -1
  33. package/src/lib/orchestrator/internals/errors.js +12 -3
  34. package/src/lib/orchestrator/internals/execute-funds-only.d.ts +2 -2
  35. package/src/lib/orchestrator/internals/execute-funds-only.js +297 -259
  36. package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +2 -2
  37. package/src/lib/orchestrator/internals/execute-funds-payload.js +220 -220
  38. package/src/lib/orchestrator/internals/execute-standard.d.ts +0 -8
  39. package/src/lib/orchestrator/internals/execute-standard.js +339 -342
  40. package/src/lib/orchestrator/internals/gas-calculator.js +497 -520
  41. package/src/lib/orchestrator/internals/gas-usd-sizer.js +101 -110
  42. package/src/lib/orchestrator/internals/gateway-client.js +102 -103
  43. package/src/lib/orchestrator/internals/helpers.js +30 -27
  44. package/src/lib/orchestrator/internals/inbound-tracker.js +234 -238
  45. package/src/lib/orchestrator/internals/outbound-sync.js +463 -452
  46. package/src/lib/orchestrator/internals/outbound-tracker.js +27 -34
  47. package/src/lib/orchestrator/internals/payload-builder.d.ts +2 -2
  48. package/src/lib/orchestrator/internals/payload-builder.js +119 -100
  49. package/src/lib/orchestrator/internals/pc-usd-oracle.js +121 -129
  50. package/src/lib/orchestrator/internals/pc20/address-codec.d.ts +31 -0
  51. package/src/lib/orchestrator/internals/pc20/address-codec.js +124 -0
  52. package/src/lib/orchestrator/internals/pc20/chain-namespace.d.ts +68 -0
  53. package/src/lib/orchestrator/internals/pc20/chain-namespace.js +136 -0
  54. package/src/lib/orchestrator/internals/pc20/errors.d.ts +160 -0
  55. package/src/lib/orchestrator/internals/pc20/errors.js +236 -0
  56. package/src/lib/orchestrator/internals/pc20/export.d.ts +176 -0
  57. package/src/lib/orchestrator/internals/pc20/export.js +431 -0
  58. package/src/lib/orchestrator/internals/pc20/gate.d.ts +67 -0
  59. package/src/lib/orchestrator/internals/pc20/gate.js +184 -0
  60. package/src/lib/orchestrator/internals/pc20/resolver.d.ts +185 -0
  61. package/src/lib/orchestrator/internals/pc20/resolver.js +649 -0
  62. package/src/lib/orchestrator/internals/pc20/svm.d.ts +189 -0
  63. package/src/lib/orchestrator/internals/pc20/svm.js +286 -0
  64. package/src/lib/orchestrator/internals/pc20/tracking.d.ts +46 -0
  65. package/src/lib/orchestrator/internals/pc20/tracking.js +109 -0
  66. package/src/lib/orchestrator/internals/preflight.js +1 -1
  67. package/src/lib/orchestrator/internals/progress-route-hooks.js +2 -2
  68. package/src/lib/orchestrator/internals/push-chain-tx.js +319 -329
  69. package/src/lib/orchestrator/internals/quote.js +90 -94
  70. package/src/lib/orchestrator/internals/rescue.js +76 -79
  71. package/src/lib/orchestrator/internals/response-builder.d.ts +28 -1
  72. package/src/lib/orchestrator/internals/response-builder.js +817 -701
  73. package/src/lib/orchestrator/internals/route-handlers.d.ts +7 -15
  74. package/src/lib/orchestrator/internals/route-handlers.js +1522 -1176
  75. package/src/lib/orchestrator/internals/signing.js +78 -83
  76. package/src/lib/orchestrator/internals/svm-bridge.d.ts +2 -2
  77. package/src/lib/orchestrator/internals/svm-bridge.js +161 -93
  78. package/src/lib/orchestrator/internals/svm-helpers.d.ts +15 -1
  79. package/src/lib/orchestrator/internals/svm-helpers.js +68 -24
  80. package/src/lib/orchestrator/internals/svm-rent.d.ts +19 -1
  81. package/src/lib/orchestrator/internals/svm-rent.js +163 -141
  82. package/src/lib/orchestrator/internals/tx-transformer.js +26 -23
  83. package/src/lib/orchestrator/internals/uea-manager.js +89 -86
  84. package/src/lib/orchestrator/max-pc-for-gas.js +5 -6
  85. package/src/lib/orchestrator/orchestrator.js +217 -200
  86. package/src/lib/orchestrator/orchestrator.types.d.ts +121 -1
  87. package/src/lib/orchestrator/orchestrator.types.js +19 -0
  88. package/src/lib/orchestrator/payload-builders.d.ts +2 -2
  89. package/src/lib/orchestrator/payload-builders.js +26 -24
  90. package/src/lib/orchestrator/route-detector.js +26 -9
  91. package/src/lib/orchestrator/svm-idl/ix-encoder.js +1 -2
  92. package/src/lib/orchestrator/svm-idl/normalize-address.js +2 -2
  93. package/src/lib/orchestrator/svm-idl/resolve.js +1 -2
  94. package/src/lib/price-fetch/price-fetch.js +67 -68
  95. package/src/lib/progress-hook/progress-hook.js +124 -72
  96. package/src/lib/push-chain/push-chain.js +171 -153
  97. package/src/lib/push-client/push-client.js +223 -237
  98. package/src/lib/universal/account/account.js +349 -365
  99. package/src/lib/universal/signer/signer.js +306 -294
  100. package/src/lib/universal-tx-detector/auto-detect.js +55 -60
  101. package/src/lib/universal-tx-detector/cascade.js +160 -172
  102. package/src/lib/universal-tx-detector/child-inbounds.js +67 -75
  103. package/src/lib/universal-tx-detector/classify.js +2 -3
  104. package/src/lib/universal-tx-detector/detector-svm.js +139 -147
  105. package/src/lib/universal-tx-detector/detector.js +145 -157
  106. package/src/lib/universal-tx-detector/normalize.js +7 -7
  107. package/src/lib/utils/external-tx-hash.js +1 -2
  108. package/src/lib/utils.d.ts +44 -0
  109. package/src/lib/utils.js +762 -683
  110. package/src/lib/vm-client/evm-client.js +186 -202
  111. package/src/lib/vm-client/svm-client.d.ts +1 -1
  112. package/src/lib/vm-client/svm-client.js +220 -224
  113. 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((_b = (_a = maybe.shortMessage) !== null && _a !== void 0 ? _a : maybe.message) !== null && _b !== void 0 ? _b : err);
24
+ return String(maybe.shortMessage ?? maybe.message ?? err);
27
25
  }
28
26
  return String(err);
29
27
  }
30
- function waitForEvmReceipt(evmClient, txHash, timeoutMs) {
31
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
32
- const start = Date.now();
33
- // eslint-disable-next-line no-constant-condition
34
- while (true) {
35
- try {
36
- return yield evmClient.publicClient.getTransactionReceipt({
37
- hash: txHash,
38
- });
39
- }
40
- catch (err) {
41
- const msg = getErrorMessage(err);
42
- const retryable = EVM_RECEIPT_NOT_FOUND_RE.test(msg);
43
- if (!retryable || Date.now() - start > timeoutMs) {
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
53
- if (confirmations <= 0) {
54
- (0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, 0, 0, txHash);
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
- (0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03, confirmations, txHash);
58
- const start = Date.now();
59
- const receipt = yield waitForEvmReceipt(evmClient, txHash, timeoutMs);
60
- const targetBlock = receipt.blockNumber + BigInt(confirmations);
61
- let lastEmitted = 0;
62
- // eslint-disable-next-line no-constant-condition
63
- while (true) {
64
- const currentBlock = yield evmClient.publicClient.getBlockNumber();
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 remaining = Number(targetBlock - currentBlock);
72
- const completed = Math.max(1, confirmations - remaining + 1);
73
- if (completed > lastEmitted) {
74
- (0, context_2.fireProgressHook)(ctx, completed >= confirmations
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, completed, confirmations, txHash);
77
- lastEmitted = completed;
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 (Date.now() - start > timeoutMs) {
82
- throw new Error(`Timeout: transaction ${txHash} not confirmed with ${confirmations} confirmations within ${timeoutMs} ms`);
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
- (0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03, confirmations, txSignature);
95
- const start = Date.now();
96
- let lastConfirmed = 0;
97
- // eslint-disable-next-line no-constant-condition
98
- while (true) {
99
- const connection = svmClient.connections[svmClient.currentConnectionIndex];
100
- const { value } = yield connection.getSignatureStatuses([txSignature]);
101
- const status = value[0];
102
- if (status) {
103
- if (status.err) {
104
- throw new Error(`SVM transaction ${txSignature} failed: ${JSON.stringify(status.err)}`);
105
- }
106
- const rawConfirmations = status.confirmations;
107
- const hasNumericConfirmations = rawConfirmations != null;
108
- const currentConfirms = hasNumericConfirmations ? rawConfirmations : 0;
109
- const isFinalized = status.err === null &&
110
- (status.confirmationStatus === 'finalized' || status.confirmations === null);
111
- const hasEnoughConfirmations = hasNumericConfirmations && currentConfirms >= confirmations;
112
- if (currentConfirms > lastConfirmed) {
113
- const clamped = currentConfirms >= confirmations ? confirmations : currentConfirms;
114
- (0, context_2.fireProgressHook)(ctx, clamped >= confirmations
115
- ? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02
116
- : progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01, Math.max(1, clamped), confirmations, txSignature);
117
- lastConfirmed = currentConfirms;
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
- function waitForLockerFeeConfirmation(ctx, txHashBytes) {
134
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
135
- const chain = ctx.universalSigner.account.chain;
136
- const { vm, defaultRPC, fastConfirmations, timeout } = chain_1.CHAIN_INFO[chain];
137
- // Poll silently — the fee-lock path fires SEND-TX-105-02 as its terminal
138
- // confirmation marker; emitting 106-xx here would leak funds-bridge hooks
139
- // into a non-funds-bridge path. Uses the same underlying RPC wait as the
140
- // funds-bridge confirmation helpers but without the 106-03 / 106-03-02
141
- // emissions.
142
- switch (vm) {
143
- case enums_1.VM.EVM: {
144
- const evmClient = (0, context_1.getOriginEvmClient)(ctx);
145
- const txHash = (0, viem_1.bytesToHex)(txHashBytes);
146
- const receipt = yield waitForEvmReceipt(evmClient, txHash, timeout);
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
- yield new Promise((r) => setTimeout(r, 3000));
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
- case enums_1.VM.SVM: {
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
@@ -117,7 +117,7 @@ function decodeRevert(errorMsg) {
117
117
  }
118
118
  }
119
119
  }
120
- catch (_a) {
120
+ catch {
121
121
  /* fall through to unknown */
122
122
  }
123
123
  }
@@ -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
- var _a;
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 { ExecuteParams, UniversalTxResponse } from '../orchestrator.types';
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: ExecuteParams, eventBuffer: ProgressEvent[], getResponseCallbacks: () => ResponseBuilderCallbacks): Promise<UniversalTxResponse>;
11
+ export declare function executeFundsOnly(ctx: OrchestratorContext, execute: LegacyExecuteParams, eventBuffer: ProgressEvent[], getResponseCallbacks: () => ResponseBuilderCallbacks): Promise<UniversalTxResponse>;