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

Commit

Permalink
feat: improve esm compatibility (#21373)
Browse files Browse the repository at this point in the history
  • Loading branch information
vovacodes authored Nov 24, 2021
1 parent c68a11f commit 1aebe65
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion web3.js/src/account.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion web3.js/src/keypair.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as nacl from 'tweetnacl';
import nacl from 'tweetnacl';

import {PublicKey} from './publickey';

Expand Down
10 changes: 5 additions & 5 deletions web3.js/src/secp256k1-program.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}`);
}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 1aebe65

Please sign in to comment.