@solana/web3.js 1.54.1 → 1.56.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 +85 -20
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +85 -20
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +85 -20
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +130 -4
- package/lib/index.esm.js +85 -20
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +85 -20
- 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/lib/index.native.js +85 -20
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +244 -21
- package/src/message/versioned.ts +12 -3
package/lib/index.browser.cjs.js
CHANGED
|
@@ -890,16 +890,24 @@ class MessageV0 {
|
|
|
890
890
|
|
|
891
891
|
// eslint-disable-next-line no-redeclare
|
|
892
892
|
const VersionedMessage = {
|
|
893
|
-
|
|
893
|
+
deserializeMessageVersion(serializedMessage) {
|
|
894
894
|
const prefix = serializedMessage[0];
|
|
895
895
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK; // if the highest bit of the prefix is not set, the message is not versioned
|
|
896
896
|
|
|
897
897
|
if (maskedPrefix === prefix) {
|
|
898
|
-
return
|
|
898
|
+
return 'legacy';
|
|
899
899
|
} // the lower 7 bits of the prefix indicate the message version
|
|
900
900
|
|
|
901
901
|
|
|
902
|
-
|
|
902
|
+
return maskedPrefix;
|
|
903
|
+
},
|
|
904
|
+
|
|
905
|
+
deserialize: serializedMessage => {
|
|
906
|
+
const version = VersionedMessage.deserializeMessageVersion(serializedMessage);
|
|
907
|
+
|
|
908
|
+
if (version === 'legacy') {
|
|
909
|
+
return Message.from(serializedMessage);
|
|
910
|
+
}
|
|
903
911
|
|
|
904
912
|
if (version === 0) {
|
|
905
913
|
return MessageV0.deserialize(serializedMessage);
|
|
@@ -3231,6 +3239,28 @@ function notificationResultAndContext(value) {
|
|
|
3231
3239
|
value
|
|
3232
3240
|
});
|
|
3233
3241
|
}
|
|
3242
|
+
/**
|
|
3243
|
+
* @internal
|
|
3244
|
+
*/
|
|
3245
|
+
|
|
3246
|
+
|
|
3247
|
+
function versionedMessageFromResponse(version, response) {
|
|
3248
|
+
if (version === 0) {
|
|
3249
|
+
return new MessageV0({
|
|
3250
|
+
header: response.header,
|
|
3251
|
+
staticAccountKeys: response.accountKeys.map(accountKey => new PublicKey(accountKey)),
|
|
3252
|
+
recentBlockhash: response.recentBlockhash,
|
|
3253
|
+
compiledInstructions: response.instructions.map(ix => ({
|
|
3254
|
+
programIdIndex: ix.programIdIndex,
|
|
3255
|
+
accountKeyIndexes: ix.accounts,
|
|
3256
|
+
data: bs58__default["default"].decode(ix.data)
|
|
3257
|
+
})),
|
|
3258
|
+
addressTableLookups: response.addressTableLookups
|
|
3259
|
+
});
|
|
3260
|
+
} else {
|
|
3261
|
+
return new Message(response);
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3234
3264
|
/**
|
|
3235
3265
|
* The level of commitment desired when querying state
|
|
3236
3266
|
* <pre>
|
|
@@ -3786,6 +3816,11 @@ const GetSignatureStatusesRpcResult = jsonRpcResultAndContext(superstruct.array(
|
|
|
3786
3816
|
*/
|
|
3787
3817
|
|
|
3788
3818
|
const GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult(superstruct.number());
|
|
3819
|
+
const AddressTableLookupStruct = superstruct.type({
|
|
3820
|
+
accountKey: PublicKeyFromString,
|
|
3821
|
+
writableIndexes: superstruct.array(superstruct.number()),
|
|
3822
|
+
readonlyIndexes: superstruct.array(superstruct.number())
|
|
3823
|
+
});
|
|
3789
3824
|
const ConfirmedTransactionResult = superstruct.type({
|
|
3790
3825
|
signatures: superstruct.array(superstruct.string()),
|
|
3791
3826
|
message: superstruct.type({
|
|
@@ -3800,7 +3835,8 @@ const ConfirmedTransactionResult = superstruct.type({
|
|
|
3800
3835
|
data: superstruct.string(),
|
|
3801
3836
|
programIdIndex: superstruct.number()
|
|
3802
3837
|
})),
|
|
3803
|
-
recentBlockhash: superstruct.string()
|
|
3838
|
+
recentBlockhash: superstruct.string(),
|
|
3839
|
+
addressTableLookups: superstruct.optional(superstruct.array(AddressTableLookupStruct))
|
|
3804
3840
|
})
|
|
3805
3841
|
});
|
|
3806
3842
|
const ParsedInstructionResult = superstruct.type({
|
|
@@ -3843,7 +3879,8 @@ const ParsedConfirmedTransactionResult = superstruct.type({
|
|
|
3843
3879
|
writable: superstruct.boolean()
|
|
3844
3880
|
})),
|
|
3845
3881
|
instructions: superstruct.array(ParsedOrRawInstruction),
|
|
3846
|
-
recentBlockhash: superstruct.string()
|
|
3882
|
+
recentBlockhash: superstruct.string(),
|
|
3883
|
+
addressTableLookups: superstruct.optional(superstruct.nullable(superstruct.array(AddressTableLookupStruct)))
|
|
3847
3884
|
})
|
|
3848
3885
|
});
|
|
3849
3886
|
const TokenBalanceResult = superstruct.type({
|
|
@@ -3896,6 +3933,7 @@ const ParsedConfirmedTransactionMetaResult = superstruct.type({
|
|
|
3896
3933
|
postTokenBalances: superstruct.optional(superstruct.nullable(superstruct.array(TokenBalanceResult))),
|
|
3897
3934
|
loadedAddresses: superstruct.optional(LoadedAddressesResult)
|
|
3898
3935
|
});
|
|
3936
|
+
const TransactionVersionStruct = superstruct.union([superstruct.literal(0), superstruct.literal('legacy')]);
|
|
3899
3937
|
/**
|
|
3900
3938
|
* Expected JSON RPC response for the "getBlock" message
|
|
3901
3939
|
*/
|
|
@@ -3906,7 +3944,8 @@ const GetBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
|
|
|
3906
3944
|
parentSlot: superstruct.number(),
|
|
3907
3945
|
transactions: superstruct.array(superstruct.type({
|
|
3908
3946
|
transaction: ConfirmedTransactionResult,
|
|
3909
|
-
meta: superstruct.nullable(ConfirmedTransactionMetaResult)
|
|
3947
|
+
meta: superstruct.nullable(ConfirmedTransactionMetaResult),
|
|
3948
|
+
version: superstruct.optional(TransactionVersionStruct)
|
|
3910
3949
|
})),
|
|
3911
3950
|
rewards: superstruct.optional(superstruct.array(superstruct.type({
|
|
3912
3951
|
pubkey: superstruct.string(),
|
|
@@ -3958,7 +3997,8 @@ const GetTransactionRpcResult = jsonRpcResult(superstruct.nullable(superstruct.t
|
|
|
3958
3997
|
slot: superstruct.number(),
|
|
3959
3998
|
meta: ConfirmedTransactionMetaResult,
|
|
3960
3999
|
blockTime: superstruct.optional(superstruct.nullable(superstruct.number())),
|
|
3961
|
-
transaction: ConfirmedTransactionResult
|
|
4000
|
+
transaction: ConfirmedTransactionResult,
|
|
4001
|
+
version: superstruct.optional(TransactionVersionStruct)
|
|
3962
4002
|
})));
|
|
3963
4003
|
/**
|
|
3964
4004
|
* Expected parsed JSON RPC response for the "getTransaction" message
|
|
@@ -3968,7 +4008,8 @@ const GetParsedTransactionRpcResult = jsonRpcResult(superstruct.nullable(superst
|
|
|
3968
4008
|
slot: superstruct.number(),
|
|
3969
4009
|
transaction: ParsedConfirmedTransactionResult,
|
|
3970
4010
|
meta: superstruct.nullable(ParsedConfirmedTransactionMetaResult),
|
|
3971
|
-
blockTime: superstruct.optional(superstruct.nullable(superstruct.number()))
|
|
4011
|
+
blockTime: superstruct.optional(superstruct.nullable(superstruct.number())),
|
|
4012
|
+
version: superstruct.optional(TransactionVersionStruct)
|
|
3972
4013
|
})));
|
|
3973
4014
|
/**
|
|
3974
4015
|
* Expected JSON RPC response for the "getRecentBlockhash" message
|
|
@@ -5211,9 +5252,16 @@ class Connection {
|
|
|
5211
5252
|
}
|
|
5212
5253
|
/**
|
|
5213
5254
|
* Fetch a processed block from the cluster.
|
|
5255
|
+
*
|
|
5256
|
+
* @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
|
|
5257
|
+
* setting the `maxSupportedTransactionVersion` property.
|
|
5214
5258
|
*/
|
|
5215
5259
|
|
|
5216
5260
|
|
|
5261
|
+
/**
|
|
5262
|
+
* Fetch a processed block from the cluster.
|
|
5263
|
+
*/
|
|
5264
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
5217
5265
|
async getBlock(slot, rawConfig) {
|
|
5218
5266
|
const {
|
|
5219
5267
|
commitment,
|
|
@@ -5236,16 +5284,15 @@ class Connection {
|
|
|
5236
5284
|
return { ...result,
|
|
5237
5285
|
transactions: result.transactions.map(({
|
|
5238
5286
|
transaction,
|
|
5239
|
-
meta
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
})
|
|
5287
|
+
meta,
|
|
5288
|
+
version
|
|
5289
|
+
}) => ({
|
|
5290
|
+
meta,
|
|
5291
|
+
transaction: { ...transaction,
|
|
5292
|
+
message: versionedMessageFromResponse(version, transaction.message)
|
|
5293
|
+
},
|
|
5294
|
+
version
|
|
5295
|
+
}))
|
|
5249
5296
|
};
|
|
5250
5297
|
}
|
|
5251
5298
|
/*
|
|
@@ -5305,9 +5352,17 @@ class Connection {
|
|
|
5305
5352
|
}
|
|
5306
5353
|
/**
|
|
5307
5354
|
* Fetch a confirmed or finalized transaction from the cluster.
|
|
5355
|
+
*
|
|
5356
|
+
* @deprecated Instead, call `getTransaction` using a
|
|
5357
|
+
* `GetVersionedTransactionConfig` by setting the
|
|
5358
|
+
* `maxSupportedTransactionVersion` property.
|
|
5308
5359
|
*/
|
|
5309
5360
|
|
|
5310
5361
|
|
|
5362
|
+
/**
|
|
5363
|
+
* Fetch a confirmed or finalized transaction from the cluster.
|
|
5364
|
+
*/
|
|
5365
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
5311
5366
|
async getTransaction(signature, rawConfig) {
|
|
5312
5367
|
const {
|
|
5313
5368
|
commitment,
|
|
@@ -5329,7 +5384,7 @@ class Connection {
|
|
|
5329
5384
|
if (!result) return result;
|
|
5330
5385
|
return { ...result,
|
|
5331
5386
|
transaction: { ...result.transaction,
|
|
5332
|
-
message:
|
|
5387
|
+
message: versionedMessageFromResponse(result.version, result.transaction.message)
|
|
5333
5388
|
}
|
|
5334
5389
|
};
|
|
5335
5390
|
}
|
|
@@ -5388,9 +5443,19 @@ class Connection {
|
|
|
5388
5443
|
/**
|
|
5389
5444
|
* Fetch transaction details for a batch of confirmed transactions.
|
|
5390
5445
|
* Similar to {@link getParsedTransactions} but returns a {@link TransactionResponse}.
|
|
5446
|
+
*
|
|
5447
|
+
* @deprecated Instead, call `getTransactions` using a
|
|
5448
|
+
* `GetVersionedTransactionConfig` by setting the
|
|
5449
|
+
* `maxSupportedTransactionVersion` property.
|
|
5391
5450
|
*/
|
|
5392
5451
|
|
|
5393
5452
|
|
|
5453
|
+
/**
|
|
5454
|
+
* Fetch transaction details for a batch of confirmed transactions.
|
|
5455
|
+
* Similar to {@link getParsedTransactions} but returns a {@link
|
|
5456
|
+
* VersionedTransactionResponse}.
|
|
5457
|
+
*/
|
|
5458
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
5394
5459
|
async getTransactions(signatures, commitmentOrConfig) {
|
|
5395
5460
|
const {
|
|
5396
5461
|
commitment,
|
|
@@ -5418,7 +5483,7 @@ class Connection {
|
|
|
5418
5483
|
if (!result) return result;
|
|
5419
5484
|
return { ...result,
|
|
5420
5485
|
transaction: { ...result.transaction,
|
|
5421
|
-
message:
|
|
5486
|
+
message: versionedMessageFromResponse(result.version, result.transaction.message)
|
|
5422
5487
|
}
|
|
5423
5488
|
};
|
|
5424
5489
|
});
|