Skip to content

Commit

Permalink
refactor!: simplify transaction schema
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Transaction schemas doesn't contain tag anymore
Use `OBJECT_ID_TX_TYPE` to find tag by transaction type.
  • Loading branch information
davidyuk committed May 19, 2022
1 parent a083c7b commit 5f720ec
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 116 deletions.
5 changes: 3 additions & 2 deletions src/tx/builder/index.js
Expand Up @@ -406,7 +406,8 @@ export function buildTx (
type,
{ excludeKeys = [], prefix = 'tx', vsn = VSN, denomination = AE_AMOUNT_FORMATS.AETTOS } = {}
) {
const [schema, tag] = getSchema({ type, vsn })
const schema = getSchema({ type, vsn })
const tag = Object.entries(OBJECT_ID_TX_TYPE).find(([, t]) => t === type)[0]
const binary = buildRawTx(
{ ...params, VSN: vsn, tag },
schema,
Expand Down Expand Up @@ -438,7 +439,7 @@ export function unpackTx (encodedTx, fromRlpBinary = false, prefix = 'tx') {

const objId = readInt(binary[0])
const vsn = readInt(binary[1])
const [schema] = getSchema({ objId, vsn })
const schema = getSchema({ objId, vsn })

return { txType: OBJECT_ID_TX_TYPE[objId], tx: unpackRawTx(binary, schema), rlpEncoded, binary }
}
Expand Down

0 comments on commit 5f720ec

Please sign in to comment.