@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.cjs.js
CHANGED
|
@@ -528,16 +528,35 @@ class Message {
|
|
|
528
528
|
|
|
529
529
|
_defineProperty__default['default'](this, "instructions", void 0);
|
|
530
530
|
|
|
531
|
+
_defineProperty__default['default'](this, "indexToProgramIds", new Map());
|
|
532
|
+
|
|
531
533
|
this.header = args.header;
|
|
532
534
|
this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
|
|
533
535
|
this.recentBlockhash = args.recentBlockhash;
|
|
534
536
|
this.instructions = args.instructions;
|
|
537
|
+
this.instructions.forEach(ix => this.indexToProgramIds.set(ix.programIdIndex, this.accountKeys[ix.programIdIndex]));
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
isAccountSigner(index) {
|
|
541
|
+
return index < this.header.numRequiredSignatures;
|
|
535
542
|
}
|
|
536
543
|
|
|
537
544
|
isAccountWritable(index) {
|
|
538
545
|
return index < this.header.numRequiredSignatures - this.header.numReadonlySignedAccounts || index >= this.header.numRequiredSignatures && index < this.accountKeys.length - this.header.numReadonlyUnsignedAccounts;
|
|
539
546
|
}
|
|
540
547
|
|
|
548
|
+
isProgramId(index) {
|
|
549
|
+
return this.indexToProgramIds.has(index);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
programIds() {
|
|
553
|
+
return [...this.indexToProgramIds.values()];
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
nonProgramIds() {
|
|
557
|
+
return this.accountKeys.filter((_, index) => !this.isProgramId(index));
|
|
558
|
+
}
|
|
559
|
+
|
|
541
560
|
serialize() {
|
|
542
561
|
const numKeys = this.accountKeys.length;
|
|
543
562
|
let keyCount = [];
|
|
@@ -1251,7 +1270,7 @@ class Transaction {
|
|
|
1251
1270
|
*/
|
|
1252
1271
|
|
|
1253
1272
|
|
|
1254
|
-
static populate(message, signatures) {
|
|
1273
|
+
static populate(message, signatures = []) {
|
|
1255
1274
|
const transaction = new Transaction();
|
|
1256
1275
|
transaction.recentBlockhash = message.recentBlockhash;
|
|
1257
1276
|
|
|
@@ -1271,7 +1290,7 @@ class Transaction {
|
|
|
1271
1290
|
const pubkey = message.accountKeys[account];
|
|
1272
1291
|
return {
|
|
1273
1292
|
pubkey,
|
|
1274
|
-
isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()),
|
|
1293
|
+
isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()) || message.isAccountSigner(account),
|
|
1275
1294
|
isWritable: message.isAccountWritable(account)
|
|
1276
1295
|
};
|
|
1277
1296
|
});
|
|
@@ -2703,7 +2722,15 @@ const VersionResult = superstruct.type({
|
|
|
2703
2722
|
});
|
|
2704
2723
|
const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(superstruct.type({
|
|
2705
2724
|
err: superstruct.nullable(superstruct.union([superstruct.type({}), superstruct.string()])),
|
|
2706
|
-
logs: superstruct.nullable(superstruct.array(superstruct.string()))
|
|
2725
|
+
logs: superstruct.nullable(superstruct.array(superstruct.string())),
|
|
2726
|
+
accounts: superstruct.optional(superstruct.nullable(superstruct.array(superstruct.type({
|
|
2727
|
+
executable: superstruct.boolean(),
|
|
2728
|
+
owner: superstruct.string(),
|
|
2729
|
+
lamports: superstruct.number(),
|
|
2730
|
+
data: superstruct.array(superstruct.string()),
|
|
2731
|
+
rentEpoch: superstruct.optional(superstruct.number())
|
|
2732
|
+
})))),
|
|
2733
|
+
unitsConsumed: superstruct.optional(superstruct.number())
|
|
2707
2734
|
}));
|
|
2708
2735
|
|
|
2709
2736
|
function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
|
|
@@ -3435,6 +3462,8 @@ class Connection {
|
|
|
3435
3462
|
|
|
3436
3463
|
/** @internal */
|
|
3437
3464
|
|
|
3465
|
+
/** @internal */
|
|
3466
|
+
|
|
3438
3467
|
/**
|
|
3439
3468
|
* Establish a JSON RPC connection
|
|
3440
3469
|
*
|
|
@@ -3444,6 +3473,8 @@ class Connection {
|
|
|
3444
3473
|
constructor(endpoint, commitmentOrConfig) {
|
|
3445
3474
|
_defineProperty__default['default'](this, "_commitment", void 0);
|
|
3446
3475
|
|
|
3476
|
+
_defineProperty__default['default'](this, "_confirmTransactionInitialTimeout", void 0);
|
|
3477
|
+
|
|
3447
3478
|
_defineProperty__default['default'](this, "_rpcEndpoint", void 0);
|
|
3448
3479
|
|
|
3449
3480
|
_defineProperty__default['default'](this, "_rpcWsEndpoint", void 0);
|
|
@@ -3512,6 +3543,7 @@ class Connection {
|
|
|
3512
3543
|
this._commitment = commitmentOrConfig;
|
|
3513
3544
|
} else if (commitmentOrConfig) {
|
|
3514
3545
|
this._commitment = commitmentOrConfig.commitment;
|
|
3546
|
+
this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
|
|
3515
3547
|
wsEndpoint = commitmentOrConfig.wsEndpoint;
|
|
3516
3548
|
httpHeaders = commitmentOrConfig.httpHeaders;
|
|
3517
3549
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
@@ -3971,7 +4003,7 @@ class Connection {
|
|
|
3971
4003
|
reject(err);
|
|
3972
4004
|
}
|
|
3973
4005
|
});
|
|
3974
|
-
let timeoutMs = 60 * 1000;
|
|
4006
|
+
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
|
|
3975
4007
|
|
|
3976
4008
|
switch (subscriptionCommitment) {
|
|
3977
4009
|
case 'processed':
|
|
@@ -3980,7 +4012,7 @@ class Connection {
|
|
|
3980
4012
|
case 'confirmed':
|
|
3981
4013
|
case 'singleGossip':
|
|
3982
4014
|
{
|
|
3983
|
-
timeoutMs = 30 * 1000;
|
|
4015
|
+
timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
|
|
3984
4016
|
break;
|
|
3985
4017
|
}
|
|
3986
4018
|
}
|
|
@@ -4767,7 +4799,15 @@ class Connection {
|
|
|
4767
4799
|
*/
|
|
4768
4800
|
|
|
4769
4801
|
|
|
4770
|
-
async simulateTransaction(
|
|
4802
|
+
async simulateTransaction(transactionOrMessage, signers, includeAccounts) {
|
|
4803
|
+
let transaction;
|
|
4804
|
+
|
|
4805
|
+
if (transactionOrMessage instanceof Transaction) {
|
|
4806
|
+
transaction = transactionOrMessage;
|
|
4807
|
+
} else {
|
|
4808
|
+
transaction = Transaction.populate(transactionOrMessage);
|
|
4809
|
+
}
|
|
4810
|
+
|
|
4771
4811
|
if (transaction.nonceInfo && signers) {
|
|
4772
4812
|
transaction.sign(...signers);
|
|
4773
4813
|
} else {
|
|
@@ -4800,7 +4840,9 @@ class Connection {
|
|
|
4800
4840
|
}
|
|
4801
4841
|
}
|
|
4802
4842
|
|
|
4803
|
-
const
|
|
4843
|
+
const message = transaction._compile();
|
|
4844
|
+
|
|
4845
|
+
const signData = message.serialize();
|
|
4804
4846
|
|
|
4805
4847
|
const wireTransaction = transaction._serialize(signData);
|
|
4806
4848
|
|
|
@@ -4810,6 +4852,14 @@ class Connection {
|
|
|
4810
4852
|
commitment: this.commitment
|
|
4811
4853
|
};
|
|
4812
4854
|
|
|
4855
|
+
if (includeAccounts) {
|
|
4856
|
+
const addresses = (Array.isArray(includeAccounts) ? includeAccounts : message.nonProgramIds()).map(key => key.toBase58());
|
|
4857
|
+
config['accounts'] = {
|
|
4858
|
+
encoding: 'base64',
|
|
4859
|
+
addresses
|
|
4860
|
+
};
|
|
4861
|
+
}
|
|
4862
|
+
|
|
4813
4863
|
if (signers) {
|
|
4814
4864
|
config.sigVerify = true;
|
|
4815
4865
|
}
|