Hello SUI Move comrades. Please lend me a helping hand if you will. I am creating a currency of mine, minting it, splitting it and burning it as per code below:
module try_nft::dnr;
const COIN_URL: vector<u8> = b"xyz";
use sui::coin::{Self, Coin, TreasuryCap};
use sui::url;
public struct DNR has drop {}
fun init(witness: DNR, ctx: &mut TxContext) {
let (treasury_cap, metadata) = coin::create_currency<DNR>(
witness,
9,
b"My SUI Coin",
b"Denero",
b"Coin worth crickets",
option::some(url::new_unsafe_from_bytes(COIN_URL)),
ctx,
);
transfer::public_freeze_object(metadata);
transfer::public_transfer(treasury_cap, tx_context::sender(ctx));
}
public entry fun mint_coin(
treasury_cap: &mut TreasuryCap<DNR>,
amount: u64,
recipient: address,
ctx: &mut TxContext) {
coin::mint_and_transfer(treasury_cap, amount, recipient, ctx);
}
public entry fun burn_coin(
treasury_cap: &mut TreasuryCap<DNR>,
coin: Coin<DNR>) {
coin::burn(treasury_cap, coin);
}
public entry fun split_coin(
self: &mut Coin<DNR>,
amount: u64,
recipient: address,
ctx: & mut TxContext) {
let new_split_coin = coin::split(self, amount, ctx);
transfer::public_transfer(new_split_coin, recipient);
}
It compiles just fine and works as a peach when tested on SuiScan. However, when I try to join the two splitted coins, with the snippet below,
public entry fun join_coin(
self: &mut Coin<DNR>,
c: Coin<DNR>,
recipient: address) {
let new_join_coin = coin::join(self, c);
transfer::public_transfer(new_join_coin, recipient);
}
I get a compilation error as below,
error[E04005]: expected a single type
┌─ ./sources/try_nft.move:61:13
│
61 │ let new_join_coin = coin::join(self, c);
│ ^^^^^^^^^^^^^ Invalid type for local
│
┌─ /home/plyoteo/.move/https___github_com_MystenLabs_sui_git_2c930c25f8d3/crates/sui-framework/packages/sui-framework/sources/coin.move:165:18
│
165 │ public entry fun join(self: &mut Coin, c: Coin) {
│ ---- Expected a single type, but found expression list type: ‘()’
Any ideas? I think that I am using the join fun exactly as outlined in sui:
:join documentation.
I thank you in advance