From 1c9c844cf57967aa13cb05ccdccd86cb6dcff92f Mon Sep 17 00:00:00 2001 From: Leszek Stachowski Date: Fri, 8 Dec 2023 10:05:53 +0100 Subject: [PATCH] Fix Script for publishing @celo/abis + @celo/contracts * use @celo/abis in contractkit and cli * offer esm and cjs imports * remove ethers foldeer (just use plain ts files) --- .changeset/cool-waves-switch.md | 10 + .github/workflows/celo-monorepo.yml | 2 +- .../publish-contracts-abi-release.yml | 24 +- .prettierignore | 2 +- packages/celotool/tsconfig.json | 7 +- packages/cli/package.json | 3 +- packages/cli/src/base.ts | 7 +- .../cli/src/commands/network/contracts.ts | 4 +- .../commands/releasegold/admin-revoke.test.ts | 2 +- .../releasegold/refund-and-finalize.test.ts | 2 +- .../releasegold/set-beneficiary.test.ts | 2 +- .../src/commands/releasegold/withdraw.test.ts | 2 +- packages/cli/src/commands/transfer/erc20.ts | 2 +- packages/cli/src/utils/release-gold-base.ts | 2 +- packages/cli/tsconfig.json | 3 +- packages/protocol/.gitignore | 4 +- packages/protocol/abis/README.md | 30 +- packages/protocol/abis/package-cjs.json | 3 + packages/protocol/abis/package-esm.json | 3 + packages/protocol/abis/package.json | 564 +++++++++++++++++- packages/protocol/abis/tsconfig-cjs.json | 7 +- packages/protocol/abis/tsconfig-esm.json | 9 + packages/protocol/abis/tsconfig-types.json | 8 + packages/protocol/abis/tsconfig.json | 17 +- packages/protocol/contractPackages.ts | 6 +- packages/protocol/contracts/.npmignore | 5 +- packages/protocol/scripts/build.ts | 12 +- packages/protocol/scripts/consts.ts | 17 +- .../prepare-contracts-and-abis-publishing.ts | 266 +++++++-- packages/protocol/tsconfig.json | 46 +- packages/protocol/wagmi.config.ts | 4 +- packages/sdk/contractkit/README.md | 2 +- packages/sdk/contractkit/package.json | 9 +- .../sdk/contractkit/src/address-registry.ts | 2 +- .../sdk/contractkit/src/contract-cache.ts | 2 +- .../contractkit/src/mini-contract-cache.ts | 18 +- packages/sdk/contractkit/src/proxy.ts | 62 +- .../contractkit/src/web3-contract-cache.ts | 68 +-- .../sdk/contractkit/src/wrappers/Accounts.ts | 2 +- .../contractkit/src/wrappers/Attestations.ts | 2 +- .../contractkit/src/wrappers/BaseSlasher.ts | 2 +- .../src/wrappers/BaseWrapper.test.ts | 2 +- .../contractkit/src/wrappers/BaseWrapper.ts | 2 +- .../src/wrappers/BlockChainParameters.test.ts | 2 +- .../src/wrappers/BlockchainParameters.ts | 2 +- .../src/wrappers/CeloTokenWrapper.ts | 4 +- .../src/wrappers/DoubleSigningSlasher.ts | 2 +- .../src/wrappers/DowntimeSlasher.ts | 2 +- .../sdk/contractkit/src/wrappers/Election.ts | 2 +- .../contractkit/src/wrappers/EpochRewards.ts | 2 +- .../contractkit/src/wrappers/Erc20Wrapper.ts | 2 +- .../sdk/contractkit/src/wrappers/Escrow.ts | 2 +- .../sdk/contractkit/src/wrappers/Exchange.ts | 2 +- .../src/wrappers/FederatedAttestations.ts | 2 +- .../contractkit/src/wrappers/FeeHandler.ts | 2 +- .../sdk/contractkit/src/wrappers/Freezer.ts | 2 +- .../src/wrappers/GasPriceMinimum.ts | 2 +- .../src/wrappers/GoldTokenWrapper.ts | 2 +- .../src/wrappers/Governance.test.ts | 2 +- .../contractkit/src/wrappers/Governance.ts | 2 +- .../contractkit/src/wrappers/GrandaMento.ts | 4 +- .../contractkit/src/wrappers/LockedGold.ts | 3 +- .../src/wrappers/MetaTransactionWallet.ts | 2 +- .../MetaTransactionWalletDeployer.test.ts | 7 +- .../wrappers/MetaTransactionWalletDeployer.ts | 2 +- .../sdk/contractkit/src/wrappers/MultiSig.ts | 2 +- .../contractkit/src/wrappers/OdisPayments.ts | 2 +- .../contractkit/src/wrappers/ReleaseGold.ts | 2 +- .../sdk/contractkit/src/wrappers/Reserve.ts | 2 +- .../src/wrappers/SortedOracles.test.ts | 2 +- .../contractkit/src/wrappers/SortedOracles.ts | 5 +- .../src/wrappers/StableTokenWrapper.ts | 2 +- .../contractkit/src/wrappers/Validators.ts | 2 +- packages/sdk/contractkit/tsconfig.json | 1 + packages/sdk/contractkit/typedoc.json | 2 +- packages/sdk/governance/package.json | 1 + packages/sdk/governance/src/proposals.ts | 7 +- packages/sdk/governance/tsconfig.json | 1 + packages/sdk/transactions-uri/package.json | 2 +- packages/typescript/tsconfig.json | 7 +- packages/typescript/tsconfig.library.json | 5 +- yarn.lock | 13 +- 82 files changed, 1082 insertions(+), 278 deletions(-) create mode 100644 .changeset/cool-waves-switch.md create mode 100644 packages/protocol/abis/package-cjs.json create mode 100644 packages/protocol/abis/package-esm.json create mode 100644 packages/protocol/abis/tsconfig-esm.json create mode 100644 packages/protocol/abis/tsconfig-types.json diff --git a/.changeset/cool-waves-switch.md b/.changeset/cool-waves-switch.md new file mode 100644 index 00000000000..ccffa8a8aaa --- /dev/null +++ b/.changeset/cool-waves-switch.md @@ -0,0 +1,10 @@ +--- +'@celo/contractkit': major +--- + +Remove contracts from lib/generated. now available in @celo/abis package at @celo/abis/web3 + +If you were directly importing contracts from `@celo/contractkit/lib/generated/*` eg `@celo/lib/generated/Accounts` do a find replace + +find: `@celo/contractkit/lib/generated/` +replace: `@celo/abis/web3/` diff --git a/.github/workflows/celo-monorepo.yml b/.github/workflows/celo-monorepo.yml index b7f3f6d5d1b..17b33989d02 100644 --- a/.github/workflows/celo-monorepo.yml +++ b/.github/workflows/celo-monorepo.yml @@ -111,7 +111,7 @@ jobs: - name: Get the artifacts to cache id: get_artifacts_to_cache run: | - artifacts_to_cache="$(git ls-files --others --ignored --exclude-standard | grep -v node_modules)" + artifacts_to_cache="$(git ls-files --others --ignored --exclude-standard | grep -v node_modules | grep -v .js.map)" echo "artifacts_to_cache<> $GITHUB_OUTPUT echo "$artifacts_to_cache" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT diff --git a/.github/workflows/publish-contracts-abi-release.yml b/.github/workflows/publish-contracts-abi-release.yml index bfb94c03add..7795e9d4cc0 100644 --- a/.github/workflows/publish-contracts-abi-release.yml +++ b/.github/workflows/publish-contracts-abi-release.yml @@ -19,9 +19,11 @@ jobs: contents: write id-token: write pull-requests: write - repository-projects: write + repository-projects: write steps: - uses: actions/checkout@v4 + with: + submodules: recursive - name: Akeyless Get Secrets id: get_auth_token uses: docker://us-west1-docker.pkg.dev/devopsre/akeyless-public/akeyless-action:latest @@ -47,16 +49,16 @@ jobs: shell: bash run: yarn - - name: 'Build all packages' - run: yarn build - - name: Check if a release should be published + # This is what sets the RELEASE_TYPE and RELEASE_VERSION env variables run: yarn --silent is_contract_release >> "$GITHUB_ENV" working-directory: packages/protocol env: GITHUB_TAG: ${{ github.ref_name }} INPUT_VERSION: ${{ inputs.npm_version }} - + - name: 'Build packages which will not need abis' + shell: bash + run: yarn build --ignore @celo/contractkit --ignore @celo/explorer --ignore @celo/celocli --ignore @celo/governance --ignore @celo/metadata-crawler --ignore @celo/celotool --ignore @celo/env-tests --ignore @celo/transactions-uri --ignore @celo/wallet-rpc --include-dependencies - name: Compile solidity contracts and typescript files run: yarn prepare_contracts_and_abis_publishing working-directory: packages/protocol @@ -65,19 +67,23 @@ jobs: RELEASE_VERSION: ${{ env.RELEASE_VERSION }} - name: Publish @celo/contracts - run: npm publish $RELEASE_TYPE $DRY_RUN + run: | + cat package.json + npm publish $RELEASE_TYPE $DRY_RUN working-directory: packages/protocol/contracts env: - RELEASE_TYPE: ${{ env.RELEASE_TYPE != '' && '--tag $RELEASE_TYPE' || '' }} + RELEASE_TYPE: --tag ${{ env.RELEASE_TYPE != '' && env.RELEASE_TYPE || 'canary' }} RELEASE_VERSION: ${{ env.RELEASE_VERSION }} NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }} DRY_RUN: ${{ env.RELEASE_VERSION == '' && '--dry-run' || '' }} - name: Publish @celo/abis - run: npm publish $RELEASE_TYPE $DRY_RUN + run: | + cat package.json + npm publish $RELEASE_TYPE $DRY_RUN working-directory: packages/protocol/abis env: - RELEASE_TYPE: ${{ env.RELEASE_TYPE != '' && '--tag $RELEASE_TYPE' || '' }} + RELEASE_TYPE: --tag ${{ env.RELEASE_TYPE != '' && env.RELEASE_TYPE || 'canary' }} RELEASE_VERSION: ${{ env.RELEASE_VERSION }} NODE_AUTH_TOKEN: ${{ env.NPM_TOKEN }} DRY_RUN: ${{ env.RELEASE_VERSION == '' && '--dry-run' || '' }} diff --git a/.prettierignore b/.prettierignore index b62c11d9dce..269beb0221b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -20,7 +20,7 @@ packages/protocol/scripts/**/*.js packages/protocol/migrations/**/*.js packages/protocol/test/**/*.js packages/protocol/contractPackages.js - +packages/protocol/abis/src-generated/ # prettier eats Latex underscore escapting and doesn't seem to have an option to disable packages/docs/celo-codebase/protocol/proof-of-stake/epoch-rewards.md diff --git a/packages/celotool/tsconfig.json b/packages/celotool/tsconfig.json index 4a888b76f7d..747699ef2ee 100644 --- a/packages/celotool/tsconfig.json +++ b/packages/celotool/tsconfig.json @@ -4,15 +4,14 @@ "outDir": "lib", "rootDir": "src", "baseUrl": ".", - "lib": ["es7", "es2017"], - "target": "es6", + "lib": ["es7", "es2017", "es2020"], + "target": "es2020", "resolveJsonModule": true, "esModuleInterop": true, "paths": { "@google-cloud/monitoring": ["types/monitoring"] } }, - "include": ["src", "../contractkit/types"], + "include": ["src"], "exclude": ["node_modules/"], - "references": [{ "path": "../sdk/utils" }, { "path": "../sdk/contractkit" }] } diff --git a/packages/cli/package.json b/packages/cli/package.json index 9705520caa7..48604d47200 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -30,8 +30,8 @@ "test": "TZ=UTC jest --runInBand" }, "dependencies": { + "@celo/abis": "10.0.0", "@celo/base": "^6.0.0", - "@celo/celo-devchain": "^6.0.3-beta.1", "@celo/connect": "^5.1.1", "@celo/contractkit": "^5.2.1", "@celo/explorer": "^5.0.6", @@ -73,6 +73,7 @@ "web3": "1.10.0" }, "devDependencies": { + "@celo/celo-devchain": "^6.0.3", "@celo/dev-utils": "0.0.1", "@oclif/dev-cli": "^1.23.0", "@types/cli-table": "^0.3.0", diff --git a/packages/cli/src/base.ts b/packages/cli/src/base.ts index b97492c5ffb..65035b16df3 100644 --- a/packages/cli/src/base.ts +++ b/packages/cli/src/base.ts @@ -97,7 +97,7 @@ export abstract class BaseCommand extends Command { // For commands that don't require the node is synced, add the following line // to its definition: // requireSynced = false - public requireSynced: boolean = true + public requireSynced = true private _web3: Web3 | null = null private _kit: ContractKit | null = null @@ -154,7 +154,10 @@ export abstract class BaseCommand extends Command { let transport try { // Importing for ledger uses only fixes running jest tests - const TransportNodeHid = (await import('@ledgerhq/hw-transport-node-hid')).default + const _TransportNodeHid = (await import('@ledgerhq/hw-transport-node-hid')).default + // types seem to be suggesting 2 defaults but js is otherwise for TransportNodeHid + const TransportNodeHid: typeof _TransportNodeHid.default = + _TransportNodeHid.default || _TransportNodeHid transport = await TransportNodeHid.open('') const derivationPathIndexes = res.raw.some( (value) => (value as any).flag === 'ledgerCustomAddresses' diff --git a/packages/cli/src/commands/network/contracts.ts b/packages/cli/src/commands/network/contracts.ts index fef399927aa..93806bb00bd 100644 --- a/packages/cli/src/commands/network/contracts.ts +++ b/packages/cli/src/commands/network/contracts.ts @@ -1,7 +1,7 @@ +import { newICeloVersionedContract } from '@celo/abis/web3/ICeloVersionedContract' +import { newProxy } from '@celo/abis/web3/Proxy' import { concurrentMap } from '@celo/base' import { CeloContract } from '@celo/contractkit' -import { newICeloVersionedContract } from '@celo/contractkit/lib/generated/ICeloVersionedContract' -import { newProxy } from '@celo/contractkit/lib/generated/Proxy' import { cli } from 'cli-ux' import { table } from 'cli-ux/lib/styled/table' import { BaseCommand } from '../../base' diff --git a/packages/cli/src/commands/releasegold/admin-revoke.test.ts b/packages/cli/src/commands/releasegold/admin-revoke.test.ts index ac55c4ee26b..7711ca4a105 100644 --- a/packages/cli/src/commands/releasegold/admin-revoke.test.ts +++ b/packages/cli/src/commands/releasegold/admin-revoke.test.ts @@ -1,6 +1,6 @@ +import { newReleaseGold } from '@celo/abis/web3/ReleaseGold' import { serializeSignature } from '@celo/base/lib/signatureUtils' import { ContractKit, newKitFromWeb3 } from '@celo/contractkit' -import { newReleaseGold } from '@celo/contractkit/lib/generated/ReleaseGold' import { AccountsWrapper } from '@celo/contractkit/lib/wrappers/Accounts' import { GovernanceWrapper } from '@celo/contractkit/lib/wrappers/Governance' import { ReleaseGoldWrapper } from '@celo/contractkit/lib/wrappers/ReleaseGold' diff --git a/packages/cli/src/commands/releasegold/refund-and-finalize.test.ts b/packages/cli/src/commands/releasegold/refund-and-finalize.test.ts index cb0621cc4f3..a6a30ebf3c5 100644 --- a/packages/cli/src/commands/releasegold/refund-and-finalize.test.ts +++ b/packages/cli/src/commands/releasegold/refund-and-finalize.test.ts @@ -1,5 +1,5 @@ +import { newReleaseGold } from '@celo/abis/web3/ReleaseGold' import { ContractKit, newKitFromWeb3 } from '@celo/contractkit' -import { newReleaseGold } from '@celo/contractkit/lib/generated/ReleaseGold' import { ReleaseGoldWrapper } from '@celo/contractkit/lib/wrappers/ReleaseGold' import { getContractFromEvent, testWithGanache } from '@celo/dev-utils/lib/ganache-test' import Web3 from 'web3' diff --git a/packages/cli/src/commands/releasegold/set-beneficiary.test.ts b/packages/cli/src/commands/releasegold/set-beneficiary.test.ts index cf30769ada6..11710dd6f20 100644 --- a/packages/cli/src/commands/releasegold/set-beneficiary.test.ts +++ b/packages/cli/src/commands/releasegold/set-beneficiary.test.ts @@ -1,5 +1,5 @@ +import { newReleaseGold } from '@celo/abis/web3/ReleaseGold' import { newKitFromWeb3 } from '@celo/contractkit' -import { newReleaseGold } from '@celo/contractkit/lib/generated/ReleaseGold' import { ReleaseGoldWrapper } from '@celo/contractkit/lib/wrappers/ReleaseGold' import { getContractFromEvent, testWithGanache } from '@celo/dev-utils/lib/ganache-test' import Web3 from 'web3' diff --git a/packages/cli/src/commands/releasegold/withdraw.test.ts b/packages/cli/src/commands/releasegold/withdraw.test.ts index 150da5491cc..5e3548609df 100644 --- a/packages/cli/src/commands/releasegold/withdraw.test.ts +++ b/packages/cli/src/commands/releasegold/withdraw.test.ts @@ -1,5 +1,5 @@ +import { newReleaseGold } from '@celo/abis/web3/ReleaseGold' import { ContractKit, newKitFromWeb3 } from '@celo/contractkit' -import { newReleaseGold } from '@celo/contractkit/lib/generated/ReleaseGold' import { ReleaseGoldWrapper } from '@celo/contractkit/lib/wrappers/ReleaseGold' import { getContractFromEvent, testWithGanache, timeTravel } from '@celo/dev-utils/lib/ganache-test' import { BigNumber } from 'bignumber.js' diff --git a/packages/cli/src/commands/transfer/erc20.ts b/packages/cli/src/commands/transfer/erc20.ts index 31dd4458924..875f95085f0 100644 --- a/packages/cli/src/commands/transfer/erc20.ts +++ b/packages/cli/src/commands/transfer/erc20.ts @@ -1,4 +1,4 @@ -import { IERC20 } from '@celo/contractkit/lib/generated/IERC20' +import { IERC20 } from '@celo/abis/web3/IERC20' import { Erc20Wrapper } from '@celo/contractkit/lib/wrappers/Erc20Wrapper' import { flags } from '@oclif/command' import BigNumber from 'bignumber.js' diff --git a/packages/cli/src/utils/release-gold-base.ts b/packages/cli/src/utils/release-gold-base.ts index 79ab38c2241..5376ca0cf24 100644 --- a/packages/cli/src/utils/release-gold-base.ts +++ b/packages/cli/src/utils/release-gold-base.ts @@ -1,4 +1,4 @@ -import { newReleaseGold } from '@celo/contractkit/lib/generated/ReleaseGold' +import { newReleaseGold } from '@celo/abis/web3/ReleaseGold' import { ReleaseGoldWrapper } from '@celo/contractkit/lib/wrappers/ReleaseGold' import { ParserOutput } from '@oclif/parser/lib/parse' import { BaseCommand } from '../base' diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index f8c11ebdc94..f1339041c5d 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -1,10 +1,11 @@ { "extends": "@celo/typescript/tsconfig.library.json", "compilerOptions": { + "moduleResolution": "node16", "rootDir": "src", "outDir": "lib", "esModuleInterop": true, - "target": "es6" + "target": "es2020" }, "include": ["src", "../contractkit/types"], "references": [{ "path": "../sdk/utils" }, { "path": "../sdk/contractkit" }] diff --git a/packages/protocol/.gitignore b/packages/protocol/.gitignore index b0540acf166..0dd6ead63c0 100644 --- a/packages/protocol/.gitignore +++ b/packages/protocol/.gitignore @@ -43,4 +43,6 @@ wagmi.config.js wagmi.config.js.map abis/src-generated/ -abis/lib/ \ No newline at end of file +abis/lib/ +# these are copied from contracts-08 folder for purposes of publishing to npm +contracts/0.8 diff --git a/packages/protocol/abis/README.md b/packages/protocol/abis/README.md index d0dd6b751bc..240bfada491 100644 --- a/packages/protocol/abis/README.md +++ b/packages/protocol/abis/README.md @@ -19,19 +19,33 @@ yarn add @celo/abis ### In your javascript or ts ```ts -// json abi -import Accounts from '@celo/abis/Accounts.json' +// abi in json +import AccountsABI from '@celo/abis/Accounts.json' -// ethers -import { Accounts } from '@celo/abis/types/ethers' +// abi in js/ts for viem, wagmi, etc +import { accountsABI } from '@celo/abis' -// web3 -import Accounts from '@celo/abis/types/web3/Accounts' +// abi in js/ts for viem, wagmi, etc (with moduleResolution and module set to "Node16" in your tsconfig.json file) +import { accountsABI } from '@celo/abis/Accounts' -// truffle -import { AccountsContract } from '@celo/abis/types/truffle' +// abi in js/ts for use with contractkit +import { type Accounts, newAccounts, ABI } from '@celo/abis/web3/Accounts' ``` +### CommonJS syntax + +```js +const { accountsABI } = require('@celo/abis'); + +// viem +const accounts = getContract({ + address: "0x...", + abi: accountsABI, + ... +}) +``` + + ## License All packages are licensed under the terms of the Apache 2.0 License unless otherwise specified in the LICENSE file at package's root. diff --git a/packages/protocol/abis/package-cjs.json b/packages/protocol/abis/package-cjs.json new file mode 100644 index 00000000000..5bbefffbabe --- /dev/null +++ b/packages/protocol/abis/package-cjs.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/protocol/abis/package-esm.json b/packages/protocol/abis/package-esm.json new file mode 100644 index 00000000000..3dbc1ca591c --- /dev/null +++ b/packages/protocol/abis/package-esm.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/protocol/abis/package.json b/packages/protocol/abis/package.json index 8c7a86ca9ec..e3a8a9a8b22 100644 --- a/packages/protocol/abis/package.json +++ b/packages/protocol/abis/package.json @@ -1,19 +1,561 @@ { "name": "@celo/abis", - "version": "0.0.0-template.version", + "version": "10.0.0-local", "author": "cLabs", "license": "LGPL-3.0", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/types/index.d.ts", + "typings": "./dist/types/index.d.ts", "repository": { - "type": "git", - "url": "https://github.com/celo-org/celo-monorepo.git", - "directory": "packages/protocol/contracts" + "url": "git+https://github.com/celo-org/celo-monorepo.git", + "directory": "packages/protocol/abis" }, "scripts": {}, - "dependencies": {}, - "main": "./lib/cjs/index.js", - "module": "./lib/esm/index.js", - "types": "./lib/esm/index.d.ts", + "dependencies": {}, + "peerDependencies": {}, "files": [ - "lib/" - ] -} + "./dist", + "!**/*.js.map" + ], + "exports": { + "./Accounts.json": { + "default": "./dist/Accounts.json" + }, + "./Attestations.json": { + "default": "./dist/Attestations.json" + }, + "./BlockchainParameters.json": { + "default": "./dist/BlockchainParameters.json" + }, + "./DoubleSigningSlasher.json": { + "default": "./dist/DoubleSigningSlasher.json" + }, + "./DowntimeSlasher.json": { + "default": "./dist/DowntimeSlasher.json" + }, + "./Election.json": { + "default": "./dist/Election.json" + }, + "./EpochRewards.json": { + "default": "./dist/EpochRewards.json" + }, + "./Escrow.json": { + "default": "./dist/Escrow.json" + }, + "./Exchange.json": { + "default": "./dist/Exchange.json" + }, + "./ExchangeBRL.json": { + "default": "./dist/ExchangeBRL.json" + }, + "./ExchangeEUR.json": { + "default": "./dist/ExchangeEUR.json" + }, + "./FederatedAttestations.json": { + "default": "./dist/FederatedAttestations.json" + }, + "./FeeCurrencyWhitelist.json": { + "default": "./dist/FeeCurrencyWhitelist.json" + }, + "./FeeHandler.json": { + "default": "./dist/FeeHandler.json" + }, + "./Freezer.json": { + "default": "./dist/Freezer.json" + }, + "./GasPriceMinimum.json": { + "default": "./dist/GasPriceMinimum.json" + }, + "./GoldToken.json": { + "default": "./dist/GoldToken.json" + }, + "./Governance.json": { + "default": "./dist/Governance.json" + }, + "./GovernanceApproverMultiSig.json": { + "default": "./dist/GovernanceApproverMultiSig.json" + }, + "./GrandaMento.json": { + "default": "./dist/GrandaMento.json" + }, + "./ICeloToken.json": { + "default": "./dist/ICeloToken.json" + }, + "./ICeloVersionedContract.json": { + "default": "./dist/ICeloVersionedContract.json" + }, + "./IERC20.json": { + "default": "./dist/IERC20.json" + }, + "./LockedGold.json": { + "default": "./dist/LockedGold.json" + }, + "./MentoFeeHandlerSeller.json": { + "default": "./dist/MentoFeeHandlerSeller.json" + }, + "./MetaTransactionWallet.json": { + "default": "./dist/MetaTransactionWallet.json" + }, + "./MetaTransactionWalletDeployer.json": { + "default": "./dist/MetaTransactionWalletDeployer.json" + }, + "./MultiSig.json": { + "default": "./dist/MultiSig.json" + }, + "./OdisPayments.json": { + "default": "./dist/OdisPayments.json" + }, + "./Proxy.json": { + "default": "./dist/Proxy.json" + }, + "./Random.json": { + "default": "./dist/Random.json" + }, + "./Registry.json": { + "default": "./dist/Registry.json" + }, + "./ReleaseGold.json": { + "default": "./dist/ReleaseGold.json" + }, + "./Reserve.json": { + "default": "./dist/Reserve.json" + }, + "./ReserveSpenderMultiSig.json": { + "default": "./dist/ReserveSpenderMultiSig.json" + }, + "./SortedOracles.json": { + "default": "./dist/SortedOracles.json" + }, + "./StableToken.json": { + "default": "./dist/StableToken.json" + }, + "./StableTokenBRL.json": { + "default": "./dist/StableTokenBRL.json" + }, + "./StableTokenEUR.json": { + "default": "./dist/StableTokenEUR.json" + }, + "./UniswapFeeHandlerSeller.json": { + "default": "./dist/UniswapFeeHandlerSeller.json" + }, + "./Validators.json": { + "default": "./dist/Validators.json" + }, + "./Accounts": { + "import": "./dist/esm/Accounts.js", + "require": "./dist/cjs/Accounts.js", + "types": "./dist/types/Accounts.d.ts" + }, + "./Attestations": { + "import": "./dist/esm/Attestations.js", + "require": "./dist/cjs/Attestations.js", + "types": "./dist/types/Attestations.d.ts" + }, + "./BlockchainParameters": { + "import": "./dist/esm/BlockchainParameters.js", + "require": "./dist/cjs/BlockchainParameters.js", + "types": "./dist/types/BlockchainParameters.d.ts" + }, + "./DoubleSigningSlasher": { + "import": "./dist/esm/DoubleSigningSlasher.js", + "require": "./dist/cjs/DoubleSigningSlasher.js", + "types": "./dist/types/DoubleSigningSlasher.d.ts" + }, + "./DowntimeSlasher": { + "import": "./dist/esm/DowntimeSlasher.js", + "require": "./dist/cjs/DowntimeSlasher.js", + "types": "./dist/types/DowntimeSlasher.d.ts" + }, + "./Election": { + "import": "./dist/esm/Election.js", + "require": "./dist/cjs/Election.js", + "types": "./dist/types/Election.d.ts" + }, + "./EpochRewards": { + "import": "./dist/esm/EpochRewards.js", + "require": "./dist/cjs/EpochRewards.js", + "types": "./dist/types/EpochRewards.d.ts" + }, + "./Escrow": { + "import": "./dist/esm/Escrow.js", + "require": "./dist/cjs/Escrow.js", + "types": "./dist/types/Escrow.d.ts" + }, + "./Exchange": { + "import": "./dist/esm/Exchange.js", + "require": "./dist/cjs/Exchange.js", + "types": "./dist/types/Exchange.d.ts" + }, + "./ExchangeBRL": { + "import": "./dist/esm/ExchangeBRL.js", + "require": "./dist/cjs/ExchangeBRL.js", + "types": "./dist/types/ExchangeBRL.d.ts" + }, + "./ExchangeEUR": { + "import": "./dist/esm/ExchangeEUR.js", + "require": "./dist/cjs/ExchangeEUR.js", + "types": "./dist/types/ExchangeEUR.d.ts" + }, + "./FederatedAttestations": { + "import": "./dist/esm/FederatedAttestations.js", + "require": "./dist/cjs/FederatedAttestations.js", + "types": "./dist/types/FederatedAttestations.d.ts" + }, + "./FeeCurrencyWhitelist": { + "import": "./dist/esm/FeeCurrencyWhitelist.js", + "require": "./dist/cjs/FeeCurrencyWhitelist.js", + "types": "./dist/types/FeeCurrencyWhitelist.d.ts" + }, + "./FeeHandler": { + "import": "./dist/esm/FeeHandler.js", + "require": "./dist/cjs/FeeHandler.js", + "types": "./dist/types/FeeHandler.d.ts" + }, + "./Freezer": { + "import": "./dist/esm/Freezer.js", + "require": "./dist/cjs/Freezer.js", + "types": "./dist/types/Freezer.d.ts" + }, + "./GasPriceMinimum": { + "import": "./dist/esm/GasPriceMinimum.js", + "require": "./dist/cjs/GasPriceMinimum.js", + "types": "./dist/types/GasPriceMinimum.d.ts" + }, + "./GoldToken": { + "import": "./dist/esm/GoldToken.js", + "require": "./dist/cjs/GoldToken.js", + "types": "./dist/types/GoldToken.d.ts" + }, + "./Governance": { + "import": "./dist/esm/Governance.js", + "require": "./dist/cjs/Governance.js", + "types": "./dist/types/Governance.d.ts" + }, + "./GovernanceApproverMultiSig": { + "import": "./dist/esm/GovernanceApproverMultiSig.js", + "require": "./dist/cjs/GovernanceApproverMultiSig.js", + "types": "./dist/types/GovernanceApproverMultiSig.d.ts" + }, + "./GrandaMento": { + "import": "./dist/esm/GrandaMento.js", + "require": "./dist/cjs/GrandaMento.js", + "types": "./dist/types/GrandaMento.d.ts" + }, + "./ICeloToken": { + "import": "./dist/esm/ICeloToken.js", + "require": "./dist/cjs/ICeloToken.js", + "types": "./dist/types/ICeloToken.d.ts" + }, + "./ICeloVersionedContract": { + "import": "./dist/esm/ICeloVersionedContract.js", + "require": "./dist/cjs/ICeloVersionedContract.js", + "types": "./dist/types/ICeloVersionedContract.d.ts" + }, + "./IERC20": { + "import": "./dist/esm/IERC20.js", + "require": "./dist/cjs/IERC20.js", + "types": "./dist/types/IERC20.d.ts" + }, + "./LockedGold": { + "import": "./dist/esm/LockedGold.js", + "require": "./dist/cjs/LockedGold.js", + "types": "./dist/types/LockedGold.d.ts" + }, + "./MentoFeeHandlerSeller": { + "import": "./dist/esm/MentoFeeHandlerSeller.js", + "require": "./dist/cjs/MentoFeeHandlerSeller.js", + "types": "./dist/types/MentoFeeHandlerSeller.d.ts" + }, + "./MetaTransactionWallet": { + "import": "./dist/esm/MetaTransactionWallet.js", + "require": "./dist/cjs/MetaTransactionWallet.js", + "types": "./dist/types/MetaTransactionWallet.d.ts" + }, + "./MetaTransactionWalletDeployer": { + "import": "./dist/esm/MetaTransactionWalletDeployer.js", + "require": "./dist/cjs/MetaTransactionWalletDeployer.js", + "types": "./dist/types/MetaTransactionWalletDeployer.d.ts" + }, + "./MultiSig": { + "import": "./dist/esm/MultiSig.js", + "require": "./dist/cjs/MultiSig.js", + "types": "./dist/types/MultiSig.d.ts" + }, + "./OdisPayments": { + "import": "./dist/esm/OdisPayments.js", + "require": "./dist/cjs/OdisPayments.js", + "types": "./dist/types/OdisPayments.d.ts" + }, + "./Proxy": { + "import": "./dist/esm/Proxy.js", + "require": "./dist/cjs/Proxy.js", + "types": "./dist/types/Proxy.d.ts" + }, + "./Random": { + "import": "./dist/esm/Random.js", + "require": "./dist/cjs/Random.js", + "types": "./dist/types/Random.d.ts" + }, + "./Registry": { + "import": "./dist/esm/Registry.js", + "require": "./dist/cjs/Registry.js", + "types": "./dist/types/Registry.d.ts" + }, + "./ReleaseGold": { + "import": "./dist/esm/ReleaseGold.js", + "require": "./dist/cjs/ReleaseGold.js", + "types": "./dist/types/ReleaseGold.d.ts" + }, + "./Reserve": { + "import": "./dist/esm/Reserve.js", + "require": "./dist/cjs/Reserve.js", + "types": "./dist/types/Reserve.d.ts" + }, + "./ReserveSpenderMultiSig": { + "import": "./dist/esm/ReserveSpenderMultiSig.js", + "require": "./dist/cjs/ReserveSpenderMultiSig.js", + "types": "./dist/types/ReserveSpenderMultiSig.d.ts" + }, + "./SortedOracles": { + "import": "./dist/esm/SortedOracles.js", + "require": "./dist/cjs/SortedOracles.js", + "types": "./dist/types/SortedOracles.d.ts" + }, + "./StableToken": { + "import": "./dist/esm/StableToken.js", + "require": "./dist/cjs/StableToken.js", + "types": "./dist/types/StableToken.d.ts" + }, + "./StableTokenBRL": { + "import": "./dist/esm/StableTokenBRL.js", + "require": "./dist/cjs/StableTokenBRL.js", + "types": "./dist/types/StableTokenBRL.d.ts" + }, + "./StableTokenEUR": { + "import": "./dist/esm/StableTokenEUR.js", + "require": "./dist/cjs/StableTokenEUR.js", + "types": "./dist/types/StableTokenEUR.d.ts" + }, + "./UniswapFeeHandlerSeller": { + "import": "./dist/esm/UniswapFeeHandlerSeller.js", + "require": "./dist/cjs/UniswapFeeHandlerSeller.js", + "types": "./dist/types/UniswapFeeHandlerSeller.d.ts" + }, + "./Validators": { + "import": "./dist/esm/Validators.js", + "require": "./dist/cjs/Validators.js", + "types": "./dist/types/Validators.d.ts" + }, + "./web3/0.8/GasPriceMinimum": { + "import": "./dist/esm/web3/0.8/GasPriceMinimum.js", + "require": "./dist/cjs/web3/0.8/GasPriceMinimum.js", + "types": "./dist/types/web3/0.8/GasPriceMinimum.d.ts" + }, + "./web3/Accounts": { + "import": "./dist/esm/web3/Accounts.js", + "require": "./dist/cjs/web3/Accounts.js", + "types": "./dist/types/web3/Accounts.d.ts" + }, + "./web3/Attestations": { + "import": "./dist/esm/web3/Attestations.js", + "require": "./dist/cjs/web3/Attestations.js", + "types": "./dist/types/web3/Attestations.d.ts" + }, + "./web3/BlockchainParameters": { + "import": "./dist/esm/web3/BlockchainParameters.js", + "require": "./dist/cjs/web3/BlockchainParameters.js", + "types": "./dist/types/web3/BlockchainParameters.d.ts" + }, + "./web3/DoubleSigningSlasher": { + "import": "./dist/esm/web3/DoubleSigningSlasher.js", + "require": "./dist/cjs/web3/DoubleSigningSlasher.js", + "types": "./dist/types/web3/DoubleSigningSlasher.d.ts" + }, + "./web3/DowntimeSlasher": { + "import": "./dist/esm/web3/DowntimeSlasher.js", + "require": "./dist/cjs/web3/DowntimeSlasher.js", + "types": "./dist/types/web3/DowntimeSlasher.d.ts" + }, + "./web3/Election": { + "import": "./dist/esm/web3/Election.js", + "require": "./dist/cjs/web3/Election.js", + "types": "./dist/types/web3/Election.d.ts" + }, + "./web3/EpochRewards": { + "import": "./dist/esm/web3/EpochRewards.js", + "require": "./dist/cjs/web3/EpochRewards.js", + "types": "./dist/types/web3/EpochRewards.d.ts" + }, + "./web3/Escrow": { + "import": "./dist/esm/web3/Escrow.js", + "require": "./dist/cjs/web3/Escrow.js", + "types": "./dist/types/web3/Escrow.d.ts" + }, + "./web3/FederatedAttestations": { + "import": "./dist/esm/web3/FederatedAttestations.js", + "require": "./dist/cjs/web3/FederatedAttestations.js", + "types": "./dist/types/web3/FederatedAttestations.d.ts" + }, + "./web3/FeeCurrencyWhitelist": { + "import": "./dist/esm/web3/FeeCurrencyWhitelist.js", + "require": "./dist/cjs/web3/FeeCurrencyWhitelist.js", + "types": "./dist/types/web3/FeeCurrencyWhitelist.d.ts" + }, + "./web3/FeeHandler": { + "import": "./dist/esm/web3/FeeHandler.js", + "require": "./dist/cjs/web3/FeeHandler.js", + "types": "./dist/types/web3/FeeHandler.d.ts" + }, + "./web3/Freezer": { + "import": "./dist/esm/web3/Freezer.js", + "require": "./dist/cjs/web3/Freezer.js", + "types": "./dist/types/web3/Freezer.d.ts" + }, + "./web3/GasPriceMinimum": { + "import": "./dist/esm/web3/GasPriceMinimum.js", + "require": "./dist/cjs/web3/GasPriceMinimum.js", + "types": "./dist/types/web3/GasPriceMinimum.d.ts" + }, + "./web3/GoldToken": { + "import": "./dist/esm/web3/GoldToken.js", + "require": "./dist/cjs/web3/GoldToken.js", + "types": "./dist/types/web3/GoldToken.d.ts" + }, + "./web3/Governance": { + "import": "./dist/esm/web3/Governance.js", + "require": "./dist/cjs/web3/Governance.js", + "types": "./dist/types/web3/Governance.d.ts" + }, + "./web3/GovernanceApproverMultiSig": { + "import": "./dist/esm/web3/GovernanceApproverMultiSig.js", + "require": "./dist/cjs/web3/GovernanceApproverMultiSig.js", + "types": "./dist/types/web3/GovernanceApproverMultiSig.d.ts" + }, + "./web3/ICeloToken": { + "import": "./dist/esm/web3/ICeloToken.js", + "require": "./dist/cjs/web3/ICeloToken.js", + "types": "./dist/types/web3/ICeloToken.d.ts" + }, + "./web3/ICeloVersionedContract": { + "import": "./dist/esm/web3/ICeloVersionedContract.js", + "require": "./dist/cjs/web3/ICeloVersionedContract.js", + "types": "./dist/types/web3/ICeloVersionedContract.d.ts" + }, + "./web3/IERC20": { + "import": "./dist/esm/web3/IERC20.js", + "require": "./dist/cjs/web3/IERC20.js", + "types": "./dist/types/web3/IERC20.d.ts" + }, + "./web3/LockedGold": { + "import": "./dist/esm/web3/LockedGold.js", + "require": "./dist/cjs/web3/LockedGold.js", + "types": "./dist/types/web3/LockedGold.d.ts" + }, + "./web3/MentoFeeHandlerSeller": { + "import": "./dist/esm/web3/MentoFeeHandlerSeller.js", + "require": "./dist/cjs/web3/MentoFeeHandlerSeller.js", + "types": "./dist/types/web3/MentoFeeHandlerSeller.d.ts" + }, + "./web3/MetaTransactionWallet": { + "import": "./dist/esm/web3/MetaTransactionWallet.js", + "require": "./dist/cjs/web3/MetaTransactionWallet.js", + "types": "./dist/types/web3/MetaTransactionWallet.d.ts" + }, + "./web3/MetaTransactionWalletDeployer": { + "import": "./dist/esm/web3/MetaTransactionWalletDeployer.js", + "require": "./dist/cjs/web3/MetaTransactionWalletDeployer.js", + "types": "./dist/types/web3/MetaTransactionWalletDeployer.d.ts" + }, + "./web3/MultiSig": { + "import": "./dist/esm/web3/MultiSig.js", + "require": "./dist/cjs/web3/MultiSig.js", + "types": "./dist/types/web3/MultiSig.d.ts" + }, + "./web3/OdisPayments": { + "import": "./dist/esm/web3/OdisPayments.js", + "require": "./dist/cjs/web3/OdisPayments.js", + "types": "./dist/types/web3/OdisPayments.d.ts" + }, + "./web3/Proxy": { + "import": "./dist/esm/web3/Proxy.js", + "require": "./dist/cjs/web3/Proxy.js", + "types": "./dist/types/web3/Proxy.d.ts" + }, + "./web3/Random": { + "import": "./dist/esm/web3/Random.js", + "require": "./dist/cjs/web3/Random.js", + "types": "./dist/types/web3/Random.d.ts" + }, + "./web3/Registry": { + "import": "./dist/esm/web3/Registry.js", + "require": "./dist/cjs/web3/Registry.js", + "types": "./dist/types/web3/Registry.d.ts" + }, + "./web3/ReleaseGold": { + "import": "./dist/esm/web3/ReleaseGold.js", + "require": "./dist/cjs/web3/ReleaseGold.js", + "types": "./dist/types/web3/ReleaseGold.d.ts" + }, + "./web3/SortedOracles": { + "import": "./dist/esm/web3/SortedOracles.js", + "require": "./dist/cjs/web3/SortedOracles.js", + "types": "./dist/types/web3/SortedOracles.d.ts" + }, + "./web3/UniswapFeeHandlerSeller": { + "import": "./dist/esm/web3/UniswapFeeHandlerSeller.js", + "require": "./dist/cjs/web3/UniswapFeeHandlerSeller.js", + "types": "./dist/types/web3/UniswapFeeHandlerSeller.d.ts" + }, + "./web3/Validators": { + "import": "./dist/esm/web3/Validators.js", + "require": "./dist/cjs/web3/Validators.js", + "types": "./dist/types/web3/Validators.d.ts" + }, + "./web3/mento/Exchange": { + "import": "./dist/esm/web3/mento/Exchange.js", + "require": "./dist/cjs/web3/mento/Exchange.js", + "types": "./dist/types/web3/mento/Exchange.d.ts" + }, + "./web3/mento/ExchangeBRL": { + "import": "./dist/esm/web3/mento/ExchangeBRL.js", + "require": "./dist/cjs/web3/mento/ExchangeBRL.js", + "types": "./dist/types/web3/mento/ExchangeBRL.d.ts" + }, + "./web3/mento/ExchangeEUR": { + "import": "./dist/esm/web3/mento/ExchangeEUR.js", + "require": "./dist/cjs/web3/mento/ExchangeEUR.js", + "types": "./dist/types/web3/mento/ExchangeEUR.d.ts" + }, + "./web3/mento/GrandaMento": { + "import": "./dist/esm/web3/mento/GrandaMento.js", + "require": "./dist/cjs/web3/mento/GrandaMento.js", + "types": "./dist/types/web3/mento/GrandaMento.d.ts" + }, + "./web3/mento/Reserve": { + "import": "./dist/esm/web3/mento/Reserve.js", + "require": "./dist/cjs/web3/mento/Reserve.js", + "types": "./dist/types/web3/mento/Reserve.d.ts" + }, + "./web3/mento/ReserveSpenderMultiSig": { + "import": "./dist/esm/web3/mento/ReserveSpenderMultiSig.js", + "require": "./dist/cjs/web3/mento/ReserveSpenderMultiSig.js", + "types": "./dist/types/web3/mento/ReserveSpenderMultiSig.d.ts" + }, + "./web3/mento/StableToken": { + "import": "./dist/esm/web3/mento/StableToken.js", + "require": "./dist/cjs/web3/mento/StableToken.js", + "types": "./dist/types/web3/mento/StableToken.d.ts" + }, + "./web3/mento/StableTokenBRL": { + "import": "./dist/esm/web3/mento/StableTokenBRL.js", + "require": "./dist/cjs/web3/mento/StableTokenBRL.js", + "types": "./dist/types/web3/mento/StableTokenBRL.d.ts" + }, + "./web3/mento/StableTokenEUR": { + "import": "./dist/esm/web3/mento/StableTokenEUR.js", + "require": "./dist/cjs/web3/mento/StableTokenEUR.js", + "types": "./dist/types/web3/mento/StableTokenEUR.d.ts" + } + } +} \ No newline at end of file diff --git a/packages/protocol/abis/tsconfig-cjs.json b/packages/protocol/abis/tsconfig-cjs.json index 793f22f7159..50bbdbe9f10 100644 --- a/packages/protocol/abis/tsconfig-cjs.json +++ b/packages/protocol/abis/tsconfig-cjs.json @@ -1,8 +1,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "esModuleInterop": false, + "declaration": false, "module": "CommonJS", - "outDir": "./lib/cjs" + "outDir": "./dist/cjs" }, - "references": [{ "path": "../../sdk/utils" }] -} +} \ No newline at end of file diff --git a/packages/protocol/abis/tsconfig-esm.json b/packages/protocol/abis/tsconfig-esm.json new file mode 100644 index 00000000000..36251a4ed7b --- /dev/null +++ b/packages/protocol/abis/tsconfig-esm.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "target": "ES2020", + "declaration": false, + "module": "ES2020", + "outDir": "./dist/esm" + }, +} \ No newline at end of file diff --git a/packages/protocol/abis/tsconfig-types.json b/packages/protocol/abis/tsconfig-types.json new file mode 100644 index 00000000000..caf132b8e02 --- /dev/null +++ b/packages/protocol/abis/tsconfig-types.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./dist/types", + "declaration": true, + "emitDeclarationOnly": true + } +} \ No newline at end of file diff --git a/packages/protocol/abis/tsconfig.json b/packages/protocol/abis/tsconfig.json index d58d74f1d48..0ee28e1c551 100644 --- a/packages/protocol/abis/tsconfig.json +++ b/packages/protocol/abis/tsconfig.json @@ -5,20 +5,17 @@ "esModuleInterop": true, "baseUrl": ".", "strict": true, - "moduleResolution": "node", + "moduleResolution": "node16", "noUnusedLocals": true, "noUnusedParameters": true, - "removeComments": false, + "removeComments": true, "skipLibCheck": true, - "sourceMap": true, - "target": "ES2020", + "sourceMap": false, + "target": "ES5", "downlevelIteration": true, "resolveJsonModule": true, - "declaration": true, - "module": "ES2020", - "outDir": "./lib/esm" + "declaration": false, + "rootDir": "./src-generated", }, "include": ["./src-generated"], - "exclude": ["./src-generated/ethers"], - "references": [{ "path": "../../sdk/utils" }] -} +} \ No newline at end of file diff --git a/packages/protocol/contractPackages.ts b/packages/protocol/contractPackages.ts index 7c284b2d16d..577823d83d4 100644 --- a/packages/protocol/contractPackages.ts +++ b/packages/protocol/contractPackages.ts @@ -3,7 +3,7 @@ export interface ContractPackage { folderPath?: string name: string contracts: string[] - contracstFolder?: string + contractsFolder?: string proxyContracts?: string[] truffleConfig?: string solidityVersion?: string @@ -12,7 +12,7 @@ export interface ContractPackage { export const MENTO_PACKAGE: ContractPackage = { path: 'mento-core', - contracstFolder: 'contracts', + contractsFolder: 'contracts', folderPath: 'lib', name: 'mento', contracts: [ @@ -42,7 +42,7 @@ export const MENTO_PACKAGE: ContractPackage = { export const SOLIDITY_08_PACKAGE: ContractPackage = { path: 'contracts-0.8', - contracstFolder: '', + contractsFolder: '', folderPath: '', name: '0.8', proxiesPath: '/', // Proxies are still with 0.5 contracts diff --git a/packages/protocol/contracts/.npmignore b/packages/protocol/contracts/.npmignore index 474435fa49f..ea6a770f1af 100644 --- a/packages/protocol/contracts/.npmignore +++ b/packages/protocol/contracts/.npmignore @@ -1,3 +1,4 @@ -test/* +**/test/** +uniswap/** package.abis.json -README.abis.md \ No newline at end of file +README.abis.md diff --git a/packages/protocol/scripts/build.ts b/packages/protocol/scripts/build.ts index ce92663e7a9..93d6df4719a 100644 --- a/packages/protocol/scripts/build.ts +++ b/packages/protocol/scripts/build.ts @@ -31,7 +31,7 @@ function compile({ coreContractsOnly, solidity: outdir }: BuildTargets) { './', contractPackage.folderPath, contractPackage.path, - contractPackage.contracstFolder + contractPackage.contractsFolder ) if (!existsSync(contractPath)) { console.log(`Contract package named ${contractPackage.name} doesn't exist`) @@ -52,8 +52,14 @@ function compile({ coreContractsOnly, solidity: outdir }: BuildTargets) { // check that there were no errors for (const contractName of contracts) { try { + const artifactPath = `${outdir}/contracts/${contractName}.json` + const artifactPath8 = `${outdir}/contracts-0.8/${contractName}.json` + let is08 = false // This is issuing a warning: https://github.com/celo-org/celo-monorepo/issues/10564 - const fileStr = readJSONSync(`${outdir}/contracts/${contractName}.json`) + if (existsSync(artifactPath8)) { + is08 = true + } + const fileStr = readJSONSync(is08 ? artifactPath8 : artifactPath) if (hasEmptyBytecode(fileStr)) { console.error( `${contractName} has empty bytecode. Maybe you forgot to fully implement an interface?` @@ -114,7 +120,7 @@ async function generateFilesForContractKit({ coreContractsOnly, web3Types: outdi ? CoreContracts : CoreContracts.concat('Proxy').concat(Interfaces) - const globPattern = `${BUILD_DIR}/contracts/@(${contractKitContracts.join('|')}).json` + const globPattern = `${BUILD_DIR}/contracts*/@(${contractKitContracts.join('|')}).json` const cwd = process.cwd() diff --git a/packages/protocol/scripts/consts.ts b/packages/protocol/scripts/consts.ts index f9abd216234..45fb8aa4597 100644 --- a/packages/protocol/scripts/consts.ts +++ b/packages/protocol/scripts/consts.ts @@ -3,11 +3,16 @@ import { MENTO_PACKAGE, SOLIDITY_08_PACKAGE } from '../contractPackages' export const ROOT_DIR = path.join(__dirname, '../') export const CONTRACTS_PACKAGE_SRC_DIR = path.join(__dirname, '../contracts') +export const CONTRACTS_08_SOURCE_DIR = path.join(ROOT_DIR, 'contracts-0.8') +export const CONTRACTS_08_PACKAGE_DESTINATION_DIR = path.join(CONTRACTS_PACKAGE_SRC_DIR, '0.8') export const ABIS_PACKAGE_SRC_DIR = path.join(__dirname, '../abis') export const ABIS_BUILD_DIR = path.join(ABIS_PACKAGE_SRC_DIR, 'src-generated') +export const ABIS_DIST_DIR = path.join(ABIS_PACKAGE_SRC_DIR, 'dist') export const BUILD_EXECUTABLE = path.join(__dirname, 'build.ts') export const TSCONFIG_PATH = path.join(ROOT_DIR, 'tsconfig.json') +const PROXY_CONTRACT = 'Proxy' + export const ProxyContracts = [ 'AccountsProxy', 'AttestationsProxy', @@ -73,7 +78,7 @@ export const CoreContracts = [ ] export const OtherContracts = [ - 'Proxy', + PROXY_CONTRACT, 'Migrations', // abstract 'Initializable', @@ -85,3 +90,13 @@ export const contractPackages = [MENTO_PACKAGE, SOLIDITY_08_PACKAGE].filter(Bool export const Interfaces = ['ICeloToken', 'IERC20', 'ICeloVersionedContract'] export const ImplContracts = OtherContracts.concat(ProxyContracts).concat(CoreContracts) + +export const PublishContracts = CoreContracts.concat(Interfaces) + .concat(PROXY_CONTRACT) + .concat(MENTO_PACKAGE.contracts) + +export enum BuildTarget { + CJS = 'cjs', + ESM = 'esm', + TYPES = 'types', +} diff --git a/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts b/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts index 2f20e8bf2d2..25b298c4a76 100644 --- a/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts +++ b/packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts @@ -5,10 +5,14 @@ import { sync as rmrfSync } from 'rimraf' import { MENTO_PACKAGE, SOLIDITY_08_PACKAGE } from '../contractPackages' import { ABIS_BUILD_DIR, + ABIS_DIST_DIR, ABIS_PACKAGE_SRC_DIR, BUILD_EXECUTABLE, + BuildTarget, + CONTRACTS_08_PACKAGE_DESTINATION_DIR, + CONTRACTS_08_SOURCE_DIR, CONTRACTS_PACKAGE_SRC_DIR, - CoreContracts, + PublishContracts, TSCONFIG_PATH, } from './consts' @@ -24,29 +28,22 @@ try { fs.writeFileSync(TSCONFIG_PATH, JSON.stringify(tsconfig, null, 4)) // Start from scratch - rmrfSync([ABIS_BUILD_DIR, path.join(ABIS_PACKAGE_SRC_DIR, 'lib')]) + rmrfSync([ABIS_BUILD_DIR, ABIS_DIST_DIR, CONTRACTS_08_PACKAGE_DESTINATION_DIR]) fs.mkdirSync(ABIS_BUILD_DIR, { recursive: true }) + fs.mkdirSync(ABIS_DIST_DIR, { recursive: true }) // Generate all ABIs build(`--solidity ${path.join(ABIS_BUILD_DIR)}`) - // Generate ethers typings - build(`--ethersTypes ${path.join(ABIS_BUILD_DIR, 'ethers')}`) - // Generate web3 typings build(`--web3Types ${path.join(ABIS_BUILD_DIR, 'web3')}`) // Merge contracts-0.8, contracts-mento, etc.. at the root of the build dir log('Merging files at the root of the build dir') - for (const folder of [ - 'contracts', - `contracts-${MENTO_PACKAGE.name}`, - `contracts-${SOLIDITY_08_PACKAGE.name}`, - ]) { - const mvCommand = `mv -f ${ABIS_BUILD_DIR}/${folder}/* ${ABIS_BUILD_DIR}` - log(mvCommand) - child_process.execSync(mvCommand) - } + mergeFromFolder( + ['contracts', `contracts-${MENTO_PACKAGE.name}`, `contracts-${SOLIDITY_08_PACKAGE.name}`], + path.join(ABIS_BUILD_DIR) + ) // Remove Mocks, tests, extraneous files log('Deleting extraneous files') @@ -55,7 +52,7 @@ try { const name = path.basename(filePath) const baseName = name.replace(/.(sol|d.ts|json)$/, '') - if (baseName !== 'index' && !CoreContracts.includes(baseName)) { + if (baseName !== 'index' && !PublishContracts.includes(baseName)) { rmrfSync(path.join(ABIS_BUILD_DIR, `${baseName}.json`)) rmrfSync(path.join(ABIS_BUILD_DIR, `${baseName}.ts`)) rmrfSync(path.join(ABIS_BUILD_DIR, '**', `${baseName}.d.ts`)) @@ -63,46 +60,43 @@ try { } }) - // Generate wagmi friendly ts files + let exports = processRawJsonsAndPrepareExports() + + // Generate ts abi files log('Running yarn wagmi generate') child_process.execSync(`yarn wagmi generate`, { stdio: 'inherit' }) - // Generate an index.ts to be esm friendly - log('Generate index.ts from `CoreContracts`') - fs.writeFileSync( - path.join(ABIS_BUILD_DIR, 'index.ts'), - '// This is a generated file, do not modify\n' + - [...new Set(CoreContracts)] - .map((contract) => { - return `export * as ${contract} from './${contract}';` - }) - .join('\n') - ) + // must be after wagmi gen but before compiling + createIndex() - // Generate the js folder to be published from ts files - log('Running tsc -b ') - child_process.execSync(`yarn tsc -b ${path.join(ABIS_PACKAGE_SRC_DIR, 'tsconfig.json')}`, { + log('Compiling esm') + child_process.execSync(`yarn tsc -b ${path.join(ABIS_PACKAGE_SRC_DIR, 'tsconfig-esm.json')}`, { stdio: 'inherit', }) + + log('Compiling cjs') child_process.execSync(`yarn tsc -b ${path.join(ABIS_PACKAGE_SRC_DIR, 'tsconfig-cjs.json')}`, { stdio: 'inherit', }) - // Change the packages version to what CI is providing from environment variables - const packageJsons = [ - path.join(CONTRACTS_PACKAGE_SRC_DIR, 'package.json'), - path.join(ABIS_PACKAGE_SRC_DIR, 'package.json'), - ] - packageJsons.forEach((packageJsonPath) => { - const file = fs.readFileSync(packageJsonPath).toString() - - if (process.env.RELEASE_VERSION) { - fs.writeFileSync( - packageJsonPath, - file.replace('0.0.0-template.version', process.env.RELEASE_VERSION) - ) - } + log('Compiling declarations') + child_process.execSync(`yarn tsc -b ${path.join(ABIS_PACKAGE_SRC_DIR, 'tsconfig-types.json')}`, { + stdio: 'inherit', }) + + exports = { + '.': { + import: './dist/esm/index.js', + require: './dist/cjs/index.js', + types: './dist/types/index.d.ts', + }, + ...exports, + ...prepareTargetTypesExports(), + } + + // Change the packages version to what CI is providing from environment variables + prepareAbisPackageJson(exports) + prepareContractsPackage() } finally { // Cleanup log('Cleaning up folders and checking out dirty git files') @@ -111,7 +105,170 @@ try { child_process.execSync(`git checkout ${TSCONFIG_PATH}`, { stdio: 'inherit' }) } +function createIndex() { + const reExports = PublishContracts.map((contractName) => { + return `export * from './${contractName}.js'` + }) + + fs.writeFileSync(path.join(ABIS_BUILD_DIR, 'index.ts'), reExports.join('\n')) +} + // Helper functions +function prepareTargetTypesExports() { + const exports = {} + const targets = [BuildTarget.ESM, BuildTarget.CJS, BuildTarget.TYPES] + + targets.forEach((target) => { + // We don't need package.json for type declarations + if (target !== BuildTarget.TYPES) { + fs.copyFileSync( + path.join(ABIS_PACKAGE_SRC_DIR, `package-${target}.json`), + path.join(ABIS_DIST_DIR, target, 'package.json') + ) + } + + const filePaths = lsRecursive(path.join(ABIS_DIST_DIR, target)) + filePaths.forEach((filePath) => { + const parsedPath = path.parse(filePath) + + // Remove the .d from the name -- only for types types no harm otherwise + const parsedPathName = parsedPath.name.replace('.d', '') + if (PublishContracts.includes(parsedPathName)) { + const relativePath = path.join( + path.relative(ABIS_PACKAGE_SRC_DIR, parsedPath.dir), + parsedPathName + ) + const exportKey = `./${path.join( + path.relative(path.join(ABIS_DIST_DIR, target), parsedPath.dir), + parsedPathName + )}` + + if (!exports.hasOwnProperty(exportKey)) { + exports[exportKey] = {} + } + + if (target === BuildTarget.ESM) { + const importPath = `./${relativePath}.js` + + expectFileExists(importPath) + + exports[exportKey] = { + ...exports[exportKey], + import: importPath, + } + } else if (target === BuildTarget.CJS) { + const requirePath = `./${relativePath}.js` + + expectFileExists(requirePath) + + exports[exportKey] = { + ...exports[exportKey], + require: requirePath, + } + } else { + // types + const typesPath = `./${relativePath}.d.ts` + + expectFileExists(typesPath) + + exports[exportKey] = { + ...exports[exportKey], + types: typesPath, + } + } + } + }) + }) + + return exports +} + +function expectFileExists(relativePath: string) { + if (!fs.existsSync(path.join(ABIS_PACKAGE_SRC_DIR, relativePath))) { + throw new Error(`Expected file ${relativePath} to exist`) + } +} + +function processRawJsonsAndPrepareExports() { + const exports = {} + + log('Removing extraneous fields from generated json files') + const fileNames = fs.readdirSync(ABIS_BUILD_DIR) + + fileNames.forEach((fileName) => { + const filePath = path.join(ABIS_BUILD_DIR, fileName) + const parsedPath = path.parse(filePath) + + if (PublishContracts.includes(parsedPath.name)) { + const json = JSON.parse(fs.readFileSync(filePath).toString()) + const defaultPath = path.join( + path.relative(ABIS_PACKAGE_SRC_DIR, ABIS_DIST_DIR), + `${parsedPath.name}.json` + ) + + fs.writeFileSync( + path.join(ABIS_DIST_DIR, fileName), + JSON.stringify( + { + contractName: json.contractName, + abi: json.abi, + }, + null, + 2 + ) + ) + + expectFileExists(defaultPath) + + exports[`./${parsedPath.name}.json`] = { + default: `./${defaultPath}`, + } + } + }) + + return exports +} + +function prepareAbisPackageJson(exports) { + log('Preparing @celo/abis package.json') + const packageJsonPath = path.join(ABIS_PACKAGE_SRC_DIR, 'package.json') + const json = JSON.parse(fs.readFileSync(packageJsonPath).toString()) + + if (process.env.RELEASE_VERSION) { + log('Replacing @celo/abis version with provided RELEASE_VERSION') + + json.version = process.env.RELEASE_VERSION + } else { + log('No RELEASE_VERSION provided') + } + + log('Setting @celo/abis exports') + json.exports = exports + + fs.writeFileSync(packageJsonPath, JSON.stringify(json, null, 2)) +} + +function prepareContractsPackage() { + const contracts08CpCommand = `cp -r ${CONTRACTS_08_SOURCE_DIR} ${CONTRACTS_08_PACKAGE_DESTINATION_DIR}` + log(contracts08CpCommand) + child_process.execSync(contracts08CpCommand) + + if (process.env.RELEASE_VERSION) { + log('Replacing @celo/contracts version with RELEASE_VERSION)') + const contractsPackageJsonPath = path.join(CONTRACTS_PACKAGE_SRC_DIR, 'package.json') + const contents = fs.readFileSync(contractsPackageJsonPath).toString() + + fs.writeFileSync( + contractsPackageJsonPath, + contents.replace('0.0.0-template.version', process.env.RELEASE_VERSION) + ) + + return + } + + log('Skipping @celo/contracts package.json preparation (no RELEASE_VERSION provided)') +} + function lsRecursive(dir: string): string[] { const filesAndDirectories = fs.readdirSync(dir, { withFileTypes: true }) return filesAndDirectories.reduce((fileNames, fileOrDir) => { @@ -125,8 +282,21 @@ function lsRecursive(dir: string): string[] { function build(cmd: string) { log(`Running build for ${cmd}`) - child_process.execSync( - `BUILD_DIR=./build/abis/src ts-node ${BUILD_EXECUTABLE} --coreContractsOnly ${cmd}`, - { stdio: 'inherit' } - ) + child_process.execSync(`BUILD_DIR=./build ts-node ${BUILD_EXECUTABLE} ${cmd}`, { + stdio: 'inherit', + }) +} + +function mergeFromFolder(folderNames: string[], rootFolderName: string) { + for (const folderName of folderNames) { + const mvCommand = `mv -f ${rootFolderName}/${folderName}/* ${rootFolderName}` + const rmCommand = `rm -r ${rootFolderName}/${folderName}` + + log(mvCommand) + child_process.execSync(mvCommand) + + // Once copied all the files, remove the folder + log(rmCommand) + child_process.execSync(rmCommand) + } } diff --git a/packages/protocol/tsconfig.json b/packages/protocol/tsconfig.json index 93e3054ed23..86ec49d29c4 100644 --- a/packages/protocol/tsconfig.json +++ b/packages/protocol/tsconfig.json @@ -1,21 +1,27 @@ { - "compileOnSave": false, - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "baseUrl": ".", - "lib": ["dom", "es2015", "es2016"], - "module": "commonjs", - "moduleResolution": "node", - "noUnusedLocals": true, - "noUnusedParameters": true, - "removeComments": false, - "skipLibCheck": true, - "sourceMap": true, - "target": "ES5", - "downlevelIteration": true, - "resolveJsonModule": true - }, - "exclude": ["node_modules", "wagmi.config.ts"], - "references": [{ "path": "../sdk/utils" }] -} + "compileOnSave": false, + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "baseUrl": ".", + "lib": [ + "es2015", + "es2016" + ], + "module": "commonjs", + "moduleResolution": "node", + "noUnusedLocals": true, + "noUnusedParameters": true, + "removeComments": false, + "skipLibCheck": true, + "sourceMap": true, + "target": "es5", + "downlevelIteration": true, + "resolveJsonModule": true + }, + "exclude": [ + "node_modules", + "wagmi.config.ts", + "abis" + ] +} \ No newline at end of file diff --git a/packages/protocol/wagmi.config.ts b/packages/protocol/wagmi.config.ts index 8c33b65fb74..68b0a72c103 100644 --- a/packages/protocol/wagmi.config.ts +++ b/packages/protocol/wagmi.config.ts @@ -2,10 +2,10 @@ import { defineConfig } from '@wagmi/cli' import { readFileSync } from 'fs' import * as path from 'path' -import { ABIS_BUILD_DIR, CoreContracts } from './scripts/consts' +import { ABIS_BUILD_DIR, PublishContracts } from './scripts/consts' const contracts: { name: string; abi: any }[] = [] -for (const contractName of new Set(CoreContracts)) { +for (const contractName of new Set(PublishContracts)) { try { const fileStr = readFileSync(path.join(ABIS_BUILD_DIR, `${contractName}.json`)) contracts.push({ diff --git a/packages/sdk/contractkit/README.md b/packages/sdk/contractkit/README.md index e8026404dfb..e18079e1cb2 100644 --- a/packages/sdk/contractkit/README.md +++ b/packages/sdk/contractkit/README.md @@ -178,7 +178,7 @@ You can also initialize contracts wrappers directly. They require a `Connection` import { newKit } from "@celo/contractkit/lib/mini-kit" import { MultiSigWrapper } from '@celo/contractkit/lib/wrappers/MultiSig' -import { newMultiSig } from '@celo/contractkit/lib/generated/MultiSig' +import { newMultiSig } from '@celo/abis/web3/MultiSig' const miniKit = newKit("https://alfajores-forno.celo-testnet.org/") diff --git a/packages/sdk/contractkit/package.json b/packages/sdk/contractkit/package.json index eda6808236b..271e2612c86 100644 --- a/packages/sdk/contractkit/package.json +++ b/packages/sdk/contractkit/package.json @@ -16,17 +16,15 @@ ], "scripts": { "build:ts": "tsc -b .", - "build:gen": "yarn --cwd ../../protocol ts-node ./scripts/build.ts --web3Types ../sdk/contractkit/src/generated", - "build": "yarn build:gen && yarn build:ts", - "build:releasetag": "BUILD_DIR=./build/$RELEASE_TAG yarn build", + "build": "tsc -b .", "clean": "tsc -b . --clean", - "clean:all": "yarn clean && rm -rf src/generated", "prepublishOnly": "yarn build", "docs": "typedoc", "test": "jest --runInBand --forceExit", "lint": "tslint -c tslint.json --project ." }, "dependencies": { + "@celo/abis": "10.0.0", "@celo/base": "^6.0.0", "@celo/connect": "^5.1.1", "@celo/utils": "^5.0.6", @@ -43,10 +41,9 @@ "web3-core-helpers": "1.10.0" }, "devDependencies": { - "@celo/celo-devchain": "^6.0.3-beta.1", + "@celo/celo-devchain": "^6.0.3", "@celo/odis-identifiers": "^1.0.0", "@celo/dev-utils": "0.0.1", - "@celo/protocol": "1.0.2", "@types/debug": "^4.1.5", "fetch-mock": "9.10.4", "ganache": "npm:@celo/ganache@7.8.0-unofficial.0", diff --git a/packages/sdk/contractkit/src/address-registry.ts b/packages/sdk/contractkit/src/address-registry.ts index 83937637a68..33e5958de7f 100644 --- a/packages/sdk/contractkit/src/address-registry.ts +++ b/packages/sdk/contractkit/src/address-registry.ts @@ -1,8 +1,8 @@ +import { newRegistry, Registry } from '@celo/abis/web3/Registry' import { Address, NULL_ADDRESS } from '@celo/base/lib/address' import { Connection } from '@celo/connect' import debugFactory from 'debug' import { CeloContract, RegisteredContracts, stripProxy } from './base' -import { newRegistry, Registry } from './generated/Registry' const debug = debugFactory('kit:registry') diff --git a/packages/sdk/contractkit/src/contract-cache.ts b/packages/sdk/contractkit/src/contract-cache.ts index 51bdb7b1931..ff7e033e609 100644 --- a/packages/sdk/contractkit/src/contract-cache.ts +++ b/packages/sdk/contractkit/src/contract-cache.ts @@ -1,9 +1,9 @@ +import { IERC20 } from '@celo/abis/web3/IERC20' import { Connection } from '@celo/connect' import { AddressRegistry } from './address-registry' import { CeloContract } from './base' import { ContractCacheType } from './basic-contract-cache-type' import { StableToken, stableTokenInfos } from './celo-tokens' -import { IERC20 } from './generated/IERC20' import { Web3ContractCache } from './web3-contract-cache' import { AccountsWrapper } from './wrappers/Accounts' import { AttestationsWrapper } from './wrappers/Attestations' diff --git a/packages/sdk/contractkit/src/mini-contract-cache.ts b/packages/sdk/contractkit/src/mini-contract-cache.ts index 72a4c93115b..c4b6e25d125 100644 --- a/packages/sdk/contractkit/src/mini-contract-cache.ts +++ b/packages/sdk/contractkit/src/mini-contract-cache.ts @@ -1,18 +1,18 @@ +import { newGasPriceMinimum } from '@celo/abis/web3/0.8/GasPriceMinimum' +import { newAccounts } from '@celo/abis/web3/Accounts' +import { newGoldToken } from '@celo/abis/web3/GoldToken' +import { newExchange } from '@celo/abis/web3/mento/Exchange' +import { newExchangeBRL } from '@celo/abis/web3/mento/ExchangeBRL' +import { newExchangeEUR } from '@celo/abis/web3/mento/ExchangeEUR' +import { newStableToken } from '@celo/abis/web3/mento/StableToken' +import { newStableTokenBRL } from '@celo/abis/web3/mento/StableTokenBRL' +import { newStableTokenEUR } from '@celo/abis/web3/mento/StableTokenEUR' import { StableToken } from '@celo/base' import { Connection } from '@celo/connect' import { AddressRegistry } from './address-registry' import { CeloContract } from './base' import { ContractCacheType } from './basic-contract-cache-type' import { stableTokenInfos } from './celo-tokens' -import { newGasPriceMinimum } from './generated/0.8/GasPriceMinimum' -import { newAccounts } from './generated/Accounts' -import { newGoldToken } from './generated/GoldToken' -import { newExchange } from './generated/mento/Exchange' -import { newExchangeBRL } from './generated/mento/ExchangeBRL' -import { newExchangeEUR } from './generated/mento/ExchangeEUR' -import { newStableToken } from './generated/mento/StableToken' -import { newStableTokenBRL } from './generated/mento/StableTokenBRL' -import { newStableTokenEUR } from './generated/mento/StableTokenEUR' import { AccountsWrapper } from './wrappers/Accounts' import { ExchangeWrapper } from './wrappers/Exchange' import { GasPriceMinimumWrapper } from './wrappers/GasPriceMinimum' diff --git a/packages/sdk/contractkit/src/proxy.ts b/packages/sdk/contractkit/src/proxy.ts index 9bd8c457dcf..6c57ec4adea 100644 --- a/packages/sdk/contractkit/src/proxy.ts +++ b/packages/sdk/contractkit/src/proxy.ts @@ -1,37 +1,37 @@ // tslint:disable: ordered-imports import { ABIDefinition, AbiItem } from '@celo/connect' import Web3 from 'web3' -import { ABI as GasPriceMinimumABI } from './generated/0.8/GasPriceMinimum' -import { ABI as AccountsABI } from './generated/Accounts' -import { ABI as AttestationsABI } from './generated/Attestations' -import { ABI as BlockchainParametersABI } from './generated/BlockchainParameters' -import { ABI as DoubleSigningSlasherABI } from './generated/DoubleSigningSlasher' -import { ABI as DowntimeSlasherABI } from './generated/DowntimeSlasher' -import { ABI as ElectionABI } from './generated/Election' -import { ABI as EpochRewardsABI } from './generated/EpochRewards' -import { ABI as EscrowABI } from './generated/Escrow' -import { ABI as FederatedAttestationsABI } from './generated/FederatedAttestations' -import { ABI as FeeCurrencyWhitelistABI } from './generated/FeeCurrencyWhitelist' -import { ABI as FeeHandlerABI } from './generated/FeeHandler' -import { ABI as FreezerABI } from './generated/Freezer' -import { ABI as GoldTokenABI } from './generated/GoldToken' -import { ABI as GovernanceABI } from './generated/Governance' -import { ABI as LockedGoldABI } from './generated/LockedGold' -import { ABI as MentoFeeHandlerSellerABI } from './generated/MentoFeeHandlerSeller' -import { ABI as MetaTransactionWalletABI } from './generated/MetaTransactionWallet' -import { ABI as MetaTransactionWalletDeployerABI } from './generated/MetaTransactionWalletDeployer' -import { ABI as MultiSigABI } from './generated/MultiSig' -import { ABI as OdisPaymentsABI } from './generated/OdisPayments' -import { ABI as ProxyABI } from './generated/Proxy' -import { ABI as RandomABI } from './generated/Random' -import { ABI as RegistryABI } from './generated/Registry' -import { ABI as SortedOraclesABI } from './generated/SortedOracles' -import { ABI as UniswapFeeHandlerSellerABI } from './generated/UniswapFeeHandlerSeller' -import { ABI as ValidatorsABI } from './generated/Validators' -import { ABI as ExchangeABI } from './generated/mento/Exchange' -import { ABI as GrandaMentoABI } from './generated/mento/GrandaMento' -import { ABI as ReserveABI } from './generated/mento/Reserve' -import { ABI as StableTokenABI } from './generated/mento/StableToken' +import { ABI as GasPriceMinimumABI } from '@celo/abis/web3/0.8/GasPriceMinimum' +import { ABI as AccountsABI } from '@celo/abis/web3/Accounts' +import { ABI as AttestationsABI } from '@celo/abis/web3/Attestations' +import { ABI as BlockchainParametersABI } from '@celo/abis/web3/BlockchainParameters' +import { ABI as DoubleSigningSlasherABI } from '@celo/abis/web3/DoubleSigningSlasher' +import { ABI as DowntimeSlasherABI } from '@celo/abis/web3/DowntimeSlasher' +import { ABI as ElectionABI } from '@celo/abis/web3/Election' +import { ABI as EpochRewardsABI } from '@celo/abis/web3/EpochRewards' +import { ABI as EscrowABI } from '@celo/abis/web3/Escrow' +import { ABI as FederatedAttestationsABI } from '@celo/abis/web3/FederatedAttestations' +import { ABI as FeeCurrencyWhitelistABI } from '@celo/abis/web3/FeeCurrencyWhitelist' +import { ABI as FeeHandlerABI } from '@celo/abis/web3/FeeHandler' +import { ABI as FreezerABI } from '@celo/abis/web3/Freezer' +import { ABI as GoldTokenABI } from '@celo/abis/web3/GoldToken' +import { ABI as GovernanceABI } from '@celo/abis/web3/Governance' +import { ABI as LockedGoldABI } from '@celo/abis/web3/LockedGold' +import { ABI as MentoFeeHandlerSellerABI } from '@celo/abis/web3/MentoFeeHandlerSeller' +import { ABI as MetaTransactionWalletABI } from '@celo/abis/web3/MetaTransactionWallet' +import { ABI as MetaTransactionWalletDeployerABI } from '@celo/abis/web3/MetaTransactionWalletDeployer' +import { ABI as MultiSigABI } from '@celo/abis/web3/MultiSig' +import { ABI as OdisPaymentsABI } from '@celo/abis/web3/OdisPayments' +import { ABI as ProxyABI } from '@celo/abis/web3/Proxy' +import { ABI as RandomABI } from '@celo/abis/web3/Random' +import { ABI as RegistryABI } from '@celo/abis/web3/Registry' +import { ABI as SortedOraclesABI } from '@celo/abis/web3/SortedOracles' +import { ABI as UniswapFeeHandlerSellerABI } from '@celo/abis/web3/UniswapFeeHandlerSeller' +import { ABI as ValidatorsABI } from '@celo/abis/web3/Validators' +import { ABI as ExchangeABI } from '@celo/abis/web3/mento/Exchange' +import { ABI as GrandaMentoABI } from '@celo/abis/web3/mento/GrandaMento' +import { ABI as ReserveABI } from '@celo/abis/web3/mento/Reserve' +import { ABI as StableTokenABI } from '@celo/abis/web3/mento/StableToken' export const GET_IMPLEMENTATION_ABI: ABIDefinition = { constant: true, diff --git a/packages/sdk/contractkit/src/web3-contract-cache.ts b/packages/sdk/contractkit/src/web3-contract-cache.ts index 1fd60ba80c4..c3e31b36549 100644 --- a/packages/sdk/contractkit/src/web3-contract-cache.ts +++ b/packages/sdk/contractkit/src/web3-contract-cache.ts @@ -3,41 +3,41 @@ import debugFactory from 'debug' import { AddressRegistry } from './address-registry' import { CeloContract, ProxyContracts } from './base' import { StableToken } from './celo-tokens' -import { newGasPriceMinimum } from './generated/0.8/GasPriceMinimum' -import { newAccounts } from './generated/Accounts' -import { newAttestations } from './generated/Attestations' -import { newBlockchainParameters } from './generated/BlockchainParameters' -import { newDoubleSigningSlasher } from './generated/DoubleSigningSlasher' -import { newDowntimeSlasher } from './generated/DowntimeSlasher' -import { newElection } from './generated/Election' -import { newEpochRewards } from './generated/EpochRewards' -import { newEscrow } from './generated/Escrow' -import { newFederatedAttestations } from './generated/FederatedAttestations' -import { newFeeCurrencyWhitelist } from './generated/FeeCurrencyWhitelist' -import { newFeeHandler } from './generated/FeeHandler' -import { newFreezer } from './generated/Freezer' -import { newGoldToken } from './generated/GoldToken' -import { newGovernance } from './generated/Governance' -import { newIERC20 } from './generated/IERC20' -import { newLockedGold } from './generated/LockedGold' -import { newMetaTransactionWallet } from './generated/MetaTransactionWallet' -import { newMetaTransactionWalletDeployer } from './generated/MetaTransactionWalletDeployer' -import { newMultiSig } from './generated/MultiSig' -import { newOdisPayments } from './generated/OdisPayments' -import { newProxy } from './generated/Proxy' -import { newRandom } from './generated/Random' -import { newRegistry } from './generated/Registry' -import { newSortedOracles } from './generated/SortedOracles' -import { newValidators } from './generated/Validators' -import { newExchange } from './generated/mento/Exchange' -import { newExchangeBRL } from './generated/mento/ExchangeBRL' -import { newExchangeEUR } from './generated/mento/ExchangeEUR' -import { newGrandaMento } from './generated/mento/GrandaMento' -import { newReserve } from './generated/mento/Reserve' -import { newStableToken } from './generated/mento/StableToken' +import { newGasPriceMinimum } from '@celo/abis/web3/0.8/GasPriceMinimum' +import { newAccounts } from '@celo/abis/web3/Accounts' +import { newAttestations } from '@celo/abis/web3/Attestations' +import { newBlockchainParameters } from '@celo/abis/web3/BlockchainParameters' +import { newDoubleSigningSlasher } from '@celo/abis/web3/DoubleSigningSlasher' +import { newDowntimeSlasher } from '@celo/abis/web3/DowntimeSlasher' +import { newElection } from '@celo/abis/web3/Election' +import { newEpochRewards } from '@celo/abis/web3/EpochRewards' +import { newEscrow } from '@celo/abis/web3/Escrow' +import { newFederatedAttestations } from '@celo/abis/web3/FederatedAttestations' +import { newFeeCurrencyWhitelist } from '@celo/abis/web3/FeeCurrencyWhitelist' +import { newFeeHandler } from '@celo/abis/web3/FeeHandler' +import { newFreezer } from '@celo/abis/web3/Freezer' +import { newGoldToken } from '@celo/abis/web3/GoldToken' +import { newGovernance } from '@celo/abis/web3/Governance' +import { newIERC20 } from '@celo/abis/web3/IERC20' +import { newLockedGold } from '@celo/abis/web3/LockedGold' +import { newMetaTransactionWallet } from '@celo/abis/web3/MetaTransactionWallet' +import { newMetaTransactionWalletDeployer } from '@celo/abis/web3/MetaTransactionWalletDeployer' +import { newMultiSig } from '@celo/abis/web3/MultiSig' +import { newOdisPayments } from '@celo/abis/web3/OdisPayments' +import { newProxy } from '@celo/abis/web3/Proxy' +import { newRandom } from '@celo/abis/web3/Random' +import { newRegistry } from '@celo/abis/web3/Registry' +import { newSortedOracles } from '@celo/abis/web3/SortedOracles' +import { newValidators } from '@celo/abis/web3/Validators' +import { newExchange } from '@celo/abis/web3/mento/Exchange' +import { newExchangeBRL } from '@celo/abis/web3/mento/ExchangeBRL' +import { newExchangeEUR } from '@celo/abis/web3/mento/ExchangeEUR' +import { newGrandaMento } from '@celo/abis/web3/mento/GrandaMento' +import { newReserve } from '@celo/abis/web3/mento/Reserve' +import { newStableToken } from '@celo/abis/web3/mento/StableToken' -import { newMentoFeeHandlerSeller } from './generated/MentoFeeHandlerSeller' -import { newUniswapFeeHandlerSeller } from './generated/UniswapFeeHandlerSeller' +import { newMentoFeeHandlerSeller } from '@celo/abis/web3/MentoFeeHandlerSeller' +import { newUniswapFeeHandlerSeller } from '@celo/abis/web3/UniswapFeeHandlerSeller' const debug = debugFactory('kit:web3-contract-cache') diff --git a/packages/sdk/contractkit/src/wrappers/Accounts.ts b/packages/sdk/contractkit/src/wrappers/Accounts.ts index 3a13144a922..a9d2935f18e 100644 --- a/packages/sdk/contractkit/src/wrappers/Accounts.ts +++ b/packages/sdk/contractkit/src/wrappers/Accounts.ts @@ -1,3 +1,4 @@ +import { Accounts } from '@celo/abis/web3/Accounts' import { NativeSigner, Signature, Signer } from '@celo/base/lib/signatureUtils' import { Address, CeloTransactionObject, toTransactionObject } from '@celo/connect' import { @@ -9,7 +10,6 @@ import { import { soliditySha3 } from '@celo/utils/lib/solidity' import { authorizeSigner as buildAuthorizeSignerTypedData } from '@celo/utils/lib/typed-data-constructors' import type BN from 'bn.js' // just the types -import { Accounts } from '../generated/Accounts' import { getParsedSignatureOfAddress } from '../utils/getParsedSignatureOfAddress' import { newContractVersion } from '../versions' import { diff --git a/packages/sdk/contractkit/src/wrappers/Attestations.ts b/packages/sdk/contractkit/src/wrappers/Attestations.ts index d1b539d4653..5787d06d4bb 100644 --- a/packages/sdk/contractkit/src/wrappers/Attestations.ts +++ b/packages/sdk/contractkit/src/wrappers/Attestations.ts @@ -1,8 +1,8 @@ +import { Attestations } from '@celo/abis/web3/Attestations' import { StableToken } from '@celo/base' import { eqAddress } from '@celo/base/lib/address' import { Address, Connection, toTransactionObject } from '@celo/connect' import BigNumber from 'bignumber.js' -import { Attestations } from '../generated/Attestations' import { AccountsWrapper } from './Accounts' import { BaseWrapper, diff --git a/packages/sdk/contractkit/src/wrappers/BaseSlasher.ts b/packages/sdk/contractkit/src/wrappers/BaseSlasher.ts index 17a03fb5b35..122df4322a0 100644 --- a/packages/sdk/contractkit/src/wrappers/BaseSlasher.ts +++ b/packages/sdk/contractkit/src/wrappers/BaseSlasher.ts @@ -61,7 +61,7 @@ export class BaseSlasher extends BaseWrapperForGovern } protected slash = (...args: Parameters) => - toTransactionObject(this.connection, this.contract.methods.slash(...args)) + toTransactionObject(this.connection, this.contract.methods.slash(...(args as any[]))) /** * Returns slashing incentives. diff --git a/packages/sdk/contractkit/src/wrappers/BaseWrapper.test.ts b/packages/sdk/contractkit/src/wrappers/BaseWrapper.test.ts index e24bc768e8a..fa52d068888 100644 --- a/packages/sdk/contractkit/src/wrappers/BaseWrapper.test.ts +++ b/packages/sdk/contractkit/src/wrappers/BaseWrapper.test.ts @@ -5,7 +5,7 @@ import Web3 from 'web3' import { ICeloVersionedContract, newICeloVersionedContract, -} from '../generated/ICeloVersionedContract' +} from '@celo/abis/web3/ICeloVersionedContract' import { ContractVersion, newContractVersion } from '../versions' import { BaseWrapper, unixSecondsTimestampToDateString } from './BaseWrapper' diff --git a/packages/sdk/contractkit/src/wrappers/BaseWrapper.ts b/packages/sdk/contractkit/src/wrappers/BaseWrapper.ts index a53b10195c2..efce69af554 100644 --- a/packages/sdk/contractkit/src/wrappers/BaseWrapper.ts +++ b/packages/sdk/contractkit/src/wrappers/BaseWrapper.ts @@ -1,3 +1,4 @@ +import { ICeloVersionedContract } from '@celo/abis/web3/ICeloVersionedContract' import { bufferToHex, ensureLeading0x } from '@celo/base/lib/address' import { zip } from '@celo/base/lib/collections' import { @@ -11,7 +12,6 @@ import { } from '@celo/connect' import { fromFixed, toFixed } from '@celo/utils/lib/fixidity' import BigNumber from 'bignumber.js' -import { ICeloVersionedContract } from '../generated/ICeloVersionedContract' import { ContractVersion } from '../versions' /** Represents web3 native contract Method */ diff --git a/packages/sdk/contractkit/src/wrappers/BlockChainParameters.test.ts b/packages/sdk/contractkit/src/wrappers/BlockChainParameters.test.ts index e36c9795e4e..c677dba2d55 100644 --- a/packages/sdk/contractkit/src/wrappers/BlockChainParameters.test.ts +++ b/packages/sdk/contractkit/src/wrappers/BlockChainParameters.test.ts @@ -3,7 +3,7 @@ import { testWithGanache } from '@celo/dev-utils/lib/ganache-test' import BigNumber from 'bignumber.js' import { AddressRegistry } from '../address-registry' import { CeloContract } from '../base' -import { newBlockchainParameters } from '../generated/BlockchainParameters' +import { newBlockchainParameters } from '@celo/abis/web3/BlockchainParameters' import { BlockchainParametersWrapper } from './BlockchainParameters' testWithGanache('BlockChainParametersWrapper', (web3) => { diff --git a/packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts b/packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts index c800ae7a3f0..30e04f7c051 100644 --- a/packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts +++ b/packages/sdk/contractkit/src/wrappers/BlockchainParameters.ts @@ -1,5 +1,5 @@ +import { BlockchainParameters } from '@celo/abis/web3/BlockchainParameters' import { BigNumber } from 'bignumber.js' -import { BlockchainParameters } from '../generated/BlockchainParameters' import { BaseWrapper, proxyCall, proxySend, valueToBigNumber, valueToInt } from './BaseWrapper' export interface BlockchainParametersConfig { diff --git a/packages/sdk/contractkit/src/wrappers/CeloTokenWrapper.ts b/packages/sdk/contractkit/src/wrappers/CeloTokenWrapper.ts index 39f0e8b3bc8..255f2c44cca 100644 --- a/packages/sdk/contractkit/src/wrappers/CeloTokenWrapper.ts +++ b/packages/sdk/contractkit/src/wrappers/CeloTokenWrapper.ts @@ -1,9 +1,9 @@ // NOTE: removing this import results in `yarn build` failures in Dockerfiles // after the move to node 10. This allows types to be inferred without // referencing '@celo/utils/node_modules/bignumber.js' +import { ICeloToken } from '@celo/abis/web3/ICeloToken' +import { IERC20 } from '@celo/abis/web3/IERC20' import 'bignumber.js' -import { ICeloToken } from '../generated/ICeloToken' -import { IERC20 } from '../generated/IERC20' import { proxyCall, proxySend, valueToInt } from './BaseWrapper' import { Erc20Wrapper } from './Erc20Wrapper' diff --git a/packages/sdk/contractkit/src/wrappers/DoubleSigningSlasher.ts b/packages/sdk/contractkit/src/wrappers/DoubleSigningSlasher.ts index c25454a147b..6958b59b815 100644 --- a/packages/sdk/contractkit/src/wrappers/DoubleSigningSlasher.ts +++ b/packages/sdk/contractkit/src/wrappers/DoubleSigningSlasher.ts @@ -1,5 +1,5 @@ +import { DoubleSigningSlasher } from '@celo/abis/web3/DoubleSigningSlasher' import { Address } from '@celo/connect' -import { DoubleSigningSlasher } from '../generated/DoubleSigningSlasher' import { BaseSlasher } from './BaseSlasher' import { valueToInt } from './BaseWrapper' diff --git a/packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts b/packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts index c3f543f49dd..d3ad94bafe5 100644 --- a/packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts +++ b/packages/sdk/contractkit/src/wrappers/DowntimeSlasher.ts @@ -1,6 +1,6 @@ +import { DowntimeSlasher } from '@celo/abis/web3/DowntimeSlasher' import { Address } from '@celo/connect' import BigNumber from 'bignumber.js' -import { DowntimeSlasher } from '../generated/DowntimeSlasher' import { BaseSlasher } from './BaseSlasher' import { blocksToDurationString, diff --git a/packages/sdk/contractkit/src/wrappers/Election.ts b/packages/sdk/contractkit/src/wrappers/Election.ts index d5d919d93b1..61e8e164fb6 100644 --- a/packages/sdk/contractkit/src/wrappers/Election.ts +++ b/packages/sdk/contractkit/src/wrappers/Election.ts @@ -1,3 +1,4 @@ +import { Election } from '@celo/abis/web3/Election' import { eqAddress, findAddressIndex, @@ -8,7 +9,6 @@ import { concurrentMap, concurrentValuesMap } from '@celo/base/lib/async' import { zeroRange, zip } from '@celo/base/lib/collections' import { Address, CeloTransactionObject, EventLog, toTransactionObject } from '@celo/connect' import BigNumber from 'bignumber.js' -import { Election } from '../generated/Election' import { fixidityValueToBigNumber, identity, diff --git a/packages/sdk/contractkit/src/wrappers/EpochRewards.ts b/packages/sdk/contractkit/src/wrappers/EpochRewards.ts index c1e6b36ceb3..c69d6b9244c 100644 --- a/packages/sdk/contractkit/src/wrappers/EpochRewards.ts +++ b/packages/sdk/contractkit/src/wrappers/EpochRewards.ts @@ -1,5 +1,5 @@ +import { EpochRewards } from '@celo/abis/web3/EpochRewards' import { fromFixed } from '@celo/utils/lib/fixidity' -import { EpochRewards } from '../generated/EpochRewards' import { BaseWrapper, proxyCall, valueToBigNumber } from './BaseWrapper' const parseFixidity = (v: string) => fromFixed(valueToBigNumber(v)) diff --git a/packages/sdk/contractkit/src/wrappers/Erc20Wrapper.ts b/packages/sdk/contractkit/src/wrappers/Erc20Wrapper.ts index 31269a840e4..b9228cd455f 100644 --- a/packages/sdk/contractkit/src/wrappers/Erc20Wrapper.ts +++ b/packages/sdk/contractkit/src/wrappers/Erc20Wrapper.ts @@ -1,8 +1,8 @@ // NOTE: removing this import results in `yarn build` failures in Dockerfiles // after the move to node 10. This allows types to be inferred without // referencing '@celo/utils/node_modules/bignumber.js' +import { IERC20 } from '@celo/abis/web3/IERC20' import BigNumber from 'bignumber.js' -import { IERC20 } from '../generated/IERC20' import { BaseWrapper, proxyCall, proxySend, valueToBigNumber } from './BaseWrapper' /** diff --git a/packages/sdk/contractkit/src/wrappers/Escrow.ts b/packages/sdk/contractkit/src/wrappers/Escrow.ts index 4742b0c18b7..142022303f9 100644 --- a/packages/sdk/contractkit/src/wrappers/Escrow.ts +++ b/packages/sdk/contractkit/src/wrappers/Escrow.ts @@ -1,5 +1,5 @@ +import { Escrow } from '@celo/abis/web3/Escrow' import { Address, CeloTransactionObject } from '@celo/connect' -import { Escrow } from '../generated/Escrow' import { BaseWrapper, proxyCall, proxySend } from './BaseWrapper' /** diff --git a/packages/sdk/contractkit/src/wrappers/Exchange.ts b/packages/sdk/contractkit/src/wrappers/Exchange.ts index 1cc3177d229..8ebb1482edb 100644 --- a/packages/sdk/contractkit/src/wrappers/Exchange.ts +++ b/packages/sdk/contractkit/src/wrappers/Exchange.ts @@ -1,6 +1,6 @@ +import { Exchange } from '@celo/abis/web3/mento/Exchange' import { CeloTransactionObject } from '@celo/connect' import BigNumber from 'bignumber.js' -import { Exchange } from '../generated/mento/Exchange' import { BaseWrapper, fixidityValueToBigNumber, diff --git a/packages/sdk/contractkit/src/wrappers/FederatedAttestations.ts b/packages/sdk/contractkit/src/wrappers/FederatedAttestations.ts index 4323ccffa39..86e65e5c34e 100644 --- a/packages/sdk/contractkit/src/wrappers/FederatedAttestations.ts +++ b/packages/sdk/contractkit/src/wrappers/FederatedAttestations.ts @@ -1,6 +1,6 @@ +import { FederatedAttestations } from '@celo/abis/web3/FederatedAttestations' import { Address, CeloTransactionObject, toTransactionObject } from '@celo/connect' import { registerAttestation as buildRegisterAttestationTypedData } from '@celo/utils/lib/typed-data-constructors' -import { FederatedAttestations } from '../generated/FederatedAttestations' import { BaseWrapper, proxyCall, proxySend } from './BaseWrapper' export class FederatedAttestationsWrapper extends BaseWrapper { diff --git a/packages/sdk/contractkit/src/wrappers/FeeHandler.ts b/packages/sdk/contractkit/src/wrappers/FeeHandler.ts index 207db37a68c..1d90fad4272 100644 --- a/packages/sdk/contractkit/src/wrappers/FeeHandler.ts +++ b/packages/sdk/contractkit/src/wrappers/FeeHandler.ts @@ -1,7 +1,7 @@ +import { FeeHandler } from '@celo/abis/web3/FeeHandler' import { Address } from '@celo/connect' import BigNumber from 'bignumber.js' import { StableTokenContract } from '../base' -import { FeeHandler } from '../generated/FeeHandler' import { BaseWrapper, proxyCall, proxySend } from './BaseWrapper' export enum ExchangeProposalState { diff --git a/packages/sdk/contractkit/src/wrappers/Freezer.ts b/packages/sdk/contractkit/src/wrappers/Freezer.ts index 2dcb5ec8b58..26200c9020a 100644 --- a/packages/sdk/contractkit/src/wrappers/Freezer.ts +++ b/packages/sdk/contractkit/src/wrappers/Freezer.ts @@ -1,4 +1,4 @@ -import { Freezer } from '../generated/Freezer' +import { Freezer } from '@celo/abis/web3/Freezer' import { BaseWrapper, proxyCall, proxySend } from './BaseWrapper' export class FreezerWrapper extends BaseWrapper { diff --git a/packages/sdk/contractkit/src/wrappers/GasPriceMinimum.ts b/packages/sdk/contractkit/src/wrappers/GasPriceMinimum.ts index 87cfbda9bf1..821820f35a7 100644 --- a/packages/sdk/contractkit/src/wrappers/GasPriceMinimum.ts +++ b/packages/sdk/contractkit/src/wrappers/GasPriceMinimum.ts @@ -1,5 +1,5 @@ +import { GasPriceMinimum } from '@celo/abis/web3/0.8/GasPriceMinimum' import BigNumber from 'bignumber.js' -import { GasPriceMinimum } from '../generated/0.8/GasPriceMinimum' import { BaseWrapper, fixidityValueToBigNumber, proxyCall, valueToBigNumber } from './BaseWrapper' export interface GasPriceMinimumConfig { diff --git a/packages/sdk/contractkit/src/wrappers/GoldTokenWrapper.ts b/packages/sdk/contractkit/src/wrappers/GoldTokenWrapper.ts index 370b98f27bf..3943441b8c8 100644 --- a/packages/sdk/contractkit/src/wrappers/GoldTokenWrapper.ts +++ b/packages/sdk/contractkit/src/wrappers/GoldTokenWrapper.ts @@ -1,9 +1,9 @@ // NOTE: removing this import results in `yarn build` failures in Dockerfiles // after the move to node 10. This allows types to be inferred without // referencing '@celo/utils/node_modules/bignumber.js' +import { GoldToken } from '@celo/abis/web3/GoldToken' import { Address } from '@celo/base' import 'bignumber.js' -import { GoldToken } from '../generated/GoldToken' import { proxySend, stringIdentity, diff --git a/packages/sdk/contractkit/src/wrappers/Governance.test.ts b/packages/sdk/contractkit/src/wrappers/Governance.test.ts index 1505f05b1f0..fc45bcbd03f 100644 --- a/packages/sdk/contractkit/src/wrappers/Governance.test.ts +++ b/packages/sdk/contractkit/src/wrappers/Governance.test.ts @@ -4,7 +4,7 @@ import { NetworkConfig, testWithGanache, timeTravel } from '@celo/dev-utils/lib/ import BigNumber from 'bignumber.js' import Web3 from 'web3' import { CeloContract } from '..' -import { Registry } from '../generated/Registry' +import { Registry } from '@celo/abis/web3/Registry' import { newKitFromWeb3 } from '../kit' import { AccountsWrapper } from './Accounts' import { GovernanceWrapper, Proposal, ProposalTransaction, VoteValue } from './Governance' diff --git a/packages/sdk/contractkit/src/wrappers/Governance.ts b/packages/sdk/contractkit/src/wrappers/Governance.ts index 6cc2c23e58c..21ca62316bd 100644 --- a/packages/sdk/contractkit/src/wrappers/Governance.ts +++ b/packages/sdk/contractkit/src/wrappers/Governance.ts @@ -1,3 +1,4 @@ +import { Governance } from '@celo/abis/web3/Governance' import { bufferToHex, ensureLeading0x, @@ -10,7 +11,6 @@ import { zeroRange, zip } from '@celo/base/lib/collections' import { Address, CeloTxPending, toTransactionObject } from '@celo/connect' import { fromFixed } from '@celo/utils/lib/fixidity' import BigNumber from 'bignumber.js' -import { Governance } from '../generated/Governance' import { bufferToSolidityBytes, identity, diff --git a/packages/sdk/contractkit/src/wrappers/GrandaMento.ts b/packages/sdk/contractkit/src/wrappers/GrandaMento.ts index 5b56775fa00..591ef31ae7a 100644 --- a/packages/sdk/contractkit/src/wrappers/GrandaMento.ts +++ b/packages/sdk/contractkit/src/wrappers/GrandaMento.ts @@ -1,8 +1,8 @@ +import { GrandaMento } from '@celo/abis/web3/mento/GrandaMento' +import { newStableToken } from '@celo/abis/web3/mento/StableToken' import BigNumber from 'bignumber.js' import { StableTokenContract } from '../base' import { StableToken as StableTokenEnum, stableTokenInfos } from '../celo-tokens' -import { GrandaMento } from '../generated/mento/GrandaMento' -import { newStableToken } from '../generated/mento/StableToken' import { BaseWrapper, fixidityValueToBigNumber, diff --git a/packages/sdk/contractkit/src/wrappers/LockedGold.ts b/packages/sdk/contractkit/src/wrappers/LockedGold.ts index d36721a590c..fcc305d9556 100644 --- a/packages/sdk/contractkit/src/wrappers/LockedGold.ts +++ b/packages/sdk/contractkit/src/wrappers/LockedGold.ts @@ -1,3 +1,4 @@ +import { LockedGold } from '@celo/abis/web3/LockedGold' import { AddressListItem as ALI, Comparator, @@ -6,7 +7,6 @@ import { } from '@celo/base/lib/collections' import { Address, CeloTransactionObject, EventLog } from '@celo/connect' import BigNumber from 'bignumber.js' -import { LockedGold } from '../generated/LockedGold' import { ContractVersion } from '../versions' import { proxyCall, @@ -417,6 +417,7 @@ export class LockedGoldWrapper extends BaseWrapperForGoverning { } _getTotalPendingWithdrawalsCount = proxyCall( + // @ts-expect-error this.contract.methods.getTotalPendingWithdrawalsCount, undefined, valueToBigNumber diff --git a/packages/sdk/contractkit/src/wrappers/MetaTransactionWallet.ts b/packages/sdk/contractkit/src/wrappers/MetaTransactionWallet.ts index b9aff8794e5..fa38d5d229c 100644 --- a/packages/sdk/contractkit/src/wrappers/MetaTransactionWallet.ts +++ b/packages/sdk/contractkit/src/wrappers/MetaTransactionWallet.ts @@ -1,9 +1,9 @@ +import { MetaTransactionWallet } from '@celo/abis/web3/MetaTransactionWallet' import { Address, ensureLeading0x, trimLeading0x } from '@celo/base/lib/address' import { Signature } from '@celo/base/lib/signatureUtils' import { CeloTransactionObject, CeloTxObject, toTransactionObject } from '@celo/connect' import { EIP712TypedData } from '@celo/utils/lib/sign-typed-data-utils' import BigNumber from 'bignumber.js' -import { MetaTransactionWallet } from '../generated/MetaTransactionWallet' import { BaseWrapper, proxyCall, diff --git a/packages/sdk/contractkit/src/wrappers/MetaTransactionWalletDeployer.test.ts b/packages/sdk/contractkit/src/wrappers/MetaTransactionWalletDeployer.test.ts index 335727826ff..e23271ea481 100644 --- a/packages/sdk/contractkit/src/wrappers/MetaTransactionWalletDeployer.test.ts +++ b/packages/sdk/contractkit/src/wrappers/MetaTransactionWalletDeployer.test.ts @@ -3,8 +3,11 @@ import MTWContractArtifacts from '@celo/celo-devchain/contracts/contracts-0.5/Me import MTWDeployerContractArtifacts from '@celo/celo-devchain/contracts/contracts-0.5/MetaTransactionWalletDeployer.json' import { CeloTxReceipt, EventLog } from '@celo/connect' import { testWithGanache } from '@celo/dev-utils/lib/ganache-test' -import { MetaTransactionWallet, newMetaTransactionWallet } from '../generated/MetaTransactionWallet' -import { newProxy } from '../generated/Proxy' +import { + MetaTransactionWallet, + newMetaTransactionWallet, +} from '@celo/abis/web3/MetaTransactionWallet' +import { newProxy } from '@celo/abis/web3/Proxy' import { newKitFromWeb3 } from '../kit' import { MetaTransactionWalletDeployerWrapper } from './MetaTransactionWalletDeployer' diff --git a/packages/sdk/contractkit/src/wrappers/MetaTransactionWalletDeployer.ts b/packages/sdk/contractkit/src/wrappers/MetaTransactionWalletDeployer.ts index 25fc0318777..4cbc46da035 100644 --- a/packages/sdk/contractkit/src/wrappers/MetaTransactionWalletDeployer.ts +++ b/packages/sdk/contractkit/src/wrappers/MetaTransactionWalletDeployer.ts @@ -1,4 +1,4 @@ -import { MetaTransactionWalletDeployer } from '../generated/MetaTransactionWalletDeployer' +import { MetaTransactionWalletDeployer } from '@celo/abis/web3/MetaTransactionWalletDeployer' import { BaseWrapper, proxySend } from './BaseWrapper' /* diff --git a/packages/sdk/contractkit/src/wrappers/MultiSig.ts b/packages/sdk/contractkit/src/wrappers/MultiSig.ts index e360529645f..d009a91bb19 100644 --- a/packages/sdk/contractkit/src/wrappers/MultiSig.ts +++ b/packages/sdk/contractkit/src/wrappers/MultiSig.ts @@ -1,6 +1,6 @@ +import { MultiSig } from '@celo/abis/web3/MultiSig' import { Address, CeloTransactionObject, CeloTxObject, toTransactionObject } from '@celo/connect' import BigNumber from 'bignumber.js' -import { MultiSig } from '../generated/MultiSig' import { BaseWrapper, proxyCall, diff --git a/packages/sdk/contractkit/src/wrappers/OdisPayments.ts b/packages/sdk/contractkit/src/wrappers/OdisPayments.ts index 3b4998a0a74..5777c5e670b 100644 --- a/packages/sdk/contractkit/src/wrappers/OdisPayments.ts +++ b/packages/sdk/contractkit/src/wrappers/OdisPayments.ts @@ -1,6 +1,6 @@ +import { OdisPayments } from '@celo/abis/web3/OdisPayments' import { Address, CeloTransactionObject } from '@celo/connect' import { BigNumber } from 'bignumber.js' -import { OdisPayments } from '../generated/OdisPayments' import { BaseWrapper, proxyCall, proxySend, valueToBigNumber } from './BaseWrapper' export class OdisPaymentsWrapper extends BaseWrapper { diff --git a/packages/sdk/contractkit/src/wrappers/ReleaseGold.ts b/packages/sdk/contractkit/src/wrappers/ReleaseGold.ts index 5896cf1989d..186e0c728ac 100644 --- a/packages/sdk/contractkit/src/wrappers/ReleaseGold.ts +++ b/packages/sdk/contractkit/src/wrappers/ReleaseGold.ts @@ -1,3 +1,4 @@ +import { ReleaseGold } from '@celo/abis/web3/ReleaseGold' import { concurrentMap } from '@celo/base' import { findAddressIndex } from '@celo/base/lib/address' import { Signature } from '@celo/base/lib/signatureUtils' @@ -5,7 +6,6 @@ import { Address, CeloTransactionObject, toTransactionObject } from '@celo/conne import { hashMessageWithPrefix, signedMessageToPublicKey } from '@celo/utils/lib/signatureUtils' import BigNumber from 'bignumber.js' import { flatten } from 'fp-ts/lib/Array' -import { ReleaseGold } from '../generated/ReleaseGold' import { proxyCall, proxySend, diff --git a/packages/sdk/contractkit/src/wrappers/Reserve.ts b/packages/sdk/contractkit/src/wrappers/Reserve.ts index b0bfe464889..05b7f3a8e99 100644 --- a/packages/sdk/contractkit/src/wrappers/Reserve.ts +++ b/packages/sdk/contractkit/src/wrappers/Reserve.ts @@ -1,6 +1,6 @@ +import { Reserve } from '@celo/abis/web3/mento/Reserve' import { Address, EventLog } from '@celo/connect' import BigNumber from 'bignumber.js' -import { Reserve } from '../generated/mento/Reserve' import { BaseWrapper, fixidityValueToBigNumber, diff --git a/packages/sdk/contractkit/src/wrappers/SortedOracles.test.ts b/packages/sdk/contractkit/src/wrappers/SortedOracles.test.ts index 2befdbb9f9a..4e4ce689d76 100644 --- a/packages/sdk/contractkit/src/wrappers/SortedOracles.test.ts +++ b/packages/sdk/contractkit/src/wrappers/SortedOracles.test.ts @@ -1,7 +1,7 @@ +import SortedOraclesArtifacts from '@celo/celo-devchain/contracts/contracts-0.5/SortedOracles.json' import { Address } from '@celo/connect' import { describeEach } from '@celo/dev-utils/lib/describeEach' import { NetworkConfig, testWithGanache, timeTravel } from '@celo/dev-utils/lib/ganache-test' -import SortedOraclesArtifacts from '@celo/celo-devchain/contracts/contracts-0.5/SortedOracles.json' import { CeloContract } from '../base' import { StableToken } from '../celo-tokens' import { newKitFromWeb3 } from '../kit' diff --git a/packages/sdk/contractkit/src/wrappers/SortedOracles.ts b/packages/sdk/contractkit/src/wrappers/SortedOracles.ts index 2bc56e81161..af14060b301 100644 --- a/packages/sdk/contractkit/src/wrappers/SortedOracles.ts +++ b/packages/sdk/contractkit/src/wrappers/SortedOracles.ts @@ -1,3 +1,4 @@ +import { SortedOracles } from '@celo/abis/web3/SortedOracles' import { eqAddress, NULL_ADDRESS } from '@celo/base/lib/address' import { Address, CeloTransactionObject, Connection, toTransactionObject } from '@celo/connect' import { isValidAddress } from '@celo/utils/lib/address' @@ -6,7 +7,6 @@ import BigNumber from 'bignumber.js' import { AddressRegistry } from '../address-registry' import { CeloContract, StableTokenContract } from '../base' import { isStableTokenContract, StableToken, stableTokenInfos } from '../celo-tokens' -import { SortedOracles } from '../generated/SortedOracles' import { BaseWrapper, proxyCall, @@ -136,7 +136,8 @@ export class SortedOraclesWrapper extends BaseWrapper { async isOldestReportExpired(target: ReportTarget): Promise<[boolean, Address]> { const identifier = await this.toCurrencyPairIdentifier(target) const response = await this.contract.methods.isOldestReportExpired(identifier).call() - return response as [boolean, Address] + // response is NOT an array, but a js object with two keys 0 and 1 + return [response[0], response[1]] } /** diff --git a/packages/sdk/contractkit/src/wrappers/StableTokenWrapper.ts b/packages/sdk/contractkit/src/wrappers/StableTokenWrapper.ts index d606f44321b..bb0a0f76d01 100644 --- a/packages/sdk/contractkit/src/wrappers/StableTokenWrapper.ts +++ b/packages/sdk/contractkit/src/wrappers/StableTokenWrapper.ts @@ -1,6 +1,6 @@ +import { StableToken } from '@celo/abis/web3/mento/StableToken' import { fromFixed } from '@celo/utils/lib/fixidity' import BigNumber from 'bignumber.js' -import { StableToken } from '../generated/mento/StableToken' import { proxyCall, proxySend, diff --git a/packages/sdk/contractkit/src/wrappers/Validators.ts b/packages/sdk/contractkit/src/wrappers/Validators.ts index 77a1db96c89..255d06b5bc7 100644 --- a/packages/sdk/contractkit/src/wrappers/Validators.ts +++ b/packages/sdk/contractkit/src/wrappers/Validators.ts @@ -1,10 +1,10 @@ +import { Validators } from '@celo/abis/web3/Validators' import { eqAddress, findAddressIndex, NULL_ADDRESS } from '@celo/base/lib/address' import { concurrentMap } from '@celo/base/lib/async' import { zeroRange, zip } from '@celo/base/lib/collections' import { Address, CeloTransactionObject, EventLog, toTransactionObject } from '@celo/connect' import { fromFixed, toFixed } from '@celo/utils/lib/fixidity' import BigNumber from 'bignumber.js' -import { Validators } from '../generated/Validators' import { blocksToDurationString, proxyCall, diff --git a/packages/sdk/contractkit/tsconfig.json b/packages/sdk/contractkit/tsconfig.json index c24241002b7..984b87c7e44 100644 --- a/packages/sdk/contractkit/tsconfig.json +++ b/packages/sdk/contractkit/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "@celo/typescript/tsconfig.library.json", "compilerOptions": { + "moduleResolution": "node16", "rootDir": "src", "outDir": "lib", "resolveJsonModule": true diff --git a/packages/sdk/contractkit/typedoc.json b/packages/sdk/contractkit/typedoc.json index 98ed9bc21e8..d47b699bff6 100644 --- a/packages/sdk/contractkit/typedoc.json +++ b/packages/sdk/contractkit/typedoc.json @@ -1,6 +1,6 @@ { "mode": "modules", - "exclude": ["**/generated/*.ts", "**/*+(index|.test).ts"], + "exclude": ["**/*+(index|.test).ts"], "excludeNotExported": true, "excludePrivate": true, "excludeProtected": true, diff --git a/packages/sdk/governance/package.json b/packages/sdk/governance/package.json index a68e8f07d1d..cdac59af85b 100644 --- a/packages/sdk/governance/package.json +++ b/packages/sdk/governance/package.json @@ -21,6 +21,7 @@ "prepublishOnly": "yarn build" }, "dependencies": { + "@celo/abis": "10.0.0", "@celo/base": "^6.0.0", "@celo/utils": "^5.0.6", "@celo/connect": "^5.1.1", diff --git a/packages/sdk/governance/src/proposals.ts b/packages/sdk/governance/src/proposals.ts index bb54d2290a6..29d9ba664b7 100644 --- a/packages/sdk/governance/src/proposals.ts +++ b/packages/sdk/governance/src/proposals.ts @@ -1,3 +1,5 @@ +import { ABI as GovernanceABI } from '@celo/abis/web3/Governance' +import { ABI as RegistryABI } from '@celo/abis/web3/Registry' import { Address, isHexString, trimLeading0x } from '@celo/base/lib/address' import { AbiCoder, @@ -18,8 +20,6 @@ import { REGISTRY_CONTRACT_ADDRESS, } from '@celo/contractkit' import { stripProxy, suffixProxy } from '@celo/contractkit/lib/base' -import { ABI as GovernanceABI } from '@celo/contractkit/lib/generated/Governance' -import { ABI as RegistryABI } from '@celo/contractkit/lib/generated/Registry' // tslint:disable: ordered-imports import { getInitializeAbiOfImplementation, @@ -462,8 +462,7 @@ export class InteractiveProposalBuilder { } const contractName = choice as CeloContract - const contractABI = require('@celo/contractkit/lib/generated/' + contractName) - .ABI as ABIDefinition[] + const contractABI = require('@celo/abis/web3/' + contractName).ABI as ABIDefinition[] const txMethods = contractABI.filter( (def) => def.type === 'function' && def.stateMutability !== 'view' diff --git a/packages/sdk/governance/tsconfig.json b/packages/sdk/governance/tsconfig.json index 25d848de425..0d7e3ffd850 100644 --- a/packages/sdk/governance/tsconfig.json +++ b/packages/sdk/governance/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "@celo/typescript/tsconfig.library.json", "compilerOptions": { + "moduleResolution": "node16", "rootDir": "src", "outDir": "lib" }, diff --git a/packages/sdk/transactions-uri/package.json b/packages/sdk/transactions-uri/package.json index a0b5bcac9b2..3734be750a1 100644 --- a/packages/sdk/transactions-uri/package.json +++ b/packages/sdk/transactions-uri/package.json @@ -31,7 +31,7 @@ "web3-eth-abi": "1.10.0" }, "devDependencies": { - "@celo/celo-devchain": "^6.0.3-beta.1", + "@celo/celo-devchain": "^6.0.3", "@celo/dev-utils": "0.0.1", "@celo/contractkit": "^5.2.0", "dotenv": "^8.2.0" diff --git a/packages/typescript/tsconfig.json b/packages/typescript/tsconfig.json index 8d662d06c44..89a1e70dcc6 100644 --- a/packages/typescript/tsconfig.json +++ b/packages/typescript/tsconfig.json @@ -4,14 +4,13 @@ "allowSyntheticDefaultImports": false, "baseUrl": ".", "importHelpers": true, - "jsx": "react", - "lib": ["es7", "esnext", "dom"], - "moduleResolution": "node", + "lib": ["es7", "esnext"], + "moduleResolution": "node16", "noImplicitAny": true, "noUnusedLocals": true, "strictNullChecks": true, "skipLibCheck": true, - "target": "es3", + "target": "es6", "strict": true }, "exclude": ["node_modules"] diff --git a/packages/typescript/tsconfig.library.json b/packages/typescript/tsconfig.library.json index 45376c841f8..713cd7ebf01 100644 --- a/packages/typescript/tsconfig.library.json +++ b/packages/typescript/tsconfig.library.json @@ -1,11 +1,10 @@ { "compileOnSave": false, "compilerOptions": { - "lib": ["dom", "es2015", "es2016"], - "target": "es5", + "lib": ["es2015", "es2016"], + "target": "es6", "module": "commonjs", "moduleResolution": "node", - "jsx": "preserve", "composite": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, diff --git a/yarn.lock b/yarn.lock index b7862e180fd..2c983b957c2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -973,6 +973,11 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@celo/abis@10.0.0": + version "10.0.0" + resolved "https://registry.yarnpkg.com/@celo/abis/-/abis-10.0.0.tgz#2c1002f2e82b29ca22cec70c988bf90d26fadc68" + integrity sha512-DC8UAEz89+1yEQqKzkxOWLYGUv/XWaqPAOkU0lKuQzhvN25ndP3fitawQl53WYn8i3ZPfRWfLO4w75l//tDSbg== + "@celo/base@^5.0.5": version "5.0.5" resolved "https://registry.yarnpkg.com/@celo/base/-/base-5.0.5.tgz#b4102faba080ce536411b7987259d9ca152b6e6d" @@ -986,10 +991,10 @@ "@stablelib/blake2xs" "0.10.4" big-integer "^1.6.44" -"@celo/celo-devchain@^6.0.3-beta.1": - version "6.0.3-beta.1" - resolved "https://registry.yarnpkg.com/@celo/celo-devchain/-/celo-devchain-6.0.3-beta.1.tgz#0c0637c4646904de578fa28ebe2dcb3f8ad35259" - integrity sha512-Pjqbooy1eJ9qyMyIka3GFP0UrLATtSHJtGj/TNtuJ5nlpaBMAy2oA1zjKh0AsqyhvNkjs4Os6mgFYVEm5XuKuw== +"@celo/celo-devchain@^6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@celo/celo-devchain/-/celo-devchain-6.0.3.tgz#ccf1c9c02a1b40ff7b1ab2f180ec5829fb40b2c8" + integrity sha512-k282qgIJzKzTBcBqmarR8pq91SF/G85MuHI7iHEDNYNyHZKrZENjLoQ+V3zoqeLE67NQrVgRYNPGpJ2KCCzB9g== dependencies: commander "^10.0.0" ganache "npm:@celo/ganache@7.8.0-unofficial.0"