Build 336

- Shield trp and save contacts
  - Prepare tx
  - Show summary
  - Confirm fees
- Save draft tx
This commit is contained in:
Hanh 2022-12-25 19:18:11 +08:00
parent f1e2a749d2
commit b8d0fdfda0
10 changed files with 60 additions and 79 deletions

View File

@ -342,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
STRIP_STYLE = "non-global";
@ -426,7 +426,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@ -477,7 +477,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
STRIP_STYLE = "non-global";
@ -568,4 +568,4 @@
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
}

View File

@ -70,5 +70,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>

View File

@ -90,13 +90,12 @@ class ContactsState extends State<ContactsTab> {
}
_onCommit() async {
final approve = await showMessageBox(context, S.of(context).saveToBlockchain,
S.of(context).areYouSureYouWantToSaveYourContactsIt(activeCoin().ticker),
S.of(context).ok);
if (approve) {
final tx = await WarpApi.commitUnsavedContacts(settings.anchorOffset);
showSnackBar(S.of(context).txId(tx));
contacts.markContactsSaved(active.coin, true);
try {
final txPlan = WarpApi.commitUnsavedContacts(settings.anchorOffset);
Navigator.of(context).pushNamed('/txplan', arguments: txPlan);
}
on String catch (msg) {
showSnackBar(msg);
}
}
}

View File

@ -50,6 +50,7 @@ class DualMoneyInputState extends State<DualMoneyInputWidget> {
final amount = amountToString(initialValue, precision(useMillis));
coinAmountController.text = amount;
_updateFxRate();
_updateSlider();
}
void _updateFxRate() {

View File

@ -770,26 +770,14 @@ Future<bool> authenticate(BuildContext context, String reason) async {
}
Future<void> shieldTAddr(BuildContext context) async {
await showDialog(
context: context,
barrierDismissible: false,
builder: (context) =>
AlertDialog(
title: Text(S
.of(context)
.shieldTransparentBalance),
content: Text(S
.of(context)
.doYouWantToTransferYourEntireTransparentBalanceTo(
activeCoin().ticker)),
actions: confirmButtons(context, () async {
final s = S.of(context);
Navigator.of(context).pop();
showSnackBar(s.shieldingInProgress, autoClose: true);
final txid = await WarpApi.shieldTAddr(active.coin, active.id, active.tbalance, settings.anchorOffset);
showSnackBar(s.txId(txid));
})),
);
try {
final txPlan = WarpApi.shieldTAddr(
active.coin, active.id, active.tbalance, settings.anchorOffset);
Navigator.of(context).pushNamed('/txplan', arguments: txPlan);
}
on String catch (msg) {
showSnackBar(msg);
}
}
Future<void> shareCsv(List<List> data, String filename, String title) async {

View File

@ -60,6 +60,7 @@ class SendState extends State<SendPage> {
_replyTo = false;
_subjectController.clear();
_amountKey.currentState?.clear();
active.setDraftRecipient(null);
});
}
@ -75,7 +76,6 @@ class SendState extends State<SendPage> {
_replyTo = draftRecipient.reply_to;
_subjectController.text = draftRecipient.subject;
_memoInitialized = true;
active.setDraftRecipient(null);
}
if (widget.args?.contact != null)
@ -113,6 +113,17 @@ class SendState extends State<SendPage> {
Future(_loadTemplates);
}
@override
void deactivate() {
final form = _formKey.currentState;
if (form != null) {
form.save();
final recipient = _getRecipient();
active.setDraftRecipient(recipient);
}
super.deactivate();
}
@override
void dispose() {
_newBlockAutorunDispose?.call();
@ -371,26 +382,30 @@ class SendState extends State<SendPage> {
}
}
Recipient _getRecipient() {
final amount = amountInput?.amount ?? 0;
final feeIncluded = amountInput?.feeIncluded ?? false;
final memo = _memoController.text;
final subject = _subjectController.text;
final recipient = Recipient(
_address,
amount,
feeIncluded,
_replyTo,
subject,
memo,
0,
);
return recipient;
}
void _onSend() async {
final form = _formKey.currentState;
if (form == null) return;
if (form.validate()) {
form.save();
final amount = amountInput?.amount ?? 0;
final feeIncluded = amountInput?.feeIncluded ?? false;
final memo = _memoController.text;
final subject = _subjectController.text;
final recipient = Recipient(
_address,
amount,
feeIncluded,
_replyTo,
subject,
memo,
0,
);
active.setDraftRecipient(recipient);
final recipient = _getRecipient();
if (!widget.isMulti)
// send closes the page

View File

@ -105,9 +105,11 @@ class TxPlanPage extends StatelessWidget {
final res = await WarpApi.signOnly(
active.coin, active.id, plan, (progress) {
// TODO progressPort.sendPort.send(progress);
// Orchard builder does not support progress reporting yet
});
// TODO progressPort.sendPort.send(0);
active.setBanner("");
active.setDraftRecipient(null);
if (settings.qrOffline) {
navigatorKey.currentState?.pushReplacementNamed(
'/showRawTx', arguments: res);

@ -1 +1 @@
Subproject commit 893e52fe204f77abed001ac16676949c58130738
Subproject commit cd1d84b25d560644ab8933103a881e8a6b3781c7

View File

@ -213,9 +213,9 @@ class WarpApi {
return txId;
}
static Future<String> shieldTAddr(int coin, int account, int amount, int anchorOffset) async {
final txId = await compute(shieldTAddrIsolateFn, ShieldTAddrParams(coin, account, amount, anchorOffset));
return txId;
static String shieldTAddr(int coin, int account, int amount, int anchorOffset) {
final txPlan = warp_api_lib.shield_taddr(coin, account, amount, anchorOffset);
return unwrapResultString(txPlan);
}
static Future<void> scanTransparentAccounts(
@ -303,9 +303,8 @@ class WarpApi {
address.toNativeUtf8().cast<Int8>(), dirty ? 1 : 0);
}
static Future<String> commitUnsavedContacts(int anchorOffset) async {
return compute(
commitUnsavedContactsIsolateFn, CommitContactsParams(anchorOffset));
static String commitUnsavedContacts(int anchorOffset) {
return unwrapResultString(warp_api_lib.commit_unsaved_contacts(anchorOffset));
}
static void markMessageAsRead(int messageId, bool read) {
@ -434,11 +433,6 @@ String transferPoolsIsolateFn(TransferPoolsParams params) {
return unwrapResultString(txId);
}
String shieldTAddrIsolateFn(ShieldTAddrParams params) {
final txId = warp_api_lib.shield_taddr(params.coin, params.account, params.amount, params.anchorOffset);
return unwrapResultString(txId);
}
int syncHistoricalPricesIsolateFn(SyncHistoricalPricesParams params) {
final now = DateTime.now();
final today = DateTime.utc(now.year, now.month, now.day);
@ -448,11 +442,6 @@ int syncHistoricalPricesIsolateFn(SyncHistoricalPricesParams params) {
params.currency.toNativeUtf8().cast<Int8>()));
}
String commitUnsavedContactsIsolateFn(CommitContactsParams params) {
final txId = warp_api_lib.commit_unsaved_contacts(params.anchorOffset);
return unwrapResultString(txId);
}
int getTBalanceIsolateFn(GetTBalanceParams params) {
return unwrapResultU64(warp_api_lib.get_taddr_balance(params.coin, params.account));
}
@ -512,21 +501,6 @@ class TransferPoolsParams {
this.splitAmount, this.anchorOffset);
}
class ShieldTAddrParams {
final int coin;
final int account;
final int amount;
final int anchorOffset;
ShieldTAddrParams(this.coin, this.account, this.amount, this.anchorOffset);
}
class CommitContactsParams {
final int anchorOffset;
CommitContactsParams(this.anchorOffset);
}
class SyncHistoricalPricesParams {
final String currency;

View File

@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.2.17+335
version: 1.2.17+336
environment:
sdk: ">=2.12.0 <3.0.0"