-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
182 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,30 @@ | ||
config := --account ../solis_account1.json \ | ||
--keystore ../solis_key1.json \ | ||
--rpc http://127.0.0.1:7070 \ | ||
--keystore-password 1234 | ||
|
||
ob_cl = $(shell starkli class-hash target/dev/arkchain_orderbook.sierra.json) | ||
ob_addr := 0x008707b3296680b4f67430509ee8655f86ce3c844d7223cb52b01412a6c45eff | ||
|
||
ark_executor_sn := 0x0573e38d2b37032172a1f9b370bd81954a0d44934e38154ff75a678700b73430 | ||
|
||
# Solis accounts | ||
# has token 1 and 2 | ||
solis_2 := 0x47abb77acbb2f65006a42b14fed3664bafb0d102c00a97be58618d49d5186ac | ||
# has token 3 and 4 | ||
solis_3 := 0x4c077c4085945fa6ea7116ec3c4579de29b10bd65aaf77cf4cf4f85af3ef609 | ||
# collection | ||
erc721_address := 0x044b07a8c955296dd52a9d7d31a400b16ad4f6f574aa57db79cac0e87eac48cd | ||
|
||
setup: | ||
scarb build | ||
starkli declare target/dev/arkchain_orderbook.sierra.json ${config} | ||
starkli deploy ${ob_cl} 0x3ee9e18edc71a6df30ac3aca2e0b02a198fbce19b7480a63a0d71cbd76652e0 ${config} --salt 0x1234 | ||
starkli invoke ${ob_addr} set_executor_sn_address ${ark_executor_sn} ${config} | ||
|
||
starkli invoke ${ob_addr} register_broker str:b1 1 str:starknet_testnet ${config} | ||
|
||
starkli invoke ${ob_addr} add_order_listing ${solis_2} ${erc721_address} u256:1 u256:77 0 str:b1 0 0 ${config} | ||
|
||
starkli invoke ${ob_addr} submit_order_buy 0x51a397add04213bb487668b635bedefdbbe5fb8f5b9d3aad6164031b60958b ${solis_3} str:b1 0 0 ${config} | ||
|
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,13 @@ | ||
{ | ||
"version": 1, | ||
"variant": { | ||
"type": "open_zeppelin", | ||
"version": 1, | ||
"public_key": "0x7f00d91354c3848de72fe99c94e07d89b61362a18a8137f4d0fc6057fded169" | ||
}, | ||
"deployment": { | ||
"status": "deployed", | ||
"class_hash": "0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f", | ||
"address": "0x3c2c23f8389cffce8f698c4f3d3d771a979ddce14de15e6ae14b56c8e4e355b" | ||
} | ||
} |
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 @@ | ||
{"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"9b94bbb390d9b67ce2a52de1a2828b24"},"ciphertext":"5e2f576ed9e33eec395a96538ea1710114e85fbe7c29138360b8666883794e4e","kdf":"scrypt","kdfparams":{"dklen":32,"n":8192,"p":1,"r":8,"salt":"6a2931cfd19a5ab69874e7fe1e70c6ad12e2984e57711a30801ed1e90aa7c8e8"},"mac":"f4c42c6861134e8a2c5e43f2ede9a1f3ba23609953f46924e3b7f4eacbc2750d"},"id":"ee5ca82e-5e7a-4ae8-ac6e-8a2d178f2197","version":3} |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod client; | ||
|
||
#[derive(Debug)] | ||
pub struct CairoU256 { | ||
pub low: u128, | ||
pub high: u128, | ||
|
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,70 @@ | ||
//! How to use arkchain indexer library. | ||
//! | ||
//! Can be run with `cargo run --example arkchain_indexer`. | ||
//! | ||
use anyhow::Result; | ||
use arkproject::{ | ||
arkchain::{storage::*, ArkchainIndexer}, | ||
starknet::client::{StarknetClient, StarknetClientHttp}, | ||
}; | ||
use async_trait::async_trait; | ||
use starknet::core::types::BlockId; | ||
use std::sync::Arc; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let client = StarknetClientHttp::new("http://127.0.0.1:7070").unwrap(); | ||
let storage = DefaultStorage {}; | ||
|
||
// Here, we can define any logic we want to index blocks range etc.. | ||
// We can then use the same reference across threads to work with only one | ||
// ArkchainIndexer instance. | ||
let indexer = Arc::new(ArkchainIndexer::new(Arc::new(client), Arc::new(storage))); | ||
|
||
let mut handles = vec![]; | ||
|
||
for i in 0..3 { | ||
let indexer = Arc::clone(&indexer); | ||
let handle = tokio::spawn(async move { | ||
let from = BlockId::Number(i * 10); | ||
let to = BlockId::Number(i * 10 + 5); | ||
println!("Indexer [{:?} - {:?}] started!", from, to); | ||
match indexer.index_block_range(from, to).await { | ||
Ok(_) => println!("Indexer [{:?} - {:?}] completed!", from, to), | ||
Err(e) => println!("Indexer [{:?} - {:?}] failed! [{:?}]", from, to, e), | ||
} | ||
}); | ||
|
||
handles.push(handle); | ||
} | ||
|
||
futures::future::join_all(handles).await; | ||
|
||
Ok(()) | ||
} | ||
|
||
// Default storate that logs stuff. | ||
struct DefaultStorage; | ||
|
||
#[async_trait] | ||
impl ArkchainStorage for DefaultStorage { | ||
async fn register_broker(&self, broker: BrokerData) -> StorageResult<()> { | ||
println!("\n*** register broker\n{:?}", broker); | ||
Ok(()) | ||
} | ||
|
||
async fn add_listing_order(&self, order: OrderListingData) -> StorageResult<()> { | ||
println!("\n*** add listing order \n{:?}", order); | ||
Ok(()) | ||
} | ||
|
||
async fn set_order_buy_executing(&self, order: OrderBuyExecutingData) -> StorageResult<()> { | ||
println!("\n*** buy executing order \n{:?}", order); | ||
Ok(()) | ||
} | ||
|
||
async fn set_order_finalized(&self, order: OrderFinalizedData) -> StorageResult<()> { | ||
println!("\n*** order finalized \n{:?}", order); | ||
Ok(()) | ||
} | ||
} |
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