Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions advanced/dapps/react-dapp-v2/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
const path = require("path");

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
distDir: "build",
transpilePackages: ["@web-examples/shared"],
webpack(config) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
};

// Resolve @web-examples/shared to TypeScript source files for direct transpilation
const sharedPath = path.resolve(__dirname, "../../../shared");
config.resolve.alias = {
...config.resolve.alias,
"@web-examples/shared": sharedPath,
};

// Enable WebAssembly support for packages like tiny-secp256k1
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
};

return config;
},
};
Expand Down
4 changes: 3 additions & 1 deletion advanced/dapps/react-dapp-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"start": "next start",
"lint": "next lint",
"prettier": "prettier --check '**/*.{js,ts,jsx,tsx}'",
"prettier:write": "prettier --write '**/*.{js,ts,jsx,tsx}'"
"prettier:write": "prettier --write '**/*.{js,ts,jsx,tsx}'",
"postinstall": "cd ../../../shared && pnpm install && pnpm build || echo 'Warning: Shared package postinstall failed'"
},
"dependencies": {
"@web-examples/shared": "file:../../../shared",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the monorepo instead of this?

"@celo/wallet-base": "^5.1.1",
"@ethereumjs/tx": "^3.5.0",
"@kadena/client": "^0.5.0",
Expand Down
1,559 changes: 1,534 additions & 25 deletions advanced/dapps/react-dapp-v2/pnpm-lock.yaml

Large diffs are not rendered by default.

44 changes: 2 additions & 42 deletions advanced/dapps/react-dapp-v2/src/chains/bip122.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,2 @@
import { NamespaceMetadata, ChainMetadata, ChainsMap } from "../helpers";

export const BIP122_MAINNET = "000000000019d6689c085ae165831e93";
export const BIP122_TESTNET = "000000000933ea01ad0ee984209779ba";
export const BIP122_DUST_LIMIT = "1001";

export const BtcChainData: ChainsMap = {
[BIP122_MAINNET]: {
id: `bip122:${BIP122_MAINNET}`,
name: "BTC Mainnet",
rpc: [],
slip44: 0,
testnet: false,
},
[BIP122_TESTNET]: {
id: `bip122:${BIP122_TESTNET}`,
name: "BTC Testnet",
rpc: [],
slip44: 501,
testnet: true,
},
};

export const BtcMetadata: NamespaceMetadata = {
[BIP122_MAINNET]: {
logo: "/assets/btc-testnet.png",
rgb: "247, 147, 25",
},
[BIP122_TESTNET]: {
logo: "/assets/btc-testnet.png",
rgb: "247, 147, 25",
},
};

export function getChainMetadata(chainId: string): ChainMetadata {
const reference = chainId.split(":")[1];
const metadata = BtcMetadata[reference];
if (typeof metadata === "undefined") {
throw new Error(`No chain metadata found for chainId: ${chainId}`);
}
return metadata;
}
// Re-export chain data and metadata from shared
export * from "@web-examples/shared/chains/bip122";
56 changes: 3 additions & 53 deletions advanced/dapps/react-dapp-v2/src/chains/cosmos.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,8 @@
import { JsonRpcRequest } from "@walletconnect/jsonrpc-utils";
import { ChainRequestRender } from "@web-examples/shared";

import {
NamespaceMetadata,
ChainMetadata,
ChainRequestRender,
ChainsMap,
} from "../helpers";

export const CosmosChainData: ChainsMap = {
"cosmoshub-4": {
name: "Cosmos Hub",
id: "cosmos:cosmoshub-4",
rpc: ["https://rpc.cosmos.network"],
slip44: 118,
testnet: false,
},
"irishub-1": {
name: "Irisnet",
id: "cosmos:irishub-1",
rpc: ["https://rpc.irisnet.org"],
slip44: 566,
testnet: false,
},
"kava-4": {
name: "Kava",
id: "cosmos:kava-4",
rpc: ["https://kava4.data.kava.io"],
slip44: 459,
testnet: false,
},
"columbus-4": {
name: "Terra",
id: "cosmos:columbus-4",
rpc: [],
slip44: 330,
testnet: false,
},
};

export const CosmosMetadata: NamespaceMetadata = {
"cosmoshub-4": {
logo: "/assets/" + "cosmos-cosmoshub-4.png",
rgb: "27, 31, 53",
},
};

export function getChainMetadata(chainId: string): ChainMetadata {
const reference = chainId.split(":")[1];
const metadata = CosmosMetadata[reference];
if (typeof metadata === "undefined") {
throw new Error(`No chain metadata found for chainId: ${chainId}`);
}
return metadata;
}
// Re-export chain data and metadata from shared
export * from "@web-examples/shared/chains/cosmos";

export function getChainRequestRender(
request: JsonRpcRequest
Expand Down
211 changes: 3 additions & 208 deletions advanced/dapps/react-dapp-v2/src/chains/eip155.ts
Original file line number Diff line number Diff line change
@@ -1,217 +1,12 @@
import { JsonRpcRequest } from "@walletconnect/jsonrpc-utils";

import {
NamespaceMetadata,
ChainMetadata,
ChainRequestRender,
convertHexToNumber,
convertHexToUtf8,
ChainsMap,
} from "../helpers";

export const EIP155Colors = {
ethereum: "99, 125, 234",
optimism: "233, 1, 1",
goerli: "189, 174, 155",
xdai: "73, 169, 166",
polygon: "130, 71, 229",
zksync: "90, 90, 90",
celo: "60, 203, 132",
arbitrum: "44, 55, 75",
};

export const EIP155ChainData: ChainsMap = {
"1": {
name: "Ethereum Mainnet",
id: "eip155:1",
rpc: ["https://api.mycryptoapi.com/eth"],
slip44: 60,
testnet: false,
},
"5": {
name: "Ethereum Goerli",
id: "eip155:5",
rpc: ["https://rpc.goerli.mudit.blog"],
slip44: 60,
testnet: true,
},
"11155111": {
name: "Ethereum Sepolia",
id: "eip155:11155111",
rpc: ["https://gateway.tenderly.co/public/sepolia "],
slip44: 60,
testnet: true,
},
"10": {
name: "Optimism Mainnet",
id: "eip155:10",
rpc: ["https://mainnet.optimism.io"],
slip44: 60,
testnet: false,
},
"42": {
name: "Ethereum Kovan",
id: "eip155:42",
rpc: ["https://kovan.poa.network"],
slip44: 60,
testnet: true,
},
"69": {
name: "Optimism Kovan",
id: "eip155:69",
rpc: ["https://kovan.optimism.io"],
slip44: 60,
testnet: true,
},
"100": {
name: "xDAI",
id: "eip155:100",
rpc: ["https://dai.poa.network"],
slip44: 60,
testnet: false,
},
"280": {
name: "zkSync Era Testnet",
id: "eip155:280",
rpc: ["https://testnet.era.zksync.dev"],
slip44: 60,
testnet: true,
},
"324": {
name: "zkSync Era",
id: "eip155:324",
rpc: ["https://mainnet.era.zksync.io"],
slip44: 60,
testnet: false,
},
"137": {
name: "Polygon Mainnet",
id: "eip155:137",
rpc: ["https://rpc-mainnet.matic.network"],
slip44: 60,
testnet: false,
},
"420": {
name: "Optimism Goerli",
id: "eip155:420",
rpc: ["https://goerli.optimism.io"],
slip44: 60,
testnet: true,
},
"42161": {
name: "Arbitrum One",
id: "eip155:42161",
rpc: ["https://arb1.arbitrum.io/rpc"],
slip44: 60,
testnet: false,
},
"42220": {
name: "Celo Mainnet",
id: "eip155:42220",
rpc: ["https://forno.celo.org"],
slip44: 52752,
testnet: false,
},
"44787": {
name: "Celo Alfajores",
id: "eip155:44787",
rpc: ["https://alfajores-forno.celo-testnet.org"],
slip44: 52752,
testnet: true,
},
"80001": {
name: "Polygon Mumbai",
id: "eip155:80001",
rpc: ["https://rpc-mumbai.matic.today"],
slip44: 60,
testnet: true,
},
"421611": {
name: "Arbitrum Rinkeby",
id: "eip155:421611",
rpc: ["https://rinkeby.arbitrum.io/rpc"],
slip44: 60,
testnet: true,
},
};
} from "@web-examples/shared";

export const EIP155Metadata: NamespaceMetadata = {
"1": {
name: "Ethereum",
logo: "/assets/" + "eip155-1.png",
rgb: EIP155Colors.ethereum,
},
"5": {
logo: "/assets/" + "eip155-1.png",
rgb: EIP155Colors.ethereum,
},
"11155111": {
logo: "/assets/" + "eip155-1.png",
rgb: EIP155Colors.ethereum,
},
"10": {
name: "Optimism",
logo: "/assets/" + "eip155-10.png",
rgb: EIP155Colors.optimism,
},
"42": {
logo: "/assets/" + "eip155-42.png",
rgb: EIP155Colors.ethereum,
},
"420": {
logo: "/assets/" + "eip155-420.png",
rgb: EIP155Colors.optimism,
},
"100": {
logo: "/assets/" + "eip155-100.png",
rgb: EIP155Colors.xdai,
},
"280": {
name: "zkSync Era Testnet",
logo: "/assets/" + "eip155-324.svg",
rgb: EIP155Colors.zksync,
},
"324": {
name: "zkSync Era",
logo: "/assets/" + "eip155-324.svg",
rgb: EIP155Colors.zksync,
},
"137": {
name: "Polygon",
logo: "/assets/" + "eip155-137.png",
rgb: EIP155Colors.polygon,
},
"80001": {
logo: "/assets/" + "eip155-80001.png",
rgb: EIP155Colors.polygon,
},
"42161": {
name: "Arbitrum",
logo: "/assets/" + "eip155-42161.png",
rgb: EIP155Colors.arbitrum,
},
"42220": {
name: "Celo",
logo: "/assets/" + "eip155-42220.png",
rgb: EIP155Colors.celo,
},
"44787": {
logo: "/assets/" + "eip155-44787.png",
rgb: EIP155Colors.celo,
},
"421611": {
logo: "/assets/" + "eip155-421611.png",
rgb: EIP155Colors.arbitrum,
},
};
export function getChainMetadata(chainId: string): ChainMetadata {
const reference = chainId.split(":")[1];
const metadata = EIP155Metadata[reference];
if (typeof metadata === "undefined") {
throw new Error(`No chain metadata found for chainId: ${chainId}`);
}
return metadata;
}
// Re-export chain data and metadata from shared
export * from "@web-examples/shared/chains/eip155";

export function getChainRequestRender(
request: JsonRpcRequest
Expand Down
Loading
Loading