refactor: Elrond rebranding to MultiversX (#148)

This commit is contained in:
Radu Mojic 2023-05-30 10:13:49 +03:00 committed by GitHub
parent 5d579166cb
commit a60069941f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 3711 additions and 3469 deletions

View File

@ -11,8 +11,8 @@
},
"dependencies": {
"@celo/wallet-base": "^3.0.1",
"@elrondnetwork/erdjs": "11.1.1",
"@elrondnetwork/erdjs-walletcore": "2.1.0",
"@multiversx/sdk-core": "11.5.0",
"@multiversx/sdk-wallet": "4.0.0",
"@ethereumjs/tx": "^3.5.0",
"@polkadot/util-crypto": "^10.1.2",
"@solana/web3.js": "^1.36.0",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

View 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

View File

@ -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;
}

View File

@ -5,7 +5,7 @@ import * as cosmos from "./cosmos";
import * as polkadot from "./polkadot";
import * as solana from "./solana";
import * as near from "./near";
import * as elrond from "./elrond";
import * as multiversx from "./multiversx";
import * as tron from "./tron";
import * as tezos from "./tezos";
@ -24,8 +24,8 @@ export function getChainMetadata(chainId: string): ChainMetadata {
return solana.getChainMetadata(chainId);
case "near":
return near.getChainMetadata(chainId);
case "elrond":
return elrond.getChainMetadata(chainId);
case "mvx":
return multiversx.getChainMetadata(chainId);
case "tron":
return tron.getChainMetadata(chainId);
case "tezos":

View 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;
}

View File

@ -12,7 +12,7 @@ export const DEFAULT_MAIN_CHAINS = [
"cosmos:cosmoshub-4",
"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",
"polkadot:91b171bb158e2d3848fa23a9f1c25182",
"elrond:1",
"mvx:1",
"tron:0x2b6653dc",
"tezos:mainnet",
];
@ -27,7 +27,7 @@ export const DEFAULT_TEST_CHAINS = [
"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K",
"polkadot:e143f23803ac50e8f6f8e62695d1ce9e",
"near:testnet",
"elrond:D",
"mvx:D",
"tron:0xcd8690dc",
"tezos:testnet",
];
@ -106,16 +106,17 @@ export enum DEFAULT_NEAR_METHODS {
export enum DEFAULT_NEAR_EVENTS {}
/**
* ELROND
* MULTIVERSX
*/
export enum DEFAULT_ELROND_METHODS {
ELROND_SIGN_TRANSACTION = "erd_signTransaction",
ELROND_SIGN_TRANSACTIONS = "erd_signTransactions",
ELROND_SIGN_MESSAGE = "erd_signMessage",
ELROND_SIGN_LOGIN_TOKEN = "erd_signLoginToken",
export enum DEFAULT_MULTIVERSX_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",
}
export enum DEFAULT_ELROND_EVENTS {}
export enum DEFAULT_MULTIVERSX_EVENTS {}
/**
* TRON

View File

@ -7,7 +7,7 @@ import {
} from "react";
import { SolanaChainData } from "../chains/solana";
import { PolkadotChainData } from "../chains/polkadot";
import { ElrondChainData } from "../chains/elrond";
import { MultiversxChainData } from "../chains/multiversx";
import { TronChainData } from "../chains/tron";
import { ChainNamespaces, ChainsMap, getAllChainNamespaces } from "../helpers";
@ -54,8 +54,8 @@ export function ChainDataContextProvider({
case "near":
chains = NearChainData;
break;
case "elrond":
chains = ElrondChainData;
case "mvx":
chains = MultiversxChainData;
break;
case "tron":
chains = TronChainData;

View File

@ -35,7 +35,7 @@ import {
DEFAULT_SOLANA_METHODS,
DEFAULT_POLKADOT_METHODS,
DEFAULT_NEAR_METHODS,
DEFAULT_ELROND_METHODS,
DEFAULT_MULTIVERSX_METHODS,
DEFAULT_TRON_METHODS,
DEFAULT_TEZOS_METHODS,
} from "../constants";
@ -44,16 +44,12 @@ import { rpcProvidersByChainId } from "../../src/helpers/api";
import { signatureVerify, cryptoWaitReady } from "@polkadot/util-crypto";
import {
Transaction as ElrondTransaction,
Transaction as MultiversxTransaction,
TransactionPayload,
Address,
SignableMessage,
ISignature,
} from "@elrondnetwork/erdjs";
import { UserVerifier } from "@elrondnetwork/erdjs-walletcore/out/userVerifier";
import { Signature } from "@elrondnetwork/erdjs-walletcore/out/signature";
import { IVerifiable } from "@elrondnetwork/erdjs-walletcore/out/interface";
} from "@multiversx/sdk-core";
import { UserVerifier } from "@multiversx/sdk-wallet/out/userVerifier";
/**
* Types
@ -92,7 +88,7 @@ interface IContext {
testSignAndSendTransaction: TRpcRequestCallback;
testSignAndSendTransactions: TRpcRequestCallback;
};
elrondRpc: {
multiversxRpc: {
testSignMessage: TRpcRequestCallback;
testSignTransaction: TRpcRequestCallback;
testSignTransactions: TRpcRequestCallback;
@ -881,9 +877,9 @@ export function JsonRpcContextProvider({
),
};
// -------- ELROND RPC METHODS --------
// -------- MULTIVERSX RPC METHODS --------
const elrondRpc = {
const multiversxRpc = {
testSignTransaction: _createJsonRpcRequestHandler(
async (
chainId: string,
@ -895,7 +891,7 @@ export function JsonRpcContextProvider({
const verifier = UserVerifier.fromAddress(userAddress);
const transactionPayload = new TransactionPayload("testdata");
const testTransaction = new ElrondTransaction({
const testTransaction = new MultiversxTransaction({
nonce: 1,
value: "10000000000000000000",
receiver: Address.fromBech32(address),
@ -912,22 +908,20 @@ export function JsonRpcContextProvider({
chainId,
topic: session!.topic,
request: {
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTION,
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTION,
params: {
transaction,
},
},
});
testTransaction.applySignature(
new Signature(result.signature),
userAddress
const valid = verifier.verify(
testTransaction.serializeForSigning(Address.fromBech32(address)),
result.signature
);
const valid = verifier.verify(testTransaction as IVerifiable);
return {
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTION,
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTION,
address,
valid,
result: result.signature.toString(),
@ -948,7 +942,7 @@ export function JsonRpcContextProvider({
const verifier = UserVerifier.fromAddress(userAddress);
const testTransactionPayload = new TransactionPayload("testdata");
const testTransaction = new ElrondTransaction({
const testTransaction = new MultiversxTransaction({
nonce: 1,
value: "10000000000000000000",
receiver: Address.fromBech32(address),
@ -960,7 +954,7 @@ export function JsonRpcContextProvider({
});
// no data for this Transaction
const testTransaction2 = new ElrondTransaction({
const testTransaction2 = new MultiversxTransaction({
nonce: 2,
value: "20000000000000000000",
receiver: Address.fromBech32(address),
@ -971,7 +965,7 @@ export function JsonRpcContextProvider({
});
const testTransaction3Payload = new TransactionPayload("third");
const testTransaction3 = new ElrondTransaction({
const testTransaction3 = new MultiversxTransaction({
nonce: 3,
value: "300000000000000000",
receiver: Address.fromBech32(address),
@ -995,7 +989,7 @@ export function JsonRpcContextProvider({
chainId,
topic: session!.topic,
request: {
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTIONS,
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTIONS,
params: {
transactions,
},
@ -1007,12 +1001,13 @@ export function JsonRpcContextProvider({
testTransaction2,
testTransaction3,
].reduce((acc, current, index) => {
current.applySignature(
new Signature(result.signatures[index].signature),
userAddress
return (
acc &&
verifier.verify(
current.serializeForSigning(Address.fromBech32(address)),
result.signatures[index].signature
)
);
return acc && verifier.verify(current as IVerifiable);
}, true);
const resultSignatures = result.signatures.map(
@ -1020,7 +1015,7 @@ export function JsonRpcContextProvider({
);
return {
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTIONS,
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTIONS,
address,
valid,
result: resultSignatures.join(", "),
@ -1048,7 +1043,7 @@ export function JsonRpcContextProvider({
chainId,
topic: session!.topic,
request: {
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_MESSAGE,
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_MESSAGE,
params: {
address,
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 {
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_MESSAGE,
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_MESSAGE,
address,
valid,
result: result.signature.toString(),
@ -1274,7 +1271,7 @@ export function JsonRpcContextProvider({
solanaRpc,
polkadotRpc,
nearRpc,
elrondRpc,
multiversxRpc,
tronRpc,
tezosRpc,
rpcResult: result,

View File

@ -10,8 +10,8 @@ import {
DEFAULT_POLKADOT_METHODS,
DEFAULT_NEAR_METHODS,
DEFAULT_NEAR_EVENTS,
DEFAULT_ELROND_EVENTS,
DEFAULT_ELROND_METHODS,
DEFAULT_MULTIVERSX_EVENTS,
DEFAULT_MULTIVERSX_METHODS,
DEFAULT_TRON_METHODS,
DEFAULT_TRON_EVENTS,
DEFAULT_TEZOS_METHODS,
@ -42,8 +42,8 @@ export const getSupportedMethodsByNamespace = (namespace: string) => {
return Object.values(DEFAULT_POLKADOT_METHODS);
case "near":
return Object.values(DEFAULT_NEAR_METHODS);
case "elrond":
return Object.values(DEFAULT_ELROND_METHODS);
case "mvx":
return Object.values(DEFAULT_MULTIVERSX_METHODS);
case "tron":
return Object.values(DEFAULT_TRON_METHODS);
case "tezos":
@ -65,8 +65,8 @@ export const getSupportedEventsByNamespace = (namespace: string) => {
return Object.values(DEFAULT_POLKADOT_EVENTS);
case "near":
return Object.values(DEFAULT_NEAR_EVENTS);
case "elrond":
return Object.values(DEFAULT_ELROND_EVENTS);
case "mvx":
return Object.values(DEFAULT_MULTIVERSX_EVENTS);
case "tron":
return Object.values(DEFAULT_TRON_EVENTS);
case "tezos":

View File

@ -13,7 +13,7 @@ import {
DEFAULT_MAIN_CHAINS,
DEFAULT_SOLANA_METHODS,
DEFAULT_POLKADOT_METHODS,
DEFAULT_ELROND_METHODS,
DEFAULT_MULTIVERSX_METHODS,
DEFAULT_TEST_CHAINS,
DEFAULT_NEAR_METHODS,
DEFAULT_TRON_METHODS,
@ -74,7 +74,7 @@ const Home: NextPage = () => {
solanaRpc,
polkadotRpc,
nearRpc,
elrondRpc,
multiversxRpc,
tronRpc,
tezosRpc,
isRpcRequestPending,
@ -258,30 +258,30 @@ const Home: NextPage = () => {
];
};
const getElrondActions = (): AccountAction[] => {
const getMultiversxActions = (): AccountAction[] => {
const onSignTransaction = async (chainId: string, address: string) => {
openRequestModal();
await elrondRpc.testSignTransaction(chainId, address);
await multiversxRpc.testSignTransaction(chainId, address);
};
const onSignTransactions = async (chainId: string, address: string) => {
openRequestModal();
await elrondRpc.testSignTransactions(chainId, address);
await multiversxRpc.testSignTransactions(chainId, address);
};
const onSignMessage = async (chainId: string, address: string) => {
openRequestModal();
await elrondRpc.testSignMessage(chainId, address);
await multiversxRpc.testSignMessage(chainId, address);
};
return [
{
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTION,
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTION,
callback: onSignTransaction,
},
{
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_TRANSACTIONS,
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_TRANSACTIONS,
callback: onSignTransactions,
},
{
method: DEFAULT_ELROND_METHODS.ELROND_SIGN_MESSAGE,
method: DEFAULT_MULTIVERSX_METHODS.MULTIVERSX_SIGN_MESSAGE,
callback: onSignMessage,
},
];
@ -350,8 +350,8 @@ const Home: NextPage = () => {
return getPolkadotActions();
case "near":
return getNearActions();
case "elrond":
return getElrondActions();
case "mvx":
return getMultiversxActions();
case "tron":
return getTronActions();
case "tezos":

File diff suppressed because it is too large Load Diff

View File

@ -12,8 +12,8 @@
"@cosmjs/amino": "0.28.4",
"@cosmjs/encoding": "0.28.4",
"@cosmjs/proto-signing": "0.28.4",
"@elrondnetwork/erdjs": "11.1.1",
"@elrondnetwork/erdjs-walletcore": "2.1.0",
"@multiversx/sdk-core": "11.5.0",
"@multiversx/sdk-wallet": "4.0.0",
"@json-rpc-tools/utils": "1.7.6",
"@near-wallet-selector/wallet-utils": "^7.0.2",
"@nextui-org/react": "1.0.8-beta.5",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

View 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

View File

@ -3,7 +3,7 @@ import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
import { nearAddresses } from '@/utils/NearWalletUtil'
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
import { elrondAddresses } from '@/utils/ElrondWalletUtil'
import { multiversxAddresses } from '@/utils/MultiversxWalletUtil'
import { tronAddresses } from '@/utils/TronWalletUtil'
import { tezosAddresses } from '@/utils/TezosWalletUtil'
import { useSnapshot } from 'valtio'
@ -18,7 +18,7 @@ export default function AccountPicker() {
SettingsStore.setCosmosAddress(cosmosAddresses[account])
SettingsStore.setSolanaAddress(solanaAddresses[account])
SettingsStore.setNearAddress(nearAddresses[account])
SettingsStore.setElrondAddress(elrondAddresses[account])
SettingsStore.setMultiversxAddress(multiversxAddresses[account])
SettingsStore.setTronAddress(tronAddresses[account])
SettingsStore.setTezosAddress(tezosAddresses[account])
}

View File

@ -6,7 +6,7 @@ import SessionRequestModal from '@/views/SessionSignModal'
import SessionSignNearModal from '@/views/SessionSignNearModal'
import SessionSignPolkadotModal from '@/views/SessionSignPolkadotModal'
import SessionSignSolanaModal from '@/views/SessionSignSolanaModal'
import SessionSignElrondModal from '@/views/SessionSignElrondModal'
import SessionSignMultiversxModal from '@/views/SessionSignMultiversxModal'
import SessionSignTronModal from '@/views/SessionSignTronModal'
import SessionSignTezosModal from '@/views/SessionSignTezosModal'
import SessionSignTypedDataModal from '@/views/SessionSignTypedDataModal'
@ -32,7 +32,7 @@ export default function Modal() {
{view === 'SessionSignSolanaModal' && <SessionSignSolanaModal />}
{view === 'SessionSignPolkadotModal' && <SessionSignPolkadotModal />}
{view === 'SessionSignNearModal' && <SessionSignNearModal />}
{view === 'SessionSignElrondModal' && <SessionSignElrondModal />}
{view === 'SessionSignMultiversxModal' && <SessionSignMultiversxModal />}
{view === 'SessionSignTronModal' && <SessionSignTronModal />}
{view === 'SessionSignTezosModal' && <SessionSignTezosModal />}
{view === 'LegacySessionProposalModal' && <LegacySessionProposalModal />}

View File

@ -2,7 +2,7 @@ import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData'
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
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 { Col, Divider, Row, Text } from '@nextui-org/react'
import { Fragment } from 'react'
@ -32,7 +32,7 @@ export default function RequesDetailsCard({ chains, protocol }: IProps) {
COSMOS_MAINNET_CHAINS[chain as TCosmosChain]?.name ??
SOLANA_CHAINS[chain as TSolanaChain]?.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 ??
chain
)

View File

@ -3,7 +3,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
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 { formatChainName } from '@/utils/HelperUtil'
import { Col, Row, Text } from '@nextui-org/react'
@ -16,13 +16,13 @@ import { Fragment } from 'react'
const CHAIN_METADATA = {
...COSMOS_MAINNET_CHAINS,
...SOLANA_MAINNET_CHAINS,
...ELROND_MAINNET_CHAINS,
...MULTIVERSX_MAINNET_CHAINS,
...TRON_MAINNET_CHAINS,
...EIP155_MAINNET_CHAINS,
...EIP155_TEST_CHAINS,
...SOLANA_TEST_CHAINS,
...NEAR_TEST_CHAINS,
...ELROND_TEST_CHAINS,
...MULTIVERSX_TEST_CHAINS,
...TRON_TEST_CHAINS
}

View File

@ -3,7 +3,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
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 { formatChainName } from '@/utils/HelperUtil'
import { Col, Row, Text } from '@nextui-org/react'
@ -16,13 +16,13 @@ import { Fragment } from 'react'
const CHAIN_METADATA = {
...COSMOS_MAINNET_CHAINS,
...SOLANA_MAINNET_CHAINS,
...ELROND_MAINNET_CHAINS,
...MULTIVERSX_MAINNET_CHAINS,
...TRON_MAINNET_CHAINS,
...EIP155_MAINNET_CHAINS,
...EIP155_TEST_CHAINS,
...SOLANA_TEST_CHAINS,
...NEAR_TEST_CHAINS,
...ELROND_TEST_CHAINS,
...MULTIVERSX_TEST_CHAINS,
...TRON_TEST_CHAINS
}

View File

@ -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'
}

View 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'
}

View File

@ -3,7 +3,7 @@ import { createOrRestoreCosmosWallet } from '@/utils/CosmosWalletUtil'
import { createOrRestoreEIP155Wallet } from '@/utils/EIP155WalletUtil'
import { createOrRestoreSolanaWallet } from '@/utils/SolanaWalletUtil'
import { createOrRestorePolkadotWallet } from '@/utils/PolkadotWalletUtil'
import { createOrRestoreElrondWallet } from '@/utils/ElrondWalletUtil'
import { createOrRestoreMultiversxWallet } from '@/utils/MultiversxWalletUtil'
import { createOrRestoreTronWallet } from '@/utils/TronWalletUtil'
import { createOrRestoreTezosWallet } from '@/utils/TezosWalletUtil'
import { createSignClient, signClient } from '@/utils/WalletConnectUtil'
@ -24,7 +24,7 @@ export default function useInitialization() {
const { solanaAddresses } = await createOrRestoreSolanaWallet()
const { polkadotAddresses } = await createOrRestorePolkadotWallet()
const { nearAddresses } = await createOrRestoreNearWallet()
const { elrondAddresses } = await createOrRestoreElrondWallet()
const { multiversxAddresses } = await createOrRestoreMultiversxWallet()
const { tronAddresses } = await createOrRestoreTronWallet()
const { tezosAddresses } = await createOrRestoreTezosWallet()
@ -33,7 +33,7 @@ export default function useInitialization() {
SettingsStore.setSolanaAddress(solanaAddresses[0])
SettingsStore.setPolkadotAddress(polkadotAddresses[0])
SettingsStore.setNearAddress(nearAddresses[0])
SettingsStore.setElrondAddress(elrondAddresses[0])
SettingsStore.setMultiversxAddress(multiversxAddresses[0])
SettingsStore.setTronAddress(tronAddresses[0])
SettingsStore.setTezosAddress(tezosAddresses[0])
await createSignClient(relayerRegionURL)

View File

@ -2,7 +2,7 @@ import { COSMOS_SIGNING_METHODS } from '@/data/COSMOSData'
import { EIP155_SIGNING_METHODS } from '@/data/EIP155Data'
import { SOLANA_SIGNING_METHODS } from '@/data/SolanaData'
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 ModalStore from '@/store/ModalStore'
import { signClient } from '@/utils/WalletConnectUtil'
@ -68,11 +68,12 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
case NEAR_SIGNING_METHODS.NEAR_VERIFY_OWNER:
return ModalStore.open('SessionSignNearModal', { requestEvent, requestSession })
case ELROND_SIGNING_METHODS.ELROND_SIGN_MESSAGE:
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTION:
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTIONS:
case ELROND_SIGNING_METHODS.ELROND_SIGN_LOGIN_TOKEN:
return ModalStore.open('SessionSignElrondModal', { requestEvent, requestSession })
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_MESSAGE:
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTION:
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTIONS:
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_LOGIN_TOKEN:
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN:
return ModalStore.open('SessionSignMultiversxModal', { requestEvent, requestSession })
case NEAR_SIGNING_METHODS.NEAR_GET_ACCOUNTS:
return signClient.respond({

View File

@ -1,5 +1,5 @@
import { Transaction, SignableMessage } from '@elrondnetwork/erdjs'
import { Mnemonic, UserSecretKey, UserWallet, UserSigner } from '@elrondnetwork/erdjs-walletcore'
import { Transaction, SignableMessage } from '@multiversx/sdk-core'
import { Mnemonic, UserSecretKey, UserWallet, UserSigner } from '@multiversx/sdk-wallet'
/**
* Types
@ -11,7 +11,7 @@ interface IInitArgs {
/**
* Library
*/
export default class ElrondLib {
export default class MultiversxLib {
wallet: UserWallet
mnemonic: Mnemonic
password: string
@ -20,16 +20,16 @@ export default class ElrondLib {
this.mnemonic = mnemonic
this.password = 'password' // test purposes only
const secretKey = mnemonic.deriveKey(0)
const secretKeyHex = secretKey.hex()
let fromHex = UserSecretKey.fromString(secretKeyHex)
this.wallet = new UserWallet(fromHex, this.password)
this.wallet = UserWallet.fromMnemonic({
password: this.password,
mnemonic: mnemonic.toString()
})
}
static init({ mnemonic }: IInitArgs) {
const mnemonicObj = mnemonic ? Mnemonic.fromString(mnemonic) : Mnemonic.generate()
return new ElrondLib(mnemonicObj)
return new MultiversxLib(mnemonicObj)
}
getMnemonic() {
@ -54,9 +54,9 @@ export default class ElrondLib {
})
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) {
@ -66,9 +66,9 @@ export default class ElrondLib {
const signTransaction = Transaction.fromPlainObject(transaction)
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[]) {
@ -79,9 +79,11 @@ export default class ElrondLib {
transactions.map(async (transaction: any): Promise<any> => {
const signTransaction = Transaction.fromPlainObject(transaction)
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') }
})
)

View File

@ -5,7 +5,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
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 SettingsStore from '@/store/SettingsStore'
import { Text } from '@nextui-org/react'
@ -22,7 +22,7 @@ export default function HomePage() {
solanaAddress,
polkadotAddress,
nearAddress,
elrondAddress,
multiversxAddress,
tronAddress,
tezosAddress
} = useSnapshot(SettingsStore.state)
@ -47,8 +47,8 @@ export default function HomePage() {
{Object.entries(POLKADOT_MAINNET_CHAINS).map(([caip10, {name, logo, rgb}]) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={polkadotAddress} chainId={caip10}/>
))}
{Object.entries(ELROND_MAINNET_CHAINS).map(([caip10, {name, logo, rgb}]) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={elrondAddress} chainId={caip10}/>
{Object.entries(MULTIVERSX_MAINNET_CHAINS).map(([caip10, {name, logo, rgb}]) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={multiversxAddress} chainId={caip10}/>
))}
{Object.entries(TRON_MAINNET_CHAINS).map(([caip10, {name, logo, rgb}]) => (
<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}]) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={nearAddress} chainId={caip10}/>
))}
{Object.entries(ELROND_TEST_CHAINS).map(([caip10, {name, logo, rgb}]) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={elrondAddress} chainId={caip10}/>
{Object.entries(MULTIVERSX_TEST_CHAINS).map(([caip10, {name, logo, rgb}]) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={multiversxAddress} chainId={caip10}/>
))}
{Object.entries(TRON_TEST_CHAINS).map(([caip10, {name, logo, rgb}]) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={tronAddress} chainId={caip10}/>

View File

@ -4,7 +4,7 @@ import SettingsStore from '@/store/SettingsStore'
import { cosmosWallets } from '@/utils/CosmosWalletUtil'
import { eip155Wallets } from '@/utils/EIP155WalletUtil'
import { solanaWallets } from '@/utils/SolanaWalletUtil'
import { elrondWallets } from '@/utils/ElrondWalletUtil'
import { multiversxWallets } from '@/utils/MultiversxWalletUtil'
import { tronWallets } from '@/utils/TronWalletUtil'
import { Card, Divider, Row, Switch, Text } from '@nextui-org/react'
import { Fragment } from 'react'
@ -18,7 +18,7 @@ export default function SettingsPage() {
eip155Address,
cosmosAddress,
solanaAddress,
elrondAddress,
multiversxAddress,
tronAddress,
tezosAddress
} = useSnapshot(SettingsStore.state)
@ -91,10 +91,10 @@ export default function SettingsPage() {
</Card>
<Text h4 css={{ marginTop: '$10', marginBottom: '$5' }}>
Elrond Mnemonic
MultiversX Mnemonic
</Text>
<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>
<Text h4 css={{ marginTop: '$10', marginBottom: '$5' }}>

View File

@ -29,7 +29,7 @@ interface State {
| 'SessionSignSolanaModal'
| 'SessionSignPolkadotModal'
| 'SessionSignNearModal'
| 'SessionSignElrondModal'
| 'SessionSignMultiversxModal'
| 'SessionSignTronModal'
| 'SessionSignTezosModal'
| 'LegacySessionProposalModal'

View File

@ -11,7 +11,7 @@ interface State {
solanaAddress: string
polkadotAddress: string
nearAddress: string
elrondAddress: string
multiversxAddress: string
tronAddress: string
tezosAddress: string
relayerRegionURL: string
@ -30,7 +30,7 @@ const state = proxy<State>({
solanaAddress: '',
polkadotAddress: '',
nearAddress: '',
elrondAddress: '',
multiversxAddress: '',
tronAddress: '',
tezosAddress: '',
relayerRegionURL: ''
@ -68,8 +68,8 @@ const SettingsStore = {
state.relayerRegionURL = relayerRegionURL
},
setElrondAddress(elrondAddress: string) {
state.elrondAddress = elrondAddress
setMultiversxAddress(multiversxAddress: string) {
state.multiversxAddress = multiversxAddress
},
setTronAddress(tronAddress: string) {

View File

@ -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
}
}

View File

@ -1,6 +1,6 @@
import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData'
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 { POLKADOT_CHAINS, TPolkadotChain } from '@/data/PolkadotData'
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) {
return chain.includes('elrond')
export function isMultiversxChain(chain: string) {
return chain.includes('mvx')
}
/**
@ -142,7 +142,7 @@ export function formatChainName(chainId: string) {
return (
COSMOS_MAINNET_CHAINS[chainId as TCosmosChain]?.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 ??
POLKADOT_CHAINS[chainId as TPolkadotChain]?.name ??
SOLANA_CHAINS[chainId as TSolanaChain]?.name ??

View File

@ -1,40 +1,41 @@
import { ELROND_SIGNING_METHODS } from '@/data/ElrondData'
import { MULTIVERSX_SIGNING_METHODS } from '@/data/MultiversxData'
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 { SignClientTypes } from '@walletconnect/types'
import { getSdkError } from '@walletconnect/utils'
export async function approveElrondRequest(
export async function approveMultiversxRequest(
requestEvent: SignClientTypes.EventArguments['session_request']
) {
const { params, id } = requestEvent
const { request } = params
const account = getWalletAddressFromParams(elrondAddresses, params)
const wallet = elrondWallets[account]
const account = getWalletAddressFromParams(multiversxAddresses, params)
const wallet = multiversxWallets[account]
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)
return formatJsonRpcResult(id, signedMessage)
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTION:
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_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.
const signature = await wallet.signTransaction(signTransaction)
return formatJsonRpcResult(id, signature)
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTIONS:
// Elrond Allows for a Batch of Transactions to be signed
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTIONS:
// MultiversX Allows for a Batch of Transactions to be signed
const signTransactions = request.params.transactions
const signatures = await wallet.signTransactions(signTransactions)
return formatJsonRpcResult(id, signatures)
case ELROND_SIGNING_METHODS.ELROND_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_LOGIN_TOKEN:
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.
// Afterwards, a backend application would normally verify the signature of the 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
return formatJsonRpcError(id, getSdkError('USER_REJECTED_METHODS').message)

View 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
}
}

View File

@ -6,7 +6,7 @@ import ModalStore from '@/store/ModalStore'
import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
import { polkadotAddresses } from '@/utils/PolkadotWalletUtil'
import { elrondAddresses } from '@/utils/ElrondWalletUtil'
import { multiversxAddresses } from '@/utils/MultiversxWalletUtil'
import { tronAddresses } from '@/utils/TronWalletUtil'
import { tezosAddresses } from '@/utils/TezosWalletUtil'
import {
@ -15,7 +15,7 @@ import {
isSolanaChain,
isPolkadotChain,
isNearChain,
isElrondChain,
isMultiversxChain,
isTronChain,
isTezosChain
} from '@/utils/HelperUtil'
@ -168,10 +168,10 @@ export default function SessionProposalModal() {
chain={chain}
/>
)
} else if (isElrondChain(chain)) {
} else if (isMultiversxChain(chain)) {
return (
<ProposalSelectSection
addresses={elrondAddresses}
addresses={multiversxAddresses}
selectedAddresses={selectedAccounts[chain]}
onSelect={onSelectAccount}
chain={chain}

View File

@ -4,12 +4,12 @@ import RequesDetailsCard from '@/components/RequestDetalilsCard'
import RequestMethodCard from '@/components/RequestMethodCard'
import RequestModalContainer from '@/components/RequestModalContainer'
import ModalStore from '@/store/ModalStore'
import { approveElrondRequest, rejectElrondRequest } from '@/utils/ElrondRequestHandlerUtil'
import { approveMultiversxRequest, rejectMultiversxRequest } from '@/utils/MultiversxRequestHandlerUtil'
import { signClient } from '@/utils/WalletConnectUtil'
import { Button, Divider, Modal, Text } from '@nextui-org/react'
import { Fragment } from 'react'
export default function SessionSignElrondModal() {
export default function SessionSignMultiversxModal() {
// Get request and wallet data from store
const requestEvent = ModalStore.state.data?.requestEvent
const requestSession = ModalStore.state.data?.requestSession
@ -26,7 +26,7 @@ export default function SessionSignElrondModal() {
// Handle approve action (logic varies based on request method)
async function onApprove() {
if (requestEvent) {
const response = await approveElrondRequest(requestEvent)
const response = await approveMultiversxRequest(requestEvent)
await signClient.respond({
topic,
response
@ -38,7 +38,7 @@ export default function SessionSignElrondModal() {
// Handle reject action
async function onReject() {
if (requestEvent) {
const response = rejectElrondRequest(requestEvent)
const response = rejectMultiversxRequest(requestEvent)
await signClient.respond({
topic,
response

File diff suppressed because it is too large Load Diff

View File

@ -12,8 +12,8 @@
"@cosmjs/amino": "0.28.4",
"@cosmjs/encoding": "0.28.4",
"@cosmjs/proto-signing": "0.28.4",
"@elrondnetwork/erdjs": "11.1.1",
"@elrondnetwork/erdjs-walletcore": "2.1.0",
"@multiversx/sdk-core": "11.5.0",
"@multiversx/sdk-wallet": "4.0.0",
"@json-rpc-tools/utils": "1.7.6",
"@near-wallet-selector/wallet-utils": "^7.0.2",
"@nextui-org/react": "1.0.8-beta.5",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

View 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

View File

@ -3,7 +3,7 @@ import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
import { nearAddresses } from '@/utils/NearWalletUtil'
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
import { elrondAddresses } from '@/utils/ElrondWalletUtil'
import { multiversxAddresses } from '@/utils/MultiversxWalletUtil'
import { useSnapshot } from 'valtio'
export default function AccountPicker() {
@ -16,7 +16,7 @@ export default function AccountPicker() {
SettingsStore.setCosmosAddress(cosmosAddresses[account])
SettingsStore.setSolanaAddress(solanaAddresses[account])
SettingsStore.setNearAddress(nearAddresses[account])
SettingsStore.setElrondAddress(elrondAddresses[account])
SettingsStore.setMultiversxAddress(multiversxAddresses[account])
}
return (

View File

@ -6,7 +6,7 @@ import SessionRequestModal from '@/views/SessionSignModal'
import SessionSignNearModal from '@/views/SessionSignNearModal'
import SessionSignPolkadotModal from '@/views/SessionSignPolkadotModal'
import SessionSignSolanaModal from '@/views/SessionSignSolanaModal'
import SessionSignElrondModal from '@/views/SessionSignElrondModal'
import SessionSignMultiversxModal from '@/views/SessionSignMultiversxModal'
import SessionSignTypedDataModal from '@/views/SessionSignTypedDataModal'
import SessionUnsuportedMethodModal from '@/views/SessionUnsuportedMethodModal'
import { Modal as NextModal } from '@nextui-org/react'
@ -27,7 +27,7 @@ export default function Modal() {
{view === 'SessionSignSolanaModal' && <SessionSignSolanaModal />}
{view === 'SessionSignPolkadotModal' && <SessionSignPolkadotModal />}
{view === 'SessionSignNearModal' && <SessionSignNearModal />}
{view === 'SessionSignElrondModal' && <SessionSignElrondModal />}
{view === 'SessionSignMultiversxModal' && <SessionSignMultiversxModal />}
{view === 'AuthRequestModal' && <AuthRequestModal />}
</NextModal>
)

View File

@ -2,7 +2,7 @@ import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData'
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
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 { Fragment } from 'react'
@ -31,7 +31,7 @@ export default function RequesDetailsCard({ chains, protocol }: IProps) {
COSMOS_MAINNET_CHAINS[chain as TCosmosChain]?.name ??
SOLANA_CHAINS[chain as TSolanaChain]?.name ??
NEAR_TEST_CHAINS[chain as TNearChain]?.name ??
ELROND_CHAINS[chain as TElrondChain]?.name ??
MULTIVERSX_CHAINS[chain as TMultiversxChain]?.name ??
chain
)
.join(', ')}

View File

@ -3,7 +3,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
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 { Col, Row, Text } from '@nextui-org/react'
import { SessionTypes } from '@walletconnect/types'
@ -15,12 +15,12 @@ import { Fragment } from 'react'
const CHAIN_METADATA = {
...COSMOS_MAINNET_CHAINS,
...SOLANA_MAINNET_CHAINS,
...ELROND_MAINNET_CHAINS,
...MULTIVERSX_MAINNET_CHAINS,
...EIP155_MAINNET_CHAINS,
...EIP155_TEST_CHAINS,
...SOLANA_TEST_CHAINS,
...NEAR_TEST_CHAINS,
...ELROND_TEST_CHAINS
...MULTIVERSX_TEST_CHAINS
}
/**

View File

@ -3,7 +3,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
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 { Col, Row, Text } from '@nextui-org/react'
import { ProposalTypes } from '@walletconnect/types'
@ -15,12 +15,12 @@ import { Fragment } from 'react'
const CHAIN_METADATA = {
...COSMOS_MAINNET_CHAINS,
...SOLANA_MAINNET_CHAINS,
...ELROND_MAINNET_CHAINS,
...MULTIVERSX_MAINNET_CHAINS,
...EIP155_MAINNET_CHAINS,
...EIP155_TEST_CHAINS,
...SOLANA_TEST_CHAINS,
...NEAR_TEST_CHAINS,
...ELROND_TEST_CHAINS
...MULTIVERSX_TEST_CHAINS
}
/**

View File

@ -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'
}

View 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'
}

View File

@ -3,7 +3,7 @@ import { createOrRestoreCosmosWallet } from '@/utils/CosmosWalletUtil'
import { createOrRestoreEIP155Wallet } from '@/utils/EIP155WalletUtil'
import { createOrRestoreSolanaWallet } from '@/utils/SolanaWalletUtil'
import { createOrRestorePolkadotWallet } from '@/utils/PolkadotWalletUtil'
import { createOrRestoreElrondWallet } from '@/utils/ElrondWalletUtil'
import { createOrRestoreMultiversxWallet } from '@/utils/MultiversxWalletUtil'
import { createWeb3Wallet } from '@/utils/WalletConnectUtil'
import { useCallback, useEffect, useRef, useState } from 'react'
import { useSnapshot } from 'valtio'
@ -22,14 +22,14 @@ export default function useInitialization() {
const { solanaAddresses } = await createOrRestoreSolanaWallet()
const { polkadotAddresses } = await createOrRestorePolkadotWallet()
const { nearAddresses } = await createOrRestoreNearWallet()
const { elrondAddresses } = await createOrRestoreElrondWallet()
const { multiversxAddresses } = await createOrRestoreMultiversxWallet()
SettingsStore.setEIP155Address(eip155Addresses[0])
SettingsStore.setCosmosAddress(cosmosAddresses[0])
SettingsStore.setSolanaAddress(solanaAddresses[0])
SettingsStore.setPolkadotAddress(polkadotAddresses[0])
SettingsStore.setNearAddress(nearAddresses[0])
SettingsStore.setElrondAddress(elrondAddresses[0])
SettingsStore.setMultiversxAddress(multiversxAddresses[0])
prevRelayerURLValue.current = relayerRegionURL
await createWeb3Wallet(relayerRegionURL)

View File

@ -2,7 +2,7 @@ import { COSMOS_SIGNING_METHODS } from '@/data/COSMOSData'
import { EIP155_SIGNING_METHODS } from '@/data/EIP155Data'
import { SOLANA_SIGNING_METHODS } from '@/data/SolanaData'
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 { web3wallet } from '@/utils/WalletConnectUtil'
import { SignClientTypes } from '@walletconnect/types'
@ -72,11 +72,12 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
case NEAR_SIGNING_METHODS.NEAR_VERIFY_OWNER:
return ModalStore.open('SessionSignNearModal', { requestEvent, requestSession })
case ELROND_SIGNING_METHODS.ELROND_SIGN_MESSAGE:
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTION:
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTIONS:
case ELROND_SIGNING_METHODS.ELROND_SIGN_LOGIN_TOKEN:
return ModalStore.open('SessionSignElrondModal', { requestEvent, requestSession })
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_MESSAGE:
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTION:
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTIONS:
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_LOGIN_TOKEN:
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN:
return ModalStore.open('SessionSignMultiversxModal', { requestEvent, requestSession })
case NEAR_SIGNING_METHODS.NEAR_GET_ACCOUNTS:
return web3wallet.respondSessionRequest({

View File

@ -1,5 +1,5 @@
import { Transaction, SignableMessage } from '@elrondnetwork/erdjs'
import { Mnemonic, UserSecretKey, UserWallet, UserSigner } from '@elrondnetwork/erdjs-walletcore'
import { Transaction, SignableMessage } from '@multiversx/sdk-core'
import { Mnemonic, UserSecretKey, UserWallet, UserSigner } from '@multiversx/sdk-wallet'
/**
* Types
@ -11,7 +11,7 @@ interface IInitArgs {
/**
* Library
*/
export default class ElrondLib {
export default class MultiversxLib {
wallet: UserWallet
mnemonic: Mnemonic
password: string
@ -20,16 +20,16 @@ export default class ElrondLib {
this.mnemonic = mnemonic
this.password = 'password' // test purposes only
const secretKey = mnemonic.deriveKey(0)
const secretKeyHex = secretKey.hex()
let fromHex = UserSecretKey.fromString(secretKeyHex)
this.wallet = new UserWallet(fromHex, this.password)
this.wallet = UserWallet.fromMnemonic({
password: this.password,
mnemonic: mnemonic.toString()
})
}
static init({ mnemonic }: IInitArgs) {
const mnemonicObj = mnemonic ? Mnemonic.fromString(mnemonic) : Mnemonic.generate()
return new ElrondLib(mnemonicObj)
return new MultiversxLib(mnemonicObj)
}
getMnemonic() {
@ -54,9 +54,9 @@ export default class ElrondLib {
})
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) {
@ -66,9 +66,9 @@ export default class ElrondLib {
const signTransaction = Transaction.fromPlainObject(transaction)
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[]) {
@ -79,9 +79,11 @@ export default class ElrondLib {
transactions.map(async (transaction: any): Promise<any> => {
const signTransaction = Transaction.fromPlainObject(transaction)
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') }
})
)

View File

@ -5,7 +5,7 @@ import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
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 { Text } from '@nextui-org/react'
import { Fragment } from 'react'
@ -20,7 +20,7 @@ export default function HomePage() {
solanaAddress,
polkadotAddress,
nearAddress,
elrondAddress
multiversxAddress
} = useSnapshot(SettingsStore.state)
return (
@ -43,8 +43,8 @@ export default function HomePage() {
{Object.values(POLKADOT_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={polkadotAddress} />
))}
{Object.values(ELROND_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={elrondAddress} />
{Object.values(MULTIVERSX_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={multiversxAddress} />
))}
{testNets ? (
@ -64,8 +64,8 @@ export default function HomePage() {
{Object.values(NEAR_TEST_CHAINS).map(({ name, logo, rgb }) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={nearAddress} />
))}
{Object.values(ELROND_TEST_CHAINS).map(({ name, logo, rgb }) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={elrondAddress} />
{Object.values(MULTIVERSX_TEST_CHAINS).map(({ name, logo, rgb }) => (
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={multiversxAddress} />
))}
</Fragment>
) : null}

View File

@ -4,14 +4,14 @@ import SettingsStore from '@/store/SettingsStore'
import { cosmosWallets } from '@/utils/CosmosWalletUtil'
import { eip155Wallets } from '@/utils/EIP155WalletUtil'
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 { Fragment } from 'react'
import { useSnapshot } from 'valtio'
import packageJSON from '../../package.json'
export default function SettingsPage() {
const { testNets, eip155Address, cosmosAddress, solanaAddress, elrondAddress } = useSnapshot(
const { testNets, eip155Address, cosmosAddress, solanaAddress, multiversxAddress } = useSnapshot(
SettingsStore.state
)
@ -83,10 +83,10 @@ export default function SettingsPage() {
</Card>
<Text h4 css={{ marginTop: '$10', marginBottom: '$5' }}>
Elrond Mnemonic
MultiversX Mnemonic
</Text>
<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>
</Fragment>
)

View File

@ -24,7 +24,7 @@ interface State {
| 'SessionSignSolanaModal'
| 'SessionSignPolkadotModal'
| 'SessionSignNearModal'
| 'SessionSignElrondModal'
| 'SessionSignMultiversxModal'
| 'AuthRequestModal'
data?: ModalData
}

View File

@ -11,7 +11,7 @@ interface State {
solanaAddress: string
polkadotAddress: string
nearAddress: string
elrondAddress: string
multiversxAddress: string
relayerRegionURL: string
}
@ -26,7 +26,7 @@ const state = proxy<State>({
solanaAddress: '',
polkadotAddress: '',
nearAddress: '',
elrondAddress: '',
multiversxAddress: '',
relayerRegionURL: ''
})
@ -62,8 +62,8 @@ const SettingsStore = {
state.relayerRegionURL = relayerRegionURL
},
setElrondAddress(elrondAddress: string) {
state.elrondAddress = elrondAddress
setMultiversxAddress(multiversxAddress: string) {
state.multiversxAddress = multiversxAddress
},
toggleTestNets() {

View File

@ -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
}
}

View File

@ -2,7 +2,7 @@ import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData'
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
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'
/**
@ -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) {
return chain.includes('elrond')
export function isMultiversxChain(chain: string) {
return chain.includes('mvx')
}
/**
@ -126,7 +126,7 @@ export function formatChainName(chainId: string) {
COSMOS_MAINNET_CHAINS[chainId as TCosmosChain]?.name ??
SOLANA_CHAINS[chainId as TSolanaChain]?.name ??
NEAR_TEST_CHAINS[chainId as TNearChain]?.name ??
ELROND_CHAINS[chainId as TElrondChain]?.name ??
MULTIVERSX_CHAINS[chainId as TMultiversxChain]?.name ??
chainId
)
}

View File

@ -1,40 +1,41 @@
import { ELROND_SIGNING_METHODS } from '@/data/ElrondData'
import { MULTIVERSX_SIGNING_METHODS } from '@/data/MultiversxData'
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 { SignClientTypes } from '@walletconnect/types'
import { getSdkError } from '@walletconnect/utils'
export async function approveElrondRequest(
export async function approveMultiversxRequest(
requestEvent: SignClientTypes.EventArguments['session_request']
) {
const { params, id } = requestEvent
const { request } = params
const account = getWalletAddressFromParams(elrondAddresses, params)
const wallet = elrondWallets[account]
const account = getWalletAddressFromParams(multiversxAddresses, params)
const wallet = multiversxWallets[account]
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)
return formatJsonRpcResult(id, signedMessage)
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTION:
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_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.
const signature = await wallet.signTransaction(signTransaction)
return formatJsonRpcResult(id, signature)
case ELROND_SIGNING_METHODS.ELROND_SIGN_TRANSACTIONS:
// Elrond Allows for a Batch of Transactions to be signed
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTIONS:
// Multiversx Allows for a Batch of Transactions to be signed
const signTransactions = request.params.transactions
const signatures = await wallet.signTransactions(signTransactions)
return formatJsonRpcResult(id, signatures)
case ELROND_SIGNING_METHODS.ELROND_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_LOGIN_TOKEN:
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.
// Afterwards, a backend application would normally verify the signature of the 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
return formatJsonRpcError(id, getSdkError('USER_REJECTED_METHODS').message)

View 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
}
}

View File

@ -6,14 +6,14 @@ import ModalStore from '@/store/ModalStore'
import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
import { polkadotAddresses } from '@/utils/PolkadotWalletUtil'
import { elrondAddresses } from '@/utils/ElrondWalletUtil'
import { multiversxAddresses } from '@/utils/MultiversxWalletUtil'
import {
isCosmosChain,
isEIP155Chain,
isSolanaChain,
isPolkadotChain,
isNearChain,
isElrondChain
isMultiversxChain
} from '@/utils/HelperUtil'
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
import { web3wallet } from '@/utils/WalletConnectUtil'
@ -139,10 +139,10 @@ export default function SessionProposalModal() {
chain={chain}
/>
)
} else if (isElrondChain(chain)) {
} else if (isMultiversxChain(chain)) {
return (
<ProposalSelectSection
addresses={elrondAddresses}
addresses={multiversxAddresses}
selectedAddresses={selectedAccounts[chain]}
onSelect={onSelectAccount}
chain={chain}

View File

@ -4,12 +4,12 @@ import RequesDetailsCard from '@/components/RequestDetalilsCard'
import RequestMethodCard from '@/components/RequestMethodCard'
import RequestModalContainer from '@/components/RequestModalContainer'
import ModalStore from '@/store/ModalStore'
import { approveElrondRequest, rejectElrondRequest } from '@/utils/ElrondRequestHandlerUtil'
import { approveMultiversxRequest, rejectMultiversxRequest } from '@/utils/MultiversxRequestHandlerUtil'
import { web3wallet } from '@/utils/WalletConnectUtil'
import { Button, Divider, Modal, Text } from '@nextui-org/react'
import { Fragment } from 'react'
export default function SessionSignElrondModal() {
export default function SessionSignMultiversxModal() {
// Get request and wallet data from store
const requestEvent = ModalStore.state.data?.requestEvent
const requestSession = ModalStore.state.data?.requestSession
@ -26,7 +26,7 @@ export default function SessionSignElrondModal() {
// Handle approve action (logic varies based on request method)
async function onApprove() {
if (requestEvent) {
const response = await approveElrondRequest(requestEvent)
const response = await approveMultiversxRequest(requestEvent)
await web3wallet.respondSessionRequest({
topic,
response
@ -38,7 +38,7 @@ export default function SessionSignElrondModal() {
// Handle reject action
async function onReject() {
if (requestEvent) {
const response = rejectElrondRequest(requestEvent)
const response = rejectMultiversxRequest(requestEvent)
await web3wallet.respondSessionRequest({
topic,
response

File diff suppressed because it is too large Load Diff