0xa6::squid
Squid
init
give_deep
allow_function
disallow_function
withdraw
start_swap
finalize
inner
inner_mut
version
new_version_control
use 0x0::deep;
use 0x1::ascii;
use 0x1::vector;
use 0x2::clock;
use 0x2::coin;
use 0x2::object;
use 0x2::transfer;
use 0x2::tx_context;
use 0x2::versioned;
use 0xa1::channel;
use 0xa5::interchain_token_service;
use 0xa6::owner_cap;
use 0xa6::squid_v0;
use 0xa6::swap_info;
use 0xb0::version_control;
Squid
struct Squid has store, key
id: object::UID
inner: versioned::Versioned
const VERSION: u64 = 0;
init
fun init(ctx: &mut tx_context::TxContext)
fun init(ctx: &mut TxContext) {
transfer::share_object(Squid {
id: object::new(ctx),
inner: versioned::create(
VERSION,
squid_v0::new(
new_version_control(),
ctx,
),
ctx,
),
});
transfer::public_transfer(owner_cap::create(ctx), ctx.sender());
}
give_deep
entry fun give_deep(self: &mut squid::Squid, deep: coin::Coin<deep::DEEP>)
entry fun give_deep(self: &mut Squid, deep: Coin<DEEP>) {
self.value_mut!(b"give_deep").give_deep(deep);
}
allow_function
entry fun allow_function(self: &mut squid::Squid, _: &owner_cap::OwnerCap, version: u64, function_name: ascii::String)
entry fun allow_function(
self: &mut Squid,
_: &OwnerCap,
version: u64,
function_name: String,
) {
self.value_mut!(b"allow_function").allow_function(version, function_name);
}
disallow_function
entry fun disallow_function(self: &mut squid::Squid, _: &owner_cap::OwnerCap, version: u64, function_name: ascii::String)
entry fun disallow_function(
self: &mut Squid,
_: &OwnerCap,
version: u64,
function_name: String,
) {
self
.value_mut!(b"disallow_function")
.disallow_function(version, function_name);
}
withdraw
entry fun withdraw<T>(self: &mut squid::Squid, _: &owner_cap::OwnerCap, amount: u64, ctx: &mut tx_context::TxContext)
entry fun withdraw<T>(
self: &mut Squid,
_: &OwnerCap,
amount: u64,
ctx: &mut TxContext,
) {
self.value_mut!(b"withdraw").withdraw<T>(amount, ctx);
}
start_swap
public fun start_swap<T>(self: &mut squid::Squid, its: &mut interchain_token_service::InterchainTokenService, approved_message: channel::ApprovedMessage, clock: &clock::Clock, ctx: &mut tx_context::TxContext): swap_info::SwapInfo
public fun start_swap<T>(
self: &mut Squid,
its: &mut InterchainTokenService,
approved_message: ApprovedMessage,
clock: &Clock,
ctx: &mut TxContext,
): SwapInfo {
self
.value_mut!(b"start_swap")
.start_swap<T>(its, approved_message, clock, ctx)
}
finalize
public fun finalize(swap_info: swap_info::SwapInfo)
inner
public(friend) fun inner(self: &squid::Squid): &versioned::Versioned
inner_mut
public(friend) fun inner_mut(self: &mut squid::Squid): &mut versioned::Versioned
version
public(friend) fun version(): u64
new_version_control
Private ——-
fun new_version_control(): version_control::VersionControl
fun new_version_control(): VersionControl {
version_control::new(vector[
// Version 0
vector[
b"start_swap",
b"its_transfer",
b"deepbook_v3_swap",
b"register_transaction",
b"give_deep",
b"allow_function",
b"disallow_function",
b"withdraw",
].map!(|function_name| function_name.to_ascii_string()),
])
}