forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.d.cts
More file actions
192 lines (186 loc) · 6.05 KB
/
Copy pathmodels.d.cts
File metadata and controls
192 lines (186 loc) · 6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
interface AuditMetadata {
createdAt: string;
updatedAt: string;
}
interface PaginationQuery {
limit?: number;
cursor?: string;
}
/**
* Represents a monetary amount and currency/asset identifier within Lily Protocol
* and the underlying Stellar network.
*
* All amounts must be formatted as base-10 decimal strings (e.g. `'10.50'`) rather than
* JavaScript numbers to prevent floating-point precision loss and truncation errors.
*
* ### Stellar Asset Semantics:
* - **Native Asset (`XLM`):** Omit `assetIssuer` (or set to `undefined`). Native Stellar Lumens
* have no issuing account.
* - **Issued Assets (e.g. `USDC`, `EURC`):** Specify `assetCode` (1-12 alphanumeric chars) and
* `assetIssuer` (56-character Stellar public key / G-address).
* - **Precision:** Stellar supports up to 7 decimal places (1 stroop = `0.0000001`).
*
* @example
* ```ts
* // Native Stellar Lumens
* const nativeAmount: MoneyAmount = {
* assetCode: 'XLM',
* amount: '25.5000000',
* };
*
* // Issued asset with issuer public key
* const usdcAmount: MoneyAmount = {
* assetCode: 'USDC',
* assetIssuer: 'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN',
* amount: '100.00',
* };
* ```
*/
interface MoneyAmount {
/**
* The asset code representing the currency or token.
*
* For the native network asset, use `'XLM'`. For credit/issued assets, use a 1-to-12 character
* alphanumeric code (Alpha4: 1-4 chars like `'USDC'`; Alpha12: 5-12 chars).
*/
assetCode: string;
/**
* The 56-character Stellar public key (G-address) of the issuing account.
*
* - **Native asset (`XLM`):** Must be omitted or `undefined`.
* - **Issued assets:** Required to uniquely identify the asset on Stellar (alongside `assetCode`),
* linking to the issuer's account and home domain SEP-1 metadata.
*/
assetIssuer?: string;
/**
* The monetary quantity formatted strictly as a base-10 decimal string (e.g., `'10.50'`, `'0.0000001'`).
*
* Floating-point numbers (`number`) and exponential notation (e.g., `'1e-5'`) are prohibited
* to avoid floating-point rounding/truncation bugs. Precision should match the asset's scale,
* up to Stellar's maximum 7 decimal places (1 stroop = 0.0000001).
*/
amount: string;
}
type ResourceStatus = 'pending' | 'active' | 'inactive' | 'failed' | 'paused';
/**
* Normalizes a decimal string amount to exactly two decimal places.
*
* Leading zeros are stripped and the fractional part is truncated (not
* rounded) to two digits and padded with trailing zeros, e.g.
* `'0075.5'` becomes `'75.50'`. The input object is not mutated.
*
* Throws a `RangeError` when the amount is not a base-10 decimal string
* (e.g. exponential notation like `'1e-5'` or a JavaScript number).
*/
declare function normalizeMoneyAmount(input: MoneyAmount): MoneyAmount;
interface Agent extends AuditMetadata {
id: string;
name: string;
description?: string;
status: ResourceStatus;
network: 'stellar-testnet' | 'stellar-mainnet';
identityId?: string;
walletId?: string;
capabilities: readonly string[];
}
interface ListAgentsQuery extends PaginationQuery {
status?: ResourceStatus;
}
interface CreateAgentRequest {
name: string;
description?: string;
network: Agent['network'];
capabilities?: string[];
metadata?: Record<string, string>;
}
interface UpdateAgentRequest {
name?: string;
description?: string;
capabilities?: string[];
status?: ResourceStatus;
}
interface IdentityProfile extends AuditMetadata {
id: string;
agentId: string;
displayName: string;
stellarAddress?: string;
domain?: string;
status: ResourceStatus;
verificationLevel: 'none' | 'basic' | 'enhanced';
}
interface ResolveIdentityRequest {
agentId?: string;
stellarAddress?: string;
domain?: string;
}
interface VerifyIdentityRequest {
identityId: string;
challenge: string;
signature: string;
}
interface VerificationResult {
identityId: string;
verified: boolean;
verifiedAt?: string;
}
type PaymentStatus = 'queued' | 'processing' | 'submitted' | 'settled' | 'failed';
interface Payment extends AuditMetadata {
id: string;
fromWalletId: string;
toAddress: string;
amount: MoneyAmount;
memo?: string;
status: PaymentStatus;
transactionHash?: string;
}
interface PaymentQuoteRequest {
fromWalletId: string;
toAddress: string;
amount: MoneyAmount;
}
interface PaymentQuote {
amount: MoneyAmount;
estimatedFee: MoneyAmount;
expiresAt: string;
}
interface ExecutePaymentRequest {
fromWalletId: string;
toAddress: string;
amount: MoneyAmount;
memo?: string;
/** Sent as the `Idempotency-Key` header when the payment is executed. */
idempotencyKey?: string;
}
interface HealthStatus {
status: 'ok' | 'degraded' | 'down';
version: string;
timestamp: string;
checks: Record<string, 'ok' | 'degraded' | 'down'>;
}
interface ServiceInfo {
name: string;
version: string;
environment: 'development' | 'staging' | 'production';
docsUrl?: string;
}
interface Wallet extends AuditMetadata {
id: string;
agentId: string;
address: string;
network: 'stellar-testnet' | 'stellar-mainnet';
status: ResourceStatus;
balances: readonly MoneyAmount[];
}
interface ProvisionWalletRequest {
agentId: string;
network: Wallet['network'];
fundingAsset?: {
assetCode: string;
amount: string;
};
}
interface WalletProvisioningResult {
wallet: Wallet;
recoveryHint?: string;
}
export { type Agent, type AuditMetadata, type CreateAgentRequest, type ExecutePaymentRequest, type HealthStatus, type IdentityProfile, type ListAgentsQuery, type MoneyAmount, type PaginationQuery, type Payment, type PaymentQuote, type PaymentQuoteRequest, type PaymentStatus, type ProvisionWalletRequest, type ResolveIdentityRequest, type ResourceStatus, type ServiceInfo, type UpdateAgentRequest, type VerificationResult, type VerifyIdentityRequest, type Wallet, type WalletProvisioningResult, normalizeMoneyAmount };