-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recalculate auxiliary data hash when transforming tx
- Loading branch information
1 parent
b45786f
commit c5018a7
Showing
8 changed files
with
116 additions
and
6 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 |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
"typescript": "^4.4.3" | ||
}, | ||
"dependencies": { | ||
"blake2b": "^2.1.4", | ||
"cbor": "^8.1.0" | ||
}, | ||
"bugs": { | ||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'blake2b' |
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
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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as cbor from 'cbor' | ||
|
||
import { toFixlenBuffer } from '../../test_utils' | ||
|
||
export const CanonicalAuxiliaryData = { | ||
// 259({0: {721: {"ipfs": "some other text", "assetHash": "0931ae2de9aa46212e50adc1798f9071e7c6368b78ae7eb434c2ca0ed9d05370"}}}) | ||
data: cbor.decode( | ||
Buffer.from( | ||
'd90103a100a11902d1a264697066736f736f6d65206f74686572207465787469617373657448617368784030393331616532646539616134363231326535306164633137393866393037316537633633363862373861653765623433346332636130656439643035333730', | ||
'hex', | ||
), | ||
), | ||
hash: toFixlenBuffer( | ||
'564702640848981c8b9996b84a13e34cfe4db95914694e0ad46a807da3d05bdb', | ||
32, | ||
), | ||
transformedHash: toFixlenBuffer( | ||
'564702640848981c8b9996b84a13e34cfe4db95914694e0ad46a807da3d05bdb', | ||
32, | ||
), | ||
} | ||
|
||
export const NonCanonicalAuxiliaryData = { | ||
// 259({0: {721: {"assetHash": "0931ae2de9aa46212e50adc1798f9071e7c6368b78ae7eb434c2ca0ed9d05370", "ipfs": "some text"}}}) | ||
data: cbor.decode( | ||
Buffer.from( | ||
'd90103a100a11902d1a269617373657448617368784030393331616532646539616134363231326535306164633137393866393037316537633633363862373861653765623433346332636130656439643035333730646970667369736f6d652074657874', | ||
'hex', | ||
), | ||
), | ||
hash: toFixlenBuffer( | ||
'fb7099a47afd6efb4f9cccf9d0f8745331a19eb8b3f50548ffadae9de8551743', | ||
32, | ||
), | ||
transformedHash: toFixlenBuffer( | ||
'ef10842a1a55e79310cba366c48b5bd8538039fbbadb01d9a69da74f0a5310f0', | ||
32, | ||
), | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { expect } from 'chai' | ||
|
||
import { decodeTxBody, transformTxBody } from '../../src/index' | ||
import { TransformTransactionTestcases } from './__fixtures__/transactions' | ||
|
||
describe('Transform', () => { | ||
for (const { | ||
testname, | ||
cbor, | ||
auxiliaryData, | ||
txBody, | ||
} of TransformTransactionTestcases) { | ||
it(testname, () => { | ||
const transformedTxBody = transformTxBody( | ||
decodeTxBody(Buffer.from(cbor, 'hex')), | ||
auxiliaryData, | ||
) | ||
expect(transformedTxBody).to.deep.equal(txBody) | ||
}) | ||
} | ||
}) |
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
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 |
---|---|---|
|
@@ -431,6 +431,11 @@ astral-regex@^2.0.0: | |
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" | ||
integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== | ||
|
||
b4a@^1.0.1: | ||
version "1.6.0" | ||
resolved "https://registry.yarnpkg.com/b4a/-/b4a-1.6.0.tgz#5430a9cac1af388910dd1a1c1aa9d3a0a796ed68" | ||
integrity sha512-fsTxXxj1081Yq5MOQ06gZ5+e2QcSyP2U6NofdOWyq+lrNI4IjkZ+fLVmoQ6uUCiNg1NWePMMVq93vOTdbJmErw== | ||
|
||
balanced-match@^1.0.0: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" | ||
|
@@ -446,6 +451,22 @@ binary-extensions@^2.0.0: | |
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" | ||
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== | ||
|
||
blake2b-wasm@^2.4.0: | ||
version "2.4.0" | ||
resolved "https://registry.yarnpkg.com/blake2b-wasm/-/blake2b-wasm-2.4.0.tgz#9115649111edbbd87eb24ce7c04b427e4e2be5be" | ||
integrity sha512-S1kwmW2ZhZFFFOghcx73+ZajEfKBqhP82JMssxtLVMxlaPea1p9uoLiUZ5WYyHn0KddwbLc+0vh4wR0KBNoT5w== | ||
dependencies: | ||
b4a "^1.0.1" | ||
nanoassert "^2.0.0" | ||
|
||
blake2b@^2.1.4: | ||
version "2.1.4" | ||
resolved "https://registry.yarnpkg.com/blake2b/-/blake2b-2.1.4.tgz#817d278526ddb4cd673bfb1af16d1ad61e393ba3" | ||
integrity sha512-AyBuuJNI64gIvwx13qiICz6H6hpmjvYS5DGkG6jbXMOT8Z3WUJ3V1X0FlhIoT1b/5JtHE3ki+xjtMvu1nn+t9A== | ||
dependencies: | ||
blake2b-wasm "^2.4.0" | ||
nanoassert "^2.0.0" | ||
|
||
brace-expansion@^1.1.7: | ||
version "1.1.11" | ||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" | ||
|
@@ -1619,6 +1640,11 @@ [email protected], ms@^2.1.1: | |
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" | ||
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== | ||
|
||
nanoassert@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/nanoassert/-/nanoassert-2.0.0.tgz#a05f86de6c7a51618038a620f88878ed1e490c09" | ||
integrity sha512-7vO7n28+aYO4J+8w96AzhmU8G+Y/xpPDJz/se19ICsqj/momRbb9mh9ZUtkoJ5X3nTnPdhEJyc0qnM6yAsHBaA== | ||
|
||
[email protected]: | ||
version "3.3.1" | ||
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" | ||
|