trade now takes array of UInt8 for price and expiry and is working

pull/2/head
James Sangalli 7 years ago
commit 19ca5c050e
  1. 7
      .gitignore
  2. 271
      .idea/workspace.xml
  3. 3
      JS/.babelrc
  4. 1
      JS/dist/trust-min.js
  5. 57468
      JS/dist/trust.js
  6. 67
      JS/gulpfile.babel.js
  7. 6801
      JS/package-lock.json
  8. 46
      JS/package.json
  9. 100
      JS/src/index.js
  10. 92
      Trust.xcodeproj/project.pbxproj
  11. 2
      Trust/Accounts/ViewModels/AccountViewModel.swift
  12. 12
      Trust/Accounts/ViewModels/AccountsViewController.swift
  13. 2
      Trust/Accounts/Views/AccountViewCell.swift
  14. 25
      Trust/Accounts/Views/AccountViewCell.xib
  15. BIN
      Trust/Assets.xcassets/glasses.imageset/glasses@3x.png
  16. 21
      Trust/Assets.xcassets/settings_preferences.imageset/Contents.json
  17. BIN
      Trust/Assets.xcassets/settings_preferences.imageset/settings_preferences.png
  18. 161
      Trust/Browser/Factory/WKWebViewConfiguration.swift
  19. 2
      Trust/Browser/Types/BrowserURLParser.swift
  20. 15
      Trust/Core/ViewModels/InCoordinatorViewModel.swift
  21. 2
      Trust/EtherClient/Requests/MarketOrders.swift
  22. 5
      Trust/Extensions/Address.swift
  23. 11
      Trust/Extensions/UINavigationController.swift
  24. 33
      Trust/Extensions/UITextFieldAdditions.swift
  25. 64
      Trust/Foundation/DecimalFormatter.swift
  26. 44
      Trust/Foundation/StringFormatter.swift
  27. 29
      Trust/InCoordinator.swift
  28. 4
      Trust/Info.plist
  29. 2
      Trust/Lock/ViewModels/LockCreatePasscodeViewModel.swift
  30. 32
      Trust/Market/SignOrders.swift
  31. 22
      Trust/Settings/Controllers/PreferencesController.swift
  32. 7
      Trust/Settings/Types/Config.swift
  33. 19
      Trust/Settings/Types/ConfigExplorer.swift
  34. 13
      Trust/Settings/Types/PreferenceOption.swift
  35. 12
      Trust/Settings/Types/RPCServers.swift
  36. 39
      Trust/Settings/ViewControllers/PreferencesViewController.swift
  37. 77
      Trust/Settings/ViewControllers/SettingsViewController.swift
  38. 18
      Trust/Settings/ViewModels/PreferencesViewModel.swift
  39. 1
      Trust/Settings/ViewModels/SettingsViewModel.swift
  40. 8
      Trust/Tokens/ViewControllers/NewTokenViewController.swift
  41. 4
      Trust/Tokens/ViewControllers/TokensViewController.swift
  42. 6
      Trust/Transactions/ViewControllers/TransactionViewController.swift
  43. 8
      Trust/Transactions/ViewModels/TransactionDetailsViewModel.swift
  44. 2
      Trust/Transactions/ViewModels/TransactionsViewModel.swift
  45. 2
      Trust/Transfer/Types/GasLimitConfiguration.swift
  46. 2
      Trust/Transfer/Types/GasPriceConfiguration.swift
  47. 2
      Trust/Transfer/ViewControllers/ConfigureTransactionViewController.swift
  48. 91
      Trust/Transfer/ViewControllers/SendViewController.swift
  49. 13
      Trust/Wallet/ViewControllers/ImportWalletViewController.swift
  50. 44
      TrustTests/Coordinators/InCoordinatorTests.swift
  51. 25
      TrustTests/Core/ViewModels/InCoordinatorViewModelTests.swift
  52. 14
      TrustTests/Factories/PreferencesController.swift
  53. 47
      TrustTests/Foundation/DecimalNumberFormatterTest.swift
  54. 12
      TrustTests/Foundation/StringFormatterTest.swift
  55. 4
      TrustTests/Info.plist
  56. 11
      TrustTests/Market/OrderSigningTests.swift
  57. 6
      TrustTests/Settings/ConfigTests.swift
  58. 21
      TrustTests/Settings/Controllers/PreferencesControllerTests.swift
  59. 2
      TrustTests/Transfer/Types/GasLimitConfigurationTests.swift
  60. 2
      TrustTests/Transfer/Types/GasPriceConfigurationTests.swift
  61. 4
      TrustUITests/Info.plist

7
.gitignore vendored

@ -82,3 +82,10 @@ Trust.zip
*.mobileprovision
*.cer
# VIM
*.swp
*.swo
# node
node_modules
JS/staging

@ -2,8 +2,67 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="36bad8c5-1e9e-4730-ba80-fb45b953be97" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/Trust/EtherClient/EtherKeystore.swift" afterPath="$PROJECT_DIR$/Trust/EtherClient/EtherKeystore.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/JS/.babelrc" />
<change beforePath="" afterPath="$PROJECT_DIR$/JS/dist/trust-min.js" />
<change beforePath="" afterPath="$PROJECT_DIR$/JS/dist/trust.js" />
<change beforePath="" afterPath="$PROJECT_DIR$/JS/gulpfile.babel.js" />
<change beforePath="" afterPath="$PROJECT_DIR$/JS/package-lock.json" />
<change beforePath="" afterPath="$PROJECT_DIR$/JS/package.json" />
<change beforePath="" afterPath="$PROJECT_DIR$/JS/src/index.js" />
<change beforePath="" afterPath="$PROJECT_DIR$/Trust/Assets.xcassets/settings_preferences.imageset/Contents.json" />
<change beforePath="" afterPath="$PROJECT_DIR$/Trust/Assets.xcassets/settings_preferences.imageset/settings_preferences.png" />
<change beforePath="" afterPath="$PROJECT_DIR$/Trust/Extensions/UINavigationController.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/Trust/Extensions/UITextFieldAdditions.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/Trust/Foundation/DecimalFormatter.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/Trust/Foundation/StringFormatter.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/Trust/Settings/Controllers/PreferencesController.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/Trust/Settings/Types/PreferenceOption.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/Trust/Settings/ViewControllers/PreferencesViewController.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/Trust/Settings/ViewModels/PreferencesViewModel.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/TrustTests/Core/ViewModels/InCoordinatorViewModelTests.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/TrustTests/Factories/PreferencesController.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/TrustTests/Foundation/DecimalNumberFormatterTest.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/TrustTests/Foundation/StringFormatterTest.swift" />
<change beforePath="" afterPath="$PROJECT_DIR$/TrustTests/Settings/Controllers/PreferencesControllerTests.swift" />
<change beforePath="$PROJECT_DIR$/.gitignore" afterPath="$PROJECT_DIR$/.gitignore" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/Trust.xcodeproj/project.pbxproj" afterPath="$PROJECT_DIR$/Trust.xcodeproj/project.pbxproj" />
<change beforePath="$PROJECT_DIR$/Trust/Accounts/ViewModels/AccountViewModel.swift" afterPath="$PROJECT_DIR$/Trust/Accounts/ViewModels/AccountViewModel.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Accounts/ViewModels/AccountsViewController.swift" afterPath="$PROJECT_DIR$/Trust/Accounts/ViewModels/AccountsViewController.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Accounts/Views/AccountViewCell.swift" afterPath="$PROJECT_DIR$/Trust/Accounts/Views/AccountViewCell.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Accounts/Views/AccountViewCell.xib" afterPath="$PROJECT_DIR$/Trust/Accounts/Views/AccountViewCell.xib" />
<change beforePath="$PROJECT_DIR$/Trust/Assets.xcassets/glasses.imageset/glasses@3x.png" afterPath="$PROJECT_DIR$/Trust/Assets.xcassets/glasses.imageset/glasses@3x.png" />
<change beforePath="$PROJECT_DIR$/Trust/Browser/Factory/WKWebViewConfiguration.swift" afterPath="$PROJECT_DIR$/Trust/Browser/Factory/WKWebViewConfiguration.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Browser/Types/BrowserURLParser.swift" afterPath="$PROJECT_DIR$/Trust/Browser/Types/BrowserURLParser.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Core/ViewModels/InCoordinatorViewModel.swift" afterPath="$PROJECT_DIR$/Trust/Core/ViewModels/InCoordinatorViewModel.swift" />
<change beforePath="$PROJECT_DIR$/Trust/EtherClient/Requests/MarketOrders.swift" afterPath="$PROJECT_DIR$/Trust/EtherClient/Requests/MarketOrders.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Extensions/Address.swift" afterPath="$PROJECT_DIR$/Trust/Extensions/Address.swift" />
<change beforePath="$PROJECT_DIR$/Trust/InCoordinator.swift" afterPath="$PROJECT_DIR$/Trust/InCoordinator.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Info.plist" afterPath="$PROJECT_DIR$/Trust/Info.plist" />
<change beforePath="$PROJECT_DIR$/Trust/Lock/ViewModels/LockCreatePasscodeViewModel.swift" afterPath="$PROJECT_DIR$/Trust/Lock/ViewModels/LockCreatePasscodeViewModel.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Market/SignOrders.swift" afterPath="$PROJECT_DIR$/Trust/Market/SignOrders.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Settings/Types/Config.swift" afterPath="$PROJECT_DIR$/Trust/Settings/Types/Config.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Settings/Types/ConfigExplorer.swift" afterPath="$PROJECT_DIR$/Trust/Settings/Types/ConfigExplorer.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Settings/Types/RPCServers.swift" afterPath="$PROJECT_DIR$/Trust/Settings/Types/RPCServers.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Settings/ViewControllers/SettingsViewController.swift" afterPath="$PROJECT_DIR$/Trust/Settings/ViewControllers/SettingsViewController.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Settings/ViewModels/SettingsViewModel.swift" afterPath="$PROJECT_DIR$/Trust/Settings/ViewModels/SettingsViewModel.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Tokens/ViewControllers/NewTokenViewController.swift" afterPath="$PROJECT_DIR$/Trust/Tokens/ViewControllers/NewTokenViewController.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Tokens/ViewControllers/TokensViewController.swift" afterPath="$PROJECT_DIR$/Trust/Tokens/ViewControllers/TokensViewController.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Transactions/ViewControllers/TransactionViewController.swift" afterPath="$PROJECT_DIR$/Trust/Transactions/ViewControllers/TransactionViewController.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Transactions/ViewModels/TransactionDetailsViewModel.swift" afterPath="$PROJECT_DIR$/Trust/Transactions/ViewModels/TransactionDetailsViewModel.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Transactions/ViewModels/TransactionsViewModel.swift" afterPath="$PROJECT_DIR$/Trust/Transactions/ViewModels/TransactionsViewModel.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Transfer/Types/GasLimitConfiguration.swift" afterPath="$PROJECT_DIR$/Trust/Transfer/Types/GasLimitConfiguration.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Transfer/Types/GasPriceConfiguration.swift" afterPath="$PROJECT_DIR$/Trust/Transfer/Types/GasPriceConfiguration.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Transfer/ViewControllers/ConfigureTransactionViewController.swift" afterPath="$PROJECT_DIR$/Trust/Transfer/ViewControllers/ConfigureTransactionViewController.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Transfer/ViewControllers/SendViewController.swift" afterPath="$PROJECT_DIR$/Trust/Transfer/ViewControllers/SendViewController.swift" />
<change beforePath="$PROJECT_DIR$/Trust/Wallet/ViewControllers/ImportWalletViewController.swift" afterPath="$PROJECT_DIR$/Trust/Wallet/ViewControllers/ImportWalletViewController.swift" />
<change beforePath="$PROJECT_DIR$/TrustTests/Coordinators/InCoordinatorTests.swift" afterPath="$PROJECT_DIR$/TrustTests/Coordinators/InCoordinatorTests.swift" />
<change beforePath="$PROJECT_DIR$/TrustTests/Info.plist" afterPath="$PROJECT_DIR$/TrustTests/Info.plist" />
<change beforePath="$PROJECT_DIR$/TrustTests/Market/OrderSigningTests.swift" afterPath="$PROJECT_DIR$/TrustTests/Market/OrderSigningTests.swift" />
<change beforePath="$PROJECT_DIR$/TrustTests/Settings/ConfigTests.swift" afterPath="$PROJECT_DIR$/TrustTests/Settings/ConfigTests.swift" />
<change beforePath="$PROJECT_DIR$/TrustTests/Transfer/Types/GasLimitConfigurationTests.swift" afterPath="$PROJECT_DIR$/TrustTests/Transfer/Types/GasLimitConfigurationTests.swift" />
<change beforePath="$PROJECT_DIR$/TrustTests/Transfer/Types/GasPriceConfigurationTests.swift" afterPath="$PROJECT_DIR$/TrustTests/Transfer/Types/GasPriceConfigurationTests.swift" />
<change beforePath="$PROJECT_DIR$/TrustUITests/Info.plist" afterPath="$PROJECT_DIR$/TrustUITests/Info.plist" />
</list>
<ignored path="$USER_HOME$/Library/Developer/Xcode/DerivedData/Trust-fagtjernnlugowdujijvfmqpxdjn/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -19,8 +78,8 @@
<file leaf-file-name="SignOrders.swift" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Trust/Market/SignOrders.swift">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="374">
<caret line="100" column="0" lean-forward="false" selection-start-line="100" selection-start-column="0" selection-end-line="100" selection-end-column="0" />
<state relative-caret-position="224">
<caret line="97" column="0" lean-forward="false" selection-start-line="97" selection-start-column="0" selection-end-line="97" selection-end-column="0" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
@ -28,21 +87,11 @@
</provider>
</entry>
</file>
<file leaf-file-name="EtherKeystore.swift" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Trust/EtherClient/EtherKeystore.swift">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="283">
<caret line="310" column="9" lean-forward="false" selection-start-line="310" selection-start-column="9" selection-end-line="310" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="OrderSigningTests.swift" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/TrustTests/Market/OrderSigningTests.swift">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="30" column="48" lean-forward="true" selection-start-line="30" selection-start-column="48" selection-end-line="30" selection-end-column="48" />
<state relative-caret-position="435">
<caret line="29" column="75" lean-forward="true" selection-start-line="29" selection-start-column="75" selection-end-line="29" selection-end-column="75" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
@ -80,9 +129,12 @@
<find>balance</find>
<find>UInt16</find>
<find>Uint8</find>
<find>signMessageDa</find>
<find>expiryTimeStamp</find>
</findStrings>
<replaceStrings>
<replace>UInt8</replace>
<replace>expiryBuffer</replace>
</replaceStrings>
</component>
<component name="Git.Settings">
@ -104,9 +156,9 @@
<option value="$PROJECT_DIR$/TrustTests/TrustTests.swift" />
<option value="$PROJECT_DIR$/Trust/EtherClient/Keystore.swift" />
<option value="$PROJECT_DIR$/Trust/EtherClient/KeyStoreError.swift" />
<option value="$PROJECT_DIR$/TrustTests/Market/OrderSigningTests.swift" />
<option value="$PROJECT_DIR$/Trust/EtherClient/EtherKeystore.swift" />
<option value="$PROJECT_DIR$/Trust/Market/SignOrders.swift" />
<option value="$PROJECT_DIR$/TrustTests/Market/OrderSigningTests.swift" />
</list>
</option>
</component>
@ -183,108 +235,16 @@
<expand>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="EtherClient" type="fcab9f18:XcodeViewNode" />
<item name="Pods" type="1d218c8b:XcodeProjectNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Lock" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Lock" type="fcab9f18:XcodeViewNode" />
<item name="Coordinators" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Lock" type="fcab9f18:XcodeViewNode" />
<item name="ViewControllers" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Lock" type="fcab9f18:XcodeViewNode" />
<item name="ViewModels" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Lock" type="fcab9f18:XcodeViewNode" />
<item name="Views" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Market" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="UI" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Wallet" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Wallet" type="fcab9f18:XcodeViewNode" />
<item name="Types" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Wallet" type="fcab9f18:XcodeViewNode" />
<item name="ViewControllers" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Wallet" type="fcab9f18:XcodeViewNode" />
<item name="ViewModels" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="Trust" type="fcab9f18:XcodeViewNode" />
<item name="Welcome" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="TrustTests" type="fcab9f18:XcodeViewNode" />
</path>
<path>
<item name="" type="efc3779f:XcodeRootNode" />
<item name="Trust" type="1d218c8b:XcodeProjectNode" />
<item name="TrustTests" type="fcab9f18:XcodeViewNode" />
<item name="Market" type="fcab9f18:XcodeViewNode" />
</path>
</expand>
<select />
@ -310,34 +270,19 @@
</option>
</component>
<component name="RunManager" selected="XCTest/Kiwi.OrderSigningTests.testSigningOrders">
<configuration name="All in OrderSigningTests.swift" type="OCUnitRunConfiguration" factoryName="XCTest/Kiwi" temporary="true" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Trust" TARGET_NAME="TrustTests" CONFIG_NAME="Debug" SCHEME_NAME="All in OrderSigningTests.swift" TEST_PATTERN="OrderSigningTests" TEST_MODE="PATTERN">
<envs />
</configuration>
<configuration name="All in SignOrders.swift" type="OCUnitRunConfiguration" factoryName="XCTest/Kiwi" temporary="true" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Trust" TARGET_NAME="TrustTests" CONFIG_NAME="Debug" SCHEME_NAME="All in SignOrders.swift" TEST_PATTERN="" TEST_MODE="PATTERN">
<envs />
</configuration>
<configuration name="OrderSigningTests.testInit" type="OCUnitRunConfiguration" factoryName="XCTest/Kiwi" temporary="true" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Trust" TARGET_NAME="TrustTests" CONFIG_NAME="Debug" SCHEME_NAME="OrderSigningTests.testInit" TEST_CLASS="OrderSigningTests" TEST_METHOD="testInit" TEST_MODE="SUITE_TEST">
<envs />
</configuration>
<configuration name="OrderSigningTests.testSigningOrders" type="OCUnitRunConfiguration" factoryName="XCTest/Kiwi" temporary="true" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Trust" TARGET_NAME="TrustTests" CONFIG_NAME="Debug" SCHEME_NAME="OrderSigningTests.testSigningOrders" TEST_CLASS="OrderSigningTests" TEST_METHOD="testSigningOrders" TEST_MODE="SUITE_TEST">
<envs />
</configuration>
<list size="8">
<list size="5">
<item index="0" class="java.lang.String" itemvalue="Application.Trust - Europe" />
<item index="1" class="java.lang.String" itemvalue="Application.Trust" />
<item index="2" class="java.lang.String" itemvalue="Application.TrustTests" />
<item index="3" class="java.lang.String" itemvalue="Application.TrustUITests" />
<item index="4" class="java.lang.String" itemvalue="XCTest/Kiwi.OrderSigningTests.testInit" />
<item index="5" class="java.lang.String" itemvalue="XCTest/Kiwi.All in SignOrders.swift" />
<item index="6" class="java.lang.String" itemvalue="XCTest/Kiwi.All in OrderSigningTests.swift" />
<item index="7" class="java.lang.String" itemvalue="XCTest/Kiwi.OrderSigningTests.testSigningOrders" />
<item index="4" class="java.lang.String" itemvalue="XCTest/Kiwi.OrderSigningTests.testSigningOrders" />
</list>
<recent_temporary>
<list size="4">
<list size="1">
<item index="0" class="java.lang.String" itemvalue="XCTest/Kiwi.OrderSigningTests.testSigningOrders" />
<item index="1" class="java.lang.String" itemvalue="XCTest/Kiwi.OrderSigningTests.testInit" />
<item index="2" class="java.lang.String" itemvalue="XCTest/Kiwi.All in OrderSigningTests.swift" />
<item index="3" class="java.lang.String" itemvalue="XCTest/Kiwi.All in SignOrders.swift" />
</list>
</recent_temporary>
</component>
@ -373,80 +318,68 @@
<workItem from="1518334735649" duration="1042000" />
<workItem from="1518398527471" duration="1748000" />
<workItem from="1518403192759" duration="35589000" />
<workItem from="1518668693732" duration="3531000" />
</task>
<servers />
</component>
<component name="TestHistory">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 06m 13s.xml">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 49m 35s.xml">
<configuration name="OrderSigningTests.testSigningOrders" configurationId="OCUnitRunConfiguration" />
</history-entry>
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 14m 26s.xml">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 55m 47s.xml">
<configuration name="OrderSigningTests.testSigningOrders" configurationId="OCUnitRunConfiguration" />
</history-entry>
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 19m 02s.xml">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 12h 40m 41s.xml">
<configuration name="OrderSigningTests.testSigningOrders" configurationId="OCUnitRunConfiguration" />
</history-entry>
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 36m 53s.xml">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 12h 49m 32s.xml">
<configuration name="OrderSigningTests.testSigningOrders" configurationId="OCUnitRunConfiguration" />
</history-entry>
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 37m 35s.xml">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 13h 56m 45s.xml">
<configuration name="OrderSigningTests.testSigningOrders" configurationId="OCUnitRunConfiguration" />
</history-entry>
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 40m 22s.xml">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 14h 16m 02s.xml">
<configuration name="OrderSigningTests.testSigningOrders" configurationId="OCUnitRunConfiguration" />
</history-entry>
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 41m 52s.xml">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 14h 20m 03s.xml">
<configuration name="OrderSigningTests.testSigningOrders" configurationId="OCUnitRunConfiguration" />
</history-entry>
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 44m 32s.xml">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 14h 21m 00s.xml">
<configuration name="OrderSigningTests.testSigningOrders" configurationId="OCUnitRunConfiguration" />
</history-entry>
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 49m 35s.xml">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 14h 21m 31s.xml">
<configuration name="OrderSigningTests.testSigningOrders" configurationId="OCUnitRunConfiguration" />
</history-entry>
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 11h 55m 47s.xml">
<history-entry file="OrderSigningTests_testSigningOrders - 2018.02.15 at 14h 23m 19s.xml">
<configuration name="OrderSigningTests.testSigningOrders" configurationId="OCUnitRunConfiguration" />
</history-entry>
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="78218000" />
<option name="totallyTimeSpent" value="81764000" />
</component>
<component name="ToolWindowManager">
<frame x="1280" y="23" width="2560" height="1349" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32498044" sideWeight="0.23828125" order="13" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32498044" sideWeight="0.26171875" order="13" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.33516052" sideWeight="0.57539064" order="14" side_tool="true" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.22709475" sideWeight="0.5640625" order="14" side_tool="true" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.22709475" sideWeight="0.4359375" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="15" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.22709475" sideWeight="0.42109376" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="16" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.123046875" sideWeight="0.5" order="1" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39937353" sideWeight="0.4453125" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.33516052" sideWeight="0.42460936" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32498044" sideWeight="0.275" order="13" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.22709475" sideWeight="0.5578125" order="14" side_tool="true" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.22709475" sideWeight="0.4421875" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="15" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="16" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.123046875" sideWeight="0.5" order="1" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39937353" sideWeight="0.453125" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="true" content_ui="tabs" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -460,26 +393,31 @@
<breakpoints>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/TrustTests/Market/OrderSigningTests.swift</url>
<line>28</line>
<line>35</line>
<option name="timeStamp" value="14" />
</line-breakpoint>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/Trust/Market/SignOrders.swift</url>
<line>100</line>
<line>97</line>
<option name="timeStamp" value="19" />
</line-breakpoint>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/Trust/Market/SignOrders.swift</url>
<line>111</line>
<line>108</line>
<option name="timeStamp" value="26" />
</line-breakpoint>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/Trust/Market/SignOrders.swift</url>
<line>120</line>
<line>117</line>
<option name="timeStamp" value="29" />
</line-breakpoint>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/Trust/Market/SignOrders.swift</url>
<line>62</line>
<option name="timeStamp" value="32" />
</line-breakpoint>
</breakpoints>
<option name="time" value="32" />
<option name="time" value="35" />
</breakpoint-manager>
<watches-manager />
</component>
@ -786,7 +724,6 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="360">
<caret line="26" column="4" lean-forward="false" selection-start-line="26" selection-start-column="4" selection-end-line="26" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
@ -827,16 +764,16 @@
</entry>
<entry file="file://$PROJECT_DIR$/Trust/EtherClient/EtherKeystore.swift">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="283">
<caret line="310" column="9" lean-forward="false" selection-start-line="310" selection-start-column="9" selection-end-line="310" selection-end-column="9" />
<state relative-caret-position="213">
<caret line="302" column="9" lean-forward="false" selection-start-line="302" selection-start-column="9" selection-end-line="302" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Trust/Market/SignOrders.swift">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="374">
<caret line="100" column="0" lean-forward="false" selection-start-line="100" selection-start-column="0" selection-end-line="100" selection-end-column="0" />
<state relative-caret-position="224">
<caret line="97" column="0" lean-forward="false" selection-start-line="97" selection-start-column="0" selection-end-line="97" selection-end-column="0" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
@ -845,8 +782,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/TrustTests/Market/OrderSigningTests.swift">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="30" column="48" lean-forward="true" selection-start-line="30" selection-start-column="48" selection-end-line="30" selection-end-column="48" />
<state relative-caret-position="435">
<caret line="29" column="75" lean-forward="true" selection-start-line="29" selection-start-column="75" selection-end-line="29" selection-end-column="75" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>

@ -0,0 +1,3 @@
{
"presets": ["env"]
}

File diff suppressed because one or more lines are too long

57468
JS/dist/trust.js vendored

File diff suppressed because it is too large Load Diff

@ -0,0 +1,67 @@
const gulp = require('gulp'),
babelify = require('babelify'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
del = require('del'),
minify = require('gulp-minify'),
runSequence = require('run-sequence'),
size = require('gulp-size'),
source = require('vinyl-source-stream'),
config = {
name: 'trust',
fileTypes: {
all: '**/*',
js: '**/*.js',
main: 'index.js'
},
source: {
baseDir: 'src'
},
staging: {
baseDir: 'staging'
},
distribution: {
baseDir: 'dist',
javascript: 'js'
}
};
gulp.task('clean', function (callback) {
runSequence('clean:dist', 'clean:stage', callback);
});
gulp.task('clean:stage', function () {
let stagingDir = `${config.staging.baseDir}/${config.fileTypes.all}`;
return del.sync(stagingDir);
});
gulp.task('clean:dist', function () {
let distributionDir = `${config.distribution.baseDir}/${config.fileTypes.all}`;
return del.sync(distributionDir);
});
gulp.task('javascript', function () {
let sourceDir = `${config.source.baseDir}/${config.fileTypes.js}`,
stagingDir = `${config.staging.baseDir}`;
return gulp.src(sourceDir)
.pipe(gulp.dest(stagingDir));
});
gulp.task('bundle:javascript', ['javascript', ], function () {
let mainFile = `${config.staging.baseDir}/${config.fileTypes.main}`,
distributionDir = `${config.distribution.baseDir}`;
return browserify(mainFile)
.transform(babelify, { presets: ['env'] })
.bundle()
.pipe(source(config.name + '.js'))
.pipe(buffer())
.pipe(minify())
.pipe(size())
.pipe(gulp.dest(distributionDir));
});
gulp.task('build', function (callback) {
runSequence('clean:dist', 'clean:stage', ['bundle:javascript'],
callback);
});

6801
JS/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,46 @@
{
"name": "trust-wallet",
"version": "0.0.1",
"description": "web3 injection",
"main": "index.js",
"scripts": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/TrustWallet/trust-wallet-ios.git"
},
"keywords": [
"ethereum",
"swift",
"blockchain",
"wallet",
"ethereum-dapps",
"dapps"
],
"author": "Trust <support@trustwalletapp.com>",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/TrustWallet/trust-wallet-ios/issues"
},
"homepage": "https://github.com/TrustWallet/trust-wallet-ios#readme",
"devDependencies": {
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babelify": "^8.0.0",
"browserify": "^15.2.0",
"del": "^3.0.0",
"gulp": "^3.9.1",
"gulp-minify": "^2.1.0",
"gulp-rename": "^1.2.2",
"gulp-size": "^3.0.0",
"run-sequence": "^2.2.1",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0"
},
"dependencies": {
"babel-core": "^6.26.0",
"web3": "^0.20.4",
"web3-provider-engine": "^13.6.0"
}
}

@ -0,0 +1,100 @@
const Web3 = require('web3')
const ProviderEngine = require('web3-provider-engine')
const HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet.js')
const FilterSubprovider = require('web3-provider-engine/subproviders/filters.js')
const Web3Subprovider = require("web3-provider-engine/subproviders/web3.js")
const context = window || global
context.chrome = { webstore: true }
context.Web3 = Web3
let callbacks = {}
let hookedSubProvider
let globalSyncOptions = {}
const Trust = {
init (rpcUrl, options, syncOptions) {
const engine = new ProviderEngine()
const web3 = new Web3(engine)
context.web3 = web3
globalSyncOptions = syncOptions
engine.addProvider(hookedSubProvider = new HookedWalletSubprovider(options))
engine.addProvider(new FilterSubprovider())
engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(rpcUrl)))
engine.on('error', err => console.error(err.stack))
engine.isTrust = true
engine.start()
return engine
},
addCallback (id, cb, isRPC) {
cb.isRPC = isRPC
callbacks[id] = cb
},
executeCallback (id, error, value) {
console.log(`executing callback: \nid: ${id}\nvalue: ${value}\nerror: ${error}\n`)
let callback = callbacks[id]
if (callback.isRPC) {
const response = {'id': id, jsonrpc: '2.0', result: value, error: {message: error} }
if (error) {
callback(response, null)
} else {
callback(null, response)
}
} else {
callback(error, value)
}
delete callbacks[id]
}
}
if (typeof context.Trust === 'undefined') {
context.Trust = Trust
}
ProviderEngine.prototype.send = function (payload) {
const self = this
let result = null
switch (payload.method) {
case 'eth_accounts':
let address = globalSyncOptions.address
result = address ? [address] : [] || null
break
case 'eth_coinbase':
result = globalSyncOptions.address || null
break
case 'eth_uninstallFilter':
self.sendAsync(payload, noop)
result = true
break
case 'net_version':
result = globalSyncOptions.networkVersion || null
break
// throw not-supported Error
default:
var link = 'https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#dizzy-all-async---think-of-metamask-as-a-light-client'
var message = `The MetaMask Web3 object does not support synchronous methods like ${payload.method} without a callback parameter. See ${link} for details.`
throw new Error(message)
}
// return the result
return {
id: payload.id,
jsonrpc: payload.jsonrpc,
result: result,
}
}
module.exports = Trust

@ -284,6 +284,7 @@
732E0F502022716700B39C1F /* LockEnterPasscodeCoordinatorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 732E0F4F2022716700B39C1F /* LockEnterPasscodeCoordinatorTest.swift */; };
732E0F522022754600B39C1F /* FakeLockProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 732E0F512022754600B39C1F /* FakeLockProtocol.swift */; };
732E0F542022786400B39C1F /* LockCreatePasscodeCoordinatorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 732E0F532022786400B39C1F /* LockCreatePasscodeCoordinatorTest.swift */; };
737D1675202BDCB400B42DDE /* UINavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 737D1674202BDCB400B42DDE /* UINavigationController.swift */; };
737EEDDA201BE3A8009D9D5D /* Lock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 737EEDD9201BE3A8009D9D5D /* Lock.swift */; };
739533971FEFF5FD0084AFAB /* Currency.swift in Sources */ = {isa = PBXBuildFile; fileRef = 739533961FEFF5FD0084AFAB /* Currency.swift */; };
73958DC720263525000A40EB /* SplashCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73958DC620263525000A40EB /* SplashCoordinatorTests.swift */; };
@ -303,13 +304,26 @@
76F1D137B10D8309E513BBDD /* OrderSigningTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76F1DE8ADA3176D0277EDF20 /* OrderSigningTests.swift */; };
76F1D912AFEB21137B210FE5 /* SignOrders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76F1DADFD07E2941897FD2E1 /* SignOrders.swift */; };
76F1DA1A819D5543FF698AF1 /* SignOrders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76F1DADFD07E2941897FD2E1 /* SignOrders.swift */; };
73D26837202E827E009777A1 /* DecimalFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73D26836202E827E009777A1 /* DecimalFormatter.swift */; };
73D2683B202E8411009777A1 /* DecimalNumberFormatterTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73D2683A202E8411009777A1 /* DecimalNumberFormatterTest.swift */; };
73ED85A520349BE400593BF3 /* StringFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73ED85A420349BE400593BF3 /* StringFormatter.swift */; };
73ED85A72034BFEF00593BF3 /* UITextFieldAdditions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73ED85A62034BFEF00593BF3 /* UITextFieldAdditions.swift */; };
73ED85A92034C42D00593BF3 /* StringFormatterTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73ED85A82034C42D00593BF3 /* StringFormatterTest.swift */; };
771A8471202F067D00528D28 /* NetworksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A8470202F067D00528D28 /* NetworksViewController.swift */; };
771A847320322F2500528D28 /* PreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A847220322F2500528D28 /* PreferencesViewController.swift */; };
771A847520322FD700528D28 /* PreferencesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A847420322FD700528D28 /* PreferencesViewModel.swift */; };
771A847A2032344D00528D28 /* PreferencesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A84792032344D00528D28 /* PreferencesController.swift */; };
771A847D2032409000528D28 /* PreferenceOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A847C2032409000528D28 /* PreferenceOption.swift */; };
771A8480203240BB00528D28 /* PreferencesControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A847F203240BB00528D28 /* PreferencesControllerTests.swift */; };
771A84822032423800528D28 /* PreferencesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A84812032423800528D28 /* PreferencesController.swift */; };
771A8485203242B400528D28 /* InCoordinatorViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A8484203242B400528D28 /* InCoordinatorViewModelTests.swift */; };
771AA94E1FF971CD00D25403 /* DappAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771AA94D1FF971CD00D25403 /* DappAction.swift */; };
771AA960200D5E8800D25403 /* PassphraseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771AA95F200D5E8800D25403 /* PassphraseView.swift */; };
771AA962200D5EC700D25403 /* PassphraseViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771AA961200D5EC700D25403 /* PassphraseViewModel.swift */; };
771AA964200D5EDB00D25403 /* WordCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771AA963200D5EDB00D25403 /* WordCollectionViewCell.swift */; };
771AA966200D5F1900D25403 /* WordCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 771AA965200D5F1900D25403 /* WordCollectionViewCell.xib */; };
7721A6BE202A5677004DB16C /* DecryptError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7721A6BD202A5677004DB16C /* DecryptError.swift */; };
7721A6C4202D9520004DB16C /* trust-min.js in Resources */ = {isa = PBXBuildFile; fileRef = 7721A6C3202D9520004DB16C /* trust-min.js */; };
7721A6C8202EF81B004DB16C /* CustomRPC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7721A6C7202EF81B004DB16C /* CustomRPC.swift */; };
7721A6CC202EFBC5004DB16C /* AddCustomNetworkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7721A6CB202EFBC5004DB16C /* AddCustomNetworkViewController.swift */; };
7721A6CE202EFC21004DB16C /* AddCustomNetworkViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7721A6CD202EFC21004DB16C /* AddCustomNetworkViewModel.swift */; };
@ -647,6 +661,7 @@
732E0F4F2022716700B39C1F /* LockEnterPasscodeCoordinatorTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockEnterPasscodeCoordinatorTest.swift; sourceTree = "<group>"; };
732E0F512022754600B39C1F /* FakeLockProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FakeLockProtocol.swift; sourceTree = "<group>"; };
732E0F532022786400B39C1F /* LockCreatePasscodeCoordinatorTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockCreatePasscodeCoordinatorTest.swift; sourceTree = "<group>"; };
737D1674202BDCB400B42DDE /* UINavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UINavigationController.swift; sourceTree = "<group>"; };
737EEDD9201BE3A8009D9D5D /* Lock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Lock.swift; sourceTree = "<group>"; };
739533961FEFF5FD0084AFAB /* Currency.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Currency.swift; sourceTree = "<group>"; };
73958DC620263525000A40EB /* SplashCoordinatorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashCoordinatorTests.swift; sourceTree = "<group>"; };
@ -665,7 +680,19 @@
73CBC760202139FB00374666 /* FakeGetBalanceCoordinator(.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FakeGetBalanceCoordinator(.swift"; sourceTree = "<group>"; };
76F1DADFD07E2941897FD2E1 /* SignOrders.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignOrders.swift; sourceTree = "<group>"; };
76F1DE8ADA3176D0277EDF20 /* OrderSigningTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderSigningTests.swift; sourceTree = "<group>"; };
73D26836202E827E009777A1 /* DecimalFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecimalFormatter.swift; sourceTree = "<group>"; };
73D2683A202E8411009777A1 /* DecimalNumberFormatterTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecimalNumberFormatterTest.swift; sourceTree = "<group>"; };
73ED85A420349BE400593BF3 /* StringFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringFormatter.swift; sourceTree = "<group>"; };
73ED85A62034BFEF00593BF3 /* UITextFieldAdditions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITextFieldAdditions.swift; sourceTree = "<group>"; };
73ED85A82034C42D00593BF3 /* StringFormatterTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringFormatterTest.swift; sourceTree = "<group>"; };
771A8470202F067D00528D28 /* NetworksViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworksViewController.swift; sourceTree = "<group>"; };
771A847220322F2500528D28 /* PreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesViewController.swift; sourceTree = "<group>"; };
771A847420322FD700528D28 /* PreferencesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesViewModel.swift; sourceTree = "<group>"; };
771A84792032344D00528D28 /* PreferencesController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesController.swift; sourceTree = "<group>"; };
771A847C2032409000528D28 /* PreferenceOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferenceOption.swift; sourceTree = "<group>"; };
771A847F203240BB00528D28 /* PreferencesControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesControllerTests.swift; sourceTree = "<group>"; };
771A84812032423800528D28 /* PreferencesController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesController.swift; sourceTree = "<group>"; };
771A8484203242B400528D28 /* InCoordinatorViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InCoordinatorViewModelTests.swift; sourceTree = "<group>"; };
771AA94D1FF971CD00D25403 /* DappAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DappAction.swift; sourceTree = "<group>"; };
771AA95F200D5E8800D25403 /* PassphraseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassphraseView.swift; sourceTree = "<group>"; };
771AA961200D5EC700D25403 /* PassphraseViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassphraseViewModel.swift; sourceTree = "<group>"; };
@ -675,6 +702,7 @@
7721A6BF202B1D3E004DB16C /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
7721A6C0202B1D43004DB16C /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; };
7721A6C1202B1D5A004DB16C /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = "<group>"; };
7721A6C3202D9520004DB16C /* trust-min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "trust-min.js"; path = "JS/dist/trust-min.js"; sourceTree = SOURCE_ROOT; };
7721A6C7202EF81B004DB16C /* CustomRPC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRPC.swift; sourceTree = "<group>"; };
7721A6CB202EFBC5004DB16C /* AddCustomNetworkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddCustomNetworkViewController.swift; sourceTree = "<group>"; };
7721A6CD202EFC21004DB16C /* AddCustomNetworkViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddCustomNetworkViewModel.swift; sourceTree = "<group>"; };
@ -746,6 +774,7 @@
290B2B681F92C0300053C83E /* Settings */ = {
isa = PBXGroup;
children = (
771A847E203240AB00528D28 /* Controllers */,
778EAF7B1FF10AE000C8E2AB /* Coordinators */,
290B2B691F92C0440053C83E /* ConfigTests.swift */,
290B2B6B1F92C35B0053C83E /* RPCServerTests.swift */,
@ -1014,6 +1043,7 @@
291F52AA1F6B805400B369AB /* Vendors */ = {
isa = PBXGroup;
children = (
7721A6C2202D94FC004DB16C /* JSWeb3Provider */,
2981C29A1FC18F6000537E43 /* Changelly */,
298542E61FBA9BA900CB5081 /* ShapeShift */,
295996041FAAFC9400DB66A8 /* Coinbase */,
@ -1340,6 +1370,7 @@
29F1C85E200369BA003780D8 /* HelpUsViewModel.swift */,
298542F21FBD594D00CB5081 /* SettingsViewModel.swift */,
7721A6CD202EFC21004DB16C /* AddCustomNetworkViewModel.swift */,
771A847420322FD700528D28 /* PreferencesViewModel.swift */,
);
path = ViewModels;
sourceTree = "<group>";
@ -1358,6 +1389,8 @@
children = (
299573A11FA1F369006F17FD /* QRURLParserTests.swift */,
61FC5ED01FCFBDEB00CCB12A /* EtherNumberFormatterTests.swift */,
73D2683A202E8411009777A1 /* DecimalNumberFormatterTest.swift */,
73ED85A82034C42D00593BF3 /* StringFormatterTest.swift */,
);
path = Foundation;
sourceTree = "<group>";
@ -1365,6 +1398,7 @@
2996F1441F6C9875005C33AE /* Settings */ = {
isa = PBXGroup;
children = (
771A84782032343600528D28 /* Controllers */,
298542F11FBD593900CB5081 /* ViewModels */,
2977CAE41F7E0B69009682A0 /* Coordinators */,
29FC9BC71F83144D000209CD /* ViewControllers */,
@ -1395,6 +1429,8 @@
29F1C85020032688003780D8 /* Address.swift */,
29FA00D3201EC662002F7DC5 /* NSObject.swift */,
7721A6BD202A5677004DB16C /* DecryptError.swift */,
737D1674202BDCB400B42DDE /* UINavigationController.swift */,
73ED85A62034BFEF00593BF3 /* UITextFieldAdditions.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -1478,11 +1514,13 @@
29AD8A0A1F93FBB7008E10E7 /* Foundation */ = {
isa = PBXGroup;
children = (
73D26836202E827E009777A1 /* DecimalFormatter.swift */,
29FC0CB71F8299510036089F /* Coordinator.swift */,
29AD8A0B1F93FBBF008E10E7 /* Subscribable.swift */,
2995739E1FA1F294006F17FD /* QRURLParser.swift */,
298542F81FBE9A0100CB5081 /* CryptoAddressValidator.swift */,
61FC5ECE1FCFBAE500CCB12A /* EtherNumberFormatter.swift */,
73ED85A420349BE400593BF3 /* StringFormatter.swift */,
);
path = Foundation;
sourceTree = "<group>";
@ -1712,6 +1750,7 @@
29F1C85C2003698A003780D8 /* WellDoneViewController.swift */,
7721A6CB202EFBC5004DB16C /* AddCustomNetworkViewController.swift */,
771A8470202F067D00528D28 /* NetworksViewController.swift */,
771A847220322F2500528D28 /* PreferencesViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
@ -1733,6 +1772,7 @@
294EC1D71FD7FBAB0065EB20 /* BiometryAuthenticationType.swift */,
739533961FEFF5FD0084AFAB /* Currency.swift */,
7721A6C7202EF81B004DB16C /* CustomRPC.swift */,
771A847C2032409000528D28 /* PreferenceOption.swift */,
);
path = Types;
sourceTree = "<group>";
@ -1780,6 +1820,7 @@
29F1C864200384FE003780D8 /* Wallet.swift */,
732E0F512022754600B39C1F /* FakeLockProtocol.swift */,
73CBC760202139FB00374666 /* FakeGetBalanceCoordinator(.swift */,
771A84812032423800528D28 /* PreferencesController.swift */,
);
path = Factories;
sourceTree = "<group>";
@ -1906,6 +1947,30 @@
path = Market;
sourceTree = "<group>";
};
771A84782032343600528D28 /* Controllers */ = {
isa = PBXGroup;
children = (
771A84792032344D00528D28 /* PreferencesController.swift */,
);
path = Controllers;
sourceTree = "<group>";
};
771A847E203240AB00528D28 /* Controllers */ = {
isa = PBXGroup;
children = (
771A847F203240BB00528D28 /* PreferencesControllerTests.swift */,
);
path = Controllers;
sourceTree = "<group>";
};
771A8483203242A600528D28 /* ViewModels */ = {
isa = PBXGroup;
children = (
771A8484203242B400528D28 /* InCoordinatorViewModelTests.swift */,
);
path = ViewModels;
sourceTree = "<group>";
};
771AA94C1FF971BB00D25403 /* Types */ = {
isa = PBXGroup;
children = (
@ -1930,6 +1995,14 @@
path = Views;
sourceTree = "<group>";
};
7721A6C2202D94FC004DB16C /* JSWeb3Provider */ = {
isa = PBXGroup;
children = (
7721A6C3202D9520004DB16C /* trust-min.js */,
);
path = JSWeb3Provider;
sourceTree = "<group>";
};
77872D2A202514930032D687 /* Wallet */ = {
isa = PBXGroup;
children = (
@ -2011,6 +2084,7 @@
CCA4FE301FD3652100749AE4 /* Core */ = {
isa = PBXGroup;
children = (
771A8483203242A600528D28 /* ViewModels */,
29F1C85420036879003780D8 /* Types */,
CCA4FE311FD3653300749AE4 /* Coordinators */,
);
@ -2193,6 +2267,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7721A6C4202D9520004DB16C /* trust-min.js in Resources */,
613D04891FDE15F8008DE72E /* COMODO ECC Domain Validation Secure Server CA 2.cer in Resources */,
29FA00D2201CA79F002F7DC5 /* web3.min.js in Resources */,
771AA966200D5F1900D25403 /* WordCollectionViewCell.xib in Resources */,
@ -2535,6 +2610,7 @@
77B3BF352017D0D000EEC15A /* MarketplaceViewModel.swift in Sources */,
29F114F01FA6D53700114A29 /* ImportSelectionType.swift in Sources */,
29850D251F6B27A800791A49 /* R.generated.swift in Sources */,
737D1675202BDCB400B42DDE /* UINavigationController.swift in Sources */,
296105931FA2AA2100292494 /* SignTransaction.swift in Sources */,
296105951FA2DEF000292494 /* TransactionDirection.swift in Sources */,
291ED08B1F6F5D2100E7E93A /* Bundle.swift in Sources */,
@ -2549,6 +2625,7 @@
293248861F88CCE6008A9818 /* SplashError.swift in Sources */,
296421951F70C1EC00EB363B /* LoadingView.swift in Sources */,
2961BD071FB146EB00C4B840 /* ChainState.swift in Sources */,
73D26837202E827E009777A1 /* DecimalFormatter.swift in Sources */,
29285B421F6FB3E60044CF29 /* SendViewController.swift in Sources */,
2996F14D1F6CA743005C33AE /* UIViewController.swift in Sources */,
2959961F1FAE759700DB66A8 /* RawTransaction.swift in Sources */,
@ -2635,6 +2712,7 @@
77872D292025116E0032D687 /* EnterPasswordCoordinator.swift in Sources */,
298542FB1FBEA03300CB5081 /* SendInputErrors.swift in Sources */,
29EB102A1F6CBD23000907A4 /* UIAlertController.swift in Sources */,
771A847520322FD700528D28 /* PreferencesViewModel.swift in Sources */,
296AF9A51F736BA20058AF78 /* Config.swift in Sources */,
615F10621FCD3F0F008A45AF /* OnboardingPageStyle.swift in Sources */,
2912CD341F6A849C00C6CBE3 /* WelcomeViewModel.swift in Sources */,
@ -2655,6 +2733,7 @@
615F105D1FCBF55E008A45AF /* OnboardingCollectionViewController.swift in Sources */,
29A0E1851F706B8C00BAAAED /* String.swift in Sources */,
296AF9A71F736EC70058AF78 /* RPCServers.swift in Sources */,
771A847A2032344D00528D28 /* PreferencesController.swift in Sources */,
296AF9A91F737F6F0058AF78 /* SendRawTransactionRequest.swift in Sources */,
293112121FC4F48400966EEA /* ServiceProvider.swift in Sources */,
73C5CF45201A7CAB00C74316 /* LockPasscodeViewController.swift in Sources */,
@ -2665,6 +2744,7 @@
29850D2B1F6B30FF00791A49 /* TransactionViewController.swift in Sources */,
296AF9AB1F7380920058AF78 /* GetTransactionCountRequest.swift in Sources */,
294DFB9E1FE0CA59004CEB56 /* TransactionsViewModel.swift in Sources */,
73ED85A72034BFEF00593BF3 /* UITextFieldAdditions.swift in Sources */,
2923D9B51FDA4E07000CF3F8 /* PasswordGenerator.swift in Sources */,
298542F51FBD8E6A00CB5081 /* ConfigExplorer.swift in Sources */,
29A13E2C1F6A955700E432A2 /* CreateWalletViewModel.swift in Sources */,
@ -2681,6 +2761,7 @@
29F1C84C1FEC4F6F003780D8 /* TokensFooterView.swift in Sources */,
29F114F41FA8117C00114A29 /* SendCoordinator.swift in Sources */,
293B8B411F707F4600356286 /* TransactionViewModel.swift in Sources */,
771A847D2032409000528D28 /* PreferenceOption.swift in Sources */,
77B3BF4A2019247200EEC15A /* BrowserNavigationBar.swift in Sources */,
29BB94951F6FC54C009B09CC /* EthereumUnit.swift in Sources */,
29C70C712016C7780072E454 /* SentTransaction.swift in Sources */,
@ -2693,6 +2774,7 @@
664D11A12007D59F0041A0B0 /* EstimateGasRequest.swift in Sources */,
293248841F88CCD2008A9818 /* SplashState.swift in Sources */,
299B5E2B1FCA9A640051361C /* ApproveERC20.swift in Sources */,
771A847320322F2500528D28 /* PreferencesViewController.swift in Sources */,
291794FB1F95DC2200539A30 /* Web3Swift.swift in Sources */,
29DBF2A31F9DBFF400327C60 /* BackupCoordinator.swift in Sources */,
290B2B611F9179880053C83E /* AccountViewModel.swift in Sources */,
@ -2700,6 +2782,7 @@
2932045E1F8EEE760095B7C1 /* BalanceCoordinator.swift in Sources */,
2912CD321F6A83EE00C6CBE3 /* WelcomeViewController.swift in Sources */,
29F114F61FA8147300114A29 /* RequestCoordinator.swift in Sources */,
73ED85A520349BE400593BF3 /* StringFormatter.swift in Sources */,
293112101FC4ADCB00966EEA /* InCoordinatorViewModel.swift in Sources */,
293112351FC9A0D500966EEA /* CallRequest.swift in Sources */,
291F52A91F6B7BE100B369AB /* BlockNumber.swift in Sources */,
@ -2730,6 +2813,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
771A8480203240BB00528D28 /* PreferencesControllerTests.swift in Sources */,
29F1C85620036887003780D8 /* AppTrackerTests.swift in Sources */,
29BDF19F1FEE51650023A45F /* GasLimitConfigurationTests.swift in Sources */,
290B2B6C1F92C35B0053C83E /* RPCServerTests.swift in Sources */,
@ -2739,6 +2823,7 @@
29FF13081F75F0AE00AFD326 /* AppCoordinatorTests.swift in Sources */,
2923D9B71FDA5E51000CF3F8 /* PasswordGeneratorTests.swift in Sources */,
29F1C865200384FE003780D8 /* Wallet.swift in Sources */,
73D2683B202E8411009777A1 /* DecimalNumberFormatterTest.swift in Sources */,
2912CD101F6A830700C6CBE3 /* TrustTests.swift in Sources */,
29FF130D1F7626E800AFD326 /* FakeNavigationController.swift in Sources */,
61DCE17D2001A7A20053939F /* RLPTests.swift in Sources */,
@ -2766,6 +2851,7 @@
2961BD091FB14B6D00C4B840 /* Config.swift in Sources */,
290B2B6E1F92C3980053C83E /* UserDefaults.swift in Sources */,
77872D2D202514AD0032D687 /* EnterPasswordCoordinatorTests.swift in Sources */,
771A8485203242B400528D28 /* InCoordinatorViewModelTests.swift in Sources */,
73CBC761202139FB00374666 /* FakeGetBalanceCoordinator(.swift in Sources */,
295996031FAA865800DB66A8 /* TokensCoordinatorTests.swift in Sources */,
29336FE71F6B245D005E3BFC /* WelcomeViewModelTests.swift in Sources */,
@ -2776,8 +2862,10 @@
29E14FD51F7F470C00185568 /* TransactionsStorageTests.swift in Sources */,
61C359E22002AC9D0097B04D /* TransactionSigningTests.swift in Sources */,
299B5E381FCBCDF70051361C /* RequestViewModelTests.swift in Sources */,
771A84822032423800528D28 /* PreferencesController.swift in Sources */,
293E62731FA3165C00CB0A66 /* InitialWalletCreationCoordinatorTests.swift in Sources */,
29FF130A1F75F67200AFD326 /* Address.swift in Sources */,
73ED85A92034C42D00593BF3 /* StringFormatterTest.swift in Sources */,
29BDF19D1FEE50E90023A45F /* GasPriceConfigurationTests.swift in Sources */,
295996141FAB09A200DB66A8 /* DepositCoordinatorTests.swift in Sources */,
778EAF7D1FF10AF400C8E2AB /* SettingsCoordinatorTests.swift in Sources */,
@ -2959,7 +3047,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 152;
CURRENT_PROJECT_VERSION = 157;
DEVELOPMENT_TEAM = 9873B38DWV;
ENABLE_BITCODE = YES;
INFOPLIST_FILE = Trust/Info.plist;
@ -2983,7 +3071,7 @@
CODE_SIGN_ENTITLEMENTS = Trust/Trust.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 152;
CURRENT_PROJECT_VERSION = 157;
DEVELOPMENT_TEAM = 9873B38DWV;
ENABLE_BITCODE = YES;
INFOPLIST_FILE = Trust/Info.plist;

@ -17,7 +17,7 @@ struct AccountViewModel {
return wallet.type == .watch(wallet.address)
}
var balance: String {
return walletBalance?.amountFull ?? "0"
return walletBalance?.amountFull ?? "--"
}
var title: String {
return wallet.address.description

@ -87,9 +87,9 @@ class AccountsViewController: UITableViewController {
}
func confirmDelete(account: Wallet) {
confirm(
title: "Are you sure you would like to delete this wallet?",
message: "Make sure you have backup of your wallet",
okTitle: "Delete",
title: NSLocalizedString("accounts.confirm.delete.title", value: "Are you sure you would like to delete this wallet?", comment: ""),
message: NSLocalizedString("accounts.confirm.delete.message", value: "Make sure you have backup of your wallet.", comment: ""),
okTitle: NSLocalizedString("accounts.confirm.delete.okTitle", value: "Delete", comment: ""),
okStyle: .destructive
) { result in
switch result {
@ -115,10 +115,12 @@ class AccountsViewController: UITableViewController {
}
private func refreshWalletBalances() {
let addresses = wallets.flatMap { $0.address }
for (index, address) in addresses.enumerated() {
var counter = 0
for address in addresses {
balanceCoordinator.getEthBalance(for: address, completion: { [weak self] (result) in
self?.balances[address] = result.value
if index == addresses.count - 1 {
counter += 1
if counter == addresses.count {
self?.tableView.reloadData()
}
})

@ -20,7 +20,7 @@ class AccountViewCell: UITableViewCell {
guard let model = viewModel else {
return
}
balanceLable.text = String(format: NSLocalizedString("settings.wallets.balance", value: "Balance: %@ ETH", comment: ""), model.balance)
balanceLable.text = "\(model.balance) ETH"
glassesImageView.isHidden = !model.isWatch
activeView.isHidden = !model.isActive
addressLable.text = model.title

@ -19,20 +19,20 @@
<rect key="frame" x="0.0" y="0.0" width="346" height="59.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="JUd-EF-Sra">
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="JUd-EF-Sra">
<rect key="frame" x="36" y="0.0" width="298" height="59.5"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" alignment="top" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="2t2-qW-Lcu">
<rect key="frame" x="0.0" y="11.5" width="247" height="36.5"/>
<rect key="frame" x="0.0" y="11.5" width="239" height="36.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Balance: 214.34 ETH" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="scJ-RY-qk3">
<rect key="frame" x="0.0" y="0.0" width="142.5" height="18"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="-- ETH" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="scJ-RY-qk3">
<rect key="frame" x="0.0" y="0.0" width="47" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0xdDFFF2b78463AB1cA781e853BB888FDfd06083d3" textAlignment="natural" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZWW-wY-XEU">
<rect key="frame" x="0.0" y="23" width="247" height="13.5"/>
<rect key="frame" x="0.0" y="23" width="239" height="13.5"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -40,17 +40,18 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="wMR-ps-QHM">
<rect key="frame" x="252" y="19" width="46" height="22"/>
<rect key="frame" x="249" y="19" width="49" height="22"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="glasses" translatesAutoresizingMaskIntoConstraints="NO" id="mbU-gV-kxo">
<rect key="frame" x="0.0" y="3.5" width="15" height="15"/>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="glasses" translatesAutoresizingMaskIntoConstraints="NO" id="mbU-gV-kxo">
<rect key="frame" x="0.0" y="2" width="18" height="18"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" priority="999" constant="15" id="JBT-UD-abn"/>
<constraint firstAttribute="height" priority="999" constant="15" id="UFk-ew-jRu"/>
<constraint firstAttribute="width" priority="999" constant="18" id="JBT-UD-abn"/>
<constraint firstAttribute="height" priority="999" constant="18" id="UFk-ew-jRu"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" horizontalCompressionResistancePriority="749" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="infoLight" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Io-0E-DkX">
<rect key="frame" x="25" y="0.0" width="21" height="22"/>
<rect key="frame" x="28" y="0.0" width="21" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="luV-hy-3Li"/>
<constraint firstAttribute="width" constant="21" id="seg-be-uoW"/>
@ -107,6 +108,6 @@
</tableViewCell>
</objects>
<resources>
<image name="glasses" width="33" height="33"/>
<image name="glasses" width="42" height="42"/>
</resources>
</document>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "settings_preferences.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

@ -10,150 +10,69 @@ extension WKWebViewConfiguration {
let address = session.account.address.description.lowercased()
let config = WKWebViewConfiguration()
var js = ""
if let filepath = Bundle.main.path(forResource: "web3.min", ofType: "js") {
if let filepath = Bundle.main.path(forResource: "trust-min", ofType: "js") {
do {
js += try String(contentsOfFile: filepath)
NSLog("Loaded web3.js")
NSLog("Loaded Trust in page provider")
} catch {
NSLog("Failed to load web.js")
NSLog("Failed to load Trust in page provider")
}
} else {
NSLog("web3.js not found in bundle")
NSLog("Trust in page provider not found in bundle")
}
js +=
"""
let callbacks = {};
function addCallback(id, cb, isRPC = true) {
callbacks[id] = {cb, isRPC}
}
function executeCallback(id, error, value) {
console.log("executeCallback")
console.log("id", id)
console.log("value", value)
console.log("error", error)
console.log("error", error)
let callback = callbacks[id].cb
if (callbacks[id].isRPC) {
if (error) {
let response = {"id": id, jsonrpc: "2.0", result: null, error: {message: error}}
callback(response, null)
} else {
let response = {"id": id, jsonrpc: "2.0", result: value}
callback(null, response)
}
} else {
callback(error, value)
}
delete callbacks[id]
}
const addressHex = "\(address)"
const rpcURL = "\(session.config.rpcURL.absoluteString)"
const chainID = "\(session.config.chainID)"
function sendTransaction(request, cb) {
let tx = request.params[0]
console.log("here." + tx)
let id = request.id || 8888
addCallback(id, cb)
webkit.messageHandlers.sendTransaction.postMessage({"name": "sendTransaction", "object": tx, id: id})
function executeCallback (id, error, value) {
Trust.executeCallback(id, error, value)
}
function signTransaction(tx, cb) {
console.log("here2.", tx)
let id = request.id || 8888
addCallback(id, cb)
Trust.init(rpcURL, {
getAccounts: function (cb) { cb(null, [addressHex]) },
signTransaction: function (tx, cb){
console.log('signing a transaction', tx)
const { id = 8888 } = tx
Trust.addCallback(id, cb)
webkit.messageHandlers.signTransaction.postMessage({"name": "signTransaction", "object": tx, id: id})
},
signMessage: function (msgParams, cb) {
const { data } = msgParams
const { id = 8888 } = msgParams
console.log("signing a message", msgParams)
Trust.addCallback(id, cb)
webkit.messageHandlers.signMessage.postMessage({"name": "signMessage", "object": { data }, id: id})
},
signPersonalMessage: function (msgParams, cb) {
const { data } = msgParams
const { id = 8888 } = msgParams
console.log("signing a personal message", msgParams)
Trust.addCallback(id, cb)
webkit.messageHandlers.signPersonalMessage.postMessage({"name": "signPersonalMessage", "object": { data }, id: id})
}
}, {
address: addressHex,
networkVersion: chainID
})
web3.setProvider = function () {
console.debug('Trust Wallet - overrode web3.setProvider')
}
function signPersonalMessage(request, cb) {
let message = {data: request.params[0]}
let id = request.id || 8888
console.log("here.5", cb)
addCallback(id, cb)
webkit.messageHandlers.signPersonalMessage.postMessage({"name": "signPersonalMessage", "object": message, id: id})
}
var web3 = new Web3();
let trustProvider = new Web3.providers.HttpProvider("\(session.config.rpcURL.absoluteString)")
trustProvider.isTrust = true
web3.setProvider(trustProvider);
window.web3 = web3
web3.currentProvider.isTrust = true
window.chrome = { webstore: true }
web3.eth.defaultAccount = addressHex
web3.eth.defaultAccount = "\(address)"
web3.version.getNetwork = function(cb) {
cb(null, "\(session.config.chainID)")
cb(null, chainID)
}
web3.eth.getCoinbase = function(cb) {
return cb(null, "\(address)")
}
web3.eth.sendTransaction = function(transaction, cb) {
console.log("transaction", transaction)
let id = 99999
addCallback(id, cb, false)
webkit.messageHandlers.sendTransaction.postMessage({"name": "sendTransaction", "object": transaction, id: id})
}
function response(request, result) {
return {"id": request.id, "jsonrpc": request.jsonrpc, "result": result}
}
trustProvider.sendAsync = function(request, cb) {
console.log("sendAsync ", request);
switch (request.method) {
case "net_listening":
cb(null, response(request, true))
break;
case "net_version":
cb(null, response(request, "\(session.config.chainID)"))
break;
case "eth_accounts":
cb(null, response(request, ["\(address)"]))
break;
case "eth_sendTransaction":
sendTransaction(request, cb)
break
case "eth_coinbase":
cb(null, response(request, "\(address)"))
break
case "eth_sign":
signPersonalMessage(request, cb)
break
case "personal_sign":
signPersonalMessage(request, cb)
break
default:
console.log("sendAsync return", request);
Web3.providers.HttpProvider.prototype.sendAsync.apply(trustProvider, [request, cb])
break
}
}
trustProvider.send = function(request) {
console.log("send", request);
switch (request.method) {
case "net_listening":
return true
case "net_version":
return response(request, "\(session.config.chainID)")
case "eth_accounts":
return response(request, ["\(address)"])
case "eth_coinbase":
return response(request, "\(address)")
default:
console.log("send return", request.method);
return Web3.providers.HttpProvider.prototype.send.apply(trustProvider, [request])
}
return cb(null, addressHex)
}
"""
let userScript = WKUserScript(source: js, injectionTime: .atDocumentStart, forMainFrameOnly: false)
config.userContentController.add(messageHandler, name: Method.sendTransaction.rawValue)
config.userContentController.add(messageHandler, name: Method.signTransaction.rawValue)
config.userContentController.add(messageHandler, name: Method.signPersonalMessage.rawValue)
config.userContentController.add(messageHandler, name: Method.signMessage.rawValue)

@ -27,6 +27,6 @@ class BrowserURLParser {
}
func searchURL(for query: String) -> URL? {
return URL(string: searchURL + query)!
return URL(string: searchURL + query)
}
}

@ -5,14 +5,20 @@ import Foundation
struct InCoordinatorViewModel {
let config: Config
let preferences: PreferencesController
init(config: Config) {
init(
config: Config,
preferences: PreferencesController = PreferencesController()
) {
self.config = config
self.preferences = preferences
}
var tokensAvailable: Bool {
switch config.server {
case .main, .classic, .kovan, .ropsten, .rinkeby, .poa, .sokol, .custom: return true
case .callisto: return false
}
}
@ -20,7 +26,10 @@ struct InCoordinatorViewModel {
return config.server.isTestNetwork
}
var isDAppsBrowserAvailable: Bool {
return config.isDAppsBrowserAvailable
var initialTab: Tabs {
guard preferences.get(for: .showTokensOnLaunch) else {
return .transactions
}
return .tokens
}
}

@ -13,7 +13,7 @@ import Foundation
public struct Order {
var price: BigInt?;
var ticketIndices: [Int]?;
var expiryTimeStamp: BigInt?;
var expiryBuffer: BigInt?;
var contractAddress: String?;
}

@ -3,13 +3,16 @@
import Foundation
import TrustKeystore
enum AddressError: LocalizedError {
enum Errors: LocalizedError {
case invalidAddress
case invalidAmount
var errorDescription: String? {
switch self {
case .invalidAddress:
return NSLocalizedString("send.error.invalidAddress", value: "Invalid Address", comment: "")
case .invalidAmount:
return NSLocalizedString("send.error.invalidAmount", value: "Invalid Amount", comment: "")
}
}
}

@ -0,0 +1,11 @@
// Copyright SIX DAY LLC. All rights reserved.
import UIKit
extension UINavigationController {
//Remove after iOS 11.2 will patch this bug.
func applyTintAdjustment() {
navigationBar.tintAdjustmentMode = .normal
navigationBar.tintAdjustmentMode = .automatic
}
}

@ -0,0 +1,33 @@
// Copyright SIX DAY LLC. All rights reserved.
import UIKit
var key: Void?
class UITextFieldAdditions: NSObject {
var isCopyPasteDisabled: Bool = false
}
extension UITextField {
var isCopyPasteDisabled: Bool {
get {
return self.getAdditions().isCopyPasteDisabled
} set {
self.getAdditions().isCopyPasteDisabled = newValue
}
}
private func getAdditions() -> UITextFieldAdditions {
var additions = objc_getAssociatedObject(self, &key) as? UITextFieldAdditions
if additions == nil {
additions = UITextFieldAdditions()
objc_setAssociatedObject(self, &key, additions!, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
}
return additions!
}
open override func target(forAction action: Selector, withSender sender: Any?) -> Any? {
if ((action == #selector(UIResponderStandardEditActions.paste(_:)) || (action == #selector(UIResponderStandardEditActions.cut(_:)))) && self.isCopyPasteDisabled) {
return nil
}
return super.target(forAction: action, withSender: sender)
}
}

@ -0,0 +1,64 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
final class DecimalFormatter {
/// Locale of a `DecimalFormatter`.
var locale: Locale
/// numberFormatter of a `DecimalFormatter` to represent curent locale.
private lazy var numberFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.locale = self.locale
formatter.numberStyle = .decimal
formatter.isLenient = true
return formatter
}()
/// usFormatter of a `DecimalFormatter` to represent decimal separator ".".
private lazy var usFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.locale = Locale(identifier: "en_US")
formatter.numberStyle = .decimal
formatter.isLenient = true
return formatter
}()
/// frFormatter of a `DecimalFormatter` to represent decimal separator ",".
private lazy var frFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.locale = Locale(identifier: "fr_FR")
formatter.numberStyle = .decimal
formatter.isLenient = true
return formatter
}()
/// enCaFormatter of a `DecimalFormatter` to represent decimal separator "'".
private lazy var enCaFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.locale = Locale(identifier: "en_CA")
formatter.numberStyle = .decimal
formatter.isLenient = true
return formatter
}()
/// Initializes a `DecimalFormatter` with a `Locale`.
init(locale: Locale = .current) {
self.locale = locale
self.numberFormatter = NumberFormatter()
self.numberFormatter.locale = self.locale
self.numberFormatter.numberStyle = .decimal
self.numberFormatter.isLenient = true
}
/// Converts a String to a `NSumber`.
///
/// - Parameters:
/// - string: string to convert.
/// - Returns: `NSumber` represenation.
func number(from string: String) -> NSNumber? {
return self.numberFormatter.number(from: string) ?? self.usFormatter.number(from: string) ?? self.frFormatter.number(from: string) ?? self.enCaFormatter.number(from: string)
}
/// Converts a NSumber to a `String`.
///
/// - Parameters:
/// - number: nsnumber to convert.
/// - Returns: `NSumber` represenation.
func string(from number: NSNumber) -> String? {
return self.numberFormatter.string(from: number)
}
}

@ -0,0 +1,44 @@
// Copyright SIX DAY LLC. All rights reserved.
import UIKit
final class StringFormatter {
/// currencyFormatter of a `StringFormatter` to represent curent locale.
private lazy var currencyFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.currencySymbol = ""
formatter.minimumFractionDigits = 2
formatter.maximumFractionDigits = 2
formatter.numberStyle = .currencyAccounting
formatter.isLenient = true
return formatter
}()
/// Converts a Double to a `currency String`.
///
/// - Parameters:
/// - double: double to convert.
/// - currencyCode: code of the currency.
/// - Returns: Currency `String` represenation.
func currency(with value: Double, and currencyCode: String) -> String {
let formatter = currencyFormatter
formatter.currencyCode = currencyCode
return formatter.string(from: NSNumber(value: value)) ?? "\(value)"
}
/// Converts a Double to a `String`.
///
/// - Parameters:
/// - double: double to convert.
/// - precision: symbols after coma.
/// - Returns: `String` represenation.
func formatter(for double: Double, with precision: Int) -> String {
return String(format: "%.\(precision)f", double)
}
/// Converts a Double to a `String`.
///
/// - Parameters:
/// - double: double to convert.
/// - Returns: `String` represenation.
func formatter(for double: Double) -> String {
return String(format: "%f", double)
}
}

@ -45,6 +45,7 @@ class InCoordinator: Coordinator {
var tabBarController: UITabBarController? {
return self.navigationController.viewControllers.first as? UITabBarController
}
lazy var helpUsCoordinator: HelpUsCoordinator = {
return HelpUsCoordinator(
navigationController: navigationController,
@ -118,18 +119,18 @@ class InCoordinator: Coordinator {
self?.activateDebug()
}
}
if inCoordinatorViewModel.isDAppsBrowserAvailable {
let coordinator = BrowserCoordinator(session: session, keystore: keystore)
coordinator.delegate = self
coordinator.start()
coordinator.rootViewController.tabBarItem = UITabBarItem(
title: NSLocalizedString("browser.tabbar.item.title", value: "Browser", comment: ""),
image: R.image.dapps_icon(),
selectedImage: nil
)
addCoordinator(coordinator)
tabBarController.viewControllers?.insert(coordinator.navigationController, at: 0)
}
let coordinator = BrowserCoordinator(session: session, keystore: keystore)
coordinator.delegate = self
coordinator.start()
coordinator.rootViewController.tabBarItem = UITabBarItem(
title: NSLocalizedString("browser.tabbar.item.title", value: "Browser", comment: ""),
image: R.image.dapps_icon(),
selectedImage: nil
)
addCoordinator(coordinator)
tabBarController.viewControllers?.insert(coordinator.navigationController, at: 0)
if inCoordinatorViewModel.tokensAvailable {
let tokenCoordinator = TokensCoordinator(
session: session,
@ -167,10 +168,10 @@ class InCoordinator: Coordinator {
keystore.recentlyUsedWallet = account
showTab(.transactions)
showTab(inCoordinatorViewModel.initialTab)
}
private func showTab(_ selectTab: Tabs) {
func showTab(_ selectTab: Tabs) {
guard let viewControllers = tabBarController?.viewControllers else { return }
for controller in viewControllers {
if let nav = controller as? UINavigationController {

@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1.140</string>
<string>1.1.145</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
@ -28,7 +28,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>152</string>
<string>157</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>

@ -4,6 +4,6 @@ import UIKit
class LockCreatePasscodeViewModel: LockViewModel {
let title = NSLocalizedString("lock.create.passcode.view.model.title", value: "Set Passcode", comment: "")
let initialLabelText = NSLocalizedString("lock.create.passcode.view.model.initial", value: "Enter a new password", comment: "")
let initialLabelText = NSLocalizedString("lock.create.passcode.view.model.initial", value: "Enter a new passcode", comment: "")
let confirmLabelText = NSLocalizedString("lock.create.passcode.view.model.confirm", value: "Please re-enter your passcode", comment: "")
}

@ -3,9 +3,9 @@ import TrustKeystore
import Trust
public struct Order {
var price: BigInt
var price: [UInt8]
var ticketIndices: [UInt16]
var expiryTimeStamp: BigInt
var expiryBuffer: [UInt8]
var contractAddress: String
}
@ -39,13 +39,12 @@ public class SignOrders {
//takes a list of orders and returns a list of signature objects
func signOrders(orders : Array<Order>, account : Account) -> Array<SignedOrder> {
var signedOrders : Array<SignedOrder> = Array<SignedOrder>()
//EtherKeystore.signMessage(encodeMessage(), )
for i in 0...orders.count - 1 {
//sign each order
//TODO check casting to string
let message : [UInt8] = encodeMessageForTrade(price: orders[i].price,
expiryTimestamp: orders[i].expiryTimeStamp, tickets: orders[i].ticketIndices,
expiryBuffer: orders[i].expiryBuffer, tickets: orders[i].ticketIndices,
contractAddress : orders[i].contractAddress)
let messageData = Data(bytes: message)
@ -57,33 +56,31 @@ public class SignOrders {
return signedOrders
}
//TODO fix this encoding as it doesn't match solidity ecrecover
//price is casted wrong
func encodeMessageForTrade(price : BigInt, expiryTimestamp : BigInt,
func encodeMessageForTrade(price : [UInt8], expiryBuffer : [UInt8],
tickets : [UInt16], contractAddress : String) -> [UInt8]
{
//ticket count * 2 because it is 16 bits not 8
let arrayLength: Int = 84 + tickets.count * 2
var buffer = [UInt8]()
buffer.reserveCapacity(arrayLength)
//TODO represent as Uint16 and cast back into uint8
var priceInWei = [UInt8] (price.description.utf8)
for i in 0...31 - priceInWei.count {
var priceInWei : [UInt8] = price
var expiry : [UInt8] = expiryBuffer
for _ in 0...31 - price.count {
//pad with zeros
priceInWei.insert(0, at: 0)
}
for i in 0...31 {
buffer.append(0)//priceInWei[i])
buffer.append(priceInWei[i])
}
var expiryBuffer = [UInt8] (expiryTimestamp.description.utf8)
for i in 0...31 - expiryBuffer.count {
expiryBuffer.insert(0, at: 0)
expiry.insert(0, at: 0)
}
for i in 0...31 {
buffer.append(0)//expiryBuffer[i])
buffer.append(expiry[i])
}
//no leading zeros issue here
var contractAddr = contractAddress.hexa2Bytes
@ -121,4 +118,5 @@ public class SignOrders {
return bufferString
}
}

@ -0,0 +1,22 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
class PreferencesController {
let userDefaults: UserDefaults
init(
userDefaults: UserDefaults = .standard
) {
self.userDefaults = userDefaults
}
func set(value: Bool, for option: PreferenceOption) {
userDefaults.set(value, forKey: option.key)
}
func get(for option: PreferenceOption) -> Bool {
return userDefaults.bool(forKey: option.key)
}
}

@ -58,11 +58,6 @@ struct Config {
set { defaults.set(newValue, forKey: Keys.isDebugEnabled) }
}
var isDAppsBrowserAvailable: Bool {
get { return defaults.bool(forKey: Keys.dAppBrowser) }
set { defaults.set(newValue, forKey: Keys.dAppBrowser) }
}
var server: RPCServer {
return RPCServer(chainID: chainID)
}
@ -72,6 +67,7 @@ struct Config {
switch server {
case .main: return "https://mainnet.infura.io/llyrtzQ3YhkdESt2Fzrk"
case .classic: return "https://mewapi.epool.io/"
case .callisto: return "https://callisto.network/" //TODO Add endpoint
case .kovan: return "https://kovan.infura.io/llyrtzQ3YhkdESt2Fzrk"
case .ropsten: return "https://ropsten.infura.io/llyrtzQ3YhkdESt2Fzrk"
case .rinkeby: return "https://rinkeby.infura.io/llyrtzQ3YhkdESt2Fzrk"
@ -89,6 +85,7 @@ struct Config {
switch server {
case .main: return "https://api.trustwalletapp.com"
case .classic: return "https://classic.trustwalletapp.com"
case .callisto: return "https://callisto.trustwalletapp.com"
case .kovan: return "https://kovan.trustwalletapp.com"
case .ropsten: return "https://ropsten.trustwalletapp.com"
case .rinkeby: return "https://rinkeby.trustwalletapp.com"

@ -12,9 +12,9 @@ struct ConfigExplorer {
self.server = server
}
func transactionURL(for ID: String) -> URL {
let endpoint = explorer(for: server)
let urlString: String = {
func transactionURL(for ID: String) -> URL? {
guard let endpoint = explorer(for: server) else { return .none }
let urlString: String? = {
switch server {
case .main:
return endpoint + "/tx/" + ID
@ -30,14 +30,15 @@ struct ConfigExplorer {
return endpoint + "/txid/search/" + ID
case .sokol:
return endpoint + "/tx/" + ID
case .custom:
return endpoint
case .custom, .callisto:
return .none
}
}()
return URL(string: urlString)!
guard let string = urlString else { return .none}
return URL(string: string)!
}
private func explorer(for server: RPCServer) -> String {
private func explorer(for server: RPCServer) -> String? {
switch server {
case .main:
return "https://etherscan.io"
@ -53,8 +54,8 @@ struct ConfigExplorer {
return "https://poaexplorer.com"
case .sokol:
return "https://sokol-explorer.poa.network"
case .custom:
return ""
case .custom, .callisto:
return .none
}
}
}

@ -0,0 +1,13 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
enum PreferenceOption {
case showTokensOnLaunch
var key: String {
switch self {
case .showTokensOnLaunch: return "showTokensOnLaunch"
}
}
}

@ -10,6 +10,7 @@ enum RPCServer {
case poa
case sokol
case classic
case callisto
case custom(CustomRPC)
var chainID: Int {
@ -21,6 +22,7 @@ enum RPCServer {
case .poa: return 99
case .sokol: return 77
case .classic: return 61
case .callisto: return 104729
case .custom(let custom):
return custom.chainID
}
@ -35,14 +37,19 @@ enum RPCServer {
case .poa: return "POA Network"
case .sokol: return "Sokol"
case .classic: return "Ethereum Classic"
case .callisto: return "Callisto"
case .custom(let custom):
return custom.name
}
}
var displayName: String {
return "\(self.name) (\(self.symbol))"
}
var isTestNetwork: Bool {
switch self {
case .main, .poa, .classic, .custom: return false
case .main, .poa, .classic, .callisto, .custom: return false
case .kovan, .ropsten, .rinkeby, .sokol: return true
}
}
@ -51,6 +58,7 @@ enum RPCServer {
switch self {
case .main: return "ETH"
case .classic: return "ETC"
case .callisto: return "CLO"
case .kovan, .ropsten, .rinkeby: return "ETH"
case .poa, .sokol: return "POA"
case .custom(let custom):
@ -67,6 +75,7 @@ enum RPCServer {
switch name {
case RPCServer.main.name: return .main
case RPCServer.classic.name: return .classic
case RPCServer.callisto.name: return .callisto
case RPCServer.kovan.name: return .kovan
case RPCServer.ropsten.name: return .ropsten
case RPCServer.rinkeby.name: return .rinkeby
@ -82,6 +91,7 @@ enum RPCServer {
switch chainID {
case RPCServer.main.chainID: return .main
case RPCServer.classic.chainID: return .classic
case RPCServer.callisto.chainID: return .callisto
case RPCServer.kovan.chainID: return .kovan
case RPCServer.ropsten.chainID: return .ropsten
case RPCServer.rinkeby.chainID: return .rinkeby

@ -0,0 +1,39 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
import UIKit
import Eureka
class PreferencesViewController: FormViewController {
let viewModel = PreferencesViewModel()
let preferences: PreferencesController
init(
preferences: PreferencesController = PreferencesController()
) {
self.preferences = preferences
super.init(nibName: nil, bundle: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = viewModel.title
form +++ Section()
<<< SwitchRow {
$0.title = viewModel.showTokensTabTitle
$0.value = preferences.get(for: .showTokensOnLaunch)
}.onChange { [unowned self] row in
self.preferences.set(value: row.value ?? false, for: .showTokensOnLaunch)
}.cellSetup { cell, _ in
cell.imageView?.image = R.image.coins()
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

@ -53,7 +53,7 @@ class SettingsViewController: FormViewController {
$0.value = RPCServer(chainID: strongSelf.config.chainID)
$0.selectorTitle = strongSelf.viewModel.networkTitle
$0.displayValueFor = { value in
return value?.name
return value?.displayName
}
}.onChange {[weak self] row in
self?.config.chainID = row.value?.chainID ?? RPCServer.main.chainID
@ -62,7 +62,7 @@ class SettingsViewController: FormViewController {
selectorController.enableDeselection = false
selectorController.sectionKeyForValue = { option in
switch option {
case .main, .classic, .poa: return ""
case .main, .classic, .callisto, .poa: return ""
case .kovan, .ropsten, .rinkeby, .sokol: return NSLocalizedString("settings.network.test.label.title", value: "Test", comment: "")
case .custom:
return NSLocalizedString("settings.network.custom.label.title", value: "Custom", comment: "")
@ -84,6 +84,34 @@ class SettingsViewController: FormViewController {
cell.accessoryType = .disclosureIndicator
}
+++ Section(NSLocalizedString("settings.security.label.title", value: "Security", comment: ""))
<<< SwitchRow { [weak self] in
$0.title = self?.viewModel.passcodeTitle
$0.value = self?.isPasscodeEnabled
}.onChange { [unowned self] row in
if row.value == true {
self.setPasscode { result in
row.value = result
row.updateCell()
}
} else {
self.lock.deletePasscode()
}
}.cellSetup { cell, _ in
cell.imageView?.image = R.image.settings_lock()
}
<<< SwitchRow {
$0.title = NSLocalizedString("settings.pushNotifications.button.title", value: "Push Notifications", comment: "")
$0.value = SettingsViewController.isPushNotificationEnabled
}.onChange { [unowned self] row in
let enabled = row.value ?? false
self.run(action: .pushNotifications(enabled: enabled))
}.cellSetup { cell, _ in
cell.imageView?.image = R.image.settings_push_notifications()
}
+++ Section()
<<< PushRow<Currency> { [weak self] in
@ -123,42 +151,17 @@ class SettingsViewController: FormViewController {
}.cellSetup { cell, _ in
cell.imageView?.image = R.image.settingsCurrency()
}
<<< SwitchRow { [weak self] in
$0.title = NSLocalizedString("settings.dappbroser.button.title", value: "DApps Browser", comment: "")
$0.value = self?.config.isDAppsBrowserAvailable
}.onChange { [unowned self] row in
self.config.isDAppsBrowserAvailable = row.value ?? false
self.run(action: .DAppsBrowser)
}.cellSetup { cell, _ in
cell.imageView?.image = R.image.dapps_icon()
}
+++ Section(NSLocalizedString("settings.security.label.title", value: "Security", comment: ""))
<<< SwitchRow { [weak self] in
$0.title = self?.viewModel.passcodeTitle
$0.value = self?.isPasscodeEnabled
}.onChange { [unowned self] row in
if row.value == true {
self.setPasscode { result in
row.value = result
row.updateCell()
}
} else {
self.lock.deletePasscode()
}
}.cellSetup { cell, _ in
cell.imageView?.image = R.image.settings_lock()
}
<<< SwitchRow {
$0.title = NSLocalizedString("settings.pushNotifications.button.title", value: "Push Notifications", comment: "")
$0.value = SettingsViewController.isPushNotificationEnabled
}.onChange { [unowned self] row in
let enabled = row.value ?? false
self.run(action: .pushNotifications(enabled: enabled))
}.cellSetup { cell, _ in
cell.imageView?.image = R.image.settings_push_notifications()
<<< AppFormAppearance.button { row in
row.cellStyle = .value1
row.presentationMode = .show(controllerProvider: ControllerProvider<UIViewController>.callback {
return PreferencesViewController() }, onDismiss: { _ in
})
}.cellUpdate { cell, _ in
cell.textLabel?.textColor = .black
cell.imageView?.image = R.image.settings_preferences()
cell.textLabel?.text = NSLocalizedString("settings.preferences.title", value: "Preferences", comment: "")
cell.accessoryType = .disclosureIndicator
}
+++ Section(NSLocalizedString("settings.openSourceDevelopment.label.title", value: "Open Source Development", comment: ""))

@ -0,0 +1,18 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
struct PreferencesViewModel {
var title: String {
return NSLocalizedString("settings.preferences.title", value: "Preferences", comment: "")
}
var showTokensTabTitle: String {
return NSLocalizedString("settings.preferences.button.title", value: "Show Tokens on Launch", comment: "")
}
var showTokensTabOnStart: Bool {
return true
}
}

@ -17,6 +17,7 @@ struct SettingsViewModel {
RPCServer.main,
RPCServer.classic,
RPCServer.poa,
// RPCServer.callisto, TODO: Enable.
RPCServer.kovan,
RPCServer.ropsten,
RPCServer.rinkeby,

@ -41,8 +41,8 @@ class NewTokenViewController: FormViewController {
title = viewModel.title
let recipientRightView = FieldAppereance.addressFieldRightView(
pasteAction: { self.pasteAction() },
qrAction: { self.openReader() }
pasteAction: { [unowned self] in self.pasteAction() },
qrAction: { [unowned self] in self.openReader() }
)
form = Section()
@ -92,7 +92,7 @@ class NewTokenViewController: FormViewController {
let decimals = Int(decimalsRow?.value ?? "") ?? 0
guard let address = Address(string: contract) else {
return displayError(error: AddressError.invalidAddress)
return displayError(error: Errors.invalidAddress)
}
let token = ERC20Token(
@ -118,7 +118,7 @@ class NewTokenViewController: FormViewController {
}
guard CryptoAddressValidator.isValidAddress(value) else {
return displayError(error: AddressError.invalidAddress)
return displayError(error: Errors.invalidAddress)
}
updateContractValue(value: value)

@ -62,11 +62,9 @@ class TokensViewController: UIViewController {
})
refreshView(viewModel: viewModel)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.tintAdjustmentMode = .normal
self.navigationController?.navigationBar.tintAdjustmentMode = .automatic
self.navigationController?.applyTintAdjustment()
fetch()
}
@objc func pullToRefresh() {

@ -113,13 +113,15 @@ class TransactionViewController: UIViewController {
}
@objc func more() {
openURL(viewModel.detailsURL)
guard let url = viewModel.detailsURL else { return }
openURL(url)
}
@objc func share(_ sender: UIBarButtonItem) {
guard let item = viewModel.shareItem else { return }
let activityViewController = UIActivityViewController(
activityItems: [
viewModel.shareItem,
item,
],
applicationActivities: nil
)

@ -59,16 +59,14 @@ struct TransactionDetailsViewModel {
}
var detailsAvailable: Bool {
switch config.server {
case .main, .classic, .poa, .kovan, .ropsten, .rinkeby, .sokol, .custom: return true
}
return detailsURL != nil
}
var shareAvailable: Bool {
return detailsAvailable
}
var detailsURL: URL {
var detailsURL: URL? {
return ConfigExplorer(server: config.server).transactionURL(for: transaction.id)
}
@ -145,7 +143,7 @@ struct TransactionDetailsViewModel {
return transactionViewModel.fullAmountAttributedString
}
var shareItem: URL {
var shareItem: URL? {
return detailsURL
}
}

@ -82,7 +82,7 @@ struct TransactionsViewModel {
var isBuyActionAvailable: Bool {
switch config.server {
case .main, .kovan, .classic, .ropsten, .rinkeby, .poa, .sokol, .custom: return false
case .main, .kovan, .classic, .callisto, .ropsten, .rinkeby, .poa, .sokol, .custom: return false
}
}
}

@ -6,5 +6,5 @@ import BigInt
public struct GasLimitConfiguration {
static let `default` = BigInt(90_000)
static let min = BigInt(21_000)
static let max = BigInt(600_000)
static let max = BigInt(300_000)
}

@ -6,5 +6,5 @@ import BigInt
public struct GasPriceConfiguration {
static let `default`: BigInt = EtherNumberFormatter.full.number(from: "24", units: UnitConfiguration.gasPriceUnit)!
static let min: BigInt = EtherNumberFormatter.full.number(from: "1", units: UnitConfiguration.gasPriceUnit)!
static let max: BigInt = EtherNumberFormatter.full.number(from: "250", units: UnitConfiguration.gasPriceUnit)!
static let max: BigInt = EtherNumberFormatter.full.number(from: "100", units: UnitConfiguration.gasPriceUnit)!
}

@ -147,7 +147,7 @@ class ConfigureTransactionViewController: FormViewController {
}
func recalculateTotalFee() {
var feeAndSymbol = gasViewModel.feeText
let feeAndSymbol = gasViewModel.feeText
totalFeeRow?.value = feeAndSymbol
totalFeeRow?.updateCell()
}

@ -16,19 +16,15 @@ protocol SendViewControllerDelegate: class {
in viewController: SendViewController
)
}
class SendViewController: FormViewController {
private lazy var viewModel: SendViewModel = {
return .init(transferType: self.transferType, config: Config())
}()
weak var delegate: SendViewControllerDelegate?
struct Values {
static let address = "address"
static let amount = "amount"
}
struct Pair {
let left: String
let right: String
@ -37,27 +33,32 @@ class SendViewController: FormViewController {
return Pair(left: right, right: left)
}
}
var pairValue = 0.0
let session: WalletSession
let account: Account
let transferType: TransferType
let storage: TokensDataStore
var addressRow: TextFloatLabelRow? {
return form.rowBy(tag: Values.address) as? TextFloatLabelRow
}
var amountRow: TextFloatLabelRow? {
return form.rowBy(tag: Values.amount) as? TextFloatLabelRow
}
private var allowedCharacters: String = {
let decimalSeparator = Locale.current.decimalSeparator ?? "."
return "0123456789" + decimalSeparator
}()
private var gasPrice: BigInt?
private var data = Data()
lazy var currentPair: Pair = {
return Pair(left: viewModel.symbol, right: session.config.currency.rawValue)
}()
lazy var decimalFormatter: DecimalFormatter = {
return DecimalFormatter()
}()
lazy var stringFormatter: StringFormatter = {
return StringFormatter()
}()
init(
session: WalletSession,
storage: TokensDataStore,
@ -78,8 +79,8 @@ class SendViewController: FormViewController {
view.backgroundColor = viewModel.backgroundColor
let recipientRightView = FieldAppereance.addressFieldRightView(
pasteAction: { self.pasteAction() },
qrAction: { self.openReader() }
pasteAction: { [unowned self] in self.pasteAction() },
qrAction: { [unowned self] in self.openReader() }
)
let maxButton = Button(size: .normal, style: .borderless)
@ -103,7 +104,7 @@ class SendViewController: FormViewController {
amountRightView.axis = .horizontal
form = Section()
+++ Section(header: "", footer: isFiatViewHidden() ? "" : "~ \(String(format: "%.2f", self.pairValue)) " + "\(currentPair.right)")
+++ Section(header: "", footer: isFiatViewHidden() ? "" : valueOfPairRepresantetion())
<<< AppFormAppearance.textFieldFloat(tag: Values.address) {
$0.add(rule: EthereumAddressRule())
$0.validationOptions = .validatesOnDemand
@ -118,6 +119,7 @@ class SendViewController: FormViewController {
$0.add(rule: RuleRequired())
$0.validationOptions = .validatesOnDemand
}.cellUpdate {[weak self] cell, _ in
cell.textField.isCopyPasteDisabled = true
cell.textField.textAlignment = .left
cell.textField.delegate = self
cell.textField.placeholder = "\(self?.currentPair.left ?? "") " + NSLocalizedString("send.amount.textField.placeholder", value: "Amount", comment: "")
@ -126,7 +128,10 @@ class SendViewController: FormViewController {
cell.textField.rightViewMode = .always
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.applyTintAdjustment()
}
func getGasPrice() {
let request = EtherServiceRequest(batch: BatchFactory().create(GasPriceRequest()))
Session.send(request) { [weak self] result in
@ -137,7 +142,6 @@ class SendViewController: FormViewController {
}
}
}
func clear() {
let fields = [addressRow, amountRow]
for field in fields {
@ -145,23 +149,22 @@ class SendViewController: FormViewController {
field?.reload()
}
}
@objc func send() {
let errors = form.validate()
guard errors.isEmpty else { return }
let addressString = addressRow?.value?.trimmed ?? ""
var amountString = ""
if self.currentPair.left == viewModel.symbol {
amountString = amountRow?.value?.trimmed ?? ""
} else {
amountString = String(format: "%f", self.pairValue).trimmed
guard let formatedValue = decimalFormatter.string(from: NSNumber(value: self.pairValue)) else {
return displayError(error: SendInputErrors.wrongInput)
}
amountString = formatedValue
}
guard let address = Address(string: addressString) else {
return displayError(error: AddressError.invalidAddress)
return displayError(error: Errors.invalidAddress)
}
let parsedValue: BigInt? = {
switch transferType {
case .ether:
@ -170,11 +173,9 @@ class SendViewController: FormViewController {
return EtherNumberFormatter.full.number(from: amountString, decimals: token.decimals)
}
}()
guard let value = parsedValue else {
return displayError(error: SendInputErrors.wrongInput)
}
let transaction = UnconfirmedTransaction(
transferType: transferType,
value: value,
@ -186,36 +187,28 @@ class SendViewController: FormViewController {
)
self.delegate?.didPressConfirm(transaction: transaction, transferType: transferType, in: self)
}
@objc func openReader() {
let controller = QRCodeReaderViewController()
controller.delegate = self
present(controller, animated: true, completion: nil)
}
@objc func pasteAction() {
guard let value = UIPasteboard.general.string?.trimmed else {
return displayError(error: SendInputErrors.emptyClipBoard)
}
guard CryptoAddressValidator.isValidAddress(value) else {
return displayError(error: AddressError.invalidAddress)
return displayError(error: Errors.invalidAddress)
}
addressRow?.value = value
addressRow?.reload()
activateAmountView()
}
@objc func useMaxAmount() {
guard let value = session.balance?.amountFull else { return }
amountRow?.value = value
amountRow?.reload()
}
@objc func fiatAction(sender: UIButton) {
let swappedPair = currentPair.swapPair()
//New pair for future calculation we should swap pair each time we press fiat button.
@ -232,15 +225,12 @@ class SendViewController: FormViewController {
//Set focuse on pair change.
activateAmountView()
}
func activateAmountView() {
amountRow?.cell.textField.becomeFirstResponder()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func updatePriceSection() {
//Update section only if fiat view is visible.
guard !isFiatViewHidden() else {
@ -250,13 +240,12 @@ class SendViewController: FormViewController {
UIView.setAnimationsEnabled(false)
tableView.beginUpdates()
if let containerView = tableView.footerView(forSection: 1) {
containerView.textLabel!.text = "~ \(String(format: "%.2f", self.pairValue)) " + "\(currentPair.right)"
containerView.textLabel!.text = valueOfPairRepresantetion()
containerView.sizeToFit()
}
tableView.endUpdates()
UIView.setAnimationsEnabled(true)
}
private func updatePairPrice(with amount: Double) {
guard let rates = storage.tickers, let currentTokenInfo = rates[viewModel.destinationAddress.description], let price = Double(currentTokenInfo.price) else {
return
@ -268,7 +257,6 @@ class SendViewController: FormViewController {
}
self.updatePriceSection()
}
private func isFiatViewHidden() -> Bool {
guard let currentTokenInfo = storage.tickers?[viewModel.destinationAddress.description], let price = Double(currentTokenInfo.price), price > 0 else {
return true
@ -307,18 +295,41 @@ extension SendViewController: QRCodeReaderDelegate {
pairValue = 0.0
updatePriceSection()
}
private func valueOfPairRepresantetion() -> String {
var formattedString = ""
if self.currentPair.left == viewModel.symbol {
formattedString = StringFormatter().currency(with: self.pairValue, and: self.session.config.currency.rawValue)
} else {
formattedString = stringFormatter.formatter(for: self.pairValue)
}
return "~ \(formattedString) " + "\(currentPair.right)"
}
}
extension SendViewController: UITextFieldDelegate {
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let text = (textField.text as NSString?)?.replacingCharacters(in: range, with: string)
guard let total = text, let amount = Double(total) else {
guard let input = textField.text else {
return true
}
//In this step we validate only allowed characters it is because of the iPad keyboard.
let characterSet = NSCharacterSet(charactersIn: self.allowedCharacters).inverted
let separatedChars = string.components(separatedBy: characterSet)
let filteredNumbersAndSeparator = separatedChars.joined(separator: "")
if string != filteredNumbersAndSeparator {
return false
}
//This is required to prevent user from input of numbers like 1.000.25 or 1,000,25.
if string == "," || string == "." || string == "'" {
return !input.contains(string)
}
let text = (input as NSString).replacingCharacters(in: range, with: string)
guard let amount = decimalFormatter.number(from: text) else {
//Should be done in another way.
pairValue = 0.0
updatePriceSection()
return true
}
self.updatePairPrice(with: amount)
self.updatePairPrice(with: amount.doubleValue)
return true
}
}

@ -72,6 +72,11 @@ class ImportWalletViewController: FormViewController {
}
}
let recipientRightView = FieldAppereance.addressFieldRightView(
pasteAction: { [unowned self] in self.pasteAddressAction() },
qrAction: { [unowned self] in self.openReader() }
)
form
+++ Section {
var header = HeaderFooterView<InfoHeaderView>(.class)
@ -136,6 +141,8 @@ class ImportWalletViewController: FormViewController {
})
}.cellUpdate { cell, _ in
cell.textField.placeholder = NSLocalizedString("Ethereum Address", value: "Ethereum Address", comment: "")
cell.textField.rightView = recipientRightView
cell.textField.rightViewMode = .always
}
<<< AppFormAppearance.textFieldFloat(tag: Values.password) {
@ -256,6 +263,12 @@ class ImportWalletViewController: FormViewController {
}
}
@objc func pasteAddressAction() {
let value = UIPasteboard.general.string?.trimmed
watchRow?.value = value
watchRow?.reload()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

@ -21,16 +21,10 @@ class InCoordinatorTests: XCTestCase {
XCTAssertNotNil(tabbarController)
if config.isDAppsBrowserAvailable {
XCTAssert((tabbarController?.viewControllers?[0] as? UINavigationController)?.viewControllers[0] is BrowserViewController)
XCTAssert((tabbarController?.viewControllers?[1] as? UINavigationController)?.viewControllers[0] is TransactionsViewController)
XCTAssert((tabbarController?.viewControllers?[2] as? UINavigationController)?.viewControllers[0] is TokensViewController)
XCTAssert((tabbarController?.viewControllers?[3] as? UINavigationController)?.viewControllers[0] is SettingsViewController)
} else {
XCTAssert((tabbarController?.viewControllers?[0] as? UINavigationController)?.viewControllers[0] is TransactionsViewController)
XCTAssert((tabbarController?.viewControllers?[1] as? UINavigationController)?.viewControllers[0] is TokensViewController)
XCTAssert((tabbarController?.viewControllers?[2] as? UINavigationController)?.viewControllers[0] is SettingsViewController)
}
XCTAssert((tabbarController?.viewControllers?[0] as? UINavigationController)?.viewControllers[0] is BrowserViewController)
XCTAssert((tabbarController?.viewControllers?[1] as? UINavigationController)?.viewControllers[0] is TransactionsViewController)
XCTAssert((tabbarController?.viewControllers?[2] as? UINavigationController)?.viewControllers[0] is TokensViewController)
XCTAssert((tabbarController?.viewControllers?[3] as? UINavigationController)?.viewControllers[0] is SettingsViewController)
}
func testChangeRecentlyUsedAccount() {
@ -92,4 +86,34 @@ class InCoordinatorTests: XCTestCase {
XCTAssertTrue(coordinator.coordinators.last is PaymentCoordinator)
XCTAssertTrue(controller is RequestViewController)
}
func testShowTabDefault() {
let coordinator = InCoordinator(
navigationController: FakeNavigationController(),
wallet: .make(),
keystore: FakeEtherKeystore(),
config: .make()
)
coordinator.showTabBar(for: .make())
let viewController = (coordinator.tabBarController?.selectedViewController as? UINavigationController)?.viewControllers[0]
XCTAssert(viewController is TransactionsViewController)
}
func testShowTabTokens() {
let coordinator = InCoordinator(
navigationController: FakeNavigationController(),
wallet: .make(),
keystore: FakeEtherKeystore(),
config: .make()
)
coordinator.showTabBar(for: .make())
coordinator.showTab(.tokens)
let viewController = (coordinator.tabBarController?.selectedViewController as? UINavigationController)?.viewControllers[0]
XCTAssert(viewController is TokensViewController)
}
}

@ -0,0 +1,25 @@
// Copyright SIX DAY LLC. All rights reserved.
import XCTest
@testable import Trust
class InCoordinatorViewModelTests: XCTestCase {
func testInitialTab() {
let viewModel = InCoordinatorViewModel(config: .make())
XCTAssertEqual(.transactions, viewModel.initialTab)
}
func testInitialTabWhenEnabledInPreferences() {
let preferences: PreferencesController = .make()
preferences.set(value: true, for: .showTokensOnLaunch)
let viewModel = InCoordinatorViewModel(
config: .make(),
preferences: preferences
)
XCTAssertEqual(.tokens, viewModel.initialTab)
}
}

@ -0,0 +1,14 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
@testable import Trust
extension PreferencesController {
static func make(
userDefaults: UserDefaults = .test
) -> PreferencesController {
return PreferencesController(
userDefaults: userDefaults
)
}
}

@ -0,0 +1,47 @@
// Copyright SIX DAY LLC. All rights reserved.
@testable import Trust
import XCTest
class DecimalFormatterTest: XCTestCase {
let usDecimalFormatter = DecimalFormatter(locale: Locale(identifier: "en_US"))
let frDecimalFormatter = DecimalFormatter(locale: Locale(identifier: "fr_FR"))
func testDecimalPointInUS() {
XCTAssertEqual(usDecimalFormatter.number(from: "1000.25"), NSNumber(value: 1000.25))
XCTAssertEqual(usDecimalFormatter.number(from: ".25"), NSNumber(value: 0.25))
}
func testDecimalAndThousandsPointsInUS() {
XCTAssertEqual(usDecimalFormatter.number(from: "1,000.25"), NSNumber(value: 1000.25))
XCTAssertEqual(usDecimalFormatter.number(from: "1.000,25"), NSNumber(value: 1000.25))
XCTAssertEqual(usDecimalFormatter.number(from: "1'000,25"), NSNumber(value: 1000.25))
}
func testThousandsPointsInUS() {
XCTAssertEqual(usDecimalFormatter.number(from: ",25"), NSNumber(value: 25))
}
func testNumberToStingInUS() {
XCTAssertEqual(usDecimalFormatter.string(from: NSNumber(value: 1000.25)), "1,000.25")
XCTAssertEqual(usDecimalFormatter.string(from: NSNumber(value: 0.25)), "0.25")
}
func testInvalidStringInUS() {
XCTAssertEqual(usDecimalFormatter.number(from: "test"), nil)
}
func testDecimalPointInFr() {
XCTAssertEqual(frDecimalFormatter.number(from: "1 000,25"), NSNumber(value: 1000.25))
XCTAssertEqual(frDecimalFormatter.number(from: ".25"), NSNumber(value: 25))
}
func testDecimalAndThousandsPointsInFr() {
XCTAssertEqual(frDecimalFormatter.number(from: "1,000.25"), NSNumber(value: 1000.25))
XCTAssertEqual(frDecimalFormatter.number(from: "1.000,25"), NSNumber(value: 1000.25))
XCTAssertEqual(frDecimalFormatter.number(from: "1'000,25"), NSNumber(value: 1000.25))
}
func testThousandsPointsInFr() {
XCTAssertEqual(frDecimalFormatter.number(from: ",25"), NSNumber(value: 0.25))
}
func testNumberToStingInFr() {
XCTAssertEqual(frDecimalFormatter.string(from: NSNumber(value: 1000.25)), "1 000,25")
XCTAssertEqual(frDecimalFormatter.string(from: NSNumber(value: 0.25)), "0,25")
}
func testInvalidStringInFr() {
XCTAssertEqual(frDecimalFormatter.number(from: "test"), nil)
}
}

@ -0,0 +1,12 @@
// Copyright SIX DAY LLC. All rights reserved.
@testable import Trust
import XCTest
class StringFormatterTest: XCTestCase {
let stringFormatter = StringFormatter()
func testStringFormatter() {
XCTAssertEqual(stringFormatter.formatter(for: 0.00001), "0.000010")
XCTAssertEqual(stringFormatter.formatter(for: 0.1234, with: 2), "0.12")
}
}

@ -15,8 +15,8 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.1.140</string>
<string>1.1.145</string>
<key>CFBundleVersion</key>
<string>152</string>
<string>157</string>
</dict>
</plist>

@ -15,8 +15,15 @@ class OrderSigningTests : XCTestCase {
var indices = [UInt16]()
indices.append(1)
indices.append(2)
let testOrder1 = Order(price : BigInt.init(0), ticketIndices: indices,
expiryTimeStamp: BigInt.init(0), contractAddress : "d9864b424447B758CdE90f8655Ff7cA4673956bf")
var price = [UInt8]()
price.append(1) //price is 1 wei
var expiry = [UInt8]()
expiry.append(0)
let testOrder1 = Order(price : price, ticketIndices: indices,
expiryBuffer: expiry, contractAddress : "d9864b424447B758CdE90f8655Ff7cA4673956bf")
testOrdersList.append(testOrder1)
let signOrders = SignOrders()

@ -28,11 +28,5 @@ class ConfigTests: XCTestCase {
XCTAssertEqual(false, config.isCryptoPrimaryCurrency)
}
func testTestDefaultdAppsBrowser() {
var config: Config = .make()
XCTAssertEqual(false, config.isDAppsBrowserAvailable)
}
}

@ -0,0 +1,21 @@
// Copyright SIX DAY LLC. All rights reserved.
import XCTest
@testable import Trust
class PreferencesControllerTests: XCTestCase {
func testShowTokensOnStartDefault() {
let controller = PreferencesController(userDefaults: .test)
XCTAssertEqual(controller.get(for: .showTokensOnLaunch), false)
}
func testShowTokensOnStartDisable() {
let controller = PreferencesController(userDefaults: .test)
controller.set(value: false, for: .showTokensOnLaunch)
XCTAssertEqual(controller.get(for: .showTokensOnLaunch), false)
}
}

@ -9,6 +9,6 @@ class GasLimitConfigurationTests: XCTestCase {
func testDefault() {
XCTAssertEqual(BigInt(90000), GasLimitConfiguration.default)
XCTAssertEqual(BigInt(21000), GasLimitConfiguration.min)
XCTAssertEqual(BigInt(600000), GasLimitConfiguration.max)
XCTAssertEqual(BigInt(300000), GasLimitConfiguration.max)
}
}

@ -9,6 +9,6 @@ class GasPriceConfigurationTests: XCTestCase {
func testDefault() {
XCTAssertEqual(BigInt(24000000000), GasPriceConfiguration.default)
XCTAssertEqual(BigInt(1000000000), GasPriceConfiguration.min)
XCTAssertEqual(BigInt(250000000000), GasPriceConfiguration.max)
XCTAssertEqual(BigInt(100000000000), GasPriceConfiguration.max)
}
}

@ -15,8 +15,8 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.1.140</string>
<string>1.1.145</string>
<key>CFBundleVersion</key>
<string>152</string>
<string>157</string>
</dict>
</plist>

Loading…
Cancel
Save