mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-07 14:25:49 +00:00
Compare commits
7 Commits
denis-urit
...
ripple-bin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a163aba7c7 | ||
|
|
c657e22304 | ||
|
|
689768bbf1 | ||
|
|
34ed8afae0 | ||
|
|
3124a281b5 | ||
|
|
fe75f127f6 | ||
|
|
ce229b9977 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ripple-address-codec",
|
"name": "ripple-address-codec",
|
||||||
"version": "4.2.0",
|
"version": "4.2.1-beta.0",
|
||||||
"description": "encodes/decodes base58 encoded XRP Ledger identifiers",
|
"description": "encodes/decodes base58 encoded XRP Ledger identifiers",
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ripple-binary-codec",
|
"name": "ripple-binary-codec",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1-beta.0",
|
||||||
"description": "XRP Ledger binary codec",
|
"description": "XRP Ledger binary codec",
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"buffer": "5.6.0",
|
"buffer": "5.6.0",
|
||||||
"create-hash": "^1.2.0",
|
"create-hash": "^1.2.0",
|
||||||
"decimal.js": "^10.2.0",
|
"decimal.js": "^10.2.0",
|
||||||
"ripple-address-codec": "^4.2.0"
|
"ripple-address-codec": "^4.2.1-beta.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "run-script-os",
|
"build": "run-script-os",
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ function serializeObject(object: JsonObject, opts: OptionObject = {}): Buffer {
|
|||||||
const filter = signingFieldsOnly
|
const filter = signingFieldsOnly
|
||||||
? (f: FieldInstance): boolean => f.isSigningField
|
? (f: FieldInstance): boolean => f.isSigningField
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
coreTypes.STObject.from(object, filter).toBytesSink(bytesList)
|
coreTypes.STObject.from(object, filter).toBytesSink(bytesList)
|
||||||
|
|
||||||
if (suffix) {
|
if (suffix) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as enums from './definitions.json'
|
import * as enums from './definitions.json'
|
||||||
import { SerializedType } from '../types/serialized-type'
|
import { SerializedType } from '../types/serialized-type'
|
||||||
import { Buffer } from 'buffer/'
|
import { Buffer } from 'buffer/'
|
||||||
|
import { BytesList } from '../binary'
|
||||||
|
|
||||||
const TYPE_WIDTH = 2
|
const TYPE_WIDTH = 2
|
||||||
const LEDGER_ENTRY_WIDTH = 2
|
const LEDGER_ENTRY_WIDTH = 2
|
||||||
@@ -29,8 +30,8 @@ function fieldHeader(type: number, nth: number): Buffer {
|
|||||||
/*
|
/*
|
||||||
* @brief: Bytes, name, and ordinal representing one type, ledger_type, transaction type, or result
|
* @brief: Bytes, name, and ordinal representing one type, ledger_type, transaction type, or result
|
||||||
*/
|
*/
|
||||||
class Bytes {
|
export class Bytes {
|
||||||
readonly bytes: Uint8Array
|
readonly bytes: Buffer
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
readonly name: string,
|
readonly name: string,
|
||||||
@@ -47,7 +48,7 @@ class Bytes {
|
|||||||
return this.name
|
return this.name
|
||||||
}
|
}
|
||||||
|
|
||||||
toBytesSink(sink): void {
|
toBytesSink(sink: BytesList): void {
|
||||||
sink.put(this.bytes)
|
sink.put(this.bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,11 @@ class BinarySerializer {
|
|||||||
* @param field field to write to BinarySerializer
|
* @param field field to write to BinarySerializer
|
||||||
* @param value value to write to BinarySerializer
|
* @param value value to write to BinarySerializer
|
||||||
*/
|
*/
|
||||||
writeFieldAndValue(field: FieldInstance, value: SerializedType): void {
|
writeFieldAndValue(
|
||||||
|
field: FieldInstance,
|
||||||
|
value: SerializedType,
|
||||||
|
isUnlModifyWorkaround = false,
|
||||||
|
): void {
|
||||||
const associatedValue = field.associatedType.from(value)
|
const associatedValue = field.associatedType.from(value)
|
||||||
assert.ok(associatedValue.toBytesSink !== undefined)
|
assert.ok(associatedValue.toBytesSink !== undefined)
|
||||||
assert.ok(field.name !== undefined)
|
assert.ok(field.name !== undefined)
|
||||||
@@ -134,7 +138,7 @@ class BinarySerializer {
|
|||||||
this.sink.put(field.header)
|
this.sink.put(field.header)
|
||||||
|
|
||||||
if (field.isVariableLengthEncoded) {
|
if (field.isVariableLengthEncoded) {
|
||||||
this.writeLengthEncoded(associatedValue)
|
this.writeLengthEncoded(associatedValue, isUnlModifyWorkaround)
|
||||||
} else {
|
} else {
|
||||||
associatedValue.toBytesSink(this.sink)
|
associatedValue.toBytesSink(this.sink)
|
||||||
}
|
}
|
||||||
@@ -145,9 +149,12 @@ class BinarySerializer {
|
|||||||
*
|
*
|
||||||
* @param value length encoded value to write to BytesList
|
* @param value length encoded value to write to BytesList
|
||||||
*/
|
*/
|
||||||
public writeLengthEncoded(value: SerializedType): void {
|
public writeLengthEncoded(
|
||||||
|
value: SerializedType,
|
||||||
|
isUnlModifyWorkaround = false,
|
||||||
|
): void {
|
||||||
const bytes = new BytesList()
|
const bytes = new BytesList()
|
||||||
value.toBytesSink(bytes)
|
if (!isUnlModifyWorkaround) value.toBytesSink(bytes)
|
||||||
this.put(this.encodeVariableLength(bytes.getLength()))
|
this.put(this.encodeVariableLength(bytes.getLength()))
|
||||||
this.writeBytesList(bytes)
|
this.writeBytesList(bytes)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Field, FieldInstance } from '../enums'
|
import { Field, FieldInstance, Bytes } from '../enums'
|
||||||
import { SerializedType, JsonObject } from './serialized-type'
|
import { SerializedType, JsonObject } from './serialized-type'
|
||||||
import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
|
import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
|
||||||
import { BinaryParser } from '../serdes/binary-parser'
|
import { BinaryParser } from '../serdes/binary-parser'
|
||||||
@@ -96,6 +96,8 @@ class STObject extends SerializedType {
|
|||||||
const list: BytesList = new BytesList()
|
const list: BytesList = new BytesList()
|
||||||
const bytes: BinarySerializer = new BinarySerializer(list)
|
const bytes: BinarySerializer = new BinarySerializer(list)
|
||||||
|
|
||||||
|
let isUnlModify = false
|
||||||
|
|
||||||
const xAddressDecoded = Object.entries(value).reduce((acc, [key, val]) => {
|
const xAddressDecoded = Object.entries(value).reduce((acc, [key, val]) => {
|
||||||
let handled: JsonObject | undefined = undefined
|
let handled: JsonObject | undefined = undefined
|
||||||
if (val && isValidXAddress(val.toString())) {
|
if (val && isValidXAddress(val.toString())) {
|
||||||
@@ -125,8 +127,11 @@ class STObject extends SerializedType {
|
|||||||
const associatedValue = field.associatedType.from(
|
const associatedValue = field.associatedType.from(
|
||||||
xAddressDecoded[field.name],
|
xAddressDecoded[field.name],
|
||||||
)
|
)
|
||||||
|
if ((associatedValue as unknown as Bytes).name === 'UNLModify') {
|
||||||
bytes.writeFieldAndValue(field, associatedValue)
|
isUnlModify = true
|
||||||
|
}
|
||||||
|
const isUnlModifyWorkaround = field.name == 'Account' && isUnlModify
|
||||||
|
bytes.writeFieldAndValue(field, associatedValue, isUnlModifyWorkaround)
|
||||||
if (field.type.name === ST_OBJECT) {
|
if (field.type.name === ST_OBJECT) {
|
||||||
bytes.put(OBJECT_END_MARKER_BYTE)
|
bytes.put(OBJECT_END_MARKER_BYTE)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"binary": "120066240000000026000003006840000000000000007300701321ED9D593004CC501CACD261BD8E31E863F2B3F6CA69505E7FD54DA8F5690BEFB7AE8114000000000000000000000000000000000000000000101101",
|
"binary": "120066240000000026040B52006840000000000000007300701321EDB6FC8E803EE8EDC2793F1EC917B2EE41D35255618DEB91D3F9B1FC89B75D4539810000101101",
|
||||||
"tx": {
|
"tx": {
|
||||||
"UNLModifyDisabling": 1,
|
"UNLModifyDisabling": 1,
|
||||||
"LedgerSequence": 768,
|
"LedgerSequence": 67850752,
|
||||||
"UNLModifyValidator": "ED9D593004CC501CACD261BD8E31E863F2B3F6CA69505E7FD54DA8F5690BEFB7AE",
|
"UNLModifyValidator": "EDB6FC8E803EE8EDC2793F1EC917B2EE41D35255618DEB91D3F9B1FC89B75D4539",
|
||||||
"TransactionType": "UNLModify",
|
"TransactionType": "UNLModify",
|
||||||
"Account": "rrrrrrrrrrrrrrrrrrrrrhoLvTp",
|
"Account": "rrrrrrrrrrrrrrrrrrrrrhoLvTp",
|
||||||
"Sequence": 0,
|
"Sequence": 0,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ripple-keypairs",
|
"name": "ripple-keypairs",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1-beta.0",
|
||||||
"description": "Cryptographic key pairs for the XRP Ledger",
|
"description": "Cryptographic key pairs for the XRP Ledger",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -b",
|
"build": "tsc -b",
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
"brorand": "^1.0.5",
|
"brorand": "^1.0.5",
|
||||||
"elliptic": "^6.5.4",
|
"elliptic": "^6.5.4",
|
||||||
"hash.js": "^1.0.3",
|
"hash.js": "^1.0.3",
|
||||||
"ripple-address-codec": "^4.2.0"
|
"ripple-address-codec": "^4.2.1-beta.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xrpl",
|
"name": "xrpl",
|
||||||
"version": "2.0.2",
|
"version": "2.0.3-beta.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "A TypeScript/JavaScript API for interacting with the XRP Ledger in Node.js and the browser",
|
"description": "A TypeScript/JavaScript API for interacting with the XRP Ledger in Node.js and the browser",
|
||||||
"files": [
|
"files": [
|
||||||
@@ -24,9 +24,9 @@
|
|||||||
"bip39": "^3.0.4",
|
"bip39": "^3.0.4",
|
||||||
"https-proxy-agent": "^5.0.0",
|
"https-proxy-agent": "^5.0.0",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"ripple-address-codec": "^4.2.0",
|
"ripple-address-codec": "^4.2.1-beta.0",
|
||||||
"ripple-binary-codec": "^1.2.0",
|
"ripple-binary-codec": "^1.2.1-beta.0",
|
||||||
"ripple-keypairs": "^1.1.0",
|
"ripple-keypairs": "^1.1.1-beta.0",
|
||||||
"ws": "^8.2.2"
|
"ws": "^8.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user