Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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