-
Notifications
You must be signed in to change notification settings - Fork 9
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
Migrate From ContractKit to Viem #294
Draft
aaronmgdr
wants to merge
11
commits into
main
Choose a base branch
from
feature/viem
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4a7b2c8
WIP use viem instead of contractkit
aaronmgdr d012ef3
add missing parts
aaronmgdr d2091b6
first final draft
aaronmgdr 838939b
instead of a viem client instance just use a sign function more generic.
aaronmgdr 4a09193
convert contractkit mocks to mocks for our viem contract accessors,
aaronmgdr cc5df33
add change sets for packages
aaronmgdr 6dada95
Fix up configs,
aaronmgdr 49f43be
fix config
aaronmgdr 0f4bfe1
remock the getDataEncryptionKey
aaronmgdr 1f8fb50
skip auth tests for now
aaronmgdr cfde4ce
upgrade celo dependencies
aaronmgdr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
"@celo/phone-number-privacy-monitor": major | ||
--- | ||
|
||
Replace @celo/contractkit with viem | ||
|
||
|
||
### Breaking Changes | ||
|
||
`queryOdisForQuota` and `queryOdisForSalt` for first param instead of a string url now take an object with rpcURL and chainID. | ||
|
||
```diff | ||
- queryOdisForQuota("https://forno.celo.org",...rest) | ||
+ queryOdisForQuota({rpcURL: "https://forno.celo.org", chainID: 42220},...rest) | ||
|
||
|
||
- queryOdisForSalt("https://forno.celo.org",...rest) | ||
+ queryOdisForSalt({rpcURL: "https://forno.celo.org", chainID: 42220},...rest) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
"@celo/phone-number-privacy-combiner": major | ||
--- | ||
|
||
Replace @celo/contractkit with viem | ||
|
||
|
||
### Breaking Changes | ||
|
||
`startCombiner` now takes an optional WalletClient instance from viem instead of a ContractKit instance | ||
|
||
config passed to `startCombiner` has a sub config `blockchain` which has the following changes. | ||
|
||
```diff | ||
{ | ||
...restOfConfig, | ||
blockchain: { | ||
- provider: "https://forno.celo.org" | ||
+ rpcURL: "https://forno.celo.org" | ||
+ chainID: 42220 | ||
} | ||
} | ||
|
||
``` | ||
--- | ||
|
||
`lib/common/web3` => `lib/common` | ||
|
||
`getDEK` moved from | ||
|
||
it now takes a WalletClient as its first param instead of a ContractKit. | ||
|
||
third param is now typed to require address starts with 0x | ||
|
||
```diff | ||
- export async function getDEK(kit: ContractKit, logger: Logger, account: string): Promise<string> | ||
+ export async function getDEK(client: Client, logger: Logger, account: Address): Promise<string> | ||
``` | ||
|
||
--- | ||
|
||
lib/pnp/services/account-services` | ||
|
||
`ContractKitAccountServiceOptions` => `ViemAccountServiceOptions` | ||
|
||
`ContractKitAccountService` => `ViemAccountService` | ||
|
||
addressed passed to `getAccount` now MUST start with `0x` in type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
"@celo/identity": major | ||
--- | ||
|
||
Contract kit has been replaced with viem as dependency. | ||
|
||
from `lib/odis/query`; WalletKeySigner instead of a contractKit instance now takes a sign191 function | ||
|
||
- This should use EIP191 to sign the message using the private key assosiated with the account | ||
|
||
Most places that were previously typed as string are now 0x-string typed | ||
|
||
ContractKit is now an optional peer dependency. it is only needed if using the offchain-data-wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@celo/encrypted-backup": patch | ||
--- | ||
|
||
Remove @celo/connect as a depdendency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
"@celo/phone-number-privacy-common": major | ||
--- | ||
|
||
Replace @celo/contractkit with viem | ||
|
||
|
||
### BREAKING CHANGES | ||
Config changes | ||
|
||
`BlockchainConfig` gains a new required `chainID` property | ||
|
||
`provider` which is an overloaded term is renamed to `rpcURL` | ||
|
||
```diff | ||
config: BlockchainConfig = { | ||
- provider: FORNO_URL | ||
+ rpcURL: FORNOURL | ||
+ chainID: 42220 | ||
} | ||
``` | ||
|
||
`getContractKit` => `getWalletClient` | ||
|
||
|
||
functions replaced in utils/authentication | ||
|
||
`newContractKitFetcher` => `newDEKFetcher` | ||
|
||
```diff | ||
- newContractKitFetcher(contractKit: ContractKit, ...) | ||
+ newDEKFetcher(viemClient: Client, ...) | ||
``` | ||
|
||
functions with with changed signatures | ||
|
||
`getDataEncryptionKey` | ||
|
||
```diff | ||
export async function getDataEncryptionKey( | ||
- address: string, | ||
- contractKit: ContractKit, | ||
+ address: Address, | ||
+ viemClient: Client, | ||
logger: Logger, | ||
fullNodeTimeoutMs: number, | ||
fullNodeRetryCount: number, | ||
fullNodeRetryDelayMs: number, | ||
- ): Promise<string> | ||
+ ): Promise<Hex> | ||
``` | ||
|
||
functions removed from test/utils | ||
|
||
- `createMockToken` | ||
- `createMockContractKit` | ||
- `createMockConnection` | ||
- `createMockWeb3` | ||
- `replenishQuota` | ||
|
||
|
||
### NEW FUNCTIONS | ||
|
||
`import {getAccountsContract, getOdisPaymentsContract, getCUSDContract } from @celo/phone-number-privacy-common` | ||
|
||
To replace contractKit wrappers for Accounts, OdisPayments, and StableToken, contracts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
"@celo/phone-number-privacy-signer": major | ||
--- | ||
|
||
Replace @celo/contractKit with viem | ||
|
||
|
||
If you are just running the service no actual changes required except to use with same major version of combiner and monitor | ||
|
||
### Breaking Changes | ||
|
||
|
||
|
||
`ContractKitAccountService` => `ClientAccountService` | ||
|
||
```diff | ||
- new ContractKitAccountService(logger, contractKit) | ||
+ new ClientAccountService(logger, walletClient) | ||
|
||
``` | ||
|
||
`getAccount` now takes strongly typed 0x string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
apps/combiner/src/common/web3/contracts.ts → apps/combiner/src/common/contracts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: does it make sense to call this
sign191
instead of justsign