@paradex/sdk 0.9.0 → 0.11.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.
@@ -97,6 +97,30 @@ export const UNCAPPED_LIMITS = {
97
97
  maxLeverage: NO_CAP,
98
98
  markets: ALL_MARKETS,
99
99
  };
100
+ /** The account a `SessionMint`'s SNIP-12 message hash is taken for: a mint names no account. */
101
+ export const MINT_HASH_ACCOUNT = '0x0';
102
+ /** A `SessionMint` `expiresAt` asking for the longest session the passkey allows. */
103
+ export const LONGEST_SESSION = 0;
104
+ /**
105
+ * The limits a `SessionMint` states to take its passkey's ceiling: every
106
+ * amount empty and no markets.
107
+ */
108
+ export const CEILING_LIMITS = {
109
+ maxOrderNotional: '',
110
+ maxOpenNotional: '',
111
+ dailyNotional: '',
112
+ maxLoss: '',
113
+ maxLeverage: '',
114
+ markets: [],
115
+ };
116
+ /** Whether `limits` are {@link CEILING_LIMITS}: no limit stated at all. */
117
+ export function isCeilingLimits(limits) {
118
+ return (limits != null &&
119
+ typeof limits === 'object' &&
120
+ LIMIT_AMOUNTS.every((key) => limits[key] === '') &&
121
+ Array.isArray(limits.markets) &&
122
+ limits.markets.length === 0);
123
+ }
100
124
  // ---------------------------------------------------------------------------
101
125
  // Type definitions
102
126
  // ---------------------------------------------------------------------------
@@ -108,6 +132,11 @@ const EIP712_LIMITS = [
108
132
  { name: 'maxLeverage', type: 'string' },
109
133
  { name: 'markets', type: 'string[]' },
110
134
  ];
135
+ const EIP712_BUILDER = [
136
+ { name: 'account', type: 'string' },
137
+ { name: 'maxFeeRate', type: 'string' },
138
+ { name: 'expiresAt', type: 'uint64' },
139
+ ];
111
140
  export const SESSION_GRANT_EIP712_TYPES = {
112
141
  SessionGrant: [
113
142
  { name: 'paradexChain', type: 'string' },
@@ -124,11 +153,19 @@ export const SESSION_GRANT_EIP712_TYPES = {
124
153
  { name: 'expiresAt', type: 'uint64' },
125
154
  ],
126
155
  Limits: EIP712_LIMITS,
127
- Builder: [
156
+ Builder: EIP712_BUILDER,
157
+ };
158
+ export const BUILDER_APPROVAL_EIP712_TYPES = {
159
+ BuilderApproval: [
160
+ { name: 'paradexChain', type: 'string' },
161
+ { name: 'environment', type: 'string' },
128
162
  { name: 'account', type: 'string' },
129
- { name: 'maxFeeRate', type: 'string' },
130
- { name: 'expiresAt', type: 'uint64' },
163
+ { name: 'builder', type: 'Builder' },
164
+ { name: 'subaccounts', type: 'string[]' },
165
+ { name: 'nonce', type: 'string' },
166
+ { name: 'issuedAt', type: 'uint64' },
131
167
  ],
168
+ Builder: EIP712_BUILDER,
132
169
  };
133
170
  export const PASSKEY_GRANT_EIP712_TYPES = {
134
171
  PasskeyGrant: [
@@ -163,8 +200,6 @@ export const SESSION_MINT_EIP712_TYPES = {
163
200
  SessionMint: [
164
201
  { name: 'paradexChain', type: 'string' },
165
202
  { name: 'environment', type: 'string' },
166
- { name: 'account', type: 'string' },
167
- { name: 'credentialId', type: 'string' },
168
203
  { name: 'sessionKey', type: 'string' },
169
204
  { name: 'scopes', type: 'string[]' },
170
205
  { name: 'limits', type: 'Limits' },
@@ -246,8 +281,6 @@ export const SESSION_MINT_SNIP12_TYPES = {
246
281
  SessionMint: [
247
282
  { name: 'paradexChain', type: 'shortstring' },
248
283
  { name: 'environment', type: 'shortstring' },
249
- { name: 'account', type: 'ContractAddress' },
250
- { name: 'credentialId', type: 'string' },
251
284
  { name: 'sessionKey', type: 'felt' },
252
285
  { name: 'scopes', type: 'shortstring*' },
253
286
  { name: 'limits', type: 'Limits' },
@@ -262,6 +295,21 @@ export const SESSION_MINT_SNIP12_TYPES = {
262
295
  // ---------------------------------------------------------------------------
263
296
  /** Starknet field prime. */
264
297
  const FELT_PRIME = 2n ** 251n + 17n * 2n ** 192n + 1n;
298
+ /**
299
+ * A builder account in canonical `0x` form, refusing anything but a
300
+ * non-zero felt address. Orders and the Builder Codes calls share it.
301
+ *
302
+ * @internal
303
+ */
304
+ export function builderAddress(value, name = 'builder') {
305
+ if (typeof value !== 'string' ||
306
+ !/^0x[0-9a-fA-F]{1,64}$/.test(value) ||
307
+ BigInt(value) === 0n ||
308
+ BigInt(value) >= FELT_PRIME) {
309
+ throw new Error(`${name} must be a non-zero 0x-prefixed hex address`);
310
+ }
311
+ return `0x${BigInt(value).toString(16)}`;
312
+ }
265
313
  /** Upper bound (exclusive) of a Starknet contract address. */
266
314
  const ADDRESS_BOUND = 2n ** 251n - 256n;
267
315
  const NONCE_BOUND = 2n ** 128n;
@@ -393,8 +441,9 @@ function requireUniqueAddresses(field, values, anchor) {
393
441
  const seen = new Set();
394
442
  values.forEach((v, i) => {
395
443
  requireAddress(`${field}[${i}]`, v);
396
- if (v === anchor)
444
+ if (anchor != null && v === anchor) {
397
445
  throw invalid(field, 'must not include the account');
446
+ }
398
447
  if (seen.has(v))
399
448
  throw invalid(field, 'has duplicates');
400
449
  seen.add(v);
@@ -428,18 +477,16 @@ function isNoCap(value) {
428
477
  * non-empty list, or `["*"]` alone. A limit the server does not enforce
429
478
  * must be `"none"` (`markets`: `["*"]`).
430
479
  *
431
- * @param builderGrant builder grants must cap `maxLoss` with a number, so
432
- * they are refused while the server does not enforce `maxLoss`.
480
+ * Builder grants and builder passkeys follow the same rules as any other grant.
481
+ *
482
+ * @param _builderGrant ignored; kept so existing callers still compile.
433
483
  */
434
- export function validateLimits(limits, builderGrant, field = 'limits', options = {}) {
484
+ export function validateLimits(limits, _builderGrant, field = 'limits', options = {}) {
435
485
  const caps = options.limitCaps ?? DEFAULT_LIMIT_CAPS;
436
486
  const enforced = options.enforcedLimits ?? DEFAULT_ENFORCED_LIMITS;
437
487
  if (limits == null || typeof limits !== 'object') {
438
488
  throw invalid(field, 'is required');
439
489
  }
440
- if (builderGrant && !enforced.includes('maxLoss')) {
441
- throw new SessionGrantError('BUILDER_LIMITS_REQUIRED', `${field}.maxLoss: builder grants need a loss cap, which the server does not enforce yet`);
442
- }
443
490
  for (const key of LIMIT_AMOUNTS) {
444
491
  const value = limits[key];
445
492
  if (value === '' || value == null) {
@@ -447,12 +494,7 @@ export function validateLimits(limits, builderGrant, field = 'limits', options =
447
494
  }
448
495
  if (typeof value !== 'string')
449
496
  throw invalid(`${field}.${key}`, 'must be a string');
450
- if (isNoCap(value)) {
451
- if (key === 'maxLoss' && builderGrant) {
452
- throw new SessionGrantError('BUILDER_LIMITS_REQUIRED', `${field}.maxLoss: builder grants must cap losses with a number`);
453
- }
454
- }
455
- else {
497
+ if (!isNoCap(value)) {
456
498
  requireDecimal(`${field}.${key}`, value, false);
457
499
  if (new BigNumber(value).isZero()) {
458
500
  throw invalid(`${field}.${key}`, 'must be positive');
@@ -490,11 +532,14 @@ export function validateLimits(limits, builderGrant, field = 'limits', options =
490
532
  seen.add(market);
491
533
  });
492
534
  }
493
- function validateBinding(value, noncePresent) {
535
+ function validateBinding(value) {
494
536
  requireShortString('paradexChain', value.paradexChain);
495
537
  requireEnvironment(value.environment);
538
+ requireNonce('nonce', value.nonce);
539
+ }
540
+ function validateAccountBinding(value) {
541
+ validateBinding(value);
496
542
  requireAddress('account', value.account);
497
- requireNonce('nonce', noncePresent.nonce);
498
543
  }
499
544
  function requireLabel(field, value) {
500
545
  if (typeof value !== 'string')
@@ -526,7 +571,7 @@ export function maxSessionTtl(scopes, sessionType = 'browser', clockSkewSeconds
526
571
  * before the owner is asked to sign.
527
572
  */
528
573
  export function validateSessionGrant(grant, options = {}) {
529
- validateBinding(grant, grant);
574
+ validateAccountBinding(grant);
530
575
  requireCanonicalHex('sessionKey', grant.sessionKey, FELT_PRIME);
531
576
  if (grant.sessionKey === '0x0')
532
577
  throw invalid('sessionKey', 'is zero');
@@ -563,13 +608,67 @@ export function validateSessionGrant(grant, options = {}) {
563
608
  if (hasBuilder && builder.account === grant.account) {
564
609
  throw invalid('builder.account', 'must not be the granting account');
565
610
  }
611
+ if (hasBuilder)
612
+ requireBuilderFeeRate(builder.maxFeeRate);
566
613
  if (builder.expiresAt > grant.expiresAt) {
567
614
  throw invalid('builder.expiresAt', 'must not outlive the session');
568
615
  }
616
+ if (builder.expiresAt !== 0 && builder.expiresAt <= grant.issuedAt) {
617
+ throw invalid('builder.expiresAt', 'must be after issuedAt');
618
+ }
569
619
  validateLimits(grant.limits, hasBuilder, 'limits', options);
570
620
  }
621
+ /** Longest a builder approval may live after its `issuedAt`. */
622
+ export const BUILDER_APPROVAL_TTL_MAX = 180 * DAY;
623
+ /** Most decimal places a builder's `maxFeeRate` may have. The server sets the highest rate it accepts. */
624
+ const BUILDER_FEE_RATE_PLACES = 8;
625
+ /**
626
+ * A builder's fee ceiling, as the server checks it on grants and approvals:
627
+ * above 0 and at most 8 decimal places. The server refuses a rate above its
628
+ * configured cap.
629
+ */
630
+ function requireBuilderFeeRate(maxFeeRate) {
631
+ requireDecimal('builder.maxFeeRate', maxFeeRate, false);
632
+ const rate = new BigNumber(maxFeeRate);
633
+ if (rate.isZero()) {
634
+ throw invalid('builder.maxFeeRate', 'must be above 0');
635
+ }
636
+ if ((rate.decimalPlaces() ?? 0) > BUILDER_FEE_RATE_PLACES) {
637
+ throw invalid('builder.maxFeeRate', `must have at most ${BUILDER_FEE_RATE_PLACES} decimal places`);
638
+ }
639
+ }
640
+ /**
641
+ * Checks a builder approval against the server's rules: a builder other than
642
+ * the account, a `maxFeeRate` above 0 with at most 8 decimal places, and a
643
+ * required `expiresAt` at most
644
+ * {@link BUILDER_APPROVAL_TTL_MAX} after `issuedAt`. Throws a
645
+ * {@link SessionGrantError}.
646
+ *
647
+ * @experimental
648
+ */
649
+ export function validateBuilderApproval(approval) {
650
+ validateAccountBinding(approval);
651
+ requireUniqueAddresses('subaccounts', approval.subaccounts, approval.account);
652
+ requireTimestamp('issuedAt', approval.issuedAt);
653
+ const builder = approval.builder;
654
+ if (builder == null || typeof builder !== 'object') {
655
+ throw invalid('builder', 'is required');
656
+ }
657
+ requireAddress('builder.account', builder.account);
658
+ if (builder.account === approval.account) {
659
+ throw invalid('builder.account', 'must not be the approving account');
660
+ }
661
+ requireBuilderFeeRate(builder.maxFeeRate);
662
+ requireTimestamp('builder.expiresAt', builder.expiresAt);
663
+ if (builder.expiresAt <= approval.issuedAt) {
664
+ throw invalid('builder.expiresAt', 'must be after issuedAt');
665
+ }
666
+ if (builder.expiresAt - approval.issuedAt > BUILDER_APPROVAL_TTL_MAX) {
667
+ throw new SessionGrantError('TTL_EXCEEDED', `builder.expiresAt: an approval lives at most ${BUILDER_APPROVAL_TTL_MAX}s after issuedAt`);
668
+ }
669
+ }
571
670
  export function validatePasskeyGrant(grant, options = {}) {
572
- validateBinding(grant, grant);
671
+ validateAccountBinding(grant);
573
672
  requireAddress('builderAccount', grant.builderAccount, false);
574
673
  requireTimestamp('issuedAt', grant.issuedAt);
575
674
  requireTimestamp('expiresAt', grant.expiresAt);
@@ -632,31 +731,53 @@ export function validatePasskeyGrant(grant, options = {}) {
632
731
  throw invalid('ceiling.maxConcurrentSessions', `must be 1-${MAX_PASSKEY_CONCURRENT_SESSIONS}`);
633
732
  }
634
733
  }
734
+ /**
735
+ * Checks a `SessionMint`'s format. Its limits are either all stated (as for
736
+ * a grant) or {@link CEILING_LIMITS}; `expiresAt` may be
737
+ * {@link LONGEST_SESSION}. A mint names no account, so whether its
738
+ * subaccounts leave out the passkey's account is checked by
739
+ * {@link assertMintWithinCeiling}.
740
+ */
635
741
  export function validateSessionMint(mint, options = {}) {
636
- validateBinding(mint, mint);
637
- requireUniqueAddresses('subaccounts', mint.subaccounts, mint.account);
638
- if (!BASE64URL_RE.test(mint.credentialId)) {
639
- throw invalid('credentialId', 'must be base64url');
640
- }
742
+ validateBinding(mint);
743
+ requireUniqueAddresses('subaccounts', mint.subaccounts);
641
744
  requireCanonicalHex('sessionKey', mint.sessionKey, FELT_PRIME);
642
745
  if (mint.sessionKey === '0x0')
643
746
  throw invalid('sessionKey', 'is zero');
644
747
  validateScopes(mint.scopes);
645
- validateLimits(mint.limits, false, 'limits', options);
748
+ if (!isCeilingLimits(mint.limits)) {
749
+ validateLimits(mint.limits, false, 'limits', options);
750
+ }
646
751
  requireTimestamp('expiresAt', mint.expiresAt);
647
752
  }
648
753
  function exceeds(message) {
649
754
  return new SessionGrantError('EXCEEDS_CEILING', message);
650
755
  }
651
756
  /**
652
- * Checks a `SessionMint` against the `PasskeyGrant` it mints under, as the
653
- * server does: same binding and scopes within the ceiling. Only limits the
654
- * server enforces are compared: each must be numeric and at or below a
655
- * numeric ceiling (anything goes under a `"none"` ceiling), and markets must
656
- * be within the ceiling's unless it allows `["*"]`. Unenforced limits are
657
- * `"none"` on the mint and skipped, so passkeys registered with numeric
658
- * limits keep working. Mints under a builder passkey are refused until the
659
- * server enforces `maxLoss`, as builder grants are.
757
+ * Checks a `SessionMint` against the `PasskeyGrant` of the passkey that signs
758
+ * it, as the server does: same chain and environment, and scopes within the
759
+ * ceiling. A mint names no account or passkey; the server finds the grant by
760
+ * the assertion's credential id. Only limits the server enforces are
761
+ * compared: each must be numeric and at or below a numeric ceiling (anything
762
+ * goes under a `"none"` ceiling), and markets must be within the ceiling's
763
+ * unless it allows `["*"]`. Unenforced limits are `"none"` on the mint and
764
+ * skipped, so passkeys registered with numeric limits keep working. A mint
765
+ * stating {@link CEILING_LIMITS} takes the ceiling's and fits by definition.
766
+ * A builder passkey's mints are checked like any other. Subaccounts must not
767
+ * list the passkey's account.
768
+ *
769
+ * The check holds only when `grant`'s passkey signs. With an empty
770
+ * `allowCredentials` the user may pick another passkey, on another account
771
+ * or with another ceiling, and the server checks the mint against that one.
772
+ * Pin `allowCredentials` to `grant.passkey.credentialId`, or compare the
773
+ * account in the server's response with `grant.account` and revoke the
774
+ * session if they differ.
775
+ *
776
+ * Expiry: the passkey must not have expired. `expiresAt`
777
+ * {@link LONGEST_SESSION} always fits. Otherwise it must be in the future
778
+ * and at most the ceiling's `maxSessionTtl` from `now` (less the clock-skew
779
+ * allowance). It may be later than the passkey's expiry: the server then
780
+ * ends the session when the passkey expires.
660
781
  *
661
782
  * @experimental
662
783
  */
@@ -674,12 +795,6 @@ export function assertMintWithinCeiling(mint, grant, now = nowSeconds(), options
674
795
  mint.environment !== grant.environment) {
675
796
  throw new SessionGrantError('ENVIRONMENT_MISMATCH', 'mint and passkey grant are for different environments');
676
797
  }
677
- if (mint.account !== grant.account) {
678
- throw exceeds('account: the mint names a different account');
679
- }
680
- if (mint.credentialId !== grant.passkey.credentialId) {
681
- throw exceeds('credentialId: the mint names a different passkey');
682
- }
683
798
  const { ceiling } = grant;
684
799
  for (const scope of mint.scopes) {
685
800
  if (!ceiling.scopes.includes(scope)) {
@@ -687,30 +802,33 @@ export function assertMintWithinCeiling(mint, grant, now = nowSeconds(), options
687
802
  }
688
803
  }
689
804
  const enforced = options.enforcedLimits ?? DEFAULT_ENFORCED_LIMITS;
690
- if (grant.builderAccount !== NO_BUILDER && !enforced.includes('maxLoss')) {
691
- throw new SessionGrantError('BUILDER_LIMITS_REQUIRED', 'limits.maxLoss: builder passkeys need a loss cap, which the server does not enforce yet');
692
- }
693
- // Limits the server does not enforce are "none" on the mint and are not
694
- // compared, so passkeys registered with numbers keep working.
695
- for (const key of LIMIT_AMOUNTS) {
696
- const cap = ceiling.limits[key];
697
- const value = mint.limits[key];
698
- if (!enforced.includes(key) || isNoCap(cap))
699
- continue;
700
- if (isNoCap(value)) {
701
- throw exceeds(`limits.${key}: the ceiling caps it at ${cap}`);
805
+ // The ceiling's own limits fit by definition. Limits the server does not
806
+ // enforce are "none" on the mint and are not compared, so passkeys
807
+ // registered with numbers keep working.
808
+ if (!isCeilingLimits(mint.limits)) {
809
+ for (const key of LIMIT_AMOUNTS) {
810
+ const cap = ceiling.limits[key];
811
+ const value = mint.limits[key];
812
+ if (!enforced.includes(key) || isNoCap(cap))
813
+ continue;
814
+ if (isNoCap(value)) {
815
+ throw exceeds(`limits.${key}: the ceiling caps it at ${cap}`);
816
+ }
817
+ if (new BigNumber(value).isGreaterThan(cap)) {
818
+ throw exceeds(`limits.${key}: ${value} is above the ceiling ${cap}`);
819
+ }
702
820
  }
703
- if (new BigNumber(value).isGreaterThan(cap)) {
704
- throw exceeds(`limits.${key}: ${value} is above the ceiling ${cap}`);
821
+ const allowedMarkets = enforced.includes('markets')
822
+ ? ceiling.limits.markets
823
+ : ALL_MARKETS;
824
+ for (const market of mint.limits.markets) {
825
+ if (!allowedMarkets.some((pattern) => marketCovers(pattern, market))) {
826
+ throw exceeds(`limits.markets: "${market}" is not in the ceiling`);
827
+ }
705
828
  }
706
829
  }
707
- const allowedMarkets = enforced.includes('markets')
708
- ? ceiling.limits.markets
709
- : ALL_MARKETS;
710
- for (const market of mint.limits.markets) {
711
- if (!allowedMarkets.some((pattern) => marketCovers(pattern, market))) {
712
- throw exceeds(`limits.markets: "${market}" is not in the ceiling`);
713
- }
830
+ if (mint.subaccounts.includes(grant.account)) {
831
+ throw invalid('subaccounts', "must not include the passkey's account");
714
832
  }
715
833
  if (!ceiling.includeFutureSubaccounts) {
716
834
  for (const account of mint.subaccounts) {
@@ -722,6 +840,10 @@ export function assertMintWithinCeiling(mint, grant, now = nowSeconds(), options
722
840
  if (grant.expiresAt <= now) {
723
841
  throw new SessionGrantError('GRANT_EXPIRED', `passkey grant expired at ${grant.expiresAt}`);
724
842
  }
843
+ // The server picks the expiry: the ceiling's maxSessionTtl from its own
844
+ // clock, or the passkey's expiry if that is sooner.
845
+ if (mint.expiresAt === LONGEST_SESSION)
846
+ return;
725
847
  if (mint.expiresAt <= now) {
726
848
  throw new SessionGrantError('GRANT_EXPIRED', `mint expired at ${mint.expiresAt}`);
727
849
  }
@@ -729,7 +851,9 @@ export function assertMintWithinCeiling(mint, grant, now = nowSeconds(), options
729
851
  if (ceiling.maxSessionTtl <= skew) {
730
852
  throw new SessionGrantError('TTL_EXCEEDED', `ceiling.maxSessionTtl: ${ceiling.maxSessionTtl}s leaves no time after ${skew}s of clock skew`);
731
853
  }
732
- const latest = Math.min(grant.expiresAt, now + ceiling.maxSessionTtl - skew);
854
+ // A mint may outlive its passkey: the server ends the session when the
855
+ // passkey expires.
856
+ const latest = now + ceiling.maxSessionTtl - skew;
733
857
  if (mint.expiresAt > latest) {
734
858
  throw exceeds(`expiresAt: must be at or before ${latest}`);
735
859
  }
@@ -796,6 +920,31 @@ export function createSessionGrant(params) {
796
920
  });
797
921
  return grant;
798
922
  }
923
+ /**
924
+ * Builds a canonical, validated {@link BuilderApproval}.
925
+ *
926
+ * @experimental
927
+ */
928
+ export function createBuilderApproval(params) {
929
+ const approval = {
930
+ paradexChain: params.paradexChain,
931
+ environment: params.environment,
932
+ account: canonicalFelt(params.account),
933
+ builder: {
934
+ account: canonicalFelt(params.builder.account),
935
+ maxFeeRate: params.builder.maxFeeRate,
936
+ expiresAt: params.builder.expiresAt ??
937
+ params.issuedAt + (params.ttlSeconds ?? BUILDER_APPROVAL_TTL_MAX),
938
+ },
939
+ subaccounts: (params.subaccounts ?? []).map((a) => canonicalFelt(a)),
940
+ nonce: params.nonce != null
941
+ ? canonicalFelt(params.nonce)
942
+ : generateSessionNonce(),
943
+ issuedAt: params.issuedAt,
944
+ };
945
+ validateBuilderApproval(approval);
946
+ return approval;
947
+ }
799
948
  /** Every account a grant reaches: the anchor first, then its sub-accounts. */
800
949
  export function grantAccounts(grant) {
801
950
  return [grant.account, ...grant.subaccounts];
@@ -921,6 +1070,17 @@ export function buildSessionMintSnip12(mint, options = {}) {
921
1070
  validateSessionMint(mint, options);
922
1071
  return snip12('SessionMint', SESSION_MINT_SNIP12_TYPES, mint, mint.paradexChain);
923
1072
  }
1073
+ /**
1074
+ * EIP-712 `BuilderApproval`, signed by the account's EVM owner on the
1075
+ * wallet's current chain. There is no SNIP-12 form: the server accepts
1076
+ * builder approvals from EVM owners only.
1077
+ *
1078
+ * @experimental
1079
+ */
1080
+ export function buildBuilderApprovalEip712(approval, signatureChainId) {
1081
+ validateBuilderApproval(approval);
1082
+ return eip712('BuilderApproval', BUILDER_APPROVAL_EIP712_TYPES, approval, signatureChainId);
1083
+ }
924
1084
  /** EIP-712 digest (`0x1901 ‖ domain ‖ struct`) as 0x-prefixed 32-byte hex. */
925
1085
  export function hashEip712(typedData) {
926
1086
  return hashEip712TypedData(typedData);
@@ -935,10 +1095,11 @@ export function hashSnip12(typedData, account) {
935
1095
  }
936
1096
  /**
937
1097
  * The WebAuthn challenge for a `SessionMint`: the 32-byte SNIP-12 message
938
- * hash (for `mint.account`), base64url-encoded without padding.
1098
+ * hash, taken for {@link MINT_HASH_ACCOUNT} (`0x0`) since a mint names no
1099
+ * account, base64url-encoded without padding.
939
1100
  */
940
1101
  export function sessionMintChallenge(mint, options = {}) {
941
- const hash = hashSnip12(buildSessionMintSnip12(mint, options), mint.account);
1102
+ const hash = hashSnip12(buildSessionMintSnip12(mint, options), MINT_HASH_ACCOUNT);
942
1103
  const bytes = hexToBytes(hash.slice(2));
943
1104
  let binary = '';
944
1105
  for (const b of bytes)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paradex/sdk",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "JavaScript SDK for Paradex",
5
5
  "main": "dist/index.js",
6
6
  "files": [