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

fix: remove goerli and add sepolia #37

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions site/docs/cli/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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`
Expand Down
6 changes: 3 additions & 3 deletions site/docs/cli/ens.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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`
Expand All @@ -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.
Use a custom ENS Resolver address. Resolvers for mainnet and sepolia are set by default.
2 changes: 1 addition & 1 deletion site/docs/safe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/actions/ens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ export type StatusFunction<T = object> = (
deals?: FilecoinDeal[]
}>

export type ChainName = 'mainnet' | 'goerli'
export type ChainName = 'mainnet' | 'sepolia'

export type SupportedMethods = 'pin' | 'upload' | 'both'
18 changes: 14 additions & 4 deletions src/utils/ens.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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<ChainName, Address> = {
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'
}
}
13 changes: 3 additions & 10 deletions src/utils/safe.ts
Original file line number Diff line number Diff line change
@@ -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`
Loading