@solana/web3.js 1.13.1 → 1.14.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 +83 -31
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +83 -31
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +79 -3
- package/lib/index.esm.js +83 -31
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +83 -31
- 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/module.flow.js +142 -3
- package/package.json +1 -1
- package/src/connection.ts +151 -32
package/lib/index.d.ts
CHANGED
|
@@ -740,6 +740,24 @@ declare module '@solana/web3.js' {
|
|
|
740
740
|
/** The error result of transaction processing */
|
|
741
741
|
err: TransactionError | null;
|
|
742
742
|
};
|
|
743
|
+
/**
|
|
744
|
+
* A processed transaction from the RPC API
|
|
745
|
+
*/
|
|
746
|
+
export type TransactionResponse = {
|
|
747
|
+
/** The slot during which the transaction was processed */
|
|
748
|
+
slot: number;
|
|
749
|
+
/** The transaction */
|
|
750
|
+
transaction: {
|
|
751
|
+
/** The transaction message */
|
|
752
|
+
message: Message;
|
|
753
|
+
/** The transaction signatures */
|
|
754
|
+
signatures: string[];
|
|
755
|
+
};
|
|
756
|
+
/** Metadata produced from the transaction */
|
|
757
|
+
meta: ConfirmedTransactionMeta | null;
|
|
758
|
+
/** The unix timestamp of when the transaction was processed */
|
|
759
|
+
blockTime?: number | null;
|
|
760
|
+
};
|
|
743
761
|
/**
|
|
744
762
|
* A confirmed transaction on the ledger
|
|
745
763
|
*/
|
|
@@ -819,6 +837,42 @@ declare module '@solana/web3.js' {
|
|
|
819
837
|
/** The unix timestamp of when the transaction was processed */
|
|
820
838
|
blockTime?: number | null;
|
|
821
839
|
};
|
|
840
|
+
/**
|
|
841
|
+
* A processed block fetched from the RPC API
|
|
842
|
+
*/
|
|
843
|
+
export type BlockResponse = {
|
|
844
|
+
/** Blockhash of this block */
|
|
845
|
+
blockhash: Blockhash;
|
|
846
|
+
/** Blockhash of this block's parent */
|
|
847
|
+
previousBlockhash: Blockhash;
|
|
848
|
+
/** Slot index of this block's parent */
|
|
849
|
+
parentSlot: number;
|
|
850
|
+
/** Vector of transactions with status meta and original message */
|
|
851
|
+
transactions: Array<{
|
|
852
|
+
/** The transaction */
|
|
853
|
+
transaction: {
|
|
854
|
+
/** The transaction message */
|
|
855
|
+
message: Message;
|
|
856
|
+
/** The transaction signatures */
|
|
857
|
+
signatures: string[];
|
|
858
|
+
};
|
|
859
|
+
/** Metadata produced from the transaction */
|
|
860
|
+
meta: ConfirmedTransactionMeta | null;
|
|
861
|
+
}>;
|
|
862
|
+
/** Vector of block rewards */
|
|
863
|
+
rewards?: Array<{
|
|
864
|
+
/** Public key of reward recipient */
|
|
865
|
+
pubkey: string;
|
|
866
|
+
/** Reward value in lamports */
|
|
867
|
+
lamports: number;
|
|
868
|
+
/** Account balance after reward is applied */
|
|
869
|
+
postBalance: number | null;
|
|
870
|
+
/** Type of reward received */
|
|
871
|
+
rewardType: string | null;
|
|
872
|
+
}>;
|
|
873
|
+
/** The unix timestamp of when the block was processed */
|
|
874
|
+
blockTime: number | null;
|
|
875
|
+
};
|
|
822
876
|
/**
|
|
823
877
|
* A ConfirmedBlock on the ledger
|
|
824
878
|
*/
|
|
@@ -1453,7 +1507,8 @@ declare module '@solana/web3.js' {
|
|
|
1453
1507
|
getTransactionCount(commitment?: Commitment): Promise<number>;
|
|
1454
1508
|
/**
|
|
1455
1509
|
* Fetch the current total currency supply of the cluster in lamports
|
|
1456
|
-
*
|
|
1510
|
+
*
|
|
1511
|
+
* @deprecated Deprecated since v1.2.8. Please use {@link getSupply} instead.
|
|
1457
1512
|
*/
|
|
1458
1513
|
getTotalSupply(commitment?: Commitment): Promise<number>;
|
|
1459
1514
|
/**
|
|
@@ -1523,9 +1578,29 @@ declare module '@solana/web3.js' {
|
|
|
1523
1578
|
* Fetch the node version
|
|
1524
1579
|
*/
|
|
1525
1580
|
getVersion(): Promise<Version>;
|
|
1581
|
+
/**
|
|
1582
|
+
* Fetch a processed block from the cluster.
|
|
1583
|
+
*/
|
|
1584
|
+
getBlock(
|
|
1585
|
+
slot: number,
|
|
1586
|
+
opts?: {
|
|
1587
|
+
commitment?: Finality;
|
|
1588
|
+
},
|
|
1589
|
+
): Promise<BlockResponse | null>;
|
|
1590
|
+
/**
|
|
1591
|
+
* Fetch a processed transaction from the cluster.
|
|
1592
|
+
*/
|
|
1593
|
+
getTransaction(
|
|
1594
|
+
signature: string,
|
|
1595
|
+
opts?: {
|
|
1596
|
+
commitment?: Finality;
|
|
1597
|
+
},
|
|
1598
|
+
): Promise<TransactionResponse | null>;
|
|
1526
1599
|
/**
|
|
1527
1600
|
* Fetch a list of Transactions and transaction statuses from the cluster
|
|
1528
|
-
* for a confirmed block
|
|
1601
|
+
* for a confirmed block.
|
|
1602
|
+
*
|
|
1603
|
+
* @deprecated Deprecated since v1.13.0. Please use {@link getBlock} instead.
|
|
1529
1604
|
*/
|
|
1530
1605
|
getConfirmedBlock(
|
|
1531
1606
|
slot: number,
|
|
@@ -1562,7 +1637,8 @@ declare module '@solana/web3.js' {
|
|
|
1562
1637
|
/**
|
|
1563
1638
|
* Fetch a list of all the confirmed signatures for transactions involving an address
|
|
1564
1639
|
* within a specified slot range. Max range allowed is 10,000 slots.
|
|
1565
|
-
*
|
|
1640
|
+
*
|
|
1641
|
+
* @deprecated Deprecated since v1.3. Please use {@link getConfirmedSignaturesForAddress2} instead.
|
|
1566
1642
|
*
|
|
1567
1643
|
* @param address queried address
|
|
1568
1644
|
* @param startSlot start slot, inclusive
|
package/lib/index.esm.js
CHANGED
|
@@ -2936,10 +2936,6 @@ const GetSignatureStatusesRpcResult = jsonRpcResultAndContext(array(nullable(Sig
|
|
|
2936
2936
|
*/
|
|
2937
2937
|
|
|
2938
2938
|
const GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult(number());
|
|
2939
|
-
/**
|
|
2940
|
-
* @internal
|
|
2941
|
-
*/
|
|
2942
|
-
|
|
2943
2939
|
const ConfirmedTransactionResult = type({
|
|
2944
2940
|
signatures: array(string()),
|
|
2945
2941
|
message: type({
|
|
@@ -2957,13 +2953,6 @@ const ConfirmedTransactionResult = type({
|
|
|
2957
2953
|
recentBlockhash: string()
|
|
2958
2954
|
})
|
|
2959
2955
|
});
|
|
2960
|
-
const TransactionFromConfirmed = coerce(instance(Transaction), ConfirmedTransactionResult, result => {
|
|
2961
|
-
const {
|
|
2962
|
-
message,
|
|
2963
|
-
signatures
|
|
2964
|
-
} = result;
|
|
2965
|
-
return Transaction.populate(new Message(message), signatures);
|
|
2966
|
-
});
|
|
2967
2956
|
const ParsedInstructionResult = type({
|
|
2968
2957
|
parsed: unknown(),
|
|
2969
2958
|
program: string(),
|
|
@@ -3059,7 +3048,7 @@ const GetConfirmedBlockRpcResult = jsonRpcResult(nullable(type({
|
|
|
3059
3048
|
previousBlockhash: string(),
|
|
3060
3049
|
parentSlot: number(),
|
|
3061
3050
|
transactions: array(type({
|
|
3062
|
-
transaction:
|
|
3051
|
+
transaction: ConfirmedTransactionResult,
|
|
3063
3052
|
meta: nullable(ConfirmedTransactionMetaResult)
|
|
3064
3053
|
})),
|
|
3065
3054
|
rewards: optional(array(type({
|
|
@@ -3087,9 +3076,9 @@ const GetConfirmedBlockSignaturesRpcResult = jsonRpcResult(nullable(type({
|
|
|
3087
3076
|
|
|
3088
3077
|
const GetConfirmedTransactionRpcResult = jsonRpcResult(nullable(type({
|
|
3089
3078
|
slot: number(),
|
|
3090
|
-
transaction: TransactionFromConfirmed,
|
|
3091
3079
|
meta: ConfirmedTransactionMetaResult,
|
|
3092
|
-
blockTime: optional(nullable(number()))
|
|
3080
|
+
blockTime: optional(nullable(number())),
|
|
3081
|
+
transaction: ConfirmedTransactionResult
|
|
3093
3082
|
})));
|
|
3094
3083
|
/**
|
|
3095
3084
|
* Expected JSON RPC response for the "getConfirmedTransaction" message
|
|
@@ -3902,7 +3891,8 @@ class Connection {
|
|
|
3902
3891
|
}
|
|
3903
3892
|
/**
|
|
3904
3893
|
* Fetch the current total currency supply of the cluster in lamports
|
|
3905
|
-
*
|
|
3894
|
+
*
|
|
3895
|
+
* @deprecated Deprecated since v1.2.8. Please use {@link getSupply} instead.
|
|
3906
3896
|
*/
|
|
3907
3897
|
|
|
3908
3898
|
|
|
@@ -4111,13 +4101,12 @@ class Connection {
|
|
|
4111
4101
|
return res.result;
|
|
4112
4102
|
}
|
|
4113
4103
|
/**
|
|
4114
|
-
* Fetch a
|
|
4115
|
-
* for a confirmed block
|
|
4104
|
+
* Fetch a processed block from the cluster.
|
|
4116
4105
|
*/
|
|
4117
4106
|
|
|
4118
4107
|
|
|
4119
|
-
async
|
|
4120
|
-
const args = this._buildArgsAtLeastConfirmed([slot], commitment);
|
|
4108
|
+
async getBlock(slot, opts) {
|
|
4109
|
+
const args = this._buildArgsAtLeastConfirmed([slot], opts && opts.commitment);
|
|
4121
4110
|
|
|
4122
4111
|
const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
|
|
4123
4112
|
const res = create(unsafeRes, GetConfirmedBlockRpcResult);
|
|
@@ -4127,12 +4116,73 @@ class Connection {
|
|
|
4127
4116
|
}
|
|
4128
4117
|
|
|
4129
4118
|
const result = res.result;
|
|
4119
|
+
if (!result) return result;
|
|
4120
|
+
return { ...result,
|
|
4121
|
+
transactions: result.transactions.map(({
|
|
4122
|
+
transaction,
|
|
4123
|
+
meta
|
|
4124
|
+
}) => {
|
|
4125
|
+
const message = new Message(transaction.message);
|
|
4126
|
+
return {
|
|
4127
|
+
meta,
|
|
4128
|
+
transaction: { ...transaction,
|
|
4129
|
+
message
|
|
4130
|
+
}
|
|
4131
|
+
};
|
|
4132
|
+
})
|
|
4133
|
+
};
|
|
4134
|
+
}
|
|
4135
|
+
/**
|
|
4136
|
+
* Fetch a processed transaction from the cluster.
|
|
4137
|
+
*/
|
|
4138
|
+
|
|
4139
|
+
|
|
4140
|
+
async getTransaction(signature, opts) {
|
|
4141
|
+
const args = this._buildArgsAtLeastConfirmed([signature], opts && opts.commitment);
|
|
4142
|
+
|
|
4143
|
+
const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
|
|
4144
|
+
const res = create(unsafeRes, GetConfirmedTransactionRpcResult);
|
|
4145
|
+
|
|
4146
|
+
if ('error' in res) {
|
|
4147
|
+
throw new Error('failed to get confirmed transaction: ' + res.error.message);
|
|
4148
|
+
}
|
|
4149
|
+
|
|
4150
|
+
const result = res.result;
|
|
4151
|
+
if (!result) return result;
|
|
4152
|
+
return { ...result,
|
|
4153
|
+
transaction: { ...result.transaction,
|
|
4154
|
+
message: new Message(result.transaction.message)
|
|
4155
|
+
}
|
|
4156
|
+
};
|
|
4157
|
+
}
|
|
4158
|
+
/**
|
|
4159
|
+
* Fetch a list of Transactions and transaction statuses from the cluster
|
|
4160
|
+
* for a confirmed block.
|
|
4161
|
+
*
|
|
4162
|
+
* @deprecated Deprecated since v1.13.0. Please use {@link getBlock} instead.
|
|
4163
|
+
*/
|
|
4164
|
+
|
|
4165
|
+
|
|
4166
|
+
async getConfirmedBlock(slot, commitment) {
|
|
4167
|
+
const result = await this.getBlock(slot, {
|
|
4168
|
+
commitment
|
|
4169
|
+
});
|
|
4130
4170
|
|
|
4131
4171
|
if (!result) {
|
|
4132
4172
|
throw new Error('Confirmed block ' + slot + ' not found');
|
|
4133
4173
|
}
|
|
4134
4174
|
|
|
4135
|
-
return result
|
|
4175
|
+
return { ...result,
|
|
4176
|
+
transactions: result.transactions.map(({
|
|
4177
|
+
transaction,
|
|
4178
|
+
meta
|
|
4179
|
+
}) => {
|
|
4180
|
+
return {
|
|
4181
|
+
meta,
|
|
4182
|
+
transaction: Transaction.populate(transaction.message, transaction.signatures)
|
|
4183
|
+
};
|
|
4184
|
+
})
|
|
4185
|
+
};
|
|
4136
4186
|
}
|
|
4137
4187
|
/**
|
|
4138
4188
|
* Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
|
|
@@ -4166,16 +4216,17 @@ class Connection {
|
|
|
4166
4216
|
|
|
4167
4217
|
|
|
4168
4218
|
async getConfirmedTransaction(signature, commitment) {
|
|
4169
|
-
const
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
}
|
|
4177
|
-
|
|
4178
|
-
|
|
4219
|
+
const result = await this.getTransaction(signature, {
|
|
4220
|
+
commitment
|
|
4221
|
+
});
|
|
4222
|
+
if (!result) return result;
|
|
4223
|
+
const {
|
|
4224
|
+
message,
|
|
4225
|
+
signatures
|
|
4226
|
+
} = result.transaction;
|
|
4227
|
+
return { ...result,
|
|
4228
|
+
transaction: Transaction.populate(message, signatures)
|
|
4229
|
+
};
|
|
4179
4230
|
}
|
|
4180
4231
|
/**
|
|
4181
4232
|
* Fetch parsed transaction details for a confirmed transaction
|
|
@@ -4223,7 +4274,8 @@ class Connection {
|
|
|
4223
4274
|
/**
|
|
4224
4275
|
* Fetch a list of all the confirmed signatures for transactions involving an address
|
|
4225
4276
|
* within a specified slot range. Max range allowed is 10,000 slots.
|
|
4226
|
-
*
|
|
4277
|
+
*
|
|
4278
|
+
* @deprecated Deprecated since v1.3. Please use {@link getConfirmedSignaturesForAddress2} instead.
|
|
4227
4279
|
*
|
|
4228
4280
|
* @param address queried address
|
|
4229
4281
|
* @param startSlot start slot, inclusive
|