Skip to content

Commit

Permalink
sway 0.40.1 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz2891 authored Jun 15, 2023
1 parent e2e99de commit dd5d820
Show file tree
Hide file tree
Showing 22 changed files with 209 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.69.0
FORC_VERSION: 0.35.5
FORC_VERSION: 0.40.1

jobs:
test-redstone-fuel-sdk:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
out
target
.DS_Store
.DS_Store
/.idea/
4 changes: 2 additions & 2 deletions Forc.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[[package]]
name = 'core'
source = 'path+from-root-2C66FC65A00ECA96'
source = 'path+from-root-D62A8C57DD8D2801'

[[package]]
name = 'redstone'
Expand All @@ -9,5 +9,5 @@ dependencies = ['std']

[[package]]
name = 'std'
source = 'git+https://github.com/fuellabs/sway?tag=v0.35.5#49eae2dd93a1957e2a2c2fb3f51b11eb3791fc24'
source = 'git+https://github.com/fuellabs/sway?tag=v0.40.1#48104d0bde0d343154a5bc39a310092532883235'
dependencies = ['core']
2 changes: 1 addition & 1 deletion Forc.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
authors = ["Łukasz Kalbarczyk"]
entry = "lib.sw"
forc-version = "0.35.0"
forc-version = "0.40.1"
license = "Apache-2.0"
name = "redstone"
organization = "RedStone"
117 changes: 94 additions & 23 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,23 +1,94 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Business Source License 1.1

License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
"Business Source License" is a trademark of MariaDB Corporation Ab.

Based on the Uniswap V3 license (https://github.com/Uniswap/v3-core/blob/main/LICENSE)

---

Parameters

Licensor: Distributed Data Labs

Licensed Work: Redstone Oracles Monorepo
The Licensed Work is (c) 2022 Distributed Data Labs

---

Terms

The Licensor hereby grants you the right to copy, modify, create derivative
works, redistribute, and make non-production use of the Licensed Work. The
Licensor may make an Additional Use Grant, above, permitting limited
production use.

Effective on the Change Date, or the fourth anniversary of the first publicly
available distribution of a specific version of the Licensed Work under this
License, whichever comes first, the Licensor hereby grants you rights under
the terms of the Change License, and the rights granted in the paragraph
above terminate.

If your use of the Licensed Work does not comply with the requirements
currently in effect as described in this License, you must purchase a
commercial license from the Licensor, its affiliated entities, or authorized
resellers, or you must refrain from using the Licensed Work.

All copies of the original and modified Licensed Work, and derivative works
of the Licensed Work, are subject to this License. This License applies
separately for each version of the Licensed Work and the Change Date may vary
for each version of the Licensed Work released by Licensor.

You must conspicuously display this License on each original or modified copy
of the Licensed Work. If you receive the Licensed Work in original or
modified form from a third party, the terms and conditions set forth in this
License apply to your use of that work.

Any use of the Licensed Work in violation of this License will automatically
terminate your rights under this License for the current and all other
versions of the Licensed Work.

This License does not grant you any right in any trademark or logo of
Licensor or its affiliates (provided that you may use a trademark or logo of
Licensor as expressly required by this License).

TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
TITLE.

MariaDB hereby grants you permission to use this License’s text to license
your works, and to refer to it using the trademark "Business Source License",
as long as you comply with the Covenants of Licensor below.

---

Covenants of Licensor

In consideration of the right to use this License’s text and the "Business
Source License" name and trademark, Licensor covenants to MariaDB, and to all
other recipients of the licensed work to be provided by Licensor:

1. To specify as the Change License the GPL Version 2.0 or any later version,
or a license that is compatible with GPL Version 2.0 or a later version,
where "compatible" means that software provided under the Change License can
be included in a program with software provided under GPL Version 2.0 or a
later version. Licensor may specify additional Change Licenses without
limitation.

2. To either: (a) specify an additional grant of rights to use that does not
impose any additional restriction on the right granted in this License, as
the Additional Use Grant; or (b) insert the text "None".

3. To specify a Change Date.

4. Not to modify this License in any other way.

---

Notice

The Business Source License (this document, or the "License") is not an Open
Source license. However, the Licensed Work will eventually be made available
under an Open Source License, as stated in this License.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


format:
forc-fmt

test: format
forc test
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This repository is the integral part of the https://github.com/redstone-finance/redstone-oracles-monorepo repository,
especially of the fuel-connector package (https://github.com/redstone-finance/redstone-oracles-monorepo/tree/main/packages/fuel-connector)
and is subject of all their licenses.

10 changes: 10 additions & 0 deletions src/core.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library;

pub mod sample;
pub mod validation;
pub mod aggregation;
pub mod config;
pub mod crypto;
pub mod protocol;
pub mod config_validation;
pub mod processor;
15 changes: 4 additions & 11 deletions src/aggregation.sw → src/core/aggregation.sw
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
library aggregation;

dep utils/vec;
dep utils/numbers;
library;

use std::{u256::U256, vec::*};
use vec::sort;
use numbers::*;
use ::utils::vec::sort;
use ::utils::numbers::*;

pub fn aggregate_results(results: Vec<Vec<U256>>) -> Vec<U256> {
let mut aggregated = Vec::new();
Expand All @@ -24,10 +21,6 @@ pub fn aggregate_results(results: Vec<Vec<U256>>) -> Vec<U256> {
fn aggregate_values(values: Vec<U256>) -> U256 {
let mut values = values;
sort(values);
let mut j = 0;
while (j < values.len) {
j += 1;
}

let mid = values.len / 2;

Expand Down Expand Up @@ -111,5 +104,5 @@ fn test_aggregate_three_other_values() {
#[test(should_revert)]
fn test_aggregate_zero_values() {
let data = Vec::new();
aggregate_values(data);
let _ = aggregate_values(data);
}
6 changes: 2 additions & 4 deletions src/config.sw → src/core/config.sw
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
library config;

dep utils/vec;
library;

use std::{option::*, u256::U256};
use vec::{value_index, value_index_b256};
use ::utils::vec::{value_index, value_index_b256};

pub struct Config {
signers: Vec<b256>,
Expand Down
16 changes: 6 additions & 10 deletions src/config_validation.sw → src/core/config_validation.sw
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
library config_validation;

dep protocol;
dep config;
dep validation;
dep utils/numbers;
library;

use std::u256::U256;
use protocol::{DataPackage, Payload};
use config::Config;
use validation::*;
use numbers::*;
use ::core::protocol::{DataPackage, Payload};
use ::core::config::Config;
use ::core::validation::*;
use ::utils::numbers::*;

/// 655360000 + feed_index
pub const INSUFFICIENT_SIGNER_COUNT = 0x2710_0000;
Expand Down Expand Up @@ -54,6 +49,7 @@ impl Validation for Config {

if s.is_none() {
log(data_package.signer_address.value);
log(index);
// revert(SIGNER_NOT_RECOGNIZED + index);
}

Expand Down
13 changes: 6 additions & 7 deletions src/crypto.sw → src/core/crypto.sw
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
library crypto;

dep utils/bytes;
dep sample;
library;

use std::{
b256::*,
b512::*,
bytes::*,
constants::ZERO_B256,
ecr::{
ec_recover,
EcRecoverError,
Expand All @@ -16,8 +14,9 @@ use std::{
vm::evm::ecr::ec_recover_evm_address,
vm::evm::evm_address::EvmAddress,
};
use bytes::*;
use sample::{SAMPLE_ID_V27, SAMPLE_ID_V28, SampleDataPackage};
use ::utils::bytes::*;

use ::core::sample::{SAMPLE_ID_V27, SAMPLE_ID_V28, SampleDataPackage};

pub fn recover_signer_address(signature_bytes: Bytes, signable_bytes: Bytes) -> EvmAddress {
let (r_bytes, mut s_bytes) = signature_bytes.slice_tail_offset(32, 1);
Expand All @@ -36,7 +35,7 @@ fn recover_public_address(
v: u64,
msg_hash: b256,
) -> Result<EvmAddress, EcRecoverError> {
let mut v_256: b256 = 0x0000000000000000000000000000000000000000000000000000000000000000;
let mut v_256: b256 = ZERO_B256;
if (v == 28) {
v_256 = 0x0000000000000000000000000000000000000000000000000000000000000001;
}
Expand Down
Loading

0 comments on commit dd5d820

Please sign in to comment.