Sway-lib-core - Sway standard library core primitives.

Overview

lib-core

This Sway project contains core operators and extremely primitive logic for use in the standard library of the Sway programming language.

Usage

To build this project, you must have installed forc. Once forc is installed, run forc build in the root of this project to build it.

You might also like...
Rust library that can be reset if you think it's slow

GoodbyeKT Rust library that can be reset if you think it's slow

Simple library to host lv2 plugins. Is not meant to support any kind of GUI.

lv2-host-minimal Simple library to host lv2 plugins. Is not meant to support any kind of GUI. Host fx plugins (audio in, audio out) Set parameters Hos

Extreme fast factor expression & computation library for quantitative trading in Python.

Extreme fast factor expression & computation library for quantitative trading in Python.

Demo for the swash font library

Demo for the swash crate See the swash repo or crate for the actual project. This is a chunk of very rough code.

Agent library for Internet Computer, in Dart

An agent library built for Internet Computer, a plugin package for dart and flutter apps. Developers can build ones to interact with Dfinity's blockchain directly.

Totally Speedy Transmute (TST) is a library providing a small, performance oriented, safe version of std::mem::transmute

Totally Speedy Transmute An evil spiritual successor to Totally Safe Transmute What is it? Totally Speedy Transmute (TST) is a library providing a sma

📜 A pci.ids-compliant library for getting information about available PCI devices.

aparato A pci.ids-compliant library for getting information about available PCI devices. Usage Add the following to your project's Cargo.toml file: ap

Notion Offical API client library for rust

Notion API client library for rust.

Rust library for program synthesis of string transformations from input-output examples 🔮

Synox implements program synthesis of string transformations from input-output examples. Perhaps the most well-known use of string program synthesis in end-user programs is the Flash Fill feature in Excel. These string transformations are learned from input-output examples.

Comments
  • Split `eq` out of `Ord` and put it in `Eq`

    Split `eq` out of `Ord` and put it in `Eq`

    I've done a fair bit of testing on this, optimized the ge and le methods with some in-lining of assembly, not a perfect solution but presently there isn't a neater way to do this in Sway, and with how core works no imported methods can be used for abstraction. But until this then this solution should move out that trait so @nfurfaro can begin work on his end. Lmk if there is anything I missed, tried to catch everything I could though

    enhancement 
    opened by ControlCplusControlV 5
  • Add in rsh and lsh operations

    Add in rsh and lsh operations

    Added in the lsh and rsh operators to the core sway now that FuelLabs/sway/pull/588 is fixed. I will added tests to core sway library after I try to get >> and << implemented. Tested this though locally on forc 0.2.1 and it works fine calling .rsh on a uint64. Also implemented in the same way all other traits have been for the core library.

    Hopefully his can provide people looking for bit shifting functionality with something until >> and << are implemented

    enhancement 
    opened by ControlCplusControlV 2
  • Implement

    Implement "modulo" function for uint types

    Implemented modulo function using a "Mod" trait, has worked in my tests. Followed the code style of the other ops in just wrapping the opcode in a callable function with an explicit return type.

    Adding tests here in case its helpful for CI

    main.sw

    contract;
    
    abi TestContract {
      fn sqrtu64(gas_: u64, amount_: u64, coin_: b256, amount: u64) -> u64;
      fn sqrtu32(gas_: u64, amount_: u64, coin_: b256, amount: u32) -> u64;
      fn sqrtu16(gas_: u64, amount_: u64, coin_: b256, amount: u16) -> u64;
      fn sqrtu8(gas_: u64, amount_: u64, coin_: b256, amount: u8) -> u64;
    
    }
    
    impl TestContract for Contract {
      fn sqrtu64(gas_: u64, amount_: u64, color_: b256, amount: u64) -> u64 {
        let value:u64 = amount % 10;
    
        value
      }
      fn sqrtu32(gas_: u64, amount_: u64, color_: b256, amount: u32) -> u64 {
        let value:u32 = amount % 10;
    
        value
      }
      fn sqrtu16(gas_: u64, amount_: u64, color_: b256, amount: u16) -> u64 {
        let value:u16 = amount % 10;
    
        value
      }
      fn sqrtu8(gas_: u64, amount_: u64, color_: b256, amount: u8) -> u64 {
        let value:u8 = amount % 10;
    
        value
      }
    }
    

    and

    harness.rs

    use fuel_tx::Salt;
    use fuels_abigen_macro::abigen;
    use fuels_rs::contract::Contract;
    use rand::rngs::StdRng;
    use rand::{Rng, SeedableRng};
    
    // Generate Rust bindings from our contract JSON ABI
    abigen!(MyContract, "./my-contract-abi.json");
    
    #[tokio::test]
    async fn harness() {
        let rng = &mut StdRng::seed_from_u64(2322u64);
    
        // Build the contract
        let salt: [u8; 32] = rng.gen();
        let salt = Salt::from(salt);
        let compiled = Contract::compile_sway_contract("./", salt).unwrap();
    
        // Launch a local network and deploy the contract
        let (client, contract_id) = Contract::launch_and_deploy(&compiled).await.unwrap();
    
        let contract_instance = MyContract::new(compiled, client);
    
        // Call `initialize_counter()` method in our deployed contract.
        // Note that, here, you get type-safety for free!
        let result = contract_instance
            .sqrtu32(100)
            .call()
            .await
            .unwrap();
    
        assert_eq!(0, result);
    
        // Call `increment_counter()` method in our deployed contract.
        let result = contract_instance
            .sqrtu64(15)
            .call()
            .await
            .unwrap();
    
        assert_eq!(5, result);
    }
    

    tested on forc version v0.1.9

    enhancement 
    opened by ControlCplusControlV 2
  • change author to authors in Forc.toml

    change author to authors in Forc.toml

    Updating 'Forc.toml' to use authors instead of author. This enables compatibility with the change being made in this PR https://github.com/FuelLabs/sway/pull/822

    enhancement 
    opened by JoshuaBatty 1
Releases(v0.1.0)
Owner
Fuel Labs
Fuel Labs is a group focused on sustainable blockchain scaling with optimistic rollups.
Fuel Labs
RustSBI support on SiFive FU740 board; FU740 is a five-core heterogeneous processor with four SiFive U74 cores, and one SiFive S7 core

RustSBI 在 HiFive Unmatched 主板的支持软件 这个项目的目的是在SiFive HiFive Unmatched主板上支持RustSBI。 RustSBI是一个引导程序环境;主板上电时,RustSBI将会先行启动,而后,它将会找到一个可引导的操作系统,引导启动这个操作系统。 在

RustSBI 15 Dec 1, 2022
Alternative basic focus movement for the sway and i3 window managers.

sway-overfocus Alternative basic focus movement for the sway and i3 window managers. The primary goal of this program is to create one set of keybinds

null 42 Oct 23, 2022
Rust implementation for Wlroots (Sway, Wayfire, Hikari, River, etc.) of Gnome Screenshot and Idle DBUS Server, which Upwork uses to capture the screen as proof of work.

?? upwork-wlroots-bridge ?? Rust Implementation for Wlroots (Sway, Wayfire, Hikari, River, etc.) of Gnome Screenshot and Idle DBUS Server (with extra

Daniel Moretti V. 4 Jan 2, 2023
Rust lib for Scaleway API

Notes This Scaleway API Crate is created and maintained by Qovery and used in production in the Qovery Engine. This project relies on OpenAPI Generato

Qovery 5 Nov 10, 2022
An example of Brainf*** JIT-compiler with only the standard library.

jit-compiler An example of Brainf*** JIT-compiler with only the standard library. Prerequisite Rust(1.56.0-nightly or later, but it must work kind of

Akihito KIRISAKI 18 Jan 22, 2022
Paru is your standard pacman wrapping AUR helper with lots of features and minimal interaction.

Paru Feature packed AUR helper Description Paru is your standard pacman wrapping AUR helper with lots of features and minimal interaction. Installatio

Lulu 4k Jan 9, 2023
This is a Discord bot written in Rust to translate to and from the Bottom Encoding Standard using bottom-rs and Serenity.

bottom-bot This is a Discord bot written in Rust to translate to and from the Bottom Encoding Standard using bottom-rs and Serenity. Ever had this pro

Bottom Software Foundation 11 Dec 10, 2022
A tool to calculate mean and standard deviation from multiple tests using PageSpeed Insights API.

psi-sample PSI Test tool is an open source tool to assist web developers that runs Page Speed Insight test manually! Installing To install the psi-tes

Igor Brasileiro 14 Sep 10, 2022
A standard for fungible tokens on Move.

Move Program Kit (MPK) The Move Program Kit (MPK) is a collection of software written in the Move programming language for the Aptos blockchain. Modul

Menlo Labs 6 Jul 25, 2022
The batteries for core that you never knew you needed.

core+ The batteries for core that you never knew you needed: core+ coreplus documentation Core+ contains types that make it possible to write no_std l

Lachlan Sneff 12 May 11, 2022