From 07b931c2edf003b6871114ed45d259d3dabc00ab Mon Sep 17 00:00:00 2001 From: Michael Absolon Date: Mon, 11 Nov 2024 22:07:07 +0100 Subject: [PATCH] =?UTF-8?q?feat(sdk):=20Add=20asset=20search=20by=20multi-?= =?UTF-8?q?location=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/playground/package.json | 2 +- .../src/components/CurrencySelection.tsx | 20 +- .../src/components/TransferForm.tsx | 6 +- .../playground/src/components/XcmTransfer.tsx | 7 +- .../src/hooks/useCurrencyOptions.ts | 2 +- .../src/routes/RouterTransferPage.tsx | 4 +- apps/xcm-api/package.json | 2 +- .../src/x-transfer/dto/XTransferDto.ts | 31 +- apps/xcm-api/test/app.e2e-spec.ts | 61 +- packages/sdk/e2e/xcm-papi.test.ts | 4 +- packages/sdk/e2e/xcm.test.ts | 4 +- packages/sdk/package.json | 2 +- packages/sdk/scripts/assets/addAliases.ts | 2 +- packages/sdk/scripts/assets/fetchAssets.ts | 139 +- .../sdk/scripts/assets/fetchBifrostAssets.ts | 57 - .../sdk/scripts/assets/fetchEthereumAssets.ts | 16 +- .../assets/fetchOtherAssetsRegistry.ts | 90 + .../sdk/scripts/assets/fetchXcmRegistry.ts | 33 + packages/sdk/scripts/assets/nodeToQueryMap.ts | 67 +- packages/sdk/scripts/scriptUtils.ts | 2 +- packages/sdk/src/maps/assets.json | 11738 +++++++++------- packages/sdk/src/nodes/ParachainNode.test.ts | 19 - packages/sdk/src/nodes/ParachainNode.ts | 12 +- .../src/nodes/supported/AssetHubPolkadot.ts | 22 +- packages/sdk/src/nodes/supported/Astar.ts | 2 +- packages/sdk/src/nodes/supported/Calamari.ts | 2 +- .../src/nodes/supported/ComposableFinance.ts | 2 +- packages/sdk/src/nodes/supported/Crust.ts | 2 +- .../sdk/src/nodes/supported/CrustShadow.ts | 2 +- packages/sdk/src/nodes/supported/Darwinia.ts | 2 +- packages/sdk/src/nodes/supported/Hydration.ts | 17 +- .../sdk/src/nodes/supported/InvArchTinker.ts | 2 +- packages/sdk/src/nodes/supported/Manta.ts | 2 +- packages/sdk/src/nodes/supported/Moonbeam.ts | 2 +- packages/sdk/src/nodes/supported/Moonriver.ts | 2 +- packages/sdk/src/nodes/supported/Parallel.ts | 2 +- packages/sdk/src/nodes/supported/Peaq.ts | 2 +- packages/sdk/src/nodes/supported/Picasso.ts | 2 +- packages/sdk/src/nodes/supported/Polkadex.ts | 2 +- packages/sdk/src/nodes/supported/Turing.ts | 2 +- packages/sdk/src/nodes/supported/Unique.ts | 2 +- .../xTokens/getModifiedCurrencySelection.ts | 2 +- .../sdk/src/pallets/assets/assets.test.ts | 6 +- packages/sdk/src/pallets/assets/assets.ts | 9 +- .../balance/getAssetHubMultiLocation.test.ts | 77 - .../balance/getAssetHubMultiLocation.ts | 49 - .../getBalanceForeignPolkadotXcm.test.ts | 7 - .../balance/getBalanceForeignPolkadotXcm.ts | 9 +- .../balance/getBalanceForeignXTokens.test.ts | 4 +- .../balance/getBalanceForeignXTokens.ts | 2 +- .../assets/findAssetByMultiLocation.ts | 41 + .../assets/getAssetBySymbolOrId.test.ts | 244 +- .../pallets/assets/getAssetBySymbolOrId.ts | 28 +- .../pallets/assets/getSupportedAssets.test.ts | 2 +- .../src/pallets/assets/getSupportedAssets.ts | 6 +- packages/sdk/src/pallets/assets/index.ts | 1 + .../assets/multiLocationSelectors.test.ts | 22 + .../pallets/assets/multiLocationSelectors.ts | 6 + .../ethTransfer/buildEthTransferOptions.ts | 2 +- .../xcmPallet/ethTransfer/ethTransfer.ts | 2 +- .../src/pallets/xcmPallet/transfer.test.ts | 2 +- .../sdk/src/pallets/xcmPallet/transfer.ts | 9 +- packages/sdk/src/papi/assets.ts | 1 + packages/sdk/src/pjs/assets.ts | 1 + packages/sdk/src/types/TAssets.ts | 17 +- packages/sdk/src/types/TCurrency.ts | 15 +- packages/sdk/src/types/TMultiLocation.ts | 23 - .../sdk/src/utils/assets/isForeignAsset.ts | 6 +- packages/sdk/src/utils/index.ts | 1 - .../isOverrideMultiLocationSpecifier.ts | 11 + packages/sdk/src/utils/verifyMultiLocation.ts | 9 - .../sdk/src/utils/verifyMultilocation.test.ts | 160 - packages/sdk/vitest.config.e2e.ts | 4 +- packages/xcm-analyser/src/types.ts | 2 +- pnpm-lock.yaml | 303 +- 75 files changed, 7635 insertions(+), 5839 deletions(-) delete mode 100644 packages/sdk/scripts/assets/fetchBifrostAssets.ts create mode 100644 packages/sdk/scripts/assets/fetchOtherAssetsRegistry.ts create mode 100644 packages/sdk/scripts/assets/fetchXcmRegistry.ts delete mode 100644 packages/sdk/src/pallets/assets/balance/getAssetHubMultiLocation.test.ts delete mode 100644 packages/sdk/src/pallets/assets/balance/getAssetHubMultiLocation.ts create mode 100644 packages/sdk/src/pallets/assets/findAssetByMultiLocation.ts create mode 100644 packages/sdk/src/pallets/assets/multiLocationSelectors.test.ts create mode 100644 packages/sdk/src/pallets/assets/multiLocationSelectors.ts create mode 100644 packages/sdk/src/utils/multiLocation/isOverrideMultiLocationSpecifier.ts delete mode 100644 packages/sdk/src/utils/verifyMultiLocation.ts delete mode 100644 packages/sdk/src/utils/verifyMultilocation.test.ts diff --git a/apps/playground/package.json b/apps/playground/package.json index b558df78..d868fa36 100644 --- a/apps/playground/package.json +++ b/apps/playground/package.json @@ -33,7 +33,7 @@ "@tabler/icons-react": "^3.21.0", "axios": "^1.7.7", "ethers": "^6.13.4", - "polkadot-api": "^1.6.5", + "polkadot-api": "^1.7.3", "react": "^18.3.1", "react-confetti": "^6.1.0", "react-dom": "^18.3.1", diff --git a/apps/playground/src/components/CurrencySelection.tsx b/apps/playground/src/components/CurrencySelection.tsx index 712eeaa7..f0cd6609 100644 --- a/apps/playground/src/components/CurrencySelection.tsx +++ b/apps/playground/src/components/CurrencySelection.tsx @@ -46,13 +46,25 @@ const CurrencySelection: FC = ({ form, currencyOptions }) => { {form.values.isCustomCurrency && form.values.customCurrencyType === "multilocation" && ( )} + + {form.values.isCustomCurrency && + form.values.customCurrencyType === "overridenMultilocation" && ( + + )} + {!form.values.isCustomCurrency && (