Skip to content

Commit 20bfa7a

Browse files
committed
add missing test contract bytecode
1 parent 5c3652b commit 20bfa7a

File tree

4 files changed

+66
-90
lines changed

4 files changed

+66
-90
lines changed

Sources/web3swift/Web3/Web3+HttpProvider.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ public class Web3HttpProvider: Web3Provider {
3333
if let net = net {
3434
network = net
3535
} else {
36-
let response: UInt = try await APIRequest.send(APIRequest.getNetwork.call, parameter: [], with: self).result
37-
self.network = Networks.fromInt(response)
36+
/// chain id could be a hex string or an int value.
37+
let response: String = try await APIRequest.send(APIRequest.getNetwork.call, parameter: [], with: self).result
38+
let result: UInt
39+
if response.hasHexPrefix() {
40+
result = UInt(BigUInt(response, radix: 16) ?? Networks.Mainnet.chainID)
41+
} else {
42+
result = UInt(response) ?? UInt(Networks.Mainnet.chainID)
43+
}
44+
self.network = Networks.fromInt(result)
3845
}
3946
attachedKeystoreManager = manager
4047
}

0 commit comments

Comments
 (0)