axelar-cgp-sui

Module 0xa6::squid

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;

Resource Squid

struct Squid has store, key
Fields
id: object::UID
inner: versioned::Versioned

Constants

const VERSION: u64 = 0;

Function init

fun init(ctx: &mut tx_context::TxContext)
Implementation
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());
}

Function give_deep

entry fun give_deep(self: &mut squid::Squid, deep: coin::Coin<deep::DEEP>)
Implementation
entry fun give_deep(self: &mut Squid, deep: Coin<DEEP>) {
    self.value_mut!(b"give_deep").give_deep(deep);
}

Function allow_function

entry fun allow_function(self: &mut squid::Squid, _: &owner_cap::OwnerCap, version: u64, function_name: ascii::String)
Implementation
entry fun allow_function(
    self: &mut Squid,
    _: &OwnerCap,
    version: u64,
    function_name: String,
) {
    self.value_mut!(b"allow_function").allow_function(version, function_name);
}

Function disallow_function

entry fun disallow_function(self: &mut squid::Squid, _: &owner_cap::OwnerCap, version: u64, function_name: ascii::String)
Implementation
entry fun disallow_function(
    self: &mut Squid,
    _: &OwnerCap,
    version: u64,
    function_name: String,
) {
    self
        .value_mut!(b"disallow_function")
        .disallow_function(version, function_name);
}

Function withdraw

entry fun withdraw<T>(self: &mut squid::Squid, _: &owner_cap::OwnerCap, amount: u64, ctx: &mut tx_context::TxContext)
Implementation
entry fun withdraw<T>(
    self: &mut Squid,
    _: &OwnerCap,
    amount: u64,
    ctx: &mut TxContext,
) {
    self.value_mut!(b"withdraw").withdraw<T>(amount, ctx);
}

Function 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
Implementation
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)
}

Function finalize

public fun finalize(swap_info: swap_info::SwapInfo)
Implementation
public fun finalize(swap_info: SwapInfo) {
    swap_info.finalize();
}

Function inner

public(friend) fun inner(self: &squid::Squid): &versioned::Versioned
Implementation
public(package) fun inner(self: &Squid): &Versioned {
    &self.inner
}

Function inner_mut

public(friend) fun inner_mut(self: &mut squid::Squid): &mut versioned::Versioned
Implementation
public(package) fun inner_mut(self: &mut Squid): &mut Versioned {
    &mut self.inner
}

Function version

public(friend) fun version(): u64
Implementation
public(package) fun version(): u64 {
    VERSION
}

Function new_version_control


Private ——-

fun new_version_control(): version_control::VersionControl
Implementation
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()),
    ])
}