@0xobelisk/client 0.0.6 → 0.0.7
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.js +37 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -0
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiRpcProvider/index.d.ts +66 -1
- package/dist/libs/suiTxBuilder/util.d.ts +7 -7
- package/dist/obelisk.d.ts +138 -4
- package/package.json +7 -2
- package/src/libs/suiRpcProvider/index.ts +6 -1
- package/src/obelisk.ts +47 -1
package/dist/obelisk.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ObjectData } from './libs/suiRpcProvider/types';
|
|
2
|
+
import { RawSigner, TransactionBlock, DevInspectResults, SuiTransactionBlockResponse, SuiMoveNormalizedModules, SuiAddress } from '@mysten/sui.js';
|
|
2
3
|
import { SuiAccountManager } from './libs/suiAccountManager';
|
|
3
4
|
import { SuiRpcProvider } from './libs/suiRpcProvider';
|
|
4
5
|
import { SuiTxBlock } from './libs/suiTxBuilder';
|
|
@@ -105,8 +106,8 @@ export declare class Obelisk {
|
|
|
105
106
|
epochId?: number | undefined;
|
|
106
107
|
};
|
|
107
108
|
}>;
|
|
108
|
-
getObject(objectId: string): Promise<
|
|
109
|
-
getObjects(objectIds: string[]): Promise<
|
|
109
|
+
getObject(objectId: string): Promise<ObjectData>;
|
|
110
|
+
getObjects(objectIds: string[]): Promise<ObjectData[]>;
|
|
110
111
|
signTxn(tx: Uint8Array | TransactionBlock | SuiTxBlock, derivePathParams?: DerivePathParams): Promise<import("@mysten/sui.js").SignedTransaction>;
|
|
111
112
|
signAndSendTxn(tx: Uint8Array | TransactionBlock | SuiTxBlock, derivePathParams?: DerivePathParams): Promise<SuiTransactionBlockResponse>;
|
|
112
113
|
/**
|
|
@@ -2686,7 +2687,7 @@ export declare class Obelisk {
|
|
|
2686
2687
|
returnValues?: [number[], string][] | undefined;
|
|
2687
2688
|
}[] | undefined;
|
|
2688
2689
|
}>;
|
|
2689
|
-
getWorld(worldObjectId: string): Promise<
|
|
2690
|
+
getWorld(worldObjectId: string): Promise<ObjectData>;
|
|
2690
2691
|
getAllEntities(worldId: string, cursor?: string, limit?: number): Promise<{
|
|
2691
2692
|
data: {
|
|
2692
2693
|
type: "DynamicField" | "DynamicObject";
|
|
@@ -2761,6 +2762,139 @@ export declare class Obelisk {
|
|
|
2761
2762
|
parent_object_id?: string | undefined;
|
|
2762
2763
|
} | undefined;
|
|
2763
2764
|
}>;
|
|
2765
|
+
getComponents(worldId: string): Promise<{
|
|
2766
|
+
data: {
|
|
2767
|
+
type: "DynamicField" | "DynamicObject";
|
|
2768
|
+
objectType: string;
|
|
2769
|
+
objectId: string;
|
|
2770
|
+
version: number;
|
|
2771
|
+
digest: string;
|
|
2772
|
+
name: {
|
|
2773
|
+
type: string;
|
|
2774
|
+
value?: any;
|
|
2775
|
+
};
|
|
2776
|
+
bcsName: string;
|
|
2777
|
+
}[];
|
|
2778
|
+
nextCursor: string | null;
|
|
2779
|
+
hasNextPage: boolean;
|
|
2780
|
+
}>;
|
|
2781
|
+
getComponent(worldId: string, componentId: string): Promise<{
|
|
2782
|
+
data?: {
|
|
2783
|
+
objectId: string;
|
|
2784
|
+
version: string;
|
|
2785
|
+
digest: string;
|
|
2786
|
+
type?: string | undefined;
|
|
2787
|
+
bcs?: {
|
|
2788
|
+
type: string;
|
|
2789
|
+
version: number;
|
|
2790
|
+
hasPublicTransfer: boolean;
|
|
2791
|
+
dataType: "moveObject";
|
|
2792
|
+
bcsBytes: string;
|
|
2793
|
+
} | {
|
|
2794
|
+
id: string;
|
|
2795
|
+
dataType: "package";
|
|
2796
|
+
moduleMap: Record<string, string>;
|
|
2797
|
+
} | undefined;
|
|
2798
|
+
owner?: {
|
|
2799
|
+
AddressOwner: string;
|
|
2800
|
+
} | {
|
|
2801
|
+
ObjectOwner: string;
|
|
2802
|
+
} | {
|
|
2803
|
+
Shared: {
|
|
2804
|
+
initial_shared_version: number;
|
|
2805
|
+
};
|
|
2806
|
+
} | "Immutable" | undefined;
|
|
2807
|
+
storageRebate?: string | undefined;
|
|
2808
|
+
previousTransaction?: string | undefined;
|
|
2809
|
+
content?: {
|
|
2810
|
+
type: string;
|
|
2811
|
+
fields: Record<string, any>;
|
|
2812
|
+
hasPublicTransfer: boolean;
|
|
2813
|
+
dataType: "moveObject";
|
|
2814
|
+
} | {
|
|
2815
|
+
disassembled: Record<string, string>;
|
|
2816
|
+
dataType: "package";
|
|
2817
|
+
} | undefined;
|
|
2818
|
+
display?: Record<string, string> | {
|
|
2819
|
+
data: Record<string, string> | null;
|
|
2820
|
+
error: {
|
|
2821
|
+
code: string;
|
|
2822
|
+
version?: number | undefined;
|
|
2823
|
+
digest?: string | undefined;
|
|
2824
|
+
error?: string | undefined;
|
|
2825
|
+
object_id?: string | undefined;
|
|
2826
|
+
parent_object_id?: string | undefined;
|
|
2827
|
+
} | null;
|
|
2828
|
+
} | undefined;
|
|
2829
|
+
} | undefined;
|
|
2830
|
+
error?: {
|
|
2831
|
+
code: string;
|
|
2832
|
+
version?: number | undefined;
|
|
2833
|
+
digest?: string | undefined;
|
|
2834
|
+
error?: string | undefined;
|
|
2835
|
+
object_id?: string | undefined;
|
|
2836
|
+
parent_object_id?: string | undefined;
|
|
2837
|
+
} | undefined;
|
|
2838
|
+
}>;
|
|
2839
|
+
getOwnedEntities(owner: SuiAddress, cursor?: string, limit?: number): Promise<ObjectData[]>;
|
|
2840
|
+
getTable(worldId: string, entityId: string): Promise<{
|
|
2841
|
+
data?: {
|
|
2842
|
+
objectId: string;
|
|
2843
|
+
version: string;
|
|
2844
|
+
digest: string;
|
|
2845
|
+
type?: string | undefined;
|
|
2846
|
+
bcs?: {
|
|
2847
|
+
type: string;
|
|
2848
|
+
version: number;
|
|
2849
|
+
hasPublicTransfer: boolean;
|
|
2850
|
+
dataType: "moveObject";
|
|
2851
|
+
bcsBytes: string;
|
|
2852
|
+
} | {
|
|
2853
|
+
id: string;
|
|
2854
|
+
dataType: "package";
|
|
2855
|
+
moduleMap: Record<string, string>;
|
|
2856
|
+
} | undefined;
|
|
2857
|
+
owner?: {
|
|
2858
|
+
AddressOwner: string;
|
|
2859
|
+
} | {
|
|
2860
|
+
ObjectOwner: string;
|
|
2861
|
+
} | {
|
|
2862
|
+
Shared: {
|
|
2863
|
+
initial_shared_version: number;
|
|
2864
|
+
};
|
|
2865
|
+
} | "Immutable" | undefined;
|
|
2866
|
+
storageRebate?: string | undefined;
|
|
2867
|
+
previousTransaction?: string | undefined;
|
|
2868
|
+
content?: {
|
|
2869
|
+
type: string;
|
|
2870
|
+
fields: Record<string, any>;
|
|
2871
|
+
hasPublicTransfer: boolean;
|
|
2872
|
+
dataType: "moveObject";
|
|
2873
|
+
} | {
|
|
2874
|
+
disassembled: Record<string, string>;
|
|
2875
|
+
dataType: "package";
|
|
2876
|
+
} | undefined;
|
|
2877
|
+
display?: Record<string, string> | {
|
|
2878
|
+
data: Record<string, string> | null;
|
|
2879
|
+
error: {
|
|
2880
|
+
code: string;
|
|
2881
|
+
version?: number | undefined;
|
|
2882
|
+
digest?: string | undefined;
|
|
2883
|
+
error?: string | undefined;
|
|
2884
|
+
object_id?: string | undefined;
|
|
2885
|
+
parent_object_id?: string | undefined;
|
|
2886
|
+
} | null;
|
|
2887
|
+
} | undefined;
|
|
2888
|
+
} | undefined;
|
|
2889
|
+
error?: {
|
|
2890
|
+
code: string;
|
|
2891
|
+
version?: number | undefined;
|
|
2892
|
+
digest?: string | undefined;
|
|
2893
|
+
error?: string | undefined;
|
|
2894
|
+
object_id?: string | undefined;
|
|
2895
|
+
parent_object_id?: string | undefined;
|
|
2896
|
+
} | undefined;
|
|
2897
|
+
}>;
|
|
2764
2898
|
getEntityComponents(worldId: string, entityId: string, cursor?: string, limit?: number): Promise<{
|
|
2765
2899
|
data: {
|
|
2766
2900
|
type: "DynamicField" | "DynamicObject";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xobelisk/client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Tookit for interacting with move eps framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -51,9 +51,14 @@
|
|
|
51
51
|
"format:fix": "prettier --ignore-path 'dist/* docs/*' --write '**/*.{ts,json,md}'",
|
|
52
52
|
"lint:fix": "eslint . --ignore-pattern dist --ext .ts --fix",
|
|
53
53
|
"commit": "commit",
|
|
54
|
-
"doc": "typedoc --out docs src/index.ts"
|
|
54
|
+
"doc": "typedoc --out docs src/index.ts",
|
|
55
|
+
|
|
56
|
+
"chalk": "^5.0.1",
|
|
57
|
+
"prettier": "^2.8.4",
|
|
58
|
+
"prettier-plugin-rust": "^0.1.9"
|
|
55
59
|
},
|
|
56
60
|
"dependencies": {
|
|
61
|
+
"@obelisk/common": "link:../common",
|
|
57
62
|
"@mysten/bcs": "^0.7.3",
|
|
58
63
|
"@mysten/sui.js": "^0.37.1",
|
|
59
64
|
"@scure/bip39": "^1.2.1",
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
getObjectFields,
|
|
7
7
|
getObjectDisplay,
|
|
8
8
|
getObjectVersion,
|
|
9
|
-
DynamicFieldName
|
|
9
|
+
DynamicFieldName,
|
|
10
|
+
SuiAddress
|
|
10
11
|
} from '@mysten/sui.js';
|
|
11
12
|
import { requestFaucet } from './faucet';
|
|
12
13
|
import { getDefaultNetworkParams } from './defaultChainConfigs';
|
|
@@ -64,6 +65,10 @@ export class SuiRpcProvider {
|
|
|
64
65
|
return this.provider.getDynamicFields({ parentId, cursor, limit })
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
async getOwnedObjects(owner: SuiAddress, cursor?: string, limit?: number) {
|
|
69
|
+
return await this.provider.getOwnedObjects({ owner, cursor, limit });
|
|
70
|
+
}
|
|
71
|
+
|
|
67
72
|
async getObject(id: string) {
|
|
68
73
|
const options = { showContent: true, showDisplay: true, showType: true };
|
|
69
74
|
const object = await this.provider.getObject({ id, options });
|
package/src/obelisk.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { ObjectData } from './libs/suiRpcProvider/types';
|
|
1
2
|
import {
|
|
2
3
|
RawSigner,
|
|
3
4
|
TransactionBlock,
|
|
4
5
|
DevInspectResults,
|
|
5
6
|
SuiTransactionBlockResponse,
|
|
6
|
-
SuiMoveNormalizedModules, DynamicFieldPage, DynamicFieldName,
|
|
7
|
+
SuiMoveNormalizedModules, DynamicFieldPage, DynamicFieldName, SuiAddress,
|
|
7
8
|
} from '@mysten/sui.js';
|
|
8
9
|
import { SuiAccountManager } from './libs/suiAccountManager';
|
|
9
10
|
import { SuiRpcProvider } from './libs/suiRpcProvider';
|
|
@@ -448,6 +449,51 @@ export class Obelisk {
|
|
|
448
449
|
async getEntity(worldId: string, entityId: string) {
|
|
449
450
|
const parentId = (await this.rpcProvider.getObject(worldId)).objectFields.entities.fields.id.id;
|
|
450
451
|
|
|
452
|
+
console.log(parentId)
|
|
453
|
+
const name = {
|
|
454
|
+
type: "0x2::object::ID",
|
|
455
|
+
value: entityId
|
|
456
|
+
} as DynamicFieldName
|
|
457
|
+
return await this.rpcProvider.getDynamicFieldObject(parentId, name);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
async getComponents(worldId: string) {
|
|
461
|
+
const parentId = (await this.rpcProvider.getObject(worldId)).objectFields.components.fields.id.id;
|
|
462
|
+
|
|
463
|
+
return await this.rpcProvider.getDynamicFields(parentId);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
async getComponent(worldId: string, componentId: string) {
|
|
468
|
+
const parentId = (await this.rpcProvider.getObject(worldId)).objectFields.components.fields.id.id;
|
|
469
|
+
|
|
470
|
+
console.log(parentId)
|
|
471
|
+
const name = {
|
|
472
|
+
type: "0x2::object::ID",
|
|
473
|
+
value: componentId
|
|
474
|
+
} as DynamicFieldName
|
|
475
|
+
return await this.rpcProvider.getDynamicFieldObject(parentId, name);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
async getOwnedEntities(owner: SuiAddress, cursor?: string, limit?: number) {
|
|
479
|
+
const ownedObjects = await this.rpcProvider.getOwnedObjects(owner, cursor, limit)
|
|
480
|
+
let ownedEntities: ObjectData[] = [];
|
|
481
|
+
|
|
482
|
+
for (const object of ownedObjects.data) {
|
|
483
|
+
let objectDetail = await this.getObject(object.data!.objectId);
|
|
484
|
+
|
|
485
|
+
if (objectDetail.objectType.split("::")[0] === this.contractFactory.packageId) {
|
|
486
|
+
ownedEntities.push(objectDetail);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
return ownedEntities;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
async getTable(worldId: string, entityId: string) {
|
|
494
|
+
const parentId = (await this.rpcProvider.getObject(worldId)).objectFields.storages.fields.id.id;
|
|
495
|
+
|
|
496
|
+
console.log(parentId)
|
|
451
497
|
const name = {
|
|
452
498
|
type: "0x2::object::ID",
|
|
453
499
|
value: entityId
|