Skip to content

Commit

Permalink
Merge pull request #1227 from thounyy/master
Browse files Browse the repository at this point in the history
NFT Subscription module
  • Loading branch information
andrei-marinica authored Oct 6, 2023
2 parents 28d617f + 982f7ca commit d9c77f6
Show file tree
Hide file tree
Showing 18 changed files with 1,013 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ members = [
"contracts/examples/multisig/interact",
"contracts/examples/nft-minter",
"contracts/examples/nft-minter/meta",
"contracts/examples/nft-subscription",
"contracts/examples/nft-subscription/meta",
"contracts/examples/nft-storage-prepay",
"contracts/examples/nft-storage-prepay/meta",
"contracts/examples/order-book/factory",
Expand Down
7 changes: 7 additions & 0 deletions contracts/examples/nft-subscription/.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
21 changes: 21 additions & 0 deletions contracts/examples/nft-subscription/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "nft-subscription"
version = "0.0.0"
authors = ["Thouny <[email protected]>"]
edition = "2021"
publish = false

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

[dependencies.multiversx-sc]
version = "0.43.4"
path = "../../../framework/base"

[dependencies.multiversx-sc-modules]
version = "0.43.4"
path = "../../../contracts/modules"

[dev-dependencies.multiversx-sc-scenario]
version = "0.43.4"
path = "../../../framework/scenario"
13 changes: 13 additions & 0 deletions contracts/examples/nft-subscription/meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "nft-subscription-meta"
version = "0.0.0"
authors = ["Thouny <[email protected]>"]
edition = "2021"
publish = false

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

[dependencies.multiversx-sc-meta]
version = "0.43.4"
path = "../../../../framework/meta"
3 changes: 3 additions & 0 deletions contracts/examples/nft-subscription/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_subscription::AbiProvider>();
}
3 changes: 3 additions & 0 deletions contracts/examples/nft-subscription/multiversx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language": "rust"
}
78 changes: 78 additions & 0 deletions contracts/examples/nft-subscription/scenarios/init.scen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"name": "init",
"steps": [
{
"step": "setState",
"accounts": {
"address:owner": {
"nonce": "0",
"balance": "0"
},
"address:buyer": {
"nonce": "0",
"balance": "1000"
}
},
"newAddresses": [
{
"creatorAddress": "address:owner",
"creatorNonce": "0",
"newAddress": "sc:nft-subscription"
}
]
},
{
"step": "scDeploy",
"id": "deploy",
"tx": {
"from": "address:owner",
"contractCode": "file:../output/nft-subscription.wasm",
"arguments": [],
"gasLimit": "10,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "0",
"logs": [],
"gas": "*",
"refund": "*"
}
},
{
"step": "checkState",
"accounts": {
"sc:nft-subscription": {
"nonce": "0",
"balance": "0",
"storage": {},
"code": "file:../output/nft-subscription.wasm"
},
"+": ""
}
},
{
"step": "setState",
"accounts": {
"sc:nft-subscription": {
"nonce": "0",
"balance": "0",
"esdt": {
"str:NFT-123456": {
"lastNonce": "0",
"roles": [
"ESDTRoleNFTCreate",
"ESDTRoleNFTUpdateAttributes"
]
}
},
"storage": {
"str:tokenId": "str:NFT-123456"
},
"code": "file:../output/nft-subscription.wasm",
"owner": "address:owner"
}
}
}
]
}
92 changes: 92 additions & 0 deletions contracts/examples/nft-subscription/scenarios/mint_nft.scen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"name": "mint and update nft",
"steps": [
{
"step": "externalSteps",
"path": "init.scen.json"
},
{
"step": "scCall",
"id": "create-NFT-1",
"tx": {
"from": "address:owner",
"to": "sc:nft-subscription",
"function": "mint",
"arguments": [],
"gasLimit": "20,000,000",
"gasPrice": "0"
}
},
{
"step": "checkState",
"accounts": {
"address:owner": {
"nonce": "2",
"balance": "0",
"esdt": {
"str:NFT-123456": {
"instances": [
{
"nonce": "1",
"balance": "1",
"creator": "sc:nft-subscription",
"attributes": {
"0-expiration": "u64:0",
"1-attributes": "nested:str:common"
}
}
]
}
}
},
"+": ""
}
},
{
"step": "scCall",
"id": "update-NFT-1",
"tx": {
"from": "address:owner",
"to": "sc:nft-subscription",
"esdtValue": [
{
"tokenIdentifier": "str:NFT-123456",
"nonce": "1",
"value": "1"
}
],
"function": "update_attributes",
"arguments": [
"str:rare"
],
"gasLimit": "20,000,000",
"gasPrice": "0"
}
},
{
"step": "checkState",
"accounts": {
"address:owner": {
"nonce": "3",
"balance": "0",
"esdt": {
"str:NFT-123456": {
"instances": [
{
"nonce": "1",
"balance": "1",
"creator": "sc:nft-subscription",
"attributes": {
"0-expiration": "u64:0",
"1-attributes": "nested:str:rare"
}
}
]
}
}
},
"+": ""
}
}
]
}
Loading

0 comments on commit d9c77f6

Please sign in to comment.