Skip to content

Commit

Permalink
fix(sdk): Fix Moonbeam 'xc' prefix handling 🔧
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldev5 authored and dudo50 committed Nov 1, 2024
1 parent 5c2f232 commit a986bf8
Show file tree
Hide file tree
Showing 17 changed files with 508 additions and 160 deletions.
1 change: 0 additions & 1 deletion apps/playground/src/components/XcmTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ const XcmTransfer = () => {
.from(from)
.to(to)
.currency(determineCurrency(formValues))
.feeAsset("0")
.amount(amount)
.address(address)
.build();
Expand Down
17 changes: 1 addition & 16 deletions packages/sdk/scripts/assets/fetchAssets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-explicit-any */
Expand Down Expand Up @@ -265,19 +263,6 @@ const fetchAssetsType2 = async (api: ApiPromise, query: string): Promise<Partial
return { nativeAssets, otherAssets }
}

const removePrefix = (inputString: string, prefix: string) => {
if (inputString.startsWith(prefix)) {
return inputString.substring(prefix.length)
}
return inputString
}

const transformOtherAssets = (otherAssets: any, node: TNodePolkadotKusama) => {
return node === 'Moonbeam' || node === 'Moonriver'
? otherAssets.map((asset: any) => ({ ...asset, symbol: removePrefix(asset.symbol, 'xc') }))
: otherAssets
}

const fetchNativeAsset = async (api: ApiPromise): Promise<string> => {
const propertiesRes = await api.rpc.system.properties()
const json = propertiesRes.toHuman()
Expand Down Expand Up @@ -420,7 +405,7 @@ const fetchNodeAssets = async (

return {
nativeAssets,
otherAssets: transformOtherAssets(otherAssets, node),
otherAssets,
nativeAssetSymbol
}
}
Expand Down
Loading

0 comments on commit a986bf8

Please sign in to comment.