@solana/web3.js 1.2.8 → 1.3.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 +88 -13
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +88 -13
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +23 -0
- package/lib/index.esm.js +88 -13
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +88 -13
- 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 +40 -0
- package/package.json +1 -1
- package/src/connection.ts +109 -20
package/module.flow.js
CHANGED
|
@@ -1108,6 +1108,37 @@ declare module "@solana/web3.js" {
|
|
|
1108
1108
|
...
|
|
1109
1109
|
};
|
|
1110
1110
|
|
|
1111
|
+
/**
|
|
1112
|
+
* A ConfirmedBlock on the ledger with signatures only
|
|
1113
|
+
*/
|
|
1114
|
+
declare export type ConfirmedBlockSignatures = {
|
|
1115
|
+
/**
|
|
1116
|
+
* Blockhash of this block
|
|
1117
|
+
*/
|
|
1118
|
+
blockhash: Blockhash,
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Blockhash of this block's parent
|
|
1122
|
+
*/
|
|
1123
|
+
previousBlockhash: Blockhash,
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Slot index of this block's parent
|
|
1127
|
+
*/
|
|
1128
|
+
parentSlot: number,
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Vector of signatures
|
|
1132
|
+
*/
|
|
1133
|
+
signatures: Array<string>,
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* The unix timestamp of when the block was processed
|
|
1137
|
+
*/
|
|
1138
|
+
blockTime: number | null,
|
|
1139
|
+
...
|
|
1140
|
+
};
|
|
1141
|
+
|
|
1111
1142
|
/**
|
|
1112
1143
|
* A performance sample
|
|
1113
1144
|
*/
|
|
@@ -1742,6 +1773,7 @@ account: AccountInfo<Buffer | ParsedAccountData>,...
|
|
|
1742
1773
|
|
|
1743
1774
|
/**
|
|
1744
1775
|
* Fetch the current total currency supply of the cluster in lamports
|
|
1776
|
+
* @deprecated Deprecated since v1.2.8. Use `Connection.getSupply()` instead.
|
|
1745
1777
|
*/
|
|
1746
1778
|
getTotalSupply(commitment?: Commitment): Promise<number>;
|
|
1747
1779
|
|
|
@@ -1832,6 +1864,13 @@ feeCalculator: FeeCalculator,...
|
|
|
1832
1864
|
*/
|
|
1833
1865
|
getConfirmedBlock(slot: number): Promise<ConfirmedBlock>;
|
|
1834
1866
|
|
|
1867
|
+
/**
|
|
1868
|
+
* Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
|
|
1869
|
+
*/
|
|
1870
|
+
getConfirmedBlockSignatures(
|
|
1871
|
+
slot: number
|
|
1872
|
+
): Promise<ConfirmedBlockSignatures>;
|
|
1873
|
+
|
|
1835
1874
|
/**
|
|
1836
1875
|
* Fetch a transaction details for a confirmed transaction
|
|
1837
1876
|
*/
|
|
@@ -1856,6 +1895,7 @@ feeCalculator: FeeCalculator,...
|
|
|
1856
1895
|
/**
|
|
1857
1896
|
* Fetch a list of all the confirmed signatures for transactions involving an address
|
|
1858
1897
|
* within a specified slot range. Max range allowed is 10,000 slots.
|
|
1898
|
+
* @deprecated Deprecated since v1.3. Use `Connection.getConfirmedSignaturesForAddress2()` instead.
|
|
1859
1899
|
* @param address queried address
|
|
1860
1900
|
* @param startSlot start slot, inclusive
|
|
1861
1901
|
* @param endSlot end slot, inclusive
|
package/package.json
CHANGED
package/src/connection.ts
CHANGED
|
@@ -583,6 +583,22 @@ export type ConfirmedBlock = {
|
|
|
583
583
|
blockTime: number | null;
|
|
584
584
|
};
|
|
585
585
|
|
|
586
|
+
/**
|
|
587
|
+
* A ConfirmedBlock on the ledger with signatures only
|
|
588
|
+
*/
|
|
589
|
+
export type ConfirmedBlockSignatures = {
|
|
590
|
+
/** Blockhash of this block */
|
|
591
|
+
blockhash: Blockhash;
|
|
592
|
+
/** Blockhash of this block's parent */
|
|
593
|
+
previousBlockhash: Blockhash;
|
|
594
|
+
/** Slot index of this block's parent */
|
|
595
|
+
parentSlot: number;
|
|
596
|
+
/** Vector of signatures */
|
|
597
|
+
signatures: Array<string>;
|
|
598
|
+
/** The unix timestamp of when the block was processed */
|
|
599
|
+
blockTime: number | null;
|
|
600
|
+
};
|
|
601
|
+
|
|
586
602
|
/**
|
|
587
603
|
* A performance sample
|
|
588
604
|
*/
|
|
@@ -915,13 +931,6 @@ const StakeActivationResult = pick({
|
|
|
915
931
|
inactive: number(),
|
|
916
932
|
});
|
|
917
933
|
|
|
918
|
-
/**
|
|
919
|
-
* Expected JSON RPC response for the "getConfirmedSignaturesForAddress" message
|
|
920
|
-
*/
|
|
921
|
-
const GetConfirmedSignaturesForAddressRpcResult = jsonRpcResult(
|
|
922
|
-
array(string()),
|
|
923
|
-
);
|
|
924
|
-
|
|
925
934
|
/**
|
|
926
935
|
* Expected JSON RPC response for the "getConfirmedSignaturesForAddress2" message
|
|
927
936
|
*/
|
|
@@ -1231,6 +1240,21 @@ const GetConfirmedBlockRpcResult = jsonRpcResult(
|
|
|
1231
1240
|
),
|
|
1232
1241
|
);
|
|
1233
1242
|
|
|
1243
|
+
/**
|
|
1244
|
+
* Expected JSON RPC response for the "getConfirmedBlockSignatures" message
|
|
1245
|
+
*/
|
|
1246
|
+
const GetConfirmedBlockSignaturesRpcResult = jsonRpcResult(
|
|
1247
|
+
nullable(
|
|
1248
|
+
pick({
|
|
1249
|
+
blockhash: string(),
|
|
1250
|
+
previousBlockhash: string(),
|
|
1251
|
+
parentSlot: number(),
|
|
1252
|
+
signatures: array(string()),
|
|
1253
|
+
blockTime: nullable(number()),
|
|
1254
|
+
}),
|
|
1255
|
+
),
|
|
1256
|
+
);
|
|
1257
|
+
|
|
1234
1258
|
/**
|
|
1235
1259
|
* Expected JSON RPC response for the "getConfirmedTransaction" message
|
|
1236
1260
|
*/
|
|
@@ -2284,15 +2308,16 @@ export class Connection {
|
|
|
2284
2308
|
|
|
2285
2309
|
/**
|
|
2286
2310
|
* Fetch the current total currency supply of the cluster in lamports
|
|
2311
|
+
* @deprecated Deprecated since v1.2.8. Use `Connection.getSupply()` instead.
|
|
2287
2312
|
*/
|
|
2288
2313
|
async getTotalSupply(commitment?: Commitment): Promise<number> {
|
|
2289
2314
|
const args = this._buildArgs([], commitment);
|
|
2290
|
-
const unsafeRes = await this._rpcRequest('
|
|
2291
|
-
const res = create(unsafeRes,
|
|
2315
|
+
const unsafeRes = await this._rpcRequest('getSupply', args);
|
|
2316
|
+
const res = create(unsafeRes, GetSupplyRpcResult);
|
|
2292
2317
|
if ('error' in res) {
|
|
2293
2318
|
throw new Error('failed to get total supply: ' + res.error.message);
|
|
2294
2319
|
}
|
|
2295
|
-
return res.result;
|
|
2320
|
+
return res.result.value.total;
|
|
2296
2321
|
}
|
|
2297
2322
|
|
|
2298
2323
|
/**
|
|
@@ -2477,6 +2502,27 @@ export class Connection {
|
|
|
2477
2502
|
return result;
|
|
2478
2503
|
}
|
|
2479
2504
|
|
|
2505
|
+
/**
|
|
2506
|
+
* Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
|
|
2507
|
+
*/
|
|
2508
|
+
async getConfirmedBlockSignatures(
|
|
2509
|
+
slot: number,
|
|
2510
|
+
): Promise<ConfirmedBlockSignatures> {
|
|
2511
|
+
const unsafeRes = await this._rpcRequest('getConfirmedBlock', [
|
|
2512
|
+
slot,
|
|
2513
|
+
{transactionDetails: 'signatures', rewards: false},
|
|
2514
|
+
]);
|
|
2515
|
+
const res = create(unsafeRes, GetConfirmedBlockSignaturesRpcResult);
|
|
2516
|
+
if ('error' in res) {
|
|
2517
|
+
throw new Error('failed to get confirmed block: ' + res.error.message);
|
|
2518
|
+
}
|
|
2519
|
+
const result = res.result;
|
|
2520
|
+
if (!result) {
|
|
2521
|
+
throw new Error('Confirmed block ' + slot + ' not found');
|
|
2522
|
+
}
|
|
2523
|
+
return result;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2480
2526
|
/**
|
|
2481
2527
|
* Fetch a transaction details for a confirmed transaction
|
|
2482
2528
|
*/
|
|
@@ -2544,6 +2590,7 @@ export class Connection {
|
|
|
2544
2590
|
/**
|
|
2545
2591
|
* Fetch a list of all the confirmed signatures for transactions involving an address
|
|
2546
2592
|
* within a specified slot range. Max range allowed is 10,000 slots.
|
|
2593
|
+
* @deprecated Deprecated since v1.3. Use `Connection.getConfirmedSignaturesForAddress2()` instead.
|
|
2547
2594
|
*
|
|
2548
2595
|
* @param address queried address
|
|
2549
2596
|
* @param startSlot start slot, inclusive
|
|
@@ -2554,17 +2601,59 @@ export class Connection {
|
|
|
2554
2601
|
startSlot: number,
|
|
2555
2602
|
endSlot: number,
|
|
2556
2603
|
): Promise<Array<TransactionSignature>> {
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
)
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2604
|
+
let options: any = {};
|
|
2605
|
+
|
|
2606
|
+
let firstAvailableBlock = await this.getFirstAvailableBlock();
|
|
2607
|
+
while (!('until' in options)) {
|
|
2608
|
+
startSlot--;
|
|
2609
|
+
if (startSlot <= 0 || startSlot < firstAvailableBlock) {
|
|
2610
|
+
break;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
try {
|
|
2614
|
+
const block = await this.getConfirmedBlockSignatures(startSlot);
|
|
2615
|
+
if (block.signatures.length > 0) {
|
|
2616
|
+
options.until = block.signatures[
|
|
2617
|
+
block.signatures.length - 1
|
|
2618
|
+
].toString();
|
|
2619
|
+
}
|
|
2620
|
+
} catch (err) {
|
|
2621
|
+
if (err.message.includes('skipped')) {
|
|
2622
|
+
continue;
|
|
2623
|
+
} else {
|
|
2624
|
+
throw err;
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2566
2627
|
}
|
|
2567
|
-
|
|
2628
|
+
|
|
2629
|
+
let highestConfirmedRoot = await this.getSlot('finalized');
|
|
2630
|
+
while (!('before' in options)) {
|
|
2631
|
+
endSlot++;
|
|
2632
|
+
if (endSlot > highestConfirmedRoot) {
|
|
2633
|
+
break;
|
|
2634
|
+
}
|
|
2635
|
+
|
|
2636
|
+
try {
|
|
2637
|
+
const block = await this.getConfirmedBlockSignatures(endSlot);
|
|
2638
|
+
if (block.signatures.length > 0) {
|
|
2639
|
+
options.before = block.signatures[
|
|
2640
|
+
block.signatures.length - 1
|
|
2641
|
+
].toString();
|
|
2642
|
+
}
|
|
2643
|
+
} catch (err) {
|
|
2644
|
+
if (err.message.includes('skipped')) {
|
|
2645
|
+
continue;
|
|
2646
|
+
} else {
|
|
2647
|
+
throw err;
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
const confirmedSignatureInfo = await this.getConfirmedSignaturesForAddress2(
|
|
2653
|
+
address,
|
|
2654
|
+
options,
|
|
2655
|
+
);
|
|
2656
|
+
return confirmedSignatureInfo.map(info => info.signature);
|
|
2568
2657
|
}
|
|
2569
2658
|
|
|
2570
2659
|
/**
|