From 4c172d5f1973a8739a2c19be5e33cfaa0ca82843 Mon Sep 17 00:00:00 2001 From: Hunter Cote Date: Thu, 4 Apr 2024 11:36:08 -0400 Subject: [PATCH] add etherlink --- core/utils/templateMappings.ts | 3 ++- .../template/src/utils/network.ts | 13 ++++++++++++ .../template/src/utils/networks.ts | 20 ++++++++++++++++--- scaffolds/prompts.ts | 3 ++- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/core/utils/templateMappings.ts b/core/utils/templateMappings.ts index 702d76a..a339886 100644 --- a/core/utils/templateMappings.ts +++ b/core/utils/templateMappings.ts @@ -198,7 +198,8 @@ export const buildTemplate = async (appConfig: ConfigType): Promise config.network === 'ethereum' || config.network === 'ethereum-sepolia' || config.network === 'polygon' || - config.network === 'polygon-amoy' + config.network === 'polygon-amoy' || + config.network === 'etherlink-testnet' ) { config.chain = 'evm'; } else if (config.network === 'solana-devnet' || config.network === 'solana-mainnet') { diff --git a/scaffolds/nextjs-dedicated-wallet/template/src/utils/network.ts b/scaffolds/nextjs-dedicated-wallet/template/src/utils/network.ts index 217ee45..6fdb273 100644 --- a/scaffolds/nextjs-dedicated-wallet/template/src/utils/network.ts +++ b/scaffolds/nextjs-dedicated-wallet/template/src/utils/network.ts @@ -3,6 +3,7 @@ export enum Network { POLYGON = 'polygon', ETHEREUM_SEPOLIA = 'ethereum-sepolia', ETHEREUM = 'ethereum', + ETHERLINK_TESTNET = 'etherlink-testnet', } export const getNetworkUrl = () => { @@ -15,6 +16,8 @@ export const getNetworkUrl = () => { return 'https://eth-sepolia.g.alchemy.com/v2/fYFybLQFR9Zr2GCRcgALmAktStFKr0i0'; case Network.ETHEREUM: return 'https://eth-mainnet.g.alchemy.com/v2/fYFybLQFR9Zr2GCRcgALmAktStFKr0i0'; + case Network.ETHERLINK_TESTNET: + return 'https://node.ghostnet.etherlink.com'; default: throw new Error('Network not supported'); } @@ -30,6 +33,8 @@ export const getChainId = () => { return 11155111; case Network.ETHEREUM: return 1; + case Network.ETHERLINK_TESTNET: + return 128123; } }; @@ -41,6 +46,8 @@ export const getNetworkToken = () => { case Network.ETHEREUM: case Network.ETHEREUM_SEPOLIA: return 'ETH'; + case Network.ETHERLINK_TESTNET: + return 'XTZ'; } }; @@ -50,6 +57,8 @@ export const getFaucetUrl = () => { return 'https://faucet.polygon.technology/'; case Network.ETHEREUM_SEPOLIA: return 'https://sepoliafaucet.com/'; + case Network.ETHERLINK_TESTNET: + return 'https://faucet.etherlink.com/'; } }; @@ -63,6 +72,8 @@ export const getNetworkName = () => { return 'Ethereum (Sepolia)'; case Network.ETHEREUM: return 'Ethereum (Mainnet)'; + case Network.ETHERLINK_TESTNET: + return 'Etherlink (Testnet)'; } }; @@ -76,5 +87,7 @@ export const getBlockExplorer = (address: string) => { return `https://etherscan.io/address/${address}`; case Network.ETHEREUM_SEPOLIA: return `https://sepolia.etherscan.io/address/${address}`; + case Network.ETHERLINK_TESTNET: + return `https://testnet-explorer.etherlink.com//address/${address}`; } }; diff --git a/scaffolds/nextjs-universal-wallet/template/src/utils/networks.ts b/scaffolds/nextjs-universal-wallet/template/src/utils/networks.ts index 7de9f72..fce8060 100644 --- a/scaffolds/nextjs-universal-wallet/template/src/utils/networks.ts +++ b/scaffolds/nextjs-universal-wallet/template/src/utils/networks.ts @@ -3,6 +3,7 @@ export enum Network { POLYGON = 'polygon', ETHEREUM_SEPOLIA = 'ethereum-sepolia', ETHEREUM = 'ethereum', + ETHERLINK_TESTNET = 'etherlink-testnet', } export const getNetworkUrl = () => { @@ -15,6 +16,9 @@ export const getNetworkUrl = () => { return 'https://eth-sepolia.g.alchemy.com/v2/3jKhhva6zBqwp_dnwPlF4d0rFZhu2pjD'; case Network.ETHEREUM: return 'https://eth-mainnet.g.alchemy.com/v2/3jKhhva6zBqwp_dnwPlF4d0rFZhu2pjD'; + case Network.ETHERLINK_TESTNET: + return 'https://node.ghostnet.etherlink.com'; + default: throw new Error('Network not supported'); } @@ -25,11 +29,13 @@ export const getChainId = () => { case Network.POLYGON: return 137; case Network.POLYGON_AMOY: - return 80001; + return 80002; case Network.ETHEREUM_SEPOLIA: - return 1155111; + return 11155111; case Network.ETHEREUM: return 1; + case Network.ETHERLINK_TESTNET: + return 128123; } }; @@ -41,6 +47,8 @@ export const getNetworkToken = () => { case Network.ETHEREUM: case Network.ETHEREUM_SEPOLIA: return 'ETH'; + case Network.ETHERLINK_TESTNET: + return 'XTZ'; } }; @@ -50,6 +58,8 @@ export const getFaucetUrl = () => { return 'https://faucet.polygon.technology/'; case Network.ETHEREUM_SEPOLIA: return 'https://sepoliafaucet.com/'; + case Network.ETHERLINK_TESTNET: + return 'https://faucet.etherlink.com/'; } }; @@ -58,11 +68,13 @@ export const getNetworkName = () => { case Network.POLYGON: return 'Polygon (Mainnet)'; case Network.POLYGON_AMOY: - return 'Polygon (Mumbai)'; + return 'Polygon (Amoy)'; case Network.ETHEREUM_SEPOLIA: return 'Ethereum (Sepolia)'; case Network.ETHEREUM: return 'Ethereum (Mainnet)'; + case Network.ETHERLINK_TESTNET: + return 'Etherlink (Testnet)'; } }; @@ -76,5 +88,7 @@ export const getBlockExplorer = (address: string) => { return `https://etherscan.io/address/${address}`; case Network.ETHEREUM_SEPOLIA: return `https://sepolia.etherscan.io/address/${address}`; + case Network.ETHERLINK_TESTNET: + return `https://testnet-explorer.etherlink.com//address/${address}`; } }; diff --git a/scaffolds/prompts.ts b/scaffolds/prompts.ts index 9569bd6..e2bb928 100644 --- a/scaffolds/prompts.ts +++ b/scaffolds/prompts.ts @@ -137,7 +137,7 @@ export namespace BlockchainNetworkPrompt { name: 'chain', message: 'Which blockchain do you want to use?', choices: [ - { name: 'evm', message: 'EVM (Ethereum, Polygon, etc.)' }, + { name: 'evm', message: 'EVM (Ethereum, Etherlink, Polygon, etc.)' }, { name: 'solana', message: 'Solana' }, { name: 'flow', message: 'Flow' }, ], @@ -173,6 +173,7 @@ export namespace BlockchainNetworkPrompt { choices: [ { name: 'ethereum', message: 'Ethereum (Mainnet)' }, { name: 'ethereum-sepolia', message: 'Ethereum (Sepolia Testnet)' }, + { name: 'etherlink-testnet', message: 'Etherlink (Testnet)' }, { name: 'polygon', message: 'Polygon (Mainnet)' }, { name: 'polygon-amoy', message: 'Polygon (Amoy Testnet)' }, ],