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

[ABW-1316] Split out signing and submission from TransactionClient, introduce Signing feature (prepares for signing w Ledger) #455

Merged
merged 58 commits into from
Apr 28, 2023

Conversation

CyonAlexRDX
Copy link
Contributor

@CyonAlexRDX CyonAlexRDX commented Apr 25, 2023

JIRA ABW-1316

This PR does NOT implement signing with Ledger as git branch name might suggest. That will follow in subsequent PR. This PR does however prepare for signing with factor sources which requires UI flow.

This PR splits out:

  • signing
  • submit tx
    from TransactionClient

Signing is moved into VIEW layer, a Feature called Signing.

Furthermore, this PR introduces a picker for Fee Payer. It drastically reduces complexity of TransactionClient, by use of an ephemeral notary key pair.

I've simplified TransactionClient a lot by removing the Result stuff. TransactionClient goes from 800 loc to 400 loc. 🎉

The best this PR can do is to not break anything and work just as well with the currently only supported factor source: .device.

Demo

Select fee payer

Look at slack

Two signers

This demonstrates signing with TWO accounts.
https://user-images.githubusercontent.com/116169792/235083340-43d88f0d-40e0-4d18-9f9b-60744fe3309f.MOV

CALL TO ACTION

@kugel3 We REALLY REALLY should after this PR get merged change TransactionReview Reducer, by introducing a new coordinating Reducer called... perhaps Transact which coordinates:

  • TransactionReview
  • signing (new by this PR)
  • submitting (new by this PR)

@CyonAlexRDX CyonAlexRDX changed the title Abw 1316 sign tx with ledger [ABW-1316] WIP Sign tx with ledger WIP Apr 25, 2023
@CyonAlexRDX CyonAlexRDX marked this pull request as ready for review April 27, 2023 11:53
case let .failedToGetTransactionStatus(txID, _):
return (errorKind: .failedToPollSubmittedTransaction, message: "TXID: \(txID)")
}
// case let .failedToSubmit(error):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to be fixed... by someone :P

return error.localizedDescription
case .failedToSubmit:
return "Failed to submit tx"
// case let .failedToSubmit(error):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to be fixed... by someone :P

Copy link
Contributor

@GhenadieVP GhenadieVP left a comment

Choose a reason for hiding this comment

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

Only managed to review 1/5 of the PR, will continue tomorrow morning.

if pollCount >= pollStrategy.maxPollTries {
statusSubject.send(.init(
txID: txID,
result: .failure(.failedToGetTransactionStatus(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this breaks the while loop, since failure => isComplete: true.

else {
throw FailedToDeviceFactorSourceForSigning()
}
let hdRoot = try loadedMnemonicWithPassphrase.hdRoot()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a huge improvement, this does not require any "cache" of mnemonics we had earlier, since we sign with all accounts for this hdRoot "in one go".

@@ -0,0 +1,32 @@
import FeaturePrelude

extension SignWithLedgerFactorSource.State {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Empty / Not impl for now, to be impl in coming PR

import FeaturePrelude

// MARK: - SignWithLedgerFactorSource
public struct SignWithLedgerFactorSource: SignWithFactorReducerProtocol {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Empty / Not impl for now, to be impl in coming PR

Copy link
Contributor

@GhenadieVP GhenadieVP left a comment

Choose a reason for hiding this comment

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

LGTM overall, awesome job!!!

@CyonAlexRDX CyonAlexRDX merged commit bf42486 into main Apr 28, 2023
@CyonAlexRDX CyonAlexRDX deleted the ABW-1316_sign_tx_with_ledger branch April 28, 2023 10:52
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants