Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 168d5e0

Browse files
authoredNov 24, 2021
feat: improve esm compatibility (#21373)
1 parent b45f065 commit 168d5e0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed
 

‎src/account.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as nacl from 'tweetnacl';
1+
import nacl from 'tweetnacl';
22
import type {SignKeyPair as KeyPair} from 'tweetnacl';
33
import type {Buffer} from 'buffer';
44

‎src/keypair.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as nacl from 'tweetnacl';
1+
import nacl from 'tweetnacl';
22

33
import {PublicKey} from './publickey';
44

‎src/secp256k1-program.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Buffer} from 'buffer';
22
import * as BufferLayout from '@solana/buffer-layout';
33
import secp256k1 from 'secp256k1';
4-
import {keccak_256} from 'js-sha3';
4+
import sha3 from 'js-sha3';
55

66
import {PublicKey} from './publickey';
77
import {TransactionInstruction} from './transaction';
@@ -86,9 +86,9 @@ export class Secp256k1Program {
8686
);
8787

8888
try {
89-
return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice(
90-
-ETHEREUM_ADDRESS_BYTES,
91-
);
89+
return Buffer.from(
90+
sha3.keccak_256.update(toBuffer(publicKey)).digest(),
91+
).slice(-ETHEREUM_ADDRESS_BYTES);
9292
} catch (error) {
9393
throw new Error(`Error constructing Ethereum address: ${error}`);
9494
}
@@ -197,7 +197,7 @@ export class Secp256k1Program {
197197
const privateKey = toBuffer(pkey);
198198
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
199199
const messageHash = Buffer.from(
200-
keccak_256.update(toBuffer(message)).digest(),
200+
sha3.keccak_256.update(toBuffer(message)).digest(),
201201
);
202202
const {signature, recid: recoveryId} = ecdsaSign(messageHash, privateKey);
203203

0 commit comments

Comments
 (0)
This repository has been archived.