Conversation
- Updated `package.json` to use `tsup` for building and added module exports. - Changed TypeScript module resolution to `bundler` and updated module target to `ES2022`. - Introduced `tsup.config.ts` for build configuration.
- Introduced a new constant `CHAIN_IDS` to define common chain IDs for various Celo networks, including CELO_SEPOLIA and ALFAJORES, to facilitate contract client creation.
- Added a new `index.ts` file to define the `createOakContractsClient` function, which supports both simple and full configuration for creating a client instance. - Included utility functions for client configuration and chain resolution, along with type guards for better type safety. - The client allows interaction with various contract entities such as global parameters, campaign info, and treasury factories.
- Expanded `client.ts` with new interfaces for campaign data, payment structures, and treasury configurations to improve type safety and clarity. - Consolidated protocol types in `index.ts` to streamline exports and reduce circular dependencies. - Introduced `SimpleOakContractsClientConfig` and `FullOakContractsClientConfig` for flexible client configuration options.
- Introduced Celo Sepolia testnet to the chain registry, enhancing support for Celo networks. - Updated import paths for `defineChain`, `mainnet`, `sepolia`, and `goerli` to use the new structure from the `viem` package. - Re-exported `CHAIN_IDS` from constants for simplified client configuration.
- Removed the `client.ts` file as part of the restructuring. - Added multiple new contract entities including `AllOrNothing`, `CampaignInfoFactory`, `CampaignInfo`, `GlobalParams`, `ItemRegistry`, `KeepWhatsRaised`, `PaymentTreasury`, and `TreasuryFactory` to enhance functionality and modularity. - Updated `index.ts` to export the new contract entities for easier access. - Improved type safety and clarity in contract interactions by defining specific entity functions for read/write operations.
- Introduced a comprehensive README.md file for the @oaknetwork/contracts package. - Documented installation instructions, quick start guide, client configuration options, supported chain IDs, and detailed contract functionalities. - Enhanced clarity and usability for developers interacting with Oak Network smart contracts.
- Enhanced `AllOrNothing` ABI by adding new functions `cancelTreasury` and `cancelled`, and modified event names and input types for better clarity. - Updated `CampaignInfo` ABI to include the `_cancelCampaign` function and removed outdated ownership transfer events. - Refined `KeepWhatsRaised` ABI by adding `cancelTreasury` and `cancelled` functions, and corrected event names for consistency. - Adjusted `PaymentTreasury` ABI to include an `initialize` function for contract setup. - Cleaned up `GlobalParams` ABI by removing redundant input parameters for error handling functions.
- Updated `getplatformFeePercent` to `getPlatformFeePercent` in both `AllOrNothing` and `KeepWhatsRaised` contracts for consistency and adherence to naming conventions.
- Added multiple error classes for `AllOrNothing`, `CampaignInfo`, `KeepWhatsRaised`, `ItemRegistry`, `PaymentTreasury`, `Shared`, and `TreasuryFactory` to enhance error handling and provide clearer recovery hints. - Updated `index.ts` to export the new error types for better accessibility across the contracts. - Improved type safety and clarity in error management for contract interactions.
- Updated `getplatformFeePercent` to `getPlatformFeePercent` in `AllOrNothingTreasuryEntity` and `KeepWhatsRaisedTreasuryEntity` interfaces for consistency and adherence to naming conventions.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b705617608
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| account: privateKey as `0x${string}`, | ||
| chain: provider.chain, |
There was a problem hiding this comment.
Derive wallet account from private key before client creation
The createWallet helper passes the raw private key string as account to createWalletClient, but viem expects an account object (e.g. from privateKeyToAccount) or an address for JSON-RPC signing. With a private key string here, calls that rely on this helper can’t reliably sign transactions locally and may attempt to use the 32-byte key as a sender address, so write operations fail at runtime for the advertised private-key flow.
Useful? React with 👍 / 👎.
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "type": "module", |
There was a problem hiding this comment.
Keep Jest config loadable after switching package to ESM
Setting "type": "module" makes jest.config.js execute as an ES module, but that config file still uses module.exports; this throws ReferenceError: module is not defined before tests even start (reproducible by running node packages/contracts/jest.config.js). As a result, the package test script is broken in this commit unless the config is migrated to ESM syntax or renamed to .cjs.
Useful? React with 👍 / 👎.
| * ALFAJORES is the legacy Celo testnet (44787); use CELO_SEPOLIA for new development. | ||
| */ | ||
| export const CHAIN_IDS = { | ||
| MAINNET: 1, |
There was a problem hiding this comment.
We should explicitly define the chain name and its type. For example:
CELO_MAINNET, ETHEREUM_MAINNET, CELO_SEPOLIA_TESTNET, ETHEREUM_SEPOLIA_TESTNET.
The type of the chain should be either in prefix or suffix.
Also, CELO_MAINNET: 42220 is not added here
There was a problem hiding this comment.
The functions associated with Protocol Admins -- keeping some functions won't harm but critical ones enlistPlatform delistPlatform updateProtocolFeePercent and other functions might be confusing for the general platform devs, as they would never use these. Better to remove them.
There was a problem hiding this comment.
I think it should have some of the extended functions of Ownable module too. For example minter_role - because its the only way to check (in contract call) the valid treasury address
There was a problem hiding this comment.
I think it should have the general NFT view functions ?
Introduces the Oak Contracts SDK (
@oaknetwork/contracts): a client for interacting with Oak Network smart contracts (treasuries, campaign info, global params, etc.) with typed APIs, chain support, and structured error handling.What's included
Package & build
tsup.config.ts.bundler, targetES2022, and proper module exports inpackage.json.Client & configuration
createOakContractsClientinindex.tswith:CHAIN_IDSfor Celo networks (e.g. CELO_SEPOLIA, ALFAJORES); Celo Sepolia added to chain registry; viem imports updated for current structure.Contract entities
initialize.Types
SimpleOakContractsClientConfig,FullOakContractsClientConfig.index.tsto avoid circular deps.ABIs
cancelTreasury,cancelled, and event name/input updates._cancelCampaign; removed obsolete ownership transfer events.initialize.Error handling
Documentation
@oaknetwork/contracts: installation, quick start, client config, supported chain IDs, and contract usage.