Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scheduleAs to task params #122

Merged
merged 3 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
33 changes: 25 additions & 8 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,16 @@ 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;
const createTaskFunc = (funcParams: CreateTaskFuncParams): SubmittableExtrinsic<"promise"> => {
const { oakApi, destination, executionFee, encodedCall, encodedCallWeight, overallWeight } = funcParams;
const taskExtrinsic = oakApi.tx.automationPrice.scheduleXcmpTaskThroughProxy(
Expand All @@ -147,7 +156,7 @@ export function Sdk() {
encodedCall,
encodedCallWeight,
overallWeight,
u8aToHex(keyringPair.addressRaw),
scheduleAs || u8aToHex(keyringPair.addressRaw),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is scheduleXcmpTaskThroughProxy. It has to use scheduleAs, right? If so, when scheduleAs is undefined, this should throw an error.

);
return taskExtrinsic;
};
Expand Down Expand Up @@ -214,11 +223,19 @@ 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;
const createTaskFunc = (funcParams: CreateTaskFuncParams): SubmittableExtrinsic<"promise"> => {
const { oakApi, destination, executionFee, encodedCall, encodedCallWeight, overallWeight } = funcParams;
console.log("scheduleFeeLocation: ", scheduleFeeLocation);
Expand All @@ -230,7 +247,7 @@ export function Sdk() {
encodedCall,
encodedCallWeight,
overallWeight,
u8aToHex(keyringPair.addressRaw),
scheduleAs || u8aToHex(keyringPair.addressRaw),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

);
return taskExtrinsic;
};
Expand All @@ -255,7 +272,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