Skip to content

Commit

Permalink
feat: report deployments task
Browse files Browse the repository at this point in the history
  • Loading branch information
adjisb authored and Andres Adjimann committed Aug 8, 2024
1 parent 1f4e577 commit efaac42
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/deploy/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TSB contracts deploy

This package is used to compile, deploy, test, upgrade and keep track of the
contracts we use in our environments.
contracts we use in our environments. Check [Contract releases](./releases.md) for details.

## Compilation

Expand Down
1 change: 1 addition & 0 deletions packages/deploy/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
addNodeAndMnemonic,
skipDeploymentsOnLiveNetworks,
} from './utils/hardhatConfig';
import './tasks/reportReleses';

// Package name : solidity source code path
const importedPackages = {
Expand Down
11 changes: 9 additions & 2 deletions packages/deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@
"@sandbox-smart-contracts/oft-sand": "0.0.1"
},
"files": [
"deployments"
"deployments",
"README.md",
"releases.md"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"compile": "hardhat compile",
"test": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192 node --unhandled-rejections=strict\" HARDHAT_COMPILE=true hardhat test",
Expand All @@ -43,7 +48,8 @@
"verify": "yarn hardhat etherscan-verify --network",
"live:deploy": "node ./utils/npmScriptHelper.js deploy",
"fork:deploy": "node ./utils/npmScriptHelper.js fork:deploy",
"fork:test": "node ./utils/npmScriptHelper.js fork:test"
"fork:test": "node ./utils/npmScriptHelper.js fork:test",
"report": "yarn hardhat report"
},
"devDependencies": {
"@ethersproject/abi": "^5.7.0",
Expand Down Expand Up @@ -78,6 +84,7 @@
"hardhat-contract-sizer": "^2.10.0",
"hardhat-deploy": "^0.11.43",
"hardhat-deploy-ethers": "^0.4.1",
"markdown-table-ts": "^1.0.3",
"prettier": "^2.8.8",
"prettier-plugin-solidity": "^1.1.3",
"ts-node": "^10.9.2",
Expand Down
81 changes: 81 additions & 0 deletions packages/deploy/releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!--- This file is autogenerated by hardhat report task -->

# Deployed contracts

## sepolia

| contract | address | version | path |
| :---------------- | :----------------------------------------: | :-----: | :------------------------------------------------------------------- |
| Exchange | 0x5A9275998c5F824abAC15E318Be3011F6000570a | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/Exchange.sol |
| OFTAdapterForSand | 0x888a2180f1640b94C05A35dA7979F2e5E455Abc9 | 0.0.1 | @sandbox-smart-contracts/oft-sand/contracts/OFTAdapterForSand.sol |
| OrderValidator | 0x99E5554E44E8C01F23c86212B0Fd73048f8370E6 | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/OrderValidator.sol |
| RoyaltiesRegistry | 0xA2BAf31A638dAE4aaB54F185eFE3177b685b3557 | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/RoyaltiesRegistry.sol |

## bscTestnet

| contract | address | version | path |
| :------- | :----------------------------------------: | :-----: | :------------------------------------------------------ |
| OFTSand | 0xeaac002f26254576d811f84289C821ae6AC7F420 | 0.0.1 | @sandbox-smart-contracts/oft-sand/contracts/OFTSand.sol |

## mumbai

| contract | address | version | path |
| :------------------------- | :----------------------------------------: | :-----: | :------------------------------------------------------------------------------------------- |
| AssetCreate | 0xE7eC4195b772EB1295d42a4602c40659958f15F6 | 1.2.0 | @sandbox-smart-contracts/asset/contracts/AssetCreate.sol |
| AssetReveal | 0x6a2B6427d56495A0e49Fc4D1C3Bb3ac32C2d5E0D | 1.2.0 | @sandbox-smart-contracts/asset/contracts/AssetReveal.sol |
| Asset | 0x1B94A67Ef2cFa6Ffd7De4Cb4566135F384ae8d3D | 1.2.0 | @sandbox-smart-contracts/asset/contracts/Asset.sol |
| AuthSuperValidator | 0x9f1e999d2e7Ee0d263C9589aD46b0d8f29e8233a | 1.2.0 | @sandbox-smart-contracts/asset/contracts/AuthSuperValidator.sol |
| Catalyst | 0xeB8d626E51B67e2CAa1ec614ca172AB4eEbe601f | 1.2.0 | @sandbox-smart-contracts/asset/contracts/Catalyst.sol |
| Exchange | 0xd7b0efA0EF34C25e90D914b167A159854C59a2c9 | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/Exchange.sol |
| FaucetsERC1155 | 0xE0193d3C908DB1a1976434cdDC945a65c90fa9FE | 0.0.1 | @sandbox-smart-contracts/faucets/contracts/FaucetsERC1155.sol |
| OperatorFilterSubscription | 0x54d43934efdb0b15d007bdcb30ffae9f695caba7 | 1.0.1 | @sandbox-smart-contracts/dependency-operator-filter/contracts/OperatorFilterSubscription.sol |
| OperatorFilterSubscription | 0x1482A97e8564a829cCc5A0d81a578161Bc73431e | 1.0.1 | @sandbox-smart-contracts/dependency-operator-filter/contracts/OperatorFilterSubscription.sol |
| OperatorFilterSubscription | 0x4bd0ad9D60d686a259fBCD8C56CE6100D7031e35 | 1.0.1 | @sandbox-smart-contracts/dependency-operator-filter/contracts/OperatorFilterSubscription.sol |
| OrderValidator | 0x9a0006b87d1886e30A3EeFA780D3E5CA96351938 | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/OrderValidator.sol |
| RoyaltiesRegistry | 0xe5c08f87c949315d69707ee71babb496af70506b | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/RoyaltiesRegistry.sol |
| RoyaltyManager | 0xE7D8e2cE77eDC95e930D4E72776b77D0DeFdB52C | 1.0.2 | @sandbox-smart-contracts/dependency-royalty-management/contracts/RoyaltyManager.sol |
| RoyaltySplitter | 0x6ae14ED710f456995e053e0327a7467143EF0E95 | 1.0.2 | @sandbox-smart-contracts/dependency-royalty-management/contracts/RoyaltySplitter.sol |
| SignedMultiGiveaway | 0x9412b244f1a8b30242A54EFd24c52A4697F3a3DC | 0.0.3 | @sandbox-smart-contracts/giveaway/contracts/SignedMultiGiveaway.sol |

## amoy

| contract | address | version | path |
| :------------------------- | :----------------------------------------: | :-----: | :------------------------------------------------------------------------------------------- |
| AssetCreate | 0xEe020cCF1Fcc6Dc434c69d789f174A48FdeF3D1C | 1.2.0 | @sandbox-smart-contracts/asset/contracts/AssetCreate.sol |
| Asset | 0xaF936B06A25dA532bAa26071b5bC2fc72547E845 | 1.2.0 | @sandbox-smart-contracts/asset/contracts/Asset.sol |
| AuthSuperValidator | 0x32112dD0006D58936b94071773765918f70fD5d1 | 1.2.0 | @sandbox-smart-contracts/asset/contracts/AuthSuperValidator.sol |
| AvatarCollection | 0x94D2a48b0f4163B0742917E3Ee255Fd8A75dEDd5 | \* | @sandbox-smart-contracts/avatar/contracts/avatar/AvatarCollection.sol |
| Catalyst | 0x61aB05Bf91aCe346a5aA56222Fe70b66520B7bAB | 1.2.0 | @sandbox-smart-contracts/asset/contracts/Catalyst.sol |
| CollectionFactory | 0xa21DC4BFaF044EFb57369ae574bc228a33368BDB | \* | @sandbox-smart-contracts/avatar/contracts/proxy/CollectionFactory.sol |
| Exchange | 0x75C3095971259aAd22aDBe8075FF395f68763d1d | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/Exchange.sol |
| FaucetsERC1155 | 0x735A0DC4BBa3a4f1Dc50DbaC1575E62225e5d10a | 0.0.1 | @sandbox-smart-contracts/faucets/contracts/FaucetsERC1155.sol |
| OperatorFilterSubscription | 0xF40Ba08C3766f8207843D6994d2C00F0276D8C0B | 1.0.1 | @sandbox-smart-contracts/dependency-operator-filter/contracts/OperatorFilterSubscription.sol |
| OperatorFilterSubscription | 0x08ba79dAF074d2B0Ead45ee0f126286459544834 | 1.0.1 | @sandbox-smart-contracts/dependency-operator-filter/contracts/OperatorFilterSubscription.sol |
| OrderValidator | 0x3AFE10Ad154165b5c687D17f0B20E655B5ae54eE | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/OrderValidator.sol |
| RoyaltiesRegistry | 0xc6105aeE23EB2C2CA36Cf3E112833D7cC5e3728A | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/RoyaltiesRegistry.sol |
| RoyaltyManager | 0x97bBe5222D5735efA9f18D01e6c8E6Fb8B92d624 | 1.0.2 | @sandbox-smart-contracts/dependency-royalty-management/contracts/RoyaltyManager.sol |
| RoyaltySplitter | 0xa8801b20c5744F858DE10556dCFc6650cf4D1228 | 1.0.2 | @sandbox-smart-contracts/dependency-royalty-management/contracts/RoyaltySplitter.sol |
| SignedMultiGiveaway | 0x5A2968BC3C8129ed675C22150E02E93Dd7A4C85e | 0.0.3 | @sandbox-smart-contracts/giveaway/contracts/SignedMultiGiveaway.sol |

## polygon

| contract | address | version | path |
| :------------------------- | :----------------------------------------: | :-----: | :------------------------------------------------------------------------------------------- |
| AssetCreate | 0x0E0ead62734967c43BcFeC8eb7c0978e76E87dB8 | 1.2.0 | @sandbox-smart-contracts/asset/contracts/AssetCreate.sol |
| Asset | 0x07Bf0031a52efcdD5dC10dE4862E0b86f7347e07 | 1.2.0 | @sandbox-smart-contracts/asset/contracts/Asset.sol |
| AuthSuperValidator | 0xd7b21acEE83f8313936e6EB71EA31658863A300E | 1.2.0 | @sandbox-smart-contracts/asset/contracts/AuthSuperValidator.sol |
| Catalyst | 0x62a244D0f33221f24AF3DEc47D61B609D0Cd7bD3 | 1.2.0 | @sandbox-smart-contracts/asset/contracts/Catalyst.sol |
| Exchange | 0xa6c3Fe9D0F99007C4Ceeb23F5F4D74982D0b7260 | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/Exchange.sol |
| OperatorFilterSubscription | 0x2ee34F2d8B3531754a8B6F2573A6D55c2D565119 | 1.0.1 | @sandbox-smart-contracts/dependency-operator-filter/contracts/OperatorFilterSubscription.sol |
| OperatorFilterSubscription | 0xD661CaAc58842343a6aCd73e0A8De275D561a282 | 1.0.1 | @sandbox-smart-contracts/dependency-operator-filter/contracts/OperatorFilterSubscription.sol |
| OrderValidator | 0x9c299af877BCf59Bc28a4e8967De1d404d16a597 | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/OrderValidator.sol |
| RoyaltiesRegistry | 0xfaa3067b7e9a135a5c369086f76a4d29de9bcbee | 1.0.1 | @sandbox-smart-contracts/marketplace/contracts/RoyaltiesRegistry.sol |
| RoyaltyManager | 0x5D0D09DC3B11c4c6c0D94bbEaBAf1dE0B9426f04 | 1.0.2 | @sandbox-smart-contracts/dependency-royalty-management/contracts/RoyaltyManager.sol |
| RoyaltySplitter | 0xafd5f5c6e72f0f6441e4abf2ae8ff23dee21a87a | 1.0.2 | @sandbox-smart-contracts/dependency-royalty-management/contracts/RoyaltySplitter.sol |
| SignedMultiGiveaway | 0x2c0521ea8B94bdFBc981621a7bFDc3314a2C8426 | 0.0.3 | @sandbox-smart-contracts/giveaway/contracts/SignedMultiGiveaway.sol |

## baseSepolia

| contract | address | version | path |
| :------- | :----------------------------------------: | :-----: | :------------------------------------------------------ |
| OFTSand | 0xBdC2292b459D63516355B2C85ae0cC4C0Ef23054 | 0.0.1 | @sandbox-smart-contracts/oft-sand/contracts/OFTSand.sol |
75 changes: 75 additions & 0 deletions packages/deploy/tasks/reportReleses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import {task} from 'hardhat/config';
import {DeploymentsManager} from 'hardhat-deploy/dist/src/DeploymentsManager';
import {dependencies} from '../package.json';
import {Deployment} from 'hardhat-deploy/dist/types';
import {Align, getMarkdownTable, Row} from 'markdown-table-ts';
import * as prettier from 'prettier';
import * as fs from 'fs';

async function printDeployments(
deployments: {[k: string]: Deployment},
deps: {[k: string]: string}
) {
const missing = [];
const found = [];
for (const k in deployments) {
const x = deployments[k];
if (!x.metadata) {
missing.push({name: k, err: 'metadata missing'});
continue;
}
const metadata = JSON.parse(x.metadata);
const compilationTarget = metadata.settings.compilationTarget;
const file = Object.keys(compilationTarget)[0];
const dk = Object.keys(deps).filter((x) => file.startsWith(x));
if (dk.length != 1) {
missing.push({name: k, err: 'dependency missing', file});
continue;
}
found.push({
name: k,
address: x.address,
package: dk[0],
version: deps[dk[0]],
path: Object.keys(compilationTarget)[0],
contract: Object.values(compilationTarget)[0],
});
}
return {found, missing};
}

task('report', 'report deployments addresses and packages')
.addOptionalParam('fileName', 'output file', 'releases.md')
.setAction(async (args: {fileName: string}, hre) => {
const md = [
'<!--- This file is autogenerated by hardhat report task -->',
'# Deployed contracts',
];
for (const networkName in hre.config.networks) {
const dm = new DeploymentsManager(hre, {
...hre.network,
name: networkName,
config: hre.config.networks[networkName],
});
const deployments = await dm.loadDeployments(false);
const {found} = await printDeployments(deployments, dependencies);
if (found.length > 0) {
const table = getMarkdownTable({
table: {
head: ['contract', 'address', 'version', 'path'],
body: found.map((x) => [
x.contract,
x.address,
x.version,
x.path,
]) as Row[],
},
alignment: [Align.Left, Align.Center, Align.Center, Align.Left],
});
md.push(`## ${networkName}`);
md.push(table.toString());
}
}
const report = prettier.format(md.join('\n'), {parser: 'markdown'});
fs.writeFileSync(args.fileName, report, 'utf-8');
});
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2865,6 +2865,7 @@ __metadata:
hardhat-contract-sizer: ^2.10.0
hardhat-deploy: ^0.11.43
hardhat-deploy-ethers: ^0.4.1
markdown-table-ts: ^1.0.3
prettier: ^2.8.8
prettier-plugin-solidity: ^1.1.3
ts-node: ^10.9.2
Expand Down Expand Up @@ -11065,6 +11066,13 @@ __metadata:
languageName: node
linkType: hard

"markdown-table-ts@npm:^1.0.3":
version: 1.0.3
resolution: "markdown-table-ts@npm:1.0.3"
checksum: af684c664f14d628cec0b554d3accc12309be02d25c7fc455bfd962e04484d2d2781c4d58dd1bfe07f5e895962b137ddbdae43e05f95ed3190f31f4035174840
languageName: node
linkType: hard

"markdown-table@npm:^1.1.3":
version: 1.1.3
resolution: "markdown-table@npm:1.1.3"
Expand Down

0 comments on commit efaac42

Please sign in to comment.