@paradex/sdk 0.8.1 → 0.9.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 +204 -0
- package/dist/account.d.ts +79 -8
- package/dist/account.js +298 -12
- package/dist/client.d.ts +12 -4
- package/dist/client.js +11 -3
- package/dist/config.d.ts +6 -1
- package/dist/config.js +3 -2
- package/dist/determinism-guard.d.ts +102 -0
- package/dist/determinism-guard.js +62 -0
- package/dist/eip712.d.ts +40 -0
- package/dist/eip712.js +162 -0
- package/dist/ethereum-signer.d.ts +13 -2
- package/dist/ethereum-signer.js +14 -1
- package/dist/index.d.ts +61 -0
- package/dist/index.js +51 -0
- package/dist/key-derivation.d.ts +19 -0
- package/dist/key-derivation.js +83 -0
- package/dist/session-accounts.d.ts +206 -0
- package/dist/session-accounts.js +747 -0
- package/dist/session-auth.d.ts +31 -0
- package/dist/session-auth.js +115 -0
- package/dist/session-connector.d.ts +132 -0
- package/dist/session-connector.js +304 -0
- package/dist/session-key.d.ts +68 -0
- package/dist/session-key.js +187 -0
- package/dist/session-owner-signer.d.ts +68 -0
- package/dist/session-owner-signer.js +64 -0
- package/dist/session-transport.d.ts +48 -0
- package/dist/session-transport.js +56 -0
- package/dist/session-typed-data.d.ts +346 -0
- package/dist/session-typed-data.js +984 -0
- package/dist/starknet-signer.d.ts +3 -4
- package/dist/starknet-signer.js +5 -10
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -80,6 +80,90 @@ const client = await Paradex.Client.fromStarknetAccount({
|
|
|
80
80
|
});
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
### Account Address
|
|
84
|
+
|
|
85
|
+
The SDK gets the Paradex account address from the Paradex API (`GET /onboarding`), so it matches the account the Paradex app created for the same key, whichever account class it was created with. For a key with no account yet, it is the address a new account will be created at. The API matches the key as written, so when the key has no account the SDK also looks it up zero-padded to 64 hex digits, which finds an account onboarded with the padded key.
|
|
86
|
+
|
|
87
|
+
The API URL comes from the config returned by `Paradex.Config.fetch()`. If you build the config yourself, pass `apiUrl` (for example `https://api.testnet.paradex.trade/v1`):
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const client = await Paradex.Client.fromEthSigner({
|
|
91
|
+
config,
|
|
92
|
+
signer,
|
|
93
|
+
apiUrl: 'https://api.testnet.paradex.trade/v1',
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If the request fails, creating the client throws. It never falls back to a locally computed address, which can belong to a different account.
|
|
98
|
+
|
|
99
|
+
To compute the address locally instead, with no request, pass `serverDeriveAddress: false`. That computes the address of an account created with the legacy proxy class, so use it only for such accounts. The same options are accepted by `Paradex.Client.fromStarknetAccount()`.
|
|
100
|
+
|
|
101
|
+
To look up an address and onboarding status directly from a Paradex public key (or, for an EVM-owned account, from its wallet with `ethAddress` instead of `publicKey`):
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
const info = await Paradex.Onboarding.fetch({
|
|
105
|
+
apiUrl: 'https://api.testnet.paradex.trade/v1',
|
|
106
|
+
publicKey: '0x...',
|
|
107
|
+
});
|
|
108
|
+
console.log(info.address, info.exists);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Determinism guard (experimental)
|
|
112
|
+
|
|
113
|
+
A wallet derives its Paradex key from a signature, so a wallet that does not sign deterministically derives a different key each time. By default `fromEthSigner` asks for the signature twice and compares them. Set `determinismGuard` to check the derived key against the wallet's account instead:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
const client = await Paradex.Client.fromEthSigner({
|
|
117
|
+
config,
|
|
118
|
+
signer,
|
|
119
|
+
determinismGuard: true,
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
With the guard on, the SDK:
|
|
124
|
+
|
|
125
|
+
1. Refuses a wallet that has contract code (a smart contract wallet), before asking for any signature. An EIP-7702 delegated EOA is allowed. A code lookup that fails or times out counts as no code.
|
|
126
|
+
2. Asks for one signature and looks the derived public key up with `GET /onboarding`. If an account holds it, the key is accepted with that one signature.
|
|
127
|
+
3. Otherwise, looks the wallet up. If the wallet already has an account, its key differs from the one just derived: the SDK throws a `DeterminismGuardError` with code `key_mismatch` (or `evm_owned_account` when the wallet's account is an EVM-owned one, which is used through `SessionConnector`). Do not onboard a new account in either case.
|
|
128
|
+
4. Otherwise the account is new: it asks for a second signature and throws `non_deterministic` if the two differ.
|
|
129
|
+
|
|
130
|
+
Any failed lookup throws `lookup_failed`, so the guard never returns a key it could not check. The account address always comes from the Paradex API, as with `serverDeriveAddress: true`.
|
|
131
|
+
|
|
132
|
+
The guard needs the wallet address and a provider to read its code. `Paradex.Signer.fromEthers()` provides both when the ethers signer has a provider. Otherwise pass them, along with providers for any other chain the wallet might be a contract on:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
const client = await Paradex.Client.fromEthSigner({
|
|
136
|
+
config,
|
|
137
|
+
signer,
|
|
138
|
+
determinismGuard: {
|
|
139
|
+
walletAddress: '0x...',
|
|
140
|
+
codeProviders: [mainnetProvider, arbitrumProvider, baseProvider],
|
|
141
|
+
// Called once the key is accepted, e.g. to record that a new wallet
|
|
142
|
+
// passed the two-signature test. The SDK keeps no state between calls.
|
|
143
|
+
onResult: ({ kind, signatures }) => console.log(kind, signatures),
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
For a local private-key wallet with no provider, pass `contractCodeCheck: false`.
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
try {
|
|
152
|
+
await Paradex.Client.fromEthSigner({
|
|
153
|
+
config,
|
|
154
|
+
signer,
|
|
155
|
+
determinismGuard: true,
|
|
156
|
+
});
|
|
157
|
+
} catch (error) {
|
|
158
|
+
if (error instanceof Paradex.DeterminismGuardError) {
|
|
159
|
+
// 'contract_wallet' | 'key_mismatch' | 'evm_owned_account'
|
|
160
|
+
// | 'non_deterministic'
|
|
161
|
+
// | 'lookup_failed' | 'invalid_options'
|
|
162
|
+
console.error(error.code, error.message);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
83
167
|
### Configuration
|
|
84
168
|
|
|
85
169
|
Fetch environment-specific configuration:
|
|
@@ -211,6 +295,105 @@ const result = await provider.callContract({
|
|
|
211
295
|
});
|
|
212
296
|
```
|
|
213
297
|
|
|
298
|
+
### Session Grant Typed Data (experimental)
|
|
299
|
+
|
|
300
|
+
A session grant lets a wallet authorize a short-lived Stark session key to trade, within scopes and limits, without withdrawing. The SDK builds the grant and its typed data in both encodings: EIP-712 for EVM wallets, with domain `{ name: "Paradex Session", version: "1", chainId: <the wallet's current chain> }`, and SNIP-12 revision 1 for Stark owners.
|
|
301
|
+
|
|
302
|
+
> The server side of sessions is not released yet. These APIs may change.
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
const grant = Paradex.SessionTypedData.createGrant({
|
|
306
|
+
paradexChain: 'PRIVATE_SN_PARACLEAR_MAINNET',
|
|
307
|
+
environment: 'mainnet', // or 'testnet'
|
|
308
|
+
account: '0x...', // the owner's Paradex account
|
|
309
|
+
sessionKey: '0x...', // the session's Stark public key
|
|
310
|
+
scopes: ['trade'], // 'trade' | 'trade:rfq' | 'trade:block' | 'account:settings'
|
|
311
|
+
// limits defaults to every limit uncapped ('none', markets ['*']).
|
|
312
|
+
subaccounts: [], // sub-account addresses the session may also trade
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
const chainId = await window.ethereum.request({ method: 'eth_chainId' });
|
|
316
|
+
const typedData = Paradex.SessionTypedData.buildGrantEip712(grant, chainId);
|
|
317
|
+
const digest = Paradex.SessionTypedData.hashEip712(typedData);
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Every limit is stated: a positive decimal (USD; leverage as a multiple) or `"none"` for no cap, and `markets` is a list or `["*"]` for every market. A grant may only set a limit the server enforces. Until it enforces any, every limit must be `"none"` and `markets` `["*"]`, which is the default. When the server enforces some, list them in `enforcedLimits` (for example `['maxOrderNotional', 'markets']`), and only those may be set.
|
|
321
|
+
|
|
322
|
+
Grants are checked before signing. These throw a `SessionGrantError` with a `code`:
|
|
323
|
+
|
|
324
|
+
- reserved scopes (`withdraw:owner`, `trade:isolated`);
|
|
325
|
+
- more than 32 subaccounts;
|
|
326
|
+
- lifetimes past the server caps, less a 5-minute allowance for the client's clock running ahead (`clockSkewSeconds`; pass 0 when `issuedAt` comes from the server's clock);
|
|
327
|
+
- a limit that is empty, or set while the server doesn't enforce it (`LIMIT_INVALID`);
|
|
328
|
+
- builder grants asking for `trade:block` or `account:settings`;
|
|
329
|
+
- builder grants without a numeric `maxLoss`. Builder grants need a loss cap, so they're refused until the server enforces `maxLoss`.
|
|
330
|
+
- labels over 64 characters or outside printable ASCII;
|
|
331
|
+
- passkey ceilings with scopes the server refuses: a first-party passkey's ceiling may carry `trade`, `trade:rfq` and `account:settings`, a builder passkey's only `trade`. Ceilings with subaccounts are refused until the server enables them; pass `passkeySubaccounts: true` once it does.
|
|
332
|
+
|
|
333
|
+
`POST /v2/sessions` caps every grant at 30 days (7 with `trade:block` or `account:settings`). The `api` session type's 180-day cap is for IP-pinned API sessions, which that endpoint does not open; `SessionConnector.open()` always applies the 30-day cap.
|
|
334
|
+
|
|
335
|
+
`assertMintWithinCeiling` keeps a mint's `expiresAt` the same 5 minutes inside the ceiling's `maxSessionTtl`; pass `clockSkewSeconds: 0` when `now` comes from the server's clock. For the same reason `validatePasskeyGrant` refuses a ceiling whose `maxSessionTtl` is 300 seconds or less, which would leave no time to mint; it takes the same `clockSkewSeconds` option.
|
|
336
|
+
|
|
337
|
+
Pass `limitCaps` to refuse limits above your own ceilings before the wallet is asked. Caps apply only to enforced limits; a cap on a limit the server doesn't enforce refuses every grant.
|
|
338
|
+
|
|
339
|
+
Show the owner what they are approving with `SessionTypedData.summarizeGrant(grant)`. Its first line states the risk plainly: _Cannot withdraw; can lose up to `maxLoss` USD by trading_, or, when `maxLoss` is `"none"`, _Cannot withdraw; trading losses are not capped by this session_.
|
|
340
|
+
|
|
341
|
+
### Sessions: trade with a session key (experimental)
|
|
342
|
+
|
|
343
|
+
`SessionConnector` opens a session with **one** wallet prompt. A session cannot withdraw. Its trading losses are capped only by the grant's `maxLoss`, and while that is `"none"` (the default) they are not capped by the session. The Stark session key is generated in the page and stored encrypted under a non-extractable WebCrypto key; the private key is decrypted only while signing. The grant is registered with `POST /v2/sessions`.
|
|
344
|
+
|
|
345
|
+
A grant from a wallet with no Paradex account yet opens the account along with its first session; the account is deployed when it is first funded. Such a grant lists no subaccounts, and its `account` must be the address the server derives for the wallet, which `Paradex.Onboarding.fetch({ apiUrl, ethAddress })` returns (with `exists: false`; this `apiUrl` is the `/v1` base, such as `https://api.testnet.paradex.trade/v1`, not the connector's host root); any other address fails with `INVALID_SIGNATURE` after the wallet has signed. Pass `onboarding: { referralCode, marketingCode, utm, privyAccessToken }` to `open()` for this case: the fields are sent with the grant but not signed, and a grant naming a builder ignores them. Refusals, including the onboarding ones (`INSUFFICIENT_MIN_CHAIN_BALANCE`, `PARENT_ADDRESS_ALREADY_ONBOARDED`, `ONBOARDING_RATE_LIMITED`, `SESSIONS_DISABLED` and others), throw a `SessionApiError` whose `code` is typed as `SessionApiErrorCode`.
|
|
346
|
+
|
|
347
|
+
An EVM-owned account's sub-accounts can be listed before signing in with `connector.listSubaccounts(ethAddress)`. When the owner signer knows its address (`ownerSignerFromEip1193` does; pass `address` to `ownerSignerFromExternal`), `open()` checks a grant's `subaccounts` against that list before the wallet is asked to sign.
|
|
348
|
+
|
|
349
|
+
`SessionAccounts` then mints a JWT per account the grant lists (the main account and any `subaccounts`) through `POST /v1/auth/{session_public_key}` with `PARADEX-STARKNET-ACCOUNT`, each for at most 15 minutes and never past the grant's expiry. It keeps one websocket per account and routes requests by account. Sessions never use `on_behalf_of`. When the server refuses a session token or the session key, `SessionAccounts` checks `GET /v2/sessions/{grant_id}/status`. If the grant is revoked or expired, every account is dropped and `onDropped` is called; any other refusal is treated as transient. RFQ endpoints need `trade:rfq` in the grant, or they answer 403 `INVALID_TOKEN_SCOPE`. Create, execute and drafts are open to a session whose grant also caps nothing and names no builder, where the server has enabled RFQ for the account's sessions; otherwise they answer 403 `REQUEST_NOT_ALLOWED`. An account not yet deployed gets 400 `NOT_ONBOARDED`. None of these ends the session. A session may also deposit into its own account (`POST /v1/deposit-addresses`, and `POST /v1/bridges/layerswap/swaps` with `use_deposit_address` and no `source_address`), but never move funds out. `accounts.revoke()` revokes the grant itself and, by default, cancels the session's resting orders, TWAPs and untriggered stops on every account: once revoked, the key can no longer cancel them. This differs from the Paradex app's own sign-out, which keeps orders because they are the owner's own trading. With `accounts.revoke({ cancelOrders: false })` a grant without a builder signs out and its orders keep working; a builder grant still has its TWAPs and untriggered stops cancelled and keeps only its resting orders.
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
const connector = new Paradex.SessionConnector({
|
|
353
|
+
environment: 'testnet',
|
|
354
|
+
paradexChain: config.paradexChainId,
|
|
355
|
+
// Default: the injected wallet. For MPC providers, use
|
|
356
|
+
// Paradex.Session.ownerSignerFromExternal({ chainId, sign }).
|
|
357
|
+
owner: Paradex.Session.ownerSignerFromEip1193({ provider: window.ethereum }),
|
|
358
|
+
storage: Paradex.Session.indexedDbStorage(),
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
const [existing] = await connector.restore();
|
|
362
|
+
const session =
|
|
363
|
+
existing ??
|
|
364
|
+
(await connector.open({
|
|
365
|
+
account: '0x...',
|
|
366
|
+
subaccounts: ['0x...'],
|
|
367
|
+
scopes: ['trade'],
|
|
368
|
+
// limits defaults to every limit uncapped, as the server requires
|
|
369
|
+
// until it enforces limits (see enforcedLimits).
|
|
370
|
+
}));
|
|
371
|
+
|
|
372
|
+
// The environment and chain come from the grant.
|
|
373
|
+
const accounts = new Paradex.SessionAccounts({
|
|
374
|
+
session,
|
|
375
|
+
onDropped: (reason) => {
|
|
376
|
+
console.warn('Session ended:', reason.code);
|
|
377
|
+
// Delete the key so the next load does not restore the ended session.
|
|
378
|
+
void connector.forget(session);
|
|
379
|
+
},
|
|
380
|
+
});
|
|
381
|
+
await accounts.start();
|
|
382
|
+
|
|
383
|
+
await accounts.placeOrder('0x...', {
|
|
384
|
+
market: 'BTC-USD-PERP',
|
|
385
|
+
side: 'BUY',
|
|
386
|
+
type: 'LIMIT',
|
|
387
|
+
size: '0.01',
|
|
388
|
+
price: '60000',
|
|
389
|
+
});
|
|
390
|
+
const unsubscribe = await accounts.subscribe('0x...', 'orders.ALL', (data) =>
|
|
391
|
+
console.log(data),
|
|
392
|
+
);
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
> `/v2/sessions` is experimental; its request and response shapes may change.
|
|
396
|
+
|
|
214
397
|
## Best Practices
|
|
215
398
|
|
|
216
399
|
### 1. Environment Variables
|
|
@@ -352,12 +535,33 @@ For a full React application example, see: [paradex-react-example](https://githu
|
|
|
352
535
|
| ------------------- | ----------------------------------- | --------------- |
|
|
353
536
|
| `Config.fetch(env)` | Fetch configuration for environment | `ParadexConfig` |
|
|
354
537
|
|
|
538
|
+
### Onboarding
|
|
539
|
+
|
|
540
|
+
| Method | Description | Returns |
|
|
541
|
+
| ------------------------------------------ | ------------------------------------------------------- | ---------------- |
|
|
542
|
+
| `Onboarding.fetch({ apiUrl, publicKey })` | Get the account address and onboarding status for a key | `OnboardingInfo` |
|
|
543
|
+
| `Onboarding.fetch({ apiUrl, ethAddress })` | The same for an EVM wallet's EVM-owned account | `OnboardingInfo` |
|
|
544
|
+
|
|
355
545
|
### Signer
|
|
356
546
|
|
|
357
547
|
| Method | Description | Returns |
|
|
358
548
|
| --------------------------- | ---------------------------- | ---------------- |
|
|
359
549
|
| `Signer.fromEthers(signer)` | Create signer from ethers.js | `EthereumSigner` |
|
|
360
550
|
|
|
551
|
+
### SessionTypedData (experimental)
|
|
552
|
+
|
|
553
|
+
| Method | Description | Returns |
|
|
554
|
+
| ------------------------------------- | ------------------------------------------------ | ----------------- |
|
|
555
|
+
| `createGrant(params)` | Build a canonical, validated `SessionGrant` | `SessionGrant` |
|
|
556
|
+
| `buildGrantEip712(grant, chainId)` | EIP-712 typed data for an EVM wallet | `Eip712TypedData` |
|
|
557
|
+
| `buildGrantSnip12(grant)` | SNIP-12 rev 1 typed data for a Stark owner | `TypedData` |
|
|
558
|
+
| `buildPasskeyGrantEip712/Snip12(...)` | Typed data for `PasskeyGrant` | typed data |
|
|
559
|
+
| `buildMintEip712/Snip12(...)` | Typed data for `SessionMint` | typed data |
|
|
560
|
+
| `hashEip712(typedData)` | EIP-712 digest | `Hex` |
|
|
561
|
+
| `hashSnip12(typedData, account)` | SNIP-12 message hash | `Hex` |
|
|
562
|
+
| `validateGrant(grant)` | Check format rules and lifetime caps | `void` (throws) |
|
|
563
|
+
| `assertGrantActive(grant, now?)` | Throw `GRANT_EXPIRED` once the grant has expired | `void` (throws) |
|
|
564
|
+
|
|
361
565
|
## Support
|
|
362
566
|
|
|
363
567
|
- **Discord:** [Join our Discord](https://discord.gg/paradex)
|
package/dist/account.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Starknet from 'starknet';
|
|
2
2
|
import type { ParadexConfig } from './config.js';
|
|
3
|
+
import { type DeterminismGuardOptions } from './determinism-guard.js';
|
|
3
4
|
import * as ethereumSigner from './ethereum-signer.js';
|
|
4
5
|
import type { Hex } from './types.js';
|
|
5
6
|
export interface Account extends Starknet.Account {
|
|
@@ -12,9 +13,36 @@ export interface AccountCredentials {
|
|
|
12
13
|
readonly address: Hex;
|
|
13
14
|
readonly privateKey: Hex;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Options controlling how the Paradex account address is resolved.
|
|
18
|
+
*/
|
|
19
|
+
export interface AddressDerivationOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Fetch the account address from the Paradex API (`GET /onboarding`).
|
|
22
|
+
* The API returns the stored address of an existing account of either
|
|
23
|
+
* account class, and the current-class address for a new one.
|
|
24
|
+
* Defaults to true.
|
|
25
|
+
*
|
|
26
|
+
* Pass false to compute the address locally from the class hashes in the
|
|
27
|
+
* config, with no request. That computes the legacy proxy-class address,
|
|
28
|
+
* which is only right for accounts created with the legacy class.
|
|
29
|
+
*/
|
|
30
|
+
readonly serverDeriveAddress?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Paradex REST API base URL used to fetch the address.
|
|
33
|
+
* Defaults to `config.paradexApiUrl`.
|
|
34
|
+
*/
|
|
35
|
+
readonly apiUrl?: string;
|
|
36
|
+
}
|
|
37
|
+
interface DeriveFromEthSignerParams extends AddressDerivationOptions {
|
|
16
38
|
readonly config: ParadexConfig;
|
|
17
39
|
readonly signer: ethereumSigner.EthereumSigner;
|
|
40
|
+
/**
|
|
41
|
+
* Check the derived key against the wallet's existing account before
|
|
42
|
+
* trusting it. See `DeterminismGuardOptions`.
|
|
43
|
+
* @experimental
|
|
44
|
+
*/
|
|
45
|
+
readonly determinismGuard?: boolean | DeterminismGuardOptions;
|
|
18
46
|
}
|
|
19
47
|
/**
|
|
20
48
|
* Derives Paradex account credentials from an Ethereum wallet.
|
|
@@ -22,19 +50,21 @@ interface DeriveFromEthSignerParams {
|
|
|
22
50
|
* @internal
|
|
23
51
|
* @returns The account address and private key.
|
|
24
52
|
*/
|
|
25
|
-
export declare function deriveFromEthSigner({ config, signer, }: DeriveFromEthSignerParams): Promise<AccountCredentials>;
|
|
26
|
-
interface FromEthSignerParams {
|
|
53
|
+
export declare function deriveFromEthSigner({ config, signer, serverDeriveAddress, apiUrl, determinismGuard, }: DeriveFromEthSignerParams): Promise<AccountCredentials>;
|
|
54
|
+
interface FromEthSignerParams extends AddressDerivationOptions {
|
|
27
55
|
readonly provider: Starknet.ProviderOptions | Starknet.ProviderInterface;
|
|
28
56
|
readonly config: ParadexConfig;
|
|
29
57
|
readonly signer: ethereumSigner.EthereumSigner;
|
|
58
|
+
/** @experimental See `DeterminismGuardOptions`. */
|
|
59
|
+
readonly determinismGuard?: boolean | DeterminismGuardOptions;
|
|
30
60
|
}
|
|
31
61
|
/**
|
|
32
62
|
* Generates a Paradex account from an Ethereum wallet.
|
|
33
63
|
* @deprecated Use deriveFromEthSigner() and pass credentials to DefaultProvider constructor
|
|
34
64
|
* @returns The generated Paradex account.
|
|
35
65
|
*/
|
|
36
|
-
export declare function fromEthSigner({ provider, config, signer, }: FromEthSignerParams): Promise<Account>;
|
|
37
|
-
interface DeriveFromStarknetAccountParams {
|
|
66
|
+
export declare function fromEthSigner({ provider, config, signer, serverDeriveAddress, apiUrl, determinismGuard, }: FromEthSignerParams): Promise<Account>;
|
|
67
|
+
interface DeriveFromStarknetAccountParams extends AddressDerivationOptions {
|
|
38
68
|
readonly config: ParadexConfig;
|
|
39
69
|
readonly account: Starknet.AccountInterface;
|
|
40
70
|
readonly starknetProvider?: Starknet.ProviderInterface;
|
|
@@ -46,8 +76,8 @@ interface DeriveFromStarknetAccountParams {
|
|
|
46
76
|
* @internal
|
|
47
77
|
* @returns The account address and private key.
|
|
48
78
|
*/
|
|
49
|
-
export declare function deriveFromStarknetAccount({ config, account, starknetProvider, rpcUrl, }: DeriveFromStarknetAccountParams): Promise<AccountCredentials>;
|
|
50
|
-
interface FromStarknetAccountParams {
|
|
79
|
+
export declare function deriveFromStarknetAccount({ config, account, starknetProvider, rpcUrl, serverDeriveAddress, apiUrl, }: DeriveFromStarknetAccountParams): Promise<AccountCredentials>;
|
|
80
|
+
interface FromStarknetAccountParams extends AddressDerivationOptions {
|
|
51
81
|
/** Paradex chain provider */
|
|
52
82
|
readonly provider: Starknet.ProviderOptions | Starknet.ProviderInterface;
|
|
53
83
|
readonly config: ParadexConfig;
|
|
@@ -60,7 +90,48 @@ interface FromStarknetAccountParams {
|
|
|
60
90
|
* @deprecated Use deriveFromStarknetAccount() and pass credentials to DefaultProvider constructor
|
|
61
91
|
* @returns The generated Paradex account.
|
|
62
92
|
*/
|
|
63
|
-
export declare function fromStarknetAccount({ provider, config, account, starknetProvider, rpcUrl, }: FromStarknetAccountParams): Promise<Account>;
|
|
93
|
+
export declare function fromStarknetAccount({ provider, config, account, starknetProvider, rpcUrl, serverDeriveAddress, apiUrl, }: FromStarknetAccountParams): Promise<Account>;
|
|
94
|
+
/**
|
|
95
|
+
* Class hash(es) the Paradex API used to derive an account address.
|
|
96
|
+
*/
|
|
97
|
+
export interface OnboardingDerivationInfo {
|
|
98
|
+
readonly classHash: Hex;
|
|
99
|
+
/** Present only for accounts deployed behind the legacy proxy class. */
|
|
100
|
+
readonly proxyClassHash?: Hex;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Onboarding status of a Starknet public key, or of an EVM wallet's
|
|
104
|
+
* EVM-owned account, as reported by the Paradex API.
|
|
105
|
+
*/
|
|
106
|
+
export interface OnboardingInfo {
|
|
107
|
+
/** The Paradex account address for the public key or wallet. */
|
|
108
|
+
readonly address: Hex;
|
|
109
|
+
/** Whether the account has already been onboarded. */
|
|
110
|
+
readonly exists: boolean;
|
|
111
|
+
readonly accountSignerType: string;
|
|
112
|
+
readonly derivationInfo?: OnboardingDerivationInfo;
|
|
113
|
+
}
|
|
114
|
+
type FetchOnboardingParams = {
|
|
115
|
+
/** Paradex REST API base URL, e.g. `https://api.testnet.paradex.trade/v1` */
|
|
116
|
+
readonly apiUrl: string;
|
|
117
|
+
} & ({
|
|
118
|
+
/** Paradex (Stark) public key in hex format */
|
|
119
|
+
readonly publicKey: Hex;
|
|
120
|
+
readonly ethAddress?: undefined;
|
|
121
|
+
} | {
|
|
122
|
+
/**
|
|
123
|
+
* The owner wallet of an EVM-owned (EIP-191) account. For a wallet with
|
|
124
|
+
* no account yet, the address is the one its first session grant opens.
|
|
125
|
+
*/
|
|
126
|
+
readonly ethAddress: string;
|
|
127
|
+
readonly publicKey?: undefined;
|
|
128
|
+
});
|
|
129
|
+
/**
|
|
130
|
+
* Fetches the account address and onboarding status for a Starknet public key,
|
|
131
|
+
* or for the wallet of an EVM-owned account, from the Paradex API. Public
|
|
132
|
+
* endpoint, no authentication required.
|
|
133
|
+
*/
|
|
134
|
+
export declare function fetchOnboarding(params: FetchOnboardingParams): Promise<OnboardingInfo>;
|
|
64
135
|
/**
|
|
65
136
|
* Checks if starknet signatures are equal.
|
|
66
137
|
*/
|