Skip to content

Instantly share code, notes, and snippets.

View CyberHoward's full-sized avatar
🧨

CyberHoward

🧨
View GitHub Profile
@larry0x
larry0x / json-raw-message-to-sdk-msg.go
Created June 16, 2023 03:37
json.RawMessage to sdk.Msg
package main
import (
"encoding/json"
"fmt"
"reflect"
"cosmossdk.io/simapp"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@Art3miX
Art3miX / update_storage.rs
Last active February 7, 2023 11:09
Easy way to update your storage manually in cw-multi-test.
// Long story short, IBC is not support with cw_multi_test, and I have a storage that is updaing based on some IBC call
// Because I can't mock the IBC call, I had to update the storage manually, heres a little helper to do so.
pub fn update_storage(app: &mut App, address: &[u8], function: &mut dyn FnMut(&mut PrefixedStorage)) {
app.init_modules(|_, _, storage| {
let mut namespace = b"contract_data/".to_vec();
namespace.extend_from_slice(address);
let mut prefixed_storage = PrefixedStorage::multilevel(storage, &[b"wasm", &namespace]);
@JakeHartnell
JakeHartnell / README.md
Last active November 8, 2024 01:52
Include README.md files in rust documentation generation

Include README.md in documentation generation and tests

Recentely, I was trying to make sure our README.md files for DAO DAO were included in the documentation generated by cargo doc or rustdoc. Moreover, I wanted code examples in our README.md files to be tested.

Here's a quick gist...

There is of course the doc attribute, and the rust book contains the following example which you are meant to include in your lib.rs or main.rs:

@campaul
campaul / tarnish.rs
Created December 11, 2015 01:52
Simple HTTP proxy in Rust.
/*
Simple HTTP proxy in Rust. Hard coded to proxy rust-lang.org.
*/
extern crate hyper;
use std::io::Read;
use hyper::Client;
use hyper::header::Connection;