From e7d9e583b10496b6434864881e82e2b4d73731bc Mon Sep 17 00:00:00 2001 From: lmcmz Date: Wed, 7 Dec 2022 01:51:07 +1100 Subject: [PATCH] Update project data structure --- Package.swift | 2 +- Sources/{Flow => }/Build/TransactionBuild.swift | 0 Sources/{Flow => }/Cadence/CommonCadence.swift | 0 Sources/{Flow => }/Decode/FlowArgument+Decode.swift | 0 Sources/{Flow => }/Error/FlowError.swift | 0 Sources/{Flow => }/Extension/Array.swift | 0 Sources/{Flow => }/Extension/Data.swift | 0 Sources/{Flow => }/Extension/Double.swift | 10 ++++++++++ Sources/{Flow => }/Extension/Publisher+Async.swift | 0 Sources/{Flow => }/Extension/String.swift | 0 Sources/{Flow => }/Extension/URLSession+Async.swift | 0 Sources/{Flow => }/Flow.swift | 0 Sources/{Flow => }/Models/FlowAccount.swift | 0 Sources/{Flow => }/Models/FlowAddress.swift | 0 Sources/{Flow => }/Models/FlowAlgorithm.swift | 0 Sources/{Flow => }/Models/FlowArgument.swift | 0 Sources/{Flow => }/Models/FlowBlock.swift | 0 Sources/{Flow => }/Models/FlowCadence.swift | 0 Sources/{Flow => }/Models/FlowChainId.swift | 0 Sources/{Flow => }/Models/FlowCollection.swift | 0 Sources/{Flow => }/Models/FlowDomainTag.swift | 0 Sources/{Flow => }/Models/FlowEntity.swift | 0 Sources/{Flow => }/Models/FlowEvent.swift | 0 Sources/{Flow => }/Models/FlowId.swift | 0 Sources/{Flow => }/Models/FlowKind.swift | 0 Sources/{Flow => }/Models/FlowScript.swift | 0 Sources/{Flow => }/Models/FlowSignature.swift | 0 Sources/{Flow => }/Models/FlowSigner.swift | 0 .../{Flow => }/Models/FlowTransaction+Codable.swift | 0 Sources/{Flow => }/Models/FlowTransaction+Signer.swift | 0 Sources/{Flow => }/Models/FlowTransaction.swift | 0 Sources/{Flow => }/Models/Signer.swift | 0 Sources/{Flow => }/Network/FlowAccess.swift | 0 Sources/{Flow => }/Network/FlowAccessProtocol.swift | 0 Sources/{Flow => }/Network/FlowTransport.swift | 0 Sources/{Flow => }/Network/HTTP/AccessEndpoint.swift | 0 Sources/{Flow => }/Network/HTTP/FlowHTTPClient.swift | 0 Sources/{Flow => }/Network/HTTP/FlowHTTPModel.swift | 0 Sources/{Flow => }/Network/HTTP/Target.swift | 0 Sources/{Flow => }/RLP/RLP.swift | 0 40 files changed, 11 insertions(+), 1 deletion(-) rename Sources/{Flow => }/Build/TransactionBuild.swift (100%) rename Sources/{Flow => }/Cadence/CommonCadence.swift (100%) rename Sources/{Flow => }/Decode/FlowArgument+Decode.swift (100%) rename Sources/{Flow => }/Error/FlowError.swift (100%) rename Sources/{Flow => }/Extension/Array.swift (100%) rename Sources/{Flow => }/Extension/Data.swift (100%) rename Sources/{Flow => }/Extension/Double.swift (68%) rename Sources/{Flow => }/Extension/Publisher+Async.swift (100%) rename Sources/{Flow => }/Extension/String.swift (100%) rename Sources/{Flow => }/Extension/URLSession+Async.swift (100%) rename Sources/{Flow => }/Flow.swift (100%) rename Sources/{Flow => }/Models/FlowAccount.swift (100%) rename Sources/{Flow => }/Models/FlowAddress.swift (100%) rename Sources/{Flow => }/Models/FlowAlgorithm.swift (100%) rename Sources/{Flow => }/Models/FlowArgument.swift (100%) rename Sources/{Flow => }/Models/FlowBlock.swift (100%) rename Sources/{Flow => }/Models/FlowCadence.swift (100%) rename Sources/{Flow => }/Models/FlowChainId.swift (100%) rename Sources/{Flow => }/Models/FlowCollection.swift (100%) rename Sources/{Flow => }/Models/FlowDomainTag.swift (100%) rename Sources/{Flow => }/Models/FlowEntity.swift (100%) rename Sources/{Flow => }/Models/FlowEvent.swift (100%) rename Sources/{Flow => }/Models/FlowId.swift (100%) rename Sources/{Flow => }/Models/FlowKind.swift (100%) rename Sources/{Flow => }/Models/FlowScript.swift (100%) rename Sources/{Flow => }/Models/FlowSignature.swift (100%) rename Sources/{Flow => }/Models/FlowSigner.swift (100%) rename Sources/{Flow => }/Models/FlowTransaction+Codable.swift (100%) rename Sources/{Flow => }/Models/FlowTransaction+Signer.swift (100%) rename Sources/{Flow => }/Models/FlowTransaction.swift (100%) rename Sources/{Flow => }/Models/Signer.swift (100%) rename Sources/{Flow => }/Network/FlowAccess.swift (100%) rename Sources/{Flow => }/Network/FlowAccessProtocol.swift (100%) rename Sources/{Flow => }/Network/FlowTransport.swift (100%) rename Sources/{Flow => }/Network/HTTP/AccessEndpoint.swift (100%) rename Sources/{Flow => }/Network/HTTP/FlowHTTPClient.swift (100%) rename Sources/{Flow => }/Network/HTTP/FlowHTTPModel.swift (100%) rename Sources/{Flow => }/Network/HTTP/Target.swift (100%) rename Sources/{Flow => }/RLP/RLP.swift (100%) diff --git a/Package.swift b/Package.swift index 4b517e3..1688621 100644 --- a/Package.swift +++ b/Package.swift @@ -19,7 +19,7 @@ let package = Package( .target( name: "Flow", dependencies: ["BigInt"], - path: "Sources/Flow" + path: "Sources" ), .testTarget( name: "FlowTests", diff --git a/Sources/Flow/Build/TransactionBuild.swift b/Sources/Build/TransactionBuild.swift similarity index 100% rename from Sources/Flow/Build/TransactionBuild.swift rename to Sources/Build/TransactionBuild.swift diff --git a/Sources/Flow/Cadence/CommonCadence.swift b/Sources/Cadence/CommonCadence.swift similarity index 100% rename from Sources/Flow/Cadence/CommonCadence.swift rename to Sources/Cadence/CommonCadence.swift diff --git a/Sources/Flow/Decode/FlowArgument+Decode.swift b/Sources/Decode/FlowArgument+Decode.swift similarity index 100% rename from Sources/Flow/Decode/FlowArgument+Decode.swift rename to Sources/Decode/FlowArgument+Decode.swift diff --git a/Sources/Flow/Error/FlowError.swift b/Sources/Error/FlowError.swift similarity index 100% rename from Sources/Flow/Error/FlowError.swift rename to Sources/Error/FlowError.swift diff --git a/Sources/Flow/Extension/Array.swift b/Sources/Extension/Array.swift similarity index 100% rename from Sources/Flow/Extension/Array.swift rename to Sources/Extension/Array.swift diff --git a/Sources/Flow/Extension/Data.swift b/Sources/Extension/Data.swift similarity index 100% rename from Sources/Flow/Extension/Data.swift rename to Sources/Extension/Data.swift diff --git a/Sources/Flow/Extension/Double.swift b/Sources/Extension/Double.swift similarity index 68% rename from Sources/Flow/Extension/Double.swift rename to Sources/Extension/Double.swift index f49580e..5273526 100644 --- a/Sources/Flow/Extension/Double.swift +++ b/Sources/Extension/Double.swift @@ -24,3 +24,13 @@ extension Double { return (self * multiplier).rounded() / multiplier } } + +extension Decimal { + func tokenFormat(maximumFractionDigits: Int = 8) -> String { + let formatter = NumberFormatter() + formatter.maximumFractionDigits = maximumFractionDigits + formatter.minimumFractionDigits = 0 + formatter.numberStyle = .decimal + return formatter.string(for: self) ?? String(NSDecimalNumber(decimal: self).doubleValue) + } +} diff --git a/Sources/Flow/Extension/Publisher+Async.swift b/Sources/Extension/Publisher+Async.swift similarity index 100% rename from Sources/Flow/Extension/Publisher+Async.swift rename to Sources/Extension/Publisher+Async.swift diff --git a/Sources/Flow/Extension/String.swift b/Sources/Extension/String.swift similarity index 100% rename from Sources/Flow/Extension/String.swift rename to Sources/Extension/String.swift diff --git a/Sources/Flow/Extension/URLSession+Async.swift b/Sources/Extension/URLSession+Async.swift similarity index 100% rename from Sources/Flow/Extension/URLSession+Async.swift rename to Sources/Extension/URLSession+Async.swift diff --git a/Sources/Flow/Flow.swift b/Sources/Flow.swift similarity index 100% rename from Sources/Flow/Flow.swift rename to Sources/Flow.swift diff --git a/Sources/Flow/Models/FlowAccount.swift b/Sources/Models/FlowAccount.swift similarity index 100% rename from Sources/Flow/Models/FlowAccount.swift rename to Sources/Models/FlowAccount.swift diff --git a/Sources/Flow/Models/FlowAddress.swift b/Sources/Models/FlowAddress.swift similarity index 100% rename from Sources/Flow/Models/FlowAddress.swift rename to Sources/Models/FlowAddress.swift diff --git a/Sources/Flow/Models/FlowAlgorithm.swift b/Sources/Models/FlowAlgorithm.swift similarity index 100% rename from Sources/Flow/Models/FlowAlgorithm.swift rename to Sources/Models/FlowAlgorithm.swift diff --git a/Sources/Flow/Models/FlowArgument.swift b/Sources/Models/FlowArgument.swift similarity index 100% rename from Sources/Flow/Models/FlowArgument.swift rename to Sources/Models/FlowArgument.swift diff --git a/Sources/Flow/Models/FlowBlock.swift b/Sources/Models/FlowBlock.swift similarity index 100% rename from Sources/Flow/Models/FlowBlock.swift rename to Sources/Models/FlowBlock.swift diff --git a/Sources/Flow/Models/FlowCadence.swift b/Sources/Models/FlowCadence.swift similarity index 100% rename from Sources/Flow/Models/FlowCadence.swift rename to Sources/Models/FlowCadence.swift diff --git a/Sources/Flow/Models/FlowChainId.swift b/Sources/Models/FlowChainId.swift similarity index 100% rename from Sources/Flow/Models/FlowChainId.swift rename to Sources/Models/FlowChainId.swift diff --git a/Sources/Flow/Models/FlowCollection.swift b/Sources/Models/FlowCollection.swift similarity index 100% rename from Sources/Flow/Models/FlowCollection.swift rename to Sources/Models/FlowCollection.swift diff --git a/Sources/Flow/Models/FlowDomainTag.swift b/Sources/Models/FlowDomainTag.swift similarity index 100% rename from Sources/Flow/Models/FlowDomainTag.swift rename to Sources/Models/FlowDomainTag.swift diff --git a/Sources/Flow/Models/FlowEntity.swift b/Sources/Models/FlowEntity.swift similarity index 100% rename from Sources/Flow/Models/FlowEntity.swift rename to Sources/Models/FlowEntity.swift diff --git a/Sources/Flow/Models/FlowEvent.swift b/Sources/Models/FlowEvent.swift similarity index 100% rename from Sources/Flow/Models/FlowEvent.swift rename to Sources/Models/FlowEvent.swift diff --git a/Sources/Flow/Models/FlowId.swift b/Sources/Models/FlowId.swift similarity index 100% rename from Sources/Flow/Models/FlowId.swift rename to Sources/Models/FlowId.swift diff --git a/Sources/Flow/Models/FlowKind.swift b/Sources/Models/FlowKind.swift similarity index 100% rename from Sources/Flow/Models/FlowKind.swift rename to Sources/Models/FlowKind.swift diff --git a/Sources/Flow/Models/FlowScript.swift b/Sources/Models/FlowScript.swift similarity index 100% rename from Sources/Flow/Models/FlowScript.swift rename to Sources/Models/FlowScript.swift diff --git a/Sources/Flow/Models/FlowSignature.swift b/Sources/Models/FlowSignature.swift similarity index 100% rename from Sources/Flow/Models/FlowSignature.swift rename to Sources/Models/FlowSignature.swift diff --git a/Sources/Flow/Models/FlowSigner.swift b/Sources/Models/FlowSigner.swift similarity index 100% rename from Sources/Flow/Models/FlowSigner.swift rename to Sources/Models/FlowSigner.swift diff --git a/Sources/Flow/Models/FlowTransaction+Codable.swift b/Sources/Models/FlowTransaction+Codable.swift similarity index 100% rename from Sources/Flow/Models/FlowTransaction+Codable.swift rename to Sources/Models/FlowTransaction+Codable.swift diff --git a/Sources/Flow/Models/FlowTransaction+Signer.swift b/Sources/Models/FlowTransaction+Signer.swift similarity index 100% rename from Sources/Flow/Models/FlowTransaction+Signer.swift rename to Sources/Models/FlowTransaction+Signer.swift diff --git a/Sources/Flow/Models/FlowTransaction.swift b/Sources/Models/FlowTransaction.swift similarity index 100% rename from Sources/Flow/Models/FlowTransaction.swift rename to Sources/Models/FlowTransaction.swift diff --git a/Sources/Flow/Models/Signer.swift b/Sources/Models/Signer.swift similarity index 100% rename from Sources/Flow/Models/Signer.swift rename to Sources/Models/Signer.swift diff --git a/Sources/Flow/Network/FlowAccess.swift b/Sources/Network/FlowAccess.swift similarity index 100% rename from Sources/Flow/Network/FlowAccess.swift rename to Sources/Network/FlowAccess.swift diff --git a/Sources/Flow/Network/FlowAccessProtocol.swift b/Sources/Network/FlowAccessProtocol.swift similarity index 100% rename from Sources/Flow/Network/FlowAccessProtocol.swift rename to Sources/Network/FlowAccessProtocol.swift diff --git a/Sources/Flow/Network/FlowTransport.swift b/Sources/Network/FlowTransport.swift similarity index 100% rename from Sources/Flow/Network/FlowTransport.swift rename to Sources/Network/FlowTransport.swift diff --git a/Sources/Flow/Network/HTTP/AccessEndpoint.swift b/Sources/Network/HTTP/AccessEndpoint.swift similarity index 100% rename from Sources/Flow/Network/HTTP/AccessEndpoint.swift rename to Sources/Network/HTTP/AccessEndpoint.swift diff --git a/Sources/Flow/Network/HTTP/FlowHTTPClient.swift b/Sources/Network/HTTP/FlowHTTPClient.swift similarity index 100% rename from Sources/Flow/Network/HTTP/FlowHTTPClient.swift rename to Sources/Network/HTTP/FlowHTTPClient.swift diff --git a/Sources/Flow/Network/HTTP/FlowHTTPModel.swift b/Sources/Network/HTTP/FlowHTTPModel.swift similarity index 100% rename from Sources/Flow/Network/HTTP/FlowHTTPModel.swift rename to Sources/Network/HTTP/FlowHTTPModel.swift diff --git a/Sources/Flow/Network/HTTP/Target.swift b/Sources/Network/HTTP/Target.swift similarity index 100% rename from Sources/Flow/Network/HTTP/Target.swift rename to Sources/Network/HTTP/Target.swift diff --git a/Sources/Flow/RLP/RLP.swift b/Sources/RLP/RLP.swift similarity index 100% rename from Sources/Flow/RLP/RLP.swift rename to Sources/RLP/RLP.swift