Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
jscore: Import only minimum ethers subpackages
Browse files Browse the repository at this point in the history
  • Loading branch information
blukat29 committed Sep 11, 2023
1 parent 5d0e806 commit 0dc31ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
6 changes: 3 additions & 3 deletions js-ext-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
"prepublishOnly": "npm run build"
},
"license": "MIT",
"peerDependencies": {
"ethers": "^5.7.2"
},
"devDependencies": {
"@types/chai": "^4.3.4",
"@types/chai-as-promised": "^7.1.5",
Expand All @@ -34,6 +31,9 @@
"typescript": "^5.0.4"
},
"dependencies": {
"@ethersproject/address": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/transactions": "^5.7.0",
"@klaytn/web3rpc": "^0.9.0",
"lodash": "^4.17.21"
}
Expand Down
8 changes: 4 additions & 4 deletions js-ext-core/src/core/klaytn_tx.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TransactionRequest } from "@ethersproject/abstract-provider";
import { BigNumber } from "ethers";
import { hexValue, parseTransaction } from "ethers/lib/utils";
import { BigNumber } from "@ethersproject/bignumber";
import { hexValue } from "@ethersproject/bytes";
import { parse as parseTransaction } from "@ethersproject/transactions";
import _ from "lodash";

import { FieldSet, FieldSetFactory } from "./field";
Expand Down Expand Up @@ -108,7 +108,7 @@ export function objectFromRLP(value: string): any {
return tx;
}

export function encodeTxForRPC(allowedKeys:string[], tx: TransactionRequest): any {
export function encodeTxForRPC(allowedKeys:string[], tx: any): any {
// TODO: refactoring like below
// https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/json-rpc-provider.ts#L701
// return {
Expand Down
16 changes: 6 additions & 10 deletions js-ext-core/src/core/util.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
import { BigNumber, BigNumberish, FixedNumber } from "@ethersproject/bignumber";
import { getAddress } from "@ethersproject/address";
import * as bytes from "@ethersproject/bytes";
import * as rlp from "@ethersproject/rlp";
import { FixedNumber, ethers } from "ethers";
import { computeAddress } from "ethers/lib/utils";
import { computeAddress } from "@ethersproject/transactions";

export const RLP = {
encode: rlp.encode,
Expand All @@ -26,20 +26,16 @@ export const HexStr = {
return bytes.isHexString(value, length);
},
isSameAddress(a:string, b:string): boolean {
const A = ethers.utils.getAddress(a);
const B = ethers.utils.getAddress(b);
return A == B;
return getAddress(a) == getAddress(b);
},
isSamePrivKey(a:string, b:string): boolean {
const A = computeAddress(a);
const B = computeAddress(b);
return this.isSameAddress(A, B);
return computeAddress(a) == computeAddress(b);
},
stripZeros(value: any): string {
return bytes.hexlify(bytes.stripZeros(value));
},
zeroPad(value:string, length:number): string {
return ethers.utils.hexZeroPad(value, length);
return bytes.hexZeroPad(value, length);
}
};

Expand Down

0 comments on commit 0dc31ea

Please sign in to comment.