Crates.io | omni-box |
lib.rs | omni-box |
version | |
source | src |
created_at | 2024-12-10 17:32:01.832302 |
updated_at | 2024-12-12 19:21:36.01821 |
description | Multichain testing environment for developing chain abstracted applications on NEAR |
homepage | |
repository | https://github.com/near/omni-box |
max_upload_size | |
id | 1478801 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
An opinionated testing environment for chain abstracted applications.
OmniBox contains a set of utilities and encapsulates multiple test environments into a unified framework that makes developing chain abstracted applications easier than ever.
You are developing a smart contract that interacts with the MPC signer and require to propagate signed transactions to an EVM chain, Bitcoin network or NEAR.
The typical workflow would be as follows:
Since this process is common among developers, the OmniBox provides an opinionated way to develop these type of applications.
OmniBox assumes your main goal as developer is to ensure that your integration with the MPC Signer and the propagation to the destination chain works seamlessly. This is only possible by following a test driven development approach and creating integration tests since the beginning.
Note: Although the OmniBox could have automatically download them, we believe it is more secure to avoid that and ensure you install these pre requisites from trusted sources.
Add dependency
[dev_dependencies]
omni-box = "0.0.1"
or via cargo
cargo add omni-box --dev
To get started with the OmniBox, we simply create an OmniBox instance:
let omni_box = OmniBox::new().await;
The OmniBox provides high-level abstractions through contexts
, which encapsulate interactions with specific blockchains.
Each context
includes utilities and features like pre-configured accounts, transaction propagation, and more.
The Bitcoin context allows you to interact with your local Bitcoin node, where you can propagate signed transactions for testing.
// Access the btc context
let btc_context = omni_box.btc_context;
// Use pre-configured accounts
let alice_legacy = btc_context.alice_legacy;
let alice_segwit = btc_context.alice_segwit;
let bob_legacy = btc_context.bob_legacy;
let bob_segwit = btc_context.bob_segwit;
// Create custom accounts
let new_account_legacy = btc_context.create_account(AddressType.Legacy);
//or
let new account_segwit = btc_context.create_account(AddressType.Bech32);
The EVM context lets you interact with your local Anvil instance, where you can propagate signed transactions for testing.
// Access the evm context
let evm_context = omni_box.evm_context;
// Use pre-configured accounts
let alice = evm_context.alice;
let bob = evm_context.bob;
// Create custom accounts
let new_account = evm_context.create_account();
The NEAR context helps you deploy and interact with a local [Near] instance, where you can propagate signed transactions for testing.
// Access the near context
let near_context = omni_box.near_context;
// Use pre-configured accounts
let alice = near_context.alice;
let bob = near_context.bob;
// Create custom accounts
let new_account = near_context.create_account();
Since OmniBox deploys your smart contract to the NEAR testnet, it requires a deployer account. This account must be configured in a deployer.json
file located in the root of your project.
Example deployer.json
:
{
"account_id": "your-account-id.testnet",
"public_key": "your-public-key",
"private_key": "your-private-key"
}
In addition to the pre-configured contexts, OmniBox supports advanced configurations and workflows. Examples include custom RPC endpoints and dynamic account generation.
Stay tuned for more detailed examples and features in future updates.