@solana/web3.js 1.27.1 → 1.28.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.esm.js +57 -7
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +57 -7
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +26 -2
- package/lib/index.esm.js +57 -7
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +57 -7
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/module.flow.js +47 -3
- package/package.json +1 -1
- package/src/connection.ts +62 -4
- package/src/message.ts +27 -0
- package/src/transaction.ts +8 -4
package/lib/index.browser.esm.js
CHANGED
|
@@ -488,16 +488,35 @@ class Message {
|
|
|
488
488
|
|
|
489
489
|
_defineProperty(this, "instructions", void 0);
|
|
490
490
|
|
|
491
|
+
_defineProperty(this, "indexToProgramIds", new Map());
|
|
492
|
+
|
|
491
493
|
this.header = args.header;
|
|
492
494
|
this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
|
|
493
495
|
this.recentBlockhash = args.recentBlockhash;
|
|
494
496
|
this.instructions = args.instructions;
|
|
497
|
+
this.instructions.forEach(ix => this.indexToProgramIds.set(ix.programIdIndex, this.accountKeys[ix.programIdIndex]));
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
isAccountSigner(index) {
|
|
501
|
+
return index < this.header.numRequiredSignatures;
|
|
495
502
|
}
|
|
496
503
|
|
|
497
504
|
isAccountWritable(index) {
|
|
498
505
|
return index < this.header.numRequiredSignatures - this.header.numReadonlySignedAccounts || index >= this.header.numRequiredSignatures && index < this.accountKeys.length - this.header.numReadonlyUnsignedAccounts;
|
|
499
506
|
}
|
|
500
507
|
|
|
508
|
+
isProgramId(index) {
|
|
509
|
+
return this.indexToProgramIds.has(index);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
programIds() {
|
|
513
|
+
return [...this.indexToProgramIds.values()];
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
nonProgramIds() {
|
|
517
|
+
return this.accountKeys.filter((_, index) => !this.isProgramId(index));
|
|
518
|
+
}
|
|
519
|
+
|
|
501
520
|
serialize() {
|
|
502
521
|
const numKeys = this.accountKeys.length;
|
|
503
522
|
let keyCount = [];
|
|
@@ -1211,7 +1230,7 @@ class Transaction {
|
|
|
1211
1230
|
*/
|
|
1212
1231
|
|
|
1213
1232
|
|
|
1214
|
-
static populate(message, signatures) {
|
|
1233
|
+
static populate(message, signatures = []) {
|
|
1215
1234
|
const transaction = new Transaction();
|
|
1216
1235
|
transaction.recentBlockhash = message.recentBlockhash;
|
|
1217
1236
|
|
|
@@ -1231,7 +1250,7 @@ class Transaction {
|
|
|
1231
1250
|
const pubkey = message.accountKeys[account];
|
|
1232
1251
|
return {
|
|
1233
1252
|
pubkey,
|
|
1234
|
-
isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()),
|
|
1253
|
+
isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()) || message.isAccountSigner(account),
|
|
1235
1254
|
isWritable: message.isAccountWritable(account)
|
|
1236
1255
|
};
|
|
1237
1256
|
});
|
|
@@ -3177,7 +3196,15 @@ const VersionResult = type({
|
|
|
3177
3196
|
});
|
|
3178
3197
|
const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(type({
|
|
3179
3198
|
err: nullable(union([type({}), string()])),
|
|
3180
|
-
logs: nullable(array(string()))
|
|
3199
|
+
logs: nullable(array(string())),
|
|
3200
|
+
accounts: optional(nullable(array(type({
|
|
3201
|
+
executable: boolean(),
|
|
3202
|
+
owner: string(),
|
|
3203
|
+
lamports: number(),
|
|
3204
|
+
data: array(string()),
|
|
3205
|
+
rentEpoch: optional(number())
|
|
3206
|
+
})))),
|
|
3207
|
+
unitsConsumed: optional(number())
|
|
3181
3208
|
}));
|
|
3182
3209
|
|
|
3183
3210
|
function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
|
|
@@ -3903,6 +3930,8 @@ class Connection {
|
|
|
3903
3930
|
|
|
3904
3931
|
/** @internal */
|
|
3905
3932
|
|
|
3933
|
+
/** @internal */
|
|
3934
|
+
|
|
3906
3935
|
/**
|
|
3907
3936
|
* Establish a JSON RPC connection
|
|
3908
3937
|
*
|
|
@@ -3912,6 +3941,8 @@ class Connection {
|
|
|
3912
3941
|
constructor(endpoint, commitmentOrConfig) {
|
|
3913
3942
|
_defineProperty(this, "_commitment", void 0);
|
|
3914
3943
|
|
|
3944
|
+
_defineProperty(this, "_confirmTransactionInitialTimeout", void 0);
|
|
3945
|
+
|
|
3915
3946
|
_defineProperty(this, "_rpcEndpoint", void 0);
|
|
3916
3947
|
|
|
3917
3948
|
_defineProperty(this, "_rpcWsEndpoint", void 0);
|
|
@@ -3980,6 +4011,7 @@ class Connection {
|
|
|
3980
4011
|
this._commitment = commitmentOrConfig;
|
|
3981
4012
|
} else if (commitmentOrConfig) {
|
|
3982
4013
|
this._commitment = commitmentOrConfig.commitment;
|
|
4014
|
+
this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
|
|
3983
4015
|
wsEndpoint = commitmentOrConfig.wsEndpoint;
|
|
3984
4016
|
httpHeaders = commitmentOrConfig.httpHeaders;
|
|
3985
4017
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
@@ -4439,7 +4471,7 @@ class Connection {
|
|
|
4439
4471
|
reject(err);
|
|
4440
4472
|
}
|
|
4441
4473
|
});
|
|
4442
|
-
let timeoutMs = 60 * 1000;
|
|
4474
|
+
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
|
|
4443
4475
|
|
|
4444
4476
|
switch (subscriptionCommitment) {
|
|
4445
4477
|
case 'processed':
|
|
@@ -4448,7 +4480,7 @@ class Connection {
|
|
|
4448
4480
|
case 'confirmed':
|
|
4449
4481
|
case 'singleGossip':
|
|
4450
4482
|
{
|
|
4451
|
-
timeoutMs = 30 * 1000;
|
|
4483
|
+
timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
|
|
4452
4484
|
break;
|
|
4453
4485
|
}
|
|
4454
4486
|
}
|
|
@@ -5235,7 +5267,15 @@ class Connection {
|
|
|
5235
5267
|
*/
|
|
5236
5268
|
|
|
5237
5269
|
|
|
5238
|
-
async simulateTransaction(
|
|
5270
|
+
async simulateTransaction(transactionOrMessage, signers, includeAccounts) {
|
|
5271
|
+
let transaction;
|
|
5272
|
+
|
|
5273
|
+
if (transactionOrMessage instanceof Transaction) {
|
|
5274
|
+
transaction = transactionOrMessage;
|
|
5275
|
+
} else {
|
|
5276
|
+
transaction = Transaction.populate(transactionOrMessage);
|
|
5277
|
+
}
|
|
5278
|
+
|
|
5239
5279
|
if (transaction.nonceInfo && signers) {
|
|
5240
5280
|
transaction.sign(...signers);
|
|
5241
5281
|
} else {
|
|
@@ -5268,7 +5308,9 @@ class Connection {
|
|
|
5268
5308
|
}
|
|
5269
5309
|
}
|
|
5270
5310
|
|
|
5271
|
-
const
|
|
5311
|
+
const message = transaction._compile();
|
|
5312
|
+
|
|
5313
|
+
const signData = message.serialize();
|
|
5272
5314
|
|
|
5273
5315
|
const wireTransaction = transaction._serialize(signData);
|
|
5274
5316
|
|
|
@@ -5278,6 +5320,14 @@ class Connection {
|
|
|
5278
5320
|
commitment: this.commitment
|
|
5279
5321
|
};
|
|
5280
5322
|
|
|
5323
|
+
if (includeAccounts) {
|
|
5324
|
+
const addresses = (Array.isArray(includeAccounts) ? includeAccounts : message.nonProgramIds()).map(key => key.toBase58());
|
|
5325
|
+
config['accounts'] = {
|
|
5326
|
+
encoding: 'base64',
|
|
5327
|
+
addresses
|
|
5328
|
+
};
|
|
5329
|
+
}
|
|
5330
|
+
|
|
5281
5331
|
if (signers) {
|
|
5282
5332
|
config.sigVerify = true;
|
|
5283
5333
|
}
|