Skip to content

Commit

Permalink
Merge pull request #3367 from energywebfoundation/feat/GP-243/set-tra…
Browse files Browse the repository at this point in the history
…nsaction-fees-at-deploy

Feat/gp 243/set transaction fees at deploy
  • Loading branch information
knzeng-e authored Feb 14, 2023
2 parents be77e0f + 8cf045a commit dc4930d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
5 changes: 5 additions & 0 deletions packages/traceability/issuer/src/const.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export enum CertificateTopic {
IREC = 1
}

export type DeployParameters = {
gasLimit?: number;
gasPrice?: number;
};
26 changes: 19 additions & 7 deletions packages/traceability/issuer/src/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ethers } from 'ethers';

import { CertificateTopic } from './const';
import { CertificateTopic, DeployParameters } from './const';

import { factories } from './contracts';
import { Issuer } from './ethers/Issuer';
Expand All @@ -10,12 +10,16 @@ import { PrivateIssuer } from './ethers/PrivateIssuer';
export async function migratePrivateIssuer(
provider: ethers.providers.FallbackProvider,
deployKey: string,
issuerAddress: string
issuerAddress: string,
deployParameters?: DeployParameters
): Promise<PrivateIssuer> {
const privateKeyDeployment = deployKey.startsWith('0x') ? deployKey : `0x${deployKey}`;
const wallet = new ethers.Wallet(privateKeyDeployment, provider);

const privateIssuerContract = await new factories.PrivateIssuerFactory(wallet).deploy();
const privateIssuerContract = deployParameters
? await new factories.PrivateIssuerFactory(wallet).deploy(deployParameters)
: await new factories.PrivateIssuerFactory(wallet).deploy();

await privateIssuerContract.deployed();

const tx = await privateIssuerContract.initialize(issuerAddress);
Expand All @@ -30,12 +34,16 @@ export async function migratePrivateIssuer(
export async function migrateIssuer(
provider: ethers.providers.FallbackProvider,
deployKey: string,
registryAddress: string
registryAddress: string,
deployParameters?: DeployParameters
): Promise<Issuer> {
const privateKeyDeployment = deployKey.startsWith('0x') ? deployKey : `0x${deployKey}`;
const wallet = new ethers.Wallet(privateKeyDeployment, provider);

const issuerContract = await new factories.IssuerFactory(wallet).deploy();
const issuerContract = deployParameters
? await new factories.IssuerFactory(wallet).deploy(deployParameters)
: await new factories.IssuerFactory(wallet).deploy();

await issuerContract.deployed();

const tx = await issuerContract.initialize(CertificateTopic.IREC, registryAddress);
Expand All @@ -50,12 +58,16 @@ export async function migrateIssuer(
export async function migrateRegistry(
provider: ethers.providers.FallbackProvider,
deployKey: string,
uri: string = ''
deployParameters?: DeployParameters,
uri = ''
): Promise<RegistryExtended> {
const privateKeyDeployment = deployKey.startsWith('0x') ? deployKey : `0x${deployKey}`;
const wallet = new ethers.Wallet(privateKeyDeployment, provider);

const registryContract = await new factories.RegistryExtendedFactory(wallet).deploy(uri);
const registryContract = deployParameters
? await new factories.RegistryExtendedFactory(wallet).deploy(uri, deployParameters)
: await new factories.RegistryExtendedFactory(wallet).deploy(uri);

await registryContract.deployed();

console.log(`RegistryExtended.sol deployed at ${registryContract.address}`);
Expand Down

0 comments on commit dc4930d

Please sign in to comment.