Skip to content

Commit

Permalink
Create metadata claims package / remove from contractkit (#340)
Browse files Browse the repository at this point in the history
### Description

@celo/contractkit has for a long time basically had within it a
subpackage under /identity that really didnt have anything to do with
contractkit. Removing it will make it easier to build social connect
tools as they use the IdentityMetadataMapper contained in here. However
this is not social connect tool so it will remain in the developer
tooling repo.

This is a prereq to remove contractkit as a dependency for social
connect. a long term aim.

### Other changes


### Tested

uses existing tests

### Related issues

- Fixes #15

### Backwards compatibility
nope
exports moved to a new package. file structure slightly altered.
parameter for IdentityMetadataMapper changes to take an object with
specific functions rather than a kit
### Documentation

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces the `@celo/metadata-claims` package, extracting
identity-related functionality from `@celo/contractkit`. This allows
developers to use the `IdentityMetadataWrapper` independently of
`ContractKit`, enhancing modularity and usability.

### Detailed summary
- Created `@celo/metadata-claims` package.
- Moved identity and claims-related functionality from
`@celo/contractkit`.
- Updated imports in CLI commands and SDK files to use the new package.
- Introduced types like `AccountMetadataSignerGetters`.
- Removed identity-related exports from `@celo/contractkit`.
- Added tests for new functionality in the `metadata-claims` package.

> The following files were skipped due to too many changes:
`packages/sdk/wallets/wallet-rpc/lib/rpc-signer.js.map`,
`packages/sdk/wallets/wallet-rpc/lib/rpc-signer.js`,
`packages/sdk/wallets/wallet-rpc/lib/rpc-wallet.test.js.map`,
`docs/sdk/metadata-claims/modules/claim.md`,
`packages/sdk/wallets/wallet-rpc/lib/rpc-wallet.test.js`,
`docs/sdk/metadata-claims/classes/metadata.IdentityMetadataWrapper.md`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
aaronmgdr authored Oct 2, 2024
1 parent 87223ba commit 33ad4aa
Show file tree
Hide file tree
Showing 77 changed files with 2,252 additions and 1,269 deletions.
42 changes: 42 additions & 0 deletions .changeset/hot-pugs-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
'@celo/contractkit': major
---

Removes all exports under the lib/identity folder. These have been move to a new @celo/metadata-claims package and should be imported from there.

Note that folder structure is also flattened slightly. so replace `@celo/contractkit/lib/identity/claims/` with `@celo/metadata-claims/lib/`

example

```diff
- import { createAccountClaim } from '@celo/contractkit/lib/identity/claims/account'
+ import { createAccountClaim } from '@celo/metadata-claims/lib/account'
```

```diff
- import { ContractKit, IdentityMetadataWrapper, newKitFromWeb3 } from '@celo/contractkit'
- import { ClaimTypes } from '@celo/contractkit/lib/identity'
+ import { ContractKit, newKitFromWeb3 } from '@celo/contractkit'
+ import { ClaimTypes, IdentityMetadataWrapper } from '@celo/metadata-claims'

```

Note that Contractkit is Not a dependency. Instead when using `IdentityMetadataWrapper` you should make an object that satisfis the `AccountMetadataSignerGetters` type

```typescript
import { AccountMetadataSignerGetters } from '@celo/metadata-claims/lib/types';

```
using viem it would be like

```typescript
const accountsMetaDataSignerGetters: AccountMetadataSignerGetters = {
isAccount: async (address: string) => accounts.read.isAccount([address as Address]),
getValidatorSigner: async (address: string) =>
accounts.read.getValidatorSigner([address as Address]),
getVoteSigner: async (address: string) =>
accounts.read.getValidatorSigner([address as Address]),
getAttestationSigner: async (address: string) =>
accounts.read.getValidatorSigner([address as Address]),
}
```
26 changes: 26 additions & 0 deletions .changeset/thirty-pugs-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@celo/metadata-claims': major
---

Introducing @celo/metadata-claims These are a series of functions extracted from @celo/contractkit since they didnt strictly need depend on contractkit itsefl. Developers can now use IdentityMetadataWrapper with any js rpc library like ethers or viem or web3js without being forced to import ContractKit.


Instead when using `IdentityMetadataWrapper` you should make an object that satisfis the `AccountMetadataSignerGetters` type

```typescript
import { AccountMetadataSignerGetters } from '@celo/metadata-claims/lib/types';

```
using viem it would be like

```typescript
const accountsMetaDataSignerGetters: AccountMetadataSignerGetters = {
isAccount: async (address: string) => accounts.read.isAccount([address as Address]),
getValidatorSigner: async (address: string) =>
accounts.read.getValidatorSigner([address as Address]),
getVoteSigner: async (address: string) =>
accounts.read.getValidatorSigner([address as Address]),
getAttestationSigner: async (address: string) =>
accounts.read.getValidatorSigner([address as Address]),
}
```
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@ package.json-e
# Ignore generated credentials from google-github-actions/auth
gha-creds-*.json
transactions.json
packages/sdk/metadata-claims/lib

This file was deleted.

Loading

0 comments on commit 33ad4aa

Please sign in to comment.