Skip to content

Commit 86f5669

Browse files
authored
Merge pull request #452 from CosmWasm/forward-port-440-demo-metadata-extension
Forward port 440 demo metadata extension
2 parents 0077ba1 + bd87e38 commit 86f5669

24 files changed

+1353
-20
lines changed

.circleci/config.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ workflows:
1717
- contract_cw20_staking
1818
- contract_cw20_merkle_airdrop
1919
- contract_cw721_base
20+
- contract_cw721_metadata_uri
2021
- contract_cw1155_base
2122
- package_controllers
2223
- package_cw0
@@ -548,6 +549,43 @@ jobs:
548549
- target
549550
key: cargocache-cw721-base-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }}
550551

552+
553+
contract_cw721_metadata_uri:
554+
docker:
555+
- image: rust:1.53.0
556+
working_directory: ~/project/contracts/cw721-metadata-uri
557+
steps:
558+
- checkout:
559+
path: ~/project
560+
- run:
561+
name: Version information
562+
command: rustc --version; cargo --version; rustup --version
563+
- restore_cache:
564+
keys:
565+
- cargocache-cw721-metadata-uri-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }}
566+
- run:
567+
name: Unit Tests
568+
environment:
569+
RUST_BACKTRACE: 1
570+
command: cargo unit-test --locked
571+
- run:
572+
name: Build and run schema generator
573+
command: cargo schema --locked
574+
- run:
575+
name: Ensure checked-in schemas are up-to-date
576+
command: |
577+
CHANGES_IN_REPO=$(git status --porcelain)
578+
if [[ -n "$CHANGES_IN_REPO" ]]; then
579+
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
580+
git status && git --no-pager diff
581+
exit 1
582+
fi
583+
- save_cache:
584+
paths:
585+
- /usr/local/cargo/registry
586+
- target
587+
key: cargocache-cw721-metadata-uri-rust:1.53.0-{{ checksum "~/project/Cargo.lock" }}
588+
551589
contract_cw1155_base:
552590
docker:
553591
- image: rust:1.53.0

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ incremental = false
4545
codegen-units = 1
4646
incremental = false
4747

48+
[profile.release.package.cw20-merkle-airdrop]
49+
codegen-units = 1
50+
incremental = false
51+
4852
[profile.release.package.cw20-staking]
4953
codegen-units = 1
5054
incremental = false
@@ -53,6 +57,10 @@ incremental = false
5357
codegen-units = 1
5458
incremental = false
5559

60+
[profile.release.package.cw721-metadata-uri]
61+
codegen-units = 1
62+
incremental = false
63+
5664
[profile.release.package.cw1155-base]
5765
codegen-units = 1
5866
incremental = false

contracts/cw721-base/examples/schema.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use cw721::{
77
AllNftInfoResponse, ApprovedForAllResponse, ContractInfoResponse, NftInfoResponse,
88
NumTokensResponse, OwnerOfResponse, TokensResponse,
99
};
10-
use cw721_base::entry::Extension;
11-
use cw721_base::msg::{ExecuteMsg, InstantiateMsg, MinterResponse, QueryMsg};
10+
use cw721_base::{ExecuteMsg, Extension, InstantiateMsg, MinterResponse, QueryMsg};
1211

1312
fn main() {
1413
let mut out_dir = current_dir().unwrap();

contracts/cw721-base/src/contract_tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use cw721::{
77
NftInfoResponse, OwnerOfResponse,
88
};
99

10-
use crate::entry::Extension;
11-
use crate::{ContractError, Cw721Contract, ExecuteMsg, InstantiateMsg, MintMsg, QueryMsg};
10+
use crate::{
11+
ContractError, Cw721Contract, ExecuteMsg, Extension, InstantiateMsg, MintMsg, QueryMsg,
12+
};
1213

1314
const MINTER: &str = "merlin";
1415
const CONTRACT_NAME: &str = "Magic Power";

contracts/cw721-base/src/lib.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,44 @@ pub mod state;
88
pub use crate::error::ContractError;
99
pub use crate::msg::{ExecuteMsg, InstantiateMsg, MintMsg, MinterResponse, QueryMsg};
1010
pub use crate::state::Cw721Contract;
11+
use cosmwasm_std::Empty;
1112

13+
// This is a simple type to let us handle empty extensions
14+
pub type Extension = Option<Empty>;
15+
16+
#[cfg(not(feature = "library"))]
1217
pub mod entry {
1318
use super::*;
1419

15-
#[cfg(not(feature = "library"))]
1620
use cosmwasm_std::entry_point;
17-
use cosmwasm_std::{Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult};
18-
19-
// This is a simple type to let us handle empty extensions
20-
pub type Extension = Option<Empty>;
21+
use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
2122

2223
// This makes a conscious choice on the various generics used by the contract
23-
#[cfg_attr(not(feature = "library"), entry_point)]
24+
#[entry_point]
2425
pub fn instantiate(
2526
deps: DepsMut,
2627
env: Env,
2728
info: MessageInfo,
28-
msg: msg::InstantiateMsg,
29+
msg: InstantiateMsg,
2930
) -> StdResult<Response> {
30-
let tract = state::Cw721Contract::<Extension, Empty>::default();
31+
let tract = Cw721Contract::<Extension, Empty>::default();
3132
tract.instantiate(deps, env, info, msg)
3233
}
3334

34-
#[cfg_attr(not(feature = "library"), entry_point)]
35+
#[entry_point]
3536
pub fn execute(
3637
deps: DepsMut,
3738
env: Env,
3839
info: MessageInfo,
39-
msg: msg::ExecuteMsg<Extension>,
40+
msg: ExecuteMsg<Extension>,
4041
) -> Result<Response, ContractError> {
41-
let tract = state::Cw721Contract::<Extension, Empty>::default();
42+
let tract = Cw721Contract::<Extension, Empty>::default();
4243
tract.execute(deps, env, info, msg)
4344
}
4445

45-
#[cfg_attr(not(feature = "library"), entry_point)]
46-
pub fn query(deps: Deps, env: Env, msg: msg::QueryMsg) -> StdResult<Binary> {
47-
let tract = state::Cw721Contract::<Extension, Empty>::default();
46+
#[entry_point]
47+
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
48+
let tract = Cw721Contract::<Extension, Empty>::default();
4849
tract.query(deps, env, msg)
4950
}
5051
}

contracts/cw721-base/src/msg.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
use cosmwasm_std::Binary;
2-
use cw721::Expiration;
31
use schemars::JsonSchema;
42
use serde::{Deserialize, Serialize};
53

4+
use cosmwasm_std::Binary;
5+
use cw721::Expiration;
6+
67
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
78
pub struct InstantiateMsg {
89
/// Name of the NFT contract
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[alias]
2+
wasm = "build --release --target wasm32-unknown-unknown"
3+
wasm-debug = "build --target wasm32-unknown-unknown"
4+
unit-test = "test --lib"
5+
schema = "run --example schema"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[package]
2+
name = "cw721-metadata-uri"
3+
version = "0.9.0"
4+
authors = ["Ethan Frey <ethanfrey@users.noreply.github.com>"]
5+
edition = "2018"
6+
description = "Example extending CW721 NFT with ERC20 like metadata_uri"
7+
license = "Apache-2.0"
8+
repository = "https://github.com/CosmWasm/cw-plus"
9+
homepage = "https://cosmwasm.com"
10+
documentation = "https://docs.cosmwasm.com"
11+
12+
exclude = [
13+
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
14+
"artifacts/*",
15+
]
16+
17+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
18+
[lib]
19+
crate-type = ["cdylib", "rlib"]
20+
21+
[features]
22+
# for more explicit tests, cargo test --features=backtraces
23+
backtraces = ["cosmwasm-std/backtraces"]
24+
# use library feature to disable all instantiate/execute/query exports
25+
library = []
26+
27+
[dependencies]
28+
cw0 = { path = "../../packages/cw0", version = "0.10.0-soon" }
29+
cw2 = { path = "../../packages/cw2", version = "0.10.0-soon" }
30+
cw721 = { path = "../../packages/cw721", version = "0.10.0-soon" }
31+
cw721-base = { path = "../cw721-base", version = "0.10.0-soon", features = ["library"] }
32+
cw-storage-plus = { path = "../../packages/storage-plus", version = "0.10.0-soon" }
33+
cosmwasm-std = { version = "1.0.0-soon" }
34+
schemars = "0.8.1"
35+
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
36+
thiserror = { version = "1.0.23" }
37+
38+
[dev-dependencies]
39+
cosmwasm-schema = { version = "1.0.0-soon" }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Cw721_metadata_uri
2+
Copyright (C) 2020 Confio OÜ
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.

0 commit comments

Comments
 (0)