From c93a1224ba565725079e754501d42fdf9946ed8e Mon Sep 17 00:00:00 2001 From: lmcmz Date: Mon, 20 Sep 2021 16:27:44 +1000 Subject: [PATCH] Restructure the SDK --- CODE_OF_CONDUCT.md | 128 ++ Package.resolved => FCL/Package.resolved | 32 +- FCL/Package.swift | 34 + FCL/README.md | 3 + .../FCL}/Address/AddressRegistry.swift | 47 +- .../FCL}/Address/FlowScriptAddress.swift | 39 +- .../Sources/FCL}/Config/FlowConfig.swift | 2 +- FCL/Sources/FCL/Constants/Constants.swift | 12 + .../Sources/FCL}/CurrentUser/FlowUser.swift | 3 +- FCL/Sources/FCL/Error/FlowError.swift | 26 + .../Sources/FCL}/Extension/UI.swift | 0 {Sources/Flow => FCL/Sources/FCL}/Flow.swift | 52 +- .../Sources/FCL/Models}/AuthnRequest.swift | 0 .../Sources/FCL/Models}/AuthnResponse.swift | 2 +- .../FCL/Models}/PreAuthzResponse.swift | 2 +- .../Sources/FCL/Network}/FlowAPI.swift | 10 +- .../Sources/FCL}/UI/Extension.swift | 0 .../Sources/FCL}/UI/SafariWebView.swift | 2 +- FlowFoundation/Package.resolved | 88 + FlowFoundation/Package.swift | 35 + FlowFoundation/README.md | 3 + .../Foundation}/Build/TransactionBuild.swift | 0 .../Foundation/Constants/Constants.swift | 15 + .../Sources/Foundation}/Error/FlowError.swift | 0 .../Sources/Foundation/Extension/Data.swift | 107 + .../Foundation}/Extension/String.swift | 29 +- FlowFoundation/Sources/Foundation/Flow.swift | 43 + .../Foundation}/Models/Algorithm.swift | 0 .../Foundation}/Models/FlowAccount.swift | 6 +- .../Foundation/Models/FlowAddress.swift | 31 + .../Foundation}/Models/FlowArgument.swift | 0 .../Foundation}/Models/FlowBlock.swift | 22 +- .../Foundation}/Models/FlowCadence.swift | 0 .../Foundation}/Models/FlowChainId.swift | 4 +- .../Foundation}/Models/FlowCollection.swift | 8 +- .../Foundation/Models/FlowDomainTag.swift | 23 + .../Foundation/Models/FlowEntity.swift | 26 + .../Foundation}/Models/FlowEvent.swift | 22 +- .../Sources/Foundation/Models/FlowId.swift | 26 + .../Foundation/Models/FlowScript.swift | 36 + .../Foundation/Models/FlowSignature.swift | 25 + .../Foundation}/Models/FlowTransaction.swift | 40 +- .../Sources/Foundation/Models/Signer.swift | 53 + .../Foundation/Network}/FlowAccessAPI.swift | 14 +- .../Network}/FlowAccessProtocol.swift | 0 .../Protobuf/Access/access.grpc.swift | 996 ++++++++++ .../Protobuf/Access/access.pb.swift | 1665 ++++++++++++++++ .../Protobuf/Entities/account.pb.swift | 193 ++ .../Protobuf/Entities/block.pb.swift | 127 ++ .../Protobuf/Entities/block_header.pb.swift | 103 + .../Protobuf/Entities/block_seal.pb.swift | 93 + .../Protobuf/Entities/collection.pb.swift | 129 ++ .../Protobuf/Entities/event.pb.swift | 101 + .../Protobuf/Entities/transaction.pb.swift | 329 +++ .../Protobuf/Execution/execution.grpc.swift | 302 +++ .../Protobuf/Execution/execution.pb.swift | 559 ++++++ .../Sources/Foundation}/RLP/RLP.swift | 0 .../Tests}/CadenceTypeTest.swift | 2 +- .../Tests}/FlowAPITests.swift | 2 +- .../Tests}/FlowAccessAPITests.swift | 12 +- .../Tests}/RLPTests.swift | 4 +- .../proto}/access/access.proto | 0 .../proto}/entities/account.proto | 0 .../proto}/entities/block.proto | 0 .../proto}/entities/block_header.proto | 0 .../proto}/entities/block_seal.proto | 0 .../proto}/entities/collection.proto | 0 .../proto}/entities/event.proto | 0 .../proto}/entities/transaction.proto | 0 .../proto}/execution/execution.proto | 0 LICENSE | 21 + Package.swift | 38 +- README.md | 89 +- Sources/Flow/Constants/Constants.swift | 15 - Sources/Flow/Extension/Data.swift | 77 - Sources/Flow/Models/BytesHolder.swift | 26 - Sources/Flow/Models/DomainTag.swift | 32 - Sources/Flow/Models/FlowAddress.swift | 27 - Sources/Flow/Models/FlowId.swift | 22 - Sources/Flow/Models/FlowScript.swift | 39 - Sources/Flow/Models/FlowSignature.swift | 22 - Sources/Flow/Models/Signer.swift | 49 - .../Flow/Protobuf/Access/access.grpc.swift | 999 ---------- Sources/Flow/Protobuf/Access/access.pb.swift | 1661 ---------------- .../Flow/Protobuf/Entities/account.pb.swift | 193 -- Sources/Flow/Protobuf/Entities/block.pb.swift | 126 -- .../Protobuf/Entities/block_header.pb.swift | 102 - .../Protobuf/Entities/block_seal.pb.swift | 93 - .../Protobuf/Entities/collection.pb.swift | 129 -- Sources/Flow/Protobuf/Entities/event.pb.swift | 101 - .../Protobuf/Entities/transaction.pb.swift | 329 --- .../Protobuf/Execution/execution.grpc.swift | 305 --- .../Protobuf/Execution/execution.pb.swift | 560 ------ WalletKit/.gitignore | 93 + WalletKit/CODE_OF_CONDUCT.md | 128 ++ WalletKit/File | 29 + WalletKit/LICENSE | 21 + WalletKit/Package.swift | 56 + WalletKit/README.md | 88 + WalletKit/Sources/Example/examples.swift | 40 + .../Sources/FlowAccess/Resources/README.md | 27 + .../flow-grpc/access/access.grpc.swift | 1042 ++++++++++ .../flow-grpc/execution/execution.grpc.swift | 302 +++ .../FlowAccess/flow-pb/access/access.pb.swift | 1763 +++++++++++++++++ .../flow-pb/entities/account.pb.swift | 193 ++ .../flow-pb/entities/block.pb.swift | 127 ++ .../flow-pb/entities/block_header.pb.swift | 103 + .../flow-pb/entities/block_seal.pb.swift | 93 + .../flow-pb/entities/collection.pb.swift | 129 ++ .../flow-pb/entities/event.pb.swift | 101 + .../entities/execution_result.pb.swift | 244 +++ .../flow-pb/entities/transaction.pb.swift | 329 +++ .../flow-pb/execution/execution.pb.swift | 559 ++++++ .../Client/FlowClient+Account.swift | 15 + .../Client/FlowClient+Blocks.swift | 31 + .../Client/FlowClient+Collection.swift | 7 + .../Client/FlowClient+Events.swift | 21 + .../Client/FlowClient+Script.swift | 15 + .../Client/FlowClient+Transaction.swift | 73 + .../FlowWalletKit/Client/FlowClient.swift | 143 ++ .../FlowClient+Account+Promise.swift | 43 + .../FlowClient+Blocks+Promise.swift | 95 + .../FlowClient+Collection+Promise.swift | 17 + .../FlowClient+Events+Promise.swift | 30 + .../ClientPromise/FlowClient+Promise.swift | 17 + .../FlowClient+Script+Promise.swift | 43 + .../FlowClient+Transaction+Promise.swift | 75 + .../FlowWalletKit/Crypto/AppleKeychain.swift | 77 + .../FlowWalletKit/Crypto/FlowKeychain.swift | 41 + .../FlowWalletKit/Crypto/MemoryKeychain.swift | 46 + .../Sources/FlowWalletKit/Crypto/RLP.swift | 298 +++ .../FlowWalletKit/Crypto/Signature_P256.swift | 36 + .../Crypto/Signature_secp256k1.swift | 23 + .../Crypto/TransactionSigner.swift | 93 + .../FlowWalletKit/Network/FlowRpcClient.swift | 41 + .../Network/Grpc/FlowGrpcClient.swift | 293 +++ .../Network/Grpc/FlowTypes+Grpc.swift | 185 ++ .../Network/Grpc/Transport+Grpc.swift | 36 + .../FlowWalletKit/Types/CadenceTypes.swift | 675 +++++++ .../FlowWalletKit/Types/FlowTypes.swift | 377 ++++ WalletKit/Sources/FlowWalletKit/Utils.swift | 71 + .../FlowClientTests+Blocks.swift | 48 + .../FlowClientTests+Collections.swift | 69 + .../FlowClientTests+Events.swift | 54 + .../FlowSwiftTests/FlowClientTests.swift | 28 + WalletKit/Tests/FlowSwiftTests/Types.swift | 5 + 146 files changed, 14206 insertions(+), 5104 deletions(-) create mode 100644 CODE_OF_CONDUCT.md rename Package.resolved => FCL/Package.resolved (73%) create mode 100644 FCL/Package.swift create mode 100644 FCL/README.md rename {Sources/Flow => FCL/Sources/FCL}/Address/AddressRegistry.swift (59%) rename {Sources/Flow => FCL/Sources/FCL}/Address/FlowScriptAddress.swift (54%) rename {Sources/Flow => FCL/Sources/FCL}/Config/FlowConfig.swift (98%) create mode 100644 FCL/Sources/FCL/Constants/Constants.swift rename {Sources/Flow => FCL/Sources/FCL}/CurrentUser/FlowUser.swift (90%) create mode 100644 FCL/Sources/FCL/Error/FlowError.swift rename {Sources/Flow => FCL/Sources/FCL}/Extension/UI.swift (100%) rename {Sources/Flow => FCL/Sources/FCL}/Flow.swift (72%) rename {Sources/Flow/Models/Network => FCL/Sources/FCL/Models}/AuthnRequest.swift (100%) rename {Sources/Flow/Models/Network => FCL/Sources/FCL/Models}/AuthnResponse.swift (99%) rename {Sources/Flow/Models/Network => FCL/Sources/FCL/Models}/PreAuthzResponse.swift (93%) rename {Sources/Flow/Network/Http => FCL/Sources/FCL/Network}/FlowAPI.swift (96%) rename {Sources/Flow => FCL/Sources/FCL}/UI/Extension.swift (100%) rename {Sources/Flow => FCL/Sources/FCL}/UI/SafariWebView.swift (98%) create mode 100644 FlowFoundation/Package.resolved create mode 100644 FlowFoundation/Package.swift create mode 100644 FlowFoundation/README.md rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Build/TransactionBuild.swift (100%) create mode 100644 FlowFoundation/Sources/Foundation/Constants/Constants.swift rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Error/FlowError.swift (100%) create mode 100644 FlowFoundation/Sources/Foundation/Extension/Data.swift rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Extension/String.swift (56%) create mode 100644 FlowFoundation/Sources/Foundation/Flow.swift rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Models/Algorithm.swift (100%) rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Models/FlowAccount.swift (92%) create mode 100644 FlowFoundation/Sources/Foundation/Models/FlowAddress.swift rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Models/FlowArgument.swift (100%) rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Models/FlowBlock.swift (73%) rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Models/FlowCadence.swift (100%) rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Models/FlowChainId.swift (94%) rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Models/FlowCollection.swift (77%) create mode 100644 FlowFoundation/Sources/Foundation/Models/FlowDomainTag.swift create mode 100644 FlowFoundation/Sources/Foundation/Models/FlowEntity.swift rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Models/FlowEvent.swift (69%) create mode 100644 FlowFoundation/Sources/Foundation/Models/FlowId.swift create mode 100644 FlowFoundation/Sources/Foundation/Models/FlowScript.swift create mode 100644 FlowFoundation/Sources/Foundation/Models/FlowSignature.swift rename {Sources/Flow => FlowFoundation/Sources/Foundation}/Models/FlowTransaction.swift (94%) create mode 100644 FlowFoundation/Sources/Foundation/Models/Signer.swift rename {Sources/Flow/Network/gRPC => FlowFoundation/Sources/Foundation/Network}/FlowAccessAPI.swift (96%) rename {Sources/Flow/Network/gRPC => FlowFoundation/Sources/Foundation/Network}/FlowAccessProtocol.swift (100%) create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Access/access.grpc.swift create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Access/access.pb.swift create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Entities/account.pb.swift create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Entities/block.pb.swift create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Entities/block_header.pb.swift create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Entities/block_seal.pb.swift create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Entities/collection.pb.swift create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Entities/event.pb.swift create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Entities/transaction.pb.swift create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Execution/execution.grpc.swift create mode 100644 FlowFoundation/Sources/Foundation/Protobuf/Execution/execution.pb.swift rename {Sources/Flow => FlowFoundation/Sources/Foundation}/RLP/RLP.swift (100%) rename {Tests => FlowFoundation/Tests}/CadenceTypeTest.swift (99%) rename {Tests => FlowFoundation/Tests}/FlowAPITests.swift (96%) rename {Tests => FlowFoundation/Tests}/FlowAccessAPITests.swift (95%) rename {Tests => FlowFoundation/Tests}/RLPTests.swift (99%) rename {proto => FlowFoundation/proto}/access/access.proto (100%) rename {proto => FlowFoundation/proto}/entities/account.proto (100%) rename {proto => FlowFoundation/proto}/entities/block.proto (100%) rename {proto => FlowFoundation/proto}/entities/block_header.proto (100%) rename {proto => FlowFoundation/proto}/entities/block_seal.proto (100%) rename {proto => FlowFoundation/proto}/entities/collection.proto (100%) rename {proto => FlowFoundation/proto}/entities/event.proto (100%) rename {proto => FlowFoundation/proto}/entities/transaction.proto (100%) rename {proto => FlowFoundation/proto}/execution/execution.proto (100%) create mode 100644 LICENSE delete mode 100644 Sources/Flow/Constants/Constants.swift delete mode 100644 Sources/Flow/Extension/Data.swift delete mode 100644 Sources/Flow/Models/BytesHolder.swift delete mode 100644 Sources/Flow/Models/DomainTag.swift delete mode 100644 Sources/Flow/Models/FlowAddress.swift delete mode 100644 Sources/Flow/Models/FlowId.swift delete mode 100644 Sources/Flow/Models/FlowScript.swift delete mode 100644 Sources/Flow/Models/FlowSignature.swift delete mode 100644 Sources/Flow/Models/Signer.swift delete mode 100644 Sources/Flow/Protobuf/Access/access.grpc.swift delete mode 100644 Sources/Flow/Protobuf/Access/access.pb.swift delete mode 100644 Sources/Flow/Protobuf/Entities/account.pb.swift delete mode 100644 Sources/Flow/Protobuf/Entities/block.pb.swift delete mode 100644 Sources/Flow/Protobuf/Entities/block_header.pb.swift delete mode 100644 Sources/Flow/Protobuf/Entities/block_seal.pb.swift delete mode 100644 Sources/Flow/Protobuf/Entities/collection.pb.swift delete mode 100644 Sources/Flow/Protobuf/Entities/event.pb.swift delete mode 100644 Sources/Flow/Protobuf/Entities/transaction.pb.swift delete mode 100644 Sources/Flow/Protobuf/Execution/execution.grpc.swift delete mode 100644 Sources/Flow/Protobuf/Execution/execution.pb.swift create mode 100644 WalletKit/.gitignore create mode 100644 WalletKit/CODE_OF_CONDUCT.md create mode 100644 WalletKit/File create mode 100644 WalletKit/LICENSE create mode 100644 WalletKit/Package.swift create mode 100644 WalletKit/README.md create mode 100644 WalletKit/Sources/Example/examples.swift create mode 100644 WalletKit/Sources/FlowAccess/Resources/README.md create mode 100644 WalletKit/Sources/FlowAccess/flow-grpc/access/access.grpc.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-grpc/execution/execution.grpc.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-pb/access/access.pb.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-pb/entities/account.pb.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-pb/entities/block.pb.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-pb/entities/block_header.pb.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-pb/entities/block_seal.pb.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-pb/entities/collection.pb.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-pb/entities/event.pb.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-pb/entities/execution_result.pb.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-pb/entities/transaction.pb.swift create mode 100644 WalletKit/Sources/FlowAccess/flow-pb/execution/execution.pb.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Client/FlowClient+Account.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Client/FlowClient+Blocks.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Client/FlowClient+Collection.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Client/FlowClient+Events.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Client/FlowClient+Script.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Client/FlowClient+Transaction.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Client/FlowClient.swift create mode 100644 WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Account+Promise.swift create mode 100644 WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Blocks+Promise.swift create mode 100644 WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Collection+Promise.swift create mode 100644 WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Events+Promise.swift create mode 100644 WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Promise.swift create mode 100644 WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Script+Promise.swift create mode 100644 WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Transaction+Promise.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Crypto/AppleKeychain.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Crypto/FlowKeychain.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Crypto/MemoryKeychain.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Crypto/RLP.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Crypto/Signature_P256.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Crypto/Signature_secp256k1.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Crypto/TransactionSigner.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Network/FlowRpcClient.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Network/Grpc/FlowGrpcClient.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Network/Grpc/FlowTypes+Grpc.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Network/Grpc/Transport+Grpc.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Types/CadenceTypes.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Types/FlowTypes.swift create mode 100644 WalletKit/Sources/FlowWalletKit/Utils.swift create mode 100644 WalletKit/Tests/FlowSwiftTests/FlowClientTests+Blocks.swift create mode 100644 WalletKit/Tests/FlowSwiftTests/FlowClientTests+Collections.swift create mode 100644 WalletKit/Tests/FlowSwiftTests/FlowClientTests+Events.swift create mode 100644 WalletKit/Tests/FlowSwiftTests/FlowClientTests.swift create mode 100644 WalletKit/Tests/FlowSwiftTests/Types.swift diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..d1f37d9 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +hello@ryankopinsky.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/Package.resolved b/FCL/Package.resolved similarity index 73% rename from Package.resolved rename to FCL/Package.resolved index bc5c79e..df9db38 100644 --- a/Package.resolved +++ b/FCL/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/swift-server/async-http-client.git", "state": { "branch": null, - "revision": "8e4d51908dd49272667126403bf977c5c503f78f", - "version": "1.5.0" + "revision": "8fa7f082b155ea325bcf7b2dbffaf81d4eea1ae4", + "version": "1.5.1" } }, { @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/attaswift/BigInt.git", "state": { "branch": null, - "revision": "889a1ecacd73ccc189c5cb29288048f186c44ed9", - "version": "5.2.1" + "revision": "0ed110f7555c34ff468e72e1686e59721f2b0da6", + "version": "5.3.0" } }, { @@ -24,8 +24,8 @@ "repositoryURL": "https://github.com/grpc/grpc-swift.git", "state": { "branch": null, - "revision": "14e1ea3350892a864386517c037e11fb68baf818", - "version": "1.3.0" + "revision": "66e27d7e84a2f51df6b8d5c4c3649639cfe478c1", + "version": "1.4.1" } }, { @@ -42,8 +42,8 @@ "repositoryURL": "https://github.com/apple/swift-nio.git", "state": { "branch": null, - "revision": "d79e33308b0ac83326b0ead0ea6446e604b8162d", - "version": "2.30.0" + "revision": "fb48bdd8279799f655da5f8b4e0a21430eca6012", + "version": "2.32.3" } }, { @@ -51,8 +51,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-extras.git", "state": { "branch": null, - "revision": "f72c4688f89c28502105509186eadc49a49cb922", - "version": "1.10.0" + "revision": "f73ca5ee9c6806800243f1ac415fcf82de9a4c91", + "version": "1.10.2" } }, { @@ -60,8 +60,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-http2.git", "state": { "branch": null, - "revision": "13b6a7a83864005334818d7ea2a3053869a96c04", - "version": "1.18.0" + "revision": "dbfc8fcd1a0cc4d7254a060501120d378e91f16c", + "version": "1.18.3" } }, { @@ -69,8 +69,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-ssl.git", "state": { "branch": null, - "revision": "9db7cee4b62c39160a6bd513a47a1ecdcceac18a", - "version": "2.14.0" + "revision": "77a3bf17884d2c87ba400f4d93b9a6f27b078651", + "version": "2.15.1" } }, { @@ -78,8 +78,8 @@ "repositoryURL": "https://github.com/apple/swift-nio-transport-services.git", "state": { "branch": null, - "revision": "39587bceccda72780e2a8a8c5e857e42a9df2fa8", - "version": "1.11.0" + "revision": "e7f5278a26442dc46783ba7e063643d524e414a0", + "version": "1.11.3" } }, { diff --git a/FCL/Package.swift b/FCL/Package.swift new file mode 100644 index 0000000..30c205e --- /dev/null +++ b/FCL/Package.swift @@ -0,0 +1,34 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "FCL", + platforms: [ + .iOS(.v13), + .macOS(.v10_15), + ], + products: [ + .library( + name: "FCL", + targets: ["FCL"] + ), + ], + dependencies: [ + .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.0.0"), + .package(path: "../FlowFoundation"), + ], + targets: [ + .target( + name: "FCL", + dependencies: ["FlowFoundation", + .product(name: "AsyncHTTPClient", package: "async-http-client")] + ), + .testTarget( + name: "FCLTests", + dependencies: ["FCL"], + path: "Tests" + ), + ] +) diff --git a/FCL/README.md b/FCL/README.md new file mode 100644 index 0000000..c0b3878 --- /dev/null +++ b/FCL/README.md @@ -0,0 +1,3 @@ +# flow + +A description of this package. diff --git a/Sources/Flow/Address/AddressRegistry.swift b/FCL/Sources/FCL/Address/AddressRegistry.swift similarity index 59% rename from Sources/Flow/Address/AddressRegistry.swift rename to FCL/Sources/FCL/Address/AddressRegistry.swift index 88f06d6..7988f64 100644 --- a/Sources/Flow/Address/AddressRegistry.swift +++ b/FCL/Sources/FCL/Address/AddressRegistry.swift @@ -5,6 +5,7 @@ // Created by lmcmz on 23/7/21. // +import FlowFoundation import Foundation public class AddressRegistry { @@ -19,31 +20,31 @@ public class AddressRegistry { func registerDefaults() { let addresses = [ Flow.ChainId.emulator: [ - Flow.ScriptAddress.fungibleToken, - Flow.ScriptAddress.flowToken, - Flow.ScriptAddress.flowFees, + FCL.ScriptAddress.fungibleToken, + FCL.ScriptAddress.flowToken, + FCL.ScriptAddress.flowFees, ], Flow.ChainId.testnet: [ - Flow.ScriptAddress.fungibleToken, - Flow.ScriptAddress.flowToken, - Flow.ScriptAddress.flowFees, - Flow.ScriptAddress.flowTablesTaking, - Flow.ScriptAddress.lockedTokens, - Flow.ScriptAddress.stakingProxy, - Flow.ScriptAddress.nonFungibleToken, + FCL.ScriptAddress.fungibleToken, + FCL.ScriptAddress.flowToken, + FCL.ScriptAddress.flowFees, + FCL.ScriptAddress.flowTablesTaking, + FCL.ScriptAddress.lockedTokens, + FCL.ScriptAddress.stakingProxy, + FCL.ScriptAddress.nonFungibleToken, ], Flow.ChainId.mainnet: [ - Flow.ScriptAddress.fungibleToken, - Flow.ScriptAddress.flowToken, - Flow.ScriptAddress.flowFees, - Flow.ScriptAddress.flowTablesTaking, - Flow.ScriptAddress.lockedTokens, - Flow.ScriptAddress.stakingProxy, - Flow.ScriptAddress.nonFungibleToken, + FCL.ScriptAddress.fungibleToken, + FCL.ScriptAddress.flowToken, + FCL.ScriptAddress.flowFees, + FCL.ScriptAddress.flowTablesTaking, + FCL.ScriptAddress.lockedTokens, + FCL.ScriptAddress.stakingProxy, + FCL.ScriptAddress.nonFungibleToken, ], ] - addresses.forEach { (chainId: Flow.ChainId, value: [Flow.ScriptAddress]) in + addresses.forEach { (chainId: Flow.ChainId, value: [FCL.ScriptAddress]) in value.forEach { scriptAddress in guard let address = scriptAddress.address(chain: chainId) else { return } register(chainId: chainId, contract: scriptAddress.rawValue, address: address) @@ -63,12 +64,12 @@ public class AddressRegistry { return processScript(script: script, chainId: defaultChainId) } - func processScript(script: String, chainId: Flow.ChainId) -> String { + func processScript(script: String, chainId _: Flow.ChainId) -> String { var ret = script - scriptTokenDict[chainId]?.forEach { - ret = ret.replacingOccurrences(of: $0.key, - with: $0.value.hexValue.addHexPrefix()) - } +// scriptTokenDict[chainId]?.forEach { +// ret = ret.replacingOccurrences(of: $0.key, +// with: $0.value.hexValue.addHexPrefix()) +// } return ret } diff --git a/Sources/Flow/Address/FlowScriptAddress.swift b/FCL/Sources/FCL/Address/FlowScriptAddress.swift similarity index 54% rename from Sources/Flow/Address/FlowScriptAddress.swift rename to FCL/Sources/FCL/Address/FlowScriptAddress.swift index d41bd41..07fb79a 100644 --- a/Sources/Flow/Address/FlowScriptAddress.swift +++ b/FCL/Sources/FCL/Address/FlowScriptAddress.swift @@ -5,9 +5,10 @@ // Created by lmcmz on 23/7/21. // +import FlowFoundation import Foundation -extension Flow { +extension FCL { enum ScriptAddress: String { case fungibleToken = "0xFUNGIBLETOKEN" case flowToken = "0xFLOWTOKEN" @@ -17,45 +18,45 @@ extension Flow { case stakingProxy = "0xSTAKINGPROXY" case nonFungibleToken = "0xNONFUNGIBLETOKEN" - func address(chain: ChainId) -> Address? { + func address(chain: Flow.ChainId) -> Flow.Address? { switch (self, chain) { // Mainnet case (.fungibleToken, .mainnet): - return Address(hex: "0xf233dcee88fe0abe") + return Flow.Address(hex: "0xf233dcee88fe0abe") case (.flowToken, .mainnet): - return Address(hex: "0x1654653399040a61") + return Flow.Address(hex: "0x1654653399040a61") case (.flowFees, .mainnet): - return Address(hex: "0xf919ee77447b7497") + return Flow.Address(hex: "0xf919ee77447b7497") case (.flowTablesTaking, .mainnet): - return Address(hex: "0x8624b52f9ddcd04a") + return Flow.Address(hex: "0x8624b52f9ddcd04a") case (.lockedTokens, .mainnet): - return Address(hex: "0x8d0e87b65159ae63") + return Flow.Address(hex: "0x8d0e87b65159ae63") case (.stakingProxy, .mainnet): - return Address(hex: "0x62430cf28c26d095") + return Flow.Address(hex: "0x62430cf28c26d095") case (.nonFungibleToken, .mainnet): - return Address(hex: "0x1d7e57aa55817448") + return Flow.Address(hex: "0x1d7e57aa55817448") // Testnet case (.fungibleToken, .testnet): - return Address(hex: "0x9a0766d93b6608b7") + return Flow.Address(hex: "0x9a0766d93b6608b7") case (.flowToken, .testnet): - return Address(hex: "0x7e60df042a9c0868") + return Flow.Address(hex: "0x7e60df042a9c0868") case (.flowFees, .testnet): - return Address(hex: "0x912d5440f7e3769e") + return Flow.Address(hex: "0x912d5440f7e3769e") case (.flowTablesTaking, .testnet): - return Address(hex: "0x9eca2b38b18b5dfe") + return Flow.Address(hex: "0x9eca2b38b18b5dfe") case (.lockedTokens, .testnet): - return Address(hex: "0x95e019a17d0e23d7") + return Flow.Address(hex: "0x95e019a17d0e23d7") case (.stakingProxy, .testnet): - return Address(hex: "0x7aad92e5a0715d21") + return Flow.Address(hex: "0x7aad92e5a0715d21") case (.nonFungibleToken, .testnet): - return Address(hex: "0x631e88ae7f1d7c20") + return Flow.Address(hex: "0x631e88ae7f1d7c20") // Emulator case (.fungibleToken, .emulator): - return Address(hex: "0xee82856bf20e2aa6") + return Flow.Address(hex: "0xee82856bf20e2aa6") case (.flowToken, .emulator): - return Address(hex: "0x0ae53cb6e3f42a79") + return Flow.Address(hex: "0x0ae53cb6e3f42a79") case (.flowFees, .emulator): - return Address(hex: "0xe5a8b7f23e8b548f") + return Flow.Address(hex: "0xe5a8b7f23e8b548f") default: return nil diff --git a/Sources/Flow/Config/FlowConfig.swift b/FCL/Sources/FCL/Config/FlowConfig.swift similarity index 98% rename from Sources/Flow/Config/FlowConfig.swift rename to FCL/Sources/FCL/Config/FlowConfig.swift index fb73eef..356a347 100644 --- a/Sources/Flow/Config/FlowConfig.swift +++ b/FCL/Sources/FCL/Config/FlowConfig.swift @@ -7,7 +7,7 @@ import Foundation -extension Flow { +extension FCL { public class Config { var dict = [String: String]() diff --git a/FCL/Sources/FCL/Constants/Constants.swift b/FCL/Sources/FCL/Constants/Constants.swift new file mode 100644 index 0000000..0044b25 --- /dev/null +++ b/FCL/Sources/FCL/Constants/Constants.swift @@ -0,0 +1,12 @@ +// +// File.swift +// +// +// Created by lmcmz on 14/9/21. +// + +import Foundation + +extension FCL { + class Constants {} +} diff --git a/Sources/Flow/CurrentUser/FlowUser.swift b/FCL/Sources/FCL/CurrentUser/FlowUser.swift similarity index 90% rename from Sources/Flow/CurrentUser/FlowUser.swift rename to FCL/Sources/FCL/CurrentUser/FlowUser.swift index f093813..cefb9e7 100644 --- a/Sources/Flow/CurrentUser/FlowUser.swift +++ b/FCL/Sources/FCL/CurrentUser/FlowUser.swift @@ -5,9 +5,10 @@ // Created by lmcmz on 5/9/21. // +import FlowFoundation import Foundation -extension Flow { +extension FCL { struct User: Codable { var fType: String = "USER" var fVsn: String = "1.0.0" diff --git a/FCL/Sources/FCL/Error/FlowError.swift b/FCL/Sources/FCL/Error/FlowError.swift new file mode 100644 index 0000000..e407cc0 --- /dev/null +++ b/FCL/Sources/FCL/Error/FlowError.swift @@ -0,0 +1,26 @@ +// +// File.swift +// +// +// Created by lmcmz on 29/8/21. +// + +import Foundation + +extension FCL { + public enum FError: String, Error { + case generic + case urlEmpty + case urlInvaild + case declined + case encodeFailure + case decodeFailure + case unauthenticated + } +} + +extension FCL.FError: LocalizedError { + public var errorDescription: String? { + return rawValue + } +} diff --git a/Sources/Flow/Extension/UI.swift b/FCL/Sources/FCL/Extension/UI.swift similarity index 100% rename from Sources/Flow/Extension/UI.swift rename to FCL/Sources/FCL/Extension/UI.swift diff --git a/Sources/Flow/Flow.swift b/FCL/Sources/FCL/Flow.swift similarity index 72% rename from Sources/Flow/Flow.swift rename to FCL/Sources/FCL/Flow.swift index f99343d..17b83eb 100644 --- a/Sources/Flow/Flow.swift +++ b/FCL/Sources/FCL/Flow.swift @@ -1,21 +1,20 @@ import AuthenticationServices import Combine -import GRPC -import NIO +import FlowFoundation import SafariServices -public final class Flow { - public static let shared = Flow() +public final class FCL { + public static let shared = FCL() - public var config = Flow.Config() + public var config = FCL.Config() - @Published var currentUser: Flow.User? = nil + @Published var currentUser: User? = nil private let api = API() internal let defaultUserAgent = "Flow SWIFT SDK" - internal var defaultChainId = ChainId.mainnet + internal var defaultChainId = Flow.ChainId.mainnet private lazy var defaultAddressRegistry = AddressRegistry() @@ -145,11 +144,11 @@ public final class Flow { // MARK: - Util - private func buildUser(authn: AuthnResponse) -> Flow.User? { + private func buildUser(authn: AuthnResponse) -> User? { guard let address = authn.data?.addr else { return nil } - return Flow.User(addr: Flow.Address(hex: address), - loggedIn: true, - services: authn.data?.services) + return User(addr: Flow.Address(hex: address), + loggedIn: true, + services: authn.data?.services) } private func serviceOfType(services: [Service]?, type: Service.Name) -> Service? { @@ -157,35 +156,4 @@ public final class Flow { service.type == type }) } - - // MARK: - AccessAPI - - func configureDefaults(chainId: ChainId, addressRegistry: AddressRegistry) { - defaultChainId = chainId - defaultAddressRegistry = addressRegistry - } - - func newAccessApi(chainId: ChainId) -> FlowAccessAPI? { - guard let networkNode = chainId.defaultNode else { - return nil - } - return newAccessApi(host: networkNode.gRPCNode, port: networkNode.port) - } - - func newAccessApi(host: String, port: Int = 9000, secure: Bool = false) -> FlowAccessAPI { - let config = channelConfig(host: host, port: port, secure: secure, userAgent: defaultUserAgent) - return FlowAccessAPI(config: config) - } - - func newAccessApi(host: String, port: Int = 9000, secure: Bool = false, userAgent: String) -> FlowAccessAPI { - let config = channelConfig(host: host, port: port, secure: secure, userAgent: userAgent) - return FlowAccessAPI(config: config) - } - - func channelConfig(host: String, port: Int, secure _: Bool, userAgent _: String) -> ClientConnection.Configuration { - // TODO: add secure and userAgent - let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount) - return ClientConnection.Configuration.default(target: ConnectionTarget.hostAndPort(host, port), - eventLoopGroup: eventLoopGroup) - } } diff --git a/Sources/Flow/Models/Network/AuthnRequest.swift b/FCL/Sources/FCL/Models/AuthnRequest.swift similarity index 100% rename from Sources/Flow/Models/Network/AuthnRequest.swift rename to FCL/Sources/FCL/Models/AuthnRequest.swift diff --git a/Sources/Flow/Models/Network/AuthnResponse.swift b/FCL/Sources/FCL/Models/AuthnResponse.swift similarity index 99% rename from Sources/Flow/Models/Network/AuthnResponse.swift rename to FCL/Sources/FCL/Models/AuthnResponse.swift index 7f77d6d..a33046b 100644 --- a/Sources/Flow/Models/Network/AuthnResponse.swift +++ b/FCL/Sources/FCL/Models/AuthnResponse.swift @@ -7,7 +7,7 @@ import Foundation -extension Flow { +extension FCL { public struct AuthnResponse: Codable { public let fType: String public let fVsn: String diff --git a/Sources/Flow/Models/Network/PreAuthzResponse.swift b/FCL/Sources/FCL/Models/PreAuthzResponse.swift similarity index 93% rename from Sources/Flow/Models/Network/PreAuthzResponse.swift rename to FCL/Sources/FCL/Models/PreAuthzResponse.swift index 42ec2d3..ac85df4 100644 --- a/Sources/Flow/Models/Network/PreAuthzResponse.swift +++ b/FCL/Sources/FCL/Models/PreAuthzResponse.swift @@ -7,7 +7,7 @@ import Foundation -extension Flow { +extension FCL { public struct PreAuthzResponse: Codable { public let fType: String public let fVsn: String diff --git a/Sources/Flow/Network/Http/FlowAPI.swift b/FCL/Sources/FCL/Network/FlowAPI.swift similarity index 96% rename from Sources/Flow/Network/Http/FlowAPI.swift rename to FCL/Sources/FCL/Network/FlowAPI.swift index b877267..843dec3 100644 --- a/Sources/Flow/Network/Http/FlowAPI.swift +++ b/FCL/Sources/FCL/Network/FlowAPI.swift @@ -7,12 +7,14 @@ import AsyncHTTPClient import Combine +import FlowFoundation import Foundation import NIO import NIOHTTP1 -extension Flow { +extension FCL { public class API { + internal let defaultUserAgent = "Flow SWIFT SDK" private var cancellables = Set() let client = HTTPClient(eventLoopGroupProvider: .createNew) @@ -27,7 +29,7 @@ extension Flow { promise.fail(Flow.FError.urlInvaild) return promise.futureResult } - request.headers.add(name: "User-Agent", value: Flow.shared.defaultUserAgent) + request.headers.add(name: "User-Agent", value: defaultUserAgent) let call = client.execute(request: request) call.whenSuccess { response in @@ -56,7 +58,7 @@ extension Flow { promise.fail(Flow.FError.urlInvaild) return promise.futureResult } - request.headers.add(name: "User-Agent", value: Flow.shared.defaultUserAgent) + request.headers.add(name: "User-Agent", value: defaultUserAgent) let call = client.execute(request: request) call.whenSuccess { response in @@ -177,7 +179,7 @@ func decodeToModel(body: ByteBuffer?) -> T? { return model } -extension Flow.Service.Method { +extension FCL.Service.Method { var http: HTTPMethod? { switch self { case .get: diff --git a/Sources/Flow/UI/Extension.swift b/FCL/Sources/FCL/UI/Extension.swift similarity index 100% rename from Sources/Flow/UI/Extension.swift rename to FCL/Sources/FCL/UI/Extension.swift diff --git a/Sources/Flow/UI/SafariWebView.swift b/FCL/Sources/FCL/UI/SafariWebView.swift similarity index 98% rename from Sources/Flow/UI/SafariWebView.swift rename to FCL/Sources/FCL/UI/SafariWebView.swift index 76a1562..b0d6f84 100644 --- a/Sources/Flow/UI/SafariWebView.swift +++ b/FCL/Sources/FCL/UI/SafariWebView.swift @@ -8,7 +8,7 @@ import Foundation import SafariServices -extension Flow { +extension FCL { class SafariWebViewManager: NSObject, SFSafariViewControllerDelegate { static var shared = SafariWebViewManager() var safariVC: SFSafariViewController? diff --git a/FlowFoundation/Package.resolved b/FlowFoundation/Package.resolved new file mode 100644 index 0000000..bf1a975 --- /dev/null +++ b/FlowFoundation/Package.resolved @@ -0,0 +1,88 @@ +{ + "object": { + "pins": [ + { + "package": "BigInt", + "repositoryURL": "https://github.com/attaswift/BigInt.git", + "state": { + "branch": null, + "revision": "0ed110f7555c34ff468e72e1686e59721f2b0da6", + "version": "5.3.0" + } + }, + { + "package": "grpc-swift", + "repositoryURL": "https://github.com/grpc/grpc-swift.git", + "state": { + "branch": null, + "revision": "66e27d7e84a2f51df6b8d5c4c3649639cfe478c1", + "version": "1.4.1" + } + }, + { + "package": "swift-log", + "repositoryURL": "https://github.com/apple/swift-log.git", + "state": { + "branch": null, + "revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7", + "version": "1.4.2" + } + }, + { + "package": "swift-nio", + "repositoryURL": "https://github.com/apple/swift-nio.git", + "state": { + "branch": null, + "revision": "fb48bdd8279799f655da5f8b4e0a21430eca6012", + "version": "2.32.3" + } + }, + { + "package": "swift-nio-extras", + "repositoryURL": "https://github.com/apple/swift-nio-extras.git", + "state": { + "branch": null, + "revision": "f73ca5ee9c6806800243f1ac415fcf82de9a4c91", + "version": "1.10.2" + } + }, + { + "package": "swift-nio-http2", + "repositoryURL": "https://github.com/apple/swift-nio-http2.git", + "state": { + "branch": null, + "revision": "dbfc8fcd1a0cc4d7254a060501120d378e91f16c", + "version": "1.18.3" + } + }, + { + "package": "swift-nio-ssl", + "repositoryURL": "https://github.com/apple/swift-nio-ssl.git", + "state": { + "branch": null, + "revision": "77a3bf17884d2c87ba400f4d93b9a6f27b078651", + "version": "2.15.1" + } + }, + { + "package": "swift-nio-transport-services", + "repositoryURL": "https://github.com/apple/swift-nio-transport-services.git", + "state": { + "branch": null, + "revision": "e7f5278a26442dc46783ba7e063643d524e414a0", + "version": "1.11.3" + } + }, + { + "package": "SwiftProtobuf", + "repositoryURL": "https://github.com/apple/swift-protobuf.git", + "state": { + "branch": null, + "revision": "1f62db409f2c9b0223a3f68567b4a01333aae778", + "version": "1.17.0" + } + } + ] + }, + "version": 1 +} diff --git a/FlowFoundation/Package.swift b/FlowFoundation/Package.swift new file mode 100644 index 0000000..5bb4a6d --- /dev/null +++ b/FlowFoundation/Package.swift @@ -0,0 +1,35 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "FlowFoundation", + platforms: [ + .iOS(.v13), + .macOS(.v10_15), + ], + products: [ + .library( + name: "FlowFoundation", + targets: ["FlowFoundation"] + ), + ], + dependencies: [ + .package(name: "BigInt", url: "https://github.com/attaswift/BigInt.git", from: "5.2.1"), + .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.0.0"), + ], + targets: [ + .target( + name: "FlowFoundation", + dependencies: ["BigInt", + .product(name: "GRPC", package: "grpc-swift")], + path: "Sources/Foundation" + ), + .testTarget( + name: "FlowFoundationTests", + dependencies: ["FlowFoundation"], + path: "Tests" + ), + ] +) diff --git a/FlowFoundation/README.md b/FlowFoundation/README.md new file mode 100644 index 0000000..c0b3878 --- /dev/null +++ b/FlowFoundation/README.md @@ -0,0 +1,3 @@ +# flow + +A description of this package. diff --git a/Sources/Flow/Build/TransactionBuild.swift b/FlowFoundation/Sources/Foundation/Build/TransactionBuild.swift similarity index 100% rename from Sources/Flow/Build/TransactionBuild.swift rename to FlowFoundation/Sources/Foundation/Build/TransactionBuild.swift diff --git a/FlowFoundation/Sources/Foundation/Constants/Constants.swift b/FlowFoundation/Sources/Foundation/Constants/Constants.swift new file mode 100644 index 0000000..d315d82 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Constants/Constants.swift @@ -0,0 +1,15 @@ +// +// File.swift +// +// +// Created by lmcmz on 14/9/21. +// + +import Foundation + +extension Flow { + class Constants { + internal static let transactionPrefix = DomainTag.transaction.normalize.hexValue + internal static let userPrefix = DomainTag.user.normalize.hexValue + } +} diff --git a/Sources/Flow/Error/FlowError.swift b/FlowFoundation/Sources/Foundation/Error/FlowError.swift similarity index 100% rename from Sources/Flow/Error/FlowError.swift rename to FlowFoundation/Sources/Foundation/Error/FlowError.swift diff --git a/FlowFoundation/Sources/Foundation/Extension/Data.swift b/FlowFoundation/Sources/Foundation/Extension/Data.swift new file mode 100644 index 0000000..8fc83ee --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Extension/Data.swift @@ -0,0 +1,107 @@ +// +// Data.swift +// +// +// Created by lmcmz on 19/7/21. +// + +import Foundation + +// extension Sequence where Element == UInt8 { +// } + +extension Array where Element == UInt8 { + var data: Data { .init(self) } + public var hexValue: String { map { .init(format: "%02x", $0) }.joined() } + + public mutating func padZeroLeft(blockSize: Int) -> [UInt8] { + while count < blockSize { + insert(0, at: 0) + } + return self + } + + public mutating func padZeroRight(blockSize: Int) -> [UInt8] { + while count < blockSize { + append(0) + } + return self + } + + public func paddingZeroLeft(blockSize: Int) -> [UInt8] { + var bytes = self + while bytes.count < blockSize { + bytes.insert(0, at: 0) + } + return bytes + } + + public func paddingZeroRight(blockSize: Int) -> [UInt8] { + var bytes = self + while bytes.count < blockSize { + bytes.append(0) + } + return bytes + } +} + +extension Data { + var bytes: Bytes { + return Bytes(self) + } + + static func fromHex(_ hex: String) -> Data? { + let string = hex.lowercased().stripHexPrefix() + guard let array = string.data(using: .utf8)?.bytes else { + return nil + } + if array.count == 0 { + if hex == "0x" || hex == "" { + return Data() + } else { + return nil + } + } + return array.data + } + + var hexValue: String { + return reduce("") { $0 + String(format: "%02x", $1) } + } + + public mutating func padZeroLeft(blockSize: Int) -> Data { + while count < blockSize { + insert(0, at: 0) + } + return self + } + + public mutating func padZeroRight(blockSize: Int) -> Data { + while count < blockSize { + append(0) + } + return self + } + + public func paddingZeroLeft(blockSize: Int) -> Data { + var bytes = self + while bytes.count < blockSize { + bytes.insert(0, at: 0) + } + return bytes + } + + public func paddingZeroRight(blockSize: Int) -> Data { + var bytes = self + while bytes.count < blockSize { + bytes.append(0) + } + return bytes + } +} + +extension Array where Iterator.Element: Hashable { + var hashValue: Int { + return reduce(1) { $0.hashValue ^ $1.hashValue } + } +} diff --git a/Sources/Flow/Extension/String.swift b/FlowFoundation/Sources/Foundation/Extension/String.swift similarity index 56% rename from Sources/Flow/Extension/String.swift rename to FlowFoundation/Sources/Foundation/Extension/String.swift index 5ee9b56..cf1a143 100644 --- a/Sources/Flow/Extension/String.swift +++ b/FlowFoundation/Sources/Foundation/Extension/String.swift @@ -8,11 +8,11 @@ import Foundation extension String { - var byteArray: [UInt8] { + var bytes: [UInt8] { guard let result = Data.fromHex(self) else { return [UInt8]() } - return result.byteArray + return result.bytes } var hexValue: [UInt8] { @@ -23,9 +23,30 @@ extension String { return UInt8(self[startIndex ... endIndex], radix: 16) } } -} -extension String { + enum ExtendedEncoding { + case hexadecimal + } + + func data(using _: ExtendedEncoding) -> Data? { + let hexString = dropFirst(hasPrefix("0x") ? 2 : 0) + + guard hexString.count % 2 == 0 else { return nil } + + var data = Data(capacity: hexString.count / 2) + + var indexIsEven = true + for i in hexString.indices { + if indexIsEven { + let byteRange = i ... hexString.index(after: i) + guard let byte = UInt8(hexString[byteRange], radix: 16) else { return nil } + data.append(byte) + } + indexIsEven.toggle() + } + return data + } + func hasHexPrefix() -> Bool { return hasPrefix("0x") } diff --git a/FlowFoundation/Sources/Foundation/Flow.swift b/FlowFoundation/Sources/Foundation/Flow.swift new file mode 100644 index 0000000..e7a57c2 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Flow.swift @@ -0,0 +1,43 @@ +import AuthenticationServices +import Combine +import GRPC +import NIO +import SafariServices + +public final class Flow { + public static let shared = Flow() + + internal let defaultUserAgent = "Flow SWIFT SDK" + + internal var defaultChainId = ChainId.mainnet + + // MARK: - AccessAPI + + func configureDefaults(chainId: ChainId) { + defaultChainId = chainId + } + + func newAccessApi(chainId: ChainId) -> FlowAccessAPI? { + guard let networkNode = chainId.defaultNode else { + return nil + } + return newAccessApi(host: networkNode.gRPCNode, port: networkNode.port) + } + + func newAccessApi(host: String, port: Int = 9000, secure: Bool = false) -> FlowAccessAPI { + let config = channelConfig(host: host, port: port, secure: secure, userAgent: defaultUserAgent) + return FlowAccessAPI(config: config) + } + + func newAccessApi(host: String, port: Int = 9000, secure: Bool = false, userAgent: String) -> FlowAccessAPI { + let config = channelConfig(host: host, port: port, secure: secure, userAgent: userAgent) + return FlowAccessAPI(config: config) + } + + func channelConfig(host: String, port: Int, secure _: Bool, userAgent _: String) -> ClientConnection.Configuration { + // TODO: add secure and userAgent + let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount) + return ClientConnection.Configuration.default(target: ConnectionTarget.hostAndPort(host, port), + eventLoopGroup: eventLoopGroup) + } +} diff --git a/Sources/Flow/Models/Algorithm.swift b/FlowFoundation/Sources/Foundation/Models/Algorithm.swift similarity index 100% rename from Sources/Flow/Models/Algorithm.swift rename to FlowFoundation/Sources/Foundation/Models/Algorithm.swift diff --git a/Sources/Flow/Models/FlowAccount.swift b/FlowFoundation/Sources/Foundation/Models/FlowAccount.swift similarity index 92% rename from Sources/Flow/Models/FlowAccount.swift rename to FlowFoundation/Sources/Foundation/Models/FlowAccount.swift index cf47cce..4ec2a93 100644 --- a/Sources/Flow/Models/FlowAccount.swift +++ b/FlowFoundation/Sources/Foundation/Models/FlowAccount.swift @@ -16,10 +16,10 @@ extension Flow { var contracts: [String: Code] init(value: Flow_Entities_Account) { - address = Address(bytes: value.address.byteArray) + address = Address(bytes: value.address.bytes) balance = BigInt(value.balance) keys = value.keys.compactMap { AccountKey(value: $0) } - contracts = value.contracts.compactMapValues { Code(bytes: $0.byteArray) } + contracts = value.contracts.compactMapValues { Code(data: $0) } } } @@ -34,7 +34,7 @@ extension Flow { init(value: Flow_Entities_AccountKey) { id = Int(value.index) - publicKey = PublicKey(bytes: value.publicKey.byteArray) + publicKey = PublicKey(bytes: value.publicKey.bytes) signAlgo = SignatureAlgorithm(code: Int(value.signAlgo)) hashAlgo = HashAlgorithm(code: Int(value.hashAlgo)) weight = Int(value.weight) diff --git a/FlowFoundation/Sources/Foundation/Models/FlowAddress.swift b/FlowFoundation/Sources/Foundation/Models/FlowAddress.swift new file mode 100644 index 0000000..4d5e29c --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Models/FlowAddress.swift @@ -0,0 +1,31 @@ +// +// FlowAddress.swift +// +// +// Created by lmcmz on 23/7/21. +// + +import Foundation + +extension Flow { + public struct Address: FlowEntity, Equatable, Hashable, Codable { + var data: Data + + public init(hex: String) { + data = hex.hexValue.data + } + + public init(data: Data) { + self.data = data + } + + internal init(bytes: [UInt8]) { + data = bytes.data + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(hex.addHexPrefix()) + } + } +} diff --git a/Sources/Flow/Models/FlowArgument.swift b/FlowFoundation/Sources/Foundation/Models/FlowArgument.swift similarity index 100% rename from Sources/Flow/Models/FlowArgument.swift rename to FlowFoundation/Sources/Foundation/Models/FlowArgument.swift diff --git a/Sources/Flow/Models/FlowBlock.swift b/FlowFoundation/Sources/Foundation/Models/FlowBlock.swift similarity index 73% rename from Sources/Flow/Models/FlowBlock.swift rename to FlowFoundation/Sources/Foundation/Models/FlowBlock.swift index a4783eb..487ca99 100644 --- a/Sources/Flow/Models/FlowBlock.swift +++ b/FlowFoundation/Sources/Foundation/Models/FlowBlock.swift @@ -14,14 +14,14 @@ extension Flow { let height: UInt64 init(value: Flow_Entities_Block) { - id = Id(bytes: value.id.byteArray) - parentId = Id(bytes: value.parentID.byteArray) + id = Id(bytes: value.id.bytes) + parentId = Id(bytes: value.parentID.bytes) height = value.height } init(value: Flow_Entities_BlockHeader) { - id = Id(bytes: value.id.byteArray) - parentId = Id(bytes: value.parentID.byteArray) + id = Id(bytes: value.id.bytes) + parentId = Id(bytes: value.parentID.bytes) height = value.height } } @@ -33,10 +33,10 @@ extension Flow { let resultApprovalSignatures: [Signature] init(value: Flow_Entities_BlockSeal) { - id = Id(bytes: value.blockID.byteArray) - executionReceiptId = Id(bytes: value.executionReceiptID.byteArray) - executionReceiptSignatures = value.executionReceiptSignatures.compactMap { Signature(bytes: $0.byteArray) } - resultApprovalSignatures = value.resultApprovalSignatures.compactMap { Signature(bytes: $0.byteArray) } + id = Id(bytes: value.blockID.bytes) + executionReceiptId = Id(bytes: value.executionReceiptID.bytes) + executionReceiptSignatures = value.executionReceiptSignatures.compactMap { Signature(data: $0) } + resultApprovalSignatures = value.resultApprovalSignatures.compactMap { Signature(data: $0) } } } @@ -50,13 +50,13 @@ extension Flow { var signatures: [Signature] init(value: Flow_Entities_Block) { - id = Id(bytes: value.id.byteArray) - parentId = Id(bytes: value.parentID.byteArray) + id = Id(bytes: value.id.bytes) + parentId = Id(bytes: value.parentID.bytes) height = value.height timestamp = value.timestamp.date collectionGuarantees = value.collectionGuarantees.compactMap { CollectionGuarantee(value: $0) } blockSeals = value.blockSeals.compactMap { BlockSeal(value: $0) } - signatures = value.signatures.compactMap { Signature(bytes: $0.byteArray) } + signatures = value.signatures.compactMap { Signature(data: $0) } } } } diff --git a/Sources/Flow/Models/FlowCadence.swift b/FlowFoundation/Sources/Foundation/Models/FlowCadence.swift similarity index 100% rename from Sources/Flow/Models/FlowCadence.swift rename to FlowFoundation/Sources/Foundation/Models/FlowCadence.swift diff --git a/Sources/Flow/Models/FlowChainId.swift b/FlowFoundation/Sources/Foundation/Models/FlowChainId.swift similarity index 94% rename from Sources/Flow/Models/FlowChainId.swift rename to FlowFoundation/Sources/Foundation/Models/FlowChainId.swift index d4c2f4d..c6a8c2c 100644 --- a/Sources/Flow/Models/FlowChainId.swift +++ b/FlowFoundation/Sources/Foundation/Models/FlowChainId.swift @@ -35,8 +35,8 @@ extension Flow { } } - init(id: String) { - self = ChainId.allCases.first { $0.name == id } ?? .unknown + init(name: String) { + self = ChainId.allCases.first { $0.name == name } ?? .unknown } public struct Endpoint: Hashable { diff --git a/Sources/Flow/Models/FlowCollection.swift b/FlowFoundation/Sources/Foundation/Models/FlowCollection.swift similarity index 77% rename from Sources/Flow/Models/FlowCollection.swift rename to FlowFoundation/Sources/Foundation/Models/FlowCollection.swift index cd1fe86..b26eda1 100644 --- a/Sources/Flow/Models/FlowCollection.swift +++ b/FlowFoundation/Sources/Foundation/Models/FlowCollection.swift @@ -13,8 +13,8 @@ extension Flow { let transactionIds: [Id] init(value: Flow_Entities_Collection) { - id = Id(bytes: value.id.byteArray) - transactionIds = value.transactionIds.compactMap { Id(bytes: $0.byteArray) } + id = Id(bytes: value.id.bytes) + transactionIds = value.transactionIds.compactMap { Id(bytes: $0.bytes) } } } @@ -23,8 +23,8 @@ extension Flow { let signatures: [Signature] init(value: Flow_Entities_CollectionGuarantee) { - id = Id(bytes: value.collectionID.byteArray) - signatures = value.signatures.compactMap { Signature(bytes: $0.byteArray) } + id = Id(bytes: value.collectionID.bytes) + signatures = value.signatures.compactMap { Signature(data: $0) } } } } diff --git a/FlowFoundation/Sources/Foundation/Models/FlowDomainTag.swift b/FlowFoundation/Sources/Foundation/Models/FlowDomainTag.swift new file mode 100644 index 0000000..85f37b1 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Models/FlowDomainTag.swift @@ -0,0 +1,23 @@ +// +// DomainTag.swift +// +// +// Created by lmcmz on 25/7/21. +// + +import Foundation + +extension Flow { + enum DomainTag: String { + case transaction = "FLOW-V0.0-transaction" + case user = "FLOW-V0.0-user" + + var normalize: Data { + guard let bytes = rawValue.data(using: .utf8) else { + return Data() + } + + return bytes.paddingZeroRight(blockSize: 32) + } + } +} diff --git a/FlowFoundation/Sources/Foundation/Models/FlowEntity.swift b/FlowFoundation/Sources/Foundation/Models/FlowEntity.swift new file mode 100644 index 0000000..68a0360 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Models/FlowEntity.swift @@ -0,0 +1,26 @@ +// +// BytesHolder.swift +// +// +// Created by lmcmz on 21/7/21. +// + +import Foundation + +typealias Bytes = [UInt8] + +protocol FlowEntity { + var data: Data { get set } + var bytes: Bytes { get } + var hex: String { get } +} + +extension FlowEntity { + var bytes: Bytes { + data.bytes + } + + var hex: String { + bytes.hexValue + } +} diff --git a/Sources/Flow/Models/FlowEvent.swift b/FlowFoundation/Sources/Foundation/Models/FlowEvent.swift similarity index 69% rename from Sources/Flow/Models/FlowEvent.swift rename to FlowFoundation/Sources/Foundation/Models/FlowEvent.swift index 82cf091..84dc1f3 100644 --- a/Sources/Flow/Models/FlowEvent.swift +++ b/FlowFoundation/Sources/Foundation/Models/FlowEvent.swift @@ -17,10 +17,10 @@ extension Flow { init(value: Flow_Entities_Event) { type = value.type - transactionId = Id(bytes: value.transactionID.byteArray) + transactionId = Id(bytes: value.transactionID.bytes) transactionIndex = Int(value.transactionIndex) eventIndex = Int(value.eventIndex) - payload = EventPayload(bytes: value.payload.byteArray) + payload = EventPayload(bytes: value.payload.bytes) } } @@ -31,24 +31,28 @@ extension Flow { var events: [Event] init(value: Flow_Access_EventsResponse.Result) { - blockId = Id(bytes: value.blockID.byteArray) + blockId = Id(bytes: value.blockID.bytes) blockHeight = value.blockHeight blockTimestamp = value.blockTimestamp.date events = value.events.compactMap { Event(value: $0) } } } - struct Snapshot: BytesHolder, Equatable { - var bytes: ByteArray + struct Snapshot: FlowEntity, Equatable { + var data: Data } - struct EventPayload: BytesHolder { - var bytes: [UInt8] + struct EventPayload: FlowEntity { + var data: Data var fields: Flow.Argument? + init(data: Data) { + self.data = data + fields = try? JSONDecoder().decode(Flow.Argument.self, from: data) + } + init(bytes: [UInt8]) { - self.bytes = bytes - fields = try? JSONDecoder().decode(Flow.Argument.self, from: bytes.data) + self.init(data: bytes.data) } } } diff --git a/FlowFoundation/Sources/Foundation/Models/FlowId.swift b/FlowFoundation/Sources/Foundation/Models/FlowId.swift new file mode 100644 index 0000000..f35a72a --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Models/FlowId.swift @@ -0,0 +1,26 @@ +// +// File.swift +// +// +// Created by lmcmz on 27/7/21. +// + +import Foundation + +extension Flow { + struct Id: FlowEntity, Equatable, Hashable { + var data: Data + + public init(hex: String) { + data = hex.hexValue.data + } + + init(data: Data) { + self.data = data + } + + init(bytes: [UInt8]) { + data = bytes.data + } + } +} diff --git a/FlowFoundation/Sources/Foundation/Models/FlowScript.swift b/FlowFoundation/Sources/Foundation/Models/FlowScript.swift new file mode 100644 index 0000000..31068b5 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Models/FlowScript.swift @@ -0,0 +1,36 @@ +// +// FlowScript.swift +// +// +// Created by lmcmz on 23/7/21. +// + +import Foundation + +extension Flow { + struct Script: FlowEntity, Equatable { + var data: Data + + init(script: String) { + data = script.data(using: .utf8) ?? Data() + } + + init(data: Data) { + self.data = data + } + + init(bytes: [UInt8]) { + data = bytes.data + } + } + + struct ScriptResponse: FlowEntity, Equatable { + var data: Data + var fields: Argument? + + init(data: Data) { + self.data = data + fields = try? JSONDecoder().decode(Flow.Argument.self, from: data) + } + } +} diff --git a/FlowFoundation/Sources/Foundation/Models/FlowSignature.swift b/FlowFoundation/Sources/Foundation/Models/FlowSignature.swift new file mode 100644 index 0000000..5575767 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Models/FlowSignature.swift @@ -0,0 +1,25 @@ +// +// File.swift +// +// +// Created by lmcmz on 5/9/21. +// + +import Foundation + +extension Flow { + struct Signature: FlowEntity, Equatable { + var data: Data + var bytes: [UInt8] { + data.bytes + } + + public init(data: Data) { + self.data = data + } + + public init(hex: String) { + data = hex.hexValue.data + } + } +} diff --git a/Sources/Flow/Models/FlowTransaction.swift b/FlowFoundation/Sources/Foundation/Models/FlowTransaction.swift similarity index 94% rename from Sources/Flow/Models/FlowTransaction.swift rename to FlowFoundation/Sources/Foundation/Models/FlowTransaction.swift index ba5bffe..fda1be2 100644 --- a/Sources/Flow/Models/FlowTransaction.swift +++ b/FlowFoundation/Sources/Foundation/Models/FlowTransaction.swift @@ -33,13 +33,13 @@ extension Flow { } init(value: Flow_Entities_Transaction) { - script = Script(bytes: value.script.byteArray) + script = Script(bytes: value.script.bytes) arguments = value.arguments.compactMap { try! JSONDecoder().decode(Argument.self, from: $0) } - referenceBlockId = Id(bytes: value.referenceBlockID.byteArray) + referenceBlockId = Id(bytes: value.referenceBlockID.bytes) gasLimit = BigUInt(value.gasLimit) proposalKey = TransactionProposalKey(value: value.proposalKey) - payerAddress = Address(bytes: value.payer.byteArray) - authorizers = value.authorizers.compactMap { Address(bytes: $0.byteArray) } + payerAddress = Address(bytes: value.payer.bytes) + authorizers = value.authorizers.compactMap { Address(bytes: $0.bytes) } payloadSignatures = value.payloadSignatures.compactMap { TransactionSignature(value: $0) } envelopeSignatures = value.envelopeSignatures.compactMap { TransactionSignature(value: $0) } } @@ -104,7 +104,7 @@ extension Flow { return payloadSignatures .map { sig in TransactionSignature(address: sig.address, - signerIndex: signers[sig.address.stringValue] ?? 0, + signerIndex: signers[sig.address.hex] ?? 0, keyIndex: sig.keyIndex, signature: sig.signature) } @@ -128,9 +128,9 @@ extension Flow { i += 1 } } - addSigner(address: proposalKey.address.stringValue) - addSigner(address: payerAddress.stringValue) - authorizers.forEach { addSigner(address: $0.stringValue) } + addSigner(address: proposalKey.address.hex) + addSigner(address: payerAddress.hex) + authorizers.forEach { addSigner(address: $0.hex) } return signer } @@ -163,9 +163,9 @@ extension Flow { // signature: $0.signature.bytes) // }) // } -// var canonicalPayload: ByteArray? { +// var canonicalPayload: bytes? { // // TODO: Need fix this, RLP not support encode object -// RLP.encode(payload)?.byteArray +// RLP.encode(payload)?.bytes // } // var signerList: [Address] { // var ret = [Address]() @@ -282,15 +282,15 @@ extension Flow.Transaction { extension Flow { internal struct Payload { - let script: ByteArray - let arguments: [ByteArray] - let referenceBlockId: ByteArray + let script: Bytes + let arguments: [Bytes] + let referenceBlockId: Bytes let gasLimit: BigUInt - let proposalKeyAddress: ByteArray + let proposalKeyAddress: Bytes let proposalKeyIndex: Int let proposalKeySequenceNumber: BigUInt - let payer: ByteArray - let authorizers: [ByteArray] + let payer: Bytes + let authorizers: [Bytes] } internal struct PayloadEnvelope { @@ -301,7 +301,7 @@ extension Flow { internal struct EnvelopeSignature { let signerIndex: Int let keyIndex: Int - let signature: ByteArray + let signature: Bytes } internal struct PaymentEnvelope { @@ -342,7 +342,7 @@ extension Flow { } init(value: Flow_Entities_Transaction.ProposalKey) { - address = Address(bytes: value.address.byteArray) + address = Address(bytes: value.address.bytes) keyIndex = Int(value.keyID) sequenceNumber = BigUInt(value.sequenceNumber) } @@ -363,9 +363,9 @@ extension Flow { let signature: Signature init(value: Flow_Entities_Transaction.Signature) { - address = Address(bytes: value.address.byteArray) + address = Address(bytes: value.address.bytes) keyIndex = Int(value.keyID) - signature = Signature(bytes: value.signature.byteArray) + signature = Signature(data: value.signature) signerIndex = Int(value.keyID) } diff --git a/FlowFoundation/Sources/Foundation/Models/Signer.swift b/FlowFoundation/Sources/Foundation/Models/Signer.swift new file mode 100644 index 0000000..b834c52 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Models/Signer.swift @@ -0,0 +1,53 @@ +// +// Signer.swift +// +// +// Created by lmcmz on 21/7/21. +// + +import Foundation + +protocol FlowSigner { + var hasher: Hasher { get set } + + func sign(bytes: Bytes) -> Bytes + + func signWithDomain(bytes: Bytes, domain: Bytes) -> Bytes + + func signAsUser(bytes: Bytes) -> Bytes + + func signAsTransaction(bytes: Bytes) -> Bytes +} + +protocol FlowHasher { + func hash(bytes: Bytes) -> Bytes + func hashAsHexString(bytes: Bytes) -> String +} + +extension FlowHasher { + func hashAsHexString(bytes: Bytes) -> String { + return hash(bytes: bytes).hexValue + } +} + +extension Flow { + struct PublicKey: FlowEntity, Equatable { + var data: Data + + init(hex: String) { + data = hex.hexValue.data + } + + init(data: Data) { + self.data = data + } + + init(bytes: [UInt8]) { + data = bytes.data + } + } + + struct Code: FlowEntity, Equatable { + var data: Data + } +} diff --git a/Sources/Flow/Network/gRPC/FlowAccessAPI.swift b/FlowFoundation/Sources/Foundation/Network/FlowAccessAPI.swift similarity index 96% rename from Sources/Flow/Network/gRPC/FlowAccessAPI.swift rename to FlowFoundation/Sources/Foundation/Network/FlowAccessAPI.swift index 5629a77..0b79fee 100644 --- a/Sources/Flow/Network/gRPC/FlowAccessAPI.swift +++ b/FlowFoundation/Sources/Foundation/Network/FlowAccessAPI.swift @@ -9,7 +9,7 @@ import Foundation import GRPC import NIO -open class FlowAccessAPI: FlowAccessProtocol { +final class FlowAccessAPI: FlowAccessProtocol { var clientChannel: ClientConnection var accessClient: Flow_Access_AccessAPIClient @@ -172,7 +172,7 @@ open class FlowAccessAPI: FlowAccessProtocol { accessClient.sendTransaction(request).response.whenComplete { result in switch result { case let .success(response): - let entity = Flow.Id(bytes: response.id.byteArray) + let entity = Flow.Id(bytes: response.id.bytes) promise.succeed(entity) case let .failure(error): promise.fail(error) @@ -266,7 +266,7 @@ open class FlowAccessAPI: FlowAccessProtocol { accessClient.executeScriptAtLatestBlock(request).response.whenComplete { result in switch result { case let .success(response): - let entity = Flow.ScriptResponse(bytes: response.value.byteArray) + let entity = Flow.ScriptResponse(data: response.value) promise.succeed(entity) case let .failure(error): promise.fail(error) @@ -283,7 +283,7 @@ open class FlowAccessAPI: FlowAccessProtocol { accessClient.executeScriptAtBlockID(request).response.whenComplete { result in switch result { case let .success(response): - let entity = Flow.ScriptResponse(bytes: response.value.byteArray) + let entity = Flow.ScriptResponse(data: response.value) promise.succeed(entity) case let .failure(error): promise.fail(error) @@ -301,7 +301,7 @@ open class FlowAccessAPI: FlowAccessProtocol { accessClient.executeScriptAtBlockHeight(request).response.whenComplete { result in switch result { case let .success(response): - let entity = Flow.ScriptResponse(bytes: response.value.byteArray) + let entity = Flow.ScriptResponse(data: response.value) promise.succeed(entity) case let .failure(error): promise.fail(error) @@ -351,7 +351,7 @@ open class FlowAccessAPI: FlowAccessProtocol { accessClient.getNetworkParameters(request).response.whenComplete { result in switch result { case let .success(response): - let entity = Flow.ChainId(id: response.chainID) + let entity = Flow.ChainId(name: response.chainID) promise.succeed(entity) case let .failure(error): promise.fail(error) @@ -366,7 +366,7 @@ open class FlowAccessAPI: FlowAccessProtocol { accessClient.getLatestProtocolStateSnapshot(request).response.whenComplete { result in switch result { case let .success(response): - let entity = Flow.Snapshot(bytes: response.serializedSnapshot.byteArray) + let entity = Flow.Snapshot(data: response.serializedSnapshot) promise.succeed(entity) case let .failure(error): promise.fail(error) diff --git a/Sources/Flow/Network/gRPC/FlowAccessProtocol.swift b/FlowFoundation/Sources/Foundation/Network/FlowAccessProtocol.swift similarity index 100% rename from Sources/Flow/Network/gRPC/FlowAccessProtocol.swift rename to FlowFoundation/Sources/Foundation/Network/FlowAccessProtocol.swift diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Access/access.grpc.swift b/FlowFoundation/Sources/Foundation/Protobuf/Access/access.grpc.swift new file mode 100644 index 0000000..4430ea7 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Access/access.grpc.swift @@ -0,0 +1,996 @@ +// +// DO NOT EDIT. +// +// Generated by the protocol buffer compiler. +// Source: flow/access/access.proto +// + +// +// Copyright 2018, gRPC Authors All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +import GRPC +import NIO +import SwiftProtobuf + +/// AccessAPI is the public-facing API provided by access nodes. +/// +/// Usage: instantiate `Flow_Access_AccessAPIClient`, then call methods of this protocol to make API calls. +public protocol Flow_Access_AccessAPIClientProtocol: GRPCClient { + var serviceName: String { get } + var interceptors: Flow_Access_AccessAPIClientInterceptorFactoryProtocol? { get } + + func ping( + _ request: Flow_Access_PingRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getLatestBlockHeader( + _ request: Flow_Access_GetLatestBlockHeaderRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getBlockHeaderByID( + _ request: Flow_Access_GetBlockHeaderByIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getBlockHeaderByHeight( + _ request: Flow_Access_GetBlockHeaderByHeightRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getLatestBlock( + _ request: Flow_Access_GetLatestBlockRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getBlockByID( + _ request: Flow_Access_GetBlockByIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getBlockByHeight( + _ request: Flow_Access_GetBlockByHeightRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getCollectionByID( + _ request: Flow_Access_GetCollectionByIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func sendTransaction( + _ request: Flow_Access_SendTransactionRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getTransaction( + _ request: Flow_Access_GetTransactionRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getTransactionResult( + _ request: Flow_Access_GetTransactionRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getAccount( + _ request: Flow_Access_GetAccountRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getAccountAtLatestBlock( + _ request: Flow_Access_GetAccountAtLatestBlockRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getAccountAtBlockHeight( + _ request: Flow_Access_GetAccountAtBlockHeightRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func executeScriptAtLatestBlock( + _ request: Flow_Access_ExecuteScriptAtLatestBlockRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func executeScriptAtBlockID( + _ request: Flow_Access_ExecuteScriptAtBlockIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func executeScriptAtBlockHeight( + _ request: Flow_Access_ExecuteScriptAtBlockHeightRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getEventsForHeightRange( + _ request: Flow_Access_GetEventsForHeightRangeRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getEventsForBlockIDs( + _ request: Flow_Access_GetEventsForBlockIDsRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getNetworkParameters( + _ request: Flow_Access_GetNetworkParametersRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getLatestProtocolStateSnapshot( + _ request: Flow_Access_GetLatestProtocolStateSnapshotRequest, + callOptions: CallOptions? + ) -> UnaryCall +} + +extension Flow_Access_AccessAPIClientProtocol { + public var serviceName: String { + return "flow.access.AccessAPI" + } + + /// Ping is used to check if the access node is alive and healthy. + /// + /// - Parameters: + /// - request: Request to send to Ping. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func ping( + _ request: Flow_Access_PingRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/Ping", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makePingInterceptors() ?? [] + ) + } + + /// GetLatestBlockHeader gets the latest sealed or unsealed block header. + /// + /// - Parameters: + /// - request: Request to send to GetLatestBlockHeader. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getLatestBlockHeader( + _ request: Flow_Access_GetLatestBlockHeaderRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetLatestBlockHeader", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetLatestBlockHeaderInterceptors() ?? [] + ) + } + + /// GetBlockHeaderByID gets a block header by ID. + /// + /// - Parameters: + /// - request: Request to send to GetBlockHeaderByID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getBlockHeaderByID( + _ request: Flow_Access_GetBlockHeaderByIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetBlockHeaderByID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetBlockHeaderByIDInterceptors() ?? [] + ) + } + + /// GetBlockHeaderByHeight gets a block header by height. + /// + /// - Parameters: + /// - request: Request to send to GetBlockHeaderByHeight. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getBlockHeaderByHeight( + _ request: Flow_Access_GetBlockHeaderByHeightRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetBlockHeaderByHeight", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetBlockHeaderByHeightInterceptors() ?? [] + ) + } + + /// GetLatestBlock gets the full payload of the latest sealed or unsealed + /// block. + /// + /// - Parameters: + /// - request: Request to send to GetLatestBlock. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getLatestBlock( + _ request: Flow_Access_GetLatestBlockRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetLatestBlock", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetLatestBlockInterceptors() ?? [] + ) + } + + /// GetBlockByID gets a full block by ID. + /// + /// - Parameters: + /// - request: Request to send to GetBlockByID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getBlockByID( + _ request: Flow_Access_GetBlockByIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetBlockByID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetBlockByIDInterceptors() ?? [] + ) + } + + /// GetBlockByHeight gets a full block by height. + /// + /// - Parameters: + /// - request: Request to send to GetBlockByHeight. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getBlockByHeight( + _ request: Flow_Access_GetBlockByHeightRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetBlockByHeight", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetBlockByHeightInterceptors() ?? [] + ) + } + + /// GetCollectionByID gets a collection by ID. + /// + /// - Parameters: + /// - request: Request to send to GetCollectionByID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getCollectionByID( + _ request: Flow_Access_GetCollectionByIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetCollectionByID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetCollectionByIDInterceptors() ?? [] + ) + } + + /// SendTransaction submits a transaction to the network. + /// + /// - Parameters: + /// - request: Request to send to SendTransaction. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func sendTransaction( + _ request: Flow_Access_SendTransactionRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/SendTransaction", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeSendTransactionInterceptors() ?? [] + ) + } + + /// GetTransaction gets a transaction by ID. + /// + /// - Parameters: + /// - request: Request to send to GetTransaction. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getTransaction( + _ request: Flow_Access_GetTransactionRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetTransaction", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetTransactionInterceptors() ?? [] + ) + } + + /// GetTransactionResult gets the result of a transaction. + /// + /// - Parameters: + /// - request: Request to send to GetTransactionResult. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getTransactionResult( + _ request: Flow_Access_GetTransactionRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetTransactionResult", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetTransactionResultInterceptors() ?? [] + ) + } + + /// GetAccount is an alias for GetAccountAtLatestBlock. + /// + /// Warning: this function is deprecated. It behaves identically to + /// GetAccountAtLatestBlock and will be removed in a future version. + /// + /// - Parameters: + /// - request: Request to send to GetAccount. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getAccount( + _ request: Flow_Access_GetAccountRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetAccount", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetAccountInterceptors() ?? [] + ) + } + + /// GetAccountAtLatestBlock gets an account by address from the latest sealed + /// execution state. + /// + /// - Parameters: + /// - request: Request to send to GetAccountAtLatestBlock. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getAccountAtLatestBlock( + _ request: Flow_Access_GetAccountAtLatestBlockRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetAccountAtLatestBlock", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetAccountAtLatestBlockInterceptors() ?? [] + ) + } + + /// GetAccountAtBlockHeight gets an account by address at the given block + /// height + /// + /// - Parameters: + /// - request: Request to send to GetAccountAtBlockHeight. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getAccountAtBlockHeight( + _ request: Flow_Access_GetAccountAtBlockHeightRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetAccountAtBlockHeight", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetAccountAtBlockHeightInterceptors() ?? [] + ) + } + + /// ExecuteScriptAtLatestBlock executes a read-only Cadence script against the + /// latest sealed execution state. + /// + /// - Parameters: + /// - request: Request to send to ExecuteScriptAtLatestBlock. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func executeScriptAtLatestBlock( + _ request: Flow_Access_ExecuteScriptAtLatestBlockRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/ExecuteScriptAtLatestBlock", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeExecuteScriptAtLatestBlockInterceptors() ?? [] + ) + } + + /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the + /// execution state at the block with the given ID. + /// + /// - Parameters: + /// - request: Request to send to ExecuteScriptAtBlockID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func executeScriptAtBlockID( + _ request: Flow_Access_ExecuteScriptAtBlockIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/ExecuteScriptAtBlockID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [] + ) + } + + /// ExecuteScriptAtBlockHeight executes a ready-only Cadence script against the + /// execution state at the given block height. + /// + /// - Parameters: + /// - request: Request to send to ExecuteScriptAtBlockHeight. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func executeScriptAtBlockHeight( + _ request: Flow_Access_ExecuteScriptAtBlockHeightRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/ExecuteScriptAtBlockHeight", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeExecuteScriptAtBlockHeightInterceptors() ?? [] + ) + } + + /// GetEventsForHeightRange retrieves events emitted within the specified block + /// range. + /// + /// - Parameters: + /// - request: Request to send to GetEventsForHeightRange. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getEventsForHeightRange( + _ request: Flow_Access_GetEventsForHeightRangeRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetEventsForHeightRange", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetEventsForHeightRangeInterceptors() ?? [] + ) + } + + /// GetEventsForBlockIDs retrieves events for the specified block IDs and event + /// type. + /// + /// - Parameters: + /// - request: Request to send to GetEventsForBlockIDs. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getEventsForBlockIDs( + _ request: Flow_Access_GetEventsForBlockIDsRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetEventsForBlockIDs", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [] + ) + } + + /// GetNetworkParameters retrieves the Flow network details + /// + /// - Parameters: + /// - request: Request to send to GetNetworkParameters. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getNetworkParameters( + _ request: Flow_Access_GetNetworkParametersRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetNetworkParameters", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetNetworkParametersInterceptors() ?? [] + ) + } + + /// GetLatestProtocolStateSnapshot retrieves the latest sealed protocol state + /// snapshot. Used by Flow nodes joining the network to bootstrap a + /// space-efficient local state. + /// + /// - Parameters: + /// - request: Request to send to GetLatestProtocolStateSnapshot. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getLatestProtocolStateSnapshot( + _ request: Flow_Access_GetLatestProtocolStateSnapshotRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetLatestProtocolStateSnapshot", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetLatestProtocolStateSnapshotInterceptors() ?? [] + ) + } +} + +public protocol Flow_Access_AccessAPIClientInterceptorFactoryProtocol { + /// - Returns: Interceptors to use when invoking 'ping'. + func makePingInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getLatestBlockHeader'. + func makeGetLatestBlockHeaderInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getBlockHeaderByID'. + func makeGetBlockHeaderByIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getBlockHeaderByHeight'. + func makeGetBlockHeaderByHeightInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getLatestBlock'. + func makeGetLatestBlockInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getBlockByID'. + func makeGetBlockByIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getBlockByHeight'. + func makeGetBlockByHeightInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getCollectionByID'. + func makeGetCollectionByIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'sendTransaction'. + func makeSendTransactionInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getTransaction'. + func makeGetTransactionInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getTransactionResult'. + func makeGetTransactionResultInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getAccount'. + func makeGetAccountInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getAccountAtLatestBlock'. + func makeGetAccountAtLatestBlockInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getAccountAtBlockHeight'. + func makeGetAccountAtBlockHeightInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'executeScriptAtLatestBlock'. + func makeExecuteScriptAtLatestBlockInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'executeScriptAtBlockID'. + func makeExecuteScriptAtBlockIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'executeScriptAtBlockHeight'. + func makeExecuteScriptAtBlockHeightInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getEventsForHeightRange'. + func makeGetEventsForHeightRangeInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getEventsForBlockIDs'. + func makeGetEventsForBlockIDsInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getNetworkParameters'. + func makeGetNetworkParametersInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getLatestProtocolStateSnapshot'. + func makeGetLatestProtocolStateSnapshotInterceptors() -> [ClientInterceptor] +} + +public final class Flow_Access_AccessAPIClient: Flow_Access_AccessAPIClientProtocol { + public let channel: GRPCChannel + public var defaultCallOptions: CallOptions + public var interceptors: Flow_Access_AccessAPIClientInterceptorFactoryProtocol? + + /// Creates a client for the flow.access.AccessAPI service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + /// - interceptors: A factory providing interceptors for each RPC. + public init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: Flow_Access_AccessAPIClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + self.interceptors = interceptors + } +} + +/// AccessAPI is the public-facing API provided by access nodes. +/// +/// To build a server, implement a class that conforms to this protocol. +public protocol Flow_Access_AccessAPIProvider: CallHandlerProvider { + var interceptors: Flow_Access_AccessAPIServerInterceptorFactoryProtocol? { get } + + /// Ping is used to check if the access node is alive and healthy. + func ping(request: Flow_Access_PingRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetLatestBlockHeader gets the latest sealed or unsealed block header. + func getLatestBlockHeader(request: Flow_Access_GetLatestBlockHeaderRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetBlockHeaderByID gets a block header by ID. + func getBlockHeaderByID(request: Flow_Access_GetBlockHeaderByIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetBlockHeaderByHeight gets a block header by height. + func getBlockHeaderByHeight(request: Flow_Access_GetBlockHeaderByHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetLatestBlock gets the full payload of the latest sealed or unsealed + /// block. + func getLatestBlock(request: Flow_Access_GetLatestBlockRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetBlockByID gets a full block by ID. + func getBlockByID(request: Flow_Access_GetBlockByIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetBlockByHeight gets a full block by height. + func getBlockByHeight(request: Flow_Access_GetBlockByHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetCollectionByID gets a collection by ID. + func getCollectionByID(request: Flow_Access_GetCollectionByIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// SendTransaction submits a transaction to the network. + func sendTransaction(request: Flow_Access_SendTransactionRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetTransaction gets a transaction by ID. + func getTransaction(request: Flow_Access_GetTransactionRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetTransactionResult gets the result of a transaction. + func getTransactionResult(request: Flow_Access_GetTransactionRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetAccount is an alias for GetAccountAtLatestBlock. + /// + /// Warning: this function is deprecated. It behaves identically to + /// GetAccountAtLatestBlock and will be removed in a future version. + func getAccount(request: Flow_Access_GetAccountRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetAccountAtLatestBlock gets an account by address from the latest sealed + /// execution state. + func getAccountAtLatestBlock(request: Flow_Access_GetAccountAtLatestBlockRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetAccountAtBlockHeight gets an account by address at the given block + /// height + func getAccountAtBlockHeight(request: Flow_Access_GetAccountAtBlockHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// ExecuteScriptAtLatestBlock executes a read-only Cadence script against the + /// latest sealed execution state. + func executeScriptAtLatestBlock(request: Flow_Access_ExecuteScriptAtLatestBlockRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the + /// execution state at the block with the given ID. + func executeScriptAtBlockID(request: Flow_Access_ExecuteScriptAtBlockIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// ExecuteScriptAtBlockHeight executes a ready-only Cadence script against the + /// execution state at the given block height. + func executeScriptAtBlockHeight(request: Flow_Access_ExecuteScriptAtBlockHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetEventsForHeightRange retrieves events emitted within the specified block + /// range. + func getEventsForHeightRange(request: Flow_Access_GetEventsForHeightRangeRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetEventsForBlockIDs retrieves events for the specified block IDs and event + /// type. + func getEventsForBlockIDs(request: Flow_Access_GetEventsForBlockIDsRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetNetworkParameters retrieves the Flow network details + func getNetworkParameters(request: Flow_Access_GetNetworkParametersRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetLatestProtocolStateSnapshot retrieves the latest sealed protocol state + /// snapshot. Used by Flow nodes joining the network to bootstrap a + /// space-efficient local state. + func getLatestProtocolStateSnapshot(request: Flow_Access_GetLatestProtocolStateSnapshotRequest, context: StatusOnlyCallContext) -> EventLoopFuture +} + +extension Flow_Access_AccessAPIProvider { + public var serviceName: Substring { return "flow.access.AccessAPI" } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + public func handle( + method name: Substring, + context: CallHandlerContext + ) -> GRPCServerHandlerProtocol? { + switch name { + case "Ping": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makePingInterceptors() ?? [], + userFunction: ping(request:context:) + ) + + case "GetLatestBlockHeader": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetLatestBlockHeaderInterceptors() ?? [], + userFunction: getLatestBlockHeader(request:context:) + ) + + case "GetBlockHeaderByID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetBlockHeaderByIDInterceptors() ?? [], + userFunction: getBlockHeaderByID(request:context:) + ) + + case "GetBlockHeaderByHeight": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetBlockHeaderByHeightInterceptors() ?? [], + userFunction: getBlockHeaderByHeight(request:context:) + ) + + case "GetLatestBlock": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetLatestBlockInterceptors() ?? [], + userFunction: getLatestBlock(request:context:) + ) + + case "GetBlockByID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetBlockByIDInterceptors() ?? [], + userFunction: getBlockByID(request:context:) + ) + + case "GetBlockByHeight": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetBlockByHeightInterceptors() ?? [], + userFunction: getBlockByHeight(request:context:) + ) + + case "GetCollectionByID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetCollectionByIDInterceptors() ?? [], + userFunction: getCollectionByID(request:context:) + ) + + case "SendTransaction": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeSendTransactionInterceptors() ?? [], + userFunction: sendTransaction(request:context:) + ) + + case "GetTransaction": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetTransactionInterceptors() ?? [], + userFunction: getTransaction(request:context:) + ) + + case "GetTransactionResult": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetTransactionResultInterceptors() ?? [], + userFunction: getTransactionResult(request:context:) + ) + + case "GetAccount": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetAccountInterceptors() ?? [], + userFunction: getAccount(request:context:) + ) + + case "GetAccountAtLatestBlock": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetAccountAtLatestBlockInterceptors() ?? [], + userFunction: getAccountAtLatestBlock(request:context:) + ) + + case "GetAccountAtBlockHeight": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetAccountAtBlockHeightInterceptors() ?? [], + userFunction: getAccountAtBlockHeight(request:context:) + ) + + case "ExecuteScriptAtLatestBlock": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeExecuteScriptAtLatestBlockInterceptors() ?? [], + userFunction: executeScriptAtLatestBlock(request:context:) + ) + + case "ExecuteScriptAtBlockID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [], + userFunction: executeScriptAtBlockID(request:context:) + ) + + case "ExecuteScriptAtBlockHeight": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeExecuteScriptAtBlockHeightInterceptors() ?? [], + userFunction: executeScriptAtBlockHeight(request:context:) + ) + + case "GetEventsForHeightRange": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetEventsForHeightRangeInterceptors() ?? [], + userFunction: getEventsForHeightRange(request:context:) + ) + + case "GetEventsForBlockIDs": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [], + userFunction: getEventsForBlockIDs(request:context:) + ) + + case "GetNetworkParameters": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetNetworkParametersInterceptors() ?? [], + userFunction: getNetworkParameters(request:context:) + ) + + case "GetLatestProtocolStateSnapshot": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetLatestProtocolStateSnapshotInterceptors() ?? [], + userFunction: getLatestProtocolStateSnapshot(request:context:) + ) + + default: + return nil + } + } +} + +public protocol Flow_Access_AccessAPIServerInterceptorFactoryProtocol { + /// - Returns: Interceptors to use when handling 'ping'. + /// Defaults to calling `self.makeInterceptors()`. + func makePingInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getLatestBlockHeader'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetLatestBlockHeaderInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getBlockHeaderByID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetBlockHeaderByIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getBlockHeaderByHeight'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetBlockHeaderByHeightInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getLatestBlock'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetLatestBlockInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getBlockByID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetBlockByIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getBlockByHeight'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetBlockByHeightInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getCollectionByID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetCollectionByIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'sendTransaction'. + /// Defaults to calling `self.makeInterceptors()`. + func makeSendTransactionInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getTransaction'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetTransactionInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getTransactionResult'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetTransactionResultInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getAccount'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetAccountInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getAccountAtLatestBlock'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetAccountAtLatestBlockInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getAccountAtBlockHeight'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetAccountAtBlockHeightInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'executeScriptAtLatestBlock'. + /// Defaults to calling `self.makeInterceptors()`. + func makeExecuteScriptAtLatestBlockInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'executeScriptAtBlockID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeExecuteScriptAtBlockIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'executeScriptAtBlockHeight'. + /// Defaults to calling `self.makeInterceptors()`. + func makeExecuteScriptAtBlockHeightInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getEventsForHeightRange'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetEventsForHeightRangeInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getEventsForBlockIDs'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetEventsForBlockIDsInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getNetworkParameters'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetNetworkParametersInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getLatestProtocolStateSnapshot'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetLatestProtocolStateSnapshotInterceptors() -> [ServerInterceptor] +} diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Access/access.pb.swift b/FlowFoundation/Sources/Foundation/Protobuf/Access/access.pb.swift new file mode 100644 index 0000000..a298acb --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Access/access.pb.swift @@ -0,0 +1,1665 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/access/access.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Access_PingRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_PingResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetLatestBlockHeaderRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var isSealed: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetBlockHeaderByIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetBlockHeaderByHeightRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var height: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_BlockHeaderResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var block: Flow_Entities_BlockHeader { + get { return _block ?? Flow_Entities_BlockHeader() } + set { _block = newValue } + } + + /// Returns true if `block` has been explicitly set. + public var hasBlock: Bool { return _block != nil } + /// Clears the value of `block`. Subsequent reads from it will return its default value. + public mutating func clearBlock() { _block = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _block: Flow_Entities_BlockHeader? +} + +public struct Flow_Access_GetLatestBlockRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var isSealed: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetBlockByIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetBlockByHeightRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var height: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_BlockResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var block: Flow_Entities_Block { + get { return _block ?? Flow_Entities_Block() } + set { _block = newValue } + } + + /// Returns true if `block` has been explicitly set. + public var hasBlock: Bool { return _block != nil } + /// Clears the value of `block`. Subsequent reads from it will return its default value. + public mutating func clearBlock() { _block = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _block: Flow_Entities_Block? +} + +public struct Flow_Access_GetCollectionByIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_CollectionResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var collection: Flow_Entities_Collection { + get { return _collection ?? Flow_Entities_Collection() } + set { _collection = newValue } + } + + /// Returns true if `collection` has been explicitly set. + public var hasCollection: Bool { return _collection != nil } + /// Clears the value of `collection`. Subsequent reads from it will return its default value. + public mutating func clearCollection() { _collection = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _collection: Flow_Entities_Collection? +} + +public struct Flow_Access_SendTransactionRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var transaction: Flow_Entities_Transaction { + get { return _transaction ?? Flow_Entities_Transaction() } + set { _transaction = newValue } + } + + /// Returns true if `transaction` has been explicitly set. + public var hasTransaction: Bool { return _transaction != nil } + /// Clears the value of `transaction`. Subsequent reads from it will return its default value. + public mutating func clearTransaction() { _transaction = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _transaction: Flow_Entities_Transaction? +} + +public struct Flow_Access_SendTransactionResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetTransactionRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_TransactionResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var transaction: Flow_Entities_Transaction { + get { return _transaction ?? Flow_Entities_Transaction() } + set { _transaction = newValue } + } + + /// Returns true if `transaction` has been explicitly set. + public var hasTransaction: Bool { return _transaction != nil } + /// Clears the value of `transaction`. Subsequent reads from it will return its default value. + public mutating func clearTransaction() { _transaction = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _transaction: Flow_Entities_Transaction? +} + +public struct Flow_Access_TransactionResultResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var status: Flow_Entities_TransactionStatus = .unknown + + public var statusCode: UInt32 = 0 + + public var errorMessage: String = String() + + public var events: [Flow_Entities_Event] = [] + + public var blockID: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetAccountRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetAccountResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var account: Flow_Entities_Account { + get { return _account ?? Flow_Entities_Account() } + set { _account = newValue } + } + + /// Returns true if `account` has been explicitly set. + public var hasAccount: Bool { return _account != nil } + /// Clears the value of `account`. Subsequent reads from it will return its default value. + public mutating func clearAccount() { _account = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _account: Flow_Entities_Account? +} + +public struct Flow_Access_GetAccountAtLatestBlockRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_AccountResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var account: Flow_Entities_Account { + get { return _account ?? Flow_Entities_Account() } + set { _account = newValue } + } + + /// Returns true if `account` has been explicitly set. + public var hasAccount: Bool { return _account != nil } + /// Clears the value of `account`. Subsequent reads from it will return its default value. + public mutating func clearAccount() { _account = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _account: Flow_Entities_Account? +} + +public struct Flow_Access_GetAccountAtBlockHeightRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var blockHeight: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ExecuteScriptAtLatestBlockRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var script: Data = Data() + + public var arguments: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ExecuteScriptAtBlockIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var script: Data = Data() + + public var arguments: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ExecuteScriptAtBlockHeightRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockHeight: UInt64 = 0 + + public var script: Data = Data() + + public var arguments: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ExecuteScriptResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var value: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetEventsForHeightRangeRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var type: String = String() + + public var startHeight: UInt64 = 0 + + public var endHeight: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetEventsForBlockIDsRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var type: String = String() + + public var blockIds: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_EventsResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var results: [Flow_Access_EventsResponse.Result] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public struct Result { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var blockHeight: UInt64 = 0 + + public var events: [Flow_Entities_Event] = [] + + public var blockTimestamp: SwiftProtobuf.Google_Protobuf_Timestamp { + get { return _blockTimestamp ?? SwiftProtobuf.Google_Protobuf_Timestamp() } + set { _blockTimestamp = newValue } + } + + /// Returns true if `blockTimestamp` has been explicitly set. + public var hasBlockTimestamp: Bool { return _blockTimestamp != nil } + /// Clears the value of `blockTimestamp`. Subsequent reads from it will return its default value. + public mutating func clearBlockTimestamp() { _blockTimestamp = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _blockTimestamp: SwiftProtobuf.Google_Protobuf_Timestamp? + } + + public init() {} +} + +public struct Flow_Access_GetNetworkParametersRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetNetworkParametersResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var chainID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetLatestProtocolStateSnapshotRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ProtocolStateSnapshotResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var serializedSnapshot: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.access" + +extension Flow_Access_PingRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PingRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_PingRequest, rhs: Flow_Access_PingRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_PingResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PingResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_PingResponse, rhs: Flow_Access_PingResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetLatestBlockHeaderRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetLatestBlockHeaderRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "is_sealed"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBoolField(value: &self.isSealed) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if isSealed != false { + try visitor.visitSingularBoolField(value: isSealed, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetLatestBlockHeaderRequest, rhs: Flow_Access_GetLatestBlockHeaderRequest) -> Bool { + if lhs.isSealed != rhs.isSealed { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetBlockHeaderByIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetBlockHeaderByIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetBlockHeaderByIDRequest, rhs: Flow_Access_GetBlockHeaderByIDRequest) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetBlockHeaderByHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetBlockHeaderByHeightRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "height"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if height != 0 { + try visitor.visitSingularUInt64Field(value: height, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetBlockHeaderByHeightRequest, rhs: Flow_Access_GetBlockHeaderByHeightRequest) -> Bool { + if lhs.height != rhs.height { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_BlockHeaderResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".BlockHeaderResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "block"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._block) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._block { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_BlockHeaderResponse, rhs: Flow_Access_BlockHeaderResponse) -> Bool { + if lhs._block != rhs._block { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetLatestBlockRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetLatestBlockRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "is_sealed"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBoolField(value: &self.isSealed) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if isSealed != false { + try visitor.visitSingularBoolField(value: isSealed, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetLatestBlockRequest, rhs: Flow_Access_GetLatestBlockRequest) -> Bool { + if lhs.isSealed != rhs.isSealed { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetBlockByIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetBlockByIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetBlockByIDRequest, rhs: Flow_Access_GetBlockByIDRequest) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetBlockByHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetBlockByHeightRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "height"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if height != 0 { + try visitor.visitSingularUInt64Field(value: height, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetBlockByHeightRequest, rhs: Flow_Access_GetBlockByHeightRequest) -> Bool { + if lhs.height != rhs.height { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_BlockResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".BlockResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "block"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._block) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._block { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_BlockResponse, rhs: Flow_Access_BlockResponse) -> Bool { + if lhs._block != rhs._block { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetCollectionByIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetCollectionByIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetCollectionByIDRequest, rhs: Flow_Access_GetCollectionByIDRequest) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_CollectionResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CollectionResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "collection"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._collection) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._collection { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_CollectionResponse, rhs: Flow_Access_CollectionResponse) -> Bool { + if lhs._collection != rhs._collection { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_SendTransactionRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SendTransactionRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "transaction"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._transaction) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._transaction { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_SendTransactionRequest, rhs: Flow_Access_SendTransactionRequest) -> Bool { + if lhs._transaction != rhs._transaction { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_SendTransactionResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SendTransactionResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_SendTransactionResponse, rhs: Flow_Access_SendTransactionResponse) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetTransactionRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetTransactionRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetTransactionRequest, rhs: Flow_Access_GetTransactionRequest) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_TransactionResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".TransactionResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "transaction"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._transaction) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._transaction { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_TransactionResponse, rhs: Flow_Access_TransactionResponse) -> Bool { + if lhs._transaction != rhs._transaction { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_TransactionResultResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".TransactionResultResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + 2: .standard(proto: "status_code"), + 3: .standard(proto: "error_message"), + 4: .same(proto: "events"), + 5: .standard(proto: "block_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.status) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.statusCode) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() + case 4: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() + case 5: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if status != .unknown { + try visitor.visitSingularEnumField(value: status, fieldNumber: 1) + } + if statusCode != 0 { + try visitor.visitSingularUInt32Field(value: statusCode, fieldNumber: 2) + } + if !errorMessage.isEmpty { + try visitor.visitSingularStringField(value: errorMessage, fieldNumber: 3) + } + if !events.isEmpty { + try visitor.visitRepeatedMessageField(value: events, fieldNumber: 4) + } + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_TransactionResultResponse, rhs: Flow_Access_TransactionResultResponse) -> Bool { + if lhs.status != rhs.status { return false } + if lhs.statusCode != rhs.statusCode { return false } + if lhs.errorMessage != rhs.errorMessage { return false } + if lhs.events != rhs.events { return false } + if lhs.blockID != rhs.blockID { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetAccountRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetAccountRequest, rhs: Flow_Access_GetAccountRequest) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetAccountResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "account"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._account) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._account { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetAccountResponse, rhs: Flow_Access_GetAccountResponse) -> Bool { + if lhs._account != rhs._account { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetAccountAtLatestBlockRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountAtLatestBlockRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetAccountAtLatestBlockRequest, rhs: Flow_Access_GetAccountAtLatestBlockRequest) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_AccountResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".AccountResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "account"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._account) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._account { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_AccountResponse, rhs: Flow_Access_AccountResponse) -> Bool { + if lhs._account != rhs._account { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetAccountAtBlockHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountAtBlockHeightRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .standard(proto: "block_height"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + if blockHeight != 0 { + try visitor.visitSingularUInt64Field(value: blockHeight, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetAccountAtBlockHeightRequest, rhs: Flow_Access_GetAccountAtBlockHeightRequest) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.blockHeight != rhs.blockHeight { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ExecuteScriptAtLatestBlockRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtLatestBlockRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "script"), + 2: .same(proto: "arguments"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.script) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !script.isEmpty { + try visitor.visitSingularBytesField(value: script, fieldNumber: 1) + } + if !arguments.isEmpty { + try visitor.visitRepeatedBytesField(value: arguments, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ExecuteScriptAtLatestBlockRequest, rhs: Flow_Access_ExecuteScriptAtLatestBlockRequest) -> Bool { + if lhs.script != rhs.script { return false } + if lhs.arguments != rhs.arguments { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ExecuteScriptAtBlockIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .same(proto: "script"), + 3: .same(proto: "arguments"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.script) }() + case 3: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if !script.isEmpty { + try visitor.visitSingularBytesField(value: script, fieldNumber: 2) + } + if !arguments.isEmpty { + try visitor.visitRepeatedBytesField(value: arguments, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ExecuteScriptAtBlockIDRequest, rhs: Flow_Access_ExecuteScriptAtBlockIDRequest) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.script != rhs.script { return false } + if lhs.arguments != rhs.arguments { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ExecuteScriptAtBlockHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockHeightRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_height"), + 2: .same(proto: "script"), + 3: .same(proto: "arguments"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.script) }() + case 3: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if blockHeight != 0 { + try visitor.visitSingularUInt64Field(value: blockHeight, fieldNumber: 1) + } + if !script.isEmpty { + try visitor.visitSingularBytesField(value: script, fieldNumber: 2) + } + if !arguments.isEmpty { + try visitor.visitRepeatedBytesField(value: arguments, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ExecuteScriptAtBlockHeightRequest, rhs: Flow_Access_ExecuteScriptAtBlockHeightRequest) -> Bool { + if lhs.blockHeight != rhs.blockHeight { return false } + if lhs.script != rhs.script { return false } + if lhs.arguments != rhs.arguments { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ExecuteScriptResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "value"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.value) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !value.isEmpty { + try visitor.visitSingularBytesField(value: value, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ExecuteScriptResponse, rhs: Flow_Access_ExecuteScriptResponse) -> Bool { + if lhs.value != rhs.value { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetEventsForHeightRangeRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetEventsForHeightRangeRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "start_height"), + 3: .standard(proto: "end_height"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.startHeight) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.endHeight) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !type.isEmpty { + try visitor.visitSingularStringField(value: type, fieldNumber: 1) + } + if startHeight != 0 { + try visitor.visitSingularUInt64Field(value: startHeight, fieldNumber: 2) + } + if endHeight != 0 { + try visitor.visitSingularUInt64Field(value: endHeight, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetEventsForHeightRangeRequest, rhs: Flow_Access_GetEventsForHeightRangeRequest) -> Bool { + if lhs.type != rhs.type { return false } + if lhs.startHeight != rhs.startHeight { return false } + if lhs.endHeight != rhs.endHeight { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetEventsForBlockIDsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetEventsForBlockIDsRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "block_ids"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.blockIds) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !type.isEmpty { + try visitor.visitSingularStringField(value: type, fieldNumber: 1) + } + if !blockIds.isEmpty { + try visitor.visitRepeatedBytesField(value: blockIds, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetEventsForBlockIDsRequest, rhs: Flow_Access_GetEventsForBlockIDsRequest) -> Bool { + if lhs.type != rhs.type { return false } + if lhs.blockIds != rhs.blockIds { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_EventsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".EventsResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "results"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.results) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !results.isEmpty { + try visitor.visitRepeatedMessageField(value: results, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_EventsResponse, rhs: Flow_Access_EventsResponse) -> Bool { + if lhs.results != rhs.results { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_EventsResponse.Result: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Flow_Access_EventsResponse.protoMessageName + ".Result" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .standard(proto: "block_height"), + 3: .same(proto: "events"), + 4: .standard(proto: "block_timestamp"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._blockTimestamp) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if blockHeight != 0 { + try visitor.visitSingularUInt64Field(value: blockHeight, fieldNumber: 2) + } + if !events.isEmpty { + try visitor.visitRepeatedMessageField(value: events, fieldNumber: 3) + } + if let v = self._blockTimestamp { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_EventsResponse.Result, rhs: Flow_Access_EventsResponse.Result) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.blockHeight != rhs.blockHeight { return false } + if lhs.events != rhs.events { return false } + if lhs._blockTimestamp != rhs._blockTimestamp { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetNetworkParametersRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetNetworkParametersRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetNetworkParametersRequest, rhs: Flow_Access_GetNetworkParametersRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetNetworkParametersResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetNetworkParametersResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "chain_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.chainID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !chainID.isEmpty { + try visitor.visitSingularStringField(value: chainID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetNetworkParametersResponse, rhs: Flow_Access_GetNetworkParametersResponse) -> Bool { + if lhs.chainID != rhs.chainID { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetLatestProtocolStateSnapshotRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetLatestProtocolStateSnapshotRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetLatestProtocolStateSnapshotRequest, rhs: Flow_Access_GetLatestProtocolStateSnapshotRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ProtocolStateSnapshotResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ProtocolStateSnapshotResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "serializedSnapshot"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.serializedSnapshot) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !serializedSnapshot.isEmpty { + try visitor.visitSingularBytesField(value: serializedSnapshot, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ProtocolStateSnapshotResponse, rhs: Flow_Access_ProtocolStateSnapshotResponse) -> Bool { + if lhs.serializedSnapshot != rhs.serializedSnapshot { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Entities/account.pb.swift b/FlowFoundation/Sources/Foundation/Protobuf/Entities/account.pb.swift new file mode 100644 index 0000000..04f87cd --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Entities/account.pb.swift @@ -0,0 +1,193 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/account.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_Account { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var balance: UInt64 = 0 + + public var code: Data = Data() + + public var keys: [Flow_Entities_AccountKey] = [] + + public var contracts: [String: Data] = [:] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Entities_AccountKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var index: UInt32 = 0 + + public var publicKey: Data = Data() + + public var signAlgo: UInt32 = 0 + + public var hashAlgo: UInt32 = 0 + + public var weight: UInt32 = 0 + + public var sequenceNumber: UInt32 = 0 + + public var revoked: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_Account: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Account" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .same(proto: "balance"), + 3: .same(proto: "code"), + 4: .same(proto: "keys"), + 5: .same(proto: "contracts"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.balance) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.code) }() + case 4: try { try decoder.decodeRepeatedMessageField(value: &self.keys) }() + case 5: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.contracts) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + if balance != 0 { + try visitor.visitSingularUInt64Field(value: balance, fieldNumber: 2) + } + if !code.isEmpty { + try visitor.visitSingularBytesField(value: code, fieldNumber: 3) + } + if !keys.isEmpty { + try visitor.visitRepeatedMessageField(value: keys, fieldNumber: 4) + } + if !contracts.isEmpty { + try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: contracts, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Account, rhs: Flow_Entities_Account) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.balance != rhs.balance { return false } + if lhs.code != rhs.code { return false } + if lhs.keys != rhs.keys { return false } + if lhs.contracts != rhs.contracts { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Entities_AccountKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".AccountKey" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "index"), + 2: .standard(proto: "public_key"), + 3: .standard(proto: "sign_algo"), + 4: .standard(proto: "hash_algo"), + 5: .same(proto: "weight"), + 6: .standard(proto: "sequence_number"), + 7: .same(proto: "revoked"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.index) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.publicKey) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.signAlgo) }() + case 4: try { try decoder.decodeSingularUInt32Field(value: &self.hashAlgo) }() + case 5: try { try decoder.decodeSingularUInt32Field(value: &self.weight) }() + case 6: try { try decoder.decodeSingularUInt32Field(value: &self.sequenceNumber) }() + case 7: try { try decoder.decodeSingularBoolField(value: &self.revoked) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if index != 0 { + try visitor.visitSingularUInt32Field(value: index, fieldNumber: 1) + } + if !publicKey.isEmpty { + try visitor.visitSingularBytesField(value: publicKey, fieldNumber: 2) + } + if signAlgo != 0 { + try visitor.visitSingularUInt32Field(value: signAlgo, fieldNumber: 3) + } + if hashAlgo != 0 { + try visitor.visitSingularUInt32Field(value: hashAlgo, fieldNumber: 4) + } + if weight != 0 { + try visitor.visitSingularUInt32Field(value: weight, fieldNumber: 5) + } + if sequenceNumber != 0 { + try visitor.visitSingularUInt32Field(value: sequenceNumber, fieldNumber: 6) + } + if revoked != false { + try visitor.visitSingularBoolField(value: revoked, fieldNumber: 7) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_AccountKey, rhs: Flow_Entities_AccountKey) -> Bool { + if lhs.index != rhs.index { return false } + if lhs.publicKey != rhs.publicKey { return false } + if lhs.signAlgo != rhs.signAlgo { return false } + if lhs.hashAlgo != rhs.hashAlgo { return false } + if lhs.weight != rhs.weight { return false } + if lhs.sequenceNumber != rhs.sequenceNumber { return false } + if lhs.revoked != rhs.revoked { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Entities/block.pb.swift b/FlowFoundation/Sources/Foundation/Protobuf/Entities/block.pb.swift new file mode 100644 index 0000000..71796d6 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Entities/block.pb.swift @@ -0,0 +1,127 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/block.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_Block { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var parentID: Data = Data() + + public var height: UInt64 = 0 + + public var timestamp: SwiftProtobuf.Google_Protobuf_Timestamp { + get { return _timestamp ?? SwiftProtobuf.Google_Protobuf_Timestamp() } + set { _timestamp = newValue } + } + + /// Returns true if `timestamp` has been explicitly set. + public var hasTimestamp: Bool { return _timestamp != nil } + /// Clears the value of `timestamp`. Subsequent reads from it will return its default value. + public mutating func clearTimestamp() { _timestamp = nil } + + public var collectionGuarantees: [Flow_Entities_CollectionGuarantee] = [] + + public var blockSeals: [Flow_Entities_BlockSeal] = [] + + public var signatures: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _timestamp: SwiftProtobuf.Google_Protobuf_Timestamp? +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_Block: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Block" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .standard(proto: "parent_id"), + 3: .same(proto: "height"), + 4: .same(proto: "timestamp"), + 5: .standard(proto: "collection_guarantees"), + 6: .standard(proto: "block_seals"), + 7: .same(proto: "signatures"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.parentID) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._timestamp) }() + case 5: try { try decoder.decodeRepeatedMessageField(value: &self.collectionGuarantees) }() + case 6: try { try decoder.decodeRepeatedMessageField(value: &self.blockSeals) }() + case 7: try { try decoder.decodeRepeatedBytesField(value: &self.signatures) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + if !parentID.isEmpty { + try visitor.visitSingularBytesField(value: parentID, fieldNumber: 2) + } + if height != 0 { + try visitor.visitSingularUInt64Field(value: height, fieldNumber: 3) + } + if let v = self._timestamp { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } + if !collectionGuarantees.isEmpty { + try visitor.visitRepeatedMessageField(value: collectionGuarantees, fieldNumber: 5) + } + if !blockSeals.isEmpty { + try visitor.visitRepeatedMessageField(value: blockSeals, fieldNumber: 6) + } + if !signatures.isEmpty { + try visitor.visitRepeatedBytesField(value: signatures, fieldNumber: 7) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Block, rhs: Flow_Entities_Block) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.parentID != rhs.parentID { return false } + if lhs.height != rhs.height { return false } + if lhs._timestamp != rhs._timestamp { return false } + if lhs.collectionGuarantees != rhs.collectionGuarantees { return false } + if lhs.blockSeals != rhs.blockSeals { return false } + if lhs.signatures != rhs.signatures { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Entities/block_header.pb.swift b/FlowFoundation/Sources/Foundation/Protobuf/Entities/block_header.pb.swift new file mode 100644 index 0000000..6c81482 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Entities/block_header.pb.swift @@ -0,0 +1,103 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/block_header.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_BlockHeader { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var parentID: Data = Data() + + public var height: UInt64 = 0 + + public var timestamp: SwiftProtobuf.Google_Protobuf_Timestamp { + get { return _timestamp ?? SwiftProtobuf.Google_Protobuf_Timestamp() } + set { _timestamp = newValue } + } + + /// Returns true if `timestamp` has been explicitly set. + public var hasTimestamp: Bool { return _timestamp != nil } + /// Clears the value of `timestamp`. Subsequent reads from it will return its default value. + public mutating func clearTimestamp() { _timestamp = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _timestamp: SwiftProtobuf.Google_Protobuf_Timestamp? +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_BlockHeader: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".BlockHeader" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .standard(proto: "parent_id"), + 3: .same(proto: "height"), + 4: .same(proto: "timestamp"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.parentID) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._timestamp) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + if !parentID.isEmpty { + try visitor.visitSingularBytesField(value: parentID, fieldNumber: 2) + } + if height != 0 { + try visitor.visitSingularUInt64Field(value: height, fieldNumber: 3) + } + if let v = self._timestamp { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_BlockHeader, rhs: Flow_Entities_BlockHeader) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.parentID != rhs.parentID { return false } + if lhs.height != rhs.height { return false } + if lhs._timestamp != rhs._timestamp { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Entities/block_seal.pb.swift b/FlowFoundation/Sources/Foundation/Protobuf/Entities/block_seal.pb.swift new file mode 100644 index 0000000..3352d53 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Entities/block_seal.pb.swift @@ -0,0 +1,93 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/block_seal.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_BlockSeal { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var executionReceiptID: Data = Data() + + public var executionReceiptSignatures: [Data] = [] + + public var resultApprovalSignatures: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_BlockSeal: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".BlockSeal" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .standard(proto: "execution_receipt_id"), + 3: .standard(proto: "execution_receipt_signatures"), + 4: .standard(proto: "result_approval_signatures"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.executionReceiptID) }() + case 3: try { try decoder.decodeRepeatedBytesField(value: &self.executionReceiptSignatures) }() + case 4: try { try decoder.decodeRepeatedBytesField(value: &self.resultApprovalSignatures) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if !executionReceiptID.isEmpty { + try visitor.visitSingularBytesField(value: executionReceiptID, fieldNumber: 2) + } + if !executionReceiptSignatures.isEmpty { + try visitor.visitRepeatedBytesField(value: executionReceiptSignatures, fieldNumber: 3) + } + if !resultApprovalSignatures.isEmpty { + try visitor.visitRepeatedBytesField(value: resultApprovalSignatures, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_BlockSeal, rhs: Flow_Entities_BlockSeal) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.executionReceiptID != rhs.executionReceiptID { return false } + if lhs.executionReceiptSignatures != rhs.executionReceiptSignatures { return false } + if lhs.resultApprovalSignatures != rhs.resultApprovalSignatures { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Entities/collection.pb.swift b/FlowFoundation/Sources/Foundation/Protobuf/Entities/collection.pb.swift new file mode 100644 index 0000000..e0cc820 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Entities/collection.pb.swift @@ -0,0 +1,129 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/collection.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_Collection { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var transactionIds: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Entities_CollectionGuarantee { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var collectionID: Data = Data() + + public var signatures: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_Collection: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Collection" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .standard(proto: "transaction_ids"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.transactionIds) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + if !transactionIds.isEmpty { + try visitor.visitRepeatedBytesField(value: transactionIds, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Collection, rhs: Flow_Entities_Collection) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.transactionIds != rhs.transactionIds { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Entities_CollectionGuarantee: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CollectionGuarantee" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "collection_id"), + 2: .same(proto: "signatures"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.collectionID) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.signatures) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !collectionID.isEmpty { + try visitor.visitSingularBytesField(value: collectionID, fieldNumber: 1) + } + if !signatures.isEmpty { + try visitor.visitRepeatedBytesField(value: signatures, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_CollectionGuarantee, rhs: Flow_Entities_CollectionGuarantee) -> Bool { + if lhs.collectionID != rhs.collectionID { return false } + if lhs.signatures != rhs.signatures { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Entities/event.pb.swift b/FlowFoundation/Sources/Foundation/Protobuf/Entities/event.pb.swift new file mode 100644 index 0000000..c58be7f --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Entities/event.pb.swift @@ -0,0 +1,101 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/event.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_Event { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var type: String = String() + + public var transactionID: Data = Data() + + public var transactionIndex: UInt32 = 0 + + public var eventIndex: UInt32 = 0 + + public var payload: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_Event: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Event" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "transaction_id"), + 3: .standard(proto: "transaction_index"), + 4: .standard(proto: "event_index"), + 5: .same(proto: "payload"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.transactionID) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.transactionIndex) }() + case 4: try { try decoder.decodeSingularUInt32Field(value: &self.eventIndex) }() + case 5: try { try decoder.decodeSingularBytesField(value: &self.payload) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !type.isEmpty { + try visitor.visitSingularStringField(value: type, fieldNumber: 1) + } + if !transactionID.isEmpty { + try visitor.visitSingularBytesField(value: transactionID, fieldNumber: 2) + } + if transactionIndex != 0 { + try visitor.visitSingularUInt32Field(value: transactionIndex, fieldNumber: 3) + } + if eventIndex != 0 { + try visitor.visitSingularUInt32Field(value: eventIndex, fieldNumber: 4) + } + if !payload.isEmpty { + try visitor.visitSingularBytesField(value: payload, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Event, rhs: Flow_Entities_Event) -> Bool { + if lhs.type != rhs.type { return false } + if lhs.transactionID != rhs.transactionID { return false } + if lhs.transactionIndex != rhs.transactionIndex { return false } + if lhs.eventIndex != rhs.eventIndex { return false } + if lhs.payload != rhs.payload { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Entities/transaction.pb.swift b/FlowFoundation/Sources/Foundation/Protobuf/Entities/transaction.pb.swift new file mode 100644 index 0000000..2804d44 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Entities/transaction.pb.swift @@ -0,0 +1,329 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/transaction.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public enum Flow_Entities_TransactionStatus: SwiftProtobuf.Enum { + public typealias RawValue = Int + case unknown // = 0 + case pending // = 1 + case finalized // = 2 + case executed // = 3 + case sealed // = 4 + case expired // = 5 + case UNRECOGNIZED(Int) + + public init() { + self = .unknown + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknown + case 1: self = .pending + case 2: self = .finalized + case 3: self = .executed + case 4: self = .sealed + case 5: self = .expired + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unknown: return 0 + case .pending: return 1 + case .finalized: return 2 + case .executed: return 3 + case .sealed: return 4 + case .expired: return 5 + case let .UNRECOGNIZED(i): return i + } + } +} + +#if swift(>=4.2) + + extension Flow_Entities_TransactionStatus: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static var allCases: [Flow_Entities_TransactionStatus] = [ + .unknown, + .pending, + .finalized, + .executed, + .sealed, + .expired, + ] + } + +#endif // swift(>=4.2) + +public struct Flow_Entities_Transaction { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var script: Data = Data() + + public var arguments: [Data] = [] + + public var referenceBlockID: Data = Data() + + public var gasLimit: UInt64 = 0 + + public var proposalKey: Flow_Entities_Transaction.ProposalKey { + get { return _proposalKey ?? Flow_Entities_Transaction.ProposalKey() } + set { _proposalKey = newValue } + } + + /// Returns true if `proposalKey` has been explicitly set. + public var hasProposalKey: Bool { return _proposalKey != nil } + /// Clears the value of `proposalKey`. Subsequent reads from it will return its default value. + public mutating func clearProposalKey() { _proposalKey = nil } + + public var payer: Data = Data() + + public var authorizers: [Data] = [] + + public var payloadSignatures: [Flow_Entities_Transaction.Signature] = [] + + public var envelopeSignatures: [Flow_Entities_Transaction.Signature] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public struct ProposalKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var keyID: UInt32 = 0 + + public var sequenceNumber: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public struct Signature { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var keyID: UInt32 = 0 + + public var signature: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} + + fileprivate var _proposalKey: Flow_Entities_Transaction.ProposalKey? +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_TransactionStatus: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "PENDING"), + 2: .same(proto: "FINALIZED"), + 3: .same(proto: "EXECUTED"), + 4: .same(proto: "SEALED"), + 5: .same(proto: "EXPIRED"), + ] +} + +extension Flow_Entities_Transaction: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Transaction" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "script"), + 2: .same(proto: "arguments"), + 3: .standard(proto: "reference_block_id"), + 4: .standard(proto: "gas_limit"), + 5: .standard(proto: "proposal_key"), + 6: .same(proto: "payer"), + 7: .same(proto: "authorizers"), + 8: .standard(proto: "payload_signatures"), + 9: .standard(proto: "envelope_signatures"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.script) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.referenceBlockID) }() + case 4: try { try decoder.decodeSingularUInt64Field(value: &self.gasLimit) }() + case 5: try { try decoder.decodeSingularMessageField(value: &self._proposalKey) }() + case 6: try { try decoder.decodeSingularBytesField(value: &self.payer) }() + case 7: try { try decoder.decodeRepeatedBytesField(value: &self.authorizers) }() + case 8: try { try decoder.decodeRepeatedMessageField(value: &self.payloadSignatures) }() + case 9: try { try decoder.decodeRepeatedMessageField(value: &self.envelopeSignatures) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !script.isEmpty { + try visitor.visitSingularBytesField(value: script, fieldNumber: 1) + } + if !arguments.isEmpty { + try visitor.visitRepeatedBytesField(value: arguments, fieldNumber: 2) + } + if !referenceBlockID.isEmpty { + try visitor.visitSingularBytesField(value: referenceBlockID, fieldNumber: 3) + } + if gasLimit != 0 { + try visitor.visitSingularUInt64Field(value: gasLimit, fieldNumber: 4) + } + if let v = self._proposalKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 5) + } + if !payer.isEmpty { + try visitor.visitSingularBytesField(value: payer, fieldNumber: 6) + } + if !authorizers.isEmpty { + try visitor.visitRepeatedBytesField(value: authorizers, fieldNumber: 7) + } + if !payloadSignatures.isEmpty { + try visitor.visitRepeatedMessageField(value: payloadSignatures, fieldNumber: 8) + } + if !envelopeSignatures.isEmpty { + try visitor.visitRepeatedMessageField(value: envelopeSignatures, fieldNumber: 9) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Transaction, rhs: Flow_Entities_Transaction) -> Bool { + if lhs.script != rhs.script { return false } + if lhs.arguments != rhs.arguments { return false } + if lhs.referenceBlockID != rhs.referenceBlockID { return false } + if lhs.gasLimit != rhs.gasLimit { return false } + if lhs._proposalKey != rhs._proposalKey { return false } + if lhs.payer != rhs.payer { return false } + if lhs.authorizers != rhs.authorizers { return false } + if lhs.payloadSignatures != rhs.payloadSignatures { return false } + if lhs.envelopeSignatures != rhs.envelopeSignatures { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Entities_Transaction.ProposalKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Flow_Entities_Transaction.protoMessageName + ".ProposalKey" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .standard(proto: "key_id"), + 3: .standard(proto: "sequence_number"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.keyID) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.sequenceNumber) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + if keyID != 0 { + try visitor.visitSingularUInt32Field(value: keyID, fieldNumber: 2) + } + if sequenceNumber != 0 { + try visitor.visitSingularUInt64Field(value: sequenceNumber, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Transaction.ProposalKey, rhs: Flow_Entities_Transaction.ProposalKey) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.keyID != rhs.keyID { return false } + if lhs.sequenceNumber != rhs.sequenceNumber { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Entities_Transaction.Signature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Flow_Entities_Transaction.protoMessageName + ".Signature" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .standard(proto: "key_id"), + 3: .same(proto: "signature"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.keyID) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.signature) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + if keyID != 0 { + try visitor.visitSingularUInt32Field(value: keyID, fieldNumber: 2) + } + if !signature.isEmpty { + try visitor.visitSingularBytesField(value: signature, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Transaction.Signature, rhs: Flow_Entities_Transaction.Signature) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.keyID != rhs.keyID { return false } + if lhs.signature != rhs.signature { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Execution/execution.grpc.swift b/FlowFoundation/Sources/Foundation/Protobuf/Execution/execution.grpc.swift new file mode 100644 index 0000000..219cc39 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Execution/execution.grpc.swift @@ -0,0 +1,302 @@ +// +// DO NOT EDIT. +// +// Generated by the protocol buffer compiler. +// Source: flow/execution/execution.proto +// + +// +// Copyright 2018, gRPC Authors All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +import GRPC +import NIO +import SwiftProtobuf + +/// ExecutionAPI is the API provided by the execution nodes. +/// +/// Usage: instantiate `Flow_Execution_ExecutionAPIClient`, then call methods of this protocol to make API calls. +public protocol Flow_Execution_ExecutionAPIClientProtocol: GRPCClient { + var serviceName: String { get } + var interceptors: Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol? { get } + + func ping( + _ request: Flow_Execution_PingRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getAccountAtBlockID( + _ request: Flow_Execution_GetAccountAtBlockIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func executeScriptAtBlockID( + _ request: Flow_Execution_ExecuteScriptAtBlockIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getEventsForBlockIDs( + _ request: Flow_Execution_GetEventsForBlockIDsRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getTransactionResult( + _ request: Flow_Execution_GetTransactionResultRequest, + callOptions: CallOptions? + ) -> UnaryCall +} + +extension Flow_Execution_ExecutionAPIClientProtocol { + public var serviceName: String { + return "flow.execution.ExecutionAPI" + } + + /// Ping is used to check if the access node is alive and healthy. + /// + /// - Parameters: + /// - request: Request to send to Ping. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func ping( + _ request: Flow_Execution_PingRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.execution.ExecutionAPI/Ping", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makePingInterceptors() ?? [] + ) + } + + /// GetAccountAtBlockID gets an account by address at the given block ID + /// + /// - Parameters: + /// - request: Request to send to GetAccountAtBlockID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getAccountAtBlockID( + _ request: Flow_Execution_GetAccountAtBlockIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.execution.ExecutionAPI/GetAccountAtBlockID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetAccountAtBlockIDInterceptors() ?? [] + ) + } + + /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the + /// execution state at the block with the given ID. + /// + /// - Parameters: + /// - request: Request to send to ExecuteScriptAtBlockID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func executeScriptAtBlockID( + _ request: Flow_Execution_ExecuteScriptAtBlockIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.execution.ExecutionAPI/ExecuteScriptAtBlockID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [] + ) + } + + /// GetEventsForBlockIDs retrieves events for all the specified block IDs that + /// have the given type + /// + /// - Parameters: + /// - request: Request to send to GetEventsForBlockIDs. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getEventsForBlockIDs( + _ request: Flow_Execution_GetEventsForBlockIDsRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.execution.ExecutionAPI/GetEventsForBlockIDs", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [] + ) + } + + /// GetTransactionResult gets the result of a transaction. + /// + /// - Parameters: + /// - request: Request to send to GetTransactionResult. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getTransactionResult( + _ request: Flow_Execution_GetTransactionResultRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.execution.ExecutionAPI/GetTransactionResult", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetTransactionResultInterceptors() ?? [] + ) + } +} + +public protocol Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol { + /// - Returns: Interceptors to use when invoking 'ping'. + func makePingInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getAccountAtBlockID'. + func makeGetAccountAtBlockIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'executeScriptAtBlockID'. + func makeExecuteScriptAtBlockIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getEventsForBlockIDs'. + func makeGetEventsForBlockIDsInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getTransactionResult'. + func makeGetTransactionResultInterceptors() -> [ClientInterceptor] +} + +public final class Flow_Execution_ExecutionAPIClient: Flow_Execution_ExecutionAPIClientProtocol { + public let channel: GRPCChannel + public var defaultCallOptions: CallOptions + public var interceptors: Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol? + + /// Creates a client for the flow.execution.ExecutionAPI service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + /// - interceptors: A factory providing interceptors for each RPC. + public init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + self.interceptors = interceptors + } +} + +/// ExecutionAPI is the API provided by the execution nodes. +/// +/// To build a server, implement a class that conforms to this protocol. +public protocol Flow_Execution_ExecutionAPIProvider: CallHandlerProvider { + var interceptors: Flow_Execution_ExecutionAPIServerInterceptorFactoryProtocol? { get } + + /// Ping is used to check if the access node is alive and healthy. + func ping(request: Flow_Execution_PingRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetAccountAtBlockID gets an account by address at the given block ID + func getAccountAtBlockID(request: Flow_Execution_GetAccountAtBlockIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the + /// execution state at the block with the given ID. + func executeScriptAtBlockID(request: Flow_Execution_ExecuteScriptAtBlockIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetEventsForBlockIDs retrieves events for all the specified block IDs that + /// have the given type + func getEventsForBlockIDs(request: Flow_Execution_GetEventsForBlockIDsRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetTransactionResult gets the result of a transaction. + func getTransactionResult(request: Flow_Execution_GetTransactionResultRequest, context: StatusOnlyCallContext) -> EventLoopFuture +} + +extension Flow_Execution_ExecutionAPIProvider { + public var serviceName: Substring { return "flow.execution.ExecutionAPI" } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + public func handle( + method name: Substring, + context: CallHandlerContext + ) -> GRPCServerHandlerProtocol? { + switch name { + case "Ping": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makePingInterceptors() ?? [], + userFunction: ping(request:context:) + ) + + case "GetAccountAtBlockID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetAccountAtBlockIDInterceptors() ?? [], + userFunction: getAccountAtBlockID(request:context:) + ) + + case "ExecuteScriptAtBlockID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [], + userFunction: executeScriptAtBlockID(request:context:) + ) + + case "GetEventsForBlockIDs": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [], + userFunction: getEventsForBlockIDs(request:context:) + ) + + case "GetTransactionResult": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetTransactionResultInterceptors() ?? [], + userFunction: getTransactionResult(request:context:) + ) + + default: + return nil + } + } +} + +public protocol Flow_Execution_ExecutionAPIServerInterceptorFactoryProtocol { + /// - Returns: Interceptors to use when handling 'ping'. + /// Defaults to calling `self.makeInterceptors()`. + func makePingInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getAccountAtBlockID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetAccountAtBlockIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'executeScriptAtBlockID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeExecuteScriptAtBlockIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getEventsForBlockIDs'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetEventsForBlockIDsInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getTransactionResult'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetTransactionResultInterceptors() -> [ServerInterceptor] +} diff --git a/FlowFoundation/Sources/Foundation/Protobuf/Execution/execution.pb.swift b/FlowFoundation/Sources/Foundation/Protobuf/Execution/execution.pb.swift new file mode 100644 index 0000000..0603296 --- /dev/null +++ b/FlowFoundation/Sources/Foundation/Protobuf/Execution/execution.pb.swift @@ -0,0 +1,559 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/execution/execution.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Execution_PingRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_PingResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_GetAccountAtBlockIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var address: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_GetAccountAtBlockIDResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var account: Flow_Entities_Account { + get { return _account ?? Flow_Entities_Account() } + set { _account = newValue } + } + + /// Returns true if `account` has been explicitly set. + public var hasAccount: Bool { return _account != nil } + /// Clears the value of `account`. Subsequent reads from it will return its default value. + public mutating func clearAccount() { _account = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _account: Flow_Entities_Account? +} + +public struct Flow_Execution_ExecuteScriptAtBlockIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var script: Data = Data() + + public var arguments: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_ExecuteScriptAtBlockIDResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var value: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_GetEventsForBlockIDsResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var results: [Flow_Execution_GetEventsForBlockIDsResponse.Result] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public struct Result { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var blockHeight: UInt64 = 0 + + public var events: [Flow_Entities_Event] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +public struct Flow_Execution_GetEventsForBlockIDsRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var type: String = String() + + public var blockIds: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_GetTransactionResultRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var transactionID: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_GetTransactionResultResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var statusCode: UInt32 = 0 + + public var errorMessage: String = String() + + public var events: [Flow_Entities_Event] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.execution" + +extension Flow_Execution_PingRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PingRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_PingRequest, rhs: Flow_Execution_PingRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_PingResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PingResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_PingResponse, rhs: Flow_Execution_PingResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetAccountAtBlockIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountAtBlockIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .same(proto: "address"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetAccountAtBlockIDRequest, rhs: Flow_Execution_GetAccountAtBlockIDRequest) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.address != rhs.address { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetAccountAtBlockIDResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountAtBlockIDResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "account"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._account) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._account { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetAccountAtBlockIDResponse, rhs: Flow_Execution_GetAccountAtBlockIDResponse) -> Bool { + if lhs._account != rhs._account { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_ExecuteScriptAtBlockIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .same(proto: "script"), + 3: .same(proto: "arguments"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.script) }() + case 3: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if !script.isEmpty { + try visitor.visitSingularBytesField(value: script, fieldNumber: 2) + } + if !arguments.isEmpty { + try visitor.visitRepeatedBytesField(value: arguments, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_ExecuteScriptAtBlockIDRequest, rhs: Flow_Execution_ExecuteScriptAtBlockIDRequest) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.script != rhs.script { return false } + if lhs.arguments != rhs.arguments { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_ExecuteScriptAtBlockIDResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockIDResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "value"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.value) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !value.isEmpty { + try visitor.visitSingularBytesField(value: value, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_ExecuteScriptAtBlockIDResponse, rhs: Flow_Execution_ExecuteScriptAtBlockIDResponse) -> Bool { + if lhs.value != rhs.value { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetEventsForBlockIDsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetEventsForBlockIDsResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "results"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.results) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !results.isEmpty { + try visitor.visitRepeatedMessageField(value: results, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetEventsForBlockIDsResponse, rhs: Flow_Execution_GetEventsForBlockIDsResponse) -> Bool { + if lhs.results != rhs.results { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetEventsForBlockIDsResponse.Result: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Flow_Execution_GetEventsForBlockIDsResponse.protoMessageName + ".Result" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .standard(proto: "block_height"), + 3: .same(proto: "events"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if blockHeight != 0 { + try visitor.visitSingularUInt64Field(value: blockHeight, fieldNumber: 2) + } + if !events.isEmpty { + try visitor.visitRepeatedMessageField(value: events, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetEventsForBlockIDsResponse.Result, rhs: Flow_Execution_GetEventsForBlockIDsResponse.Result) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.blockHeight != rhs.blockHeight { return false } + if lhs.events != rhs.events { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetEventsForBlockIDsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetEventsForBlockIDsRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "block_ids"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.blockIds) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !type.isEmpty { + try visitor.visitSingularStringField(value: type, fieldNumber: 1) + } + if !blockIds.isEmpty { + try visitor.visitRepeatedBytesField(value: blockIds, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetEventsForBlockIDsRequest, rhs: Flow_Execution_GetEventsForBlockIDsRequest) -> Bool { + if lhs.type != rhs.type { return false } + if lhs.blockIds != rhs.blockIds { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetTransactionResultRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetTransactionResultRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .standard(proto: "transaction_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.transactionID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if !transactionID.isEmpty { + try visitor.visitSingularBytesField(value: transactionID, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetTransactionResultRequest, rhs: Flow_Execution_GetTransactionResultRequest) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.transactionID != rhs.transactionID { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetTransactionResultResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetTransactionResultResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "status_code"), + 2: .standard(proto: "error_message"), + 3: .same(proto: "events"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.statusCode) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if statusCode != 0 { + try visitor.visitSingularUInt32Field(value: statusCode, fieldNumber: 1) + } + if !errorMessage.isEmpty { + try visitor.visitSingularStringField(value: errorMessage, fieldNumber: 2) + } + if !events.isEmpty { + try visitor.visitRepeatedMessageField(value: events, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetTransactionResultResponse, rhs: Flow_Execution_GetTransactionResultResponse) -> Bool { + if lhs.statusCode != rhs.statusCode { return false } + if lhs.errorMessage != rhs.errorMessage { return false } + if lhs.events != rhs.events { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/Sources/Flow/RLP/RLP.swift b/FlowFoundation/Sources/Foundation/RLP/RLP.swift similarity index 100% rename from Sources/Flow/RLP/RLP.swift rename to FlowFoundation/Sources/Foundation/RLP/RLP.swift diff --git a/Tests/CadenceTypeTest.swift b/FlowFoundation/Tests/CadenceTypeTest.swift similarity index 99% rename from Tests/CadenceTypeTest.swift rename to FlowFoundation/Tests/CadenceTypeTest.swift index 8ed8768..3b966a0 100644 --- a/Tests/CadenceTypeTest.swift +++ b/FlowFoundation/Tests/CadenceTypeTest.swift @@ -1,5 +1,5 @@ @testable import BigInt -@testable import Flow +@testable import FlowFoundation import XCTest final class CadenceTypeTests: XCTestCase { diff --git a/Tests/FlowAPITests.swift b/FlowFoundation/Tests/FlowAPITests.swift similarity index 96% rename from Tests/FlowAPITests.swift rename to FlowFoundation/Tests/FlowAPITests.swift index 3607b06..67d8d41 100644 --- a/Tests/FlowAPITests.swift +++ b/FlowFoundation/Tests/FlowAPITests.swift @@ -1,4 +1,4 @@ -@testable import Flow +@testable import FlowFoundation import XCTest final class FlowAPITests: XCTestCase { diff --git a/Tests/FlowAccessAPITests.swift b/FlowFoundation/Tests/FlowAccessAPITests.swift similarity index 95% rename from Tests/FlowAccessAPITests.swift rename to FlowFoundation/Tests/FlowAccessAPITests.swift index 2f6de97..6a22865 100644 --- a/Tests/FlowAccessAPITests.swift +++ b/FlowFoundation/Tests/FlowAccessAPITests.swift @@ -1,6 +1,6 @@ @testable import BigInt import CryptoKit -@testable import Flow +@testable import FlowFoundation import XCTest final class FlowAccessAPITests: XCTestCase { @@ -33,10 +33,8 @@ final class FlowAccessAPITests: XCTestCase { } func testGetAccount() throws { -// let address = Flow.Address(hex: mainnetAddress) - let address = Flow.Address(hex: "0xc6de0d94160377cd") - let api = try! Flow.shared.newAccessApi(chainId: .testnet)! - let account = try api.getAccountAtLatestBlock(address: address).wait() + let address = Flow.Address(hex: mainnetAddress) + let account = try flowAPI.getAccountAtLatestBlock(address: address).wait() XCTAssertNotNil(account?.keys.first) XCTAssertEqual(address, account?.address) } @@ -136,12 +134,12 @@ final class FlowAccessAPITests: XCTestCase { Flow.TransactionSignature(address: address, signerIndex: 0, keyIndex: 0, - signature: Flow.Signature(bytes: sign.byteArray)), + signature: Flow.Signature(data: sign)), ]) let txId = try testnetAPI.sendTransaction(transaction: newTx!).wait() XCTAssertNotNil(txId) - print("txid --> \(txId.hexValue)") + print("txid --> \(txId.hex)") } func testGetCollectionById() throws { diff --git a/Tests/RLPTests.swift b/FlowFoundation/Tests/RLPTests.swift similarity index 99% rename from Tests/RLPTests.swift rename to FlowFoundation/Tests/RLPTests.swift index 988b2d0..4622d4c 100644 --- a/Tests/RLPTests.swift +++ b/FlowFoundation/Tests/RLPTests.swift @@ -1,9 +1,9 @@ import BigInt -@testable import Flow +@testable import FlowFoundation import XCTest final class RLPTests: XCTestCase { - let prefix = "FLOW-V0.0-transaction".data(using: .utf8)!.byteArray.paddingZeroRight(blockSize: 32).hexValue + let prefix = Flow.Constants.transactionPrefix let baseTx = Flow.Transaction(script: Flow.Script(script: "transaction { execute { log(\"Hello, World!\") } }"), arguments: [], referenceBlockId: Flow.Id(hex: "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b"), diff --git a/proto/access/access.proto b/FlowFoundation/proto/access/access.proto similarity index 100% rename from proto/access/access.proto rename to FlowFoundation/proto/access/access.proto diff --git a/proto/entities/account.proto b/FlowFoundation/proto/entities/account.proto similarity index 100% rename from proto/entities/account.proto rename to FlowFoundation/proto/entities/account.proto diff --git a/proto/entities/block.proto b/FlowFoundation/proto/entities/block.proto similarity index 100% rename from proto/entities/block.proto rename to FlowFoundation/proto/entities/block.proto diff --git a/proto/entities/block_header.proto b/FlowFoundation/proto/entities/block_header.proto similarity index 100% rename from proto/entities/block_header.proto rename to FlowFoundation/proto/entities/block_header.proto diff --git a/proto/entities/block_seal.proto b/FlowFoundation/proto/entities/block_seal.proto similarity index 100% rename from proto/entities/block_seal.proto rename to FlowFoundation/proto/entities/block_seal.proto diff --git a/proto/entities/collection.proto b/FlowFoundation/proto/entities/collection.proto similarity index 100% rename from proto/entities/collection.proto rename to FlowFoundation/proto/entities/collection.proto diff --git a/proto/entities/event.proto b/FlowFoundation/proto/entities/event.proto similarity index 100% rename from proto/entities/event.proto rename to FlowFoundation/proto/entities/event.proto diff --git a/proto/entities/transaction.proto b/FlowFoundation/proto/entities/transaction.proto similarity index 100% rename from proto/entities/transaction.proto rename to FlowFoundation/proto/entities/transaction.proto diff --git a/proto/execution/execution.proto b/FlowFoundation/proto/execution/execution.proto similarity index 100% rename from proto/execution/execution.proto rename to FlowFoundation/proto/execution/execution.proto diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c4d1db5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Ryan Kopinsky + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Package.swift b/Package.swift index 1288c66..8132256 100644 --- a/Package.swift +++ b/Package.swift @@ -11,26 +11,34 @@ let package = Package( ], products: [ .library( - name: "Flow", - targets: ["Flow"] + name: "WalletKit", + targets: ["WalletKit"] + ), + .library( + name: "FCL", + targets: ["FCL"] + ), + .library( + name: "FlowFoundation", + targets: ["FlowFoundation"] ), ], - dependencies: [ - .package(name: "BigInt", url: "https://github.com/attaswift/BigInt.git", from: "5.2.1"), - .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.0.0"), - .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.0.0"), - ], + dependencies: [], targets: [ .target( - name: "Flow", - dependencies: ["BigInt", - .product(name: "GRPC", package: "grpc-swift"), - .product(name: "AsyncHTTPClient", package: "async-http-client")] + name: "WalletKit", + dependencies: ["FlowFoundation"], + path: "WalletKit/Sources" + ), + .target( + name: "FCL", + dependencies: ["FlowFoundation"], + path: "FCL/Sources" ), - .testTarget( - name: "FlowTests", - dependencies: ["Flow"], - path: "Tests" + .target( + name: "FlowFoundation", + dependencies: [], + path: "FlowFoundation/Sources" ), ] ) diff --git a/README.md b/README.md index c0b3878..bb05fe5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,88 @@ -# flow +

+ + + + +

-A description of this package. +# Flow Swift SDK +The Flow Swift SDK is a Swift gRPC client for Flow (https://www.onflow.org). + +Currently the following Flow Access API methods have been implemented: + +### Connection +- [x] Ping + +### Accounts +- [x] GetAccountAtLatestBlock +- [x] GetAccountAtBlockHeight + +### Blocks +- [x] GetLatestBlock +- [x] GetBlockByHeight + +### Events +- [x] GetEventsForHeightRange + +### Scripts +- [x] ExecuteScriptAtLatestBlock +- [x] ExecuteScriptAtBlockHeight + +## Installation + +This is a Swift Package, and can be installed via Xcode with the URL of this repository: + +`https://github.com/ryankopinsky/flow-swift-sdk` + +[For more information on how to add a Swift Package using Xcode, see Apple's official documentation.](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) + + +## Usage + +```swift +// Connect to the Flow blockchain +let client = FlowClient(host: "access.mainnet.nodes.onflow.org", port: 9000) +client.ping { error in + if let error = error { + print("Ping Error: \(error.localizedDescription)") + } else { + print("Ping Success!") + } +} +``` + +### Accounts + +```swift +// Get account balance +let accountAddress = "0xead892083b3e2c6c" // Random address on mainnet +client.getAccount(address: accountAddress) { account, error in + guard let account = account else { + print("Error getAccount: \(error!.localizedDescription)") + return + } + + print("Account with address \(accountAddress) has balance \(account.balance).") +} +``` + +### Scripts + +```swift +// Execute sample script +let script = "pub fun main(): Int { return 1 }".data(using: .utf8)! +client.executeScript(script: script, arguments: []) { jsonData, error in + guard let jsonData = jsonData else { + print("Error executeScript: \(error!.localizedDescription)") + return + } + + print("executeScript - resultType: \(String(describing: jsonData["type"])), resultValue: \(String(describing: jsonData["value"])).") +} +``` + +Note: not all functionality is demonstrated in the above examples. To explore the capabilities of the Flow Swift SDK, feel free to check out the Tests folder. Most functionality will have a corresponding test case. + +## Contributing + +Contributions (such as feature requests, bug reports, pull requests etc) are welcome and encouraged. Make sure to abide by the [Code of Conduct](https://github.com/ryankopinsky/flow-swift-sdk/blob/main/CODE_OF_CONDUCT.md). diff --git a/Sources/Flow/Constants/Constants.swift b/Sources/Flow/Constants/Constants.swift deleted file mode 100644 index 1b04ca9..0000000 --- a/Sources/Flow/Constants/Constants.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// File.swift -// -// -// Created by lmcmz on 14/9/21. -// - -import Foundation - -extension Flow { - class Constants { - internal static let transactionPrefix = "FLOW-V0.0-transaction".data(using: .utf8)!.byteArray.paddingZeroRight(blockSize: 32).hexValue - internal static let userPrefix = "FLOW-V0.0-user".data(using: .utf8)!.byteArray.paddingZeroRight(blockSize: 32).hexValue - } -} diff --git a/Sources/Flow/Extension/Data.swift b/Sources/Flow/Extension/Data.swift deleted file mode 100644 index 71bf59a..0000000 --- a/Sources/Flow/Extension/Data.swift +++ /dev/null @@ -1,77 +0,0 @@ -// -// Data.swift -// -// -// Created by lmcmz on 19/7/21. -// - -import Foundation - -// extension Sequence where Element == UInt8 { -// } - -extension Array where Element == UInt8 { - var data: Data { .init(self) } - var hexValue: String { map { .init(format: "%02x", $0) }.joined() } - - func paddingZeroLeft(blockSize: Int) -> [UInt8] { - if count >= blockSize { - return self - } - let paddingCount = blockSize - (count % blockSize) - if paddingCount > 0 { - return [UInt8](repeating: 0, count: paddingCount) + self - } - return self - } - - func paddingZeroRight(blockSize: Int) -> [UInt8] { - if count >= blockSize { - return self - } - let paddingCount = blockSize - (count % blockSize) - if paddingCount > 0 { - return self + [UInt8](repeating: 0, count: paddingCount) - } - return self - } -} - -extension Data { - var byteArray: ByteArray { - return ByteArray(self) - } - - static func fromHex(_ hex: String) -> Data? { - let string = hex.lowercased().stripHexPrefix() - guard let array = string.data(using: .utf8)?.byteArray else { - return nil - } - if array.count == 0 { - if hex == "0x" || hex == "" { - return Data() - } else { - return nil - } - } - return array.data - } - - var hexValue: String { - return reduce("") { $0 + String(format: "%02x", $1) } - } - - func paddingZeroLeft(blockSize: Int) -> Data { - return byteArray.paddingZeroLeft(blockSize: blockSize).data - } - - func paddingZeroRight(blockSize: Int) -> Data { - return byteArray.paddingZeroRight(blockSize: blockSize).data - } -} - -extension Array where Iterator.Element: Hashable { - var hashValue: Int { - return reduce(1) { $0.hashValue ^ $1.hashValue } - } -} diff --git a/Sources/Flow/Models/BytesHolder.swift b/Sources/Flow/Models/BytesHolder.swift deleted file mode 100644 index 09ef54b..0000000 --- a/Sources/Flow/Models/BytesHolder.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// BytesHolder.swift -// -// -// Created by lmcmz on 21/7/21. -// - -import Foundation - -typealias ByteArray = [UInt8] - -protocol BytesHolder { - var bytes: ByteArray { get set } - var hexValue: String { get } - var stringValue: String { get } -} - -extension BytesHolder { - var hexValue: String { - return bytes.hexValue - } - - var stringValue: String { - return String(bytes: bytes, encoding: .utf8) ?? "" - } -} diff --git a/Sources/Flow/Models/DomainTag.swift b/Sources/Flow/Models/DomainTag.swift deleted file mode 100644 index 6739e9c..0000000 --- a/Sources/Flow/Models/DomainTag.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// DomainTag.swift -// -// -// Created by lmcmz on 25/7/21. -// - -import Foundation - -enum DomainTag: String { - case transaction = "FLOW-V0.0-transaction" - case user = "FLOW-V0.0-user" - - var normalize: ByteArray? { - guard let bytes = rawValue.data(using: .utf8) else { - return nil - } - - let length = bytes.count - switch length { - case _ where length > 32: - return nil - case _ where length < 32: - let paddingBytes = (0 ..< 32 - length).compactMap { _ in UInt8() } - var result = bytes.byteArray - result.append(contentsOf: paddingBytes) - return result - default: - return bytes.byteArray - } - } -} diff --git a/Sources/Flow/Models/FlowAddress.swift b/Sources/Flow/Models/FlowAddress.swift deleted file mode 100644 index f0fe43b..0000000 --- a/Sources/Flow/Models/FlowAddress.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// FlowAddress.swift -// -// -// Created by lmcmz on 23/7/21. -// - -import Foundation - -extension Flow { - public struct Address: BytesHolder, Equatable, Hashable, Codable { - internal var bytes: [UInt8] - - internal init(hex: String) { - bytes = hex.hexValue - } - - init(bytes: [UInt8]) { - self.bytes = bytes - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(hexValue.addHexPrefix()) - } - } -} diff --git a/Sources/Flow/Models/FlowId.swift b/Sources/Flow/Models/FlowId.swift deleted file mode 100644 index 07ccae6..0000000 --- a/Sources/Flow/Models/FlowId.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// File.swift -// -// -// Created by lmcmz on 27/7/21. -// - -import Foundation - -extension Flow { - struct Id: BytesHolder, Equatable, Hashable { - var bytes: [UInt8] - - init(hex: String) { - bytes = hex.hexValue - } - - init(bytes: [UInt8]) { - self.bytes = bytes - } - } -} diff --git a/Sources/Flow/Models/FlowScript.swift b/Sources/Flow/Models/FlowScript.swift deleted file mode 100644 index 3dde641..0000000 --- a/Sources/Flow/Models/FlowScript.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// FlowScript.swift -// -// -// Created by lmcmz on 23/7/21. -// - -import Foundation - -extension Flow { - struct Script: BytesHolder, Equatable { - var bytes: [UInt8] - var data: Data { - return bytes.data - } - - init(script: String) { - bytes = script.data(using: .utf8)!.byteArray - } - - init(data: Data) { - bytes = data.byteArray - } - - init(bytes: [UInt8]) { - self.bytes = bytes - } - } - - struct ScriptResponse: BytesHolder, Equatable { - var bytes: ByteArray - var fields: Argument? - - init(bytes: ByteArray) { - self.bytes = bytes - fields = try? JSONDecoder().decode(Flow.Argument.self, from: bytes.data) - } - } -} diff --git a/Sources/Flow/Models/FlowSignature.swift b/Sources/Flow/Models/FlowSignature.swift deleted file mode 100644 index 118a28e..0000000 --- a/Sources/Flow/Models/FlowSignature.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// File.swift -// -// -// Created by lmcmz on 5/9/21. -// - -import Foundation - -extension Flow { - struct Signature: BytesHolder, Equatable { - var bytes: [UInt8] - - init(hex: String) { - bytes = hex.hexValue - } - - init(bytes: [UInt8]) { - self.bytes = bytes - } - } -} diff --git a/Sources/Flow/Models/Signer.swift b/Sources/Flow/Models/Signer.swift deleted file mode 100644 index 8414d90..0000000 --- a/Sources/Flow/Models/Signer.swift +++ /dev/null @@ -1,49 +0,0 @@ -// -// Signer.swift -// -// -// Created by lmcmz on 21/7/21. -// - -import Foundation - -protocol FlowSigner { - var hasher: Hasher { get set } - - func sign(bytes: ByteArray) -> ByteArray - - func signWithDomain(bytes: ByteArray, domain: ByteArray) -> ByteArray - - func signAsUser(bytes: ByteArray) -> ByteArray - - func signAsTransaction(bytes: ByteArray) -> ByteArray -} - -protocol FlowHasher { - func hash(bytes: ByteArray) -> ByteArray - func hashAsHexString(bytes: ByteArray) -> String -} - -extension FlowHasher { - func hashAsHexString(bytes: ByteArray) -> String { - return hash(bytes: bytes).hexValue - } -} - -extension Flow { - struct PublicKey: BytesHolder, Equatable { - var bytes: ByteArray - - init(hex: String) { - bytes = hex.hexValue - } - - init(bytes: [UInt8]) { - self.bytes = bytes - } - } - - struct Code: BytesHolder, Equatable { - var bytes: ByteArray - } -} diff --git a/Sources/Flow/Protobuf/Access/access.grpc.swift b/Sources/Flow/Protobuf/Access/access.grpc.swift deleted file mode 100644 index 9d7ab20..0000000 --- a/Sources/Flow/Protobuf/Access/access.grpc.swift +++ /dev/null @@ -1,999 +0,0 @@ -// -// DO NOT EDIT. -// -// Generated by the protocol buffer compiler. -// Source: flow/access/access.proto -// - -// -// Copyright 2018, gRPC Authors All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -import GRPC -import NIO -import SwiftProtobuf - - -/// AccessAPI is the public-facing API provided by access nodes. -/// -/// Usage: instantiate `Flow_Access_AccessAPIClient`, then call methods of this protocol to make API calls. -public protocol Flow_Access_AccessAPIClientProtocol: GRPCClient { - var serviceName: String { get } - var interceptors: Flow_Access_AccessAPIClientInterceptorFactoryProtocol? { get } - - func ping( - _ request: Flow_Access_PingRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getLatestBlockHeader( - _ request: Flow_Access_GetLatestBlockHeaderRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getBlockHeaderByID( - _ request: Flow_Access_GetBlockHeaderByIDRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getBlockHeaderByHeight( - _ request: Flow_Access_GetBlockHeaderByHeightRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getLatestBlock( - _ request: Flow_Access_GetLatestBlockRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getBlockByID( - _ request: Flow_Access_GetBlockByIDRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getBlockByHeight( - _ request: Flow_Access_GetBlockByHeightRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getCollectionByID( - _ request: Flow_Access_GetCollectionByIDRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func sendTransaction( - _ request: Flow_Access_SendTransactionRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getTransaction( - _ request: Flow_Access_GetTransactionRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getTransactionResult( - _ request: Flow_Access_GetTransactionRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getAccount( - _ request: Flow_Access_GetAccountRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getAccountAtLatestBlock( - _ request: Flow_Access_GetAccountAtLatestBlockRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getAccountAtBlockHeight( - _ request: Flow_Access_GetAccountAtBlockHeightRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func executeScriptAtLatestBlock( - _ request: Flow_Access_ExecuteScriptAtLatestBlockRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func executeScriptAtBlockID( - _ request: Flow_Access_ExecuteScriptAtBlockIDRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func executeScriptAtBlockHeight( - _ request: Flow_Access_ExecuteScriptAtBlockHeightRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getEventsForHeightRange( - _ request: Flow_Access_GetEventsForHeightRangeRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getEventsForBlockIDs( - _ request: Flow_Access_GetEventsForBlockIDsRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getNetworkParameters( - _ request: Flow_Access_GetNetworkParametersRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getLatestProtocolStateSnapshot( - _ request: Flow_Access_GetLatestProtocolStateSnapshotRequest, - callOptions: CallOptions? - ) -> UnaryCall -} - -extension Flow_Access_AccessAPIClientProtocol { - public var serviceName: String { - return "flow.access.AccessAPI" - } - - /// Ping is used to check if the access node is alive and healthy. - /// - /// - Parameters: - /// - request: Request to send to Ping. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func ping( - _ request: Flow_Access_PingRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/Ping", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makePingInterceptors() ?? [] - ) - } - - /// GetLatestBlockHeader gets the latest sealed or unsealed block header. - /// - /// - Parameters: - /// - request: Request to send to GetLatestBlockHeader. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getLatestBlockHeader( - _ request: Flow_Access_GetLatestBlockHeaderRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetLatestBlockHeader", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetLatestBlockHeaderInterceptors() ?? [] - ) - } - - /// GetBlockHeaderByID gets a block header by ID. - /// - /// - Parameters: - /// - request: Request to send to GetBlockHeaderByID. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getBlockHeaderByID( - _ request: Flow_Access_GetBlockHeaderByIDRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetBlockHeaderByID", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetBlockHeaderByIDInterceptors() ?? [] - ) - } - - /// GetBlockHeaderByHeight gets a block header by height. - /// - /// - Parameters: - /// - request: Request to send to GetBlockHeaderByHeight. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getBlockHeaderByHeight( - _ request: Flow_Access_GetBlockHeaderByHeightRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetBlockHeaderByHeight", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetBlockHeaderByHeightInterceptors() ?? [] - ) - } - - /// GetLatestBlock gets the full payload of the latest sealed or unsealed - /// block. - /// - /// - Parameters: - /// - request: Request to send to GetLatestBlock. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getLatestBlock( - _ request: Flow_Access_GetLatestBlockRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetLatestBlock", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetLatestBlockInterceptors() ?? [] - ) - } - - /// GetBlockByID gets a full block by ID. - /// - /// - Parameters: - /// - request: Request to send to GetBlockByID. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getBlockByID( - _ request: Flow_Access_GetBlockByIDRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetBlockByID", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetBlockByIDInterceptors() ?? [] - ) - } - - /// GetBlockByHeight gets a full block by height. - /// - /// - Parameters: - /// - request: Request to send to GetBlockByHeight. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getBlockByHeight( - _ request: Flow_Access_GetBlockByHeightRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetBlockByHeight", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetBlockByHeightInterceptors() ?? [] - ) - } - - /// GetCollectionByID gets a collection by ID. - /// - /// - Parameters: - /// - request: Request to send to GetCollectionByID. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getCollectionByID( - _ request: Flow_Access_GetCollectionByIDRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetCollectionByID", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetCollectionByIDInterceptors() ?? [] - ) - } - - /// SendTransaction submits a transaction to the network. - /// - /// - Parameters: - /// - request: Request to send to SendTransaction. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func sendTransaction( - _ request: Flow_Access_SendTransactionRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/SendTransaction", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeSendTransactionInterceptors() ?? [] - ) - } - - /// GetTransaction gets a transaction by ID. - /// - /// - Parameters: - /// - request: Request to send to GetTransaction. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getTransaction( - _ request: Flow_Access_GetTransactionRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetTransaction", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetTransactionInterceptors() ?? [] - ) - } - - /// GetTransactionResult gets the result of a transaction. - /// - /// - Parameters: - /// - request: Request to send to GetTransactionResult. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getTransactionResult( - _ request: Flow_Access_GetTransactionRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetTransactionResult", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetTransactionResultInterceptors() ?? [] - ) - } - - /// GetAccount is an alias for GetAccountAtLatestBlock. - /// - /// Warning: this function is deprecated. It behaves identically to - /// GetAccountAtLatestBlock and will be removed in a future version. - /// - /// - Parameters: - /// - request: Request to send to GetAccount. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getAccount( - _ request: Flow_Access_GetAccountRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetAccount", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetAccountInterceptors() ?? [] - ) - } - - /// GetAccountAtLatestBlock gets an account by address from the latest sealed - /// execution state. - /// - /// - Parameters: - /// - request: Request to send to GetAccountAtLatestBlock. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getAccountAtLatestBlock( - _ request: Flow_Access_GetAccountAtLatestBlockRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetAccountAtLatestBlock", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetAccountAtLatestBlockInterceptors() ?? [] - ) - } - - /// GetAccountAtBlockHeight gets an account by address at the given block - /// height - /// - /// - Parameters: - /// - request: Request to send to GetAccountAtBlockHeight. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getAccountAtBlockHeight( - _ request: Flow_Access_GetAccountAtBlockHeightRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetAccountAtBlockHeight", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetAccountAtBlockHeightInterceptors() ?? [] - ) - } - - /// ExecuteScriptAtLatestBlock executes a read-only Cadence script against the - /// latest sealed execution state. - /// - /// - Parameters: - /// - request: Request to send to ExecuteScriptAtLatestBlock. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func executeScriptAtLatestBlock( - _ request: Flow_Access_ExecuteScriptAtLatestBlockRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/ExecuteScriptAtLatestBlock", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeExecuteScriptAtLatestBlockInterceptors() ?? [] - ) - } - - /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the - /// execution state at the block with the given ID. - /// - /// - Parameters: - /// - request: Request to send to ExecuteScriptAtBlockID. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func executeScriptAtBlockID( - _ request: Flow_Access_ExecuteScriptAtBlockIDRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/ExecuteScriptAtBlockID", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [] - ) - } - - /// ExecuteScriptAtBlockHeight executes a ready-only Cadence script against the - /// execution state at the given block height. - /// - /// - Parameters: - /// - request: Request to send to ExecuteScriptAtBlockHeight. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func executeScriptAtBlockHeight( - _ request: Flow_Access_ExecuteScriptAtBlockHeightRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/ExecuteScriptAtBlockHeight", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeExecuteScriptAtBlockHeightInterceptors() ?? [] - ) - } - - /// GetEventsForHeightRange retrieves events emitted within the specified block - /// range. - /// - /// - Parameters: - /// - request: Request to send to GetEventsForHeightRange. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getEventsForHeightRange( - _ request: Flow_Access_GetEventsForHeightRangeRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetEventsForHeightRange", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetEventsForHeightRangeInterceptors() ?? [] - ) - } - - /// GetEventsForBlockIDs retrieves events for the specified block IDs and event - /// type. - /// - /// - Parameters: - /// - request: Request to send to GetEventsForBlockIDs. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getEventsForBlockIDs( - _ request: Flow_Access_GetEventsForBlockIDsRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetEventsForBlockIDs", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [] - ) - } - - /// GetNetworkParameters retrieves the Flow network details - /// - /// - Parameters: - /// - request: Request to send to GetNetworkParameters. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getNetworkParameters( - _ request: Flow_Access_GetNetworkParametersRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetNetworkParameters", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetNetworkParametersInterceptors() ?? [] - ) - } - - /// GetLatestProtocolStateSnapshot retrieves the latest sealed protocol state - /// snapshot. Used by Flow nodes joining the network to bootstrap a - /// space-efficient local state. - /// - /// - Parameters: - /// - request: Request to send to GetLatestProtocolStateSnapshot. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getLatestProtocolStateSnapshot( - _ request: Flow_Access_GetLatestProtocolStateSnapshotRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.access.AccessAPI/GetLatestProtocolStateSnapshot", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetLatestProtocolStateSnapshotInterceptors() ?? [] - ) - } -} - -public protocol Flow_Access_AccessAPIClientInterceptorFactoryProtocol { - - /// - Returns: Interceptors to use when invoking 'ping'. - func makePingInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getLatestBlockHeader'. - func makeGetLatestBlockHeaderInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getBlockHeaderByID'. - func makeGetBlockHeaderByIDInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getBlockHeaderByHeight'. - func makeGetBlockHeaderByHeightInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getLatestBlock'. - func makeGetLatestBlockInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getBlockByID'. - func makeGetBlockByIDInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getBlockByHeight'. - func makeGetBlockByHeightInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getCollectionByID'. - func makeGetCollectionByIDInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'sendTransaction'. - func makeSendTransactionInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getTransaction'. - func makeGetTransactionInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getTransactionResult'. - func makeGetTransactionResultInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getAccount'. - func makeGetAccountInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getAccountAtLatestBlock'. - func makeGetAccountAtLatestBlockInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getAccountAtBlockHeight'. - func makeGetAccountAtBlockHeightInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'executeScriptAtLatestBlock'. - func makeExecuteScriptAtLatestBlockInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'executeScriptAtBlockID'. - func makeExecuteScriptAtBlockIDInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'executeScriptAtBlockHeight'. - func makeExecuteScriptAtBlockHeightInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getEventsForHeightRange'. - func makeGetEventsForHeightRangeInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getEventsForBlockIDs'. - func makeGetEventsForBlockIDsInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getNetworkParameters'. - func makeGetNetworkParametersInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getLatestProtocolStateSnapshot'. - func makeGetLatestProtocolStateSnapshotInterceptors() -> [ClientInterceptor] -} - -public final class Flow_Access_AccessAPIClient: Flow_Access_AccessAPIClientProtocol { - public let channel: GRPCChannel - public var defaultCallOptions: CallOptions - public var interceptors: Flow_Access_AccessAPIClientInterceptorFactoryProtocol? - - /// Creates a client for the flow.access.AccessAPI service. - /// - /// - Parameters: - /// - channel: `GRPCChannel` to the service host. - /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. - /// - interceptors: A factory providing interceptors for each RPC. - public init( - channel: GRPCChannel, - defaultCallOptions: CallOptions = CallOptions(), - interceptors: Flow_Access_AccessAPIClientInterceptorFactoryProtocol? = nil - ) { - self.channel = channel - self.defaultCallOptions = defaultCallOptions - self.interceptors = interceptors - } -} - -/// AccessAPI is the public-facing API provided by access nodes. -/// -/// To build a server, implement a class that conforms to this protocol. -public protocol Flow_Access_AccessAPIProvider: CallHandlerProvider { - var interceptors: Flow_Access_AccessAPIServerInterceptorFactoryProtocol? { get } - - /// Ping is used to check if the access node is alive and healthy. - func ping(request: Flow_Access_PingRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetLatestBlockHeader gets the latest sealed or unsealed block header. - func getLatestBlockHeader(request: Flow_Access_GetLatestBlockHeaderRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetBlockHeaderByID gets a block header by ID. - func getBlockHeaderByID(request: Flow_Access_GetBlockHeaderByIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetBlockHeaderByHeight gets a block header by height. - func getBlockHeaderByHeight(request: Flow_Access_GetBlockHeaderByHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetLatestBlock gets the full payload of the latest sealed or unsealed - /// block. - func getLatestBlock(request: Flow_Access_GetLatestBlockRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetBlockByID gets a full block by ID. - func getBlockByID(request: Flow_Access_GetBlockByIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetBlockByHeight gets a full block by height. - func getBlockByHeight(request: Flow_Access_GetBlockByHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetCollectionByID gets a collection by ID. - func getCollectionByID(request: Flow_Access_GetCollectionByIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// SendTransaction submits a transaction to the network. - func sendTransaction(request: Flow_Access_SendTransactionRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetTransaction gets a transaction by ID. - func getTransaction(request: Flow_Access_GetTransactionRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetTransactionResult gets the result of a transaction. - func getTransactionResult(request: Flow_Access_GetTransactionRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetAccount is an alias for GetAccountAtLatestBlock. - /// - /// Warning: this function is deprecated. It behaves identically to - /// GetAccountAtLatestBlock and will be removed in a future version. - func getAccount(request: Flow_Access_GetAccountRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetAccountAtLatestBlock gets an account by address from the latest sealed - /// execution state. - func getAccountAtLatestBlock(request: Flow_Access_GetAccountAtLatestBlockRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetAccountAtBlockHeight gets an account by address at the given block - /// height - func getAccountAtBlockHeight(request: Flow_Access_GetAccountAtBlockHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// ExecuteScriptAtLatestBlock executes a read-only Cadence script against the - /// latest sealed execution state. - func executeScriptAtLatestBlock(request: Flow_Access_ExecuteScriptAtLatestBlockRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the - /// execution state at the block with the given ID. - func executeScriptAtBlockID(request: Flow_Access_ExecuteScriptAtBlockIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// ExecuteScriptAtBlockHeight executes a ready-only Cadence script against the - /// execution state at the given block height. - func executeScriptAtBlockHeight(request: Flow_Access_ExecuteScriptAtBlockHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetEventsForHeightRange retrieves events emitted within the specified block - /// range. - func getEventsForHeightRange(request: Flow_Access_GetEventsForHeightRangeRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetEventsForBlockIDs retrieves events for the specified block IDs and event - /// type. - func getEventsForBlockIDs(request: Flow_Access_GetEventsForBlockIDsRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetNetworkParameters retrieves the Flow network details - func getNetworkParameters(request: Flow_Access_GetNetworkParametersRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetLatestProtocolStateSnapshot retrieves the latest sealed protocol state - /// snapshot. Used by Flow nodes joining the network to bootstrap a - /// space-efficient local state. - func getLatestProtocolStateSnapshot(request: Flow_Access_GetLatestProtocolStateSnapshotRequest, context: StatusOnlyCallContext) -> EventLoopFuture -} - -extension Flow_Access_AccessAPIProvider { - public var serviceName: Substring { return "flow.access.AccessAPI" } - - /// Determines, calls and returns the appropriate request handler, depending on the request's method. - /// Returns nil for methods not handled by this service. - public func handle( - method name: Substring, - context: CallHandlerContext - ) -> GRPCServerHandlerProtocol? { - switch name { - case "Ping": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makePingInterceptors() ?? [], - userFunction: self.ping(request:context:) - ) - - case "GetLatestBlockHeader": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetLatestBlockHeaderInterceptors() ?? [], - userFunction: self.getLatestBlockHeader(request:context:) - ) - - case "GetBlockHeaderByID": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetBlockHeaderByIDInterceptors() ?? [], - userFunction: self.getBlockHeaderByID(request:context:) - ) - - case "GetBlockHeaderByHeight": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetBlockHeaderByHeightInterceptors() ?? [], - userFunction: self.getBlockHeaderByHeight(request:context:) - ) - - case "GetLatestBlock": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetLatestBlockInterceptors() ?? [], - userFunction: self.getLatestBlock(request:context:) - ) - - case "GetBlockByID": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetBlockByIDInterceptors() ?? [], - userFunction: self.getBlockByID(request:context:) - ) - - case "GetBlockByHeight": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetBlockByHeightInterceptors() ?? [], - userFunction: self.getBlockByHeight(request:context:) - ) - - case "GetCollectionByID": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetCollectionByIDInterceptors() ?? [], - userFunction: self.getCollectionByID(request:context:) - ) - - case "SendTransaction": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeSendTransactionInterceptors() ?? [], - userFunction: self.sendTransaction(request:context:) - ) - - case "GetTransaction": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetTransactionInterceptors() ?? [], - userFunction: self.getTransaction(request:context:) - ) - - case "GetTransactionResult": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetTransactionResultInterceptors() ?? [], - userFunction: self.getTransactionResult(request:context:) - ) - - case "GetAccount": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetAccountInterceptors() ?? [], - userFunction: self.getAccount(request:context:) - ) - - case "GetAccountAtLatestBlock": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetAccountAtLatestBlockInterceptors() ?? [], - userFunction: self.getAccountAtLatestBlock(request:context:) - ) - - case "GetAccountAtBlockHeight": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetAccountAtBlockHeightInterceptors() ?? [], - userFunction: self.getAccountAtBlockHeight(request:context:) - ) - - case "ExecuteScriptAtLatestBlock": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeExecuteScriptAtLatestBlockInterceptors() ?? [], - userFunction: self.executeScriptAtLatestBlock(request:context:) - ) - - case "ExecuteScriptAtBlockID": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [], - userFunction: self.executeScriptAtBlockID(request:context:) - ) - - case "ExecuteScriptAtBlockHeight": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeExecuteScriptAtBlockHeightInterceptors() ?? [], - userFunction: self.executeScriptAtBlockHeight(request:context:) - ) - - case "GetEventsForHeightRange": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetEventsForHeightRangeInterceptors() ?? [], - userFunction: self.getEventsForHeightRange(request:context:) - ) - - case "GetEventsForBlockIDs": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [], - userFunction: self.getEventsForBlockIDs(request:context:) - ) - - case "GetNetworkParameters": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetNetworkParametersInterceptors() ?? [], - userFunction: self.getNetworkParameters(request:context:) - ) - - case "GetLatestProtocolStateSnapshot": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetLatestProtocolStateSnapshotInterceptors() ?? [], - userFunction: self.getLatestProtocolStateSnapshot(request:context:) - ) - - default: - return nil - } - } -} - -public protocol Flow_Access_AccessAPIServerInterceptorFactoryProtocol { - - /// - Returns: Interceptors to use when handling 'ping'. - /// Defaults to calling `self.makeInterceptors()`. - func makePingInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getLatestBlockHeader'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetLatestBlockHeaderInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getBlockHeaderByID'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetBlockHeaderByIDInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getBlockHeaderByHeight'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetBlockHeaderByHeightInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getLatestBlock'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetLatestBlockInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getBlockByID'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetBlockByIDInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getBlockByHeight'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetBlockByHeightInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getCollectionByID'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetCollectionByIDInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'sendTransaction'. - /// Defaults to calling `self.makeInterceptors()`. - func makeSendTransactionInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getTransaction'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetTransactionInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getTransactionResult'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetTransactionResultInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getAccount'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetAccountInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getAccountAtLatestBlock'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetAccountAtLatestBlockInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getAccountAtBlockHeight'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetAccountAtBlockHeightInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'executeScriptAtLatestBlock'. - /// Defaults to calling `self.makeInterceptors()`. - func makeExecuteScriptAtLatestBlockInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'executeScriptAtBlockID'. - /// Defaults to calling `self.makeInterceptors()`. - func makeExecuteScriptAtBlockIDInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'executeScriptAtBlockHeight'. - /// Defaults to calling `self.makeInterceptors()`. - func makeExecuteScriptAtBlockHeightInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getEventsForHeightRange'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetEventsForHeightRangeInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getEventsForBlockIDs'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetEventsForBlockIDsInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getNetworkParameters'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetNetworkParametersInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getLatestProtocolStateSnapshot'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetLatestProtocolStateSnapshotInterceptors() -> [ServerInterceptor] -} diff --git a/Sources/Flow/Protobuf/Access/access.pb.swift b/Sources/Flow/Protobuf/Access/access.pb.swift deleted file mode 100644 index b2a2719..0000000 --- a/Sources/Flow/Protobuf/Access/access.pb.swift +++ /dev/null @@ -1,1661 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: flow/access/access.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -public struct Flow_Access_PingRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_PingResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetLatestBlockHeaderRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var isSealed: Bool = false - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetBlockHeaderByIDRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var id: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetBlockHeaderByHeightRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var height: UInt64 = 0 - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_BlockHeaderResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var block: Flow_Entities_BlockHeader { - get {return _block ?? Flow_Entities_BlockHeader()} - set {_block = newValue} - } - /// Returns true if `block` has been explicitly set. - public var hasBlock: Bool {return self._block != nil} - /// Clears the value of `block`. Subsequent reads from it will return its default value. - public mutating func clearBlock() {self._block = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _block: Flow_Entities_BlockHeader? = nil -} - -public struct Flow_Access_GetLatestBlockRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var isSealed: Bool = false - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetBlockByIDRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var id: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetBlockByHeightRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var height: UInt64 = 0 - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_BlockResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var block: Flow_Entities_Block { - get {return _block ?? Flow_Entities_Block()} - set {_block = newValue} - } - /// Returns true if `block` has been explicitly set. - public var hasBlock: Bool {return self._block != nil} - /// Clears the value of `block`. Subsequent reads from it will return its default value. - public mutating func clearBlock() {self._block = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _block: Flow_Entities_Block? = nil -} - -public struct Flow_Access_GetCollectionByIDRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var id: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_CollectionResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var collection: Flow_Entities_Collection { - get {return _collection ?? Flow_Entities_Collection()} - set {_collection = newValue} - } - /// Returns true if `collection` has been explicitly set. - public var hasCollection: Bool {return self._collection != nil} - /// Clears the value of `collection`. Subsequent reads from it will return its default value. - public mutating func clearCollection() {self._collection = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _collection: Flow_Entities_Collection? = nil -} - -public struct Flow_Access_SendTransactionRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var transaction: Flow_Entities_Transaction { - get {return _transaction ?? Flow_Entities_Transaction()} - set {_transaction = newValue} - } - /// Returns true if `transaction` has been explicitly set. - public var hasTransaction: Bool {return self._transaction != nil} - /// Clears the value of `transaction`. Subsequent reads from it will return its default value. - public mutating func clearTransaction() {self._transaction = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _transaction: Flow_Entities_Transaction? = nil -} - -public struct Flow_Access_SendTransactionResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var id: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetTransactionRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var id: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_TransactionResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var transaction: Flow_Entities_Transaction { - get {return _transaction ?? Flow_Entities_Transaction()} - set {_transaction = newValue} - } - /// Returns true if `transaction` has been explicitly set. - public var hasTransaction: Bool {return self._transaction != nil} - /// Clears the value of `transaction`. Subsequent reads from it will return its default value. - public mutating func clearTransaction() {self._transaction = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _transaction: Flow_Entities_Transaction? = nil -} - -public struct Flow_Access_TransactionResultResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var status: Flow_Entities_TransactionStatus = .unknown - - public var statusCode: UInt32 = 0 - - public var errorMessage: String = String() - - public var events: [Flow_Entities_Event] = [] - - public var blockID: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetAccountRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var address: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetAccountResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var account: Flow_Entities_Account { - get {return _account ?? Flow_Entities_Account()} - set {_account = newValue} - } - /// Returns true if `account` has been explicitly set. - public var hasAccount: Bool {return self._account != nil} - /// Clears the value of `account`. Subsequent reads from it will return its default value. - public mutating func clearAccount() {self._account = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _account: Flow_Entities_Account? = nil -} - -public struct Flow_Access_GetAccountAtLatestBlockRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var address: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_AccountResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var account: Flow_Entities_Account { - get {return _account ?? Flow_Entities_Account()} - set {_account = newValue} - } - /// Returns true if `account` has been explicitly set. - public var hasAccount: Bool {return self._account != nil} - /// Clears the value of `account`. Subsequent reads from it will return its default value. - public mutating func clearAccount() {self._account = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _account: Flow_Entities_Account? = nil -} - -public struct Flow_Access_GetAccountAtBlockHeightRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var address: Data = Data() - - public var blockHeight: UInt64 = 0 - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_ExecuteScriptAtLatestBlockRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var script: Data = Data() - - public var arguments: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_ExecuteScriptAtBlockIDRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var blockID: Data = Data() - - public var script: Data = Data() - - public var arguments: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_ExecuteScriptAtBlockHeightRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var blockHeight: UInt64 = 0 - - public var script: Data = Data() - - public var arguments: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_ExecuteScriptResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var value: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetEventsForHeightRangeRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var type: String = String() - - public var startHeight: UInt64 = 0 - - public var endHeight: UInt64 = 0 - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetEventsForBlockIDsRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var type: String = String() - - public var blockIds: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_EventsResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var results: [Flow_Access_EventsResponse.Result] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public struct Result { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var blockID: Data = Data() - - public var blockHeight: UInt64 = 0 - - public var events: [Flow_Entities_Event] = [] - - public var blockTimestamp: SwiftProtobuf.Google_Protobuf_Timestamp { - get {return _blockTimestamp ?? SwiftProtobuf.Google_Protobuf_Timestamp()} - set {_blockTimestamp = newValue} - } - /// Returns true if `blockTimestamp` has been explicitly set. - public var hasBlockTimestamp: Bool {return self._blockTimestamp != nil} - /// Clears the value of `blockTimestamp`. Subsequent reads from it will return its default value. - public mutating func clearBlockTimestamp() {self._blockTimestamp = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _blockTimestamp: SwiftProtobuf.Google_Protobuf_Timestamp? = nil - } - - public init() {} -} - -public struct Flow_Access_GetNetworkParametersRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetNetworkParametersResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var chainID: String = String() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_GetLatestProtocolStateSnapshotRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Access_ProtocolStateSnapshotResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var serializedSnapshot: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "flow.access" - -extension Flow_Access_PingRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PingRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - public mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - public func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_PingRequest, rhs: Flow_Access_PingRequest) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_PingResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PingResponse" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - public mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - public func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_PingResponse, rhs: Flow_Access_PingResponse) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetLatestBlockHeaderRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetLatestBlockHeaderRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "is_sealed"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBoolField(value: &self.isSealed) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.isSealed != false { - try visitor.visitSingularBoolField(value: self.isSealed, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetLatestBlockHeaderRequest, rhs: Flow_Access_GetLatestBlockHeaderRequest) -> Bool { - if lhs.isSealed != rhs.isSealed {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetBlockHeaderByIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetBlockHeaderByIDRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.id.isEmpty { - try visitor.visitSingularBytesField(value: self.id, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetBlockHeaderByIDRequest, rhs: Flow_Access_GetBlockHeaderByIDRequest) -> Bool { - if lhs.id != rhs.id {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetBlockHeaderByHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetBlockHeaderByHeightRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "height"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.height != 0 { - try visitor.visitSingularUInt64Field(value: self.height, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetBlockHeaderByHeightRequest, rhs: Flow_Access_GetBlockHeaderByHeightRequest) -> Bool { - if lhs.height != rhs.height {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_BlockHeaderResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".BlockHeaderResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "block"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._block) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if let v = self._block { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_BlockHeaderResponse, rhs: Flow_Access_BlockHeaderResponse) -> Bool { - if lhs._block != rhs._block {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetLatestBlockRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetLatestBlockRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "is_sealed"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBoolField(value: &self.isSealed) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.isSealed != false { - try visitor.visitSingularBoolField(value: self.isSealed, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetLatestBlockRequest, rhs: Flow_Access_GetLatestBlockRequest) -> Bool { - if lhs.isSealed != rhs.isSealed {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetBlockByIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetBlockByIDRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.id.isEmpty { - try visitor.visitSingularBytesField(value: self.id, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetBlockByIDRequest, rhs: Flow_Access_GetBlockByIDRequest) -> Bool { - if lhs.id != rhs.id {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetBlockByHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetBlockByHeightRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "height"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.height != 0 { - try visitor.visitSingularUInt64Field(value: self.height, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetBlockByHeightRequest, rhs: Flow_Access_GetBlockByHeightRequest) -> Bool { - if lhs.height != rhs.height {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_BlockResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".BlockResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "block"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._block) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if let v = self._block { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_BlockResponse, rhs: Flow_Access_BlockResponse) -> Bool { - if lhs._block != rhs._block {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetCollectionByIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetCollectionByIDRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.id.isEmpty { - try visitor.visitSingularBytesField(value: self.id, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetCollectionByIDRequest, rhs: Flow_Access_GetCollectionByIDRequest) -> Bool { - if lhs.id != rhs.id {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_CollectionResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".CollectionResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "collection"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._collection) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if let v = self._collection { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_CollectionResponse, rhs: Flow_Access_CollectionResponse) -> Bool { - if lhs._collection != rhs._collection {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_SendTransactionRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".SendTransactionRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "transaction"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._transaction) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if let v = self._transaction { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_SendTransactionRequest, rhs: Flow_Access_SendTransactionRequest) -> Bool { - if lhs._transaction != rhs._transaction {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_SendTransactionResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".SendTransactionResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.id.isEmpty { - try visitor.visitSingularBytesField(value: self.id, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_SendTransactionResponse, rhs: Flow_Access_SendTransactionResponse) -> Bool { - if lhs.id != rhs.id {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetTransactionRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetTransactionRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.id.isEmpty { - try visitor.visitSingularBytesField(value: self.id, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetTransactionRequest, rhs: Flow_Access_GetTransactionRequest) -> Bool { - if lhs.id != rhs.id {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_TransactionResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".TransactionResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "transaction"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._transaction) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if let v = self._transaction { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_TransactionResponse, rhs: Flow_Access_TransactionResponse) -> Bool { - if lhs._transaction != rhs._transaction {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_TransactionResultResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".TransactionResultResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "status"), - 2: .standard(proto: "status_code"), - 3: .standard(proto: "error_message"), - 4: .same(proto: "events"), - 5: .standard(proto: "block_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularEnumField(value: &self.status) }() - case 2: try { try decoder.decodeSingularUInt32Field(value: &self.statusCode) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() - case 4: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() - case 5: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.status != .unknown { - try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) - } - if self.statusCode != 0 { - try visitor.visitSingularUInt32Field(value: self.statusCode, fieldNumber: 2) - } - if !self.errorMessage.isEmpty { - try visitor.visitSingularStringField(value: self.errorMessage, fieldNumber: 3) - } - if !self.events.isEmpty { - try visitor.visitRepeatedMessageField(value: self.events, fieldNumber: 4) - } - if !self.blockID.isEmpty { - try visitor.visitSingularBytesField(value: self.blockID, fieldNumber: 5) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_TransactionResultResponse, rhs: Flow_Access_TransactionResultResponse) -> Bool { - if lhs.status != rhs.status {return false} - if lhs.statusCode != rhs.statusCode {return false} - if lhs.errorMessage != rhs.errorMessage {return false} - if lhs.events != rhs.events {return false} - if lhs.blockID != rhs.blockID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetAccountRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetAccountRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "address"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.address.isEmpty { - try visitor.visitSingularBytesField(value: self.address, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetAccountRequest, rhs: Flow_Access_GetAccountRequest) -> Bool { - if lhs.address != rhs.address {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetAccountResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetAccountResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "account"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._account) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if let v = self._account { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetAccountResponse, rhs: Flow_Access_GetAccountResponse) -> Bool { - if lhs._account != rhs._account {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetAccountAtLatestBlockRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetAccountAtLatestBlockRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "address"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.address.isEmpty { - try visitor.visitSingularBytesField(value: self.address, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetAccountAtLatestBlockRequest, rhs: Flow_Access_GetAccountAtLatestBlockRequest) -> Bool { - if lhs.address != rhs.address {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_AccountResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".AccountResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "account"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._account) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if let v = self._account { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_AccountResponse, rhs: Flow_Access_AccountResponse) -> Bool { - if lhs._account != rhs._account {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetAccountAtBlockHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetAccountAtBlockHeightRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "address"), - 2: .standard(proto: "block_height"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.address.isEmpty { - try visitor.visitSingularBytesField(value: self.address, fieldNumber: 1) - } - if self.blockHeight != 0 { - try visitor.visitSingularUInt64Field(value: self.blockHeight, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetAccountAtBlockHeightRequest, rhs: Flow_Access_GetAccountAtBlockHeightRequest) -> Bool { - if lhs.address != rhs.address {return false} - if lhs.blockHeight != rhs.blockHeight {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_ExecuteScriptAtLatestBlockRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtLatestBlockRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "script"), - 2: .same(proto: "arguments"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.script) }() - case 2: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.script.isEmpty { - try visitor.visitSingularBytesField(value: self.script, fieldNumber: 1) - } - if !self.arguments.isEmpty { - try visitor.visitRepeatedBytesField(value: self.arguments, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_ExecuteScriptAtLatestBlockRequest, rhs: Flow_Access_ExecuteScriptAtLatestBlockRequest) -> Bool { - if lhs.script != rhs.script {return false} - if lhs.arguments != rhs.arguments {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_ExecuteScriptAtBlockIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockIDRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "block_id"), - 2: .same(proto: "script"), - 3: .same(proto: "arguments"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.script) }() - case 3: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.blockID.isEmpty { - try visitor.visitSingularBytesField(value: self.blockID, fieldNumber: 1) - } - if !self.script.isEmpty { - try visitor.visitSingularBytesField(value: self.script, fieldNumber: 2) - } - if !self.arguments.isEmpty { - try visitor.visitRepeatedBytesField(value: self.arguments, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_ExecuteScriptAtBlockIDRequest, rhs: Flow_Access_ExecuteScriptAtBlockIDRequest) -> Bool { - if lhs.blockID != rhs.blockID {return false} - if lhs.script != rhs.script {return false} - if lhs.arguments != rhs.arguments {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_ExecuteScriptAtBlockHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockHeightRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "block_height"), - 2: .same(proto: "script"), - 3: .same(proto: "arguments"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.script) }() - case 3: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.blockHeight != 0 { - try visitor.visitSingularUInt64Field(value: self.blockHeight, fieldNumber: 1) - } - if !self.script.isEmpty { - try visitor.visitSingularBytesField(value: self.script, fieldNumber: 2) - } - if !self.arguments.isEmpty { - try visitor.visitRepeatedBytesField(value: self.arguments, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_ExecuteScriptAtBlockHeightRequest, rhs: Flow_Access_ExecuteScriptAtBlockHeightRequest) -> Bool { - if lhs.blockHeight != rhs.blockHeight {return false} - if lhs.script != rhs.script {return false} - if lhs.arguments != rhs.arguments {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_ExecuteScriptResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "value"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.value) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.value.isEmpty { - try visitor.visitSingularBytesField(value: self.value, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_ExecuteScriptResponse, rhs: Flow_Access_ExecuteScriptResponse) -> Bool { - if lhs.value != rhs.value {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetEventsForHeightRangeRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetEventsForHeightRangeRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "type"), - 2: .standard(proto: "start_height"), - 3: .standard(proto: "end_height"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.startHeight) }() - case 3: try { try decoder.decodeSingularUInt64Field(value: &self.endHeight) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.type.isEmpty { - try visitor.visitSingularStringField(value: self.type, fieldNumber: 1) - } - if self.startHeight != 0 { - try visitor.visitSingularUInt64Field(value: self.startHeight, fieldNumber: 2) - } - if self.endHeight != 0 { - try visitor.visitSingularUInt64Field(value: self.endHeight, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetEventsForHeightRangeRequest, rhs: Flow_Access_GetEventsForHeightRangeRequest) -> Bool { - if lhs.type != rhs.type {return false} - if lhs.startHeight != rhs.startHeight {return false} - if lhs.endHeight != rhs.endHeight {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetEventsForBlockIDsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetEventsForBlockIDsRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "type"), - 2: .standard(proto: "block_ids"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() - case 2: try { try decoder.decodeRepeatedBytesField(value: &self.blockIds) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.type.isEmpty { - try visitor.visitSingularStringField(value: self.type, fieldNumber: 1) - } - if !self.blockIds.isEmpty { - try visitor.visitRepeatedBytesField(value: self.blockIds, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetEventsForBlockIDsRequest, rhs: Flow_Access_GetEventsForBlockIDsRequest) -> Bool { - if lhs.type != rhs.type {return false} - if lhs.blockIds != rhs.blockIds {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_EventsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".EventsResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "results"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.results) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.results.isEmpty { - try visitor.visitRepeatedMessageField(value: self.results, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_EventsResponse, rhs: Flow_Access_EventsResponse) -> Bool { - if lhs.results != rhs.results {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_EventsResponse.Result: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Flow_Access_EventsResponse.protoMessageName + ".Result" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "block_id"), - 2: .standard(proto: "block_height"), - 3: .same(proto: "events"), - 4: .standard(proto: "block_timestamp"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() - case 3: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() - case 4: try { try decoder.decodeSingularMessageField(value: &self._blockTimestamp) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.blockID.isEmpty { - try visitor.visitSingularBytesField(value: self.blockID, fieldNumber: 1) - } - if self.blockHeight != 0 { - try visitor.visitSingularUInt64Field(value: self.blockHeight, fieldNumber: 2) - } - if !self.events.isEmpty { - try visitor.visitRepeatedMessageField(value: self.events, fieldNumber: 3) - } - if let v = self._blockTimestamp { - try visitor.visitSingularMessageField(value: v, fieldNumber: 4) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_EventsResponse.Result, rhs: Flow_Access_EventsResponse.Result) -> Bool { - if lhs.blockID != rhs.blockID {return false} - if lhs.blockHeight != rhs.blockHeight {return false} - if lhs.events != rhs.events {return false} - if lhs._blockTimestamp != rhs._blockTimestamp {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetNetworkParametersRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetNetworkParametersRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - public mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - public func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetNetworkParametersRequest, rhs: Flow_Access_GetNetworkParametersRequest) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetNetworkParametersResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetNetworkParametersResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "chain_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.chainID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.chainID.isEmpty { - try visitor.visitSingularStringField(value: self.chainID, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetNetworkParametersResponse, rhs: Flow_Access_GetNetworkParametersResponse) -> Bool { - if lhs.chainID != rhs.chainID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_GetLatestProtocolStateSnapshotRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetLatestProtocolStateSnapshotRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - public mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - public func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_GetLatestProtocolStateSnapshotRequest, rhs: Flow_Access_GetLatestProtocolStateSnapshotRequest) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Access_ProtocolStateSnapshotResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ProtocolStateSnapshotResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "serializedSnapshot"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.serializedSnapshot) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.serializedSnapshot.isEmpty { - try visitor.visitSingularBytesField(value: self.serializedSnapshot, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Access_ProtocolStateSnapshotResponse, rhs: Flow_Access_ProtocolStateSnapshotResponse) -> Bool { - if lhs.serializedSnapshot != rhs.serializedSnapshot {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/Flow/Protobuf/Entities/account.pb.swift b/Sources/Flow/Protobuf/Entities/account.pb.swift deleted file mode 100644 index 1a6772a..0000000 --- a/Sources/Flow/Protobuf/Entities/account.pb.swift +++ /dev/null @@ -1,193 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: flow/entities/account.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -public struct Flow_Entities_Account { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var address: Data = Data() - - public var balance: UInt64 = 0 - - public var code: Data = Data() - - public var keys: [Flow_Entities_AccountKey] = [] - - public var contracts: Dictionary = [:] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Entities_AccountKey { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var index: UInt32 = 0 - - public var publicKey: Data = Data() - - public var signAlgo: UInt32 = 0 - - public var hashAlgo: UInt32 = 0 - - public var weight: UInt32 = 0 - - public var sequenceNumber: UInt32 = 0 - - public var revoked: Bool = false - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "flow.entities" - -extension Flow_Entities_Account: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".Account" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "address"), - 2: .same(proto: "balance"), - 3: .same(proto: "code"), - 4: .same(proto: "keys"), - 5: .same(proto: "contracts"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.balance) }() - case 3: try { try decoder.decodeSingularBytesField(value: &self.code) }() - case 4: try { try decoder.decodeRepeatedMessageField(value: &self.keys) }() - case 5: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.contracts) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.address.isEmpty { - try visitor.visitSingularBytesField(value: self.address, fieldNumber: 1) - } - if self.balance != 0 { - try visitor.visitSingularUInt64Field(value: self.balance, fieldNumber: 2) - } - if !self.code.isEmpty { - try visitor.visitSingularBytesField(value: self.code, fieldNumber: 3) - } - if !self.keys.isEmpty { - try visitor.visitRepeatedMessageField(value: self.keys, fieldNumber: 4) - } - if !self.contracts.isEmpty { - try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.contracts, fieldNumber: 5) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_Account, rhs: Flow_Entities_Account) -> Bool { - if lhs.address != rhs.address {return false} - if lhs.balance != rhs.balance {return false} - if lhs.code != rhs.code {return false} - if lhs.keys != rhs.keys {return false} - if lhs.contracts != rhs.contracts {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Entities_AccountKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".AccountKey" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "index"), - 2: .standard(proto: "public_key"), - 3: .standard(proto: "sign_algo"), - 4: .standard(proto: "hash_algo"), - 5: .same(proto: "weight"), - 6: .standard(proto: "sequence_number"), - 7: .same(proto: "revoked"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt32Field(value: &self.index) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.publicKey) }() - case 3: try { try decoder.decodeSingularUInt32Field(value: &self.signAlgo) }() - case 4: try { try decoder.decodeSingularUInt32Field(value: &self.hashAlgo) }() - case 5: try { try decoder.decodeSingularUInt32Field(value: &self.weight) }() - case 6: try { try decoder.decodeSingularUInt32Field(value: &self.sequenceNumber) }() - case 7: try { try decoder.decodeSingularBoolField(value: &self.revoked) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.index != 0 { - try visitor.visitSingularUInt32Field(value: self.index, fieldNumber: 1) - } - if !self.publicKey.isEmpty { - try visitor.visitSingularBytesField(value: self.publicKey, fieldNumber: 2) - } - if self.signAlgo != 0 { - try visitor.visitSingularUInt32Field(value: self.signAlgo, fieldNumber: 3) - } - if self.hashAlgo != 0 { - try visitor.visitSingularUInt32Field(value: self.hashAlgo, fieldNumber: 4) - } - if self.weight != 0 { - try visitor.visitSingularUInt32Field(value: self.weight, fieldNumber: 5) - } - if self.sequenceNumber != 0 { - try visitor.visitSingularUInt32Field(value: self.sequenceNumber, fieldNumber: 6) - } - if self.revoked != false { - try visitor.visitSingularBoolField(value: self.revoked, fieldNumber: 7) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_AccountKey, rhs: Flow_Entities_AccountKey) -> Bool { - if lhs.index != rhs.index {return false} - if lhs.publicKey != rhs.publicKey {return false} - if lhs.signAlgo != rhs.signAlgo {return false} - if lhs.hashAlgo != rhs.hashAlgo {return false} - if lhs.weight != rhs.weight {return false} - if lhs.sequenceNumber != rhs.sequenceNumber {return false} - if lhs.revoked != rhs.revoked {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/Flow/Protobuf/Entities/block.pb.swift b/Sources/Flow/Protobuf/Entities/block.pb.swift deleted file mode 100644 index 133f8b6..0000000 --- a/Sources/Flow/Protobuf/Entities/block.pb.swift +++ /dev/null @@ -1,126 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: flow/entities/block.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -public struct Flow_Entities_Block { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var id: Data = Data() - - public var parentID: Data = Data() - - public var height: UInt64 = 0 - - public var timestamp: SwiftProtobuf.Google_Protobuf_Timestamp { - get {return _timestamp ?? SwiftProtobuf.Google_Protobuf_Timestamp()} - set {_timestamp = newValue} - } - /// Returns true if `timestamp` has been explicitly set. - public var hasTimestamp: Bool {return self._timestamp != nil} - /// Clears the value of `timestamp`. Subsequent reads from it will return its default value. - public mutating func clearTimestamp() {self._timestamp = nil} - - public var collectionGuarantees: [Flow_Entities_CollectionGuarantee] = [] - - public var blockSeals: [Flow_Entities_BlockSeal] = [] - - public var signatures: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _timestamp: SwiftProtobuf.Google_Protobuf_Timestamp? = nil -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "flow.entities" - -extension Flow_Entities_Block: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".Block" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "id"), - 2: .standard(proto: "parent_id"), - 3: .same(proto: "height"), - 4: .same(proto: "timestamp"), - 5: .standard(proto: "collection_guarantees"), - 6: .standard(proto: "block_seals"), - 7: .same(proto: "signatures"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.parentID) }() - case 3: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() - case 4: try { try decoder.decodeSingularMessageField(value: &self._timestamp) }() - case 5: try { try decoder.decodeRepeatedMessageField(value: &self.collectionGuarantees) }() - case 6: try { try decoder.decodeRepeatedMessageField(value: &self.blockSeals) }() - case 7: try { try decoder.decodeRepeatedBytesField(value: &self.signatures) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.id.isEmpty { - try visitor.visitSingularBytesField(value: self.id, fieldNumber: 1) - } - if !self.parentID.isEmpty { - try visitor.visitSingularBytesField(value: self.parentID, fieldNumber: 2) - } - if self.height != 0 { - try visitor.visitSingularUInt64Field(value: self.height, fieldNumber: 3) - } - if let v = self._timestamp { - try visitor.visitSingularMessageField(value: v, fieldNumber: 4) - } - if !self.collectionGuarantees.isEmpty { - try visitor.visitRepeatedMessageField(value: self.collectionGuarantees, fieldNumber: 5) - } - if !self.blockSeals.isEmpty { - try visitor.visitRepeatedMessageField(value: self.blockSeals, fieldNumber: 6) - } - if !self.signatures.isEmpty { - try visitor.visitRepeatedBytesField(value: self.signatures, fieldNumber: 7) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_Block, rhs: Flow_Entities_Block) -> Bool { - if lhs.id != rhs.id {return false} - if lhs.parentID != rhs.parentID {return false} - if lhs.height != rhs.height {return false} - if lhs._timestamp != rhs._timestamp {return false} - if lhs.collectionGuarantees != rhs.collectionGuarantees {return false} - if lhs.blockSeals != rhs.blockSeals {return false} - if lhs.signatures != rhs.signatures {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/Flow/Protobuf/Entities/block_header.pb.swift b/Sources/Flow/Protobuf/Entities/block_header.pb.swift deleted file mode 100644 index 62e0006..0000000 --- a/Sources/Flow/Protobuf/Entities/block_header.pb.swift +++ /dev/null @@ -1,102 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: flow/entities/block_header.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -public struct Flow_Entities_BlockHeader { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var id: Data = Data() - - public var parentID: Data = Data() - - public var height: UInt64 = 0 - - public var timestamp: SwiftProtobuf.Google_Protobuf_Timestamp { - get {return _timestamp ?? SwiftProtobuf.Google_Protobuf_Timestamp()} - set {_timestamp = newValue} - } - /// Returns true if `timestamp` has been explicitly set. - public var hasTimestamp: Bool {return self._timestamp != nil} - /// Clears the value of `timestamp`. Subsequent reads from it will return its default value. - public mutating func clearTimestamp() {self._timestamp = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _timestamp: SwiftProtobuf.Google_Protobuf_Timestamp? = nil -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "flow.entities" - -extension Flow_Entities_BlockHeader: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".BlockHeader" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "id"), - 2: .standard(proto: "parent_id"), - 3: .same(proto: "height"), - 4: .same(proto: "timestamp"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.parentID) }() - case 3: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() - case 4: try { try decoder.decodeSingularMessageField(value: &self._timestamp) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.id.isEmpty { - try visitor.visitSingularBytesField(value: self.id, fieldNumber: 1) - } - if !self.parentID.isEmpty { - try visitor.visitSingularBytesField(value: self.parentID, fieldNumber: 2) - } - if self.height != 0 { - try visitor.visitSingularUInt64Field(value: self.height, fieldNumber: 3) - } - if let v = self._timestamp { - try visitor.visitSingularMessageField(value: v, fieldNumber: 4) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_BlockHeader, rhs: Flow_Entities_BlockHeader) -> Bool { - if lhs.id != rhs.id {return false} - if lhs.parentID != rhs.parentID {return false} - if lhs.height != rhs.height {return false} - if lhs._timestamp != rhs._timestamp {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/Flow/Protobuf/Entities/block_seal.pb.swift b/Sources/Flow/Protobuf/Entities/block_seal.pb.swift deleted file mode 100644 index c0afdaf..0000000 --- a/Sources/Flow/Protobuf/Entities/block_seal.pb.swift +++ /dev/null @@ -1,93 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: flow/entities/block_seal.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -public struct Flow_Entities_BlockSeal { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var blockID: Data = Data() - - public var executionReceiptID: Data = Data() - - public var executionReceiptSignatures: [Data] = [] - - public var resultApprovalSignatures: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "flow.entities" - -extension Flow_Entities_BlockSeal: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".BlockSeal" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "block_id"), - 2: .standard(proto: "execution_receipt_id"), - 3: .standard(proto: "execution_receipt_signatures"), - 4: .standard(proto: "result_approval_signatures"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.executionReceiptID) }() - case 3: try { try decoder.decodeRepeatedBytesField(value: &self.executionReceiptSignatures) }() - case 4: try { try decoder.decodeRepeatedBytesField(value: &self.resultApprovalSignatures) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.blockID.isEmpty { - try visitor.visitSingularBytesField(value: self.blockID, fieldNumber: 1) - } - if !self.executionReceiptID.isEmpty { - try visitor.visitSingularBytesField(value: self.executionReceiptID, fieldNumber: 2) - } - if !self.executionReceiptSignatures.isEmpty { - try visitor.visitRepeatedBytesField(value: self.executionReceiptSignatures, fieldNumber: 3) - } - if !self.resultApprovalSignatures.isEmpty { - try visitor.visitRepeatedBytesField(value: self.resultApprovalSignatures, fieldNumber: 4) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_BlockSeal, rhs: Flow_Entities_BlockSeal) -> Bool { - if lhs.blockID != rhs.blockID {return false} - if lhs.executionReceiptID != rhs.executionReceiptID {return false} - if lhs.executionReceiptSignatures != rhs.executionReceiptSignatures {return false} - if lhs.resultApprovalSignatures != rhs.resultApprovalSignatures {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/Flow/Protobuf/Entities/collection.pb.swift b/Sources/Flow/Protobuf/Entities/collection.pb.swift deleted file mode 100644 index ada5614..0000000 --- a/Sources/Flow/Protobuf/Entities/collection.pb.swift +++ /dev/null @@ -1,129 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: flow/entities/collection.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -public struct Flow_Entities_Collection { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var id: Data = Data() - - public var transactionIds: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Entities_CollectionGuarantee { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var collectionID: Data = Data() - - public var signatures: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "flow.entities" - -extension Flow_Entities_Collection: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".Collection" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "id"), - 2: .standard(proto: "transaction_ids"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() - case 2: try { try decoder.decodeRepeatedBytesField(value: &self.transactionIds) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.id.isEmpty { - try visitor.visitSingularBytesField(value: self.id, fieldNumber: 1) - } - if !self.transactionIds.isEmpty { - try visitor.visitRepeatedBytesField(value: self.transactionIds, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_Collection, rhs: Flow_Entities_Collection) -> Bool { - if lhs.id != rhs.id {return false} - if lhs.transactionIds != rhs.transactionIds {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Entities_CollectionGuarantee: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".CollectionGuarantee" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "collection_id"), - 2: .same(proto: "signatures"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.collectionID) }() - case 2: try { try decoder.decodeRepeatedBytesField(value: &self.signatures) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.collectionID.isEmpty { - try visitor.visitSingularBytesField(value: self.collectionID, fieldNumber: 1) - } - if !self.signatures.isEmpty { - try visitor.visitRepeatedBytesField(value: self.signatures, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_CollectionGuarantee, rhs: Flow_Entities_CollectionGuarantee) -> Bool { - if lhs.collectionID != rhs.collectionID {return false} - if lhs.signatures != rhs.signatures {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/Flow/Protobuf/Entities/event.pb.swift b/Sources/Flow/Protobuf/Entities/event.pb.swift deleted file mode 100644 index 49dcb05..0000000 --- a/Sources/Flow/Protobuf/Entities/event.pb.swift +++ /dev/null @@ -1,101 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: flow/entities/event.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -public struct Flow_Entities_Event { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var type: String = String() - - public var transactionID: Data = Data() - - public var transactionIndex: UInt32 = 0 - - public var eventIndex: UInt32 = 0 - - public var payload: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "flow.entities" - -extension Flow_Entities_Event: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".Event" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "type"), - 2: .standard(proto: "transaction_id"), - 3: .standard(proto: "transaction_index"), - 4: .standard(proto: "event_index"), - 5: .same(proto: "payload"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.transactionID) }() - case 3: try { try decoder.decodeSingularUInt32Field(value: &self.transactionIndex) }() - case 4: try { try decoder.decodeSingularUInt32Field(value: &self.eventIndex) }() - case 5: try { try decoder.decodeSingularBytesField(value: &self.payload) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.type.isEmpty { - try visitor.visitSingularStringField(value: self.type, fieldNumber: 1) - } - if !self.transactionID.isEmpty { - try visitor.visitSingularBytesField(value: self.transactionID, fieldNumber: 2) - } - if self.transactionIndex != 0 { - try visitor.visitSingularUInt32Field(value: self.transactionIndex, fieldNumber: 3) - } - if self.eventIndex != 0 { - try visitor.visitSingularUInt32Field(value: self.eventIndex, fieldNumber: 4) - } - if !self.payload.isEmpty { - try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 5) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_Event, rhs: Flow_Entities_Event) -> Bool { - if lhs.type != rhs.type {return false} - if lhs.transactionID != rhs.transactionID {return false} - if lhs.transactionIndex != rhs.transactionIndex {return false} - if lhs.eventIndex != rhs.eventIndex {return false} - if lhs.payload != rhs.payload {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/Flow/Protobuf/Entities/transaction.pb.swift b/Sources/Flow/Protobuf/Entities/transaction.pb.swift deleted file mode 100644 index b3f747a..0000000 --- a/Sources/Flow/Protobuf/Entities/transaction.pb.swift +++ /dev/null @@ -1,329 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: flow/entities/transaction.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -public enum Flow_Entities_TransactionStatus: SwiftProtobuf.Enum { - public typealias RawValue = Int - case unknown // = 0 - case pending // = 1 - case finalized // = 2 - case executed // = 3 - case sealed // = 4 - case expired // = 5 - case UNRECOGNIZED(Int) - - public init() { - self = .unknown - } - - public init?(rawValue: Int) { - switch rawValue { - case 0: self = .unknown - case 1: self = .pending - case 2: self = .finalized - case 3: self = .executed - case 4: self = .sealed - case 5: self = .expired - default: self = .UNRECOGNIZED(rawValue) - } - } - - public var rawValue: Int { - switch self { - case .unknown: return 0 - case .pending: return 1 - case .finalized: return 2 - case .executed: return 3 - case .sealed: return 4 - case .expired: return 5 - case .UNRECOGNIZED(let i): return i - } - } - -} - -#if swift(>=4.2) - -extension Flow_Entities_TransactionStatus: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Flow_Entities_TransactionStatus] = [ - .unknown, - .pending, - .finalized, - .executed, - .sealed, - .expired, - ] -} - -#endif // swift(>=4.2) - -public struct Flow_Entities_Transaction { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var script: Data = Data() - - public var arguments: [Data] = [] - - public var referenceBlockID: Data = Data() - - public var gasLimit: UInt64 = 0 - - public var proposalKey: Flow_Entities_Transaction.ProposalKey { - get {return _proposalKey ?? Flow_Entities_Transaction.ProposalKey()} - set {_proposalKey = newValue} - } - /// Returns true if `proposalKey` has been explicitly set. - public var hasProposalKey: Bool {return self._proposalKey != nil} - /// Clears the value of `proposalKey`. Subsequent reads from it will return its default value. - public mutating func clearProposalKey() {self._proposalKey = nil} - - public var payer: Data = Data() - - public var authorizers: [Data] = [] - - public var payloadSignatures: [Flow_Entities_Transaction.Signature] = [] - - public var envelopeSignatures: [Flow_Entities_Transaction.Signature] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public struct ProposalKey { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var address: Data = Data() - - public var keyID: UInt32 = 0 - - public var sequenceNumber: UInt64 = 0 - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public struct Signature { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var address: Data = Data() - - public var keyID: UInt32 = 0 - - public var signature: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} - - fileprivate var _proposalKey: Flow_Entities_Transaction.ProposalKey? = nil -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "flow.entities" - -extension Flow_Entities_TransactionStatus: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "UNKNOWN"), - 1: .same(proto: "PENDING"), - 2: .same(proto: "FINALIZED"), - 3: .same(proto: "EXECUTED"), - 4: .same(proto: "SEALED"), - 5: .same(proto: "EXPIRED"), - ] -} - -extension Flow_Entities_Transaction: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".Transaction" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "script"), - 2: .same(proto: "arguments"), - 3: .standard(proto: "reference_block_id"), - 4: .standard(proto: "gas_limit"), - 5: .standard(proto: "proposal_key"), - 6: .same(proto: "payer"), - 7: .same(proto: "authorizers"), - 8: .standard(proto: "payload_signatures"), - 9: .standard(proto: "envelope_signatures"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.script) }() - case 2: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() - case 3: try { try decoder.decodeSingularBytesField(value: &self.referenceBlockID) }() - case 4: try { try decoder.decodeSingularUInt64Field(value: &self.gasLimit) }() - case 5: try { try decoder.decodeSingularMessageField(value: &self._proposalKey) }() - case 6: try { try decoder.decodeSingularBytesField(value: &self.payer) }() - case 7: try { try decoder.decodeRepeatedBytesField(value: &self.authorizers) }() - case 8: try { try decoder.decodeRepeatedMessageField(value: &self.payloadSignatures) }() - case 9: try { try decoder.decodeRepeatedMessageField(value: &self.envelopeSignatures) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.script.isEmpty { - try visitor.visitSingularBytesField(value: self.script, fieldNumber: 1) - } - if !self.arguments.isEmpty { - try visitor.visitRepeatedBytesField(value: self.arguments, fieldNumber: 2) - } - if !self.referenceBlockID.isEmpty { - try visitor.visitSingularBytesField(value: self.referenceBlockID, fieldNumber: 3) - } - if self.gasLimit != 0 { - try visitor.visitSingularUInt64Field(value: self.gasLimit, fieldNumber: 4) - } - if let v = self._proposalKey { - try visitor.visitSingularMessageField(value: v, fieldNumber: 5) - } - if !self.payer.isEmpty { - try visitor.visitSingularBytesField(value: self.payer, fieldNumber: 6) - } - if !self.authorizers.isEmpty { - try visitor.visitRepeatedBytesField(value: self.authorizers, fieldNumber: 7) - } - if !self.payloadSignatures.isEmpty { - try visitor.visitRepeatedMessageField(value: self.payloadSignatures, fieldNumber: 8) - } - if !self.envelopeSignatures.isEmpty { - try visitor.visitRepeatedMessageField(value: self.envelopeSignatures, fieldNumber: 9) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_Transaction, rhs: Flow_Entities_Transaction) -> Bool { - if lhs.script != rhs.script {return false} - if lhs.arguments != rhs.arguments {return false} - if lhs.referenceBlockID != rhs.referenceBlockID {return false} - if lhs.gasLimit != rhs.gasLimit {return false} - if lhs._proposalKey != rhs._proposalKey {return false} - if lhs.payer != rhs.payer {return false} - if lhs.authorizers != rhs.authorizers {return false} - if lhs.payloadSignatures != rhs.payloadSignatures {return false} - if lhs.envelopeSignatures != rhs.envelopeSignatures {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Entities_Transaction.ProposalKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Flow_Entities_Transaction.protoMessageName + ".ProposalKey" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "address"), - 2: .standard(proto: "key_id"), - 3: .standard(proto: "sequence_number"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() - case 2: try { try decoder.decodeSingularUInt32Field(value: &self.keyID) }() - case 3: try { try decoder.decodeSingularUInt64Field(value: &self.sequenceNumber) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.address.isEmpty { - try visitor.visitSingularBytesField(value: self.address, fieldNumber: 1) - } - if self.keyID != 0 { - try visitor.visitSingularUInt32Field(value: self.keyID, fieldNumber: 2) - } - if self.sequenceNumber != 0 { - try visitor.visitSingularUInt64Field(value: self.sequenceNumber, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_Transaction.ProposalKey, rhs: Flow_Entities_Transaction.ProposalKey) -> Bool { - if lhs.address != rhs.address {return false} - if lhs.keyID != rhs.keyID {return false} - if lhs.sequenceNumber != rhs.sequenceNumber {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Entities_Transaction.Signature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Flow_Entities_Transaction.protoMessageName + ".Signature" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "address"), - 2: .standard(proto: "key_id"), - 3: .same(proto: "signature"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() - case 2: try { try decoder.decodeSingularUInt32Field(value: &self.keyID) }() - case 3: try { try decoder.decodeSingularBytesField(value: &self.signature) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.address.isEmpty { - try visitor.visitSingularBytesField(value: self.address, fieldNumber: 1) - } - if self.keyID != 0 { - try visitor.visitSingularUInt32Field(value: self.keyID, fieldNumber: 2) - } - if !self.signature.isEmpty { - try visitor.visitSingularBytesField(value: self.signature, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Entities_Transaction.Signature, rhs: Flow_Entities_Transaction.Signature) -> Bool { - if lhs.address != rhs.address {return false} - if lhs.keyID != rhs.keyID {return false} - if lhs.signature != rhs.signature {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Sources/Flow/Protobuf/Execution/execution.grpc.swift b/Sources/Flow/Protobuf/Execution/execution.grpc.swift deleted file mode 100644 index beb47ed..0000000 --- a/Sources/Flow/Protobuf/Execution/execution.grpc.swift +++ /dev/null @@ -1,305 +0,0 @@ -// -// DO NOT EDIT. -// -// Generated by the protocol buffer compiler. -// Source: flow/execution/execution.proto -// - -// -// Copyright 2018, gRPC Authors All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -import GRPC -import NIO -import SwiftProtobuf - - -/// ExecutionAPI is the API provided by the execution nodes. -/// -/// Usage: instantiate `Flow_Execution_ExecutionAPIClient`, then call methods of this protocol to make API calls. -public protocol Flow_Execution_ExecutionAPIClientProtocol: GRPCClient { - var serviceName: String { get } - var interceptors: Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol? { get } - - func ping( - _ request: Flow_Execution_PingRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getAccountAtBlockID( - _ request: Flow_Execution_GetAccountAtBlockIDRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func executeScriptAtBlockID( - _ request: Flow_Execution_ExecuteScriptAtBlockIDRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getEventsForBlockIDs( - _ request: Flow_Execution_GetEventsForBlockIDsRequest, - callOptions: CallOptions? - ) -> UnaryCall - - func getTransactionResult( - _ request: Flow_Execution_GetTransactionResultRequest, - callOptions: CallOptions? - ) -> UnaryCall -} - -extension Flow_Execution_ExecutionAPIClientProtocol { - public var serviceName: String { - return "flow.execution.ExecutionAPI" - } - - /// Ping is used to check if the access node is alive and healthy. - /// - /// - Parameters: - /// - request: Request to send to Ping. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func ping( - _ request: Flow_Execution_PingRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.execution.ExecutionAPI/Ping", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makePingInterceptors() ?? [] - ) - } - - /// GetAccountAtBlockID gets an account by address at the given block ID - /// - /// - Parameters: - /// - request: Request to send to GetAccountAtBlockID. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getAccountAtBlockID( - _ request: Flow_Execution_GetAccountAtBlockIDRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.execution.ExecutionAPI/GetAccountAtBlockID", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetAccountAtBlockIDInterceptors() ?? [] - ) - } - - /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the - /// execution state at the block with the given ID. - /// - /// - Parameters: - /// - request: Request to send to ExecuteScriptAtBlockID. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func executeScriptAtBlockID( - _ request: Flow_Execution_ExecuteScriptAtBlockIDRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.execution.ExecutionAPI/ExecuteScriptAtBlockID", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [] - ) - } - - /// GetEventsForBlockIDs retrieves events for all the specified block IDs that - /// have the given type - /// - /// - Parameters: - /// - request: Request to send to GetEventsForBlockIDs. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getEventsForBlockIDs( - _ request: Flow_Execution_GetEventsForBlockIDsRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.execution.ExecutionAPI/GetEventsForBlockIDs", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [] - ) - } - - /// GetTransactionResult gets the result of a transaction. - /// - /// - Parameters: - /// - request: Request to send to GetTransactionResult. - /// - callOptions: Call options. - /// - Returns: A `UnaryCall` with futures for the metadata, status and response. - public func getTransactionResult( - _ request: Flow_Execution_GetTransactionResultRequest, - callOptions: CallOptions? = nil - ) -> UnaryCall { - return self.makeUnaryCall( - path: "/flow.execution.ExecutionAPI/GetTransactionResult", - request: request, - callOptions: callOptions ?? self.defaultCallOptions, - interceptors: self.interceptors?.makeGetTransactionResultInterceptors() ?? [] - ) - } -} - -public protocol Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol { - - /// - Returns: Interceptors to use when invoking 'ping'. - func makePingInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getAccountAtBlockID'. - func makeGetAccountAtBlockIDInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'executeScriptAtBlockID'. - func makeExecuteScriptAtBlockIDInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getEventsForBlockIDs'. - func makeGetEventsForBlockIDsInterceptors() -> [ClientInterceptor] - - /// - Returns: Interceptors to use when invoking 'getTransactionResult'. - func makeGetTransactionResultInterceptors() -> [ClientInterceptor] -} - -public final class Flow_Execution_ExecutionAPIClient: Flow_Execution_ExecutionAPIClientProtocol { - public let channel: GRPCChannel - public var defaultCallOptions: CallOptions - public var interceptors: Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol? - - /// Creates a client for the flow.execution.ExecutionAPI service. - /// - /// - Parameters: - /// - channel: `GRPCChannel` to the service host. - /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. - /// - interceptors: A factory providing interceptors for each RPC. - public init( - channel: GRPCChannel, - defaultCallOptions: CallOptions = CallOptions(), - interceptors: Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol? = nil - ) { - self.channel = channel - self.defaultCallOptions = defaultCallOptions - self.interceptors = interceptors - } -} - -/// ExecutionAPI is the API provided by the execution nodes. -/// -/// To build a server, implement a class that conforms to this protocol. -public protocol Flow_Execution_ExecutionAPIProvider: CallHandlerProvider { - var interceptors: Flow_Execution_ExecutionAPIServerInterceptorFactoryProtocol? { get } - - /// Ping is used to check if the access node is alive and healthy. - func ping(request: Flow_Execution_PingRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetAccountAtBlockID gets an account by address at the given block ID - func getAccountAtBlockID(request: Flow_Execution_GetAccountAtBlockIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the - /// execution state at the block with the given ID. - func executeScriptAtBlockID(request: Flow_Execution_ExecuteScriptAtBlockIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetEventsForBlockIDs retrieves events for all the specified block IDs that - /// have the given type - func getEventsForBlockIDs(request: Flow_Execution_GetEventsForBlockIDsRequest, context: StatusOnlyCallContext) -> EventLoopFuture - - /// GetTransactionResult gets the result of a transaction. - func getTransactionResult(request: Flow_Execution_GetTransactionResultRequest, context: StatusOnlyCallContext) -> EventLoopFuture -} - -extension Flow_Execution_ExecutionAPIProvider { - public var serviceName: Substring { return "flow.execution.ExecutionAPI" } - - /// Determines, calls and returns the appropriate request handler, depending on the request's method. - /// Returns nil for methods not handled by this service. - public func handle( - method name: Substring, - context: CallHandlerContext - ) -> GRPCServerHandlerProtocol? { - switch name { - case "Ping": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makePingInterceptors() ?? [], - userFunction: self.ping(request:context:) - ) - - case "GetAccountAtBlockID": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetAccountAtBlockIDInterceptors() ?? [], - userFunction: self.getAccountAtBlockID(request:context:) - ) - - case "ExecuteScriptAtBlockID": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [], - userFunction: self.executeScriptAtBlockID(request:context:) - ) - - case "GetEventsForBlockIDs": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [], - userFunction: self.getEventsForBlockIDs(request:context:) - ) - - case "GetTransactionResult": - return UnaryServerHandler( - context: context, - requestDeserializer: ProtobufDeserializer(), - responseSerializer: ProtobufSerializer(), - interceptors: self.interceptors?.makeGetTransactionResultInterceptors() ?? [], - userFunction: self.getTransactionResult(request:context:) - ) - - default: - return nil - } - } -} - -public protocol Flow_Execution_ExecutionAPIServerInterceptorFactoryProtocol { - - /// - Returns: Interceptors to use when handling 'ping'. - /// Defaults to calling `self.makeInterceptors()`. - func makePingInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getAccountAtBlockID'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetAccountAtBlockIDInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'executeScriptAtBlockID'. - /// Defaults to calling `self.makeInterceptors()`. - func makeExecuteScriptAtBlockIDInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getEventsForBlockIDs'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetEventsForBlockIDsInterceptors() -> [ServerInterceptor] - - /// - Returns: Interceptors to use when handling 'getTransactionResult'. - /// Defaults to calling `self.makeInterceptors()`. - func makeGetTransactionResultInterceptors() -> [ServerInterceptor] -} diff --git a/Sources/Flow/Protobuf/Execution/execution.pb.swift b/Sources/Flow/Protobuf/Execution/execution.pb.swift deleted file mode 100644 index e10822d..0000000 --- a/Sources/Flow/Protobuf/Execution/execution.pb.swift +++ /dev/null @@ -1,560 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: flow/execution/execution.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -public struct Flow_Execution_PingRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Execution_PingResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Execution_GetAccountAtBlockIDRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var blockID: Data = Data() - - public var address: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Execution_GetAccountAtBlockIDResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var account: Flow_Entities_Account { - get {return _account ?? Flow_Entities_Account()} - set {_account = newValue} - } - /// Returns true if `account` has been explicitly set. - public var hasAccount: Bool {return self._account != nil} - /// Clears the value of `account`. Subsequent reads from it will return its default value. - public mutating func clearAccount() {self._account = nil} - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - - fileprivate var _account: Flow_Entities_Account? = nil -} - -public struct Flow_Execution_ExecuteScriptAtBlockIDRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var blockID: Data = Data() - - public var script: Data = Data() - - public var arguments: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Execution_ExecuteScriptAtBlockIDResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var value: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Execution_GetEventsForBlockIDsResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var results: [Flow_Execution_GetEventsForBlockIDsResponse.Result] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public struct Result { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var blockID: Data = Data() - - public var blockHeight: UInt64 = 0 - - public var events: [Flow_Entities_Event] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} - } - - public init() {} -} - -public struct Flow_Execution_GetEventsForBlockIDsRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var type: String = String() - - public var blockIds: [Data] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Execution_GetTransactionResultRequest { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var blockID: Data = Data() - - public var transactionID: Data = Data() - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -public struct Flow_Execution_GetTransactionResultResponse { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var statusCode: UInt32 = 0 - - public var errorMessage: String = String() - - public var events: [Flow_Entities_Event] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "flow.execution" - -extension Flow_Execution_PingRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PingRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - public mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - public func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_PingRequest, rhs: Flow_Execution_PingRequest) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Execution_PingResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".PingResponse" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - public mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { - } - } - - public func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_PingResponse, rhs: Flow_Execution_PingResponse) -> Bool { - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Execution_GetAccountAtBlockIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetAccountAtBlockIDRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "block_id"), - 2: .same(proto: "address"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.address) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.blockID.isEmpty { - try visitor.visitSingularBytesField(value: self.blockID, fieldNumber: 1) - } - if !self.address.isEmpty { - try visitor.visitSingularBytesField(value: self.address, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_GetAccountAtBlockIDRequest, rhs: Flow_Execution_GetAccountAtBlockIDRequest) -> Bool { - if lhs.blockID != rhs.blockID {return false} - if lhs.address != rhs.address {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Execution_GetAccountAtBlockIDResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetAccountAtBlockIDResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "account"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._account) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if let v = self._account { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_GetAccountAtBlockIDResponse, rhs: Flow_Execution_GetAccountAtBlockIDResponse) -> Bool { - if lhs._account != rhs._account {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Execution_ExecuteScriptAtBlockIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockIDRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "block_id"), - 2: .same(proto: "script"), - 3: .same(proto: "arguments"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.script) }() - case 3: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.blockID.isEmpty { - try visitor.visitSingularBytesField(value: self.blockID, fieldNumber: 1) - } - if !self.script.isEmpty { - try visitor.visitSingularBytesField(value: self.script, fieldNumber: 2) - } - if !self.arguments.isEmpty { - try visitor.visitRepeatedBytesField(value: self.arguments, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_ExecuteScriptAtBlockIDRequest, rhs: Flow_Execution_ExecuteScriptAtBlockIDRequest) -> Bool { - if lhs.blockID != rhs.blockID {return false} - if lhs.script != rhs.script {return false} - if lhs.arguments != rhs.arguments {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Execution_ExecuteScriptAtBlockIDResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockIDResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "value"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.value) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.value.isEmpty { - try visitor.visitSingularBytesField(value: self.value, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_ExecuteScriptAtBlockIDResponse, rhs: Flow_Execution_ExecuteScriptAtBlockIDResponse) -> Bool { - if lhs.value != rhs.value {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Execution_GetEventsForBlockIDsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetEventsForBlockIDsResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "results"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeRepeatedMessageField(value: &self.results) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.results.isEmpty { - try visitor.visitRepeatedMessageField(value: self.results, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_GetEventsForBlockIDsResponse, rhs: Flow_Execution_GetEventsForBlockIDsResponse) -> Bool { - if lhs.results != rhs.results {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Execution_GetEventsForBlockIDsResponse.Result: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = Flow_Execution_GetEventsForBlockIDsResponse.protoMessageName + ".Result" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "block_id"), - 2: .standard(proto: "block_height"), - 3: .same(proto: "events"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() - case 3: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.blockID.isEmpty { - try visitor.visitSingularBytesField(value: self.blockID, fieldNumber: 1) - } - if self.blockHeight != 0 { - try visitor.visitSingularUInt64Field(value: self.blockHeight, fieldNumber: 2) - } - if !self.events.isEmpty { - try visitor.visitRepeatedMessageField(value: self.events, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_GetEventsForBlockIDsResponse.Result, rhs: Flow_Execution_GetEventsForBlockIDsResponse.Result) -> Bool { - if lhs.blockID != rhs.blockID {return false} - if lhs.blockHeight != rhs.blockHeight {return false} - if lhs.events != rhs.events {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Execution_GetEventsForBlockIDsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetEventsForBlockIDsRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "type"), - 2: .standard(proto: "block_ids"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() - case 2: try { try decoder.decodeRepeatedBytesField(value: &self.blockIds) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.type.isEmpty { - try visitor.visitSingularStringField(value: self.type, fieldNumber: 1) - } - if !self.blockIds.isEmpty { - try visitor.visitRepeatedBytesField(value: self.blockIds, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_GetEventsForBlockIDsRequest, rhs: Flow_Execution_GetEventsForBlockIDsRequest) -> Bool { - if lhs.type != rhs.type {return false} - if lhs.blockIds != rhs.blockIds {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Execution_GetTransactionResultRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetTransactionResultRequest" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "block_id"), - 2: .standard(proto: "transaction_id"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() - case 2: try { try decoder.decodeSingularBytesField(value: &self.transactionID) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if !self.blockID.isEmpty { - try visitor.visitSingularBytesField(value: self.blockID, fieldNumber: 1) - } - if !self.transactionID.isEmpty { - try visitor.visitSingularBytesField(value: self.transactionID, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_GetTransactionResultRequest, rhs: Flow_Execution_GetTransactionResultRequest) -> Bool { - if lhs.blockID != rhs.blockID {return false} - if lhs.transactionID != rhs.transactionID {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} - -extension Flow_Execution_GetTransactionResultResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetTransactionResultResponse" - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "status_code"), - 2: .standard(proto: "error_message"), - 3: .same(proto: "events"), - ] - - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt32Field(value: &self.statusCode) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() - case 3: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() - default: break - } - } - } - - public func traverse(visitor: inout V) throws { - if self.statusCode != 0 { - try visitor.visitSingularUInt32Field(value: self.statusCode, fieldNumber: 1) - } - if !self.errorMessage.isEmpty { - try visitor.visitSingularStringField(value: self.errorMessage, fieldNumber: 2) - } - if !self.events.isEmpty { - try visitor.visitRepeatedMessageField(value: self.events, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) - } - - public static func ==(lhs: Flow_Execution_GetTransactionResultResponse, rhs: Flow_Execution_GetTransactionResultResponse) -> Bool { - if lhs.statusCode != rhs.statusCode {return false} - if lhs.errorMessage != rhs.errorMessage {return false} - if lhs.events != rhs.events {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/WalletKit/.gitignore b/WalletKit/.gitignore new file mode 100644 index 0000000..6025218 --- /dev/null +++ b/WalletKit/.gitignore @@ -0,0 +1,93 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Obj-C/Swift specific +*.hmap + +## App packaging +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +# *.xcodeproj +# +# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata +# hence it is not needed unless you have added a package configuration file to your project +# .swiftpm + +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build/ + +# Accio dependency management +Dependencies/ +.accio/ + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. +# Instead, use fastlane to re-generate the screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ +.DS_Store +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +Package.resolved diff --git a/WalletKit/CODE_OF_CONDUCT.md b/WalletKit/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..d1f37d9 --- /dev/null +++ b/WalletKit/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +hello@ryankopinsky.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/WalletKit/File b/WalletKit/File new file mode 100644 index 0000000..ffba9ac --- /dev/null +++ b/WalletKit/File @@ -0,0 +1,29 @@ + ping + +Blocks + retrieve a block by ID + retrieve a block by height + retrieve the latest block + +Collections: + retrieve a collection by ID + +Events: + retrieve events by name in the block height range + +Scripts: + submit a script and parse the response + submit a script with arguments and parse the response + +Accounts: + retrieve an account by address + create a new account + deploy a new contract to the account + remove a contract from the account + update an existing contract on the account + +Transactions: + retrieve a transaction by ID + sign a transaction (single payer, proposer, authorizer or combination of multiple) + submit a signed transaction + sign a transaction with arguments and submit it diff --git a/WalletKit/LICENSE b/WalletKit/LICENSE new file mode 100644 index 0000000..c4d1db5 --- /dev/null +++ b/WalletKit/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Ryan Kopinsky + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/WalletKit/Package.swift b/WalletKit/Package.swift new file mode 100644 index 0000000..b2c8c18 --- /dev/null +++ b/WalletKit/Package.swift @@ -0,0 +1,56 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "FlowWalletKit", + platforms: [ + .iOS(.v13), + .macOS(.v10_15), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "FlowWalletKit", + targets: ["FlowWalletKit"] + ), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + .package(name: "SwiftProtobuf", url: "https://github.com/apple/swift-protobuf.git", from: "1.17.0"), + .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.3.0"), + .package(url: "https://github.com/YusukeHosonuma/SwiftPrettyPrint.git", .upToNextMajor(from: "1.2.0")), + .package(url: "https://github.com/attaswift/BigInt.git", from: "5.3.0"), + .package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMajor(from: "1.4.1")), + .package(url: "https://github.com/mxcl/PromiseKit", from: "7.0.0-rc1"), + .package( + name: "secp256k1", + url: "https://github.com/GigaBitcoin/secp256k1.swift.git", + from: "0.3.0" + ), + + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "FlowAccess", + dependencies: ["SwiftProtobuf", .product(name: "GRPC", package: "grpc-swift")], + resources: [ + .process("README.md"), + .copy("Resources"), + ] + ), + + .target( + name: "FlowWalletKit", + dependencies: ["FlowAccess", "SwiftProtobuf", "SwiftPrettyPrint", "BigInt", "CryptoSwift", "PromiseKit", "secp256k1", .product(name: "GRPC", package: "grpc-swift")] + ), + + .testTarget( + name: "FlowSwiftTests", + dependencies: ["FlowAccess", "FlowWalletKit", "SwiftProtobuf", .product(name: "GRPC", package: "grpc-swift")] + ), + ] +) diff --git a/WalletKit/README.md b/WalletKit/README.md new file mode 100644 index 0000000..bb05fe5 --- /dev/null +++ b/WalletKit/README.md @@ -0,0 +1,88 @@ +

+ + + + +

+ +# Flow Swift SDK +The Flow Swift SDK is a Swift gRPC client for Flow (https://www.onflow.org). + +Currently the following Flow Access API methods have been implemented: + +### Connection +- [x] Ping + +### Accounts +- [x] GetAccountAtLatestBlock +- [x] GetAccountAtBlockHeight + +### Blocks +- [x] GetLatestBlock +- [x] GetBlockByHeight + +### Events +- [x] GetEventsForHeightRange + +### Scripts +- [x] ExecuteScriptAtLatestBlock +- [x] ExecuteScriptAtBlockHeight + +## Installation + +This is a Swift Package, and can be installed via Xcode with the URL of this repository: + +`https://github.com/ryankopinsky/flow-swift-sdk` + +[For more information on how to add a Swift Package using Xcode, see Apple's official documentation.](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) + + +## Usage + +```swift +// Connect to the Flow blockchain +let client = FlowClient(host: "access.mainnet.nodes.onflow.org", port: 9000) +client.ping { error in + if let error = error { + print("Ping Error: \(error.localizedDescription)") + } else { + print("Ping Success!") + } +} +``` + +### Accounts + +```swift +// Get account balance +let accountAddress = "0xead892083b3e2c6c" // Random address on mainnet +client.getAccount(address: accountAddress) { account, error in + guard let account = account else { + print("Error getAccount: \(error!.localizedDescription)") + return + } + + print("Account with address \(accountAddress) has balance \(account.balance).") +} +``` + +### Scripts + +```swift +// Execute sample script +let script = "pub fun main(): Int { return 1 }".data(using: .utf8)! +client.executeScript(script: script, arguments: []) { jsonData, error in + guard let jsonData = jsonData else { + print("Error executeScript: \(error!.localizedDescription)") + return + } + + print("executeScript - resultType: \(String(describing: jsonData["type"])), resultValue: \(String(describing: jsonData["value"])).") +} +``` + +Note: not all functionality is demonstrated in the above examples. To explore the capabilities of the Flow Swift SDK, feel free to check out the Tests folder. Most functionality will have a corresponding test case. + +## Contributing + +Contributions (such as feature requests, bug reports, pull requests etc) are welcome and encouraged. Make sure to abide by the [Code of Conduct](https://github.com/ryankopinsky/flow-swift-sdk/blob/main/CODE_OF_CONDUCT.md). diff --git a/WalletKit/Sources/Example/examples.swift b/WalletKit/Sources/Example/examples.swift new file mode 100644 index 0000000..8122bc4 --- /dev/null +++ b/WalletKit/Sources/Example/examples.swift @@ -0,0 +1,40 @@ +import CryptoKit +import Flow +import FlowSwift +import Foundation + +public func example_SendTransactionSingleSigner() { + let client = FlowClient() + + var keychain: MemoryKeychain = MemoryKeychain() + try keychain.addKey(address: FlowAddress("f8d6e0586b0a20c7"), + key: FlowKey(address: FlowAddress("f8d6e0586b0a20c7"), + keyId: 0, + key: "38b6f958c11a79312b1e44ba825299c03b9eaa362d571662366cdb4e08b59c32", + signingAlgorithm: FlowSignatureAlgorithm.ECDSA_P256, + hashAlgorithm: FlowHashAlgorithm.SHA3_256)) + + var script = "transaction {prepare(acct: AuthAccount) {} execute {}}" + + _ = try client.sendTransaction(script: script, singleSigner: "f8d6e0586b0a20c7", keychain: keychain).done { + result in + let txid = result + }.wait() + + _ = try client.getTransactionResult(id: FlowIdentifier("1d5315640e6dd20e28a1bf21ecc11964380a748915e69d4374f3ada497571a3b")).done { + txResult in + print(txResult.pretty) + + for event in txResult.events { + var payload = event.payload! + + print(payload.id) + + for field in payload.fields { + print(field) + } + } + } + + RunLoop.main.run() +} diff --git a/WalletKit/Sources/FlowAccess/Resources/README.md b/WalletKit/Sources/FlowAccess/Resources/README.md new file mode 100644 index 0000000..d9a006e --- /dev/null +++ b/WalletKit/Sources/FlowAccess/Resources/README.md @@ -0,0 +1,27 @@ +# Generating client code using the protocol buffer compiler. + +## Overview +Generating client code depends on the gRPC Swift API and code generator. gRPC is intended for use with Apple's SwiftProtobuf support for Protocol Buffers. Both gRPC and SwiftProtobuf contain code generation plugins for protoc, Google's Protocol Buffer compiler, and both contain libraries of supporting code that is needed to build and run the generated code. + +## Generating Code +### Step 1 +Before generating code, make sure gRPC Swift and SwiftProtobuf are properly installed and configured: +- gRPC: https://github.com/grpc/grpc-swift +- SwiftProtobuf: https://github.com/apple/swift-protobuf + +### Step 2 +Download the Flow Protocol Buffer Source Files from https://github.com/onflow/flow + +### Step 3 +Generate the code using the following commands: + +```console +$ cd flow-master && mkdir flow-pb && mkdir flow-grpc + +$ cd protobuf + +$ protoc --swift_out=../flow-pb --swift_opt=Visibility=Public flow/**/*.proto && protoc --grpc-swift_out=../flow-grpc --grpc-swift_opt=Visibility=Public flow/**/*.proto +``` + +### Step 4 +Import the gRPC and SwiftProtobuf files (*.grpc.swift and *.pb.swift, respectively) into Xcode. Note: Importing the legacy folder might cause issues with filenames clashing. diff --git a/WalletKit/Sources/FlowAccess/flow-grpc/access/access.grpc.swift b/WalletKit/Sources/FlowAccess/flow-grpc/access/access.grpc.swift new file mode 100644 index 0000000..c1ff94b --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-grpc/access/access.grpc.swift @@ -0,0 +1,1042 @@ +// +// DO NOT EDIT. +// +// Generated by the protocol buffer compiler. +// Source: flow/access/access.proto +// + +// +// Copyright 2018, gRPC Authors All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +import GRPC +import NIO +import SwiftProtobuf + +/// AccessAPI is the public-facing API provided by access nodes. +/// +/// Usage: instantiate `Flow_Access_AccessAPIClient`, then call methods of this protocol to make API calls. +public protocol Flow_Access_AccessAPIClientProtocol: GRPCClient { + var serviceName: String { get } + var interceptors: Flow_Access_AccessAPIClientInterceptorFactoryProtocol? { get } + + func ping( + _ request: Flow_Access_PingRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getLatestBlockHeader( + _ request: Flow_Access_GetLatestBlockHeaderRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getBlockHeaderByID( + _ request: Flow_Access_GetBlockHeaderByIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getBlockHeaderByHeight( + _ request: Flow_Access_GetBlockHeaderByHeightRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getLatestBlock( + _ request: Flow_Access_GetLatestBlockRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getBlockByID( + _ request: Flow_Access_GetBlockByIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getBlockByHeight( + _ request: Flow_Access_GetBlockByHeightRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getCollectionByID( + _ request: Flow_Access_GetCollectionByIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func sendTransaction( + _ request: Flow_Access_SendTransactionRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getTransaction( + _ request: Flow_Access_GetTransactionRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getTransactionResult( + _ request: Flow_Access_GetTransactionRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getAccount( + _ request: Flow_Access_GetAccountRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getAccountAtLatestBlock( + _ request: Flow_Access_GetAccountAtLatestBlockRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getAccountAtBlockHeight( + _ request: Flow_Access_GetAccountAtBlockHeightRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func executeScriptAtLatestBlock( + _ request: Flow_Access_ExecuteScriptAtLatestBlockRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func executeScriptAtBlockID( + _ request: Flow_Access_ExecuteScriptAtBlockIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func executeScriptAtBlockHeight( + _ request: Flow_Access_ExecuteScriptAtBlockHeightRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getEventsForHeightRange( + _ request: Flow_Access_GetEventsForHeightRangeRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getEventsForBlockIDs( + _ request: Flow_Access_GetEventsForBlockIDsRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getNetworkParameters( + _ request: Flow_Access_GetNetworkParametersRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getLatestProtocolStateSnapshot( + _ request: Flow_Access_GetLatestProtocolStateSnapshotRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getExecutionResultForBlockID( + _ request: Flow_Access_GetExecutionResultForBlockIDRequest, + callOptions: CallOptions? + ) -> UnaryCall +} + +extension Flow_Access_AccessAPIClientProtocol { + public var serviceName: String { + return "flow.access.AccessAPI" + } + + /// Ping is used to check if the access node is alive and healthy. + /// + /// - Parameters: + /// - request: Request to send to Ping. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func ping( + _ request: Flow_Access_PingRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/Ping", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makePingInterceptors() ?? [] + ) + } + + /// GetLatestBlockHeader gets the latest sealed or unsealed block header. + /// + /// - Parameters: + /// - request: Request to send to GetLatestBlockHeader. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getLatestBlockHeader( + _ request: Flow_Access_GetLatestBlockHeaderRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetLatestBlockHeader", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetLatestBlockHeaderInterceptors() ?? [] + ) + } + + /// GetBlockHeaderByID gets a block header by ID. + /// + /// - Parameters: + /// - request: Request to send to GetBlockHeaderByID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getBlockHeaderByID( + _ request: Flow_Access_GetBlockHeaderByIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetBlockHeaderByID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetBlockHeaderByIDInterceptors() ?? [] + ) + } + + /// GetBlockHeaderByHeight gets a block header by height. + /// + /// - Parameters: + /// - request: Request to send to GetBlockHeaderByHeight. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getBlockHeaderByHeight( + _ request: Flow_Access_GetBlockHeaderByHeightRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetBlockHeaderByHeight", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetBlockHeaderByHeightInterceptors() ?? [] + ) + } + + /// GetLatestBlock gets the full payload of the latest sealed or unsealed + /// block. + /// + /// - Parameters: + /// - request: Request to send to GetLatestBlock. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getLatestBlock( + _ request: Flow_Access_GetLatestBlockRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetLatestBlock", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetLatestBlockInterceptors() ?? [] + ) + } + + /// GetBlockByID gets a full block by ID. + /// + /// - Parameters: + /// - request: Request to send to GetBlockByID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getBlockByID( + _ request: Flow_Access_GetBlockByIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetBlockByID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetBlockByIDInterceptors() ?? [] + ) + } + + /// GetBlockByHeight gets a full block by height. + /// + /// - Parameters: + /// - request: Request to send to GetBlockByHeight. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getBlockByHeight( + _ request: Flow_Access_GetBlockByHeightRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetBlockByHeight", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetBlockByHeightInterceptors() ?? [] + ) + } + + /// GetCollectionByID gets a collection by ID. + /// + /// - Parameters: + /// - request: Request to send to GetCollectionByID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getCollectionByID( + _ request: Flow_Access_GetCollectionByIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetCollectionByID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetCollectionByIDInterceptors() ?? [] + ) + } + + /// SendTransaction submits a transaction to the network. + /// + /// - Parameters: + /// - request: Request to send to SendTransaction. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func sendTransaction( + _ request: Flow_Access_SendTransactionRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/SendTransaction", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeSendTransactionInterceptors() ?? [] + ) + } + + /// GetTransaction gets a transaction by ID. + /// + /// - Parameters: + /// - request: Request to send to GetTransaction. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getTransaction( + _ request: Flow_Access_GetTransactionRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetTransaction", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetTransactionInterceptors() ?? [] + ) + } + + /// GetTransactionResult gets the result of a transaction. + /// + /// - Parameters: + /// - request: Request to send to GetTransactionResult. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getTransactionResult( + _ request: Flow_Access_GetTransactionRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetTransactionResult", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetTransactionResultInterceptors() ?? [] + ) + } + + /// GetAccount is an alias for GetAccountAtLatestBlock. + /// + /// Warning: this function is deprecated. It behaves identically to + /// GetAccountAtLatestBlock and will be removed in a future version. + /// + /// - Parameters: + /// - request: Request to send to GetAccount. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getAccount( + _ request: Flow_Access_GetAccountRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetAccount", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetAccountInterceptors() ?? [] + ) + } + + /// GetAccountAtLatestBlock gets an account by address from the latest sealed + /// execution state. + /// + /// - Parameters: + /// - request: Request to send to GetAccountAtLatestBlock. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getAccountAtLatestBlock( + _ request: Flow_Access_GetAccountAtLatestBlockRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetAccountAtLatestBlock", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetAccountAtLatestBlockInterceptors() ?? [] + ) + } + + /// GetAccountAtBlockHeight gets an account by address at the given block + /// height + /// + /// - Parameters: + /// - request: Request to send to GetAccountAtBlockHeight. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getAccountAtBlockHeight( + _ request: Flow_Access_GetAccountAtBlockHeightRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetAccountAtBlockHeight", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetAccountAtBlockHeightInterceptors() ?? [] + ) + } + + /// ExecuteScriptAtLatestBlock executes a read-only Cadence script against the + /// latest sealed execution state. + /// + /// - Parameters: + /// - request: Request to send to ExecuteScriptAtLatestBlock. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func executeScriptAtLatestBlock( + _ request: Flow_Access_ExecuteScriptAtLatestBlockRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/ExecuteScriptAtLatestBlock", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeExecuteScriptAtLatestBlockInterceptors() ?? [] + ) + } + + /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the + /// execution state at the block with the given ID. + /// + /// - Parameters: + /// - request: Request to send to ExecuteScriptAtBlockID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func executeScriptAtBlockID( + _ request: Flow_Access_ExecuteScriptAtBlockIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/ExecuteScriptAtBlockID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [] + ) + } + + /// ExecuteScriptAtBlockHeight executes a ready-only Cadence script against the + /// execution state at the given block height. + /// + /// - Parameters: + /// - request: Request to send to ExecuteScriptAtBlockHeight. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func executeScriptAtBlockHeight( + _ request: Flow_Access_ExecuteScriptAtBlockHeightRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/ExecuteScriptAtBlockHeight", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeExecuteScriptAtBlockHeightInterceptors() ?? [] + ) + } + + /// GetEventsForHeightRange retrieves events emitted within the specified block + /// range. + /// + /// - Parameters: + /// - request: Request to send to GetEventsForHeightRange. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getEventsForHeightRange( + _ request: Flow_Access_GetEventsForHeightRangeRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetEventsForHeightRange", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetEventsForHeightRangeInterceptors() ?? [] + ) + } + + /// GetEventsForBlockIDs retrieves events for the specified block IDs and event + /// type. + /// + /// - Parameters: + /// - request: Request to send to GetEventsForBlockIDs. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getEventsForBlockIDs( + _ request: Flow_Access_GetEventsForBlockIDsRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetEventsForBlockIDs", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [] + ) + } + + /// GetNetworkParameters retrieves the Flow network details + /// + /// - Parameters: + /// - request: Request to send to GetNetworkParameters. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getNetworkParameters( + _ request: Flow_Access_GetNetworkParametersRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetNetworkParameters", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetNetworkParametersInterceptors() ?? [] + ) + } + + /// GetLatestProtocolStateSnapshot retrieves the latest sealed protocol state + /// snapshot. Used by Flow nodes joining the network to bootstrap a + /// space-efficient local state. + /// + /// - Parameters: + /// - request: Request to send to GetLatestProtocolStateSnapshot. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getLatestProtocolStateSnapshot( + _ request: Flow_Access_GetLatestProtocolStateSnapshotRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetLatestProtocolStateSnapshot", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetLatestProtocolStateSnapshotInterceptors() ?? [] + ) + } + + /// GetExecutionResultForBlockID returns Execution Result for a given block. + /// At present, Access Node might not have execution results for every block + /// and as usual, until sealed, this data can change + /// + /// - Parameters: + /// - request: Request to send to GetExecutionResultForBlockID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getExecutionResultForBlockID( + _ request: Flow_Access_GetExecutionResultForBlockIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.access.AccessAPI/GetExecutionResultForBlockID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetExecutionResultForBlockIDInterceptors() ?? [] + ) + } +} + +public protocol Flow_Access_AccessAPIClientInterceptorFactoryProtocol { + /// - Returns: Interceptors to use when invoking 'ping'. + func makePingInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getLatestBlockHeader'. + func makeGetLatestBlockHeaderInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getBlockHeaderByID'. + func makeGetBlockHeaderByIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getBlockHeaderByHeight'. + func makeGetBlockHeaderByHeightInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getLatestBlock'. + func makeGetLatestBlockInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getBlockByID'. + func makeGetBlockByIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getBlockByHeight'. + func makeGetBlockByHeightInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getCollectionByID'. + func makeGetCollectionByIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'sendTransaction'. + func makeSendTransactionInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getTransaction'. + func makeGetTransactionInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getTransactionResult'. + func makeGetTransactionResultInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getAccount'. + func makeGetAccountInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getAccountAtLatestBlock'. + func makeGetAccountAtLatestBlockInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getAccountAtBlockHeight'. + func makeGetAccountAtBlockHeightInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'executeScriptAtLatestBlock'. + func makeExecuteScriptAtLatestBlockInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'executeScriptAtBlockID'. + func makeExecuteScriptAtBlockIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'executeScriptAtBlockHeight'. + func makeExecuteScriptAtBlockHeightInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getEventsForHeightRange'. + func makeGetEventsForHeightRangeInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getEventsForBlockIDs'. + func makeGetEventsForBlockIDsInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getNetworkParameters'. + func makeGetNetworkParametersInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getLatestProtocolStateSnapshot'. + func makeGetLatestProtocolStateSnapshotInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getExecutionResultForBlockID'. + func makeGetExecutionResultForBlockIDInterceptors() -> [ClientInterceptor] +} + +public final class Flow_Access_AccessAPIClient: Flow_Access_AccessAPIClientProtocol { + public let channel: GRPCChannel + public var defaultCallOptions: CallOptions + public var interceptors: Flow_Access_AccessAPIClientInterceptorFactoryProtocol? + + /// Creates a client for the flow.access.AccessAPI service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + /// - interceptors: A factory providing interceptors for each RPC. + public init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: Flow_Access_AccessAPIClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + self.interceptors = interceptors + } +} + +/// AccessAPI is the public-facing API provided by access nodes. +/// +/// To build a server, implement a class that conforms to this protocol. +public protocol Flow_Access_AccessAPIProvider: CallHandlerProvider { + var interceptors: Flow_Access_AccessAPIServerInterceptorFactoryProtocol? { get } + + /// Ping is used to check if the access node is alive and healthy. + func ping(request: Flow_Access_PingRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetLatestBlockHeader gets the latest sealed or unsealed block header. + func getLatestBlockHeader(request: Flow_Access_GetLatestBlockHeaderRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetBlockHeaderByID gets a block header by ID. + func getBlockHeaderByID(request: Flow_Access_GetBlockHeaderByIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetBlockHeaderByHeight gets a block header by height. + func getBlockHeaderByHeight(request: Flow_Access_GetBlockHeaderByHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetLatestBlock gets the full payload of the latest sealed or unsealed + /// block. + func getLatestBlock(request: Flow_Access_GetLatestBlockRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetBlockByID gets a full block by ID. + func getBlockByID(request: Flow_Access_GetBlockByIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetBlockByHeight gets a full block by height. + func getBlockByHeight(request: Flow_Access_GetBlockByHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetCollectionByID gets a collection by ID. + func getCollectionByID(request: Flow_Access_GetCollectionByIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// SendTransaction submits a transaction to the network. + func sendTransaction(request: Flow_Access_SendTransactionRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetTransaction gets a transaction by ID. + func getTransaction(request: Flow_Access_GetTransactionRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetTransactionResult gets the result of a transaction. + func getTransactionResult(request: Flow_Access_GetTransactionRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetAccount is an alias for GetAccountAtLatestBlock. + /// + /// Warning: this function is deprecated. It behaves identically to + /// GetAccountAtLatestBlock and will be removed in a future version. + func getAccount(request: Flow_Access_GetAccountRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetAccountAtLatestBlock gets an account by address from the latest sealed + /// execution state. + func getAccountAtLatestBlock(request: Flow_Access_GetAccountAtLatestBlockRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetAccountAtBlockHeight gets an account by address at the given block + /// height + func getAccountAtBlockHeight(request: Flow_Access_GetAccountAtBlockHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// ExecuteScriptAtLatestBlock executes a read-only Cadence script against the + /// latest sealed execution state. + func executeScriptAtLatestBlock(request: Flow_Access_ExecuteScriptAtLatestBlockRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the + /// execution state at the block with the given ID. + func executeScriptAtBlockID(request: Flow_Access_ExecuteScriptAtBlockIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// ExecuteScriptAtBlockHeight executes a ready-only Cadence script against the + /// execution state at the given block height. + func executeScriptAtBlockHeight(request: Flow_Access_ExecuteScriptAtBlockHeightRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetEventsForHeightRange retrieves events emitted within the specified block + /// range. + func getEventsForHeightRange(request: Flow_Access_GetEventsForHeightRangeRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetEventsForBlockIDs retrieves events for the specified block IDs and event + /// type. + func getEventsForBlockIDs(request: Flow_Access_GetEventsForBlockIDsRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetNetworkParameters retrieves the Flow network details + func getNetworkParameters(request: Flow_Access_GetNetworkParametersRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetLatestProtocolStateSnapshot retrieves the latest sealed protocol state + /// snapshot. Used by Flow nodes joining the network to bootstrap a + /// space-efficient local state. + func getLatestProtocolStateSnapshot(request: Flow_Access_GetLatestProtocolStateSnapshotRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetExecutionResultForBlockID returns Execution Result for a given block. + /// At present, Access Node might not have execution results for every block + /// and as usual, until sealed, this data can change + func getExecutionResultForBlockID(request: Flow_Access_GetExecutionResultForBlockIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture +} + +extension Flow_Access_AccessAPIProvider { + public var serviceName: Substring { return "flow.access.AccessAPI" } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + public func handle( + method name: Substring, + context: CallHandlerContext + ) -> GRPCServerHandlerProtocol? { + switch name { + case "Ping": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makePingInterceptors() ?? [], + userFunction: ping(request:context:) + ) + + case "GetLatestBlockHeader": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetLatestBlockHeaderInterceptors() ?? [], + userFunction: getLatestBlockHeader(request:context:) + ) + + case "GetBlockHeaderByID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetBlockHeaderByIDInterceptors() ?? [], + userFunction: getBlockHeaderByID(request:context:) + ) + + case "GetBlockHeaderByHeight": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetBlockHeaderByHeightInterceptors() ?? [], + userFunction: getBlockHeaderByHeight(request:context:) + ) + + case "GetLatestBlock": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetLatestBlockInterceptors() ?? [], + userFunction: getLatestBlock(request:context:) + ) + + case "GetBlockByID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetBlockByIDInterceptors() ?? [], + userFunction: getBlockByID(request:context:) + ) + + case "GetBlockByHeight": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetBlockByHeightInterceptors() ?? [], + userFunction: getBlockByHeight(request:context:) + ) + + case "GetCollectionByID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetCollectionByIDInterceptors() ?? [], + userFunction: getCollectionByID(request:context:) + ) + + case "SendTransaction": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeSendTransactionInterceptors() ?? [], + userFunction: sendTransaction(request:context:) + ) + + case "GetTransaction": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetTransactionInterceptors() ?? [], + userFunction: getTransaction(request:context:) + ) + + case "GetTransactionResult": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetTransactionResultInterceptors() ?? [], + userFunction: getTransactionResult(request:context:) + ) + + case "GetAccount": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetAccountInterceptors() ?? [], + userFunction: getAccount(request:context:) + ) + + case "GetAccountAtLatestBlock": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetAccountAtLatestBlockInterceptors() ?? [], + userFunction: getAccountAtLatestBlock(request:context:) + ) + + case "GetAccountAtBlockHeight": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetAccountAtBlockHeightInterceptors() ?? [], + userFunction: getAccountAtBlockHeight(request:context:) + ) + + case "ExecuteScriptAtLatestBlock": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeExecuteScriptAtLatestBlockInterceptors() ?? [], + userFunction: executeScriptAtLatestBlock(request:context:) + ) + + case "ExecuteScriptAtBlockID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [], + userFunction: executeScriptAtBlockID(request:context:) + ) + + case "ExecuteScriptAtBlockHeight": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeExecuteScriptAtBlockHeightInterceptors() ?? [], + userFunction: executeScriptAtBlockHeight(request:context:) + ) + + case "GetEventsForHeightRange": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetEventsForHeightRangeInterceptors() ?? [], + userFunction: getEventsForHeightRange(request:context:) + ) + + case "GetEventsForBlockIDs": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [], + userFunction: getEventsForBlockIDs(request:context:) + ) + + case "GetNetworkParameters": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetNetworkParametersInterceptors() ?? [], + userFunction: getNetworkParameters(request:context:) + ) + + case "GetLatestProtocolStateSnapshot": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetLatestProtocolStateSnapshotInterceptors() ?? [], + userFunction: getLatestProtocolStateSnapshot(request:context:) + ) + + case "GetExecutionResultForBlockID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetExecutionResultForBlockIDInterceptors() ?? [], + userFunction: getExecutionResultForBlockID(request:context:) + ) + + default: + return nil + } + } +} + +public protocol Flow_Access_AccessAPIServerInterceptorFactoryProtocol { + /// - Returns: Interceptors to use when handling 'ping'. + /// Defaults to calling `self.makeInterceptors()`. + func makePingInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getLatestBlockHeader'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetLatestBlockHeaderInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getBlockHeaderByID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetBlockHeaderByIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getBlockHeaderByHeight'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetBlockHeaderByHeightInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getLatestBlock'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetLatestBlockInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getBlockByID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetBlockByIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getBlockByHeight'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetBlockByHeightInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getCollectionByID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetCollectionByIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'sendTransaction'. + /// Defaults to calling `self.makeInterceptors()`. + func makeSendTransactionInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getTransaction'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetTransactionInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getTransactionResult'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetTransactionResultInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getAccount'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetAccountInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getAccountAtLatestBlock'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetAccountAtLatestBlockInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getAccountAtBlockHeight'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetAccountAtBlockHeightInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'executeScriptAtLatestBlock'. + /// Defaults to calling `self.makeInterceptors()`. + func makeExecuteScriptAtLatestBlockInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'executeScriptAtBlockID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeExecuteScriptAtBlockIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'executeScriptAtBlockHeight'. + /// Defaults to calling `self.makeInterceptors()`. + func makeExecuteScriptAtBlockHeightInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getEventsForHeightRange'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetEventsForHeightRangeInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getEventsForBlockIDs'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetEventsForBlockIDsInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getNetworkParameters'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetNetworkParametersInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getLatestProtocolStateSnapshot'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetLatestProtocolStateSnapshotInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getExecutionResultForBlockID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetExecutionResultForBlockIDInterceptors() -> [ServerInterceptor] +} diff --git a/WalletKit/Sources/FlowAccess/flow-grpc/execution/execution.grpc.swift b/WalletKit/Sources/FlowAccess/flow-grpc/execution/execution.grpc.swift new file mode 100644 index 0000000..219cc39 --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-grpc/execution/execution.grpc.swift @@ -0,0 +1,302 @@ +// +// DO NOT EDIT. +// +// Generated by the protocol buffer compiler. +// Source: flow/execution/execution.proto +// + +// +// Copyright 2018, gRPC Authors All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +import GRPC +import NIO +import SwiftProtobuf + +/// ExecutionAPI is the API provided by the execution nodes. +/// +/// Usage: instantiate `Flow_Execution_ExecutionAPIClient`, then call methods of this protocol to make API calls. +public protocol Flow_Execution_ExecutionAPIClientProtocol: GRPCClient { + var serviceName: String { get } + var interceptors: Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol? { get } + + func ping( + _ request: Flow_Execution_PingRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getAccountAtBlockID( + _ request: Flow_Execution_GetAccountAtBlockIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func executeScriptAtBlockID( + _ request: Flow_Execution_ExecuteScriptAtBlockIDRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getEventsForBlockIDs( + _ request: Flow_Execution_GetEventsForBlockIDsRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func getTransactionResult( + _ request: Flow_Execution_GetTransactionResultRequest, + callOptions: CallOptions? + ) -> UnaryCall +} + +extension Flow_Execution_ExecutionAPIClientProtocol { + public var serviceName: String { + return "flow.execution.ExecutionAPI" + } + + /// Ping is used to check if the access node is alive and healthy. + /// + /// - Parameters: + /// - request: Request to send to Ping. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func ping( + _ request: Flow_Execution_PingRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.execution.ExecutionAPI/Ping", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makePingInterceptors() ?? [] + ) + } + + /// GetAccountAtBlockID gets an account by address at the given block ID + /// + /// - Parameters: + /// - request: Request to send to GetAccountAtBlockID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getAccountAtBlockID( + _ request: Flow_Execution_GetAccountAtBlockIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.execution.ExecutionAPI/GetAccountAtBlockID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetAccountAtBlockIDInterceptors() ?? [] + ) + } + + /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the + /// execution state at the block with the given ID. + /// + /// - Parameters: + /// - request: Request to send to ExecuteScriptAtBlockID. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func executeScriptAtBlockID( + _ request: Flow_Execution_ExecuteScriptAtBlockIDRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.execution.ExecutionAPI/ExecuteScriptAtBlockID", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [] + ) + } + + /// GetEventsForBlockIDs retrieves events for all the specified block IDs that + /// have the given type + /// + /// - Parameters: + /// - request: Request to send to GetEventsForBlockIDs. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getEventsForBlockIDs( + _ request: Flow_Execution_GetEventsForBlockIDsRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.execution.ExecutionAPI/GetEventsForBlockIDs", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [] + ) + } + + /// GetTransactionResult gets the result of a transaction. + /// + /// - Parameters: + /// - request: Request to send to GetTransactionResult. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + public func getTransactionResult( + _ request: Flow_Execution_GetTransactionResultRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return makeUnaryCall( + path: "/flow.execution.ExecutionAPI/GetTransactionResult", + request: request, + callOptions: callOptions ?? defaultCallOptions, + interceptors: interceptors?.makeGetTransactionResultInterceptors() ?? [] + ) + } +} + +public protocol Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol { + /// - Returns: Interceptors to use when invoking 'ping'. + func makePingInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getAccountAtBlockID'. + func makeGetAccountAtBlockIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'executeScriptAtBlockID'. + func makeExecuteScriptAtBlockIDInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getEventsForBlockIDs'. + func makeGetEventsForBlockIDsInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'getTransactionResult'. + func makeGetTransactionResultInterceptors() -> [ClientInterceptor] +} + +public final class Flow_Execution_ExecutionAPIClient: Flow_Execution_ExecutionAPIClientProtocol { + public let channel: GRPCChannel + public var defaultCallOptions: CallOptions + public var interceptors: Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol? + + /// Creates a client for the flow.execution.ExecutionAPI service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + /// - interceptors: A factory providing interceptors for each RPC. + public init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: Flow_Execution_ExecutionAPIClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + self.interceptors = interceptors + } +} + +/// ExecutionAPI is the API provided by the execution nodes. +/// +/// To build a server, implement a class that conforms to this protocol. +public protocol Flow_Execution_ExecutionAPIProvider: CallHandlerProvider { + var interceptors: Flow_Execution_ExecutionAPIServerInterceptorFactoryProtocol? { get } + + /// Ping is used to check if the access node is alive and healthy. + func ping(request: Flow_Execution_PingRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetAccountAtBlockID gets an account by address at the given block ID + func getAccountAtBlockID(request: Flow_Execution_GetAccountAtBlockIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// ExecuteScriptAtBlockID executes a ready-only Cadence script against the + /// execution state at the block with the given ID. + func executeScriptAtBlockID(request: Flow_Execution_ExecuteScriptAtBlockIDRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetEventsForBlockIDs retrieves events for all the specified block IDs that + /// have the given type + func getEventsForBlockIDs(request: Flow_Execution_GetEventsForBlockIDsRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + /// GetTransactionResult gets the result of a transaction. + func getTransactionResult(request: Flow_Execution_GetTransactionResultRequest, context: StatusOnlyCallContext) -> EventLoopFuture +} + +extension Flow_Execution_ExecutionAPIProvider { + public var serviceName: Substring { return "flow.execution.ExecutionAPI" } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + public func handle( + method name: Substring, + context: CallHandlerContext + ) -> GRPCServerHandlerProtocol? { + switch name { + case "Ping": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makePingInterceptors() ?? [], + userFunction: ping(request:context:) + ) + + case "GetAccountAtBlockID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetAccountAtBlockIDInterceptors() ?? [], + userFunction: getAccountAtBlockID(request:context:) + ) + + case "ExecuteScriptAtBlockID": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeExecuteScriptAtBlockIDInterceptors() ?? [], + userFunction: executeScriptAtBlockID(request:context:) + ) + + case "GetEventsForBlockIDs": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetEventsForBlockIDsInterceptors() ?? [], + userFunction: getEventsForBlockIDs(request:context:) + ) + + case "GetTransactionResult": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: interceptors?.makeGetTransactionResultInterceptors() ?? [], + userFunction: getTransactionResult(request:context:) + ) + + default: + return nil + } + } +} + +public protocol Flow_Execution_ExecutionAPIServerInterceptorFactoryProtocol { + /// - Returns: Interceptors to use when handling 'ping'. + /// Defaults to calling `self.makeInterceptors()`. + func makePingInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getAccountAtBlockID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetAccountAtBlockIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'executeScriptAtBlockID'. + /// Defaults to calling `self.makeInterceptors()`. + func makeExecuteScriptAtBlockIDInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getEventsForBlockIDs'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetEventsForBlockIDsInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'getTransactionResult'. + /// Defaults to calling `self.makeInterceptors()`. + func makeGetTransactionResultInterceptors() -> [ServerInterceptor] +} diff --git a/WalletKit/Sources/FlowAccess/flow-pb/access/access.pb.swift b/WalletKit/Sources/FlowAccess/flow-pb/access/access.pb.swift new file mode 100644 index 0000000..196ef2d --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-pb/access/access.pb.swift @@ -0,0 +1,1763 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/access/access.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Access_PingRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_PingResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetLatestBlockHeaderRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var isSealed: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetBlockHeaderByIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetBlockHeaderByHeightRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var height: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_BlockHeaderResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var block: Flow_Entities_BlockHeader { + get { return _block ?? Flow_Entities_BlockHeader() } + set { _block = newValue } + } + + /// Returns true if `block` has been explicitly set. + public var hasBlock: Bool { return _block != nil } + /// Clears the value of `block`. Subsequent reads from it will return its default value. + public mutating func clearBlock() { _block = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _block: Flow_Entities_BlockHeader? +} + +public struct Flow_Access_GetLatestBlockRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var isSealed: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetBlockByIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetBlockByHeightRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var height: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_BlockResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var block: Flow_Entities_Block { + get { return _block ?? Flow_Entities_Block() } + set { _block = newValue } + } + + /// Returns true if `block` has been explicitly set. + public var hasBlock: Bool { return _block != nil } + /// Clears the value of `block`. Subsequent reads from it will return its default value. + public mutating func clearBlock() { _block = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _block: Flow_Entities_Block? +} + +public struct Flow_Access_GetCollectionByIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_CollectionResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var collection: Flow_Entities_Collection { + get { return _collection ?? Flow_Entities_Collection() } + set { _collection = newValue } + } + + /// Returns true if `collection` has been explicitly set. + public var hasCollection: Bool { return _collection != nil } + /// Clears the value of `collection`. Subsequent reads from it will return its default value. + public mutating func clearCollection() { _collection = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _collection: Flow_Entities_Collection? +} + +public struct Flow_Access_SendTransactionRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var transaction: Flow_Entities_Transaction { + get { return _transaction ?? Flow_Entities_Transaction() } + set { _transaction = newValue } + } + + /// Returns true if `transaction` has been explicitly set. + public var hasTransaction: Bool { return _transaction != nil } + /// Clears the value of `transaction`. Subsequent reads from it will return its default value. + public mutating func clearTransaction() { _transaction = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _transaction: Flow_Entities_Transaction? +} + +public struct Flow_Access_SendTransactionResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetTransactionRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_TransactionResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var transaction: Flow_Entities_Transaction { + get { return _transaction ?? Flow_Entities_Transaction() } + set { _transaction = newValue } + } + + /// Returns true if `transaction` has been explicitly set. + public var hasTransaction: Bool { return _transaction != nil } + /// Clears the value of `transaction`. Subsequent reads from it will return its default value. + public mutating func clearTransaction() { _transaction = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _transaction: Flow_Entities_Transaction? +} + +public struct Flow_Access_TransactionResultResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var status: Flow_Entities_TransactionStatus = .unknown + + public var statusCode: UInt32 = 0 + + public var errorMessage: String = String() + + public var events: [Flow_Entities_Event] = [] + + public var blockID: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetAccountRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetAccountResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var account: Flow_Entities_Account { + get { return _account ?? Flow_Entities_Account() } + set { _account = newValue } + } + + /// Returns true if `account` has been explicitly set. + public var hasAccount: Bool { return _account != nil } + /// Clears the value of `account`. Subsequent reads from it will return its default value. + public mutating func clearAccount() { _account = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _account: Flow_Entities_Account? +} + +public struct Flow_Access_GetAccountAtLatestBlockRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_AccountResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var account: Flow_Entities_Account { + get { return _account ?? Flow_Entities_Account() } + set { _account = newValue } + } + + /// Returns true if `account` has been explicitly set. + public var hasAccount: Bool { return _account != nil } + /// Clears the value of `account`. Subsequent reads from it will return its default value. + public mutating func clearAccount() { _account = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _account: Flow_Entities_Account? +} + +public struct Flow_Access_GetAccountAtBlockHeightRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var blockHeight: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ExecuteScriptAtLatestBlockRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var script: Data = Data() + + public var arguments: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ExecuteScriptAtBlockIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var script: Data = Data() + + public var arguments: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ExecuteScriptAtBlockHeightRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockHeight: UInt64 = 0 + + public var script: Data = Data() + + public var arguments: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ExecuteScriptResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var value: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetEventsForHeightRangeRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var type: String = String() + + public var startHeight: UInt64 = 0 + + public var endHeight: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetEventsForBlockIDsRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var type: String = String() + + public var blockIds: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_EventsResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var results: [Flow_Access_EventsResponse.Result] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public struct Result { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var blockHeight: UInt64 = 0 + + public var events: [Flow_Entities_Event] = [] + + public var blockTimestamp: SwiftProtobuf.Google_Protobuf_Timestamp { + get { return _blockTimestamp ?? SwiftProtobuf.Google_Protobuf_Timestamp() } + set { _blockTimestamp = newValue } + } + + /// Returns true if `blockTimestamp` has been explicitly set. + public var hasBlockTimestamp: Bool { return _blockTimestamp != nil } + /// Clears the value of `blockTimestamp`. Subsequent reads from it will return its default value. + public mutating func clearBlockTimestamp() { _blockTimestamp = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _blockTimestamp: SwiftProtobuf.Google_Protobuf_Timestamp? + } + + public init() {} +} + +public struct Flow_Access_GetNetworkParametersRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetNetworkParametersResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var chainID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetLatestProtocolStateSnapshotRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ProtocolStateSnapshotResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var serializedSnapshot: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_GetExecutionResultForBlockIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Access_ExecutionResultForBlockIDResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var executionResult: Flow_Entities_ExecutionResult { + get { return _executionResult ?? Flow_Entities_ExecutionResult() } + set { _executionResult = newValue } + } + + /// Returns true if `executionResult` has been explicitly set. + public var hasExecutionResult: Bool { return _executionResult != nil } + /// Clears the value of `executionResult`. Subsequent reads from it will return its default value. + public mutating func clearExecutionResult() { _executionResult = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _executionResult: Flow_Entities_ExecutionResult? +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.access" + +extension Flow_Access_PingRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PingRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_PingRequest, rhs: Flow_Access_PingRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_PingResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PingResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_PingResponse, rhs: Flow_Access_PingResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetLatestBlockHeaderRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetLatestBlockHeaderRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "is_sealed"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBoolField(value: &self.isSealed) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if isSealed != false { + try visitor.visitSingularBoolField(value: isSealed, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetLatestBlockHeaderRequest, rhs: Flow_Access_GetLatestBlockHeaderRequest) -> Bool { + if lhs.isSealed != rhs.isSealed { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetBlockHeaderByIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetBlockHeaderByIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetBlockHeaderByIDRequest, rhs: Flow_Access_GetBlockHeaderByIDRequest) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetBlockHeaderByHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetBlockHeaderByHeightRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "height"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if height != 0 { + try visitor.visitSingularUInt64Field(value: height, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetBlockHeaderByHeightRequest, rhs: Flow_Access_GetBlockHeaderByHeightRequest) -> Bool { + if lhs.height != rhs.height { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_BlockHeaderResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".BlockHeaderResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "block"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._block) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._block { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_BlockHeaderResponse, rhs: Flow_Access_BlockHeaderResponse) -> Bool { + if lhs._block != rhs._block { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetLatestBlockRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetLatestBlockRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "is_sealed"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBoolField(value: &self.isSealed) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if isSealed != false { + try visitor.visitSingularBoolField(value: isSealed, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetLatestBlockRequest, rhs: Flow_Access_GetLatestBlockRequest) -> Bool { + if lhs.isSealed != rhs.isSealed { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetBlockByIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetBlockByIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetBlockByIDRequest, rhs: Flow_Access_GetBlockByIDRequest) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetBlockByHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetBlockByHeightRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "height"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if height != 0 { + try visitor.visitSingularUInt64Field(value: height, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetBlockByHeightRequest, rhs: Flow_Access_GetBlockByHeightRequest) -> Bool { + if lhs.height != rhs.height { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_BlockResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".BlockResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "block"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._block) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._block { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_BlockResponse, rhs: Flow_Access_BlockResponse) -> Bool { + if lhs._block != rhs._block { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetCollectionByIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetCollectionByIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetCollectionByIDRequest, rhs: Flow_Access_GetCollectionByIDRequest) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_CollectionResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CollectionResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "collection"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._collection) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._collection { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_CollectionResponse, rhs: Flow_Access_CollectionResponse) -> Bool { + if lhs._collection != rhs._collection { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_SendTransactionRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SendTransactionRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "transaction"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._transaction) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._transaction { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_SendTransactionRequest, rhs: Flow_Access_SendTransactionRequest) -> Bool { + if lhs._transaction != rhs._transaction { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_SendTransactionResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SendTransactionResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_SendTransactionResponse, rhs: Flow_Access_SendTransactionResponse) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetTransactionRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetTransactionRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetTransactionRequest, rhs: Flow_Access_GetTransactionRequest) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_TransactionResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".TransactionResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "transaction"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._transaction) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._transaction { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_TransactionResponse, rhs: Flow_Access_TransactionResponse) -> Bool { + if lhs._transaction != rhs._transaction { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_TransactionResultResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".TransactionResultResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + 2: .standard(proto: "status_code"), + 3: .standard(proto: "error_message"), + 4: .same(proto: "events"), + 5: .standard(proto: "block_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.status) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.statusCode) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() + case 4: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() + case 5: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if status != .unknown { + try visitor.visitSingularEnumField(value: status, fieldNumber: 1) + } + if statusCode != 0 { + try visitor.visitSingularUInt32Field(value: statusCode, fieldNumber: 2) + } + if !errorMessage.isEmpty { + try visitor.visitSingularStringField(value: errorMessage, fieldNumber: 3) + } + if !events.isEmpty { + try visitor.visitRepeatedMessageField(value: events, fieldNumber: 4) + } + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_TransactionResultResponse, rhs: Flow_Access_TransactionResultResponse) -> Bool { + if lhs.status != rhs.status { return false } + if lhs.statusCode != rhs.statusCode { return false } + if lhs.errorMessage != rhs.errorMessage { return false } + if lhs.events != rhs.events { return false } + if lhs.blockID != rhs.blockID { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetAccountRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetAccountRequest, rhs: Flow_Access_GetAccountRequest) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetAccountResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "account"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._account) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._account { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetAccountResponse, rhs: Flow_Access_GetAccountResponse) -> Bool { + if lhs._account != rhs._account { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetAccountAtLatestBlockRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountAtLatestBlockRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetAccountAtLatestBlockRequest, rhs: Flow_Access_GetAccountAtLatestBlockRequest) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_AccountResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".AccountResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "account"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._account) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._account { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_AccountResponse, rhs: Flow_Access_AccountResponse) -> Bool { + if lhs._account != rhs._account { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetAccountAtBlockHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountAtBlockHeightRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .standard(proto: "block_height"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + if blockHeight != 0 { + try visitor.visitSingularUInt64Field(value: blockHeight, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetAccountAtBlockHeightRequest, rhs: Flow_Access_GetAccountAtBlockHeightRequest) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.blockHeight != rhs.blockHeight { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ExecuteScriptAtLatestBlockRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtLatestBlockRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "script"), + 2: .same(proto: "arguments"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.script) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !script.isEmpty { + try visitor.visitSingularBytesField(value: script, fieldNumber: 1) + } + if !arguments.isEmpty { + try visitor.visitRepeatedBytesField(value: arguments, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ExecuteScriptAtLatestBlockRequest, rhs: Flow_Access_ExecuteScriptAtLatestBlockRequest) -> Bool { + if lhs.script != rhs.script { return false } + if lhs.arguments != rhs.arguments { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ExecuteScriptAtBlockIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .same(proto: "script"), + 3: .same(proto: "arguments"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.script) }() + case 3: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if !script.isEmpty { + try visitor.visitSingularBytesField(value: script, fieldNumber: 2) + } + if !arguments.isEmpty { + try visitor.visitRepeatedBytesField(value: arguments, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ExecuteScriptAtBlockIDRequest, rhs: Flow_Access_ExecuteScriptAtBlockIDRequest) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.script != rhs.script { return false } + if lhs.arguments != rhs.arguments { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ExecuteScriptAtBlockHeightRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockHeightRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_height"), + 2: .same(proto: "script"), + 3: .same(proto: "arguments"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.script) }() + case 3: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if blockHeight != 0 { + try visitor.visitSingularUInt64Field(value: blockHeight, fieldNumber: 1) + } + if !script.isEmpty { + try visitor.visitSingularBytesField(value: script, fieldNumber: 2) + } + if !arguments.isEmpty { + try visitor.visitRepeatedBytesField(value: arguments, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ExecuteScriptAtBlockHeightRequest, rhs: Flow_Access_ExecuteScriptAtBlockHeightRequest) -> Bool { + if lhs.blockHeight != rhs.blockHeight { return false } + if lhs.script != rhs.script { return false } + if lhs.arguments != rhs.arguments { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ExecuteScriptResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "value"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.value) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !value.isEmpty { + try visitor.visitSingularBytesField(value: value, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ExecuteScriptResponse, rhs: Flow_Access_ExecuteScriptResponse) -> Bool { + if lhs.value != rhs.value { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetEventsForHeightRangeRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetEventsForHeightRangeRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "start_height"), + 3: .standard(proto: "end_height"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.startHeight) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.endHeight) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !type.isEmpty { + try visitor.visitSingularStringField(value: type, fieldNumber: 1) + } + if startHeight != 0 { + try visitor.visitSingularUInt64Field(value: startHeight, fieldNumber: 2) + } + if endHeight != 0 { + try visitor.visitSingularUInt64Field(value: endHeight, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetEventsForHeightRangeRequest, rhs: Flow_Access_GetEventsForHeightRangeRequest) -> Bool { + if lhs.type != rhs.type { return false } + if lhs.startHeight != rhs.startHeight { return false } + if lhs.endHeight != rhs.endHeight { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetEventsForBlockIDsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetEventsForBlockIDsRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "block_ids"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.blockIds) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !type.isEmpty { + try visitor.visitSingularStringField(value: type, fieldNumber: 1) + } + if !blockIds.isEmpty { + try visitor.visitRepeatedBytesField(value: blockIds, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetEventsForBlockIDsRequest, rhs: Flow_Access_GetEventsForBlockIDsRequest) -> Bool { + if lhs.type != rhs.type { return false } + if lhs.blockIds != rhs.blockIds { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_EventsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".EventsResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "results"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.results) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !results.isEmpty { + try visitor.visitRepeatedMessageField(value: results, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_EventsResponse, rhs: Flow_Access_EventsResponse) -> Bool { + if lhs.results != rhs.results { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_EventsResponse.Result: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Flow_Access_EventsResponse.protoMessageName + ".Result" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .standard(proto: "block_height"), + 3: .same(proto: "events"), + 4: .standard(proto: "block_timestamp"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._blockTimestamp) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if blockHeight != 0 { + try visitor.visitSingularUInt64Field(value: blockHeight, fieldNumber: 2) + } + if !events.isEmpty { + try visitor.visitRepeatedMessageField(value: events, fieldNumber: 3) + } + if let v = self._blockTimestamp { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_EventsResponse.Result, rhs: Flow_Access_EventsResponse.Result) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.blockHeight != rhs.blockHeight { return false } + if lhs.events != rhs.events { return false } + if lhs._blockTimestamp != rhs._blockTimestamp { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetNetworkParametersRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetNetworkParametersRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetNetworkParametersRequest, rhs: Flow_Access_GetNetworkParametersRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetNetworkParametersResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetNetworkParametersResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "chain_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.chainID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !chainID.isEmpty { + try visitor.visitSingularStringField(value: chainID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetNetworkParametersResponse, rhs: Flow_Access_GetNetworkParametersResponse) -> Bool { + if lhs.chainID != rhs.chainID { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetLatestProtocolStateSnapshotRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetLatestProtocolStateSnapshotRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetLatestProtocolStateSnapshotRequest, rhs: Flow_Access_GetLatestProtocolStateSnapshotRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ProtocolStateSnapshotResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ProtocolStateSnapshotResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "serializedSnapshot"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.serializedSnapshot) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !serializedSnapshot.isEmpty { + try visitor.visitSingularBytesField(value: serializedSnapshot, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ProtocolStateSnapshotResponse, rhs: Flow_Access_ProtocolStateSnapshotResponse) -> Bool { + if lhs.serializedSnapshot != rhs.serializedSnapshot { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_GetExecutionResultForBlockIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetExecutionResultForBlockIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_GetExecutionResultForBlockIDRequest, rhs: Flow_Access_GetExecutionResultForBlockIDRequest) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Access_ExecutionResultForBlockIDResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecutionResultForBlockIDResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "execution_result"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._executionResult) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._executionResult { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Access_ExecutionResultForBlockIDResponse, rhs: Flow_Access_ExecutionResultForBlockIDResponse) -> Bool { + if lhs._executionResult != rhs._executionResult { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/WalletKit/Sources/FlowAccess/flow-pb/entities/account.pb.swift b/WalletKit/Sources/FlowAccess/flow-pb/entities/account.pb.swift new file mode 100644 index 0000000..04f87cd --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-pb/entities/account.pb.swift @@ -0,0 +1,193 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/account.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_Account { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var balance: UInt64 = 0 + + public var code: Data = Data() + + public var keys: [Flow_Entities_AccountKey] = [] + + public var contracts: [String: Data] = [:] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Entities_AccountKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var index: UInt32 = 0 + + public var publicKey: Data = Data() + + public var signAlgo: UInt32 = 0 + + public var hashAlgo: UInt32 = 0 + + public var weight: UInt32 = 0 + + public var sequenceNumber: UInt32 = 0 + + public var revoked: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_Account: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Account" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .same(proto: "balance"), + 3: .same(proto: "code"), + 4: .same(proto: "keys"), + 5: .same(proto: "contracts"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.balance) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.code) }() + case 4: try { try decoder.decodeRepeatedMessageField(value: &self.keys) }() + case 5: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.contracts) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + if balance != 0 { + try visitor.visitSingularUInt64Field(value: balance, fieldNumber: 2) + } + if !code.isEmpty { + try visitor.visitSingularBytesField(value: code, fieldNumber: 3) + } + if !keys.isEmpty { + try visitor.visitRepeatedMessageField(value: keys, fieldNumber: 4) + } + if !contracts.isEmpty { + try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: contracts, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Account, rhs: Flow_Entities_Account) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.balance != rhs.balance { return false } + if lhs.code != rhs.code { return false } + if lhs.keys != rhs.keys { return false } + if lhs.contracts != rhs.contracts { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Entities_AccountKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".AccountKey" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "index"), + 2: .standard(proto: "public_key"), + 3: .standard(proto: "sign_algo"), + 4: .standard(proto: "hash_algo"), + 5: .same(proto: "weight"), + 6: .standard(proto: "sequence_number"), + 7: .same(proto: "revoked"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.index) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.publicKey) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.signAlgo) }() + case 4: try { try decoder.decodeSingularUInt32Field(value: &self.hashAlgo) }() + case 5: try { try decoder.decodeSingularUInt32Field(value: &self.weight) }() + case 6: try { try decoder.decodeSingularUInt32Field(value: &self.sequenceNumber) }() + case 7: try { try decoder.decodeSingularBoolField(value: &self.revoked) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if index != 0 { + try visitor.visitSingularUInt32Field(value: index, fieldNumber: 1) + } + if !publicKey.isEmpty { + try visitor.visitSingularBytesField(value: publicKey, fieldNumber: 2) + } + if signAlgo != 0 { + try visitor.visitSingularUInt32Field(value: signAlgo, fieldNumber: 3) + } + if hashAlgo != 0 { + try visitor.visitSingularUInt32Field(value: hashAlgo, fieldNumber: 4) + } + if weight != 0 { + try visitor.visitSingularUInt32Field(value: weight, fieldNumber: 5) + } + if sequenceNumber != 0 { + try visitor.visitSingularUInt32Field(value: sequenceNumber, fieldNumber: 6) + } + if revoked != false { + try visitor.visitSingularBoolField(value: revoked, fieldNumber: 7) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_AccountKey, rhs: Flow_Entities_AccountKey) -> Bool { + if lhs.index != rhs.index { return false } + if lhs.publicKey != rhs.publicKey { return false } + if lhs.signAlgo != rhs.signAlgo { return false } + if lhs.hashAlgo != rhs.hashAlgo { return false } + if lhs.weight != rhs.weight { return false } + if lhs.sequenceNumber != rhs.sequenceNumber { return false } + if lhs.revoked != rhs.revoked { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/WalletKit/Sources/FlowAccess/flow-pb/entities/block.pb.swift b/WalletKit/Sources/FlowAccess/flow-pb/entities/block.pb.swift new file mode 100644 index 0000000..71796d6 --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-pb/entities/block.pb.swift @@ -0,0 +1,127 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/block.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_Block { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var parentID: Data = Data() + + public var height: UInt64 = 0 + + public var timestamp: SwiftProtobuf.Google_Protobuf_Timestamp { + get { return _timestamp ?? SwiftProtobuf.Google_Protobuf_Timestamp() } + set { _timestamp = newValue } + } + + /// Returns true if `timestamp` has been explicitly set. + public var hasTimestamp: Bool { return _timestamp != nil } + /// Clears the value of `timestamp`. Subsequent reads from it will return its default value. + public mutating func clearTimestamp() { _timestamp = nil } + + public var collectionGuarantees: [Flow_Entities_CollectionGuarantee] = [] + + public var blockSeals: [Flow_Entities_BlockSeal] = [] + + public var signatures: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _timestamp: SwiftProtobuf.Google_Protobuf_Timestamp? +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_Block: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Block" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .standard(proto: "parent_id"), + 3: .same(proto: "height"), + 4: .same(proto: "timestamp"), + 5: .standard(proto: "collection_guarantees"), + 6: .standard(proto: "block_seals"), + 7: .same(proto: "signatures"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.parentID) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._timestamp) }() + case 5: try { try decoder.decodeRepeatedMessageField(value: &self.collectionGuarantees) }() + case 6: try { try decoder.decodeRepeatedMessageField(value: &self.blockSeals) }() + case 7: try { try decoder.decodeRepeatedBytesField(value: &self.signatures) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + if !parentID.isEmpty { + try visitor.visitSingularBytesField(value: parentID, fieldNumber: 2) + } + if height != 0 { + try visitor.visitSingularUInt64Field(value: height, fieldNumber: 3) + } + if let v = self._timestamp { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } + if !collectionGuarantees.isEmpty { + try visitor.visitRepeatedMessageField(value: collectionGuarantees, fieldNumber: 5) + } + if !blockSeals.isEmpty { + try visitor.visitRepeatedMessageField(value: blockSeals, fieldNumber: 6) + } + if !signatures.isEmpty { + try visitor.visitRepeatedBytesField(value: signatures, fieldNumber: 7) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Block, rhs: Flow_Entities_Block) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.parentID != rhs.parentID { return false } + if lhs.height != rhs.height { return false } + if lhs._timestamp != rhs._timestamp { return false } + if lhs.collectionGuarantees != rhs.collectionGuarantees { return false } + if lhs.blockSeals != rhs.blockSeals { return false } + if lhs.signatures != rhs.signatures { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/WalletKit/Sources/FlowAccess/flow-pb/entities/block_header.pb.swift b/WalletKit/Sources/FlowAccess/flow-pb/entities/block_header.pb.swift new file mode 100644 index 0000000..6c81482 --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-pb/entities/block_header.pb.swift @@ -0,0 +1,103 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/block_header.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_BlockHeader { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var parentID: Data = Data() + + public var height: UInt64 = 0 + + public var timestamp: SwiftProtobuf.Google_Protobuf_Timestamp { + get { return _timestamp ?? SwiftProtobuf.Google_Protobuf_Timestamp() } + set { _timestamp = newValue } + } + + /// Returns true if `timestamp` has been explicitly set. + public var hasTimestamp: Bool { return _timestamp != nil } + /// Clears the value of `timestamp`. Subsequent reads from it will return its default value. + public mutating func clearTimestamp() { _timestamp = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _timestamp: SwiftProtobuf.Google_Protobuf_Timestamp? +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_BlockHeader: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".BlockHeader" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .standard(proto: "parent_id"), + 3: .same(proto: "height"), + 4: .same(proto: "timestamp"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.parentID) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._timestamp) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + if !parentID.isEmpty { + try visitor.visitSingularBytesField(value: parentID, fieldNumber: 2) + } + if height != 0 { + try visitor.visitSingularUInt64Field(value: height, fieldNumber: 3) + } + if let v = self._timestamp { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_BlockHeader, rhs: Flow_Entities_BlockHeader) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.parentID != rhs.parentID { return false } + if lhs.height != rhs.height { return false } + if lhs._timestamp != rhs._timestamp { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/WalletKit/Sources/FlowAccess/flow-pb/entities/block_seal.pb.swift b/WalletKit/Sources/FlowAccess/flow-pb/entities/block_seal.pb.swift new file mode 100644 index 0000000..3352d53 --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-pb/entities/block_seal.pb.swift @@ -0,0 +1,93 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/block_seal.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_BlockSeal { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var executionReceiptID: Data = Data() + + public var executionReceiptSignatures: [Data] = [] + + public var resultApprovalSignatures: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_BlockSeal: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".BlockSeal" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .standard(proto: "execution_receipt_id"), + 3: .standard(proto: "execution_receipt_signatures"), + 4: .standard(proto: "result_approval_signatures"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.executionReceiptID) }() + case 3: try { try decoder.decodeRepeatedBytesField(value: &self.executionReceiptSignatures) }() + case 4: try { try decoder.decodeRepeatedBytesField(value: &self.resultApprovalSignatures) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if !executionReceiptID.isEmpty { + try visitor.visitSingularBytesField(value: executionReceiptID, fieldNumber: 2) + } + if !executionReceiptSignatures.isEmpty { + try visitor.visitRepeatedBytesField(value: executionReceiptSignatures, fieldNumber: 3) + } + if !resultApprovalSignatures.isEmpty { + try visitor.visitRepeatedBytesField(value: resultApprovalSignatures, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_BlockSeal, rhs: Flow_Entities_BlockSeal) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.executionReceiptID != rhs.executionReceiptID { return false } + if lhs.executionReceiptSignatures != rhs.executionReceiptSignatures { return false } + if lhs.resultApprovalSignatures != rhs.resultApprovalSignatures { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/WalletKit/Sources/FlowAccess/flow-pb/entities/collection.pb.swift b/WalletKit/Sources/FlowAccess/flow-pb/entities/collection.pb.swift new file mode 100644 index 0000000..e0cc820 --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-pb/entities/collection.pb.swift @@ -0,0 +1,129 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/collection.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_Collection { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var id: Data = Data() + + public var transactionIds: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Entities_CollectionGuarantee { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var collectionID: Data = Data() + + public var signatures: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_Collection: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Collection" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .standard(proto: "transaction_ids"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.id) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.transactionIds) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !id.isEmpty { + try visitor.visitSingularBytesField(value: id, fieldNumber: 1) + } + if !transactionIds.isEmpty { + try visitor.visitRepeatedBytesField(value: transactionIds, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Collection, rhs: Flow_Entities_Collection) -> Bool { + if lhs.id != rhs.id { return false } + if lhs.transactionIds != rhs.transactionIds { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Entities_CollectionGuarantee: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CollectionGuarantee" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "collection_id"), + 2: .same(proto: "signatures"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.collectionID) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.signatures) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !collectionID.isEmpty { + try visitor.visitSingularBytesField(value: collectionID, fieldNumber: 1) + } + if !signatures.isEmpty { + try visitor.visitRepeatedBytesField(value: signatures, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_CollectionGuarantee, rhs: Flow_Entities_CollectionGuarantee) -> Bool { + if lhs.collectionID != rhs.collectionID { return false } + if lhs.signatures != rhs.signatures { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/WalletKit/Sources/FlowAccess/flow-pb/entities/event.pb.swift b/WalletKit/Sources/FlowAccess/flow-pb/entities/event.pb.swift new file mode 100644 index 0000000..c58be7f --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-pb/entities/event.pb.swift @@ -0,0 +1,101 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/event.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_Event { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var type: String = String() + + public var transactionID: Data = Data() + + public var transactionIndex: UInt32 = 0 + + public var eventIndex: UInt32 = 0 + + public var payload: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_Event: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Event" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "transaction_id"), + 3: .standard(proto: "transaction_index"), + 4: .standard(proto: "event_index"), + 5: .same(proto: "payload"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.transactionID) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.transactionIndex) }() + case 4: try { try decoder.decodeSingularUInt32Field(value: &self.eventIndex) }() + case 5: try { try decoder.decodeSingularBytesField(value: &self.payload) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !type.isEmpty { + try visitor.visitSingularStringField(value: type, fieldNumber: 1) + } + if !transactionID.isEmpty { + try visitor.visitSingularBytesField(value: transactionID, fieldNumber: 2) + } + if transactionIndex != 0 { + try visitor.visitSingularUInt32Field(value: transactionIndex, fieldNumber: 3) + } + if eventIndex != 0 { + try visitor.visitSingularUInt32Field(value: eventIndex, fieldNumber: 4) + } + if !payload.isEmpty { + try visitor.visitSingularBytesField(value: payload, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Event, rhs: Flow_Entities_Event) -> Bool { + if lhs.type != rhs.type { return false } + if lhs.transactionID != rhs.transactionID { return false } + if lhs.transactionIndex != rhs.transactionIndex { return false } + if lhs.eventIndex != rhs.eventIndex { return false } + if lhs.payload != rhs.payload { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/WalletKit/Sources/FlowAccess/flow-pb/entities/execution_result.pb.swift b/WalletKit/Sources/FlowAccess/flow-pb/entities/execution_result.pb.swift new file mode 100644 index 0000000..523b6c4 --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-pb/entities/execution_result.pb.swift @@ -0,0 +1,244 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/execution_result.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Entities_ExecutionResult { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var previousResultID: Data = Data() + + public var blockID: Data = Data() + + public var chunks: [Flow_Entities_Chunk] = [] + + public var serviceEvents: [Flow_Entities_ServiceEvent] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Entities_Chunk { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// state when starting executing this chunk + public var startState: Data = Data() + + /// Events generated by executing results + public var eventCollection: Data = Data() + + /// Block id of the execution result this chunk belongs to + public var blockID: Data = Data() + + /// total amount of computation used by running all txs in this chunk + public var totalComputationUsed: UInt64 = 0 + + /// number of transactions inside the collection + public var numberOfTransactions: UInt64 = 0 + + /// chunk index inside the ER (starts from zero) + public var index: UInt64 = 0 + + /// EndState inferred from next chunk or from the ER + public var endState: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Entities_ServiceEvent { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var type: String = String() + + public var payload: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_ExecutionResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecutionResult" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "previous_result_id"), + 2: .standard(proto: "block_id"), + 3: .same(proto: "chunks"), + 4: .standard(proto: "service_events"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.previousResultID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.chunks) }() + case 4: try { try decoder.decodeRepeatedMessageField(value: &self.serviceEvents) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !previousResultID.isEmpty { + try visitor.visitSingularBytesField(value: previousResultID, fieldNumber: 1) + } + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 2) + } + if !chunks.isEmpty { + try visitor.visitRepeatedMessageField(value: chunks, fieldNumber: 3) + } + if !serviceEvents.isEmpty { + try visitor.visitRepeatedMessageField(value: serviceEvents, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_ExecutionResult, rhs: Flow_Entities_ExecutionResult) -> Bool { + if lhs.previousResultID != rhs.previousResultID { return false } + if lhs.blockID != rhs.blockID { return false } + if lhs.chunks != rhs.chunks { return false } + if lhs.serviceEvents != rhs.serviceEvents { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Entities_Chunk: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Chunk" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "start_state"), + 2: .standard(proto: "event_collection"), + 3: .standard(proto: "block_id"), + 4: .standard(proto: "total_computation_used"), + 5: .standard(proto: "number_of_transactions"), + 6: .same(proto: "index"), + 7: .standard(proto: "end_state"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.startState) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.eventCollection) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 4: try { try decoder.decodeSingularUInt64Field(value: &self.totalComputationUsed) }() + case 5: try { try decoder.decodeSingularUInt64Field(value: &self.numberOfTransactions) }() + case 6: try { try decoder.decodeSingularUInt64Field(value: &self.index) }() + case 7: try { try decoder.decodeSingularBytesField(value: &self.endState) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !startState.isEmpty { + try visitor.visitSingularBytesField(value: startState, fieldNumber: 1) + } + if !eventCollection.isEmpty { + try visitor.visitSingularBytesField(value: eventCollection, fieldNumber: 2) + } + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 3) + } + if totalComputationUsed != 0 { + try visitor.visitSingularUInt64Field(value: totalComputationUsed, fieldNumber: 4) + } + if numberOfTransactions != 0 { + try visitor.visitSingularUInt64Field(value: numberOfTransactions, fieldNumber: 5) + } + if index != 0 { + try visitor.visitSingularUInt64Field(value: index, fieldNumber: 6) + } + if !endState.isEmpty { + try visitor.visitSingularBytesField(value: endState, fieldNumber: 7) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Chunk, rhs: Flow_Entities_Chunk) -> Bool { + if lhs.startState != rhs.startState { return false } + if lhs.eventCollection != rhs.eventCollection { return false } + if lhs.blockID != rhs.blockID { return false } + if lhs.totalComputationUsed != rhs.totalComputationUsed { return false } + if lhs.numberOfTransactions != rhs.numberOfTransactions { return false } + if lhs.index != rhs.index { return false } + if lhs.endState != rhs.endState { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Entities_ServiceEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ServiceEvent" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .same(proto: "payload"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.payload) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !type.isEmpty { + try visitor.visitSingularStringField(value: type, fieldNumber: 1) + } + if !payload.isEmpty { + try visitor.visitSingularBytesField(value: payload, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_ServiceEvent, rhs: Flow_Entities_ServiceEvent) -> Bool { + if lhs.type != rhs.type { return false } + if lhs.payload != rhs.payload { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/WalletKit/Sources/FlowAccess/flow-pb/entities/transaction.pb.swift b/WalletKit/Sources/FlowAccess/flow-pb/entities/transaction.pb.swift new file mode 100644 index 0000000..2804d44 --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-pb/entities/transaction.pb.swift @@ -0,0 +1,329 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/entities/transaction.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public enum Flow_Entities_TransactionStatus: SwiftProtobuf.Enum { + public typealias RawValue = Int + case unknown // = 0 + case pending // = 1 + case finalized // = 2 + case executed // = 3 + case sealed // = 4 + case expired // = 5 + case UNRECOGNIZED(Int) + + public init() { + self = .unknown + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknown + case 1: self = .pending + case 2: self = .finalized + case 3: self = .executed + case 4: self = .sealed + case 5: self = .expired + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unknown: return 0 + case .pending: return 1 + case .finalized: return 2 + case .executed: return 3 + case .sealed: return 4 + case .expired: return 5 + case let .UNRECOGNIZED(i): return i + } + } +} + +#if swift(>=4.2) + + extension Flow_Entities_TransactionStatus: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static var allCases: [Flow_Entities_TransactionStatus] = [ + .unknown, + .pending, + .finalized, + .executed, + .sealed, + .expired, + ] + } + +#endif // swift(>=4.2) + +public struct Flow_Entities_Transaction { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var script: Data = Data() + + public var arguments: [Data] = [] + + public var referenceBlockID: Data = Data() + + public var gasLimit: UInt64 = 0 + + public var proposalKey: Flow_Entities_Transaction.ProposalKey { + get { return _proposalKey ?? Flow_Entities_Transaction.ProposalKey() } + set { _proposalKey = newValue } + } + + /// Returns true if `proposalKey` has been explicitly set. + public var hasProposalKey: Bool { return _proposalKey != nil } + /// Clears the value of `proposalKey`. Subsequent reads from it will return its default value. + public mutating func clearProposalKey() { _proposalKey = nil } + + public var payer: Data = Data() + + public var authorizers: [Data] = [] + + public var payloadSignatures: [Flow_Entities_Transaction.Signature] = [] + + public var envelopeSignatures: [Flow_Entities_Transaction.Signature] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public struct ProposalKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var keyID: UInt32 = 0 + + public var sequenceNumber: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public struct Signature { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: Data = Data() + + public var keyID: UInt32 = 0 + + public var signature: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} + + fileprivate var _proposalKey: Flow_Entities_Transaction.ProposalKey? +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.entities" + +extension Flow_Entities_TransactionStatus: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "PENDING"), + 2: .same(proto: "FINALIZED"), + 3: .same(proto: "EXECUTED"), + 4: .same(proto: "SEALED"), + 5: .same(proto: "EXPIRED"), + ] +} + +extension Flow_Entities_Transaction: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".Transaction" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "script"), + 2: .same(proto: "arguments"), + 3: .standard(proto: "reference_block_id"), + 4: .standard(proto: "gas_limit"), + 5: .standard(proto: "proposal_key"), + 6: .same(proto: "payer"), + 7: .same(proto: "authorizers"), + 8: .standard(proto: "payload_signatures"), + 9: .standard(proto: "envelope_signatures"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.script) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.referenceBlockID) }() + case 4: try { try decoder.decodeSingularUInt64Field(value: &self.gasLimit) }() + case 5: try { try decoder.decodeSingularMessageField(value: &self._proposalKey) }() + case 6: try { try decoder.decodeSingularBytesField(value: &self.payer) }() + case 7: try { try decoder.decodeRepeatedBytesField(value: &self.authorizers) }() + case 8: try { try decoder.decodeRepeatedMessageField(value: &self.payloadSignatures) }() + case 9: try { try decoder.decodeRepeatedMessageField(value: &self.envelopeSignatures) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !script.isEmpty { + try visitor.visitSingularBytesField(value: script, fieldNumber: 1) + } + if !arguments.isEmpty { + try visitor.visitRepeatedBytesField(value: arguments, fieldNumber: 2) + } + if !referenceBlockID.isEmpty { + try visitor.visitSingularBytesField(value: referenceBlockID, fieldNumber: 3) + } + if gasLimit != 0 { + try visitor.visitSingularUInt64Field(value: gasLimit, fieldNumber: 4) + } + if let v = self._proposalKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 5) + } + if !payer.isEmpty { + try visitor.visitSingularBytesField(value: payer, fieldNumber: 6) + } + if !authorizers.isEmpty { + try visitor.visitRepeatedBytesField(value: authorizers, fieldNumber: 7) + } + if !payloadSignatures.isEmpty { + try visitor.visitRepeatedMessageField(value: payloadSignatures, fieldNumber: 8) + } + if !envelopeSignatures.isEmpty { + try visitor.visitRepeatedMessageField(value: envelopeSignatures, fieldNumber: 9) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Transaction, rhs: Flow_Entities_Transaction) -> Bool { + if lhs.script != rhs.script { return false } + if lhs.arguments != rhs.arguments { return false } + if lhs.referenceBlockID != rhs.referenceBlockID { return false } + if lhs.gasLimit != rhs.gasLimit { return false } + if lhs._proposalKey != rhs._proposalKey { return false } + if lhs.payer != rhs.payer { return false } + if lhs.authorizers != rhs.authorizers { return false } + if lhs.payloadSignatures != rhs.payloadSignatures { return false } + if lhs.envelopeSignatures != rhs.envelopeSignatures { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Entities_Transaction.ProposalKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Flow_Entities_Transaction.protoMessageName + ".ProposalKey" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .standard(proto: "key_id"), + 3: .standard(proto: "sequence_number"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.keyID) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.sequenceNumber) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + if keyID != 0 { + try visitor.visitSingularUInt32Field(value: keyID, fieldNumber: 2) + } + if sequenceNumber != 0 { + try visitor.visitSingularUInt64Field(value: sequenceNumber, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Transaction.ProposalKey, rhs: Flow_Entities_Transaction.ProposalKey) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.keyID != rhs.keyID { return false } + if lhs.sequenceNumber != rhs.sequenceNumber { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Entities_Transaction.Signature: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Flow_Entities_Transaction.protoMessageName + ".Signature" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .standard(proto: "key_id"), + 3: .same(proto: "signature"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.address) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.keyID) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.signature) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 1) + } + if keyID != 0 { + try visitor.visitSingularUInt32Field(value: keyID, fieldNumber: 2) + } + if !signature.isEmpty { + try visitor.visitSingularBytesField(value: signature, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Entities_Transaction.Signature, rhs: Flow_Entities_Transaction.Signature) -> Bool { + if lhs.address != rhs.address { return false } + if lhs.keyID != rhs.keyID { return false } + if lhs.signature != rhs.signature { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/WalletKit/Sources/FlowAccess/flow-pb/execution/execution.pb.swift b/WalletKit/Sources/FlowAccess/flow-pb/execution/execution.pb.swift new file mode 100644 index 0000000..0603296 --- /dev/null +++ b/WalletKit/Sources/FlowAccess/flow-pb/execution/execution.pb.swift @@ -0,0 +1,559 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: flow/execution/execution.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +public struct Flow_Execution_PingRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_PingResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_GetAccountAtBlockIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var address: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_GetAccountAtBlockIDResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var account: Flow_Entities_Account { + get { return _account ?? Flow_Entities_Account() } + set { _account = newValue } + } + + /// Returns true if `account` has been explicitly set. + public var hasAccount: Bool { return _account != nil } + /// Clears the value of `account`. Subsequent reads from it will return its default value. + public mutating func clearAccount() { _account = nil } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _account: Flow_Entities_Account? +} + +public struct Flow_Execution_ExecuteScriptAtBlockIDRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var script: Data = Data() + + public var arguments: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_ExecuteScriptAtBlockIDResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var value: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_GetEventsForBlockIDsResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var results: [Flow_Execution_GetEventsForBlockIDsResponse.Result] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public struct Result { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var blockHeight: UInt64 = 0 + + public var events: [Flow_Entities_Event] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public init() {} +} + +public struct Flow_Execution_GetEventsForBlockIDsRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var type: String = String() + + public var blockIds: [Data] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_GetTransactionResultRequest { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var blockID: Data = Data() + + public var transactionID: Data = Data() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Flow_Execution_GetTransactionResultResponse { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var statusCode: UInt32 = 0 + + public var errorMessage: String = String() + + public var events: [Flow_Entities_Event] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +private let _protobuf_package = "flow.execution" + +extension Flow_Execution_PingRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PingRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_PingRequest, rhs: Flow_Execution_PingRequest) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_PingResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".PingResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_PingResponse, rhs: Flow_Execution_PingResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetAccountAtBlockIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountAtBlockIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .same(proto: "address"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.address) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if !address.isEmpty { + try visitor.visitSingularBytesField(value: address, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetAccountAtBlockIDRequest, rhs: Flow_Execution_GetAccountAtBlockIDRequest) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.address != rhs.address { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetAccountAtBlockIDResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetAccountAtBlockIDResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "account"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._account) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if let v = self._account { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetAccountAtBlockIDResponse, rhs: Flow_Execution_GetAccountAtBlockIDResponse) -> Bool { + if lhs._account != rhs._account { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_ExecuteScriptAtBlockIDRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockIDRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .same(proto: "script"), + 3: .same(proto: "arguments"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.script) }() + case 3: try { try decoder.decodeRepeatedBytesField(value: &self.arguments) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if !script.isEmpty { + try visitor.visitSingularBytesField(value: script, fieldNumber: 2) + } + if !arguments.isEmpty { + try visitor.visitRepeatedBytesField(value: arguments, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_ExecuteScriptAtBlockIDRequest, rhs: Flow_Execution_ExecuteScriptAtBlockIDRequest) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.script != rhs.script { return false } + if lhs.arguments != rhs.arguments { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_ExecuteScriptAtBlockIDResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ExecuteScriptAtBlockIDResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "value"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.value) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !value.isEmpty { + try visitor.visitSingularBytesField(value: value, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_ExecuteScriptAtBlockIDResponse, rhs: Flow_Execution_ExecuteScriptAtBlockIDResponse) -> Bool { + if lhs.value != rhs.value { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetEventsForBlockIDsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetEventsForBlockIDsResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "results"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.results) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !results.isEmpty { + try visitor.visitRepeatedMessageField(value: results, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetEventsForBlockIDsResponse, rhs: Flow_Execution_GetEventsForBlockIDsResponse) -> Bool { + if lhs.results != rhs.results { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetEventsForBlockIDsResponse.Result: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Flow_Execution_GetEventsForBlockIDsResponse.protoMessageName + ".Result" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .standard(proto: "block_height"), + 3: .same(proto: "events"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self.blockHeight) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if blockHeight != 0 { + try visitor.visitSingularUInt64Field(value: blockHeight, fieldNumber: 2) + } + if !events.isEmpty { + try visitor.visitRepeatedMessageField(value: events, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetEventsForBlockIDsResponse.Result, rhs: Flow_Execution_GetEventsForBlockIDsResponse.Result) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.blockHeight != rhs.blockHeight { return false } + if lhs.events != rhs.events { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetEventsForBlockIDsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetEventsForBlockIDsRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "block_ids"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.type) }() + case 2: try { try decoder.decodeRepeatedBytesField(value: &self.blockIds) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !type.isEmpty { + try visitor.visitSingularStringField(value: type, fieldNumber: 1) + } + if !blockIds.isEmpty { + try visitor.visitRepeatedBytesField(value: blockIds, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetEventsForBlockIDsRequest, rhs: Flow_Execution_GetEventsForBlockIDsRequest) -> Bool { + if lhs.type != rhs.type { return false } + if lhs.blockIds != rhs.blockIds { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetTransactionResultRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetTransactionResultRequest" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "block_id"), + 2: .standard(proto: "transaction_id"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self.blockID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.transactionID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !blockID.isEmpty { + try visitor.visitSingularBytesField(value: blockID, fieldNumber: 1) + } + if !transactionID.isEmpty { + try visitor.visitSingularBytesField(value: transactionID, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetTransactionResultRequest, rhs: Flow_Execution_GetTransactionResultRequest) -> Bool { + if lhs.blockID != rhs.blockID { return false } + if lhs.transactionID != rhs.transactionID { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} + +extension Flow_Execution_GetTransactionResultResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetTransactionResultResponse" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "status_code"), + 2: .standard(proto: "error_message"), + 3: .same(proto: "events"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.statusCode) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.events) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if statusCode != 0 { + try visitor.visitSingularUInt32Field(value: statusCode, fieldNumber: 1) + } + if !errorMessage.isEmpty { + try visitor.visitSingularStringField(value: errorMessage, fieldNumber: 2) + } + if !events.isEmpty { + try visitor.visitRepeatedMessageField(value: events, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func == (lhs: Flow_Execution_GetTransactionResultResponse, rhs: Flow_Execution_GetTransactionResultResponse) -> Bool { + if lhs.statusCode != rhs.statusCode { return false } + if lhs.errorMessage != rhs.errorMessage { return false } + if lhs.events != rhs.events { return false } + if lhs.unknownFields != rhs.unknownFields { return false } + return true + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Account.swift b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Account.swift new file mode 100644 index 0000000..3f2180d --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Account.swift @@ -0,0 +1,15 @@ +import Foundation + +extension FlowClient { + public func getAccount(account: FlowAddress, completion: @escaping (ResultCallback)) { + rpcProvider.getAccount(account: account, completion: completion) + } + + public func getAccountAtLatestBlock(account: FlowAddress, completion: @escaping (ResultCallback)) { + rpcProvider.getAccountAtLatestBlock(account: account, completion: completion) + } + + public func getAccountAtBlockHeight(account: FlowAddress, height: Int, completion: @escaping (ResultCallback)) { + rpcProvider.getAccountAtBlockHeight(account: account, height: height, completion: completion) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Blocks.swift b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Blocks.swift new file mode 100644 index 0000000..e83bbf4 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Blocks.swift @@ -0,0 +1,31 @@ +import Foundation + +extension FlowClient { + public func getLatestBlock(isSealed: Bool = false, completion: @escaping (ResultCallback)) { + rpcProvider.getLatestBlock(isSealed: isSealed, completion: completion) + } + + public func getLatestBlockHeader(isSealed: Bool = false, completion: @escaping (ResultCallback)) { + rpcProvider.getLatestBlockHeader(isSealed: isSealed, completion: completion) + } + + public func getBlockById(id: FlowIdentifier, completion: @escaping (ResultCallback)) { + rpcProvider.getBlockById(id: id, completion: completion) + } + + public func getBlockHeaderById(id: FlowIdentifier, completion: @escaping (ResultCallback)) { + rpcProvider.getBlockHeaderById(id: id, completion: completion) + } + + public func getBlockByHeight(height: Int, completion: @escaping (ResultCallback)) { + rpcProvider.getBlockByHeight(height: height, completion: completion) + } + + public func getBlockHeaderByHeight(height: Int, completion: @escaping (ResultCallback)) { + rpcProvider.getBlockHeaderByHeight(height: height, completion: completion) + } + + public func getExecutionResultForBlockID(id: FlowIdentifier, completion: @escaping (ResultCallback)) { + rpcProvider.getExecutionResultForBlockId(id: id, completion: completion) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Collection.swift b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Collection.swift new file mode 100644 index 0000000..0a3d9f7 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Collection.swift @@ -0,0 +1,7 @@ +import Foundation + +extension FlowClient { + public func getCollectionById(id: FlowIdentifier, completion: @escaping (ResultCallback)) { + rpcProvider.getCollectionById(id: id, completion: completion) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Events.swift b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Events.swift new file mode 100644 index 0000000..3b239b6 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Events.swift @@ -0,0 +1,21 @@ +import Foundation + +extension FlowClient { + public func getEventsForHeightRange(type: String, start: Int = 0, end: Int = 0, completion: @escaping (ResultCallback)) { + var queryStart = start + var queryEnd = end + if end == 0, start == 0 { + return + } else if end == 0 { + queryEnd = start + 249 + } else if start == 0 { + queryStart = end - 249 + } + + rpcProvider.getEventsForHeightRange(type: type, start: queryStart, end: queryEnd, completion: completion) + } + + public func getEventsForBlockIds(type: String, blockIds: [FlowIdentifier], completion: @escaping (ResultCallback)) { + rpcProvider.getEventsForBlockIds(type: type, blockIds: blockIds, completion: completion) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Script.swift b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Script.swift new file mode 100644 index 0000000..710d411 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Script.swift @@ -0,0 +1,15 @@ +import Foundation + +extension FlowClient { + public func executeScriptAtLatestBlock(_ script: String, arguments: [CadenceValue] = [], completion: @escaping (ResultCallback)) { + rpcProvider.executeScriptAtLatestBlock(script: script, arguments: arguments, completion: completion) + } + + public func executeScriptAtBlockID(_ script: String, blockId: FlowIdentifier, arguments: [CadenceValue] = [], completion: @escaping (ResultCallback)) { + rpcProvider.executeScriptAtBlockId(script: script, blockId: blockId, arguments: arguments, completion: completion) + } + + public func executeScriptAtBlockHeight(_ script: String, height: Int, arguments: [CadenceValue] = [], completion: @escaping (ResultCallback)) { + rpcProvider.executeScriptAtBlockHeight(script: script, height: height, arguments: arguments, completion: completion) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Transaction.swift b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Transaction.swift new file mode 100644 index 0000000..2a1ecdd --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Client/FlowClient+Transaction.swift @@ -0,0 +1,73 @@ +import Foundation + +extension FlowClient { + public func sendTransaction(_ transaction: FlowTransaction, completion: @escaping (ResultCallback)) { + rpcProvider.sendTransaction(transaction: transaction, completion: completion) + } + + public func getTransactionResult(id: FlowIdentifier, completion: @escaping (ResultCallback)) { + rpcProvider.getTransactionResult(id: id, completion: completion) + } + + public func sendTransaction(script: String, arguments: [CadenceValue], proposer: FlowAddress, payer: FlowAddress, authorizers _: [FlowAddress], keychain: FlowKeyChainProtocol, completion: @escaping (ResultCallback)) { + let transaction: FlowTransaction = FlowTransaction() + + getAccount(account: proposer) { + accountResponse in + + guard let account = accountResponse.result as? FlowAccount else { + completion(RpcResponse(result: nil, error: FlowError.invalidAccount)) + return + } + + guard let keychainKey = try? keychain.getKeyGroup(address: proposer).keys.first else { + completion(RpcResponse(result: nil, error: FlowError.keyNotFound)) + return + } + + let keys = account.keys + + transaction.proposalKey.set { + $0.address = proposer + $0.keyId = keychainKey.keyId + $0.sequenceNumber = keys[Int(keychainKey.keyId)].sequenceNumber + } + + self.getLatestBlockHeader(isSealed: true) { + blockHeaderResponse in + + guard let blockHeader = blockHeaderResponse.result as? FlowBlockHeader else { + completion(RpcResponse(result: nil, error: FlowError.unknownError)) + return + } + + transaction.referenceBlockId = blockHeader.id + transaction.set { + $0.script = script + $0.arguments = arguments + $0.gasLimit = 9999 + $0.payer = payer + $0.authorizers = [proposer] + } + let signer = FlowTransactionSigner(keychain) + + do { + try signer.signTransaction(transaction) + } catch { + completion(RpcResponse(result: nil, error: FlowError.unknownError)) + } + + self.sendTransaction(transaction) { + response in + + guard let result = response.result as? FlowIdentifier else { + completion(RpcResponse(result: nil, error: FlowError.unknownError)) + return + } + + completion(RpcResponse(result: result, error: nil)) + } + } + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Client/FlowClient.swift b/WalletKit/Sources/FlowWalletKit/Client/FlowClient.swift new file mode 100644 index 0000000..d76ee3d --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Client/FlowClient.swift @@ -0,0 +1,143 @@ +import Foundation +import Swift + +// extend business logic on FlowClient + +public class FlowClient: FlowEntity { + enum FlowError: LocalizedError { + case unknownError + case invalidAccount + case keyNotFound + } + + public var rpcProvider: FlowRpcClientProtocol = FlowGrpcClient(host: "127.0.0.1", port: 3569) + + public override init() {} + + public func ping(completion: @escaping (ResultCallback)) { + rpcProvider.ping(completion: completion) + } + + public func addKeyToAccount(_ account: FlowAddress, publicKey: String, keychain: FlowKeyChainProtocol, completion: @escaping (ResultCallback)) { + let script = """ + transaction(publicKey: String) { + prepare(signer: AuthAccount) { + signer.addPublicKey(publicKey.decodeHex()) + } + } + """ + sendTransaction(script: script, + arguments: [CadenceString(publicKey)], + proposer: account, + payer: account, + authorizers: [account], + keychain: keychain, completion: completion) + } + + public func addContractToAccount(account: FlowAddress, keychain: FlowKeyChainProtocol, contractName: String, code: String, completion: @escaping (ResultCallback)) { + let script = """ + transaction(name: String, code: String) { + prepare(signer: AuthAccount) { + signer.contracts.add(name: name, code: code.decodeHex()) + } + } + """ + let codeEncoded = code.data(using: .utf8)?.hexString() + + sendTransaction(script: script, + arguments: [CadenceString(contractName), + CadenceString(codeEncoded!)], + proposer: account, + payer: account, + authorizers: [account], + keychain: keychain, completion: completion) + } + + public func createAccount(account: FlowAddress, keychain: FlowKeyChainProtocol, publicKeys: [String], contracts: [String: String], completion: @escaping (ResultCallback)) { + let script = """ + transaction(publicKeys: [String], contracts: {String: String}) { + prepare(signer: AuthAccount) { + let acct = AuthAccount(payer: signer) + for key in publicKeys { + acct.addPublicKey(key.decodeHex()) + } + for contract in contracts.keys { + acct.contracts.add(name: contract, code: contracts[contract]!.decodeHex()) + } + } + } + """ + var encodedKeys: [CadenceValue] = [] + for publicKey in publicKeys { + encodedKeys.append(CadenceString(publicKey)) + } + + var encodedContractsValues: [CadenceDictionary.InnerElement] = [] + + for contract in contracts.keys { + let codeEncoded = contracts[contract]!.data(using: .utf8)!.hexString() + + let inner = CadenceDictionary.InnerElement(CadenceString(contract), + value: CadenceString(codeEncoded)) + encodedContractsValues.append(inner) + } + + try! sendTransaction(script: script, + arguments: [CadenceArray(value: publicKeys.map { CadenceString($0) }), + CadenceDictionary(value: encodedContractsValues)], + proposer: account, + payer: account, + authorizers: [account], + keychain: keychain, completion: completion) + } + + public func removeAccountKeyByIndex(_ account: FlowAddress, keychain: FlowKeyChainProtocol, index: Int, completion: @escaping (ResultCallback)) { + let script = """ + transaction(keyIndex: Int) { + prepare(signer: AuthAccount) { + signer.removePublicKey(keyIndex) + } + """ + sendTransaction(script: script, + arguments: [CadenceInt(index)], + proposer: account, + payer: account, + authorizers: [account], + keychain: keychain, completion: completion) + } + + public func removeContractFromAccount(_ account: FlowAddress, contractName: String, keychain: FlowKeyChainProtocol, index _: Int, completion: @escaping (ResultCallback)) { + let script = """ + transaction(name: String) { + prepare(signer: AuthAccount) { + signer.contracts.remove(name: name) + } + } + """ + sendTransaction(script: script, + arguments: [CadenceString(contractName)], + proposer: account, + payer: account, + authorizers: [account], + keychain: keychain, completion: completion) + } + + public func updateContractOfAccount(_ account: FlowAddress, contractName: String, newCode: String, keychain: FlowKeyChainProtocol, index _: Int, completion: @escaping (ResultCallback)) { + let script = """ + transaction(name: String, code: String) { + prepare(signer: AuthAccount) { + signer.contracts.update__experimental(name: name, code: code.decodeHex()) + } + } + """ + let codeEncoded = newCode.data(using: .utf8)?.hexString() + + sendTransaction(script: script, + arguments: [CadenceString(contractName), + CadenceString(codeEncoded!)], + proposer: account, + payer: account, + authorizers: [account], + keychain: keychain, completion: completion) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Account+Promise.swift b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Account+Promise.swift new file mode 100644 index 0000000..cb359d4 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Account+Promise.swift @@ -0,0 +1,43 @@ +import Foundation +import PromiseKit + +extension FlowClient { + public func getAccount(_ address: FlowAddress) -> Promise { + return Promise { task in + self.rpcProvider.getAccount(account: address) { + response in + guard let account = response.result as? FlowAccount else { + task.reject(response.error!) + return + } + task.fulfill(account) + } + } + } + + public func getAccountAtLatestBlock(_ address: FlowAddress) -> Promise { + return Promise { task in + self.rpcProvider.getAccountAtLatestBlock(account: address) { + response in + guard let account = response.result as? FlowAccount else { + task.reject(response.error!) + return + } + task.fulfill(account) + } + } + } + + public func getAccountAtBlockHeight(_ address: FlowAddress, height: Int) -> Promise { + return Promise { task in + self.rpcProvider.getAccountAtBlockHeight(account: address, height: height) { + response in + guard let account = response.result as? FlowAccount else { + task.reject(response.error!) + return + } + task.fulfill(account) + } + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Blocks+Promise.swift b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Blocks+Promise.swift new file mode 100644 index 0000000..b1ce89e --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Blocks+Promise.swift @@ -0,0 +1,95 @@ +import Foundation +import PromiseKit + +extension FlowClient { + public func getLatestBlockHeader(isSealed: Bool) -> Promise { + return Promise { task in + self.rpcProvider.getLatestBlockHeader(isSealed: isSealed) { + response in + guard let result = response.result as? FlowBlockHeader else { + task.reject(response.error!) + return + } + task.fulfill(result) + } + } + } + + public func getLatestBlock(isSealed: Bool) -> Promise { + return Promise { task in + self.rpcProvider.getLatestBlock(isSealed: isSealed) { + response in + guard let result = response.result as? FlowBlock else { + task.reject(response.error!) + return + } + task.fulfill(result) + } + } + } + + public func getBlockHeaderById(id: FlowIdentifier) -> Promise { + return Promise { task in + self.getBlockHeaderById(id: id) { + response in + guard let result = response.result as? FlowBlockHeader else { + task.reject(response.error!) + return + } + task.fulfill(result) + } + } + } + + public func getBlockById(id: FlowIdentifier) -> Promise { + return Promise { task in + self.getBlockById(id: id) { + response in + guard let result = response.result as? FlowBlock else { + task.reject(response.error!) + return + } + task.fulfill(result) + } + } + } + + public func getBlockHeaderByHeight(height: Int) -> Promise { + return Promise { task in + self.rpcProvider.getBlockHeaderByHeight(height: height) { + response in + guard let result = response.result as? FlowBlockHeader else { + task.reject(response.error!) + return + } + task.fulfill(result) + } + } + } + + public func getBlockByHeight(height: Int) -> Promise { + return Promise { task in + self.rpcProvider.getBlockByHeight(height: height) { + response in + guard let result = response.result as? FlowBlock else { + task.reject(response.error!) + return + } + task.fulfill(result) + } + } + } + + public func getExecutionResultForBlockID(id: FlowIdentifier) -> Promise { + return Promise { task in + self.getExecutionResultForBlockID(id: id) { + response in + guard let result = response.result as? FlowExecutionResult else { + task.reject(response.error!) + return + } + task.fulfill(result) + } + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Collection+Promise.swift b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Collection+Promise.swift new file mode 100644 index 0000000..bf10694 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Collection+Promise.swift @@ -0,0 +1,17 @@ +import Foundation +import PromiseKit + +extension FlowClient { + public func getCollectionById(_ id: FlowIdentifier) -> Promise { + return Promise { task in + self.getCollectionById(id: id) { + response in + guard let account = response.result as? FlowCollection else { + task.reject(response.error!) + return + } + task.fulfill(account) + } + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Events+Promise.swift b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Events+Promise.swift new file mode 100644 index 0000000..e794356 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Events+Promise.swift @@ -0,0 +1,30 @@ +import Foundation +import PromiseKit + +extension FlowClient { + public func getEventsForHeightRange(_ type: String, start: Int = 0, end: Int = 0) -> Promise { + return Promise { task in + self.getEventsForHeightRange(type: type, start: start, end: end) { + response in + guard let account = response.result as? FlowEventsResult else { + task.reject(response.error!) + return + } + task.fulfill(account) + } + } + } + + public func getEventsForBlockIds(_ type: String, blockIds: [FlowIdentifier]) -> Promise { + return Promise { task in + self.getEventsForBlockIds(type: type, blockIds: blockIds) { + response in + guard let account = response.result as? FlowEventsResult else { + task.reject(response.error!) + return + } + task.fulfill(account) + } + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Promise.swift b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Promise.swift new file mode 100644 index 0000000..96a733d --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Promise.swift @@ -0,0 +1,17 @@ +import Foundation +import PromiseKit + +extension FlowClient { + public func ping() -> Promise { + return Promise { task in + self.rpcProvider.ping() { + response in + guard let result = response.result else { + task.reject(response.error!) + return + } + task.fulfill(result) + } + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Script+Promise.swift b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Script+Promise.swift new file mode 100644 index 0000000..42a0625 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Script+Promise.swift @@ -0,0 +1,43 @@ +import Foundation +import PromiseKit + +extension FlowClient { + public func executeScriptAtLatestBlock(_ script: String, arguments: [CadenceValue] = []) -> Promise { + return Promise { task in + self.executeScriptAtLatestBlock(script, arguments: arguments) { + response in + guard let account = response.result as? CadenceValue else { + task.reject(response.error!) + return + } + task.fulfill(account) + } + } + } + + public func executeScriptAtBlockID(_ script: String, blockId: FlowIdentifier, arguments: [CadenceValue] = []) -> Promise { + return Promise { task in + self.executeScriptAtBlockID(script, blockId: blockId, arguments: arguments) { + response in + guard let account = response.result as? CadenceValue else { + task.reject(response.error!) + return + } + task.fulfill(account) + } + } + } + + public func executeScriptAtBlockHeight(_ script: String, height: Int, arguments: [CadenceValue] = []) -> Promise { + return Promise { task in + self.executeScriptAtBlockHeight(script, height: height, arguments: arguments) { + response in + guard let account = response.result as? CadenceValue else { + task.reject(response.error!) + return + } + task.fulfill(account) + } + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Transaction+Promise.swift b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Transaction+Promise.swift new file mode 100644 index 0000000..f09e200 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/ClientPromise/FlowClient+Transaction+Promise.swift @@ -0,0 +1,75 @@ +import Foundation +import PromiseKit + +extension FlowClient { + public func sendTransaction(script: String, arguments: [CadenceValue], singleSigner: String, keychain: FlowKeyChainProtocol) -> Promise { + let proposer = FlowAddress.from(singleSigner)! + return sendTransaction(script: script, + arguments: arguments, + proposer: proposer, + payer: proposer, + authorizers: [proposer], + keychain: keychain) + } + + public func getTransactionResult(id: FlowIdentifier) -> Promise { + return Promise { task in + + self.getTransactionResult(id: id) { + response in + + guard let result = response.result as? FlowTransactionResult else { + task.reject(response.error!) + return + } + + task.fulfill(result) + } + } + } + + public func sendTransaction(script: String, arguments: [CadenceValue], proposer: FlowAddress, payer: FlowAddress, authorizers _: [FlowAddress], keychain: FlowKeyChainProtocol) -> Promise { + return Promise { task in + + let transaction: FlowTransaction = FlowTransaction() + + let account = try! self.getAccount(proposer).wait() + + guard let keychainKey = try keychain.getKeyGroup(address: proposer).keys.first else { + throw FlowError.keyNotFound + } + + let keys = account.keys + + transaction.proposalKey.set { + $0.address = proposer + $0.keyId = keychainKey.keyId + $0.sequenceNumber = keys[Int(keychainKey.keyId)].sequenceNumber + } + let blockHeader = try! self.getLatestBlockHeader(isSealed: true).wait() + + transaction.referenceBlockId = blockHeader.id + transaction.set { + $0.script = script + $0.arguments = arguments + $0.gasLimit = 1000 + $0.payer = payer + $0.authorizers = [proposer] + } + + let signer = FlowTransactionSigner(keychain) + try signer.signTransaction(transaction) + + self.sendTransaction(transaction) { + response in + + guard let result = response.result as? FlowIdentifier else { + task.reject(response.error!) + return + } + + task.fulfill(result) + } + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Crypto/AppleKeychain.swift b/WalletKit/Sources/FlowWalletKit/Crypto/AppleKeychain.swift new file mode 100644 index 0000000..827fb0a --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Crypto/AppleKeychain.swift @@ -0,0 +1,77 @@ +import Foundation + +public class AppleKeychain: FlowKeyChainProtocol { + public init() {} + + enum KeyChainError: Error { + case accountNotFound + } + + public func addKey(address: FlowAddress, key: FlowKey) throws { + assert(address.hex == key.address) + + var keyGroup = try getKeyGroup(address: address) + + for k in keyGroup.keys { + if k.address == key.address, k.keyId == key.keyId { + return + } + } + keyGroup.keys.append(key) + + let data = try JSONEncoder().encode(keyGroup) + let query = [ + kSecValueData: data, + kSecClass: kSecClassGenericPassword, + kSecAttrService: "Flow Account Key", + kSecAttrAccount: address.hex, + ] as CFDictionary + + let status = SecItemAdd(query, nil) + + if status != errSecSuccess { + print("Error: \(status)") + } + } + + public func removeKey(address _: FlowAddress, key _: FlowKey) { + // self.keys[address.hex]?.remove(at: index) + } + + public func getKeyGroup(address: FlowAddress) throws -> KeyGroup { + let query = [ + kSecAttrService: "Flow Account Key", + kSecAttrAccount: address.hex, + kSecClass: kSecClassGenericPassword, + kSecReturnData: true, + ] as CFDictionary + + var result: AnyObject? + SecItemCopyMatching(query, &result) + + if result == nil { + return KeyGroup() + } + do { + let data = result as! Data + let group = try JSONDecoder().decode(KeyGroup.self, from: data) + return group + } catch { + print(error) + return KeyGroup() + } + } + + public func signData(signerIndex: Int, address: FlowAddress, payload: Data) throws -> FlowTransactionSignature { + guard let signerKey = try self.getKeyGroup(address: address).keys.first else { + throw KeyChainError.accountNotFound + } + + let signature = FlowSigner.signData(payload, + privateKey: signerKey.key.data(using: .hexadecimal)!, + signatureAlgorithm: signerKey.signingAlgorithm, + hashAlgorithm: signerKey.hashAlgorithm) + + return FlowTransactionSignature(signerIndex: signerIndex, address: address, keyId: signerKey.keyId, signature: signature) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Crypto/FlowKeychain.swift b/WalletKit/Sources/FlowWalletKit/Crypto/FlowKeychain.swift new file mode 100644 index 0000000..0edcb65 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Crypto/FlowKeychain.swift @@ -0,0 +1,41 @@ +import Foundation + +public protocol FlowKeyChainProtocol { + func addKey(address: FlowAddress, key: FlowKey) throws + func removeKey(address: FlowAddress, key: FlowKey) + func getKeyGroup(address: FlowAddress) throws -> KeyGroup + func signData(signerIndex: Int, address: FlowAddress, payload: Data) throws -> FlowTransactionSignature +} + +public struct KeyGroup: Codable { + public var keys: [FlowKey] = [FlowKey]() + + public mutating func remove(_ key: FlowKey) { + for i in 0 ..< keys.count { + if keys[i].address == key.address, keys[i].keyId == key.keyId { + keys.remove(at: i) + return + } + } + } +} + +public class FlowKey: FlowEntity, Codable { + public var address: String + public var keyId: Int + public var key: String + public var signingAlgorithm: FlowSignatureAlgorithm + public var hashAlgorithm: FlowHashAlgorithm + + public init(address: FlowAddress, keyId: Int, key: String, signingAlgorithm: FlowSignatureAlgorithm, hashAlgorithm: FlowHashAlgorithm) { + self.address = address.hex + self.keyId = keyId + self.key = key + self.signingAlgorithm = signingAlgorithm + self.hashAlgorithm = hashAlgorithm + } + + public var uid: String { + return String(format: "%@_%@", address, keyId) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Crypto/MemoryKeychain.swift b/WalletKit/Sources/FlowWalletKit/Crypto/MemoryKeychain.swift new file mode 100644 index 0000000..741287d --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Crypto/MemoryKeychain.swift @@ -0,0 +1,46 @@ +import Foundation + +public class MemoryKeychain: FlowKeyChainProtocol { + public init() {} + + enum KeyChainError: Error { + case accountNotFound + } + + public var keys: [String: KeyGroup] = [:] + + public func addKey(address: FlowAddress, key: FlowKey) { + if !keys.keys.contains(address.hex) { + keys[address.hex] = KeyGroup() + } + keys[address.hex]!.keys.append(key) + } + + public func removeKey(address: FlowAddress, key: FlowKey) { + var group = keys[address.hex]! + group.remove(key) + } + + public func getKeyGroup(address: FlowAddress) throws -> KeyGroup { + if !keys.keys.contains(address.hex) { + throw KeyChainError.accountNotFound + } + return keys[address.hex]! + } + + public func signData(signerIndex: Int, address: FlowAddress, payload: Data) throws -> FlowTransactionSignature { + guard let signerKey = try self.getKeyGroup(address: address).keys.first else { + throw KeyChainError.accountNotFound + } + + let signature = FlowSigner.signData(payload, + privateKey: signerKey.key.data(using: .hexadecimal)!, + signatureAlgorithm: signerKey.signingAlgorithm, + hashAlgorithm: signerKey.hashAlgorithm) + + return FlowTransactionSignature(signerIndex: signerIndex, + address: address, + keyId: signerKey.keyId, + signature: signature) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Crypto/RLP.swift b/WalletKit/Sources/FlowWalletKit/Crypto/RLP.swift new file mode 100644 index 0000000..b5acdfc --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Crypto/RLP.swift @@ -0,0 +1,298 @@ +import BigInt +import Foundation + +extension BigUInt { + init(bigEndianBytes bytes: [UInt8]) throws { + self.init(Data(bytes)) + } + + func asBytes() -> [UInt8] { + return [UInt8](serialize()) + } + + func minimumRequiredBytes() -> UInt8 { + return UInt8(asBytes().count) + } +} + +extension UInt64 { + init(bigEndianBytes bytes: [UInt8]) throws { + guard bytes.count <= 8 else { + throw RLP.Error.dataSizeOverflow + } + var number: UInt64 = 0 + + for byte in bytes { + number = number << 8 + number += UInt64(byte) + } + + self = number + } + + func asBytes() -> [UInt8] { + var number = self + var output: [UInt8] = [] + for _ in 0 ..< minimumRequiredBytes() { + output.insert(UInt8(number & 255), at: 0) + number = number >> 8 + } + return output + } + + func minimumRequiredBytes() -> UInt8 { + var n = self + var bytesRequired = 0 + while n > 0 { + n /= 256 + bytesRequired += 1 + } + return UInt8(bytesRequired) + } +} + +extension UInt8 { + var unicodeString: String { + return String(UnicodeScalar(self)) + } +} + +extension Array { // where Element: UInt8 { + var unicodeString: String { + return (self as! [UInt8]).reduce("") { $0 + $1.unicodeString } + } +} + +public struct UInt7 { + static let max: UInt8 = 127 + let uInt8: UInt8 + init(_ value: UInt8) throws { + guard value <= UInt7.max else { throw RLP.Error.dataSizeOverflow } + uInt8 = value + } +} + +public struct RLP { + // RLP doesn't specify any type encoding just bytes and lists + public enum Value { + case bytes([UInt8]) + case list([Value]) + + // Some rough helpers for common swift types + public var stringValue: String? { + if case let .bytes(bytes) = self { + return bytes.unicodeString + } + return nil + } + + public var intValue: Int? { + if case let .bytes(bytes) = self { + return (try? UInt64(bigEndianBytes: bytes)).flatMap { Int($0) } + } + return nil + } + + public var bigUIntValue: BigUInt? { + if case let .bytes(bytes) = self { + return try? BigUInt(bigEndianBytes: bytes) + } + return nil + } + + public var listValue: [Value]? { + if case let .list(list) = self { + return list + } + return nil + } + + public var stringList: [String]? { + return listValue?.compactMap { $0.stringValue } + } + + public var intList: [Int]? { + return listValue?.compactMap { $0.intValue } + } + + // Output the decoded bytes maintaining struture but no type information. You would need to apply your own casting on top of this. + public var rawBytes: Any { + switch self { + case let .bytes(bytes): + return bytes + case let .list(values): + return values.map { $0.rawBytes } + } + } + } + + public enum Error: Swift.Error { + case invalidNumberOfBytes + case invalidEncodingFlag + case dataSizeOverflow + case unableToEncodeType + } + + // Covers the encoding information, the flag bit if needed along with the length of data or value if byte is a value + enum EncodingFlag { + case valueByte(UInt7) + case multipleBytes(dataLength: UInt64) + case list(dataLength: UInt64) + + private enum Key: UInt8 { + case singleValueBelow128 = 0x00 + case upTo55Bytes = 0x80 + case longerThan55Bytes = 0xB7 + case listUpTo55Bytes = 0xC0 + case listLongerThan55Bytes = 0xF7 + } + + // Given the full encoded data work out the encoding type + init(encodedBytes: [UInt8]) throws { + guard let firstByte = encodedBytes.first else { + throw Error.invalidNumberOfBytes + } + switch firstByte { + case Key.singleValueBelow128.rawValue ..< Key.upTo55Bytes.rawValue: + self = .valueByte(try UInt7(firstByte)) + case Key.upTo55Bytes.rawValue ..< Key.longerThan55Bytes.rawValue: + let dataLength = UInt64(firstByte - Key.upTo55Bytes.rawValue) + guard UInt64(encodedBytes.count) >= 1 + dataLength else { throw Error.invalidNumberOfBytes } + self = .multipleBytes(dataLength: dataLength) + case Key.longerThan55Bytes.rawValue ..< Key.listUpTo55Bytes.rawValue: + let numBytesForLength = Int(firstByte - Key.longerThan55Bytes.rawValue) + let dataLength = try UInt64(bigEndianBytes: Array(encodedBytes[1 ..< 1.advanced(by: numBytesForLength)])) + guard UInt64(encodedBytes.count) >= 1 + UInt64(numBytesForLength) + dataLength else { throw Error.invalidNumberOfBytes } + self = .multipleBytes(dataLength: dataLength) + case Key.listUpTo55Bytes.rawValue ..< Key.listLongerThan55Bytes.rawValue: + let dataLength = UInt64(firstByte - Key.listUpTo55Bytes.rawValue) + guard UInt64(encodedBytes.count) >= 1 + dataLength else { throw Error.invalidNumberOfBytes } + self = .list(dataLength: dataLength) + case Key.listLongerThan55Bytes.rawValue ..< UInt8.max: + let numBytesForLength = Int(firstByte - Key.listLongerThan55Bytes.rawValue) + let dataLength = try UInt64(bigEndianBytes: Array(encodedBytes[1 ..< 1.advanced(by: numBytesForLength)])) + guard UInt64(encodedBytes.count) >= 1 + UInt64(numBytesForLength) + dataLength else { throw Error.invalidNumberOfBytes } + self = .list(dataLength: dataLength) + default: + fatalError() + } + } + + // The endcoding information. This would usually be followed with the data bytes(if not a value byte) + func composedValue() -> [UInt8] { + switch self { + case let .valueByte(value): + return [Key.singleValueBelow128.rawValue + value.uInt8] + case let .multipleBytes(dataLength): + if dataLength <= UInt64(RLP.shortEncodingLimit) { + return [Key.upTo55Bytes.rawValue + UInt8(dataLength)] + } else { + return [Key.longerThan55Bytes.rawValue + dataLength.minimumRequiredBytes()] + dataLength.asBytes() + } + case let .list(dataLength): + if dataLength <= UInt64(RLP.shortEncodingLimit) { + return [Key.listUpTo55Bytes.rawValue + UInt8(dataLength)] + } else { + return [Key.listLongerThan55Bytes.rawValue + dataLength.minimumRequiredBytes()] + dataLength.asBytes() + } + } + } + + // How many bytes are needed to describe the encoding of the data + func numberOfEncodingBytes() -> Int { + return composedValue().count + } + + func dataLength() -> Int { + switch self { + case .valueByte: + return 0 + case let .multipleBytes(dataLength): + return Int(dataLength) + case let .list(dataLength): + return Int(dataLength) + } + } + + func totalByteLength() -> Int { + return numberOfEncodingBytes() + dataLength() + } + } + + public static let shortEncodingLimit = 55 + + // Encode a value using RLP + public static func encode(_ value: Value) -> [UInt8] { + switch value { + case let .bytes(bytes) where bytes.count == 0: + return [0x80] + case let .bytes(bytes) where bytes.count == 1 && bytes[0] <= UInt7.max: + return EncodingFlag.valueByte(try! UInt7(bytes[0])).composedValue() + case let .bytes(bytes): + return EncodingFlag.multipleBytes(dataLength: UInt64(bytes.count)).composedValue() + bytes + case let .list(list): + let encodedList = list.flatMap { encode($0) } + return EncodingFlag.list(dataLength: UInt64(encodedList.count)).composedValue() + encodedList + } + } + + // Helper func to encode common types Int, String, BigUInt, and any amount of nesting of these within arrays + public static func encode(_ any: Any) throws -> [UInt8] { + return try encode(values(any)) + } + + // Decode RLP encoded data in to values(with no associated type information) + public static func decode(_ bytes: [UInt8]) throws -> Value { + let encodingFlag = try EncodingFlag(encodedBytes: bytes) + // Check initial size is correct. + guard encodingFlag.totalByteLength() == bytes.count else { throw Error.invalidNumberOfBytes } + var mutableBytes = bytes + return try _decode(&mutableBytes) + } + + // Recursively decode remaining bytes + private static func _decode(_ bytes: inout [UInt8]) throws -> Value { + let encodingFlag = try EncodingFlag(encodedBytes: bytes) + let numberOfEncodingBytes = encodingFlag.numberOfEncodingBytes() + let dataBytes = bytes.dropFirst(numberOfEncodingBytes) + switch encodingFlag { + case let .valueByte(value): + bytes = Array(bytes.dropFirst(1)) + return .bytes([value.uInt8]) + case let .multipleBytes(dataLength): + let result = Array(dataBytes.prefix(Int(dataLength))) + bytes = Array(dataBytes.dropFirst(Int(dataLength))) + return .bytes(result) + case let .list(dataLength): + var listBytes = Array(dataBytes.prefix(Int(dataLength))) + bytes = Array(dataBytes.dropFirst(Int(dataLength))) + var list: [Value] = [] + while listBytes.count > 0 { + list.append(try _decode(&listBytes)) + } + return .list(list) + } + } + + // Wrap known types as their bytes in values + private static func values(_ any: Any) throws -> Value { + if let int = any as? Int { + return .bytes(UInt64(int).asBytes()) + } else if let int = any as? UInt64 { + return .bytes(UInt64(int).asBytes()) + } else if let int = any as? UInt32 { + return .bytes(UInt64(int).asBytes()) + } else if let bigInt = any as? BigUInt { + return .bytes(bigInt.asBytes()) + } else if let string = any as? String { + return .bytes(Array(string.utf8)) + } else if let data = any as? Data { + return .bytes(data.bytes) + } else if let array = any as? [Any] { + return .list(try array.map { try values($0) }) + + } else { + throw Error.unableToEncodeType + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Crypto/Signature_P256.swift b/WalletKit/Sources/FlowWalletKit/Crypto/Signature_P256.swift new file mode 100644 index 0000000..fe48b28 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Crypto/Signature_P256.swift @@ -0,0 +1,36 @@ +import CryptoKit +import CryptoSwift +import Foundation + +public class FlowSigner { + public static func sign_P256(_ hash: Data, privateKey: Data) -> Data { + let privateKey256 = try! P256.Signing.PrivateKey(rawRepresentation: privateKey) + + var fakeDigest = SHA256.hash(data: Data("42".bytes)) + withUnsafeMutableBytes(of: &fakeDigest) { pointerBuffer in + for i in 0 ..< pointerBuffer.count { + pointerBuffer[i] = hash.bytes[i] + } + } + let signature = try! privateKey256.signature(for: fakeDigest) + return signature.rawRepresentation + } + + public static func signData(_ data: Data, privateKey: Data, signatureAlgorithm: FlowSignatureAlgorithm, hashAlgorithm: FlowHashAlgorithm) -> Data { + var hash: Data + + switch hashAlgorithm { + case FlowHashAlgorithm.SHA2_256: + hash = Data(SHA256.hash(data: data)) + case FlowHashAlgorithm.SHA3_256: + let sha3 = CryptoSwift.SHA3(variant: SHA3.Variant.sha256) + hash = Data(sha3.calculate(for: data.bytes)) + } + + if signatureAlgorithm == FlowSignatureAlgorithm.ECDSA_secp256k1 { + return sign_secp256k1(hash, privateKey: privateKey) + } else { + return sign_P256(hash, privateKey: privateKey) + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Crypto/Signature_secp256k1.swift b/WalletKit/Sources/FlowWalletKit/Crypto/Signature_secp256k1.swift new file mode 100644 index 0000000..45de6ab --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Crypto/Signature_secp256k1.swift @@ -0,0 +1,23 @@ +import CryptoSwift +import Foundation +import secp256k1 + +extension FlowSigner { + public static func sign_secp256k1(_ hash: Data, privateKey: Data) -> Data { + let privateKeyBytes = privateKey.bytes + let privatekeySecp256k1 = try! secp256k1.Signing.PrivateKey(rawRepresentation: privateKeyBytes) + + print(String(byteArray: privatekeySecp256k1.publicKey.rawRepresentation)) + + var fakeDigest = SHA256.hash(data: Data("42".bytes)) + withUnsafeMutableBytes(of: &fakeDigest) { pointerBuffer in + for i in 0 ..< pointerBuffer.count { + pointerBuffer[i] = hash.bytes[i] + } + } + + let signature = try! privatekeySecp256k1.signature(for: fakeDigest) + print(signature.rawRepresentation) + return signature.rawRepresentation + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Crypto/TransactionSigner.swift b/WalletKit/Sources/FlowWalletKit/Crypto/TransactionSigner.swift new file mode 100644 index 0000000..5771f73 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Crypto/TransactionSigner.swift @@ -0,0 +1,93 @@ +import Foundation + +public class FlowTransactionSigner { + public var transaction: FlowTransaction = FlowTransaction() + public var keychain: FlowKeyChainProtocol + public var signerAccounts: [String] = [String]() + + public init(_ keychain: FlowKeyChainProtocol) { + self.keychain = keychain + } + + public func getTransactionDomainTag() -> Data { + let tag = "FLOW-V0.0-transaction" + var d: Data = tag.data(using: .ascii)! + return d.padRightZero(32) + } + + public func getPayload() -> [Any] { + return [ + transaction.script, + transaction.arguments.map { arg in arg.toJSON() }, + transaction.referenceBlockId.data.padLeftZero(32), + transaction.gasLimit, + transaction.proposalKey.address.data, + transaction.proposalKey.keyId, + transaction.proposalKey.sequenceNumber, + transaction.payer.data, + transaction.authorizers.map { $0.data }, + ] + } + + public func getEnvelope() -> [Any] { + return [ + self.getPayload(), + transaction.payloadSignatures.map { + [ + $0.signerIndex, + $0.keyId, + $0.signature, + ] + }, + ] + } + + public func getPayloadEncoded() -> Data { + let rlpEncoded = try! RLP.encode(getPayload()) + return Data(rlpEncoded) + } + + public func getEnvelopeEncoded() -> Data { + let rlpEncoded = try! RLP.encode(getEnvelope()) + return Data(rlpEncoded) + } + + public func getSignerIndex(_ address: FlowAddress) -> Int { + guard let signerIndex = signerAccounts.firstIndex(of: address.hex) else { + signerAccounts.append(address.hex) + return signerAccounts.firstIndex(of: address.hex)! + } + return signerIndex + } + + public func signTransaction(_ transaction: FlowTransaction) throws { + self.transaction = transaction + + var encodedPayload = getPayloadEncoded() + encodedPayload.insert(contentsOf: getTransactionDomainTag(), at: 0) + + if transaction.proposalKey.address.hex != transaction.payer.hex { + let signature = try keychain.signData(signerIndex: getSignerIndex(transaction.proposalKey.address), + address: transaction.proposalKey.address, + payload: encodedPayload) + transaction.payloadSignatures.append(signature) + } + + for authorizer in transaction.authorizers { + if transaction.proposalKey.address.hex == authorizer.hex { + continue + } + let signature = try keychain.signData(signerIndex: getSignerIndex(authorizer), + address: authorizer, + payload: encodedPayload) + transaction.payloadSignatures.append(signature) + } + + var encodedEnvelope = getEnvelopeEncoded() + encodedEnvelope.insert(contentsOf: getTransactionDomainTag(), at: 0) + let signature = try keychain.signData(signerIndex: getSignerIndex(transaction.payer), + address: transaction.payer, + payload: encodedEnvelope) + transaction.envelopeSignatures.append(signature) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Network/FlowRpcClient.swift b/WalletKit/Sources/FlowWalletKit/Network/FlowRpcClient.swift new file mode 100644 index 0000000..5964e7b --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Network/FlowRpcClient.swift @@ -0,0 +1,41 @@ +import Flow +import Foundation +import GRPC +import Swift +import SwiftProtobuf + +public class RpcResponse { + public var error: Error? + public var result: T? + + public init(result: T?, error: Error?) { + self.result = result + self.error = error + } +} + +public typealias ResultCallback = (RpcResponse) -> Void + +public protocol FlowRpcClientProtocol { + func getAccount(account: FlowAddress, completion: @escaping (ResultCallback)) + func getAccountAtLatestBlock(account: FlowAddress, completion: @escaping (ResultCallback)) + func getAccountAtBlockHeight(account: FlowAddress, height: Int, completion: @escaping (ResultCallback)) + func ping(completion: @escaping (ResultCallback)) + func getLatestBlock(isSealed: Bool, completion: @escaping (ResultCallback)) + func getLatestBlockHeader(isSealed: Bool, completion: @escaping (ResultCallback)) + func getBlockHeaderById(id: FlowIdentifier, completion: @escaping (ResultCallback)) + func getBlockHeaderByHeight(height: Int, completion: @escaping (ResultCallback)) + func getBlockById(id: FlowIdentifier, completion: @escaping (ResultCallback)) + func getBlockByHeight(height: Int, completion: @escaping (ResultCallback)) + func getExecutionResultForBlockId(id: FlowIdentifier, completion: @escaping (ResultCallback)) + func getCollectionById(id: FlowIdentifier, completion: @escaping (ResultCallback)) + func getEventsForHeightRange(type: String, start: Int, end: Int, completion: @escaping (ResultCallback)) + func getEventsForBlockIds(type: String, blockIds: [FlowIdentifier], completion: @escaping (ResultCallback)) + func executeScriptAtLatestBlock(script: String, arguments: [CadenceValue], completion: @escaping (ResultCallback)) + func executeScriptAtBlockId(script: String, blockId: FlowIdentifier, arguments: [CadenceValue], completion: @escaping (ResultCallback)) + func executeScriptAtBlockHeight(script: String, height: Int, arguments: [CadenceValue], completion: @escaping (ResultCallback)) + func getNetworkParameters(completion: @escaping (ResultCallback)) + func getLatestProtocolStateSnapshot(completion: @escaping (ResultCallback)) + func sendTransaction(transaction: FlowTransaction, completion: @escaping (ResultCallback)) + func getTransactionResult(id: FlowIdentifier, completion: @escaping (ResultCallback)) +} diff --git a/WalletKit/Sources/FlowWalletKit/Network/Grpc/FlowGrpcClient.swift b/WalletKit/Sources/FlowWalletKit/Network/Grpc/FlowGrpcClient.swift new file mode 100644 index 0000000..b7fd0c7 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Network/Grpc/FlowGrpcClient.swift @@ -0,0 +1,293 @@ +import Flow +import Foundation + +public class FlowGrpcClient: FlowRpcClientProtocol { + var transport: GRPCTransport + + public init(host: String, port: Int) { + transport = GRPCTransport(host: host, port: port) + } + + public func getTransactionResult(id: FlowIdentifier, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getTransactionResult, + transform: { + $0.id = Data(id) + }, success: { + FlowTransactionResult.from($0) as! FlowTransactionResult + }, + completion: completion) + } + + public func sendTransaction(transaction: FlowTransaction, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.sendTransaction, + transform: { + var tosend = Flow_Entities_Transaction() + tosend.script = transaction.script.data(using: .utf8)! + tosend.arguments = transaction.arguments.map { arg in arg.toJSON()! } + tosend.referenceBlockID = transaction.referenceBlockId.data + tosend.gasLimit = UInt64(transaction.gasLimit) + tosend.proposalKey.address = transaction.proposalKey.address.data + tosend.proposalKey.keyID = UInt32(transaction.proposalKey.keyId) + tosend.proposalKey.sequenceNumber = UInt64(transaction.proposalKey.sequenceNumber) + tosend.payer = transaction.payer.data + tosend.authorizers = transaction.authorizers.map { auth in auth.data } + + for signature in transaction.payloadSignatures { + var s = Flow_Entities_Transaction.Signature() + s.address = signature.address.data + s.keyID = UInt32(signature.keyId) + s.signature = signature.signature.data + tosend.payloadSignatures.append(s) + } + + for signature in transaction.envelopeSignatures { + var s = Flow_Entities_Transaction.Signature() + s.address = signature.address.data + s.keyID = UInt32(signature.keyId) + s.signature = signature.signature.data + tosend.envelopeSignatures.append(s) + } + + $0.transaction = tosend + + }, + success: { + FlowIdentifier.from($0.id) + }, + completion: completion) + } + + public func getAccount(account: FlowAddress, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getAccount, + transform: { + $0.address = account.data + }, + success: { + FlowAccount.from($0.account) as? FlowAccount + }, + completion: completion) + } + + public func getAccountAtLatestBlock(account: FlowAddress, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getAccountAtLatestBlock, + transform: { + $0.address = account.data + }, + success: { + FlowAccount.from($0.account) as? FlowAccount + }, + completion: completion) + } + + public func getAccountAtBlockHeight(account: FlowAddress, height: Int, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getAccountAtBlockHeight, + transform: { + $0.address = account.data + $0.blockHeight = UInt64(height) + }, + success: { + FlowAccount.from($0.account) as? FlowAccount + }, + completion: completion) + } + + public func ping(completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.ping, + transform: { _ in + }, + success: { _ in + FlowEntity() + }, + completion: completion) + } + + public func getLatestBlock(isSealed _: Bool, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getLatestBlock, + transform: { _ in + }, + success: { + FlowBlock.from($0.block) + }, + completion: completion) + } + + public func getLatestBlockHeader(isSealed _: Bool, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getLatestBlockHeader, + transform: { _ in + }, + success: { + FlowBlockHeader.from($0.block) + }, + completion: completion) + } + + public func getBlockHeaderById(id: FlowIdentifier, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getBlockHeaderByID, + transform: { + $0.id = Data(id) + }, + success: { + FlowBlockHeader.from($0.block) + }, + completion: completion) + } + + public func getBlockHeaderByHeight(height: Int, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getBlockHeaderByHeight, + transform: { + $0.height = UInt64(height) + }, + success: { + FlowBlockHeader.from($0.block) + }, + completion: completion) + } + + public func getBlockById(id: FlowIdentifier, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getBlockByID, + transform: { + $0.id = Data(id) + }, + success: { + FlowBlock.from($0.block) + }, + completion: completion) + } + + public func getBlockByHeight(height: Int, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getBlockByHeight, + transform: { + $0.height = UInt64(height) + }, + success: { + FlowBlock.from($0.block) + }, + completion: completion) + } + + public func getExecutionResultForBlockId(id: FlowIdentifier, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getExecutionResultForBlockID, + transform: { + $0.blockID = Data(id) + }, + success: { + FlowExecutionResult.from($0.executionResult) + }, + completion: completion) + } + + public func getCollectionById(id: FlowIdentifier, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getCollectionByID, + transform: { + $0.id = Data(id) + }, + success: { + FlowCollection.from($0.collection) + }, + completion: completion) + } + + public func getEventsForHeightRange(type: String, start: Int, end: Int, completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getEventsForHeightRange, + transform: { + $0.type = type + $0.startHeight = UInt64(start) + $0.endHeight = UInt64(end) + }, + success: { + FlowEventsResponse.from($0) + }, + completion: completion) + } + + public func getEventsForBlockIds(type: String, blockIds: [FlowIdentifier], completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getEventsForBlockIDs, + transform: { + $0.type = type + $0.blockIds = blockIds.map { Data($0) } + }, + success: { + FlowEventsResponse.from($0) + }, + completion: completion) + } + + public func executeScriptAtLatestBlock(script: String, arguments: [CadenceValue], completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.executeScriptAtLatestBlock, + transform: { + $0.script = script.data(using: .utf8)! + $0.arguments = arguments.map { $0.toJSON()! } + }, + success: { + CadenceValue.fromJSON($0.value) + }, + completion: completion) + } + + public func executeScriptAtBlockId(script: String, blockId: FlowIdentifier, arguments: [CadenceValue], completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.executeScriptAtBlockID, + transform: { + $0.script = script.data(using: .utf8)! + $0.arguments = arguments.map { $0.toJSON()! } + $0.blockID = Data(blockId) + }, + success: { + CadenceValue.fromJSON($0.value) + }, + completion: completion) + } + + public func executeScriptAtBlockHeight(script: String, height: Int, arguments: [CadenceValue], completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.executeScriptAtBlockHeight, + transform: { + $0.script = script.data(using: .utf8)! + $0.arguments = arguments.map { $0.toJSON()! } + $0.blockHeight = UInt64(height) + }, + success: { + CadenceValue.fromJSON($0.value) + }, + completion: completion) + } + + public func getNetworkParameters(completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getNetworkParameters, + transform: { _ in + }, + success: { _ in + FlowEntity() + }, + completion: completion) + } + + public func getLatestProtocolStateSnapshot(completion: @escaping (ResultCallback)) { + GRPCTransport.GRPCRequest + .with(transport.client.getLatestProtocolStateSnapshot, + transform: { _ in + }, + success: { _ in + FlowEntity() + }, + completion: completion) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Network/Grpc/FlowTypes+Grpc.swift b/WalletKit/Sources/FlowWalletKit/Network/Grpc/FlowTypes+Grpc.swift new file mode 100644 index 0000000..b7832c4 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Network/Grpc/FlowTypes+Grpc.swift @@ -0,0 +1,185 @@ +import Flow +import Foundation +import SwiftProtobuf + +public protocol GrpcEntityConsumer { + static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? +} + +extension FlowTransactionResult: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let transactionResult = FlowTransactionResult() + let input = object as! Flow_Access_TransactionResultResponse + + transactionResult.errorMessage = input.errorMessage + transactionResult.events = input.events.map { event in FlowEvent.from(event) as! FlowEvent } + transactionResult.statusCode = Int(input.statusCode) + transactionResult.status = FlowTransactionStatus(rawValue: Int(input.status.rawValue))! + + return transactionResult + } +} + +extension FlowExecutionResult: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let executionResult = FlowExecutionResult() + let input = object as! Flow_Entities_ExecutionResult + executionResult.previousResultId = FlowIdentifier(input.previousResultID) + executionResult.blockId = FlowIdentifier(input.blockID) + executionResult.chunks = input.chunks.map { object in FlowChunk.from(object) as! FlowChunk } + executionResult.serviceEvents = input.serviceEvents.map { object in FlowServiceEvent.from(object) as! FlowServiceEvent } + return executionResult + } +} + +extension FlowChunk: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let input = object as! Flow_Entities_Chunk + let chunk = FlowChunk() + chunk.startState = FlowBlob.from(input.startState) + chunk.eventCollection = FlowBlob.from(input.eventCollection) + chunk.blockId = FlowIdentifier.from(input.blockID) + chunk.totalComputationUsed = Int(input.totalComputationUsed) + chunk.numberOfTransactions = Int(input.numberOfTransactions) + chunk.index = Int(input.index) + chunk.endState = FlowBlob.from(input.endState) + return chunk + } +} + +extension FlowServiceEvent: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let event = FlowServiceEvent() + let input = object as! Flow_Entities_ServiceEvent + event.type = input.type + event.payload = FlowBlob.from(input.payload) + return event + } +} + +extension FlowCollection: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let collection = FlowCollection() + let input = object as! Flow_Entities_Collection + collection.id = FlowIdentifier(input.id) + collection.transactionIds = FlowIdentifier.from(input.transactionIds) + return collection + } +} + +extension FlowEventsResult: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let result = FlowEventsResult() + let input = object as! Flow_Access_EventsResponse.Result + result.blockHeight = Int(input.blockHeight) + result.blockId = FlowIdentifier.from(input.blockID) + result.blockTimestamp = UInt64(input.blockTimestamp.seconds) + result.events = input.events.map { object in FlowEvent.from(object) as! FlowEvent } + return result + } +} + +extension FlowEventsResponse: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let result = FlowEventsResponse() + let input = object as! Flow_Access_EventsResponse + result.results = input.results.map { object in FlowEventsResult.from(object) as! FlowEventsResult } + return result + } +} + +extension FlowEvent: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let event = FlowEvent() + let input = object as! Flow_Entities_Event + event.type = input.type + event.transactionId = FlowIdentifier.from(input.transactionID) + event.transactionIndex = Int(input.transactionIndex) + event.eventIndex = Int(input.eventIndex) + event.payload = CadenceValue.fromJSON(input.payload)?.innerValue as? CadenceStruct + return event + } +} + +extension FlowAccountKey: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let input = object as! Flow_Entities_AccountKey + return FlowAccountKey( + publicKey: input.publicKey.bytes, + signAlgorithm: Int(input.signAlgo), + hashAlgorithm: Int(input.hashAlgo), + weight: Int(input.weight), + sequenceNumber: Int(input.sequenceNumber) + ) + } +} + +extension FlowBlockSeal: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let seal = FlowBlockSeal() + let input = object as! Flow_Entities_BlockSeal + + seal.blockId = FlowIdentifier.from(input.blockID) + seal.executionReceiptId = FlowIdentifier.from(input.executionReceiptID) + seal.executionReceiptSignatures = FlowBlob.from(input.executionReceiptSignatures.map { object in object }) + seal.resultApprovalSignatures = FlowBlob.from(input.resultApprovalSignatures.map { object in object }) + return seal + } +} + +extension FlowCollectionGuarantee: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let guarantee = FlowCollectionGuarantee() + let input = object as! Flow_Entities_CollectionGuarantee + + guarantee.collectionId = FlowIdentifier.from(input.collectionID) + guarantee.signatures = FlowBlob.from(input.signatures.map { object in object }) + return guarantee + } +} + +extension FlowBlock: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let block = FlowBlock() + let input = object as! Flow_Entities_Block + + block.id = FlowIdentifier.from(input.id) + block.parentId = FlowIdentifier.from(input.parentID) + block.height = Int(input.height) + block.timestamp = UInt64(input.timestamp.seconds) + block.collectionGuarantees = input.collectionGuarantees.map { object in FlowCollectionGuarantee.from(object) as! FlowCollectionGuarantee } + block.blockSeals = input.blockSeals.map { object in FlowBlockSeal.from(object) as! FlowBlockSeal } + block.signatures = FlowBlob.from(input.signatures.map { object in object }) + return block + } +} + +extension FlowBlockHeader: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let block = FlowBlockHeader() + let input = object as! Flow_Entities_BlockHeader + + block.id = FlowIdentifier.from(input.id) + block.parentId = FlowIdentifier.from(input.parentID) + block.height = Int(input.height) + return block + } +} + +extension FlowAccount: GrpcEntityConsumer { + public static func from(_ object: SwiftProtobuf.Message) -> FlowEntity? { + let flowAccount = FlowAccount() + let account = object as! Flow_Entities_Account + flowAccount.address = FlowAddress.from(account.address.hexString())! + flowAccount.balance = CadenceUInt64(account.balance) + flowAccount.keys = account.keys.map { key in FlowAccountKey.from(key) as! FlowAccountKey } + for contractName in account.contracts.keys { + let deployed = FlowDeployedContract( + name: contractName, + code: String(data: account.contracts[contractName]!, encoding: .utf8)! + ) + flowAccount.contracts[contractName] = deployed + } + return flowAccount + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Network/Grpc/Transport+Grpc.swift b/WalletKit/Sources/FlowWalletKit/Network/Grpc/Transport+Grpc.swift new file mode 100644 index 0000000..e1c6243 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Network/Grpc/Transport+Grpc.swift @@ -0,0 +1,36 @@ +import Flow +import Foundation +import GRPC +import NIOCore +import SwiftProtobuf + +public class GRPCTransport { + public var client: Flow_Access_AccessAPIClient + public var channel: GRPCChannel + + public init(host: String, port: Int) { + let group = PlatformSupport.makeEventLoopGroup(loopCount: 1) + channel = ClientConnection.insecure(group: group).connect(host: host, port: port) + client = Flow_Access_AccessAPIClient(channel: channel) + } + + public class GRPCRequest { + public static func with(_ function: (PR, GRPC.CallOptions?) -> GRPC.UnaryCall, + transform: @escaping ((inout PR) -> Void), + success: @escaping (RR) -> FlowEntity?, + completion: @escaping (RpcResponse) -> Void) { + var message: PR = PR() + transform(&message) + let result = function(message, nil) + let response = result.response + response.whenFailure { + error in + completion(RpcResponse(result: nil, error: error)) + } + response.whenSuccess { + rawResponse in + completion(RpcResponse(result: success(rawResponse), error: nil)) + } + } + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Types/CadenceTypes.swift b/WalletKit/Sources/FlowWalletKit/Types/CadenceTypes.swift new file mode 100644 index 0000000..26d1ec9 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Types/CadenceTypes.swift @@ -0,0 +1,675 @@ +import Foundation + +public class CadenceValue: FlowEntity, CustomStringConvertible, Codable { + public func toJSON() -> Data? { + let encoder = JSONEncoder() + do { + return try encoder.encode(self) + } catch { + print("Error while converting to JSON: %@", error) + return nil + } + } + + public static func fromJSON(_ jsonData: Data) -> CadenceValue? { + let decoder = JSONDecoder() + do { + let result = try decoder.decode(CadenceValue.self, from: jsonData) + return result + } catch { + print("Error while converting from JSON: %@", error) + return nil + } + } + + public var cadenceType: String { + return innerType + } + + var innerValue: (Any & CustomStringConvertible & Codable) = CadenceNull() + var innerType: String = "" + + public var value: Any & CustomStringConvertible & Codable { + return innerValue + } + + public var description: String { + return String(format: "%@(%@)", cadenceType, innerValue.description) + } + + enum CodingKeys: String, CodingKey { + case type + case id + case value + case fields + } + + public override init() {} + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + if !container.allKeys.contains(.type) { + return + } + + innerType = try container.decode(String.self, forKey: .type) + + switch innerType { + case "Optional": + innerValue = try container.decode(CadenceOptional.self, forKey: .value) + case "Struct": + innerValue = try container.decode(CadenceStruct.self, forKey: .value) + case "Address": + innerValue = try container.decode(CadenceAddress.self, forKey: .value) + case "Bool": + innerValue = try container.decode(CadenceBool.self, forKey: .value) + case "UFix64": + innerValue = try container.decode(CadenceString.self, forKey: .value) + case "UInt8": + innerValue = try container.decode(CadenceUInt8.self, forKey: .value) + case "Enum": + innerValue = try container.decode(CadenceStruct.self, forKey: .value) + case "Event": + innerValue = try container.decode(CadenceStruct.self, forKey: .value) + + default: + break + } + } + + public func encode(to _: Encoder) throws {} +} + +public class CadenceValueType: CadenceValue { + public override var cadenceType: String { return "" } + public override var description: String { return "" } + + public init(_ value: T) { + super.init() + innerValue = value as! (Any & CustomStringConvertible & Codable) + } + + enum CodingKeys: String, CodingKey { + case type + case value + } + + public required init(from decoder: Decoder) throws { + super.init() + let container = try decoder.singleValueContainer() + let value = try container.decode(String.self) + innerValue = value as (Any & CustomStringConvertible & Codable) + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(cadenceType, forKey: .type) + try container.encode(innerValue as! T, forKey: .value) + } +} + +// [U]Int, [U]Int8, [U]Int16, [U]Int32,[U]Int64,[U]Int128, [U]Int256, Word8, Word16, Word32, or Word64 + +public class CadenceBool: CadenceValueType { + public override var cadenceType: String { return "Bool" } + public override var description: String { return value.description } + public required init(from decoder: Decoder) throws { + super.init(false) + let container = try decoder.singleValueContainer() + let value = try container.decode(Bool.self) + innerValue = value as (Any & CustomStringConvertible & Codable) + } +} + +public class CadenceString: CadenceValueType { + public override var cadenceType: String { return "String" } + public override var description: String { return "\"" + value.description + "\"" } +} + +public class CadenceUInt: CadenceValueType { + public override var cadenceType: String { return "UInt" } + public override var description: String { return value.description } +} + +public class CadenceUInt8: CadenceValueType { + public override var cadenceType: String { return "UInt8" } + public override var description: String { return value.description } +} + +public class CadenceUInt16: CadenceValueType { + public override var cadenceType: String { return "UInt16" } + public override var description: String { return value.description } +} + +public class CadenceUInt32: CadenceValueType { + public override var cadenceType: String { return "UInt32" } + public override var description: String { return value.description } +} + +public class CadenceUInt64: CadenceValueType { + public override var cadenceType: String { return "UInt64" } + public override var description: String { return value.description } +} + +public class CadenceInt: CadenceValueType { + public override var cadenceType: String { return "Int" } + public override var description: String { return value.description } +} + +public class CadenceInt8: CadenceValueType { + public override var cadenceType: String { return "Int8" } + public override var description: String { return value.description } +} + +public class CadenceInt16: CadenceValueType { + public override var cadenceType: String { return "Int16" } + public override var description: String { return value.description } +} + +public class CadenceInt32: CadenceValueType { + public override var cadenceType: String { return "Int32" } + public override var description: String { return value.description } +} + +public class CadenceInt64: CadenceValueType { + public override var cadenceType: String { return "Int64" } + public override var description: String { return value.description } +} + +public class CadenceNull: CustomStringConvertible, Codable { + public var description: String { + return "nil" + } +} + +public class CadencePath: CadenceValue { + public enum Domain: String { + case Storage = "storage" + case Private = "private" + case Public = "public" + } + + public override var cadenceType: String { return "Path" } + + enum PathError: Error { + case InvalidIdentifier + } + + public var domain: Domain + public var identifier: String + + public override var description: String { + return String(format: "%@/%@", domain.rawValue, identifier) + } + + public static func from(_ value: String) -> CadencePath? { + let parts = value.components(separatedBy: "/") + if parts.count == 2 { + let storageDomain = parts[0] + let identifier = parts[1] + guard let domain = Domain(rawValue: storageDomain) else { + return nil + } + do { + return try CadencePath(domain: domain, identifier: identifier) + } catch { + return nil + } + } + return nil + } + + public init(domain: Domain, identifier: String) throws { + self.domain = domain + if identifier.contains(" ") { + throw PathError.InvalidIdentifier + } + self.identifier = identifier + super.init() + } + + enum CodingKeys: String, CodingKey { + case type + case value + case domain + case identifier + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let valueContainer = try container.nestedContainer(keyedBy: CodingKeys.self, forKey: .value) + let domain = try valueContainer.decode(String.self, forKey: .domain) + let identifier = try valueContainer.decode(String.self, forKey: .identifier) + self.domain = Domain(rawValue: domain)! + self.identifier = identifier + super.init() + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode("Path", forKey: .type) + var valueContainer = container.nestedContainer(keyedBy: CodingKeys.self, forKey: .value) + try valueContainer.encode(domain.rawValue, forKey: .domain) + try valueContainer.encode(identifier, forKey: .identifier) + } +} + +public class CadenceOptional: CadenceValue { + public override var cadenceType: String { return "Optional" } + + public override var description: String { + return String(format: "%@", innerValue.description) + } + + public required init(value _: CadenceValue) throws { + super.init() + } + + enum CodingKeys: String, CodingKey { + case type + case value + } + + public required init(from decoder: Decoder) throws { + super.init() + let container = try decoder.singleValueContainer() + innerValue = CadenceNull() + do { + innerValue = try container.decode(CadenceValue.self) + } catch {} + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(cadenceType, forKey: .type) + try container.encode(innerValue as! CadenceValue, forKey: .value) + } +} + +public class CadenceArray: CadenceValue, Collection, Sequence { + public typealias Index = Array.Index + public typealias Element = Array.Element + + public var startIndex: Index { return (innerValue as! [CadenceValue]).startIndex } + public var endIndex: Index { return (innerValue as! [CadenceValue]).endIndex } + + public subscript(index: Index) -> Iterator.Element { return (innerValue as! [CadenceValue])[index] } + + public func index(after i: Index) -> Index { + return (innerValue as! [CadenceValue]).index(after: i) + } + + public override var cadenceType: String { return "Array" } + + public override var description: String { + return value.description + } + + public required init(value: [CadenceValue]) throws { + super.init() + innerValue = value + } + + enum CodingKeys: String, CodingKey { + case type + case value + } + + public required init(from decoder: Decoder) throws { + super.init() + + let container = try decoder.singleValueContainer() + + do { + innerValue = try container.decode([CadenceValue].self) + } catch { + print(error) + throw error + } + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(cadenceType, forKey: .type) + try container.encode(innerValue as! [CadenceValue], forKey: .value) + } +} + +public class CadenceDictionary: CadenceValue, Collection, Sequence { + public class InnerElement: Codable { + public var key: CadenceValue + public var value: CadenceValue + + enum CodingKeys: String, CodingKey { + case key + case value + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + key = try container.decode(CadenceValue.self, forKey: .value) + value = try container.decode(CadenceValue.self, forKey: .value) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(key, forKey: .key) + try container.encode(value, forKey: .value) + } + + public init(_ key: CadenceValue, value: CadenceValue) { + self.key = key + self.value = value + } + } + + public typealias Index = Array.Index + public typealias Element = Array.Element + + public var startIndex: Index { return (innerValue as! [InnerElement]).startIndex } + public var endIndex: Index { return (innerValue as! [InnerElement]).endIndex } + + public subscript(index: Index) -> Iterator.Element { return (innerValue as! [InnerElement])[index] } + + public func index(after i: Index) -> Index { + return (innerValue as! [InnerElement]).index(after: i) + } + + public override var cadenceType: String { return "Dictionary" } + + public override var description: String { + return cadenceType + } + + public required init(value: [InnerElement]) throws { + super.init() + innerValue = value + } + + enum CodingKeys: String, CodingKey { + case type + case value + } + + public required init(from decoder: Decoder) throws { + super.init() + let container = try decoder.container(keyedBy: CodingKeys.self) + innerValue = try container.decode([InnerElement].self, forKey: .value) + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(cadenceType, forKey: .type) + try container.encode(innerValue as! [InnerElement], forKey: .value) + } +} + +public class CadenceStruct: CadenceValue, Collection, Sequence { + public typealias Index = Array.Index + public typealias Element = Array.Element + public var startIndex: Index { return fields.startIndex } + public var endIndex: Index { return fields.endIndex } + + public subscript(key: String) -> CadenceValue { + for field in fields { + if key == field.name { + return field.value + } + } + return CadenceString("") // TODO: + } + + public subscript(index: Index) -> Iterator.Element { + return (fields)[index] + } + + public func index(after i: Index) -> Index { + return fields.index(after: i) + } + + public class Field: Codable, CustomStringConvertible { + public var name: String + public var value: CadenceValue + + enum CodingKeys: String, CodingKey { + case name + case value + } + + public var description: String { + return String(format: "%@ = %@", name, value.description) + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + name = try container.decode(String.self, forKey: .name) + value = try container.decode(CadenceValue.self, forKey: .value) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(name, forKey: .name) + try container.encode(value, forKey: .value) + } + } + + public override var cadenceType: String { "Composite" } + + public var id: String + public var fields: [Field] + + public override var description: String { + return String(format: "identifier=%@(%@)", id, fields.map { $0.description }.joined(separator: ", ")) + } + + public required init(id: String, fields: [Field]) throws { + self.id = id + self.fields = fields + super.init() + } + + enum CodingKeys: String, CodingKey { + case type + case value + case fields + case id + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + id = try container.decode(String.self, forKey: .id) + fields = try container.decode([Field].self, forKey: .fields) + super.init() + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + var valueContainer = container.nestedContainer(keyedBy: CodingKeys.self, forKey: .value) + try valueContainer.encode(id, forKey: .id) + try valueContainer.encode(fields, forKey: .fields) + } +} + +public class CadenceType: CadenceValue { + public var staticType: String + public override var cadenceType: String { return "Type" } + + public override var description: String { + return String(format: "Type<%@>", staticType) + } + + public required init(staticType: String) throws { + self.staticType = staticType + super.init() + } + + public static func from(_ value: String) -> CadenceType? { + guard let result = try? self.init(staticType: value) else { + return nil + } + return result + } + + enum CodingKeys: String, CodingKey { + case type + case value + case staticType + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let valueContainer = try container.nestedContainer(keyedBy: CodingKeys.self, forKey: .value) + let staticTypeString = try valueContainer.decode(String.self, forKey: .staticType) + staticType = staticTypeString + super.init() + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode("Capability", forKey: .type) + var valueContainer = container.nestedContainer(keyedBy: CodingKeys.self, forKey: .value) + try valueContainer.encode(staticType, forKey: .staticType) + } +} + +public class CadenceCapability: CadenceValue { + public var path: CadencePath + public var address: CadenceAddress + public var borrowType: String + public override var cadenceType: String { return "Capability" } + + public override var description: String { + return String(format: "Capability", path.description, address.description, borrowType) + } + + public init(address: CadenceAddress, path: CadencePath, borrowType: String) throws { + self.path = path + self.address = address + self.borrowType = borrowType + super.init() + } + + enum CodingKeys: String, CodingKey { + case type + case value + case path + case address + case borrowType + } + + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let valueContainer = try container.nestedContainer(keyedBy: CodingKeys.self, forKey: .value) + let pathString = try valueContainer.decode(String.self, forKey: .path) + let addressString = try valueContainer.decode(String.self, forKey: .address) + address = CadenceAddress.from(addressString)! + borrowType = try valueContainer.decode(String.self, forKey: .borrowType) + path = CadencePath.from(pathString)! + super.init() + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode("Capability", forKey: .type) + var valueContainer = container.nestedContainer(keyedBy: CodingKeys.self, forKey: .value) + try valueContainer.encode(path.description, forKey: .path) + try valueContainer.encode(address.description, forKey: .address) + try valueContainer.encode(borrowType, forKey: .borrowType) + } +} + +public class CadenceAddress: CadenceValue { + enum AddressError: Error { + case InvalidHex + case InvalidLength + case InvalidType + } + + public override var cadenceType: String { + return "Address" + } + + private static var MAX_ADDRESS_SIZE = 8 + + public override var description: String { + return shortHexWithPrefix + } + + public var bytes: [UInt8] { + return value as! [UInt8] + } + + public var data: Data { + return Data(value as! [UInt8]) + } + + public var hex: String { + return (innerValue as! [UInt8]).map { String(format: "%02x", $0) }.joined() + } + + public var shortHexWithPrefix: String { + return String(format: "0x%@", hex.trimLeft("0")) + } + + public var hexWithPrefix: String { + return String(format: "0x%@", hex) + } + + public var swiftValue: UInt64 { + return UInt64(hex, radix: 16)! + } + + public static func from(_ value: Any) -> CadenceAddress? { + do { + switch value { + case is String: + return try CadenceAddress(value as! String) + case is UInt64: + return try CadenceAddress(value as! UInt64) + case is [UInt8]: + return try CadenceAddress(value as! [UInt8]) + default: + return nil + } + } catch { + return nil + } + } + + public init(_ bytes: [UInt8]) throws { + super.init() + innerValue = bytes + guard (innerValue as! [UInt8]).count <= CadenceAddress.MAX_ADDRESS_SIZE else { + throw AddressError.InvalidLength + } + } + + public convenience init(_ address: UInt64) throws { + try self.init(withUnsafeBytes(of: address, Array.init)) + } + + public convenience init(_ address: String) throws { + guard let v = UInt64(address.trimLeft("0x"), radix: 16) else { + throw AddressError.InvalidHex + } + try self.init(v.bigEndian) + } + + enum CodingKeys: String, CodingKey { + case type + case value + } + + public required convenience init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + let value = try container.decode(String.self) + try self.init(value) + } + + public override func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode("Address", forKey: .type) + try container.encode(shortHexWithPrefix, forKey: .value) + } +} diff --git a/WalletKit/Sources/FlowWalletKit/Types/FlowTypes.swift b/WalletKit/Sources/FlowWalletKit/Types/FlowTypes.swift new file mode 100644 index 0000000..e6bee68 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Types/FlowTypes.swift @@ -0,0 +1,377 @@ +import Flow +import Foundation +import SwiftPrettyPrint +import SwiftProtobuf + +public class FlowEntity: Equatable { + public init() {} + public typealias Element = FlowEntity + public var pretty: String { + var debug: String = "" + Pretty.prettyPrintDebug(self, to: &debug) + return debug + } + + public func set(transform: @escaping ((Element) -> Void)) { + transform(self) + } + + public static func == (lhs: FlowEntity, rhs: FlowEntity) -> Bool { + return lhs.pretty == rhs.pretty + } +} + +public class FlowAddress: FlowBlob { + enum AddressError: Error { + case InvalidHex + case InvalidLength + case InvalidType + } + + public var bytes: [UInt8] { + return data.bytes + } + + public var hex: String { + return data.bytes.map { String(format: "%02x", $0) }.joined() + } + + public var shortHexWithPrefix: String { + return String(format: "0x%@", hex.trimLeft("0")) + } + + public var hexWithPrefix: String { + return String(format: "0x%@", hex) + } + + public static func from(_ value: Any) -> FlowAddress? { + do { + switch value { + case is String: + return try FlowAddress(value as! String) + case is UInt64: + return try FlowAddress(value as! UInt64) + case is [UInt8]: + return try FlowAddress(value as! [UInt8]) + default: + return nil + } + } catch { + return nil + } + } + + public init(_ bytes: [UInt8]) throws { + super.init() + data = Data(bytes) + _ = data.padLeftZero(8) + guard data.bytes.count <= 8 else { + throw AddressError.InvalidLength + } + } + + public convenience init(_ address: UInt64) throws { + try self.init(withUnsafeBytes(of: address, Array.init)) + } + + public convenience init(_ address: String) throws { + guard let v = UInt64(address.trimLeft("0x"), radix: 16) else { + throw AddressError.InvalidHex + } + try self.init(v.bigEndian) + } +} + +public class FlowBlob: FlowEntity, DataProtocol, CustomStringConvertible { + public subscript(position: Data.Index) -> UInt8 { + return data[position] + } + + public typealias Element = UInt8 + public var regions: Data.Regions + + public var startIndex: Data.Index + + public var endIndex: Data.Index + + public typealias Regions = Data.Regions + + public typealias Index = Data.Index + + public typealias SubSequence = Data.SubSequence + + public typealias Indices = Data.Indices + + public override func set(transform: @escaping ((FlowBlob) -> Void)) { + transform(self) + } + + public var data: Data = Data() + public var description: String { + return data.hexString() + } + + public static func from(_ object: Data) -> FlowIdentifier { + return FlowIdentifier(object) + } + + public static func from(_ objects: [Data]) -> [FlowIdentifier] { + return objects.map { o in FlowIdentifier(o) } + } + + public init(_ data: Data) { + self.data = data + regions = self.data.regions + startIndex = self.data.startIndex + endIndex = self.data.endIndex + } + + public override init() { + regions = data.regions + startIndex = data.startIndex + endIndex = data.endIndex + } +} + +public class FlowIdentifier: FlowBlob { + public convenience init(_ string: String) { + self.init(string.data(using: .hexadecimal)!) + } +} + +public class FlowTransactionProposalKey: FlowEntity { + public override func set(transform: @escaping ((FlowTransactionProposalKey) -> Void)) { + transform(self) + } + + public var address: FlowAddress = FlowAddress.from("0x0")! + public var keyId: Int = 0 + public var sequenceNumber: Int = 0 +} + +public class FlowTransactionSignature: FlowEntity { + public override func set(transform: @escaping ((FlowTransactionSignature) -> Void)) { + transform(self) + } + + public var signerIndex: Int = 0 + public var address: FlowAddress = FlowAddress.from("0x0")! + public var keyId: Int = 0 + public var signature: FlowBlob = FlowBlob() + + public init(signerIndex: Int, address: FlowAddress, keyId: Int, signature: Data) { + self.signerIndex = signerIndex + self.address = address + self.keyId = keyId + self.signature = FlowBlob(signature) + } +} + +public class FlowTransaction: FlowEntity { + public override func set(transform: @escaping ((FlowTransaction) -> Void)) { + transform(self) + } + + public var script: String = "" + public var arguments: [CadenceValue] = [CadenceValue]() + public var referenceBlockId: FlowIdentifier = FlowIdentifier() + public var gasLimit: Int = 0 + public var proposalKey: FlowTransactionProposalKey = FlowTransactionProposalKey() + public var payer: FlowAddress = FlowAddress.from("0x0")! + public var authorizers: [FlowAddress] = [FlowAddress]() + public var payloadSignatures: [FlowTransactionSignature] = [FlowTransactionSignature]() + public var envelopeSignatures: [FlowTransactionSignature] = [FlowTransactionSignature]() +} + +public enum FlowTransactionStatus: Int { + case UNKNOWN = 0 + case PENDING = 1 + case FINALIZED = 2 + case EXECUTED = 3 + case SEALED = 4 + case EXPIRED = 5 +} + +public class FlowTransactionResult: FlowEntity { + public override func set(transform: @escaping ((FlowTransactionResult) -> Void)) { + transform(self) + } + + public var status: FlowTransactionStatus = FlowTransactionStatus.UNKNOWN + public var statusCode: Int = 0 + public var errorMessage: String = "" + public var events: [FlowEvent] = [FlowEvent]() +} + +public class FlowExecutionResult: FlowEntity { + public override func set(transform: @escaping ((FlowExecutionResult) -> Void)) { + transform(self) + } + + public var previousResultId: FlowIdentifier = FlowIdentifier() + public var blockId: FlowIdentifier = FlowIdentifier() + public var chunks: [FlowChunk] = [FlowChunk]() + public var serviceEvents: [FlowServiceEvent] = [FlowServiceEvent]() +} + +public class FlowChunk: FlowEntity { + public override func set(transform: @escaping ((FlowChunk) -> Void)) { + transform(self) + } + + public var startState: FlowBlob = FlowBlob() + public var eventCollection: FlowBlob = FlowBlob() + public var blockId: FlowIdentifier = FlowIdentifier() + public var totalComputationUsed: Int = 0 + public var numberOfTransactions: Int = 0 + public var index: Int = 0 + public var endState: FlowBlob = FlowBlob() +} + +public class FlowServiceEvent: FlowEntity { + public override func set(transform: @escaping ((FlowServiceEvent) -> Void)) { + transform(self) + } + + public var type: String = "" + public var payload: FlowBlob = FlowBlob() +} + +public class FlowBlockHeader: FlowEntity { + public override func set(transform: @escaping ((FlowBlockHeader) -> Void)) { + transform(self) + } + + public var id: FlowIdentifier = FlowIdentifier() + public var parentId: FlowIdentifier = FlowIdentifier() + public var height: Int = 0 +} + +public class FlowBlockSeal: FlowEntity { + public override func set(transform: @escaping ((FlowBlockSeal) -> Void)) { + transform(self) + } + + public var blockId: FlowIdentifier = FlowIdentifier() + public var executionReceiptId: FlowIdentifier = FlowIdentifier() + public var executionReceiptSignatures: [FlowBlob] = [FlowBlob]() + public var resultApprovalSignatures: [FlowBlob] = [FlowBlob]() +} + +public class FlowBlock: FlowEntity { + public override func set(transform: @escaping ((FlowBlock) -> Void)) { + transform(self) + } + + public var id: FlowIdentifier = FlowIdentifier() + public var parentId: FlowIdentifier = FlowIdentifier() + public var height: Int = 0 + public var timestamp: UInt64 = 0 + public var collectionGuarantees: [FlowCollectionGuarantee] = [FlowCollectionGuarantee]() + public var blockSeals: [FlowBlockSeal] = [FlowBlockSeal]() + public var signatures: [FlowBlob] = [FlowBlob]() +} + +public class FlowCollection: FlowEntity { + public override func set(transform: @escaping ((FlowCollection) -> Void)) { + transform(self) + } + + public var id: FlowIdentifier = FlowIdentifier() + public var transactionIds: [FlowIdentifier] = [FlowIdentifier]() +} + +public class FlowCollectionGuarantee: FlowEntity { + public override func set(transform: @escaping ((FlowCollectionGuarantee) -> Void)) { + transform(self) + } + + public var collectionId: FlowIdentifier = FlowIdentifier() + public var signatures: [FlowBlob] = [FlowBlob]() +} + +public class FlowDeployedContract: FlowEntity { + public override func set(transform: @escaping ((FlowDeployedContract) -> Void)) { + transform(self) + } + + public var name: String + public var code: String + public init(name: String, code: String) { + self.name = name + self.code = code + } +} + +public class FlowEvent: FlowEntity { + public override func set(transform: @escaping ((FlowEvent) -> Void)) { + transform(self) + } + + public var type: String = "" + public var transactionId: FlowIdentifier = FlowIdentifier() + public var transactionIndex: Int = 0 + public var eventIndex: Int = 0 + public var payload: CadenceStruct? +} + +public class FlowEventsResult: FlowEntity { + public override func set(transform: @escaping ((FlowEventsResult) -> Void)) { + transform(self) + } + + public var blockId: FlowIdentifier = FlowIdentifier() + public var blockHeight: Int = 0 + public var events: [FlowEvent] = [FlowEvent]() + public var blockTimestamp: UInt64 = 0 +} + +public class FlowEventsResponse: FlowEntity { + public override func set(transform: @escaping ((FlowEventsResponse) -> Void)) { + transform(self) + } + + public var results: [FlowEventsResult] = [FlowEventsResult]() +} + +public enum FlowSignatureAlgorithm: Int, Codable { + case ECDSA_P256 = 2 + case ECDSA_secp256k1 = 3 +} + +public enum FlowHashAlgorithm: Int, Codable { + case SHA2_256 = 1 + case SHA3_256 = 3 +} + +public class FlowAccountKey: FlowEntity { + public override func set(transform: @escaping ((FlowAccountKey) -> Void)) { + transform(self) + } + + public var publicKey: [UInt8] + public var signAlgorithm: Int + public var hashAlgorithm: Int + public var weight: Int + public var sequenceNumber: Int + + public init(publicKey: [UInt8], signAlgorithm: Int, hashAlgorithm: Int, weight: Int, sequenceNumber: Int) { + self.publicKey = publicKey + self.signAlgorithm = signAlgorithm + self.hashAlgorithm = hashAlgorithm + self.weight = weight + self.sequenceNumber = sequenceNumber + } +} + +public class FlowAccount: FlowEntity { + public override func set(transform: @escaping ((FlowAccount) -> Void)) { + transform(self) + } + + public var address: FlowAddress = FlowAddress.from("0x0")! + public var balance: CadenceUInt64 = CadenceUInt64(0) + public var keys: [FlowAccountKey] = [FlowAccountKey]() + public var contracts: [String: FlowDeployedContract] = [String: FlowDeployedContract]() + public override init() {} +} diff --git a/WalletKit/Sources/FlowWalletKit/Utils.swift b/WalletKit/Sources/FlowWalletKit/Utils.swift new file mode 100644 index 0000000..fa7dd01 --- /dev/null +++ b/WalletKit/Sources/FlowWalletKit/Utils.swift @@ -0,0 +1,71 @@ +import Foundation + +extension String { + func trimLeft(_ prefix: String) -> String { + guard hasPrefix(prefix) else { return self } + return String(dropFirst(prefix.count)).trimLeft(prefix) + } +} + +extension Array { + mutating func padToSize(_ size: Int, withValue value: Element) { + while count < size { + insert(value, at: 0) + } + if count > size { + removeLast(count - size) + } + } +} + +// MARK: - HexString <> Data + +// Reference: https://stackoverflow.com/a/56870030 +extension String { + enum ExtendedEncoding { + case hexadecimal + } + + func data(using _: ExtendedEncoding) -> Data? { + let hexString = dropFirst(hasPrefix("0x") ? 2 : 0) + + guard hexString.count % 2 == 0 else { return nil } + + var data = Data(capacity: hexString.count / 2) + + var indexIsEven = true + for i in hexString.indices { + if indexIsEven { + let byteRange = i ... hexString.index(after: i) + guard let byte = UInt8(hexString[byteRange], radix: 16) else { return nil } + data.append(byte) + } + indexIsEven.toggle() + } + return data + } +} + +extension Data { + var bytes: [UInt8] { + return [UInt8](self) + } + + func hexString(prefixed isPrefixed: Bool = false) -> String { + return bytes.reduce(isPrefixed ? "0x" : "") { $0 + String(format: "%02X", $1).lowercased() } + } + + public mutating func padLeftZero(_ count: Int) -> Data { + while self.count < count { + insert(0, at: 0) + } + return self + } + + public mutating func padRightZero(_ count: Int) -> Data { + while self.count < count { + append(0) + } + return self + } +} diff --git a/WalletKit/Tests/FlowSwiftTests/FlowClientTests+Blocks.swift b/WalletKit/Tests/FlowSwiftTests/FlowClientTests+Blocks.swift new file mode 100644 index 0000000..2a1e26a --- /dev/null +++ b/WalletKit/Tests/FlowSwiftTests/FlowClientTests+Blocks.swift @@ -0,0 +1,48 @@ +import Flow +@testable import FlowSwift +import XCTest + +final class FlowClientTestsBlocks: XCTestCase { + let client = FlowClient() + var latestBlock: FlowBlock = FlowBlock() + + public override func setUp() { + latestBlock = try! client.getLatestBlock(isSealed: true).wait() + } + + func testRetrieveBlockById() { + let expectation = XCTestExpectation(description: "retrieve a block by ID") + client.getBlockById(id: latestBlock.id) { response in + XCTAssertNil(response.error, "getBlockById error: \(String(describing: response.error?.localizedDescription)).") + expectation.fulfill() + + let block = response.result as! FlowBlock + print(block.pretty) + XCTAssertEqual(self.latestBlock, block) + } + wait(for: [expectation], timeout: 5) + } + + func testRetrieveBlockByHeight() { + let expectation = XCTestExpectation(description: "retrieve a block by height") + client.getBlockByHeight(height: latestBlock.height) { response in + XCTAssertNil(response.error, "getBlockByHeight error: \(String(describing: response.error?.localizedDescription)).") + expectation.fulfill() + + let block = response.result as! FlowBlock + print(block.pretty) + XCTAssertEqual(self.latestBlock, block) + } + wait(for: [expectation], timeout: 5) + } + + func testRetrieveLatestBlock() { + let expectation = XCTestExpectation(description: "retrieve the latest block") + + client.getLatestBlock(isSealed: true) { latestBlockResponse in + XCTAssertNil(latestBlockResponse.error, "getLatestBlock error: \(String(describing: latestBlockResponse.error?.localizedDescription)).") + // let latestBlock = latestBlockResponse.result as! FlowBlock + } + wait(for: [expectation], timeout: 5) + } +} diff --git a/WalletKit/Tests/FlowSwiftTests/FlowClientTests+Collections.swift b/WalletKit/Tests/FlowSwiftTests/FlowClientTests+Collections.swift new file mode 100644 index 0000000..775b099 --- /dev/null +++ b/WalletKit/Tests/FlowSwiftTests/FlowClientTests+Collections.swift @@ -0,0 +1,69 @@ +import Flow +@testable import FlowSwift +import XCTest + +final class FlowClientTestsCollections: XCTestCase { + let client = FlowClient() + var latestBlock: FlowBlock = FlowBlock() + + public override func setUp() { + // make a transaction to create a collection on latest block + + let keychain: MemoryKeychain = MemoryKeychain() + try! keychain.addKey(address: FlowAddress("f8d6e0586b0a20c7"), + key: FlowKey(address: FlowAddress("f8d6e0586b0a20c7"), + keyId: 0, + key: "38b6f958c11a79312b1e44ba825299c03b9eaa362d571662366cdb4e08b59c32", + signingAlgorithm: FlowSignatureAlgorithm.ECDSA_P256, + hashAlgorithm: FlowHashAlgorithm.SHA3_256)) + + let script = "transaction {prepare(acct: AuthAccount) {} execute {}}" + + _ = try! client.sendTransaction(script: script, + singleSigner: "f8d6e0586b0a20c7", + keychain: keychain).wait() + + latestBlock = try! client.getLatestBlock(isSealed: true).wait() + } + + func testRetrieveCollectionByID() { + let expectation = XCTestExpectation(description: "retrieve the latest block") + + let collectionId = latestBlock.collectionGuarantees[0].collectionId + client.getCollectionById(id: collectionId) { response in + XCTAssertNil(response.error, "getCollectionByID error: \(String(describing: response.error?.localizedDescription)).") + + // check here + let collection = response.result as! FlowCollection + XCTAssertEqual(collection.id, collectionId) + + expectation.fulfill() + } + wait(for: [expectation], timeout: 5) + } + + // MARK: - Events + + // retrieve events by name in the block height range + + // MARK: - Scripts + + // submit a script and parse the response + // submit a script with arguments and parse the response + + // MARK: - Accounts + + /* retrieve an account by address + create a new account + deploy a new contract to the account + remove a contract from the account + update an existing contract on the account + */ + + // MARK: - Transactions + + // retrieve a transaction by ID + // sign a transaction (single payer, proposer, authorizer or combination of multiple) + // submit a signed transaction + // sign a transaction with arguments and submit it +} diff --git a/WalletKit/Tests/FlowSwiftTests/FlowClientTests+Events.swift b/WalletKit/Tests/FlowSwiftTests/FlowClientTests+Events.swift new file mode 100644 index 0000000..3753c3f --- /dev/null +++ b/WalletKit/Tests/FlowSwiftTests/FlowClientTests+Events.swift @@ -0,0 +1,54 @@ +import Flow +@testable import FlowSwift +import XCTest + +final class FlowClientTestsEvents: XCTestCase { + let client = FlowClient() + var latestBlock: FlowBlock = FlowBlock() + + public override func setUp() { + // make a transaction to create an event + + let keychain: MemoryKeychain = MemoryKeychain() + try! keychain.addKey(address: FlowAddress("f8d6e0586b0a20c7"), + key: FlowKey(address: FlowAddress("f8d6e0586b0a20c7"), + keyId: 0, + key: "38b6f958c11a79312b1e44ba825299c03b9eaa362d571662366cdb4e08b59c32", + signingAlgorithm: FlowSignatureAlgorithm.ECDSA_P256, + hashAlgorithm: FlowHashAlgorithm.SHA3_256)) + + let script = "transaction {prepare(acct: AuthAccount) {} execute {}}" + + _ = try! client.sendTransaction(script: script, + singleSigner: "f8d6e0586b0a20c7", + keychain: keychain).wait() + + latestBlock = try! client.getLatestBlock(isSealed: true).wait() + } + + func testRetrieveEvents() { + let expectation = XCTestExpectation(description: "retrieve the latest block") + let results = try! client.getEventsForHeightRange("xxx", + start: 0, + end: 200).wait() + XCTAssertEqual(results.events.count, 1) + + wait(for: [expectation], timeout: 5) + } + + // MARK: - Accounts + + /* retrieve an account by address + create a new account + deploy a new contract to the account + remove a contract from the account + update an existing contract on the account + */ + + // MARK: - Transactions + + // retrieve a transaction by ID + // sign a transaction (single payer, proposer, authorizer or combination of multiple) + // submit a signed transaction + // sign a transaction with arguments and submit it +} diff --git a/WalletKit/Tests/FlowSwiftTests/FlowClientTests.swift b/WalletKit/Tests/FlowSwiftTests/FlowClientTests.swift new file mode 100644 index 0000000..0965f81 --- /dev/null +++ b/WalletKit/Tests/FlowSwiftTests/FlowClientTests.swift @@ -0,0 +1,28 @@ +import Flow +@testable import FlowSwift +import XCTest + +final class FlowClientTests: XCTestCase { + let client = FlowClient() + + func testFlowClientConnection() { + let expectation = XCTestExpectation(description: "test Flow Client connection.") + + client.ping { response in + XCTAssertNil(response.error, "Client connection error: \(String(describing: response.error?.localizedDescription)).") + expectation.fulfill() + } + + wait(for: [expectation], timeout: 5) + } + + func testRetrieveCollectionById() { + let expectation = XCTestExpectation(description: "retrieve the latest block") + + client.getLatestBlock(isSealed: true) { latestBlockResponse in + XCTAssertNil(latestBlockResponse.error, "getLatestBlock error: \(String(describing: latestBlockResponse.error?.localizedDescription)).") + // let latestBlock = latestBlockResponse.result as! FlowBlock + } + wait(for: [expectation], timeout: 5) + } +} diff --git a/WalletKit/Tests/FlowSwiftTests/Types.swift b/WalletKit/Tests/FlowSwiftTests/Types.swift new file mode 100644 index 0000000..275e901 --- /dev/null +++ b/WalletKit/Tests/FlowSwiftTests/Types.swift @@ -0,0 +1,5 @@ +import Flow +@testable import FlowSwift +import XCTest + +final class FlowTypeTests: XCTestCase {}