fix: replace ethers dependency with @ethersproject/sha2 (#20920)
This commit is contained in:
parent
43ea579f63
commit
b825390752
File diff suppressed because it is too large
Load Diff
|
@ -63,13 +63,13 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@ethersproject/sha2": "^5.5.0",
|
||||
"@solana/buffer-layout": "^3.0.0",
|
||||
"bn.js": "^5.0.0",
|
||||
"borsh": "^0.4.0",
|
||||
"bs58": "^4.0.1",
|
||||
"buffer": "6.0.1",
|
||||
"cross-fetch": "^3.1.4",
|
||||
"ethers": "^5.5.1",
|
||||
"jayson": "^3.4.4",
|
||||
"js-sha3": "^0.8.0",
|
||||
"rpc-websockets": "^7.4.2",
|
||||
|
|
|
@ -2,7 +2,7 @@ import BN from 'bn.js';
|
|||
import bs58 from 'bs58';
|
||||
import {Buffer} from 'buffer';
|
||||
import nacl from 'tweetnacl';
|
||||
import {ethers} from 'ethers';
|
||||
import {sha256} from '@ethersproject/sha2';
|
||||
|
||||
import {Struct, SOLANA_SCHEMA} from './util/borsh-schema';
|
||||
import {toBuffer} from './util/to-buffer';
|
||||
|
@ -131,7 +131,7 @@ export class PublicKey extends Struct {
|
|||
Buffer.from(seed),
|
||||
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'));
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ export class PublicKey extends Struct {
|
|||
programId.toBuffer(),
|
||||
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);
|
||||
if (is_on_curve(publicKeyBytes)) {
|
||||
throw new Error(`Invalid seeds, address must fall off the curve`);
|
||||
|
|
Loading…
Reference in New Issue