Severity: MEDIUM — Starknet Chain Support Is Non-Functional
Problem
contract/starknet/src/htlc.cairo is completely empty (0 bytes). The bridge router routes Starknet payments via Layerswap, which handles bridging, but the on-chain HTLC on Starknet side for locking payer funds does not exist.
Implementation Required
```cairo
use starknet::ContractAddress;
use starknet::get_caller_address;
use starknet::get_block_timestamp;
use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait};
#[derive(Drop, Serde, starknet::Store)]
struct LockEntry {
sender: ContractAddress,
receiver: ContractAddress,
token: ContractAddress,
amount: u256,
hashlock: felt252, // sha256 of secret
timelock: u64,
withdrawn: bool,
refunded: bool,
}
#[starknet::contract]
mod HTLCStarknet {
use super::*;
use starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess};
#[storage]
struct Storage {
locks: Map<felt252, LockEntry>, // lockId => LockEntry
paused: bool,
admin: ContractAddress,
}
#[event]
#[derive(Drop, starknet::Event)]
enum Event {
Locked: LockedEvent,
Withdrawn: WithdrawnEvent,
Refunded: RefundedEvent,
}
#[abi(embed_v0)]
impl HTLCImpl of super::IHTLC<ContractState> {
fn lock(ref self, receiver, token, amount, hashlock, timelock) -> felt252
fn withdraw(ref self, lock_id: felt252, preimage: felt252) -> bool
fn refund(ref self, lock_id: felt252) -> bool
fn get_lock(self: @ContractState, lock_id: felt252) -> LockEntry
fn pause(ref self)
fn unpause(ref self)
}
}
```
Also Required
Scarb.toml build config
- Deploy script using
starkli
- Tests using
snforge (Starknet Foundry)
- Add
STARKNET_HTLC_ADDRESS and STARKNET_RELAY_PRIVATE_KEY to .env.example
Note on Layerswap Integration
For the beta, Layerswap handles Starknet bridging at the protocol level. The Cairo HTLC is needed for a fully non-custodial Starknet integration in the future. This can be deprioritized if beta scope excludes Starknet.
Acceptance Criteria
Severity: MEDIUM — Starknet Chain Support Is Non-Functional
Problem
contract/starknet/src/htlc.cairois completely empty (0 bytes). The bridge router routes Starknet payments via Layerswap, which handles bridging, but the on-chain HTLC on Starknet side for locking payer funds does not exist.Implementation Required
```cairo
use starknet::ContractAddress;
use starknet::get_caller_address;
use starknet::get_block_timestamp;
use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait};
#[derive(Drop, Serde, starknet::Store)]
struct LockEntry {
sender: ContractAddress,
receiver: ContractAddress,
token: ContractAddress,
amount: u256,
hashlock: felt252, // sha256 of secret
timelock: u64,
withdrawn: bool,
refunded: bool,
}
#[starknet::contract]
mod HTLCStarknet {
use super::*;
use starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess};
}
```
Also Required
Scarb.tomlbuild configstarklisnforge(Starknet Foundry)STARKNET_HTLC_ADDRESSandSTARKNET_RELAY_PRIVATE_KEYto.env.exampleNote on Layerswap Integration
For the beta, Layerswap handles Starknet bridging at the protocol level. The Cairo HTLC is needed for a fully non-custodial Starknet integration in the future. This can be deprioritized if beta scope excludes Starknet.
Acceptance Criteria
scarb buildlock(),withdraw(),refund()match EVM/Soroban semanticssnforge: min 8 test casesstarkli