Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.
Draft
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
12 changes: 4 additions & 8 deletions src/config/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ import {
PublicClient,
} from 'viem'
import { riverNetSigner } from '@/constants'
import { config } from 'dotenv'

config()
import { env } from '@/services'

const chain = 'optimism-goerli'

export const pimlicoBundlerClient = createClient({
chain: optimismGoerli,
// ⚠️ using v1 of the API ⚠️
transport: http(
`https://api.pimlico.io/v1/${chain}/rpc?apikey=${process.env.PIMLICO_KEY}`,
`https://api.pimlico.io/v1/${chain}/rpc?apikey=${env.PIMLICO_KEY}`,
),
})
.extend(bundlerActions)
Expand All @@ -32,15 +30,13 @@ export const pimlicoPaymasterClient = createClient({
chain: optimismGoerli,
// ⚠️ using v2 of the API ⚠️
transport: http(
`https://api.pimlico.io/v2/${chain}/rpc?apikey=${process.env.PIMLICO_KEY}`,
`https://api.pimlico.io/v2/${chain}/rpc?apikey=${env.PIMLICO_KEY}`,
),
}).extend(pimlicoPaymasterActions)

export const publicClient = createPublicClient({
chain: optimismGoerli,
transport: http(
`https://opt-goerli.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`,
),
transport: http(`https://opt-goerli.g.alchemy.com/v2/${env.ALCHEMY_KEY}`),
}) as PublicClient

export const walletClient = createWalletClient({
Expand Down
7 changes: 2 additions & 5 deletions src/constants/riverNetSigner.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { privateKeyToAccount } from 'viem/accounts'
import { type Hash } from 'viem'
import { config } from 'dotenv'
import { env } from '@/services'

config()

export const riverNetSigner = privateKeyToAccount(
process.env.PRIVATE_KEY as Hash,
)
export const riverNetSigner = privateKeyToAccount(env.PRIVATE_KEY as Hash)
1 change: 1 addition & 0 deletions src/services/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './createAccount'
export * from './env'
6 changes: 2 additions & 4 deletions src/userOperations/createAndRegisterAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import {
import { entryPoint, riverNetSigner, idRegistry } from '@/constants'
import { idRegistryAbi, riverAccountAbi } from '@/abi'
import { buildInitCode } from '@/helpers'
import { config } from 'dotenv'

config()
import { env } from '@/services'

export async function createAndRegisterAccount({
initialAdmin,
Expand Down Expand Up @@ -78,7 +76,7 @@ export async function createAndRegisterAccount({
chainId: optimismGoerli.id,
}),
},
privateKey: process.env.PRIVATE_KEY as Hash,
privateKey: env.PRIVATE_KEY as Hash,
})

sponsoredUserOperation.signature = signature
Expand Down