Code Monkey home page Code Monkey logo

beet-js's Introduction

BeetJS

BeetJS is a client library for interaction with Beet (https://github.com/bitshares/beet).

Installation

Node module

npm install @beetapp/beet-js

Examples

Examples to try and play around can be found in examples folder. Basically there are two options, library injection and direct calls.

Library injection

Powerful and easy way to integrate Beet is by using injection. Not supported for all chains yet.

List of supported blockchains:

  • BitShares
  • Steem
  • BinanceChain
  • Bitcoin

beet-js's People

Contributors

abitmore avatar clockworkgr avatar dependabot[bot] avatar grctest avatar sschiessl-bcp avatar xeroc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

beet-js's Issues

JSON limit order create

I tried to import a limit order operation to the transaction builder. The example had a transfer which I believe is different syntax from a limit order. I have the json copied below:

{
    "expiration": "2019-06-29T16:41:16",
    "operations": [
        [
            1,
            {
                "expiration": "2019-06-30T16:40:23",
                "seller": "1.2.1595919",
                "fee": {
                    "amount": 143,
                    "asset_id": "1.3.113"
                },
                "amount_to_sell": {
                    "amount": 649045361,
                    "asset_id": "1.3.0"
                },
                "fill_or_kill": false,
                "min_to_receive": {
                    "amount": 31054802,
                    "asset_id": "1.3.113"
                },
                "extensions": []
            }
        ],
        [
            1,
            {
                "expiration": "2019-06-30T16:40:24",
                "seller": "1.2.1595919",
                "fee": {
                    "amount": 143,
                    "asset_id": "1.3.113"
                },
                "amount_to_sell": {
                    "amount": 55809766,
                    "asset_id": "1.3.113"
                },
                "fill_or_kill": false,
                "min_to_receive": {
                    "amount": 1205490946,
                    "asset_id": "1.3.0"
                },
                "extensions": []
            }
        ]
    ],
    "extensions": [],
    "ref_block_num": 24162,
    "signatures": [],
    "ref_block_prefix": 4066567281
}

No response in app

With the beet lib in directory and app open. When running a "vote" direct call on bitshares - no response or activity in app.

Am I missing something?

Screen Shot 2020-03-03 at 1 50 29 PM

Firefox breaks beet-js on Linux

firefox 65.0.1

When executing the bitshares_signedmessage example you get the following:

socket.onopen authenticate rejected ReferenceError: "event is not defined"

Import issues

Is it possible to import this package like the following? import {beet} from '@beetapp/beet-js';

When I try the above I get the following error:

error - lib\beet-js.js (16:20482) @ Object.eval
ReferenceError: self is not defined

Bitshares references 'sats' in buy field

image

let transfer_op = tr.get_type_operation("limit_order_create", {
    fee: {
        amount: 0,
        asset_id: "1.3.0"
    },
    seller: account.id,
    amount_to_sell: {
      amount: ${100000/bids[0].price},
      asset_id: "${approvedMarketID}"
    },
    min_to_receive: {
      amount: 1,
      asset_id: "${symbolID}"
    },
    fill_or_kill: true,
    expiration: 100000
});

I'm trying to buy a single NFT, not a fraction yet the UI states I'm buying 1 'sat' (satoshi?) rather than a whole unit of NFT.

Pull Fields and Generate Transaction

@sschiessl-bcp I would like to allow beet users to pull from a page on my website and generate a transfer operation in beet. The page has a simple paragraph with three variable fields where a user selects from a drop-down menu. These variables are "recipient", "type & amount asset", & "memo content". Could user generate and sign a transfer operation with these variables and inject-raw-tx.html? Thank you.

Bitshare Js Transfer failed with error (Not defined in console)

I would like to point out that with both Bitshare-Js in raw HTML or using Vue boilerplate I get this error whenever I sign and broadcast the transaction

Steps to reproduce it...

<script src="beet-js.js"></script>

<script>
beet.get("BitShares Transfer Example", "BTS_TEST", true).then(app => {
    app.BTS_TEST.transfer(
        {
            to: "jeevan-jot",
            amount:
                {
                    satoshis: 300000,
                    asset_id: "1.3.0"
                }
        }
    ).then(result => {
        console.log("Success", result);
    }).catch(err => {
        console.error(err);
    });
}).catch(err => {
    console.error(err);
});
</script>

Use this html and then make the transaction (Both gives this error BTS_TEST and BTS (Main net))

2019-05-19 (10)
2019-05-19 (11)
2019-05-19 (13)

and the Vue code is...

        let app = await this.$beet.connect()
        console.log(app.getAccount().name)
        console.log(app.getAccount())
        app.transfer({
          to: this.btsname.toString().trim(),
          amount: {
            satoshis: parseInt(this.tbts),
            asset_id: '1.3.0'
          }
        })

(Sorry for those spaces)

2019-05-18 (36)
2019-05-18 (34)

Inconsistent trade sell/price fields?

I have an NFT for sale at 20000 BTS, when I fetch this bid from openexplorer api I have to perform 1/bids[0].price to get "20000 BTS"

However when I create a beet limit_order_create I have to perform 100000/bids[0].price to get 20000 BTS:

let transfer_op = tr.get_type_operation("limit_order_create", {
    fee: {
        amount: 0,
        asset_id: "1.3.0"
    },
    seller: account.id,
    amount_to_sell: {
      amount: ${100000/bids[0].price},
      asset_id: "${approvedMarketID}"
    },
    min_to_receive: {
      amount: 1,
      asset_id: "${symbolID}"
    },
    fill_or_kill: true,
    expiration: 100000
});

image

However NFTEA.F3 with a price of 31705.300007503152 BTS (31,705.3 in DEX) (shown with 1\bids[0].price) when applied with 100000/bids[0].price results in Sell: 317053000000.00006 BTS:

image

What's the correct calculation I should be performing for these amount_to_sell & min_to_receive fields? It seems inconsistent? Is the above error due to the large quantity of BTS decimal places?

Fallback to localhost not working

By trying the samples i get this error:

Firefox can’t establish a connection to the server at wss://local.get-beet.io:60556/.

By watching the code the fallback flag is false:
https://github.com/bitshares/beet-js/blob/master/src/lib/socket.js#L3

By beet README:

While logged-in, Beet exposes a websocket API LOCALLY that can only be accessed by applications running on your computer ...

I think the default should be localhost, i am not sure why the fallback is there and why beet will expose to that url.

At least some docs for clarification about this should be needed, hosts should be maybe in a config file among other variables if we really need them(for me it should just need to try to connect to ws://localhost:60555)

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.