Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 91
feat: add Admin scripts for Single Request Proxy Factory#1478
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a19482169d7b4c195297dd354a0a3beb884File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { EvmChains } from '@requestnetwork/currency'; | ||
| import { singleRequestProxyFactoryArtifact } from '../../src/lib'; | ||
| import { HardhatRuntimeEnvironmentExtended } from '../types'; | ||
| import { | ||
| getSignerAndGasFees, | ||
| updateSRPFERC20FeeProxyAddress, | ||
| updateSRPFEthereumFeeProxyAddress, | ||
| } from './adminTasks'; | ||
| /** | ||
| * Setup the SingleRequestProxyFactory values once deployed | ||
| * @param contractAddress address of the SingleRequestProxyFactory contract | ||
| * If not provided fallback to the latest deployment address | ||
| * @param hre Hardhat runtime environment | ||
| * @param signWithEoa Are transactions to be signed by an EOA | ||
| */ | ||
MantisClone marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| export const setupSRPF = async ({ | ||
| contractAddress, | ||
| hre, | ||
| signWithEoa, | ||
| }: { | ||
| contractAddress?: string; | ||
| hre: HardhatRuntimeEnvironmentExtended; | ||
| signWithEoa: boolean; | ||
| }): Promise<void> => { | ||
| await Promise.all( | ||
| hre.config.xdeploy.networks.map(async (network: string) => { | ||
| try { | ||
MantisClone marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| EvmChains.assertChainSupported(network); | ||
| if (!contractAddress) { | ||
| contractAddress = singleRequestProxyFactoryArtifact.getAddress(network); | ||
| } | ||
| if (!contractAddress) { | ||
| console.warn(`Missing SingleRequestProxyFactory deployment on ${network}`); | ||
| return; | ||
| } | ||
MantisClone marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| const factory = new hre.ethers.Contract( | ||
| contractAddress, | ||
| singleRequestProxyFactoryArtifact.getContractAbi(), | ||
| ); | ||
| const { signer, txOverrides } = await getSignerAndGasFees(network, hre); | ||
| const factoryConnected = factory.connect(signer); | ||
MantisClone marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| await updateSRPFERC20FeeProxyAddress( | ||
| factoryConnected, | ||
| network, | ||
| txOverrides, | ||
| signer, | ||
| signWithEoa, | ||
| ); | ||
| await updateSRPFEthereumFeeProxyAddress( | ||
| factoryConnected, | ||
| network, | ||
| txOverrides, | ||
| signer, | ||
| signWithEoa, | ||
| ); | ||
| console.log(`Setup of SingleRequestProxyFactory successful on ${network}`); | ||
| } catch (err) { | ||
| console.warn( | ||
| `An error occurred during the setup of SingleRequestProxyFactory on ${network}`, | ||
| ); | ||
| console.warn(err); | ||
| } | ||
| }), | ||
| ); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider refactoring to reduce code duplication between proxy update functions.
The two functions share almost identical structure and differ only in method names and variable names. Consider refactoring into a single function with a type parameter:
This refactoring:
ProxyTypetype📝 Committable suggestion