@solana/web3.js 1.36.0 → 1.37.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.cjs.js +9848 -0
- package/lib/index.browser.cjs.js.map +1 -0
- package/lib/index.browser.esm.js +168 -52
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +169 -51
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +52 -13
- package/lib/index.esm.js +169 -51
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +1593 -1238
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +5 -4
- package/lib/index.iife.min.js.map +1 -1
- package/module.flow.js +83 -14
- package/package.json +5 -4
- package/src/connection.ts +106 -8
- package/src/ed25519-program.ts +21 -4
- package/src/instruction.ts +15 -5
- package/src/layout.ts +59 -19
- package/src/loader.ts +16 -3
- package/src/message.ts +21 -4
- package/src/nonce-account.ts +15 -2
- package/src/secp256k1-program.ts +15 -1
- package/src/stake-program.ts +83 -21
- package/src/system-program.ts +100 -36
- package/src/transaction.ts +8 -0
- package/src/vote-account.ts +55 -27
- package/src/vote-program.ts +37 -10
package/lib/index.d.ts
CHANGED
|
@@ -456,6 +456,10 @@ declare module '@solana/web3.js' {
|
|
|
456
456
|
* Get a buffer of the Transaction data that need to be covered by signatures
|
|
457
457
|
*/
|
|
458
458
|
serializeMessage(): Buffer;
|
|
459
|
+
/**
|
|
460
|
+
* Get the estimated fee associated with a transaction
|
|
461
|
+
*/
|
|
462
|
+
getEstimatedFee(connection: Connection): Promise<number>;
|
|
459
463
|
/**
|
|
460
464
|
* Specify the public keys which will be used to sign the Transaction.
|
|
461
465
|
* The first signer will be used as the transaction fee payer account.
|
|
@@ -998,6 +1002,33 @@ declare module '@solana/web3.js' {
|
|
|
998
1002
|
/** The unix timestamp of when the block was processed */
|
|
999
1003
|
blockTime: number | null;
|
|
1000
1004
|
};
|
|
1005
|
+
/**
|
|
1006
|
+
* recent block production information
|
|
1007
|
+
*/
|
|
1008
|
+
export type BlockProduction = Readonly<{
|
|
1009
|
+
/** a dictionary of validator identities, as base-58 encoded strings. Value is a two element array containing the number of leader slots and the number of blocks produced */
|
|
1010
|
+
byIdentity: Readonly<Record<string, ReadonlyArray<number>>>;
|
|
1011
|
+
/** Block production slot range */
|
|
1012
|
+
range: Readonly<{
|
|
1013
|
+
/** first slot of the block production information (inclusive) */
|
|
1014
|
+
firstSlot: number;
|
|
1015
|
+
/** last slot of block production information (inclusive) */
|
|
1016
|
+
lastSlot: number;
|
|
1017
|
+
}>;
|
|
1018
|
+
}>;
|
|
1019
|
+
export type GetBlockProductionConfig = {
|
|
1020
|
+
/** Optional commitment level */
|
|
1021
|
+
commitment?: Commitment;
|
|
1022
|
+
/** Slot range to return block production for. If parameter not provided, defaults to current epoch. */
|
|
1023
|
+
range?: {
|
|
1024
|
+
/** first slot to return block production information for (inclusive) */
|
|
1025
|
+
firstSlot: number;
|
|
1026
|
+
/** last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot */
|
|
1027
|
+
lastSlot?: number;
|
|
1028
|
+
};
|
|
1029
|
+
/** Only return results for this validator identity (base-58 encoded) */
|
|
1030
|
+
identity?: string;
|
|
1031
|
+
};
|
|
1001
1032
|
/**
|
|
1002
1033
|
* A performance sample
|
|
1003
1034
|
*/
|
|
@@ -1389,7 +1420,7 @@ declare module '@solana/web3.js' {
|
|
|
1389
1420
|
httpHeaders?: HttpHeaders;
|
|
1390
1421
|
/** Optional fetch middleware callback */
|
|
1391
1422
|
fetchMiddleware?: FetchMiddleware;
|
|
1392
|
-
/** Optional Disable
|
|
1423
|
+
/** Optional Disable retrying calls when server responds with HTTP 429 (Too Many Requests) */
|
|
1393
1424
|
disableRetryOnRateLimit?: boolean;
|
|
1394
1425
|
/** time to allow for the server to initially process a transaction (in milliseconds) */
|
|
1395
1426
|
confirmTransactionInitialTimeout?: number;
|
|
@@ -1412,6 +1443,10 @@ declare module '@solana/web3.js' {
|
|
|
1412
1443
|
* The default commitment used for requests
|
|
1413
1444
|
*/
|
|
1414
1445
|
get commitment(): Commitment | undefined;
|
|
1446
|
+
/**
|
|
1447
|
+
* The RPC endpoint
|
|
1448
|
+
*/
|
|
1449
|
+
get rpcEndpoint(): string;
|
|
1415
1450
|
/**
|
|
1416
1451
|
* Fetch the balance for the specified public key, return with context
|
|
1417
1452
|
*/
|
|
@@ -1742,6 +1777,10 @@ declare module '@solana/web3.js' {
|
|
|
1742
1777
|
commitment?: Finality;
|
|
1743
1778
|
},
|
|
1744
1779
|
): Promise<BlockResponse | null>;
|
|
1780
|
+
getBlockHeight(commitment?: Commitment): Promise<number>;
|
|
1781
|
+
getBlockProduction(
|
|
1782
|
+
configOrCommitment?: GetBlockProductionConfig | Commitment,
|
|
1783
|
+
): Promise<RpcResponseAndContext<BlockProduction>>;
|
|
1745
1784
|
/**
|
|
1746
1785
|
* Fetch a confirmed or finalized transaction from the cluster.
|
|
1747
1786
|
*/
|
|
@@ -2380,14 +2419,14 @@ declare module '@solana/web3.js' {
|
|
|
2380
2419
|
* An enumeration of valid StakeInstructionType's
|
|
2381
2420
|
*/
|
|
2382
2421
|
export type StakeInstructionType =
|
|
2383
|
-
| 'AuthorizeWithSeed'
|
|
2384
2422
|
| 'Authorize'
|
|
2423
|
+
| 'AuthorizeWithSeed'
|
|
2385
2424
|
| 'Deactivate'
|
|
2386
2425
|
| 'Delegate'
|
|
2387
2426
|
| 'Initialize'
|
|
2427
|
+
| 'Merge'
|
|
2388
2428
|
| 'Split'
|
|
2389
|
-
| 'Withdraw'
|
|
2390
|
-
| 'Merge';
|
|
2429
|
+
| 'Withdraw';
|
|
2391
2430
|
/**
|
|
2392
2431
|
* Stake authorization type
|
|
2393
2432
|
*/
|
|
@@ -2929,24 +2968,24 @@ declare module '@solana/web3.js' {
|
|
|
2929
2968
|
/**
|
|
2930
2969
|
* History of how many credits earned by the end of each epoch
|
|
2931
2970
|
*/
|
|
2932
|
-
export type EpochCredits = {
|
|
2971
|
+
export type EpochCredits = Readonly<{
|
|
2933
2972
|
epoch: number;
|
|
2934
2973
|
credits: number;
|
|
2935
2974
|
prevCredits: number;
|
|
2936
|
-
}
|
|
2937
|
-
export type AuthorizedVoter = {
|
|
2975
|
+
}>;
|
|
2976
|
+
export type AuthorizedVoter = Readonly<{
|
|
2938
2977
|
epoch: number;
|
|
2939
2978
|
authorizedVoter: PublicKey;
|
|
2940
|
-
}
|
|
2941
|
-
export type PriorVoter = {
|
|
2979
|
+
}>;
|
|
2980
|
+
export type PriorVoter = Readonly<{
|
|
2942
2981
|
authorizedPubkey: PublicKey;
|
|
2943
2982
|
epochOfLastAuthorizedSwitch: number;
|
|
2944
2983
|
targetEpoch: number;
|
|
2945
|
-
}
|
|
2946
|
-
export type BlockTimestamp = {
|
|
2984
|
+
}>;
|
|
2985
|
+
export type BlockTimestamp = Readonly<{
|
|
2947
2986
|
slot: number;
|
|
2948
|
-
|
|
2949
|
-
}
|
|
2987
|
+
timestamp: number;
|
|
2988
|
+
}>;
|
|
2950
2989
|
/**
|
|
2951
2990
|
* VoteAccount class
|
|
2952
2991
|
*/
|
package/lib/index.esm.js
CHANGED
|
@@ -46,32 +46,38 @@ var inherits_browser = {exports: {}};
|
|
|
46
46
|
if (typeof Object.create === 'function') {
|
|
47
47
|
// implementation from standard node.js 'util' module
|
|
48
48
|
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
if (superCtor) {
|
|
50
|
+
ctor.super_ = superCtor;
|
|
51
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
52
|
+
constructor: {
|
|
53
|
+
value: ctor,
|
|
54
|
+
enumerable: false,
|
|
55
|
+
writable: true,
|
|
56
|
+
configurable: true
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
58
60
|
};
|
|
59
61
|
} else {
|
|
60
62
|
// old school shim for old browsers
|
|
61
63
|
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
if (superCtor) {
|
|
65
|
+
ctor.super_ = superCtor;
|
|
66
|
+
var TempCtor = function () {};
|
|
67
|
+
TempCtor.prototype = superCtor.prototype;
|
|
68
|
+
ctor.prototype = new TempCtor();
|
|
69
|
+
ctor.prototype.constructor = ctor;
|
|
70
|
+
}
|
|
67
71
|
};
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
try {
|
|
71
75
|
var util = require('util');
|
|
76
|
+
/* istanbul ignore next */
|
|
72
77
|
if (typeof util.inherits !== 'function') throw '';
|
|
73
78
|
inherits$1.exports = util.inherits;
|
|
74
79
|
} catch (e) {
|
|
80
|
+
/* istanbul ignore next */
|
|
75
81
|
inherits$1.exports = inherits_browser.exports;
|
|
76
82
|
}
|
|
77
83
|
|
|
@@ -1284,7 +1290,7 @@ hash.ripemd160 = hash.ripemd.ripemd160;
|
|
|
1284
1290
|
|
|
1285
1291
|
var hash = hash$1;
|
|
1286
1292
|
|
|
1287
|
-
const version$2 = "logger/5.
|
|
1293
|
+
const version$2 = "logger/5.6.0";
|
|
1288
1294
|
|
|
1289
1295
|
let _permanentCensorErrors = false;
|
|
1290
1296
|
let _censorErrors = false;
|
|
@@ -1463,6 +1469,40 @@ class Logger {
|
|
|
1463
1469
|
messageDetails.push(`code=${code}`);
|
|
1464
1470
|
messageDetails.push(`version=${this.version}`);
|
|
1465
1471
|
const reason = message;
|
|
1472
|
+
let url = "";
|
|
1473
|
+
switch (code) {
|
|
1474
|
+
case ErrorCode.NUMERIC_FAULT: {
|
|
1475
|
+
url = "NUMERIC_FAULT";
|
|
1476
|
+
const fault = message;
|
|
1477
|
+
switch (fault) {
|
|
1478
|
+
case "overflow":
|
|
1479
|
+
case "underflow":
|
|
1480
|
+
case "division-by-zero":
|
|
1481
|
+
url += "-" + fault;
|
|
1482
|
+
break;
|
|
1483
|
+
case "negative-power":
|
|
1484
|
+
case "negative-width":
|
|
1485
|
+
url += "-unsupported";
|
|
1486
|
+
break;
|
|
1487
|
+
case "unbound-bitwise-result":
|
|
1488
|
+
url += "-unbound-result";
|
|
1489
|
+
break;
|
|
1490
|
+
}
|
|
1491
|
+
break;
|
|
1492
|
+
}
|
|
1493
|
+
case ErrorCode.CALL_EXCEPTION:
|
|
1494
|
+
case ErrorCode.INSUFFICIENT_FUNDS:
|
|
1495
|
+
case ErrorCode.MISSING_NEW:
|
|
1496
|
+
case ErrorCode.NONCE_EXPIRED:
|
|
1497
|
+
case ErrorCode.REPLACEMENT_UNDERPRICED:
|
|
1498
|
+
case ErrorCode.TRANSACTION_REPLACED:
|
|
1499
|
+
case ErrorCode.UNPREDICTABLE_GAS_LIMIT:
|
|
1500
|
+
url = code;
|
|
1501
|
+
break;
|
|
1502
|
+
}
|
|
1503
|
+
if (url) {
|
|
1504
|
+
message += " [ See: https:/\/links.ethers.org/v5-errors-" + url + " ]";
|
|
1505
|
+
}
|
|
1466
1506
|
if (messageDetails.length) {
|
|
1467
1507
|
message += " (" + messageDetails.join(", ") + ")";
|
|
1468
1508
|
}
|
|
@@ -1596,7 +1636,7 @@ class Logger {
|
|
|
1596
1636
|
Logger.errors = ErrorCode;
|
|
1597
1637
|
Logger.levels = LogLevel;
|
|
1598
1638
|
|
|
1599
|
-
const version$1 = "bytes/5.
|
|
1639
|
+
const version$1 = "bytes/5.6.0";
|
|
1600
1640
|
|
|
1601
1641
|
const logger = new Logger(version$1);
|
|
1602
1642
|
///////////////////////////////
|
|
@@ -1693,7 +1733,7 @@ function isHexString(value, length) {
|
|
|
1693
1733
|
return true;
|
|
1694
1734
|
}
|
|
1695
1735
|
|
|
1696
|
-
const version = "sha2/5.
|
|
1736
|
+
const version = "sha2/5.6.0";
|
|
1697
1737
|
|
|
1698
1738
|
new Logger(version);
|
|
1699
1739
|
function sha256(data) {
|
|
@@ -2031,10 +2071,10 @@ const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader111111111111111
|
|
|
2031
2071
|
const publicKey = (property = 'publicKey') => {
|
|
2032
2072
|
return BufferLayout.blob(32, property);
|
|
2033
2073
|
};
|
|
2074
|
+
|
|
2034
2075
|
/**
|
|
2035
2076
|
* Layout for a Rust String type
|
|
2036
2077
|
*/
|
|
2037
|
-
|
|
2038
2078
|
const rustString = (property = 'string') => {
|
|
2039
2079
|
const rsl = BufferLayout.struct([BufferLayout.u32('length'), BufferLayout.u32('lengthPadding'), BufferLayout.blob(BufferLayout.offset(BufferLayout.u32(), -8), 'chars')], property);
|
|
2040
2080
|
|
|
@@ -2042,24 +2082,26 @@ const rustString = (property = 'string') => {
|
|
|
2042
2082
|
|
|
2043
2083
|
const _encode = rsl.encode.bind(rsl);
|
|
2044
2084
|
|
|
2045
|
-
|
|
2046
|
-
|
|
2085
|
+
const rslShim = rsl;
|
|
2086
|
+
|
|
2087
|
+
rslShim.decode = (b, offset) => {
|
|
2088
|
+
const data = _decode(b, offset);
|
|
2047
2089
|
|
|
2048
|
-
return data['chars'].toString(
|
|
2090
|
+
return data['chars'].toString();
|
|
2049
2091
|
};
|
|
2050
2092
|
|
|
2051
|
-
|
|
2093
|
+
rslShim.encode = (str, b, offset) => {
|
|
2052
2094
|
const data = {
|
|
2053
2095
|
chars: Buffer.from(str, 'utf8')
|
|
2054
2096
|
};
|
|
2055
|
-
return _encode(data,
|
|
2097
|
+
return _encode(data, b, offset);
|
|
2056
2098
|
};
|
|
2057
2099
|
|
|
2058
|
-
|
|
2100
|
+
rslShim.alloc = str => {
|
|
2059
2101
|
return BufferLayout.u32().span + BufferLayout.u32().span + Buffer.from(str, 'utf8').length;
|
|
2060
2102
|
};
|
|
2061
2103
|
|
|
2062
|
-
return
|
|
2104
|
+
return rslShim;
|
|
2063
2105
|
};
|
|
2064
2106
|
/**
|
|
2065
2107
|
* Layout for an Authorized object
|
|
@@ -2179,7 +2221,7 @@ class Message {
|
|
|
2179
2221
|
accounts,
|
|
2180
2222
|
programIdIndex
|
|
2181
2223
|
} = instruction;
|
|
2182
|
-
const data = bs58.decode(instruction.data);
|
|
2224
|
+
const data = Array.from(bs58.decode(instruction.data));
|
|
2183
2225
|
let keyIndicesCount = [];
|
|
2184
2226
|
encodeLength(keyIndicesCount, accounts.length);
|
|
2185
2227
|
let dataCount = [];
|
|
@@ -2187,7 +2229,7 @@ class Message {
|
|
|
2187
2229
|
return {
|
|
2188
2230
|
programIdIndex,
|
|
2189
2231
|
keyIndicesCount: Buffer.from(keyIndicesCount),
|
|
2190
|
-
keyIndices:
|
|
2232
|
+
keyIndices: accounts,
|
|
2191
2233
|
dataLength: Buffer.from(dataCount),
|
|
2192
2234
|
data
|
|
2193
2235
|
};
|
|
@@ -2591,6 +2633,14 @@ class Transaction {
|
|
|
2591
2633
|
serializeMessage() {
|
|
2592
2634
|
return this._compile().serialize();
|
|
2593
2635
|
}
|
|
2636
|
+
/**
|
|
2637
|
+
* Get the estimated fee associated with a transaction
|
|
2638
|
+
*/
|
|
2639
|
+
|
|
2640
|
+
|
|
2641
|
+
async getEstimatedFee(connection) {
|
|
2642
|
+
return (await connection.getFeeForMessage(this.compileMessage())).value;
|
|
2643
|
+
}
|
|
2594
2644
|
/**
|
|
2595
2645
|
* Specify the public keys which will be used to sign the Transaction.
|
|
2596
2646
|
* The first signer will be used as the transaction fee payer account.
|
|
@@ -2954,10 +3004,6 @@ function sleep(ms) {
|
|
|
2954
3004
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
2955
3005
|
}
|
|
2956
3006
|
|
|
2957
|
-
/**
|
|
2958
|
-
* @internal
|
|
2959
|
-
*/
|
|
2960
|
-
|
|
2961
3007
|
/**
|
|
2962
3008
|
* Populate a buffer of instruction data using an InstructionType
|
|
2963
3009
|
* @internal
|
|
@@ -3757,11 +3803,11 @@ class SystemProgram {
|
|
|
3757
3803
|
}
|
|
3758
3804
|
SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
|
|
3759
3805
|
|
|
3806
|
+
// Keep program chunks under PACKET_DATA_SIZE, leaving enough room for the
|
|
3760
3807
|
// rest of the Transaction fields
|
|
3761
3808
|
//
|
|
3762
3809
|
// TODO: replace 300 with a proper constant for the size of the other
|
|
3763
3810
|
// Transaction fields
|
|
3764
|
-
|
|
3765
3811
|
const CHUNK_SIZE = PACKET_DATA_SIZE - 300;
|
|
3766
3812
|
/**
|
|
3767
3813
|
* Program loader interface
|
|
@@ -3869,7 +3915,9 @@ class Loader {
|
|
|
3869
3915
|
instruction: 0,
|
|
3870
3916
|
// Load instruction
|
|
3871
3917
|
offset,
|
|
3872
|
-
bytes
|
|
3918
|
+
bytes: bytes,
|
|
3919
|
+
bytesLength: 0,
|
|
3920
|
+
bytesLengthPadding: 0
|
|
3873
3921
|
}, data);
|
|
3874
3922
|
const transaction = new Transaction().add({
|
|
3875
3923
|
keys: [{
|
|
@@ -4329,6 +4377,20 @@ const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(type({
|
|
|
4329
4377
|
unitsConsumed: optional(number())
|
|
4330
4378
|
}));
|
|
4331
4379
|
|
|
4380
|
+
/**
|
|
4381
|
+
* Expected JSON RPC response for the "getBlockProduction" message
|
|
4382
|
+
*/
|
|
4383
|
+
const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
|
|
4384
|
+
byIdentity: record(string(), array(number())),
|
|
4385
|
+
range: type({
|
|
4386
|
+
firstSlot: number(),
|
|
4387
|
+
lastSlot: number()
|
|
4388
|
+
})
|
|
4389
|
+
}));
|
|
4390
|
+
/**
|
|
4391
|
+
* A performance sample
|
|
4392
|
+
*/
|
|
4393
|
+
|
|
4332
4394
|
function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
|
|
4333
4395
|
let agentManager;
|
|
4334
4396
|
|
|
@@ -5189,6 +5251,14 @@ class Connection {
|
|
|
5189
5251
|
get commitment() {
|
|
5190
5252
|
return this._commitment;
|
|
5191
5253
|
}
|
|
5254
|
+
/**
|
|
5255
|
+
* The RPC endpoint
|
|
5256
|
+
*/
|
|
5257
|
+
|
|
5258
|
+
|
|
5259
|
+
get rpcEndpoint() {
|
|
5260
|
+
return this._rpcEndpoint;
|
|
5261
|
+
}
|
|
5192
5262
|
/**
|
|
5193
5263
|
* Fetch the balance for the specified public key, return with context
|
|
5194
5264
|
*/
|
|
@@ -6111,6 +6181,54 @@ class Connection {
|
|
|
6111
6181
|
})
|
|
6112
6182
|
};
|
|
6113
6183
|
}
|
|
6184
|
+
/*
|
|
6185
|
+
* Returns the current block height of the node
|
|
6186
|
+
*/
|
|
6187
|
+
|
|
6188
|
+
|
|
6189
|
+
async getBlockHeight(commitment) {
|
|
6190
|
+
const args = this._buildArgs([], commitment);
|
|
6191
|
+
|
|
6192
|
+
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
6193
|
+
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
6194
|
+
|
|
6195
|
+
if ('error' in res) {
|
|
6196
|
+
throw new Error('failed to get block height information: ' + res.error.message);
|
|
6197
|
+
}
|
|
6198
|
+
|
|
6199
|
+
return res.result;
|
|
6200
|
+
}
|
|
6201
|
+
/*
|
|
6202
|
+
* Returns recent block production information from the current or previous epoch
|
|
6203
|
+
*/
|
|
6204
|
+
|
|
6205
|
+
|
|
6206
|
+
async getBlockProduction(configOrCommitment) {
|
|
6207
|
+
let extra;
|
|
6208
|
+
let commitment;
|
|
6209
|
+
|
|
6210
|
+
if (typeof configOrCommitment === 'string') {
|
|
6211
|
+
commitment = configOrCommitment;
|
|
6212
|
+
} else if (configOrCommitment) {
|
|
6213
|
+
const {
|
|
6214
|
+
commitment: c,
|
|
6215
|
+
...rest
|
|
6216
|
+
} = configOrCommitment;
|
|
6217
|
+
commitment = c;
|
|
6218
|
+
extra = rest;
|
|
6219
|
+
}
|
|
6220
|
+
|
|
6221
|
+
const args = this._buildArgs([], commitment, 'base64', extra);
|
|
6222
|
+
|
|
6223
|
+
const unsafeRes = await this._rpcRequest('getBlockProduction', args);
|
|
6224
|
+
const res = create(unsafeRes, BlockProductionResponseStruct);
|
|
6225
|
+
|
|
6226
|
+
if ('error' in res) {
|
|
6227
|
+
throw new Error('failed to get block production information: ' + res.error.message);
|
|
6228
|
+
}
|
|
6229
|
+
|
|
6230
|
+
return res.result;
|
|
6231
|
+
}
|
|
6114
6232
|
/**
|
|
6115
6233
|
* Fetch a confirmed or finalized transaction from the cluster.
|
|
6116
6234
|
*/
|
|
@@ -6603,7 +6721,14 @@ class Connection {
|
|
|
6603
6721
|
let transaction;
|
|
6604
6722
|
|
|
6605
6723
|
if (transactionOrMessage instanceof Transaction) {
|
|
6606
|
-
|
|
6724
|
+
let originalTx = transactionOrMessage;
|
|
6725
|
+
transaction = new Transaction({
|
|
6726
|
+
recentBlockhash: originalTx.recentBlockhash,
|
|
6727
|
+
nonceInfo: originalTx.nonceInfo,
|
|
6728
|
+
feePayer: originalTx.feePayer,
|
|
6729
|
+
signatures: [...originalTx.signatures]
|
|
6730
|
+
});
|
|
6731
|
+
transaction.instructions = transactionOrMessage.instructions;
|
|
6607
6732
|
} else {
|
|
6608
6733
|
transaction = Transaction.populate(transactionOrMessage);
|
|
6609
6734
|
}
|
|
@@ -6771,12 +6896,6 @@ class Connection {
|
|
|
6771
6896
|
|
|
6772
6897
|
if ('data' in res.error) {
|
|
6773
6898
|
logs = res.error.data.logs;
|
|
6774
|
-
|
|
6775
|
-
if (logs && Array.isArray(logs)) {
|
|
6776
|
-
const traceIndent = '\n ';
|
|
6777
|
-
const logTrace = traceIndent + logs.join(traceIndent);
|
|
6778
|
-
console.error(res.error.message, logTrace);
|
|
6779
|
-
}
|
|
6780
6899
|
}
|
|
6781
6900
|
|
|
6782
6901
|
throw new SendTransactionError('failed to send transaction: ' + res.error.message, logs);
|
|
@@ -6882,6 +7001,7 @@ class Connection {
|
|
|
6882
7001
|
|
|
6883
7002
|
_resetSubscriptions() {
|
|
6884
7003
|
Object.values(this._accountChangeSubscriptions).forEach(s => s.subscriptionId = null);
|
|
7004
|
+
Object.values(this._logsSubscriptions).forEach(s => s.subscriptionId = null);
|
|
6885
7005
|
Object.values(this._programAccountChangeSubscriptions).forEach(s => s.subscriptionId = null);
|
|
6886
7006
|
Object.values(this._rootSubscriptions).forEach(s => s.subscriptionId = null);
|
|
6887
7007
|
Object.values(this._signatureSubscriptions).forEach(s => s.subscriptionId = null);
|
|
@@ -7592,16 +7712,18 @@ class Ed25519Program {
|
|
|
7592
7712
|
const messageDataOffset = signatureOffset + signature.length;
|
|
7593
7713
|
const numSignatures = 1;
|
|
7594
7714
|
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
7715
|
+
const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
|
|
7716
|
+
: instructionIndex;
|
|
7595
7717
|
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
7596
7718
|
numSignatures,
|
|
7597
7719
|
padding: 0,
|
|
7598
7720
|
signatureOffset,
|
|
7599
|
-
signatureInstructionIndex:
|
|
7721
|
+
signatureInstructionIndex: index,
|
|
7600
7722
|
publicKeyOffset,
|
|
7601
|
-
publicKeyInstructionIndex:
|
|
7723
|
+
publicKeyInstructionIndex: index,
|
|
7602
7724
|
messageDataOffset,
|
|
7603
7725
|
messageDataSize: message.length,
|
|
7604
|
-
messageInstructionIndex:
|
|
7726
|
+
messageInstructionIndex: index
|
|
7605
7727
|
}, instructionData);
|
|
7606
7728
|
instructionData.fill(publicKey, publicKeyOffset);
|
|
7607
7729
|
instructionData.fill(signature, signatureOffset);
|
|
@@ -7672,10 +7794,10 @@ class Authorized {
|
|
|
7672
7794
|
}
|
|
7673
7795
|
|
|
7674
7796
|
}
|
|
7797
|
+
|
|
7675
7798
|
/**
|
|
7676
7799
|
* Stake account lockup info
|
|
7677
7800
|
*/
|
|
7678
|
-
|
|
7679
7801
|
class Lockup {
|
|
7680
7802
|
/** Unix timestamp of lockup expiration */
|
|
7681
7803
|
|
|
@@ -7700,10 +7822,6 @@ class Lockup {
|
|
|
7700
7822
|
|
|
7701
7823
|
|
|
7702
7824
|
}
|
|
7703
|
-
/**
|
|
7704
|
-
* Create stake account transaction params
|
|
7705
|
-
*/
|
|
7706
|
-
|
|
7707
7825
|
Lockup.default = new Lockup(0, 0, PublicKey.default);
|
|
7708
7826
|
|
|
7709
7827
|
/**
|
|
@@ -8731,8 +8849,8 @@ class VoteAccount {
|
|
|
8731
8849
|
}
|
|
8732
8850
|
|
|
8733
8851
|
function parseAuthorizedVoter({
|
|
8734
|
-
|
|
8735
|
-
|
|
8852
|
+
authorizedVoter,
|
|
8853
|
+
epoch
|
|
8736
8854
|
}) {
|
|
8737
8855
|
return {
|
|
8738
8856
|
epoch,
|
|
@@ -8761,7 +8879,7 @@ function getPriorVoters({
|
|
|
8761
8879
|
return [];
|
|
8762
8880
|
}
|
|
8763
8881
|
|
|
8764
|
-
return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx)];
|
|
8882
|
+
return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx).map(parsePriorVoters)];
|
|
8765
8883
|
}
|
|
8766
8884
|
|
|
8767
8885
|
/**
|