Skip to content
Draft
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
22 changes: 17 additions & 5 deletions app/bridge/components/gravityConfirmationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,24 @@ const GravityConfirmationModal = ({

async function handleConfirm() {
try {
await switchNetwork({ chainId: GRAVITY_BRIGDE_EVM.chainId });
const network = getNetwork();
if (!network.chain || network.chain.id !== GRAVITY_BRIGDE_EVM.chainId) {
throw new Error(TX_SIGN_ERRORS.SWITCH_CHAIN_ERROR());
}
if (!window.ethereum) throw new Error("No ethereum provider found");

await window.ethereum.request({
method: "wallet_addEthereumChain",
params: [
{
chainId: `0x${GRAVITY_BRIGDE_EVM.chainId.toString(16)}`,
chainName: GRAVITY_BRIGDE_EVM.name,
rpcUrls: [GRAVITY_BRIGDE_EVM.rpcUrl],
iconUrls: [GRAVITY_BRIGDE_EVM.icon],
nativeCurrency: {
name: GRAVITY_BRIGDE_EVM.nativeCurrency.name,
symbol: GRAVITY_BRIGDE_EVM.nativeCurrency.symbol,
decimals: GRAVITY_BRIGDE_EVM.nativeCurrency.decimals,
},
},
],
});
setAddChainError(null);
onConfirm();
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion config/networks/evm/gravityEVM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const GRAVITY_BRIGDE_EVM: EVMNetwork = {
icon: "/icons/grav.svg",
name: "Gravity Bridge",
isTestChain: false,
rpcUrl: "https://info.gravitychain.io:8545",
rpcUrl: "https://gravity.plexnode.wtf",
nativeCurrency: {
name: "Graviton",
baseName: "ugraviton",
Expand Down
12 changes: 9 additions & 3 deletions transactions/signTx/cosmosEIP/signCosmosEIP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ async function signAndBroadcastCosmosTransaction(
if (!context.sender.pubkey) {
// create a public key for the user IFF EIP712 Canto is used (since through metamask)
try {
const signature = await signMessage({
message:"Welcome to Canto! \n\nPlease sign this message to generate your Canto account.",
const signature = await window.ethereum.request({
method: "personal_sign",
params: [context.ethAddress, "generate_pubkey"],
});
context.sender.pubkey = signatureToPubkey(
signature,
Expand Down Expand Up @@ -152,7 +153,12 @@ async function signAndBroadcastCosmosTransaction(
);

// get signature from metamask
const signature = await signTypedData(eipToSign as SignTypedDataArgs);

const signature = await window.ethereum.request({
method: "eth_signTypedData_v4",
params: [context.ethAddress, JSON.stringify(eipToSign)],
});

const signedTx = createTxRawEIP712(
cosmosPayload.legacyAmino.body,
cosmosPayload.legacyAmino.authInfo,
Expand Down