Merge branch 'main' into export-AccountOffer

This commit is contained in:
Caleb Kniffen
2022-05-31 12:43:36 -05:00
committed by GitHub
3 changed files with 23 additions and 0 deletions

View File

@@ -1,5 +1,8 @@
# ripple-binary-codec Release History
## Unreleased
- Added a clearer error message for trying to encode an invalid transaction. (Ex. With an incorrect TransactionType)
## 1.4.0 (2022-04-18)
- Updated NFT definitions to match 1.9.0's breaking naming changes

View File

@@ -127,6 +127,15 @@ class STObject extends SerializedType {
const associatedValue = field.associatedType.from(
xAddressDecoded[field.name],
)
if (associatedValue == undefined) {
throw new TypeError(
`Unable to interpret "${field.name}: ${
xAddressDecoded[field.name]
}".`,
)
}
if ((associatedValue as unknown as Bytes).name === 'UNLModify') {
// triggered when the TransactionType field has a value of 'UNLModify'
isUnlModify = true

View File

@@ -1,3 +1,4 @@
const { throws } = require('assert')
const {
encodeForSigning,
encodeForSigningClaim,
@@ -65,6 +66,16 @@ describe('Signing data', function () {
].join(''),
)
})
test('can fail gracefully for invalid TransactionType', function () {
const invalidTransactionType = {
...tx_json,
TransactionType: 'NotAPayment',
}
throws(() => encodeForSigning(invalidTransactionType), /NotAPayment/u)
})
test('can create multi signing blobs', function () {
const signingAccount = 'rJZdUusLDtY9NEsGea7ijqhVrXv98rYBYN'
const signingJson = Object.assign({}, tx_json, { SigningPubKey: '' })