@reyaxyz/sdk 0.151.4 → 0.152.1
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 +1 -1
- package/dist/services/orders/index.js +1 -1
- package/dist/services/orders/index.js.map +1 -1
- package/dist/services/orders/nonce.js +37 -0
- package/dist/services/orders/nonce.js.map +1 -0
- package/dist/services/orders/orderV2.js +416 -89
- package/dist/services/orders/orderV2.js.map +1 -1
- package/dist/services/orders/triggerSettlementHeadroom.js +51 -0
- package/dist/services/orders/triggerSettlementHeadroom.js.map +1 -0
- package/dist/services/orders/types.js.map +1 -1
- package/dist/types/services/orders/index.d.ts +1 -1
- package/dist/types/services/orders/index.d.ts.map +1 -1
- package/dist/types/services/orders/nonce.d.ts +2 -0
- package/dist/types/services/orders/nonce.d.ts.map +1 -0
- package/dist/types/services/orders/orderV2.d.ts +194 -14
- package/dist/types/services/orders/orderV2.d.ts.map +1 -1
- package/dist/types/services/orders/triggerSettlementHeadroom.d.ts +33 -0
- package/dist/types/services/orders/triggerSettlementHeadroom.d.ts.map +1 -0
- package/dist/types/services/orders/types.d.ts +1 -11
- package/dist/types/services/orders/types.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/services/orders/index.ts +1 -1
- package/src/services/orders/nonce.ts +34 -0
- package/src/services/orders/orderV2.ts +731 -122
- package/src/services/orders/triggerSettlementHeadroom.ts +56 -0
- package/src/services/orders/types.ts +0 -15
- package/dist/services/orders/order.js +0 -231
- package/dist/services/orders/order.js.map +0 -1
- package/dist/types/services/orders/order.d.ts +0 -4
- package/dist/types/services/orders/order.d.ts.map +0 -1
- package/src/services/orders/order.ts +0 -214
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -15,6 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./order"), exports);
|
|
19
18
|
__exportStar(require("./orderV2"), exports);
|
|
19
|
+
__exportStar(require("./triggerSettlementHeadroom"), exports);
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["services/orders/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["services/orders/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,8DAA4C","sourcesContent":["export * from './types';\nexport * from './orderV2';\nexport * from './triggerSettlementHeadroom';\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Per-wallet monotonic nonce generator for matching-engine order signatures.
|
|
3
|
+
//
|
|
4
|
+
// The matching engine enforces strict `newNonce > currentNonce` per signer.
|
|
5
|
+
// Using raw `Date.now()` as the nonce would fail under same-millisecond batches
|
|
6
|
+
// (UI mass-create / mass-cancel).
|
|
7
|
+
//
|
|
8
|
+
// We use microsecond-scaled wall time as the base and bump from the last
|
|
9
|
+
// returned nonce on collision — matching the Python SDK pattern.
|
|
10
|
+
// JavaScript's single-threaded event loop makes the read-modify-write below
|
|
11
|
+
// atomic per process; no lock is needed.
|
|
12
|
+
//
|
|
13
|
+
// LIMITATION — single-process only: `lastNonceByWallet` is module state, so
|
|
14
|
+
// this guarantee holds ONLY within one process/realm. Two browser tabs, an
|
|
15
|
+
// SSR + client pair, or multiple Node workers signing for the SAME wallet
|
|
16
|
+
// keep independent maps and can mint the same `Date.now()*1000` base in one
|
|
17
|
+
// millisecond; the matching engine's strict comparison silently rejects the
|
|
18
|
+
// loser (a dropped order/cancel, not an auth break). For
|
|
19
|
+
// concurrent multi-context signing, pass an explicit `nonce` (seeded from the
|
|
20
|
+
// matching engine's current nonce) rather than relying on this generator.
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.nextNonce = void 0;
|
|
23
|
+
var lastNonceByWallet = new Map();
|
|
24
|
+
var US_PER_MS = BigInt(1000);
|
|
25
|
+
var ONE = BigInt(1);
|
|
26
|
+
var ZERO = BigInt(0);
|
|
27
|
+
var nextNonce = function (walletAddress) {
|
|
28
|
+
var _a;
|
|
29
|
+
var key = walletAddress.toLowerCase();
|
|
30
|
+
var nowUs = BigInt(Date.now()) * US_PER_MS;
|
|
31
|
+
var prev = (_a = lastNonceByWallet.get(key)) !== null && _a !== void 0 ? _a : ZERO;
|
|
32
|
+
var next = nowUs > prev ? nowUs : prev + ONE;
|
|
33
|
+
lastNonceByWallet.set(key, next);
|
|
34
|
+
return next;
|
|
35
|
+
};
|
|
36
|
+
exports.nextNonce = nextNonce;
|
|
37
|
+
//# sourceMappingURL=nonce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonce.js","sourceRoot":"/","sources":["services/orders/nonce.ts"],"names":[],"mappings":";AAAA,6EAA6E;AAC7E,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,kCAAkC;AAClC,EAAE;AACF,yEAAyE;AACzE,iEAAiE;AACjE,4EAA4E;AAC5E,yCAAyC;AACzC,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,yDAAyD;AACzD,8EAA8E;AAC9E,0EAA0E;;;AAE1E,IAAM,iBAAiB,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEpD,IAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAC/B,IAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,IAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAEhB,IAAM,SAAS,GAAG,UAAC,aAAqB;;IAC7C,IAAM,GAAG,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IACxC,IAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC;IAC7C,IAAM,IAAI,GAAG,MAAA,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,mCAAI,IAAI,CAAC;IAChD,IAAM,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC;IAC/C,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAPW,QAAA,SAAS,aAOpB","sourcesContent":["// Per-wallet monotonic nonce generator for matching-engine order signatures.\n//\n// The matching engine enforces strict `newNonce > currentNonce` per signer.\n// Using raw `Date.now()` as the nonce would fail under same-millisecond batches\n// (UI mass-create / mass-cancel).\n//\n// We use microsecond-scaled wall time as the base and bump from the last\n// returned nonce on collision — matching the Python SDK pattern.\n// JavaScript's single-threaded event loop makes the read-modify-write below\n// atomic per process; no lock is needed.\n//\n// LIMITATION — single-process only: `lastNonceByWallet` is module state, so\n// this guarantee holds ONLY within one process/realm. Two browser tabs, an\n// SSR + client pair, or multiple Node workers signing for the SAME wallet\n// keep independent maps and can mint the same `Date.now()*1000` base in one\n// millisecond; the matching engine's strict comparison silently rejects the\n// loser (a dropped order/cancel, not an auth break). For\n// concurrent multi-context signing, pass an explicit `nonce` (seeded from the\n// matching engine's current nonce) rather than relying on this generator.\n\nconst lastNonceByWallet = new Map<string, bigint>();\n\nconst US_PER_MS = BigInt(1000);\nconst ONE = BigInt(1);\nconst ZERO = BigInt(0);\n\nexport const nextNonce = (walletAddress: string): bigint => {\n const key = walletAddress.toLowerCase();\n const nowUs = BigInt(Date.now()) * US_PER_MS;\n const prev = lastNonceByWallet.get(key) ?? ZERO;\n const next = nowUs > prev ? nowUs : prev + ONE;\n lastNonceByWallet.set(key, next);\n return next;\n};\n"]}
|