@open-rights-exchange/orejs
Version:
Orejs is a Javascript helper library to provide simple high-level access to the ore-protocol. Orejs uses eosJS as a wrapper to the EOS blockchain.
82 lines • 3.14 kB
JavaScript
;
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
var eosjs_1 = require("eosjs");
var compose_1 = require("./compose");
var errors_1 = require("./errors");
var args = { authAccountName: 'abc', authPermission: 'authPerm', permission: 'perm' };
var myAction = compose_1.composeAction(compose_1.ChainAction.Account_DeleteAuth, args);
console.log(JSON.stringify(myAction));
var error1 = {
code: 3080004,
name: 'tx_cpu_usage_exceeded',
what: 'Transaction exceeded the current CPU usage limit imposed on the transaction',
details: [
{
message: 'billed CPU time (4062 us) is greater than the maximum billable CPU time for the transaction (1543 us)',
file: 'transaction_context.cpp',
line_number: 553,
method: 'validate_cpu_usage_to_bill'
}
]
};
var error2 = {
code: 3080004,
name: 'Unlink the authority first',
what: 'Cannot delete a linked authority. Unlink the authority first. This authority is linked to',
details: [
{
message: 'billed CPU time (4062 us) is greater than the maximum billable CPU time for the transaction (1543 us)',
file: 'eosio_contract.cpp',
line_number: 553,
method: 'apply_eosio_deleteauth'
}
]
};
var testError = new eosjs_1.RpcError(error2);
var mappedError = errors_1.mapError(testError);
if (mappedError.name === 'PermissionDeleteFailedInUse')
console.log('yay');
console.log('mapped error:', JSON.parse(mappedError.message));
try {
var response = chain.sendTransaction.apply(chain, __spread([endodedTransaction], ));
}
catch (error) {
if (error.name === 'PermissionDeleteFailedInUse') {
chainErrorData = tryParseJson(error.message);
// specific error handler for this error
}
else {
// generic error handler
}
}
// error.message will parse into a JSON object of info with details of the chain error
// for EOS, this is the RPCError.json and looks like this
// { code: 3080004, name: '1', what: '2', details: '3' },
// 'Unlink the authority first',
// 'Cannot delete a linked authority. Unlink the authority first. This authority is linked to',
// [ '4' ],
// { message: '5', file: '6', line_number: 553, method: '7' },
// 'billed CPU time (4062 us) is greater than the maximum billable CPU time for the transaction (1543 us)',
// 'eosio_contract.cpp',
// 'apply_eosio_deleteauth'
//# sourceMappingURL=test.js.map