Skip to content

Commit

Permalink
Merge pull request #21 from CosmWasm/cw20-allowances
Browse files Browse the repository at this point in the history
Cw20 allowances
  • Loading branch information
ethanfrey authored Jul 7, 2020
2 parents 2754640 + fbcef6a commit 3d37518
Show file tree
Hide file tree
Showing 17 changed files with 1,265 additions and 51 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions contracts/cw20-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
cw20 = { path = "../../packages/cw20", version = "0.1.0" }
cosmwasm-std = { version = "0.9.1" }
cosmwasm-storage = { version = "0.9.1" }
cosmwasm-std = { version = "0.9.2" }
cosmwasm-storage = { version = "0.9.2" }
schemars = "0.7"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
snafu = { version = "0.6.3" }

[dev-dependencies]
# we only need to enable this if we use integration tests
#cosmwasm-vm = { version = "0.9.1", default-features = false }
cosmwasm-schema = { version = "0.9.1" }
#cosmwasm-vm = { version = "0.9.2", default-features = false }
cosmwasm-schema = { version = "0.9.2" }
218 changes: 218 additions & 0 deletions contracts/cw20-base/schema/handle_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,231 @@
}
}
}
},
{
"description": "Only with \"approval\" extension. Allows spender to access an additional amount tokens from the owner's (env.sender) account. If expires is Some(), overwrites current allowance expiration with this one.",
"type": "object",
"required": [
"increase_allowance"
],
"properties": {
"increase_allowance": {
"type": "object",
"required": [
"amount",
"spender"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"expires": {
"anyOf": [
{
"$ref": "#/definitions/Expiration"
},
{
"type": "null"
}
]
},
"spender": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"description": "Only with \"approval\" extension. Lowers the spender's access of tokens from the owner's (env.sender) account by amount. If expires is Some(), overwrites current allowance expiration with this one.",
"type": "object",
"required": [
"decrease_allowance"
],
"properties": {
"decrease_allowance": {
"type": "object",
"required": [
"amount",
"spender"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"expires": {
"anyOf": [
{
"$ref": "#/definitions/Expiration"
},
{
"type": "null"
}
]
},
"spender": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"description": "Only with \"approval\" extension. Transfers amount tokens from owner -> recipient if `env.sender` has sufficient pre-approval.",
"type": "object",
"required": [
"transfer_from"
],
"properties": {
"transfer_from": {
"type": "object",
"required": [
"amount",
"owner",
"recipient"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"owner": {
"$ref": "#/definitions/HumanAddr"
},
"recipient": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"description": "Only with \"approval\" extension. Sends amount tokens from owner -> contract if `env.sender` has sufficient pre-approval.",
"type": "object",
"required": [
"send_from"
],
"properties": {
"send_from": {
"type": "object",
"required": [
"amount",
"contract",
"owner"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"contract": {
"$ref": "#/definitions/HumanAddr"
},
"msg": {
"anyOf": [
{
"$ref": "#/definitions/Binary"
},
{
"type": "null"
}
]
},
"owner": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
},
{
"description": "Only with \"approval\" extension. Destroys tokens forever",
"type": "object",
"required": [
"burn_from"
],
"properties": {
"burn_from": {
"type": "object",
"required": [
"amount",
"owner"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"owner": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
}
],
"definitions": {
"Binary": {
"description": "Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>",
"type": "string"
},
"Expiration": {
"anyOf": [
{
"description": "AtHeight will expire when `env.block.height` >= height",
"type": "object",
"required": [
"at_height"
],
"properties": {
"at_height": {
"type": "object",
"required": [
"height"
],
"properties": {
"height": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
}
}
},
{
"description": "AtTime will expire when `env.block.time` >= time",
"type": "object",
"required": [
"at_time"
],
"properties": {
"at_time": {
"type": "object",
"required": [
"time"
],
"properties": {
"time": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
}
}
},
{
"description": "Never will never expire. Used to distinguish None from Some(Expiration::Never)",
"type": "object",
"required": [
"never"
],
"properties": {
"never": {
"type": "object"
}
}
}
]
},
"HumanAddr": {
"type": "string"
},
Expand Down
24 changes: 24 additions & 0 deletions contracts/cw20-base/schema/query_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@
"type": "object"
}
}
},
{
"description": "Only with \"allowance\" extension. Returns how much spender can use from owner account, 0 if unset. Return type: AllowanceResponse.",
"type": "object",
"required": [
"allowance"
],
"properties": {
"allowance": {
"type": "object",
"required": [
"owner",
"spender"
],
"properties": {
"owner": {
"$ref": "#/definitions/HumanAddr"
},
"spender": {
"$ref": "#/definitions/HumanAddr"
}
}
}
}
}
],
"definitions": {
Expand Down
Loading

0 comments on commit 3d37518

Please sign in to comment.