@lifi/sdk-provider-sui 4.0.0-beta.0 → 4.0.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/dist/esm/SuiProvider.d.ts +7 -2
- package/dist/esm/SuiProvider.d.ts.map +1 -0
- package/dist/esm/SuiProvider.js +32 -37
- package/dist/esm/SuiProvider.js.map +1 -1
- package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +12 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.js +14 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +9 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.js +11 -0
- package/dist/esm/actions/getSuiBalance.d.ts +7 -2
- package/dist/esm/actions/getSuiBalance.d.ts.map +1 -0
- package/dist/esm/actions/getSuiBalance.js +33 -47
- package/dist/esm/actions/getSuiBalance.js.map +1 -1
- package/dist/esm/actions/getSuiNSAddress.d.ts +7 -2
- package/dist/esm/actions/getSuiNSAddress.d.ts.map +1 -0
- package/dist/esm/actions/getSuiNSAddress.js +24 -28
- package/dist/esm/actions/getSuiNSAddress.js.map +1 -1
- package/dist/esm/actions/resolveSuiAddress.d.ts +5 -1
- package/dist/esm/actions/resolveSuiAddress.d.ts.map +1 -0
- package/dist/esm/actions/resolveSuiAddress.js +7 -3
- package/dist/esm/actions/resolveSuiAddress.js.map +1 -1
- package/dist/esm/client/suiClient.d.ts +13 -8
- package/dist/esm/client/suiClient.d.ts.map +1 -0
- package/dist/esm/client/suiClient.js +32 -33
- package/dist/esm/client/suiClient.js.map +1 -1
- package/dist/esm/core/SuiStepExecutor.d.ts +15 -10
- package/dist/esm/core/SuiStepExecutor.d.ts.map +1 -0
- package/dist/esm/core/SuiStepExecutor.js +44 -46
- package/dist/esm/core/SuiStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/SuiSignAndExecuteTask.d.ts +9 -4
- package/dist/esm/core/tasks/SuiSignAndExecuteTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/SuiSignAndExecuteTask.js +25 -28
- package/dist/esm/core/tasks/SuiSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/SuiWaitForTransactionTask.d.ts +9 -4
- package/dist/esm/core/tasks/SuiWaitForTransactionTask.d.ts.map +1 -0
- package/dist/esm/core/tasks/SuiWaitForTransactionTask.js +25 -32
- package/dist/esm/core/tasks/SuiWaitForTransactionTask.js.map +1 -1
- package/dist/esm/errors/parseSuiErrors.d.ts +7 -2
- package/dist/esm/errors/parseSuiErrors.d.ts.map +1 -0
- package/dist/esm/errors/parseSuiErrors.js +17 -27
- package/dist/esm/errors/parseSuiErrors.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +3 -4
- package/dist/esm/package.json +1 -1
- package/dist/esm/types.d.ts +25 -20
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +9 -5
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/version.d.ts +6 -2
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +6 -2
- package/dist/esm/version.js.map +1 -1
- package/package.json +6 -6
- package/src/core/SuiStepExecutor.ts +2 -2
- package/src/version.ts +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/types/SuiProvider.d.ts +0 -3
- package/dist/types/SuiProvider.d.ts.map +0 -1
- package/dist/types/actions/getSuiBalance.d.ts +0 -3
- package/dist/types/actions/getSuiBalance.d.ts.map +0 -1
- package/dist/types/actions/getSuiNSAddress.d.ts +0 -3
- package/dist/types/actions/getSuiNSAddress.d.ts.map +0 -1
- package/dist/types/actions/resolveSuiAddress.d.ts +0 -2
- package/dist/types/actions/resolveSuiAddress.d.ts.map +0 -1
- package/dist/types/client/suiClient.d.ts +0 -10
- package/dist/types/client/suiClient.d.ts.map +0 -1
- package/dist/types/core/SuiStepExecutor.d.ts +0 -12
- package/dist/types/core/SuiStepExecutor.d.ts.map +0 -1
- package/dist/types/core/tasks/SuiSignAndExecuteTask.d.ts +0 -6
- package/dist/types/core/tasks/SuiSignAndExecuteTask.d.ts.map +0 -1
- package/dist/types/core/tasks/SuiWaitForTransactionTask.d.ts +0 -6
- package/dist/types/core/tasks/SuiWaitForTransactionTask.d.ts.map +0 -1
- package/dist/types/errors/parseSuiErrors.d.ts +0 -3
- package/dist/types/errors/parseSuiErrors.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -26
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/version.d.ts +0 -3
- package/dist/types/version.d.ts.map +0 -1
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { SuiProviderOptions, SuiSDKProvider } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/SuiProvider.d.ts
|
|
4
|
+
declare function SuiProvider(options?: SuiProviderOptions): SuiSDKProvider;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { SuiProvider };
|
|
7
|
+
//# sourceMappingURL=SuiProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SuiProvider.d.ts","names":[],"sources":["../../src/SuiProvider.ts"],"mappings":";;;iBAYgB,WAAA,CAAY,OAAA,GAAU,kBAAA,GAAqB,cAAA"}
|
package/dist/esm/SuiProvider.js
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
return executor;
|
|
33
|
-
},
|
|
34
|
-
setOptions(options) {
|
|
35
|
-
Object.assign(_options, options);
|
|
36
|
-
},
|
|
37
|
-
};
|
|
1
|
+
import { getSuiBalance } from "./actions/getSuiBalance.js";
|
|
2
|
+
import { resolveSuiAddress } from "./actions/resolveSuiAddress.js";
|
|
3
|
+
import { SuiStepExecutor } from "./core/SuiStepExecutor.js";
|
|
4
|
+
import { ChainType, LiFiErrorCode, ProviderError } from "@lifi/sdk";
|
|
5
|
+
import { isValidSuiAddress } from "@mysten/sui/utils";
|
|
6
|
+
//#region src/SuiProvider.ts
|
|
7
|
+
function SuiProvider(options) {
|
|
8
|
+
const _options = options ?? {};
|
|
9
|
+
return {
|
|
10
|
+
get type() {
|
|
11
|
+
return ChainType.MVM;
|
|
12
|
+
},
|
|
13
|
+
isAddress: isValidSuiAddress,
|
|
14
|
+
resolveAddress: resolveSuiAddress,
|
|
15
|
+
getBalance: getSuiBalance,
|
|
16
|
+
async getStepExecutor(options) {
|
|
17
|
+
if (!_options.getClient) throw new ProviderError(LiFiErrorCode.ProviderUnavailable, "getClient is not provided.");
|
|
18
|
+
if (!_options.getSigner) throw new ProviderError(LiFiErrorCode.ProviderUnavailable, "getSigner is not provided.");
|
|
19
|
+
return new SuiStepExecutor({
|
|
20
|
+
client: await _options.getClient(),
|
|
21
|
+
signer: await _options.getSigner(),
|
|
22
|
+
routeId: options.routeId,
|
|
23
|
+
executionOptions: { ...options.executionOptions }
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
setOptions(options) {
|
|
27
|
+
Object.assign(_options, options);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
38
30
|
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { SuiProvider };
|
|
33
|
+
|
|
39
34
|
//# sourceMappingURL=SuiProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuiProvider.js","
|
|
1
|
+
{"version":3,"file":"SuiProvider.js","names":[],"sources":["../../src/SuiProvider.ts"],"sourcesContent":["import {\n ChainType,\n LiFiErrorCode,\n ProviderError,\n type StepExecutorOptions,\n} from '@lifi/sdk'\nimport { isValidSuiAddress } from '@mysten/sui/utils'\nimport { getSuiBalance } from './actions/getSuiBalance.js'\nimport { resolveSuiAddress } from './actions/resolveSuiAddress.js'\nimport { SuiStepExecutor } from './core/SuiStepExecutor.js'\nimport type { SuiProviderOptions, SuiSDKProvider } from './types.js'\n\nexport function SuiProvider(options?: SuiProviderOptions): SuiSDKProvider {\n const _options: SuiProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.MVM\n },\n isAddress: isValidSuiAddress,\n resolveAddress: resolveSuiAddress,\n getBalance: getSuiBalance,\n async getStepExecutor(\n options: StepExecutorOptions\n ): Promise<SuiStepExecutor> {\n if (!_options.getClient) {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'getClient is not provided.'\n )\n }\n if (!_options.getSigner) {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'getSigner is not provided.'\n )\n }\n\n const client = await _options.getClient()\n const signer = await _options.getSigner()\n\n const executor = new SuiStepExecutor({\n client,\n signer,\n routeId: options.routeId,\n executionOptions: {\n ...options.executionOptions,\n },\n })\n\n return executor\n },\n setOptions(options: SuiProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;AAYA,SAAgB,YAAY,SAA8C;CACxE,MAAM,WAA+B,WAAW,EAAE;AAClD,QAAO;EACL,IAAI,OAAO;AACT,UAAO,UAAU;;EAEnB,WAAW;EACX,gBAAgB;EAChB,YAAY;EACZ,MAAM,gBACJ,SAC0B;AAC1B,OAAI,CAAC,SAAS,UACZ,OAAM,IAAI,cACR,cAAc,qBACd,6BACD;AAEH,OAAI,CAAC,SAAS,UACZ,OAAM,IAAI,cACR,cAAc,qBACd,6BACD;AAeH,UATiB,IAAI,gBAAgB;IACnC,QAJa,MAAM,SAAS,WAAW;IAKvC,QAJa,MAAM,SAAS,WAAW;IAKvC,SAAS,QAAQ;IACjB,kBAAkB,EAChB,GAAG,QAAQ,kBACZ;IACF,CAAC;;EAIJ,WAAW,SAA6B;AACtC,UAAO,OAAO,UAAU,QAAQ;;EAEnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { toPropertyKey } from "./toPropertyKey.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/defineProperty.js
|
|
3
|
+
function _defineProperty(e, r, t) {
|
|
4
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
5
|
+
value: t,
|
|
6
|
+
enumerable: !0,
|
|
7
|
+
configurable: !0,
|
|
8
|
+
writable: !0
|
|
9
|
+
}) : e[r] = t, e;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { _defineProperty };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { _typeof } from "./typeof.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/toPrimitive.js
|
|
3
|
+
function toPrimitive(t, r) {
|
|
4
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
5
|
+
var e = t[Symbol.toPrimitive];
|
|
6
|
+
if (void 0 !== e) {
|
|
7
|
+
var i = e.call(t, r || "default");
|
|
8
|
+
if ("object" != _typeof(i)) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === r ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { toPrimitive };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { _typeof } from "./typeof.js";
|
|
2
|
+
import { toPrimitive } from "./toPrimitive.js";
|
|
3
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/toPropertyKey.js
|
|
4
|
+
function toPropertyKey(t) {
|
|
5
|
+
var i = toPrimitive(t, "string");
|
|
6
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { toPropertyKey };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.115.0/helpers/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { _typeof };
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { SDKClient, Token, TokenAmount } from "@lifi/sdk";
|
|
2
|
+
|
|
3
|
+
//#region src/actions/getSuiBalance.d.ts
|
|
4
|
+
declare function getSuiBalance(client: SDKClient, walletAddress: string, tokens: Token[]): Promise<TokenAmount[]>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { getSuiBalance };
|
|
7
|
+
//# sourceMappingURL=getSuiBalance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSuiBalance.d.ts","names":[],"sources":["../../../src/actions/getSuiBalance.ts"],"mappings":";;;iBASsB,aAAA,CACpB,MAAA,EAAQ,SAAA,EACR,aAAA,UACA,MAAA,EAAQ,KAAA,KACP,OAAA,CAAQ,WAAA"}
|
|
@@ -1,51 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (token.chainId !== chainId) {
|
|
11
|
-
console.warn('Requested tokens have to be on the same chain.');
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return getSuiBalanceDefault(client, chainId, tokens, walletAddress);
|
|
1
|
+
import { callSuiWithRetry } from "../client/suiClient.js";
|
|
2
|
+
import { SuiTokenLongAddress, SuiTokenShortAddress } from "../types.js";
|
|
3
|
+
import { withDedupe } from "@lifi/sdk";
|
|
4
|
+
//#region src/actions/getSuiBalance.ts
|
|
5
|
+
async function getSuiBalance(client, walletAddress, tokens) {
|
|
6
|
+
if (tokens.length === 0) return [];
|
|
7
|
+
const { chainId } = tokens[0];
|
|
8
|
+
for (const token of tokens) if (token.chainId !== chainId) console.warn("Requested tokens have to be on the same chain.");
|
|
9
|
+
return getSuiBalanceDefault(client, chainId, tokens, walletAddress);
|
|
15
10
|
}
|
|
16
11
|
const getSuiBalanceDefault = async (client, _chainId, tokens, walletAddress) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
...token,
|
|
40
|
-
amount: walletTokenAmounts[token.address],
|
|
41
|
-
blockNumber,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
...token,
|
|
46
|
-
blockNumber,
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
return tokenAmounts;
|
|
12
|
+
const [coins, checkpoint] = await Promise.allSettled([withDedupe(() => callSuiWithRetry(client, (client) => client.getAllBalances({ owner: walletAddress })), { id: `${getSuiBalanceDefault.name}.getAllBalances` }), withDedupe(() => callSuiWithRetry(client, (client) => client.getLatestCheckpointSequenceNumber()), { id: `${getSuiBalanceDefault.name}.getLatestCheckpointSequenceNumber` })]);
|
|
13
|
+
const coinsResult = coins.status === "fulfilled" ? coins.value : [];
|
|
14
|
+
const blockNumber = checkpoint.status === "fulfilled" ? BigInt(checkpoint.value) : 0n;
|
|
15
|
+
const walletTokenAmounts = coinsResult.reduce((tokenAmounts, coin) => {
|
|
16
|
+
const amount = BigInt(coin.totalBalance);
|
|
17
|
+
if (amount > 0n) tokenAmounts[coin.coinType] = amount;
|
|
18
|
+
return tokenAmounts;
|
|
19
|
+
}, {});
|
|
20
|
+
const suiTokenBalance = coinsResult.find((coin) => coin.coinType === SuiTokenShortAddress);
|
|
21
|
+
if (suiTokenBalance?.totalBalance) walletTokenAmounts[SuiTokenLongAddress] = BigInt(suiTokenBalance.totalBalance);
|
|
22
|
+
return tokens.map((token) => {
|
|
23
|
+
if (walletTokenAmounts[token.address]) return {
|
|
24
|
+
...token,
|
|
25
|
+
amount: walletTokenAmounts[token.address],
|
|
26
|
+
blockNumber
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
...token,
|
|
30
|
+
blockNumber
|
|
31
|
+
};
|
|
32
|
+
});
|
|
50
33
|
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { getSuiBalance };
|
|
36
|
+
|
|
51
37
|
//# sourceMappingURL=getSuiBalance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSuiBalance.js","
|
|
1
|
+
{"version":3,"file":"getSuiBalance.js","names":[],"sources":["../../../src/actions/getSuiBalance.ts"],"sourcesContent":["import {\n type SDKClient,\n type Token,\n type TokenAmount,\n withDedupe,\n} from '@lifi/sdk'\nimport { callSuiWithRetry } from '../client/suiClient.js'\nimport { SuiTokenLongAddress, SuiTokenShortAddress } from '../types.js'\n\nexport async function getSuiBalance(\n client: SDKClient,\n walletAddress: string,\n tokens: Token[]\n): Promise<TokenAmount[]> {\n if (tokens.length === 0) {\n return []\n }\n\n const { chainId } = tokens[0]\n for (const token of tokens) {\n if (token.chainId !== chainId) {\n console.warn('Requested tokens have to be on the same chain.')\n }\n }\n\n return getSuiBalanceDefault(client, chainId, tokens, walletAddress)\n}\n\nconst getSuiBalanceDefault = async (\n client: SDKClient,\n _chainId: number,\n tokens: Token[],\n walletAddress: string\n): Promise<TokenAmount[]> => {\n const [coins, checkpoint] = await Promise.allSettled([\n withDedupe(\n () =>\n callSuiWithRetry(client, (client) =>\n client.getAllBalances({\n owner: walletAddress,\n })\n ),\n { id: `${getSuiBalanceDefault.name}.getAllBalances` }\n ),\n withDedupe(\n () =>\n callSuiWithRetry(client, (client) =>\n client.getLatestCheckpointSequenceNumber()\n ),\n { id: `${getSuiBalanceDefault.name}.getLatestCheckpointSequenceNumber` }\n ),\n ])\n\n const coinsResult = coins.status === 'fulfilled' ? coins.value : []\n const blockNumber =\n checkpoint.status === 'fulfilled' ? BigInt(checkpoint.value) : 0n\n\n const walletTokenAmounts = coinsResult.reduce(\n (tokenAmounts, coin) => {\n const amount = BigInt(coin.totalBalance)\n if (amount > 0n) {\n tokenAmounts[coin.coinType] = amount\n }\n return tokenAmounts\n },\n {} as Record<string, bigint>\n )\n\n const suiTokenBalance = coinsResult.find(\n (coin) => coin.coinType === SuiTokenShortAddress\n )\n if (suiTokenBalance?.totalBalance) {\n walletTokenAmounts[SuiTokenLongAddress] = BigInt(\n suiTokenBalance.totalBalance\n )\n }\n\n const tokenAmounts: TokenAmount[] = tokens.map((token) => {\n if (walletTokenAmounts[token.address]) {\n return {\n ...token,\n amount: walletTokenAmounts[token.address],\n blockNumber,\n }\n }\n return {\n ...token,\n blockNumber,\n }\n })\n return tokenAmounts\n}\n"],"mappings":";;;;AASA,eAAsB,cACpB,QACA,eACA,QACwB;AACxB,KAAI,OAAO,WAAW,EACpB,QAAO,EAAE;CAGX,MAAM,EAAE,YAAY,OAAO;AAC3B,MAAK,MAAM,SAAS,OAClB,KAAI,MAAM,YAAY,QACpB,SAAQ,KAAK,iDAAiD;AAIlE,QAAO,qBAAqB,QAAQ,SAAS,QAAQ,cAAc;;AAGrE,MAAM,uBAAuB,OAC3B,QACA,UACA,QACA,kBAC2B;CAC3B,MAAM,CAAC,OAAO,cAAc,MAAM,QAAQ,WAAW,CACnD,iBAEI,iBAAiB,SAAS,WACxB,OAAO,eAAe,EACpB,OAAO,eACR,CAAC,CACH,EACH,EAAE,IAAI,GAAG,qBAAqB,KAAK,kBAAkB,CACtD,EACD,iBAEI,iBAAiB,SAAS,WACxB,OAAO,mCAAmC,CAC3C,EACH,EAAE,IAAI,GAAG,qBAAqB,KAAK,qCAAqC,CACzE,CACF,CAAC;CAEF,MAAM,cAAc,MAAM,WAAW,cAAc,MAAM,QAAQ,EAAE;CACnE,MAAM,cACJ,WAAW,WAAW,cAAc,OAAO,WAAW,MAAM,GAAG;CAEjE,MAAM,qBAAqB,YAAY,QACpC,cAAc,SAAS;EACtB,MAAM,SAAS,OAAO,KAAK,aAAa;AACxC,MAAI,SAAS,GACX,cAAa,KAAK,YAAY;AAEhC,SAAO;IAET,EAAE,CACH;CAED,MAAM,kBAAkB,YAAY,MACjC,SAAS,KAAK,aAAa,qBAC7B;AACD,KAAI,iBAAiB,aACnB,oBAAmB,uBAAuB,OACxC,gBAAgB,aACjB;AAgBH,QAboC,OAAO,KAAK,UAAU;AACxD,MAAI,mBAAmB,MAAM,SAC3B,QAAO;GACL,GAAG;GACH,QAAQ,mBAAmB,MAAM;GACjC;GACD;AAEH,SAAO;GACL,GAAG;GACH;GACD;GACD"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { SuiClientTypes } from "@mysten/sui/client";
|
|
2
|
+
|
|
3
|
+
//#region src/actions/getSuiNSAddress.d.ts
|
|
4
|
+
declare function getSuiNSAddress(name: string, rpcUrl?: string, network?: SuiClientTypes.Network): Promise<string | undefined>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { getSuiNSAddress };
|
|
7
|
+
//# sourceMappingURL=getSuiNSAddress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSuiNSAddress.d.ts","names":[],"sources":["../../../src/actions/getSuiNSAddress.ts"],"mappings":";;;iBAMsB,eAAA,CACpB,IAAA,UACA,MAAA,WACA,OAAA,GAAU,cAAA,CAAe,OAAA,GACxB,OAAA"}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import { SuiJsonRpcClient } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
return nameRecord.fields.address;
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
console.error('Error resolving SuiNS address:', error);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
1
|
+
import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
|
|
2
|
+
//#region src/actions/getSuiNSAddress.ts
|
|
3
|
+
const SNS_REGISTRY_ID = "0x6e0ddefc0ad3ed64f53f5f91b7023077b2f7c131d7e6d5e0d1a0e4e6f1a2c3b4";
|
|
4
|
+
async function getSuiNSAddress(name, rpcUrl, network) {
|
|
5
|
+
const client = new SuiJsonRpcClient({
|
|
6
|
+
url: rpcUrl || "https://fullnode.mainnet.sui.io:443",
|
|
7
|
+
network: network || "mainnet"
|
|
8
|
+
});
|
|
9
|
+
try {
|
|
10
|
+
const result = await client.getObject({
|
|
11
|
+
id: SNS_REGISTRY_ID,
|
|
12
|
+
options: { showContent: true }
|
|
13
|
+
});
|
|
14
|
+
if (!result.data?.content) return;
|
|
15
|
+
const nameRecord = result.data.content.fields.records.find((record) => record.fields.name === name);
|
|
16
|
+
if (!nameRecord) return;
|
|
17
|
+
return nameRecord.fields.address;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error("Error resolving SuiNS address:", error);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
29
22
|
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { getSuiNSAddress };
|
|
25
|
+
|
|
30
26
|
//# sourceMappingURL=getSuiNSAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSuiNSAddress.js","
|
|
1
|
+
{"version":3,"file":"getSuiNSAddress.js","names":[],"sources":["../../../src/actions/getSuiNSAddress.ts"],"sourcesContent":["import type { SuiClientTypes } from '@mysten/sui/client'\nimport { SuiJsonRpcClient } from '@mysten/sui/jsonRpc'\n\nconst SNS_REGISTRY_ID =\n '0x6e0ddefc0ad3ed64f53f5f91b7023077b2f7c131d7e6d5e0d1a0e4e6f1a2c3b4'\n\nexport async function getSuiNSAddress(\n name: string,\n rpcUrl?: string,\n network?: SuiClientTypes.Network\n): Promise<string | undefined> {\n const client = new SuiJsonRpcClient({\n url: rpcUrl || 'https://fullnode.mainnet.sui.io:443',\n network: network || 'mainnet',\n })\n\n try {\n const result = await client.getObject({\n id: SNS_REGISTRY_ID,\n options: {\n showContent: true,\n },\n })\n\n if (!result.data?.content) {\n return\n }\n\n const registry = result.data.content as any\n const nameRecord = registry.fields.records.find(\n (record: any) => record.fields.name === name\n )\n\n if (!nameRecord) {\n return\n }\n\n return nameRecord.fields.address\n } catch (error) {\n console.error('Error resolving SuiNS address:', error)\n return\n }\n}\n"],"mappings":";;AAGA,MAAM,kBACJ;AAEF,eAAsB,gBACpB,MACA,QACA,SAC6B;CAC7B,MAAM,SAAS,IAAI,iBAAiB;EAClC,KAAK,UAAU;EACf,SAAS,WAAW;EACrB,CAAC;AAEF,KAAI;EACF,MAAM,SAAS,MAAM,OAAO,UAAU;GACpC,IAAI;GACJ,SAAS,EACP,aAAa,MACd;GACF,CAAC;AAEF,MAAI,CAAC,OAAO,MAAM,QAChB;EAIF,MAAM,aADW,OAAO,KAAK,QACD,OAAO,QAAQ,MACxC,WAAgB,OAAO,OAAO,SAAS,KACzC;AAED,MAAI,CAAC,WACH;AAGF,SAAO,WAAW,OAAO;UAClB,OAAO;AACd,UAAQ,MAAM,kCAAkC,MAAM;AACtD"}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/actions/resolveSuiAddress.d.ts
|
|
2
|
+
declare function resolveSuiAddress(name: string): Promise<string | undefined>;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { resolveSuiAddress };
|
|
5
|
+
//# sourceMappingURL=resolveSuiAddress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSuiAddress.d.ts","names":[],"sources":["../../../src/actions/resolveSuiAddress.ts"],"mappings":";iBAEsB,iBAAA,CACpB,IAAA,WACC,OAAA"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { getSuiNSAddress } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getSuiNSAddress } from "./getSuiNSAddress.js";
|
|
2
|
+
//#region src/actions/resolveSuiAddress.ts
|
|
3
|
+
async function resolveSuiAddress(name) {
|
|
4
|
+
return await getSuiNSAddress(name);
|
|
4
5
|
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { resolveSuiAddress };
|
|
8
|
+
|
|
5
9
|
//# sourceMappingURL=resolveSuiAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveSuiAddress.js","
|
|
1
|
+
{"version":3,"file":"resolveSuiAddress.js","names":[],"sources":["../../../src/actions/resolveSuiAddress.ts"],"sourcesContent":["import { getSuiNSAddress } from './getSuiNSAddress.js'\n\nexport async function resolveSuiAddress(\n name: string\n): Promise<string | undefined> {\n return await getSuiNSAddress(name)\n}\n"],"mappings":";;AAEA,eAAsB,kBACpB,MAC6B;AAC7B,QAAO,MAAM,gBAAgB,KAAK"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SuiJsonRpcClient } from
|
|
1
|
+
import { SDKClient } from "@lifi/sdk";
|
|
2
|
+
import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
|
|
3
|
+
|
|
4
|
+
//#region src/client/suiClient.d.ts
|
|
3
5
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
* Calls a function on the SuiJsonRpcClient instances with retry logic.
|
|
7
|
+
* @param client - The SDK client
|
|
8
|
+
* @param fn - The function to call, which receives a SuiJsonRpcClient instance.
|
|
9
|
+
* @returns - The result of the function call.
|
|
10
|
+
*/
|
|
11
|
+
declare function callSuiWithRetry<R>(client: SDKClient, fn: (client: SuiJsonRpcClient) => Promise<R>): Promise<R>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { callSuiWithRetry };
|
|
14
|
+
//# sourceMappingURL=suiClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suiClient.d.ts","names":[],"sources":["../../../src/client/suiClient.ts"],"mappings":";;;;;;AAyBA;;;;iBAAsB,gBAAA,GAAA,CACpB,MAAA,EAAQ,SAAA,EACR,EAAA,GAAK,MAAA,EAAQ,gBAAA,KAAqB,OAAA,CAAQ,CAAA,IACzC,OAAA,CAAQ,CAAA"}
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
import { ChainId } from
|
|
2
|
-
import { SuiJsonRpcClient } from
|
|
3
|
-
|
|
1
|
+
import { ChainId } from "@lifi/sdk";
|
|
2
|
+
import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
|
|
3
|
+
//#region src/client/suiClient.ts
|
|
4
|
+
const clients = /* @__PURE__ */ new Map();
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* Initializes the Sui clients if they haven't been initialized yet.
|
|
7
|
+
* @returns - Promise that resolves when clients are initialized.
|
|
8
|
+
*/
|
|
8
9
|
const ensureClients = async (client) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const rpcUrls = await client.getRpcUrlsByChainId(ChainId.SUI);
|
|
11
|
+
for (const rpcUrl of rpcUrls) if (!clients.get(rpcUrl)) {
|
|
12
|
+
const client = new SuiJsonRpcClient({
|
|
13
|
+
url: rpcUrl,
|
|
14
|
+
network: "mainnet"
|
|
15
|
+
});
|
|
16
|
+
clients.set(rpcUrl, client);
|
|
17
|
+
}
|
|
16
18
|
};
|
|
17
19
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
catch (error) {
|
|
33
|
-
lastError = error;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// Throw the last encountered error
|
|
37
|
-
throw lastError;
|
|
20
|
+
* Calls a function on the SuiJsonRpcClient instances with retry logic.
|
|
21
|
+
* @param client - The SDK client
|
|
22
|
+
* @param fn - The function to call, which receives a SuiJsonRpcClient instance.
|
|
23
|
+
* @returns - The result of the function call.
|
|
24
|
+
*/
|
|
25
|
+
async function callSuiWithRetry(client, fn) {
|
|
26
|
+
await ensureClients(client);
|
|
27
|
+
let lastError = null;
|
|
28
|
+
for (const client of clients.values()) try {
|
|
29
|
+
return await fn(client);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
lastError = error;
|
|
32
|
+
}
|
|
33
|
+
throw lastError;
|
|
38
34
|
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { callSuiWithRetry };
|
|
37
|
+
|
|
39
38
|
//# sourceMappingURL=suiClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suiClient.js","
|
|
1
|
+
{"version":3,"file":"suiClient.js","names":[],"sources":["../../../src/client/suiClient.ts"],"sourcesContent":["import { ChainId, type SDKClient } from '@lifi/sdk'\nimport { SuiJsonRpcClient } from '@mysten/sui/jsonRpc'\n\nconst clients = new Map<string, SuiJsonRpcClient>()\n\n/**\n * Initializes the Sui clients if they haven't been initialized yet.\n * @returns - Promise that resolves when clients are initialized.\n */\nconst ensureClients = async (client: SDKClient): Promise<void> => {\n const rpcUrls = await client.getRpcUrlsByChainId(ChainId.SUI)\n for (const rpcUrl of rpcUrls) {\n if (!clients.get(rpcUrl)) {\n const client = new SuiJsonRpcClient({ url: rpcUrl, network: 'mainnet' })\n clients.set(rpcUrl, client)\n }\n }\n}\n\n/**\n * Calls a function on the SuiJsonRpcClient instances with retry logic.\n * @param client - The SDK client\n * @param fn - The function to call, which receives a SuiJsonRpcClient instance.\n * @returns - The result of the function call.\n */\nexport async function callSuiWithRetry<R>(\n client: SDKClient,\n fn: (client: SuiJsonRpcClient) => Promise<R>\n): Promise<R> {\n // Ensure clients are initialized\n await ensureClients(client)\n let lastError: any = null\n for (const client of clients.values()) {\n try {\n const result = await fn(client)\n return result\n } catch (error) {\n lastError = error\n }\n }\n // Throw the last encountered error\n throw lastError\n}\n"],"mappings":";;;AAGA,MAAM,0BAAU,IAAI,KAA+B;;;;;AAMnD,MAAM,gBAAgB,OAAO,WAAqC;CAChE,MAAM,UAAU,MAAM,OAAO,oBAAoB,QAAQ,IAAI;AAC7D,MAAK,MAAM,UAAU,QACnB,KAAI,CAAC,QAAQ,IAAI,OAAO,EAAE;EACxB,MAAM,SAAS,IAAI,iBAAiB;GAAE,KAAK;GAAQ,SAAS;GAAW,CAAC;AACxE,UAAQ,IAAI,QAAQ,OAAO;;;;;;;;;AAWjC,eAAsB,iBACpB,QACA,IACY;AAEZ,OAAM,cAAc,OAAO;CAC3B,IAAI,YAAiB;AACrB,MAAK,MAAM,UAAU,QAAQ,QAAQ,CACnC,KAAI;AAEF,SADe,MAAM,GAAG,OAAO;UAExB,OAAO;AACd,cAAY;;AAIhB,OAAM"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { SuiStepExecutorContext, SuiStepExecutorOptions } from "../types.js";
|
|
2
|
+
import { BaseStepExecutor, ExecutionAction, LiFiStepExtended, SDKError, StepExecutorBaseContext, TaskPipeline } from "@lifi/sdk";
|
|
3
|
+
|
|
4
|
+
//#region src/core/SuiStepExecutor.d.ts
|
|
5
|
+
declare class SuiStepExecutor extends BaseStepExecutor {
|
|
6
|
+
private client;
|
|
7
|
+
private signer;
|
|
8
|
+
constructor(options: SuiStepExecutorOptions);
|
|
9
|
+
checkWallet: (step: LiFiStepExtended) => void;
|
|
10
|
+
parseErrors: (error: Error, step?: LiFiStepExtended, action?: ExecutionAction) => Promise<SDKError>;
|
|
11
|
+
createContext: (baseContext: StepExecutorBaseContext) => Promise<SuiStepExecutorContext>;
|
|
12
|
+
createPipeline: (context: SuiStepExecutorContext) => TaskPipeline;
|
|
11
13
|
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SuiStepExecutor };
|
|
16
|
+
//# sourceMappingURL=SuiStepExecutor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SuiStepExecutor.d.ts","names":[],"sources":["../../../src/core/SuiStepExecutor.ts"],"mappings":";;;;cAuBa,eAAA,SAAwB,gBAAA;EAAA,QAC3B,MAAA;EAAA,QACA,MAAA;EAER,WAAA,CAAY,OAAA,EAAS,sBAAA;EAMrB,WAAA,GAAe,IAAA,EAAM,gBAAA;EAWrB,WAAA,GACE,KAAA,EAAO,KAAA,EACP,IAAA,GAAO,gBAAA,EACP,MAAA,GAAS,eAAA,KACR,OAAA,CAAQ,QAAA;EAEX,aAAA,GACE,WAAA,EAAa,uBAAA,KACZ,OAAA,CAAQ,sBAAA;EASX,cAAA,GAA2B,OAAA,EAAS,sBAAA,KAAyB,YAAA;AAAA"}
|