@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
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from '@mysten/sui.js';
|
|
2
|
+
export { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';
|
|
3
|
+
export * from '@mysten/bcs';
|
|
4
|
+
export { Obelisk } from './obelisk';
|
|
5
|
+
export { SuiAccountManager } from './libs/suiAccountManager';
|
|
6
|
+
export { SuiTxBlock } from './libs/suiTxBuilder';
|
|
7
|
+
export { SuiContractFactory } from './libs/suiContractFactory';
|
|
8
|
+
export { getMetadata } from './metadata';
|
|
9
|
+
export type * from './types';
|
package/dist/index.js
CHANGED
|
@@ -918,10 +918,10 @@ var Obelisk = class {
|
|
|
918
918
|
if (metadata !== void 0) {
|
|
919
919
|
this.metadata = metadata;
|
|
920
920
|
Object.values(metadata).forEach((value) => {
|
|
921
|
-
|
|
922
|
-
|
|
921
|
+
const data = value;
|
|
922
|
+
const moduleName = data.name;
|
|
923
923
|
Object.entries(data.exposedFunctions).forEach(([funcName, value2]) => {
|
|
924
|
-
|
|
924
|
+
const meta = value2;
|
|
925
925
|
meta.moudleName = moduleName;
|
|
926
926
|
meta.funcName = funcName;
|
|
927
927
|
if (isUndefined(__privateGet(this, _query)[moduleName])) {
|
|
@@ -1130,125 +1130,85 @@ var Obelisk = class {
|
|
|
1130
1130
|
async getWorld(worldObjectId) {
|
|
1131
1131
|
return this.suiInteractor.getObject(worldObjectId);
|
|
1132
1132
|
}
|
|
1133
|
-
async
|
|
1134
|
-
const
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
async getComponentByName(worldId, componentName) {
|
|
1138
|
-
const componentNameId = `${componentName}`;
|
|
1139
|
-
const componentId = (0, import_keccak256.default)(componentNameId);
|
|
1140
|
-
return await this.getComponent(worldId, componentId);
|
|
1141
|
-
}
|
|
1142
|
-
async getComponent(worldId, componentId) {
|
|
1143
|
-
const componentIdValue = Array.from(componentId);
|
|
1144
|
-
const parentId = (await this.suiInteractor.getObject(worldId)).objectFields.comps.fields.id.id;
|
|
1145
|
-
const name = {
|
|
1146
|
-
type: "address",
|
|
1147
|
-
value: componentIdValue
|
|
1148
|
-
};
|
|
1149
|
-
return await this.suiInteractor.getDynamicFieldObject(parentId, name);
|
|
1133
|
+
async listSchemaNames(worldId) {
|
|
1134
|
+
const worldObject = await this.getObject(worldId);
|
|
1135
|
+
const newObjectContent = worldObject.objectFields;
|
|
1136
|
+
return newObjectContent["schemaNames"];
|
|
1150
1137
|
}
|
|
1151
|
-
async
|
|
1152
|
-
|
|
1138
|
+
async getEntity(worldId, schemaName, entityId) {
|
|
1139
|
+
const schemaMoudleName = `${schemaName}_schema`;
|
|
1153
1140
|
const tx = new import_sui9.TransactionBlock();
|
|
1154
|
-
|
|
1155
|
-
|
|
1141
|
+
const params = [tx.pure(worldId)];
|
|
1142
|
+
if (entityId !== void 0) {
|
|
1143
|
+
params.push(tx.pure(entityId));
|
|
1144
|
+
}
|
|
1145
|
+
const getResult = await this.query[schemaMoudleName].get(
|
|
1156
1146
|
tx,
|
|
1157
1147
|
params
|
|
1158
1148
|
);
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1149
|
+
const returnValue = [];
|
|
1150
|
+
if (getResult.effects.status.status === "success") {
|
|
1151
|
+
const resultList = getResult.results[0].returnValues;
|
|
1152
|
+
for (const res of resultList) {
|
|
1153
|
+
const bcs = new import_bcs.BCS((0, import_bcs.getSuiMoveConfig)());
|
|
1154
|
+
const value = Uint8Array.from(res[0]);
|
|
1155
|
+
const data = bcs.de(res[1], value);
|
|
1156
|
+
returnValue.push(data);
|
|
1157
|
+
}
|
|
1158
|
+
return returnValue;
|
|
1159
|
+
} else {
|
|
1160
|
+
return void 0;
|
|
1161
|
+
}
|
|
1164
1162
|
}
|
|
1165
|
-
async
|
|
1166
|
-
|
|
1163
|
+
async containEntity(worldId, schemaName, entityId) {
|
|
1164
|
+
const schemaMoudleName = `${schemaName}_schema`;
|
|
1167
1165
|
const tx = new import_sui9.TransactionBlock();
|
|
1168
|
-
|
|
1169
|
-
|
|
1166
|
+
const params = [tx.pure(worldId)];
|
|
1167
|
+
if (entityId !== void 0) {
|
|
1168
|
+
params.push(tx.pure(entityId));
|
|
1169
|
+
}
|
|
1170
|
+
const getResult = await this.query[schemaMoudleName].contains(
|
|
1170
1171
|
tx,
|
|
1171
1172
|
params
|
|
1172
1173
|
);
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
tableId,
|
|
1179
|
-
cursor,
|
|
1180
|
-
limit
|
|
1181
|
-
);
|
|
1182
|
-
let objectIds = dynamicFields.data.map((field) => field.objectId);
|
|
1183
|
-
let objectDatas = await this.suiInteractor.getEntitiesObjects(objectIds);
|
|
1184
|
-
return {
|
|
1185
|
-
data: objectDatas,
|
|
1186
|
-
nextCursor: dynamicFields.nextCursor,
|
|
1187
|
-
hasNextPage: dynamicFields.hasNextPage
|
|
1188
|
-
};
|
|
1189
|
-
}
|
|
1190
|
-
async getEntity(worldId, componentName, entityId) {
|
|
1191
|
-
let checkWorldId = normalizeHexAddress(worldId);
|
|
1192
|
-
if (checkWorldId) {
|
|
1193
|
-
worldId = checkWorldId;
|
|
1194
|
-
} else {
|
|
1195
|
-
return void 0;
|
|
1196
|
-
}
|
|
1197
|
-
let checkEntityId = normalizeHexAddress(entityId);
|
|
1198
|
-
if (checkEntityId) {
|
|
1199
|
-
entityId = checkEntityId;
|
|
1174
|
+
if (getResult.effects.status.status === "success") {
|
|
1175
|
+
const res = getResult.results[0].returnValues[0];
|
|
1176
|
+
const bcs = new import_bcs.BCS((0, import_bcs.getSuiMoveConfig)());
|
|
1177
|
+
const value = Uint8Array.from(res[0]);
|
|
1178
|
+
return bcs.de(res[1], value);
|
|
1200
1179
|
} else {
|
|
1201
1180
|
return void 0;
|
|
1202
1181
|
}
|
|
1203
|
-
const parentId = await this.getComponentTable(worldId, componentName);
|
|
1204
|
-
const name = {
|
|
1205
|
-
type: "address",
|
|
1206
|
-
value: entityId
|
|
1207
|
-
};
|
|
1208
|
-
let dynamicFieldObject = await this.suiInteractor.getDynamicFieldObject(
|
|
1209
|
-
parentId,
|
|
1210
|
-
name
|
|
1211
|
-
);
|
|
1212
|
-
return dynamicFieldObject;
|
|
1213
1182
|
}
|
|
1214
|
-
// async
|
|
1183
|
+
// async getEntities(
|
|
1215
1184
|
// worldId: string,
|
|
1216
|
-
//
|
|
1217
|
-
//
|
|
1185
|
+
// schemaName: string,
|
|
1186
|
+
// cursor?: string,
|
|
1187
|
+
// limit?: number
|
|
1218
1188
|
// ) {
|
|
1219
|
-
//
|
|
1220
|
-
// const name = {
|
|
1221
|
-
// type: 'address',
|
|
1222
|
-
// value: entityId,
|
|
1223
|
-
// } as DynamicFieldName;
|
|
1224
|
-
// let dynamicFieldObject = await this.suiInteractor.getDynamicFieldObject(
|
|
1225
|
-
// parentId,
|
|
1226
|
-
// name
|
|
1227
|
-
// );
|
|
1228
|
-
// let componentMoudleName = `${componentName}_comp`;
|
|
1189
|
+
// let schemaMoudleName = `${schemaName}_schema`;
|
|
1229
1190
|
// const tx = new TransactionBlock();
|
|
1230
|
-
// let params = [] as SuiTxArgument[];
|
|
1231
|
-
// const
|
|
1191
|
+
// let params = [tx.pure(worldId)] as SuiTxArgument[];
|
|
1192
|
+
// const tableResult = (await this.query[schemaonentMoudleName].entities(
|
|
1232
1193
|
// tx,
|
|
1233
1194
|
// params
|
|
1234
1195
|
// )) as DevInspectResults;
|
|
1235
|
-
//
|
|
1236
|
-
// console.log(typeReturn[0].returnValues[0][0]);
|
|
1237
|
-
// const typeBCS = new BCS(getSuiMoveConfig());
|
|
1238
|
-
// let typeValue = Uint8Array.from(typeReturn[0].returnValues[0][0]);
|
|
1239
|
-
// let typeData = typeBCS.de('vector<vector<u8>>', typeValue);
|
|
1240
|
-
// console.log(typeData);
|
|
1241
|
-
// const entityType = String.fromCharCode(...typeData[0]);
|
|
1242
|
-
// let dynamicFieldContent = dynamicFieldObject.data!
|
|
1243
|
-
// .content as DynamicFieldContentType;
|
|
1244
|
-
// let entityValue = dynamicFieldContent.fields['value'];
|
|
1196
|
+
// const entities = tableResult.results as SuiReturnValues;
|
|
1245
1197
|
// const bcs = new BCS(getSuiMoveConfig());
|
|
1246
|
-
// let value = Uint8Array.from(
|
|
1247
|
-
//
|
|
1248
|
-
//
|
|
1249
|
-
//
|
|
1250
|
-
//
|
|
1251
|
-
//
|
|
1198
|
+
// let value = Uint8Array.from(entities[0].returnValues[0][0]);
|
|
1199
|
+
// let tableId = '0x' + bcs.de('address', value);
|
|
1200
|
+
// let dynamicFields = await this.suiInteractor.getDynamicFields(
|
|
1201
|
+
// tableId,
|
|
1202
|
+
// cursor,
|
|
1203
|
+
// limit
|
|
1204
|
+
// );
|
|
1205
|
+
// let objectIds = dynamicFields.data.map((field) => field.objectId);
|
|
1206
|
+
// let objectDatas = await this.suiInteractor.getEntitiesObjects(objectIds);
|
|
1207
|
+
// return {
|
|
1208
|
+
// data: objectDatas,
|
|
1209
|
+
// nextCursor: dynamicFields.nextCursor,
|
|
1210
|
+
// hasNextPage: dynamicFields.hasNextPage,
|
|
1211
|
+
// };
|
|
1252
1212
|
// }
|
|
1253
1213
|
async getOwnedObjects(owner, cursor, limit) {
|
|
1254
1214
|
const ownedObjects = await this.suiInteractor.getOwnedObjects(
|
|
@@ -1256,9 +1216,9 @@ var Obelisk = class {
|
|
|
1256
1216
|
cursor,
|
|
1257
1217
|
limit
|
|
1258
1218
|
);
|
|
1259
|
-
|
|
1219
|
+
const ownedObjectsRes = [];
|
|
1260
1220
|
for (const object of ownedObjects.data) {
|
|
1261
|
-
|
|
1221
|
+
const objectDetail = await this.getObject(object.data.objectId);
|
|
1262
1222
|
if (objectDetail.objectType.split("::")[0] === this.contractFactory.packageId) {
|
|
1263
1223
|
ownedObjectsRes.push(objectDetail);
|
|
1264
1224
|
}
|
|
@@ -1266,7 +1226,7 @@ var Obelisk = class {
|
|
|
1266
1226
|
return ownedObjectsRes;
|
|
1267
1227
|
}
|
|
1268
1228
|
async entity_key_from_object(objectId) {
|
|
1269
|
-
|
|
1229
|
+
const checkObjectId = normalizeHexAddress(objectId);
|
|
1270
1230
|
if (checkObjectId !== null) {
|
|
1271
1231
|
objectId = checkObjectId;
|
|
1272
1232
|
return objectId;
|
|
@@ -1275,11 +1235,11 @@ var Obelisk = class {
|
|
|
1275
1235
|
}
|
|
1276
1236
|
}
|
|
1277
1237
|
async entity_key_from_bytes(bytes) {
|
|
1278
|
-
|
|
1238
|
+
const hashBytes = (0, import_keccak256.default)(bytes);
|
|
1279
1239
|
const hashU8Array = Array.from(hashBytes);
|
|
1280
1240
|
const bcs = new import_bcs.BCS((0, import_bcs.getSuiMoveConfig)());
|
|
1281
|
-
|
|
1282
|
-
|
|
1241
|
+
const value = Uint8Array.from(hashU8Array);
|
|
1242
|
+
const data = bcs.de("address", value);
|
|
1283
1243
|
return "0x" + data;
|
|
1284
1244
|
}
|
|
1285
1245
|
async entity_key_from_u256(x) {
|
|
@@ -1287,7 +1247,7 @@ var Obelisk = class {
|
|
|
1287
1247
|
}
|
|
1288
1248
|
async formatData(type, value) {
|
|
1289
1249
|
const bcs = new import_bcs.BCS((0, import_bcs.getSuiMoveConfig)());
|
|
1290
|
-
|
|
1250
|
+
const u8Value = Uint8Array.from(value);
|
|
1291
1251
|
return bcs.de(type, u8Value);
|
|
1292
1252
|
}
|
|
1293
1253
|
};
|