cw-desmos-filter-posts

Crates.iocw-desmos-filter-posts
lib.rscw-desmos-filter-posts
version0.1.4
sourcesrc
created_at2021-03-18 09:11:03.529455
updated_at2021-11-18 14:06:39.51026
descriptionA cosmwasm contract that filters desmos' network posts based on the number of reports a post has
homepage
repositoryhttps://github.com/desmos-labs/desmos-contracts
max_upload_size
id370465
size534,943
Leonardo Bragagnolo (bragaz)

documentation

README

Filter posts contract

This contract will filter the posts returning only the posts that has less than n reports. n will be the number of reports that the contract need to exclude a post from the resulting list. The parameter can be chosen by the system, or the user that performs the query.

filter-posts-contract-flow

Store, instantiate and Interact with the contract on Desmos chain

Store the contract (if not stored before)

desmos tx wasm store <contract_name.wasm> --chain-id <chain_id> --from <key_name> --gas 1050000

Instantiate the contract

First you need to get the code_id of the previously stored contract. You can check it from the tx_response or alternatively by executing the following query:

desmos query wasm list-code

Response's example:

code_infos:
- creator: desmos1k8u92hx3k33a5vgppkyzq6m4frxx7ewnlkyjrh
  data_hash: 151EF9413F16C8953EE18FE527692B5DEA142EBF02027C3564852AC874844B7A
  id: 1
pagination: {}

After getting the contract's id you can now instatiate it by doing:

desmos tx wasm instantiate <code_id> '{"reports_limit": <number>}' --label <contract_name> --from <key_name> --chain-id <chain_id> --amount <amount>

Interact with the contract

desmos tx wasm execute <contract_address> '{"edit_reports_limit": { "reports_limit": <number> }}' --from <key_name> --chain-id <chain_id>
desmos query wasm contract-state smart <contract_address> '{"get_filtered_posts":{"reports_limit": <number>}}' --chain-id <chai_id>
Commit count: 652

cargo fmt