From a52c72680b89f74ca91e99c6abd3569fa9089954 Mon Sep 17 00:00:00 2001 From: Romain TREFAULT Date: Thu, 28 Jul 2022 10:22:08 +0200 Subject: [PATCH 01/11] refactor: command to create request --- packages/toolbox/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/toolbox/README.md b/packages/toolbox/README.md index f86129022..072f779b0 100644 --- a/packages/toolbox/README.md +++ b/packages/toolbox/README.md @@ -27,8 +27,8 @@ CreateRequest.createTestRequest(12); #### In the CLI ```bash -yarn run:create -yarn run:create 12 +yarn request-toolbox request create +yarn request-toolbox request create 12 ``` ### Conversion paths From b4707e3bbd8b41e43918f065f1d81ebc864a958f Mon Sep 17 00:00:00 2001 From: Darko Kolev Date: Thu, 7 Jul 2022 17:51:55 +0300 Subject: [PATCH 02/11] fix: escrow audit fix 2 (#878) --- .../src/contracts/ERC20EscrowToPay.sol | 10 +++++-- .../test/contracts/ERC20EscrowToPay.test.ts | 30 ++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/packages/smart-contracts/src/contracts/ERC20EscrowToPay.sol b/packages/smart-contracts/src/contracts/ERC20EscrowToPay.sol index a961db772..cda270218 100644 --- a/packages/smart-contracts/src/contracts/ERC20EscrowToPay.sol +++ b/packages/smart-contracts/src/contracts/ERC20EscrowToPay.sol @@ -151,13 +151,19 @@ contract ERC20EscrowToPay is Ownable { revert('not payable receive'); } + /** + * @notice Sets duration of emergency period, with minimum value of 30 days. + */ function setEmergencyClaimPeriod(uint256 _emergencyClaimPeriod) external onlyOwner { - require(_emergencyClaimPeriod >= 30, 'emergency period too short'); + require(_emergencyClaimPeriod >= 30 days, 'emergency period too short'); emergencyClaimPeriod = _emergencyClaimPeriod; } + /** + * @notice Sets duration of freeze period, with minimum value of 30 days. + */ function setFrozenPeriod(uint256 _frozenPeriod) external onlyOwner { - require(_frozenPeriod >= 30, 'frozen period too short'); + require(_frozenPeriod >= 30 days, 'frozen period too short'); frozenPeriod = _frozenPeriod; } diff --git a/packages/smart-contracts/test/contracts/ERC20EscrowToPay.test.ts b/packages/smart-contracts/test/contracts/ERC20EscrowToPay.test.ts index 0f3ac5148..4cca90f13 100644 --- a/packages/smart-contracts/test/contracts/ERC20EscrowToPay.test.ts +++ b/packages/smart-contracts/test/contracts/ERC20EscrowToPay.test.ts @@ -259,19 +259,33 @@ describe('Contract: ERC20EscrowToPay', () => { }); }); describe('Admin should be able to change emergency and freeze periods', () => { - it('Should be able to change emergency period', async () => { + it('Minimum emergency period is 30 days', async () => { const twoDaysInSeconds = 3600 * 24 * 2; - await erc20EscrowToPay.connect(admin).setEmergencyClaimPeriod(twoDaysInSeconds); + expect( + erc20EscrowToPay.connect(admin).setEmergencyClaimPeriod(twoDaysInSeconds), + ).to.be.revertedWith('emergency period too short'); + }); + + it('Minimum frozen period is 30 days', async () => { + const twentyNineDaysInSeconds = 3600 * 24 * 29; + expect( + erc20EscrowToPay.connect(admin).setFrozenPeriod(twentyNineDaysInSeconds), + ).to.be.revertedWith('frozen period too short'); + }); + + it('Should be able to adjust emergency period', async () => { + const thirtyOneDaysInSeconds = 3600 * 24 * 31; + await erc20EscrowToPay.connect(admin).setEmergencyClaimPeriod(thirtyOneDaysInSeconds); const contractEmergencyPeriod = await erc20EscrowToPay.connect(payee).emergencyClaimPeriod(); - expect(contractEmergencyPeriod).to.be.equal(twoDaysInSeconds); + expect(contractEmergencyPeriod).to.be.equal(thirtyOneDaysInSeconds); }); - it('Should be able to adjust freeze period, only admin', async () => { - const twoDaysInSeconds = 3600 * 24 * 2; - await erc20EscrowToPay.connect(admin).setFrozenPeriod(twoDaysInSeconds); + it('Should be able to adjust freeze period', async () => { + const thirtyOneDaysInSeconds = 3600 * 24 * 31; + await erc20EscrowToPay.connect(admin).setFrozenPeriod(thirtyOneDaysInSeconds); const contractFreezePeriod = await erc20EscrowToPay.connect(payee).frozenPeriod(); - expect(contractFreezePeriod).to.be.equal(twoDaysInSeconds); + expect(contractFreezePeriod).to.be.equal(thirtyOneDaysInSeconds); }); - it('Contract creator should not be able to change periods', async () => { + it('Contract creator who is not the owner, should not be able to change periods', async () => { expect(erc20EscrowToPay.connect(owner).setEmergencyClaimPeriod(100)).to.be.revertedWith( 'Ownable: caller is not the owner', ); From 76ea2e62e560b68602d5c7941a00a5b66005da8a Mon Sep 17 00:00:00 2001 From: olivier7delf <55892112+olivier7delf@users.noreply.github.com> Date: Mon, 11 Jul 2022 10:58:06 +0200 Subject: [PATCH 03/11] fix(smart-contracts): update batch fees (#873) update batch fees from 1% to .3% --- .../scripts-create2/contract-setup/adminTasks.ts | 6 ++++-- .../scripts-create2/contract-setup/setupBatchPayments.ts | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/smart-contracts/scripts-create2/contract-setup/adminTasks.ts b/packages/smart-contracts/scripts-create2/contract-setup/adminTasks.ts index b33fe6fcb..a2c8d6ffc 100644 --- a/packages/smart-contracts/scripts-create2/contract-setup/adminTasks.ts +++ b/packages/smart-contracts/scripts-create2/contract-setup/adminTasks.ts @@ -5,8 +5,8 @@ import { BigNumber } from 'ethers'; // Fees: 0.5% export const REQUEST_SWAP_FEES = 5; -// Batch Fees: 1% -export const BATCH_FEE = 10; +// Batch Fees: .3% +export const BATCH_FEE = 3; export const updateChainlinkConversionPath = async ( contract: any, @@ -57,6 +57,8 @@ export const updateBatchPaymentFees = async ( ): Promise => { const currentFees = await contract.batchFee(); if (currentFees !== BATCH_FEE) { + // Log is useful to have a direct view on was is being updated + console.log(`currentFees: ${currentFees.toString()}, new fees: ${BATCH_FEE}`); await contract.setBatchFee(BATCH_FEE, { nonce: nonce, gasPrice: gasPrice }); } }; diff --git a/packages/smart-contracts/scripts-create2/contract-setup/setupBatchPayments.ts b/packages/smart-contracts/scripts-create2/contract-setup/setupBatchPayments.ts index db3b703bc..78fa718e0 100644 --- a/packages/smart-contracts/scripts-create2/contract-setup/setupBatchPayments.ts +++ b/packages/smart-contracts/scripts-create2/contract-setup/setupBatchPayments.ts @@ -37,9 +37,9 @@ export const setupBatchPayments = async ( // start from the adminNonce, increase gasPrice if needed await Promise.all([ - updateBatchPaymentFees(batchPaymentConnected, adminNonce, gasPrice), - updatePaymentErc20FeeProxy(batchPaymentConnected, network, adminNonce + 1, gasPrice), - updatePaymentEthFeeProxy(batchPaymentConnected, network, adminNonce + 2, gasPrice), + updateBatchPaymentFees(batchPaymentConnected, adminNonce, gasPrice.mul(2)), + updatePaymentErc20FeeProxy(batchPaymentConnected, network, adminNonce + 1, gasPrice.mul(2)), + updatePaymentEthFeeProxy(batchPaymentConnected, network, adminNonce + 2, gasPrice.mul(2)), ]); }), ); From 56afdcffb426bcd3cc386ee4bb95f301d41336ff Mon Sep 17 00:00:00 2001 From: Bertrand Juglas Date: Tue, 12 Jul 2022 19:04:45 +0200 Subject: [PATCH 04/11] feat: add cancel stream function (#884) --- .../src/payment/erc777-stream.ts | 99 ++++++++++++++----- .../test/payment/erc777-stream.test.ts | 58 +++++++++-- 2 files changed, 126 insertions(+), 31 deletions(-) diff --git a/packages/payment-processor/src/payment/erc777-stream.ts b/packages/payment-processor/src/payment/erc777-stream.ts index 01a627db9..ef2553118 100644 --- a/packages/payment-processor/src/payment/erc777-stream.ts +++ b/packages/payment-processor/src/payment/erc777-stream.ts @@ -10,12 +10,16 @@ import { } from './utils'; import { Framework } from '@superfluid-finance/sdk-core'; -export const resolverAddress = '0x913bbCFea2f347a24cfCA441d483E7CBAc8De3Db'; +export const RESOLVER_ADDRESS = '0x913bbCFea2f347a24cfCA441d483E7CBAc8De3Db'; +// Superfluid payments of requests use the generic field `userData` to index payments. +// Since it's a multi-purpose field, payments will use a fix-prefix heading the payment reference, +// in order to speed up the indexing and payment detection. +export const USERDATA_PREFIX = '0xbeefac'; /** * Processes a transaction to pay an ERC777 stream Request. * @param request - * @param signerOrProvider the Web3 provider, or signer. Defaults to window.ethereum. + * @param signer the Web3 signer. Defaults to window.ethereum. * @param overrides optionally, override default transaction values, like gas. */ export async function payErc777StreamRequest( @@ -28,35 +32,84 @@ export async function payErc777StreamRequest( throw new Error('Not a supported ERC777 payment network request'); } validateRequest(request, PaymentTypes.PAYMENT_NETWORK_ID.ERC777_STREAM); - const networkName = - request.currencyInfo.network === 'private' ? 'custom' : request.currencyInfo.network; - const sf = await Framework.create({ - networkName, - provider: signer.provider ?? getProvider(), - dataMode: request.currencyInfo.network === 'private' ? 'WEB3_ONLY' : undefined, - resolverAddress: request.currencyInfo.network === 'private' ? resolverAddress : undefined, - protocolReleaseVersion: request.currencyInfo.network === 'private' ? 'test' : undefined, - }); - const superSigner = sf.createSigner({ - signer: signer, - provider: signer.provider, - }); - const superToken = await sf.loadSuperToken(request.currencyInfo.value); + const sf = await getSuperFluidFramework(request, signer); // FIXME: according to specs PR https://github.com/RequestNetwork/requestNetwork/pull/688 // in file packages/advanced-logic/specs/payment-network-erc777-stream-0.1.0.md + // Below are the SF actions to add in the BatchCall: // - use expectedStartDate to compute offset between start of invoicing and start of streaming // - start fee streaming + const streamPayOp = await getStartStreamOp(sf, request, overrides); + const batchCall = sf.batchCall([streamPayOp]); + return batchCall.exec(signer); +} + +/** + * Processes a transaction to complete an ERC777 stream paying a Request. + * @param request + * @param signer the Web3 signer. Defaults to window.ethereum. + * @param overrides optionally, override default transaction values, like gas. + */ +export async function completeErc777StreamRequest( + request: ClientTypes.IRequestData, + signer: Signer, + overrides?: Overrides, +): Promise { + const id = getPaymentNetworkExtension(request)?.id; + if (id !== ExtensionTypes.ID.PAYMENT_NETWORK_ERC777_STREAM) { + throw new Error('Not a supported ERC777 payment network request'); + } + validateRequest(request, PaymentTypes.PAYMENT_NETWORK_ID.ERC777_STREAM); + const sf = await getSuperFluidFramework(request, signer); + // FIXME: according to specs PR https://github.com/RequestNetwork/requestNetwork/pull/688 + // in file packages/advanced-logic/specs/payment-network-erc777-stream-0.1.0.md + // Below are the SF actions to add in the BatchCall : + // - use expectedEndDate to compute offset between stop of invoicing and stop of streaming + // - stop fee streaming + const streamPayOp = await getStopStreamOp(sf, signer, request, overrides); + const batchCall = sf.batchCall([streamPayOp]); + return batchCall.exec(signer); +} + +async function getSuperFluidFramework(request: ClientTypes.IRequestData, signer: Signer) { + const isNetworkPrivate = request.currencyInfo.network === 'private'; + const networkName = isNetworkPrivate ? 'custom' : request.currencyInfo.network; + return await Framework.create({ + networkName, + provider: signer.provider ?? getProvider(), + dataMode: isNetworkPrivate ? 'WEB3_ONLY' : undefined, + resolverAddress: isNetworkPrivate ? RESOLVER_ADDRESS : undefined, + protocolReleaseVersion: isNetworkPrivate ? 'test' : undefined, + }); +} +async function getStartStreamOp( + sf: Framework, + request: ClientTypes.IRequestData, + overrides?: Overrides, +) { + const superToken = await sf.loadSuperToken(request.currencyInfo.value); const { paymentReference, paymentAddress, expectedFlowRate } = getRequestPaymentValues(request); - // Superfluid payments of requests use the generic field `userData` to index payments. - // Since it's a multi-purpose field, payments will use a fix-prefix heading the payment reference, - // in order to speed up the indexing and payment detection. - const streamPayOp = sf.cfaV1.createFlow({ + return sf.cfaV1.createFlow({ flowRate: expectedFlowRate ?? '0', receiver: paymentAddress, superToken: superToken.address, - userData: `0xbeefac${paymentReference}`, + userData: `${USERDATA_PREFIX}${paymentReference}`, + overrides: overrides, + }); +} + +async function getStopStreamOp( + sf: Framework, + signer: Signer, + request: ClientTypes.IRequestData, + overrides?: Overrides, +) { + const superToken = await sf.loadSuperToken(request.currencyInfo.value); + const { paymentReference, paymentAddress } = getRequestPaymentValues(request); + return sf.cfaV1.deleteFlow({ + superToken: superToken.address, + sender: await signer.getAddress(), + receiver: paymentAddress, + userData: `${USERDATA_PREFIX}${paymentReference}`, overrides: overrides, }); - const batchCall = sf.batchCall([streamPayOp]); - return batchCall.exec(superSigner); } diff --git a/packages/payment-processor/test/payment/erc777-stream.test.ts b/packages/payment-processor/test/payment/erc777-stream.test.ts index 605e3f03d..644e71225 100644 --- a/packages/payment-processor/test/payment/erc777-stream.test.ts +++ b/packages/payment-processor/test/payment/erc777-stream.test.ts @@ -10,7 +10,11 @@ import { } from '@requestnetwork/types'; import Utils from '@requestnetwork/utils'; -import { payErc777StreamRequest, resolverAddress } from '../../src/payment/erc777-stream'; +import { + completeErc777StreamRequest, + payErc777StreamRequest, + RESOLVER_ADDRESS, +} from '../../src/payment/erc777-stream'; import { getRequestPaymentValues } from '../../src/payment/utils'; const daiABI = require('../abis/fDAIABI'); @@ -120,8 +124,8 @@ describe('erc777-stream', () => { }); }); - describe('payErc777StreamRequest', () => { - it('should pay an ERC777 request with fees', async () => { + describe('Streams management', () => { + it('payErc777StreamRequest should pay an ERC777 request', async () => { let tx; let confirmedTx; // initialize the superfluid framework...put custom and web3 only bc we are using ganache locally @@ -129,7 +133,7 @@ describe('erc777-stream', () => { networkName: 'custom', provider, dataMode: 'WEB3_ONLY', - resolverAddress: resolverAddress, + resolverAddress: RESOLVER_ADDRESS, protocolReleaseVersion: 'test', }); @@ -183,18 +187,56 @@ describe('erc777-stream', () => { expect(confirmedTx.status).toBe(1); expect(tx.hash).not.toBeUndefined(); - const wFlowRate = await sf.cfaV1.getNetFlow({ + const walletFlowRate = await sf.cfaV1.getNetFlow({ + superToken: daix.address, + account: wallet.address, + providerOrSigner: provider, + }); + expect(walletFlowRate).toBe(`-${expectedFlowRate}`); + const paymentFlowRate = await sf.cfaV1.getNetFlow({ + superToken: daix.address, + account: paymentAddress, + providerOrSigner: provider, + }); + expect(paymentFlowRate).toBe(expectedFlowRate); + }); + + it('completeErc777StreamRequest should complete an ERC777 request', async () => { + let tx; + let confirmedTx; + // initialize the superfluid framework...put custom and web3 only bc we are using ganache locally + const sf = await Framework.create({ + networkName: 'custom', + provider, + dataMode: 'WEB3_ONLY', + resolverAddress: RESOLVER_ADDRESS, + protocolReleaseVersion: 'test', + }); + + // use the framework to get the SuperToken + const daix = await sf.loadSuperToken('fDAIx'); + + // wait 2 seconds of streaming to avoid failing + await new Promise((r) => setTimeout(r, 2000)); + + // Stopping fDAIX stream request + tx = await completeErc777StreamRequest(validRequest, wallet); + confirmedTx = await tx.wait(1); + expect(confirmedTx.status).toBe(1); + expect(tx.hash).not.toBeUndefined(); + + const walletFlowRate = await sf.cfaV1.getNetFlow({ superToken: daix.address, account: wallet.address, providerOrSigner: provider, }); - expect(wFlowRate).toBe(`-${expectedFlowRate}`); - const pFlowRate = await sf.cfaV1.getNetFlow({ + expect(walletFlowRate).toBe('0'); + const paymentFlowRate = await sf.cfaV1.getNetFlow({ superToken: daix.address, account: paymentAddress, providerOrSigner: provider, }); - expect(pFlowRate).toBe(expectedFlowRate); + expect(paymentFlowRate).toBe('0'); }); }); }); From 54510349cd462d259615960f7fef33b0d1d42e91 Mon Sep 17 00:00:00 2001 From: Darko Kolev Date: Thu, 28 Jul 2022 10:05:11 +0200 Subject: [PATCH 05/11] refactor: contract setup compression fix (#888) --- packages/currency/src/native.ts | 6 + packages/smart-contracts/README.md | 86 ++++----- packages/smart-contracts/hardhat.config.ts | 10 +- .../scripts-create2/compute-one-address.ts | 14 +- .../scripts-create2/constructor-args.ts | 35 ++-- .../contract-setup/setupETHConversionProxy.ts | 47 +++++ .../scripts-create2/contract-setup/setups.ts | 168 ++++++++++++++++++ .../deploy-request-deployer.ts | 2 +- .../{deploy-one.ts => deploy.ts} | 6 +- .../smart-contracts/scripts-create2/utils.ts | 2 + .../{verify-one.ts => verify.ts} | 2 + .../src/lib/artifacts/BatchPayments/index.ts | 4 + .../ChainlinkConversionPath/index.ts | 4 + .../lib/artifacts/ERC20EscrowToPay/index.ts | 4 + .../src/lib/artifacts/ERC20FeeProxy/index.ts | 4 + .../src/lib/artifacts/ERC20SwapToPay/index.ts | 4 + .../artifacts/Erc20ConversionProxy/index.ts | 4 + .../artifacts/Erc20SwapConversion/index.ts | 4 + .../lib/artifacts/EthConversionProxy/index.ts | 4 + .../lib/artifacts/EthereumFeeProxy/index.ts | 4 + .../src/lib/artifacts/EthereumProxy/index.ts | 4 + .../lib/artifacts/RequestDeployer/index.ts | 4 + .../lib/artifacts/RequestHashStorage/index.ts | 4 + .../artifacts/RequestHashSubmitter/index.ts | 4 + 24 files changed, 365 insertions(+), 65 deletions(-) create mode 100644 packages/smart-contracts/scripts-create2/contract-setup/setupETHConversionProxy.ts create mode 100644 packages/smart-contracts/scripts-create2/contract-setup/setups.ts rename packages/smart-contracts/scripts-create2/{deploy-one.ts => deploy.ts} (93%) rename packages/smart-contracts/scripts-create2/{verify-one.ts => verify.ts} (97%) diff --git a/packages/currency/src/native.ts b/packages/currency/src/native.ts index ec6bf066e..dc1fa018d 100644 --- a/packages/currency/src/native.ts +++ b/packages/currency/src/native.ts @@ -15,6 +15,12 @@ export const nativeCurrencies: Record ``` -#### Compute the contract addresses +### Compute the contract addresses Run: @@ -152,13 +128,21 @@ yarn hardhat compute-contract-addresses It will compute the addresses of the contracts to be deployed via the request deployer. -#### Deploy the contracts +### Deploy the contracts Depending on the xdeployer config, this script will deploy the smart contracts on several chain simultaneously Environment variables needed: `ADMIN_PRIVATE_KEY` You will need the request deployer to be deployed. Then run: +To deploy all contracts to one network, use: + +```bash +NETWORK= yarn hardhat deploy-contracts-through-deployer +``` + +If you want to deploy all contracts on all networks: + ```bash yarn hardhat deploy-contracts-through-deployer ``` @@ -171,17 +155,45 @@ This command will output details about each contract deployment on each chain: - If already deployed: the network, and the contract address - If an error occured: the said error -#### Verify the contracts +### Verify the contracts -For each network the contract were deployed to run: +Verify and publish the contract code automatically to blockchain explorers, right after smart contracts compilation. You should first set the `ETHERSCAN_API_KEY` environment variable. ```bash yarn hardhat verify-contract-from-deployer --network ``` -The associated `EXPLORER_API_KEY` is mandatory. +#### Verify the contracts manually With Hardhat (legacy) -### Tests +A more generic way to verify any contract by setting constructor argments manually: + +```bash +yarn hardhat verify --network NETWORK_NAME DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1" +``` + +### Deprecated payment deployment scripts (legacy) + +The goal of this script is to let all our payment contracts be deployed with the same sequence on every chain. + +The script also verify deployed contracts. + +**Be sure that artifacts are up-to-date with most recent deployments** + +Environment variables needed: `ETHERSCAN_API_KEY`, `ADMIN_WALLET_ADDRESS`, `DEPLOYMENT_PRIVATE_KEY` + +```bash +# First check what will be done +yarn hardhat deploy-live-payments --network matic --dry-run + +# Run +yarn hardhat deploy-live-payments --network matic + +# To test locally +yarn hardhat deploy-live-payments --network private --force +yarn hardhat deploy-live-payments --network private --force --dry-run +``` + +## Tests After a local deployment: @@ -195,14 +207,6 @@ Networks and providers are configured in [hardhat.config.ts](hardhat.config.ts). Have a look at the [Hardhat documentation](https://hardhat.org/config/). -## Contract verification with Hardhat - -Verify and publish the contract code automatically to blockchain explorers, right after smart contracts compilation. You should first set the `ETHERSCAN_API_KEY` environment variable. - -```bash -yarn hardhat verify --network NETWORK_NAME DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1" -``` - ## Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. diff --git a/packages/smart-contracts/hardhat.config.ts b/packages/smart-contracts/hardhat.config.ts index c9369f911..f12fdc0d4 100644 --- a/packages/smart-contracts/hardhat.config.ts +++ b/packages/smart-contracts/hardhat.config.ts @@ -11,8 +11,8 @@ import { checkCreate2Deployer } from './scripts-create2/check-deployer'; import { deployDeployer } from './scripts-create2/deploy-request-deployer'; import { HardhatRuntimeEnvironmentExtended } from './scripts-create2/types'; import { computeCreate2DeploymentAddressesFromList } from './scripts-create2/compute-one-address'; -import { VerifyCreate2FromList } from './scripts-create2/verify-one'; -import { deployWithCreate2FromList } from './scripts-create2/deploy-one'; +import { VerifyCreate2FromList } from './scripts-create2/verify'; +import { deployWithCreate2FromList } from './scripts-create2/deploy'; import utils from '@requestnetwork/utils'; config(); @@ -69,6 +69,11 @@ export default { chainId: 4, accounts, }, + goerli: { + url: process.env.WEB3_PROVIDER_URL || 'https://goerli.infura.io/v3/YOUR_API_KEY', + chainId: 5, + accounts, + }, matic: { url: url('matic'), chainId: 137, @@ -124,6 +129,7 @@ export default { apiKey: { mainnet: process.env.ETHERSCAN_API_KEY, rinkeby: process.env.ETHERSCAN_API_KEY, + goerli: process.env.ETHERSCAN_API_KEY, // binance smart chain bsc: process.env.BSCSCAN_API_KEY, bscTestnet: process.env.BSCSCAN_API_KEY, diff --git a/packages/smart-contracts/scripts-create2/compute-one-address.ts b/packages/smart-contracts/scripts-create2/compute-one-address.ts index 17ebcc5c8..7e8c4809a 100644 --- a/packages/smart-contracts/scripts-create2/compute-one-address.ts +++ b/packages/smart-contracts/scripts-create2/compute-one-address.ts @@ -52,11 +52,19 @@ export const computeCreate2DeploymentAddressesFromList = async ( switch (contract) { case 'EthereumProxy': case 'EthereumFeeProxy': + case 'ETHConversionProxy': + case 'ERC20FeeProxy': case 'Erc20ConversionProxy': + case 'ERC20EscrowToPay': + case 'BatchPayments': case 'ERC20SwapToConversion': { - const constructorArgs = getConstructorArgs(contract); - address = await computeCreate2DeploymentAddress({ contract, constructorArgs }, hre); - console.log(`${contract.padEnd(36, ' ')}${address}`); + try { + const constructorArgs = getConstructorArgs(contract, hre.network.name); + address = await computeCreate2DeploymentAddress({ contract, constructorArgs }, hre); + console.log(`${contract.padEnd(36, ' ')}${address}`); + } catch (e) { + console.warn(`ERROR computing address of ${contract}: ${e}`); + } break; } // Other cases to add when necessary diff --git a/packages/smart-contracts/scripts-create2/constructor-args.ts b/packages/smart-contracts/scripts-create2/constructor-args.ts index 1d462ff12..db9d4952e 100644 --- a/packages/smart-contracts/scripts-create2/constructor-args.ts +++ b/packages/smart-contracts/scripts-create2/constructor-args.ts @@ -1,27 +1,33 @@ import * as artifacts from '../src/lib'; +const getAdminWalletAddress = (contract: string): string => { + if (!process.env.ADMIN_WALLET_ADDRESS) { + throw new Error(`ADMIN_WALLET_ADDRESS missing to get constructor args for: ${contract}`); + } + return process.env.ADMIN_WALLET_ADDRESS; +}; + export const getConstructorArgs = (contract: string, network?: string): string[] => { switch (contract) { case 'Erc20ConversionProxy': { - if (!process.env.ADMIN_WALLET_ADDRESS) { - throw new Error(`ADMIN_WALLET_ADDRESS missing to get constructor args for: ${contract}`); - } return [ '0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', - process.env.ADMIN_WALLET_ADDRESS, + getAdminWalletAddress(contract), + ]; + } + case 'ETHConversionProxy': { + return [ + '0x0000000000000000000000000000000000000000', + '0x0000000000000000000000000000000000000000', + '0x39e19aa5b69466dfdc313c7cda37cb2a599015cd', ]; + // TODO setupETHConversionProxy } case 'ERC20SwapToConversion': { - if (!process.env.ADMIN_WALLET_ADDRESS) { - throw new Error(`ADMIN_WALLET_ADDRESS missing to get constructor args for: ${contract}`); - } - return [process.env.ADMIN_WALLET_ADDRESS]; + return [getAdminWalletAddress(contract)]; } case 'ERC20EscrowToPay': { - if (!process.env.ADMIN_WALLET_ADDRESS) { - throw new Error(`ADMIN_WALLET_ADDRESS missing to get constructor args for: ${contract}`); - } if (!network) { throw new Error( 'Escrow contract requires network parameter to get correct address of erc20FeeProxy', @@ -29,12 +35,9 @@ export const getConstructorArgs = (contract: string, network?: string): string[] } const erc20FeeProxy = artifacts.erc20FeeProxyArtifact; const erc20FeeProxyAddress = erc20FeeProxy.getAddress(network); - return [erc20FeeProxyAddress, process.env.ADMIN_WALLET_ADDRESS]; + return [erc20FeeProxyAddress, getAdminWalletAddress(contract)]; } case 'BatchPayments': { - if (!process.env.ADMIN_WALLET_ADDRESS) { - throw new Error(`ADMIN_WALLET_ADDRESS missing to get constructor args for: ${contract}`); - } if (!network) { throw new Error( 'Batch contract requires network parameter to get correct address of erc20FeeProxy and ethereumFeeProxy', @@ -43,7 +46,7 @@ export const getConstructorArgs = (contract: string, network?: string): string[] return [ '0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', - process.env.ADMIN_WALLET_ADDRESS, + getAdminWalletAddress(contract), ]; } default: diff --git a/packages/smart-contracts/scripts-create2/contract-setup/setupETHConversionProxy.ts b/packages/smart-contracts/scripts-create2/contract-setup/setupETHConversionProxy.ts new file mode 100644 index 000000000..28d1c974d --- /dev/null +++ b/packages/smart-contracts/scripts-create2/contract-setup/setupETHConversionProxy.ts @@ -0,0 +1,47 @@ +import { batchPaymentsArtifact } from '../../src/lib'; +import { HardhatRuntimeEnvironmentExtended } from '../types'; +import utils from '@requestnetwork/utils'; +import { updateChainlinkConversionPath, updatePaymentErc20FeeProxy } from './adminTasks'; + +/** + * Updates the values of the batch fees of the BatchPayments contract, if needed + * @param contractAddress address of the BatchPayments Proxy + * @param hre Hardhat runtime environment + */ +export const setupEthConversionProxy = async ( + contractAddress: string, + hre: HardhatRuntimeEnvironmentExtended, +): Promise => { + // Setup contract parameters + const EthConversionProxyContract = new hre.ethers.Contract( + contractAddress, + batchPaymentsArtifact.getContractAbi(), + ); + await Promise.all( + hre.config.xdeploy.networks.map(async (network) => { + let provider; + if (network === 'celo') { + provider = utils.getCeloProvider(); + } else { + provider = utils.getDefaultProvider(network); + } + const wallet = new hre.ethers.Wallet(hre.config.xdeploy.signer, provider); + const signer = wallet.connect(provider); + const EthConversionProxyConnected = await EthConversionProxyContract.connect(signer); + const adminNonce = await signer.getTransactionCount(); + const gasPrice = await provider.getGasPrice(); + + // start from the adminNonce, increase gasPrice if needed + await Promise.all([ + updatePaymentErc20FeeProxy(EthConversionProxyConnected, network, adminNonce, gasPrice), + updateChainlinkConversionPath( + EthConversionProxyConnected, + network, + adminNonce + 1, + gasPrice, + ), + ]); + }), + ); + console.log('Setup for EthConversionProxy successful'); +}; diff --git a/packages/smart-contracts/scripts-create2/contract-setup/setups.ts b/packages/smart-contracts/scripts-create2/contract-setup/setups.ts new file mode 100644 index 000000000..88f85e030 --- /dev/null +++ b/packages/smart-contracts/scripts-create2/contract-setup/setups.ts @@ -0,0 +1,168 @@ +import { HardhatRuntimeEnvironmentExtended } from '../types'; +import { erc20SwapConversionArtifact } from '../../src/lib'; +import { batchPaymentsArtifact } from '../../src/lib'; +import utils from '@requestnetwork/utils'; +import { + updateBatchPaymentFees, + updatePaymentErc20FeeProxy, + updatePaymentEthFeeProxy, + updateChainlinkConversionPath, + updateRequestSwapFees, + updateSwapRouter, +} from './adminTasks'; + +/** + * Updates the values of the batch fees of the BatchPayments contract, if needed + * @param contractAddress address of the BatchPayments Proxy + * @param hre Hardhat runtime environment + */ +const setupBatchPayments = async ( + contractAddress: string, + hre: HardhatRuntimeEnvironmentExtended, +): Promise => { + // Setup contract parameters + const batchPaymentContract = new hre.ethers.Contract( + contractAddress, + batchPaymentsArtifact.getContractAbi(), + ); + await Promise.all( + hre.config.xdeploy.networks.map(async (network) => { + let provider; + if (network === 'celo') { + provider = utils.getCeloProvider(); + } else { + provider = utils.getDefaultProvider(network); + } + const wallet = new hre.ethers.Wallet(hre.config.xdeploy.signer, provider); + const signer = wallet.connect(provider); + const batchPaymentConnected = await batchPaymentContract.connect(signer); + const adminNonce = await signer.getTransactionCount(); + const gasPrice = await provider.getGasPrice(); + + // start from the adminNonce, increase gasPrice if needed + await Promise.all([ + updateBatchPaymentFees(batchPaymentConnected, adminNonce, gasPrice.mul(2)), + updatePaymentErc20FeeProxy(batchPaymentConnected, network, adminNonce + 1, gasPrice.mul(2)), + updatePaymentEthFeeProxy(batchPaymentConnected, network, adminNonce + 2, gasPrice.mul(2)), + ]); + }), + ); + console.log('Setup for setupBatchPayment successful'); +}; + +/** + * Updates the values of the chainlinkConversionPath and swap router of the ERC20SwapToConversion contract, if needed + * @param contractAddress address of the ERC20SwapToConversion Proxy + * @param hre Hardhat runtime environment + */ +const setupERC20SwapToConversion = async ( + contractAddress: string, + hre: HardhatRuntimeEnvironmentExtended, +): Promise => { + // Setup contract parameters + const ERC20SwapToConversionContract = new hre.ethers.Contract( + contractAddress, + erc20SwapConversionArtifact.getContractAbi(), + ); + await Promise.all( + hre.config.xdeploy.networks.map(async (network) => { + let provider; + if (network === 'celo') { + provider = utils.getCeloProvider(); + } else { + provider = utils.getDefaultProvider(network); + } + const wallet = new hre.ethers.Wallet(hre.config.xdeploy.signer, provider); + const signer = wallet.connect(provider); + const ERC20SwapToConversionConnected = await ERC20SwapToConversionContract.connect(signer); + const adminNonce = await signer.getTransactionCount(); + const gasPrice = await provider.getGasPrice(); + + await Promise.all([ + updateChainlinkConversionPath( + ERC20SwapToConversionConnected, + network, + adminNonce, + gasPrice, + ), + updateSwapRouter(ERC20SwapToConversionConnected, network, adminNonce + 1, gasPrice), + updateRequestSwapFees(ERC20SwapToConversionConnected, adminNonce + 2, gasPrice), + ]); + }), + ); + console.log('Setup for ERC20SwapToConversion successfull'); +}; + +/** + * Updates the values of the EthConversionProxy contract, if needed + * @param contractAddress address of the EthConversion Proxy + * @param hre Hardhat runtime environment + */ +const setupEthConversionProxy = async ( + contractAddress: string, + hre: HardhatRuntimeEnvironmentExtended, +): Promise => { + // Setup contract parameters + const EthConversionProxyContract = new hre.ethers.Contract( + contractAddress, + batchPaymentsArtifact.getContractAbi(), + ); + await Promise.all( + hre.config.xdeploy.networks.map(async (network) => { + let provider; + if (network === 'celo') { + provider = utils.getCeloProvider(); + } else { + provider = utils.getDefaultProvider(network); + } + const wallet = new hre.ethers.Wallet(hre.config.xdeploy.signer, provider); + const signer = wallet.connect(provider); + const EthConversionProxyConnected = await EthConversionProxyContract.connect(signer); + const adminNonce = await signer.getTransactionCount(); + const gasPrice = await provider.getGasPrice(); + + // start from the adminNonce, increase gasPrice if needed + await Promise.all([ + updatePaymentErc20FeeProxy(EthConversionProxyConnected, network, adminNonce, gasPrice), + updateChainlinkConversionPath( + EthConversionProxyConnected, + network, + adminNonce + 1, + gasPrice, + ), + ]); + }), + ); + console.log('Setup for EthConversionProxy successful'); +}; + +/** + * Updates the values of either BatchPayments, EthConversionProxy, or ERC20SwapToConversion contract, if needed + * @param contractAddress address of the proxy + * @param hre Hardhat runtime environment + * @param contractName name of the contract + */ +export const setupContract = async ( + contractAddress: string, + hre: HardhatRuntimeEnvironmentExtended, + contractName: string, +): Promise => { + switch (contractName) { + case 'EthConversionProxy': { + await setupEthConversionProxy(contractAddress, hre); + break; + } + case 'ERC20SwapToConversion': { + await setupERC20SwapToConversion(contractAddress, hre); + break; + } + case 'BatchPayments': { + await setupBatchPayments(contractAddress, hre); + break; + } + default: { + console.log('Contract name not found'); + break; + } + } +}; diff --git a/packages/smart-contracts/scripts-create2/deploy-request-deployer.ts b/packages/smart-contracts/scripts-create2/deploy-request-deployer.ts index 1138f1568..34fbdcc37 100644 --- a/packages/smart-contracts/scripts-create2/deploy-request-deployer.ts +++ b/packages/smart-contracts/scripts-create2/deploy-request-deployer.ts @@ -1,6 +1,6 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { HardhatRuntimeEnvironmentExtended } from './types'; -import { verifyOne } from './verify-one'; +import { verifyOne } from './verify'; // Deploys, set up the contracts export async function deployDeployer(hre: HardhatRuntimeEnvironment): Promise { diff --git a/packages/smart-contracts/scripts-create2/deploy-one.ts b/packages/smart-contracts/scripts-create2/deploy.ts similarity index 93% rename from packages/smart-contracts/scripts-create2/deploy-one.ts rename to packages/smart-contracts/scripts-create2/deploy.ts index 3cf7c0c73..ec15644fa 100644 --- a/packages/smart-contracts/scripts-create2/deploy-one.ts +++ b/packages/smart-contracts/scripts-create2/deploy.ts @@ -18,7 +18,7 @@ export const deployOneWithCreate2 = async ( const deploymentResult = await xdeploy(deploymentParams, hre); for (let i = 0; i < hre.config.xdeploy.networks.length; i++) { if (deploymentResult[i].deployed) { - console.log(`${deploymentParams.contract} succesffuly deployed:`); + console.log(`${deploymentParams.contract} successfully deployed:`); console.log(` On network: ${hre.config.xdeploy.networks[i]}`); console.log(` At address: ${deploymentResult[i].address}`); console.log(` At block: ${deploymentResult[i].receipt.blockNumber}`); @@ -53,6 +53,8 @@ export const deployWithCreate2FromList = async ( switch (contract) { case 'EthereumProxy': case 'EthereumFeeProxy': + case 'ETHConversionProxy': + case 'ERC20FeeProxy': case 'Erc20ConversionProxy': { const constructorArgs = getConstructorArgs(contract); await deployOneWithCreate2({ contract, constructorArgs }, hre); @@ -79,7 +81,7 @@ export const deployWithCreate2FromList = async ( } // Other cases to add when necessary default: - throw new Error(`The contrat ${contract} is not to be deployed using the CREATE2 scheme`); + throw new Error(`The contract ${contract} is not to be deployed using the CREATE2 scheme`); } } }; diff --git a/packages/smart-contracts/scripts-create2/utils.ts b/packages/smart-contracts/scripts-create2/utils.ts index 5f0fe3d9d..421bba148 100644 --- a/packages/smart-contracts/scripts-create2/utils.ts +++ b/packages/smart-contracts/scripts-create2/utils.ts @@ -9,6 +9,8 @@ import * as artifacts from '../src/lib'; export const create2ContractDeploymentList = [ 'EthereumProxy', 'EthereumFeeProxy', + 'ETHConversionProxy', + 'ERC20FeeProxy', 'Erc20ConversionProxy', 'ERC20SwapToConversion', 'ERC20EscrowToPay', diff --git a/packages/smart-contracts/scripts-create2/verify-one.ts b/packages/smart-contracts/scripts-create2/verify.ts similarity index 97% rename from packages/smart-contracts/scripts-create2/verify-one.ts rename to packages/smart-contracts/scripts-create2/verify.ts index 2b5875240..cc8648e86 100644 --- a/packages/smart-contracts/scripts-create2/verify-one.ts +++ b/packages/smart-contracts/scripts-create2/verify.ts @@ -27,6 +27,8 @@ export async function VerifyCreate2FromList(hre: HardhatRuntimeEnvironmentExtend switch (contract) { case 'EthereumProxy': case 'EthereumFeeProxy': + case 'ETHConversionProxy': + case 'ERC20FeeProxy': case 'ERC20SwapToConversion': case 'Erc20ConversionProxy': { const constructorArgs = getConstructorArgs(contract); diff --git a/packages/smart-contracts/src/lib/artifacts/BatchPayments/index.ts b/packages/smart-contracts/src/lib/artifacts/BatchPayments/index.ts index e0de6d9db..b62fc9924 100644 --- a/packages/smart-contracts/src/lib/artifacts/BatchPayments/index.ts +++ b/packages/smart-contracts/src/lib/artifacts/BatchPayments/index.ts @@ -17,6 +17,10 @@ export const batchPaymentsArtifact = new ContractArtifact( address: '0x0DD57FFe83a53bCbd657e234B16A3e74fEDb8fBA', creationBlockNumber: 10857190, }, + goerli: { + address: '0x0DD57FFe83a53bCbd657e234B16A3e74fEDb8fBA', + creationBlockNumber: 7091488, + }, mainnet: { address: '0x0DD57FFe83a53bCbd657e234B16A3e74fEDb8fBA', creationBlockNumber: 14884721, diff --git a/packages/smart-contracts/src/lib/artifacts/ChainlinkConversionPath/index.ts b/packages/smart-contracts/src/lib/artifacts/ChainlinkConversionPath/index.ts index 7ebde7952..ee0761fde 100644 --- a/packages/smart-contracts/src/lib/artifacts/ChainlinkConversionPath/index.ts +++ b/packages/smart-contracts/src/lib/artifacts/ChainlinkConversionPath/index.ts @@ -22,6 +22,10 @@ export const chainlinkConversionPath = new ContractArtifact( address: '0xEbe28A2B7336670Ba752bfEad4a121D2c4FF2464', creationBlockNumber: 10461945, }, + goerli: { + address: '0xEbe28A2B7336670Ba752bfEad4a121D2c4FF2464', + creationBlockNumber: 10461945, + }, matic: { address: '0xc7f471F5A8f8b33F131049b1e9A43941CbE31792', creationBlockNumber: 29821569, diff --git a/packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts b/packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts index f3c6024a5..dd64ee33e 100644 --- a/packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts +++ b/packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts @@ -21,6 +21,10 @@ export const erc20FeeProxyArtifact = new ContractArtifact( address: '0xda46309973bFfDdD5a10cE12c44d2EE266f45A44', creationBlockNumber: 7118080, }, + goerli: { + address: '0x399F5EE127ce7432E4921a61b8CF52b0af52cbfE', + creationBlockNumber: 7091472, + }, matic: { address: '0x2171a0dc12a9E5b1659feF2BB20E54c84Fa7dB0C', creationBlockNumber: 14163521, diff --git a/packages/smart-contracts/src/lib/artifacts/ERC20SwapToPay/index.ts b/packages/smart-contracts/src/lib/artifacts/ERC20SwapToPay/index.ts index 4a03696db..ad9a3ff5e 100644 --- a/packages/smart-contracts/src/lib/artifacts/ERC20SwapToPay/index.ts +++ b/packages/smart-contracts/src/lib/artifacts/ERC20SwapToPay/index.ts @@ -21,6 +21,10 @@ export const erc20SwapToPayArtifact = new ContractArtifact( address: '0xb674e3d228e631594D8fd4BF947E1811288bf836', creationBlockNumber: 7363204, }, + goerli: { + address: '0x0Ef49176A87Adcc88bD5125126C6a6c23a28303C', + creationBlockNumber: 7109102, + }, }, }, '0.3.0': { diff --git a/packages/smart-contracts/src/lib/artifacts/Erc20ConversionProxy/index.ts b/packages/smart-contracts/src/lib/artifacts/Erc20ConversionProxy/index.ts index 830cbf6ec..dc1e7ce92 100644 --- a/packages/smart-contracts/src/lib/artifacts/Erc20ConversionProxy/index.ts +++ b/packages/smart-contracts/src/lib/artifacts/Erc20ConversionProxy/index.ts @@ -22,6 +22,10 @@ export const erc20ConversionProxy = new ContractArtifact( address: '0x78334ed20da456e89cd7e5a90de429d705f5bc88', creationBlockNumber: 8014584, }, + goerli: { + address: '0x493d6cBeE0142c73eE5461fA92CaC94e3e75df62', + creationBlockNumber: 7091387, + }, matic: { address: '0xf0f49873C50765239F6f9534Ba13c4fe16eD5f2E', creationBlockNumber: 17427747, diff --git a/packages/smart-contracts/src/lib/artifacts/Erc20SwapConversion/index.ts b/packages/smart-contracts/src/lib/artifacts/Erc20SwapConversion/index.ts index 5f221c55a..8eae29f28 100644 --- a/packages/smart-contracts/src/lib/artifacts/Erc20SwapConversion/index.ts +++ b/packages/smart-contracts/src/lib/artifacts/Erc20SwapConversion/index.ts @@ -63,6 +63,10 @@ export const erc20SwapConversionArtifact = new ContractArtifact( address: '0xCa3353a15fCb5C83a1Ff64BFf055781aC5c4d2F4', creationBlockNumber: 9447194, }, + goerli: { + address: '0xED250D9219EB93098Bb67aEbc992963172B9c8DA', + creationBlockNumber: 7108896, + }, fantom: { address: '0xCa3353a15fCb5C83a1Ff64BFf055781aC5c4d2F4', creationBlockNumber: 20066436, diff --git a/packages/smart-contracts/src/lib/artifacts/EthereumFeeProxy/index.ts b/packages/smart-contracts/src/lib/artifacts/EthereumFeeProxy/index.ts index 40f2adb12..06dd43676 100644 --- a/packages/smart-contracts/src/lib/artifacts/EthereumFeeProxy/index.ts +++ b/packages/smart-contracts/src/lib/artifacts/EthereumFeeProxy/index.ts @@ -17,6 +17,10 @@ export const ethereumFeeProxyArtifact = new ContractArtifact( address: '0xC6E23a20C0a1933ACC8E30247B5D1e2215796C1F', creationBlockNumber: 9447193, }, + goerli: { + address: '0xe11BF2fDA23bF0A98365e1A4c04A87C9339e8687', + creationBlockNumber: 7091386, + }, fantom: { address: '0xC6E23a20C0a1933ACC8E30247B5D1e2215796C1F', creationBlockNumber: 20066431, diff --git a/packages/smart-contracts/src/lib/artifacts/EthereumProxy/index.ts b/packages/smart-contracts/src/lib/artifacts/EthereumProxy/index.ts index 85e0e9a30..527cedbb7 100644 --- a/packages/smart-contracts/src/lib/artifacts/EthereumProxy/index.ts +++ b/packages/smart-contracts/src/lib/artifacts/EthereumProxy/index.ts @@ -21,6 +21,10 @@ export const ethereumProxyArtifact = new ContractArtifact( address: '0x9c6c7817e3679c4b3f9ef9486001eae5aaed25ff', creationBlockNumber: 5955681, }, + goerli: { + address: '0x171Ee0881407d4c0C11eA1a2FB7D5b4cdED71e6e', + creationBlockNumber: 7069045, + }, xdai: { address: '0x27c60BE17e853c47A9F1d280B05365f483c2dFAF', creationBlockNumber: 18326895, diff --git a/packages/smart-contracts/src/lib/artifacts/RequestDeployer/index.ts b/packages/smart-contracts/src/lib/artifacts/RequestDeployer/index.ts index f43aa7229..1a8522cbf 100644 --- a/packages/smart-contracts/src/lib/artifacts/RequestDeployer/index.ts +++ b/packages/smart-contracts/src/lib/artifacts/RequestDeployer/index.ts @@ -21,6 +21,10 @@ export const requestDeployer = new ContractArtifact( address: '0xE99Ab70a5FAE59551544FA326fA048f7B95A24B2', creationBlockNumber: 10307305, }, + goerli: { + address: '0xE99Ab70a5FAE59551544FA326fA048f7B95A24B2', + creationBlockNumber: 7068867, + }, 'arbitrum-rinkeby': { address: '0xE99Ab70a5FAE59551544FA326fA048f7B95A24B2', creationBlockNumber: 10382055, diff --git a/packages/smart-contracts/src/lib/artifacts/RequestHashStorage/index.ts b/packages/smart-contracts/src/lib/artifacts/RequestHashStorage/index.ts index e3e0981d6..d9b4ae963 100644 --- a/packages/smart-contracts/src/lib/artifacts/RequestHashStorage/index.ts +++ b/packages/smart-contracts/src/lib/artifacts/RequestHashStorage/index.ts @@ -21,6 +21,10 @@ export const requestHashStorageArtifact = new ContractArtifact Date: Thu, 7 Jul 2022 17:51:55 +0300 Subject: [PATCH 06/11] fix: escrow audit fix 2 (#878) From 0f428294c1f179fd613bd17d4aa13ebf61c53bdc Mon Sep 17 00:00:00 2001 From: olivier7delf <55892112+olivier7delf@users.noreply.github.com> Date: Mon, 11 Jul 2022 10:58:06 +0200 Subject: [PATCH 07/11] fix(smart-contracts): update batch fees (#873) update batch fees from 1% to .3% From 52a5228ec4be9f1ceb6eba801ad17f1e1a479b85 Mon Sep 17 00:00:00 2001 From: Bertrand Juglas Date: Tue, 12 Jul 2022 19:04:45 +0200 Subject: [PATCH 08/11] feat: add cancel stream function (#884) From 56fc8f1c87b3afdc0944a6c5f6f9dd13cc00f2fc Mon Sep 17 00:00:00 2001 From: Darko Kolev Date: Thu, 28 Jul 2022 10:05:11 +0200 Subject: [PATCH 09/11] refactor: contract setup compression fix (#888) From e902e7aea860e8319b14ad43e1ed3688345a129a Mon Sep 17 00:00:00 2001 From: Romain <45540622+rom1trt@users.noreply.github.com> Date: Thu, 28 Jul 2022 10:42:51 +0200 Subject: [PATCH 10/11] feat: goerli storage (#890) feat: squash commits goerli storage --- packages/ethereum-storage/src/ethereum-utils.ts | 1 + packages/ethereum-storage/test/ethereum-utils.test.ts | 6 ++++++ packages/types/src/storage-types.ts | 1 + 3 files changed, 8 insertions(+) diff --git a/packages/ethereum-storage/src/ethereum-utils.ts b/packages/ethereum-storage/src/ethereum-utils.ts index 9b879685d..75351078f 100644 --- a/packages/ethereum-storage/src/ethereum-utils.ts +++ b/packages/ethereum-storage/src/ethereum-utils.ts @@ -8,6 +8,7 @@ const networks = { [StorageTypes.EthereumNetwork.MAINNET]: 'mainnet', [StorageTypes.EthereumNetwork.KOVAN]: 'kovan', [StorageTypes.EthereumNetwork.RINKEBY]: 'rinkeby', + [StorageTypes.EthereumNetwork.GOERLI]: 'goerli', [StorageTypes.EthereumNetwork.SOKOL]: 'sokol', [StorageTypes.EthereumNetwork.XDAI]: 'xdai', }; diff --git a/packages/ethereum-storage/test/ethereum-utils.test.ts b/packages/ethereum-storage/test/ethereum-utils.test.ts index 17fc6d353..a423b9dda 100644 --- a/packages/ethereum-storage/test/ethereum-utils.test.ts +++ b/packages/ethereum-storage/test/ethereum-utils.test.ts @@ -21,6 +21,9 @@ describe('Ethereum Utils', () => { expect(EthereumUtils.getEthereumNetworkNameFromId(StorageTypes.EthereumNetwork.RINKEBY)).toBe( 'rinkeby', ); + expect(EthereumUtils.getEthereumNetworkNameFromId(StorageTypes.EthereumNetwork.GOERLI)).toBe( + 'goerli', + ); expect(EthereumUtils.getEthereumNetworkNameFromId(StorageTypes.EthereumNetwork.SOKOL)).toBe( 'sokol', ); @@ -48,6 +51,9 @@ describe('Ethereum Utils', () => { expect(EthereumUtils.getEthereumIdFromNetworkName('rinkeby')).toBe( StorageTypes.EthereumNetwork.RINKEBY, ); + expect(EthereumUtils.getEthereumIdFromNetworkName('goerli')).toBe( + StorageTypes.EthereumNetwork.GOERLI, + ); expect(EthereumUtils.getEthereumIdFromNetworkName('sokol')).toBe( StorageTypes.EthereumNetwork.SOKOL, ); diff --git a/packages/types/src/storage-types.ts b/packages/types/src/storage-types.ts index c6e51c33b..4ab5c6702 100644 --- a/packages/types/src/storage-types.ts +++ b/packages/types/src/storage-types.ts @@ -136,6 +136,7 @@ export enum EthereumNetwork { PRIVATE = 0, MAINNET = 1, RINKEBY = 4, + GOERLI = 5, KOVAN = 42, SOKOL = 77, XDAI = 100, From 30fdf28590e519b429d9c025a565c73f1eadc0d3 Mon Sep 17 00:00:00 2001 From: Romain TREFAULT Date: Thu, 28 Jul 2022 14:41:57 +0200 Subject: [PATCH 11/11] fix: delete ETHConversionProxy --- .../contract-setup/setupETHConversionProxy.ts | 47 ------------------- 1 file changed, 47 deletions(-) delete mode 100644 packages/smart-contracts/scripts-create2/contract-setup/setupETHConversionProxy.ts diff --git a/packages/smart-contracts/scripts-create2/contract-setup/setupETHConversionProxy.ts b/packages/smart-contracts/scripts-create2/contract-setup/setupETHConversionProxy.ts deleted file mode 100644 index 28d1c974d..000000000 --- a/packages/smart-contracts/scripts-create2/contract-setup/setupETHConversionProxy.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { batchPaymentsArtifact } from '../../src/lib'; -import { HardhatRuntimeEnvironmentExtended } from '../types'; -import utils from '@requestnetwork/utils'; -import { updateChainlinkConversionPath, updatePaymentErc20FeeProxy } from './adminTasks'; - -/** - * Updates the values of the batch fees of the BatchPayments contract, if needed - * @param contractAddress address of the BatchPayments Proxy - * @param hre Hardhat runtime environment - */ -export const setupEthConversionProxy = async ( - contractAddress: string, - hre: HardhatRuntimeEnvironmentExtended, -): Promise => { - // Setup contract parameters - const EthConversionProxyContract = new hre.ethers.Contract( - contractAddress, - batchPaymentsArtifact.getContractAbi(), - ); - await Promise.all( - hre.config.xdeploy.networks.map(async (network) => { - let provider; - if (network === 'celo') { - provider = utils.getCeloProvider(); - } else { - provider = utils.getDefaultProvider(network); - } - const wallet = new hre.ethers.Wallet(hre.config.xdeploy.signer, provider); - const signer = wallet.connect(provider); - const EthConversionProxyConnected = await EthConversionProxyContract.connect(signer); - const adminNonce = await signer.getTransactionCount(); - const gasPrice = await provider.getGasPrice(); - - // start from the adminNonce, increase gasPrice if needed - await Promise.all([ - updatePaymentErc20FeeProxy(EthConversionProxyConnected, network, adminNonce, gasPrice), - updateChainlinkConversionPath( - EthConversionProxyConnected, - network, - adminNonce + 1, - gasPrice, - ), - ]); - }), - ); - console.log('Setup for EthConversionProxy successful'); -};