-
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
Merged
aimensahnoun
merged 5 commits into
master
from
1462-add-admins-scripts-for-the-singlerequestproxyfactory-to-the-sdk
Nov 5, 2024
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a194821
feat: add `SingleRequestProxyFactory` artifacts to getArtifacts method
aimensahnoun 69d7b4c
feat: add task to update the `SingleRequestProxyFactory` fee proxy ad…
aimensahnoun 195297d
Merge branch 'master' of github.com:RequestNetwork/requestNetwork int…
aimensahnoun d354a0a
refactor: refactor admin scripts
aimensahnoun 3beb884
refactor: rename `SRPF` functions
aimensahnoun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
packages/smart-contracts/scripts-create2/contract-setup/update-fee-proxies.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import { | ||
| singleRequestProxyFactoryArtifact, | ||
| erc20FeeProxyArtifact, | ||
| ethereumFeeProxyArtifact, | ||
| } from '../../src/lib'; | ||
| import { HardhatRuntimeEnvironmentExtended } from '../types'; | ||
| import { getSignerAndGasFees } from './adminTasks'; | ||
| import { EvmChains } from '@requestnetwork/currency'; | ||
| import { executeContractMethod } from './execute-contract-method'; | ||
| import { Contract } from 'ethers'; | ||
|
|
||
| /** | ||
| * Update the proxy addresses in the SingleRequestProxyFactory contract | ||
| * @param hre Hardhat runtime environment | ||
| * @param signWithEoa Are transactions to be signed by an EOA | ||
| */ | ||
| export const updateFeeProxies = async ( | ||
aimensahnoun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| hre: HardhatRuntimeEnvironmentExtended, | ||
| signWithEoa: boolean, | ||
| ): Promise<void> => { | ||
aimensahnoun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for (const network of hre.config.xdeploy.networks) { | ||
| try { | ||
| EvmChains.assertChainSupported(network); | ||
|
|
||
| const factoryAddress = singleRequestProxyFactoryArtifact.getAddress(network); | ||
| const erc20ProxyAddress = erc20FeeProxyArtifact.getAddress(network); | ||
| const ethereumProxyAddress = ethereumFeeProxyArtifact.getAddress(network); | ||
|
|
||
| if (!factoryAddress || !erc20ProxyAddress || !ethereumProxyAddress) { | ||
| console.info(`Missing contract deployment on ${network}`); | ||
| continue; | ||
aimensahnoun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| const { signer, txOverrides } = await getSignerAndGasFees(network, hre); | ||
|
|
||
| const factory = new Contract(factoryAddress, factoryAbi, signer); | ||
|
|
||
| // Check current values | ||
| const currentErc20Proxy = await factory.erc20FeeProxy(); | ||
| const currentEthereumProxy = await factory.ethereumFeeProxy(); | ||
|
|
||
| // Update ERC20 proxy if needed | ||
| if (currentErc20Proxy.toLowerCase() !== erc20ProxyAddress.toLowerCase()) { | ||
| await executeContractMethod({ | ||
aimensahnoun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| network, | ||
| contract: factory, | ||
| method: 'setERC20FeeProxy', | ||
| props: [erc20ProxyAddress], | ||
| txOverrides, | ||
| signer, | ||
| signWithEoa, | ||
| }); | ||
| console.log(`Updated ERC20FeeProxy to ${erc20ProxyAddress} on ${network}`); | ||
| } else { | ||
| console.log(`ERC20FeeProxy is already set to ${erc20ProxyAddress} on ${network}`); | ||
| } | ||
|
|
||
| // Update Ethereum proxy if needed | ||
| if (currentEthereumProxy.toLowerCase() !== ethereumProxyAddress.toLowerCase()) { | ||
| await executeContractMethod({ | ||
aimensahnoun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| network, | ||
| contract: factory, | ||
| method: 'setEthereumFeeProxy', | ||
| props: [ethereumProxyAddress], | ||
| txOverrides, | ||
| signer, | ||
| signWithEoa, | ||
| }); | ||
aimensahnoun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| console.log(`Updated EthereumFeeProxy to ${ethereumProxyAddress} on ${network}`); | ||
| } else { | ||
| console.log(`EthereumFeeProxy is already set to ${ethereumProxyAddress} on ${network}`); | ||
| } | ||
| } catch (err) { | ||
| console.warn(`An error occurred updating proxies on ${network}`); | ||
| console.warn(err); | ||
| } | ||
MantisClone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| }; | ||
|
|
||
| const factoryAbi = [ | ||
| 'function erc20FeeProxy() view returns (address)', | ||
| 'function ethereumFeeProxy() view returns (address)', | ||
| 'function setERC20FeeProxy(address _newERC20FeeProxy)', | ||
| 'function setEthereumFeeProxy(address _newEthereumFeeProxy)', | ||
| ]; | ||
aimensahnoun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.