Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(solis): smart contract implement asset ownership verification #312

2 changes: 1 addition & 1 deletion contracts.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"goerli":{"nftContract":"0x22411b480425fe6e627fdf4d1b6ac7f8567314ada5617a0a6d8ef3e74b69436","messaging":"0x2c3d3e0c37d29364a13ba8cff046e7bc5624655a72526961876a1c8bb3f63c8","executor":"0x73148536f8ea9546e92761d11515548cc433df46883d5ee98871a6f63a0bbbc","orderbook":"0x66f1e6acf9bdbd23837b2eea271430298b355c506978edb132737e7fcb6b310"},"sepolia":{},"mainnet":{},"dev":{"nftContract":"0x6f63d7d261c2d2c5409ba80ab0b235303fdcd01daeef61ca5ae7238285d7b78","eth":"0x7b8fc5c78bf249bb4173ef45267da1a710c65d76bb9ff03deb6b8fc21f35ba4","messaging":"0x38e142d3d69cfe6757fd9d11704652f6bd8302dd23f483555e9b5698bf69d5","executor":"0x1f303987f8a61ee25d5a153791fd778f0c478947bb32613d15fc8194e0360a6","orderbook":"0x3d7a3a02741c905fdb3cccf14e376a7d64c8cb071874f47f0b01d73015eae6b"}}
{"goerli":{"nftContract":"0x22411b480425fe6e627fdf4d1b6ac7f8567314ada5617a0a6d8ef3e74b69436","messaging":"0x2c3d3e0c37d29364a13ba8cff046e7bc5624655a72526961876a1c8bb3f63c8","executor":"0x73148536f8ea9546e92761d11515548cc433df46883d5ee98871a6f63a0bbbc","orderbook":"0x66f1e6acf9bdbd23837b2eea271430298b355c506978edb132737e7fcb6b310"},"sepolia":{},"mainnet":{},"dev":{"messaging":"0x28f42924c72d2d444be20e715d0b5c97544b22e3147002d67bd59232187bc3","executor":"0x24457c33d887b2b3c6a9dd1d65205e1b1796e97537d5ee1e291012bb68ee382","nftContract":"0x64e73de9240ba05218b7e8fe53d1f9a3bae51791c5c5b6746fa7dae2e912764","eth":"0x144a0c8ae6e665dc3652e164ba2881eda87ad9cb5dcc93d30ca6d61b818014c","orderbook":"0x6404d0ba6809a56549bd132573e39170d0134c74a21b06375352c2cfd1c54d8"}}
6 changes: 6 additions & 0 deletions contracts/ark_orderbook/src/orderbook.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ mod orderbook {
self.emit(OrderExecuted { order_hash: info.order_hash, order_status: order_status });
}

/// Update status : only from solis.
#[l1_handler]
fn rollback_status_order(ref self: ContractState, _from_address: felt252, order_hash: felt252) {
order_status_write(order_hash, OrderStatus::Open);
}

// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
Expand Down
6 changes: 3 additions & 3 deletions crates/solis/messaging.local.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"chain": "starknet",
"rpc_url": "http://127.0.0.1:5050",
"contract_address": "0x38e142d3d69cfe6757fd9d11704652f6bd8302dd23f483555e9b5698bf69d5",
"sender_address": "0x2d71e9c974539bb3ffb4b115e66a23d0f62a641ea66c4016e903454c8753bbc",
"private_key": "0x33003003001800009900180300d206308b0070db00121318d17b5e6262150b",
"contract_address": "0x28f42924c72d2d444be20e715d0b5c97544b22e3147002d67bd59232187bc3",
"sender_address": "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03",
"private_key": "0x1800000000300000180000000000030000000000003006001800006600",
"interval": 2,
"from_block": 0
}
15 changes: 0 additions & 15 deletions crates/solis/src/error.rs

This file was deleted.

20 changes: 10 additions & 10 deletions crates/solis/src/hooker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ impl<P: Provider + Sync + Send + 'static + std::fmt::Debug> SolisHooker<P> {

if let Ok(allowance) = allowance {
if allowance < balance_verifier.start_amount {
tracing::trace!(
"\nAllowance {:?} is not enough {:?} ",
allowance,
balance_verifier.start_amount
);
println!(
"\nAllowance {:?} is not enough {:?} for offerer {:?}",
allowance, balance_verifier.start_amount, balance_verifier.offerer
Expand Down Expand Up @@ -155,7 +150,6 @@ impl<P: Provider + Sync + Send + 'static + std::fmt::Debug> SolisHooker<P> {

let owner_ship_verification = self.verify_ownership(&verifier).await;
if !owner_ship_verification {
println!("verify ownership for starknet before failed");
return false;
}
}
Expand Down Expand Up @@ -346,7 +340,11 @@ impl<P: Provider + Sync + Send + 'static + std::fmt::Debug> KatanaHooker for Sol

let owner_ship_verification = self.verify_ownership(&verifier).await;
if !owner_ship_verification {
println!("verify ownership for starknet before failed");
// rollback the status
self.add_l1_handler_transaction_for_orderbook(
selector!("rollback_status_order"),
&[execution_info.order_hash],
);
return false;
}

Expand All @@ -361,12 +359,14 @@ impl<P: Provider + Sync + Send + 'static + std::fmt::Debug> KatanaHooker for Sol
})
.await
{
// rollback the status
self.add_l1_handler_transaction_for_orderbook(
selector!("rollback_status_order"),
&[execution_info.order_hash],
);
return false;
}

println!("order nft_address{:?}", &execution_info.nft_address);
println!("order nft_from{:?}", &execution_info.nft_from);

true
}

Expand Down
11 changes: 5 additions & 6 deletions crates/solis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use args::KatanaArgs;

//mod args;
mod contracts;
mod error;
mod hooker;
mod solis_args;

Expand Down Expand Up @@ -146,18 +145,18 @@ fn print_intro(accounts: String, seed: String, address: String, account_class_ha
Style::new().blue().apply_to(
r"

___ ___ | (_)___
___ ___ | (_)___
/ __|/ _ \| | / __|
\__ \ (_) | | \__ \
|___/\___/|_|_|___/
|___/\___/|_|_|___/
"
)
);

println!(
r"
PREDEPLOYED CONTRACTS
==================
PREDEPLOYED CONTRACTS
==================

| Contract | Fee Token
| Address | {}
Expand All @@ -178,7 +177,7 @@ PREDEPLOYED CONTRACTS
);

println!(
r"
r"
PREFUNDED ACCOUNTS
==================
{accounts}
Expand Down
9 changes: 7 additions & 2 deletions packages/core/examples/createListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { shortString } from "starknet";
import { getSolisProvider, getStarknetProvider } from "../../deployer/src/providers";



Expand Down Expand Up @@ -40,7 +41,11 @@ import { whitelistBroker } from "./utils/whitelistBroker";
);

console.log(`=> Whitelisting broker ${brokerId}`);
await whitelistBroker(config, solisAdminAccount, brokerId);
await whitelistBroker(
config,
solisAdminAccount,
brokerId
);

console.log(`=> Creating account`);
// Create a new account for the listing using the provider
Expand All @@ -59,7 +64,7 @@ import { whitelistBroker } from "./utils/whitelistBroker";
await mintERC721(config.starknetProvider, starknetOffererAccount);
const tokenId = await getCurrentTokenId(config, STARKNET_NFT_ADDRESS);
const owner = await getTokenOwner(config, STARKNET_NFT_ADDRESS, tokenId);
const ownerHex = "0x" + owner.toString(16).padStart(64, "0");
const ownerHex = "0x" + owner.toString(16).padStart(64, '0');
console.log("Owner of tokenId", tokenId, "is", ownerHex);

console.log(`=> Approving for all`);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/examples/createOffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* checking the order status
*/

import { shortString } from "starknet";
import { Contract, shortString } from "starknet";

import "dotenv/config";

Expand Down
6 changes: 5 additions & 1 deletion packages/core/examples/fulfillListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ import { whitelistBroker } from "./utils/whitelistBroker";
);

console.log(`=> Whitelisting broker ${brokerId}`);
await whitelistBroker(config, solisAdminAccount, brokerId);
await whitelistBroker(
config,
solisAdminAccount,
brokerId
);

console.log(`=> Getting config...`);
const { arkProvider, starknetProvider } = config;
Expand Down
21 changes: 9 additions & 12 deletions packages/core/src/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
// This file is auto-generated. Do not edit directly.

export const GOERLI_CONTRACTS = {
nftContract:
"0x22411b480425fe6e627fdf4d1b6ac7f8567314ada5617a0a6d8ef3e74b69436",
messaging:
"0x2c3d3e0c37d29364a13ba8cff046e7bc5624655a72526961876a1c8bb3f63c8",
executor: "0x73148536f8ea9546e92761d11515548cc433df46883d5ee98871a6f63a0bbbc",
orderbook: "0x66f1e6acf9bdbd23837b2eea271430298b355c506978edb132737e7fcb6b310"
"nftContract": "0x22411b480425fe6e627fdf4d1b6ac7f8567314ada5617a0a6d8ef3e74b69436",
"messaging": "0x2c3d3e0c37d29364a13ba8cff046e7bc5624655a72526961876a1c8bb3f63c8",
"executor": "0x73148536f8ea9546e92761d11515548cc433df46883d5ee98871a6f63a0bbbc",
"orderbook": "0x66f1e6acf9bdbd23837b2eea271430298b355c506978edb132737e7fcb6b310"
};
export const SEPOLIA_CONTRACTS = {};
export const MAINNET_CONTRACTS = {};
export const DEV_CONTRACTS = {
nftContract:
"0x6f63d7d261c2d2c5409ba80ab0b235303fdcd01daeef61ca5ae7238285d7b78",
eth: "0x7b8fc5c78bf249bb4173ef45267da1a710c65d76bb9ff03deb6b8fc21f35ba4",
messaging: "0x38e142d3d69cfe6757fd9d11704652f6bd8302dd23f483555e9b5698bf69d5",
executor: "0x1f303987f8a61ee25d5a153791fd778f0c478947bb32613d15fc8194e0360a6",
orderbook: "0x3d7a3a02741c905fdb3cccf14e376a7d64c8cb071874f47f0b01d73015eae6b"
"messaging": "0x28f42924c72d2d444be20e715d0b5c97544b22e3147002d67bd59232187bc3",
"executor": "0x24457c33d887b2b3c6a9dd1d65205e1b1796e97537d5ee1e291012bb68ee382",
"nftContract": "0x64e73de9240ba05218b7e8fe53d1f9a3bae51791c5c5b6746fa7dae2e912764",
"eth": "0x144a0c8ae6e665dc3652e164ba2881eda87ad9cb5dcc93d30ca6d61b818014c",
"orderbook": "0x6404d0ba6809a56549bd132573e39170d0134c74a21b06375352c2cfd1c54d8"
};
Loading