Skip to content

Commit

Permalink
OG-1035: Add deployment script function and artifact for SingletonWhi…
Browse files Browse the repository at this point in the history
…telistPaymaster (#967)

* Add deployment script function and artifact for SingletonWhitelistPaymaster
  • Loading branch information
forshtat authored Apr 11, 2023
1 parent ba2c451 commit b9abb2f
Show file tree
Hide file tree
Showing 5 changed files with 1,559 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"scripts": {
"test": "yarn preprocess && yarn lerna-run-test-with-hardhat",
"hardhat-fork-mainnet": "CHAINID=1 hardhat node --port 8544 --fork https://mainnet.infura.io/v3/f40be2b1a3914db682491dc62a19ad43 --fork-block-number 16814541",
"hardhat-fork-goerli": "CHAINID=5 hardhat node --port 8544 --fork https://goerli.infura.io/v3/f40be2b1a3914db682491dc62a19ad43 --fork-block-number 8716348",
"hardhat-fork-goerli": "CHAINID=5 hardhat node --port 8544 --fork https://goerli.infura.io/v3/f40be2b1a3914db682491dc62a19ad43 --fork-block-number 8806897",
"preprocess": "yarn lerna-rm-dist && yarn lerna-typechain-generate && yarn extract_abi && yarn lerna-tsc && yarn lerna-chmod-commands",
"preprocess-paymasters": "yarn lerna-rm-dist --scope @opengsn/paymasters && yarn lerna-typechain-generate-paymasters && yarn extract_abi_paymasters && yarn lerna-tsc-paymasters",
"extract_abi": "./scripts/extract_abi.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const WETH9_CONTRACT_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc

const DAI_CONTRACT_ADDRESS_GOERLI = '0x11fe4b6ae13d2a6055c8d9cf65c55bac32b5d844'
const PERMIT_ERC20_UNISWAP_V3_PAYMASTER_GOERLI_5 = '0xc7709b37c63e116cc973842ae902462580d76104'
const SINGLETON_WHITELIST_PAYMASTER_GOERLI_5 = '0xfc9d2357570b0b2b87be4ac7461a082daaf19f4b'

const ACCEPT_EVERYTHING_PAYMASTER_AVALANCHE_FUJI = '0x735719a8c5af199ea5b93207083787a5b548c0e2'
const ACCEPT_EVERYTHING_PAYMASTER_BSC_TESTNET = '0x735719a8c5af199ea5b93207083787a5b548c0e2'
Expand Down Expand Up @@ -111,6 +112,11 @@ export const OfficialPaymasterDeployments: DeploymentObject = {
}
}
},
[PaymasterType.SingletonWhitelistPaymaster]: {
type: PaymasterType.SingletonWhitelistPaymaster,
address: SINGLETON_WHITELIST_PAYMASTER_GOERLI_5,
supportedTokensERC20: {}
},
[PaymasterType.AcceptEverythingPaymaster]:
{
type: PaymasterType.AcceptEverythingPaymaster,
Expand Down
42 changes: 40 additions & 2 deletions packages/paymasters/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { HttpNetworkConfig } from 'hardhat/src/types/config'
import { ethers } from 'hardhat'
import { formatEther } from 'ethers/lib/utils'

import { Address } from '@opengsn/common'
import { Address, PaymasterType } from '@opengsn/common'

// TODO: extract duplicated code to utils
// helper: nicer logging view fo deployed contracts
Expand Down Expand Up @@ -94,9 +94,12 @@ export default async function deploymentFunc (hre: HardhatRuntimeEnvironment): P
const paymasterToDeploy = process.env.PAYMASTER_TO_DEPLOY
const chainId = parseInt(await hre.getChainId())
switch (paymasterToDeploy) {
case 'PermitERC20UniswapV3Paymaster':
case PaymasterType.PermitERC20UniswapV3Paymaster:
await deployPermitERC20UniswapV3Paymaster(deployments, deployer, chainId)
break
case PaymasterType.SingletonWhitelistPaymaster:
await deploySingletonWhitelistPaymaster(deployments, deployer, chainId)
break
default:
throw new Error(`Unknown PAYMASTER_TO_DEPLOY env variable: ${paymasterToDeploy}`)
}
Expand All @@ -122,3 +125,38 @@ async function deployPermitERC20UniswapV3Paymaster (
console.log('current paymaster balance=', formatEther(paymasterBalance))
// TODO: support depositing based on paymaster type
}

async function deploySingletonWhitelistPaymaster (
deployments: DeploymentsExtension,
deployer: Address,
chainId: number
): Promise<void> {
// TODO: Hub and Forwarder address are shared across Paymasters - refactor
const allConfigurations = require(deploymentConfigFile()) as PaymasterDeploymentConfig
const config = allConfigurations[chainId]?.PermitERC20UniswapV3Paymaster
console.log('Will deploy SingletonWhitelistPaymaster')
const paymasterName = 'SingletonWhitelistPaymaster'
await deploy(deployments, paymasterName, {
from: deployer
})
// TODO: read it from the file!
await deployments.execute(
paymasterName,
{ from: deployer, log: true },
'setSharedConfiguration',
30000,
15
)
await deployments.execute(
paymasterName,
{ from: deployer, log: true },
'setRelayHub',
config.GSN_HUB_CONTRACT_ADDRESS
)
await deployments.execute(
paymasterName,
{ from: deployer, log: true },
'setTrustedForwarder',
config.GSN_FORWARDER_CONTRACT_ADDRESS
)
}
Loading

0 comments on commit b9abb2f

Please sign in to comment.