Skip to content

Commit

Permalink
addressed some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Oct 25, 2024
1 parent d787666 commit d7b01b6
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module example::a;
module example::token_a;

use sui::coin;

// ------------
// Capabilities
// ------------
public struct A has drop {}
public struct TOKEN_A has drop {}

// -----
// Setup
// -----
fun init(witness: A, ctx: &mut TxContext) {
fun init(witness: TOKEN_A, ctx: &mut TxContext) {
let (treasury_cap, coin_metadata) = coin::create_currency(
witness,
9,
b"ITS",
b"ITS Example Coin",
b"TOKEN1",
b"Token 1",
b"",
option::none(),
ctx,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module example::b;
module example::token_b;

use sui::coin;

// ------------
// Capabilities
// ------------
public struct B has drop {}
public struct TOKEN_B has drop {}

// -----
// Setup
// -----
fun init(witness: B, ctx: &mut TxContext) {
fun init(witness: TOKEN_B, ctx: &mut TxContext) {
let (treasury_cap, coin_metadata) = coin::create_currency(
witness,
9,
b"ITS",
b"ITS Example Coin",
b"TOKEN2",
b"Token 2",
b"",
option::none(),
ctx,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module example::c;
module example::token_c;

use sui::coin;

// ------------
// Capabilities
// ------------
public struct C has drop {}
public struct TOKEN_C has drop {}

// -----
// Setup
// -----
fun init(witness: C, ctx: &mut TxContext) {
fun init(witness: TOKEN_C, ctx: &mut TxContext) {
let (treasury_cap, coin_metadata) = coin::create_currency(
witness,
9,
b"ITS",
b"ITS Example Coin",
b"TOKEN3",
b"Token 3",
b"",
option::none(),
ctx,
Expand Down
5 changes: 2 additions & 3 deletions move/squid/sources/squid/deepbook_v3.move
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public(package) fun swap_move_call(
}

public(package) fun peel_swap_data(bcs: &mut BCS): DeepbookV3SwapData {
let data = DeepbookV3SwapData {
DeepbookV3SwapData {
swap_type: swap_type::peel(bcs),
pool_id: bcs.peel_address(),
has_base: bcs.peel_bool(),
Expand All @@ -268,8 +268,7 @@ public(package) fun peel_swap_data(bcs: &mut BCS): DeepbookV3SwapData {
quote_type: ascii::string(bcs.peel_vec_u8()),
lot_size: bcs.peel_u64(),
should_sweep: bcs.peel_bool(),
};
data
}
}

/// Multiply two u64 numbers and divide by FLOAT_SCALING. Rounded down.
Expand Down
4 changes: 2 additions & 2 deletions move/squid/sources/squid/discovery.move
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public fun transaction(
move_calls.push_back(call);
});

swap_data.do_ref!(|data| {
let mut bcs = bcs::new(*data);
swap_data.do!(|data| {
let mut bcs = bcs::new(data);
let swap_type = swap_type::peel(&mut bcs);

let call = if (swap_type == swap_type::deepbook_v3()) {
Expand Down
11 changes: 7 additions & 4 deletions move/squid/sources/squid/squid.move
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public(package) macro fun value_mut(
value
}

// ---------------
// Entry Functions
// ---------------
entry fun give_deep(self: &mut Squid, deep: Coin<DEEP>) {
self.value_mut!(b"give_deep").give_deep(deep);
}

// ----------------
// Public Functions
// ----------------
Expand All @@ -79,10 +86,6 @@ public fun finalize(swap_info: SwapInfo) {
swap_info.finalize();
}

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

// -----------------
// Package Functions
// -----------------
Expand Down
43 changes: 9 additions & 34 deletions test/squid.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const { keccak256, defaultAbiCoder, hexlify, randomBytes } = require('ethers/lib

const SUI = '0x2';

describe('Squid', () => {
describe.only('Squid', () => {

Check failure on line 32 in test/squid.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected exclusive mocha test
// Sui Client
let client;
const network = process.env.NETWORK || 'localnet';
Expand Down Expand Up @@ -196,21 +196,6 @@ describe('Squid', () => {
});

await builder.signAndExecute(deployer);
/* place_limit_order<BaseAsset, QuoteAsset>(
self: &mut Pool<BaseAsset, QuoteAsset>,
balance_manager: &mut BalanceManager,
trade_proof: &TradeProof,
client_order_id: u64,
order_type: u8,
self_matching_option: u8,
price: u64,
quantity: u64,
is_bid: bool,
pay_with_deep: bool,
expire_timestamp: u64,
clock: &Clock,
ctx: &TxContext,
) */
}

async function registerCoin(coin) {
Expand Down Expand Up @@ -292,24 +277,14 @@ describe('Squid', () => {
itsChannel: await getVersionedChannelId(client, objectIds.itsV0),
squidChannel: await getVersionedChannelId(client, objectIds.squidV0),
};
let type = `${deployments.example.packageId}::a::A`;
coins.a = {
treasuryCap: findObjectId(deployments.example.publishTxn, `TreasuryCap<${type}>`),
coinMetadata: findObjectId(deployments.example.publishTxn, `CoinMetadata<${type}>`),
type,
};
type = `${deployments.example.packageId}::b::B`;
coins.b = {
treasuryCap: findObjectId(deployments.example.publishTxn, `TreasuryCap<${type}>`),
coinMetadata: findObjectId(deployments.example.publishTxn, `CoinMetadata<${type}>`),
type,
};
type = `${deployments.example.packageId}::c::C`;
coins.c = {
treasuryCap: findObjectId(deployments.example.publishTxn, `TreasuryCap<${type}>`),
coinMetadata: findObjectId(deployments.example.publishTxn, `CoinMetadata<${type}>`),
type,
};
for(token of ['a', 'b', 'c']) {
const type = `${deployments.example.packageId}::${token}::${token.toUpperCase()}`;

Check failure on line 281 in test/squid.js

View workflow job for this annotation

GitHub Actions / lint

'token' is not defined
coins[token] = {

Check failure on line 282 in test/squid.js

View workflow job for this annotation

GitHub Actions / lint

'token' is not defined

Check failure on line 282 in test/squid.js

View workflow job for this annotation

GitHub Actions / lint

'token' is not defined
treasuryCap: findObjectId(deployments.example.publishTxn, `TreasuryCap<${type}>`),

Check failure on line 283 in test/squid.js

View workflow job for this annotation

GitHub Actions / lint

'token' is not defined
coinMetadata: findObjectId(deployments.example.publishTxn, `CoinMetadata<${type}>`),
type,
};
}

pools.ab = await createPool('a', 'b');
pools.bc = await createPool('b', 'c');
Expand Down

0 comments on commit d7b01b6

Please sign in to comment.