Skip to content

Commit a49f771

Browse files
fix: EIP681 - when parsing arguments chain ID must be defaulted to Mainnet instead of 0
1 parent 15f7770 commit a49f771

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/web3swift/Utils/EIP/EIP681.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ extension Web3 {
289289
guard let rawValue = comp.value,
290290
let functionArgument = await parseFunctionArgument(inputType,
291291
rawValue.trimmingCharacters(in: .whitespacesAndNewlines),
292-
chainID: code.chainID ?? 0,
292+
chainID: code.chainID,
293293
inputNumber: inputNumber)
294294
else { continue }
295295

@@ -348,7 +348,7 @@ extension Web3 {
348348

349349
private static func parseFunctionArgument(_ inputType: ABI.Element.ParameterType,
350350
_ rawValue: String,
351-
chainID: BigUInt,
351+
chainID: BigUInt? = Networks.Mainnet.chainID,
352352
inputNumber: Int) async -> FunctionArgument? {
353353
var nativeValue: Any?
354354
switch inputType {
@@ -359,7 +359,7 @@ extension Web3 {
359359
nativeValue = ethereumAddress
360360
case .ensAddress(let ens):
361361
do {
362-
let web = await Web3(provider: InfuraProvider(Networks.fromInt(UInt(chainID)) ?? Networks.Mainnet)!)
362+
let web = await Web3(provider: InfuraProvider(chainID == nil ? .Mainnet : .fromInt(UInt(chainID!)))!)
363363
let ensModel = ENS(web3: web)
364364
try await ensModel?.setENSResolver(withDomain: ens)
365365
let address = try await ensModel?.getAddress(forNode: ens)

0 commit comments

Comments
 (0)