@solana/web3.js 1.75.1 → 1.76.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/lib/index.browser.cjs.js +45 -59
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +10 -20
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +59 -73
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +10 -20
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +3104 -1750
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +12 -5
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +45 -59
- package/lib/index.native.js.map +1 -1
- package/package.json +12 -13
- package/src/utils/ed25519.ts +6 -9
- package/src/utils/secp256k1.ts +7 -14
package/lib/index.cjs.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var buffer = require('buffer');
|
|
6
|
-
var
|
|
7
|
-
var ed25519 = require('@noble/ed25519');
|
|
4
|
+
var ed25519 = require('@noble/curves/ed25519');
|
|
8
5
|
var BN = require('bn.js');
|
|
9
6
|
var bs58 = require('bs58');
|
|
10
7
|
var sha256 = require('@noble/hashes/sha256');
|
|
@@ -23,13 +20,12 @@ var nodeFetch = require('node-fetch');
|
|
|
23
20
|
var RpcWebSocketCommonClient = require('rpc-websockets/dist/lib/client');
|
|
24
21
|
var WebsocketFactory = require('rpc-websockets/dist/lib/client/websocket');
|
|
25
22
|
var sha3 = require('@noble/hashes/sha3');
|
|
26
|
-
var
|
|
27
|
-
var secp256k1 = require('@noble/secp256k1');
|
|
23
|
+
var secp256k1 = require('@noble/curves/secp256k1');
|
|
28
24
|
|
|
29
|
-
function
|
|
25
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
30
26
|
|
|
31
|
-
function
|
|
32
|
-
if (e && e
|
|
27
|
+
function _interopNamespaceCompat(e) {
|
|
28
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
33
29
|
var n = Object.create(null);
|
|
34
30
|
if (e) {
|
|
35
31
|
Object.keys(e).forEach(function (k) {
|
|
@@ -42,25 +38,23 @@ function _interopNamespace(e) {
|
|
|
42
38
|
}
|
|
43
39
|
});
|
|
44
40
|
}
|
|
45
|
-
n
|
|
41
|
+
n.default = e;
|
|
46
42
|
return Object.freeze(n);
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var require$$0__default
|
|
54
|
-
var require$$0__default = /*#__PURE__*/
|
|
55
|
-
var require$$
|
|
56
|
-
var require$$
|
|
57
|
-
var require$$0__default$
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var WebsocketFactory__default = /*#__PURE__*/_interopDefaultLegacy(WebsocketFactory);
|
|
63
|
-
var secp256k1__namespace = /*#__PURE__*/_interopNamespace(secp256k1);
|
|
45
|
+
var BN__default = /*#__PURE__*/_interopDefaultCompat(BN);
|
|
46
|
+
var bs58__default = /*#__PURE__*/_interopDefaultCompat(bs58);
|
|
47
|
+
var BufferLayout__namespace = /*#__PURE__*/_interopNamespaceCompat(BufferLayout);
|
|
48
|
+
var require$$0__default$1 = /*#__PURE__*/_interopDefaultCompat(require$$0$1);
|
|
49
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
|
|
50
|
+
var require$$0__default$2 = /*#__PURE__*/_interopDefaultCompat(require$$0$2);
|
|
51
|
+
var require$$1__default = /*#__PURE__*/_interopDefaultCompat(require$$1);
|
|
52
|
+
var require$$0__default$3 = /*#__PURE__*/_interopDefaultCompat(require$$0$3);
|
|
53
|
+
var require$$0__default$4 = /*#__PURE__*/_interopDefaultCompat(require$$0$4);
|
|
54
|
+
var RpcClient__default = /*#__PURE__*/_interopDefaultCompat(RpcClient);
|
|
55
|
+
var nodeFetch__namespace = /*#__PURE__*/_interopNamespaceCompat(nodeFetch);
|
|
56
|
+
var RpcWebSocketCommonClient__default = /*#__PURE__*/_interopDefaultCompat(RpcWebSocketCommonClient);
|
|
57
|
+
var WebsocketFactory__default = /*#__PURE__*/_interopDefaultCompat(WebsocketFactory);
|
|
64
58
|
|
|
65
59
|
/**
|
|
66
60
|
* A 64 byte secret key, the first 32 bytes of which is the
|
|
@@ -68,10 +62,9 @@ var secp256k1__namespace = /*#__PURE__*/_interopNamespace(secp256k1);
|
|
|
68
62
|
* Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
|
|
69
63
|
*/
|
|
70
64
|
|
|
71
|
-
|
|
72
|
-
const generatePrivateKey = ed25519__namespace.utils.randomPrivateKey;
|
|
65
|
+
const generatePrivateKey = ed25519.ed25519.utils.randomPrivateKey;
|
|
73
66
|
const generateKeypair = () => {
|
|
74
|
-
const privateScalar =
|
|
67
|
+
const privateScalar = ed25519.ed25519.utils.randomPrivateKey();
|
|
75
68
|
const publicKey = getPublicKey(privateScalar);
|
|
76
69
|
const secretKey = new Uint8Array(64);
|
|
77
70
|
secretKey.set(privateScalar);
|
|
@@ -81,17 +74,17 @@ const generateKeypair = () => {
|
|
|
81
74
|
secretKey
|
|
82
75
|
};
|
|
83
76
|
};
|
|
84
|
-
const getPublicKey =
|
|
77
|
+
const getPublicKey = ed25519.ed25519.getPublicKey;
|
|
85
78
|
function isOnCurve(publicKey) {
|
|
86
79
|
try {
|
|
87
|
-
|
|
80
|
+
ed25519.ed25519.ExtendedPoint.fromHex(publicKey);
|
|
88
81
|
return true;
|
|
89
82
|
} catch {
|
|
90
83
|
return false;
|
|
91
84
|
}
|
|
92
85
|
}
|
|
93
|
-
const sign = (message, secretKey) =>
|
|
94
|
-
const verify =
|
|
86
|
+
const sign = (message, secretKey) => ed25519.ed25519.sign(message, secretKey.slice(0, 32));
|
|
87
|
+
const verify = ed25519.ed25519.verify;
|
|
95
88
|
|
|
96
89
|
const toBuffer = arr => {
|
|
97
90
|
if (buffer.Buffer.isBuffer(arr)) {
|
|
@@ -177,13 +170,13 @@ class PublicKey extends Struct {
|
|
|
177
170
|
} else {
|
|
178
171
|
if (typeof value === 'string') {
|
|
179
172
|
// assume base 58 encoding by default
|
|
180
|
-
const decoded = bs58__default
|
|
173
|
+
const decoded = bs58__default.default.decode(value);
|
|
181
174
|
if (decoded.length != PUBLIC_KEY_LENGTH) {
|
|
182
175
|
throw new Error(`Invalid public key input`);
|
|
183
176
|
}
|
|
184
|
-
this._bn = new BN__default
|
|
177
|
+
this._bn = new BN__default.default(decoded);
|
|
185
178
|
} else {
|
|
186
|
-
this._bn = new BN__default
|
|
179
|
+
this._bn = new BN__default.default(value);
|
|
187
180
|
}
|
|
188
181
|
if (this._bn.byteLength() > PUBLIC_KEY_LENGTH) {
|
|
189
182
|
throw new Error(`Invalid public key input`);
|
|
@@ -216,7 +209,7 @@ class PublicKey extends Struct {
|
|
|
216
209
|
* Return the base-58 representation of the public key
|
|
217
210
|
*/
|
|
218
211
|
toBase58() {
|
|
219
|
-
return bs58__default
|
|
212
|
+
return bs58__default.default.encode(this.toBytes());
|
|
220
213
|
}
|
|
221
214
|
toJSON() {
|
|
222
215
|
return this.toBase58();
|
|
@@ -773,7 +766,7 @@ class Message {
|
|
|
773
766
|
return this.instructions.map(ix => ({
|
|
774
767
|
programIdIndex: ix.programIdIndex,
|
|
775
768
|
accountKeyIndexes: ix.accounts,
|
|
776
|
-
data: bs58__default
|
|
769
|
+
data: bs58__default.default.decode(ix.data)
|
|
777
770
|
}));
|
|
778
771
|
}
|
|
779
772
|
get addressTableLookups() {
|
|
@@ -789,7 +782,7 @@ class Message {
|
|
|
789
782
|
const instructions = accountKeys.compileInstructions(args.instructions).map(ix => ({
|
|
790
783
|
programIdIndex: ix.programIdIndex,
|
|
791
784
|
accounts: ix.accountKeyIndexes,
|
|
792
|
-
data: bs58__default
|
|
785
|
+
data: bs58__default.default.encode(ix.data)
|
|
793
786
|
}));
|
|
794
787
|
return new Message({
|
|
795
788
|
header,
|
|
@@ -831,7 +824,7 @@ class Message {
|
|
|
831
824
|
accounts,
|
|
832
825
|
programIdIndex
|
|
833
826
|
} = instruction;
|
|
834
|
-
const data = Array.from(bs58__default
|
|
827
|
+
const data = Array.from(bs58__default.default.decode(instruction.data));
|
|
835
828
|
let keyIndicesCount = [];
|
|
836
829
|
encodeLength(keyIndicesCount, accounts.length);
|
|
837
830
|
let dataCount = [];
|
|
@@ -862,7 +855,7 @@ class Message {
|
|
|
862
855
|
numReadonlyUnsignedAccounts: buffer.Buffer.from([this.header.numReadonlyUnsignedAccounts]),
|
|
863
856
|
keyCount: buffer.Buffer.from(keyCount),
|
|
864
857
|
keys: this.accountKeys.map(key => toBuffer(key.toBytes())),
|
|
865
|
-
recentBlockhash: bs58__default
|
|
858
|
+
recentBlockhash: bs58__default.default.decode(this.recentBlockhash)
|
|
866
859
|
};
|
|
867
860
|
let signData = buffer.Buffer.alloc(2048);
|
|
868
861
|
const length = signDataLayout.encode(transaction, signData);
|
|
@@ -897,7 +890,7 @@ class Message {
|
|
|
897
890
|
const accounts = guardedSplice(byteArray, 0, accountCount);
|
|
898
891
|
const dataLength = decodeLength(byteArray);
|
|
899
892
|
const dataSlice = guardedSplice(byteArray, 0, dataLength);
|
|
900
|
-
const data = bs58__default
|
|
893
|
+
const data = bs58__default.default.encode(buffer.Buffer.from(dataSlice));
|
|
901
894
|
instructions.push({
|
|
902
895
|
programIdIndex,
|
|
903
896
|
accounts,
|
|
@@ -910,7 +903,7 @@ class Message {
|
|
|
910
903
|
numReadonlySignedAccounts,
|
|
911
904
|
numReadonlyUnsignedAccounts
|
|
912
905
|
},
|
|
913
|
-
recentBlockhash: bs58__default
|
|
906
|
+
recentBlockhash: bs58__default.default.encode(buffer.Buffer.from(recentBlockhash)),
|
|
914
907
|
accountKeys,
|
|
915
908
|
instructions
|
|
916
909
|
};
|
|
@@ -1054,7 +1047,7 @@ class MessageV0 {
|
|
|
1054
1047
|
header: this.header,
|
|
1055
1048
|
staticAccountKeysLength: new Uint8Array(encodedStaticAccountKeysLength),
|
|
1056
1049
|
staticAccountKeys: this.staticAccountKeys.map(key => key.toBytes()),
|
|
1057
|
-
recentBlockhash: bs58__default
|
|
1050
|
+
recentBlockhash: bs58__default.default.decode(this.recentBlockhash),
|
|
1058
1051
|
instructionsLength: new Uint8Array(encodedInstructionsLength),
|
|
1059
1052
|
serializedInstructions,
|
|
1060
1053
|
addressTableLookupsLength: new Uint8Array(encodedAddressTableLookupsLength),
|
|
@@ -1117,7 +1110,7 @@ class MessageV0 {
|
|
|
1117
1110
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
1118
1111
|
staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
|
|
1119
1112
|
}
|
|
1120
|
-
const recentBlockhash = bs58__default
|
|
1113
|
+
const recentBlockhash = bs58__default.default.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
|
|
1121
1114
|
const instructionCount = decodeLength(byteArray);
|
|
1122
1115
|
const compiledInstructions = [];
|
|
1123
1116
|
for (let i = 0; i < instructionCount; i++) {
|
|
@@ -1523,7 +1516,7 @@ class Transaction {
|
|
|
1523
1516
|
return {
|
|
1524
1517
|
programIdIndex: accountKeys.indexOf(programId.toString()),
|
|
1525
1518
|
accounts: instruction.keys.map(meta => accountKeys.indexOf(meta.pubkey.toString())),
|
|
1526
|
-
data: bs58__default
|
|
1519
|
+
data: bs58__default.default.encode(data)
|
|
1527
1520
|
};
|
|
1528
1521
|
});
|
|
1529
1522
|
compiledInstructions.forEach(instruction => {
|
|
@@ -1815,7 +1808,7 @@ class Transaction {
|
|
|
1815
1808
|
let signatures = [];
|
|
1816
1809
|
for (let i = 0; i < signatureCount; i++) {
|
|
1817
1810
|
const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
|
|
1818
|
-
signatures.push(bs58__default
|
|
1811
|
+
signatures.push(bs58__default.default.encode(buffer.Buffer.from(signature)));
|
|
1819
1812
|
}
|
|
1820
1813
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
1821
1814
|
}
|
|
@@ -1831,7 +1824,7 @@ class Transaction {
|
|
|
1831
1824
|
}
|
|
1832
1825
|
signatures.forEach((signature, index) => {
|
|
1833
1826
|
const sigPubkeyPair = {
|
|
1834
|
-
signature: signature == bs58__default
|
|
1827
|
+
signature: signature == bs58__default.default.encode(DEFAULT_SIGNATURE) ? null : bs58__default.default.decode(signature),
|
|
1835
1828
|
publicKey: message.accountKeys[index]
|
|
1836
1829
|
};
|
|
1837
1830
|
transaction.signatures.push(sigPubkeyPair);
|
|
@@ -1848,7 +1841,7 @@ class Transaction {
|
|
|
1848
1841
|
transaction.instructions.push(new TransactionInstruction({
|
|
1849
1842
|
keys,
|
|
1850
1843
|
programId: message.accountKeys[instruction.programIdIndex],
|
|
1851
|
-
data: bs58__default
|
|
1844
|
+
data: bs58__default.default.decode(instruction.data)
|
|
1852
1845
|
}));
|
|
1853
1846
|
});
|
|
1854
1847
|
transaction._message = message;
|
|
@@ -3246,7 +3239,7 @@ function plural(ms, msAbs, n, name) {
|
|
|
3246
3239
|
* Module dependencies.
|
|
3247
3240
|
*/
|
|
3248
3241
|
|
|
3249
|
-
var util = require$$0__default
|
|
3242
|
+
var util = require$$0__default.default;
|
|
3250
3243
|
var ms$2 = ms$3;
|
|
3251
3244
|
|
|
3252
3245
|
var humanizeMs = function (t) {
|
|
@@ -4052,8 +4045,8 @@ function requireNode () {
|
|
|
4052
4045
|
if (hasRequiredNode) return nodeExports;
|
|
4053
4046
|
hasRequiredNode = 1;
|
|
4054
4047
|
(function (module, exports) {
|
|
4055
|
-
const tty = require$$0__default$1
|
|
4056
|
-
const util = require$$0__default
|
|
4048
|
+
const tty = require$$0__default$1.default;
|
|
4049
|
+
const util = require$$0__default.default;
|
|
4057
4050
|
|
|
4058
4051
|
/**
|
|
4059
4052
|
* This is the Node.js implementation of `debug()`.
|
|
@@ -4488,7 +4481,7 @@ function requireEventListenerCount () {
|
|
|
4488
4481
|
* @private
|
|
4489
4482
|
*/
|
|
4490
4483
|
|
|
4491
|
-
var EventEmitter = require$$0__default$2
|
|
4484
|
+
var EventEmitter = require$$0__default$2.default.EventEmitter;
|
|
4492
4485
|
|
|
4493
4486
|
/**
|
|
4494
4487
|
* Module exports.
|
|
@@ -4568,7 +4561,7 @@ function requireEventListenerCount () {
|
|
|
4568
4561
|
|
|
4569
4562
|
var callSiteToString = compatExports.callSiteToString;
|
|
4570
4563
|
var eventListenerCount = compatExports.eventListenerCount;
|
|
4571
|
-
var relative = require$$1__default
|
|
4564
|
+
var relative = require$$1__default.default.relative;
|
|
4572
4565
|
|
|
4573
4566
|
/**
|
|
4574
4567
|
* Module exports.
|
|
@@ -5091,7 +5084,7 @@ var constants = {
|
|
|
5091
5084
|
SOCKET_REQUEST_FINISHED_COUNT: Symbol('agentkeepalive#socketRequestFinishedCount'),
|
|
5092
5085
|
};
|
|
5093
5086
|
|
|
5094
|
-
const OriginalAgent = require$$0__default$3
|
|
5087
|
+
const OriginalAgent = require$$0__default$3.default.Agent;
|
|
5095
5088
|
const ms = humanizeMs;
|
|
5096
5089
|
const debug = srcExports('agentkeepalive');
|
|
5097
5090
|
const deprecate = depd_1('agentkeepalive');
|
|
@@ -5488,7 +5481,7 @@ function inspect(obj) {
|
|
|
5488
5481
|
return res;
|
|
5489
5482
|
}
|
|
5490
5483
|
|
|
5491
|
-
const OriginalHttpsAgent = require$$0__default$4
|
|
5484
|
+
const OriginalHttpsAgent = require$$0__default$4.default.Agent;
|
|
5492
5485
|
const HttpAgent = agent;
|
|
5493
5486
|
const {
|
|
5494
5487
|
INIT_SOCKET,
|
|
@@ -5760,10 +5753,10 @@ async function fetchImpl (input, init) {
|
|
|
5760
5753
|
return await nodeFetch__namespace.default(processedInput, init);
|
|
5761
5754
|
}
|
|
5762
5755
|
|
|
5763
|
-
class RpcWebSocketClient extends RpcWebSocketCommonClient__default
|
|
5756
|
+
class RpcWebSocketClient extends RpcWebSocketCommonClient__default.default {
|
|
5764
5757
|
constructor(address, options, generate_request_id) {
|
|
5765
5758
|
const webSocketFactory = url => {
|
|
5766
|
-
const rpc = WebsocketFactory__default
|
|
5759
|
+
const rpc = WebsocketFactory__default.default(url, {
|
|
5767
5760
|
autoconnect: true,
|
|
5768
5761
|
max_reconnects: 5,
|
|
5769
5762
|
reconnect: true,
|
|
@@ -6017,7 +6010,7 @@ function versionedMessageFromResponse(version, response) {
|
|
|
6017
6010
|
compiledInstructions: response.instructions.map(ix => ({
|
|
6018
6011
|
programIdIndex: ix.programIdIndex,
|
|
6019
6012
|
accountKeyIndexes: ix.accounts,
|
|
6020
|
-
data: bs58__default
|
|
6013
|
+
data: bs58__default.default.decode(ix.data)
|
|
6021
6014
|
})),
|
|
6022
6015
|
addressTableLookups: response.addressTableLookups
|
|
6023
6016
|
});
|
|
@@ -6201,7 +6194,7 @@ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disable
|
|
|
6201
6194
|
return await fetch(...modifiedFetchArgs);
|
|
6202
6195
|
};
|
|
6203
6196
|
}
|
|
6204
|
-
const clientBrowser = new RpcClient__default
|
|
6197
|
+
const clientBrowser = new RpcClient__default.default(async (request, callback) => {
|
|
6205
6198
|
const options = {
|
|
6206
6199
|
method: 'POST',
|
|
6207
6200
|
body: request,
|
|
@@ -6984,7 +6977,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
6984
6977
|
|
|
6985
6978
|
/** @internal */
|
|
6986
6979
|
const COMMON_HTTP_HEADERS = {
|
|
6987
|
-
'solana-client': `js/${"1.
|
|
6980
|
+
'solana-client': `js/${"1.76.1" }`
|
|
6988
6981
|
};
|
|
6989
6982
|
|
|
6990
6983
|
/**
|
|
@@ -7520,7 +7513,7 @@ class Connection {
|
|
|
7520
7513
|
}
|
|
7521
7514
|
let decodedSignature;
|
|
7522
7515
|
try {
|
|
7523
|
-
decodedSignature = bs58__default
|
|
7516
|
+
decodedSignature = bs58__default.default.decode(rawSignature);
|
|
7524
7517
|
} catch (err) {
|
|
7525
7518
|
throw new Error('signature must be base58 encoded: ' + rawSignature);
|
|
7526
7519
|
}
|
|
@@ -10445,19 +10438,12 @@ class Ed25519Program {
|
|
|
10445
10438
|
}
|
|
10446
10439
|
Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
|
|
10447
10440
|
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
const h = hmac.hmac.create(sha256.sha256, key);
|
|
10452
|
-
msgs.forEach(msg => h.update(msg));
|
|
10453
|
-
return h.digest();
|
|
10441
|
+
const ecdsaSign = (msgHash, privKey) => {
|
|
10442
|
+
const signature = secp256k1.secp256k1.sign(msgHash, privKey);
|
|
10443
|
+
return [signature.toCompactRawBytes(), signature.recovery];
|
|
10454
10444
|
};
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
recovered: true
|
|
10458
|
-
});
|
|
10459
|
-
secp256k1__namespace.utils.isValidPrivateKey;
|
|
10460
|
-
const publicKeyCreate = secp256k1__namespace.getPublicKey;
|
|
10445
|
+
secp256k1.secp256k1.utils.isValidPrivateKey;
|
|
10446
|
+
const publicKeyCreate = secp256k1.secp256k1.getPublicKey;
|
|
10461
10447
|
|
|
10462
10448
|
const PRIVATE_KEY_BYTES = 32;
|
|
10463
10449
|
const ETHEREUM_ADDRESS_BYTES = 20;
|