Skip to content

Commit

Permalink
Merge pull request Synthetixio#234 from Synthetixio/feature/ethers-su…
Browse files Browse the repository at this point in the history
…bmodules-wei

Use submodules for ethers dependencies
  • Loading branch information
jmzwar authored Jul 29, 2022
2 parents f4d21a4 + 355d845 commit 078b697
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/wei/__tests__/wei.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Wei, { wei } from '../src/wei';
import { BigNumber } from 'ethers';
import Big from 'big.js';
import { BigNumber } from '@ethersproject/bignumber';

describe('Wei numeric type', () => {
describe('Constructor', () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/wei/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
},
"homepage": "https://github.com/Synthetixio/js-monorepo#readme",
"dependencies": {
"big.js": "^6.1.1",
"ethers": "^5.5.3"
"@ethersproject/bignumber": "^5.6.2",
"@ethersproject/bytes": "^5.6.1",
"big.js": "^6.1.1"
},
"devDependencies": {
"@babel/core": "^7.11.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/wei/src/wei.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// https://en.wikipedia.org/wiki/Scale_factor_(computer_science)

// TODO: create a BN extension which works as a replacement for big using scaled integers
import { BigNumber, ethers } from 'ethers';
import { hexZeroPad } from '@ethersproject/bytes';
import { BigNumber } from '@ethersproject/bignumber';
import Big from 'big.js';

export const WEI_PRECISION = 18;
Expand Down Expand Up @@ -138,7 +139,7 @@ export default class Wei {
*/
toSortable(): string {
// TODO: handle sign?
return ethers.utils.hexZeroPad(Buffer.from(this.bn.toHexString()), 64);
return hexZeroPad(Buffer.from(this.bn.toHexString()), 64);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2411,11 +2411,12 @@ __metadata:
"@babel/plugin-transform-runtime": ^7.13.10
"@babel/preset-env": ^7.13.10
"@babel/preset-typescript": ^7.13.0
"@ethersproject/bignumber": ^5.6.2
"@ethersproject/bytes": ^5.6.1
"@types/big.js": ^6.0.2
"@types/node": ^17.0.43
big.js: ^6.1.1
eslint: ^7.26.0
ethers: ^5.5.3
jest: ^27.0.6
ts-loader: ^8.0.2
ts-node: ^10.2.1
Expand Down

0 comments on commit 078b697

Please sign in to comment.