@lifi/sdk-provider-sui 4.0.1-alpha.0 → 4.0.1

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 (115) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +88 -5
  3. package/dist/esm/SuiProvider.d.ts +7 -2
  4. package/dist/esm/SuiProvider.d.ts.map +1 -0
  5. package/dist/esm/SuiProvider.js +32 -32
  6. package/dist/esm/SuiProvider.js.map +1 -1
  7. package/dist/esm/actions/getSuiBalance.d.ts +7 -2
  8. package/dist/esm/actions/getSuiBalance.d.ts.map +1 -0
  9. package/dist/esm/actions/getSuiBalance.js +40 -47
  10. package/dist/esm/actions/getSuiBalance.js.map +1 -1
  11. package/dist/esm/actions/getSuiNSAddress.d.ts +7 -1
  12. package/dist/esm/actions/getSuiNSAddress.d.ts.map +1 -0
  13. package/dist/esm/actions/getSuiNSAddress.js +24 -27
  14. package/dist/esm/actions/getSuiNSAddress.js.map +1 -1
  15. package/dist/esm/actions/resolveSuiAddress.d.ts +5 -1
  16. package/dist/esm/actions/resolveSuiAddress.d.ts.map +1 -0
  17. package/dist/esm/actions/resolveSuiAddress.js +7 -3
  18. package/dist/esm/actions/resolveSuiAddress.js.map +1 -1
  19. package/dist/esm/client/suiClient.d.ts +13 -8
  20. package/dist/esm/client/suiClient.d.ts.map +1 -0
  21. package/dist/esm/client/suiClient.js +32 -33
  22. package/dist/esm/client/suiClient.js.map +1 -1
  23. package/dist/esm/core/SuiStepExecutor.d.ts +16 -0
  24. package/dist/esm/core/SuiStepExecutor.d.ts.map +1 -0
  25. package/dist/esm/core/SuiStepExecutor.js +44 -0
  26. package/dist/esm/core/SuiStepExecutor.js.map +1 -0
  27. package/dist/esm/core/tasks/SuiSignAndExecuteTask.d.ts +10 -0
  28. package/dist/esm/core/tasks/SuiSignAndExecuteTask.d.ts.map +1 -0
  29. package/dist/esm/core/tasks/SuiSignAndExecuteTask.js +26 -0
  30. package/dist/esm/core/tasks/SuiSignAndExecuteTask.js.map +1 -0
  31. package/dist/esm/core/tasks/SuiWaitForTransactionTask.d.ts +10 -0
  32. package/dist/esm/core/tasks/SuiWaitForTransactionTask.d.ts.map +1 -0
  33. package/dist/esm/core/tasks/SuiWaitForTransactionTask.js +26 -0
  34. package/dist/esm/core/tasks/SuiWaitForTransactionTask.js.map +1 -0
  35. package/dist/esm/errors/parseSuiErrors.d.ts +7 -2
  36. package/dist/esm/errors/parseSuiErrors.d.ts.map +1 -0
  37. package/dist/esm/errors/parseSuiErrors.js +17 -27
  38. package/dist/esm/errors/parseSuiErrors.js.map +1 -1
  39. package/dist/esm/index.d.ts +3 -3
  40. package/dist/esm/index.js +3 -4
  41. package/dist/esm/package.json +1 -1
  42. package/dist/esm/types.d.ts +27 -11
  43. package/dist/esm/types.d.ts.map +1 -0
  44. package/dist/esm/types.js +9 -5
  45. package/dist/esm/types.js.map +1 -1
  46. package/dist/esm/version.d.ts +6 -2
  47. package/dist/esm/version.d.ts.map +1 -0
  48. package/dist/esm/version.js +6 -2
  49. package/dist/esm/version.js.map +1 -1
  50. package/package.json +9 -9
  51. package/src/SuiProvider.ts +22 -6
  52. package/src/actions/getSuiBalance.ts +10 -10
  53. package/src/actions/getSuiNSAddress.ts +6 -3
  54. package/src/client/suiClient.ts +6 -6
  55. package/src/core/SuiStepExecutor.ts +93 -0
  56. package/src/core/tasks/SuiSignAndExecuteTask.ts +68 -0
  57. package/src/core/tasks/SuiWaitForTransactionTask.ts +67 -0
  58. package/src/types.ts +20 -3
  59. package/src/version.ts +1 -1
  60. package/dist/cjs/SuiProvider.d.ts +0 -2
  61. package/dist/cjs/SuiProvider.js +0 -37
  62. package/dist/cjs/SuiProvider.js.map +0 -1
  63. package/dist/cjs/SuiStepExecutor.d.ts +0 -8
  64. package/dist/cjs/SuiStepExecutor.js +0 -109
  65. package/dist/cjs/SuiStepExecutor.js.map +0 -1
  66. package/dist/cjs/actions/getSuiBalance.d.ts +0 -2
  67. package/dist/cjs/actions/getSuiBalance.js +0 -54
  68. package/dist/cjs/actions/getSuiBalance.js.map +0 -1
  69. package/dist/cjs/actions/getSuiNSAddress.d.ts +0 -1
  70. package/dist/cjs/actions/getSuiNSAddress.js +0 -32
  71. package/dist/cjs/actions/getSuiNSAddress.js.map +0 -1
  72. package/dist/cjs/actions/resolveSuiAddress.d.ts +0 -1
  73. package/dist/cjs/actions/resolveSuiAddress.js +0 -8
  74. package/dist/cjs/actions/resolveSuiAddress.js.map +0 -1
  75. package/dist/cjs/client/suiClient.d.ts +0 -3
  76. package/dist/cjs/client/suiClient.js +0 -30
  77. package/dist/cjs/client/suiClient.js.map +0 -1
  78. package/dist/cjs/errors/parseSuiErrors.d.ts +0 -2
  79. package/dist/cjs/errors/parseSuiErrors.js +0 -35
  80. package/dist/cjs/errors/parseSuiErrors.js.map +0 -1
  81. package/dist/cjs/index.d.ts +0 -3
  82. package/dist/cjs/index.js +0 -8
  83. package/dist/cjs/index.js.map +0 -1
  84. package/dist/cjs/package.json +0 -1
  85. package/dist/cjs/types.d.ts +0 -14
  86. package/dist/cjs/types.js +0 -11
  87. package/dist/cjs/types.js.map +0 -1
  88. package/dist/cjs/version.d.ts +0 -2
  89. package/dist/cjs/version.js +0 -6
  90. package/dist/cjs/version.js.map +0 -1
  91. package/dist/esm/SuiStepExecutor.d.ts +0 -8
  92. package/dist/esm/SuiStepExecutor.js +0 -110
  93. package/dist/esm/SuiStepExecutor.js.map +0 -1
  94. package/dist/esm/index.js.map +0 -1
  95. package/dist/types/SuiProvider.d.ts +0 -3
  96. package/dist/types/SuiProvider.d.ts.map +0 -1
  97. package/dist/types/SuiStepExecutor.d.ts +0 -9
  98. package/dist/types/SuiStepExecutor.d.ts.map +0 -1
  99. package/dist/types/actions/getSuiBalance.d.ts +0 -3
  100. package/dist/types/actions/getSuiBalance.d.ts.map +0 -1
  101. package/dist/types/actions/getSuiNSAddress.d.ts +0 -2
  102. package/dist/types/actions/getSuiNSAddress.d.ts.map +0 -1
  103. package/dist/types/actions/resolveSuiAddress.d.ts +0 -2
  104. package/dist/types/actions/resolveSuiAddress.d.ts.map +0 -1
  105. package/dist/types/client/suiClient.d.ts +0 -10
  106. package/dist/types/client/suiClient.d.ts.map +0 -1
  107. package/dist/types/errors/parseSuiErrors.d.ts +0 -3
  108. package/dist/types/errors/parseSuiErrors.d.ts.map +0 -1
  109. package/dist/types/index.d.ts +0 -4
  110. package/dist/types/index.d.ts.map +0 -1
  111. package/dist/types/types.d.ts +0 -15
  112. package/dist/types/types.d.ts.map +0 -1
  113. package/dist/types/version.d.ts +0 -3
  114. package/dist/types/version.d.ts.map +0 -1
  115. package/src/SuiStepExecutor.ts +0 -191
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseSuiErrors.js","sourceRoot":"","sources":["../../../src/errors/parseSuiErrors.ts"],"names":[],"mappings":";;;AAAA,mCASkB;AAEX,MAAM,cAAc,GAAG,KAAK,EACjC,CAAQ,EACR,IAAe,EACf,MAAwB,EACL,EAAE;IACrB,IAAI,CAAC,YAAY,cAAQ,EAAE,CAAC;QAC1B,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,IAAI,CAAA;QACvB,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,MAAM,CAAA;QAC7B,OAAO,CAAC,CAAA;IACV,CAAC;IAED,MAAM,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAA;IAEzC,OAAO,IAAI,cAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;AAC9C,CAAC,CAAA;AAdY,QAAA,cAAc,kBAc1B;AAED,MAAM,oBAAoB,GAAG,CAAC,CAAM,EAAE,EAAE;IACtC,MAAM,WAAW,GACf,OAAO,CAAC,KAAK,QAAQ;QACnB,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAEjD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,IAAI,sBAAgB,CAAC,mBAAa,CAAC,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IAC5E,CAAC;IAED,IACE,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;QAChD,CAAC,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC1C,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAC7C,CAAC;QACD,OAAO,IAAI,sBAAgB,CAAC,mBAAa,CAAC,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IAC5E,CAAC;IAED,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QACzE,OAAO,IAAI,sBAAgB,CACzB,mBAAa,CAAC,2BAA2B,EACzC,CAAC,CAAC,OAAO,EACT,CAAC,CACF,CAAA;IACH,CAAC;IAED,IAAI,CAAC,YAAY,eAAS,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAA;IACV,CAAC;IAED,OAAO,IAAI,kBAAY,CAAC,CAAC,CAAC,OAAO,IAAI,kBAAY,CAAC,YAAY,EAAE,CAAC,CAAC,CAAA;AACpE,CAAC,CAAA"}
@@ -1,3 +0,0 @@
1
- export { SuiProvider } from './SuiProvider.js';
2
- export type { SuiProviderOptions, SuiSDKProvider } from './types.js';
3
- export { isSuiProvider } from './types.js';
package/dist/cjs/index.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSuiProvider = exports.SuiProvider = void 0;
4
- var SuiProvider_js_1 = require("./SuiProvider.js");
5
- Object.defineProperty(exports, "SuiProvider", { enumerable: true, get: function () { return SuiProvider_js_1.SuiProvider; } });
6
- var types_js_1 = require("./types.js");
7
- Object.defineProperty(exports, "isSuiProvider", { enumerable: true, get: function () { return types_js_1.isSuiProvider; } });
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,mDAA8C;AAArC,6GAAA,WAAW,OAAA;AAEpB,uCAA0C;AAAjC,yGAAA,aAAa,OAAA"}
@@ -1 +0,0 @@
1
- {"type":"commonjs"}
@@ -1,14 +0,0 @@
1
- import { type SDKProvider, type StepExecutorOptions } from '@lifi/sdk';
2
- import type { WalletWithRequiredFeatures } from '@mysten/wallet-standard';
3
- export interface SuiProviderOptions {
4
- getWallet?: () => Promise<WalletWithRequiredFeatures>;
5
- }
6
- export interface SuiSDKProvider extends SDKProvider {
7
- setOptions(options: SuiProviderOptions): void;
8
- }
9
- export declare function isSuiProvider(provider: SDKProvider): provider is SuiSDKProvider;
10
- export interface SuiStepExecutorOptions extends StepExecutorOptions {
11
- wallet: WalletWithRequiredFeatures;
12
- }
13
- export declare const SuiTokenShortAddress = "0x2::sui::SUI";
14
- export declare const SuiTokenLongAddress = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
package/dist/cjs/types.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SuiTokenLongAddress = exports.SuiTokenShortAddress = void 0;
4
- exports.isSuiProvider = isSuiProvider;
5
- const sdk_1 = require("@lifi/sdk");
6
- function isSuiProvider(provider) {
7
- return provider.type === sdk_1.ChainType.MVM;
8
- }
9
- exports.SuiTokenShortAddress = '0x2::sui::SUI';
10
- exports.SuiTokenLongAddress = '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI';
11
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAeA,sCAIC;AAnBD,mCAIkB;AAWlB,SAAgB,aAAa,CAC3B,QAAqB;IAErB,OAAO,QAAQ,CAAC,IAAI,KAAK,eAAS,CAAC,GAAG,CAAA;AACxC,CAAC;AAMY,QAAA,oBAAoB,GAAG,eAAe,CAAA;AACtC,QAAA,mBAAmB,GAC9B,8EAA8E,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const name = "@lifi/sdk-provider-sui";
2
- export declare const version = "4.0.1-alpha.0";
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.version = exports.name = void 0;
4
- exports.name = '@lifi/sdk-provider-sui';
5
- exports.version = '4.0.1-alpha.0';
6
- //# sourceMappingURL=version.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,wBAAwB,CAAA;AAC/B,QAAA,OAAO,GAAG,eAAe,CAAA"}
@@ -1,8 +0,0 @@
1
- import { BaseStepExecutor, type LiFiStepExtended, type SDKClient } from '@lifi/sdk';
2
- import type { SuiStepExecutorOptions } from './types.js';
3
- export declare class SuiStepExecutor extends BaseStepExecutor {
4
- private wallet;
5
- constructor(options: SuiStepExecutorOptions);
6
- checkWallet: (step: LiFiStepExtended) => void;
7
- executeStep: (client: SDKClient, step: LiFiStepExtended) => Promise<LiFiStepExtended>;
8
- }
@@ -1,110 +0,0 @@
1
- import { BaseStepExecutor, checkBalance, getStepTransaction, LiFiErrorCode, stepComparison, TransactionError, waitForDestinationChainTransaction, } from '@lifi/sdk';
2
- import { signAndExecuteTransaction, } from '@mysten/wallet-standard';
3
- import { callSuiWithRetry } from './client/suiClient.js';
4
- import { parseSuiErrors } from './errors/parseSuiErrors.js';
5
- export class SuiStepExecutor extends BaseStepExecutor {
6
- wallet;
7
- constructor(options) {
8
- super(options);
9
- this.wallet = options.wallet;
10
- }
11
- checkWallet = (step) => {
12
- // Prevent execution of the quote by wallet different from the one which requested the quote
13
- if (!this.wallet.accounts?.some?.((account) => account.address === step.action.fromAddress)) {
14
- throw new TransactionError(LiFiErrorCode.WalletChangedDuringExecution, 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.');
15
- }
16
- };
17
- executeStep = async (client, step) => {
18
- step.execution = this.statusManager.initExecutionObject(step);
19
- const fromChain = await client.getChainById(step.action.fromChainId);
20
- const toChain = await client.getChainById(step.action.toChainId);
21
- const isBridgeExecution = fromChain.id !== toChain.id;
22
- const currentActionType = isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP';
23
- let action = this.statusManager.findOrCreateAction({
24
- step,
25
- type: currentActionType,
26
- chainId: fromChain.id,
27
- });
28
- if (action.status !== 'DONE') {
29
- try {
30
- action = this.statusManager.updateAction(step, action.type, 'STARTED');
31
- // Check balance
32
- await checkBalance(client, step.action.fromAddress, step);
33
- // Create new transaction
34
- if (!step.transactionRequest) {
35
- const { execution, ...stepBase } = step;
36
- const updatedStep = await getStepTransaction(client, stepBase);
37
- const comparedStep = await stepComparison(this.statusManager, step, updatedStep, this.allowUserInteraction, this.executionOptions);
38
- Object.assign(step, {
39
- ...comparedStep,
40
- execution: step.execution,
41
- });
42
- }
43
- if (!step.transactionRequest?.data) {
44
- throw new TransactionError(LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
45
- }
46
- action = this.statusManager.updateAction(step, action.type, 'ACTION_REQUIRED');
47
- if (!this.allowUserInteraction) {
48
- return step;
49
- }
50
- let transactionRequest = {
51
- data: step.transactionRequest.data,
52
- };
53
- if (this.executionOptions?.updateTransactionRequestHook) {
54
- const customizedTransactionRequest = await this.executionOptions.updateTransactionRequestHook({
55
- requestType: 'transaction',
56
- ...transactionRequest,
57
- });
58
- transactionRequest = {
59
- ...transactionRequest,
60
- ...customizedTransactionRequest,
61
- };
62
- }
63
- const transactionRequestData = transactionRequest.data;
64
- if (!transactionRequestData) {
65
- throw new TransactionError(LiFiErrorCode.TransactionUnprepared, 'Unable to prepare transaction.');
66
- }
67
- this.checkWallet(step);
68
- // We give users 2 minutes to sign the transaction
69
- const signedTx = await signAndExecuteTransaction(this.wallet, {
70
- account: this.wallet.accounts.find((account) => account.address === step.action.fromAddress),
71
- chain: 'sui:mainnet',
72
- transaction: {
73
- toJSON: async () => transactionRequestData,
74
- },
75
- });
76
- action = this.statusManager.updateAction(step, action.type, 'PENDING');
77
- const result = await callSuiWithRetry(client, (client) => client.waitForTransaction({
78
- digest: signedTx.digest,
79
- options: {
80
- showEffects: true,
81
- },
82
- }));
83
- if (result.effects?.status.status !== 'success') {
84
- throw new TransactionError(LiFiErrorCode.TransactionFailed, `Transaction failed: ${result.effects?.status.error}`);
85
- }
86
- // Transaction has been confirmed and we can update the action
87
- action = this.statusManager.updateAction(step, action.type, 'PENDING', {
88
- txHash: result.digest,
89
- txLink: `${fromChain.metamask.blockExplorerUrls[0]}txblock/${result.digest}`,
90
- });
91
- if (isBridgeExecution) {
92
- action = this.statusManager.updateAction(step, action.type, 'DONE');
93
- }
94
- }
95
- catch (e) {
96
- const error = await parseSuiErrors(e, step, action);
97
- action = this.statusManager.updateAction(step, action.type, 'FAILED', {
98
- error: {
99
- message: error.cause.message,
100
- code: error.code,
101
- },
102
- });
103
- throw error;
104
- }
105
- }
106
- await waitForDestinationChainTransaction(client, step, action, fromChain, toChain, this.statusManager);
107
- return step;
108
- };
109
- }
110
- //# sourceMappingURL=SuiStepExecutor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SuiStepExecutor.js","sourceRoot":"","sources":["../../src/SuiStepExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EAGb,cAAc,EACd,gBAAgB,EAEhB,kCAAkC,GACnC,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,yBAAyB,GAE1B,MAAM,yBAA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,aAAa,CACnB,CAAA;QAED,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { SuiProviderOptions, SuiSDKProvider } from './types.js';
2
- export declare function SuiProvider(options?: SuiProviderOptions): SuiSDKProvider;
3
- //# sourceMappingURL=SuiProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SuiProvider.d.ts","sourceRoot":"","sources":["../../src/SuiProvider.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEpE,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,CAgCxE"}
@@ -1,9 +0,0 @@
1
- import { BaseStepExecutor, type LiFiStepExtended, type SDKClient } from '@lifi/sdk';
2
- import type { SuiStepExecutorOptions } from './types.js';
3
- export declare class SuiStepExecutor extends BaseStepExecutor {
4
- private wallet;
5
- constructor(options: SuiStepExecutorOptions);
6
- checkWallet: (step: LiFiStepExtended) => void;
7
- executeStep: (client: SDKClient, step: LiFiStepExtended) => Promise<LiFiStepExtended>;
8
- }
9
- //# sourceMappingURL=SuiStepExecutor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SuiStepExecutor.d.ts","sourceRoot":"","sources":["../../src/SuiStepExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAIhB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAKf,MAAM,WAAW,CAAA;AAOlB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD,qBAAa,eAAgB,SAAQ,gBAAgB;IACnD,OAAO,CAAC,MAAM,CAA4B;gBAE9B,OAAO,EAAE,sBAAsB;IAK3C,WAAW,GAAI,MAAM,gBAAgB,UAYpC;IAED,WAAW,GACT,QAAQ,SAAS,EACjB,MAAM,gBAAgB,KACrB,OAAO,CAAC,gBAAgB,CAAC,CAgJ3B;CACF"}
@@ -1,3 +0,0 @@
1
- import { type SDKClient, type Token, type TokenAmount } from '@lifi/sdk';
2
- export declare function getSuiBalance(client: SDKClient, walletAddress: string, tokens: Token[]): Promise<TokenAmount[]>;
3
- //# sourceMappingURL=getSuiBalance.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSuiBalance.d.ts","sourceRoot":"","sources":["../../../src/actions/getSuiBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,WAAW,EAEjB,MAAM,WAAW,CAAA;AAIlB,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,KAAK,EAAE,GACd,OAAO,CAAC,WAAW,EAAE,CAAC,CAaxB"}
@@ -1,2 +0,0 @@
1
- export declare function getSuiNSAddress(name: string, rpcUrl?: string): Promise<string | undefined>;
2
- //# sourceMappingURL=getSuiNSAddress.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSuiNSAddress.d.ts","sourceRoot":"","sources":["../../../src/actions/getSuiNSAddress.ts"],"names":[],"mappings":"AAKA,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA+B7B"}
@@ -1,2 +0,0 @@
1
- export declare function resolveSuiAddress(name: string): Promise<string | undefined>;
2
- //# sourceMappingURL=resolveSuiAddress.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveSuiAddress.d.ts","sourceRoot":"","sources":["../../../src/actions/resolveSuiAddress.ts"],"names":[],"mappings":"AAEA,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE7B"}
@@ -1,10 +0,0 @@
1
- import { type SDKClient } from '@lifi/sdk';
2
- import { SuiClient } from '@mysten/sui/client';
3
- /**
4
- * Calls a function on the SuiClient instances with retry logic.
5
- * @param client - The SDK client
6
- * @param fn - The function to call, which receives a SuiClient instance.
7
- * @returns - The result of the function call.
8
- */
9
- export declare function callSuiWithRetry<R>(client: SDKClient, fn: (client: SuiClient) => Promise<R>): Promise<R>;
10
- //# sourceMappingURL=suiClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"suiClient.d.ts","sourceRoot":"","sources":["../../../src/client/suiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAkB9C;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,MAAM,EAAE,SAAS,EACjB,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,GACpC,OAAO,CAAC,CAAC,CAAC,CAcZ"}
@@ -1,3 +0,0 @@
1
- import { type ExecutionAction, type LiFiStep, SDKError } from '@lifi/sdk';
2
- export declare const parseSuiErrors: (e: Error, step?: LiFiStep, action?: ExecutionAction) => Promise<SDKError>;
3
- //# sourceMappingURL=parseSuiErrors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseSuiErrors.d.ts","sourceRoot":"","sources":["../../../src/errors/parseSuiErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EAEpB,KAAK,QAAQ,EACb,QAAQ,EAGT,MAAM,WAAW,CAAA;AAElB,eAAO,MAAM,cAAc,GACzB,GAAG,KAAK,EACR,OAAO,QAAQ,EACf,SAAS,eAAe,KACvB,OAAO,CAAC,QAAQ,CAUlB,CAAA"}
@@ -1,4 +0,0 @@
1
- export { SuiProvider } from './SuiProvider.js';
2
- export type { SuiProviderOptions, SuiSDKProvider } from './types.js';
3
- export { isSuiProvider } from './types.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"}
@@ -1,15 +0,0 @@
1
- import { type SDKProvider, type StepExecutorOptions } from '@lifi/sdk';
2
- import type { WalletWithRequiredFeatures } from '@mysten/wallet-standard';
3
- export interface SuiProviderOptions {
4
- getWallet?: () => Promise<WalletWithRequiredFeatures>;
5
- }
6
- export interface SuiSDKProvider extends SDKProvider {
7
- setOptions(options: SuiProviderOptions): void;
8
- }
9
- export declare function isSuiProvider(provider: SDKProvider): provider is SuiSDKProvider;
10
- export interface SuiStepExecutorOptions extends StepExecutorOptions {
11
- wallet: WalletWithRequiredFeatures;
12
- }
13
- export declare const SuiTokenShortAddress = "0x2::sui::SUI";
14
- export declare const SuiTokenLongAddress = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
15
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAA;AAClB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAA;AAEzE,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,0BAA0B,CAAC,CAAA;CACtD;AAED,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAA;CAC9C;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,WAAW,GACpB,QAAQ,IAAI,cAAc,CAE5B;AAED,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IACjE,MAAM,EAAE,0BAA0B,CAAA;CACnC;AAED,eAAO,MAAM,oBAAoB,kBAAkB,CAAA;AACnD,eAAO,MAAM,mBAAmB,iFACgD,CAAA"}
@@ -1,3 +0,0 @@
1
- export declare const name = "@lifi/sdk-provider-sui";
2
- export declare const version = "4.0.1-alpha.0";
3
- //# sourceMappingURL=version.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,2BAA2B,CAAA;AAC5C,eAAO,MAAM,OAAO,kBAAkB,CAAA"}
@@ -1,191 +0,0 @@
1
- import {
2
- BaseStepExecutor,
3
- checkBalance,
4
- getStepTransaction,
5
- LiFiErrorCode,
6
- type LiFiStepExtended,
7
- type SDKClient,
8
- stepComparison,
9
- TransactionError,
10
- type TransactionParameters,
11
- waitForDestinationChainTransaction,
12
- } from '@lifi/sdk'
13
- import {
14
- signAndExecuteTransaction,
15
- type WalletWithRequiredFeatures,
16
- } from '@mysten/wallet-standard'
17
- import { callSuiWithRetry } from './client/suiClient.js'
18
- import { parseSuiErrors } from './errors/parseSuiErrors.js'
19
- import type { SuiStepExecutorOptions } from './types.js'
20
-
21
- export class SuiStepExecutor extends BaseStepExecutor {
22
- private wallet: WalletWithRequiredFeatures
23
-
24
- constructor(options: SuiStepExecutorOptions) {
25
- super(options)
26
- this.wallet = options.wallet
27
- }
28
-
29
- checkWallet = (step: LiFiStepExtended) => {
30
- // Prevent execution of the quote by wallet different from the one which requested the quote
31
- if (
32
- !this.wallet.accounts?.some?.(
33
- (account) => account.address === step.action.fromAddress
34
- )
35
- ) {
36
- throw new TransactionError(
37
- LiFiErrorCode.WalletChangedDuringExecution,
38
- 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'
39
- )
40
- }
41
- }
42
-
43
- executeStep = async (
44
- client: SDKClient,
45
- step: LiFiStepExtended
46
- ): Promise<LiFiStepExtended> => {
47
- step.execution = this.statusManager.initExecutionObject(step)
48
-
49
- const fromChain = await client.getChainById(step.action.fromChainId)
50
- const toChain = await client.getChainById(step.action.toChainId)
51
-
52
- const isBridgeExecution = fromChain.id !== toChain.id
53
- const currentActionType = isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'
54
-
55
- let action = this.statusManager.findOrCreateAction({
56
- step,
57
- type: currentActionType,
58
- chainId: fromChain.id,
59
- })
60
-
61
- if (action.status !== 'DONE') {
62
- try {
63
- action = this.statusManager.updateAction(step, action.type, 'STARTED')
64
-
65
- // Check balance
66
- await checkBalance(client, step.action.fromAddress!, step)
67
-
68
- // Create new transaction
69
- if (!step.transactionRequest) {
70
- const { execution, ...stepBase } = step
71
- const updatedStep = await getStepTransaction(client, stepBase)
72
- const comparedStep = await stepComparison(
73
- this.statusManager,
74
- step,
75
- updatedStep,
76
- this.allowUserInteraction,
77
- this.executionOptions
78
- )
79
- Object.assign(step, {
80
- ...comparedStep,
81
- execution: step.execution,
82
- })
83
- }
84
-
85
- if (!step.transactionRequest?.data) {
86
- throw new TransactionError(
87
- LiFiErrorCode.TransactionUnprepared,
88
- 'Unable to prepare transaction.'
89
- )
90
- }
91
-
92
- action = this.statusManager.updateAction(
93
- step,
94
- action.type,
95
- 'ACTION_REQUIRED'
96
- )
97
-
98
- if (!this.allowUserInteraction) {
99
- return step
100
- }
101
-
102
- let transactionRequest: TransactionParameters = {
103
- data: step.transactionRequest.data,
104
- }
105
-
106
- if (this.executionOptions?.updateTransactionRequestHook) {
107
- const customizedTransactionRequest: TransactionParameters =
108
- await this.executionOptions.updateTransactionRequestHook({
109
- requestType: 'transaction',
110
- ...transactionRequest,
111
- })
112
-
113
- transactionRequest = {
114
- ...transactionRequest,
115
- ...customizedTransactionRequest,
116
- }
117
- }
118
-
119
- const transactionRequestData = transactionRequest.data
120
-
121
- if (!transactionRequestData) {
122
- throw new TransactionError(
123
- LiFiErrorCode.TransactionUnprepared,
124
- 'Unable to prepare transaction.'
125
- )
126
- }
127
-
128
- this.checkWallet(step)
129
-
130
- // We give users 2 minutes to sign the transaction
131
- const signedTx = await signAndExecuteTransaction(this.wallet, {
132
- account: this.wallet.accounts.find(
133
- (account) => account.address === step.action.fromAddress
134
- )!,
135
- chain: 'sui:mainnet',
136
- transaction: {
137
- toJSON: async () => transactionRequestData,
138
- },
139
- })
140
-
141
- action = this.statusManager.updateAction(step, action.type, 'PENDING')
142
-
143
- const result = await callSuiWithRetry(client, (client) =>
144
- client.waitForTransaction({
145
- digest: signedTx.digest,
146
- options: {
147
- showEffects: true,
148
- },
149
- })
150
- )
151
-
152
- if (result.effects?.status.status !== 'success') {
153
- throw new TransactionError(
154
- LiFiErrorCode.TransactionFailed,
155
- `Transaction failed: ${result.effects?.status.error}`
156
- )
157
- }
158
-
159
- // Transaction has been confirmed and we can update the action
160
- action = this.statusManager.updateAction(step, action.type, 'PENDING', {
161
- txHash: result.digest,
162
- txLink: `${fromChain.metamask.blockExplorerUrls[0]}txblock/${result.digest}`,
163
- })
164
-
165
- if (isBridgeExecution) {
166
- action = this.statusManager.updateAction(step, action.type, 'DONE')
167
- }
168
- } catch (e: any) {
169
- const error = await parseSuiErrors(e, step, action)
170
- action = this.statusManager.updateAction(step, action.type, 'FAILED', {
171
- error: {
172
- message: error.cause.message,
173
- code: error.code,
174
- },
175
- })
176
- throw error
177
- }
178
- }
179
-
180
- await waitForDestinationChainTransaction(
181
- client,
182
- step,
183
- action,
184
- fromChain,
185
- toChain,
186
- this.statusManager
187
- )
188
-
189
- return step
190
- }
191
- }