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

Zeta chain integration #45

Merged
merged 5 commits into from
Oct 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
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.8",
"version": "0.3.9",
"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/zeta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 24 additions & 1 deletion src/constants/assets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BN } from "bn.js";
import { BigNumber } from "ethers";
import { PARACHAINS } from "./chains";
import { PARACHAINS, ZETA_CHAIN_TESTNET } from "./chains";

export const REF_TIME = new BN("1000000000000");
export const PROOF_SIZE = new BN("1000000000000");
Expand Down Expand Up @@ -34,6 +34,29 @@ export const defaultAssetConfig = {
decimals: 18,
},
],

[ZETA_CHAIN_TESTNET.name]: [
{
address: "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891",
symbol: "tBNB",
decimals: 18,
},
{
address: "0x13A0c5930C028511Dc02665E7285134B6d11A5f4",
symbol: "gETH",
decimals: 18,
},
{
address: "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb",
symbol: "tMATIC",
decimals: 18,
},
{
address: "0x65a45c57636f9BcCeD4fe193A602008578BcA90b",
symbol: "tBTC",
decimals: 18,
},
],
};

export const COINGECKO_ASSET_MAP: { [key: string]: string } = {
Expand Down
21 changes: 21 additions & 0 deletions src/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,26 @@ export const WESTEND = {
supportedAccounts: [WASM],
};

export const ZETA_CHAIN_TESTNET: Chain = {
name: "Zeta Chain Testnet",
rpc: {
evm: "https://zetachain-athens-evm.blockpi.network/v1/rpc/public",
},
nativeCurrency: {
name: "aZETA",
symbol: "aZETA",
decimals: 18,
},
logo: "zeta",
explorer: {
evm: {
name: "",
url: "https://zetachain-athens-3.blockscout.com/",
},
},
supportedAccounts: [EVM],
};

export const MAINNETS: Chain[] = [
POLKADOT,
KUSAMA,
Expand All @@ -547,6 +567,7 @@ export const TESTNETS: Chain[] = [
ROCOCO,
ROCOCO_ASSET_HUB,
WESTEND,
ZETA_CHAIN_TESTNET,
];

export const CHAINS = [
Expand Down
9 changes: 9 additions & 0 deletions src/pages/send/components/EvmForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ describe("EvmForm", () => {
],
},
}),
useAccountContext: () => ({
state: {
selectedAccount: {
value: {
address: "0xa0a58b72969DF1904Bf2315f2D041AD639737429",
}
},
}
}),
useThemeContext: () => ({
color: "red",
}),
Expand Down
9 changes: 6 additions & 3 deletions src/pages/send/components/EvmForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Loading, Button, ReEnterPassword } from "@src/components/common";
import Extension from "@src/Extension";
import { useToast } from "@src/hooks";
import {
useAccountContext,
useAssetContext,
useNetworkContext,
useThemeContext,
Expand Down Expand Up @@ -46,6 +47,8 @@ export const EvmForm: FC<EvmFormProps> = ({ confirmTx }) => {
formState: { errors },
} = useFormContext();

const { state: { selectedAccount } } = useAccountContext()

const { showErrorToast } = useToast();

const [fee, setFee] = useState<EVMFee>({
Expand Down Expand Up @@ -105,6 +108,7 @@ export const EvmForm: FC<EvmFormProps> = ({ confirmTx }) => {

const to = getValues("to");


if (isXcm) {
const { method, abi, contractAddress, extrinsicValues } = XCM_MAPPING[
selectedChain.name
Expand Down Expand Up @@ -161,10 +165,12 @@ export const EvmForm: FC<EvmFormProps> = ({ confirmTx }) => {
setEvmTx(contract);
} else if (isNativeAsset) {
let tx: evmTx = {
from: selectedAccount.value.address,
to: destinationAccount,
value: bnAmount,
};


const [feeData, gasLimit] = await Promise.all([
_api.getFeeData(),
_api.estimateGas(tx),
Expand Down Expand Up @@ -232,9 +238,6 @@ export const EvmForm: FC<EvmFormProps> = ({ confirmTx }) => {
setEvmTx(contract);
}
} catch (error) {
console.log('fee', {
error
})
setFee({
"gas limit": BigNumber0,
"max fee per gas": BigNumber0,
Expand Down