Skip to content

Commit

Permalink
Merge pull request #147 from public-awesome/shanev/addr-string
Browse files Browse the repository at this point in the history
`Addr` -> `String` in response
  • Loading branch information
shanev authored Mar 7, 2022
2 parents d1149f8 + c55ea7f commit 1ee351a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 37 deletions.
18 changes: 5 additions & 13 deletions contracts/minter/schema/config_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"properties": {
"admin": {
"$ref": "#/definitions/Addr"
"type": "string"
},
"base_token_uri": {
"type": "string"
Expand All @@ -30,7 +30,7 @@
"minimum": 0.0
},
"sg721_address": {
"$ref": "#/definitions/Addr"
"type": "string"
},
"sg721_code_id": {
"type": "integer",
Expand All @@ -44,21 +44,13 @@
"$ref": "#/definitions/Coin"
},
"whitelist": {
"anyOf": [
{
"$ref": "#/definitions/Addr"
},
{
"type": "null"
}
"type": [
"string",
"null"
]
}
},
"definitions": {
"Addr": {
"description": "A human readable address.\n\nIn 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.\n\nThis 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.\n\nThis 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.",
"type": "string"
},
"Coin": {
"type": "object",
"required": [
Expand Down
6 changes: 3 additions & 3 deletions contracts/minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,15 +545,15 @@ fn query_config(deps: Deps) -> StdResult<ConfigResponse> {
let sg721_address = SG721_ADDRESS.load(deps.storage)?;

Ok(ConfigResponse {
admin: config.admin,
admin: config.admin.to_string(),
base_token_uri: config.base_token_uri,
sg721_address,
sg721_address: sg721_address.to_string(),
sg721_code_id: config.sg721_code_id,
num_tokens: config.num_tokens,
start_time: config.start_time,
unit_price: config.unit_price,
per_address_limit: config.per_address_limit,
whitelist: config.whitelist,
whitelist: config.whitelist.map(|w| w.to_string()),
})
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/minter/src/contract_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ fn mint_count_query() {
let (creator, buyer) = setup_accounts(&mut router);
let num_tokens = 10;
let (minter_addr, config) = setup_minter_contract(&mut router, &creator, num_tokens);
let sg721_addr = config.sg721_address;
let sg721_addr = Addr::unchecked(config.sg721_address);
let whitelist_addr = setup_whitelist_contract(&mut router, &creator);
const EXPIRATION_TIME: Timestamp = Timestamp::from_nanos(GENESIS_MINT_START_TIME + 10_000);

Expand Down Expand Up @@ -895,7 +895,7 @@ fn whitelist_access_len_add_remove_expiration() {
};
let res = router.execute_contract(
buyer.clone(),
sg721_addr,
Addr::unchecked(sg721_addr),
&transfer_msg,
&coins_for_msg(coin(123, NATIVE_DENOM)),
);
Expand Down
8 changes: 4 additions & 4 deletions contracts/minter/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{Addr, Coin, Timestamp};
use cosmwasm_std::{Coin, Timestamp};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -39,15 +39,15 @@ pub enum QueryMsg {

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ConfigResponse {
pub admin: Addr,
pub admin: String,
pub base_token_uri: String,
pub num_tokens: u32,
pub per_address_limit: u32,
pub sg721_address: Addr,
pub sg721_address: String,
pub sg721_code_id: u64,
pub start_time: Timestamp,
pub unit_price: Coin,
pub whitelist: Option<Addr>,
pub whitelist: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
Expand Down
13 changes: 12 additions & 1 deletion types/contracts/minter/config.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import { Addr, Coin, Timestamp } from "./shared-types";
import { Coin, Timestamp } from "./shared-types";

/**
* 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

export interface Config {
admin: Addr
Expand Down
8 changes: 4 additions & 4 deletions types/contracts/minter/config_response.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Addr, Coin, Timestamp } from "./shared-types";
import { Coin, Timestamp } from "./shared-types";

export interface ConfigResponse {
admin: Addr
admin: string
base_token_uri: string
num_tokens: number
per_address_limit: number
sg721_address: Addr
sg721_address: string
sg721_code_id: number
start_time: Timestamp
unit_price: Coin
whitelist?: (Addr | null)
whitelist?: (string | null)
[k: string]: unknown
}
10 changes: 0 additions & 10 deletions types/contracts/minter/shared-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
/**
* 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 point in time in nanosecond precision.
*
Expand Down

0 comments on commit 1ee351a

Please sign in to comment.