@solana/web3.js 1.35.1 → 1.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.browser.cjs.js +9840 -0
- package/lib/index.browser.cjs.js.map +1 -0
- package/lib/index.browser.esm.js +173 -68
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +174 -67
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +61 -15
- package/lib/index.esm.js +174 -67
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +1591 -1247
- 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 +93 -16
- package/package.json +6 -5
- package/src/connection.ts +116 -27
- 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
|
*/
|
|
@@ -1527,13 +1562,20 @@ declare module '@solana/web3.js' {
|
|
|
1527
1562
|
publicKey: PublicKey,
|
|
1528
1563
|
commitment?: Commitment,
|
|
1529
1564
|
): Promise<AccountInfo<Buffer> | null>;
|
|
1565
|
+
/**
|
|
1566
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys, return with context
|
|
1567
|
+
*/
|
|
1568
|
+
getMultipleAccountsInfoAndContext(
|
|
1569
|
+
publicKeys: PublicKey[],
|
|
1570
|
+
commitment?: Commitment,
|
|
1571
|
+
): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>>;
|
|
1530
1572
|
/**
|
|
1531
1573
|
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
1532
1574
|
*/
|
|
1533
1575
|
getMultipleAccountsInfo(
|
|
1534
1576
|
publicKeys: PublicKey[],
|
|
1535
|
-
|
|
1536
|
-
): Promise<(AccountInfo<Buffer
|
|
1577
|
+
commitment?: Commitment,
|
|
1578
|
+
): Promise<(AccountInfo<Buffer> | null)[]>;
|
|
1537
1579
|
/**
|
|
1538
1580
|
* Returns epoch activation information for a stake account that has been delegated
|
|
1539
1581
|
*/
|
|
@@ -1735,6 +1777,10 @@ declare module '@solana/web3.js' {
|
|
|
1735
1777
|
commitment?: Finality;
|
|
1736
1778
|
},
|
|
1737
1779
|
): Promise<BlockResponse | null>;
|
|
1780
|
+
getBlockHeight(commitment?: Commitment): Promise<number>;
|
|
1781
|
+
getBlockProduction(
|
|
1782
|
+
configOrCommitment?: GetBlockProductionConfig | Commitment,
|
|
1783
|
+
): Promise<RpcResponseAndContext<BlockProduction>>;
|
|
1738
1784
|
/**
|
|
1739
1785
|
* Fetch a confirmed or finalized transaction from the cluster.
|
|
1740
1786
|
*/
|
|
@@ -2373,14 +2419,14 @@ declare module '@solana/web3.js' {
|
|
|
2373
2419
|
* An enumeration of valid StakeInstructionType's
|
|
2374
2420
|
*/
|
|
2375
2421
|
export type StakeInstructionType =
|
|
2376
|
-
| 'AuthorizeWithSeed'
|
|
2377
2422
|
| 'Authorize'
|
|
2423
|
+
| 'AuthorizeWithSeed'
|
|
2378
2424
|
| 'Deactivate'
|
|
2379
2425
|
| 'Delegate'
|
|
2380
2426
|
| 'Initialize'
|
|
2427
|
+
| 'Merge'
|
|
2381
2428
|
| 'Split'
|
|
2382
|
-
| 'Withdraw'
|
|
2383
|
-
| 'Merge';
|
|
2429
|
+
| 'Withdraw';
|
|
2384
2430
|
/**
|
|
2385
2431
|
* Stake authorization type
|
|
2386
2432
|
*/
|
|
@@ -2922,24 +2968,24 @@ declare module '@solana/web3.js' {
|
|
|
2922
2968
|
/**
|
|
2923
2969
|
* History of how many credits earned by the end of each epoch
|
|
2924
2970
|
*/
|
|
2925
|
-
export type EpochCredits = {
|
|
2971
|
+
export type EpochCredits = Readonly<{
|
|
2926
2972
|
epoch: number;
|
|
2927
2973
|
credits: number;
|
|
2928
2974
|
prevCredits: number;
|
|
2929
|
-
}
|
|
2930
|
-
export type AuthorizedVoter = {
|
|
2975
|
+
}>;
|
|
2976
|
+
export type AuthorizedVoter = Readonly<{
|
|
2931
2977
|
epoch: number;
|
|
2932
2978
|
authorizedVoter: PublicKey;
|
|
2933
|
-
}
|
|
2934
|
-
export type PriorVoter = {
|
|
2979
|
+
}>;
|
|
2980
|
+
export type PriorVoter = Readonly<{
|
|
2935
2981
|
authorizedPubkey: PublicKey;
|
|
2936
2982
|
epochOfLastAuthorizedSwitch: number;
|
|
2937
2983
|
targetEpoch: number;
|
|
2938
|
-
}
|
|
2939
|
-
export type BlockTimestamp = {
|
|
2984
|
+
}>;
|
|
2985
|
+
export type BlockTimestamp = Readonly<{
|
|
2940
2986
|
slot: number;
|
|
2941
|
-
|
|
2942
|
-
}
|
|
2987
|
+
timestamp: number;
|
|
2988
|
+
}>;
|
|
2943
2989
|
/**
|
|
2944
2990
|
* VoteAccount class
|
|
2945
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
|
-
const data = _decode(buffer, offset);
|
|
2085
|
+
const rslShim = rsl;
|
|
2047
2086
|
|
|
2048
|
-
|
|
2087
|
+
rslShim.decode = (b, offset) => {
|
|
2088
|
+
const data = _decode(b, offset);
|
|
2089
|
+
|
|
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
|
*/
|
|
@@ -5474,35 +5544,32 @@ class Connection {
|
|
|
5474
5544
|
}
|
|
5475
5545
|
}
|
|
5476
5546
|
/**
|
|
5477
|
-
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
5547
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys, return with context
|
|
5478
5548
|
*/
|
|
5479
5549
|
|
|
5480
5550
|
|
|
5481
|
-
async
|
|
5551
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitment) {
|
|
5482
5552
|
const keys = publicKeys.map(key => key.toBase58());
|
|
5483
|
-
let commitment;
|
|
5484
|
-
let encoding = 'base64';
|
|
5485
5553
|
|
|
5486
|
-
|
|
5487
|
-
if (typeof configOrCommitment === 'string') {
|
|
5488
|
-
commitment = configOrCommitment;
|
|
5489
|
-
encoding = 'base64';
|
|
5490
|
-
} else {
|
|
5491
|
-
commitment = configOrCommitment.commitment;
|
|
5492
|
-
encoding = configOrCommitment.encoding || 'base64';
|
|
5493
|
-
}
|
|
5494
|
-
}
|
|
5495
|
-
|
|
5496
|
-
const args = this._buildArgs([keys], commitment, encoding);
|
|
5554
|
+
const args = this._buildArgs([keys], commitment, 'base64');
|
|
5497
5555
|
|
|
5498
5556
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
5499
|
-
const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(
|
|
5557
|
+
const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
|
|
5500
5558
|
|
|
5501
5559
|
if ('error' in res) {
|
|
5502
5560
|
throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
|
|
5503
5561
|
}
|
|
5504
5562
|
|
|
5505
|
-
return res.result
|
|
5563
|
+
return res.result;
|
|
5564
|
+
}
|
|
5565
|
+
/**
|
|
5566
|
+
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
5567
|
+
*/
|
|
5568
|
+
|
|
5569
|
+
|
|
5570
|
+
async getMultipleAccountsInfo(publicKeys, commitment) {
|
|
5571
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitment);
|
|
5572
|
+
return res.value;
|
|
5506
5573
|
}
|
|
5507
5574
|
/**
|
|
5508
5575
|
* Returns epoch activation information for a stake account that has been delegated
|
|
@@ -6114,6 +6181,54 @@ class Connection {
|
|
|
6114
6181
|
})
|
|
6115
6182
|
};
|
|
6116
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
|
+
}
|
|
6117
6232
|
/**
|
|
6118
6233
|
* Fetch a confirmed or finalized transaction from the cluster.
|
|
6119
6234
|
*/
|
|
@@ -6774,12 +6889,6 @@ class Connection {
|
|
|
6774
6889
|
|
|
6775
6890
|
if ('data' in res.error) {
|
|
6776
6891
|
logs = res.error.data.logs;
|
|
6777
|
-
|
|
6778
|
-
if (logs && Array.isArray(logs)) {
|
|
6779
|
-
const traceIndent = '\n ';
|
|
6780
|
-
const logTrace = traceIndent + logs.join(traceIndent);
|
|
6781
|
-
console.error(res.error.message, logTrace);
|
|
6782
|
-
}
|
|
6783
6892
|
}
|
|
6784
6893
|
|
|
6785
6894
|
throw new SendTransactionError('failed to send transaction: ' + res.error.message, logs);
|
|
@@ -7595,16 +7704,18 @@ class Ed25519Program {
|
|
|
7595
7704
|
const messageDataOffset = signatureOffset + signature.length;
|
|
7596
7705
|
const numSignatures = 1;
|
|
7597
7706
|
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
7707
|
+
const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
|
|
7708
|
+
: instructionIndex;
|
|
7598
7709
|
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
7599
7710
|
numSignatures,
|
|
7600
7711
|
padding: 0,
|
|
7601
7712
|
signatureOffset,
|
|
7602
|
-
signatureInstructionIndex:
|
|
7713
|
+
signatureInstructionIndex: index,
|
|
7603
7714
|
publicKeyOffset,
|
|
7604
|
-
publicKeyInstructionIndex:
|
|
7715
|
+
publicKeyInstructionIndex: index,
|
|
7605
7716
|
messageDataOffset,
|
|
7606
7717
|
messageDataSize: message.length,
|
|
7607
|
-
messageInstructionIndex:
|
|
7718
|
+
messageInstructionIndex: index
|
|
7608
7719
|
}, instructionData);
|
|
7609
7720
|
instructionData.fill(publicKey, publicKeyOffset);
|
|
7610
7721
|
instructionData.fill(signature, signatureOffset);
|
|
@@ -7675,10 +7786,10 @@ class Authorized {
|
|
|
7675
7786
|
}
|
|
7676
7787
|
|
|
7677
7788
|
}
|
|
7789
|
+
|
|
7678
7790
|
/**
|
|
7679
7791
|
* Stake account lockup info
|
|
7680
7792
|
*/
|
|
7681
|
-
|
|
7682
7793
|
class Lockup {
|
|
7683
7794
|
/** Unix timestamp of lockup expiration */
|
|
7684
7795
|
|
|
@@ -7703,10 +7814,6 @@ class Lockup {
|
|
|
7703
7814
|
|
|
7704
7815
|
|
|
7705
7816
|
}
|
|
7706
|
-
/**
|
|
7707
|
-
* Create stake account transaction params
|
|
7708
|
-
*/
|
|
7709
|
-
|
|
7710
7817
|
Lockup.default = new Lockup(0, 0, PublicKey.default);
|
|
7711
7818
|
|
|
7712
7819
|
/**
|
|
@@ -8734,8 +8841,8 @@ class VoteAccount {
|
|
|
8734
8841
|
}
|
|
8735
8842
|
|
|
8736
8843
|
function parseAuthorizedVoter({
|
|
8737
|
-
|
|
8738
|
-
|
|
8844
|
+
authorizedVoter,
|
|
8845
|
+
epoch
|
|
8739
8846
|
}) {
|
|
8740
8847
|
return {
|
|
8741
8848
|
epoch,
|
|
@@ -8764,7 +8871,7 @@ function getPriorVoters({
|
|
|
8764
8871
|
return [];
|
|
8765
8872
|
}
|
|
8766
8873
|
|
|
8767
|
-
return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx)];
|
|
8874
|
+
return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx).map(parsePriorVoters)];
|
|
8768
8875
|
}
|
|
8769
8876
|
|
|
8770
8877
|
/**
|