@0xobelisk/client 0.4.3 → 0.4.6
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/dist/index.d.ts +9 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiAccountManager/crypto.d.ts +1 -0
- package/dist/libs/suiAccountManager/index.d.ts +35 -0
- package/dist/libs/suiAccountManager/keypair.d.ts +21 -0
- package/dist/libs/suiAccountManager/util.d.ts +29 -0
- package/dist/libs/suiContractFactory/index.d.ts +20 -0
- package/dist/libs/suiContractFactory/types.d.ts +49 -0
- package/dist/libs/suiInteractor/defaultConfig.d.ts +10 -0
- package/dist/libs/suiInteractor/index.d.ts +2 -0
- package/dist/libs/suiInteractor/suiInteractor.d.ts +205 -0
- package/dist/libs/suiInteractor/util.d.ts +1 -0
- package/dist/libs/suiModel/index.d.ts +2 -0
- package/dist/libs/suiModel/suiOwnedObject.d.ts +24 -0
- package/dist/libs/suiModel/suiSharedObject.d.ts +12 -0
- package/dist/libs/suiTxBuilder/index.d.ts +544 -0
- package/dist/libs/suiTxBuilder/util.d.ts +76 -0
- package/dist/metadata/index.d.ts +34 -0
- package/dist/obelisk.d.ts +2566 -0
- package/dist/types/index.d.ts +141 -0
- package/dist/utils/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/libs/suiAccountManager/index.ts +1 -1
- package/src/libs/suiInteractor/defaultConfig.ts +1 -1
- package/src/libs/suiInteractor/suiInteractor.ts +1 -1
- package/src/libs/suiTxBuilder/index.ts +1 -1
- package/src/libs/suiTxBuilder/util.ts +1 -1
- package/src/metadata/index.ts +1 -1
- package/src/obelisk.ts +3 -2
- package/src/types/index.ts +1 -4
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Infer } from 'superstruct';
|
|
2
|
+
import { DisplayFieldsResponse, ObjectCallArg, ObjectContentFields, SharedObjectRef, SuiObjectRef, TransactionArgument, TransactionBlock, SuiTransactionBlockResponse, DevInspectResults, SuiMoveNormalizedModules } from '@mysten/sui.js';
|
|
3
|
+
import { SuiMoveMoudleFuncType } from '../libs/suiContractFactory/types';
|
|
4
|
+
export type ObeliskObjectData = {
|
|
5
|
+
objectId: string;
|
|
6
|
+
objectType: string;
|
|
7
|
+
objectVersion: number;
|
|
8
|
+
objectDisplay: DisplayFieldsResponse;
|
|
9
|
+
objectFields: ObjectContentFields;
|
|
10
|
+
};
|
|
11
|
+
export type ObeliskParams = {
|
|
12
|
+
mnemonics?: string;
|
|
13
|
+
secretKey?: string;
|
|
14
|
+
fullnodeUrls?: string[];
|
|
15
|
+
faucetUrl?: string;
|
|
16
|
+
networkType?: NetworkType;
|
|
17
|
+
packageId?: string;
|
|
18
|
+
metadata?: SuiMoveNormalizedModules;
|
|
19
|
+
};
|
|
20
|
+
export type SchemaFieldType = {
|
|
21
|
+
schemas: {
|
|
22
|
+
type: string;
|
|
23
|
+
fields: {
|
|
24
|
+
id: {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
size: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type SchemaValueType = {
|
|
32
|
+
id: {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
name: string;
|
|
36
|
+
value: {
|
|
37
|
+
type: string;
|
|
38
|
+
fields: SchemaFieldType;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type SuiTxArgument = {
|
|
42
|
+
kind: 'Input';
|
|
43
|
+
index: number;
|
|
44
|
+
type?: 'object' | 'pure' | undefined;
|
|
45
|
+
value?: any;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'GasCoin';
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'Result';
|
|
50
|
+
index: number;
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'NestedResult';
|
|
53
|
+
index: number;
|
|
54
|
+
resultIndex: number;
|
|
55
|
+
};
|
|
56
|
+
export type SchemaContentType = {
|
|
57
|
+
type: string;
|
|
58
|
+
fields: SchemaValueType;
|
|
59
|
+
hasPublicTransfer: boolean;
|
|
60
|
+
dataType: 'moveObject';
|
|
61
|
+
};
|
|
62
|
+
export interface MessageMeta {
|
|
63
|
+
readonly meta: SuiMoveMoudleFuncType;
|
|
64
|
+
}
|
|
65
|
+
export interface ContractQuery extends MessageMeta {
|
|
66
|
+
(tx: TransactionBlock, params: SuiTxArgument[], isRaw?: boolean): Promise<DevInspectResults | TransactionBlock>;
|
|
67
|
+
}
|
|
68
|
+
export interface ContractTx extends MessageMeta {
|
|
69
|
+
(tx: TransactionBlock, params: SuiTxArgument[], isRaw?: boolean): SuiTransactionBlockResponse | TransactionBlock;
|
|
70
|
+
}
|
|
71
|
+
export type MapMessageTx = Record<string, ContractTx>;
|
|
72
|
+
export type MapMessageQuery = Record<string, ContractQuery>;
|
|
73
|
+
export type MapMoudleFuncTx = Record<string, MapMessageTx>;
|
|
74
|
+
export type MapMoudleFuncQuery = Record<string, MapMessageQuery>;
|
|
75
|
+
export type MapMoudleFuncTest = Record<string, Record<string, string>>;
|
|
76
|
+
export type MapMoudleFuncQueryTest = Record<string, Record<string, string>>;
|
|
77
|
+
export type AccountMangerParams = {
|
|
78
|
+
mnemonics?: string;
|
|
79
|
+
secretKey?: string;
|
|
80
|
+
};
|
|
81
|
+
export type DerivePathParams = {
|
|
82
|
+
accountIndex?: number;
|
|
83
|
+
isExternal?: boolean;
|
|
84
|
+
addressIndex?: number;
|
|
85
|
+
};
|
|
86
|
+
export type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
|
|
87
|
+
export type FaucetNetworkType = 'testnet' | 'devnet' | 'localnet';
|
|
88
|
+
export type SuiKitParams = {
|
|
89
|
+
mnemonics?: string;
|
|
90
|
+
secretKey?: string;
|
|
91
|
+
fullnodeUrls?: string[];
|
|
92
|
+
faucetUrl?: string;
|
|
93
|
+
networkType?: NetworkType;
|
|
94
|
+
};
|
|
95
|
+
export type ObjectData = {
|
|
96
|
+
objectId: string;
|
|
97
|
+
objectType: string;
|
|
98
|
+
objectVersion: number;
|
|
99
|
+
objectDigest: string;
|
|
100
|
+
initialSharedVersion?: number;
|
|
101
|
+
objectDisplay: DisplayFieldsResponse;
|
|
102
|
+
objectFields: ObjectContentFields;
|
|
103
|
+
};
|
|
104
|
+
export type ObjectFieldType = {
|
|
105
|
+
id: {
|
|
106
|
+
id: string;
|
|
107
|
+
};
|
|
108
|
+
name: string;
|
|
109
|
+
value: string;
|
|
110
|
+
};
|
|
111
|
+
export type EntityData = {
|
|
112
|
+
objectId: string;
|
|
113
|
+
index: string;
|
|
114
|
+
key: string;
|
|
115
|
+
};
|
|
116
|
+
export type SuiTxArg = Infer<typeof TransactionArgument> | Infer<typeof ObjectCallArg> | string | number | bigint | boolean;
|
|
117
|
+
export type SuiObjectArg = SharedObjectRef | Infer<typeof SuiObjectRef> | string | Infer<typeof ObjectCallArg> | Infer<typeof TransactionArgument>;
|
|
118
|
+
export type SuiVecTxArg = {
|
|
119
|
+
value: SuiTxArg[];
|
|
120
|
+
vecType: SuiInputTypes;
|
|
121
|
+
} | SuiTxArg[];
|
|
122
|
+
/**
|
|
123
|
+
* These are the basics types that can be used in the SUI
|
|
124
|
+
*/
|
|
125
|
+
export type SuiBasicTypes = 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256';
|
|
126
|
+
export type SuiInputTypes = 'object' | SuiBasicTypes;
|
|
127
|
+
export type SuiReturnValues = {
|
|
128
|
+
returnValues: [number[], string][];
|
|
129
|
+
}[];
|
|
130
|
+
export type DynamicFieldContentType = {
|
|
131
|
+
type: string;
|
|
132
|
+
fields: Record<string, any>;
|
|
133
|
+
hasPublicTransfer: boolean;
|
|
134
|
+
dataType: string;
|
|
135
|
+
};
|
|
136
|
+
export type ObjectContent = {
|
|
137
|
+
type: string;
|
|
138
|
+
fields: Record<string, any>;
|
|
139
|
+
hasPublicTransfer: boolean;
|
|
140
|
+
dataType: string;
|
|
141
|
+
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { Ed25519Keypair } from '@mysten/sui.js';
|
|
|
2
2
|
import { getKeyPair } from './keypair';
|
|
3
3
|
import { hexOrBase64ToUint8Array, normalizePrivateKey } from './util';
|
|
4
4
|
import { generateMnemonic } from './crypto';
|
|
5
|
-
import type { AccountMangerParams, DerivePathParams } from '
|
|
5
|
+
import type { AccountMangerParams, DerivePathParams } from '../../types';
|
|
6
6
|
|
|
7
7
|
export class SuiAccountManager {
|
|
8
8
|
private mnemonics: string;
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
mainnetConnection,
|
|
6
6
|
} from '@mysten/sui.js';
|
|
7
7
|
import type { Connection } from '@mysten/sui.js';
|
|
8
|
-
import type { NetworkType } from '
|
|
8
|
+
import type { NetworkType } from '../../types';
|
|
9
9
|
export const defaultGasBudget = 10 ** 8; // 0.1 SUI, should be enough for most of the transactions
|
|
10
10
|
export const defaultGasPrice = 1000; // 1000 MIST
|
|
11
11
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
ObjectCallArg,
|
|
11
11
|
} from '@mysten/sui.js';
|
|
12
12
|
import { convertArgs } from './util';
|
|
13
|
-
import type { SuiTxArg, SuiObjectArg, SuiVecTxArg } from '
|
|
13
|
+
import type { SuiTxArg, SuiObjectArg, SuiVecTxArg } from '../../types';
|
|
14
14
|
|
|
15
15
|
export class SuiTxBlock {
|
|
16
16
|
public txBlock: TransactionBlock;
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
TransactionArgument,
|
|
4
4
|
TransactionBlock,
|
|
5
5
|
} from '@mysten/sui.js';
|
|
6
|
-
import { SuiTxArg, SuiInputTypes } from '
|
|
6
|
+
import { SuiTxArg, SuiInputTypes } from '../../types';
|
|
7
7
|
|
|
8
8
|
export const getDefaultSuiInputType = (value: any): SuiInputTypes => {
|
|
9
9
|
if (typeof value === 'string' && value.startsWith('0x')) {
|
package/src/metadata/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SuiMoveNormalizedModules } from '@mysten/sui.js';
|
|
2
2
|
import { SuiInteractor, getDefaultConnection } from '../libs/suiInteractor';
|
|
3
3
|
|
|
4
|
-
import { NetworkType } from '
|
|
4
|
+
import { NetworkType } from '../types';
|
|
5
5
|
|
|
6
6
|
export async function loadMetadata(
|
|
7
7
|
networkType: NetworkType,
|
package/src/obelisk.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { SuiAccountManager } from './libs/suiAccountManager';
|
|
|
10
10
|
import { SuiTxBlock } from './libs/suiTxBuilder';
|
|
11
11
|
import { getDefaultConnection, SuiInteractor } from './libs/suiInteractor';
|
|
12
12
|
|
|
13
|
-
import { ObeliskObjectData } from '
|
|
13
|
+
import { ObeliskObjectData } from './types';
|
|
14
14
|
import { SuiContractFactory } from './libs/suiContractFactory';
|
|
15
15
|
import {
|
|
16
16
|
SuiMoveMoudleFuncType,
|
|
@@ -475,7 +475,8 @@ export class Obelisk {
|
|
|
475
475
|
for (const res of resultList) {
|
|
476
476
|
const bcs = new BCS(getSuiMoveConfig());
|
|
477
477
|
const value = Uint8Array.from(res[0]);
|
|
478
|
-
const
|
|
478
|
+
const bcsType = res[1].replace(/0x1::ascii::String/g, 'string');
|
|
479
|
+
const data = bcs.de(bcsType, value);
|
|
479
480
|
returnValue.push(data);
|
|
480
481
|
}
|
|
481
482
|
return returnValue;
|
package/src/types/index.ts
CHANGED
|
@@ -12,10 +12,7 @@ import {
|
|
|
12
12
|
SuiMoveNormalizedModules,
|
|
13
13
|
} from '@mysten/sui.js';
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
SuiMoveMoudleValueType,
|
|
17
|
-
SuiMoveMoudleFuncType,
|
|
18
|
-
} from '../libs/suiContractFactory/types';
|
|
15
|
+
import { SuiMoveMoudleFuncType } from '../libs/suiContractFactory/types';
|
|
19
16
|
|
|
20
17
|
export type ObeliskObjectData = {
|
|
21
18
|
objectId: string;
|