@pushchain/core 5.1.11 → 5.1.12
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/package.json
CHANGED
|
@@ -89,7 +89,7 @@ function prepareTransaction(ctx, params, callbacks) {
|
|
|
89
89
|
// ============================================================================
|
|
90
90
|
function buildHopDescriptor(ctx, params, route, ueaAddress) {
|
|
91
91
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
92
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
93
93
|
// Pass 0 when user omits gasLimit → contract uses per-chain baseGasLimitByChainNamespace
|
|
94
94
|
const gasLimit = (_a = params.gasLimit) !== null && _a !== void 0 ? _a : BigInt(0);
|
|
95
95
|
const routeStr = route;
|
|
@@ -227,10 +227,39 @@ function buildHopDescriptor(ctx, params, route, ueaAddress) {
|
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
+
else if ((_f = params.funds) === null || _f === void 0 ? void 0 : _f.amount) {
|
|
231
|
+
// Funds-only transfer (no data, no value). Without this branch the
|
|
232
|
+
// CEA multicall is empty and relayed funds stay in the CEA instead
|
|
233
|
+
// of reaching the caller's recipient.
|
|
234
|
+
const token = params.funds.token;
|
|
235
|
+
if (token) {
|
|
236
|
+
if (token.mechanism === 'native') {
|
|
237
|
+
if (target.address.toLowerCase() !== ceaAddress.toLowerCase()) {
|
|
238
|
+
ceaMulticalls.push({
|
|
239
|
+
to: target.address,
|
|
240
|
+
value: params.funds.amount,
|
|
241
|
+
data: '0x',
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
const erc20Transfer = (0, viem_1.encodeFunctionData)({
|
|
247
|
+
abi: erc20_evm_1.ERC20_EVM,
|
|
248
|
+
functionName: 'transfer',
|
|
249
|
+
args: [target.address, params.funds.amount],
|
|
250
|
+
});
|
|
251
|
+
ceaMulticalls.push({
|
|
252
|
+
to: token.address,
|
|
253
|
+
value: BigInt(0),
|
|
254
|
+
data: erc20Transfer,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
230
259
|
// Determine PRC-20 token and burn amount
|
|
231
260
|
let prc20Token = selectors_1.ZERO_ADDRESS;
|
|
232
261
|
let burnAmount = BigInt(0);
|
|
233
|
-
if ((
|
|
262
|
+
if ((_g = params.funds) === null || _g === void 0 ? void 0 : _g.amount) {
|
|
234
263
|
const token = params.funds.token;
|
|
235
264
|
if (token) {
|
|
236
265
|
prc20Token = push_chain_1.PushChain.utils.tokens.getPRC20Address(token).address;
|
|
@@ -288,7 +317,7 @@ function buildHopDescriptor(ctx, params, route, ueaAddress) {
|
|
|
288
317
|
Buffer.from(ceaPda.toBytes()).toString('hex'));
|
|
289
318
|
let amount = BigInt(0);
|
|
290
319
|
let prc20Token;
|
|
291
|
-
if (((
|
|
320
|
+
if (((_h = params.funds) === null || _h === void 0 ? void 0 : _h.amount) && params.funds.amount > BigInt(0)) {
|
|
292
321
|
amount = params.funds.amount;
|
|
293
322
|
const token = params.funds.token;
|
|
294
323
|
if (token && token.address) {
|
|
@@ -319,14 +348,14 @@ function buildHopDescriptor(ctx, params, route, ueaAddress) {
|
|
|
319
348
|
gasFee,
|
|
320
349
|
sizing });
|
|
321
350
|
}
|
|
322
|
-
const { cea: ceaAddress } = yield (0, cea_utils_1.getCEAAddress)(ueaAddress, sourceChain, (
|
|
351
|
+
const { cea: ceaAddress } = yield (0, cea_utils_1.getCEAAddress)(ueaAddress, sourceChain, (_j = ctx.rpcUrls[sourceChain]) === null || _j === void 0 ? void 0 : _j[0]);
|
|
323
352
|
// CEA auto-deploys on-chain: Vault.finalizeUniversalTx calls CEAFactory.deployCEA()
|
|
324
353
|
// if CEA doesn't exist yet. No SDK-side blocking needed.
|
|
325
354
|
// Determine token/amount for the inbound
|
|
326
355
|
let tokenAddress = selectors_1.ZERO_ADDRESS;
|
|
327
356
|
let amount = BigInt(0);
|
|
328
357
|
let nativeValue = BigInt(0);
|
|
329
|
-
if ((
|
|
358
|
+
if ((_k = params.funds) === null || _k === void 0 ? void 0 : _k.amount) {
|
|
330
359
|
const token = params.funds.token;
|
|
331
360
|
if (token) {
|
|
332
361
|
if (token.mechanism === 'native') {
|
|
@@ -116,7 +116,7 @@ function resolveR2Prc20TokenSvm(params, targetChain, pushNetwork, hasSvmExecute)
|
|
|
116
116
|
* multicall when the target IS the CEA (avoids a CEA._handleMulticall revert).
|
|
117
117
|
*/
|
|
118
118
|
function buildR2CeaPayloadEvm(params, ceaAddress, targetAddress) {
|
|
119
|
-
var _a, _b;
|
|
119
|
+
var _a, _b, _c;
|
|
120
120
|
if (params.migration) {
|
|
121
121
|
return (0, payload_builders_1.buildMigrationPayload)();
|
|
122
122
|
}
|
|
@@ -164,6 +164,38 @@ function buildR2CeaPayloadEvm(params, ceaAddress, targetAddress) {
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
+
else if ((_c = params.funds) === null || _c === void 0 ? void 0 : _c.amount) {
|
|
168
|
+
// Funds-only transfer (no data, no value). Without this branch the CEA
|
|
169
|
+
// multicall is empty and the relayed funds sit in the CEA instead of
|
|
170
|
+
// being forwarded to the caller's recipient.
|
|
171
|
+
const token = params.funds.token;
|
|
172
|
+
if (token) {
|
|
173
|
+
if (token.mechanism === 'native') {
|
|
174
|
+
// Native funds (e.g. pETH → ETH): forward value to the recipient.
|
|
175
|
+
// Self-CEA is skipped — the gateway already deposits into the CEA.
|
|
176
|
+
if (targetAddress.toLowerCase() !== ceaAddress.toLowerCase()) {
|
|
177
|
+
ceaMulticalls.push({
|
|
178
|
+
to: targetAddress,
|
|
179
|
+
value: params.funds.amount,
|
|
180
|
+
data: '0x',
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
// ERC-20 funds: forward via ERC20.transfer from the CEA.
|
|
186
|
+
const erc20Transfer = (0, viem_1.encodeFunctionData)({
|
|
187
|
+
abi: erc20_evm_1.ERC20_EVM,
|
|
188
|
+
functionName: 'transfer',
|
|
189
|
+
args: [targetAddress, params.funds.amount],
|
|
190
|
+
});
|
|
191
|
+
ceaMulticalls.push({
|
|
192
|
+
to: token.address,
|
|
193
|
+
value: BigInt(0),
|
|
194
|
+
data: erc20Transfer,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
167
199
|
return (0, payload_builders_1.buildCeaMulticallPayload)(ceaMulticalls);
|
|
168
200
|
}
|
|
169
201
|
const SIZER_HOOK_BY_ROUTE = {
|
|
@@ -8,12 +8,19 @@ const withTimestamp = (fn) => {
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
9
|
return (...args) => (Object.assign(Object.assign({}, fn(...args)), { timestamp: new Date().toISOString() }));
|
|
10
10
|
};
|
|
11
|
+
const ACRONYMS = new Set(['BNB']);
|
|
12
|
+
const toTitleCase = (key) => key
|
|
13
|
+
.split('_')
|
|
14
|
+
.map((part) => ACRONYMS.has(part)
|
|
15
|
+
? part
|
|
16
|
+
: part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
|
|
17
|
+
.join(' ');
|
|
11
18
|
const friendlyChain = (chainOrNs) => {
|
|
12
|
-
var _a;
|
|
13
19
|
if (!chainOrNs)
|
|
14
20
|
return 'chain';
|
|
15
21
|
const asString = String(chainOrNs);
|
|
16
|
-
|
|
22
|
+
const key = utils_1.Utils.chains.getChainName(asString);
|
|
23
|
+
return key ? toTitleCase(key) : asString;
|
|
17
24
|
};
|
|
18
25
|
/**
|
|
19
26
|
* Classify a sign-time error as either a true wallet user-decline
|