Skip to content

Commit

Permalink
Merge pull request #121 from public-awesome/JakeHartnell/re-add-creator
Browse files Browse the repository at this point in the history
Re-add creator to CollectionInfo, @stargazezone/types v0.2.3
  • Loading branch information
JakeHartnell authored Mar 4, 2022
2 parents a3a2d93 + e92a484 commit d389ad9
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 31 deletions.
4 changes: 4 additions & 0 deletions contracts/minter/schema/instantiate_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@
"CollectionInfo_for_RoyaltyInfoResponse": {
"type": "object",
"required": [
"creator",
"description",
"image"
],
"properties": {
"creator": {
"type": "string"
},
"description": {
"type": "string"
},
Expand Down
9 changes: 9 additions & 0 deletions contracts/minter/src/contract_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ fn setup_minter_contract(
symbol: String::from("TEST"),
minter: creator.to_string(),
collection_info: CollectionInfo {
creator: creator.to_string(),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down Expand Up @@ -215,6 +216,7 @@ fn initialization() {
symbol: String::from("TEST"),
minter: info.sender.to_string(),
collection_info: CollectionInfo {
creator: info.sender.to_string(),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down Expand Up @@ -244,6 +246,7 @@ fn initialization() {
symbol: String::from("TEST"),
minter: info.sender.to_string(),
collection_info: CollectionInfo {
creator: info.sender.to_string(),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down Expand Up @@ -273,6 +276,7 @@ fn initialization() {
symbol: String::from("TEST"),
minter: info.sender.to_string(),
collection_info: CollectionInfo {
creator: info.sender.to_string(),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down Expand Up @@ -301,6 +305,7 @@ fn initialization() {
symbol: String::from("TEST"),
minter: info.sender.to_string(),
collection_info: CollectionInfo {
creator: info.sender.to_string(),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down Expand Up @@ -329,6 +334,7 @@ fn initialization() {
symbol: String::from("TEST"),
minter: info.sender.to_string(),
collection_info: CollectionInfo {
creator: info.sender.to_string(),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down Expand Up @@ -357,6 +363,7 @@ fn initialization() {
symbol: String::from("TEST"),
minter: info.sender.to_string(),
collection_info: CollectionInfo {
creator: info.sender.to_string(),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down Expand Up @@ -1189,6 +1196,7 @@ fn test_start_time_before_genesis() {
symbol: String::from("TEST"),
minter: creator.to_string(),
collection_info: CollectionInfo {
creator: creator.to_string(),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down Expand Up @@ -1239,6 +1247,7 @@ fn test_update_start_time() {
symbol: String::from("TEST"),
minter: creator.to_string(),
collection_info: CollectionInfo {
creator: creator.to_string(),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down
4 changes: 4 additions & 0 deletions contracts/sg721/schema/collection_info_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
"title": "CollectionInfoResponse",
"type": "object",
"required": [
"creator",
"description",
"image"
],
"properties": {
"creator": {
"type": "string"
},
"description": {
"type": "string"
},
Expand Down
4 changes: 4 additions & 0 deletions contracts/sg721/schema/instantiate_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
"CollectionInfo_for_RoyaltyInfoResponse": {
"type": "object",
"required": [
"creator",
"description",
"image"
],
"properties": {
"creator": {
"type": "string"
},
"description": {
"type": "string"
},
Expand Down
6 changes: 6 additions & 0 deletions contracts/sg721/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ pub fn instantiate(
None => None,
};

deps.api.addr_validate(&msg.collection_info.creator)?;

let collection_info = CollectionInfo {
creator: msg.collection_info.creator,
description: msg.collection_info.description,
image: msg.collection_info.image,
external_link: msg.collection_info.external_link,
Expand Down Expand Up @@ -116,6 +119,7 @@ fn query_config(deps: Deps) -> StdResult<CollectionInfoResponse> {
};

Ok(CollectionInfoResponse {
creator: info.creator,
description: info.description,
image: info.image,
external_link: info.external_link,
Expand All @@ -142,6 +146,7 @@ mod tests {
symbol: String::from("BOBO"),
minter: String::from("minter"),
collection_info: CollectionInfo {
creator: String::from("creator"),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down Expand Up @@ -177,6 +182,7 @@ mod tests {
symbol: String::from("BOBO"),
minter: String::from("minter"),
collection_info: CollectionInfo {
creator: String::from("creator"),
description: String::from("Stargaze Monkeys"),
image: "https://example.com/image.png".to_string(),
external_link: Some("https://example.com/external.html".to_string()),
Expand Down
1 change: 1 addition & 0 deletions contracts/sg721/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl From<QueryMsg> for Cw721QueryMsg {

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct CollectionInfoResponse {
pub creator: String,
pub description: String,
pub image: String,
pub external_link: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions contracts/sg721/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct CollectionInfo<T> {
pub creator: String,
pub description: String,
pub image: String,
pub external_link: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions types/contracts/minter/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export interface Config {
admin: Addr
base_token_uri: string
num_tokens: number
per_address_limit?: (number | null)
per_address_limit: number
sg721_code_id: number
start_time?: (Expiration | null)
start_time: Expiration
unit_price: Coin
whitelist?: (Addr | null)
[k: string]: unknown
Expand Down
4 changes: 2 additions & 2 deletions types/contracts/minter/config_response.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export interface ConfigResponse {
admin: Addr
base_token_uri: string
num_tokens: number
per_address_limit?: (number | null)
per_address_limit: number
sg721_address: Addr
sg721_code_id: number
start_time?: (Expiration | null)
start_time: Expiration
unit_price: Coin
whitelist?: (Addr | null)
[k: string]: unknown
Expand Down
17 changes: 9 additions & 8 deletions types/contracts/minter/instantiate_msg.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Addr, Coin, Expiration } from "./shared-types";
import { Coin, Expiration } from "./shared-types";

/**
* A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0
Expand All @@ -10,30 +10,31 @@ export type Decimal = string
export interface InstantiateMsg {
base_token_uri: string
num_tokens: number
per_address_limit?: (number | null)
per_address_limit: number
sg721_code_id: number
sg721_instantiate_msg: InstantiateMsg1
start_time?: (Expiration | null)
start_time: Expiration
unit_price: Coin
whitelist?: (string | null)
[k: string]: unknown
}
export interface InstantiateMsg1 {
collection_info: CollectionInfo
collection_info: CollectionInfoFor_RoyaltyInfoResponse
minter: string
name: string
symbol: string
[k: string]: unknown
}
export interface CollectionInfo {
export interface CollectionInfoFor_RoyaltyInfoResponse {
creator: string
description: string
external_link?: (string | null)
image: string
royalties?: (RoyaltyInfo | null)
royalty_info?: (RoyaltyInfoResponse | null)
[k: string]: unknown
}
export interface RoyaltyInfo {
payment_address: Addr
export interface RoyaltyInfoResponse {
payment_address: string
share: Decimal
[k: string]: unknown
}
5 changes: 5 additions & 0 deletions types/contracts/minter/query_msg.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ start_time: {
mint_price: {
[k: string]: unknown
}
} | {
mint_count: {
address: string
[k: string]: unknown
}
})
5 changes: 3 additions & 2 deletions types/contracts/sg721/collection_info_response.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { RoyaltyInfo } from "./shared-types";
import { RoyaltyInfoResponse } from "./shared-types";

export interface CollectionInfoResponse {
creator: string
description: string
external_link?: (string | null)
image: string
royalty?: (RoyaltyInfo | null)
royalty?: (RoyaltyInfoResponse | null)
[k: string]: unknown
}
9 changes: 5 additions & 4 deletions types/contracts/sg721/instantiate_msg.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { RoyaltyInfo } from "./shared-types";
import { RoyaltyInfoResponse } from "./shared-types";

export interface InstantiateMsg {
collection_info: CollectionInfo
collection_info: CollectionInfoFor_RoyaltyInfoResponse
minter: string
name: string
symbol: string
[k: string]: unknown
}
export interface CollectionInfo {
export interface CollectionInfoFor_RoyaltyInfoResponse {
creator: string
description: string
external_link?: (string | null)
image: string
royalties?: (RoyaltyInfo | null)
royalty_info?: (RoyaltyInfoResponse | null)
[k: string]: unknown
}
14 changes: 2 additions & 12 deletions types/contracts/sg721/shared-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
/**
* A human readable address.
*
* In Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.
*
* This type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.
*
* This type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.
*/
export type Addr = string;
/**
* A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0
*
* The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)
*/
export type Decimal = string;
export interface RoyaltyInfo {
export interface RoyaltyInfoResponse {
[k: string]: unknown;
payment_address: Addr;
payment_address: string;
share: Decimal;
}
2 changes: 1 addition & 1 deletion types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stargazezone/types",
"version": "0.2.2",
"version": "0.2.3",
"description": "Types for Stargaze CosmWasm Contracts",
"main": "build/codegen.js",
"scripts": {
Expand Down

0 comments on commit d389ad9

Please sign in to comment.