Skip to content

Commit

Permalink
Merge branch 'main' of github.com:PureStake/xcm-sdk into mjm/zeitgeis…
Browse files Browse the repository at this point in the history
…t-moonbeam
  • Loading branch information
mmaurello committed Oct 30, 2023
2 parents 40e93f9 + 71a34c5 commit d4ebf02
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 17 deletions.
4 changes: 2 additions & 2 deletions examples/sdk-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,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({
Expand Down
8 changes: 4 additions & 4 deletions packages/config/src/configs/bifrostPolkadot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
9 changes: 9 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 17 additions & 2 deletions packages/sdk/src/getTransferData/getDestinationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<AssetAmount> {
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,
Expand Down

0 comments on commit d4ebf02

Please sign in to comment.