Giter VIP home page Giter VIP logo

monorepo's Introduction

bitcoin-computer-logo

Bitcoin Computer

A smart contract system for Bitcoin and Litecoin
website · docs

This monorepo contains everything you need to build smart contract based applications. To get started, follow the readme file of Lib.

Core

  • Lib - A Javascript library for smart contracts
  • Node - Server side infrastructure for smart contracts
  • NakamotoJS - A Javascript library for building and parsing transactions

Applications

Standard Contracts

  • TBC20 - An implementation of the ERC20 Fungible Token Standard
  • TBC721 - An implementation of the ERC721 Non-Fungible Token Standard
  • Swap - An implementation of TBC721 swap and sale contracts

Templates

Documentation

  • Docs - The sources for the documentation
  • Website - The sources for the website

Legal Notice

See here.

Getting Help

Have a look at the docs. If you have any questions, please let us know on Telegram, Twitter, or by email [email protected].

monorepo's People

Contributors

clemensley avatar eltociear avatar jonty007 avatar ltardivo avatar unknown-kush 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

monorepo's Issues

Optimize litecoind for testing

We need to modify the code so that the halving interval on regtest is infinite. This allows an application developper to run many tests in a row without having to restart the node.

Add support for DOGE

First, have a look at the PRs for the Pepecoin integration:
#227
https://github.com/Bitcoin-Computer-Secrets/secret-repo/pull/323

  • Create a Doge docker image. We can get started with this Dockerfile. The author is using intel architecture, we will need to change it (dogecoin-1.14.7-arm-linux-gnueabihf.tar.gz. For now we can try with arm. Later we can create a Doge multiplatform docker image.
  • Create a file /chain-setup/doge-regtest/docker-compose-local-doge-regtest.yml file, use ltc-regtest as inspiration
  • Change the image in the node service of the /chain-setup/doge-regtest/docker-compose-local-doge-regtest.yml file, to the one created in the first step.
  • Modify NakamotJS with the network configuration for DOGE. We have to search online, or ask in a DOGE coin social media group

NOTES:

Explorer: unresponsive after switching to tBTC

After I switched to tBTC, the UI becomes unresponsive, probably due to the RPC URLs not working but the UI should not freeze nonetheless.

Screen.Recording.2024-04-19.at.00.01.23.mov

Login: Dark mode issue

When in dark mode, the text fields have white font on a white background due to a bug in flowbite. We have to perform some css magic to fix it

Fix the nodejs template

Make sure that the following is pre-configured:

  • Typescript
  • testing env
  • linter
  • prettier

Make sure that the readme file works and describes all functionality (e.g. how to test, lint, ...)

Make a wallet component

Using the drawer component. We want to use the wallet component in the explorer and the cra-template

Deal with block reorgs

TODO at DB level

  • Add block_hash to output and input table
  • Create blocks_header table (block_height, block_hash, prev_hash?)
  • Add new table syncBlockStatus (block_height)
  • Rename table syncStatus to syncTxStatus

PROCESSES

SYNC_TX (parallel): KEEP SYNCING

  • But instead of asking to RPC the next block, get it from DB blocks_header table
  • Always insert into "Input" and "Output" tables. If "duplicated key" error is received over output.pk, the zmq already inserted the rows. This means we should update the block_hash value of all the rows of that block_id.

SYNC_BLOCK (sequential):

  • Fill block_header table UNTIL REACHING THE TIP (do not confuse with the initialization process for blockheads download, both cases we receive an error from the node)

  • Detect block reorganization (for each block synced):

  • Get from RPC the current_block to sync

  • Select previous block and get its hash: #"SELECT block_hash FROM block_headers where block_height == current_block -1"

  • Check if the current_block.prev_hash matches the previous block hash. If not, launch "searchChainForkOrigin(current_block)" function

  • Search the origin of the fork (current_block)

  • Ask to RPC for the current_block. Compare with block_headers, if different, continue backwards (get current_block -1 from RPC, compare with block_headers. If different, continue backwards...and so on). If matching, mark range of blocks [found + 1, current_block] to be deleted, and resync from block "found".

  • In resume status, check if there are orphaned blocks, update input and output blockHashes, delete blocks

AGED TXs on mempool

  • Periodically check all tx over mempool to remove the aged ones (see RPC getrawmempool)

Some example explanied on block reogrs
https://medium.com/@nicolas.vargas_35315/what-are-blockchain-reorgs-and-how-to-detect-them-when-consuming-nodes-762300f4512e

RPC getchaintips
https://developer.bitcoin.org/reference/rpc/getchaintips.html

How to simulate a block reorg on regtest
https://bitcoin.stackexchange.com/questions/114044/how-can-i-simulate-a-reorg-for-testing

Computer: return expression from sync

It currently requires two http requests to determine the value of a smart object and the smart contract that created it. However when determining the value the smart contract needs to be determined anyway. So we can return that smart contract in addition to the value without computational overhead.

Build new NFT app

The new app can replace the old nft app that is not working anymore

  • Clone the CRA-template
  • Plug in the nft contract from the TBC721 project
  • Add a deploy script like in the explorer using the methods of the helper classes (note how the module specifier works) [New]
  • Make it possible to add a url to an image when creating an nft and show that image on the nft page
  • Create custom page "sell offer" from swaps/sale.test.ts (when only the nft to be sold is known)

Monorepo: Add secp256 project

  • The current package @bitcoincomputer/tiny-secp256 should be renamed to @bitcoincomputer/secp256
  • The new package version should be 0.17.0-beta.3

Explorer: missing .env issue

If a user forgets to copy .env.example into .env the app is not loading, and an error “url” not found is logged at the console. We should notify the user on the website to copy the .env.example file instead

Login: dissapearing modal issue

The modal sometimes disappears when editing the fields in a certain order (best to test in the explorer)

To recreate try to select the complete url with your mouse

Make a drawer component

We can look at the explorer for how we use the drawer. The component should be generic so that it can be reused for different purposes

Fix buffer usage in NakamotoJs

In NakamotoJS:

  • Make sure that we are always using Buffer from the NPM package and never the node buffer
  • Make sure we are using the correct typeforce buffer (Buffer vs BufferN) everywhere

Implement withdraws

For the wallet component:

  • Add a form to the wallet sidebar with
    • a text field amount
    • a text field "To" for an address
    • button "withdraw"
  • When the button is pressed we call computer.send(amount, to)

Next, investigate if we can call the withdraw function immediately after the swap function in the same expression, so that there are never any payment objects to begin with.

If that fails, we can try something along the lines of the below:

Then for the nft app

  • Add a form to the wallet sidebar with
    • a text field amount
    • a text field "To" for an address
    • button "withdraw"
  • When the button is pressed
    • we first try to service the request from the normal utxos by calling computer.getBalance. If balance is sufficient we call computer.send(amount, to)
    • otherwise, we have to call the withdraw function on some payment objects first and then call the computer.withdraw function.

Update dependencies

We should update all packages to their latest version if possible (like yarn upgrade and yarn upgrade latest). Afaik relevant commands are:

https://docs.npmjs.com/updating-packages-downloaded-from-the-registry
https://docs.npmjs.com/cli/v10/commands/npm-outdated

We have to make sure that all tests (including browser tests) are still passing. If some package puts up a fight we can keep the older version. However we should take care to update all packages with known security issues:

https://github.com/bitcoin-computer/monorepo/security/dependabot

Computer: Add support for arbitrary scripts

We should make it possible for the developer to specify input and output scripts in smart contracts. This will enable advanced applications that cannot be currently built. For example one can create a smart object that can only be updated when some BitVM script evaluates to true.

Upgrade CRA-template

The template should have the following functionality:

  • Create smart object (we can use counter as an example)
  • Show all smart objects of that type
  • Show my smart objects of that type

Explorer: start script doesn't work on macos

Fresh clone, npm i in the root, and then running npm start dev in packages/explorer lead to this:

 ~/projects/bitcoin-computer/packages/explorer | on main !1 ------------------------------------------------------- at 00:06:40 
> npm run start     

> @bitcoin-computer/[email protected] start
> PORT=1032 react-scripts start

validateOptions is not a function
npm ERR! Lifecycle script `start` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: @bitcoin-computer/[email protected] 

on MacOS
node v20.10.0
npm 10.2.3

Fix the CRA template

We should

  • use the auth component
  • use new wallet component
  • use flowbite everywhere
  • fix the readme if necessary

Explorer: fix error when clicking outside the modal

If I first click in the modal window, and then outside of the modal, an error is displayed:

Cannot read properties of null (reading 'remove')
TypeError: Cannot read properties of null (reading 'remove')
    at Modal._destroyBackdropEl (http://localhost:1032/static/js/bundle.js:23043:49)
    at Modal.hide (http://localhost:1032/static/js/bundle.js:23134:12)
    at Modal._handleOutsideClick (http://localhost:1032/static/js/bundle.js:23069:12)
    at HTMLDivElement._clickOutsideEventListener (http://localhost:1032/static/js/bundle.js:23050:15)

Explorer: Loader needed when broadcasting tx

When a user presses the button “call deploy” or “call function” a loading bar should be show, bc we are waiting to the response of the deploy, otherwise is odd, we don’t know what is going on

Explorer: use URLs instead of local storage for state

I was trying out the explorer and it looks like local storage is used to save the network. Wouldn't it be better to use URL routes like /:network for this? This would also enable linking to specific networks, as now it shows different values depending on what you select.

NFT app improvements

  • The NFT class should store the following data: title, artist
  • The NFT page in the app should display the image in top, underneath the title in larger bold font (maybe H2 or H3) and beneath the artist (see https://flowbite.com/docs/typography/headings/#heading-two-h2)
  • On the homepage we should display flowbite cards as shown here: https://flowbite.com/docs/components/card/#card-with-image
  • On the mint page we should reposition the image to make it look nice
  • there should be a heading "List for sale" on the NFT site
  • It would be nice if the NFT on the NFT site would be bigger
  • If an NFT is listed, it should say "You listed this NFT for 2 LTC" for the seller
  • If an NFT is listed, it should have a button "Buy for 2 LTC" for the buyer
  • There should be a way to "unlist" an NFT
  • On the wallet it should say in the "Fund" section: "Click the balance reload button after funding"
  • On the mint page, we should have a caption "Mint NFT"
  • When an nft is minted, it should say "Congratiolations! You minted an nft. Click here to see it.". "Here" should link to the nft site
  • On the NFT site, there should be the tile in a big caption, then the author in normal text, then the image, then a small caption "List for sale", and then the list for sale form
  • On the NFT site, if you own an NFT and it is listed, it should not have a box with the listing price, instead it should just say "You listed this NFT for 2 RLTC"
  • We should hide the "List this NFT" when it is listed

Lib: Enable unlimited regtest

We want to enable users to use the faucet without having to run a node

  • Set the configuration by default on our custom regtest node
  • Update the README files (include instructions to run the faucet on the computer object)

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.