@hawksightco/hawk-sdk 1.3.265 → 1.3.266
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/dist/addresses.d.ts +37 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +84 -0
- package/dist/anchor.d.ts +22 -0
- package/dist/anchor.d.ts.map +1 -0
- package/dist/anchor.js +121 -0
- package/dist/classes/AltStorage.d.ts +29 -0
- package/dist/classes/AltStorage.d.ts.map +1 -0
- package/dist/classes/AltStorage.js +58 -0
- package/dist/classes/Atomicity.d.ts +34 -0
- package/dist/classes/Atomicity.d.ts.map +1 -0
- package/dist/classes/Atomicity.js +110 -0
- package/dist/classes/Client.d.ts +35 -0
- package/dist/classes/Client.d.ts.map +1 -0
- package/dist/classes/Client.js +66 -0
- package/dist/classes/CombineTransactions.d.ts +11 -0
- package/dist/classes/CombineTransactions.d.ts.map +1 -0
- package/dist/classes/CombineTransactions.js +58 -0
- package/dist/classes/CreateTxMetadata.d.ts +100 -0
- package/dist/classes/CreateTxMetadata.d.ts.map +1 -0
- package/dist/classes/CreateTxMetadata.js +415 -0
- package/dist/classes/General.d.ts +87 -0
- package/dist/classes/General.d.ts.map +1 -0
- package/dist/classes/General.js +176 -0
- package/dist/classes/GeneralUtility.d.ts +79 -0
- package/dist/classes/GeneralUtility.d.ts.map +1 -0
- package/dist/classes/GeneralUtility.js +121 -0
- package/dist/classes/HawkAPI.d.ts +122 -0
- package/dist/classes/HawkAPI.d.ts.map +1 -0
- package/dist/classes/HawkAPI.js +169 -0
- package/dist/classes/Health.d.ts +29 -0
- package/dist/classes/Health.d.ts.map +1 -0
- package/dist/classes/Health.js +48 -0
- package/dist/classes/JupiterAlts.d.ts +37 -0
- package/dist/classes/JupiterAlts.d.ts.map +1 -0
- package/dist/classes/JupiterAlts.js +114 -0
- package/dist/classes/JupiterSwap.d.ts +21 -0
- package/dist/classes/JupiterSwap.d.ts.map +1 -0
- package/dist/classes/JupiterSwap.js +40 -0
- package/dist/classes/Logging.d.ts +13 -0
- package/dist/classes/Logging.d.ts.map +1 -0
- package/dist/classes/Logging.js +50 -0
- package/dist/classes/MultiTransaction.d.ts +75 -0
- package/dist/classes/MultiTransaction.d.ts.map +1 -0
- package/dist/classes/MultiTransaction.js +296 -0
- package/dist/classes/RaydiumSDK.d.ts +67 -0
- package/dist/classes/RaydiumSDK.d.ts.map +1 -0
- package/dist/classes/RaydiumSDK.js +206 -0
- package/dist/classes/Search.d.ts +100 -0
- package/dist/classes/Search.d.ts.map +1 -0
- package/dist/classes/Search.js +216 -0
- package/dist/classes/SimpleIxGenerator.d.ts +57 -0
- package/dist/classes/SimpleIxGenerator.d.ts.map +1 -0
- package/dist/classes/SimpleIxGenerator.js +62 -0
- package/dist/classes/SimplePdaGenerator.d.ts +28 -0
- package/dist/classes/SimplePdaGenerator.d.ts.map +1 -0
- package/dist/classes/SimplePdaGenerator.js +33 -0
- package/dist/classes/Transaction.d.ts +229 -0
- package/dist/classes/Transaction.d.ts.map +1 -0
- package/dist/classes/Transaction.js +643 -0
- package/dist/classes/Transaction2.d.ts +107 -0
- package/dist/classes/Transaction2.d.ts.map +1 -0
- package/dist/classes/Transaction2.js +249 -0
- package/dist/classes/Transaction3.d.ts +165 -0
- package/dist/classes/Transaction3.d.ts.map +1 -0
- package/dist/classes/Transaction3.js +416 -0
- package/dist/classes/TransactionBatchExecute.d.ts +163 -0
- package/dist/classes/TransactionBatchExecute.d.ts.map +1 -0
- package/dist/classes/TransactionBatchExecute.js +466 -0
- package/dist/classes/TransactionBatchExecute2.d.ts +99 -0
- package/dist/classes/TransactionBatchExecute2.d.ts.map +1 -0
- package/dist/classes/TransactionBatchExecute2.js +357 -0
- package/dist/classes/Transactions.d.ts +586 -0
- package/dist/classes/Transactions.d.ts.map +1 -0
- package/dist/classes/Transactions.js +7667 -0
- package/dist/classes/TxGenerator.d.ts +350 -0
- package/dist/classes/TxGenerator.d.ts.map +1 -0
- package/dist/classes/TxGenerator.js +1957 -0
- package/dist/classes/TxGeneratorAutomations.d.ts +186 -0
- package/dist/classes/TxGeneratorAutomations.d.ts.map +1 -0
- package/dist/classes/TxGeneratorAutomations.js +897 -0
- package/dist/classes/Util.d.ts +87 -0
- package/dist/classes/Util.d.ts.map +1 -0
- package/dist/classes/Util.js +148 -0
- package/dist/classes/account-cache/AccountCache.d.ts +54 -0
- package/dist/classes/account-cache/AccountCache.d.ts.map +1 -0
- package/dist/classes/account-cache/AccountCache.js +143 -0
- package/dist/classes/account-cache/MintCache.d.ts +33 -0
- package/dist/classes/account-cache/MintCache.d.ts.map +1 -0
- package/dist/classes/account-cache/MintCache.js +47 -0
- package/dist/classes/account-cache/TokenCache.d.ts +33 -0
- package/dist/classes/account-cache/TokenCache.d.ts.map +1 -0
- package/dist/classes/account-cache/TokenCache.js +47 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +96 -0
- package/dist/functions.d.ts +514 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js +1636 -0
- package/dist/hawksight.d.ts +53 -0
- package/dist/hawksight.d.ts.map +1 -0
- package/dist/hawksight.js +328 -0
- package/dist/hsToMeteora.d.ts +31 -0
- package/dist/hsToMeteora.d.ts.map +1 -0
- package/dist/hsToMeteora.js +3175 -0
- package/dist/idl/iyf-extension-idl.d.ts +14583 -0
- package/dist/idl/iyf-extension-idl.d.ts.map +1 -0
- package/dist/idl/iyf-extension-idl.js +14578 -0
- package/dist/idl/iyf-extension-wrapper.d.ts +112 -0
- package/dist/idl/iyf-extension-wrapper.d.ts.map +1 -0
- package/dist/idl/iyf-extension-wrapper.js +2 -0
- package/dist/idl/iyf-main-idl.d.ts +12078 -0
- package/dist/idl/iyf-main-idl.d.ts.map +1 -0
- package/dist/idl/iyf-main-idl.js +12073 -0
- package/dist/idl/iyf-main-wrapper.d.ts +112 -0
- package/dist/idl/iyf-main-wrapper.d.ts.map +1 -0
- package/dist/idl/iyf-main-wrapper.js +2 -0
- package/dist/idl/jupiter-idl.d.ts +3063 -0
- package/dist/idl/jupiter-idl.d.ts.map +1 -0
- package/dist/idl/jupiter-idl.js +3061 -0
- package/dist/idl/meteora-idl.d.ts +7371 -0
- package/dist/idl/meteora-idl.d.ts.map +1 -0
- package/dist/idl/meteora-idl.js +7372 -0
- package/dist/idl/orca-idl.d.ts +3833 -0
- package/dist/idl/orca-idl.d.ts.map +1 -0
- package/dist/idl/orca-idl.js +3834 -0
- package/dist/idl/raydium-idl.d.ts +3054 -0
- package/dist/idl/raydium-idl.d.ts.map +1 -0
- package/dist/idl/raydium-idl.js +3055 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/ixGenerator/IyfExtensionIxGenerator.d.ts +126 -0
- package/dist/ixGenerator/IyfExtensionIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/IyfExtensionIxGenerator.js +467 -0
- package/dist/ixGenerator/IyfMainIxGenerator.d.ts +330 -0
- package/dist/ixGenerator/IyfMainIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/IyfMainIxGenerator.js +1239 -0
- package/dist/ixGenerator/MeteoraDlmmIxGenerator.d.ts +685 -0
- package/dist/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/MeteoraDlmmIxGenerator.js +3005 -0
- package/dist/ixGenerator/OrcaIxGenerator.d.ts +119 -0
- package/dist/ixGenerator/OrcaIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/OrcaIxGenerator.js +438 -0
- package/dist/ixGenerator/RaydiumIxGenerator.d.ts +99 -0
- package/dist/ixGenerator/RaydiumIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/RaydiumIxGenerator.js +558 -0
- package/dist/ixGenerator/UtilIxGenerator.d.ts +20 -0
- package/dist/ixGenerator/UtilIxGenerator.d.ts.map +1 -0
- package/dist/ixGenerator/UtilIxGenerator.js +25 -0
- package/dist/meteora/index.d.ts +2 -0
- package/dist/meteora/index.d.ts.map +1 -0
- package/dist/meteora/index.js +17 -0
- package/dist/meteora/liquidityStrategy.d.ts +408 -0
- package/dist/meteora/liquidityStrategy.d.ts.map +1 -0
- package/dist/meteora/liquidityStrategy.js +1325 -0
- package/dist/meteora.d.ts +669 -0
- package/dist/meteora.d.ts.map +1 -0
- package/dist/meteora.js +1932 -0
- package/dist/orca.d.ts +57 -0
- package/dist/orca.d.ts.map +1 -0
- package/dist/orca.js +123 -0
- package/dist/pdaGenerator/HawksightPdaGenerator.d.ts +29 -0
- package/dist/pdaGenerator/HawksightPdaGenerator.d.ts.map +1 -0
- package/dist/pdaGenerator/HawksightPdaGenerator.js +75 -0
- package/dist/pdaGenerator/MeteoraPdaGenerator.d.ts +76 -0
- package/dist/pdaGenerator/MeteoraPdaGenerator.d.ts.map +1 -0
- package/dist/pdaGenerator/MeteoraPdaGenerator.js +166 -0
- package/dist/pdaGenerator/OrcaPdaGenerator.d.ts +23 -0
- package/dist/pdaGenerator/OrcaPdaGenerator.d.ts.map +1 -0
- package/dist/pdaGenerator/OrcaPdaGenerator.js +68 -0
- package/dist/pdaGenerator/RaydiumPdaGenerator.d.ts +49 -0
- package/dist/pdaGenerator/RaydiumPdaGenerator.d.ts.map +1 -0
- package/dist/pdaGenerator/RaydiumPdaGenerator.js +114 -0
- package/dist/pdaGenerator/UtilPdaGenerator.d.ts +8 -0
- package/dist/pdaGenerator/UtilPdaGenerator.d.ts.map +1 -0
- package/dist/pdaGenerator/UtilPdaGenerator.js +51 -0
- package/dist/types.d.ts +1104 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +95 -0
- package/package.json +6 -5
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as client from "@hawksightco/swagger-client";
|
|
2
|
+
import { MeteoraDlmmActiveBin, ResponseWithStatus, UserPortfolioOut } from "../types";
|
|
3
|
+
import { Client } from "./Client";
|
|
4
|
+
/**
|
|
5
|
+
* Provides utility functions for interacting with the Meteora DLMM and Orca CLMM subsystems of the HawkSight API.
|
|
6
|
+
* This class enables fetching and manipulating data related to pools, positions, and other transaction-related information.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Util {
|
|
9
|
+
private readonly client;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes a new instance of the Util class.
|
|
12
|
+
*
|
|
13
|
+
* @param client The Client object through which API calls will be made.
|
|
14
|
+
*/
|
|
15
|
+
constructor(client: Client);
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves a list of pools managed by Meteora DLMM.
|
|
18
|
+
*
|
|
19
|
+
* @returns A Promise resolving to a response object containing the status and array of pool information.
|
|
20
|
+
*/
|
|
21
|
+
meteoraDlmmPools(): Promise<ResponseWithStatus<client.InlineResponse2003[]>>;
|
|
22
|
+
/**
|
|
23
|
+
* Fetches positions held in Meteora DLMM pools, optionally filtered by a specific pool.
|
|
24
|
+
*
|
|
25
|
+
* @param params An object containing wallet address and an optional pool identifier.
|
|
26
|
+
* @returns A Promise resolving to a response object with the status and data of positions.
|
|
27
|
+
*/
|
|
28
|
+
meteoraDlmmPositions(params: {
|
|
29
|
+
wallet: string;
|
|
30
|
+
pool?: string;
|
|
31
|
+
}): Promise<ResponseWithStatus<UserPortfolioOut>>;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves the active bin data for a specific set of parameters in Meteora DLMM.
|
|
34
|
+
*
|
|
35
|
+
* @param params The parameters required to define the active bin query.
|
|
36
|
+
* @returns A Promise resolving to a response with the status and data of the active bin.
|
|
37
|
+
*/
|
|
38
|
+
meteoraDlmmActiveBin(params: client.UtilActiveBinBody): Promise<ResponseWithStatus<MeteoraDlmmActiveBin>>;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves a list of pools managed by Orca CLMM.
|
|
41
|
+
*
|
|
42
|
+
* @returns A Promise resolving to a response object containing the status and array of pool information.
|
|
43
|
+
*/
|
|
44
|
+
orcaClmmPools(): Promise<ResponseWithStatus<any>>;
|
|
45
|
+
/**
|
|
46
|
+
* Fetches positions held in Orca CLMM pools, optionally filtered by a specific pool.
|
|
47
|
+
*
|
|
48
|
+
* @param params An object containing wallet address and an optional pool identifier.
|
|
49
|
+
* @returns A Promise resolving to a response object with the status and data of positions.
|
|
50
|
+
*/
|
|
51
|
+
orcaPositions(params: {
|
|
52
|
+
wallet: string;
|
|
53
|
+
pool?: string;
|
|
54
|
+
}): Promise<ResponseWithStatus<any>>;
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves the mint information of a specific position managed by Orca CLMM.
|
|
57
|
+
*
|
|
58
|
+
* @param params An object containing the identifier of the position.
|
|
59
|
+
* @returns A Promise resolving to a response object with the status and mint details of the position.
|
|
60
|
+
*/
|
|
61
|
+
orcaGetPositionMint(params: {
|
|
62
|
+
position: string;
|
|
63
|
+
}): Promise<ResponseWithStatus<any>>;
|
|
64
|
+
/**
|
|
65
|
+
* Get single orca pool from hawksight api
|
|
66
|
+
*
|
|
67
|
+
* @param params Whirlpool address.
|
|
68
|
+
* @returns A Promise resolving to a response object with the status and mint details of the position.
|
|
69
|
+
*/
|
|
70
|
+
orcaGetPosition(params: {
|
|
71
|
+
pool: string;
|
|
72
|
+
}): Promise<ResponseWithStatus<any>>;
|
|
73
|
+
/**
|
|
74
|
+
* Returns orca tick current index of given whirlpool(s)
|
|
75
|
+
*
|
|
76
|
+
* @param params
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
orcaGetActiveTick(params: {
|
|
80
|
+
pools: string[];
|
|
81
|
+
commitment?: string;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
status: any;
|
|
84
|
+
data: any;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=Util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../src/classes/Util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAiB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;GAGG;AACH,qBAAa,IAAI;IAOb,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB;;;;OAIG;gBAEgB,MAAM,EAAE,MAAM;IAGjC;;;;OAIG;IACG,gBAAgB,IAAI,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAQlF;;;;;OAKG;IACG,oBAAoB,CACxB,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GACA,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IAQhD;;;;;OAKG;IACG,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;IAQ/G;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAQvD;;;;;OAKG;IACG,aAAa,CACjB,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GACA,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAQnC;;;;;OAKG;IACG,mBAAmB,CACvB,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;KAClB,GACA,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAQnC;;;;;OAKG;IACG,eAAe,CACnB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;KACd,GACA,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAQnC;;;;;OAKG;IACG,iBAAiB,CACrB,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB;;;;CAWJ"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Util = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Provides utility functions for interacting with the Meteora DLMM and Orca CLMM subsystems of the HawkSight API.
|
|
15
|
+
* This class enables fetching and manipulating data related to pools, positions, and other transaction-related information.
|
|
16
|
+
*/
|
|
17
|
+
class Util {
|
|
18
|
+
/**
|
|
19
|
+
* Initializes a new instance of the Util class.
|
|
20
|
+
*
|
|
21
|
+
* @param client The Client object through which API calls will be made.
|
|
22
|
+
*/
|
|
23
|
+
constructor(client) {
|
|
24
|
+
this.client = client;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves a list of pools managed by Meteora DLMM.
|
|
28
|
+
*
|
|
29
|
+
* @returns A Promise resolving to a response object containing the status and array of pool information.
|
|
30
|
+
*/
|
|
31
|
+
meteoraDlmmPools() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const result = yield this.client.meteoraDLMMUtilityFunctionsApi.meteoraDlmmUtilPoolsGet().catch(e => e.response);
|
|
34
|
+
return {
|
|
35
|
+
status: result.status,
|
|
36
|
+
data: result.data,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fetches positions held in Meteora DLMM pools, optionally filtered by a specific pool.
|
|
42
|
+
*
|
|
43
|
+
* @param params An object containing wallet address and an optional pool identifier.
|
|
44
|
+
* @returns A Promise resolving to a response object with the status and data of positions.
|
|
45
|
+
*/
|
|
46
|
+
meteoraDlmmPositions(params) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const result = yield this.client.meteoraDLMMUtilityFunctionsApi.meteoraDlmmUtilPositionsGet(params.wallet, params.pool).catch(e => e.response);
|
|
49
|
+
return {
|
|
50
|
+
status: result.status,
|
|
51
|
+
data: result.data,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves the active bin data for a specific set of parameters in Meteora DLMM.
|
|
57
|
+
*
|
|
58
|
+
* @param params The parameters required to define the active bin query.
|
|
59
|
+
* @returns A Promise resolving to a response with the status and data of the active bin.
|
|
60
|
+
*/
|
|
61
|
+
meteoraDlmmActiveBin(params) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const result = yield this.client.meteoraDLMMUtilityFunctionsApi.meteoraDlmmUtilActiveBinPost(params).catch(e => e.response);
|
|
64
|
+
return {
|
|
65
|
+
status: result.status,
|
|
66
|
+
data: result.data,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves a list of pools managed by Orca CLMM.
|
|
72
|
+
*
|
|
73
|
+
* @returns A Promise resolving to a response object containing the status and array of pool information.
|
|
74
|
+
*/
|
|
75
|
+
orcaClmmPools() {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const result = yield this.client.orcaUtilityFunctionsApi.orcaUtilPoolsGet().catch(e => e.response);
|
|
78
|
+
return {
|
|
79
|
+
status: result.status,
|
|
80
|
+
data: result.data,
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Fetches positions held in Orca CLMM pools, optionally filtered by a specific pool.
|
|
86
|
+
*
|
|
87
|
+
* @param params An object containing wallet address and an optional pool identifier.
|
|
88
|
+
* @returns A Promise resolving to a response object with the status and data of positions.
|
|
89
|
+
*/
|
|
90
|
+
orcaPositions(params) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const result = yield this.client.orcaUtilityFunctionsApi.orcaUtilPositionsGet(params.wallet, params.pool).catch(e => e.response);
|
|
93
|
+
return {
|
|
94
|
+
status: result.status,
|
|
95
|
+
data: result.data,
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Retrieves the mint information of a specific position managed by Orca CLMM.
|
|
101
|
+
*
|
|
102
|
+
* @param params An object containing the identifier of the position.
|
|
103
|
+
* @returns A Promise resolving to a response object with the status and mint details of the position.
|
|
104
|
+
*/
|
|
105
|
+
orcaGetPositionMint(params) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const result = yield this.client.orcaUtilityFunctionsApi.orcaUtilGetPositionMintGet(params.position).catch(e => e.response);
|
|
108
|
+
return {
|
|
109
|
+
status: result.status,
|
|
110
|
+
data: result.data,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get single orca pool from hawksight api
|
|
116
|
+
*
|
|
117
|
+
* @param params Whirlpool address.
|
|
118
|
+
* @returns A Promise resolving to a response object with the status and mint details of the position.
|
|
119
|
+
*/
|
|
120
|
+
orcaGetPosition(params) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const result = yield this.client.generalEndpoints.poolGet(params.pool, "orca");
|
|
123
|
+
return {
|
|
124
|
+
status: result.status,
|
|
125
|
+
data: result.data,
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Returns orca tick current index of given whirlpool(s)
|
|
131
|
+
*
|
|
132
|
+
* @param params
|
|
133
|
+
* @returns
|
|
134
|
+
*/
|
|
135
|
+
orcaGetActiveTick(params) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
const result = yield this.client.orcaUtilityFunctionsApi.orcaUtilActiveTickPost({
|
|
138
|
+
pools: params.pools,
|
|
139
|
+
commitment: params.commitment,
|
|
140
|
+
}).catch(e => e.response);
|
|
141
|
+
return {
|
|
142
|
+
status: result.status,
|
|
143
|
+
data: result.data,
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.Util = Util;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as web3 from "@solana/web3.js";
|
|
2
|
+
type AccountInfoInternal = {
|
|
3
|
+
refetch: boolean;
|
|
4
|
+
info: web3.AccountInfo<Buffer>;
|
|
5
|
+
};
|
|
6
|
+
type _AccountCache = Record<string, AccountInfoInternal>;
|
|
7
|
+
export declare abstract class AccountCache {
|
|
8
|
+
protected connection: web3.Connection;
|
|
9
|
+
/**
|
|
10
|
+
* Cache of accounts.
|
|
11
|
+
*/
|
|
12
|
+
protected static accounts: _AccountCache;
|
|
13
|
+
/**
|
|
14
|
+
* Promise that resolves when the accounts are fetched.
|
|
15
|
+
* This is used to wait for the accounts to be fetched before using them.
|
|
16
|
+
*/
|
|
17
|
+
protected pending: Promise<void> | null;
|
|
18
|
+
/**
|
|
19
|
+
* Instantiate the AccountCache class
|
|
20
|
+
*
|
|
21
|
+
* @param connection - The connection to the blockchain.
|
|
22
|
+
*/
|
|
23
|
+
constructor(connection: web3.Connection);
|
|
24
|
+
/**
|
|
25
|
+
* Criteria of accounts to be fetched must be only owned by the given programs
|
|
26
|
+
*/
|
|
27
|
+
protected abstract mustOwnedByEitherPrograms(): web3.PublicKey[];
|
|
28
|
+
/**
|
|
29
|
+
* Whether the account query should require the account to exist.
|
|
30
|
+
*/
|
|
31
|
+
protected abstract requireToExist(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Get account info from cache
|
|
34
|
+
*
|
|
35
|
+
* @param key
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
static get(key: web3.PublicKey): AccountInfoInternal | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Mark accounts to be refetched
|
|
41
|
+
*/
|
|
42
|
+
refetch(pubkeys: web3.PublicKey[]): this;
|
|
43
|
+
/**
|
|
44
|
+
* The goal of this function is to batch 100 accounts at a time as it is the max number of accounts that can be fetched at once.
|
|
45
|
+
* Skips accounts that are already fetched.
|
|
46
|
+
*
|
|
47
|
+
* @param pubkeys - The accounts to fetch.
|
|
48
|
+
* @returns - A promise that resolves to an array of TokenAccountInfo objects.
|
|
49
|
+
*/
|
|
50
|
+
getBatchedMultipleAccountsInfo(pubkeys: web3.PublicKey[], commitment?: web3.Commitment): this;
|
|
51
|
+
waitForResult(): Promise<_AccountCache>;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=AccountCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountCache.d.ts","sourceRoot":"","sources":["../../../src/classes/account-cache/AccountCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;CAChC,CAAA;AAED,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAEzD,8BAAsB,YAAY;IAmB9B,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU;IAjBvC;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAM;IAE9C;;;OAGG;IACH,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAQ;IAE/C;;;;OAIG;gBAES,UAAU,EAAE,IAAI,CAAC,UAAU;IAGvC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,yBAAyB,IAAI,IAAI,CAAC,SAAS,EAAE;IAEhE;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,OAAO;IAE5C;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,GAAG,mBAAmB,GAAG,SAAS;IAIhE;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI;IASxC;;;;;;OAMG;IACH,8BAA8B,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,UAAU,GAAE,IAAI,CAAC,UAAwB,GAAG,IAAI;IA2CpG,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;CAM9C"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.AccountCache = void 0;
|
|
46
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
47
|
+
class AccountCache {
|
|
48
|
+
/**
|
|
49
|
+
* Instantiate the AccountCache class
|
|
50
|
+
*
|
|
51
|
+
* @param connection - The connection to the blockchain.
|
|
52
|
+
*/
|
|
53
|
+
constructor(connection) {
|
|
54
|
+
this.connection = connection;
|
|
55
|
+
/**
|
|
56
|
+
* Promise that resolves when the accounts are fetched.
|
|
57
|
+
* This is used to wait for the accounts to be fetched before using them.
|
|
58
|
+
*/
|
|
59
|
+
this.pending = null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get account info from cache
|
|
63
|
+
*
|
|
64
|
+
* @param key
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
static get(key) {
|
|
68
|
+
return AccountCache.accounts[key.toString()];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Mark accounts to be refetched
|
|
72
|
+
*/
|
|
73
|
+
refetch(pubkeys) {
|
|
74
|
+
for (const pubkey of pubkeys) {
|
|
75
|
+
if (!!AccountCache.accounts[pubkey.toString()]) {
|
|
76
|
+
AccountCache.accounts[pubkey.toString()].refetch = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The goal of this function is to batch 100 accounts at a time as it is the max number of accounts that can be fetched at once.
|
|
83
|
+
* Skips accounts that are already fetched.
|
|
84
|
+
*
|
|
85
|
+
* @param pubkeys - The accounts to fetch.
|
|
86
|
+
* @returns - A promise that resolves to an array of TokenAccountInfo objects.
|
|
87
|
+
*/
|
|
88
|
+
getBatchedMultipleAccountsInfo(pubkeys, commitment = "confirmed") {
|
|
89
|
+
// Check first if account is already fetched. Skips accounts that are marked to be refetched.
|
|
90
|
+
const pubkeysToFetch = pubkeys.filter(pubkey => {
|
|
91
|
+
const cache = AccountCache.accounts[pubkey.toString()];
|
|
92
|
+
if (cache) {
|
|
93
|
+
return cache.refetch;
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
});
|
|
97
|
+
const batchSize = 100;
|
|
98
|
+
const batches = [];
|
|
99
|
+
for (let i = 0; i < pubkeysToFetch.length; i += batchSize) {
|
|
100
|
+
batches.push(pubkeysToFetch.slice(i, i + batchSize));
|
|
101
|
+
}
|
|
102
|
+
const pending = Promise.all(batches.map(batch => this.connection.getMultipleAccountsInfo(batch, commitment))).then(batch => {
|
|
103
|
+
const result = batch.flat();
|
|
104
|
+
for (let i = 0; i < result.length; i++) {
|
|
105
|
+
const pubkey = pubkeysToFetch[i];
|
|
106
|
+
const info = result[i];
|
|
107
|
+
if (info !== null) {
|
|
108
|
+
// Throw error if account fetching requires program ownership
|
|
109
|
+
const mustBeOwnedByEither = this.mustOwnedByEitherPrograms();
|
|
110
|
+
const requiredToExist = this.requireToExist();
|
|
111
|
+
const doesNotExist = info.owner.equals(web3.SystemProgram.programId) && info.data.length === 0;
|
|
112
|
+
if (doesNotExist && !requiredToExist) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
else if (mustBeOwnedByEither.length > 0 && !mustBeOwnedByEither.some(program => info.owner.equals(program))) {
|
|
116
|
+
throw new Error(`Account ${pubkey.toString()} is not owned by any of the programs ${mustBeOwnedByEither.map(program => program.toString()).join(", ")}`);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
AccountCache.accounts[pubkey.toString()] = { refetch: false, info };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else if (this.requireToExist()) {
|
|
123
|
+
throw new Error(`Account ${pubkey.toString()} does not exist`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
this.pending = pending;
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
waitForResult() {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
if (this.pending) {
|
|
133
|
+
yield this.pending;
|
|
134
|
+
}
|
|
135
|
+
return AccountCache.accounts;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.AccountCache = AccountCache;
|
|
140
|
+
/**
|
|
141
|
+
* Cache of accounts.
|
|
142
|
+
*/
|
|
143
|
+
AccountCache.accounts = {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as web3 from "@solana/web3.js";
|
|
2
|
+
import { AccountCache } from "./AccountCache";
|
|
3
|
+
/**
|
|
4
|
+
* Singleton instance of AccountCache for mint accounts.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MintCache extends AccountCache {
|
|
7
|
+
/**
|
|
8
|
+
* Singleton instance of MintCache
|
|
9
|
+
*/
|
|
10
|
+
private static _instance;
|
|
11
|
+
/**
|
|
12
|
+
* Instantiate the MintCache class
|
|
13
|
+
*
|
|
14
|
+
* @param connection The Solana connection
|
|
15
|
+
*/
|
|
16
|
+
private constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Get the singleton instance of MintCache
|
|
19
|
+
*
|
|
20
|
+
* @param connection The Solana connection
|
|
21
|
+
* @returns The MintCache instance
|
|
22
|
+
*/
|
|
23
|
+
static instance(connection: web3.Connection): MintCache;
|
|
24
|
+
/**
|
|
25
|
+
* Criteria of accounts to be fetched must be only owned by the given programs
|
|
26
|
+
*/
|
|
27
|
+
protected mustOwnedByEitherPrograms(): web3.PublicKey[];
|
|
28
|
+
/**
|
|
29
|
+
* Whether the account query should require the account to exist.
|
|
30
|
+
*/
|
|
31
|
+
protected requireToExist(): boolean;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=MintCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MintCache.d.ts","sourceRoot":"","sources":["../../../src/classes/account-cache/MintCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;GAEG;AACH,qBAAa,SAAU,SAAQ,YAAY;IAEzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS,CAA0B;IAElD;;;;OAIG;IACH,OAAO;IAIP;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,GAAG,SAAS;IAOvD;;OAEG;IACH,SAAS,CAAC,yBAAyB,IAAI,IAAI,CAAC,SAAS,EAAE;IAIvD;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,OAAO;CAGpC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MintCache = void 0;
|
|
4
|
+
const AccountCache_1 = require("./AccountCache");
|
|
5
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
6
|
+
/**
|
|
7
|
+
* Singleton instance of AccountCache for mint accounts.
|
|
8
|
+
*/
|
|
9
|
+
class MintCache extends AccountCache_1.AccountCache {
|
|
10
|
+
/**
|
|
11
|
+
* Instantiate the MintCache class
|
|
12
|
+
*
|
|
13
|
+
* @param connection The Solana connection
|
|
14
|
+
*/
|
|
15
|
+
constructor(connection) {
|
|
16
|
+
super(connection);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get the singleton instance of MintCache
|
|
20
|
+
*
|
|
21
|
+
* @param connection The Solana connection
|
|
22
|
+
* @returns The MintCache instance
|
|
23
|
+
*/
|
|
24
|
+
static instance(connection) {
|
|
25
|
+
if (!MintCache._instance) {
|
|
26
|
+
MintCache._instance = new MintCache(connection);
|
|
27
|
+
}
|
|
28
|
+
return MintCache._instance;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Criteria of accounts to be fetched must be only owned by the given programs
|
|
32
|
+
*/
|
|
33
|
+
mustOwnedByEitherPrograms() {
|
|
34
|
+
return [spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.TOKEN_2022_PROGRAM_ID];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether the account query should require the account to exist.
|
|
38
|
+
*/
|
|
39
|
+
requireToExist() {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.MintCache = MintCache;
|
|
44
|
+
/**
|
|
45
|
+
* Singleton instance of MintCache
|
|
46
|
+
*/
|
|
47
|
+
MintCache._instance = null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as web3 from "@solana/web3.js";
|
|
2
|
+
import { AccountCache } from "./AccountCache";
|
|
3
|
+
/**
|
|
4
|
+
* Singleton instance of AccountCache for mint accounts.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TokenCache extends AccountCache {
|
|
7
|
+
/**
|
|
8
|
+
* Singleton instance of TokenCache
|
|
9
|
+
*/
|
|
10
|
+
private static _instance;
|
|
11
|
+
/**
|
|
12
|
+
* Instantiate the TokenCache class
|
|
13
|
+
*
|
|
14
|
+
* @param connection The Solana connection
|
|
15
|
+
*/
|
|
16
|
+
private constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Get the singleton instance of TokenCache
|
|
19
|
+
*
|
|
20
|
+
* @param connection The Solana connection
|
|
21
|
+
* @returns The TokenCache instance
|
|
22
|
+
*/
|
|
23
|
+
static instance(connection: web3.Connection): TokenCache;
|
|
24
|
+
/**
|
|
25
|
+
* Criteria of accounts to be fetched must be only owned by the given programs
|
|
26
|
+
*/
|
|
27
|
+
protected mustOwnedByEitherPrograms(): web3.PublicKey[];
|
|
28
|
+
/**
|
|
29
|
+
* Whether the account query should require the account to exist.
|
|
30
|
+
*/
|
|
31
|
+
protected requireToExist(): boolean;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=TokenCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenCache.d.ts","sourceRoot":"","sources":["../../../src/classes/account-cache/TokenCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;GAEG;AACH,qBAAa,UAAW,SAAQ,YAAY;IAE1C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS,CAA2B;IAEnD;;;;OAIG;IACH,OAAO;IAIP;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,GAAG,UAAU;IAOxD;;OAEG;IACH,SAAS,CAAC,yBAAyB,IAAI,IAAI,CAAC,SAAS,EAAE;IAIvD;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,OAAO;CAGpC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenCache = void 0;
|
|
4
|
+
const AccountCache_1 = require("./AccountCache");
|
|
5
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
6
|
+
/**
|
|
7
|
+
* Singleton instance of AccountCache for mint accounts.
|
|
8
|
+
*/
|
|
9
|
+
class TokenCache extends AccountCache_1.AccountCache {
|
|
10
|
+
/**
|
|
11
|
+
* Instantiate the TokenCache class
|
|
12
|
+
*
|
|
13
|
+
* @param connection The Solana connection
|
|
14
|
+
*/
|
|
15
|
+
constructor(connection) {
|
|
16
|
+
super(connection);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get the singleton instance of TokenCache
|
|
20
|
+
*
|
|
21
|
+
* @param connection The Solana connection
|
|
22
|
+
* @returns The TokenCache instance
|
|
23
|
+
*/
|
|
24
|
+
static instance(connection) {
|
|
25
|
+
if (!TokenCache._instance) {
|
|
26
|
+
TokenCache._instance = new TokenCache(connection);
|
|
27
|
+
}
|
|
28
|
+
return TokenCache._instance;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Criteria of accounts to be fetched must be only owned by the given programs
|
|
32
|
+
*/
|
|
33
|
+
mustOwnedByEitherPrograms() {
|
|
34
|
+
return [spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.TOKEN_2022_PROGRAM_ID];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether the account query should require the account to exist.
|
|
38
|
+
*/
|
|
39
|
+
requireToExist() {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.TokenCache = TokenCache;
|
|
44
|
+
/**
|
|
45
|
+
* Singleton instance of TokenCache
|
|
46
|
+
*/
|
|
47
|
+
TokenCache._instance = null;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class AppError extends Error {
|
|
2
|
+
readonly isErrorHandled: boolean;
|
|
3
|
+
readonly stackTrace: string[];
|
|
4
|
+
readonly errorMsg: string;
|
|
5
|
+
constructor(message: string, _module: string, stackTrace?: string);
|
|
6
|
+
static handleErrorAsync<T>(fn: () => Promise<T>): Promise<T>;
|
|
7
|
+
static handleErrorSync<T>(fn: () => T): T;
|
|
8
|
+
}
|
|
9
|
+
export declare class UniversalErrorHandler {
|
|
10
|
+
static catchErrorsAsync<T>(moduleName: string, fn: () => Promise<T>): Promise<T>;
|
|
11
|
+
static catchErrorsSync<T>(moduleName: string, fn: () => T): T;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,qBAAa,QAAS,SAAQ,KAAK;IAEjC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAQ;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;WAgCpD,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IASlE,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;CAQ1C;AAGD,qBAAa,qBAAqB;WACnB,gBAAgB,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAatF,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;CAY9D"}
|