@solana/web3.js 1.30.2 → 1.31.0
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
|
|
|
@@ -2693,7 +2692,7 @@ class Transaction {
|
|
|
2693
2692
|
_partialSign(message, ...signers) {
|
|
2694
2693
|
const signData = message.serialize();
|
|
2695
2694
|
signers.forEach(signer => {
|
|
2696
|
-
const signature =
|
|
2695
|
+
const signature = nacl.sign.detached(signData, signer.secretKey);
|
|
2697
2696
|
|
|
2698
2697
|
this._addSignature(signer.publicKey, toBuffer(signature));
|
|
2699
2698
|
});
|
|
@@ -2749,7 +2748,7 @@ class Transaction {
|
|
|
2749
2748
|
return false;
|
|
2750
2749
|
}
|
|
2751
2750
|
} else {
|
|
2752
|
-
if (!
|
|
2751
|
+
if (!nacl.sign.detached.verify(signData, signature, publicKey.toBuffer())) {
|
|
2753
2752
|
return false;
|
|
2754
2753
|
}
|
|
2755
2754
|
}
|
|
@@ -7896,7 +7895,7 @@ class Ed25519Program {
|
|
|
7896
7895
|
try {
|
|
7897
7896
|
const keypair = Keypair.fromSecretKey(privateKey);
|
|
7898
7897
|
const publicKey = keypair.publicKey.toBytes();
|
|
7899
|
-
const signature =
|
|
7898
|
+
const signature = nacl.sign.detached(message, keypair.secretKey);
|
|
7900
7899
|
return this.createInstructionWithPublicKey({
|
|
7901
7900
|
publicKey,
|
|
7902
7901
|
message,
|
|
@@ -8693,7 +8692,7 @@ class Secp256k1Program {
|
|
|
8693
8692
|
assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
|
|
8694
8693
|
|
|
8695
8694
|
try {
|
|
8696
|
-
return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
8695
|
+
return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
8697
8696
|
} catch (error) {
|
|
8698
8697
|
throw new Error(`Error constructing Ethereum address: ${error}`);
|
|
8699
8698
|
}
|
|
@@ -8791,7 +8790,7 @@ class Secp256k1Program {
|
|
|
8791
8790
|
const privateKey = toBuffer(pkey);
|
|
8792
8791
|
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
|
|
8793
8792
|
|
|
8794
|
-
const messageHash = Buffer.from(keccak_256.update(toBuffer(message)).digest());
|
|
8793
|
+
const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
8795
8794
|
const {
|
|
8796
8795
|
signature,
|
|
8797
8796
|
recid: recoveryId
|