Skip to content

Commit

Permalink
Merge branch 'main' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls authored Feb 16, 2024
2 parents c10edad + 23820b2 commit cbd05cf
Show file tree
Hide file tree
Showing 16 changed files with 290 additions and 52 deletions.
9 changes: 9 additions & 0 deletions .changeset/nervous-candles-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@thirdweb-dev/wallets": patch
"@thirdweb-dev/react": patch
---

Update Supported Networks for Safe wallet

- Remove Goerli, Base Goerli
- Add Sepolia, Base Mainnet, Polygon zkEVM, ZkSync Mainnet
6 changes: 3 additions & 3 deletions packages/chains/chains/128123.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export default {
"chainId": 128123,
"explorers": [
{
"name": "Explorer",
"url": "https://testnet-explorer.etherlink.com/",
"standard": "EIP1559"
"name": "Etherlink Testnet Explorer",
"url": "https://testnet-explorer.etherlink.com",
"standard": "EIP3091"
}
],
"faucets": [
Expand Down
6 changes: 6 additions & 0 deletions packages/chains/chains/16.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export default {
"https://faucet.towolabs.com",
"https://fauceth.komputing.org?chain=16&address=${ADDRESS}"
],
"icon": {
"url": "ipfs://QmW7Ljv2eLQ1poRrhJBaVWJBF1TyfZ8QYxDeELRo6sssrj",
"width": 382,
"height": 382,
"format": "png"
},
"infoURL": "https://flare.xyz",
"name": "Flare Testnet Coston",
"nativeCurrency": {
Expand Down
45 changes: 45 additions & 0 deletions packages/chains/chains/2442.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { Chain } from "../src/types";
export default {
"chain": "Polygon",
"chainId": 2442,
"explorers": [
{
"name": "polygonscan",
"url": "https://cardona-zkevm.polygonscan.com",
"standard": "EIP3091"
}
],
"faucets": [],
"icon": {
"url": "ipfs://QmNmJZkQgx9RcFLS3rvxQTVYcPfyAFPr667keHTUxB9PDv",
"width": 122,
"height": 135,
"format": "png"
},
"infoURL": "https://polygon.technology/polygon-zkevm",
"name": "Polygon zkEVM Cardona Testnet",
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"networkId": 2442,
"parent": {
"type": "L2",
"chain": "eip155-1",
"bridges": [
{
"url": "https://bridge-ui.cardona.zkevm-rpc.com"
}
]
},
"rpc": [
"https://polygon-zkevm-cardona-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://2442.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.cardona.zkevm-rpc.com"
],
"shortName": "zkevm-testnet-cardona",
"slug": "polygon-zkevm-cardona-testnet",
"testnet": true,
"title": "Polygon zkEVM Cardona Testnet"
} as const satisfies Chain;
31 changes: 31 additions & 0 deletions packages/chains/chains/54356.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Chain } from "../src/types";
export default {
"chain": "Avalanche",
"chainId": 54356,
"explorers": [],
"faucets": [],
"features": [],
"icon": {
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
"width": 256,
"height": 256,
"format": "svg"
},
"infoURL": "https://avacloud.io",
"name": "Jambon's Testnet",
"nativeCurrency": {
"name": "Jambon's Testnet Token",
"symbol": "ZEG",
"decimals": 18
},
"networkId": 54356,
"redFlags": [],
"rpc": [
"https://jambon-s-testnet-jambon's testnet-54356.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://54356.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://subnets.avacloud-dev.io/e6f00b45-8486-445d-b3b8-815708aab379"
],
"shortName": "Jambon's Testnet",
"slug": "jambon-s-testnet-jambon's testnet-54356",
"testnet": true
} as const satisfies Chain;
1 change: 1 addition & 0 deletions packages/chains/chains/84531.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ export default {
"shortName": "basegor",
"slip44": 1,
"slug": "base-goerli",
"status": "deprecated",
"testnet": true
} as const satisfies Chain;
42 changes: 42 additions & 0 deletions packages/chains/chains/9393.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Chain } from "../src/types";
export default {
"chain": "ETH",
"chainId": 9393,
"explorers": [
{
"name": "basescout",
"url": "https://sepolia-delascan.deperp.com",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmYtUimyqHkkFxYdbXXRbUqNg2VLPUg6Uu2C2nmFWowiZM",
"width": 551,
"height": 540,
"format": "png"
}
}
],
"faucets": [],
"icon": {
"url": "ipfs://QmZQbfJfxYez8iQyVsB65y7ZTssKbgUpMXzPTEk5xGDwQB",
"width": 600,
"height": 600,
"format": "png"
},
"infoURL": "https://www.deperp.com/dela",
"name": "Dela Sepolia Testnet",
"nativeCurrency": {
"name": "Sepolia Ether",
"symbol": "ETH",
"decimals": 18
},
"networkId": 9393,
"rpc": [
"https://dela-sepolia-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://9393.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://sepolia-dela.deperp.com"
],
"shortName": "delasep",
"slip44": 1,
"slug": "dela-sepolia-testnet",
"testnet": true
} as const satisfies Chain;
31 changes: 31 additions & 0 deletions packages/chains/chains/946751.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Chain } from "../src/types";
export default {
"chain": "Avalanche",
"chainId": 946751,
"explorers": [],
"faucets": [],
"features": [],
"icon": {
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
"width": 256,
"height": 256,
"format": "svg"
},
"infoURL": "https://avacloud.io",
"name": "QR0214Y1P",
"nativeCurrency": {
"name": "QR0214Y1P Token",
"symbol": "QAT",
"decimals": 18
},
"networkId": 946751,
"redFlags": [],
"rpc": [
"https://qr0214y1p.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://946751.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://subnets.avax.network/qr0214y1p/testnet/rpc"
],
"shortName": "QR0214Y1P",
"slug": "qr0214y1p",
"testnet": true
} as const satisfies Chain;
6 changes: 6 additions & 0 deletions packages/chains/chains/963.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export default {
"name": "EIP1559"
}
],
"icon": {
"url": "ipfs://QmRUzDpn3xqPYnjLuZvFs2Attio9VxGRUprXEjcNQDcpe5",
"width": 375,
"height": 456,
"format": "png"
},
"infoURL": "https://bitcoincode.technology",
"name": "BTC20 Smart Chain",
"nativeCurrency": {
Expand Down
18 changes: 17 additions & 1 deletion packages/chains/src/index.ts

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions packages/react/src/wallet/wallets/safe/SelectAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import {
useSupportedChains,
useWalletContext,
} from "@thirdweb-dev/react-core";
import { SafeSupportedChainsSet, SafeWallet } from "@thirdweb-dev/wallets";
import { SafeWallet } from "@thirdweb-dev/wallets";
import { utils } from "ethers";
import { useContext, useState } from "react";
import { Container, Line, ModalHeader } from "../../../components/basic";
import { Link, Text } from "../../../components/text";
import { ModalConfigCtx } from "../../../evm/providers/wallet-ui-states-provider";
import { safeSlugToChainId } from "./safeChainSlug";
import { safeChainIdToSlug, safeSlugToChainId } from "./safeChainSlug";
import { useTWLocale } from "../../../evm/providers/locale-provider";
import { StyledSelect } from "../../../design-system/elements";
import { useCustomTheme } from "../../../design-system/CustomThemeProvider";
Expand Down Expand Up @@ -50,9 +50,7 @@ export const SelectAccount: React.FC<{
const chains = useSupportedChains();

// put supported chains first
const supportedChains = chains.filter((c) =>
SafeSupportedChainsSet.has(c.chainId),
);
const supportedChains = chains.filter((c) => c.chainId in safeChainIdToSlug);

const selectedSafeChain = supportedChains.find(
(c) => c.chainId === safeChainId,
Expand Down Expand Up @@ -160,11 +158,13 @@ export const SelectAccount: React.FC<{
setSafeConnectError(false);
if (value.length > 4) {
const prefix = value.split(":")[0];
const _chainId =
prefix && prefix in safeSlugToChainId
? safeSlugToChainId[prefix]
: undefined;

if (prefix && prefix in safeSlugToChainId) {
setSafeChainId(
safeSlugToChainId[prefix as keyof typeof safeSlugToChainId],
);
if (_chainId && prefix) {
setSafeChainId(_chainId);
setSafeAddress(value.slice(prefix.length + 1));
} else {
setSafeAddress(value);
Expand Down
34 changes: 21 additions & 13 deletions packages/react/src/wallet/wallets/safe/safeChainSlug.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
export const safeSlugToChainId = {
eth: 1,
matic: 137,
avax: 43114,
bnb: 56,
oeth: 10,
gor: 5,
"base-gor": 84531,
} as const;
import type { SafeSupportedChains } from "@thirdweb-dev/wallets/evm/connectors/safe";

export const safeChainIdToSlug = {
// maps safe chain id to safe-chain slug
export const safeChainIdToSlug: Record<SafeSupportedChains, string> = {
1: "eth",
137: "matic",
43114: "avax",
56: "bnb",
10: "oeth",
5: "gor",
84531: "base-gor",
} as const;
8453: "base",
11155111: "sep",
100: "gno",
1313161554: "aurora",
42161: "arb1",
42220: "celo",
1101: "zkevm",
324: "zksync",
};

// maps safe chain slug to chain id
export const safeSlugToChainId = /* @__PURE__ */ (() => {
const result: Record<string, SafeSupportedChains> = {};
for (const [chainId, prefix] of Object.entries(safeChainIdToSlug)) {
result[prefix] = Number(chainId) as SafeSupportedChains;
}
return result;
})();
29 changes: 16 additions & 13 deletions packages/wallets/src/evm/connectors/safe/constants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// excerpt from https://docs.gnosis-safe.io/backend/available-services
export const CHAIN_ID_TO_GNOSIS_SERVER_URL = {
import { SafeSupportedChains } from "./types";

// excerpt from https://docs.safe.global/api-supported-networks#safe-transaction-service
export const CHAIN_ID_TO_GNOSIS_SERVER_URL: Record<
SafeSupportedChains,
string
> = {
// mainnet
1: "https://safe-transaction-mainnet.safe.global",
// goerli
5: "https://safe-transaction-goerli.safe.global",
// Sepolia
11155111: "https://safe-transaction-sepolia.safe.global",
// optimism
10: "https://safe-transaction-optimism.safe.global",
// bsc
Expand All @@ -18,14 +23,12 @@ export const CHAIN_ID_TO_GNOSIS_SERVER_URL = {
42161: "https://safe-transaction-arbitrum.safe.global",
// celo
42220: "https://safe-transaction-celo.safe.global",
// base goerli
84531: "https://safe-transaction-base-testnet.safe.global",
// Base mainnet
8453: "https://safe-transaction-base.safe.global",
// aurora
1313161554: "https://safe-transaction-aurora.safe.global",
} as const;

/**
* @internal
*/
export const SafeSupportedChainsSet = /* @__PURE__ */ (() =>
new Set(Object.keys(CHAIN_ID_TO_GNOSIS_SERVER_URL).map(Number)))();
// Polygon zkEVM
1101: "https://safe-transaction-zkevm.safe.global",
// ZkSync Mainnet
324: "https://safe-transaction-zksync.safe.global",
};
Loading

0 comments on commit cbd05cf

Please sign in to comment.