Skip to content
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,900 changes: 1,356 additions & 2,544 deletions package-lock.json

Large diffs are not rendered by default.

498 changes: 238 additions & 260 deletions packages/ripple-binary-codec/src/enums/definitions.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/ripple-binary-codec/src/serdes/binary-serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class BinarySerializer {
*
* @param length the length of the bytes
*/
private encodeVariableLength(length: number): Uint8Array {
static encodeVariableLength(length: number): Uint8Array {
const lenBytes = new Uint8Array(3)
if (length <= 192) {
lenBytes[0] = length
Expand Down Expand Up @@ -158,7 +158,7 @@ class BinarySerializer {
// this part doesn't happen for the Account field in a UNLModify transaction
value.toBytesSink(bytes)
}
this.put(this.encodeVariableLength(bytes.getLength()))
this.put(BinarySerializer.encodeVariableLength(bytes.getLength()))
this.writeBytesList(bytes)
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/ripple-binary-codec/src/types/account-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from 'ripple-address-codec'
import { Hash160 } from './hash-160'
import { hexToBytes } from '@xrplf/isomorphic/utils'
import { SerializedTypeID } from './serialized-type'

const HEX_REGEX = /^[A-F0-9]{40}$/

Expand Down Expand Up @@ -81,6 +82,10 @@ class AccountID extends Hash160 {
toBase58(): string {
return encodeAccountID(this.bytes)
}

getSType(): SerializedTypeID {
return SerializedTypeID.STI_ACCOUNT
}
}

export { AccountID }
6 changes: 5 additions & 1 deletion packages/ripple-binary-codec/src/types/amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BinaryParser } from '../serdes/binary-parser'

import { AccountID } from './account-id'
import { Currency } from './currency'
import { JsonObject, SerializedType } from './serialized-type'
import { JsonObject, SerializedType, SerializedTypeID } from './serialized-type'
import BigNumber from 'bignumber.js'
import { bytesToHex, concat, hexToBytes } from '@xrplf/isomorphic/utils'
import { readUInt32BE, writeUInt32BE } from '../utils'
Expand Down Expand Up @@ -357,6 +357,10 @@ class Amount extends SerializedType {
private isIOU(): boolean {
return (this.bytes[0] & 0x80) !== 0
}

getSType(): SerializedTypeID {
return SerializedTypeID.STI_AMOUNT
}
}

export { Amount, AmountObject }
6 changes: 5 additions & 1 deletion packages/ripple-binary-codec/src/types/blob.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SerializedType } from './serialized-type'
import { SerializedType, SerializedTypeID } from './serialized-type'
import { BinaryParser } from '../serdes/binary-parser'
import { hexToBytes } from '@xrplf/isomorphic/utils'

Expand Down Expand Up @@ -41,6 +41,10 @@ class Blob extends SerializedType {

throw new Error('Cannot construct Blob from value given')
}

getSType(): SerializedTypeID {
return SerializedTypeID.STI_VL
}
}

export { Blob }
5 changes: 5 additions & 0 deletions packages/ripple-binary-codec/src/types/currency.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Hash160 } from './hash-160'
import { bytesToHex, hexToBytes, hexToString } from '@xrplf/isomorphic/utils'
import { SerializedTypeID } from './serialized-type'

const XRP_HEX_REGEX = /^0{40}$/
const ISO_REGEX = /^[A-Z0-9a-z?!@#$%^&*(){}[\]|]{3}$/
Expand Down Expand Up @@ -135,6 +136,10 @@ class Currency extends Hash160 {
}
return bytesToHex(this.bytes)
}

getSType(): SerializedTypeID {
return SerializedTypeID.STI_CURRENCY
}
}

export { Currency }
Loading
Loading