@anywalletkit/protocol-swap2-core 0.7.0 → 0.8.0
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/README.md +1 -1
- package/dist/{chunk-WBYCNN6S.js → chunk-5FPDKWBG.js} +7 -2
- package/dist/chunk-5FPDKWBG.js.map +1 -0
- package/dist/{chunk-CT2REW2V.js → chunk-6MTZNYKM.js} +2 -1
- package/dist/chunk-6MTZNYKM.js.map +1 -0
- package/dist/{chunk-5E5FWYZQ.js → chunk-CRCDWV3L.js} +8 -2
- package/dist/chunk-CRCDWV3L.js.map +1 -0
- package/dist/{chunk-U653ZREM.js → chunk-FHEU7E5A.js} +3 -3
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/remote.cjs +1 -0
- package/dist/remote.cjs.map +1 -1
- package/dist/remote.d.cts +8 -1
- package/dist/remote.d.ts +8 -1
- package/dist/remote.js +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +1 -1
- package/dist/swap2/base.cjs +7 -1
- package/dist/swap2/base.cjs.map +1 -1
- package/dist/swap2/base.js +1 -1
- package/dist/swap2/single.cjs +13 -2
- package/dist/swap2/single.cjs.map +1 -1
- package/dist/swap2/single.js +3 -3
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +17 -0
- package/dist/types.d.ts +17 -0
- package/dist/validate.cjs +6 -1
- package/dist/validate.cjs.map +1 -1
- package/dist/validate.d.cts +7 -5
- package/dist/validate.d.ts +7 -5
- package/dist/validate.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-5E5FWYZQ.js.map +0 -1
- package/dist/chunk-CT2REW2V.js.map +0 -1
- package/dist/chunk-WBYCNN6S.js.map +0 -1
- /package/dist/{chunk-U653ZREM.js.map → chunk-FHEU7E5A.js.map} +0 -0
package/dist/swap2/base.js
CHANGED
package/dist/swap2/single.cjs
CHANGED
|
@@ -764,12 +764,15 @@ var BaseSwap2Protocol = class extends import_core.Swap2Protocol {
|
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
766
|
const executionModels = [unsigned.data !== void 0, unsigned.bodyBoc !== void 0, unsigned.typedData !== void 0].filter(Boolean).length;
|
|
767
|
-
if (executionModels > 1 || unsigned.memo !== void 0 && (unsigned.bodyBoc !== void 0 || unsigned.typedData !== void 0)) {
|
|
767
|
+
if (executionModels > 1 || unsigned.memo !== void 0 && (unsigned.bodyBoc !== void 0 || unsigned.typedData !== void 0) || unsigned.orderExtension !== void 0 && unsigned.typedData === void 0) {
|
|
768
768
|
throw new Error("swap2: provider returned ambiguous execution payloads");
|
|
769
769
|
}
|
|
770
770
|
if (unsigned.approvalAddress && !unsigned.data && !unsigned.typedData) {
|
|
771
771
|
throw new Error("swap2: approval is only valid for calldata or typed-order execution");
|
|
772
772
|
}
|
|
773
|
+
if (provider.remote === true && provider.depositAddressRoutes !== true && unsigned.data === void 0 && unsigned.bodyBoc === void 0 && unsigned.typedData === void 0 && !serialized) {
|
|
774
|
+
throw new Swap2ValidationError(`swap2: remote provider '${q.provider}' sends the input to ${unsigned.to}, an address its backend named, and the app did not allow deposit-address routes for it (remoteProvider depositAddressRoutes) \u2014 refused`);
|
|
775
|
+
}
|
|
773
776
|
const tronSource = this.fromChain.startsWith("tron:");
|
|
774
777
|
const nearSource = this.fromChain.startsWith("near:");
|
|
775
778
|
if (unsigned.memo && !this.fromChain.startsWith("ton:") && !tronSource && !nearSource) {
|
|
@@ -876,6 +879,9 @@ var BaseSwap2Protocol = class extends import_core.Swap2Protocol {
|
|
|
876
879
|
throw new Swap2ValidationError(`swap2: remote provider '${q.provider}' asks to approve ${unsigned.approvalAddress} on ${this.fromChain}, which the app did not pin as a spender (remoteProvider spenders) \u2014 refused`);
|
|
877
880
|
}
|
|
878
881
|
if (unsigned.typedData !== void 0) {
|
|
882
|
+
if (remote && provider.verifiesBuilds !== true) {
|
|
883
|
+
throw new Swap2ValidationError(`swap2: remote provider '${q.provider}' asks to sign a typed order, which needs the app's own validator (remoteProvider verifyBuild) \u2014 refused`);
|
|
884
|
+
}
|
|
879
885
|
const chainId = this.fromChain.startsWith("eip155:") ? Number(this.fromChain.slice("eip155:".length)) : null;
|
|
880
886
|
assertTypedOrder(unsigned.typedData, unsigned.approvalAddress, { self: selfAddress, token: source.contract ?? void 0, amount: q.sourceAmount, chainId });
|
|
881
887
|
}
|
|
@@ -1373,8 +1379,13 @@ function validQuote(q, params, provider) {
|
|
|
1373
1379
|
}
|
|
1374
1380
|
}
|
|
1375
1381
|
function remotePinRefusal(provider, q, chain) {
|
|
1376
|
-
if (provider.remote !== true
|
|
1382
|
+
if (provider.remote !== true) return null;
|
|
1377
1383
|
const tx = q.txRequest;
|
|
1384
|
+
const plain = tx ? tx.data === void 0 && tx.serializedTx === void 0 : typeof q.depositAddress === "string" && q.depositAddress !== "";
|
|
1385
|
+
if (plain && provider.depositAddressRoutes !== true) {
|
|
1386
|
+
return `${provider.name}: the route pays ${tx?.to || q.depositAddress}, an address the backend named, and the app did not allow deposit-address routes for this provider (remoteProvider depositAddressRoutes)`;
|
|
1387
|
+
}
|
|
1388
|
+
if (!chain.startsWith("eip155:")) return null;
|
|
1378
1389
|
if (!tx || tx.serializedTx !== void 0) return null;
|
|
1379
1390
|
const pinned = (list, address) => (list ?? []).some((a) => typeof a === "string" && a.toLowerCase() === address.toLowerCase());
|
|
1380
1391
|
if (tx.approvalAddress && !pinned(provider.spenders?.(chain), tx.approvalAddress)) {
|