Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds zksync to network configuration #5066

Closed
Closed
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ declare module 'react-native-dotenv' {
export const ARBITRUM_MAINNET_RPC: string;
export const BSC_MAINNET_RPC: string;
export const ZORA_MAINNET_RPC: string;
export const ZKSYNC_MAINNET_RPC: string;
export const RAINBOW_WYRE_MERCHANT_ID: string;
export const RAINBOW_WYRE_MERCHANT_ID_TEST: string;
export const WYRE_ACCOUNT_ID: string;
Expand Down
23 changes: 23 additions & 0 deletions ios/Images.xcassets/badges/zksyncBadge.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "zksyncBadge.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions ios/Images.xcassets/badges/zksyncBadgeDark.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "zksyncBadgeDark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions ios/Images.xcassets/badges/zksyncBadgeLarge.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "zksyncBadgeLarge.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "zksyncBadgeLargeDark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "zksyncBadgeNoShadow.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/appIconzkSync.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/badges/zksyncBadge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/badges/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/badges/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/badges/zksyncBadgeDark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/badges/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/badges/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/badges/zksyncBadgeLarge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/badges/[email protected]
Binary file added src/assets/badges/[email protected]
Binary file added src/assets/badges/zksyncBadgeLargeDark.png
Binary file added src/assets/badges/[email protected]
Binary file added src/assets/badges/[email protected]
Binary file added src/assets/badges/zksyncBadgeNoShadow.png
Binary file added src/assets/badges/[email protected]
Binary file added src/assets/badges/[email protected]
9 changes: 9 additions & 0 deletions src/components/ChainLogo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import ZoraBadgeNoShadow from '../assets/badges/zoraBadgeNoShadow.png';
import BaseBadge from '../assets/badges/baseBadge.png';
import BaseBadgeDark from '../assets/badges/baseBadgeDark.png';
import BaseBadgeNoShadow from '../assets/badges/baseBadgeNoShadow.png';
import ZkSyncBadge from '../assets/badges/zksyncBadge.png';
import ZkSyncBadgeDark from '../assets/badges/zksyncBadgeDark.png';
import ZkSyncBadgeNoShadow from '../assets/badges/zksyncBadgeNoShadow.png';
import { Centered } from './layout';
import networkTypes from '@/helpers/networkTypes';
import styled from '@/styled-thing';
Expand Down Expand Up @@ -79,6 +82,12 @@ export default function ChainLogo({
? BaseBadgeDark
: BaseBadge
: BaseBadgeNoShadow;
} else if (network === networkTypes.zksync) {
val = withShadows
? isDarkMode
? ZkSyncBadgeDark
: ZkSyncBadge
: ZkSyncBadgeNoShadow;
}
return val;
}, [isDarkMode, network, withShadows]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import ZoraBadge from '@/assets/badges/zoraBadge.png';
import ZoraBadgeDark from '@/assets/badges/zoraBadgeDark.png';
import BaseBadge from '@/assets/badges/baseBadge.png';
import BaseBadgeDark from '@/assets/badges/baseBadgeDark.png';
import ZkSyncBadge from '@/assets/badges/zksyncBadge.png';
import ZkSyncBadgeDark from '@/assets/badges/zksyncBadgeDark.png';
import { AssetType } from '@/entities';

interface FastChainBadgeProps {
Expand Down Expand Up @@ -49,6 +51,10 @@ const AssetIconsByTheme: {
dark: BaseBadgeDark,
light: BaseBadge,
},
[AssetType.zksync]: {
dark: ZkSyncBadgeDark,
light: ZkSyncBadge,
},
};

export const FastChainBadge = React.memo(function FastChainBadge({
Expand Down
8 changes: 8 additions & 0 deletions src/components/coin-icon/ChainBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import BaseBadge from '../../assets/badges/baseBadge.png';
import BaseBadgeDark from '../../assets/badges/baseBadgeDark.png';
import BaseBadgeLarge from '../../assets/badges/baseBadgeLarge.png';
import BaseBadgeLargeDark from '../../assets/badges/baseBadgeLargeDark.png';
import ZkSyncBadge from '../../assets/badges/zksyncBadge.png';
import ZkSyncBadgeDark from '../../assets/badges/zksyncBadgeDark.png';
import ZkSyncBadgeLarge from '../../assets/badges/zksyncBadgeLarge.png';
import ZkSyncBadgeLargeDark from '../../assets/badges/zksyncBadgeLargeDark.png';
import { Centered } from '../layout';
import { AssetType } from '@/entities';
import styled from '@/styled-thing';
Expand Down Expand Up @@ -78,6 +82,8 @@ export default function ChainBadge({
val = isDarkMode ? ZoraBadgeLargeDark : ZoraBadgeLarge;
} else if (assetType === AssetType.base) {
val = isDarkMode ? BaseBadgeLargeDark : BaseBadgeLarge;
} else if (assetType === AssetType.zksync) {
val = isDarkMode ? ZkSyncBadgeLargeDark : ZkSyncBadgeLarge;
}
} else {
if (assetType === AssetType.arbitrum) {
Expand All @@ -92,6 +98,8 @@ export default function ChainBadge({
val = isDarkMode ? ZoraBadgeDark : ZoraBadge;
} else if (assetType === AssetType.base) {
val = isDarkMode ? BaseBadgeDark : BaseBadge;
} else if (assetType === AssetType.zksync) {
val = isDarkMode ? ZkSyncBadgeDark : ZkSyncBadge;
}
}
return val;
Expand Down
1 change: 1 addition & 0 deletions src/components/gas/GasSpeedButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ const GasSpeedButton = ({
case networkTypes.arbitrum:
case networkTypes.zora:
case networkTypes.base:
case networkTypes.zkSync:
default:
return { mainnet_address: ETH_ADDRESS, symbol: 'ETH' };
}
Expand Down
2 changes: 2 additions & 0 deletions src/entities/assetTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum AssetType {
trash = 'trash',
uniswap = 'uniswap',
uniswapV2 = 'uniswap-v2',
zksync = 'zksync',
}

export default {
Expand All @@ -28,4 +29,5 @@ export default {
trash: 'trash',
uniswap: 'uniswap',
uniswapV2: 'uniswap-v2',
zksync: 'zksync',
} as const;
1 change: 1 addition & 0 deletions src/handlers/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function isL2Asset(type: any) {
case AssetTypes.bsc:
case AssetTypes.zora:
case AssetTypes.base:
case AssetTypes.zksync:
return true;
default:
return false;
Expand Down
5 changes: 4 additions & 1 deletion src/handlers/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
smartContractMethods,
CRYPTO_KITTIES_NFT_ADDRESS,
CRYPTO_PUNKS_NFT_ADDRESS,
ZKSYNC_ETH_ADDRESS,
} from '@/references';
import {
addBuffer,
Expand Down Expand Up @@ -114,6 +115,7 @@ export const setRpcEndpoints = (config: RainbowConfig): void => {
rpcEndpoints[Network.polygon] = config.polygon_mainnet_rpc;
rpcEndpoints[Network.bsc] = config.bsc_mainnet_rpc;
rpcEndpoints[Network.zora] = config.zora_mainnet_rpc;
rpcEndpoints[Network.zkSync] = config.zkSync_mainnet_rpc;
rpcEndpoints[Network.base] = config.base_mainnet_rpc;
};

Expand Down Expand Up @@ -651,7 +653,8 @@ export const createSignableTransaction = async (
transaction.asset.address === ARBITRUM_ETH_ADDRESS ||
transaction.asset.address === OPTIMISM_ETH_ADDRESS ||
transaction.asset.address === MATIC_POLYGON_ADDRESS ||
transaction.asset.address === BNB_BSC_ADDRESS
transaction.asset.address === BNB_BSC_ADDRESS ||
transaction.asset.address === ZKSYNC_ETH_ADDRESS
) {
return getTxDetails(transaction);
}
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/networkTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum Network {
base = 'base',
bsc = 'bsc',
zora = 'zora',
zkSync = 'zkSync',
gnosis = 'gnosis',
}

Expand All @@ -21,5 +22,6 @@ export default {
base: 'base' as Network,
bsc: 'bsc' as Network,
zora: 'zora' as Network,
zkSync: 'zkSync' as Network,
gnosis: 'gnosis' as Network,
};
6 changes: 5 additions & 1 deletion src/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,10 @@
"text": "Binance Smart Chain (BSC) is the blockchain for the trading platform Binance. \n\nBSC allows for cheaper and faster transactions, but unlike a Layer 2 network, it has its own security and consensus mechanisms that differ from Ethereum.",
"title": "What's Binance Smart Chain?"
},
"zksync": {
"text": "zkSync is a Layer 2 network that runs on top of Ethereum, enabling cheaper and faster transactions while still benefiting from the underlying security of Ethereum.\n\nIt bundles lots of transactions together in a \"roll up\" before sending them down to live permanently on Ethereum.",
"title": "What's zkSync"
},
"read_more": "Read More",
"learn_more": "Learn More",
"sending_to_contract": {
Expand Down Expand Up @@ -1373,7 +1377,7 @@
},
"info_row_2": {
"title": "Swap directly on L2",
"description": "Fast and cheap swaps on Arbitrum, Optimism, Polygon and BSC."
"description": "Fast and cheap swaps on Arbitrum, Optimism, Polygon, BSC, and zkSync."
},
"info_row_3": {
"title": "Flashbots protection",
Expand Down
10 changes: 10 additions & 0 deletions src/model/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
BASE_MAINNET_RPC_DEV,
BSC_MAINNET_RPC,
ZORA_MAINNET_RPC,
ZKSYNC_MAINNET_RPC,
} from 'react-native-dotenv';
import {
getNetwork,
Expand All @@ -41,6 +42,7 @@ export interface RainbowConfig
optimism_mainnet_rpc: string;
polygon_mainnet_rpc: string;
zora_mainnet_rpc: string;
zkSync_mainnet_rpc: string;
base_mainnet_rpc: string;
swagg_enabled: boolean;
trace_call_block_number_offset: number;
Expand All @@ -51,6 +53,7 @@ export interface RainbowConfig
polygon_enabled: boolean;
optimism_enabled: boolean;
zora_enabled: boolean;
zkSync_enabled: boolean;
base_enabled: boolean;
op_chains_enabled: boolean;
mainnet_enabled: boolean;
Expand All @@ -62,6 +65,7 @@ export interface RainbowConfig
polygon_tx_enabled: boolean;
optimism_tx_enabled: boolean;
zora_tx_enabled: boolean;
zkSync_tx_enabled: boolean;
op_chains_tx_enabled: boolean;
mainnet_tx_enabled: boolean;
goerli_tx_enabled: boolean;
Expand All @@ -82,6 +86,7 @@ const DEFAULT_CONFIG: RainbowConfig = {
bsc: 200,
base: 200,
zora: 200,
zkSync: 200,
}),
ethereum_goerli_rpc: __DEV__ ? ETHEREUM_GOERLI_RPC_DEV : ETHEREUM_GOERLI_RPC,
ethereum_mainnet_rpc: __DEV__
Expand All @@ -95,6 +100,7 @@ const DEFAULT_CONFIG: RainbowConfig = {
polygon_mainnet_rpc: POLYGON_MAINNET_RPC,
bsc_mainnet_rpc: BSC_MAINNET_RPC,
zora_mainnet_rpc: ZORA_MAINNET_RPC,
zkSync_mainnet_rpc: ZKSYNC_MAINNET_RPC,
base_mainnet_rpc: __DEV__ ? BASE_MAINNET_RPC_DEV : BASE_MAINNET_RPC,
swagg_enabled: true,
trace_call_block_number_offset: 20,
Expand All @@ -105,6 +111,7 @@ const DEFAULT_CONFIG: RainbowConfig = {
polygon_enabled: true,
optimism_enabled: true,
zora_enabled: true,
zkSync_enabled: true,
base_enabled: true,
op_chains_enabled: true,

Expand All @@ -118,6 +125,7 @@ const DEFAULT_CONFIG: RainbowConfig = {
polygon_tx_enabled: true,
optimism_tx_enabled: true,
zora_tx_enabled: true,
zkSync_tx_enabled: true,
op_chains_tx_enabled: true,

mainnet_tx_enabled: true,
Expand Down Expand Up @@ -165,6 +173,7 @@ const init = async () => {
key === 'polygon_tx_enabled' ||
key === 'optimism_tx_enabled' ||
key === 'zora_tx_enabled' ||
key === 'zkSync_tx_enabled' ||
key === 'base_tx_enabled' ||
key === 'op_chains_tx_enabled' ||
key === 'goerli_tx_enabled' ||
Expand All @@ -174,6 +183,7 @@ const init = async () => {
key === 'polygon_enabled' ||
key === 'optimism_enabled' ||
key === 'zora_enabled' ||
key === 'zkSync_enabled' ||
key === 'base_enabled' ||
key === 'op_chains_enabled' ||
key === 'goerli_enabled' ||
Expand Down
4 changes: 4 additions & 0 deletions src/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getOptimismNetworkObject } from './optimism';
import { getPolygonNetworkObject } from './polygon';
import { Network, NetworkProperties } from './types';
import { getZoraNetworkObject } from './zora';
import { getZkSyncNetworkObject } from './zksync';
import { getGnosisNetworkObject } from './gnosis';
import { getBaseNetworkObject } from './base';
import store from '@/redux/store';
Expand All @@ -22,6 +23,7 @@ export const RainbowNetworks = [
getOptimismNetworkObject(),
getPolygonNetworkObject(),
getZoraNetworkObject(),
getZkSyncNetworkObject(),
getGnosisNetworkObject(),
getGoerliNetworkObject(),
getBSCNetworkObject(),
Expand All @@ -45,6 +47,8 @@ export function getNetworkObj(network: Network): NetworkProperties {
return getPolygonNetworkObject();
case Network.zora:
return getZoraNetworkObject();
case Network.zkSync:
return getZkSyncNetworkObject();
case Network.gnosis:
return getGnosisNetworkObject();

Expand Down
Loading