@gvnrdao/dh-sdk 0.0.287 → 0.0.288

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.
Files changed (76) hide show
  1. package/browser/dist/397.browser.js +2 -0
  2. package/browser/dist/397.browser.js.LICENSE.txt +1 -0
  3. package/browser/dist/833.browser.js +1 -1
  4. package/browser/dist/browser.js +1 -1
  5. package/browser/dist/browser.js.LICENSE.txt +10 -5
  6. package/dist/deployments.js +45 -21
  7. package/dist/deployments.mjs +45 -21
  8. package/dist/index.js +615 -1100
  9. package/dist/index.mjs +615 -1100
  10. package/package.json +1 -1
  11. package/dist/constants/chunks/contract-abis.d.ts +0 -20
  12. package/dist/constants/chunks/deployment-addresses.d.ts +0 -79
  13. package/dist/constants/chunks/encrypted-provider-params.d.ts +0 -21
  14. package/dist/constants/chunks/environment.browser.d.ts +0 -44
  15. package/dist/constants/chunks/environment.d.ts +0 -57
  16. package/dist/constants/chunks/network-configs.d.ts +0 -72
  17. package/dist/constants/chunks/sdk-config.d.ts +0 -33
  18. package/dist/constants/chunks/sdk-limits.d.ts +0 -66
  19. package/dist/constants/index.d.ts +0 -15
  20. package/dist/contracts/typechain-contracts/common.d.ts +0 -50
  21. package/dist/contracts/typechain-contracts/factories/src/psm/SimplePSMV2__factory.d.ts +0 -1996
  22. package/dist/contracts/typechain-contracts/src/psm/SimplePSMV2.d.ts +0 -1198
  23. package/dist/graphs/client.d.ts +0 -22
  24. package/dist/graphs/diamond-hands.d.ts +0 -259
  25. package/dist/index.d.ts +0 -56
  26. package/dist/interfaces/chunks/btc.i.d.ts +0 -36
  27. package/dist/interfaces/chunks/config.i.d.ts +0 -270
  28. package/dist/interfaces/chunks/contract-interactions.i.d.ts +0 -64
  29. package/dist/interfaces/chunks/contract-types.i.d.ts +0 -171
  30. package/dist/interfaces/chunks/lit-actions-results.i.d.ts +0 -165
  31. package/dist/interfaces/chunks/lit-actions.i.d.ts +0 -98
  32. package/dist/interfaces/chunks/loan-operations.i.d.ts +0 -331
  33. package/dist/interfaces/chunks/pkp-integration.i.d.ts +0 -87
  34. package/dist/interfaces/chunks/position-query.i.d.ts +0 -76
  35. package/dist/interfaces/chunks/requests.i.d.ts +0 -55
  36. package/dist/interfaces/chunks/ucd-minting.i.d.ts +0 -34
  37. package/dist/interfaces/chunks/utility.i.d.ts +0 -64
  38. package/dist/interfaces/index.d.ts +0 -17
  39. package/dist/modules/bitcoin/bitcoin-operations.module.d.ts +0 -254
  40. package/dist/modules/cache/cache-manager.module.d.ts +0 -259
  41. package/dist/modules/contract/contract-manager.module.d.ts +0 -152
  42. package/dist/modules/diamond-hands-sdk.d.ts +0 -969
  43. package/dist/modules/loan/loan-creator.module.d.ts +0 -132
  44. package/dist/modules/loan/loan-query.module.d.ts +0 -204
  45. package/dist/modules/mock/mock-token-manager.module.d.ts +0 -83
  46. package/dist/modules/pkp/pkp-manager.module.d.ts +0 -136
  47. package/dist/modules/withdrawal-address/withdrawal-address.module.d.ts +0 -78
  48. package/dist/protocol/protocol-pause.d.ts +0 -19
  49. package/dist/server.d.ts +0 -17
  50. package/dist/types/authorization-params.d.ts +0 -160
  51. package/dist/types/branded/domain-values.d.ts +0 -138
  52. package/dist/types/branded/ids.d.ts +0 -23
  53. package/dist/types/event-types.d.ts +0 -261
  54. package/dist/types/graph-dtos.d.ts +0 -228
  55. package/dist/types/loanStatus.d.ts +0 -10
  56. package/dist/types/protocol-event-types.d.ts +0 -99
  57. package/dist/types/result.d.ts +0 -120
  58. package/dist/utils/address-conversion.utils.d.ts +0 -51
  59. package/dist/utils/bitcoin-address-cache.utils.d.ts +0 -87
  60. package/dist/utils/bitcoin-provider.utils.d.ts +0 -84
  61. package/dist/utils/btc-withdrawal-message.d.ts +0 -60
  62. package/dist/utils/chunks/bitcoin-utils.d.ts +0 -85
  63. package/dist/utils/chunks/eip1559-broadcast.utils.d.ts +0 -33
  64. package/dist/utils/eip712-login.d.ts +0 -34
  65. package/dist/utils/error-handler.d.ts +0 -106
  66. package/dist/utils/ethers-interop.utils.d.ts +0 -146
  67. package/dist/utils/extend-authorization.utils.d.ts +0 -61
  68. package/dist/utils/lit-signature.utils.d.ts +0 -6
  69. package/dist/utils/logger.utils.d.ts +0 -142
  70. package/dist/utils/mint-authorization.utils.d.ts +0 -248
  71. package/dist/utils/position-delegate.utils.d.ts +0 -41
  72. package/dist/utils/quantum-timing.d.ts +0 -75
  73. package/dist/utils/server-session.d.ts +0 -50
  74. package/dist/utils/service-endpoint-policy.d.ts +0 -16
  75. package/dist/utils/signature-tempering.utils.d.ts +0 -34
  76. package/dist/utils/telegram-messaging.utils.d.ts +0 -188
@@ -1,60 +0,0 @@
1
- /**
2
- * Helpers for building the EIP-191 `execute-btc-withdrawal` envelope that the
3
- * `btc-transaction-signer` LIT Action verifies.
4
- *
5
- * Pulled out of the CLI's executePendingWithdrawal util so the SDK and CLI
6
- * use the same logic and signing rules.
7
- */
8
- import { type Signer } from "ethers";
9
- export interface BtcExecuteSignParams {
10
- positionId: string;
11
- txid: string;
12
- vout: number;
13
- networkFee: number;
14
- chainId: number;
15
- signer: Signer;
16
- }
17
- export interface BtcExecuteSignedEnvelope {
18
- positionId: string;
19
- txid: string;
20
- vout: number;
21
- satoshis: number;
22
- /** Bitcoin destination address bound into the signature. */
23
- targetAddress: string;
24
- /** Authorized withdrawal amount (sats) bound into the signature. */
25
- targetAmount: number;
26
- networkFee: number;
27
- chainId: number;
28
- /** Quantum-aligned timestamp (start of a 60s quantum). */
29
- timestamp: number;
30
- /** EIP-191 signature over the message hash. */
31
- userSignature: string;
32
- /** Address recovered from the signer (borrower). */
33
- borrowerAddress: string;
34
- }
35
- /**
36
- * Build the quantum-aligned timestamp + EIP-191 signature the
37
- * `/api/lit/pending-withdrawals/execute` endpoint expects.
38
- *
39
- * Audit CRIT-1: the signed message now binds `targetAddress` and `targetAmount`
40
- * in addition to the UTXO identifier. The previous shape bound only the UTXO,
41
- * delegating destination/amount enforcement to the Lit Action's on-chain
42
- * `getAuthorizedSpends` lookup. That single defense was reliable in practice
43
- * but the user-signed message is now self-describing — the Lit Action
44
- * cross-checks the user-signed values against the on-chain authorizer record
45
- * and refuses any disagreement, so a bug or future loosening of one side does
46
- * not silently redirect funds.
47
- *
48
- * Caller passes the UTXO satoshis (from Phase 1 result) AND the user-authorized
49
- * destination + amount; this helper returns everything the server needs to
50
- * delegate to the BTC signer LIT Action.
51
- *
52
- * Wire-compat: this is a coordinated breaking change — the new SDK signatures
53
- * are not accepted by an older btc-transaction-signer Lit Action, and the new
54
- * Lit Action does not accept older SDK signatures. Deploy together.
55
- */
56
- export declare function buildBtcExecuteEnvelope(params: BtcExecuteSignParams & {
57
- satoshis: number;
58
- targetAddress: string;
59
- targetAmount: number;
60
- }): Promise<BtcExecuteSignedEnvelope>;
@@ -1,85 +0,0 @@
1
- import { BitcoinAddressCache } from "../bitcoin-address-cache.utils";
2
- import type { BitcoinAddresses } from "../../interfaces";
3
- /**
4
- * Initialize the global address cache with sensible defaults
5
- */
6
- export declare function initializeAddressCache(config?: {
7
- maxSize?: number;
8
- ttlMs?: number;
9
- debug?: boolean;
10
- }): void;
11
- /**
12
- * Get the global address cache instance
13
- */
14
- export declare function getAddressCache(): BitcoinAddressCache | null;
15
- /**
16
- * Convert hex string to Uint8Array
17
- * @param hexString Hex string
18
- * @returns Uint8Array
19
- */
20
- export declare const hexToUint8Array: (hexString: string) => Uint8Array;
21
- /**
22
- * SHA256 hash using Node.js crypto module
23
- * @param data Uint8Array
24
- * @returns Uint8Array
25
- */
26
- export declare const sha256: (data: Uint8Array) => Uint8Array;
27
- /**
28
- * RIPEMD160 hash using native Web Crypto API
29
- * @param data Uint8Array
30
- * @returns Promise<Uint8Array>
31
- */
32
- export declare const ripemd160: (data: Uint8Array) => Uint8Array;
33
- /**
34
- * Convert CryptoJS WordArray to Uint8Array (fallback for RIPEMD160)
35
- * @param wordArray CryptoJS WordArray
36
- * @returns Uint8Array
37
- */
38
- export declare const wordArrayToUint8Array: (wordArray: any) => Uint8Array;
39
- /**
40
- * Generate a Bitcoin address from a PKP public key for regtest or mainnet.
41
- * @param pkpPublicKey Hex string public key (with or without '0x' prefix)
42
- * @param network "regtest" | "mainnet" | "testnet"
43
- * @returns Bitcoin address (string)
44
- */
45
- export declare function getBitcoinAddressFromPkp(pkpPublicKey: string, network?: "regtest" | "mainnet" | "testnet"): Promise<string>;
46
- /**
47
- * Generate multiple Bitcoin addresses from a PKP public key for different networks.
48
- * Uses caching to avoid repeated SHA256+RIPEMD160 operations for the same PKP ID.
49
- * @param pkpPublicKey Hex string public key (with or without '0x' prefix)
50
- * @returns Object containing addresses for different networks
51
- */
52
- export declare function getBitcoinAddressesFromPkp(pkpPublicKey: string): Promise<BitcoinAddresses>;
53
- export declare class BitcoinUtils {
54
- /**
55
- * Validate a Bitcoin address across mainnet / testnet / regtest with full
56
- * checksum verification.
57
- *
58
- * Audit H-12: the previous implementation was a permissive regex with no
59
- * checksum check — garbage like `bc1qqqqqqqqqq` passed. The new
60
- * implementation uses the `bech32` and `bs58check` packages (both already
61
- * in deps) to validate the actual checksum, and rejects unknown HRPs /
62
- * version bytes / witness program lengths.
63
- */
64
- static validateAddress(address: string): boolean;
65
- static formatTransaction(hash: string, amount: string, recipient: string): {
66
- hash: string;
67
- amount: string;
68
- recipient: string;
69
- timestamp: number;
70
- };
71
- static calculateFee(inputAmount: string, outputAmount: string): string;
72
- /**
73
- * Generate Bitcoin addresses from PKP public key
74
- * @param pkpPublicKey PKP public key
75
- * @param network Bitcoin network
76
- * @returns Bitcoin address
77
- */
78
- static getBitcoinAddress(pkpPublicKey: string, network?: "regtest" | "mainnet" | "testnet"): Promise<string>;
79
- /**
80
- * Generate Bitcoin addresses for all networks
81
- * @param pkpPublicKey PKP public key
82
- * @returns Object with addresses for all networks
83
- */
84
- static getAllBitcoinAddresses(pkpPublicKey: string): Promise<BitcoinAddresses>;
85
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * EIP-1559 transaction broadcast helpers for paths that need explicit gas limits
3
- * (e.g. large mintUCD) without manual signDigest / eth_sendRawTransaction.
4
- */
5
- import { type Provider, type Signer, type TransactionResponse } from "ethers";
6
- /** Observed mintUCD + LIT validation can exceed 7M gas; cap avoids block limit issues. */
7
- export declare const MINT_UCD_GAS_CEILING: bigint;
8
- /**
9
- * Fixed-gas ceiling for the withdrawBTC raw-tx fallback (used when estimateGas
10
- * is unavailable on the RPC). The on-chain flow now spans PositionManager →
11
- * CollateralManager → LoanOperationsManager → BTCSpendAuthorizer plus the audit
12
- * #3 Chainlink feed-staleness gate and the BitcoinWithdrawalAddressRegistry
13
- * allowlist STATICCALL; observed end-to-end cost is ~1.0–1.3M gas, so the prior
14
- * hardcoded 1,000,000 limit caused a nested out-of-gas. 3M gives ~2x headroom
15
- * while staying well under the block gas limit.
16
- */
17
- export declare const WITHDRAW_BTC_GAS_CEILING: bigint;
18
- /** Headroom on eth_estimateGas (25%). */
19
- export declare const MINT_UCD_ESTIMATE_MARGIN_BPS = 2500;
20
- /**
21
- * Returns gas limit with margin, capped, or null if estimateGas reverts/fails.
22
- */
23
- export declare function estimateContractCallGasWithMargin(provider: Provider, from: string, to: string, data: string, marginBps: number, ceiling: bigint): Promise<bigint | null>;
24
- export declare function resolveEip1559FeeFields(provider: Provider): Promise<{
25
- maxFeePerGas: bigint;
26
- maxPriorityFeePerGas: bigint;
27
- }>;
28
- export declare function sendEip1559Transaction(params: {
29
- signer: Signer;
30
- to: string;
31
- data: string;
32
- gasLimit: bigint;
33
- }): Promise<TransactionResponse>;
@@ -1,34 +0,0 @@
1
- /**
2
- * Build + sign the `DhServerLogin` EIP-712 envelope the lit-ops-server's
3
- * `POST /api/auth/login` route expects. Used by both the CLI helper and
4
- * frontends that consume the SDK directly.
5
- */
6
- import { Signer, TypedDataField } from "ethers";
7
- export interface DhServerLoginMessage {
8
- address: string;
9
- issuedAt: number;
10
- nonce: string;
11
- /** Audit M-8: service endpoint URL this login targets (replay-binds to one service). */
12
- audience?: string;
13
- }
14
- export interface DhServerLoginPayload {
15
- chainId: number;
16
- message: DhServerLoginMessage;
17
- signature: string;
18
- }
19
- export declare function buildLoginDomain(chainId: number): {
20
- name: string;
21
- version: string;
22
- chainId: number;
23
- };
24
- export declare const LOGIN_TYPES: Record<string, TypedDataField[]>;
25
- /** Audit M-8: login types with the audience binding. */
26
- export declare const LOGIN_TYPES_WITH_AUDIENCE: Record<string, TypedDataField[]>;
27
- /**
28
- * Sign a fresh login envelope. Caller POSTs the returned `payload` to the
29
- * server's `/api/auth/login` route.
30
- *
31
- * Audit M-8: pass `audience` (the service endpoint URL being logged into) to bind the login to
32
- * one service. Omit it for legacy compatibility during the migration window.
33
- */
34
- export declare function buildSignedLoginPayload(signer: Signer, chainId: number, audience?: string): Promise<DhServerLoginPayload>;
@@ -1,106 +0,0 @@
1
- /**
2
- * Production-Ready Error Handler for PKP Validation and Loan Creation
3
- */
4
- /**
5
- * Error categories for SDK operations
6
- */
7
- export declare enum ErrorCategory {
8
- CONFIGURATION = "CONFIGURATION",
9
- INITIALIZATION = "INITIALIZATION",
10
- NETWORK = "NETWORK",
11
- CONTRACT = "CONTRACT",
12
- PKP = "PKP",
13
- BITCOIN = "BITCOIN",
14
- AUTHORIZATION = "AUTHORIZATION",
15
- VALIDATION = "VALIDATION",
16
- TRANSACTION = "TRANSACTION",
17
- SUBGRAPH = "SUBGRAPH",
18
- CACHE = "CACHE",
19
- UNKNOWN = "UNKNOWN"
20
- }
21
- /**
22
- * Error severity levels
23
- */
24
- export declare enum ErrorSeverity {
25
- LOW = "LOW",
26
- MEDIUM = "MEDIUM",
27
- HIGH = "HIGH",
28
- CRITICAL = "CRITICAL"
29
- }
30
- /**
31
- * Modern SDK Error class with structured error handling
32
- */
33
- export declare class SDKError extends Error {
34
- readonly code: string;
35
- readonly category: ErrorCategory;
36
- readonly severity: ErrorSeverity;
37
- readonly retryable: boolean;
38
- readonly context?: Record<string, unknown>;
39
- readonly originalError?: Error;
40
- readonly cause?: unknown;
41
- readonly timestamp: number;
42
- constructor(params: {
43
- code?: string;
44
- message: string;
45
- category: ErrorCategory;
46
- severity: ErrorSeverity;
47
- retryable?: boolean;
48
- context?: Record<string, unknown>;
49
- originalError?: Error;
50
- cause?: unknown;
51
- });
52
- /**
53
- * Convert to JSON-serializable format
54
- */
55
- toJSON(): {
56
- name: string;
57
- code: string;
58
- message: string;
59
- category: ErrorCategory;
60
- severity: ErrorSeverity;
61
- retryable: boolean;
62
- context: Record<string, unknown> | undefined;
63
- timestamp: number;
64
- stack: string | undefined;
65
- };
66
- }
67
- export interface ErrorContext {
68
- operation: string;
69
- network: string;
70
- timestamp: number;
71
- attemptNumber?: number;
72
- duration?: number;
73
- additionalInfo?: Record<string, any>;
74
- }
75
- export interface PKPValidationError {
76
- code: string;
77
- message: string;
78
- context: ErrorContext;
79
- severity: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
80
- retryable: boolean;
81
- userMessage?: string;
82
- }
83
- export declare class PKPErrorHandler {
84
- static classifyError(error: any, context: ErrorContext): PKPValidationError;
85
- static shouldRetry(error: PKPValidationError, attemptNumber: number, maxAttempts: number): boolean;
86
- static getRetryDelay(error: PKPValidationError, attemptNumber: number): number;
87
- static logError(error: PKPValidationError, context?: {
88
- userId?: string;
89
- sessionId?: string;
90
- }): {
91
- timestamp: string;
92
- errorCode: string;
93
- severity: "LOW" | "MEDIUM" | "HIGH" | "CRITICAL";
94
- operation: string;
95
- network: string;
96
- attemptNumber: number | undefined;
97
- duration: number | undefined;
98
- retryable: boolean;
99
- message: string;
100
- userId: string | undefined;
101
- sessionId: string | undefined;
102
- };
103
- static createUserFriendlyMessage(error: PKPValidationError, context?: {
104
- isRetrying?: boolean;
105
- }): string;
106
- }
@@ -1,146 +0,0 @@
1
- /**
2
- * Ethers v5/v6 Interop Utilities
3
- * Systematic normalization of BigNumber fields for cross-version compatibility
4
- */
5
- /**
6
- * Normalize a single BigNumberish value to string
7
- * Handles ethers v5 BigNumber, native bigint, hex strings, and numbers
8
- * @param value BigNumberish value to normalize
9
- * @returns Normalized string representation
10
- */
11
- export declare function normalizeBigNumberish(value: unknown): string;
12
- /**
13
- * Normalize transaction receipt for cross-version compatibility
14
- * Converts all BigNumber fields to strings
15
- * @param receipt Transaction receipt to normalize
16
- * @returns Normalized transaction receipt
17
- */
18
- export declare function normalizeTransactionReceipt(receipt: unknown): Record<string, unknown> | null | undefined;
19
- /**
20
- * Normalize transaction response for cross-version compatibility
21
- * Converts all BigNumber fields to strings and preserves methods
22
- * @param tx Transaction response to normalize
23
- * @returns Normalized transaction response
24
- */
25
- export declare function normalizeTransactionResponse(tx: unknown): Record<string, unknown> | null | undefined;
26
- /**
27
- * Normalize contract method result for cross-version compatibility
28
- * Recursively converts all BigNumber fields to strings
29
- * @param result Contract method result to normalize
30
- * @returns Normalized result
31
- */
32
- export declare function normalizeContractResult(result: unknown): unknown;
33
- /**
34
- * Normalize event logs for cross-version compatibility
35
- * @param logs Array of event logs to normalize
36
- * @returns Normalized logs
37
- */
38
- export declare function normalizeLogs(logs: unknown): unknown[] | unknown;
39
- /**
40
- * Normalize loan data for cross-version compatibility
41
- * Specifically handles loan-related BigNumber fields
42
- * @param loanData Loan data to normalize
43
- * @returns Normalized loan data
44
- */
45
- export declare function normalizeLoanData(loanData: unknown): Record<string, unknown> | null | undefined;
46
- /**
47
- * Normalize position data for cross-version compatibility
48
- * Specifically handles position-related BigNumber fields
49
- * @param positionData Position data to normalize
50
- * @returns Normalized position data
51
- */
52
- export declare function normalizePositionData(positionData: unknown): Record<string, unknown> | null | undefined;
53
- /**
54
- * Create a comprehensive normalizer for any data structure
55
- * Automatically detects and normalizes BigNumber fields
56
- * @param data Data to normalize
57
- * @returns Normalized data
58
- */
59
- export declare function normalizeForEthersInterop(data: unknown): unknown;
60
- /**
61
- * BigInt Utility Functions for Ethers v6 Compatibility
62
- * Native bigint doesn't have methods like BigNumber did in ethers v5
63
- */
64
- /**
65
- * Convert bigint to number (like BigNumber.toNumber())
66
- * @param value bigint value
67
- * @returns number representation
68
- * @throws if value is too large for safe integer
69
- */
70
- export declare function toNumber(value: bigint): number;
71
- /**
72
- * Greater than comparison (like BigNumber.gt())
73
- * @param a First value
74
- * @param b Second value
75
- * @returns true if a > b
76
- */
77
- export declare function gt(a: bigint, b: bigint): boolean;
78
- /**
79
- * Less than comparison (like BigNumber.lt())
80
- * @param a First value
81
- * @param b Second value
82
- * @returns true if a < b
83
- */
84
- export declare function lt(a: bigint, b: bigint): boolean;
85
- /**
86
- * Addition (like BigNumber.add())
87
- * @param a First value
88
- * @param b Second value
89
- * @returns Sum of a and b
90
- */
91
- export declare function add(a: bigint, b: bigint): bigint;
92
- /**
93
- * Subtraction (like BigNumber.sub())
94
- * @param a First value
95
- * @param b Second value
96
- * @returns Difference of a and b
97
- */
98
- export declare function sub(a: bigint, b: bigint): bigint;
99
- /**
100
- * Multiplication (like BigNumber.mul())
101
- * @param a First value
102
- * @param b Second value
103
- * @returns Product of a and b
104
- */
105
- export declare function mul(a: bigint, b: bigint): bigint;
106
- /**
107
- * Division (like BigNumber.div())
108
- * @param a First value
109
- * @param b Second value
110
- * @returns Quotient of a and b
111
- */
112
- export declare function div(a: bigint, b: bigint): bigint;
113
- /**
114
- * Equals comparison (like BigNumber.eq())
115
- * @param a First value
116
- * @param b Second value
117
- * @returns true if a equals b
118
- */
119
- export declare function eq(a: bigint, b: bigint): boolean;
120
- /**
121
- * Safe wait for transaction confirmation with ethers v5/v6 compatibility
122
- *
123
- * The issue: ethers v5 uses receipt.confirmations() as a function
124
- * while ethers v6 uses receipt.confirmations as a property (number).
125
- * When v5 and v6 are mixed in the dependency tree, the internal
126
- * polling mechanism can fail with "receipt.confirmations is not a function".
127
- *
128
- * This wrapper provides a safe way to wait for transactions that handles
129
- * the version incompatibility gracefully.
130
- *
131
- * @param tx Transaction response with wait() method
132
- * @param confirmations Number of confirmations to wait for (default: 1)
133
- * @param timeout Timeout in milliseconds (default: 60000)
134
- * @returns Normalized transaction receipt
135
- */
136
- export declare function safeWaitForTransaction(tx: {
137
- wait?: (confirmations?: number) => Promise<unknown>;
138
- hash?: string;
139
- provider?: unknown;
140
- }, confirmations?: number, timeout?: number): Promise<Record<string, unknown>>;
141
- /**
142
- * Check if an error is related to ethers v5/v6 compatibility issues
143
- * @param error Error to check
144
- * @returns true if this is an ethers compatibility error
145
- */
146
- export declare function isEthersCompatibilityError(error: unknown): boolean;
@@ -1,61 +0,0 @@
1
- /**
2
- * Extend Position Authorization Utilities
3
- *
4
- * Generates authorization signatures for extend position requests
5
- * that can be verified by the extend-position-validator LIT Action.
6
- */
7
- import { type Wallet } from "ethers";
8
- /**
9
- * Extend Owner Authorization Interface (matches lit-actions)
10
- */
11
- export interface ExtendOwnerAuthorization {
12
- positionId: string;
13
- timestamp: number;
14
- chainId: number;
15
- newTerm: number;
16
- action: string;
17
- signature: string;
18
- callerAddress: string;
19
- }
20
- /**
21
- * Build the extend authorization message hash without signing.
22
- *
23
- * Use this when signing with a smart contract wallet (e.g. Safe) that
24
- * needs to wrap the hash in its own domain before signing.
25
- *
26
- * @param positionId - Position identifier
27
- * @param newTerm - Extension term in months (number)
28
- * @param chainId - Chain ID for cross-chain replay protection
29
- * @returns { hash, timestamp } — pass these to Safe for signing
30
- */
31
- export declare function buildExtendAuthorizationHash(positionId: string, newTerm: number, chainId: number): {
32
- hash: string;
33
- timestamp: number;
34
- };
35
- /**
36
- * Generate extend position authorization signature
37
- *
38
- * Creates a signature that matches the format expected by
39
- * AuthorizationModule.verifyExtendAuthorization in lit-actions.
40
- *
41
- * Message structure:
42
- * solidityKeccak256(
43
- * ["bytes32", "uint256", "uint256", "uint256", "bytes32"],
44
- * [positionId, timestamp, chainId, newTerm, actionHash]
45
- * )
46
- *
47
- * Where:
48
- * - actionHash = keccak256("extend-position")
49
- * - Signer address is recovered from signature by LIT Action
50
- * - LIT Action validates recovered address === position owner
51
- *
52
- * @param positionId - Position identifier
53
- * @param newTerm - Extension term in months (number)
54
- * @param chainId - Chain ID for cross-chain replay protection
55
- * @param signerOrPrecomputed - Either an ethers Wallet (EOA) or { timestamp, signature } for smart contract wallets
56
- * @returns Authorization object with signature
57
- */
58
- export declare function generateExtendAuthorization(positionId: string, newTerm: number, chainId: number, signerOrPrecomputed: Wallet | {
59
- timestamp: number;
60
- signature: string;
61
- }): Promise<ExtendOwnerAuthorization>;
@@ -1,6 +0,0 @@
1
- export declare function extractLitSignature(raw: unknown, key: string): {
2
- signature: string;
3
- envelope?: Record<string, unknown>;
4
- };
5
- export declare function extractOptionalLitSignatureFromEnvelope(envelope: Record<string, unknown> | undefined, key: string): string;
6
- export declare function extractOptionalLitSignature(raw: unknown): string;
@@ -1,142 +0,0 @@
1
- /**
2
- * Minimal Logger Utility
3
- * Provides structured logging with levels and context to keep production output clean
4
- */
5
- export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
6
- export interface LogContext {
7
- operation?: string;
8
- id?: string;
9
- userId?: string;
10
- positionId?: string;
11
- pkpId?: string;
12
- address?: string;
13
- network?: string;
14
- provider?: string;
15
- attempt?: number;
16
- maxAttempts?: number;
17
- duration?: number;
18
- [key: string]: any;
19
- }
20
- export interface LoggerConfig {
21
- enabled: boolean;
22
- level: LogLevel;
23
- includeTimestamp: boolean;
24
- includeContext: boolean;
25
- maxContextKeys: number;
26
- verboseInProduction: boolean;
27
- isProduction: boolean;
28
- }
29
- export declare class Logger {
30
- private config;
31
- private static instance;
32
- constructor(config?: Partial<LoggerConfig>);
33
- /**
34
- * Get or create singleton logger instance
35
- */
36
- static getInstance(config?: Partial<LoggerConfig>): Logger;
37
- /**
38
- * Update logger configuration
39
- */
40
- updateConfig(config: Partial<LoggerConfig>): void;
41
- /**
42
- * Check if a log level should be output
43
- */
44
- private shouldLog;
45
- /**
46
- * Format context object for output
47
- */
48
- private formatContext;
49
- /**
50
- * Format timestamp for output
51
- */
52
- private formatTimestamp;
53
- /**
54
- * Core logging method
55
- */
56
- private log;
57
- /**
58
- * Get prefix for log level
59
- */
60
- private getLevelPrefix;
61
- /**
62
- * Debug level logging
63
- */
64
- debug(message: string, context?: LogContext): void;
65
- /**
66
- * Info level logging
67
- */
68
- info(message: string, context?: LogContext): void;
69
- /**
70
- * Warning level logging
71
- */
72
- warn(message: string, context?: LogContext): void;
73
- /**
74
- * Error level logging
75
- */
76
- error(message: string, context?: LogContext): void;
77
- /**
78
- * Log operation start
79
- */
80
- startOperation(operation: string, context?: LogContext): void;
81
- /**
82
- * Log operation completion
83
- */
84
- completeOperation(operation: string, context?: LogContext): void;
85
- /**
86
- * Log operation failure
87
- */
88
- failOperation(operation: string, error: Error | string, context?: LogContext): void;
89
- /**
90
- * Log retry attempt
91
- */
92
- retry(operation: string, attempt: number, maxAttempts: number, error?: Error, context?: LogContext): void;
93
- /**
94
- * Log cache operations
95
- */
96
- cacheHit(key: string, context?: LogContext): void;
97
- cacheMiss(key: string, context?: LogContext): void;
98
- /**
99
- * Log network operations
100
- */
101
- networkRequest(url: string, method: string, context?: LogContext): void;
102
- networkResponse(url: string, status: number, duration?: number, context?: LogContext): void;
103
- /**
104
- * Log Bitcoin operations
105
- */
106
- bitcoinOperation(operation: string, address?: string, context?: LogContext): void;
107
- /**
108
- * Log contract operations
109
- */
110
- contractOperation(operation: string, contract?: string, context?: LogContext): void;
111
- }
112
- /**
113
- * Get the global logger instance
114
- */
115
- export declare function getLogger(): Logger;
116
- /**
117
- * Create a logger with specific configuration
118
- */
119
- export declare function createLogger(config: Partial<LoggerConfig>): Logger;
120
- /**
121
- * Quick logging functions for common use cases
122
- */
123
- export declare const log: {
124
- debug: (message: string, context?: LogContext) => void;
125
- info: (message: string, context?: LogContext) => void;
126
- warn: (message: string, context?: LogContext) => void;
127
- error: (message: string, context?: LogContext) => void;
128
- start: (operation: string, context?: LogContext) => void;
129
- complete: (operation: string, context?: LogContext) => void;
130
- fail: (operation: string, error: Error | string, context?: LogContext) => void;
131
- retry: (operation: string, attempt: number, maxAttempts: number, error?: Error, context?: LogContext) => void;
132
- cache: {
133
- hit: (key: string, context?: LogContext) => void;
134
- miss: (key: string, context?: LogContext) => void;
135
- };
136
- network: {
137
- request: (url: string, method: string, context?: LogContext) => void;
138
- response: (url: string, status: number, duration?: number, context?: LogContext) => void;
139
- };
140
- bitcoin: (operation: string, address?: string, context?: LogContext) => void;
141
- contract: (operation: string, contract?: string, context?: LogContext) => void;
142
- };