Comments (2)
Has there been any progress on this? I'm attempting to run mocha chai unit tests and am also encountering this issue:
> mocha --require source-map-support/register --require make-promises-safe lib/test/unit/**/*_test.js --timeout 10000 --bail --exit
/Users/marcmartinez/Desktop/0x-monorepo/node_modules/trezor-connect/lib/data/ConnectSettings.js:39
supportedBrowser: !/Trident|MSIE/.test(navigator.userAgent),
^
ReferenceError: navigator is not defined
Here's my implementation in TS:
export class TrezorSubprovider extends BaseWalletSubprovider {
private readonly _publicKeyPath: string;
private _cachedAccounts: string[];
// NOTE:: trezor-connect module currently runs in browser only https://github.com/trezor/connect/issues/248
private _runningInBrowser: boolean;
/**
* Instantiates a TrezorSubprovider. Defaults to private key path set to `44'/60'/0'`.
* @return TrezorSubprovider instance
*/
constructor() {
super();
this._publicKeyPath = PRIVATE_KEY_PATH;
this._cachedAccounts = [];
this._runningInBrowser = typeof window === 'undefined' ? false : true;
}
/**
* Retrieve a users Trezor account. The accounts are private key path derived, This method
* is automatically called when issuing a `eth_accounts` JSON RPC request via your providerEngine
* instance.
* @return An array of accounts
*/
public async getAccountsAsync(): Promise<string[]> {
if (!this._runningInBrowser) {
throw new Error(WalletSubproviderErrors.MustRunInBrowser);
}
if (this._cachedAccounts.length) {
return this._cachedAccounts;
}
const accounts: string[] = [];
const response: TrezorConnectResponse = TrezorConnect.ethereumGetAddress({ path: this._publicKeyPath, showOnTrezor: true });
if (response.success) {
const payload: TrezorGetAddressResponsePayload = response.payload;
accounts.push(payload.address);
this._cachedAccounts = accounts;
} else {
const payload: TrezorResponseErrorPayload = response.payload;
throw new Error(payload.error);
}
return accounts;
}
}
from trezor-link.
Outdated, we have moved trezor-link to trezor-suite monorepo, please open a new issue there if needed.
from trezor-link.
Related Issues (11)
- src/lowlevel/node-hid.js: macOS & interface number HOT 3
- Remove bridge1 artefacts HOT 4
- Unhandled WebUsb Error: LowLevelTransportWithSharedConnections.call Error: Device released or disconnected HOT 1
- Update protobuf dependency HOT 1
- Do not throw error on unknown ButtonRequest
- regeneratorRuntime is not defined HOT 1
- Unable to handle passphrase requests HOT 1
- Expose error messages HOT 1
- lowlevel/webusb unreadableHidDevice should be emited as response of enumerate HOT 1
- Request to Bridge v2 fails with 403 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trezor-link.