@gala-chain/launchpad-sdk 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +628 -0
- package/dist/LaunchpadSDK.d.ts +573 -0
- package/dist/LaunchpadSDK.d.ts.map +1 -0
- package/dist/api/CommentAPI.d.ts +119 -0
- package/dist/api/CommentAPI.d.ts.map +1 -0
- package/dist/api/LaunchpadAPI.d.ts +440 -0
- package/dist/api/LaunchpadAPI.d.ts.map +1 -0
- package/dist/api/TradeAPI.d.ts +164 -0
- package/dist/api/TradeAPI.d.ts.map +1 -0
- package/dist/api/Trading.d.ts +176 -0
- package/dist/api/Trading.d.ts.map +1 -0
- package/dist/api/UserAPI.d.ts +426 -0
- package/dist/api/UserAPI.d.ts.map +1 -0
- package/dist/api/WebSocketAPI.d.ts +156 -0
- package/dist/api/WebSocketAPI.d.ts.map +1 -0
- package/dist/api/dto/BondingCurveDTOs.d.ts +142 -0
- package/dist/api/dto/BondingCurveDTOs.d.ts.map +1 -0
- package/dist/api/services/BundleService.d.ts +105 -0
- package/dist/api/services/BundleService.d.ts.map +1 -0
- package/dist/api/services/SignatureService.d.ts +71 -0
- package/dist/api/services/SignatureService.d.ts.map +1 -0
- package/dist/api/services/TokenClassKeyService.d.ts +116 -0
- package/dist/api/services/TokenClassKeyService.d.ts.map +1 -0
- package/dist/api/services/WebSocketManager.d.ts +99 -0
- package/dist/api/services/WebSocketManager.d.ts.map +1 -0
- package/dist/api/services/WebSocketService.d.ts +66 -0
- package/dist/api/services/WebSocketService.d.ts.map +1 -0
- package/dist/auth/SignatureAuth.d.ts +92 -0
- package/dist/auth/SignatureAuth.d.ts.map +1 -0
- package/dist/auth/types.d.ts +41 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/helpers/sdk.d.ts +75 -0
- package/dist/helpers/sdk.d.ts.map +1 -0
- package/dist/helpers/wallet.d.ts +60 -0
- package/dist/helpers/wallet.d.ts.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/comment.dto.d.ts +160 -0
- package/dist/types/comment.dto.d.ts.map +1 -0
- package/dist/types/common.d.ts +108 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/dto.d.ts +145 -0
- package/dist/types/dto.d.ts.map +1 -0
- package/dist/types/launchpad.dto.d.ts +517 -0
- package/dist/types/launchpad.dto.d.ts.map +1 -0
- package/dist/types/launchpad.validation.d.ts +40 -0
- package/dist/types/launchpad.validation.d.ts.map +1 -0
- package/dist/types/trade.dto.d.ts +446 -0
- package/dist/types/trade.dto.d.ts.map +1 -0
- package/dist/types/user.dto.d.ts +330 -0
- package/dist/types/user.dto.d.ts.map +1 -0
- package/dist/utils/VaultCache.d.ts +73 -0
- package/dist/utils/VaultCache.d.ts.map +1 -0
- package/dist/utils/adapters.d.ts +111 -0
- package/dist/utils/adapters.d.ts.map +1 -0
- package/dist/utils/agent-config.d.ts +206 -0
- package/dist/utils/agent-config.d.ts.map +1 -0
- package/dist/utils/http.d.ts +85 -0
- package/dist/utils/http.d.ts.map +1 -0
- package/dist/utils/multipart.d.ts +60 -0
- package/dist/utils/multipart.d.ts.map +1 -0
- package/dist/utils/precision-math.d.ts +37 -0
- package/dist/utils/precision-math.d.ts.map +1 -0
- package/dist/utils/validation.d.ts +131 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/wallet.d.ts +174 -0
- package/dist/utils/wallet.d.ts.map +1 -0
- package/package.json +151 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket Connection Manager
|
|
3
|
+
*
|
|
4
|
+
* Singleton manager for WebSocket connections to prevent duplicate connections
|
|
5
|
+
* when multiple SDK instances are used. Each unique endpoint gets a single
|
|
6
|
+
* shared connection with reference counting for proper cleanup.
|
|
7
|
+
*
|
|
8
|
+
* @category Services
|
|
9
|
+
* @since 2.1.0
|
|
10
|
+
*/
|
|
11
|
+
import { WebSocketService, WebSocketConfig } from './WebSocketService';
|
|
12
|
+
/**
|
|
13
|
+
* Singleton WebSocket Connection Manager
|
|
14
|
+
*
|
|
15
|
+
* Manages WebSocket connections across multiple SDK instances to ensure
|
|
16
|
+
* efficient resource usage and prevent duplicate connections to the same endpoint.
|
|
17
|
+
*
|
|
18
|
+
* Key features:
|
|
19
|
+
* - Single connection per unique WebSocket endpoint
|
|
20
|
+
* - Reference counting for proper cleanup
|
|
21
|
+
* - Automatic cleanup when all references are removed
|
|
22
|
+
* - Thread-safe for concurrent SDK instances
|
|
23
|
+
*/
|
|
24
|
+
export declare class WebSocketManager {
|
|
25
|
+
private static instances;
|
|
26
|
+
/**
|
|
27
|
+
* Get or create a shared WebSocket service instance
|
|
28
|
+
*
|
|
29
|
+
* @param url WebSocket endpoint URL
|
|
30
|
+
* @param config WebSocket configuration
|
|
31
|
+
* @param debug Enable debug logging
|
|
32
|
+
* @returns Shared WebSocketService instance
|
|
33
|
+
*/
|
|
34
|
+
static getInstance(url: string, config: WebSocketConfig, debug?: boolean): WebSocketService;
|
|
35
|
+
/**
|
|
36
|
+
* Release a reference to a WebSocket service
|
|
37
|
+
*
|
|
38
|
+
* When reference count reaches zero, the connection is automatically closed
|
|
39
|
+
* and the service is removed from the manager.
|
|
40
|
+
*
|
|
41
|
+
* @param url WebSocket endpoint URL
|
|
42
|
+
* @param debug Enable debug logging
|
|
43
|
+
*/
|
|
44
|
+
static releaseReference(url: string, debug?: boolean): void;
|
|
45
|
+
/**
|
|
46
|
+
* Disconnect a specific WebSocket connection
|
|
47
|
+
*
|
|
48
|
+
* Forces disconnection regardless of reference count.
|
|
49
|
+
* Useful for error recovery or manual cleanup.
|
|
50
|
+
*
|
|
51
|
+
* @param url WebSocket endpoint URL
|
|
52
|
+
* @param debug Enable debug logging
|
|
53
|
+
*/
|
|
54
|
+
static disconnect(url: string, debug?: boolean): void;
|
|
55
|
+
/**
|
|
56
|
+
* Disconnect all WebSocket connections
|
|
57
|
+
*
|
|
58
|
+
* Forces disconnection of all managed connections.
|
|
59
|
+
* Useful for application shutdown or testing cleanup.
|
|
60
|
+
*
|
|
61
|
+
* @param debug Enable debug logging
|
|
62
|
+
*/
|
|
63
|
+
static disconnectAll(debug?: boolean): void;
|
|
64
|
+
/**
|
|
65
|
+
* Get information about currently managed connections
|
|
66
|
+
*
|
|
67
|
+
* @returns Array of connection info objects
|
|
68
|
+
*/
|
|
69
|
+
static getConnectionInfo(): Array<{
|
|
70
|
+
url: string;
|
|
71
|
+
referenceCount: number;
|
|
72
|
+
isConnected: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Check if a connection exists for the given URL
|
|
76
|
+
*
|
|
77
|
+
* @param url WebSocket endpoint URL
|
|
78
|
+
* @returns True if connection exists
|
|
79
|
+
*/
|
|
80
|
+
static hasConnection(url: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Get the reference count for a specific URL
|
|
83
|
+
*
|
|
84
|
+
* @param url WebSocket endpoint URL
|
|
85
|
+
* @returns Reference count (0 if no connection exists)
|
|
86
|
+
*/
|
|
87
|
+
static getReferenceCount(url: string): number;
|
|
88
|
+
/**
|
|
89
|
+
* Create a consistent key from URL for internal mapping
|
|
90
|
+
*
|
|
91
|
+
* Normalizes URLs to prevent duplicate connections for equivalent URLs
|
|
92
|
+
* (e.g., with/without trailing slashes)
|
|
93
|
+
*
|
|
94
|
+
* @param url WebSocket endpoint URL
|
|
95
|
+
* @returns Normalized key string
|
|
96
|
+
*/
|
|
97
|
+
private static createKey;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=WebSocketManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebSocketManager.d.ts","sourceRoot":"","sources":["../../../src/api/services/WebSocketManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAQvE;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAmD;IAE3E;;;;;;;OAOG;IACH,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,GAAE,OAAe,GAAG,gBAAgB;IA+BlG;;;;;;;;OAQG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,IAAI;IA4BlE;;;;;;;;OAQG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,IAAI;IAc5D;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,GAAE,OAAe,GAAG,IAAI;IAelD;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,IAAI,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,CAAC;IAQhG;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI1C;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAK7C;;;;;;;;OAQG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;CAGzB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Socket.IO Service for Real-time Transaction Monitoring
|
|
3
|
+
*
|
|
4
|
+
* This service provides real-time monitoring of bundle transactions
|
|
5
|
+
* using Socket.IO connections to track transaction completion status.
|
|
6
|
+
*
|
|
7
|
+
* @category Services
|
|
8
|
+
* @since 2.0.0
|
|
9
|
+
*/
|
|
10
|
+
export interface TransactionStatus {
|
|
11
|
+
transactionId: string;
|
|
12
|
+
status: 'pending' | 'processing' | 'completed' | 'failed' | 'timeout';
|
|
13
|
+
message?: string;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
blockHash?: string;
|
|
16
|
+
gasUsed?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface WebSocketConfig {
|
|
19
|
+
url: string;
|
|
20
|
+
reconnectAttempts?: number;
|
|
21
|
+
reconnectDelay?: number;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
}
|
|
24
|
+
export declare class WebSocketService {
|
|
25
|
+
private socket;
|
|
26
|
+
private config;
|
|
27
|
+
private listeners;
|
|
28
|
+
private reconnectCount;
|
|
29
|
+
private debug;
|
|
30
|
+
private isSocketIOAvailable;
|
|
31
|
+
constructor(config: WebSocketConfig, debug?: boolean);
|
|
32
|
+
/**
|
|
33
|
+
* Check if Socket.IO is available in the current environment
|
|
34
|
+
* Handles both browser and Node.js environments gracefully
|
|
35
|
+
*/
|
|
36
|
+
private checkSocketIOAvailability;
|
|
37
|
+
/**
|
|
38
|
+
* Connect to Socket.IO endpoint
|
|
39
|
+
*/
|
|
40
|
+
connect(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Monitor a specific transaction
|
|
43
|
+
*/
|
|
44
|
+
monitorTransaction(transactionId: string, callback: (status: TransactionStatus) => void): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Wait for transaction completion
|
|
47
|
+
*/
|
|
48
|
+
waitForTransaction(transactionId: string): Promise<TransactionStatus>;
|
|
49
|
+
/**
|
|
50
|
+
* Map Socket.IO status to our standard status
|
|
51
|
+
*/
|
|
52
|
+
private mapSocketStatus;
|
|
53
|
+
/**
|
|
54
|
+
* Handle Socket.IO reconnection
|
|
55
|
+
*/
|
|
56
|
+
private handleReconnect;
|
|
57
|
+
/**
|
|
58
|
+
* Disconnect Socket.IO
|
|
59
|
+
*/
|
|
60
|
+
disconnect(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Check connection status
|
|
63
|
+
*/
|
|
64
|
+
isConnected(): boolean;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=WebSocketService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebSocketService.d.ts","sourceRoot":"","sources":["../../../src/api/services/WebSocketService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,SAAS,CAA+D;IAChF,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,mBAAmB,CAAU;gBAEzB,MAAM,EAAE,eAAe,EAAE,KAAK,GAAE,OAAe;IAa3D;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAmBjC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA6D9B;;OAEG;IACG,kBAAkB,CACtB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAC5C,OAAO,CAAC,IAAI,CAAC;IA0EhB;;OAEG;IACG,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAY3E;;OAEG;IACH,OAAO,CAAC,eAAe;IAiBvB;;OAEG;YACW,eAAe;IAqB7B;;OAEG;IACH,UAAU,IAAI,IAAI;IAiBlB;;OAEG;IACH,WAAW,IAAI,OAAO;CAGvB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { AuthConfig, SignatureResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Handles signature-based authentication for the Launchpad SDK
|
|
4
|
+
*
|
|
5
|
+
* This class generates signatures that are used in the `Sign` header
|
|
6
|
+
* for authenticating requests to the backend API.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SignatureAuth {
|
|
9
|
+
private readonly wallet;
|
|
10
|
+
private readonly messagePrefix;
|
|
11
|
+
constructor(config: AuthConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Generates a signature for the current timestamp
|
|
14
|
+
*
|
|
15
|
+
* The message format is: "Create a GalaChain Wallet {13-digit-timestamp}"
|
|
16
|
+
* This signature is used in the `Sign` header for API authentication.
|
|
17
|
+
*
|
|
18
|
+
* @returns Promise<SignatureResult> The signature data
|
|
19
|
+
* @throws AuthError If signature generation fails
|
|
20
|
+
*/
|
|
21
|
+
generateSignature(): Promise<SignatureResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the wallet address in the required eth|{address} format
|
|
24
|
+
*
|
|
25
|
+
* @returns The formatted address
|
|
26
|
+
*/
|
|
27
|
+
getAddress(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the raw Ethereum wallet address (0x prefixed)
|
|
30
|
+
*
|
|
31
|
+
* @returns The Ethereum address with 0x prefix
|
|
32
|
+
*/
|
|
33
|
+
getEthereumAddress(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Formats an Ethereum address to the required backend format
|
|
36
|
+
*
|
|
37
|
+
* @param address The Ethereum address (with or without 0x prefix)
|
|
38
|
+
* @returns Formatted address as eth|{40-hex-chars}
|
|
39
|
+
*/
|
|
40
|
+
private formatAddress;
|
|
41
|
+
/**
|
|
42
|
+
* Signs a message and returns result in Ethereum format (for tests/debugging)
|
|
43
|
+
*
|
|
44
|
+
* @param message The message to sign
|
|
45
|
+
* @returns Promise<SignatureResult> The signature data with Ethereum addresses
|
|
46
|
+
* @throws AuthError If signature generation fails
|
|
47
|
+
*/
|
|
48
|
+
signMessage(message: string): Promise<SignatureResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Generates authentication headers for HTTP requests
|
|
51
|
+
*
|
|
52
|
+
* @param url The request URL path
|
|
53
|
+
* @param method The HTTP method
|
|
54
|
+
* @returns Promise<Record<string, string>> Authentication headers
|
|
55
|
+
* @throws AuthError If header generation fails
|
|
56
|
+
*/
|
|
57
|
+
generateAuthHeaders(url: string, method: string): Promise<Record<string, string>>;
|
|
58
|
+
/**
|
|
59
|
+
* Signs typed data using EIP-712 standard
|
|
60
|
+
*
|
|
61
|
+
* @param domain The EIP-712 domain
|
|
62
|
+
* @param types The EIP-712 types
|
|
63
|
+
* @param message The message to sign
|
|
64
|
+
* @returns Promise<string> The signature
|
|
65
|
+
* @throws AuthError If signature generation fails
|
|
66
|
+
*/
|
|
67
|
+
signTypedData(domain: any, types: any, message: any): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Generates a signature for a custom message (for endpoint-specific auth)
|
|
70
|
+
*
|
|
71
|
+
* This method signs a custom message without adding a timestamp,
|
|
72
|
+
* used for endpoints that require specific message signatures like "Update profile".
|
|
73
|
+
*
|
|
74
|
+
* @param message The custom message to sign
|
|
75
|
+
* @returns Promise<SignatureResult> The signature data
|
|
76
|
+
* @throws AuthError If signature generation fails
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const signatureAuth = new SignatureAuth({ wallet, messagePrefix: 'Custom' });
|
|
81
|
+
* const result = await signatureAuth.generateCustomSignature("Update profile");
|
|
82
|
+
* console.log('Signature:', result.signature);
|
|
83
|
+
* console.log('Address:', result.address); // eth|{address} format
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
generateCustomSignature(message: string): Promise<SignatureResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Validates that the wallet is properly configured
|
|
89
|
+
*/
|
|
90
|
+
private validateWallet;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=SignatureAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignatureAuth.d.ts","sourceRoot":"","sources":["../../src/auth/SignatureAuth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,eAAe,EAA4B,MAAM,SAAS,CAAC;AAEhF;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,MAAM,EAAE,UAAU;IAe9B;;;;;;;;OAQG;IACG,iBAAiB,IAAI,OAAO,CAAC,eAAe,CAAC;IA0BnD;;;;OAIG;IACH,UAAU,IAAI,MAAM;IAIpB;;;;OAIG;IACH,kBAAkB,IAAI,MAAM;IAI5B;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAerB;;;;;;OAMG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAsB5D;;;;;;;OAOG;IACG,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IA2BvF;;;;;;;;OAQG;IACG,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAc3E;;;;;;;;;;;;;;;;;OAiBG;IACG,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA+BxE;;OAEG;IACH,OAAO,CAAC,cAAc;CAuBvB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Wallet } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for signature-based authentication
|
|
4
|
+
*/
|
|
5
|
+
export interface AuthConfig {
|
|
6
|
+
/** The ethers wallet used for signing messages */
|
|
7
|
+
wallet: Wallet;
|
|
8
|
+
/** Optional custom message prefix (defaults to "Create a GalaChain Wallet") */
|
|
9
|
+
messagePrefix?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Result of signature generation for authentication
|
|
13
|
+
*/
|
|
14
|
+
export interface SignatureResult {
|
|
15
|
+
/** The message that was signed */
|
|
16
|
+
message: string;
|
|
17
|
+
/** The signature to use in the Sign header */
|
|
18
|
+
signature: string;
|
|
19
|
+
/** The address that signed the message in eth|{address} format */
|
|
20
|
+
address: string;
|
|
21
|
+
/** Timestamp when the signature was created */
|
|
22
|
+
timestamp: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Authentication error types
|
|
26
|
+
*/
|
|
27
|
+
export declare enum AuthErrorType {
|
|
28
|
+
WALLET_NOT_CONNECTED = "WALLET_NOT_CONNECTED",
|
|
29
|
+
SIGNATURE_FAILED = "SIGNATURE_FAILED",
|
|
30
|
+
INVALID_ADDRESS = "INVALID_ADDRESS",
|
|
31
|
+
MESSAGE_GENERATION_FAILED = "MESSAGE_GENERATION_FAILED"
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Authentication error class
|
|
35
|
+
*/
|
|
36
|
+
export declare class AuthError extends Error {
|
|
37
|
+
readonly type: AuthErrorType;
|
|
38
|
+
readonly originalError?: Error | undefined;
|
|
39
|
+
constructor(type: AuthErrorType, message: string, originalError?: Error | undefined);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,oBAAY,aAAa;IACvB,oBAAoB,yBAAyB;IAC7C,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,yBAAyB,8BAA8B;CACxD;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;aAEhB,IAAI,EAAE,aAAa;aAEnB,aAAa,CAAC,EAAE,KAAK;gBAFrB,IAAI,EAAE,aAAa,EACnC,OAAO,EAAE,MAAM,EACC,aAAa,CAAC,EAAE,KAAK,YAAA;CAKxC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Launchpad SDK factory functions
|
|
3
|
+
*
|
|
4
|
+
* Provides convenient factory functions for creating configured SDK instances
|
|
5
|
+
* with smart defaults and automatic wallet handling.
|
|
6
|
+
*/
|
|
7
|
+
import { Wallet } from 'ethers';
|
|
8
|
+
import { LaunchpadSDK, LaunchpadSDKConfig } from '../LaunchpadSDK';
|
|
9
|
+
/**
|
|
10
|
+
* Creates a fully configured LaunchpadSDK instance with smart defaults
|
|
11
|
+
*
|
|
12
|
+
* This factory function simplifies SDK initialization by:
|
|
13
|
+
* - Auto-detecting wallet input format (private key, mnemonic, or Wallet instance)
|
|
14
|
+
* - Providing smart environment-based defaults
|
|
15
|
+
* - Handling wallet creation automatically
|
|
16
|
+
*
|
|
17
|
+
* @param options Configuration options
|
|
18
|
+
* @param options.wallet Wallet input (private key string, mnemonic string, or Wallet instance)
|
|
19
|
+
* @param options.config Additional SDK configuration options
|
|
20
|
+
* @returns Fully configured LaunchpadSDK instance
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
|
|
25
|
+
*
|
|
26
|
+
* // Generate new random wallet and create SDK
|
|
27
|
+
* const sdk = createLaunchpadSDK();
|
|
28
|
+
*
|
|
29
|
+
* // From private key
|
|
30
|
+
* const sdkFromPk = createLaunchpadSDK({
|
|
31
|
+
* wallet: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12'
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* // From mnemonic
|
|
35
|
+
* const sdkFromMnemonic = createLaunchpadSDK({
|
|
36
|
+
* wallet: 'word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12'
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // With additional config
|
|
40
|
+
* const sdkWithConfig = createLaunchpadSDK({
|
|
41
|
+
* wallet: process.env.PRIVATE_KEY,
|
|
42
|
+
* config: {
|
|
43
|
+
* debug: true,
|
|
44
|
+
* timeout: 60000
|
|
45
|
+
* }
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // Ready to use immediately
|
|
49
|
+
* const balance = await sdk.user.getGalaBalance({ walletAddress: sdk.getAddress() });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function createLaunchpadSDK(options?: {
|
|
53
|
+
wallet?: string | Wallet;
|
|
54
|
+
config?: Partial<LaunchpadSDKConfig>;
|
|
55
|
+
}): LaunchpadSDK;
|
|
56
|
+
/**
|
|
57
|
+
* Quick start SDK with test configuration
|
|
58
|
+
*
|
|
59
|
+
* Creates SDK instance optimized for testing and development.
|
|
60
|
+
* Uses test-friendly defaults and enables debug mode.
|
|
61
|
+
*
|
|
62
|
+
* @param walletInput Optional wallet input (generates random if not provided)
|
|
63
|
+
* @returns LaunchpadSDK configured for testing
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* // Quick test SDK
|
|
68
|
+
* const testSdk = createTestLaunchpadSDK();
|
|
69
|
+
*
|
|
70
|
+
* // With specific wallet
|
|
71
|
+
* const testSdkWithWallet = createTestLaunchpadSDK('0x1234...');
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function createTestLaunchpadSDK(walletInput?: string): LaunchpadSDK;
|
|
75
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/helpers/sdk.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE;IAC3C,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACtC,GAAG,YAAY,CA+Bf;AAGD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,CAmBzE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet creation helper functions
|
|
3
|
+
*
|
|
4
|
+
* Provides convenient functions for creating wallets with auto-detection
|
|
5
|
+
* of input formats (private key vs mnemonic phrase).
|
|
6
|
+
*/
|
|
7
|
+
import { GeneratedWallet } from '../utils/wallet';
|
|
8
|
+
/**
|
|
9
|
+
* Creates a wallet with smart input detection
|
|
10
|
+
*
|
|
11
|
+
* Automatically detects whether the input is a private key or mnemonic phrase,
|
|
12
|
+
* and creates the appropriate wallet. If no input is provided, generates a new
|
|
13
|
+
* random wallet.
|
|
14
|
+
*
|
|
15
|
+
* @param input Optional wallet creation input
|
|
16
|
+
* - No input: Creates a new random wallet
|
|
17
|
+
* - 64 hex characters (with/without 0x): Treated as private key
|
|
18
|
+
* - 12 or 24 space-separated words: Treated as mnemonic phrase
|
|
19
|
+
* @returns Generated wallet with all necessary information
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { createWallet } from '@gala-chain/launchpad-sdk';
|
|
24
|
+
*
|
|
25
|
+
* // Generate new random wallet
|
|
26
|
+
* const newWallet = createWallet();
|
|
27
|
+
*
|
|
28
|
+
* // From private key
|
|
29
|
+
* const pkWallet = createWallet('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12');
|
|
30
|
+
*
|
|
31
|
+
* // From mnemonic
|
|
32
|
+
* const mnemonicWallet = createWallet('word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12');
|
|
33
|
+
*
|
|
34
|
+
* // Use with SDK
|
|
35
|
+
* const sdk = new LaunchpadSDK({ wallet: newWallet.wallet });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function createWallet(input?: string): GeneratedWallet;
|
|
39
|
+
/**
|
|
40
|
+
* Validates wallet input format without creating wallet
|
|
41
|
+
*
|
|
42
|
+
* @param input Input to validate
|
|
43
|
+
* @returns Object with validation result and detected format
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const result = validateWalletInput('0x1234...');
|
|
48
|
+
* if (result.valid) {
|
|
49
|
+
* console.log(`Detected format: ${result.format}`);
|
|
50
|
+
* } else {
|
|
51
|
+
* console.log(`Validation error: ${result.error}`);
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function validateWalletInput(input: string): {
|
|
56
|
+
valid: boolean;
|
|
57
|
+
format?: 'private_key' | 'mnemonic' | 'random';
|
|
58
|
+
error?: string;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/helpers/wallet.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAe,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CA8B5D;AAmCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG;IAClD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,aAAa,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAuBA"}
|