Spam Filter

This commit is contained in:
Hanh 2022-08-02 22:36:46 +08:00
parent 39abcf2d8d
commit 274c73ce88
12 changed files with 52 additions and 7 deletions

View File

@ -105,6 +105,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Amount must be positive"),
"amountTooHigh":
MessageLookupByLibrary.simpleMessage("Amount too high"),
"antispamFilter":
MessageLookupByLibrary.simpleMessage("Anti-Spam Filter"),
"applicationReset":
MessageLookupByLibrary.simpleMessage("Application Reset"),
"approve": MessageLookupByLibrary.simpleMessage("APPROVE"),

View File

@ -105,6 +105,8 @@ class MessageLookup extends MessageLookupByLibrary {
"Cantidad debe ser un positivo"),
"amountTooHigh":
MessageLookupByLibrary.simpleMessage("Cantidad demasiado alta"),
"antispamFilter":
MessageLookupByLibrary.simpleMessage("Anti-Spam Filter"),
"applicationReset":
MessageLookupByLibrary.simpleMessage("Application Reset"),
"approve": MessageLookupByLibrary.simpleMessage("APROBAR"),

View File

@ -106,6 +106,8 @@ class MessageLookup extends MessageLookupByLibrary {
"Le montant doit être positif"),
"amountTooHigh":
MessageLookupByLibrary.simpleMessage("Montant trop haut"),
"antispamFilter":
MessageLookupByLibrary.simpleMessage("Anti-Spam Filter"),
"applicationReset":
MessageLookupByLibrary.simpleMessage("Réinitialisation"),
"approve": MessageLookupByLibrary.simpleMessage("APPROUVER"),

View File

@ -2581,6 +2581,16 @@ class S {
args: [],
);
}
/// `Anti-Spam Filter`
String get antispamFilter {
return Intl.message(
'Anti-Spam Filter',
name: 'antispamFilter',
desc: '',
args: [],
);
}
}
class AppLocalizationDelegate extends LocalizationsDelegate<S> {

View File

@ -251,5 +251,6 @@
"derivationPath": "Derivation Path",
"privateKey": "Private Key",
"keyTool": "Key Tool",
"update": "Recalc"
"update": "Recalc",
"antispamFilter": "Anti-Spam Filter"
}

View File

@ -249,5 +249,6 @@
"derivationPath": "Ruta de Derivación",
"privateKey": "Clave Privada",
"keyTool": "Clave Utilidad",
"update": "Recalcular"
"update": "Recalcular",
"antispamFilter": "Anti-Spam Filter"
}

View File

@ -249,5 +249,6 @@
"derivationPath": "Chemin de Dérivation",
"privateKey": "Clé Privée",
"keyTool": "Clés Utilitaires",
"update": "Recalculer"
"update": "Recalculer",
"antispamFilter": "Anti-Spam Filter"
}

View File

@ -213,9 +213,14 @@ class SettingsState extends State<SettingsPage> with SingleTickerProviderStateMi
onSaved: _shieldBalance),
if (!simpleMode) FormBuilderCheckbox(
name: 'use_cold_qr',
title: Text(S.of(context).useQrForOfflineSigning),
title: Text(s.useQrForOfflineSigning),
initialValue: settings.qrOffline,
onSaved: _qrOffline),
if (!simpleMode) FormBuilderCheckbox(
name: 'antispam',
title: Text(s.antispamFilter),
initialValue: settings.antispam,
onSaved: _antispam),
if (!simpleMode) FormBuilderTextField(
decoration: InputDecoration(
labelText: s.defaultMemo),
@ -295,6 +300,10 @@ class SettingsState extends State<SettingsPage> with SingleTickerProviderStateMi
settings.setProtectOpen(v);
}
_antispam(v) {
settings.setAntiSpam(v);
}
_onSave() async {
final form = _settingsFormKey.currentState!;
if (form.validate()) {

View File

@ -181,6 +181,9 @@ abstract class _Settings with Store {
@observable
bool flat = false;
@observable
bool antispam = false;
@action
Future<bool> restore() async {
final prefs = await SharedPreferences.getInstance();
@ -213,6 +216,7 @@ abstract class _Settings with Store {
prefs.getInt('secondary.variant') ?? Colors.greenAccent.value;
memoSignature = prefs.getString('memo_signature');
antispam = prefs.getBool('antispam') ?? false;
for (var s in servers) {
await s.loadPrefs();
@ -272,6 +276,13 @@ abstract class _Settings with Store {
prefs.setInt('anchor_offset', offset);
}
@action
Future<void> setAntiSpam(bool v) async {
final prefs = await SharedPreferences.getInstance();
antispam = v;
prefs.setBool('antispam', antispam);
}
@action
Future<void> setGapLimit(int _gapLimit) async {
final prefs = await SharedPreferences.getInstance();
@ -605,6 +616,7 @@ abstract class _SyncStatus with Store {
if (!isSynced()) {
final params = SyncParams(
active.coin, settings.getTx, settings.anchorOffset,
settings.antispam ? 20 : 1000000,
syncPort.sendPort);
final res = await compute(WarpApi.warpSync, params);
if (res == 0) {

@ -1 +1 @@
Subproject commit 82a1872cccc355558794d3d926507ddf99cde647
Subproject commit fd53c1cb315ca2d9ee5062edda61c065108a7d5d

View File

@ -86,7 +86,7 @@ class WarpApi {
}
static int warpSync(SyncParams params) {
final res = warp_api_lib.warp(params.coin, params.getTx ? 1 : 0, params.anchorOffset, params.port!.nativePort);
final res = warp_api_lib.warp(params.coin, params.getTx ? 1 : 0, params.anchorOffset, params.maxCost, params.port!.nativePort);
params.port!.send(null);
return res;
}
@ -433,9 +433,10 @@ class SyncParams {
final int coin;
final bool getTx;
final int anchorOffset;
final int maxCost;
final SendPort? port;
SyncParams(this.coin, this.getTx, this.anchorOffset, this.port);
SyncParams(this.coin, this.getTx, this.anchorOffset, this.maxCost, this.port);
}
class PaymentParams {

View File

@ -235,12 +235,14 @@ class NativeLibrary {
int coin,
int get_tx,
int anchor_offset,
int max_cost,
int port,
) {
return _warp(
coin,
get_tx,
anchor_offset,
max_cost,
port,
);
}
@ -885,6 +887,7 @@ typedef _c_warp = ffi.Uint8 Function(
ffi.Uint8 coin,
ffi.Int8 get_tx,
ffi.Uint32 anchor_offset,
ffi.Uint32 max_cost,
ffi.Int64 port,
);
@ -892,6 +895,7 @@ typedef _dart_warp = int Function(
int coin,
int get_tx,
int anchor_offset,
int max_cost,
int port,
);