Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/fix-ledger-console-noise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/wallet-ledger': patch
---

Replace `console.info` with `debug` for derivation path logging to avoid noisy test output
5 changes: 5 additions & 0 deletions .changeset/remove-delegate-debug-logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/celocli': patch
---

Remove debug console.log statements from lockedcelo:delegate command that were leaking internal values to stdout
17 changes: 17 additions & 0 deletions .changeset/remove-rpc-contract-promievent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@celo/connect': major
'@celo/contractkit': minor
'@celo/celocli': minor
'@celo/dev-utils': minor
---

**Remove rpc-contract.ts, PromiEvent, and legacy Contract interface from @celo/connect**

- Deleted `rpc-contract.ts`, `promi-event.ts`, and `viem-contract.ts` — replaced with native viem `getContract()` / `GetContractReturnType`
- `CeloTxObject.send()` now returns `Promise<string>` (tx hash) instead of `PromiEvent<CeloTxReceipt>`
- Removed `Connection.createContract()` — use `Connection.getCeloContract()` instead
- Removed `PromiEvent<T>` and `Contract` interfaces from types
- `Connection.getViemContract()` deprecated — delegates to `getCeloContract()`
- `ViemContract<TAbi>` deprecated — use `CeloContract<TAbi>` (viem's `GetContractReturnType`)
- Contract deployment rewritten to use viem's `encodeDeployData` + `connection.sendTransaction()`
- All contractkit wrappers, CLI commands, and test files updated
10 changes: 10 additions & 0 deletions .changeset/remove-web3-shim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@celo/connect': major
'@celo/contractkit': major
'@celo/celocli': major
'@celo/explorer': patch
'@celo/governance': patch
'@celo/dev-utils': patch
---

Remove Web3 shim from Connection and migrate contractkit to use viem ABIs with Connection.createContract(). Add backward-compatible kit.web3 shim (deprecated). Add newKitFromProvider() factory function.
5 changes: 5 additions & 0 deletions .changeset/strong-typing-contractkit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/contractkit': minor
---

**Improved type safety**: Added explicit type annotations to all wrapper methods that previously emitted `CeloTransactionObject<any>` or `Promise<any>` in their declaration files. All `proxySend` and `proxyCall` usages now have explicit return types, eliminating approximately 110 instances of `any` in the public API surface. This provides better IDE autocompletion and compile-time type checking for consumers of `@celo/contractkit`.
15 changes: 15 additions & 0 deletions .changeset/viem-native-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@celo/connect': minor
'@celo/contractkit': minor
'@celo/explorer': patch
---

**Migrate internal contract interaction from web3-style RPC Contract to viem-native ViemContract**

- Added `ViemContract` type and `createViemTxObject()` function in `@celo/connect`
- Added `Connection.getViemContract()` factory method
- Updated all 36 ContractKit wrappers to use viem-native contract interaction
- Updated `proxyCall`/`proxySend` to accept `ViemContract` + function name strings
- Migrated CLI commands, dev-utils, and explorer to use new API
- Deprecated `Connection.createContract()` (kept for backward compatibility with `.deploy()`)
- Public API unchanged: `CeloTransactionObject`, wrapper method signatures remain the same
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/index.js b/index.js
index 5462c1f830bdbe79bf2b1fcfd811cd9799b4dd11..e8fe7e61083d95714bba6f2d4544d0426749a64f 100644
--- a/index.js
+++ b/index.js
@@ -28,14 +28,19 @@ function bufferEq(a, b) {
}

bufferEq.install = function() {
- Buffer.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
+ Buffer.prototype.equal = function equal(that) {
return bufferEq(this, that);
};
+ if (SlowBuffer) {
+ SlowBuffer.prototype.equal = Buffer.prototype.equal;
+ }
};

var origBufEqual = Buffer.prototype.equal;
-var origSlowBufEqual = SlowBuffer.prototype.equal;
+var origSlowBufEqual = SlowBuffer ? SlowBuffer.prototype.equal : undefined;
bufferEq.restore = function() {
Buffer.prototype.equal = origBufEqual;
- SlowBuffer.prototype.equal = origSlowBufEqual;
+ if (SlowBuffer && origSlowBufEqual) {
+ SlowBuffer.prototype.equal = origSlowBufEqual;
+ }
};
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@
"typescript": "5.3.3"
},
"resolutions": {
"web3": "1.10.4",
"web3-utils": "1.10.4",
"blind-threshold-bls": "npm:@celo/blind-threshold-bls@1.0.0-beta",
"@types/bn.js": "4.11.6",
"bignumber.js": "9.0.0"
"bignumber.js": "9.0.0",
"buffer-equal-constant-time@npm:1.0.1": "patch:buffer-equal-constant-time@npm%3A1.0.1#~/.yarn/patches/buffer-equal-constant-time-npm-1.0.1-41826f3419.patch"
},
"dependencies": {
"@changesets/cli": "^2.29.5"
Expand Down
1 change: 1 addition & 0 deletions packages/actions/tsconfig-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"rootDir": "src",
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"types": ["node"],
"lib": ["esnext"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"address": "0x4200000000000000000000000000000000000018",
"function": "setValue(uint256,uint256,bool)",
"args": ["3", "4", true],
"value": 0
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"address": "0x4200000000000000000000000000000000000018",
"function": "setValue(uint256,uint256,bool)",
"args": ["3", "4", true],
"value": 0
}
]
9 changes: 5 additions & 4 deletions packages/sdk/connect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ Please use GitHub to:
### Basic

```typescript
import { Connection, CeloProvider } from '@celo/connect'
import { Connection } from '@celo/connect'

const web3 = new Web3("YOUR_RPC_URL")
const connection = new Connection(web3)
const connection = new Connection('YOUR_RPC_URL')
```

For a raw transaction:

```ts
const oneCelo = connection.web3.utils.toWei('1', 'ether')
import { parseEther } from 'viem'

const oneCelo = parseEther('1')

const tx = connection.sendTransaction({
from: myAddress,
Expand Down
16 changes: 2 additions & 14 deletions packages/sdk/connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,15 @@
"dependencies": {
"@celo/base": "^7.0.3",
"@celo/utils": "^8.0.3",
"@ethereumjs/util": "8.0.5",
"@types/debug": "^4.1.5",
"@types/utf8": "^2.1.6",
"bignumber.js": "^9.0.0",
"debug": "^4.1.1",
"utf8": "3.0.0",
"web3-core": "1.10.4",
"web3-eth": "1.10.4",
"web3-eth-contract": "1.10.4"
"viem": "^2.33.2"
},
"devDependencies": {
"@celo/typescript": "workspace:^",
"@types/debug": "^4.1.12",
"web3": "1.10.4",
"web3-core": "1.10.4",
"web3-eth": "1.10.4",
"web3-eth-abi": "1.10.4",
"web3-eth-contract": "1.10.4"
},
"peerDependencies": {
"web3": "1.10.4"
"@types/debug": "^4.1.12"
},
"engines": {
"node": ">=20"
Expand Down
63 changes: 18 additions & 45 deletions packages/sdk/connect/src/abi-types.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,41 @@
import { EventLog } from './types'
import type { AbiParameter } from 'viem'

/** @internal */
export type ABIType = 'uint256' | 'boolean' | 'string' | 'bytes' | string // TODO complete list
/** @internal - Matches viem's AbiParameter, extended with indexed for event inputs */
export type AbiInput = AbiParameter & { indexed?: boolean }
/** @internal - Matches viem's AbiParameter */
export type AbiOutput = AbiParameter

/** @internal */
export interface DecodedParamsArray {
[index: number]: any
__length__: number
}

/** @internal */
export interface DecodedParamsObject extends DecodedParamsArray {
[key: string]: any
}

// Note the following types come from web3-utils: AbiInput, AbiOutput, AbiItem, AbiType StateMutabilityType, ABIDefinition
type AbiType = 'function' | 'constructor' | 'event' | 'fallback'
type StateMutabilityType = 'pure' | 'view' | 'nonpayable' | 'payable'

/** @internal */
export interface AbiInput {
name: string
type: string
indexed?: boolean
components?: AbiInput[]
internalType?: string
}

/** @internal */
export interface AbiOutput {
name: string
type: string
components?: AbiOutput[]
internalType?: string
}
/** @internal */
export interface AbiItem {
anonymous?: boolean
constant?: boolean
inputs?: AbiInput[]
inputs?: readonly AbiInput[]
name?: string
outputs?: AbiOutput[]
outputs?: readonly AbiOutput[]
payable?: boolean
stateMutability?: StateMutabilityType
type: AbiType
gas?: number
}

/** @internal */
export interface ABIDefinition extends AbiItem {
signature: string
}
/** @internal */
export interface AbiCoder {
decodeLog(inputs: AbiInput[], hexString: string, topics: string[]): EventLog

encodeParameter(type: ABIType, parameter: any): string
encodeParameters(types: ABIType[], paramaters: any[]): string

encodeEventSignature(name: string | object): string
encodeFunctionCall(jsonInterface: object, parameters: any[]): string
encodeFunctionSignature(name: string | object): string
/** @internal */
export type ABIType = string

decodeParameter(type: ABIType, hex: string): any
/** @internal */
export interface DecodedParamsArray {
[index: number]: unknown
__length__: number
}

decodeParameters(types: ABIType[], hex: string): DecodedParamsArray
decodeParameters(types: AbiInput[], hex: string): DecodedParamsObject
/** @internal */
export interface DecodedParamsObject extends DecodedParamsArray {
[key: string]: unknown
}
Loading
Loading