@typemove/sui 1.0.0-rc.10

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 (30) hide show
  1. package/LICENSE +201 -0
  2. package/dist/codegen/run.js +19 -0
  3. package/dist/index.js +5 -0
  4. package/package.json +43 -0
  5. package/src/abis/0x1.json +2063 -0
  6. package/src/abis/0x2.json +13410 -0
  7. package/src/abis/0x3.json +8645 -0
  8. package/src/builtin/0x1.ts +2909 -0
  9. package/src/builtin/0x2.ts +14389 -0
  10. package/src/builtin/0x3.ts +4385 -0
  11. package/src/builtin/index.ts +6 -0
  12. package/src/codegen/codegen.ts +244 -0
  13. package/src/codegen/index.ts +1 -0
  14. package/src/codegen/run.ts +20 -0
  15. package/src/index.ts +8 -0
  16. package/src/models.ts +24 -0
  17. package/src/module-client.ts +23 -0
  18. package/src/move-coder.ts +147 -0
  19. package/src/sui-chain-adapter.ts +113 -0
  20. package/src/tests/abis/testnet/0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5.json +265 -0
  21. package/src/tests/abis/testnet/0x6c4a21e3e7e6b6d51c4604021633e1d97e24e37a696f8c082cd48f37503e602a.json +2429 -0
  22. package/src/tests/abis/testnet/0xdee9.json +5523 -0
  23. package/src/tests/abis/testnet/0xebaa2ad3eacc230f309cd933958cc52684df0a41ae7ac214d186b80f830867d2.json +10060 -0
  24. package/src/tests/types/testnet/0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5.ts +295 -0
  25. package/src/tests/types/testnet/0x6c4a21e3e7e6b6d51c4604021633e1d97e24e37a696f8c082cd48f37503e602a.ts +2745 -0
  26. package/src/tests/types/testnet/0xdee9.ts +3148 -0
  27. package/src/tests/types/testnet/0xebaa2ad3eacc230f309cd933958cc52684df0a41ae7ac214d186b80f830867d2.ts +10516 -0
  28. package/src/tests/types/testnet/index.ts +7 -0
  29. package/src/to-internal.ts +129 -0
  30. package/src/utils.ts +62 -0
@@ -0,0 +1,295 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+
5
+ /* Generated modules for account 0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5 */
6
+
7
+ import { TypeDescriptor, ANY_TYPE } from "@typemove/move";
8
+ import { MoveCoder, defaultMoveCoder, TypedEventInstance } from "@typemove/sui";
9
+ import { SuiAddress, ObjectId } from "@mysten/sui.js";
10
+
11
+ import { ZERO_ADDRESS } from "@typemove/sui";
12
+ import {
13
+ TransactionBlock,
14
+ TransactionArgument,
15
+ ObjectCallArg,
16
+ JsonRpcProvider,
17
+ } from "@mysten/sui.js";
18
+
19
+ import { _0x2 } from "@typemove/sui/builtin";
20
+ import { _0x1 } from "@typemove/sui/builtin";
21
+
22
+ export namespace oracle {
23
+ export interface Key<T0> {
24
+ id: _0x2.object_.UID;
25
+ for: _0x2.object_.ID;
26
+ }
27
+
28
+ export namespace Key {
29
+ export const TYPE_QNAME =
30
+ "0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5::oracle::Key";
31
+
32
+ const TYPE = new TypeDescriptor<Key<any>>(Key.TYPE_QNAME);
33
+
34
+ export function type<T0>(
35
+ arg0: TypeDescriptor<T0> = ANY_TYPE
36
+ ): TypeDescriptor<Key<T0>> {
37
+ return TYPE.apply(arg0);
38
+ }
39
+ }
40
+
41
+ export interface Oracle<T0> {
42
+ id: _0x2.object_.UID;
43
+ decimal: bigint;
44
+ price: bigint;
45
+ twap_price_1h: bigint;
46
+ ts_ms: bigint;
47
+ epoch: bigint;
48
+ }
49
+
50
+ export namespace Oracle {
51
+ export const TYPE_QNAME =
52
+ "0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5::oracle::Oracle";
53
+
54
+ const TYPE = new TypeDescriptor<Oracle<any>>(Oracle.TYPE_QNAME);
55
+
56
+ export function type<T0>(
57
+ arg0: TypeDescriptor<T0> = ANY_TYPE
58
+ ): TypeDescriptor<Oracle<T0>> {
59
+ return TYPE.apply(arg0);
60
+ }
61
+ }
62
+
63
+ export interface PriceEvent {
64
+ token: _0x1.ascii.String;
65
+ price: bigint;
66
+ ts_ms: bigint;
67
+ epoch: bigint;
68
+ }
69
+
70
+ export namespace PriceEvent {
71
+ export const TYPE_QNAME =
72
+ "0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5::oracle::PriceEvent";
73
+
74
+ const TYPE = new TypeDescriptor<PriceEvent>(PriceEvent.TYPE_QNAME);
75
+
76
+ export function type(): TypeDescriptor<PriceEvent> {
77
+ return TYPE.apply();
78
+ }
79
+ }
80
+
81
+ export interface PriceEventInstance extends TypedEventInstance<PriceEvent> {
82
+ data_decoded: PriceEvent;
83
+ type_arguments: [];
84
+ }
85
+
86
+ export namespace builder {
87
+ export function copyKey<T0 = any>(
88
+ tx: TransactionBlock,
89
+ args: [
90
+ ObjectId | ObjectCallArg | TransactionArgument,
91
+ SuiAddress | TransactionArgument,
92
+ ObjectId | ObjectCallArg | TransactionArgument
93
+ ],
94
+ typeArguments: [TypeDescriptor<T0> | string]
95
+ ): TransactionArgument &
96
+ [TransactionArgument, TransactionArgument, TransactionArgument] {
97
+ const _args: any[] = [];
98
+ _args.push(
99
+ TransactionArgument.is(args[0]) ? args[0] : tx.object(args[0])
100
+ );
101
+ _args.push(TransactionArgument.is(args[1]) ? args[1] : tx.pure(args[1]));
102
+ _args.push(
103
+ TransactionArgument.is(args[2]) ? args[2] : tx.object(args[2])
104
+ );
105
+
106
+ // @ts-ignore
107
+ return tx.moveCall({
108
+ target:
109
+ "0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5::oracle::copy_key",
110
+ arguments: _args,
111
+ typeArguments: [
112
+ typeof typeArguments[0] === "string"
113
+ ? typeArguments[0]
114
+ : typeArguments[0].getSignature(),
115
+ ],
116
+ });
117
+ }
118
+ export function getOracle<T0 = any>(
119
+ tx: TransactionBlock,
120
+ args: [ObjectId | ObjectCallArg | TransactionArgument],
121
+ typeArguments: [TypeDescriptor<T0> | string]
122
+ ): TransactionArgument & [TransactionArgument] {
123
+ const _args: any[] = [];
124
+ _args.push(
125
+ TransactionArgument.is(args[0]) ? args[0] : tx.object(args[0])
126
+ );
127
+
128
+ // @ts-ignore
129
+ return tx.moveCall({
130
+ target:
131
+ "0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5::oracle::get_oracle",
132
+ arguments: _args,
133
+ typeArguments: [
134
+ typeof typeArguments[0] === "string"
135
+ ? typeArguments[0]
136
+ : typeArguments[0].getSignature(),
137
+ ],
138
+ });
139
+ }
140
+ export function newOracle<T0 = any>(
141
+ tx: TransactionBlock,
142
+ args: [
143
+ bigint | TransactionArgument,
144
+ ObjectId | ObjectCallArg | TransactionArgument
145
+ ],
146
+ typeArguments: [TypeDescriptor<T0> | string]
147
+ ): TransactionArgument & [TransactionArgument, TransactionArgument] {
148
+ const _args: any[] = [];
149
+ _args.push(TransactionArgument.is(args[0]) ? args[0] : tx.pure(args[0]));
150
+ _args.push(
151
+ TransactionArgument.is(args[1]) ? args[1] : tx.object(args[1])
152
+ );
153
+
154
+ // @ts-ignore
155
+ return tx.moveCall({
156
+ target:
157
+ "0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5::oracle::new_oracle",
158
+ arguments: _args,
159
+ typeArguments: [
160
+ typeof typeArguments[0] === "string"
161
+ ? typeArguments[0]
162
+ : typeArguments[0].getSignature(),
163
+ ],
164
+ });
165
+ }
166
+ export function update<T0 = any>(
167
+ tx: TransactionBlock,
168
+ args: [
169
+ ObjectId | ObjectCallArg | TransactionArgument,
170
+ ObjectId | ObjectCallArg | TransactionArgument,
171
+ bigint | TransactionArgument,
172
+ bigint | TransactionArgument,
173
+ bigint | TransactionArgument,
174
+ ObjectId | ObjectCallArg | TransactionArgument
175
+ ],
176
+ typeArguments: [TypeDescriptor<T0> | string]
177
+ ): TransactionArgument &
178
+ [
179
+ TransactionArgument,
180
+ TransactionArgument,
181
+ TransactionArgument,
182
+ TransactionArgument,
183
+ TransactionArgument,
184
+ TransactionArgument
185
+ ] {
186
+ const _args: any[] = [];
187
+ _args.push(
188
+ TransactionArgument.is(args[0]) ? args[0] : tx.object(args[0])
189
+ );
190
+ _args.push(
191
+ TransactionArgument.is(args[1]) ? args[1] : tx.object(args[1])
192
+ );
193
+ _args.push(TransactionArgument.is(args[2]) ? args[2] : tx.pure(args[2]));
194
+ _args.push(TransactionArgument.is(args[3]) ? args[3] : tx.pure(args[3]));
195
+ _args.push(TransactionArgument.is(args[4]) ? args[4] : tx.pure(args[4]));
196
+ _args.push(
197
+ TransactionArgument.is(args[5]) ? args[5] : tx.object(args[5])
198
+ );
199
+
200
+ // @ts-ignore
201
+ return tx.moveCall({
202
+ target:
203
+ "0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5::oracle::update",
204
+ arguments: _args,
205
+ typeArguments: [
206
+ typeof typeArguments[0] === "string"
207
+ ? typeArguments[0]
208
+ : typeArguments[0].getSignature(),
209
+ ],
210
+ });
211
+ }
212
+ }
213
+ export namespace view {
214
+ export async function copyKey<T0 = any>(
215
+ provider: JsonRpcProvider,
216
+ args: [
217
+ ObjectId | ObjectCallArg | TransactionArgument,
218
+ SuiAddress | TransactionArgument,
219
+ ObjectId | ObjectCallArg | TransactionArgument
220
+ ],
221
+ typeArguments: [TypeDescriptor<T0> | string]
222
+ ) {
223
+ const tx = new TransactionBlock();
224
+ builder.copyKey(tx, args, typeArguments);
225
+ const res = await provider.devInspectTransactionBlock({
226
+ transactionBlock: tx,
227
+ sender: ZERO_ADDRESS,
228
+ });
229
+ return res;
230
+ }
231
+ export async function getOracle<T0 = any>(
232
+ provider: JsonRpcProvider,
233
+ args: [ObjectId | ObjectCallArg | TransactionArgument],
234
+ typeArguments: [TypeDescriptor<T0> | string]
235
+ ) {
236
+ const tx = new TransactionBlock();
237
+ builder.getOracle(tx, args, typeArguments);
238
+ const res = await provider.devInspectTransactionBlock({
239
+ transactionBlock: tx,
240
+ sender: ZERO_ADDRESS,
241
+ });
242
+ return res;
243
+ }
244
+ export async function newOracle<T0 = any>(
245
+ provider: JsonRpcProvider,
246
+ args: [
247
+ bigint | TransactionArgument,
248
+ ObjectId | ObjectCallArg | TransactionArgument
249
+ ],
250
+ typeArguments: [TypeDescriptor<T0> | string]
251
+ ) {
252
+ const tx = new TransactionBlock();
253
+ builder.newOracle(tx, args, typeArguments);
254
+ const res = await provider.devInspectTransactionBlock({
255
+ transactionBlock: tx,
256
+ sender: ZERO_ADDRESS,
257
+ });
258
+ return res;
259
+ }
260
+ export async function update<T0 = any>(
261
+ provider: JsonRpcProvider,
262
+ args: [
263
+ ObjectId | ObjectCallArg | TransactionArgument,
264
+ ObjectId | ObjectCallArg | TransactionArgument,
265
+ bigint | TransactionArgument,
266
+ bigint | TransactionArgument,
267
+ bigint | TransactionArgument,
268
+ ObjectId | ObjectCallArg | TransactionArgument
269
+ ],
270
+ typeArguments: [TypeDescriptor<T0> | string]
271
+ ) {
272
+ const tx = new TransactionBlock();
273
+ builder.update(tx, args, typeArguments);
274
+ const res = await provider.devInspectTransactionBlock({
275
+ transactionBlock: tx,
276
+ sender: ZERO_ADDRESS,
277
+ });
278
+ return res;
279
+ }
280
+ }
281
+ }
282
+
283
+ const MODULES = JSON.parse(
284
+ '[{"fileFormatVersion":6,"address":"0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5","name":"oracle","friends":[],"structs":{"Key":{"abilities":{"abilities":["Key"]},"typeParameters":[{"constraints":{"abilities":[]},"isPhantom":true}],"fields":[{"name":"id","type":{"Struct":{"address":"0x2","module":"object","name":"UID","typeArguments":[]}}},{"name":"for","type":{"Struct":{"address":"0x2","module":"object","name":"ID","typeArguments":[]}}}]},"Oracle":{"abilities":{"abilities":["Key"]},"typeParameters":[{"constraints":{"abilities":[]},"isPhantom":true}],"fields":[{"name":"id","type":{"Struct":{"address":"0x2","module":"object","name":"UID","typeArguments":[]}}},{"name":"decimal","type":"U64"},{"name":"price","type":"U64"},{"name":"twap_price_1h","type":"U64"},{"name":"ts_ms","type":"U64"},{"name":"epoch","type":"U64"}]},"PriceEvent":{"abilities":{"abilities":["Copy","Drop"]},"typeParameters":[],"fields":[{"name":"token","type":{"Struct":{"address":"0x1","module":"ascii","name":"String","typeArguments":[]}}},{"name":"price","type":"U64"},{"name":"ts_ms","type":"U64"},{"name":"epoch","type":"U64"}]}},"exposedFunctions":{"copy_key":{"visibility":"Public","isEntry":true,"typeParameters":[{"abilities":[]}],"parameters":[{"Reference":{"Struct":{"address":"0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5","module":"oracle","name":"Key","typeArguments":[{"TypeParameter":0}]}}},"Address",{"MutableReference":{"Struct":{"address":"0x2","module":"tx_context","name":"TxContext","typeArguments":[]}}}],"return":[]},"get_oracle":{"visibility":"Public","isEntry":false,"typeParameters":[{"abilities":[]}],"parameters":[{"Reference":{"Struct":{"address":"0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5","module":"oracle","name":"Oracle","typeArguments":[{"TypeParameter":0}]}}}],"return":["U64","U64","U64","U64"]},"new_oracle":{"visibility":"Public","isEntry":true,"typeParameters":[{"abilities":[]}],"parameters":["U64",{"MutableReference":{"Struct":{"address":"0x2","module":"tx_context","name":"TxContext","typeArguments":[]}}}],"return":[]},"update":{"visibility":"Public","isEntry":true,"typeParameters":[{"abilities":[]}],"parameters":[{"MutableReference":{"Struct":{"address":"0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5","module":"oracle","name":"Oracle","typeArguments":[{"TypeParameter":0}]}}},{"Reference":{"Struct":{"address":"0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5","module":"oracle","name":"Key","typeArguments":[{"TypeParameter":0}]}}},"U64","U64","U64",{"MutableReference":{"Struct":{"address":"0x2","module":"tx_context","name":"TxContext","typeArguments":[]}}}],"return":[]}}}]'
285
+ );
286
+
287
+ export function loadAllTypes(coder: MoveCoder) {
288
+ _0x2.loadAllTypes(coder);
289
+ _0x1.loadAllTypes(coder);
290
+ for (const m of Object.values(MODULES)) {
291
+ coder.load(m as any);
292
+ }
293
+ }
294
+
295
+ loadAllTypes(defaultMoveCoder());