@lifi/sdk 3.7.0-beta.0 → 3.7.0-beta.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/package.json +3 -3
- package/src/_cjs/core/EVM/isBatchingSupported.js +6 -19
- package/src/_cjs/core/EVM/isBatchingSupported.js.map +1 -1
- package/src/_cjs/version.js +1 -1
- package/src/_esm/core/EVM/isBatchingSupported.js +6 -18
- package/src/_esm/core/EVM/isBatchingSupported.js.map +1 -1
- package/src/_esm/version.js +1 -1
- package/src/_types/core/EVM/isBatchingSupported.d.ts +1 -3
- package/src/_types/core/EVM/isBatchingSupported.d.ts.map +1 -1
- package/src/_types/version.d.ts +1 -1
- package/src/core/EVM/isBatchingSupported.ts +7 -46
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/lifinance/sdk/issues"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@bigmi/core": "
|
|
6
|
+
"@bigmi/core": "0.2.0-beta.2",
|
|
7
7
|
"@lifi/types": "^17.13.0",
|
|
8
8
|
"@noble/curves": "^1.9.0",
|
|
9
9
|
"@solana/wallet-adapter-base": "^0.9.24",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bech32": "^2.0.0",
|
|
12
12
|
"bitcoinjs-lib": "^7.0.0-rc.0",
|
|
13
13
|
"bs58": "^6.0.0",
|
|
14
|
-
"viem": "^2.29.
|
|
14
|
+
"viem": "^2.29.2"
|
|
15
15
|
},
|
|
16
16
|
"description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
|
|
17
17
|
"exports": {
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"sideEffects": false,
|
|
68
68
|
"types": "./src/_types/index.d.ts",
|
|
69
69
|
"typings": "./src/_types/index.d.ts",
|
|
70
|
-
"version": "3.7.0-beta.
|
|
70
|
+
"version": "3.7.0-beta.2"
|
|
71
71
|
}
|
|
@@ -1,27 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCapabilities = getCapabilities;
|
|
4
3
|
exports.isBatchingSupported = isBatchingSupported;
|
|
5
4
|
const types_1 = require("@lifi/types");
|
|
6
|
-
const
|
|
5
|
+
const actions_1 = require("viem/actions");
|
|
7
6
|
const utils_1 = require("viem/utils");
|
|
8
7
|
const config_js_1 = require("../../config.js");
|
|
9
|
-
|
|
10
|
-
const { account = client.account, chainId } = parameters;
|
|
11
|
-
const account_ = account ? (0, accounts_1.parseAccount)(account) : undefined;
|
|
12
|
-
const capabilities_raw = await client.request({
|
|
13
|
-
method: 'wallet_getCapabilities',
|
|
14
|
-
params: [account_?.address],
|
|
15
|
-
}, {
|
|
16
|
-
dedupe: true,
|
|
17
|
-
retryCount: 0,
|
|
18
|
-
});
|
|
19
|
-
const capabilities = {};
|
|
20
|
-
for (const [key, value] of Object.entries(capabilities_raw)) {
|
|
21
|
-
capabilities[Number(key)] = value;
|
|
22
|
-
}
|
|
23
|
-
return (typeof chainId === 'number' ? capabilities[chainId] : capabilities);
|
|
24
|
-
}
|
|
8
|
+
const sleep_js_1 = require("../../utils/sleep.js");
|
|
25
9
|
async function isBatchingSupported({ client, chainId, }) {
|
|
26
10
|
const _client = client ??
|
|
27
11
|
(await config_js_1.config.getProvider(types_1.ChainType.EVM)?.getWalletClient?.());
|
|
@@ -29,7 +13,10 @@ async function isBatchingSupported({ client, chainId, }) {
|
|
|
29
13
|
throw new Error('WalletClient is not provided.');
|
|
30
14
|
}
|
|
31
15
|
try {
|
|
32
|
-
const capabilities = await
|
|
16
|
+
const capabilities = await Promise.race([
|
|
17
|
+
(0, utils_1.getAction)(_client, actions_1.getCapabilities, 'getCapabilities')({ chainId }),
|
|
18
|
+
(0, sleep_js_1.sleep)(2_000),
|
|
19
|
+
]);
|
|
33
20
|
return (capabilities?.atomicBatch?.supported ||
|
|
34
21
|
capabilities?.atomic?.status === 'supported' ||
|
|
35
22
|
capabilities?.atomic?.status === 'ready' ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isBatchingSupported.js","sourceRoot":"","sources":["../../../core/EVM/isBatchingSupported.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"isBatchingSupported.js","sourceRoot":"","sources":["../../../core/EVM/isBatchingSupported.ts"],"names":[],"mappings":";;AAQA,kDAiCC;AAzCD,uCAAuC;AAEvC,0CAA8C;AAC9C,sCAAsC;AACtC,+CAAwC;AACxC,mDAA4C;AAGrC,KAAK,UAAU,mBAAmB,CAAC,EACxC,MAAM,EACN,OAAO,GAIR;IACC,MAAM,OAAO,GACX,MAAM;QACN,CAAC,MACC,kBAAM,CAAC,WAAW,CAAC,iBAAS,CAAC,GAAG,CACjC,EAAE,eAAe,EAAE,EAAE,CAAC,CAAA;IAEzB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAED,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;YACtC,IAAA,iBAAS,EAAC,OAAO,EAAE,yBAAe,EAAE,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;YACnE,IAAA,gBAAK,EAAC,KAAK,CAAC;SACb,CAAC,CAAA;QACF,OAAO,CACL,YAAY,EAAE,WAAW,EAAE,SAAS;YACpC,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,WAAW;YAC5C,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO;YACxC,KAAK,CACN,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QAGP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
package/src/_cjs/version.js
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
import { ChainType } from '@lifi/types';
|
|
2
|
-
import {
|
|
2
|
+
import { getCapabilities } from 'viem/actions';
|
|
3
3
|
import { getAction } from 'viem/utils';
|
|
4
4
|
import { config } from '../../config.js';
|
|
5
|
-
|
|
6
|
-
const { account = client.account, chainId } = parameters;
|
|
7
|
-
const account_ = account ? parseAccount(account) : undefined;
|
|
8
|
-
const capabilities_raw = await client.request({
|
|
9
|
-
method: 'wallet_getCapabilities',
|
|
10
|
-
params: [account_?.address],
|
|
11
|
-
}, {
|
|
12
|
-
dedupe: true,
|
|
13
|
-
retryCount: 0,
|
|
14
|
-
});
|
|
15
|
-
const capabilities = {};
|
|
16
|
-
for (const [key, value] of Object.entries(capabilities_raw)) {
|
|
17
|
-
capabilities[Number(key)] = value;
|
|
18
|
-
}
|
|
19
|
-
return (typeof chainId === 'number' ? capabilities[chainId] : capabilities);
|
|
20
|
-
}
|
|
5
|
+
import { sleep } from '../../utils/sleep.js';
|
|
21
6
|
export async function isBatchingSupported({ client, chainId, }) {
|
|
22
7
|
const _client = client ??
|
|
23
8
|
(await config.getProvider(ChainType.EVM)?.getWalletClient?.());
|
|
@@ -25,7 +10,10 @@ export async function isBatchingSupported({ client, chainId, }) {
|
|
|
25
10
|
throw new Error('WalletClient is not provided.');
|
|
26
11
|
}
|
|
27
12
|
try {
|
|
28
|
-
const capabilities = await
|
|
13
|
+
const capabilities = await Promise.race([
|
|
14
|
+
getAction(_client, getCapabilities, 'getCapabilities')({ chainId }),
|
|
15
|
+
sleep(2_000),
|
|
16
|
+
]);
|
|
29
17
|
return (capabilities?.atomicBatch?.supported ||
|
|
30
18
|
capabilities?.atomic?.status === 'supported' ||
|
|
31
19
|
capabilities?.atomic?.status === 'ready' ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isBatchingSupported.js","sourceRoot":"","sources":["../../../core/EVM/isBatchingSupported.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"isBatchingSupported.js","sourceRoot":"","sources":["../../../core/EVM/isBatchingSupported.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAG5C,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,EACxC,MAAM,EACN,OAAO,GAIR;IACC,MAAM,OAAO,GACX,MAAM;QACN,CAAC,MACC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CACjC,EAAE,eAAe,EAAE,EAAE,CAAC,CAAA;IAEzB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAED,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;YACtC,SAAS,CAAC,OAAO,EAAE,eAAe,EAAE,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;YACnE,KAAK,CAAC,KAAK,CAAC;SACb,CAAC,CAAA;QACF,OAAO,CACL,YAAY,EAAE,WAAW,EAAE,SAAS;YACpC,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,WAAW;YAC5C,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO;YACxC,KAAK,CACN,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,oEAAoE;QACpE,+CAA+C;QAC/C,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
package/src/_esm/version.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { Client
|
|
2
|
-
import type { GetCapabilitiesParameters, GetCapabilitiesReturnType } from 'viem';
|
|
3
|
-
export declare function getCapabilities<chainId extends number | undefined = undefined>(client: Client<Transport>, parameters?: GetCapabilitiesParameters<chainId>): Promise<GetCapabilitiesReturnType<chainId>>;
|
|
1
|
+
import type { Client } from 'viem';
|
|
4
2
|
export declare function isBatchingSupported({ client, chainId, }: {
|
|
5
3
|
client?: Client;
|
|
6
4
|
chainId: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isBatchingSupported.d.ts","sourceRoot":"","sources":["../../../core/EVM/isBatchingSupported.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"isBatchingSupported.d.ts","sourceRoot":"","sources":["../../../core/EVM/isBatchingSupported.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAOlC,wBAAsB,mBAAmB,CAAC,EACxC,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,OAAO,CAAC,OAAO,CAAC,CA2BnB"}
|
package/src/_types/version.d.ts
CHANGED
|
@@ -1,49 +1,11 @@
|
|
|
1
1
|
import { ChainType } from '@lifi/types'
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
Transport,
|
|
5
|
-
WalletCapabilities,
|
|
6
|
-
WalletCapabilitiesRecord,
|
|
7
|
-
} from 'viem'
|
|
8
|
-
import type { GetCapabilitiesParameters, GetCapabilitiesReturnType } from 'viem'
|
|
9
|
-
import { parseAccount } from 'viem/accounts'
|
|
2
|
+
import type { Client } from 'viem'
|
|
3
|
+
import { getCapabilities } from 'viem/actions'
|
|
10
4
|
import { getAction } from 'viem/utils'
|
|
11
5
|
import { config } from '../../config.js'
|
|
6
|
+
import { sleep } from '../../utils/sleep.js'
|
|
12
7
|
import type { EVMProvider } from './types.js'
|
|
13
8
|
|
|
14
|
-
export async function getCapabilities<
|
|
15
|
-
chainId extends number | undefined = undefined,
|
|
16
|
-
>(
|
|
17
|
-
client: Client<Transport>,
|
|
18
|
-
parameters: GetCapabilitiesParameters<chainId> = {}
|
|
19
|
-
): Promise<GetCapabilitiesReturnType<chainId>> {
|
|
20
|
-
const { account = client.account, chainId } = parameters
|
|
21
|
-
|
|
22
|
-
const account_ = account ? parseAccount(account) : undefined
|
|
23
|
-
|
|
24
|
-
const capabilities_raw = await client.request(
|
|
25
|
-
{
|
|
26
|
-
method: 'wallet_getCapabilities',
|
|
27
|
-
params: [account_?.address],
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
dedupe: true,
|
|
31
|
-
retryCount: 0,
|
|
32
|
-
}
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
const capabilities = {} as WalletCapabilitiesRecord<
|
|
36
|
-
WalletCapabilities,
|
|
37
|
-
number
|
|
38
|
-
>
|
|
39
|
-
for (const [key, value] of Object.entries(capabilities_raw)) {
|
|
40
|
-
capabilities[Number(key)] = value
|
|
41
|
-
}
|
|
42
|
-
return (
|
|
43
|
-
typeof chainId === 'number' ? capabilities[chainId] : capabilities
|
|
44
|
-
) as never
|
|
45
|
-
}
|
|
46
|
-
|
|
47
9
|
export async function isBatchingSupported({
|
|
48
10
|
client,
|
|
49
11
|
chainId,
|
|
@@ -62,11 +24,10 @@ export async function isBatchingSupported({
|
|
|
62
24
|
}
|
|
63
25
|
|
|
64
26
|
try {
|
|
65
|
-
const capabilities = await
|
|
66
|
-
_client,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
)({ chainId })
|
|
27
|
+
const capabilities = await Promise.race([
|
|
28
|
+
getAction(_client, getCapabilities, 'getCapabilities')({ chainId }),
|
|
29
|
+
sleep(2_000),
|
|
30
|
+
])
|
|
70
31
|
return (
|
|
71
32
|
capabilities?.atomicBatch?.supported ||
|
|
72
33
|
capabilities?.atomic?.status === 'supported' ||
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk'
|
|
2
|
-
export const version = '3.7.0-beta.
|
|
2
|
+
export const version = '3.7.0-beta.2'
|