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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
pub mod account;
pub mod hash;
pub mod signature;
pub mod type_info;
use move_deps::{
move_core_types::{account_address::AccountAddress, identifier::Identifier},
move_vm_runtime::native_functions::{NativeFunction, NativeFunctionTable},
};
pub mod cost {
pub const APTOS_CREATE_ADDRESS: u64 = 5;
pub const APTOS_LIB_TYPE_OF: u64 = 10;
pub const APTOS_LIB_TYPE_NAME: u64 = 10;
pub const APTOS_SIP_HASH: u64 = 10;
pub const APTOS_SECP256K1_RECOVER: u64 = 71;
}
pub mod status {
pub const NFE_EXPECTED_STRUCT_TYPE_TAG: u64 = 0x1;
pub const NFE_UNABLE_TO_PARSE_ADDRESS: u64 = 0x2;
}
pub fn all_natives(framework_addr: AccountAddress) -> NativeFunctionTable {
const NATIVES: &[(&str, &str, NativeFunction)] = &[
("account", "create_address", account::native_create_address),
("account", "create_signer", account::native_create_signer),
(
"signature",
"bls12381_validate_pubkey",
signature::native_bls12381_public_key_validation,
),
(
"signature",
"ed25519_validate_pubkey",
signature::native_ed25519_publickey_validation,
),
(
"signature",
"ed25519_verify",
signature::native_ed25519_signature_verification,
),
(
"signature",
"secp256k1_recover",
signature::native_secp256k1_recover,
),
("type_info", "type_of", type_info::type_of),
("type_info", "type_name", type_info::type_name),
("hash", "sip_hash", hash::native_sip_hash),
];
NATIVES
.iter()
.cloned()
.map(|(module_name, func_name, func)| {
(
framework_addr,
Identifier::new(module_name).unwrap(),
Identifier::new(func_name).unwrap(),
func,
)
})
.collect()
}
pub fn patch_table_module(table: NativeFunctionTable) -> NativeFunctionTable {
table
.into_iter()
.map(|(m, _, f, i)| (m, Identifier::new("table").unwrap(), f, i))
.collect()
}