@lifi/sdk-provider-sui 4.0.0-alpha.21 → 4.0.0-alpha.23

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.
Files changed (75) hide show
  1. package/dist/esm/SuiProvider.d.ts +7 -2
  2. package/dist/esm/SuiProvider.d.ts.map +1 -0
  3. package/dist/esm/SuiProvider.js +32 -37
  4. package/dist/esm/SuiProvider.js.map +1 -1
  5. package/dist/esm/actions/getSuiBalance.d.ts +7 -2
  6. package/dist/esm/actions/getSuiBalance.d.ts.map +1 -0
  7. package/dist/esm/actions/getSuiBalance.js +33 -47
  8. package/dist/esm/actions/getSuiBalance.js.map +1 -1
  9. package/dist/esm/actions/getSuiNSAddress.d.ts +7 -2
  10. package/dist/esm/actions/getSuiNSAddress.d.ts.map +1 -0
  11. package/dist/esm/actions/getSuiNSAddress.js +24 -28
  12. package/dist/esm/actions/getSuiNSAddress.js.map +1 -1
  13. package/dist/esm/actions/resolveSuiAddress.d.ts +5 -1
  14. package/dist/esm/actions/resolveSuiAddress.d.ts.map +1 -0
  15. package/dist/esm/actions/resolveSuiAddress.js +7 -3
  16. package/dist/esm/actions/resolveSuiAddress.js.map +1 -1
  17. package/dist/esm/client/suiClient.d.ts +13 -8
  18. package/dist/esm/client/suiClient.d.ts.map +1 -0
  19. package/dist/esm/client/suiClient.js +32 -33
  20. package/dist/esm/client/suiClient.js.map +1 -1
  21. package/dist/esm/core/SuiStepExecutor.d.ts +15 -10
  22. package/dist/esm/core/SuiStepExecutor.d.ts.map +1 -0
  23. package/dist/esm/core/SuiStepExecutor.js +43 -46
  24. package/dist/esm/core/SuiStepExecutor.js.map +1 -1
  25. package/dist/esm/core/tasks/SuiSignAndExecuteTask.d.ts +9 -4
  26. package/dist/esm/core/tasks/SuiSignAndExecuteTask.d.ts.map +1 -0
  27. package/dist/esm/core/tasks/SuiSignAndExecuteTask.js +25 -28
  28. package/dist/esm/core/tasks/SuiSignAndExecuteTask.js.map +1 -1
  29. package/dist/esm/core/tasks/SuiWaitForTransactionTask.d.ts +9 -4
  30. package/dist/esm/core/tasks/SuiWaitForTransactionTask.d.ts.map +1 -0
  31. package/dist/esm/core/tasks/SuiWaitForTransactionTask.js +25 -32
  32. package/dist/esm/core/tasks/SuiWaitForTransactionTask.js.map +1 -1
  33. package/dist/esm/errors/parseSuiErrors.d.ts +7 -2
  34. package/dist/esm/errors/parseSuiErrors.d.ts.map +1 -0
  35. package/dist/esm/errors/parseSuiErrors.js +17 -27
  36. package/dist/esm/errors/parseSuiErrors.js.map +1 -1
  37. package/dist/esm/index.d.ts +3 -3
  38. package/dist/esm/index.js +3 -4
  39. package/dist/esm/package.json +1 -1
  40. package/dist/esm/types.d.ts +25 -20
  41. package/dist/esm/types.d.ts.map +1 -0
  42. package/dist/esm/types.js +9 -5
  43. package/dist/esm/types.js.map +1 -1
  44. package/dist/esm/version.d.ts +6 -2
  45. package/dist/esm/version.d.ts.map +1 -0
  46. package/dist/esm/version.js +6 -2
  47. package/dist/esm/version.js.map +1 -1
  48. package/package.json +8 -8
  49. package/src/core/SuiStepExecutor.ts +2 -2
  50. package/src/version.ts +1 -1
  51. package/dist/esm/index.js.map +0 -1
  52. package/dist/types/SuiProvider.d.ts +0 -3
  53. package/dist/types/SuiProvider.d.ts.map +0 -1
  54. package/dist/types/actions/getSuiBalance.d.ts +0 -3
  55. package/dist/types/actions/getSuiBalance.d.ts.map +0 -1
  56. package/dist/types/actions/getSuiNSAddress.d.ts +0 -3
  57. package/dist/types/actions/getSuiNSAddress.d.ts.map +0 -1
  58. package/dist/types/actions/resolveSuiAddress.d.ts +0 -2
  59. package/dist/types/actions/resolveSuiAddress.d.ts.map +0 -1
  60. package/dist/types/client/suiClient.d.ts +0 -10
  61. package/dist/types/client/suiClient.d.ts.map +0 -1
  62. package/dist/types/core/SuiStepExecutor.d.ts +0 -12
  63. package/dist/types/core/SuiStepExecutor.d.ts.map +0 -1
  64. package/dist/types/core/tasks/SuiSignAndExecuteTask.d.ts +0 -6
  65. package/dist/types/core/tasks/SuiSignAndExecuteTask.d.ts.map +0 -1
  66. package/dist/types/core/tasks/SuiWaitForTransactionTask.d.ts +0 -6
  67. package/dist/types/core/tasks/SuiWaitForTransactionTask.d.ts.map +0 -1
  68. package/dist/types/errors/parseSuiErrors.d.ts +0 -3
  69. package/dist/types/errors/parseSuiErrors.d.ts.map +0 -1
  70. package/dist/types/index.d.ts +0 -4
  71. package/dist/types/index.d.ts.map +0 -1
  72. package/dist/types/types.d.ts +0 -26
  73. package/dist/types/types.d.ts.map +0 -1
  74. package/dist/types/version.d.ts +0 -3
  75. package/dist/types/version.d.ts.map +0 -1
@@ -1,2 +1,7 @@
1
- import type { SuiProviderOptions, SuiSDKProvider } from './types.js';
2
- export declare function SuiProvider(options?: SuiProviderOptions): SuiSDKProvider;
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"}
@@ -1,39 +1,34 @@
1
- import { ChainType, LiFiErrorCode, ProviderError, } from '@lifi/sdk';
2
- import { isValidSuiAddress } from '@mysten/sui/utils';
3
- import { getSuiBalance } from './actions/getSuiBalance.js';
4
- import { resolveSuiAddress } from './actions/resolveSuiAddress.js';
5
- import { SuiStepExecutor } from './core/SuiStepExecutor.js';
6
- export function SuiProvider(options) {
7
- const _options = options ?? {};
8
- return {
9
- get type() {
10
- return ChainType.MVM;
11
- },
12
- isAddress: isValidSuiAddress,
13
- resolveAddress: resolveSuiAddress,
14
- getBalance: getSuiBalance,
15
- async getStepExecutor(options) {
16
- if (!_options.getClient) {
17
- throw new ProviderError(LiFiErrorCode.ProviderUnavailable, 'getClient is not provided.');
18
- }
19
- if (!_options.getSigner) {
20
- throw new ProviderError(LiFiErrorCode.ProviderUnavailable, 'getSigner is not provided.');
21
- }
22
- const client = await _options.getClient();
23
- const signer = await _options.getSigner();
24
- const executor = new SuiStepExecutor({
25
- client,
26
- signer,
27
- routeId: options.routeId,
28
- executionOptions: {
29
- ...options.executionOptions,
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","sourceRoot":"","sources":["../../src/SuiProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,aAAa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;QAClC,CAAC;KACF,CAAA;AACH,CAAC"}
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"}
@@ -1,2 +1,7 @@
1
- import { type SDKClient, type Token, type TokenAmount } from '@lifi/sdk';
2
- export declare function getSuiBalance(client: SDKClient, walletAddress: string, tokens: Token[]): Promise<TokenAmount[]>;
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 { withDedupe, } from '@lifi/sdk';
2
- import { callSuiWithRetry } from '../client/suiClient.js';
3
- import { SuiTokenLongAddress, SuiTokenShortAddress } from '../types.js';
4
- export async function getSuiBalance(client, walletAddress, tokens) {
5
- if (tokens.length === 0) {
6
- return [];
7
- }
8
- const { chainId } = tokens[0];
9
- for (const token of tokens) {
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
- const [coins, checkpoint] = await Promise.allSettled([
18
- withDedupe(() => callSuiWithRetry(client, (client) => client.getAllBalances({
19
- owner: walletAddress,
20
- })), { id: `${getSuiBalanceDefault.name}.getAllBalances` }),
21
- withDedupe(() => callSuiWithRetry(client, (client) => client.getLatestCheckpointSequenceNumber()), { id: `${getSuiBalanceDefault.name}.getLatestCheckpointSequenceNumber` }),
22
- ]);
23
- const coinsResult = coins.status === 'fulfilled' ? coins.value : [];
24
- const blockNumber = checkpoint.status === 'fulfilled' ? BigInt(checkpoint.value) : 0n;
25
- const walletTokenAmounts = coinsResult.reduce((tokenAmounts, coin) => {
26
- const amount = BigInt(coin.totalBalance);
27
- if (amount > 0n) {
28
- tokenAmounts[coin.coinType] = amount;
29
- }
30
- return tokenAmounts;
31
- }, {});
32
- const suiTokenBalance = coinsResult.find((coin) => coin.coinType === SuiTokenShortAddress);
33
- if (suiTokenBalance?.totalBalance) {
34
- walletTokenAmounts[SuiTokenLongAddress] = BigInt(suiTokenBalance.totalBalance);
35
- }
36
- const tokenAmounts = tokens.map((token) => {
37
- if (walletTokenAmounts[token.address]) {
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","sourceRoot":"","sources":["../../../src/actions/getSuiBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,GACX,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAiB,EACjB,aAAqB,EACrB,MAAe;IAEf,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;YAC9B,OAAO,CAA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I,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAA;QACtC,CAAC;QACD,OAAO,YAAY,CAAA;IACrB,CAAC,EACD,EAA4B,CAC7B,CAAA;IAED,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,oBAAoB,CACjD,CAAA;IACD,IAAI,eAAe,EAAE,YAAY,EAAE,CAAC;QAClC,kBAAkB,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAC9C,eAAe,CAAC,YAAY,CAC7B,CAAA;IACH,CAAC;IAED,MAAM,YAAY,GAAkB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACvD,IAAI,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YACtC,OAAO;gBACL,GAAG,KAAK;gBACR,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC;gBACzC,WAAW;aACZ,CAAA;QACH,CAAC;QACD,OAAO;YACL,GAAG,KAAK;YACR,WAAW;SACZ,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA"}
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 type { SuiClientTypes } from '@mysten/sui/client';
2
- export declare function getSuiNSAddress(name: string, rpcUrl?: string, network?: SuiClientTypes.Network): Promise<string | undefined>;
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 '@mysten/sui/jsonRpc';
2
- const SNS_REGISTRY_ID = '0x6e0ddefc0ad3ed64f53f5f91b7023077b2f7c131d7e6d5e0d1a0e4e6f1a2c3b4';
3
- export async function getSuiNSAddress(name, rpcUrl, network) {
4
- const client = new SuiJsonRpcClient({
5
- url: rpcUrl || 'https://fullnode.mainnet.sui.io:443',
6
- network: network || 'mainnet',
7
- });
8
- try {
9
- const result = await client.getObject({
10
- id: SNS_REGISTRY_ID,
11
- options: {
12
- showContent: true,
13
- },
14
- });
15
- if (!result.data?.content) {
16
- return;
17
- }
18
- const registry = result.data.content;
19
- const nameRecord = registry.fields.records.find((record) => record.fields.name === name);
20
- if (!nameRecord) {
21
- return;
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","sourceRoot":"","sources":["../../../src/actions/getSuiNSAddress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,MAAM,eAAe,GACnB,oEAAoE,CAAA;AAEtE,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAY,EACZ,MAAe,EACf,OAAgC;IAEhC,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC;QAClC,GAAG,EAAE,MAAM,IAAI,qCAAqC;QACpD,OAAO,EAAE,OAAO,IAAI,SAAS;KAC9B,CAAC,CAAA;IAEF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC;YACpC,EAAE,EAAE,eAAe;YACnB,OAAO,EAAE;gBACP,WAAW,EAAE,IAAI;aAClB;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;YAC1B,OAAM;QACR,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAc,CAAA;QAC3C,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAC7C,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAC7C,CAAA;QAED,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAM;QACR,CAAC;QAED,OAAO,UAAU,CAAC,MAAM,CAAC,OAAO,CAAA;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAA;QACtD,OAAM;IACR,CAAC;AACH,CAAC"}
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
- export declare function resolveSuiAddress(name: string): Promise<string | undefined>;
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 './getSuiNSAddress.js';
2
- export async function resolveSuiAddress(name) {
3
- return await getSuiNSAddress(name);
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","sourceRoot":"","sources":["../../../src/actions/resolveSuiAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAY;IAEZ,OAAO,MAAM,eAAe,CAAC,IAAI,CAAC,CAAA;AACpC,CAAC"}
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 { type SDKClient } from '@lifi/sdk';
2
- import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
1
+ import { SDKClient } from "@lifi/sdk";
2
+ import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
3
+
4
+ //#region src/client/suiClient.d.ts
3
5
  /**
4
- * Calls a function on the SuiJsonRpcClient instances with retry logic.
5
- * @param client - The SDK client
6
- * @param fn - The function to call, which receives a SuiJsonRpcClient instance.
7
- * @returns - The result of the function call.
8
- */
9
- export declare function callSuiWithRetry<R>(client: SDKClient, fn: (client: SuiJsonRpcClient) => Promise<R>): Promise<R>;
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 '@lifi/sdk';
2
- import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
- const clients = new Map();
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
- * Initializes the Sui clients if they haven't been initialized yet.
6
- * @returns - Promise that resolves when clients are initialized.
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
- const rpcUrls = await client.getRpcUrlsByChainId(ChainId.SUI);
10
- for (const rpcUrl of rpcUrls) {
11
- if (!clients.get(rpcUrl)) {
12
- const client = new SuiJsonRpcClient({ url: rpcUrl, network: 'mainnet' });
13
- clients.set(rpcUrl, client);
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
- * Calls a function on the SuiJsonRpcClient instances with retry logic.
19
- * @param client - The SDK client
20
- * @param fn - The function to call, which receives a SuiJsonRpcClient instance.
21
- * @returns - The result of the function call.
22
- */
23
- export async function callSuiWithRetry(client, fn) {
24
- // Ensure clients are initialized
25
- await ensureClients(client);
26
- let lastError = null;
27
- for (const client of clients.values()) {
28
- try {
29
- const result = await fn(client);
30
- return result;
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","sourceRoot":"","sources":["../../../src/client/suiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,MAAM,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAA;AAEnD;;;GAGG;AACH,MAAM,aAAa,GAAG,KAAK,EAAE,MAAiB,EAAiB,EAAE;IAC/D,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC7D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAA;YACxE,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAiB,EACjB,EAA4C;IAE5C,iCAAiC;IACjC,MAAM,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,SAAS,GAAQ,IAAI,CAAA;IACzB,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,CAAA;YAC/B,OAAO,MAAM,CAAA;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,SAAS,GAAG,KAAK,CAAA;QACnB,CAAC;IACH,CAAC;IACD,mCAAmC;IACnC,MAAM,SAAS,CAAA;AACjB,CAAC"}
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 { BaseStepExecutor, type ExecutionAction, type LiFiStepExtended, type SDKError, type StepExecutorBaseContext, TaskPipeline } from '@lifi/sdk';
2
- import type { SuiStepExecutorContext, SuiStepExecutorOptions } from '../types.js';
3
- export declare class SuiStepExecutor extends BaseStepExecutor {
4
- private client;
5
- private signer;
6
- constructor(options: SuiStepExecutorOptions);
7
- checkWallet: (step: LiFiStepExtended) => void;
8
- parseErrors: (error: Error, step?: LiFiStepExtended, action?: ExecutionAction) => Promise<SDKError>;
9
- createContext: (baseContext: StepExecutorBaseContext) => Promise<SuiStepExecutorContext>;
10
- createPipeline: (context: SuiStepExecutorContext) => TaskPipeline;
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
+ override parseErrors: (error: Error, step?: LiFiStepExtended, action?: ExecutionAction) => Promise<SDKError>;
11
+ override createContext: (baseContext: StepExecutorBaseContext) => Promise<SuiStepExecutorContext>;
12
+ override 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;EAAA,SAWZ,WAAA,GACP,KAAA,EAAO,KAAA,EACP,IAAA,GAAO,gBAAA,EACP,MAAA,GAAS,eAAA,KACR,OAAA,CAAQ,QAAA;EAAA,SAEF,aAAA,GACP,WAAA,EAAa,uBAAA,KACZ,OAAA,CAAQ,sBAAA;EAAA,SASF,cAAA,GAAkB,OAAA,EAAS,sBAAA,KAAyB,YAAA;AAAA"}
@@ -1,47 +1,44 @@
1
- import { BaseStepExecutor, CheckBalanceTask, LiFiErrorCode, PrepareTransactionTask, TaskPipeline, TransactionError, WaitForTransactionStatusTask, } from '@lifi/sdk';
2
- import { parseSuiErrors } from '../errors/parseSuiErrors.js';
3
- import { SuiSignAndExecuteTask } from './tasks/SuiSignAndExecuteTask.js';
4
- import { SuiWaitForTransactionTask } from './tasks/SuiWaitForTransactionTask.js';
5
- export class SuiStepExecutor extends BaseStepExecutor {
6
- client;
7
- signer;
8
- constructor(options) {
9
- super(options);
10
- this.client = options.client;
11
- this.signer = options.signer;
12
- }
13
- checkWallet = (step) => {
14
- // Prevent execution of the quote by wallet different from the one which requested the quote
15
- const address = this.signer.toSuiAddress();
16
- if (address !== step.action.fromAddress) {
17
- throw new TransactionError(LiFiErrorCode.WalletChangedDuringExecution, 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.');
18
- }
19
- };
20
- parseErrors = (error, step, action) => parseSuiErrors(error, step, action);
21
- createContext = async (baseContext) => {
22
- return {
23
- ...baseContext,
24
- suiClient: this.client,
25
- signer: this.signer,
26
- checkWallet: this.checkWallet,
27
- };
28
- };
29
- createPipeline = (context) => {
30
- const { step, isBridgeExecution } = context;
31
- const tasks = [
32
- new CheckBalanceTask(),
33
- new PrepareTransactionTask(),
34
- new SuiSignAndExecuteTask(),
35
- new SuiWaitForTransactionTask(),
36
- new WaitForTransactionStatusTask(isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'),
37
- ];
38
- const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP');
39
- const taskName = swapOrBridgeAction?.txHash && swapOrBridgeAction?.status === 'DONE'
40
- ? WaitForTransactionStatusTask.name
41
- : CheckBalanceTask.name;
42
- const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
43
- const tasksToRun = tasks.slice(firstTaskIndex);
44
- return new TaskPipeline(tasksToRun);
45
- };
46
- }
1
+ import { parseSuiErrors } from "../errors/parseSuiErrors.js";
2
+ import { SuiSignAndExecuteTask } from "./tasks/SuiSignAndExecuteTask.js";
3
+ import { SuiWaitForTransactionTask } from "./tasks/SuiWaitForTransactionTask.js";
4
+ import { BaseStepExecutor, CheckBalanceTask, LiFiErrorCode, PrepareTransactionTask, TaskPipeline, TransactionError, WaitForTransactionStatusTask } from "@lifi/sdk";
5
+ //#region src/core/SuiStepExecutor.ts
6
+ var SuiStepExecutor = class extends BaseStepExecutor {
7
+ client;
8
+ signer;
9
+ constructor(options) {
10
+ super(options);
11
+ this.client = options.client;
12
+ this.signer = options.signer;
13
+ }
14
+ checkWallet = (step) => {
15
+ if (this.signer.toSuiAddress() !== step.action.fromAddress) throw new TransactionError(LiFiErrorCode.WalletChangedDuringExecution, "The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.");
16
+ };
17
+ parseErrors = (error, step, action) => parseSuiErrors(error, step, action);
18
+ createContext = async (baseContext) => {
19
+ return {
20
+ ...baseContext,
21
+ suiClient: this.client,
22
+ signer: this.signer,
23
+ checkWallet: this.checkWallet
24
+ };
25
+ };
26
+ createPipeline = (context) => {
27
+ const { step, isBridgeExecution } = context;
28
+ const tasks = [
29
+ new CheckBalanceTask(),
30
+ new PrepareTransactionTask(),
31
+ new SuiSignAndExecuteTask(),
32
+ new SuiWaitForTransactionTask(),
33
+ new WaitForTransactionStatusTask(isBridgeExecution ? "RECEIVING_CHAIN" : "SWAP")
34
+ ];
35
+ const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
36
+ const taskName = swapOrBridgeAction?.txHash && swapOrBridgeAction?.status === "DONE" ? WaitForTransactionStatusTask.name : CheckBalanceTask.name;
37
+ const firstTaskIndex = tasks.findIndex((task) => task.constructor.name === taskName);
38
+ return new TaskPipeline(tasks.slice(firstTaskIndex));
39
+ };
40
+ };
41
+ //#endregion
42
+ export { SuiStepExecutor };
43
+
47
44
  //# sourceMappingURL=SuiStepExecutor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SuiStepExecutor.js","sourceRoot":"","sources":["../../../src/core/SuiStepExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAEhB,aAAa,EAEb,sBAAsB,EAGtB,YAAY,EACZ,gBAAgB,EAChB,4BAA4B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I,gBAAgB,EAAE;YACtB,IAAI,sBAAsB,EAAE;YAC5B,IAAI,qBAAqB,EAAE;YAC3B,IAAI,yBAAyB,EAAE;YAC/B,IAAI,4BAA4B,CAC9B,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAC/C;SACF,CAAA;QAED,MAAM,kBAAkB,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CACtD,IAAI,EACJ,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAC3C,CAAA;QAED,MAAM,QAAQ,GACZ,kBAAkB,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,KAAK,MAAM;YACjE,CAAC,CAAC,4BAA4B,CAAC,IAAI;YACnC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAA;QAE3B,MAAM,cAAc,GAAG,KAAK,CAAC,SAAS,CACpC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,CAC7C,CAAA;QAED,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QAE9C,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC,CAAA;CACF"}
1
+ {"version":3,"file":"SuiStepExecutor.js","names":[],"sources":["../../../src/core/SuiStepExecutor.ts"],"sourcesContent":["import {\n BaseStepExecutor,\n CheckBalanceTask,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStepExtended,\n PrepareTransactionTask,\n type SDKError,\n type StepExecutorBaseContext,\n TaskPipeline,\n TransactionError,\n WaitForTransactionStatusTask,\n} from '@lifi/sdk'\nimport type { ClientWithCoreApi } from '@mysten/sui/client'\nimport type { Signer } from '@mysten/sui/cryptography'\nimport { parseSuiErrors } from '../errors/parseSuiErrors.js'\nimport type {\n SuiStepExecutorContext,\n SuiStepExecutorOptions,\n} from '../types.js'\nimport { SuiSignAndExecuteTask } from './tasks/SuiSignAndExecuteTask.js'\nimport { SuiWaitForTransactionTask } from './tasks/SuiWaitForTransactionTask.js'\n\nexport class SuiStepExecutor extends BaseStepExecutor {\n private client: ClientWithCoreApi\n private signer: Signer\n\n constructor(options: SuiStepExecutorOptions) {\n super(options)\n this.client = options.client\n this.signer = options.signer\n }\n\n checkWallet = (step: LiFiStepExtended): void => {\n // Prevent execution of the quote by wallet different from the one which requested the quote\n const address = this.signer.toSuiAddress()\n if (address !== step.action.fromAddress) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction\n ): Promise<SDKError> => parseSuiErrors(error, step, action)\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<SuiStepExecutorContext> => {\n return {\n ...baseContext,\n suiClient: this.client,\n signer: this.signer,\n checkWallet: this.checkWallet,\n }\n }\n\n override createPipeline = (context: SuiStepExecutorContext): TaskPipeline => {\n const { step, isBridgeExecution } = context\n\n const tasks = [\n new CheckBalanceTask(),\n new PrepareTransactionTask(),\n new SuiSignAndExecuteTask(),\n new SuiWaitForTransactionTask(),\n new WaitForTransactionStatusTask(\n isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'\n ),\n ]\n\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n const taskName =\n swapOrBridgeAction?.txHash && swapOrBridgeAction?.status === 'DONE'\n ? WaitForTransactionStatusTask.name\n : CheckBalanceTask.name\n\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor.name === taskName\n )\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n}\n"],"mappings":";;;;;AAuBA,IAAa,kBAAb,cAAqC,iBAAiB;CACpD;CACA;CAEA,YAAY,SAAiC;AAC3C,QAAM,QAAQ;AACd,OAAK,SAAS,QAAQ;AACtB,OAAK,SAAS,QAAQ;;CAGxB,eAAe,SAAiC;AAG9C,MADgB,KAAK,OAAO,cAAc,KAC1B,KAAK,OAAO,YAC1B,OAAM,IAAI,iBACR,cAAc,8BACd,oHACD;;CAIL,eACE,OACA,MACA,WACsB,eAAe,OAAO,MAAM,OAAO;CAE3D,gBAAyB,OACvB,gBACoC;AACpC,SAAO;GACL,GAAG;GACH,WAAW,KAAK;GAChB,QAAQ,KAAK;GACb,aAAa,KAAK;GACnB;;CAGH,kBAA2B,YAAkD;EAC3E,MAAM,EAAE,MAAM,sBAAsB;EAEpC,MAAM,QAAQ;GACZ,IAAI,kBAAkB;GACtB,IAAI,wBAAwB;GAC5B,IAAI,uBAAuB;GAC3B,IAAI,2BAA2B;GAC/B,IAAI,6BACF,oBAAoB,oBAAoB,OACzC;GACF;EAED,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,OACrC;EAED,MAAM,WACJ,oBAAoB,UAAU,oBAAoB,WAAW,SACzD,6BAA6B,OAC7B,iBAAiB;EAEvB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,SACrC;AAID,SAAO,IAAI,aAFQ,MAAM,MAAM,eAAe,CAEX"}