@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/lib/index.cjs.js
CHANGED
|
@@ -2742,11 +2742,6 @@ const StakeActivationResult = superstruct.type({
|
|
|
2742
2742
|
active: superstruct.number(),
|
|
2743
2743
|
inactive: superstruct.number()
|
|
2744
2744
|
});
|
|
2745
|
-
/**
|
|
2746
|
-
* Expected JSON RPC response for the "getConfirmedSignaturesForAddress" message
|
|
2747
|
-
*/
|
|
2748
|
-
|
|
2749
|
-
const GetConfirmedSignaturesForAddressRpcResult = jsonRpcResult(superstruct.array(superstruct.string()));
|
|
2750
2745
|
/**
|
|
2751
2746
|
* Expected JSON RPC response for the "getConfirmedSignaturesForAddress2" message
|
|
2752
2747
|
*/
|
|
@@ -2991,6 +2986,17 @@ const GetConfirmedBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruc
|
|
|
2991
2986
|
}))),
|
|
2992
2987
|
blockTime: superstruct.nullable(superstruct.number())
|
|
2993
2988
|
})));
|
|
2989
|
+
/**
|
|
2990
|
+
* Expected JSON RPC response for the "getConfirmedBlockSignatures" message
|
|
2991
|
+
*/
|
|
2992
|
+
|
|
2993
|
+
const GetConfirmedBlockSignaturesRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
|
|
2994
|
+
blockhash: superstruct.string(),
|
|
2995
|
+
previousBlockhash: superstruct.string(),
|
|
2996
|
+
parentSlot: superstruct.number(),
|
|
2997
|
+
signatures: superstruct.array(superstruct.string()),
|
|
2998
|
+
blockTime: superstruct.nullable(superstruct.number())
|
|
2999
|
+
})));
|
|
2994
3000
|
/**
|
|
2995
3001
|
* Expected JSON RPC response for the "getConfirmedTransaction" message
|
|
2996
3002
|
*/
|
|
@@ -3753,20 +3759,21 @@ class Connection {
|
|
|
3753
3759
|
}
|
|
3754
3760
|
/**
|
|
3755
3761
|
* Fetch the current total currency supply of the cluster in lamports
|
|
3762
|
+
* @deprecated Deprecated since v1.2.8. Use `Connection.getSupply()` instead.
|
|
3756
3763
|
*/
|
|
3757
3764
|
|
|
3758
3765
|
|
|
3759
3766
|
async getTotalSupply(commitment) {
|
|
3760
3767
|
const args = this._buildArgs([], commitment);
|
|
3761
3768
|
|
|
3762
|
-
const unsafeRes = await this._rpcRequest('
|
|
3763
|
-
const res = superstruct.create(unsafeRes,
|
|
3769
|
+
const unsafeRes = await this._rpcRequest('getSupply', args);
|
|
3770
|
+
const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
|
|
3764
3771
|
|
|
3765
3772
|
if ('error' in res) {
|
|
3766
3773
|
throw new Error('failed to get total supply: ' + res.error.message);
|
|
3767
3774
|
}
|
|
3768
3775
|
|
|
3769
|
-
return res.result;
|
|
3776
|
+
return res.result.value.total;
|
|
3770
3777
|
}
|
|
3771
3778
|
/**
|
|
3772
3779
|
* Fetch the cluster InflationGovernor parameters
|
|
@@ -3963,6 +3970,30 @@ class Connection {
|
|
|
3963
3970
|
|
|
3964
3971
|
return result;
|
|
3965
3972
|
}
|
|
3973
|
+
/**
|
|
3974
|
+
* Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
|
|
3975
|
+
*/
|
|
3976
|
+
|
|
3977
|
+
|
|
3978
|
+
async getConfirmedBlockSignatures(slot) {
|
|
3979
|
+
const unsafeRes = await this._rpcRequest('getConfirmedBlock', [slot, {
|
|
3980
|
+
transactionDetails: 'signatures',
|
|
3981
|
+
rewards: false
|
|
3982
|
+
}]);
|
|
3983
|
+
const res = superstruct.create(unsafeRes, GetConfirmedBlockSignaturesRpcResult);
|
|
3984
|
+
|
|
3985
|
+
if ('error' in res) {
|
|
3986
|
+
throw new Error('failed to get confirmed block: ' + res.error.message);
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
const result = res.result;
|
|
3990
|
+
|
|
3991
|
+
if (!result) {
|
|
3992
|
+
throw new Error('Confirmed block ' + slot + ' not found');
|
|
3993
|
+
}
|
|
3994
|
+
|
|
3995
|
+
return result;
|
|
3996
|
+
}
|
|
3966
3997
|
/**
|
|
3967
3998
|
* Fetch a transaction details for a confirmed transaction
|
|
3968
3999
|
*/
|
|
@@ -4020,6 +4051,7 @@ class Connection {
|
|
|
4020
4051
|
/**
|
|
4021
4052
|
* Fetch a list of all the confirmed signatures for transactions involving an address
|
|
4022
4053
|
* within a specified slot range. Max range allowed is 10,000 slots.
|
|
4054
|
+
* @deprecated Deprecated since v1.3. Use `Connection.getConfirmedSignaturesForAddress2()` instead.
|
|
4023
4055
|
*
|
|
4024
4056
|
* @param address queried address
|
|
4025
4057
|
* @param startSlot start slot, inclusive
|
|
@@ -4028,14 +4060,57 @@ class Connection {
|
|
|
4028
4060
|
|
|
4029
4061
|
|
|
4030
4062
|
async getConfirmedSignaturesForAddress(address, startSlot, endSlot) {
|
|
4031
|
-
|
|
4032
|
-
|
|
4063
|
+
let options = {};
|
|
4064
|
+
let firstAvailableBlock = await this.getFirstAvailableBlock();
|
|
4033
4065
|
|
|
4034
|
-
|
|
4035
|
-
|
|
4066
|
+
while (!('until' in options)) {
|
|
4067
|
+
startSlot--;
|
|
4068
|
+
|
|
4069
|
+
if (startSlot <= 0 || startSlot < firstAvailableBlock) {
|
|
4070
|
+
break;
|
|
4071
|
+
}
|
|
4072
|
+
|
|
4073
|
+
try {
|
|
4074
|
+
const block = await this.getConfirmedBlockSignatures(startSlot);
|
|
4075
|
+
|
|
4076
|
+
if (block.signatures.length > 0) {
|
|
4077
|
+
options.until = block.signatures[block.signatures.length - 1].toString();
|
|
4078
|
+
}
|
|
4079
|
+
} catch (err) {
|
|
4080
|
+
if (err.message.includes('skipped')) {
|
|
4081
|
+
continue;
|
|
4082
|
+
} else {
|
|
4083
|
+
throw err;
|
|
4084
|
+
}
|
|
4085
|
+
}
|
|
4036
4086
|
}
|
|
4037
4087
|
|
|
4038
|
-
|
|
4088
|
+
let highestConfirmedRoot = await this.getSlot('finalized');
|
|
4089
|
+
|
|
4090
|
+
while (!('before' in options)) {
|
|
4091
|
+
endSlot++;
|
|
4092
|
+
|
|
4093
|
+
if (endSlot > highestConfirmedRoot) {
|
|
4094
|
+
break;
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
try {
|
|
4098
|
+
const block = await this.getConfirmedBlockSignatures(endSlot);
|
|
4099
|
+
|
|
4100
|
+
if (block.signatures.length > 0) {
|
|
4101
|
+
options.before = block.signatures[block.signatures.length - 1].toString();
|
|
4102
|
+
}
|
|
4103
|
+
} catch (err) {
|
|
4104
|
+
if (err.message.includes('skipped')) {
|
|
4105
|
+
continue;
|
|
4106
|
+
} else {
|
|
4107
|
+
throw err;
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
}
|
|
4111
|
+
|
|
4112
|
+
const confirmedSignatureInfo = await this.getConfirmedSignaturesForAddress2(address, options);
|
|
4113
|
+
return confirmedSignatureInfo.map(info => info.signature);
|
|
4039
4114
|
}
|
|
4040
4115
|
/**
|
|
4041
4116
|
* Returns confirmed signatures for transactions involving an
|