feat: improve esm compatibility (#21373)
This commit is contained in:
parent
c68a11f715
commit
1aebe655b7
|
@ -1,4 +1,4 @@
|
|||
import * as nacl from 'tweetnacl';
|
||||
import nacl from 'tweetnacl';
|
||||
import type {SignKeyPair as KeyPair} from 'tweetnacl';
|
||||
import type {Buffer} from 'buffer';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as nacl from 'tweetnacl';
|
||||
import nacl from 'tweetnacl';
|
||||
|
||||
import {PublicKey} from './publickey';
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {Buffer} from 'buffer';
|
||||
import * as BufferLayout from '@solana/buffer-layout';
|
||||
import secp256k1 from 'secp256k1';
|
||||
import {keccak_256} from 'js-sha3';
|
||||
import sha3 from 'js-sha3';
|
||||
|
||||
import {PublicKey} from './publickey';
|
||||
import {TransactionInstruction} from './transaction';
|
||||
|
@ -86,9 +86,9 @@ export class Secp256k1Program {
|
|||
);
|
||||
|
||||
try {
|
||||
return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice(
|
||||
-ETHEREUM_ADDRESS_BYTES,
|
||||
);
|
||||
return Buffer.from(
|
||||
sha3.keccak_256.update(toBuffer(publicKey)).digest(),
|
||||
).slice(-ETHEREUM_ADDRESS_BYTES);
|
||||
} catch (error) {
|
||||
throw new Error(`Error constructing Ethereum address: ${error}`);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ export class Secp256k1Program {
|
|||
const privateKey = toBuffer(pkey);
|
||||
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
|
||||
const messageHash = Buffer.from(
|
||||
keccak_256.update(toBuffer(message)).digest(),
|
||||
sha3.keccak_256.update(toBuffer(message)).digest(),
|
||||
);
|
||||
const {signature, recid: recoveryId} = ecdsaSign(messageHash, privateKey);
|
||||
|
||||
|
|
Loading…
Reference in New Issue