-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(pop-api): add demo contract and unit test for placing a spot order * fix(pop-api): update origin and weight to make XCM calls work * feat: update ink deps to 5.0.0-rc3 * feat: update spot-order-contract to ink 5.0.0-rc.3 * style: formatting * docs: add todo note * test(extension): fix contract artifact path --------- Co-authored-by: Frank Bell <frank@r0gue.io>
- Loading branch information
1 parent
27d5528
commit 0fce3f6
Showing
10 changed files
with
185 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Ignore build artifacts from the local tests sub-crate. | ||
/target/ | ||
|
||
# Ignore backup files creates by cargo fmt. | ||
**/*.rs.bk | ||
|
||
# Remove Cargo.lock when creating an executable, leave it for libraries | ||
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "pop_api_spot_order_example" | ||
version = "0.1.0" | ||
authors = ["[your_name] <[your_email]>"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ink = { version = "5.0.0-rc.3", default-features = false } | ||
pop-api = { path = "../../../pop-api", default-features = false } | ||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } | ||
scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true } | ||
|
||
[lib] | ||
path = "lib.rs" | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"ink/std", | ||
"pop-api/std", | ||
"scale/std", | ||
"scale-info/std", | ||
] | ||
ink-as-dependency = [] | ||
e2e-tests = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#![cfg_attr(not(feature = "std"), no_std, no_main)] | ||
|
||
use pop_api::nfts; | ||
|
||
#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] | ||
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] | ||
pub enum ContractError { | ||
InvalidCollection, | ||
ItemAlreadyExists, | ||
NftsError(nfts::Error), | ||
NotOwner, | ||
} | ||
|
||
impl From<nfts::Error> for ContractError { | ||
fn from(value: nfts::Error) -> Self { | ||
ContractError::NftsError(value) | ||
} | ||
} | ||
|
||
#[ink::contract(env = pop_api::Environment)] | ||
mod pop_api_spot_order_example { | ||
use super::ContractError; | ||
|
||
#[ink(storage)] | ||
#[derive(Default)] | ||
pub struct PopApiSpotOrderExample; | ||
|
||
impl PopApiSpotOrderExample { | ||
#[ink(constructor, payable)] | ||
pub fn new() -> Self { | ||
ink::env::debug_println!("Contract::new"); | ||
Default::default() | ||
} | ||
|
||
#[ink(message)] | ||
pub fn place_spot_order( | ||
&mut self, | ||
max_amount: Balance, | ||
para_id: u32, | ||
) -> Result<(), ContractError> { | ||
ink::env::debug_println!( | ||
"Contract::place_spot_order: max_amount {:?} para_id: {:?} ", | ||
max_amount, | ||
para_id, | ||
); | ||
|
||
let res = pop_api::cross_chain::coretime::place_spot_order(max_amount, para_id); | ||
ink::env::debug_println!( | ||
"Contract::place_spot_order: res {:?} ", | ||
res, | ||
); | ||
|
||
ink::env::debug_println!("Contract::place_spot_order end"); | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[ink::test] | ||
fn default_works() { | ||
PopApiSpotOrderExample::new(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters