ADD: The selected balance unit per wallet is now saved.

This commit is contained in:
Marcos Rodriguez Vélez 2018-12-16 11:24:23 -05:00
commit 3b4844490c
8 changed files with 311 additions and 46 deletions

View File

@ -86,12 +86,10 @@ export class AbstractHDWallet extends LegacyWallet {
return this.preferredBalanceUnit; return this.preferredBalanceUnit;
} }
getPreferredBalanceUnitIndex() {
return Object.entries(BitcoinUnit).indexOf(this.getPreferredBalanceUnit);
}
setPreferredBalanceUnit(unit) { setPreferredBalanceUnit(unit) {
this.preferredBalanceUnit = unit; const indexOf = Object.values(BitcoinUnit).indexOf(unit);
const currentPreferredUnit = Object.entries(BitcoinUnit)[indexOf][0];
this.preferredBalanceUnit = currentPreferredUnit;
return this; return this;
} }

View File

@ -39,12 +39,10 @@ export class AbstractWallet {
return this.preferredBalanceUnit; return this.preferredBalanceUnit;
} }
getPreferredBalanceUnitIndex() {
return Object.entries(BitcoinUnit).indexOf(this.getPreferredBalanceUnit);
}
setPreferredBalanceUnit(unit) { setPreferredBalanceUnit(unit) {
this.preferredBalanceUnit = unit; const indexOf = Object.values(BitcoinUnit).indexOf(unit);
const currentPreferredUnit = Object.entries(BitcoinUnit)[indexOf][0];
this.preferredBalanceUnit = currentPreferredUnit;
return this; return this;
} }

View File

@ -1,5 +1,6 @@
import { LegacyWallet } from './legacy-wallet'; import { LegacyWallet } from './legacy-wallet';
import Frisbee from 'frisbee'; import Frisbee from 'frisbee';
import { BitcoinUnit } from '../models/bitcoinUnits';
let BigNumber = require('bignumber.js'); let BigNumber = require('bignumber.js');
export class LightningCustodianWallet extends LegacyWallet { export class LightningCustodianWallet extends LegacyWallet {
@ -15,6 +16,7 @@ export class LightningCustodianWallet extends LegacyWallet {
this.refill_addressess = []; this.refill_addressess = [];
this.pending_transactions_raw = []; this.pending_transactions_raw = [];
this.info_raw = false; this.info_raw = false;
this.preferredBalanceUnit = BitcoinUnit.SATOSHIS;
} }
/** /**
@ -499,6 +501,17 @@ export class LightningCustodianWallet extends LegacyWallet {
allowReceive() { allowReceive() {
return false; return false;
} }
getPreferredBalanceUnit() {
return this.preferredBalanceUnit;
}
setPreferredBalanceUnit(unit) {
const indexOf = Object.values(BitcoinUnit).indexOf(unit);
const currentPreferredUnit = Object.entries(BitcoinUnit)[indexOf][0];
this.preferredBalanceUnit = currentPreferredUnit;
return this;
}
} }
/* /*

View File

@ -17,15 +17,11 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<<<<<<< HEAD <string>3.3.1</string>
<string>3.2.1</string>
=======
<string>3.3.0</string>
>>>>>>> a4fe0c201c07e0b879076d4391705fe29b04a7d2
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>147</string> <string>149</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSAppTransportSecurity</key> <key>NSAppTransportSecurity</key>

270
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "BlueWallet", "name": "BlueWallet",
"version": "3.2.3", "version": "3.3.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -2839,6 +2839,37 @@
"wif": "^2.0.1" "wif": "^2.0.1"
} }
}, },
"bl": {
"version": "0.8.2",
"resolved": "http://registry.npmjs.org/bl/-/bl-0.8.2.tgz",
"integrity": "sha1-yba8oI0bwuoA/Ir7Txpf0eHGbk4=",
"requires": {
"readable-stream": "~1.0.26"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"readable-stream": {
"version": "1.0.34",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
}
}
},
"bn.js": { "bn.js": {
"version": "4.11.8", "version": "4.11.8",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz",
@ -3246,6 +3277,11 @@
} }
} }
}, },
"clone": {
"version": "0.1.19",
"resolved": "https://registry.npmjs.org/clone/-/clone-0.1.19.tgz",
"integrity": "sha1-YT+2hjmyaklKxTJT4Vsaa9iK2oU="
},
"co": { "co": {
"version": "4.6.0", "version": "4.6.0",
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
@ -3711,6 +3747,14 @@
} }
} }
}, },
"deferred-leveldown": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/deferred-leveldown/-/deferred-leveldown-0.2.0.tgz",
"integrity": "sha1-LO8fER4cV4cNi7uK8mUOWHzS9bQ=",
"requires": {
"abstract-leveldown": "~0.12.1"
}
},
"define-properties": { "define-properties": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
@ -3934,6 +3978,14 @@
"resolved": "https://registry.npmjs.org/envinfo/-/envinfo-5.12.1.tgz", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-5.12.1.tgz",
"integrity": "sha512-pwdo0/G3CIkQ0y6PCXq4RdkvId2elvtPCJMG0konqlrfkWQbf1DWeH9K2b/cvu2YgGvPPTOnonZxXM1gikFu1w==" "integrity": "sha512-pwdo0/G3CIkQ0y6PCXq4RdkvId2elvtPCJMG0konqlrfkWQbf1DWeH9K2b/cvu2YgGvPPTOnonZxXM1gikFu1w=="
}, },
"errno": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
"integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==",
"requires": {
"prr": "~1.0.1"
}
},
"error-ex": { "error-ex": {
"version": "1.3.2", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@ -4683,6 +4735,11 @@
"for-in": "^1.0.1" "for-in": "^1.0.1"
} }
}, },
"foreach": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
"integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k="
},
"forever-agent": { "forever-agent": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
@ -5232,6 +5289,37 @@
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
"dev": true "dev": true
}, },
"fwd-stream": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/fwd-stream/-/fwd-stream-1.0.4.tgz",
"integrity": "sha1-7Sgcq+1G/uz5Ie4y3ExQs3KsfPo=",
"requires": {
"readable-stream": "~1.0.26-4"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"readable-stream": {
"version": "1.0.34",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
}
}
},
"gauge": { "gauge": {
"version": "1.2.7", "version": "1.2.7",
"resolved": "https://registry.npmjs.org/gauge/-/gauge-1.2.7.tgz", "resolved": "https://registry.npmjs.org/gauge/-/gauge-1.2.7.tgz",
@ -5675,6 +5763,11 @@
"integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=",
"dev": true "dev": true
}, },
"indexof": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10="
},
"inflight": { "inflight": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@ -5738,6 +5831,11 @@
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz",
"integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY="
}, },
"is": {
"version": "0.2.7",
"resolved": "http://registry.npmjs.org/is/-/is-0.2.7.tgz",
"integrity": "sha1-OzSixI81mXLzUEKEkZOucmS2NWI="
},
"is-accessor-descriptor": { "is-accessor-descriptor": {
"version": "0.1.6", "version": "0.1.6",
"resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
@ -5904,6 +6002,11 @@
} }
} }
}, },
"is-object": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/is-object/-/is-object-0.1.2.tgz",
"integrity": "sha1-AO+8CIFsM8/ErIJR0TLhDcZQmNc="
},
"is-plain-object": { "is-plain-object": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
@ -8115,6 +8218,137 @@
"integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==", "integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==",
"dev": true "dev": true
}, },
"level-blobs": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/level-blobs/-/level-blobs-0.1.7.tgz",
"integrity": "sha1-mrm5e7mfHtv594o0M+Ie1WOGva8=",
"requires": {
"level-peek": "1.0.6",
"once": "^1.3.0",
"readable-stream": "^1.0.26-4"
}
},
"level-filesystem": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/level-filesystem/-/level-filesystem-1.2.0.tgz",
"integrity": "sha1-oArKmRnEpN+v3KaoEI0iWq3/Y7M=",
"requires": {
"concat-stream": "^1.4.4",
"errno": "^0.1.1",
"fwd-stream": "^1.0.4",
"level-blobs": "^0.1.7",
"level-peek": "^1.0.6",
"level-sublevel": "^5.2.0",
"octal": "^1.0.0",
"once": "^1.3.0",
"xtend": "^2.2.0"
},
"dependencies": {
"xtend": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-2.2.0.tgz",
"integrity": "sha1-7vax8ZjByN6vrYsXZaBNrUoBxak="
}
}
},
"level-fix-range": {
"version": "1.0.2",
"resolved": "http://registry.npmjs.org/level-fix-range/-/level-fix-range-1.0.2.tgz",
"integrity": "sha1-vxW5Fa422EcMgh6IPd95zRZCCCg="
},
"level-hooks": {
"version": "4.5.0",
"resolved": "http://registry.npmjs.org/level-hooks/-/level-hooks-4.5.0.tgz",
"integrity": "sha1-G5rmGSKTDzMF0aYfxNg8gQLA3ZM=",
"requires": {
"string-range": "~1.2"
}
},
"level-peek": {
"version": "1.0.6",
"resolved": "http://registry.npmjs.org/level-peek/-/level-peek-1.0.6.tgz",
"integrity": "sha1-vsUccqgu5GTTNkNMfIdsP8vM538=",
"requires": {
"level-fix-range": "~1.0.2"
}
},
"level-sublevel": {
"version": "5.2.3",
"resolved": "http://registry.npmjs.org/level-sublevel/-/level-sublevel-5.2.3.tgz",
"integrity": "sha1-dEwSxy0ucr543eO5tc2E1iGRQTo=",
"requires": {
"level-fix-range": "2.0",
"level-hooks": ">=4.4.0 <5",
"string-range": "~1.2.1",
"xtend": "~2.0.4"
},
"dependencies": {
"level-fix-range": {
"version": "2.0.0",
"resolved": "http://registry.npmjs.org/level-fix-range/-/level-fix-range-2.0.0.tgz",
"integrity": "sha1-xBfWIVlEIVGhnZojZ4aPFyTC1Ug=",
"requires": {
"clone": "~0.1.9"
}
},
"xtend": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-2.0.6.tgz",
"integrity": "sha1-XqZXptukRwacLlnFihE4ywxebO4=",
"requires": {
"is-object": "~0.1.2",
"object-keys": "~0.2.0"
}
}
}
},
"levelup": {
"version": "0.18.6",
"resolved": "https://registry.npmjs.org/levelup/-/levelup-0.18.6.tgz",
"integrity": "sha1-5qAcsIlhbI7MApHCqb0/DETj5es=",
"requires": {
"bl": "~0.8.1",
"deferred-leveldown": "~0.2.0",
"errno": "~0.1.1",
"prr": "~0.0.0",
"readable-stream": "~1.0.26",
"semver": "~2.3.1",
"xtend": "~3.0.0"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"prr": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz",
"integrity": "sha1-GoS4WQgyVQFBGFPQCB7j+obikmo="
},
"readable-stream": {
"version": "1.0.34",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"semver": {
"version": "2.3.2",
"resolved": "http://registry.npmjs.org/semver/-/semver-2.3.2.tgz",
"integrity": "sha1-uYSPJdbPNjMwc+ye+IVtQvEjPlI="
},
"string_decoder": {
"version": "0.10.31",
"resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
}
}
},
"leven": { "leven": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz",
@ -9248,6 +9482,16 @@
} }
} }
}, },
"object-keys": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.2.0.tgz",
"integrity": "sha1-zd7AKZiwkb5CvxA1rjLknxy26mc=",
"requires": {
"foreach": "~2.0.1",
"indexof": "~0.0.1",
"is": "~0.2.6"
}
},
"object-visit": { "object-visit": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz",
@ -9297,6 +9541,11 @@
} }
} }
}, },
"octal": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/octal/-/octal-1.0.0.tgz",
"integrity": "sha1-Y+cWKmjvvrniE1iNWOmJ0eXEUws="
},
"on-finished": { "on-finished": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
@ -9949,6 +10198,11 @@
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz",
"integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=" "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4="
}, },
"prr": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
"integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY="
},
"pseudomap": { "pseudomap": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
@ -10385,6 +10639,15 @@
"resolved": "https://registry.npmjs.org/react-native-haptic-feedback/-/react-native-haptic-feedback-1.4.2.tgz", "resolved": "https://registry.npmjs.org/react-native-haptic-feedback/-/react-native-haptic-feedback-1.4.2.tgz",
"integrity": "sha512-uLtdxKL4nul5QQUczctCdAr2b6P7/KPLyfQVP8lfcVaNANHpL1WFhCnrWPNCkh2LHSduA88MNgPcTsN9CHbwlw==" "integrity": "sha512-uLtdxKL4nul5QQUczctCdAr2b6P7/KPLyfQVP8lfcVaNANHpL1WFhCnrWPNCkh2LHSduA88MNgPcTsN9CHbwlw=="
}, },
"react-native-level-fs": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/react-native-level-fs/-/react-native-level-fs-3.0.1.tgz",
"integrity": "sha1-8wVGFMK8Gjedyz0+5RtqG2YSMoM=",
"requires": {
"level-filesystem": "^1.0.1",
"levelup": "^0.18.2"
}
},
"react-native-linear-gradient": { "react-native-linear-gradient": {
"version": "2.5.3", "version": "2.5.3",
"resolved": "https://registry.npmjs.org/react-native-linear-gradient/-/react-native-linear-gradient-2.5.3.tgz", "resolved": "https://registry.npmjs.org/react-native-linear-gradient/-/react-native-linear-gradient-2.5.3.tgz",
@ -12065,6 +12328,11 @@
} }
} }
}, },
"string-range": {
"version": "1.2.2",
"resolved": "http://registry.npmjs.org/string-range/-/string-range-1.2.2.tgz",
"integrity": "sha1-qJPtNH5yKZvIO++78qaSqNI51d0="
},
"string-width": { "string-width": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",

View File

@ -71,6 +71,7 @@
"react-native-gesture-handler": "^1.0.11", "react-native-gesture-handler": "^1.0.11",
"react-native-google-analytics-bridge": "^6.1.2", "react-native-google-analytics-bridge": "^6.1.2",
"react-native-haptic-feedback": "^1.4.2", "react-native-haptic-feedback": "^1.4.2",
"react-native-level-fs": "^3.0.1",
"react-native-linear-gradient": "^2.5.3", "react-native-linear-gradient": "^2.5.3",
"react-native-material-dropdown": "^0.11.1", "react-native-material-dropdown": "^0.11.1",
"react-native-modal": "^7.0.2", "react-native-modal": "^7.0.2",

View File

@ -3,10 +3,8 @@ import React, { Component } from 'react';
import { ActivityIndicator, View, Text, TextInput, Alert, TouchableOpacity, Keyboard, TouchableWithoutFeedback } from 'react-native'; import { ActivityIndicator, View, Text, TextInput, Alert, TouchableOpacity, Keyboard, TouchableWithoutFeedback } from 'react-native';
import { BlueButton, SafeBlueArea, BlueCard, BlueSpacing20, BlueNavigationStyle } from '../../BlueComponents'; import { BlueButton, SafeBlueArea, BlueCard, BlueSpacing20, BlueNavigationStyle } from '../../BlueComponents';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { ButtonGroup } from 'react-native-elements';
import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet'; import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { BitcoinUnit } from '../../models/bitcoinUnits';
let EV = require('../../events'); let EV = require('../../events');
/** @type {AppStorage} */ /** @type {AppStorage} */
let BlueApp = require('../../BlueApp'); let BlueApp = require('../../BlueApp');
@ -67,10 +65,6 @@ export default class WalletDetails extends Component {
this.props.navigation.goBack(null); this.props.navigation.goBack(null);
} }
updatePreferredBalanceUnit = selectedIndex => {
this.state.wallet.setPreferredBalanceUnit(Object.entries(BitcoinUnit)[selectedIndex][0]);
};
render() { render() {
if (this.state.isLoading) { if (this.state.isLoading) {
return ( return (
@ -129,15 +123,6 @@ export default class WalletDetails extends Component {
{loc.wallets.details.type.toLowerCase()} {loc.wallets.details.type.toLowerCase()}
</Text> </Text>
<Text style={{ color: '#81868e', fontWeight: '500', fontSize: 14 }}>{this.state.wallet.getTypeReadable()}</Text> <Text style={{ color: '#81868e', fontWeight: '500', fontSize: 14 }}>{this.state.wallet.getTypeReadable()}</Text>
<Text style={{ color: '#0c2550', fontWeight: '500', fontSize: 14, marginVertical: 12 }}>
{loc.wallets.details.displayBalanceUsing.toLowerCase()}
</Text>
<ButtonGroup
onPress={this.updatePreferredBalanceUnit}
selectedIndex={Number(this.state.wallet.getPreferredBalanceUnitIndex)}
buttons={[BitcoinUnit.BTC, BitcoinUnit.MBTC, BitcoinUnit.BITS, BitcoinUnit.SATOSHIS, BitcoinUnit.LOCAL_CURRENCY]}
/>
</BlueCard> </BlueCard>
<View> <View>
<BlueSpacing20 /> <BlueSpacing20 />

View File

@ -64,7 +64,6 @@ export default class WalletTransactions extends Component {
isTransactionsLoading: false, isTransactionsLoading: false,
wallet: wallet, wallet: wallet,
dataSource: wallet.getTransactions(), dataSource: wallet.getTransactions(),
walletBalanceUnit: wallet.getPreferredBalanceUnit(),
}; };
} }
@ -122,7 +121,6 @@ export default class WalletTransactions extends Component {
showManageFundsBigButton, showManageFundsBigButton,
showManageFundsSmallButton, showManageFundsSmallButton,
dataSource: txs, dataSource: txs,
walletBalanceUnit: wallet.getPreferredBalanceUnit(),
}); });
}, 1); }, 1);
} }
@ -176,17 +174,22 @@ export default class WalletTransactions extends Component {
} }
changeWalletBalanceUnit() { changeWalletBalanceUnit() {
if (BitcoinUnit[this.state.walletBalanceUnit] === undefined || BitcoinUnit[this.state.walletBalanceUnit] === BitcoinUnit.BTC) { const indexOf = Object.keys(BitcoinUnit).indexOf(this.state.wallet.getPreferredBalanceUnit());
this.setState({ walletBalanceUnit: BitcoinUnit.LOCAL_CURRENCY }); const currentPreferredUnit = Object.entries(BitcoinUnit)[indexOf][0];
} else if (BitcoinUnit[this.state.walletBalanceUnit] === BitcoinUnit.MBTC) { const { wallet } = this.state;
this.setState({ walletBalanceUnit: BitcoinUnit.BITS });
} else if (BitcoinUnit[this.state.walletBalanceUnit] === BitcoinUnit.BITS) { if (BitcoinUnit[currentPreferredUnit] === undefined || BitcoinUnit[currentPreferredUnit] === BitcoinUnit.BTC) {
this.setState({ walletBalanceUnit: BitcoinUnit.SATOSHIS }); wallet.setPreferredBalanceUnit(BitcoinUnit.LOCAL_CURRENCY);
} else if (BitcoinUnit[this.state.walletBalanceUnit] === BitcoinUnit.SATOSHIS) { } else if (BitcoinUnit[currentPreferredUnit] === BitcoinUnit.MBTC) {
this.setState({ walletBalanceUnit: BitcoinUnit.BTC }); wallet.setPreferredBalanceUnit(BitcoinUnit.BITS);
} else if (BitcoinUnit[this.state.walletBalanceUnit] === BitcoinUnit.LOCAL_CURRENCY) { } else if (BitcoinUnit[currentPreferredUnit] === BitcoinUnit.BITS) {
this.setState({ walletBalanceUnit: BitcoinUnit.MBTC }); wallet.setPreferredBalanceUnit(BitcoinUnit.SATOSHIS);
} else if (BitcoinUnit[currentPreferredUnit] === BitcoinUnit.SATOSHIS) {
wallet.setPreferredBalanceUnit(BitcoinUnit.BTC);
} else if (BitcoinUnit[currentPreferredUnit] === BitcoinUnit.LOCAL_CURRENCY) {
wallet.setPreferredBalanceUnit(BitcoinUnit.MBTC);
} }
this.setState({ wallet: wallet }, () => BlueApp.saveToDisk());
} }
renderWalletHeader = () => { renderWalletHeader = () => {
@ -229,7 +232,7 @@ export default class WalletTransactions extends Component {
color: '#fff', color: '#fff',
}} }}
> >
{loc.formatBalance(this.state.wallet.getBalance(), this.state.walletBalanceUnit)} {loc.formatBalance(this.state.wallet.getBalance(), this.state.wallet.getPreferredBalanceUnit())}
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
<Text style={{ backgroundColor: 'transparent' }} /> <Text style={{ backgroundColor: 'transparent' }} />
@ -440,7 +443,10 @@ export default class WalletTransactions extends Component {
containerStyle: { marginTop: 0 }, containerStyle: { marginTop: 0 },
}} }}
hideChevron hideChevron
rightTitle={new BigNumber((rowData.item.value && rowData.item.value) || 0).dividedBy(100000000).toString()} rightTitle={loc.formatBalance(
new BigNumber((rowData.item.value && rowData.item.value) || 0).dividedBy(100000000),
this.state.wallet.getPreferredBalanceUnit(),
)}
rightTitleStyle={{ rightTitleStyle={{
fontWeight: '600', fontWeight: '600',
fontSize: 16, fontSize: 16,