Skip to content

Commit

Permalink
Merge branch 'shazarre/contractkit_use_celo_abis_package' into therea…
Browse files Browse the repository at this point in the history
…lharpaljadeja/celo-abi-node-env-example
  • Loading branch information
aaronmgdr authored Dec 6, 2023
2 parents 84d1ed0 + 3ab415a commit 23a5fb7
Show file tree
Hide file tree
Showing 97 changed files with 3,263 additions and 2,326 deletions.
10 changes: 10 additions & 0 deletions .changeset/cool-waves-switch.md
Original file line number Diff line number Diff line change
@@ -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/`
5 changes: 0 additions & 5 deletions .changeset/gold-crabs-carry.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/rotten-weeks-sip.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/strange-eels-live.md

This file was deleted.

5 changes: 1 addition & 4 deletions .github/workflows/celo-monorepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<<EOF" >> $GITHUB_OUTPUT
echo "$artifacts_to_cache" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -279,9 +279,6 @@ jobs:
- name: Protocol Governance Voting
command: |
yarn --cwd packages/protocol test governance/voting/
- name: Protocol Identity
command: |
yarn --cwd packages/protocol test identity/
- name: Protocol Stability
command: |
yarn --cwd packages/protocol test stability/
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/protocol_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@ jobs:
- name: Install forge dependencies
run: forge install

# "Run tests" already tries to compile the contracts
# Making it explicit here to have easier to read errors
- name: Compile Contracts
run: forge compile

- name: Run tests
run: forge test -vvv
run: forge test -vvv
24 changes: 15 additions & 9 deletions .github/workflows/publish-contracts-abi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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' || '' }}
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions packages/celotool/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" }]
}
10 changes: 10 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 3.1.1

### Patch Changes

- 6ff7f4a1e: network:contracts command fix added StableTokens to unversioned contracts list
- Updated dependencies [88e3788b8]
- Updated dependencies [70f600bb0]
- Updated dependencies [2985f9eb2]
- @celo/contractkit@5.2.1

## 3.1.0

### Minor Changes
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@celo/celocli",
"description": "CLI Tool for transacting with the Celo protocol",
"version": "3.1.0",
"version": "3.1.1",
"author": "Celo",
"license": "Apache-2.0",
"repository": "celo-org/celo-monorepo",
Expand Down Expand Up @@ -30,10 +30,10 @@
"test": "TZ=UTC jest --runInBand"
},
"dependencies": {
"@celo/abis": "10.0.0-rc.2",
"@celo/base": "^6.0.0",
"@celo/celo-devchain": "^6.0.3-beta.1",
"@celo/connect": "^5.1.1",
"@celo/contractkit": "^5.2.0",
"@celo/contractkit": "^5.2.1",
"@celo/explorer": "^5.0.6",
"@celo/governance": "^5.0.6",
"@celo/identity": "^5.1.1",
Expand Down Expand Up @@ -73,6 +73,7 @@
"web3": "1.10.0"
},
"devDependencies": {
"@celo/celo-devchain": "^6.0.3-beta.1",
"@celo/dev-utils": "0.0.1",
"@oclif/dev-cli": "^1.23.0",
"@types/cli-table": "^0.3.0",
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/commands/network/contracts.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -10,6 +10,9 @@ const UNVERSIONED_CONTRACTS = [
CeloContract.Registry,
CeloContract.FeeCurrencyWhitelist,
CeloContract.Freezer,
CeloContract.StableToken,
CeloContract.StableTokenBRL,
CeloContract.StableTokenEUR,
]
const UNPROXIED_CONTRACTS: CeloContract[] = []

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/releasegold/admin-revoke.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/releasegold/withdraw.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/transfer/erc20.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/release-gold-base.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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" }]
Expand Down
29 changes: 14 additions & 15 deletions packages/protocol/abis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,36 @@ or
yarn add @celo/abis
```

### JS/TS syntax

**There is no index so the following do not work**
`import abis from '@celo/abis'` or ` import web3AbiTypes from '@celo/abis/web3'`

### 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'

// viem
import { accountsABI } from "@celo/abis/types/wagmi";

// ethers
import { Accounts } from '@celo/abis/types/ethers'
// abi in js/ts for viem, wagmi, etc
import { accountsABI } from '@celo/abis/Accounts'

// abi in js/ts for use with contractkit
import { type Accounts, newAccounts, ABI } from '@celo/abis/web3/Accounts'

// web3
import Accounts from '@celo/abis/types/web3/Accounts'

// truffle
import { AccountsContract } from '@celo/abis/types/truffle'
```

### CommonJS syntax

```js
const Accounts = require("@celo/abis/Accounts.json");
const AccountsABI = require("@celo/abis/Accounts.json");

// ethers
const accounts = new ethers.Contract("0x...", Accounts.abi, ...);

// viem
const accounts = getContract({
address: "0x...",
abi: Accounts.abi,
abi: AccountsABI,
...
})
```
Expand Down
3 changes: 3 additions & 0 deletions packages/protocol/abis/package-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
3 changes: 3 additions & 0 deletions packages/protocol/abis/package-esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Loading

0 comments on commit 23a5fb7

Please sign in to comment.