From de87e3e4b2817080dcb60495cbcc70a8bef47a69 Mon Sep 17 00:00:00 2001 From: mmaurello <93129175+mmaurello@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:58:37 +0200 Subject: [PATCH 1/2] Change vDOT paying asset - fix decimals fetching in destination (#153) * Change paying token for vDOT transfers and adapt decimals query in destination chain * add changeset --- .changeset/orange-trainers-teach.md | 6 ++++++ packages/config/src/chains.ts | 2 +- .../config/src/configs/bifrostPolkadot.ts | 8 ++++---- .../src/getTransferData/getDestinationData.ts | 19 +++++++++++++++++-- 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 .changeset/orange-trainers-teach.md diff --git a/.changeset/orange-trainers-teach.md b/.changeset/orange-trainers-teach.md new file mode 100644 index 00000000..338e6d80 --- /dev/null +++ b/.changeset/orange-trainers-teach.md @@ -0,0 +1,6 @@ +--- +'@moonbeam-network/xcm-config': patch +'@moonbeam-network/xcm-sdk': patch +--- + +Change how we get decimals from assets in destination and change vDOT transfers paying asset diff --git a/packages/config/src/chains.ts b/packages/config/src/chains.ts index cdcf7a37..6c719bc5 100644 --- a/packages/config/src/chains.ts +++ b/packages/config/src/chains.ts @@ -219,7 +219,7 @@ export const bifrostPolkadot = new Parachain({ name: 'Bifrost', parachainId: 2030, ss58Format: 6, - ws: 'wss://hk.p.bifrost-rpc.liebi.com/ws', + ws: 'wss://eu.bifrost-polkadot-rpc.liebi.com/ws', }); export const calamari = new Parachain({ diff --git a/packages/config/src/configs/bifrostPolkadot.ts b/packages/config/src/configs/bifrostPolkadot.ts index f7542e73..f6d24020 100644 --- a/packages/config/src/configs/bifrostPolkadot.ts +++ b/packages/config/src/configs/bifrostPolkadot.ts @@ -59,11 +59,11 @@ export const bifrostPolkadotConfig = new ChainConfig({ balance: BalanceBuilder().substrate().tokens().accounts(), destination: moonbeam, destinationFee: { - amount: 0.2, - asset: bnc, - balance: BalanceBuilder().substrate().system().account(), + amount: 0.01, + asset: vdot, + balance: BalanceBuilder().substrate().tokens().accounts(), }, - extrinsic: ExtrinsicBuilder().xTokens().transferMultiCurrencies(), + extrinsic: ExtrinsicBuilder().xTokens().transfer(), fee: { asset: bnc, balance: BalanceBuilder().substrate().system().account(), diff --git a/packages/sdk/src/getTransferData/getDestinationData.ts b/packages/sdk/src/getTransferData/getDestinationData.ts index 1f59fd0b..ed56e1cc 100644 --- a/packages/sdk/src/getTransferData/getDestinationData.ts +++ b/packages/sdk/src/getTransferData/getDestinationData.ts @@ -46,7 +46,12 @@ export async function getDestinationData({ const balanceAmount = zeroAmount.copyWith({ amount: balance }); const { existentialDeposit } = polkadot; - const feeAmount = await getFee({ config: transferConfig, polkadot }); + const feeAmount = await getFee({ + address: destinationAddress, + config: transferConfig, + evmSigner, + polkadot, + }); const minAmount = zeroAmount.copyWith({ amount: min }); return { @@ -59,16 +64,26 @@ export async function getDestinationData({ } export interface GetFeeParams { + address: string; config: TransferConfig; + evmSigner?: EvmSigner; polkadot: PolkadotService; } export async function getFee({ + address, config, + evmSigner, polkadot, }: GetFeeParams): Promise { const { amount, asset } = config.source.config.destinationFee; - const decimals = await polkadot.getAssetDecimals(asset); + const decimals = await getDecimals({ + address, + asset, + config: config.destination.config, + evmSigner, + polkadot, + }); const zeroAmount = AssetAmount.fromAsset(asset, { amount: 0n, decimals, From 71a34c5a94dc9926c70ddcab87ff07dd1b681303 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 27 Oct 2023 15:54:00 +0200 Subject: [PATCH 2/2] Version Packages (#154) Co-authored-by: github-actions[bot] --- .changeset/orange-trainers-teach.md | 6 ------ examples/sdk-simple/package.json | 4 ++-- package-lock.json | 10 +++++----- packages/config/CHANGELOG.md | 6 ++++++ packages/config/package.json | 2 +- packages/sdk/CHANGELOG.md | 9 +++++++++ packages/sdk/package.json | 4 ++-- 7 files changed, 25 insertions(+), 16 deletions(-) delete mode 100644 .changeset/orange-trainers-teach.md diff --git a/.changeset/orange-trainers-teach.md b/.changeset/orange-trainers-teach.md deleted file mode 100644 index 338e6d80..00000000 --- a/.changeset/orange-trainers-teach.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@moonbeam-network/xcm-config': patch -'@moonbeam-network/xcm-sdk': patch ---- - -Change how we get decimals from assets in destination and change vDOT transfers paying asset diff --git a/examples/sdk-simple/package.json b/examples/sdk-simple/package.json index 6232c379..b926851a 100644 --- a/examples/sdk-simple/package.json +++ b/examples/sdk-simple/package.json @@ -12,8 +12,8 @@ "author": "", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "1.3.7", - "@moonbeam-network/xcm-sdk": "1.4.2", + "@moonbeam-network/xcm-config": "1.3.8", + "@moonbeam-network/xcm-sdk": "1.4.3", "@moonbeam-network/xcm-utils": "1.0.3" }, "devDependencies": { diff --git a/package-lock.json b/package-lock.json index 6ecf7aea..f7501718 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,8 +49,8 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@moonbeam-network/xcm-config": "1.3.7", - "@moonbeam-network/xcm-sdk": "1.4.2", + "@moonbeam-network/xcm-config": "1.3.8", + "@moonbeam-network/xcm-sdk": "1.4.3", "@moonbeam-network/xcm-utils": "1.0.3" }, "devDependencies": { @@ -16951,7 +16951,7 @@ }, "packages/config": { "name": "@moonbeam-network/xcm-config", - "version": "1.3.7", + "version": "1.3.8", "license": "MIT", "dependencies": { "@moonbeam-network/xcm-builder": "1.0.8", @@ -16965,11 +16965,11 @@ }, "packages/sdk": { "name": "@moonbeam-network/xcm-sdk", - "version": "1.4.2", + "version": "1.4.3", "license": "MIT", "dependencies": { "@moonbeam-network/xcm-builder": "1.0.8", - "@moonbeam-network/xcm-config": "1.3.7", + "@moonbeam-network/xcm-config": "1.3.8", "@moonbeam-network/xcm-types": "1.0.1", "@moonbeam-network/xcm-utils": "1.0.3", "big.js": "^6.2.1" diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index 96e3c73a..1e7fb408 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,11 @@ # @moonbeam-network/xcm-config +## 1.3.8 + +### Patch Changes + +- [#153](https://github.com/PureStake/xcm-sdk/pull/153) [`de87e3e`](https://github.com/PureStake/xcm-sdk/commit/de87e3e4b2817080dcb60495cbcc70a8bef47a69) Thanks [@mmaurello](https://github.com/mmaurello)! - Change how we get decimals from assets in destination and change vDOT transfers paying asset + ## 1.3.7 ### Patch Changes diff --git a/packages/config/package.json b/packages/config/package.json index 11dc5b89..afd290f1 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-config", - "version": "1.3.7", + "version": "1.3.8", "description": "All necessary configuration to transfer assets from Moonbeam, Moonriver, Moonbase to other parachains and back", "scripts": { "build": "tsup", diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 779097d9..4d0e1741 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,14 @@ # @moonbeam-network/xcm-sdk +## 1.4.3 + +### Patch Changes + +- [#153](https://github.com/PureStake/xcm-sdk/pull/153) [`de87e3e`](https://github.com/PureStake/xcm-sdk/commit/de87e3e4b2817080dcb60495cbcc70a8bef47a69) Thanks [@mmaurello](https://github.com/mmaurello)! - Change how we get decimals from assets in destination and change vDOT transfers paying asset + +- Updated dependencies [[`de87e3e`](https://github.com/PureStake/xcm-sdk/commit/de87e3e4b2817080dcb60495cbcc70a8bef47a69)]: + - @moonbeam-network/xcm-config@1.3.8 + ## 1.4.2 ### Patch Changes diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 7be133a2..ede9928f 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@moonbeam-network/xcm-sdk", - "version": "1.4.2", + "version": "1.4.3", "description": "The Moonbeam XCM SDK enables developers to easily deposit and withdraw assets to Moonbeam/Moonriver from the relay chain and other parachains in the Polkadot/Kusama ecosystem", "scripts": { "build": "tsup", @@ -48,7 +48,7 @@ "main": "./build/index.cjs", "dependencies": { "@moonbeam-network/xcm-builder": "1.0.8", - "@moonbeam-network/xcm-config": "1.3.7", + "@moonbeam-network/xcm-config": "1.3.8", "@moonbeam-network/xcm-types": "1.0.1", "@moonbeam-network/xcm-utils": "1.0.3", "big.js": "^6.2.1"