cosmwasm: accounting: Drop dependency on the tokenbridge contract
Now that the accounting contract can handle chain registrations on its own, there's no need to query the tokenbridge contract. Remove references to it from `InstantiateMsg` and the internal state.
This commit is contained in:
parent
9a559f3fbd
commit
acc3ec14d8
|
@ -30,10 +30,7 @@ use crate::{
|
|||
AllTransfersResponse, ChainRegistrationResponse, ExecuteMsg, Instantiate, InstantiateMsg,
|
||||
MigrateMsg, Observation, QueryMsg, Upgrade,
|
||||
},
|
||||
state::{
|
||||
self, Data, PendingTransfer, CHAIN_REGISTRATIONS, GOVERNANCE_VAAS, PENDING_TRANSFERS,
|
||||
TOKENBRIDGE_ADDR,
|
||||
},
|
||||
state::{self, Data, PendingTransfer, CHAIN_REGISTRATIONS, GOVERNANCE_VAAS, PENDING_TRANSFERS},
|
||||
};
|
||||
|
||||
// version info for migration info
|
||||
|
@ -65,15 +62,6 @@ pub fn instantiate(
|
|||
let init: Instantiate =
|
||||
from_binary(&msg.instantiate).context("failed to parse `Instantiate` message")?;
|
||||
|
||||
let tokenbridge_addr = deps
|
||||
.api
|
||||
.addr_validate(&init.tokenbridge_addr)
|
||||
.context("failed to validate tokenbridge address")?;
|
||||
|
||||
TOKENBRIDGE_ADDR
|
||||
.save(deps.storage, &tokenbridge_addr)
|
||||
.context("failed to save tokenbridge address")?;
|
||||
|
||||
let event =
|
||||
accounting::instantiate(deps, init.into()).context("failed to instantiate accounting")?;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ use crate::state::{self, PendingTransfer};
|
|||
|
||||
#[cw_serde]
|
||||
pub struct Instantiate {
|
||||
pub tokenbridge_addr: String,
|
||||
pub accounts: Vec<Account>,
|
||||
pub transfers: Vec<Transfer>,
|
||||
pub modifications: Vec<Modification>,
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
use accounting::state::transfer;
|
||||
use cosmwasm_schema::cw_serde;
|
||||
use cosmwasm_std::{Addr, Binary};
|
||||
use cw_storage_plus::{Item, Map};
|
||||
use cosmwasm_std::Binary;
|
||||
use cw_storage_plus::Map;
|
||||
use thiserror::Error;
|
||||
use tinyvec::TinyVec;
|
||||
use wormhole::vaa::Signature;
|
||||
|
||||
use crate::msg::Observation;
|
||||
|
||||
pub const TOKENBRIDGE_ADDR: Item<Addr> = Item::new("tokenbride_addr");
|
||||
pub const PENDING_TRANSFERS: Map<transfer::Key, TinyVec<[Data; 2]>> = Map::new("pending_transfers");
|
||||
pub const CHAIN_REGISTRATIONS: Map<u16, Binary> = Map::new("chain_registrations");
|
||||
pub const GOVERNANCE_VAAS: Map<Vec<u8>, ()> = Map::new("governance_vaas");
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
use cosmwasm_std::{
|
||||
to_binary, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdError, StdResult,
|
||||
};
|
||||
use tokenbridge::msg::{ChainRegistrationResponse, QueryMsg};
|
||||
|
||||
pub fn instantiate(_: DepsMut, _: Env, _: MessageInfo, _: Empty) -> StdResult<Response> {
|
||||
Ok(Response::new())
|
||||
}
|
||||
|
||||
pub fn execute(_: DepsMut, _: Env, _: MessageInfo, _: Empty) -> StdResult<Response> {
|
||||
Err(StdError::GenericErr {
|
||||
msg: "execute not implemented".into(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn query(_: Deps, _: Env, msg: QueryMsg) -> StdResult<Binary> {
|
||||
match msg {
|
||||
QueryMsg::ChainRegistration { chain } => to_binary(&ChainRegistrationResponse {
|
||||
address: vec![chain as u8; 32].into(),
|
||||
}),
|
||||
_ => Err(StdError::GenericErr {
|
||||
msg: "unimplemented query message".into(),
|
||||
}),
|
||||
}
|
||||
}
|
|
@ -23,8 +23,6 @@ use wormhole::{
|
|||
};
|
||||
use wormhole_bindings::{fake, WormholeQuery};
|
||||
|
||||
mod fake_tokenbridge;
|
||||
|
||||
pub struct Contract {
|
||||
addr: Addr,
|
||||
app: FakeApp,
|
||||
|
@ -260,32 +258,13 @@ pub fn proper_instantiate(
|
|||
let wh = fake::WormholeKeeper::new();
|
||||
let mut app = fake_app(wh.clone());
|
||||
|
||||
let tokenbridge_id = app.store_code(Box::new(ContractWrapper::new_with_empty(
|
||||
fake_tokenbridge::execute,
|
||||
fake_tokenbridge::instantiate,
|
||||
fake_tokenbridge::query,
|
||||
)));
|
||||
|
||||
let accounting_id = app.store_code(Box::new(ContractWrapper::new(
|
||||
wormchain_accounting::contract::execute,
|
||||
wormchain_accounting::contract::instantiate,
|
||||
wormchain_accounting::contract::query,
|
||||
)));
|
||||
|
||||
let tokenbridge_addr = app
|
||||
.instantiate_contract(
|
||||
tokenbridge_id,
|
||||
Addr::unchecked(ADMIN),
|
||||
&Empty {},
|
||||
&[],
|
||||
"tokenbridge",
|
||||
None,
|
||||
)
|
||||
.unwrap()
|
||||
.into();
|
||||
|
||||
let instantiate = to_binary(&Instantiate {
|
||||
tokenbridge_addr,
|
||||
accounts,
|
||||
transfers,
|
||||
modifications,
|
||||
|
@ -323,7 +302,7 @@ pub fn proper_instantiate(
|
|||
&msg,
|
||||
&[],
|
||||
"accounting",
|
||||
Some("contract1".into()),
|
||||
Some("contract0".into()),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
Loading…
Reference in New Issue