@transia/ripple-binary-codec 1.4.6-alpha.3 → 1.4.6-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,6 +46,7 @@
46
46
  "NFTokenPage": 80,
47
47
  "NFTokenOffer": 55,
48
48
  "URIToken": 85,
49
+ "UNLReport": 82,
49
50
  "Any": -3,
50
51
  "Child": -2,
51
52
  "Nickname": 110,
@@ -46,6 +46,7 @@
46
46
  "NFTokenPage": 80,
47
47
  "NFTokenOffer": 55,
48
48
  "URIToken": 85,
49
+ "UNLReport": 82,
49
50
  "Any": -3,
50
51
  "Child": -2,
51
52
  "Nickname": 110,
@@ -13,7 +13,7 @@ const STANDARD_FORMAT_HEX_REGEX = /^0{24}[\x00-\x7F]{6}0{10}$/;
13
13
  */
14
14
  function isoToBytes(iso) {
15
15
  const bytes = buffer_1.Buffer.alloc(20);
16
- if (iso !== 'XRP') {
16
+ if (iso !== 'XAH') {
17
17
  const isoBytes = iso.split('').map((c) => c.charCodeAt(0));
18
18
  bytes.set(isoBytes, 12);
19
19
  }
@@ -27,7 +27,7 @@ function isIsoCode(iso) {
27
27
  }
28
28
  function isoCodeFromHex(code) {
29
29
  const iso = code.toString();
30
- if (iso === 'XRP') {
30
+ if (iso === 'XAH') {
31
31
  return null;
32
32
  }
33
33
  if (isIsoCode(iso)) {
@@ -78,7 +78,7 @@ class Currency extends hash_160_1.Hash160 {
78
78
  super(byteBuf !== null && byteBuf !== void 0 ? byteBuf : Currency.XRP.bytes);
79
79
  const hex = this.bytes.toString('hex');
80
80
  if (XRP_HEX_REGEX.test(hex)) {
81
- this._iso = 'XRP';
81
+ this._iso = 'XAH';
82
82
  }
83
83
  else if (STANDARD_FORMAT_HEX_REGEX.test(hex)) {
84
84
  this._iso = isoCodeFromHex(this.bytes.slice(12, 15));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transia/ripple-binary-codec",
3
- "version": "1.4.6-alpha.3",
3
+ "version": "1.4.6-alpha.5",
4
4
  "description": "XRP Ledger binary codec",
5
5
  "files": [
6
6
  "dist/*",
@@ -40,5 +40,5 @@
40
40
  "engines": {
41
41
  "node": ">= 10"
42
42
  },
43
- "gitHead": "edc11a1f88e4be861e7dace7ab48f4c670a46194"
43
+ "gitHead": "ac865e472ee71484a692fa4484106c7a0fa0865c"
44
44
  }
@@ -369,7 +369,7 @@ function pathSetBinaryTests() {
369
369
  currency: 'BTC',
370
370
  issuer: 'r3AWbdp2jQLXLywJypdoNwVSvr81xs3uhn',
371
371
  },
372
- { currency: 'XRP' },
372
+ { currency: 'XAH' },
373
373
  {
374
374
  currency: 'USD',
375
375
  issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
@@ -105,6 +105,11 @@ let json_omitted = {
105
105
  }
106
106
 
107
107
  const NegativeUNL = require('./fixtures/negative-unl.json')
108
+ const UNLReport = {
109
+ tx: require('./fixtures/unl-report.json'),
110
+ binary: require('./fixtures/unl-report-binary.json'),
111
+ meta: require('./fixtures/unl-report-meta-binary.json'),
112
+ }
108
113
 
109
114
  function bytesListTest() {
110
115
  const list = new BytesList()
@@ -229,6 +234,18 @@ function NegativeUNLTest() {
229
234
  })
230
235
  }
231
236
 
237
+ function UNLReportTest() {
238
+ test('can serialize UNLReport', () => {
239
+ expect(encode(UNLReport.tx)).toEqual(UNLReport.binary)
240
+ })
241
+ test('can serialize UNLReport metadata', () => {
242
+ expect(encode(UNLReport.tx.meta)).toEqual(UNLReport.meta)
243
+ })
244
+ test('can deserialize UNLReport metadata', () => {
245
+ expect(decode(UNLReport.meta)).toEqual(UNLReport.tx.meta)
246
+ })
247
+ }
248
+
232
249
  function omitUndefinedTest() {
233
250
  test('omits fields with undefined value', () => {
234
251
  let encodedOmitted = encode(json_omitted)
@@ -286,4 +303,5 @@ describe('Binary Serialization', function () {
286
303
  describe('OmitUndefined', omitUndefinedTest)
287
304
  describe('TicketTest', ticketTest)
288
305
  describe('NFToken', nfTokenTest)
306
+ describe('UNLReport', UNLReportTest)
289
307
  })
@@ -2904,7 +2904,7 @@
2904
2904
  "type_id": 6,
2905
2905
  "is_native": true,
2906
2906
  "type": "Amount",
2907
- "error": "1000000000000 absolute XRP is bigger than max native value 100000000000.0",
2907
+ "error": "1000000000000 absolute XAH is bigger than max native value 100000000000.0",
2908
2908
  "is_negative": false
2909
2909
  },
2910
2910
  {
@@ -2912,7 +2912,7 @@
2912
2912
  "type_id": 6,
2913
2913
  "is_native": true,
2914
2914
  "type": "Amount",
2915
- "error": "10000000000000000000 absolute XRP is bigger than max native value 100000000000.0",
2915
+ "error": "10000000000000000000 absolute XAH is bigger than max native value 100000000000.0",
2916
2916
  "is_negative": true
2917
2917
  }
2918
2918
  ]
@@ -0,0 +1 @@
1
+ "120068240000000026006D2E00684000000000000000730081140000000000000000000000000000000000000000E05F7121ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655E1"
@@ -0,0 +1 @@
1
+ "201C00000000F8E51100525661E32E7A24A238F1C619D5F9DDCC41A94B33B66C0163F7EFCC8A19C9FD6F28DCE6F05FE05F7121ED3ABC6740983BFB13FFD9728EBCC365A2877877D368FC28990819522300C92A698114A53F8465478D79DC0C764F0FB2B67AE92465FD5EE1E05F7121ED49F82B2FFD537F224A1E0A10DEEFC3C25CE3882979E6B327C9F18603D21F0A2281142BF2A77E25382EC1DEF521D81D24BC0FDD35BC9BE1E05F7121ED79EB0F6A9F01A039235E536D19F812B55ACF540C9E22CF62C271E0D42BFF51748114C45147960400DB6B763110CBCE8D641E9365F24EE1E05F7121ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655811408BCFB092DEE1BF0F2662AECE4DCC62C4AECCB8AE1E05F7121ED96F581FED430E8CBE1F08B37408857001D4118D49FBB594B0BE007C2DBFFD3678114A4EF485B50A7D91DF45450A680FAC31C53367B2DE1E05F7121EDCF31B8F683345E1C49B4A1D85BF2731E55E7D6781F3D4BF45EE7ADF2D2FB340281144D854497B48F1A41EF04E09DB656A11AAD01A703E1E05F7121EDDF197FC59A7FAA09EB1AD60A4638BA6201DD51497B5C08A1745115098E229E0E811446550CBD2B655081662AE3159B0488DE27EC0592E1F1E1E72200000000F05EE05E7121ED264807102805220DA0F312E71FC2C69E1552C9C5790F6C25E3729DEB573D5860811478339DD5880A994A5CB6E56CB7ED13FEEF201928E1F1F05FE05F7121ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655811408BCFB092DEE1BF0F2662AECE4DCC62C4AECCB8AE1F1E1E1F1031000"
@@ -0,0 +1,89 @@
1
+ {
2
+ "Account": "",
3
+ "ActiveValidator": {
4
+ "PublicKey": "ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655"
5
+ },
6
+ "Fee": "0",
7
+ "LedgerSequence": 7155200,
8
+ "Sequence": 0,
9
+ "SigningPubKey": "",
10
+ "TransactionType": "UNLReport",
11
+ "hash": "0878863F758F74A5CBD35691CDAB625A3BCD35B21B440E20545C4757DDB0CA43",
12
+ "meta": {
13
+ "AffectedNodes": [
14
+ {
15
+ "ModifiedNode": {
16
+ "FinalFields": {
17
+ "ActiveValidators": [
18
+ {
19
+ "ActiveValidator": {
20
+ "Account": "roUo3ygV92bdhfE1v9LGpPETXvJv2kQv5",
21
+ "PublicKey": "ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655"
22
+ }
23
+ }
24
+ ],
25
+ "Flags": 0,
26
+ "ImportVLKeys": [
27
+ {
28
+ "ImportVLKey": {
29
+ "Account": "rBxZvQBY551DJ21g9AC1Qc9ASQowqcskbF",
30
+ "PublicKey": "ED264807102805220DA0F312E71FC2C69E1552C9C5790F6C25E3729DEB573D5860"
31
+ }
32
+ }
33
+ ]
34
+ },
35
+ "LedgerEntryType": "UNLReport",
36
+ "LedgerIndex": "61E32E7A24A238F1C619D5F9DDCC41A94B33B66C0163F7EFCC8A19C9FD6F28DC",
37
+ "PreviousFields": {
38
+ "ActiveValidators": [
39
+ {
40
+ "ActiveValidator": {
41
+ "Account": "rGhk2uLd8ShzX2Zrcgn8sQk1LWBG4jjEwf",
42
+ "PublicKey": "ED3ABC6740983BFB13FFD9728EBCC365A2877877D368FC28990819522300C92A69"
43
+ }
44
+ },
45
+ {
46
+ "ActiveValidator": {
47
+ "Account": "rnr4kwS1VkJhvjVRuq2fbWZtEdN2HbpVVu",
48
+ "PublicKey": "ED49F82B2FFD537F224A1E0A10DEEFC3C25CE3882979E6B327C9F18603D21F0A22"
49
+ }
50
+ },
51
+ {
52
+ "ActiveValidator": {
53
+ "Account": "rJupFrPPYgUNFBdoSqhMEJ22hiHKiZSHXQ",
54
+ "PublicKey": "ED79EB0F6A9F01A039235E536D19F812B55ACF540C9E22CF62C271E0D42BFF5174"
55
+ }
56
+ },
57
+ {
58
+ "ActiveValidator": {
59
+ "Account": "roUo3ygV92bdhfE1v9LGpPETXvJv2kQv5",
60
+ "PublicKey": "ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655"
61
+ }
62
+ },
63
+ {
64
+ "ActiveValidator": {
65
+ "Account": "rGsa7f4arJ8JE9ok9LCht6jCu5xBKUKVMq",
66
+ "PublicKey": "ED96F581FED430E8CBE1F08B37408857001D4118D49FBB594B0BE007C2DBFFD367"
67
+ }
68
+ },
69
+ {
70
+ "ActiveValidator": {
71
+ "Account": "r3htgPchiR2r8kMGzPK3Wfv3WTrpaRKjtU",
72
+ "PublicKey": "EDCF31B8F683345E1C49B4A1D85BF2731E55E7D6781F3D4BF45EE7ADF2D2FB3402"
73
+ }
74
+ },
75
+ {
76
+ "ActiveValidator": {
77
+ "Account": "rfQtB8m51sdbWgcmddRX2mMjMpSxzX1AGr",
78
+ "PublicKey": "EDDF197FC59A7FAA09EB1AD60A4638BA6201DD51497B5C08A1745115098E229E0E"
79
+ }
80
+ }
81
+ ]
82
+ }
83
+ }
84
+ }
85
+ ],
86
+ "TransactionIndex": 0,
87
+ "TransactionResult": "tesSUCCESS"
88
+ }
89
+ }
package/test/hash.test.js CHANGED
@@ -77,7 +77,7 @@ describe('Hash256', function () {
77
77
 
78
78
  describe('Currency', function () {
79
79
  test('Decoding allows dodgy XRP without throwing', function () {
80
- const currencyCode = '0000000000000000000000005852500000000000'
80
+ const currencyCode = '0000000000000000000000005841480000000000'
81
81
  expect(Currency.from(currencyCode).toJSON()).toBe(currencyCode)
82
82
  })
83
83
  test('Currency code with lowercase letters decodes to ISO code', () => {
@@ -113,7 +113,7 @@ describe('Currency', function () {
113
113
 
114
114
  test('can be constructed from a Buffer', function () {
115
115
  const xrp = new Currency(Buffer.alloc(20))
116
- expect(xrp.iso()).toBe('XRP')
116
+ expect(xrp.iso()).toBe('XAH')
117
117
  })
118
118
  test('Can handle non-standard currency codes', () => {
119
119
  const currency = '015841551A748AD2C1F76FF6ECB0CCCD00000000'
@@ -58,7 +58,7 @@ describe('encoding and decoding tx_json', function () {
58
58
  Sequence: 19,
59
59
  LimitAmount: {
60
60
  value: '200',
61
- currency: '0000000000000000000000005852500000000000',
61
+ currency: '0000000000000000000000005841480000000000',
62
62
  issuer: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
63
63
  },
64
64
  Fee: '10',