Skip to content

Commit

Permalink
Implement nft escrow contract example.
Browse files Browse the repository at this point in the history
  • Loading branch information
raress96 authored Oct 2, 2023
1 parent 3f65acd commit 09dfbe3
Show file tree
Hide file tree
Showing 18 changed files with 1,497 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ members = [
"contracts/multisig/interact-rs",
"contracts/mystery-box",
"contracts/mystery-box/meta",
"contracts/nft-escrow",
"contracts/nft-escrow/meta",
"contracts/nft-minter",
"contracts/nft-minter/meta",
"contracts/nft-storage-prepay",
Expand Down
7 changes: 7 additions & 0 deletions contracts/nft-escrow/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
*/target/

# The mxpy output
/output*/
18 changes: 18 additions & 0 deletions contracts/nft-escrow/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "nft-escrow"
version = "0.0.0"
authors = [ "you",]
edition = "2018"
publish = false

[lib]
path = "src/lib.rs"

[dev-dependencies]
num-bigint = "0.4.2"

[dependencies.multiversx-sc]
version = "0.41.1"

[dev-dependencies.multiversx-sc-scenario]
version = "0.41.1"
14 changes: 14 additions & 0 deletions contracts/nft-escrow/meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "nft-escrow-meta"
version = "0.0.0"
edition = "2018"
publish = false
authors = [ "you",]

[dev-dependencies]

[dependencies.nft-escrow]
path = ".."

[dependencies.multiversx-sc-meta]
version = "0.41.1"
3 changes: 3 additions & 0 deletions contracts/nft-escrow/meta/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
multiversx_sc_meta::cli_main::<nft_escrow::AbiProvider>();
}
3 changes: 3 additions & 0 deletions contracts/nft-escrow/multiversx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language": "rust"
}
18 changes: 18 additions & 0 deletions contracts/nft-escrow/mxsc-template.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name = "empty"
contract_trait = "EmptyContract"
src_file = "empty.rs"
rename_pairs = [
[
"blockchain.set_current_dir_from_workspace(\"contracts/examples/empty\");",
"// blockchain.set_current_dir_from_workspace(\"relative path to your workspace, if applicable\");",
],
]
files_include = [
"meta",
"scenarios",
"src",
"tests",
"wasm/Cargo.toml",
"Cargo.toml",
"multiversx.json",
]
254 changes: 254 additions & 0 deletions contracts/nft-escrow/scenarios/accept.scen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
{
"name": "buy nft",
"steps": [
{
"step": "externalSteps",
"path": "escrow.scen.json"
},
{
"step": "scCall",
"id": "accept-offer-not-exists",
"tx": {
"from": "address:second",
"to": "sc:nft-escrow",
"egldValue": "0",
"function": "accept",
"arguments": [
"2"
],
"gasLimit": "10,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "4",
"message": "str:Offer does not exist",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "accept-offer-only-wanted",
"tx": {
"from": "address:first",
"to": "sc:nft-escrow",
"egldValue": "0",
"function": "accept",
"arguments": [
"1"
],
"gasLimit": "10,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "4",
"message": "str:Can not accept this offer",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "accept-other-token",
"tx": {
"from": "address:second",
"to": "sc:nft-escrow",
"egldValue": "0",
"function": "accept",
"arguments": [
"1"
],
"esdtValue": [
{
"tokenIdentifier": "str:SEMIFUNG-123456",
"value": "1000",
"nonce": "1"
}
],
"gasLimit": "10,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "4",
"message": "str:NFT does not match",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "accept-other-nonce",
"tx": {
"from": "address:second",
"to": "sc:nft-escrow",
"egldValue": "0",
"function": "accept",
"arguments": [
"1"
],
"esdtValue": [
{
"tokenIdentifier": "str:NFT2-654321",
"value": "1",
"nonce": "1"
}
],
"gasLimit": "10,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "4",
"message": "str:NFT does not match",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "accept-other-amount",
"tx": {
"from": "address:second",
"to": "sc:nft-escrow",
"egldValue": "0",
"function": "accept",
"arguments": [
"1"
],
"esdtValue": [
{
"tokenIdentifier": "str:NFT2-654321",
"value": "2",
"nonce": "2"
}
],
"gasLimit": "10,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "4",
"message": "str:NFT does not match",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "accept",
"tx": {
"from": "address:second",
"to": "sc:nft-escrow",
"egldValue": "0",
"function": "accept",
"arguments": [
"1"
],
"esdtValue": [
{
"tokenIdentifier": "str:NFT2-654321",
"value": "1",
"nonce": "2"
}
],
"gasLimit": "10,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "0",
"gas": "*",
"refund": "*"
}
},
{
"step": "checkState",
"accounts": {
"address:first": {
"nonce": "6",
"balance": "0",
"esdt": {
"str:FUNG-123456": "1000",
"str:SEMIFUNG-123456": {
"instances": [
{
"nonce": "1",
"balance": "1000"
}
]
},
"str:NFT-123456": {
"instances": [
{
"nonce": "2",
"balance": "1"
}
]
},
"str:NFT2-654321": {
"instances": [
{
"nonce": "2",
"balance": "1"
}
]
}
}
},
"address:second": {
"nonce": "5",
"balance": "0",
"esdt": {
"str:FUNG-123456": "1000",
"str:SEMIFUNG-123456": {
"instances": [
{
"nonce": "1",
"balance": "1000"
}
]
},
"str:NFT-123456": {
"instances": [
{
"nonce": "1",
"balance": "1"
}
]
},
"str:NFT2-654321": {
"instances": [
{
"nonce": "1",
"balance": "1"
},
{
"nonce": "2",
"balance": "1"
}
]
}
}
},
"sc:nft-escrow": {
"nonce": "0",
"balance": "0",
"esdt": {
"str:NFT-123456": {
"instances": []
}
},
"storage": {
"str:lastOfferId": "1"
},
"code": "file:../output/nft-escrow.wasm",
"owner": "address:owner"
},
"+": ""
}
}
]
}
Loading

0 comments on commit 09dfbe3

Please sign in to comment.