diff --git a/src/renderer/pages/Operations/components/Operation.tsx b/src/renderer/pages/Operations/components/Operation.tsx index 181679fed..4644400f3 100644 --- a/src/renderer/pages/Operations/components/Operation.tsx +++ b/src/renderer/pages/Operations/components/Operation.tsx @@ -25,7 +25,8 @@ const Operation = ({ tx, account }: Props) => { const approvals = events?.filter((e) => e.status === 'SIGNED') || []; const initEvent = approvals.find((e) => e.accountId === tx.depositor); const date = new Date(tx.dateCreated || initEvent?.dateCreated || Date.now()); - const assetId = tx.transaction && (tx.transaction.args.assetId || tx.transaction.args.asset); + + const assetId = tx.transaction?.args.assetId || tx.transaction?.args.asset; const asset = getAssetById(assetId, chainsService.getChainById(tx.chainId)?.assets); const amount = tx.transaction && getTransactionAmount(tx.transaction); diff --git a/src/renderer/shared/api/xcm/__tests__/mock/xcmData.ts b/src/renderer/shared/api/xcm/__tests__/mock/xcmData.ts index 2a1e50e84..4801e07e9 100644 --- a/src/renderer/shared/api/xcm/__tests__/mock/xcmData.ts +++ b/src/renderer/shared/api/xcm/__tests__/mock/xcmData.ts @@ -269,6 +269,51 @@ export const XCMPALLET_TRANSFER_HUB_ASTAR = { }, }; +export const XCMPALLET_TRANSFER_PAH_MYTH = { + dest: { + V2: { + parents: '1', + interior: { + X1: { + Parachain: '3,369', + }, + }, + }, + }, + beneficiary: { + V2: { + parents: '0', + interior: { + X1: { + AccountKey20: { + network: 'Any', + key: '0x3da9ea1622ee74cf87144e3d2c7f7cce4d167d9c', + }, + }, + }, + }, + }, + assets: { + V2: [ + { + id: { + Concrete: { + parents: '1', + interior: { + X1: { + Parachain: '3,369', + }, + }, + }, + }, + fun: { + Fungible: '1327680000000000065', + }, + }, + ], + }, +}; + export const XTOKENS_ACA_DOT = { asset: { V2: { diff --git a/src/renderer/shared/api/xcm/__tests__/xcm-service.test.ts b/src/renderer/shared/api/xcm/__tests__/xcm-service.test.ts index 8eefb6340..3ab4edc71 100644 --- a/src/renderer/shared/api/xcm/__tests__/xcm-service.test.ts +++ b/src/renderer/shared/api/xcm/__tests__/xcm-service.test.ts @@ -4,6 +4,7 @@ import { CONFIG, XCMPALLET_TRANSFER_HUB_ASTAR, XCMPALLET_TRANSFER_KSM_BIFROST, + XCMPALLET_TRANSFER_PAH_MYTH, XTOKENS_ACA_DOT, XTOKENS_ACA_PARALLEL, } from './mock/xcmData'; @@ -17,12 +18,28 @@ describe('shared/api/xcm/service/xcm-service', () => { amount: '10070392000', destParachain: 2001, destAccountId: '0x7a28037947ecebe0dd86dc0e910911cb33185fd0714b37b75943f67dcf9b6e7c', + assetParachain: 0, assetGeneralIndex: '', toRelayChain: false, type: 'xcmPallet', }); }); + test('should parse xcmPallet parachain > eth parachain', () => { + const result = xcmService.parseXcmPalletExtrinsic(XCMPALLET_TRANSFER_PAH_MYTH); + + expect(result).toEqual({ + isRelayToken: false, + amount: '1327680000000000065', + assetGeneralIndex: '', + assetParachain: 3369, + destAccountId: '0x3da9ea1622ee74cf87144e3d2c7f7cce4d167d9c', + destParachain: 3369, + toRelayChain: false, + type: 'xcmPallet', + }); + }); + test('should parse xcmPallet parachain > parachain', () => { const result = xcmService.parseXcmPalletExtrinsic(XCMPALLET_TRANSFER_HUB_ASTAR); @@ -32,6 +49,7 @@ describe('shared/api/xcm/service/xcm-service', () => { destParachain: 2006, destAccountId: '0x4d081065a791aaabf8c4c9ec8ed87dce10145c86869c66e80286645730d70c44', assetGeneralIndex: '1984', + assetParachain: 0, toRelayChain: false, type: 'xcmPallet', }); diff --git a/src/renderer/shared/api/xcm/lib/xcm-utils.ts b/src/renderer/shared/api/xcm/lib/xcm-utils.ts index a5c45cafd..22c8f561c 100644 --- a/src/renderer/shared/api/xcm/lib/xcm-utils.ts +++ b/src/renderer/shared/api/xcm/lib/xcm-utils.ts @@ -245,6 +245,10 @@ function getSiblingLocation(parachainId: number, accountId?: AccountId) { } function getJunctionCols(interior: Record, path: string): T { + if (path === 'X1') { + return get(interior, path) as T; + } + return Object.values(get(interior, path)).reduce((acc, item) => { return { ...acc, ...item }; }, {}); diff --git a/src/renderer/shared/api/xcm/service/xcmService.ts b/src/renderer/shared/api/xcm/service/xcmService.ts index adcbea648..239c27a19 100644 --- a/src/renderer/shared/api/xcm/service/xcmService.ts +++ b/src/renderer/shared/api/xcm/service/xcmService.ts @@ -186,6 +186,7 @@ type ParsedPayload = { type XcmPalletPayload = ParsedPayload & { assetGeneralIndex: string; + assetParachain?: number; type: 'xcmPallet'; }; @@ -208,20 +209,25 @@ function parseXcmPalletExtrinsic(args: Omit(assetInterior, assetJunction); - parsedPayload.assetGeneralIndex = xcmUtils.toRawString(cols.GeneralIndex); + const cols = xcmUtils.getJunctionCols<{ GeneralIndex: string; Parachain: number }>(assetInterior, assetJunction); + + parsedPayload.assetGeneralIndex = xcmUtils.toRawString(cols?.GeneralIndex); + parsedPayload.assetParachain = cols?.Parachain ? Number(xcmUtils.toRawString(cols.Parachain.toString())) : 0; } return parsedPayload; @@ -255,14 +261,17 @@ function parseXTokensExtrinsic(args: Omit(destInterior, destJunction); if (cols.Parachain) { parsedPayload.destParachain = Number(xcmUtils.toRawString(cols.Parachain.toString())); parsedPayload.toRelayChain = false; } - parsedPayload.destAccountId = get(cols, 'AccountId32.id') as unknown as string; + parsedPayload.destAccountId = (get(cols, 'AccountId32.id') || get(cols, 'AccountKey20.key')) as unknown as string; } return parsedPayload; @@ -301,7 +310,10 @@ function decodeXcm(chainId: ChainId, data: XcmPalletPayload | XTokensPayload): D }, []); const assetKeyVal = filteredAssetLocations.find(([_, { multiLocation }]) => { - const xcmPalletMatch = data.type === 'xcmPallet' && multiLocation.generalIndex === data.assetGeneralIndex; + const xcmPalletMatch = + data.type === 'xcmPallet' && + (!data.assetParachain || multiLocation.parachainId === data.assetParachain) && + (multiLocation.generalIndex === data.assetGeneralIndex || data.assetGeneralIndex.length === 0); const xTokensMatch = data.type === 'xTokens' &&