@oasisprotocol/privana-sdk 0.5.0 → 0.5.2
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/{chunk-ACLJPC75.cjs → chunk-UHXVYWTF.cjs} +936 -20
- package/dist/chunk-UHXVYWTF.cjs.map +1 -0
- package/dist/{chunk-54FC6TO3.js → chunk-ZVUMV4NR.js} +907 -23
- package/dist/chunk-ZVUMV4NR.js.map +1 -0
- package/dist/index.cjs +823 -538
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +58 -341
- package/dist/index.d.ts +58 -341
- package/dist/index.js +532 -334
- package/dist/index.js.map +1 -1
- package/dist/on-ramp.cjs +3 -3
- package/dist/on-ramp.d.cts +40 -4
- package/dist/on-ramp.d.ts +40 -4
- package/dist/on-ramp.js +1 -1
- package/dist/pending-lock-BdkuMjmY.d.cts +600 -0
- package/dist/pending-lock-BdkuMjmY.d.ts +600 -0
- package/package.json +1 -1
- package/dist/chunk-54FC6TO3.js.map +0 -1
- package/dist/chunk-ACLJPC75.cjs.map +0 -1
- package/dist/on-ramp-XLXsy0aI.d.cts +0 -130
- package/dist/on-ramp-XLXsy0aI.d.ts +0 -130
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import { WalletClient } from 'viem';
|
|
2
|
+
|
|
3
|
+
var networks = {
|
|
4
|
+
testnet: {
|
|
5
|
+
chainId: 23295,
|
|
6
|
+
name: "Sapphire Testnet",
|
|
7
|
+
accountingContract: "0xad3C76e4E621C0cfF7540479Ee9B0A945723A642",
|
|
8
|
+
apiUrl: "https://api.testnet.privana.finance"
|
|
9
|
+
},
|
|
10
|
+
mainnet: {
|
|
11
|
+
chainId: 23294,
|
|
12
|
+
name: "Sapphire Mainnet",
|
|
13
|
+
accountingContract: "0x0000000000000000000000000000000000000000",
|
|
14
|
+
apiUrl: ""
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var config = {
|
|
18
|
+
networks: networks
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type Address = `0x${string}`;
|
|
22
|
+
type Bytes32 = `0x${string}`;
|
|
23
|
+
type HexString = `0x${string}`;
|
|
24
|
+
type IntegerLike = string | number;
|
|
25
|
+
type HostedAuthResponseMode = 'web_message' | 'redirect';
|
|
26
|
+
type Network = keyof typeof config.networks;
|
|
27
|
+
interface NetworkConfig {
|
|
28
|
+
chainId: number;
|
|
29
|
+
name: string;
|
|
30
|
+
accountingContract: Address;
|
|
31
|
+
apiUrl: string;
|
|
32
|
+
/** Versioned MoonPay REST API base URL (default: 'https://api.moonpay.com/v3'). */
|
|
33
|
+
moonpayApiUrl?: string;
|
|
34
|
+
/**
|
|
35
|
+
* MoonPay publishable API key ('pk_test_…' / 'pk_live_…' — MoonPay infers the
|
|
36
|
+
* environment from the prefix). Enables the credit-card deposit flow: the SDK
|
|
37
|
+
* mounts its own MoonPayProvider around the credit-card subtree, so consumers
|
|
38
|
+
* don't wrap the app in one (and don't pay MoonPay's CDN script cost at app start).
|
|
39
|
+
*/
|
|
40
|
+
moonpayApiKey?: string;
|
|
41
|
+
}
|
|
42
|
+
declare const NETWORK_CONFIG: {
|
|
43
|
+
readonly testnet: {
|
|
44
|
+
readonly accountingContract: Address;
|
|
45
|
+
readonly chainId: number;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly apiUrl: string;
|
|
48
|
+
};
|
|
49
|
+
readonly mainnet: {
|
|
50
|
+
readonly accountingContract: Address;
|
|
51
|
+
readonly chainId: number;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly apiUrl: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
declare function getChainId(network: Network): number;
|
|
57
|
+
declare function getAccountingContract(network: Network): Address;
|
|
58
|
+
declare function getApiUrl(network: Network): string;
|
|
59
|
+
declare function normalizeHex(value: string): HexString;
|
|
60
|
+
declare function normalizeAddress(value: string): Address;
|
|
61
|
+
|
|
62
|
+
interface TokenConfig {
|
|
63
|
+
id: Bytes32;
|
|
64
|
+
symbol: string;
|
|
65
|
+
decimals: number;
|
|
66
|
+
contract: Address;
|
|
67
|
+
name: string;
|
|
68
|
+
chainId: number;
|
|
69
|
+
/**
|
|
70
|
+
* MoonPay-specific currency identifier for the credit-card on-ramp (e.g. 'usdc'
|
|
71
|
+
* or 'usdc_base'). Populated SDK-side from a stopgap map until the token API
|
|
72
|
+
* returns it; `undefined` when the token isn't supported by MoonPay.
|
|
73
|
+
*/
|
|
74
|
+
moonpayCurrencyCode?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface DepositAddressRequest {
|
|
78
|
+
chain_type?: string;
|
|
79
|
+
version?: number;
|
|
80
|
+
}
|
|
81
|
+
interface DepositCheckRequest {
|
|
82
|
+
chain_type?: string;
|
|
83
|
+
chain_id: number;
|
|
84
|
+
tx_hash: HexString;
|
|
85
|
+
amount: IntegerLike;
|
|
86
|
+
log_index?: number;
|
|
87
|
+
version?: number;
|
|
88
|
+
}
|
|
89
|
+
interface PendingDepositsRequest {
|
|
90
|
+
chain_id: number;
|
|
91
|
+
version?: number;
|
|
92
|
+
token_address?: Address;
|
|
93
|
+
lookback_blocks?: number;
|
|
94
|
+
}
|
|
95
|
+
interface LockFundsRequest {
|
|
96
|
+
service_address: Address;
|
|
97
|
+
token_id: Bytes32;
|
|
98
|
+
amount: IntegerLike;
|
|
99
|
+
expiry: IntegerLike;
|
|
100
|
+
nonce: IntegerLike;
|
|
101
|
+
signature: HexString;
|
|
102
|
+
}
|
|
103
|
+
interface ModifyLockRequest {
|
|
104
|
+
lock_id: number;
|
|
105
|
+
amount: IntegerLike;
|
|
106
|
+
new_expiry: IntegerLike;
|
|
107
|
+
nonce: IntegerLike;
|
|
108
|
+
signature: HexString;
|
|
109
|
+
}
|
|
110
|
+
interface UnlockFundsRequest {
|
|
111
|
+
user_address: Address;
|
|
112
|
+
lock_id: number;
|
|
113
|
+
}
|
|
114
|
+
interface UnlockAllExpiredRequest {
|
|
115
|
+
user_address: Address;
|
|
116
|
+
}
|
|
117
|
+
interface TransferFundsRequest {
|
|
118
|
+
to_address: Address;
|
|
119
|
+
token_id: Bytes32;
|
|
120
|
+
amount: IntegerLike;
|
|
121
|
+
nonce: IntegerLike;
|
|
122
|
+
signature: HexString;
|
|
123
|
+
}
|
|
124
|
+
interface TransferLockedFundsRequest {
|
|
125
|
+
user_address: Address;
|
|
126
|
+
lock_id: number;
|
|
127
|
+
to_address: Address;
|
|
128
|
+
amount: IntegerLike;
|
|
129
|
+
service_address: Address;
|
|
130
|
+
nonce: IntegerLike;
|
|
131
|
+
signature: HexString;
|
|
132
|
+
}
|
|
133
|
+
interface WithdrawalRequest {
|
|
134
|
+
token_id: Bytes32;
|
|
135
|
+
amount: IntegerLike;
|
|
136
|
+
nonce: IntegerLike;
|
|
137
|
+
signature: HexString;
|
|
138
|
+
}
|
|
139
|
+
interface WithdrawFromLockRequest {
|
|
140
|
+
to_address: Address;
|
|
141
|
+
lock_id: number;
|
|
142
|
+
amount: IntegerLike;
|
|
143
|
+
nonce: IntegerLike;
|
|
144
|
+
signature: HexString;
|
|
145
|
+
}
|
|
146
|
+
interface BatchBalancesRequest {
|
|
147
|
+
token_ids: Bytes32[];
|
|
148
|
+
}
|
|
149
|
+
interface HistoryRequest {
|
|
150
|
+
offset?: number;
|
|
151
|
+
limit?: number;
|
|
152
|
+
}
|
|
153
|
+
interface SiweLoginRequest {
|
|
154
|
+
siwe_message: string;
|
|
155
|
+
signature: HexString;
|
|
156
|
+
}
|
|
157
|
+
interface HostedAuthAuthorizeUrlRequest {
|
|
158
|
+
client_id: string;
|
|
159
|
+
redirect_uri: string;
|
|
160
|
+
code_challenge: string;
|
|
161
|
+
state: string;
|
|
162
|
+
chain_id: number;
|
|
163
|
+
response_mode?: HostedAuthResponseMode;
|
|
164
|
+
code_challenge_method?: 'S256';
|
|
165
|
+
}
|
|
166
|
+
interface HostedAuthTokenExchangeRequest {
|
|
167
|
+
grant_type?: 'authorization_code';
|
|
168
|
+
code: string;
|
|
169
|
+
code_verifier: string;
|
|
170
|
+
client_id: string;
|
|
171
|
+
redirect_uri: string;
|
|
172
|
+
}
|
|
173
|
+
interface JwtRefreshRequest {
|
|
174
|
+
refresh_token: string;
|
|
175
|
+
}
|
|
176
|
+
interface JwtLogoutRequest {
|
|
177
|
+
refresh_token?: string;
|
|
178
|
+
revoke_all?: boolean;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
interface MinDepositAmounts {
|
|
182
|
+
native: string;
|
|
183
|
+
erc20: string;
|
|
184
|
+
}
|
|
185
|
+
interface DepositAddressResponse {
|
|
186
|
+
deposit_address: Address;
|
|
187
|
+
chain_type: string;
|
|
188
|
+
version: number;
|
|
189
|
+
min_deposit: Record<string, MinDepositAmounts>;
|
|
190
|
+
}
|
|
191
|
+
interface DepositCheckResponse {
|
|
192
|
+
status: 'credited' | 'pending' | 'error';
|
|
193
|
+
deposit_id?: string | null;
|
|
194
|
+
amount?: string | null;
|
|
195
|
+
token_address?: Address | null;
|
|
196
|
+
detail?: string | null;
|
|
197
|
+
}
|
|
198
|
+
type PendingDepositStatus = 'discovered' | 'processing';
|
|
199
|
+
interface PendingDeposit {
|
|
200
|
+
chain_id: number;
|
|
201
|
+
tx_hash: HexString;
|
|
202
|
+
log_index: number;
|
|
203
|
+
/** Base units. */
|
|
204
|
+
amount: string;
|
|
205
|
+
token_address: Address;
|
|
206
|
+
token_id: Bytes32;
|
|
207
|
+
block_number: number;
|
|
208
|
+
version: number;
|
|
209
|
+
status: PendingDepositStatus;
|
|
210
|
+
/** Set only when status is 'processing'. */
|
|
211
|
+
deposit_id: string | null;
|
|
212
|
+
}
|
|
213
|
+
interface PendingDepositsResponse {
|
|
214
|
+
pending: PendingDeposit[];
|
|
215
|
+
scanned_from_block: number;
|
|
216
|
+
scanned_to_block: number;
|
|
217
|
+
}
|
|
218
|
+
interface TransactionSubmissionResponse {
|
|
219
|
+
submission_id: string;
|
|
220
|
+
status: string;
|
|
221
|
+
detail?: string;
|
|
222
|
+
}
|
|
223
|
+
interface BalanceResponse {
|
|
224
|
+
user_address: Address;
|
|
225
|
+
token_id: Bytes32;
|
|
226
|
+
balance: string;
|
|
227
|
+
token_symbol: string;
|
|
228
|
+
chain_id: string;
|
|
229
|
+
}
|
|
230
|
+
interface TokenBalance {
|
|
231
|
+
token_id: Bytes32;
|
|
232
|
+
balance: string;
|
|
233
|
+
token_symbol: string;
|
|
234
|
+
chain_id: string;
|
|
235
|
+
}
|
|
236
|
+
interface BatchBalancesResponse {
|
|
237
|
+
user_address: Address;
|
|
238
|
+
balances: TokenBalance[];
|
|
239
|
+
}
|
|
240
|
+
type HistoryKind = 'deposit' | 'withdraw' | 'createLock' | 'transferFromLockOut' | 'transferFromLockIn' | 'transferBalanceOut' | 'transferBalanceIn' | 'modifyLock' | 'unlockLock' | 'unknown';
|
|
241
|
+
interface HistoryEntry {
|
|
242
|
+
kind: HistoryKind;
|
|
243
|
+
timestamp: number;
|
|
244
|
+
token_id?: Bytes32 | null;
|
|
245
|
+
amount?: string | null;
|
|
246
|
+
counterparty?: Address | null;
|
|
247
|
+
deposit_id?: Bytes32 | null;
|
|
248
|
+
chain_id?: number | null;
|
|
249
|
+
}
|
|
250
|
+
interface HistoryResponse {
|
|
251
|
+
history: HistoryEntry[];
|
|
252
|
+
total: number;
|
|
253
|
+
}
|
|
254
|
+
interface TokenInfoResponse {
|
|
255
|
+
token_id: Bytes32;
|
|
256
|
+
token_type: number;
|
|
257
|
+
token_type_name: string;
|
|
258
|
+
data: string;
|
|
259
|
+
chain_id: number;
|
|
260
|
+
chain_name: string;
|
|
261
|
+
token_address: Address;
|
|
262
|
+
symbol: string;
|
|
263
|
+
name: string;
|
|
264
|
+
decimals: number;
|
|
265
|
+
}
|
|
266
|
+
interface TokenListResponse {
|
|
267
|
+
tokens: TokenInfoResponse[];
|
|
268
|
+
}
|
|
269
|
+
interface LockInfo {
|
|
270
|
+
lock_id: number;
|
|
271
|
+
user_address: Address;
|
|
272
|
+
service_address: Address;
|
|
273
|
+
token_id: Bytes32;
|
|
274
|
+
amount: string;
|
|
275
|
+
expiry: number;
|
|
276
|
+
is_expired: boolean;
|
|
277
|
+
}
|
|
278
|
+
interface LockedFundsResponse {
|
|
279
|
+
user_address: Address;
|
|
280
|
+
service_address?: Address;
|
|
281
|
+
locks: LockInfo[];
|
|
282
|
+
total_locked: string;
|
|
283
|
+
}
|
|
284
|
+
interface ExpiredLocksResponse {
|
|
285
|
+
user_address: Address;
|
|
286
|
+
expired_locks: LockInfo[];
|
|
287
|
+
}
|
|
288
|
+
interface TotalLockedBalanceResponse {
|
|
289
|
+
user_address: Address;
|
|
290
|
+
token_id: Bytes32;
|
|
291
|
+
total_locked: string;
|
|
292
|
+
}
|
|
293
|
+
interface WithdrawalInfo {
|
|
294
|
+
index: number;
|
|
295
|
+
user_address: Address;
|
|
296
|
+
to_address: Address;
|
|
297
|
+
amount: string;
|
|
298
|
+
block_number: number;
|
|
299
|
+
token_id: Bytes32;
|
|
300
|
+
resolved: boolean;
|
|
301
|
+
tx_identifier: string;
|
|
302
|
+
}
|
|
303
|
+
interface PendingWithdrawalsResponse {
|
|
304
|
+
user_address: Address;
|
|
305
|
+
pending_withdrawals: WithdrawalInfo[];
|
|
306
|
+
}
|
|
307
|
+
type WithdrawalInfoResponse = WithdrawalInfo;
|
|
308
|
+
interface TransferNonceResponse {
|
|
309
|
+
user_address: Address;
|
|
310
|
+
nonce: string;
|
|
311
|
+
}
|
|
312
|
+
interface WithdrawalNonceResponse {
|
|
313
|
+
user_address: Address;
|
|
314
|
+
nonce: string;
|
|
315
|
+
}
|
|
316
|
+
interface LockNonceResponse {
|
|
317
|
+
user_address: Address;
|
|
318
|
+
nonce: string;
|
|
319
|
+
}
|
|
320
|
+
interface ModifyLockNonceResponse {
|
|
321
|
+
user_address: Address;
|
|
322
|
+
nonce: string;
|
|
323
|
+
}
|
|
324
|
+
interface TransferLockedNonceResponse {
|
|
325
|
+
service_address: Address;
|
|
326
|
+
nonce: string;
|
|
327
|
+
}
|
|
328
|
+
interface SiweDomainResponse {
|
|
329
|
+
domain: string;
|
|
330
|
+
}
|
|
331
|
+
interface SiweNonceResponse {
|
|
332
|
+
address: Address;
|
|
333
|
+
nonce: string;
|
|
334
|
+
expires_in: number;
|
|
335
|
+
}
|
|
336
|
+
interface SiweLoginResponse {
|
|
337
|
+
siwe_token: HexString;
|
|
338
|
+
jwt_access_token: string;
|
|
339
|
+
jwt_refresh_token: string;
|
|
340
|
+
address: Address;
|
|
341
|
+
jwt_expires_in: number;
|
|
342
|
+
jwt_refresh_expires_in: number;
|
|
343
|
+
}
|
|
344
|
+
interface HostedAuthTokenExchangeResponse {
|
|
345
|
+
access_token: string;
|
|
346
|
+
id_token: string;
|
|
347
|
+
refresh_token: string;
|
|
348
|
+
token_type: string;
|
|
349
|
+
expires_in: number;
|
|
350
|
+
refresh_expires_in: number;
|
|
351
|
+
address: Address;
|
|
352
|
+
}
|
|
353
|
+
interface JwtRefreshResponse {
|
|
354
|
+
token: string;
|
|
355
|
+
refresh_token: string;
|
|
356
|
+
expires_in: number;
|
|
357
|
+
refresh_expires_in: number;
|
|
358
|
+
}
|
|
359
|
+
interface JwtLogoutResponse {
|
|
360
|
+
message: string;
|
|
361
|
+
revoked_tokens: number;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
type OnRampStatus = 'pending' | 'completed' | 'failed' | 'cancelled';
|
|
365
|
+
/** Request body / response of POST /api/onramp/sign-url */
|
|
366
|
+
interface SignOnRampUrlRequest {
|
|
367
|
+
url: string;
|
|
368
|
+
}
|
|
369
|
+
interface SignOnRampUrlResponse {
|
|
370
|
+
signature: string;
|
|
371
|
+
}
|
|
372
|
+
/** Request body / response of POST /api/onramp/intent. */
|
|
373
|
+
interface CreateOnRampIntentRequest {
|
|
374
|
+
wallet_address?: Address;
|
|
375
|
+
token_id: Bytes32;
|
|
376
|
+
chain_id: number;
|
|
377
|
+
moonpay_currency_code: string;
|
|
378
|
+
base_currency_code?: string;
|
|
379
|
+
base_currency_amount?: string;
|
|
380
|
+
}
|
|
381
|
+
type CreateOnRampIntentResponse = OnRampRecord;
|
|
382
|
+
/** Request body / response of POST /api/onramp/{id}. */
|
|
383
|
+
interface UpdateOnRampRequest {
|
|
384
|
+
wallet_address?: Address;
|
|
385
|
+
token_id?: Bytes32;
|
|
386
|
+
chain_id?: number;
|
|
387
|
+
moonpay_transaction_id?: string;
|
|
388
|
+
base_currency_code?: string;
|
|
389
|
+
base_currency_amount?: string;
|
|
390
|
+
quote_currency_amount?: string;
|
|
391
|
+
on_chain_tx_hash?: HexString;
|
|
392
|
+
deposit_tx_hash?: HexString;
|
|
393
|
+
}
|
|
394
|
+
type UpdateOnRampResponse = OnRampRecord;
|
|
395
|
+
interface OnRampRecord {
|
|
396
|
+
transaction_id: string;
|
|
397
|
+
external_transaction_id?: string;
|
|
398
|
+
moonpay_transaction_id?: string;
|
|
399
|
+
status: OnRampStatus;
|
|
400
|
+
wallet_address?: Address;
|
|
401
|
+
token_id?: Bytes32;
|
|
402
|
+
chain_id?: number;
|
|
403
|
+
moonpay_currency_code?: string;
|
|
404
|
+
base_currency_code?: string;
|
|
405
|
+
base_currency_amount?: string;
|
|
406
|
+
quote_currency_amount?: string;
|
|
407
|
+
on_chain_tx_hash?: HexString;
|
|
408
|
+
deposit_tx_hash?: HexString;
|
|
409
|
+
deposit_triggered_at?: number;
|
|
410
|
+
credited_at?: number;
|
|
411
|
+
created_at: number;
|
|
412
|
+
updated_at: number;
|
|
413
|
+
}
|
|
414
|
+
/** Response body of GET /api/onramp/pending */
|
|
415
|
+
interface PendingOnRampsResponse {
|
|
416
|
+
pending: OnRampRecord[];
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
interface HttpClientConfig {
|
|
420
|
+
baseUrl: string;
|
|
421
|
+
timeout?: number;
|
|
422
|
+
headers?: Record<string, string>;
|
|
423
|
+
}
|
|
424
|
+
declare class HttpClient {
|
|
425
|
+
private readonly baseUrl;
|
|
426
|
+
private readonly timeout;
|
|
427
|
+
private readonly headers;
|
|
428
|
+
constructor(config: HttpClientConfig);
|
|
429
|
+
get<T>(path: string): Promise<T>;
|
|
430
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
431
|
+
getBaseUrl(): string;
|
|
432
|
+
setHeader(name: string, value: string): void;
|
|
433
|
+
removeHeader(name: string): void;
|
|
434
|
+
getHeader(name: string): string | undefined;
|
|
435
|
+
private request;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
type PrivanaClientConfig = HttpClientConfig;
|
|
439
|
+
declare class PrivanaClient {
|
|
440
|
+
private readonly http;
|
|
441
|
+
constructor(config: PrivanaClientConfig);
|
|
442
|
+
getBaseUrl(): string;
|
|
443
|
+
getDepositAddress(request?: DepositAddressRequest): Promise<DepositAddressResponse>;
|
|
444
|
+
checkDeposit(request: DepositCheckRequest): Promise<DepositCheckResponse>;
|
|
445
|
+
getDepositStatus(depositId: string): Promise<DepositCheckResponse>;
|
|
446
|
+
getPendingDeposits(request: PendingDepositsRequest): Promise<PendingDepositsResponse>;
|
|
447
|
+
getBalance(tokenId: Bytes32 | string): Promise<BalanceResponse>;
|
|
448
|
+
getBatchBalances(request: BatchBalancesRequest): Promise<BatchBalancesResponse>;
|
|
449
|
+
getHistory(request?: HistoryRequest): Promise<HistoryResponse>;
|
|
450
|
+
listTokens(): Promise<TokenListResponse>;
|
|
451
|
+
getTokenInfo(tokenId: Bytes32 | string): Promise<TokenInfoResponse>;
|
|
452
|
+
lockFunds(request: LockFundsRequest): Promise<TransactionSubmissionResponse>;
|
|
453
|
+
modifyLock(request: ModifyLockRequest): Promise<TransactionSubmissionResponse>;
|
|
454
|
+
unlockFunds(request: UnlockFundsRequest): Promise<TransactionSubmissionResponse>;
|
|
455
|
+
unlockAllExpired(request: UnlockAllExpiredRequest): Promise<TransactionSubmissionResponse>;
|
|
456
|
+
getLockedFunds(serviceAddress?: Address | string): Promise<LockedFundsResponse>;
|
|
457
|
+
getTotalLockedBalance(tokenId: Bytes32 | string): Promise<TotalLockedBalanceResponse>;
|
|
458
|
+
getExpiredLocks(): Promise<ExpiredLocksResponse>;
|
|
459
|
+
transferFunds(request: TransferFundsRequest): Promise<TransactionSubmissionResponse>;
|
|
460
|
+
getTransferNonce(userAddress: Address | string): Promise<TransferNonceResponse>;
|
|
461
|
+
getLockNonce(userAddress: Address | string): Promise<LockNonceResponse>;
|
|
462
|
+
getModifyLockNonce(userAddress: Address | string): Promise<ModifyLockNonceResponse>;
|
|
463
|
+
transferLockedFunds(request: TransferLockedFundsRequest): Promise<TransactionSubmissionResponse>;
|
|
464
|
+
withdrawFromLock(request: WithdrawFromLockRequest): Promise<TransactionSubmissionResponse>;
|
|
465
|
+
requestWithdrawal(request: WithdrawalRequest): Promise<TransactionSubmissionResponse>;
|
|
466
|
+
getWithdrawalNonce(userAddress: Address | string): Promise<WithdrawalNonceResponse>;
|
|
467
|
+
getTransferLockedNonce(serviceAddress: Address | string): Promise<TransferLockedNonceResponse>;
|
|
468
|
+
getPendingWithdrawals(userAddress: Address | string): Promise<PendingWithdrawalsResponse>;
|
|
469
|
+
getWithdrawalInfo(index: number): Promise<WithdrawalInfoResponse>;
|
|
470
|
+
getSiweDomain(): Promise<SiweDomainResponse>;
|
|
471
|
+
getSiweNonce(userAddress: Address | string): Promise<SiweNonceResponse>;
|
|
472
|
+
loginWithSiwe(request: SiweLoginRequest): Promise<SiweLoginResponse>;
|
|
473
|
+
getHostedAuthAuthorizeUrl(request: HostedAuthAuthorizeUrlRequest): string;
|
|
474
|
+
exchangeHostedAuthCode(request: HostedAuthTokenExchangeRequest): Promise<HostedAuthTokenExchangeResponse>;
|
|
475
|
+
refreshJwtSession(request: JwtRefreshRequest): Promise<JwtRefreshResponse>;
|
|
476
|
+
logoutJwtSession(request?: JwtLogoutRequest): Promise<JwtLogoutResponse>;
|
|
477
|
+
signOnRampUrl(request: SignOnRampUrlRequest): Promise<SignOnRampUrlResponse>;
|
|
478
|
+
createOnRampIntent(request: CreateOnRampIntentRequest): Promise<CreateOnRampIntentResponse>;
|
|
479
|
+
updateOnRamp(transactionId: string, request: UpdateOnRampRequest): Promise<UpdateOnRampResponse>;
|
|
480
|
+
getPendingOnRamps(): Promise<PendingOnRampsResponse>;
|
|
481
|
+
setPrivateReadToken(token: string): void;
|
|
482
|
+
getPrivateReadToken(): string | undefined;
|
|
483
|
+
clearPrivateReadToken(): void;
|
|
484
|
+
setBearerToken(token: string): void;
|
|
485
|
+
clearBearerToken(): void;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Deposit-and-lock without backend involvement: the user pre-signs a regular
|
|
490
|
+
* `Lock` (EIP-712) for the exact expected amount before the deposit, the SDK
|
|
491
|
+
* persists the payload, and submits it to POST /funds/lock once the deposit is
|
|
492
|
+
* credited. Every failure fails closed — if the credited amount is short or the
|
|
493
|
+
* nonce went stale, the lock reverts, the funds stay in the user's available
|
|
494
|
+
* balance, and the UI re-prompts a fresh signature at the actual amount.
|
|
495
|
+
* Services must only act on lock confirmation, never on deposit.
|
|
496
|
+
*/
|
|
497
|
+
interface PostDepositLockConfig {
|
|
498
|
+
/** Service the funds get locked to. Defaults to the provider's `serviceAddress`. */
|
|
499
|
+
serviceAddress?: Address;
|
|
500
|
+
/**
|
|
501
|
+
* Lock lifetime in seconds from signing (default 259200, 3 days). The `Lock` expiry is
|
|
502
|
+
* an absolute timestamp baked into the signature, so it runs from signing
|
|
503
|
+
* time, not from credit time — budget for the expected delivery delay.
|
|
504
|
+
*/
|
|
505
|
+
lockDuration?: number;
|
|
506
|
+
/**
|
|
507
|
+
* Cap on the locked amount in base units (the allowance the service
|
|
508
|
+
* requested). The signed amount is `min(computed amount, maxAmount)`.
|
|
509
|
+
*/
|
|
510
|
+
maxAmount?: bigint;
|
|
511
|
+
}
|
|
512
|
+
/** `PostDepositLockConfig` for on-ramps, where fees make delivery inexact. */
|
|
513
|
+
interface OnRampPostDepositLockConfig extends PostDepositLockConfig {
|
|
514
|
+
/**
|
|
515
|
+
* Fraction shaved off the quoted amount before signing (default 0.02), so
|
|
516
|
+
* settlement-rate drift on slow payment rails can't push the delivered
|
|
517
|
+
* amount below the signed amount. The difference stays in the user's
|
|
518
|
+
* available balance. Card purchases target the quote amount; the buffer
|
|
519
|
+
* mainly matters for bank rails that settle at a later rate.
|
|
520
|
+
*/
|
|
521
|
+
buffer?: number;
|
|
522
|
+
}
|
|
523
|
+
declare const DEFAULT_LOCK_DURATION_SECONDS = 259200;
|
|
524
|
+
declare const DEFAULT_ONRAMP_LOCK_BUFFER = 0.02;
|
|
525
|
+
/**
|
|
526
|
+
* `floor(amount × (1 − buffer))` in base units. Always rounds down so the
|
|
527
|
+
* signed amount never exceeds what the buffer is meant to guarantee.
|
|
528
|
+
*/
|
|
529
|
+
declare function applyLockBuffer(amount: bigint, buffer?: number): bigint;
|
|
530
|
+
/**
|
|
531
|
+
* `min(amount, maxAmount)` — the allowance cap the service requested. The
|
|
532
|
+
* signed lock must never exceed it, no matter what the flow computed.
|
|
533
|
+
*/
|
|
534
|
+
declare function clampLockAmount(amount: bigint, maxAmount?: bigint): bigint;
|
|
535
|
+
interface CreateSignedLockRequestParams {
|
|
536
|
+
client: PrivanaClient;
|
|
537
|
+
walletClient: WalletClient;
|
|
538
|
+
userAddress: Address;
|
|
539
|
+
networkConfig: NetworkConfig;
|
|
540
|
+
serviceAddress: Address;
|
|
541
|
+
tokenId: Bytes32;
|
|
542
|
+
/** Exact amount to lock, in base units. */
|
|
543
|
+
amount: bigint;
|
|
544
|
+
lockDuration?: number;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Fetch the user's lock nonce and sign a ready-to-submit `Lock` payload.
|
|
548
|
+
* Validity is bounded by the single-use nonce — any other lock operation by
|
|
549
|
+
* the user invalidates it, which fails closed (revert → re-prompt).
|
|
550
|
+
*/
|
|
551
|
+
declare function createSignedLockRequest({ client, walletClient, userAddress, networkConfig, serviceAddress, tokenId, amount, lockDuration, }: CreateSignedLockRequestParams): Promise<LockFundsRequest>;
|
|
552
|
+
/** False once the signed lock's expiry is too close to be worth submitting. */
|
|
553
|
+
declare function isSignedLockUsable(payload: LockFundsRequest): boolean;
|
|
554
|
+
type PostDepositLockFailureReason =
|
|
555
|
+
/** The signed lock's expiry passed before the deposit was credited. */
|
|
556
|
+
'expired'
|
|
557
|
+
/** The credited amount is below the signed amount; submitting would revert. */
|
|
558
|
+
| 'credited-below-signed'
|
|
559
|
+
/** The API rejected the submission (stale nonce, revert, transport error). */
|
|
560
|
+
| 'submission-failed'
|
|
561
|
+
/** No persisted signed lock for this deposit (storage cleared, other device). */
|
|
562
|
+
| 'not-found';
|
|
563
|
+
/**
|
|
564
|
+
* The deposit itself was credited; only the post-credit lock failed. UIs
|
|
565
|
+
* should re-prompt a fresh `Lock` signature at the actual credited amount.
|
|
566
|
+
*/
|
|
567
|
+
declare class PostDepositLockError extends Error {
|
|
568
|
+
readonly reason: PostDepositLockFailureReason;
|
|
569
|
+
readonly signedAmount?: bigint | undefined;
|
|
570
|
+
readonly creditedAmount?: bigint | undefined;
|
|
571
|
+
constructor(message: string, reason: PostDepositLockFailureReason, signedAmount?: bigint | undefined, creditedAmount?: bigint | undefined, options?: {
|
|
572
|
+
cause?: unknown;
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
interface SubmitPendingLockParams {
|
|
576
|
+
client: PrivanaClient;
|
|
577
|
+
payload: LockFundsRequest;
|
|
578
|
+
/** Credited amount in base units, when known — skips a guaranteed revert. */
|
|
579
|
+
creditedAmount?: bigint;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Submit a pre-signed lock after the deposit credited. Throws
|
|
583
|
+
* `PostDepositLockError` on every failure path so callers can route to the
|
|
584
|
+
* re-prompt flow.
|
|
585
|
+
*/
|
|
586
|
+
declare function submitPendingLock({ client, payload, creditedAmount, }: SubmitPendingLockParams): Promise<TransactionSubmissionResponse>;
|
|
587
|
+
/**
|
|
588
|
+
* Persist a signed lock so submission survives a page reload between deposit
|
|
589
|
+
* and credit. `correlationId` ties it to the deposit (tx hash) or on-ramp
|
|
590
|
+
* intent (transaction id).
|
|
591
|
+
*/
|
|
592
|
+
declare function savePendingLock(userAddress: string, correlationId: string, payload: LockFundsRequest): void;
|
|
593
|
+
/**
|
|
594
|
+
* Returns the stored payload even when its expiry passed — expiry belongs to
|
|
595
|
+
* `submitPendingLock`, which reports it as a precise `'expired'` failure.
|
|
596
|
+
*/
|
|
597
|
+
declare function loadPendingLock(userAddress: string, correlationId: string): LockFundsRequest | undefined;
|
|
598
|
+
declare function clearPendingLock(userAddress: string, correlationId: string): void;
|
|
599
|
+
|
|
600
|
+
export { type OnRampRecord as $, type Address as A, type Bytes32 as B, type CreateOnRampIntentRequest as C, type DepositAddressResponse as D, type ExpiredLocksResponse as E, type HttpClientConfig as F, type JwtLogoutRequest as G, type HostedAuthTokenExchangeResponse as H, type IntegerLike as I, type JwtRefreshResponse as J, type JwtLogoutResponse as K, type LockInfo as L, type JwtRefreshRequest as M, type NetworkConfig as N, type LockFundsRequest as O, PrivanaClient as P, type LockNonceResponse as Q, type LockedFundsResponse as R, type SiweLoginResponse as S, type TokenConfig as T, type MinDepositAmounts as U, type ModifyLockNonceResponse as V, type WithdrawalInfo as W, type ModifyLockRequest as X, NETWORK_CONFIG as Y, type Network as Z, type OnRampPostDepositLockConfig as _, type TokenBalance as a, type OnRampStatus as a0, type PendingDepositStatus as a1, type PendingDepositsRequest as a2, type PendingOnRampsResponse as a3, type PendingWithdrawalsResponse as a4, type PostDepositLockFailureReason as a5, type PrivanaClientConfig as a6, type SignOnRampUrlRequest as a7, type SignOnRampUrlResponse as a8, type SiweDomainResponse as a9, normalizeAddress as aA, normalizeHex as aB, savePendingLock as aC, submitPendingLock as aD, type SiweLoginRequest as aa, type SiweNonceResponse as ab, type SubmitPendingLockParams as ac, type TokenListResponse as ad, type TotalLockedBalanceResponse as ae, type TransferFundsRequest as af, type TransferLockedFundsRequest as ag, type TransferLockedNonceResponse as ah, type TransferNonceResponse as ai, type UnlockAllExpiredRequest as aj, type UnlockFundsRequest as ak, type UpdateOnRampRequest as al, type UpdateOnRampResponse as am, type WithdrawFromLockRequest as an, type WithdrawalInfoResponse as ao, type WithdrawalNonceResponse as ap, type WithdrawalRequest as aq, applyLockBuffer as ar, clampLockAmount as as, clearPendingLock as at, createSignedLockRequest as au, getAccountingContract as av, getApiUrl as aw, getChainId as ax, isSignedLockUsable as ay, loadPendingLock as az, type PostDepositLockConfig as b, type DepositCheckResponse as c, type TransactionSubmissionResponse as d, PostDepositLockError as e, type PendingDeposit as f, type PendingDepositsResponse as g, type HistoryEntry as h, type TokenInfoResponse as i, type BalanceResponse as j, type BatchBalancesRequest as k, type BatchBalancesResponse as l, type CreateOnRampIntentResponse as m, type CreateSignedLockRequestParams as n, DEFAULT_LOCK_DURATION_SECONDS as o, DEFAULT_ONRAMP_LOCK_BUFFER as p, type DepositAddressRequest as q, type DepositCheckRequest as r, type HexString as s, type HistoryKind as t, type HistoryRequest as u, type HistoryResponse as v, type HostedAuthAuthorizeUrlRequest as w, type HostedAuthResponseMode as x, type HostedAuthTokenExchangeRequest as y, HttpClient as z };
|