@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.esm.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
1
|
import * as nacl from 'tweetnacl';
|
|
3
2
|
import nacl__default from 'tweetnacl';
|
|
4
3
|
import { Buffer } from 'buffer';
|
|
@@ -1725,8 +1724,7 @@ class Struct {
|
|
|
1725
1724
|
class Enum extends Struct {
|
|
1726
1725
|
constructor(properties) {
|
|
1727
1726
|
super(properties);
|
|
1728
|
-
|
|
1729
|
-
_defineProperty(this, "enum", '');
|
|
1727
|
+
this.enum = '';
|
|
1730
1728
|
|
|
1731
1729
|
if (Object.keys(properties).length !== 1) {
|
|
1732
1730
|
throw new Error('Enum can only take single value');
|
|
@@ -1766,8 +1764,7 @@ class PublicKey extends Struct {
|
|
|
1766
1764
|
*/
|
|
1767
1765
|
constructor(value) {
|
|
1768
1766
|
super({});
|
|
1769
|
-
|
|
1770
|
-
_defineProperty(this, "_bn", void 0);
|
|
1767
|
+
this._bn = void 0;
|
|
1771
1768
|
|
|
1772
1769
|
if (isPublicKeyData(value)) {
|
|
1773
1770
|
this._bn = value._bn;
|
|
@@ -1777,7 +1774,7 @@ class PublicKey extends Struct {
|
|
|
1777
1774
|
const decoded = bs58.decode(value);
|
|
1778
1775
|
|
|
1779
1776
|
if (decoded.length != 32) {
|
|
1780
|
-
throw new Error(
|
|
1777
|
+
throw new Error(`Invalid public key input`);
|
|
1781
1778
|
}
|
|
1782
1779
|
|
|
1783
1780
|
this._bn = new BN(decoded);
|
|
@@ -1786,7 +1783,7 @@ class PublicKey extends Struct {
|
|
|
1786
1783
|
}
|
|
1787
1784
|
|
|
1788
1785
|
if (this._bn.byteLength() > 32) {
|
|
1789
|
-
throw new Error(
|
|
1786
|
+
throw new Error(`Invalid public key input`);
|
|
1790
1787
|
}
|
|
1791
1788
|
}
|
|
1792
1789
|
}
|
|
@@ -1866,7 +1863,7 @@ class PublicKey extends Struct {
|
|
|
1866
1863
|
let buffer = Buffer.alloc(0);
|
|
1867
1864
|
seeds.forEach(function (seed) {
|
|
1868
1865
|
if (seed.length > MAX_SEED_LENGTH) {
|
|
1869
|
-
throw new TypeError(
|
|
1866
|
+
throw new TypeError(`Max seed length exceeded`);
|
|
1870
1867
|
}
|
|
1871
1868
|
|
|
1872
1869
|
buffer = Buffer.concat([buffer, toBuffer(seed)]);
|
|
@@ -1876,7 +1873,7 @@ class PublicKey extends Struct {
|
|
|
1876
1873
|
let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
|
|
1877
1874
|
|
|
1878
1875
|
if (is_on_curve(publicKeyBytes)) {
|
|
1879
|
-
throw new Error(
|
|
1876
|
+
throw new Error(`Invalid seeds, address must fall off the curve`);
|
|
1880
1877
|
}
|
|
1881
1878
|
|
|
1882
1879
|
return new PublicKey(publicKeyBytes);
|
|
@@ -1910,7 +1907,7 @@ class PublicKey extends Struct {
|
|
|
1910
1907
|
return [address, nonce];
|
|
1911
1908
|
}
|
|
1912
1909
|
|
|
1913
|
-
throw new Error(
|
|
1910
|
+
throw new Error(`Unable to find a viable program address nonce`);
|
|
1914
1911
|
}
|
|
1915
1912
|
/**
|
|
1916
1913
|
* Check that a pubkey is on the ed25519 curve.
|
|
@@ -1922,9 +1919,7 @@ class PublicKey extends Struct {
|
|
|
1922
1919
|
}
|
|
1923
1920
|
|
|
1924
1921
|
}
|
|
1925
|
-
|
|
1926
|
-
_defineProperty(PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
|
|
1927
|
-
|
|
1922
|
+
PublicKey.default = new PublicKey('11111111111111111111111111111111');
|
|
1928
1923
|
SOLANA_SCHEMA.set(PublicKey, {
|
|
1929
1924
|
kind: 'struct',
|
|
1930
1925
|
fields: [['_bn', 'u256']]
|
|
@@ -1997,7 +1992,7 @@ class Account {
|
|
|
1997
1992
|
* @param secretKey Secret key for the account
|
|
1998
1993
|
*/
|
|
1999
1994
|
constructor(secretKey) {
|
|
2000
|
-
|
|
1995
|
+
this._keypair = void 0;
|
|
2001
1996
|
|
|
2002
1997
|
if (secretKey) {
|
|
2003
1998
|
this._keypair = nacl.sign.keyPair.fromSecretKey(toBuffer(secretKey));
|
|
@@ -2133,16 +2128,11 @@ const PUBKEY_LENGTH = 32;
|
|
|
2133
2128
|
|
|
2134
2129
|
class Message {
|
|
2135
2130
|
constructor(args) {
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
_defineProperty(this, "instructions", void 0);
|
|
2143
|
-
|
|
2144
|
-
_defineProperty(this, "indexToProgramIds", new Map());
|
|
2145
|
-
|
|
2131
|
+
this.header = void 0;
|
|
2132
|
+
this.accountKeys = void 0;
|
|
2133
|
+
this.recentBlockhash = void 0;
|
|
2134
|
+
this.instructions = void 0;
|
|
2135
|
+
this.indexToProgramIds = new Map();
|
|
2146
2136
|
this.header = args.header;
|
|
2147
2137
|
this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
|
|
2148
2138
|
this.recentBlockhash = args.recentBlockhash;
|
|
@@ -2316,12 +2306,9 @@ class TransactionInstruction {
|
|
|
2316
2306
|
* Program input
|
|
2317
2307
|
*/
|
|
2318
2308
|
constructor(opts) {
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
_defineProperty(this, "data", Buffer.alloc(0));
|
|
2324
|
-
|
|
2309
|
+
this.keys = void 0;
|
|
2310
|
+
this.programId = void 0;
|
|
2311
|
+
this.data = Buffer.alloc(0);
|
|
2325
2312
|
this.programId = opts.programId;
|
|
2326
2313
|
this.keys = opts.keys;
|
|
2327
2314
|
|
|
@@ -2363,16 +2350,11 @@ class Transaction {
|
|
|
2363
2350
|
* Construct an empty Transaction
|
|
2364
2351
|
*/
|
|
2365
2352
|
constructor(opts) {
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
_defineProperty(this, "recentBlockhash", void 0);
|
|
2373
|
-
|
|
2374
|
-
_defineProperty(this, "nonceInfo", void 0);
|
|
2375
|
-
|
|
2353
|
+
this.signatures = [];
|
|
2354
|
+
this.feePayer = void 0;
|
|
2355
|
+
this.instructions = [];
|
|
2356
|
+
this.recentBlockhash = void 0;
|
|
2357
|
+
this.nonceInfo = void 0;
|
|
2376
2358
|
opts && Object.assign(this, opts);
|
|
2377
2359
|
}
|
|
2378
2360
|
/**
|
|
@@ -2436,7 +2418,7 @@ class Transaction {
|
|
|
2436
2418
|
|
|
2437
2419
|
for (let i = 0; i < this.instructions.length; i++) {
|
|
2438
2420
|
if (this.instructions[i].programId === undefined) {
|
|
2439
|
-
throw new Error(
|
|
2421
|
+
throw new Error(`Transaction instruction index ${i} has undefined program id`);
|
|
2440
2422
|
}
|
|
2441
2423
|
}
|
|
2442
2424
|
|
|
@@ -2511,7 +2493,7 @@ class Transaction {
|
|
|
2511
2493
|
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.');
|
|
2512
2494
|
}
|
|
2513
2495
|
} else {
|
|
2514
|
-
throw new Error(
|
|
2496
|
+
throw new Error(`unknown signer: ${signature.publicKey.toString()}`);
|
|
2515
2497
|
}
|
|
2516
2498
|
}
|
|
2517
2499
|
|
|
@@ -2746,7 +2728,7 @@ class Transaction {
|
|
|
2746
2728
|
const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
|
|
2747
2729
|
|
|
2748
2730
|
if (index < 0) {
|
|
2749
|
-
throw new Error(
|
|
2731
|
+
throw new Error(`unknown signer: ${pubkey.toString()}`);
|
|
2750
2732
|
}
|
|
2751
2733
|
|
|
2752
2734
|
this.signatures[index].signature = Buffer.from(signature);
|
|
@@ -2822,12 +2804,12 @@ class Transaction {
|
|
|
2822
2804
|
signature
|
|
2823
2805
|
}, index) => {
|
|
2824
2806
|
if (signature !== null) {
|
|
2825
|
-
assert(signature.length === 64,
|
|
2807
|
+
assert(signature.length === 64, `signature has invalid length`);
|
|
2826
2808
|
Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2827
2809
|
}
|
|
2828
2810
|
});
|
|
2829
2811
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
2830
|
-
assert(wireTransaction.length <= PACKET_DATA_SIZE,
|
|
2812
|
+
assert(wireTransaction.length <= PACKET_DATA_SIZE, `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`);
|
|
2831
2813
|
return wireTransaction;
|
|
2832
2814
|
}
|
|
2833
2815
|
/**
|
|
@@ -2946,7 +2928,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
2946
2928
|
const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
2947
2929
|
|
|
2948
2930
|
if (status.err) {
|
|
2949
|
-
throw new Error(
|
|
2931
|
+
throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
2950
2932
|
}
|
|
2951
2933
|
|
|
2952
2934
|
return signature;
|
|
@@ -2989,7 +2971,7 @@ function decodeData(type, buffer) {
|
|
|
2989
2971
|
}
|
|
2990
2972
|
|
|
2991
2973
|
if (data.instruction !== type.index) {
|
|
2992
|
-
throw new Error(
|
|
2974
|
+
throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
|
|
2993
2975
|
}
|
|
2994
2976
|
|
|
2995
2977
|
return data;
|
|
@@ -3023,12 +3005,9 @@ class NonceAccount {
|
|
|
3023
3005
|
* @internal
|
|
3024
3006
|
*/
|
|
3025
3007
|
constructor(args) {
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
_defineProperty(this, "feeCalculator", void 0);
|
|
3031
|
-
|
|
3008
|
+
this.authorizedPubkey = void 0;
|
|
3009
|
+
this.nonce = void 0;
|
|
3010
|
+
this.feeCalculator = void 0;
|
|
3032
3011
|
this.authorizedPubkey = args.authorizedPubkey;
|
|
3033
3012
|
this.nonce = args.nonce;
|
|
3034
3013
|
this.feeCalculator = args.feeCalculator;
|
|
@@ -3329,7 +3308,7 @@ class SystemInstruction {
|
|
|
3329
3308
|
|
|
3330
3309
|
static checkKeyLength(keys, expectedLength) {
|
|
3331
3310
|
if (keys.length < expectedLength) {
|
|
3332
|
-
throw new Error(
|
|
3311
|
+
throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
|
|
3333
3312
|
}
|
|
3334
3313
|
}
|
|
3335
3314
|
|
|
@@ -3761,8 +3740,7 @@ class SystemProgram {
|
|
|
3761
3740
|
}
|
|
3762
3741
|
|
|
3763
3742
|
}
|
|
3764
|
-
|
|
3765
|
-
_defineProperty(SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
|
|
3743
|
+
SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
|
|
3766
3744
|
|
|
3767
3745
|
// rest of the Transaction fields
|
|
3768
3746
|
//
|
|
@@ -3931,8 +3909,7 @@ class Loader {
|
|
|
3931
3909
|
}
|
|
3932
3910
|
|
|
3933
3911
|
}
|
|
3934
|
-
|
|
3935
|
-
_defineProperty(Loader, "chunkSize", CHUNK_SIZE);
|
|
3912
|
+
Loader.chunkSize = CHUNK_SIZE;
|
|
3936
3913
|
|
|
3937
3914
|
const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
|
|
3938
3915
|
/**
|
|
@@ -3983,14 +3960,10 @@ class AgentManager {
|
|
|
3983
3960
|
}
|
|
3984
3961
|
|
|
3985
3962
|
constructor(useHttps) {
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
_defineProperty(this, "_destroyTimeout", null);
|
|
3991
|
-
|
|
3992
|
-
_defineProperty(this, "_useHttps", void 0);
|
|
3993
|
-
|
|
3963
|
+
this._agent = void 0;
|
|
3964
|
+
this._activeRequests = 0;
|
|
3965
|
+
this._destroyTimeout = null;
|
|
3966
|
+
this._useHttps = void 0;
|
|
3994
3967
|
this._useHttps = useHttps === true;
|
|
3995
3968
|
this._agent = AgentManager._newAgent(this._useHttps);
|
|
3996
3969
|
}
|
|
@@ -4063,16 +4036,11 @@ class EpochSchedule {
|
|
|
4063
4036
|
|
|
4064
4037
|
/** The first slot of `firstNormalEpoch` */
|
|
4065
4038
|
constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
_defineProperty(this, "firstNormalEpoch", void 0);
|
|
4073
|
-
|
|
4074
|
-
_defineProperty(this, "firstNormalSlot", void 0);
|
|
4075
|
-
|
|
4039
|
+
this.slotsPerEpoch = void 0;
|
|
4040
|
+
this.leaderScheduleSlotOffset = void 0;
|
|
4041
|
+
this.warmup = void 0;
|
|
4042
|
+
this.firstNormalEpoch = void 0;
|
|
4043
|
+
this.firstNormalSlot = void 0;
|
|
4076
4044
|
this.slotsPerEpoch = slotsPerEpoch;
|
|
4077
4045
|
this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
|
|
4078
4046
|
this.warmup = warmup;
|
|
@@ -4124,9 +4092,7 @@ class EpochSchedule {
|
|
|
4124
4092
|
class SendTransactionError extends Error {
|
|
4125
4093
|
constructor(message, logs) {
|
|
4126
4094
|
super(message);
|
|
4127
|
-
|
|
4128
|
-
_defineProperty(this, "logs", void 0);
|
|
4129
|
-
|
|
4095
|
+
this.logs = void 0;
|
|
4130
4096
|
this.logs = logs;
|
|
4131
4097
|
}
|
|
4132
4098
|
|
|
@@ -4410,7 +4376,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
|
|
|
4410
4376
|
break;
|
|
4411
4377
|
}
|
|
4412
4378
|
|
|
4413
|
-
console.log(
|
|
4379
|
+
console.log(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);
|
|
4414
4380
|
await sleep(waitTime);
|
|
4415
4381
|
waitTime *= 2;
|
|
4416
4382
|
}
|
|
@@ -4420,7 +4386,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
|
|
|
4420
4386
|
if (res.ok) {
|
|
4421
4387
|
callback(null, text);
|
|
4422
4388
|
} else {
|
|
4423
|
-
callback(new Error(
|
|
4389
|
+
callback(new Error(`${res.status} ${res.statusText}: ${text}`));
|
|
4424
4390
|
}
|
|
4425
4391
|
} catch (err) {
|
|
4426
4392
|
if (err instanceof Error) callback(err);
|
|
@@ -5086,67 +5052,39 @@ class Connection {
|
|
|
5086
5052
|
* @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
|
|
5087
5053
|
*/
|
|
5088
5054
|
constructor(endpoint, commitmentOrConfig) {
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
_defineProperty(this, "_rpcWebSocket", void 0);
|
|
5104
|
-
|
|
5105
|
-
_defineProperty(this, "_rpcWebSocketConnected", false);
|
|
5106
|
-
|
|
5107
|
-
_defineProperty(this, "_rpcWebSocketHeartbeat", null);
|
|
5108
|
-
|
|
5109
|
-
_defineProperty(this, "_rpcWebSocketIdleTimeout", null);
|
|
5110
|
-
|
|
5111
|
-
_defineProperty(this, "_disableBlockhashCaching", false);
|
|
5112
|
-
|
|
5113
|
-
_defineProperty(this, "_pollingBlockhash", false);
|
|
5114
|
-
|
|
5115
|
-
_defineProperty(this, "_blockhashInfo", {
|
|
5055
|
+
this._commitment = void 0;
|
|
5056
|
+
this._confirmTransactionInitialTimeout = void 0;
|
|
5057
|
+
this._rpcEndpoint = void 0;
|
|
5058
|
+
this._rpcWsEndpoint = void 0;
|
|
5059
|
+
this._rpcClient = void 0;
|
|
5060
|
+
this._rpcRequest = void 0;
|
|
5061
|
+
this._rpcBatchRequest = void 0;
|
|
5062
|
+
this._rpcWebSocket = void 0;
|
|
5063
|
+
this._rpcWebSocketConnected = false;
|
|
5064
|
+
this._rpcWebSocketHeartbeat = null;
|
|
5065
|
+
this._rpcWebSocketIdleTimeout = null;
|
|
5066
|
+
this._disableBlockhashCaching = false;
|
|
5067
|
+
this._pollingBlockhash = false;
|
|
5068
|
+
this._blockhashInfo = {
|
|
5116
5069
|
recentBlockhash: null,
|
|
5117
5070
|
lastFetch: 0,
|
|
5118
5071
|
transactionSignatures: [],
|
|
5119
5072
|
simulatedSignatures: []
|
|
5120
|
-
}
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
_defineProperty(this, "_signatureSubscriptions", {});
|
|
5137
|
-
|
|
5138
|
-
_defineProperty(this, "_slotSubscriptionCounter", 0);
|
|
5139
|
-
|
|
5140
|
-
_defineProperty(this, "_slotSubscriptions", {});
|
|
5141
|
-
|
|
5142
|
-
_defineProperty(this, "_logsSubscriptionCounter", 0);
|
|
5143
|
-
|
|
5144
|
-
_defineProperty(this, "_logsSubscriptions", {});
|
|
5145
|
-
|
|
5146
|
-
_defineProperty(this, "_slotUpdateSubscriptionCounter", 0);
|
|
5147
|
-
|
|
5148
|
-
_defineProperty(this, "_slotUpdateSubscriptions", {});
|
|
5149
|
-
|
|
5073
|
+
};
|
|
5074
|
+
this._accountChangeSubscriptionCounter = 0;
|
|
5075
|
+
this._accountChangeSubscriptions = {};
|
|
5076
|
+
this._programAccountChangeSubscriptionCounter = 0;
|
|
5077
|
+
this._programAccountChangeSubscriptions = {};
|
|
5078
|
+
this._rootSubscriptionCounter = 0;
|
|
5079
|
+
this._rootSubscriptions = {};
|
|
5080
|
+
this._signatureSubscriptionCounter = 0;
|
|
5081
|
+
this._signatureSubscriptions = {};
|
|
5082
|
+
this._slotSubscriptionCounter = 0;
|
|
5083
|
+
this._slotSubscriptions = {};
|
|
5084
|
+
this._logsSubscriptionCounter = 0;
|
|
5085
|
+
this._logsSubscriptions = {};
|
|
5086
|
+
this._slotUpdateSubscriptionCounter = 0;
|
|
5087
|
+
this._slotUpdateSubscriptions = {};
|
|
5150
5088
|
let url = new URL(endpoint);
|
|
5151
5089
|
const useHttps = url.protocol === 'https:';
|
|
5152
5090
|
let wsEndpoint;
|
|
@@ -5520,7 +5458,7 @@ class Connection {
|
|
|
5520
5458
|
const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
5521
5459
|
|
|
5522
5460
|
if ('error' in res) {
|
|
5523
|
-
throw new Error(
|
|
5461
|
+
throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
|
|
5524
5462
|
}
|
|
5525
5463
|
|
|
5526
5464
|
return res.result;
|
|
@@ -5656,7 +5594,7 @@ class Connection {
|
|
|
5656
5594
|
|
|
5657
5595
|
if (response === null) {
|
|
5658
5596
|
const duration = (Date.now() - start) / 1000;
|
|
5659
|
-
throw new Error(
|
|
5597
|
+
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.`);
|
|
5660
5598
|
}
|
|
5661
5599
|
|
|
5662
5600
|
return response;
|
|
@@ -6430,7 +6368,7 @@ class Connection {
|
|
|
6430
6368
|
await sleep(MS_PER_SLOT / 2);
|
|
6431
6369
|
}
|
|
6432
6370
|
|
|
6433
|
-
throw new Error(
|
|
6371
|
+
throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);
|
|
6434
6372
|
} finally {
|
|
6435
6373
|
this._pollingBlockhash = false;
|
|
6436
6374
|
}
|
|
@@ -6687,7 +6625,7 @@ class Connection {
|
|
|
6687
6625
|
}
|
|
6688
6626
|
|
|
6689
6627
|
if (err instanceof Error) {
|
|
6690
|
-
console.error(
|
|
6628
|
+
console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
|
|
6691
6629
|
}
|
|
6692
6630
|
}
|
|
6693
6631
|
}
|
|
@@ -6707,7 +6645,7 @@ class Connection {
|
|
|
6707
6645
|
await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
|
|
6708
6646
|
} catch (err) {
|
|
6709
6647
|
if (err instanceof Error) {
|
|
6710
|
-
console.error(
|
|
6648
|
+
console.error(`${rpcMethod} error:`, err.message);
|
|
6711
6649
|
}
|
|
6712
6650
|
}
|
|
6713
6651
|
}
|
|
@@ -6872,7 +6810,7 @@ class Connection {
|
|
|
6872
6810
|
|
|
6873
6811
|
this._updateSubscriptions();
|
|
6874
6812
|
} else {
|
|
6875
|
-
throw new Error(
|
|
6813
|
+
throw new Error(`Unknown account change id: ${id}`);
|
|
6876
6814
|
}
|
|
6877
6815
|
}
|
|
6878
6816
|
/**
|
|
@@ -6938,7 +6876,7 @@ class Connection {
|
|
|
6938
6876
|
|
|
6939
6877
|
this._updateSubscriptions();
|
|
6940
6878
|
} else {
|
|
6941
|
-
throw new Error(
|
|
6879
|
+
throw new Error(`Unknown program account change id: ${id}`);
|
|
6942
6880
|
}
|
|
6943
6881
|
}
|
|
6944
6882
|
/**
|
|
@@ -6968,7 +6906,7 @@ class Connection {
|
|
|
6968
6906
|
|
|
6969
6907
|
async removeOnLogsListener(id) {
|
|
6970
6908
|
if (!this._logsSubscriptions[id]) {
|
|
6971
|
-
throw new Error(
|
|
6909
|
+
throw new Error(`Unknown logs id: ${id}`);
|
|
6972
6910
|
}
|
|
6973
6911
|
|
|
6974
6912
|
const subInfo = this._logsSubscriptions[id];
|
|
@@ -7044,7 +6982,7 @@ class Connection {
|
|
|
7044
6982
|
|
|
7045
6983
|
this._updateSubscriptions();
|
|
7046
6984
|
} else {
|
|
7047
|
-
throw new Error(
|
|
6985
|
+
throw new Error(`Unknown slot change id: ${id}`);
|
|
7048
6986
|
}
|
|
7049
6987
|
}
|
|
7050
6988
|
/**
|
|
@@ -7097,7 +7035,7 @@ class Connection {
|
|
|
7097
7035
|
|
|
7098
7036
|
this._updateSubscriptions();
|
|
7099
7037
|
} else {
|
|
7100
|
-
throw new Error(
|
|
7038
|
+
throw new Error(`Unknown slot update id: ${id}`);
|
|
7101
7039
|
}
|
|
7102
7040
|
}
|
|
7103
7041
|
|
|
@@ -7238,7 +7176,7 @@ class Connection {
|
|
|
7238
7176
|
|
|
7239
7177
|
this._updateSubscriptions();
|
|
7240
7178
|
} else {
|
|
7241
|
-
throw new Error(
|
|
7179
|
+
throw new Error(`Unknown signature result id: ${id}`);
|
|
7242
7180
|
}
|
|
7243
7181
|
}
|
|
7244
7182
|
/**
|
|
@@ -7290,7 +7228,7 @@ class Connection {
|
|
|
7290
7228
|
|
|
7291
7229
|
this._updateSubscriptions();
|
|
7292
7230
|
} else {
|
|
7293
|
-
throw new Error(
|
|
7231
|
+
throw new Error(`Unknown root change id: ${id}`);
|
|
7294
7232
|
}
|
|
7295
7233
|
}
|
|
7296
7234
|
|
|
@@ -7311,7 +7249,7 @@ class Keypair {
|
|
|
7311
7249
|
* @param keypair ed25519 keypair
|
|
7312
7250
|
*/
|
|
7313
7251
|
constructor(keypair) {
|
|
7314
|
-
|
|
7252
|
+
this._keypair = void 0;
|
|
7315
7253
|
|
|
7316
7254
|
if (keypair) {
|
|
7317
7255
|
this._keypair = keypair;
|
|
@@ -7415,8 +7353,8 @@ class Ed25519Program {
|
|
|
7415
7353
|
signature,
|
|
7416
7354
|
instructionIndex
|
|
7417
7355
|
} = params;
|
|
7418
|
-
assert(publicKey.length === PUBLIC_KEY_BYTES$1,
|
|
7419
|
-
assert(signature.length === SIGNATURE_BYTES,
|
|
7356
|
+
assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
|
|
7357
|
+
assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
|
|
7420
7358
|
const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
|
|
7421
7359
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
7422
7360
|
const messageDataOffset = signatureOffset + signature.length;
|
|
@@ -7454,7 +7392,7 @@ class Ed25519Program {
|
|
|
7454
7392
|
message,
|
|
7455
7393
|
instructionIndex
|
|
7456
7394
|
} = params;
|
|
7457
|
-
assert(privateKey.length === PRIVATE_KEY_BYTES$1,
|
|
7395
|
+
assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
|
|
7458
7396
|
|
|
7459
7397
|
try {
|
|
7460
7398
|
const keypair = Keypair.fromSecretKey(privateKey);
|
|
@@ -7467,13 +7405,12 @@ class Ed25519Program {
|
|
|
7467
7405
|
instructionIndex
|
|
7468
7406
|
});
|
|
7469
7407
|
} catch (error) {
|
|
7470
|
-
throw new Error(
|
|
7408
|
+
throw new Error(`Error creating instruction; ${error}`);
|
|
7471
7409
|
}
|
|
7472
7410
|
}
|
|
7473
7411
|
|
|
7474
7412
|
}
|
|
7475
|
-
|
|
7476
|
-
_defineProperty(Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
|
|
7413
|
+
Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
|
|
7477
7414
|
|
|
7478
7415
|
/**
|
|
7479
7416
|
* Address of the stake config account which configures the rate
|
|
@@ -7496,10 +7433,8 @@ class Authorized {
|
|
|
7496
7433
|
* @param withdrawer the withdraw authority
|
|
7497
7434
|
*/
|
|
7498
7435
|
constructor(staker, withdrawer) {
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
_defineProperty(this, "withdrawer", void 0);
|
|
7502
|
-
|
|
7436
|
+
this.staker = void 0;
|
|
7437
|
+
this.withdrawer = void 0;
|
|
7503
7438
|
this.staker = staker;
|
|
7504
7439
|
this.withdrawer = withdrawer;
|
|
7505
7440
|
}
|
|
@@ -7520,12 +7455,9 @@ class Lockup {
|
|
|
7520
7455
|
* Create a new Lockup object
|
|
7521
7456
|
*/
|
|
7522
7457
|
constructor(unixTimestamp, epoch, custodian) {
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
_defineProperty(this, "custodian", void 0);
|
|
7528
|
-
|
|
7458
|
+
this.unixTimestamp = void 0;
|
|
7459
|
+
this.epoch = void 0;
|
|
7460
|
+
this.custodian = void 0;
|
|
7529
7461
|
this.unixTimestamp = unixTimestamp;
|
|
7530
7462
|
this.epoch = epoch;
|
|
7531
7463
|
this.custodian = custodian;
|
|
@@ -7540,7 +7472,7 @@ class Lockup {
|
|
|
7540
7472
|
* Create stake account transaction params
|
|
7541
7473
|
*/
|
|
7542
7474
|
|
|
7543
|
-
|
|
7475
|
+
Lockup.default = new Lockup(0, 0, PublicKey.default);
|
|
7544
7476
|
|
|
7545
7477
|
/**
|
|
7546
7478
|
* Stake Instruction class
|
|
@@ -7753,7 +7685,7 @@ class StakeInstruction {
|
|
|
7753
7685
|
|
|
7754
7686
|
static checkKeyLength(keys, expectedLength) {
|
|
7755
7687
|
if (keys.length < expectedLength) {
|
|
7756
|
-
throw new Error(
|
|
7688
|
+
throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
|
|
7757
7689
|
}
|
|
7758
7690
|
}
|
|
7759
7691
|
|
|
@@ -8228,10 +8160,8 @@ class StakeProgram {
|
|
|
8228
8160
|
}
|
|
8229
8161
|
|
|
8230
8162
|
}
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
_defineProperty(StakeProgram, "space", 200);
|
|
8163
|
+
StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
|
|
8164
|
+
StakeProgram.space = 200;
|
|
8235
8165
|
|
|
8236
8166
|
const {
|
|
8237
8167
|
publicKeyCreate,
|
|
@@ -8261,12 +8191,12 @@ class Secp256k1Program {
|
|
|
8261
8191
|
* @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
|
|
8262
8192
|
*/
|
|
8263
8193
|
static publicKeyToEthAddress(publicKey) {
|
|
8264
|
-
assert(publicKey.length === PUBLIC_KEY_BYTES,
|
|
8194
|
+
assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
|
|
8265
8195
|
|
|
8266
8196
|
try {
|
|
8267
8197
|
return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
8268
8198
|
} catch (error) {
|
|
8269
|
-
throw new Error(
|
|
8199
|
+
throw new Error(`Error constructing Ethereum address: ${error}`);
|
|
8270
8200
|
}
|
|
8271
8201
|
}
|
|
8272
8202
|
/**
|
|
@@ -8317,7 +8247,7 @@ class Secp256k1Program {
|
|
|
8317
8247
|
ethAddress = rawAddress;
|
|
8318
8248
|
}
|
|
8319
8249
|
|
|
8320
|
-
assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES,
|
|
8250
|
+
assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);
|
|
8321
8251
|
const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
|
|
8322
8252
|
const ethAddressOffset = dataStart;
|
|
8323
8253
|
const signatureOffset = dataStart + ethAddress.length;
|
|
@@ -8356,7 +8286,7 @@ class Secp256k1Program {
|
|
|
8356
8286
|
message,
|
|
8357
8287
|
instructionIndex
|
|
8358
8288
|
} = params;
|
|
8359
|
-
assert(pkey.length === PRIVATE_KEY_BYTES,
|
|
8289
|
+
assert(pkey.length === PRIVATE_KEY_BYTES, `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);
|
|
8360
8290
|
|
|
8361
8291
|
try {
|
|
8362
8292
|
const privateKey = toBuffer(pkey);
|
|
@@ -8375,13 +8305,12 @@ class Secp256k1Program {
|
|
|
8375
8305
|
instructionIndex
|
|
8376
8306
|
});
|
|
8377
8307
|
} catch (error) {
|
|
8378
|
-
throw new Error(
|
|
8308
|
+
throw new Error(`Error creating instruction; ${error}`);
|
|
8379
8309
|
}
|
|
8380
8310
|
}
|
|
8381
8311
|
|
|
8382
8312
|
}
|
|
8383
|
-
|
|
8384
|
-
_defineProperty(Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
|
|
8313
|
+
Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
|
|
8385
8314
|
|
|
8386
8315
|
const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
|
|
8387
8316
|
/**
|
|
@@ -8414,10 +8343,8 @@ class ValidatorInfo {
|
|
|
8414
8343
|
* @param info validator information
|
|
8415
8344
|
*/
|
|
8416
8345
|
constructor(key, info) {
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
_defineProperty(this, "info", void 0);
|
|
8420
|
-
|
|
8346
|
+
this.key = void 0;
|
|
8347
|
+
this.info = void 0;
|
|
8421
8348
|
this.key = key;
|
|
8422
8349
|
this.info = info;
|
|
8423
8350
|
}
|
|
@@ -8481,26 +8408,16 @@ class VoteAccount {
|
|
|
8481
8408
|
* @internal
|
|
8482
8409
|
*/
|
|
8483
8410
|
constructor(args) {
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
_defineProperty(this, "rootSlot", void 0);
|
|
8495
|
-
|
|
8496
|
-
_defineProperty(this, "epoch", void 0);
|
|
8497
|
-
|
|
8498
|
-
_defineProperty(this, "credits", void 0);
|
|
8499
|
-
|
|
8500
|
-
_defineProperty(this, "lastEpochCredits", void 0);
|
|
8501
|
-
|
|
8502
|
-
_defineProperty(this, "epochCredits", void 0);
|
|
8503
|
-
|
|
8411
|
+
this.nodePubkey = void 0;
|
|
8412
|
+
this.authorizedVoterPubkey = void 0;
|
|
8413
|
+
this.authorizedWithdrawerPubkey = void 0;
|
|
8414
|
+
this.commission = void 0;
|
|
8415
|
+
this.votes = void 0;
|
|
8416
|
+
this.rootSlot = void 0;
|
|
8417
|
+
this.epoch = void 0;
|
|
8418
|
+
this.credits = void 0;
|
|
8419
|
+
this.lastEpochCredits = void 0;
|
|
8420
|
+
this.epochCredits = void 0;
|
|
8504
8421
|
this.nodePubkey = args.nodePubkey;
|
|
8505
8422
|
this.authorizedVoterPubkey = args.authorizedVoterPubkey;
|
|
8506
8423
|
this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
|
|
@@ -8563,7 +8480,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
|
|
|
8563
8480
|
const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
8564
8481
|
|
|
8565
8482
|
if (status.err) {
|
|
8566
|
-
throw new Error(
|
|
8483
|
+
throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
8567
8484
|
}
|
|
8568
8485
|
|
|
8569
8486
|
return signature;
|
|
@@ -8595,7 +8512,7 @@ function clusterApiUrl(cluster, tls) {
|
|
|
8595
8512
|
const url = endpoint[key][cluster];
|
|
8596
8513
|
|
|
8597
8514
|
if (!url) {
|
|
8598
|
-
throw new Error(
|
|
8515
|
+
throw new Error(`Unknown ${key} cluster: ${cluster}`);
|
|
8599
8516
|
}
|
|
8600
8517
|
|
|
8601
8518
|
return url;
|