How to use @ledgerhq/web3-subprovider - 10 common examples

To help you get started, we’ve selected a few @ledgerhq/web3-subprovider examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github loomnetwork / dashboard / src / components / modals / HardwareWalletModal.vue View on Github external
async loadMore() {
    const transport = await this.transport()
    const getTransport = () => transport
    const path = this.selectedPath
    const networkId = Number(this.state.ethereum.networkId)
    const accountsLength = 4
    const offset = this.accounts.length
    // stop the loop when selectedPath has chaned or max accounts reached
    if (offset + accountsLength >= 100) {
      return
    }

    // console.log("loading,", path, offset, networkId, accountsLength)
    this.loadingAccounts = true
    const ledger = createLedgerSubprovider(
      getTransport
      , {
        networkId,
        accountsLength,
        path: this.calculatePath(path, offset),
      })
    const t = Date.now()
    // console.log("getAccounts")
    ledger.getAccounts((error, accounts: string[]) => {
      console.log("getAccounts", (Date.now() - t) / 1000)

      if (error) {
        // show error "please unlock your ledger wallet and go to the etherum app"
        console.log(error)
      } else {
        from(accounts)
github loomnetwork / dashboard / src / services / initWeb3.ts View on Github external
return new Promise(async (resolve, reject) => {
    const engine = new ProviderEngine()
    const getTransport = () => TransportU2F.create()
    const ledger = createLedgerSubprovider(getTransport, {
      networkId: 1,
      // maybe we only need 1 now that we solved this
      accountsLength: 5,
      path,
    })

    ledger.signMessage = ledger.signPersonalMessage
    engine.addProvider(ledger)
    engine.addProvider(
      new FetchSubprovider({
        rpcUrl: "https://mainnet.infura.io/5Ic91y0T9nLh6qUg33K0",
      }),
    )
    engine.start()
    resolve(new Web3(engine))
  })
github loomnetwork / dashboard / src / components / modals / HardwareWalletModal.vue View on Github external
async connect(account: LedgerAccount) {
    const selectedAddress = account.address
    const path = this.calculatePath(this.selectedPath, this.accounts.indexOf(account))
    const networkId = Number(this.state.ethereum.networkId)
    const rpcUrl = this.state.ethereum.endpoint
    const engine = new ProviderEngine()
    const transport = await this.transport()
    const ledger = createLedgerSubprovider(
      () => transport, {
        networkId,
        accountsLength: 1,
        path,
      })

    ledger.signMessage = ledger.signPersonalMessage
    engine.addProvider(ledger)
    engine.addProvider(
      // new RpcSubprovider({ rpcUrl }),
      new FetchSubprovider({
        rpcUrl,
      }),
    )
    engine.start()
    // @ts-ignore
github MuzikaFoundation / muzika-platform / projects / core / common / providers / web3-wallet / ledger.provider.ts View on Github external
constructor(opts?: SubproviderOptions,
              providerUrl?: string) {
    opts = Object.assign({
      accountsLength: 5
    }, opts);

    const getTransport = () => TransportU2F.create();

    const ledger = createLedgerSubprovider(getTransport, opts);

    const rpcProvider = new RpcSubprovider({
      rpcUrl: providerUrl || DEFAULT_RPC_URL
    });

    this.engine = new ProviderEngine({pollingInterval: 10000});
    this.engine.addProvider(ledger);
    this.engine.addProvider(rpcProvider);
    this.engine.start(); // Required by the provider engine.
  }
github deens-com / frontend / src / libs / web3-utils.js View on Github external
export async function getLedgerWeb3() {
  if (!_ledgerWeb3Instance) {
    const engine = new ProviderEngine();
    const getTransport = () => TransportU2F.create();
    const ledger = createLedgerSubprovider(getTransport, {
      networkId,
      accountsLength: 5,
    });
    engine.addProvider(ledger);
    engine.addProvider(new FetchSubprovider({ rpcUrl }));
    engine.start();
    _ledgerWeb3Instance = new Web3(engine);
  }
  return _ledgerWeb3Instance;
}
github SelfKeyFoundation / Identity-Wallet / src / main / blockchain / leadger-service.js View on Github external
createWeb3(accountsOffset, accountsQuantity) {
		accountsOffset = accountsOffset || 0;
		accountsQuantity = accountsQuantity || 6;
		const engine = new ProviderEngine();
		const getTransport = () => HWTransportNodeHid.create();
		const ledger = Web3SubProvider(getTransport, {
			networkId: chainId,
			accountsLength: accountsQuantity,
			accountsOffset
		});

		engine.addProvider(ledger);
		engine.addProvider(new FetchSubprovider({ rpcUrl: SELECTED_SERVER_URL }));
		engine.start();
		return new Web3(engine);
	}
	signTransaction(args) {
github dexdexplatform / dexdex-mono / packages / widget / src / model / wallets / ledger.ts View on Github external
export function getProvider() {
  const ethNet = appConfig().network;
  const networkId = appConfig().networkId;
  const rpcUrl = getNodeUrl(ethNet);

  const engine = new ProviderEngine();
  const getTransport = async () => TransportU2F.create();

  const ledger = createLedgerSubprovider(getTransport, {
    networkId,
    accountsLength: 5,
  });
  engine.addProvider(ledger);
  engine.addProvider(new FetchSubprovider({ rpcUrl }));
  engine.start();
  return engine;
}
github loomnetwork / dashboard / src / services / initWeb3.ts View on Github external
return new Promise(async (resolve, reject) => {
    const engine = new ProviderEngine()
    const getTransport = () => TransportU2F.create()
    const ledger = createLedgerSubprovider(getTransport, {
      networkId: 1,
      accountsLength: 10,
      path,
    })
    const accounts = ledger.getAccounts((err, val) => {
      if (err) reject(err)
      resolve(val)
    })
  })
}
github loomnetwork / dashboard / src / services / initWeb3.ts View on Github external
return new Promise(async (resolve, reject) => {
    const engine = new ProviderEngine()
    const getTransport = () => TransportU2F.create()
    const ledger = createLedgerSubprovider(getTransport, {
      networkId: 1,
      accountsLength: 5,
    })

    ledger.getAccounts = () => ["123"]

    ledger.signMessage = ledger.signPersonalMessage
    engine.addProvider(ledger)
    engine.addProvider(
      new FetchSubprovider({
        rpcUrl: "https://mainnet.infura.io/5Ic91y0T9nLh6qUg33K0",
      }),
    )
    engine.start()
    resolve(new Web3(engine))
  })
github enslogin / Hackathon / packages / modules / ledger / lib / ledger.js View on Github external
window.provider = (config) => {

	const basicProvider = new ethers.providers.InfuraProvider(config.provider.network);

	const engine = new ProviderEngine();
	const getTransport = () => TransportU2F.create();
	const ledger = createLedgerSubprovider(getTransport, { accountsLength: 1 });
	engine.addProvider(ledger);
	engine.addProvider(new RpcSubprovider({ rpcUrl: '${basicProvider.baseUrl}/api' }));
	engine.start();
	return engine;
}

@ledgerhq/web3-subprovider

Ledger Hardware Wallet Ethereum Web3 subprovider

Apache-2.0
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis

Popular @ledgerhq/web3-subprovider functions