Giter Site home page Giter Site logo

marketplace's Introduction

NFT Marketplace project

This contract is an example for the NFT marketplace implementation. The contract currently supports 2 token types PSP34 and RMRK

License

Apache 2.0

๐Ÿ—๏ธ How to use - Contracts

๐Ÿ’ซ Build

Clone project

git clone [email protected]:swanky-dapps/marketplace.git

Navigate yourself to marketplace directory

cd marketplace/contracts/marketplace
cargo contract build
๐Ÿ’ซ Run unit test
cargo test
๐Ÿ’ซ Run integration test

First start your local node. Recommended the latest swanky-node. After you download and unzip Swanky package for your OS, run it with

./swanky-node --dev --tmp -lruntime=trace -lruntime::contracts=debug -lerror

Navigate to Marketplace project root folder and run the following commands:

yarn
yarn compile
yarn test
๐Ÿ’ซ Deploy

To manually deploy the contract to local Swanky node or any other node that supports contracts pallet use Contracts UI

marketplace's People

Contributors

bobo-k2 avatar maar-io avatar vikiival avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

marketplace's Issues

no matching package named `pallet_payable_mint` found

I was trying to build the project #5

but seems like some dependency is missing

2023-01-22T19:20:30.472966Z  INFO cargo_contract::util: Invoking cargo: "/Users/vikival/.rustup/toolchains/nightly-2022-08-15-aarch64-apple-darwin/bin/cargo" "build" "--target=wasm32-unknown-unknown" "-Zbuild-std" "--no-default-features" "--release" "--target-dir=/Users/vikival/Documents/Work/KodaDot/marketplace/target/ink/marketplace" "--features=ink_env/ink-debug"
    Updating crates.io index
    Updating git repository `https://github.com/Supercolony-net/openbrush-contracts`
    Updating git repository `https://github.com/Supercolony-net/pallet-assets-chain-extension`
    Updating git repository `https://github.com/swanky-dapps/nft`
error: no matching package named `pallet_payable_mint` found
location searched: https://github.com/swanky-dapps/nft
required by package `shiden34 v0.2.0 (/private/var/folders/tw/g2bzmzdn51q9v0z03y3nb9fr0000gn/T/cargo-contract_YmbDpK/contracts/shiden34)`
    ... which satisfies path dependency `shiden34` of package `pallet_marketplace v0.2.0 (/private/var/folders/tw/g2bzmzdn51q9v0z03y3nb9fr0000gn/T/cargo-contract_YmbDpK/logics)`
    ... which satisfies path dependency `pallet_marketplace` of package `marketplace v0.2.0 (/private/var/folders/tw/g2bzmzdn51q9v0z03y3nb9fr0000gn/T/cargo-contract_YmbDpK/contracts/marketplace)`
ERROR: `"/Users/vikival/.rustup/toolchains/nightly-2022-08-15-aarch64-apple-darwin/bin/cargo" "build" "--target=wasm32-unknown-unknown" "-Zbuild-std" "--no-default-features" "--release" "--target-dir=~/marketplace/target/ink/marketplace" "--features=ink_env/ink-debug"` failed with exit code: Some(101)

Unable to Init smart contract via factory

I have problems with calling factory function on the marketplace contract.

I though first time that I did not set contract hash but the error is still there.

Built with latest main at hash 0xedf9dde8b7c52a23ef3972268217a92f3c356707388aaa68a3952e31973797c3

Failed Txs
https://shibuya.subscan.io/account/Z7rYZFFCFt9B2cv692TSWnxTKM1CYnoukBhxUd39ajsYWTe

Example of call:

Screenshot 2023-01-23 at 13 28 21

The supplied hash of RMRK smart contract

0xd22f1aabf3d04bfba1ef5d0b5a5e1fa4764df7224afd1ee1422a8344a54b490f

MarketPlace does not emit any events

The exported data told me there is no event emitted for the whole marketplace.

The minimum I have out of my head

    /// should be also emitted for unlist
    #[ink(event)]
    pub struct TokenListed {
        #[ink(topic)]
        contract: AccountId,
        #[ink(topic)]
        id: Id,
        #[ink(topic)]
        price: Option<Balance>,
    }
    
    /// price 'cause user can send more
    #[ink(event)]
    pub struct TokenBought {
        #[ink(topic)]
        contract: AccountId,
        #[ink(topic)]
        id: Id,
        #[ink(topic)]
        price: Balance,
    }
    
    /// can be also emitted for factory
     #[ink(event)]
     pub struct CollectionRegistered {
        #[ink(topic)]
        contract: AccountId,
        metadada: Bytes
    }
export type Event = never

export type Message = Message_MarketplaceSale_unlist | Message_MarketplaceSale_register | Message_MarketplaceSale_buy | Message_MarketplaceSale_set_marketplace_fee | Message_MarketplaceSale_set_fee_recipient | Message_MarketplaceSale_get_price | Message_MarketplaceSale_list | Message_MarketplaceSale_factory | Message_MarketplaceSale_get_max_fee | Message_MarketplaceSale_get_registered_collection | Message_MarketplaceSale_get_marketplace_fee | Message_MarketplaceSale_set_nft_contract_hash | Message_MarketplaceSale_get_fee_recipient | Message_MarketplaceSale_set_contract_metadata | Message_MarketplaceSale_nft_contract_hash

Substrate node

Is this compatible with Substrate node?

My node is running and all installation is completed. However, when run yarn test I failed all of the cases.

Marketplace tests
2023-01-27 21:36:24 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
1) setup and mint works
2023-01-27 21:36:25 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
2) setMarketplaceFee works
2023-01-27 21:36:25 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
3) register contract works for the Marketplace owner
2023-01-27 21:36:25 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
4) register contract fails if fee is too high
2023-01-27 21:36:25 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
5) list / unlist works
2023-01-27 21:36:25 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
6) list fails if not a nft owner
2023-01-27 21:36:25 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
7) list fails if token is already listed
2023-01-27 21:36:25 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
8) unlist fails if token is not listed
2023-01-27 21:36:25 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
9) buy works
2023-01-27 21:36:26 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
10) setContractMetadata works
2023-01-27 21:36:26 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
11) setContractMetadata returns error if no contract
2023-01-27 21:36:26 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
12) setNftContractHash works
2023-01-27 21:36:26 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
13) setNftContractHash fails if not an owner
2023-01-27 21:36:26 API/INIT: RPC methods not decorated: transaction_unstable_submitAndWatch, transaction_unstable_unwatch
14) factory works
0 passing (2s)
14 failing

  1. Marketplace tests
    setup and mint works:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:73:5)

  2. Marketplace tests
    setMarketplaceFee works:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:82:5)

  3. Marketplace tests
    register contract works for the Marketplace owner:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:90:5)

  4. Marketplace tests
    register contract fails if fee is too high:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at processImmediate (node:internal/timers:446:9)
    at async Context. (tests/marketplace.spec.ts:101:5)

  5. Marketplace tests
    list / unlist works:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:111:5)

  6. Marketplace tests
    list fails if not a nft owner:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:132:5)

  7. Marketplace tests
    list fails if token is already listed:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:144:5)

  8. Marketplace tests
    unlist fails if token is not listed:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:159:5)

  9. Marketplace tests
    buy works:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:171:5)

  10. Marketplace tests
    setContractMetadata works:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:217:5)

  11. Marketplace tests
    setContractMetadata returns error if no contract:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:229:5)

  12. Marketplace tests
    setNftContractHash works:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:239:5)

  13. Marketplace tests
    setNftContractHash fails if not an owner:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at processImmediate (node:internal/timers:446:9)
    at async Context. (tests/marketplace.spec.ts:251:5)

  14. Marketplace tests
    factory works:
    Error: The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit
    at new Base (node_modules/@polkadot/api-contract/cjs/base/Base.js:17:13)
    at new Code (node_modules/@polkadot/api-contract/cjs/base/Code.js:29:5)
    at new CodePromise (node_modules/@polkadot/api-contract/cjs/promise/index.js:20:5)
    at Constructors.new (types/constructors/marketplace.ts:32:16)
    at setup (tests/marketplace.spec.ts:61:59)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Context. (tests/marketplace.spec.ts:262:5)

error Command failed with exit code 14.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.