Skip to content

Commit

Permalink
Added rudimentary contract debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
thekevinbrown committed Jun 3, 2019
1 parent a318dba commit 8434bd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/contracts/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface ContractActionParameters {

export interface ContractActionOptions {
from?: Account;
debug?: boolean;
}

export interface ContractConstructorArgs {
Expand Down Expand Up @@ -128,7 +129,8 @@ export class Contract implements EOSJSContract {
},
],
},
eos
eos,
{ debug: options && options.debug }
);
};
}
Expand Down
8 changes: 5 additions & 3 deletions src/eosManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,18 @@ export class EOSManager {
static transact = (
transaction: any,
eos = EOSManager.api,
options = { blocksBehind: 3, expireSeconds: 30 }
options?: { debug?: boolean; blocksBehind?: number; expireSeconds?: number }
) => {
if (ConfigManager.debugTransactions) {
const flattenedOptions = Object.assign({ blocksBehind: 1, expireSeconds: 30 }, options);

if (ConfigManager.debugTransactions || flattenedOptions.debug) {
const calls = transaction.actions.map((action: any) => `${action.account}.${action.name}`);
console.log(`========== Calling ${calls.join(', ')} ==========`);
console.log('Transaction: ', JSON.stringify(transaction, null, 4));
console.log('Options: ', options);
console.log();
}

return eos.transact(transaction, options);
return eos.transact(transaction, flattenedOptions);
};
}

0 comments on commit 8434bd8

Please sign in to comment.