Skip to content

Commit

Permalink
chore(address): remove rpcProvider from sc wallets (#2436)
Browse files Browse the repository at this point in the history
  • Loading branch information
poolsar42 authored Jun 22, 2023
1 parent e5a9fbd commit d9d234c
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 84 deletions.
Binary file not shown.
7 changes: 1 addition & 6 deletions platform/address/.dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@ SECRET_MICROSOFT_OAUTH_CLIENT_SECRET = ""
INTERNAL_TWITTER_OAUTH_CLIENT_ID = ""
SECRET_TWITTER_OAUTH_CLIENT_SECRET = ""

SECRET_ZERODEV_PROJECTID = ""

ALCHEMY_MUMBAI_PROVIDER_URL = ""
ALCHEMY_POLYGON_PROVIDER_URL = ""
ALCHEMY_GOERLI_PROVIDER_URL = ""
ALCHEMY_ETH_PROVIDER_URL = ""
SECRET_ZERODEV_PROJECTID = ""
2 changes: 1 addition & 1 deletion platform/address/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@proofzero/utils": "workspace:*",
"@trpc/server": "10.8.1",
"@types/node": "18.15.3",
"@zerodevapp/sdk": "3.1.37",
"@zerodevapp/sdk": "3.1.39",
"do-proxy": "1.3.3",
"jose": "4.11.0",
"remix-auth-google": "1.2.0",
Expand Down
4 changes: 0 additions & 4 deletions platform/address/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ interface CreateInnerContextOptions
DELAY_BETWEEN_REGENERATION_ATTEMPTS_IN_MS: number
REGENERATION_COOLDOWN_PERIOD_IN_MS: number
MAX_ATTEMPTS_TIME_PERIOD_IN_MS: number
ALCHEMY_MUMBAI_PROVIDER_URL: string
ALCHEMY_POLYGON_PROVIDER_URL: string
ALCHEMY_GOERLI_PROVIDER_URL: string
ALCHEMY_ETH_PROVIDER_URL: string

SECRET_ZERODEV_PROJECTID: string

Expand Down
32 changes: 0 additions & 32 deletions platform/address/src/jsonrpc/methods/initSmartContractWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { z } from 'zod'
import { Wallet } from '@ethersproject/wallet'

import { AddressURNInput } from '@proofzero/platform-middleware/inputValidators'
import { JsonRpcProvider } from '@ethersproject/providers'

import createEdgesClient from '@proofzero/platform-clients/edges'
import { Context } from '../../context'
Expand Down Expand Up @@ -46,39 +45,8 @@ export const initSmartContractWalletMethod = async ({

const owner = Wallet.createRandom()

const projectInfoRes = await fetch(
`https://prod-api.zerodev.app/projects/${ctx.SECRET_ZERODEV_PROJECTID}`,
{ headers: { accept: 'application/json' } }
)

const projectInfo = (await projectInfoRes.json()) as {
id: string
name: string
chainId: string
}

let ALCHEMY_PROVIDER_URL = ctx.ALCHEMY_MUMBAI_PROVIDER_URL // by default

switch (projectInfo.chainId) {
case '1':
ALCHEMY_PROVIDER_URL = ctx.ALCHEMY_ETH_PROVIDER_URL
break
case '5':
ALCHEMY_PROVIDER_URL = ctx.ALCHEMY_GOERLI_PROVIDER_URL
break
case '137':
ALCHEMY_PROVIDER_URL = ctx.ALCHEMY_POLYGON_PROVIDER_URL
break
case '80001':
ALCHEMY_PROVIDER_URL = ctx.ALCHEMY_MUMBAI_PROVIDER_URL
}

const smartContractWallet = await getZeroDevSigner({
skipFetchSetup: true,
rpcProvider: new JsonRpcProvider({
url: ALCHEMY_PROVIDER_URL,
skipFetchSetup: true,
}),
projectId: ctx.SECRET_ZERODEV_PROJECTID,
owner,
})
Expand Down
32 changes: 0 additions & 32 deletions platform/address/src/jsonrpc/methods/registerWalletSessionKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { z } from 'zod'

import { Context } from '../../context'
import { initAddressNodeByName } from '../../nodes'
import { JsonRpcProvider } from '@ethersproject/providers'
import {
createSessionKey,
getZeroDevSigner,
Expand Down Expand Up @@ -58,40 +57,9 @@ export const registerSessionKeyMethod = async ({
let sessionKey = ''

if (paymaster && paymaster.provider === 'zerodev') {
const projectInfoRes = await fetch(
`https://prod-api.zerodev.app/projects/${paymaster.secret}`,
{ headers: { accept: 'application/json' } }
)

const projectInfo = (await projectInfoRes.json()) as {
id: string
name: string
chainId: string
}

let ALCHEMY_PROVIDER_URL = ctx.ALCHEMY_MUMBAI_PROVIDER_URL // by default

switch (projectInfo.chainId) {
case '1':
ALCHEMY_PROVIDER_URL = ctx.ALCHEMY_ETH_PROVIDER_URL
break
case '5':
ALCHEMY_PROVIDER_URL = ctx.ALCHEMY_GOERLI_PROVIDER_URL
break
case '137':
ALCHEMY_PROVIDER_URL = ctx.ALCHEMY_POLYGON_PROVIDER_URL
break
case '80001':
ALCHEMY_PROVIDER_URL = ctx.ALCHEMY_MUMBAI_PROVIDER_URL
}

const zdSigner = await getZeroDevSigner({
projectId: paymaster.secret,
owner: getPrivateKeyOwner(ownerPrivateKey),
rpcProvider: new JsonRpcProvider({
url: ALCHEMY_PROVIDER_URL,
skipFetchSetup: true,
}),
skipFetchSetup: true,
})

Expand Down
4 changes: 0 additions & 4 deletions platform/address/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ export interface Environment {
DELAY_BETWEEN_REGENERATION_ATTEMPTS_IN_MS: number
REGENERATION_COOLDOWN_PERIOD_IN_MS: number
MAX_ATTEMPTS_TIME_PERIOD_IN_MS: number
ALCHEMY_MUMBAI_PROVIDER_URL: string
ALCHEMY_POLYGON_PROVIDER_URL: string
ALCHEMY_GOERLI_PROVIDER_URL: string
ALCHEMY_ETH_PROVIDER_URL: string

SECRET_ZERODEV_PROJECTID: string

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6236,7 +6236,7 @@ __metadata:
"@types/node": 18.15.3
"@typescript-eslint/eslint-plugin": 5.42.1
"@typescript-eslint/parser": 5.42.1
"@zerodevapp/sdk": 3.1.37
"@zerodevapp/sdk": 3.1.39
do-proxy: 1.3.3
env-cmd: 10.1.0
eslint: 8.28.0
Expand Down Expand Up @@ -14206,9 +14206,9 @@ __metadata:
languageName: node
linkType: hard

"@zerodevapp/sdk@npm:3.1.37":
version: 3.1.37
resolution: "@zerodevapp/sdk@npm:3.1.37"
"@zerodevapp/sdk@npm:3.1.39":
version: 3.1.39
resolution: "@zerodevapp/sdk@npm:3.1.39"
dependencies:
"@account-abstraction/contracts": ^0.6.0
"@account-abstraction/utils": ^0.4.0
Expand All @@ -14230,7 +14230,7 @@ __metadata:
merkletreejs: ^0.3.9
peerDependencies:
ethers: ^5.7.0
checksum: 58f0bc2ff408e04d0a7d41bedff7fbcaab1aaca769307e1a44de6b2b02188575f358ce672348571e40e324d8525230aca300cc9d5c7d3ba6c49c34b42f05ae93
checksum: 1274cd5eac1c68bec37ba35312fee0efaeb3cbd14b131dd04f621717c0432be838f3e8634ef91f8d5181e31d6b872b38a3185aba60369afd6923ed91aad747cc
languageName: node
linkType: hard

Expand Down

0 comments on commit d9d234c

Please sign in to comment.