@n1xyz/nord-ts 0.0.19 → 0.0.21
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/dist/const.d.ts +8 -0
- package/dist/const.js +30 -0
- package/dist/gen/nord.d.ts +882 -0
- package/dist/gen/nord.js +6520 -0
- package/dist/gen/openapi.d.ts +2244 -0
- package/dist/gen/openapi.js +6 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -0
- package/dist/nord/api/actions.d.ts +135 -0
- package/dist/nord/api/actions.js +313 -0
- package/dist/nord/api/core.d.ts +16 -0
- package/dist/nord/api/core.js +81 -0
- package/dist/nord/api/metrics.d.ts +67 -0
- package/dist/nord/api/metrics.js +229 -0
- package/dist/nord/client/Nord.d.ts +282 -0
- package/dist/nord/client/Nord.js +528 -0
- package/dist/nord/client/NordUser.d.ts +340 -0
- package/dist/nord/client/NordUser.js +652 -0
- package/dist/nord/index.d.ts +7 -0
- package/dist/nord/index.js +31 -0
- package/dist/nord/models/Subscriber.d.ts +37 -0
- package/dist/nord/models/Subscriber.js +25 -0
- package/dist/nord/utils/NordError.d.ts +35 -0
- package/dist/nord/utils/NordError.js +49 -0
- package/dist/types.d.ts +251 -0
- package/dist/types.js +101 -0
- package/dist/utils.d.ts +98 -0
- package/dist/utils.js +237 -0
- package/dist/websocket/NordWebSocketClient.d.ts +57 -0
- package/dist/websocket/NordWebSocketClient.js +251 -0
- package/dist/websocket/events.d.ts +19 -0
- package/dist/websocket/events.js +2 -0
- package/dist/websocket/index.d.ts +2 -0
- package/dist/websocket/index.js +5 -0
- package/package.json +8 -2
- package/src/gen/.gitkeep +0 -0
- package/src/gen/nord.ts +7593 -0
- package/src/gen/openapi.ts +2245 -0
- package/src/nord/api/core.ts +1 -16
- package/src/nord/client/Nord.ts +7 -11
- package/src/types.ts +0 -11
- package/src/websocket/NordWebSocketClient.ts +0 -113
- package/.claude/settings.local.json +0 -11
- package/.local/qa.ts +0 -77
- package/.local/test-atomic.ts +0 -112
- package/.prettierignore +0 -2
- package/check.sh +0 -4
- package/default.nix +0 -47
- package/eslint.config.mjs +0 -66
- package/tests/utils.spec.ts +0 -121
- package/tsconfig.eslint.json +0 -12
- package/tsconfig.json +0 -24
package/tests/utils.spec.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "@jest/globals";
|
|
2
|
-
import {
|
|
3
|
-
toScaledU64,
|
|
4
|
-
toScaledU128,
|
|
5
|
-
encodeLengthDelimited,
|
|
6
|
-
decodeLengthDelimited,
|
|
7
|
-
} from "../src/utils";
|
|
8
|
-
import Decimal from "decimal.js";
|
|
9
|
-
import * as proto from "../src/gen/nord";
|
|
10
|
-
|
|
11
|
-
describe("toScaledU64", () => {
|
|
12
|
-
// Used as scaling medium
|
|
13
|
-
const D64 = Decimal.clone({
|
|
14
|
-
precision: 20,
|
|
15
|
-
toExpPos: 20,
|
|
16
|
-
toExpNeg: -20,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const MaxDec = new D64(2).pow(64).sub(1);
|
|
20
|
-
const MaxUint = BigInt(MaxDec.toString());
|
|
21
|
-
|
|
22
|
-
const success: Array<[Decimal.Value, number, bigint]> = [
|
|
23
|
-
[0, 0, 0n],
|
|
24
|
-
[1, 0, 1n],
|
|
25
|
-
[123.45, 3, 123450n],
|
|
26
|
-
[MaxDec, 0, MaxUint],
|
|
27
|
-
[MaxDec.div(1000), 3, MaxUint],
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
success.forEach((sample) => {
|
|
31
|
-
it(`Convert decimal ${sample[0]}*10^${sample[1]} to bignum ${sample[2]} should succeed`, () => {
|
|
32
|
-
expect(toScaledU64(sample[0], sample[1])).toEqual(sample[2]);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const failure: Array<[Decimal.Value, number, string]> = [
|
|
37
|
-
[-1, 0, "Number is negative"],
|
|
38
|
-
[-1000, 2, "Number is negative"],
|
|
39
|
-
[0.1, 0, "Precision loss"],
|
|
40
|
-
[0.0001, 3, "Precision loss"],
|
|
41
|
-
[MaxDec.add(1), 0, "Integer is out of range"],
|
|
42
|
-
[MaxDec.add(1).div(1000), 3, "Integer is out of range"],
|
|
43
|
-
];
|
|
44
|
-
|
|
45
|
-
failure.forEach((sample) => {
|
|
46
|
-
it(`Convert decimal ${sample[0]}/10^${sample[1]} to bignum should fail with ${sample[2]} `, () => {
|
|
47
|
-
expect(() => toScaledU64(sample[0], sample[1])).toThrow(sample[2]);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe("toScaledU128", () => {
|
|
53
|
-
// Used as scaling medium
|
|
54
|
-
const D128 = Decimal.clone({
|
|
55
|
-
precision: 40,
|
|
56
|
-
toExpPos: 40,
|
|
57
|
-
toExpNeg: -40,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const MaxDec = new D128(2).pow(128).sub(1);
|
|
61
|
-
const MaxUint = BigInt(MaxDec.toString());
|
|
62
|
-
|
|
63
|
-
const success: Array<[Decimal.Value, number, bigint]> = [
|
|
64
|
-
[0, 0, 0n],
|
|
65
|
-
[1, 0, 1n],
|
|
66
|
-
[123.45, 3, 123450n],
|
|
67
|
-
[MaxDec, 0, MaxUint],
|
|
68
|
-
[MaxDec.div(1000), 3, MaxUint],
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
success.forEach((sample) => {
|
|
72
|
-
it(`Convert decimal ${sample[0]}*10^${sample[1]} to bignum ${sample[2]} should succeed`, () => {
|
|
73
|
-
expect(toScaledU128(sample[0], sample[1])).toEqual(sample[2]);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const failure: Array<[Decimal.Value, number, string]> = [
|
|
78
|
-
[-1, 0, "Number is negative"],
|
|
79
|
-
[-1000, 2, "Number is negative"],
|
|
80
|
-
[0.1, 0, "Precision loss"],
|
|
81
|
-
[0.0001, 3, "Precision loss"],
|
|
82
|
-
[MaxDec.add(1), 0, "Integer is out of range"],
|
|
83
|
-
[MaxDec.add(1).div(1000), 3, "Integer is out of range"],
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
failure.forEach((sample) => {
|
|
87
|
-
it(`Convert decimal ${sample[0]}/10^${sample[1]} to bignum should fail with ${sample[2]} `, () => {
|
|
88
|
-
expect(() => toScaledU128(sample[0], sample[1])).toThrow(sample[2]);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe("proto.Action encode-decode loop", () => {
|
|
94
|
-
const action: proto.Action = {
|
|
95
|
-
currentTimestamp: 0n,
|
|
96
|
-
nonce: 0,
|
|
97
|
-
kind: {
|
|
98
|
-
$case: "placeOrder",
|
|
99
|
-
value: {
|
|
100
|
-
sessionId: 42n,
|
|
101
|
-
marketId: 9,
|
|
102
|
-
fillMode: proto.FillMode.LIMIT,
|
|
103
|
-
side: proto.Side.ASK,
|
|
104
|
-
isReduceOnly: false,
|
|
105
|
-
price: 12n,
|
|
106
|
-
size: 39n,
|
|
107
|
-
quoteSize: { size: 54n, price: 55n },
|
|
108
|
-
senderAccountId: undefined,
|
|
109
|
-
delegatorAccountId: undefined,
|
|
110
|
-
clientOrderId: 350n,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
it("action encode-decode roundabout should succeed", () => {
|
|
116
|
-
const encoded = encodeLengthDelimited(action, proto.Action);
|
|
117
|
-
const decoded: proto.Action = decodeLengthDelimited(encoded, proto.Action);
|
|
118
|
-
|
|
119
|
-
expect(decoded).toEqual(action);
|
|
120
|
-
});
|
|
121
|
-
});
|
package/tsconfig.eslint.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
|
-
"target": "es2020",
|
|
5
|
-
"lib": ["es2020", "dom"],
|
|
6
|
-
"module": "commonjs",
|
|
7
|
-
"rootDir": "./src",
|
|
8
|
-
"moduleResolution": "Node",
|
|
9
|
-
"outDir": "./dist",
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"strict": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
},
|
|
16
|
-
"typeAcquisition": {
|
|
17
|
-
"include": [
|
|
18
|
-
"jest",
|
|
19
|
-
"@types/jest"
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
|
-
"exclude": ["dist", "**/node_modules/**/*"],
|
|
23
|
-
"include": ["./src/**/*"]
|
|
24
|
-
}
|