@0xobelisk/client 0.4.8 → 1.2.0-pre.101
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/README.md +550 -2
- package/dist/browser/obelisk-client.js +102 -0
- package/dist/browser/obelisk-client.js.LICENSE.txt +16 -0
- package/dist/browser/obelisk-client.js.map +1 -0
- package/dist/browser/obelisk-client.min.js +101 -0
- package/dist/browser/obelisk-client.min.js.map +1 -0
- package/dist/index.d.ts +27 -9
- package/dist/sui/client.d.ts +59 -0
- package/dist/sui/index.d.mts +156 -0
- package/dist/sui/index.d.ts +19 -0
- package/dist/sui/index.js +93 -0
- package/dist/sui/index.js.map +1 -0
- package/dist/sui/index.mjs +88 -0
- package/dist/sui/index.mjs.map +1 -0
- package/dist/sui/types.d.ts +90 -0
- package/package.json +60 -121
- package/src/index.ts +31 -9
- package/src/sui/client.test.ts +277 -0
- package/src/sui/client.ts +157 -0
- package/src/sui/index.ts +30 -0
- package/src/sui/types.ts +94 -0
- package/LICENSE +0 -92
- package/dist/index.js +0 -1310
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1291
- package/dist/index.mjs.map +0 -1
- package/dist/libs/suiAccountManager/crypto.d.ts +0 -1
- package/dist/libs/suiAccountManager/index.d.ts +0 -35
- package/dist/libs/suiAccountManager/keypair.d.ts +0 -21
- package/dist/libs/suiAccountManager/util.d.ts +0 -29
- package/dist/libs/suiContractFactory/index.d.ts +0 -20
- package/dist/libs/suiContractFactory/types.d.ts +0 -49
- package/dist/libs/suiInteractor/defaultConfig.d.ts +0 -10
- package/dist/libs/suiInteractor/index.d.ts +0 -2
- package/dist/libs/suiInteractor/suiInteractor.d.ts +0 -205
- package/dist/libs/suiInteractor/util.d.ts +0 -1
- package/dist/libs/suiModel/index.d.ts +0 -2
- package/dist/libs/suiModel/suiOwnedObject.d.ts +0 -24
- package/dist/libs/suiModel/suiSharedObject.d.ts +0 -12
- package/dist/libs/suiTxBuilder/index.d.ts +0 -544
- package/dist/libs/suiTxBuilder/util.d.ts +0 -76
- package/dist/metadata/index.d.ts +0 -34
- package/dist/obelisk.d.ts +0 -2568
- package/dist/types/index.d.ts +0 -141
- package/dist/utils/index.d.ts +0 -3
- package/src/libs/suiAccountManager/crypto.ts +0 -7
- package/src/libs/suiAccountManager/index.ts +0 -72
- package/src/libs/suiAccountManager/keypair.ts +0 -38
- package/src/libs/suiAccountManager/util.ts +0 -70
- package/src/libs/suiContractFactory/index.ts +0 -120
- package/src/libs/suiContractFactory/types.ts +0 -54
- package/src/libs/suiInteractor/defaultConfig.ts +0 -32
- package/src/libs/suiInteractor/index.ts +0 -2
- package/src/libs/suiInteractor/suiInteractor.ts +0 -319
- package/src/libs/suiInteractor/util.ts +0 -2
- package/src/libs/suiModel/index.ts +0 -2
- package/src/libs/suiModel/suiOwnedObject.ts +0 -62
- package/src/libs/suiModel/suiSharedObject.ts +0 -33
- package/src/libs/suiTxBuilder/index.ts +0 -245
- package/src/libs/suiTxBuilder/util.ts +0 -84
- package/src/metadata/index.ts +0 -22
- package/src/obelisk.ts +0 -625
- package/src/types/index.ts +0 -205
- package/src/utils/index.ts +0 -23
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
normalizeSuiObjectId,
|
|
3
|
-
TransactionArgument,
|
|
4
|
-
TransactionBlock,
|
|
5
|
-
} from '@mysten/sui.js';
|
|
6
|
-
import { SuiTxArg, SuiInputTypes } from '../../types';
|
|
7
|
-
|
|
8
|
-
export const getDefaultSuiInputType = (value: any): SuiInputTypes => {
|
|
9
|
-
if (typeof value === 'string' && value.startsWith('0x')) {
|
|
10
|
-
return 'object';
|
|
11
|
-
} else if (typeof value === 'number' || typeof value === 'bigint') {
|
|
12
|
-
return 'u64';
|
|
13
|
-
} else if (typeof value === 'boolean') {
|
|
14
|
-
return 'bool';
|
|
15
|
-
} else {
|
|
16
|
-
return 'object';
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Since we know the elements in the array are the same type
|
|
22
|
-
* If type is not provided, we will try to infer the type from the first element
|
|
23
|
-
* By default,
|
|
24
|
-
*
|
|
25
|
-
* string starting with `0x` =====> object id
|
|
26
|
-
* number, bigint ====> u64
|
|
27
|
-
* boolean =====> bool
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* If type is provided, we will use the type to convert the array
|
|
31
|
-
* @param args
|
|
32
|
-
* @param type 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256' | 'object'
|
|
33
|
-
*/
|
|
34
|
-
export function makeVecParam(
|
|
35
|
-
txBlock: TransactionBlock,
|
|
36
|
-
args: SuiTxArg[],
|
|
37
|
-
type?: SuiInputTypes
|
|
38
|
-
) {
|
|
39
|
-
if (args.length === 0)
|
|
40
|
-
throw new Error('Transaction builder error: Empty array is not allowed');
|
|
41
|
-
const defaultSuiType = getDefaultSuiInputType(args[0]);
|
|
42
|
-
if (type === 'object' || (!type && defaultSuiType === 'object')) {
|
|
43
|
-
const objects = args.map((arg) =>
|
|
44
|
-
typeof arg === 'string'
|
|
45
|
-
? txBlock.object(normalizeSuiObjectId(arg))
|
|
46
|
-
: (arg as any)
|
|
47
|
-
);
|
|
48
|
-
return txBlock.makeMoveVec({ objects });
|
|
49
|
-
} else {
|
|
50
|
-
const vecType = type || defaultSuiType;
|
|
51
|
-
return txBlock.pure(args, `vector<${vecType}>`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function isMoveVecArg(arg: any) {
|
|
56
|
-
const isFullMoveVecArg =
|
|
57
|
-
arg && arg.value && Array.isArray(arg.value) && arg.vecType;
|
|
58
|
-
const isSimpleMoveVecArg = Array.isArray(arg);
|
|
59
|
-
return isFullMoveVecArg || isSimpleMoveVecArg;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function convertArgs(
|
|
63
|
-
txBlock: TransactionBlock,
|
|
64
|
-
args: any[]
|
|
65
|
-
): TransactionArgument[] {
|
|
66
|
-
return args.map((arg) => {
|
|
67
|
-
if (typeof arg === 'string' && arg.startsWith('0x')) {
|
|
68
|
-
// We always treat string starting with `0x` as object id
|
|
69
|
-
return txBlock.object(normalizeSuiObjectId(arg));
|
|
70
|
-
} else if (isMoveVecArg(arg)) {
|
|
71
|
-
// if it's an array arg, we will convert it to move vec
|
|
72
|
-
const vecType = arg.vecType || undefined;
|
|
73
|
-
return vecType
|
|
74
|
-
? makeVecParam(txBlock, arg.value, vecType)
|
|
75
|
-
: makeVecParam(txBlock, arg);
|
|
76
|
-
} else if (typeof arg !== 'object') {
|
|
77
|
-
// Other basic types such as string, number, boolean are converted to pure value
|
|
78
|
-
return txBlock.pure(arg);
|
|
79
|
-
} else {
|
|
80
|
-
// We do nothing, because it's most likely already a move value
|
|
81
|
-
return arg;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
package/src/metadata/index.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SuiMoveNormalizedModules } from '@mysten/sui.js';
|
|
2
|
-
import { SuiInteractor, getDefaultConnection } from '../libs/suiInteractor';
|
|
3
|
-
|
|
4
|
-
import { NetworkType } from '../types';
|
|
5
|
-
|
|
6
|
-
export async function loadMetadata(
|
|
7
|
-
networkType: NetworkType,
|
|
8
|
-
packageId: string
|
|
9
|
-
) {
|
|
10
|
-
// Init the rpc provider
|
|
11
|
-
const fullnodeUrls = [getDefaultConnection(networkType).fullnode];
|
|
12
|
-
const suiInteractor = new SuiInteractor(fullnodeUrls);
|
|
13
|
-
if (packageId !== undefined) {
|
|
14
|
-
const jsonData = await suiInteractor.getNormalizedMoveModulesByPackage(
|
|
15
|
-
packageId
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
return jsonData as SuiMoveNormalizedModules;
|
|
19
|
-
} else {
|
|
20
|
-
console.error('please set your package id.');
|
|
21
|
-
}
|
|
22
|
-
}
|