@solana/web3.js 1.30.3 → 1.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -45,7 +45,7 @@ $ npm install --save @solana/web3.js
45
45
  <!-- Development (un-minified) -->
46
46
  <script src="https://unpkg.com/@solana/web3.js@latest/lib/index.iife.js"></script>
47
47
 
48
- <!-- Production (un-minified) -->
48
+ <!-- Production (minified) -->
49
49
  <script src="https://unpkg.com/@solana/web3.js@latest/lib/index.iife.min.js"></script>
50
50
  ```
51
51
 
@@ -88,7 +88,7 @@ console.log(solanaWeb3);
88
88
 
89
89
  Example scripts for the web3.js repo and native programs:
90
90
 
91
- - [Web3 Examples](./examples)
91
+ - [Web3 Examples](https://github.com/solana-labs/solana/tree/master/web3.js/examples)
92
92
 
93
93
  Example scripts for the Solana Program Library:
94
94
 
@@ -1,5 +1,4 @@
1
- import * as nacl from 'tweetnacl';
2
- import nacl__default from 'tweetnacl';
1
+ import nacl from 'tweetnacl';
3
2
  import { Buffer } from 'buffer';
4
3
  import BN from 'bn.js';
5
4
  import bs58 from 'bs58';
@@ -9,7 +8,7 @@ import { coerce, instance, string, tuple, literal, unknown, union, type, optiona
9
8
  import { Client } from 'rpc-websockets';
10
9
  import RpcClient from 'jayson/lib/client/browser';
11
10
  import secp256k1 from 'secp256k1';
12
- import { keccak_256 } from 'js-sha3';
11
+ import sha3 from 'js-sha3';
13
12
 
14
13
  const toBuffer = arr => {
15
14
  if (Buffer.isBuffer(arr)) {
@@ -1918,7 +1917,7 @@ SOLANA_SCHEMA.set(PublicKey, {
1918
1917
  fields: [['_bn', 'u256']]
1919
1918
  }); // @ts-ignore
1920
1919
 
1921
- let naclLowLevel = nacl__default.lowlevel; // Check that a pubkey is on the curve.
1920
+ let naclLowLevel = nacl.lowlevel; // Check that a pubkey is on the curve.
1922
1921
  // This function and its dependents were sourced from:
1923
1922
  // https://github.com/dchest/tweetnacl-js/blob/f1ec050ceae0861f34280e62498b1d3ed9c350c6/nacl.js#L792
1924
1923
 
@@ -2723,7 +2722,7 @@ class Transaction {
2723
2722
  _partialSign(message, ...signers) {
2724
2723
  const signData = message.serialize();
2725
2724
  signers.forEach(signer => {
2726
- const signature = nacl__default.sign.detached(signData, signer.secretKey);
2725
+ const signature = nacl.sign.detached(signData, signer.secretKey);
2727
2726
 
2728
2727
  this._addSignature(signer.publicKey, toBuffer(signature));
2729
2728
  });
@@ -2779,7 +2778,7 @@ class Transaction {
2779
2778
  return false;
2780
2779
  }
2781
2780
  } else {
2782
- if (!nacl__default.sign.detached.verify(signData, signature, publicKey.toBuffer())) {
2781
+ if (!nacl.sign.detached.verify(signData, signature, publicKey.toBuffer())) {
2783
2782
  return false;
2784
2783
  }
2785
2784
  }
@@ -7925,7 +7924,7 @@ class Ed25519Program {
7925
7924
  try {
7926
7925
  const keypair = Keypair.fromSecretKey(privateKey);
7927
7926
  const publicKey = keypair.publicKey.toBytes();
7928
- const signature = nacl__default.sign.detached(message, keypair.secretKey);
7927
+ const signature = nacl.sign.detached(message, keypair.secretKey);
7929
7928
  return this.createInstructionWithPublicKey({
7930
7929
  publicKey,
7931
7930
  message,
@@ -8722,7 +8721,7 @@ class Secp256k1Program {
8722
8721
  assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
8723
8722
 
8724
8723
  try {
8725
- return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8724
+ return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8726
8725
  } catch (error) {
8727
8726
  throw new Error(`Error constructing Ethereum address: ${error}`);
8728
8727
  }
@@ -8820,7 +8819,7 @@ class Secp256k1Program {
8820
8819
  const privateKey = toBuffer(pkey);
8821
8820
  const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
8822
8821
 
8823
- const messageHash = Buffer.from(keccak_256.update(toBuffer(message)).digest());
8822
+ const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
8824
8823
  const {
8825
8824
  signature,
8826
8825
  recid: recoveryId