@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 +2 -2
- package/lib/index.browser.esm.js +8 -9
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +12 -12
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +8 -9
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +14 -12
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -3
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +7 -7
- package/src/account.ts +1 -1
- package/src/keypair.ts +1 -1
- package/src/secp256k1-program.ts +5 -5
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 (
|
|
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](
|
|
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
|
|
package/lib/index.browser.esm.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
|
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 =
|
|
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 =
|
|
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 (!
|
|
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 =
|
|
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
|