@getpara/rest-sdk 3.20.0 → 3.22.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/README.md +51 -0
- package/dist/cjs/index.js +9 -0
- package/dist/esm/index.js +9 -0
- package/dist/types/index.d.ts +26 -3
- package/dist/types/webhooks.d.ts +1 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -135,6 +135,57 @@ methods as the read model: fetch the record immediately after a broadcast, backf
|
|
|
135
135
|
reconcile your database against Para's persisted transaction state. See the Para webhook docs for signature
|
|
136
136
|
verification and `rest.transaction.confirmed` / `rest.transaction.failed` payload examples.
|
|
137
137
|
|
|
138
|
+
## Sponsored Transfers
|
|
139
|
+
|
|
140
|
+
Para enables gas sponsorship per partner through its existing admin-managed `featureFlags.restGasSponsorship` setting.
|
|
141
|
+
For enabled partners, eligible EVM token transfers return HTTP 202 with
|
|
142
|
+
`executionMode: 'sponsored'`, a `transactionId`, and a status. The response has no `signedTransaction`.
|
|
143
|
+
The SDK request is unchanged. Check `executionMode` before reading legacy response fields.
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
// Save this key with your payout before the request. Reuse it if the response is lost.
|
|
147
|
+
const requestKey = crypto.randomUUID();
|
|
148
|
+
const result = await para.transfer(
|
|
149
|
+
wallet.id,
|
|
150
|
+
{ to: recipient, value: '1000000', chainId, tokenAddress, kind: 'ERC20' },
|
|
151
|
+
{ idempotencyKey: requestKey },
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
if (result.executionMode === 'sponsored') {
|
|
155
|
+
// Save the tracking ID, then poll this lookup from your background job.
|
|
156
|
+
const record = await para.getRestTransaction(wallet.id, result.transactionId);
|
|
157
|
+
console.log(record.status, record.stage, record.hash, record.actualGasCost);
|
|
158
|
+
} else {
|
|
159
|
+
console.log(result.signedTransaction, result.txHash);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Sponsored requests require an idempotency key and a positive integer `value` in token base units. Sponsorship manages
|
|
164
|
+
gas and submission: omit nonce, transaction type and gas/fee overrides; omit `broadcast` or set it to `true`.
|
|
165
|
+
The server applies its configured supported chains and tokens. With the partner flag enabled, pausing global or
|
|
166
|
+
chain sponsorship rejects matching transfers rather than falling back to wallet-paid gas. Turning the partner flag
|
|
167
|
+
off routes new requests through the ordinary transfer path; existing sponsored operations retain their tracking IDs.
|
|
168
|
+
|
|
169
|
+
Poll `getRestTransaction` until the status is `confirmed`, `reverted`, or `failed`; stop polling for policy approval when
|
|
170
|
+
`stage` is `requires_action`. `submitted` with stage `included` is still awaiting receipt verification. `submission_unknown` means
|
|
171
|
+
the provider may have received the operation. `delivery_unverified` means the operation was included but token delivery
|
|
172
|
+
needs reconciliation; neither stage is a reason to send again. Reuse the original request and key to recover a lost
|
|
173
|
+
response, and resume polling the original tracking ID. The SDK does not retry or poll automatically.
|
|
174
|
+
|
|
175
|
+
Conditional approval policies are not supported for sponsored transfers in this pilot.
|
|
176
|
+
After an existing policy review is approved, explicitly continue the same operation:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
await para.resumeRestTransaction(wallet.id, transactionId, { reviewId });
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Resume accepts a review ID, not a new transfer. Repeating `transfer` with the original key only retrieves the existing
|
|
183
|
+
operation and does not resume it. `userOperationHash` identifies the sponsored operation; `txHash` on the transfer
|
|
184
|
+
response and `hash` in transaction history identify its on-chain transaction once included. `actualGasCost` is a decimal
|
|
185
|
+
string in the chain's native-token base units after settlement, including included reverts. Keep it as a string or
|
|
186
|
+
convert it to `bigint`, not `number`. Use `getRestTransaction()` for sponsorship stage, review details, user-operation hash,
|
|
187
|
+
and settled gas cost; `listRestTransactions()` returns transaction summaries. Fetch persisted status to reconcile missed webhooks.
|
|
188
|
+
|
|
138
189
|
## On-Ramp Purchases
|
|
139
190
|
|
|
140
191
|
`getOnRampPurchase` looks up a fiat on-ramp purchase by the id the SDK reports on the `ONRAMP_LAUNCHED` event — the
|
package/dist/cjs/index.js
CHANGED
|
@@ -223,6 +223,15 @@ class ParaRestClient extends import_permissions.RestPermissionsClient {
|
|
|
223
223
|
}
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
|
+
resumeRestTransaction(walletId, transactionId, body, options) {
|
|
227
|
+
(0, import_validation.requireBody)(body, "body");
|
|
228
|
+
(0, import_validation.requireNonEmpty)(body.reviewId, "reviewId");
|
|
229
|
+
return this.request(
|
|
230
|
+
"POST",
|
|
231
|
+
`/v1/wallets/${walletPath(walletId)}/transactions/${(0, import_validation.pathSegment)("transactionId", transactionId)}/resume`,
|
|
232
|
+
{ body, options }
|
|
233
|
+
);
|
|
234
|
+
}
|
|
226
235
|
/**
|
|
227
236
|
* Look up a fiat on-ramp purchase by id — the id the SDK reports on the `ONRAMP_LAUNCHED` event, and the
|
|
228
237
|
* `purchaseId` on the `onramp.completed` webhook. Use it to reconcile a delivery you missed, or to check one still in flight.
|
package/dist/esm/index.js
CHANGED
|
@@ -196,6 +196,15 @@ class ParaRestClient extends RestPermissionsClient {
|
|
|
196
196
|
}
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
|
+
resumeRestTransaction(walletId, transactionId, body, options) {
|
|
200
|
+
requireBody(body, "body");
|
|
201
|
+
requireNonEmpty(body.reviewId, "reviewId");
|
|
202
|
+
return this.request(
|
|
203
|
+
"POST",
|
|
204
|
+
`/v1/wallets/${walletPath(walletId)}/transactions/${pathSegment("transactionId", transactionId)}/resume`,
|
|
205
|
+
{ body, options }
|
|
206
|
+
);
|
|
207
|
+
}
|
|
199
208
|
/**
|
|
200
209
|
* Look up a fiat on-ramp purchase by id — the id the SDK reports on the `ONRAMP_LAUNCHED` event, and the
|
|
201
210
|
* `purchaseId` on the `onramp.completed` webhook. Use it to reconcile a delivery you missed, or to check one still in flight.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export interface EnclavePublicKeyResponse {
|
|
|
58
58
|
generatedAt: string;
|
|
59
59
|
}
|
|
60
60
|
export type SolanaNetwork = 'SOLANA' | 'SOLANA_DEVNET';
|
|
61
|
+
export type SuiNetwork = 'SUI' | 'SUI_TESTNET' | 'SUI_DEVNET';
|
|
61
62
|
export interface GetWalletBalanceRequest {
|
|
62
63
|
chainId?: string | number;
|
|
63
64
|
tokenAddress?: string;
|
|
@@ -85,7 +86,7 @@ export interface SignMessageResponse {
|
|
|
85
86
|
export interface SignTransactionRequest {
|
|
86
87
|
transaction: EvmSignTransactionRequest | string;
|
|
87
88
|
broadcast?: boolean;
|
|
88
|
-
network?: SolanaNetwork;
|
|
89
|
+
network?: SolanaNetwork | SuiNetwork;
|
|
89
90
|
networkPassphrase?: string;
|
|
90
91
|
}
|
|
91
92
|
export interface EvmSignTransactionRequest {
|
|
@@ -157,11 +158,20 @@ export interface TransferRequest {
|
|
|
157
158
|
broadcast?: boolean;
|
|
158
159
|
network?: SolanaNetwork;
|
|
159
160
|
}
|
|
160
|
-
export interface
|
|
161
|
+
export interface LegacyTransferResponse {
|
|
162
|
+
executionMode?: 'legacy';
|
|
161
163
|
signedTransaction: string;
|
|
162
164
|
txHash?: string;
|
|
163
165
|
transactionId?: string;
|
|
164
166
|
}
|
|
167
|
+
export interface SponsoredTransferResponse extends RestSponsorshipDetails {
|
|
168
|
+
executionMode: 'sponsored';
|
|
169
|
+
transactionId: string;
|
|
170
|
+
status: RestTransactionKnownStatus;
|
|
171
|
+
txHash?: string;
|
|
172
|
+
signedTransaction?: never;
|
|
173
|
+
}
|
|
174
|
+
export type TransferResponse = LegacyTransferResponse | SponsoredTransferResponse;
|
|
165
175
|
export interface EstimateFeeRequest {
|
|
166
176
|
to: string;
|
|
167
177
|
value: string;
|
|
@@ -195,18 +205,30 @@ export type RestTransactionStatus = RestTransactionKnownStatus | (string & {});
|
|
|
195
205
|
export type RestTransactionIntentKind = 'transfer' | 'sign_transaction';
|
|
196
206
|
export type RestTransactionFailureStage = 'mpc_sign' | 'signature_apply' | 'signer_verify' | 'broadcast' | 'monitor_timeout';
|
|
197
207
|
export type RestTransactionWalletType = 'EVM' | 'SOLANA';
|
|
208
|
+
export type RestSponsoredTransactionStage = 'requires_action' | 'preparing' | 'signed' | 'submission_unknown' | 'included' | 'delivery_unverified';
|
|
209
|
+
export interface RestSponsorshipDetails {
|
|
210
|
+
userOperationHash?: string;
|
|
211
|
+
stage?: RestSponsoredTransactionStage;
|
|
212
|
+
reviewId?: string;
|
|
213
|
+
/** Actual gas cost in native-token base units, available after settlement. */
|
|
214
|
+
actualGasCost?: string;
|
|
215
|
+
}
|
|
216
|
+
export interface ResumeRestTransactionRequest {
|
|
217
|
+
reviewId: string;
|
|
218
|
+
}
|
|
198
219
|
export interface ListRestTransactionsRequest {
|
|
199
220
|
limit?: number;
|
|
200
221
|
cursor?: string;
|
|
201
222
|
status?: RestTransactionKnownStatus;
|
|
202
223
|
intentKind?: RestTransactionIntentKind;
|
|
203
224
|
}
|
|
204
|
-
export interface RestTransaction {
|
|
225
|
+
export interface RestTransaction extends RestSponsorshipDetails {
|
|
205
226
|
transactionId: string;
|
|
206
227
|
walletId: string;
|
|
207
228
|
walletType: RestTransactionWalletType;
|
|
208
229
|
intentKind: RestTransactionIntentKind;
|
|
209
230
|
status: RestTransactionStatus;
|
|
231
|
+
executionMode?: 'legacy' | 'sponsored';
|
|
210
232
|
chainId?: string;
|
|
211
233
|
network?: SolanaNetwork;
|
|
212
234
|
to?: string;
|
|
@@ -307,6 +329,7 @@ export declare class ParaRestClient extends RestPermissionsClient {
|
|
|
307
329
|
requestFaucet(body: FaucetRequest, options?: ParaRestCallOptions): Promise<FaucetResponse>;
|
|
308
330
|
listRestTransactions(walletId: string, query?: ListRestTransactionsRequest, options?: ParaRestCallOptions): Promise<RestListResponse<RestTransaction>>;
|
|
309
331
|
getRestTransaction(walletId: string, transactionId: string, options?: ParaRestCallOptions): Promise<RestTransaction>;
|
|
332
|
+
resumeRestTransaction(walletId: string, transactionId: string, body: ResumeRestTransactionRequest, options?: ParaRestCallOptions): Promise<SponsoredTransferResponse>;
|
|
310
333
|
/**
|
|
311
334
|
* Look up a fiat on-ramp purchase by id — the id the SDK reports on the `ONRAMP_LAUNCHED` event, and the
|
|
312
335
|
* `purchaseId` on the `onramp.completed` webhook. Use it to reconcile a delivery you missed, or to check one still in flight.
|
package/dist/types/webhooks.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { WebhookEventType } from '@getpara/shared';
|
|
2
|
-
export type { WebhookEvent, WebhookEventPayload, WebhookEventPayloadMap, UserCreatedPayload, WalletCreatedPayload, TransactionSignedPayload, SendBroadcastedPayload, SendConfirmedPayload, SendFailedPayload, RestTransactionConfirmedPayload, RestTransactionFailedPayload, WalletPregenClaimedPayload, UserExternalWalletVerifiedPayload, OnrampCompletedPayload, TestPingPayload, } from '@getpara/shared';
|
|
2
|
+
export type { WebhookEvent, WebhookEventPayload, WebhookEventPayloadMap, UserCreatedPayload, WalletCreatedPayload, TransactionSignedPayload, SendBroadcastedPayload, SendConfirmedPayload, SendFailedPayload, RestTransactionConfirmedPayload, RestTransactionFailedPayload, WalletPregenClaimedPayload, UserExternalWalletVerifiedPayload, OnrampCompletedPayload, UserTwoFactorResetPayload, FundsReceivedPayload, TestPingPayload, } from '@getpara/shared';
|
|
3
3
|
import type { WebhookEventPayloadMap } from '@getpara/shared';
|
|
4
4
|
/**
|
|
5
5
|
* A received webhook, as a discriminated union over the event type.
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/rest-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.22.0",
|
|
4
4
|
"description": "Typed server-side SDK for Para REST wallet management and signing",
|
|
5
5
|
"author": "Para Team <hello@getpara.com> (https://getpara.com)",
|
|
6
|
-
"homepage": "https://docs.getpara.com/
|
|
6
|
+
"homepage": "https://docs.getpara.com/v3/rest/sdk",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"para",
|
|
9
9
|
"rest",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"vitest": "^3.2.4"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@getpara/shared": "^1.
|
|
30
|
+
"@getpara/shared": "^1.35.0"
|
|
31
31
|
},
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@solana/signers": "^2.2.1",
|
|
65
65
|
"@solana/transactions": "^2.2.1",
|
|
66
66
|
"ethers": "^6.13.4",
|
|
67
|
-
"viem": "^2.
|
|
67
|
+
"viem": "^2.10.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|
|
70
70
|
"@solana/addresses": {
|
|
@@ -88,8 +88,9 @@
|
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
90
|
"build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
|
|
91
|
-
"build:types": "
|
|
92
|
-
"test": "vitest run"
|
|
91
|
+
"build:types": "tsc --emitDeclarationOnly",
|
|
92
|
+
"test": "vitest run --coverage",
|
|
93
|
+
"typecheck": "tsc --noEmit"
|
|
93
94
|
},
|
|
94
95
|
"publishConfig": {
|
|
95
96
|
"access": "public"
|
|
@@ -110,5 +111,5 @@
|
|
|
110
111
|
}
|
|
111
112
|
},
|
|
112
113
|
"typings": "dist/types/index.d.ts",
|
|
113
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "4ca50a0fc70e11370595f16daad0f1ac4da0edbc"
|
|
114
115
|
}
|