Skip to content

Commit

Permalink
Add scheduleAs to task params (#122)
Browse files Browse the repository at this point in the history
* Add scheduleAs to task params

* docs(changeset): Add scheduleAs to task params

* The scheduleAs parameter should be pass into schedule task function
  • Loading branch information
imstar15 authored Dec 7, 2023
1 parent 18c3c1a commit 2d5b02f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-rats-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@oak-network/sdk": patch
---

Add scheduleAs to task params
42 changes: 33 additions & 9 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface ScheduleXcmpTaskWithPayThroughSoverignAccountFlowParams extends Schedu

interface ScheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlowParams extends ScheduleXcmpTaskParams {
destinationChainAdapter: TaskSchedulerChainAdapter;
scheduleAs?: HexString;
}

interface CreateTaskFuncParams {
Expand Down Expand Up @@ -129,8 +130,20 @@ export function Sdk() {
params: ScheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlowParams,
automationPriceTriggerParams: AutomationPriceTriggerParams,
): Promise<SendExtrinsicResult> => {
const { oakAdapter, destinationChainAdapter, taskPayloadExtrinsic, scheduleFeeLocation, executionFeeLocation, keyringPair, xcmOptions } =
params;
const {
oakAdapter,
destinationChainAdapter,
taskPayloadExtrinsic,
scheduleFeeLocation,
executionFeeLocation,
keyringPair,
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(
Expand All @@ -147,7 +160,7 @@ export function Sdk() {
encodedCall,
encodedCallWeight,
overallWeight,
u8aToHex(keyringPair.addressRaw),
scheduleAs,
);
return taskExtrinsic;
};
Expand Down Expand Up @@ -214,14 +227,25 @@ export function Sdk() {
* @returns
*/
scheduleXcmpTimeTaskWithPayThroughRemoteDerivativeAccountFlow: async (
scheduleXcmpTaskParams: ScheduleXcmpTaskParams,
destinationChainAdapter: TaskSchedulerChainAdapter,
scheduleXcmpTaskParams: ScheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlowParams,
schedule: any,
): Promise<SendExtrinsicResult> => {
const { oakAdapter, taskPayloadExtrinsic, scheduleFeeLocation, executionFeeLocation, keyringPair, xcmOptions } = scheduleXcmpTaskParams;
const {
oakAdapter,
destinationChainAdapter,
taskPayloadExtrinsic,
scheduleFeeLocation,
executionFeeLocation,
keyringPair,
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,
Expand All @@ -230,7 +254,7 @@ export function Sdk() {
encodedCall,
encodedCallWeight,
overallWeight,
u8aToHex(keyringPair.addressRaw),
scheduleAs,
);
return taskExtrinsic;
};
Expand All @@ -255,7 +279,7 @@ export function Sdk() {
* @returns
*/
scheduleXcmpTimeTaskWithPayThroughSoverignAccountFlow: async (
scheduleXcmpTaskParams: ScheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlowParams,
scheduleXcmpTaskParams: ScheduleXcmpTaskWithPayThroughSoverignAccountFlowParams,
schedule: any,
): Promise<SendExtrinsicResult> => {
const { oakAdapter, destinationChainAdapter, taskPayloadExtrinsic, scheduleFeeLocation, executionFeeLocation, keyringPair, xcmOptions } =
Expand Down

0 comments on commit 2d5b02f

Please sign in to comment.