cosmwasm: Rename accounting -> accountant
Also change wormchain -> global.
This commit is contained in:
parent
1f939ea2dd
commit
dd95954fc3
|
@ -3,7 +3,7 @@
|
|||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "accounting"
|
||||
name = "accountant"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
|
@ -926,6 +926,32 @@ version = "0.26.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d"
|
||||
|
||||
[[package]]
|
||||
name = "global-accountant"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"accountant",
|
||||
"anyhow",
|
||||
"base64",
|
||||
"cosmwasm-schema",
|
||||
"cosmwasm-std",
|
||||
"cosmwasm-storage",
|
||||
"cw-multi-test",
|
||||
"cw-storage-plus",
|
||||
"cw2",
|
||||
"cw_transcode",
|
||||
"hex",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde-json-wasm",
|
||||
"serde_wormhole",
|
||||
"thiserror",
|
||||
"tinyvec",
|
||||
"token-bridge-terra-2",
|
||||
"wormhole-bindings",
|
||||
"wormhole-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "group"
|
||||
version = "0.10.0"
|
||||
|
@ -2247,32 +2273,6 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "wormchain-accounting"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"accounting",
|
||||
"anyhow",
|
||||
"base64",
|
||||
"cosmwasm-schema",
|
||||
"cosmwasm-std",
|
||||
"cosmwasm-storage",
|
||||
"cw-multi-test",
|
||||
"cw-storage-plus",
|
||||
"cw2",
|
||||
"cw_transcode",
|
||||
"hex",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde-json-wasm",
|
||||
"serde_wormhole",
|
||||
"thiserror",
|
||||
"tinyvec",
|
||||
"token-bridge-terra-2",
|
||||
"wormhole-bindings",
|
||||
"wormhole-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wormhole-bindings"
|
||||
version = "0.1.0"
|
||||
|
|
|
@ -6,8 +6,8 @@ members = [
|
|||
"contracts/token-bridge",
|
||||
"contracts/shutdown-token-bridge",
|
||||
"contracts/mock-bridge-integration",
|
||||
"packages/accounting",
|
||||
"contracts/wormchain-accounting",
|
||||
"packages/accountant",
|
||||
"contracts/global-accountant",
|
||||
"packages/wormhole-bindings",
|
||||
"packages/cw_transcode",
|
||||
]
|
||||
|
@ -28,12 +28,12 @@ incremental = false
|
|||
overflow-checks = true
|
||||
|
||||
[patch.crates-io]
|
||||
accounting = { path = "packages/accounting" }
|
||||
accountant = { path = "packages/accountant" }
|
||||
cw_transcode = { path = "packages/cw_transcode" }
|
||||
cw20-wrapped-2 = { path = "contracts/cw20-wrapped" }
|
||||
serde_wormhole = { path = "../sdk/rust/serde_wormhole" }
|
||||
token-bridge-terra-2 = { path = "contracts/token-bridge" }
|
||||
wormchain-accounting = { path = "contracts/wormchain-accounting" }
|
||||
global-accountant = { path = "contracts/global-accountant" }
|
||||
wormhole-bindings = { path = "packages/wormhole-bindings" }
|
||||
wormhole-bridge-terra-2 = { path = "contracts/wormhole" }
|
||||
wormhole-core = { path = "../sdk/rust/core" }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "wormchain-accounting"
|
||||
name = "global-accountant"
|
||||
version = "0.1.0"
|
||||
authors = ["Wormhole Project Contributors"]
|
||||
edition = "2021"
|
||||
|
@ -13,7 +13,7 @@ backtraces = ["cosmwasm-std/backtraces"]
|
|||
library = []
|
||||
|
||||
[dependencies]
|
||||
accounting = "0.1.0"
|
||||
accountant = "0.1.0"
|
||||
anyhow = "1"
|
||||
base64 = "0.13"
|
||||
cosmwasm-schema = "1"
|
|
@ -1,7 +1,7 @@
|
|||
use cosmwasm_schema::write_api;
|
||||
|
||||
use cosmwasm_std::Empty;
|
||||
use wormchain_accounting::msg::{ExecuteMsg, QueryMsg};
|
||||
use global_accountant::msg::{ExecuteMsg, QueryMsg};
|
||||
|
||||
fn main() {
|
||||
write_api! {
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"contract_name": "wormchain-accounting",
|
||||
"contract_name": "global-accountant",
|
||||
"contract_version": "0.1.0",
|
||||
"idl_version": "1.0.0",
|
||||
"instantiate": {
|
|
@ -1,6 +1,6 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use accounting::{
|
||||
use accountant::{
|
||||
query_balance, query_modification,
|
||||
state::{account, transfer, Modification, TokenAddress, Transfer},
|
||||
validate_transfer,
|
||||
|
@ -37,7 +37,7 @@ use crate::{
|
|||
};
|
||||
|
||||
// version info for migration info
|
||||
const CONTRACT_NAME: &str = "crates.io:wormchain-accounting";
|
||||
const CONTRACT_NAME: &str = "crates.io:global-accountant";
|
||||
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
#[cfg_attr(not(feature = "library"), entry_point)]
|
||||
|
@ -241,7 +241,7 @@ fn handle_observation(
|
|||
"unknown emitter address"
|
||||
);
|
||||
|
||||
accounting::commit_transfer(
|
||||
accountant::commit_transfer(
|
||||
deps.branch(),
|
||||
Transfer {
|
||||
key: tx_key,
|
||||
|
@ -287,7 +287,7 @@ fn modify_balance(
|
|||
let msg: Modification = from_binary(&modification).context("failed to parse `Modification`")?;
|
||||
|
||||
let event =
|
||||
accounting::modify_balance(deps, msg).context("failed to modify account balance")?;
|
||||
accountant::modify_balance(deps, msg).context("failed to modify account balance")?;
|
||||
|
||||
Ok(Response::new()
|
||||
.add_attribute("action", "modify_balance")
|
||||
|
@ -471,7 +471,7 @@ fn handle_tokenbridge_vaa(
|
|||
key: key.clone(),
|
||||
data,
|
||||
};
|
||||
let evt = accounting::commit_transfer(deps.branch(), tx)
|
||||
let evt = accountant::commit_transfer(deps.branch(), tx)
|
||||
.with_context(|| format!("failed to commit transfer for key {key}"))?;
|
||||
|
||||
PENDING_TRANSFERS.remove(deps.storage, key);
|
||||
|
@ -532,12 +532,12 @@ fn query_all_accounts(
|
|||
let l = lim
|
||||
.try_into()
|
||||
.map_err(|_| ConversionOverflowError::new("u32", "usize", lim.to_string()))?;
|
||||
accounting::query_all_accounts(deps, start_after)
|
||||
accountant::query_all_accounts(deps, start_after)
|
||||
.take(l)
|
||||
.collect::<StdResult<Vec<_>>>()
|
||||
.map(|accounts| AllAccountsResponse { accounts })
|
||||
} else {
|
||||
accounting::query_all_accounts(deps, start_after)
|
||||
accountant::query_all_accounts(deps, start_after)
|
||||
.collect::<StdResult<Vec<_>>>()
|
||||
.map(|accounts| AllAccountsResponse { accounts })
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ fn query_all_transfers(
|
|||
let l = lim
|
||||
.try_into()
|
||||
.map_err(|_| ConversionOverflowError::new("u32", "usize", lim.to_string()))?;
|
||||
accounting::query_all_transfers(deps, start_after)
|
||||
accountant::query_all_transfers(deps, start_after)
|
||||
.map(|res| {
|
||||
res.and_then(|t| {
|
||||
let digest = DIGESTS.load(
|
||||
|
@ -571,7 +571,7 @@ fn query_all_transfers(
|
|||
.collect::<StdResult<Vec<_>>>()
|
||||
.map(|transfers| AllTransfersResponse { transfers })
|
||||
} else {
|
||||
accounting::query_all_transfers(deps, start_after)
|
||||
accountant::query_all_transfers(deps, start_after)
|
||||
.map(|res| {
|
||||
res.and_then(|t| {
|
||||
let digest = DIGESTS.load(
|
||||
|
@ -637,12 +637,12 @@ fn query_all_modifications(
|
|||
let l = lim
|
||||
.try_into()
|
||||
.map_err(|_| ConversionOverflowError::new("u32", "usize", lim.to_string()))?;
|
||||
accounting::query_all_modifications(deps, start_after)
|
||||
accountant::query_all_modifications(deps, start_after)
|
||||
.take(l)
|
||||
.collect::<StdResult<Vec<_>>>()
|
||||
.map(|modifications| AllModificationsResponse { modifications })
|
||||
} else {
|
||||
accounting::query_all_modifications(deps, start_after)
|
||||
accountant::query_all_modifications(deps, start_after)
|
||||
.collect::<StdResult<Vec<_>>>()
|
||||
.map(|modifications| AllModificationsResponse { modifications })
|
||||
}
|
||||
|
@ -690,7 +690,7 @@ fn query_transfer_status(
|
|||
key.sequence(),
|
||||
),
|
||||
)? {
|
||||
let data = accounting::query_transfer(deps, key.clone())?;
|
||||
let data = accountant::query_transfer(deps, key.clone())?;
|
||||
Ok(TransferStatus::Committed { data, digest })
|
||||
} else if let Some(data) = PENDING_TRANSFERS.may_load(deps.storage, key.clone())? {
|
||||
Ok(TransferStatus::Pending(tinyvec_to_vec(data)))
|
|
@ -1,4 +1,4 @@
|
|||
use accounting::state::{account, transfer, Account, Modification, Transfer};
|
||||
use accountant::state::{account, transfer, Account, Modification, Transfer};
|
||||
use cosmwasm_schema::{cw_serde, QueryResponses};
|
||||
use cosmwasm_std::Binary;
|
||||
use serde_wormhole::RawMessage;
|
|
@ -1,4 +1,4 @@
|
|||
use accounting::state::transfer;
|
||||
use accountant::state::transfer;
|
||||
use cosmwasm_schema::cw_serde;
|
||||
use cosmwasm_std::Binary;
|
||||
use cw_storage_plus::Map;
|
|
@ -1,8 +1,8 @@
|
|||
mod helpers;
|
||||
|
||||
use cosmwasm_std::{to_binary, Event};
|
||||
use global_accountant::msg::ChainRegistrationResponse;
|
||||
use helpers::*;
|
||||
use wormchain_accounting::msg::ChainRegistrationResponse;
|
||||
use wormhole::{
|
||||
token::{Action, GovernancePacket},
|
||||
vaa::Body,
|
|
@ -1,6 +1,6 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use accounting::state::{account, transfer, Modification};
|
||||
use accountant::state::{account, transfer, Modification};
|
||||
use cosmwasm_schema::cw_serde;
|
||||
use cosmwasm_std::{
|
||||
testing::{MockApi, MockStorage},
|
||||
|
@ -9,8 +9,7 @@ use cosmwasm_std::{
|
|||
use cw_multi_test::{
|
||||
App, AppBuilder, AppResponse, BankKeeper, ContractWrapper, Executor, WasmKeeper,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use wormchain_accounting::{
|
||||
use global_accountant::{
|
||||
msg::{
|
||||
AllAccountsResponse, AllModificationsResponse, AllPendingTransfersResponse,
|
||||
AllTransfersResponse, BatchTransferStatusResponse, ChainRegistrationResponse, ExecuteMsg,
|
||||
|
@ -18,6 +17,7 @@ use wormchain_accounting::{
|
|||
},
|
||||
state,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use wormhole::{
|
||||
token::{Action, GovernancePacket},
|
||||
vaa::{Body, Header, Signature},
|
||||
|
@ -253,10 +253,10 @@ pub fn proper_instantiate() -> (fake::WormholeKeeper, Contract) {
|
|||
let wh = fake::WormholeKeeper::new();
|
||||
let mut app = fake_app(wh.clone());
|
||||
|
||||
let accounting_id = app.store_code(Box::new(ContractWrapper::new(
|
||||
wormchain_accounting::contract::execute,
|
||||
wormchain_accounting::contract::instantiate,
|
||||
wormchain_accounting::contract::query,
|
||||
let accountant_id = app.store_code(Box::new(ContractWrapper::new(
|
||||
global_accountant::contract::execute,
|
||||
global_accountant::contract::instantiate,
|
||||
global_accountant::contract::query,
|
||||
)));
|
||||
|
||||
// We want the contract to be able to upgrade itself, which means we have to set the contract
|
||||
|
@ -278,11 +278,11 @@ pub fn proper_instantiate() -> (fake::WormholeKeeper, Contract) {
|
|||
// can't use it here. Maybe something to bring up with upstream.
|
||||
let addr = app
|
||||
.instantiate_contract(
|
||||
accounting_id,
|
||||
accountant_id,
|
||||
Addr::unchecked(ADMIN),
|
||||
&Empty {},
|
||||
&[],
|
||||
"accounting",
|
||||
"accountant",
|
||||
Some("contract0".into()),
|
||||
)
|
||||
.unwrap();
|
|
@ -1,9 +1,9 @@
|
|||
mod helpers;
|
||||
|
||||
use accounting::state::transfer;
|
||||
use accountant::state::transfer;
|
||||
use cosmwasm_std::{to_binary, Uint256};
|
||||
use global_accountant::msg::Observation;
|
||||
use helpers::*;
|
||||
use wormchain_accounting::msg::Observation;
|
||||
use wormhole::{token::Message, Address, Amount, Chain};
|
||||
|
||||
fn create_observation() -> Observation {
|
|
@ -1,6 +1,6 @@
|
|||
mod helpers;
|
||||
|
||||
use accounting::state::{account, Kind, Modification};
|
||||
use accountant::state::{account, Kind, Modification};
|
||||
use cosmwasm_std::{to_binary, Event, Uint256};
|
||||
use helpers::*;
|
||||
|
|
@ -2,13 +2,13 @@ mod helpers;
|
|||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use accounting::state::{
|
||||
use accountant::state::{
|
||||
account::{self, Balance},
|
||||
transfer, Kind, Modification, Transfer,
|
||||
};
|
||||
use cosmwasm_std::{to_binary, Uint256};
|
||||
use global_accountant::msg::TransferStatus;
|
||||
use helpers::*;
|
||||
use wormchain_accounting::msg::TransferStatus;
|
||||
use wormhole::{token::Message, vaa::Body, Address, Amount};
|
||||
use wormhole_bindings::fake;
|
||||
|
|
@ -2,11 +2,11 @@ mod helpers;
|
|||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use accounting::state::{account, transfer, Kind, Modification, TokenAddress};
|
||||
use accountant::state::{account, transfer, Kind, Modification, TokenAddress};
|
||||
use cosmwasm_std::{from_binary, to_binary, Binary, Event, Uint256};
|
||||
use cw_multi_test::AppResponse;
|
||||
use global_accountant::msg::{Observation, ObservationStatus, SubmitObservationResponse};
|
||||
use helpers::*;
|
||||
use wormchain_accounting::msg::{Observation, ObservationStatus, SubmitObservationResponse};
|
||||
use wormhole::{
|
||||
token::Message,
|
||||
vaa::{Body, Header},
|
|
@ -1,10 +1,10 @@
|
|||
mod helpers;
|
||||
|
||||
use accounting::state::{transfer, TokenAddress};
|
||||
use accountant::state::{transfer, TokenAddress};
|
||||
use cosmwasm_std::{from_binary, to_binary, Binary, Event, Uint256};
|
||||
use global_accountant::msg::{Observation, ObservationStatus, SubmitObservationResponse};
|
||||
use helpers::*;
|
||||
use serde_wormhole::RawMessage;
|
||||
use wormchain_accounting::msg::{Observation, ObservationStatus, SubmitObservationResponse};
|
||||
use wormhole::{
|
||||
token::Message,
|
||||
vaa::{Body, Header, Vaa},
|
|
@ -5,8 +5,8 @@ use cosmwasm_std::{
|
|||
to_binary, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Response, StdResult,
|
||||
};
|
||||
use cw_multi_test::ContractWrapper;
|
||||
use global_accountant::msg::Upgrade;
|
||||
use helpers::*;
|
||||
use wormchain_accounting::msg::Upgrade;
|
||||
use wormhole_bindings::WormholeQuery;
|
||||
|
||||
pub fn instantiate(
|
|
@ -22,7 +22,7 @@ const artifacts = [
|
|||
"mock_bridge_integration_2.wasm",
|
||||
"shutdown_core_bridge_cosmwasm.wasm",
|
||||
"shutdown_token_bridge_cosmwasm.wasm",
|
||||
"wormchain_accounting.wasm",
|
||||
"global_accountant.wasm",
|
||||
];
|
||||
|
||||
/* Check that the artifact folder contains all the wasm files we expect and nothing else */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "accounting"
|
||||
name = "accountant"
|
||||
version = "0.1.0"
|
||||
authors = ["Wormhole Project Contributors"]
|
||||
edition = "2021"
|
|
@ -13,7 +13,7 @@ use crate::{
|
|||
},
|
||||
};
|
||||
|
||||
/// Instantiate the on-chain state for accounting. Unlike other methods in this crate,
|
||||
/// Instantiate the on-chain state for accountant. Unlike other methods in this crate,
|
||||
/// `instantiate` does not perform any validation of the data in `init`.
|
||||
pub fn instantiate<C: CustomQuery>(deps: DepsMut<C>, init: Instantiate) -> anyhow::Result<Event> {
|
||||
let num_accounts = init.accounts.len();
|
||||
|
@ -72,7 +72,7 @@ pub fn validate_transfer<C: CustomQuery>(deps: Deps<C>, t: &Transfer) -> anyhow:
|
|||
///
|
||||
/// ```
|
||||
/// # fn example() -> anyhow::Result<()> {
|
||||
/// # use accounting::{
|
||||
/// # use accountant::{
|
||||
/// # commit_transfer,
|
||||
/// # state::{transfer, Transfer},
|
||||
/// # TransferError,
|
||||
|
@ -201,7 +201,7 @@ pub enum ModifyBalanceError {
|
|||
///
|
||||
/// ```
|
||||
/// # fn example() {
|
||||
/// # use accounting::{
|
||||
/// # use accountant::{
|
||||
/// # modify_balance,
|
||||
/// # state::{Kind, Modification},
|
||||
/// # ModifyBalanceError,
|
||||
|
@ -405,7 +405,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn instantiate_accounting() {
|
||||
fn instantiate_accountant() {
|
||||
let mut deps = mock_dependencies();
|
||||
let count = 3;
|
||||
let msg = Instantiate {
|
|
@ -12,9 +12,9 @@ pub use account::Account;
|
|||
pub use addr::TokenAddress;
|
||||
pub use transfer::Transfer;
|
||||
|
||||
pub const ACCOUNTS: Map<account::Key, account::Balance> = Map::new("accounting/accounts");
|
||||
pub const ACCOUNTS: Map<account::Key, account::Balance> = Map::new("accountant/accounts");
|
||||
|
||||
pub const TRANSFERS: Map<transfer::Key, transfer::Data> = Map::new("accounting/transfers");
|
||||
pub const TRANSFERS: Map<transfer::Key, transfer::Data> = Map::new("accountant/transfers");
|
||||
|
||||
#[cw_serde]
|
||||
#[derive(Eq, PartialOrd, Ord)]
|
||||
|
@ -52,4 +52,4 @@ pub struct Modification {
|
|||
pub reason: String,
|
||||
}
|
||||
|
||||
pub const MODIFICATIONS: Map<u64, Modification> = Map::new("accounting/modifications");
|
||||
pub const MODIFICATIONS: Map<u64, Modification> = Map::new("accountant/modifications");
|
Loading…
Reference in New Issue