Skip to content

Commit

Permalink
Merge pull request #38 from public-awesome/shanev/37-secondary-index
Browse files Browse the repository at this point in the history
Add secondary indicies to Bids and Asks via `IndexedMap`
  • Loading branch information
shanev committed Apr 15, 2022
2 parents f64c2f7 + bc8d030 commit d9032d5
Show file tree
Hide file tree
Showing 18 changed files with 473 additions and 183 deletions.
25 changes: 7 additions & 18 deletions contracts/marketplace/schema/asks_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"asks": {
"type": "array",
"items": {
"$ref": "#/definitions/AskInfo"
"$ref": "#/definitions/Ask"
}
}
},
Expand All @@ -18,14 +18,18 @@
"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"
},
"AskInfo": {
"Ask": {
"type": "object",
"required": [
"collection",
"price",
"seller",
"token_id"
],
"properties": {
"collection": {
"$ref": "#/definitions/Addr"
},
"funds_recipient": {
"anyOf": [
{
Expand All @@ -37,7 +41,7 @@
]
},
"price": {
"$ref": "#/definitions/Coin"
"$ref": "#/definitions/Uint128"
},
"seller": {
"$ref": "#/definitions/Addr"
Expand All @@ -49,21 +53,6 @@
}
}
},
"Coin": {
"type": "object",
"required": [
"amount",
"denom"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"denom": {
"type": "string"
}
}
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
Expand Down
31 changes: 30 additions & 1 deletion contracts/marketplace/schema/bid_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bid": {
"anyOf": [
{
"$ref": "#/definitions/Uint128"
"$ref": "#/definitions/Bid"
},
{
"type": "null"
Expand All @@ -15,6 +15,35 @@
}
},
"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"
},
"Bid": {
"type": "object",
"required": [
"bidder",
"collection",
"price",
"token_id"
],
"properties": {
"bidder": {
"$ref": "#/definitions/Addr"
},
"collection": {
"$ref": "#/definitions/Addr"
},
"price": {
"$ref": "#/definitions/Uint128"
},
"token_id": {
"type": "integer",
"format": "uint32",
"minimum": 0.0
}
}
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
Expand Down
33 changes: 15 additions & 18 deletions contracts/marketplace/schema/bids_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,32 @@
"bids": {
"type": "array",
"items": {
"$ref": "#/definitions/BidInfo"
"$ref": "#/definitions/Bid"
}
}
},
"definitions": {
"BidInfo": {
"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"
},
"Bid": {
"type": "object",
"required": [
"bidder",
"collection",
"price",
"token_id"
],
"properties": {
"bidder": {
"$ref": "#/definitions/Addr"
},
"collection": {
"$ref": "#/definitions/Addr"
},
"price": {
"$ref": "#/definitions/Coin"
"$ref": "#/definitions/Uint128"
},
"token_id": {
"type": "integer",
Expand All @@ -31,21 +43,6 @@
}
}
},
"Coin": {
"type": "object",
"required": [
"amount",
"denom"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"denom": {
"type": "string"
}
}
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
Expand Down
12 changes: 11 additions & 1 deletion contracts/marketplace/schema/current_ask_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@
"Ask": {
"type": "object",
"required": [
"collection",
"price",
"seller"
"seller",
"token_id"
],
"properties": {
"collection": {
"$ref": "#/definitions/Addr"
},
"funds_recipient": {
"anyOf": [
{
Expand All @@ -41,6 +46,11 @@
},
"seller": {
"$ref": "#/definitions/Addr"
},
"token_id": {
"type": "integer",
"format": "uint32",
"minimum": 0.0
}
}
},
Expand Down
61 changes: 61 additions & 0 deletions contracts/marketplace/schema/query_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,46 @@
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"ask_count"
],
"properties": {
"ask_count": {
"type": "object",
"required": [
"collection"
],
"properties": {
"collection": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"asks_by_seller"
],
"properties": {
"asks_by_seller": {
"type": "object",
"required": [
"seller"
],
"properties": {
"seller": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"description": "List of collections that have asks on them Return type: `CollectionsResponse`",
"type": "object",
Expand Down Expand Up @@ -126,6 +166,27 @@
},
"additionalProperties": false
},
{
"description": "Get all bids by a bidder Return type: `BidsResponse`",
"type": "object",
"required": [
"bids_by_bidder"
],
"properties": {
"bids_by_bidder": {
"type": "object",
"required": [
"bidder"
],
"properties": {
"bidder": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"description": "Get all bids for a specific NFT Return type: `BidsResponse`",
"type": "object",
Expand Down
Loading

0 comments on commit d9032d5

Please sign in to comment.