Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contractkit: use @celo/abis package #10791

Merged
merged 77 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
bd843b7
revert ESM/CJS compilation, use previous directory structure
shazarre Nov 28, 2023
9c32883
merge web3/* folders into one as well
shazarre Nov 28, 2023
5a6333d
change working dir to packages/protocol/abis/src-generated
shazarre Nov 28, 2023
123fffe
include interfaces
shazarre Nov 28, 2023
0bb93ba
prepare contracts package.json
shazarre Nov 29, 2023
fa8813a
fix package.json not exisiting for @celo/abis package
shazarre Nov 29, 2023
286e7fa
fix npm tagging, and a spelling issue
aaronmgdr Nov 29, 2023
a660324
leave nested dirs in web3/ generated folder
shazarre Nov 29, 2023
38f8249
Merge branch 'shazarre/contractkit_use_celo_abis_package' of github.c…
shazarre Nov 29, 2023
2a46bb0
fix #10564 warning
aaronmgdr Nov 29, 2023
55054ff
fix #10564 warning
aaronmgdr Nov 29, 2023
9729338
add @celo/abis usage and change imports
shazarre Nov 29, 2023
8ff9d81
Merge branch 'shazarre/contractkit_use_celo_abis_package' of github.c…
shazarre Nov 29, 2023
404c55f
change @celo/abis to be a regular dependency instead of a dev one
shazarre Nov 29, 2023
d24e275
remove extraneous fields from generated jsons
shazarre Nov 29, 2023
550caf4
missing yarn.lock + bump up @celo/abis
shazarre Nov 29, 2023
8d341ab
no longer need build:gen as the contract interfaces come from celo/ab…
aaronmgdr Nov 30, 2023
90a16c9
esm/cjs compilation
shazarre Nov 30, 2023
3df7eb4
missed changed imports
shazarre Nov 30, 2023
e6dbff1
contract cache: use @celo/abis package
shazarre Nov 30, 2023
8a6311f
proxy: use @celo/abis package
shazarre Nov 30, 2023
ed89d65
mini contract cache: use @celo/abis package
shazarre Nov 30, 2023
11a0506
contract cache: use @celo/abis package
shazarre Nov 30, 2023
8e1f35c
replace all other usages of ./generated
shazarre Nov 30, 2023
698e725
fix other places import must change and add changeset
aaronmgdr Nov 30, 2023
cb1f383
use @celo/abis/types/web3 instead of generated/
shazarre Nov 30, 2023
d5f2dad
bump up @celo/abis version
shazarre Nov 30, 2023
ba7ca78
abis are imported to these packages
aaronmgdr Nov 30, 2023
e5dc220
must set moduleResolution to node16,
aaronmgdr Dec 1, 2023
72ccaea
keep declarations separate
aaronmgdr Dec 1, 2023
1666b01
yolo
aaronmgdr Dec 1, 2023
2737ba0
two experiments,
aaronmgdr Dec 1, 2023
6fe6b5d
we dont need to change target as it already set.
aaronmgdr Dec 1, 2023
e4fd383
may it be so
aaronmgdr Dec 1, 2023
bf6c32b
must run packages protocol needs, then prepare abis, then contractkit ++
aaronmgdr Dec 1, 2023
a23eaa3
dont need to cache these
aaronmgdr Dec 1, 2023
2359a56
order imports, and fix esModuleInterpo issue
aaronmgdr Dec 1, 2023
f48a933
fix linting errors
shazarre Dec 1, 2023
26f8fab
fix failure made noticable by test
aaronmgdr Dec 1, 2023
cf53346
lint cli
aaronmgdr Dec 1, 2023
4115f38
Merge branch 'master' into shazarre/contractkit_use_celo_abis_package
aaronmgdr Dec 4, 2023
ba46338
fix ledger connection
aaronmgdr Dec 4, 2023
36952d8
clean up ts configs
aaronmgdr Dec 4, 2023
540a033
target must be es5 for tests but es2020 for export
aaronmgdr Dec 4, 2023
b501100
es5 is a must
aaronmgdr Dec 4, 2023
bc8c20e
remove types/ prefix
shazarre Dec 4, 2023
f53db38
change imports
shazarre Dec 4, 2023
bb9eabf
comment out temporarily
shazarre Dec 4, 2023
fcd07df
Merge branch 'master' into shazarre/contractkit_use_celo_abis_package
shazarre Dec 4, 2023
b347833
is this the changed file? + uncomment
shazarre Dec 4, 2023
5390850
Merge branch 'shazarre/contractkit_use_celo_abis_package' of github.c…
shazarre Dec 4, 2023
c94f514
add packages/protocol/abis/src-generated/ to .prettierignore
shazarre Dec 4, 2023
8d046fd
lint fix
shazarre Dec 4, 2023
818d0c6
remove ethers specific files generation
shazarre Dec 5, 2023
93c2c1d
esm should be esm
aaronmgdr Dec 5, 2023
a7977ea
better changeset
aaronmgdr Dec 5, 2023
1ed4041
use rc of abi
aaronmgdr Dec 5, 2023
1f36681
shhhh - we are already not expecting this to be working on current ve…
aaronmgdr Dec 5, 2023
c01197d
exclude source maps
aaronmgdr Dec 6, 2023
a50a543
generate ts files at top level
aaronmgdr Dec 6, 2023
3ab415a
fix the readme and undo some temp stuff
aaronmgdr Dec 6, 2023
9589d1c
feat(@celo/abis): add Node env usage (#10797)
therealharpaljadeja Dec 6, 2023
54f2544
use latest versions
aaronmgdr Dec 6, 2023
a9dd84a
fix mento tokens missing from the abis , add index.js
aaronmgdr Dec 7, 2023
30d8537
dont publish contract tests
aaronmgdr Dec 7, 2023
0387043
need actual file location
aaronmgdr Dec 7, 2023
c2667b7
give esm consumers a index entry
aaronmgdr Dec 7, 2023
945b7d8
update READMEs
shazarre Dec 7, 2023
aa7a9f6
Merge branch 'shazarre/contractkit_use_celo_abis_package' of github.c…
shazarre Dec 7, 2023
6fc66cf
rc 4
aaronmgdr Dec 7, 2023
789a89e
update yarn.lock
shazarre Dec 7, 2023
2c854a5
ignore
aaronmgdr Dec 7, 2023
e3f3452
copy 0.8 contracts to the package
shazarre Dec 7, 2023
04e8b44
Merge branch 'shazarre/contractkit_use_celo_abis_package' of github.c…
shazarre Dec 7, 2023
6809f28
missed consts file
shazarre Dec 7, 2023
ad2efb5
@celo/abis: rc4 -> rc5
shazarre Dec 7, 2023
a0dd38e
gold master
aaronmgdr Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/`
2 changes: 1 addition & 1 deletion .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
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" }]
}
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
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
4 changes: 2 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 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
4 changes: 3 additions & 1 deletion packages/protocol/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ wagmi.config.js
wagmi.config.js.map

abis/src-generated/
abis/lib/
abis/lib/
# these are copied from contracts-08 folder for purposes of publishing to npm
contracts/0.8
30 changes: 22 additions & 8 deletions packages/protocol/abis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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
Loading