Skip to content

Commit

Permalink
Merge pull request #4989 from vechainfoundation/feat/vechain-support
Browse files Browse the repository at this point in the history
Fix pnpm doc + pnpm test
  • Loading branch information
hedi-edelbloute authored Oct 11, 2023
2 parents 6b3fa6c + a3f26d6 commit 643b73a
Show file tree
Hide file tree
Showing 4 changed files with 37,812 additions and 19,919 deletions.
59 changes: 59 additions & 0 deletions libs/ledgerjs/packages/hw-app-vet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,62 @@ For a smooth and quick integration:
***

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

* [Vet](#vet)
* [Parameters](#parameters)
* [Examples](#examples)
* [getAddress](#getaddress)
* [Parameters](#parameters-1)
* [Examples](#examples-1)
* [signTransaction](#signtransaction)
* [Parameters](#parameters-2)

### Vet

VeChain API

#### Parameters

* `transport` **Transport**
* `scrambleKey` (optional, default `"V3T"`)

#### Examples

```javascript
import Vet from "@ledgerhq/hw-app-vet";
const vet = new Vet(transport)
```

#### getAddress

get VeChain address for a given BIP 32 path.

##### Parameters

* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
* `display` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
* `chainCode` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
* `statusCodes` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<StatusCodes>** (optional, default `[StatusCodes.OK]`)

##### Examples

```javascript
vet.getAddress("m/44'/818'/0'/0").then(o => o.address)
```

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), address: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), chainCode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?}>** an object with a publicKey and address

#### signTransaction

You can sign a transaction and retrieve v, r, s given the raw transaction and the BIP 32 path of the account to sign.

##### Parameters

* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** : the BIP32 path to sign the transaction on
* `rawTxHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** : the raw vechain transaction in hexadecimal to sign

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Buffer](https://nodejs.org/api/buffer.html)>**
13 changes: 11 additions & 2 deletions libs/ledgerjs/packages/hw-app-vet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"test": "jest"
},
"devDependencies": {
"typescript": "^4"
}
"@ledgerhq/hw-transport-mocker": "workspace:^",
"source-map-support": "^0.5.21",
"typescript": "^4",
"@types/jest": "^29.5.0",
"jest": "^28.1.1",
"ts-jest": "^28.0.5",
"@types/node": "^18.15.3",
"documentation": "13.2.5",
"ts-node": "^10.4.0"
},
"gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec"
}
18 changes: 6 additions & 12 deletions libs/ledgerjs/packages/hw-app-vet/tests/Vechain.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
openTransportReplayer,
RecordStore,
} from "@ledgerhq/hw-transport-mocker";
import { openTransportReplayer, RecordStore } from "@ledgerhq/hw-transport-mocker";
import Vet from "../src/Vet";
import { Transaction as ThorTransaction } from "thor-devkit";

Expand All @@ -10,7 +7,7 @@ test("getAppConfiguration", async () => {
RecordStore.fromString(`
=> e006000000
<= 030100079000
`)
`),
);
const vet = new Vet(transport);
const result = await vet.getAppConfiguration();
Expand All @@ -24,7 +21,7 @@ test("Get address", async () => {
RecordStore.fromString(`
=> e002000015058000002c80000332800000000000000000000000
<= 410482c44bc99cdf08d4360c97fbf62d387288ab75c576926943ad90059002720e93f58799391393c98ad41136aa4ac871b103d25cb9a88f1aadd7dbbe3c7794888928333234373631393364346133323438383332326666426239383335613763463263376532323032439000
`)
`),
);
const vet = new Vet(transport);
const { address } = await vet.getAddress("44'/818'/0'/0/0");
Expand All @@ -36,7 +33,7 @@ test("signMessage", async () => {
RecordStore.fromString(`
=> e004000037058000002c80000332800000000000000000000000e1278012d8d7940000000000000000000000000000000000000000808080808080c0
<= dd0ad907f6cfdd068226999eee0d20789732905270a7c4ed385872599f40978e043a5d7a15e396e59e9c9e921be5f4e02e3b6284b8cf835443f4123ca20b5b35009000
`)
`),
);

const unsigned = new ThorTransaction({
Expand All @@ -57,12 +54,9 @@ test("signMessage", async () => {
});

const vet = new Vet(transport);
const res = await vet.signTransaction(
"44'/818'/0'/0/0",
unsigned.encode().toString("hex")
);
const res = await vet.signTransaction("44'/818'/0'/0/0", unsigned.encode().toString("hex"));

expect(res.toString("hex")).toEqual(
"dd0ad907f6cfdd068226999eee0d20789732905270a7c4ed385872599f40978e043a5d7a15e396e59e9c9e921be5f4e02e3b6284b8cf835443f4123ca20b5b3500"
"dd0ad907f6cfdd068226999eee0d20789732905270a7c4ed385872599f40978e043a5d7a15e396e59e9c9e921be5f4e02e3b6284b8cf835443f4123ca20b5b3500",
);
});
Loading

2 comments on commit 643b73a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Bot] Testing with 'Nitrogen' ($0.00) ⏲ 3.00ms

What is the bot and how does it work? Everything is documented here!

Details of the 0 mutations
Portfolio ($0.00) – Details of the 0 currencies
Spec (accounts) State Remaining Runs (est) funds?

Performance ⏲ 3.00ms

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL N/A N/A N/A N/A N/A N/A N/A N/A

What is the bot and how does it work? Everything is documented here!

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Bot] Testing with 'Nitrogen' ($0.00) ⏲ 3.00ms

What is the bot and how does it work? Everything is documented here!

Details of the 0 mutations
Portfolio ($0.00) – Details of the 0 currencies
Spec (accounts) State Remaining Runs (est) funds?

Performance ⏲ 3.00ms

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL N/A N/A N/A N/A N/A N/A N/A N/A

What is the bot and how does it work? Everything is documented here!

Please sign in to comment.