From c2062f3c93f688e2c031ff69b0fe69182bb4acd0 Mon Sep 17 00:00:00 2001 From: Elmar Kenigs Date: Tue, 24 Jan 2023 16:43:11 +0100 Subject: [PATCH] Added to destination and source chains ss58Format and genesisHash (#55) --- package-lock.json | 7 +++---- packages/config/src/interfaces.ts | 2 ++ packages/sdk/src/polkadot/PolkadotService.ts | 2 ++ packages/sdk/src/sdk/sdk.deposit.ts | 6 +++++- packages/sdk/src/sdk/sdk.withdraw.ts | 6 +++++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9027a8fb..0b21e387 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,9 @@ { - "name": "xcm-sdk", + "name": "xcm", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "xcm-sdk", "license": "MIT", "workspaces": [ "packages/*", @@ -9073,7 +9072,7 @@ }, "packages/config": { "name": "@moonbeam-network/xcm-config", - "version": "0.3.4", + "version": "0.3.6", "license": "MIT", "peerDependencies": { "@polkadot/api": "9.x", @@ -9085,7 +9084,7 @@ }, "packages/sdk": { "name": "@moonbeam-network/xcm-sdk", - "version": "0.3.4", + "version": "0.3.6", "license": "MIT", "dependencies": { "@moonbeam-network/xcm-config": "*", diff --git a/packages/config/src/interfaces.ts b/packages/config/src/interfaces.ts index ec70352f..af97b0e6 100644 --- a/packages/config/src/interfaces.ts +++ b/packages/config/src/interfaces.ts @@ -49,6 +49,8 @@ export interface Chain * unitsPerSecond = weightPerSecond * baseExtrinsicCost / baseExtrinsicWeight */ unitsPerSecond?: bigint; + ss58Format?: number; + genesisHash?: string; } export interface XcmFeeAsset { diff --git a/packages/sdk/src/polkadot/PolkadotService.ts b/packages/sdk/src/polkadot/PolkadotService.ts index 9a2eb0d5..fc915a96 100644 --- a/packages/sdk/src/polkadot/PolkadotService.ts +++ b/packages/sdk/src/polkadot/PolkadotService.ts @@ -48,6 +48,8 @@ export class PolkadotService< return { decimals: this.#api.registry.chainDecimals.at(0) || 12, symbol: this.#api.registry.chainTokens.at(0) as Symbols, + ss58Format: this.#api.registry.chainSS58 || 42, + genesisHash: this.#api.genesisHash.toHex(), }; } diff --git a/packages/sdk/src/sdk/sdk.deposit.ts b/packages/sdk/src/sdk/sdk.deposit.ts index ca1e3c83..54e605f7 100644 --- a/packages/sdk/src/sdk/sdk.deposit.ts +++ b/packages/sdk/src/sdk/sdk.deposit.ts @@ -160,7 +160,11 @@ export async function getDepositData< }, native: { ...nativeAsset, decimals: meta.decimals }, origin, - source: config.source, + source: { + ...config.source, + ss58Format: meta.ss58Format, + genesisHash: meta.genesisHash, + }, sourceBalance, sourceFeeBalance: !isUndefined(sourceFeeBalance) ? { ...meta, balance: sourceFeeBalance } diff --git a/packages/sdk/src/sdk/sdk.withdraw.ts b/packages/sdk/src/sdk/sdk.withdraw.ts index 0265b8a4..fcd5967d 100644 --- a/packages/sdk/src/sdk/sdk.withdraw.ts +++ b/packages/sdk/src/sdk/sdk.withdraw.ts @@ -111,7 +111,11 @@ export async function getWithdrawData< return { asset: { ...asset, decimals }, - destination: config.destination, + destination: { + ...config.destination, + ss58Format: meta.ss58Format, + genesisHash: meta.genesisHash, + }, destinationBalance, destinationFee, existentialDeposit,