-
Notifications
You must be signed in to change notification settings - Fork 500
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
Aliter: Implement DeliverMax alias in Payment transactions, through autofill method #2689
base: main
Are you sure you want to change the base?
Conversation
@@ -46,6 +47,121 @@ describe('client.autofill', function () { | |||
}) | |||
afterEach(async () => teardownClient(testContext)) | |||
|
|||
it('Validate Payment transaction v2 API: Payment Transaction: Specify Only Amount field', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My conundrum: this unit test fails:
it('Validate Payment transaction v2 API: Payment Transaction: lack of DeliverMax and Amount fields', async function () {
const amount_ = '1234'
const deliverMax_ = '5678'
const paytxn = {
TransactionType: 'Payment',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
DestinationTag: 1,
Fee: '12',
Flags: 2147483648,
LastLedgerSequence: 65953073,
Sequence: 65923914,
SigningPubKey:
'02F9E33F16DF9507705EC954E3F94EB5F10D1FC4A354606DBE6297DBB1096FE654',
TxnSignature:
'3045022100E3FAE0EDEC3D6A8FF6D81BC9CF8288A61B7EEDE8071E90FF9314CB4621058D10022043545CF631706D700CEE65A1DB83EFDD185413808292D9D90F14D87D3DC2D8CB',
InvoiceID:
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
Paths: [
[{ currency: 'BTC', issuer: 'r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X' }],
],
SendMax: '100000000',
} as any
# this error is never thrown
await assertRejects(testContext.client.autofill(paytxn), XrplError)
})
My code change did not affect the behavior of this unit test. But the lack of Amount
or DeliverMax
field is something that a client library should catch.
This probably needs to be tackled in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why it should fail here - that's checked in validate
, which is checked at signing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, that was my confusion. I thought this validation happened in autofill too, my bad
Do you guys have any ideas for complying with lint errors? For instance:
|
@mvadari Do you have any workarounds for the lint errors? type-erasure does not seem to sit well with the linter. |
Feel free to disable the linter error for that line. |
thanks, I've fixed the linter errors and warnings. I didn't realize that I could ignore the errors and get away with it haha I think it's safe to ignore the linter errors because, a malformed input is sure to through an error in signing or serialization steps. |
@@ -666,7 +667,57 @@ class Client extends EventEmitter<EventTypes> { | |||
promises.push(checkAccountDeleteBlockers(this, tx)) | |||
} | |||
|
|||
return Promise.all(promises).then(() => tx) | |||
// further manipulation of tx_ uses non-SubmittableTransaction types, hence we need a typecast to any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have ideas for implementing this in a more clean fashion (fewer eslint-disable
commands), please let me know
High Level Overview of Change
This is an alternative solution for the DeliverMax alias, inspired from this discussion: #2684 (comment)
Note: Only one of these two PRs must be merged.
Both the PRs seek to achieve the same objectives, albeit through different means.
Context of Change
Type of Change
Did you update HISTORY.md?
Test Plan
Added unit tests