Skip to content
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
2 changes: 1 addition & 1 deletion .changeset/curly-toes-pump.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@celo/celocli': major
---

Now defaults to using "m/44'/60'/0'" as base derivation path for account:new and any command using --useLedger. use celocli config:set --derivationPath celoLegacy for old behavior.
Now defaults to using "m/44'/60'/0'" as base derivation path for account:new and any command using --useLedger. use celocli `config:set --derivationPath celoLegacy` for old behavior.
2 changes: 1 addition & 1 deletion .changeset/fresh-months-share.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@celo/celocli': major
---

Remove node:accounts commmand (use account:list)
Remove node:accounts command (use account:list)
2 changes: 1 addition & 1 deletion .changeset/old-cougars-look.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
'@celo/celocli': patch
---

Deprecate useAKV flag with intent to remove. This was for connecting to AzureKeyVault for storing key to sign trnsactions. We hope to streamline and remove this functionality.
Deprecate useAKV flag with intent to remove. This was for connecting to AzureKeyVault for storing key to sign transactions. We hope to streamline and remove this functionality.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ jobs:
steps:
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
- name: 'enable corepack for yarn'
run: sudo corepack enable yarn
- uses: actions/checkout@v4
# must call twice because of chicken and egg problem with yarn and node
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'yarn'
- name: Restore node cache
uses: actions/cache@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
# must call twice because of chicken and egg problem with yarn and node
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'yarn'
- name: Install Dependencies
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/upload-celocli-executables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
# must call twice because of chicken and egg problem with yarn and node
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'yarn'

- name: Install Dependencies
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
# must call twice because of chicken and egg problem with yarn and node
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'yarn'
- name: Install Dependencies
shell: bash
Expand Down Expand Up @@ -194,7 +194,7 @@ jobs:
# must call twice because of chicken and egg problem with yarn and node
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'yarn'
- name: Install Dependencies
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"postbuild": "node ../../scripts/post-build.mjs",
"clean": "yarn --top-level run tsc -b . --clean && yarn --top-level run rimraf dist",
"docs": "yarn --top-level run typedoc",
"test": "yarn run vitest --run --passWithNoTests",
"test": "yarn run vitest --run --retry=1",
"check-size": "size-limit",
"test:watch": "yarn run vitest --watch",
"test:changes": "yarn run vitest --run --changed",
Expand Down
16 changes: 15 additions & 1 deletion packages/actions/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import type { Account, Client, PublicClient, Transport, WalletClient } from 'viem'
import {
type Account,
type Client,
type PublicClient,
type Transport,
type WalletClient,
} from 'viem'
import type { celo, celoAlfajores } from 'viem/chains'
import type { celoBaklava } from './chains'

Expand All @@ -9,3 +15,11 @@ export type CeloClient = Client<Transport, CeloChain>
export type PublicCeloClient = PublicClient<Transport, CeloChain, undefined>

export type WalletCeloClient = WalletClient<Transport, CeloChain, Account>

export type Clients<
P extends PublicCeloClient | PublicClient = PublicCeloClient,
W extends WalletCeloClient | WalletClient = WalletCeloClient
> = {
public: P
wallet?: W
}
21 changes: 11 additions & 10 deletions packages/actions/src/contracts/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import { accountsABI } from '@celo/abis'
import { Address, Client, getContract, GetContractReturnType, PublicClient } from 'viem'

import { Address, getContract, GetContractReturnType } from 'viem'

Check warning on line 2 in packages/actions/src/contracts/accounts.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/accounts.ts#L2

Added line #L2 was not covered by tests
import { Clients, PublicCeloClient } from '../client'
import { resolveAddress } from './registry'

export type AccountsContract<T extends Client = PublicClient> = GetContractReturnType<
export type AccountsContract<C extends Clients = Clients> = GetContractReturnType<
typeof accountsABI,
T
C
>

export async function getAccountsContract<T extends Client = PublicClient>(
client: T
): Promise<AccountsContract<T>> {
export async function getAccountsContract(clients: Clients): Promise<AccountsContract<Clients>> {

Check warning on line 11 in packages/actions/src/contracts/accounts.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/accounts.ts#L11

Added line #L11 was not covered by tests
return getContract({
address: await resolveAddress(client, 'Accounts'),
address: await resolveAddress(clients.public, 'Accounts'),

Check warning on line 13 in packages/actions/src/contracts/accounts.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/accounts.ts#L13

Added line #L13 was not covered by tests
abi: accountsABI,
client,
client: clients,

Check warning on line 15 in packages/actions/src/contracts/accounts.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/accounts.ts#L15

Added line #L15 was not covered by tests
})
}

// METHODS

export const signerToAccount = async (client: PublicClient, signer: Address): Promise<Address> => {
export const signerToAccount = async (
client: PublicCeloClient,
signer: Address
): Promise<Address> => {

Check warning on line 24 in packages/actions/src/contracts/accounts.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/accounts.ts#L21-L24

Added lines #L21 - L24 were not covered by tests
return await client.readContract({
address: await resolveAddress(client, 'Accounts'),
abi: accountsABI,
Expand Down
17 changes: 8 additions & 9 deletions packages/actions/src/contracts/celo-erc20.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { goldTokenABI } from '@celo/abis'
import { Client, getContract, GetContractReturnType, PublicClient } from 'viem'
import { getContract, GetContractReturnType } from 'viem'

Check warning on line 2 in packages/actions/src/contracts/celo-erc20.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/celo-erc20.ts#L2

Added line #L2 was not covered by tests
import { Clients } from '../client'
import { resolveAddress } from './registry'

export async function getCeloERC20Contract<T extends Client = PublicClient>(
client: T
export type CeloERC20<T extends Clients = Clients> = GetContractReturnType<typeof goldTokenABI, T>

export async function getCeloERC20Contract<T extends Clients = Clients>(
clients: T

Check warning on line 9 in packages/actions/src/contracts/celo-erc20.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/celo-erc20.ts#L8-L9

Added lines #L8 - L9 were not covered by tests
): Promise<CeloERC20<T>> {
return getContract({
address: await resolveAddress(client, 'GoldToken'),
address: await resolveAddress(clients.public, 'GoldToken'),

Check warning on line 12 in packages/actions/src/contracts/celo-erc20.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/celo-erc20.ts#L12

Added line #L12 was not covered by tests
abi: goldTokenABI,
client,
client: clients,

Check warning on line 14 in packages/actions/src/contracts/celo-erc20.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/celo-erc20.ts#L14

Added line #L14 was not covered by tests
})
}
export type CeloERC20<T extends Client = PublicClient> = GetContractReturnType<
typeof goldTokenABI,
T
>
13 changes: 7 additions & 6 deletions packages/actions/src/contracts/election.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { electionABI } from '@celo/abis'
import { Client, getContract, GetContractReturnType, PublicClient } from 'viem'
import { getContract, GetContractReturnType } from 'viem'

Check warning on line 2 in packages/actions/src/contracts/election.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/election.ts#L2

Added line #L2 was not covered by tests
import { Clients } from '../client'
import { resolveAddress } from './registry'

export type ElectionContract<T extends Client = PublicClient> = GetContractReturnType<
export type ElectionContract<T extends Clients = Clients> = GetContractReturnType<
typeof electionABI,
T
>

export async function getElectionContract<T extends Client = PublicClient>(
client: T
export async function getElectionContract<T extends Clients = Clients>(
clients: T

Check warning on line 12 in packages/actions/src/contracts/election.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/election.ts#L11-L12

Added lines #L11 - L12 were not covered by tests
): Promise<ElectionContract<T>> {
return getContract({
address: await resolveAddress(client, 'Election'),
address: await resolveAddress(clients.public, 'Election'),

Check warning on line 15 in packages/actions/src/contracts/election.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/election.ts#L15

Added line #L15 was not covered by tests
abi: electionABI,
client,
client: clients,

Check warning on line 17 in packages/actions/src/contracts/election.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/election.ts#L17

Added line #L17 was not covered by tests
})
}
20 changes: 11 additions & 9 deletions packages/actions/src/contracts/epoch-manager.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { epochManagerABI } from '@celo/abis'
import { Client, getContract, GetContractReturnType, PublicClient } from 'viem'
import { getContract, GetContractReturnType } from 'viem'

Check warning on line 2 in packages/actions/src/contracts/epoch-manager.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/epoch-manager.ts#L2

Added line #L2 was not covered by tests
import { Clients } from '../client'
import { resolveAddress } from './registry'

export async function getEpochManagerContract<T extends Client = PublicClient>(
client: T
export type EpochManager<T extends Clients = Clients> = GetContractReturnType<
typeof epochManagerABI,
T
>

export async function getEpochManagerContract<T extends Clients = Clients>(
clients: T

Check warning on line 12 in packages/actions/src/contracts/epoch-manager.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/epoch-manager.ts#L11-L12

Added lines #L11 - L12 were not covered by tests
): Promise<EpochManager<T>> {
return getContract({
address: await resolveAddress(client, 'EpochManager'),
address: await resolveAddress(clients.public, 'EpochManager'),

Check warning on line 15 in packages/actions/src/contracts/epoch-manager.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/epoch-manager.ts#L15

Added line #L15 was not covered by tests
abi: epochManagerABI,
client,
client: clients,

Check warning on line 17 in packages/actions/src/contracts/epoch-manager.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/epoch-manager.ts#L17

Added line #L17 was not covered by tests
})
}
export type EpochManager<T extends Client = PublicClient> = GetContractReturnType<
typeof epochManagerABI,
T
>
11 changes: 6 additions & 5 deletions packages/actions/src/contracts/erc20.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Address, Client, erc20Abi, getContract, GetContractReturnType, PublicClient } from 'viem'
import { erc20Abi, getContract, type Address, type GetContractReturnType } from 'viem'
import { Clients } from '../client'

export async function getERC20Contract<T extends Client = PublicClient>(
client: T,
export async function getERC20Contract<T extends Clients = Clients>(
clients: T,

Check warning on line 5 in packages/actions/src/contracts/erc20.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/erc20.ts#L4-L5

Added lines #L4 - L5 were not covered by tests
address: Address
): Promise<ERC20<T>> {
return getContract({
address,
abi: erc20Abi,
client,
client: clients,

Check warning on line 11 in packages/actions/src/contracts/erc20.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/erc20.ts#L11

Added line #L11 was not covered by tests
})
}
export type ERC20<T extends Client = PublicClient> = GetContractReturnType<typeof erc20Abi, T>
export type ERC20<T extends Clients = Clients> = GetContractReturnType<typeof erc20Abi, T>
13 changes: 7 additions & 6 deletions packages/actions/src/contracts/feecurrency-directory.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { feeCurrencyDirectoryABI } from '@celo/abis'
import { Client, getContract, GetContractReturnType, PublicClient } from 'viem'
import { getContract, GetContractReturnType } from 'viem'

Check warning on line 2 in packages/actions/src/contracts/feecurrency-directory.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/feecurrency-directory.ts#L2

Added line #L2 was not covered by tests
import { Clients } from '../client'
import { resolveAddress } from './registry'

export async function getFeeCurrencyDirectoryContract<T extends Client = PublicClient>(
client: T
export async function getFeeCurrencyDirectoryContract<T extends Clients = Clients>(
clients: T

Check warning on line 7 in packages/actions/src/contracts/feecurrency-directory.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/feecurrency-directory.ts#L6-L7

Added lines #L6 - L7 were not covered by tests
): Promise<FeeCurrencyDirectory<T>> {
return getContract({
address: await resolveAddress(client, 'FeeCurrencyDirectory'),
address: await resolveAddress(clients.public, 'FeeCurrencyDirectory'),

Check warning on line 10 in packages/actions/src/contracts/feecurrency-directory.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/feecurrency-directory.ts#L10

Added line #L10 was not covered by tests
abi: feeCurrencyDirectoryABI,
client,
client: clients,

Check warning on line 12 in packages/actions/src/contracts/feecurrency-directory.ts

View check run for this annotation

Codecov / codecov/patch

packages/actions/src/contracts/feecurrency-directory.ts#L12

Added line #L12 was not covered by tests
})
}
export type FeeCurrencyDirectory<T extends Client = PublicClient> = GetContractReturnType<
export type FeeCurrencyDirectory<T extends Clients = Clients> = GetContractReturnType<
typeof feeCurrencyDirectoryABI,
T
>
30 changes: 17 additions & 13 deletions packages/actions/src/contracts/governance.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { viem_testWithAnvil } from '@celo/dev-utils/viem/anvil-test'
import { createWalletClient, http } from 'viem'
import { createPublicClient, createWalletClient, http } from 'viem'
import { celo } from 'viem/chains'
import { expect, it } from 'vitest'
import { WalletCeloClient } from '../client'
import { PublicCeloClient, WalletCeloClient } from '../client'
import { vote } from './governance'

const TIMEOUT = 10_000
Expand All @@ -16,14 +16,21 @@ const forkUrl = celo.rpcUrls.default.http[0]
viem_testWithAnvil(
'vote',
async (client) => {
let walletClient: WalletCeloClient
let clients: { public: PublicCeloClient; wallet: WalletCeloClient }
beforeEach(async () => {
client.impersonateAccount({ address: voter })
walletClient = createWalletClient({
await client.impersonateAccount({ address: voter })
const walletClient = createWalletClient({
account: voter,
chain: client.chain,
transport: http(client.chain.rpcUrls.default.http[0]),
})
clients = {
public: createPublicClient({
chain: client.chain,
transport: http(client.chain.rpcUrls.default.http[0]),
}),
wallet: walletClient,
}
})
afterEach(async () => {
await client.stopImpersonatingAccount({ address: voter })
Expand All @@ -33,25 +40,22 @@ viem_testWithAnvil(
it(
'votes Yes on a proposal',
async () => {
// This will throw if proposalId is not in the dequeue
// In a real test, ensure proposalId is valid and in the dequeue
await expect(vote(walletClient, proposalId, 'Yes')).resolves.toMatch(txHashRegex)
await expect(vote(clients, proposalId, 'Yes')).resolves.toMatch(txHashRegex)
},
TIMEOUT
)

it(
'votes No on a proposal',
async () => {
await expect(vote(walletClient, proposalId, 'No')).resolves.toMatch(txHashRegex)
await expect(vote(clients, proposalId, 'No')).resolves.toMatch(txHashRegex)
},
TIMEOUT
)

it(
'votes Abstain on a proposal',
'votes Abstain a proposal',
async () => {
await expect(vote(walletClient, proposalId, 'Abstain')).resolves.toMatch(txHashRegex)
await expect(vote(clients, proposalId, 'Abstain')).resolves.toMatch(txHashRegex)
},
TIMEOUT
)
Expand All @@ -61,7 +65,7 @@ viem_testWithAnvil(
async () => {
const invalidProposalId = 999999n
await expect(
vote(walletClient, invalidProposalId, 'Yes')
vote(clients, invalidProposalId, 'Yes')
).rejects.toThrowErrorMatchingInlineSnapshot(
`[Error: ID 999999 not found in array 36,47,72,32,33,37,38,44,46,45,52,51,58,59,65,64,112,70,73,78,75,74,84,79,81,82,95,87,94,110,90,92,93,97,98,104,100,106,113,108,109,114,126,125,122,124,129,153,146,154,141,152,149,148,155,156,192,184,166,173,186,185,196,230,203,0,207,0,224,206]`
)
Expand Down
Loading
Loading