Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions crates/e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,14 @@ impl NearBlockchain {
```

`DeployedContract` wraps the contract's account ID plus its own `near-kit`
client. It exposes `call` (from the contract account), `call_from`/
`call_from_with_deposit` (from an arbitrary `NearKitCaller`), `view`, and
`state()` (parsed `ProtocolContractState`).
client. It exposes `call` (from the contract account, used only for `init`),
`contract_handle` (a typed `MpcContractHandle` calling as a given
`NearKitCaller`), `view`, and `state()` (parsed `ProtocolContractState`).

`NearKitCaller` binds a signer to a non-contract account (nodes voting, users
submitting sign requests) and implements the `CallContract` transport trait,
so typed calls can go through `MpcContractHandle`.
so typed calls go through `MpcContractHandle` — the single source of each
method's wire format, gas, and deposit.

### 3. `MpcNode` / `MpcNodeSetup` — node process manager

Expand Down
69 changes: 0 additions & 69 deletions crates/e2e-tests/src/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,75 +155,6 @@ impl DeployedContract {
.map_err(|e| anyhow::anyhow!("contract call `{method}` failed: {e}"))
}

pub async fn call_from(
&self,
client: &NearKitCaller,
method: &str,
args: serde_json::Value,
) -> anyhow::Result<FinalExecutionOutcome> {
client
.inner
.call(&self.contract_id, method)
.args(args)
.gas(MAX_GAS)
.send()
.await
.map_err(|e| anyhow::anyhow!("contract call `{method}` (external signer) failed: {e}"))
}

pub async fn call_from_with_deposit(
&self,
client: &NearKitCaller,
method: &str,
args: serde_json::Value,
gas: near_kit::Gas,
deposit: near_kit::NearToken,
) -> anyhow::Result<FinalExecutionOutcome> {
client
.inner
.call(&self.contract_id, method)
.args(args)
.gas(gas)
.deposit(deposit)
.send()
.await
.map_err(|e| anyhow::anyhow!("contract call `{method}` (with deposit) failed: {e}"))
}

/// Like [`Self::call_from`], but with an attached `deposit`.
pub async fn call_from_deposit(
&self,
client: &NearKitCaller,
method: &str,
args: serde_json::Value,
deposit: near_kit::NearToken,
) -> anyhow::Result<FinalExecutionOutcome> {
self.call_from_with_deposit(client, method, args, MAX_GAS, deposit)
.await
}

/// Call a method whose arguments are borsh-serialized (e.g. `propose_update`).
pub async fn call_from_borsh_with_deposit<A: borsh::BorshSerialize>(
&self,
client: &NearKitCaller,
method: &str,
args: A,
gas: near_kit::Gas,
deposit: near_kit::NearToken,
) -> anyhow::Result<FinalExecutionOutcome> {
client
.inner
.call(&self.contract_id, method)
.args_borsh(args)
.gas(gas)
.deposit(deposit)
.send()
.await
.map_err(|e| {
anyhow::anyhow!("contract call `{method}` (borsh args, with deposit) failed: {e}")
})
}

pub async fn view<T: DeserializeOwned + Send + 'static>(
&self,
method: &str,
Expand Down
Loading
Loading