Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for community tickets #233

Merged
merged 6 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/client/v2/algod/sendRawTransaction.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
const assert = require('assert');

class SendRawTransaction {
constructor(c, stx_or_stxs) {
let forPosting = stx_or_stxs;
function isByteArray(array) {
return !!(array && array.byteLength !== undefined);
}
if (Array.isArray(stx_or_stxs)) {
assert(stx_or_stxs.every(isByteArray));
forPosting = Array.prototype.concat(...stx_or_stxs.map(arr => Array.from(arr)));
} else {
assert(isByteArray(forPosting));
}
this.txnBytesToPost = forPosting;
this.c = c;
Expand Down
8 changes: 8 additions & 0 deletions src/logicsig.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ class LogicSig {
this.tag = Buffer.from("Program");

assert(logic.checkProgram(program, args));
if (args) {
assert(Array.isArray(args))
function checkType(arg) {
let theType = typeof arg;
return ((theType == "string") || (theType == "number") || (arg.constructor == Uint8Array) || (Buffer.isBuffer(arg)));
}
assert(args.every(checkType))
}

this.logic = program;
this.args = args;
Expand Down
5 changes: 4 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ function signTransaction(txn, sk) {
let key = nacl.keyPairFromSecretKey(sk);
txn.from = address.encodeAddress(key.publicKey);
}
let algoTxn = new txnBuilder.Transaction(txn);
let algoTxn = txn;
if (! (txn instanceof txnBuilder.Transaction)) {
algoTxn = new txnBuilder.Transaction(txn);
}

return {"txID": algoTxn.txID().toString(), "blob": algoTxn.signTxn(sk)};
}
Expand Down