@glamsystems/glam-sdk 1.0.2 → 1.0.3-alpha.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/index.cjs.js +3548 -2715
- package/index.esm.js +3543 -2717
- package/package.json +4 -3
- package/src/client/cctp.d.ts +45 -0
- package/src/client/drift.d.ts +5 -4
- package/src/client/jupiter.d.ts +1 -0
- package/src/client/kamino.d.ts +59 -26
- package/src/client/mint.d.ts +1 -1
- package/src/client/price.d.ts +63 -8
- package/src/client/vault.d.ts +1 -18
- package/src/client.d.ts +4 -1
- package/src/constants.d.ts +1 -0
- package/src/deser/base.d.ts +17 -0
- package/src/deser/driftLayouts.d.ts +4 -6
- package/src/deser/index.d.ts +3 -0
- package/src/deser/kaminoLayouts.d.ts +205 -3
- package/src/index.d.ts +1 -0
- package/src/models/mint.d.ts +6 -0
- package/src/models/types.d.ts +0 -16
- package/src/utils/common.d.ts +2 -0
- package/src/utils/fraction.d.ts +29 -0
- package/src/utils/index.d.ts +3 -0
- package/src/utils/pkmap.d.ts +82 -0
- package/src/utils/pkset.d.ts +73 -0
- package/target/idl/ext_kamino.json +226 -0
- package/target/idl/glam_config.json +10 -0
- package/target/idl/glam_mint.json +297 -152
- package/target/idl/glam_protocol.json +14 -561
- package/target/types/ext_kamino.d.ts +226 -0
- package/target/types/ext_kamino.ts +226 -0
- package/target/types/glam_config.d.ts +10 -0
- package/target/types/glam_config.ts +10 -0
- package/target/types/glam_mint.d.ts +293 -148
- package/target/types/glam_mint.ts +297 -152
- package/target/types/glam_protocol.d.ts +14 -561
- package/target/types/glam_protocol.ts +14 -561
- package/src/client/validator.d.ts +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BN } from "@coral-xyz/anchor";
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { BigFractionBytes } from "../utils";
|
|
4
|
+
import { Decodable } from "./base";
|
|
5
|
+
import Decimal from "decimal.js";
|
|
5
6
|
export interface KVaultAllocation {
|
|
6
7
|
reserve: PublicKey;
|
|
7
8
|
ctokenVault: PublicKey;
|
|
@@ -14,7 +15,7 @@ export interface KVaultAllocation {
|
|
|
14
15
|
tokenTargetAllocationSf: BN;
|
|
15
16
|
statePadding: BN[];
|
|
16
17
|
}
|
|
17
|
-
export
|
|
18
|
+
export declare class KVaultState extends Decodable {
|
|
18
19
|
discriminator: number[];
|
|
19
20
|
vaultAdminAuthority: PublicKey;
|
|
20
21
|
baseVaultAuthority: PublicKey;
|
|
@@ -52,4 +53,205 @@ export interface KVaultState {
|
|
|
52
53
|
padding2: BN;
|
|
53
54
|
allocationAdmin: PublicKey;
|
|
54
55
|
padding3: BN[];
|
|
56
|
+
static _layout: any;
|
|
57
|
+
get nameStr(): string;
|
|
55
58
|
}
|
|
59
|
+
interface LastUpdate {
|
|
60
|
+
slot: BN;
|
|
61
|
+
stale: number;
|
|
62
|
+
priceStatus: number;
|
|
63
|
+
placeholder: number[];
|
|
64
|
+
}
|
|
65
|
+
interface PriceHeuristic {
|
|
66
|
+
lower: BN;
|
|
67
|
+
upper: BN;
|
|
68
|
+
exp: BN;
|
|
69
|
+
}
|
|
70
|
+
interface ScopeConfiguration {
|
|
71
|
+
priceFeed: PublicKey;
|
|
72
|
+
priceChain: number[];
|
|
73
|
+
twapChain: number[];
|
|
74
|
+
}
|
|
75
|
+
interface SwitchboardConfiguration {
|
|
76
|
+
priceAggregator: PublicKey;
|
|
77
|
+
twapAggregator: PublicKey;
|
|
78
|
+
}
|
|
79
|
+
interface PythConfiguration {
|
|
80
|
+
price: PublicKey;
|
|
81
|
+
}
|
|
82
|
+
interface TokenInfo {
|
|
83
|
+
name: number[];
|
|
84
|
+
heuristic: PriceHeuristic;
|
|
85
|
+
maxTwapDivergenceBps: BN;
|
|
86
|
+
maxAgePriceSeconds: BN;
|
|
87
|
+
maxAgeTwapSeconds: BN;
|
|
88
|
+
scopeConfiguration: ScopeConfiguration;
|
|
89
|
+
switchboardConfiguration: SwitchboardConfiguration;
|
|
90
|
+
pythConfiguration: PythConfiguration;
|
|
91
|
+
blockPriceUsage: number;
|
|
92
|
+
reserved: number[];
|
|
93
|
+
padding: BN[];
|
|
94
|
+
}
|
|
95
|
+
interface ReserveFees {
|
|
96
|
+
borrowFeeSf: BN;
|
|
97
|
+
flashLoanFeeSf: BN;
|
|
98
|
+
padding: number[];
|
|
99
|
+
}
|
|
100
|
+
interface CurvePoint {
|
|
101
|
+
utilizationRateBps: number;
|
|
102
|
+
borrowRateBps: number;
|
|
103
|
+
}
|
|
104
|
+
interface BorrowRateCurve {
|
|
105
|
+
points: CurvePoint[];
|
|
106
|
+
}
|
|
107
|
+
interface WithdrawalCaps {
|
|
108
|
+
configCapacity: BN;
|
|
109
|
+
currentTotal: BN;
|
|
110
|
+
lastIntervalStartTimestamp: BN;
|
|
111
|
+
configIntervalLengthSeconds: BN;
|
|
112
|
+
}
|
|
113
|
+
interface ReserveLiquidity {
|
|
114
|
+
mintPubkey: PublicKey;
|
|
115
|
+
supplyVault: PublicKey;
|
|
116
|
+
feeVault: PublicKey;
|
|
117
|
+
availableAmount: BN;
|
|
118
|
+
borrowedAmountSf: BN;
|
|
119
|
+
marketPriceSf: BN;
|
|
120
|
+
marketPriceLastUpdatedTs: BN;
|
|
121
|
+
mintDecimals: BN;
|
|
122
|
+
depositLimitCrossedTimestamp: BN;
|
|
123
|
+
borrowLimitCrossedTimestamp: BN;
|
|
124
|
+
cumulativeBorrowRateBsf: BigFractionBytes;
|
|
125
|
+
accumulatedProtocolFeesSf: BN;
|
|
126
|
+
accumulatedReferrerFeesSf: BN;
|
|
127
|
+
pendingReferrerFeesSf: BN;
|
|
128
|
+
absoluteReferralRateSf: BN;
|
|
129
|
+
tokenProgram: PublicKey;
|
|
130
|
+
padding2: BN[];
|
|
131
|
+
padding3: BN[];
|
|
132
|
+
}
|
|
133
|
+
interface ReserveCollateral {
|
|
134
|
+
mintPubkey: PublicKey;
|
|
135
|
+
mintTotalSupply: BN;
|
|
136
|
+
supplyVault: PublicKey;
|
|
137
|
+
padding1: BN[];
|
|
138
|
+
padding2: BN[];
|
|
139
|
+
}
|
|
140
|
+
interface ReserveConfig {
|
|
141
|
+
status: number;
|
|
142
|
+
assetTier: number;
|
|
143
|
+
hostFixedInterestRateBps: number;
|
|
144
|
+
reserved2: number[];
|
|
145
|
+
protocolOrderExecutionFeePct: number;
|
|
146
|
+
protocolTakeRatePct: number;
|
|
147
|
+
protocolLiquidationFeePct: number;
|
|
148
|
+
loanToValuePct: number;
|
|
149
|
+
liquidationThresholdPct: number;
|
|
150
|
+
minLiquidationBonusBps: number;
|
|
151
|
+
maxLiquidationBonusBps: number;
|
|
152
|
+
badDebtLiquidationBonusBps: number;
|
|
153
|
+
deleveragingMarginCallPeriodSecs: BN;
|
|
154
|
+
deleveragingThresholdDecreaseBpsPerDay: BN;
|
|
155
|
+
fees: ReserveFees;
|
|
156
|
+
borrowRateCurve: BorrowRateCurve;
|
|
157
|
+
borrowFactorPct: BN;
|
|
158
|
+
depositLimit: BN;
|
|
159
|
+
borrowLimit: BN;
|
|
160
|
+
tokenInfo: TokenInfo;
|
|
161
|
+
depositWithdrawalCap: WithdrawalCaps;
|
|
162
|
+
debtWithdrawalCap: WithdrawalCaps;
|
|
163
|
+
elevationGroups: number[];
|
|
164
|
+
disableUsageAsCollOutsideEmode: number;
|
|
165
|
+
utilizationLimitBlockBorrowingAbovePct: number;
|
|
166
|
+
autodeleverageEnabled: number;
|
|
167
|
+
reserved1: number[];
|
|
168
|
+
borrowLimitOutsideElevationGroup: BN;
|
|
169
|
+
borrowLimitAgainstThisCollateralInElevationGroup: BN[];
|
|
170
|
+
}
|
|
171
|
+
export declare class Reserve extends Decodable {
|
|
172
|
+
discriminator: number[];
|
|
173
|
+
version: BN;
|
|
174
|
+
lastUpdate: LastUpdate;
|
|
175
|
+
lendingMarket: PublicKey;
|
|
176
|
+
farmCollateral: PublicKey;
|
|
177
|
+
farmDebt: PublicKey;
|
|
178
|
+
liquidity: ReserveLiquidity;
|
|
179
|
+
reserveLiquidityPadding: BN[];
|
|
180
|
+
collateral: ReserveCollateral;
|
|
181
|
+
reserveCollateralPadding: BN[];
|
|
182
|
+
config: ReserveConfig;
|
|
183
|
+
configPadding: BN[];
|
|
184
|
+
borrowedAmountOutsideElevationGroup: BN;
|
|
185
|
+
borrowedAmountsAgainstThisReserveInElevationGroups: BN[];
|
|
186
|
+
padding: BN[];
|
|
187
|
+
static _layout: any;
|
|
188
|
+
get cumulativeBorrowRate(): Decimal;
|
|
189
|
+
/**
|
|
190
|
+
* @returns the stale exchange rate between the collateral tokens and the liquidity - this is a decimal number scaled by 1e18
|
|
191
|
+
*/
|
|
192
|
+
get collateralExchangeRate(): Decimal;
|
|
193
|
+
get totalSupply(): Decimal;
|
|
194
|
+
get borrowedAmount(): Decimal;
|
|
195
|
+
get accumulatedProtocolFees(): Decimal;
|
|
196
|
+
get accumulatedReferrerFees(): Decimal;
|
|
197
|
+
get pendingReferrerFees(): Decimal;
|
|
198
|
+
}
|
|
199
|
+
interface ObligationCollateral {
|
|
200
|
+
depositReserve: PublicKey;
|
|
201
|
+
depositedAmount: BN;
|
|
202
|
+
marketValueSf: BN;
|
|
203
|
+
borrowedAmountAgainstThisCollateralInElevationGroup: BN;
|
|
204
|
+
padding: BN[];
|
|
205
|
+
}
|
|
206
|
+
interface ObligationLiquidity {
|
|
207
|
+
borrowReserve: PublicKey;
|
|
208
|
+
cumulativeBorrowRateBsf: BigFractionBytes;
|
|
209
|
+
padding: BN;
|
|
210
|
+
borrowedAmountSf: BN;
|
|
211
|
+
marketValueSf: BN;
|
|
212
|
+
borrowFactorAdjustedMarketValueSf: BN;
|
|
213
|
+
borrowedAmountOutsideElevationGroups: BN;
|
|
214
|
+
padding2: BN[];
|
|
215
|
+
}
|
|
216
|
+
interface ObligationOrder {
|
|
217
|
+
conditionThresholdSf: BN;
|
|
218
|
+
opportunityParameterSf: BN;
|
|
219
|
+
minExecutionBonusBps: number;
|
|
220
|
+
maxExecutionBonusBps: number;
|
|
221
|
+
conditionType: number;
|
|
222
|
+
opportunityType: number;
|
|
223
|
+
padding1: number[];
|
|
224
|
+
padding2: BN[];
|
|
225
|
+
}
|
|
226
|
+
export declare class Obligation extends Decodable {
|
|
227
|
+
discriminator: number[];
|
|
228
|
+
tag: BN;
|
|
229
|
+
lastUpdate: LastUpdate;
|
|
230
|
+
lendingMarket: PublicKey;
|
|
231
|
+
owner: PublicKey;
|
|
232
|
+
deposits: ObligationCollateral[];
|
|
233
|
+
lowestReserveDepositLiquidationLtv: BN;
|
|
234
|
+
depositedValueSf: BN;
|
|
235
|
+
borrows: ObligationLiquidity[];
|
|
236
|
+
borrowFactorAdjustedDebtValueSf: BN;
|
|
237
|
+
borrowedAssetsMarketValueSf: BN;
|
|
238
|
+
allowedBorrowValueSf: BN;
|
|
239
|
+
unhealthyBorrowValueSf: BN;
|
|
240
|
+
depositsAssetTiers: number[];
|
|
241
|
+
borrowsAssetTiers: number[];
|
|
242
|
+
elevationGroup: number;
|
|
243
|
+
numOfObsoleteDepositReserves: number;
|
|
244
|
+
hasDebt: number;
|
|
245
|
+
referrer: PublicKey;
|
|
246
|
+
borrowingDisabled: number;
|
|
247
|
+
autodeleverageTargetLtvPct: number;
|
|
248
|
+
lowestReserveDepositMaxLtvPct: number;
|
|
249
|
+
numOfObsoleteBorrowReserves: number;
|
|
250
|
+
reserved: number[];
|
|
251
|
+
highestBorrowFactorPct: BN;
|
|
252
|
+
autodeleverageMarginCallStartedTimestamp: BN;
|
|
253
|
+
orders: ObligationOrder[];
|
|
254
|
+
padding3: BN[];
|
|
255
|
+
static _layout: any;
|
|
256
|
+
}
|
|
257
|
+
export {};
|
package/src/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./client";
|
|
|
5
5
|
export * from "./client/jupiter";
|
|
6
6
|
export * from "./client/drift";
|
|
7
7
|
export * from "./client/timelock";
|
|
8
|
+
export * from "./client/cctp";
|
|
8
9
|
export * from "./deser/integrationPolicies";
|
|
9
10
|
export * from "./client/base";
|
|
10
11
|
export * from "./assets";
|
package/src/models/mint.d.ts
CHANGED
|
@@ -56,3 +56,9 @@ export declare class RequestType {
|
|
|
56
56
|
redemption: {};
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
+
export type OracleConfigsType = IdlTypes<GlamProtocol>["oracleConfigs"];
|
|
60
|
+
export declare class OracleConfigs implements OracleConfigsType {
|
|
61
|
+
readonly maxAgesSeconds: number[][];
|
|
62
|
+
padding: number[];
|
|
63
|
+
constructor(maxAgesSeconds: number[][]);
|
|
64
|
+
}
|
package/src/models/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IdlTypes } from "@coral-xyz/anchor";
|
|
2
2
|
import { GlamMint } from "../glamExports";
|
|
3
|
-
import { PublicKey } from "@solana/web3.js";
|
|
4
3
|
export type RequestQueue = IdlTypes<GlamMint>["requestQueue"];
|
|
5
4
|
export type PendingRequest = IdlTypes<GlamMint>["pendingRequest"];
|
|
6
5
|
export declare class PriceDenom {
|
|
@@ -10,21 +9,6 @@ export declare class PriceDenom {
|
|
|
10
9
|
static readonly USD: {
|
|
11
10
|
usd: {};
|
|
12
11
|
};
|
|
13
|
-
static readonly ASSET: {
|
|
14
|
-
asset6: {};
|
|
15
|
-
};
|
|
16
|
-
static fromAsset(asset: PublicKey): {
|
|
17
|
-
sol: {};
|
|
18
|
-
} | {
|
|
19
|
-
usd: {};
|
|
20
|
-
} | {
|
|
21
|
-
asset6: {};
|
|
22
|
-
};
|
|
23
|
-
static fromString(str: string): {
|
|
24
|
-
sol: {};
|
|
25
|
-
} | {
|
|
26
|
-
usd: {};
|
|
27
|
-
};
|
|
28
12
|
}
|
|
29
13
|
export declare class TimeUnit {
|
|
30
14
|
static readonly Slot: {
|
package/src/utils/common.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BN } from "@coral-xyz/anchor";
|
|
1
2
|
/**
|
|
2
3
|
* Compares two sets for equality
|
|
3
4
|
*/
|
|
@@ -10,3 +11,4 @@ export declare function charsToName(chars: number[] | Buffer): string;
|
|
|
10
11
|
* Converts a string to an array of character codes (max 32 bytes)
|
|
11
12
|
*/
|
|
12
13
|
export declare function nameToChars(name: string): number[];
|
|
14
|
+
export declare function toUiAmount(amount: BN, decimals: number): number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BN } from "@coral-xyz/anchor";
|
|
2
|
+
import Decimal from "decimal.js";
|
|
3
|
+
export interface BigFractionBytes {
|
|
4
|
+
value: BN[];
|
|
5
|
+
padding: BN[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Replicates the Fraction class from the klend-sdk:
|
|
9
|
+
* https://github.com/Kamino-Finance/klend-sdk/blob/2fbc31a5b165aca3e2ca2e3d0e6162848743192d/src/classes/fraction.ts#L26
|
|
10
|
+
*/
|
|
11
|
+
export declare class Fraction {
|
|
12
|
+
static MAX_SIZE_F: number;
|
|
13
|
+
static MAX_SIZE_BF: number;
|
|
14
|
+
static FRACTIONS: number;
|
|
15
|
+
static MULTIPLIER: Decimal;
|
|
16
|
+
static MAX_F_BN: any;
|
|
17
|
+
static MAX_BF_BN: any;
|
|
18
|
+
static MIN_BN: any;
|
|
19
|
+
valueSf: BN;
|
|
20
|
+
constructor(valueSf: BN);
|
|
21
|
+
toDecimal(): Decimal;
|
|
22
|
+
getValue(): BN;
|
|
23
|
+
gt(x: Fraction): boolean;
|
|
24
|
+
lt(x: Fraction): boolean;
|
|
25
|
+
gte(x: Fraction): boolean;
|
|
26
|
+
lte(x: Fraction): boolean;
|
|
27
|
+
eq(x: Fraction): boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function bfToDecimal(x: BigFractionBytes): Decimal;
|
package/src/utils/index.d.ts
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* A Map implementation that uses PublicKey as keys.
|
|
4
|
+
*
|
|
5
|
+
* This class extends the standard Map and allows using PublicKey objects
|
|
6
|
+
* as keys by converting them to base58 strings internally. This solves the
|
|
7
|
+
* problem of PublicKey object reference equality - two PublicKey objects
|
|
8
|
+
* with the same address would normally be considered different keys in a Map.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Create empty map
|
|
13
|
+
* const map = new PkMap<string>();
|
|
14
|
+
* const key = new PublicKey("11111111111111111111111111111111");
|
|
15
|
+
* map.set(key, "value");
|
|
16
|
+
*
|
|
17
|
+
* // Create with initial entries
|
|
18
|
+
* const map2 = new PkMap<string>([
|
|
19
|
+
* [new PublicKey("11111111111111111111111111111111"), "value1"],
|
|
20
|
+
* [new PublicKey("22222222222222222222222222222222"), "value2"]
|
|
21
|
+
* ]);
|
|
22
|
+
*
|
|
23
|
+
* // Can retrieve with a different PublicKey object with same address
|
|
24
|
+
* const sameKey = new PublicKey("11111111111111111111111111111111");
|
|
25
|
+
* console.log(map.get(sameKey)); // "value"
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class PkMap<V> {
|
|
29
|
+
private readonly _map;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new PkMap instance.
|
|
32
|
+
* @param entries - Optional initial entries as [PublicKey, V] pairs
|
|
33
|
+
*/
|
|
34
|
+
constructor(entries?: readonly (readonly [PublicKey, V])[] | null);
|
|
35
|
+
/**
|
|
36
|
+
* Associates the specified value with the specified PublicKey in this map.
|
|
37
|
+
* @param key - The PublicKey to use as the key
|
|
38
|
+
* @param value - The value to associate with the key
|
|
39
|
+
* @returns This PkMap instance for chaining
|
|
40
|
+
*/
|
|
41
|
+
set(key: PublicKey, value: V): this;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the value associated with the specified PublicKey, or undefined if not found.
|
|
44
|
+
* @param key - The PublicKey whose associated value is to be returned
|
|
45
|
+
* @returns The value associated with the specified key, or undefined
|
|
46
|
+
*/
|
|
47
|
+
get(key: PublicKey): V | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Returns true if this map contains a mapping for the specified PublicKey.
|
|
50
|
+
* @param key - The PublicKey whose presence in this map is to be tested
|
|
51
|
+
* @returns true if this map contains a mapping for the specified key
|
|
52
|
+
*/
|
|
53
|
+
has(key: PublicKey): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Removes the mapping for the specified PublicKey from this map if present.
|
|
56
|
+
* @param key - The PublicKey whose mapping is to be removed
|
|
57
|
+
* @returns true if the element was removed, false otherwise
|
|
58
|
+
*/
|
|
59
|
+
delete(key: PublicKey): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Returns an iterator of all PublicKey keys in this map.
|
|
62
|
+
* Note: This reconstructs PublicKey objects from the stored base58 strings.
|
|
63
|
+
* @returns An iterator of PublicKey objects
|
|
64
|
+
*/
|
|
65
|
+
pkKeys(): IterableIterator<PublicKey>;
|
|
66
|
+
/**
|
|
67
|
+
* Returns an iterator of [PublicKey, value] pairs for every entry in the map.
|
|
68
|
+
* Note: This reconstructs PublicKey objects from the stored base58 strings.
|
|
69
|
+
* @returns An iterator of [PublicKey, V] tuples
|
|
70
|
+
*/
|
|
71
|
+
pkEntries(): IterableIterator<[PublicKey, V]>;
|
|
72
|
+
/**
|
|
73
|
+
* Executes a provided function once per each PublicKey/value pair in the Map.
|
|
74
|
+
* @param callbackfn - Function to execute for each entry
|
|
75
|
+
* @param thisArg - Value to use as this when executing callback
|
|
76
|
+
*/
|
|
77
|
+
forEachPk(callbackfn: (value: V, key: PublicKey, map: PkMap<V>) => void, thisArg?: any): void;
|
|
78
|
+
get size(): number;
|
|
79
|
+
clear(): void;
|
|
80
|
+
values(): IterableIterator<V>;
|
|
81
|
+
[Symbol.iterator](): IterableIterator<[PublicKey, V]>;
|
|
82
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* A Set implementation that uses PublicKey as values.
|
|
4
|
+
*
|
|
5
|
+
* This class extends the standard Set and allows using PublicKey objects
|
|
6
|
+
* as values by converting them to base58 strings internally. This solves the
|
|
7
|
+
* problem of PublicKey object reference equality - two PublicKey objects
|
|
8
|
+
* with the same address would normally be considered different values in a Set.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Create empty set
|
|
13
|
+
* const set = new PkSet();
|
|
14
|
+
* const key = new PublicKey("11111111111111111111111111111111");
|
|
15
|
+
* set.add(key);
|
|
16
|
+
*
|
|
17
|
+
* // Create with initial values
|
|
18
|
+
* const set2 = new PkSet([
|
|
19
|
+
* new PublicKey("11111111111111111111111111111111"),
|
|
20
|
+
* new PublicKey("22222222222222222222222222222222")
|
|
21
|
+
* ]);
|
|
22
|
+
*
|
|
23
|
+
* // Can check with a different PublicKey object with same address
|
|
24
|
+
* const sameKey = new PublicKey("11111111111111111111111111111111");
|
|
25
|
+
* console.log(set.has(sameKey)); // true
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class PkSet {
|
|
29
|
+
private readonly _set;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new PkSet instance.
|
|
32
|
+
* @param values - Optional initial values as PublicKey array
|
|
33
|
+
*/
|
|
34
|
+
constructor(values?: readonly PublicKey[] | null);
|
|
35
|
+
/**
|
|
36
|
+
* Adds the specified PublicKey to this set.
|
|
37
|
+
* @param value - The PublicKey to add to the set
|
|
38
|
+
* @returns This PkSet instance for chaining
|
|
39
|
+
*/
|
|
40
|
+
add(value: PublicKey): this;
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if this set contains the specified PublicKey.
|
|
43
|
+
* @param value - The PublicKey whose presence in this set is to be tested
|
|
44
|
+
* @returns true if this set contains the specified PublicKey
|
|
45
|
+
*/
|
|
46
|
+
has(value: PublicKey): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Removes the specified PublicKey from this set if present.
|
|
49
|
+
* @param value - The PublicKey to be removed
|
|
50
|
+
* @returns true if the element was removed, false otherwise
|
|
51
|
+
*/
|
|
52
|
+
delete(value: PublicKey): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Returns an iterator of all PublicKey values in this set.
|
|
55
|
+
* Note: This reconstructs PublicKey objects from the stored base58 strings.
|
|
56
|
+
* @returns An iterator of PublicKey objects
|
|
57
|
+
*/
|
|
58
|
+
pkValues(): IterableIterator<PublicKey>;
|
|
59
|
+
/**
|
|
60
|
+
* Executes a provided function once per each PublicKey in the Set.
|
|
61
|
+
* @param callbackfn - Function to execute for each value
|
|
62
|
+
* @param thisArg - Value to use as this when executing callback
|
|
63
|
+
*/
|
|
64
|
+
forEachPk(callbackfn: (value: PublicKey, value2: PublicKey, set: PkSet) => void, thisArg?: any): void;
|
|
65
|
+
get size(): number;
|
|
66
|
+
clear(): void;
|
|
67
|
+
[Symbol.iterator](): IterableIterator<PublicKey>;
|
|
68
|
+
equals(other: PkSet): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* @returns true if this set contains all the PublicKeys in the other set
|
|
71
|
+
*/
|
|
72
|
+
includes(other: PkSet): boolean;
|
|
73
|
+
}
|