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

CR10 npm package release script #10809

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
89 changes: 89 additions & 0 deletions .github/workflows/publish-contracts-abi-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Publish ABIs and Solidity files to NPM
on:
push:
branches: [main]
pull_request:

release:
types: [released]
workflow_dispatch:
inputs:
npm_version:
description: 'NPM version'
required: true
type: string
jobs:
publish:
runs-on: ['self-hosted', 'org', 'npm-publish']
permissions:
contents: write
id-token: write
pull-requests: 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
with:
api-url: https://api.gateway.akeyless.celo-networks-dev.org
access-id: p-kf9vjzruht6l
static-secrets: '{"/static-secrets/NPM/npm-publish-token":"NPM_TOKEN"}'

# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
#scope: '@celo'

- name: 'Setup yarn'
shell: bash
run: |
npm install --global yarn
source ~/.bashrc

- name: 'Install packages'
shell: bash
run: yarn

- 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
env:
RELEASE_TYPE: ${{ env.RELEASE_TYPE }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}

- name: Publish @celo/contracts
run: |
cat package.json
npm publish $RELEASE_TYPE $DRY_RUN
working-directory: packages/protocol/contracts
env:
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: |
cat package.json
npm publish $RELEASE_TYPE $DRY_RUN
working-directory: packages/protocol/abis
env:
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 .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
pull-requests: write

steps:
- uses: actions/stale@v3
- uses: actions/stale@v8
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale and will be closed in 30 days without activity'
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "packages/protocol/lib/celo-foundry"]
path = packages/protocol/lib/celo-foundry
url = https://github.com/bowd/celo-foundry
url = https://github.com/celo-org/celo-foundry
[submodule "packages/protocol/lib/solidity-bytes-utils"]
path = packages/protocol/lib/solidity-bytes-utils
url = https://github.com/GNSPS/solidity-bytes-utils
Expand All @@ -10,6 +10,6 @@
[submodule "packages/protocol/lib/mento-core"]
path = packages/protocol/lib/mento-core
url = https://github.com/mento-protocol/mento-core
[submodule "lib/memview.sol"]
[submodule "packages/protocol/lib/memview.sol"]
path = packages/protocol/lib/memview.sol
url = https://github.com/summa-tx/memview.sol
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
5 changes: 2 additions & 3 deletions dependency-graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@
"@celo/base",
"@celo/connect",
"@celo/cryptographic-utils",
"@celo/flake-tracker",
"@celo/phone-utils",
"@celo/typescript",
"@celo/utils"
"@celo/utils",
"@celo/wallet-local"
]
},
"@celo/typescript": {
Expand Down
4 changes: 2 additions & 2 deletions 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/contractkit/lib/generated/IERC20'
import { Erc20Wrapper } from '@celo/contractkit/lib/wrappers/Erc20Wrapper'
import { flags } from '@oclif/command'
import BigNumber from 'bignumber.js'
Expand Down Expand Up @@ -42,7 +42,7 @@ export default class TransferErc20 extends BaseCommand {
const value = new BigNumber(res.flags.value)

this.kit.defaultAccount = from
let celoToken: Erc20Wrapper<Ierc20>
let celoToken: Erc20Wrapper<IERC20>
try {
celoToken = await this.kit.contracts.getErc20(res.flags.erc20Address)
// this call allow us to check if it is a valid erc20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Kit ContractWrappers factory & cache.

Provides access to all contract wrappers for celo core contracts

**`remarks`**
**`remarks`**

Because it provides access to all contract wrappers it must load all wrappers and the contract ABIs for them
Consider Using {@link MiniWrapperCache}, building your own, or if you only need one Wrapper using it directly
Expand Down Expand Up @@ -200,7 +200,7 @@ ___

### getErc20

▸ **getErc20**(`address`: string): *Promise‹[Erc20Wrapper](_wrappers_erc20wrapper_.erc20wrapper.md)‹Ierc20‹›››*
▸ **getErc20**(`address`: string): *Promise‹[Erc20Wrapper](_wrappers_erc20wrapper_.erc20wrapper.md)‹IERC20‹›››*

*Defined in [packages/sdk/contractkit/src/contract-cache.ts:154](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/contract-cache.ts#L154)*

Expand All @@ -210,7 +210,7 @@ Name | Type |
------ | ------ |
`address` | string |

**Returns:** *Promise‹[Erc20Wrapper](_wrappers_erc20wrapper_.erc20wrapper.md)‹Ierc20‹›››*
**Returns:** *Promise‹[Erc20Wrapper](_wrappers_erc20wrapper_.erc20wrapper.md)‹IERC20‹›››*

___

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ ___

### getErc20

▸ **getErc20**(`address`: string): *Promise‹Ierc20‹››*
▸ **getErc20**(`address`: string): *Promise‹IERC20‹››*

*Defined in [packages/sdk/contractkit/src/web3-contract-cache.ts:120](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/web3-contract-cache.ts#L120)*

Expand All @@ -188,7 +188,7 @@ Name | Type |
------ | ------ |
`address` | string |

**Returns:** *Promise‹Ierc20‹››*
**Returns:** *Promise‹IERC20‹››*

___

Expand All @@ -204,7 +204,7 @@ ___

### getExchange

▸ **getExchange**(`stableToken`: [StableToken](../enums/_base_.celocontract.md#stabletoken)): *Promise‹Registry‹› | Accounts‹› | Exchange‹› | Ierc20‹› | GoldToken‹› | StableToken‹› | Attestations‹› | BlockchainParameters‹› | DoubleSigningSlasher‹› | DowntimeSlasher‹› | Election‹› | EpochRewards‹› | Escrow‹› | ExchangeEur‹› | ExchangeBrl‹› | FeeCurrencyWhitelist‹› | Freezer‹› | GasPriceMinimum‹› | Governance‹› | GrandaMento‹› | LockedGold‹› | MetaTransactionWallet‹› | MetaTransactionWalletDeployer‹› | MultiSig‹› | Random‹› | Reserve‹› | SortedOracles‹› | TransferWhitelist‹› | Validators‹››*
▸ **getExchange**(`stableToken`: [StableToken](../enums/_base_.celocontract.md#stabletoken)): *Promise‹Registry‹› | Accounts‹› | Exchange‹› | IERC20‹› | GoldToken‹› | StableToken‹› | Attestations‹› | BlockchainParameters‹› | DoubleSigningSlasher‹› | DowntimeSlasher‹› | Election‹› | EpochRewards‹› | Escrow‹› | ExchangeEur‹› | ExchangeBrl‹› | FeeCurrencyWhitelist‹› | Freezer‹› | GasPriceMinimum‹› | Governance‹› | GrandaMento‹› | LockedGold‹› | MetaTransactionWallet‹› | MetaTransactionWalletDeployer‹› | MultiSig‹› | Random‹› | Reserve‹› | SortedOracles‹› | TransferWhitelist‹› | Validators‹››*

*Defined in [packages/sdk/contractkit/src/web3-contract-cache.ts:126](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/web3-contract-cache.ts#L126)*

Expand All @@ -214,7 +214,7 @@ Name | Type | Default |
------ | ------ | ------ |
`stableToken` | [StableToken](../enums/_base_.celocontract.md#stabletoken) | StableToken.cUSD |

**Returns:** *Promise‹Registry‹› | Accounts‹› | Exchange‹› | Ierc20‹› | GoldToken‹› | StableToken‹› | Attestations‹› | BlockchainParameters‹› | DoubleSigningSlasher‹› | DowntimeSlasher‹› | Election‹› | EpochRewards‹› | Escrow‹› | ExchangeEur‹› | ExchangeBrl‹› | FeeCurrencyWhitelist‹› | Freezer‹› | GasPriceMinimum‹› | Governance‹› | GrandaMento‹› | LockedGold‹› | MetaTransactionWallet‹› | MetaTransactionWalletDeployer‹› | MultiSig‹› | Random‹› | Reserve‹› | SortedOracles‹› | TransferWhitelist‹› | Validators‹››*
**Returns:** *Promise‹Registry‹› | Accounts‹› | Exchange‹› | IERC20‹› | GoldToken‹› | StableToken‹› | Attestations‹› | BlockchainParameters‹› | DoubleSigningSlasher‹› | DowntimeSlasher‹› | Election‹› | EpochRewards‹› | Escrow‹› | ExchangeEur‹› | ExchangeBrl‹› | FeeCurrencyWhitelist‹› | Freezer‹› | GasPriceMinimum‹› | Governance‹› | GrandaMento‹› | LockedGold‹› | MetaTransactionWallet‹› | MetaTransactionWalletDeployer‹› | MultiSig‹› | Random‹› | Reserve‹› | SortedOracles‹› | TransferWhitelist‹› | Validators‹››*

___

Expand Down Expand Up @@ -378,7 +378,7 @@ ___

### getStableToken

▸ **getStableToken**(`stableToken`: [StableToken](../enums/_base_.celocontract.md#stabletoken)): *Promise‹Registry‹› | Accounts‹› | Exchange‹› | Ierc20‹› | GoldToken‹› | StableToken‹› | Attestations‹› | BlockchainParameters‹› | DoubleSigningSlasher‹› | DowntimeSlasher‹› | Election‹› | EpochRewards‹› | Escrow‹› | ExchangeEur‹› | ExchangeBrl‹› | FeeCurrencyWhitelist‹› | Freezer‹› | GasPriceMinimum‹› | Governance‹› | GrandaMento‹› | LockedGold‹› | MetaTransactionWallet‹› | MetaTransactionWalletDeployer‹› | MultiSig‹› | Random‹› | Reserve‹› | SortedOracles‹› | TransferWhitelist‹› | Validators‹››*
▸ **getStableToken**(`stableToken`: [StableToken](../enums/_base_.celocontract.md#stabletoken)): *Promise‹Registry‹› | Accounts‹› | Exchange‹› | IERC20‹› | GoldToken‹› | StableToken‹› | Attestations‹› | BlockchainParameters‹› | DoubleSigningSlasher‹› | DowntimeSlasher‹› | Election‹› | EpochRewards‹› | Escrow‹› | ExchangeEur‹› | ExchangeBrl‹› | FeeCurrencyWhitelist‹› | Freezer‹› | GasPriceMinimum‹› | Governance‹› | GrandaMento‹› | LockedGold‹› | MetaTransactionWallet‹› | MetaTransactionWalletDeployer‹› | MultiSig‹› | Random‹› | Reserve‹› | SortedOracles‹› | TransferWhitelist‹› | Validators‹››*

*Defined in [packages/sdk/contractkit/src/web3-contract-cache.ts:171](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/web3-contract-cache.ts#L171)*

Expand All @@ -388,7 +388,7 @@ Name | Type | Default |
------ | ------ | ------ |
`stableToken` | [StableToken](../enums/_base_.celocontract.md#stabletoken) | StableToken.cUSD |

**Returns:** *Promise‹Registry‹› | Accounts‹› | Exchange‹› | Ierc20‹› | GoldToken‹› | StableToken‹› | Attestations‹› | BlockchainParameters‹› | DoubleSigningSlasher‹› | DowntimeSlasher‹› | Election‹› | EpochRewards‹› | Escrow‹› | ExchangeEur‹› | ExchangeBrl‹› | FeeCurrencyWhitelist‹› | Freezer‹› | GasPriceMinimum‹› | Governance‹› | GrandaMento‹› | LockedGold‹› | MetaTransactionWallet‹› | MetaTransactionWalletDeployer‹› | MultiSig‹› | Random‹› | Reserve‹› | SortedOracles‹› | TransferWhitelist‹› | Validators‹››*
**Returns:** *Promise‹Registry‹› | Accounts‹› | Exchange‹› | IERC20‹› | GoldToken‹› | StableToken‹› | Attestations‹› | BlockchainParameters‹› | DoubleSigningSlasher‹› | DowntimeSlasher‹› | Election‹› | EpochRewards‹› | Escrow‹› | ExchangeEur‹› | ExchangeBrl‹› | FeeCurrencyWhitelist‹› | Freezer‹› | GasPriceMinimum‹› | Governance‹› | GrandaMento‹› | LockedGold‹› | MetaTransactionWallet‹› | MetaTransactionWalletDeployer‹› | MultiSig‹› | Random‹› | Reserve‹› | SortedOracles‹› | TransferWhitelist‹› | Validators‹››*

___

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Contract for Celo native currency that adheres to the ICeloToken and IERC20 inte

## Type parameters

▪ **T**: *Ierc20 & ICeloToken*
▪ **T**: *IERC20 & ICeloToken*

## Hierarchy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ERC-20 contract only containing the non-optional functions

## Type parameters

▪ **T**: *Ierc20*
▪ **T**: *IERC20*

## Hierarchy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

### [CeloContract.ERC20]

• **[CeloContract.ERC20]**: *newIerc20* = newIerc20
• **[CeloContract.ERC20]**: *newIERC20* = newIERC20

*Defined in [packages/sdk/contractkit/src/web3-contract-cache.ts:46](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/web3-contract-cache.ts#L46)*

Expand All @@ -88,13 +88,13 @@

### [CeloContract.ExchangeBRL]

• **[CeloContract.ExchangeBRL]**: *newExchangeBrl* = newExchangeBrl
• **[CeloContract.ExchangeBRL]**: *newExchangeBRL* = newExchangeBRL

*Defined in [packages/sdk/contractkit/src/web3-contract-cache.ts:50](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/web3-contract-cache.ts#L50)*

### [CeloContract.ExchangeEUR]

• **[CeloContract.ExchangeEUR]**: *newExchangeEur* = newExchangeEur
• **[CeloContract.ExchangeEUR]**: *newExchangeEUR* = newExchangeEUR

*Defined in [packages/sdk/contractkit/src/web3-contract-cache.ts:49](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/contractkit/src/web3-contract-cache.ts#L49)*

Expand Down
7 changes: 7 additions & 0 deletions packages/protocol/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ deployedGrants.json
cache/
out/

wagmi.config.js
wagmi.config.js.map

abis/src-generated/
abis/lib/
# these are copied from contracts-08 folder for purposes of publishing to npm
contracts/0.8
51 changes: 51 additions & 0 deletions packages/protocol/abis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Celo core contracts ABIS

Smart contracts ABIS for the Celo protocol.

## Usage

### Installation

```bash
npm install @celo/abis
```

or

```bash
yarn add @celo/abis
```

### In your javascript or ts

```ts
// abi in json
import AccountsABI from '@celo/abis/Accounts.json'

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

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

// 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