@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.esm.js
CHANGED
|
@@ -859,16 +859,24 @@ class MessageV0 {
|
|
|
859
859
|
|
|
860
860
|
// eslint-disable-next-line no-redeclare
|
|
861
861
|
const VersionedMessage = {
|
|
862
|
-
|
|
862
|
+
deserializeMessageVersion(serializedMessage) {
|
|
863
863
|
const prefix = serializedMessage[0];
|
|
864
864
|
const maskedPrefix = prefix & VERSION_PREFIX_MASK; // if the highest bit of the prefix is not set, the message is not versioned
|
|
865
865
|
|
|
866
866
|
if (maskedPrefix === prefix) {
|
|
867
|
-
return
|
|
867
|
+
return 'legacy';
|
|
868
868
|
} // the lower 7 bits of the prefix indicate the message version
|
|
869
869
|
|
|
870
870
|
|
|
871
|
-
|
|
871
|
+
return maskedPrefix;
|
|
872
|
+
},
|
|
873
|
+
|
|
874
|
+
deserialize: serializedMessage => {
|
|
875
|
+
const version = VersionedMessage.deserializeMessageVersion(serializedMessage);
|
|
876
|
+
|
|
877
|
+
if (version === 'legacy') {
|
|
878
|
+
return Message.from(serializedMessage);
|
|
879
|
+
}
|
|
872
880
|
|
|
873
881
|
if (version === 0) {
|
|
874
882
|
return MessageV0.deserialize(serializedMessage);
|
|
@@ -3200,6 +3208,28 @@ function notificationResultAndContext(value) {
|
|
|
3200
3208
|
value
|
|
3201
3209
|
});
|
|
3202
3210
|
}
|
|
3211
|
+
/**
|
|
3212
|
+
* @internal
|
|
3213
|
+
*/
|
|
3214
|
+
|
|
3215
|
+
|
|
3216
|
+
function versionedMessageFromResponse(version, response) {
|
|
3217
|
+
if (version === 0) {
|
|
3218
|
+
return new MessageV0({
|
|
3219
|
+
header: response.header,
|
|
3220
|
+
staticAccountKeys: response.accountKeys.map(accountKey => new PublicKey(accountKey)),
|
|
3221
|
+
recentBlockhash: response.recentBlockhash,
|
|
3222
|
+
compiledInstructions: response.instructions.map(ix => ({
|
|
3223
|
+
programIdIndex: ix.programIdIndex,
|
|
3224
|
+
accountKeyIndexes: ix.accounts,
|
|
3225
|
+
data: bs58.decode(ix.data)
|
|
3226
|
+
})),
|
|
3227
|
+
addressTableLookups: response.addressTableLookups
|
|
3228
|
+
});
|
|
3229
|
+
} else {
|
|
3230
|
+
return new Message(response);
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3203
3233
|
/**
|
|
3204
3234
|
* The level of commitment desired when querying state
|
|
3205
3235
|
* <pre>
|
|
@@ -3755,6 +3785,11 @@ const GetSignatureStatusesRpcResult = jsonRpcResultAndContext(array(nullable(Sig
|
|
|
3755
3785
|
*/
|
|
3756
3786
|
|
|
3757
3787
|
const GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult(number());
|
|
3788
|
+
const AddressTableLookupStruct = type({
|
|
3789
|
+
accountKey: PublicKeyFromString,
|
|
3790
|
+
writableIndexes: array(number()),
|
|
3791
|
+
readonlyIndexes: array(number())
|
|
3792
|
+
});
|
|
3758
3793
|
const ConfirmedTransactionResult = type({
|
|
3759
3794
|
signatures: array(string()),
|
|
3760
3795
|
message: type({
|
|
@@ -3769,7 +3804,8 @@ const ConfirmedTransactionResult = type({
|
|
|
3769
3804
|
data: string(),
|
|
3770
3805
|
programIdIndex: number()
|
|
3771
3806
|
})),
|
|
3772
|
-
recentBlockhash: string()
|
|
3807
|
+
recentBlockhash: string(),
|
|
3808
|
+
addressTableLookups: optional(array(AddressTableLookupStruct))
|
|
3773
3809
|
})
|
|
3774
3810
|
});
|
|
3775
3811
|
const ParsedInstructionResult = type({
|
|
@@ -3812,7 +3848,8 @@ const ParsedConfirmedTransactionResult = type({
|
|
|
3812
3848
|
writable: boolean()
|
|
3813
3849
|
})),
|
|
3814
3850
|
instructions: array(ParsedOrRawInstruction),
|
|
3815
|
-
recentBlockhash: string()
|
|
3851
|
+
recentBlockhash: string(),
|
|
3852
|
+
addressTableLookups: optional(nullable(array(AddressTableLookupStruct)))
|
|
3816
3853
|
})
|
|
3817
3854
|
});
|
|
3818
3855
|
const TokenBalanceResult = type({
|
|
@@ -3865,6 +3902,7 @@ const ParsedConfirmedTransactionMetaResult = type({
|
|
|
3865
3902
|
postTokenBalances: optional(nullable(array(TokenBalanceResult))),
|
|
3866
3903
|
loadedAddresses: optional(LoadedAddressesResult)
|
|
3867
3904
|
});
|
|
3905
|
+
const TransactionVersionStruct = union([literal(0), literal('legacy')]);
|
|
3868
3906
|
/**
|
|
3869
3907
|
* Expected JSON RPC response for the "getBlock" message
|
|
3870
3908
|
*/
|
|
@@ -3875,7 +3913,8 @@ const GetBlockRpcResult = jsonRpcResult(nullable(type({
|
|
|
3875
3913
|
parentSlot: number(),
|
|
3876
3914
|
transactions: array(type({
|
|
3877
3915
|
transaction: ConfirmedTransactionResult,
|
|
3878
|
-
meta: nullable(ConfirmedTransactionMetaResult)
|
|
3916
|
+
meta: nullable(ConfirmedTransactionMetaResult),
|
|
3917
|
+
version: optional(TransactionVersionStruct)
|
|
3879
3918
|
})),
|
|
3880
3919
|
rewards: optional(array(type({
|
|
3881
3920
|
pubkey: string(),
|
|
@@ -3927,7 +3966,8 @@ const GetTransactionRpcResult = jsonRpcResult(nullable(type({
|
|
|
3927
3966
|
slot: number(),
|
|
3928
3967
|
meta: ConfirmedTransactionMetaResult,
|
|
3929
3968
|
blockTime: optional(nullable(number())),
|
|
3930
|
-
transaction: ConfirmedTransactionResult
|
|
3969
|
+
transaction: ConfirmedTransactionResult,
|
|
3970
|
+
version: optional(TransactionVersionStruct)
|
|
3931
3971
|
})));
|
|
3932
3972
|
/**
|
|
3933
3973
|
* Expected parsed JSON RPC response for the "getTransaction" message
|
|
@@ -3937,7 +3977,8 @@ const GetParsedTransactionRpcResult = jsonRpcResult(nullable(type({
|
|
|
3937
3977
|
slot: number(),
|
|
3938
3978
|
transaction: ParsedConfirmedTransactionResult,
|
|
3939
3979
|
meta: nullable(ParsedConfirmedTransactionMetaResult),
|
|
3940
|
-
blockTime: optional(nullable(number()))
|
|
3980
|
+
blockTime: optional(nullable(number())),
|
|
3981
|
+
version: optional(TransactionVersionStruct)
|
|
3941
3982
|
})));
|
|
3942
3983
|
/**
|
|
3943
3984
|
* Expected JSON RPC response for the "getRecentBlockhash" message
|
|
@@ -5180,9 +5221,16 @@ class Connection {
|
|
|
5180
5221
|
}
|
|
5181
5222
|
/**
|
|
5182
5223
|
* Fetch a processed block from the cluster.
|
|
5224
|
+
*
|
|
5225
|
+
* @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
|
|
5226
|
+
* setting the `maxSupportedTransactionVersion` property.
|
|
5183
5227
|
*/
|
|
5184
5228
|
|
|
5185
5229
|
|
|
5230
|
+
/**
|
|
5231
|
+
* Fetch a processed block from the cluster.
|
|
5232
|
+
*/
|
|
5233
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
5186
5234
|
async getBlock(slot, rawConfig) {
|
|
5187
5235
|
const {
|
|
5188
5236
|
commitment,
|
|
@@ -5205,16 +5253,15 @@ class Connection {
|
|
|
5205
5253
|
return { ...result,
|
|
5206
5254
|
transactions: result.transactions.map(({
|
|
5207
5255
|
transaction,
|
|
5208
|
-
meta
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
})
|
|
5256
|
+
meta,
|
|
5257
|
+
version
|
|
5258
|
+
}) => ({
|
|
5259
|
+
meta,
|
|
5260
|
+
transaction: { ...transaction,
|
|
5261
|
+
message: versionedMessageFromResponse(version, transaction.message)
|
|
5262
|
+
},
|
|
5263
|
+
version
|
|
5264
|
+
}))
|
|
5218
5265
|
};
|
|
5219
5266
|
}
|
|
5220
5267
|
/*
|
|
@@ -5274,9 +5321,17 @@ class Connection {
|
|
|
5274
5321
|
}
|
|
5275
5322
|
/**
|
|
5276
5323
|
* Fetch a confirmed or finalized transaction from the cluster.
|
|
5324
|
+
*
|
|
5325
|
+
* @deprecated Instead, call `getTransaction` using a
|
|
5326
|
+
* `GetVersionedTransactionConfig` by setting the
|
|
5327
|
+
* `maxSupportedTransactionVersion` property.
|
|
5277
5328
|
*/
|
|
5278
5329
|
|
|
5279
5330
|
|
|
5331
|
+
/**
|
|
5332
|
+
* Fetch a confirmed or finalized transaction from the cluster.
|
|
5333
|
+
*/
|
|
5334
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
5280
5335
|
async getTransaction(signature, rawConfig) {
|
|
5281
5336
|
const {
|
|
5282
5337
|
commitment,
|
|
@@ -5298,7 +5353,7 @@ class Connection {
|
|
|
5298
5353
|
if (!result) return result;
|
|
5299
5354
|
return { ...result,
|
|
5300
5355
|
transaction: { ...result.transaction,
|
|
5301
|
-
message:
|
|
5356
|
+
message: versionedMessageFromResponse(result.version, result.transaction.message)
|
|
5302
5357
|
}
|
|
5303
5358
|
};
|
|
5304
5359
|
}
|
|
@@ -5357,9 +5412,19 @@ class Connection {
|
|
|
5357
5412
|
/**
|
|
5358
5413
|
* Fetch transaction details for a batch of confirmed transactions.
|
|
5359
5414
|
* Similar to {@link getParsedTransactions} but returns a {@link TransactionResponse}.
|
|
5415
|
+
*
|
|
5416
|
+
* @deprecated Instead, call `getTransactions` using a
|
|
5417
|
+
* `GetVersionedTransactionConfig` by setting the
|
|
5418
|
+
* `maxSupportedTransactionVersion` property.
|
|
5360
5419
|
*/
|
|
5361
5420
|
|
|
5362
5421
|
|
|
5422
|
+
/**
|
|
5423
|
+
* Fetch transaction details for a batch of confirmed transactions.
|
|
5424
|
+
* Similar to {@link getParsedTransactions} but returns a {@link
|
|
5425
|
+
* VersionedTransactionResponse}.
|
|
5426
|
+
*/
|
|
5427
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
5363
5428
|
async getTransactions(signatures, commitmentOrConfig) {
|
|
5364
5429
|
const {
|
|
5365
5430
|
commitment,
|
|
@@ -5387,7 +5452,7 @@ class Connection {
|
|
|
5387
5452
|
if (!result) return result;
|
|
5388
5453
|
return { ...result,
|
|
5389
5454
|
transaction: { ...result.transaction,
|
|
5390
|
-
message:
|
|
5455
|
+
message: versionedMessageFromResponse(result.version, result.transaction.message)
|
|
5391
5456
|
}
|
|
5392
5457
|
};
|
|
5393
5458
|
});
|