Skip to content

Conversation

@chrismaree
Copy link
Member

We need the ability to import contract artifacts and addresses from this repo in other repos. this PR adds an export process for this.

…acts

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>

export function getContractArtifact(contractName: string, networkId: number) {
try {
return deploymentExport[networkId.toString()][0].contracts[contractName];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is [0] accessing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this element is within a nested array. we need to extract the 0th element.

tsconfig.json Outdated
"target": "es2018",
"module": "commonjs",
"strict": true,
"strict": false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems dangerous, not sure we should change to false. What's the reasoning?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, +1 on @nicholaspai's question

Copy link
Member Author

@chrismaree chrismaree Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structure of the export.json file makes this fail. to make it pass I needed to make this change.

Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff on this PR looks huge but the logic changes are very minimal. I've left a few comments but have one question: what is deployments/export.json?

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
@chrismaree
Copy link
Member Author

chrismaree commented Apr 1, 2022

The diff on this PR looks huge but the logic changes are very minimal. I've left a few comments but have one question: what is deployments/export.json?

this is the exported file containing the addresses deployed on all networks and associated ABI. It is produced by running:

hardhat export --export-all ./deployments/export.json

@@ -0,0 +1,9 @@
import * as deploymentExport from "../deployments/export.json";

export function getContractArtifact(contractName: string, networkId: number) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOC, why do we have this function here rather than having the users access the JSON directly? Just convenience I assume?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just much easier to have a method to call & export rather than needing to know how to deal with the structure internally of this file.

tsconfig.json Outdated
"target": "es2018",
"module": "commonjs",
"strict": true,
"strict": false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, +1 on @nicholaspai's question

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
…ol/across-smart-contracts-v2 into chrismaree/hardhat-export
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
"test:gas-analytics": "GAS_TEST_ENABLED=true hardhat test ./test/gas-analytics/*",
"test:all": "GAS_TEST_ENABLED=true REPORT_GAS=true yarn hardhat test",
"prepublish": "yarn build"
"prepublish": "yarn build && hardhat export --export-all ./cache/massExport.json && ts-node ./scripts/processHardhatExport.ts && prettier --write ./deployments/deployments.json"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more involved now.

@@ -0,0 +1,24 @@
var fs = require("fs");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new script.

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Comment on lines -178 to +180
_amount?: string,
_realizedLpFeePct?: string,
_relayerFeePct?: string
_amount?: BigNumber,
_realizedLpFeePct?: BigNumber,
_relayerFeePct?: BigNumber
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the reason all the other .toStrings() were removed: we now use the correct types.

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants