Git Product home page Git Product logo

fuel-js's Introduction

fuel-js

License Community

Abstract

This repository contains all the necessary working Fuel javascript infrastructure.

Usage

Please consult the SDK documentation: docs.fuel.sh

Install

lerna bootstrap

fuel-js's People

Contributors

adlerjohn avatar benjythebee avatar dependabot[bot] avatar dzgoldman avatar silentcicero avatar vimwitch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fuel-js's Issues

[feature request] separate wallet from client

Currently the client is bonded to a demanded wallet. This was for posterity sake and to ensure a key is always available if Fraud is detected. This can be removed for a watch-only version.

Quick idea: a dummy key can be used as a placeholder and thrown away upon shutdown.

`Error: getaddrinfo EAI_AGAIN` when connecting to Infura with `--infura` flag set

Summary

I'm experiencing a UX issue when running fuel against a remote RPC endpoint provided by Infura.

Running the pre-compiled binary results in the code reporting a stack trace and then exiting.

Observed behaviour

I run ./fuel --network="mainnet" --infura="********c40b4d538f126b1e5520eca2" and then I see this:

✔ Please enter your Fuel wallet decryption passphrase … ************
fuel-2021-01-05 8:09:56 PM : Using API key: ********c40b4d538f12...
fuel-2021-01-05 8:09:56 PM : Using Infura provider
fuel-2021-01-05 8:09:56 PM : Wallet/operator address used: 0x****************eB6144fACaD91956********
fuel-2021-01-05 8:09:56 PM : DB: default local db selected.
{ Error: invalid response - 0
    at exports.XMLHttpRequest.request.onreadystatechange (/snapshot/client/node_modules/ethers/utils/web.js:84:29)
    at exports.XMLHttpRequest.dispatchEvent (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at exports.XMLHttpRequest.handleError (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:532:5)
    at ClientRequest.errorHandler (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:459:14)
    at ClientRequest.emit (events.js:198:13)
    at TLSSocket.socketErrorListener (_http_client.js:401:9)
    at TLSSocket.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
  statusCode: 0,
  responseText:
   'Error: getaddrinfo EAI_AGAIN mainnet.infura.io mainnet.infura.io:443\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)' }
attempting exit

This also happens when running ./fuel --network="mainnet" --rpc="https://mainnet.infura.io/v3/********c40b4d538f126b1e5520eca2"

This is running against an Infura "Core" Account (free up to 100,000 requests per day).

Expected behaviour

Well, I don't really know for sure what I would expect at this point. I mean, I'm running a piece of pre-compiled binary software against an opaque third-party infrastructure provider - I guess I'm expecting it should do more than it does, perhaps allow me to do things like deposit funds from mainnet, then transfer funds to other ETH addresses, and to withdraw somehow back onto mainnet - perhaps via some calls from fuel-js.

But I've got little to no clue about what I expect to see in the logs, about what the node is doing, perhaps something about monitoring the L1 chain for deposits into some kind of contract, like in eth2, or creating / destroying private records of transactions which allow recipients of transfers to prove that they are entitled to some kind of funds.

So, I'll just say this: I expect it to do more than it currently does, and I expect that whatever the error is, that the code should be aware that something like this might happen, and that it could report some message to help me, as the user, to better understand what I should do next (if indeed there's anything I can do).

Environment

image

`Error: socket hang` when connecting to `geth`

Summary

I'm experiencing what might best be described as a UX issue when running fuel against a local geth.

There appears to be issues connecting to geth, resulting in a time-out, no helpful graceful error message, and a stack trace.

Observed behaviour

I run ./fuel --network="mainnet" --rpc="http://localhost:8545" then after some moments, I see this:

{ Error: invalid response - 0
    at exports.XMLHttpRequest.request.onreadystatechange (/snapshot/client/node_modules/ethers/utils/web.js:84:29)
    at exports.XMLHttpRequest.dispatchEvent (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at exports.XMLHttpRequest.handleError (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:532:5)
    at ClientRequest.errorHandler (/snapshot/client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:459:14)
    at ClientRequest.emit (events.js:198:13)
    at Socket.socketOnEnd (_http_client.js:435:9)
    at Socket.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  statusCode: 0,
  responseText:
 'Error: socket hang up\n    at createHangUpError (_http_client.js:332:15)\n    at Socket.socketOnEnd (_http_client.js:435:23)\n    at Socket.emit (events.js:203:15)\n    at endReadableNT (_stream_readable.js:1145:12)\n    at process._tickCallback (internal/process/next_tick.js:63:19)' }
attempting exit

I am running geth with the following settings (with moz-extension parameters anonymised):

geth --http -http.corsdomain moz-extension://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,moz-extension://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --graphql --graphql.corsdomain moz-extension://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,moz-extension://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Expected behaviour

I expect that the issue is caused by a configuration of geth which is too closed, and not configured to allow fuel to connect.

If this is the case, I expect to see:

  • the stdout report a time-out from the RPC endpoint
  • the fuel node to attempt to retry geth
  • the fuel node to provide a helpful hint to what might be required to reconfigure geth (desirable)

If this is not the case, I at least expect to see fuel handle this gracefully, and report something more meaningful.

Environment

image

[feature request] return data logging plugin

Users might want to leverage Fuel's return data, we could allow a simple plugin such that everytime return data is detected, it calls a specific API. This way users could run a Fuel node and filter and database return logs based upon a specific set of criteria.

Proposed API

// ./index.js
const app = require('@fuel-js/client/src/app');

app({
   filter: async (transaction = {}) => {
       transaction.outputs....
   },
})
.then(console.log)
.catch(console.log);

Running it:

node src/index --network="rinkeby" --infura="...."

Better Features for Contract Signing [Feature Request]

Pain Point:
Signing as a contract (API wise), is not as smooth as it could be for the Fuel wallet.

Feature Request:

  1. Better commitWitness: wait on a committed witness, and store it in the wallet local DB for later use in a TX.
  2. Handle committed witnesses better for use with transacting.

RaidGuild Request: indexed.wtf doc edits and additions

Hello blessed devs,

We here at Raid Guild have brought you indexed.wtf and are taking care to make sure the docs we display for each Layer 2 and side-chain project are accurate and filled with information the dev teams would like to highlight specifically. Having easily accessible information about all these solutions will bring more attention to your project.

Please find the markdown for the docs for your project below.

Kindly review, edit and provide any missing details and information at your taste and discretion as project leaders.

Moving forward we aim to keep indexed.wtf as current and beneficial to developers researching the ecosystem as possible. Please feel free at any time to submit an issue or PR to update the displayed information.

Thank you for your attention to this matter.

Best,
The Indexed Army
We stand for accurate data.

www.RaidGuild.org
@chair28980 @kittyslasher

# Fuel Labs Docs
<!-- Please update description if necessary. Please feel free to update/eliminate/include headers below.-->

## Name
Fuel Labs

## Description
Fuel is a permissionless and trustless layer-2 protocol for Ethereum, targeted at low-cost high-throughput value-transfer transactions. Fuel is powered by a highly-optimized optimistic rollup design.

## Consensus Type
[Optimistic Rollup](https://medium.com/matter-labs/optimistic-vs-zk-rollup-deep-dive-ea141e71e075)

## Tx Cost
1350-1600 gas

## Average TPS
500 TPS 

## Governance/validator Token
None

## Transactional Token
 ⧫ ETH + Any ERC20 Token ⧫

## Resources
[Website](https://fuel.sh/)
[Docs](https://docs.fuel.sh/v1.1.0/Introduction/Welcome.html)
[Github](https://github.com/fuellabs)



## Social Media & Community
[Twitter](https://twitter.com/fuellabs_?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor)
[Discord](https://discord.gg/xfpK4Pe)
[Medium](https://fuellabs.medium.com/)

Typescript error due to spelling mistake

Heya, just gave Fuel a try after downloading @ latest and typescript will not run it.
Error:

Error TS2304: Cannot find name 'Promsie'

Pretty obvious it's due to a spelling mistake

Node should halt on password error

When entering a less-than-8 character passphrase, the node should halt immediately instead of continuing until a different error is hit.

✔ Please enter a Fuel wallet encryption passphrase … ***
Error: password must be more than 8 characters
    at wallet (/snapshot/client/src/wallet.js:68:15)
    at process._tickCallback (internal/process/next_tick.js:68:7)
fuel-2021-01-04 7:36:35 PM : Wallet/operator address used: undefined
fuel-2021-01-04 7:36:35 PM : DB: default local db selected.
{ Error: invalid private key (arg="privateKey", reason="exactly 32 bytes required", value="[REDACTED]", length=10, type="string", version=4.0.48)
    at Object.throwError (/snapshot/client/node_modules/ethers/errors.js:76:17)
    at new SigningKey (/snapshot/client/node_modules/ethers/utils/signing-key.js:50:20)
    at new Wallet (/snapshot/client/node_modules/ethers/wallet.js:44:62)
    at config (/snapshot/client/src/config.local.js:178:24)
    at app (/snapshot/client/src/app.js:74:24)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  reason: 'exactly 32 bytes required',
  code: 'INVALID_ARGUMENT',
  arg: 'privateKey',
  value: '[REDACTED]',
  length: 10,
  type: 'string' }
attempting exit

Can't deposit ether into fuel

Here is the sample code with my implementation

import fuel from '@fuel-js/wallet';

// use the window provider key / account / eth_signTypedData_v4 for transaction signing
const k = '..'
const wallet = new fuel.Wallet(null, {
    privateKey: k
});

(async () => {
  // get your address
  console.log('my address', wallet.address);
  
    // make a deposit
    await wallet.deposit('0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', fuel.utils.parseEther('0.0003'));
  
    // make a transfer
    await wallet.transfer('0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', '0xD1d9D81f07e579f77c8C7A4580Bcf1c8F8af09fe', fuel.utils.parseEther('0.0002'));
  
    // listen for new inputs and balance changes
    wallet.on('input', input => {
      console.log('listening for new inputs: ', input);
    });
  
  
  })();

error


/home/rogelio/Code/fuel/node_modules/ethers/errors.js:76
    var error = new Error(message);
                ^
Error: contract not deployed (contractAddress="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", operation="getDeployed", version=4.0.48)
    at Object.throwError (/home/rogelio/Code/fuel/node_modules/ethers/errors.js:76:17)
    at /home/rogelio/Code/fuel/node_modules/ethers/contract.js:353:32
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async Promise.all (index 0)
    at Wallet.deposit (/home/rogelio/Code/fuel/node_modules/@fuel-js/wallet/src/index.js:558:20)

Package only supports Node 12

The package.json file only allows fuel-core to be added to Node 12. If the code is compatible with earlier versions of Node, this restriction should be decreased.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.