mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-04 21:15:47 +00:00
fix: make transaction-generating scripts more robust (#2690)
* improve scripts * Update settings.json * update file locations after refactor
This commit is contained in:
@@ -11,7 +11,7 @@ function getTx(txName) {
|
||||
.filter((tx) => tx.json.TransactionType === txName)
|
||||
.map((tx) => tx.json)
|
||||
if (validTxs.length == 0) {
|
||||
throw new Error(`Must have ripple-binary-codec fixture for ${txName}`)
|
||||
return '{ /* TODO: add sample transaction */ }'
|
||||
}
|
||||
const validTx = validTxs[0]
|
||||
delete validTx.TxnSignature
|
||||
@@ -74,7 +74,7 @@ function getInvalidValue(paramTypes) {
|
||||
} else if (paramType == 'XChainBridge') {
|
||||
return JSON.stringify({ XChainDoor: 'test' })
|
||||
} else {
|
||||
throw Error(`${paramType} not supported yet`)
|
||||
return '/*TODO*/'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ function getInvalidValue(paramTypes) {
|
||||
} else if (JSON.stringify(simplifiedParamTypes) === '["number","string"]') {
|
||||
return JSON.stringify({ currency: 'ETH' })
|
||||
} else {
|
||||
throw Error(`${simplifiedParamTypes} not supported yet`)
|
||||
return '/*TODO*/'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ let jsTransactionFile
|
||||
|
||||
function processRippledSource(folder) {
|
||||
const sfieldCpp = readFile(
|
||||
path.join(folder, 'src/ripple/protocol/impl/SField.cpp'),
|
||||
path.join(folder, 'src/libxrpl/protocol/SField.cpp'),
|
||||
)
|
||||
const sfieldHits = sfieldCpp.match(
|
||||
/^ *CONSTRUCT_[^\_]+_SFIELD *\( *[^,\n]*,[ \n]*"([^\"\n ]+)"[ \n]*,[ \n]*([^, \n]+)[ \n]*,[ \n]*([0-9]+)(,.*?(notSigning))?/gm,
|
||||
@@ -29,7 +29,7 @@ function processRippledSource(folder) {
|
||||
}
|
||||
|
||||
const txFormatsCpp = readFile(
|
||||
path.join(folder, 'src/ripple/protocol/impl/TxFormats.cpp'),
|
||||
path.join(folder, 'src/libxrpl/protocol/TxFormats.cpp'),
|
||||
)
|
||||
const txFormatsHits = txFormatsCpp.match(
|
||||
/^ *add\(jss::([^\"\n, ]+),[ \n]*tt[A-Z_]+,[ \n]*{[ \n]*(({sf[A-Za-z0-9]+, soe(OPTIONAL|REQUIRED|DEFAULT)},[ \n]+)*)},[ \n]*[pseudocC]+ommonFields\);/gm,
|
||||
@@ -49,10 +49,10 @@ function processRippledSource(folder) {
|
||||
),
|
||||
)
|
||||
const transactionMatch = jsTransactionFile.match(
|
||||
/export type Transaction =([| \nA-Za-z]+)\nexport/,
|
||||
/export type SubmittableTransaction =([| \nA-Za-z]+)\n\/\*\*/,
|
||||
)[0]
|
||||
const existingLibraryTxs = transactionMatch
|
||||
.replace('\n\nexport', '')
|
||||
.replace('\n\n/**', '')
|
||||
.split('\n | ')
|
||||
.filter((value) => !value.includes('export type'))
|
||||
.map((value) => value.trim())
|
||||
@@ -248,6 +248,7 @@ ${validationImportLine}`
|
||||
)
|
||||
|
||||
const validateTests = createValidateTests(tx)
|
||||
if (validateTests !== '')
|
||||
fs.writeFileSync(
|
||||
path.join(path.dirname(__filename), `../test/models/${tx}.test.ts`),
|
||||
validateTests,
|
||||
@@ -259,9 +260,7 @@ ${validationImportLine}`
|
||||
|
||||
console.log(`Added ${tx}`)
|
||||
})
|
||||
console.log(
|
||||
'Future steps: Adding docstrings to the models and adding integration tests',
|
||||
)
|
||||
// TODO: add docstrings to the models and add integration tests
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
|
||||
Reference in New Issue
Block a user