@0xobelisk/sui-client 0.5.16 → 0.5.18

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 (43) hide show
  1. package/dist/index.js +360 -205
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +350 -195
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +11 -5
  6. package/src/index.ts +9 -8
  7. package/src/libs/multiSig/client.ts +2 -2
  8. package/src/libs/multiSig/publickey.ts +3 -3
  9. package/src/libs/suiAccountManager/index.ts +25 -6
  10. package/src/libs/suiAccountManager/keypair.ts +1 -1
  11. package/src/libs/suiAccountManager/util.ts +1 -1
  12. package/src/libs/suiContractFactory/index.ts +1 -1
  13. package/src/libs/suiContractFactory/types.ts +1 -1
  14. package/src/libs/suiInteractor/suiInteractor.ts +4 -4
  15. package/src/libs/suiModel/suiOwnedObject.ts +6 -4
  16. package/src/libs/suiModel/suiSharedObject.ts +5 -3
  17. package/src/libs/suiTxBuilder/index.ts +102 -84
  18. package/src/libs/suiTxBuilder/util.ts +113 -42
  19. package/src/metadata/index.ts +2 -3
  20. package/src/obelisk.ts +200 -91
  21. package/src/types/index.ts +46 -32
  22. package/dist/index.d.ts +0 -14
  23. package/dist/libs/multiSig/client.d.ts +0 -15
  24. package/dist/libs/multiSig/index.d.ts +0 -1
  25. package/dist/libs/multiSig/publickey.d.ts +0 -2
  26. package/dist/libs/suiAccountManager/crypto.d.ts +0 -1
  27. package/dist/libs/suiAccountManager/index.d.ts +0 -35
  28. package/dist/libs/suiAccountManager/keypair.d.ts +0 -21
  29. package/dist/libs/suiAccountManager/util.d.ts +0 -29
  30. package/dist/libs/suiContractFactory/index.d.ts +0 -20
  31. package/dist/libs/suiContractFactory/types.d.ts +0 -49
  32. package/dist/libs/suiInteractor/index.d.ts +0 -1
  33. package/dist/libs/suiInteractor/suiInteractor.d.ts +0 -50
  34. package/dist/libs/suiInteractor/util.d.ts +0 -1
  35. package/dist/libs/suiModel/index.d.ts +0 -2
  36. package/dist/libs/suiModel/suiOwnedObject.d.ts +0 -24
  37. package/dist/libs/suiModel/suiSharedObject.d.ts +0 -11
  38. package/dist/libs/suiTxBuilder/index.d.ts +0 -333
  39. package/dist/libs/suiTxBuilder/util.d.ts +0 -58
  40. package/dist/metadata/index.d.ts +0 -3
  41. package/dist/obelisk.d.ts +0 -136
  42. package/dist/types/index.d.ts +0 -152
  43. package/dist/utils/index.d.ts +0 -3
@@ -1,3 +0,0 @@
1
- import { SuiMoveNormalizedModules } from '@mysten/sui.js/client';
2
- import { NetworkType } from '../types';
3
- export declare function loadMetadata(networkType: NetworkType, packageId: string): Promise<SuiMoveNormalizedModules | undefined>;
package/dist/obelisk.d.ts DELETED
@@ -1,136 +0,0 @@
1
- /// <reference types="node" />
2
- import { TransactionBlock } from '@mysten/sui.js/transactions';
3
- import type { SuiTransactionBlockResponse, DevInspectResults, SuiMoveNormalizedModules, SuiObjectData } from '@mysten/sui.js/client';
4
- import { SuiAccountManager } from './libs/suiAccountManager';
5
- import { SuiTxBlock } from './libs/suiTxBuilder';
6
- import { SuiInteractor } from './libs/suiInteractor';
7
- import { SuiContractFactory } from './libs/suiContractFactory';
8
- import { SuiMoveMoudleFuncType } from './libs/suiContractFactory/types';
9
- import { DerivePathParams, FaucetNetworkType, MapMoudleFuncQuery, MapMoudleFuncTx, ObeliskParams, SuiTxArg, SuiVecTxArg } from './types';
10
- export declare function isUndefined(value?: unknown): value is undefined;
11
- export declare function withMeta<T extends {
12
- meta: SuiMoveMoudleFuncType;
13
- }>(meta: SuiMoveMoudleFuncType, creator: Omit<T, 'meta'>): T;
14
- /**
15
- * @class Obelisk
16
- * @description This class is used to aggregate the tools that used to interact with SUI network.
17
- */
18
- export declare class Obelisk {
19
- #private;
20
- accountManager: SuiAccountManager;
21
- suiInteractor: SuiInteractor;
22
- contractFactory: SuiContractFactory;
23
- packageId: string | undefined;
24
- metadata: SuiMoveNormalizedModules | undefined;
25
- /**
26
- * Support the following ways to init the ObeliskClient:
27
- * 1. mnemonics
28
- * 2. secretKey (base64 or hex)
29
- * If none of them is provided, will generate a random mnemonics with 24 words.
30
- *
31
- * @param mnemonics, 12 or 24 mnemonics words, separated by space
32
- * @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
33
- * @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet'
34
- * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
35
- * @param packageId
36
- */
37
- constructor({ mnemonics, secretKey, networkType, fullnodeUrls, packageId, metadata, }?: ObeliskParams);
38
- get query(): MapMoudleFuncQuery;
39
- get tx(): MapMoudleFuncTx;
40
- /**
41
- * if derivePathParams is not provided or mnemonics is empty, it will return the keypair.
42
- * else:
43
- * it will generate signer from the mnemonic with the given derivePathParams.
44
- * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
45
- */
46
- getKeypair(derivePathParams?: DerivePathParams): import("@mysten/sui.js/dist/cjs/keypairs/ed25519").Ed25519Keypair;
47
- /**
48
- * @description Switch the current account with the given derivePathParams
49
- * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
50
- */
51
- switchAccount(derivePathParams: DerivePathParams): void;
52
- /**
53
- * @description Get the address of the account for the given derivePathParams
54
- * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
55
- */
56
- getAddress(derivePathParams?: DerivePathParams): string;
57
- currentAddress(): string;
58
- getPackageId(): string;
59
- getMetadata(): SuiMoveNormalizedModules | undefined;
60
- /**
61
- * Request some SUI from faucet
62
- * @Returns {Promise<boolean>}, true if the request is successful, false otherwise.
63
- */
64
- requestFaucet(address: string, network: FaucetNetworkType): Promise<void>;
65
- getBalance(coinType?: string, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui.js/client").CoinBalance>;
66
- balanceOf(accountAddress?: string, coinType?: string, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui.js/client").CoinBalance>;
67
- client(): import("@mysten/sui.js/client").SuiClient;
68
- getObject(objectId: string): Promise<SuiObjectData>;
69
- getObjects(objectIds: string[]): Promise<SuiObjectData[]>;
70
- signTxn(tx: Uint8Array | TransactionBlock | SuiTxBlock, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui.js/dist/cjs/cryptography").SignatureWithBytes>;
71
- signAndSendTxn(tx: Uint8Array | TransactionBlock | SuiTxBlock, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
72
- /**
73
- * Transfer the given amount of SUI to the recipient
74
- * @param recipient
75
- * @param amount
76
- * @param derivePathParams
77
- */
78
- transferSui(recipient: string, amount: number, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
79
- /**
80
- * Transfer to mutliple recipients
81
- * @param recipients the recipients addresses
82
- * @param amounts the amounts of SUI to transfer to each recipient, the length of amounts should be the same as the length of recipients
83
- * @param derivePathParams
84
- */
85
- transferSuiToMany(recipients: string[], amounts: number[], derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
86
- /**
87
- * Transfer the given amounts of coin to multiple recipients
88
- * @param recipients the list of recipient address
89
- * @param amounts the amounts to transfer for each recipient
90
- * @param coinType any custom coin type but not SUI
91
- * @param derivePathParams the derive path params for the current signer
92
- */
93
- transferCoinToMany(recipients: string[], amounts: number[], coinType: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
94
- transferCoin(recipient: string, amount: number, coinType: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
95
- transferObjects(objects: string[], recipient: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
96
- moveCall(callParams: {
97
- target: string;
98
- arguments?: (SuiTxArg | SuiVecTxArg)[];
99
- typeArguments?: string[];
100
- derivePathParams?: DerivePathParams;
101
- }): Promise<SuiTransactionBlockResponse>;
102
- /**
103
- * Select coins with the given amount and coin type, the total amount is greater than or equal to the given amount
104
- * @param amount
105
- * @param coinType
106
- * @param owner
107
- */
108
- selectCoinsWithAmount(amount: number, coinType: string, owner?: string): Promise<string[]>;
109
- selectObjectsWithType(objectType: string, owner?: string): Promise<string[]>;
110
- /**
111
- * stake the given amount of SUI to the validator
112
- * @param amount the amount of SUI to stake
113
- * @param validatorAddr the validator address
114
- * @param derivePathParams the derive path params for the current signer
115
- */
116
- stakeSui(amount: number, validatorAddr: string, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
117
- /**
118
- * Execute the transaction with on-chain data but without really submitting. Useful for querying the effects of a transaction.
119
- * Since the transaction is not submitted, its gas cost is not charged.
120
- * @param tx the transaction to execute
121
- * @param derivePathParams the derive path params
122
- * @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.
123
- */
124
- inspectTxn(tx: Uint8Array | TransactionBlock | SuiTxBlock, derivePathParams?: DerivePathParams): Promise<DevInspectResults>;
125
- getWorld(worldObjectId: string): Promise<SuiObjectData>;
126
- listSchemaNames(worldId: string): Promise<any>;
127
- getEntity(worldId: string, schemaName: string, entityId?: string): Promise<any[] | undefined>;
128
- containEntity(worldId: string, schemaName: string, entityId?: string): Promise<boolean | undefined>;
129
- getOwnedObjects(owner: string, cursor?: string, limit?: number): Promise<SuiObjectData[]>;
130
- entity_key_from_object(objectId: string): Promise<string | undefined>;
131
- entity_key_from_bytes(bytes: Uint8Array | Buffer | string): Promise<string>;
132
- entity_key_from_address_with_seed(objectId: string, seed: string): Promise<string | undefined>;
133
- entity_key_from_address_with_u256(objectId: string, x: number): Promise<string | undefined>;
134
- entity_key_from_u256(x: number): Promise<string>;
135
- formatData(type: string, value: Buffer | number[] | Uint8Array): Promise<any>;
136
- }
@@ -1,152 +0,0 @@
1
- import type { Infer } from 'superstruct';
2
- import type { SerializedBcs } from '@mysten/bcs';
3
- import type { TransactionArgument } from '@mysten/sui.js/transactions';
4
- import type { TransactionBlock, TransactionObjectArgument, TransactionResult } from '@mysten/sui.js/transactions';
5
- import type { SuiObjectRef, SuiMoveNormalizedModules, DevInspectResults, SuiTransactionBlockResponse, DisplayFieldsResponse, MoveStruct } from '@mysten/sui.js/client';
6
- import type { SharedObjectRef, ObjectArg } from '@mysten/sui.js/bcs';
7
- import { SuiMoveMoudleFuncType } from '../libs/suiContractFactory/types';
8
- export declare const ObjectContentFields: import("superstruct").Struct<Record<string, any>, null>;
9
- export type ObjectContentFields = Infer<typeof ObjectContentFields>;
10
- export type ObeliskObjectData = {
11
- objectId: string;
12
- objectType: string;
13
- objectVersion: number;
14
- objectDisplay: DisplayFieldsResponse;
15
- objectFields: ObjectContentFields;
16
- };
17
- export type ObeliskObjectContent = {
18
- dataType: 'moveObject';
19
- fields: MoveStruct;
20
- hasPublicTransfer: boolean;
21
- type: string;
22
- };
23
- export type ObeliskParams = {
24
- mnemonics?: string;
25
- secretKey?: string;
26
- fullnodeUrls?: string[];
27
- faucetUrl?: string;
28
- networkType?: NetworkType;
29
- packageId?: string;
30
- metadata?: SuiMoveNormalizedModules;
31
- };
32
- export type SchemaFieldType = {
33
- schemas: {
34
- type: string;
35
- fields: {
36
- id: {
37
- id: string;
38
- };
39
- size: string;
40
- };
41
- };
42
- };
43
- export type SchemaValueType = {
44
- id: {
45
- id: string;
46
- };
47
- name: string;
48
- value: {
49
- type: string;
50
- fields: SchemaFieldType;
51
- };
52
- };
53
- export type SchemaContentType = {
54
- type: string;
55
- fields: SchemaValueType;
56
- hasPublicTransfer: boolean;
57
- dataType: 'moveObject';
58
- };
59
- export interface MessageMeta {
60
- readonly meta: SuiMoveMoudleFuncType;
61
- }
62
- export interface ContractQuery extends MessageMeta {
63
- (tx: TransactionBlock, params: (TransactionArgument | SerializedBcs<any>)[], typeArguments?: string[], isRaw?: boolean): Promise<DevInspectResults | TransactionResult>;
64
- }
65
- export interface ContractTx extends MessageMeta {
66
- (tx: TransactionBlock, params: (TransactionArgument | SerializedBcs<any>)[], typeArguments?: string[], isRaw?: boolean): Promise<SuiTransactionBlockResponse | TransactionResult>;
67
- }
68
- export type MapMessageTx = Record<string, ContractTx>;
69
- export type MapMessageQuery = Record<string, ContractQuery>;
70
- export type MapMoudleFuncTx = Record<string, MapMessageTx>;
71
- export type MapMoudleFuncQuery = Record<string, MapMessageQuery>;
72
- export type MapMoudleFuncTest = Record<string, Record<string, string>>;
73
- export type MapMoudleFuncQueryTest = Record<string, Record<string, string>>;
74
- export type AccountMangerParams = {
75
- mnemonics?: string;
76
- secretKey?: string;
77
- };
78
- export type DerivePathParams = {
79
- accountIndex?: number;
80
- isExternal?: boolean;
81
- addressIndex?: number;
82
- };
83
- export type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
84
- export type FaucetNetworkType = 'testnet' | 'devnet' | 'localnet';
85
- export type SuiKitParams = {
86
- mnemonics?: string;
87
- secretKey?: string;
88
- fullnodeUrls?: string[];
89
- faucetUrl?: string;
90
- networkType?: NetworkType;
91
- };
92
- export type ObjectData = {
93
- objectId: string;
94
- objectType: string;
95
- objectVersion: number;
96
- objectDigest: string;
97
- initialSharedVersion?: number;
98
- objectDisplay: DisplayFieldsResponse;
99
- objectFields: ObjectContentFields;
100
- };
101
- type TransactionBlockType = InstanceType<typeof TransactionBlock>;
102
- export type PureCallArg = {
103
- Pure: number[];
104
- };
105
- export type ObjectCallArg = {
106
- Object: ObjectArg;
107
- };
108
- export type TransactionType = Parameters<TransactionBlockType['add']>;
109
- export type TransactionPureArgument = Extract<TransactionArgument, {
110
- kind: 'Input';
111
- type: 'pure';
112
- }>;
113
- export type ObjectFieldType = {
114
- id: {
115
- id: string;
116
- };
117
- name: string;
118
- value: string;
119
- };
120
- export type EntityData = {
121
- objectId: string;
122
- index: string;
123
- key: string;
124
- };
125
- export type SuiAddressArg = TransactionArgument | SerializedBcs<any> | string | PureCallArg;
126
- export type SuiTxArg = SuiAddressArg | number | bigint | boolean;
127
- export type SuiObjectArg = TransactionObjectArgument | string | SharedObjectRef | SuiObjectRef | ObjectCallArg;
128
- export type SuiVecTxArg = {
129
- value: SuiTxArg[];
130
- vecType: SuiInputTypes;
131
- } | SuiTxArg[];
132
- /**
133
- * These are the basics types that can be used in the SUI
134
- */
135
- export type SuiBasicTypes = 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256' | 'signer';
136
- export type SuiInputTypes = 'object' | SuiBasicTypes;
137
- export type SuiReturnValues = {
138
- returnValues: [number[], string][];
139
- }[];
140
- export type DynamicFieldContentType = {
141
- type: string;
142
- fields: Record<string, any>;
143
- hasPublicTransfer: boolean;
144
- dataType: string;
145
- };
146
- export type ObjectContent = {
147
- type: string;
148
- fields: Record<string, any>;
149
- hasPublicTransfer: boolean;
150
- dataType: string;
151
- };
152
- export {};
@@ -1,3 +0,0 @@
1
- export declare function capitalizeFirstLetter(input: string): string;
2
- export declare function normalizeHexAddress(input: string): string | null;
3
- export declare function numberToAddressHex(num: number): string;