@n1xyz/nord-ts 0.0.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.
Files changed (141) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +20 -0
  3. package/.prettierignore +1 -0
  4. package/README.md +110 -0
  5. package/dist/abis/ERC20_ABI.d.ts +39 -0
  6. package/dist/abis/ERC20_ABI.js +313 -0
  7. package/dist/abis/NORD_GETTERS_FACET_ABI.d.ts +34 -0
  8. package/dist/abis/NORD_GETTERS_FACET_ABI.js +195 -0
  9. package/dist/abis/NORD_RAMP_FACET_ABI.d.ts +35 -0
  10. package/dist/abis/NORD_RAMP_FACET_ABI.js +144 -0
  11. package/dist/abis/index.d.ts +3 -0
  12. package/dist/abis/index.js +9 -0
  13. package/dist/const.d.ts +11 -0
  14. package/dist/const.js +34 -0
  15. package/dist/gen/common.d.ts +63 -0
  16. package/dist/gen/common.js +205 -0
  17. package/dist/gen/nord.d.ts +705 -0
  18. package/dist/gen/nord.js +4784 -0
  19. package/dist/index.d.ts +5 -0
  20. package/dist/index.js +21 -0
  21. package/dist/nord/Nord.d.ts +76 -0
  22. package/dist/nord/Nord.js +376 -0
  23. package/dist/nord/NordImpl.d.ts +7 -0
  24. package/dist/nord/NordImpl.js +6 -0
  25. package/dist/nord/NordUser.d.ts +77 -0
  26. package/dist/nord/NordUser.js +249 -0
  27. package/dist/nord/actions.d.ts +101 -0
  28. package/dist/nord/actions.js +254 -0
  29. package/dist/nord/index.d.ts +2 -0
  30. package/dist/nord/index.js +9 -0
  31. package/dist/types.d.ts +343 -0
  32. package/dist/types.js +92 -0
  33. package/dist/utils.d.ts +114 -0
  34. package/dist/utils.js +257 -0
  35. package/docs/.nojekyll +1 -0
  36. package/docs/assets/highlight.css +92 -0
  37. package/docs/assets/icons.js +15 -0
  38. package/docs/assets/icons.svg +1 -0
  39. package/docs/assets/main.js +59 -0
  40. package/docs/assets/navigation.js +1 -0
  41. package/docs/assets/search.js +1 -0
  42. package/docs/assets/style.css +1415 -0
  43. package/docs/classes/Nord.html +44 -0
  44. package/docs/classes/NordUser.html +35 -0
  45. package/docs/classes/Subscriber.html +6 -0
  46. package/docs/enums/FillMode.html +5 -0
  47. package/docs/enums/KeyType.html +4 -0
  48. package/docs/enums/PeakTpsPeriodUnit.html +15 -0
  49. package/docs/enums/Side.html +3 -0
  50. package/docs/functions/assert.html +1 -0
  51. package/docs/functions/bigIntToProtoU128.html +4 -0
  52. package/docs/functions/checkPubKeyLength.html +1 -0
  53. package/docs/functions/checkedFetch.html +6 -0
  54. package/docs/functions/createWebSocketSubscription.html +12 -0
  55. package/docs/functions/decodeLengthDelimited.html +10 -0
  56. package/docs/functions/encodeLengthDelimited.html +6 -0
  57. package/docs/functions/fillModeToProtoFillMode.html +5 -0
  58. package/docs/functions/findMarket.html +1 -0
  59. package/docs/functions/findToken.html +1 -0
  60. package/docs/functions/makeWalletSignFn.html +6 -0
  61. package/docs/functions/optExpect.html +5 -0
  62. package/docs/functions/optMap.html +5 -0
  63. package/docs/functions/optUnwrap.html +2 -0
  64. package/docs/functions/panic.html +1 -0
  65. package/docs/functions/signAction.html +6 -0
  66. package/docs/functions/toScaledU128.html +8 -0
  67. package/docs/functions/toScaledU64.html +8 -0
  68. package/docs/index.html +21 -0
  69. package/docs/interfaces/Account.html +8 -0
  70. package/docs/interfaces/ActionInfo.html +8 -0
  71. package/docs/interfaces/ActionQuery.html +4 -0
  72. package/docs/interfaces/ActionResponse.html +8 -0
  73. package/docs/interfaces/ActionsExtendedInfo.html +10 -0
  74. package/docs/interfaces/ActionsQuery.html +5 -0
  75. package/docs/interfaces/ActionsResponse.html +6 -0
  76. package/docs/interfaces/AggregateMetrics.html +12 -0
  77. package/docs/interfaces/BlockQuery.html +6 -0
  78. package/docs/interfaces/BlockResponse.html +6 -0
  79. package/docs/interfaces/BlockSummary.html +8 -0
  80. package/docs/interfaces/BlockSummaryResponse.html +6 -0
  81. package/docs/interfaces/DeltaEvent.html +6 -0
  82. package/docs/interfaces/ERC20TokenInfo.html +5 -0
  83. package/docs/interfaces/Info.html +3 -0
  84. package/docs/interfaces/Market.html +6 -0
  85. package/docs/interfaces/MarketStats.html +7 -0
  86. package/docs/interfaces/MarketsStatsResponse.html +2 -0
  87. package/docs/interfaces/NordConfig.html +5 -0
  88. package/docs/interfaces/Order.html +6 -0
  89. package/docs/interfaces/OrderInfo.html +6 -0
  90. package/docs/interfaces/OrderbookOrder.html +6 -0
  91. package/docs/interfaces/OrderbookResponse.html +10 -0
  92. package/docs/interfaces/PerpMarketStats.html +5 -0
  93. package/docs/interfaces/RollmanActionExtendedInfo.html +4 -0
  94. package/docs/interfaces/RollmanActionInfo.html +4 -0
  95. package/docs/interfaces/RollmanActionResponse.html +4 -0
  96. package/docs/interfaces/RollmanActionsResponse.html +2 -0
  97. package/docs/interfaces/RollmanBlockResponse.html +3 -0
  98. package/docs/interfaces/SubscriberConfig.html +3 -0
  99. package/docs/interfaces/Token.html +5 -0
  100. package/docs/interfaces/Trade.html +5 -0
  101. package/docs/interfaces/TradeInfo.html +20 -0
  102. package/docs/interfaces/Trades.html +5 -0
  103. package/docs/interfaces/TradesQueryParams.html +10 -0
  104. package/docs/interfaces/TradesResponse.html +12 -0
  105. package/docs/modules.html +77 -0
  106. package/docs/types/BigIntValue.html +2 -0
  107. package/docs/variables/DEBUG_KEYS.html +1 -0
  108. package/docs/variables/DEFAULT_FUNDING_AMOUNTS.html +1 -0
  109. package/docs/variables/DEV_CONTRACT_ADDRESS.html +1 -0
  110. package/docs/variables/DEV_TOKEN_INFOS.html +1 -0
  111. package/docs/variables/DEV_URL.html +1 -0
  112. package/docs/variables/ERC20_ABI.html +1 -0
  113. package/docs/variables/EVM_DEV_URL.html +1 -0
  114. package/docs/variables/FAUCET_PRIVATE_ADDRESS.html +1 -0
  115. package/docs/variables/MAX_BUFFER_LEN.html +1 -0
  116. package/docs/variables/NORD_GETTERS_FACET_ABI.html +1 -0
  117. package/docs/variables/NORD_RAMP_FACET_ABI.html +1 -0
  118. package/docs/variables/SESSION_TTL.html +1 -0
  119. package/docs/variables/WEBSERVER_DEV_URL.html +1 -0
  120. package/docs/variables/ZERO_DECIMAL.html +1 -0
  121. package/jest.config.ts +9 -0
  122. package/nodemon.json +4 -0
  123. package/package.json +61 -0
  124. package/protoc-generate.sh +23 -0
  125. package/src/abis/ERC20_ABI.ts +310 -0
  126. package/src/abis/NORD_GETTERS_FACET_ABI.ts +192 -0
  127. package/src/abis/NORD_RAMP_FACET_ABI.ts +141 -0
  128. package/src/abis/index.ts +3 -0
  129. package/src/const.ts +39 -0
  130. package/src/gen/common.ts +280 -0
  131. package/src/gen/nord.ts +5666 -0
  132. package/src/index.ts +5 -0
  133. package/src/nord/Nord.ts +504 -0
  134. package/src/nord/NordImpl.ts +8 -0
  135. package/src/nord/NordUser.ts +469 -0
  136. package/src/nord/actions.ts +484 -0
  137. package/src/nord/index.ts +2 -0
  138. package/src/types.ts +393 -0
  139. package/src/utils.ts +300 -0
  140. package/tests/utils.spec.ts +154 -0
  141. package/tsconfig.json +24 -0
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.2.0
5
+ // protoc v5.28.3
6
+ // source: common.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Message_Transfer = exports.Message = exports.protobufPackage = void 0;
9
+ /* eslint-disable */
10
+ const wire_1 = require("@bufbuild/protobuf/wire");
11
+ exports.protobufPackage = "common";
12
+ function createBaseMessage() {
13
+ return { kind: undefined };
14
+ }
15
+ exports.Message = {
16
+ encode(message, writer = new wire_1.BinaryWriter()) {
17
+ switch (message.kind?.$case) {
18
+ case "transfer":
19
+ exports.Message_Transfer.encode(message.kind.value, writer.uint32(10).fork()).join();
20
+ break;
21
+ }
22
+ return writer;
23
+ },
24
+ decode(input, length) {
25
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
26
+ let end = length === undefined ? reader.len : reader.pos + length;
27
+ const message = createBaseMessage();
28
+ while (reader.pos < end) {
29
+ const tag = reader.uint32();
30
+ switch (tag >>> 3) {
31
+ case 1:
32
+ if (tag !== 10) {
33
+ break;
34
+ }
35
+ message.kind = { $case: "transfer", value: exports.Message_Transfer.decode(reader, reader.uint32()) };
36
+ continue;
37
+ }
38
+ if ((tag & 7) === 4 || tag === 0) {
39
+ break;
40
+ }
41
+ reader.skip(tag & 7);
42
+ }
43
+ return message;
44
+ },
45
+ fromJSON(object) {
46
+ return {
47
+ kind: isSet(object.transfer)
48
+ ? { $case: "transfer", value: exports.Message_Transfer.fromJSON(object.transfer) }
49
+ : undefined,
50
+ };
51
+ },
52
+ toJSON(message) {
53
+ const obj = {};
54
+ if (message.kind?.$case === "transfer") {
55
+ obj.transfer = exports.Message_Transfer.toJSON(message.kind.value);
56
+ }
57
+ return obj;
58
+ },
59
+ create(base) {
60
+ return exports.Message.fromPartial(base ?? {});
61
+ },
62
+ fromPartial(object) {
63
+ const message = createBaseMessage();
64
+ if (object.kind?.$case === "transfer" && object.kind?.value !== undefined && object.kind?.value !== null) {
65
+ message.kind = { $case: "transfer", value: exports.Message_Transfer.fromPartial(object.kind.value) };
66
+ }
67
+ return message;
68
+ },
69
+ };
70
+ function createBaseMessage_Transfer() {
71
+ return { tokenId: 0, userPubkey: new Uint8Array(0), amount: 0n, channelId: [] };
72
+ }
73
+ exports.Message_Transfer = {
74
+ encode(message, writer = new wire_1.BinaryWriter()) {
75
+ if (message.tokenId !== 0) {
76
+ writer.uint32(8).uint32(message.tokenId);
77
+ }
78
+ if (message.userPubkey.length !== 0) {
79
+ writer.uint32(18).bytes(message.userPubkey);
80
+ }
81
+ if (message.amount !== 0n) {
82
+ if (BigInt.asUintN(64, message.amount) !== message.amount) {
83
+ throw new globalThis.Error("value provided for field message.amount of type uint64 too large");
84
+ }
85
+ writer.uint32(24).uint64(message.amount);
86
+ }
87
+ writer.uint32(58).fork();
88
+ for (const v of message.channelId) {
89
+ writer.uint32(v);
90
+ }
91
+ writer.join();
92
+ return writer;
93
+ },
94
+ decode(input, length) {
95
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
96
+ let end = length === undefined ? reader.len : reader.pos + length;
97
+ const message = createBaseMessage_Transfer();
98
+ while (reader.pos < end) {
99
+ const tag = reader.uint32();
100
+ switch (tag >>> 3) {
101
+ case 1:
102
+ if (tag !== 8) {
103
+ break;
104
+ }
105
+ message.tokenId = reader.uint32();
106
+ continue;
107
+ case 2:
108
+ if (tag !== 18) {
109
+ break;
110
+ }
111
+ message.userPubkey = reader.bytes();
112
+ continue;
113
+ case 3:
114
+ if (tag !== 24) {
115
+ break;
116
+ }
117
+ message.amount = reader.uint64();
118
+ continue;
119
+ case 7:
120
+ if (tag === 56) {
121
+ message.channelId.push(reader.uint32());
122
+ continue;
123
+ }
124
+ if (tag === 58) {
125
+ const end2 = reader.uint32() + reader.pos;
126
+ while (reader.pos < end2) {
127
+ message.channelId.push(reader.uint32());
128
+ }
129
+ continue;
130
+ }
131
+ break;
132
+ }
133
+ if ((tag & 7) === 4 || tag === 0) {
134
+ break;
135
+ }
136
+ reader.skip(tag & 7);
137
+ }
138
+ return message;
139
+ },
140
+ fromJSON(object) {
141
+ return {
142
+ tokenId: isSet(object.tokenId) ? globalThis.Number(object.tokenId) : 0,
143
+ userPubkey: isSet(object.userPubkey) ? bytesFromBase64(object.userPubkey) : new Uint8Array(0),
144
+ amount: isSet(object.amount) ? BigInt(object.amount) : 0n,
145
+ channelId: globalThis.Array.isArray(object?.channelId)
146
+ ? object.channelId.map((e) => globalThis.Number(e))
147
+ : [],
148
+ };
149
+ },
150
+ toJSON(message) {
151
+ const obj = {};
152
+ if (message.tokenId !== 0) {
153
+ obj.tokenId = Math.round(message.tokenId);
154
+ }
155
+ if (message.userPubkey.length !== 0) {
156
+ obj.userPubkey = base64FromBytes(message.userPubkey);
157
+ }
158
+ if (message.amount !== 0n) {
159
+ obj.amount = message.amount.toString();
160
+ }
161
+ if (message.channelId?.length) {
162
+ obj.channelId = message.channelId.map((e) => Math.round(e));
163
+ }
164
+ return obj;
165
+ },
166
+ create(base) {
167
+ return exports.Message_Transfer.fromPartial(base ?? {});
168
+ },
169
+ fromPartial(object) {
170
+ const message = createBaseMessage_Transfer();
171
+ message.tokenId = object.tokenId ?? 0;
172
+ message.userPubkey = object.userPubkey ?? new Uint8Array(0);
173
+ message.amount = object.amount ?? 0n;
174
+ message.channelId = object.channelId?.map((e) => e) || [];
175
+ return message;
176
+ },
177
+ };
178
+ function bytesFromBase64(b64) {
179
+ if (globalThis.Buffer) {
180
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
181
+ }
182
+ else {
183
+ const bin = globalThis.atob(b64);
184
+ const arr = new Uint8Array(bin.length);
185
+ for (let i = 0; i < bin.length; ++i) {
186
+ arr[i] = bin.charCodeAt(i);
187
+ }
188
+ return arr;
189
+ }
190
+ }
191
+ function base64FromBytes(arr) {
192
+ if (globalThis.Buffer) {
193
+ return globalThis.Buffer.from(arr).toString("base64");
194
+ }
195
+ else {
196
+ const bin = [];
197
+ arr.forEach((byte) => {
198
+ bin.push(globalThis.String.fromCharCode(byte));
199
+ });
200
+ return globalThis.btoa(bin.join(""));
201
+ }
202
+ }
203
+ function isSet(value) {
204
+ return value !== null && value !== undefined;
205
+ }