@flashnet/sdk 0.3.7 → 0.3.10
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/cjs/index.d.ts +2 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/api/typed-endpoints.d.ts.map +1 -1
- package/dist/cjs/src/api/typed-endpoints.js.map +1 -1
- package/dist/cjs/src/client/FlashnetClient.d.ts +61 -12
- package/dist/cjs/src/client/FlashnetClient.d.ts.map +1 -1
- package/dist/cjs/src/client/FlashnetClient.js +156 -63
- package/dist/cjs/src/client/FlashnetClient.js.map +1 -1
- package/dist/cjs/src/config/index.d.ts +2 -13
- package/dist/cjs/src/config/index.d.ts.map +1 -1
- package/dist/cjs/src/config/index.js +17 -30
- package/dist/cjs/src/config/index.js.map +1 -1
- package/dist/cjs/src/types/index.d.ts.map +1 -1
- package/dist/cjs/src/types/index.js +16 -0
- package/dist/cjs/src/types/index.js.map +1 -1
- package/dist/cjs/src/utils/index.d.ts +1 -0
- package/dist/cjs/src/utils/index.d.ts.map +1 -1
- package/dist/cjs/src/utils/index.js +29 -0
- package/dist/cjs/src/utils/index.js.map +1 -1
- package/dist/cjs/src/utils/intents.d.ts.map +1 -1
- package/dist/cjs/src/utils/intents.js.map +1 -1
- package/dist/cjs/src/utils/spark-address.d.ts.map +1 -1
- package/dist/cjs/src/utils/spark-address.js.map +1 -1
- package/dist/cjs/src/utils/tokenAddress.d.ts.map +1 -1
- package/dist/cjs/src/utils/tokenAddress.js +1 -1
- package/dist/cjs/src/utils/tokenAddress.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/src/api/typed-endpoints.d.ts.map +1 -1
- package/dist/esm/src/api/typed-endpoints.js.map +1 -1
- package/dist/esm/src/client/FlashnetClient.d.ts +61 -12
- package/dist/esm/src/client/FlashnetClient.d.ts.map +1 -1
- package/dist/esm/src/client/FlashnetClient.js +161 -68
- package/dist/esm/src/client/FlashnetClient.js.map +1 -1
- package/dist/esm/src/config/index.d.ts +2 -13
- package/dist/esm/src/config/index.d.ts.map +1 -1
- package/dist/esm/src/config/index.js +18 -30
- package/dist/esm/src/config/index.js.map +1 -1
- package/dist/esm/src/types/index.d.ts.map +1 -1
- package/dist/esm/src/types/index.js +14 -1
- package/dist/esm/src/types/index.js.map +1 -1
- package/dist/esm/src/utils/index.d.ts +1 -0
- package/dist/esm/src/utils/index.d.ts.map +1 -1
- package/dist/esm/src/utils/index.js +29 -1
- package/dist/esm/src/utils/index.js.map +1 -1
- package/dist/esm/src/utils/intents.d.ts.map +1 -1
- package/dist/esm/src/utils/intents.js.map +1 -1
- package/dist/esm/src/utils/spark-address.d.ts.map +1 -1
- package/dist/esm/src/utils/spark-address.js.map +1 -1
- package/dist/esm/src/utils/tokenAddress.d.ts.map +1 -1
- package/dist/esm/src/utils/tokenAddress.js +1 -1
- package/dist/esm/src/utils/tokenAddress.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export { fromSmallestUnit, generateNonce, toSmallestUnit } from "./src/utils";
|
|
|
9
9
|
export { AuthManager } from "./src/utils/auth";
|
|
10
10
|
export { generateAddLiquidityIntentMessage, generateConstantProductPoolInitializationIntentMessage, generatePoolConfirmInitialDepositIntentMessage, generatePoolInitializationIntentMessage, generatePoolSwapIntentMessage, generateRegisterHostIntentMessage, generateRemoveLiquidityIntentMessage, generateWithdrawHostFeesIntentMessage, } from "./src/utils/intents";
|
|
11
11
|
export { createWalletSigner } from "./src/utils/signer";
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
12
|
+
export { convertSparkAddressToNetwork, convertSparkAddressToSparkNetwork, decodeSparkAddress, decodeSparkAddressNew, encodeSparkAddress, encodeSparkAddressNew, getNetworkFromAddress, getSparkNetworkFromAddress, isValidPublicKey, isValidSparkAddress, isValidSparkAddressNew, looksLikePublicKey, type SparkAddressFormat, } from "./src/utils/spark-address";
|
|
13
|
+
export { decodeHumanReadableTokenIdentifier, decodeSparkHumanReadableTokenIdentifier, encodeHumanReadableTokenIdentifier, encodeSparkHumanReadableTokenIdentifier, type HumanReadableTokenIdentifier, type SparkHumanReadableTokenIdentifier, } from "./src/utils/tokenAddress";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,UAAU,EACV,eAAe,EACf,WAAW,GACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,kCAAkC,EAClC,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,WAAW,EACX,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,6BAA6B,CAAC;AAGrC,cAAc,cAAc,CAAC;AAC7B,mBAAmB,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,iCAAiC,EACjC,sDAAsD,EACtD,8CAA8C,EAC9C,uCAAuC,EACvC,6BAA6B,EAC7B,iCAAiC,EACjC,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,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2BAA2B,CAAC;AAGnC,OAAO,EACL,kCAAkC,EAClC,uCAAuC,EAEvC,kCAAkC,EAElC,uCAAuC,EACvC,KAAK,4BAA4B,EACjC,KAAK,iCAAiC,GACvC,MAAM,0BAA0B,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -40,7 +40,6 @@ exports.getDefaultSparkNetworkForEnvironment = index$1.getDefaultSparkNetworkFor
|
|
|
40
40
|
exports.getNetworkConfig = index$1.getNetworkConfig;
|
|
41
41
|
exports.resolveClientNetworkConfig = index$1.resolveClientNetworkConfig;
|
|
42
42
|
exports.validateClientNetworkConfig = index$1.validateClientNetworkConfig;
|
|
43
|
-
exports.validateNetworkCombination = index$1.validateNetworkCombination;
|
|
44
43
|
exports.fromSmallestUnit = index.fromSmallestUnit;
|
|
45
44
|
exports.generateNonce = index.generateNonce;
|
|
46
45
|
exports.toSmallestUnit = index.toSmallestUnit;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-endpoints.d.ts","sourceRoot":"","sources":["../../../../src/api/typed-endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;GAEG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAIrC;;;OAGG;IACG,YAAY,CAChB,OAAO,EAAE,KAAK,CAAC,gBAAgB,GAC9B,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAOn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CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAAC,gBAAgB,CAO1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-endpoints.js","sources":["../../../../../../src/api/typed-endpoints.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;AAEG;MACU,WAAW,CAAA;AACF,IAAA,MAAA;AAApB,IAAA,WAAA,CAAoB,MAAiB,EAAA;QAAjB,IAAA,CAAA,MAAM,GAAN,MAAM;IAAc;;AAIxC;;;AAGG;IACH,MAAM,YAAY,CAChB,OAA+B,EAAA;QAE/B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,oBAAoB,EACpB,OAAO,CACR;IACH;AAEA;;;AAGG;IACH,MAAM,MAAM,CAAC,OAA4B,EAAA;QACvC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,iBAAiB,EACjB,OAAO,CACR;IACH;;AAIA;;;;AAIG;IACH,MAAM,YAAY,CAChB,OAAkC,EAAA;QAElC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,oBAAoB,EACpB,OAAO,CACR;IACH;AAEA;;;AAGG;IACH,MAAM,OAAO,CAAC,SAAiB,EAAA;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAwB,CAAA,UAAA,EAAa,SAAS,CAAA,CAAE,CAAC;IAC5E;AAEA;;;;AAIG;IACH,MAAM,gBAAgB,CACpB,OAAsC,EAAA;QAEtC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,yBAAyB,EACzB,OAAO,CACR;IACH;AAEA;;;;AAIG;IACH,MAAM,eAAe,CACnB,OAAqC,EAAA;QAErC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,qBAAqB,EACrB,OAAO,CACR;IACH;AAEA;;;;AAIG;IACH,MAAM,WAAW,CACf,OAAiC,EAAA;QAEjC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,qBAAqB,EACrB,OAAO,CACR;IACH;;AAIA;;;;AAIG;IACH,MAAM,yBAAyB,CAC7B,OAA+C,EAAA;QAE/C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,4BAA4B,EAC5B,OAAO,CACR;IACH;AAEA;;;;AAIG;IACH,MAAM,qBAAqB,CACzB,OAA2C,EAAA;QAE3C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,wBAAwB,EACxB,OAAO,CACR;IACH;AAEA;;;;AAIG;IACH,MAAM,qBAAqB,CACzB,OAA2C,EAAA;QAE3C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,gDAAgD,EAChD,OAAO,CACR;IACH;AAEA;;;AAGG;IACH,MAAM,SAAS,CACb,KAA4B,EAAA;AAE5B,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAA0B,WAAW,EAAE;AAC9D,YAAA,MAAM,EAAE,KAAY;AACrB,SAAA,CAAC;IACJ;AAEA;;;AAGG;IACH,MAAM,OAAO,CAAC,MAAc,EAAA;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAA4B,CAAA,UAAA,EAAa,MAAM,CAAA,CAAE,CAAC;IAC7E;AAEA;;;;AAIG;AACH,IAAA,MAAM,aAAa,CACjB,MAAc,EACd,iBAAyB,EAAA;AAEzB,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CACvB,CAAA,UAAA,EAAa,MAAM,CAAA,IAAA,EAAO,iBAAiB,CAAA,CAAE,CAC9C;IACH;AAEA;;;;AAIG;AACH,IAAA,MAAM,iBAAiB,GAAA;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"typed-endpoints.js","sources":["../../../../../../src/api/typed-endpoints.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;;AAEG;MACU,WAAW,CAAA;AACF,IAAA,MAAA;AAApB,IAAA,WAAA,CAAoB,MAAiB,EAAA;QAAjB,IAAA,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M,iBAAiB,GAAA;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CACvB,2BAA2B,CAC5B;IACH;AAEA;;;;;;AAMG;IACH,MAAM,qBAAqB,CACzB,MAAc,EAAA;QAEd,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CACvB,CAAA,0BAAA,EAA6B,MAAM,CAAA,CAAE,CACtC;IACH;AAEA;;;;AAIG;IACH,MAAM,sBAAsB,CAC1B,OAA4C,EAAA;QAE5C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,+BAA+B,EAC/B,OAAO,CACR;IACH;;AAIA;;;AAGG;AACH,IAAA,MAAM,IAAI,GAAA;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAA+B,UAAU,CAAC;IACrE;AACD;AAED;;AAEG;AACG,SAAU,eAAe,CAC7B,KAAc,EAAA;AAEd,IAAA,QACE,OAAO,KAAK,KAAK,QAAQ;AACzB,QAAA,KAAK,KAAK,IAAI;AACd,QAAA,MAAM,IAAI,KAAK;AACf,QAAA,KAAK,IAAI,KAAK;AACd,QAAA,OAAQ,KAAa,CAAC,IAAI,KAAK,QAAQ;AACvC,QAAA,OAAQ,KAAa,CAAC,GAAG,KAAK,QAAQ;AAE1C;AAEM,SAAU,UAAU,CAAC,KAAc,EAAA;AACvC,IAAA,QACE,OAAO,KAAK,KAAK,QAAQ;AACzB,QAAA,KAAK,KAAK,IAAI;AACd,QAAA,OAAO,IAAI,KAAK;AAChB,QAAA,OAAQ,KAAa,CAAC,KAAK,KAAK,QAAQ;AAE5C;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IssuerSparkWallet } from "@buildonspark/issuer-sdk";
|
|
2
2
|
import type { SparkWallet } from "@buildonspark/spark-sdk";
|
|
3
|
-
import { type AddLiquidityResponse, type AllLpPositionsResponse, type ConfirmDepositResponse, type CreatePoolResponse, type ExecuteRouteSwapResponse, type GetHostFeesResponse, type GetHostResponse, type GetIntegratorFeesResponse, type GetPoolHostFeesResponse, type ListGlobalSwapsQuery, type ListGlobalSwapsResponse, type ListPoolSwapsQuery, type ListPoolSwapsResponse, type ListPoolsQuery, type ListPoolsResponse, type ListUserSwapsQuery, type ListUserSwapsResponse, type LpPositionDetailsResponse, type NetworkType, type PoolDetailsResponse, type RegisterHostResponse, type RemoveLiquidityResponse, type SettlementPingResponse, type SimulateAddLiquidityRequest, type SimulateAddLiquidityResponse, type SimulateRemoveLiquidityRequest, type SimulateRemoveLiquidityResponse, type SimulateRouteSwapRequest, type SimulateRouteSwapResponse, type SimulateSwapRequest, type SimulateSwapResponse, type SwapResponse, type WithdrawHostFeesResponse, type WithdrawIntegratorFeesResponse } from "../types";
|
|
4
|
-
import { type
|
|
3
|
+
import { type AddLiquidityResponse, type AllLpPositionsResponse, type ClientEnvironment, type ConfirmDepositResponse, type CreatePoolResponse, type ExecuteRouteSwapResponse, type FlashnetClientConfig, type FlashnetClientCustomConfig, type FlashnetClientEnvironmentConfig, type FlashnetClientLegacyConfig, type GetHostFeesResponse, type GetHostResponse, type GetIntegratorFeesResponse, type GetPoolHostFeesResponse, type ListGlobalSwapsQuery, type ListGlobalSwapsResponse, type ListPoolSwapsQuery, type ListPoolSwapsResponse, type ListPoolsQuery, type ListPoolsResponse, type ListUserSwapsQuery, type ListUserSwapsResponse, type LpPositionDetailsResponse, type NetworkType, type PoolDetailsResponse, type RegisterHostResponse, type RemoveLiquidityResponse, type SettlementPingResponse, type SimulateAddLiquidityRequest, type SimulateAddLiquidityResponse, type SimulateRemoveLiquidityRequest, type SimulateRemoveLiquidityResponse, type SimulateRouteSwapRequest, type SimulateRouteSwapResponse, type SimulateSwapRequest, type SimulateSwapResponse, type SparkNetworkType, type SwapResponse, type WithdrawHostFeesResponse, type WithdrawIntegratorFeesResponse } from "../types";
|
|
4
|
+
import { type SparkHumanReadableTokenIdentifier } from "../utils/tokenAddress";
|
|
5
5
|
export interface TokenBalance {
|
|
6
6
|
balance: bigint;
|
|
7
7
|
tokenInfo?: {
|
|
@@ -17,6 +17,9 @@ export interface WalletBalance {
|
|
|
17
17
|
balance: bigint;
|
|
18
18
|
tokenBalances: Map<string, TokenBalance>;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use FlashnetClientConfig instead
|
|
22
|
+
*/
|
|
20
23
|
export interface FlashnetClientOptions {
|
|
21
24
|
autoAuthenticate?: boolean;
|
|
22
25
|
}
|
|
@@ -35,7 +38,8 @@ export declare class FlashnetClient {
|
|
|
35
38
|
private apiClient;
|
|
36
39
|
private typedApi;
|
|
37
40
|
private authManager;
|
|
38
|
-
private
|
|
41
|
+
private sparkNetwork;
|
|
42
|
+
private clientEnvironment;
|
|
39
43
|
private publicKey;
|
|
40
44
|
private sparkAddress;
|
|
41
45
|
private isAuthenticated;
|
|
@@ -44,6 +48,15 @@ export declare class FlashnetClient {
|
|
|
44
48
|
*/
|
|
45
49
|
get wallet(): IssuerSparkWallet | SparkWallet;
|
|
46
50
|
/**
|
|
51
|
+
* Get the Spark network type (for blockchain operations)
|
|
52
|
+
*/
|
|
53
|
+
get sparkNetworkType(): SparkNetworkType;
|
|
54
|
+
/**
|
|
55
|
+
* Get the client environment (for API configuration)
|
|
56
|
+
*/
|
|
57
|
+
get clientEnvironmentType(): ClientEnvironment;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Use sparkNetworkType instead
|
|
47
60
|
* Get the network type
|
|
48
61
|
*/
|
|
49
62
|
get networkType(): NetworkType;
|
|
@@ -56,11 +69,30 @@ export declare class FlashnetClient {
|
|
|
56
69
|
*/
|
|
57
70
|
get address(): string;
|
|
58
71
|
/**
|
|
59
|
-
* Create a new FlashnetClient instance
|
|
72
|
+
* Create a new FlashnetClient instance with new configuration system
|
|
73
|
+
* @param wallet - The SparkWallet to use
|
|
74
|
+
* @param config - Client configuration with separate Spark network and client config
|
|
75
|
+
*/
|
|
76
|
+
constructor(wallet: IssuerSparkWallet | SparkWallet, config: FlashnetClientConfig);
|
|
77
|
+
/**
|
|
78
|
+
* Create a new FlashnetClient instance with custom configuration
|
|
79
|
+
* @param wallet - The SparkWallet to use
|
|
80
|
+
* @param config - Custom configuration with specific endpoints
|
|
81
|
+
*/
|
|
82
|
+
constructor(wallet: IssuerSparkWallet | SparkWallet, config: FlashnetClientCustomConfig);
|
|
83
|
+
/**
|
|
84
|
+
* Create a new FlashnetClient instance with environment configuration
|
|
85
|
+
* @param wallet - The SparkWallet to use
|
|
86
|
+
* @param config - Environment-based configuration
|
|
87
|
+
*/
|
|
88
|
+
constructor(wallet: IssuerSparkWallet | SparkWallet, config: FlashnetClientEnvironmentConfig);
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated Use the new constructor with FlashnetClientConfig instead
|
|
91
|
+
* Create a new FlashnetClient instance with legacy configuration
|
|
60
92
|
* @param wallet - The SparkWallet to use
|
|
61
|
-
* @param options -
|
|
93
|
+
* @param options - Legacy client options
|
|
62
94
|
*/
|
|
63
|
-
constructor(wallet: IssuerSparkWallet | SparkWallet,
|
|
95
|
+
constructor(wallet: IssuerSparkWallet | SparkWallet, options?: FlashnetClientLegacyConfig);
|
|
64
96
|
/**
|
|
65
97
|
* Initialize the client by deducing network and authenticating
|
|
66
98
|
* This is called automatically on first use if not called manually
|
|
@@ -73,7 +105,7 @@ export declare class FlashnetClient {
|
|
|
73
105
|
/**
|
|
74
106
|
* Ensure a token identifier is in human-readable (Bech32m) form expected by the Spark SDK.
|
|
75
107
|
* If the identifier is already human-readable or it is the BTC constant, it is returned unchanged.
|
|
76
|
-
* Otherwise, it is encoded from the raw hex form using the client network.
|
|
108
|
+
* Otherwise, it is encoded from the raw hex form using the client's Spark network.
|
|
77
109
|
*/
|
|
78
110
|
private toHumanReadableTokenIdentifier;
|
|
79
111
|
/**
|
|
@@ -103,8 +135,8 @@ export declare class FlashnetClient {
|
|
|
103
135
|
*/
|
|
104
136
|
getLpPosition(poolId: string, providerPublicKey?: string): Promise<LpPositionDetailsResponse>;
|
|
105
137
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
138
|
+
* Get LP position details for a provider in a pool
|
|
139
|
+
*/
|
|
108
140
|
getAllLpPositions(): Promise<AllLpPositionsResponse>;
|
|
109
141
|
/**
|
|
110
142
|
* Create a constant product pool
|
|
@@ -257,17 +289,34 @@ export declare class FlashnetClient {
|
|
|
257
289
|
*/
|
|
258
290
|
getUserSwaps(userPublicKey?: string, query?: ListUserSwapsQuery): Promise<ListUserSwapsResponse>;
|
|
259
291
|
/**
|
|
260
|
-
* Encode a token identifier into a human-readable token address using the client's network
|
|
292
|
+
* Encode a token identifier into a human-readable token address using the client's Spark network
|
|
261
293
|
* @param tokenIdentifier - Token identifier as hex string or Uint8Array
|
|
262
294
|
* @returns Human-readable token address
|
|
263
295
|
*/
|
|
264
|
-
encodeTokenAddress(tokenIdentifier: string | Uint8Array):
|
|
296
|
+
encodeTokenAddress(tokenIdentifier: string | Uint8Array): SparkHumanReadableTokenIdentifier;
|
|
265
297
|
/**
|
|
266
298
|
* Decode a human-readable token address back to its identifier
|
|
267
299
|
* @param address - Human-readable token address
|
|
300
|
+
* @returns Object containing the token identifier (as hex string) and Spark network
|
|
301
|
+
*/
|
|
302
|
+
decodeTokenAddress(address: SparkHumanReadableTokenIdentifier): {
|
|
303
|
+
tokenIdentifier: string;
|
|
304
|
+
network: SparkNetworkType;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* @deprecated Use encodeTokenAddress instead - this method uses legacy types
|
|
308
|
+
* Encode a token identifier into a human-readable token address using legacy types
|
|
309
|
+
* @param tokenIdentifier - Token identifier as hex string or Uint8Array
|
|
310
|
+
* @returns Human-readable token address
|
|
311
|
+
*/
|
|
312
|
+
encodeLegacyTokenAddress(tokenIdentifier: string | Uint8Array): SparkHumanReadableTokenIdentifier;
|
|
313
|
+
/**
|
|
314
|
+
* @deprecated Use decodeTokenAddress instead - this method uses legacy types
|
|
315
|
+
* Decode a human-readable token address back to its identifier using legacy types
|
|
316
|
+
* @param address - Human-readable token address
|
|
268
317
|
* @returns Object containing the token identifier (as hex string) and network
|
|
269
318
|
*/
|
|
270
|
-
|
|
319
|
+
decodeLegacyTokenAddress(address: SparkHumanReadableTokenIdentifier): {
|
|
271
320
|
tokenIdentifier: string;
|
|
272
321
|
network: NetworkType;
|
|
273
322
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlashnetClient.d.ts","sourceRoot":"","sources":["../../../../src/client/FlashnetClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"FlashnetClient.d.ts","sourceRoot":"","sources":["../../../../src/client/FlashnetClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAS3D,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EAEtB,KAAK,sBAAsB,EAG3B,KAAK,kBAAkB,EAGvB,KAAK,wBAAwB,EAE7B,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAE/B,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAG5B,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAE9B,KAAK,WAAW,EAChB,KAAK,mBAAmB,EAExB,KAAK,oBAAoB,EAEzB,KAAK,uBAAuB,EAG5B,KAAK,sBAAsB,EAC3B,K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AAiC;IAOpC;;;;;OAKG;IACH,wBAAwB,CAAC,OAAO,EAAE,iCAAiC,GAAG;QACpE,eAAe,EAAE,MAAM,CAAC;QACxB,OAAO,EAAE,WAAW,CAAC;KACtB;IAMD;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAO7C;;OAEG;YACW,mBAAmB;IAwFjC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
|
|
@@ -26,7 +26,8 @@ class FlashnetClient {
|
|
|
26
26
|
apiClient;
|
|
27
27
|
typedApi;
|
|
28
28
|
authManager;
|
|
29
|
-
|
|
29
|
+
sparkNetwork;
|
|
30
|
+
clientEnvironment;
|
|
30
31
|
publicKey = "";
|
|
31
32
|
sparkAddress = "";
|
|
32
33
|
isAuthenticated = false;
|
|
@@ -37,10 +38,27 @@ class FlashnetClient {
|
|
|
37
38
|
return this._wallet;
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
41
|
+
* Get the Spark network type (for blockchain operations)
|
|
42
|
+
*/
|
|
43
|
+
get sparkNetworkType() {
|
|
44
|
+
return this.sparkNetwork;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the client environment (for API configuration)
|
|
48
|
+
*/
|
|
49
|
+
get clientEnvironmentType() {
|
|
50
|
+
return this.clientEnvironment;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Use sparkNetworkType instead
|
|
40
54
|
* Get the network type
|
|
41
55
|
*/
|
|
42
56
|
get networkType() {
|
|
43
|
-
|
|
57
|
+
// Map Spark network back to legacy network type
|
|
58
|
+
// This is for backward compatibility
|
|
59
|
+
return this.sparkNetwork === "REGTEST" && this.clientEnvironment === "local"
|
|
60
|
+
? "LOCAL"
|
|
61
|
+
: this.sparkNetwork;
|
|
44
62
|
}
|
|
45
63
|
/**
|
|
46
64
|
* Get the wallet's public key
|
|
@@ -54,24 +72,83 @@ class FlashnetClient {
|
|
|
54
72
|
get address() {
|
|
55
73
|
return this.sparkAddress;
|
|
56
74
|
}
|
|
57
|
-
|
|
58
|
-
* Create a new FlashnetClient instance
|
|
59
|
-
* @param wallet - The SparkWallet to use
|
|
60
|
-
* @param options - Client options
|
|
61
|
-
*/
|
|
62
|
-
constructor(wallet, _options = {}) {
|
|
75
|
+
constructor(wallet, configOrOptions) {
|
|
63
76
|
this._wallet = wallet;
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
// Determine configuration type and extract values
|
|
78
|
+
const isLegacyConfig = !configOrOptions ||
|
|
79
|
+
"network" in configOrOptions ||
|
|
80
|
+
!("sparkNetworkType" in configOrOptions);
|
|
81
|
+
if (isLegacyConfig) {
|
|
82
|
+
// Legacy configuration system - derive from wallet or options
|
|
83
|
+
const legacyConfig = configOrOptions;
|
|
84
|
+
if (legacyConfig?.network) {
|
|
85
|
+
// Use provided legacy network
|
|
86
|
+
this.sparkNetwork = index.getSparkNetworkFromLegacy(legacyConfig.network);
|
|
87
|
+
this.clientEnvironment = index.getClientEnvironmentFromLegacy(legacyConfig.network);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// Auto-detect from wallet (existing behavior)
|
|
91
|
+
// @ts-expect-error - wallet.config is protected
|
|
92
|
+
const networkEnum = wallet.config.getNetwork();
|
|
93
|
+
const networkName = index.Network[networkEnum];
|
|
94
|
+
const detectedNetwork = networkName === "MAINNET" ? "MAINNET" : "REGTEST";
|
|
95
|
+
this.sparkNetwork = index.getSparkNetworkFromLegacy(detectedNetwork);
|
|
96
|
+
this.clientEnvironment =
|
|
97
|
+
index.getClientEnvironmentFromLegacy(detectedNetwork);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// New configuration system
|
|
102
|
+
const config = configOrOptions;
|
|
103
|
+
this.sparkNetwork = config.sparkNetworkType;
|
|
104
|
+
// Determine client configuration based on the specific config type
|
|
105
|
+
let clientConfig;
|
|
106
|
+
if ("clientConfig" in config) {
|
|
107
|
+
// FlashnetClientConfig - can be either environment or custom config
|
|
108
|
+
clientConfig = config.clientConfig;
|
|
109
|
+
}
|
|
110
|
+
else if ("clientNetworkConfig" in config) {
|
|
111
|
+
// FlashnetClientCustomConfig - custom configuration
|
|
112
|
+
clientConfig = config.clientNetworkConfig;
|
|
113
|
+
}
|
|
114
|
+
else if ("clientEnvironment" in config) {
|
|
115
|
+
// FlashnetClientEnvironmentConfig - predefined environment
|
|
116
|
+
clientConfig = config.clientEnvironment;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw new Error("Invalid configuration: must specify clientConfig, clientNetworkConfig, or clientEnvironment");
|
|
120
|
+
}
|
|
121
|
+
// Resolve the client environment name for internal tracking
|
|
122
|
+
const environmentName = index$1.getClientEnvironmentName(clientConfig);
|
|
123
|
+
this.clientEnvironment =
|
|
124
|
+
environmentName === "custom"
|
|
125
|
+
? "local"
|
|
126
|
+
: environmentName;
|
|
127
|
+
}
|
|
128
|
+
// Initialize API client with resolved client configuration
|
|
129
|
+
let resolvedClientConfig;
|
|
130
|
+
if (!isLegacyConfig) {
|
|
131
|
+
const config = configOrOptions;
|
|
132
|
+
let clientConfigParam;
|
|
133
|
+
if ("clientConfig" in config) {
|
|
134
|
+
clientConfigParam = config.clientConfig;
|
|
135
|
+
}
|
|
136
|
+
else if ("clientNetworkConfig" in config) {
|
|
137
|
+
clientConfigParam = config.clientNetworkConfig;
|
|
138
|
+
}
|
|
139
|
+
else if ("clientEnvironment" in config) {
|
|
140
|
+
clientConfigParam = config.clientEnvironment;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
throw new Error("Invalid configuration");
|
|
144
|
+
}
|
|
145
|
+
resolvedClientConfig = index$1.resolveClientNetworkConfig(clientConfigParam);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Use legacy resolution
|
|
149
|
+
resolvedClientConfig = index$1.getClientNetworkConfig(this.clientEnvironment);
|
|
72
150
|
}
|
|
73
|
-
|
|
74
|
-
this.apiClient = new client.ApiClient(config);
|
|
151
|
+
this.apiClient = new client.ApiClient(resolvedClientConfig);
|
|
75
152
|
this.typedApi = new typedEndpoints.TypedAmmApi(this.apiClient);
|
|
76
153
|
this.authManager = new auth.AuthManager(this.apiClient, "", wallet);
|
|
77
154
|
}
|
|
@@ -86,20 +163,17 @@ class FlashnetClient {
|
|
|
86
163
|
// Get wallet details
|
|
87
164
|
this.publicKey = await this._wallet.getIdentityPublicKey();
|
|
88
165
|
this.sparkAddress = await this._wallet.getSparkAddress();
|
|
89
|
-
// Deduce network from spark address
|
|
90
|
-
const
|
|
91
|
-
if (!
|
|
92
|
-
throw new Error(`Unable to determine network from spark address: ${this.sparkAddress}`);
|
|
166
|
+
// Deduce Spark network from spark address and validate consistency
|
|
167
|
+
const detectedSparkNetwork = sparkAddress.getSparkNetworkFromAddress(this.sparkAddress);
|
|
168
|
+
if (!detectedSparkNetwork) {
|
|
169
|
+
throw new Error(`Unable to determine Spark network from spark address: ${this.sparkAddress}`);
|
|
93
170
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
171
|
+
// Warn if configured Spark network doesn't match detected network
|
|
172
|
+
if (this.sparkNetwork !== detectedSparkNetwork) {
|
|
173
|
+
console.warn(`Warning: Configured Spark network (${this.sparkNetwork}) doesn't match detected network from address (${detectedSparkNetwork}). Using detected network.`);
|
|
174
|
+
this.sparkNetwork = detectedSparkNetwork;
|
|
98
175
|
}
|
|
99
|
-
//
|
|
100
|
-
const config = index$1.getNetworkConfig(this.network);
|
|
101
|
-
this.apiClient = new client.ApiClient(config);
|
|
102
|
-
this.typedApi = new typedEndpoints.TypedAmmApi(this.apiClient);
|
|
176
|
+
// Re-initialize auth manager with correct public key
|
|
103
177
|
this.authManager = new auth.AuthManager(this.apiClient, this.publicKey, signer.createWalletSigner(this._wallet));
|
|
104
178
|
// Authenticate
|
|
105
179
|
const token = await this.authManager.authenticate();
|
|
@@ -117,7 +191,7 @@ class FlashnetClient {
|
|
|
117
191
|
/**
|
|
118
192
|
* Ensure a token identifier is in human-readable (Bech32m) form expected by the Spark SDK.
|
|
119
193
|
* If the identifier is already human-readable or it is the BTC constant, it is returned unchanged.
|
|
120
|
-
* Otherwise, it is encoded from the raw hex form using the client network.
|
|
194
|
+
* Otherwise, it is encoded from the raw hex form using the client's Spark network.
|
|
121
195
|
*/
|
|
122
196
|
toHumanReadableTokenIdentifier(tokenIdentifier) {
|
|
123
197
|
if (tokenIdentifier === index$1.BTC_ASSET_PUBKEY) {
|
|
@@ -126,7 +200,7 @@ class FlashnetClient {
|
|
|
126
200
|
if (tokenIdentifier.startsWith("btkn")) {
|
|
127
201
|
return tokenIdentifier;
|
|
128
202
|
}
|
|
129
|
-
return tokenAddress.
|
|
203
|
+
return tokenAddress.encodeSparkHumanReadableTokenIdentifier(tokenIdentifier, this.sparkNetwork);
|
|
130
204
|
}
|
|
131
205
|
/**
|
|
132
206
|
* Convert a token identifier into the raw hex string form expected by the Flashnet backend.
|
|
@@ -138,7 +212,7 @@ class FlashnetClient {
|
|
|
138
212
|
return tokenIdentifier;
|
|
139
213
|
}
|
|
140
214
|
if (tokenIdentifier.startsWith("btkn")) {
|
|
141
|
-
return tokenAddress.
|
|
215
|
+
return tokenAddress.decodeSparkHumanReadableTokenIdentifier(tokenIdentifier, this.sparkNetwork).tokenIdentifier;
|
|
142
216
|
}
|
|
143
217
|
return tokenIdentifier;
|
|
144
218
|
}
|
|
@@ -154,7 +228,7 @@ class FlashnetClient {
|
|
|
154
228
|
const info = tokenData.tokenMetadata;
|
|
155
229
|
// Convert raw token identifier to hex and human-readable forms
|
|
156
230
|
const tokenIdentifierHex = Buffer.from(info.rawTokenIdentifier).toString("hex");
|
|
157
|
-
const tokenAddress$1 = tokenAddress.
|
|
231
|
+
const tokenAddress$1 = tokenAddress.encodeSparkHumanReadableTokenIdentifier(info.rawTokenIdentifier, this.sparkNetwork);
|
|
158
232
|
tokenBalances.set(tokenPubkey, {
|
|
159
233
|
balance: BigInt(tokenData.balance),
|
|
160
234
|
tokenInfo: {
|
|
@@ -190,7 +264,8 @@ class FlashnetClient {
|
|
|
190
264
|
for (const [tokenPubkey, requiredAmount,] of requirements.tokens.entries()) {
|
|
191
265
|
// If direct lookup fails (possible representation mismatch), try the human-readable form
|
|
192
266
|
const hrKey = this.toHumanReadableTokenIdentifier(tokenPubkey);
|
|
193
|
-
const effectiveTokenBalance = balance.tokenBalances.get(tokenPubkey) ??
|
|
267
|
+
const effectiveTokenBalance = balance.tokenBalances.get(tokenPubkey) ??
|
|
268
|
+
balance.tokenBalances.get(hrKey);
|
|
194
269
|
const available = effectiveTokenBalance?.balance ?? 0n;
|
|
195
270
|
if (available < requiredAmount) {
|
|
196
271
|
return {
|
|
@@ -226,8 +301,8 @@ class FlashnetClient {
|
|
|
226
301
|
return this.typedApi.getLpPosition(poolId, provider);
|
|
227
302
|
}
|
|
228
303
|
/**
|
|
229
|
-
|
|
230
|
-
|
|
304
|
+
* Get LP position details for a provider in a pool
|
|
305
|
+
*/
|
|
231
306
|
async getAllLpPositions() {
|
|
232
307
|
await this.ensureInitialized();
|
|
233
308
|
return this.typedApi.getAllLpPositions();
|
|
@@ -354,10 +429,10 @@ class FlashnetClient {
|
|
|
354
429
|
// If pool creation was successful, handle the initial deposit
|
|
355
430
|
if (createResponse.poolId) {
|
|
356
431
|
try {
|
|
357
|
-
// Transfer initial reserve to the pool
|
|
358
|
-
const lpSparkAddress = sparkAddress.
|
|
432
|
+
// Transfer initial reserve to the pool using new address encoding
|
|
433
|
+
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
359
434
|
identityPublicKey: createResponse.poolId,
|
|
360
|
-
network: this.
|
|
435
|
+
network: this.sparkNetwork,
|
|
361
436
|
});
|
|
362
437
|
let assetATransferId;
|
|
363
438
|
if (params.assetAAddress === index$1.BTC_ASSET_PUBKEY) {
|
|
@@ -456,10 +531,10 @@ class FlashnetClient {
|
|
|
456
531
|
if (!balanceCheck.sufficient) {
|
|
457
532
|
throw new Error(`Insufficient balance for swap: ${balanceCheck.message}`);
|
|
458
533
|
}
|
|
459
|
-
// Transfer assets to pool
|
|
460
|
-
const lpSparkAddress = sparkAddress.
|
|
534
|
+
// Transfer assets to pool using new address encoding
|
|
535
|
+
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
461
536
|
identityPublicKey: params.poolId,
|
|
462
|
-
network: this.
|
|
537
|
+
network: this.sparkNetwork,
|
|
463
538
|
});
|
|
464
539
|
let transferId;
|
|
465
540
|
if (params.assetInAddress === index$1.BTC_ASSET_PUBKEY) {
|
|
@@ -548,14 +623,14 @@ class FlashnetClient {
|
|
|
548
623
|
if (!params.hops.length) {
|
|
549
624
|
throw new Error("Route swap requires at least one hop");
|
|
550
625
|
}
|
|
551
|
-
// Transfer initial asset to first pool
|
|
626
|
+
// Transfer initial asset to first pool using new address encoding
|
|
552
627
|
const firstPoolId = params.hops[0]?.poolId;
|
|
553
628
|
if (!firstPoolId) {
|
|
554
629
|
throw new Error("First pool ID is required");
|
|
555
630
|
}
|
|
556
|
-
const lpSparkAddress = sparkAddress.
|
|
631
|
+
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
557
632
|
identityPublicKey: firstPoolId,
|
|
558
|
-
network: this.
|
|
633
|
+
network: this.sparkNetwork,
|
|
559
634
|
});
|
|
560
635
|
let initialTransferId;
|
|
561
636
|
if (params.initialAssetAddress === index$1.BTC_ASSET_PUBKEY) {
|
|
@@ -670,10 +745,10 @@ class FlashnetClient {
|
|
|
670
745
|
if (!balanceCheck.sufficient) {
|
|
671
746
|
throw new Error(`Insufficient balance for adding liquidity: ${balanceCheck.message}`);
|
|
672
747
|
}
|
|
673
|
-
// Transfer assets to pool
|
|
674
|
-
const lpSparkAddress = sparkAddress.
|
|
748
|
+
// Transfer assets to pool using new address encoding
|
|
749
|
+
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
675
750
|
identityPublicKey: params.poolId,
|
|
676
|
-
network: this.
|
|
751
|
+
network: this.sparkNetwork,
|
|
677
752
|
});
|
|
678
753
|
// Transfer asset A
|
|
679
754
|
let assetATransferId;
|
|
@@ -756,9 +831,9 @@ class FlashnetClient {
|
|
|
756
831
|
await this.ensureInitialized();
|
|
757
832
|
// Check LP token balance
|
|
758
833
|
const position = await this.getLpPosition(params.poolId);
|
|
759
|
-
const lpTokensOwned =
|
|
760
|
-
const tokensToRemove =
|
|
761
|
-
if (lpTokensOwned <
|
|
834
|
+
const lpTokensOwned = position.lpTokensOwned;
|
|
835
|
+
const tokensToRemove = params.lpTokensToRemove;
|
|
836
|
+
if (index$2.compareDecimalStrings(lpTokensOwned, tokensToRemove) < 0) {
|
|
762
837
|
throw new Error(`Insufficient LP tokens. Owned: ${lpTokensOwned}, Requested: ${tokensToRemove}`);
|
|
763
838
|
}
|
|
764
839
|
// Generate remove liquidity intent
|
|
@@ -933,20 +1008,38 @@ class FlashnetClient {
|
|
|
933
1008
|
}
|
|
934
1009
|
// ===== Token Address Operations =====
|
|
935
1010
|
/**
|
|
936
|
-
* Encode a token identifier into a human-readable token address using the client's network
|
|
1011
|
+
* Encode a token identifier into a human-readable token address using the client's Spark network
|
|
937
1012
|
* @param tokenIdentifier - Token identifier as hex string or Uint8Array
|
|
938
1013
|
* @returns Human-readable token address
|
|
939
1014
|
*/
|
|
940
1015
|
encodeTokenAddress(tokenIdentifier) {
|
|
941
|
-
return tokenAddress.
|
|
1016
|
+
return tokenAddress.encodeSparkHumanReadableTokenIdentifier(tokenIdentifier, this.sparkNetwork);
|
|
942
1017
|
}
|
|
943
1018
|
/**
|
|
944
1019
|
* Decode a human-readable token address back to its identifier
|
|
945
1020
|
* @param address - Human-readable token address
|
|
946
|
-
* @returns Object containing the token identifier (as hex string) and network
|
|
1021
|
+
* @returns Object containing the token identifier (as hex string) and Spark network
|
|
947
1022
|
*/
|
|
948
1023
|
decodeTokenAddress(address) {
|
|
949
|
-
return tokenAddress.
|
|
1024
|
+
return tokenAddress.decodeSparkHumanReadableTokenIdentifier(address, this.sparkNetwork);
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* @deprecated Use encodeTokenAddress instead - this method uses legacy types
|
|
1028
|
+
* Encode a token identifier into a human-readable token address using legacy types
|
|
1029
|
+
* @param tokenIdentifier - Token identifier as hex string or Uint8Array
|
|
1030
|
+
* @returns Human-readable token address
|
|
1031
|
+
*/
|
|
1032
|
+
encodeLegacyTokenAddress(tokenIdentifier) {
|
|
1033
|
+
return tokenAddress.encodeSparkHumanReadableTokenIdentifier(tokenIdentifier, this.sparkNetwork);
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* @deprecated Use decodeTokenAddress instead - this method uses legacy types
|
|
1037
|
+
* Decode a human-readable token address back to its identifier using legacy types
|
|
1038
|
+
* @param address - Human-readable token address
|
|
1039
|
+
* @returns Object containing the token identifier (as hex string) and network
|
|
1040
|
+
*/
|
|
1041
|
+
decodeLegacyTokenAddress(address) {
|
|
1042
|
+
return tokenAddress.decodeSparkHumanReadableTokenIdentifier(address, this.sparkNetwork);
|
|
950
1043
|
}
|
|
951
1044
|
// ===== Status =====
|
|
952
1045
|
/**
|
|
@@ -960,14 +1053,14 @@ class FlashnetClient {
|
|
|
960
1053
|
/**
|
|
961
1054
|
* Helper method to add initial liquidity after pool creation
|
|
962
1055
|
*/
|
|
963
|
-
async addInitialLiquidity(poolId,
|
|
964
|
-
const lpSparkAddress = sparkAddress.
|
|
1056
|
+
async addInitialLiquidity(poolId, assetAAddress, assetBAddress, assetAAmount, assetBAmount) {
|
|
1057
|
+
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
965
1058
|
identityPublicKey: poolId,
|
|
966
|
-
network: this.
|
|
1059
|
+
network: this.sparkNetwork,
|
|
967
1060
|
});
|
|
968
1061
|
// Transfer asset A
|
|
969
1062
|
let assetATransferId;
|
|
970
|
-
if (
|
|
1063
|
+
if (assetAAddress === index$1.BTC_ASSET_PUBKEY) {
|
|
971
1064
|
const transfer = await this._wallet.transfer({
|
|
972
1065
|
amountSats: Number(assetAAmount),
|
|
973
1066
|
receiverSparkAddress: lpSparkAddress,
|
|
@@ -976,14 +1069,14 @@ class FlashnetClient {
|
|
|
976
1069
|
}
|
|
977
1070
|
else {
|
|
978
1071
|
assetATransferId = await this._wallet.transferTokens({
|
|
979
|
-
tokenIdentifier: this.toHumanReadableTokenIdentifier(
|
|
1072
|
+
tokenIdentifier: this.toHumanReadableTokenIdentifier(assetAAddress),
|
|
980
1073
|
tokenAmount: BigInt(assetAAmount),
|
|
981
1074
|
receiverSparkAddress: lpSparkAddress,
|
|
982
1075
|
});
|
|
983
1076
|
}
|
|
984
1077
|
// Transfer asset B
|
|
985
1078
|
let assetBTransferId;
|
|
986
|
-
if (
|
|
1079
|
+
if (assetBAddress === index$1.BTC_ASSET_PUBKEY) {
|
|
987
1080
|
const transfer = await this._wallet.transfer({
|
|
988
1081
|
amountSats: Number(assetBAmount),
|
|
989
1082
|
receiverSparkAddress: lpSparkAddress,
|
|
@@ -992,7 +1085,7 @@ class FlashnetClient {
|
|
|
992
1085
|
}
|
|
993
1086
|
else {
|
|
994
1087
|
assetBTransferId = await this._wallet.transferTokens({
|
|
995
|
-
tokenIdentifier: this.toHumanReadableTokenIdentifier(
|
|
1088
|
+
tokenIdentifier: this.toHumanReadableTokenIdentifier(assetBAddress),
|
|
996
1089
|
tokenAmount: BigInt(assetBAmount),
|
|
997
1090
|
receiverSparkAddress: lpSparkAddress,
|
|
998
1091
|
});
|