mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 10:35:50 +00:00
feat: add more keylet host functions (#5522)
This commit is contained in:
@@ -2263,23 +2263,11 @@ struct Escrow_test : public beast::unit_test::suite
|
||||
|
||||
// TODO: create wasm module for all host functions
|
||||
static auto wasmHex = allHostFunctionsHex;
|
||||
// let sender = get_tx_account_id();
|
||||
// let owner = get_current_escrow_account_id();
|
||||
// let dest = get_current_escrow_destination();
|
||||
// let dest_balance = get_account_balance(dest);
|
||||
// let escrow_data = get_current_escrow_data();
|
||||
// let ed_str = String::from_utf8(escrow_data).unwrap();
|
||||
// let threshold_balance = ed_str.parse::<u64>().unwrap();
|
||||
// let pl_time = host_lib::getParentLedgerTime();
|
||||
// let e_time = get_current_escrow_finish_after();
|
||||
// sender == owner && dest_balance <= threshold_balance &&
|
||||
// pl_time >= e_time
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const carol{"carol"};
|
||||
|
||||
{
|
||||
// basic FinishFunction situation
|
||||
Env env(*this);
|
||||
// create escrow
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
@@ -2350,6 +2338,81 @@ struct Escrow_test : public beast::unit_test::suite
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testKeyletHostFunctions()
|
||||
{
|
||||
testcase("Test all keylet host functions");
|
||||
|
||||
using namespace jtx;
|
||||
using namespace std::chrono;
|
||||
|
||||
// TODO: create wasm module for all host functions
|
||||
static auto wasmHex = keyletHostFunctions;
|
||||
|
||||
Account const alice{"alice"};
|
||||
Account const carol{"carol"};
|
||||
|
||||
{
|
||||
Env env(*this);
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
}
|
||||
|
||||
{
|
||||
Env env{*this};
|
||||
env.fund(XRP(5000), alice, carol);
|
||||
|
||||
BEAST_EXPECT(env.seq(alice) == 4);
|
||||
BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 0);
|
||||
|
||||
// base objects that need to be created first
|
||||
auto const tokenId =
|
||||
token::getNextID(env, alice, 0, tfTransferable);
|
||||
env(token::mint(alice, 0u), txflags(tfTransferable));
|
||||
env(trust(alice, carol["USD"](1'000'000)));
|
||||
env.close();
|
||||
BEAST_EXPECT(env.seq(alice) == 6);
|
||||
BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 2);
|
||||
|
||||
// set up a bunch of objects to check their keylets
|
||||
env(check::create(alice, carol, XRP(100)));
|
||||
env(credentials::create(alice, alice, "termsandconditions"));
|
||||
env(delegate::set(alice, carol, {"TrustSet"}));
|
||||
env(deposit::auth(alice, carol));
|
||||
env(did::set(alice), did::data("alice_did"));
|
||||
env(escrow::create(alice, carol, XRP(100)),
|
||||
escrow::finish_time(env.now() + 100s));
|
||||
env(token::createOffer(carol, tokenId, XRP(100)),
|
||||
token::owner(alice));
|
||||
env(create(alice, carol, XRP(1000), 100s, alice.pk()));
|
||||
env(signers(alice, 1, {{carol, 1}}));
|
||||
env(ticket::create(alice, 1));
|
||||
env.close();
|
||||
|
||||
BEAST_EXPECT((*env.le(alice))[sfOwnerCount] == 11);
|
||||
if (BEAST_EXPECTS(
|
||||
env.seq(alice) == 16, std::to_string(env.seq(alice))))
|
||||
{
|
||||
auto const seq = env.seq(alice);
|
||||
XRPAmount txnFees = env.current()->fees().base + 1000;
|
||||
env(escrow::create(alice, carol, XRP(1000)),
|
||||
escrow::finish_function(wasmHex),
|
||||
escrow::finish_time(env.now() + 2s),
|
||||
escrow::cancel_time(env.now() + 100s),
|
||||
fee(txnFees));
|
||||
env.close();
|
||||
env.close();
|
||||
env.close();
|
||||
|
||||
auto const allowance = 1'000'000;
|
||||
|
||||
env(escrow::finish(carol, alice, seq),
|
||||
escrow::comp_allowance(allowance),
|
||||
fee(txnFees));
|
||||
env.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testWithFeats(FeatureBitset features)
|
||||
{
|
||||
@@ -2371,6 +2434,7 @@ struct Escrow_test : public beast::unit_test::suite
|
||||
|
||||
// TODO: Update module with new host functions
|
||||
testAllHostFunctions();
|
||||
testKeyletHostFunctions();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -11756,3 +11756,244 @@ extern std::string const opcCallPerfTest =
|
||||
"84afdf0021004494b768e11b6c9b42210141d1e3c6012102024003401000"
|
||||
"200041016b220041004a0d000b0b41010f0b0b01017f1001210220020f0b"
|
||||
"0b0e01004180080b07623a2025660a00";
|
||||
|
||||
extern std::string const keyletHostFunctions =
|
||||
"0061736d01000000015b0c60057f7f7f7f7f017f60037f7f7f017f60037f7f7e017f60047f"
|
||||
"7f7f7f017f60087f7f7f7f7f7f7f7f017f60067f7f7f7f7f7f017f60077f7f7f7f7f7f7f01"
|
||||
"7f60057f7f7f7f7f006000017f60000060037f7f7f0060027f7f0002c6031108686f73745f"
|
||||
"6c6962057472616365000008686f73745f6c69621063616368655f6c65646765725f6f626a"
|
||||
"000108686f73745f6c69620974726163655f6e756d000208686f73745f6c6962146765745f"
|
||||
"6c65646765725f6f626a5f6669656c64000308686f73745f6c69621c6765745f6375727265"
|
||||
"6e745f6c65646765725f6f626a5f6669656c64000108686f73745f6c69620e6163636f756e"
|
||||
"745f6b65796c6574000308686f73745f6c69620b6c696e655f6b65796c6574000408686f73"
|
||||
"745f6c69620c636865636b5f6b65796c6574000008686f73745f6c69621163726564656e74"
|
||||
"69616c5f6b65796c6574000408686f73745f6c69620f64656c65676174655f6b65796c6574"
|
||||
"000508686f73745f6c6962166465706f7369745f707265617574685f6b65796c6574000508"
|
||||
"686f73745f6c69620a6469645f6b65796c6574000308686f73745f6c69620d657363726f77"
|
||||
"5f6b65796c6574000008686f73745f6c6962106e66745f6f666665725f6b65796c65740000"
|
||||
"08686f73745f6c69620e7061796368616e5f6b65796c6574000608686f73745f6c69620e73"
|
||||
"69676e6572735f6b65796c6574000308686f73745f6c69620d7469636b65745f6b65796c65"
|
||||
"740000030d0c0708090a0a0a0b0b0b0a0b0b05030100110619037f01418080c0000b7f0041"
|
||||
"f989c0000b7f0041808ac0000b073e05066d656d6f727902000d6f626a6563745f65786973"
|
||||
"747300110666696e69736800120a5f5f646174615f656e6403010b5f5f686561705f626173"
|
||||
"6503020a94270c9a0603017f037e037f23808080800041f0006b2205248080808000024002"
|
||||
"40024020012d00000d00200541186a200141196a290000370300200541106a200141116a29"
|
||||
"0000370300200541086a200141096a29000037030020052001290001370300200220032005"
|
||||
"412041011080808080001a20054120410010818080800022014101480d0102400240024002"
|
||||
"4020040d00418b80c08000410f428580141082808080001a200541d0006a41186a42003703"
|
||||
"00200541d0006a41106a4200370300200541d0006a41086a42003703002005420037035020"
|
||||
"0141858014200541d0006a412010838080800022014120470d01200541206a41086a200541"
|
||||
"d0006a410f6a22012900002206370300200541206a41106a200541e7006a22042900002207"
|
||||
"370300200541206a41186a200541ef006a22032d000022023a000020052005290057220837"
|
||||
"032020052f015021092005280152210a20052d0056210b2001200637000020042007370000"
|
||||
"200320023a00002005200b3a00562005200a360152200520093b015020052008370057419a"
|
||||
"80c08000410c200541d0006a412041011080808080001a0c030b418b80c08000410f2004ac"
|
||||
"1082808080001a200541e0006a4100360200200541d8006a42003703002005420037035020"
|
||||
"012004200541d0006a411410838080800022014114460d0141a680c0800041152001417f20"
|
||||
"01417f481b2201ac1082808080001a200041013a0000200020013602040c050b41a680c080"
|
||||
"0041152001417f2001417f481b2201ac1082808080001a200041013a000020002001360204"
|
||||
"0c040b200541226a20052d00523a0000200520052900573703402005200541d0006a410c6a"
|
||||
"290000370045200541206a410c6a2005290045370000200520052f01503b01202005200528"
|
||||
"005336002320052005290340370027419a80c08000410c200541206a411441011080808080"
|
||||
"001a0b20004180023b01000c020b41c280c08000411620012802042201ac1082808080001a"
|
||||
"200041013a0000200020013602040c010b41bb80c0800041072001ac1082808080001a2000"
|
||||
"41013a0000200041783602040b200541f0006a2480808080000bd21201067f238080808000"
|
||||
"4190046b220024808080800041d880c0800041234100410041001080808080001a20004180"
|
||||
"046a22014100360200200041f8036a22024200370300200042003703f00302400240024002"
|
||||
"4041818020200041f0036a411410848080800022034114470d00200041046a41026a20002d"
|
||||
"00f2033a0000200020002900f7033703502000200041f0036a410c6a220329000037005520"
|
||||
"0041046a410c6a2000290055370000200020002f01f0033b0104200020002800f303360007"
|
||||
"2000200029035037000b41fb80c08000410a200041046a411441011080808080001a200141"
|
||||
"0036020020024200370300200042003703f00341838020200041f0036a4114108480808000"
|
||||
"22014114470d01200041186a41026a20002d00f2033a0000200020002900f7033703502000"
|
||||
"2003290000370055200041186a410c6a2000290055370000200020002f01f0033b01182000"
|
||||
"20002800f30336001b2000200029035037001f418581c08000410e200041186a4114410110"
|
||||
"80808080001a20004188046a2202420037030020004180046a22034200370300200041f803"
|
||||
"6a22044200370300200042003703f003200041046a4114200041f0036a4120108580808000"
|
||||
"22014120460d02024002402001417f4a0d00200020013602300c010b2000417f3602300b41"
|
||||
"0121010c030b418080c08000410b2003417f2003417f481bac1082808080001a1093808080"
|
||||
"00000b418080c08000410b2001417f2001417f481bac1082808080001a109380808000000b"
|
||||
"200041c5006a20022903003700002000413d6a2003290300370000200041356a2004290300"
|
||||
"370000200020002903f00337002d410021010b200020013a002c200041f0036a2000412c6a"
|
||||
"419381c080004107418180201091808080000240024020002d00f0030d00024020002d00f1"
|
||||
"030d00419a81c0800041364100410041001080808080001a0c010b4100210141d081c08000"
|
||||
"41354100410041001080808080001a200041de006a41c4003a0000200041d0006a41086a41"
|
||||
"00360200200041e3006a41003a0000200041d5a6013b015c20004200370350200041003600"
|
||||
"5f20004188046a2203420037030020004180046a22044200370300200041f0036a41086a22"
|
||||
"054200370300200042003703f00302400240200041046a4114200041186a4114200041d000"
|
||||
"6a4114200041f0036a412010868080800022024120460d00024002402002417f4a0d002000"
|
||||
"20023602680c010b2000417f3602680b410121010c010b200041fd006a2003290300370000"
|
||||
"200041f5006a2004290300370000200041ed006a2005290300370000200020002903f00337"
|
||||
"00650b200020013a0064200041f0036a200041e4006a418582c08000410941001091808080"
|
||||
"0020002d00f0030d00024020002d00f1030d00418e82c08000413a41004100410010808080"
|
||||
"80001a0c010b4100210141c882c0800041394100410041001080808080001a20004188046a"
|
||||
"2203420037030020004180046a22044200370300200041f8036a2205420037030020004200"
|
||||
"3703f00302400240200041046a41144106200041f0036a412010878080800022024120460d"
|
||||
"00024002402002417f4a0d002000200236028c010c010b2000417f36028c010b410121010c"
|
||||
"010b200041a1016a200329030037000020004199016a200429030037000020004191016a20"
|
||||
"05290300370000200020002903f003370089010b200020013a008801200041f0036a200041"
|
||||
"88016a418183c0800041054181802010918080800020002d00f0030d00024020002d00f103"
|
||||
"0d00419a81c0800041364100410041001080808080001a0c010b41d081c080004135410041"
|
||||
"0041001080808080001a200041ac016a200041046a200041046a109480808000200041f003"
|
||||
"6a200041ac016a419883c08000410a4198802010918080800020002d00f0030d0002402000"
|
||||
"2d00f1030d0041a283c08000413b4100410041001080808080001a0c010b41dd83c0800041"
|
||||
"3a4100410041001080808080001a200041d0016a200041046a200041186a10958080800020"
|
||||
"0041f0036a200041d0016a419784c0800041084181802010918080800020002d00f0030d00"
|
||||
"024020002d00f1030d00419f84c0800041394100410041001080808080001a0c010b41d884"
|
||||
"c0800041384100410041001080808080001a200041f4016a200041046a200041186a109680"
|
||||
"808000200041f0036a200041f4016a419784c0800041084181802010918080800020002d00"
|
||||
"f0030d00024020002d00f1030d00419f84c0800041394100410041001080808080001a0c01"
|
||||
"0b41d884c0800041384100410041001080808080001a20004198026a200041046a10978080"
|
||||
"8000200041f0036a20004198026a419381c0800041074181802010918080800020002d00f0"
|
||||
"030d00024020002d00f1030d00419a81c0800041364100410041001080808080001a0c010b"
|
||||
"41d081c0800041354100410041001080808080001a200041bc026a200041046a1098808080"
|
||||
"00200041f0036a200041bc026a419085c0800041064181802010918080800020002d00f003"
|
||||
"0d00024020002d00f1030d00419685c0800041374100410041001080808080001a0c010b41"
|
||||
"cd85c0800041364100410041001080808080001a200041e0026a200041186a109980808000"
|
||||
"200041f0036a200041e0026a418386c08000410c4182802010918080800020002d00f0030d"
|
||||
"00024020002d00f1030d00418f86c08000413d4100410041001080808080001a0c010b41cc"
|
||||
"86c08000413c4100410041001080808080001a20004184036a200041046a200041186a109a"
|
||||
"80808000200041f0036a20004184036a418887c08000410a4181802010918080800020002d"
|
||||
"00f0030d00024020002d00f1030d00419287c08000413b4100410041001080808080001a0c"
|
||||
"010b41cd87c08000413a4100410041001080808080001a200041a8036a200041046a109b80"
|
||||
"808000200041f0036a200041a8036a418788c08000410a410010918080800020002d00f003"
|
||||
"0d00024020002d00f1030d00419188c08000413b4100410041001080808080001a0c010b41"
|
||||
"cc88c08000413a4100410041001080808080001a200041cc036a200041046a109c80808000"
|
||||
"200041f0036a200041cc036a418689c0800041064181802010918080800020002d00f0030d"
|
||||
"00024020002d00f1030d00418c89c0800041374100410041001080808080001a0c010b41c3"
|
||||
"89c0800041364100410041001080808080001a410121010c010b410021010b20004190046a"
|
||||
"24808080800020010b0300000bd10101047f23808080800041206b22032480808080002003"
|
||||
"41186a22044200370300200341106a22054200370300200341086a22064200370300200342"
|
||||
"00370300024002402001411420024114418683c08000411220034120108880808000220241"
|
||||
"20460d00024002402002417f4a0d00200020023602040c010b2000417f3602040b41012102"
|
||||
"0c010b20002003290300370001200041196a2004290300370000200041116a200529030037"
|
||||
"0000200041096a2006290300370000410021020b200020023a0000200341206a2480808080"
|
||||
"000bc90101047f23808080800041206b2203248080808000200341186a2204420037030020"
|
||||
"0341106a22054200370300200341086a220642003703002003420037030002400240200141"
|
||||
"14200241142003412010898080800022024120460d00024002402002417f4a0d0020002002"
|
||||
"3602040c010b2000417f3602040b410121020c010b20002003290300370001200041196a20"
|
||||
"04290300370000200041116a2005290300370000200041096a200629030037000041002102"
|
||||
"0b200020023a0000200341206a2480808080000bc90101047f23808080800041206b220324"
|
||||
"8080808000200341186a22044200370300200341106a22054200370300200341086a220642"
|
||||
"003703002003420037030002400240200141142002411420034120108a8080800022024120"
|
||||
"460d00024002402002417f4a0d00200020023602040c010b2000417f3602040b410121020c"
|
||||
"010b20002003290300370001200041196a2004290300370000200041116a20052903003700"
|
||||
"00200041096a2006290300370000410021020b200020023a0000200341206a248080808000"
|
||||
"0bc50101047f23808080800041206b2202248080808000200241186a220342003703002002"
|
||||
"41106a22044200370300200241086a22054200370300200242003703000240024020014114"
|
||||
"20024120108b8080800022014120460d00024002402001417f4a0d00200020013602040c01"
|
||||
"0b2000417f3602040b410121010c010b20002002290300370001200041196a200329030037"
|
||||
"0000200041116a2004290300370000200041096a2005290300370000410021010b20002001"
|
||||
"3a0000200241206a2480808080000bc70101047f23808080800041206b2202248080808000"
|
||||
"200241186a22034200370300200241106a22044200370300200241086a2205420037030020"
|
||||
"0242003703000240024020014114410b20024120108c8080800022014120460d0002400240"
|
||||
"2001417f4a0d00200020013602040c010b2000417f3602040b410121010c010b2000200229"
|
||||
"0300370001200041196a2003290300370000200041116a2004290300370000200041096a20"
|
||||
"05290300370000410021010b200020013a0000200241206a2480808080000bc70101047f23"
|
||||
"808080800041206b2202248080808000200241186a22034200370300200241106a22044200"
|
||||
"370300200241086a2205420037030020024200370300024002402001411441042002412010"
|
||||
"8d8080800022014120460d00024002402001417f4a0d00200020013602040c010b2000417f"
|
||||
"3602040b410121010c010b20002002290300370001200041196a2003290300370000200041"
|
||||
"116a2004290300370000200041096a2005290300370000410021010b200020013a00002002"
|
||||
"41206a2480808080000bcb0101047f23808080800041206b2203248080808000200341186a"
|
||||
"22044200370300200341106a22054200370300200341086a22064200370300200342003703"
|
||||
"00024002402001411420024114410c20034120108e8080800022024120460d000240024020"
|
||||
"02417f4a0d00200020023602040c010b2000417f3602040b410121020c010b200020032903"
|
||||
"00370001200041196a2004290300370000200041116a2005290300370000200041096a2006"
|
||||
"290300370000410021020b200020023a0000200341206a2480808080000bc50101047f2380"
|
||||
"8080800041206b2202248080808000200241186a22034200370300200241106a2204420037"
|
||||
"0300200241086a2205420037030020024200370300024002402001411420024120108f8080"
|
||||
"800022014120460d00024002402001417f4a0d00200020013602040c010b2000417f360204"
|
||||
"0b410121010c010b20002002290300370001200041196a2003290300370000200041116a20"
|
||||
"04290300370000200041096a2005290300370000410021010b200020013a0000200241206a"
|
||||
"2480808080000bc70101047f23808080800041206b2202248080808000200241186a220342"
|
||||
"00370300200241106a22044200370300200241086a22054200370300200242003703000240"
|
||||
"024020014114410f2002412010908080800022014120460d00024002402001417f4a0d0020"
|
||||
"0020013602040c010b2000417f3602040b410121010c010b20002002290300370001200041"
|
||||
"196a2003290300370000200041116a2004290300370000200041096a200529030037000041"
|
||||
"0021010b200020013a0000200241206a2480808080000b0b830a0100418080c0000bf90965"
|
||||
"72726f725f636f64653d47657474696e67206669656c643a204669656c6420646174613a20"
|
||||
"4572726f722067657474696e67206669656c643a204572726f723a204572726f7220676574"
|
||||
"74696e67206b65796c65743a202424242424205354415254494e47205741534d2045584543"
|
||||
"5554494f4e20242424242420204163636f756e743a202044657374696e6174696f6e3a4163"
|
||||
"636f756e742020436865636b206f626a65637420646f6573206e6f742065786973742c2061"
|
||||
"626f7274696e6720657363726f772066696e6973682e2020436865636b206f626a65637420"
|
||||
"6578697374732c2070726f63656564696e67207769746820657363726f772066696e697368"
|
||||
"2e54727573746c696e65202054727573746c696e65206f626a65637420646f6573206e6f74"
|
||||
"2065786973742c2061626f7274696e6720657363726f772066696e6973682e202054727573"
|
||||
"746c696e65206f626a656374206578697374732c2070726f63656564696e67207769746820"
|
||||
"657363726f772066696e6973682e436865636b7465726d73616e64636f6e646974696f6e73"
|
||||
"43726564656e7469616c202043726564656e7469616c206f626a65637420646f6573206e6f"
|
||||
"742065786973742c2061626f7274696e6720657363726f772066696e6973682e2020437265"
|
||||
"64656e7469616c206f626a656374206578697374732c2070726f63656564696e6720776974"
|
||||
"6820657363726f772066696e6973682e44656c6567617465202044656c6567617465206f62"
|
||||
"6a65637420646f6573206e6f742065786973742c2061626f7274696e6720657363726f7720"
|
||||
"66696e6973682e202044656c6567617465206f626a656374206578697374732c2070726f63"
|
||||
"656564696e67207769746820657363726f772066696e6973682e457363726f772020457363"
|
||||
"726f77206f626a65637420646f6573206e6f742065786973742c2061626f7274696e672065"
|
||||
"7363726f772066696e6973682e2020457363726f77206f626a656374206578697374732c20"
|
||||
"70726f63656564696e67207769746820657363726f772066696e6973682e4e46546f6b656e"
|
||||
"4f6666657220204e46546f6b656e4f66666572206f626a65637420646f6573206e6f742065"
|
||||
"786973742c2061626f7274696e6720657363726f772066696e6973682e20204e46546f6b65"
|
||||
"6e4f66666572206f626a656374206578697374732c2070726f63656564696e672077697468"
|
||||
"20657363726f772066696e6973682e5061794368616e6e656c20205061794368616e6e656c"
|
||||
"206f626a65637420646f6573206e6f742065786973742c2061626f7274696e672065736372"
|
||||
"6f772066696e6973682e20205061794368616e6e656c206f626a656374206578697374732c"
|
||||
"2070726f63656564696e67207769746820657363726f772066696e6973682e5369676e6572"
|
||||
"4c69737420205369676e65724c697374206f626a65637420646f6573206e6f742065786973"
|
||||
"742c2061626f7274696e6720657363726f772066696e6973682e20205369676e65724c6973"
|
||||
"74206f626a656374206578697374732c2070726f63656564696e6720776974682065736372"
|
||||
"6f772066696e6973682e5469636b657420205469636b6574206f626a65637420646f657320"
|
||||
"6e6f742065786973742c2061626f7274696e6720657363726f772066696e6973682e202054"
|
||||
"69636b6574206f626a656374206578697374732c2070726f63656564696e67207769746820"
|
||||
"657363726f772066696e6973682e00ad0d046e616d650014136b65796c65745f6578616d70"
|
||||
"6c652e7761736d01ef0c1d002b5f5a4e387872706c5f73746434686f737435747261636531"
|
||||
"3768356563663766653133666438643166354501375f5a4e387872706c5f73746434686f73"
|
||||
"74313663616368655f6c65646765725f6f626a313768373838623636346237363634616165"
|
||||
"3145022f5f5a4e387872706c5f73746434686f73743974726163655f6e756d313768653639"
|
||||
"3463616436386330376633386345033b5f5a4e387872706c5f73746434686f737432306765"
|
||||
"745f6c65646765725f6f626a5f6669656c6431376838373939646530383866396236356339"
|
||||
"4504435f5a4e387872706c5f73746434686f737432386765745f63757272656e745f6c6564"
|
||||
"6765725f6f626a5f6669656c64313768346239313763353864363137613961394505355f5a"
|
||||
"4e387872706c5f73746434686f737431346163636f756e745f6b65796c6574313768616233"
|
||||
"363663616435383039376261304506325f5a4e387872706c5f73746434686f737431316c69"
|
||||
"6e655f6b65796c6574313768653466386161383862646663633464664507335f5a4e387872"
|
||||
"706c5f73746434686f73743132636865636b5f6b65796c6574313768333165356538343139"
|
||||
"326131633631654508385f5a4e387872706c5f73746434686f7374313763726564656e7469"
|
||||
"616c5f6b65796c6574313768643731653739346561383463373839644509365f5a4e387872"
|
||||
"706c5f73746434686f7374313564656c65676174655f6b65796c6574313768323639663430"
|
||||
"63643739663834373237450a3d5f5a4e387872706c5f73746434686f737432326465706f73"
|
||||
"69745f707265617574685f6b65796c65743137686161306631646338616233346634623745"
|
||||
"0b315f5a4e387872706c5f73746434686f737431306469645f6b65796c6574313768313866"
|
||||
"61393935616436326331313139450c345f5a4e387872706c5f73746434686f737431336573"
|
||||
"63726f775f6b65796c657431376838373464316235373266376333326437450d375f5a4e38"
|
||||
"7872706c5f73746434686f737431366e66745f6f666665725f6b65796c6574313768663931"
|
||||
"35393838643961386466633863450e355f5a4e387872706c5f73746434686f737431347061"
|
||||
"796368616e5f6b65796c657431376862373435373234653534336539333565450f355f5a4e"
|
||||
"387872706c5f73746434686f737431347369676e6572735f6b65796c657431376866646335"
|
||||
"3536343961633961626465304510345f5a4e387872706c5f73746434686f73743133746963"
|
||||
"6b65745f6b65796c65743137683164393432633034663234386362666545110d6f626a6563"
|
||||
"745f657869737473120666696e69736813305f5a4e34636f72653970616e69636b696e6739"
|
||||
"70616e69635f666d74313768623931626164616365366565383238374514465f5a4e387872"
|
||||
"706c5f73746434636f7265357479706573376b65796c657473313763726564656e7469616c"
|
||||
"5f6b65796c6574313768353839343033303564323939613236354515445f5a4e387872706c"
|
||||
"5f73746434636f7265357479706573376b65796c657473313564656c65676174655f6b6579"
|
||||
"6c65743137686665363134666163326238656437626445164b5f5a4e387872706c5f737464"
|
||||
"34636f7265357479706573376b65796c65747332326465706f7369745f707265617574685f"
|
||||
"6b65796c65743137683634303539316533346337323839363645173f5f5a4e387872706c5f"
|
||||
"73746434636f7265357479706573376b65796c65747331306469645f6b65796c6574313768"
|
||||
"326538323337313938626638373463634518425f5a4e387872706c5f73746434636f726535"
|
||||
"7479706573376b65796c6574733133657363726f775f6b65796c6574313768363462336265"
|
||||
"663061333138383233634519455f5a4e387872706c5f73746434636f726535747970657337"
|
||||
"6b65796c65747331366e66745f6f666665725f6b65796c6574313768633833353933386361"
|
||||
"63306465646263451a435f5a4e387872706c5f73746434636f7265357479706573376b6579"
|
||||
"6c65747331347061796368616e5f6b65796c65743137683332396231633338396165343162"
|
||||
"3638451b435f5a4e387872706c5f73746434636f7265357479706573376b65796c65747331"
|
||||
"347369676e6572735f6b65796c657431376839633832313566396330386134636565451c42"
|
||||
"5f5a4e387872706c5f73746434636f7265357479706573376b65796c65747331337469636b"
|
||||
"65745f6b65796c65743137683366303138626436663561373338326645071201000f5f5f73"
|
||||
"7461636b5f706f696e746572090a0100072e726f64617461004d0970726f64756365727302"
|
||||
"086c616e6775616765010452757374000c70726f6365737365642d6279010572757374631d"
|
||||
"312e38352e31202834656231363132353020323032352d30332d31352900490f7461726765"
|
||||
"745f6665617475726573042b0a6d756c746976616c75652b0f6d757461626c652d676c6f62"
|
||||
"616c732b0f7265666572656e63652d74797065732b087369676e2d657874";
|
||||
|
||||
@@ -60,3 +60,5 @@ extern std::string const reqNonexistentField;
|
||||
extern std::string const hfPerfTest;
|
||||
|
||||
extern std::string const opcCallPerfTest;
|
||||
|
||||
extern std::string const keyletHostFunctions;
|
||||
|
||||
@@ -94,6 +94,8 @@ SuiteJournalSink::writeAlways(
|
||||
return "FTL:";
|
||||
}();
|
||||
|
||||
static std::mutex log_mutex;
|
||||
std::lock_guard lock(log_mutex);
|
||||
suite_.log << s << partition_ << text << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Keylet.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -183,6 +184,12 @@ struct HostFunctions
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
checkKeylet(AccountID const& account, std::uint32_t seq)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
credentialKeylet(
|
||||
AccountID const& subject,
|
||||
@@ -192,18 +199,78 @@ struct HostFunctions
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
didKeylet(AccountID const& account)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
delegateKeylet(AccountID const& account, AccountID const& authorize)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
depositPreauthKeylet(AccountID const& account, AccountID const& authorize)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
escrowKeylet(AccountID const& account, std::uint32_t seq)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
lineKeylet(
|
||||
AccountID const& account1,
|
||||
AccountID const& account2,
|
||||
Currency const& currency)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
nftOfferKeylet(AccountID const& account, std::uint32_t seq)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
offerKeylet(AccountID const& account, std::uint32_t seq)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
oracleKeylet(AccountID const& account, std::uint32_t docId)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
paychanKeylet(
|
||||
AccountID const& account,
|
||||
AccountID const& destination,
|
||||
std::uint32_t seq)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
signersKeylet(AccountID const& account)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
ticketKeylet(AccountID const& account, std::uint32_t seq)
|
||||
{
|
||||
return Unexpected(HostFunctionError::INTERNAL);
|
||||
}
|
||||
|
||||
virtual Expected<Bytes, HostFunctionError>
|
||||
getNFT(AccountID const& account, uint256 const& nftId)
|
||||
{
|
||||
|
||||
@@ -419,6 +419,15 @@ WasmHostFunctionsImpl::accountKeylet(AccountID const& account)
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::checkKeylet(AccountID const& account, std::uint32_t seq)
|
||||
{
|
||||
if (!account)
|
||||
return Unexpected(HostFunctionError::INVALID_ACCOUNT);
|
||||
auto const keylet = keylet::check(account, seq);
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::credentialKeylet(
|
||||
AccountID const& subject,
|
||||
@@ -437,6 +446,41 @@ WasmHostFunctionsImpl::credentialKeylet(
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::didKeylet(AccountID const& account)
|
||||
{
|
||||
if (!account)
|
||||
return Unexpected(HostFunctionError::INVALID_ACCOUNT);
|
||||
auto const keylet = keylet::did(account);
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::delegateKeylet(
|
||||
AccountID const& account,
|
||||
AccountID const& authorize)
|
||||
{
|
||||
if (!account || !authorize)
|
||||
return Unexpected(HostFunctionError::INVALID_ACCOUNT);
|
||||
if (account == authorize)
|
||||
return Unexpected(HostFunctionError::INVALID_PARAMS);
|
||||
auto const keylet = keylet::delegate(account, authorize);
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::depositPreauthKeylet(
|
||||
AccountID const& account,
|
||||
AccountID const& authorize)
|
||||
{
|
||||
if (!account || !authorize)
|
||||
return Unexpected(HostFunctionError::INVALID_ACCOUNT);
|
||||
if (account == authorize)
|
||||
return Unexpected(HostFunctionError::INVALID_PARAMS);
|
||||
auto const keylet = keylet::depositPreauth(account, authorize);
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::escrowKeylet(AccountID const& account, std::uint32_t seq)
|
||||
{
|
||||
@@ -446,6 +490,43 @@ WasmHostFunctionsImpl::escrowKeylet(AccountID const& account, std::uint32_t seq)
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::lineKeylet(
|
||||
AccountID const& account1,
|
||||
AccountID const& account2,
|
||||
Currency const& currency)
|
||||
{
|
||||
if (!account1 || !account2)
|
||||
return Unexpected(HostFunctionError::INVALID_ACCOUNT);
|
||||
if (account1 == account2)
|
||||
return Unexpected(HostFunctionError::INVALID_PARAMS);
|
||||
if (currency.isZero())
|
||||
return Unexpected(HostFunctionError::INVALID_PARAMS);
|
||||
|
||||
auto const keylet = keylet::line(account1, account2, currency);
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::nftOfferKeylet(
|
||||
AccountID const& account,
|
||||
std::uint32_t seq)
|
||||
{
|
||||
if (!account)
|
||||
return Unexpected(HostFunctionError::INVALID_ACCOUNT);
|
||||
auto const keylet = keylet::nftoffer(account, seq);
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::offerKeylet(AccountID const& account, std::uint32_t seq)
|
||||
{
|
||||
if (!account)
|
||||
return Unexpected(HostFunctionError::INVALID_ACCOUNT);
|
||||
auto const keylet = keylet::offer(account, seq);
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::oracleKeylet(
|
||||
AccountID const& account,
|
||||
@@ -457,6 +538,40 @@ WasmHostFunctionsImpl::oracleKeylet(
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::paychanKeylet(
|
||||
AccountID const& account,
|
||||
AccountID const& destination,
|
||||
std::uint32_t seq)
|
||||
{
|
||||
if (!account || !destination)
|
||||
return Unexpected(HostFunctionError::INVALID_ACCOUNT);
|
||||
if (account == destination)
|
||||
return Unexpected(HostFunctionError::INVALID_PARAMS);
|
||||
if (seq == 0)
|
||||
return Unexpected(HostFunctionError::INVALID_PARAMS);
|
||||
auto const keylet = keylet::payChan(account, destination, seq);
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::signersKeylet(AccountID const& account)
|
||||
{
|
||||
if (!account)
|
||||
return Unexpected(HostFunctionError::INVALID_ACCOUNT);
|
||||
auto const keylet = keylet::signers(account);
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::ticketKeylet(AccountID const& account, std::uint32_t seq)
|
||||
{
|
||||
if (!account)
|
||||
return Unexpected(HostFunctionError::INVALID_ACCOUNT);
|
||||
auto const keylet = keylet::ticket(account, seq);
|
||||
return Bytes{keylet.key.begin(), keylet.key.end()};
|
||||
}
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
WasmHostFunctionsImpl::getNFT(AccountID const& account, uint256 const& nftId)
|
||||
{
|
||||
|
||||
@@ -114,17 +114,55 @@ public:
|
||||
Expected<Bytes, HostFunctionError>
|
||||
accountKeylet(AccountID const& account) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
checkKeylet(AccountID const& account, std::uint32_t seq) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
credentialKeylet(
|
||||
AccountID const& subject,
|
||||
AccountID const& issuer,
|
||||
Slice const& credentialType) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
didKeylet(AccountID const& account) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
delegateKeylet(AccountID const& account, AccountID const& authorize)
|
||||
override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
depositPreauthKeylet(AccountID const& account, AccountID const& authorize)
|
||||
override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
escrowKeylet(AccountID const& account, std::uint32_t seq) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
oracleKeylet(AccountID const& account, std::uint32_t documentId) override;
|
||||
lineKeylet(
|
||||
AccountID const& account1,
|
||||
AccountID const& account2,
|
||||
Currency const& currency) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
nftOfferKeylet(AccountID const& account, std::uint32_t seq) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
offerKeylet(AccountID const& account, std::uint32_t seq) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
oracleKeylet(AccountID const& account, std::uint32_t docId) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
paychanKeylet(
|
||||
AccountID const& account,
|
||||
AccountID const& destination,
|
||||
std::uint32_t seq) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
signersKeylet(AccountID const& account) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
ticketKeylet(AccountID const& account, std::uint32_t seq) override;
|
||||
|
||||
Expected<Bytes, HostFunctionError>
|
||||
getNFT(AccountID const& account, uint256 const& nftId) override;
|
||||
|
||||
@@ -146,6 +146,17 @@ getDataAccountID(IW const* rt, wasm_val_vec_t const* params, int32_t& i)
|
||||
return AccountID::fromVoid(r->data());
|
||||
}
|
||||
|
||||
template <class IW>
|
||||
static Expected<Currency, HostFunctionError>
|
||||
getDataCurrency(IW const* rt, wasm_val_vec_t const* params, int32_t& i)
|
||||
{
|
||||
auto const r = getDataSlice(rt, params, i);
|
||||
if (!r || (r->size() != Currency::bytes))
|
||||
return Unexpected(HostFunctionError::INVALID_PARAMS);
|
||||
|
||||
return Currency::fromVoid(r->data());
|
||||
}
|
||||
|
||||
template <class IW>
|
||||
Expected<std::string_view, HostFunctionError>
|
||||
getDataString(IW const* rt, wasm_val_vec_t const* params, int32_t& i)
|
||||
@@ -642,6 +653,32 @@ accountKeylet_wrap(
|
||||
return returnResult(rt, params, results, hf->accountKeylet(*acc), index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
checkKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results)
|
||||
{
|
||||
auto* hf = reinterpret_cast<HostFunctions*>(env);
|
||||
auto const* rt = reinterpret_cast<InstanceWrapper const*>(hf->getRT());
|
||||
int index = 0;
|
||||
|
||||
auto const acc = getDataAccountID(rt, params, index);
|
||||
if (!acc)
|
||||
{
|
||||
return hfResult(results, acc.error());
|
||||
}
|
||||
|
||||
auto const seq = getDataInt32(rt, params, index);
|
||||
if (!seq)
|
||||
{
|
||||
return hfResult(results, seq.error());
|
||||
}
|
||||
|
||||
return returnResult(
|
||||
rt, params, results, hf->checkKeylet(acc.value(), *seq), index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
credentialKeylet_wrap(
|
||||
void* env,
|
||||
@@ -678,6 +715,82 @@ credentialKeylet_wrap(
|
||||
index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
delegateKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results)
|
||||
{
|
||||
auto* hf = reinterpret_cast<HostFunctions*>(env);
|
||||
auto const* rt = reinterpret_cast<InstanceWrapper const*>(hf->getRT());
|
||||
int index = 0;
|
||||
|
||||
auto const acc = getDataAccountID(rt, params, index);
|
||||
if (!acc)
|
||||
{
|
||||
return hfResult(results, acc.error());
|
||||
}
|
||||
|
||||
auto const authorize = getDataAccountID(rt, params, index);
|
||||
if (!authorize)
|
||||
{
|
||||
return hfResult(results, authorize.error());
|
||||
}
|
||||
|
||||
return returnResult(
|
||||
rt,
|
||||
params,
|
||||
results,
|
||||
hf->delegateKeylet(acc.value(), authorize.value()),
|
||||
index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
depositPreauthKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results)
|
||||
{
|
||||
auto* hf = reinterpret_cast<HostFunctions*>(env);
|
||||
auto const* rt = reinterpret_cast<InstanceWrapper const*>(hf->getRT());
|
||||
int index = 0;
|
||||
|
||||
auto const acc = getDataAccountID(rt, params, index);
|
||||
if (!acc)
|
||||
{
|
||||
return hfResult(results, acc.error());
|
||||
}
|
||||
|
||||
auto const authorize = getDataAccountID(rt, params, index);
|
||||
if (!authorize)
|
||||
{
|
||||
return hfResult(results, authorize.error());
|
||||
}
|
||||
|
||||
return returnResult(
|
||||
rt,
|
||||
params,
|
||||
results,
|
||||
hf->depositPreauthKeylet(acc.value(), authorize.value()),
|
||||
index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
didKeylet_wrap(void* env, wasm_val_vec_t const* params, wasm_val_vec_t* results)
|
||||
{
|
||||
auto* hf = reinterpret_cast<HostFunctions*>(env);
|
||||
auto const* rt = reinterpret_cast<InstanceWrapper const*>(hf->getRT());
|
||||
int index = 0;
|
||||
|
||||
auto const acc = getDataAccountID(rt, params, index);
|
||||
if (!acc)
|
||||
{
|
||||
return hfResult(results, acc.error());
|
||||
}
|
||||
|
||||
return returnResult(rt, params, results, hf->didKeylet(acc.value()), index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
escrowKeylet_wrap(
|
||||
void* env,
|
||||
@@ -705,7 +818,43 @@ escrowKeylet_wrap(
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
oracleKeylet_wrap(
|
||||
lineKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results)
|
||||
{
|
||||
auto* hf = reinterpret_cast<HostFunctions*>(env);
|
||||
auto const* rt = reinterpret_cast<InstanceWrapper const*>(hf->getRT());
|
||||
int index = 0;
|
||||
|
||||
auto const acc1 = getDataAccountID(rt, params, index);
|
||||
if (!acc1)
|
||||
{
|
||||
return hfResult(results, acc1.error());
|
||||
}
|
||||
|
||||
auto const acc2 = getDataAccountID(rt, params, index);
|
||||
if (!acc2)
|
||||
{
|
||||
return hfResult(results, acc2.error());
|
||||
}
|
||||
|
||||
auto const currency = getDataCurrency(rt, params, index);
|
||||
if (!currency)
|
||||
{
|
||||
return hfResult(results, currency.error());
|
||||
}
|
||||
|
||||
return returnResult(
|
||||
rt,
|
||||
params,
|
||||
results,
|
||||
hf->lineKeylet(acc1.value(), acc2.value(), currency.value()),
|
||||
index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
nftOfferKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results)
|
||||
@@ -725,8 +874,147 @@ oracleKeylet_wrap(
|
||||
{
|
||||
return hfResult(results, seq.error());
|
||||
}
|
||||
|
||||
return returnResult(
|
||||
rt, params, results, hf->oracleKeylet(*acc, *seq), index);
|
||||
rt,
|
||||
params,
|
||||
results,
|
||||
hf->nftOfferKeylet(acc.value(), seq.value()),
|
||||
index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
offerKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results)
|
||||
{
|
||||
auto* hf = reinterpret_cast<HostFunctions*>(env);
|
||||
auto const* rt = reinterpret_cast<InstanceWrapper const*>(hf->getRT());
|
||||
int index = 0;
|
||||
|
||||
auto const acc = getDataAccountID(rt, params, index);
|
||||
if (!acc)
|
||||
{
|
||||
return hfResult(results, acc.error());
|
||||
}
|
||||
|
||||
auto const seq = getDataInt32(rt, params, index);
|
||||
if (!seq)
|
||||
{
|
||||
return hfResult(results, seq.error());
|
||||
}
|
||||
|
||||
return returnResult(
|
||||
rt, params, results, hf->offerKeylet(acc.value(), seq.value()), index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
oracleKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results)
|
||||
{
|
||||
auto* hf = reinterpret_cast<HostFunctions*>(env);
|
||||
auto const* rt = reinterpret_cast<InstanceWrapper const*>(hf->getRT());
|
||||
int index = 0;
|
||||
|
||||
auto const acc = getDataAccountID(rt, params, index);
|
||||
if (!acc)
|
||||
{
|
||||
return hfResult(results, acc.error());
|
||||
}
|
||||
|
||||
auto const documentId = getDataInt32(rt, params, index);
|
||||
if (!documentId)
|
||||
{
|
||||
return hfResult(results, documentId.error());
|
||||
}
|
||||
return returnResult(
|
||||
rt, params, results, hf->oracleKeylet(*acc, *documentId), index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
paychanKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results)
|
||||
{
|
||||
auto* hf = reinterpret_cast<HostFunctions*>(env);
|
||||
auto const* rt = reinterpret_cast<InstanceWrapper const*>(hf->getRT());
|
||||
int index = 0;
|
||||
|
||||
auto const acc = getDataAccountID(rt, params, index);
|
||||
if (!acc)
|
||||
{
|
||||
return hfResult(results, acc.error());
|
||||
}
|
||||
|
||||
auto const dest = getDataAccountID(rt, params, index);
|
||||
if (!dest)
|
||||
{
|
||||
return hfResult(results, dest.error());
|
||||
}
|
||||
|
||||
auto const seq = getDataInt32(rt, params, index);
|
||||
if (!seq)
|
||||
{
|
||||
return hfResult(results, seq.error());
|
||||
}
|
||||
|
||||
return returnResult(
|
||||
rt,
|
||||
params,
|
||||
results,
|
||||
hf->paychanKeylet(acc.value(), dest.value(), seq.value()),
|
||||
index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
signersKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results)
|
||||
{
|
||||
auto* hf = reinterpret_cast<HostFunctions*>(env);
|
||||
auto const* rt = reinterpret_cast<InstanceWrapper const*>(hf->getRT());
|
||||
int index = 0;
|
||||
|
||||
auto const acc = getDataAccountID(rt, params, index);
|
||||
if (!acc)
|
||||
{
|
||||
return hfResult(results, acc.error());
|
||||
}
|
||||
|
||||
return returnResult(
|
||||
rt, params, results, hf->signersKeylet(acc.value()), index);
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
ticketKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results)
|
||||
{
|
||||
auto* hf = reinterpret_cast<HostFunctions*>(env);
|
||||
auto const* rt = reinterpret_cast<InstanceWrapper const*>(hf->getRT());
|
||||
int index = 0;
|
||||
|
||||
auto const acc = getDataAccountID(rt, params, index);
|
||||
if (!acc)
|
||||
{
|
||||
return hfResult(results, acc.error());
|
||||
}
|
||||
|
||||
auto const seq = getDataInt32(rt, params, index);
|
||||
if (!seq)
|
||||
{
|
||||
return hfResult(results, seq.error());
|
||||
}
|
||||
|
||||
return returnResult(
|
||||
rt, params, results, hf->ticketKeylet(acc.value(), seq.value()), index);
|
||||
;
|
||||
}
|
||||
|
||||
wasm_trap_t*
|
||||
|
||||
@@ -169,6 +169,14 @@ accountKeylet_wrap(
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using checkKeylet_proto =
|
||||
int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t);
|
||||
wasm_trap_t*
|
||||
checkKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using credentialKeylet_proto = int32_t(
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
@@ -184,6 +192,39 @@ credentialKeylet_wrap(
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using delegateKeylet_proto = int32_t(
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
uint8_t*,
|
||||
int32_t);
|
||||
wasm_trap_t*
|
||||
delegateKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using depositPreauthKeylet_proto = int32_t(
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
uint8_t*,
|
||||
int32_t);
|
||||
wasm_trap_t*
|
||||
depositPreauthKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using didKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t);
|
||||
wasm_trap_t*
|
||||
didKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using escrowKeylet_proto =
|
||||
int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t);
|
||||
wasm_trap_t*
|
||||
@@ -192,6 +233,37 @@ escrowKeylet_wrap(
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using lineKeylet_proto = int32_t(
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
uint8_t*,
|
||||
int32_t);
|
||||
wasm_trap_t*
|
||||
lineKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using nftOfferKeylet_proto =
|
||||
int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t);
|
||||
wasm_trap_t*
|
||||
nftOfferKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using offerKeylet_proto =
|
||||
int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t);
|
||||
wasm_trap_t*
|
||||
offerKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using oracleKeylet_proto =
|
||||
int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t);
|
||||
wasm_trap_t*
|
||||
@@ -200,6 +272,35 @@ oracleKeylet_wrap(
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using paychanKeylet_proto = int32_t(
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
int32_t,
|
||||
uint8_t*,
|
||||
int32_t);
|
||||
wasm_trap_t*
|
||||
paychanKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using signersKeylet_proto = int32_t(uint8_t const*, int32_t, uint8_t*, int32_t);
|
||||
wasm_trap_t*
|
||||
signersKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using ticketKeylet_proto =
|
||||
int32_t(uint8_t const*, int32_t, int32_t, uint8_t*, int32_t);
|
||||
wasm_trap_t*
|
||||
ticketKeylet_wrap(
|
||||
void* env,
|
||||
wasm_val_vec_t const* params,
|
||||
wasm_val_vec_t* results);
|
||||
|
||||
using getNFT_proto = int32_t(
|
||||
uint8_t const*,
|
||||
int32_t,
|
||||
|
||||
@@ -61,10 +61,20 @@ createWasmImport(HostFunctions* hfs)
|
||||
WASM_IMPORT_FUNC2(i, updateData, "update_data", hfs, 1000);
|
||||
WASM_IMPORT_FUNC2(i, computeSha512HalfHash, "compute_sha512_half", hfs, 2000);
|
||||
WASM_IMPORT_FUNC2(i, accountKeylet, "account_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, checkKeylet, "check_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, credentialKeylet, "credential_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, delegateKeylet, "delegate_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, depositPreauthKeylet, "deposit_preauth_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, didKeylet, "did_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, escrowKeylet, "escrow_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, lineKeylet, "line_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, nftOfferKeylet, "nft_offer_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, offerKeylet, "offer_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, oracleKeylet, "oracle_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, getNFT, "get_NFT", hfs, 1000);
|
||||
WASM_IMPORT_FUNC2(i, paychanKeylet, "paychan_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, signersKeylet, "signers_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, ticketKeylet, "ticket_keylet", hfs, 350);
|
||||
WASM_IMPORT_FUNC2(i, getNFT, "get_nft", hfs, 1000);
|
||||
WASM_IMPORT_FUNC (i, trace, hfs, 500);
|
||||
WASM_IMPORT_FUNC2(i, traceNum, "trace_num", hfs, 500);
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ EscrowCreate::preflight(PreflightContext const& ctx)
|
||||
}
|
||||
|
||||
HostFunctions mock;
|
||||
auto const re = preflightEscrowWasm(code, "finish", {}, &mock);
|
||||
auto const re = preflightEscrowWasm(code, "finish", {}, &mock, ctx.j);
|
||||
if (!isTesSuccess(re))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "EscrowCreate.FinishFunction bad WASM";
|
||||
|
||||
Reference in New Issue
Block a user