-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge the develop branch to the master branch, preparation to v2.0.0-rc4
This update for the master branch contains the following set of changes: * [Improvement] Multi part contract verification in Etherscan and Blockscout (#35) * [Improvement] Robust way of using TransferSingle mint for first mint ever (#36)
- Loading branch information
Showing
21 changed files
with
979 additions
and
256 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -5,7 +5,7 @@ on: | |
types: [created] | ||
|
||
jobs: | ||
flats: | ||
source: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: get_release | ||
|
@@ -23,13 +23,22 @@ jobs: | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} | ||
- run: yarn | ||
if: ${{ !steps.yarn-cache.outputs.cache-hit }} | ||
- run: yarn flatten | ||
- run: zip flats $(find flats -name '*.sol') | ||
- run: yarn compile | ||
- run: zip contracts $(find contracts -name '*.sol') | ||
- run: zip artifacts $(find build -name '*.json') | ||
- uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ steps.get_release.outputs.upload_url }} | ||
asset_path: flats.zip | ||
asset_name: omnibridge-nft-contracts-flattened-${{ steps.get_release.outputs.tag_name }}.zip | ||
asset_path: contracts.zip | ||
asset_name: omnibridge-nft-contracts-${{ steps.get_release.outputs.tag_name }}.zip | ||
asset_content_type: application/zip | ||
- uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ steps.get_release.outputs.upload_url }} | ||
asset_path: artifacts.zip | ||
asset_name: omnibridge-nft-artifacts-${{ steps.get_release.outputs.tag_name }}.zip | ||
asset_content_type: application/zip |
This file contains 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 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 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 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,72 @@ | ||
## Process | ||
|
||
Due to usage of `pragma abicoder v2;` in the contracts source code, | ||
it is not possible to verify contracts through flattened source files. | ||
|
||
Instead, two different approaches can be used for Etherscan and Blockscout explorers. | ||
|
||
## Verification in Etherscan/Bscscan | ||
|
||
The simplest semi-automated solution found so far is to use `truffle-plugin-verify` and the corresponding shell script. | ||
First, collect information about deployed contracts from the logs for the particular chain in the following format: | ||
|
||
Example of deployed contracts list in the Foreign chain: | ||
``` | ||
EternalStorageProxy@0xEc05e3f4D845f0E39e33146395aCE5D35c01Fcc0 | ||
ERC721BridgeToken@0xd880d9d42Fad3dcbe885F499AE15822ACBF1f1F8 | ||
ERC1155BridgeToken@0xaa5cF36b6d97a709fccF3fd4BEa94dA9753d9cA4 | ||
ForeignNFTOmnibridge@0x964C086398cba3c0BaE520bE900E660a84cA331c | ||
``` | ||
|
||
Example of deployed contracts list in the Home chain: | ||
``` | ||
EternalStorageProxy@0x2c0bF58cC87763783e35a625ff6a3e50d9E05337 | ||
ERC721BridgeToken@0x714c7985B073b1177356560631A30D24F60f9241 | ||
ERC1155BridgeToken@0xB2bf0271DB0d30090756A25B01be2698f3E5e556 | ||
OwnedUpgradeabilityProxy@0x4dCD4Dd4096eab35611D496087ceF7DaF1D4E57C | ||
SelectorTokenGasLimitManager@0x783A53aC5ab27d24E83A0211e6Ff70c3705a5435 | ||
HomeNFTOmnibridge@0xFF9c66898B706cd56d2dB9587aB597A000eC6ed6 | ||
# If required: | ||
# NFTForwardingRulesManager@0x... | ||
``` | ||
|
||
After that run the following command for source verification in Etherscan for foreign network: | ||
```bash | ||
deploy/verifyEtherscan.sh ForeignNFTOmnibridge@0x964C086398cba3c0BaE520bE900E660a84cA331c | ||
``` | ||
|
||
Use `VERIFY_HOME=true` environment variable for verification in the home network: | ||
```bash | ||
VERIFY_HOME=true deploy/verifyEtherscan.sh HomeNFTOmnibridge@0xFF9c66898B706cd56d2dB9587aB597A000eC6ed6 | ||
``` | ||
|
||
## Verification in Blockscout | ||
|
||
In order to verify multi-file contract in Blockscout, it must support Sourcify integration (present in the xDAI instance). | ||
|
||
The list of actions is the following: | ||
1) Upload contracts sources and metadata to IPFS. | ||
2) Wait until Sourcify monitor will handle uploaded files and will automatically verify deployed contracts. | ||
3) Import sources to blockscout from Sourcify database. | ||
|
||
### Upload to IPFS | ||
|
||
Run the following in our terminal | ||
|
||
```bash | ||
node deploy/uploadToIPFS.js | ||
``` | ||
|
||
You should see all compiled artifacts being uploaded sequentially, their hashes should be printed into the console. | ||
|
||
### Check that contracts are verified in Sourcify | ||
|
||
You can check if your contracts are verified by visiting https://sourcify.dev | ||
Select the corresponding chain, then enter your contract address. | ||
You should be able to see a green check sign at the top. | ||
|
||
### Import sources to Blockscout | ||
|
||
Go to the contract page of your contract in the Blockscout, click `Code`, then `Verify & Publish`, then `Sources and Metadata JSON file`. | ||
Upload any file from the `./build/contract/*.json`. It could be any artifact, it does not matter, since our sources are already present in the Sourcify database. |
This file contains 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,4 @@ | ||
const Web3 = require('web3') | ||
|
||
const web3 = new Web3(process.env.RPC_URL) | ||
web3.eth.getChainId().then(console.log) |
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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,41 @@ | ||
const IPFS = require('ipfs-http-client') | ||
const shell = require('shelljs') | ||
const path = require('path') | ||
|
||
async function main() { | ||
const ipfs = IPFS.create({ | ||
host: 'ipfs.infura.io', | ||
port: 5001, | ||
protocol: 'https', | ||
}) | ||
|
||
const artifactPaths = shell.ls('./build/contracts/*.json') | ||
|
||
console.log('Uploading sources & metadata to IPFS (Infura Gateway)...') | ||
console.log('========================================================') | ||
|
||
for (const p of artifactPaths) { | ||
const artifact = require(path.join(process.cwd(), p)) | ||
|
||
console.log() | ||
console.log(artifact.contractName) | ||
console.log('-'.repeat(artifact.contractName.length)) | ||
|
||
const res1 = await ipfs.add(artifact.metadata) | ||
console.log(`metadata: ${res1.path}`) | ||
|
||
const res2 = await ipfs.add(artifact.source) | ||
console.log(`source: ${res2.path}`) | ||
} | ||
|
||
console.log() | ||
console.log('Finished.') | ||
console.log() | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((err) => { | ||
console.log(err) | ||
process.exit(1) | ||
}) |
Empty file.
Oops, something went wrong.