This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/*jshint esversion: 8 */ | |
/* eslint-disable @typescript-eslint/naming-convention */ | |
const { toBase64, toUtf8 } = require('@cosmjs/encoding'); | |
const axios = require('axios'); | |
const { SigningCosmWasmClient } = require('@cosmjs/cosmwasm-stargate'); | |
const { GasPrice } = require('@cosmjs/stargate'); | |
const { DirectSecp256k1HdWallet } = require('@cosmjs/proto-signing'); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[entry_point] | |
pub fn ibc_packet_receive( | |
deps: DepsMut, | |
_env: Env, | |
msg: IbcPacketReceiveMsg, | |
) -> Result<IbcReceiveResponse, Never> { | |
// other parse code here... | |
let msg = Cw20ExecuteMsg::Transfer { | |
recipient, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CONTRACT_NAME: &str = "crates.io:my-crate-name"; | |
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); | |
#[entry_point] | |
pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, ContractError> { | |
let ver = cw2::get_contract_version(deps.storage)?; | |
// ensure we are migrating from an allowed contract | |
if ver.contract != CONTRACT_NAME { | |
return Err(StdError::generic_err("Can only upgrade from same type").into()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[entry_point] | |
pub fn sudo(_deps: DepsMut, _env: Env, msg: SudoMsg) -> Result<Response, HackError> { | |
match msg { | |
// you certainly don't want just anyone calling this | |
SudoMsg::TakeFunds { recipient, amount } => { | |
let msg = BankMsg::Send { | |
to_address: recipient, | |
amount, | |
}; | |
Ok(Response::new().add_message(msg)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use cw0::parse_reply_instantiate_data; | |
pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractError> { | |
let res = parse_reply_instantiate_data(msg)?; | |
let child_contract = deps.api.addr_validate(res.contract_address)?; | |
// store this where it belongs... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use cosmwasm_std::{Addr, QuerierWrapper}; | |
use cw4::Cw4Contract; | |
fn assert_membership(querier: &QuerierWrapper, contract: &Addr, account: &Addr) -> StdResult<()> { | |
let contract = Cw4Contract(addr.clone()); | |
if whitelist.is_member(&deps.querier, sender)?.is_none() { | |
return Err(StdError::generic("unauthorized")); | |
} | |
Ok(()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg_attr(not(feature = "library"), entry_point)] | |
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<Binary, StdError> { | |
/* your implementation here */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg_attr(not(feature = "library"), entry_point)] | |
pub fn execute( | |
deps: DepsMut, | |
env: Env, | |
info: MessageInfo, | |
msg: ExecuteMsg, | |
) -> Result<Response, ContractError> { | |
/* your implementation here */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simple http server to create streams for asyncio tests | |
""" | |
import asyncio | |
import aiohttp | |
from aiohttp import web | |
async def get_data(host, port): | |
url = 'http://{}:{}/'.format(host, port) |
NewerOlder