Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oak-network/sdk

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oak-network/sdk - npm Package Compare versions

Comparing version 0.1.0-rc.20 to 0.1.0-rc.21

25

index.d.ts

@@ -22,2 +22,21 @@ import type { SubmittableExtrinsic } from '@polkadot/api/types';

}
interface AutomationPriceTriggerParams {
chain: string;
exchange: string;
asset1: string;
asset2: string;
submittedAt: number;
triggerFunction: 'lt' | 'gt';
triggerParam: number[];
}
interface ScheduleXcmpPriceTaskWithPayThroughRemoteDerivativeAccountFlowParams {
oakAdapter: OakAdapter;
destinationChainAdapter: TaskSchedulerChainAdapter;
taskPayloadExtrinsic: SubmittableExtrinsic<'promise'>;
scheduleFeeLocation: any;
executionFeeLocation: any;
automationPriceTriggerParams: AutomationPriceTriggerParams;
scheduleAs: HexString;
keyringPair: KeyringPair;
}
export declare function Sdk(): {

@@ -36,3 +55,9 @@ /**

scheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlow: (params: ScheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlowParams) => Promise<SendExtrinsicResult>;
/**
* Schedule XCMP price task with PayThroughRemoteDerivativeAccount instruction sequances
* @param params Operation params
* @returns
*/
scheduleXcmpPriceTaskWithPayThroughRemoteDerivativeAccountFlow: (params: ScheduleXcmpPriceTaskWithPayThroughRemoteDerivativeAccountFlowParams) => Promise<SendExtrinsicResult>;
};
export {};

@@ -57,2 +57,33 @@ "use strict";

}
async function scheduleXcmpPriceTaskWithPayThroughRemoteDerivativeAccountFlow({ oakAdapter, destinationChainAdapter, taskPayloadExtrinsic, scheduleFeeLocation, executionFeeLocation, automationPriceTriggerParams, scheduleAs, keyringPair, }) {
const oakApi = oakAdapter.getApi();
const { paraId, xcmInstructionNetworkType, xcm } = destinationChainAdapter.getChainData();
if (lodash_1.default.isUndefined(paraId))
throw new Error("chainData.paraId not set");
if (lodash_1.default.isUndefined(xcmInstructionNetworkType))
throw new Error("chainData.xcmInstructionNetworkType not set");
if (lodash_1.default.isUndefined(xcm))
throw new Error("chainData.xcm not set");
// Caluculate weight and fee for task
const destination = { V3: destinationChainAdapter.getLocation() };
const encodedCall = taskPayloadExtrinsic.method.toHex();
const oakTransactXcmInstructionCount = oakAdapter.getTransactXcmInstructionCount();
const { encodedCallWeight, overallWeight } = await destinationChainAdapter.getXcmWeight(taskPayloadExtrinsic, keyringPair.address, oakTransactXcmInstructionCount);
const scheduleFee = { V3: scheduleFeeLocation };
const executionFeeAmout = await destinationChainAdapter.weightToFee(overallWeight, executionFeeLocation);
const executionFee = { assetLocation: { V3: executionFeeLocation }, amount: executionFeeAmout };
// Calculate derive account on Turing/OAK
const options = xcmInstructionNetworkType === adapter_1.XcmInstructionNetworkType.Concrete ? { locationType: 'XcmV3MultiLocation', network: xcm.network } : undefined;
const deriveAccountId = oakAdapter.getDerivativeAccount((0, util_1.u8aToHex)(keyringPair.addressRaw), paraId, options);
// Schedule task through proxy
const taskExtrinsic = oakApi.tx.automationPrice.scheduleXcmpTaskThroughProxy(automationPriceTriggerParams.chain, automationPriceTriggerParams.exchange, automationPriceTriggerParams.asset1, automationPriceTriggerParams.asset2, automationPriceTriggerParams.submittedAt, automationPriceTriggerParams.triggerFunction, automationPriceTriggerParams.triggerParam, destination, scheduleFee, executionFee, encodedCall, encodedCallWeight, overallWeight, scheduleAs);
// Schedule task through XCM
const taskEncodedCall = taskExtrinsic.method.toHex();
const destinationTransactXcmInstructionCount = destinationChainAdapter.getTransactXcmInstructionCount();
const { encodedCallWeight: taskEncodedCallWeight, overallWeight: taskOverallWeight } = await oakAdapter.getXcmWeight(taskExtrinsic, deriveAccountId, destinationTransactXcmInstructionCount);
const taskExecutionFee = await oakAdapter.weightToFee(taskOverallWeight, executionFeeLocation);
const oakLocation = oakAdapter.getLocation();
const sendExtrinsicResult = await destinationChainAdapter.scheduleTaskThroughXcm(oakLocation, taskEncodedCall, executionFeeLocation, taskExecutionFee, taskEncodedCallWeight, taskOverallWeight, keyringPair);
return sendExtrinsicResult;
}
function Sdk() {

@@ -78,2 +109,11 @@ return {

},
/**
* Schedule XCMP price task with PayThroughRemoteDerivativeAccount instruction sequances
* @param params Operation params
* @returns
*/
scheduleXcmpPriceTaskWithPayThroughRemoteDerivativeAccountFlow: async (params) => {
const result = await scheduleXcmpPriceTaskWithPayThroughRemoteDerivativeAccountFlow(params);
return result;
},
};

@@ -80,0 +120,0 @@ }

2

package.json
{
"name": "@oak-network/sdk",
"version": "0.1.0-rc.20",
"version": "0.1.0-rc.21",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "main": "./index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc