terra/contracts: rustfmt in line with solana

Change-Id: I566dc2c4504bf7014d11a6d18775c4eec896b42f
This commit is contained in:
Reisen 2021-09-06 08:27:27 +00:00 committed by David Paryente
parent 7d6db92c35
commit 50bd0355fd
12 changed files with 376 additions and 86 deletions

View File

@ -1,17 +1,57 @@
use cosmwasm_std::{ use cosmwasm_std::{
to_binary, Api, Binary, CosmosMsg, Env, Extern, HandleResponse, HumanAddr, InitResponse, to_binary,
Querier, StdError, StdResult, Storage, Uint128, WasmMsg, Api,
Binary,
CosmosMsg,
Env,
Extern,
HandleResponse,
HumanAddr,
InitResponse,
Querier,
StdError,
StdResult,
Storage,
Uint128,
WasmMsg,
}; };
use cw20_base::allowances::{ use cw20_base::{
handle_burn_from, handle_decrease_allowance, handle_increase_allowance, handle_send_from, allowances::{
handle_transfer_from, query_allowance, handle_burn_from,
handle_decrease_allowance,
handle_increase_allowance,
handle_send_from,
handle_transfer_from,
query_allowance,
},
contract::{
handle_mint,
handle_send,
handle_transfer,
query_balance,
},
state::{
token_info,
token_info_read,
MinterData,
TokenInfo,
},
}; };
use cw20_base::contract::{handle_mint, handle_send, handle_transfer, query_balance};
use cw20_base::state::{token_info, token_info_read, MinterData, TokenInfo};
use crate::msg::{HandleMsg, InitMsg, QueryMsg, WrappedAssetInfoResponse}; use crate::{
use crate::state::{wrapped_asset_info, wrapped_asset_info_read, WrappedAssetInfo}; msg::{
HandleMsg,
InitMsg,
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;
@ -164,8 +204,13 @@ pub fn query_wrapped_asset_info<S: Storage, A: Api, Q: Querier>(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use cosmwasm_std::testing::{mock_dependencies, mock_env}; use cosmwasm_std::{
use cosmwasm_std::HumanAddr; testing::{
mock_dependencies,
mock_env,
},
HumanAddr,
};
use cw20::TokenInfoResponse; use cw20::TokenInfoResponse;
const CANONICAL_LENGTH: usize = 20; const CANONICAL_LENGTH: usize = 20;

View File

@ -1,8 +1,15 @@
#![allow(clippy::field_reassign_with_default)] #![allow(clippy::field_reassign_with_default)]
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{
Deserialize,
Serialize,
};
use cosmwasm_std::{Binary, HumanAddr, Uint128}; use cosmwasm_std::{
Binary,
HumanAddr,
Uint128,
};
use cw20::Expiration; use cw20::Expiration;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]

View File

@ -1,8 +1,21 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{
Deserialize,
Serialize,
};
use cosmwasm_std::{Binary, CanonicalAddr, ReadonlyStorage, Storage}; use cosmwasm_std::{
use cosmwasm_storage::{singleton, singleton_read, ReadonlySingleton, Singleton}; Binary,
CanonicalAddr,
ReadonlyStorage,
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";

View File

@ -2,17 +2,43 @@ static WASM: &[u8] =
include_bytes!("../../../target/wasm32-unknown-unknown/release/cw20_wrapped.wasm"); include_bytes!("../../../target/wasm32-unknown-unknown/release/cw20_wrapped.wasm");
use cosmwasm_std::{ use cosmwasm_std::{
from_slice, Binary, Env, HandleResponse, HandleResult, HumanAddr, InitResponse, Uint128, from_slice,
Binary,
Env,
HandleResponse,
HandleResult,
HumanAddr,
InitResponse,
Uint128,
}; };
use cosmwasm_storage::to_length_prefixed; use cosmwasm_storage::to_length_prefixed;
use cosmwasm_vm::testing::{ use cosmwasm_vm::{
handle, init, mock_env, mock_instance, query, MockApi, MockQuerier, MockStorage, testing::{
handle,
init,
mock_env,
mock_instance,
query,
MockApi,
MockQuerier,
MockStorage,
},
Api,
Instance,
Storage,
};
use cw20_wrapped::{
msg::{
HandleMsg,
InitMsg,
QueryMsg,
},
state::{
WrappedAssetInfo,
KEY_WRAPPED_ASSET,
},
ContractError,
}; };
use cosmwasm_vm::{Api, Instance, Storage};
use cw20_wrapped::msg::{HandleMsg, InitMsg, QueryMsg};
use cw20_wrapped::state::WrappedAssetInfo;
use cw20_wrapped::state::KEY_WRAPPED_ASSET;
use cw20_wrapped::ContractError;
enum TestAddress { enum TestAddress {
INITIALIZER, INITIALIZER,

View File

@ -1,38 +1,101 @@
use crate::msg::WrappedRegistryResponse; use crate::msg::WrappedRegistryResponse;
use cosmwasm_std::{ use cosmwasm_std::{
log, to_binary, Api, Binary, CanonicalAddr, Coin, CosmosMsg, Env, Extern, HandleResponse, log,
HumanAddr, InitResponse, Querier, QueryRequest, StdError, StdResult, Storage, Uint128, WasmMsg, to_binary,
Api,
Binary,
CanonicalAddr,
Coin,
CosmosMsg,
Env,
Extern,
HandleResponse,
HumanAddr,
InitResponse,
Querier,
QueryRequest,
StdError,
StdResult,
Storage,
Uint128,
WasmMsg,
WasmQuery, WasmQuery,
}; };
use crate::msg::{HandleMsg, InitMsg, QueryMsg}; use crate::{
use crate::state::{ msg::{
bridge_contracts, bridge_contracts_read, config, config_read, receive_native, send_native, HandleMsg,
wrapped_asset, wrapped_asset_address, wrapped_asset_address_read, wrapped_asset_read, Action, InitMsg,
AssetMeta, ConfigInfo, RegisterChain, TokenBridgeMessage, TransferInfo, QueryMsg,
},
state::{
bridge_contracts,
bridge_contracts_read,
config,
config_read,
receive_native,
send_native,
wrapped_asset,
wrapped_asset_address,
wrapped_asset_address_read,
wrapped_asset_read,
Action,
AssetMeta,
ConfigInfo,
RegisterChain,
TokenBridgeMessage,
TransferInfo,
},
};
use wormhole::{
byte_utils::{
extend_address_to_32,
extend_string_to_32,
get_string_from_32,
ByteUtils,
},
error::ContractError,
}; };
use wormhole::byte_utils::{extend_address_to_32, extend_string_to_32};
use wormhole::byte_utils::{get_string_from_32, ByteUtils};
use wormhole::error::ContractError;
use cw20_base::msg::HandleMsg as TokenMsg; use cw20_base::msg::{
use cw20_base::msg::QueryMsg as TokenQuery; HandleMsg as TokenMsg,
QueryMsg as TokenQuery,
};
use wormhole::msg::HandleMsg as WormholeHandleMsg; use wormhole::msg::{
use wormhole::msg::QueryMsg as WormholeQueryMsg; HandleMsg as WormholeHandleMsg,
QueryMsg as WormholeQueryMsg,
};
use wormhole::state::{vaa_archive_add, vaa_archive_check, GovernancePacket, ParsedVAA}; use wormhole::state::{
vaa_archive_add,
vaa_archive_check,
GovernancePacket,
ParsedVAA,
};
use cw20::TokenInfoResponse; use cw20::TokenInfoResponse;
use cw20_wrapped::msg::HandleMsg as WrappedMsg; use cw20_wrapped::msg::{
use cw20_wrapped::msg::InitMsg as WrappedInit; HandleMsg as WrappedMsg,
use cw20_wrapped::msg::QueryMsg as WrappedQuery; InitHook,
use cw20_wrapped::msg::{InitHook, WrappedAssetInfoResponse}; InitMsg as WrappedInit,
use terraswap::asset::{Asset, AssetInfo}; QueryMsg as WrappedQuery,
WrappedAssetInfoResponse,
};
use terraswap::asset::{
Asset,
AssetInfo,
};
use sha3::{Digest, Keccak256}; use sha3::{
use std::cmp::{max, min}; Digest,
Keccak256,
};
use std::cmp::{
max,
min,
};
// Chain ID of Terra // Chain ID of Terra
const CHAIN_ID: u16 = 3; const CHAIN_ID: u16 = 3;
@ -673,7 +736,11 @@ fn build_asset_id(chain: u16, address: &[u8]) -> Vec<u8> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use cosmwasm_std::{to_binary, Binary, StdResult}; use cosmwasm_std::{
to_binary,
Binary,
StdResult,
};
#[test] #[test]
fn test_me() -> StdResult<()> { fn test_me() -> StdResult<()> {

View File

@ -1,6 +1,13 @@
use cosmwasm_std::{Binary, HumanAddr, Uint128}; use cosmwasm_std::{
Binary,
HumanAddr,
Uint128,
};
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{
Deserialize,
Serialize,
};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InitMsg { pub struct InitMsg {

View File

@ -1,9 +1,25 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{
Deserialize,
Serialize,
};
use cosmwasm_std::{CanonicalAddr, HumanAddr, StdError, StdResult, Storage, Uint128}; use cosmwasm_std::{
CanonicalAddr,
HumanAddr,
StdError,
StdResult,
Storage,
Uint128,
};
use cosmwasm_storage::{ use cosmwasm_storage::{
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton, bucket,
bucket_read,
singleton,
singleton_read,
Bucket,
ReadonlyBucket,
ReadonlySingleton,
Singleton, Singleton,
}; };

View File

@ -1,12 +1,36 @@
static WASM: &[u8] = include_bytes!("../../../target/wasm32-unknown-unknown/release/wormhole.wasm"); static WASM: &[u8] = include_bytes!("../../../target/wasm32-unknown-unknown/release/wormhole.wasm");
use cosmwasm_std::{from_slice, Coin, Env, HumanAddr, InitResponse}; use cosmwasm_std::{
from_slice,
Coin,
Env,
HumanAddr,
InitResponse,
};
use cosmwasm_storage::to_length_prefixed; use cosmwasm_storage::to_length_prefixed;
use cosmwasm_vm::testing::{init, mock_env, mock_instance, MockApi, MockQuerier, MockStorage}; use cosmwasm_vm::{
use cosmwasm_vm::{Api, Instance, Storage}; testing::{
init,
mock_env,
mock_instance,
MockApi,
MockQuerier,
MockStorage,
},
Api,
Instance,
Storage,
};
use wormhole::msg::InitMsg; use wormhole::{
use wormhole::state::{ConfigInfo, GuardianAddress, GuardianSetInfo, CONFIG_KEY}; msg::InitMsg,
state::{
ConfigInfo,
GuardianAddress,
GuardianSetInfo,
CONFIG_KEY,
},
};
use hex; use hex;

View File

@ -1,4 +1,8 @@
use cosmwasm_std::{CanonicalAddr, StdError, StdResult}; use cosmwasm_std::{
CanonicalAddr,
StdError,
StdResult,
};
pub trait ByteUtils { pub trait ByteUtils {
fn get_u8(&self, index: usize) -> u8; fn get_u8(&self, index: usize) -> u8;

View File

@ -1,26 +1,72 @@
use cosmwasm_std::{ use cosmwasm_std::{
has_coins, log, to_binary, Api, BankMsg, Binary, Coin, CosmosMsg, Env, Extern, HandleResponse, has_coins,
HumanAddr, InitResponse, Querier, StdError, StdResult, Storage, log,
to_binary,
Api,
BankMsg,
Binary,
Coin,
CosmosMsg,
Env,
Extern,
HandleResponse,
HumanAddr,
InitResponse,
Querier,
StdError,
StdResult,
Storage,
}; };
use crate::byte_utils::extend_address_to_32; use crate::{
use crate::byte_utils::ByteUtils; byte_utils::{
use crate::error::ContractError; extend_address_to_32,
use crate::msg::{ ByteUtils,
GetAddressHexResponse, GetStateResponse, GuardianSetInfoResponse, HandleMsg, InitMsg, QueryMsg, },
}; error::ContractError,
use crate::state::{ msg::{
config, config_read, guardian_set_get, guardian_set_set, sequence_read, sequence_set, GetAddressHexResponse,
vaa_archive_add, vaa_archive_check, ConfigInfo, GovernancePacket, GuardianAddress, GetStateResponse,
GuardianSetInfo, GuardianSetUpgrade, ParsedVAA, SetFee, TransferFee, GuardianSetInfoResponse,
HandleMsg,
InitMsg,
QueryMsg,
},
state::{
config,
config_read,
guardian_set_get,
guardian_set_set,
sequence_read,
sequence_set,
vaa_archive_add,
vaa_archive_check,
ConfigInfo,
GovernancePacket,
GuardianAddress,
GuardianSetInfo,
GuardianSetUpgrade,
ParsedVAA,
SetFee,
TransferFee,
},
}; };
use k256::ecdsa::recoverable::Id as RecoverableId; use k256::{
use k256::ecdsa::recoverable::Signature as RecoverableSignature; ecdsa::{
use k256::ecdsa::Signature; recoverable::{
use k256::ecdsa::VerifyKey; Id as RecoverableId,
use k256::EncodedPoint; Signature as RecoverableSignature,
use sha3::{Digest, Keccak256}; },
Signature,
VerifyKey,
},
EncodedPoint,
};
use sha3::{
Digest,
Keccak256,
};
use generic_array::GenericArray; use generic_array::GenericArray;
use std::convert::TryFrom; use std::convert::TryFrom;

View File

@ -1,8 +1,18 @@
use cosmwasm_std::{Binary, Coin, HumanAddr}; use cosmwasm_std::{
Binary,
Coin,
HumanAddr,
};
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{
Deserialize,
Serialize,
};
use crate::state::{GuardianAddress, GuardianSetInfo}; use crate::state::{
GuardianAddress,
GuardianSetInfo,
};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InitMsg { pub struct InitMsg {

View File

@ -1,16 +1,41 @@
use schemars::{JsonSchema, Set}; use schemars::{
use serde::{Deserialize, Serialize}; JsonSchema,
Set,
};
use serde::{
Deserialize,
Serialize,
};
use cosmwasm_std::{Binary, CanonicalAddr, Coin, HumanAddr, StdResult, Storage, Uint128}; use cosmwasm_std::{
Binary,
CanonicalAddr,
Coin,
HumanAddr,
StdResult,
Storage,
Uint128,
};
use cosmwasm_storage::{ use cosmwasm_storage::{
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton, bucket,
bucket_read,
singleton,
singleton_read,
Bucket,
ReadonlyBucket,
ReadonlySingleton,
Singleton, Singleton,
}; };
use crate::byte_utils::ByteUtils; use crate::{
use crate::error::ContractError; byte_utils::ByteUtils,
error::ContractError,
};
use sha3::{Digest, Keccak256}; use sha3::{
Digest,
Keccak256,
};
pub static CONFIG_KEY: &[u8] = b"config"; pub static CONFIG_KEY: &[u8] = b"config";
pub static GUARDIAN_SET_KEY: &[u8] = b"guardian_set"; pub static GUARDIAN_SET_KEY: &[u8] = b"guardian_set";