@0xobelisk/sui-client 0.4.9

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 (47) hide show
  1. package/LICENSE +92 -0
  2. package/README.md +284 -0
  3. package/dist/index.d.ts +9 -0
  4. package/dist/index.js +1311 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +1292 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/libs/suiAccountManager/crypto.d.ts +1 -0
  9. package/dist/libs/suiAccountManager/index.d.ts +35 -0
  10. package/dist/libs/suiAccountManager/keypair.d.ts +21 -0
  11. package/dist/libs/suiAccountManager/util.d.ts +29 -0
  12. package/dist/libs/suiContractFactory/index.d.ts +20 -0
  13. package/dist/libs/suiContractFactory/types.d.ts +49 -0
  14. package/dist/libs/suiInteractor/defaultConfig.d.ts +10 -0
  15. package/dist/libs/suiInteractor/index.d.ts +2 -0
  16. package/dist/libs/suiInteractor/suiInteractor.d.ts +204 -0
  17. package/dist/libs/suiInteractor/util.d.ts +1 -0
  18. package/dist/libs/suiModel/index.d.ts +2 -0
  19. package/dist/libs/suiModel/suiOwnedObject.d.ts +24 -0
  20. package/dist/libs/suiModel/suiSharedObject.d.ts +12 -0
  21. package/dist/libs/suiTxBuilder/index.d.ts +544 -0
  22. package/dist/libs/suiTxBuilder/util.d.ts +76 -0
  23. package/dist/metadata/index.d.ts +34 -0
  24. package/dist/obelisk.d.ts +2568 -0
  25. package/dist/types/index.d.ts +141 -0
  26. package/dist/utils/index.d.ts +3 -0
  27. package/package.json +149 -0
  28. package/src/index.ts +9 -0
  29. package/src/libs/suiAccountManager/crypto.ts +7 -0
  30. package/src/libs/suiAccountManager/index.ts +72 -0
  31. package/src/libs/suiAccountManager/keypair.ts +38 -0
  32. package/src/libs/suiAccountManager/util.ts +70 -0
  33. package/src/libs/suiContractFactory/index.ts +120 -0
  34. package/src/libs/suiContractFactory/types.ts +61 -0
  35. package/src/libs/suiInteractor/defaultConfig.ts +32 -0
  36. package/src/libs/suiInteractor/index.ts +2 -0
  37. package/src/libs/suiInteractor/suiInteractor.ts +302 -0
  38. package/src/libs/suiInteractor/util.ts +2 -0
  39. package/src/libs/suiModel/index.ts +2 -0
  40. package/src/libs/suiModel/suiOwnedObject.ts +62 -0
  41. package/src/libs/suiModel/suiSharedObject.ts +33 -0
  42. package/src/libs/suiTxBuilder/index.ts +245 -0
  43. package/src/libs/suiTxBuilder/util.ts +84 -0
  44. package/src/metadata/index.ts +22 -0
  45. package/src/obelisk.ts +636 -0
  46. package/src/types/index.ts +211 -0
  47. package/src/utils/index.ts +23 -0
@@ -0,0 +1,211 @@
1
+ import { Infer } from 'superstruct';
2
+ import {
3
+ DisplayFieldsResponse,
4
+ ObjectCallArg,
5
+ ObjectContentFields,
6
+ SharedObjectRef,
7
+ SuiObjectRef,
8
+ TransactionArgument,
9
+ TransactionBlock,
10
+ SuiTransactionBlockResponse,
11
+ DevInspectResults,
12
+ SuiMoveNormalizedModules,
13
+ } from '@mysten/sui.js';
14
+
15
+ import { SuiMoveMoudleFuncType } from '../libs/suiContractFactory/types';
16
+
17
+ export type ObeliskObjectData = {
18
+ objectId: string;
19
+ objectType: string;
20
+ objectVersion: number;
21
+ objectDisplay: DisplayFieldsResponse;
22
+ objectFields: ObjectContentFields;
23
+ };
24
+
25
+ export type ObeliskParams = {
26
+ mnemonics?: string;
27
+ secretKey?: string;
28
+ fullnodeUrls?: string[];
29
+ faucetUrl?: string;
30
+ networkType?: NetworkType;
31
+ packageId?: string;
32
+ metadata?: SuiMoveNormalizedModules;
33
+ };
34
+
35
+ export type SchemaFieldType = {
36
+ schemas: {
37
+ type: string;
38
+ fields: {
39
+ id: {
40
+ id: string;
41
+ };
42
+ size: string;
43
+ };
44
+ };
45
+ };
46
+
47
+ export type SchemaValueType = {
48
+ id: {
49
+ id: string;
50
+ };
51
+ name: string;
52
+ value: {
53
+ type: string;
54
+ fields: SchemaFieldType;
55
+ };
56
+ };
57
+
58
+ export type SuiTxArgument =
59
+ | {
60
+ kind: 'Input';
61
+ index: number;
62
+ type?: 'object' | 'pure' | undefined;
63
+ value?: any;
64
+ }
65
+ | {
66
+ kind: 'GasCoin';
67
+ }
68
+ | {
69
+ kind: 'Result';
70
+ index: number;
71
+ }
72
+ | {
73
+ kind: 'NestedResult';
74
+ index: number;
75
+ resultIndex: number;
76
+ };
77
+ export type SchemaContentType = {
78
+ type: string;
79
+ fields: SchemaValueType;
80
+ hasPublicTransfer: boolean;
81
+ dataType: 'moveObject';
82
+ };
83
+
84
+ export interface MessageMeta {
85
+ readonly meta: SuiMoveMoudleFuncType;
86
+ }
87
+
88
+ export interface ContractQuery extends MessageMeta {
89
+ (
90
+ tx: TransactionBlock,
91
+ params: SuiTxArgument[],
92
+ typeArguments?: string[],
93
+ isRaw?: boolean
94
+ ): Promise<DevInspectResults | TransactionBlock>;
95
+ }
96
+
97
+ export interface ContractTx extends MessageMeta {
98
+ (
99
+ tx: TransactionBlock,
100
+ params: SuiTxArgument[],
101
+ typeArguments?: string[],
102
+ isRaw?: boolean
103
+ ): SuiTransactionBlockResponse | TransactionBlock;
104
+ }
105
+
106
+ export type MapMessageTx = Record<string, ContractTx>;
107
+ export type MapMessageQuery = Record<string, ContractQuery>;
108
+
109
+ export type MapMoudleFuncTx = Record<string, MapMessageTx>;
110
+ export type MapMoudleFuncQuery = Record<string, MapMessageQuery>;
111
+
112
+ export type MapMoudleFuncTest = Record<string, Record<string, string>>;
113
+ export type MapMoudleFuncQueryTest = Record<string, Record<string, string>>;
114
+
115
+ export type AccountMangerParams = {
116
+ mnemonics?: string;
117
+ secretKey?: string;
118
+ };
119
+
120
+ export type DerivePathParams = {
121
+ accountIndex?: number;
122
+ isExternal?: boolean;
123
+ addressIndex?: number;
124
+ };
125
+
126
+ export type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
127
+ export type FaucetNetworkType = 'testnet' | 'devnet' | 'localnet';
128
+
129
+ export type SuiKitParams = {
130
+ mnemonics?: string;
131
+ secretKey?: string;
132
+ fullnodeUrls?: string[];
133
+ faucetUrl?: string;
134
+ networkType?: NetworkType;
135
+ };
136
+
137
+ export type ObjectData = {
138
+ objectId: string;
139
+ objectType: string;
140
+ objectVersion: number;
141
+ objectDigest: string;
142
+ initialSharedVersion?: number;
143
+ objectDisplay: DisplayFieldsResponse;
144
+ objectFields: ObjectContentFields;
145
+ };
146
+
147
+ export type ObjectFieldType = {
148
+ id: {
149
+ id: string;
150
+ };
151
+ name: string;
152
+ value: string;
153
+ };
154
+
155
+ export type EntityData = {
156
+ objectId: string;
157
+ index: string;
158
+ key: string;
159
+ };
160
+
161
+ export type SuiTxArg =
162
+ | Infer<typeof TransactionArgument>
163
+ | Infer<typeof ObjectCallArg>
164
+ | string
165
+ | number
166
+ | bigint
167
+ | boolean;
168
+
169
+ export type SuiObjectArg =
170
+ | SharedObjectRef
171
+ | Infer<typeof SuiObjectRef>
172
+ | string
173
+ | Infer<typeof ObjectCallArg>
174
+ | Infer<typeof TransactionArgument>;
175
+
176
+ export type SuiVecTxArg =
177
+ | { value: SuiTxArg[]; vecType: SuiInputTypes }
178
+ | SuiTxArg[];
179
+
180
+ /**
181
+ * These are the basics types that can be used in the SUI
182
+ */
183
+ export type SuiBasicTypes =
184
+ | 'address'
185
+ | 'bool'
186
+ | 'u8'
187
+ | 'u16'
188
+ | 'u32'
189
+ | 'u64'
190
+ | 'u128'
191
+ | 'u256';
192
+
193
+ export type SuiInputTypes = 'object' | SuiBasicTypes;
194
+
195
+ export type SuiReturnValues = {
196
+ returnValues: [number[], string][];
197
+ }[];
198
+
199
+ export type DynamicFieldContentType = {
200
+ type: string;
201
+ fields: Record<string, any>;
202
+ hasPublicTransfer: boolean;
203
+ dataType: string;
204
+ };
205
+
206
+ export type ObjectContent = {
207
+ type: string;
208
+ fields: Record<string, any>;
209
+ hasPublicTransfer: boolean;
210
+ dataType: string;
211
+ };
@@ -0,0 +1,23 @@
1
+ export function capitalizeFirstLetter(input: string): string {
2
+ return input.charAt(0).toUpperCase() + input.slice(1);
3
+ }
4
+
5
+ export function normalizeHexAddress(input: string): string | null {
6
+ const hexRegex = /^(0x)?[0-9a-fA-F]{64}$/;
7
+
8
+ if (hexRegex.test(input)) {
9
+ if (input.startsWith('0x')) {
10
+ return input;
11
+ } else {
12
+ return '0x' + input;
13
+ }
14
+ } else {
15
+ return null;
16
+ }
17
+ }
18
+
19
+ export function numberToAddressHex(num: number): string {
20
+ const hex = num.toString(16);
21
+ const paddedHex = '0x' + hex.padStart(64, '0');
22
+ return paddedHex;
23
+ }