Files
xahaud/hook-api-examples/doubler/install.js
2022-02-18 12:43:56 +00:00

44 lines
1.2 KiB
JavaScript

if (process.argv.length < 3)
{
console.log("Usage: node accept <account family seed>")
process.exit(1);
}
require('../utils-tests.js').TestRig('ws://localhost:6005').then(t=>
{
let wasm = t.findWasm();
if (wasm.length != 1)
{
console.log("There should be exactly one .wasm file in the current working directory.")
console.log("Try make")
process.exit(1);
}
const secret = process.argv[2];
const account = t.xrpljs.Wallet.fromSeed(secret)
t.api.submit(
{
Account: account.classicAddress,
TransactionType: "SetHook",
Hooks: [
{
Hook: {
CreateCode: t.wasm(wasm[0]),
HookApiVersion: 0,
HookNamespace: "CAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE",
HookOn: "0000000000000000",
Flags: t.hsfOVERRIDE
}
}
],
Fee: "100000"
}, {wallet: account}).then(x=>
{
t.assertTxnSuccess(x)
console.log(x);
process.exit(0);
}).catch(e=>console.log(e));
}).catch(e=>console.log(e));