-
Notifications
You must be signed in to change notification settings - Fork 75
feat: add contract finder to export artifacts and addresses for contracts #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f5e2cf9
feat: add contract finder to export artifacts and addresses for contr…
chrismaree d182bcd
nit
chrismaree 2d280ba
nit
chrismaree 1158daa
nit
chrismaree 68a7aa1
nit
chrismaree a6e6348
nit
chrismaree 726c667
nit
chrismaree 166fdc8
nit
chrismaree ad7c9b1
nit
chrismaree 98c0245
nit
chrismaree 4bc69f9
nit
chrismaree 0ef36ea
nit
chrismaree 5d3f61e
nit
chrismaree ecd224e
Restore Ethereum_SpokePool.json
chrismaree eb5af24
Delete 0cbb34d0852dbbdf983e586f15b99b69.json
chrismaree 1bdb2ab
nit
chrismaree 504c8f7
qMerge branch 'chrismaree/hardhat-export' of github.com:across-protoc…
chrismaree b5297f2
nit
chrismaree 8258822
nit
chrismaree 3da5d82
nit
chrismaree b71df6a
nit
chrismaree 18a00c3
nit
chrismaree 54de3f0
nit
chrismaree 163c6d7
nit
chrismaree 30f3d8a
nit
chrismaree 7535197
nit
chrismaree File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,4 +9,3 @@ typechain-types | |
| #Hardhat files | ||
| cache | ||
| artifacts | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| { | ||
| "4": { | ||
| "Arbitrum_Adapter": "0x18F4D98C7CeA6Ab934F2976c2a98009A529d8F49", | ||
| "Ethereum_Adapter": "0x682DEa71e7246910A4dec2396a53B24291EB0AD8", | ||
| "Ethereum_SpokePool": "0x90743806D7A66b37F31FAfd7b3447210aB55640f", | ||
| "HubPool": "0xa1b6DA4AaE90fA16F3A3338c8d1Dc70B4926FCa7", | ||
| "LpTokenFactory": "0x0668ab3839346ebf95d969b3e18B2a96b1CC2b02", | ||
| "Optimism_Adapter": "0x277C7ecB45851dcB49c494fB4D0d9d8228037f0C", | ||
| "PolygonTokenBridger": "0xF92B101f07df74B1f4f3160f9e8a25D48BA5d583", | ||
| "Polygon_Adapter": "0xd8176EBf6170513Aa232D065042fa480557232A4" | ||
| }, | ||
| "5": { | ||
| "Arbitrum_Adapter": "0xc6aFa90Ebf5F7eC9Ce0409a0B2bF7b0E6E81b5F6", | ||
| "Ethereum_Adapter": "0xbe96050668dECb6FA0ef5Af919f37221658cfbEf", | ||
| "Ethereum_SpokePool": "0x9a5de999108042946F59848E083e12690ff018C6", | ||
| "HubPool": "0xe1fC1EB80db9AD0160AEF6998673625bc2a09d14", | ||
| "LpTokenFactory": "0x56f2c8353049270d3553773E680B0d6c632544b6", | ||
| "Optimism_Adapter": "0x04Ec0038859943Cf28E49d51821e33c987C4faDD", | ||
| "PolygonTokenBridger": "0xe9D669a4A28aBF4C77c1c6f98942638b7A9aEaC9", | ||
| "Polygon_Adapter": "0xD732393f8eC57644675c104Ec8A4661db58CCE41" | ||
| }, | ||
| "42": { | ||
| "Arbitrum_Adapter": "0xD007aB76E36B03853C1F2fE5980069E7ACd38FF8", | ||
| "Ethereum_Adapter": "0x304d7cbD119E356084b6c02542191EA43df5E399", | ||
| "Ethereum_SpokePool": "0x73549B5639B04090033c1E77a22eE9Aa44C2eBa0", | ||
| "HubPool": "0xD449Af45a032Df413b497A709EeD3E8C112EbcE3", | ||
| "LpTokenFactory": "0x2C4f1527Ec183ccD25f65816Cfc3a45b26B626B8", | ||
| "Optimism_Adapter": "0x7851603f5d6679FC8fFe76bBCb08a88Db34DB4E2", | ||
| "PolygonTokenBridger": "0x6C9cb9a525aED1f6EEbF5321A1f35DF3ec3dfe84", | ||
| "Polygon_Adapter": "0x3aa1b039252ee320bd551875213AFA4996c00b85", | ||
| "RateModelStore": "0x5923929DF7A2D6E038bb005B167c1E8a86cd13C8" | ||
| }, | ||
| "69": { "Optimism_SpokePool": "0x2b7b7bAE341089103dD22fa4e8D7E4FA63E11084" }, | ||
| "80001": { | ||
| "PolygonTokenBridger": "0xe9D669a4A28aBF4C77c1c6f98942638b7A9aEaC9", | ||
| "Polygon_SpokePool": "0xC50c8cEd449321a6c506a5Da409D9eDe7269ac3a" | ||
| }, | ||
| "421611": { "Arbitrum_SpokePool": "0x3BED21dAe767e4Df894B31b14aD32369cE4bad8b" } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| export * from "./typechain"; | ||
| export * from "./src/ContractFinder"; | ||
| export * from "./utils/MerkleTree"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import fs from "fs"; | ||
| import path from "path"; | ||
|
|
||
| // Prunes the hardhat export file sent to the cache directory to only contain the deployment addresses of each contract | ||
| // over the network of chains the Across v2 contracts are deployed on. Meant to be run as part of a publish process. | ||
| export async function run(): Promise<void> { | ||
| try { | ||
| const deploymentExport = require("../cache/massExport.json"); | ||
| const castExport = deploymentExport as any; | ||
| console.log("Generating exports on the following networks(if they have deployments)", Object.keys(castExport)); | ||
| const processedOutput: { [chainid: string]: { [contractName: string]: string } } = {}; | ||
| Object.keys(castExport).forEach((chainId) => { | ||
| if (castExport[chainId][0]) | ||
| Object.keys(castExport[chainId][0].contracts).forEach((contractName) => { | ||
| if (!processedOutput[chainId]) processedOutput[chainId] = {}; | ||
| processedOutput[chainId][contractName] = castExport[chainId][0]?.contracts[contractName].address; | ||
| }); | ||
| }); | ||
| console.log("Constructed the following address export for release:\n", processedOutput); | ||
|
|
||
| fs.writeFileSync(`${path.resolve(__dirname)}/../deployments/deployments.json`, JSON.stringify(processedOutput)); | ||
| } catch (error) {} | ||
| } | ||
|
|
||
| if (require.main === module) { | ||
| run().then(() => { | ||
| process.exit(0); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import * as deployments from "../deployments/deployments.json"; | ||
|
|
||
| // Returns the deployed address of any contract on any network. Uses the pruned network file in the deployments directory. | ||
| // Note that we dont export the contract ABI or bytecode. Implementors are expected to use the typechain artifacts. | ||
| export function getDeployedAddress(contractName: string, networkId: number): string { | ||
| try { | ||
| return (deployments as any)[networkId.toString()][contractName]; | ||
| } catch (_) { | ||
| throw new Error(`Contract ${contractName} not found on ${networkId} in export.json`); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,7 +101,7 @@ export async function deposit( | |
|
|
||
| export async function fillRelay( | ||
| spokePool: Contract, | ||
| destErc20: Contract, | ||
| destErc20: Contract | string, | ||
| recipient: SignerWithAddress, | ||
| depositor: SignerWithAddress, | ||
| relayer: SignerWithAddress, | ||
|
|
@@ -117,15 +117,15 @@ export async function fillRelay( | |
| .fillRelay( | ||
| ...getFillRelayParams( | ||
| getRelayHash( | ||
| depositor.address ?? depositor, | ||
| recipient.address ?? recipient, | ||
| depositor.address, | ||
| recipient.address, | ||
| depositId, | ||
| originChainId, | ||
| consts.destinationChainId, | ||
| destErc20.address ?? destErc20, | ||
| depositAmount.toString(), | ||
| realizedLpFeePct.toString(), | ||
| relayerFeePct.toString() | ||
| (destErc20 as Contract).address ?? (destErc20 as string), | ||
| depositAmount, | ||
| realizedLpFeePct, | ||
| relayerFeePct | ||
| ).relayData, | ||
| amountToRelay, | ||
| consts.repaymentChainId | ||
|
|
@@ -161,9 +161,9 @@ export interface RelayData { | |
| depositor: string; | ||
| recipient: string; | ||
| destinationToken: string; | ||
| amount: string; | ||
| realizedLpFeePct: string; | ||
| relayerFeePct: string; | ||
| amount: BigNumber; | ||
| realizedLpFeePct: BigNumber; | ||
| relayerFeePct: BigNumber; | ||
| depositId: string; | ||
| originChainId: string; | ||
| destinationChainId: string; | ||
|
|
@@ -175,19 +175,19 @@ export function getRelayHash( | |
| _originChainId: number, | ||
| _destinationChainId: number, | ||
| _destinationToken: string, | ||
| _amount?: string, | ||
| _realizedLpFeePct?: string, | ||
| _relayerFeePct?: string | ||
| _amount?: BigNumber, | ||
| _realizedLpFeePct?: BigNumber, | ||
| _relayerFeePct?: BigNumber | ||
|
Comment on lines
-178
to
+180
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the reason all the other |
||
| ): { relayHash: string; relayData: RelayData } { | ||
| const relayData = { | ||
| depositor: _depositor, | ||
| recipient: _recipient, | ||
| destinationToken: _destinationToken, | ||
| amount: _amount || consts.amountToDeposit.toString(), | ||
| amount: _amount || consts.amountToDeposit, | ||
| originChainId: _originChainId.toString(), | ||
| destinationChainId: _destinationChainId.toString(), | ||
| realizedLpFeePct: _realizedLpFeePct || consts.realizedLpFeePct.toString(), | ||
| relayerFeePct: _relayerFeePct || consts.depositRelayerFeePct.toString(), | ||
| realizedLpFeePct: _realizedLpFeePct || consts.realizedLpFeePct, | ||
| relayerFeePct: _relayerFeePct || consts.depositRelayerFeePct, | ||
| depositId: _depositId.toString(), | ||
| }; | ||
| const relayHash = ethers.utils.keccak256( | ||
|
|
@@ -196,10 +196,7 @@ export function getRelayHash( | |
| Object.values(relayData) | ||
| ) | ||
| ); | ||
| return { | ||
| relayHash, | ||
| relayData, | ||
| }; | ||
| return { relayHash, relayData }; | ||
| } | ||
|
|
||
| export function getDepositParams( | ||
|
|
@@ -229,12 +226,12 @@ export function getFillRelayParams( | |
| _relayData.depositor, | ||
| _relayData.recipient, | ||
| _relayData.destinationToken, | ||
| _relayData.amount, | ||
| _relayData.amount.toString(), | ||
| _maxTokensToSend.toString(), | ||
| _repaymentChain ? _repaymentChain.toString() : consts.repaymentChainId.toString(), | ||
| _relayData.originChainId, | ||
| _relayData.realizedLpFeePct, | ||
| _relayData.relayerFeePct, | ||
| _relayData.realizedLpFeePct.toString(), | ||
| _relayData.relayerFeePct.toString(), | ||
| _relayData.depositId, | ||
| ]; | ||
| } | ||
|
|
@@ -250,12 +247,12 @@ export function getFillRelayUpdatedFeeParams( | |
| _relayData.depositor, | ||
| _relayData.recipient, | ||
| _relayData.destinationToken, | ||
| _relayData.amount, | ||
| _relayData.amount.toString(), | ||
| _maxTokensToSend.toString(), | ||
| _repaymentChain ? _repaymentChain.toString() : consts.repaymentChainId.toString(), | ||
| _relayData.originChainId, | ||
| _relayData.realizedLpFeePct, | ||
| _relayData.relayerFeePct, | ||
| _relayData.realizedLpFeePct.toString(), | ||
| _relayData.relayerFeePct.toString(), | ||
| _updatedFee.toString(), | ||
| _relayData.depositId, | ||
| _signature, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more involved now.