Skip to content

Commit

Permalink
forgot to commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Jun 16, 2023
1 parent 649881b commit fc8a72b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 39 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# hardhat-deploy

## 0.11.31

### Patch Changes

- add bnreplacer to stringify values from ethers v6

## 0.11.30

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hardhat-deploy",
"version": "0.11.30",
"version": "0.11.31",
"description": "Hardhat Plugin For Replicable Deployments And Tests",
"repository": "github:wighawag/hardhat-deploy",
"author": "wighawag",
Expand Down
64 changes: 34 additions & 30 deletions src/DeploymentsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {addHelpers, waitForTx} from './helpers';
import {TransactionResponse} from '@ethersproject/providers';
import {Artifact, HardhatRuntimeEnvironment, Network} from 'hardhat/types';
import {store} from './globalStore';
import {bnReplacer} from './internal/utils';

export class DeploymentsManager {
public deploymentsExtension: DeploymentsExtension;
Expand Down Expand Up @@ -328,7 +329,7 @@ export class DeploymentsManager {
return async (options?: O) => {
let id = baseId;
if (options !== undefined) {
id = id + JSON.stringify(options);
id = id + JSON.stringify(options, bnReplacer);
}
const saved = this.db.pastFixtures[id];
if (saved) {
Expand Down Expand Up @@ -540,7 +541,7 @@ export class DeploymentsManager {
: {rawTx, decoded};
fs.writeFileSync(
pendingTxPath,
JSON.stringify(this.db.pendingTransactions, null, ' ')
JSON.stringify(this.db.pendingTransactions, bnReplacer, ' ')
);
// await new Promise(r => setTimeout(r, 20000));
const wait = tx.wait.bind(tx);
Expand All @@ -553,7 +554,7 @@ export class DeploymentsManager {
} else {
fs.writeFileSync(
pendingTxPath,
JSON.stringify(this.db.pendingTransactions, null, ' ')
JSON.stringify(this.db.pendingTransactions, bnReplacer, ' ')
);
}
this.db.gasUsed = this.db.gasUsed.add(receipt.gasUsed);
Expand Down Expand Up @@ -858,30 +859,33 @@ export class DeploymentsManager {
}

const obj = JSON.parse(
JSON.stringify({
address: deployment.address || actualReceipt?.contractAddress,
abi: deployment.abi,
transactionHash:
deployment.transactionHash || actualReceipt?.transactionHash,
receipt: actualReceipt,
args: actualArgs,
numDeployments,
linkedData: deployment.linkedData,
solcInputHash: deployment.solcInputHash,
metadata: deployment.metadata,
bytecode: deployment.bytecode,
deployedBytecode: deployment.deployedBytecode,
libraries: deployment.libraries,
facets: deployment.facets,
execute: deployment.execute,
history: deployment.history,
implementation: deployment.implementation,
devdoc: deployment.devdoc,
userdoc: deployment.userdoc,
storageLayout: deployment.storageLayout,
methodIdentifiers: deployment.methodIdentifiers,
gasEstimates: deployment.gasEstimates, // TODO double check : use evm field ?
})
JSON.stringify(
{
address: deployment.address || actualReceipt?.contractAddress,
abi: deployment.abi,
transactionHash:
deployment.transactionHash || actualReceipt?.transactionHash,
receipt: actualReceipt,
args: actualArgs,
numDeployments,
linkedData: deployment.linkedData,
solcInputHash: deployment.solcInputHash,
metadata: deployment.metadata,
bytecode: deployment.bytecode,
deployedBytecode: deployment.deployedBytecode,
libraries: deployment.libraries,
facets: deployment.facets,
execute: deployment.execute,
history: deployment.history,
implementation: deployment.implementation,
devdoc: deployment.devdoc,
userdoc: deployment.userdoc,
storageLayout: deployment.storageLayout,
methodIdentifiers: deployment.methodIdentifiers,
gasEstimates: deployment.gasEstimates, // TODO double check : use evm field ?
},
bnReplacer
)
);
if (deployment.factoryDeps?.length) {
obj.factoryDeps = deployment.factoryDeps;
Expand Down Expand Up @@ -930,7 +934,7 @@ export class DeploymentsManager {
fs.writeFileSync(chainIdFilepath, chainId);
}

fs.writeFileSync(filepath, JSON.stringify(obj, null, ' '));
fs.writeFileSync(filepath, JSON.stringify(obj, bnReplacer, ' '));

if (deployment.solcInputHash && deployment.solcInput) {
const solcInputsFolderpath = path.join(
Expand Down Expand Up @@ -1260,7 +1264,7 @@ export class DeploymentsManager {
deploymentFolderPath,
'.migrations.json'
),
JSON.stringify(this.db.migrations, null, ' ')
JSON.stringify(this.db.migrations, bnReplacer, ' ')
);
}
}
Expand Down Expand Up @@ -1365,7 +1369,7 @@ export class DeploymentsManager {
}

private _writeExports(dests: string, outputObject: any) {
const output = JSON.stringify(outputObject, null, ' '); // TODO remove bytecode ?
const output = JSON.stringify(outputObject, bnReplacer, ' '); // TODO remove bytecode ?
const splitted = dests.split(',');
for (const split of splitted) {
if (!split) {
Expand Down
7 changes: 6 additions & 1 deletion src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {BigNumber} from '@ethersproject/bignumber';
import {bnReplacer} from './internal/utils';

export class UnknownSignerError extends Error {
constructor(
Expand All @@ -13,7 +14,11 @@ export class UnknownSignerError extends Error {
super(
`Unknown Signer for account: ${
data.from
} Trying to execute the following::\n ${JSON.stringify(data, null, ' ')}`
} Trying to execute the following::\n ${JSON.stringify(
data,
bnReplacer,
' '
)}`
);
Error.captureStackTrace(this, UnknownSignerError);
}
Expand Down
15 changes: 8 additions & 7 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
Transaction,
} from '@ethersproject/transactions';
import {getDerivationPath} from './hdpath';
import {bnReplacer} from './internal/utils';

let LedgerSigner: any; // TODO type
let TrezorSigner: any; // TODO type
Expand Down Expand Up @@ -103,7 +104,7 @@ You'll need to wait the tx resolve, or increase the gas price via --gasprice (th
// confirmations: 0,
// });
} else {
console.error((e as any).message, JSON.stringify(e), e);
console.error((e as any).message, JSON.stringify(e, bnReplacer), e);
throw e;
}
}
Expand Down Expand Up @@ -630,7 +631,7 @@ export function addHelpers(
if (unknown) {
throw new UnknownSignerError({
from,
...JSON.parse(JSON.stringify(unsignedTx)),
...JSON.parse(JSON.stringify(unsignedTx, bnReplacer)),
});
}

Expand Down Expand Up @@ -830,7 +831,7 @@ export function addHelpers(
if (unknown) {
throw new UnknownSignerError({
from,
...JSON.parse(JSON.stringify(unsignedTx)),
...JSON.parse(JSON.stringify(unsignedTx, bnReplacer)),
});
}

Expand Down Expand Up @@ -3063,7 +3064,7 @@ data: ${data}
} else {
fs.writeFileSync(
pendingTxPath,
JSON.stringify(pendingTxs, null, ' ')
JSON.stringify(pendingTxs, bnReplacer, ' ')
);
}
await onPendingTx(txReq);
Expand Down Expand Up @@ -3127,7 +3128,7 @@ data: ${data}
} else {
fs.writeFileSync(
pendingTxPath,
JSON.stringify(pendingTxs, null, ' ')
JSON.stringify(pendingTxs, bnReplacer, ' ')
);
}
await onPendingTx(txReq);
Expand Down Expand Up @@ -3159,7 +3160,7 @@ data: ${data}
} else {
fs.writeFileSync(
pendingTxPath,
JSON.stringify(pendingTxs, null, ' ')
JSON.stringify(pendingTxs, bnReplacer, ' ')
);
}
}
Expand Down Expand Up @@ -3276,7 +3277,7 @@ data: ${data}
} else {
throw new Error(`old diamond deployments are now disabled`);
}
// console.log({ oldFacets: JSON.stringify(oldFacets, null, " ") });
// console.log({ oldFacets: JSON.stringify(oldFacets, bnReplacer, " ") });

let changesDetected = !oldDeployment;
let abi: any[] = oldDiamonBase.abi.concat([]);
Expand Down
6 changes: 6 additions & 0 deletions src/internal/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function bnReplacer(k: string, v: any): any {
if (typeof v === 'bigint') {
return v.toString();
}
return v;
}

0 comments on commit fc8a72b

Please sign in to comment.