Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement nft escrow contract example. #25

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ members = [
"contracts/multisig/interact",
"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*/
15 changes: 15 additions & 0 deletions contracts/nft-escrow/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "nft-escrow"
version = "0.0.0"
authors = [ "you",]
edition = "2018"
publish = false

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

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

[dev-dependencies.multiversx-sc-scenario]
version = "0.43.4"
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.43.4"
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
Loading