From a37e6c2e802a62a6b9c4c6a1881d2567897489f6 Mon Sep 17 00:00:00 2001 From: imstar15 Date: Wed, 6 Dec 2023 22:16:55 +0800 Subject: [PATCH 1/3] Add scheduleAs to task params --- packages/sdk/src/index.ts | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index 360eee9..2c91f61 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -34,6 +34,7 @@ interface ScheduleXcmpTaskWithPayThroughSoverignAccountFlowParams extends Schedu interface ScheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlowParams extends ScheduleXcmpTaskParams { destinationChainAdapter: TaskSchedulerChainAdapter; + scheduleAs?: HexString; } interface CreateTaskFuncParams { @@ -129,8 +130,16 @@ export function Sdk() { params: ScheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlowParams, automationPriceTriggerParams: AutomationPriceTriggerParams, ): Promise => { - const { oakAdapter, destinationChainAdapter, taskPayloadExtrinsic, scheduleFeeLocation, executionFeeLocation, keyringPair, xcmOptions } = - params; + const { + oakAdapter, + destinationChainAdapter, + taskPayloadExtrinsic, + scheduleFeeLocation, + executionFeeLocation, + keyringPair, + xcmOptions, + scheduleAs, + } = params; const createTaskFunc = (funcParams: CreateTaskFuncParams): SubmittableExtrinsic<"promise"> => { const { oakApi, destination, executionFee, encodedCall, encodedCallWeight, overallWeight } = funcParams; const taskExtrinsic = oakApi.tx.automationPrice.scheduleXcmpTaskThroughProxy( @@ -147,7 +156,7 @@ export function Sdk() { encodedCall, encodedCallWeight, overallWeight, - u8aToHex(keyringPair.addressRaw), + scheduleAs || u8aToHex(keyringPair.addressRaw), ); return taskExtrinsic; }; @@ -214,11 +223,19 @@ export function Sdk() { * @returns */ scheduleXcmpTimeTaskWithPayThroughRemoteDerivativeAccountFlow: async ( - scheduleXcmpTaskParams: ScheduleXcmpTaskParams, - destinationChainAdapter: TaskSchedulerChainAdapter, + scheduleXcmpTaskParams: ScheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlowParams, schedule: any, ): Promise => { - const { oakAdapter, taskPayloadExtrinsic, scheduleFeeLocation, executionFeeLocation, keyringPair, xcmOptions } = scheduleXcmpTaskParams; + const { + oakAdapter, + destinationChainAdapter, + taskPayloadExtrinsic, + scheduleFeeLocation, + executionFeeLocation, + keyringPair, + xcmOptions, + scheduleAs, + } = scheduleXcmpTaskParams; const createTaskFunc = (funcParams: CreateTaskFuncParams): SubmittableExtrinsic<"promise"> => { const { oakApi, destination, executionFee, encodedCall, encodedCallWeight, overallWeight } = funcParams; console.log("scheduleFeeLocation: ", scheduleFeeLocation); @@ -230,7 +247,7 @@ export function Sdk() { encodedCall, encodedCallWeight, overallWeight, - u8aToHex(keyringPair.addressRaw), + scheduleAs || u8aToHex(keyringPair.addressRaw), ); return taskExtrinsic; }; @@ -255,7 +272,7 @@ export function Sdk() { * @returns */ scheduleXcmpTimeTaskWithPayThroughSoverignAccountFlow: async ( - scheduleXcmpTaskParams: ScheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlowParams, + scheduleXcmpTaskParams: ScheduleXcmpTaskWithPayThroughSoverignAccountFlowParams, schedule: any, ): Promise => { const { oakAdapter, destinationChainAdapter, taskPayloadExtrinsic, scheduleFeeLocation, executionFeeLocation, keyringPair, xcmOptions } = From 6f4d4edce988c63d1d83ad87304e5dd50598843f Mon Sep 17 00:00:00 2001 From: imstar15 Date: Wed, 6 Dec 2023 22:19:22 +0800 Subject: [PATCH 2/3] docs(changeset): Add scheduleAs to task params --- .changeset/itchy-rats-shave.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/itchy-rats-shave.md diff --git a/.changeset/itchy-rats-shave.md b/.changeset/itchy-rats-shave.md new file mode 100644 index 0000000..d9b41da --- /dev/null +++ b/.changeset/itchy-rats-shave.md @@ -0,0 +1,5 @@ +--- +"@oak-network/sdk": patch +--- + +Add scheduleAs to task params From a49df015b3bcda39b7f83af780ba905f324799a7 Mon Sep 17 00:00:00 2001 From: imstar15 Date: Thu, 7 Dec 2023 15:21:29 +0800 Subject: [PATCH 3/3] The scheduleAs parameter should be pass into schedule task function --- packages/sdk/src/index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index 2c91f61..8f83908 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -140,6 +140,10 @@ export function Sdk() { xcmOptions, scheduleAs, } = params; + if (_.isEmpty(scheduleAs)) { + throw new Error("The scheduleAs parameter should not be empty"); + } + const createTaskFunc = (funcParams: CreateTaskFuncParams): SubmittableExtrinsic<"promise"> => { const { oakApi, destination, executionFee, encodedCall, encodedCallWeight, overallWeight } = funcParams; const taskExtrinsic = oakApi.tx.automationPrice.scheduleXcmpTaskThroughProxy( @@ -156,7 +160,7 @@ export function Sdk() { encodedCall, encodedCallWeight, overallWeight, - scheduleAs || u8aToHex(keyringPair.addressRaw), + scheduleAs, ); return taskExtrinsic; }; @@ -236,9 +240,12 @@ export function Sdk() { xcmOptions, scheduleAs, } = scheduleXcmpTaskParams; + if (_.isEmpty(scheduleAs)) { + throw new Error("The scheduleAs parameter should not be empty"); + } + const createTaskFunc = (funcParams: CreateTaskFuncParams): SubmittableExtrinsic<"promise"> => { const { oakApi, destination, executionFee, encodedCall, encodedCallWeight, overallWeight } = funcParams; - console.log("scheduleFeeLocation: ", scheduleFeeLocation); const taskExtrinsic = oakApi.tx.automationTime.scheduleXcmpTaskThroughProxy( schedule, destination, @@ -247,7 +254,7 @@ export function Sdk() { encodedCall, encodedCallWeight, overallWeight, - scheduleAs || u8aToHex(keyringPair.addressRaw), + scheduleAs, ); return taskExtrinsic; };