Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further fixes to transaction type handling
Minimizer is overly aggressive and renames all proto constructors to have same name.
- Loading branch information
Showing
1 changed file
with
11 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
const protos = require('./protos'); | ||
|
||
const TRANSACTION_FIELD_MAP = { | ||
[protos.CreateAccountTransaction.name]: 'createAccount', | ||
[protos.DeployContractTransaction.name]: 'deployContract', | ||
[protos.FunctionCallTransaction.name]: 'functionCall', | ||
[protos.SendMoneyTransaction.name]: 'sendMoney', | ||
[protos.StakeTransaction.name]: 'stake', | ||
[protos.SwapKeyTransaction.name]: 'swapKey', | ||
[protos.AddKeyTransaction.name]: 'addKey', | ||
[protos.DeleteKeyTransaction.name]: 'deleteKey', | ||
}; | ||
const TRANSACTION_FIELD_MAP = new Map([ | ||
[protos.CreateAccountTransaction, 'createAccount'], | ||
[protos.DeployContractTransaction, 'deployContract'], | ||
[protos.FunctionCallTransaction, 'functionCall'], | ||
[protos.SendMoneyTransaction, 'sendMoney'], | ||
[protos.StakeTransaction, 'stake'], | ||
[protos.SwapKeyTransaction, 'swapKey'], | ||
[protos.AddKeyTransaction, 'addKey'], | ||
[protos.DeleteKeyTransaction, 'deleteKey'], | ||
]); | ||
|
||
module.exports.getTransactionFieldName = (transactionProto) => TRANSACTION_FIELD_MAP[transactionProto.constructor.name]; | ||
module.exports.getTransactionFieldName = (transactionProto) => TRANSACTION_FIELD_MAP.get(transactionProto.constructor); |