Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/smart-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The package stores the following smart contracts:
- `RequestOpenHashSubmitter` entry point to add hashes in `RequestHashStorage`. It gives the rules to get the right to submit hashes and collect the fees. This contract must be whitelisted in `RequestHashStorage`. The only condition for adding hash is to pay the fees.
- `StorageFeeCollector` parent contract (not deployed) of `RequestOpenHashSubmitter`, computes the fees and send them to the burner.

**Smart contracts for advanced-logic package**
**Smart contracts for payments (advanced-logic package)**

- `TestERC20` minimal erc20 token used for tests.
- `ERC20Proxy` used to pay requests with an ERC20 proxy contract payment network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export async function computeCreate2DeploymentAddress(
);
return computedAddress;
} catch (e) {
console.warn('Error while computing the deployment address', {
'deploymentParams.contract': deploymentParams.contract,
WEB3_PROVIDER_URL: process.env.WEB3_PROVIDER_URL,
});
throw new Error(e.toString());
}
}
Expand Down
17 changes: 12 additions & 5 deletions packages/smart-contracts/scripts-create2/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,26 @@ import { setupContract } from './contract-setup/setups';
export const deployOneWithCreate2 = async (
deploymentParams: IDeploymentParams,
hre: HardhatRuntimeEnvironmentExtended,
): Promise<string> => {
): Promise<{ deployed: 'success' | 'yes' | 'no'; address: string }> => {
if (!hre.config.xdeploy.networks || hre.config.xdeploy.networks.length === 0) {
throw new Error('Invalid networks');
}
// Deploy the contract on several network through xdeployer
let deployed: 'success' | 'yes' | 'no' = 'no';
const deploymentResult = await xdeploy(deploymentParams, hre);
hre.config.xdeploy.networks.forEach((network, i) => {
if (deploymentResult[i].deployed) {
console.log(`${deploymentParams.contract} successfully deployed:`);
console.log(` On network: ${network}`);
console.log(` At address: ${deploymentResult[i].address}`);
console.log(` At block: ${deploymentResult[i].receipt.blockNumber}`);
deployed = 'success';
} else {
if (isContractDeployed(deploymentParams.contract, network, deploymentResult[i].address)) {
console.log(`${deploymentParams.contract} already deployed:`);
console.log(` On network: ${network}`);
console.log(` At address: ${deploymentResult[i].address}`);
deployed = 'yes';
} else {
console.log(`${deploymentParams.contract} has not been deployed:`);
console.log(` On network: ${network}`);
Expand All @@ -42,7 +45,7 @@ export const deployOneWithCreate2 = async (
}
}
});
return deploymentResult[0].address;
return { deployed, address: deploymentResult[0].address };
};

/**
Expand All @@ -53,11 +56,15 @@ export const deployOneWithCreate2 = async (
export const deployWithCreate2FromList = async (
hre: HardhatRuntimeEnvironmentExtended,
): Promise<void> => {
const network = hre.config.xdeploy.networks[0];
EvmChains.assertChainSupported(network);
for (const contract of create2ContractDeploymentList) {
const network = hre.config.xdeploy.networks[0];
EvmChains.assertChainSupported(network);
const constructorArgs = getConstructorArgs(contract, network);
const address = await deployOneWithCreate2({ contract, constructorArgs }, hre);
const { deployed, address } = await deployOneWithCreate2({ contract, constructorArgs }, hre);
if (deployed === 'no') {
console.warn('Skipping contract setup');
continue;
}
Comment thread
yomarion marked this conversation as resolved.
await setupContract({
contractAddress: address,
contractName: contract,
Expand Down
7 changes: 5 additions & 2 deletions packages/smart-contracts/scripts-create2/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export async function VerifyCreate2FromList(hre: HardhatRuntimeEnvironmentExtend
};

let address: string;
const network = hre.config.xdeploy.networks[0];
EvmChains.assertChainSupported(network);
console.debug(`Verifying ${create2ContractDeploymentList.length} contracts on ${network}`);
for (const contract of create2ContractDeploymentList) {
try {
await delay();
Expand All @@ -53,11 +56,11 @@ export async function VerifyCreate2FromList(hre: HardhatRuntimeEnvironmentExtend
case 'SingleRequestProxyFactory':
case 'ERC20RecurringPaymentProxy':
case 'ERC20CommerceEscrowWrapper': {
const network = hre.config.xdeploy.networks[0];
EvmChains.assertChainSupported(network);
const constructorArgs = getConstructorArgs(contract, network);
address = await computeCreate2DeploymentAddress({ contract, constructorArgs }, hre);
console.debug(`Verifying ${contract} at ${address} on ${network}`);
await verifyOne(address, { contract, constructorArgs }, hre);
console.debug(`Verified ${contract} on ${network}`);
break;
}
// Other cases to add when necessary
Expand Down
10 changes: 9 additions & 1 deletion packages/smart-contracts/scripts-create2/xdeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const xdeploy = async (
hre: HardhatRuntimeEnvironmentExtended,
): Promise<Array<IDeploymentResult>> => {
const { contract, constructorArgs } = deploymentParams;
if (!hre.config.xdeploy.signer) {
throw new Error('Xdeployer signer (process.env.ADMIN_PRIVATE_KEY) missing');
}
console.log(
`Deployment of ${contract} through xdeployer starting now, with ${
new hre.ethers.Wallet(hre.config.xdeploy.signer).address
Expand Down Expand Up @@ -73,6 +76,7 @@ export const xdeploy = async (
'Contract address could not be computed, check your contract name and arguments',
);
}
console.log(`... at ${computedContractAddress}`);

let receipt = undefined;
let deployed = false;
Expand All @@ -99,7 +103,11 @@ export const xdeploy = async (
receipt = createReceipt;
deployed = true;
} catch (err) {
error = err;
if (err?.message?.match(/insufficient funds for intrinsic transaction cost/)) {
error = 'Insufficient funds';
} else {
error = err;
}
}
result.push({
network,
Expand Down
Loading