@solana/web3.js 1.27.0 → 1.28.0
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
|
@@ -458,16 +458,35 @@ class Message {
|
|
|
458
458
|
|
|
459
459
|
_defineProperty(this, "instructions", void 0);
|
|
460
460
|
|
|
461
|
+
_defineProperty(this, "indexToProgramIds", new Map());
|
|
462
|
+
|
|
461
463
|
this.header = args.header;
|
|
462
464
|
this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
|
|
463
465
|
this.recentBlockhash = args.recentBlockhash;
|
|
464
466
|
this.instructions = args.instructions;
|
|
467
|
+
this.instructions.forEach(ix => this.indexToProgramIds.set(ix.programIdIndex, this.accountKeys[ix.programIdIndex]));
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
isAccountSigner(index) {
|
|
471
|
+
return index < this.header.numRequiredSignatures;
|
|
465
472
|
}
|
|
466
473
|
|
|
467
474
|
isAccountWritable(index) {
|
|
468
475
|
return index < this.header.numRequiredSignatures - this.header.numReadonlySignedAccounts || index >= this.header.numRequiredSignatures && index < this.accountKeys.length - this.header.numReadonlyUnsignedAccounts;
|
|
469
476
|
}
|
|
470
477
|
|
|
478
|
+
isProgramId(index) {
|
|
479
|
+
return this.indexToProgramIds.has(index);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
programIds() {
|
|
483
|
+
return [...this.indexToProgramIds.values()];
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
nonProgramIds() {
|
|
487
|
+
return this.accountKeys.filter((_, index) => !this.isProgramId(index));
|
|
488
|
+
}
|
|
489
|
+
|
|
471
490
|
serialize() {
|
|
472
491
|
const numKeys = this.accountKeys.length;
|
|
473
492
|
let keyCount = [];
|
|
@@ -1182,7 +1201,7 @@ class Transaction {
|
|
|
1182
1201
|
*/
|
|
1183
1202
|
|
|
1184
1203
|
|
|
1185
|
-
static populate(message, signatures) {
|
|
1204
|
+
static populate(message, signatures = []) {
|
|
1186
1205
|
const transaction = new Transaction();
|
|
1187
1206
|
transaction.recentBlockhash = message.recentBlockhash;
|
|
1188
1207
|
|
|
@@ -1202,7 +1221,7 @@ class Transaction {
|
|
|
1202
1221
|
const pubkey = message.accountKeys[account];
|
|
1203
1222
|
return {
|
|
1204
1223
|
pubkey,
|
|
1205
|
-
isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()),
|
|
1224
|
+
isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()) || message.isAccountSigner(account),
|
|
1206
1225
|
isWritable: message.isAccountWritable(account)
|
|
1207
1226
|
};
|
|
1208
1227
|
});
|
|
@@ -3148,7 +3167,15 @@ const VersionResult = type({
|
|
|
3148
3167
|
});
|
|
3149
3168
|
const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(type({
|
|
3150
3169
|
err: nullable(union([type({}), string()])),
|
|
3151
|
-
logs: nullable(array(string()))
|
|
3170
|
+
logs: nullable(array(string())),
|
|
3171
|
+
accounts: optional(nullable(array(type({
|
|
3172
|
+
executable: boolean(),
|
|
3173
|
+
owner: string(),
|
|
3174
|
+
lamports: number(),
|
|
3175
|
+
data: array(string()),
|
|
3176
|
+
rentEpoch: optional(number())
|
|
3177
|
+
})))),
|
|
3178
|
+
unitsConsumed: optional(number())
|
|
3152
3179
|
}));
|
|
3153
3180
|
|
|
3154
3181
|
function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
|
|
@@ -3874,6 +3901,8 @@ class Connection {
|
|
|
3874
3901
|
|
|
3875
3902
|
/** @internal */
|
|
3876
3903
|
|
|
3904
|
+
/** @internal */
|
|
3905
|
+
|
|
3877
3906
|
/**
|
|
3878
3907
|
* Establish a JSON RPC connection
|
|
3879
3908
|
*
|
|
@@ -3883,6 +3912,8 @@ class Connection {
|
|
|
3883
3912
|
constructor(endpoint, commitmentOrConfig) {
|
|
3884
3913
|
_defineProperty(this, "_commitment", void 0);
|
|
3885
3914
|
|
|
3915
|
+
_defineProperty(this, "_confirmTransactionInitialTimeout", void 0);
|
|
3916
|
+
|
|
3886
3917
|
_defineProperty(this, "_rpcEndpoint", void 0);
|
|
3887
3918
|
|
|
3888
3919
|
_defineProperty(this, "_rpcWsEndpoint", void 0);
|
|
@@ -3951,6 +3982,7 @@ class Connection {
|
|
|
3951
3982
|
this._commitment = commitmentOrConfig;
|
|
3952
3983
|
} else if (commitmentOrConfig) {
|
|
3953
3984
|
this._commitment = commitmentOrConfig.commitment;
|
|
3985
|
+
this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
|
|
3954
3986
|
wsEndpoint = commitmentOrConfig.wsEndpoint;
|
|
3955
3987
|
httpHeaders = commitmentOrConfig.httpHeaders;
|
|
3956
3988
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
@@ -4410,7 +4442,7 @@ class Connection {
|
|
|
4410
4442
|
reject(err);
|
|
4411
4443
|
}
|
|
4412
4444
|
});
|
|
4413
|
-
let timeoutMs = 60 * 1000;
|
|
4445
|
+
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
|
|
4414
4446
|
|
|
4415
4447
|
switch (subscriptionCommitment) {
|
|
4416
4448
|
case 'processed':
|
|
@@ -4419,7 +4451,7 @@ class Connection {
|
|
|
4419
4451
|
case 'confirmed':
|
|
4420
4452
|
case 'singleGossip':
|
|
4421
4453
|
{
|
|
4422
|
-
timeoutMs = 30 * 1000;
|
|
4454
|
+
timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
|
|
4423
4455
|
break;
|
|
4424
4456
|
}
|
|
4425
4457
|
}
|
|
@@ -5206,7 +5238,15 @@ class Connection {
|
|
|
5206
5238
|
*/
|
|
5207
5239
|
|
|
5208
5240
|
|
|
5209
|
-
async simulateTransaction(
|
|
5241
|
+
async simulateTransaction(transactionOrMessage, signers, includeAccounts) {
|
|
5242
|
+
let transaction;
|
|
5243
|
+
|
|
5244
|
+
if (transactionOrMessage instanceof Transaction) {
|
|
5245
|
+
transaction = transactionOrMessage;
|
|
5246
|
+
} else {
|
|
5247
|
+
transaction = Transaction.populate(transactionOrMessage);
|
|
5248
|
+
}
|
|
5249
|
+
|
|
5210
5250
|
if (transaction.nonceInfo && signers) {
|
|
5211
5251
|
transaction.sign(...signers);
|
|
5212
5252
|
} else {
|
|
@@ -5239,7 +5279,9 @@ class Connection {
|
|
|
5239
5279
|
}
|
|
5240
5280
|
}
|
|
5241
5281
|
|
|
5242
|
-
const
|
|
5282
|
+
const message = transaction._compile();
|
|
5283
|
+
|
|
5284
|
+
const signData = message.serialize();
|
|
5243
5285
|
|
|
5244
5286
|
const wireTransaction = transaction._serialize(signData);
|
|
5245
5287
|
|
|
@@ -5249,6 +5291,14 @@ class Connection {
|
|
|
5249
5291
|
commitment: this.commitment
|
|
5250
5292
|
};
|
|
5251
5293
|
|
|
5294
|
+
if (includeAccounts) {
|
|
5295
|
+
const addresses = (Array.isArray(includeAccounts) ? includeAccounts : message.nonProgramIds()).map(key => key.toBase58());
|
|
5296
|
+
config['accounts'] = {
|
|
5297
|
+
encoding: 'base64',
|
|
5298
|
+
addresses
|
|
5299
|
+
};
|
|
5300
|
+
}
|
|
5301
|
+
|
|
5252
5302
|
if (signers) {
|
|
5253
5303
|
config.sigVerify = true;
|
|
5254
5304
|
}
|