Skip to content

Commit fe5b688

Browse files
committed
adjustments after integrating XCM in the dapp
1 parent 82e55a4 commit fe5b688

File tree

6 files changed

+35
-8
lines changed

6 files changed

+35
-8
lines changed

packages/builder/src/fee/FeeBuilder.utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ export async function getVersionedAssetId(
201201
const assetId = asset.getAssetId();
202202
const palletInstance = asset.getAssetPalletInstance();
203203

204-
if (assetId === chain.nativeAsset.address) {
204+
if (assetId === chain.nativeAsset.originSymbol) {
205205
return getNativeAssetId(palletInstance);
206206
}
207207

208-
if (isHexString(assetId)) {
209-
return getConcreteAssetIdWithAccountKey20(assetId, palletInstance);
208+
if (asset.hasOnlyAddress()) {
209+
return getConcreteAssetIdWithAccountKey20(asset.address, palletInstance);
210210
}
211211

212212
const assetType = await getAssetIdType(api, assetId);

packages/config/src/chains.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,9 @@ export const moonbeam = new EvmParachain({
10721072
ChainAsset.fromAsset(dai, {
10731073
address: '0x06e605775296e851FF43b4dAa541Bb0984E9D6fD',
10741074
decimals: 18,
1075+
ids: {
1076+
palletInstance: 110,
1077+
},
10751078
}),
10761079
ChainAsset.fromAsset(ded, {
10771080
address: '0xfFffFFFf5da2d7214D268375cf8fb1715705FdC6',
@@ -1210,10 +1213,16 @@ export const moonbeam = new EvmParachain({
12101213
ChainAsset.fromAsset(usdcwh, {
12111214
address: '0x931715FEE2d06333043d11F658C8CE934aC61D0c',
12121215
decimals: 6,
1216+
ids: {
1217+
palletInstance: 110,
1218+
},
12131219
}),
12141220
ChainAsset.fromAsset(usdtwh, {
12151221
address: '0xc30E9cA94CF52f3Bf5692aaCF81353a27052c46f',
12161222
decimals: 6,
1223+
ids: {
1224+
palletInstance: 110,
1225+
},
12171226
}),
12181227
ChainAsset.fromAsset(usdt, {
12191228
address: '0xFFFFFFfFea09FB06d082fd1275CD48b191cbCD1d',
@@ -1260,10 +1269,16 @@ export const moonbeam = new EvmParachain({
12601269
ChainAsset.fromAsset(wbtc, {
12611270
address: '0xE57eBd2d67B462E9926e04a8e33f01cD0D64346D',
12621271
decimals: 8,
1272+
ids: {
1273+
palletInstance: 110,
1274+
},
12631275
}),
12641276
ChainAsset.fromAsset(weth, {
12651277
address: '0xab3f0245B83feB11d15AAffeFD7AD465a59817eD',
12661278
decimals: 18,
1279+
ids: {
1280+
palletInstance: 110,
1281+
},
12671282
}),
12681283
ChainAsset.fromAsset(ztg, {
12691284
address: '0xFFFFfffF71815ab6142E0E20c7259126C6B40612',
@@ -1398,6 +1413,9 @@ export const moonriver = new EvmParachain({
13981413
address: '0x0000000000000000000000000000000000000802',
13991414
decimals: 18,
14001415
min: 0.01,
1416+
ids: {
1417+
palletInstance: 10,
1418+
},
14011419
}),
14021420
ChainAsset.fromAsset(pha, {
14031421
address: '0xffFfFFff8E6b63d9e447B6d4C45BDA8AF9dc9603',

packages/config/src/xcm-configs/bifrostPolkadot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const bifrostPolkadotRoutes = new ChainRoutes({
8484
destination: {
8585
asset: glmr,
8686
chain: moonbeam,
87-
balance: BalanceBuilder().substrate().assets().account(),
87+
balance: BalanceBuilder().substrate().system().account(),
8888
fee: {
8989
amount: FeeBuilder()
9090
.xcmPaymentApi()

packages/sdk/src/getTransferData/getDestinationData.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ async function getSovereignAccountBalances({
6666
destination,
6767
source,
6868
}: GetSovereignAccountBalancesProps) {
69-
if (!Parachain.is(source.chain) || !Parachain.is(destination.chain)) {
69+
if (
70+
!Parachain.is(source.chain) ||
71+
!Parachain.is(destination.chain) ||
72+
!destination.chain.checkSovereignAccountBalances
73+
) {
7074
return undefined;
7175
}
7276

packages/sdk/src/sdk.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ConfigService, xcmRoutesMap } from '@moonbeam-network/xcm-config';
22
import {
33
type AnyAsset,
4+
type AnyChain,
45
type AnyParachain,
56
type AssetAmount,
67
type Ecosystem,
@@ -28,15 +29,15 @@ export function Sdk({ configService, ecosystem }: SdkOptions = {}) {
2829

2930
return {
3031
sources,
31-
setSource(source: string | AnyParachain) {
32+
setSource(source: string | AnyChain) {
3233
const destinations = service.getDestinationChains({
3334
asset,
3435
source,
3536
});
3637

3738
return {
3839
destinations,
39-
setDestination(destination: string | AnyParachain) {
40+
setDestination(destination: string | AnyChain) {
4041
const route = service.getAssetRoute({
4142
asset,
4243
source,
@@ -59,7 +60,7 @@ export function Sdk({ configService, ecosystem }: SdkOptions = {}) {
5960
);
6061
}
6162

62-
if (!EvmParachain.isAnyParachain(route.destination)) {
63+
if (!EvmParachain.isAnyParachain(route.destination.chain)) {
6364
throw new Error(
6465
'Destination chain should be a Parachain or EvmParachain',
6566
);

packages/types/src/asset/ChainAsset.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,8 @@ export class ChainAsset extends Asset {
9090
getAssetMin(): bigint {
9191
return this.min ?? 0n;
9292
}
93+
94+
hasOnlyAddress(): this is { address: string } {
95+
return !!this.address && !this.ids?.id;
96+
}
9397
}

0 commit comments

Comments
 (0)