@0xobelisk/sui-client 0.5.18 → 0.5.19

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 (35) hide show
  1. package/dist/index.d.ts +15 -0
  2. package/dist/index.js +93 -134
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +63 -104
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/libs/multiSig/client.d.ts +15 -0
  7. package/dist/libs/multiSig/index.d.ts +1 -0
  8. package/dist/libs/multiSig/publickey.d.ts +2 -0
  9. package/dist/libs/suiAccountManager/crypto.d.ts +1 -0
  10. package/dist/libs/suiAccountManager/index.d.ts +39 -0
  11. package/dist/libs/suiAccountManager/keypair.d.ts +21 -0
  12. package/dist/libs/suiAccountManager/util.d.ts +29 -0
  13. package/dist/libs/suiContractFactory/index.d.ts +20 -0
  14. package/dist/libs/suiContractFactory/types.d.ts +49 -0
  15. package/dist/libs/suiInteractor/index.d.ts +1 -0
  16. package/dist/libs/suiInteractor/suiInteractor.d.ts +50 -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 +11 -0
  21. package/dist/libs/suiTxBuilder/index.d.ts +538 -0
  22. package/dist/libs/suiTxBuilder/util.d.ts +49 -0
  23. package/dist/metadata/index.d.ts +3 -0
  24. package/dist/obelisk.d.ts +140 -0
  25. package/dist/types/index.d.ts +202 -0
  26. package/dist/utils/index.d.ts +3 -0
  27. package/package.json +2 -5
  28. package/src/libs/multiSig/client.ts +1 -1
  29. package/src/libs/suiAccountManager/index.ts +4 -5
  30. package/src/libs/suiInteractor/index.ts +0 -1
  31. package/src/libs/suiModel/suiOwnedObject.ts +2 -2
  32. package/src/libs/suiModel/suiSharedObject.ts +2 -2
  33. package/src/libs/suiTxBuilder/index.ts +43 -49
  34. package/src/libs/suiTxBuilder/util.ts +65 -129
  35. package/src/types/index.ts +40 -16
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @description This regular expression matches any string that contains only hexadecimal digits (0-9, A-F, a-f).
3
+ * @param str
4
+ */
5
+ export declare const isHex: (str: string) => boolean;
6
+ /**
7
+ * @description This regular expression matches any string that contains only base64 digits (0-9, A-Z, a-z, +, /, =).
8
+ * Note that the "=" signs at the end are optional padding characters that may be present in some base64 encoded strings.
9
+ * @param str
10
+ */
11
+ export declare const isBase64: (str: string) => boolean;
12
+ /**
13
+ * Convert a hex string to Uint8Array
14
+ * @param hexStr
15
+ */
16
+ export declare const fromHEX: (hexStr: string) => Uint8Array;
17
+ /**
18
+ * @description Convert a hex or base64 string to Uint8Array
19
+ */
20
+ export declare const hexOrBase64ToUint8Array: (str: string) => Uint8Array;
21
+ /**
22
+ * normalize a private key
23
+ * A private key is a 32-byte array.
24
+ * But there are two different formats for private keys:
25
+ * 1. A 32-byte array
26
+ * 2. A 64-byte array with the first 32 bytes being the private key and the last 32 bytes being the public key
27
+ * 3. A 33-byte array with the first byte being 0x00 (sui.keystore key is a Base64 string with scheme flag 0x00 at the beginning)
28
+ */
29
+ export declare const normalizePrivateKey: (key: Uint8Array) => Uint8Array;
@@ -0,0 +1,20 @@
1
+ import type { SuiMoveNormalizedModules } from '@mysten/sui/client';
2
+ import type { ContractFactoryParams } from './types';
3
+ export type ApiTypes = 'promise' | 'rxjs';
4
+ export declare class SuiContractFactory {
5
+ packageId: string;
6
+ metadata: SuiMoveNormalizedModules | undefined;
7
+ /**
8
+ * Support the following ways to init the SuiToolkit:
9
+ * 1. mnemonics
10
+ * 2. secretKey (base64 or hex)
11
+ * If none of them is provided, will generate a random mnemonics with 24 words.
12
+ *
13
+ * @param mnemonics, 12 or 24 mnemonics words, separated by space
14
+ * @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
15
+ */
16
+ constructor({ packageId, metadata }?: ContractFactoryParams);
17
+ getFuncByModuleName(moduleName: string): void;
18
+ getAllFunc(): void;
19
+ getAllModule(): void;
20
+ }
@@ -0,0 +1,49 @@
1
+ import type { SuiMoveNormalizedModules, SuiMoveNormalizedType } from '@mysten/sui/client';
2
+ export type ContractFactoryParams = {
3
+ packageId?: string;
4
+ metadata?: SuiMoveNormalizedModules;
5
+ };
6
+ export type SuiMoveMoudleValueType = {
7
+ address: string;
8
+ name: string;
9
+ fileFormatVersion: number;
10
+ friends: {
11
+ address: string;
12
+ name: string;
13
+ }[];
14
+ structs: Record<string, {
15
+ fields: {
16
+ type: SuiMoveNormalizedType;
17
+ name: string;
18
+ }[];
19
+ abilities: {
20
+ abilities: string[];
21
+ };
22
+ typeParameters: {
23
+ constraints: {
24
+ abilities: string[];
25
+ };
26
+ isPhantom: boolean;
27
+ }[];
28
+ }>;
29
+ exposedFunctions: Record<string, {
30
+ visibility: 'Private' | 'Public' | 'Friend';
31
+ isEntry: boolean;
32
+ typeParameters: {
33
+ abilities: string[];
34
+ }[];
35
+ parameters: SuiMoveNormalizedType[];
36
+ return: SuiMoveNormalizedType[];
37
+ }>;
38
+ };
39
+ export type SuiMoveMoudleFuncType = {
40
+ moduleName: string;
41
+ funcName: string;
42
+ visibility: 'Private' | 'Public' | 'Friend';
43
+ isEntry: boolean;
44
+ typeParameters: {
45
+ abilities: string[];
46
+ }[];
47
+ parameters: SuiMoveNormalizedType[];
48
+ return: SuiMoveNormalizedType[];
49
+ };
@@ -0,0 +1 @@
1
+ export { SuiInteractor } from './suiInteractor';
@@ -0,0 +1,50 @@
1
+ import { SuiClient } from '@mysten/sui/client';
2
+ import type { SuiTransactionBlockResponse, SuiObjectDataOptions, SuiObjectData } from '@mysten/sui/client';
3
+ import type * as RpcTypes from '@mysten/sui/dist/cjs/client/types/generated';
4
+ import { FaucetNetworkType, NetworkType } from '../../types';
5
+ import { SuiOwnedObject, SuiSharedObject } from '../suiModel';
6
+ /**
7
+ * `SuiTransactionSender` is used to send transaction with a given gas coin.
8
+ * It always uses the gas coin to pay for the gas,
9
+ * and update the gas coin after the transaction.
10
+ */
11
+ export declare class SuiInteractor {
12
+ readonly clients: SuiClient[];
13
+ currentClient: SuiClient;
14
+ readonly fullNodes: string[];
15
+ currentFullNode: string;
16
+ network?: NetworkType;
17
+ constructor(fullNodeUrls: string[], network?: NetworkType);
18
+ switchToNextClient(): void;
19
+ sendTx(transactionBlock: Uint8Array | string, signature: string | string[]): Promise<SuiTransactionBlockResponse>;
20
+ getObjects(ids: string[], options?: SuiObjectDataOptions): Promise<SuiObjectData[]>;
21
+ getObject(id: string): Promise<SuiObjectData>;
22
+ getDynamicFieldObject(parentId: string, name: RpcTypes.DynamicFieldName): Promise<RpcTypes.SuiObjectResponse>;
23
+ getDynamicFields(parentId: string, cursor?: string, limit?: number): Promise<import("@mysten/sui/client").DynamicFieldPage>;
24
+ getTxDetails(digest: string): Promise<SuiTransactionBlockResponse>;
25
+ getOwnedObjects(owner: string, cursor?: string, limit?: number): Promise<RpcTypes.PaginatedObjectsResponse>;
26
+ getNormalizedMoveModulesByPackage(packageId: string): Promise<import("@mysten/sui/client").SuiMoveNormalizedModules>;
27
+ /**
28
+ * @description Update objects in a batch
29
+ * @param suiObjects
30
+ */
31
+ updateObjects(suiObjects: (SuiOwnedObject | SuiSharedObject)[]): Promise<void>;
32
+ /**
33
+ * @description Select coins that add up to the given amount.
34
+ * @param addr the address of the owner
35
+ * @param amount the amount that is needed for the coin
36
+ * @param coinType the coin type, default is '0x2::SUI::SUI'
37
+ */
38
+ selectCoins(addr: string, amount: number, coinType?: string): Promise<{
39
+ objectId: string;
40
+ digest: string;
41
+ version: string;
42
+ }[]>;
43
+ /**
44
+ * @description Select owned objects with objectType.
45
+ * @param addr the address of the owner
46
+ * @param objectType the coin type, default is '0x2::SUI::SUI'
47
+ */
48
+ selectObjects(addr: string, objectType: string): Promise<SuiObjectData[]>;
49
+ requestFaucet(address: string, network: FaucetNetworkType): Promise<void>;
50
+ }
@@ -0,0 +1 @@
1
+ export declare const delay: (ms: number) => Promise<unknown>;
@@ -0,0 +1,2 @@
1
+ export { SuiOwnedObject } from './suiOwnedObject';
2
+ export { SuiSharedObject } from './suiSharedObject';
@@ -0,0 +1,24 @@
1
+ import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
2
+ import type { CallArg } from '@mysten/sui/transactions';
3
+ export declare class SuiOwnedObject {
4
+ readonly objectId: string;
5
+ version?: string;
6
+ digest?: string;
7
+ constructor(param: {
8
+ objectId: string;
9
+ version?: string;
10
+ digest?: string;
11
+ });
12
+ /**
13
+ * Check if the object is fully initialized.
14
+ * So that when it's used as an input, it won't be necessary to fetch from fullnode again.
15
+ * Which can save time when sending transactions.
16
+ */
17
+ isFullObject(): boolean;
18
+ asCallArg(): CallArg | string;
19
+ /**
20
+ * Update object version & digest based on the transaction response.
21
+ * @param txResponse
22
+ */
23
+ updateFromTxResponse(txResponse: SuiTransactionBlockResponse): void;
24
+ }
@@ -0,0 +1,11 @@
1
+ import type { CallArg } from '@mysten/sui/transactions';
2
+ export declare class SuiSharedObject {
3
+ readonly objectId: string;
4
+ initialSharedVersion?: string;
5
+ constructor(param: {
6
+ objectId: string;
7
+ initialSharedVersion?: string;
8
+ mutable?: boolean;
9
+ });
10
+ asCallArg(mutable?: boolean): CallArg | string;
11
+ }