Skip to content

Commit

Permalink
feat(connect-examples): node example in ts
Browse files Browse the repository at this point in the history
  • Loading branch information
karliatto committed Nov 15, 2024
1 parent ffff4f8 commit c4e3d8a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 253 deletions.
2 changes: 1 addition & 1 deletion packages/connect-examples/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Please note, that this example needs:

## Run

`node index.js`
`yarn start`
5 changes: 3 additions & 2 deletions packages/connect-examples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"author": "Satoshilabs s.r.o <[email protected]>",
"license": "MIT",
"scripts": {
"start": "node index.js"
"start": "tsx ./src/index.ts"
},
"dependencies": {
"@trezor/connect": "workspace:*"
"@trezor/connect": "workspace:*",
"tsx": "^4.19.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const TrezorConnect = require('@trezor/connect').default;
const { TRANSPORT_EVENT, DEVICE_EVENT } = require('@trezor/connect');
import TrezorConnect, { TRANSPORT_EVENT, DEVICE_EVENT } from '@trezor/connect';

/**
* Please note, that this example needs:
Expand All @@ -16,16 +15,19 @@ const runExample = async () => {

// this event will be fired when bridge starts or stops or there is no bridge running
TrezorConnect.on(TRANSPORT_EVENT, event => {
// eslint-disable-next-line
console.log(event);
});

// this event will be fired when device connects, disconnects or changes
TrezorConnect.on(DEVICE_EVENT, event => {
// eslint-disable-next-line
console.log(event);
});

const result = await TrezorConnect.getFeatures();

// eslint-disable-next-line
console.log(result);

if (!result.success) {
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-examples/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": { "outDir": "./libDev" },
"compilerOptions": { "outDir": "libDev" },
"include": ["."],
"references": [{ "path": "../../connect" }]
}
Loading

0 comments on commit c4e3d8a

Please sign in to comment.