@zofai/zo-sdk 0.1.92
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/.claude/settings.local.json +9 -0
- package/.gitattributes +4 -0
- package/.prettierrc.js +9 -0
- package/README.md +28 -0
- package/dist/abstract/BaseAPI.cjs +206 -0
- package/dist/abstract/BaseAPI.cjs.map +1 -0
- package/dist/abstract/BaseAPI.d.cts +172 -0
- package/dist/abstract/BaseAPI.d.cts.map +1 -0
- package/dist/abstract/BaseAPI.d.mts +172 -0
- package/dist/abstract/BaseAPI.d.mts.map +1 -0
- package/dist/abstract/BaseAPI.mjs +202 -0
- package/dist/abstract/BaseAPI.mjs.map +1 -0
- package/dist/abstract/BaseDataAPI.cjs +140 -0
- package/dist/abstract/BaseDataAPI.cjs.map +1 -0
- package/dist/abstract/BaseDataAPI.d.cts +89 -0
- package/dist/abstract/BaseDataAPI.d.cts.map +1 -0
- package/dist/abstract/BaseDataAPI.d.mts +89 -0
- package/dist/abstract/BaseDataAPI.d.mts.map +1 -0
- package/dist/abstract/BaseDataAPI.mjs +136 -0
- package/dist/abstract/BaseDataAPI.mjs.map +1 -0
- package/dist/abstract/index.cjs +12 -0
- package/dist/abstract/index.cjs.map +1 -0
- package/dist/abstract/index.d.cts +7 -0
- package/dist/abstract/index.d.cts.map +1 -0
- package/dist/abstract/index.d.mts +7 -0
- package/dist/abstract/index.d.mts.map +1 -0
- package/dist/abstract/index.mjs +7 -0
- package/dist/abstract/index.mjs.map +1 -0
- package/dist/api.cjs +779 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +75 -0
- package/dist/api.d.cts.map +1 -0
- package/dist/api.d.mts +75 -0
- package/dist/api.d.mts.map +1 -0
- package/dist/api.mjs +775 -0
- package/dist/api.mjs.map +1 -0
- package/dist/bcs.cjs +42 -0
- package/dist/bcs.cjs.map +1 -0
- package/dist/bcs.d.cts +91 -0
- package/dist/bcs.d.cts.map +1 -0
- package/dist/bcs.d.mts +91 -0
- package/dist/bcs.d.mts.map +1 -0
- package/dist/bcs.mjs +39 -0
- package/dist/bcs.mjs.map +1 -0
- package/dist/consts/deployments-shared-mainnet.json +50 -0
- package/dist/consts/deployments-shared-testnet.json +45 -0
- package/dist/consts/deployments-slp-mainnet.json +600 -0
- package/dist/consts/deployments-slp-testnet.json +87 -0
- package/dist/consts/deployments-usdz-mainnet.json +494 -0
- package/dist/consts/deployments-usdz-testnet.json +98 -0
- package/dist/consts/deployments-zbtcvc-mainnet.json +180 -0
- package/dist/consts/deployments-zlp-mainnet.json +791 -0
- package/dist/consts/deployments-zlp-testnet.json +76 -0
- package/dist/consts/index.cjs +200 -0
- package/dist/consts/index.cjs.map +1 -0
- package/dist/consts/index.d.cts +157 -0
- package/dist/consts/index.d.cts.map +1 -0
- package/dist/consts/index.d.mts +157 -0
- package/dist/consts/index.d.mts.map +1 -0
- package/dist/consts/index.mjs +189 -0
- package/dist/consts/index.mjs.map +1 -0
- package/dist/consts/price_id_to_object_id.mainnet.json +56 -0
- package/dist/consts/price_id_to_object_id.testnet.json +17 -0
- package/dist/data.cjs +919 -0
- package/dist/data.cjs.map +1 -0
- package/dist/data.d.cts +235 -0
- package/dist/data.d.cts.map +1 -0
- package/dist/data.d.mts +235 -0
- package/dist/data.d.mts.map +1 -0
- package/dist/data.mjs +915 -0
- package/dist/data.mjs.map +1 -0
- package/dist/factory/SDKFactory.cjs +228 -0
- package/dist/factory/SDKFactory.cjs.map +1 -0
- package/dist/factory/SDKFactory.d.cts +84 -0
- package/dist/factory/SDKFactory.d.cts.map +1 -0
- package/dist/factory/SDKFactory.d.mts +84 -0
- package/dist/factory/SDKFactory.d.mts.map +1 -0
- package/dist/factory/SDKFactory.mjs +222 -0
- package/dist/factory/SDKFactory.mjs.map +1 -0
- package/dist/implementations/SLPAPI.cjs +1794 -0
- package/dist/implementations/SLPAPI.cjs.map +1 -0
- package/dist/implementations/SLPAPI.d.cts +183 -0
- package/dist/implementations/SLPAPI.d.cts.map +1 -0
- package/dist/implementations/SLPAPI.d.mts +183 -0
- package/dist/implementations/SLPAPI.d.mts.map +1 -0
- package/dist/implementations/SLPAPI.mjs +1790 -0
- package/dist/implementations/SLPAPI.mjs.map +1 -0
- package/dist/implementations/SLPDataAPI.cjs +1384 -0
- package/dist/implementations/SLPDataAPI.cjs.map +1 -0
- package/dist/implementations/SLPDataAPI.d.cts +158 -0
- package/dist/implementations/SLPDataAPI.d.cts.map +1 -0
- package/dist/implementations/SLPDataAPI.d.mts +158 -0
- package/dist/implementations/SLPDataAPI.d.mts.map +1 -0
- package/dist/implementations/SLPDataAPI.mjs +1380 -0
- package/dist/implementations/SLPDataAPI.mjs.map +1 -0
- package/dist/implementations/USDZAPI.cjs +1676 -0
- package/dist/implementations/USDZAPI.cjs.map +1 -0
- package/dist/implementations/USDZAPI.d.cts +180 -0
- package/dist/implementations/USDZAPI.d.cts.map +1 -0
- package/dist/implementations/USDZAPI.d.mts +180 -0
- package/dist/implementations/USDZAPI.d.mts.map +1 -0
- package/dist/implementations/USDZAPI.mjs +1672 -0
- package/dist/implementations/USDZAPI.mjs.map +1 -0
- package/dist/implementations/USDZDataAPI.cjs +1209 -0
- package/dist/implementations/USDZDataAPI.cjs.map +1 -0
- package/dist/implementations/USDZDataAPI.d.cts +191 -0
- package/dist/implementations/USDZDataAPI.d.cts.map +1 -0
- package/dist/implementations/USDZDataAPI.d.mts +191 -0
- package/dist/implementations/USDZDataAPI.d.mts.map +1 -0
- package/dist/implementations/USDZDataAPI.mjs +1205 -0
- package/dist/implementations/USDZDataAPI.mjs.map +1 -0
- package/dist/implementations/ZBTCVCAPI.cjs +906 -0
- package/dist/implementations/ZBTCVCAPI.cjs.map +1 -0
- package/dist/implementations/ZBTCVCAPI.d.cts +107 -0
- package/dist/implementations/ZBTCVCAPI.d.cts.map +1 -0
- package/dist/implementations/ZBTCVCAPI.d.mts +107 -0
- package/dist/implementations/ZBTCVCAPI.d.mts.map +1 -0
- package/dist/implementations/ZBTCVCAPI.mjs +902 -0
- package/dist/implementations/ZBTCVCAPI.mjs.map +1 -0
- package/dist/implementations/ZBTCVCDataAPI.cjs +829 -0
- package/dist/implementations/ZBTCVCDataAPI.cjs.map +1 -0
- package/dist/implementations/ZBTCVCDataAPI.d.cts +94 -0
- package/dist/implementations/ZBTCVCDataAPI.d.cts.map +1 -0
- package/dist/implementations/ZBTCVCDataAPI.d.mts +94 -0
- package/dist/implementations/ZBTCVCDataAPI.d.mts.map +1 -0
- package/dist/implementations/ZBTCVCDataAPI.mjs +825 -0
- package/dist/implementations/ZBTCVCDataAPI.mjs.map +1 -0
- package/dist/implementations/ZLPAPI.cjs +1948 -0
- package/dist/implementations/ZLPAPI.cjs.map +1 -0
- package/dist/implementations/ZLPAPI.d.cts +192 -0
- package/dist/implementations/ZLPAPI.d.cts.map +1 -0
- package/dist/implementations/ZLPAPI.d.mts +192 -0
- package/dist/implementations/ZLPAPI.d.mts.map +1 -0
- package/dist/implementations/ZLPAPI.mjs +1944 -0
- package/dist/implementations/ZLPAPI.mjs.map +1 -0
- package/dist/implementations/ZLPDataAPI.cjs +1267 -0
- package/dist/implementations/ZLPDataAPI.cjs.map +1 -0
- package/dist/implementations/ZLPDataAPI.d.cts +193 -0
- package/dist/implementations/ZLPDataAPI.d.cts.map +1 -0
- package/dist/implementations/ZLPDataAPI.d.mts +193 -0
- package/dist/implementations/ZLPDataAPI.d.mts.map +1 -0
- package/dist/implementations/ZLPDataAPI.mjs +1263 -0
- package/dist/implementations/ZLPDataAPI.mjs.map +1 -0
- package/dist/implementations/index.cjs +26 -0
- package/dist/implementations/index.cjs.map +1 -0
- package/dist/implementations/index.d.cts +13 -0
- package/dist/implementations/index.d.cts.map +1 -0
- package/dist/implementations/index.d.mts +13 -0
- package/dist/implementations/index.d.mts.map +1 -0
- package/dist/implementations/index.mjs +15 -0
- package/dist/implementations/index.mjs.map +1 -0
- package/dist/index.cjs +69 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +51 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +51 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +51 -0
- package/dist/index.mjs.map +1 -0
- package/dist/interfaces/base.cjs +7 -0
- package/dist/interfaces/base.cjs.map +1 -0
- package/dist/interfaces/base.d.cts +346 -0
- package/dist/interfaces/base.d.cts.map +1 -0
- package/dist/interfaces/base.d.mts +346 -0
- package/dist/interfaces/base.d.mts.map +1 -0
- package/dist/interfaces/base.mjs +6 -0
- package/dist/interfaces/base.mjs.map +1 -0
- package/dist/interfaces/index.cjs +31 -0
- package/dist/interfaces/index.cjs.map +1 -0
- package/dist/interfaces/index.d.cts +15 -0
- package/dist/interfaces/index.d.cts.map +1 -0
- package/dist/interfaces/index.d.mts +15 -0
- package/dist/interfaces/index.d.mts.map +1 -0
- package/dist/interfaces/index.mjs +15 -0
- package/dist/interfaces/index.mjs.map +1 -0
- package/dist/interfaces/slp.cjs +7 -0
- package/dist/interfaces/slp.cjs.map +1 -0
- package/dist/interfaces/slp.d.cts +179 -0
- package/dist/interfaces/slp.d.cts.map +1 -0
- package/dist/interfaces/slp.d.mts +179 -0
- package/dist/interfaces/slp.d.mts.map +1 -0
- package/dist/interfaces/slp.mjs +6 -0
- package/dist/interfaces/slp.mjs.map +1 -0
- package/dist/interfaces/usdz.cjs +7 -0
- package/dist/interfaces/usdz.cjs.map +1 -0
- package/dist/interfaces/usdz.d.cts +104 -0
- package/dist/interfaces/usdz.d.cts.map +1 -0
- package/dist/interfaces/usdz.d.mts +104 -0
- package/dist/interfaces/usdz.d.mts.map +1 -0
- package/dist/interfaces/usdz.mjs +6 -0
- package/dist/interfaces/usdz.mjs.map +1 -0
- package/dist/interfaces/zbtcvc.cjs +7 -0
- package/dist/interfaces/zbtcvc.cjs.map +1 -0
- package/dist/interfaces/zbtcvc.d.cts +64 -0
- package/dist/interfaces/zbtcvc.d.cts.map +1 -0
- package/dist/interfaces/zbtcvc.d.mts +64 -0
- package/dist/interfaces/zbtcvc.d.mts.map +1 -0
- package/dist/interfaces/zbtcvc.mjs +6 -0
- package/dist/interfaces/zbtcvc.mjs.map +1 -0
- package/dist/interfaces/zlp.cjs +7 -0
- package/dist/interfaces/zlp.cjs.map +1 -0
- package/dist/interfaces/zlp.d.cts +114 -0
- package/dist/interfaces/zlp.d.cts.map +1 -0
- package/dist/interfaces/zlp.d.mts +114 -0
- package/dist/interfaces/zlp.d.mts.map +1 -0
- package/dist/interfaces/zlp.mjs +6 -0
- package/dist/interfaces/zlp.mjs.map +1 -0
- package/dist/oracle.cjs +118 -0
- package/dist/oracle.cjs.map +1 -0
- package/dist/oracle.d.cts +25 -0
- package/dist/oracle.d.cts.map +1 -0
- package/dist/oracle.d.mts +25 -0
- package/dist/oracle.d.mts.map +1 -0
- package/dist/oracle.mjs +114 -0
- package/dist/oracle.mjs.map +1 -0
- package/dist/utils.cjs +129 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +44 -0
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +44 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +115 -0
- package/dist/utils.mjs.map +1 -0
- package/docs/SUMMARY.md +10 -0
- package/docs/api-reference.md +32 -0
- package/docs/architecture.md +14 -0
- package/docs/common-operations.md +52 -0
- package/docs/error-handling.md +17 -0
- package/docs/getting-started.md +60 -0
- package/docs/introduction.md +15 -0
- package/docs/lp-specific-features.md +96 -0
- package/docs/type-safety.md +29 -0
- package/eslint.config.mjs +18 -0
- package/package.json +42 -0
- package/src/abstract/BaseAPI.ts +575 -0
- package/src/abstract/BaseDataAPI.ts +207 -0
- package/src/abstract/index.ts +7 -0
- package/src/api.ts +1100 -0
- package/src/bcs.ts +45 -0
- package/src/consts/deployments-shared-mainnet.json +50 -0
- package/src/consts/deployments-shared-testnet.json +45 -0
- package/src/consts/deployments-slp-mainnet.json +600 -0
- package/src/consts/deployments-slp-testnet.json +87 -0
- package/src/consts/deployments-usdz-mainnet.json +494 -0
- package/src/consts/deployments-usdz-testnet.json +98 -0
- package/src/consts/deployments-zbtcvc-mainnet.json +180 -0
- package/src/consts/deployments-zlp-mainnet.json +791 -0
- package/src/consts/deployments-zlp-testnet.json +76 -0
- package/src/consts/index.ts +345 -0
- package/src/consts/price_id_to_object_id.mainnet.json +56 -0
- package/src/consts/price_id_to_object_id.testnet.json +17 -0
- package/src/data.ts +1279 -0
- package/src/factory/SDKFactory.ts +340 -0
- package/src/implementations/SLPAPI.ts +2722 -0
- package/src/implementations/SLPDataAPI.ts +1839 -0
- package/src/implementations/USDZAPI.ts +2488 -0
- package/src/implementations/USDZDataAPI.ts +1548 -0
- package/src/implementations/ZBTCVCAPI.ts +1337 -0
- package/src/implementations/ZBTCVCDataAPI.ts +993 -0
- package/src/implementations/ZLPAPI.ts +2888 -0
- package/src/implementations/ZLPDataAPI.ts +1603 -0
- package/src/implementations/index.ts +16 -0
- package/src/index.ts +58 -0
- package/src/interfaces/base.ts +838 -0
- package/src/interfaces/index.ts +50 -0
- package/src/interfaces/slp.ts +268 -0
- package/src/interfaces/usdz.ts +181 -0
- package/src/interfaces/zbtcvc.ts +116 -0
- package/src/interfaces/zlp.ts +244 -0
- package/src/oracle.ts +153 -0
- package/src/utils.ts +168 -0
- package/tests/api.test.ts +219 -0
- package/tests/data.test.ts +156 -0
- package/tests/oracle.test.ts +33 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/* eslint-disable unicorn/empty-brace-spaces */
|
|
2
|
+
/**
|
|
3
|
+
* SDK Factory for creating appropriate SDK instances based on LP token type
|
|
4
|
+
* This is the main entry point for the re-architected SDK system
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { SuiClient } from '@mysten/sui/client'
|
|
8
|
+
|
|
9
|
+
import type { LPToken, Network } from '../consts'
|
|
10
|
+
import { LPToken as LPTokenEnum } from '../consts'
|
|
11
|
+
// Import concrete implementations
|
|
12
|
+
import {
|
|
13
|
+
SLPAPI,
|
|
14
|
+
SLPDataAPI,
|
|
15
|
+
USDZAPI,
|
|
16
|
+
USDZDataAPI,
|
|
17
|
+
ZLPAPI,
|
|
18
|
+
ZLPDataAPI,
|
|
19
|
+
} from '../implementations'
|
|
20
|
+
import { ZBTCVCAPI } from '../implementations/ZBTCVCAPI'
|
|
21
|
+
import { ZBTCVCDataAPI } from '../implementations/ZBTCVCDataAPI'
|
|
22
|
+
import type {
|
|
23
|
+
IBaseAPI,
|
|
24
|
+
IBaseDataAPI,
|
|
25
|
+
ISDKFactory,
|
|
26
|
+
ISLPAPI,
|
|
27
|
+
ISLPDataAPI,
|
|
28
|
+
IUSDZAPI,
|
|
29
|
+
IUSDZDataAPI,
|
|
30
|
+
IZBTCVCAPI,
|
|
31
|
+
IZBTCVCDataAPI,
|
|
32
|
+
IZLPAPI,
|
|
33
|
+
IZLPDataAPI,
|
|
34
|
+
} from '../interfaces'
|
|
35
|
+
|
|
36
|
+
export class SDKFactory implements ISDKFactory {
|
|
37
|
+
private static instance: SDKFactory
|
|
38
|
+
|
|
39
|
+
// Singleton instances for DataAPI
|
|
40
|
+
private zlpDataAPIInstance: IZLPDataAPI | null = null
|
|
41
|
+
private slpDataAPIInstance: ISLPDataAPI | null = null
|
|
42
|
+
private usdzDataAPIInstance: IUSDZDataAPI | null = null
|
|
43
|
+
private zbtcvcDataAPIInstance: IZBTCVCDataAPI | null = null
|
|
44
|
+
|
|
45
|
+
// Singleton instances for API
|
|
46
|
+
private zlpAPIInstance: IZLPAPI | null = null
|
|
47
|
+
private slpAPIInstance: ISLPAPI | null = null
|
|
48
|
+
private usdzAPIInstance: IUSDZAPI | null = null
|
|
49
|
+
private zbtcvcAPIInstance: IZBTCVCAPI | null = null
|
|
50
|
+
|
|
51
|
+
private constructor() { }
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Gets the singleton instance of the SDK factory
|
|
55
|
+
*/
|
|
56
|
+
public static getInstance(): SDKFactory {
|
|
57
|
+
if (!SDKFactory.instance) {
|
|
58
|
+
SDKFactory.instance = new SDKFactory()
|
|
59
|
+
}
|
|
60
|
+
return SDKFactory.instance
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Creates a DataAPI instance based on the LP token type (returns singleton)
|
|
65
|
+
*/
|
|
66
|
+
public createDataAPI(
|
|
67
|
+
network: Network,
|
|
68
|
+
provider: SuiClient,
|
|
69
|
+
apiEndpoint: string,
|
|
70
|
+
connectionURL: string,
|
|
71
|
+
lpToken: LPToken,
|
|
72
|
+
): IBaseDataAPI {
|
|
73
|
+
switch (lpToken) {
|
|
74
|
+
case LPTokenEnum.ZLP: {
|
|
75
|
+
if (!this.zlpDataAPIInstance) {
|
|
76
|
+
this.zlpDataAPIInstance = new ZLPDataAPI(network, provider, apiEndpoint, connectionURL)
|
|
77
|
+
}
|
|
78
|
+
return this.zlpDataAPIInstance
|
|
79
|
+
}
|
|
80
|
+
case LPTokenEnum.SLP: {
|
|
81
|
+
if (!this.slpDataAPIInstance) {
|
|
82
|
+
this.slpDataAPIInstance = new SLPDataAPI(network, provider, apiEndpoint, connectionURL)
|
|
83
|
+
}
|
|
84
|
+
return this.slpDataAPIInstance
|
|
85
|
+
}
|
|
86
|
+
case LPTokenEnum.USDZ: {
|
|
87
|
+
if (!this.usdzDataAPIInstance) {
|
|
88
|
+
this.usdzDataAPIInstance = new USDZDataAPI(network, provider, apiEndpoint, connectionURL)
|
|
89
|
+
}
|
|
90
|
+
return this.usdzDataAPIInstance
|
|
91
|
+
}
|
|
92
|
+
case LPTokenEnum.ZBTCVC: {
|
|
93
|
+
if (!this.zbtcvcDataAPIInstance) {
|
|
94
|
+
this.zbtcvcDataAPIInstance = new ZBTCVCDataAPI(network, provider, apiEndpoint, connectionURL)
|
|
95
|
+
}
|
|
96
|
+
return this.zbtcvcDataAPIInstance
|
|
97
|
+
}
|
|
98
|
+
default: {
|
|
99
|
+
throw new Error(`Unsupported LP token type: ${lpToken}`)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Creates an API instance based on the LP token type (returns singleton)
|
|
106
|
+
*/
|
|
107
|
+
public createAPI(
|
|
108
|
+
network: Network,
|
|
109
|
+
provider: SuiClient,
|
|
110
|
+
apiEndpoint: string,
|
|
111
|
+
connectionURL: string,
|
|
112
|
+
lpToken: LPToken,
|
|
113
|
+
): IBaseAPI {
|
|
114
|
+
switch (lpToken) {
|
|
115
|
+
case LPTokenEnum.ZLP: {
|
|
116
|
+
if (!this.zlpAPIInstance) {
|
|
117
|
+
this.zlpAPIInstance = new ZLPAPI(network, provider, apiEndpoint, connectionURL)
|
|
118
|
+
}
|
|
119
|
+
return this.zlpAPIInstance
|
|
120
|
+
}
|
|
121
|
+
case LPTokenEnum.SLP: {
|
|
122
|
+
if (!this.slpAPIInstance) {
|
|
123
|
+
this.slpAPIInstance = new SLPAPI(network, provider, apiEndpoint, connectionURL)
|
|
124
|
+
}
|
|
125
|
+
return this.slpAPIInstance
|
|
126
|
+
}
|
|
127
|
+
case LPTokenEnum.USDZ: {
|
|
128
|
+
if (!this.usdzAPIInstance) {
|
|
129
|
+
this.usdzAPIInstance = new USDZAPI(network, provider, apiEndpoint, connectionURL)
|
|
130
|
+
}
|
|
131
|
+
return this.usdzAPIInstance
|
|
132
|
+
}
|
|
133
|
+
case LPTokenEnum.ZBTCVC: {
|
|
134
|
+
if (!this.zbtcvcAPIInstance) {
|
|
135
|
+
this.zbtcvcAPIInstance = new ZBTCVCAPI(network, provider, apiEndpoint, connectionURL)
|
|
136
|
+
}
|
|
137
|
+
return this.zbtcvcAPIInstance
|
|
138
|
+
}
|
|
139
|
+
default: {
|
|
140
|
+
throw new Error(`Unsupported LP token type: ${lpToken}`)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Creates a typed DataAPI instance for ZLP (returns singleton)
|
|
147
|
+
*/
|
|
148
|
+
public createZLPDataAPI(
|
|
149
|
+
network: Network,
|
|
150
|
+
provider: SuiClient,
|
|
151
|
+
apiEndpoint: string,
|
|
152
|
+
connectionURL: string,
|
|
153
|
+
): IZLPDataAPI {
|
|
154
|
+
if (!this.zlpDataAPIInstance) {
|
|
155
|
+
this.zlpDataAPIInstance = new ZLPDataAPI(network, provider, apiEndpoint, connectionURL)
|
|
156
|
+
}
|
|
157
|
+
return this.zlpDataAPIInstance
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Creates a typed API instance for ZLP (returns singleton)
|
|
162
|
+
*/
|
|
163
|
+
public createZLPAPI(
|
|
164
|
+
network: Network,
|
|
165
|
+
provider: SuiClient,
|
|
166
|
+
apiEndpoint: string,
|
|
167
|
+
connectionURL: string,
|
|
168
|
+
): IZLPAPI {
|
|
169
|
+
if (!this.zlpAPIInstance) {
|
|
170
|
+
this.zlpAPIInstance = new ZLPAPI(network, provider, apiEndpoint, connectionURL)
|
|
171
|
+
}
|
|
172
|
+
return this.zlpAPIInstance
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Creates a typed DataAPI instance for SLP (returns singleton)
|
|
177
|
+
*/
|
|
178
|
+
public createSLPDataAPI(
|
|
179
|
+
network: Network,
|
|
180
|
+
provider: SuiClient,
|
|
181
|
+
apiEndpoint: string,
|
|
182
|
+
connectionURL: string,
|
|
183
|
+
): ISLPDataAPI {
|
|
184
|
+
if (!this.slpDataAPIInstance) {
|
|
185
|
+
this.slpDataAPIInstance = new SLPDataAPI(network, provider, apiEndpoint, connectionURL)
|
|
186
|
+
}
|
|
187
|
+
return this.slpDataAPIInstance
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Creates a typed API instance for SLP (returns singleton)
|
|
192
|
+
*/
|
|
193
|
+
public createSLPAPI(
|
|
194
|
+
network: Network,
|
|
195
|
+
provider: SuiClient,
|
|
196
|
+
apiEndpoint: string,
|
|
197
|
+
connectionURL: string,
|
|
198
|
+
): ISLPAPI {
|
|
199
|
+
if (!this.slpAPIInstance) {
|
|
200
|
+
this.slpAPIInstance = new SLPAPI(network, provider, apiEndpoint, connectionURL)
|
|
201
|
+
}
|
|
202
|
+
return this.slpAPIInstance
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Creates a typed DataAPI instance for USDZ (returns singleton)
|
|
207
|
+
*/
|
|
208
|
+
public createUSDZDataAPI(
|
|
209
|
+
network: Network,
|
|
210
|
+
provider: SuiClient,
|
|
211
|
+
apiEndpoint: string,
|
|
212
|
+
connectionURL: string,
|
|
213
|
+
): IUSDZDataAPI {
|
|
214
|
+
if (!this.usdzDataAPIInstance) {
|
|
215
|
+
this.usdzDataAPIInstance = new USDZDataAPI(network, provider, apiEndpoint, connectionURL)
|
|
216
|
+
}
|
|
217
|
+
return this.usdzDataAPIInstance
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Creates a typed API instance for USDZ (returns singleton)
|
|
222
|
+
*/
|
|
223
|
+
public createUSDZAPI(
|
|
224
|
+
network: Network,
|
|
225
|
+
provider: SuiClient,
|
|
226
|
+
apiEndpoint: string,
|
|
227
|
+
connectionURL: string,
|
|
228
|
+
): IUSDZAPI {
|
|
229
|
+
if (!this.usdzAPIInstance) {
|
|
230
|
+
this.usdzAPIInstance = new USDZAPI(network, provider, apiEndpoint, connectionURL)
|
|
231
|
+
}
|
|
232
|
+
return this.usdzAPIInstance
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Creates a typed DataAPI instance for USDZ (returns singleton)
|
|
237
|
+
*/
|
|
238
|
+
public createZBTCVCDataAPI(
|
|
239
|
+
network: Network,
|
|
240
|
+
provider: SuiClient,
|
|
241
|
+
apiEndpoint: string,
|
|
242
|
+
connectionURL: string,
|
|
243
|
+
): IZBTCVCDataAPI {
|
|
244
|
+
if (!this.zbtcvcDataAPIInstance) {
|
|
245
|
+
this.zbtcvcDataAPIInstance = new ZBTCVCDataAPI(network, provider, apiEndpoint, connectionURL)
|
|
246
|
+
}
|
|
247
|
+
return this.zbtcvcDataAPIInstance
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Creates a typed API instance for USDZ (returns singleton)
|
|
252
|
+
*/
|
|
253
|
+
public createZBTCVCAPI(
|
|
254
|
+
network: Network,
|
|
255
|
+
provider: SuiClient,
|
|
256
|
+
apiEndpoint: string,
|
|
257
|
+
connectionURL: string,
|
|
258
|
+
): IZBTCVCAPI {
|
|
259
|
+
if (!this.zbtcvcAPIInstance) {
|
|
260
|
+
this.zbtcvcAPIInstance = new ZBTCVCAPI(network, provider, apiEndpoint, connectionURL)
|
|
261
|
+
}
|
|
262
|
+
return this.zbtcvcAPIInstance
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Validates if a given LP token is supported
|
|
267
|
+
*/
|
|
268
|
+
public static isLPTokenSupported(lpToken: string): lpToken is LPToken {
|
|
269
|
+
return Object.values(LPTokenEnum).includes(lpToken as LPToken)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Gets all supported LP token types
|
|
274
|
+
*/
|
|
275
|
+
public static getSupportedLPTokens(): LPToken[] {
|
|
276
|
+
return Object.values(LPTokenEnum)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Clears all singleton instances (useful for testing or configuration changes)
|
|
281
|
+
*/
|
|
282
|
+
public clearInstances(): void {
|
|
283
|
+
this.zlpDataAPIInstance = null
|
|
284
|
+
this.slpDataAPIInstance = null
|
|
285
|
+
this.usdzDataAPIInstance = null
|
|
286
|
+
this.zbtcvcAPIInstance = null
|
|
287
|
+
this.zlpAPIInstance = null
|
|
288
|
+
this.slpAPIInstance = null
|
|
289
|
+
this.usdzAPIInstance = null
|
|
290
|
+
this.zbtcvcAPIInstance = null
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Creates the appropriate SDK instance based on string LP token type
|
|
295
|
+
* Useful for dynamic SDK creation from configuration
|
|
296
|
+
*/
|
|
297
|
+
public createSDKFromString(
|
|
298
|
+
lpTokenString: string,
|
|
299
|
+
network: Network,
|
|
300
|
+
provider: SuiClient,
|
|
301
|
+
apiEndpoint: string,
|
|
302
|
+
connectionURL: string,
|
|
303
|
+
includeTrading = true,
|
|
304
|
+
): IBaseDataAPI | IBaseAPI {
|
|
305
|
+
if (!SDKFactory.isLPTokenSupported(lpTokenString)) {
|
|
306
|
+
throw new Error(`Unsupported LP token: ${lpTokenString}`)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const lpToken = lpTokenString as LPToken
|
|
310
|
+
|
|
311
|
+
if (includeTrading) {
|
|
312
|
+
return this.createAPI(network, provider, apiEndpoint, connectionURL, lpToken)
|
|
313
|
+
}
|
|
314
|
+
return this.createDataAPI(network, provider, apiEndpoint, connectionURL, lpToken)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Export convenience functions for backward compatibility
|
|
319
|
+
export function createDataAPI(
|
|
320
|
+
network: Network,
|
|
321
|
+
provider: SuiClient,
|
|
322
|
+
apiEndpoint: string,
|
|
323
|
+
connectionURL: string,
|
|
324
|
+
lpToken: LPToken,
|
|
325
|
+
): IBaseDataAPI {
|
|
326
|
+
return SDKFactory.getInstance().createDataAPI(network, provider, apiEndpoint, connectionURL, lpToken)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export function createAPI(
|
|
330
|
+
network: Network,
|
|
331
|
+
provider: SuiClient,
|
|
332
|
+
apiEndpoint: string,
|
|
333
|
+
connectionURL: string,
|
|
334
|
+
lpToken: LPToken,
|
|
335
|
+
): IBaseAPI {
|
|
336
|
+
return SDKFactory.getInstance().createAPI(network, provider, apiEndpoint, connectionURL, lpToken)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Export the singleton instance for direct use
|
|
340
|
+
export const sdkFactory = SDKFactory.getInstance()
|