fix: replace ethers dependency with @ethersproject/sha2 (#20920)
This commit is contained in:
committed by
GitHub
parent
43ea579f63
commit
b825390752
1102
web3.js/package-lock.json
generated
1102
web3.js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -63,13 +63,13 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
|
"@ethersproject/sha2": "^5.5.0",
|
||||||
"@solana/buffer-layout": "^3.0.0",
|
"@solana/buffer-layout": "^3.0.0",
|
||||||
"bn.js": "^5.0.0",
|
"bn.js": "^5.0.0",
|
||||||
"borsh": "^0.4.0",
|
"borsh": "^0.4.0",
|
||||||
"bs58": "^4.0.1",
|
"bs58": "^4.0.1",
|
||||||
"buffer": "6.0.1",
|
"buffer": "6.0.1",
|
||||||
"cross-fetch": "^3.1.4",
|
"cross-fetch": "^3.1.4",
|
||||||
"ethers": "^5.5.1",
|
|
||||||
"jayson": "^3.4.4",
|
"jayson": "^3.4.4",
|
||||||
"js-sha3": "^0.8.0",
|
"js-sha3": "^0.8.0",
|
||||||
"rpc-websockets": "^7.4.2",
|
"rpc-websockets": "^7.4.2",
|
||||||
|
@ -2,7 +2,7 @@ import BN from 'bn.js';
|
|||||||
import bs58 from 'bs58';
|
import bs58 from 'bs58';
|
||||||
import {Buffer} from 'buffer';
|
import {Buffer} from 'buffer';
|
||||||
import nacl from 'tweetnacl';
|
import nacl from 'tweetnacl';
|
||||||
import {ethers} from 'ethers';
|
import {sha256} from '@ethersproject/sha2';
|
||||||
|
|
||||||
import {Struct, SOLANA_SCHEMA} from './util/borsh-schema';
|
import {Struct, SOLANA_SCHEMA} from './util/borsh-schema';
|
||||||
import {toBuffer} from './util/to-buffer';
|
import {toBuffer} from './util/to-buffer';
|
||||||
@ -131,7 +131,7 @@ export class PublicKey extends Struct {
|
|||||||
Buffer.from(seed),
|
Buffer.from(seed),
|
||||||
programId.toBuffer(),
|
programId.toBuffer(),
|
||||||
]);
|
]);
|
||||||
const hash = ethers.utils.sha256(new Uint8Array(buffer)).slice(2);
|
const hash = sha256(new Uint8Array(buffer)).slice(2);
|
||||||
return new PublicKey(Buffer.from(hash, 'hex'));
|
return new PublicKey(Buffer.from(hash, 'hex'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ export class PublicKey extends Struct {
|
|||||||
programId.toBuffer(),
|
programId.toBuffer(),
|
||||||
Buffer.from('ProgramDerivedAddress'),
|
Buffer.from('ProgramDerivedAddress'),
|
||||||
]);
|
]);
|
||||||
let hash = ethers.utils.sha256(new Uint8Array(buffer)).slice(2);
|
let hash = sha256(new Uint8Array(buffer)).slice(2);
|
||||||
let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
|
let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
|
||||||
if (is_on_curve(publicKeyBytes)) {
|
if (is_on_curve(publicKeyBytes)) {
|
||||||
throw new Error(`Invalid seeds, address must fall off the curve`);
|
throw new Error(`Invalid seeds, address must fall off the curve`);
|
||||||
|
Reference in New Issue
Block a user