From c3e258bd4c66492ac949fa2d6da486dd6c7f8da8 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Mon, 4 Jan 2021 15:34:00 +0100 Subject: [PATCH 1/3] Update contract refs to v0.4.0 Update rust-optimizer ref version --- contracts/cw1-subkeys/helpers.ts | 4 ++-- contracts/cw20-base/helpers.ts | 4 ++-- contracts/cw721-base/helpers.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/cw1-subkeys/helpers.ts b/contracts/cw1-subkeys/helpers.ts index e38555f74..b79d887e9 100644 --- a/contracts/cw1-subkeys/helpers.ts +++ b/contracts/cw1-subkeys/helpers.ts @@ -327,10 +327,10 @@ const CW1 = (client: SigningCosmWasmClient): CW1Contract => { const upload = async (): Promise => { const meta = { - source: "https://github.com/CosmWasm/cosmwasm-plus/tree/v0.3.2/contracts/cw1-subkeys", + source: "https://github.com/CosmWasm/cosmwasm-plus/tree/v0.4.0/contracts/cw1-subkeys", builder: "cosmwasm/rust-optimizer:0.10.7" }; - const sourceUrl = "https://github.com/CosmWasm/cosmwasm-plus/releases/download/v0.3.2/cw1_subkeys.wasm"; + const sourceUrl = "https://github.com/CosmWasm/cosmwasm-plus/releases/download/v0.4.0/cw1_subkeys.wasm"; const wasm = await downloadWasm(sourceUrl); const result = await client.upload(wasm, meta); return result.codeId; diff --git a/contracts/cw20-base/helpers.ts b/contracts/cw20-base/helpers.ts index 72232c6f4..7f28765f0 100644 --- a/contracts/cw20-base/helpers.ts +++ b/contracts/cw20-base/helpers.ts @@ -276,10 +276,10 @@ const CW20 = (client: SigningCosmWasmClient): CW20Contract => { const upload = async (): Promise => { const meta = { - source: "https://github.com/CosmWasm/cosmwasm-plus/tree/v0.3.2/contracts/cw20-base", + source: "https://github.com/CosmWasm/cosmwasm-plus/tree/v0.4.0/contracts/cw20-base", builder: "cosmwasm/workspace-optimizer:0.10.7" }; - const sourceUrl = "https://github.com/CosmWasm/cosmwasm-plus/releases/download/v0.3.2/cw20_base.wasm"; + const sourceUrl = "https://github.com/CosmWasm/cosmwasm-plus/releases/download/v0.4.0/cw20_base.wasm"; const wasm = await downloadWasm(sourceUrl); const result = await client.upload(wasm, meta); return result.codeId; diff --git a/contracts/cw721-base/helpers.ts b/contracts/cw721-base/helpers.ts index 54eab3136..e8ee52b70 100644 --- a/contracts/cw721-base/helpers.ts +++ b/contracts/cw721-base/helpers.ts @@ -386,10 +386,10 @@ const CW721 = (client: SigningCosmWasmClient): CW721Contract => { const upload = async (): Promise => { const meta = { - source: "https://github.com/CosmWasm/cosmwasm-plus/tree/v0.3.2/contracts/cw721-base", - builder: "cosmwasm/workspace-optimizer:0.10.4" + source: "https://github.com/CosmWasm/cosmwasm-plus/tree/v0.4.0/contracts/cw721-base", + builder: "cosmwasm/workspace-optimizer:0.10.7" }; - const sourceUrl = "https://github.com/CosmWasm/cosmwasm-plus/releases/download/v0.3.2/cw721_base.wasm"; + const sourceUrl = "https://github.com/CosmWasm/cosmwasm-plus/releases/download/v0.4.0/cw721_base.wasm"; const wasm = await downloadWasm(sourceUrl); const result = await client.upload(wasm, meta); return result.codeId; From dd01d05af677c352e9ba9f0b6d4cb1e2bfb25e1f Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 7 Jan 2021 16:03:13 +0100 Subject: [PATCH 2/3] Add missing contract entries to README --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d7fe6afc0..ff16f8a87 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ We are running a [public testnet](https://github.com/CosmWasm/testnets/blob/mast you can use to test out any contracts. **Warning** None of these contracts have been audited and no liability is -assumed for the use of any of this code. They are provided to turbo-start +assumed for the use of this code. They are provided to turbo-start your projects. **Note** All code in pre-1.0 packages is in "draft" form, meaning it may @@ -59,7 +59,7 @@ cleaner (before: `expires: {at_height: {height: 12345}}` after The most reusable components are the various cwXYZ specifications under `packages`. Each one defines a standard interface for different domains, -eg. [cw20](./packages/cw20/README.md) for fungible tokens, +e.g. [cw20](./packages/cw20/README.md) for fungible tokens, [cw721](./packages/cw721/README.md) for non-fungible tokens, [cw1](./packages/cw1/README.md) for "proxy contracts", etc. The interface comes with a human description in the READMEs, as well @@ -79,7 +79,7 @@ or [create a pull request](https://github.com/CosmWasm/cosmwasm-plus/pulls) on t ## Contracts We provide sample contracts that either implement or consume these -specifications to both provide examples, as well as provide a basis +specifications to both provide examples, and provide a basis for code you can extend for more custom contacts, without worrying about reinventing the wheel each time. For example [`cw20-base`](./contracts/cw20-base) is a basic implementation @@ -89,26 +89,61 @@ contract you want to build on it. CW1 Proxy Contracts: * [`cw1-whitelist`](./contracts/cw1-whitelist) a minimal implementation of `cw1` -mainly designed for reference +mainly designed for reference. * [`cw1-subkeys`](./contracts/cw1-subkeys) a simple, but useful implementation, which lets us use a proxy contract to provide "allowances" for native tokens -without modifying the `bank` module +without modifying the `bank` module. + +CW3 Multisig: + +* [`cw3-fixed-multisig`](./contracts/cw3-fixed-multisig) a simple implementation of the +[cw3 spec](./packages/cw3/README.md). It is a multisig with a fixed set of addresses, +created upon initialization. +Each address may have the same weight (K of N), or some may have extra voting +power. This works much like the native Cosmos SDK multisig, except that rather +than aggregating the signatures off chain and submitting the final result, +we aggregate the approvals on-chain. +* [`cw3-flex-multisig`](./contracts/cw3-flex-multisig) builds on cw3-fixed-multisig, +with a more powerful implementation of the cw3 spec. It's a multisig contract +backed by a cw4 (group) contract, which independently maintains the voter set. + +CW4 Group: + +* [`cw4-group`](./contracts/cw4-group) a basic implementation of the +[cw4 spec](./packages/cw4/README.md). It handles elected membership, by admin or multisig. +It fulfills all elements of the spec, including raw query lookups, +and is designed to be used as a backing storage for [cw3 compliant contracts](./packages/cw3/README.md). +* [`cw4-stake`](./contracts/cw4-stake) a second implementation of the +[cw4 spec](./packages/cw4/README.md). It fulfills all elements of the spec, including raw query lookups, +and is designed to be used as a backing storage for [cw3 compliant contracts](./packages/cw3/README.md). +It provides a similar API to [`cw4-group`], but rather than appointing members, +their membership and weight are based on the number of staked tokens they have. CW20 Fungible Tokens: * [`cw20-base`](./contracts/cw20-base) a straightforward, but complete implementation of the cw20 spec along with all extensions. Can be deployed -as-is, or imported by other contracts +as-is, or imported by other contracts. +* [`cw20-atomic-swap`](./contracts/cw20-atomic-swap) an implementation of atomic swaps for +both native and cw20 tokens. +* [`cw20-bonding`](./contracts/cw20-bonding) a smart contract implementing arbitrary bonding curves, +which can use native and cw20 tokens as reserve tokens. * [`cw20-staking`](./contracts/cw20-staking) provides staking derivatives, staking native tokens on your behalf and minting cw20 tokens that can be used to claim them. It uses `cw20-base` for all the cw20 logic and only implements the interactions with the staking module and accounting -for prices +for prices. * [`cw20-escrow`](./contracts/cw20-escrow) is a basic escrow contract (arbiter can release or refund tokens) that is compatible with all native and cw20 tokens. This is a good example to show how to interact with cw20 tokens. +CW721 Non-fungible Tokens: + +* [`cw721-base`](./contracts/cw721-base) a base implementation of a cw721 NFT contract. +It implements the [CW721 spec](./packages/cw721/README.md) and is designed to be deployed as is, +or imported into other contracts to easily build cw721-compatible NFTs with custom logic. + ## Compiling To compile all the contracts, run the following in the repo root: @@ -143,4 +178,3 @@ Contracts that are "ready to deploy" may be licensed under AGPL 3.0 to encourage anyone using them to contribute back any improvements they make. This is common practice for actual projects running on Ethereum, like Uniswap or Maker DAO. - From 9f17171a88c26b2bf92f880808fbae2f1f5edfc8 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 7 Jan 2021 16:06:18 +0100 Subject: [PATCH 3/3] Fix syntax / typos --- contracts/cw3-fixed-multisig/README.md | 6 +++--- contracts/cw3-flex-multisig/README.md | 22 +++++++++++----------- contracts/cw4-group/README.md | 12 ++++++------ contracts/cw4-stake/README.md | 6 +++--- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/contracts/cw3-fixed-multisig/README.md b/contracts/cw3-fixed-multisig/README.md index 2f8df84db..e7e9d158a 100644 --- a/contracts/cw3-fixed-multisig/README.md +++ b/contracts/cw3-fixed-multisig/README.md @@ -2,7 +2,7 @@ This is a simple implementation of the [cw3 spec](../../packages/cw3/README.md). It is a multisig with a fixed set of addresses created upon initialization. -Each address may have the same weight (K of N) or some may have extra voting +Each address may have the same weight (K of N), or some may have extra voting power. This works much like the native Cosmos SDK multisig, except that rather than aggregating the signatures off chain and submitting the final result, we aggregate the approvals on-chain. @@ -39,7 +39,7 @@ Once a proposal is "Passed", anyone may submit an "Execute" message. This will trigger the proposal to send all stored messages from the proposal and update it's state to "Executed", so it cannot run again. (Note if the execution fails for any reason - out of gas, insufficient funds, etc - the state update will -be reverted and it will remain "Passed" so you can try again). +be reverted, and it will remain "Passed", so you can try again). Once a proposal has expired without passing, anyone can submit a "Close" message to mark it closed. This has no effect beyond cleaning up the UI/database. @@ -62,4 +62,4 @@ sha256sum cw3_fixed_multisig.wasm ``` Or for a production-ready (optimized) build, run a build command in the -the repository root: https://github.com/CosmWasm/cosmwasm-plus#compiling. +repository root: https://github.com/CosmWasm/cosmwasm-plus#compiling. diff --git a/contracts/cw3-flex-multisig/README.md b/contracts/cw3-flex-multisig/README.md index fbf8f2838..cc83f25d2 100644 --- a/contracts/cw3-flex-multisig/README.md +++ b/contracts/cw3-flex-multisig/README.md @@ -1,23 +1,23 @@ # CW3 Flexible Multisig -This builds on [cw3-fixed-multisig](../cw3-fixed-multisig) with a more +This builds on [cw3-fixed-multisig](../cw3-fixed-multisig) with a more powerful implementation of the [cw3 spec](../../packages/cw3/README.md). -It is a multisig contract that is backed by a +It is a multisig contract that is backed by a [cw4 (group)](../../packages/cw4/README.md) contract, which independently maintains the voter set. This provides 2 main advantages: * You can create two different multisigs with different voting thresholds - backed by the same group. Thus, you can have a 50% vote and a 67% vote + backed by the same group. Thus, you can have a 50% vote, and a 67% vote that always use the same voter set, but can take other actions. * TODO: It allows dynamic multisig groups. Since the group can change, we can set one of the multisigs as the admin of the group contract, and the -Besides the dynamic voting set, the main difference with the native -Cosmos SDK multisig, is that it aggregates the signatures on chain with +In addition to the dynamic voting set, the main difference with the native +Cosmos SDK multisig, is that it aggregates the signatures on chain, with visible proposals (like `x/gov` in the Cosmos SDK), rather than requiring signers to share signatures off chain. @@ -26,10 +26,10 @@ signers to share signatures off chain. The first step to create such a multisig is to instantiate a cw4 contract with the desired member set. For now, this only is supported by [cw4-group](../cw4-group), but we will add a token-weighted group contract -(TODO). +(TODO). If you create a `cw4-group` contract and want a multisig to be able -to modify it's own group, do the following in multiple transactions: +to modify its own group, do the following in multiple transactions: * init cw4-group, with your personal key as admin * init a multisig pointing to the group @@ -41,7 +41,7 @@ and depends on an external driver (hard to impossible to script such a self-deploying contract on-chain). (TODO: document better). When creating the multisig, you must set the required weight to pass a vote -as well as the max/default voting period. (TODO: allow more threshold types) +as well as the max/default voting period. (TODO: allow more threshold types) ## Handle Process @@ -59,7 +59,7 @@ Once a proposal is "Passed", anyone may submit an "Execute" message. This will trigger the proposal to send all stored messages from the proposal and update it's state to "Executed", so it cannot run again. (Note if the execution fails for any reason - out of gas, insufficient funds, etc - the state update will -be reverted and it will remain "Passed" so you can try again). +be reverted, and it will remain "Passed", so you can try again). Once a proposal has expired without passing, anyone can submit a "Close" message to mark it closed. This has no effect beyond cleaning up the UI/database. @@ -72,7 +72,7 @@ open, this will calculate incorrect values (future PR). You will need Rust 1.44.1+ with `wasm32-unknown-unknown` target installed. -You can run unit tests on this via: +You can run unit tests on this via: `cargo test` @@ -85,5 +85,5 @@ ls -l cw3_fixed_multisig.wasm sha256sum cw3_fixed_multisig.wasm ``` -Or for a production-ready (optimized) build, run a build command in the +Or for a production-ready (optimized) build, run a build command in the repository root: https://github.com/CosmWasm/cosmwasm-plus#compiling. diff --git a/contracts/cw4-group/README.md b/contracts/cw4-group/README.md index ae8180947..19dd60082 100644 --- a/contracts/cw4-group/README.md +++ b/contracts/cw4-group/README.md @@ -1,12 +1,12 @@ # CW4 Group This is a basic implementation of the [cw4 spec](../../packages/cw4/README.md). -It fufills all elements of the spec, including the raw query lookups, -and it designed to be used as a backing storage for +It fulfills all elements of the spec, including the raw query lookups, +and it designed to be used as a backing storage for [cw3 compliant contracts](../../packages/cw3/README.md). It stores a set of members along with an admin, and allows the admin to -update the state. Raw queries (intended for cross-contract queries) +update the state. Raw queries (intended for cross-contract queries) can check a given member address and the total weight. Smart queries (designed for client API) can do the same, and also query the admin address as well as paginate over all members. @@ -34,12 +34,12 @@ and stored under their `CanonicalAddr`, in a format defined in Note that 0 *is an allowed weight*. This doesn't give any voting rights, but it does define this address is part of the group. This could be used in -eg. a KYC whitelist to say they are allowed, but cannot participate in +e.g. a KYC whitelist to say they are allowed, but cannot participate in decision-making. ## Messages -Basic update messages, queries, and hooks are defined by the +Basic update messages, queries, and hooks are defined by the [cw4 spec](../../packages/cw4/README.md). Please refer to it for more info. `cw4-group` adds one message to control the group membership: @@ -47,5 +47,5 @@ Basic update messages, queries, and hooks are defined by the `UpdateMembers{add, remove}` - takes a membership diff and adds/updates the members, as well as removing any provided addresses. If an address is on both lists, it will be removed. If it appears multiple times in `add`, only the -last occurance will be used. +last occurrence will be used. diff --git a/contracts/cw4-stake/README.md b/contracts/cw4-stake/README.md index e505758bb..a5c82feb4 100644 --- a/contracts/cw4-stake/README.md +++ b/contracts/cw4-stake/README.md @@ -1,13 +1,13 @@ # CW4 Stake This is a second implementation of the [cw4 spec](../../packages/cw4/README.md). -It fufills all elements of the spec, including the raw query lookups, -and it is designed to be used as a backing storage for +It fulfills all elements of the spec, including the raw query lookups, +and is designed to be used as a backing storage for [cw3 compliant contracts](../../packages/cw3/README.md). It provides a similar API to [`cw4-group`] (which handles elected membership), but rather than appointing members (by admin or multisig), their -membership and weight is based on the number of tokens they have staked. +membership and weight are based on the number of tokens they have staked. This is similar to many DAOs. Only one denom can be bonded with both `min_bond` as the minimum amount