From dfb88505afac7d42c03f8a2ac31e195221c2f5e2 Mon Sep 17 00:00:00 2001 From: v1rtl Date: Tue, 28 May 2024 21:16:02 +0300 Subject: [PATCH] fix: remove goerli and add sepolia --- site/docs/cli/deploy.md | 6 +++--- site/docs/cli/ens.md | 6 +++--- site/docs/safe.md | 2 +- src/actions/ens.ts | 10 +++++----- src/types.ts | 2 +- src/utils/ens.ts | 18 ++++++++++++++---- src/utils/safe.ts | 13 +++---------- 7 files changed, 30 insertions(+), 27 deletions(-) diff --git a/site/docs/cli/deploy.md b/site/docs/cli/deploy.md index cb1136a..0b04c39 100644 --- a/site/docs/cli/deploy.md +++ b/site/docs/cli/deploy.md @@ -30,12 +30,12 @@ blumen deploy --ens v1rtl.eth ### `resolver-address` -Use a custom ENS Resolver address. Resolvers for mainnet and goerli are set by default. +Use a custom ENS Resolver address. Resolvers for mainnet and sepolia are set by default. ### `chain` Default: `mainnet` -Options: `mainnet`, `goerli` +Options: `mainnet`, `sepolia` EVM Chain to use for ENS deployment. Requires `--ens` option to be defined. @@ -93,7 +93,7 @@ blumen deploy --verbose --providers=Gateway3 Deploy using a [Safe](https://safe.global) multisig wallet. Requires private key of a Safe owner/delegate to sign a transaction. [EIP-3770](https://eips.ethereum.org/EIPS/eip-3770) addresses are supported. ```sh -blumen ens bafybeibp54tslsez36quqptgzwyda3vo66za3rraujksmsb3d5q247uht4 v1rtl.eth --safe gor:0x1234567890000000000000000000000000000000 --chain goerli +blumen ens bafybeibp54tslsez36quqptgzwyda3vo66za3rraujksmsb3d5q247uht4 v1rtl.eth --safe sep:0x1234567890000000000000000000000000000000 --chain sepolia ``` ### `dnslink` diff --git a/site/docs/cli/ens.md b/site/docs/cli/ens.md index f149111..ece981f 100644 --- a/site/docs/cli/ens.md +++ b/site/docs/cli/ens.md @@ -19,7 +19,7 @@ It is recommended to use multisig wallets for deployments instead of using a pri ### `chain` Default: `mainnet` -Options: `mainnet`, `goerli` +Options: `mainnet`, `sepolia` EVM Chain to use for ENS deployment. Requires `--ens` option to be defined. @@ -28,7 +28,7 @@ EVM Chain to use for ENS deployment. Requires `--ens` option to be defined. Deploy using a [Safe](https://safe.global) multisig wallet. Requires private key of a Safe owner/delegate to sign a transaction. [EIP-3770](https://eips.ethereum.org/EIPS/eip-3770) addresses are supported. ```sh -blumen ens bafybeibp54tslsez36quqptgzwyda3vo66za3rraujksmsb3d5q247uht4 v1rtl.eth --safe gor:0x1234567890000000000000000000000000000000 --chain goerli +blumen ens bafybeibp54tslsez36quqptgzwyda3vo66za3rraujksmsb3d5q247uht4 v1rtl.eth --safe gor:0x1234567890000000000000000000000000000000 --chain sepolia ``` ### `rpc-url` @@ -37,4 +37,4 @@ Use a custom Ethereum RPC for transactions. By default, [Ankr RPCs](https://ankr ### `resolver-address` -Use a custom ENS Resolver address. Resolvers for mainnet and goerli are set by default. \ No newline at end of file +Use a custom ENS Resolver address. Resolvers for mainnet and sepolia are set by default. \ No newline at end of file diff --git a/site/docs/safe.md b/site/docs/safe.md index 46969f9..7873cba 100644 --- a/site/docs/safe.md +++ b/site/docs/safe.md @@ -24,7 +24,7 @@ BLUMEN_PK=0x... Once environment is set up, we can deploy our application by running blumen deploy with our Safe and ENS name: ```sh -blumen deploy --safe=gor:0x... --ens=mydomain.eth +blumen deploy --safe=sep:0x... --ens=mydomain.eth # 📦 Packing app (965.48KB) # 🟢 Root CID: bafybeieao2nmw5njfino26llsokqdbc56pdfq7kudhoc5rrsvp4jk7tlk4 # 🟢 Deploying with providers: Gateway3, Filebase diff --git a/src/actions/ens.ts b/src/actions/ens.ts index 4801460..eaa1acf 100644 --- a/src/actions/ens.ts +++ b/src/actions/ens.ts @@ -12,12 +12,12 @@ import { InvalidCIDError, MissingCLIArgsError, MissingKeyError } from '../errors import { PUBLIC_RESOLVER_ADDRESS, prepareUpdateEnsArgs, abi } from '../utils/ens.js' import type { ChainName } from '../types.js' import { privateKeyToAccount } from 'viem/accounts' -import { goerli, mainnet } from 'viem/chains' +import * as chains from 'viem/chains' import { walletSafeActions, publicSafeActions } from '@stauro/piggybank/actions' import { EIP3770Address, OperationType } from '@stauro/piggybank/types' import { getEip3770Address } from '@stauro/piggybank/utils' import { ApiClient } from '@stauro/piggybank/api' -import { chainIdToSafeApiUrl } from '../utils/safe.js' +import { chainToSafeApiUrl } from '../utils/safe.js' import * as colors from 'colorette' import { logger } from '../utils/logger.js' import { isTTY } from '../constants.js' @@ -48,7 +48,7 @@ export const ensAction = async ( throw new InvalidCIDError(cid) } if (!domain) throw new MissingCLIArgsError([domain]) - const chain = chainName === 'mainnet' ? mainnet : goerli + const chain = chains[chainName] const transport = http(rpcUrl ?? chain.id === 1 ? 'https://rpc.ankr.com/eth' : 'https://rpc.ankr.com/eth_goerli') @@ -96,7 +96,7 @@ export const ensAction = async ( const request = await publicClient.prepareTransactionRequest({ account: from, - to: resolverAddress || PUBLIC_RESOLVER_ADDRESS[chain.id as 1 | 5], + to: resolverAddress || PUBLIC_RESOLVER_ADDRESS[chainName], chain, data: encodeFunctionData({ functionName: 'setContenthash', @@ -137,7 +137,7 @@ export const ensAction = async ( logger.info('Proposing a Safe transaction') - const apiClient = new ApiClient({ url: chainIdToSafeApiUrl(chain.id), safeAddress, chainId: chain.id }) + const apiClient = new ApiClient({ url: chainToSafeApiUrl(chainName), safeAddress, chainId: chain.id }) try { await apiClient.proposeTransaction({ diff --git a/src/types.ts b/src/types.ts index 67a0a13..376274a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -60,6 +60,6 @@ export type StatusFunction = ( deals?: FilecoinDeal[] }> -export type ChainName = 'mainnet' | 'goerli' +export type ChainName = 'mainnet' | 'sepolia' export type SupportedMethods = 'pin' | 'upload' | 'both' diff --git a/src/utils/ens.ts b/src/utils/ens.ts index ea56ba9..d60e652 100644 --- a/src/utils/ens.ts +++ b/src/utils/ens.ts @@ -1,6 +1,7 @@ import { encode } from '@ensdomains/content-hash' -import { parseAbi } from 'viem' +import { Address, parseAbi } from 'viem' import { namehash, normalize } from 'viem/ens' +import type { ChainName } from '../types' export const prepareUpdateEnsArgs = async ({ cid, domain }: { cid: string, domain: string }) => { const contentHash = encode('ipfs', cid) @@ -12,7 +13,16 @@ export const prepareUpdateEnsArgs = async ({ cid, domain }: { cid: string, domai export const abi = parseAbi(['function setContenthash(bytes32 node, bytes calldata hash) external']) -export const PUBLIC_RESOLVER_ADDRESS = { - 1: '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41', - 5: '0xd7a4F6473f32aC2Af804B3686AE8F1932bC35750', +export const PUBLIC_RESOLVER_ADDRESS: Record = { + mainnet: '0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63', + sepolia: '0x8FADE66B79cC9f707aB26799354482EB93a5B7dD', } as const + +export const chainToRpcUrl = (chain: ChainName) => { + switch (chain) { + case 'mainnet': + return 'https://rpc.ankr.com/eth' + case 'sepolia': + return 'https://rpc.ankr.com/eth_sepolia' + } +} diff --git a/src/utils/safe.ts b/src/utils/safe.ts index 582a35d..ea46a94 100644 --- a/src/utils/safe.ts +++ b/src/utils/safe.ts @@ -1,10 +1,3 @@ -export const chainIdToSafeApiUrl = (chainId: 1 | 5) => { - switch (chainId) { - case 1: - return 'https://safe-transaction-mainnet.safe.global' - case 5: - return 'https://safe-transaction-goerli.safe.global' - default: - throw new Error('Unsupported chain') - } -} +import type { ChainName } from '../types' + +export const chainToSafeApiUrl = (chainName: ChainName) => `https://safe-transaction-${chainName}.safe.global`