@0xobelisk/client 0.3.0 → 0.3.2
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.d.ts +9 -0
- package/dist/index.js +68 -108
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -108
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiAccountManager/index.d.ts +35 -0
- package/dist/libs/suiAccountManager/keypair.d.ts +21 -0
- package/dist/libs/suiInteractor/defaultConfig.d.ts +10 -0
- package/dist/libs/suiInteractor/index.d.ts +2 -0
- package/dist/libs/suiInteractor/suiInteractor.d.ts +205 -0
- package/dist/libs/suiTxBuilder/index.d.ts +544 -0
- package/dist/libs/suiTxBuilder/util.d.ts +76 -0
- package/dist/metadata/index.d.ts +34 -0
- package/dist/obelisk.d.ts +2566 -0
- package/dist/types/index.d.ts +141 -0
- package/package.json +1 -1
- package/src/obelisk.ts +92 -151
- package/src/types/index.ts +13 -6
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Infer } from 'superstruct';
|
|
2
|
+
import { DisplayFieldsResponse, ObjectCallArg, ObjectContentFields, SharedObjectRef, SuiObjectRef, TransactionArgument, TransactionBlock, SuiTransactionBlockResponse, DevInspectResults, SuiMoveNormalizedModules } from '@mysten/sui.js';
|
|
3
|
+
import { SuiMoveMoudleFuncType } from '../libs/suiContractFactory/types';
|
|
4
|
+
export type ObeliskObjectData = {
|
|
5
|
+
objectId: string;
|
|
6
|
+
objectType: string;
|
|
7
|
+
objectVersion: number;
|
|
8
|
+
objectDisplay: DisplayFieldsResponse;
|
|
9
|
+
objectFields: ObjectContentFields;
|
|
10
|
+
};
|
|
11
|
+
export type ObeliskParams = {
|
|
12
|
+
mnemonics?: string;
|
|
13
|
+
secretKey?: string;
|
|
14
|
+
fullnodeUrls?: string[];
|
|
15
|
+
faucetUrl?: string;
|
|
16
|
+
networkType?: NetworkType;
|
|
17
|
+
packageId?: string;
|
|
18
|
+
metadata?: SuiMoveNormalizedModules;
|
|
19
|
+
};
|
|
20
|
+
export type SchemaFieldType = {
|
|
21
|
+
schemas: {
|
|
22
|
+
type: string;
|
|
23
|
+
fields: {
|
|
24
|
+
id: {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
size: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type SchemaValueType = {
|
|
32
|
+
id: {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
name: string;
|
|
36
|
+
value: {
|
|
37
|
+
type: string;
|
|
38
|
+
fields: SchemaFieldType;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type SuiTxArgument = {
|
|
42
|
+
kind: 'Input';
|
|
43
|
+
index: number;
|
|
44
|
+
type?: 'object' | 'pure' | undefined;
|
|
45
|
+
value?: any;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'GasCoin';
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'Result';
|
|
50
|
+
index: number;
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'NestedResult';
|
|
53
|
+
index: number;
|
|
54
|
+
resultIndex: number;
|
|
55
|
+
};
|
|
56
|
+
export type SchemaContentType = {
|
|
57
|
+
type: string;
|
|
58
|
+
fields: SchemaValueType;
|
|
59
|
+
hasPublicTransfer: boolean;
|
|
60
|
+
dataType: 'moveObject';
|
|
61
|
+
};
|
|
62
|
+
export interface MessageMeta {
|
|
63
|
+
readonly meta: SuiMoveMoudleFuncType;
|
|
64
|
+
}
|
|
65
|
+
export interface ContractQuery extends MessageMeta {
|
|
66
|
+
(tx: TransactionBlock, params: SuiTxArgument[], isRaw?: boolean): Promise<DevInspectResults | TransactionBlock>;
|
|
67
|
+
}
|
|
68
|
+
export interface ContractTx extends MessageMeta {
|
|
69
|
+
(tx: TransactionBlock, params: SuiTxArgument[], isRaw?: boolean): SuiTransactionBlockResponse | TransactionBlock;
|
|
70
|
+
}
|
|
71
|
+
export type MapMessageTx = Record<string, ContractTx>;
|
|
72
|
+
export type MapMessageQuery = Record<string, ContractQuery>;
|
|
73
|
+
export type MapMoudleFuncTx = Record<string, MapMessageTx>;
|
|
74
|
+
export type MapMoudleFuncQuery = Record<string, MapMessageQuery>;
|
|
75
|
+
export type MapMoudleFuncTest = Record<string, Record<string, string>>;
|
|
76
|
+
export type MapMoudleFuncQueryTest = Record<string, Record<string, string>>;
|
|
77
|
+
export type AccountMangerParams = {
|
|
78
|
+
mnemonics?: string;
|
|
79
|
+
secretKey?: string;
|
|
80
|
+
};
|
|
81
|
+
export type DerivePathParams = {
|
|
82
|
+
accountIndex?: number;
|
|
83
|
+
isExternal?: boolean;
|
|
84
|
+
addressIndex?: number;
|
|
85
|
+
};
|
|
86
|
+
export type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
|
|
87
|
+
export type FaucetNetworkType = 'testnet' | 'devnet' | 'localnet';
|
|
88
|
+
export type SuiKitParams = {
|
|
89
|
+
mnemonics?: string;
|
|
90
|
+
secretKey?: string;
|
|
91
|
+
fullnodeUrls?: string[];
|
|
92
|
+
faucetUrl?: string;
|
|
93
|
+
networkType?: NetworkType;
|
|
94
|
+
};
|
|
95
|
+
export type ObjectData = {
|
|
96
|
+
objectId: string;
|
|
97
|
+
objectType: string;
|
|
98
|
+
objectVersion: number;
|
|
99
|
+
objectDigest: string;
|
|
100
|
+
initialSharedVersion?: number;
|
|
101
|
+
objectDisplay: DisplayFieldsResponse;
|
|
102
|
+
objectFields: ObjectContentFields;
|
|
103
|
+
};
|
|
104
|
+
export type ObjectFieldType = {
|
|
105
|
+
id: {
|
|
106
|
+
id: string;
|
|
107
|
+
};
|
|
108
|
+
name: string;
|
|
109
|
+
value: string;
|
|
110
|
+
};
|
|
111
|
+
export type EntityData = {
|
|
112
|
+
objectId: string;
|
|
113
|
+
index: string;
|
|
114
|
+
key: string;
|
|
115
|
+
};
|
|
116
|
+
export type SuiTxArg = Infer<typeof TransactionArgument> | Infer<typeof ObjectCallArg> | string | number | bigint | boolean;
|
|
117
|
+
export type SuiObjectArg = SharedObjectRef | Infer<typeof SuiObjectRef> | string | Infer<typeof ObjectCallArg> | Infer<typeof TransactionArgument>;
|
|
118
|
+
export type SuiVecTxArg = {
|
|
119
|
+
value: SuiTxArg[];
|
|
120
|
+
vecType: SuiInputTypes;
|
|
121
|
+
} | SuiTxArg[];
|
|
122
|
+
/**
|
|
123
|
+
* These are the basics types that can be used in the SUI
|
|
124
|
+
*/
|
|
125
|
+
export type SuiBasicTypes = 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256';
|
|
126
|
+
export type SuiInputTypes = 'object' | SuiBasicTypes;
|
|
127
|
+
export type SuiReturnValues = {
|
|
128
|
+
returnValues: [number[], string][];
|
|
129
|
+
}[];
|
|
130
|
+
export type DynamicFieldContentType = {
|
|
131
|
+
type: string;
|
|
132
|
+
fields: Record<string, any>;
|
|
133
|
+
hasPublicTransfer: boolean;
|
|
134
|
+
dataType: string;
|
|
135
|
+
};
|
|
136
|
+
export type ObjectContent = {
|
|
137
|
+
type: string;
|
|
138
|
+
fields: Record<string, any>;
|
|
139
|
+
hasPublicTransfer: boolean;
|
|
140
|
+
dataType: string;
|
|
141
|
+
};
|
package/package.json
CHANGED
package/src/obelisk.ts
CHANGED
|
@@ -1,45 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
RawSigner,
|
|
3
|
-
TransactionBlock,
|
|
4
2
|
DevInspectResults,
|
|
5
|
-
|
|
6
|
-
SuiMoveNormalizedModules,
|
|
7
|
-
DynamicFieldName,
|
|
3
|
+
RawSigner,
|
|
8
4
|
SuiAddress,
|
|
5
|
+
SuiMoveNormalizedModules,
|
|
6
|
+
SuiTransactionBlockResponse,
|
|
7
|
+
TransactionBlock,
|
|
9
8
|
} from '@mysten/sui.js';
|
|
10
9
|
import { SuiAccountManager } from './libs/suiAccountManager';
|
|
11
10
|
import { SuiTxBlock } from './libs/suiTxBuilder';
|
|
12
|
-
import {
|
|
13
|
-
import { SuiSharedObject, SuiOwnedObject } from './libs/suiModel';
|
|
11
|
+
import { getDefaultConnection, SuiInteractor } from './libs/suiInteractor';
|
|
14
12
|
|
|
15
13
|
import { ObeliskObjectData } from 'src/types';
|
|
16
14
|
import { SuiContractFactory } from './libs/suiContractFactory';
|
|
17
15
|
import {
|
|
18
|
-
SuiMoveMoudleValueType,
|
|
19
16
|
SuiMoveMoudleFuncType,
|
|
17
|
+
SuiMoveMoudleValueType,
|
|
20
18
|
} from './libs/suiContractFactory/types';
|
|
21
19
|
import {
|
|
22
|
-
ObeliskParams,
|
|
23
|
-
DerivePathParams,
|
|
24
|
-
SuiTxArg,
|
|
25
|
-
SuiVecTxArg,
|
|
26
|
-
ComponentContentType,
|
|
27
|
-
SuiTxArgument,
|
|
28
20
|
ContractQuery,
|
|
29
21
|
ContractTx,
|
|
22
|
+
DerivePathParams,
|
|
23
|
+
FaucetNetworkType,
|
|
30
24
|
MapMoudleFuncQuery,
|
|
31
25
|
MapMoudleFuncTx,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
ObeliskParams,
|
|
27
|
+
SuiTxArg,
|
|
28
|
+
SuiTxArgument,
|
|
29
|
+
SuiVecTxArg,
|
|
35
30
|
} from './types';
|
|
36
|
-
import {
|
|
37
|
-
capitalizeFirstLetter,
|
|
38
|
-
normalizeHexAddress,
|
|
39
|
-
numberToAddressHex,
|
|
40
|
-
} from './utils';
|
|
31
|
+
import { normalizeHexAddress, numberToAddressHex } from './utils';
|
|
41
32
|
import keccak256 from 'keccak256';
|
|
42
|
-
import { BCS, getSuiMoveConfig
|
|
33
|
+
import { BCS, getSuiMoveConfig } from '@mysten/bcs';
|
|
43
34
|
|
|
44
35
|
export function isUndefined(value?: unknown): value is undefined {
|
|
45
36
|
return value === undefined;
|
|
@@ -139,10 +130,10 @@ export class Obelisk {
|
|
|
139
130
|
if (metadata !== undefined) {
|
|
140
131
|
this.metadata = metadata as SuiMoveNormalizedModules;
|
|
141
132
|
Object.values(metadata as SuiMoveNormalizedModules).forEach((value) => {
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
const data = value as SuiMoveMoudleValueType;
|
|
134
|
+
const moduleName = data.name;
|
|
144
135
|
Object.entries(data.exposedFunctions).forEach(([funcName, value]) => {
|
|
145
|
-
|
|
136
|
+
const meta = value as SuiMoveMoudleFuncType;
|
|
146
137
|
meta.moudleName = moduleName;
|
|
147
138
|
meta.funcName = funcName;
|
|
148
139
|
|
|
@@ -454,155 +445,105 @@ export class Obelisk {
|
|
|
454
445
|
return this.suiInteractor.getObject(worldObjectId);
|
|
455
446
|
}
|
|
456
447
|
|
|
457
|
-
async
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
return await this.suiInteractor.getDynamicFields(parentId, cursor, limit);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
async getComponentByName(worldId: string, componentName: string) {
|
|
465
|
-
const componentNameId = `${componentName}`;
|
|
466
|
-
const componentId = keccak256(componentNameId);
|
|
467
|
-
return await this.getComponent(worldId, componentId);
|
|
448
|
+
async listSchemaNames(worldId: string) {
|
|
449
|
+
const worldObject = await this.getObject(worldId);
|
|
450
|
+
const newObjectContent = worldObject.objectFields;
|
|
451
|
+
return newObjectContent['schemaNames'];
|
|
468
452
|
}
|
|
469
453
|
|
|
470
|
-
async
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
value: componentIdValue,
|
|
477
|
-
} as DynamicFieldName;
|
|
478
|
-
return await this.suiInteractor.getDynamicFieldObject(parentId, name);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
async getComponentTable(worldId: string, componentName: string) {
|
|
482
|
-
let componentMoudleName = `${componentName}_comp`;
|
|
454
|
+
async getEntity(
|
|
455
|
+
worldId: string,
|
|
456
|
+
schemaName: string,
|
|
457
|
+
entityId?: string
|
|
458
|
+
): Promise<any[] | undefined> {
|
|
459
|
+
const schemaMoudleName = `${schemaName}_schema`;
|
|
483
460
|
const tx = new TransactionBlock();
|
|
484
|
-
|
|
461
|
+
const params = [tx.pure(worldId)] as SuiTxArgument[];
|
|
462
|
+
if (entityId !== undefined) {
|
|
463
|
+
params.push(tx.pure(entityId));
|
|
464
|
+
}
|
|
485
465
|
|
|
486
|
-
const
|
|
466
|
+
const getResult = (await this.query[schemaMoudleName].get(
|
|
487
467
|
tx,
|
|
488
468
|
params
|
|
489
469
|
)) as DevInspectResults;
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
470
|
+
const returnValue = [];
|
|
471
|
+
|
|
472
|
+
// "success" | "failure";
|
|
473
|
+
if (getResult.effects.status.status === 'success') {
|
|
474
|
+
const resultList = getResult.results![0].returnValues!;
|
|
475
|
+
for (const res of resultList) {
|
|
476
|
+
const bcs = new BCS(getSuiMoveConfig());
|
|
477
|
+
const value = Uint8Array.from(res[0]);
|
|
478
|
+
const data = bcs.de(res[1], value);
|
|
479
|
+
returnValue.push(data);
|
|
480
|
+
}
|
|
481
|
+
return returnValue;
|
|
482
|
+
} else {
|
|
483
|
+
return undefined;
|
|
484
|
+
}
|
|
496
485
|
}
|
|
497
486
|
|
|
498
|
-
async
|
|
487
|
+
async containEntity(
|
|
499
488
|
worldId: string,
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
let componentMoudleName = `${componentName}_comp`;
|
|
505
|
-
|
|
489
|
+
schemaName: string,
|
|
490
|
+
entityId?: string
|
|
491
|
+
): Promise<boolean | undefined> {
|
|
492
|
+
const schemaMoudleName = `${schemaName}_schema`;
|
|
506
493
|
const tx = new TransactionBlock();
|
|
507
|
-
|
|
494
|
+
const params = [tx.pure(worldId)] as SuiTxArgument[];
|
|
495
|
+
if (entityId !== undefined) {
|
|
496
|
+
params.push(tx.pure(entityId));
|
|
497
|
+
}
|
|
508
498
|
|
|
509
|
-
const
|
|
499
|
+
const getResult = (await this.query[schemaMoudleName].contains(
|
|
510
500
|
tx,
|
|
511
501
|
params
|
|
512
502
|
)) as DevInspectResults;
|
|
513
|
-
const entities = tableResult.results as SuiReturnValues;
|
|
514
|
-
const bcs = new BCS(getSuiMoveConfig());
|
|
515
|
-
|
|
516
|
-
let value = Uint8Array.from(entities[0].returnValues[0][0]);
|
|
517
|
-
let tableId = '0x' + bcs.de('address', value);
|
|
518
|
-
let dynamicFields = await this.suiInteractor.getDynamicFields(
|
|
519
|
-
tableId,
|
|
520
|
-
cursor,
|
|
521
|
-
limit
|
|
522
|
-
);
|
|
523
|
-
let objectIds = dynamicFields.data.map((field) => field.objectId);
|
|
524
|
-
let objectDatas = await this.suiInteractor.getEntitiesObjects(objectIds);
|
|
525
|
-
return {
|
|
526
|
-
data: objectDatas,
|
|
527
|
-
nextCursor: dynamicFields.nextCursor,
|
|
528
|
-
hasNextPage: dynamicFields.hasNextPage,
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
async getEntity(worldId: string, componentName: string, entityId: string) {
|
|
533
|
-
let checkWorldId = normalizeHexAddress(worldId);
|
|
534
|
-
if (checkWorldId) {
|
|
535
|
-
worldId = checkWorldId;
|
|
536
|
-
} else {
|
|
537
|
-
return undefined;
|
|
538
|
-
}
|
|
539
503
|
|
|
540
|
-
|
|
541
|
-
if (
|
|
542
|
-
|
|
504
|
+
// "success" | "failure";
|
|
505
|
+
if (getResult.effects.status.status === 'success') {
|
|
506
|
+
const res = getResult.results![0].returnValues![0];
|
|
507
|
+
const bcs = new BCS(getSuiMoveConfig());
|
|
508
|
+
const value = Uint8Array.from(res[0]);
|
|
509
|
+
return bcs.de(res[1], value);
|
|
543
510
|
} else {
|
|
544
511
|
return undefined;
|
|
545
512
|
}
|
|
546
|
-
|
|
547
|
-
const parentId = await this.getComponentTable(worldId, componentName);
|
|
548
|
-
const name = {
|
|
549
|
-
type: 'address',
|
|
550
|
-
value: entityId,
|
|
551
|
-
} as DynamicFieldName;
|
|
552
|
-
|
|
553
|
-
let dynamicFieldObject = await this.suiInteractor.getDynamicFieldObject(
|
|
554
|
-
parentId,
|
|
555
|
-
name
|
|
556
|
-
);
|
|
557
|
-
return dynamicFieldObject;
|
|
558
513
|
}
|
|
559
514
|
|
|
560
|
-
// async
|
|
515
|
+
// async getEntities(
|
|
561
516
|
// worldId: string,
|
|
562
|
-
//
|
|
563
|
-
//
|
|
517
|
+
// schemaName: string,
|
|
518
|
+
// cursor?: string,
|
|
519
|
+
// limit?: number
|
|
564
520
|
// ) {
|
|
565
|
-
//
|
|
566
|
-
// const name = {
|
|
567
|
-
// type: 'address',
|
|
568
|
-
// value: entityId,
|
|
569
|
-
// } as DynamicFieldName;
|
|
570
|
-
|
|
571
|
-
// let dynamicFieldObject = await this.suiInteractor.getDynamicFieldObject(
|
|
572
|
-
// parentId,
|
|
573
|
-
// name
|
|
574
|
-
// );
|
|
575
|
-
// let componentMoudleName = `${componentName}_comp`;
|
|
521
|
+
// let schemaMoudleName = `${schemaName}_schema`;
|
|
576
522
|
|
|
577
523
|
// const tx = new TransactionBlock();
|
|
578
|
-
// let params = [] as SuiTxArgument[];
|
|
524
|
+
// let params = [tx.pure(worldId)] as SuiTxArgument[];
|
|
579
525
|
|
|
580
|
-
// const
|
|
526
|
+
// const tableResult = (await this.query[schemaonentMoudleName].entities(
|
|
581
527
|
// tx,
|
|
582
528
|
// params
|
|
583
529
|
// )) as DevInspectResults;
|
|
584
|
-
//
|
|
585
|
-
// console.log(typeReturn[0].returnValues[0][0]);
|
|
586
|
-
|
|
587
|
-
// const typeBCS = new BCS(getSuiMoveConfig());
|
|
588
|
-
// let typeValue = Uint8Array.from(typeReturn[0].returnValues[0][0]);
|
|
589
|
-
|
|
590
|
-
// let typeData = typeBCS.de('vector<vector<u8>>', typeValue);
|
|
591
|
-
// console.log(typeData);
|
|
592
|
-
// const entityType = String.fromCharCode(...typeData[0]);
|
|
593
|
-
|
|
594
|
-
// let dynamicFieldContent = dynamicFieldObject.data!
|
|
595
|
-
// .content as DynamicFieldContentType;
|
|
596
|
-
|
|
597
|
-
// let entityValue = dynamicFieldContent.fields['value'];
|
|
530
|
+
// const entities = tableResult.results as SuiReturnValues;
|
|
598
531
|
// const bcs = new BCS(getSuiMoveConfig());
|
|
599
|
-
// let value = Uint8Array.from(entityValue);
|
|
600
|
-
// console.log(entityType);
|
|
601
|
-
// console.log(value);
|
|
602
532
|
|
|
603
|
-
// let
|
|
604
|
-
//
|
|
605
|
-
//
|
|
533
|
+
// let value = Uint8Array.from(entities[0].returnValues[0][0]);
|
|
534
|
+
// let tableId = '0x' + bcs.de('address', value);
|
|
535
|
+
// let dynamicFields = await this.suiInteractor.getDynamicFields(
|
|
536
|
+
// tableId,
|
|
537
|
+
// cursor,
|
|
538
|
+
// limit
|
|
539
|
+
// );
|
|
540
|
+
// let objectIds = dynamicFields.data.map((field) => field.objectId);
|
|
541
|
+
// let objectDatas = await this.suiInteractor.getEntitiesObjects(objectIds);
|
|
542
|
+
// return {
|
|
543
|
+
// data: objectDatas,
|
|
544
|
+
// nextCursor: dynamicFields.nextCursor,
|
|
545
|
+
// hasNextPage: dynamicFields.hasNextPage,
|
|
546
|
+
// };
|
|
606
547
|
// }
|
|
607
548
|
|
|
608
549
|
async getOwnedObjects(owner: SuiAddress, cursor?: string, limit?: number) {
|
|
@@ -611,10 +552,10 @@ export class Obelisk {
|
|
|
611
552
|
cursor,
|
|
612
553
|
limit
|
|
613
554
|
);
|
|
614
|
-
|
|
555
|
+
const ownedObjectsRes: ObeliskObjectData[] = [];
|
|
615
556
|
|
|
616
557
|
for (const object of ownedObjects.data) {
|
|
617
|
-
|
|
558
|
+
const objectDetail = await this.getObject(object.data!.objectId);
|
|
618
559
|
|
|
619
560
|
if (
|
|
620
561
|
objectDetail.objectType.split('::')[0] ===
|
|
@@ -628,7 +569,7 @@ export class Obelisk {
|
|
|
628
569
|
}
|
|
629
570
|
|
|
630
571
|
async entity_key_from_object(objectId: string) {
|
|
631
|
-
|
|
572
|
+
const checkObjectId = normalizeHexAddress(objectId);
|
|
632
573
|
if (checkObjectId !== null) {
|
|
633
574
|
objectId = checkObjectId;
|
|
634
575
|
return objectId;
|
|
@@ -638,11 +579,11 @@ export class Obelisk {
|
|
|
638
579
|
}
|
|
639
580
|
|
|
640
581
|
async entity_key_from_bytes(bytes: Uint8Array | Buffer | string) {
|
|
641
|
-
|
|
582
|
+
const hashBytes = keccak256(bytes);
|
|
642
583
|
const hashU8Array: number[] = Array.from(hashBytes);
|
|
643
584
|
const bcs = new BCS(getSuiMoveConfig());
|
|
644
|
-
|
|
645
|
-
|
|
585
|
+
const value = Uint8Array.from(hashU8Array);
|
|
586
|
+
const data = bcs.de('address', value);
|
|
646
587
|
return '0x' + data;
|
|
647
588
|
}
|
|
648
589
|
|
|
@@ -652,7 +593,7 @@ export class Obelisk {
|
|
|
652
593
|
|
|
653
594
|
async formatData(type: string, value: Buffer | number[] | Uint8Array) {
|
|
654
595
|
const bcs = new BCS(getSuiMoveConfig());
|
|
655
|
-
|
|
596
|
+
const u8Value = Uint8Array.from(value);
|
|
656
597
|
return bcs.de(type, u8Value);
|
|
657
598
|
}
|
|
658
599
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -35,8 +35,8 @@ export type ObeliskParams = {
|
|
|
35
35
|
metadata?: SuiMoveNormalizedModules;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
export type
|
|
39
|
-
|
|
38
|
+
export type SchemaFieldType = {
|
|
39
|
+
schemas: {
|
|
40
40
|
type: string;
|
|
41
41
|
fields: {
|
|
42
42
|
id: {
|
|
@@ -47,14 +47,14 @@ export type ComponentFieldType = {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
export type
|
|
50
|
+
export type SchemaValueType = {
|
|
51
51
|
id: {
|
|
52
52
|
id: string;
|
|
53
53
|
};
|
|
54
54
|
name: string;
|
|
55
55
|
value: {
|
|
56
56
|
type: string;
|
|
57
|
-
fields:
|
|
57
|
+
fields: SchemaFieldType;
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
60
|
|
|
@@ -77,9 +77,9 @@ export type SuiTxArgument =
|
|
|
77
77
|
index: number;
|
|
78
78
|
resultIndex: number;
|
|
79
79
|
};
|
|
80
|
-
export type
|
|
80
|
+
export type SchemaContentType = {
|
|
81
81
|
type: string;
|
|
82
|
-
fields:
|
|
82
|
+
fields: SchemaValueType;
|
|
83
83
|
hasPublicTransfer: boolean;
|
|
84
84
|
dataType: 'moveObject';
|
|
85
85
|
};
|
|
@@ -199,3 +199,10 @@ export type DynamicFieldContentType = {
|
|
|
199
199
|
hasPublicTransfer: boolean;
|
|
200
200
|
dataType: string;
|
|
201
201
|
};
|
|
202
|
+
|
|
203
|
+
export type ObjectContent = {
|
|
204
|
+
type: string;
|
|
205
|
+
fields: Record<string, any>;
|
|
206
|
+
hasPublicTransfer: boolean;
|
|
207
|
+
dataType: string;
|
|
208
|
+
};
|