Skip to content

Commit

Permalink
Remove bn.js and resolutions from celo/utils (#105)
Browse files Browse the repository at this point in the history
* Remove bn.js and resolutions.

* docs

---------

Co-authored-by: Aaron <[email protected]>
  • Loading branch information
aaronmgdr and aaronmgdr authored Jan 30, 2024
1 parent cdba30e commit 6b2e34c
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 57 deletions.
19 changes: 19 additions & 0 deletions .changeset/tall-buckets-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@celo/utils': major
---

Remove export compareBN

This would have been used to sort BN.js numbers. Generic comparator functions are not really the scope of this library. Removing it allows the bn.js dependency to be removed too. If you were using this function it can be re-implemented as

```typescript
export function compareBN(a: BN, b: BN) {
if (a.eq(b)) {
return 0
} else if (a.lt(b)) {
return -1
} else {
return 1
}
}
```
1 change: 0 additions & 1 deletion packages/docs/sdk/docs/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

- [address](modules/address.md)
- [async](modules/async.md)
- [bn](modules/bn.md)
- [celoHistory](modules/celoHistory.md)
- [collections](modules/collections.md)
- [contacts](modules/contacts.md)
Expand Down
30 changes: 0 additions & 30 deletions packages/docs/sdk/docs/utils/modules/bn.md

This file was deleted.

6 changes: 3 additions & 3 deletions packages/docs/sdk/docs/utils/modules/sign_typed_data_utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Constructs the struct encoding of the data as the primary type.

#### Defined in

[packages/sdk/utils/src/sign-typed-data-utils.ts:249](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/utils/src/sign-typed-data-utils.ts#L249)
[packages/sdk/utils/src/sign-typed-data-utils.ts:248](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/utils/src/sign-typed-data-utils.ts#L248)

___

Expand Down Expand Up @@ -316,7 +316,7 @@ ___

#### Defined in

[packages/sdk/utils/src/sign-typed-data-utils.ts:258](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/utils/src/sign-typed-data-utils.ts#L258)
[packages/sdk/utils/src/sign-typed-data-utils.ts:257](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/utils/src/sign-typed-data-utils.ts#L257)

___

Expand Down Expand Up @@ -368,4 +368,4 @@ Note that EIP-712 does not specify zero values, and so this is non-standard.

#### Defined in

[packages/sdk/utils/src/sign-typed-data-utils.ts:274](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/utils/src/sign-typed-data-utils.ts#L274)
[packages/sdk/utils/src/sign-typed-data-utils.ts:273](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/utils/src/sign-typed-data-utils.ts#L273)
9 changes: 0 additions & 9 deletions packages/sdk/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
"dependencies": {
"@celo/base": "^6.0.0",
"@ethereumjs/util": "8.0.5",
"@types/bn.js": "^5.1.0",
"@types/elliptic": "^6.4.9",
"@types/node": "^18.7.16",
"bignumber.js": "^9.0.0",
"bn.js": "4.11.9",
"elliptic": "^6.5.4",
"ethereum-cryptography": "1.2.0",
"fp-ts": "2.1.1",
Expand All @@ -39,12 +37,5 @@
},
"devDependencies": {
"@celo/typescript": "0.0.1"
},
"resolutions": {
"@types/bn.js": "4.11.6",
"bn.js": "4.11.9",
"elliptic/bn.js": "[email protected]",
"web3-utils/bn.js": "[email protected]",
"@ethereumjs/bn.js": "[email protected]"
}
}
11 changes: 0 additions & 11 deletions packages/sdk/utils/src/bn.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/sdk/utils/src/sign-typed-data-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ export function typeHash(primaryType: string, types: EIP712Types): Buffer {
function encodeValue(valueType: string, value: EIP712ObjectValue, types: EIP712Types): Buffer {
// Encode the atomic types as their corresponding soldity ABI type.
if (EIP712_ATOMIC_TYPES.includes(valueType)) {
// @ts-ignore TypeScript does not believe encodeParameter exists.
const hexEncoded = coder.encodeParameter(valueType, normalizeValue(valueType, value))
return Buffer.from(trimLeading0x(hexEncoded), 'hex')
}
Expand Down
2 changes: 0 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1932,11 +1932,9 @@ __metadata:
"@celo/base": "npm:^6.0.0"
"@celo/typescript": "npm:0.0.1"
"@ethereumjs/util": "npm:8.0.5"
"@types/bn.js": "npm:^5.1.0"
"@types/elliptic": "npm:^6.4.9"
"@types/node": "npm:^18.7.16"
bignumber.js: "npm:^9.0.0"
bn.js: "npm:4.11.9"
elliptic: "npm:^6.5.4"
ethereum-cryptography: "npm:1.2.0"
fp-ts: "npm:2.1.1"
Expand Down

0 comments on commit 6b2e34c

Please sign in to comment.