Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

predecessor_account_id is not surfaced #125

Open
amgando opened this issue Feb 8, 2020 · 0 comments
Open

predecessor_account_id is not surfaced #125

amgando opened this issue Feb 8, 2020 · 0 comments
Assignees

Comments

@amgando
Copy link

amgando commented Feb 8, 2020

unless i'm misunderstanding something, it seems like predecessor_account_id can be easily surfaced into the context object exposed by near-runtime-ts

@external("env", "predecessor_account_id")
export function predecessor_account_id(register_id: u64) : void;

but it is not
https://github.com/nearprotocol/near-runtime-ts/blob/master/assembly/contract.ts

just happened to wonder about this specific method after reading through the Rust contract that implements the open web concept here: near/near-sdk-rs#66

pub fn post_message(&mut self, app_id: AppId, message: Message) {
    verify_app_id(&app_id);
    self.verify_app_active(&app_id);
    let mut q = self.messages.get(&app_id).unwrap_or_else(|| {
        let mut vec_id = Vec::with_capacity(app_id.len() + 4);
        vec_id.extend_from_slice(b":m:");
        vec_id.extend_from_slice(app_id.as_bytes());
        vec_id.push(b':');
        Vector::new(vec_id)
    });
    q.push(&WrappedMessage {
        sender: env::predecessor_account_id(),  /// <-- HERE it is
        message,
        time: env::block_timestamp(),
    });
    self.messages.insert(&app_id, &q);
}

if what i've written above makes sense, then more generally, it seems like we could use a test that simply checks for parity between the namespace runtime_api and some implementation in near-runtime-ts. if a matching method is not found we can at least flag it as a warning or create an issue on the repo but not sure what makes sense here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants