@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.
- package/.eslintignore +1 -0
- package/.eslintrc.js +20 -0
- package/.prettierignore +1 -0
- package/README.md +110 -0
- package/dist/abis/ERC20_ABI.d.ts +39 -0
- package/dist/abis/ERC20_ABI.js +313 -0
- package/dist/abis/NORD_GETTERS_FACET_ABI.d.ts +34 -0
- package/dist/abis/NORD_GETTERS_FACET_ABI.js +195 -0
- package/dist/abis/NORD_RAMP_FACET_ABI.d.ts +35 -0
- package/dist/abis/NORD_RAMP_FACET_ABI.js +144 -0
- package/dist/abis/index.d.ts +3 -0
- package/dist/abis/index.js +9 -0
- package/dist/const.d.ts +11 -0
- package/dist/const.js +34 -0
- package/dist/gen/common.d.ts +63 -0
- package/dist/gen/common.js +205 -0
- package/dist/gen/nord.d.ts +705 -0
- package/dist/gen/nord.js +4784 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -0
- package/dist/nord/Nord.d.ts +76 -0
- package/dist/nord/Nord.js +376 -0
- package/dist/nord/NordImpl.d.ts +7 -0
- package/dist/nord/NordImpl.js +6 -0
- package/dist/nord/NordUser.d.ts +77 -0
- package/dist/nord/NordUser.js +249 -0
- package/dist/nord/actions.d.ts +101 -0
- package/dist/nord/actions.js +254 -0
- package/dist/nord/index.d.ts +2 -0
- package/dist/nord/index.js +9 -0
- package/dist/types.d.ts +343 -0
- package/dist/types.js +92 -0
- package/dist/utils.d.ts +114 -0
- package/dist/utils.js +257 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +92 -0
- package/docs/assets/icons.js +15 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1415 -0
- package/docs/classes/Nord.html +44 -0
- package/docs/classes/NordUser.html +35 -0
- package/docs/classes/Subscriber.html +6 -0
- package/docs/enums/FillMode.html +5 -0
- package/docs/enums/KeyType.html +4 -0
- package/docs/enums/PeakTpsPeriodUnit.html +15 -0
- package/docs/enums/Side.html +3 -0
- package/docs/functions/assert.html +1 -0
- package/docs/functions/bigIntToProtoU128.html +4 -0
- package/docs/functions/checkPubKeyLength.html +1 -0
- package/docs/functions/checkedFetch.html +6 -0
- package/docs/functions/createWebSocketSubscription.html +12 -0
- package/docs/functions/decodeLengthDelimited.html +10 -0
- package/docs/functions/encodeLengthDelimited.html +6 -0
- package/docs/functions/fillModeToProtoFillMode.html +5 -0
- package/docs/functions/findMarket.html +1 -0
- package/docs/functions/findToken.html +1 -0
- package/docs/functions/makeWalletSignFn.html +6 -0
- package/docs/functions/optExpect.html +5 -0
- package/docs/functions/optMap.html +5 -0
- package/docs/functions/optUnwrap.html +2 -0
- package/docs/functions/panic.html +1 -0
- package/docs/functions/signAction.html +6 -0
- package/docs/functions/toScaledU128.html +8 -0
- package/docs/functions/toScaledU64.html +8 -0
- package/docs/index.html +21 -0
- package/docs/interfaces/Account.html +8 -0
- package/docs/interfaces/ActionInfo.html +8 -0
- package/docs/interfaces/ActionQuery.html +4 -0
- package/docs/interfaces/ActionResponse.html +8 -0
- package/docs/interfaces/ActionsExtendedInfo.html +10 -0
- package/docs/interfaces/ActionsQuery.html +5 -0
- package/docs/interfaces/ActionsResponse.html +6 -0
- package/docs/interfaces/AggregateMetrics.html +12 -0
- package/docs/interfaces/BlockQuery.html +6 -0
- package/docs/interfaces/BlockResponse.html +6 -0
- package/docs/interfaces/BlockSummary.html +8 -0
- package/docs/interfaces/BlockSummaryResponse.html +6 -0
- package/docs/interfaces/DeltaEvent.html +6 -0
- package/docs/interfaces/ERC20TokenInfo.html +5 -0
- package/docs/interfaces/Info.html +3 -0
- package/docs/interfaces/Market.html +6 -0
- package/docs/interfaces/MarketStats.html +7 -0
- package/docs/interfaces/MarketsStatsResponse.html +2 -0
- package/docs/interfaces/NordConfig.html +5 -0
- package/docs/interfaces/Order.html +6 -0
- package/docs/interfaces/OrderInfo.html +6 -0
- package/docs/interfaces/OrderbookOrder.html +6 -0
- package/docs/interfaces/OrderbookResponse.html +10 -0
- package/docs/interfaces/PerpMarketStats.html +5 -0
- package/docs/interfaces/RollmanActionExtendedInfo.html +4 -0
- package/docs/interfaces/RollmanActionInfo.html +4 -0
- package/docs/interfaces/RollmanActionResponse.html +4 -0
- package/docs/interfaces/RollmanActionsResponse.html +2 -0
- package/docs/interfaces/RollmanBlockResponse.html +3 -0
- package/docs/interfaces/SubscriberConfig.html +3 -0
- package/docs/interfaces/Token.html +5 -0
- package/docs/interfaces/Trade.html +5 -0
- package/docs/interfaces/TradeInfo.html +20 -0
- package/docs/interfaces/Trades.html +5 -0
- package/docs/interfaces/TradesQueryParams.html +10 -0
- package/docs/interfaces/TradesResponse.html +12 -0
- package/docs/modules.html +77 -0
- package/docs/types/BigIntValue.html +2 -0
- package/docs/variables/DEBUG_KEYS.html +1 -0
- package/docs/variables/DEFAULT_FUNDING_AMOUNTS.html +1 -0
- package/docs/variables/DEV_CONTRACT_ADDRESS.html +1 -0
- package/docs/variables/DEV_TOKEN_INFOS.html +1 -0
- package/docs/variables/DEV_URL.html +1 -0
- package/docs/variables/ERC20_ABI.html +1 -0
- package/docs/variables/EVM_DEV_URL.html +1 -0
- package/docs/variables/FAUCET_PRIVATE_ADDRESS.html +1 -0
- package/docs/variables/MAX_BUFFER_LEN.html +1 -0
- package/docs/variables/NORD_GETTERS_FACET_ABI.html +1 -0
- package/docs/variables/NORD_RAMP_FACET_ABI.html +1 -0
- package/docs/variables/SESSION_TTL.html +1 -0
- package/docs/variables/WEBSERVER_DEV_URL.html +1 -0
- package/docs/variables/ZERO_DECIMAL.html +1 -0
- package/jest.config.ts +9 -0
- package/nodemon.json +4 -0
- package/package.json +61 -0
- package/protoc-generate.sh +23 -0
- package/src/abis/ERC20_ABI.ts +310 -0
- package/src/abis/NORD_GETTERS_FACET_ABI.ts +192 -0
- package/src/abis/NORD_RAMP_FACET_ABI.ts +141 -0
- package/src/abis/index.ts +3 -0
- package/src/const.ts +39 -0
- package/src/gen/common.ts +280 -0
- package/src/gen/nord.ts +5666 -0
- package/src/index.ts +5 -0
- package/src/nord/Nord.ts +504 -0
- package/src/nord/NordImpl.ts +8 -0
- package/src/nord/NordUser.ts +469 -0
- package/src/nord/actions.ts +484 -0
- package/src/nord/index.ts +2 -0
- package/src/types.ts +393 -0
- package/src/utils.ts +300 -0
- package/tests/utils.spec.ts +154 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.2.0
|
|
4
|
+
// protoc v5.28.3
|
|
5
|
+
// source: common.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
9
|
+
|
|
10
|
+
export const protobufPackage = "common";
|
|
11
|
+
|
|
12
|
+
export interface Message {
|
|
13
|
+
kind?: { $case: "transfer"; value: Message_Transfer } | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Message sent by user to app to move funds out of app, `withdraw`.
|
|
18
|
+
* Receiver side considers it `route` or `deposit`.
|
|
19
|
+
*/
|
|
20
|
+
export interface Message_Transfer {
|
|
21
|
+
/** Token id as registered on L1 chain settlement */
|
|
22
|
+
tokenId: number;
|
|
23
|
+
/**
|
|
24
|
+
* User public key from L1 which he used for deposits
|
|
25
|
+
* This address will be used to deposit onto L1 or L2 target,
|
|
26
|
+
* Target is "here", as soon as ther are no `channel_id`s remaining.
|
|
27
|
+
*/
|
|
28
|
+
userPubkey: Uint8Array;
|
|
29
|
+
amount: bigint;
|
|
30
|
+
/**
|
|
31
|
+
* Numeric identifiers of channels to traverse.
|
|
32
|
+
*
|
|
33
|
+
* Message removed first channel_id in list,
|
|
34
|
+
* and sent remaining message to "removed" channel.
|
|
35
|
+
*
|
|
36
|
+
* If received by app via channel and no channels defined,
|
|
37
|
+
* deposit target this app ("here").
|
|
38
|
+
*
|
|
39
|
+
* If it is direct user input and no channels defined, default route is used: q
|
|
40
|
+
* to Gate on Nord, to L1 on Gate, and to Gate on L1.
|
|
41
|
+
*/
|
|
42
|
+
channelId: number[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function createBaseMessage(): Message {
|
|
46
|
+
return { kind: undefined };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const Message: MessageFns<Message> = {
|
|
50
|
+
encode(message: Message, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
51
|
+
switch (message.kind?.$case) {
|
|
52
|
+
case "transfer":
|
|
53
|
+
Message_Transfer.encode(message.kind.value, writer.uint32(10).fork()).join();
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
return writer;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
decode(input: BinaryReader | Uint8Array, length?: number): Message {
|
|
60
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
61
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
62
|
+
const message = createBaseMessage();
|
|
63
|
+
while (reader.pos < end) {
|
|
64
|
+
const tag = reader.uint32();
|
|
65
|
+
switch (tag >>> 3) {
|
|
66
|
+
case 1:
|
|
67
|
+
if (tag !== 10) {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
message.kind = { $case: "transfer", value: Message_Transfer.decode(reader, reader.uint32()) };
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
reader.skip(tag & 7);
|
|
78
|
+
}
|
|
79
|
+
return message;
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
fromJSON(object: any): Message {
|
|
83
|
+
return {
|
|
84
|
+
kind: isSet(object.transfer)
|
|
85
|
+
? { $case: "transfer", value: Message_Transfer.fromJSON(object.transfer) }
|
|
86
|
+
: undefined,
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
toJSON(message: Message): unknown {
|
|
91
|
+
const obj: any = {};
|
|
92
|
+
if (message.kind?.$case === "transfer") {
|
|
93
|
+
obj.transfer = Message_Transfer.toJSON(message.kind.value);
|
|
94
|
+
}
|
|
95
|
+
return obj;
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
create<I extends Exact<DeepPartial<Message>, I>>(base?: I): Message {
|
|
99
|
+
return Message.fromPartial(base ?? ({} as any));
|
|
100
|
+
},
|
|
101
|
+
fromPartial<I extends Exact<DeepPartial<Message>, I>>(object: I): Message {
|
|
102
|
+
const message = createBaseMessage();
|
|
103
|
+
if (object.kind?.$case === "transfer" && object.kind?.value !== undefined && object.kind?.value !== null) {
|
|
104
|
+
message.kind = { $case: "transfer", value: Message_Transfer.fromPartial(object.kind.value) };
|
|
105
|
+
}
|
|
106
|
+
return message;
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
function createBaseMessage_Transfer(): Message_Transfer {
|
|
111
|
+
return { tokenId: 0, userPubkey: new Uint8Array(0), amount: 0n, channelId: [] };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const Message_Transfer: MessageFns<Message_Transfer> = {
|
|
115
|
+
encode(message: Message_Transfer, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
116
|
+
if (message.tokenId !== 0) {
|
|
117
|
+
writer.uint32(8).uint32(message.tokenId);
|
|
118
|
+
}
|
|
119
|
+
if (message.userPubkey.length !== 0) {
|
|
120
|
+
writer.uint32(18).bytes(message.userPubkey);
|
|
121
|
+
}
|
|
122
|
+
if (message.amount !== 0n) {
|
|
123
|
+
if (BigInt.asUintN(64, message.amount) !== message.amount) {
|
|
124
|
+
throw new globalThis.Error("value provided for field message.amount of type uint64 too large");
|
|
125
|
+
}
|
|
126
|
+
writer.uint32(24).uint64(message.amount);
|
|
127
|
+
}
|
|
128
|
+
writer.uint32(58).fork();
|
|
129
|
+
for (const v of message.channelId) {
|
|
130
|
+
writer.uint32(v);
|
|
131
|
+
}
|
|
132
|
+
writer.join();
|
|
133
|
+
return writer;
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
decode(input: BinaryReader | Uint8Array, length?: number): Message_Transfer {
|
|
137
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
138
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
139
|
+
const message = createBaseMessage_Transfer();
|
|
140
|
+
while (reader.pos < end) {
|
|
141
|
+
const tag = reader.uint32();
|
|
142
|
+
switch (tag >>> 3) {
|
|
143
|
+
case 1:
|
|
144
|
+
if (tag !== 8) {
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
message.tokenId = reader.uint32();
|
|
149
|
+
continue;
|
|
150
|
+
case 2:
|
|
151
|
+
if (tag !== 18) {
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
message.userPubkey = reader.bytes();
|
|
156
|
+
continue;
|
|
157
|
+
case 3:
|
|
158
|
+
if (tag !== 24) {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
message.amount = reader.uint64() as bigint;
|
|
163
|
+
continue;
|
|
164
|
+
case 7:
|
|
165
|
+
if (tag === 56) {
|
|
166
|
+
message.channelId.push(reader.uint32());
|
|
167
|
+
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (tag === 58) {
|
|
172
|
+
const end2 = reader.uint32() + reader.pos;
|
|
173
|
+
while (reader.pos < end2) {
|
|
174
|
+
message.channelId.push(reader.uint32());
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
reader.skip(tag & 7);
|
|
186
|
+
}
|
|
187
|
+
return message;
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
fromJSON(object: any): Message_Transfer {
|
|
191
|
+
return {
|
|
192
|
+
tokenId: isSet(object.tokenId) ? globalThis.Number(object.tokenId) : 0,
|
|
193
|
+
userPubkey: isSet(object.userPubkey) ? bytesFromBase64(object.userPubkey) : new Uint8Array(0),
|
|
194
|
+
amount: isSet(object.amount) ? BigInt(object.amount) : 0n,
|
|
195
|
+
channelId: globalThis.Array.isArray(object?.channelId)
|
|
196
|
+
? object.channelId.map((e: any) => globalThis.Number(e))
|
|
197
|
+
: [],
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
toJSON(message: Message_Transfer): unknown {
|
|
202
|
+
const obj: any = {};
|
|
203
|
+
if (message.tokenId !== 0) {
|
|
204
|
+
obj.tokenId = Math.round(message.tokenId);
|
|
205
|
+
}
|
|
206
|
+
if (message.userPubkey.length !== 0) {
|
|
207
|
+
obj.userPubkey = base64FromBytes(message.userPubkey);
|
|
208
|
+
}
|
|
209
|
+
if (message.amount !== 0n) {
|
|
210
|
+
obj.amount = message.amount.toString();
|
|
211
|
+
}
|
|
212
|
+
if (message.channelId?.length) {
|
|
213
|
+
obj.channelId = message.channelId.map((e) => Math.round(e));
|
|
214
|
+
}
|
|
215
|
+
return obj;
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
create<I extends Exact<DeepPartial<Message_Transfer>, I>>(base?: I): Message_Transfer {
|
|
219
|
+
return Message_Transfer.fromPartial(base ?? ({} as any));
|
|
220
|
+
},
|
|
221
|
+
fromPartial<I extends Exact<DeepPartial<Message_Transfer>, I>>(object: I): Message_Transfer {
|
|
222
|
+
const message = createBaseMessage_Transfer();
|
|
223
|
+
message.tokenId = object.tokenId ?? 0;
|
|
224
|
+
message.userPubkey = object.userPubkey ?? new Uint8Array(0);
|
|
225
|
+
message.amount = object.amount ?? 0n;
|
|
226
|
+
message.channelId = object.channelId?.map((e) => e) || [];
|
|
227
|
+
return message;
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
function bytesFromBase64(b64: string): Uint8Array {
|
|
232
|
+
if ((globalThis as any).Buffer) {
|
|
233
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
234
|
+
} else {
|
|
235
|
+
const bin = globalThis.atob(b64);
|
|
236
|
+
const arr = new Uint8Array(bin.length);
|
|
237
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
238
|
+
arr[i] = bin.charCodeAt(i);
|
|
239
|
+
}
|
|
240
|
+
return arr;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function base64FromBytes(arr: Uint8Array): string {
|
|
245
|
+
if ((globalThis as any).Buffer) {
|
|
246
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
247
|
+
} else {
|
|
248
|
+
const bin: string[] = [];
|
|
249
|
+
arr.forEach((byte) => {
|
|
250
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
251
|
+
});
|
|
252
|
+
return globalThis.btoa(bin.join(""));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
|
|
257
|
+
|
|
258
|
+
export type DeepPartial<T> = T extends Builtin ? T
|
|
259
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
260
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
261
|
+
: T extends { $case: string; value: unknown } ? { $case: T["$case"]; value?: DeepPartial<T["value"]> }
|
|
262
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
263
|
+
: Partial<T>;
|
|
264
|
+
|
|
265
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
266
|
+
export type Exact<P, I extends P> = P extends Builtin ? P
|
|
267
|
+
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
|
268
|
+
|
|
269
|
+
function isSet(value: any): boolean {
|
|
270
|
+
return value !== null && value !== undefined;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface MessageFns<T> {
|
|
274
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
275
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
276
|
+
fromJSON(object: any): T;
|
|
277
|
+
toJSON(message: T): unknown;
|
|
278
|
+
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
279
|
+
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
280
|
+
}
|