non-fungible.test.ts.md•27.1 kB
# Snapshot report for `src/non-fungible.test.ts`
The actual snapshot is saved in `non-fungible.test.ts.snap`.
Generated by [AVA](https://avajs.dev).
## basic non-fungible
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{contract, contractimpl, Env, String};␊
use stellar_macros::default_impl;␊
use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Base;␊
␊
}␊
`
## non-fungible burnable
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{contract, contractimpl, Env, String};␊
use stellar_macros::default_impl;␊
use stellar_tokens::non_fungible::{Base, burnable::NonFungibleBurnable, NonFungibleToken};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Base;␊
␊
}␊
␊
//␊
// Extensions␊
//␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleBurnable for MyToken {}␊
`
## non-fungible pausable
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
use stellar_access::ownable::{self as ownable, Ownable};␊
use stellar_contract_utils::pausable::{self as pausable, Pausable};␊
use stellar_macros::{default_impl, only_owner, when_not_paused};␊
use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Base;␊
␊
#[when_not_paused]␊
fn transfer(e: &Env, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer(e, &from, &to, token_id);␊
}␊
␊
#[when_not_paused]␊
fn transfer_from(e: &Env, spender: Address, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer_from(e, &spender, &from, &to, token_id);␊
}␊
}␊
␊
//␊
// Utils␊
//␊
␊
#[contractimpl]␊
impl Pausable for MyToken {␊
fn paused(e: &Env) -> bool {␊
pausable::paused(e)␊
}␊
␊
#[only_owner]␊
fn pause(e: &Env, caller: Address) {␊
pausable::pause(e);␊
}␊
␊
#[only_owner]␊
fn unpause(e: &Env, caller: Address) {␊
pausable::unpause(e);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl Ownable for MyToken {}␊
`
## non-fungible burnable pausable
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
use stellar_access::ownable::{self as ownable, Ownable};␊
use stellar_contract_utils::pausable::{self as pausable, Pausable};␊
use stellar_macros::{default_impl, only_owner, when_not_paused};␊
use stellar_tokens::non_fungible::{Base, burnable::NonFungibleBurnable, NonFungibleToken};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Base;␊
␊
#[when_not_paused]␊
fn transfer(e: &Env, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer(e, &from, &to, token_id);␊
}␊
␊
#[when_not_paused]␊
fn transfer_from(e: &Env, spender: Address, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer_from(e, &spender, &from, &to, token_id);␊
}␊
}␊
␊
//␊
// Extensions␊
//␊
␊
#[contractimpl]␊
impl NonFungibleBurnable for MyToken {␊
#[when_not_paused]␊
fn burn(e: &Env, from: Address, token_id: u32) {␊
Self::ContractType::burn(e, &from, token_id);␊
}␊
␊
#[when_not_paused]␊
fn burn_from(e: &Env, spender: Address, from: Address, token_id: u32) {␊
Self::ContractType::burn_from(e, &spender, &from, token_id);␊
}␊
}␊
␊
//␊
// Utils␊
//␊
␊
#[contractimpl]␊
impl Pausable for MyToken {␊
fn paused(e: &Env) -> bool {␊
pausable::paused(e)␊
}␊
␊
#[only_owner]␊
fn pause(e: &Env, caller: Address) {␊
pausable::pause(e);␊
}␊
␊
#[only_owner]␊
fn unpause(e: &Env, caller: Address) {␊
pausable::unpause(e);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl Ownable for MyToken {}␊
`
## non-fungible mintable
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
use stellar_access::ownable::{self as ownable, Ownable};␊
use stellar_macros::{default_impl, only_owner};␊
use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
␊
#[only_owner]␊
pub fn mint(e: &Env, to: Address, token_id: u32, caller: Address) {␊
Base::mint(e, &to, token_id);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Base;␊
␊
}␊
␊
//␊
// Utils␊
//␊
␊
#[default_impl]␊
#[contractimpl]␊
impl Ownable for MyToken {}␊
`
## non-fungible enumerable
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{contract, contractimpl, Env, String};␊
use stellar_macros::default_impl;␊
use stellar_tokens::non_fungible::{␊
Base, enumerable::{NonFungibleEnumerable, Enumerable}, NonFungibleToken␊
};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Enumerable;␊
␊
}␊
␊
//␊
// Extensions␊
//␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleEnumerable for MyToken {}␊
`
## non-fungible consecutive
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
use stellar_access::ownable::{self as ownable, Ownable};␊
use stellar_macros::{default_impl, only_owner};␊
use stellar_tokens::non_fungible::{␊
Base, consecutive::{NonFungibleConsecutive, Consecutive}, NonFungibleToken␊
};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
␊
#[only_owner]␊
pub fn batch_mint(e: &Env, to: Address, amount: u32, caller: Address) -> u32 {␊
Consecutive::batch_mint(e, &to, amount)␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Consecutive;␊
␊
}␊
␊
//␊
// Extensions␊
//␊
␊
#[contractimpl]␊
impl NonFungibleConsecutive for MyToken {}␊
␊
//␊
// Utils␊
//␊
␊
#[default_impl]␊
#[contractimpl]␊
impl Ownable for MyToken {}␊
`
## non-fungible consecutive burnable
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
use stellar_access::ownable::{self as ownable, Ownable};␊
use stellar_macros::{default_impl, only_owner};␊
use stellar_tokens::non_fungible::{␊
Base, burnable::NonFungibleBurnable, consecutive::{NonFungibleConsecutive, Consecutive},␊
NonFungibleToken␊
};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
␊
#[only_owner]␊
pub fn batch_mint(e: &Env, to: Address, amount: u32, caller: Address) -> u32 {␊
Consecutive::batch_mint(e, &to, amount)␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Consecutive;␊
␊
}␊
␊
//␊
// Extensions␊
//␊
␊
#[contractimpl]␊
impl NonFungibleConsecutive for MyToken {}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleBurnable for MyToken {}␊
␊
//␊
// Utils␊
//␊
␊
#[default_impl]␊
#[contractimpl]␊
impl Ownable for MyToken {}␊
`
## non-fungible consecutive pausable
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
use stellar_access::ownable::{self as ownable, Ownable};␊
use stellar_contract_utils::pausable::{self as pausable, Pausable};␊
use stellar_macros::{default_impl, only_owner, when_not_paused};␊
use stellar_tokens::non_fungible::{␊
Base, consecutive::{NonFungibleConsecutive, Consecutive}, NonFungibleToken␊
};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
␊
#[when_not_paused]␊
#[only_owner]␊
pub fn batch_mint(e: &Env, to: Address, amount: u32, caller: Address) -> u32 {␊
Consecutive::batch_mint(e, &to, amount)␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Consecutive;␊
␊
#[when_not_paused]␊
fn transfer(e: &Env, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer(e, &from, &to, token_id);␊
}␊
␊
#[when_not_paused]␊
fn transfer_from(e: &Env, spender: Address, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer_from(e, &spender, &from, &to, token_id);␊
}␊
}␊
␊
//␊
// Extensions␊
//␊
␊
#[contractimpl]␊
impl NonFungibleConsecutive for MyToken {}␊
␊
//␊
// Utils␊
//␊
␊
#[contractimpl]␊
impl Pausable for MyToken {␊
fn paused(e: &Env) -> bool {␊
pausable::paused(e)␊
}␊
␊
#[only_owner]␊
fn pause(e: &Env, caller: Address) {␊
pausable::pause(e);␊
}␊
␊
#[only_owner]␊
fn unpause(e: &Env, caller: Address) {␊
pausable::unpause(e);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl Ownable for MyToken {}␊
`
## non-fungible consecutive burnable pausable
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
use stellar_access::ownable::{self as ownable, Ownable};␊
use stellar_contract_utils::pausable::{self as pausable, Pausable};␊
use stellar_macros::{default_impl, only_owner, when_not_paused};␊
use stellar_tokens::non_fungible::{␊
Base, burnable::NonFungibleBurnable, consecutive::{NonFungibleConsecutive, Consecutive},␊
NonFungibleToken␊
};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
␊
#[when_not_paused]␊
#[only_owner]␊
pub fn batch_mint(e: &Env, to: Address, amount: u32, caller: Address) -> u32 {␊
Consecutive::batch_mint(e, &to, amount)␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Consecutive;␊
␊
#[when_not_paused]␊
fn transfer(e: &Env, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer(e, &from, &to, token_id);␊
}␊
␊
#[when_not_paused]␊
fn transfer_from(e: &Env, spender: Address, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer_from(e, &spender, &from, &to, token_id);␊
}␊
}␊
␊
//␊
// Extensions␊
//␊
␊
#[contractimpl]␊
impl NonFungibleBurnable for MyToken {␊
#[when_not_paused]␊
fn burn(e: &Env, from: Address, token_id: u32) {␊
Self::ContractType::burn(e, &from, token_id);␊
}␊
␊
#[when_not_paused]␊
fn burn_from(e: &Env, spender: Address, from: Address, token_id: u32) {␊
Self::ContractType::burn_from(e, &spender, &from, token_id);␊
}␊
}␊
␊
#[contractimpl]␊
impl NonFungibleConsecutive for MyToken {}␊
␊
//␊
// Utils␊
//␊
␊
#[contractimpl]␊
impl Pausable for MyToken {␊
fn paused(e: &Env) -> bool {␊
pausable::paused(e)␊
}␊
␊
#[only_owner]␊
fn pause(e: &Env, caller: Address) {␊
pausable::pause(e);␊
}␊
␊
#[only_owner]␊
fn unpause(e: &Env, caller: Address) {␊
pausable::unpause(e);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl Ownable for MyToken {}␊
`
## non-fungible sequential
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{contract, contractimpl, Env, String};␊
use stellar_macros::default_impl;␊
use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊
␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Base;␊
␊
}␊
`
## non-fungible upgradeable
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
use stellar_access::ownable::{self as ownable, Ownable};␊
use stellar_contract_utils::upgradeable::UpgradeableInternal;␊
use stellar_macros::{default_impl, only_owner, Upgradeable};␊
use stellar_tokens::non_fungible::{Base, NonFungibleToken};␊
␊
#[derive(Upgradeable)]␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Base;␊
␊
}␊
␊
//␊
// Utils␊
//␊
␊
impl UpgradeableInternal for MyToken {␊
fn _require_auth(e: &Env, operator: &Address) {␊
ownable::enforce_owner_auth(e);␊
operator.require_auth();␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl Ownable for MyToken {}␊
`
## non-fungible with compatible options
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
use stellar_access::ownable::{self as ownable, Ownable};␊
use stellar_contract_utils::pausable::{self as pausable, Pausable};␊
use stellar_contract_utils::upgradeable::UpgradeableInternal;␊
use stellar_macros::{default_impl, only_owner, Upgradeable, when_not_paused};␊
use stellar_tokens::non_fungible::{␊
Base, burnable::NonFungibleBurnable, enumerable::{NonFungibleEnumerable, Enumerable},␊
NonFungibleToken␊
};␊
␊
#[derive(Upgradeable)]␊
#[contract]␊
pub struct MyToken;␊
␊
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "MyToken");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
␊
#[only_owner]␊
#[when_not_paused]␊
pub fn mint(e: &Env, to: Address, token_id: u32) {␊
Enumerable::non_sequential_mint(e, &to, token_id);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for MyToken {␊
type ContractType = Enumerable;␊
␊
#[when_not_paused]␊
fn transfer(e: &Env, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer(e, &from, &to, token_id);␊
}␊
␊
#[when_not_paused]␊
fn transfer_from(e: &Env, spender: Address, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer_from(e, &spender, &from, &to, token_id);␊
}␊
}␊
␊
//␊
// Extensions␊
//␊
␊
#[contractimpl]␊
impl NonFungibleBurnable for MyToken {␊
#[when_not_paused]␊
fn burn(e: &Env, from: Address, token_id: u32) {␊
Self::ContractType::burn(e, &from, token_id);␊
}␊
␊
#[when_not_paused]␊
fn burn_from(e: &Env, spender: Address, from: Address, token_id: u32) {␊
Self::ContractType::burn_from(e, &spender, &from, token_id);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleEnumerable for MyToken {}␊
␊
//␊
// Utils␊
//␊
␊
impl UpgradeableInternal for MyToken {␊
fn _require_auth(e: &Env, _operator: &Address) {␊
ownable::enforce_owner_auth(e);␊
}␊
}␊
␊
#[contractimpl]␊
impl Pausable for MyToken {␊
fn paused(e: &Env) -> bool {␊
pausable::paused(e)␊
}␊
␊
#[only_owner]␊
fn pause(e: &Env, _caller: Address) {␊
pausable::pause(e);␊
}␊
␊
#[only_owner]␊
fn unpause(e: &Env, _caller: Address) {␊
pausable::unpause(e);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl Ownable for MyToken {}␊
`
## non-fungible - complex name
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.4.1␊
#![no_std]␊
␊
use soroban_sdk::{Address, contract, contractimpl, Env, String};␊
use stellar_access::ownable::{self as ownable, Ownable};␊
use stellar_contract_utils::pausable::{self as pausable, Pausable};␊
use stellar_macros::{default_impl, only_owner, when_not_paused};␊
use stellar_tokens::non_fungible::{Base, burnable::NonFungibleBurnable, NonFungibleToken};␊
␊
#[contract]␊
pub struct CustomToken;␊
␊
#[contractimpl]␊
impl CustomToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
let uri = String::from_str(e, "www.mytoken.com");␊
let name = String::from_str(e, "Custom $ Token");␊
let symbol = String::from_str(e, "MTK");␊
Base::set_metadata(e, uri, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl NonFungibleToken for CustomToken {␊
type ContractType = Base;␊
␊
#[when_not_paused]␊
fn transfer(e: &Env, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer(e, &from, &to, token_id);␊
}␊
␊
#[when_not_paused]␊
fn transfer_from(e: &Env, spender: Address, from: Address, to: Address, token_id: u32) {␊
Self::ContractType::transfer_from(e, &spender, &from, &to, token_id);␊
}␊
}␊
␊
//␊
// Extensions␊
//␊
␊
#[contractimpl]␊
impl NonFungibleBurnable for CustomToken {␊
#[when_not_paused]␊
fn burn(e: &Env, from: Address, token_id: u32) {␊
Self::ContractType::burn(e, &from, token_id);␊
}␊
␊
#[when_not_paused]␊
fn burn_from(e: &Env, spender: Address, from: Address, token_id: u32) {␊
Self::ContractType::burn_from(e, &spender, &from, token_id);␊
}␊
}␊
␊
//␊
// Utils␊
//␊
␊
#[contractimpl]␊
impl Pausable for CustomToken {␊
fn paused(e: &Env) -> bool {␊
pausable::paused(e)␊
}␊
␊
#[only_owner]␊
fn pause(e: &Env, _caller: Address) {␊
pausable::pause(e);␊
}␊
␊
#[only_owner]␊
fn unpause(e: &Env, _caller: Address) {␊
pausable::unpause(e);␊
}␊
}␊
␊
#[default_impl]␊
#[contractimpl]␊
impl Ownable for CustomToken {}␊
`