@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.mjs
CHANGED
|
@@ -903,10 +903,10 @@ var Obelisk = class {
|
|
|
903
903
|
if (metadata !== void 0) {
|
|
904
904
|
this.metadata = metadata;
|
|
905
905
|
Object.values(metadata).forEach((value) => {
|
|
906
|
-
|
|
907
|
-
|
|
906
|
+
const data = value;
|
|
907
|
+
const moduleName = data.name;
|
|
908
908
|
Object.entries(data.exposedFunctions).forEach(([funcName, value2]) => {
|
|
909
|
-
|
|
909
|
+
const meta = value2;
|
|
910
910
|
meta.moudleName = moduleName;
|
|
911
911
|
meta.funcName = funcName;
|
|
912
912
|
if (isUndefined(__privateGet(this, _query)[moduleName])) {
|
|
@@ -1115,125 +1115,85 @@ var Obelisk = class {
|
|
|
1115
1115
|
async getWorld(worldObjectId) {
|
|
1116
1116
|
return this.suiInteractor.getObject(worldObjectId);
|
|
1117
1117
|
}
|
|
1118
|
-
async
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
async getComponentByName(worldId, componentName) {
|
|
1123
|
-
const componentNameId = `${componentName}`;
|
|
1124
|
-
const componentId = keccak256(componentNameId);
|
|
1125
|
-
return await this.getComponent(worldId, componentId);
|
|
1126
|
-
}
|
|
1127
|
-
async getComponent(worldId, componentId) {
|
|
1128
|
-
const componentIdValue = Array.from(componentId);
|
|
1129
|
-
const parentId = (await this.suiInteractor.getObject(worldId)).objectFields.comps.fields.id.id;
|
|
1130
|
-
const name = {
|
|
1131
|
-
type: "address",
|
|
1132
|
-
value: componentIdValue
|
|
1133
|
-
};
|
|
1134
|
-
return await this.suiInteractor.getDynamicFieldObject(parentId, name);
|
|
1118
|
+
async listSchemaNames(worldId) {
|
|
1119
|
+
const worldObject = await this.getObject(worldId);
|
|
1120
|
+
const newObjectContent = worldObject.objectFields;
|
|
1121
|
+
return newObjectContent["schemaNames"];
|
|
1135
1122
|
}
|
|
1136
|
-
async
|
|
1137
|
-
|
|
1123
|
+
async getEntity(worldId, schemaName, entityId) {
|
|
1124
|
+
const schemaMoudleName = `${schemaName}_schema`;
|
|
1138
1125
|
const tx = new TransactionBlock3();
|
|
1139
|
-
|
|
1140
|
-
|
|
1126
|
+
const params = [tx.pure(worldId)];
|
|
1127
|
+
if (entityId !== void 0) {
|
|
1128
|
+
params.push(tx.pure(entityId));
|
|
1129
|
+
}
|
|
1130
|
+
const getResult = await this.query[schemaMoudleName].get(
|
|
1141
1131
|
tx,
|
|
1142
1132
|
params
|
|
1143
1133
|
);
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1134
|
+
const returnValue = [];
|
|
1135
|
+
if (getResult.effects.status.status === "success") {
|
|
1136
|
+
const resultList = getResult.results[0].returnValues;
|
|
1137
|
+
for (const res of resultList) {
|
|
1138
|
+
const bcs = new BCS(getSuiMoveConfig());
|
|
1139
|
+
const value = Uint8Array.from(res[0]);
|
|
1140
|
+
const data = bcs.de(res[1], value);
|
|
1141
|
+
returnValue.push(data);
|
|
1142
|
+
}
|
|
1143
|
+
return returnValue;
|
|
1144
|
+
} else {
|
|
1145
|
+
return void 0;
|
|
1146
|
+
}
|
|
1149
1147
|
}
|
|
1150
|
-
async
|
|
1151
|
-
|
|
1148
|
+
async containEntity(worldId, schemaName, entityId) {
|
|
1149
|
+
const schemaMoudleName = `${schemaName}_schema`;
|
|
1152
1150
|
const tx = new TransactionBlock3();
|
|
1153
|
-
|
|
1154
|
-
|
|
1151
|
+
const params = [tx.pure(worldId)];
|
|
1152
|
+
if (entityId !== void 0) {
|
|
1153
|
+
params.push(tx.pure(entityId));
|
|
1154
|
+
}
|
|
1155
|
+
const getResult = await this.query[schemaMoudleName].contains(
|
|
1155
1156
|
tx,
|
|
1156
1157
|
params
|
|
1157
1158
|
);
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
tableId,
|
|
1164
|
-
cursor,
|
|
1165
|
-
limit
|
|
1166
|
-
);
|
|
1167
|
-
let objectIds = dynamicFields.data.map((field) => field.objectId);
|
|
1168
|
-
let objectDatas = await this.suiInteractor.getEntitiesObjects(objectIds);
|
|
1169
|
-
return {
|
|
1170
|
-
data: objectDatas,
|
|
1171
|
-
nextCursor: dynamicFields.nextCursor,
|
|
1172
|
-
hasNextPage: dynamicFields.hasNextPage
|
|
1173
|
-
};
|
|
1174
|
-
}
|
|
1175
|
-
async getEntity(worldId, componentName, entityId) {
|
|
1176
|
-
let checkWorldId = normalizeHexAddress(worldId);
|
|
1177
|
-
if (checkWorldId) {
|
|
1178
|
-
worldId = checkWorldId;
|
|
1179
|
-
} else {
|
|
1180
|
-
return void 0;
|
|
1181
|
-
}
|
|
1182
|
-
let checkEntityId = normalizeHexAddress(entityId);
|
|
1183
|
-
if (checkEntityId) {
|
|
1184
|
-
entityId = checkEntityId;
|
|
1159
|
+
if (getResult.effects.status.status === "success") {
|
|
1160
|
+
const res = getResult.results[0].returnValues[0];
|
|
1161
|
+
const bcs = new BCS(getSuiMoveConfig());
|
|
1162
|
+
const value = Uint8Array.from(res[0]);
|
|
1163
|
+
return bcs.de(res[1], value);
|
|
1185
1164
|
} else {
|
|
1186
1165
|
return void 0;
|
|
1187
1166
|
}
|
|
1188
|
-
const parentId = await this.getComponentTable(worldId, componentName);
|
|
1189
|
-
const name = {
|
|
1190
|
-
type: "address",
|
|
1191
|
-
value: entityId
|
|
1192
|
-
};
|
|
1193
|
-
let dynamicFieldObject = await this.suiInteractor.getDynamicFieldObject(
|
|
1194
|
-
parentId,
|
|
1195
|
-
name
|
|
1196
|
-
);
|
|
1197
|
-
return dynamicFieldObject;
|
|
1198
1167
|
}
|
|
1199
|
-
// async
|
|
1168
|
+
// async getEntities(
|
|
1200
1169
|
// worldId: string,
|
|
1201
|
-
//
|
|
1202
|
-
//
|
|
1170
|
+
// schemaName: string,
|
|
1171
|
+
// cursor?: string,
|
|
1172
|
+
// limit?: number
|
|
1203
1173
|
// ) {
|
|
1204
|
-
//
|
|
1205
|
-
// const name = {
|
|
1206
|
-
// type: 'address',
|
|
1207
|
-
// value: entityId,
|
|
1208
|
-
// } as DynamicFieldName;
|
|
1209
|
-
// let dynamicFieldObject = await this.suiInteractor.getDynamicFieldObject(
|
|
1210
|
-
// parentId,
|
|
1211
|
-
// name
|
|
1212
|
-
// );
|
|
1213
|
-
// let componentMoudleName = `${componentName}_comp`;
|
|
1174
|
+
// let schemaMoudleName = `${schemaName}_schema`;
|
|
1214
1175
|
// const tx = new TransactionBlock();
|
|
1215
|
-
// let params = [] as SuiTxArgument[];
|
|
1216
|
-
// const
|
|
1176
|
+
// let params = [tx.pure(worldId)] as SuiTxArgument[];
|
|
1177
|
+
// const tableResult = (await this.query[schemaonentMoudleName].entities(
|
|
1217
1178
|
// tx,
|
|
1218
1179
|
// params
|
|
1219
1180
|
// )) as DevInspectResults;
|
|
1220
|
-
//
|
|
1221
|
-
// console.log(typeReturn[0].returnValues[0][0]);
|
|
1222
|
-
// const typeBCS = new BCS(getSuiMoveConfig());
|
|
1223
|
-
// let typeValue = Uint8Array.from(typeReturn[0].returnValues[0][0]);
|
|
1224
|
-
// let typeData = typeBCS.de('vector<vector<u8>>', typeValue);
|
|
1225
|
-
// console.log(typeData);
|
|
1226
|
-
// const entityType = String.fromCharCode(...typeData[0]);
|
|
1227
|
-
// let dynamicFieldContent = dynamicFieldObject.data!
|
|
1228
|
-
// .content as DynamicFieldContentType;
|
|
1229
|
-
// let entityValue = dynamicFieldContent.fields['value'];
|
|
1181
|
+
// const entities = tableResult.results as SuiReturnValues;
|
|
1230
1182
|
// const bcs = new BCS(getSuiMoveConfig());
|
|
1231
|
-
// let value = Uint8Array.from(
|
|
1232
|
-
//
|
|
1233
|
-
//
|
|
1234
|
-
//
|
|
1235
|
-
//
|
|
1236
|
-
//
|
|
1183
|
+
// let value = Uint8Array.from(entities[0].returnValues[0][0]);
|
|
1184
|
+
// let tableId = '0x' + bcs.de('address', value);
|
|
1185
|
+
// let dynamicFields = await this.suiInteractor.getDynamicFields(
|
|
1186
|
+
// tableId,
|
|
1187
|
+
// cursor,
|
|
1188
|
+
// limit
|
|
1189
|
+
// );
|
|
1190
|
+
// let objectIds = dynamicFields.data.map((field) => field.objectId);
|
|
1191
|
+
// let objectDatas = await this.suiInteractor.getEntitiesObjects(objectIds);
|
|
1192
|
+
// return {
|
|
1193
|
+
// data: objectDatas,
|
|
1194
|
+
// nextCursor: dynamicFields.nextCursor,
|
|
1195
|
+
// hasNextPage: dynamicFields.hasNextPage,
|
|
1196
|
+
// };
|
|
1237
1197
|
// }
|
|
1238
1198
|
async getOwnedObjects(owner, cursor, limit) {
|
|
1239
1199
|
const ownedObjects = await this.suiInteractor.getOwnedObjects(
|
|
@@ -1241,9 +1201,9 @@ var Obelisk = class {
|
|
|
1241
1201
|
cursor,
|
|
1242
1202
|
limit
|
|
1243
1203
|
);
|
|
1244
|
-
|
|
1204
|
+
const ownedObjectsRes = [];
|
|
1245
1205
|
for (const object of ownedObjects.data) {
|
|
1246
|
-
|
|
1206
|
+
const objectDetail = await this.getObject(object.data.objectId);
|
|
1247
1207
|
if (objectDetail.objectType.split("::")[0] === this.contractFactory.packageId) {
|
|
1248
1208
|
ownedObjectsRes.push(objectDetail);
|
|
1249
1209
|
}
|
|
@@ -1251,7 +1211,7 @@ var Obelisk = class {
|
|
|
1251
1211
|
return ownedObjectsRes;
|
|
1252
1212
|
}
|
|
1253
1213
|
async entity_key_from_object(objectId) {
|
|
1254
|
-
|
|
1214
|
+
const checkObjectId = normalizeHexAddress(objectId);
|
|
1255
1215
|
if (checkObjectId !== null) {
|
|
1256
1216
|
objectId = checkObjectId;
|
|
1257
1217
|
return objectId;
|
|
@@ -1260,11 +1220,11 @@ var Obelisk = class {
|
|
|
1260
1220
|
}
|
|
1261
1221
|
}
|
|
1262
1222
|
async entity_key_from_bytes(bytes) {
|
|
1263
|
-
|
|
1223
|
+
const hashBytes = keccak256(bytes);
|
|
1264
1224
|
const hashU8Array = Array.from(hashBytes);
|
|
1265
1225
|
const bcs = new BCS(getSuiMoveConfig());
|
|
1266
|
-
|
|
1267
|
-
|
|
1226
|
+
const value = Uint8Array.from(hashU8Array);
|
|
1227
|
+
const data = bcs.de("address", value);
|
|
1268
1228
|
return "0x" + data;
|
|
1269
1229
|
}
|
|
1270
1230
|
async entity_key_from_u256(x) {
|
|
@@ -1272,7 +1232,7 @@ var Obelisk = class {
|
|
|
1272
1232
|
}
|
|
1273
1233
|
async formatData(type, value) {
|
|
1274
1234
|
const bcs = new BCS(getSuiMoveConfig());
|
|
1275
|
-
|
|
1235
|
+
const u8Value = Uint8Array.from(value);
|
|
1276
1236
|
return bcs.de(type, u8Value);
|
|
1277
1237
|
}
|
|
1278
1238
|
};
|