xrpl-ruby 0.7.0 → 0.9.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +261 -0
- data/README.md +160 -3
- data/lib/binary-codec/binary_codec.rb +122 -1
- data/lib/binary-codec/enums/definitions.json +84 -288
- data/lib/binary-codec/enums/definitions.rb +38 -1
- data/lib/binary-codec/serdes/binary_serializer.rb +7 -1
- data/lib/binary-codec/types/st_array.rb +7 -2
- data/lib/binary-codec/types/st_object.rb +7 -11
- data/lib/binary-codec/types/uint.rb +109 -50
- data/lib/wallet/wallet.rb +180 -6
- data/lib/xrpl/batch.rb +167 -0
- data/lib/xrpl/client.rb +48 -7
- data/lib/xrpl/fee.rb +94 -0
- data/lib/xrpl/ledger_entry.rb +53 -0
- data/lib/xrpl/model.rb +239 -0
- data/lib/xrpl/transaction.rb +14 -163
- data/lib/xrpl/version.rb +1 -1
- data/lib/xrpl-ruby.rb +4 -0
- metadata +6 -2
|
@@ -148,46 +148,6 @@
|
|
|
148
148
|
"type": "UInt16"
|
|
149
149
|
}
|
|
150
150
|
],
|
|
151
|
-
[
|
|
152
|
-
"HookStateChangeCount",
|
|
153
|
-
{
|
|
154
|
-
"isSerialized": true,
|
|
155
|
-
"isSigningField": true,
|
|
156
|
-
"isVLEncoded": false,
|
|
157
|
-
"nth": 17,
|
|
158
|
-
"type": "UInt16"
|
|
159
|
-
}
|
|
160
|
-
],
|
|
161
|
-
[
|
|
162
|
-
"HookEmitCount",
|
|
163
|
-
{
|
|
164
|
-
"isSerialized": true,
|
|
165
|
-
"isSigningField": true,
|
|
166
|
-
"isVLEncoded": false,
|
|
167
|
-
"nth": 18,
|
|
168
|
-
"type": "UInt16"
|
|
169
|
-
}
|
|
170
|
-
],
|
|
171
|
-
[
|
|
172
|
-
"HookExecutionIndex",
|
|
173
|
-
{
|
|
174
|
-
"isSerialized": true,
|
|
175
|
-
"isSigningField": true,
|
|
176
|
-
"isVLEncoded": false,
|
|
177
|
-
"nth": 19,
|
|
178
|
-
"type": "UInt16"
|
|
179
|
-
}
|
|
180
|
-
],
|
|
181
|
-
[
|
|
182
|
-
"HookApiVersion",
|
|
183
|
-
{
|
|
184
|
-
"isSerialized": true,
|
|
185
|
-
"isSigningField": true,
|
|
186
|
-
"isVLEncoded": false,
|
|
187
|
-
"nth": 20,
|
|
188
|
-
"type": "UInt16"
|
|
189
|
-
}
|
|
190
|
-
],
|
|
191
151
|
[
|
|
192
152
|
"LedgerFixType",
|
|
193
153
|
{
|
|
@@ -648,26 +608,6 @@
|
|
|
648
608
|
"type": "UInt32"
|
|
649
609
|
}
|
|
650
610
|
],
|
|
651
|
-
[
|
|
652
|
-
"HookStateCount",
|
|
653
|
-
{
|
|
654
|
-
"isSerialized": true,
|
|
655
|
-
"isSigningField": true,
|
|
656
|
-
"isVLEncoded": false,
|
|
657
|
-
"nth": 45,
|
|
658
|
-
"type": "UInt32"
|
|
659
|
-
}
|
|
660
|
-
],
|
|
661
|
-
[
|
|
662
|
-
"EmitGeneration",
|
|
663
|
-
{
|
|
664
|
-
"isSerialized": true,
|
|
665
|
-
"isSigningField": true,
|
|
666
|
-
"isVLEncoded": false,
|
|
667
|
-
"nth": 46,
|
|
668
|
-
"type": "UInt32"
|
|
669
|
-
}
|
|
670
|
-
],
|
|
671
611
|
[
|
|
672
612
|
"VoteWeight",
|
|
673
613
|
{
|
|
@@ -928,6 +868,26 @@
|
|
|
928
868
|
"type": "UInt32"
|
|
929
869
|
}
|
|
930
870
|
],
|
|
871
|
+
[
|
|
872
|
+
"SubscriptionDate",
|
|
873
|
+
{
|
|
874
|
+
"isSerialized": true,
|
|
875
|
+
"isSigningField": true,
|
|
876
|
+
"isVLEncoded": false,
|
|
877
|
+
"nth": 75,
|
|
878
|
+
"type": "UInt32"
|
|
879
|
+
}
|
|
880
|
+
],
|
|
881
|
+
[
|
|
882
|
+
"RedemptionDate",
|
|
883
|
+
{
|
|
884
|
+
"isSerialized": true,
|
|
885
|
+
"isSigningField": true,
|
|
886
|
+
"isVLEncoded": false,
|
|
887
|
+
"nth": 76,
|
|
888
|
+
"type": "UInt32"
|
|
889
|
+
}
|
|
890
|
+
],
|
|
931
891
|
[
|
|
932
892
|
"IndexNext",
|
|
933
893
|
{
|
|
@@ -1058,36 +1018,6 @@
|
|
|
1058
1018
|
"type": "UInt64"
|
|
1059
1019
|
}
|
|
1060
1020
|
],
|
|
1061
|
-
[
|
|
1062
|
-
"HookOn",
|
|
1063
|
-
{
|
|
1064
|
-
"isSerialized": true,
|
|
1065
|
-
"isSigningField": true,
|
|
1066
|
-
"isVLEncoded": false,
|
|
1067
|
-
"nth": 16,
|
|
1068
|
-
"type": "UInt64"
|
|
1069
|
-
}
|
|
1070
|
-
],
|
|
1071
|
-
[
|
|
1072
|
-
"HookInstructionCount",
|
|
1073
|
-
{
|
|
1074
|
-
"isSerialized": true,
|
|
1075
|
-
"isSigningField": true,
|
|
1076
|
-
"isVLEncoded": false,
|
|
1077
|
-
"nth": 17,
|
|
1078
|
-
"type": "UInt64"
|
|
1079
|
-
}
|
|
1080
|
-
],
|
|
1081
|
-
[
|
|
1082
|
-
"HookReturnCode",
|
|
1083
|
-
{
|
|
1084
|
-
"isSerialized": true,
|
|
1085
|
-
"isSigningField": true,
|
|
1086
|
-
"isVLEncoded": false,
|
|
1087
|
-
"nth": 18,
|
|
1088
|
-
"type": "UInt64"
|
|
1089
|
-
}
|
|
1090
|
-
],
|
|
1091
1021
|
[
|
|
1092
1022
|
"ReferenceCount",
|
|
1093
1023
|
{
|
|
@@ -1518,46 +1448,6 @@
|
|
|
1518
1448
|
"type": "Hash256"
|
|
1519
1449
|
}
|
|
1520
1450
|
],
|
|
1521
|
-
[
|
|
1522
|
-
"HookStateKey",
|
|
1523
|
-
{
|
|
1524
|
-
"isSerialized": true,
|
|
1525
|
-
"isSigningField": true,
|
|
1526
|
-
"isVLEncoded": false,
|
|
1527
|
-
"nth": 30,
|
|
1528
|
-
"type": "Hash256"
|
|
1529
|
-
}
|
|
1530
|
-
],
|
|
1531
|
-
[
|
|
1532
|
-
"HookHash",
|
|
1533
|
-
{
|
|
1534
|
-
"isSerialized": true,
|
|
1535
|
-
"isSigningField": true,
|
|
1536
|
-
"isVLEncoded": false,
|
|
1537
|
-
"nth": 31,
|
|
1538
|
-
"type": "Hash256"
|
|
1539
|
-
}
|
|
1540
|
-
],
|
|
1541
|
-
[
|
|
1542
|
-
"HookNamespace",
|
|
1543
|
-
{
|
|
1544
|
-
"isSerialized": true,
|
|
1545
|
-
"isSigningField": true,
|
|
1546
|
-
"isVLEncoded": false,
|
|
1547
|
-
"nth": 32,
|
|
1548
|
-
"type": "Hash256"
|
|
1549
|
-
}
|
|
1550
|
-
],
|
|
1551
|
-
[
|
|
1552
|
-
"HookSetTxnID",
|
|
1553
|
-
{
|
|
1554
|
-
"isSerialized": true,
|
|
1555
|
-
"isSigningField": true,
|
|
1556
|
-
"isVLEncoded": false,
|
|
1557
|
-
"nth": 33,
|
|
1558
|
-
"type": "Hash256"
|
|
1559
|
-
}
|
|
1560
|
-
],
|
|
1561
1451
|
[
|
|
1562
1452
|
"DomainID",
|
|
1563
1453
|
{
|
|
@@ -2158,46 +2048,6 @@
|
|
|
2158
2048
|
"type": "Blob"
|
|
2159
2049
|
}
|
|
2160
2050
|
],
|
|
2161
|
-
[
|
|
2162
|
-
"HookStateData",
|
|
2163
|
-
{
|
|
2164
|
-
"isSerialized": true,
|
|
2165
|
-
"isSigningField": true,
|
|
2166
|
-
"isVLEncoded": true,
|
|
2167
|
-
"nth": 22,
|
|
2168
|
-
"type": "Blob"
|
|
2169
|
-
}
|
|
2170
|
-
],
|
|
2171
|
-
[
|
|
2172
|
-
"HookReturnString",
|
|
2173
|
-
{
|
|
2174
|
-
"isSerialized": true,
|
|
2175
|
-
"isSigningField": true,
|
|
2176
|
-
"isVLEncoded": true,
|
|
2177
|
-
"nth": 23,
|
|
2178
|
-
"type": "Blob"
|
|
2179
|
-
}
|
|
2180
|
-
],
|
|
2181
|
-
[
|
|
2182
|
-
"HookParameterName",
|
|
2183
|
-
{
|
|
2184
|
-
"isSerialized": true,
|
|
2185
|
-
"isSigningField": true,
|
|
2186
|
-
"isVLEncoded": true,
|
|
2187
|
-
"nth": 24,
|
|
2188
|
-
"type": "Blob"
|
|
2189
|
-
}
|
|
2190
|
-
],
|
|
2191
|
-
[
|
|
2192
|
-
"HookParameterValue",
|
|
2193
|
-
{
|
|
2194
|
-
"isSerialized": true,
|
|
2195
|
-
"isSigningField": true,
|
|
2196
|
-
"isVLEncoded": true,
|
|
2197
|
-
"nth": 25,
|
|
2198
|
-
"type": "Blob"
|
|
2199
|
-
}
|
|
2200
|
-
],
|
|
2201
2051
|
[
|
|
2202
2052
|
"DIDDocument",
|
|
2203
2053
|
{
|
|
@@ -2518,16 +2368,6 @@
|
|
|
2518
2368
|
"type": "AccountID"
|
|
2519
2369
|
}
|
|
2520
2370
|
],
|
|
2521
|
-
[
|
|
2522
|
-
"HookAccount",
|
|
2523
|
-
{
|
|
2524
|
-
"isSerialized": true,
|
|
2525
|
-
"isSigningField": true,
|
|
2526
|
-
"isVLEncoded": true,
|
|
2527
|
-
"nth": 16,
|
|
2528
|
-
"type": "AccountID"
|
|
2529
|
-
}
|
|
2530
|
-
],
|
|
2531
2371
|
[
|
|
2532
2372
|
"OtherChainSource",
|
|
2533
2373
|
{
|
|
@@ -2978,16 +2818,6 @@
|
|
|
2978
2818
|
"type": "STObject"
|
|
2979
2819
|
}
|
|
2980
2820
|
],
|
|
2981
|
-
[
|
|
2982
|
-
"Hook",
|
|
2983
|
-
{
|
|
2984
|
-
"isSerialized": true,
|
|
2985
|
-
"isSigningField": true,
|
|
2986
|
-
"isVLEncoded": false,
|
|
2987
|
-
"nth": 14,
|
|
2988
|
-
"type": "STObject"
|
|
2989
|
-
}
|
|
2990
|
-
],
|
|
2991
2821
|
[
|
|
2992
2822
|
"Permission",
|
|
2993
2823
|
{
|
|
@@ -3028,56 +2858,6 @@
|
|
|
3028
2858
|
"type": "STObject"
|
|
3029
2859
|
}
|
|
3030
2860
|
],
|
|
3031
|
-
[
|
|
3032
|
-
"EmittedTxn",
|
|
3033
|
-
{
|
|
3034
|
-
"isSerialized": true,
|
|
3035
|
-
"isSigningField": true,
|
|
3036
|
-
"isVLEncoded": false,
|
|
3037
|
-
"nth": 20,
|
|
3038
|
-
"type": "STObject"
|
|
3039
|
-
}
|
|
3040
|
-
],
|
|
3041
|
-
[
|
|
3042
|
-
"HookExecution",
|
|
3043
|
-
{
|
|
3044
|
-
"isSerialized": true,
|
|
3045
|
-
"isSigningField": true,
|
|
3046
|
-
"isVLEncoded": false,
|
|
3047
|
-
"nth": 21,
|
|
3048
|
-
"type": "STObject"
|
|
3049
|
-
}
|
|
3050
|
-
],
|
|
3051
|
-
[
|
|
3052
|
-
"HookDefinition",
|
|
3053
|
-
{
|
|
3054
|
-
"isSerialized": true,
|
|
3055
|
-
"isSigningField": true,
|
|
3056
|
-
"isVLEncoded": false,
|
|
3057
|
-
"nth": 22,
|
|
3058
|
-
"type": "STObject"
|
|
3059
|
-
}
|
|
3060
|
-
],
|
|
3061
|
-
[
|
|
3062
|
-
"HookParameter",
|
|
3063
|
-
{
|
|
3064
|
-
"isSerialized": true,
|
|
3065
|
-
"isSigningField": true,
|
|
3066
|
-
"isVLEncoded": false,
|
|
3067
|
-
"nth": 23,
|
|
3068
|
-
"type": "STObject"
|
|
3069
|
-
}
|
|
3070
|
-
],
|
|
3071
|
-
[
|
|
3072
|
-
"HookGrant",
|
|
3073
|
-
{
|
|
3074
|
-
"isSerialized": true,
|
|
3075
|
-
"isSigningField": true,
|
|
3076
|
-
"isVLEncoded": false,
|
|
3077
|
-
"nth": 24,
|
|
3078
|
-
"type": "STObject"
|
|
3079
|
-
}
|
|
3080
|
-
],
|
|
3081
2861
|
[
|
|
3082
2862
|
"VoteEntry",
|
|
3083
2863
|
{
|
|
@@ -3298,16 +3078,6 @@
|
|
|
3298
3078
|
"type": "STArray"
|
|
3299
3079
|
}
|
|
3300
3080
|
],
|
|
3301
|
-
[
|
|
3302
|
-
"Hooks",
|
|
3303
|
-
{
|
|
3304
|
-
"isSerialized": true,
|
|
3305
|
-
"isSigningField": true,
|
|
3306
|
-
"isVLEncoded": false,
|
|
3307
|
-
"nth": 11,
|
|
3308
|
-
"type": "STArray"
|
|
3309
|
-
}
|
|
3310
|
-
],
|
|
3311
3081
|
[
|
|
3312
3082
|
"VoteSlots",
|
|
3313
3083
|
{
|
|
@@ -3348,36 +3118,6 @@
|
|
|
3348
3118
|
"type": "STArray"
|
|
3349
3119
|
}
|
|
3350
3120
|
],
|
|
3351
|
-
[
|
|
3352
|
-
"HookExecutions",
|
|
3353
|
-
{
|
|
3354
|
-
"isSerialized": true,
|
|
3355
|
-
"isSigningField": true,
|
|
3356
|
-
"isVLEncoded": false,
|
|
3357
|
-
"nth": 18,
|
|
3358
|
-
"type": "STArray"
|
|
3359
|
-
}
|
|
3360
|
-
],
|
|
3361
|
-
[
|
|
3362
|
-
"HookParameters",
|
|
3363
|
-
{
|
|
3364
|
-
"isSerialized": true,
|
|
3365
|
-
"isSigningField": true,
|
|
3366
|
-
"isVLEncoded": false,
|
|
3367
|
-
"nth": 19,
|
|
3368
|
-
"type": "STArray"
|
|
3369
|
-
}
|
|
3370
|
-
],
|
|
3371
|
-
[
|
|
3372
|
-
"HookGrants",
|
|
3373
|
-
{
|
|
3374
|
-
"isSerialized": true,
|
|
3375
|
-
"isSigningField": true,
|
|
3376
|
-
"isVLEncoded": false,
|
|
3377
|
-
"nth": 20,
|
|
3378
|
-
"type": "STArray"
|
|
3379
|
-
}
|
|
3380
|
-
],
|
|
3381
3121
|
[
|
|
3382
3122
|
"XChainClaimAttestations",
|
|
3383
3123
|
{
|
|
@@ -3529,32 +3269,32 @@
|
|
|
3529
3269
|
}
|
|
3530
3270
|
],
|
|
3531
3271
|
[
|
|
3532
|
-
"
|
|
3272
|
+
"LEVersion",
|
|
3533
3273
|
{
|
|
3534
3274
|
"isSerialized": true,
|
|
3535
3275
|
"isSigningField": true,
|
|
3536
3276
|
"isVLEncoded": false,
|
|
3537
|
-
"nth":
|
|
3277
|
+
"nth": 6,
|
|
3538
3278
|
"type": "UInt8"
|
|
3539
3279
|
}
|
|
3540
3280
|
],
|
|
3541
3281
|
[
|
|
3542
|
-
"
|
|
3282
|
+
"TickSize",
|
|
3543
3283
|
{
|
|
3544
3284
|
"isSerialized": true,
|
|
3545
3285
|
"isSigningField": true,
|
|
3546
3286
|
"isVLEncoded": false,
|
|
3547
|
-
"nth":
|
|
3287
|
+
"nth": 16,
|
|
3548
3288
|
"type": "UInt8"
|
|
3549
3289
|
}
|
|
3550
3290
|
],
|
|
3551
3291
|
[
|
|
3552
|
-
"
|
|
3292
|
+
"UNLModifyDisabling",
|
|
3553
3293
|
{
|
|
3554
3294
|
"isSerialized": true,
|
|
3555
3295
|
"isSigningField": true,
|
|
3556
3296
|
"isVLEncoded": false,
|
|
3557
|
-
"nth":
|
|
3297
|
+
"nth": 17,
|
|
3558
3298
|
"type": "UInt8"
|
|
3559
3299
|
}
|
|
3560
3300
|
],
|
|
@@ -3578,6 +3318,26 @@
|
|
|
3578
3318
|
"type": "UInt8"
|
|
3579
3319
|
}
|
|
3580
3320
|
],
|
|
3321
|
+
[
|
|
3322
|
+
"ContractResult",
|
|
3323
|
+
{
|
|
3324
|
+
"isSerialized": true,
|
|
3325
|
+
"isSigningField": true,
|
|
3326
|
+
"isVLEncoded": false,
|
|
3327
|
+
"nth": 21,
|
|
3328
|
+
"type": "UInt8"
|
|
3329
|
+
}
|
|
3330
|
+
],
|
|
3331
|
+
[
|
|
3332
|
+
"VaultKind",
|
|
3333
|
+
{
|
|
3334
|
+
"isSerialized": true,
|
|
3335
|
+
"isSigningField": true,
|
|
3336
|
+
"isVLEncoded": false,
|
|
3337
|
+
"nth": 22,
|
|
3338
|
+
"type": "UInt8"
|
|
3339
|
+
}
|
|
3340
|
+
],
|
|
3581
3341
|
[
|
|
3582
3342
|
"TakerPaysCurrency",
|
|
3583
3343
|
{
|
|
@@ -5239,6 +4999,22 @@
|
|
|
5239
4999
|
{
|
|
5240
5000
|
"name": "Scale",
|
|
5241
5001
|
"optionality": 2
|
|
5002
|
+
},
|
|
5003
|
+
{
|
|
5004
|
+
"name": "LEVersion",
|
|
5005
|
+
"optionality": 2
|
|
5006
|
+
},
|
|
5007
|
+
{
|
|
5008
|
+
"name": "VaultKind",
|
|
5009
|
+
"optionality": 2
|
|
5010
|
+
},
|
|
5011
|
+
{
|
|
5012
|
+
"name": "SubscriptionDate",
|
|
5013
|
+
"optionality": 1
|
|
5014
|
+
},
|
|
5015
|
+
{
|
|
5016
|
+
"name": "RedemptionDate",
|
|
5017
|
+
"optionality": 1
|
|
5242
5018
|
}
|
|
5243
5019
|
],
|
|
5244
5020
|
"XChainOwnedClaimID": [
|
|
@@ -6090,6 +5866,10 @@
|
|
|
6090
5866
|
{
|
|
6091
5867
|
"name": "DestinationTag",
|
|
6092
5868
|
"optionality": 1
|
|
5869
|
+
},
|
|
5870
|
+
{
|
|
5871
|
+
"name": "CredentialIDs",
|
|
5872
|
+
"optionality": 1
|
|
6093
5873
|
}
|
|
6094
5874
|
],
|
|
6095
5875
|
"LoanBrokerDelete": [
|
|
@@ -6730,6 +6510,18 @@
|
|
|
6730
6510
|
{
|
|
6731
6511
|
"name": "Scale",
|
|
6732
6512
|
"optionality": 1
|
|
6513
|
+
},
|
|
6514
|
+
{
|
|
6515
|
+
"name": "VaultKind",
|
|
6516
|
+
"optionality": 1
|
|
6517
|
+
},
|
|
6518
|
+
{
|
|
6519
|
+
"name": "SubscriptionDate",
|
|
6520
|
+
"optionality": 1
|
|
6521
|
+
},
|
|
6522
|
+
{
|
|
6523
|
+
"name": "RedemptionDate",
|
|
6524
|
+
"optionality": 1
|
|
6733
6525
|
}
|
|
6734
6526
|
],
|
|
6735
6527
|
"VaultDelete": [
|
|
@@ -6786,6 +6578,10 @@
|
|
|
6786
6578
|
{
|
|
6787
6579
|
"name": "DestinationTag",
|
|
6788
6580
|
"optionality": 1
|
|
6581
|
+
},
|
|
6582
|
+
{
|
|
6583
|
+
"name": "CredentialIDs",
|
|
6584
|
+
"optionality": 1
|
|
6789
6585
|
}
|
|
6790
6586
|
],
|
|
6791
6587
|
"XChainAccountCreateCommit": [
|
|
@@ -7374,5 +7170,5 @@
|
|
|
7374
7170
|
"Vector256": 19,
|
|
7375
7171
|
"XChainBridge": 25
|
|
7376
7172
|
},
|
|
7377
|
-
"hash": "
|
|
7378
|
-
}
|
|
7173
|
+
"hash": "1EA05B0FC11101F7C500BD0DAC794A8BC746A7FBA6250B75489603EB820E0FF5"
|
|
7174
|
+
}
|
|
@@ -8,6 +8,26 @@ module BinaryCodec
|
|
|
8
8
|
|
|
9
9
|
@@instance = nil
|
|
10
10
|
|
|
11
|
+
# The permissions a DelegateSet can grant that are narrower than a whole
|
|
12
|
+
# transaction type. rippled numbers them from 65537 upwards, above the
|
|
13
|
+
# range the transaction types occupy. The table is not part of
|
|
14
|
+
# definitions.json - xrpl.js carries it in code as well
|
|
15
|
+
# (XrplDefinitionsBase#granularPermissions) - so it lives here.
|
|
16
|
+
GRANULAR_PERMISSIONS = {
|
|
17
|
+
'TrustlineAuthorize' => 65_537,
|
|
18
|
+
'TrustlineFreeze' => 65_538,
|
|
19
|
+
'TrustlineUnfreeze' => 65_539,
|
|
20
|
+
'AccountDomainSet' => 65_540,
|
|
21
|
+
'AccountEmailHashSet' => 65_541,
|
|
22
|
+
'AccountMessageKeySet' => 65_542,
|
|
23
|
+
'AccountTransferRateSet' => 65_543,
|
|
24
|
+
'AccountTickSizeSet' => 65_544,
|
|
25
|
+
'PaymentMint' => 65_545,
|
|
26
|
+
'PaymentBurn' => 65_546,
|
|
27
|
+
'MPTokenIssuanceLock' => 65_547,
|
|
28
|
+
'MPTokenIssuanceUnlock' => 65_548
|
|
29
|
+
}.freeze
|
|
30
|
+
|
|
11
31
|
def initialize
|
|
12
32
|
file_path = File.join(__dir__, 'definitions.json') #
|
|
13
33
|
contents = File.read(file_path)
|
|
@@ -18,6 +38,15 @@ module BinaryCodec
|
|
|
18
38
|
@transaction_results = @definitions['TRANSACTION_RESULTS']
|
|
19
39
|
@transaction_types = @definitions['TRANSACTION_TYPES']
|
|
20
40
|
|
|
41
|
+
# PermissionValue names a delegatable permission. A whole transaction
|
|
42
|
+
# type is its type code plus one, so that Payment (type 0) is not
|
|
43
|
+
# confused with "no permission"; the granular permissions follow above.
|
|
44
|
+
@delegatable_permissions = @transaction_types
|
|
45
|
+
.reject { |_, code| code.negative? }
|
|
46
|
+
.transform_values { |code| code + 1 }
|
|
47
|
+
.merge(GRANULAR_PERMISSIONS)
|
|
48
|
+
.freeze
|
|
49
|
+
|
|
21
50
|
@field_info_map = {}
|
|
22
51
|
@field_id_name_map = {}
|
|
23
52
|
@field_header_map = {}
|
|
@@ -55,6 +84,11 @@ module BinaryCodec
|
|
|
55
84
|
attr_reader :definitions
|
|
56
85
|
alias raw definitions
|
|
57
86
|
|
|
87
|
+
# Name -> code tables, for the types that render as names in JSON.
|
|
88
|
+
# @return [Hash{String => Integer}]
|
|
89
|
+
attr_reader :transaction_types, :ledger_entry_types, :transaction_results,
|
|
90
|
+
:delegatable_permissions
|
|
91
|
+
|
|
58
92
|
# Returns the singleton instance of the Definitions class.
|
|
59
93
|
# @return [Definitions] The singleton instance.
|
|
60
94
|
def self.instance
|
|
@@ -77,9 +111,12 @@ module BinaryCodec
|
|
|
77
111
|
|
|
78
112
|
# Returns a FieldInstance for a given field name.
|
|
79
113
|
# @param field_name [String] The name of the field.
|
|
80
|
-
# @return [FieldInstance] The field instance
|
|
114
|
+
# @return [FieldInstance, nil] The field instance, nil for a name the
|
|
115
|
+
# definitions do not know
|
|
81
116
|
def get_field_instance(field_name)
|
|
82
117
|
field_info = @field_info_map[field_name]
|
|
118
|
+
return nil if field_info.nil?
|
|
119
|
+
|
|
83
120
|
field_header = get_field_header_from_name(field_name)
|
|
84
121
|
|
|
85
122
|
FieldInstance.new(
|
|
@@ -47,7 +47,13 @@ module BinaryCodec
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
field_header = field.header
|
|
50
|
-
|
|
50
|
+
# A UInt reads a String by its field: a UInt64 is hex, or decimal in a
|
|
51
|
+
# base-10 field.
|
|
52
|
+
associated_value = if field.associated_type <= Uint
|
|
53
|
+
field.associated_type.from(value, field.name)
|
|
54
|
+
else
|
|
55
|
+
field.associated_type.from(value)
|
|
56
|
+
end
|
|
51
57
|
|
|
52
58
|
@sink.put(field_header.to_bytes)
|
|
53
59
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
module BinaryCodec
|
|
4
4
|
class STArray < SerializedType
|
|
5
5
|
ARRAY_END_MARKER = 0xF1
|
|
6
|
+
OBJECT_END_MARKER = 0xE1
|
|
6
7
|
|
|
7
8
|
def initialize(byte_buf = nil)
|
|
8
9
|
super(byte_buf || [])
|
|
@@ -35,7 +36,11 @@ module BinaryCodec
|
|
|
35
36
|
|
|
36
37
|
obj = STObject.from(field_value, nil, definitions)
|
|
37
38
|
bytes.concat(obj.to_bytes)
|
|
38
|
-
|
|
39
|
+
# Every element is closed by its own ObjectEndMarker. Testing the
|
|
40
|
+
# last byte for 0xE1 instead dropped it whenever the element
|
|
41
|
+
# happened to end in that byte - an AccountID, a Memo, or a nested
|
|
42
|
+
# object, whose own marker is 0xE1 too.
|
|
43
|
+
bytes.concat([OBJECT_END_MARKER])
|
|
39
44
|
else
|
|
40
45
|
raise StandardError, "STArray item must be a Hash, got #{item.class}"
|
|
41
46
|
end
|
|
@@ -70,7 +75,7 @@ module BinaryCodec
|
|
|
70
75
|
# Reconstruct the serialized item: [FieldHeader][STObject][ObjectEndMarker]
|
|
71
76
|
bytes.concat(field_header.to_bytes)
|
|
72
77
|
bytes.concat(obj.to_bytes)
|
|
73
|
-
bytes.concat([
|
|
78
|
+
bytes.concat([OBJECT_END_MARKER])
|
|
74
79
|
end
|
|
75
80
|
|
|
76
81
|
# The ArrayEndMarker has to go back in. Without it the reconstructed
|
|
@@ -100,20 +100,16 @@ module BinaryCodec
|
|
|
100
100
|
list = BytesList.new
|
|
101
101
|
bytes = BinarySerializer.new(list)
|
|
102
102
|
|
|
103
|
+
# Malformed input raises rather than ending the object early: a silent
|
|
104
|
+
# break here returned a truncated object that nothing could trace.
|
|
103
105
|
until parser.end?
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
break if field.name == OBJECT_END_MARKER
|
|
106
|
+
field = parser.read_field
|
|
107
|
+
break if field.name == OBJECT_END_MARKER
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
associated_value = parser.read_field_value(field)
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
rescue => e
|
|
113
|
-
# If we fail to read a field (e.g. unknown header), we might have hit
|
|
114
|
-
# the end of the object without an end marker, or just malformed data.
|
|
115
|
-
break
|
|
116
|
-
end
|
|
111
|
+
# Closes a nested STObject with its ObjectEndMarker itself.
|
|
112
|
+
bytes.write_field_and_value(field, associated_value)
|
|
117
113
|
end
|
|
118
114
|
|
|
119
115
|
STObject.new(list.to_bytes)
|