@sequence0/sdk 1.2.0 → 2.0.1
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/core/atomic.d.ts +76 -0
- package/dist/core/atomic.d.ts.map +1 -0
- package/dist/core/atomic.js +39 -0
- package/dist/core/atomic.js.map +1 -0
- package/dist/core/client.d.ts +238 -0
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +536 -4
- package/dist/core/client.js.map +1 -1
- package/dist/core/delegation.d.ts +184 -0
- package/dist/core/delegation.d.ts.map +1 -0
- package/dist/core/delegation.js +37 -0
- package/dist/core/delegation.js.map +1 -0
- package/dist/core/programmable.d.ts +66 -0
- package/dist/core/programmable.d.ts.map +1 -0
- package/dist/core/programmable.js +36 -0
- package/dist/core/programmable.js.map +1 -0
- package/dist/core/solvency.d.ts +223 -0
- package/dist/core/solvency.d.ts.map +1 -0
- package/dist/core/solvency.js +267 -0
- package/dist/core/solvency.js.map +1 -0
- package/dist/core/types.d.ts +11 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/universal-account.d.ts +438 -0
- package/dist/core/universal-account.d.ts.map +1 -0
- package/dist/core/universal-account.js +597 -0
- package/dist/core/universal-account.js.map +1 -0
- package/dist/core/witness.d.ts +197 -0
- package/dist/core/witness.d.ts.map +1 -0
- package/dist/core/witness.js +298 -0
- package/dist/core/witness.js.map +1 -0
- package/dist/erc4337/types.js +2 -2
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/settlement/settlement.d.ts +152 -0
- package/dist/settlement/settlement.d.ts.map +1 -0
- package/dist/settlement/settlement.js +172 -0
- package/dist/settlement/settlement.js.map +1 -0
- package/dist/utils/discovery.js +4 -5
- package/dist/utils/discovery.js.map +1 -1
- package/dist/utils/eip712.js +2 -2
- package/dist/utils/fee.d.ts +2 -2
- package/dist/utils/fee.js +2 -2
- package/dist/utils/http.d.ts.map +1 -1
- package/dist/utils/http.js +6 -1
- package/dist/utils/http.js.map +1 -1
- package/dist/utils/logger.d.ts +3 -3
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +3 -3
- package/dist/utils/logger.js.map +1 -1
- package/dist/wallet/wallet.d.ts +52 -0
- package/dist/wallet/wallet.d.ts.map +1 -1
- package/dist/wallet/wallet.js +204 -0
- package/dist/wallet/wallet.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* KEYSTONE: Universal Account — One Wallet, All Chains
|
|
4
|
+
*
|
|
5
|
+
* A single account identity that works across all 81 supported chains.
|
|
6
|
+
* Threshold keys (secp256k1 + ed25519) are generated once, and chain-
|
|
7
|
+
* specific addresses are derived deterministically. Send any token on
|
|
8
|
+
* any chain from one unified account, with automatic routing to the
|
|
9
|
+
* optimal source chain.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { UniversalAccountClient } from '@sequence0/sdk';
|
|
14
|
+
*
|
|
15
|
+
* const ua = new UniversalAccountClient('http://agent:8080');
|
|
16
|
+
*
|
|
17
|
+
* // Create a universal account
|
|
18
|
+
* const account = await ua.createAccount({
|
|
19
|
+
* ownerSignature: '0x...',
|
|
20
|
+
* timestamp: Date.now(),
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // View all chain addresses
|
|
24
|
+
* const addresses = await ua.getChainAddresses(account.accountId);
|
|
25
|
+
* console.log('Ethereum:', addresses.ethereum.address);
|
|
26
|
+
* console.log('Solana:', addresses.solana.address);
|
|
27
|
+
* console.log('Bitcoin:', addresses.bitcoin.address);
|
|
28
|
+
*
|
|
29
|
+
* // Get unified balance across all chains
|
|
30
|
+
* const balance = await ua.getUnifiedBalance(account.accountId);
|
|
31
|
+
* for (const chain of balance.chains) {
|
|
32
|
+
* console.log(`${chain.chain}: ${chain.nativeBalance} ${chain.nativeSymbol}`);
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // Send — automatic routing picks the best source chain
|
|
36
|
+
* const result = await ua.send({
|
|
37
|
+
* accountId: account.accountId,
|
|
38
|
+
* to: '0xRecipient...',
|
|
39
|
+
* amount: '1.0',
|
|
40
|
+
* token: 'ETH',
|
|
41
|
+
* ownerSignature: '0x...',
|
|
42
|
+
* timestamp: Date.now(),
|
|
43
|
+
* });
|
|
44
|
+
* console.log('Tx:', result.txHash);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.UniversalAccountClient = void 0;
|
|
49
|
+
const errors_1 = require("../utils/errors");
|
|
50
|
+
// ── Universal Account Client ──
|
|
51
|
+
/**
|
|
52
|
+
* Client for the KEYSTONE Universal Account protocol.
|
|
53
|
+
*
|
|
54
|
+
* Communicates with universal account endpoints on the agent node
|
|
55
|
+
* to create accounts, query balances across all chains, and send
|
|
56
|
+
* tokens with automatic chain routing.
|
|
57
|
+
*/
|
|
58
|
+
class UniversalAccountClient {
|
|
59
|
+
/**
|
|
60
|
+
* Create a new UniversalAccountClient.
|
|
61
|
+
*
|
|
62
|
+
* @param agentUrl - Agent node REST API URL (e.g., 'http://agent:8080')
|
|
63
|
+
* @param options - Optional client configuration
|
|
64
|
+
* @param options.timeout - Request timeout in milliseconds (default: 30000)
|
|
65
|
+
*/
|
|
66
|
+
constructor(agentUrl, options) {
|
|
67
|
+
this.baseUrl = agentUrl.replace(/\/+$/, '');
|
|
68
|
+
}
|
|
69
|
+
// ────────────────────────────────────────────────
|
|
70
|
+
// Account Management
|
|
71
|
+
// ────────────────────────────────────────────────
|
|
72
|
+
/**
|
|
73
|
+
* Create a new universal account.
|
|
74
|
+
*
|
|
75
|
+
* Initiates DKG for both secp256k1 and ed25519 curves, derives
|
|
76
|
+
* addresses on all 81 supported chains, and registers the account
|
|
77
|
+
* on the Sequence0 chain.
|
|
78
|
+
*
|
|
79
|
+
* @param options - Account creation options
|
|
80
|
+
* @returns The created account information with all chain addresses
|
|
81
|
+
*
|
|
82
|
+
* @throws {Sequence0Error} If the creation parameters are invalid
|
|
83
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
84
|
+
*/
|
|
85
|
+
async createAccount(options) {
|
|
86
|
+
if (!options.ownerSignature || typeof options.ownerSignature !== 'string') {
|
|
87
|
+
throw new errors_1.Sequence0Error('ownerSignature must be a non-empty string');
|
|
88
|
+
}
|
|
89
|
+
if (!options.timestamp || typeof options.timestamp !== 'number') {
|
|
90
|
+
throw new errors_1.Sequence0Error('timestamp must be a positive number');
|
|
91
|
+
}
|
|
92
|
+
const response = await this.post('/universal/create', {
|
|
93
|
+
threshold: options.threshold ?? 16,
|
|
94
|
+
committee_size: options.committeeSize ?? 24,
|
|
95
|
+
owner_signature: options.ownerSignature,
|
|
96
|
+
timestamp: options.timestamp,
|
|
97
|
+
});
|
|
98
|
+
return this.mapAccountResponse(response);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get a universal account by its account ID.
|
|
102
|
+
*
|
|
103
|
+
* @param accountId - The unique account identifier
|
|
104
|
+
* @returns The account information
|
|
105
|
+
*
|
|
106
|
+
* @throws {Sequence0Error} If the account ID is invalid
|
|
107
|
+
* @throws {NetworkError} If the agent is unreachable or account not found
|
|
108
|
+
*/
|
|
109
|
+
async getAccount(accountId) {
|
|
110
|
+
if (!accountId || typeof accountId !== 'string') {
|
|
111
|
+
throw new errors_1.Sequence0Error('accountId must be a non-empty string');
|
|
112
|
+
}
|
|
113
|
+
const response = await this.get(`/universal/account/${accountId}`);
|
|
114
|
+
return this.mapAccountResponse(response);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Look up a universal account by any of its chain addresses.
|
|
118
|
+
*
|
|
119
|
+
* Given an address on any chain (Ethereum, Bitcoin, Solana, etc.),
|
|
120
|
+
* returns the universal account that owns it.
|
|
121
|
+
*
|
|
122
|
+
* @param address - An address on any supported chain
|
|
123
|
+
* @returns The account information, or null if no account owns this address
|
|
124
|
+
*
|
|
125
|
+
* @throws {Sequence0Error} If the address is invalid
|
|
126
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
127
|
+
*/
|
|
128
|
+
async getAccountByAddress(address) {
|
|
129
|
+
if (!address || typeof address !== 'string') {
|
|
130
|
+
throw new errors_1.Sequence0Error('address must be a non-empty string');
|
|
131
|
+
}
|
|
132
|
+
const response = await this.get(`/universal/lookup/${address}`);
|
|
133
|
+
return this.mapAccountResponse(response);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get all universal accounts owned by a specific owner address.
|
|
137
|
+
*
|
|
138
|
+
* @param ownerAddress - The Ethereum owner address
|
|
139
|
+
* @returns Array of account information objects
|
|
140
|
+
*
|
|
141
|
+
* @throws {Sequence0Error} If the owner address is invalid
|
|
142
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
143
|
+
*/
|
|
144
|
+
async getOwnerAccounts(ownerAddress) {
|
|
145
|
+
if (!ownerAddress || typeof ownerAddress !== 'string') {
|
|
146
|
+
throw new errors_1.Sequence0Error('ownerAddress must be a non-empty string');
|
|
147
|
+
}
|
|
148
|
+
const response = await this.get(`/universal/owner/${ownerAddress}`);
|
|
149
|
+
if (!response || !Array.isArray(response.accounts)) {
|
|
150
|
+
throw new errors_1.Sequence0Error('Invalid response from /universal/owner: missing accounts array');
|
|
151
|
+
}
|
|
152
|
+
return response.accounts.map((a) => this.mapAccountResponse(a));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Deactivate a universal account.
|
|
156
|
+
*
|
|
157
|
+
* Marks the account as inactive. This does not destroy the keys
|
|
158
|
+
* or chain addresses — it prevents new sends from being initiated.
|
|
159
|
+
* Only the account owner can deactivate.
|
|
160
|
+
*
|
|
161
|
+
* @param accountId - The account ID to deactivate
|
|
162
|
+
* @param ownerSignature - Owner signature authorizing deactivation
|
|
163
|
+
* @param timestamp - Unix timestamp of the signature
|
|
164
|
+
*
|
|
165
|
+
* @throws {Sequence0Error} If parameters are invalid
|
|
166
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
167
|
+
*/
|
|
168
|
+
async deactivateAccount(accountId, ownerSignature, timestamp) {
|
|
169
|
+
if (!accountId || typeof accountId !== 'string') {
|
|
170
|
+
throw new errors_1.Sequence0Error('accountId must be a non-empty string');
|
|
171
|
+
}
|
|
172
|
+
if (!ownerSignature || typeof ownerSignature !== 'string') {
|
|
173
|
+
throw new errors_1.Sequence0Error('ownerSignature must be a non-empty string');
|
|
174
|
+
}
|
|
175
|
+
if (!timestamp || typeof timestamp !== 'number') {
|
|
176
|
+
throw new errors_1.Sequence0Error('timestamp must be a positive number');
|
|
177
|
+
}
|
|
178
|
+
await this.post('/universal/deactivate', {
|
|
179
|
+
account_id: accountId,
|
|
180
|
+
owner_signature: ownerSignature,
|
|
181
|
+
timestamp,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
// ────────────────────────────────────────────────
|
|
185
|
+
// Address Management
|
|
186
|
+
// ────────────────────────────────────────────────
|
|
187
|
+
/**
|
|
188
|
+
* Get all chain addresses for a universal account.
|
|
189
|
+
*
|
|
190
|
+
* @param accountId - The account ID
|
|
191
|
+
* @returns Map of chain name to chain address info
|
|
192
|
+
*
|
|
193
|
+
* @throws {Sequence0Error} If the account ID is invalid
|
|
194
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
195
|
+
*/
|
|
196
|
+
async getChainAddresses(accountId) {
|
|
197
|
+
if (!accountId || typeof accountId !== 'string') {
|
|
198
|
+
throw new errors_1.Sequence0Error('accountId must be a non-empty string');
|
|
199
|
+
}
|
|
200
|
+
const response = await this.get(`/universal/addresses/${accountId}`);
|
|
201
|
+
if (!response || typeof response.addresses !== 'object') {
|
|
202
|
+
throw new errors_1.Sequence0Error('Invalid response from /universal/addresses: missing addresses object');
|
|
203
|
+
}
|
|
204
|
+
const result = {};
|
|
205
|
+
for (const [chain, raw] of Object.entries(response.addresses)) {
|
|
206
|
+
result[chain] = this.mapChainAddressResponse(chain, raw);
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Get the address for a specific chain within a universal account.
|
|
212
|
+
*
|
|
213
|
+
* @param accountId - The account ID
|
|
214
|
+
* @param chain - The chain name (e.g., 'ethereum', 'bitcoin', 'solana')
|
|
215
|
+
* @returns The chain address info
|
|
216
|
+
*
|
|
217
|
+
* @throws {Sequence0Error} If parameters are invalid
|
|
218
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
219
|
+
*/
|
|
220
|
+
async getAddressForChain(accountId, chain) {
|
|
221
|
+
if (!accountId || typeof accountId !== 'string') {
|
|
222
|
+
throw new errors_1.Sequence0Error('accountId must be a non-empty string');
|
|
223
|
+
}
|
|
224
|
+
if (!chain || typeof chain !== 'string') {
|
|
225
|
+
throw new errors_1.Sequence0Error('chain must be a non-empty string');
|
|
226
|
+
}
|
|
227
|
+
const addresses = await this.getChainAddresses(accountId);
|
|
228
|
+
const info = addresses[chain];
|
|
229
|
+
if (!info) {
|
|
230
|
+
throw new errors_1.Sequence0Error(`No address found for chain '${chain}' in account ${accountId}`);
|
|
231
|
+
}
|
|
232
|
+
return info;
|
|
233
|
+
}
|
|
234
|
+
// ────────────────────────────────────────────────
|
|
235
|
+
// Balance
|
|
236
|
+
// ────────────────────────────────────────────────
|
|
237
|
+
/**
|
|
238
|
+
* Get unified balance across all chains for a universal account.
|
|
239
|
+
*
|
|
240
|
+
* Agents query balances on all chains where the account has
|
|
241
|
+
* derived addresses and return an aggregated view.
|
|
242
|
+
*
|
|
243
|
+
* @param accountId - The account ID
|
|
244
|
+
* @returns Unified balance with per-chain breakdown
|
|
245
|
+
*
|
|
246
|
+
* @throws {Sequence0Error} If the account ID is invalid
|
|
247
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
248
|
+
*/
|
|
249
|
+
async getUnifiedBalance(accountId) {
|
|
250
|
+
if (!accountId || typeof accountId !== 'string') {
|
|
251
|
+
throw new errors_1.Sequence0Error('accountId must be a non-empty string');
|
|
252
|
+
}
|
|
253
|
+
const response = await this.get(`/universal/balance/${accountId}`);
|
|
254
|
+
return this.mapUnifiedBalanceResponse(response);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Get the balance for a specific chain within a universal account.
|
|
258
|
+
*
|
|
259
|
+
* @param accountId - The account ID
|
|
260
|
+
* @param chain - The chain name (e.g., 'ethereum', 'bitcoin', 'solana')
|
|
261
|
+
* @returns The chain balance
|
|
262
|
+
*
|
|
263
|
+
* @throws {Sequence0Error} If parameters are invalid
|
|
264
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
265
|
+
*/
|
|
266
|
+
async getChainBalance(accountId, chain) {
|
|
267
|
+
if (!accountId || typeof accountId !== 'string') {
|
|
268
|
+
throw new errors_1.Sequence0Error('accountId must be a non-empty string');
|
|
269
|
+
}
|
|
270
|
+
if (!chain || typeof chain !== 'string') {
|
|
271
|
+
throw new errors_1.Sequence0Error('chain must be a non-empty string');
|
|
272
|
+
}
|
|
273
|
+
const response = await this.get(`/universal/balance/${accountId}/${chain}`);
|
|
274
|
+
return this.mapChainBalanceResponse(response);
|
|
275
|
+
}
|
|
276
|
+
// ────────────────────────────────────────────────
|
|
277
|
+
// Send
|
|
278
|
+
// ────────────────────────────────────────────────
|
|
279
|
+
/**
|
|
280
|
+
* Send tokens from a universal account.
|
|
281
|
+
*
|
|
282
|
+
* The agent network automatically selects the optimal source chain
|
|
283
|
+
* based on available balances, gas fees, and confirmation times.
|
|
284
|
+
* Use `preferredChain` to override automatic routing.
|
|
285
|
+
*
|
|
286
|
+
* @param options - Send options
|
|
287
|
+
* @returns The send result with routing decision and request ID for polling
|
|
288
|
+
*
|
|
289
|
+
* @throws {Sequence0Error} If the send parameters are invalid
|
|
290
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* const result = await ua.send({
|
|
295
|
+
* accountId: 'ua-abc123',
|
|
296
|
+
* to: '0xRecipient...',
|
|
297
|
+
* amount: '1.5',
|
|
298
|
+
* token: 'ETH',
|
|
299
|
+
* ownerSignature: '0x...',
|
|
300
|
+
* timestamp: Date.now(),
|
|
301
|
+
* });
|
|
302
|
+
*
|
|
303
|
+
* // Poll for confirmation
|
|
304
|
+
* const status = await ua.getSendStatus(result.requestId);
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
async send(options) {
|
|
308
|
+
if (!options.accountId || typeof options.accountId !== 'string') {
|
|
309
|
+
throw new errors_1.Sequence0Error('accountId must be a non-empty string');
|
|
310
|
+
}
|
|
311
|
+
if (!options.to || typeof options.to !== 'string') {
|
|
312
|
+
throw new errors_1.Sequence0Error('to must be a non-empty string');
|
|
313
|
+
}
|
|
314
|
+
if (!options.amount || typeof options.amount !== 'string') {
|
|
315
|
+
throw new errors_1.Sequence0Error('amount must be a non-empty string');
|
|
316
|
+
}
|
|
317
|
+
if (!options.token || typeof options.token !== 'string') {
|
|
318
|
+
throw new errors_1.Sequence0Error('token must be a non-empty string');
|
|
319
|
+
}
|
|
320
|
+
if (!options.ownerSignature || typeof options.ownerSignature !== 'string') {
|
|
321
|
+
throw new errors_1.Sequence0Error('ownerSignature must be a non-empty string');
|
|
322
|
+
}
|
|
323
|
+
if (!options.timestamp || typeof options.timestamp !== 'number') {
|
|
324
|
+
throw new errors_1.Sequence0Error('timestamp must be a positive number');
|
|
325
|
+
}
|
|
326
|
+
const response = await this.post('/universal/send', {
|
|
327
|
+
account_id: options.accountId,
|
|
328
|
+
to: options.to,
|
|
329
|
+
amount: options.amount,
|
|
330
|
+
token: options.token,
|
|
331
|
+
preferred_chain: options.preferredChain,
|
|
332
|
+
owner_signature: options.ownerSignature,
|
|
333
|
+
timestamp: options.timestamp,
|
|
334
|
+
});
|
|
335
|
+
return this.mapSendResultResponse(response);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Get the current status of a send operation.
|
|
339
|
+
*
|
|
340
|
+
* @param requestId - The send request ID
|
|
341
|
+
* @returns Current status of the send
|
|
342
|
+
*
|
|
343
|
+
* @throws {Sequence0Error} If the request ID is invalid
|
|
344
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
345
|
+
*/
|
|
346
|
+
async getSendStatus(requestId) {
|
|
347
|
+
if (!requestId || typeof requestId !== 'string') {
|
|
348
|
+
throw new errors_1.Sequence0Error('requestId must be a non-empty string');
|
|
349
|
+
}
|
|
350
|
+
const response = await this.get(`/universal/send/${requestId}`);
|
|
351
|
+
return this.mapSendResultResponse(response);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Wait for a send operation to reach a terminal status by polling.
|
|
355
|
+
*
|
|
356
|
+
* Polls the send status endpoint at 2-second intervals until
|
|
357
|
+
* the send is confirmed, fails, or the timeout is exceeded.
|
|
358
|
+
*
|
|
359
|
+
* @param requestId - The send request ID to wait for
|
|
360
|
+
* @param timeout - Max time to wait in ms (default: 120000)
|
|
361
|
+
* @returns The final send result
|
|
362
|
+
*
|
|
363
|
+
* @throws {TimeoutError} If the send is not completed within the timeout
|
|
364
|
+
* @throws {Sequence0Error} If the send fails
|
|
365
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
366
|
+
*/
|
|
367
|
+
async waitForSend(requestId, timeout) {
|
|
368
|
+
if (!requestId || typeof requestId !== 'string') {
|
|
369
|
+
throw new errors_1.Sequence0Error('requestId must be a non-empty string');
|
|
370
|
+
}
|
|
371
|
+
const maxWait = timeout ?? 120000;
|
|
372
|
+
const pollInterval = 2000;
|
|
373
|
+
const startTime = Date.now();
|
|
374
|
+
while (Date.now() - startTime < maxWait) {
|
|
375
|
+
const result = await this.getSendStatus(requestId);
|
|
376
|
+
if (result.status === 'confirmed') {
|
|
377
|
+
return result;
|
|
378
|
+
}
|
|
379
|
+
if (result.status === 'failed') {
|
|
380
|
+
throw new errors_1.Sequence0Error(`Universal send ${requestId} failed: ${result.routing.reason}`);
|
|
381
|
+
}
|
|
382
|
+
// Wait before polling again
|
|
383
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
384
|
+
}
|
|
385
|
+
throw new errors_1.TimeoutError(`Universal send ${requestId} did not complete within ${maxWait}ms`);
|
|
386
|
+
}
|
|
387
|
+
// ────────────────────────────────────────────────
|
|
388
|
+
// Route Preview
|
|
389
|
+
// ────────────────────────────────────────────────
|
|
390
|
+
/**
|
|
391
|
+
* Preview the routing decision for a send without executing it.
|
|
392
|
+
*
|
|
393
|
+
* Use this to show users which chain will be used and the estimated
|
|
394
|
+
* fee before they authorize the send with their signature.
|
|
395
|
+
*
|
|
396
|
+
* @param options - Send options (without ownerSignature and timestamp)
|
|
397
|
+
* @returns The routing decision that would be made
|
|
398
|
+
*
|
|
399
|
+
* @throws {Sequence0Error} If the parameters are invalid
|
|
400
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```typescript
|
|
404
|
+
* const route = await ua.previewRoute({
|
|
405
|
+
* accountId: 'ua-abc123',
|
|
406
|
+
* to: '0xRecipient...',
|
|
407
|
+
* amount: '1.5',
|
|
408
|
+
* token: 'ETH',
|
|
409
|
+
* });
|
|
410
|
+
* console.log(`Will send from ${route.sourceChain} (fee: ${route.estimatedFee})`);
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
async previewRoute(options) {
|
|
414
|
+
if (!options.accountId || typeof options.accountId !== 'string') {
|
|
415
|
+
throw new errors_1.Sequence0Error('accountId must be a non-empty string');
|
|
416
|
+
}
|
|
417
|
+
if (!options.to || typeof options.to !== 'string') {
|
|
418
|
+
throw new errors_1.Sequence0Error('to must be a non-empty string');
|
|
419
|
+
}
|
|
420
|
+
if (!options.amount || typeof options.amount !== 'string') {
|
|
421
|
+
throw new errors_1.Sequence0Error('amount must be a non-empty string');
|
|
422
|
+
}
|
|
423
|
+
if (!options.token || typeof options.token !== 'string') {
|
|
424
|
+
throw new errors_1.Sequence0Error('token must be a non-empty string');
|
|
425
|
+
}
|
|
426
|
+
const response = await this.post('/universal/route', {
|
|
427
|
+
account_id: options.accountId,
|
|
428
|
+
to: options.to,
|
|
429
|
+
amount: options.amount,
|
|
430
|
+
token: options.token,
|
|
431
|
+
preferred_chain: options.preferredChain,
|
|
432
|
+
});
|
|
433
|
+
return this.mapRoutingDecisionResponse(response);
|
|
434
|
+
}
|
|
435
|
+
// ────────────────────────────────────────────────
|
|
436
|
+
// Stats
|
|
437
|
+
// ────────────────────────────────────────────────
|
|
438
|
+
/**
|
|
439
|
+
* Get network-wide Universal Account statistics.
|
|
440
|
+
*
|
|
441
|
+
* @returns Protocol statistics
|
|
442
|
+
*
|
|
443
|
+
* @throws {NetworkError} If the agent is unreachable
|
|
444
|
+
*/
|
|
445
|
+
async getStats() {
|
|
446
|
+
const response = await this.get('/universal/stats');
|
|
447
|
+
if (!response || typeof response.total_accounts !== 'number') {
|
|
448
|
+
throw new errors_1.Sequence0Error('Invalid response from /universal/stats: missing total_accounts');
|
|
449
|
+
}
|
|
450
|
+
return {
|
|
451
|
+
totalAccounts: response.total_accounts,
|
|
452
|
+
totalAddresses: response.total_addresses,
|
|
453
|
+
activeSends: response.active_sends,
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
// ── Internal HTTP helpers ──
|
|
457
|
+
async get(path) {
|
|
458
|
+
const url = `${this.baseUrl}${path}`;
|
|
459
|
+
let res;
|
|
460
|
+
try {
|
|
461
|
+
res = await fetch(url, {
|
|
462
|
+
method: 'GET',
|
|
463
|
+
headers: { 'Content-Type': 'application/json' },
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
catch (err) {
|
|
467
|
+
throw new errors_1.NetworkError(`Failed to reach agent at ${url}: ${err.message}`);
|
|
468
|
+
}
|
|
469
|
+
if (!res.ok) {
|
|
470
|
+
const body = await res.text().catch(() => '');
|
|
471
|
+
throw new errors_1.NetworkError(`GET ${path} failed with status ${res.status}: ${body}`, res.status);
|
|
472
|
+
}
|
|
473
|
+
return res.json();
|
|
474
|
+
}
|
|
475
|
+
async post(path, body) {
|
|
476
|
+
const url = `${this.baseUrl}${path}`;
|
|
477
|
+
let res;
|
|
478
|
+
try {
|
|
479
|
+
res = await fetch(url, {
|
|
480
|
+
method: 'POST',
|
|
481
|
+
headers: { 'Content-Type': 'application/json' },
|
|
482
|
+
body: JSON.stringify(body),
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
catch (err) {
|
|
486
|
+
throw new errors_1.NetworkError(`Failed to reach agent at ${url}: ${err.message}`);
|
|
487
|
+
}
|
|
488
|
+
if (!res.ok) {
|
|
489
|
+
const errBody = await res.text().catch(() => '');
|
|
490
|
+
throw new errors_1.NetworkError(`POST ${path} failed with status ${res.status}: ${errBody}`, res.status);
|
|
491
|
+
}
|
|
492
|
+
return res.json();
|
|
493
|
+
}
|
|
494
|
+
// ── Response Mappers ──
|
|
495
|
+
mapAccountResponse(response) {
|
|
496
|
+
if (!response || typeof response.account_id !== 'string') {
|
|
497
|
+
throw new errors_1.Sequence0Error('Invalid universal account response: missing account_id');
|
|
498
|
+
}
|
|
499
|
+
const chainAddresses = {};
|
|
500
|
+
if (response.chain_addresses && typeof response.chain_addresses === 'object') {
|
|
501
|
+
for (const [chain, raw] of Object.entries(response.chain_addresses)) {
|
|
502
|
+
chainAddresses[chain] = this.mapChainAddressResponse(chain, raw);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return {
|
|
506
|
+
accountId: response.account_id,
|
|
507
|
+
ownerAddress: response.owner_address,
|
|
508
|
+
secp256k1GroupKey: response.secp256k1_group_key,
|
|
509
|
+
ed25519GroupKey: response.ed25519_group_key,
|
|
510
|
+
threshold: response.threshold,
|
|
511
|
+
committeeSize: response.committee_size,
|
|
512
|
+
chainAddresses,
|
|
513
|
+
createdAt: response.created_at,
|
|
514
|
+
isActive: response.is_active ?? true,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
mapChainAddressResponse(chain, response) {
|
|
518
|
+
const validCurves = ['secp256k1', 'ed25519'];
|
|
519
|
+
const curveType = validCurves.includes(response.curve_type)
|
|
520
|
+
? response.curve_type
|
|
521
|
+
: 'secp256k1';
|
|
522
|
+
return {
|
|
523
|
+
chain,
|
|
524
|
+
address: response.address,
|
|
525
|
+
curveType,
|
|
526
|
+
isActive: response.is_active ?? true,
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
mapChainBalanceResponse(response) {
|
|
530
|
+
if (!response || typeof response.chain !== 'string') {
|
|
531
|
+
throw new errors_1.Sequence0Error('Invalid chain balance response: missing chain');
|
|
532
|
+
}
|
|
533
|
+
const tokens = Array.isArray(response.tokens)
|
|
534
|
+
? response.tokens.map((t) => ({
|
|
535
|
+
symbol: t.symbol,
|
|
536
|
+
contractAddress: t.contract_address,
|
|
537
|
+
balance: t.balance,
|
|
538
|
+
decimals: t.decimals,
|
|
539
|
+
}))
|
|
540
|
+
: [];
|
|
541
|
+
return {
|
|
542
|
+
chain: response.chain,
|
|
543
|
+
address: response.address,
|
|
544
|
+
nativeBalance: response.native_balance,
|
|
545
|
+
nativeSymbol: response.native_symbol,
|
|
546
|
+
tokens,
|
|
547
|
+
lastUpdated: response.last_updated,
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
mapUnifiedBalanceResponse(response) {
|
|
551
|
+
if (!response || typeof response.account_id !== 'string') {
|
|
552
|
+
throw new errors_1.Sequence0Error('Invalid unified balance response: missing account_id');
|
|
553
|
+
}
|
|
554
|
+
const chains = Array.isArray(response.chains)
|
|
555
|
+
? response.chains.map((c) => this.mapChainBalanceResponse(c))
|
|
556
|
+
: [];
|
|
557
|
+
return {
|
|
558
|
+
accountId: response.account_id,
|
|
559
|
+
chains,
|
|
560
|
+
totalChains: response.total_chains,
|
|
561
|
+
lastAggregated: response.last_aggregated,
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
mapRoutingDecisionResponse(response) {
|
|
565
|
+
if (!response || typeof response.source_chain !== 'string') {
|
|
566
|
+
throw new errors_1.Sequence0Error('Invalid routing decision response: missing source_chain');
|
|
567
|
+
}
|
|
568
|
+
return {
|
|
569
|
+
sourceChain: response.source_chain,
|
|
570
|
+
sourceAddress: response.source_address,
|
|
571
|
+
destinationChain: response.destination_chain,
|
|
572
|
+
destinationAddress: response.destination_address,
|
|
573
|
+
amount: response.amount,
|
|
574
|
+
token: response.token,
|
|
575
|
+
estimatedFee: response.estimated_fee,
|
|
576
|
+
reason: response.reason,
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
mapSendResultResponse(response) {
|
|
580
|
+
if (!response || typeof response.request_id !== 'string') {
|
|
581
|
+
throw new errors_1.Sequence0Error('Invalid send result response: missing request_id');
|
|
582
|
+
}
|
|
583
|
+
const validStatuses = ['pending', 'routing', 'signing', 'broadcasting', 'confirmed', 'failed'];
|
|
584
|
+
const status = validStatuses.includes(response.status)
|
|
585
|
+
? response.status
|
|
586
|
+
: 'pending';
|
|
587
|
+
return {
|
|
588
|
+
requestId: response.request_id,
|
|
589
|
+
routing: this.mapRoutingDecisionResponse(response.routing),
|
|
590
|
+
status,
|
|
591
|
+
txHash: response.tx_hash,
|
|
592
|
+
signature: response.signature,
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
exports.UniversalAccountClient = UniversalAccountClient;
|
|
597
|
+
//# sourceMappingURL=universal-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal-account.js","sourceRoot":"","sources":["../../src/core/universal-account.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;;;AAEH,4CAA6E;AA4M7E,iCAAiC;AAEjC;;;;;;GAMG;AACH,MAAa,sBAAsB;IAG/B;;;;;;OAMG;IACH,YAAY,QAAgB,EAAE,OAA8B;QACxD,IAAI,CAAC,OAAO,GAAG,QA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