Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: vesting managed #20

Merged
merged 14 commits into from
Mar 28, 2023
Merged
6 changes: 6 additions & 0 deletions contracts/vesting-managed/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
integration-test = "test --test integration"
schema = "run --example vesting_schema"
27 changes: 27 additions & 0 deletions contracts/vesting-managed/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "vesting-managed"
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
version = "1.1.0"
authors = ["andrei.z@p2p.org"]
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
# use library feature to disable all init/handle/query exports
library = []

[dependencies]
vesting-base = {path = "../../packages/vesting-base"}
astroport = { path = "../../packages/astroport", default-features = false }
cosmwasm-schema = { version = "1.1", default-features = false }
cosmwasm-std = { version = "1.1" }
cw-storage-plus = "0.15"
cw-utils = "0.15"
cw20 = { version = "0.15" }

[dev-dependencies]
cw-multi-test = "0.15"
astroport-token = {path = "../astroport/token"}
cw20 = { version = "0.15" }
cw-utils = "0.15"
12 changes: 12 additions & 0 deletions contracts/vesting-managed/examples/vesting_schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use cosmwasm_schema::write_api;

use astroport::vesting::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
execute: ExecuteMsg,
migrate: MigrateMsg
}
}
244 changes: 244 additions & 0 deletions contracts/vesting-managed/schema/raw/execute.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ExecuteMsg",
"description": "This structure describes the execute messages available in the contract.",
"oneOf": [
{
"description": "Claim claims vested tokens and sends them to a recipient",
"type": "object",
"required": [
"claim"
],
"properties": {
"claim": {
"type": "object",
"properties": {
"amount": {
"description": "The amount of tokens to claim",
"anyOf": [
{
"$ref": "#/definitions/Uint128"
},
{
"type": "null"
}
]
},
"recipient": {
"description": "The address that receives the vested tokens",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Receives a message of type [`Cw20ReceiveMsg`] and processes it depending on the received template",
"type": "object",
"required": [
"receive"
],
"properties": {
"receive": {
"$ref": "#/definitions/Cw20ReceiveMsg"
}
},
"additionalProperties": false
},
{
"description": "RegisterVestingAccounts registers vesting targets/accounts",
"type": "object",
"required": [
"register_vesting_accounts"
],
"properties": {
"register_vesting_accounts": {
"type": "object",
"required": [
"vesting_accounts"
],
"properties": {
"vesting_accounts": {
"type": "array",
"items": {
"$ref": "#/definitions/VestingAccount"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Creates a request to change contract ownership ## Executor Only the current owner can execute this",
"type": "object",
"required": [
"propose_new_owner"
],
"properties": {
"propose_new_owner": {
"type": "object",
"required": [
"expires_in",
"owner"
],
"properties": {
"expires_in": {
"description": "The validity period of the offer to change the owner",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"owner": {
"description": "The newly proposed owner",
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Removes a request to change contract ownership ## Executor Only the current owner can execute this",
"type": "object",
"required": [
"drop_ownership_proposal"
],
"properties": {
"drop_ownership_proposal": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Claims contract ownership ## Executor Only the newly proposed owner can execute this",
"type": "object",
"required": [
"claim_ownership"
],
"properties": {
"claim_ownership": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
}
],
"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>. See also <https://github.com/CosmWasm/cosmwasm/blob/main/docs/MESSAGE_TYPES.md>.",
"type": "string"
},
"Cw20ReceiveMsg": {
"description": "Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg",
"type": "object",
"required": [
"amount",
"msg",
"sender"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"msg": {
"$ref": "#/definitions/Binary"
},
"sender": {
"type": "string"
}
},
"additionalProperties": false
},
"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"
},
"VestingAccount": {
"description": "This structure stores vesting information for a specific address that is getting tokens.",
"type": "object",
"required": [
"address",
"schedules"
],
"properties": {
"address": {
"description": "The address that is getting tokens",
"type": "string"
},
"schedules": {
"description": "The vesting schedules targeted at the `address`",
"type": "array",
"items": {
"$ref": "#/definitions/VestingSchedule"
}
}
},
"additionalProperties": false
},
"VestingSchedule": {
"description": "This structure stores parameters for a specific vesting schedule",
"type": "object",
"required": [
"start_point"
],
"properties": {
"end_point": {
"description": "The end point for the vesting schedule",
"anyOf": [
{
"$ref": "#/definitions/VestingSchedulePoint"
},
{
"type": "null"
}
]
},
"start_point": {
"description": "The start date for the vesting schedule",
"allOf": [
{
"$ref": "#/definitions/VestingSchedulePoint"
}
]
}
},
"additionalProperties": false
},
"VestingSchedulePoint": {
"description": "This structure stores the parameters used to create a vesting schedule.",
"type": "object",
"required": [
"amount",
"time"
],
"properties": {
"amount": {
"description": "The amount of tokens being vested",
"allOf": [
{
"$ref": "#/definitions/Uint128"
}
]
},
"time": {
"description": "The start time for the vesting schedule",
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false
}
}
}
80 changes: 80 additions & 0 deletions contracts/vesting-managed/schema/raw/instantiate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "InstantiateMsg",
"description": "This structure describes the parameters used for creating a contract.",
"type": "object",
"required": [
"owner",
"vesting_token"
],
"properties": {
"owner": {
"description": "Address allowed to change contract parameters",
"type": "string"
},
"vesting_token": {
"description": "[`AssetInfo`] of the token that's being vested",
"allOf": [
{
"$ref": "#/definitions/AssetInfo"
}
]
}
},
"additionalProperties": false,
"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"
},
"AssetInfo": {
"description": "This enum describes available Token types. ## Examples ``` # use cosmwasm_std::Addr; # use astroport::asset::AssetInfo::{NativeToken, Token}; Token { contract_addr: Addr::unchecked(\"stake...\") }; NativeToken { denom: String::from(\"uluna\") }; ```",
"oneOf": [
{
"description": "Non-native Token",
"type": "object",
"required": [
"token"
],
"properties": {
"token": {
"type": "object",
"required": [
"contract_addr"
],
"properties": {
"contract_addr": {
"$ref": "#/definitions/Addr"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Native token",
"type": "object",
"required": [
"native_token"
],
"properties": {
"native_token": {
"type": "object",
"required": [
"denom"
],
"properties": {
"denom": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
}
}
}
7 changes: 7 additions & 0 deletions contracts/vesting-managed/schema/raw/migrate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "MigrateMsg",
"description": "This structure describes a migration message. We currently take no arguments for migrations.",
"type": "object",
"additionalProperties": false
}
Loading