Skip to content

Commit

Permalink
Merge develop (#263)
Browse files Browse the repository at this point in the history
* Feature: NFT permissions (#233)

* Refactor NFT permissions

* Listing NFTs in orderbook creates a transfer cap (#244)

* Listing NFTs in orderbook creates a transfer cap

* One sentence per line

* Feature: Nft df domains (#245)

Nft df domains

* Fixing orderbook funds recipient (#247)

* Feature: Limited market (#246)

LimitedFixedPriceMarket

* Chore: MintCap issues (#253)

NFT permissions cleanup

* Free for all allowlist is now deployed by default (#254)

* Orderbook endpoints which minimise txs (#255)

* Endpoint to cancel ask and discard the transfer cap in a single tx (#258)

* TransferAllowlistDomain (#257)

* Free for all allowlist (#256)

* Chore: Update devnet-0.26.0 (#261)

* Publish devnet-0.26.0

* Bump dependency

* Chore: Release 0.23.0 (#262)

Deployed v.0.23.0

---------

Co-authored-by: Nuno Boavida <[email protected]>

* Adding endpoint to edit an ask (#265)

Co-authored-by: porkbrain <[email protected]>

* Republish (#266)

---------

Co-authored-by: porkbrain <[email protected]>
Co-authored-by: Nuno Boavida <[email protected]>
  • Loading branch information
3 people authored Feb 16, 2023
1 parent 69c75fc commit 2458d4b
Show file tree
Hide file tree
Showing 50 changed files with 2,551 additions and 807 deletions.
2 changes: 1 addition & 1 deletion .env.dist
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SUI_VERSION="devnet-0.24.0"
SUI_VERSION="devnet-0.26.0"
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,43 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.23.0] - 2023-02-16

### Added

- `TransferAllowlistDomain` which keeps track of shared object IDs of type `Allowlist`.
- Helper endpoints in orderbook which allow marketplaces to perform actions in a single tx.
The marketplaces can now
- `deposit_and_list_nft` (and with commission)
- `create_safe_and_deposit_and_list_nft` (and with commission)
- `create_safe_and_buy_nft`
- `create_safe_and_buy_generic_nft`
- `cancel_ask_and_discard_transfer_cap`
- `edit_ask`
- Added static `name` and `url` fields to `Nft` for better integration with explorer.
- Added `LimitedFixedPriceMarket`
- `orderbook::list_nft` and `orderbook::list_nft_with_commission` endpoints.
These allow the client to skip the creation of transfer caps and instead provide `OwnerCap` to `Safe` directly to the orderbook contract.

### Changed

- Updated to Devnet 0.26.0
- `transfer_allowlist::remove_itself` is now an entry function.
- Revamped NFT domain permissions and control over them
- `Collection` and `Nft` were reverted to use dynamic fields instead of dynamic object fields.
- Migrated all domains not requiring `key` property after loosening `key` requirement on `Nft` and `Collection` domains.

### Fixed

- Orderbook recipient was wrong when trading in orderbook.

## [0.22.0] - 2023-02-02

### Added

- Introduced `DelegatedWitness` pattern
- Refactored `CreatorsDomain` to support `DelegatedWitness` and introduced `PluginDomain`

### Changed

- Renamed `CollectionMintEvent` to `MintCollectionEvent` to be consistent with
Expand Down
12 changes: 6 additions & 6 deletions Move.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
name = "NftProtocol"
version = "0.22.0"
version = "0.23.0"

[dependencies.Sui]
git = "https://github.com/MystenLabs/sui.git"
subdir = "crates/sui-framework"
# devnet-0.24.0
rev = "f911c73bb0502ebbf34720e76daa1d698e51b9f0"
# devnet-0.26.0
rev = "b63532e36df5b1fcccff3893509259494c719a78"

[dependencies.Originmate]
git = "https://github.com/Origin-Byte/originmate.git"
# devnet-0.24.0
rev = "55d0ca3a9c2dd8d9489df3dcaef1d07755c56cf9"
# devnet-0.26.0
rev = "86ff9808166af83695df9cbadd9eef44ba0f4d59"

[addresses]
nft_protocol = "0x481c2e6a9961a67aced2f1b9d4094d4ba2badc98"
nft_protocol = "0xabea22bd189925217062c5122b087df5f5745137"
169 changes: 15 additions & 154 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,174 +1,35 @@
- Sui v0.24.0
<a href="https://originbyte.io/">
<h1><img src="./assets/logo.svg" alt="OriginByte" width="50%"></h1>
</a>

Checkout our:
<h3>A new approach to NFTs</h3>

- Devnet contract on the [Sui Explorer](https://explorer.sui.io/object/0x481c2e6a9961a67aced2f1b9d4094d4ba2badc98?network=devnet)
- [Official Documentation](https://docs.originbyte.io/origin-byte/)
- [Developer Documentation](https://origin-byte.github.io/)

# OriginByte

A new approach to NFTs.

Origin-Byte is an ecosystem of tools, standards and smart contracts designed to
make life easier for Web3 Game Developers and NFT creators. From simple artwork
to complex gaming assets, we want to help you reach the public, and provide
on-chain market infrastructure.
Origin-Byte is an ecosystem of tools, standards, and smart contracts designed to make life easier for Web3 Game Developers and NFT creators.
From simple artwork to complex gaming assets, we want to help you reach the public, and provide on-chain market infrastructure.

The ecosystem is partitioned into three critical components:

- The NFT standard, encompassing the core `Nft`, `Collection`, and `Safe` types,
controlling the lifecycle and properties of each NFT.
- Primary markets, encompassing `Marketplace`, `Listing`, and numerous markets which
control the initial minting of NFTs.
control the initial minting and sale of NFTs.
- Secondary markets, encompassing principally the `Orderbook` which allows you
to trade existing NFTs.

## Resources

- Devnet contract on the [Sui Explorer](https://explorer.sui.io/object/0xde886c0410106e811bc4a67957fed77e456831d2?network=devnet)
- [Official Documentation](https://docs.originbyte.io/origin-byte/)
- [Developer Documentation](https://origin-byte.github.io/)

# Install

This codebase requires installation of the [Sui CLI](https://docs.sui.io/build/install).

If you are running on Linux you can use [suivm](https://github.com/Origin-Byte/suivm) to handle installation for you.

# Built and Test

1. `$ sui move build` to build the available move modules
2. `$ sui move test` to run the move tests
3. `./bin/publish.sh` to publish the modules on localnet or devnet

# Deploy an NFT collection

To deploy an NFT collection you will need to create a SUI [Move](https://docs.sui.io/build/move) contract, which plugs into our protocol.

We provide an example on how to build such collection in the examples folder. Additionally below follows an example of an NFT Collection, the SUIMARINES!

```move
module nft_protocol::suimarines {
use std::string::{Self, String};
use sui::url;
use sui::balance;
use sui::transfer;
use sui::tx_context::{Self, TxContext};
use nft_protocol::nft;
use nft_protocol::tags;
use nft_protocol::royalty;
use nft_protocol::display;
use nft_protocol::creators;
use nft_protocol::inventory::{Self, Inventory};
use nft_protocol::royalties::{Self, TradePayment};
use nft_protocol::collection::{Self, Collection, MintCap};
/// One time witness is only instantiated in the init method
struct SUIMARINES has drop {}
/// Can be used for authorization of other actions post-creation. It is
/// vital that this struct is not freely given to any contract, because it
/// serves as an auth token.
struct Witness has drop {}
fun init(witness: SUIMARINES, ctx: &mut TxContext) {
let (mint_cap, collection) = collection::create(
&witness, ctx,
);
collection::add_domain(
&mut collection,
&mut mint_cap,
creators::from_address(tx_context::sender(ctx))
);
// Register custom domains
display::add_collection_display_domain(
&mut collection,
&mut mint_cap,
string::utf8(b"Suimarines"),
string::utf8(b"A unique NFT collection of Suimarines on Sui"),
);
display::add_collection_url_domain(
&mut collection,
&mut mint_cap,
sui::url::new_unsafe_from_bytes(b"https://originbyte.io/"),
);
display::add_collection_symbol_domain(
&mut collection,
&mut mint_cap,
string::utf8(b"SUIM")
);
let royalty = royalty::from_address(tx_context::sender(ctx), ctx);
royalty::add_proportional_royalty(&mut royalty, 100);
royalty::add_royalty_domain(&mut collection, &mut mint_cap, royalty);
let tags = tags::empty(ctx);
tags::add_tag(&mut tags, tags::art());
tags::add_collection_tag_domain(&mut collection, &mut mint_cap, tags);
transfer::transfer(mint_cap, tx_context::sender(ctx));
transfer::share_object(collection);
}
/// Calculates and transfers royalties to the `RoyaltyDomain`
public entry fun collect_royalty<FT>(
payment: &mut TradePayment<SUIMARINES, FT>,
collection: &mut Collection<SUIMARINES>,
ctx: &mut TxContext,
) {
let b = royalties::balance_mut(Witness {}, payment);
let domain = royalty::royalty_domain(collection);
let royalty_owed =
royalty::calculate_proportional_royalty(domain, balance::value(b));
royalty::collect_royalty(collection, b, royalty_owed);
royalties::transfer_remaining_to_beneficiary(Witness {}, payment, ctx);
}
public entry fun mint_nft(
name: String,
description: String,
url: vector<u8>,
attribute_keys: vector<String>,
attribute_values: vector<String>,
_mint_cap: &MintCap<SUIMARINES>,
inventory: &mut Inventory,
ctx: &mut TxContext,
) {
let nft = nft::new<SUIMARINES, Witness>(
&Witness {}, tx_context::sender(ctx), ctx
);
display::add_display_domain(
&mut nft,
name,
description,
ctx,
);
display::add_url_domain(
&mut nft,
url::new_unsafe_from_bytes(url),
ctx,
);
display::add_attributes_domain_from_vec(
&mut nft,
attribute_keys,
attribute_values,
ctx,
);
inventory::deposit_nft(inventory, nft);
}
}
```

and in your `Move.toml`, define the following dependency:

```toml
[dependencies.NftProtocol]
git = "https://github.com/Origin-Byte/nft-protocol.git"
# v0.22.0
rev = "7a19d30aa84faa335d722832f869c4f08a8c487a"
```
26 changes: 26 additions & 0 deletions assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 11 additions & 10 deletions examples/footbytes.move
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module nft_protocol::footbytes {
use nft_protocol::tags;
use nft_protocol::royalty;
use nft_protocol::display;
use nft_protocol::witness;
use nft_protocol::creators;
use nft_protocol::template;
use nft_protocol::templates;
Expand All @@ -27,12 +28,14 @@ module nft_protocol::footbytes {

fun init(witness: FOOTBYTES, ctx: &mut TxContext) {
let (mint_cap, collection) = collection::create(&witness, ctx);
let delegated_witness = nft_protocol::witness::from_witness(&witness);
let delegated_witness = witness::from_witness(&Witness {});

collection::add_domain(
delegated_witness,
&mut collection,
creators::from_address(&witness, tx_context::sender(ctx), ctx),
creators::from_address<FOOTBYTES, Witness>(
&Witness {}, tx_context::sender(ctx),
),
);

// Register custom domains
Expand All @@ -41,21 +44,18 @@ module nft_protocol::footbytes {
&mut collection,
string::utf8(b"Football digital stickers"),
string::utf8(b"A NFT collection of football player collectibles"),
ctx,
);

display::add_collection_url_domain(
delegated_witness,
&mut collection,
sui::url::new_unsafe_from_bytes(b"https://originbyte.io/"),
ctx,
);

display::add_collection_symbol_domain(
delegated_witness,
&mut collection,
string::utf8(b"FOOT"),
ctx
);

let royalty = royalty::from_address(tx_context::sender(ctx), ctx);
Expand Down Expand Up @@ -108,15 +108,16 @@ module nft_protocol::footbytes {
supply: u64,
ctx: &mut TxContext,
) {
let nft = nft::new(mint_cap, tx_context::sender(ctx), ctx);
let url = url::new_unsafe_from_bytes(url);

let nft = nft::from_mint_cap(mint_cap, name, url, ctx);
let delegated_witness = witness::from_witness(&Witness {});

display::add_display_domain(
&mut nft, name, description, ctx,
delegated_witness, &mut nft, name, description,
);

display::add_url_domain(
&mut nft, url::new_unsafe_from_bytes(url), ctx,
);
display::add_url_domain(delegated_witness, &mut nft, url);

let template = template::new_regulated(nft, supply, ctx);
templates::add_collection_template(mint_cap, collection, template);
Expand Down
Loading

0 comments on commit 2458d4b

Please sign in to comment.