@ercworldio/blockchain-shared 1.0.6 → 1.0.7
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.
|
@@ -365,7 +365,7 @@
|
|
|
365
365
|
},
|
|
366
366
|
{
|
|
367
367
|
"name": "qn-custodial-webhook-pol-prod-ab120",
|
|
368
|
-
"network": "
|
|
368
|
+
"network": "polygon-mainnet",
|
|
369
369
|
"template": "evmWalletFilter"
|
|
370
370
|
}
|
|
371
371
|
],
|
|
@@ -543,7 +543,7 @@
|
|
|
543
543
|
"tronConfig": {
|
|
544
544
|
"trxTransferCost": 270000,
|
|
545
545
|
"trc20TransferCost": 4000000,
|
|
546
|
-
"rentEnergyWallet": "
|
|
546
|
+
"rentEnergyWallet": "TTMcDoAyr9BThYDiHDUf2NJQGoK34ScYSL"
|
|
547
547
|
},
|
|
548
548
|
"accounting": {
|
|
549
549
|
"funding_wallet": "TQ4gL5VGbKWDoUwPMQa9JE9939ijfmPauB",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custodial.d.ts","sourceRoot":"","sources":["../../src/utils/custodial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,MAAM,EAAwC,MAAM,QAAQ,CAAC;AAC7G,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAYnF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAMvD,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,GAAG,cAAc,CAAC;AACpE,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,OAAO,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,kCAAkC;IAC/C,gBAAgB,EAAE,MAAM,CAAC;I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AE,QAAQ,OAAO;;;EAkG1J,CAAA;AAGD,eAAO,MAAM,2BAA2B,GAAU,UAAU,OAAO,EAAE,SAAS,sCAAsC,EAAE,QAAQ,MAAM,EAAE,QAAQ,OAAO,oBAwBpJ,CAAA;AAED,eAAO,MAAM,gCAAgC,GAAU,UAAU,OAAO,EAAE,UAAU,kCAAkC,EAAE,EAAE,QAAQ,aAAa,EAAE,QAAQ,OAAO,oBAoE/J,CAAA;AAED,eAAO,MAAM,WAAW,GACpB,UAAU,MAAM,CAAC,QAAQ,EACzB,cAAc,MAAM,EACpB,gBAAgB,MAAM,GAAG,IAAI,EAC7B,QAAQ,MAAM,EACd,aAAa,MAAM,EACnB,SAAS,MAAM,EACf,iBAAiB,eAAe,EAChC,wBAAsB,oBAgEzB,CAAA"}
|
package/build/utils/custodial.js
CHANGED
|
@@ -204,6 +204,7 @@ const estimate_execute_withdrawal = (chain_id, payload, caller, config) => __awa
|
|
|
204
204
|
});
|
|
205
205
|
exports.estimate_execute_withdrawal = estimate_execute_withdrawal;
|
|
206
206
|
const estimate_escrow_method_call_cost = (chain_id, payloads, dbPool, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
207
|
+
var _a;
|
|
207
208
|
const errors = new TransactionsErrors_1.default();
|
|
208
209
|
if (payloads.length === 0)
|
|
209
210
|
throw new Error(errors.EmptyPayload("estimating Escrow withdrawal cost"));
|
|
@@ -219,6 +220,24 @@ const estimate_escrow_method_call_cost = (chain_id, payloads, dbPool, config) =>
|
|
|
219
220
|
receiverAddress: p.receiver
|
|
220
221
|
};
|
|
221
222
|
});
|
|
223
|
+
// Check reserves before ever attempting to simulate. A probe against an empty (or
|
|
224
|
+
// under-funded) reserve reverts inside IERC20.safeTransfer, and how that surfaces is
|
|
225
|
+
// entirely up to the token: some revert with a decodable custom error, but non-standard
|
|
226
|
+
// tokens (e.g. mainnet USDT's pre-0.4.22 contract) revert via a bare assert/INVALID opcode
|
|
227
|
+
// with zero returndata — nothing to pattern-match on. Reserves are known upfront and
|
|
228
|
+
// deterministic, so check them directly instead of inferring "no funds" from the shape of
|
|
229
|
+
// a revert. A batch can mix tokens (the queue isn't token-filtered) and `_withdraw` checks
|
|
230
|
+
// each request's reserves independently in the same atomic call, so any one under-funded
|
|
231
|
+
// token sinks the whole batch — check every distinct token, not just the first.
|
|
232
|
+
// Message matches the string this call's callers already fall back on.
|
|
233
|
+
const required_per_token = new Map();
|
|
234
|
+
for (const p of batch_payloads) {
|
|
235
|
+
required_per_token.set(p.tokenAddress, ((_a = required_per_token.get(p.tokenAddress)) !== null && _a !== void 0 ? _a : BigInt(0)) + p.amount);
|
|
236
|
+
}
|
|
237
|
+
const coverages = yield Promise.all([...required_per_token.entries()].map(([tokenAddress, amount]) => Escrow.getReservesCoverage(amount, tokenAddress).then(c => ({ amount, coverage: c }))));
|
|
238
|
+
if (coverages.some(({ amount, coverage }) => coverage.currentReserves < amount)) {
|
|
239
|
+
throw new Error("InsufficientReserves");
|
|
240
|
+
}
|
|
222
241
|
const data = Escrow.interface.encodeFunctionData('batch_withdraw', [
|
|
223
242
|
batch_payloads
|
|
224
243
|
]);
|