xpring-eng / XpringKit

XpringKit provides a Swift SDK for interacting with Xpring Protocols (XRP/PayID/ILP). This library is deprecated.
https://xrpl.org/
MIT License
26 stars 14 forks source link

(1/3 Swift) Refactors prepare/sign/submit/await logic for re-use in other transaction types #260

Closed amiecorso closed 4 years ago

amiecorso commented 4 years ago

High Level Overview of Change

In preparation to include additional transaction types in the XRPClient, this PR refactors the code for preparing and submitting transactions into private reusable helper functions.

Specifically,

prepareBaseTransaction constructs and returns a Transaction protobuf object that has been populated with the required and recommended common fields (https://xrpl.org/transaction-common-fields.html) necessary for all transaction types.

signAndSubmitTransaction takes a completed Transaction protobuf object and handles the signing and submitting process.

awaitFinalTransactionResult handles the reliable submission logic of waiting for the transaction to either be included in a validated ledger or pass its lastLedgerSequence, at which point the result code of the transaction can be considered final.

The logic for constructing and submitting an arbitrary transaction type would now be:

Context of Change

Type of Change

Before / After

Common transaction submission steps are now reusable.

Test Plan

CI still passes

codecov[bot] commented 4 years ago

Codecov Report

Merging #260 into master will decrease coverage by 0.00%. The diff coverage is 95.34%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #260      +/-   ##
==========================================
- Coverage   90.01%   90.01%   -0.01%     
==========================================
  Files          42       42              
  Lines         941      951      +10     
==========================================
+ Hits          847      856       +9     
- Misses         94       95       +1     
Impacted Files Coverage Δ
XpringKit/XRP/DefaultXRPClient.swift 98.01% <93.75%> (-0.59%) :arrow_down:
XpringKit/XRP/ReliableSubmissionXRPClient.swift 94.44% <100.00%> (+0.21%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f47a93f...67f2eff. Read the comment docs.