[feature #5213] allow user to select fleet in settings

- get wnodes from resources/config/fleets.json which is taken from
fleets.status.im
- store wnodes by fleet and not by network since they are always the same
- reset wnodes settings during migration
- add option in developper menu to select fleet
- mailservers are now presented by their real name

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
Eric Dvorsak 2018-09-04 14:15:50 +02:00 committed by Igor Mandrigin
parent 8d053b4389
commit 80aa0e9286
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
34 changed files with 484 additions and 225 deletions

View File

@ -0,0 +1,85 @@
{
"fleets": {
"eth.beta": {
"boot": {
"boot-01.ac-cn-hongkong-c.eth.beta": "enode://e8a7c03b58911e98bbd66accb2a55d57683f35b23bf9dfca89e5e244eb5cc3f25018b4112db507faca34fb69ffb44b362f79eda97a669a8df29c72e654416784@47.91.224.35:30404",
"boot-01.do-ams3.eth.beta": "enode://436cc6f674928fdc9a9f7990f2944002b685d1c37f025c1be425185b5b1f0900feaf1ccc2a6130268f9901be4a7d252f37302c8335a2c1a62736e9232691cc3a@174.138.105.243:30404",
"boot-01.gc-us-central1-a.eth.beta": "enode://7427dfe38bd4cf7c58bb96417806fab25782ec3e6046a8053370022cbaa281536e8d64ecd1b02e1f8f72768e295d06258ba43d88304db068e6f2417ae8bcb9a6@104.154.88.123:30404",
"boot-02.ac-cn-hongkong-c.eth.beta": "enode://43947863cfa5aad1178f482ac35a8ebb9116cded1c23f7f9af1a47badfc1ee7f0dd9ec0543417cc347225a6e47e46c6873f647559e43434596c54e17a4d3a1e4@47.52.74.140:30404",
"boot-02.do-ams3.eth.beta": "enode://5395aab7833f1ecb671b59bf0521cf20224fe8162fc3d2675de4ee4d5636a75ec32d13268fc184df8d1ddfa803943906882da62a4df42d4fccf6d17808156a87@206.189.243.57:30404",
"boot-02.gc-us-central1-a.eth.beta": "enode://ebefab39b69bbbe64d8cd86be765b3be356d8c4b24660f65d493143a0c44f38c85a257300178f7845592a1b0332811542e9a58281c835babdd7535babb64efc1@35.202.99.224:30404"
},
"mail": {
"mail-01.ac-cn-hongkong-c.eth.beta": "enode://da61e9eff86a56633b635f887d8b91e0ff5236bbc05b8169834292e92afb92929dcf6efdbf373a37903da8fe0384d5a0a8247e83f1ce211aa429200b6d28c548@47.91.156.93:30504",
"mail-01.do-ams3.eth.beta": "enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:30504",
"mail-01.gc-us-central1-a.eth.beta": "enode://7de99e4cb1b3523bd26ca212369540646607c721ad4f3e5c821ed9148150ce6ce2e72631723002210fac1fd52dfa8bbdf3555e05379af79515e1179da37cc3db@35.188.19.210:30504",
"mail-02.ac-cn-hongkong-c.eth.beta": "enode://744098ab6d3308af5cd03920aea60c46d16b2cd3d33bf367cbaf1d01c2fcd066ff8878576d0967897cd7dbb0e63f873cc0b4f7e4b0f1d7222e6b3451a78d9bda@47.89.20.15:30504",
"mail-02.do-ams3.eth.beta": "enode://7aa648d6e855950b2e3d3bf220c496e0cae4adfddef3e1e6062e6b177aec93bc6cdcf1282cb40d1656932ebfdd565729da440368d7c4da7dbd4d004b1ac02bf8@206.189.243.169:30504",
"mail-02.gc-us-central1-a.eth.beta": "enode://015e22f6cd2b44c8a51bd7a23555e271e0759c7d7f52432719665a74966f2da456d28e154e836bee6092b4d686fe67e331655586c57b718be3997c1629d24167@35.226.21.19:30504",
"mail-03.ac-cn-hongkong-c.eth.beta": "enode://74957e361ab290e6af45a124536bc9adee39fbd2f995a77ace6ed7d05d9a1c7c98b78b2df5f8071c439b9c0afe4a69893ede4ad633473f96bc195ddf33f6ce00@47.52.255.195:30504",
"mail-03.do-ams3.eth.beta": "enode://8a64b3c349a2e0ef4a32ea49609ed6eb3364be1110253c20adc17a3cebbc39a219e5d3e13b151c0eee5d8e0f9a8ba2cd026014e67b41a4ab7d1d5dd67ca27427@206.189.243.168:30504",
"mail-03.gc-us-central1-a.eth.beta": "enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eabfb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6@35.225.227.79:30504"
},
"whisper": {
"node-01.ac-cn-hongkong-c.eth.beta": "enode://9c2b82304d988cd78bf290a09b6f81c6ae89e71f9c0f69c41d21bd5cabbd1019522d5d73d7771ea933adf0727de5e847c89e751bd807ba1f7f6fc3a0cd88d997@47.52.91.239:30305",
"node-01.do-ams3.eth.beta": "enode://66ba15600cda86009689354c3a77bdf1a97f4f4fb3ab50ffe34dbc904fac561040496828397be18d9744c75881ffc6ac53729ddbd2cdbdadc5f45c400e2622f7@206.189.243.176:30305",
"node-01.gc-us-central1-a.eth.beta": "enode://0440117a5bc67c2908fad94ba29c7b7f2c1536e96a9df950f3265a9566bf3a7306ea8ab5a1f9794a0a641dcb1e4951ce7c093c61c0d255f4ed5d2ed02c8fce23@35.224.15.65:30305",
"node-02.ac-cn-hongkong-c.eth.beta": "enode://a80eb084f6bf3f98bf6a492fd6ba3db636986b17643695f67f543115d93d69920fb72e349e0c617a01544764f09375bb85f452b9c750a892d01d0e627d9c251e@47.89.16.125:30305",
"node-02.do-ams3.eth.beta": "enode://4ea35352702027984a13274f241a56a47854a7fd4b3ba674a596cff917d3c825506431cf149f9f2312a293bb7c2b1cca55db742027090916d01529fe0729643b@206.189.243.178:30305",
"node-02.gc-us-central1-a.eth.beta": "enode://552942cc4858073102a6bcd0df9fe4de6d9fc52ddf7363e8e0746eba21b0f98fb37e8270bc629f72cfe29e0b3522afaf51e309a05998736e2c0dad5288991148@130.211.215.133:30305",
"node-03.ac-cn-hongkong-c.eth.beta": "enode://aa97756bc147d74be6d07adfc465266e17756339d3d18591f4be9d1b2e80b86baf314aed79adbe8142bcb42bc7bc40e83ee3bbd0b82548e595bf855d548906a1@47.52.188.241:30305",
"node-03.do-ams3.eth.beta": "enode://ce559a37a9c344d7109bd4907802dd690008381d51f658c43056ec36ac043338bd92f1ac6043e645b64953b06f27202d679756a9c7cf62fdefa01b2e6ac5098e@206.189.243.179:30305",
"node-03.gc-us-central1-a.eth.beta": "enode://b33dc678589931713a085d29f9dc0efee1783dacce1d13696eb5d3a546293198470d97822c40b187336062b39fd3464e9807858109752767d486ea699a6ab3de@35.193.151.184:30305",
"node-04.ac-cn-hongkong-c.eth.beta": "enode://f34451823b173dc5f2ac0eec1668fdb13dba9452b174249a7e0272d6dce16fb811a01e623300d1b7a67c240ae052a462bff3f60e4a05e4c4bd23cc27dea57051@47.52.173.66:30305",
"node-04.do-ams3.eth.beta": "enode://4e0a8db9b73403c9339a2077e911851750fc955db1fc1e09f81a4a56725946884dd5e4d11258eac961f9078a393c45bcab78dd0e3bc74e37ce773b3471d2e29c@206.189.243.171:30305",
"node-04.gc-us-central1-a.eth.beta": "enode://eb4cc33c1948b1f4b9cb8157757645d78acd731cc8f9468ad91cef8a7023e9c9c62b91ddab107043aabc483742ac15cb4372107b23962d3bfa617b05583f2260@146.148.66.209:30305",
"node-05.ac-cn-hongkong-c.eth.beta": "enode://7c80e37f324bbc767d890e6381854ef9985d33940285413311e8b5927bf47702afa40cd5d34be9aa6183ac467009b9545e24b0d0bc54ef2b773547bb8c274192@47.91.155.62:30305",
"node-05.do-ams3.eth.beta": "enode://a8bddfa24e1e92a82609b390766faa56cf7a5eef85b22a2b51e79b333c8aaeec84f7b4267e432edd1cf45b63a3ad0fc7d6c3a16f046aa6bc07ebe50e80b63b8c@206.189.243.172:30305",
"node-05.gc-us-central1-a.eth.beta": "enode://c7e00e5a333527c009a9b8f75659d9e40af8d8d896ebaa5dbdd46f2c58fc010e4583813bc7fc6da98fcf4f9ca7687d37ced8390330ef570d30b5793692875083@35.192.123.253:30305",
"node-06.ac-cn-hongkong-c.eth.beta": "enode://4b2530d045b1d9e0e45afa7c008292744fe77675462090b4001f85faf03b87aa79259c8a3d6d64f815520ac76944e795cbf32ff9e2ce9ba38f57af00d1cc0568@47.90.29.122:30305",
"node-06.do-ams3.eth.beta": "enode://887cbd92d95afc2c5f1e227356314a53d3d18855880ac0509e0c0870362aee03939d4074e6ad31365915af41d34320b5094bfcc12a67c381788cd7298d06c875@206.189.243.177:30305",
"node-06.gc-us-central1-a.eth.beta": "enode://2af8f4f7a0b5aabaf49eb72b9b59474b1b4a576f99a869e00f8455928fa242725864c86bdff95638a8b17657040b21771a7588d18b0f351377875f5b46426594@35.232.187.4:30305",
"node-07.ac-cn-hongkong-c.eth.beta": "enode://76ee16566fb45ca7644c8dec7ac74cadba3bfa0b92c566ad07bcb73298b0ffe1315fd787e1f829e90dba5cd3f4e0916e069f14e50e9cbec148bead397ac8122d@47.91.226.75:30305",
"node-07.do-ams3.eth.beta": "enode://2b01955d7e11e29dce07343b456e4e96c081760022d1652b1c4b641eaf320e3747871870fa682e9e9cfb85b819ce94ed2fee1ac458904d54fd0b97d33ba2c4a4@206.189.240.70:30305",
"node-07.gc-us-central1-a.eth.beta": "enode://19872f94b1e776da3a13e25afa71b47dfa99e658afd6427ea8d6e03c22a99f13590205a8826443e95a37eee1d815fc433af7a8ca9a8d0df7943d1f55684045b7@35.238.60.236:30305"
}
},
"eth.staging": {
"boot": {
"boot-01.ac-cn-hongkong-c.eth.staging": "enode://630b0342ca4e9552f50714b6c8e28d6955bc0fd14e7950f93bc3b2b8cc8c1f3b6d103df66f51a13d773b5db0f130661fb5c7b8fa21c48890c64c79b41a56a490@47.91.229.44:30404",
"boot-01.do-ams3.eth.staging": "enode://f79fb3919f72ca560ad0434dcc387abfe41e0666201ebdada8ede0462454a13deb05cda15f287d2c4bd85da81f0eb25d0a486bbbc8df427b971ac51533bd00fe@174.138.107.239:30404"
},
"mail": {
"mail-01.ac-cn-hongkong-c.eth.staging": "enode://b74859176c9751d314aeeffc26ec9f866a412752e7ddec91b19018a18e7cca8d637cfe2cedcb972f8eb64d816fbd5b4e89c7e8c7fd7df8a1329fa43db80b0bfe@47.52.90.156:30504",
"mail-01.do-ams3.eth.staging": "enode://69f72baa7f1722d111a8c9c68c39a31430e9d567695f6108f31ccb6cd8f0adff4991e7fdca8fa770e75bc8a511a87d24690cbc80e008175f40c157d6f6788d48@206.189.240.16:30504",
"mail-01.gc-us-central1-a.eth.staging": "enode://e4fc10c1f65c8aed83ac26bc1bfb21a45cc1a8550a58077c8d2de2a0e0cd18e40fd40f7e6f7d02dc6cd06982b014ce88d6e468725ffe2c138e958788d0002a7f@35.239.193.41:30504"
},
"whisper": {
"node-01.ac-cn-hongkong-c.eth.staging": "enode://00395686f5954662a3796e170b9e87bbaf68a050d57e9987b78a2292502dae44aae2b8803280a017ec9af9be0b3121db9d6b3693ab3a0451a866bcbedd58fdac@47.52.226.137:30305",
"node-01.do-ams3.eth.staging": "enode://914c0b30f27bab30c1dfd31dad7652a46fda9370542aee1b062498b1345ee0913614b8b9e3e84622e84a7203c5858ae1d9819f63aece13ee668e4f6668063989@167.99.19.148:30305",
"node-01.gc-us-central1-a.eth.staging": "enode://2d897c6e846949f9dcf10279f00e9b8325c18fe7fa52d658520ad7be9607c83008b42b06aefd97cfe1fdab571f33a2a9383ff97c5909ed51f63300834913237e@35.192.0.86:30305"
}
},
"eth.test": {
"boot": {
"boot-01.ac-cn-hongkong-c.eth.test": "enode://daae2e72820e86e942fa2a8aa7d6e9954d4043a753483d8bd338e16be82cf962392d5c0e1ae57c3d793c3d3dddd8fd58339262e4234dc966f953cd73b535f5fa@47.52.188.149:30404",
"boot-01.do-ams3.eth.test": "enode://9e0988575eb7717c25dea72fd11c7b37767dc09c1a7686f7c2ec577d308d24b377ceb675de4317474a1a870e47882732967f4fa785b02ba95d669b31d464dec0@206.189.243.164:30404",
"boot-01.gc-us-central1-a.eth.test": "enode://c1e5018887c863d64e431b69bf617561087825430e4401733f5ba77c70db14236df381fefb0ebe1ac42294b9e261bbe233dbdb83e32c586c66ae26c8de70cb4c@35.188.168.137:30404"
},
"mail": {
"mail-01.ac-cn-hongkong-c.eth.test": "enode://954c06603a6e755bffe9992615f4755848bda9aadda74d920aa31d1d8e4f6022dc556dca6768f8a0f9459f57b729509db3c8b3bb80acfbd8a2123087f6cbd7bd@47.52.188.196:30504",
"mail-01.do-ams3.eth.test": "enode://e4865fe6c2a9c1a563a6447990d8e9ce672644ae3e08277ce38ec1f1b690eef6320c07a5d60c3b629f5d4494f93d6b86a745a0bf64ab295bbf6579017adc6ed8@206.189.243.161:30504",
"mail-01.gc-us-central1-a.eth.test": "enode://707e57453acd3e488c44b9d0e17975371e2f8fb67525eae5baca9b9c8e06c86cde7c794a6c2e36203bf9f56cae8b0e50f3b33c4c2b694a7baeea1754464ce4e3@35.192.229.172:30504"
},
"whisper": {
"node-01.ac-cn-hongkong-c.eth.test": "enode://ad38f94030a846cc7005b7a1f3b6b01bf4ef59d34e8d3d6f4d12df23d14ba8656702a435d34cf4df3b412c0c1923df5adcce8461321a0d8ffb9435b26e572c2a@47.52.255.194:30305",
"node-01.do-ams3.eth.test": "enode://1d193635e015918fb85bbaf774863d12f65d70c6977506187ef04420d74ec06c9e8f0dcb57ea042f85df87433dab17a1260ed8dde1bdf9d6d5d2de4b7bf8e993@206.189.243.163:30305",
"node-01.gc-us-central1-a.eth.test": "enode://f593a27731bc0f8eb088e2d39222c2d59dfb9bf0b3950d7a828d51e8ab9e08fffbd9916a82fd993c1a080c57c2bd70ed6c36f489a969de697aff93088dbee1a9@35.194.31.108:30305"
}
}
},
"meta": {
"hostname": "bots-01.gc-us-central1-a.eth.test",
"timestamp": "2018-09-03T18:10:52.315172"
}
}

View File

@ -85,65 +85,6 @@
(into {} (filter network-enabled? (into {} (filter network-enabled?
(merge testnet-networks mainnet-networks)))) (merge testnet-networks mainnet-networks))))
(def default-wnodes-without-custom
{"eth.beta" {"mailserver-a" {:id "mailserver-a" ;mail-01.do-ams3.eth.beta
:name "Status mailserver A"
:password inbox-password
:address "enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:30504"}
"mailserver-b" {:id "mailserver-b" ;mail-02.do-ams3.eth.beta
:name "Status mailserver B"
:password inbox-password
:address "enode://7aa648d6e855950b2e3d3bf220c496e0cae4adfddef3e1e6062e6b177aec93bc6cdcf1282cb40d1656932ebfdd565729da440368d7c4da7dbd4d004b1ac02bf8@206.189.243.169:30504"}
"mailserver-c" {:id "mailserver-c" ;mail-03.do-ams3.eth.beta
:name "Status mailserver C"
:password inbox-password
:address "enode://8a64b3c349a2e0ef4a32ea49609ed6eb3364be1110253c20adc17a3cebbc39a219e5d3e13b151c0eee5d8e0f9a8ba2cd026014e67b41a4ab7d1d5dd67ca27427@206.189.243.168:30504"}
"mailserver-d" {:id "mailserver-d" ;mail-01.gc-us-central1-a.eth.beta
:name "Status mailserver D"
:password inbox-password
:address "enode://7de99e4cb1b3523bd26ca212369540646607c721ad4f3e5c821ed9148150ce6ce2e72631723002210fac1fd52dfa8bbdf3555e05379af79515e1179da37cc3db@35.188.19.210:30504"}
"mailserver-e" {:id "mailserver-e" ;mail-02.gc-us-central1-a.eth.beta
:name "Status mailserver E"
:password inbox-password
:address "enode://015e22f6cd2b44c8a51bd7a23555e271e0759c7d7f52432719665a74966f2da456d28e154e836bee6092b4d686fe67e331655586c57b718be3997c1629d24167@35.226.21.19:30504"}
"mailserver-f" {:id "mailserver-f" ;mail-03.gc-us-central1-a.eth.beta
:name "Status mailserver F"
:password inbox-password
:address "enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eabfb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6@35.225.227.79:30504"}}
"eth.staging" {"mailserver-a" {:id "mailserver-a" ;mail-01.gc-us-central1-a.eth.staging
:name "Status mailserver A"
:password inbox-password
:address "enode://e4fc10c1f65c8aed83ac26bc1bfb21a45cc1a8550a58077c8d2de2a0e0cd18e40fd40f7e6f7d02dc6cd06982b014ce88d6e468725ffe2c138e958788d0002a7f@35.239.193.41:30504"}
"mailserver-b" {:id "mailserver-b" ;mail-01.do-ams3.eth.staging
:name "Status mailserver B"
:password inbox-password
:address "enode://69f72baa7f1722d111a8c9c68c39a31430e9d567695f6108f31ccb6cd8f0adff4991e7fdca8fa770e75bc8a511a87d24690cbc80e008175f40c157d6f6788d48@206.189.240.16:30504"}
"mailserver-c" {:id "mailserver-c" ;mail-01.ac-cn-hongkong-c.eth.staging
:name "Status mailserver C"
:password inbox-password
:address "enode://b74859176c9751d314aeeffc26ec9f866a412752e7ddec91b19018a18e7cca8d637cfe2cedcb972f8eb64d816fbd5b4e89c7e8c7fd7df8a1329fa43db80b0bfe@47.75.159.188:30504"}}
"eth.test" {"mailserver-a" {:id "mailserver-a" ;mail-01.gc-us-central1-a.eth.test
:name "Status mailserver A"
:password inbox-password
:address "enode://707e57453acd3e488c44b9d0e17975371e2f8fb67525eae5baca9b9c8e06c86cde7c794a6c2e36203bf9f56cae8b0e50f3b33c4c2b694a7baeea1754464ce4e3@35.192.229.172:30504"}
"mailserver-b" {:id "mailserver-b" ;mail-01.do-ams3.eth.test
:name "Status mailserver B"
:password inbox-password
:address "enode://e4865fe6c2a9c1a563a6447990d8e9ce672644ae3e08277ce38ec1f1b690eef6320c07a5d60c3b629f5d4494f93d6b86a745a0bf64ab295bbf6579017adc6ed8@206.189.243.161:30504"}
"mailserver-c" {:id "mailserver-c" ;mail-01.ac-cn-hongkong-c.eth.test
:name "Status mailserver C"
:password inbox-password
:address "enode://954c06603a6e755bffe9992615f4755848bda9aadda74d920aa31d1d8e4f6022dc556dca6768f8a0f9459f57b729509db3c8b3bb80acfbd8a2123087f6cbd7bd@47.52.251.180:30504"}}})
(def default-wnodes
;; We use the same set of mailservers for every network now
;; They are only dependent on the selected fleet (test, stage, beta)
(let [nodes-for-fleet (get default-wnodes-without-custom config/fleet)]
{:custom nodes-for-fleet
:testnet nodes-for-fleet
:mainnet nodes-for-fleet
:rinkeby nodes-for-fleet}))
(defn default-account-settings [] (defn default-account-settings []
{:wallet {:visible-tokens {:testnet #{:STT :HND} {:wallet {:visible-tokens {:testnet #{:STT :HND}
:mainnet #{:SNT} :mainnet #{:SNT}

View File

@ -9,7 +9,8 @@
[status-im.data-store.realm.schemas.account.v7.core :as v7] [status-im.data-store.realm.schemas.account.v7.core :as v7]
[status-im.data-store.realm.schemas.account.v8.core :as v8] [status-im.data-store.realm.schemas.account.v8.core :as v8]
[status-im.data-store.realm.schemas.account.v9.core :as v9] [status-im.data-store.realm.schemas.account.v9.core :as v9]
[status-im.data-store.realm.schemas.account.v10.core :as v10])) [status-im.data-store.realm.schemas.account.v10.core :as v10]
[status-im.data-store.realm.schemas.account.v11.core :as v11]))
;; TODO(oskarth): Add failing test if directory vXX exists but isn't in schemas. ;; TODO(oskarth): Add failing test if directory vXX exists but isn't in schemas.
@ -43,4 +44,7 @@
:migration v9/migration} :migration v9/migration}
{:schema v10/schema {:schema v10/schema
:schemaVersion 10 :schemaVersion 10
:migration v10/migration}]) :migration v10/migration}
{:schema v11/schema
:schemaVersion 11
:migration v11/migration}])

View File

@ -0,0 +1,25 @@
(ns status-im.data-store.realm.schemas.account.v11.core
(:require [status-im.data-store.realm.schemas.account.v5.chat :as chat]
[status-im.data-store.realm.schemas.account.v6.transport :as transport]
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
[status-im.data-store.realm.schemas.account.v7.message :as message]
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
[status-im.data-store.realm.schemas.account.v11.mailserver :as mailserver]
[status-im.data-store.realm.schemas.account.v8.browser :as browser]
[status-im.data-store.realm.schemas.account.v9.dapp-permissions :as dapp-permissions]
[taoensso.timbre :as log]))
(def schema [chat/schema
transport/schema
contact/schema
message/schema
mailserver/schema
user-status/schema
local-storage/schema
browser/schema
dapp-permissions/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v11 account database: " old-realm new-realm)
(mailserver/migration old-realm new-realm))

View File

@ -0,0 +1,17 @@
(ns status-im.data-store.realm.schemas.account.v11.mailserver
(:require [taoensso.timbre :as log]))
(def schema {:name :mailserver
:primaryKey :id
:properties {:id :string
:name {:type :string}
:address {:type :string}
:password {:type :string
:optional true}
:fleet {:type :string}}})
(defn migration [old-realm new-realm]
(log/debug "migrating mailservers schema v10")
(let [mailservers (.objects new-realm "mailserver")]
(dotimes [i (.-length mailservers)]
(aset (aget mailservers i) "fleet" "eth.beta"))))

View File

@ -23,4 +23,4 @@
dapp-permissions/schema]) dapp-permissions/schema])
(defn migration [old-realm new-realm] (defn migration [old-realm new-realm]
(log/debug "migrating v9 account database: " old-realm new-realm)) (log/debug "migrating v9 account database: " old-realm new-realm))

View File

@ -6,7 +6,8 @@
[status-im.data-store.realm.schemas.base.v5.core :as v5] [status-im.data-store.realm.schemas.base.v5.core :as v5]
[status-im.data-store.realm.schemas.base.v6.core :as v6] [status-im.data-store.realm.schemas.base.v6.core :as v6]
[status-im.data-store.realm.schemas.base.v7.core :as v7] [status-im.data-store.realm.schemas.base.v7.core :as v7]
[status-im.data-store.realm.schemas.base.v8.core :as v8])) [status-im.data-store.realm.schemas.base.v8.core :as v8]
[status-im.data-store.realm.schemas.base.v9.core :as v9]))
;; put schemas ordered by version ;; put schemas ordered by version
(def schemas [{:schema v1/schema (def schemas [{:schema v1/schema
@ -32,4 +33,7 @@
:migration v7/migration} :migration v7/migration}
{:schema v8/schema {:schema v8/schema
:schemaVersion 8 :schemaVersion 8
:migration v8/migration}]) :migration v8/migration}
{:schema v9/schema
:schemaVersion 9
:migration v9/migration}])

View File

@ -0,0 +1,24 @@
(ns status-im.data-store.realm.schemas.base.v9.account
(:require [taoensso.timbre :as log]
[cognitect.transit :as transit]
[clojure.set :as set]
[status-im.data-store.realm.schemas.base.v8.account :as v8]))
(def schema v8/schema)
(def reader (transit/reader :json))
(def writer (transit/writer :json))
(defn serialize [o] (transit/write writer o))
(defn deserialize [o] (try (transit/read reader o) (catch :default e nil)))
(defn migration [old-realm new-realm]
(log/debug "migrating accounts schema v9")
(let [accounts (.objects new-realm "account")]
(dotimes [i (.-length accounts)]
(let [account (aget accounts i)
old-settings (deserialize (aget account "settings"))
new-settings (-> old-settings
(dissoc :wnode))
updated (serialize new-settings)]
(aset account "settings" updated)))))

View File

@ -0,0 +1,13 @@
(ns status-im.data-store.realm.schemas.base.v9.core
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
[status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode]
[status-im.data-store.realm.schemas.base.v9.account :as account]
[taoensso.timbre :as log]))
(def schema [network/schema
bootnode/schema
account/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating base database v9: " old-realm new-realm)
(account/migration old-realm new-realm))

View File

@ -0,0 +1,37 @@
(ns status-im.models.fleet
(:require-macros [status-im.utils.slurp :refer [slurp]])
(:require [status-im.utils.types :as types]
[status-im.constants :as constants]
[status-im.utils.config :as config]))
(defn current-fleet
([db]
(current-fleet db nil))
([db address]
(keyword (or (if address
(get-in db [:accounts/accounts address :settings :fleet])
(get-in db [:account/account :settings :fleet]))
config/fleet))))
(def fleets
(:fleets (types/json->clj (slurp "resources/config/fleets.json"))))
(defn format-wnode
[wnode address]
{:id wnode
:name (name wnode)
:password constants/inbox-password
:address address})
(defn format-wnodes
[wnodes]
(reduce (fn [acc [wnode address]]
(assoc acc wnode (format-wnode wnode address)))
{}
wnodes))
(def default-wnodes
(reduce (fn [acc [fleet node-by-type]]
(assoc acc fleet (format-wnodes (:mail node-by-type))))
{}
fleets))

View File

@ -1,9 +1,9 @@
(ns status-im.models.mailserver (ns status-im.models.mailserver
(:require [clojure.string :as string] (:require [clojure.string :as string]
[status-im.data-store.mailservers :as data-store.mailservers] [status-im.data-store.mailservers :as data-store.mailservers]
[status-im.models.network :as models.network]
[status-im.utils.ethereum.core :as ethereum] [status-im.utils.ethereum.core :as ethereum]
[status-im.utils.handlers-macro :as handlers-macro])) [status-im.utils.handlers-macro :as handlers-macro]
[status-im.models.fleet :as fleet]))
(def enode-address-regex #"enode://[a-zA-Z0-9]+\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b:(\d{1,5})") (def enode-address-regex #"enode://[a-zA-Z0-9]+\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b:(\d{1,5})")
(def enode-url-regex #"enode://[a-zA-Z0-9]+:(.+)\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b:(\d{1,5})") (def enode-url-regex #"enode://[a-zA-Z0-9]+:(.+)\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b:(\d{1,5})")
@ -53,14 +53,13 @@
(= (:inbox/current-id db) id)) (= (:inbox/current-id db) id))
(defn fetch [id {:keys [db] :as cofx}] (defn fetch [id {:keys [db] :as cofx}]
(get-in db [:inbox/wnodes (models.network/get-chain cofx) id])) (get-in db [:inbox/wnodes (fleet/current-fleet db) id]))
(defn fetch-current [{:keys [db] :as cofx}] (defn fetch-current [{:keys [db] :as cofx}]
(fetch (:inbox/current-id db) cofx)) (fetch (:inbox/current-id db) cofx))
(defn preferred-mailserver-id [{:keys [db] :as cofx}] (defn preferred-mailserver-id [{:keys [db] :as cofx}]
(let [chain (models.network/get-chain cofx)] (get-in db [:account/account :settings :wnode (fleet/current-fleet db)]))
(get-in db [:account/account :settings :wnode chain])))
(defn- round-robin (defn- round-robin
"Find the choice and pick the next one, default to first if not found" "Find the choice and pick the next one, default to first if not found"
@ -81,10 +80,10 @@
"Use the preferred mailserver if set & exists, otherwise picks one randomly "Use the preferred mailserver if set & exists, otherwise picks one randomly
if current-id is not set, else round-robin" if current-id is not set, else round-robin"
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [chain (models.network/get-chain cofx) (let [current-fleet (fleet/current-fleet db)
current-id (:inbox/current-id db) current-id (:inbox/current-id db)
preference (preferred-mailserver-id cofx) preference (preferred-mailserver-id cofx)
choices (-> db :inbox/wnodes chain keys)] choices (-> db :inbox/wnodes current-fleet keys)]
(if (and preference (if (and preference
(fetch preference cofx)) (fetch preference cofx))
preference preference
@ -98,7 +97,7 @@
(when-not (or (when-not (or
(default? id cofx) (default? id cofx)
(connected? id cofx)) (connected? id cofx))
{:db (update-in db [:inbox/wnodes (models.network/get-chain cofx)] dissoc id) {:db (update-in db [:inbox/wnodes (fleet/current-fleet db)] dissoc id)
:data-store/tx [(data-store.mailservers/delete-tx id)]})) :data-store/tx [(data-store.mailservers/delete-tx id)]}))
(defn set-current-mailserver [{:keys [db] :as cofx}] (defn set-current-mailserver [{:keys [db] :as cofx}]
@ -108,10 +107,10 @@
{:db (update-in db [:account/account :last-request] (fnil identity (quot now 1000)))}) {:db (update-in db [:account/account :last-request] (fnil identity (quot now 1000)))})
(defn add-custom-mailservers [mailservers {:keys [db]}] (defn add-custom-mailservers [mailservers {:keys [db]}]
{:db (reduce (fn [db {:keys [id chain] :as mailserver}] {:db (reduce (fn [db {:keys [id fleet] :as mailserver}]
(assoc-in db [:inbox/wnodes (keyword chain) id] (assoc-in db [:inbox/wnodes fleet id]
(-> mailserver (-> mailserver
(dissoc :chain) (dissoc :fleet)
(assoc :user-defined true)))) (assoc :user-defined true))))
db db
mailservers)}) mailservers)})
@ -131,8 +130,7 @@
(defn upsert [{{:mailservers/keys [manage] :account/keys [account] :as db} :db :as cofx}] (defn upsert [{{:mailservers/keys [manage] :account/keys [account] :as db} :db :as cofx}]
(let [{:keys [name url id]} manage (let [{:keys [name url id]} manage
network (get (:networks (:account/account db)) (:network db)) current-fleet (fleet/current-fleet db)
chain (ethereum/network->chain-keyword network)
mailserver (build mailserver (build
(or (:value id) (or (:value id)
(string/replace (:random-id cofx) "-" "")) (string/replace (:random-id cofx) "-" ""))
@ -141,12 +139,12 @@
current (connected? (:id mailserver) cofx)] current (connected? (:id mailserver) cofx)]
{:db (-> db {:db (-> db
(dissoc :mailservers/manage) (dissoc :mailservers/manage)
(assoc-in [:inbox/wnodes chain (:id mailserver)] mailserver)) (assoc-in [:inbox/wnodes current-fleet (:id mailserver)] mailserver))
:data-store/tx [{:transaction :data-store/tx [{:transaction
(data-store.mailservers/save-tx (assoc (data-store.mailservers/save-tx (assoc
mailserver mailserver
:chain :fleet
chain)) current-fleet))
;; we naively logout if the user is connected to the edited mailserver ;; we naively logout if the user is connected to the edited mailserver
:success-event (when current [:logout])}] :success-event (when current [:logout])}]
:dispatch [:navigate-back]})) :dispatch [:navigate-back]}))

View File

@ -5,10 +5,10 @@
(re-frame/reg-fx (re-frame/reg-fx
:node/start :node/start
(fn [config] (fn [[config fleet]]
(status/start-node config config/fleet))) (status/start-node config fleet)))
(re-frame/reg-fx (re-frame/reg-fx
:node/stop :node/stop
(fn [config] (fn []
(status/stop-node))) (status/stop-node)))

View File

@ -2,7 +2,8 @@
(:require [status-im.utils.config :as config] (:require [status-im.utils.config :as config]
[status-im.utils.types :as types] [status-im.utils.types :as types]
[clojure.string :as str] [clojure.string :as str]
[taoensso.timbre :as log])) [taoensso.timbre :as log]
[status-im.models.fleet :as fleet]))
(defn- add-custom-bootnodes [config network all-bootnodes] (defn- add-custom-bootnodes [config network all-bootnodes]
(let [bootnodes (as-> all-bootnodes $ (let [bootnodes (as-> all-bootnodes $
@ -57,10 +58,11 @@
node-config (if address node-config (if address
(get-account-node-config db address) (get-account-node-config db address)
(get-node-config db network)) (get-node-config db network))
node-config-json (types/clj->json node-config)] node-config-json (types/clj->json node-config)
fleet (name (fleet/current-fleet db address))]
(log/info "Node config: " node-config-json) (log/info "Node config: " node-config-json)
{:db (assoc db :network network) {:db (assoc db :network network)
:node/start node-config-json}))) :node/start [node-config-json fleet]})))
(defn restart (defn restart
[] []

View File

@ -681,7 +681,10 @@
:network-settings "Network settings" :network-settings "Network settings"
:log-level "Log level" :log-level "Log level"
:log-level-settings "Log level settings" :log-level-settings "Log level settings"
:fleet "Fleet"
:fleet-settings "Fleet settings"
:change-log-level "Change log level to {{log-level}}" :change-log-level "Change log level to {{log-level}}"
:change-fleet "Change fleet to {{fleet}}"
:offline-messaging "Mailserver" :offline-messaging "Mailserver"
:offline-messaging-settings "Mailserver settings" :offline-messaging-settings "Mailserver settings"
:edit-network-warning "Be careful! Editing the network data may disable this network for you" :edit-network-warning "Be careful! Editing the network data may disable this network for you"

View File

@ -16,7 +16,8 @@
[status-im.utils.handlers-macro :as handlers-macro] [status-im.utils.handlers-macro :as handlers-macro]
[status-im.data-store.core :as data-store] [status-im.data-store.core :as data-store]
[status-im.models.mailserver :as models.mailserver] [status-im.models.mailserver :as models.mailserver]
[status-im.data-store.transport :as transport-store])) [status-im.data-store.transport :as transport-store]
[status-im.models.fleet :as fleet]))
;; How does offline inboxing work ? ;; How does offline inboxing work ?
;; ;;
@ -76,9 +77,8 @@
(success-fn result))))) (success-fn result)))))
(defn add-sym-key-id-to-wnode [{:keys [id]} sym-key-id {:keys [db]}] (defn add-sym-key-id-to-wnode [{:keys [id]} sym-key-id {:keys [db]}]
(let [network (get (:networks (:account/account db)) (:network db)) (let [current-fleet (fleet/current-fleet db)]
chain (ethereum/network->chain-keyword network)] {:db (assoc-in db [:inbox/wnodes current-fleet id :sym-key-id] sym-key-id)}))
{:db (assoc-in db [:inbox/wnodes chain id :sym-key-id] sym-key-id)}))
(defn registered-peer? [peers enode] (defn registered-peer? [peers enode]
(let [peer-ids (into #{} (map :id) peers) (let [peer-ids (into #{} (map :id) peers)

View File

@ -84,6 +84,7 @@
:icons/network (js/require "./resources/icons/network.svg") :icons/network (js/require "./resources/icons/network.svg")
:icons/wnode (js/require "./resources/icons/wnode.svg") :icons/wnode (js/require "./resources/icons/wnode.svg")
:icons/log-level (js/require "./resources/icons/wnode.svg") :icons/log-level (js/require "./resources/icons/wnode.svg")
:icons/fleet (js/require "./resources/icons/wnode.svg")
:icons/refresh (js/require "./resources/icons/refresh.svg") :icons/refresh (js/require "./resources/icons/refresh.svg")
:icons/newchat (js/require "./resources/icons/newchat.svg") :icons/newchat (js/require "./resources/icons/newchat.svg")
:icons/logo (js/require "./resources/icons/logo.svg") :icons/logo (js/require "./resources/icons/logo.svg")
@ -147,6 +148,7 @@
:icons/network (components.svg/slurp-svg "./resources/icons/network.svg") :icons/network (components.svg/slurp-svg "./resources/icons/network.svg")
:icons/wnode (components.svg/slurp-svg "./resources/icons/wnode.svg") :icons/wnode (components.svg/slurp-svg "./resources/icons/wnode.svg")
:icons/log-level (components.svg/slurp-svg "./resources/icons/wnode.svg") :icons/log-level (components.svg/slurp-svg "./resources/icons/wnode.svg")
:icons/fleet (components.svg/slurp-svg "./resources/icons/wnode.svg")
:icons/refresh (components.svg/slurp-svg "./resources/icons/refresh.svg") :icons/refresh (components.svg/slurp-svg "./resources/icons/refresh.svg")
:icons/newchat (components.svg/slurp-svg "./resources/icons/newchat.svg") :icons/newchat (components.svg/slurp-svg "./resources/icons/newchat.svg")
:icons/logo (components.svg/slurp-svg "./resources/icons/logo.svg") :icons/logo (components.svg/slurp-svg "./resources/icons/logo.svg")

View File

@ -4,6 +4,7 @@
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.utils.platform :as platform] [status-im.utils.platform :as platform]
[status-im.utils.dimensions :as dimensions] [status-im.utils.dimensions :as dimensions]
[status-im.models.fleet :as fleet]
pluto.registry pluto.registry
status-im.transport.db status-im.transport.db
status-im.ui.screens.accounts.db status-im.ui.screens.accounts.db
@ -45,7 +46,7 @@
:semaphores #{} :semaphores #{}
:network constants/default-network :network constants/default-network
:networks/networks constants/default-networks :networks/networks constants/default-networks
:inbox/wnodes constants/default-wnodes :inbox/wnodes fleet/default-wnodes
:my-profile/editing? false :my-profile/editing? false
:transport/chats {} :transport/chats {}
:transport/message-envelopes {} :transport/message-envelopes {}
@ -144,7 +145,7 @@
(spec/def ::peers-count (spec/nilable integer?)) (spec/def ::peers-count (spec/nilable integer?))
(spec/def ::peers-summary (spec/nilable vector?)) (spec/def ::peers-summary (spec/nilable vector?))
(spec/def :inbox/fetching? (spec/nilable boolean?)) (spec/def :inbox/fetching? (spec/nilable boolean?))
(spec/def :inbox/current-id (spec/nilable string?)) (spec/def :inbox/current-id (spec/nilable keyword?))
(spec/def ::collectible (spec/nilable map?)) (spec/def ::collectible (spec/nilable map?))
(spec/def ::collectibles (spec/nilable map?)) (spec/def ::collectibles (spec/nilable map?))

View File

@ -60,7 +60,7 @@
(views/defview advanced-settings [] (views/defview advanced-settings []
(views/letsubs [current-wnode-id [:settings/current-wnode] (views/letsubs [current-wnode-id [:settings/current-wnode]
wnodes [:settings/network-wnodes]] wnodes [:settings/fleet-wnodes]]
(let [render-fn (offline-messaging.views/render-row current-wnode-id)] (let [render-fn (offline-messaging.views/render-row current-wnode-id)]
[react/view [react/view
[react/text {:style styles/advanced-settings-title [react/text {:style styles/advanced-settings-title

View File

@ -38,6 +38,7 @@
status-im.ui.screens.browser.events status-im.ui.screens.browser.events
status-im.ui.screens.offline-messaging-settings.events status-im.ui.screens.offline-messaging-settings.events
status-im.ui.screens.log-level-settings.events status-im.ui.screens.log-level-settings.events
status-im.ui.screens.fleet-settings.events
status-im.ui.screens.privacy-policy.events status-im.ui.screens.privacy-policy.events
status-im.ui.screens.bootnodes-settings.events status-im.ui.screens.bootnodes-settings.events
status-im.ui.screens.currency-settings.events status-im.ui.screens.currency-settings.events

View File

@ -0,0 +1,27 @@
(ns status-im.ui.screens.fleet-settings.events
(:require [re-frame.core :as re-frame]
[status-im.i18n :as i18n]
[status-im.ui.screens.accounts.models :as accounts.models]
[status-im.utils.handlers :as handlers]
[status-im.utils.handlers-macro :as handlers-macro]))
(handlers/register-handler-fx
::save-fleet
(fn [{:keys [db now] :as cofx} [_ fleet]]
(let [settings (get-in db [:account/account :settings])]
(handlers-macro/merge-fx cofx
(accounts.models/update-settings
(if fleet
(assoc settings :fleet fleet)
(dissoc settings :fleet))
[:logout])))))
(handlers/register-handler-fx
:change-fleet
(fn [{:keys [db]} [_ fleet]]
{:show-confirmation {:title (i18n/label :t/close-app-title)
:content (i18n/label :t/change-fleet
{:fleet fleet})
:confirm-button-text (i18n/label :t/close-app-button)
:on-accept #(re-frame/dispatch [::save-fleet (keyword fleet)])
:on-cancel nil}}))

View File

@ -0,0 +1 @@
(ns status-im.ui.screens.fleet-settings.models)

View File

@ -0,0 +1,48 @@
(ns status-im.ui.screens.fleet-settings.styles
(:require [status-im.ui.components.colors :as colors]
[status-im.utils.platform :as platform])
(:require-macros [status-im.utils.styles :refer [defstyle]]))
(def wrapper
{:flex 1
:background-color :white})
(def fleet-item-inner
{:padding-horizontal 16})
(defstyle fleet-item
{:flex-direction :row
:background-color :white
:align-items :center
:padding-horizontal 16
:ios {:height 64}
:android {:height 56}})
(defstyle fleet-item-name-text
{:color colors/black
:ios {:font-size 17
:letter-spacing -0.2
:line-height 20}
:desktop {:font-size 16}
:android {:font-size 16}})
(defstyle fleet-item-connected-text
{:color colors/gray
:ios {:font-size 14
:margin-top 6
:letter-spacing -0.2}
:android {:font-size 12
:margin-top 2}})
(defn fleet-icon-container [current?]
{:width 40
:height 40
:border-radius 20
:background-color (if current?
colors/blue
colors/gray-light)
:align-items :center
:justify-content :center})
(defn fleet-icon [current?]
(hash-map (if platform/desktop? :tint-color :color) (if current? :white :gray)))

View File

@ -0,0 +1,9 @@
(ns status-im.ui.screens.fleet-settings.subs
(:require [re-frame.core :as re-frame]
[status-im.utils.config :as config]
[status-im.models.fleet :as fleet]))
(re-frame/reg-sub
:settings/current-fleet
(fn [db _]
(fleet/current-fleet db)))

View File

@ -0,0 +1,50 @@
(ns status-im.ui.screens.fleet-settings.views
(:require [re-frame.core :as re-frame]
[status-im.i18n :as i18n]
[status-im.ui.components.icons.vector-icons :as vector-icons]
[status-im.ui.components.list.views :as list]
[status-im.ui.components.react :as react]
[status-im.ui.components.status-bar.view :as status-bar]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.screens.fleet-settings.styles :as styles]
[status-im.utils.platform :as platform])
(:require-macros [status-im.utils.views :as views]))
(defn- fleet-icon [current?]
[react/view (if platform/desktop?
{:style (styles/fleet-icon-container current?)}
(styles/fleet-icon-container current?))
[vector-icons/icon :icons/fleet
(if platform/desktop? {:style (styles/fleet-icon current?)}
(styles/fleet-icon current?))]])
(defn change-fleet [fleet]
(re-frame/dispatch [:change-fleet fleet]))
(defn render-row [current-fleet]
(fn [fleet]
(let [current? (= fleet current-fleet)]
[react/touchable-highlight
{:on-press #(change-fleet fleet)
:accessibility-label :fleet-item}
[react/view styles/fleet-item
[fleet-icon current?]
[react/view styles/fleet-item-inner
[react/text {:style styles/fleet-item-name-text}
fleet]]]])))
(def fleets
["eth.staging" "eth.beta" "eth.test"])
(views/defview fleet-settings []
(views/letsubs [current-fleet [:settings/current-fleet]]
[react/view {:flex 1}
[status-bar/status-bar]
[toolbar/toolbar {}
toolbar/default-nav-back
[toolbar/content-title (i18n/label :t/fleet-settings)]]
[react/view styles/wrapper
[list/flat-list {:data fleets
:default-separator? false
:key-fn identity
:render-fn (render-row (name current-fleet))}]]]))

View File

@ -8,7 +8,7 @@
(spec/def :wnode/address (spec/and string? models.mailserver/valid-enode-address?)) (spec/def :wnode/address (spec/and string? models.mailserver/valid-enode-address?))
(spec/def :wnode/name ::not-blank-string) (spec/def :wnode/name ::not-blank-string)
(spec/def :wnode/id ::not-blank-string) (spec/def :wnode/id keyword?)
(spec/def :wnode/user-defined boolean?) (spec/def :wnode/user-defined boolean?)
(spec/def :wnode/password ::not-blank-string) (spec/def :wnode/password ::not-blank-string)
(spec/def :wnode/sym-key-id string?) (spec/def :wnode/sym-key-id string?)

View File

@ -1,5 +1,6 @@
(ns status-im.ui.screens.offline-messaging-settings.events (ns status-im.ui.screens.offline-messaging-settings.events
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[status-im.models.fleet :as fleet]
[status-im.utils.handlers :as handlers] [status-im.utils.handlers :as handlers]
[status-im.utils.handlers-macro :as handlers-macro] [status-im.utils.handlers-macro :as handlers-macro]
[status-im.ui.screens.accounts.models :as accounts.models] [status-im.ui.screens.accounts.models :as accounts.models]
@ -9,22 +10,20 @@
(handlers/register-handler-fx (handlers/register-handler-fx
::save-wnode ::save-wnode
(fn [{:keys [db now] :as cofx} [_ chain wnode]] (fn [{:keys [db now] :as cofx} [_ current-fleet wnode]]
(let [settings (get-in db [:account/account :settings])] (let [settings (get-in db [:account/account :settings])]
(handlers-macro/merge-fx cofx (handlers-macro/merge-fx cofx
(accounts.models/update-settings (accounts.models/update-settings
(assoc-in settings [:wnode chain] wnode) (assoc-in settings [:wnode current-fleet] wnode)
[:logout]))))) [:logout])))))
(handlers/register-handler-fx (handlers/register-handler-fx
:connect-wnode :connect-wnode
(fn [{:keys [db]} [_ wnode]] (fn [{:keys [db]} [_ wnode]]
(let [network (get (:networks (:account/account db)) (:network db)) (let [current-fleet (fleet/current-fleet db)]
chain (ethereum/network->chain-keyword network)]
{:show-confirmation {:title (i18n/label :t/close-app-title) {:show-confirmation {:title (i18n/label :t/close-app-title)
:content (i18n/label :t/connect-wnode-content :content (i18n/label :t/connect-wnode-content
{:name (get-in db [:inbox/wnodes chain wnode :name])}) {:name (get-in db [:inbox/wnodes current-fleet wnode :name])})
:confirm-button-text (i18n/label :t/close-app-button) :confirm-button-text (i18n/label :t/close-app-button)
:on-accept #(re-frame/dispatch [::save-wnode chain wnode]) :on-accept #(re-frame/dispatch [::save-wnode current-fleet wnode])
:on-cancel nil}}))) :on-cancel nil}})))

View File

@ -7,9 +7,8 @@
(fn [db _] (fn [db _]
(:inbox/current-id db))) (:inbox/current-id db)))
(re-frame/reg-sub :settings/network-wnodes (re-frame/reg-sub :settings/fleet-wnodes
:<- [:network] :<- [:settings/current-fleet]
:<- [:get :inbox/wnodes] :<- [:get :inbox/wnodes]
(fn [[network wnodes]] (fn [[current-fleet wnodes]]
(let [chain (ethereum/network->chain-keyword network)] (current-fleet wnodes)))
(chain wnodes))))

View File

@ -42,7 +42,7 @@
(views/defview offline-messaging-settings [] (views/defview offline-messaging-settings []
(views/letsubs [current-wnode-id [:settings/current-wnode] (views/letsubs [current-wnode-id [:settings/current-wnode]
wnodes [:settings/network-wnodes]] wnodes [:settings/fleet-wnodes]]
[react/view {:flex 1} [react/view {:flex 1}
[status-bar/status-bar] [status-bar/status-bar]
[toolbar/toolbar {} [toolbar/toolbar {}
@ -53,5 +53,5 @@
[react/view styles/wrapper [react/view styles/wrapper
[list/flat-list {:data (vals wnodes) [list/flat-list {:data (vals wnodes)
:default-separator? false :default-separator? false
:key-fn :id :key-fn :name
:render-fn (render-row current-wnode-id)}]]])) :render-fn (render-row current-wnode-id)}]]]))

View File

@ -166,6 +166,11 @@
{:label-kw :t/log-level {:label-kw :t/log-level
:action-fn #(re-frame/dispatch [:navigate-to :log-level-settings]) :action-fn #(re-frame/dispatch [:navigate-to :log-level-settings])
:accessibility-label :log-level-settings-button}] :accessibility-label :log-level-settings-button}]
[profile.components/settings-item-separator]
[profile.components/settings-item
{:label-kw :t/fleet
:action-fn #(re-frame/dispatch [:navigate-to :fleet-settings])
:accessibility-label :fleet-settings-button}]
(when config/bootnodes-settings-enabled? (when config/bootnodes-settings-enabled?
[profile.components/settings-item-separator]) [profile.components/settings-item-separator])
(when config/bootnodes-settings-enabled? (when config/bootnodes-settings-enabled?

View File

@ -14,6 +14,7 @@
status-im.ui.screens.wallet.transactions.subs status-im.ui.screens.wallet.transactions.subs
status-im.ui.screens.network-settings.subs status-im.ui.screens.network-settings.subs
status-im.ui.screens.log-level-settings.subs status-im.ui.screens.log-level-settings.subs
status-im.ui.screens.fleet-settings.subs
status-im.ui.screens.offline-messaging-settings.subs status-im.ui.screens.offline-messaging-settings.subs
status-im.ui.screens.bootnodes-settings.subs status-im.ui.screens.bootnodes-settings.subs
status-im.ui.screens.currency-settings.subs status-im.ui.screens.currency-settings.subs

View File

@ -44,6 +44,7 @@
[status-im.ui.screens.network-settings.edit-network.views :refer [edit-network]] [status-im.ui.screens.network-settings.edit-network.views :refer [edit-network]]
[status-im.ui.screens.extensions.views :refer [extensions-settings]] [status-im.ui.screens.extensions.views :refer [extensions-settings]]
[status-im.ui.screens.log-level-settings.views :refer [log-level-settings]] [status-im.ui.screens.log-level-settings.views :refer [log-level-settings]]
[status-im.ui.screens.fleet-settings.views :refer [fleet-settings]]
[status-im.ui.screens.offline-messaging-settings.views :refer [offline-messaging-settings]] [status-im.ui.screens.offline-messaging-settings.views :refer [offline-messaging-settings]]
[status-im.ui.screens.offline-messaging-settings.edit-mailserver.views :refer [edit-mailserver]] [status-im.ui.screens.offline-messaging-settings.edit-mailserver.views :refer [edit-mailserver]]
[status-im.ui.screens.extensions.add.views :refer [add-extension show-extension]] [status-im.ui.screens.extensions.add.views :refer [add-extension show-extension]]
@ -97,6 +98,7 @@
:network-details network-details :network-details network-details
:edit-network edit-network :edit-network edit-network
:log-level-settings log-level-settings :log-level-settings log-level-settings
:fleet-settings fleet-settings
:offline-messaging-settings offline-messaging-settings :offline-messaging-settings offline-messaging-settings
:edit-mailserver edit-mailserver :edit-mailserver edit-mailserver
:add-extension add-extension :add-extension add-extension

View File

@ -63,14 +63,11 @@
(model/set-input :url "broken" {})))))) (model/set-input :url "broken" {}))))))
(deftest edit-mailserver (deftest edit-mailserver
(let [db {:network "mainnet_rpc" (let [db {:inbox/wnodes
:account/account {:networks {"mainnet_rpc" {:eth.beta {"a" {:id "a"
{:config {:NetworkId 1}}}} :address valid-enode-address
:inbox/wnodes :password password
{:mainnet {"a" {:id "a" :name "name"}}}}
:address valid-enode-address
:password password
:name "name"}}}}
cofx {:db db}] cofx {:db db}]
(testing "when no id is given" (testing "when no id is given"
(let [actual (model/edit nil cofx)] (let [actual (model/edit nil cofx)]
@ -122,45 +119,36 @@
(deftest fetch-mailserver (deftest fetch-mailserver
(testing "it fetches the mailserver from the db" (testing "it fetches the mailserver from the db"
(let [cofx {:db {:network "mainnet_rpc" (let [cofx {:db {:inbox/wnodes {:eth.beta {"a" {:id "a"
:account/account {:networks {"mainnet_rpc" :name "old-name"
{:config {:NetworkId 1}}}} :address "enode://old-id:old-password@url:port"}}}}}]
:inbox/wnodes {:mainnet {"a" {:id "a"
:name "old-name"
:address "enode://old-id:old-password@url:port"}}}}}]
(is (model/fetch "a" cofx))))) (is (model/fetch "a" cofx)))))
(deftest fetch-current-mailserver (deftest fetch-current-mailserver
(testing "it fetches the mailserver from the db with corresponding id" (testing "it fetches the mailserver from the db with corresponding id"
(let [cofx {:db {:network "mainnet_rpc" (let [cofx {:db {:inbox/current-id "a"
:account/account {:networks {"mainnet_rpc" :inbox/wnodes {:eth.beta {"a" {:id "a"
{:config {:NetworkId 1}}}} :name "old-name"
:inbox/current-id "a" :address "enode://old-id:old-password@url:port"}}}}}]
:inbox/wnodes {:mainnet {"a" {:id "a"
:name "old-name"
:address "enode://old-id:old-password@url:port"}}}}}]
(is (model/fetch-current cofx))))) (is (model/fetch-current cofx)))))
(deftest set-current-mailserver (deftest set-current-mailserver
(with-redefs [rand-nth (comp last sort)] (with-redefs [rand-nth (comp last sort)]
(let [cofx {:db {:network "mainnet_rpc" (let [cofx {:db {:inbox/wnodes {:eth.beta {"a" {}
:account/account {:networks {"mainnet_rpc" "b" {}
{:config {:NetworkId 1}}}} "c" {}
:inbox/wnodes {:mainnet {"a" {} "d" {}}}}}]
"b" {}
"c" {}
"d" {}}}}}]
(testing "the user has already a preference" (testing "the user has already a preference"
(let [cofx (assoc-in cofx (let [cofx (assoc-in cofx
[:db :account/account :settings] [:db :account/account :settings]
{:wnode {:mainnet "a"}})] {:wnode {:eth.beta "a"}})]
(testing "the mailserver exists" (testing "the mailserver exists"
(testing "it sets the preferred mailserver" (testing "it sets the preferred mailserver"
(is (= "a" (-> (model/set-current-mailserver cofx) (is (= "a" (-> (model/set-current-mailserver cofx)
:db :db
:inbox/current-id))))) :inbox/current-id)))))
(testing "the mailserver does not exists" (testing "the mailserver does not exists"
(let [cofx (update-in cofx [:db :inbox/wnodes :mainnet] dissoc "a")] (let [cofx (update-in cofx [:db :inbox/wnodes :eth.beta] dissoc "a")]
(testing "sets a random mailserver" (testing "sets a random mailserver"
(is (= "d" (-> (model/set-current-mailserver cofx) (is (= "d" (-> (model/set-current-mailserver cofx)
:db :db
@ -195,13 +183,10 @@
(deftest delete-mailserver (deftest delete-mailserver
(testing "the user is not connected to the mailserver" (testing "the user is not connected to the mailserver"
(let [cofx {:random-id "random-id" (let [cofx {:random-id "random-id"
:db {:network "mainnet_rpc" :db {:inbox/wnodes {:eth.beta {"a" {:id "a"
:account/account {:networks {"mainnet_rpc" :name "old-name"
{:config {:NetworkId 1}}}} :user-defined true
:inbox/wnodes {:mainnet {"a" {:id "a" :address "enode://old-id:old-password@url:port"}}}}}
:name "old-name"
:user-defined true
:address "enode://old-id:old-password@url:port"}}}}}
actual (model/delete "a" cofx)] actual (model/delete "a" cofx)]
(testing "it removes the mailserver from the list" (testing "it removes the mailserver from the list"
(is (not (model/fetch "a" actual)))) (is (not (model/fetch "a" actual))))
@ -209,24 +194,17 @@
(is (= 1 (count (:data-store/tx actual))))))) (is (= 1 (count (:data-store/tx actual)))))))
(testing "the mailserver is not user-defined" (testing "the mailserver is not user-defined"
(let [cofx {:random-id "random-id" (let [cofx {:random-id "random-id"
:db {:network "mainnet_rpc" :db {:inbox/wnodes {:eth.beta {"a" {:id "a"
:account/account {:networks {"mainnet_rpc" :name "old-name"
{:config {:NetworkId 1}}}} :address "enode://old-id:old-password@url:port"}}}}}
:inbox/wnodes {:mainnet {"a" {:id "a"
:name "old-name"
:address "enode://old-id:old-password@url:port"}}}}}
actual (model/delete "a" cofx)] actual (model/delete "a" cofx)]
(testing "it does not delete the mailserver" (testing "it does not delete the mailserver"
(is (nil? actual))))) (is (nil? actual)))))
(testing "the user is connected to the mailserver" (testing "the user is connected to the mailserver"
(let [cofx {:random-id "random-id" (let [cofx {:random-id "random-id"
:db {:network "mainnet_rpc" :db {:inbox/wnodes {:eth.beta {"a" {:id "a"
:account/account {:settings {:wnode {:mainnet "a"}} :name "old-name"
:networks {"mainnet_rpc" :address "enode://old-id:old-password@url:port"}}}}}
{:config {:NetworkId 1}}}}
:inbox/wnodes {:mainnet {"a" {:id "a"
:name "old-name"
:address "enode://old-id:old-password@url:port"}}}}}
actual (model/delete "a" cofx)] actual (model/delete "a" cofx)]
(testing "it does not remove the mailserver from the list" (testing "it does not remove the mailserver from the list"
(is (nil? actual)))))) (is (nil? actual))))))
@ -234,21 +212,18 @@
(deftest upsert-mailserver (deftest upsert-mailserver
(testing "new mailserver" (testing "new mailserver"
(let [cofx {:random-id "random-id" (let [cofx {:random-id "random-id"
:db {:network "mainnet_rpc" :db {:mailservers/manage {:name {:value "test-name"}
:account/account {:networks {"mainnet_rpc"
{:config {:NetworkId 1}}}}
:mailservers/manage {:name {:value "test-name"}
:url {:value "enode://test-id:test-password@url:port"}} :url {:value "enode://test-id:test-password@url:port"}}
:inbox/wnodes {}}} :inbox/wnodes {}}}
actual (model/upsert cofx)] actual (model/upsert cofx)]
(testing "it adds the enode to inbox/wnodes" (testing "it adds the enode to inbox/wnodes"
(is (= {:mainnet {"randomid" {:password "test-password" (is (= {:eth.beta {"randomid" {:password "test-password"
:address "enode://test-id@url:port" :address "enode://test-id@url:port"
:name "test-name" :name "test-name"
:id "randomid" :id "randomid"
:user-defined true}}} :user-defined true}}}
(get-in actual [:db :inbox/wnodes])))) (get-in actual [:db :inbox/wnodes]))))
(testing "it navigates back" (testing "it navigates back"
(is (= [:navigate-back] (is (= [:navigate-back]
@ -257,26 +232,23 @@
(is (= 1 (count (:data-store/tx actual))))))) (is (= 1 (count (:data-store/tx actual)))))))
(testing "existing mailserver" (testing "existing mailserver"
(let [cofx {:random-id "random-id" (let [cofx {:random-id "random-id"
:db {:network "mainnet_rpc" :db {:mailservers/manage {:id {:value "a"}
:account/account {:networks {"mainnet_rpc"
{:config {:NetworkId 1}}}}
:mailservers/manage {:id {:value "a"}
:name {:value "new-name"} :name {:value "new-name"}
:url {:value "enode://new-id:new-password@url:port"}} :url {:value "enode://new-id:new-password@url:port"}}
:inbox/wnodes {:mainnet {"a" {:id "a" :inbox/wnodes {:eth.beta {"a" {:id "a"
:name "old-name" :name "old-name"
:address "enode://old-id:old-password@url:port"}}}}} :address "enode://old-id:old-password@url:port"}}}}}
actual (model/upsert cofx)] actual (model/upsert cofx)]
(testing "it navigates back" (testing "it navigates back"
(is (= [:navigate-back] (is (= [:navigate-back]
(:dispatch actual)))) (:dispatch actual))))
(testing "it updates the enode to inbox/wnodes" (testing "it updates the enode to inbox/wnodes"
(is (= {:mainnet {"a" {:password "new-password" (is (= {:eth.beta {"a" {:password "new-password"
:address "enode://new-id@url:port" :address "enode://new-id@url:port"
:name "new-name" :name "new-name"
:id "a" :id "a"
:user-defined true}}} :user-defined true}}}
(get-in actual [:db :inbox/wnodes])))) (get-in actual [:db :inbox/wnodes]))))
(testing "it stores it in the db" (testing "it stores it in the db"
(is (= 1 (count (:data-store/tx actual))))) (is (= 1 (count (:data-store/tx actual)))))

View File

@ -4,10 +4,7 @@
[status-im.transport.core :as transport])) [status-im.transport.core :as transport]))
(deftest init-whisper (deftest init-whisper
(let [cofx {:db {:network "mainnet_rpc" (let [cofx {:db {:account/account {:public-key "1"}
:account/account
{:networks {"mainnet_rpc" {:config {:NetworkId 1}}}
:public-key "1"}
:semaphores #{}}}] :semaphores #{}}}]
(testing "it adds the discover filter" (testing "it adds the discover filter"
(is (= (:shh/add-discovery-filter (protocol/initialize-protocol "user-address" cofx))))) (is (= (:shh/add-discovery-filter (protocol/initialize-protocol "user-address" cofx)))))
@ -15,29 +12,29 @@
(is (= (:shh/restore-sym-keys (protocol/initialize-protocol "user-address" cofx))))) (is (= (:shh/restore-sym-keys (protocol/initialize-protocol "user-address" cofx)))))
(testing "custom mailservers" (testing "custom mailservers"
(let [ms-1 {:id "1" (let [ms-1 {:id "1"
:chain "mainnet" :fleet :eth.beta
:name "name-1" :name "name-1"
:address "address-1" :address "address-1"
:password "password-1"} :password "password-1"}
ms-2 {:id "2" ms-2 {:id "2"
:chain "mainnet" :fleet :eth.beta
:name "name-2" :name "name-2"
:address "address-2" :address "address-2"
:password "password-2"} :password "password-2"}
ms-3 {:id "3" ms-3 {:id "3"
:chain "rinkeby" :fleet :eth.test
:name "name-3" :name "name-3"
:address "address-3" :address "address-3"
:password "password-3"} :password "password-3"}
expected-wnodes {:mainnet {"1" (-> ms-1 expected-wnodes {:eth.beta {"1" (-> ms-1
(dissoc :chain) (dissoc :fleet)
(assoc :user-defined true)) (assoc :user-defined true))
"2" (-> ms-2 "2" (-> ms-2
(dissoc ms-2 :chain) (dissoc ms-2 :fleet)
(assoc :user-defined true))} (assoc :user-defined true))}
:rinkeby {"3" (-> ms-3 :eth.test {"3" (-> ms-3
(dissoc :chain) (dissoc :fleet)
(assoc :user-defined true))}} (assoc :user-defined true))}}
cofx-with-ms (assoc cofx cofx-with-ms (assoc cofx
:data-store/mailservers :data-store/mailservers
[ms-1 [ms-1

View File

@ -1,18 +1,16 @@
(ns status-im.test.transport.inbox (ns status-im.test.transport.inbox
(:require [cljs.test :refer-macros [deftest is testing]] (:require [cljs.test :refer-macros [deftest is testing]]
[status-im.transport.inbox :as inbox] [status-im.transport.inbox :as inbox]))
[status-im.constants :as constants]))
(defn cofx-fixtures [sym-key registered-peer?] (defn cofx-fixtures [sym-key registered-peer?]
{:db {:mailserver-status :connected {:db {:mailserver-status :connected
:network "mainnet_rpc"
:peers-summary (if registered-peer? :peers-summary (if registered-peer?
[{:id "wnode-id"}] [{:id "wnode-id"}]
[]) [])
:account/account {:networks constants/default-networks} :account/account {:settings {:fleet :eth.beta}}
:inbox/current-id "mailserver-a" :inbox/current-id "mailserver-a"
:inbox/wnodes {:mainnet {"mailserver-a" {:sym-key-id sym-key :inbox/wnodes {:eth.beta {"mailserver-a" {:sym-key-id sym-key
:address "enode://wnode-id@ip"}}}}}) :address "enode://wnode-id@ip"}}}}})
(defn peers-summary-change-fx-result [sym-key registered-peer? registered-peer-before?] (defn peers-summary-change-fx-result [sym-key registered-peer? registered-peer-before?]
(inbox/peers-summary-change-fx (if registered-peer-before? (inbox/peers-summary-change-fx (if registered-peer-before?
@ -45,14 +43,13 @@
#{})))) #{}))))
(deftest connect-to-mailserver (deftest connect-to-mailserver
(let [db {:network "mainnet" (let [db {:inbox/current-id "wnodeid"
:inbox/current-id "wnodeid"
:inbox/wnodes :inbox/wnodes
{:mainnet {"wnodeid" {:address "wnode-address" {:eth.beta {"wnodeid" {:address "wnode-address"
:password "wnode-password"}}} :password "wnode-password"}}}
:account/account :account/account
{:settings {:wnode {:mainnet "wnodeid"}} {:settings {:fleet :eth.beta
:networks {"mainnet" {:config {:NetworkId 1}}}}}] :wnode {:eth.beta "wnodeid"}}}}]
(testing "it adds the peer" (testing "it adds the peer"
(is (= {:wnode "wnode-address"} (is (= {:wnode "wnode-address"}
(::inbox/add-peer (inbox/connect-to-mailserver {:db db}))))) (::inbox/add-peer (inbox/connect-to-mailserver {:db db})))))
@ -63,7 +60,7 @@
first first
:password)))) :password))))
(let [wnode-with-sym-key-db (assoc-in db (let [wnode-with-sym-key-db (assoc-in db
[:inbox/wnodes :mainnet "wnodeid" :sym-key-id] [:inbox/wnodes :eth.beta "wnodeid" :sym-key-id]
"somesymkeyid")] "somesymkeyid")]
(testing "it does not generate a sym key if already present" (testing "it does not generate a sym key if already present"
(is (not (-> (inbox/connect-to-mailserver {:db wnode-with-sym-key-db}) (is (not (-> (inbox/connect-to-mailserver {:db wnode-with-sym-key-db})
@ -71,15 +68,12 @@
first))))))) first)))))))
(deftest request-messages (deftest request-messages
(let [db {:network "mainnet" (let [db {:mailserver-status :connected
:mailserver-status :connected
:inbox/current-id "wnodeid" :inbox/current-id "wnodeid"
:inbox/wnodes :inbox/wnodes {:eth.beta {"wnodeid" {:address "wnode-address"
{:mainnet {"wnodeid" {:address "wnode-address" :sym-key-id "something"
:sym-key-id "something" :password "wnode-password"}}}
:password "wnode-password"}}} :account/account {:settings {:fleet :eth.beta}}
:account/account
{:networks {"mainnet" {:config {:NetworkId 1}}}}
:transport/chats :transport/chats
{:dont-fetch-history {:topic "dont-fetch-history"} {:dont-fetch-history {:topic "dont-fetch-history"}
:fetch-history {:topic "fetch-history" :fetch-history {:topic "fetch-history"
@ -166,15 +160,13 @@
(into #{} (inbox/request-inbox-messages-params mailserver 0 90000 ["a" "b"]))))))) (into #{} (inbox/request-inbox-messages-params mailserver 0 90000 ["a" "b"])))))))
(deftest initialize-offline-inbox (deftest initialize-offline-inbox
(let [db {:network "mainnet" (let [db {:mailserver-status :connected
:mailserver-status :connected :account/account {:settings {:fleet :eth.beta}}
:inbox/current-id "wnodeid" :inbox/current-id "wnodeid"
:inbox/wnodes :inbox/wnodes
{:mainnet {"wnodeid" {:address "wnode-address" {:eth.beta {"wnodeid" {:address "wnode-address"
:sym-key-id "something" :sym-key-id "something"
:password "wnode-password"}}} :password "wnode-password"}}}}]
:account/account
{:networks {"mainnet" {:config {:NetworkId 1}}}}}]
(testing "last-request is not set" (testing "last-request is not set"
(testing "it sets it to now in seconds" (testing "it sets it to now in seconds"
(is (= 10 (is (= 10