From 73a2defba7c03eaebc7142886612e180753d3380 Mon Sep 17 00:00:00 2001 From: cat Date: Tue, 18 Jun 2024 14:58:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20add=20network=20=E2=80=98testnet-mi?= =?UTF-8?q?gration=E2=80=99=20=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Models/FlowChainId.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/Models/FlowChainId.swift b/Sources/Models/FlowChainId.swift index 0445a4b..cfa849a 100644 --- a/Sources/Models/FlowChainId.swift +++ b/Sources/Models/FlowChainId.swift @@ -33,7 +33,8 @@ public extension Flow { /// Default gRPC node is `access.devnet.nodes.onflow.org:9000` /// HTTP node `https://rest-mainnet.onflow.org/` case testnet - + + case testnetMigration /// Canarynet enviroment /// Default node is `access.canary.nodes.onflow.org:9000` case canarynet @@ -55,7 +56,7 @@ public extension Flow { case custom(name: String, transport: Flow.Transport) /// List of other type chain id exclude custom type - public static var allCases: [Flow.ChainID] = [.mainnet, .testnet, .canarynet, .crescendo,.previewnet, .emulator] + public static var allCases: [Flow.ChainID] = [.mainnet, .testnet, .testnetMigration, .canarynet, .crescendo,.previewnet, .emulator] /// Name of the chain id public var name: String { @@ -64,6 +65,8 @@ public extension Flow { return "mainnet" case .testnet: return "testnet" + case .testnetMigration: + return "testnet-migration" case .crescendo: return "crescendo" case .previewnet: @@ -100,6 +103,8 @@ public extension Flow { return .HTTP(URL(string: "https://rest-mainnet.onflow.org/")!) case .testnet: return .HTTP(URL(string: "https://rest-testnet.onflow.org/")!) + case .testnetMigration: + return .HTTP(URL(string: "https://rest-migrationtestnet.onflow.org/v1/")!) case .emulator: return .HTTP(URL(string: "http://127.0.0.1:8888/")!) case .crescendo: @@ -120,6 +125,8 @@ public extension Flow { return .gRPC(.init(node: "access.mainnet.nodes.onflow.org", port: 9000)) case .testnet: return .gRPC(.init(node: "access.devnet.nodes.onflow.org", port: 9000)) + case .testnetMigration: + return .gRPC(.init(node: "access.devnet.nodes.onflow.org", port: 9000)) case .canarynet: return .gRPC(.init(node: "access.canary.nodes.onflow.org", port: 9000)) case .crescendo: From a2c15f10e298b62f6fd7c19d0c7fd5fc7d815151 Mon Sep 17 00:00:00 2001 From: cat Date: Tue, 18 Jun 2024 15:35:40 +0800 Subject: [PATCH 2/2] fix: wrap nil --- Tests/FlowAccessAPIOnMainnetTests.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tests/FlowAccessAPIOnMainnetTests.swift b/Tests/FlowAccessAPIOnMainnetTests.swift index 67fb0a9..274a18a 100644 --- a/Tests/FlowAccessAPIOnMainnetTests.swift +++ b/Tests/FlowAccessAPIOnMainnetTests.swift @@ -231,8 +231,11 @@ final class FlowAccessAPIOnMainnetTests: XCTestCase { let id: UInt64 let from: String } - - let test: TestType = try result.events.first!.payload.decode() + guard let event = result.events.first else { + + return + } + let test: TestType = try event.payload.decode() XCTAssertEqual(result.events.first?.payload.fields?.type, .event) XCTAssertEqual(test.id, 11800)