terra: Fix formatting
Also disable the unstable options in rustfmt.toml.
This commit is contained in:
parent
8d6bf74262
commit
68ae3ff6cd
|
@ -1,16 +1,6 @@
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{
|
||||||
to_binary,
|
to_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response, StdError, StdResult,
|
||||||
Binary,
|
Uint128, WasmMsg,
|
||||||
CosmosMsg,
|
|
||||||
Deps,
|
|
||||||
DepsMut,
|
|
||||||
Env,
|
|
||||||
MessageInfo,
|
|
||||||
Response,
|
|
||||||
StdError,
|
|
||||||
StdResult,
|
|
||||||
Uint128,
|
|
||||||
WasmMsg,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "library"))]
|
#[cfg(not(feature = "library"))]
|
||||||
|
@ -19,40 +9,17 @@ use cosmwasm_std::entry_point;
|
||||||
use cw2::set_contract_version;
|
use cw2::set_contract_version;
|
||||||
use cw20_legacy::{
|
use cw20_legacy::{
|
||||||
allowances::{
|
allowances::{
|
||||||
execute_burn_from,
|
execute_burn_from, execute_decrease_allowance, execute_increase_allowance,
|
||||||
execute_decrease_allowance,
|
execute_send_from, execute_transfer_from, query_allowance,
|
||||||
execute_increase_allowance,
|
|
||||||
execute_send_from,
|
|
||||||
execute_transfer_from,
|
|
||||||
query_allowance,
|
|
||||||
},
|
|
||||||
contract::{
|
|
||||||
execute_mint,
|
|
||||||
execute_send,
|
|
||||||
execute_transfer,
|
|
||||||
query_balance,
|
|
||||||
},
|
|
||||||
state::{
|
|
||||||
MinterData,
|
|
||||||
TokenInfo,
|
|
||||||
TOKEN_INFO,
|
|
||||||
},
|
},
|
||||||
|
contract::{execute_mint, execute_send, execute_transfer, query_balance},
|
||||||
|
state::{MinterData, TokenInfo, TOKEN_INFO},
|
||||||
ContractError,
|
ContractError,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
msg::{
|
msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, WrappedAssetInfoResponse},
|
||||||
ExecuteMsg,
|
state::{wrapped_asset_info, wrapped_asset_info_read, WrappedAssetInfo},
|
||||||
InstantiateMsg,
|
|
||||||
MigrateMsg,
|
|
||||||
QueryMsg,
|
|
||||||
WrappedAssetInfoResponse,
|
|
||||||
},
|
|
||||||
state::{
|
|
||||||
wrapped_asset_info,
|
|
||||||
wrapped_asset_info_read,
|
|
||||||
WrappedAssetInfo,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use cw20::TokenInfoResponse;
|
use cw20::TokenInfoResponse;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
|
@ -237,11 +204,7 @@ pub fn query_wrapped_asset_info(deps: Deps) -> StdResult<WrappedAssetInfoRespons
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use cosmwasm_std::testing::{
|
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
|
||||||
mock_dependencies,
|
|
||||||
mock_env,
|
|
||||||
mock_info,
|
|
||||||
};
|
|
||||||
use cw20::TokenInfoResponse;
|
use cw20::TokenInfoResponse;
|
||||||
|
|
||||||
fn get_balance(deps: Deps, address: HumanAddr) -> Uint128 {
|
fn get_balance(deps: Deps, address: HumanAddr) -> Uint128 {
|
||||||
|
|
|
@ -1,15 +1,8 @@
|
||||||
#![allow(clippy::field_reassign_with_default)]
|
#![allow(clippy::field_reassign_with_default)]
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{Addr, Binary, Uint128};
|
||||||
Addr,
|
|
||||||
Binary,
|
|
||||||
Uint128,
|
|
||||||
};
|
|
||||||
use cw20::Expiration;
|
use cw20::Expiration;
|
||||||
|
|
||||||
type HumanAddr = String;
|
type HumanAddr = String;
|
||||||
|
|
|
@ -1,20 +1,8 @@
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{Binary, CanonicalAddr, Storage};
|
||||||
Binary,
|
use cosmwasm_storage::{singleton, singleton_read, ReadonlySingleton, Singleton};
|
||||||
CanonicalAddr,
|
|
||||||
Storage,
|
|
||||||
};
|
|
||||||
use cosmwasm_storage::{
|
|
||||||
singleton,
|
|
||||||
singleton_read,
|
|
||||||
ReadonlySingleton,
|
|
||||||
Singleton,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const KEY_WRAPPED_ASSET: &[u8] = b"wrappedAsset";
|
pub const KEY_WRAPPED_ASSET: &[u8] = b"wrappedAsset";
|
||||||
|
|
||||||
|
@ -30,8 +18,6 @@ pub fn wrapped_asset_info(storage: &mut dyn Storage) -> Singleton<WrappedAssetIn
|
||||||
singleton(storage, KEY_WRAPPED_ASSET)
|
singleton(storage, KEY_WRAPPED_ASSET)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wrapped_asset_info_read(
|
pub fn wrapped_asset_info_read(storage: &dyn Storage) -> ReadonlySingleton<WrappedAssetInfo> {
|
||||||
storage: &dyn Storage,
|
|
||||||
) -> ReadonlySingleton<WrappedAssetInfo> {
|
|
||||||
singleton_read(storage, KEY_WRAPPED_ASSET)
|
singleton_read(storage, KEY_WRAPPED_ASSET)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,14 @@
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{
|
||||||
from_slice,
|
from_slice,
|
||||||
testing::{
|
testing::{mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage},
|
||||||
mock_dependencies,
|
Addr, Api, OwnedDeps, Response, Storage, Uint128,
|
||||||
mock_env,
|
|
||||||
mock_info,
|
|
||||||
MockApi,
|
|
||||||
MockQuerier,
|
|
||||||
MockStorage,
|
|
||||||
},
|
|
||||||
Addr,
|
|
||||||
Api,
|
|
||||||
OwnedDeps,
|
|
||||||
Response,
|
|
||||||
Storage,
|
|
||||||
Uint128,
|
|
||||||
};
|
};
|
||||||
use cosmwasm_storage::to_length_prefixed;
|
use cosmwasm_storage::to_length_prefixed;
|
||||||
use cw20::TokenInfoResponse;
|
use cw20::TokenInfoResponse;
|
||||||
use cw20_wrapped::{
|
use cw20_wrapped::{
|
||||||
contract::{
|
contract::{execute, instantiate, query},
|
||||||
execute,
|
msg::{ExecuteMsg, InstantiateMsg, QueryMsg, WrappedAssetInfoResponse},
|
||||||
instantiate,
|
state::{WrappedAssetInfo, KEY_WRAPPED_ASSET},
|
||||||
query,
|
|
||||||
},
|
|
||||||
msg::{
|
|
||||||
ExecuteMsg,
|
|
||||||
InstantiateMsg,
|
|
||||||
QueryMsg,
|
|
||||||
WrappedAssetInfoResponse,
|
|
||||||
},
|
|
||||||
state::{
|
|
||||||
WrappedAssetInfo,
|
|
||||||
KEY_WRAPPED_ASSET,
|
|
||||||
},
|
|
||||||
ContractError,
|
ContractError,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,9 +18,7 @@ static SENDER: &str = "addr3333";
|
||||||
|
|
||||||
fn get_wrapped_asset_info<S: Storage>(storage: &S) -> WrappedAssetInfo {
|
fn get_wrapped_asset_info<S: Storage>(storage: &S) -> WrappedAssetInfo {
|
||||||
let key = to_length_prefixed(KEY_WRAPPED_ASSET);
|
let key = to_length_prefixed(KEY_WRAPPED_ASSET);
|
||||||
let data = storage
|
let data = storage.get(&key).expect("data should exist");
|
||||||
.get(&key)
|
|
||||||
.expect("data should exist");
|
|
||||||
from_slice(&data).expect("invalid data")
|
from_slice(&data).expect("invalid data")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,39 +1,17 @@
|
||||||
#![cfg(test)]
|
#![cfg(test)]
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{
|
||||||
from_binary,
|
from_binary,
|
||||||
testing::{
|
testing::{mock_dependencies, mock_env, mock_info},
|
||||||
mock_dependencies,
|
to_binary, CosmosMsg, DepsMut, Empty, Response, WasmMsg,
|
||||||
mock_env,
|
|
||||||
mock_info,
|
|
||||||
},
|
|
||||||
to_binary,
|
|
||||||
CosmosMsg,
|
|
||||||
DepsMut,
|
|
||||||
Empty,
|
|
||||||
Response,
|
|
||||||
WasmMsg,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use cw721::{
|
use cw721::{
|
||||||
Approval,
|
Approval, ApprovalResponse, ContractInfoResponse, Cw721Query, Cw721ReceiveMsg, Expiration,
|
||||||
ApprovalResponse,
|
NftInfoResponse, OperatorsResponse, OwnerOfResponse,
|
||||||
ContractInfoResponse,
|
|
||||||
Cw721Query,
|
|
||||||
Cw721ReceiveMsg,
|
|
||||||
Expiration,
|
|
||||||
NftInfoResponse,
|
|
||||||
OperatorsResponse,
|
|
||||||
OwnerOfResponse,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ContractError,
|
ContractError, Cw721Contract, ExecuteMsg, Extension, InstantiateMsg, MintMsg, QueryMsg,
|
||||||
Cw721Contract,
|
|
||||||
ExecuteMsg,
|
|
||||||
Extension,
|
|
||||||
InstantiateMsg,
|
|
||||||
MintMsg,
|
|
||||||
QueryMsg,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const MINTER: &str = "merlin";
|
const MINTER: &str = "merlin";
|
||||||
|
|
|
@ -1,33 +1,12 @@
|
||||||
use std::{
|
use std::{env::current_dir, fs::create_dir_all};
|
||||||
env::current_dir,
|
|
||||||
fs::create_dir_all,
|
|
||||||
};
|
|
||||||
|
|
||||||
use cosmwasm_schema::{
|
use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for};
|
||||||
export_schema,
|
|
||||||
export_schema_with_title,
|
|
||||||
remove_schemas,
|
|
||||||
schema_for,
|
|
||||||
};
|
|
||||||
|
|
||||||
use cw721::{
|
use cw721::{
|
||||||
AllNftInfoResponse,
|
AllNftInfoResponse, ApprovalResponse, ApprovalsResponse, ContractInfoResponse, NftInfoResponse,
|
||||||
ApprovalResponse,
|
NumTokensResponse, OperatorsResponse, OwnerOfResponse, TokensResponse,
|
||||||
ApprovalsResponse,
|
|
||||||
ContractInfoResponse,
|
|
||||||
NftInfoResponse,
|
|
||||||
NumTokensResponse,
|
|
||||||
OperatorsResponse,
|
|
||||||
OwnerOfResponse,
|
|
||||||
TokensResponse,
|
|
||||||
};
|
|
||||||
use cw721_base::{
|
|
||||||
ExecuteMsg,
|
|
||||||
Extension,
|
|
||||||
InstantiateMsg,
|
|
||||||
MinterResponse,
|
|
||||||
QueryMsg,
|
|
||||||
};
|
};
|
||||||
|
use cw721_base::{ExecuteMsg, Extension, InstantiateMsg, MinterResponse, QueryMsg};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut out_dir = current_dir().unwrap();
|
let mut out_dir = current_dir().unwrap();
|
||||||
|
|
|
@ -2,10 +2,7 @@ pub mod msg;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
|
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub use cosmwasm_std::to_binary;
|
pub use cosmwasm_std::to_binary;
|
||||||
use cosmwasm_std::Empty;
|
use cosmwasm_std::Empty;
|
||||||
|
@ -27,34 +24,17 @@ pub mod entry {
|
||||||
|
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use crate::msg::{
|
use crate::msg::{InstantiateMsg, WrappedAssetInfoResponse};
|
||||||
InstantiateMsg,
|
|
||||||
WrappedAssetInfoResponse,
|
|
||||||
};
|
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
msg::QueryMsg,
|
msg::QueryMsg,
|
||||||
state::{
|
state::{wrapped_asset_info, wrapped_asset_info_read, WrappedAssetInfo},
|
||||||
wrapped_asset_info,
|
|
||||||
wrapped_asset_info_read,
|
|
||||||
WrappedAssetInfo,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{
|
||||||
entry_point,
|
entry_point, to_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Response,
|
||||||
to_binary,
|
StdError, StdResult, WasmMsg,
|
||||||
Binary,
|
|
||||||
CosmosMsg,
|
|
||||||
Deps,
|
|
||||||
DepsMut,
|
|
||||||
Env,
|
|
||||||
MessageInfo,
|
|
||||||
Response,
|
|
||||||
StdError,
|
|
||||||
StdResult,
|
|
||||||
WasmMsg,
|
|
||||||
};
|
};
|
||||||
use cw721::Cw721Query;
|
use cw721::Cw721Query;
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,8 @@
|
||||||
pub use cw721_base::MintMsg;
|
pub use cw721_base::MintMsg;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{Addr, Binary, Empty};
|
||||||
Addr,
|
|
||||||
Binary,
|
|
||||||
Empty,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub use cw721_base::msg::ExecuteMsg;
|
pub use cw721_base::msg::ExecuteMsg;
|
||||||
|
|
||||||
|
@ -129,7 +122,7 @@ pub enum QueryMsg {
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||||
pub struct WrappedAssetInfoResponse {
|
pub struct WrappedAssetInfoResponse {
|
||||||
pub asset_chain: u16, // Asset chain id
|
pub asset_chain: u16, // Asset chain id
|
||||||
pub asset_address: Binary, // Asset smart contract address in the original chain
|
pub asset_address: Binary, // Asset smart contract address in the original chain
|
||||||
pub bridge: Addr, // Bridge address, authorized to mint and burn wrapped tokens
|
pub bridge: Addr, // Bridge address, authorized to mint and burn wrapped tokens
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,8 @@
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{Binary, CanonicalAddr, Storage};
|
||||||
Binary,
|
use cosmwasm_storage::{singleton, singleton_read, ReadonlySingleton, Singleton};
|
||||||
CanonicalAddr,
|
|
||||||
Storage,
|
|
||||||
};
|
|
||||||
use cosmwasm_storage::{
|
|
||||||
singleton,
|
|
||||||
singleton_read,
|
|
||||||
ReadonlySingleton,
|
|
||||||
Singleton,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const KEY_WRAPPED_ASSET: &[u8] = b"wrappedAsset";
|
pub const KEY_WRAPPED_ASSET: &[u8] = b"wrappedAsset";
|
||||||
|
|
||||||
|
|
|
@ -1,42 +1,16 @@
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{
|
||||||
entry_point,
|
entry_point, to_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, QueryRequest,
|
||||||
to_binary,
|
Reply, Response, StdError, StdResult, SubMsg, WasmMsg, WasmQuery,
|
||||||
Binary,
|
|
||||||
CosmosMsg,
|
|
||||||
Deps,
|
|
||||||
DepsMut,
|
|
||||||
Env,
|
|
||||||
MessageInfo,
|
|
||||||
QueryRequest,
|
|
||||||
Reply,
|
|
||||||
Response,
|
|
||||||
StdError,
|
|
||||||
StdResult,
|
|
||||||
SubMsg,
|
|
||||||
WasmMsg,
|
|
||||||
WasmQuery,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
msg::{
|
msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg},
|
||||||
ExecuteMsg,
|
state::{config, config_read, Config},
|
||||||
InstantiateMsg,
|
|
||||||
MigrateMsg,
|
|
||||||
QueryMsg,
|
|
||||||
},
|
|
||||||
state::{
|
|
||||||
Config,
|
|
||||||
config,
|
|
||||||
config_read,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use token_bridge_terra::{
|
use token_bridge_terra::{
|
||||||
msg::{
|
|
||||||
ExecuteMsg as TokenBridgeExecuteMsg,
|
|
||||||
QueryMsg as TokenBridgeQueryMessage,
|
|
||||||
},
|
|
||||||
msg::TransferInfoResponse,
|
msg::TransferInfoResponse,
|
||||||
|
msg::{ExecuteMsg as TokenBridgeExecuteMsg, QueryMsg as TokenBridgeQueryMessage},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg_attr(not(feature = "library"), entry_point)]
|
#[cfg_attr(not(feature = "library"), entry_point)]
|
||||||
|
@ -64,7 +38,7 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S
|
||||||
match msg {
|
match msg {
|
||||||
ExecuteMsg::CompleteTransferWithPayload { data } => {
|
ExecuteMsg::CompleteTransferWithPayload { data } => {
|
||||||
complete_transfer_with_payload(deps, env, info, &data)
|
complete_transfer_with_payload(deps, env, info, &data)
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,31 +64,31 @@ fn complete_transfer_with_payload(
|
||||||
CosmosMsg::Wasm(WasmMsg::Execute {
|
CosmosMsg::Wasm(WasmMsg::Execute {
|
||||||
contract_addr: cfg.token_bridge_contract,
|
contract_addr: cfg.token_bridge_contract,
|
||||||
msg: to_binary(&TokenBridgeExecuteMsg::CompleteTransferWithPayload {
|
msg: to_binary(&TokenBridgeExecuteMsg::CompleteTransferWithPayload {
|
||||||
data: data.clone(), relayer: info.sender.to_string()
|
data: data.clone(),
|
||||||
|
relayer: info.sender.to_string(),
|
||||||
})?,
|
})?,
|
||||||
funds: vec![],
|
funds: vec![],
|
||||||
}),
|
}),
|
||||||
1,
|
1,
|
||||||
),];
|
)];
|
||||||
|
|
||||||
let transfer_info = parse_transfer_vaa(deps.as_ref(), data)?;
|
let transfer_info = parse_transfer_vaa(deps.as_ref(), data)?;
|
||||||
|
|
||||||
Ok(Response::new()
|
Ok(Response::new()
|
||||||
.add_submessages(messages)
|
.add_submessages(messages)
|
||||||
.add_attribute("action", "complete_transfer_with_payload")
|
.add_attribute("action", "complete_transfer_with_payload")
|
||||||
.add_attribute("transfer_payload", Binary::from(transfer_info.payload).to_base64()))
|
.add_attribute(
|
||||||
|
"transfer_payload",
|
||||||
|
Binary::from(transfer_info.payload).to_base64(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_transfer_vaa(
|
fn parse_transfer_vaa(deps: Deps, data: &Binary) -> StdResult<TransferInfoResponse> {
|
||||||
deps: Deps,
|
|
||||||
data: &Binary,
|
|
||||||
) -> StdResult<TransferInfoResponse> {
|
|
||||||
let cfg = config_read(deps.storage).load()?;
|
let cfg = config_read(deps.storage).load()?;
|
||||||
let transfer_info: TransferInfoResponse = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
|
let transfer_info: TransferInfoResponse =
|
||||||
contract_addr: cfg.token_bridge_contract,
|
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
|
||||||
msg: to_binary(&TokenBridgeQueryMessage::TransferInfo {
|
contract_addr: cfg.token_bridge_contract,
|
||||||
vaa: data.clone(),
|
msg: to_binary(&TokenBridgeQueryMessage::TransferInfo { vaa: data.clone() })?,
|
||||||
})?,
|
}))?;
|
||||||
}))?;
|
|
||||||
Ok(transfer_info)
|
Ok(transfer_info)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use cosmwasm_std::Binary;
|
use cosmwasm_std::Binary;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
type HumanAddr = String;
|
type HumanAddr = String;
|
||||||
|
|
||||||
|
@ -15,9 +12,7 @@ pub struct InstantiateMsg {
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum ExecuteMsg {
|
pub enum ExecuteMsg {
|
||||||
CompleteTransferWithPayload {
|
CompleteTransferWithPayload { data: Binary },
|
||||||
data: Binary,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||||
|
@ -28,4 +23,4 @@ pub struct MigrateMsg {}
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum QueryMsg {
|
pub enum QueryMsg {
|
||||||
WrappedRegistry { chain: u16, address: Binary },
|
WrappedRegistry { chain: u16, address: Binary },
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,8 @@
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use cosmwasm_std::Storage;
|
use cosmwasm_std::Storage;
|
||||||
use cosmwasm_storage::{
|
use cosmwasm_storage::{singleton, singleton_read, ReadonlySingleton, Singleton};
|
||||||
singleton,
|
|
||||||
singleton_read,
|
|
||||||
ReadonlySingleton,
|
|
||||||
Singleton,
|
|
||||||
};
|
|
||||||
|
|
||||||
type HumanAddr = String;
|
type HumanAddr = String;
|
||||||
|
|
||||||
|
@ -28,4 +20,4 @@ pub fn config(storage: &mut dyn Storage) -> Singleton<Config> {
|
||||||
|
|
||||||
pub fn config_read(storage: &dyn Storage) -> ReadonlySingleton<Config> {
|
pub fn config_read(storage: &dyn Storage) -> ReadonlySingleton<Config> {
|
||||||
singleton_read(storage, CONFIG_KEY)
|
singleton_read(storage, CONFIG_KEY)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,87 +1,35 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
msg::WrappedRegistryResponse,
|
msg::WrappedRegistryResponse,
|
||||||
state::{
|
state::{spl_cache, spl_cache_read, wrapped_asset, BoundedVec, SplCacheItem},
|
||||||
spl_cache,
|
token_id::{from_external_token_id, to_external_token_id},
|
||||||
spl_cache_read,
|
|
||||||
wrapped_asset,
|
|
||||||
BoundedVec,
|
|
||||||
SplCacheItem,
|
|
||||||
},
|
|
||||||
token_id::{
|
|
||||||
from_external_token_id,
|
|
||||||
to_external_token_id,
|
|
||||||
},
|
|
||||||
CHAIN_ID,
|
CHAIN_ID,
|
||||||
};
|
};
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{
|
||||||
entry_point,
|
entry_point, to_binary, Binary, CanonicalAddr, CosmosMsg, Deps, DepsMut, Empty, Env,
|
||||||
to_binary,
|
MessageInfo, Order, QueryRequest, Response, StdError, StdResult, WasmMsg, WasmQuery,
|
||||||
Binary,
|
|
||||||
CanonicalAddr,
|
|
||||||
CosmosMsg,
|
|
||||||
Deps,
|
|
||||||
DepsMut,
|
|
||||||
Empty,
|
|
||||||
Env,
|
|
||||||
MessageInfo,
|
|
||||||
QueryRequest,
|
|
||||||
Response,
|
|
||||||
StdError,
|
|
||||||
StdResult,
|
|
||||||
WasmMsg,
|
|
||||||
WasmQuery, Order,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
msg::{
|
msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg},
|
||||||
ExecuteMsg,
|
|
||||||
InstantiateMsg,
|
|
||||||
MigrateMsg,
|
|
||||||
QueryMsg,
|
|
||||||
},
|
|
||||||
state::{
|
state::{
|
||||||
bridge_contracts,
|
bridge_contracts, bridge_contracts_read, config, config_read, wrapped_asset_address,
|
||||||
bridge_contracts_read,
|
wrapped_asset_address_read, wrapped_asset_read, Action, ConfigInfo, RegisterChain,
|
||||||
config,
|
TokenBridgeMessage, TransferInfo, UpgradeContract,
|
||||||
config_read,
|
|
||||||
wrapped_asset_address,
|
|
||||||
wrapped_asset_address_read,
|
|
||||||
wrapped_asset_read,
|
|
||||||
Action,
|
|
||||||
ConfigInfo,
|
|
||||||
RegisterChain,
|
|
||||||
TokenBridgeMessage,
|
|
||||||
TransferInfo,
|
|
||||||
UpgradeContract,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use wormhole::{
|
use wormhole::{
|
||||||
byte_utils::{
|
byte_utils::{
|
||||||
extend_address_to_32,
|
extend_address_to_32, extend_address_to_32_array, get_string_from_32, string_to_array,
|
||||||
extend_address_to_32_array,
|
|
||||||
get_string_from_32,
|
|
||||||
string_to_array,
|
|
||||||
ByteUtils,
|
ByteUtils,
|
||||||
},
|
},
|
||||||
error::ContractError,
|
error::ContractError,
|
||||||
};
|
};
|
||||||
|
|
||||||
use wormhole::msg::{
|
use wormhole::msg::{ExecuteMsg as WormholeExecuteMsg, QueryMsg as WormholeQueryMsg};
|
||||||
ExecuteMsg as WormholeExecuteMsg,
|
|
||||||
QueryMsg as WormholeQueryMsg,
|
|
||||||
};
|
|
||||||
|
|
||||||
use wormhole::state::{
|
use wormhole::state::{vaa_archive_add, vaa_archive_check, GovernancePacket, ParsedVAA};
|
||||||
vaa_archive_add,
|
|
||||||
vaa_archive_check,
|
|
||||||
GovernancePacket,
|
|
||||||
ParsedVAA,
|
|
||||||
};
|
|
||||||
|
|
||||||
use sha3::{
|
use sha3::{Digest, Keccak256};
|
||||||
Digest,
|
|
||||||
Keccak256,
|
|
||||||
};
|
|
||||||
|
|
||||||
type HumanAddr = String;
|
type HumanAddr = String;
|
||||||
|
|
||||||
|
@ -409,7 +357,10 @@ fn handle_initiate_transfer(
|
||||||
|
|
||||||
let mut messages: Vec<CosmosMsg> = vec![];
|
let mut messages: Vec<CosmosMsg> = vec![];
|
||||||
|
|
||||||
if wrapped_asset_address_read(deps.storage).load(asset_canonical.as_slice()).is_ok() {
|
if wrapped_asset_address_read(deps.storage)
|
||||||
|
.load(asset_canonical.as_slice())
|
||||||
|
.is_ok()
|
||||||
|
{
|
||||||
// This is a deployed wrapped asset, burn it
|
// This is a deployed wrapped asset, burn it
|
||||||
messages.push(CosmosMsg::Wasm(WasmMsg::Execute {
|
messages.push(CosmosMsg::Wasm(WasmMsg::Execute {
|
||||||
contract_addr: asset.clone(),
|
contract_addr: asset.clone(),
|
||||||
|
@ -525,9 +476,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
|
||||||
QueryMsg::WrappedRegistry { chain, address } => {
|
QueryMsg::WrappedRegistry { chain, address } => {
|
||||||
to_binary(&query_wrapped_registry(deps, chain, address.as_slice())?)
|
to_binary(&query_wrapped_registry(deps, chain, address.as_slice())?)
|
||||||
}
|
}
|
||||||
QueryMsg::AllWrappedAssets { } => {
|
QueryMsg::AllWrappedAssets {} => to_binary(&query_all_wrapped_assets(deps)?),
|
||||||
to_binary(&query_all_wrapped_assets(deps)?)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +529,6 @@ fn query_all_wrapped_assets(deps: Deps) -> StdResult<Vec<String>> {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn build_asset_id(chain: u16, address: &[u8]) -> Vec<u8> {
|
fn build_asset_id(chain: u16, address: &[u8]) -> Vec<u8> {
|
||||||
let mut asset_id: Vec<u8> = vec![];
|
let mut asset_id: Vec<u8> = vec![];
|
||||||
asset_id.extend_from_slice(&chain.to_be_bytes());
|
asset_id.extend_from_slice(&chain.to_be_bytes());
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use cosmwasm_std::Binary;
|
use cosmwasm_std::Binary;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
type HumanAddr = String;
|
type HumanAddr = String;
|
||||||
|
|
||||||
|
@ -45,7 +42,7 @@ pub struct MigrateMsg {}
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum QueryMsg {
|
pub enum QueryMsg {
|
||||||
WrappedRegistry { chain: u16, address: Binary },
|
WrappedRegistry { chain: u16, address: Binary },
|
||||||
AllWrappedAssets { },
|
AllWrappedAssets {},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||||
|
|
|
@ -1,24 +1,11 @@
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{StdError, StdResult, Storage};
|
||||||
StdError,
|
|
||||||
StdResult,
|
|
||||||
Storage,
|
|
||||||
};
|
|
||||||
use cosmwasm_storage::{
|
use cosmwasm_storage::{
|
||||||
bucket,
|
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton,
|
||||||
bucket_read,
|
|
||||||
singleton,
|
|
||||||
singleton_read,
|
|
||||||
Bucket,
|
|
||||||
ReadonlyBucket,
|
|
||||||
ReadonlySingleton,
|
|
||||||
Singleton,
|
Singleton,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
use bigint::U256;
|
use bigint::U256;
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{StdError, StdResult, Storage};
|
||||||
StdError,
|
|
||||||
StdResult,
|
|
||||||
Storage,
|
|
||||||
};
|
|
||||||
|
|
||||||
use sha3::{
|
use sha3::{
|
||||||
digest::{consts::U32, generic_array::GenericArray},
|
digest::{consts::U32, generic_array::GenericArray},
|
||||||
|
@ -12,10 +8,7 @@ use sha3::{
|
||||||
use wormhole::byte_utils::ByteUtils;
|
use wormhole::byte_utils::ByteUtils;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
state::{
|
state::{token_id_hashes, token_id_hashes_read},
|
||||||
token_id_hashes,
|
|
||||||
token_id_hashes_read,
|
|
||||||
},
|
|
||||||
CHAIN_ID,
|
CHAIN_ID,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,117 +1,44 @@
|
||||||
use cw20::{
|
use cw20::{BalanceResponse, TokenInfoResponse};
|
||||||
BalanceResponse,
|
use cw20_base::msg::{ExecuteMsg as TokenMsg, QueryMsg as TokenQuery};
|
||||||
TokenInfoResponse,
|
|
||||||
};
|
|
||||||
use cw20_base::msg::{
|
|
||||||
ExecuteMsg as TokenMsg,
|
|
||||||
QueryMsg as TokenQuery,
|
|
||||||
};
|
|
||||||
use cw20_wrapped::msg::{
|
use cw20_wrapped::msg::{
|
||||||
ExecuteMsg as WrappedMsg,
|
ExecuteMsg as WrappedMsg, InitHook, InstantiateMsg as WrappedInit, QueryMsg as WrappedQuery,
|
||||||
InitHook,
|
|
||||||
InstantiateMsg as WrappedInit,
|
|
||||||
QueryMsg as WrappedQuery,
|
|
||||||
WrappedAssetInfoResponse,
|
WrappedAssetInfoResponse,
|
||||||
};
|
};
|
||||||
use sha3::{
|
use sha3::{Digest, Keccak256};
|
||||||
Digest,
|
|
||||||
Keccak256,
|
|
||||||
};
|
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{
|
cmp::{max, min},
|
||||||
max,
|
|
||||||
min,
|
|
||||||
},
|
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
};
|
};
|
||||||
use terraswap::asset::{
|
use terraswap::asset::{Asset, AssetInfo};
|
||||||
Asset,
|
|
||||||
AssetInfo,
|
|
||||||
};
|
|
||||||
|
|
||||||
use terra_cosmwasm::TerraQuerier;
|
use terra_cosmwasm::TerraQuerier;
|
||||||
use wormhole::{
|
use wormhole::{
|
||||||
byte_utils::{
|
byte_utils::{
|
||||||
extend_address_to_32,
|
extend_address_to_32, extend_address_to_32_array, extend_string_to_32, get_string_from_32,
|
||||||
extend_address_to_32_array,
|
|
||||||
extend_string_to_32,
|
|
||||||
get_string_from_32,
|
|
||||||
ByteUtils,
|
ByteUtils,
|
||||||
},
|
},
|
||||||
error::ContractError,
|
error::ContractError,
|
||||||
msg::{
|
msg::{ExecuteMsg as WormholeExecuteMsg, QueryMsg as WormholeQueryMsg},
|
||||||
ExecuteMsg as WormholeExecuteMsg,
|
state::{vaa_archive_add, vaa_archive_check, GovernancePacket, ParsedVAA},
|
||||||
QueryMsg as WormholeQueryMsg,
|
|
||||||
},
|
|
||||||
state::{
|
|
||||||
vaa_archive_add,
|
|
||||||
vaa_archive_check,
|
|
||||||
GovernancePacket,
|
|
||||||
ParsedVAA,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{
|
||||||
coin,
|
coin, entry_point, to_binary, BankMsg, Binary, CanonicalAddr, Coin, CosmosMsg, Decimal, Deps,
|
||||||
entry_point,
|
DepsMut, Empty, Env, MessageInfo, Order, QuerierWrapper, QueryRequest, Reply, Response,
|
||||||
to_binary,
|
StdError, StdResult, SubMsg, Uint128, WasmMsg, WasmQuery,
|
||||||
BankMsg,
|
|
||||||
Binary,
|
|
||||||
CanonicalAddr,
|
|
||||||
Coin,
|
|
||||||
CosmosMsg,
|
|
||||||
Decimal,
|
|
||||||
Deps,
|
|
||||||
DepsMut,
|
|
||||||
Empty,
|
|
||||||
Env,
|
|
||||||
MessageInfo,
|
|
||||||
Order,
|
|
||||||
QuerierWrapper,
|
|
||||||
QueryRequest,
|
|
||||||
Reply,
|
|
||||||
Response,
|
|
||||||
StdError,
|
|
||||||
StdResult,
|
|
||||||
SubMsg,
|
|
||||||
Uint128,
|
|
||||||
WasmMsg,
|
|
||||||
WasmQuery,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
msg::{
|
msg::{
|
||||||
ExecuteMsg,
|
ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, TransferInfoResponse,
|
||||||
InstantiateMsg,
|
|
||||||
MigrateMsg,
|
|
||||||
QueryMsg,
|
|
||||||
TransferInfoResponse,
|
|
||||||
WrappedRegistryResponse,
|
WrappedRegistryResponse,
|
||||||
},
|
},
|
||||||
state::{
|
state::{
|
||||||
bridge_contracts,
|
bridge_contracts, bridge_contracts_read, bridge_deposit, config, config_read,
|
||||||
bridge_contracts_read,
|
receive_native, send_native, wrapped_asset, wrapped_asset_address,
|
||||||
bridge_deposit,
|
wrapped_asset_address_read, wrapped_asset_read, wrapped_asset_seq, wrapped_asset_seq_read,
|
||||||
config,
|
wrapped_transfer_tmp, Action, AssetMeta, ConfigInfo, RegisterChain, TokenBridgeMessage,
|
||||||
config_read,
|
TransferInfo, TransferState, TransferWithPayloadInfo, UpgradeContract,
|
||||||
receive_native,
|
|
||||||
send_native,
|
|
||||||
wrapped_asset,
|
|
||||||
wrapped_asset_address,
|
|
||||||
wrapped_asset_address_read,
|
|
||||||
wrapped_asset_read,
|
|
||||||
wrapped_asset_seq,
|
|
||||||
wrapped_asset_seq_read,
|
|
||||||
wrapped_transfer_tmp,
|
|
||||||
Action,
|
|
||||||
AssetMeta,
|
|
||||||
ConfigInfo,
|
|
||||||
RegisterChain,
|
|
||||||
TokenBridgeMessage,
|
|
||||||
TransferInfo,
|
|
||||||
TransferState,
|
|
||||||
TransferWithPayloadInfo,
|
|
||||||
UpgradeContract,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,7 @@
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{Binary, Uint128};
|
||||||
Binary,
|
|
||||||
Uint128,
|
|
||||||
};
|
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
use terraswap::asset::{Asset, AssetInfo};
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
use terraswap::asset::{
|
|
||||||
Asset,
|
|
||||||
AssetInfo,
|
|
||||||
};
|
|
||||||
|
|
||||||
type HumanAddr = String;
|
type HumanAddr = String;
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,9 @@
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{CanonicalAddr, StdError, StdResult, Storage, Uint128};
|
||||||
CanonicalAddr,
|
|
||||||
StdError,
|
|
||||||
StdResult,
|
|
||||||
Storage,
|
|
||||||
Uint128,
|
|
||||||
};
|
|
||||||
use cosmwasm_storage::{
|
use cosmwasm_storage::{
|
||||||
bucket,
|
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton,
|
||||||
bucket_read,
|
|
||||||
singleton,
|
|
||||||
singleton_read,
|
|
||||||
Bucket,
|
|
||||||
ReadonlyBucket,
|
|
||||||
ReadonlySingleton,
|
|
||||||
Singleton,
|
Singleton,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -265,7 +250,6 @@ impl TransferWithPayloadInfo {
|
||||||
sender_address,
|
sender_address,
|
||||||
payload,
|
payload,
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn serialize(&self) -> Vec<u8> {
|
pub fn serialize(&self) -> Vec<u8> {
|
||||||
|
|
|
@ -1,21 +1,10 @@
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{Binary, StdResult};
|
||||||
Binary,
|
|
||||||
StdResult,
|
|
||||||
};
|
|
||||||
|
|
||||||
use wormhole::state::ParsedVAA;
|
use wormhole::state::ParsedVAA;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
contract::{
|
contract::{build_asset_id, build_native_id},
|
||||||
build_asset_id,
|
state::{Action, TokenBridgeMessage, TransferInfo, TransferWithPayloadInfo},
|
||||||
build_native_id,
|
|
||||||
},
|
|
||||||
state::{
|
|
||||||
Action,
|
|
||||||
TokenBridgeMessage,
|
|
||||||
TransferInfo,
|
|
||||||
TransferWithPayloadInfo,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -138,27 +127,26 @@ fn deserialize_transfer_vaa() -> StdResult<()> {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_transfer_with_payload_vaa() -> StdResult<()> {
|
fn deserialize_transfer_with_payload_vaa() -> StdResult<()> {
|
||||||
|
// ┌──────────────────────────────────────────────────────────────────────────────┐
|
||||||
// ┌──────────────────────────────────────────────────────────────────────────────┐
|
// │ Wormhole VAA v1 │ nonce: 2080370133 │ time: 0 │
|
||||||
// │ Wormhole VAA v1 │ nonce: 2080370133 │ time: 0 │
|
// │ guardian set #0 │ #4568529024235897313 │ consistency: 32 │
|
||||||
// │ guardian set #0 │ #4568529024235897313 │ consistency: 32 │
|
// ├──────────────────────────────────────────────────────────────────────────────┤
|
||||||
// ├──────────────────────────────────────────────────────────────────────────────┤
|
// │ Signature: │
|
||||||
// │ Signature: │
|
// │ #0: 2565e7ae10421624fd81118855acda893e752aeeef31c13fbfc417591ada... │
|
||||||
// │ #0: 2565e7ae10421624fd81118855acda893e752aeeef31c13fbfc417591ada... │
|
// ├──────────────────────────────────────────────────────────────────────────────┤
|
||||||
// ├──────────────────────────────────────────────────────────────────────────────┤
|
// │ Emitter: 11111111111111111111111111111115 (Solana) │
|
||||||
// │ Emitter: 11111111111111111111111111111115 (Solana) │
|
// ╞══════════════════════════════════════════════════════════════════════════════╡
|
||||||
// ╞══════════════════════════════════════════════════════════════════════════════╡
|
// │ Token transfer with payload (aka payload 3) │
|
||||||
// │ Token transfer with payload (aka payload 3) │
|
// │ Amount: 1.0 │
|
||||||
// │ Amount: 1.0 │
|
// │ Token: terra1qqqqqqqqqqqqqqqqqqqqqqqqqp6h2umyswfh6y (Terra) │
|
||||||
// │ Token: terra1qqqqqqqqqqqqqqqqqqqqqqqqqp6h2umyswfh6y (Terra) │
|
// │ Recipient: terra13nkgqrfymug724h8pprpexqj9h629sa3ncw7sh (Terra) │
|
||||||
// │ Recipient: terra13nkgqrfymug724h8pprpexqj9h629sa3ncw7sh (Terra) │
|
// │ From: 1399a4e782b935d2bb36b97586d3df8747b07dc66902d807eed0ae99e00ed256 │
|
||||||
// │ From: 1399a4e782b935d2bb36b97586d3df8747b07dc66902d807eed0ae99e00ed256 │
|
// ╞══════════════════════════════════════════════════════════════════════════════╡
|
||||||
// ╞══════════════════════════════════════════════════════════════════════════════╡
|
// │ Custom payload: │
|
||||||
// │ Custom payload: │
|
// │ Length: 30 (0x1e) bytes │
|
||||||
// │ Length: 30 (0x1e) bytes │
|
// │ 0000: 41 6c 6c 20 79 6f 75 72 20 62 61 73 65 20 61 72 All your base ar│
|
||||||
// │ 0000: 41 6c 6c 20 79 6f 75 72 20 62 61 73 65 20 61 72 All your base ar│
|
// │ 0010: 65 20 62 65 6c 6f 6e 67 20 74 6f 20 75 73 e belong to us │
|
||||||
// │ 0010: 65 20 62 65 6c 6f 6e 67 20 74 6f 20 75 73 e belong to us │
|
// └──────────────────────────────────────────────────────────────────────────────┘
|
||||||
// └──────────────────────────────────────────────────────────────────────────────┘
|
|
||||||
|
|
||||||
let signed_vaa = "\
|
let signed_vaa = "\
|
||||||
010000000001002565e7ae10421624fd81118855acda893e752aeeef31c13fbf\
|
010000000001002565e7ae10421624fd81118855acda893e752aeeef31c13fbf\
|
||||||
|
@ -221,7 +209,6 @@ fn deserialize_transfer_with_payload_vaa() -> StdResult<()> {
|
||||||
"info.recipient_chain != expected"
|
"info.recipient_chain != expected"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
let transfer_payload = "All your base are belong to us";
|
let transfer_payload = "All your base are belong to us";
|
||||||
let transfer_payload = transfer_payload.as_bytes();
|
let transfer_payload = transfer_payload.as_bytes();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -1,75 +1,33 @@
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{
|
||||||
has_coins,
|
has_coins, to_binary, BankMsg, Binary, Coin, CosmosMsg, Deps, DepsMut, Env, MessageInfo,
|
||||||
to_binary,
|
Response, StdError, StdResult, Storage, WasmMsg,
|
||||||
BankMsg,
|
|
||||||
Binary,
|
|
||||||
Coin,
|
|
||||||
CosmosMsg,
|
|
||||||
Deps,
|
|
||||||
DepsMut,
|
|
||||||
Env,
|
|
||||||
MessageInfo,
|
|
||||||
Response,
|
|
||||||
StdError,
|
|
||||||
StdResult,
|
|
||||||
Storage,
|
|
||||||
WasmMsg,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "library"))]
|
#[cfg(not(feature = "library"))]
|
||||||
use cosmwasm_std::entry_point;
|
use cosmwasm_std::entry_point;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
byte_utils::{
|
byte_utils::{extend_address_to_32, ByteUtils},
|
||||||
extend_address_to_32,
|
|
||||||
ByteUtils,
|
|
||||||
},
|
|
||||||
error::ContractError,
|
error::ContractError,
|
||||||
msg::{
|
msg::{
|
||||||
ExecuteMsg,
|
ExecuteMsg, GetAddressHexResponse, GetStateResponse, GuardianSetInfoResponse,
|
||||||
GetAddressHexResponse,
|
InstantiateMsg, MigrateMsg, QueryMsg,
|
||||||
GetStateResponse,
|
|
||||||
GuardianSetInfoResponse,
|
|
||||||
InstantiateMsg,
|
|
||||||
MigrateMsg,
|
|
||||||
QueryMsg,
|
|
||||||
},
|
},
|
||||||
state::{
|
state::{
|
||||||
config,
|
config, config_read, guardian_set_get, guardian_set_set, sequence_read, sequence_set,
|
||||||
config_read,
|
vaa_archive_add, vaa_archive_check, ConfigInfo, ContractUpgrade, GovernancePacket,
|
||||||
guardian_set_get,
|
GuardianAddress, GuardianSetInfo, GuardianSetUpgrade, ParsedVAA, SetFee, TransferFee,
|
||||||
guardian_set_set,
|
|
||||||
sequence_read,
|
|
||||||
sequence_set,
|
|
||||||
vaa_archive_add,
|
|
||||||
vaa_archive_check,
|
|
||||||
ConfigInfo,
|
|
||||||
ContractUpgrade,
|
|
||||||
GovernancePacket,
|
|
||||||
GuardianAddress,
|
|
||||||
GuardianSetInfo,
|
|
||||||
GuardianSetUpgrade,
|
|
||||||
ParsedVAA,
|
|
||||||
SetFee,
|
|
||||||
TransferFee,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use k256::{
|
use k256::{
|
||||||
ecdsa::{
|
ecdsa::{
|
||||||
recoverable::{
|
recoverable::{Id as RecoverableId, Signature as RecoverableSignature},
|
||||||
Id as RecoverableId,
|
Signature, VerifyingKey,
|
||||||
Signature as RecoverableSignature,
|
|
||||||
},
|
|
||||||
Signature,
|
|
||||||
VerifyingKey,
|
|
||||||
},
|
},
|
||||||
EncodedPoint,
|
EncodedPoint,
|
||||||
};
|
};
|
||||||
use sha3::{
|
use sha3::{Digest, Keccak256};
|
||||||
Digest,
|
|
||||||
Keccak256,
|
|
||||||
};
|
|
||||||
|
|
||||||
use generic_array::GenericArray;
|
use generic_array::GenericArray;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{Binary, Coin};
|
||||||
Binary,
|
|
||||||
Coin,
|
|
||||||
};
|
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{
|
use serde::{Deserialize, Serialize};
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::state::{
|
use crate::state::{GuardianAddress, GuardianSetInfo};
|
||||||
GuardianAddress,
|
|
||||||
GuardianSetInfo,
|
|
||||||
};
|
|
||||||
|
|
||||||
type HumanAddr = String;
|
type HumanAddr = String;
|
||||||
|
|
||||||
|
@ -33,8 +24,7 @@ pub enum ExecuteMsg {
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub struct MigrateMsg {
|
pub struct MigrateMsg {}
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
|
|
|
@ -1,39 +1,15 @@
|
||||||
use schemars::{
|
use schemars::JsonSchema;
|
||||||
JsonSchema,
|
use serde::{Deserialize, Serialize};
|
||||||
};
|
|
||||||
use serde::{
|
|
||||||
Deserialize,
|
|
||||||
Serialize,
|
|
||||||
};
|
|
||||||
|
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{Binary, CanonicalAddr, Coin, StdResult, Storage, Uint128};
|
||||||
Binary,
|
|
||||||
CanonicalAddr,
|
|
||||||
Coin,
|
|
||||||
StdResult,
|
|
||||||
Storage,
|
|
||||||
Uint128,
|
|
||||||
};
|
|
||||||
use cosmwasm_storage::{
|
use cosmwasm_storage::{
|
||||||
bucket,
|
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton,
|
||||||
bucket_read,
|
|
||||||
singleton,
|
|
||||||
singleton_read,
|
|
||||||
Bucket,
|
|
||||||
ReadonlyBucket,
|
|
||||||
ReadonlySingleton,
|
|
||||||
Singleton,
|
Singleton,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{byte_utils::ByteUtils, error::ContractError};
|
||||||
byte_utils::ByteUtils,
|
|
||||||
error::ContractError,
|
|
||||||
};
|
|
||||||
|
|
||||||
use sha3::{
|
use sha3::{Digest, Keccak256};
|
||||||
Digest,
|
|
||||||
Keccak256,
|
|
||||||
};
|
|
||||||
|
|
||||||
type HumanAddr = String;
|
type HumanAddr = String;
|
||||||
|
|
||||||
|
@ -299,7 +275,7 @@ impl GovernancePacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
// action 1
|
// action 1
|
||||||
pub struct ContractUpgrade {
|
pub struct ContractUpgrade {
|
||||||
pub new_contract: u64,
|
pub new_contract: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,9 +288,7 @@ pub struct GuardianSetUpgrade {
|
||||||
impl ContractUpgrade {
|
impl ContractUpgrade {
|
||||||
pub fn deserialize(data: &[u8]) -> StdResult<Self> {
|
pub fn deserialize(data: &[u8]) -> StdResult<Self> {
|
||||||
let new_contract = data.get_u64(24);
|
let new_contract = data.get_u64(24);
|
||||||
Ok(ContractUpgrade {
|
Ok(ContractUpgrade { new_contract })
|
||||||
new_contract,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,4 +359,3 @@ impl TransferFee {
|
||||||
Ok(TransferFee { amount, recipient })
|
Ok(TransferFee { amount, recipient })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
|
@ -1,26 +1,20 @@
|
||||||
use cosmwasm_std::{StdResult, CanonicalAddr};
|
use cosmwasm_std::{CanonicalAddr, StdResult};
|
||||||
|
|
||||||
use crate::state::{GuardianAddress, GuardianSetInfo, ParsedVAA};
|
|
||||||
use crate::byte_utils::ByteUtils;
|
use crate::byte_utils::ByteUtils;
|
||||||
|
use crate::state::{GuardianAddress, GuardianSetInfo, ParsedVAA};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn quardian_set_quorum() {
|
fn quardian_set_quorum() {
|
||||||
let num_guardians_trials: Vec<usize> = vec![
|
let num_guardians_trials: Vec<usize> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 20, 25, 100];
|
||||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 20, 25, 100,
|
|
||||||
];
|
|
||||||
|
|
||||||
let expected_quorums: Vec<usize> = vec![
|
let expected_quorums: Vec<usize> = vec![1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 14, 17, 67];
|
||||||
1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 14, 17, 67,
|
|
||||||
];
|
|
||||||
|
|
||||||
let make_guardian_set = |n: usize| -> GuardianSetInfo {
|
let make_guardian_set = |n: usize| -> GuardianSetInfo {
|
||||||
let mut addresses = Vec::with_capacity(n);
|
let mut addresses = Vec::with_capacity(n);
|
||||||
for _ in 0..n {
|
for _ in 0..n {
|
||||||
addresses.push(
|
addresses.push(GuardianAddress {
|
||||||
GuardianAddress {
|
bytes: Vec::new().into(),
|
||||||
bytes: Vec::new().into(),
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
GuardianSetInfo {
|
GuardianSetInfo {
|
||||||
addresses,
|
addresses,
|
||||||
|
@ -49,7 +43,10 @@ fn deserialize_round_1() -> StdResult<()> {
|
||||||
assert_eq!(parsed.version, version, "parsed.version != expected");
|
assert_eq!(parsed.version, version, "parsed.version != expected");
|
||||||
|
|
||||||
let guardian_set_index = 9u32;
|
let guardian_set_index = 9u32;
|
||||||
assert_eq!(parsed.guardian_set_index, guardian_set_index, "parsed.guardian_set_index != expected");
|
assert_eq!(
|
||||||
|
parsed.guardian_set_index, guardian_set_index,
|
||||||
|
"parsed.guardian_set_index != expected"
|
||||||
|
);
|
||||||
|
|
||||||
let timestamp = 2837u32;
|
let timestamp = 2837u32;
|
||||||
assert_eq!(parsed.timestamp, timestamp, "parsed.timestamp != expected");
|
assert_eq!(parsed.timestamp, timestamp, "parsed.timestamp != expected");
|
||||||
|
@ -58,29 +55,40 @@ fn deserialize_round_1() -> StdResult<()> {
|
||||||
assert_eq!(parsed.nonce, nonce, "parsed.nonce != expected");
|
assert_eq!(parsed.nonce, nonce, "parsed.nonce != expected");
|
||||||
|
|
||||||
let len_signers = 1u8;
|
let len_signers = 1u8;
|
||||||
assert_eq!(parsed.len_signers, len_signers, "parsed.len_signers != expected");
|
assert_eq!(
|
||||||
|
parsed.len_signers, len_signers,
|
||||||
|
"parsed.len_signers != expected"
|
||||||
|
);
|
||||||
|
|
||||||
let emitter_chain = 2u16;
|
let emitter_chain = 2u16;
|
||||||
assert_eq!(parsed.emitter_chain, emitter_chain, "parsed.emitter_chain != expected");
|
assert_eq!(
|
||||||
|
parsed.emitter_chain, emitter_chain,
|
||||||
|
"parsed.emitter_chain != expected"
|
||||||
|
);
|
||||||
|
|
||||||
let emitter_address = "0001020304000000000000000000000000000000000000000000000000000000";
|
let emitter_address = "0001020304000000000000000000000000000000000000000000000000000000";
|
||||||
let emitter_address = hex::decode(emitter_address).unwrap();
|
let emitter_address = hex::decode(emitter_address).unwrap();
|
||||||
assert_eq!(parsed.emitter_address, emitter_address, "parsed.emitter_address != expected");
|
assert_eq!(
|
||||||
|
parsed.emitter_address, emitter_address,
|
||||||
|
"parsed.emitter_address != expected"
|
||||||
|
);
|
||||||
|
|
||||||
let sequence = 10u64;
|
let sequence = 10u64;
|
||||||
assert_eq!(parsed.sequence, sequence, "parsed.sequence != expected");
|
assert_eq!(parsed.sequence, sequence, "parsed.sequence != expected");
|
||||||
|
|
||||||
let consistency_level = 2u8;
|
let consistency_level = 2u8;
|
||||||
assert_eq!(parsed.consistency_level, consistency_level, "parsed.consistency_level != expected");
|
assert_eq!(
|
||||||
|
parsed.consistency_level, consistency_level,
|
||||||
|
"parsed.consistency_level != expected"
|
||||||
|
);
|
||||||
|
|
||||||
let payload = vec![97u8, 98u8, 99u8, 100u8];
|
let payload = vec![97u8, 98u8, 99u8, 100u8];
|
||||||
assert_eq!(parsed.payload, payload, "parsed.payload != expected");
|
assert_eq!(parsed.payload, payload, "parsed.payload != expected");
|
||||||
|
|
||||||
let hash = vec![
|
let hash = vec![
|
||||||
164u8, 44u8, 82u8, 103u8, 33u8, 170u8, 183u8, 178u8,
|
164u8, 44u8, 82u8, 103u8, 33u8, 170u8, 183u8, 178u8, 188u8, 204u8, 35u8, 53u8, 78u8, 148u8,
|
||||||
188u8, 204u8, 35u8, 53u8, 78u8, 148u8, 160u8, 153u8,
|
160u8, 153u8, 122u8, 252u8, 84u8, 211u8, 26u8, 204u8, 128u8, 215u8, 37u8, 232u8, 222u8,
|
||||||
122u8, 252u8, 84u8, 211u8, 26u8, 204u8, 128u8, 215u8,
|
186u8, 222u8, 186u8, 98u8, 94u8,
|
||||||
37u8, 232u8, 222u8, 186u8, 222u8, 186u8, 98u8, 94u8,
|
|
||||||
];
|
];
|
||||||
assert_eq!(parsed.hash, hash, "parsed.hash != expected");
|
assert_eq!(parsed.hash, hash, "parsed.hash != expected");
|
||||||
|
|
||||||
|
@ -106,7 +114,10 @@ fn deserialize_round_2() -> StdResult<()> {
|
||||||
assert_eq!(parsed.version, version, "parsed.version != expected");
|
assert_eq!(parsed.version, version, "parsed.version != expected");
|
||||||
|
|
||||||
let guardian_set_index = 0u32;
|
let guardian_set_index = 0u32;
|
||||||
assert_eq!(parsed.guardian_set_index, guardian_set_index, "parsed.guardian_set_index != expected");
|
assert_eq!(
|
||||||
|
parsed.guardian_set_index, guardian_set_index,
|
||||||
|
"parsed.guardian_set_index != expected"
|
||||||
|
);
|
||||||
|
|
||||||
let timestamp = 0u32;
|
let timestamp = 0u32;
|
||||||
assert_eq!(parsed.timestamp, timestamp, "parsed.timestamp != expected");
|
assert_eq!(parsed.timestamp, timestamp, "parsed.timestamp != expected");
|
||||||
|
@ -115,47 +126,49 @@ fn deserialize_round_2() -> StdResult<()> {
|
||||||
assert_eq!(parsed.nonce, nonce, "parsed.nonce != expected");
|
assert_eq!(parsed.nonce, nonce, "parsed.nonce != expected");
|
||||||
|
|
||||||
let len_signers = 1u8;
|
let len_signers = 1u8;
|
||||||
assert_eq!(parsed.len_signers, len_signers, "parsed.len_signers != expected");
|
assert_eq!(
|
||||||
|
parsed.len_signers, len_signers,
|
||||||
|
"parsed.len_signers != expected"
|
||||||
|
);
|
||||||
|
|
||||||
let emitter_chain = 1u16;
|
let emitter_chain = 1u16;
|
||||||
assert_eq!(parsed.emitter_chain, emitter_chain, "parsed.emitter_chain != expected");
|
assert_eq!(
|
||||||
|
parsed.emitter_chain, emitter_chain,
|
||||||
|
"parsed.emitter_chain != expected"
|
||||||
|
);
|
||||||
|
|
||||||
let emitter_address = "000000000000000000000000000000000000000000000000000000000000ffff";
|
let emitter_address = "000000000000000000000000000000000000000000000000000000000000ffff";
|
||||||
let emitter_address = hex::decode(emitter_address).unwrap();
|
let emitter_address = hex::decode(emitter_address).unwrap();
|
||||||
assert_eq!(parsed.emitter_address, emitter_address, "parsed.emitter_address != expected");
|
assert_eq!(
|
||||||
|
parsed.emitter_address, emitter_address,
|
||||||
|
"parsed.emitter_address != expected"
|
||||||
|
);
|
||||||
|
|
||||||
let sequence = 0u64;
|
let sequence = 0u64;
|
||||||
assert_eq!(parsed.sequence, sequence, "parsed.sequence != expected");
|
assert_eq!(parsed.sequence, sequence, "parsed.sequence != expected");
|
||||||
|
|
||||||
let consistency_level = 0u8;
|
let consistency_level = 0u8;
|
||||||
assert_eq!(parsed.consistency_level, consistency_level, "parsed.consistency_level != expected");
|
assert_eq!(
|
||||||
|
parsed.consistency_level, consistency_level,
|
||||||
|
"parsed.consistency_level != expected"
|
||||||
|
);
|
||||||
|
|
||||||
let payload = vec![
|
let payload = vec![
|
||||||
1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
||||||
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 5u8, 245u8, 225u8, 0u8, 1u8, 0u8,
|
||||||
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
||||||
0u8, 0u8, 0u8, 0u8, 0u8, 5u8, 245u8, 225u8,
|
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 117u8, 117u8, 115u8, 100u8, 0u8, 3u8, 0u8, 0u8,
|
||||||
0u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 247u8, 247u8, 221u8, 232u8, 72u8, 231u8,
|
||||||
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
69u8, 10u8, 2u8, 156u8, 208u8, 169u8, 189u8, 155u8, 218u8, 228u8, 181u8, 20u8, 125u8,
|
||||||
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
179u8, 0u8, 3u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
||||||
0u8, 0u8, 0u8, 0u8, 0u8, 117u8, 117u8, 115u8,
|
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 15u8, 66u8, 64u8,
|
||||||
100u8, 0u8, 3u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
|
||||||
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 247u8,
|
|
||||||
247u8, 221u8, 232u8, 72u8, 231u8, 69u8, 10u8, 2u8,
|
|
||||||
156u8, 208u8, 169u8, 189u8, 155u8, 218u8, 228u8, 181u8,
|
|
||||||
20u8, 125u8, 179u8, 0u8, 3u8, 0u8, 0u8, 0u8,
|
|
||||||
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
|
||||||
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
|
||||||
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
|
|
||||||
0u8, 0u8, 15u8, 66u8, 64u8,
|
|
||||||
];
|
];
|
||||||
assert_eq!(parsed.payload, payload, "parsed.payload != expected");
|
assert_eq!(parsed.payload, payload, "parsed.payload != expected");
|
||||||
|
|
||||||
let hash = vec![
|
let hash = vec![
|
||||||
114u8, 108u8, 111u8, 78u8, 204u8, 83u8, 150u8, 170u8,
|
114u8, 108u8, 111u8, 78u8, 204u8, 83u8, 150u8, 170u8, 240u8, 15u8, 193u8, 176u8, 165u8,
|
||||||
240u8, 15u8, 193u8, 176u8, 165u8, 87u8, 174u8, 230u8,
|
87u8, 174u8, 230u8, 94u8, 222u8, 106u8, 206u8, 179u8, 203u8, 193u8, 187u8, 1u8, 148u8,
|
||||||
94u8, 222u8, 106u8, 206u8, 179u8, 203u8, 193u8, 187u8,
|
17u8, 40u8, 248u8, 214u8, 147u8, 68u8,
|
||||||
1u8, 148u8, 17u8, 40u8, 248u8, 214u8, 147u8, 68u8,
|
|
||||||
];
|
];
|
||||||
assert_eq!(parsed.hash, hash, "parsed.hash != expected");
|
assert_eq!(parsed.hash, hash, "parsed.hash != expected");
|
||||||
|
|
||||||
|
@ -164,8 +177,8 @@ fn deserialize_round_2() -> StdResult<()> {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn get_address_test() -> StdResult<()> {
|
fn get_address_test() -> StdResult<()> {
|
||||||
let zeros_32: &[u8] = &[0;32];
|
let zeros_32: &[u8] = &[0; 32];
|
||||||
let zeros_20: &[u8] = &[0;20];
|
let zeros_20: &[u8] = &[0; 20];
|
||||||
assert_eq!(zeros_32.get_address(0), CanonicalAddr::from(zeros_20));
|
assert_eq!(zeros_32.get_address(0), CanonicalAddr::from(zeros_20));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -174,15 +187,14 @@ fn get_address_test() -> StdResult<()> {
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn get_address_test_panic() -> () {
|
fn get_address_test_panic() -> () {
|
||||||
// panics because of junk in first 12 bytes
|
// panics because of junk in first 12 bytes
|
||||||
let ones_32: &[u8] = &[1;32];
|
let ones_32: &[u8] = &[1; 32];
|
||||||
ones_32.get_address(0);
|
ones_32.get_address(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn get_address_test_panic_2() -> () {
|
fn get_address_test_panic_2() -> () {
|
||||||
// panics because not enough bytes (need at least 32)
|
// panics because not enough bytes (need at least 32)
|
||||||
let short_address: &[u8] = &[0;31];
|
let short_address: &[u8] = &[0; 31];
|
||||||
short_address.get_address(0);
|
short_address.get_address(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,14 @@
|
||||||
use cosmwasm_std::{
|
use cosmwasm_std::{
|
||||||
from_slice,
|
from_slice,
|
||||||
testing::{
|
testing::{mock_dependencies, mock_env, mock_info, MockApi, MockQuerier, MockStorage},
|
||||||
mock_dependencies,
|
Coin, OwnedDeps, Response, Storage,
|
||||||
mock_env,
|
|
||||||
mock_info,
|
|
||||||
MockApi,
|
|
||||||
MockQuerier,
|
|
||||||
MockStorage,
|
|
||||||
},
|
|
||||||
Coin,
|
|
||||||
OwnedDeps,
|
|
||||||
Response,
|
|
||||||
Storage,
|
|
||||||
};
|
};
|
||||||
use cosmwasm_storage::to_length_prefixed;
|
use cosmwasm_storage::to_length_prefixed;
|
||||||
|
|
||||||
use wormhole::{
|
use wormhole::{
|
||||||
contract::instantiate,
|
contract::instantiate,
|
||||||
msg::InstantiateMsg,
|
msg::InstantiateMsg,
|
||||||
state::{
|
state::{ConfigInfo, GuardianAddress, GuardianSetInfo, CONFIG_KEY},
|
||||||
ConfigInfo,
|
|
||||||
GuardianAddress,
|
|
||||||
GuardianSetInfo,
|
|
||||||
CONFIG_KEY,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use hex;
|
use hex;
|
||||||
|
@ -33,9 +18,7 @@ static GOV_ADDR: &[u8] = b"GOVERNANCE_ADDRESS";
|
||||||
|
|
||||||
fn get_config_info<S: Storage>(storage: &S) -> ConfigInfo {
|
fn get_config_info<S: Storage>(storage: &S) -> ConfigInfo {
|
||||||
let key = to_length_prefixed(CONFIG_KEY);
|
let key = to_length_prefixed(CONFIG_KEY);
|
||||||
let data = storage
|
let data = storage.get(&key).expect("data should exist");
|
||||||
.get(&key)
|
|
||||||
.expect("data should exist");
|
|
||||||
from_slice(&data).expect("invalid data")
|
from_slice(&data).expect("invalid data")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
|
# Unstable options are listed but commented out. We should re-enable them once they are stabilized.
|
||||||
|
|
||||||
# Merge similar crates together to avoid multiple use statements.
|
# Merge similar crates together to avoid multiple use statements.
|
||||||
imports_granularity = "Crate"
|
# imports_granularity = "Crate"
|
||||||
|
|
||||||
# Consistency in formatting makes tool based searching/editing better.
|
# Consistency in formatting makes tool based searching/editing better.
|
||||||
empty_item_single_line = false
|
# empty_item_single_line = false
|
||||||
|
|
||||||
# Easier editing when arbitrary mixed use statements do not collapse.
|
# Easier editing when arbitrary mixed use statements do not collapse.
|
||||||
imports_layout = "Vertical"
|
# imports_layout = "Vertical"
|
||||||
|
|
||||||
# Default rustfmt formatting of match arms with branches is awful.
|
# Default rustfmt formatting of match arms with branches is awful.
|
||||||
match_arm_leading_pipes = "Preserve"
|
match_arm_leading_pipes = "Preserve"
|
||||||
|
|
Loading…
Reference in New Issue