@trustware/sdk-staging 1.1.17-staging.6 → 1.1.18-staging.1
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/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/core.cjs +36 -5
- package/dist/core.cjs.map +1 -1
- package/dist/core.mjs +36 -5
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +358 -489
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +358 -489
- package/dist/index.mjs.map +1 -1
- package/dist/smart-account.cjs +1 -1
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.mjs +1 -1
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +1 -1
- package/dist/wallet.mjs +1 -1
- package/dist/widget.cjs +358 -489
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +358 -489
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/constants.cjs
CHANGED
|
@@ -30,7 +30,7 @@ __export(constants_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(constants_exports);
|
|
32
32
|
var SDK_NAME = "@trustware/sdk";
|
|
33
|
-
var SDK_VERSION = "1.1.
|
|
33
|
+
var SDK_VERSION = "1.1.18-staging.1";
|
|
34
34
|
var API_ROOT = "https://bv-staging-api.trustware.io";
|
|
35
35
|
var GTM_ID = "GTM-TZDGNCXB";
|
|
36
36
|
var API_PREFIX = "/api";
|
package/dist/constants.mjs
CHANGED
package/dist/core.cjs
CHANGED
|
@@ -132,7 +132,7 @@ var init_constants = __esm({
|
|
|
132
132
|
"src/constants.ts"() {
|
|
133
133
|
"use strict";
|
|
134
134
|
SDK_NAME = "@trustware/sdk";
|
|
135
|
-
SDK_VERSION = "1.1.
|
|
135
|
+
SDK_VERSION = "1.1.18-staging.1";
|
|
136
136
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
137
137
|
API_PREFIX = "/api";
|
|
138
138
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -4623,6 +4623,32 @@ var init_routeError = __esm({
|
|
|
4623
4623
|
}
|
|
4624
4624
|
});
|
|
4625
4625
|
|
|
4626
|
+
// src/core/routeApprovals.ts
|
|
4627
|
+
function approvalAmountWei(approval, stepIndex) {
|
|
4628
|
+
const { amount } = approval;
|
|
4629
|
+
if (amount === void 0 || amount === "") {
|
|
4630
|
+
throw new Error(
|
|
4631
|
+
`Route approval ${stepIndex} (spender ${String(approval.spender)}) has no amount.`
|
|
4632
|
+
);
|
|
4633
|
+
}
|
|
4634
|
+
if (!DECIMAL_INTEGER.test(amount)) {
|
|
4635
|
+
throw new Error(
|
|
4636
|
+
`Route approval ${stepIndex} (spender ${String(approval.spender)}) has an invalid amount "${amount}".`
|
|
4637
|
+
);
|
|
4638
|
+
}
|
|
4639
|
+
return BigInt(amount);
|
|
4640
|
+
}
|
|
4641
|
+
function assertValidRouteApprovals(approvals) {
|
|
4642
|
+
(approvals ?? []).forEach(approvalAmountWei);
|
|
4643
|
+
}
|
|
4644
|
+
var DECIMAL_INTEGER;
|
|
4645
|
+
var init_routeApprovals = __esm({
|
|
4646
|
+
"src/core/routeApprovals.ts"() {
|
|
4647
|
+
"use strict";
|
|
4648
|
+
DECIMAL_INTEGER = /^\d+$/;
|
|
4649
|
+
}
|
|
4650
|
+
});
|
|
4651
|
+
|
|
4626
4652
|
// src/core/routeValue.ts
|
|
4627
4653
|
function parseUsd(value) {
|
|
4628
4654
|
if (value == null) return null;
|
|
@@ -4783,6 +4809,7 @@ async function buildRoute(body, signal) {
|
|
|
4783
4809
|
if (!txReq?.data) {
|
|
4784
4810
|
throw new Error("Invalid route: missing transaction data");
|
|
4785
4811
|
}
|
|
4812
|
+
assertValidRouteApprovals(route?.execution?.approvals);
|
|
4786
4813
|
assertRouteDeliversValue(route);
|
|
4787
4814
|
return { intentId, txReq, actions, finalExchangeRate, route, sponsorship };
|
|
4788
4815
|
}
|
|
@@ -4903,6 +4930,7 @@ var init_routes = __esm({
|
|
|
4903
4930
|
"use strict";
|
|
4904
4931
|
init_http();
|
|
4905
4932
|
init_routeError();
|
|
4933
|
+
init_routeApprovals();
|
|
4906
4934
|
init_routeValue();
|
|
4907
4935
|
init_store();
|
|
4908
4936
|
init_address();
|
|
@@ -5197,11 +5225,13 @@ async function ensureApprovals(w, approvals, fallbackChainId, intentId, routeAmo
|
|
|
5197
5225
|
for (const [stepIndex, approval] of approvals.entries()) {
|
|
5198
5226
|
const spender = approval.spender;
|
|
5199
5227
|
const tokenAddress = approval.tokenAddress;
|
|
5200
|
-
|
|
5201
|
-
if (!spender || !tokenAddress || !amount) continue;
|
|
5228
|
+
if (!spender || !tokenAddress) continue;
|
|
5202
5229
|
const chainId = approval.chainId || String(fallbackChainId ?? "");
|
|
5203
5230
|
if (!chainId) continue;
|
|
5204
|
-
const amountWei = requiredApprovalAmount(
|
|
5231
|
+
const amountWei = requiredApprovalAmount(
|
|
5232
|
+
approvalAmountWei(approval, stepIndex),
|
|
5233
|
+
routeAmountWei
|
|
5234
|
+
);
|
|
5205
5235
|
let currentAllowance = 0n;
|
|
5206
5236
|
try {
|
|
5207
5237
|
const { allowance } = await getEVMAllowance({
|
|
@@ -5287,7 +5317,6 @@ async function sendRouteTransactionReporting(b, fallbackChainId, options, onAcce
|
|
|
5287
5317
|
)}).`
|
|
5288
5318
|
);
|
|
5289
5319
|
}
|
|
5290
|
-
await ensureWalletOnChain(w, target);
|
|
5291
5320
|
if (!validatedSponsorship && !options?.approvalsEnsured) {
|
|
5292
5321
|
await ensureApprovals(
|
|
5293
5322
|
w,
|
|
@@ -5297,6 +5326,7 @@ async function sendRouteTransactionReporting(b, fallbackChainId, options, onAcce
|
|
|
5297
5326
|
BigInt(b.route?.estimate?.fromAmount ?? "0")
|
|
5298
5327
|
);
|
|
5299
5328
|
}
|
|
5329
|
+
await ensureWalletOnChain(w, target);
|
|
5300
5330
|
if (w.type === "eip1193") {
|
|
5301
5331
|
const from = await w.getAddress();
|
|
5302
5332
|
const hexValue = value ? `0x${value.toString(16)}` : "0x0";
|
|
@@ -5463,6 +5493,7 @@ var import_viem2, erc20ApproveAbi, NOT_FOUND_GRACE_MS, UNLIMITED_APPROVAL_FLOOR;
|
|
|
5463
5493
|
var init_tx = __esm({
|
|
5464
5494
|
"src/core/tx.ts"() {
|
|
5465
5495
|
"use strict";
|
|
5496
|
+
init_routeApprovals();
|
|
5466
5497
|
init_routeValue();
|
|
5467
5498
|
init_wallets();
|
|
5468
5499
|
init_routes();
|