Module 0xa6::squid_v0
use 0x0::deep;
use 0x1::ascii;
use 0x2::balance;
use 0x2::clock;
use 0x2::coin;
use 0x2::transfer;
use 0x2::tx_context;
use 0xa1::channel;
use 0xa5::interchain_token_service;
use 0xa6::coin_bag;
use 0xa6::swap_info;
use 0xb0::version_control;
Struct Squid_v0
struct Squid_v0 has store
Fields
-
channel: channel::Channel
-
-
coin_bag: coin_bag::CoinBag
-
-
version_control: version_control::VersionControl
-
Function new
public(friend) fun new(version_control: version_control::VersionControl, ctx: &mut tx_context::TxContext): squid_v0::Squid_v0
Implementation
public(package) fun new(
version_control: VersionControl,
ctx: &mut TxContext,
): Squid_v0 {
Squid_v0 {
channel: channel::new(ctx),
coin_bag: coin_bag::new(ctx),
version_control,
}
}
Function channel
public(friend) fun channel(self: &squid_v0::Squid_v0): &channel::Channel
Implementation
public(package) fun channel(self: &Squid_v0): &Channel {
&self.channel
}
Function version_control
public(friend) fun version_control(self: &squid_v0::Squid_v0): &version_control::VersionControl
Implementation
public(package) fun version_control(self: &Squid_v0): &VersionControl {
&self.version_control
}
Function coin_bag_mut
public(friend) fun coin_bag_mut(self: &mut squid_v0::Squid_v0): &mut coin_bag::CoinBag
Implementation
public(package) fun coin_bag_mut(self: &mut Squid_v0): &mut CoinBag {
&mut self.coin_bag
}
Function start_swap
public(friend) fun start_swap<T>(self: &squid_v0::Squid_v0, its: &mut interchain_token_service::InterchainTokenService, approved_message: channel::ApprovedMessage, clock: &clock::Clock, ctx: &mut tx_context::TxContext): swap_info::SwapInfo
Implementation
public(package) fun start_swap<T>(
self: &Squid_v0,
its: &mut InterchainTokenService,
approved_message: ApprovedMessage,
clock: &Clock,
ctx: &mut TxContext,
): SwapInfo {
let (_, _, data, coin) = its.receive_interchain_transfer_with_data<T>(
approved_message,
self.channel(),
clock,
ctx,
);
let mut swap_info = swap_info::new(data, ctx);
swap_info.coin_bag().store_estimate<T>(coin.value());
swap_info.coin_bag().store_balance(coin.into_balance());
swap_info
}
Function give_deep
public(friend) fun give_deep(self: &mut squid_v0::Squid_v0, deep: coin::Coin<deep::DEEP>)
Implementation
public(package) fun give_deep(self: &mut Squid_v0, deep: Coin<DEEP>) {
self.coin_bag.store_balance(deep.into_balance());
}
Function allow_function
public(friend) fun allow_function(self: &mut squid_v0::Squid_v0, version: u64, function_name: ascii::String)
Implementation
public(package) fun allow_function(
self: &mut Squid_v0,
version: u64,
function_name: String,
) {
self.version_control.allow_function(version, function_name);
}
Function disallow_function
public(friend) fun disallow_function(self: &mut squid_v0::Squid_v0, version: u64, function_name: ascii::String)
Implementation
public(package) fun disallow_function(
self: &mut Squid_v0,
version: u64,
function_name: String,
) {
self.version_control.disallow_function(version, function_name);
}
Function withdraw
public(friend) fun withdraw<T>(self: &mut squid_v0::Squid_v0, amount: u64, ctx: &mut tx_context::TxContext)
Implementation
public(package) fun withdraw<T>(
self: &mut Squid_v0,
amount: u64,
ctx: &mut TxContext,
) {
let balance = self.coin_bag.exact_balance<T>(amount);
transfer::public_transfer(coin::from_balance(balance, ctx), ctx.sender());
}