@flashnet/sdk 0.3.5 → 0.3.6
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 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +17 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/api/client.d.ts +11 -0
- package/dist/cjs/src/api/client.d.ts.map +1 -1
- package/dist/cjs/src/api/client.js.map +1 -1
- package/dist/cjs/src/client/FlashnetClient.d.ts +59 -10
- package/dist/cjs/src/client/FlashnetClient.d.ts.map +1 -1
- package/dist/cjs/src/client/FlashnetClient.js +149 -49
- package/dist/cjs/src/client/FlashnetClient.js.map +1 -1
- package/dist/cjs/src/config/index.d.ts +60 -2
- package/dist/cjs/src/config/index.d.ts.map +1 -1
- package/dist/cjs/src/config/index.js +184 -6
- package/dist/cjs/src/config/index.js.map +1 -1
- package/dist/cjs/src/types/index.d.ts +101 -0
- package/dist/cjs/src/types/index.d.ts.map +1 -1
- package/dist/cjs/src/types/index.js +19 -0
- package/dist/cjs/src/types/index.js.map +1 -1
- package/dist/cjs/src/utils/index.js +5 -0
- package/dist/cjs/src/utils/index.js.map +1 -1
- package/dist/cjs/src/utils/spark-address.d.ts +61 -13
- package/dist/cjs/src/utils/spark-address.d.ts.map +1 -1
- package/dist/cjs/src/utils/spark-address.js +192 -30
- package/dist/cjs/src/utils/spark-address.js.map +1 -1
- package/dist/cjs/src/utils/tokenAddress.d.ts +28 -1
- package/dist/cjs/src/utils/tokenAddress.d.ts.map +1 -1
- package/dist/cjs/src/utils/tokenAddress.js +63 -0
- package/dist/cjs/src/utils/tokenAddress.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/src/api/client.d.ts +11 -0
- package/dist/esm/src/api/client.d.ts.map +1 -1
- package/dist/esm/src/api/client.js.map +1 -1
- package/dist/esm/src/client/FlashnetClient.d.ts +59 -10
- package/dist/esm/src/client/FlashnetClient.d.ts.map +1 -1
- package/dist/esm/src/client/FlashnetClient.js +153 -53
- package/dist/esm/src/client/FlashnetClient.js.map +1 -1
- package/dist/esm/src/config/index.d.ts +60 -2
- package/dist/esm/src/config/index.d.ts.map +1 -1
- package/dist/esm/src/config/index.js +178 -7
- package/dist/esm/src/config/index.js.map +1 -1
- package/dist/esm/src/types/index.d.ts +101 -0
- package/dist/esm/src/types/index.d.ts.map +1 -1
- package/dist/esm/src/types/index.js +17 -1
- package/dist/esm/src/types/index.js.map +1 -1
- package/dist/esm/src/utils/index.js +1 -1
- package/dist/esm/src/utils/spark-address.d.ts +61 -13
- package/dist/esm/src/utils/spark-address.d.ts.map +1 -1
- package/dist/esm/src/utils/spark-address.js +188 -31
- package/dist/esm/src/utils/spark-address.js.map +1 -1
- package/dist/esm/src/utils/tokenAddress.d.ts +28 -1
- package/dist/esm/src/utils/tokenAddress.d.ts.map +1 -1
- package/dist/esm/src/utils/tokenAddress.js +62 -1
- package/dist/esm/src/utils/tokenAddress.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -9,5 +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 { convertSparkAddressToNetwork, decodeSparkAddress, encodeSparkAddress, getNetworkFromAddress,
|
|
12
|
+
export { convertSparkAddressToSparkNetwork, decodeSparkAddressNew, encodeSparkAddressNew, getSparkNetworkFromAddress, isValidSparkAddressNew, convertSparkAddressToNetwork, decodeSparkAddress, encodeSparkAddress, getNetworkFromAddress, isValidSparkAddress, isValidPublicKey, looksLikePublicKey, type SparkAddressFormat, } from "./src/utils/spark-address";
|
|
13
|
+
export { encodeSparkHumanReadableTokenIdentifier, decodeSparkHumanReadableTokenIdentifier, type SparkHumanReadableTokenIdentifier, encodeHumanReadableTokenIdentifier, decodeHumanReadableTokenIdentifier, type HumanReadableTokenIdentifier, } from "./src/utils/tokenAddress";
|
|
13
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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AAkB,EAClB,KAAK,kBAAkB,GACxB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAEL,uCAAuC,EACvC,uCAAuC,EACvC,KAAK,iCAAiC,EAEtC,kCAAkC,EAClC,kCAAkC,EAClC,KAAK,4BAA4B,GAClC,MAAM,0BAA0B,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var auth = require('./src/utils/auth.js');
|
|
|
10
10
|
var intents = require('./src/utils/intents.js');
|
|
11
11
|
var signer = require('./src/utils/signer.js');
|
|
12
12
|
var sparkAddress = require('./src/utils/spark-address.js');
|
|
13
|
+
var tokenAddress = require('./src/utils/tokenAddress.js');
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
@@ -29,10 +30,17 @@ exports.validateSignature = validation.validateSignature;
|
|
|
29
30
|
exports.FlashnetClient = FlashnetClient.FlashnetClient;
|
|
30
31
|
exports.BTC_ASSET_PUBKEY = index$1.BTC_ASSET_PUBKEY;
|
|
31
32
|
exports.BTC_DECIMALS = index$1.BTC_DECIMALS;
|
|
33
|
+
exports.CLIENT_NETWORK_CONFIGS = index$1.CLIENT_NETWORK_CONFIGS;
|
|
32
34
|
exports.DEFAULT_HOST_NAMESPACE = index$1.DEFAULT_HOST_NAMESPACE;
|
|
33
35
|
exports.DEFAULT_SLIPPAGE_BPS = index$1.DEFAULT_SLIPPAGE_BPS;
|
|
34
36
|
exports.NETWORK_CONFIGS = index$1.NETWORK_CONFIGS;
|
|
37
|
+
exports.getClientEnvironmentName = index$1.getClientEnvironmentName;
|
|
38
|
+
exports.getClientNetworkConfig = index$1.getClientNetworkConfig;
|
|
39
|
+
exports.getDefaultSparkNetworkForEnvironment = index$1.getDefaultSparkNetworkForEnvironment;
|
|
35
40
|
exports.getNetworkConfig = index$1.getNetworkConfig;
|
|
41
|
+
exports.resolveClientNetworkConfig = index$1.resolveClientNetworkConfig;
|
|
42
|
+
exports.validateClientNetworkConfig = index$1.validateClientNetworkConfig;
|
|
43
|
+
exports.validateNetworkCombination = index$1.validateNetworkCombination;
|
|
36
44
|
exports.fromSmallestUnit = index.fromSmallestUnit;
|
|
37
45
|
exports.generateNonce = index.generateNonce;
|
|
38
46
|
exports.toSmallestUnit = index.toSmallestUnit;
|
|
@@ -47,10 +55,19 @@ exports.generateRemoveLiquidityIntentMessage = intents.generateRemoveLiquidityIn
|
|
|
47
55
|
exports.generateWithdrawHostFeesIntentMessage = intents.generateWithdrawHostFeesIntentMessage;
|
|
48
56
|
exports.createWalletSigner = signer.createWalletSigner;
|
|
49
57
|
exports.convertSparkAddressToNetwork = sparkAddress.convertSparkAddressToNetwork;
|
|
58
|
+
exports.convertSparkAddressToSparkNetwork = sparkAddress.convertSparkAddressToSparkNetwork;
|
|
50
59
|
exports.decodeSparkAddress = sparkAddress.decodeSparkAddress;
|
|
60
|
+
exports.decodeSparkAddressNew = sparkAddress.decodeSparkAddressNew;
|
|
51
61
|
exports.encodeSparkAddress = sparkAddress.encodeSparkAddress;
|
|
62
|
+
exports.encodeSparkAddressNew = sparkAddress.encodeSparkAddressNew;
|
|
52
63
|
exports.getNetworkFromAddress = sparkAddress.getNetworkFromAddress;
|
|
64
|
+
exports.getSparkNetworkFromAddress = sparkAddress.getSparkNetworkFromAddress;
|
|
53
65
|
exports.isValidPublicKey = sparkAddress.isValidPublicKey;
|
|
54
66
|
exports.isValidSparkAddress = sparkAddress.isValidSparkAddress;
|
|
67
|
+
exports.isValidSparkAddressNew = sparkAddress.isValidSparkAddressNew;
|
|
55
68
|
exports.looksLikePublicKey = sparkAddress.looksLikePublicKey;
|
|
69
|
+
exports.decodeHumanReadableTokenIdentifier = tokenAddress.decodeHumanReadableTokenIdentifier;
|
|
70
|
+
exports.decodeSparkHumanReadableTokenIdentifier = tokenAddress.decodeSparkHumanReadableTokenIdentifier;
|
|
71
|
+
exports.encodeHumanReadableTokenIdentifier = tokenAddress.encodeHumanReadableTokenIdentifier;
|
|
72
|
+
exports.encodeSparkHumanReadableTokenIdentifier = tokenAddress.encodeSparkHumanReadableTokenIdentifier;
|
|
56
73
|
//# sourceMappingURL=index.js.map
|
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,4 +1,5 @@
|
|
|
1
1
|
import type { NetworkConfig } from "../config";
|
|
2
|
+
import type { ClientNetworkConfig } from "../types";
|
|
2
3
|
export interface RequestOptions {
|
|
3
4
|
headers?: Record<string, string>;
|
|
4
5
|
body?: any;
|
|
@@ -7,6 +8,16 @@ export interface RequestOptions {
|
|
|
7
8
|
export declare class ApiClient {
|
|
8
9
|
private config;
|
|
9
10
|
private authToken?;
|
|
11
|
+
/**
|
|
12
|
+
* Create an ApiClient with new ClientNetworkConfig
|
|
13
|
+
* @param config Client network configuration
|
|
14
|
+
*/
|
|
15
|
+
constructor(config: ClientNetworkConfig);
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use ClientNetworkConfig instead of NetworkConfig
|
|
18
|
+
* Create an ApiClient with legacy NetworkConfig for backward compatibility
|
|
19
|
+
* @param config Legacy network configuration
|
|
20
|
+
*/
|
|
10
21
|
constructor(config: NetworkConfig);
|
|
11
22
|
setAuthToken(token: string): void;
|
|
12
23
|
private makeRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC1C;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,SAAS,CAAC,CAAS;IAE3B;;;OAGG;gBACS,MAAM,EAAE,mBAAmB;IAEvC;;;;OAIG;gBACS,MAAM,EAAE,aAAa;IAMjC,YAAY,CAAC,KAAK,EAAE,MAAM;YAIZ,WAAW;IA0EnB,OAAO,CAAC,CAAC,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,GAAG,EACT,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;IAOP,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAS7D,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IASjE,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;CAU1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../../../../src/api/client.ts"],"sourcesContent":[null],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../../../../src/api/client.ts"],"sourcesContent":[null],"names":[],"mappings":";;MASa,SAAS,CAAA;AACZ,IAAA,MAAM;AACN,IAAA,SAAS;AAejB,IAAA,WAAA,CAAY,MAA2C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GA,IAAA,MAAM,OAAO,CACX,IAAY,EACZ,IAAS,EACT,OAAwB,EAAA;AAExB,QAAA,OAAO,IAAI,CAAC,WAAW,CAAI,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAA,EAAG,IAAI,CAAA,CAAE,EAAE,MAAM,EAAE;AACxE,YAAA,GAAG,OAAO;YACV,IAAI;AACL,SAAA,CAAC;IACJ;AAEA,IAAA,MAAM,MAAM,CAAI,IAAY,EAAE,OAAwB,EAAA;AACpD,QAAA,OAAO,IAAI,CAAC,WAAW,CACrB,CAAA,EAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAA,EAAG,IAAI,CAAA,CAAE,EACrC,KAAK,EACL,OAAO,CACR;IACH;;AAGA,IAAA,MAAM,UAAU,CAAI,IAAY,EAAE,OAAwB,EAAA;AACxD,QAAA,OAAO,IAAI,CAAC,WAAW,CACrB,CAAA,EAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAA,EAAG,IAAI,CAAA,CAAE,EACrC,KAAK,EACL,OAAO,CACR;IACH;;AAGA,IAAA,MAAM,YAAY,CAAI,IAAY,EAAE,OAAwB,EAAA;AAC1D,QAAA,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;AAC7B,YAAA,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC;QAClE;AACA,QAAA,OAAO,IAAI,CAAC,WAAW,CACrB,CAAA,EAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAA,EAAG,IAAI,CAAA,CAAE,EACpC,KAAK,EACL,OAAO,CACR;IACH;AACD;;;;"}
|
|
@@ -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 HumanReadableTokenIdentifier } from "../utils/tokenAddress";
|
|
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 SparkNetworkType, type ClientEnvironment, type FlashnetClientConfig, type FlashnetClientCustomConfig, type FlashnetClientEnvironmentConfig, type FlashnetClientLegacyConfig, 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 HumanReadableTokenIdentifier, type SparkHumanReadableTokenIdentifier } from "../utils/tokenAddress";
|
|
5
5
|
export interface TokenBalance {
|
|
6
6
|
balance: bigint;
|
|
7
7
|
tokenInfo?: {
|
|
@@ -16,6 +16,9 @@ export interface WalletBalance {
|
|
|
16
16
|
balance: bigint;
|
|
17
17
|
tokenBalances: Map<string, TokenBalance>;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use FlashnetClientConfig instead
|
|
21
|
+
*/
|
|
19
22
|
export interface FlashnetClientOptions {
|
|
20
23
|
autoAuthenticate?: boolean;
|
|
21
24
|
}
|
|
@@ -34,7 +37,8 @@ export declare class FlashnetClient {
|
|
|
34
37
|
private apiClient;
|
|
35
38
|
private typedApi;
|
|
36
39
|
private authManager;
|
|
37
|
-
private
|
|
40
|
+
private sparkNetwork;
|
|
41
|
+
private clientEnvironment;
|
|
38
42
|
private publicKey;
|
|
39
43
|
private sparkAddress;
|
|
40
44
|
private isAuthenticated;
|
|
@@ -43,6 +47,15 @@ export declare class FlashnetClient {
|
|
|
43
47
|
*/
|
|
44
48
|
get wallet(): IssuerSparkWallet | SparkWallet;
|
|
45
49
|
/**
|
|
50
|
+
* Get the Spark network type (for blockchain operations)
|
|
51
|
+
*/
|
|
52
|
+
get sparkNetworkType(): SparkNetworkType;
|
|
53
|
+
/**
|
|
54
|
+
* Get the client environment (for API configuration)
|
|
55
|
+
*/
|
|
56
|
+
get clientEnvironmentType(): ClientEnvironment;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use sparkNetworkType instead
|
|
46
59
|
* Get the network type
|
|
47
60
|
*/
|
|
48
61
|
get networkType(): NetworkType;
|
|
@@ -55,11 +68,30 @@ export declare class FlashnetClient {
|
|
|
55
68
|
*/
|
|
56
69
|
get address(): string;
|
|
57
70
|
/**
|
|
58
|
-
* Create a new FlashnetClient instance
|
|
71
|
+
* Create a new FlashnetClient instance with new configuration system
|
|
72
|
+
* @param wallet - The SparkWallet to use
|
|
73
|
+
* @param config - Client configuration with separate Spark network and client config
|
|
74
|
+
*/
|
|
75
|
+
constructor(wallet: IssuerSparkWallet | SparkWallet, config: FlashnetClientConfig);
|
|
76
|
+
/**
|
|
77
|
+
* Create a new FlashnetClient instance with custom configuration
|
|
78
|
+
* @param wallet - The SparkWallet to use
|
|
79
|
+
* @param config - Custom configuration with specific endpoints
|
|
80
|
+
*/
|
|
81
|
+
constructor(wallet: IssuerSparkWallet | SparkWallet, config: FlashnetClientCustomConfig);
|
|
82
|
+
/**
|
|
83
|
+
* Create a new FlashnetClient instance with environment configuration
|
|
59
84
|
* @param wallet - The SparkWallet to use
|
|
60
|
-
* @param
|
|
85
|
+
* @param config - Environment-based configuration
|
|
61
86
|
*/
|
|
62
|
-
constructor(wallet: IssuerSparkWallet | SparkWallet,
|
|
87
|
+
constructor(wallet: IssuerSparkWallet | SparkWallet, config: FlashnetClientEnvironmentConfig);
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Use the new constructor with FlashnetClientConfig instead
|
|
90
|
+
* Create a new FlashnetClient instance with legacy configuration
|
|
91
|
+
* @param wallet - The SparkWallet to use
|
|
92
|
+
* @param options - Legacy client options
|
|
93
|
+
*/
|
|
94
|
+
constructor(wallet: IssuerSparkWallet | SparkWallet, options?: FlashnetClientLegacyConfig);
|
|
63
95
|
/**
|
|
64
96
|
* Initialize the client by deducing network and authenticating
|
|
65
97
|
* This is called automatically on first use if not called manually
|
|
@@ -72,7 +104,7 @@ export declare class FlashnetClient {
|
|
|
72
104
|
/**
|
|
73
105
|
* Ensure a token identifier is in human-readable (Bech32m) form expected by the Spark SDK.
|
|
74
106
|
* If the identifier is already human-readable or it is the BTC constant, it is returned unchanged.
|
|
75
|
-
* Otherwise, it is encoded from the raw hex form using the client network.
|
|
107
|
+
* Otherwise, it is encoded from the raw hex form using the client's Spark network.
|
|
76
108
|
*/
|
|
77
109
|
private toHumanReadableTokenIdentifier;
|
|
78
110
|
/**
|
|
@@ -256,17 +288,34 @@ export declare class FlashnetClient {
|
|
|
256
288
|
*/
|
|
257
289
|
getUserSwaps(userPublicKey?: string, query?: ListUserSwapsQuery): Promise<ListUserSwapsResponse>;
|
|
258
290
|
/**
|
|
259
|
-
* Encode a token identifier into a human-readable token address using the client's network
|
|
291
|
+
* Encode a token identifier into a human-readable token address using the client's Spark network
|
|
260
292
|
* @param tokenIdentifier - Token identifier as hex string or Uint8Array
|
|
261
293
|
* @returns Human-readable token address
|
|
262
294
|
*/
|
|
263
|
-
encodeTokenAddress(tokenIdentifier: string | Uint8Array):
|
|
295
|
+
encodeTokenAddress(tokenIdentifier: string | Uint8Array): SparkHumanReadableTokenIdentifier;
|
|
264
296
|
/**
|
|
265
297
|
* Decode a human-readable token address back to its identifier
|
|
266
298
|
* @param address - Human-readable token address
|
|
299
|
+
* @returns Object containing the token identifier (as hex string) and Spark network
|
|
300
|
+
*/
|
|
301
|
+
decodeTokenAddress(address: SparkHumanReadableTokenIdentifier): {
|
|
302
|
+
tokenIdentifier: string;
|
|
303
|
+
network: SparkNetworkType;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* @deprecated Use encodeTokenAddress instead - this method uses legacy types
|
|
307
|
+
* Encode a token identifier into a human-readable token address using legacy types
|
|
308
|
+
* @param tokenIdentifier - Token identifier as hex string or Uint8Array
|
|
309
|
+
* @returns Human-readable token address
|
|
310
|
+
*/
|
|
311
|
+
encodeLegacyTokenAddress(tokenIdentifier: string | Uint8Array): HumanReadableTokenIdentifier;
|
|
312
|
+
/**
|
|
313
|
+
* @deprecated Use decodeTokenAddress instead - this method uses legacy types
|
|
314
|
+
* Decode a human-readable token address back to its identifier using legacy types
|
|
315
|
+
* @param address - Human-readable token address
|
|
267
316
|
* @returns Object containing the token identifier (as hex string) and network
|
|
268
317
|
*/
|
|
269
|
-
|
|
318
|
+
decodeLegacyTokenAddress(address: HumanReadableTokenIdentifier): {
|
|
270
319
|
tokenIdentifier: string;
|
|
271
320
|
network: NetworkType;
|
|
272
321
|
};
|
|
@@ -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;AAY3D,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAG3B,KAAK,kBAAkB,EAGvB,KAAK,wBAAwB,EAG7B,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,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,gBAAgB,EACrB,KAAK,iBAAiB,EAEtB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EAExB,KAAK,oBAAoB,EAEzB,KAAK,uBAAuB,EAG5B,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EACpC,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAEjB,KAAK,wBAAwB,EAE7B,KAAK,8BAA8B,EAG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,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,87 @@ 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
|
-
|
|
77
|
+
// Determine configuration type and extract values
|
|
78
|
+
const isLegacyConfig = !configOrOptions || 'network' in configOrOptions ||
|
|
79
|
+
(!('sparkNetworkType' in configOrOptions));
|
|
80
|
+
if (isLegacyConfig) {
|
|
81
|
+
// Legacy configuration system - derive from wallet or options
|
|
82
|
+
const legacyConfig = configOrOptions;
|
|
83
|
+
if (legacyConfig?.network) {
|
|
84
|
+
// Use provided legacy network
|
|
85
|
+
this.sparkNetwork = index.getSparkNetworkFromLegacy(legacyConfig.network);
|
|
86
|
+
this.clientEnvironment = index.getClientEnvironmentFromLegacy(legacyConfig.network);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Auto-detect from wallet (existing behavior)
|
|
90
|
+
// @ts-expect-error - wallet.config is protected
|
|
91
|
+
const networkEnum = wallet.config.getNetwork();
|
|
92
|
+
const networkName = index.Network[networkEnum];
|
|
93
|
+
const detectedNetwork = networkName === "MAINNET" ? "MAINNET" : "REGTEST";
|
|
94
|
+
this.sparkNetwork = index.getSparkNetworkFromLegacy(detectedNetwork);
|
|
95
|
+
this.clientEnvironment = index.getClientEnvironmentFromLegacy(detectedNetwork);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
// New configuration system
|
|
100
|
+
const config = configOrOptions;
|
|
101
|
+
this.sparkNetwork = config.sparkNetworkType;
|
|
102
|
+
// Determine client configuration based on the specific config type
|
|
103
|
+
let clientConfig;
|
|
104
|
+
if ('clientConfig' in config) {
|
|
105
|
+
// FlashnetClientConfig - can be either environment or custom config
|
|
106
|
+
clientConfig = config.clientConfig;
|
|
107
|
+
}
|
|
108
|
+
else if ('clientNetworkConfig' in config) {
|
|
109
|
+
// FlashnetClientCustomConfig - custom configuration
|
|
110
|
+
clientConfig = config.clientNetworkConfig;
|
|
111
|
+
}
|
|
112
|
+
else if ('clientEnvironment' in config) {
|
|
113
|
+
// FlashnetClientEnvironmentConfig - predefined environment
|
|
114
|
+
clientConfig = config.clientEnvironment;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
throw new Error('Invalid configuration: must specify clientConfig, clientNetworkConfig, or clientEnvironment');
|
|
118
|
+
}
|
|
119
|
+
// Resolve the client environment name for internal tracking
|
|
120
|
+
const environmentName = index$1.getClientEnvironmentName(clientConfig);
|
|
121
|
+
this.clientEnvironment = environmentName === 'custom' ? 'local' : environmentName;
|
|
122
|
+
// Validate Spark network and client environment combination
|
|
123
|
+
const validation = index$1.validateNetworkCombination(this.sparkNetwork, this.clientEnvironment);
|
|
124
|
+
if (!validation.valid) {
|
|
125
|
+
throw new Error(`Invalid network combination: ${validation.error}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Panic if mainnet for now
|
|
129
|
+
if (this.sparkNetwork === "MAINNET") {
|
|
71
130
|
throw new Error("Mainnet is not supported yet");
|
|
72
131
|
}
|
|
73
|
-
|
|
74
|
-
|
|
132
|
+
// Initialize API client with resolved client configuration
|
|
133
|
+
let resolvedClientConfig;
|
|
134
|
+
if (!isLegacyConfig) {
|
|
135
|
+
const config = configOrOptions;
|
|
136
|
+
let clientConfigParam;
|
|
137
|
+
if ('clientConfig' in config) {
|
|
138
|
+
clientConfigParam = config.clientConfig;
|
|
139
|
+
}
|
|
140
|
+
else if ('clientNetworkConfig' in config) {
|
|
141
|
+
clientConfigParam = config.clientNetworkConfig;
|
|
142
|
+
}
|
|
143
|
+
else if ('clientEnvironment' in config) {
|
|
144
|
+
clientConfigParam = config.clientEnvironment;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
throw new Error('Invalid configuration');
|
|
148
|
+
}
|
|
149
|
+
resolvedClientConfig = index$1.resolveClientNetworkConfig(clientConfigParam);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// Use legacy resolution
|
|
153
|
+
resolvedClientConfig = index$1.getClientNetworkConfig(this.clientEnvironment);
|
|
154
|
+
}
|
|
155
|
+
this.apiClient = new client.ApiClient(resolvedClientConfig);
|
|
75
156
|
this.typedApi = new typedEndpoints.TypedAmmApi(this.apiClient);
|
|
76
157
|
this.authManager = new auth.AuthManager(this.apiClient, "", wallet);
|
|
77
158
|
}
|
|
@@ -86,20 +167,21 @@ class FlashnetClient {
|
|
|
86
167
|
// Get wallet details
|
|
87
168
|
this.publicKey = await this._wallet.getIdentityPublicKey();
|
|
88
169
|
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}`);
|
|
170
|
+
// Deduce Spark network from spark address and validate consistency
|
|
171
|
+
const detectedSparkNetwork = sparkAddress.getSparkNetworkFromAddress(this.sparkAddress);
|
|
172
|
+
if (!detectedSparkNetwork) {
|
|
173
|
+
throw new Error(`Unable to determine Spark network from spark address: ${this.sparkAddress}`);
|
|
174
|
+
}
|
|
175
|
+
// Warn if configured Spark network doesn't match detected network
|
|
176
|
+
if (this.sparkNetwork !== detectedSparkNetwork) {
|
|
177
|
+
console.warn(`Warning: Configured Spark network (${this.sparkNetwork}) doesn't match detected network from address (${detectedSparkNetwork}). Using detected network.`);
|
|
178
|
+
this.sparkNetwork = detectedSparkNetwork;
|
|
93
179
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (detectedNetwork === "MAINNET") {
|
|
180
|
+
// Panic if mainnet for now
|
|
181
|
+
if (this.sparkNetwork === "MAINNET") {
|
|
97
182
|
throw new Error("Mainnet is not supported yet");
|
|
98
183
|
}
|
|
99
|
-
//
|
|
100
|
-
const config = index$1.getNetworkConfig(this.network);
|
|
101
|
-
this.apiClient = new client.ApiClient(config);
|
|
102
|
-
this.typedApi = new typedEndpoints.TypedAmmApi(this.apiClient);
|
|
184
|
+
// Re-initialize auth manager with correct public key
|
|
103
185
|
this.authManager = new auth.AuthManager(this.apiClient, this.publicKey, signer.createWalletSigner(this._wallet));
|
|
104
186
|
// Authenticate
|
|
105
187
|
const token = await this.authManager.authenticate();
|
|
@@ -117,7 +199,7 @@ class FlashnetClient {
|
|
|
117
199
|
/**
|
|
118
200
|
* Ensure a token identifier is in human-readable (Bech32m) form expected by the Spark SDK.
|
|
119
201
|
* 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.
|
|
202
|
+
* Otherwise, it is encoded from the raw hex form using the client's Spark network.
|
|
121
203
|
*/
|
|
122
204
|
toHumanReadableTokenIdentifier(tokenIdentifier) {
|
|
123
205
|
if (tokenIdentifier === index$1.BTC_ASSET_PUBKEY) {
|
|
@@ -126,7 +208,7 @@ class FlashnetClient {
|
|
|
126
208
|
if (tokenIdentifier.startsWith("btkn")) {
|
|
127
209
|
return tokenIdentifier;
|
|
128
210
|
}
|
|
129
|
-
return tokenAddress.
|
|
211
|
+
return tokenAddress.encodeSparkHumanReadableTokenIdentifier(tokenIdentifier, this.sparkNetwork);
|
|
130
212
|
}
|
|
131
213
|
/**
|
|
132
214
|
* Convert a token identifier into the raw hex string form expected by the Flashnet backend.
|
|
@@ -138,7 +220,7 @@ class FlashnetClient {
|
|
|
138
220
|
return tokenIdentifier;
|
|
139
221
|
}
|
|
140
222
|
if (tokenIdentifier.startsWith("btkn")) {
|
|
141
|
-
return tokenAddress.
|
|
223
|
+
return tokenAddress.decodeSparkHumanReadableTokenIdentifier(tokenIdentifier, this.sparkNetwork).tokenIdentifier;
|
|
142
224
|
}
|
|
143
225
|
return tokenIdentifier;
|
|
144
226
|
}
|
|
@@ -352,10 +434,10 @@ class FlashnetClient {
|
|
|
352
434
|
// If pool creation was successful, handle the initial deposit
|
|
353
435
|
if (createResponse.poolId) {
|
|
354
436
|
try {
|
|
355
|
-
// Transfer initial reserve to the pool
|
|
356
|
-
const lpSparkAddress = sparkAddress.
|
|
437
|
+
// Transfer initial reserve to the pool using new address encoding
|
|
438
|
+
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
357
439
|
identityPublicKey: createResponse.poolId,
|
|
358
|
-
network: this.
|
|
440
|
+
network: this.sparkNetwork,
|
|
359
441
|
});
|
|
360
442
|
let assetATransferId;
|
|
361
443
|
if (params.assetAAddress === index$1.BTC_ASSET_PUBKEY) {
|
|
@@ -454,10 +536,10 @@ class FlashnetClient {
|
|
|
454
536
|
if (!balanceCheck.sufficient) {
|
|
455
537
|
throw new Error(`Insufficient balance for swap: ${balanceCheck.message}`);
|
|
456
538
|
}
|
|
457
|
-
// Transfer assets to pool
|
|
458
|
-
const lpSparkAddress = sparkAddress.
|
|
539
|
+
// Transfer assets to pool using new address encoding
|
|
540
|
+
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
459
541
|
identityPublicKey: params.poolId,
|
|
460
|
-
network: this.
|
|
542
|
+
network: this.sparkNetwork,
|
|
461
543
|
});
|
|
462
544
|
let transferId;
|
|
463
545
|
if (params.assetInAddress === index$1.BTC_ASSET_PUBKEY) {
|
|
@@ -546,14 +628,14 @@ class FlashnetClient {
|
|
|
546
628
|
if (!params.hops.length) {
|
|
547
629
|
throw new Error("Route swap requires at least one hop");
|
|
548
630
|
}
|
|
549
|
-
// Transfer initial asset to first pool
|
|
631
|
+
// Transfer initial asset to first pool using new address encoding
|
|
550
632
|
const firstPoolId = params.hops[0]?.poolId;
|
|
551
633
|
if (!firstPoolId) {
|
|
552
634
|
throw new Error("First pool ID is required");
|
|
553
635
|
}
|
|
554
|
-
const lpSparkAddress = sparkAddress.
|
|
636
|
+
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
555
637
|
identityPublicKey: firstPoolId,
|
|
556
|
-
network: this.
|
|
638
|
+
network: this.sparkNetwork,
|
|
557
639
|
});
|
|
558
640
|
let initialTransferId;
|
|
559
641
|
if (params.initialAssetAddress === index$1.BTC_ASSET_PUBKEY) {
|
|
@@ -668,10 +750,10 @@ class FlashnetClient {
|
|
|
668
750
|
if (!balanceCheck.sufficient) {
|
|
669
751
|
throw new Error(`Insufficient balance for adding liquidity: ${balanceCheck.message}`);
|
|
670
752
|
}
|
|
671
|
-
// Transfer assets to pool
|
|
672
|
-
const lpSparkAddress = sparkAddress.
|
|
753
|
+
// Transfer assets to pool using new address encoding
|
|
754
|
+
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
673
755
|
identityPublicKey: params.poolId,
|
|
674
|
-
network: this.
|
|
756
|
+
network: this.sparkNetwork,
|
|
675
757
|
});
|
|
676
758
|
// Transfer asset A
|
|
677
759
|
let assetATransferId;
|
|
@@ -931,20 +1013,38 @@ class FlashnetClient {
|
|
|
931
1013
|
}
|
|
932
1014
|
// ===== Token Address Operations =====
|
|
933
1015
|
/**
|
|
934
|
-
* Encode a token identifier into a human-readable token address using the client's network
|
|
1016
|
+
* Encode a token identifier into a human-readable token address using the client's Spark network
|
|
935
1017
|
* @param tokenIdentifier - Token identifier as hex string or Uint8Array
|
|
936
1018
|
* @returns Human-readable token address
|
|
937
1019
|
*/
|
|
938
1020
|
encodeTokenAddress(tokenIdentifier) {
|
|
939
|
-
return tokenAddress.
|
|
1021
|
+
return tokenAddress.encodeSparkHumanReadableTokenIdentifier(tokenIdentifier, this.sparkNetwork);
|
|
940
1022
|
}
|
|
941
1023
|
/**
|
|
942
1024
|
* Decode a human-readable token address back to its identifier
|
|
943
1025
|
* @param address - Human-readable token address
|
|
944
|
-
* @returns Object containing the token identifier (as hex string) and network
|
|
1026
|
+
* @returns Object containing the token identifier (as hex string) and Spark network
|
|
945
1027
|
*/
|
|
946
1028
|
decodeTokenAddress(address) {
|
|
947
|
-
return tokenAddress.
|
|
1029
|
+
return tokenAddress.decodeSparkHumanReadableTokenIdentifier(address, this.sparkNetwork);
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* @deprecated Use encodeTokenAddress instead - this method uses legacy types
|
|
1033
|
+
* Encode a token identifier into a human-readable token address using legacy types
|
|
1034
|
+
* @param tokenIdentifier - Token identifier as hex string or Uint8Array
|
|
1035
|
+
* @returns Human-readable token address
|
|
1036
|
+
*/
|
|
1037
|
+
encodeLegacyTokenAddress(tokenIdentifier) {
|
|
1038
|
+
return tokenAddress.encodeHumanReadableTokenIdentifier(tokenIdentifier, this.sparkNetwork);
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* @deprecated Use decodeTokenAddress instead - this method uses legacy types
|
|
1042
|
+
* Decode a human-readable token address back to its identifier using legacy types
|
|
1043
|
+
* @param address - Human-readable token address
|
|
1044
|
+
* @returns Object containing the token identifier (as hex string) and network
|
|
1045
|
+
*/
|
|
1046
|
+
decodeLegacyTokenAddress(address) {
|
|
1047
|
+
return tokenAddress.decodeHumanReadableTokenIdentifier(address, this.sparkNetwork);
|
|
948
1048
|
}
|
|
949
1049
|
// ===== Status =====
|
|
950
1050
|
/**
|
|
@@ -959,9 +1059,9 @@ class FlashnetClient {
|
|
|
959
1059
|
* Helper method to add initial liquidity after pool creation
|
|
960
1060
|
*/
|
|
961
1061
|
async addInitialLiquidity(poolId, assetATokenPublicKey, assetBTokenPublicKey, assetAAmount, assetBAmount) {
|
|
962
|
-
const lpSparkAddress = sparkAddress.
|
|
1062
|
+
const lpSparkAddress = sparkAddress.encodeSparkAddressNew({
|
|
963
1063
|
identityPublicKey: poolId,
|
|
964
|
-
network: this.
|
|
1064
|
+
network: this.sparkNetwork,
|
|
965
1065
|
});
|
|
966
1066
|
// Transfer asset A
|
|
967
1067
|
let assetATransferId;
|