@solana/web3.js 1.30.1 → 1.30.2
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.esm.js +119 -198
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +123 -207
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +123 -206
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +28733 -28832
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +30 -30
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +2 -2
package/lib/index.cjs.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
5
|
var nacl = require('tweetnacl');
|
|
7
6
|
var buffer = require('buffer');
|
|
8
7
|
var BN = require('bn.js');
|
|
@@ -38,7 +37,6 @@ function _interopNamespace(e) {
|
|
|
38
37
|
return Object.freeze(n);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
42
40
|
var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
|
|
43
41
|
var nacl__namespace = /*#__PURE__*/_interopNamespace(nacl);
|
|
44
42
|
var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
|
|
@@ -1760,8 +1758,7 @@ class Struct {
|
|
|
1760
1758
|
class Enum extends Struct {
|
|
1761
1759
|
constructor(properties) {
|
|
1762
1760
|
super(properties);
|
|
1763
|
-
|
|
1764
|
-
_defineProperty__default["default"](this, "enum", '');
|
|
1761
|
+
this.enum = '';
|
|
1765
1762
|
|
|
1766
1763
|
if (Object.keys(properties).length !== 1) {
|
|
1767
1764
|
throw new Error('Enum can only take single value');
|
|
@@ -1801,8 +1798,7 @@ class PublicKey extends Struct {
|
|
|
1801
1798
|
*/
|
|
1802
1799
|
constructor(value) {
|
|
1803
1800
|
super({});
|
|
1804
|
-
|
|
1805
|
-
_defineProperty__default["default"](this, "_bn", void 0);
|
|
1801
|
+
this._bn = void 0;
|
|
1806
1802
|
|
|
1807
1803
|
if (isPublicKeyData(value)) {
|
|
1808
1804
|
this._bn = value._bn;
|
|
@@ -1812,7 +1808,7 @@ class PublicKey extends Struct {
|
|
|
1812
1808
|
const decoded = bs58__default["default"].decode(value);
|
|
1813
1809
|
|
|
1814
1810
|
if (decoded.length != 32) {
|
|
1815
|
-
throw new Error(
|
|
1811
|
+
throw new Error(`Invalid public key input`);
|
|
1816
1812
|
}
|
|
1817
1813
|
|
|
1818
1814
|
this._bn = new BN__default["default"](decoded);
|
|
@@ -1821,7 +1817,7 @@ class PublicKey extends Struct {
|
|
|
1821
1817
|
}
|
|
1822
1818
|
|
|
1823
1819
|
if (this._bn.byteLength() > 32) {
|
|
1824
|
-
throw new Error(
|
|
1820
|
+
throw new Error(`Invalid public key input`);
|
|
1825
1821
|
}
|
|
1826
1822
|
}
|
|
1827
1823
|
}
|
|
@@ -1901,7 +1897,7 @@ class PublicKey extends Struct {
|
|
|
1901
1897
|
let buffer$1 = buffer.Buffer.alloc(0);
|
|
1902
1898
|
seeds.forEach(function (seed) {
|
|
1903
1899
|
if (seed.length > MAX_SEED_LENGTH) {
|
|
1904
|
-
throw new TypeError(
|
|
1900
|
+
throw new TypeError(`Max seed length exceeded`);
|
|
1905
1901
|
}
|
|
1906
1902
|
|
|
1907
1903
|
buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
|
|
@@ -1911,7 +1907,7 @@ class PublicKey extends Struct {
|
|
|
1911
1907
|
let publicKeyBytes = new BN__default["default"](hash, 16).toArray(undefined, 32);
|
|
1912
1908
|
|
|
1913
1909
|
if (is_on_curve(publicKeyBytes)) {
|
|
1914
|
-
throw new Error(
|
|
1910
|
+
throw new Error(`Invalid seeds, address must fall off the curve`);
|
|
1915
1911
|
}
|
|
1916
1912
|
|
|
1917
1913
|
return new PublicKey(publicKeyBytes);
|
|
@@ -1945,7 +1941,7 @@ class PublicKey extends Struct {
|
|
|
1945
1941
|
return [address, nonce];
|
|
1946
1942
|
}
|
|
1947
1943
|
|
|
1948
|
-
throw new Error(
|
|
1944
|
+
throw new Error(`Unable to find a viable program address nonce`);
|
|
1949
1945
|
}
|
|
1950
1946
|
/**
|
|
1951
1947
|
* Check that a pubkey is on the ed25519 curve.
|
|
@@ -1957,9 +1953,7 @@ class PublicKey extends Struct {
|
|
|
1957
1953
|
}
|
|
1958
1954
|
|
|
1959
1955
|
}
|
|
1960
|
-
|
|
1961
|
-
_defineProperty__default["default"](PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
|
|
1962
|
-
|
|
1956
|
+
PublicKey.default = new PublicKey('11111111111111111111111111111111');
|
|
1963
1957
|
SOLANA_SCHEMA.set(PublicKey, {
|
|
1964
1958
|
kind: 'struct',
|
|
1965
1959
|
fields: [['_bn', 'u256']]
|
|
@@ -2032,7 +2026,7 @@ class Account {
|
|
|
2032
2026
|
* @param secretKey Secret key for the account
|
|
2033
2027
|
*/
|
|
2034
2028
|
constructor(secretKey) {
|
|
2035
|
-
|
|
2029
|
+
this._keypair = void 0;
|
|
2036
2030
|
|
|
2037
2031
|
if (secretKey) {
|
|
2038
2032
|
this._keypair = nacl__namespace.sign.keyPair.fromSecretKey(toBuffer(secretKey));
|
|
@@ -2168,16 +2162,11 @@ const PUBKEY_LENGTH = 32;
|
|
|
2168
2162
|
|
|
2169
2163
|
class Message {
|
|
2170
2164
|
constructor(args) {
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
_defineProperty__default["default"](this, "instructions", void 0);
|
|
2178
|
-
|
|
2179
|
-
_defineProperty__default["default"](this, "indexToProgramIds", new Map());
|
|
2180
|
-
|
|
2165
|
+
this.header = void 0;
|
|
2166
|
+
this.accountKeys = void 0;
|
|
2167
|
+
this.recentBlockhash = void 0;
|
|
2168
|
+
this.instructions = void 0;
|
|
2169
|
+
this.indexToProgramIds = new Map();
|
|
2181
2170
|
this.header = args.header;
|
|
2182
2171
|
this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
|
|
2183
2172
|
this.recentBlockhash = args.recentBlockhash;
|
|
@@ -2351,12 +2340,9 @@ class TransactionInstruction {
|
|
|
2351
2340
|
* Program input
|
|
2352
2341
|
*/
|
|
2353
2342
|
constructor(opts) {
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
_defineProperty__default["default"](this, "data", buffer.Buffer.alloc(0));
|
|
2359
|
-
|
|
2343
|
+
this.keys = void 0;
|
|
2344
|
+
this.programId = void 0;
|
|
2345
|
+
this.data = buffer.Buffer.alloc(0);
|
|
2360
2346
|
this.programId = opts.programId;
|
|
2361
2347
|
this.keys = opts.keys;
|
|
2362
2348
|
|
|
@@ -2398,16 +2384,11 @@ class Transaction {
|
|
|
2398
2384
|
* Construct an empty Transaction
|
|
2399
2385
|
*/
|
|
2400
2386
|
constructor(opts) {
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
_defineProperty__default["default"](this, "recentBlockhash", void 0);
|
|
2408
|
-
|
|
2409
|
-
_defineProperty__default["default"](this, "nonceInfo", void 0);
|
|
2410
|
-
|
|
2387
|
+
this.signatures = [];
|
|
2388
|
+
this.feePayer = void 0;
|
|
2389
|
+
this.instructions = [];
|
|
2390
|
+
this.recentBlockhash = void 0;
|
|
2391
|
+
this.nonceInfo = void 0;
|
|
2411
2392
|
opts && Object.assign(this, opts);
|
|
2412
2393
|
}
|
|
2413
2394
|
/**
|
|
@@ -2471,7 +2452,7 @@ class Transaction {
|
|
|
2471
2452
|
|
|
2472
2453
|
for (let i = 0; i < this.instructions.length; i++) {
|
|
2473
2454
|
if (this.instructions[i].programId === undefined) {
|
|
2474
|
-
throw new Error(
|
|
2455
|
+
throw new Error(`Transaction instruction index ${i} has undefined program id`);
|
|
2475
2456
|
}
|
|
2476
2457
|
}
|
|
2477
2458
|
|
|
@@ -2546,7 +2527,7 @@ class Transaction {
|
|
|
2546
2527
|
console.warn('Transaction references a signature that is unnecessary, ' + 'only the fee payer and instruction signer accounts should sign a transaction. ' + 'This behavior is deprecated and will throw an error in the next major version release.');
|
|
2547
2528
|
}
|
|
2548
2529
|
} else {
|
|
2549
|
-
throw new Error(
|
|
2530
|
+
throw new Error(`unknown signer: ${signature.publicKey.toString()}`);
|
|
2550
2531
|
}
|
|
2551
2532
|
}
|
|
2552
2533
|
|
|
@@ -2781,7 +2762,7 @@ class Transaction {
|
|
|
2781
2762
|
const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
|
|
2782
2763
|
|
|
2783
2764
|
if (index < 0) {
|
|
2784
|
-
throw new Error(
|
|
2765
|
+
throw new Error(`unknown signer: ${pubkey.toString()}`);
|
|
2785
2766
|
}
|
|
2786
2767
|
|
|
2787
2768
|
this.signatures[index].signature = buffer.Buffer.from(signature);
|
|
@@ -2857,12 +2838,12 @@ class Transaction {
|
|
|
2857
2838
|
signature
|
|
2858
2839
|
}, index) => {
|
|
2859
2840
|
if (signature !== null) {
|
|
2860
|
-
assert(signature.length === 64,
|
|
2841
|
+
assert(signature.length === 64, `signature has invalid length`);
|
|
2861
2842
|
buffer.Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2862
2843
|
}
|
|
2863
2844
|
});
|
|
2864
2845
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
2865
|
-
assert(wireTransaction.length <= PACKET_DATA_SIZE,
|
|
2846
|
+
assert(wireTransaction.length <= PACKET_DATA_SIZE, `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`);
|
|
2866
2847
|
return wireTransaction;
|
|
2867
2848
|
}
|
|
2868
2849
|
/**
|
|
@@ -2981,7 +2962,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
2981
2962
|
const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
2982
2963
|
|
|
2983
2964
|
if (status.err) {
|
|
2984
|
-
throw new Error(
|
|
2965
|
+
throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
2985
2966
|
}
|
|
2986
2967
|
|
|
2987
2968
|
return signature;
|
|
@@ -3024,7 +3005,7 @@ function decodeData(type, buffer) {
|
|
|
3024
3005
|
}
|
|
3025
3006
|
|
|
3026
3007
|
if (data.instruction !== type.index) {
|
|
3027
|
-
throw new Error(
|
|
3008
|
+
throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
|
|
3028
3009
|
}
|
|
3029
3010
|
|
|
3030
3011
|
return data;
|
|
@@ -3058,12 +3039,9 @@ class NonceAccount {
|
|
|
3058
3039
|
* @internal
|
|
3059
3040
|
*/
|
|
3060
3041
|
constructor(args) {
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
_defineProperty__default["default"](this, "feeCalculator", void 0);
|
|
3066
|
-
|
|
3042
|
+
this.authorizedPubkey = void 0;
|
|
3043
|
+
this.nonce = void 0;
|
|
3044
|
+
this.feeCalculator = void 0;
|
|
3067
3045
|
this.authorizedPubkey = args.authorizedPubkey;
|
|
3068
3046
|
this.nonce = args.nonce;
|
|
3069
3047
|
this.feeCalculator = args.feeCalculator;
|
|
@@ -3364,7 +3342,7 @@ class SystemInstruction {
|
|
|
3364
3342
|
|
|
3365
3343
|
static checkKeyLength(keys, expectedLength) {
|
|
3366
3344
|
if (keys.length < expectedLength) {
|
|
3367
|
-
throw new Error(
|
|
3345
|
+
throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
|
|
3368
3346
|
}
|
|
3369
3347
|
}
|
|
3370
3348
|
|
|
@@ -3796,8 +3774,7 @@ class SystemProgram {
|
|
|
3796
3774
|
}
|
|
3797
3775
|
|
|
3798
3776
|
}
|
|
3799
|
-
|
|
3800
|
-
_defineProperty__default["default"](SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
|
|
3777
|
+
SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
|
|
3801
3778
|
|
|
3802
3779
|
// rest of the Transaction fields
|
|
3803
3780
|
//
|
|
@@ -3966,8 +3943,7 @@ class Loader {
|
|
|
3966
3943
|
}
|
|
3967
3944
|
|
|
3968
3945
|
}
|
|
3969
|
-
|
|
3970
|
-
_defineProperty__default["default"](Loader, "chunkSize", CHUNK_SIZE);
|
|
3946
|
+
Loader.chunkSize = CHUNK_SIZE;
|
|
3971
3947
|
|
|
3972
3948
|
const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
|
|
3973
3949
|
/**
|
|
@@ -4018,14 +3994,10 @@ class AgentManager {
|
|
|
4018
3994
|
}
|
|
4019
3995
|
|
|
4020
3996
|
constructor(useHttps) {
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
_defineProperty__default["default"](this, "_destroyTimeout", null);
|
|
4026
|
-
|
|
4027
|
-
_defineProperty__default["default"](this, "_useHttps", void 0);
|
|
4028
|
-
|
|
3997
|
+
this._agent = void 0;
|
|
3998
|
+
this._activeRequests = 0;
|
|
3999
|
+
this._destroyTimeout = null;
|
|
4000
|
+
this._useHttps = void 0;
|
|
4029
4001
|
this._useHttps = useHttps === true;
|
|
4030
4002
|
this._agent = AgentManager._newAgent(this._useHttps);
|
|
4031
4003
|
}
|
|
@@ -4098,16 +4070,11 @@ class EpochSchedule {
|
|
|
4098
4070
|
|
|
4099
4071
|
/** The first slot of `firstNormalEpoch` */
|
|
4100
4072
|
constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
_defineProperty__default["default"](this, "firstNormalEpoch", void 0);
|
|
4108
|
-
|
|
4109
|
-
_defineProperty__default["default"](this, "firstNormalSlot", void 0);
|
|
4110
|
-
|
|
4073
|
+
this.slotsPerEpoch = void 0;
|
|
4074
|
+
this.leaderScheduleSlotOffset = void 0;
|
|
4075
|
+
this.warmup = void 0;
|
|
4076
|
+
this.firstNormalEpoch = void 0;
|
|
4077
|
+
this.firstNormalSlot = void 0;
|
|
4111
4078
|
this.slotsPerEpoch = slotsPerEpoch;
|
|
4112
4079
|
this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
|
|
4113
4080
|
this.warmup = warmup;
|
|
@@ -4159,9 +4126,7 @@ class EpochSchedule {
|
|
|
4159
4126
|
class SendTransactionError extends Error {
|
|
4160
4127
|
constructor(message, logs) {
|
|
4161
4128
|
super(message);
|
|
4162
|
-
|
|
4163
|
-
_defineProperty__default["default"](this, "logs", void 0);
|
|
4164
|
-
|
|
4129
|
+
this.logs = void 0;
|
|
4165
4130
|
this.logs = logs;
|
|
4166
4131
|
}
|
|
4167
4132
|
|
|
@@ -4445,7 +4410,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
|
|
|
4445
4410
|
break;
|
|
4446
4411
|
}
|
|
4447
4412
|
|
|
4448
|
-
console.log(
|
|
4413
|
+
console.log(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);
|
|
4449
4414
|
await sleep(waitTime);
|
|
4450
4415
|
waitTime *= 2;
|
|
4451
4416
|
}
|
|
@@ -4455,7 +4420,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
|
|
|
4455
4420
|
if (res.ok) {
|
|
4456
4421
|
callback(null, text);
|
|
4457
4422
|
} else {
|
|
4458
|
-
callback(new Error(
|
|
4423
|
+
callback(new Error(`${res.status} ${res.statusText}: ${text}`));
|
|
4459
4424
|
}
|
|
4460
4425
|
} catch (err) {
|
|
4461
4426
|
if (err instanceof Error) callback(err);
|
|
@@ -5121,67 +5086,39 @@ class Connection {
|
|
|
5121
5086
|
* @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
|
|
5122
5087
|
*/
|
|
5123
5088
|
constructor(endpoint, commitmentOrConfig) {
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
_defineProperty__default["default"](this, "_rpcWebSocket", void 0);
|
|
5139
|
-
|
|
5140
|
-
_defineProperty__default["default"](this, "_rpcWebSocketConnected", false);
|
|
5141
|
-
|
|
5142
|
-
_defineProperty__default["default"](this, "_rpcWebSocketHeartbeat", null);
|
|
5143
|
-
|
|
5144
|
-
_defineProperty__default["default"](this, "_rpcWebSocketIdleTimeout", null);
|
|
5145
|
-
|
|
5146
|
-
_defineProperty__default["default"](this, "_disableBlockhashCaching", false);
|
|
5147
|
-
|
|
5148
|
-
_defineProperty__default["default"](this, "_pollingBlockhash", false);
|
|
5149
|
-
|
|
5150
|
-
_defineProperty__default["default"](this, "_blockhashInfo", {
|
|
5089
|
+
this._commitment = void 0;
|
|
5090
|
+
this._confirmTransactionInitialTimeout = void 0;
|
|
5091
|
+
this._rpcEndpoint = void 0;
|
|
5092
|
+
this._rpcWsEndpoint = void 0;
|
|
5093
|
+
this._rpcClient = void 0;
|
|
5094
|
+
this._rpcRequest = void 0;
|
|
5095
|
+
this._rpcBatchRequest = void 0;
|
|
5096
|
+
this._rpcWebSocket = void 0;
|
|
5097
|
+
this._rpcWebSocketConnected = false;
|
|
5098
|
+
this._rpcWebSocketHeartbeat = null;
|
|
5099
|
+
this._rpcWebSocketIdleTimeout = null;
|
|
5100
|
+
this._disableBlockhashCaching = false;
|
|
5101
|
+
this._pollingBlockhash = false;
|
|
5102
|
+
this._blockhashInfo = {
|
|
5151
5103
|
recentBlockhash: null,
|
|
5152
5104
|
lastFetch: 0,
|
|
5153
5105
|
transactionSignatures: [],
|
|
5154
5106
|
simulatedSignatures: []
|
|
5155
|
-
}
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
_defineProperty__default["default"](this, "_signatureSubscriptions", {});
|
|
5172
|
-
|
|
5173
|
-
_defineProperty__default["default"](this, "_slotSubscriptionCounter", 0);
|
|
5174
|
-
|
|
5175
|
-
_defineProperty__default["default"](this, "_slotSubscriptions", {});
|
|
5176
|
-
|
|
5177
|
-
_defineProperty__default["default"](this, "_logsSubscriptionCounter", 0);
|
|
5178
|
-
|
|
5179
|
-
_defineProperty__default["default"](this, "_logsSubscriptions", {});
|
|
5180
|
-
|
|
5181
|
-
_defineProperty__default["default"](this, "_slotUpdateSubscriptionCounter", 0);
|
|
5182
|
-
|
|
5183
|
-
_defineProperty__default["default"](this, "_slotUpdateSubscriptions", {});
|
|
5184
|
-
|
|
5107
|
+
};
|
|
5108
|
+
this._accountChangeSubscriptionCounter = 0;
|
|
5109
|
+
this._accountChangeSubscriptions = {};
|
|
5110
|
+
this._programAccountChangeSubscriptionCounter = 0;
|
|
5111
|
+
this._programAccountChangeSubscriptions = {};
|
|
5112
|
+
this._rootSubscriptionCounter = 0;
|
|
5113
|
+
this._rootSubscriptions = {};
|
|
5114
|
+
this._signatureSubscriptionCounter = 0;
|
|
5115
|
+
this._signatureSubscriptions = {};
|
|
5116
|
+
this._slotSubscriptionCounter = 0;
|
|
5117
|
+
this._slotSubscriptions = {};
|
|
5118
|
+
this._logsSubscriptionCounter = 0;
|
|
5119
|
+
this._logsSubscriptions = {};
|
|
5120
|
+
this._slotUpdateSubscriptionCounter = 0;
|
|
5121
|
+
this._slotUpdateSubscriptions = {};
|
|
5185
5122
|
let url = new URL(endpoint);
|
|
5186
5123
|
const useHttps = url.protocol === 'https:';
|
|
5187
5124
|
let wsEndpoint;
|
|
@@ -5555,7 +5492,7 @@ class Connection {
|
|
|
5555
5492
|
const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
5556
5493
|
|
|
5557
5494
|
if ('error' in res) {
|
|
5558
|
-
throw new Error(
|
|
5495
|
+
throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
|
|
5559
5496
|
}
|
|
5560
5497
|
|
|
5561
5498
|
return res.result;
|
|
@@ -5691,7 +5628,7 @@ class Connection {
|
|
|
5691
5628
|
|
|
5692
5629
|
if (response === null) {
|
|
5693
5630
|
const duration = (Date.now() - start) / 1000;
|
|
5694
|
-
throw new Error(
|
|
5631
|
+
throw new Error(`Transaction was not confirmed in ${duration.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`);
|
|
5695
5632
|
}
|
|
5696
5633
|
|
|
5697
5634
|
return response;
|
|
@@ -6465,7 +6402,7 @@ class Connection {
|
|
|
6465
6402
|
await sleep(MS_PER_SLOT / 2);
|
|
6466
6403
|
}
|
|
6467
6404
|
|
|
6468
|
-
throw new Error(
|
|
6405
|
+
throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);
|
|
6469
6406
|
} finally {
|
|
6470
6407
|
this._pollingBlockhash = false;
|
|
6471
6408
|
}
|
|
@@ -6722,7 +6659,7 @@ class Connection {
|
|
|
6722
6659
|
}
|
|
6723
6660
|
|
|
6724
6661
|
if (err instanceof Error) {
|
|
6725
|
-
console.error(
|
|
6662
|
+
console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
|
|
6726
6663
|
}
|
|
6727
6664
|
}
|
|
6728
6665
|
}
|
|
@@ -6742,7 +6679,7 @@ class Connection {
|
|
|
6742
6679
|
await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
|
|
6743
6680
|
} catch (err) {
|
|
6744
6681
|
if (err instanceof Error) {
|
|
6745
|
-
console.error(
|
|
6682
|
+
console.error(`${rpcMethod} error:`, err.message);
|
|
6746
6683
|
}
|
|
6747
6684
|
}
|
|
6748
6685
|
}
|
|
@@ -6907,7 +6844,7 @@ class Connection {
|
|
|
6907
6844
|
|
|
6908
6845
|
this._updateSubscriptions();
|
|
6909
6846
|
} else {
|
|
6910
|
-
throw new Error(
|
|
6847
|
+
throw new Error(`Unknown account change id: ${id}`);
|
|
6911
6848
|
}
|
|
6912
6849
|
}
|
|
6913
6850
|
/**
|
|
@@ -6973,7 +6910,7 @@ class Connection {
|
|
|
6973
6910
|
|
|
6974
6911
|
this._updateSubscriptions();
|
|
6975
6912
|
} else {
|
|
6976
|
-
throw new Error(
|
|
6913
|
+
throw new Error(`Unknown program account change id: ${id}`);
|
|
6977
6914
|
}
|
|
6978
6915
|
}
|
|
6979
6916
|
/**
|
|
@@ -7003,7 +6940,7 @@ class Connection {
|
|
|
7003
6940
|
|
|
7004
6941
|
async removeOnLogsListener(id) {
|
|
7005
6942
|
if (!this._logsSubscriptions[id]) {
|
|
7006
|
-
throw new Error(
|
|
6943
|
+
throw new Error(`Unknown logs id: ${id}`);
|
|
7007
6944
|
}
|
|
7008
6945
|
|
|
7009
6946
|
const subInfo = this._logsSubscriptions[id];
|
|
@@ -7079,7 +7016,7 @@ class Connection {
|
|
|
7079
7016
|
|
|
7080
7017
|
this._updateSubscriptions();
|
|
7081
7018
|
} else {
|
|
7082
|
-
throw new Error(
|
|
7019
|
+
throw new Error(`Unknown slot change id: ${id}`);
|
|
7083
7020
|
}
|
|
7084
7021
|
}
|
|
7085
7022
|
/**
|
|
@@ -7132,7 +7069,7 @@ class Connection {
|
|
|
7132
7069
|
|
|
7133
7070
|
this._updateSubscriptions();
|
|
7134
7071
|
} else {
|
|
7135
|
-
throw new Error(
|
|
7072
|
+
throw new Error(`Unknown slot update id: ${id}`);
|
|
7136
7073
|
}
|
|
7137
7074
|
}
|
|
7138
7075
|
|
|
@@ -7273,7 +7210,7 @@ class Connection {
|
|
|
7273
7210
|
|
|
7274
7211
|
this._updateSubscriptions();
|
|
7275
7212
|
} else {
|
|
7276
|
-
throw new Error(
|
|
7213
|
+
throw new Error(`Unknown signature result id: ${id}`);
|
|
7277
7214
|
}
|
|
7278
7215
|
}
|
|
7279
7216
|
/**
|
|
@@ -7325,7 +7262,7 @@ class Connection {
|
|
|
7325
7262
|
|
|
7326
7263
|
this._updateSubscriptions();
|
|
7327
7264
|
} else {
|
|
7328
|
-
throw new Error(
|
|
7265
|
+
throw new Error(`Unknown root change id: ${id}`);
|
|
7329
7266
|
}
|
|
7330
7267
|
}
|
|
7331
7268
|
|
|
@@ -7346,7 +7283,7 @@ class Keypair {
|
|
|
7346
7283
|
* @param keypair ed25519 keypair
|
|
7347
7284
|
*/
|
|
7348
7285
|
constructor(keypair) {
|
|
7349
|
-
|
|
7286
|
+
this._keypair = void 0;
|
|
7350
7287
|
|
|
7351
7288
|
if (keypair) {
|
|
7352
7289
|
this._keypair = keypair;
|
|
@@ -7450,8 +7387,8 @@ class Ed25519Program {
|
|
|
7450
7387
|
signature,
|
|
7451
7388
|
instructionIndex
|
|
7452
7389
|
} = params;
|
|
7453
|
-
assert(publicKey.length === PUBLIC_KEY_BYTES$1,
|
|
7454
|
-
assert(signature.length === SIGNATURE_BYTES,
|
|
7390
|
+
assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
|
|
7391
|
+
assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
|
|
7455
7392
|
const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
|
|
7456
7393
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
7457
7394
|
const messageDataOffset = signatureOffset + signature.length;
|
|
@@ -7489,7 +7426,7 @@ class Ed25519Program {
|
|
|
7489
7426
|
message,
|
|
7490
7427
|
instructionIndex
|
|
7491
7428
|
} = params;
|
|
7492
|
-
assert(privateKey.length === PRIVATE_KEY_BYTES$1,
|
|
7429
|
+
assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
|
|
7493
7430
|
|
|
7494
7431
|
try {
|
|
7495
7432
|
const keypair = Keypair.fromSecretKey(privateKey);
|
|
@@ -7502,13 +7439,12 @@ class Ed25519Program {
|
|
|
7502
7439
|
instructionIndex
|
|
7503
7440
|
});
|
|
7504
7441
|
} catch (error) {
|
|
7505
|
-
throw new Error(
|
|
7442
|
+
throw new Error(`Error creating instruction; ${error}`);
|
|
7506
7443
|
}
|
|
7507
7444
|
}
|
|
7508
7445
|
|
|
7509
7446
|
}
|
|
7510
|
-
|
|
7511
|
-
_defineProperty__default["default"](Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
|
|
7447
|
+
Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
|
|
7512
7448
|
|
|
7513
7449
|
/**
|
|
7514
7450
|
* Address of the stake config account which configures the rate
|
|
@@ -7531,10 +7467,8 @@ class Authorized {
|
|
|
7531
7467
|
* @param withdrawer the withdraw authority
|
|
7532
7468
|
*/
|
|
7533
7469
|
constructor(staker, withdrawer) {
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
_defineProperty__default["default"](this, "withdrawer", void 0);
|
|
7537
|
-
|
|
7470
|
+
this.staker = void 0;
|
|
7471
|
+
this.withdrawer = void 0;
|
|
7538
7472
|
this.staker = staker;
|
|
7539
7473
|
this.withdrawer = withdrawer;
|
|
7540
7474
|
}
|
|
@@ -7555,12 +7489,9 @@ class Lockup {
|
|
|
7555
7489
|
* Create a new Lockup object
|
|
7556
7490
|
*/
|
|
7557
7491
|
constructor(unixTimestamp, epoch, custodian) {
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
_defineProperty__default["default"](this, "custodian", void 0);
|
|
7563
|
-
|
|
7492
|
+
this.unixTimestamp = void 0;
|
|
7493
|
+
this.epoch = void 0;
|
|
7494
|
+
this.custodian = void 0;
|
|
7564
7495
|
this.unixTimestamp = unixTimestamp;
|
|
7565
7496
|
this.epoch = epoch;
|
|
7566
7497
|
this.custodian = custodian;
|
|
@@ -7575,7 +7506,7 @@ class Lockup {
|
|
|
7575
7506
|
* Create stake account transaction params
|
|
7576
7507
|
*/
|
|
7577
7508
|
|
|
7578
|
-
|
|
7509
|
+
Lockup.default = new Lockup(0, 0, PublicKey.default);
|
|
7579
7510
|
|
|
7580
7511
|
/**
|
|
7581
7512
|
* Stake Instruction class
|
|
@@ -7788,7 +7719,7 @@ class StakeInstruction {
|
|
|
7788
7719
|
|
|
7789
7720
|
static checkKeyLength(keys, expectedLength) {
|
|
7790
7721
|
if (keys.length < expectedLength) {
|
|
7791
|
-
throw new Error(
|
|
7722
|
+
throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
|
|
7792
7723
|
}
|
|
7793
7724
|
}
|
|
7794
7725
|
|
|
@@ -8263,10 +8194,8 @@ class StakeProgram {
|
|
|
8263
8194
|
}
|
|
8264
8195
|
|
|
8265
8196
|
}
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
_defineProperty__default["default"](StakeProgram, "space", 200);
|
|
8197
|
+
StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
|
|
8198
|
+
StakeProgram.space = 200;
|
|
8270
8199
|
|
|
8271
8200
|
const {
|
|
8272
8201
|
publicKeyCreate,
|
|
@@ -8296,12 +8225,12 @@ class Secp256k1Program {
|
|
|
8296
8225
|
* @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
|
|
8297
8226
|
*/
|
|
8298
8227
|
static publicKeyToEthAddress(publicKey) {
|
|
8299
|
-
assert(publicKey.length === PUBLIC_KEY_BYTES,
|
|
8228
|
+
assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
|
|
8300
8229
|
|
|
8301
8230
|
try {
|
|
8302
8231
|
return buffer.Buffer.from(jsSha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
8303
8232
|
} catch (error) {
|
|
8304
|
-
throw new Error(
|
|
8233
|
+
throw new Error(`Error constructing Ethereum address: ${error}`);
|
|
8305
8234
|
}
|
|
8306
8235
|
}
|
|
8307
8236
|
/**
|
|
@@ -8352,7 +8281,7 @@ class Secp256k1Program {
|
|
|
8352
8281
|
ethAddress = rawAddress;
|
|
8353
8282
|
}
|
|
8354
8283
|
|
|
8355
|
-
assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES,
|
|
8284
|
+
assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);
|
|
8356
8285
|
const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
|
|
8357
8286
|
const ethAddressOffset = dataStart;
|
|
8358
8287
|
const signatureOffset = dataStart + ethAddress.length;
|
|
@@ -8391,7 +8320,7 @@ class Secp256k1Program {
|
|
|
8391
8320
|
message,
|
|
8392
8321
|
instructionIndex
|
|
8393
8322
|
} = params;
|
|
8394
|
-
assert(pkey.length === PRIVATE_KEY_BYTES,
|
|
8323
|
+
assert(pkey.length === PRIVATE_KEY_BYTES, `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);
|
|
8395
8324
|
|
|
8396
8325
|
try {
|
|
8397
8326
|
const privateKey = toBuffer(pkey);
|
|
@@ -8410,13 +8339,12 @@ class Secp256k1Program {
|
|
|
8410
8339
|
instructionIndex
|
|
8411
8340
|
});
|
|
8412
8341
|
} catch (error) {
|
|
8413
|
-
throw new Error(
|
|
8342
|
+
throw new Error(`Error creating instruction; ${error}`);
|
|
8414
8343
|
}
|
|
8415
8344
|
}
|
|
8416
8345
|
|
|
8417
8346
|
}
|
|
8418
|
-
|
|
8419
|
-
_defineProperty__default["default"](Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
|
|
8347
|
+
Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
|
|
8420
8348
|
|
|
8421
8349
|
const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
|
|
8422
8350
|
/**
|
|
@@ -8449,10 +8377,8 @@ class ValidatorInfo {
|
|
|
8449
8377
|
* @param info validator information
|
|
8450
8378
|
*/
|
|
8451
8379
|
constructor(key, info) {
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
_defineProperty__default["default"](this, "info", void 0);
|
|
8455
|
-
|
|
8380
|
+
this.key = void 0;
|
|
8381
|
+
this.info = void 0;
|
|
8456
8382
|
this.key = key;
|
|
8457
8383
|
this.info = info;
|
|
8458
8384
|
}
|
|
@@ -8516,26 +8442,16 @@ class VoteAccount {
|
|
|
8516
8442
|
* @internal
|
|
8517
8443
|
*/
|
|
8518
8444
|
constructor(args) {
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
_defineProperty__default["default"](this, "rootSlot", void 0);
|
|
8530
|
-
|
|
8531
|
-
_defineProperty__default["default"](this, "epoch", void 0);
|
|
8532
|
-
|
|
8533
|
-
_defineProperty__default["default"](this, "credits", void 0);
|
|
8534
|
-
|
|
8535
|
-
_defineProperty__default["default"](this, "lastEpochCredits", void 0);
|
|
8536
|
-
|
|
8537
|
-
_defineProperty__default["default"](this, "epochCredits", void 0);
|
|
8538
|
-
|
|
8445
|
+
this.nodePubkey = void 0;
|
|
8446
|
+
this.authorizedVoterPubkey = void 0;
|
|
8447
|
+
this.authorizedWithdrawerPubkey = void 0;
|
|
8448
|
+
this.commission = void 0;
|
|
8449
|
+
this.votes = void 0;
|
|
8450
|
+
this.rootSlot = void 0;
|
|
8451
|
+
this.epoch = void 0;
|
|
8452
|
+
this.credits = void 0;
|
|
8453
|
+
this.lastEpochCredits = void 0;
|
|
8454
|
+
this.epochCredits = void 0;
|
|
8539
8455
|
this.nodePubkey = args.nodePubkey;
|
|
8540
8456
|
this.authorizedVoterPubkey = args.authorizedVoterPubkey;
|
|
8541
8457
|
this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
|
|
@@ -8598,7 +8514,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
|
|
|
8598
8514
|
const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
8599
8515
|
|
|
8600
8516
|
if (status.err) {
|
|
8601
|
-
throw new Error(
|
|
8517
|
+
throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
8602
8518
|
}
|
|
8603
8519
|
|
|
8604
8520
|
return signature;
|
|
@@ -8630,7 +8546,7 @@ function clusterApiUrl(cluster, tls) {
|
|
|
8630
8546
|
const url = endpoint[key][cluster];
|
|
8631
8547
|
|
|
8632
8548
|
if (!url) {
|
|
8633
|
-
throw new Error(
|
|
8549
|
+
throw new Error(`Unknown ${key} cluster: ${cluster}`);
|
|
8634
8550
|
}
|
|
8635
8551
|
|
|
8636
8552
|
return url;
|