Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPT #2661

Merged
merged 61 commits into from
Dec 11, 2024
Merged

MPT #2661

Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
2f04983
initial commit
shawnxie999 Feb 13, 2024
cd73e1b
wip
shawnxie999 Feb 14, 2024
da51954
revert bad changes
shawnxie999 Feb 15, 2024
0d2af85
definitions
shawnxie999 Feb 15, 2024
2ee5d88
export
shawnxie999 Feb 15, 2024
134b977
MPT create (wip)
shawnxie999 Feb 16, 2024
ba890ca
issuancecreate
shawnxie999 Feb 21, 2024
54648a8
destroy tx
shawnxie999 Feb 21, 2024
05a831c
mptset tx
shawnxie999 Feb 21, 2024
24dc137
authorize tx
shawnxie999 Feb 22, 2024
7ea0aba
payment + clawback (wip)
shawnxie999 Mar 6, 2024
229a0c7
wip
shawnxie999 Mar 7, 2024
cfc7979
fix binary codec test fail
shawnxie999 Mar 7, 2024
d53ef0e
has192 test
shawnxie999 Mar 7, 2024
034bebb
amount simple serialization test
shawnxie999 Mar 7, 2024
8449439
fix test
shawnxie999 Mar 8, 2024
a11a395
some amount tests
shawnxie999 Mar 11, 2024
0ff4169
more tests
shawnxie999 Mar 12, 2024
02d78ee
some hex value tests
shawnxie999 Mar 12, 2024
11ce368
negative amount test
shawnxie999 Mar 13, 2024
3d56868
rename mptDecimalToHex
shawnxie999 Mar 14, 2024
a9d5a9b
history.md
shawnxie999 Apr 22, 2024
3093e38
only apply mptamount for payment and claw
shawnxie999 Apr 22, 2024
58aca14
fix test and update to latest definition
shawnxie999 Jul 8, 2024
5e55b80
Merge remote-tracking branch 'upstream/main' into mpt
shawnxie999 Jul 9, 2024
542c201
update definitoin.json
shawnxie999 Aug 21, 2024
637347c
add object type def and filter by type
shawnxie999 Aug 21, 2024
7d43a14
add mpt payment
shawnxie999 Aug 21, 2024
e885c3a
fix bad comment and improvements
shawnxie999 Aug 21, 2024
613c306
Merge branch 'main' into mpt
shawnxie999 Aug 22, 2024
ca53e51
update definition with ledgerstatefix
shawnxie999 Sep 4, 2024
25ea3d3
wip
shawnxie999 Sep 13, 2024
a6f3738
binary codec test
shawnxie999 Sep 13, 2024
cb92806
tests
shawnxie999 Oct 1, 2024
d367a83
Merge pull request #1 from shawnxie999/mpt-base10
shawnxie999 Oct 1, 2024
f69fc74
update definitions.json
shawnxie999 Oct 9, 2024
6461315
Merge remote-tracking branch 'upstream/main' into mpt
shawnxie999 Oct 9, 2024
458f0b8
fix failed test
shawnxie999 Oct 9, 2024
32ea011
fix lint
shawnxie999 Oct 9, 2024
7529657
fix lint errors
shawnxie999 Oct 9, 2024
46c66e5
fix more lint
shawnxie999 Oct 9, 2024
9bfb200
const to let
shawnxie999 Oct 10, 2024
92efe13
Rename MPTokenHolder to Holder (#2)
shawnxie999 Oct 28, 2024
143de08
fix failing binary codec test
shawnxie999 Nov 1, 2024
14603ad
Merge branch 'main' into mpt
shawnxie999 Nov 13, 2024
e7da4dc
add index
shawnxie999 Nov 13, 2024
d861672
Merge branch 'main' into mpt
shawnxie999 Dec 5, 2024
e42b015
Address code comments
shawnxie999 Dec 6, 2024
bd9b190
Code comments
shawnxie999 Dec 6, 2024
e6b5c23
docker
shawnxie999 Dec 6, 2024
5111266
rippled cfg
shawnxie999 Dec 6, 2024
1668e76
lint
shawnxie999 Dec 6, 2024
0a660e9
lint
shawnxie999 Dec 6, 2024
a8f5abf
code rabbits
shawnxie999 Dec 6, 2024
f7259bf
lint
shawnxie999 Dec 6, 2024
0223d93
lint
shawnxie999 Dec 6, 2024
7840311
config comment
shawnxie999 Dec 9, 2024
3d475d8
Merge branch 'main' into mpt
shawnxie999 Dec 9, 2024
ccf54de
add optional field check
shawnxie999 Dec 9, 2024
93fcb98
Merge branch 'main' into mpt
shawnxie999 Dec 9, 2024
46814fa
Update packages/xrpl/src/models/transactions/MPTokenIssuanceCreate.ts
shawnxie999 Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update definitions.json
shawnxie999 committed Oct 9, 2024
commit f69fc7425b4f535ac0787b1759c4871f4c6bcfb1
39 changes: 13 additions & 26 deletions packages/ripple-binary-codec/src/enums/definitions.json
Original file line number Diff line number Diff line change
@@ -1112,20 +1112,10 @@
"type": "UInt64"
}
],
[
"LockedAmount",
{
"nth": 26,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt64"
}
],
[
"MPTAmount",
{
"nth": 27,
"nth": 26,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
@@ -2890,17 +2880,17 @@
"temUNKNOWN": -264,
"temSEQ_AND_TICKET": -263,
"temBAD_NFTOKEN_TRANSFER_FEE": -262,
"temBAD_MPTOKEN_TRANSFER_FEE": -261,
"temBAD_AMM_TOKENS": -260,
"temXCHAIN_EQUAL_DOOR_ACCOUNTS": -259,
"temXCHAIN_BAD_PROOF": -258,
"temXCHAIN_BRIDGE_BAD_ISSUES": -257,
"temXCHAIN_BRIDGE_NONDOOR_OWNER": -256,
"temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -255,
"temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -254,
"temEMPTY_DID": -253,
"temARRAY_EMPTY": -252,
"temARRAY_TOO_LARGE": -251,
"temBAD_AMM_TOKENS": -261,
"temXCHAIN_EQUAL_DOOR_ACCOUNTS": -260,
"temXCHAIN_BAD_PROOF": -259,
"temXCHAIN_BRIDGE_BAD_ISSUES": -258,
"temXCHAIN_BRIDGE_NONDOOR_OWNER": -257,
"temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -256,
"temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -255,
"temEMPTY_DID": -254,
"temARRAY_EMPTY": -253,
"temARRAY_TOO_LARGE": -252,
"temBAD_TRANSFER_FEE": -251,

"tefFAILURE": -199,
"tefALREADY": -198,
@@ -3018,10 +3008,7 @@
"tecTOKEN_PAIR_NOT_FOUND": 189,
"tecARRAY_EMPTY": 190,
"tecARRAY_TOO_LARGE": 191,
"tecMPTOKEN_EXISTS": 192,
"tecMPT_MAX_AMOUNT_EXCEEDED": 193,
"tecMPT_LOCKED": 194,
"tecMPT_NOT_SUPPORTED": 195
"tecLOCKED": 192
},
"TRANSACTION_TYPES": {
"Invalid": -1,
22 changes: 10 additions & 12 deletions packages/ripple-binary-codec/src/types/uint-64.ts
Original file line number Diff line number Diff line change
@@ -8,6 +8,14 @@ const HEX_REGEX = /^[a-fA-F0-9]{1,16}$/
const BASE10_REGEX = /^[0-9]{1,20}$/
const mask = BigInt(0x00000000ffffffff)

function useBase10(fieldName: string): boolean {
return (
fieldName === 'MaximumAmount' ||
fieldName === 'OutstandingAmount' ||
fieldName === 'MPTAmount'
)
}
Comment on lines +11 to +17
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using a Set for field names in useBase10 function.

To enhance scalability and performance, especially if more fields are added in the future, consider using a Set to store field names. This approach simplifies the addition of new fields and improves lookup efficiency.

Apply this refactor:

+const BASE10_FIELDS = new Set(['MaximumAmount', 'OutstandingAmount', 'MPTAmount'])

-function useBase10(fieldName: string): boolean {
-  return (
-    fieldName === 'MaximumAmount' ||
-    fieldName === 'OutstandingAmount' ||
-    fieldName === 'MPTAmount'
-  )
+function useBase10(fieldName: string): boolean {
+  return BASE10_FIELDS.has(fieldName)
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function useBase10(fieldName: string): boolean {
return (
fieldName === 'MaximumAmount' ||
fieldName === 'OutstandingAmount' ||
fieldName === 'MPTAmount'
)
}
const BASE10_FIELDS = new Set(['MaximumAmount', 'OutstandingAmount', 'MPTAmount'])
function useBase10(fieldName: string): boolean {
return BASE10_FIELDS.has(fieldName)
}


/**
* Derived UInt class for serializing/deserializing 64 bit UInt
*/
@@ -56,12 +64,7 @@ class UInt64 extends UInt {
}

if (typeof val === 'string') {
if (
fieldName == 'MaximumAmount' ||
fieldName == 'OutstandingAmount' ||
fieldName == 'LockedAmount' ||
fieldName == 'MPTAmount'
) {
if (useBase10(fieldName)) {
if (!BASE10_REGEX.test(val)) {
throw new Error(`${fieldName} ${val} is not a valid base 10 string`)
}
@@ -98,12 +101,7 @@ class UInt64 extends UInt {
fieldName: string = '',
): string {
const hexString = bytesToHex(this.bytes)
if (
fieldName == 'MaximumAmount' ||
fieldName == 'OutstandingAmount' ||
fieldName == 'LockedAmount' ||
fieldName == 'MPTAmount'
) {
if (useBase10(fieldName)) {
return BigInt('0x' + hexString).toString(10)
}