Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/components/header/mobile/AstarDomains.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ export default defineComponent({
img: icon_img.home,
link: 'https://astar.network/',
},
{
title: 'Astar 2.0',
img: icon_img.astar2,
link: 'https://astar.network/astar2',
},
{
title: 'Tech Stack',
img: icon_img.tech_stack,
link: 'https://astar.network/developers/techstack',
},
{
title: 'Astar Docs',
img: icon_img.docs,
Expand Down
7 changes: 2 additions & 5 deletions src/modules/xcm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ export let xcmChainObj: XcmChainObj = {
img: require('/src/assets/img/token/pha.png'),
parachainId: parachainIds.PHALA,
endpoints: [
'wss://api.phala.network/ws',
'wss://phala-rpc.dwellir.com',
'wss://phala.api.onfinality.io/public-ws',
'wss://rpc.helikon.io/phala',
],
subscan: 'https://phala.subscan.io',
isAstarNativeToken: true,
Expand All @@ -298,10 +298,7 @@ export let xcmChainObj: XcmChainObj = {
relayChain: Chain.POLKADOT,
img: require('/src/assets/img/token/bnc.svg'),
parachainId: parachainIds.BIFROST_POLKADOT,
endpoints: [
'wss://hk.p.bifrost-rpc.liebi.com/ws',
'wss://bifrost-polkadot.api.onfinality.io/public-ws',
],
endpoints: ['wss://hk.p.bifrost-rpc.liebi.com/ws'],
chopsticksEndpoint: 'ws://localhost:9947',
subscan: 'https://bifrost.subscan.io',
isAstarNativeToken: true,
Expand Down
23 changes: 16 additions & 7 deletions src/v2/repositories/implementations/XcmRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export const ASTAR_ADDRESS_PREFIX = 5;

@injectable()
export class XcmRepository implements IXcmRepository {
// XCM version to use for all message constructions
protected readonly xcmVersion: 'V3' | 'V5' = 'V3';

// Ids of Astar tokens on foreign network. To be initialized in iherited class.
protected astarTokens: TokenId;

Expand Down Expand Up @@ -128,10 +131,9 @@ export class XcmRepository implements IXcmRepository {
throw `Parachain id for ${to.name} is not defined`;
}

const version = 'V3';
// the target parachain connected to the current relaychain
const destination = {
[version]: {
[this.xcmVersion]: {
interior: {
X1: {
Parachain: new BN(to.parachainId),
Expand All @@ -149,7 +151,7 @@ export class XcmRepository implements IXcmRepository {
};

const beneficiary = {
[version]: {
[this.xcmVersion]: {
interior: {
X1: {
AccountId32,
Expand All @@ -160,7 +162,7 @@ export class XcmRepository implements IXcmRepository {
};

const assets = {
[version]: [
[this.xcmVersion]: [
{
fun: {
Fungible: amount,
Expand Down Expand Up @@ -210,7 +212,7 @@ export class XcmRepository implements IXcmRepository {
};

const assets = {
V3: {
[this.xcmVersion]: {
fun: {
Fungible: new BN(amount),
},
Expand All @@ -219,7 +221,7 @@ export class XcmRepository implements IXcmRepository {
};

const destination = {
V3: {
[this.xcmVersion]: {
interior: {
X1: {
AccountId32: {
Expand Down Expand Up @@ -305,7 +307,14 @@ export class XcmRepository implements IXcmRepository {
const api = await this.apiFactory.get(endpoint);
const config = await api.query.xcAssetConfig.assetIdToLocation<Option<AssetConfig>>(tokenId);
const formattedAssetConfig = JSON.parse(config.toString());
return formattedAssetConfig.v3;

// Get the first available version (v3, v4, v5, etc.)
const versionKey = Object.keys(formattedAssetConfig)[0];
if (!versionKey) {
throw new Error('No version found in asset config');
}

return formattedAssetConfig[versionKey];
}

protected async fetchAssetConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class AcalaXcmRepository extends XcmRepository {
const tokenData = this.getTokenData(token);

const destination = {
V3: {
[this.xcmVersion]: {
parents: '1',
interior: {
X2: [
Expand Down
19 changes: 8 additions & 11 deletions src/v2/repositories/implementations/xcm/AstarXcmRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getPubkeyFromSS58Addr } from '@astar-network/astar-sdk-core';
import { XcmTokenInformation } from 'src/modules/xcm';
import { container } from 'src/v2/common';
import { ExtrinsicPayload, IApi, IApiFactory } from 'src/v2/integration';
import { Asset, Chain, ethWalletChains, XcmChain } from 'src/v2/models';
import { Asset, ethWalletChains, XcmChain } from 'src/v2/models';
import { Symbols } from 'src/v2/symbols';
import { XcmRepository } from '../XcmRepository';

Expand All @@ -13,6 +13,7 @@ import { XcmRepository } from '../XcmRepository';
*/
export class AstarXcmRepository extends XcmRepository {
private astarNativeTokenId;
protected readonly xcmVersion = 'V5';

constructor() {
const defaultApi = container.get<IApi>(Symbols.DefaultApi);
Expand All @@ -39,18 +40,14 @@ export class AstarXcmRepository extends XcmRepository {
const isWithdrawAssets = token.id !== this.astarNativeTokenId;

const asset = isWithdrawAssets
? {
Concrete: await this.fetchAssetConfig(from, token, endpoint),
}
? await this.fetchAssetConfig(from, token, endpoint)
: {
Concrete: {
interior: 'Here',
parents: new BN(0),
},
interior: 'Here',
parents: new BN(0),
};

const assets = {
V3: {
[this.xcmVersion]: {
fun: {
Fungible: new BN(amount),
},
Expand All @@ -73,7 +70,7 @@ export class AstarXcmRepository extends XcmRepository {
};

const destination = {
V3: {
[this.xcmVersion]: {
interior: {
X2: [
{
Expand All @@ -97,7 +94,7 @@ export class AstarXcmRepository extends XcmRepository {
if (feeAssetInformation.feeAssetIsRequired) {
// we need to use another token for the fee
const fee = {
V3: {
[this.xcmVersion]: {
fun: {
Fungible: new BN(feeAssetInformation.feeAmount),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@ export class BifrostXcmRepository extends XcmRepository {
throw `Token name for ${token.originAssetId} is not defined`;
}

const version = 'V3';

const AccountId32 = {
id: decodeAddress(recipientAddress),
};

const destination = {
[version]: {
[this.xcmVersion]: {
parents: '1',
interior: {
X2: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ export class HydrationXcmRepository extends XcmRepository {
throw `Token name for ${token.originAssetId} is not defined`;
}

const version = 'V3';

const AccountId32 = {
id: decodeAddress(recipientAddress),
};

const destination = {
[version]: {
[this.xcmVersion]: {
parents: '1',
interior: {
X2: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class InterlayXcmRepository extends XcmRepository {
const tokenData = { Token: token.originAssetId };

const destination = {
V3: {
[this.xcmVersion]: {
parents: '1',
interior: {
X2: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ export class PendulumXcmRepository extends XcmRepository {
throw `Token name for ${token.originAssetId} is not defined`;
}

const version = 'V3';

const AccountId32 = {
id: decodeAddress(recipientAddress),
};

const destination = {
[version]: {
[this.xcmVersion]: {
parents: '1',
interior: {
X2: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ export class StatemintXcmRepository extends XcmRepository {
throw `Parachain id for ${to.name} is not defined`;
}

const version = 'V3';
const destination = {
[version]: {
[this.xcmVersion]: {
interior: {
X1: {
Parachain: to.parachainId,
Expand All @@ -52,7 +51,7 @@ export class StatemintXcmRepository extends XcmRepository {
};

const beneficiary = {
[version]: {
[this.xcmVersion]: {
interior: {
X1: {
AccountId32,
Expand All @@ -68,7 +67,7 @@ export class StatemintXcmRepository extends XcmRepository {
const instance = 50;

const assets = {
[version]: [
[this.xcmVersion]: [
{
fun: {
Fungible: new BN(amount),
Expand Down
Loading
Loading