Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mock): receiver id on receipt to be AccountId #529

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `promise_batch_action_function_call`, `Promise::function_call`, `promise_batch_action_add_key_with_function_call`, `Promise::add_access_key`, and `Promise::add_access_key_with_nonce` are afffected.
- Instead of `b"method_name"` just use `"method_name"`, the bytes are enforced to be utf8 in the runtime.
- Fixes `#[ext_contract]` codegen function signatures to take an `AccountId` instead of a generic `ToString` and converting unchecked to `AccountId`. [PR 518](https://github.com/near/near-sdk-rs/pull/518)
- Fixes `receiver_id` in `mock::Receipt` to `AccountId` from string. This is a change to the type added in `4.0.0-pre.1`. [PR 529](https://github.com/near/near-sdk-rs/pull/529)

## `4.0.0-pre.1` [07-23-2021]
* Implements new `LazyOption` type under `unstable` feature. Similar to `Lazy` but is optional to set a value. [PR 444](https://github.com/near/near-sdk-rs/pull/444).
Expand Down
6 changes: 5 additions & 1 deletion near-sdk/src/environment/mock/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ impl External for SdkExternal {
return Err(HostError::InvalidReceiptIndex { receipt_index: *index }.into());
}
let res = self.receipts.len() as u64;
self.receipts.push(Receipt { receipt_indices, receiver_id, actions: vec![] });
self.receipts.push(Receipt {
receipt_indices,
receiver_id: AccountId::new_unchecked(receiver_id),
actions: vec![],
});
Ok(res)
}

Expand Down
6 changes: 1 addition & 5 deletions near-sdk/src/environment/mock/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{AccountId, Balance, Gas, PublicKey};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Receipt {
pub receipt_indices: Vec<u64>,
pub receiver_id: String,
pub receiver_id: AccountId,
pub actions: Vec<VmAction>,
}

Expand All @@ -16,10 +16,6 @@ pub enum VmAction {
},
FunctionCall {
method_name: Vec<u8>,
/// Most function calls still take JSON as input, so we'll keep it there as a string.
/// Once we switch to borsh, we'll have to switch to base64 encoding.
/// Right now, it is only used with standalone runtime when passing in Receipts or expecting
/// receipts. The workaround for input is to use a VMContext input.
args: Vec<u8>,
gas: Gas,
deposit: Balance,
Expand Down