Skip to content

Commit

Permalink
Add mode
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed May 10, 2024
1 parent fc1eb95 commit 91e2641
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@openzeppelin/contracts": "^4.9.3",
"async-lock": "^1.4.0",
"axios": "^1.5.0",
"blockchain-addressbook": "^0.46.56",
"blockchain-addressbook": "^0.46.105",
"dotenv": "^16.3.1",
"lodash": "^4.17.21",
"pg": "^8.11.3",
Expand Down
14 changes: 7 additions & 7 deletions src/lib/addressbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ import { Chain } from './chain';
import { Hex } from 'viem';

export function getChainWNativeTokenDecimals(chain: Chain): number {
if (chain === 'fraxtal') {
if (chain === 'mode') {
return 18;
}
const tokens = addressbook.addressBook[chain].tokens;
return tokens.WNATIVE.decimals;
}

export function getChainWNativeTokenSymbol(chain: Chain): string {
if (chain === 'fraxtal') {
return 'frxETH';
if (chain === 'mode') {
return 'ETH';
}
const tokens = addressbook.addressBook[chain].tokens;
return tokens.WNATIVE.symbol;
}

export function getChainWNativeTokenAddress(chain: Chain): Hex {
if (chain === 'fraxtal') {
return '0xFC00000000000000000000000000000000000006';
if (chain === 'mode') {
return '0x4200000000000000000000000000000000000006';
}
const tokens = addressbook.addressBook[chain].tokens;
return tokens.WNATIVE.address as Hex;
}

export function getNetworkId(chain: Chain): number {
if (chain === 'fraxtal') {
return 252;
if (chain === 'mode') {
return 34443;
}
const tokens = addressbook.addressBook[chain].tokens;
return tokens.WNATIVE.chainId;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/chain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addressBook } from 'blockchain-addressbook';

export type Chain = keyof typeof addressBook | 'fraxtal';
export type Chain = keyof typeof addressBook | 'mode';

export const allChainIds: Chain[] = [...Object.keys(addressBook), 'fraxtal'] as Chain[];
export const allChainIds: Chain[] = [...Object.keys(addressBook), 'mode'] as Chain[];
26 changes: 26 additions & 0 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,25 @@ export const RPC_CONFIG: Record<Chain, RpcConfig> = {
setTransactionGasLimit: false,
},
},
mode: {
...defaultConfig,
url: RPC_FORCE_URL || process.env.MODE_RPC_URL || 'https://mainnet.mode.network',
transaction: {
...defaultTransactionConfig,
type: 'eip1559',
maxNativePerTransactionWei: bigintMultiplyFloat(ONE_ETHER, 0.01),
},
harvest: {
...defaultHarvestConfig,
setTransactionGasLimit: false,
},
unwrap: {
...defaultUnwrapConfig,
minAmountOfWNativeWei: bigintMultiplyFloat(ONE_ETHER, 0.01),
maxAmountOfNativeWei: bigintMultiplyFloat(ONE_ETHER, 0.01),
setTransactionGasLimit: false,
},
},
metis: {
...defaultConfig,
url: RPC_FORCE_URL || process.env.METIS_RPC_URL || 'https://andromeda.metis.io/?owner=1088',
Expand Down Expand Up @@ -837,6 +856,13 @@ export const EXPLORER_CONFIG: Record<Chain, ExplorerConfig> = {
apiUrl: process.env.METIS_EXPLORER_API_URL || 'https://andromeda-explorer.metis.io/api?',
type: 'blockscout',
},
mode: {
addressLinkTemplate: 'https://modescan.io//address/${address}',
transactionLinkTemplate: 'https://modescan.io/tx/${hash}',
apiUrl: process.env.AVAX_EXPLORER_API_URL || 'https://api.modescan.io/api',
apiKey: process.env.AVAX_EXPLORER_API_KEY || '',
type: 'etherscan',
},
moonbeam: {
addressLinkTemplate: 'https://moonbeam.moonscan.io/address/${address}',
transactionLinkTemplate: 'https://moonbeam.moonscan.io/tx/${hash}',
Expand Down
3 changes: 2 additions & 1 deletion src/lib/rpc-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createPublicClient, createWalletClient } from 'viem';
import { type Chain } from './chain';
import { privateKeyToAccount } from 'viem/accounts';
import { RPC_CONFIG } from './config';
import { gnosis, linea, mantle, type Chain as ViemChain } from 'viem/chains';
import { gnosis, linea, mantle, mode, type Chain as ViemChain } from 'viem/chains';
import {
arbitrum,
aurora,
Expand Down Expand Up @@ -67,6 +67,7 @@ const VIEM_CHAINS: Record<Chain, ViemChain | null> = {
linea: applyConfig('linea', linea),
mantle: applyConfig('mantle', mantle),
metis: applyConfig('metis', metis),
mode: applyConfig('mode', mode),
moonbeam: applyConfig('moonbeam', moonbeam),
moonriver: applyConfig('moonriver', moonriver),
one: applyConfig('one', harmonyOne),
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1228,10 +1228,10 @@ base64-js@^1.3.1:
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==

blockchain-addressbook@^0.46.56:
version "0.46.56"
resolved "https://registry.yarnpkg.com/blockchain-addressbook/-/blockchain-addressbook-0.46.56.tgz#87be25341df9068f891b8fa8850ce8a18beed388"
integrity sha512-BN+dAMAuE0YlCvtRStoIz0Q1vZEr6ldPKO3Bq7ksyTH2x/WGSTlwmICDm1Usp/bxPkEvL4VkIl68Fh5iUjSZvA==
blockchain-addressbook@^0.46.105:
version "0.46.105"
resolved "https://registry.yarnpkg.com/blockchain-addressbook/-/blockchain-addressbook-0.46.105.tgz#01ddeb1936119384accebc2c4ced28af11852059"
integrity sha512-dIQj1oozxddpPASS0A0tYQerHpxMIOC37NDcb7NOVzIjlb/xs8KugxgjBDiNEic8LvIICJp04x1ZXfnnb4w9ow==
dependencies:
"@types/node" "^20.9.0"

Expand Down

0 comments on commit 91e2641

Please sign in to comment.