Skip to content

Commit

Permalink
CORE-66: In Core Ethereum, clean up compiler warnings, update to Swif…
Browse files Browse the repository at this point in the history
…t 4.2
  • Loading branch information
Ed Gamble committed Sep 27, 2018
1 parent da1fba8 commit 5f47257
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 53 deletions.
20 changes: 12 additions & 8 deletions Swift/BRCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1057,18 +1057,22 @@
};
3C902601210A30F100143B69 = {
CreatedOnToolsVersion = 9.4.1;
LastSwiftMigration = 1000;
};
3CAB609A20AF8C5D00810CE4 = {
CreatedOnToolsVersion = 9.3.1;
};
3CAB60A520AF8C8500810CE4 = {
CreatedOnToolsVersion = 9.3.1;
LastSwiftMigration = 1000;
};
3CAB60EE20AF936200810CE4 = {
CreatedOnToolsVersion = 9.3.1;
LastSwiftMigration = 1000;
};
3CAB60F620AF936200810CE4 = {
CreatedOnToolsVersion = 9.3.1;
LastSwiftMigration = 1000;
};
};
};
Expand Down Expand Up @@ -1604,7 +1608,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.breadwallet.CoreDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1624,7 +1628,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.breadwallet.CoreDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down Expand Up @@ -1693,7 +1697,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.breadwallet.CoreTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "CoreTests/CoreTests-Bridging-Header.h";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1715,7 +1719,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.breadwallet.CoreTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "CoreTests/CoreTests-Bridging-Header.h";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -1742,7 +1746,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/Core/";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1769,7 +1773,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/Core/";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -1789,7 +1793,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.breadwallet.BRCoreTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1809,7 +1813,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.breadwallet.BRCoreTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
6 changes: 6 additions & 0 deletions Swift/BRCore/BREthereum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ public struct EthereumNetwork : EthereumPointer {
static public let rinkeby = EthereumNetwork (core: ethereumRinkeby)
}

extension EthereumNetwork : Equatable {
static public func == (lhs: EthereumNetwork, rhs: EthereumNetwork) -> Bool {
return lhs.core == rhs.core
}
}

// MARK: - Token

///
Expand Down
4 changes: 3 additions & 1 deletion Swift/BRCoreTests/BRCoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ class TestLightClient : EthereumClient {

func getTokens(ewm: EthereumWalletManager, rid: Int32) {
ewm.announceToken (rid: rid,
address: "0x558ec3152e2eb2174905cd19aea4e34a23de9ad6",
address: (ewm.network == EthereumNetwork.mainnet
? "0x558ec3152e2eb2174905cd19aea4e34a23de9ad6"
: "0x7108ca7c4718efa810457f228305c9c71390931a"),
symbol: "BRD",
name: "BRD Token",
description: "The BRD Token",
Expand Down
2 changes: 1 addition & 1 deletion Swift/CoreDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
var client : CoreDemoEthereumClient!


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let splitViewController = window!.rootViewController as! UISplitViewController

Expand Down
2 changes: 1 addition & 1 deletion Swift/CoreDemo/SummaryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SummaryViewController: UITableViewController, WalletListener {
return true
}

override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
wallets.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .fade)
Expand Down
6 changes: 3 additions & 3 deletions Swift/CoreDemo/TransferCreateController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class TransferCreateController: UIViewController, UITextViewDelegate {
@IBAction func submit(_ sender: UIBarButtonItem) {
NSLog ("Want to submit")

let alert = UIAlertController (title: "Submit Transaction", message: "Are you sure?", preferredStyle: UIAlertControllerStyle.actionSheet)
alert.addAction(UIAlertAction (title: "Yes", style: UIAlertActionStyle.destructive) { (action) in
let alert = UIAlertController (title: "Submit Transaction", message: "Are you sure?", preferredStyle: UIAlertController.Style.actionSheet)
alert.addAction(UIAlertAction (title: "Yes", style: UIAlertAction.Style.destructive) { (action) in
let transfer = self.wallet.createTransfer (recvAddress: self.recvField.text!,
amount: self.amountSlider.value.description,
unit: EthereumAmountUnit.defaultUnitEther);
Expand All @@ -59,7 +59,7 @@ class TransferCreateController: UIViewController, UITextViewDelegate {
// Notify, close
self.dismiss(animated: true) {}
})
alert.addAction(UIAlertAction (title: "No", style: UIAlertActionStyle.cancel) { (action) in
alert.addAction(UIAlertAction (title: "No", style: UIAlertAction.Style.cancel) { (action) in
NSLog ("Will Cancel" )
})
self.present(alert, animated: true) {}
Expand Down
2 changes: 1 addition & 1 deletion ethereum/bcs/BREthereumBCS.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ bcsHandleAnnounce (BREthereumBCS bcs,
(BREthereumLESProvisionContext) bcs,
(BREthereumLESProvisionCallback) bcsSignalProvision,
headNumber - reorgDepth,
1 + reorgDepth,
(uint32_t) (1 + reorgDepth),
0,
ETHEREUM_BOOLEAN_FALSE);
}
Expand Down
3 changes: 0 additions & 3 deletions ethereum/bcs/BREthereumBCSSync.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ computeOptimalStep (uint64_t numberOfBlocks,
uint64_t *optimalStep,
uint64_t *optimalCount);

static inline uint64_t minimum (uint64_t x, uint64_t y ) { return x <= y ? x : y; }
static inline uint64_t maximum (uint64_t x, uint64_t y ) { return x >= y ? x : y; }

/**
* The BCS Sync Type represents the types of nodes in an N-ary tree. We sync Ethereum blocks based
* on a N-ary search for regions of blocks where the account state of the desired address changed.
Expand Down
2 changes: 1 addition & 1 deletion ethereum/blockchain/BREthereumBlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ blockHeaderCanonicalDifficulty (BREthereumBlockHeader header,
uint64_t y = parentOmmersCount == 0 ? 1 : 2;
int64_t sigma_2 = max (y - delay_scaled, -99);
assert (sigma_2 <= INT32_MAX && INT32_MIN <= sigma_2);
UInt256 x_sigma = mulUInt256_Small(x, (uint64_t) (sigma_2 < 0 ? -sigma_2 : sigma_2), &overflow);
UInt256 x_sigma = mulUInt256_Small(x, (uint32_t) (sigma_2 < 0 ? -sigma_2 : sigma_2), &overflow);
assert (0 == overflow);

uint64_t fake_block_number = header->number > 3000000 ? (header->number - 3000000) : 0;
Expand Down
4 changes: 0 additions & 4 deletions ethereum/blockchain/BREthereumTransaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
static unsigned int transactionAllocCount = 0;
#endif

// Forward Declarations
static void
provideData (BREthereumTransaction transaction);

/**
* An Ethereum Transaction ...
*
Expand Down
4 changes: 2 additions & 2 deletions ethereum/contract/testContract.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include "BREthereumToken.h"

#if defined (BITCOIN_TESTNET) && 1 == BITCOIN_TESTNET
extern const char *tokenBRDAddress = "0x7108ca7c4718efa810457f228305c9c71390931a"; // testnet
const char *tokenBRDAddress = "0x7108ca7c4718efa810457f228305c9c71390931a"; // testnet
#else
extern const char *tokenBRDAddress = "0x558ec3152e2eb2174905cd19aea4e34a23de9ad6"; // mainnet
const char *tokenBRDAddress = "0x558ec3152e2eb2174905cd19aea4e34a23de9ad6"; // mainnet
#endif

#if defined (BITCOIN_DEBUG)
Expand Down
6 changes: 0 additions & 6 deletions ethereum/les/BREthereumLES.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ lesHandleProvision (BREthereumLES les,
BREthereumNode node,
BREthereumProvisionResult result);

static void
lesHandleNodeState (BREthereumLES les,
BREthereumNode node,
BREthereumNodeEndpointRoute route,
BREthereumNodeState state);

static void
lesHandleStatus (BREthereumLES les,
BREthereumNode node,
Expand Down
2 changes: 2 additions & 0 deletions ethereum/les/BREthereumLESFrameCoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ static void _BRAES256ECBEncrypt(const void *key32, void *buf16)
memcpy(buf16, buf, sizeof(buf));
mem_clean(buf, sizeof(buf));
}

static void _BRAES256ECBDecrypt(const void *key32, void *buf16)
{
size_t i, j;
Expand Down Expand Up @@ -221,6 +222,7 @@ static void _BRAES256ECBDecrypt(const void *key32, void *buf16)
memcpy(buf16, buf, sizeof(buf));
mem_clean(buf, sizeof(buf));
}

//
// Public Functions
//
Expand Down
22 changes: 1 addition & 21 deletions ethereum/les/BREthereumNode.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ nodeStateAnnounce (BREthereumNode node,
BREthereumNodeEndpointRoute route,
BREthereumNodeState state);

static uint64_t
getEndpointChainId (BREthereumNodeEndpoint *endpoint);

static void
showEndpointStatusMessage (BREthereumNodeEndpoint *endpoint);

Expand Down Expand Up @@ -1066,7 +1063,7 @@ nodeUpdateTimeoutRecv (BREthereumNode node,

static int
nodeStatusIsSufficient (BREthereumNode node) {
BREthereumP2PMessageStatusValue remValue, locValue;
BREthereumP2PMessageStatusValue remValue;

// Both LES or both PIP
assert (node->remote.status.identifier == node->local.status.identifier);
Expand Down Expand Up @@ -1838,23 +1835,6 @@ showEndpointStatusMessage (BREthereumNodeEndpoint *endpoint) {
}
}

static uint64_t
getEndpointChainId (BREthereumNodeEndpoint *endpoint) {
switch (endpoint->status.identifier) {
case MESSAGE_P2P:
case MESSAGE_DIS:
case MESSAGE_ETH:
assert (0);

case MESSAGE_LES:
return endpoint->status.u.les.u.status.p2p.chainId;

case MESSAGE_PIP:
return endpoint->status.u.pip.u.status.p2p.chainId;
break;
}
}

/// MARK: - Send / Recv

static BREthereumNodeStatus
Expand Down
2 changes: 1 addition & 1 deletion ethereum/les/msg/BREthereumMessageDIS.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ uint256Bitwise (BREthereumIntBitwiseType type,
return z;
}

#if 0
static int
uint256BitOffset (UInt256 x) {
for (unsigned int index = 0; index < 256; index++)
Expand All @@ -67,7 +68,6 @@ uint256BitOffset (UInt256 x) {
return -1;
}

#if 0
static int
uint64tBitCount (uint64_t val) {
int count = 0;
Expand Down

0 comments on commit 5f47257

Please sign in to comment.