@super-protocol/sdk-js 0.12.2-beta.0 → 0.12.2-beta.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/build/models/TCB.js
CHANGED
|
@@ -75,7 +75,7 @@ var TCB = /** @class */ (function () {
|
|
|
75
75
|
switch (_a.label) {
|
|
76
76
|
case 0:
|
|
77
77
|
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
78
|
-
fromattedDeviceId = (0, utils_1.
|
|
78
|
+
fromattedDeviceId = (0, utils_1.packDevicId)(pb.deviceID);
|
|
79
79
|
return [4 /*yield*/, TxManager_1.default.execute(this.contract.methods.setTcbData, [this.tcbId, pb.benchmark, pb.properties, fromattedDeviceId, quote], transactionOptions)];
|
|
80
80
|
case 1:
|
|
81
81
|
_a.sent();
|
|
@@ -198,7 +198,7 @@ var TCB = /** @class */ (function () {
|
|
|
198
198
|
case 1:
|
|
199
199
|
tcb = _a.sent();
|
|
200
200
|
tcbObject = (0, utils_1.tupleToObject)(tcb, Consensus_1.TcbStructure);
|
|
201
|
-
tcbObject.publicData.deviceID = (0, utils_1.
|
|
201
|
+
tcbObject.publicData.deviceID = (0, utils_1.unpackDeviceId)(tcbObject.publicData.deviceID);
|
|
202
202
|
return [2 /*return*/, tcbObject];
|
|
203
203
|
}
|
|
204
204
|
});
|
|
@@ -141,7 +141,7 @@ var Consensus = /** @class */ (function () {
|
|
|
141
141
|
tcbInfo = _a.sent();
|
|
142
142
|
tcbsForVerification.push({
|
|
143
143
|
tcbId: blocksIds[blockIndex].toString(),
|
|
144
|
-
deviceId: (0, utils_1.
|
|
144
|
+
deviceId: (0, utils_1.unpackDeviceId)(tcbInfo.publicData.deviceID),
|
|
145
145
|
properties: tcbInfo.publicData.properties,
|
|
146
146
|
benchmark: tcbInfo.publicData.benchmark,
|
|
147
147
|
quote: tcbInfo.quote,
|
|
@@ -153,7 +153,7 @@ var TeeOffersFactory = /** @class */ (function () {
|
|
|
153
153
|
*/
|
|
154
154
|
TeeOffersFactory.getByDeviceId = function (deviceId) {
|
|
155
155
|
var contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
156
|
-
var fromattedDeviceId = (0, utils_3.
|
|
156
|
+
var fromattedDeviceId = (0, utils_3.packDevicId)(deviceId);
|
|
157
157
|
return contract.methods.getTeeOfferByDeviceId(fromattedDeviceId).call();
|
|
158
158
|
};
|
|
159
159
|
/**
|
package/build/utils.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TransactionOptions } from "./types/Web3";
|
|
2
2
|
import Web3 from "web3";
|
|
3
|
-
import { BytesLike } from "@ethersproject/bytes";
|
|
4
3
|
/**
|
|
5
4
|
* Function for checking if provider action account initialized (required for set methods)
|
|
6
5
|
* Used in all set methods
|
|
@@ -31,6 +30,6 @@ type Format = FormatItem[] | {
|
|
|
31
30
|
export declare const tupleToObject: <T>(data: unknown[], format: Format) => T;
|
|
32
31
|
export declare const objectToTuple: (data: unknown, format: Format) => unknown[];
|
|
33
32
|
export declare function incrementMethodCall(): (_target: any, propertyName: string, propertyDescriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
34
|
-
export declare function
|
|
35
|
-
export declare function
|
|
33
|
+
export declare function packDevicId(hexedDeviceId: string): string;
|
|
34
|
+
export declare function unpackDeviceId(bytes32: string): string;
|
|
36
35
|
export {};
|
package/build/utils.js
CHANGED
|
@@ -39,13 +39,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.
|
|
42
|
+
exports.unpackDeviceId = exports.packDevicId = exports.incrementMethodCall = exports.objectToTuple = exports.tupleToObject = exports.isNodeJS = exports.createTransactionOptions = exports.getGasPrice = exports.checkForUsingExternalTxManager = exports.checkIfActionAccountInitialized = void 0;
|
|
43
43
|
var store_1 = __importDefault(require("./store"));
|
|
44
44
|
var lodash_1 = require("lodash");
|
|
45
45
|
var Monitoring_1 = require("./utils/Monitoring");
|
|
46
|
-
var utils_1 = require("ethers/lib/utils");
|
|
47
|
-
var bytes_1 = require("@ethersproject/bytes");
|
|
48
|
-
var constants_1 = require("@ethersproject/constants");
|
|
49
46
|
/**
|
|
50
47
|
* Function for checking if provider action account initialized (required for set methods)
|
|
51
48
|
* Used in all set methods
|
|
@@ -194,36 +191,20 @@ function incrementMethodCall() {
|
|
|
194
191
|
}
|
|
195
192
|
exports.incrementMethodCall = incrementMethodCall;
|
|
196
193
|
var hexRegex = /^[0-9a-fA-F]+$/;
|
|
197
|
-
function
|
|
198
|
-
if (
|
|
199
|
-
throw new Error("
|
|
194
|
+
function packDevicId(hexedDeviceId) {
|
|
195
|
+
if (hexedDeviceId.length !== 64) {
|
|
196
|
+
throw new Error("DeviceId must be equal 64 hex symbols");
|
|
200
197
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
// Check we have room for null-termination
|
|
204
|
-
if (bytes.length > 32) {
|
|
205
|
-
throw new Error("bytes32 string must be less or equal than 32 bytes");
|
|
198
|
+
if (!hexRegex.test(hexedDeviceId)) {
|
|
199
|
+
throw new Error("DeviceId must be a hexedecimal");
|
|
206
200
|
}
|
|
207
|
-
|
|
208
|
-
return (0, bytes_1.hexlify)((0, bytes_1.concat)([bytes, constants_1.HashZero]).slice(0, 32));
|
|
201
|
+
return "0x" + hexedDeviceId;
|
|
209
202
|
}
|
|
210
|
-
exports.
|
|
211
|
-
function
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (data.length !== 32) {
|
|
215
|
-
throw new Error("invalid bytes32 - not 32 bytes long");
|
|
203
|
+
exports.packDevicId = packDevicId;
|
|
204
|
+
function unpackDeviceId(bytes32) {
|
|
205
|
+
if (bytes32.length == 66) {
|
|
206
|
+
throw new Error("DeviceId bytes must be equal 66 symbols");
|
|
216
207
|
}
|
|
217
|
-
|
|
218
|
-
var length = 32;
|
|
219
|
-
while (data[length - 1] === 0) {
|
|
220
|
-
length--;
|
|
221
|
-
}
|
|
222
|
-
// Determine the string value
|
|
223
|
-
var decodedValue = (0, utils_1.toUtf8String)(data.slice(0, length));
|
|
224
|
-
if (!hexRegex.test(decodedValue)) {
|
|
225
|
-
throw new Error("parsed value - is not a hex");
|
|
226
|
-
}
|
|
227
|
-
return decodedValue;
|
|
208
|
+
return bytes32.slice(0, 64);
|
|
228
209
|
}
|
|
229
|
-
exports.
|
|
210
|
+
exports.unpackDeviceId = unpackDeviceId;
|