refactor: Elrond rebranding to MultiversX (#148)
This commit is contained in:
parent
5d579166cb
commit
a60069941f
@ -11,8 +11,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@celo/wallet-base": "^3.0.1",
|
"@celo/wallet-base": "^3.0.1",
|
||||||
"@elrondnetwork/erdjs": "11.1.1",
|
"@multiversx/sdk-core": "11.5.0",
|
||||||
"@elrondnetwork/erdjs-walletcore": "2.1.0",
|
"@multiversx/sdk-wallet": "4.0.0",
|
||||||
"@ethereumjs/tx": "^3.5.0",
|
"@ethereumjs/tx": "^3.5.0",
|
||||||
"@polkadot/util-crypto": "^10.1.2",
|
"@polkadot/util-crypto": "^10.1.2",
|
||||||
"@solana/web3.js": "^1.36.0",
|
"@solana/web3.js": "^1.36.0",
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 8.1 KiB |
4
dapps/react-dapp-v2/public/assets/multiversx_logo.svg
Normal file
4
dapps/react-dapp-v2/public/assets/multiversx_logo.svg
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<svg width="300" height="300" viewBox="0 0 300 300" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect width="300" height="300" rx="150" fill="black"/>
|
||||||
|
<path d="M158.482 149.928L228.714 112.529L216.919 90L152.575 115.854C150.923 116.523 149.077 116.523 147.425 115.854L83.0814 90L71.25 112.602L141.482 150L71.25 187.398L83.0814 210L147.425 183.948C149.077 183.279 150.923 183.279 152.575 183.948L216.919 209.874L228.75 187.272L158.482 149.928Z" fill="#23F7DD"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 472 B |
@ -1,53 +0,0 @@
|
|||||||
import { NamespaceMetadata, ChainMetadata, ChainsMap } from "../helpers";
|
|
||||||
|
|
||||||
export const ElrondChainData: ChainsMap = {
|
|
||||||
"1": {
|
|
||||||
id: "elrond:1",
|
|
||||||
name: "Elrond Mainnet",
|
|
||||||
rpc: ["https://api.elrond.com"],
|
|
||||||
slip44: 508,
|
|
||||||
testnet: false,
|
|
||||||
},
|
|
||||||
D: {
|
|
||||||
id: "elrond:D",
|
|
||||||
name: "Elrond Devnet",
|
|
||||||
rpc: ["https://devnet-api.elrond.com"],
|
|
||||||
slip44: 508,
|
|
||||||
testnet: true,
|
|
||||||
},
|
|
||||||
// Keep only one Test Chain visible
|
|
||||||
// T: {
|
|
||||||
// id: "elrond:T",
|
|
||||||
// name: "Elrond Testnet",
|
|
||||||
// rpc: ["https://testnet-api.elrond.com"],
|
|
||||||
// slip44: 508,
|
|
||||||
// testnet: true,
|
|
||||||
// },
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ElrondMetadata: NamespaceMetadata = {
|
|
||||||
// Elrond Mainnet
|
|
||||||
"1": {
|
|
||||||
logo: "/assets/elrond_logo.png",
|
|
||||||
rgb: "0, 0, 0",
|
|
||||||
},
|
|
||||||
// Elrond Testnet
|
|
||||||
T: {
|
|
||||||
logo: "/assets/elrond_logo.png",
|
|
||||||
rgb: "0, 0, 0",
|
|
||||||
},
|
|
||||||
// Elrond Devnet
|
|
||||||
D: {
|
|
||||||
logo: "/assets/elrond_logo.png",
|
|
||||||
rgb: "0, 0, 0",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export function getChainMetadata(chainId: string): ChainMetadata {
|
|
||||||
const reference = chainId.split(":")[1];
|
|
||||||
const metadata = ElrondMetadata[reference];
|
|
||||||
if (typeof metadata === "undefined") {
|
|
||||||
throw new Error(`No chain metadata found for chainId: ${chainId}`);
|
|
||||||
}
|
|
||||||
return metadata;
|
|
||||||
}
|
|
@ -5,7 +5,7 @@ import * as cosmos from "./cosmos";
|
|||||||
import * as polkadot from "./polkadot";
|
import * as polkadot from "./polkadot";
|
||||||
import * as solana from "./solana";
|
import * as solana from "./solana";
|
||||||
import * as near from "./near";
|
import * as near from "./near";
|
||||||
import * as elrond from "./elrond";
|
import * as multiversx from "./multiversx";
|
||||||
import * as tron from "./tron";
|
import * as tron from "./tron";
|
||||||
import * as tezos from "./tezos";
|
import * as tezos from "./tezos";
|
||||||
|
|
||||||
@ -24,8 +24,8 @@ export function getChainMetadata(chainId: string): ChainMetadata {
|
|||||||
return solana.getChainMetadata(chainId);
|
return solana.getChainMetadata(chainId);
|
||||||
case "near":
|
case "near":
|
||||||
return near.getChainMetadata(chainId);
|
return near.getChainMetadata(chainId);
|
||||||
case "elrond":
|
case "mvx":
|
||||||
return elrond.getChainMetadata(chainId);
|
return multiversx.getChainMetadata(chainId);
|
||||||
case "tron":
|
case "tron":
|
||||||
return tron.getChainMetadata(chainId);
|
return tron.getChainMetadata(chainId);
|
||||||
case "tezos":
|
case "tezos":
|
||||||
|
53
dapps/react-dapp-v2/src/chains/multiversx.ts
Normal file
53
dapps/react-dapp-v2/src/chains/multiversx.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { NamespaceMetadata, ChainMetadata, ChainsMap } from "../helpers";
|
||||||
|
|
||||||
|
export const MultiversxChainData: ChainsMap = {
|
||||||
|
"1": {
|
||||||
|
id: "mvx:1",
|
||||||
|
name: "MultiversX Mainnet",
|
||||||
|
rpc: ["https://api.multiversx.com"],
|
||||||
|
slip44: 508,
|
||||||
|
testnet: false,
|
||||||
|
},
|
||||||
|
D: {
|
||||||
|
id: "mvx:D",
|
||||||
|
name: "MultiversX Devnet",
|
||||||
|
rpc: ["https://devnet-api.multiversx.com"],
|
||||||
|
slip44: 508,
|
||||||
|
testnet: true,
|
||||||
|
},
|
||||||
|
// Keep only one Test Chain visible
|
||||||
|
// T: {
|
||||||
|
// id: "mvx:T",
|
||||||
|
// name: "MultiversX Testnet",
|
||||||
|
// rpc: ["https://testnet-api.multiversx.com"],
|
||||||
|
// slip44: 508,
|
||||||
|
// testnet: true,
|
||||||
|
// },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MultiversxMetadata: NamespaceMetadata = {
|
||||||
|
// MultiversX Mainnet
|
||||||
|
"1": {
|
||||||
|
logo: "/assets/multiversx_logo.svg",
|
||||||
|
rgb: "0, 0, 0",
|
||||||
|
},
|
||||||
|
// MultiversX Testnet
|
||||||
|
T: {
|
||||||
|
logo: "/assets/multiversx_logo.svg",
|
||||||
|
rgb: "0, 0, 0",
|
||||||
|
},
|
||||||
|
// MultiversX Devnet
|
||||||
|
D: {
|
||||||
|
logo: "/assets/multiversx_logo.svg",
|
||||||
|
rgb: "0, 0, 0",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getChainMetadata(chainId: string): ChainMetadata {
|
||||||
|
const reference = chainId.split(":")[1];
|
||||||
|
const metadata = MultiversxMetadata[reference];
|
||||||
|
if (typeof metadata === "undefined") {
|
||||||
|
throw new Error(`No chain metadata found for chainId: ${chainId}`);
|
||||||
|
}
|
||||||
|
return metadata;
|
||||||
|
}
|
@ -12,7 +12,7 @@ export const DEFAULT_MAIN_CHAINS = [
|
|||||||
"cosmos:cosmoshub-4",
|
"cosmos:cosmoshub-4",
|
||||||
"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",
|
"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",
|
||||||
"polkadot:91b171bb158e2d3848fa23a9f1c25182",
|
"polkadot:91b171bb158e2d3848fa23a9f1c25182",
|
||||||
"elrond:1",
|
"mvx:1",
|
||||||
"tron:0x2b6653dc",
|
"tron:0x2b6653dc",
|
||||||
"tezos:mainnet",
|
"tezos:mainnet",
|
||||||
];
|
];
|
||||||
@ -27,7 +27,7 @@ export const DEFAULT_TEST_CHAINS = [
|
|||||||
"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K",
|
"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K",
|
||||||
"polkadot:e143f23803ac50e8f6f8e62695d1ce9e",
|
"polkadot:e143f23803ac50e8f6f8e62695d1ce9e",
|
||||||
"near:testnet",
|
"near:testnet",
|
||||||
"elrond:D",
|
"mvx:D",
|
||||||
"tron:0xcd8690dc",
|
"tron:0xcd8690dc",
|
||||||
"tezos:testnet",
|
"tezos:testnet",
|
||||||
];
|
];
|
||||||
@ -106,16 +106,17 @@ export enum DEFAULT_NEAR_METHODS {
|
|||||||
export enum DEFAULT_NEAR_EVENTS {}
|
export enum DEFAULT_NEAR_EVENTS {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ELROND
|
* MULTIVERSX
|
||||||
*/
|
*/
|
||||||
export enum DEFAULT_ELROND_METHODS {
|
export enum DEFAULT_MULTIVERSX_METHODS {
|
||||||
ELROND_SIGN_TRANSACTION = "erd_signTransaction",
|
MULTIVERSX_SIGN_TRANSACTION = "mvx_signTransaction",
|
||||||
ELROND_SIGN_TRANSACTIONS = "erd_signTransactions",
|
MULTIVERSX_SIGN_TRANSACTIONS = "mvx_signTransactions",
|
||||||
ELROND_SIGN_MESSAGE = "erd_signMessage",
|
MULTIVERSX_SIGN_MESSAGE = "mvx_signMessage",
|
||||||
ELROND_SIGN_LOGIN_TOKEN = "erd_signLoginToken",
|
MULTIVERSX_SIGN_LOGIN_TOKEN = "mvx_signLoginToken",
|
||||||
|
MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN = "mvx_signNativeAuthToken",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DEFAULT_ELROND_EVENTS {}
|
export enum DEFAULT_MULTIVERSX_EVENTS {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TRON
|
* TRON
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
} from "react";
|
} from "react";
|
||||||
import { SolanaChainData } from "../chains/solana";
|
import { SolanaChainData } from "../chains/solana";
|
||||||
import { PolkadotChainData } from "../chains/polkadot";
|
import { PolkadotChainData } from "../chains/polkadot";
|
||||||
import { ElrondChainData } from "../chains/elrond";
|
import { MultiversxChainData } from "../chains/multiversx";
|
||||||
import { TronChainData } from "../chains/tron";
|
import { TronChainData } from "../chains/tron";
|
||||||
|
|
||||||
import { ChainNamespaces, ChainsMap, getAllChainNamespaces } from "../helpers";
|
import { ChainNamespaces, ChainsMap, getAllChainNamespaces } from "../helpers";
|
||||||
@ -54,8 +54,8 @@ export function ChainDataContextProvider({
|
|||||||
case "near":
|
case "near":
|
||||||
chains = NearChainData;
|
chains = NearChainData;
|
||||||
break;
|
break;
|
||||||
case "elrond":
|
case "mvx":
|
||||||
chains = ElrondChainData;
|
chains = MultiversxChainData;
|
||||||
break;
|
break;
|
||||||
case "tron":
|
case "tron":
|
||||||
chains = TronChainData;
|
chains = TronChainData;
|
||||||
|
@ -35,7 +35,7 @@ import {
|
|||||||
DEFAULT_SOLANA_METHODS,
|
DEFAULT_SOLANA_METHODS,
|
||||||
DEFAULT_POLKADOT_METHODS,
|
DEFAULT_POLKADOT_METHODS,
|
||||||
DEFAULT_NEAR_METHODS,
|
DEFAULT_NEAR_METHODS,
|
||||||
DEFAULT_ELROND_METHODS,
|
DEFAULT_MULTIVERSX_METHODS,
|
||||||
DEFAULT_TRON_METHODS,
|
DEFAULT_TRON_METHODS,
|
||||||
DEFAULT_TEZOS_METHODS,
|
DEFAULT_TEZOS_METHODS,
|
||||||
} from "../constants";
|
} from "../constants";
|
||||||
@ -44,16 +44,12 @@ import { rpcProvidersByChainId } from "../../src/helpers/api";
|
|||||||
import { signatureVerify, cryptoWaitReady } from "@polkadot/util-crypto";
|
import { signatureVerify, cryptoWaitReady } from "@polkadot/util-crypto";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Transaction as ElrondTransaction,
|
Transaction as MultiversxTransaction,
|
||||||
TransactionPayload,
|
TransactionPayload,
|
||||||
Address,
|
Address,
|
||||||
SignableMessage,
|
SignableMessage,
|
||||||
ISignature,
|
} from "@multiversx/sdk-core";
|
||||||
} from "@elrondnetwork/erdjs";
|
import { UserVerifier } from "@multiversx/sdk-wallet/out/userVerifier";
|
||||||
|
|
||||||
import { UserVerifier } from "@elrondnetwork/erdjs-walletcore/out/userVerifier";
|
|
||||||
import { Signature } from "@elrondnetwork/erdjs-walletcore/out/signature";
|
|
||||||
import { IVerifiable } from "@elrondnetwork/erdjs-walletcore/out/interface";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types
|
* Types
|
||||||
@ -92,7 +88,7 @@ interface IContext {
|
|||||||
testSignAndSendTransaction: TRpcRequestCallback;
|
testSignAndSendTransaction: TRpcRequestCallback;
|
||||||
testSignAndSendTransactions: TRpcRequestCallback;
|
testSignAndSendTransactions: TRpcRequestCallback;
|
||||||
};
|
};
|
||||||
elrondRpc: {
|
multiversxRpc: {
|
||||||
testSignMessage: TRpcRequestCallback;
|
testSignMessage: TRpcRequestCallback;
|
||||||
testSignTransaction: TRpcRequestCallback;
|
testSignTransaction: TRpcRequestCallback;
|
||||||
testSignTransactions: TRpcRequestCallback;
|
testSignTransactions: TRpcRequestCallback;
|
||||||
@ -881,9 +877,9 @@ export function JsonRpcContextProvider({
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
// -------- ELROND RPC METHODS --------
|
// -------- MULTIVERSX RPC METHODS --------
|
||||||
|
|
||||||
const elrondRpc = {
|
const multiversxRpc = {
|
||||||
testSignTransaction: _createJsonRpcRequestHandler(
|
testSignTransaction: _createJsonRpcRequestHandler(
|
||||||
async (
|
async (
|
||||||
chainId: string,
|
chainId: string,
|
||||||
@ -895,7 +891,7 @@ export function JsonRpcContextProvider({
|
|||||||
const verifier = UserVerifier.fromAddress(userAddress);
|
const verifier = UserVerifier.fromAddress(userAddress);
|
||||||
const transactionPayload = new TransactionPayload("testdata");
|
const transactionPayload = new TransactionPayload("testdata");
|
||||||
|
|
||||||
const testTransaction = new ElrondTransaction({
|
const testTransaction = new MultiversxTransaction({
|
||||||
nonce: 1,
|
nonce: 1,
|
||||||
value: "10000000000000000000",
|
value: "10000000000000000000",
|
||||||
receiver: Address.fromBech32(address),
|
receiver: Address.fromBech32(address),
|
||||||
@ -912,22 +908,20 @@ export function JsonRpcContextProvider({
|
|||||||
chainId,
|
chainId,
|
||||||
topic: session!.topic,
|
topic: session!.topic,
|
||||||
request: {
|
request: {
|
||||||
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTION,
|
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTION,
|
||||||
params: {
|
params: {
|
||||||
transaction,
|
transaction,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
testTransaction.applySignature(
|
const valid = verifier.verify(
|
||||||
new Signature(result.signature),
|
testTransaction.serializeForSigning(Address.fromBech32(address)),
|
||||||
userAddress
|
result.signature
|
||||||
);
|
);
|
||||||
|
|
||||||
const valid = verifier.verify(testTransaction as IVerifiable);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTION,
|
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTION,
|
||||||
address,
|
address,
|
||||||
valid,
|
valid,
|
||||||
result: result.signature.toString(),
|
result: result.signature.toString(),
|
||||||
@ -948,7 +942,7 @@ export function JsonRpcContextProvider({
|
|||||||
const verifier = UserVerifier.fromAddress(userAddress);
|
const verifier = UserVerifier.fromAddress(userAddress);
|
||||||
const testTransactionPayload = new TransactionPayload("testdata");
|
const testTransactionPayload = new TransactionPayload("testdata");
|
||||||
|
|
||||||
const testTransaction = new ElrondTransaction({
|
const testTransaction = new MultiversxTransaction({
|
||||||
nonce: 1,
|
nonce: 1,
|
||||||
value: "10000000000000000000",
|
value: "10000000000000000000",
|
||||||
receiver: Address.fromBech32(address),
|
receiver: Address.fromBech32(address),
|
||||||
@ -960,7 +954,7 @@ export function JsonRpcContextProvider({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// no data for this Transaction
|
// no data for this Transaction
|
||||||
const testTransaction2 = new ElrondTransaction({
|
const testTransaction2 = new MultiversxTransaction({
|
||||||
nonce: 2,
|
nonce: 2,
|
||||||
value: "20000000000000000000",
|
value: "20000000000000000000",
|
||||||
receiver: Address.fromBech32(address),
|
receiver: Address.fromBech32(address),
|
||||||
@ -971,7 +965,7 @@ export function JsonRpcContextProvider({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const testTransaction3Payload = new TransactionPayload("third");
|
const testTransaction3Payload = new TransactionPayload("third");
|
||||||
const testTransaction3 = new ElrondTransaction({
|
const testTransaction3 = new MultiversxTransaction({
|
||||||
nonce: 3,
|
nonce: 3,
|
||||||
value: "300000000000000000",
|
value: "300000000000000000",
|
||||||
receiver: Address.fromBech32(address),
|
receiver: Address.fromBech32(address),
|
||||||
@ -995,7 +989,7 @@ export function JsonRpcContextProvider({
|
|||||||
chainId,
|
chainId,
|
||||||
topic: session!.topic,
|
topic: session!.topic,
|
||||||
request: {
|
request: {
|
||||||
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTIONS,
|
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTIONS,
|
||||||
params: {
|
params: {
|
||||||
transactions,
|
transactions,
|
||||||
},
|
},
|
||||||
@ -1007,12 +1001,13 @@ export function JsonRpcContextProvider({
|
|||||||
testTransaction2,
|
testTransaction2,
|
||||||
testTransaction3,
|
testTransaction3,
|
||||||
].reduce((acc, current, index) => {
|
].reduce((acc, current, index) => {
|
||||||
current.applySignature(
|
return (
|
||||||
new Signature(result.signatures[index].signature),
|
acc &&
|
||||||
userAddress
|
verifier.verify(
|
||||||
|
current.serializeForSigning(Address.fromBech32(address)),
|
||||||
|
result.signatures[index].signature
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return acc && verifier.verify(current as IVerifiable);
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
const resultSignatures = result.signatures.map(
|
const resultSignatures = result.signatures.map(
|
||||||
@ -1020,7 +1015,7 @@ export function JsonRpcContextProvider({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTIONS,
|
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTIONS,
|
||||||
address,
|
address,
|
||||||
valid,
|
valid,
|
||||||
result: resultSignatures.join(", "),
|
result: resultSignatures.join(", "),
|
||||||
@ -1048,7 +1043,7 @@ export function JsonRpcContextProvider({
|
|||||||
chainId,
|
chainId,
|
||||||
topic: session!.topic,
|
topic: session!.topic,
|
||||||
request: {
|
request: {
|
||||||
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_MESSAGE,
|
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_MESSAGE,
|
||||||
params: {
|
params: {
|
||||||
address,
|
address,
|
||||||
message: testMessage.message.toString(),
|
message: testMessage.message.toString(),
|
||||||
@ -1056,12 +1051,14 @@ export function JsonRpcContextProvider({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
testMessage.applySignature(new Signature(result.signature));
|
|
||||||
|
|
||||||
const valid = verifier.verify(testMessage);
|
const valid = verifier.verify(
|
||||||
|
testMessage.serializeForSigning(),
|
||||||
|
result.signature
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_MESSAGE,
|
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_MESSAGE,
|
||||||
address,
|
address,
|
||||||
valid,
|
valid,
|
||||||
result: result.signature.toString(),
|
result: result.signature.toString(),
|
||||||
@ -1274,7 +1271,7 @@ export function JsonRpcContextProvider({
|
|||||||
solanaRpc,
|
solanaRpc,
|
||||||
polkadotRpc,
|
polkadotRpc,
|
||||||
nearRpc,
|
nearRpc,
|
||||||
elrondRpc,
|
multiversxRpc,
|
||||||
tronRpc,
|
tronRpc,
|
||||||
tezosRpc,
|
tezosRpc,
|
||||||
rpcResult: result,
|
rpcResult: result,
|
||||||
|
@ -10,8 +10,8 @@ import {
|
|||||||
DEFAULT_POLKADOT_METHODS,
|
DEFAULT_POLKADOT_METHODS,
|
||||||
DEFAULT_NEAR_METHODS,
|
DEFAULT_NEAR_METHODS,
|
||||||
DEFAULT_NEAR_EVENTS,
|
DEFAULT_NEAR_EVENTS,
|
||||||
DEFAULT_ELROND_EVENTS,
|
DEFAULT_MULTIVERSX_EVENTS,
|
||||||
DEFAULT_ELROND_METHODS,
|
DEFAULT_MULTIVERSX_METHODS,
|
||||||
DEFAULT_TRON_METHODS,
|
DEFAULT_TRON_METHODS,
|
||||||
DEFAULT_TRON_EVENTS,
|
DEFAULT_TRON_EVENTS,
|
||||||
DEFAULT_TEZOS_METHODS,
|
DEFAULT_TEZOS_METHODS,
|
||||||
@ -42,8 +42,8 @@ export const getSupportedMethodsByNamespace = (namespace: string) => {
|
|||||||
return Object.values(DEFAULT_POLKADOT_METHODS);
|
return Object.values(DEFAULT_POLKADOT_METHODS);
|
||||||
case "near":
|
case "near":
|
||||||
return Object.values(DEFAULT_NEAR_METHODS);
|
return Object.values(DEFAULT_NEAR_METHODS);
|
||||||
case "elrond":
|
case "mvx":
|
||||||
return Object.values(DEFAULT_ELROND_METHODS);
|
return Object.values(DEFAULT_MULTIVERSX_METHODS);
|
||||||
case "tron":
|
case "tron":
|
||||||
return Object.values(DEFAULT_TRON_METHODS);
|
return Object.values(DEFAULT_TRON_METHODS);
|
||||||
case "tezos":
|
case "tezos":
|
||||||
@ -65,8 +65,8 @@ export const getSupportedEventsByNamespace = (namespace: string) => {
|
|||||||
return Object.values(DEFAULT_POLKADOT_EVENTS);
|
return Object.values(DEFAULT_POLKADOT_EVENTS);
|
||||||
case "near":
|
case "near":
|
||||||
return Object.values(DEFAULT_NEAR_EVENTS);
|
return Object.values(DEFAULT_NEAR_EVENTS);
|
||||||
case "elrond":
|
case "mvx":
|
||||||
return Object.values(DEFAULT_ELROND_EVENTS);
|
return Object.values(DEFAULT_MULTIVERSX_EVENTS);
|
||||||
case "tron":
|
case "tron":
|
||||||
return Object.values(DEFAULT_TRON_EVENTS);
|
return Object.values(DEFAULT_TRON_EVENTS);
|
||||||
case "tezos":
|
case "tezos":
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
DEFAULT_MAIN_CHAINS,
|
DEFAULT_MAIN_CHAINS,
|
||||||
DEFAULT_SOLANA_METHODS,
|
DEFAULT_SOLANA_METHODS,
|
||||||
DEFAULT_POLKADOT_METHODS,
|
DEFAULT_POLKADOT_METHODS,
|
||||||
DEFAULT_ELROND_METHODS,
|
DEFAULT_MULTIVERSX_METHODS,
|
||||||
DEFAULT_TEST_CHAINS,
|
DEFAULT_TEST_CHAINS,
|
||||||
DEFAULT_NEAR_METHODS,
|
DEFAULT_NEAR_METHODS,
|
||||||
DEFAULT_TRON_METHODS,
|
DEFAULT_TRON_METHODS,
|
||||||
@ -74,7 +74,7 @@ const Home: NextPage = () => {
|
|||||||
solanaRpc,
|
solanaRpc,
|
||||||
polkadotRpc,
|
polkadotRpc,
|
||||||
nearRpc,
|
nearRpc,
|
||||||
elrondRpc,
|
multiversxRpc,
|
||||||
tronRpc,
|
tronRpc,
|
||||||
tezosRpc,
|
tezosRpc,
|
||||||
isRpcRequestPending,
|
isRpcRequestPending,
|
||||||
@ -258,30 +258,30 @@ const Home: NextPage = () => {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getElrondActions = (): AccountAction[] => {
|
const getMultiversxActions = (): AccountAction[] => {
|
||||||
const onSignTransaction = async (chainId: string, address: string) => {
|
const onSignTransaction = async (chainId: string, address: string) => {
|
||||||
openRequestModal();
|
openRequestModal();
|
||||||
await elrondRpc.testSignTransaction(chainId, address);
|
await multiversxRpc.testSignTransaction(chainId, address);
|
||||||
};
|
};
|
||||||
const onSignTransactions = async (chainId: string, address: string) => {
|
const onSignTransactions = async (chainId: string, address: string) => {
|
||||||
openRequestModal();
|
openRequestModal();
|
||||||
await elrondRpc.testSignTransactions(chainId, address);
|
await multiversxRpc.testSignTransactions(chainId, address);
|
||||||
};
|
};
|
||||||
const onSignMessage = async (chainId: string, address: string) => {
|
const onSignMessage = async (chainId: string, address: string) => {
|
||||||
openRequestModal();
|
openRequestModal();
|
||||||
await elrondRpc.testSignMessage(chainId, address);
|
await multiversxRpc.testSignMessage(chainId, address);
|
||||||
};
|
};
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTION,
|
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTION,
|
||||||
callback: onSignTransaction,
|
callback: onSignTransaction,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTIONS,
|
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTIONS,
|
||||||
callback: onSignTransactions,
|
callback: onSignTransactions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_MESSAGE,
|
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_MESSAGE,
|
||||||
callback: onSignMessage,
|
callback: onSignMessage,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -350,8 +350,8 @@ const Home: NextPage = () => {
|
|||||||
return getPolkadotActions();
|
return getPolkadotActions();
|
||||||
case "near":
|
case "near":
|
||||||
return getNearActions();
|
return getNearActions();
|
||||||
case "elrond":
|
case "mvx":
|
||||||
return getElrondActions();
|
return getMultiversxActions();
|
||||||
case "tron":
|
case "tron":
|
||||||
return getTronActions();
|
return getTronActions();
|
||||||
case "tezos":
|
case "tezos":
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -12,8 +12,8 @@
|
|||||||
"@cosmjs/amino": "0.28.4",
|
"@cosmjs/amino": "0.28.4",
|
||||||
"@cosmjs/encoding": "0.28.4",
|
"@cosmjs/encoding": "0.28.4",
|
||||||
"@cosmjs/proto-signing": "0.28.4",
|
"@cosmjs/proto-signing": "0.28.4",
|
||||||
"@elrondnetwork/erdjs": "11.1.1",
|
"@multiversx/sdk-core": "11.5.0",
|
||||||
"@elrondnetwork/erdjs-walletcore": "2.1.0",
|
"@multiversx/sdk-wallet": "4.0.0",
|
||||||
"@json-rpc-tools/utils": "1.7.6",
|
"@json-rpc-tools/utils": "1.7.6",
|
||||||
"@near-wallet-selector/wallet-utils": "^7.0.2",
|
"@near-wallet-selector/wallet-utils": "^7.0.2",
|
||||||
"@nextui-org/react": "1.0.8-beta.5",
|
"@nextui-org/react": "1.0.8-beta.5",
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 8.1 KiB |
@ -0,0 +1,4 @@
|
|||||||
|
<svg width="300" height="300" viewBox="0 0 300 300" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect width="300" height="300" rx="150" fill="black"/>
|
||||||
|
<path d="M158.482 149.928L228.714 112.529L216.919 90L152.575 115.854C150.923 116.523 149.077 116.523 147.425 115.854L83.0814 90L71.25 112.602L141.482 150L71.25 187.398L83.0814 210L147.425 183.948C149.077 183.279 150.923 183.279 152.575 183.948L216.919 209.874L228.75 187.272L158.482 149.928Z" fill="#23F7DD"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 472 B |
@ -3,7 +3,7 @@ import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
|
|||||||
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
|
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
|
||||||
import { nearAddresses } from '@/utils/NearWalletUtil'
|
import { nearAddresses } from '@/utils/NearWalletUtil'
|
||||||
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
|
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
|
||||||
import { elrondAddresses } from '@/utils/ElrondWalletUtil'
|
import { multiversxAddresses } from '@/utils/MultiversxWalletUtil'
|
||||||
import { tronAddresses } from '@/utils/TronWalletUtil'
|
import { tronAddresses } from '@/utils/TronWalletUtil'
|
||||||
import { tezosAddresses } from '@/utils/TezosWalletUtil'
|
import { tezosAddresses } from '@/utils/TezosWalletUtil'
|
||||||
import { useSnapshot } from 'valtio'
|
import { useSnapshot } from 'valtio'
|
||||||
@ -18,7 +18,7 @@ export default function AccountPicker() {
|
|||||||
SettingsStore.setCosmosAddress(cosmosAddresses[account])
|
SettingsStore.setCosmosAddress(cosmosAddresses[account])
|
||||||
SettingsStore.setSolanaAddress(solanaAddresses[account])
|
SettingsStore.setSolanaAddress(solanaAddresses[account])
|
||||||
SettingsStore.setNearAddress(nearAddresses[account])
|
SettingsStore.setNearAddress(nearAddresses[account])
|
||||||
SettingsStore.setElrondAddress(elrondAddresses[account])
|
SettingsStore.setMultiversxAddress(multiversxAddresses[account])
|
||||||
SettingsStore.setTronAddress(tronAddresses[account])
|
SettingsStore.setTronAddress(tronAddresses[account])
|
||||||
SettingsStore.setTezosAddress(tezosAddresses[account])
|
SettingsStore.setTezosAddress(tezosAddresses[account])
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import SessionRequestModal from '@/views/SessionSignModal'
|
|||||||
import SessionSignNearModal from '@/views/SessionSignNearModal'
|
import SessionSignNearModal from '@/views/SessionSignNearModal'
|
||||||
import SessionSignPolkadotModal from '@/views/SessionSignPolkadotModal'
|
import SessionSignPolkadotModal from '@/views/SessionSignPolkadotModal'
|
||||||
import SessionSignSolanaModal from '@/views/SessionSignSolanaModal'
|
import SessionSignSolanaModal from '@/views/SessionSignSolanaModal'
|
||||||
import SessionSignElrondModal from '@/views/SessionSignElrondModal'
|
import SessionSignMultiversxModal from '@/views/SessionSignMultiversxModal'
|
||||||
import SessionSignTronModal from '@/views/SessionSignTronModal'
|
import SessionSignTronModal from '@/views/SessionSignTronModal'
|
||||||
import SessionSignTezosModal from '@/views/SessionSignTezosModal'
|
import SessionSignTezosModal from '@/views/SessionSignTezosModal'
|
||||||
import SessionSignTypedDataModal from '@/views/SessionSignTypedDataModal'
|
import SessionSignTypedDataModal from '@/views/SessionSignTypedDataModal'
|
||||||
@ -32,7 +32,7 @@ export default function Modal() {
|
|||||||
{view === 'SessionSignSolanaModal' && <SessionSignSolanaModal />}
|
{view === 'SessionSignSolanaModal' && <SessionSignSolanaModal />}
|
||||||
{view === 'SessionSignPolkadotModal' && <SessionSignPolkadotModal />}
|
{view === 'SessionSignPolkadotModal' && <SessionSignPolkadotModal />}
|
||||||
{view === 'SessionSignNearModal' && <SessionSignNearModal />}
|
{view === 'SessionSignNearModal' && <SessionSignNearModal />}
|
||||||
{view === 'SessionSignElrondModal' && <SessionSignElrondModal />}
|
{view === 'SessionSignMultiversxModal' && <SessionSignMultiversxModal />}
|
||||||
{view === 'SessionSignTronModal' && <SessionSignTronModal />}
|
{view === 'SessionSignTronModal' && <SessionSignTronModal />}
|
||||||
{view === 'SessionSignTezosModal' && <SessionSignTezosModal />}
|
{view === 'SessionSignTezosModal' && <SessionSignTezosModal />}
|
||||||
{view === 'LegacySessionProposalModal' && <LegacySessionProposalModal />}
|
{view === 'LegacySessionProposalModal' && <LegacySessionProposalModal />}
|
||||||
|
@ -2,7 +2,7 @@ import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData'
|
|||||||
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
|
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
|
||||||
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
||||||
import { SOLANA_CHAINS, TSolanaChain } from '@/data/SolanaData'
|
import { SOLANA_CHAINS, TSolanaChain } from '@/data/SolanaData'
|
||||||
import { ELROND_CHAINS, TElrondChain } from '@/data/ElrondData'
|
import { MULTIVERSX_CHAINS, TMultiversxChain } from '@/data/MultiversxData'
|
||||||
import { TRON_CHAINS, TTronChain } from '@/data/TronData'
|
import { TRON_CHAINS, TTronChain } from '@/data/TronData'
|
||||||
import { Col, Divider, Row, Text } from '@nextui-org/react'
|
import { Col, Divider, Row, Text } from '@nextui-org/react'
|
||||||
import { Fragment } from 'react'
|
import { Fragment } from 'react'
|
||||||
@ -32,7 +32,7 @@ export default function RequesDetailsCard({ chains, protocol }: IProps) {
|
|||||||
COSMOS_MAINNET_CHAINS[chain as TCosmosChain]?.name ??
|
COSMOS_MAINNET_CHAINS[chain as TCosmosChain]?.name ??
|
||||||
SOLANA_CHAINS[chain as TSolanaChain]?.name ??
|
SOLANA_CHAINS[chain as TSolanaChain]?.name ??
|
||||||
NEAR_TEST_CHAINS[chain as TNearChain]?.name ??
|
NEAR_TEST_CHAINS[chain as TNearChain]?.name ??
|
||||||
ELROND_CHAINS[chain as TElrondChain]?.name ??
|
MULTIVERSX_CHAINS[chain as TMultiversxChain]?.name ??
|
||||||
TRON_CHAINS[chain as TTronChain]?.name ??
|
TRON_CHAINS[chain as TTronChain]?.name ??
|
||||||
chain
|
chain
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
|
|||||||
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
||||||
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
||||||
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
||||||
import { ELROND_MAINNET_CHAINS, ELROND_TEST_CHAINS } from '@/data/ElrondData'
|
import { MULTIVERSX_MAINNET_CHAINS, MULTIVERSX_TEST_CHAINS } from '@/data/MultiversxData'
|
||||||
import { TRON_MAINNET_CHAINS, TRON_TEST_CHAINS } from '@/data/TronData'
|
import { TRON_MAINNET_CHAINS, TRON_TEST_CHAINS } from '@/data/TronData'
|
||||||
import { formatChainName } from '@/utils/HelperUtil'
|
import { formatChainName } from '@/utils/HelperUtil'
|
||||||
import { Col, Row, Text } from '@nextui-org/react'
|
import { Col, Row, Text } from '@nextui-org/react'
|
||||||
@ -16,13 +16,13 @@ import { Fragment } from 'react'
|
|||||||
const CHAIN_METADATA = {
|
const CHAIN_METADATA = {
|
||||||
...COSMOS_MAINNET_CHAINS,
|
...COSMOS_MAINNET_CHAINS,
|
||||||
...SOLANA_MAINNET_CHAINS,
|
...SOLANA_MAINNET_CHAINS,
|
||||||
...ELROND_MAINNET_CHAINS,
|
...MULTIVERSX_MAINNET_CHAINS,
|
||||||
...TRON_MAINNET_CHAINS,
|
...TRON_MAINNET_CHAINS,
|
||||||
...EIP155_MAINNET_CHAINS,
|
...EIP155_MAINNET_CHAINS,
|
||||||
...EIP155_TEST_CHAINS,
|
...EIP155_TEST_CHAINS,
|
||||||
...SOLANA_TEST_CHAINS,
|
...SOLANA_TEST_CHAINS,
|
||||||
...NEAR_TEST_CHAINS,
|
...NEAR_TEST_CHAINS,
|
||||||
...ELROND_TEST_CHAINS,
|
...MULTIVERSX_TEST_CHAINS,
|
||||||
...TRON_TEST_CHAINS
|
...TRON_TEST_CHAINS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
|
|||||||
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
||||||
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
||||||
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
||||||
import { ELROND_MAINNET_CHAINS, ELROND_TEST_CHAINS } from '@/data/ElrondData'
|
import { MULTIVERSX_MAINNET_CHAINS, MULTIVERSX_TEST_CHAINS } from '@/data/MultiversxData'
|
||||||
import { TRON_MAINNET_CHAINS, TRON_TEST_CHAINS } from '@/data/TronData'
|
import { TRON_MAINNET_CHAINS, TRON_TEST_CHAINS } from '@/data/TronData'
|
||||||
import { formatChainName } from '@/utils/HelperUtil'
|
import { formatChainName } from '@/utils/HelperUtil'
|
||||||
import { Col, Row, Text } from '@nextui-org/react'
|
import { Col, Row, Text } from '@nextui-org/react'
|
||||||
@ -16,13 +16,13 @@ import { Fragment } from 'react'
|
|||||||
const CHAIN_METADATA = {
|
const CHAIN_METADATA = {
|
||||||
...COSMOS_MAINNET_CHAINS,
|
...COSMOS_MAINNET_CHAINS,
|
||||||
...SOLANA_MAINNET_CHAINS,
|
...SOLANA_MAINNET_CHAINS,
|
||||||
...ELROND_MAINNET_CHAINS,
|
...MULTIVERSX_MAINNET_CHAINS,
|
||||||
...TRON_MAINNET_CHAINS,
|
...TRON_MAINNET_CHAINS,
|
||||||
...EIP155_MAINNET_CHAINS,
|
...EIP155_MAINNET_CHAINS,
|
||||||
...EIP155_TEST_CHAINS,
|
...EIP155_TEST_CHAINS,
|
||||||
...SOLANA_TEST_CHAINS,
|
...SOLANA_TEST_CHAINS,
|
||||||
...NEAR_TEST_CHAINS,
|
...NEAR_TEST_CHAINS,
|
||||||
...ELROND_TEST_CHAINS,
|
...MULTIVERSX_TEST_CHAINS,
|
||||||
...TRON_TEST_CHAINS
|
...TRON_TEST_CHAINS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* Types
|
|
||||||
*/
|
|
||||||
export type TElrondChain = keyof typeof ELROND_MAINNET_CHAINS
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chains
|
|
||||||
*/
|
|
||||||
export const ELROND_MAINNET_CHAINS = {
|
|
||||||
'elrond:1': {
|
|
||||||
chainId: '1',
|
|
||||||
name: 'Elrond',
|
|
||||||
logo: '/chain-logos/elrond-1.png',
|
|
||||||
rgb: '43, 45, 46',
|
|
||||||
rpc: ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ELROND_TEST_CHAINS = {
|
|
||||||
'elrond:D': {
|
|
||||||
chainId: 'D',
|
|
||||||
name: 'Elrond Devnet',
|
|
||||||
logo: '/chain-logos/elrond-1.png',
|
|
||||||
rgb: '43, 45, 46',
|
|
||||||
rpc: ''
|
|
||||||
}
|
|
||||||
// Keep only one Test Chain visible
|
|
||||||
// 'elrond:T': {
|
|
||||||
// chainId: 'T',
|
|
||||||
// name: 'Elrond Testnet',
|
|
||||||
// logo: '/chain-logos/elrond-1.png',
|
|
||||||
// rgb: '43, 45, 46',
|
|
||||||
// rpc: ''
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ELROND_CHAINS = { ...ELROND_MAINNET_CHAINS, ...ELROND_TEST_CHAINS }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Methods
|
|
||||||
*/
|
|
||||||
export const ELROND_SIGNING_METHODS = {
|
|
||||||
ELROND_SIGN_TRANSACTION: 'erd_signTransaction',
|
|
||||||
ELROND_SIGN_TRANSACTIONS: 'erd_signTransactions',
|
|
||||||
ELROND_SIGN_MESSAGE: 'erd_signMessage',
|
|
||||||
ELROND_SIGN_LOGIN_TOKEN: 'erd_signLoginToken'
|
|
||||||
}
|
|
48
wallets/react-wallet-v2/src/data/MultiversxData.ts
Normal file
48
wallets/react-wallet-v2/src/data/MultiversxData.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Types
|
||||||
|
*/
|
||||||
|
export type TMultiversxChain = keyof typeof MULTIVERSX_MAINNET_CHAINS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chains
|
||||||
|
*/
|
||||||
|
export const MULTIVERSX_MAINNET_CHAINS = {
|
||||||
|
'mvx:1': {
|
||||||
|
chainId: '1',
|
||||||
|
name: 'MultiversX',
|
||||||
|
logo: '/chain-logos/multiversx-1.svg',
|
||||||
|
rgb: '43, 45, 46',
|
||||||
|
rpc: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MULTIVERSX_TEST_CHAINS = {
|
||||||
|
'mvx:D': {
|
||||||
|
chainId: 'D',
|
||||||
|
name: 'MultiversX Devnet',
|
||||||
|
logo: '/chain-logos/multiversx-1.svg',
|
||||||
|
rgb: '43, 45, 46',
|
||||||
|
rpc: ''
|
||||||
|
}
|
||||||
|
// Keep only one Test Chain visible
|
||||||
|
// 'mvx:T': {
|
||||||
|
// chainId: 'T',
|
||||||
|
// name: 'MultiversX Testnet',
|
||||||
|
// logo: '/chain-logos/multiversx-1.svg',
|
||||||
|
// rgb: '43, 45, 46',
|
||||||
|
// rpc: ''
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MULTIVERSX_CHAINS = { ...MULTIVERSX_MAINNET_CHAINS, ...MULTIVERSX_TEST_CHAINS }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Methods
|
||||||
|
*/
|
||||||
|
export const MULTIVERSX_SIGNING_METHODS = {
|
||||||
|
MULTIVERSX_SIGN_TRANSACTION: 'mvx_signTransaction',
|
||||||
|
MULTIVERSX_SIGN_TRANSACTIONS: 'mvx_signTransactions',
|
||||||
|
MULTIVERSX_SIGN_MESSAGE: 'mvx_signMessage',
|
||||||
|
MULTIVERSX_SIGN_LOGIN_TOKEN: 'mvx_signLoginToken',
|
||||||
|
MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN: 'mvx_signNativeAuthToken'
|
||||||
|
}
|
@ -3,7 +3,7 @@ import { createOrRestoreCosmosWallet } from '@/utils/CosmosWalletUtil'
|
|||||||
import { createOrRestoreEIP155Wallet } from '@/utils/EIP155WalletUtil'
|
import { createOrRestoreEIP155Wallet } from '@/utils/EIP155WalletUtil'
|
||||||
import { createOrRestoreSolanaWallet } from '@/utils/SolanaWalletUtil'
|
import { createOrRestoreSolanaWallet } from '@/utils/SolanaWalletUtil'
|
||||||
import { createOrRestorePolkadotWallet } from '@/utils/PolkadotWalletUtil'
|
import { createOrRestorePolkadotWallet } from '@/utils/PolkadotWalletUtil'
|
||||||
import { createOrRestoreElrondWallet } from '@/utils/ElrondWalletUtil'
|
import { createOrRestoreMultiversxWallet } from '@/utils/MultiversxWalletUtil'
|
||||||
import { createOrRestoreTronWallet } from '@/utils/TronWalletUtil'
|
import { createOrRestoreTronWallet } from '@/utils/TronWalletUtil'
|
||||||
import { createOrRestoreTezosWallet } from '@/utils/TezosWalletUtil'
|
import { createOrRestoreTezosWallet } from '@/utils/TezosWalletUtil'
|
||||||
import { createSignClient, signClient } from '@/utils/WalletConnectUtil'
|
import { createSignClient, signClient } from '@/utils/WalletConnectUtil'
|
||||||
@ -24,7 +24,7 @@ export default function useInitialization() {
|
|||||||
const { solanaAddresses } = await createOrRestoreSolanaWallet()
|
const { solanaAddresses } = await createOrRestoreSolanaWallet()
|
||||||
const { polkadotAddresses } = await createOrRestorePolkadotWallet()
|
const { polkadotAddresses } = await createOrRestorePolkadotWallet()
|
||||||
const { nearAddresses } = await createOrRestoreNearWallet()
|
const { nearAddresses } = await createOrRestoreNearWallet()
|
||||||
const { elrondAddresses } = await createOrRestoreElrondWallet()
|
const { multiversxAddresses } = await createOrRestoreMultiversxWallet()
|
||||||
const { tronAddresses } = await createOrRestoreTronWallet()
|
const { tronAddresses } = await createOrRestoreTronWallet()
|
||||||
const { tezosAddresses } = await createOrRestoreTezosWallet()
|
const { tezosAddresses } = await createOrRestoreTezosWallet()
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ export default function useInitialization() {
|
|||||||
SettingsStore.setSolanaAddress(solanaAddresses[0])
|
SettingsStore.setSolanaAddress(solanaAddresses[0])
|
||||||
SettingsStore.setPolkadotAddress(polkadotAddresses[0])
|
SettingsStore.setPolkadotAddress(polkadotAddresses[0])
|
||||||
SettingsStore.setNearAddress(nearAddresses[0])
|
SettingsStore.setNearAddress(nearAddresses[0])
|
||||||
SettingsStore.setElrondAddress(elrondAddresses[0])
|
SettingsStore.setMultiversxAddress(multiversxAddresses[0])
|
||||||
SettingsStore.setTronAddress(tronAddresses[0])
|
SettingsStore.setTronAddress(tronAddresses[0])
|
||||||
SettingsStore.setTezosAddress(tezosAddresses[0])
|
SettingsStore.setTezosAddress(tezosAddresses[0])
|
||||||
await createSignClient(relayerRegionURL)
|
await createSignClient(relayerRegionURL)
|
||||||
|
@ -2,7 +2,7 @@ import { COSMOS_SIGNING_METHODS } from '@/data/COSMOSData'
|
|||||||
import { EIP155_SIGNING_METHODS } from '@/data/EIP155Data'
|
import { EIP155_SIGNING_METHODS } from '@/data/EIP155Data'
|
||||||
import { SOLANA_SIGNING_METHODS } from '@/data/SolanaData'
|
import { SOLANA_SIGNING_METHODS } from '@/data/SolanaData'
|
||||||
import { POLKADOT_SIGNING_METHODS } from '@/data/PolkadotData'
|
import { POLKADOT_SIGNING_METHODS } from '@/data/PolkadotData'
|
||||||
import { ELROND_SIGNING_METHODS } from '@/data/ElrondData'
|
import { MULTIVERSX_SIGNING_METHODS } from '@/data/MultiversxData'
|
||||||
import { TRON_SIGNING_METHODS } from '@/data/TronData'
|
import { TRON_SIGNING_METHODS } from '@/data/TronData'
|
||||||
import ModalStore from '@/store/ModalStore'
|
import ModalStore from '@/store/ModalStore'
|
||||||
import { signClient } from '@/utils/WalletConnectUtil'
|
import { signClient } from '@/utils/WalletConnectUtil'
|
||||||
@ -68,11 +68,12 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
|
|||||||
case NEAR_SIGNING_METHODS.NEAR_VERIFY_OWNER:
|
case NEAR_SIGNING_METHODS.NEAR_VERIFY_OWNER:
|
||||||
return ModalStore.open('SessionSignNearModal', { requestEvent, requestSession })
|
return ModalStore.open('SessionSignNearModal', { requestEvent, requestSession })
|
||||||
|
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_MESSAGE:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_MESSAGE:
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTION:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTION:
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTIONS:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTIONS:
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_LOGIN_TOKEN:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_LOGIN_TOKEN:
|
||||||
return ModalStore.open('SessionSignElrondModal', { requestEvent, requestSession })
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN:
|
||||||
|
return ModalStore.open('SessionSignMultiversxModal', { requestEvent, requestSession })
|
||||||
|
|
||||||
case NEAR_SIGNING_METHODS.NEAR_GET_ACCOUNTS:
|
case NEAR_SIGNING_METHODS.NEAR_GET_ACCOUNTS:
|
||||||
return signClient.respond({
|
return signClient.respond({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Transaction, SignableMessage } from '@elrondnetwork/erdjs'
|
import { Transaction, SignableMessage } from '@multiversx/sdk-core'
|
||||||
import { Mnemonic, UserSecretKey, UserWallet, UserSigner } from '@elrondnetwork/erdjs-walletcore'
|
import { Mnemonic, UserSecretKey, UserWallet, UserSigner } from '@multiversx/sdk-wallet'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types
|
* Types
|
||||||
@ -11,7 +11,7 @@ interface IInitArgs {
|
|||||||
/**
|
/**
|
||||||
* Library
|
* Library
|
||||||
*/
|
*/
|
||||||
export default class ElrondLib {
|
export default class MultiversxLib {
|
||||||
wallet: UserWallet
|
wallet: UserWallet
|
||||||
mnemonic: Mnemonic
|
mnemonic: Mnemonic
|
||||||
password: string
|
password: string
|
||||||
@ -20,16 +20,16 @@ export default class ElrondLib {
|
|||||||
this.mnemonic = mnemonic
|
this.mnemonic = mnemonic
|
||||||
this.password = 'password' // test purposes only
|
this.password = 'password' // test purposes only
|
||||||
|
|
||||||
const secretKey = mnemonic.deriveKey(0)
|
this.wallet = UserWallet.fromMnemonic({
|
||||||
const secretKeyHex = secretKey.hex()
|
password: this.password,
|
||||||
let fromHex = UserSecretKey.fromString(secretKeyHex)
|
mnemonic: mnemonic.toString()
|
||||||
this.wallet = new UserWallet(fromHex, this.password)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static init({ mnemonic }: IInitArgs) {
|
static init({ mnemonic }: IInitArgs) {
|
||||||
const mnemonicObj = mnemonic ? Mnemonic.fromString(mnemonic) : Mnemonic.generate()
|
const mnemonicObj = mnemonic ? Mnemonic.fromString(mnemonic) : Mnemonic.generate()
|
||||||
|
|
||||||
return new ElrondLib(mnemonicObj)
|
return new MultiversxLib(mnemonicObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
getMnemonic() {
|
getMnemonic() {
|
||||||
@ -54,9 +54,9 @@ export default class ElrondLib {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
||||||
await signer.sign(signMessage)
|
const signature = await signer.sign(signMessage.serializeForSigning())
|
||||||
|
|
||||||
return { signature: signMessage.signature.hex() }
|
return { signature: signature.toString('hex') }
|
||||||
}
|
}
|
||||||
|
|
||||||
async signTransaction(transaction: any) {
|
async signTransaction(transaction: any) {
|
||||||
@ -66,9 +66,9 @@ export default class ElrondLib {
|
|||||||
const signTransaction = Transaction.fromPlainObject(transaction)
|
const signTransaction = Transaction.fromPlainObject(transaction)
|
||||||
|
|
||||||
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
||||||
await signer.sign(signTransaction)
|
const signature = await signer.sign(signTransaction.serializeForSigning(signer.getAddress()))
|
||||||
|
|
||||||
return { signature: signTransaction.getSignature().hex() }
|
return { signature: signature.toString('hex') }
|
||||||
}
|
}
|
||||||
|
|
||||||
async signTransactions(transactions: any[]) {
|
async signTransactions(transactions: any[]) {
|
||||||
@ -79,9 +79,11 @@ export default class ElrondLib {
|
|||||||
transactions.map(async (transaction: any): Promise<any> => {
|
transactions.map(async (transaction: any): Promise<any> => {
|
||||||
const signTransaction = Transaction.fromPlainObject(transaction)
|
const signTransaction = Transaction.fromPlainObject(transaction)
|
||||||
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
||||||
await signer.sign(signTransaction)
|
const signature = await signer.sign(
|
||||||
|
signTransaction.serializeForSigning(signer.getAddress())
|
||||||
|
)
|
||||||
|
|
||||||
return { signature: signTransaction.getSignature().hex() }
|
return { signature: signature.toString('hex') }
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
@ -5,7 +5,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
|
|||||||
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
||||||
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
||||||
import { POLKADOT_MAINNET_CHAINS, POLKADOT_TEST_CHAINS } from '@/data/PolkadotData'
|
import { POLKADOT_MAINNET_CHAINS, POLKADOT_TEST_CHAINS } from '@/data/PolkadotData'
|
||||||
import { ELROND_MAINNET_CHAINS, ELROND_TEST_CHAINS } from '@/data/ElrondData'
|
import { MULTIVERSX_MAINNET_CHAINS, MULTIVERSX_TEST_CHAINS } from '@/data/MultiversxData'
|
||||||
import { TRON_MAINNET_CHAINS, TRON_TEST_CHAINS } from '@/data/TronData'
|
import { TRON_MAINNET_CHAINS, TRON_TEST_CHAINS } from '@/data/TronData'
|
||||||
import SettingsStore from '@/store/SettingsStore'
|
import SettingsStore from '@/store/SettingsStore'
|
||||||
import { Text } from '@nextui-org/react'
|
import { Text } from '@nextui-org/react'
|
||||||
@ -22,7 +22,7 @@ export default function HomePage() {
|
|||||||
solanaAddress,
|
solanaAddress,
|
||||||
polkadotAddress,
|
polkadotAddress,
|
||||||
nearAddress,
|
nearAddress,
|
||||||
elrondAddress,
|
multiversxAddress,
|
||||||
tronAddress,
|
tronAddress,
|
||||||
tezosAddress
|
tezosAddress
|
||||||
} = useSnapshot(SettingsStore.state)
|
} = useSnapshot(SettingsStore.state)
|
||||||
@ -47,8 +47,8 @@ export default function HomePage() {
|
|||||||
{Object.entries(POLKADOT_MAINNET_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
{Object.entries(POLKADOT_MAINNET_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={polkadotAddress} chainId={caip10}/>
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={polkadotAddress} chainId={caip10}/>
|
||||||
))}
|
))}
|
||||||
{Object.entries(ELROND_MAINNET_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
{Object.entries(MULTIVERSX_MAINNET_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={elrondAddress} chainId={caip10}/>
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={multiversxAddress} chainId={caip10}/>
|
||||||
))}
|
))}
|
||||||
{Object.entries(TRON_MAINNET_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
{Object.entries(TRON_MAINNET_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={tronAddress} chainId={caip10}/>
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={tronAddress} chainId={caip10}/>
|
||||||
@ -74,8 +74,8 @@ export default function HomePage() {
|
|||||||
{Object.entries(NEAR_TEST_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
{Object.entries(NEAR_TEST_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={nearAddress} chainId={caip10}/>
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={nearAddress} chainId={caip10}/>
|
||||||
))}
|
))}
|
||||||
{Object.entries(ELROND_TEST_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
{Object.entries(MULTIVERSX_TEST_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={elrondAddress} chainId={caip10}/>
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={multiversxAddress} chainId={caip10}/>
|
||||||
))}
|
))}
|
||||||
{Object.entries(TRON_TEST_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
{Object.entries(TRON_TEST_CHAINS).map(([caip10, {name, logo, rgb}]) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={tronAddress} chainId={caip10}/>
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={tronAddress} chainId={caip10}/>
|
||||||
|
@ -4,7 +4,7 @@ import SettingsStore from '@/store/SettingsStore'
|
|||||||
import { cosmosWallets } from '@/utils/CosmosWalletUtil'
|
import { cosmosWallets } from '@/utils/CosmosWalletUtil'
|
||||||
import { eip155Wallets } from '@/utils/EIP155WalletUtil'
|
import { eip155Wallets } from '@/utils/EIP155WalletUtil'
|
||||||
import { solanaWallets } from '@/utils/SolanaWalletUtil'
|
import { solanaWallets } from '@/utils/SolanaWalletUtil'
|
||||||
import { elrondWallets } from '@/utils/ElrondWalletUtil'
|
import { multiversxWallets } from '@/utils/MultiversxWalletUtil'
|
||||||
import { tronWallets } from '@/utils/TronWalletUtil'
|
import { tronWallets } from '@/utils/TronWalletUtil'
|
||||||
import { Card, Divider, Row, Switch, Text } from '@nextui-org/react'
|
import { Card, Divider, Row, Switch, Text } from '@nextui-org/react'
|
||||||
import { Fragment } from 'react'
|
import { Fragment } from 'react'
|
||||||
@ -18,7 +18,7 @@ export default function SettingsPage() {
|
|||||||
eip155Address,
|
eip155Address,
|
||||||
cosmosAddress,
|
cosmosAddress,
|
||||||
solanaAddress,
|
solanaAddress,
|
||||||
elrondAddress,
|
multiversxAddress,
|
||||||
tronAddress,
|
tronAddress,
|
||||||
tezosAddress
|
tezosAddress
|
||||||
} = useSnapshot(SettingsStore.state)
|
} = useSnapshot(SettingsStore.state)
|
||||||
@ -91,10 +91,10 @@ export default function SettingsPage() {
|
|||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Text h4 css={{ marginTop: '$10', marginBottom: '$5' }}>
|
<Text h4 css={{ marginTop: '$10', marginBottom: '$5' }}>
|
||||||
Elrond Mnemonic
|
MultiversX Mnemonic
|
||||||
</Text>
|
</Text>
|
||||||
<Card bordered borderWeight="light" css={{ minHeight: '215px', wordWrap: 'break-word' }}>
|
<Card bordered borderWeight="light" css={{ minHeight: '215px', wordWrap: 'break-word' }}>
|
||||||
<Text css={{ fontFamily: '$mono' }}>{elrondWallets[elrondAddress].getMnemonic()}</Text>
|
<Text css={{ fontFamily: '$mono' }}>{multiversxWallets[multiversxAddress].getMnemonic()}</Text>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Text h4 css={{ marginTop: '$10', marginBottom: '$5' }}>
|
<Text h4 css={{ marginTop: '$10', marginBottom: '$5' }}>
|
||||||
|
@ -29,7 +29,7 @@ interface State {
|
|||||||
| 'SessionSignSolanaModal'
|
| 'SessionSignSolanaModal'
|
||||||
| 'SessionSignPolkadotModal'
|
| 'SessionSignPolkadotModal'
|
||||||
| 'SessionSignNearModal'
|
| 'SessionSignNearModal'
|
||||||
| 'SessionSignElrondModal'
|
| 'SessionSignMultiversxModal'
|
||||||
| 'SessionSignTronModal'
|
| 'SessionSignTronModal'
|
||||||
| 'SessionSignTezosModal'
|
| 'SessionSignTezosModal'
|
||||||
| 'LegacySessionProposalModal'
|
| 'LegacySessionProposalModal'
|
||||||
|
@ -11,7 +11,7 @@ interface State {
|
|||||||
solanaAddress: string
|
solanaAddress: string
|
||||||
polkadotAddress: string
|
polkadotAddress: string
|
||||||
nearAddress: string
|
nearAddress: string
|
||||||
elrondAddress: string
|
multiversxAddress: string
|
||||||
tronAddress: string
|
tronAddress: string
|
||||||
tezosAddress: string
|
tezosAddress: string
|
||||||
relayerRegionURL: string
|
relayerRegionURL: string
|
||||||
@ -30,7 +30,7 @@ const state = proxy<State>({
|
|||||||
solanaAddress: '',
|
solanaAddress: '',
|
||||||
polkadotAddress: '',
|
polkadotAddress: '',
|
||||||
nearAddress: '',
|
nearAddress: '',
|
||||||
elrondAddress: '',
|
multiversxAddress: '',
|
||||||
tronAddress: '',
|
tronAddress: '',
|
||||||
tezosAddress: '',
|
tezosAddress: '',
|
||||||
relayerRegionURL: ''
|
relayerRegionURL: ''
|
||||||
@ -68,8 +68,8 @@ const SettingsStore = {
|
|||||||
state.relayerRegionURL = relayerRegionURL
|
state.relayerRegionURL = relayerRegionURL
|
||||||
},
|
},
|
||||||
|
|
||||||
setElrondAddress(elrondAddress: string) {
|
setMultiversxAddress(multiversxAddress: string) {
|
||||||
state.elrondAddress = elrondAddress
|
state.multiversxAddress = multiversxAddress
|
||||||
},
|
},
|
||||||
|
|
||||||
setTronAddress(tronAddress: string) {
|
setTronAddress(tronAddress: string) {
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
import ElrondLib from '@/lib/ElrondLib'
|
|
||||||
|
|
||||||
export let wallet1: ElrondLib
|
|
||||||
export let wallet2: ElrondLib
|
|
||||||
export let elrondWallets: Record<string, ElrondLib>
|
|
||||||
export let elrondAddresses: string[]
|
|
||||||
|
|
||||||
let address1: string
|
|
||||||
let address2: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utilities
|
|
||||||
*/
|
|
||||||
export async function createOrRestoreElrondWallet() {
|
|
||||||
const mnemonic1 = localStorage.getItem('ELROND_MNEMONIC_1')
|
|
||||||
const mnemonic2 = localStorage.getItem('ELROND_MNEMONIC_2')
|
|
||||||
|
|
||||||
if (mnemonic1 && mnemonic2) {
|
|
||||||
wallet1 = await ElrondLib.init({ mnemonic: mnemonic1 })
|
|
||||||
wallet2 = await ElrondLib.init({ mnemonic: mnemonic2 })
|
|
||||||
} else {
|
|
||||||
wallet1 = await ElrondLib.init({})
|
|
||||||
wallet2 = await ElrondLib.init({})
|
|
||||||
|
|
||||||
// Don't store mnemonic in local storage in a production project!
|
|
||||||
localStorage.setItem('ELROND_MNEMONIC_1', wallet1.getMnemonic())
|
|
||||||
localStorage.setItem('ELROND_MNEMONIC_2', wallet2.getMnemonic())
|
|
||||||
}
|
|
||||||
|
|
||||||
address1 = await wallet1.getAddress()
|
|
||||||
address2 = await wallet2.getAddress()
|
|
||||||
|
|
||||||
elrondWallets = {
|
|
||||||
[address1]: wallet1,
|
|
||||||
[address2]: wallet2
|
|
||||||
}
|
|
||||||
elrondAddresses = Object.keys(elrondWallets)
|
|
||||||
|
|
||||||
return {
|
|
||||||
elrondWallets,
|
|
||||||
elrondAddresses
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData'
|
import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData'
|
||||||
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
|
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
|
||||||
import { ELROND_CHAINS, TElrondChain } from '@/data/ElrondData'
|
import { MULTIVERSX_CHAINS, TMultiversxChain } from '@/data/MultiversxData'
|
||||||
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
||||||
import { POLKADOT_CHAINS, TPolkadotChain } from '@/data/PolkadotData'
|
import { POLKADOT_CHAINS, TPolkadotChain } from '@/data/PolkadotData'
|
||||||
import { SOLANA_CHAINS, TSolanaChain } from '@/data/SolanaData'
|
import { SOLANA_CHAINS, TSolanaChain } from '@/data/SolanaData'
|
||||||
@ -115,10 +115,10 @@ export function isNearChain(chain: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if chain is part of ELROND standard
|
* Check if chain is part of MULTIVERSX standard
|
||||||
*/
|
*/
|
||||||
export function isElrondChain(chain: string) {
|
export function isMultiversxChain(chain: string) {
|
||||||
return chain.includes('elrond')
|
return chain.includes('mvx')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,7 +142,7 @@ export function formatChainName(chainId: string) {
|
|||||||
return (
|
return (
|
||||||
COSMOS_MAINNET_CHAINS[chainId as TCosmosChain]?.name ??
|
COSMOS_MAINNET_CHAINS[chainId as TCosmosChain]?.name ??
|
||||||
EIP155_CHAINS[chainId as TEIP155Chain]?.name ??
|
EIP155_CHAINS[chainId as TEIP155Chain]?.name ??
|
||||||
ELROND_CHAINS[chainId as TElrondChain]?.name ??
|
MULTIVERSX_CHAINS[chainId as TMultiversxChain]?.name ??
|
||||||
NEAR_TEST_CHAINS[chainId as TNearChain]?.name ??
|
NEAR_TEST_CHAINS[chainId as TNearChain]?.name ??
|
||||||
POLKADOT_CHAINS[chainId as TPolkadotChain]?.name ??
|
POLKADOT_CHAINS[chainId as TPolkadotChain]?.name ??
|
||||||
SOLANA_CHAINS[chainId as TSolanaChain]?.name ??
|
SOLANA_CHAINS[chainId as TSolanaChain]?.name ??
|
||||||
|
@ -1,40 +1,41 @@
|
|||||||
import { ELROND_SIGNING_METHODS } from '@/data/ElrondData'
|
import { MULTIVERSX_SIGNING_METHODS } from '@/data/MultiversxData'
|
||||||
import { getWalletAddressFromParams } from '@/utils/HelperUtil'
|
import { getWalletAddressFromParams } from '@/utils/HelperUtil'
|
||||||
import { elrondAddresses, elrondWallets } from '@/utils/ElrondWalletUtil'
|
import { multiversxAddresses, multiversxWallets } from '@/utils/MultiversxWalletUtil'
|
||||||
import { formatJsonRpcError, formatJsonRpcResult } from '@json-rpc-tools/utils'
|
import { formatJsonRpcError, formatJsonRpcResult } from '@json-rpc-tools/utils'
|
||||||
import { SignClientTypes } from '@walletconnect/types'
|
import { SignClientTypes } from '@walletconnect/types'
|
||||||
import { getSdkError } from '@walletconnect/utils'
|
import { getSdkError } from '@walletconnect/utils'
|
||||||
|
|
||||||
export async function approveElrondRequest(
|
export async function approveMultiversxRequest(
|
||||||
requestEvent: SignClientTypes.EventArguments['session_request']
|
requestEvent: SignClientTypes.EventArguments['session_request']
|
||||||
) {
|
) {
|
||||||
const { params, id } = requestEvent
|
const { params, id } = requestEvent
|
||||||
const { request } = params
|
const { request } = params
|
||||||
const account = getWalletAddressFromParams(elrondAddresses, params)
|
const account = getWalletAddressFromParams(multiversxAddresses, params)
|
||||||
const wallet = elrondWallets[account]
|
const wallet = multiversxWallets[account]
|
||||||
|
|
||||||
switch (request.method) {
|
switch (request.method) {
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_MESSAGE:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_MESSAGE:
|
||||||
const signedMessage = await wallet.signMessage(request.params.message)
|
const signedMessage = await wallet.signMessage(request.params.message)
|
||||||
return formatJsonRpcResult(id, signedMessage)
|
return formatJsonRpcResult(id, signedMessage)
|
||||||
|
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTION:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTION:
|
||||||
const signTransaction = request.params.transaction
|
const signTransaction = request.params.transaction
|
||||||
// Transactions must be signed with the Sender's Private Key before submitting them to the Elrond Network.
|
// Transactions must be signed with the Sender's Private Key before submitting them to the MultiversX Network.
|
||||||
// Signing is performed with the Ed25519 algorithm.
|
// Signing is performed with the Ed25519 algorithm.
|
||||||
const signature = await wallet.signTransaction(signTransaction)
|
const signature = await wallet.signTransaction(signTransaction)
|
||||||
|
|
||||||
return formatJsonRpcResult(id, signature)
|
return formatJsonRpcResult(id, signature)
|
||||||
|
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTIONS:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTIONS:
|
||||||
// Elrond Allows for a Batch of Transactions to be signed
|
// MultiversX Allows for a Batch of Transactions to be signed
|
||||||
const signTransactions = request.params.transactions
|
const signTransactions = request.params.transactions
|
||||||
|
|
||||||
const signatures = await wallet.signTransactions(signTransactions)
|
const signatures = await wallet.signTransactions(signTransactions)
|
||||||
return formatJsonRpcResult(id, signatures)
|
return formatJsonRpcResult(id, signatures)
|
||||||
|
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_LOGIN_TOKEN:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_LOGIN_TOKEN:
|
||||||
// Sometimes a dApp (and its backend) might want to reliably assign an off-chain user identity to an Elrond address.
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN:
|
||||||
|
// Sometimes a dApp (and its backend) might want to reliably assign an off-chain user identity to a MultiversX address.
|
||||||
// On this purpose, the signing providers allow a login token to be used within the login flow - this token is signed using the wallet of the user.
|
// On this purpose, the signing providers allow a login token to be used within the login flow - this token is signed using the wallet of the user.
|
||||||
// Afterwards, a backend application would normally verify the signature of the token
|
// Afterwards, a backend application would normally verify the signature of the token
|
||||||
const message = `${account}${request.params.token}{}`
|
const message = `${account}${request.params.token}{}`
|
||||||
@ -47,7 +48,9 @@ export async function approveElrondRequest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rejectElrondRequest(request: SignClientTypes.EventArguments['session_request']) {
|
export function rejectMultiversxRequest(
|
||||||
|
request: SignClientTypes.EventArguments['session_request']
|
||||||
|
) {
|
||||||
const { id } = request
|
const { id } = request
|
||||||
|
|
||||||
return formatJsonRpcError(id, getSdkError('USER_REJECTED_METHODS').message)
|
return formatJsonRpcError(id, getSdkError('USER_REJECTED_METHODS').message)
|
43
wallets/react-wallet-v2/src/utils/MultiversxWalletUtil.ts
Normal file
43
wallets/react-wallet-v2/src/utils/MultiversxWalletUtil.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import MultiversxLib from '@/lib/MultiversxLib'
|
||||||
|
|
||||||
|
export let wallet1: MultiversxLib
|
||||||
|
export let wallet2: MultiversxLib
|
||||||
|
export let multiversxWallets: Record<string, MultiversxLib>
|
||||||
|
export let multiversxAddresses: string[]
|
||||||
|
|
||||||
|
let address1: string
|
||||||
|
let address2: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities
|
||||||
|
*/
|
||||||
|
export async function createOrRestoreMultiversxWallet() {
|
||||||
|
const mnemonic1 = localStorage.getItem('MULTIVERSX_MNEMONIC_1')
|
||||||
|
const mnemonic2 = localStorage.getItem('MULTIVERSX_MNEMONIC_2')
|
||||||
|
|
||||||
|
if (mnemonic1 && mnemonic2) {
|
||||||
|
wallet1 = await MultiversxLib.init({ mnemonic: mnemonic1 })
|
||||||
|
wallet2 = await MultiversxLib.init({ mnemonic: mnemonic2 })
|
||||||
|
} else {
|
||||||
|
wallet1 = await MultiversxLib.init({})
|
||||||
|
wallet2 = await MultiversxLib.init({})
|
||||||
|
|
||||||
|
// Don't store mnemonic in local storage in a production project!
|
||||||
|
localStorage.setItem('MULTIVERSX_MNEMONIC_1', wallet1.getMnemonic())
|
||||||
|
localStorage.setItem('MULTIVERSX_MNEMONIC_2', wallet2.getMnemonic())
|
||||||
|
}
|
||||||
|
|
||||||
|
address1 = await wallet1.getAddress()
|
||||||
|
address2 = await wallet2.getAddress()
|
||||||
|
|
||||||
|
multiversxWallets = {
|
||||||
|
[address1]: wallet1,
|
||||||
|
[address2]: wallet2
|
||||||
|
}
|
||||||
|
multiversxAddresses = Object.keys(multiversxWallets)
|
||||||
|
|
||||||
|
return {
|
||||||
|
multiversxWallets,
|
||||||
|
multiversxAddresses
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@ import ModalStore from '@/store/ModalStore'
|
|||||||
import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
|
import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
|
||||||
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
|
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
|
||||||
import { polkadotAddresses } from '@/utils/PolkadotWalletUtil'
|
import { polkadotAddresses } from '@/utils/PolkadotWalletUtil'
|
||||||
import { elrondAddresses } from '@/utils/ElrondWalletUtil'
|
import { multiversxAddresses } from '@/utils/MultiversxWalletUtil'
|
||||||
import { tronAddresses } from '@/utils/TronWalletUtil'
|
import { tronAddresses } from '@/utils/TronWalletUtil'
|
||||||
import { tezosAddresses } from '@/utils/TezosWalletUtil'
|
import { tezosAddresses } from '@/utils/TezosWalletUtil'
|
||||||
import {
|
import {
|
||||||
@ -15,7 +15,7 @@ import {
|
|||||||
isSolanaChain,
|
isSolanaChain,
|
||||||
isPolkadotChain,
|
isPolkadotChain,
|
||||||
isNearChain,
|
isNearChain,
|
||||||
isElrondChain,
|
isMultiversxChain,
|
||||||
isTronChain,
|
isTronChain,
|
||||||
isTezosChain
|
isTezosChain
|
||||||
} from '@/utils/HelperUtil'
|
} from '@/utils/HelperUtil'
|
||||||
@ -168,10 +168,10 @@ export default function SessionProposalModal() {
|
|||||||
chain={chain}
|
chain={chain}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
} else if (isElrondChain(chain)) {
|
} else if (isMultiversxChain(chain)) {
|
||||||
return (
|
return (
|
||||||
<ProposalSelectSection
|
<ProposalSelectSection
|
||||||
addresses={elrondAddresses}
|
addresses={multiversxAddresses}
|
||||||
selectedAddresses={selectedAccounts[chain]}
|
selectedAddresses={selectedAccounts[chain]}
|
||||||
onSelect={onSelectAccount}
|
onSelect={onSelectAccount}
|
||||||
chain={chain}
|
chain={chain}
|
||||||
|
@ -4,12 +4,12 @@ import RequesDetailsCard from '@/components/RequestDetalilsCard'
|
|||||||
import RequestMethodCard from '@/components/RequestMethodCard'
|
import RequestMethodCard from '@/components/RequestMethodCard'
|
||||||
import RequestModalContainer from '@/components/RequestModalContainer'
|
import RequestModalContainer from '@/components/RequestModalContainer'
|
||||||
import ModalStore from '@/store/ModalStore'
|
import ModalStore from '@/store/ModalStore'
|
||||||
import { approveElrondRequest, rejectElrondRequest } from '@/utils/ElrondRequestHandlerUtil'
|
import { approveMultiversxRequest, rejectMultiversxRequest } from '@/utils/MultiversxRequestHandlerUtil'
|
||||||
import { signClient } from '@/utils/WalletConnectUtil'
|
import { signClient } from '@/utils/WalletConnectUtil'
|
||||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||||
import { Fragment } from 'react'
|
import { Fragment } from 'react'
|
||||||
|
|
||||||
export default function SessionSignElrondModal() {
|
export default function SessionSignMultiversxModal() {
|
||||||
// Get request and wallet data from store
|
// Get request and wallet data from store
|
||||||
const requestEvent = ModalStore.state.data?.requestEvent
|
const requestEvent = ModalStore.state.data?.requestEvent
|
||||||
const requestSession = ModalStore.state.data?.requestSession
|
const requestSession = ModalStore.state.data?.requestSession
|
||||||
@ -26,7 +26,7 @@ export default function SessionSignElrondModal() {
|
|||||||
// Handle approve action (logic varies based on request method)
|
// Handle approve action (logic varies based on request method)
|
||||||
async function onApprove() {
|
async function onApprove() {
|
||||||
if (requestEvent) {
|
if (requestEvent) {
|
||||||
const response = await approveElrondRequest(requestEvent)
|
const response = await approveMultiversxRequest(requestEvent)
|
||||||
await signClient.respond({
|
await signClient.respond({
|
||||||
topic,
|
topic,
|
||||||
response
|
response
|
||||||
@ -38,7 +38,7 @@ export default function SessionSignElrondModal() {
|
|||||||
// Handle reject action
|
// Handle reject action
|
||||||
async function onReject() {
|
async function onReject() {
|
||||||
if (requestEvent) {
|
if (requestEvent) {
|
||||||
const response = rejectElrondRequest(requestEvent)
|
const response = rejectMultiversxRequest(requestEvent)
|
||||||
await signClient.respond({
|
await signClient.respond({
|
||||||
topic,
|
topic,
|
||||||
response
|
response
|
File diff suppressed because it is too large
Load Diff
@ -12,8 +12,8 @@
|
|||||||
"@cosmjs/amino": "0.28.4",
|
"@cosmjs/amino": "0.28.4",
|
||||||
"@cosmjs/encoding": "0.28.4",
|
"@cosmjs/encoding": "0.28.4",
|
||||||
"@cosmjs/proto-signing": "0.28.4",
|
"@cosmjs/proto-signing": "0.28.4",
|
||||||
"@elrondnetwork/erdjs": "11.1.1",
|
"@multiversx/sdk-core": "11.5.0",
|
||||||
"@elrondnetwork/erdjs-walletcore": "2.1.0",
|
"@multiversx/sdk-wallet": "4.0.0",
|
||||||
"@json-rpc-tools/utils": "1.7.6",
|
"@json-rpc-tools/utils": "1.7.6",
|
||||||
"@near-wallet-selector/wallet-utils": "^7.0.2",
|
"@near-wallet-selector/wallet-utils": "^7.0.2",
|
||||||
"@nextui-org/react": "1.0.8-beta.5",
|
"@nextui-org/react": "1.0.8-beta.5",
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 8.1 KiB |
@ -0,0 +1,4 @@
|
|||||||
|
<svg width="300" height="300" viewBox="0 0 300 300" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect width="300" height="300" rx="150" fill="black"/>
|
||||||
|
<path d="M158.482 149.928L228.714 112.529L216.919 90L152.575 115.854C150.923 116.523 149.077 116.523 147.425 115.854L83.0814 90L71.25 112.602L141.482 150L71.25 187.398L83.0814 210L147.425 183.948C149.077 183.279 150.923 183.279 152.575 183.948L216.919 209.874L228.75 187.272L158.482 149.928Z" fill="#23F7DD"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 472 B |
@ -3,7 +3,7 @@ import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
|
|||||||
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
|
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
|
||||||
import { nearAddresses } from '@/utils/NearWalletUtil'
|
import { nearAddresses } from '@/utils/NearWalletUtil'
|
||||||
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
|
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
|
||||||
import { elrondAddresses } from '@/utils/ElrondWalletUtil'
|
import { multiversxAddresses } from '@/utils/MultiversxWalletUtil'
|
||||||
import { useSnapshot } from 'valtio'
|
import { useSnapshot } from 'valtio'
|
||||||
|
|
||||||
export default function AccountPicker() {
|
export default function AccountPicker() {
|
||||||
@ -16,7 +16,7 @@ export default function AccountPicker() {
|
|||||||
SettingsStore.setCosmosAddress(cosmosAddresses[account])
|
SettingsStore.setCosmosAddress(cosmosAddresses[account])
|
||||||
SettingsStore.setSolanaAddress(solanaAddresses[account])
|
SettingsStore.setSolanaAddress(solanaAddresses[account])
|
||||||
SettingsStore.setNearAddress(nearAddresses[account])
|
SettingsStore.setNearAddress(nearAddresses[account])
|
||||||
SettingsStore.setElrondAddress(elrondAddresses[account])
|
SettingsStore.setMultiversxAddress(multiversxAddresses[account])
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -6,7 +6,7 @@ import SessionRequestModal from '@/views/SessionSignModal'
|
|||||||
import SessionSignNearModal from '@/views/SessionSignNearModal'
|
import SessionSignNearModal from '@/views/SessionSignNearModal'
|
||||||
import SessionSignPolkadotModal from '@/views/SessionSignPolkadotModal'
|
import SessionSignPolkadotModal from '@/views/SessionSignPolkadotModal'
|
||||||
import SessionSignSolanaModal from '@/views/SessionSignSolanaModal'
|
import SessionSignSolanaModal from '@/views/SessionSignSolanaModal'
|
||||||
import SessionSignElrondModal from '@/views/SessionSignElrondModal'
|
import SessionSignMultiversxModal from '@/views/SessionSignMultiversxModal'
|
||||||
import SessionSignTypedDataModal from '@/views/SessionSignTypedDataModal'
|
import SessionSignTypedDataModal from '@/views/SessionSignTypedDataModal'
|
||||||
import SessionUnsuportedMethodModal from '@/views/SessionUnsuportedMethodModal'
|
import SessionUnsuportedMethodModal from '@/views/SessionUnsuportedMethodModal'
|
||||||
import { Modal as NextModal } from '@nextui-org/react'
|
import { Modal as NextModal } from '@nextui-org/react'
|
||||||
@ -27,7 +27,7 @@ export default function Modal() {
|
|||||||
{view === 'SessionSignSolanaModal' && <SessionSignSolanaModal />}
|
{view === 'SessionSignSolanaModal' && <SessionSignSolanaModal />}
|
||||||
{view === 'SessionSignPolkadotModal' && <SessionSignPolkadotModal />}
|
{view === 'SessionSignPolkadotModal' && <SessionSignPolkadotModal />}
|
||||||
{view === 'SessionSignNearModal' && <SessionSignNearModal />}
|
{view === 'SessionSignNearModal' && <SessionSignNearModal />}
|
||||||
{view === 'SessionSignElrondModal' && <SessionSignElrondModal />}
|
{view === 'SessionSignMultiversxModal' && <SessionSignMultiversxModal />}
|
||||||
{view === 'AuthRequestModal' && <AuthRequestModal />}
|
{view === 'AuthRequestModal' && <AuthRequestModal />}
|
||||||
</NextModal>
|
</NextModal>
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,7 @@ import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData'
|
|||||||
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
|
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
|
||||||
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
||||||
import { SOLANA_CHAINS, TSolanaChain } from '@/data/SolanaData'
|
import { SOLANA_CHAINS, TSolanaChain } from '@/data/SolanaData'
|
||||||
import { ELROND_CHAINS, TElrondChain } from '@/data/ElrondData'
|
import { MULTIVERSX_CHAINS, TMultiversxChain } from '@/data/MultiversxData'
|
||||||
import { Col, Divider, Row, Text } from '@nextui-org/react'
|
import { Col, Divider, Row, Text } from '@nextui-org/react'
|
||||||
import { Fragment } from 'react'
|
import { Fragment } from 'react'
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ export default function RequesDetailsCard({ chains, protocol }: IProps) {
|
|||||||
COSMOS_MAINNET_CHAINS[chain as TCosmosChain]?.name ??
|
COSMOS_MAINNET_CHAINS[chain as TCosmosChain]?.name ??
|
||||||
SOLANA_CHAINS[chain as TSolanaChain]?.name ??
|
SOLANA_CHAINS[chain as TSolanaChain]?.name ??
|
||||||
NEAR_TEST_CHAINS[chain as TNearChain]?.name ??
|
NEAR_TEST_CHAINS[chain as TNearChain]?.name ??
|
||||||
ELROND_CHAINS[chain as TElrondChain]?.name ??
|
MULTIVERSX_CHAINS[chain as TMultiversxChain]?.name ??
|
||||||
chain
|
chain
|
||||||
)
|
)
|
||||||
.join(', ')}
|
.join(', ')}
|
||||||
|
@ -3,7 +3,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
|
|||||||
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
||||||
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
||||||
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
||||||
import { ELROND_MAINNET_CHAINS, ELROND_TEST_CHAINS } from '@/data/ElrondData'
|
import { MULTIVERSX_MAINNET_CHAINS, MULTIVERSX_TEST_CHAINS } from '@/data/MultiversxData'
|
||||||
import { formatChainName } from '@/utils/HelperUtil'
|
import { formatChainName } from '@/utils/HelperUtil'
|
||||||
import { Col, Row, Text } from '@nextui-org/react'
|
import { Col, Row, Text } from '@nextui-org/react'
|
||||||
import { SessionTypes } from '@walletconnect/types'
|
import { SessionTypes } from '@walletconnect/types'
|
||||||
@ -15,12 +15,12 @@ import { Fragment } from 'react'
|
|||||||
const CHAIN_METADATA = {
|
const CHAIN_METADATA = {
|
||||||
...COSMOS_MAINNET_CHAINS,
|
...COSMOS_MAINNET_CHAINS,
|
||||||
...SOLANA_MAINNET_CHAINS,
|
...SOLANA_MAINNET_CHAINS,
|
||||||
...ELROND_MAINNET_CHAINS,
|
...MULTIVERSX_MAINNET_CHAINS,
|
||||||
...EIP155_MAINNET_CHAINS,
|
...EIP155_MAINNET_CHAINS,
|
||||||
...EIP155_TEST_CHAINS,
|
...EIP155_TEST_CHAINS,
|
||||||
...SOLANA_TEST_CHAINS,
|
...SOLANA_TEST_CHAINS,
|
||||||
...NEAR_TEST_CHAINS,
|
...NEAR_TEST_CHAINS,
|
||||||
...ELROND_TEST_CHAINS
|
...MULTIVERSX_TEST_CHAINS
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
|
|||||||
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
||||||
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
||||||
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
||||||
import { ELROND_MAINNET_CHAINS, ELROND_TEST_CHAINS } from '@/data/ElrondData'
|
import { MULTIVERSX_MAINNET_CHAINS, MULTIVERSX_TEST_CHAINS } from '@/data/MultiversxData'
|
||||||
import { formatChainName } from '@/utils/HelperUtil'
|
import { formatChainName } from '@/utils/HelperUtil'
|
||||||
import { Col, Row, Text } from '@nextui-org/react'
|
import { Col, Row, Text } from '@nextui-org/react'
|
||||||
import { ProposalTypes } from '@walletconnect/types'
|
import { ProposalTypes } from '@walletconnect/types'
|
||||||
@ -15,12 +15,12 @@ import { Fragment } from 'react'
|
|||||||
const CHAIN_METADATA = {
|
const CHAIN_METADATA = {
|
||||||
...COSMOS_MAINNET_CHAINS,
|
...COSMOS_MAINNET_CHAINS,
|
||||||
...SOLANA_MAINNET_CHAINS,
|
...SOLANA_MAINNET_CHAINS,
|
||||||
...ELROND_MAINNET_CHAINS,
|
...MULTIVERSX_MAINNET_CHAINS,
|
||||||
...EIP155_MAINNET_CHAINS,
|
...EIP155_MAINNET_CHAINS,
|
||||||
...EIP155_TEST_CHAINS,
|
...EIP155_TEST_CHAINS,
|
||||||
...SOLANA_TEST_CHAINS,
|
...SOLANA_TEST_CHAINS,
|
||||||
...NEAR_TEST_CHAINS,
|
...NEAR_TEST_CHAINS,
|
||||||
...ELROND_TEST_CHAINS
|
...MULTIVERSX_TEST_CHAINS
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* Types
|
|
||||||
*/
|
|
||||||
export type TElrondChain = keyof typeof ELROND_MAINNET_CHAINS
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chains
|
|
||||||
*/
|
|
||||||
export const ELROND_MAINNET_CHAINS = {
|
|
||||||
'elrond:1': {
|
|
||||||
chainId: '1',
|
|
||||||
name: 'Elrond',
|
|
||||||
logo: '/chain-logos/elrond-1.png',
|
|
||||||
rgb: '43, 45, 46',
|
|
||||||
rpc: ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ELROND_TEST_CHAINS = {
|
|
||||||
'elrond:D': {
|
|
||||||
chainId: 'D',
|
|
||||||
name: 'Elrond Devnet',
|
|
||||||
logo: '/chain-logos/elrond-1.png',
|
|
||||||
rgb: '43, 45, 46',
|
|
||||||
rpc: ''
|
|
||||||
}
|
|
||||||
// Keep only one Test Chain visible
|
|
||||||
// 'elrond:T': {
|
|
||||||
// chainId: 'T',
|
|
||||||
// name: 'Elrond Testnet',
|
|
||||||
// logo: '/chain-logos/elrond-1.png',
|
|
||||||
// rgb: '43, 45, 46',
|
|
||||||
// rpc: ''
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ELROND_CHAINS = { ...ELROND_MAINNET_CHAINS, ...ELROND_TEST_CHAINS }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Methods
|
|
||||||
*/
|
|
||||||
export const ELROND_SIGNING_METHODS = {
|
|
||||||
ELROND_SIGN_TRANSACTION: 'erd_signTransaction',
|
|
||||||
ELROND_SIGN_TRANSACTIONS: 'erd_signTransactions',
|
|
||||||
ELROND_SIGN_MESSAGE: 'erd_signMessage',
|
|
||||||
ELROND_SIGN_LOGIN_TOKEN: 'erd_signLoginToken'
|
|
||||||
}
|
|
48
wallets/react-web3wallet/src/data/MultiversxData.ts
Normal file
48
wallets/react-web3wallet/src/data/MultiversxData.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Types
|
||||||
|
*/
|
||||||
|
export type TMultiversxChain = keyof typeof MULTIVERSX_MAINNET_CHAINS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chains
|
||||||
|
*/
|
||||||
|
export const MULTIVERSX_MAINNET_CHAINS = {
|
||||||
|
'mvx:1': {
|
||||||
|
chainId: '1',
|
||||||
|
name: 'MultiversX',
|
||||||
|
logo: '/chain-logos/multiversx-1.svg',
|
||||||
|
rgb: '43, 45, 46',
|
||||||
|
rpc: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MULTIVERSX_TEST_CHAINS = {
|
||||||
|
'mvx:D': {
|
||||||
|
chainId: 'D',
|
||||||
|
name: 'MultiversX Devnet',
|
||||||
|
logo: '/chain-logos/multiversx-1.svg',
|
||||||
|
rgb: '43, 45, 46',
|
||||||
|
rpc: ''
|
||||||
|
}
|
||||||
|
// Keep only one Test Chain visible
|
||||||
|
// 'mvx:T': {
|
||||||
|
// chainId: 'T',
|
||||||
|
// name: 'MultiversX Testnet',
|
||||||
|
// logo: '/chain-logos/multiversx-1.svg',
|
||||||
|
// rgb: '43, 45, 46',
|
||||||
|
// rpc: ''
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MULTIVERSX_CHAINS = { ...MULTIVERSX_MAINNET_CHAINS, ...MULTIVERSX_TEST_CHAINS }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Methods
|
||||||
|
*/
|
||||||
|
export const MULTIVERSX_SIGNING_METHODS = {
|
||||||
|
MULTIVERSX_SIGN_TRANSACTION: 'mvx_signTransaction',
|
||||||
|
MULTIVERSX_SIGN_TRANSACTIONS: 'mvx_signTransactions',
|
||||||
|
MULTIVERSX_SIGN_MESSAGE: 'mvx_signMessage',
|
||||||
|
MULTIVERSX_SIGN_LOGIN_TOKEN: 'mvx_signLoginToken',
|
||||||
|
MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN: 'mvx_signNativeAuthToken'
|
||||||
|
}
|
@ -3,7 +3,7 @@ import { createOrRestoreCosmosWallet } from '@/utils/CosmosWalletUtil'
|
|||||||
import { createOrRestoreEIP155Wallet } from '@/utils/EIP155WalletUtil'
|
import { createOrRestoreEIP155Wallet } from '@/utils/EIP155WalletUtil'
|
||||||
import { createOrRestoreSolanaWallet } from '@/utils/SolanaWalletUtil'
|
import { createOrRestoreSolanaWallet } from '@/utils/SolanaWalletUtil'
|
||||||
import { createOrRestorePolkadotWallet } from '@/utils/PolkadotWalletUtil'
|
import { createOrRestorePolkadotWallet } from '@/utils/PolkadotWalletUtil'
|
||||||
import { createOrRestoreElrondWallet } from '@/utils/ElrondWalletUtil'
|
import { createOrRestoreMultiversxWallet } from '@/utils/MultiversxWalletUtil'
|
||||||
import { createWeb3Wallet } from '@/utils/WalletConnectUtil'
|
import { createWeb3Wallet } from '@/utils/WalletConnectUtil'
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { useSnapshot } from 'valtio'
|
import { useSnapshot } from 'valtio'
|
||||||
@ -22,14 +22,14 @@ export default function useInitialization() {
|
|||||||
const { solanaAddresses } = await createOrRestoreSolanaWallet()
|
const { solanaAddresses } = await createOrRestoreSolanaWallet()
|
||||||
const { polkadotAddresses } = await createOrRestorePolkadotWallet()
|
const { polkadotAddresses } = await createOrRestorePolkadotWallet()
|
||||||
const { nearAddresses } = await createOrRestoreNearWallet()
|
const { nearAddresses } = await createOrRestoreNearWallet()
|
||||||
const { elrondAddresses } = await createOrRestoreElrondWallet()
|
const { multiversxAddresses } = await createOrRestoreMultiversxWallet()
|
||||||
|
|
||||||
SettingsStore.setEIP155Address(eip155Addresses[0])
|
SettingsStore.setEIP155Address(eip155Addresses[0])
|
||||||
SettingsStore.setCosmosAddress(cosmosAddresses[0])
|
SettingsStore.setCosmosAddress(cosmosAddresses[0])
|
||||||
SettingsStore.setSolanaAddress(solanaAddresses[0])
|
SettingsStore.setSolanaAddress(solanaAddresses[0])
|
||||||
SettingsStore.setPolkadotAddress(polkadotAddresses[0])
|
SettingsStore.setPolkadotAddress(polkadotAddresses[0])
|
||||||
SettingsStore.setNearAddress(nearAddresses[0])
|
SettingsStore.setNearAddress(nearAddresses[0])
|
||||||
SettingsStore.setElrondAddress(elrondAddresses[0])
|
SettingsStore.setMultiversxAddress(multiversxAddresses[0])
|
||||||
prevRelayerURLValue.current = relayerRegionURL
|
prevRelayerURLValue.current = relayerRegionURL
|
||||||
|
|
||||||
await createWeb3Wallet(relayerRegionURL)
|
await createWeb3Wallet(relayerRegionURL)
|
||||||
|
@ -2,7 +2,7 @@ import { COSMOS_SIGNING_METHODS } from '@/data/COSMOSData'
|
|||||||
import { EIP155_SIGNING_METHODS } from '@/data/EIP155Data'
|
import { EIP155_SIGNING_METHODS } from '@/data/EIP155Data'
|
||||||
import { SOLANA_SIGNING_METHODS } from '@/data/SolanaData'
|
import { SOLANA_SIGNING_METHODS } from '@/data/SolanaData'
|
||||||
import { POLKADOT_SIGNING_METHODS } from '@/data/PolkadotData'
|
import { POLKADOT_SIGNING_METHODS } from '@/data/PolkadotData'
|
||||||
import { ELROND_SIGNING_METHODS } from '@/data/ElrondData'
|
import { MULTIVERSX_SIGNING_METHODS } from '@/data/MultiversxData'
|
||||||
import ModalStore from '@/store/ModalStore'
|
import ModalStore from '@/store/ModalStore'
|
||||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||||
import { SignClientTypes } from '@walletconnect/types'
|
import { SignClientTypes } from '@walletconnect/types'
|
||||||
@ -72,11 +72,12 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
|
|||||||
case NEAR_SIGNING_METHODS.NEAR_VERIFY_OWNER:
|
case NEAR_SIGNING_METHODS.NEAR_VERIFY_OWNER:
|
||||||
return ModalStore.open('SessionSignNearModal', { requestEvent, requestSession })
|
return ModalStore.open('SessionSignNearModal', { requestEvent, requestSession })
|
||||||
|
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_MESSAGE:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_MESSAGE:
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTION:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTION:
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTIONS:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTIONS:
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_LOGIN_TOKEN:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_LOGIN_TOKEN:
|
||||||
return ModalStore.open('SessionSignElrondModal', { requestEvent, requestSession })
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN:
|
||||||
|
return ModalStore.open('SessionSignMultiversxModal', { requestEvent, requestSession })
|
||||||
|
|
||||||
case NEAR_SIGNING_METHODS.NEAR_GET_ACCOUNTS:
|
case NEAR_SIGNING_METHODS.NEAR_GET_ACCOUNTS:
|
||||||
return web3wallet.respondSessionRequest({
|
return web3wallet.respondSessionRequest({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Transaction, SignableMessage } from '@elrondnetwork/erdjs'
|
import { Transaction, SignableMessage } from '@multiversx/sdk-core'
|
||||||
import { Mnemonic, UserSecretKey, UserWallet, UserSigner } from '@elrondnetwork/erdjs-walletcore'
|
import { Mnemonic, UserSecretKey, UserWallet, UserSigner } from '@multiversx/sdk-wallet'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types
|
* Types
|
||||||
@ -11,7 +11,7 @@ interface IInitArgs {
|
|||||||
/**
|
/**
|
||||||
* Library
|
* Library
|
||||||
*/
|
*/
|
||||||
export default class ElrondLib {
|
export default class MultiversxLib {
|
||||||
wallet: UserWallet
|
wallet: UserWallet
|
||||||
mnemonic: Mnemonic
|
mnemonic: Mnemonic
|
||||||
password: string
|
password: string
|
||||||
@ -20,16 +20,16 @@ export default class ElrondLib {
|
|||||||
this.mnemonic = mnemonic
|
this.mnemonic = mnemonic
|
||||||
this.password = 'password' // test purposes only
|
this.password = 'password' // test purposes only
|
||||||
|
|
||||||
const secretKey = mnemonic.deriveKey(0)
|
this.wallet = UserWallet.fromMnemonic({
|
||||||
const secretKeyHex = secretKey.hex()
|
password: this.password,
|
||||||
let fromHex = UserSecretKey.fromString(secretKeyHex)
|
mnemonic: mnemonic.toString()
|
||||||
this.wallet = new UserWallet(fromHex, this.password)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static init({ mnemonic }: IInitArgs) {
|
static init({ mnemonic }: IInitArgs) {
|
||||||
const mnemonicObj = mnemonic ? Mnemonic.fromString(mnemonic) : Mnemonic.generate()
|
const mnemonicObj = mnemonic ? Mnemonic.fromString(mnemonic) : Mnemonic.generate()
|
||||||
|
|
||||||
return new ElrondLib(mnemonicObj)
|
return new MultiversxLib(mnemonicObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
getMnemonic() {
|
getMnemonic() {
|
||||||
@ -54,9 +54,9 @@ export default class ElrondLib {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
||||||
await signer.sign(signMessage)
|
const signature = await signer.sign(signMessage.serializeForSigning())
|
||||||
|
|
||||||
return { signature: signMessage.signature.hex() }
|
return { signature: signature.toString('hex') }
|
||||||
}
|
}
|
||||||
|
|
||||||
async signTransaction(transaction: any) {
|
async signTransaction(transaction: any) {
|
||||||
@ -66,9 +66,9 @@ export default class ElrondLib {
|
|||||||
const signTransaction = Transaction.fromPlainObject(transaction)
|
const signTransaction = Transaction.fromPlainObject(transaction)
|
||||||
|
|
||||||
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
||||||
await signer.sign(signTransaction)
|
const signature = await signer.sign(signTransaction.serializeForSigning(signer.getAddress()))
|
||||||
|
|
||||||
return { signature: signTransaction.getSignature().hex() }
|
return { signature: signature.toString('hex') }
|
||||||
}
|
}
|
||||||
|
|
||||||
async signTransactions(transactions: any[]) {
|
async signTransactions(transactions: any[]) {
|
||||||
@ -79,9 +79,11 @@ export default class ElrondLib {
|
|||||||
transactions.map(async (transaction: any): Promise<any> => {
|
transactions.map(async (transaction: any): Promise<any> => {
|
||||||
const signTransaction = Transaction.fromPlainObject(transaction)
|
const signTransaction = Transaction.fromPlainObject(transaction)
|
||||||
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
||||||
await signer.sign(signTransaction)
|
const signature = await signer.sign(
|
||||||
|
signTransaction.serializeForSigning(signer.getAddress())
|
||||||
|
)
|
||||||
|
|
||||||
return { signature: signTransaction.getSignature().hex() }
|
return { signature: signature.toString('hex') }
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
@ -5,7 +5,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
|
|||||||
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
||||||
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
||||||
import { POLKADOT_MAINNET_CHAINS, POLKADOT_TEST_CHAINS } from '@/data/PolkadotData'
|
import { POLKADOT_MAINNET_CHAINS, POLKADOT_TEST_CHAINS } from '@/data/PolkadotData'
|
||||||
import { ELROND_MAINNET_CHAINS, ELROND_TEST_CHAINS } from '@/data/ElrondData'
|
import { MULTIVERSX_MAINNET_CHAINS, MULTIVERSX_TEST_CHAINS } from '@/data/MultiversxData'
|
||||||
import SettingsStore from '@/store/SettingsStore'
|
import SettingsStore from '@/store/SettingsStore'
|
||||||
import { Text } from '@nextui-org/react'
|
import { Text } from '@nextui-org/react'
|
||||||
import { Fragment } from 'react'
|
import { Fragment } from 'react'
|
||||||
@ -20,7 +20,7 @@ export default function HomePage() {
|
|||||||
solanaAddress,
|
solanaAddress,
|
||||||
polkadotAddress,
|
polkadotAddress,
|
||||||
nearAddress,
|
nearAddress,
|
||||||
elrondAddress
|
multiversxAddress
|
||||||
} = useSnapshot(SettingsStore.state)
|
} = useSnapshot(SettingsStore.state)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -43,8 +43,8 @@ export default function HomePage() {
|
|||||||
{Object.values(POLKADOT_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
{Object.values(POLKADOT_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={polkadotAddress} />
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={polkadotAddress} />
|
||||||
))}
|
))}
|
||||||
{Object.values(ELROND_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
{Object.values(MULTIVERSX_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={elrondAddress} />
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={multiversxAddress} />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{testNets ? (
|
{testNets ? (
|
||||||
@ -64,8 +64,8 @@ export default function HomePage() {
|
|||||||
{Object.values(NEAR_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
{Object.values(NEAR_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={nearAddress} />
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={nearAddress} />
|
||||||
))}
|
))}
|
||||||
{Object.values(ELROND_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
{Object.values(MULTIVERSX_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
||||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={elrondAddress} />
|
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={multiversxAddress} />
|
||||||
))}
|
))}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -4,14 +4,14 @@ import SettingsStore from '@/store/SettingsStore'
|
|||||||
import { cosmosWallets } from '@/utils/CosmosWalletUtil'
|
import { cosmosWallets } from '@/utils/CosmosWalletUtil'
|
||||||
import { eip155Wallets } from '@/utils/EIP155WalletUtil'
|
import { eip155Wallets } from '@/utils/EIP155WalletUtil'
|
||||||
import { solanaWallets } from '@/utils/SolanaWalletUtil'
|
import { solanaWallets } from '@/utils/SolanaWalletUtil'
|
||||||
import { elrondWallets } from '@/utils/ElrondWalletUtil'
|
import { multiversxWallets } from '@/utils/MultiversxWalletUtil'
|
||||||
import { Card, Divider, Row, Switch, Text } from '@nextui-org/react'
|
import { Card, Divider, Row, Switch, Text } from '@nextui-org/react'
|
||||||
import { Fragment } from 'react'
|
import { Fragment } from 'react'
|
||||||
import { useSnapshot } from 'valtio'
|
import { useSnapshot } from 'valtio'
|
||||||
import packageJSON from '../../package.json'
|
import packageJSON from '../../package.json'
|
||||||
|
|
||||||
export default function SettingsPage() {
|
export default function SettingsPage() {
|
||||||
const { testNets, eip155Address, cosmosAddress, solanaAddress, elrondAddress } = useSnapshot(
|
const { testNets, eip155Address, cosmosAddress, solanaAddress, multiversxAddress } = useSnapshot(
|
||||||
SettingsStore.state
|
SettingsStore.state
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -83,10 +83,10 @@ export default function SettingsPage() {
|
|||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Text h4 css={{ marginTop: '$10', marginBottom: '$5' }}>
|
<Text h4 css={{ marginTop: '$10', marginBottom: '$5' }}>
|
||||||
Elrond Mnemonic
|
MultiversX Mnemonic
|
||||||
</Text>
|
</Text>
|
||||||
<Card bordered borderWeight="light" css={{ minHeight: '215px', wordWrap: 'break-word' }}>
|
<Card bordered borderWeight="light" css={{ minHeight: '215px', wordWrap: 'break-word' }}>
|
||||||
<Text css={{ fontFamily: '$mono' }}>{elrondWallets[elrondAddress].getMnemonic()}</Text>
|
<Text css={{ fontFamily: '$mono' }}>{multiversxWallets[multiversxAddress].getMnemonic()}</Text>
|
||||||
</Card>
|
</Card>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
|
@ -24,7 +24,7 @@ interface State {
|
|||||||
| 'SessionSignSolanaModal'
|
| 'SessionSignSolanaModal'
|
||||||
| 'SessionSignPolkadotModal'
|
| 'SessionSignPolkadotModal'
|
||||||
| 'SessionSignNearModal'
|
| 'SessionSignNearModal'
|
||||||
| 'SessionSignElrondModal'
|
| 'SessionSignMultiversxModal'
|
||||||
| 'AuthRequestModal'
|
| 'AuthRequestModal'
|
||||||
data?: ModalData
|
data?: ModalData
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ interface State {
|
|||||||
solanaAddress: string
|
solanaAddress: string
|
||||||
polkadotAddress: string
|
polkadotAddress: string
|
||||||
nearAddress: string
|
nearAddress: string
|
||||||
elrondAddress: string
|
multiversxAddress: string
|
||||||
relayerRegionURL: string
|
relayerRegionURL: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ const state = proxy<State>({
|
|||||||
solanaAddress: '',
|
solanaAddress: '',
|
||||||
polkadotAddress: '',
|
polkadotAddress: '',
|
||||||
nearAddress: '',
|
nearAddress: '',
|
||||||
elrondAddress: '',
|
multiversxAddress: '',
|
||||||
relayerRegionURL: ''
|
relayerRegionURL: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -62,8 +62,8 @@ const SettingsStore = {
|
|||||||
state.relayerRegionURL = relayerRegionURL
|
state.relayerRegionURL = relayerRegionURL
|
||||||
},
|
},
|
||||||
|
|
||||||
setElrondAddress(elrondAddress: string) {
|
setMultiversxAddress(multiversxAddress: string) {
|
||||||
state.elrondAddress = elrondAddress
|
state.multiversxAddress = multiversxAddress
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleTestNets() {
|
toggleTestNets() {
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
import ElrondLib from '@/lib/ElrondLib'
|
|
||||||
|
|
||||||
export let wallet1: ElrondLib
|
|
||||||
export let wallet2: ElrondLib
|
|
||||||
export let elrondWallets: Record<string, ElrondLib>
|
|
||||||
export let elrondAddresses: string[]
|
|
||||||
|
|
||||||
let address1: string
|
|
||||||
let address2: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utilities
|
|
||||||
*/
|
|
||||||
export async function createOrRestoreElrondWallet() {
|
|
||||||
const mnemonic1 = localStorage.getItem('ELROND_MNEMONIC_1')
|
|
||||||
const mnemonic2 = localStorage.getItem('ELROND_MNEMONIC_2')
|
|
||||||
|
|
||||||
if (mnemonic1 && mnemonic2) {
|
|
||||||
wallet1 = await ElrondLib.init({ mnemonic: mnemonic1 })
|
|
||||||
wallet2 = await ElrondLib.init({ mnemonic: mnemonic2 })
|
|
||||||
} else {
|
|
||||||
wallet1 = await ElrondLib.init({})
|
|
||||||
wallet2 = await ElrondLib.init({})
|
|
||||||
|
|
||||||
// Don't store mnemonic in local storage in a production project!
|
|
||||||
localStorage.setItem('ELROND_MNEMONIC_1', wallet1.getMnemonic())
|
|
||||||
localStorage.setItem('ELROND_MNEMONIC_2', wallet2.getMnemonic())
|
|
||||||
}
|
|
||||||
|
|
||||||
address1 = await wallet1.getAddress()
|
|
||||||
address2 = await wallet2.getAddress()
|
|
||||||
|
|
||||||
elrondWallets = {
|
|
||||||
[address1]: wallet1,
|
|
||||||
[address2]: wallet2
|
|
||||||
}
|
|
||||||
elrondAddresses = Object.keys(elrondWallets)
|
|
||||||
|
|
||||||
return {
|
|
||||||
elrondWallets,
|
|
||||||
elrondAddresses
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,7 @@ import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData'
|
|||||||
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
|
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
|
||||||
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
||||||
import { SOLANA_CHAINS, TSolanaChain } from '@/data/SolanaData'
|
import { SOLANA_CHAINS, TSolanaChain } from '@/data/SolanaData'
|
||||||
import { ELROND_CHAINS, TElrondChain } from '@/data/ElrondData'
|
import { MULTIVERSX_CHAINS, TMultiversxChain } from '@/data/MultiversxData'
|
||||||
import { utils } from 'ethers'
|
import { utils } from 'ethers'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,10 +111,10 @@ export function isNearChain(chain: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if chain is part of ELROND standard
|
* Check if chain is part of MULTIVERSX standard
|
||||||
*/
|
*/
|
||||||
export function isElrondChain(chain: string) {
|
export function isMultiversxChain(chain: string) {
|
||||||
return chain.includes('elrond')
|
return chain.includes('mvx')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +126,7 @@ export function formatChainName(chainId: string) {
|
|||||||
COSMOS_MAINNET_CHAINS[chainId as TCosmosChain]?.name ??
|
COSMOS_MAINNET_CHAINS[chainId as TCosmosChain]?.name ??
|
||||||
SOLANA_CHAINS[chainId as TSolanaChain]?.name ??
|
SOLANA_CHAINS[chainId as TSolanaChain]?.name ??
|
||||||
NEAR_TEST_CHAINS[chainId as TNearChain]?.name ??
|
NEAR_TEST_CHAINS[chainId as TNearChain]?.name ??
|
||||||
ELROND_CHAINS[chainId as TElrondChain]?.name ??
|
MULTIVERSX_CHAINS[chainId as TMultiversxChain]?.name ??
|
||||||
chainId
|
chainId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,41 @@
|
|||||||
import { ELROND_SIGNING_METHODS } from '@/data/ElrondData'
|
import { MULTIVERSX_SIGNING_METHODS } from '@/data/MultiversxData'
|
||||||
import { getWalletAddressFromParams } from '@/utils/HelperUtil'
|
import { getWalletAddressFromParams } from '@/utils/HelperUtil'
|
||||||
import { elrondAddresses, elrondWallets } from '@/utils/ElrondWalletUtil'
|
import { multiversxAddresses, multiversxWallets } from '@/utils/MultiversxWalletUtil'
|
||||||
import { formatJsonRpcError, formatJsonRpcResult } from '@json-rpc-tools/utils'
|
import { formatJsonRpcError, formatJsonRpcResult } from '@json-rpc-tools/utils'
|
||||||
import { SignClientTypes } from '@walletconnect/types'
|
import { SignClientTypes } from '@walletconnect/types'
|
||||||
import { getSdkError } from '@walletconnect/utils'
|
import { getSdkError } from '@walletconnect/utils'
|
||||||
|
|
||||||
export async function approveElrondRequest(
|
export async function approveMultiversxRequest(
|
||||||
requestEvent: SignClientTypes.EventArguments['session_request']
|
requestEvent: SignClientTypes.EventArguments['session_request']
|
||||||
) {
|
) {
|
||||||
const { params, id } = requestEvent
|
const { params, id } = requestEvent
|
||||||
const { request } = params
|
const { request } = params
|
||||||
const account = getWalletAddressFromParams(elrondAddresses, params)
|
const account = getWalletAddressFromParams(multiversxAddresses, params)
|
||||||
const wallet = elrondWallets[account]
|
const wallet = multiversxWallets[account]
|
||||||
|
|
||||||
switch (request.method) {
|
switch (request.method) {
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_MESSAGE:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_MESSAGE:
|
||||||
const signedMessage = await wallet.signMessage(request.params.message)
|
const signedMessage = await wallet.signMessage(request.params.message)
|
||||||
return formatJsonRpcResult(id, signedMessage)
|
return formatJsonRpcResult(id, signedMessage)
|
||||||
|
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTION:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTION:
|
||||||
const signTransaction = request.params.transaction
|
const signTransaction = request.params.transaction
|
||||||
// Transactions must be signed with the Sender's Private Key before submitting them to the Elrond Network.
|
// Transactions must be signed with the Sender's Private Key before submitting them to the Multiversx Network.
|
||||||
// Signing is performed with the Ed25519 algorithm.
|
// Signing is performed with the Ed25519 algorithm.
|
||||||
const signature = await wallet.signTransaction(signTransaction)
|
const signature = await wallet.signTransaction(signTransaction)
|
||||||
|
|
||||||
return formatJsonRpcResult(id, signature)
|
return formatJsonRpcResult(id, signature)
|
||||||
|
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTIONS:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTIONS:
|
||||||
// Elrond Allows for a Batch of Transactions to be signed
|
// Multiversx Allows for a Batch of Transactions to be signed
|
||||||
const signTransactions = request.params.transactions
|
const signTransactions = request.params.transactions
|
||||||
|
|
||||||
const signatures = await wallet.signTransactions(signTransactions)
|
const signatures = await wallet.signTransactions(signTransactions)
|
||||||
return formatJsonRpcResult(id, signatures)
|
return formatJsonRpcResult(id, signatures)
|
||||||
|
|
||||||
case ELROND_SIGNING_METHODS.ELROND_SIGN_LOGIN_TOKEN:
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_LOGIN_TOKEN:
|
||||||
// Sometimes a dApp (and its backend) might want to reliably assign an off-chain user identity to an Elrond address.
|
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN:
|
||||||
|
// Sometimes a dApp (and its backend) might want to reliably assign an off-chain user identity to a MultiversX address.
|
||||||
// On this purpose, the signing providers allow a login token to be used within the login flow - this token is signed using the wallet of the user.
|
// On this purpose, the signing providers allow a login token to be used within the login flow - this token is signed using the wallet of the user.
|
||||||
// Afterwards, a backend application would normally verify the signature of the token
|
// Afterwards, a backend application would normally verify the signature of the token
|
||||||
const message = `${account}${request.params.token}{}`
|
const message = `${account}${request.params.token}{}`
|
||||||
@ -47,7 +48,9 @@ export async function approveElrondRequest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rejectElrondRequest(request: SignClientTypes.EventArguments['session_request']) {
|
export function rejectMultiversxRequest(
|
||||||
|
request: SignClientTypes.EventArguments['session_request']
|
||||||
|
) {
|
||||||
const { id } = request
|
const { id } = request
|
||||||
|
|
||||||
return formatJsonRpcError(id, getSdkError('USER_REJECTED_METHODS').message)
|
return formatJsonRpcError(id, getSdkError('USER_REJECTED_METHODS').message)
|
43
wallets/react-web3wallet/src/utils/MultiversxWalletUtil.ts
Normal file
43
wallets/react-web3wallet/src/utils/MultiversxWalletUtil.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import MultiversxLib from '@/lib/MultiversxLib'
|
||||||
|
|
||||||
|
export let wallet1: MultiversxLib
|
||||||
|
export let wallet2: MultiversxLib
|
||||||
|
export let multiversxWallets: Record<string, MultiversxLib>
|
||||||
|
export let multiversxAddresses: string[]
|
||||||
|
|
||||||
|
let address1: string
|
||||||
|
let address2: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities
|
||||||
|
*/
|
||||||
|
export async function createOrRestoreMultiversxWallet() {
|
||||||
|
const mnemonic1 = localStorage.getItem('MULTIVERSX_MNEMONIC_1')
|
||||||
|
const mnemonic2 = localStorage.getItem('MULTIVERSX_MNEMONIC_2')
|
||||||
|
|
||||||
|
if (mnemonic1 && mnemonic2) {
|
||||||
|
wallet1 = await MultiversxLib.init({ mnemonic: mnemonic1 })
|
||||||
|
wallet2 = await MultiversxLib.init({ mnemonic: mnemonic2 })
|
||||||
|
} else {
|
||||||
|
wallet1 = await MultiversxLib.init({})
|
||||||
|
wallet2 = await MultiversxLib.init({})
|
||||||
|
|
||||||
|
// Don't store mnemonic in local storage in a production project!
|
||||||
|
localStorage.setItem('MULTIVERSX_MNEMONIC_1', wallet1.getMnemonic())
|
||||||
|
localStorage.setItem('MULTIVERSX_MNEMONIC_2', wallet2.getMnemonic())
|
||||||
|
}
|
||||||
|
|
||||||
|
address1 = await wallet1.getAddress()
|
||||||
|
address2 = await wallet2.getAddress()
|
||||||
|
|
||||||
|
multiversxWallets = {
|
||||||
|
[address1]: wallet1,
|
||||||
|
[address2]: wallet2
|
||||||
|
}
|
||||||
|
multiversxAddresses = Object.keys(multiversxWallets)
|
||||||
|
|
||||||
|
return {
|
||||||
|
multiversxWallets,
|
||||||
|
multiversxAddresses
|
||||||
|
}
|
||||||
|
}
|
@ -6,14 +6,14 @@ import ModalStore from '@/store/ModalStore'
|
|||||||
import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
|
import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
|
||||||
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
|
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
|
||||||
import { polkadotAddresses } from '@/utils/PolkadotWalletUtil'
|
import { polkadotAddresses } from '@/utils/PolkadotWalletUtil'
|
||||||
import { elrondAddresses } from '@/utils/ElrondWalletUtil'
|
import { multiversxAddresses } from '@/utils/MultiversxWalletUtil'
|
||||||
import {
|
import {
|
||||||
isCosmosChain,
|
isCosmosChain,
|
||||||
isEIP155Chain,
|
isEIP155Chain,
|
||||||
isSolanaChain,
|
isSolanaChain,
|
||||||
isPolkadotChain,
|
isPolkadotChain,
|
||||||
isNearChain,
|
isNearChain,
|
||||||
isElrondChain
|
isMultiversxChain
|
||||||
} from '@/utils/HelperUtil'
|
} from '@/utils/HelperUtil'
|
||||||
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
|
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
|
||||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||||
@ -139,10 +139,10 @@ export default function SessionProposalModal() {
|
|||||||
chain={chain}
|
chain={chain}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
} else if (isElrondChain(chain)) {
|
} else if (isMultiversxChain(chain)) {
|
||||||
return (
|
return (
|
||||||
<ProposalSelectSection
|
<ProposalSelectSection
|
||||||
addresses={elrondAddresses}
|
addresses={multiversxAddresses}
|
||||||
selectedAddresses={selectedAccounts[chain]}
|
selectedAddresses={selectedAccounts[chain]}
|
||||||
onSelect={onSelectAccount}
|
onSelect={onSelectAccount}
|
||||||
chain={chain}
|
chain={chain}
|
||||||
|
@ -4,12 +4,12 @@ import RequesDetailsCard from '@/components/RequestDetalilsCard'
|
|||||||
import RequestMethodCard from '@/components/RequestMethodCard'
|
import RequestMethodCard from '@/components/RequestMethodCard'
|
||||||
import RequestModalContainer from '@/components/RequestModalContainer'
|
import RequestModalContainer from '@/components/RequestModalContainer'
|
||||||
import ModalStore from '@/store/ModalStore'
|
import ModalStore from '@/store/ModalStore'
|
||||||
import { approveElrondRequest, rejectElrondRequest } from '@/utils/ElrondRequestHandlerUtil'
|
import { approveMultiversxRequest, rejectMultiversxRequest } from '@/utils/MultiversxRequestHandlerUtil'
|
||||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||||
import { Fragment } from 'react'
|
import { Fragment } from 'react'
|
||||||
|
|
||||||
export default function SessionSignElrondModal() {
|
export default function SessionSignMultiversxModal() {
|
||||||
// Get request and wallet data from store
|
// Get request and wallet data from store
|
||||||
const requestEvent = ModalStore.state.data?.requestEvent
|
const requestEvent = ModalStore.state.data?.requestEvent
|
||||||
const requestSession = ModalStore.state.data?.requestSession
|
const requestSession = ModalStore.state.data?.requestSession
|
||||||
@ -26,7 +26,7 @@ export default function SessionSignElrondModal() {
|
|||||||
// Handle approve action (logic varies based on request method)
|
// Handle approve action (logic varies based on request method)
|
||||||
async function onApprove() {
|
async function onApprove() {
|
||||||
if (requestEvent) {
|
if (requestEvent) {
|
||||||
const response = await approveElrondRequest(requestEvent)
|
const response = await approveMultiversxRequest(requestEvent)
|
||||||
await web3wallet.respondSessionRequest({
|
await web3wallet.respondSessionRequest({
|
||||||
topic,
|
topic,
|
||||||
response
|
response
|
||||||
@ -38,7 +38,7 @@ export default function SessionSignElrondModal() {
|
|||||||
// Handle reject action
|
// Handle reject action
|
||||||
async function onReject() {
|
async function onReject() {
|
||||||
if (requestEvent) {
|
if (requestEvent) {
|
||||||
const response = rejectElrondRequest(requestEvent)
|
const response = rejectMultiversxRequest(requestEvent)
|
||||||
await web3wallet.respondSessionRequest({
|
await web3wallet.respondSessionRequest({
|
||||||
topic,
|
topic,
|
||||||
response
|
response
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user