@qubic.ts/contracts 0.1.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.
Files changed (83) hide show
  1. package/package.json +17 -0
  2. package/scripts/generate-artifacts.ts +178 -0
  3. package/src/codec/entry-input.test.ts +198 -0
  4. package/src/codec/entry-input.ts +959 -0
  5. package/src/codec/index.ts +8 -0
  6. package/src/generated/contracts/CCF.registry.json +741 -0
  7. package/src/generated/contracts/CCF.types.ts +307 -0
  8. package/src/generated/contracts/GQMPROP.registry.json +518 -0
  9. package/src/generated/contracts/GQMPROP.types.ts +238 -0
  10. package/src/generated/contracts/MLM.registry.json +8 -0
  11. package/src/generated/contracts/MLM.types.ts +42 -0
  12. package/src/generated/contracts/MSVAULT.registry.json +1162 -0
  13. package/src/generated/contracts/MSVAULT.types.ts +598 -0
  14. package/src/generated/contracts/NOST.registry.json +1131 -0
  15. package/src/generated/contracts/NOST.types.ts +515 -0
  16. package/src/generated/contracts/QBAY.registry.json +1492 -0
  17. package/src/generated/contracts/QBAY.types.ts +681 -0
  18. package/src/generated/contracts/QBOND.registry.json +734 -0
  19. package/src/generated/contracts/QBOND.types.ts +397 -0
  20. package/src/generated/contracts/QDRAW.registry.json +112 -0
  21. package/src/generated/contracts/QDRAW.types.ts +110 -0
  22. package/src/generated/contracts/QDUEL.registry.json +466 -0
  23. package/src/generated/contracts/QDUEL.types.ts +265 -0
  24. package/src/generated/contracts/QEARN.registry.json +458 -0
  25. package/src/generated/contracts/QEARN.types.ts +265 -0
  26. package/src/generated/contracts/QIP.registry.json +483 -0
  27. package/src/generated/contracts/QIP.types.ts +194 -0
  28. package/src/generated/contracts/QRAFFLE.registry.json +916 -0
  29. package/src/generated/contracts/QRAFFLE.types.ts +446 -0
  30. package/src/generated/contracts/QRP.registry.json +139 -0
  31. package/src/generated/contracts/QRP.types.ts +144 -0
  32. package/src/generated/contracts/QRWA.registry.json +765 -0
  33. package/src/generated/contracts/QRWA.types.ts +402 -0
  34. package/src/generated/contracts/QSWAP.registry.json +941 -0
  35. package/src/generated/contracts/QSWAP.types.ts +479 -0
  36. package/src/generated/contracts/QTF.registry.json +480 -0
  37. package/src/generated/contracts/QTF.types.ts +346 -0
  38. package/src/generated/contracts/QUOTTERY.registry.json +530 -0
  39. package/src/generated/contracts/QUOTTERY.types.ts +262 -0
  40. package/src/generated/contracts/QUTIL.registry.json +1378 -0
  41. package/src/generated/contracts/QUTIL.types.ts +612 -0
  42. package/src/generated/contracts/QVAULT.registry.json +527 -0
  43. package/src/generated/contracts/QVAULT.types.ts +309 -0
  44. package/src/generated/contracts/QX.registry.json +610 -0
  45. package/src/generated/contracts/QX.types.ts +323 -0
  46. package/src/generated/contracts/RANDOM.registry.json +51 -0
  47. package/src/generated/contracts/RANDOM.types.ts +65 -0
  48. package/src/generated/contracts/RL.registry.json +490 -0
  49. package/src/generated/contracts/RL.types.ts +304 -0
  50. package/src/generated/contracts/SWATCH.registry.json +8 -0
  51. package/src/generated/contracts/SWATCH.types.ts +42 -0
  52. package/src/generated/core-registry.codecs.ts +6622 -0
  53. package/src/generated/core-registry.source.json +14342 -0
  54. package/src/generated/core-registry.ts +14349 -0
  55. package/src/generated/core-registry.types.ts +100 -0
  56. package/src/generator/contract-codecs.fixture.test.ts +17 -0
  57. package/src/generator/contract-codecs.test.ts +115 -0
  58. package/src/generator/contract-codecs.ts +416 -0
  59. package/src/generator/index.ts +14 -0
  60. package/src/generator/per-contract-files.test.ts +70 -0
  61. package/src/generator/per-contract-files.ts +122 -0
  62. package/src/generator/registry-runtime.fixture.test.ts +17 -0
  63. package/src/generator/registry-runtime.test.ts +55 -0
  64. package/src/generator/registry-runtime.ts +28 -0
  65. package/src/generator/registry-types.fixture.test.ts +17 -0
  66. package/src/generator/registry-types.test.ts +55 -0
  67. package/src/generator/registry-types.ts +75 -0
  68. package/src/index.test.ts +29 -0
  69. package/src/index.ts +49 -0
  70. package/src/registry/index.ts +17 -0
  71. package/src/registry/io-layout.fixture.test.ts +24 -0
  72. package/src/registry/io-layout.test.ts +93 -0
  73. package/src/registry/io-layout.ts +57 -0
  74. package/src/registry/normalize.ts +61 -0
  75. package/src/registry/schema.fixture.test.ts +21 -0
  76. package/src/registry/schema.ts +97 -0
  77. package/src/registry/types.ts +98 -0
  78. package/test/fixtures/io-layout.contracts.json +32 -0
  79. package/test/fixtures/io-layout.layouts.json +14 -0
  80. package/test/fixtures/registry.sample.codecs.ts +100 -0
  81. package/test/fixtures/registry.sample.json +27 -0
  82. package/test/fixtures/registry.sample.runtime.ts +54 -0
  83. package/test/fixtures/registry.sample.types.ts +16 -0
@@ -0,0 +1,323 @@
1
+ /* eslint-disable */
2
+ /* This file is generated. Do not edit manually. */
3
+
4
+ export type QX_AddToAskOrder_input = {
5
+ readonly issuer: string;
6
+ readonly assetName: bigint;
7
+ readonly price: bigint;
8
+ readonly numberOfShares: bigint;
9
+ };
10
+ export type QX_AddToAskOrder_output = {
11
+ readonly addedNumberOfShares: bigint;
12
+ };
13
+ export type QX_AddToBidOrder_input = {
14
+ readonly issuer: string;
15
+ readonly assetName: bigint;
16
+ readonly price: bigint;
17
+ readonly numberOfShares: bigint;
18
+ };
19
+ export type QX_AddToBidOrder_output = {
20
+ readonly addedNumberOfShares: bigint;
21
+ };
22
+ export type QX_Asset = {
23
+ readonly issuer: string;
24
+ readonly assetName: bigint;
25
+ };
26
+ export type QX_AssetAskOrders_input = {
27
+ readonly issuer: string;
28
+ readonly assetName: bigint;
29
+ readonly offset: bigint;
30
+ };
31
+ export type QX_AssetAskOrders_output = {
32
+ readonly orders: ReadonlyArray<QX_Order>;
33
+ };
34
+ export type QX_AssetBidOrders_input = {
35
+ readonly issuer: string;
36
+ readonly assetName: bigint;
37
+ readonly offset: bigint;
38
+ };
39
+ export type QX_AssetBidOrders_output = {
40
+ readonly orders: ReadonlyArray<QX_Order>;
41
+ };
42
+ export type QX_EntityAskOrders_input = {
43
+ readonly entity: string;
44
+ readonly offset: bigint;
45
+ };
46
+ export type QX_EntityAskOrders_output = {
47
+ readonly orders: ReadonlyArray<QX_Order>;
48
+ };
49
+ export type QX_EntityBidOrders_input = {
50
+ readonly entity: string;
51
+ readonly offset: bigint;
52
+ };
53
+ export type QX_EntityBidOrders_output = {
54
+ readonly orders: ReadonlyArray<QX_Order>;
55
+ };
56
+ export type QX_Fees_input = Record<string, never>;
57
+ export type QX_Fees_output = {
58
+ readonly assetIssuanceFee: number;
59
+ readonly transferFee: number;
60
+ readonly tradeFee: number;
61
+ };
62
+ export type QX_IssueAsset_input = {
63
+ readonly assetName: bigint;
64
+ readonly numberOfShares: bigint;
65
+ readonly unitOfMeasurement: bigint;
66
+ readonly numberOfDecimalPlaces: number;
67
+ };
68
+ export type QX_IssueAsset_output = {
69
+ readonly issuedNumberOfShares: bigint;
70
+ };
71
+ export type QX_Order = {
72
+ readonly issuer: string;
73
+ readonly assetName: bigint;
74
+ readonly price: bigint;
75
+ readonly numberOfShares: bigint;
76
+ };
77
+ export type QX_RemoveFromAskOrder_input = {
78
+ readonly issuer: string;
79
+ readonly assetName: bigint;
80
+ readonly price: bigint;
81
+ readonly numberOfShares: bigint;
82
+ };
83
+ export type QX_RemoveFromAskOrder_output = {
84
+ readonly removedNumberOfShares: bigint;
85
+ };
86
+ export type QX_RemoveFromBidOrder_input = {
87
+ readonly issuer: string;
88
+ readonly assetName: bigint;
89
+ readonly price: bigint;
90
+ readonly numberOfShares: bigint;
91
+ };
92
+ export type QX_RemoveFromBidOrder_output = {
93
+ readonly removedNumberOfShares: bigint;
94
+ };
95
+ export type QX_TransferShareManagementRights_input = {
96
+ readonly asset: QX_Asset;
97
+ readonly numberOfShares: bigint;
98
+ readonly newManagingContractIndex: number;
99
+ };
100
+ export type QX_TransferShareManagementRights_output = {
101
+ readonly transferredNumberOfShares: bigint;
102
+ };
103
+ export type QX_TransferShareOwnershipAndPossession_input = {
104
+ readonly issuer: string;
105
+ readonly newOwnerAndPossessor: string;
106
+ readonly assetName: bigint;
107
+ readonly numberOfShares: bigint;
108
+ };
109
+ export type QX_TransferShareOwnershipAndPossession_output = {
110
+ readonly transferredNumberOfShares: bigint;
111
+ };
112
+
113
+ export interface ContractTypeMap {
114
+ QX: {
115
+ readonly contractIndex: 1;
116
+ readonly functions: {
117
+ Fees: {
118
+ readonly kind: "function";
119
+ readonly inputType: 1;
120
+ readonly inputTypeName: "Fees_input";
121
+ readonly outputTypeName: "Fees_output";
122
+ readonly input: QX_Fees_input;
123
+ readonly output: QX_Fees_output;
124
+ };
125
+ AssetAskOrders: {
126
+ readonly kind: "function";
127
+ readonly inputType: 2;
128
+ readonly inputTypeName: "AssetAskOrders_input";
129
+ readonly outputTypeName: "AssetAskOrders_output";
130
+ readonly input: QX_AssetAskOrders_input;
131
+ readonly output: QX_AssetAskOrders_output;
132
+ };
133
+ AssetBidOrders: {
134
+ readonly kind: "function";
135
+ readonly inputType: 3;
136
+ readonly inputTypeName: "AssetBidOrders_input";
137
+ readonly outputTypeName: "AssetBidOrders_output";
138
+ readonly input: QX_AssetBidOrders_input;
139
+ readonly output: QX_AssetBidOrders_output;
140
+ };
141
+ EntityAskOrders: {
142
+ readonly kind: "function";
143
+ readonly inputType: 4;
144
+ readonly inputTypeName: "EntityAskOrders_input";
145
+ readonly outputTypeName: "EntityAskOrders_output";
146
+ readonly input: QX_EntityAskOrders_input;
147
+ readonly output: QX_EntityAskOrders_output;
148
+ };
149
+ EntityBidOrders: {
150
+ readonly kind: "function";
151
+ readonly inputType: 5;
152
+ readonly inputTypeName: "EntityBidOrders_input";
153
+ readonly outputTypeName: "EntityBidOrders_output";
154
+ readonly input: QX_EntityBidOrders_input;
155
+ readonly output: QX_EntityBidOrders_output;
156
+ };
157
+ };
158
+ readonly procedures: {
159
+ IssueAsset: {
160
+ readonly kind: "procedure";
161
+ readonly inputType: 1;
162
+ readonly inputTypeName: "IssueAsset_input";
163
+ readonly outputTypeName: "IssueAsset_output";
164
+ readonly input: QX_IssueAsset_input;
165
+ readonly output: QX_IssueAsset_output;
166
+ };
167
+ TransferShareOwnershipAndPossession: {
168
+ readonly kind: "procedure";
169
+ readonly inputType: 2;
170
+ readonly inputTypeName: "TransferShareOwnershipAndPossession_input";
171
+ readonly outputTypeName: "TransferShareOwnershipAndPossession_output";
172
+ readonly input: QX_TransferShareOwnershipAndPossession_input;
173
+ readonly output: QX_TransferShareOwnershipAndPossession_output;
174
+ };
175
+ AddToAskOrder: {
176
+ readonly kind: "procedure";
177
+ readonly inputType: 5;
178
+ readonly inputTypeName: "AddToAskOrder_input";
179
+ readonly outputTypeName: "AddToAskOrder_output";
180
+ readonly input: QX_AddToAskOrder_input;
181
+ readonly output: QX_AddToAskOrder_output;
182
+ };
183
+ AddToBidOrder: {
184
+ readonly kind: "procedure";
185
+ readonly inputType: 6;
186
+ readonly inputTypeName: "AddToBidOrder_input";
187
+ readonly outputTypeName: "AddToBidOrder_output";
188
+ readonly input: QX_AddToBidOrder_input;
189
+ readonly output: QX_AddToBidOrder_output;
190
+ };
191
+ RemoveFromAskOrder: {
192
+ readonly kind: "procedure";
193
+ readonly inputType: 7;
194
+ readonly inputTypeName: "RemoveFromAskOrder_input";
195
+ readonly outputTypeName: "RemoveFromAskOrder_output";
196
+ readonly input: QX_RemoveFromAskOrder_input;
197
+ readonly output: QX_RemoveFromAskOrder_output;
198
+ };
199
+ RemoveFromBidOrder: {
200
+ readonly kind: "procedure";
201
+ readonly inputType: 8;
202
+ readonly inputTypeName: "RemoveFromBidOrder_input";
203
+ readonly outputTypeName: "RemoveFromBidOrder_output";
204
+ readonly input: QX_RemoveFromBidOrder_input;
205
+ readonly output: QX_RemoveFromBidOrder_output;
206
+ };
207
+ TransferShareManagementRights: {
208
+ readonly kind: "procedure";
209
+ readonly inputType: 9;
210
+ readonly inputTypeName: "TransferShareManagementRights_input";
211
+ readonly outputTypeName: "TransferShareManagementRights_output";
212
+ readonly input: QX_TransferShareManagementRights_input;
213
+ readonly output: QX_TransferShareManagementRights_output;
214
+ };
215
+ };
216
+ };
217
+ }
218
+
219
+ export type ContractName = keyof ContractTypeMap & string;
220
+ export type FunctionName<C extends ContractName> = keyof ContractTypeMap[C]["functions"] & string;
221
+ export type ProcedureName<C extends ContractName> = keyof ContractTypeMap[C]["procedures"] & string;
222
+
223
+ export type FunctionInput<
224
+ C extends ContractName,
225
+ F extends FunctionName<C>,
226
+ > = ContractTypeMap[C]["functions"][F]["input"];
227
+ export type FunctionOutput<
228
+ C extends ContractName,
229
+ F extends FunctionName<C>,
230
+ > = ContractTypeMap[C]["functions"][F]["output"];
231
+
232
+ export type ProcedureInput<
233
+ C extends ContractName,
234
+ P extends ProcedureName<C>,
235
+ > = ContractTypeMap[C]["procedures"][P]["input"];
236
+ export type ProcedureOutput<
237
+ C extends ContractName,
238
+ P extends ProcedureName<C>,
239
+ > = ContractTypeMap[C]["procedures"][P]["output"];
240
+
241
+ export const contractCodecRegistry = {
242
+ QX: {
243
+ contractIndex: 1,
244
+ functions: {
245
+ Fees: {
246
+ kind: "function",
247
+ inputType: 1,
248
+ inputTypeName: "Fees_input",
249
+ outputTypeName: "Fees_output",
250
+ },
251
+ AssetAskOrders: {
252
+ kind: "function",
253
+ inputType: 2,
254
+ inputTypeName: "AssetAskOrders_input",
255
+ outputTypeName: "AssetAskOrders_output",
256
+ },
257
+ AssetBidOrders: {
258
+ kind: "function",
259
+ inputType: 3,
260
+ inputTypeName: "AssetBidOrders_input",
261
+ outputTypeName: "AssetBidOrders_output",
262
+ },
263
+ EntityAskOrders: {
264
+ kind: "function",
265
+ inputType: 4,
266
+ inputTypeName: "EntityAskOrders_input",
267
+ outputTypeName: "EntityAskOrders_output",
268
+ },
269
+ EntityBidOrders: {
270
+ kind: "function",
271
+ inputType: 5,
272
+ inputTypeName: "EntityBidOrders_input",
273
+ outputTypeName: "EntityBidOrders_output",
274
+ },
275
+ },
276
+ procedures: {
277
+ IssueAsset: {
278
+ kind: "procedure",
279
+ inputType: 1,
280
+ inputTypeName: "IssueAsset_input",
281
+ outputTypeName: "IssueAsset_output",
282
+ },
283
+ TransferShareOwnershipAndPossession: {
284
+ kind: "procedure",
285
+ inputType: 2,
286
+ inputTypeName: "TransferShareOwnershipAndPossession_input",
287
+ outputTypeName: "TransferShareOwnershipAndPossession_output",
288
+ },
289
+ AddToAskOrder: {
290
+ kind: "procedure",
291
+ inputType: 5,
292
+ inputTypeName: "AddToAskOrder_input",
293
+ outputTypeName: "AddToAskOrder_output",
294
+ },
295
+ AddToBidOrder: {
296
+ kind: "procedure",
297
+ inputType: 6,
298
+ inputTypeName: "AddToBidOrder_input",
299
+ outputTypeName: "AddToBidOrder_output",
300
+ },
301
+ RemoveFromAskOrder: {
302
+ kind: "procedure",
303
+ inputType: 7,
304
+ inputTypeName: "RemoveFromAskOrder_input",
305
+ outputTypeName: "RemoveFromAskOrder_output",
306
+ },
307
+ RemoveFromBidOrder: {
308
+ kind: "procedure",
309
+ inputType: 8,
310
+ inputTypeName: "RemoveFromBidOrder_input",
311
+ outputTypeName: "RemoveFromBidOrder_output",
312
+ },
313
+ TransferShareManagementRights: {
314
+ kind: "procedure",
315
+ inputType: 9,
316
+ inputTypeName: "TransferShareManagementRights_input",
317
+ outputTypeName: "TransferShareManagementRights_output",
318
+ },
319
+ },
320
+ },
321
+ } as const satisfies Readonly<Record<ContractName, unknown>>;
322
+
323
+ export type RuntimeContractCodecRegistry = typeof contractCodecRegistry;
@@ -0,0 +1,51 @@
1
+ {
2
+ "contractName": "RANDOM",
3
+ "contractIndex": 3,
4
+ "filename": "Random.h",
5
+ "address": "DAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANMIG",
6
+ "entries": [
7
+ {
8
+ "kind": "procedure",
9
+ "name": "RevealAndCommit",
10
+ "inputType": 1,
11
+ "inputTypeName": "RevealAndCommit_input",
12
+ "outputTypeName": "RevealAndCommit_output",
13
+ "inputSize": 544,
14
+ "outputSize": 1
15
+ }
16
+ ],
17
+ "ioTypes": [
18
+ {
19
+ "kind": "struct",
20
+ "name": "RevealAndCommit_input",
21
+ "fields": [
22
+ {
23
+ "name": "revealedBits",
24
+ "type": "bit_4096",
25
+ "byteOffset": 0
26
+ },
27
+ {
28
+ "name": "committedDigest",
29
+ "type": "id",
30
+ "byteOffset": 512
31
+ }
32
+ ],
33
+ "byteSize": 544,
34
+ "byteAlign": 8
35
+ },
36
+ {
37
+ "kind": "struct",
38
+ "name": "RevealAndCommit_output",
39
+ "fields": [],
40
+ "byteSize": 1,
41
+ "byteAlign": 1
42
+ },
43
+ {
44
+ "kind": "alias",
45
+ "name": "bit_4096",
46
+ "target": "BitArray<4096>",
47
+ "byteSize": 512,
48
+ "byteAlign": 8
49
+ }
50
+ ]
51
+ }
@@ -0,0 +1,65 @@
1
+ /* eslint-disable */
2
+ /* This file is generated. Do not edit manually. */
3
+
4
+ export type RANDOM_RevealAndCommit_input = {
5
+ readonly revealedBits: RANDOM_bit_4096;
6
+ readonly committedDigest: string;
7
+ };
8
+ export type RANDOM_RevealAndCommit_output = Record<string, never>;
9
+ export type RANDOM_bit_4096 = ReadonlyArray<boolean>;
10
+
11
+ export interface ContractTypeMap {
12
+ RANDOM: {
13
+ readonly contractIndex: 3;
14
+ readonly functions: Record<never, never>;
15
+ readonly procedures: {
16
+ RevealAndCommit: {
17
+ readonly kind: "procedure";
18
+ readonly inputType: 1;
19
+ readonly inputTypeName: "RevealAndCommit_input";
20
+ readonly outputTypeName: "RevealAndCommit_output";
21
+ readonly input: RANDOM_RevealAndCommit_input;
22
+ readonly output: RANDOM_RevealAndCommit_output;
23
+ };
24
+ };
25
+ };
26
+ }
27
+
28
+ export type ContractName = keyof ContractTypeMap & string;
29
+ export type FunctionName<C extends ContractName> = keyof ContractTypeMap[C]["functions"] & string;
30
+ export type ProcedureName<C extends ContractName> = keyof ContractTypeMap[C]["procedures"] & string;
31
+
32
+ export type FunctionInput<
33
+ C extends ContractName,
34
+ F extends FunctionName<C>,
35
+ > = ContractTypeMap[C]["functions"][F]["input"];
36
+ export type FunctionOutput<
37
+ C extends ContractName,
38
+ F extends FunctionName<C>,
39
+ > = ContractTypeMap[C]["functions"][F]["output"];
40
+
41
+ export type ProcedureInput<
42
+ C extends ContractName,
43
+ P extends ProcedureName<C>,
44
+ > = ContractTypeMap[C]["procedures"][P]["input"];
45
+ export type ProcedureOutput<
46
+ C extends ContractName,
47
+ P extends ProcedureName<C>,
48
+ > = ContractTypeMap[C]["procedures"][P]["output"];
49
+
50
+ export const contractCodecRegistry = {
51
+ RANDOM: {
52
+ contractIndex: 3,
53
+ functions: {},
54
+ procedures: {
55
+ RevealAndCommit: {
56
+ kind: "procedure",
57
+ inputType: 1,
58
+ inputTypeName: "RevealAndCommit_input",
59
+ outputTypeName: "RevealAndCommit_output",
60
+ },
61
+ },
62
+ },
63
+ } as const satisfies Readonly<Record<ContractName, unknown>>;
64
+
65
+ export type RuntimeContractCodecRegistry = typeof contractCodecRegistry;