[Android, iOS] Advanced ClojureScript compilation

This commit is contained in:
Roman Volosovskyi 2019-05-29 19:52:41 +03:00
parent f03225c03d
commit daacccb512
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
11 changed files with 687 additions and 108 deletions

View File

@ -64,7 +64,7 @@ pipeline {
} }
stage('Build') { stage('Build') {
steps { steps {
script { cmn.nix.shell('lein prod-build-android') } script { cmn.nix.shell('lein prod-build-android')}
} }
} }
stage('Bundle') { stage('Bundle') {

View File

@ -39,7 +39,7 @@ pipeline {
stages { stages {
stage('Prep') { stage('Prep') {
steps { steps {
script { script {
/* Necessary to load methods */ /* Necessary to load methods */
mobile = load 'ci/mobile.groovy' mobile = load 'ci/mobile.groovy'
cmn = load 'ci/common.groovy' cmn = load 'ci/common.groovy'

561
externs.js Normal file
View File

@ -0,0 +1,561 @@
var TopLevel = {
"abs" : function () {},
"ActionSheetIOS" : function () {},
"add" : function () {},
"addEventListener" : function () {},
"addListener" : function () {},
"addPeer" : function () {},
"addSymKey" : function () {},
"addTier2Support" : function () {},
"Alert" : function () {},
"alert" : function () {},
"all" : function () {},
"Android" : function () {},
"android" : function () {},
"Animated" : function () {},
"append" : function () {},
"appStateChange" : function () {},
"args" : function () {},
"argv" : function () {},
"Array" : function () {},
"array" : function () {},
"at" : function () {},
"back" : function () {},
"balanceOf" : function () {},
"bezier" : function () {},
"blur" : function () {},
"button" : function () {},
"bytesToHex" : function () {},
"call" : function () {},
"callPrivateRPC" : function () {},
"callRPC" : function () {},
"canImplyAuthentication" : function () {},
"capture" : function () {},
"catch" : function () {},
"Chance" : function () {},
"changePin" : function () {},
"Channel" : function () {},
"chaosModeUpdate" : function () {},
"charCodeAt" : function () {},
"checkAddressChecksum" : function () {},
"checkVideoAuthorizationStatus" : function () {},
"clear" : function () {},
"clearCookies" : function () {},
"clearInterval" : function () {},
"clearStorageAPIs" : function () {},
"clearTimeout" : function () {},
"Clipboard" : function () {},
"close" : function () {},
"closeApplication" : function () {},
"code" : function () {},
"concat" : function () {},
"confirmMessagesProcessed" : function () {},
"confirmMessagesProcessedByID" : function () {},
"connectionChange" : function () {},
"console" : function () {},
"ContactRequest" : function () {},
"ContactRequestConfirmed" : function () {},
"ContactRequestConfirmedHandler" : function () {},
"ContactRequestHandler" : function () {},
"ContactUpdate" : function () {},
"ContactUpdateHandler" : function () {},
"contentOffset" : function () {},
"contentSize" : function () {},
"contract" : function () {},
"create" : function () {},
"createAccount" : function () {},
"createBatch" : function () {},
"createChannel" : function () {},
"cubic" : function () {},
"CURRENCY" : function () {},
"data" : function () {},
"Date" : function () {},
"DateTimeFormat" : function () {},
"DEBUG" : function () {},
"decay" : function () {},
"DECIMAL_SEP" : function () {},
"GROUP_SEP" : function () {},
"PERCENT" : function () {},
"ZERO_DIGIT" : function () {},
"PLUS_SIGN" : function () {},
"MINUS_SIGN" : function () {},
"EXP_SYMBOL" : function () {},
"PERMILL" : function () {},
"INFINITY" : function () {},
"NAN" : function () {},
"DECIMAL_PATTERN" : function () {},
"SCIENTIFIC_PATTERN" : function () {},
"PERCENT_PATTERN" : function () {},
"CURRENCY_PATTERN" : function () {},
"DEF_CURRENCY_CODE" : function () {},
"decimals" : function () {},
"decodeURI" : function () {},
"default" : function () {},
"defaultAccount" : function () {},
"defaultPath" : function () {},
"defaultSeparator" : function () {},
"delay" : function () {},
"delete" : function () {},
"DesktopNotification" : function () {},
"DeviceEventEmitter" : function () {},
"Dimensions" : function () {},
"disableInstallation" : function () {},
"dispatch" : function () {},
"displayNotification" : function () {},
"dividedBy" : function () {},
"DocumentDirectoryPath" : function () {},
"dx" : function () {},
"dy" : function () {},
"ease" : function () {},
"Easing" : function () {},
"enableInstallation" : function () {},
"enableVibration" : function () {},
"encode" : function () {},
"encodeURIComponent" : function () {},
"encryptionKey" : function () {},
"end" : function () {},
"endCoordinates" : function () {},
"entries" : function () {},
"eq" : function () {},
"Error" : function () {},
"error" : function () {},
"ErrorUtils" : function () {},
"estimateGas" : function () {},
"eth" : function () {},
"event" : function () {},
"EventEmmiter" : function () {},
"exec" : function () {},
"execute" : function () {},
"exists" : function () {},
"extPost" : function () {},
"extractGroupMembershipSignatures" : function () {},
"fallbacks" : function () {},
"fetch" : function () {},
"filtered" : function () {},
"firebase" : function () {},
"floor" : function () {},
"focus" : function () {},
"format" : function () {},
"FormData" : function () {},
"from" : function () {},
"fromAscii" : function () {},
"fromCharCode" : function () {},
"fromUtf8" : function () {},
"fromWei" : function () {},
"generateAndLoadKey" : function () {},
"generateMnemonic" : function () {},
"generateSecureRandom" : function () {},
"generateSymKeyFromPassword" : function () {},
"get" : function () {},
"getApplicationInfo" : function () {},
"getBalance" : function () {},
"getBlock" : function () {},
"getBlockNumber" : function () {},
"getConnectionInfo" : function () {},
"getDeviceUUID" : function () {},
"getDomain" : function () {},
"getGasPrice" : function () {},
"getGenericPassword" : function () {},
"getGlobalHandler" : function () {},
"getInitialNotification" : function () {},
"getInitialURL" : function () {},
"getInternetCredentials" : function () {},
"getKeys" : function () {},
"getLayout" : function () {},
"getNetwork" : function () {},
"getNode" : function () {},
"getNodesFromContract" : function () {},
"getPublicKey" : function () {},
"getSecurityLevel" : function () {},
"getString" : function () {},
"getSymKey" : function () {},
"getSyncing" : function () {},
"getTimezoneOffset" : function () {},
"getToken" : function () {},
"getTransactionReceipt" : function () {},
"getValue" : function () {},
"goog" : function () {},
"greaterThanOrEqualTo" : function () {},
"GroupMembershipUpdate" : function () {},
"GroupMembershipUpdateHandler" : function () {},
"guid" : function () {},
"hashMessage" : function () {},
"hashTransaction" : function () {},
"hashTypedData" : function () {},
"headers" : function () {},
"height" : function () {},
"hexToNumber" : function () {},
"hexToNumberString" : function () {},
"hexToUtf8" : function () {},
"hide" : function () {},
"i18n" : function () {},
"ignoreWarnings" : function () {},
"in" : function () {},
"index" : function () {},
"indexOf" : function () {},
"init" : function () {},
"injectJavaScript" : function () {},
"installApplet" : function () {},
"installAppletAndInitCard" : function () {},
"Int8Array" : function () {},
"integer" : function () {},
"interpolate" : function () {},
"is24Hour" : function () {},
"isAddress" : function () {},
"isConnected" : function () {},
"isConnectionExpensive" : function () {},
"isDeviceRooted" : function () {},
"isFocused" : function () {},
"isLinux" : function () {},
"isMacOs" : function () {},
"isMatches" : function () {},
"isNaN" : function () {},
"isUnix" : function () {},
"isWin" : function () {},
"isZero" : function () {},
"Item" : function () {},
"item" : function () {},
"JSON" : function () {},
"jsonEvent" : function () {},
"keccak512" : function () {},
"Keyboard" : function () {},
"language" : function () {},
"layout" : function () {},
"layoutMeasurement" : function () {},
"leftPad" : function () {},
"length" : function () {},
"LibraryDirectoryPath" : function () {},
"Linking" : function () {},
"locale" : function () {},
"log" : function () {},
"login" : function () {},
"loginWithKeycard" : function () {},
"loop" : function () {},
"lt" : function () {},
"mail" : function () {},
"map" : function () {},
"map->GroupMembershipUpdate" : function () {},
"MapEntry" : function () {},
"markTrustedPeer" : function () {},
"MaskedData" : function () {},
"Math" : function () {},
"Message" : function () {},
"message" : function () {},
"MessageHandler" : function () {},
"MessagesSeen" : function () {},
"MessagesSeenHandler" : function () {},
"messaging" : function () {},
"method" : function () {},
"minus" : function () {},
"mkdir" : function () {},
"module" : function () {},
"moveFile" : function () {},
"Multihash" : function () {},
"name" : function () {},
"nativeEvent" : function () {},
"NativeEventEmitter" : function () {},
"NativeModules" : function () {},
"navigate" : function () {},
"navigation" : function () {},
"NavigationActions" : function () {},
"NavigationEvents" : function () {},
"newKeyPair" : function () {},
"newMessageFilter" : function () {},
"newSymKey" : function () {},
"nfcIsEnabled" : function () {},
"nfcIsSupported" : function () {},
"Notification" : function () {},
"notification" : function () {},
"notifications" : function () {},
"now" : function () {},
"Number" : function () {},
"NumberFormatSymbols" : function () {},
"NumberFormatSymbols_af" : function () {},
"NumberFormatSymbols_am" : function () {},
"NumberFormatSymbols_ar" : function () {},
"NumberFormatSymbols_ar_DZ" : function () {},
"NumberFormatSymbols_az" : function () {},
"NumberFormatSymbols_be" : function () {},
"NumberFormatSymbols_bg" : function () {},
"NumberFormatSymbols_bn" : function () {},
"NumberFormatSymbols_br" : function () {},
"NumberFormatSymbols_bs" : function () {},
"NumberFormatSymbols_cs" : function () {},
"NumberFormatSymbols_cy" : function () {},
"NumberFormatSymbols_da" : function () {},
"NumberFormatSymbols_de_CH" : function () {},
"NumberFormatSymbols_en" : function () {},
"NumberFormatSymbols_en_AU" : function () {},
"NumberFormatSymbols_en_CA" : function () {},
"NumberFormatSymbols_en_IN" : function () {},
"NumberFormatSymbols_en_SG" : function () {},
"NumberFormatSymbols_es_419" : function () {},
"NumberFormatSymbols_fa" : function () {},
"NumberFormatSymbols_fil" : function () {},
"NumberFormatSymbols_he" : function () {},
"NumberFormatSymbols_hr" : function () {},
"NumberFormatSymbols_hu" : function () {},
"NumberFormatSymbols_hy" : function () {},
"NumberFormatSymbols_id" : function () {},
"NumberFormatSymbols_is" : function () {},
"NumberFormatSymbols_ja" : function () {},
"NumberFormatSymbols_ka" : function () {},
"NumberFormatSymbols_kk" : function () {},
"NumberFormatSymbols_km" : function () {},
"NumberFormatSymbols_ko" : function () {},
"NumberFormatSymbols_ky" : function () {},
"NumberFormatSymbols_ln" : function () {},
"NumberFormatSymbols_lo" : function () {},
"NumberFormatSymbols_mk" : function () {},
"NumberFormatSymbols_mn" : function () {},
"NumberFormatSymbols_mo" : function () {},
"NumberFormatSymbols_ms" : function () {},
"NumberFormatSymbols_my" : function () {},
"NumberFormatSymbols_nb" : function () {},
"NumberFormatSymbols_ne" : function () {},
"NumberFormatSymbols_pl" : function () {},
"NumberFormatSymbols_pt" : function () {},
"NumberFormatSymbols_ro" : function () {},
"NumberFormatSymbols_ru" : function () {},
"NumberFormatSymbols_sh" : function () {},
"NumberFormatSymbols_si" : function () {},
"NumberFormatSymbols_sq" : function () {},
"NumberFormatSymbols_sv" : function () {},
"NumberFormatSymbols_sw" : function () {},
"NumberFormatSymbols_th" : function () {},
"NumberFormatSymbols_tr" : function () {},
"NumberFormatSymbols_uk" : function () {},
"NumberFormatSymbols_ur" : function () {},
"NumberFormatSymbols_uz" : function () {},
"NumberFormatSymbols_vi" : function () {},
"NumberFormatSymbols_zh" : function () {},
"NumberFormatSymbols_zh_HK" : function () {},
"NumberFormatSymbols_zh_TW" : function () {},
"numberToHex" : function () {},
"objectForPrimaryKey" : function () {},
"objects" : function () {},
"ok" : function () {},
"onMessage" : function () {},
"onNotification" : function () {},
"onNotificationOpened" : function () {},
"onTokenRefresh" : function () {},
"openNfcSettings" : function () {},
"openPicker" : function () {},
"openURL" : function () {},
"OS" : function () {},
"out" : function () {},
"p" : function () {},
"pageY" : function () {},
"pair" : function () {},
"PairInstallation" : function () {},
"PairInstallationHandler" : function () {},
"panHandlers" : function () {},
"PanResponder" : function () {},
"parallel" : function () {},
"parse" : function () {},
"parseFloat" : function () {},
"parseInt" : function () {},
"password" : function () {},
"path" : function () {},
"payload" : function () {},
"PermissionsAndroid" : function () {},
"PersistentPriorityMap" : function () {},
"PersonalRequestCommand" : function () {},
"PersonalSendCommand" : function () {},
"Platform" : function () {},
"pow" : function () {},
"Priority" : function () {},
"Category" : function () {},
"High" : function () {},
"Importance" : function () {},
"Promise" : function () {},
"props" : function () {},
"prototype" : function () {},
"push" : function () {},
"quad" : function () {},
"ReactNative" : function () {},
"readDir" : function () {},
"readFile" : function () {},
"realm" : function () {},
"recoverAccount" : function () {},
"reduce" : function () {},
"register" : function () {},
"registerComponent" : function () {},
"registerHeadlessTask" : function () {},
"reject" : function () {},
"reload" : function () {},
"remove" : function () {},
"removeAllListeners" : function () {},
"removeEventListener" : function () {},
"removeKey" : function () {},
"removeKeyWithUnpair" : function () {},
"removeListener" : function () {},
"repeat" : function () {},
"request" : function () {},
"requestMessages" : function () {},
"requestMultiple" : function () {},
"requestPermission" : function () {},
"require" : function () {},
"reset" : function () {},
"resetGenericPassword" : function () {},
"resetInternetCredentials" : function () {},
"resolve" : function () {},
"respond" : function () {},
"rightPad" : function () {},
"round" : function () {},
"routeName" : function () {},
"routes" : function () {},
"schemaVersion" : function () {},
"scrollTo" : function () {},
"scrollToEnd" : function () {},
"scrollToIndex" : function () {},
"section" : function () {},
"selection" : function () {},
"sendDataNotification" : function () {},
"sendDirectMessage" : function () {},
"sendLogs" : function () {},
"sendPairingMessage" : function () {},
"sendPublicMessage" : function () {},
"sendToBridge" : function () {},
"sendTransaction" : function () {},
"sendTransactionWithSignature" : function () {},
"separators" : function () {},
"sequence" : function () {},
"set" : function () {},
"setAutoCancel" : function () {},
"setBackgroundColor" : function () {},
"setBarStyle" : function () {},
"setCategory" : function () {},
"setChannelId" : function () {},
"setCurrentDapp" : function () {},
"setDockBadgeLabel" : function () {},
"setGenericPassword" : function () {},
"setGlobalHandler" : function () {},
"setGroup" : function () {},
"setHidden" : function () {},
"setInternetCredentials" : function () {},
"setInterval" : function () {},
"setNativeProps" : function () {},
"setNetworkActivityIndicatorVisible" : function () {},
"setPriority" : function () {},
"setShowBadge" : function () {},
"setSmallIcon" : function () {},
"setSoftInputMode" : function () {},
"setSound" : function () {},
"setString" : function () {},
"setTimeout" : function () {},
"setTranslucent" : function () {},
"setUsername" : function () {},
"setValue" : function () {},
"sha3" : function () {},
"Share" : function () {},
"share" : function () {},
"shh" : function () {},
"show" : function () {},
"showActionSheetWithOptions" : function () {},
"showPicker" : function () {},
"sign" : function () {},
"signGroupMembership" : function () {},
"signMessage" : function () {},
"signTypedData" : function () {},
"slice" : function () {},
"sorted" : function () {},
"SplashScreen" : function () {},
"spring" : function () {},
"stack" : function () {},
"StackActions" : function () {},
"start" : function () {},
"startNode" : function () {},
"state" : function () {},
"Status" : function () {},
"status" : function () {},
"statusText" : function () {},
"stop" : function () {},
"stopAnimation" : function () {},
"stopNode" : function () {},
"stopWatching" : function () {},
"stream" : function () {},
"String" : function () {},
"stringify" : function () {},
"subscribe" : function () {},
"substr" : function () {},
"symbol" : function () {},
"SyncInstallation" : function () {},
"SyncInstallationHandler" : function () {},
"t" : function () {},
"Text" : function () {},
"text" : function () {},
"TextEncoder" : function () {},
"then" : function () {},
"times" : function () {},
"timestamp" : function () {},
"timing" : function () {},
"title" : function () {},
"toAscii" : function () {},
"toBigNumber" : function () {},
"toChecksumAddress" : function () {},
"toFixed" : function () {},
"toHex" : function () {},
"toLocaleString" : function () {},
"toNumber" : function () {},
"torchMode" : function () {},
"toString" : function () {},
"totalSupply" : function () {},
"toTwosComplement" : function () {},
"toUtf8" : function () {},
"toWei" : function () {},
"translations" : function () {},
"Uint8Array" : function () {},
"unblockPin" : function () {},
"unlink" : function () {},
"unpair" : function () {},
"unpairAndDelete" : function () {},
"updateMailservers" : function () {},
"Uri" : function () {},
"url" : function () {},
"Value" : function () {},
"value" : function () {},
"verify" : function () {},
"verifyPin" : function () {},
"Version" : function () {},
"version" : function () {},
"View" : function () {},
"warn" : function () {},
"Web3" : function () {},
"WebView" : function () {},
"WebViewBridgeModule" : function () {},
"width" : function () {},
"window" : function () {},
"write" : function () {},
"writeCopyTo" : function () {},
"x" : function () {},
"y" : function () {},
"YellowBox" : function () {},
"UtcDateTime": function () {},
"fromTimestamp": function () {},
"ERAS": function () {},
"ERANAMES": function () {},
"NARROWMONTHS": function () {},
"STANDALONENARROWMONTHS": function () {},
"MONTHS": function () {},
"STANDALONEMONTHS": function () {},
"SHORTMONTHS": function () {},
"STANDALONESHORTMONTHS": function () {},
"WEEKDAYS": function () {},
"STANDALONEWEEKDAYS": function () {},
"SHORTWEEKDAYS": function () {},
"STANDALONESHORTWEEKDAYS": function () {},
"NARROWWEEKDAYS": function () {},
"STANDALONENARROWWEEKDAYS": function () {},
"SHORTQUARTERS": function () {},
"QUARTERS": function () {},
"AMPMS": function () {},
"DATEFORMATS": function () {},
"TIMEFORMATS": function () {},
"DATETIMEFORMATS": function () {},
"FIRSTDAYOFWEEK": function () {},
"WEEKENDRANGE": function () {},
"FIRSTWEEKCUTOFFDAY": function () {},
"decimalPlaces": function () {},
"_android": function () {},
}

View File

@ -2,8 +2,15 @@
:url "https://github.com/status-im/status-react/" :url "https://github.com/status-im/status-react/"
:license {:name "Eclipse Public License" :license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"} :url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.9.0"] :dependencies [[org.clojure/clojure "1.10.0"]
[org.clojure/clojurescript "1.10.238"] [org.clojure/clojurescript "1.10.520"
:exclusions
[com.google.javascript/closure-compiler-unshaded
org.clojure/google-closure-library]]
;; [com.google.javascript/closure-compiler-unshaded "v20180319"]
;; v20180506
[com.google.javascript/closure-compiler-unshaded "v20190325"]
[org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
[org.clojure/core.async "0.4.474"] [org.clojure/core.async "0.4.474"]
[reagent "0.7.0" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server cljsjs/create-react-class]] [reagent "0.7.0" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server cljsjs/create-react-class]]
[status-im/re-frame "0.10.5"] [status-im/re-frame "0.10.5"]
@ -103,11 +110,15 @@
:main "env.ios.main" :main "env.ios.main"
:output-dir "target/ios-prod" :output-dir "target/ios-prod"
:static-fns true :static-fns true
:fn-invoke-direct true
:optimize-constants true :optimize-constants true
:optimizations :simple :optimizations :advanced
:pseudo-names false
:pretty-print false
:closure-defines {"goog.DEBUG" false} :closure-defines {"goog.DEBUG" false}
:parallel-build false :parallel-build false
:elide-asserts true :elide-asserts true
:externs ["externs.js"]
:language-in :ecmascript5} :language-in :ecmascript5}
:warning-handlers [status-im.utils.build/warning-handler]} :warning-handlers [status-im.utils.build/warning-handler]}
:android :android
@ -116,11 +127,15 @@
:main "env.android.main" :main "env.android.main"
:output-dir "target/android-prod" :output-dir "target/android-prod"
:static-fns true :static-fns true
:fn-invoke-direct true
:optimize-constants true :optimize-constants true
:optimizations :simple :optimizations :advanced
:pseudo-names false
:pretty-print false
:closure-defines {"goog.DEBUG" false} :closure-defines {"goog.DEBUG" false}
:parallel-build false :parallel-build false
:elide-asserts true :elide-asserts true
:externs ["externs.js"]
:language-in :ecmascript5} :language-in :ecmascript5}
:warning-handlers [status-im.utils.build/warning-handler]} :warning-handlers [status-im.utils.build/warning-handler]}
:desktop :desktop

View File

@ -334,7 +334,8 @@
(conj (butlast (:coll (reduce offset-reducer {:cnt 0 :coll []} lengths))) 0))) (conj (butlast (:coll (reduce offset-reducer {:cnt 0 :coll []} lengths))) 0)))
(defn hex-to-bytes [hex] (defn hex-to-bytes [hex]
(let [len (* (hex-to-number (subs hex 0 64)) 2)] (let [number (hex-to-number (subs hex 0 64))
len (* (if (nil? number) 0 number) 2)]
(substr hex 64 len))) (substr hex 64 len)))
(defn dyn-hex-to-value [hex type] (defn dyn-hex-to-value [hex type]

View File

@ -854,7 +854,7 @@
:content (i18n/label :t/something-went-wrong)}} :content (i18n/label :t/something-went-wrong)}}
(navigation/navigate-to-cofx :keycard-settings nil))) (navigation/navigate-to-cofx :keycard-settings nil)))
(defn- verify-pin (defn verify-pin
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [pin (vector->string (get-in db [:hardwallet :pin :current])) (let [pin (vector->string (get-in db [:hardwallet :pin :current]))
pairing (get-pairing db) pairing (get-pairing db)
@ -870,7 +870,7 @@
:hardwallet-connect :hardwallet-connect
:hardwallet-connect-settings) nil))))) :hardwallet-connect-settings) nil)))))
(defn- unblock-pin (defn unblock-pin
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [puk (vector->string (get-in db [:hardwallet :pin :puk])) (let [puk (vector->string (get-in db [:hardwallet :pin :puk]))
instance-uid (get-in db [:hardwallet :application-info :instance-uid]) instance-uid (get-in db [:hardwallet :application-info :instance-uid])

View File

@ -284,79 +284,80 @@
([value currency-code] ([value currency-code]
(format-currency value currency-code true)) (format-currency value currency-code true))
([value currency-code currency-symbol?] ([value currency-code currency-symbol?]
(.addTier2Support goog.i18n.currency) (.addTier2Support goog/i18n.currency)
(let [currency-code-to-nfs-map {"ZAR" (.-NumberFormatSymbols_af goog.i18n) (let [currency-code-to-nfs-map {"ZAR" goog/i18n.NumberFormatSymbols_af
"ETB" (.-NumberFormatSymbols_am goog.i18n) "ETB" goog/i18n.NumberFormatSymbols_am
"EGP" (.-NumberFormatSymbols_ar goog.i18n) "EGP" goog/i18n.NumberFormatSymbols_ar
"DZD" (.-NumberFormatSymbols_ar_DZ goog.i18n) "DZD" goog/i18n.NumberFormatSymbols_ar_DZ
"AZN" (.-NumberFormatSymbols_az goog.i18n) "AZN" goog/i18n.NumberFormatSymbols_az
"BYN" (.-NumberFormatSymbols_be goog.i18n) "BYN" goog/i18n.NumberFormatSymbols_be
"BGN" (.-NumberFormatSymbols_bg goog.i18n) "BGN" goog/i18n.NumberFormatSymbols_bg
"BDT" (.-NumberFormatSymbols_bn goog.i18n) "BDT" goog/i18n.NumberFormatSymbols_bn
"EUR" (.-NumberFormatSymbols_br goog.i18n) "EUR" goog/i18n.NumberFormatSymbols_br
"BAM" (.-NumberFormatSymbols_bs goog.i18n) "BAM" goog/i18n.NumberFormatSymbols_bs
"USD" (.-NumberFormatSymbols_en goog.i18n) "USD" goog/i18n.NumberFormatSymbols_en
"CZK" (.-NumberFormatSymbols_cs goog.i18n) "CZK" goog/i18n.NumberFormatSymbols_cs
"GBP" (.-NumberFormatSymbols_cy goog.i18n) "GBP" goog/i18n.NumberFormatSymbols_cy
"DKK" (.-NumberFormatSymbols_da goog.i18n) "DKK" goog/i18n.NumberFormatSymbols_da
"CHF" (.-NumberFormatSymbols_de_CH goog.i18n) "CHF" goog/i18n.NumberFormatSymbols_de_CH
"AUD" (.-NumberFormatSymbols_en_AU goog.i18n) "AUD" goog/i18n.NumberFormatSymbols_en_AU
"CAD" (.-NumberFormatSymbols_en_CA goog.i18n) "CAD" goog/i18n.NumberFormatSymbols_en_CA
"INR" (.-NumberFormatSymbols_en_IN goog.i18n) "INR" goog/i18n.NumberFormatSymbols_en_IN
"SGD" (.-NumberFormatSymbols_en_SG goog.i18n) "SGD" goog/i18n.NumberFormatSymbols_en_SG
"MXN" (.-NumberFormatSymbols_es_419 goog.i18n) "MXN" goog/i18n.NumberFormatSymbols_es_419
"IRR" (.-NumberFormatSymbols_fa goog.i18n) "IRR" goog/i18n.NumberFormatSymbols_fa
"PHP" (.-NumberFormatSymbols_fil goog.i18n) "PHP" goog/i18n.NumberFormatSymbols_fil
"ILS" (.-NumberFormatSymbols_he goog.i18n) "ILS" goog/i18n.NumberFormatSymbols_he
"HRK" (.-NumberFormatSymbols_hr goog.i18n) "HRK" goog/i18n.NumberFormatSymbols_hr
"HUF" (.-NumberFormatSymbols_hu goog.i18n) "HUF" goog/i18n.NumberFormatSymbols_hu
"AMD" (.-NumberFormatSymbols_hy goog.i18n) "AMD" goog/i18n.NumberFormatSymbols_hy
"IDR" (.-NumberFormatSymbols_id goog.i18n) "IDR" goog/i18n.NumberFormatSymbols_id
"ISK" (.-NumberFormatSymbols_is goog.i18n) "ISK" goog/i18n.NumberFormatSymbols_is
"JPY" (.-NumberFormatSymbols_ja goog.i18n) "JPY" goog/i18n.NumberFormatSymbols_ja
"GEL" (.-NumberFormatSymbols_ka goog.i18n) "GEL" goog/i18n.NumberFormatSymbols_ka
"KZT" (.-NumberFormatSymbols_kk goog.i18n) "KZT" goog/i18n.NumberFormatSymbols_kk
"KHR" (.-NumberFormatSymbols_km goog.i18n) "KHR" goog/i18n.NumberFormatSymbols_km
"KRW" (.-NumberFormatSymbols_ko goog.i18n) "KRW" goog/i18n.NumberFormatSymbols_ko
"KGS" (.-NumberFormatSymbols_ky goog.i18n) "KGS" goog/i18n.NumberFormatSymbols_ky
"CDF" (.-NumberFormatSymbols_ln goog.i18n) "CDF" goog/i18n.NumberFormatSymbols_ln
"LAK" (.-NumberFormatSymbols_lo goog.i18n) "LAK" goog/i18n.NumberFormatSymbols_lo
"MKD" (.-NumberFormatSymbols_mk goog.i18n) "MKD" goog/i18n.NumberFormatSymbols_mk
"MNT" (.-NumberFormatSymbols_mn goog.i18n) "MNT" goog/i18n.NumberFormatSymbols_mn
"MDL" (.-NumberFormatSymbols_mo goog.i18n) "MDL" goog/i18n.NumberFormatSymbols_mo
"MYR" (.-NumberFormatSymbols_ms goog.i18n) "MYR" goog/i18n.NumberFormatSymbols_ms
"MMK" (.-NumberFormatSymbols_my goog.i18n) "MMK" goog/i18n.NumberFormatSymbols_my
"NOK" (.-NumberFormatSymbols_nb goog.i18n) "NOK" goog/i18n.NumberFormatSymbols_nb
"NPR" (.-NumberFormatSymbols_ne goog.i18n) "NPR" goog/i18n.NumberFormatSymbols_ne
"PLN" (.-NumberFormatSymbols_pl goog.i18n) "PLN" goog/i18n.NumberFormatSymbols_pl
"BRL" (.-NumberFormatSymbols_pt goog.i18n) "BRL" goog/i18n.NumberFormatSymbols_pt
"RON" (.-NumberFormatSymbols_ro goog.i18n) "RON" goog/i18n.NumberFormatSymbols_ro
"RUB" (.-NumberFormatSymbols_ru goog.i18n) "RUB" goog/i18n.NumberFormatSymbols_ru
"RSD" (.-NumberFormatSymbols_sh goog.i18n) "RSD" goog/i18n.NumberFormatSymbols_sh
"LKR" (.-NumberFormatSymbols_si goog.i18n) "LKR" goog/i18n.NumberFormatSymbols_si
"ALL" (.-NumberFormatSymbols_sq goog.i18n) "ALL" goog/i18n.NumberFormatSymbols_sq
"SEK" (.-NumberFormatSymbols_sv goog.i18n) "SEK" goog/i18n.NumberFormatSymbols_sv
"TZS" (.-NumberFormatSymbols_sw goog.i18n) "TZS" goog/i18n.NumberFormatSymbols_sw
"THB" (.-NumberFormatSymbols_th goog.i18n) "THB" goog/i18n.NumberFormatSymbols_th
"TRY" (.-NumberFormatSymbols_tr goog.i18n) "TRY" goog/i18n.NumberFormatSymbols_tr
"UAH" (.-NumberFormatSymbols_uk goog.i18n) "UAH" goog/i18n.NumberFormatSymbols_uk
"PKR" (.-NumberFormatSymbols_ur goog.i18n) "PKR" goog/i18n.NumberFormatSymbols_ur
"UZS" (.-NumberFormatSymbols_uz goog.i18n) "UZS" goog/i18n.NumberFormatSymbols_uz
"VND" (.-NumberFormatSymbols_vi goog.i18n) "VND" goog/i18n.NumberFormatSymbols_vi
"CNY" (.-NumberFormatSymbols_zh goog.i18n) "CNY" goog/i18n.NumberFormatSymbols_zh
"HKD" (.-NumberFormatSymbols_zh_HK goog.i18n) "HKD" goog/i18n.NumberFormatSymbols_zh_HK
"TWD" (.-NumberFormatSymbols_zh_TW goog.i18n)} "TWD" goog/i18n.NumberFormatSymbols_zh_TW}
nfs (or (get currency-code-to-nfs-map currency-code) nfs (or (get currency-code-to-nfs-map currency-code)
(.-NumberFormatSymbols_en goog.i18n))] goog/i18n.NumberFormatSymbols_en)]
(set! (.-NumberFormatSymbols goog.i18n) (set! goog/i18n.NumberFormatSymbols
(if currency-symbol? (if currency-symbol?
nfs nfs
(-> nfs (-> nfs
(js->clj :keywordize-keys true) (js->clj :keywordize-keys true)
;; Remove any currency symbol placeholders in the pattern ;; Remove any currency symbol placeholders in the pattern
(update-in [:CURRENCY_PATTERN] #(string/replace % #"\s*¤\s*" "")) (update :CURRENCY_PATTERN (fn [pat]
(string/replace pat #"\s*¤\s*" "")))
clj->js))) clj->js)))
(.format (.format
(new goog.i18n.NumberFormat (.-CURRENCY goog.i18n.NumberFormat.Format) currency-code) (new goog/i18n.NumberFormat goog/i18n.NumberFormat.Format.CURRENCY currency-code)
value)))) value))))

View File

@ -1304,7 +1304,7 @@
:<- [:account/account] :<- [:account/account]
(fn [{:keys [signing-phrase]}] (fn [{:keys [signing-phrase]}]
(when signing-phrase (when signing-phrase
(clojure.string/replace-all signing-phrase #" " " ")))) (clojure.string/replace signing-phrase #" " " "))))
(re-frame/reg-sub (re-frame/reg-sub
:wallet/settings :wallet/settings

View File

@ -240,7 +240,7 @@
[address data] (wallet/normalize-sign-message-params params)] [address data] (wallet/normalize-sign-message-params params)]
(if (and address data) (if (and address data)
(let [signing-phrase (-> (get-in db [:account/account :signing-phrase]) (let [signing-phrase (-> (get-in db [:account/account :signing-phrase])
(clojure.string/replace-all #" " " ")) (clojure.string/replace #" " " "))
screen-params {:id (str (or id message-id)) screen-params {:id (str (or id message-id))
:from address :from address
:data data :data data

View File

@ -28,16 +28,16 @@
;; xx-YY locale, xx locale or en fallback ;; xx-YY locale, xx locale or en fallback
(defn- locale-symbols [locale-name] (defn- locale-symbols [locale-name]
(if-let [loc (get goog.i18n (str "DateTimeSymbols_" locale-name))] (if-let [loc (get goog/i18n (str "DateTimeSymbols_" locale-name))]
loc loc
(let [name-first (s/replace (or locale-name "") #"-.*$" "") (let [name-first (s/replace (or locale-name "") #"-.*$" "")
loc (get goog.i18n (str "DateTimeSymbols_" name-first))] loc (get goog/i18n (str "DateTimeSymbols_" name-first))]
(or loc goog.i18n.DateTimeSymbols_en)))) (or loc goog/i18n.DateTimeSymbols_en))))
;; detects if given locale symbols timeformat generates AM/PM ("a") ;; detects if given locale symbols timeformat generates AM/PM ("a")
(defn- is24Hour-locsym [locsym] (defn- is24Hour-locsym [locsym]
(not (s/includes? (not (s/includes?
(nth (get locsym 'TIMEFORMATS) 2) (nth (.-TIMEFORMATS locsym) 2)
"a"))) "a")))
;; returns is24Hour from device or from given locale symbols ;; returns is24Hour from device or from given locale symbols
@ -53,15 +53,16 @@
;; date formats ;; date formats
(defn- short-date-format [locsym] "dd MMM") (defn- short-date-format [locsym] "dd MMM")
(defn- medium-date-format [locsym] (nth (get locsym 'DATEFORMATS) 2)) ; get medium format from current locale symbols (defn- medium-date-format [locsym] (nth (.-DATEFORMATS locsym) 2)) ; get medium format from current locale symbols
;; date-time formats ;; date-time formats
(defn- medium-date-time-format [locsym] (str (medium-date-format locsym) ", " (time-format locsym))) (defn- medium-date-time-format [locsym]
(str (medium-date-format locsym) ", " (time-format locsym)))
;; get formatter for current locale symbols and format function ;; get formatter for current locale symbols and format function
(defn- mk-fmt [locale format-fn] (defn- mk-fmt [locale format-fn]
(let [locsym (locale-symbols locale)] (let [locsym (locale-symbols locale)]
(goog.i18n.DateTimeFormat. (format-fn locsym) locsym))) (goog/i18n.DateTimeFormat. (format-fn locsym) locsym)))
;; generate formatters for different formats ;; generate formatters for different formats
(def date-time-fmt (def date-time-fmt

View File

@ -36,19 +36,19 @@
d/time-zone-offset (t/period :hours 0)] d/time-zone-offset (t/period :hours 0)]
(is (= (d/to-short-str epoch-plus-3d) "12:00 AM")))) (is (= (d/to-short-str epoch-plus-3d) "12:00 AM"))))
(deftest to-short-str-today-force-24H-test #_((deftest to-short-str-today-force-24H-test
(with-redefs [t/*ms-fn* (constantly epoch-plus-3d) (with-redefs [t/*ms-fn* (constantly epoch-plus-3d)
d/is24Hour (constantly true) d/is24Hour (constantly true)
d/time-fmt (d/mk-fmt "us" d/short-time-format) d/time-fmt (d/mk-fmt "us" d/short-time-format)
d/time-zone-offset (t/period :hours 0)] d/time-zone-offset (t/period :hours 0)]
(is (= (d/to-short-str epoch-plus-3d) "00:00")))) (is (= (d/to-short-str epoch-plus-3d) "00:00"))))
(deftest to-short-str-today-force-AMPM-test (deftest to-short-str-today-force-AMPM-test
(with-redefs [t/*ms-fn* (constantly epoch-plus-3d) (with-redefs [t/*ms-fn* (constantly epoch-plus-3d)
d/is24Hour (constantly false) d/is24Hour (constantly false)
d/time-fmt (d/mk-fmt "it" d/short-time-format) d/time-fmt (d/mk-fmt "it" d/short-time-format)
d/time-zone-offset (t/period :hours 0)] d/time-zone-offset (t/period :hours 0)]
(is (= (d/to-short-str epoch-plus-3d) "12:00 AM")))) (is (= (d/to-short-str epoch-plus-3d) "12:00 AM")))))
(deftest to-short-str-before-yesterday-us-test (deftest to-short-str-before-yesterday-us-test
(with-redefs [t/*ms-fn* (constantly epoch-plus-3d) (with-redefs [t/*ms-fn* (constantly epoch-plus-3d)
@ -74,16 +74,16 @@
d/date-fmt (d/mk-fmt "nb-NO" d/medium-date-time-format)] d/date-fmt (d/mk-fmt "nb-NO" d/medium-date-time-format)]
(is (= (d/day-relative epoch) "1. jan. 1970, 00:00:00")))) (is (= (d/day-relative epoch) "1. jan. 1970, 00:00:00"))))
(deftest day-relative-before-yesterday-force-24H-test #_((deftest day-relative-before-yesterday-force-24H-test
(with-redefs [t/*ms-fn* (constantly epoch-plus-3d) (with-redefs [t/*ms-fn* (constantly epoch-plus-3d)
d/is24Hour (constantly true) d/is24Hour (constantly true)
d/time-zone-offset (t/period :hours 0) d/time-zone-offset (t/period :hours 0)
d/date-fmt (d/mk-fmt "us" d/medium-date-time-format)] d/date-fmt (d/mk-fmt "us" d/medium-date-time-format)]
(is (= (d/day-relative epoch) "Jan 1, 1970, 00:00:00")))) (is (= (d/day-relative epoch) "Jan 1, 1970, 00:00:00"))))
(deftest day-relative-before-yesterday-force-AMPM-test (deftest day-relative-before-yesterday-force-AMPM-test
(with-redefs [t/*ms-fn* (constantly epoch-plus-3d) (with-redefs [t/*ms-fn* (constantly epoch-plus-3d)
d/is24Hour (constantly false) d/is24Hour (constantly false)
d/time-zone-offset (t/period :hours 0) d/time-zone-offset (t/period :hours 0)
d/date-fmt (d/mk-fmt "it" d/medium-date-time-format)] d/date-fmt (d/mk-fmt "it" d/medium-date-time-format)]
(is (= (d/day-relative epoch) "01 gen 1970, 12:00:00 AM")))) (is (= (d/day-relative epoch) "01 gen 1970, 12:00:00 AM")))))