Skip to content

Commit 786db5e

Browse files
authored
fix: better formatting handling in definitions script (#879)
1 parent bc5e170 commit 786db5e

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

tools/generate_definitions.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ def _add_line(line: str) -> None:
171171
# Example line:
172172
# STYPE(STI_UINT32, 2) \
173173
type_hits = re.findall(
174-
r"^ *STYPE\(STI_([^ ]*?) *, *([0-9-]+) *\) *\\?$", sfield_h, re.MULTILINE
174+
r"^ *STYPE\(STI_([^ ]*?)[ \n]*,[ \n]*([0-9-]+)[ \n]*\)[ \n]*\\?$",
175+
sfield_h,
176+
re.MULTILINE,
175177
)
176178
# name-to-value map - needed for SField processing
177179
type_map = {x[0]: x[1] for x in type_hits}
@@ -204,7 +206,7 @@ def _is_signing_field(t: str, not_signing_field: str) -> str:
204206
# TYPED_SFIELD(sfFee, AMOUNT, 8)
205207
# UNTYPED_SFIELD(sfSigners, ARRAY, 3, SField::sMD_Default, SField::notSigning)
206208
sfield_hits = re.findall(
207-
r"^ *[A-Z]*TYPED_SFIELD *\( *sf([^,\n]*),[ \n]*([^, \n]+)[ \n]*,[ \n]*"
209+
r"^ *[A-Z]*TYPED_SFIELD[ \n]*\([ \n]*sf([^,\n]*),[ \n]*([^, \n]+)[ \n]*,[ \n]*"
208210
r"([0-9]+)(,.*?(notSigning))?",
209211
sfield_macro_file,
210212
re.MULTILINE,
@@ -252,7 +254,8 @@ def _unhex(x: str) -> str:
252254
# Example line:
253255
# LEDGER_ENTRY(ltNFTOKEN_OFFER, 0x0037, NFTokenOffer, nft_offer, ({
254256
lt_hits = re.findall(
255-
r"^ *LEDGER_ENTRY[A-Z_]*\(lt[A-Z_]+ *, *([xX0-9a-fA-F]+) *, *([^,]+), *([^,]+), "
257+
r"^ *LEDGER_ENTRY[A-Z_]*\(lt[A-Z_]+[ \n]*,[ \n]*([xX0-9a-fA-F]+)[ \n]*,[ \n]*"
258+
r"([^,]+),[ \n]*([^,]+), "
256259
r"\({$",
257260
ledger_entries_file,
258261
re.MULTILINE,
@@ -277,7 +280,8 @@ def _unhex(x: str) -> str:
277280

278281
# Parse TER codes
279282
ter_code_hits = re.findall(
280-
r"^ *((tel|tem|tef|ter|tes|tec)[A-Z_]+)( *= *([0-9-]+))? *,? *(\/\/[^\n]*)?$",
283+
r"^ *((tel|tem|tef|ter|tes|tec)[A-Z_]+)([ \n]*=[ \n]*([0-9-]+))?[ \n]*,?[ \n]*"
284+
r"(\/\/[^\n]*)?$",
281285
ter_h,
282286
re.MULTILINE,
283287
)
@@ -321,7 +325,7 @@ def _unhex(x: str) -> str:
321325
# Example line:
322326
# TRANSACTION(ttCHECK_CREATE, 16, CheckCreate, ({
323327
tx_hits = re.findall(
324-
r"^ *TRANSACTION\(tt[A-Z_]+ *,* ([0-9]+) *, *([A-Za-z]+).*$",
328+
r"^ *TRANSACTION\(tt[A-Z_]+[ \n]*,[ \n]*([0-9]+)[ \n]*,[ \n]*([A-Za-z]+).*$",
325329
transactions_file,
326330
re.MULTILINE,
327331
)

xrpl/core/binarycodec/definitions/definitions.json

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,16 @@
680680
"type": "UInt32"
681681
}
682682
],
683+
[
684+
"MutableFlags",
685+
{
686+
"isSerialized": true,
687+
"isSigningField": true,
688+
"isVLEncoded": false,
689+
"nth": 53,
690+
"type": "UInt32"
691+
}
692+
],
683693
[
684694
"IndexNext",
685695
{
@@ -2130,6 +2140,16 @@
21302140
"type": "Number"
21312141
}
21322142
],
2143+
[
2144+
"DummyInt32",
2145+
{
2146+
"isSerialized": true,
2147+
"isSigningField": true,
2148+
"isVLEncoded": false,
2149+
"nth": 1,
2150+
"type": "Int32"
2151+
}
2152+
],
21332153
[
21342154
"TransactionMetaData",
21352155
{
@@ -3276,7 +3296,6 @@
32763296
"terLAST": -91,
32773297
"terNO_ACCOUNT": -96,
32783298
"terNO_AMM": -87,
3279-
"tedADDRESS_COLLISION": -86,
32803299
"terNO_AUTH": -95,
32813300
"terNO_LINE": -94,
32823301
"terNO_RIPPLE": -90,
@@ -3342,10 +3361,10 @@
33423361
"TicketCreate": 10,
33433362
"TrustSet": 20,
33443363
"UNLModify": 102,
3345-
"VaultCreate": 65,
33463364
"VaultClawback": 70,
3347-
"VaultDeposit": 68,
3365+
"VaultCreate": 65,
33483366
"VaultDelete": 67,
3367+
"VaultDeposit": 68,
33493368
"VaultSet": 66,
33503369
"VaultWithdraw": 69,
33513370
"XChainAccountCreateCommit": 44,
@@ -3367,6 +3386,8 @@
33673386
"Hash160": 17,
33683387
"Hash192": 21,
33693388
"Hash256": 5,
3389+
"Int32": 10,
3390+
"Int64": 11,
33703391
"Issue": 24,
33713392
"LedgerEntry": 10002,
33723393
"Metadata": 10004,

0 commit comments

Comments
 (0)