@lifi/sdk-provider-sui 4.2.6 → 4.2.7
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/CHANGELOG.md +6 -0
- package/dist/esm/core/SuiStepExecutor.js +3 -2
- package/dist/esm/core/SuiStepExecutor.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +1 -1
- package/src/core/SuiStepExecutor.ts +12 -4
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lifi/sdk-provider-sui
|
|
2
2
|
|
|
3
|
+
## 4.2.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#505](https://github.com/lifinance/sdk/pull/505) [`56f9913`](https://github.com/lifinance/sdk/commit/56f9913ccbc0508c94122baf3b7bbbcaa867d95b) Thanks [@chybisov](https://github.com/chybisov)! - Pick the first pipeline task by class reference instead of by class name. In builds that mangle class names, a step could start or resume at the wrong task — for example, an unneeded `approve()` before a native-token swap.
|
|
8
|
+
|
|
3
9
|
## 4.2.6
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -33,8 +33,9 @@ var SuiStepExecutor = class extends BaseStepExecutor {
|
|
|
33
33
|
new WaitForTransactionStatusTask(isBridgeExecution ? "RECEIVING_CHAIN" : "SWAP")
|
|
34
34
|
];
|
|
35
35
|
const swapOrBridgeAction = this.statusManager.findAction(step, isBridgeExecution ? "CROSS_CHAIN" : "SWAP");
|
|
36
|
-
const
|
|
37
|
-
const firstTaskIndex = tasks.findIndex((task) => task.constructor
|
|
36
|
+
const firstTask = swapOrBridgeAction?.txHash && swapOrBridgeAction?.status === "DONE" ? WaitForTransactionStatusTask : CheckBalanceTask;
|
|
37
|
+
const firstTaskIndex = tasks.findIndex((task) => task.constructor === firstTask);
|
|
38
|
+
if (firstTaskIndex === -1) throw new TransactionError(LiFiErrorCode.InternalError, "SuiStepExecutor.createPipeline: first task not found");
|
|
38
39
|
const tasksToRun = tasks.slice(firstTaskIndex);
|
|
39
40
|
return new TaskPipeline(tasksToRun);
|
|
40
41
|
};
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 firstTask =\n swapOrBridgeAction?.txHash && swapOrBridgeAction?.status === 'DONE'\n ? WaitForTransactionStatusTask\n : CheckBalanceTask\n\n // Compare classes, not names: a minifier can give two task classes the\n // same name.\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor === firstTask\n )\n if (firstTaskIndex === -1) {\n throw new TransactionError(\n LiFiErrorCode.InternalError,\n 'SuiStepExecutor.createPipeline: first task not found'\n )\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;EAC3C,MAAM,OAAO;EACb,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ;CACxB;CAEA,eAAe,SAAiC;EAG9C,IADgB,KAAK,OAAO,aAClB,MAAM,KAAK,OAAO,aAC1B,MAAM,IAAI,iBACR,cAAc,8BACd,mHACF;CAEJ;CAEA,eACE,OACA,MACA,WACsB,eAAe,OAAO,MAAM,MAAM;CAE1D,gBAAyB,OACvB,gBACoC;EACpC,OAAO;GACL,GAAG;GACH,WAAW,KAAK;GAChB,QAAQ,KAAK;GACb,aAAa,KAAK;EACpB;CACF;CAEA,kBAA2B,YAAkD;EAC3E,MAAM,EAAE,MAAM,sBAAsB;EAEpC,MAAM,QAAQ;GACZ,IAAI,iBAAiB;GACrB,IAAI,uBAAuB;GAC3B,IAAI,sBAAsB;GAC1B,IAAI,0BAA0B;GAC9B,IAAI,6BACF,oBAAoB,oBAAoB,MAC1C;EACF;EAEA,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,MACtC;EAEA,MAAM,YACJ,oBAAoB,UAAU,oBAAoB,WAAW,SACzD,+BACA;EAIN,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,gBAAgB,SACjC;EACA,IAAI,mBAAmB,IACrB,MAAM,IAAI,iBACR,cAAc,eACd,sDACF;EAGF,MAAM,aAAa,MAAM,MAAM,cAAc;EAE7C,OAAO,IAAI,aAAa,UAAU;CACpC;AACF"}
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-sui'\nexport const version = '4.2.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-sui'\nexport const version = '4.2.7'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
package/package.json
CHANGED
|
@@ -77,14 +77,22 @@ export class SuiStepExecutor extends BaseStepExecutor {
|
|
|
77
77
|
isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
-
const
|
|
80
|
+
const firstTask =
|
|
81
81
|
swapOrBridgeAction?.txHash && swapOrBridgeAction?.status === 'DONE'
|
|
82
|
-
? WaitForTransactionStatusTask
|
|
83
|
-
: CheckBalanceTask
|
|
82
|
+
? WaitForTransactionStatusTask
|
|
83
|
+
: CheckBalanceTask
|
|
84
84
|
|
|
85
|
+
// Compare classes, not names: a minifier can give two task classes the
|
|
86
|
+
// same name.
|
|
85
87
|
const firstTaskIndex = tasks.findIndex(
|
|
86
|
-
(task) => task.constructor
|
|
88
|
+
(task) => task.constructor === firstTask
|
|
87
89
|
)
|
|
90
|
+
if (firstTaskIndex === -1) {
|
|
91
|
+
throw new TransactionError(
|
|
92
|
+
LiFiErrorCode.InternalError,
|
|
93
|
+
'SuiStepExecutor.createPipeline: first task not found'
|
|
94
|
+
)
|
|
95
|
+
}
|
|
88
96
|
|
|
89
97
|
const tasksToRun = tasks.slice(firstTaskIndex)
|
|
90
98
|
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk-provider-sui'
|
|
2
|
-
export const version = '4.2.
|
|
2
|
+
export const version = '4.2.7'
|