Skip to content

Commit

Permalink
Updated Contractkit v2 migration with info about attestations wrapper (
Browse files Browse the repository at this point in the history
…celo-org#308)

* Add Breaking Changes from Attestations Wrapper

* IdentityMetadata no longer is a breaking change, instead allow either kit or AccountsWrapper

* GasPriceMinimum no longer mvp
  • Loading branch information
aaronmgdr authored Apr 1, 2022
1 parent 8e3c6c4 commit 64cefed
Showing 1 changed file with 20 additions and 31 deletions.
51 changes: 20 additions & 31 deletions docs/developer-resources/contractkit/migrating-to-contractkit-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ___

## Why v2?

### Bundlesize
### Bundle Size

The primary motivation in creating v2 was reduced bundlesize and increased modularity. The massive package size for `@celo/contractkit` has been an elephant in the room and source of dissonance for looking to build mobile first dApps. As of 1.5.2 bundlephobia list the minified size at 3.7MB. 2.0.0 comes in at 1.7MB. still big yet we have a few more tricks. First the packages have been all marked as `sideEffects:false`, a `kit` instance is no longer required to any classes in the contractkit package, and the introduction of `MiniContractKit`.

Expand All @@ -30,7 +30,7 @@ In v2 AddressRegistry, Wrappers, WrapperCache, and more can all be constructed u

The prize of no longer needing a full `kit` is that it became possible to create a slimed down minimal viable ContractKit.

`MiniContractKit` provides a subset of ContractKit features with the same interface. For many dapps it will be a drop in opt-in change (eg `import {newKit, ContractKit} from "@celo/contractkit/lib/mini/kit`). It reduces size by only including access to `Accounts, GasPriceMinimum, StableToken*, Exchange* and GoldToken` wrappers and contracts. It can `setFeeCurrency`, look up info about the current account and, like full Contractkit, it delegates most functionality to `connection`.
`MiniContractKit` provides a subset of ContractKit features with the same interface. For many dapps it will be a drop in opt-in change (eg `import {newKit, ContractKit} from "@celo/contractkit/lib/mini/kit`). It reduces size by only including access to `Accounts, StableToken*, Exchange* and GoldToken` wrappers and contracts. It can `setFeeCurrency`, look up info about the current account and, like full Contractkit, it delegates most functionality to `connection`.

## Get Started

Expand All @@ -55,35 +55,6 @@ Because of how we publish packages, all packages will be upgraded to v2. However

Most changes are about eliminating the need to construct an entire kit to use other classes and functions.

#### IdentityMetadataWrapper (idendity/metadata.ts)

This had functions that took a `kit` as a parameter. Now it takes an AccountsWrapper class.

This change was done so that `kit` was not required to be passed into all the classes and functions that use `IdentityMetadataWrapper`.

*v1

```typescript
IdentityMetadataWrapper.fetchFromURL(kit, url)

IdentityMetadataWrapper.fromFile(kit, path)

IdentityMetadataWrapper.verifySignerForAddress(kit, hash, signature, address)
IdentityMetadataWrapper.fromRawString(kit, rawData)
```

*v2

```typescript
const accounts = await kit.contracts.getAccounts()

IdentityMetadataWrapper.fetchFromURL(accounts, url)

IdentityMetadataWrapper.fromFile(accounts, path)

IdentityMetadataWrapper.verifySignerForAddress(accounts, hash, signature, address)
IdentityMetadataWrapper.fromRawString(accounts, rawData)
```

#### AddressRegistry

Expand Down Expand Up @@ -133,6 +104,24 @@ accountsInstance.authorizeValidatorSigner(signer, sig, validatorsInstance)

```

##### AttestationsWrapper

`AttestationsWrapper.getConfig()` and`AttestationsWrapper.getHumanReadableConfig()`

These functions now require an array of fee payable token addresses. You can get these from the CeloTokens class, the Registry, or Token Contracts

```typescript
const celoTokens = kit.celoTokens
const eachTokenAddress = await celoTokens.getAddresses()
const addresses = Object.values(eachTokenAddress)

AttestationsWrapper.getConfig(addresses)
// OR
AttestationsWrapper.getHumanReadableConfig(addresses)

```


#### Web3ContractCache

Instead of a `kit` instance, it requires only a `AddressRegistry` (uses AddressRegistry's web3 instances).
Expand Down

0 comments on commit 64cefed

Please sign in to comment.