Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async signTransactionWithIndexes(
indexes: Array
): Promise> {
let response = [];
for (let i = 0; i < indexes.length; i++) {
if (isNaN(indexes[i])) {
throw new TransportStatusError(INDEX_NAN);
}
if (indexes[i] > INDEX_MAX) {
throw new TransportStatusError(INDEX_MAX_EXCEEDED);
}
const data = Buffer.alloc(4);
data.writeUInt32BE(indexes[i], 0);
const res = await this.transport.send(CLA, INS_SIGN_TX, 0x00, 0x00, data);
const digest = res.slice(0, res.length - 2).toString("hex");
response.push({ digest });
}
return response;
}
}
async signTransactionWithIndexes(
indexes: Array
): Promise> {
let response = [];
for (let i = 0; i < indexes.length; i++) {
if (isNaN(indexes[i])) {
throw new TransportStatusError(INDEX_NAN);
}
if (indexes[i] > INDEX_MAX) {
throw new TransportStatusError(INDEX_MAX_EXCEEDED);
}
const data = Buffer.alloc(4);
data.writeUInt32BE(indexes[i], 0);
const res = await this.transport.send(CLA, INS_SIGN_TX, 0x00, 0x00, data);
const digest = res.slice(0, res.length - 2).toString("hex");
response.push({ digest });
}
return response;
async getWalletPublicKeyWithIndex(
index: number
): Promise<{ publicKey: string }> {
if (isNaN(index)) {
throw new TransportStatusError(INDEX_NAN);
}
const data = Buffer.alloc(4);
data.writeUInt32BE(index, 0);
const response = await this.transport.send(
CLA,
INS_GET_PUBLIC_KEY,
0x02,
0x00,
data
);
const [publicKeyLength] = response;
const publicKey = response.slice(1, 1 + publicKeyLength).toString("hex");