Skip to content

Commit cfb2719

Browse files
committed
add call to relay to submit_inscription
1 parent 09f0925 commit cfb2719

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/onchain/src/orderbook/orderbook.cairo

+15-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mod Orderbook {
1010
StoragePointerReadAccess, StoragePointerWriteAccess,
1111
};
1212
use starknet::{ContractAddress, get_caller_address, get_contract_address, get_block_number};
13+
use starknet::{SyscallResultTrait, syscalls::call_contract_syscall};
1314

1415
#[storage]
1516
struct Storage {
@@ -28,12 +29,14 @@ mod Orderbook {
2829
inscription_locks: Map<u32, (ContractAddress, ByteArray, u64)>,
2930
// STRK fee token.
3031
strk_token: ERC20ABIDispatcher,
32+
// Address of the contract checking transaction inclusion.
33+
relay_address: ContractAddress,
3134
}
3235

3336
#[constructor]
34-
fn constructor(ref self: ContractState, strk_token: ContractAddress) {
37+
fn constructor(ref self: ContractState, strk_token: ContractAddress, relay_address: ContractAddress) {
3538
// initialize contract
36-
self.initializer(:strk_token);
39+
self.initializer(:strk_token, :relay_address);
3740
}
3841

3942
#[abi(embed_v0)]
@@ -159,7 +162,14 @@ mod Orderbook {
159162
let (_, precomputed_tx_hash, _) = self.inscription_locks.read(inscription_id);
160163
assert(precomputed_tx_hash == tx_hash, 'Precomputed hash != submitted');
161164

162-
// TODO: process the submitted transaction hash, verify that it is on Bitcoin
165+
const selector: felt252 = selector!("prove_inclusion");
166+
let to = self.relay_address.read();
167+
let calldata: Array<felt252> = array![];
168+
169+
// TODO: assert successful inclusion call
170+
call_contract_syscall(to, selector, calldata.span()).unwrap_syscall();
171+
172+
// TODO: assert that the witness data contains the requested inscription
163173

164174
self.inscription_statuses.write(inscription_id, Status::Closed);
165175
}
@@ -182,8 +192,9 @@ mod Orderbook {
182192
pub impl InternalImpl of InternalTrait {
183193
/// Executed once when the Orderbook contract is deployed. Used to set
184194
/// initial values for contract storage variables for the fee tokens.
185-
fn initializer(ref self: ContractState, strk_token: ContractAddress) {
195+
fn initializer(ref self: ContractState, strk_token: ContractAddress, relay_address: ContractAddress) {
186196
self.strk_token.write(ERC20ABIDispatcher { contract_address: strk_token });
197+
self.relay_address.write(relay_address);
187198
}
188199
}
189200
}

0 commit comments

Comments
 (0)