@anywalletkit/protocol-swap2-core 0.3.0 → 0.3.2
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 +11 -3
- package/dist/{chunk-42SESAZB.js → chunk-62XJXMGD.js} +11 -3
- package/dist/chunk-62XJXMGD.js.map +1 -0
- package/dist/{chunk-ELHFINC3.js → chunk-KNBYYSYS.js} +2 -2
- package/dist/index.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -3
- package/dist/swap2/base.cjs +11 -3
- package/dist/swap2/base.cjs.map +1 -1
- package/dist/swap2/base.d.cts +9 -1
- package/dist/swap2/base.d.ts +9 -1
- package/dist/swap2/base.js +7 -3
- package/dist/swap2/single.cjs +8 -2
- package/dist/swap2/single.cjs.map +1 -1
- package/dist/swap2/single.js +2 -2
- package/package.json +6 -6
- package/dist/chunk-42SESAZB.js.map +0 -1
- /package/dist/{chunk-ELHFINC3.js.map → chunk-KNBYYSYS.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ export { Swap2ConfigurationError, Swap2Error, Swap2ErrorCode, Swap2ExecutionErro
|
|
|
3
3
|
export { validQuote } from './validate.cjs';
|
|
4
4
|
export { RemoteProviderOptions, remoteProvider } from './remote.cjs';
|
|
5
5
|
export { evmRef, isEvm, namespace, redactUrls } from './util.cjs';
|
|
6
|
-
export { BaseSwap2Protocol, NATIVE_DECIMALS, SWAP2_ID_PREFIX, SerializedExecutionExpectation, Swap2Account, Swap2EngineConfig, Swap2ExecutionPlan, nativeDecimals, nativeUnits } from './swap2/base.cjs';
|
|
6
|
+
export { BaseSwap2Protocol, NATIVE_DECIMALS, SWAP2_CHAIN_ALIASES, SWAP2_ID_PREFIX, SerializedExecutionExpectation, Swap2Account, Swap2EngineConfig, Swap2ExecutionPlan, nativeDecimals, nativeUnits, swap2ChainId } from './swap2/base.cjs';
|
|
7
7
|
export { SingleProviderSwap2 } from './swap2/single.cjs';
|
|
8
8
|
export { SwapActivityOptions, assetLabel, assetMetaFor, callSelector, calledContract, callsContract, chainLabel, describeSwapLike, matchesCall, ownerAssets, shortAddress } from './activity.cjs';
|
|
9
9
|
export { SlippageClass, SlippageContext, SlippageOptions, SlippageSuggestion, slippageClassOf, suggestSlippage } from './slippage.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { Swap2ConfigurationError, Swap2Error, Swap2ErrorCode, Swap2ExecutionErro
|
|
|
3
3
|
export { validQuote } from './validate.js';
|
|
4
4
|
export { RemoteProviderOptions, remoteProvider } from './remote.js';
|
|
5
5
|
export { evmRef, isEvm, namespace, redactUrls } from './util.js';
|
|
6
|
-
export { BaseSwap2Protocol, NATIVE_DECIMALS, SWAP2_ID_PREFIX, SerializedExecutionExpectation, Swap2Account, Swap2EngineConfig, Swap2ExecutionPlan, nativeDecimals, nativeUnits } from './swap2/base.js';
|
|
6
|
+
export { BaseSwap2Protocol, NATIVE_DECIMALS, SWAP2_CHAIN_ALIASES, SWAP2_ID_PREFIX, SerializedExecutionExpectation, Swap2Account, Swap2EngineConfig, Swap2ExecutionPlan, nativeDecimals, nativeUnits, swap2ChainId } from './swap2/base.js';
|
|
7
7
|
export { SingleProviderSwap2 } from './swap2/single.js';
|
|
8
8
|
export { SwapActivityOptions, assetLabel, assetMetaFor, callSelector, calledContract, callsContract, chainLabel, describeSwapLike, matchesCall, ownerAssets, shortAddress } from './activity.js';
|
|
9
9
|
export { SlippageClass, SlippageContext, SlippageOptions, SlippageSuggestion, slippageClassOf, suggestSlippage } from './slippage.js';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SingleProviderSwap2
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KNBYYSYS.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseSwap2Protocol,
|
|
6
6
|
NATIVE_DECIMALS,
|
|
7
|
+
SWAP2_CHAIN_ALIASES,
|
|
7
8
|
SWAP2_ID_PREFIX,
|
|
8
9
|
nativeDecimals,
|
|
9
|
-
nativeUnits
|
|
10
|
-
|
|
10
|
+
nativeUnits,
|
|
11
|
+
swap2ChainId
|
|
12
|
+
} from "./chunk-62XJXMGD.js";
|
|
11
13
|
import "./chunk-55J6XMHW.js";
|
|
12
14
|
import {
|
|
13
15
|
Swap2ConfigurationError,
|
|
@@ -53,6 +55,7 @@ import {
|
|
|
53
55
|
export {
|
|
54
56
|
BaseSwap2Protocol,
|
|
55
57
|
NATIVE_DECIMALS,
|
|
58
|
+
SWAP2_CHAIN_ALIASES,
|
|
56
59
|
SWAP2_ID_PREFIX,
|
|
57
60
|
SingleProviderSwap2,
|
|
58
61
|
Swap2ConfigurationError,
|
|
@@ -85,6 +88,7 @@ export {
|
|
|
85
88
|
shortAddress,
|
|
86
89
|
slippageClassOf,
|
|
87
90
|
suggestSlippage,
|
|
91
|
+
swap2ChainId,
|
|
88
92
|
validQuote
|
|
89
93
|
};
|
|
90
94
|
//# sourceMappingURL=index.js.map
|
package/dist/swap2/base.cjs
CHANGED
|
@@ -22,10 +22,12 @@ var base_exports = {};
|
|
|
22
22
|
__export(base_exports, {
|
|
23
23
|
BaseSwap2Protocol: () => BaseSwap2Protocol,
|
|
24
24
|
NATIVE_DECIMALS: () => NATIVE_DECIMALS,
|
|
25
|
+
SWAP2_CHAIN_ALIASES: () => SWAP2_CHAIN_ALIASES,
|
|
25
26
|
SWAP2_ID_PREFIX: () => SWAP2_ID_PREFIX,
|
|
26
27
|
nativeDecimals: () => nativeDecimals,
|
|
27
28
|
nativeUnits: () => nativeUnits,
|
|
28
|
-
normalizeTypedDomain: () => normalizeTypedDomain
|
|
29
|
+
normalizeTypedDomain: () => normalizeTypedDomain,
|
|
30
|
+
swap2ChainId: () => swap2ChainId
|
|
29
31
|
});
|
|
30
32
|
module.exports = __toCommonJS(base_exports);
|
|
31
33
|
var import_core = require("@anywalletkit/core");
|
|
@@ -243,6 +245,12 @@ function chainType(caip2) {
|
|
|
243
245
|
if (["bitcoin", "litecoin", "doge", "bch", "zcash"].includes(ns)) return "utxo";
|
|
244
246
|
return ns;
|
|
245
247
|
}
|
|
248
|
+
var SWAP2_CHAIN_ALIASES = Object.freeze({
|
|
249
|
+
"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": "solana:mainnet",
|
|
250
|
+
"tron:0x2b6653dc": "tron:728126428",
|
|
251
|
+
"bip122:000000000019d6689c085ae165831e93": "bitcoin:mainnet"
|
|
252
|
+
});
|
|
253
|
+
var swap2ChainId = (chain) => SWAP2_CHAIN_ALIASES[chain] ?? chain;
|
|
246
254
|
function toCaip2(chain, fallback) {
|
|
247
255
|
if (chain == null || chain === "") return fallback;
|
|
248
256
|
if (typeof chain === "number") {
|
|
@@ -257,7 +265,7 @@ function toCaip2(chain, fallback) {
|
|
|
257
265
|
if (!/^[a-z0-9]{3,8}:[-_A-Za-z0-9]{1,32}$/.test(chain)) {
|
|
258
266
|
throw new Swap2ValidationError("swap2: chain must be a valid CAIP-2 identifier");
|
|
259
267
|
}
|
|
260
|
-
return chain;
|
|
268
|
+
return swap2ChainId(chain);
|
|
261
269
|
}
|
|
262
270
|
function toSymbol(caip2, ref) {
|
|
263
271
|
const byToken = ref.startsWith("0x") || ref.length > 20 ? (0, import_swap2_assets.ccAssetByToken)(caip2, ref) : void 0;
|
|
@@ -412,7 +420,7 @@ var BaseSwap2Protocol = class extends import_core.Swap2Protocol {
|
|
|
412
420
|
}
|
|
413
421
|
const expected = this.fromChain;
|
|
414
422
|
const expectedId = expected.startsWith("eip155:") ? expected.slice("eip155:".length) : expected;
|
|
415
|
-
const actualText = typeof actual === "string" ? actual : String(actual);
|
|
423
|
+
const actualText = swap2ChainId(typeof actual === "string" ? actual : String(actual));
|
|
416
424
|
const actualId = actualText.startsWith("eip155:") ? actualText.slice("eip155:".length) : actualText;
|
|
417
425
|
if (actualId !== expectedId) {
|
|
418
426
|
throw new Error(`swap2: account is bound to ${actualText}, but fromChain is ${expected}`);
|