@solana/web3.js 1.67.1 → 1.68.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.cjs.js +171 -49
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +171 -49
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +171 -49
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +128 -2
- package/lib/index.esm.js +171 -49
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +171 -49
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +1 -1
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +171 -49
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +325 -65
package/lib/index.iife.js
CHANGED
|
@@ -17978,6 +17978,16 @@ var solanaWeb3 = (function (exports) {
|
|
|
17978
17978
|
addressTableLookups: optional(array(AddressTableLookupStruct))
|
|
17979
17979
|
})
|
|
17980
17980
|
});
|
|
17981
|
+
const AnnotatedAccountKey = type({
|
|
17982
|
+
pubkey: PublicKeyFromString,
|
|
17983
|
+
signer: boolean(),
|
|
17984
|
+
writable: boolean(),
|
|
17985
|
+
source: optional(union([literal('transaction'), literal('lookupTable')]))
|
|
17986
|
+
});
|
|
17987
|
+
const ConfirmedTransactionAccountsModeResult = type({
|
|
17988
|
+
accountKeys: array(AnnotatedAccountKey),
|
|
17989
|
+
signatures: array(string())
|
|
17990
|
+
});
|
|
17981
17991
|
const ParsedInstructionResult = type({
|
|
17982
17992
|
parsed: unknown(),
|
|
17983
17993
|
program: string(),
|
|
@@ -18012,12 +18022,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18012
18022
|
const ParsedConfirmedTransactionResult = type({
|
|
18013
18023
|
signatures: array(string()),
|
|
18014
18024
|
message: type({
|
|
18015
|
-
accountKeys: array(
|
|
18016
|
-
pubkey: PublicKeyFromString,
|
|
18017
|
-
signer: boolean(),
|
|
18018
|
-
writable: boolean(),
|
|
18019
|
-
source: optional(union([literal('transaction'), literal('lookupTable')]))
|
|
18020
|
-
})),
|
|
18025
|
+
accountKeys: array(AnnotatedAccountKey),
|
|
18021
18026
|
instructions: array(ParsedOrRawInstruction),
|
|
18022
18027
|
recentBlockhash: string(),
|
|
18023
18028
|
addressTableLookups: optional(nullable(array(AddressTableLookupStruct)))
|
|
@@ -18076,6 +18081,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
18076
18081
|
computeUnitsConsumed: optional(number())
|
|
18077
18082
|
});
|
|
18078
18083
|
const TransactionVersionStruct = union([literal(0), literal('legacy')]);
|
|
18084
|
+
/** @internal */
|
|
18085
|
+
|
|
18086
|
+
const RewardsResult = type({
|
|
18087
|
+
pubkey: string(),
|
|
18088
|
+
lamports: number(),
|
|
18089
|
+
postBalance: nullable(number()),
|
|
18090
|
+
rewardType: nullable(string())
|
|
18091
|
+
});
|
|
18079
18092
|
/**
|
|
18080
18093
|
* Expected JSON RPC response for the "getBlock" message
|
|
18081
18094
|
*/
|
|
@@ -18089,12 +18102,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
18089
18102
|
meta: nullable(ConfirmedTransactionMetaResult),
|
|
18090
18103
|
version: optional(TransactionVersionStruct)
|
|
18091
18104
|
})),
|
|
18092
|
-
rewards: optional(array(
|
|
18093
|
-
|
|
18094
|
-
|
|
18095
|
-
|
|
18096
|
-
|
|
18097
|
-
|
|
18105
|
+
rewards: optional(array(RewardsResult)),
|
|
18106
|
+
blockTime: nullable(number()),
|
|
18107
|
+
blockHeight: nullable(number())
|
|
18108
|
+
})));
|
|
18109
|
+
/**
|
|
18110
|
+
* Expected JSON RPC response for the "getBlock" message when `transactionDetails` is `none`
|
|
18111
|
+
*/
|
|
18112
|
+
|
|
18113
|
+
const GetNoneModeBlockRpcResult = jsonRpcResult(nullable(type({
|
|
18114
|
+
blockhash: string(),
|
|
18115
|
+
previousBlockhash: string(),
|
|
18116
|
+
parentSlot: number(),
|
|
18117
|
+
rewards: optional(array(RewardsResult)),
|
|
18118
|
+
blockTime: nullable(number()),
|
|
18119
|
+
blockHeight: nullable(number())
|
|
18120
|
+
})));
|
|
18121
|
+
/**
|
|
18122
|
+
* Expected JSON RPC response for the "getBlock" message when `transactionDetails` is `accounts`
|
|
18123
|
+
*/
|
|
18124
|
+
|
|
18125
|
+
const GetAccountsModeBlockRpcResult = jsonRpcResult(nullable(type({
|
|
18126
|
+
blockhash: string(),
|
|
18127
|
+
previousBlockhash: string(),
|
|
18128
|
+
parentSlot: number(),
|
|
18129
|
+
transactions: array(type({
|
|
18130
|
+
transaction: ConfirmedTransactionAccountsModeResult,
|
|
18131
|
+
meta: nullable(ConfirmedTransactionMetaResult),
|
|
18132
|
+
version: optional(TransactionVersionStruct)
|
|
18133
|
+
})),
|
|
18134
|
+
rewards: optional(array(RewardsResult)),
|
|
18098
18135
|
blockTime: nullable(number()),
|
|
18099
18136
|
blockHeight: nullable(number())
|
|
18100
18137
|
})));
|
|
@@ -18111,12 +18148,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
18111
18148
|
meta: nullable(ParsedConfirmedTransactionMetaResult),
|
|
18112
18149
|
version: optional(TransactionVersionStruct)
|
|
18113
18150
|
})),
|
|
18114
|
-
rewards: optional(array(
|
|
18115
|
-
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
18151
|
+
rewards: optional(array(RewardsResult)),
|
|
18152
|
+
blockTime: nullable(number()),
|
|
18153
|
+
blockHeight: nullable(number())
|
|
18154
|
+
})));
|
|
18155
|
+
/**
|
|
18156
|
+
* Expected parsed JSON RPC response for the "getBlock" message when `transactionDetails` is `accounts`
|
|
18157
|
+
*/
|
|
18158
|
+
|
|
18159
|
+
const GetParsedAccountsModeBlockRpcResult = jsonRpcResult(nullable(type({
|
|
18160
|
+
blockhash: string(),
|
|
18161
|
+
previousBlockhash: string(),
|
|
18162
|
+
parentSlot: number(),
|
|
18163
|
+
transactions: array(type({
|
|
18164
|
+
transaction: ConfirmedTransactionAccountsModeResult,
|
|
18165
|
+
meta: nullable(ParsedConfirmedTransactionMetaResult),
|
|
18166
|
+
version: optional(TransactionVersionStruct)
|
|
18167
|
+
})),
|
|
18168
|
+
rewards: optional(array(RewardsResult)),
|
|
18169
|
+
blockTime: nullable(number()),
|
|
18170
|
+
blockHeight: nullable(number())
|
|
18171
|
+
})));
|
|
18172
|
+
/**
|
|
18173
|
+
* Expected parsed JSON RPC response for the "getBlock" message when `transactionDetails` is `none`
|
|
18174
|
+
*/
|
|
18175
|
+
|
|
18176
|
+
const GetParsedNoneModeBlockRpcResult = jsonRpcResult(nullable(type({
|
|
18177
|
+
blockhash: string(),
|
|
18178
|
+
previousBlockhash: string(),
|
|
18179
|
+
parentSlot: number(),
|
|
18180
|
+
rewards: optional(array(RewardsResult)),
|
|
18120
18181
|
blockTime: nullable(number()),
|
|
18121
18182
|
blockHeight: nullable(number())
|
|
18122
18183
|
})));
|
|
@@ -18134,12 +18195,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18134
18195
|
transaction: ConfirmedTransactionResult,
|
|
18135
18196
|
meta: nullable(ConfirmedTransactionMetaResult)
|
|
18136
18197
|
})),
|
|
18137
|
-
rewards: optional(array(
|
|
18138
|
-
pubkey: string(),
|
|
18139
|
-
lamports: number(),
|
|
18140
|
-
postBalance: nullable(number()),
|
|
18141
|
-
rewardType: nullable(string())
|
|
18142
|
-
}))),
|
|
18198
|
+
rewards: optional(array(RewardsResult)),
|
|
18143
18199
|
blockTime: nullable(number())
|
|
18144
18200
|
})));
|
|
18145
18201
|
/**
|
|
@@ -19636,7 +19692,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
19636
19692
|
|
|
19637
19693
|
|
|
19638
19694
|
async getFeeForMessage(message, commitment) {
|
|
19639
|
-
const wireMessage = message.serialize().toString('base64');
|
|
19695
|
+
const wireMessage = toBuffer(message.serialize()).toString('base64');
|
|
19640
19696
|
|
|
19641
19697
|
const args = this._buildArgs([wireMessage], commitment);
|
|
19642
19698
|
|
|
@@ -19761,33 +19817,67 @@ var solanaWeb3 = (function (exports) {
|
|
|
19761
19817
|
, config);
|
|
19762
19818
|
|
|
19763
19819
|
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
19764
|
-
const res = create(unsafeRes, GetBlockRpcResult);
|
|
19765
19820
|
|
|
19766
|
-
|
|
19767
|
-
|
|
19768
|
-
|
|
19821
|
+
try {
|
|
19822
|
+
switch (config === null || config === void 0 ? void 0 : config.transactionDetails) {
|
|
19823
|
+
case 'accounts':
|
|
19824
|
+
{
|
|
19825
|
+
const res = create(unsafeRes, GetAccountsModeBlockRpcResult);
|
|
19769
19826
|
|
|
19770
|
-
|
|
19771
|
-
|
|
19772
|
-
|
|
19773
|
-
|
|
19774
|
-
|
|
19775
|
-
|
|
19776
|
-
|
|
19777
|
-
|
|
19778
|
-
|
|
19779
|
-
|
|
19780
|
-
|
|
19781
|
-
|
|
19782
|
-
|
|
19783
|
-
|
|
19784
|
-
|
|
19827
|
+
if ('error' in res) {
|
|
19828
|
+
throw res.error;
|
|
19829
|
+
}
|
|
19830
|
+
|
|
19831
|
+
return res.result;
|
|
19832
|
+
}
|
|
19833
|
+
|
|
19834
|
+
case 'none':
|
|
19835
|
+
{
|
|
19836
|
+
const res = create(unsafeRes, GetNoneModeBlockRpcResult);
|
|
19837
|
+
|
|
19838
|
+
if ('error' in res) {
|
|
19839
|
+
throw res.error;
|
|
19840
|
+
}
|
|
19841
|
+
|
|
19842
|
+
return res.result;
|
|
19843
|
+
}
|
|
19844
|
+
|
|
19845
|
+
default:
|
|
19846
|
+
{
|
|
19847
|
+
const res = create(unsafeRes, GetBlockRpcResult);
|
|
19848
|
+
|
|
19849
|
+
if ('error' in res) {
|
|
19850
|
+
throw res.error;
|
|
19851
|
+
}
|
|
19852
|
+
|
|
19853
|
+
const {
|
|
19854
|
+
result
|
|
19855
|
+
} = res;
|
|
19856
|
+
return result ? { ...result,
|
|
19857
|
+
transactions: result.transactions.map(({
|
|
19858
|
+
transaction,
|
|
19859
|
+
meta,
|
|
19860
|
+
version
|
|
19861
|
+
}) => ({
|
|
19862
|
+
meta,
|
|
19863
|
+
transaction: { ...transaction,
|
|
19864
|
+
message: versionedMessageFromResponse(version, transaction.message)
|
|
19865
|
+
},
|
|
19866
|
+
version
|
|
19867
|
+
}))
|
|
19868
|
+
} : null;
|
|
19869
|
+
}
|
|
19870
|
+
}
|
|
19871
|
+
} catch (e) {
|
|
19872
|
+
throw new SolanaJSONRPCError(e, 'failed to get confirmed block');
|
|
19873
|
+
}
|
|
19785
19874
|
}
|
|
19786
19875
|
/**
|
|
19787
19876
|
* Fetch parsed transaction details for a confirmed or finalized block
|
|
19788
19877
|
*/
|
|
19789
19878
|
|
|
19790
19879
|
|
|
19880
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
19791
19881
|
async getParsedBlock(slot, rawConfig) {
|
|
19792
19882
|
const {
|
|
19793
19883
|
commitment,
|
|
@@ -19797,13 +19887,45 @@ var solanaWeb3 = (function (exports) {
|
|
|
19797
19887
|
const args = this._buildArgsAtLeastConfirmed([slot], commitment, 'jsonParsed', config);
|
|
19798
19888
|
|
|
19799
19889
|
const unsafeRes = await this._rpcRequest('getBlock', args);
|
|
19800
|
-
const res = create(unsafeRes, GetParsedBlockRpcResult);
|
|
19801
19890
|
|
|
19802
|
-
|
|
19803
|
-
|
|
19804
|
-
|
|
19891
|
+
try {
|
|
19892
|
+
switch (config === null || config === void 0 ? void 0 : config.transactionDetails) {
|
|
19893
|
+
case 'accounts':
|
|
19894
|
+
{
|
|
19895
|
+
const res = create(unsafeRes, GetParsedAccountsModeBlockRpcResult);
|
|
19805
19896
|
|
|
19806
|
-
|
|
19897
|
+
if ('error' in res) {
|
|
19898
|
+
throw res.error;
|
|
19899
|
+
}
|
|
19900
|
+
|
|
19901
|
+
return res.result;
|
|
19902
|
+
}
|
|
19903
|
+
|
|
19904
|
+
case 'none':
|
|
19905
|
+
{
|
|
19906
|
+
const res = create(unsafeRes, GetParsedNoneModeBlockRpcResult);
|
|
19907
|
+
|
|
19908
|
+
if ('error' in res) {
|
|
19909
|
+
throw res.error;
|
|
19910
|
+
}
|
|
19911
|
+
|
|
19912
|
+
return res.result;
|
|
19913
|
+
}
|
|
19914
|
+
|
|
19915
|
+
default:
|
|
19916
|
+
{
|
|
19917
|
+
const res = create(unsafeRes, GetParsedBlockRpcResult);
|
|
19918
|
+
|
|
19919
|
+
if ('error' in res) {
|
|
19920
|
+
throw res.error;
|
|
19921
|
+
}
|
|
19922
|
+
|
|
19923
|
+
return res.result;
|
|
19924
|
+
}
|
|
19925
|
+
}
|
|
19926
|
+
} catch (e) {
|
|
19927
|
+
throw new SolanaJSONRPCError(e, 'failed to get block');
|
|
19928
|
+
}
|
|
19807
19929
|
}
|
|
19808
19930
|
/*
|
|
19809
19931
|
* Returns the current block height of the node
|