@solana/web3.js 1.75.0 → 1.77.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/lib/index.browser.cjs.js +106 -90
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +71 -51
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +120 -104
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +15 -9
- package/lib/index.esm.js +71 -51
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +3165 -1781
- 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 +106 -90
- package/lib/index.native.js.map +1 -1
- package/package.json +12 -13
- package/src/connection.ts +30 -8
- package/src/loader.ts +34 -3
- package/src/programs/vote.ts +3 -1
- 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();
|
|
@@ -648,8 +641,8 @@ class CompiledKeys {
|
|
|
648
641
|
getOrInsertDefault(ix.programId).isInvoked = true;
|
|
649
642
|
for (const accountMeta of ix.keys) {
|
|
650
643
|
const keyMeta = getOrInsertDefault(accountMeta.pubkey);
|
|
651
|
-
keyMeta.isSigner
|
|
652
|
-
keyMeta.isWritable
|
|
644
|
+
keyMeta.isSigner ||= accountMeta.isSigner;
|
|
645
|
+
keyMeta.isWritable ||= accountMeta.isWritable;
|
|
653
646
|
}
|
|
654
647
|
}
|
|
655
648
|
return new CompiledKeys(payer, keyMetaMap);
|
|
@@ -748,7 +741,7 @@ class Message {
|
|
|
748
741
|
return this.instructions.map(ix => ({
|
|
749
742
|
programIdIndex: ix.programIdIndex,
|
|
750
743
|
accountKeyIndexes: ix.accounts,
|
|
751
|
-
data: bs58__default
|
|
744
|
+
data: bs58__default.default.decode(ix.data)
|
|
752
745
|
}));
|
|
753
746
|
}
|
|
754
747
|
get addressTableLookups() {
|
|
@@ -764,7 +757,7 @@ class Message {
|
|
|
764
757
|
const instructions = accountKeys.compileInstructions(args.instructions).map(ix => ({
|
|
765
758
|
programIdIndex: ix.programIdIndex,
|
|
766
759
|
accounts: ix.accountKeyIndexes,
|
|
767
|
-
data: bs58__default
|
|
760
|
+
data: bs58__default.default.encode(ix.data)
|
|
768
761
|
}));
|
|
769
762
|
return new Message({
|
|
770
763
|
header,
|
|
@@ -806,7 +799,7 @@ class Message {
|
|
|
806
799
|
accounts,
|
|
807
800
|
programIdIndex
|
|
808
801
|
} = instruction;
|
|
809
|
-
const data = Array.from(bs58__default
|
|
802
|
+
const data = Array.from(bs58__default.default.decode(instruction.data));
|
|
810
803
|
let keyIndicesCount = [];
|
|
811
804
|
encodeLength(keyIndicesCount, accounts.length);
|
|
812
805
|
let dataCount = [];
|
|
@@ -837,7 +830,7 @@ class Message {
|
|
|
837
830
|
numReadonlyUnsignedAccounts: buffer.Buffer.from([this.header.numReadonlyUnsignedAccounts]),
|
|
838
831
|
keyCount: buffer.Buffer.from(keyCount),
|
|
839
832
|
keys: this.accountKeys.map(key => toBuffer(key.toBytes())),
|
|
840
|
-
recentBlockhash: bs58__default
|
|
833
|
+
recentBlockhash: bs58__default.default.decode(this.recentBlockhash)
|
|
841
834
|
};
|
|
842
835
|
let signData = buffer.Buffer.alloc(2048);
|
|
843
836
|
const length = signDataLayout.encode(transaction, signData);
|
|
@@ -875,7 +868,7 @@ class Message {
|
|
|
875
868
|
byteArray = byteArray.slice(accountCount);
|
|
876
869
|
const dataLength = decodeLength(byteArray);
|
|
877
870
|
const dataSlice = byteArray.slice(0, dataLength);
|
|
878
|
-
const data = bs58__default
|
|
871
|
+
const data = bs58__default.default.encode(buffer.Buffer.from(dataSlice));
|
|
879
872
|
byteArray = byteArray.slice(dataLength);
|
|
880
873
|
instructions.push({
|
|
881
874
|
programIdIndex,
|
|
@@ -889,7 +882,7 @@ class Message {
|
|
|
889
882
|
numReadonlySignedAccounts,
|
|
890
883
|
numReadonlyUnsignedAccounts
|
|
891
884
|
},
|
|
892
|
-
recentBlockhash: bs58__default
|
|
885
|
+
recentBlockhash: bs58__default.default.encode(buffer.Buffer.from(recentBlockhash)),
|
|
893
886
|
accountKeys,
|
|
894
887
|
instructions
|
|
895
888
|
};
|
|
@@ -1033,7 +1026,7 @@ class MessageV0 {
|
|
|
1033
1026
|
header: this.header,
|
|
1034
1027
|
staticAccountKeysLength: new Uint8Array(encodedStaticAccountKeysLength),
|
|
1035
1028
|
staticAccountKeys: this.staticAccountKeys.map(key => key.toBytes()),
|
|
1036
|
-
recentBlockhash: bs58__default
|
|
1029
|
+
recentBlockhash: bs58__default.default.decode(this.recentBlockhash),
|
|
1037
1030
|
instructionsLength: new Uint8Array(encodedInstructionsLength),
|
|
1038
1031
|
serializedInstructions,
|
|
1039
1032
|
addressTableLookupsLength: new Uint8Array(encodedAddressTableLookupsLength),
|
|
@@ -1096,7 +1089,7 @@ class MessageV0 {
|
|
|
1096
1089
|
for (let i = 0; i < staticAccountKeysLength; i++) {
|
|
1097
1090
|
staticAccountKeys.push(new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH)));
|
|
1098
1091
|
}
|
|
1099
|
-
const recentBlockhash = bs58__default
|
|
1092
|
+
const recentBlockhash = bs58__default.default.encode(byteArray.splice(0, PUBLIC_KEY_LENGTH));
|
|
1100
1093
|
const instructionCount = decodeLength(byteArray);
|
|
1101
1094
|
const compiledInstructions = [];
|
|
1102
1095
|
for (let i = 0; i < instructionCount; i++) {
|
|
@@ -1502,7 +1495,7 @@ class Transaction {
|
|
|
1502
1495
|
return {
|
|
1503
1496
|
programIdIndex: accountKeys.indexOf(programId.toString()),
|
|
1504
1497
|
accounts: instruction.keys.map(meta => accountKeys.indexOf(meta.pubkey.toString())),
|
|
1505
|
-
data: bs58__default
|
|
1498
|
+
data: bs58__default.default.encode(data)
|
|
1506
1499
|
};
|
|
1507
1500
|
});
|
|
1508
1501
|
compiledInstructions.forEach(instruction => {
|
|
@@ -1795,7 +1788,7 @@ class Transaction {
|
|
|
1795
1788
|
for (let i = 0; i < signatureCount; i++) {
|
|
1796
1789
|
const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
|
|
1797
1790
|
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
1798
|
-
signatures.push(bs58__default
|
|
1791
|
+
signatures.push(bs58__default.default.encode(buffer.Buffer.from(signature)));
|
|
1799
1792
|
}
|
|
1800
1793
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
1801
1794
|
}
|
|
@@ -1811,7 +1804,7 @@ class Transaction {
|
|
|
1811
1804
|
}
|
|
1812
1805
|
signatures.forEach((signature, index) => {
|
|
1813
1806
|
const sigPubkeyPair = {
|
|
1814
|
-
signature: signature == bs58__default
|
|
1807
|
+
signature: signature == bs58__default.default.encode(DEFAULT_SIGNATURE) ? null : bs58__default.default.decode(signature),
|
|
1815
1808
|
publicKey: message.accountKeys[index]
|
|
1816
1809
|
};
|
|
1817
1810
|
transaction.signatures.push(sigPubkeyPair);
|
|
@@ -1828,7 +1821,7 @@ class Transaction {
|
|
|
1828
1821
|
transaction.instructions.push(new TransactionInstruction({
|
|
1829
1822
|
keys,
|
|
1830
1823
|
programId: message.accountKeys[instruction.programIdIndex],
|
|
1831
|
-
data: bs58__default
|
|
1824
|
+
data: bs58__default.default.decode(instruction.data)
|
|
1832
1825
|
}));
|
|
1833
1826
|
});
|
|
1834
1827
|
transaction._message = message;
|
|
@@ -1987,6 +1980,29 @@ class VersionedTransaction {
|
|
|
1987
1980
|
}
|
|
1988
1981
|
}
|
|
1989
1982
|
|
|
1983
|
+
// TODO: These constants should be removed in favor of reading them out of a
|
|
1984
|
+
// Syscall account
|
|
1985
|
+
|
|
1986
|
+
/**
|
|
1987
|
+
* @internal
|
|
1988
|
+
*/
|
|
1989
|
+
const NUM_TICKS_PER_SECOND = 160;
|
|
1990
|
+
|
|
1991
|
+
/**
|
|
1992
|
+
* @internal
|
|
1993
|
+
*/
|
|
1994
|
+
const DEFAULT_TICKS_PER_SLOT = 64;
|
|
1995
|
+
|
|
1996
|
+
/**
|
|
1997
|
+
* @internal
|
|
1998
|
+
*/
|
|
1999
|
+
const NUM_SLOTS_PER_SECOND = NUM_TICKS_PER_SECOND / DEFAULT_TICKS_PER_SLOT;
|
|
2000
|
+
|
|
2001
|
+
/**
|
|
2002
|
+
* @internal
|
|
2003
|
+
*/
|
|
2004
|
+
const MS_PER_SLOT = 1000 / NUM_SLOTS_PER_SECOND;
|
|
2005
|
+
|
|
1990
2006
|
const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
|
|
1991
2007
|
const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
|
|
1992
2008
|
const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
|
|
@@ -3001,9 +3017,37 @@ class Loader {
|
|
|
3001
3017
|
programId,
|
|
3002
3018
|
data
|
|
3003
3019
|
});
|
|
3004
|
-
|
|
3005
|
-
|
|
3020
|
+
const deployCommitment = 'processed';
|
|
3021
|
+
const finalizeSignature = await connection.sendTransaction(transaction, [payer, program], {
|
|
3022
|
+
preflightCommitment: deployCommitment
|
|
3006
3023
|
});
|
|
3024
|
+
const {
|
|
3025
|
+
context,
|
|
3026
|
+
value
|
|
3027
|
+
} = await connection.confirmTransaction({
|
|
3028
|
+
signature: finalizeSignature,
|
|
3029
|
+
lastValidBlockHeight: transaction.lastValidBlockHeight,
|
|
3030
|
+
blockhash: transaction.recentBlockhash
|
|
3031
|
+
}, deployCommitment);
|
|
3032
|
+
if (value.err) {
|
|
3033
|
+
throw new Error(`Transaction ${finalizeSignature} failed (${JSON.stringify(value)})`);
|
|
3034
|
+
}
|
|
3035
|
+
// We prevent programs from being usable until the slot after their deployment.
|
|
3036
|
+
// See https://github.com/solana-labs/solana/pull/29654
|
|
3037
|
+
while (true // eslint-disable-line no-constant-condition
|
|
3038
|
+
) {
|
|
3039
|
+
try {
|
|
3040
|
+
const currentSlot = await connection.getSlot({
|
|
3041
|
+
commitment: deployCommitment
|
|
3042
|
+
});
|
|
3043
|
+
if (currentSlot > context.slot) {
|
|
3044
|
+
break;
|
|
3045
|
+
}
|
|
3046
|
+
} catch {
|
|
3047
|
+
/* empty */
|
|
3048
|
+
}
|
|
3049
|
+
await new Promise(resolve => setTimeout(resolve, Math.round(MS_PER_SLOT / 2)));
|
|
3050
|
+
}
|
|
3007
3051
|
}
|
|
3008
3052
|
|
|
3009
3053
|
// success
|
|
@@ -3226,7 +3270,7 @@ function plural(ms, msAbs, n, name) {
|
|
|
3226
3270
|
* Module dependencies.
|
|
3227
3271
|
*/
|
|
3228
3272
|
|
|
3229
|
-
var util = require$$0__default
|
|
3273
|
+
var util = require$$0__default.default;
|
|
3230
3274
|
var ms$2 = ms$3;
|
|
3231
3275
|
|
|
3232
3276
|
var humanizeMs = function (t) {
|
|
@@ -4032,8 +4076,8 @@ function requireNode () {
|
|
|
4032
4076
|
if (hasRequiredNode) return nodeExports;
|
|
4033
4077
|
hasRequiredNode = 1;
|
|
4034
4078
|
(function (module, exports) {
|
|
4035
|
-
const tty = require$$0__default$1
|
|
4036
|
-
const util = require$$0__default
|
|
4079
|
+
const tty = require$$0__default$1.default;
|
|
4080
|
+
const util = require$$0__default.default;
|
|
4037
4081
|
|
|
4038
4082
|
/**
|
|
4039
4083
|
* This is the Node.js implementation of `debug()`.
|
|
@@ -4468,7 +4512,7 @@ function requireEventListenerCount () {
|
|
|
4468
4512
|
* @private
|
|
4469
4513
|
*/
|
|
4470
4514
|
|
|
4471
|
-
var EventEmitter = require$$0__default$2
|
|
4515
|
+
var EventEmitter = require$$0__default$2.default.EventEmitter;
|
|
4472
4516
|
|
|
4473
4517
|
/**
|
|
4474
4518
|
* Module exports.
|
|
@@ -4548,7 +4592,7 @@ function requireEventListenerCount () {
|
|
|
4548
4592
|
|
|
4549
4593
|
var callSiteToString = compatExports.callSiteToString;
|
|
4550
4594
|
var eventListenerCount = compatExports.eventListenerCount;
|
|
4551
|
-
var relative = require$$1__default
|
|
4595
|
+
var relative = require$$1__default.default.relative;
|
|
4552
4596
|
|
|
4553
4597
|
/**
|
|
4554
4598
|
* Module exports.
|
|
@@ -5071,7 +5115,7 @@ var constants = {
|
|
|
5071
5115
|
SOCKET_REQUEST_FINISHED_COUNT: Symbol('agentkeepalive#socketRequestFinishedCount'),
|
|
5072
5116
|
};
|
|
5073
5117
|
|
|
5074
|
-
const OriginalAgent = require$$0__default$3
|
|
5118
|
+
const OriginalAgent = require$$0__default$3.default.Agent;
|
|
5075
5119
|
const ms = humanizeMs;
|
|
5076
5120
|
const debug = srcExports('agentkeepalive');
|
|
5077
5121
|
const deprecate = depd_1('agentkeepalive');
|
|
@@ -5468,7 +5512,7 @@ function inspect(obj) {
|
|
|
5468
5512
|
return res;
|
|
5469
5513
|
}
|
|
5470
5514
|
|
|
5471
|
-
const OriginalHttpsAgent = require$$0__default$4
|
|
5515
|
+
const OriginalHttpsAgent = require$$0__default$4.default.Agent;
|
|
5472
5516
|
const HttpAgent = agent;
|
|
5473
5517
|
const {
|
|
5474
5518
|
INIT_SOCKET,
|
|
@@ -5740,10 +5784,10 @@ async function fetchImpl (input, init) {
|
|
|
5740
5784
|
return await nodeFetch__namespace.default(processedInput, init);
|
|
5741
5785
|
}
|
|
5742
5786
|
|
|
5743
|
-
class RpcWebSocketClient extends RpcWebSocketCommonClient__default
|
|
5787
|
+
class RpcWebSocketClient extends RpcWebSocketCommonClient__default.default {
|
|
5744
5788
|
constructor(address, options, generate_request_id) {
|
|
5745
5789
|
const webSocketFactory = url => {
|
|
5746
|
-
const rpc = WebsocketFactory__default
|
|
5790
|
+
const rpc = WebsocketFactory__default.default(url, {
|
|
5747
5791
|
autoconnect: true,
|
|
5748
5792
|
max_reconnects: 5,
|
|
5749
5793
|
reconnect: true,
|
|
@@ -5776,29 +5820,6 @@ class RpcWebSocketClient extends RpcWebSocketCommonClient__default["default"] {
|
|
|
5776
5820
|
}
|
|
5777
5821
|
}
|
|
5778
5822
|
|
|
5779
|
-
// TODO: These constants should be removed in favor of reading them out of a
|
|
5780
|
-
// Syscall account
|
|
5781
|
-
|
|
5782
|
-
/**
|
|
5783
|
-
* @internal
|
|
5784
|
-
*/
|
|
5785
|
-
const NUM_TICKS_PER_SECOND = 160;
|
|
5786
|
-
|
|
5787
|
-
/**
|
|
5788
|
-
* @internal
|
|
5789
|
-
*/
|
|
5790
|
-
const DEFAULT_TICKS_PER_SLOT = 64;
|
|
5791
|
-
|
|
5792
|
-
/**
|
|
5793
|
-
* @internal
|
|
5794
|
-
*/
|
|
5795
|
-
const NUM_SLOTS_PER_SECOND = NUM_TICKS_PER_SECOND / DEFAULT_TICKS_PER_SLOT;
|
|
5796
|
-
|
|
5797
|
-
/**
|
|
5798
|
-
* @internal
|
|
5799
|
-
*/
|
|
5800
|
-
const MS_PER_SLOT = 1000 / NUM_SLOTS_PER_SECOND;
|
|
5801
|
-
|
|
5802
5823
|
/**
|
|
5803
5824
|
* @internal
|
|
5804
5825
|
*/
|
|
@@ -5997,7 +6018,7 @@ function versionedMessageFromResponse(version, response) {
|
|
|
5997
6018
|
compiledInstructions: response.instructions.map(ix => ({
|
|
5998
6019
|
programIdIndex: ix.programIdIndex,
|
|
5999
6020
|
accountKeyIndexes: ix.accounts,
|
|
6000
|
-
data: bs58__default
|
|
6021
|
+
data: bs58__default.default.decode(ix.data)
|
|
6001
6022
|
})),
|
|
6002
6023
|
addressTableLookups: response.addressTableLookups
|
|
6003
6024
|
});
|
|
@@ -6181,7 +6202,7 @@ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disable
|
|
|
6181
6202
|
return await fetch(...modifiedFetchArgs);
|
|
6182
6203
|
};
|
|
6183
6204
|
}
|
|
6184
|
-
const clientBrowser = new RpcClient__default
|
|
6205
|
+
const clientBrowser = new RpcClient__default.default(async (request, callback) => {
|
|
6185
6206
|
const options = {
|
|
6186
6207
|
method: 'POST',
|
|
6187
6208
|
body: request,
|
|
@@ -7253,7 +7274,7 @@ class Connection {
|
|
|
7253
7274
|
/**
|
|
7254
7275
|
* Fetch all the token accounts owned by the specified account
|
|
7255
7276
|
*
|
|
7256
|
-
* @return {Promise<RpcResponseAndContext<
|
|
7277
|
+
* @return {Promise<RpcResponseAndContext<GetProgramAccountsResponse>}
|
|
7257
7278
|
*/
|
|
7258
7279
|
async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
|
|
7259
7280
|
const {
|
|
@@ -7450,6 +7471,8 @@ class Connection {
|
|
|
7450
7471
|
*
|
|
7451
7472
|
* @return {Promise<Array<{pubkey: PublicKey, account: AccountInfo<Buffer>}>>}
|
|
7452
7473
|
*/
|
|
7474
|
+
|
|
7475
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
7453
7476
|
async getProgramAccounts(programId, configOrCommitment) {
|
|
7454
7477
|
const {
|
|
7455
7478
|
commitment,
|
|
@@ -7461,7 +7484,8 @@ class Connection {
|
|
|
7461
7484
|
} = config || {};
|
|
7462
7485
|
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
|
|
7463
7486
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
7464
|
-
const
|
|
7487
|
+
const baseSchema = superstruct.array(KeyedAccountInfoResult);
|
|
7488
|
+
const res = configWithoutEncoding.withContext === true ? superstruct.create(unsafeRes, jsonRpcResultAndContext(baseSchema)) : superstruct.create(unsafeRes, jsonRpcResult(baseSchema));
|
|
7465
7489
|
if ('error' in res) {
|
|
7466
7490
|
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
7467
7491
|
}
|
|
@@ -7500,7 +7524,7 @@ class Connection {
|
|
|
7500
7524
|
}
|
|
7501
7525
|
let decodedSignature;
|
|
7502
7526
|
try {
|
|
7503
|
-
decodedSignature = bs58__default
|
|
7527
|
+
decodedSignature = bs58__default.default.decode(rawSignature);
|
|
7504
7528
|
} catch (err) {
|
|
7505
7529
|
throw new Error('signature must be base58 encoded: ' + rawSignature);
|
|
7506
7530
|
}
|
|
@@ -9193,12 +9217,11 @@ class Connection {
|
|
|
9193
9217
|
* @internal
|
|
9194
9218
|
*/
|
|
9195
9219
|
_onSubscriptionStateChange(clientSubscriptionId, callback) {
|
|
9196
|
-
var _this$_subscriptionSt;
|
|
9197
9220
|
const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
|
|
9198
9221
|
if (hash == null) {
|
|
9199
9222
|
return () => {};
|
|
9200
9223
|
}
|
|
9201
|
-
const stateChangeCallbacks =
|
|
9224
|
+
const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();
|
|
9202
9225
|
stateChangeCallbacks.add(callback);
|
|
9203
9226
|
return () => {
|
|
9204
9227
|
stateChangeCallbacks.delete(callback);
|
|
@@ -10426,19 +10449,12 @@ class Ed25519Program {
|
|
|
10426
10449
|
}
|
|
10427
10450
|
Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
|
|
10428
10451
|
|
|
10429
|
-
|
|
10430
|
-
|
|
10431
|
-
|
|
10432
|
-
const h = hmac.hmac.create(sha256.sha256, key);
|
|
10433
|
-
msgs.forEach(msg => h.update(msg));
|
|
10434
|
-
return h.digest();
|
|
10452
|
+
const ecdsaSign = (msgHash, privKey) => {
|
|
10453
|
+
const signature = secp256k1.secp256k1.sign(msgHash, privKey);
|
|
10454
|
+
return [signature.toCompactRawBytes(), signature.recovery];
|
|
10435
10455
|
};
|
|
10436
|
-
|
|
10437
|
-
|
|
10438
|
-
recovered: true
|
|
10439
|
-
});
|
|
10440
|
-
secp256k1__namespace.utils.isValidPrivateKey;
|
|
10441
|
-
const publicKeyCreate = secp256k1__namespace.getPublicKey;
|
|
10456
|
+
secp256k1.secp256k1.utils.isValidPrivateKey;
|
|
10457
|
+
const publicKeyCreate = secp256k1.secp256k1.getPublicKey;
|
|
10442
10458
|
|
|
10443
10459
|
const PRIVATE_KEY_BYTES = 32;
|
|
10444
10460
|
const ETHEREUM_ADDRESS_BYTES = 20;
|
|
@@ -11706,7 +11722,7 @@ class VoteProgram {
|
|
|
11706
11722
|
}
|
|
11707
11723
|
}
|
|
11708
11724
|
VoteProgram.programId = new PublicKey('Vote111111111111111111111111111111111111111');
|
|
11709
|
-
VoteProgram.space = 3731;
|
|
11725
|
+
VoteProgram.space = process.env.TEST_LIVE ? 3762 : 3731;
|
|
11710
11726
|
|
|
11711
11727
|
const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
|
|
11712
11728
|
|