@getpara/rest-sdk 3.23.0 → 3.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -22,7 +22,21 @@ import { RestPermissionsClient } from "./permissions.js";
22
22
  import { ParaRestValidationError, pathSegment, requireBody, requireNonEmpty } from "./validation.js";
23
23
  export * from "./permissions.js";
24
24
  export * from "./webhooks.js";
25
+ export * from "./webhookVerification.js";
25
26
  import { ParaRestValidationError as ParaRestValidationError2 } from "./validation.js";
27
+ function isSponsoredTransfer(result) {
28
+ var _a;
29
+ return (_a = result.sponsoredGas) != null ? _a : result.executionMode === "sponsored";
30
+ }
31
+ class ParaRestSponsorshipError extends Error {
32
+ constructor(requestedSponsorship, response) {
33
+ super(
34
+ `Sponsorship mismatch: requested sponsoredGas: ${requestedSponsorship} but received ${isSponsoredTransfer(response)}. Reconcile the response before retrying; a transaction may already have been submitted.`
35
+ );
36
+ this.name = "ParaRestSponsorshipError";
37
+ this.response = response;
38
+ }
39
+ }
26
40
  class ParaRestError extends Error {
27
41
  constructor({
28
42
  status,
@@ -142,6 +156,17 @@ class ParaRestClient extends RestPermissionsClient {
142
156
  }
143
157
  return this.request("POST", `/v1/wallets/${walletPath(walletId)}/sign-transaction`, { body, options });
144
158
  }
159
+ signTransactionWithAutoRetry(walletId, body, options) {
160
+ requireNonEmpty(walletId, "walletId");
161
+ requireBody(body, "body");
162
+ if (body.transaction == null || body.transaction === "") {
163
+ throw new ParaRestValidationError("transaction is required");
164
+ }
165
+ if (body.broadcast !== true) throw new ParaRestValidationError("autoRetry requires broadcast:true");
166
+ requireBody(body.autoRetry, "autoRetry");
167
+ requireNonEmpty(options == null ? void 0 : options.idempotencyKey, "idempotencyKey");
168
+ return this.request("POST", `/v1/wallets/${walletPath(walletId)}/sign-transaction`, { body, options });
169
+ }
145
170
  signTypedData(walletId, body, options) {
146
171
  requireNonEmpty(walletId, "walletId");
147
172
  requireBody(body, "body");
@@ -172,6 +197,23 @@ class ParaRestClient extends RestPermissionsClient {
172
197
  requireBody(body, "body");
173
198
  requireNonEmpty(body.to, "to");
174
199
  requireNonEmpty(body.value, "value");
200
+ const sponsoredGas = body.sponsoredGas === true;
201
+ return this.request("POST", `/v1/wallets/${walletPath(walletId)}/transfer`, { body, options }).then(
202
+ (result) => {
203
+ if (isSponsoredTransfer(result) !== sponsoredGas) {
204
+ throw new ParaRestSponsorshipError(sponsoredGas, result);
205
+ }
206
+ return result;
207
+ }
208
+ );
209
+ }
210
+ transferWithAutoRetry(walletId, body, options) {
211
+ requireNonEmpty(walletId, "walletId");
212
+ requireBody(body, "body");
213
+ requireNonEmpty(body.to, "to");
214
+ requireNonEmpty(body.value, "value");
215
+ requireBody(body.autoRetry, "autoRetry");
216
+ requireNonEmpty(options == null ? void 0 : options.idempotencyKey, "idempotencyKey");
175
217
  return this.request("POST", `/v1/wallets/${walletPath(walletId)}/transfer`, { body, options });
176
218
  }
177
219
  estimateFee(walletId, body, options) {
@@ -198,6 +240,45 @@ class ParaRestClient extends RestPermissionsClient {
198
240
  }
199
241
  );
200
242
  }
243
+ speedUpRestTransaction(walletId, transactionId, body, options) {
244
+ requireBody(body, "body");
245
+ requireNonEmpty(body.maxExecutionFeeWei, "maxExecutionFeeWei");
246
+ requireNonEmpty(options == null ? void 0 : options.idempotencyKey, "idempotencyKey");
247
+ return this.request(
248
+ "POST",
249
+ `/v1/wallets/${walletPath(walletId)}/transactions/${pathSegment("transactionId", transactionId)}/speed-up`,
250
+ { body, options }
251
+ );
252
+ }
253
+ cancelRestTransaction(walletId, transactionId, body, options) {
254
+ requireBody(body, "body");
255
+ requireNonEmpty(body.maxExecutionFeeWei, "maxExecutionFeeWei");
256
+ requireNonEmpty(options == null ? void 0 : options.idempotencyKey, "idempotencyKey");
257
+ return this.request(
258
+ "POST",
259
+ `/v1/wallets/${walletPath(walletId)}/transactions/${pathSegment("transactionId", transactionId)}/cancel`,
260
+ { body, options }
261
+ );
262
+ }
263
+ createYieldDeposit(walletId, body, options) {
264
+ requireBody(body, "body");
265
+ requireNonEmpty(body.amount, "amount");
266
+ requireNonEmpty(options == null ? void 0 : options.idempotencyKey, "idempotencyKey");
267
+ return this.request("POST", `/v1/wallets/${walletPath(walletId)}/yield/deposits`, { body, options });
268
+ }
269
+ createYieldWithdrawal(walletId, body, options) {
270
+ requireBody(body, "body");
271
+ requireNonEmpty(body.amount, "amount");
272
+ requireNonEmpty(options == null ? void 0 : options.idempotencyKey, "idempotencyKey");
273
+ return this.request("POST", `/v1/wallets/${walletPath(walletId)}/yield/withdrawals`, { body, options });
274
+ }
275
+ getYieldOperation(walletId, operationId, options) {
276
+ return this.request(
277
+ "GET",
278
+ `/v1/wallets/${walletPath(walletId)}/yield/operations/${pathSegment("operationId", operationId)}`,
279
+ { options }
280
+ );
281
+ }
201
282
  resumeRestTransaction(walletId, transactionId, body, options) {
202
283
  requireBody(body, "body");
203
284
  requireNonEmpty(body.reviewId, "reviewId");
@@ -317,6 +398,8 @@ export {
317
398
  ParaRestClient,
318
399
  ParaRestError,
319
400
  ParaRestSerializationError,
401
+ ParaRestSponsorshipError,
320
402
  ParaRestValidationError2 as ParaRestValidationError,
403
+ isSponsoredTransfer,
321
404
  toRestJson
322
405
  };
@@ -50,13 +50,13 @@ function requirementPath(reference) {
50
50
  )}`;
51
51
  }
52
52
  class RestPermissionsClient {
53
- listPartnerPolicies(options) {
53
+ listPolicies(options) {
54
54
  return this.request("GET", `${basePath}/policies`, { options });
55
55
  }
56
- getPartnerPolicy(policyId, options) {
56
+ getPolicy(policyId, options) {
57
57
  return this.request("GET", `${basePath}/policies/${pathSegment("policyId", policyId)}`, { options });
58
58
  }
59
- listPartnerPolicyVersions(policyId, options) {
59
+ listPolicyVersions(policyId, options) {
60
60
  return this.request("GET", `${basePath}/policies/${pathSegment("policyId", policyId)}/versions`, { options });
61
61
  }
62
62
  listUserPolicyConsents(userId, context, options) {
@@ -181,16 +181,22 @@ class RestPermissionsClient {
181
181
  { options }
182
182
  );
183
183
  }
184
- listPartnerApprovalCases(query, options) {
184
+ listApprovalCases(query, options) {
185
185
  return this.request("GET", `${basePath}/approval-cases${queryString(query)}`, { options });
186
186
  }
187
- getPartnerApprovalCase(caseId, options) {
187
+ getApprovalCase(caseId, options) {
188
188
  return this.request("GET", `${basePath}/approval-cases/${pathSegment("caseId", caseId)}`, { options });
189
189
  }
190
- cancelPartnerApprovalCase(caseId, options) {
190
+ cancelApprovalCase(caseId, options) {
191
191
  return this.request("POST", `${basePath}/approval-cases/${pathSegment("caseId", caseId)}/cancel`, { options });
192
192
  }
193
- getPartnerPolicyUsage(policyId, context, options) {
193
+ approveReview(reviewId, options) {
194
+ return this.request("POST", `${basePath}/reviews/${pathSegment("reviewId", reviewId)}/approve`, { options });
195
+ }
196
+ rejectReview(reviewId, options) {
197
+ return this.request("POST", `${basePath}/reviews/${pathSegment("reviewId", reviewId)}/reject`, { options });
198
+ }
199
+ getPolicyUsage(policyId, context, options) {
194
200
  const _a = context, { userId, walletId } = _a, query = __objRest(_a, ["userId", "walletId"]);
195
201
  const subjectPath = userId ? `users/${pathSegment("userId", userId)}` : `wallets/${pathSegment("walletId", walletId)}`;
196
202
  const usageQuery = userId ? __spreadValues({ walletId }, query) : query;
@@ -0,0 +1,132 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import { ParaRestValidationError, requireNonEmpty } from "./validation.js";
22
+ const DEFAULT_TOLERANCE_IN_SECONDS = 300;
23
+ const SIGNATURE_PREFIX = "v1,";
24
+ const SECRET_PREFIX = /^whsec_/;
25
+ const WHOLE_SECONDS = /^\d+$/;
26
+ class ParaWebhookVerificationError extends Error {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = "ParaWebhookVerificationError";
30
+ }
31
+ }
32
+ function verifyParaWebhook(options) {
33
+ return __async(this, null, function* () {
34
+ var _a;
35
+ requireNonEmpty(options.secret, "secret");
36
+ const toleranceInSeconds = requireValidTolerance((_a = options.toleranceInSeconds) != null ? _a : DEFAULT_TOLERANCE_IN_SECONDS);
37
+ const id = requireHeader(options.headers, "webhook-id");
38
+ const timestamp = requireHeader(options.headers, "webhook-timestamp");
39
+ const signatureHeader = requireHeader(options.headers, "webhook-signature");
40
+ assertTimestampWithinTolerance(timestamp, toleranceInSeconds);
41
+ const body = typeof options.body === "string" ? options.body : new TextDecoder().decode(options.body);
42
+ const expectedSignatures = yield signDelivery({ id, timestamp, body }, options.secret);
43
+ const receivedSignatures = signatureHeader.split(" ").filter((entry) => entry.startsWith(SIGNATURE_PREFIX)).map((entry) => entry.slice(SIGNATURE_PREFIX.length));
44
+ const matches = receivedSignatures.some(
45
+ (received) => expectedSignatures.some((expected) => equalsInConstantTime(expected, received))
46
+ );
47
+ if (!matches) {
48
+ throw new ParaWebhookVerificationError("No matching webhook signature");
49
+ }
50
+ return JSON.parse(body);
51
+ });
52
+ }
53
+ function requireValidTolerance(toleranceInSeconds) {
54
+ if (!Number.isFinite(toleranceInSeconds) || toleranceInSeconds < 0) {
55
+ throw new ParaRestValidationError("toleranceInSeconds must be a finite, non-negative number");
56
+ }
57
+ return toleranceInSeconds;
58
+ }
59
+ function requireHeader(headers, name) {
60
+ var _a;
61
+ const value = isHeaderGetter(headers) ? headers.get(name) : headers[(_a = findHeaderKey(headers, name)) != null ? _a : name];
62
+ if (typeof value !== "string" || value === "") {
63
+ throw new ParaWebhookVerificationError(`Missing ${name} header`);
64
+ }
65
+ return value;
66
+ }
67
+ function isHeaderGetter(headers) {
68
+ return typeof headers.get === "function";
69
+ }
70
+ function findHeaderKey(headers, name) {
71
+ return Object.keys(headers).find((key) => key.toLowerCase() === name);
72
+ }
73
+ function assertTimestampWithinTolerance(timestamp, toleranceInSeconds) {
74
+ if (!WHOLE_SECONDS.test(timestamp)) {
75
+ throw new ParaWebhookVerificationError("Invalid webhook-timestamp header");
76
+ }
77
+ const ageInSeconds = Math.floor(Date.now() / 1e3) - Number(timestamp);
78
+ if (ageInSeconds > toleranceInSeconds) {
79
+ throw new ParaWebhookVerificationError("Webhook timestamp is too old");
80
+ }
81
+ if (-ageInSeconds > toleranceInSeconds) {
82
+ throw new ParaWebhookVerificationError("Webhook timestamp is too new");
83
+ }
84
+ }
85
+ function signDelivery(_0, _1) {
86
+ return __async(this, arguments, function* ({ id, timestamp, body }, secret) {
87
+ const originalSignature = yield signHmacSha256(new TextEncoder().encode(secret), `${timestamp}.${body}`);
88
+ const standardKey = decodeStandardSigningKey(secret);
89
+ if (!standardKey) {
90
+ return [originalSignature];
91
+ }
92
+ return [originalSignature, yield signHmacSha256(standardKey, `${id}.${timestamp}.${body}`)];
93
+ });
94
+ }
95
+ function decodeStandardSigningKey(secret) {
96
+ try {
97
+ const key = Uint8Array.from(atob(secret.replace(SECRET_PREFIX, "")), (character) => character.charCodeAt(0));
98
+ return key.length > 0 ? key : null;
99
+ } catch (e) {
100
+ return null;
101
+ }
102
+ }
103
+ function signHmacSha256(key, message) {
104
+ return __async(this, null, function* () {
105
+ const subtle = requireSubtleCrypto();
106
+ const cryptoKey = yield subtle.importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
107
+ const signature = new Uint8Array(yield subtle.sign("HMAC", cryptoKey, new TextEncoder().encode(message)));
108
+ return btoa(String.fromCharCode(...signature));
109
+ });
110
+ }
111
+ function requireSubtleCrypto() {
112
+ var _a;
113
+ const subtle = (_a = globalThis.crypto) == null ? void 0 : _a.subtle;
114
+ if (!subtle) {
115
+ throw new ParaRestValidationError("Web Crypto is required in this runtime to verify webhooks");
116
+ }
117
+ return subtle;
118
+ }
119
+ function equalsInConstantTime(expected, received) {
120
+ if (expected.length !== received.length) {
121
+ return false;
122
+ }
123
+ let difference = 0;
124
+ for (let index = 0; index < expected.length; index++) {
125
+ difference |= expected.charCodeAt(index) ^ received.charCodeAt(index);
126
+ }
127
+ return difference === 0;
128
+ }
129
+ export {
130
+ ParaWebhookVerificationError,
131
+ verifyParaWebhook
132
+ };
@@ -2,6 +2,7 @@ import type { OnrampCompletedPayload, PermissionsV2SigningInitiatorRequest, TPre
2
2
  import { RestPermissionsClient } from './permissions.js';
3
3
  export * from './permissions.js';
4
4
  export * from './webhooks.js';
5
+ export * from './webhookVerification.js';
5
6
  export { ParaRestValidationError } from './validation.js';
6
7
  export type ParaRestEnvironment = 'PROD' | 'BETA' | 'SANDBOX' | {
7
8
  baseUrl: string;
@@ -70,7 +71,10 @@ export interface WalletBalanceResponse {
70
71
  rawBalance: string;
71
72
  }
72
73
  export type RestSigningInitiator = PermissionsV2SigningInitiatorRequest;
73
- export interface SignRawRequest extends RestSigningInitiator {
74
+ export interface RestSigningRequestContext extends RestSigningInitiator {
75
+ reviewId?: string;
76
+ }
77
+ export interface SignRawRequest extends RestSigningRequestContext {
74
78
  data: string;
75
79
  encoding?: 'hex';
76
80
  walletType?: WalletType;
@@ -78,18 +82,45 @@ export interface SignRawRequest extends RestSigningInitiator {
78
82
  export interface SignRawResponse {
79
83
  signature: string;
80
84
  }
81
- export interface SignMessageRequest extends RestSigningInitiator {
85
+ export interface SignMessageRequest extends RestSigningRequestContext {
82
86
  message: string;
83
87
  }
84
88
  export interface SignMessageResponse {
85
89
  signature: string;
86
90
  }
87
- export interface SignTransactionRequest extends RestSigningInitiator {
91
+ export interface SignTransactionRequest extends RestSigningRequestContext {
88
92
  transaction: EvmSignTransactionRequest | string;
89
93
  broadcast?: boolean;
90
94
  network?: SolanaNetwork | SuiNetwork;
91
95
  networkPassphrase?: string;
92
- }
96
+ autoRetry?: never;
97
+ }
98
+ export interface EvmAutoRetryAuthorization {
99
+ /** Per-attempt execution-gas ceiling in wei; excludes separate chain fees. */
100
+ maxExecutionFeeWei: string;
101
+ expiresAt: string;
102
+ }
103
+ export interface SolanaAutoRetryAuthorization {
104
+ /** Per-attempt base plus priority transaction fee ceiling; excludes rent. */
105
+ maxExecutionFeeLamports: string;
106
+ expiresAt: string;
107
+ }
108
+ export type AutoRetrySignTransactionRequest = {
109
+ transaction: EvmAutoRetrySignTransactionRequest;
110
+ broadcast: true;
111
+ walletType?: 'EVM';
112
+ autoRetry: EvmAutoRetryAuthorization;
113
+ } | {
114
+ /** Unsigned legacy transaction: sole wallet signer/fee payer, still-valid finalized blockhash,
115
+ * one 120000-unit limit and one compute-unit-price instruction. */
116
+ transaction: string;
117
+ broadcast: true;
118
+ walletType?: 'SOLANA';
119
+ network?: SolanaNetwork;
120
+ versioned?: false;
121
+ autoRetry: SolanaAutoRetryAuthorization;
122
+ };
123
+ export type AnySignTransactionRequest = SignTransactionRequest | AutoRetrySignTransactionRequest;
93
124
  export interface EvmSignTransactionRequest {
94
125
  to: string;
95
126
  chainId: string | number;
@@ -102,11 +133,26 @@ export interface EvmSignTransactionRequest {
102
133
  maxPriorityFeePerGas?: string;
103
134
  gasPrice?: string;
104
135
  }
136
+ export interface EvmAutoRetrySignTransactionRequest extends EvmSignTransactionRequest {
137
+ /** Managed retry only. Ordinary signTransaction does not preserve access lists. */
138
+ accessList?: Array<{
139
+ address: string;
140
+ storageKeys: string[];
141
+ } | [string, string[]]>;
142
+ }
105
143
  export interface SignTransactionResponse {
106
144
  signedTransaction: string;
107
145
  txHash?: string;
108
146
  transactionId?: string;
147
+ autoRetry?: never;
148
+ }
149
+ /** HTTP 202 is durable admission, before signing or broadcast. */
150
+ export interface AutoRetrySignTransactionResponse extends RestTransaction {
151
+ autoRetry: RestAutoRetryDetails;
152
+ signedTransaction?: never;
153
+ txHash?: never;
109
154
  }
155
+ export type AnySignTransactionResponse = SignTransactionResponse | AutoRetrySignTransactionResponse;
110
156
  export interface TypedDataPayload {
111
157
  domain: Record<string, unknown>;
112
158
  types: Record<string, Array<{
@@ -116,13 +162,13 @@ export interface TypedDataPayload {
116
162
  primaryType: string;
117
163
  message: Record<string, unknown>;
118
164
  }
119
- export interface SignTypedDataRequest extends RestSigningInitiator {
165
+ export interface SignTypedDataRequest extends RestSigningRequestContext {
120
166
  typedData: TypedDataPayload;
121
167
  }
122
168
  export interface SignTypedDataResponse {
123
169
  signature: string;
124
170
  }
125
- export interface SignAuthorizationRequest extends RestSigningInitiator {
171
+ export interface SignAuthorizationRequest extends RestSigningRequestContext {
126
172
  authorization: SignAuthorizationPayload;
127
173
  }
128
174
  export type SignAuthorizationPayload = ({
@@ -144,9 +190,17 @@ export interface SignAuthorizationResponse {
144
190
  yParity: 0 | 1;
145
191
  signature: string;
146
192
  }
147
- export interface TransferRequest extends RestSigningInitiator {
193
+ export type EvmFeeUrgency = 'normal' | 'urgent';
194
+ export interface TransferRequest extends RestSigningRequestContext {
148
195
  to: string;
149
196
  value: string;
197
+ /**
198
+ * Only true requires Para-paid gas with Para-managed nonce, gas and fees; false or omission requires wallet-paid gas.
199
+ * Unsupported explicit controls produce an API error; the SDK preserves them and never changes the payer.
200
+ */
201
+ sponsoredGas?: boolean;
202
+ /** Generated self-funded EVM prices only; omission means normal. Explicit prices remain pinned. */
203
+ urgency?: EvmFeeUrgency;
150
204
  chainId?: string | number;
151
205
  tokenAddress?: string;
152
206
  nonce?: number;
@@ -160,12 +214,16 @@ export interface TransferRequest extends RestSigningInitiator {
160
214
  network?: SolanaNetwork;
161
215
  }
162
216
  export interface LegacyTransferResponse {
217
+ sponsoredGas?: false;
218
+ /** @deprecated Use sponsoredGas. Retained for compatibility with older responses. */
163
219
  executionMode?: 'legacy';
164
220
  signedTransaction: string;
165
221
  txHash?: string;
166
222
  transactionId?: string;
167
223
  }
168
224
  export interface SponsoredTransferResponse extends RestSponsorshipDetails {
225
+ sponsoredGas?: true;
226
+ /** @deprecated Use sponsoredGas. Retained for compatibility with older responses. */
169
227
  executionMode: 'sponsored';
170
228
  transactionId: string;
171
229
  status: RestTransactionKnownStatus;
@@ -173,6 +231,34 @@ export interface SponsoredTransferResponse extends RestSponsorshipDetails {
173
231
  signedTransaction?: never;
174
232
  }
175
233
  export type TransferResponse = LegacyTransferResponse | SponsoredTransferResponse;
234
+ export type EvmAutoRetryTransferRequest = Pick<TransferRequest, 'to' | 'value' | 'tokenAddress' | 'nonce' | 'gasLimit' | 'maxFeePerGas' | 'maxPriorityFeePerGas' | 'gasPrice' | 'type' | 'urgency'> & {
235
+ chainId: string | number;
236
+ kind?: 'NATIVE' | 'ERC20';
237
+ sponsoredGas?: false;
238
+ broadcast?: true;
239
+ addressScreening?: true;
240
+ autoRetry: EvmAutoRetryAuthorization;
241
+ };
242
+ /** HTTP 202 is durable admission, before signing or broadcast. */
243
+ export interface AutoRetryTransferResponse extends RestTransaction {
244
+ sponsoredGas: false;
245
+ autoRetry: RestAutoRetryDetails;
246
+ signedTransaction?: never;
247
+ txHash?: never;
248
+ }
249
+ export interface ManualRecoveryRequest {
250
+ maxExecutionFeeWei: string;
251
+ urgency?: EvmFeeUrgency;
252
+ }
253
+ export interface ManualRecoveryTransferResponse extends RestTransaction {
254
+ manualRecovery: RestManualRecoveryDetails;
255
+ }
256
+ /** Identify Para-paid transfers, including older responses without sponsoredGas. The Boolean takes precedence. */
257
+ export declare function isSponsoredTransfer(result: TransferResponse): result is SponsoredTransferResponse;
258
+ export declare class ParaRestSponsorshipError extends Error {
259
+ readonly response: TransferResponse;
260
+ constructor(requestedSponsorship: boolean, response: TransferResponse);
261
+ }
176
262
  export interface EstimateFeeRequest {
177
263
  to: string;
178
264
  value: string;
@@ -180,6 +266,21 @@ export interface EstimateFeeRequest {
180
266
  tokenAddress?: string;
181
267
  network?: SolanaNetwork;
182
268
  }
269
+ export type EvmFeeOption = {
270
+ gasLimit: string;
271
+ maxExecutionFeeWei: string;
272
+ maxExecutionCostWei: string;
273
+ } & ({
274
+ type: 0;
275
+ gasPrice: string;
276
+ maxFeePerGas?: never;
277
+ maxPriorityFeePerGas?: never;
278
+ } | {
279
+ type: 2;
280
+ maxFeePerGas: string;
281
+ maxPriorityFeePerGas: string;
282
+ gasPrice?: never;
283
+ });
183
284
  export interface EstimateFeeResponse {
184
285
  estimatedFee: string;
185
286
  transferAmount: string;
@@ -188,6 +289,12 @@ export interface EstimateFeeResponse {
188
289
  maxFeePerGas?: string;
189
290
  maxPriorityFeePerGas?: string;
190
291
  gasPrice?: string;
292
+ type?: 0 | 2;
293
+ maxExecutionFeeWei?: string;
294
+ maxExecutionCostWei?: string;
295
+ feeOptions?: Record<EvmFeeUrgency, EvmFeeOption>;
296
+ quotedAt?: string;
297
+ blockNumber?: string;
191
298
  warning?: string;
192
299
  }
193
300
  export interface FaucetRequest {
@@ -203,7 +310,7 @@ export interface FaucetResponse {
203
310
  }
204
311
  export type RestTransactionKnownStatus = 'pending' | 'submitted' | 'confirmed' | 'reverted' | 'failed';
205
312
  export type RestTransactionStatus = RestTransactionKnownStatus | (string & {});
206
- export type RestTransactionIntentKind = 'transfer' | 'sign_transaction';
313
+ export type RestTransactionIntentKind = 'transfer' | 'sign_transaction' | 'yield';
207
314
  export type RestTransactionFailureStage = 'mpc_sign' | 'signature_apply' | 'signer_verify' | 'broadcast' | 'monitor_timeout';
208
315
  export type RestTransactionWalletType = 'EVM' | 'SOLANA';
209
316
  export type RestSponsoredTransactionStage = 'requires_action' | 'preparing' | 'signed' | 'submission_unknown' | 'included' | 'delivery_unverified';
@@ -229,13 +336,15 @@ export interface RestTransaction extends RestSponsorshipDetails {
229
336
  walletType: RestTransactionWalletType;
230
337
  intentKind: RestTransactionIntentKind;
231
338
  status: RestTransactionStatus;
339
+ sponsoredGas?: boolean;
340
+ /** @deprecated Use sponsoredGas. Retained for compatibility with older responses. */
232
341
  executionMode?: 'legacy' | 'sponsored';
233
342
  chainId?: string;
234
343
  network?: SolanaNetwork;
235
344
  to?: string;
236
345
  value?: string;
237
346
  tokenAddress?: string;
238
- hash?: string;
347
+ hash?: string | null;
239
348
  blockNumber?: string;
240
349
  blockHash?: string;
241
350
  failureStage?: RestTransactionFailureStage;
@@ -244,6 +353,97 @@ export interface RestTransaction extends RestSponsorshipDetails {
244
353
  createdAt: string;
245
354
  submittedAt?: string;
246
355
  resolvedAt?: string;
356
+ autoRetry?: RestAutoRetryDetails;
357
+ manualRecovery?: RestManualRecoveryDetails;
358
+ monitoring?: {
359
+ state: string;
360
+ reason?: string;
361
+ winningHash?: string;
362
+ };
363
+ }
364
+ export interface RestAutoRetryDetails {
365
+ state: 'active' | 'stopped' | 'resolved';
366
+ reason?: string;
367
+ nonce?: number;
368
+ network?: SolanaNetwork;
369
+ maxExecutionFeeWei?: string;
370
+ maxExecutionFeeLamports?: string;
371
+ expiresAt: string;
372
+ bumpCount: number;
373
+ latestAttemptHash?: string;
374
+ attempts: Array<{
375
+ ordinal: number;
376
+ stage: 'prepared' | 'signing' | 'rejected' | 'signed' | 'submission_unknown' | 'submitted';
377
+ hash?: string;
378
+ preparedAt: string;
379
+ lastBroadcastAt?: string;
380
+ lastValidBlockHeight?: number;
381
+ }>;
382
+ }
383
+ export interface RestManualRecoveryDetails {
384
+ action: 'speed_up' | 'cancel';
385
+ state: RestAutoRetryDetails['state'];
386
+ reason?: string;
387
+ nonce: number;
388
+ originalHash: string;
389
+ attempt: Pick<RestAutoRetryDetails['attempts'][number], 'stage' | 'hash' | 'preparedAt' | 'lastBroadcastAt'>;
390
+ }
391
+ export type RestYieldPhase = 'approval' | 'action';
392
+ export interface RestYieldAutoRetryAuthorization {
393
+ /** One original operation deadline, shared by every phase and replay. */
394
+ expiresAt: string;
395
+ action: {
396
+ maxExecutionFeeWei: string;
397
+ };
398
+ /** Required before a needed token approval can be signed; never inferred from action. */
399
+ approval?: {
400
+ maxExecutionFeeWei: string;
401
+ };
402
+ }
403
+ export type CreateYieldRequest = ({
404
+ marketId: string;
405
+ chainId?: string | number;
406
+ } | {
407
+ chainId: string | number;
408
+ marketId?: string;
409
+ }) & {
410
+ /** USDC decimal units; withdrawals also accept "all". */
411
+ amount: string;
412
+ /** Applied to fresh approval/action prices; retained across phases, retries, and replays. */
413
+ urgency?: EvmFeeUrgency;
414
+ autoRetry?: RestYieldAutoRetryAuthorization;
415
+ };
416
+ export interface RestYieldOperation {
417
+ id: string;
418
+ walletId: string;
419
+ chainId: number;
420
+ source: 'aave-v3' | 'morpho-v2';
421
+ marketId: string;
422
+ action: 'deposit' | 'withdraw';
423
+ amount: string;
424
+ status: 'pending' | 'submitted' | 'confirmed' | 'failed' | 'requires_action' | 'cancelled';
425
+ transactions: Array<{
426
+ phase: RestYieldPhase;
427
+ transactionId: string;
428
+ hash: string;
429
+ nonce: number;
430
+ status: 'signed' | 'submitted' | 'confirmed' | 'reverted' | 'failed';
431
+ blockNumber?: number;
432
+ blockHash?: string;
433
+ }>;
434
+ autoRetry?: RestYieldAutoRetryAuthorization & {
435
+ phases: Array<RestAutoRetryDetails & {
436
+ phase: RestYieldPhase;
437
+ transactionId: string;
438
+ }>;
439
+ };
440
+ error?: {
441
+ code: string;
442
+ message: string | null;
443
+ reviewId?: string;
444
+ };
445
+ createdAt: string;
446
+ updatedAt: string;
247
447
  }
248
448
  export type RestOnRampPurchaseKnownStatus = 'INITIATED' | 'FINISHED' | 'CANCELLED';
249
449
  /**
@@ -329,13 +529,32 @@ export declare class ParaRestClient extends RestPermissionsClient {
329
529
  signRaw(walletId: string, body: SignRawRequest, options?: ParaRestCallOptions): Promise<SignRawResponse>;
330
530
  signMessage(walletId: string, body: SignMessageRequest, options?: ParaRestCallOptions): Promise<SignMessageResponse>;
331
531
  signTransaction(walletId: string, body: SignTransactionRequest, options?: ParaRestCallOptions): Promise<SignTransactionResponse>;
532
+ signTransactionWithAutoRetry(walletId: string, body: AutoRetrySignTransactionRequest, options: ParaRestCallOptions & {
533
+ idempotencyKey: string;
534
+ }): Promise<AutoRetrySignTransactionResponse>;
332
535
  signTypedData(walletId: string, body: SignTypedDataRequest, options?: ParaRestCallOptions): Promise<SignTypedDataResponse>;
333
536
  signAuthorization(walletId: string, body: SignAuthorizationRequest, options?: ParaRestCallOptions): Promise<SignAuthorizationResponse>;
334
537
  transfer(walletId: string, body: TransferRequest, options?: ParaRestCallOptions): Promise<TransferResponse>;
538
+ transferWithAutoRetry(walletId: string, body: EvmAutoRetryTransferRequest, options: ParaRestCallOptions & {
539
+ idempotencyKey: string;
540
+ }): Promise<AutoRetryTransferResponse>;
335
541
  estimateFee(walletId: string, body: EstimateFeeRequest, options?: ParaRestCallOptions): Promise<EstimateFeeResponse>;
336
542
  requestFaucet(body: FaucetRequest, options?: ParaRestCallOptions): Promise<FaucetResponse>;
337
543
  listRestTransactions(walletId: string, query?: ListRestTransactionsRequest, options?: ParaRestCallOptions): Promise<RestListResponse<RestTransaction>>;
338
544
  getRestTransaction(walletId: string, transactionId: string, options?: ParaRestCallOptions): Promise<RestTransaction>;
545
+ speedUpRestTransaction(walletId: string, transactionId: string, body: ManualRecoveryRequest, options: ParaRestCallOptions & {
546
+ idempotencyKey: string;
547
+ }): Promise<ManualRecoveryTransferResponse>;
548
+ cancelRestTransaction(walletId: string, transactionId: string, body: ManualRecoveryRequest, options: ParaRestCallOptions & {
549
+ idempotencyKey: string;
550
+ }): Promise<ManualRecoveryTransferResponse>;
551
+ createYieldDeposit(walletId: string, body: CreateYieldRequest, options: ParaRestCallOptions & {
552
+ idempotencyKey: string;
553
+ }): Promise<RestYieldOperation>;
554
+ createYieldWithdrawal(walletId: string, body: CreateYieldRequest, options: ParaRestCallOptions & {
555
+ idempotencyKey: string;
556
+ }): Promise<RestYieldOperation>;
557
+ getYieldOperation(walletId: string, operationId: string, options?: ParaRestCallOptions): Promise<RestYieldOperation>;
339
558
  resumeRestTransaction(walletId: string, transactionId: string, body: ResumeRestTransactionRequest, options?: ParaRestCallOptions): Promise<SponsoredTransferResponse>;
340
559
  /**
341
560
  * Look up a fiat on-ramp purchase by id — the id the SDK reports on the `ONRAMP_LAUNCHED` event, and the