From 9cfa4a93c4c6152e77b6639a6b8072b01324c336 Mon Sep 17 00:00:00 2001 From: imstar15 Date: Tue, 12 Dec 2023 09:09:24 +0800 Subject: [PATCH] Change oakAdapter account derivation (#125) * Change oakAdapter account derivation * docs(changeset): Change oakAdapter account derivation --- .changeset/cyan-needles-act.md | 6 ++++++ packages/adapter/src/chains/oak.ts | 22 +++++----------------- packages/sdk/src/index.ts | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-) create mode 100644 .changeset/cyan-needles-act.md diff --git a/.changeset/cyan-needles-act.md b/.changeset/cyan-needles-act.md new file mode 100644 index 0000000..8d7bdda --- /dev/null +++ b/.changeset/cyan-needles-act.md @@ -0,0 +1,6 @@ +--- +"@oak-network/adapter": patch +"@oak-network/sdk": patch +--- + +Change oakAdapter account derivation diff --git a/packages/adapter/src/chains/oak.ts b/packages/adapter/src/chains/oak.ts index 4bdc1ef..aa42a37 100644 --- a/packages/adapter/src/chains/oak.ts +++ b/packages/adapter/src/chains/oak.ts @@ -6,10 +6,10 @@ import type { SubmittableExtrinsic, AddressOrPair } from "@polkadot/api/types"; import type { u32, u128, Option } from "@polkadot/types"; import type { WeightV2 } from "@polkadot/types/interfaces"; import type { KeyringPair } from "@polkadot/keyring/types"; -import { Weight, XcmInstructionNetworkType, Chain, XToken } from "@oak-network/config"; +import { Weight, Chain, XToken } from "@oak-network/config"; import { ISubmittableResult } from "@polkadot/types/types"; import { ChainAdapter } from "./chainAdapter"; -import { getDerivativeAccountV2, isValidAddress, sendExtrinsic, getDecimalBN } from "../utils"; +import { isValidAddress, sendExtrinsic, getDecimalBN, getDerivativeAccountV3 } from "../utils"; import { AccountType, SendExtrinsicResult } from "../types"; import { WEIGHT_REF_TIME_PER_SECOND } from "../constants"; import { InvalidAddress } from "../errors"; @@ -296,23 +296,11 @@ export class OakAdapter extends ChainAdapter { * Calculate the derivative account ID of a certain account ID * @param accountId * @param paraId The paraId of the XCM message sender - * @param options Optional operation options: { locationType, network } * @returns Derivative account */ - getDerivativeAccount( - accountId: HexString, - paraId: number, - xcmInstructionNetworkType: XcmInstructionNetworkType = XcmInstructionNetworkType.Null, - ): HexString { - const api = this.getApi(); - const accountOptions = - xcmInstructionNetworkType === XcmInstructionNetworkType.Concrete - ? { - locationType: "XcmV3MultiLocation", - network: this.getChainConfig().xcm.network, - } - : undefined; - return getDerivativeAccountV2(api, accountId, paraId, accountOptions); + // eslint-disable-next-line class-methods-use-this + getDerivativeAccount(accountId: HexString, paraId: number): HexString { + return getDerivativeAccountV3(accountId, paraId); } /** diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index 8f83908..7dabe12 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -88,7 +88,7 @@ const scheduleXcmpTaskWithPayThroughRemoteDerivativeAccountFlow = async ( }; // Calculate derive account on Turing/OAK - const deriveAccountId = oakAdapter.getDerivativeAccount(u8aToHex(keyringPair.addressRaw), paraId, xcm.instructionNetworkType); + const deriveAccountId = oakAdapter.getDerivativeAccount(u8aToHex(keyringPair.addressRaw), paraId); // Create task extrinsic const taskExtrinsic = createTaskFunc({