@0xobelisk/client 0.0.7 → 0.0.8
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 +27 -115
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -118
- package/dist/index.mjs.map +1 -1
- package/dist/obelisk.d.ts +60 -132
- package/dist/utils/index.d.ts +1 -0
- package/package.json +3 -3
- package/src/obelisk.ts +13 -24
- package/src/utils/index.ts +3 -0
package/dist/obelisk.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { ObjectData } from './libs/suiRpcProvider/types';
|
|
2
3
|
import { RawSigner, TransactionBlock, DevInspectResults, SuiTransactionBlockResponse, SuiMoveNormalizedModules, SuiAddress } from '@mysten/sui.js';
|
|
3
4
|
import { SuiAccountManager } from './libs/suiAccountManager';
|
|
@@ -2556,137 +2557,6 @@ export declare class Obelisk {
|
|
|
2556
2557
|
* @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.
|
|
2557
2558
|
*/
|
|
2558
2559
|
inspectTxn(tx: Uint8Array | TransactionBlock | SuiTxBlock, derivePathParams?: DerivePathParams): Promise<DevInspectResults>;
|
|
2559
|
-
getBirthTime(objectId: string, derivePathParams?: DerivePathParams): Promise<{
|
|
2560
|
-
effects: {
|
|
2561
|
-
messageVersion: "v1";
|
|
2562
|
-
status: {
|
|
2563
|
-
status: "success" | "failure";
|
|
2564
|
-
error?: string | undefined;
|
|
2565
|
-
};
|
|
2566
|
-
executedEpoch: string;
|
|
2567
|
-
gasUsed: {
|
|
2568
|
-
computationCost: string;
|
|
2569
|
-
storageCost: string;
|
|
2570
|
-
storageRebate: string;
|
|
2571
|
-
nonRefundableStorageFee: string;
|
|
2572
|
-
};
|
|
2573
|
-
transactionDigest: string;
|
|
2574
|
-
gasObject: {
|
|
2575
|
-
owner: "Immutable" | {
|
|
2576
|
-
AddressOwner: string;
|
|
2577
|
-
} | {
|
|
2578
|
-
ObjectOwner: string;
|
|
2579
|
-
} | {
|
|
2580
|
-
Shared: {
|
|
2581
|
-
initial_shared_version: number;
|
|
2582
|
-
};
|
|
2583
|
-
};
|
|
2584
|
-
reference: {
|
|
2585
|
-
objectId: string;
|
|
2586
|
-
version: string | number;
|
|
2587
|
-
digest: string;
|
|
2588
|
-
};
|
|
2589
|
-
};
|
|
2590
|
-
modifiedAtVersions?: {
|
|
2591
|
-
objectId: string;
|
|
2592
|
-
sequenceNumber: string;
|
|
2593
|
-
}[] | undefined;
|
|
2594
|
-
sharedObjects?: {
|
|
2595
|
-
objectId: string;
|
|
2596
|
-
version: string | number;
|
|
2597
|
-
digest: string;
|
|
2598
|
-
}[] | undefined;
|
|
2599
|
-
created?: {
|
|
2600
|
-
owner: "Immutable" | {
|
|
2601
|
-
AddressOwner: string;
|
|
2602
|
-
} | {
|
|
2603
|
-
ObjectOwner: string;
|
|
2604
|
-
} | {
|
|
2605
|
-
Shared: {
|
|
2606
|
-
initial_shared_version: number;
|
|
2607
|
-
};
|
|
2608
|
-
};
|
|
2609
|
-
reference: {
|
|
2610
|
-
objectId: string;
|
|
2611
|
-
version: string | number;
|
|
2612
|
-
digest: string;
|
|
2613
|
-
};
|
|
2614
|
-
}[] | undefined;
|
|
2615
|
-
mutated?: {
|
|
2616
|
-
owner: "Immutable" | {
|
|
2617
|
-
AddressOwner: string;
|
|
2618
|
-
} | {
|
|
2619
|
-
ObjectOwner: string;
|
|
2620
|
-
} | {
|
|
2621
|
-
Shared: {
|
|
2622
|
-
initial_shared_version: number;
|
|
2623
|
-
};
|
|
2624
|
-
};
|
|
2625
|
-
reference: {
|
|
2626
|
-
objectId: string;
|
|
2627
|
-
version: string | number;
|
|
2628
|
-
digest: string;
|
|
2629
|
-
};
|
|
2630
|
-
}[] | undefined;
|
|
2631
|
-
unwrapped?: {
|
|
2632
|
-
owner: "Immutable" | {
|
|
2633
|
-
AddressOwner: string;
|
|
2634
|
-
} | {
|
|
2635
|
-
ObjectOwner: string;
|
|
2636
|
-
} | {
|
|
2637
|
-
Shared: {
|
|
2638
|
-
initial_shared_version: number;
|
|
2639
|
-
};
|
|
2640
|
-
};
|
|
2641
|
-
reference: {
|
|
2642
|
-
objectId: string;
|
|
2643
|
-
version: string | number;
|
|
2644
|
-
digest: string;
|
|
2645
|
-
};
|
|
2646
|
-
}[] | undefined;
|
|
2647
|
-
deleted?: {
|
|
2648
|
-
objectId: string;
|
|
2649
|
-
version: string | number;
|
|
2650
|
-
digest: string;
|
|
2651
|
-
}[] | undefined;
|
|
2652
|
-
unwrappedThenDeleted?: {
|
|
2653
|
-
objectId: string;
|
|
2654
|
-
version: string | number;
|
|
2655
|
-
digest: string;
|
|
2656
|
-
}[] | undefined;
|
|
2657
|
-
wrapped?: {
|
|
2658
|
-
objectId: string;
|
|
2659
|
-
version: string | number;
|
|
2660
|
-
digest: string;
|
|
2661
|
-
}[] | undefined;
|
|
2662
|
-
eventsDigest?: string | undefined;
|
|
2663
|
-
dependencies?: string[] | undefined;
|
|
2664
|
-
};
|
|
2665
|
-
events: {
|
|
2666
|
-
id: {
|
|
2667
|
-
txDigest: string;
|
|
2668
|
-
eventSeq: string;
|
|
2669
|
-
};
|
|
2670
|
-
packageId: string;
|
|
2671
|
-
transactionModule: string;
|
|
2672
|
-
sender: string;
|
|
2673
|
-
type: string;
|
|
2674
|
-
parsedJson?: Record<string, any> | undefined;
|
|
2675
|
-
bcs?: string | undefined;
|
|
2676
|
-
timestampMs?: string | undefined;
|
|
2677
|
-
}[];
|
|
2678
|
-
error?: string | undefined;
|
|
2679
|
-
results?: {
|
|
2680
|
-
mutableReferenceOutputs?: ["GasCoin" | {
|
|
2681
|
-
Input: number;
|
|
2682
|
-
} | {
|
|
2683
|
-
Result: number;
|
|
2684
|
-
} | {
|
|
2685
|
-
NestedResult: [number, number];
|
|
2686
|
-
}, number[], string][] | undefined;
|
|
2687
|
-
returnValues?: [number[], string][] | undefined;
|
|
2688
|
-
}[] | undefined;
|
|
2689
|
-
}>;
|
|
2690
2560
|
getWorld(worldObjectId: string): Promise<ObjectData>;
|
|
2691
2561
|
getAllEntities(worldId: string, cursor?: string, limit?: number): Promise<{
|
|
2692
2562
|
data: {
|
|
@@ -2778,7 +2648,65 @@ export declare class Obelisk {
|
|
|
2778
2648
|
nextCursor: string | null;
|
|
2779
2649
|
hasNextPage: boolean;
|
|
2780
2650
|
}>;
|
|
2781
|
-
|
|
2651
|
+
getComponentByName(worldId: string, componentName: string): Promise<{
|
|
2652
|
+
data?: {
|
|
2653
|
+
objectId: string;
|
|
2654
|
+
version: string;
|
|
2655
|
+
digest: string;
|
|
2656
|
+
type?: string | undefined;
|
|
2657
|
+
bcs?: {
|
|
2658
|
+
type: string;
|
|
2659
|
+
version: number;
|
|
2660
|
+
hasPublicTransfer: boolean;
|
|
2661
|
+
dataType: "moveObject";
|
|
2662
|
+
bcsBytes: string;
|
|
2663
|
+
} | {
|
|
2664
|
+
id: string;
|
|
2665
|
+
dataType: "package";
|
|
2666
|
+
moduleMap: Record<string, string>;
|
|
2667
|
+
} | undefined;
|
|
2668
|
+
owner?: {
|
|
2669
|
+
AddressOwner: string;
|
|
2670
|
+
} | {
|
|
2671
|
+
ObjectOwner: string;
|
|
2672
|
+
} | {
|
|
2673
|
+
Shared: {
|
|
2674
|
+
initial_shared_version: number;
|
|
2675
|
+
};
|
|
2676
|
+
} | "Immutable" | undefined;
|
|
2677
|
+
storageRebate?: string | undefined;
|
|
2678
|
+
previousTransaction?: string | undefined;
|
|
2679
|
+
content?: {
|
|
2680
|
+
type: string;
|
|
2681
|
+
fields: Record<string, any>;
|
|
2682
|
+
hasPublicTransfer: boolean;
|
|
2683
|
+
dataType: "moveObject";
|
|
2684
|
+
} | {
|
|
2685
|
+
disassembled: Record<string, string>;
|
|
2686
|
+
dataType: "package";
|
|
2687
|
+
} | undefined;
|
|
2688
|
+
display?: Record<string, string> | {
|
|
2689
|
+
data: Record<string, string> | null;
|
|
2690
|
+
error: {
|
|
2691
|
+
code: string;
|
|
2692
|
+
version?: number | undefined;
|
|
2693
|
+
digest?: string | undefined;
|
|
2694
|
+
error?: string | undefined;
|
|
2695
|
+
object_id?: string | undefined;
|
|
2696
|
+
parent_object_id?: string | undefined;
|
|
2697
|
+
} | null;
|
|
2698
|
+
} | undefined;
|
|
2699
|
+
} | undefined;
|
|
2700
|
+
error?: {
|
|
2701
|
+
code: string;
|
|
2702
|
+
version?: number | undefined;
|
|
2703
|
+
digest?: string | undefined;
|
|
2704
|
+
error?: string | undefined;
|
|
2705
|
+
object_id?: string | undefined;
|
|
2706
|
+
parent_object_id?: string | undefined;
|
|
2707
|
+
} | undefined;
|
|
2708
|
+
}>;
|
|
2709
|
+
getComponent(worldId: string, componentId: Buffer): Promise<{
|
|
2782
2710
|
data?: {
|
|
2783
2711
|
objectId: string;
|
|
2784
2712
|
version: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function capitalizeFirstLetter(input: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xobelisk/client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Tookit for interacting with move eps framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -52,19 +52,19 @@
|
|
|
52
52
|
"lint:fix": "eslint . --ignore-pattern dist --ext .ts --fix",
|
|
53
53
|
"commit": "commit",
|
|
54
54
|
"doc": "typedoc --out docs src/index.ts",
|
|
55
|
-
|
|
56
55
|
"chalk": "^5.0.1",
|
|
57
56
|
"prettier": "^2.8.4",
|
|
58
57
|
"prettier-plugin-rust": "^0.1.9"
|
|
59
58
|
},
|
|
60
59
|
"dependencies": {
|
|
61
|
-
"@obelisk/common": "link:../common",
|
|
62
60
|
"@mysten/bcs": "^0.7.3",
|
|
63
61
|
"@mysten/sui.js": "^0.37.1",
|
|
62
|
+
"@obelisk/common": "link:../common",
|
|
64
63
|
"@scure/bip39": "^1.2.1",
|
|
65
64
|
"assert": "^2.0.0",
|
|
66
65
|
"colorts": "^0.1.63",
|
|
67
66
|
"husky": "^8.0.3",
|
|
67
|
+
"keccak256": "^1.0.6",
|
|
68
68
|
"process": "^0.11.10",
|
|
69
69
|
"superstruct": "^1.0.3",
|
|
70
70
|
"tmp": "^0.2.1",
|
package/src/obelisk.ts
CHANGED
|
@@ -20,7 +20,8 @@ import {
|
|
|
20
20
|
ContractTx, MapMoudleFuncQuery,
|
|
21
21
|
MapMoudleFuncTx
|
|
22
22
|
} from './types';
|
|
23
|
-
import {
|
|
23
|
+
import {capitalizeFirstLetter} from "./utils"
|
|
24
|
+
const keccak256 = require('keccak256');
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
export function isUndefined (value?: unknown): value is undefined {
|
|
@@ -418,25 +419,6 @@ export class Obelisk {
|
|
|
418
419
|
});
|
|
419
420
|
}
|
|
420
421
|
|
|
421
|
-
async getBirthTime(objectId: string, derivePathParams?: DerivePathParams) {
|
|
422
|
-
const tx = new TransactionBlock();
|
|
423
|
-
|
|
424
|
-
tx.moveCall({
|
|
425
|
-
// target: `0x12b216923e5454e1f076ccb5fc638b59f8aba2175c34df9899de71124d66badd::status_system::get_pet_state`,
|
|
426
|
-
target: `0x6afbf113a5872b781a2a0068b95c0d9d0ee89428518fdd65f862c841eab45b82::pet_system::get_pet_basic_info`,
|
|
427
|
-
arguments: [
|
|
428
|
-
// tx.pure("0x6fa43c68221960f942572905f3c198a5bccaa0700506b3b6bd83dd9b007e6324"),
|
|
429
|
-
// tx.pure("0xbf64721f0961a0426ccde6b8d9343e2cb2c26a105a5c33e57074580fd98b2cb1"),
|
|
430
|
-
// tx.pure("0x6"),
|
|
431
|
-
|
|
432
|
-
obj(tx, "0x26804211486be597a89c46c16b929d7031fb7c701ecf89d4c750e49459b4bea2"),
|
|
433
|
-
pure(tx, "0x35ba3bfb8590dbd060f41cd58c7b140d67efd2126648409cd231c74cff2828b8", `0x2::object::ID`),
|
|
434
|
-
obj(tx, "0x6")
|
|
435
|
-
],
|
|
436
|
-
})
|
|
437
|
-
return await this.inspectTxn(tx, derivePathParams);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
422
|
async getWorld(worldObjectId: string) {
|
|
441
423
|
return this.rpcProvider.getObject(worldObjectId)
|
|
442
424
|
}
|
|
@@ -464,13 +446,20 @@ export class Obelisk {
|
|
|
464
446
|
}
|
|
465
447
|
|
|
466
448
|
|
|
467
|
-
async
|
|
468
|
-
const
|
|
449
|
+
async getComponentByName(worldId: string, componentName: string) {
|
|
450
|
+
const componentId = keccak256(`${capitalizeFirstLetter(componentName)} Component`);
|
|
451
|
+
return await this.getComponent(worldId, componentId);
|
|
452
|
+
}
|
|
469
453
|
|
|
454
|
+
async getComponent(worldId: string, componentId: Buffer) {
|
|
455
|
+
const componentIdValue: number[] = Array.from(componentId);
|
|
456
|
+
const parentId = (await this.rpcProvider.getObject(worldId)).objectFields.components.fields.id.id;
|
|
470
457
|
console.log(parentId)
|
|
471
458
|
const name = {
|
|
472
|
-
type: "0x2::object::ID",
|
|
473
|
-
|
|
459
|
+
// type: "0x2::object::ID",
|
|
460
|
+
type: "vector<u8>",
|
|
461
|
+
value: componentIdValue
|
|
462
|
+
// value: [250,208,186,160,39,171,62,206,98,224,138,41,11,217,63,100,248,104,207,64,78,126,43,109,129,68,64,127,236,113,152,132]
|
|
474
463
|
} as DynamicFieldName
|
|
475
464
|
return await this.rpcProvider.getDynamicFieldObject(parentId, name);
|
|
476
465
|
}
|