mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-23 03:59:22 +00:00
Create a dedicated crate for the extension
This commit is contained in:
parent
5583bf3447
commit
43c4487804
6 changed files with 115 additions and 97 deletions
102
Cargo.lock
generated
102
Cargo.lock
generated
|
@ -1002,9 +1002,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "concurrent-queue"
|
name = "concurrent-queue"
|
||||||
version = "1.2.2"
|
version = "1.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3"
|
checksum = "83827793632c72fa4f73c2edb31e7a997527dd8ffe7077344621fc62c5478157"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cache-padded",
|
"cache-padded",
|
||||||
]
|
]
|
||||||
|
@ -1268,9 +1268,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.5"
|
version = "0.1.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2ccfd8c0ee4cce11e45b3fd6f9d5e69e0cc62912aa6a0cb1bf4617b0eba5a12f"
|
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"generic-array 0.14.5",
|
"generic-array 0.14.5",
|
||||||
"typenum",
|
"typenum",
|
||||||
|
@ -1820,7 +1820,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers"
|
name = "ethers"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ethers-addressbook",
|
"ethers-addressbook",
|
||||||
"ethers-contract",
|
"ethers-contract",
|
||||||
|
@ -1835,7 +1835,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers-addressbook"
|
name = "ethers-addressbook"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ethers-core",
|
"ethers-core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
@ -1846,7 +1846,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers-contract"
|
name = "ethers-contract"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ethers-contract-abigen",
|
"ethers-contract-abigen",
|
||||||
"ethers-contract-derive",
|
"ethers-contract-derive",
|
||||||
|
@ -1864,7 +1864,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers-contract-abigen"
|
name = "ethers-contract-abigen"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"Inflector",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
@ -1886,7 +1886,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers-contract-derive"
|
name = "ethers-contract-derive"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ethers-contract-abigen",
|
"ethers-contract-abigen",
|
||||||
"ethers-core",
|
"ethers-core",
|
||||||
|
@ -1900,7 +1900,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers-core"
|
name = "ethers-core"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec 0.7.2",
|
"arrayvec 0.7.2",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -1931,7 +1931,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers-etherscan"
|
name = "ethers-etherscan"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ethers-core",
|
"ethers-core",
|
||||||
"getrandom 0.2.7",
|
"getrandom 0.2.7",
|
||||||
|
@ -1947,7 +1947,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers-middleware"
|
name = "ethers-middleware"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"ethers-contract",
|
"ethers-contract",
|
||||||
|
@ -1971,7 +1971,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers-providers"
|
name = "ethers-providers"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"auto_impl",
|
"auto_impl",
|
||||||
|
@ -2005,7 +2005,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers-signers"
|
name = "ethers-signers"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"coins-bip32",
|
"coins-bip32",
|
||||||
|
@ -2022,7 +2022,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ethers-solc"
|
name = "ethers-solc"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
source = "git+https://github.com/gakonst/ethers-rs#ba00f549dd05e72fed7f00703f29752324645172"
|
source = "git+https://github.com/gakonst/ethers-rs#13ce18fd3b0f995183ce5cc14a85133e28f994dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"colored",
|
"colored",
|
||||||
|
@ -2716,9 +2716,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gimli"
|
name = "gimli"
|
||||||
version = "0.26.1"
|
version = "0.26.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4"
|
checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fallible-iterator",
|
"fallible-iterator",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
@ -2827,9 +2827,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.12.2"
|
version = "0.12.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "607c8a29735385251a339424dd462993c0fed8fa09d378f259377df08c126022"
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
]
|
]
|
||||||
|
@ -3127,7 +3127,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
|
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown 0.12.2",
|
"hashbrown 0.12.3",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4485,7 +4485,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6566c70c1016f525ced45d7b7f97730a2bafb037c788211d0c186ef5b2189f0a"
|
checksum = "6566c70c1016f525ced45d7b7f97730a2bafb037c788211d0c186ef5b2189f0a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hash-db",
|
"hash-db",
|
||||||
"hashbrown 0.12.2",
|
"hashbrown 0.12.3",
|
||||||
"parity-util-mem",
|
"parity-util-mem",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4713,19 +4713,6 @@ version = "0.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
|
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "multisig-serai"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"ink_env",
|
|
||||||
"ink_lang",
|
|
||||||
"ink_metadata",
|
|
||||||
"ink_primitives",
|
|
||||||
"ink_storage",
|
|
||||||
"parity-scale-codec",
|
|
||||||
"scale-info",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "multistream-select"
|
name = "multistream-select"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
|
@ -4870,9 +4857,9 @@ checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.24.1"
|
version = "0.24.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9"
|
checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
@ -5085,9 +5072,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "os_str_bytes"
|
name = "os_str_bytes"
|
||||||
version = "6.1.0"
|
version = "6.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
|
checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "owning_ref"
|
name = "owning_ref"
|
||||||
|
@ -5337,7 +5324,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c32561d248d352148124f036cac253a644685a21dc9fea383eb4907d7bd35a8f"
|
checksum = "c32561d248d352148124f036cac253a644685a21dc9fea383eb4907d7bd35a8f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"hashbrown 0.12.2",
|
"hashbrown 0.12.3",
|
||||||
"impl-trait-for-tuples",
|
"impl-trait-for-tuples",
|
||||||
"parity-util-mem-derive",
|
"parity-util-mem-derive",
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
|
@ -7520,6 +7507,28 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serai-extension"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"ink_env",
|
||||||
|
"ink_lang",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serai-multisig"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"ink_env",
|
||||||
|
"ink_lang",
|
||||||
|
"ink_metadata",
|
||||||
|
"ink_primitives",
|
||||||
|
"ink_storage",
|
||||||
|
"parity-scale-codec",
|
||||||
|
"scale-info",
|
||||||
|
"serai-extension",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serai-node"
|
name = "serai-node"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -8982,19 +8991,6 @@ version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "token-serai"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"ink_env",
|
|
||||||
"ink_lang",
|
|
||||||
"ink_metadata",
|
|
||||||
"ink_primitives",
|
|
||||||
"ink_storage",
|
|
||||||
"parity-scale-codec",
|
|
||||||
"scale-info",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.20.0"
|
version = "1.20.0"
|
||||||
|
@ -9185,7 +9181,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d32d034c0d3db64b43c31de38e945f15b40cd4ca6d2dcfc26d4798ce8de4ab83"
|
checksum = "d32d034c0d3db64b43c31de38e945f15b40cd4ca6d2dcfc26d4798ce8de4ab83"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hash-db",
|
"hash-db",
|
||||||
"hashbrown 0.12.2",
|
"hashbrown 0.12.3",
|
||||||
"log",
|
"log",
|
||||||
"rustc-hex",
|
"rustc-hex",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
|
|
@ -17,6 +17,7 @@ members = [
|
||||||
"substrate/consensus",
|
"substrate/consensus",
|
||||||
"substrate/node",
|
"substrate/node",
|
||||||
|
|
||||||
|
"contracts/extension",
|
||||||
"contracts/multisig",
|
"contracts/multisig",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
16
contracts/extension/Cargo.toml
Normal file
16
contracts/extension/Cargo.toml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[package]
|
||||||
|
name = "serai-extension"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "An ink! extension for exposing Serai to ink"
|
||||||
|
license = "AGPL-3.0-only"
|
||||||
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
ink_env = { version = "3", default-features = false }
|
||||||
|
ink_lang = { version = "3", default-features = false }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["std"]
|
||||||
|
std = ["ink_env/std"]
|
||||||
|
ink-as-dependency = []
|
35
contracts/extension/src/lib.rs
Normal file
35
contracts/extension/src/lib.rs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
|
use ink_lang as ink;
|
||||||
|
use ink_env::{Environment, DefaultEnvironment, AccountId};
|
||||||
|
|
||||||
|
#[ink::chain_extension]
|
||||||
|
pub trait SeraiExtension {
|
||||||
|
type ErrorCode = ();
|
||||||
|
|
||||||
|
/// Returns the amount of active validators on the current chain.
|
||||||
|
#[ink(extension = 0, handle_status = false, returns_result = false)]
|
||||||
|
fn active_validators_len() -> u16;
|
||||||
|
|
||||||
|
/// Returns the ID for the current validator set for the current chain.
|
||||||
|
// TODO: Decide if this should be an increasing unsigned integer instead of a hash.
|
||||||
|
#[ink(extension = 1, handle_status = false, returns_result = false)]
|
||||||
|
fn validator_set_id() -> [u8; 32];
|
||||||
|
|
||||||
|
/// Returns if the specified account is an active validator for the current chain.
|
||||||
|
#[ink(extension = 2, handle_status = false, returns_result = false)]
|
||||||
|
fn is_active_validator(account: &AccountId) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SeraiEnvironment;
|
||||||
|
impl Environment for SeraiEnvironment {
|
||||||
|
const MAX_EVENT_TOPICS: usize = <DefaultEnvironment as Environment>::MAX_EVENT_TOPICS;
|
||||||
|
|
||||||
|
type AccountId = <DefaultEnvironment as Environment>::AccountId;
|
||||||
|
type Balance = <DefaultEnvironment as Environment>::Balance;
|
||||||
|
type Hash = <DefaultEnvironment as Environment>::Hash;
|
||||||
|
type BlockNumber = <DefaultEnvironment as Environment>::BlockNumber;
|
||||||
|
type Timestamp = <DefaultEnvironment as Environment>::Timestamp;
|
||||||
|
|
||||||
|
type ChainExtension = SeraiExtension;
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "multisig-serai"
|
name = "serai-multisig"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "An ink! tracker for Serai's current multisig"
|
description = "An ink! tracker for Serai's current multisig"
|
||||||
license = "AGPL-3.0-only"
|
license = "AGPL-3.0-only"
|
||||||
|
@ -7,31 +7,33 @@ authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
|
||||||
|
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }
|
||||||
|
|
||||||
ink_primitives = { version = "3", default-features = false }
|
ink_primitives = { version = "3", default-features = false }
|
||||||
ink_metadata = { version = "3", default-features = false, features = ["derive"], optional = true }
|
ink_metadata = { version = "3", default-features = false, features = ["derive"], optional = true }
|
||||||
ink_env = { version = "3", default-features = false }
|
ink_env = { version = "3", default-features = false }
|
||||||
ink_storage = { version = "3", default-features = false }
|
ink_storage = { version = "3", default-features = false }
|
||||||
ink_lang = { version = "3", default-features = false }
|
ink_lang = { version = "3", default-features = false }
|
||||||
|
|
||||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
|
serai-extension = { path = "../extension", default-features = false }
|
||||||
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "multisig"
|
name = "serai_multisig"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
crate-type = [
|
crate-type = ["cdylib"]
|
||||||
# Used for normal contract Wasm blobs.
|
|
||||||
"cdylib",
|
|
||||||
]
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
|
"scale/std",
|
||||||
|
"scale-info/std",
|
||||||
|
|
||||||
|
"ink_primitives/std",
|
||||||
"ink_metadata/std",
|
"ink_metadata/std",
|
||||||
"ink_env/std",
|
"ink_env/std",
|
||||||
"ink_storage/std",
|
"ink_storage/std",
|
||||||
"ink_primitives/std",
|
|
||||||
"scale/std",
|
"serai-extension/std",
|
||||||
"scale-info/std",
|
|
||||||
]
|
]
|
||||||
ink-as-dependency = []
|
ink-as-dependency = []
|
||||||
|
|
|
@ -1,40 +1,8 @@
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
use ink_lang as ink;
|
use ink_lang as ink;
|
||||||
use ink_env::{Environment, DefaultEnvironment, AccountId};
|
|
||||||
|
|
||||||
#[ink::chain_extension]
|
#[ink::contract(env = serai_extension::SeraiEnvironment)]
|
||||||
pub trait ValidatorsExtension {
|
|
||||||
type ErrorCode = ();
|
|
||||||
|
|
||||||
/// Returns the amount of active validators on the current chain.
|
|
||||||
#[ink(extension = 0, handle_status = false, returns_result = false)]
|
|
||||||
fn active_validators_len() -> u16;
|
|
||||||
|
|
||||||
/// Returns the ID for the current validator set for the current chain.
|
|
||||||
// TODO: Decide if this should be an increasing unsigned integer instead of a hash.
|
|
||||||
#[ink(extension = 1, handle_status = false, returns_result = false)]
|
|
||||||
fn validator_set_id() -> [u8; 32];
|
|
||||||
|
|
||||||
/// Returns if the specified account is an active validator for the current chain.
|
|
||||||
#[ink(extension = 2, handle_status = false, returns_result = false)]
|
|
||||||
fn is_active_validator(account: &AccountId) -> bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ValidatorEnvironment;
|
|
||||||
impl Environment for ValidatorEnvironment {
|
|
||||||
const MAX_EVENT_TOPICS: usize = <DefaultEnvironment as Environment>::MAX_EVENT_TOPICS;
|
|
||||||
|
|
||||||
type AccountId = <DefaultEnvironment as Environment>::AccountId;
|
|
||||||
type Balance = <DefaultEnvironment as Environment>::Balance;
|
|
||||||
type Hash = <DefaultEnvironment as Environment>::Hash;
|
|
||||||
type BlockNumber = <DefaultEnvironment as Environment>::BlockNumber;
|
|
||||||
type Timestamp = <DefaultEnvironment as Environment>::Timestamp;
|
|
||||||
|
|
||||||
type ChainExtension = ValidatorsExtension;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[ink::contract(env = crate::ValidatorEnvironment)]
|
|
||||||
mod multisig {
|
mod multisig {
|
||||||
use scale::Encode;
|
use scale::Encode;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue