-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime_api.rs
More file actions
60 lines (50 loc) · 1.85 KB
/
runtime_api.rs
File metadata and controls
60 lines (50 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use crate::message::Message;
use crate::{AccountId, InvokableMessage, InvokeRequest, InvokeResponse};
use borsh::{BorshDeserialize, BorshSerialize};
pub const ACCOUNT_IDENTIFIER_PREFIX: u8 = 0;
pub const ACCOUNT_IDENTIFIER_SINGLETON_PREFIX: u8 = 1;
pub const ACCOUNT_STORAGE_PREFIX: u8 = 2;
pub const RUNTIME_ACCOUNT_ID: AccountId = AccountId::from_u64(0);
/// Storage key for consensus parameters.
/// This is a well-known key that nodes read to validate blocks during sync.
pub const CONSENSUS_PARAMS_KEY: &[u8] = b"consensus_params";
#[derive(BorshDeserialize, BorshSerialize, Clone)]
pub struct CreateAccountRequest {
pub code_id: String,
pub init_message: Message,
}
impl InvokableMessage for CreateAccountRequest {
const FUNCTION_IDENTIFIER: u64 = 1;
const FUNCTION_IDENTIFIER_NAME: &'static str = "create_account";
}
#[derive(BorshDeserialize, BorshSerialize, Clone)]
pub struct CreateAccountResponse {
pub new_account_id: AccountId,
pub init_response: Message,
}
#[derive(BorshDeserialize, BorshSerialize, Clone)]
pub struct RegisterAccountAtIdRequest {
pub account_id: AccountId,
pub code_id: String,
pub init_message: Message,
}
impl InvokableMessage for RegisterAccountAtIdRequest {
const FUNCTION_IDENTIFIER: u64 = 2;
const FUNCTION_IDENTIFIER_NAME: &'static str = "register_account_at_id";
}
#[derive(BorshDeserialize, BorshSerialize, Clone)]
pub struct RegisterAccountAtIdResponse {}
#[derive(BorshDeserialize, BorshSerialize, Clone)]
pub struct MigrateRequest {
pub account_id: AccountId,
pub new_code_id: String,
pub execute_message: InvokeRequest,
}
impl InvokableMessage for MigrateRequest {
const FUNCTION_IDENTIFIER: u64 = 3;
const FUNCTION_IDENTIFIER_NAME: &'static str = "migrate";
}
#[derive(BorshDeserialize, BorshSerialize)]
pub struct MigrateResponse {
pub migrate_response: InvokeResponse,
}