@paradex/sdk 0.8.0 → 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 +81 -8
- package/dist/account.js +304 -14
- package/dist/client.d.ts +13 -4
- package/dist/client.js +12 -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-account-support.js +23 -1
- package/dist/starknet-signer.d.ts +3 -4
- package/dist/starknet-signer.js +10 -14
- package/package.json +6 -6
|
@@ -11,6 +11,8 @@ const BRAAVOS_MULTI_OWNER_V1_0_0_CLASS_HASH = '0x041bf1e71792aecb9df3e9d04e15400
|
|
|
11
11
|
const BRAAVOS_V1_0_0_CLASS_HASH = '0x00816dd0297efc55dc1e7559020a3a825e81ef734b558f03c83325d4da7e6253';
|
|
12
12
|
const BRAAVOS_V1_1_0_CLASS_HASH = '0x02c8c7e6fbcfb3e8e15a46648e8914c6aa1fc506fc1e7fb3d1e19630716174bc';
|
|
13
13
|
const BRAAVOS_V1_2_0_CLASS_HASH = '0x03957f9f5a1cbfe918cedc2015c85200ca51a5f7506ecb6de98a5207b759bf8a';
|
|
14
|
+
const KEPLR_OZ_V0_17_0_CLASS_HASH = '0x06cc43e9a4a0036cd09d8a997c61df18d7e4fa9459c907a4664b4e56b679d187';
|
|
15
|
+
const XVERSE_ARGENT_V0_4_0_CLASS_HASH = '0x0663fc01a0dbe1bacc4cd2a4c856eb9784b255a20988aa33d4d52b6fc20bd024';
|
|
14
16
|
export class AccountSupport {
|
|
15
17
|
constructor(
|
|
16
18
|
/** The contract instance of the account. */
|
|
@@ -32,7 +34,8 @@ export class AccountSupport {
|
|
|
32
34
|
if (this.testClassHash(ARGENT_V0_3_1_CLASS_HASH)) {
|
|
33
35
|
return 'argent-v0.3.1';
|
|
34
36
|
}
|
|
35
|
-
if (this.testClassHash(ARGENT_V0_4_0_CLASS_HASH)
|
|
37
|
+
if (this.testClassHash(ARGENT_V0_4_0_CLASS_HASH) ||
|
|
38
|
+
this.testClassHash(XVERSE_ARGENT_V0_4_0_CLASS_HASH)) {
|
|
36
39
|
const ownerTypeResp = (await this.contract.call('get_owner_type'));
|
|
37
40
|
const ownerType = ownerTypeResp.activeVariant();
|
|
38
41
|
switch (ownerType) {
|
|
@@ -111,6 +114,9 @@ export class AccountSupport {
|
|
|
111
114
|
return 'braavos-v1.2.0-stark-signer';
|
|
112
115
|
return 'unknown';
|
|
113
116
|
}
|
|
117
|
+
if (this.testClassHash(KEPLR_OZ_V0_17_0_CLASS_HASH)) {
|
|
118
|
+
return 'keplr-oz-v0.17.0';
|
|
119
|
+
}
|
|
114
120
|
return 'unknown';
|
|
115
121
|
}
|
|
116
122
|
async check() {
|
|
@@ -122,6 +128,7 @@ export class AccountSupport {
|
|
|
122
128
|
case 'braavos-v1.0.0-stark-signer':
|
|
123
129
|
case 'braavos-v1.1.0-stark-signer':
|
|
124
130
|
case 'braavos-v1.2.0-stark-signer':
|
|
131
|
+
case 'keplr-oz-v0.17.0':
|
|
125
132
|
return { ok: true };
|
|
126
133
|
case 'argent-v0.4.0-secp256k1-signer':
|
|
127
134
|
return {
|
|
@@ -227,6 +234,21 @@ export class AccountSupport {
|
|
|
227
234
|
}
|
|
228
235
|
throw new Error('Unsupported Braavos signature');
|
|
229
236
|
}
|
|
237
|
+
case 'keplr-oz-v0.17.0': {
|
|
238
|
+
if (segments.length !== 5) {
|
|
239
|
+
throw new Error('Keplr signature must have 5 segments');
|
|
240
|
+
}
|
|
241
|
+
const [rl, rh, _sl, _sh, _v] = segments;
|
|
242
|
+
if (rl == null || rh == null) {
|
|
243
|
+
throw new Error('Keplr signature is missing R segments');
|
|
244
|
+
}
|
|
245
|
+
// Combine r.low and r.high into a single hex value
|
|
246
|
+
// Uint256 = high * 2^128 + low
|
|
247
|
+
const lowBig = BigInt(rl);
|
|
248
|
+
const highBig = BigInt(rh);
|
|
249
|
+
const r = highBig * 2n ** 128n + lowBig;
|
|
250
|
+
return Starknet.num.toHex(r);
|
|
251
|
+
}
|
|
230
252
|
case 'argent-v0.4.0-secp256k1-signer':
|
|
231
253
|
case 'argent-v0.4.0-secp256r1-signer':
|
|
232
254
|
case 'argent-v0.4.0-eip191-signer':
|
|
@@ -5,10 +5,9 @@ export type { SignerInterface as Signer, TypedData, Signature };
|
|
|
5
5
|
export declare function buildStarknetStarkKeyTypedData(starknetChainId: string): TypedData;
|
|
6
6
|
type StarknetKeypair = [string, string];
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `grindKey()` along the Stark curve.
|
|
8
|
+
* Mirrors `getPrivateKeyFromEthSignature()` in `./key-derivation.ts`:
|
|
9
|
+
* the deterministic signature R segment, hex encoded, is the `keySeed`
|
|
10
|
+
* for `grindKey()` along the Stark curve.
|
|
12
11
|
*/
|
|
13
12
|
export declare function getStarkKeypairFromStarknetSignature(signatureR: string): Promise<StarknetKeypair>;
|
|
14
13
|
export declare function getAccountSupport(account: Starknet.AccountInterface, starknetProvider: Starknet.ProviderInterface): Promise<AccountSupport>;
|
package/dist/starknet-signer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { keyDerivation } from '@starkware-industries/starkware-crypto-utils';
|
|
2
1
|
import * as Starknet from 'starknet';
|
|
3
2
|
import { STARKNET_MAINNET_CHAIN_ID } from './constants.js';
|
|
3
|
+
import * as keyDerivation from './key-derivation.js';
|
|
4
4
|
import { AccountSupport } from './starknet-account-support.js';
|
|
5
5
|
export function buildStarknetStarkKeyTypedData(starknetChainId) {
|
|
6
6
|
return {
|
|
@@ -24,18 +24,13 @@ export function buildStarknetStarkKeyTypedData(starknetChainId) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* `grindKey()` along the Stark curve.
|
|
27
|
+
* Mirrors `getPrivateKeyFromEthSignature()` in `./key-derivation.ts`:
|
|
28
|
+
* the deterministic signature R segment, hex encoded, is the `keySeed`
|
|
29
|
+
* for `grindKey()` along the Stark curve.
|
|
31
30
|
*/
|
|
32
31
|
export async function getStarkKeypairFromStarknetSignature(signatureR) {
|
|
33
|
-
const curve = keyDerivation.StarkExEc;
|
|
34
|
-
if (curve == null) {
|
|
35
|
-
throw new Error('StarkExEc curve is not defined');
|
|
36
|
-
}
|
|
37
32
|
const r = signatureR.replace(/^0x/u, '');
|
|
38
|
-
const privateKey = keyDerivation.grindKey(r
|
|
33
|
+
const privateKey = keyDerivation.grindKey(r);
|
|
39
34
|
const publicKey = keyDerivation.privateToStarkKey(privateKey);
|
|
40
35
|
return [privateKey, publicKey];
|
|
41
36
|
}
|
|
@@ -58,12 +53,13 @@ export async function getAccountSupport(account, starknetProvider) {
|
|
|
58
53
|
return accountSupport;
|
|
59
54
|
}
|
|
60
55
|
const RPC_NODES_MAINNET = [
|
|
61
|
-
'https://starknet
|
|
62
|
-
'https://
|
|
56
|
+
'https://rpc.starknet.lava.build/rpc/v0_9',
|
|
57
|
+
'https://api-starknet-mainnet.n.dwellir.com/79e509c1-b94b-4146-ac66-efdc56786415/rpc/v0_9',
|
|
63
58
|
];
|
|
64
59
|
const RPC_NODES_TESTNET = [
|
|
65
|
-
'https://starknet-
|
|
66
|
-
'https://
|
|
60
|
+
'https://rpc.starknet-testnet.lava.build/rpc/v0_9',
|
|
61
|
+
'https://api-starknet-sepolia.n.dwellir.com/79e509c1-b94b-4146-ac66-efdc56786415/rpc/v0_9',
|
|
62
|
+
'https://starknet.api.onfinality.io/public',
|
|
67
63
|
];
|
|
68
64
|
export function getPublicProvider(chainId) {
|
|
69
65
|
const nodes = chainId === STARKNET_MAINNET_CHAIN_ID
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paradex/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "JavaScript SDK for Paradex",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -28,13 +28,12 @@
|
|
|
28
28
|
"url": "git+https://github.com/tradeparadex/paradex.js.git"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@
|
|
31
|
+
"@noble/hashes": "~1.6.0",
|
|
32
32
|
"bignumber.js": "^9.3.1",
|
|
33
33
|
"starknet": "^8.6.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
|
|
37
|
-
"@types/elliptic": "^6.4.18",
|
|
38
37
|
"@types/jest": "^29.5.14",
|
|
39
38
|
"@typescript-eslint/eslint-plugin": "6.21.0",
|
|
40
39
|
"@typescript-eslint/parser": "6.21.0",
|
|
@@ -45,6 +44,7 @@
|
|
|
45
44
|
"eslint-plugin-n": "^16.6.2 ",
|
|
46
45
|
"eslint-plugin-promise": "^6.0.0",
|
|
47
46
|
"ethers": "^6.15.0",
|
|
47
|
+
"fake-indexeddb": "^6.2.5",
|
|
48
48
|
"husky": "^9.1.7",
|
|
49
49
|
"jest": "^29.7.0",
|
|
50
50
|
"jest-ts-webcompat-resolver": "^1.0.1",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"typescript": "~5.9.3"
|
|
56
56
|
},
|
|
57
57
|
"resolutions": {
|
|
58
|
-
"brace-expansion": "^2.0.2",
|
|
59
|
-
"js-yaml": "^4.1.1",
|
|
60
58
|
"micromatch": "^4.0.8",
|
|
61
|
-
"@babel/helpers": "^7.26.10"
|
|
59
|
+
"@babel/helpers": "^7.26.10",
|
|
60
|
+
"ethers/ws": "^8.21.0",
|
|
61
|
+
"**/@typescript-eslint/typescript-estree/minimatch": "^9.0.7"
|
|
62
62
|
}
|
|
63
63
|
}
|