diff --git a/config/gva_endpoints.json b/config/gva_endpoints.json index 541e9fb..1533920 100644 --- a/config/gva_endpoints.json +++ b/config/gva_endpoints.json @@ -1,5 +1,3 @@ [ - "https://g1.librelois.fr/gva", - "https://duniter-gva.axiom-team.fr/gva", - "https://duniter-g1.p2p.legal/gva" + "https://g1.librelois.fr/gva" ] diff --git a/lib/globals.dart b/lib/globals.dart index 1745811..5571b50 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -22,7 +22,8 @@ late Box configBox; late Box g1WalletsBox; // late Box keystoreBox; -String cesiumPod = "https://g1.data.le-sou.org"; +// String cesiumPod = "https://g1.data.le-sou.org"; +String cesiumPod = "https://g1.data.presles.fr"; // String cesiumPod = "https://g1.data.e-is.pro"; // Responsive ratios diff --git a/lib/main.dart b/lib/main.dart index 31f98c0..e0b29da 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,7 +20,6 @@ import 'dart:io'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/providers/cesium_plus.dart'; -import 'package:gecko/providers/change_pin.dart'; import 'package:gecko/models/chest_data.dart'; import 'package:gecko/providers/chest_provider.dart'; import 'package:gecko/models/g1_wallets_list.dart'; @@ -71,17 +70,18 @@ Future main() async { walletBox = await Hive.openBox("walletBox"); chestBox = await Hive.openBox("chestBox"); configBox = await Hive.openBox("configBox"); + await Hive.deleteBoxFromDisk('g1WalletsBox'); g1WalletsBox = await Hive.openBox("g1WalletsBox"); // keystoreBox = await Hive.openBox("keystoreBox"); - g1WalletsBox.clear(); + // g1WalletsBox.clear(); // final HiveStore _store = // await HiveStore.open(path: '${appPath.path}/gqlCache'); // Get a valid GVA endpoint - // endPointGVA = 'https://g1.librelois.fr/gva'; - endPointGVA = 'https://duniter-g1.p2p.legal/gva'; + endPointGVA = 'https://g1.librelois.fr/gva'; + // endPointGVA = 'https://duniter-g1.p2p.legal/gva'; // await _homeProvider.getValidEndpoint(); // if (endPointGVA == 'HS') { @@ -156,7 +156,6 @@ class Gecko extends StatelessWidget { ChangeNotifierProvider(create: (_) => ChestProvider()), ChangeNotifierProvider(create: (_) => GenerateWalletsProvider()), ChangeNotifierProvider(create: (_) => WalletOptionsProvider()), - ChangeNotifierProvider(create: (_) => ChangePinProvider()), ChangeNotifierProvider(create: (_) => SearchProvider()), ChangeNotifierProvider(create: (_) => CesiumPlusProvider()), ChangeNotifierProvider(create: (_) => SubstrateSdk()) diff --git a/lib/models/bip39_words.dart b/lib/models/bip39_words.dart index 0809642..82ec9c9 100644 --- a/lib/models/bip39_words.dart +++ b/lib/models/bip39_words.dart @@ -1,4 +1,2066 @@ -List bip39Words = [ +List bip39Words(String lang) { + switch (lang) { + case 'english': + return _english; + case 'french': + return _french; + default: + return _english; + } +} + +List _english = [ + 'abandon', + 'ability', + 'able', + 'about', + 'above', + 'absent', + 'absorb', + 'abstract', + 'absurd', + 'abuse', + 'access', + 'accident', + 'account', + 'accuse', + 'achieve', + 'acid', + 'acoustic', + 'acquire', + 'across', + 'act', + 'action', + 'actor', + 'actress', + 'actual', + 'adapt', + 'add', + 'addict', + 'address', + 'adjust', + 'admit', + 'adult', + 'advance', + 'advice', + 'aerobic', + 'affair', + 'afford', + 'afraid', + 'again', + 'age', + 'agent', + 'agree', + 'ahead', + 'aim', + 'air', + 'airport', + 'aisle', + 'alarm', + 'album', + 'alcohol', + 'alert', + 'alien', + 'all', + 'alley', + 'allow', + 'almost', + 'alone', + 'alpha', + 'already', + 'also', + 'alter', + 'always', + 'amateur', + 'amazing', + 'among', + 'amount', + 'amused', + 'analyst', + 'anchor', + 'ancient', + 'anger', + 'angle', + 'angry', + 'animal', + 'ankle', + 'announce', + 'annual', + 'another', + 'answer', + 'antenna', + 'antique', + 'anxiety', + 'any', + 'apart', + 'apology', + 'appear', + 'apple', + 'approve', + 'april', + 'arch', + 'arctic', + 'area', + 'arena', + 'argue', + 'arm', + 'armed', + 'armor', + 'army', + 'around', + 'arrange', + 'arrest', + 'arrive', + 'arrow', + 'art', + 'artefact', + 'artist', + 'artwork', + 'ask', + 'aspect', + 'assault', + 'asset', + 'assist', + 'assume', + 'asthma', + 'athlete', + 'atom', + 'attack', + 'attend', + 'attitude', + 'attract', + 'auction', + 'audit', + 'august', + 'aunt', + 'author', + 'auto', + 'autumn', + 'average', + 'avocado', + 'avoid', + 'awake', + 'aware', + 'away', + 'awesome', + 'awful', + 'awkward', + 'axis', + 'baby', + 'bachelor', + 'bacon', + 'badge', + 'bag', + 'balance', + 'balcony', + 'ball', + 'bamboo', + 'banana', + 'banner', + 'bar', + 'barely', + 'bargain', + 'barrel', + 'base', + 'basic', + 'basket', + 'battle', + 'beach', + 'bean', + 'beauty', + 'because', + 'become', + 'beef', + 'before', + 'begin', + 'behave', + 'behind', + 'believe', + 'below', + 'belt', + 'bench', + 'benefit', + 'best', + 'betray', + 'better', + 'between', + 'beyond', + 'bicycle', + 'bid', + 'bike', + 'bind', + 'biology', + 'bird', + 'birth', + 'bitter', + 'black', + 'blade', + 'blame', + 'blanket', + 'blast', + 'bleak', + 'bless', + 'blind', + 'blood', + 'blossom', + 'blouse', + 'blue', + 'blur', + 'blush', + 'board', + 'boat', + 'body', + 'boil', + 'bomb', + 'bone', + 'bonus', + 'book', + 'boost', + 'border', + 'boring', + 'borrow', + 'boss', + 'bottom', + 'bounce', + 'box', + 'boy', + 'bracket', + 'brain', + 'brand', + 'brass', + 'brave', + 'bread', + 'breeze', + 'brick', + 'bridge', + 'brief', + 'bright', + 'bring', + 'brisk', + 'broccoli', + 'broken', + 'bronze', + 'broom', + 'brother', + 'brown', + 'brush', + 'bubble', + 'buddy', + 'budget', + 'buffalo', + 'build', + 'bulb', + 'bulk', + 'bullet', + 'bundle', + 'bunker', + 'burden', + 'burger', + 'burst', + 'bus', + 'business', + 'busy', + 'butter', + 'buyer', + 'buzz', + 'cabbage', + 'cabin', + 'cable', + 'cactus', + 'cage', + 'cake', + 'call', + 'calm', + 'camera', + 'camp', + 'can', + 'canal', + 'cancel', + 'candy', + 'cannon', + 'canoe', + 'canvas', + 'canyon', + 'capable', + 'capital', + 'captain', + 'car', + 'carbon', + 'card', + 'cargo', + 'carpet', + 'carry', + 'cart', + 'case', + 'cash', + 'casino', + 'castle', + 'casual', + 'cat', + 'catalog', + 'catch', + 'category', + 'cattle', + 'caught', + 'cause', + 'caution', + 'cave', + 'ceiling', + 'celery', + 'cement', + 'census', + 'century', + 'cereal', + 'certain', + 'chair', + 'chalk', + 'champion', + 'change', + 'chaos', + 'chapter', + 'charge', + 'chase', + 'chat', + 'cheap', + 'check', + 'cheese', + 'chef', + 'cherry', + 'chest', + 'chicken', + 'chief', + 'child', + 'chimney', + 'choice', + 'choose', + 'chronic', + 'chuckle', + 'chunk', + 'churn', + 'cigar', + 'cinnamon', + 'circle', + 'citizen', + 'city', + 'civil', + 'claim', + 'clap', + 'clarify', + 'claw', + 'clay', + 'clean', + 'clerk', + 'clever', + 'click', + 'client', + 'cliff', + 'climb', + 'clinic', + 'clip', + 'clock', + 'clog', + 'close', + 'cloth', + 'cloud', + 'clown', + 'club', + 'clump', + 'cluster', + 'clutch', + 'coach', + 'coast', + 'coconut', + 'code', + 'coffee', + 'coil', + 'coin', + 'collect', + 'color', + 'column', + 'combine', + 'come', + 'comfort', + 'comic', + 'common', + 'company', + 'concert', + 'conduct', + 'confirm', + 'congress', + 'connect', + 'consider', + 'control', + 'convince', + 'cook', + 'cool', + 'copper', + 'copy', + 'coral', + 'core', + 'corn', + 'correct', + 'cost', + 'cotton', + 'couch', + 'country', + 'couple', + 'course', + 'cousin', + 'cover', + 'coyote', + 'crack', + 'cradle', + 'craft', + 'cram', + 'crane', + 'crash', + 'crater', + 'crawl', + 'crazy', + 'cream', + 'credit', + 'creek', + 'crew', + 'cricket', + 'crime', + 'crisp', + 'critic', + 'crop', + 'cross', + 'crouch', + 'crowd', + 'crucial', + 'cruel', + 'cruise', + 'crumble', + 'crunch', + 'crush', + 'cry', + 'crystal', + 'cube', + 'culture', + 'cup', + 'cupboard', + 'curious', + 'current', + 'curtain', + 'curve', + 'cushion', + 'custom', + 'cute', + 'cycle', + 'dad', + 'damage', + 'damp', + 'dance', + 'danger', + 'daring', + 'dash', + 'daughter', + 'dawn', + 'day', + 'deal', + 'debate', + 'debris', + 'decade', + 'december', + 'decide', + 'decline', + 'decorate', + 'decrease', + 'deer', + 'defense', + 'define', + 'defy', + 'degree', + 'delay', + 'deliver', + 'demand', + 'demise', + 'denial', + 'dentist', + 'deny', + 'depart', + 'depend', + 'deposit', + 'depth', + 'deputy', + 'derive', + 'describe', + 'desert', + 'design', + 'desk', + 'despair', + 'destroy', + 'detail', + 'detect', + 'develop', + 'device', + 'devote', + 'diagram', + 'dial', + 'diamond', + 'diary', + 'dice', + 'diesel', + 'diet', + 'differ', + 'digital', + 'dignity', + 'dilemma', + 'dinner', + 'dinosaur', + 'direct', + 'dirt', + 'disagree', + 'discover', + 'disease', + 'dish', + 'dismiss', + 'disorder', + 'display', + 'distance', + 'divert', + 'divide', + 'divorce', + 'dizzy', + 'doctor', + 'document', + 'dog', + 'doll', + 'dolphin', + 'domain', + 'donate', + 'donkey', + 'donor', + 'door', + 'dose', + 'double', + 'dove', + 'draft', + 'dragon', + 'drama', + 'drastic', + 'draw', + 'dream', + 'dress', + 'drift', + 'drill', + 'drink', + 'drip', + 'drive', + 'drop', + 'drum', + 'dry', + 'duck', + 'dumb', + 'dune', + 'during', + 'dust', + 'dutch', + 'duty', + 'dwarf', + 'dynamic', + 'eager', + 'eagle', + 'early', + 'earn', + 'earth', + 'easily', + 'east', + 'easy', + 'echo', + 'ecology', + 'economy', + 'edge', + 'edit', + 'educate', + 'effort', + 'egg', + 'eight', + 'either', + 'elbow', + 'elder', + 'electric', + 'elegant', + 'element', + 'elephant', + 'elevator', + 'elite', + 'else', + 'embark', + 'embody', + 'embrace', + 'emerge', + 'emotion', + 'employ', + 'empower', + 'empty', + 'enable', + 'enact', + 'end', + 'endless', + 'endorse', + 'enemy', + 'energy', + 'enforce', + 'engage', + 'engine', + 'enhance', + 'enjoy', + 'enlist', + 'enough', + 'enrich', + 'enroll', + 'ensure', + 'enter', + 'entire', + 'entry', + 'envelope', + 'episode', + 'equal', + 'equip', + 'era', + 'erase', + 'erode', + 'erosion', + 'error', + 'erupt', + 'escape', + 'essay', + 'essence', + 'estate', + 'eternal', + 'ethics', + 'evidence', + 'evil', + 'evoke', + 'evolve', + 'exact', + 'example', + 'excess', + 'exchange', + 'excite', + 'exclude', + 'excuse', + 'execute', + 'exercise', + 'exhaust', + 'exhibit', + 'exile', + 'exist', + 'exit', + 'exotic', + 'expand', + 'expect', + 'expire', + 'explain', + 'expose', + 'express', + 'extend', + 'extra', + 'eye', + 'eyebrow', + 'fabric', + 'face', + 'faculty', + 'fade', + 'faint', + 'faith', + 'fall', + 'false', + 'fame', + 'family', + 'famous', + 'fan', + 'fancy', + 'fantasy', + 'farm', + 'fashion', + 'fat', + 'fatal', + 'father', + 'fatigue', + 'fault', + 'favorite', + 'feature', + 'february', + 'federal', + 'fee', + 'feed', + 'feel', + 'female', + 'fence', + 'festival', + 'fetch', + 'fever', + 'few', + 'fiber', + 'fiction', + 'field', + 'figure', + 'file', + 'film', + 'filter', + 'final', + 'find', + 'fine', + 'finger', + 'finish', + 'fire', + 'firm', + 'first', + 'fiscal', + 'fish', + 'fit', + 'fitness', + 'fix', + 'flag', + 'flame', + 'flash', + 'flat', + 'flavor', + 'flee', + 'flight', + 'flip', + 'float', + 'flock', + 'floor', + 'flower', + 'fluid', + 'flush', + 'fly', + 'foam', + 'focus', + 'fog', + 'foil', + 'fold', + 'follow', + 'food', + 'foot', + 'force', + 'forest', + 'forget', + 'fork', + 'fortune', + 'forum', + 'forward', + 'fossil', + 'foster', + 'found', + 'fox', + 'fragile', + 'frame', + 'frequent', + 'fresh', + 'friend', + 'fringe', + 'frog', + 'front', + 'frost', + 'frown', + 'frozen', + 'fruit', + 'fuel', + 'fun', + 'funny', + 'furnace', + 'fury', + 'future', + 'gadget', + 'gain', + 'galaxy', + 'gallery', + 'game', + 'gap', + 'garage', + 'garbage', + 'garden', + 'garlic', + 'garment', + 'gas', + 'gasp', + 'gate', + 'gather', + 'gauge', + 'gaze', + 'general', + 'genius', + 'genre', + 'gentle', + 'genuine', + 'gesture', + 'ghost', + 'giant', + 'gift', + 'giggle', + 'ginger', + 'giraffe', + 'girl', + 'give', + 'glad', + 'glance', + 'glare', + 'glass', + 'glide', + 'glimpse', + 'globe', + 'gloom', + 'glory', + 'glove', + 'glow', + 'glue', + 'goat', + 'goddess', + 'gold', + 'good', + 'goose', + 'gorilla', + 'gospel', + 'gossip', + 'govern', + 'gown', + 'grab', + 'grace', + 'grain', + 'grant', + 'grape', + 'grass', + 'gravity', + 'great', + 'green', + 'grid', + 'grief', + 'grit', + 'grocery', + 'group', + 'grow', + 'grunt', + 'guard', + 'guess', + 'guide', + 'guilt', + 'guitar', + 'gun', + 'gym', + 'habit', + 'hair', + 'half', + 'hammer', + 'hamster', + 'hand', + 'happy', + 'harbor', + 'hard', + 'harsh', + 'harvest', + 'hat', + 'have', + 'hawk', + 'hazard', + 'head', + 'health', + 'heart', + 'heavy', + 'hedgehog', + 'height', + 'hello', + 'helmet', + 'help', + 'hen', + 'hero', + 'hidden', + 'high', + 'hill', + 'hint', + 'hip', + 'hire', + 'history', + 'hobby', + 'hockey', + 'hold', + 'hole', + 'holiday', + 'hollow', + 'home', + 'honey', + 'hood', + 'hope', + 'horn', + 'horror', + 'horse', + 'hospital', + 'host', + 'hotel', + 'hour', + 'hover', + 'hub', + 'huge', + 'human', + 'humble', + 'humor', + 'hundred', + 'hungry', + 'hunt', + 'hurdle', + 'hurry', + 'hurt', + 'husband', + 'hybrid', + 'ice', + 'icon', + 'idea', + 'identify', + 'idle', + 'ignore', + 'ill', + 'illegal', + 'illness', + 'image', + 'imitate', + 'immense', + 'immune', + 'impact', + 'impose', + 'improve', + 'impulse', + 'inch', + 'include', + 'income', + 'increase', + 'index', + 'indicate', + 'indoor', + 'industry', + 'infant', + 'inflict', + 'inform', + 'inhale', + 'inherit', + 'initial', + 'inject', + 'injury', + 'inmate', + 'inner', + 'innocent', + 'input', + 'inquiry', + 'insane', + 'insect', + 'inside', + 'inspire', + 'install', + 'intact', + 'interest', + 'into', + 'invest', + 'invite', + 'involve', + 'iron', + 'island', + 'isolate', + 'issue', + 'item', + 'ivory', + 'jacket', + 'jaguar', + 'jar', + 'jazz', + 'jealous', + 'jeans', + 'jelly', + 'jewel', + 'job', + 'join', + 'joke', + 'journey', + 'joy', + 'judge', + 'juice', + 'jump', + 'jungle', + 'junior', + 'junk', + 'just', + 'kangaroo', + 'keen', + 'keep', + 'ketchup', + 'key', + 'kick', + 'kid', + 'kidney', + 'kind', + 'kingdom', + 'kiss', + 'kit', + 'kitchen', + 'kite', + 'kitten', + 'kiwi', + 'knee', + 'knife', + 'knock', + 'know', + 'lab', + 'label', + 'labor', + 'ladder', + 'lady', + 'lake', + 'lamp', + 'language', + 'laptop', + 'large', + 'later', + 'latin', + 'laugh', + 'laundry', + 'lava', + 'law', + 'lawn', + 'lawsuit', + 'layer', + 'lazy', + 'leader', + 'leaf', + 'learn', + 'leave', + 'lecture', + 'left', + 'leg', + 'legal', + 'legend', + 'leisure', + 'lemon', + 'lend', + 'length', + 'lens', + 'leopard', + 'lesson', + 'letter', + 'level', + 'liar', + 'liberty', + 'library', + 'license', + 'life', + 'lift', + 'light', + 'like', + 'limb', + 'limit', + 'link', + 'lion', + 'liquid', + 'list', + 'little', + 'live', + 'lizard', + 'load', + 'loan', + 'lobster', + 'local', + 'lock', + 'logic', + 'lonely', + 'long', + 'loop', + 'lottery', + 'loud', + 'lounge', + 'love', + 'loyal', + 'lucky', + 'luggage', + 'lumber', + 'lunar', + 'lunch', + 'luxury', + 'lyrics', + 'machine', + 'mad', + 'magic', + 'magnet', + 'maid', + 'mail', + 'main', + 'major', + 'make', + 'mammal', + 'man', + 'manage', + 'mandate', + 'mango', + 'mansion', + 'manual', + 'maple', + 'marble', + 'march', + 'margin', + 'marine', + 'market', + 'marriage', + 'mask', + 'mass', + 'master', + 'match', + 'material', + 'math', + 'matrix', + 'matter', + 'maximum', + 'maze', + 'meadow', + 'mean', + 'measure', + 'meat', + 'mechanic', + 'medal', + 'media', + 'melody', + 'melt', + 'member', + 'memory', + 'mention', + 'menu', + 'mercy', + 'merge', + 'merit', + 'merry', + 'mesh', + 'message', + 'metal', + 'method', + 'middle', + 'midnight', + 'milk', + 'million', + 'mimic', + 'mind', + 'minimum', + 'minor', + 'minute', + 'miracle', + 'mirror', + 'misery', + 'miss', + 'mistake', + 'mix', + 'mixed', + 'mixture', + 'mobile', + 'model', + 'modify', + 'mom', + 'moment', + 'monitor', + 'monkey', + 'monster', + 'month', + 'moon', + 'moral', + 'more', + 'morning', + 'mosquito', + 'mother', + 'motion', + 'motor', + 'mountain', + 'mouse', + 'move', + 'movie', + 'much', + 'muffin', + 'mule', + 'multiply', + 'muscle', + 'museum', + 'mushroom', + 'music', + 'must', + 'mutual', + 'myself', + 'mystery', + 'myth', + 'naive', + 'name', + 'napkin', + 'narrow', + 'nasty', + 'nation', + 'nature', + 'near', + 'neck', + 'need', + 'negative', + 'neglect', + 'neither', + 'nephew', + 'nerve', + 'nest', + 'net', + 'network', + 'neutral', + 'never', + 'news', + 'next', + 'nice', + 'night', + 'noble', + 'noise', + 'nominee', + 'noodle', + 'normal', + 'north', + 'nose', + 'notable', + 'note', + 'nothing', + 'notice', + 'novel', + 'now', + 'nuclear', + 'number', + 'nurse', + 'nut', + 'oak', + 'obey', + 'object', + 'oblige', + 'obscure', + 'observe', + 'obtain', + 'obvious', + 'occur', + 'ocean', + 'october', + 'odor', + 'off', + 'offer', + 'office', + 'often', + 'oil', + 'okay', + 'old', + 'olive', + 'olympic', + 'omit', + 'once', + 'one', + 'onion', + 'online', + 'only', + 'open', + 'opera', + 'opinion', + 'oppose', + 'option', + 'orange', + 'orbit', + 'orchard', + 'order', + 'ordinary', + 'organ', + 'orient', + 'original', + 'orphan', + 'ostrich', + 'other', + 'outdoor', + 'outer', + 'output', + 'outside', + 'oval', + 'oven', + 'over', + 'own', + 'owner', + 'oxygen', + 'oyster', + 'ozone', + 'pact', + 'paddle', + 'page', + 'pair', + 'palace', + 'palm', + 'panda', + 'panel', + 'panic', + 'panther', + 'paper', + 'parade', + 'parent', + 'park', + 'parrot', + 'party', + 'pass', + 'patch', + 'path', + 'patient', + 'patrol', + 'pattern', + 'pause', + 'pave', + 'payment', + 'peace', + 'peanut', + 'pear', + 'peasant', + 'pelican', + 'pen', + 'penalty', + 'pencil', + 'people', + 'pepper', + 'perfect', + 'permit', + 'person', + 'pet', + 'phone', + 'photo', + 'phrase', + 'physical', + 'piano', + 'picnic', + 'picture', + 'piece', + 'pig', + 'pigeon', + 'pill', + 'pilot', + 'pink', + 'pioneer', + 'pipe', + 'pistol', + 'pitch', + 'pizza', + 'place', + 'planet', + 'plastic', + 'plate', + 'play', + 'please', + 'pledge', + 'pluck', + 'plug', + 'plunge', + 'poem', + 'poet', + 'point', + 'polar', + 'pole', + 'police', + 'pond', + 'pony', + 'pool', + 'popular', + 'portion', + 'position', + 'possible', + 'post', + 'potato', + 'pottery', + 'poverty', + 'powder', + 'power', + 'practice', + 'praise', + 'predict', + 'prefer', + 'prepare', + 'present', + 'pretty', + 'prevent', + 'price', + 'pride', + 'primary', + 'print', + 'priority', + 'prison', + 'private', + 'prize', + 'problem', + 'process', + 'produce', + 'profit', + 'program', + 'project', + 'promote', + 'proof', + 'property', + 'prosper', + 'protect', + 'proud', + 'provide', + 'public', + 'pudding', + 'pull', + 'pulp', + 'pulse', + 'pumpkin', + 'punch', + 'pupil', + 'puppy', + 'purchase', + 'purity', + 'purpose', + 'purse', + 'push', + 'put', + 'puzzle', + 'pyramid', + 'quality', + 'quantum', + 'quarter', + 'question', + 'quick', + 'quit', + 'quiz', + 'quote', + 'rabbit', + 'raccoon', + 'race', + 'rack', + 'radar', + 'radio', + 'rail', + 'rain', + 'raise', + 'rally', + 'ramp', + 'ranch', + 'random', + 'range', + 'rapid', + 'rare', + 'rate', + 'rather', + 'raven', + 'raw', + 'razor', + 'ready', + 'real', + 'reason', + 'rebel', + 'rebuild', + 'recall', + 'receive', + 'recipe', + 'record', + 'recycle', + 'reduce', + 'reflect', + 'reform', + 'refuse', + 'region', + 'regret', + 'regular', + 'reject', + 'relax', + 'release', + 'relief', + 'rely', + 'remain', + 'remember', + 'remind', + 'remove', + 'render', + 'renew', + 'rent', + 'reopen', + 'repair', + 'repeat', + 'replace', + 'report', + 'require', + 'rescue', + 'resemble', + 'resist', + 'resource', + 'response', + 'result', + 'retire', + 'retreat', + 'return', + 'reunion', + 'reveal', + 'review', + 'reward', + 'rhythm', + 'rib', + 'ribbon', + 'rice', + 'rich', + 'ride', + 'ridge', + 'rifle', + 'right', + 'rigid', + 'ring', + 'riot', + 'ripple', + 'risk', + 'ritual', + 'rival', + 'river', + 'road', + 'roast', + 'robot', + 'robust', + 'rocket', + 'romance', + 'roof', + 'rookie', + 'room', + 'rose', + 'rotate', + 'rough', + 'round', + 'route', + 'royal', + 'rubber', + 'rude', + 'rug', + 'rule', + 'run', + 'runway', + 'rural', + 'sad', + 'saddle', + 'sadness', + 'safe', + 'sail', + 'salad', + 'salmon', + 'salon', + 'salt', + 'salute', + 'same', + 'sample', + 'sand', + 'satisfy', + 'satoshi', + 'sauce', + 'sausage', + 'save', + 'say', + 'scale', + 'scan', + 'scare', + 'scatter', + 'scene', + 'scheme', + 'school', + 'science', + 'scissors', + 'scorpion', + 'scout', + 'scrap', + 'screen', + 'script', + 'scrub', + 'sea', + 'search', + 'season', + 'seat', + 'second', + 'secret', + 'section', + 'security', + 'seed', + 'seek', + 'segment', + 'select', + 'sell', + 'seminar', + 'senior', + 'sense', + 'sentence', + 'series', + 'service', + 'session', + 'settle', + 'setup', + 'seven', + 'shadow', + 'shaft', + 'shallow', + 'share', + 'shed', + 'shell', + 'sheriff', + 'shield', + 'shift', + 'shine', + 'ship', + 'shiver', + 'shock', + 'shoe', + 'shoot', + 'shop', + 'short', + 'shoulder', + 'shove', + 'shrimp', + 'shrug', + 'shuffle', + 'shy', + 'sibling', + 'sick', + 'side', + 'siege', + 'sight', + 'sign', + 'silent', + 'silk', + 'silly', + 'silver', + 'similar', + 'simple', + 'since', + 'sing', + 'siren', + 'sister', + 'situate', + 'six', + 'size', + 'skate', + 'sketch', + 'ski', + 'skill', + 'skin', + 'skirt', + 'skull', + 'slab', + 'slam', + 'sleep', + 'slender', + 'slice', + 'slide', + 'slight', + 'slim', + 'slogan', + 'slot', + 'slow', + 'slush', + 'small', + 'smart', + 'smile', + 'smoke', + 'smooth', + 'snack', + 'snake', + 'snap', + 'sniff', + 'snow', + 'soap', + 'soccer', + 'social', + 'sock', + 'soda', + 'soft', + 'solar', + 'soldier', + 'solid', + 'solution', + 'solve', + 'someone', + 'song', + 'soon', + 'sorry', + 'sort', + 'soul', + 'sound', + 'soup', + 'source', + 'south', + 'space', + 'spare', + 'spatial', + 'spawn', + 'speak', + 'special', + 'speed', + 'spell', + 'spend', + 'sphere', + 'spice', + 'spider', + 'spike', + 'spin', + 'spirit', + 'split', + 'spoil', + 'sponsor', + 'spoon', + 'sport', + 'spot', + 'spray', + 'spread', + 'spring', + 'spy', + 'square', + 'squeeze', + 'squirrel', + 'stable', + 'stadium', + 'staff', + 'stage', + 'stairs', + 'stamp', + 'stand', + 'start', + 'state', + 'stay', + 'steak', + 'steel', + 'stem', + 'step', + 'stereo', + 'stick', + 'still', + 'sting', + 'stock', + 'stomach', + 'stone', + 'stool', + 'story', + 'stove', + 'strategy', + 'street', + 'strike', + 'strong', + 'struggle', + 'student', + 'stuff', + 'stumble', + 'style', + 'subject', + 'submit', + 'subway', + 'success', + 'such', + 'sudden', + 'suffer', + 'sugar', + 'suggest', + 'suit', + 'summer', + 'sun', + 'sunny', + 'sunset', + 'super', + 'supply', + 'supreme', + 'sure', + 'surface', + 'surge', + 'surprise', + 'surround', + 'survey', + 'suspect', + 'sustain', + 'swallow', + 'swamp', + 'swap', + 'swarm', + 'swear', + 'sweet', + 'swift', + 'swim', + 'swing', + 'switch', + 'sword', + 'symbol', + 'symptom', + 'syrup', + 'system', + 'table', + 'tackle', + 'tag', + 'tail', + 'talent', + 'talk', + 'tank', + 'tape', + 'target', + 'task', + 'taste', + 'tattoo', + 'taxi', + 'teach', + 'team', + 'tell', + 'ten', + 'tenant', + 'tennis', + 'tent', + 'term', + 'test', + 'text', + 'thank', + 'that', + 'theme', + 'then', + 'theory', + 'there', + 'they', + 'thing', + 'this', + 'thought', + 'three', + 'thrive', + 'throw', + 'thumb', + 'thunder', + 'ticket', + 'tide', + 'tiger', + 'tilt', + 'timber', + 'time', + 'tiny', + 'tip', + 'tired', + 'tissue', + 'title', + 'toast', + 'tobacco', + 'today', + 'toddler', + 'toe', + 'together', + 'toilet', + 'token', + 'tomato', + 'tomorrow', + 'tone', + 'tongue', + 'tonight', + 'tool', + 'tooth', + 'top', + 'topic', + 'topple', + 'torch', + 'tornado', + 'tortoise', + 'toss', + 'total', + 'tourist', + 'toward', + 'tower', + 'town', + 'toy', + 'track', + 'trade', + 'traffic', + 'tragic', + 'train', + 'transfer', + 'trap', + 'trash', + 'travel', + 'tray', + 'treat', + 'tree', + 'trend', + 'trial', + 'tribe', + 'trick', + 'trigger', + 'trim', + 'trip', + 'trophy', + 'trouble', + 'truck', + 'true', + 'truly', + 'trumpet', + 'trust', + 'truth', + 'try', + 'tube', + 'tuition', + 'tumble', + 'tuna', + 'tunnel', + 'turkey', + 'turn', + 'turtle', + 'twelve', + 'twenty', + 'twice', + 'twin', + 'twist', + 'two', + 'type', + 'typical', + 'ugly', + 'umbrella', + 'unable', + 'unaware', + 'uncle', + 'uncover', + 'under', + 'undo', + 'unfair', + 'unfold', + 'unhappy', + 'uniform', + 'unique', + 'unit', + 'universe', + 'unknown', + 'unlock', + 'until', + 'unusual', + 'unveil', + 'update', + 'upgrade', + 'uphold', + 'upon', + 'upper', + 'upset', + 'urban', + 'urge', + 'usage', + 'use', + 'used', + 'useful', + 'useless', + 'usual', + 'utility', + 'vacant', + 'vacuum', + 'vague', + 'valid', + 'valley', + 'valve', + 'van', + 'vanish', + 'vapor', + 'various', + 'vast', + 'vault', + 'vehicle', + 'velvet', + 'vendor', + 'venture', + 'venue', + 'verb', + 'verify', + 'version', + 'very', + 'vessel', + 'veteran', + 'viable', + 'vibrant', + 'vicious', + 'victory', + 'video', + 'view', + 'village', + 'vintage', + 'violin', + 'virtual', + 'virus', + 'visa', + 'visit', + 'visual', + 'vital', + 'vivid', + 'vocal', + 'voice', + 'void', + 'volcano', + 'volume', + 'vote', + 'voyage', + 'wage', + 'wagon', + 'wait', + 'walk', + 'wall', + 'walnut', + 'want', + 'warfare', + 'warm', + 'warrior', + 'wash', + 'wasp', + 'waste', + 'water', + 'wave', + 'way', + 'wealth', + 'weapon', + 'wear', + 'weasel', + 'weather', + 'web', + 'wedding', + 'weekend', + 'weird', + 'welcome', + 'west', + 'wet', + 'whale', + 'what', + 'wheat', + 'wheel', + 'when', + 'where', + 'whip', + 'whisper', + 'wide', + 'width', + 'wife', + 'wild', + 'will', + 'win', + 'window', + 'wine', + 'wing', + 'wink', + 'winner', + 'winter', + 'wire', + 'wisdom', + 'wise', + 'wish', + 'witness', + 'wolf', + 'woman', + 'wonder', + 'wood', + 'wool', + 'word', + 'work', + 'world', + 'worry', + 'worth', + 'wrap', + 'wreck', + 'wrestle', + 'wrist', + 'write', + 'wrong', + 'yard', + 'year', + 'yellow', + 'you', + 'young', + 'youth', + 'zebra', + 'zero', + 'zone', + 'zoo' +]; + +List _french = [ 'abaisser', 'abandon', 'abdiquer', diff --git a/lib/models/chest_data.dart b/lib/models/chest_data.dart index 950dfdd..cd9ab30 100644 --- a/lib/models/chest_data.dart +++ b/lib/models/chest_data.dart @@ -7,7 +7,7 @@ part 'chest_data.g.dart'; @HiveType(typeId: 1) class ChestData extends HiveObject { @HiveField(0) - String? dewif; + String? address; @HiveField(1) String? rootAddress; @@ -28,7 +28,7 @@ class ChestData extends HiveObject { bool? isCesium; ChestData({ - this.dewif, + this.address, this.rootAddress, this.name, this.defaultWallet, diff --git a/lib/models/chest_data.g.dart b/lib/models/chest_data.g.dart index 52665b8..b853f39 100644 --- a/lib/models/chest_data.g.dart +++ b/lib/models/chest_data.g.dart @@ -17,7 +17,7 @@ class ChestDataAdapter extends TypeAdapter { for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), }; return ChestData( - dewif: fields[0] as String?, + address: fields[0] as String?, rootAddress: fields[1] as String?, name: fields[2] as String?, defaultWallet: fields[3] as int?, @@ -32,7 +32,7 @@ class ChestDataAdapter extends TypeAdapter { writer ..writeByte(7) ..writeByte(0) - ..write(obj.dewif) + ..write(obj.address) ..writeByte(1) ..write(obj.rootAddress) ..writeByte(2) diff --git a/lib/models/g1_wallets_list.dart b/lib/models/g1_wallets_list.dart index 1cc62ab..b98a699 100644 --- a/lib/models/g1_wallets_list.dart +++ b/lib/models/g1_wallets_list.dart @@ -11,19 +11,19 @@ class G1WalletsList { @HiveField(1) double? balance; - @HiveField(3) + @HiveField(2) Id? id; - @HiveField(4) + @HiveField(3) Image? avatar; - @HiveField(5) + @HiveField(4) String? username; - @HiveField(6) + @HiveField(5) String? csName; - @HiveField(7) + @HiveField(6) bool? isMembre; G1WalletsList({ diff --git a/lib/models/g1_wallets_list.g.dart b/lib/models/g1_wallets_list.g.dart index b81cf40..1fcbb43 100644 --- a/lib/models/g1_wallets_list.g.dart +++ b/lib/models/g1_wallets_list.g.dart @@ -19,11 +19,11 @@ class G1WalletsListAdapter extends TypeAdapter { return G1WalletsList( pubkey: fields[0] as String?, balance: fields[1] as double?, - id: fields[3] as Id?, - avatar: fields[4] as Image?, - username: fields[5] as String?, - csName: fields[6] as String?, - isMembre: fields[7] as bool?, + id: fields[2] as Id?, + avatar: fields[3] as Image?, + username: fields[4] as String?, + csName: fields[5] as String?, + isMembre: fields[6] as bool?, ); } @@ -35,15 +35,15 @@ class G1WalletsListAdapter extends TypeAdapter { ..write(obj.pubkey) ..writeByte(1) ..write(obj.balance) - ..writeByte(3) + ..writeByte(2) ..write(obj.id) - ..writeByte(4) + ..writeByte(3) ..write(obj.avatar) - ..writeByte(5) + ..writeByte(4) ..write(obj.username) - ..writeByte(6) + ..writeByte(5) ..write(obj.csName) - ..writeByte(7) + ..writeByte(6) ..write(obj.isMembre); } diff --git a/lib/models/wallet_data.dart b/lib/models/wallet_data.dart index 4e7cfef..4943f51 100644 --- a/lib/models/wallet_data.dart +++ b/lib/models/wallet_data.dart @@ -8,22 +8,26 @@ class WalletData extends HiveObject { int? chest; @HiveField(1) - int? number; + String? address; @HiveField(2) - String? name; + int? number; @HiveField(3) - int? derivation; + String? name; @HiveField(4) - String? imageName; + int? derivation; @HiveField(5) + String? imageName; + + @HiveField(6) File? imageFile; WalletData( {this.chest, + this.address, this.number, this.name, this.derivation, @@ -46,3 +50,10 @@ class WalletData extends HiveObject { return [chest, number]; } } + +class NewWallet { + final String address; + final String password; + + NewWallet._(this.address, this.password); +} diff --git a/lib/models/wallet_data.g.dart b/lib/models/wallet_data.g.dart index 56f2ce8..d6ba5ef 100644 --- a/lib/models/wallet_data.g.dart +++ b/lib/models/wallet_data.g.dart @@ -18,29 +18,32 @@ class WalletDataAdapter extends TypeAdapter { }; return WalletData( chest: fields[0] as int?, - number: fields[1] as int?, - name: fields[2] as String?, - derivation: fields[3] as int?, - imageName: fields[4] as String?, - imageFile: fields[5] as File?, + address: fields[1] as String?, + number: fields[2] as int?, + name: fields[3] as String?, + derivation: fields[4] as int?, + imageName: fields[5] as String?, + imageFile: fields[6] as File?, ); } @override void write(BinaryWriter writer, WalletData obj) { writer - ..writeByte(6) + ..writeByte(7) ..writeByte(0) ..write(obj.chest) ..writeByte(1) - ..write(obj.number) + ..write(obj.address) ..writeByte(2) - ..write(obj.name) + ..write(obj.number) ..writeByte(3) - ..write(obj.derivation) + ..write(obj.name) ..writeByte(4) - ..write(obj.imageName) + ..write(obj.derivation) ..writeByte(5) + ..write(obj.imageName) + ..writeByte(6) ..write(obj.imageFile); } diff --git a/lib/providers/change_pin.dart b/lib/providers/change_pin.dart deleted file mode 100644 index 422cf2b..0000000 --- a/lib/providers/change_pin.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:durt/durt.dart'; -import 'package:flutter/material.dart'; -import 'package:gecko/globals.dart'; - -class ChangePinProvider with ChangeNotifier { - bool ischangedPin = false; - TextEditingController newPin = TextEditingController(); - String? pinToGive; - - NewWallet? get badWallet => null; - - Future changePin(String _oldPin, {String? newCustomPin}) async { - final NewWallet newWalletFile; - try { - final _chest = chestBox.get(configBox.get('currentChest'))!; - - if (_chest.isCesium!) { - newWalletFile = await Dewif().changeCesiumPassword( - dewif: _chest.dewif!, - oldPassword: _oldPin.toUpperCase(), - newPassword: newCustomPin); - } else { - newWalletFile = await Dewif().changePassword( - dewif: _chest.dewif!, - oldPassword: _oldPin.toUpperCase(), - newPassword: newCustomPin); - } - newPin.text = pinToGive = newWalletFile.password; - ischangedPin = true; - // notifyListeners(); - return newWalletFile; - } catch (e) { - log.e('Impossible de changer le code PIN: $e'); - return badWallet; - } - } - - void storeNewPinChest(context, NewWallet _newWalletFile) { - // ChestData currentChest = chestBox.getAt(configBox.get('currentChest')); - // currentChest.dewif = _newWalletFile.dewif; - // await chestBox.add(currentChest); - - chestBox.get(configBox.get('currentChest'))!.dewif = _newWalletFile.dewif; - - Navigator.pop(context, pinToGive); - pinToGive = ''; - } -} diff --git a/lib/providers/generate_wallets.dart b/lib/providers/generate_wallets.dart index e56367d..0ab36e1 100644 --- a/lib/providers/generate_wallets.dart +++ b/lib/providers/generate_wallets.dart @@ -72,7 +72,7 @@ class GenerateWalletsProvider with ChangeNotifier { chestName = 'Coffre à Ğecko ${chestNumber + 1}'; } ChestData thisChest = ChestData( - dewif: address, + address: address, name: chestName, defaultWallet: 0, imageName: '${chestNumber % 8}.png', @@ -83,6 +83,7 @@ class GenerateWalletsProvider with ChangeNotifier { WalletData myWallet = WalletData( chest: chestKey, + address: address, number: 0, name: _name, derivation: 3, @@ -228,55 +229,55 @@ class GenerateWalletsProvider with ChangeNotifier { log.d(_walletPubkey); } - Future importCesiumWallet() async { - // String _walletPubkey = await DubpRust.getLegacyPublicKey( - // salt: _cesiumID, password: _cesiumPWD); - // String shortPubkey = truncate(_walletPubkey, 9, - // omission: "...", position: TruncatePosition.end); - // await storeWallet( - // actualWallet, 'Portefeuille Cesium - $shortPubkey', context); - // NewWallet myCesiumWallet = await DubpRust.genWalletFromDeprecatedSaltPassword(salt: _cesiumID, password: _cesiumPWD); + // Future importCesiumWallet() async { + // // String _walletPubkey = await DubpRust.getLegacyPublicKey( + // // salt: _cesiumID, password: _cesiumPWD); + // // String shortPubkey = truncate(_walletPubkey, 9, + // // omission: "...", position: TruncatePosition.end); + // // await storeWallet( + // // actualWallet, 'Portefeuille Cesium - $shortPubkey', context); + // // NewWallet myCesiumWallet = await DubpRust.genWalletFromDeprecatedSaltPassword(salt: _cesiumID, password: _cesiumPWD); - cesiumID.text = ''; - cesiumPWD.text = ''; - cesiumPubkey.text = ''; - canImport = false; - isCesiumIDVisible = false; - isCesiumPWDVisible = false; + // cesiumID.text = ''; + // cesiumPWD.text = ''; + // cesiumPubkey.text = ''; + // canImport = false; + // isCesiumIDVisible = false; + // isCesiumPWDVisible = false; - int chestNumber = 0; - chestBox.toMap().forEach((key, value) { - if (value.isCesium!) { - chestNumber++; - } - }); + // int chestNumber = 0; + // chestBox.toMap().forEach((key, value) { + // if (value.isCesium!) { + // chestNumber++; + // } + // }); - String chestName; - if (chestNumber == 0) { - chestName = 'Coffre à Césium'; - } else { - chestName = 'Coffre à Césium ${chestNumber + 1}'; - } + // String chestName; + // if (chestNumber == 0) { + // chestName = 'Coffre à Césium'; + // } else { + // chestName = 'Coffre à Césium ${chestNumber + 1}'; + // } - log.d(pin.text); - durt.NewWallet cesiumDewif = - await durt.Dewif().generateCesiumDewif(cesiumWallet.seed, pin.text); + // log.d(pin.text); + // durt.NewWallet cesiumDewif = + // await durt.Dewif().generateCesiumDewif(cesiumWallet.seed, pin.text); - ChestData cesiumChest = ChestData( - dewif: cesiumDewif.dewif, - name: chestName, - imageName: 'cesium.png', - defaultWallet: 0, - isCesium: true); + // ChestData cesiumChest = ChestData( + // dewif: cesiumDewif.dewif, + // name: chestName, + // imageName: 'cesium.png', + // defaultWallet: 0, + // isCesium: true); - await chestBox.add(cesiumChest).then((value) => null); - int? chestKey = await chestBox.toMap().keys.last; - // chestBox.toMap(). - await configBox.put('currentChest', chestKey); + // await chestBox.add(cesiumChest).then((value) => null); + // int? chestKey = await chestBox.toMap().keys.last; + // // chestBox.toMap(). + // await configBox.put('currentChest', chestKey); - pin.text = ''; - return chestKey; - } + // pin.text = ''; + // return chestKey; + // } void cesiumIDisVisible() { isCesiumIDVisible = !isCesiumIDVisible; @@ -296,8 +297,7 @@ class GenerateWalletsProvider with ChangeNotifier { } Future> generateWordList(BuildContext context) async { - SubstrateSdk _sdk = - Provider.of(context, listen: false); + SubstrateSdk _sdk = Provider.of(context, listen: false); generatedMnemonic = await _sdk.generateMnemonic(lang: appLang); List _wordsList = []; @@ -318,7 +318,7 @@ class GenerateWalletsProvider with ChangeNotifier { // Needed for bad encoding of UTF-8 word = word.replaceAll('é', 'é'); word = word.replaceAll('è', 'è'); - return bip39Words.contains(word); + return bip39Words(appLang).contains(word); } bool isBipWordsList(List words) { @@ -327,7 +327,7 @@ class GenerateWalletsProvider with ChangeNotifier { // Needed for bad encoding of UTF-8 word = word.replaceAll('é', 'é'); word = word.replaceAll('è', 'è'); - if (!bip39Words.contains(word)) { + if (!bip39Words(appLang).contains(word)) { isValid = false; } } diff --git a/lib/providers/my_wallets.dart b/lib/providers/my_wallets.dart index e826a83..1144cba 100644 --- a/lib/providers/my_wallets.dart +++ b/lib/providers/my_wallets.dart @@ -1,10 +1,11 @@ import 'dart:typed_data'; - -import 'package:durt/durt.dart'; import 'package:flutter/material.dart'; import 'dart:async'; import 'package:gecko/globals.dart'; +import 'package:gecko/models/chest_data.dart'; import 'package:gecko/models/wallet_data.dart'; +import 'package:gecko/providers/substrate_sdk.dart'; +import 'package:provider/provider.dart'; class MyWalletsProvider with ChangeNotifier { List listWallets = []; @@ -21,24 +22,6 @@ class MyWalletsProvider with ChangeNotifier { return configBox.get('currentChest'); } - String dewifToMnemonic(context, WalletData _wallet, String _pin) { - String _mnemonic; - - try { - String _localDewif = chestBox.get(_wallet.chest)!.dewif!; - _mnemonic = Dewif() - .mnemonicFromDewif(_localDewif, _pin.toUpperCase(), lang: appLang); - } on ChecksumException catch (e) { - log.e(e.cause); - return 'bad'; - } catch (e) { - // _homeProvider.playSound('non', 0.6); - log.e('ERROR READING FILE: $e'); - return 'bad'; - } - return _mnemonic; - } - bool checkIfWalletExist() { if (chestBox.isEmpty) { log.i('No wallets detected'); @@ -150,8 +133,19 @@ class MyWalletsProvider with ChangeNotifier { _newWalletNbr = _walletConfig.last.number! + 1; } + MyWalletsProvider myWalletProvider = + Provider.of(context, listen: false); + + SubstrateSdk _sdk = Provider.of(context, listen: false); + + final int? _currentChestNumber = myWalletProvider.getCurrentChest(); + final ChestData _currentChest = chestBox.get(_currentChestNumber)!; + + final address = await _sdk.derive(context, _currentChest.address!, _newDerivationNbr, pinCode); + WalletData newWallet = WalletData( chest: _chest, + address: address, number: _newWalletNbr, name: _name, derivation: _newDerivationNbr, diff --git a/lib/providers/substrate_sdk.dart b/lib/providers/substrate_sdk.dart index b8da790..9364700 100644 --- a/lib/providers/substrate_sdk.dart +++ b/lib/providers/substrate_sdk.dart @@ -4,6 +4,7 @@ import 'package:crypto/crypto.dart'; import 'package:fast_base58/fast_base58.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/globals.dart'; import 'package:polkawallet_sdk/api/apiKeyring.dart'; import 'package:polkawallet_sdk/api/types/networkParams.dart'; import 'package:polkawallet_sdk/api/types/txInfoData.dart'; @@ -69,7 +70,8 @@ class SubstrateSdk with ChangeNotifier { Future importAccount( {String mnemonic = '', bool fromMnemonic = false, - String derivePath = ''}) async { + String derivePath = '', + String password = ''}) async { // toy exercise immense month enter answer table prefer speed cycle gold phone final clipboardData = await Clipboard.getData(Clipboard.kTextPlain); if (mnemonic != '') { @@ -80,6 +82,10 @@ class SubstrateSdk with ChangeNotifier { generatedMnemonic = clipboardData.text!; } + if (password == '') { + password = keystorePassword.text; + } + final KeyType keytype; final String keyToImport; if (fromMnemonic) { @@ -97,8 +103,8 @@ class SubstrateSdk with ChangeNotifier { .importAccount(keyring, keyType: keytype, key: keyToImport, - name: 'testKey', - password: keystorePassword.text, + name: derivePath, + password: password, derivePath: derivePath, cryptoType: CryptoType.sr25519) .catchError((e) { @@ -107,16 +113,16 @@ class SubstrateSdk with ChangeNotifier { }); if (json == null) return ''; print(json); - late KeyPairData? keyPairData; try { - keyPairData = await sdk.api.keyring.addAccount( + await sdk.api.keyring.addAccount( keyring, keyType: keytype, acc: json, - password: keystorePassword.text, + password: password, ); // Clipboard.setData(ClipboardData(text: jsonEncode(acc.toJson()))); } catch (e) { + print(e); importIsLoading = false; notifyListeners(); } @@ -124,7 +130,8 @@ class SubstrateSdk with ChangeNotifier { importIsLoading = false; await Future.delayed(const Duration(milliseconds: 20)); notifyListeners(); - return keyPairData!.address!; + final bakedAddress = keyring.allAccounts.last.address; + return bakedAddress!; } void reload() { @@ -142,23 +149,56 @@ class SubstrateSdk with ChangeNotifier { // account.balance = int.parse(p0.freeBalance) / 100; // }); // sdk.api.setting.unsubscribeBestNumber(); - if (nodeConnected) { - final brutBalance = await sdk.api.account.queryBalance(element.address); - account.balance = int.parse(brutBalance!.freeBalance) / 100; - } + account.balance = await getBalance(element.address!); result.add(account); + print('waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); + print(element.indexInfo); + print(element.memo); } return result; } + Future getBalance(String address, {bool isUd = false}) async { + double balance = 0.0; + if (nodeConnected) { + final brutBalance = await sdk.api.account.queryBalance(address); + balance = int.parse(brutBalance!.freeBalance) / 100; + } + return balance; + } + + KeyPairData getKeypair(String address) { + return keyring.keyPairs.firstWhere((kp) => kp.address == address, + orElse: (() => KeyPairData())); + } + + Future checkPassword(String address, String pass) async { + final account = getKeypair(address); + return await sdk.api.keyring.checkPassword(account, pass); + } + + int getDerivationNumber(String address) { + final account = getKeypair(address); + final deriveNbr = account.name!.split('/')[1]; + return int.parse(deriveNbr); + } + + Future changePassword( + String address, String passOld, String? passNew) async { + final account = getKeypair(address); + keyring.setCurrent(account); + + return await sdk.api.keyring.changePassword(keyring, passOld, passNew); + } + Future deleteAllAccounts() async { for (var account in keyring.allAccounts) { await sdk.api.keyring.deleteAccount(keyring, account); } } - Future generateMnemonic({String lang = 'english'}) async { + Future generateMnemonic({String lang = appLang}) async { final gen = await sdk.api.keyring.generateMnemonic(ss58); generatedMnemonic = gen.mnemonic!; @@ -192,16 +232,16 @@ class SubstrateSdk with ChangeNotifier { } } - derive( + Future derive( BuildContext context, String address, int number, String password) async { - final keypair = - keyring.keyPairs.firstWhere((element) => element.address == address); + final keypair = getKeypair(address); final seedMap = await keyring.store.getDecryptedSeed(keypair.pubKey, password); print(seedMap); - if (seedMap!['type'] != 'mnemonic') return; - final List seedList = seedMap['seed'].split('/'); + + if (seedMap?['type'] != 'mnemonic') return ''; + final List seedList = seedMap!['seed'].split('/'); generatedMnemonic = seedList[0]; int sourceDerivation = -1; // To get derivation number of this account if (seedList.length > 1) { @@ -210,7 +250,7 @@ class SubstrateSdk with ChangeNotifier { print(generatedMnemonic); print(sourceDerivation); - importAccount(fromMnemonic: true, derivePath: '/$number'); + return await importAccount(fromMnemonic: true, derivePath: '/$number'); } } diff --git a/lib/providers/wallet_options.dart b/lib/providers/wallet_options.dart index 1056d7c..5a7db82 100644 --- a/lib/providers/wallet_options.dart +++ b/lib/providers/wallet_options.dart @@ -1,6 +1,5 @@ import 'dart:io'; import 'package:crypto/crypto.dart'; -import 'package:durt/durt.dart'; import 'package:fast_base58/fast_base58.dart'; import 'package:flutter/material.dart'; import 'dart:async'; @@ -12,7 +11,7 @@ import 'package:image_picker/image_picker.dart'; import 'package:truncate/truncate.dart'; class WalletOptionsProvider with ChangeNotifier { - TextEditingController pubkey = TextEditingController(); + TextEditingController address = TextEditingController(); final TextEditingController _newWalletName = TextEditingController(); bool isWalletUnlock = false; bool ischangedPin = false; @@ -25,82 +24,6 @@ class WalletOptionsProvider with ChangeNotifier { Future? get badWallet => null; - String _getPubkeyFromDewif( - String? _dewif, _pin, int _pinLenght, int? derivation) { - RegExp regExp = RegExp( - r'^[A-Z0-9]+$', - caseSensitive: false, - multiLine: false, - ); - - if (regExp.hasMatch(_pin) == true && _pin.length == _pinLenght) { - } else { - return 'false'; - } - if (derivation != -1) { - try { - final _wallet = HdWallet.fromDewif(_dewif!, _pin, lang: appLang); - pubkey.text = _wallet.getPubkey(derivation!); - log.d(pubkey.text); - notifyListeners(); - - return pubkey.text; - } catch (e) { - log.w('Bad PIN code !\n' + e.toString()); - notifyListeners(); - - return 'false'; - } - } else { - try { - pubkey.text = CesiumWallet.fromDewif(_dewif!, _pin).pubkey; - notifyListeners(); - return pubkey.text; - } catch (e) { - log.w('Bad PIN code !\n' + e.toString()); - notifyListeners(); - - return 'false'; - } - } - } - - String? readLocalWallet( - context, WalletData _wallet, String _pin, int _pinLenght, - {String? mnemonic}) { - isWalletUnlock = false; - final String _localPubkey; - - try { - String? _localDewif = chestBox.get(_wallet.chest)!.dewif; - - if (mnemonic == null) { - _localPubkey = _getPubkeyFromDewif( - _localDewif, _pin.toUpperCase(), _pinLenght, _wallet.derivation); - } else { - final _hdwallet = HdWallet.fromMnemonic(mnemonic); - _localPubkey = _hdwallet.getPubkey(_wallet.derivation!); - } - - if (_localPubkey != 'false') { - pubkey.text = _localPubkey; - isWalletUnlock = true; - log.d(pubkey.text); - return _localDewif; - } else { - throw 'Bad pubkey'; - } - } on ChecksumException catch (e) { - log.e(e.cause); - return 'bad'; - } catch (e) { - // _homeProvider.playSound('non', 0.6); - log.e('ERROR READING FILE: $e'); - pubkey.clear(); - return 'bad'; - } - } - int getPinLenght(_walletNbr) { // TODOo: Get real Dewif lenght // String _localDewif; @@ -116,11 +39,6 @@ class WalletOptionsProvider with ChangeNotifier { return pinLength; } - Future getBalance(String pubkey, {bool isUd = false}) async { - final node = Gva(node: endPointGVA); - return await node.balance(pubkey, ud: isUd); - } - void _renameWallet(List _walletID, _newName, {required bool isCesium}) async { if (isCesium) { @@ -252,4 +170,18 @@ class WalletOptionsProvider with ChangeNotifier { void reloadBuild() { notifyListeners(); } + + String? getAddress(int chest, int derivation) { + String? _address; + walletBox.toMap().forEach((key, value) { + if (value.chest == chest) { + _address = value.address!; + return; + } + }); + + address.text = _address ?? ''; + + return _address; + } } diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 0cfbe62..eedf9b0 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -103,7 +103,7 @@ class HomeScreen extends StatelessWidget { WidgetsBinding.instance.addPostFrameCallback((_) async { if (!_sub.sdkReady && !_sub.sdkLoading) await _sub.initApi(); if (_sub.sdkReady && !_sub.nodeConnected) { - await _sub.connectNode(); + await _sub.connectNode(); //kopa } if (isWalletsExists) homeClass.snackNode(ctx); }); diff --git a/lib/screens/myWallets/cesium_wallet_options.dart b/lib/screens/myWallets/cesium_wallet_options.dart index 0c01801..bce4b45 100644 --- a/lib/screens/myWallets/cesium_wallet_options.dart +++ b/lib/screens/myWallets/cesium_wallet_options.dart @@ -38,7 +38,7 @@ class CesiumWalletOptions extends StatelessWidget { Provider.of(context, listen: false); final String shortPubkey = - _walletOptions.getShortPubkey(_walletOptions.pubkey.text); + _walletOptions.getShortPubkey(_walletOptions.address.text); if (_isNewNameValid == false) { _walletOptions.nameController.text = cesiumWallet.name!; @@ -158,7 +158,7 @@ class CesiumWalletOptions extends StatelessWidget { options: QueryOptions( document: gql(getBalance), variables: { - 'pubkey': _walletOptions.pubkey.text, + 'pubkey': _walletOptions.address.text, }, // pollInterval: Duration(seconds: 1), ), @@ -257,7 +257,7 @@ class CesiumWalletOptions extends StatelessWidget { }), SizedBox(height: 4 * ratio), QrImageWidget( - data: _walletOptions.pubkey.text, + data: _walletOptions.address.text, version: QrVersions.auto, size: isTall ? 300 : 270, ), @@ -266,7 +266,7 @@ class CesiumWalletOptions extends StatelessWidget { key: const Key('copyPubkey'), onTap: () { Clipboard.setData( - ClipboardData(text: _walletOptions.pubkey.text)); + ClipboardData(text: _walletOptions.address.text)); _walletOptions.snackCopyKey(ctx); }, child: SizedBox( @@ -303,7 +303,7 @@ class CesiumWalletOptions extends StatelessWidget { ), onPressed: () { Clipboard.setData(ClipboardData( - text: _walletOptions.pubkey.text)); + text: _walletOptions.address.text)); _walletOptions.snackCopyKey(ctx); }, child: Row(children: [ @@ -326,7 +326,7 @@ class CesiumWalletOptions extends StatelessWidget { context, MaterialPageRoute(builder: (context) { return HistoryScreen( - pubkey: _walletOptions.pubkey.text); + pubkey: _walletOptions.address.text); }), ); }, diff --git a/lib/screens/myWallets/change_pin.dart b/lib/screens/myWallets/change_pin.dart index 9410865..88c254e 100644 --- a/lib/screens/myWallets/change_pin.dart +++ b/lib/screens/myWallets/change_pin.dart @@ -3,9 +3,10 @@ import 'package:durt/durt.dart'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/stateful_wrapper.dart'; -import 'package:gecko/providers/change_pin.dart'; import 'package:gecko/providers/my_wallets.dart'; +import 'package:gecko/providers/substrate_sdk.dart'; import 'dart:io'; + import 'package:provider/provider.dart'; // ignore: must_be_immutable @@ -19,15 +20,16 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { final MyWalletsProvider walletProvider; Directory? appPath; + TextEditingController newPin = TextEditingController(); + @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); - ChangePinProvider _changePin = Provider.of(context); - // _walletOptions.changePin(walletName, oldPin); - // _walletOptions.newPin.text = _tmpPin; + SubstrateSdk _sdk = Provider.of(context, listen: false); + return WillPopScope( onWillPop: () { - _changePin.newPin.text = ''; + newPin.text = ''; return Future.value(true); }, child: Scaffold( @@ -37,7 +39,7 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { leading: IconButton( icon: const Icon(Icons.arrow_back, color: Colors.black), onPressed: () { - _changePin.newPin.text = ''; + newPin.text = ''; Navigator.of(context).pop(); }), title: SizedBox( @@ -50,7 +52,7 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { child: Column(children: [ StatefulWrapper( onInit: () { - _changePin.newPin.text = randomSecretCode(pinLength); + newPin.text = randomSecretCode(pinLength); }, child: Container(), ), @@ -69,7 +71,7 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { children: [ TextField( enabled: false, - controller: _changePin.newPin, + controller: newPin, maxLines: 1, textAlign: TextAlign.center, decoration: const InputDecoration(), @@ -81,7 +83,7 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { icon: const Icon(Icons.replay), color: orangeC, onPressed: () async { - _changePin.newPin.text = randomSecretCode(pinLength); + newPin.text = randomSecretCode(pinLength); }, ), ], @@ -97,12 +99,10 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier { onPrimary: Colors.black, // foreground ), onPressed: () async { - NewWallet? _newWalletFile = await _changePin.changePin( - walletProvider.pinCode, - newCustomPin: _changePin.newPin.text); - _changePin.newPin.text = ''; - _changePin.storeNewPinChest(context, _newWalletFile!); - walletProvider.pinCode = _changePin.newPin.text; + final _chest = chestBox.get(configBox.get('currentChest')); + _sdk.changePassword(_chest!.address!, walletProvider.pinCode, newPin.text); + newPin.text = ''; + walletProvider.pinCode = newPin.text; }, child: const Text( 'Confirmer', diff --git a/lib/screens/myWallets/confirm_wallet_storage.dart b/lib/screens/myWallets/confirm_wallet_storage.dart index 822f37f..4079d1d 100644 --- a/lib/screens/myWallets/confirm_wallet_storage.dart +++ b/lib/screens/myWallets/confirm_wallet_storage.dart @@ -5,6 +5,7 @@ import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/providers/generate_wallets.dart'; import 'package:gecko/providers/my_wallets.dart'; +import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/screens/myWallets/unlocking_wallet.dart'; import 'package:provider/provider.dart'; @@ -32,6 +33,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { MyWalletsProvider _myWalletProvider = Provider.of(context); final int? _currentChest = _myWalletProvider.getCurrentChest(); + SubstrateSdk _sdk = Provider.of(context, listen: false); _mnemonicController.text = generatedMnemonic!; return WillPopScope( @@ -134,9 +136,16 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { .isAskedWordValid && walletName.text != '') ? () async { - _generateWalletProvider.storeHDWChest( - generatedWallet!.dewif, - walletName.text, + final address = await _sdk.importAccount( + fromMnemonic: true, + mnemonic: _generateWalletProvider + .generatedMnemonic!, + password: + _generateWalletProvider.pin.text, + derivePath: '/3'); + await _generateWalletProvider.storeHDWChest( + address, + 'Mon portefeuille courant', context); _generateWalletProvider.isAskedWordValid = false; diff --git a/lib/screens/myWallets/generate_wallets.dart b/lib/screens/myWallets/generate_wallets.dart index 3052e69..b0f4976 100644 --- a/lib/screens/myWallets/generate_wallets.dart +++ b/lib/screens/myWallets/generate_wallets.dart @@ -23,14 +23,9 @@ class GenerateFastChestScreen extends StatelessWidget { Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); GenerateWalletsProvider _generateWalletProvider = - Provider.of(context); + Provider.of(context, listen: false); - if (_generateWalletProvider.mnemonicController.text == '') { - _generateWalletProvider.generateWordList(context); - _generateWalletProvider.mnemonicController.text = - _generateWalletProvider.generatedMnemonic!; - _generateWalletProvider.pin.text = randomSecretCode(pinLength); - } + _generateWalletProvider.changePinCode(reload: false); return WillPopScope( onWillPop: () { @@ -59,9 +54,7 @@ class GenerateFastChestScreen extends StatelessWidget { child: FloatingActionButton( heroTag: "buttonGenerateWallet", onPressed: () { - _generateWalletProvider.generateWordList(context); - _generateWalletProvider.mnemonicController.text = - _generateWalletProvider.generatedMnemonic!; + _generateWalletProvider.reloadBuild(); }, child: SizedBox( height: 40.0, @@ -77,18 +70,23 @@ class GenerateFastChestScreen extends StatelessWidget { const SizedBox(height: 20), toolTips(_toolTipSentence, 'Phrase de restauration:', "Notez et gardez cette phrase précieusement sur un papier, elle vous servira à restaurer votre portefeuille sur un autre appareil"), - TextField( - enabled: false, - controller: _generateWalletProvider.mnemonicController, - maxLines: 3, - textAlign: TextAlign.center, - decoration: const InputDecoration( - contentPadding: EdgeInsets.all(15.0), - ), - style: const TextStyle( - fontSize: 22.0, - color: Colors.black, - fontWeight: FontWeight.w400)), + Consumer(builder: (context, _gWP, _) { + return FutureBuilder( + future: _gWP.generateWordList(context), + builder: (BuildContext context, AsyncSnapshot _data) { + if (!_data.hasData) { + return const Text(''); + } else { + return Text(_gWP.generatedMnemonic!, + maxLines: 3, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 22.0, + color: Colors.black, + fontWeight: FontWeight.w400)); + } + }); + }), const SizedBox(height: 8), toolTips(_toolTipSecret, 'Code secret:', "Retenez bien votre code secret, il vous sera demandé à chaque paiement, ainsi que pour configurer votre portefeuille"), @@ -110,7 +108,7 @@ class GenerateFastChestScreen extends StatelessWidget { icon: const Icon(Icons.replay), color: orangeC, onPressed: () { - _generateWalletProvider.changePinCode(reload: true); + _generateWalletProvider.changePinCode(reload: false); }, ), ], diff --git a/lib/screens/myWallets/import_cesium_wallet.dart b/lib/screens/myWallets/import_cesium_wallet.dart deleted file mode 100644 index bbac4cc..0000000 --- a/lib/screens/myWallets/import_cesium_wallet.dart +++ /dev/null @@ -1,244 +0,0 @@ -import 'dart:async'; -import 'package:durt/durt.dart'; -import 'package:flutter/services.dart'; -import 'package:gecko/globals.dart'; -import 'package:gecko/providers/generate_wallets.dart'; -import 'package:flutter/material.dart'; -import 'package:gecko/providers/my_wallets.dart'; -import 'package:gecko/models/wallet_data.dart'; -import 'package:gecko/providers/wallet_options.dart'; -import 'package:gecko/screens/myWallets/unlocking_wallet.dart'; -import 'package:provider/provider.dart'; - -class ImportWalletScreen extends StatelessWidget { - const ImportWalletScreen({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); - GlobalKey _toolTipSecret = GlobalKey(); - Timer? _debounce; - GenerateWalletsProvider _generateWalletProvider = - Provider.of(context, listen: false); - WalletOptionsProvider _walletOptions = - Provider.of(context, listen: false); - MyWalletsProvider _myWalletProvider = - Provider.of(context, listen: false); - - _generateWalletProvider.pin.text = randomSecretCode(pinLength); - return WillPopScope( - onWillPop: () { - _generateWalletProvider.resetCesiumImportView(); - return Future.value(true); - }, - child: Scaffold( - appBar: AppBar( - toolbarHeight: 60 * ratio, - leading: IconButton( - icon: const Icon(Icons.arrow_back, color: Colors.black), - onPressed: () { - _generateWalletProvider.resetCesiumImportView(); - Navigator.of(context).pop(); - }), - title: const SizedBox( - height: 22, - child: Text('Importer un portefeuille'), - )), - body: Builder( - builder: (ctx) => SafeArea( - child: Column(children: [ - const SizedBox(height: 20), - Consumer( - builder: (context, walletProvider, _) { - return TextFormField( - autofocus: true, - onChanged: (text) { - if (_debounce?.isActive ?? false) { - _debounce!.cancel(); - } - _debounce = Timer(const Duration(milliseconds: 600), () { - walletProvider - .generateCesiumWalletPubkey( - text, walletProvider.cesiumPWD.text) - .then((value) { - walletProvider.canImport = true; - walletProvider.reloadBuild(); - }); - }); - }, - keyboardType: TextInputType.text, - controller: walletProvider.cesiumID, - obscureText: !walletProvider - .isCesiumIDVisible, //This will obscure text dynamically - decoration: InputDecoration( - hintText: 'Entrez votre identifiant Cesium', - suffixIcon: IconButton( - icon: Icon( - walletProvider.isCesiumIDVisible - ? Icons.visibility - : Icons.visibility_off, - color: Colors.black, - ), - onPressed: () { - walletProvider.cesiumIDisVisible(); - }, - ), - ), - ); - }), - const SizedBox(height: 15), - Consumer( - builder: (context, walletProvider, _) { - return TextFormField( - onChanged: (text) { - if (_debounce?.isActive ?? false) { - _debounce!.cancel(); - } - _debounce = Timer(const Duration(milliseconds: 600), () { - walletProvider - .generateCesiumWalletPubkey( - walletProvider.cesiumID.text, text) - .then((value) { - walletProvider.canImport = true; - walletProvider.reloadBuild(); - }); - }); - }, - keyboardType: TextInputType.text, - controller: walletProvider.cesiumPWD, - obscureText: !walletProvider - .isCesiumPWDVisible, //This will obscure text dynamically - decoration: InputDecoration( - hintText: 'Entrez votre mot de passe Cesium', - suffixIcon: IconButton( - icon: Icon( - walletProvider.isCesiumPWDVisible - ? Icons.visibility - : Icons.visibility_off, - color: Colors.black, - ), - onPressed: () { - walletProvider.cesiumPWDisVisible(); - }, - ), - ), - ); - }), - const SizedBox(height: 15), - GestureDetector( - onTap: () { - Clipboard.setData(ClipboardData( - text: _generateWalletProvider.cesiumPubkey.text)); - _walletOptions.snackCopyKey(ctx); - }, - child: Consumer( - builder: (context, walletProvider, _) { - return Text( - _generateWalletProvider.cesiumPubkey.text, - style: const TextStyle( - fontSize: 14.0, - color: Colors.black, - fontWeight: FontWeight.bold, - fontFamily: 'Monospace'), - ); - }), - ), - const SizedBox(height: 20), - toolTips(_toolTipSecret, 'Code secret:', - "Retenez bien votre code secret, il vous sera demandé à chaque paiement, ainsi que pour configurer votre portefeuille"), - Stack( - alignment: Alignment.centerRight, - children: [ - TextField( - enabled: false, - controller: _generateWalletProvider.pin, - maxLines: 1, - textAlign: TextAlign.center, - decoration: const InputDecoration(), - style: const TextStyle( - fontSize: 30.0, - color: Colors.black, - fontWeight: FontWeight.bold)), - IconButton( - icon: const Icon(Icons.replay), - color: orangeC, - onPressed: () { - _generateWalletProvider.changePinCode(reload: true); - }, - ), - ], - ), - const SizedBox(height: 30), - Consumer( - builder: (context, walletProvider, _) { - return ElevatedButton( - style: ElevatedButton.styleFrom( - primary: yellowC, // background - onPrimary: Colors.black, // foreground - ), - onPressed: walletProvider.canImport - ? () async { - final chestKey = - await walletProvider.importCesiumWallet(); - _myWalletProvider.rebuildWidget(); - - await Navigator.pushAndRemoveUntil( - context, - MaterialPageRoute(builder: (context) { - return UnlockingWallet( - wallet: WalletData(chest: chestKey), - action: "mywallets", - ); - }), - ModalRoute.withName('/'), - ); - _generateWalletProvider.resetCesiumImportView(); - } - : null, - child: const Text( - 'Importer ce portefeuille Cesium', - style: TextStyle(fontSize: 20), - ), - ); - }), - ]), - ), - ), - ), - ); - } - - Widget toolTips(_key, _text, _message) { - return GestureDetector( - onTap: () { - final dynamic _toolTip = _key.currentState; - _toolTip.ensureTooltipVisible(); - }, - child: Tooltip( - padding: const EdgeInsets.all(10), - key: _key, - showDuration: const Duration(seconds: 5), - message: _message, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const SizedBox(width: 20), - Column(children: [ - SizedBox( - width: 30, - height: 25, - child: - Icon(Icons.info_outline, size: 22, color: orangeC)), - const SizedBox(height: 1) - ]), - Text( - _text, - style: TextStyle( - fontSize: 15.0, - color: Colors.grey[600], - fontWeight: FontWeight.w400), - ), - const SizedBox(width: 45) - ]))); - } -} diff --git a/lib/screens/myWallets/unlocking_wallet.dart b/lib/screens/myWallets/unlocking_wallet.dart index d3ed360..13307ae 100644 --- a/lib/screens/myWallets/unlocking_wallet.dart +++ b/lib/screens/myWallets/unlocking_wallet.dart @@ -1,7 +1,9 @@ +// ignore_for_file: avoid_print + import 'dart:async'; -import 'package:durt/durt.dart'; import 'package:flutter/services.dart'; import 'package:gecko/models/chest_data.dart'; +import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/wallets_profiles.dart'; import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/models/wallet_data.dart'; @@ -34,17 +36,12 @@ class UnlockingWallet extends StatelessWidget { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); WalletOptionsProvider _walletOptions = Provider.of(context); - final double statusBarHeight = MediaQuery.of(context).padding.top; + // final double statusBarHeight = MediaQuery.of(context).padding.top; int _pinLenght; ChestData currentChest = chestBox.get(configBox.get('currentChest'))!; - if (currentChest.isCesium!) { - _pinLenght = _walletOptions.getPinLenght(currentChest.dewif); - wallet = WalletData(derivation: -1, chest: currentChest.key); - } else { - _pinLenght = _walletOptions.getPinLenght(wallet!.number); - } + _pinLenght = _walletOptions.getPinLenght(wallet!.number); errorController = StreamController(); return Scaffold( @@ -55,7 +52,7 @@ class UnlockingWallet extends StatelessWidget { children: [ Stack(children: [ Positioned( - top: statusBarHeight + 10, + top: 10, //statusBarHeight + 10, left: 15, child: Builder( builder: (context) => IconButton( @@ -63,7 +60,7 @@ class UnlockingWallet extends StatelessWidget { icon: const Icon( Icons.arrow_back, color: Colors.black, - size: 25, + size: 30, ), onPressed: () => Navigator.pop(context), ), @@ -150,6 +147,8 @@ class UnlockingWallet extends StatelessWidget { WalletsProfilesProvider _historyProvider = Provider.of(context); + SubstrateSdk _sdk = Provider.of(context, listen: false); + FocusNode pinFocus = FocusNode(); return Form( @@ -201,30 +200,12 @@ class UnlockingWallet extends StatelessWidget { ], onCompleted: (_pin) async { log.d("Completed"); - _myWalletProvider.pinCode = _pin; + _myWalletProvider.pinCode = _pin.toUpperCase(); - if (currentChest.isCesium!) { - try { - String _localDewif = chestBox.get(wallet!.chest)!.dewif!; - final cesiumWallet = - CesiumWallet.fromDewif(_localDewif, _pin.toUpperCase()); - _walletOptions.pubkey.text = cesiumWallet.pubkey; - _myWalletProvider.cesiumSeed = cesiumWallet.seed; - _myWalletProvider.mnemonic = 'cesium'; - } catch (e) { - log.e(e); - _myWalletProvider.mnemonic = 'bad'; - } - } else { - _myWalletProvider.mnemonic = _myWalletProvider.dewifToMnemonic( - context, wallet!, _pin.toUpperCase()); - } - // final String? resultWallet = _walletOptions.readLocalWallet( - // context, wallet!, _pin.toUpperCase(), _pinLenght); - // _myWalletProvider.pinCode = _pin.toUpperCase(); - _myWalletProvider.pinLenght = _pinLenght; + final isValid = await _sdk.checkPassword( + currentChest.address!, _pin.toUpperCase()); - if (_myWalletProvider.mnemonic == 'bad') { + if (!isValid) { await Future.delayed(const Duration(milliseconds: 50)); errorController.add(ErrorAnimationType .shake); // Triggering error shake animation diff --git a/lib/screens/myWallets/wallet_options.dart b/lib/screens/myWallets/wallet_options.dart index 29d2567..66422e4 100644 --- a/lib/screens/myWallets/wallet_options.dart +++ b/lib/screens/myWallets/wallet_options.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/models/wallet_data.dart'; +import 'package:gecko/providers/substrate_sdk.dart'; import 'package:gecko/providers/wallet_options.dart'; import 'package:gecko/providers/wallets_profiles.dart'; import 'package:gecko/screens/history.dart'; @@ -27,7 +28,7 @@ class WalletOptions extends StatelessWidget { MyWalletsProvider _myWalletProvider = Provider.of(context); - log.d(_walletOptions.pubkey.text); + log.d(_walletOptions.address.text); final int _currentChest = _myWalletProvider.getCurrentChest()!; @@ -97,7 +98,7 @@ class WalletOptions extends StatelessWidget { }), SizedBox(height: 4 * ratio), QrImageWidget( - data: _walletOptions.pubkey.text, + data: _walletOptions.address.text, version: QrVersions.auto, size: isTall ? 300 : 270, ), @@ -221,9 +222,10 @@ class WalletOptions extends StatelessWidget { } Widget balance(WalletOptionsProvider walletProvider) { + SubstrateSdk _sdk = SubstrateSdk(); return Column(children: [ FutureBuilder( - future: walletProvider.getBalance(walletProvider.pubkey.text), + future: _sdk.getBalance(walletProvider.address.text), builder: (BuildContext context, AsyncSnapshot _balance) { if (_balance.connectionState != ConnectionState.done || _balance.hasError) { @@ -262,11 +264,11 @@ class WalletOptions extends StatelessWidget { Widget pubkeyWidget(WalletOptionsProvider walletProvider, BuildContext ctx) { final String shortPubkey = - walletProvider.getShortPubkey(walletProvider.pubkey.text); + walletProvider.getShortPubkey(walletProvider.address.text); return GestureDetector( key: const Key('copyPubkey'), onTap: () { - Clipboard.setData(ClipboardData(text: walletProvider.pubkey.text)); + Clipboard.setData(ClipboardData(text: walletProvider.address.text)); walletProvider.snackCopyKey(ctx); }, child: SizedBox( @@ -303,7 +305,7 @@ class WalletOptions extends StatelessWidget { ), onPressed: () { Clipboard.setData( - ClipboardData(text: walletProvider.pubkey.text)); + ClipboardData(text: walletProvider.address.text)); walletProvider.snackCopyKey(ctx); }, child: Row(children: [ @@ -336,7 +338,7 @@ class WalletOptions extends StatelessWidget { context, MaterialPageRoute(builder: (context) { return HistoryScreen( - pubkey: walletProvider.pubkey.text, + pubkey: walletProvider.address.text, avatar: wallet.imageFile == null ? Image.asset( 'assets/avatars/${wallet.imageName}', diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index c751e2d..eab5beb 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -1,4 +1,3 @@ -import 'package:durt/durt.dart'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/chest_data.dart'; @@ -55,7 +54,7 @@ class WalletsHome extends StatelessWidget { backgroundColor: const Color(0xffFFD58D), ), body: SafeArea( - child: myWalletsTiles(context), + child: myWalletsTiles(context, _currentChestNumber!), ), ), ); @@ -132,7 +131,7 @@ class WalletsHome extends StatelessWidget { ]); } - Widget myWalletsTiles(BuildContext context) { + Widget myWalletsTiles(BuildContext context, int _currentChestNumber) { MyWalletsProvider _myWalletProvider = Provider.of(context); WalletOptionsProvider _walletOptions = @@ -182,9 +181,8 @@ class WalletsHome extends StatelessWidget { onTap: () { // _walletOptions.readLocalWallet(context, _repository, // _myWalletProvider.pinCode, pinLength); - _walletOptions.pubkey.text = - HdWallet.fromMnemonic(_myWalletProvider.mnemonic) - .getPubkey(_repository.derivation!); + _walletOptions.getAddress( + _currentChestNumber, _repository.derivation!); Navigator.push( context, SmoothTransition( @@ -275,10 +273,8 @@ class WalletsHome extends StatelessWidget { // _repository, // _myWalletProvider.pinCode, // pinLength); - _walletOptions.pubkey.text = - HdWallet.fromMnemonic( - _myWalletProvider.mnemonic) - .getPubkey(_repository.derivation!); + _walletOptions.getAddress( + _currentChestNumber, _repository.derivation!); Navigator.push( context, SmoothTransition( diff --git a/lib/screens/onBoarding/0_no_keychain_found.dart b/lib/screens/onBoarding/0_no_keychain_found.dart index 12fe699..59604ff 100644 --- a/lib/screens/onBoarding/0_no_keychain_found.dart +++ b/lib/screens/onBoarding/0_no_keychain_found.dart @@ -1,10 +1,8 @@ // ignore_for_file: file_names import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/screens/common_elements.dart'; -import 'package:gecko/screens/myWallets/import_cesium_wallet.dart'; import 'package:gecko/screens/onBoarding/1.dart'; class NoKeyChainScreen extends StatelessWidget { @@ -66,46 +64,6 @@ class NoKeyChainScreen extends StatelessWidget { fontSize: 16, fontWeight: FontWeight.w500), ), - const SizedBox(height: 70), - Container( - child: ClipOval( - child: Material( - color: const Color(0xffFFD58D), // button color - child: InkWell( - splashColor: orangeC, // inkwell color - child: Padding( - padding: const EdgeInsets.all(12), - child: - // Image( - // image: AssetImage('assets/cesium_bw3.png'), - // height: 60), - SvgPicture.asset('assets/cesium_small.svg', - semanticsLabel: 'Cesium Logo', height: 48), - ), - onTap: () { - Navigator.push(context, - SlideLeftRoute(page: const ImportWalletScreen())); - }), - ), - ), - decoration: const BoxDecoration( - shape: BoxShape.circle, - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Colors.grey, - blurRadius: 4.0, - offset: Offset(2.0, 2.5), - spreadRadius: 0.5) - ], - ), - ), - const SizedBox(height: 10), - const Text( - "Importer un\nportefeuille Cesium", - textAlign: TextAlign.center, - style: TextStyle(color: Colors.black, fontSize: 13), - ) ]), )); } diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index f9cdce1..09738ee 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -4,7 +4,7 @@ import 'package:flutter/services.dart'; import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/screens/myWallets/generate_wallets.dart'; import 'dart:io'; -import 'package:gecko/screens/myWallets/import_cesium_wallet.dart'; +// import 'package:gecko/screens/myWallets/import_cesium_wallet.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/screens/myWallets/restore_chest.dart'; @@ -48,14 +48,15 @@ class SettingsScreen extends StatelessWidget { primary: yellowC, // background onPrimary: Colors.black, // foreground ), - onPressed: () => Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return const ImportWalletScreen(); - }), - ).then((value) => { - if (value == true) {Navigator.pop(context)} - }), + onPressed: null, + // () => Navigator.push( + // context, + // MaterialPageRoute(builder: (context) { + // return const ImportWalletScreen(); + // }), + // ).then((value) => { + // if (value == true) {Navigator.pop(context)} + // }), child: const Text( "Importer un portefeuille Cesium", style: TextStyle(fontSize: 16), diff --git a/lib/screens/substrate_sandbox.dart b/lib/screens/substrate_sandbox.dart index 44346e0..9daa3c5 100644 --- a/lib/screens/substrate_sandbox.dart +++ b/lib/screens/substrate_sandbox.dart @@ -94,7 +94,7 @@ class SubstrateSandBox extends StatelessWidget { child: const Text("Dériver"), ) ]) - ]); + ]); }), const SizedBox(height: 20), const Text('Mot de passe du trousseau:'), diff --git a/pubspec.lock b/pubspec.lock index b168152..bfcfcb1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "38.0.0" + version: "40.0.0" aes_ecb_pkcs5_flutter: dependency: transitive description: @@ -21,7 +21,7 @@ packages: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "3.4.1" + version: "4.1.0" archive: dependency: transitive description: @@ -126,7 +126,7 @@ packages: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.1.10" + version: "2.1.11" build_runner_core: dependency: transitive description: @@ -381,7 +381,7 @@ packages: name: flutter_logs url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "2.1.6" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -412,7 +412,7 @@ packages: name: frontend_server_client url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.3" fuchsia_remote_debug_protocol: dependency: transitive description: flutter @@ -494,7 +494,7 @@ packages: name: graphql url: "https://pub.dartlang.org" source: hosted - version: "5.1.2-beta.1" + version: "5.1.1" graphql_flutter: dependency: "direct main" description: @@ -524,7 +524,7 @@ packages: name: hive url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.1" hive_flutter: dependency: "direct main" description: @@ -538,7 +538,7 @@ packages: name: hive_generator url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.3" http: dependency: "direct main" description: @@ -573,7 +573,7 @@ packages: name: icons_launcher url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "1.1.8" image: dependency: transitive description: @@ -615,7 +615,7 @@ packages: name: image_picker_ios url: "https://pub.dartlang.org" source: hosted - version: "0.8.5+2" + version: "0.8.5+4" image_picker_platform_interface: dependency: transitive description: @@ -1387,7 +1387,7 @@ packages: name: webview_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" webview_flutter_wkwebview: dependency: transitive description: @@ -1401,7 +1401,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.6.0" + version: "2.6.1" window_size: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index a8a2eea..2da7456 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,23 +51,20 @@ dependencies: url: https://github.com/DavBfr/dart_pdf.git path: printing provider: ^6.0.1 - # qrscan: ^0.3.2 - qrscan: + qrscan: #^0.3.2 git: url: https://github.com/leyan95/qrcode_scanner.git ref: master # branch name # qr_code_scanner: ^0.6.1 - # qr_flutter: ^4.0.0 - qr_flutter: + qr_flutter: #^4.0.0 git: url: https://github.com/insinfo/qr.flutter.git ref: master # branch name responsive_builder: ^0.4.1 responsive_framework: ^0.1.4 - sentry: 6.5.1 + sentry: ^6.5.1 sentry_flutter: ^6.5.1 shared_preferences: ^2.0.7 - # super_tooltip: ^1.0.1 sync_http: ^0.3.0 test: ^1.17.10 truncate: ^3.0.1 @@ -78,10 +75,7 @@ dependencies: desktop_window: ^0.4.0 durt: ^0.1.6 package_info_plus: ^1.4.2 - polkawallet_sdk: ^0.4.5 ## Wait for merging PR: https://github.com/polkawallet-io/sdk/pull/19 - # git: - # url: git://github.com/poka-IT/sdk.git - # ref: fixAndroidActivityVersion + polkawallet_sdk: ^0.4.5 flutter_icons: android: true