Skip to content
This repository was archived by the owner on Dec 15, 2023. It is now read-only.

Commit b3a9d16

Browse files
authored
Merge branch 'develop' into feature/addEmptyBytesPublicConstructor
2 parents a90b4fb + 0c759e5 commit b3a9d16

File tree

16 files changed

+208
-90
lines changed

16 files changed

+208
-90
lines changed

Example/Podfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ end
88

99
target 'Web3Swift_Tests' do
1010
pod 'Web3Swift.io', :path => '../'
11-
pod 'SwiftLint', '~> 0.27'
11+
pod 'SwiftLint', '= 0.27'
1212
pod 'Quick', '~> 1.2'
1313
pod 'Nimble', '~> 7.0'
1414
end

Example/Podfile.lock

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
PODS:
22
- BigInt (5.0.0)
3-
- CryptoSwift (1.3.0)
3+
- CryptoSwift (1.3.1)
44
- Nimble (7.3.4)
55
- Quick (1.3.4)
6-
- secp256k1_ios (0.1.3)
7-
- SwiftLint (0.31.0)
6+
- secp256k1.swift (0.1.4)
7+
- SwiftLint (0.27.0)
88
- SwiftyJSON (4.3.0)
9-
- Web3Swift.io (0.0.3):
9+
- Web3Swift.io (0.0.4):
1010
- BigInt (~> 5.0)
1111
- CryptoSwift (~> 1.0)
12-
- secp256k1_ios (~> 0.1)
12+
- secp256k1.swift (~> 0.1)
1313
- SwiftyJSON (~> 4.3)
1414

1515
DEPENDENCIES:
1616
- Nimble (~> 7.0)
1717
- Quick (~> 1.2)
18+
- SwiftLint (= 0.27)
1819
- SwiftLint (~> 0.27)
1920
- Web3Swift.io (from `../`)
2021

2122
SPEC REPOS:
22-
https://github.com/CocoaPods/Specs.git:
23-
- Nimble
24-
- Quick
25-
- SwiftLint
2623
trunk:
2724
- BigInt
2825
- CryptoSwift
29-
- secp256k1_ios
26+
- Nimble
27+
- Quick
28+
- secp256k1.swift
29+
- SwiftLint
3030
- SwiftyJSON
3131

3232
EXTERNAL SOURCES:
@@ -35,14 +35,14 @@ EXTERNAL SOURCES:
3535

3636
SPEC CHECKSUMS:
3737
BigInt: 74b4d88367b0e819d9f77393549226d36faeb0d8
38-
CryptoSwift: 1283821600233bdbeb96d7b389c3288c3bf77211
38+
CryptoSwift: f12f037f6d0fcd6d48c96db0071b653de64e6c4d
3939
Nimble: 051e3d8912d40138fa5591c78594f95fb172af37
4040
Quick: f4f7f063c524394c73ed93ac70983c609805d481
41-
secp256k1_ios: ac9ef04e761f43c58012b28548afa91493761f17
42-
SwiftLint: 7a0227733d786395817373b2d0ca799fd0093ff3
41+
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
42+
SwiftLint: 3207c1faa2240bf8973b191820a116113cd11073
4343
SwiftyJSON: 6faa0040f8b59dead0ee07436cbf76b73c08fd08
44-
Web3Swift.io: d73b1a0e4a8cec74493c1090265b7828a5effc48
44+
Web3Swift.io: c10366f6daa98d6cd669d053fbe831b0ed20338d
4545

46-
PODFILE CHECKSUM: 2e44a26eed843b24dadf38c791a6c0a80ffde2fb
46+
PODFILE CHECKSUM: a92dfff1059a074e829f137af158b15e15bc2d87
4747

48-
COCOAPODS: 1.8.4
48+
COCOAPODS: 1.9.3

Example/Tests/ContractCall/EthContractCallTests.swift

+28
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,33 @@ final class EthContractCallTests: XCTestCase {
3737
description: "EOS supply is expected to be 1,000,000,000,000,000,000,000,000,000 wad"
3838
)
3939
}
40+
41+
func testWethDeposit() {
42+
expect{
43+
try HexAsDecimalString(
44+
hex: EthContractCall(
45+
network: MainnetInfuraNetwork(),
46+
senderAddress: EthAddress(
47+
hex: "0x42b9df65b219b3dd36ff330a4dd8f327a6ada990"
48+
),
49+
contractAddress: EthAddress(
50+
hex: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
51+
),
52+
weiAmount: EthNumber(decimal: "1"),
53+
functionCall: EncodedABIFunction(
54+
signature: SimpleString(
55+
string: "deposit()"
56+
),
57+
parameters: []
58+
)
59+
)
60+
).value()
61+
}.to(
62+
equal(
63+
"0"
64+
),
65+
description: "Paypable functions should be eligible for calling"
66+
)
67+
}
4068

4169
}

Example/Tests/Entropy/RandomNonceTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import CryptoSwift
1212
import Nimble
1313
import Quick
14-
import secp256k1_ios
14+
import secp256k1
1515
@testable import Web3Swift
1616
import XCTest
1717

Example/Tests/TransactionBytes/EthContractCallBytesTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ final class EthContractCallBytesTests: XCTestCase {
6262
//TODO: We got a problem with gas price encoding here. Since we use mainnet to encode this request gas price changes every time. Migration to Ganage might solve this problem.
6363
expect{
6464
try EthContractCallBytes(
65-
network: MainnetAlchemyNetwork(),
65+
network: MainnetInfuraNetwork(),
6666
senderKey: Alice().privateKey(),
6767
contractAddress: EthAddress(
6868
hex: "0x6b175474e89094c44da98b954eedeac495271d0f"

Example/Tests/TransactionLog/EthTransactionLogTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class EthTransactionLogTests: XCTestCase {
3434
transactionHash: BytesFromHexString(
3535
hex: "0xfbaad83ca594fa30902586f06c9a2fd4d3855f3769e4cf3157eb0013abd0661f"
3636
),
37-
network: MainnetAlchemyNetwork()
37+
network: MainnetInfuraNetwork()
3838
).receipt().logs().value()[0]
3939

4040
expect{
@@ -86,7 +86,7 @@ class EthTransactionLogTests: XCTestCase {
8686
expect{
8787
try log.index().value().toDecimalString()
8888
}.to(
89-
equal("0"),
89+
equal("85"),
9090
description: "Expect log index to be correct"
9191
)
9292

Example/Web3Swift.xcodeproj/project.pbxproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@
10761076
"${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework",
10771077
"${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework",
10781078
"${BUILT_PRODUCTS_DIR}/Web3Swift.io/Web3Swift.framework",
1079-
"${BUILT_PRODUCTS_DIR}/secp256k1_ios/secp256k1_ios.framework",
1079+
"${BUILT_PRODUCTS_DIR}/secp256k1.swift/secp256k1.framework",
10801080
"${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework",
10811081
"${BUILT_PRODUCTS_DIR}/Quick/Quick.framework",
10821082
);
@@ -1086,7 +1086,7 @@
10861086
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework",
10871087
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework",
10881088
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Web3Swift.framework",
1089-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/secp256k1_ios.framework",
1089+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/secp256k1.framework",
10901090
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework",
10911091
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework",
10921092
);
@@ -1137,7 +1137,7 @@
11371137
);
11381138
runOnlyForDeploymentPostprocessing = 0;
11391139
shellPath = /bin/sh;
1140-
shellScript = "${PODS_ROOT}/SwiftLint/swiftlint --path ../";
1140+
shellScript = "${PODS_ROOT}/SwiftLint/swiftlint --path ../\n";
11411141
};
11421142
D0ECBA0FCDB34E08A91BF630 /* [CP] Check Pods Manifest.lock */ = {
11431143
isa = PBXShellScriptBuildPhase;
@@ -1168,15 +1168,15 @@
11681168
"${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework",
11691169
"${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework",
11701170
"${BUILT_PRODUCTS_DIR}/Web3Swift.io/Web3Swift.framework",
1171-
"${BUILT_PRODUCTS_DIR}/secp256k1_ios/secp256k1_ios.framework",
1171+
"${BUILT_PRODUCTS_DIR}/secp256k1.swift/secp256k1.framework",
11721172
);
11731173
name = "[CP] Embed Pods Frameworks";
11741174
outputPaths = (
11751175
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BigInt.framework",
11761176
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework",
11771177
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework",
11781178
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Web3Swift.framework",
1179-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/secp256k1_ios.framework",
1179+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/secp256k1.framework",
11801180
);
11811181
runOnlyForDeploymentPostprocessing = 0;
11821182
shellPath = /bin/sh;

Web3Swift.io.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Web3Swift.io'
3-
s.version = '0.0.3'
3+
s.version = '0.0.4'
44
s.summary = 'Web3 library for Swift. Construct and sign transactions, interact with smart contracts.'
55

66
s.description = <<-DESC
@@ -23,7 +23,7 @@ encode and decode ABI messages.
2323
s.module_name = 'Web3Swift'
2424
s.source_files = 'Web3Swift/**/*'
2525
s.dependency 'SwiftyJSON', '~> 4.3'
26-
s.dependency 'secp256k1_ios', '~> 0.1'
26+
s.dependency 'secp256k1.swift', '~> 0.1'
2727
s.dependency 'CryptoSwift', '~> 1.0'
2828
s.dependency 'BigInt', '~> 5.0'
2929

Web3Swift/CollectionScalar/SimpleCollection.swift

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public final class SimpleCollection<T>: CollectionScalar<T> {
3131
- parameters:
3232
- collection: a closure representing an array as a collection of elements
3333
*/
34+
// swiftlint:disable:next attributes
3435
public convenience init(collection: @escaping () throws -> ([T])) {
3536
self.init(collection: { try AnyCollection(collection()) })
3637
}

Web3Swift/ContractCall/EthContractCall.swift

+39-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,44 @@ public final class EthContractCall: BytesScalar {
9595
)
9696
}
9797

98+
/**
99+
Ctor
100+
101+
- parameters:
102+
- network: network to call
103+
- senderAddress: address of the msg.sender
104+
- contractAddress: address of the contract
105+
- weiAmount: amount to be sent in wei
106+
- functionCall: encoded call the contract function
107+
*/
108+
public convenience init(
109+
network: Network,
110+
senderAddress: BytesScalar,
111+
contractAddress: BytesScalar,
112+
weiAmount: BytesScalar,
113+
functionCall: BytesScalar
114+
) {
115+
self.init(
116+
call: ContractCallProcedure(
117+
network: network,
118+
parameters: [
119+
"from" : BytesParameter(
120+
bytes: senderAddress
121+
),
122+
"to" : BytesParameter(
123+
bytes: contractAddress
124+
),
125+
"value" : QuantityParameter(
126+
number: weiAmount
127+
),
128+
"data" : BytesParameter(
129+
bytes: functionCall
130+
)
131+
]
132+
)
133+
)
134+
}
135+
98136
/**
99137
- returns:
100138
The return of the function call
@@ -103,4 +141,4 @@ public final class EthContractCall: BytesScalar {
103141
return try call.value()
104142
}
105143

106-
}
144+
}

Web3Swift/Network/AlchemyNetwork.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public final class AlchemyNetwork: Network {
2323
- apiKey: api key for accessing JSON RPC calls
2424
*/
2525
public init(chain: String, apiKey: String) {
26-
origin = GethNetwork(url: "https://eth-"+chain.lowercased()+".alchemyapi.io/jsonrpc/"+apiKey)
26+
origin = GethNetwork(url: "https://eth-"+chain.lowercased()+".alchemyapi.io/v2/"+apiKey)
2727
}
2828

2929
/**

Web3Swift/PrivateKey/EthPrivateKey.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import CryptoSwift
1212
import Foundation
13-
import secp256k1_ios
13+
import secp256k1
1414

1515
private final class InvalidPrivateKeyError: DescribedError {
1616

Web3Swift/SECP256k1/SECP256k1Signature.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import CryptoSwift
1212
import Foundation
13-
import secp256k1_ios
13+
import secp256k1
1414

1515
public final class SigningError: DescribedError {
1616

Web3Swift/TransactionBytes/EthContractCallBytes.swift

+34-5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,40 @@ public final class EthContractCallBytes: BytesScalar {
6666
contractAddress: BytesScalar,
6767
weiAmount: BytesScalar,
6868
functionCall: BytesScalar
69+
) {
70+
let gasPrice = CachedBytes(
71+
origin: EthGasPrice(
72+
network: network
73+
)
74+
)
75+
self.init(
76+
network: network,
77+
gasPrice: gasPrice,
78+
senderKey: senderKey,
79+
contractAddress: contractAddress,
80+
weiAmount: weiAmount,
81+
functionCall: functionCall
82+
)
83+
}
84+
85+
/**
86+
Ctor
87+
88+
- parameters:
89+
- network: network where transaction is to be deployed
90+
- gasPrice: gas price in Wei
91+
- senderKey: private key of a sender
92+
- contractAddress: address of the recipient contract
93+
- weiAmount: amount to be sent in wei
94+
- functionCall: encoded function call
95+
*/
96+
public convenience init(
97+
network: Network,
98+
gasPrice: BytesScalar,
99+
senderKey: PrivateKey,
100+
contractAddress: BytesScalar,
101+
weiAmount: BytesScalar,
102+
functionCall: BytesScalar
69103
) {
70104
let senderAddress = CachedBytes(
71105
origin: SimpleBytes{
@@ -75,11 +109,6 @@ public final class EthContractCallBytes: BytesScalar {
75109
let contractAddress = CachedBytes(
76110
origin: contractAddress
77111
)
78-
let gasPrice = CachedBytes(
79-
origin: EthGasPrice(
80-
network: network
81-
)
82-
)
83112
let functionCall = CachedBytes(
84113
origin: functionCall
85114
)

Web3Swift/TransactionLogs/EthTransactionLog.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public final class EthTransactionLog: TransactionLog {
5252

5353
public func index() throws -> EthNumber {
5454
return try EthNumber(
55-
hex: log["transactionLogIndex"].string()
55+
hex: log["logIndex"].string()
5656
)
5757
}
5858

0 commit comments

Comments
 (0)