Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add assethub for rococo xcm #38

Merged
merged 1 commit into from
Aug 24, 2023
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
4 changes: 4 additions & 0 deletions README-es.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ Para agregar una nueva cadena, go to **Configuracion > General > Adminsitrar red

![add-network-5](./images/add-network-5.png)

## Probar Transferencias XCM
Puedes transferir ROC de Rococo a AssetHub. Ve a Ajustes > General y activa la opción "Mostrar redes de prueba", luego cambia a Rococo y ya podrás transferir a AssetHub:

![xcm-transfer](./images/test-xcm.png)

## Registro de cambios

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ To add a new network, go to **Settings > General > Manage networks > New network

![add-network-5](./images/add-network-5.png)

## Test XCM Transfer
You can transfer ROC from Rococo to AssetHub. Go to Settings > General and activate the "Show testnets" option, then change to Rococo, and you're able to transfer to AssetHub:

![xcm-transfer](./images/test-xcm.png)


## Change Log

See [Changelog](CHANGELOG.md) for more information.
Expand Down
Binary file added images/test-xcm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kuma-wallet",
"displayName": "Kuma Wallet",
"version": "0.3.6",
"version": "0.3.7",
"description": "Kuma a cross-chain wallet that offers seamless management and transfer of assets between EVM and WASM chains.",
"author": "Blockcoders Engineering <hello@blockcoders.io>",
"license": "MIT",
Expand Down
Binary file added public/images/assethub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions src/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ export const enum PARACHAINS {
ACALA = "Acala",
}

export const enum RELAY_CHAIN_TESTNETS {
ROCOCO = "Rococo",
}

export const enum PARACHAINS_TESTNETS {
ROCOCO_ASSET_HUB = "Asset Hub (Rococo)",
}

export const POLKADOT_PARACHAINS = {
ACALA: {
name: PARACHAINS.ACALA,
Expand All @@ -43,6 +51,13 @@ export const KUSAMA_PARACHAINS = {
},
};

export const ROCOCO_PARACHAINS = {
ASSET_HUB: {
name: PARACHAINS_TESTNETS.ROCOCO_ASSET_HUB,
id: 1000,
},
};

// MAINNETS
export const POLKADOT = {
name: "Polkadot",
Expand Down Expand Up @@ -462,6 +477,29 @@ export const ROCOCO = {
},
logo: "rococo",
supportedAccounts: [WASM],
xcm: [PARACHAINS_TESTNETS.ROCOCO_ASSET_HUB],
};

export const ROCOCO_ASSET_HUB = {
name: "Asset Hub (Rococo)",
rpc: {
wasm: "wss://rococo-asset-hub-rpc.polkadot.io",
},
addressPrefix: 2,
nativeCurrency: {
name: "Rococo",
symbol: "ROC",
decimals: 12,
},
explorer: {
wasm: {
name: "subscan",
url: "https://assethub-rococo.subscan.io/",
},
},
logo: "assethub",
supportedAccounts: [WASM],
xcm: [RELAY_CHAIN_TESTNETS.ROCOCO],
};

export const WESTEND = {
Expand Down Expand Up @@ -507,6 +545,7 @@ export const TESTNETS: Chain[] = [
SEPOLIA,
MANDALA,
ROCOCO,
ROCOCO_ASSET_HUB,
WESTEND,
];

Expand Down
9 changes: 4 additions & 5 deletions src/pages/balance/components/ConfirmChainChangeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { CREATE_ACCOUNT } from "@src/routes/paths";
import { Chain } from "@src/storage/entities/Chains";
import { useThemeContext } from "@src/providers";
import { Button } from "@src/components/common";

interface ConfirmChainChangeModalProps {
Expand Down Expand Up @@ -91,10 +90,10 @@ export const ConfirmChainChangeModal: FC<ConfirmChainChangeModalProps> = ({
<p className="text-sm">
{needToCreateAccount
? t("chain_selector.create_or_import_warning", {
supported_type: tCommon(
`${chainType?.toLowerCase()}_type`
),
})
supported_type: tCommon(
`${chainType?.toLowerCase()}_type`
),
})
: t("chain_selector.network_change_warning")}
</p>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/xcm/assets.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { PARACHAINS } from "@src/constants/chains";
import { PARACHAINS, PARACHAINS_TESTNETS } from "@src/constants/chains";
import {
MOONBEAM_ASSETS_MAPPING,
ASTAR_ASSETS_MAPPING,
ACALA_ASSETS_MAPPING,
SHIDEN_ASSETS_MAPPING,
ROCOCO_ASSET_HUB_ASSETS_MAPPING,
} from "./chains";

interface IXCM_ASSETS_MAPPING {
Expand All @@ -18,4 +19,7 @@ export const XCM_ASSETS_MAPPING: IXCM_ASSETS_MAPPING = {
[PARACHAINS.ACALA]: ACALA_ASSETS_MAPPING,
[PARACHAINS.MOONRIVER]: MOONBEAM_ASSETS_MAPPING,
[PARACHAINS.SHIDEN]: SHIDEN_ASSETS_MAPPING,

// testnest
[PARACHAINS_TESTNETS.ROCOCO_ASSET_HUB]: ROCOCO_ASSET_HUB_ASSETS_MAPPING,
};
4 changes: 4 additions & 0 deletions src/xcm/chains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ export * from "./acala";
export * from "./astar";
export * from "./shiden";
export * from "./moonriver";

// testnests
export * from "./rococo";
export * from "./rococo-asset-hub";
35 changes: 35 additions & 0 deletions src/xcm/chains/rococo-asset-hub.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { RELAY_CHAIN_TESTNETS } from "@src/constants/chains";
import { Map } from "../interfaces";
import { XCM, getAssets, getBeneficiary, getDest } from "../utils";

export const ROCOCO_ASSET_HUB_EXTRINSICS: { [key: string]: Map } = {
[RELAY_CHAIN_TESTNETS.ROCOCO]: ({ address, amount }) => ({
pallet: XCM.pallets.POLKADOT_XCM.NAME,
method: XCM.pallets.POLKADOT_XCM.methods.LIMITED_TELEPORT_ASSETS,
extrinsicValues: {
dest: getDest({
parents: 1,
version: "V3",
}),
beneficiary: getBeneficiary({
address,
version: "V3",
}),
assets: getAssets({
fungible: amount,
parents: 1,
version: "V3",
}),
feeAssetItem: 0,
destWeightLimit: "Unlimited",
},
}),
};

enum ASSET_HUB_ASSETS {
ROC = "ROC",
}

export const ROCOCO_ASSET_HUB_ASSETS_MAPPING = {
[RELAY_CHAIN_TESTNETS.ROCOCO]: [ASSET_HUB_ASSETS.ROC],
};
36 changes: 36 additions & 0 deletions src/xcm/chains/rococo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { PARACHAINS_TESTNETS, ROCOCO_PARACHAINS } from "@src/constants/chains";
import { Map } from "../interfaces";
import {
XCM,
XCM_DEFAULT_VERSIONS,
getAssets,
getBeneficiary,
getDest,
} from "../utils";

export const ROCOCO_EXTRINSICS: { [key: string]: Map } = {
[PARACHAINS_TESTNETS.ROCOCO_ASSET_HUB]: ({
address,
amount,
xcmPalletVersion,
}) => ({
pallet: XCM.pallets.XCM_PALLET.NAME,
method: XCM.pallets.XCM_PALLET.methods.LIMITED_TELEPORT_ASSETS,
extrinsicValues: {
dest: getDest({
parachainId: ROCOCO_PARACHAINS.ASSET_HUB.id,
version: XCM_DEFAULT_VERSIONS[xcmPalletVersion],
}),
beneficiary: getBeneficiary({
address,
version: XCM_DEFAULT_VERSIONS[xcmPalletVersion],
}),
assets: getAssets({
fungible: amount,
version: XCM_DEFAULT_VERSIONS[xcmPalletVersion],
}),
feeAssetItem: 0,
destWeightLimit: "Unlimited",
},
}),
};
19 changes: 12 additions & 7 deletions src/xcm/extrinsics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { PARACHAINS, RELAY_CHAINS } from "@src/constants/chains";
import {
PARACHAINS,
PARACHAINS_TESTNETS,
RELAY_CHAINS,
RELAY_CHAIN_TESTNETS,
} from "@src/constants/chains";
import { IXCM_MAPPING } from "./interfaces";
import {
POLKADOT_EXTRINSICS,
Expand All @@ -8,20 +13,20 @@ import {
ASTAR_EXTRINSICS,
SHIDEN_EXTRINSICS,
MOONRIVER_EXTRINSICS,
ROCOCO_EXTRINSICS,
ROCOCO_ASSET_HUB_EXTRINSICS,
} from "./chains";

export const XCM_MAPPING: IXCM_MAPPING = {
[RELAY_CHAINS.POLKADOT]: POLKADOT_EXTRINSICS,

[RELAY_CHAINS.KUSAMA]: KUSAMA_EXTRINSICS,

[PARACHAINS.MOONBEAM]: MOONBEAM_EXTRINSICS,

[PARACHAINS.ACALA]: ACALA_EXTRINSICS,

[PARACHAINS.ASTAR]: ASTAR_EXTRINSICS,

[PARACHAINS.MOONRIVER]: MOONRIVER_EXTRINSICS,

[PARACHAINS.SHIDEN]: SHIDEN_EXTRINSICS,

// testnest
[RELAY_CHAIN_TESTNETS.ROCOCO]: ROCOCO_EXTRINSICS,
[PARACHAINS_TESTNETS.ROCOCO_ASSET_HUB]: ROCOCO_ASSET_HUB_EXTRINSICS,
};
2 changes: 2 additions & 0 deletions src/xcm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const XCM = {
methods: {
RESERVE_TRANSFER_ASSETS: "reserveTransferAssets",
LIMITED_RESERVE_TRANSFER_ASSETS: "limitedReserveTransferAssets",
LIMITED_TELEPORT_ASSETS: "limitedTeleportAssets",
},
},
POLKADOT_XCM: {
Expand All @@ -134,6 +135,7 @@ export const XCM = {
RESERVE_WITHDRAW_ASSETS: "reserveWithdrawAssets",
RESERVE_TRANSFER_ASSETS: "reserveTransferAssets",
LIMITED_RESERVE_TRANSFER_ASSETS: "limitedReserveTransferAssets",
LIMITED_TELEPORT_ASSETS: "limitedTeleportAssets",
},
},
X_TOKENS: {
Expand Down