|
34 | 34 |
|
35 | 35 | namespace ripple { |
36 | 36 |
|
| 37 | +static void |
| 38 | +setCommonHostFunctions(HostFunctions* hfs, std::vector<WasmImportFunc>& i) |
| 39 | +{ |
| 40 | + // clang-format off |
| 41 | + WASM_IMPORT_FUNC2(i, getLedgerSqn, "get_ledger_sqn", hfs, 60); |
| 42 | + WASM_IMPORT_FUNC2(i, getParentLedgerTime, "get_parent_ledger_time", hfs, 60); |
| 43 | + WASM_IMPORT_FUNC2(i, getParentLedgerHash, "get_parent_ledger_hash", hfs, 60); |
| 44 | + WASM_IMPORT_FUNC2(i, getLedgerAccountHash, "get_ledger_account_hash", hfs, 60); |
| 45 | + WASM_IMPORT_FUNC2(i, getLedgerTransactionHash, "get_ledger_tx_hash", hfs, 60); |
| 46 | + WASM_IMPORT_FUNC2(i, getBaseFee, "get_base_fee", hfs, 60); |
| 47 | + WASM_IMPORT_FUNC2(i, isAmendmentEnabled, "amendment_enabled", hfs, 60); |
| 48 | + WASM_IMPORT_FUNC2(i, cacheLedgerObj, "cache_ledger_obj", hfs, 5000); |
| 49 | + WASM_IMPORT_FUNC2(i, getTxField, "get_tx_field", hfs, 70); |
| 50 | + WASM_IMPORT_FUNC2(i, getCurrentLedgerObjField, "get_current_ledger_obj_field", hfs, 70); |
| 51 | + WASM_IMPORT_FUNC2(i, getLedgerObjField, "get_ledger_obj_field", hfs, 70); |
| 52 | + WASM_IMPORT_FUNC2(i, getTxNestedField, "get_tx_nested_field", hfs, 110); |
| 53 | + WASM_IMPORT_FUNC2(i, getCurrentLedgerObjNestedField, "get_current_ledger_obj_nested_field", hfs, 110); |
| 54 | + WASM_IMPORT_FUNC2(i, getLedgerObjNestedField, "get_ledger_obj_nested_field", hfs, 110); |
| 55 | + WASM_IMPORT_FUNC2(i, getTxArrayLen, "get_tx_array_len", hfs, 40); |
| 56 | + WASM_IMPORT_FUNC2(i, getCurrentLedgerObjArrayLen, "get_current_ledger_obj_array_len", hfs, 40); |
| 57 | + WASM_IMPORT_FUNC2(i, getLedgerObjArrayLen, "get_ledger_obj_array_len", hfs, 40); |
| 58 | + WASM_IMPORT_FUNC2(i, getTxNestedArrayLen, "get_tx_nested_array_len", hfs, 70); |
| 59 | + WASM_IMPORT_FUNC2(i, getCurrentLedgerObjNestedArrayLen, "get_current_ledger_obj_nested_array_len", hfs, 70); |
| 60 | + WASM_IMPORT_FUNC2(i, getLedgerObjNestedArrayLen, "get_ledger_obj_nested_array_len", hfs, 70); |
| 61 | + WASM_IMPORT_FUNC2(i, updateData, "update_data", hfs, 1000); |
| 62 | + WASM_IMPORT_FUNC2(i, checkSignature, "check_sig", hfs, 2000); |
| 63 | + WASM_IMPORT_FUNC2(i, computeSha512HalfHash, "compute_sha512_half", hfs, 2000); |
| 64 | + WASM_IMPORT_FUNC2(i, accountKeylet, "account_keylet", hfs, 350); |
| 65 | + WASM_IMPORT_FUNC2(i, checkKeylet, "check_keylet", hfs, 350); |
| 66 | + WASM_IMPORT_FUNC2(i, credentialKeylet, "credential_keylet", hfs, 350); |
| 67 | + WASM_IMPORT_FUNC2(i, delegateKeylet, "delegate_keylet", hfs, 350); |
| 68 | + WASM_IMPORT_FUNC2(i, depositPreauthKeylet, "deposit_preauth_keylet", hfs, 350); |
| 69 | + WASM_IMPORT_FUNC2(i, didKeylet, "did_keylet", hfs, 350); |
| 70 | + WASM_IMPORT_FUNC2(i, escrowKeylet, "escrow_keylet", hfs, 350); |
| 71 | + WASM_IMPORT_FUNC2(i, lineKeylet, "line_keylet", hfs, 350); |
| 72 | + WASM_IMPORT_FUNC2(i, nftOfferKeylet, "nft_offer_keylet", hfs, 350); |
| 73 | + WASM_IMPORT_FUNC2(i, offerKeylet, "offer_keylet", hfs, 350); |
| 74 | + WASM_IMPORT_FUNC2(i, oracleKeylet, "oracle_keylet", hfs, 350); |
| 75 | + WASM_IMPORT_FUNC2(i, paychanKeylet, "paychan_keylet", hfs, 350); |
| 76 | + WASM_IMPORT_FUNC2(i, signersKeylet, "signers_keylet", hfs, 350); |
| 77 | + WASM_IMPORT_FUNC2(i, ticketKeylet, "ticket_keylet", hfs, 350); |
| 78 | + WASM_IMPORT_FUNC2(i, getNFT, "get_nft", hfs, 1000); |
| 79 | + WASM_IMPORT_FUNC2(i, getNFTIssuer, "get_nft_issuer", hfs, 60); |
| 80 | + WASM_IMPORT_FUNC2(i, getNFTTaxon, "get_nft_taxon", hfs, 60); |
| 81 | + WASM_IMPORT_FUNC2(i, getNFTFlags, "get_nft_flags", hfs, 60); |
| 82 | + WASM_IMPORT_FUNC2(i, getNFTTransferFee, "get_nft_transfer_fee", hfs, 60); |
| 83 | + WASM_IMPORT_FUNC2(i, getNFTSerial, "get_nft_serial", hfs, 60); |
| 84 | + WASM_IMPORT_FUNC (i, trace, hfs, 500); |
| 85 | + WASM_IMPORT_FUNC2(i, traceNum, "trace_num", hfs, 500); |
| 86 | + WASM_IMPORT_FUNC2(i, traceFloat, "trace_opaque_float", hfs, 500); |
| 87 | + |
| 88 | + WASM_IMPORT_FUNC2(i, floatFromInt, "float_from_int", hfs, 1000); |
| 89 | + WASM_IMPORT_FUNC2(i, floatFromUint, "float_from_uint", hfs, 1000); |
| 90 | + WASM_IMPORT_FUNC2(i, floatSet, "float_set", hfs, 1000); |
| 91 | + WASM_IMPORT_FUNC2(i, floatCompare, "float_compare", hfs, 1000); |
| 92 | + WASM_IMPORT_FUNC2(i, floatAdd, "float_add", hfs, 1000); |
| 93 | + WASM_IMPORT_FUNC2(i, floatSubtract, "float_subtract", hfs, 1000); |
| 94 | + WASM_IMPORT_FUNC2(i, floatMultiply, "float_multiply", hfs, 1000); |
| 95 | + WASM_IMPORT_FUNC2(i, floatDivide, "float_divide", hfs, 1000); |
| 96 | + WASM_IMPORT_FUNC2(i, floatRoot, "float_root", hfs, 1000); |
| 97 | + WASM_IMPORT_FUNC2(i, floatPower, "float_pow", hfs, 1000); |
| 98 | + WASM_IMPORT_FUNC2(i, floatLog, "float_log", hfs, 1000); |
| 99 | + // clang-format on |
| 100 | +} |
| 101 | + |
37 | 102 | std::vector<WasmImportFunc> |
38 | 103 | createWasmImport(HostFunctions* hfs) |
39 | 104 | { |
40 | 105 | std::vector<WasmImportFunc> i; |
41 | 106 |
|
42 | 107 | if (hfs) |
43 | 108 | { |
44 | | - // clang-format off |
45 | | - |
46 | | - WASM_IMPORT_FUNC2(i, getLedgerSqn, "get_ledger_sqn", hfs, 60); |
47 | | - WASM_IMPORT_FUNC2(i, getParentLedgerTime, "get_parent_ledger_time", hfs, 60); |
48 | | - WASM_IMPORT_FUNC2(i, getParentLedgerHash, "get_parent_ledger_hash", hfs, 60); |
49 | | - WASM_IMPORT_FUNC2(i, getLedgerAccountHash, "get_ledger_account_hash", hfs, 60); |
50 | | - WASM_IMPORT_FUNC2(i, getLedgerTransactionHash, "get_ledger_tx_hash", hfs, 60); |
51 | | - WASM_IMPORT_FUNC2(i, getBaseFee, "get_base_fee", hfs, 60); |
52 | | - WASM_IMPORT_FUNC2(i, isAmendmentEnabled, "amendment_enabled", hfs, 60); |
53 | | - WASM_IMPORT_FUNC2(i, cacheLedgerObj, "cache_ledger_obj", hfs, 5000); |
54 | | - WASM_IMPORT_FUNC2(i, getTxField, "get_tx_field", hfs, 70); |
55 | | - WASM_IMPORT_FUNC2(i, getCurrentLedgerObjField, "get_current_ledger_obj_field", hfs, 70); |
56 | | - WASM_IMPORT_FUNC2(i, getLedgerObjField, "get_ledger_obj_field", hfs, 70); |
57 | | - WASM_IMPORT_FUNC2(i, getTxNestedField, "get_tx_nested_field", hfs, 110); |
58 | | - WASM_IMPORT_FUNC2(i, getCurrentLedgerObjNestedField, "get_current_ledger_obj_nested_field", hfs, 110); |
59 | | - WASM_IMPORT_FUNC2(i, getLedgerObjNestedField, "get_ledger_obj_nested_field", hfs, 110); |
60 | | - WASM_IMPORT_FUNC2(i, getTxArrayLen, "get_tx_array_len", hfs, 40); |
61 | | - WASM_IMPORT_FUNC2(i, getCurrentLedgerObjArrayLen, "get_current_ledger_obj_array_len", hfs, 40); |
62 | | - WASM_IMPORT_FUNC2(i, getLedgerObjArrayLen, "get_ledger_obj_array_len", hfs, 40); |
63 | | - WASM_IMPORT_FUNC2(i, getTxNestedArrayLen, "get_tx_nested_array_len", hfs, 70); |
64 | | - WASM_IMPORT_FUNC2(i, getCurrentLedgerObjNestedArrayLen, "get_current_ledger_obj_nested_array_len", hfs, 70); |
65 | | - WASM_IMPORT_FUNC2(i, getLedgerObjNestedArrayLen, "get_ledger_obj_nested_array_len", hfs, 70); |
66 | | - WASM_IMPORT_FUNC2(i, updateData, "update_data", hfs, 1000); |
67 | | - WASM_IMPORT_FUNC2(i, checkSignature, "check_sig", hfs, 2000); |
68 | | - WASM_IMPORT_FUNC2(i, computeSha512HalfHash, "compute_sha512_half", hfs, 2000); |
69 | | - WASM_IMPORT_FUNC2(i, accountKeylet, "account_keylet", hfs, 350); |
70 | | - WASM_IMPORT_FUNC2(i, checkKeylet, "check_keylet", hfs, 350); |
71 | | - WASM_IMPORT_FUNC2(i, credentialKeylet, "credential_keylet", hfs, 350); |
72 | | - WASM_IMPORT_FUNC2(i, delegateKeylet, "delegate_keylet", hfs, 350); |
73 | | - WASM_IMPORT_FUNC2(i, depositPreauthKeylet, "deposit_preauth_keylet", hfs, 350); |
74 | | - WASM_IMPORT_FUNC2(i, didKeylet, "did_keylet", hfs, 350); |
75 | | - WASM_IMPORT_FUNC2(i, escrowKeylet, "escrow_keylet", hfs, 350); |
76 | | - WASM_IMPORT_FUNC2(i, lineKeylet, "line_keylet", hfs, 350); |
77 | | - WASM_IMPORT_FUNC2(i, nftOfferKeylet, "nft_offer_keylet", hfs, 350); |
78 | | - WASM_IMPORT_FUNC2(i, offerKeylet, "offer_keylet", hfs, 350); |
79 | | - WASM_IMPORT_FUNC2(i, oracleKeylet, "oracle_keylet", hfs, 350); |
80 | | - WASM_IMPORT_FUNC2(i, paychanKeylet, "paychan_keylet", hfs, 350); |
81 | | - WASM_IMPORT_FUNC2(i, signersKeylet, "signers_keylet", hfs, 350); |
82 | | - WASM_IMPORT_FUNC2(i, ticketKeylet, "ticket_keylet", hfs, 350); |
83 | | - WASM_IMPORT_FUNC2(i, getNFT, "get_nft", hfs, 1000); |
84 | | - WASM_IMPORT_FUNC2(i, getNFTIssuer, "get_nft_issuer", hfs, 60); |
85 | | - WASM_IMPORT_FUNC2(i, getNFTTaxon, "get_nft_taxon", hfs, 60); |
86 | | - WASM_IMPORT_FUNC2(i, getNFTFlags, "get_nft_flags", hfs, 60); |
87 | | - WASM_IMPORT_FUNC2(i, getNFTTransferFee, "get_nft_transfer_fee", hfs, 60); |
88 | | - WASM_IMPORT_FUNC2(i, getNFTSerial, "get_nft_serial", hfs, 60); |
89 | | - WASM_IMPORT_FUNC (i, trace, hfs, 500); |
90 | | - WASM_IMPORT_FUNC2(i, traceNum, "trace_num", hfs, 500); |
91 | | - WASM_IMPORT_FUNC2(i, traceFloat, "trace_opaque_float", hfs, 500); |
92 | | - |
93 | | - WASM_IMPORT_FUNC2(i, floatFromInt, "float_from_int", hfs, 1000); |
94 | | - WASM_IMPORT_FUNC2(i, floatFromUint, "float_from_uint", hfs, 1000); |
95 | | - WASM_IMPORT_FUNC2(i, floatSet, "float_set", hfs, 1000); |
96 | | - WASM_IMPORT_FUNC2(i, floatCompare, "float_compare", hfs, 1000); |
97 | | - WASM_IMPORT_FUNC2(i, floatAdd, "float_add", hfs, 1000); |
98 | | - WASM_IMPORT_FUNC2(i, floatSubtract, "float_subtract", hfs, 1000); |
99 | | - WASM_IMPORT_FUNC2(i, floatMultiply, "float_multiply", hfs, 1000); |
100 | | - WASM_IMPORT_FUNC2(i, floatDivide, "float_divide", hfs, 1000); |
101 | | - WASM_IMPORT_FUNC2(i, floatRoot, "float_root", hfs, 1000); |
102 | | - WASM_IMPORT_FUNC2(i, floatPower, "float_pow", hfs, 1000); |
103 | | - WASM_IMPORT_FUNC2(i, floatLog, "float_log", hfs, 1000); |
104 | | - |
105 | | - // clang-format on |
| 109 | + setCommonHostFunctions(hfs, i); |
| 110 | + WASM_IMPORT_FUNC2(i, updateData, "update_data", hfs, 1000); |
106 | 111 | } |
107 | 112 |
|
108 | 113 | return i; |
|
0 commit comments