Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ledgerhq/hw-app-ada

Package Overview
Dependencies
Maintainers
7
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ledgerhq/hw-app-ada - npm Package Compare versions

Comparing version 4.13.0 to 4.14.0

2

package.json
{
"name": "@ledgerhq/hw-app-ada",
"version": "4.13.0",
"version": "4.14.0",
"description": "Ledger Hardware Wallet Cardano ADA API",

@@ -5,0 +5,0 @@ "main": "lib/Ada.js",

// @flow
import Int64 from "node-int64";
import type Transport from "@ledgerhq/hw-transport";
import Ada from "../../lib/Ada.js";
import Ada from "../..";

@@ -23,10 +23,13 @@ const CLA = 0x80;

export default class TestAda extends Ada {
constructor(transport: Transport<*>) {
super(transport);
this.methods = [ "testBase58Encode", "testCBORDecode", "testHashTransaction" ];
this.methods = [
"testBase58Encode",
"testCBORDecode",
"testHashTransaction"
];
this.transport.decorateAppAPIMethods(this, this.methods, "ADA");
}
get t() : Transport<*> {
get t(): Transport<*> {
return this.transport;

@@ -38,3 +41,3 @@ }

}
/**

@@ -46,7 +49,15 @@ * Check Base58 encoding on the device. This is for testing purposes only and is not available in production.

*/
async testBase58Encode(txHex: string): Promise<{ addressLength: number, encodedAddress: string }> {
async testBase58Encode(
txHex: string
): Promise<{ addressLength: number, encodedAddress: string }> {
const tx = Buffer.from(txHex, "hex");
const response = await this.transport.send(CLA, INS_BASE58_ENCODE_TEST, 0x00, 0x00, tx);
const [ addressLength ] = response;
const response = await this.transport.send(
CLA,
INS_BASE58_ENCODE_TEST,
0x00,
0x00,
tx
);
const [addressLength] = response;
const encodedAddress = response.slice(1, 1 + addressLength).toString();

@@ -63,3 +74,9 @@

*/
async testCBORDecode(txHex: string) : Promise<{ inputs?: number, outputs?: number, txs?: Array<{ checksum: string, amount: string }> }> {
async testCBORDecode(
txHex: string
): Promise<{
inputs?: number,
outputs?: number,
txs?: Array<{ checksum: string, amount: string }>
}> {
const rawTx = Buffer.from(txHex, "hex");

@@ -75,22 +92,31 @@ const chunkSize = MAX_APDU_SIZE - OFFSET_CDATA;

if (i === 0) {
p1 = P1_FIRST;
p1 = P1_FIRST;
} else if (i + chunkSize >= rawTx.length) {
p1 = P1_LAST;
p1 = P1_LAST;
}
const res = await this.transport.send(CLA, INS_CBOR_DECODE_TEST, p1, p2, chunk);
const res = await this.transport.send(
CLA,
INS_CBOR_DECODE_TEST,
p1,
p2,
chunk
);
if (res.length > 4) {
const [ inputs, outputs ] = res;
const txs = [];
const [inputs, outputs] = res;
const txs = [];
let position = 2;
while (position < res.length - 2) {
let checksum = res.readUInt32BE(position);
let amount = new Int64(res.readUInt32LE(position + 9), res.readUInt32LE(position + 5)).toOctetString();
txs.push({ checksum, amount });
position += 14;
}
let position = 2;
while (position < res.length - 2) {
let checksum = res.readUInt32BE(position);
let amount = new Int64(
res.readUInt32LE(position + 9),
res.readUInt32LE(position + 5)
).toOctetString();
txs.push({ checksum, amount });
position += 14;
}
response = { inputs, outputs, txs };
response = { inputs, outputs, txs };
}

@@ -108,3 +134,3 @@ }

*/
async testHashTransaction(txHex: string) : Promise<{ tx?: string }> {
async testHashTransaction(txHex: string): Promise<{ tx?: string }> {
const rawTx = Buffer.from(txHex, "hex");

@@ -120,11 +146,17 @@ const chunkSize = MAX_APDU_SIZE - OFFSET_CDATA;

if (i === 0) {
p1 = P1_FIRST;
p1 = P1_FIRST;
} else if (i + chunkSize >= rawTx.length) {
p1 = P1_LAST;
p1 = P1_LAST;
}
const res = await this.transport.send(CLA, INS_BLAKE2B_TEST, p1, p2, chunk);
const res = await this.transport.send(
CLA,
INS_BLAKE2B_TEST,
p1,
p2,
chunk
);
if (res.length > 4) {
const tx = res.slice(1, res.length - 2).toString('hex');
const tx = res.slice(1, res.length - 2).toString("hex");
response = { tx };

@@ -131,0 +163,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc