Giter Site home page Giter Site logo

terra-rust's Introduction

Terra Rust

This is a WIP.

No security audit has been performed.

There are currently 5 interesting things

Terra-Rust to help smart contract development

see Smart Contract Dev Notes

Randomness

The API is currently using random numbers via
let mut rng = rand::thread_rng();

Disclaimer

This may steal your money.

This is not investment advice.

Do you own research

Why?

I built this for 2 main reasons.

  1. There was no easy way for me to get the default terra-cli to work on Windows
  2. I wanted a RUST api to use in other things. The CLI is just cream on top.

Environment Variables

some things are used often and repeatedly, so we decided to use environment variables.

TERRARUST_LCD sets the LCD URL. e.g. https://tequila-lcd.terra.dev

TERRARUST_CHAIN set the CHAIN to use e.g. tequila-0004

TERRARUST_SEED_PHRASE the passphrase used in combination with the 24-words to generate the private key

TERRARUST_WALLET the default wallet to use

TERRARUST_GAS_PRICES the gas price to use. e.g. 50ukrw

TERRARUST_GAS_ADJUSTMENT the gas adjustment multiplier to use

TERRARUST_CONTRACT (for smart contract development) your contract to migrate you can also set these in a file called '.env' if you prefer

Documentation

on first install you may want to:

$ terra-rust wallet create default

Help ?

$ terra-rust --help

If you think this was useful, feel free to delegate to the PFC validator. It will help defray the costs.

PFC - Terra/Luna is Pretty Freaking Cool right... feel free to drop me a line

Contribute

Feel free to submit patches/comments/Pull Requests.

We have also set up a Discord channel to discuss this, and other PFC things

terra-rust's People

Contributors

geodimm avatar kryton avatar patternmachine avatar pfc-developer avatar pronvis avatar snoyberg 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

terra-rust's Issues

Too many redirects

When running the code below: (slightly modified version of the example code).

use bitcoin::secp256k1::Secp256k1;
use terra_rust_api::{Terra, GasOptions, PrivateKey, Message};
use terra_rust_api::core_types::{Coin};
use terra_rust_api::messages::MsgSend;

async fn send_tx() {
    // set up the LCD client
    let gas_opts = GasOptions::create_with_gas_estimate("50ukrw",1.4).unwrap();
    let terra = Terra::lcd_client("https://bombay-lcd.terra.dev/", "bombay-12", &gas_opts, None).await.unwrap();

    // generate a private key
    let secp = Secp256k1::new();
    let from_key = PrivateKey::from_words(&secp,"uncle simple tide bundle apart absurd tenant fluid slam actor caught month hip tornado cattle regular nerve brand tower boy alert crash good neck").unwrap();
    let from_public_key = from_key.public_key(&secp);

    // generate the message SEND 1000 uluna from your private key to someone else
    let coin: Coin = Coin::parse("1000uluna").unwrap().unwrap();
    let from_account = from_public_key.account().unwrap();
    let send: Message = MsgSend::create(from_account, "terra1usws7c2c6cs7nuc8vma9qzaky5pkgvm2uag6rh".to_string(), vec![coin]);

    // generate the transaction & calc fees
    let messages = vec![send];
    // and submit the message(s) to the chain
    let resp = terra.submit_transaction_sync(
        &secp,
        &from_key,
        &messages,
        None
    )
        .await;
    println!("{:?}", resp)
}

fn main() {
    let rt = tokio::runtime::Runtime::new().unwrap();
    rt.block_on(send_tx());
}

I'm getting this error:

Err(Reqwest HTTP(s) Error

Caused by:
    0: error following redirect for url (https://bombay-lcd.terra.dev/auth/accounts/terra1rz4mcfwmqkgv7ss2tygpy79ffd33gh32as49j0): too many redirects
    1: too many redirects)

terra-rust-wallet: compile errors due to lack of Sync

I believe this is related exclusively to error handling code. I'm seeing error messages such as the following:

error[E0277]: `*const i8` cannot be shared between threads safely
  --> terra-rust-wallet/src/lib.rs:62:72
   |
62 |         keyring.set_password(&serde_json::to_string(&wallet_internal)?)?;
   |                                                                        ^ `*const i8` cannot be shared between threads safely
   |
   = help: within `KeyringError`, the trait `Sync` is not implemented for `*const i8`
   = note: required because it appears within the type `dbus::ffi::DBusError`
   = note: required because it appears within the type `dbus::Error`
   = note: required because it appears within the type `secret_service::error::SsError`
   = note: required because it appears within the type `KeyringError`
   = note: required because of the requirements on the impl of `From<KeyringError>` for `anyhow::Error`
   = note: required by `std::convert::From::from`

error[E0277]: `*const std::ffi::c_void` cannot be shared between threads safely
  --> terra-rust-wallet/src/lib.rs:62:72
   |
62 |         keyring.set_password(&serde_json::to_string(&wallet_internal)?)?;
   |                                                                        ^ `*const std::ffi::c_void` cannot be shared between threads safely
   |
   = help: within `KeyringError`, the trait `Sync` is not implemented for `*const std::ffi::c_void`
   = note: required because it appears within the type `dbus::ffi::DBusError`
   = note: required because it appears within the type `dbus::Error`
   = note: required because it appears within the type `secret_service::error::SsError`
   = note: required because it appears within the type `KeyringError`
   = note: required because of the requirements on the impl of `From<KeyringError>` for `anyhow::Error`
   = note: required by `std::convert::From::from`

I'll try to investigate this a bit further myself.

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.