Skip to content

Commit

Permalink
CT-256 - renaming txbase64 to txhex in algo
Browse files Browse the repository at this point in the history
  • Loading branch information
twtaylorbitgo committed Jul 10, 2019
1 parent bc37816 commit 399148b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions modules/core/src/v2/coins/algo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface SignTransactionOptions {
}

export interface TransactionPrebuild {
txBase64: string;
txHex: string;
txInfo: {
from: string;
to: string;
Expand All @@ -54,7 +54,7 @@ export interface TransactionPrebuild {

export interface HalfSignedTransaction {
halfSigned: {
txBase64: string,
txHex: string,
}
}

Expand All @@ -70,7 +70,7 @@ export interface TransactionFee {
}

export interface ExplainTransactionOptions {
txBase64: string;
txHex: string;
wallet: {
addressVersion: string;
}
Expand Down Expand Up @@ -203,14 +203,14 @@ export class Algo extends BaseCoin {
/**
* Explain/parse transaction
* @param params
* - txBase64: transaction encoded as base64 string
* - txHex: transaction encoded as base64 string
*/
explainTransaction(params: ExplainTransactionOptions): TransactionExplanation {
const { txBase64 } = params;
const { txHex } = params;

let tx;
try {
const txToHex = Buffer.from(txBase64, 'base64');
const txToHex = Buffer.from(txHex, 'base64');
const decodedTx = Encoding.decode(txToHex);

// if we are a signed msig tx, the structure actually has the { msig, txn } as the root object
Expand All @@ -220,7 +220,7 @@ export class Algo extends BaseCoin {

tx = Multisig.MultiSigTransaction.from_obj_for_encoding(txnForDecoding);
} catch (ex) {
throw new Error('txBase64 needs to be a valid tx encoded as base64 string');
throw new Error('txHex needs to be a valid tx encoded as base64 string');
}

const id = tx.txID();
Expand Down Expand Up @@ -258,15 +258,15 @@ export class Algo extends BaseCoin {
*/
signTransaction(params: SignTransactionOptions): HalfSignedTransaction {
const prv = params.prv;
const txBase64 = params.txPrebuild.txBase64;
const txHex = params.txPrebuild.txHex;
const addressVersion = params.wallet.addressVersion;

if (_.isUndefined(txBase64)) {
if (_.isUndefined(txHex)) {
throw new Error('missing txPrebuild parameter');
}

if (!_.isString(txBase64)) {
throw new Error(`txPrebuild must be an object, got type ${typeof txBase64}`);
if (!_.isString(txHex)) {
throw new Error(`txPrebuild must be an object, got type ${typeof txHex}`);
}

if (_.isUndefined(prv)) {
Expand Down Expand Up @@ -300,7 +300,7 @@ export class Algo extends BaseCoin {
// decode our tx
let transaction;
try {
const txToHex = Buffer.from(txBase64, 'base64');
const txToHex = Buffer.from(txHex, 'base64');
const decodedTx = Encoding.decode(txToHex);
transaction = Multisig.MultiSigTransaction.from_obj_for_encoding(decodedTx);
} catch (e) {
Expand All @@ -317,7 +317,7 @@ export class Algo extends BaseCoin {

return {
halfSigned: {
txBase64: signedBase64,
txHex: signedBase64,
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions modules/core/test/v2/unit/coins/algo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ describe('ALGO:', function() {
it('should sign a prebuild', co(function *() {
// sign transaction
halfSignedTransaction = yield wallet.signTransaction({
txPrebuild: { txBase64: fixtures.buildTxBase64 },
txPrebuild: { txHex: fixtures.buildTxBase64 },
prv: fixtures.userKeychain.prv,
keychain: fixtures.userKeychain,
backupKeychain: fixtures.backupKeychain,
bitgoKeychain: fixtures.bitgoKeychain,
wallet: { addressVersion: fixtures.walletData.coinSpecific.addressVersion }
});

halfSignedTransaction.halfSigned.txBase64.should.equal(fixtures.signedTxBase64);
halfSignedTransaction.halfSigned.txHex.should.equal(fixtures.signedTxBase64);
}));
});
});

0 comments on commit 399148b

Please sign in to comment.