Skip to content

Commit

Permalink
Docs and comments on factory pattern, clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell committed Sep 16, 2023
1 parent 274635e commit 9b9df6a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 80 deletions.
69 changes: 0 additions & 69 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion contracts/voting/dao-voting-token-staked/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ library = []
# cargo test --features "test-tube"
test-tube = []
# when writing tests you may wish to enable test-tube as a default feature
default = ["test-tube"]
# default = ["test-tube"]

[dependencies]
cosmwasm-std = { workspace = true, features = ["cosmwasm_1_1"] }
Expand Down
8 changes: 8 additions & 0 deletions contracts/voting/dao-voting-token-staked/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@ Example insantiation mesggage:

NOTE: if using an existing Token Factory token, double check the Token Factory admin and consider changing the Token Factory to be the DAO after the DAO is created.

### Use a factory
Occassionally, more customization is needed. Maybe you want to have an Augmented Bonding Curve contract or LP pool that requires additional setup? It's possible with factory contracts!

The `factory` pattern takes a single `WasmMsg::Execute` message that calls into a custom factory contract.

**NOTE:** when using the factory pattern, it is important to only use a trusted factory contract, as all validation happens in the factory contract.

The [dao-test-custom-factory contract](../test/dao-test-custom-factory) provides an example of how this can be done and is used for tests. It is NOT production ready, but meant to serve as an example for building factory contracts.
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
"additionalProperties": false
},
{
"description": "Uses a factory pattern that must return the denom, optionally a Token Contract address. The binary must serialize to a `WasmMsg::Execute` message.",
"description": "Uses a factory contract that must return the denom, optionally a Token Contract address. The binary must serialize to a `WasmMsg::Execute` message. Validation happens in the factory contract itself, so be sure to use a trusted factory contract.",
"type": "object",
"required": [
"factory"
Expand Down
4 changes: 3 additions & 1 deletion contracts/voting/dao-voting-token-staked/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ pub enum TokenInfo {
/// Creates a new Token Factory token via the issue contract with the DAO automatically
/// setup as admin and owner.
New(NewTokenInfo),
/// Uses a factory pattern that must return the denom, optionally a Token Contract address.
/// Uses a factory contract that must return the denom, optionally a Token Contract address.
/// The binary must serialize to a `WasmMsg::Execute` message.
/// Validation happens in the factory contract itself, so be sure to use a
/// trusted factory contract.
Factory(Binary),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,5 @@ fn test_factory() {
// Query token contract
let token_contract: Addr = voting.query(&QueryMsg::TokenContract {}).unwrap();

assert_eq!(
denom,
format!(
"factory/{}/{}",
token_contract.to_string(),
DENOM.to_string()
)
);
assert_eq!(denom, format!("factory/{}/{}", token_contract, DENOM));
}

0 comments on commit 9b9df6a

Please sign in to comment.