diff --git a/Doc/ScaleCoder.md b/Doc/ScaleCoder.md new file mode 100644 index 0000000..e36052c --- /dev/null +++ b/Doc/ScaleCoder.md @@ -0,0 +1,41 @@ +### ScaleCoder Example + +Bellow is provided an example of `ScaleCoder`'s creation and usage which decodes and encodes any type, conforming to `Codable`. + +## Initialization + +You can use the default way of creating it: + +```Swift +let coder = ScaleCoder.defaultCoder() +``` +The above method uses `DefaultScaleCodecAdapterProvider` under the hood +which supports all the basic `Codable` types out of a box as well as some +custom ones, including: `struct`; `Int128`; `Int256`; `Int512`; `UInt128`; `UInt256` etc. + +On the other hand, you can create your custom one: + +```Swift +let adapterProvider = ScaleCodecAdapterProvider() +adapterProvider.setAdapter(adapter:for:) +let encoder = ScaleEncoder(adapterProvider: adapterProvider) +let decoder = ScaleDecoder(adapterProvider: adapterProvider) +let coder = ScaleCoder(encoder: encoder, decoder: decoder) +``` +Note that in the above-mentioned case you have to manually set an adapter for your `Codable` type. +The library includes adapters for all the basic `Swift` types as well as for custom ones like: +`struct`; `Int128`; `Int256`; `Int512`; `UInt128`; `UInt256`; `UInt512`; `BigUInt` etc. + +*Note:* For all standard numeric types (`Int`; `Int16`; `UInt32` etc.) `NumericAdapter` class should be used. + +## Usage + +After creating a coder object, it can be to encode (or decode) types (or to types), conforming to `Codable`. + +```Swift +let initialValue = "Some String" +let encodedValue = coder.encoder.encode(initialValue) +let decodedValue = coder.decoder.decode(String.self, from: encodedValue) +``` + +Here we try to encode and after that to decode a `String` value. The `decodedValue` will be equal to `initialValue`. \ No newline at end of file diff --git a/Example/.gitignore b/Example/.gitignore new file mode 100644 index 0000000..3fa37ae --- /dev/null +++ b/Example/.gitignore @@ -0,0 +1,5 @@ +### CocoaPods ### +Pods/ + +## User settings +xcuserdata/ diff --git a/Example/Podfile b/Example/Podfile index 0f93e03..e53ddd0 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,9 +1,11 @@ use_frameworks! -platform :ios, '10.0' +platform :ios, '13.0' target 'ScaleCodecSwift_Example' do pod 'ScaleCodecSwift', :path => '../' + pod 'CommonSwift', :git => 'https://github.com/sublabdev/common-swift.git', :branch => 'dev' + pod 'BigInt' target 'ScaleCodecSwift_Tests' do inherit! :search_paths diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 955d871..249c078 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,16 +1,37 @@ PODS: - - ScaleCodecSwift (0.1.0) + - BigInt (5.0.0) + - CommonSwift (1.0.0): + - BigInt (~> 5.0.0) + - ScaleCodecSwift (1.0.0): + - BigInt (~> 5.0.0) + - CommonSwift DEPENDENCIES: + - BigInt + - CommonSwift (from `https://github.com/sublabdev/common-swift.git`, branch `dev`) - ScaleCodecSwift (from `../`) +SPEC REPOS: + trunk: + - BigInt + EXTERNAL SOURCES: + CommonSwift: + :branch: dev + :git: https://github.com/sublabdev/common-swift.git ScaleCodecSwift: :path: "../" +CHECKOUT OPTIONS: + CommonSwift: + :commit: 24cc1514dedb0755a86ae8b6752778a4ff54fb95 + :git: https://github.com/sublabdev/common-swift.git + SPEC CHECKSUMS: - ScaleCodecSwift: 179b6ddc31bb8528d380fd19166a2a9fddc03e86 + BigInt: 74b4d88367b0e819d9f77393549226d36faeb0d8 + CommonSwift: ad350f0e06c040e5cb660cd7154f947851c73fbd + ScaleCodecSwift: 2fa35cbc70c5634fdc0960cc6c712e917b2c688c -PODFILE CHECKSUM: eef510782536c545ce866fb495ea308eae3f0286 +PODFILE CHECKSUM: 1a95faa77d7a036005bcfe079d3f5c22b423b9c7 COCOAPODS: 1.11.3 diff --git a/Example/Pods/Local Podspecs/ScaleCodecSwift.podspec.json b/Example/Pods/Local Podspecs/ScaleCodecSwift.podspec.json deleted file mode 100644 index 0e71111..0000000 --- a/Example/Pods/Local Podspecs/ScaleCodecSwift.podspec.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "ScaleCodecSwift", - "version": "0.1.0", - "summary": "A short description of ScaleCodecSwift.", - "description": "TODO: Add long description of the pod here.", - "homepage": "https://github.com/TigranIsk/ScaleCodecSwift", - "license": { - "type": "MIT", - "file": "LICENSE" - }, - "authors": { - "TigranIsk": "tiskandaryan@griddynamics.com" - }, - "source": { - "git": "https://github.com/TigranIsk/ScaleCodecSwift.git", - "tag": "0.1.0" - }, - "platforms": { - "ios": "10.0" - }, - "source_files": "ScaleCodecSwift/Classes/**/*" -} diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock deleted file mode 100644 index 955d871..0000000 --- a/Example/Pods/Manifest.lock +++ /dev/null @@ -1,16 +0,0 @@ -PODS: - - ScaleCodecSwift (0.1.0) - -DEPENDENCIES: - - ScaleCodecSwift (from `../`) - -EXTERNAL SOURCES: - ScaleCodecSwift: - :path: "../" - -SPEC CHECKSUMS: - ScaleCodecSwift: 179b6ddc31bb8528d380fd19166a2a9fddc03e86 - -PODFILE CHECKSUM: eef510782536c545ce866fb495ea308eae3f0286 - -COCOAPODS: 1.11.3 diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj deleted file mode 100644 index 605ab25..0000000 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ /dev/null @@ -1,776 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 3734824E06C05131A951DAAC4E363C77 /* Pods-ScaleCodecSwift_Tests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 554507D500D7EAB7F11FE014A9E7982F /* Pods-ScaleCodecSwift_Tests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 5D04F01B972B576769EFC70983DD68AC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 73010CC983E3809BECEE5348DA1BB8C6 /* Foundation.framework */; }; - 7840FCFEABAFA311CB537EA1693EFB27 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 73010CC983E3809BECEE5348DA1BB8C6 /* Foundation.framework */; }; - 7A5CAD942C9F2DFDC717B892746D7F7F /* Pods-ScaleCodecSwift_Tests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = EEE736A8BA616C773E2060E710CC1900 /* Pods-ScaleCodecSwift_Tests-dummy.m */; }; - 93E8CD0004FABF0494111F11630414B6 /* ReplaceMe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A903C8646004BAD459BC0BF7106ED0B /* ReplaceMe.swift */; }; - 9884C146807143691916493C608A32A0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 73010CC983E3809BECEE5348DA1BB8C6 /* Foundation.framework */; }; - A2F8781448D292DE387A3E63039780A5 /* ScaleCodecSwift-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 7209488145A891C0F48F3DEEE940D485 /* ScaleCodecSwift-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AC2623D4384749BDE7B53AEE4D61209E /* Pods-ScaleCodecSwift_Example-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = A05EA4F8043D8616ED0F1BBA99A62D91 /* Pods-ScaleCodecSwift_Example-dummy.m */; }; - B92DEC5B5672479495EEE79F683486E2 /* Pods-ScaleCodecSwift_Example-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 17136B9A42DE29355C9CF00087C08668 /* Pods-ScaleCodecSwift_Example-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CF1B8DADFE7231E2B8B6472434E75373 /* ScaleCodecSwift-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = B35450D13CC6033E28DA3204233AD81B /* ScaleCodecSwift-dummy.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 147CBDFB8AA7AAF9BCCC9E611F19E4BF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 698A4B4F8D8337D9A69FD704AA980F2B; - remoteInfo = "Pods-ScaleCodecSwift_Example"; - }; - 687CE176E69F96016BAA118115D1A85F /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 327EB852AC99FB550B56117AAF91EF30; - remoteInfo = ScaleCodecSwift; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 12DC422EFF79957B8069405113195BF1 /* Pods-ScaleCodecSwift_Example */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = "Pods-ScaleCodecSwift_Example"; path = Pods_ScaleCodecSwift_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 17136B9A42DE29355C9CF00087C08668 /* Pods-ScaleCodecSwift_Example-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-ScaleCodecSwift_Example-umbrella.h"; sourceTree = ""; }; - 19203D09C09EE8BBD9C9553D3EEF250E /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE; sourceTree = ""; }; - 1A477E3A591641C98C50E041AE0F0FB6 /* ScaleCodecSwift */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = ScaleCodecSwift; path = ScaleCodecSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 232BA43356C264CF30EDEA0DAC4334E0 /* ScaleCodecSwift-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "ScaleCodecSwift-prefix.pch"; sourceTree = ""; }; - 2EF993197BD9800FDE7D12150A34E52A /* Pods-ScaleCodecSwift_Example-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-ScaleCodecSwift_Example-Info.plist"; sourceTree = ""; }; - 30A7FA10B2584C9C59D67483D5A1AA9C /* Pods-ScaleCodecSwift_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-ScaleCodecSwift_Tests.debug.xcconfig"; sourceTree = ""; }; - 3A02D1FE631581D18A4C5771EB0CC543 /* Pods-ScaleCodecSwift_Example-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-ScaleCodecSwift_Example-acknowledgements.plist"; sourceTree = ""; }; - 3B1A7AAA294EA8CEA380C58AEC9734EF /* ScaleCodecSwift-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "ScaleCodecSwift-Info.plist"; sourceTree = ""; }; - 3C3FC26F046FB97250E1E9B28CD71683 /* Pods-ScaleCodecSwift_Tests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-ScaleCodecSwift_Tests-acknowledgements.markdown"; sourceTree = ""; }; - 3E94F2BE68E8526D7D3D4CAED94B966A /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; path = README.md; sourceTree = ""; }; - 4694A9A2850179E8DC7F3CDF76FEA3EE /* ScaleCodecSwift.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = ScaleCodecSwift.modulemap; sourceTree = ""; }; - 4E874735E40C7492FDF351D3D34A3BF4 /* ScaleCodecSwift.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = ScaleCodecSwift.release.xcconfig; sourceTree = ""; }; - 4F73E606F0D95894FA5ADF03AFD5B85E /* Pods-ScaleCodecSwift_Example-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-ScaleCodecSwift_Example-frameworks.sh"; sourceTree = ""; }; - 554507D500D7EAB7F11FE014A9E7982F /* Pods-ScaleCodecSwift_Tests-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-ScaleCodecSwift_Tests-umbrella.h"; sourceTree = ""; }; - 5A903C8646004BAD459BC0BF7106ED0B /* ReplaceMe.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ReplaceMe.swift; path = ScaleCodecSwift/Classes/ReplaceMe.swift; sourceTree = ""; }; - 7209488145A891C0F48F3DEEE940D485 /* ScaleCodecSwift-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "ScaleCodecSwift-umbrella.h"; sourceTree = ""; }; - 73010CC983E3809BECEE5348DA1BB8C6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - 7725A8A09405DFEF7F23C0BF1BA71F6F /* ScaleCodecSwift.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = ScaleCodecSwift.debug.xcconfig; sourceTree = ""; }; - 79459316AB6480B2CC7C59762CB9878F /* Pods-ScaleCodecSwift_Tests */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = "Pods-ScaleCodecSwift_Tests"; path = Pods_ScaleCodecSwift_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 92861781C07BBC936A71E6723017B321 /* Pods-ScaleCodecSwift_Tests-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-ScaleCodecSwift_Tests-Info.plist"; sourceTree = ""; }; - 92F58EAE3B4CE7913B4F77EF8B58CD5A /* Pods-ScaleCodecSwift_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-ScaleCodecSwift_Tests.release.xcconfig"; sourceTree = ""; }; - 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - A05EA4F8043D8616ED0F1BBA99A62D91 /* Pods-ScaleCodecSwift_Example-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-ScaleCodecSwift_Example-dummy.m"; sourceTree = ""; }; - A951E762902FC12B5B2C72843F93ED74 /* Pods-ScaleCodecSwift_Example-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-ScaleCodecSwift_Example-acknowledgements.markdown"; sourceTree = ""; }; - B35450D13CC6033E28DA3204233AD81B /* ScaleCodecSwift-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "ScaleCodecSwift-dummy.m"; sourceTree = ""; }; - BA2371A630C845BDDE44196FE65ADF4B /* Pods-ScaleCodecSwift_Tests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-ScaleCodecSwift_Tests-acknowledgements.plist"; sourceTree = ""; }; - C2BB3A2FB1E68AD1CF253D861ECB224A /* Pods-ScaleCodecSwift_Tests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-ScaleCodecSwift_Tests.modulemap"; sourceTree = ""; }; - CB409CD4B5CD269E7A867716FB9FEEE2 /* Pods-ScaleCodecSwift_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-ScaleCodecSwift_Example.release.xcconfig"; sourceTree = ""; }; - CD440A8169B990032D42B41109BB0DC4 /* Pods-ScaleCodecSwift_Example.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-ScaleCodecSwift_Example.modulemap"; sourceTree = ""; }; - D982FD02CC7357A7A4CF334C65A14C00 /* Pods-ScaleCodecSwift_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-ScaleCodecSwift_Example.debug.xcconfig"; sourceTree = ""; }; - DAB8DC369C66758792D87BEB8648D656 /* ScaleCodecSwift.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; path = ScaleCodecSwift.podspec; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - EEE736A8BA616C773E2060E710CC1900 /* Pods-ScaleCodecSwift_Tests-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-ScaleCodecSwift_Tests-dummy.m"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 8B0F7369B57C0985270176964A46F6A3 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 7840FCFEABAFA311CB537EA1693EFB27 /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 9C55E839657AC80E8BF15EDCFF235012 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 5D04F01B972B576769EFC70983DD68AC /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - B8389429C5B27CDC142274B86F36C4C6 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 9884C146807143691916493C608A32A0 /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 01D5C3A148AD52FD29C9D9830EA53AC9 /* Development Pods */ = { - isa = PBXGroup; - children = ( - C0C4B2C49180074D58AF91E9E8AC8737 /* ScaleCodecSwift */, - ); - name = "Development Pods"; - sourceTree = ""; - }; - 10A01ED182FBB0D01D213FE8394E21C5 /* Pods-ScaleCodecSwift_Tests */ = { - isa = PBXGroup; - children = ( - C2BB3A2FB1E68AD1CF253D861ECB224A /* Pods-ScaleCodecSwift_Tests.modulemap */, - 3C3FC26F046FB97250E1E9B28CD71683 /* Pods-ScaleCodecSwift_Tests-acknowledgements.markdown */, - BA2371A630C845BDDE44196FE65ADF4B /* Pods-ScaleCodecSwift_Tests-acknowledgements.plist */, - EEE736A8BA616C773E2060E710CC1900 /* Pods-ScaleCodecSwift_Tests-dummy.m */, - 92861781C07BBC936A71E6723017B321 /* Pods-ScaleCodecSwift_Tests-Info.plist */, - 554507D500D7EAB7F11FE014A9E7982F /* Pods-ScaleCodecSwift_Tests-umbrella.h */, - 30A7FA10B2584C9C59D67483D5A1AA9C /* Pods-ScaleCodecSwift_Tests.debug.xcconfig */, - 92F58EAE3B4CE7913B4F77EF8B58CD5A /* Pods-ScaleCodecSwift_Tests.release.xcconfig */, - ); - name = "Pods-ScaleCodecSwift_Tests"; - path = "Target Support Files/Pods-ScaleCodecSwift_Tests"; - sourceTree = ""; - }; - 1ABAE1751A90CC299162938372FAEEAC /* Support Files */ = { - isa = PBXGroup; - children = ( - 4694A9A2850179E8DC7F3CDF76FEA3EE /* ScaleCodecSwift.modulemap */, - B35450D13CC6033E28DA3204233AD81B /* ScaleCodecSwift-dummy.m */, - 3B1A7AAA294EA8CEA380C58AEC9734EF /* ScaleCodecSwift-Info.plist */, - 232BA43356C264CF30EDEA0DAC4334E0 /* ScaleCodecSwift-prefix.pch */, - 7209488145A891C0F48F3DEEE940D485 /* ScaleCodecSwift-umbrella.h */, - 7725A8A09405DFEF7F23C0BF1BA71F6F /* ScaleCodecSwift.debug.xcconfig */, - 4E874735E40C7492FDF351D3D34A3BF4 /* ScaleCodecSwift.release.xcconfig */, - ); - name = "Support Files"; - path = "Example/Pods/Target Support Files/ScaleCodecSwift"; - sourceTree = ""; - }; - 53ED60ED824866DD8ED6251415F560D6 /* Pods-ScaleCodecSwift_Example */ = { - isa = PBXGroup; - children = ( - CD440A8169B990032D42B41109BB0DC4 /* Pods-ScaleCodecSwift_Example.modulemap */, - A951E762902FC12B5B2C72843F93ED74 /* Pods-ScaleCodecSwift_Example-acknowledgements.markdown */, - 3A02D1FE631581D18A4C5771EB0CC543 /* Pods-ScaleCodecSwift_Example-acknowledgements.plist */, - A05EA4F8043D8616ED0F1BBA99A62D91 /* Pods-ScaleCodecSwift_Example-dummy.m */, - 4F73E606F0D95894FA5ADF03AFD5B85E /* Pods-ScaleCodecSwift_Example-frameworks.sh */, - 2EF993197BD9800FDE7D12150A34E52A /* Pods-ScaleCodecSwift_Example-Info.plist */, - 17136B9A42DE29355C9CF00087C08668 /* Pods-ScaleCodecSwift_Example-umbrella.h */, - D982FD02CC7357A7A4CF334C65A14C00 /* Pods-ScaleCodecSwift_Example.debug.xcconfig */, - CB409CD4B5CD269E7A867716FB9FEEE2 /* Pods-ScaleCodecSwift_Example.release.xcconfig */, - ); - name = "Pods-ScaleCodecSwift_Example"; - path = "Target Support Files/Pods-ScaleCodecSwift_Example"; - sourceTree = ""; - }; - 578452D2E740E91742655AC8F1636D1F /* iOS */ = { - isa = PBXGroup; - children = ( - 73010CC983E3809BECEE5348DA1BB8C6 /* Foundation.framework */, - ); - name = iOS; - sourceTree = ""; - }; - 8D70BBFAB3D3F1652C8290FC189E91CF /* Targets Support Files */ = { - isa = PBXGroup; - children = ( - 53ED60ED824866DD8ED6251415F560D6 /* Pods-ScaleCodecSwift_Example */, - 10A01ED182FBB0D01D213FE8394E21C5 /* Pods-ScaleCodecSwift_Tests */, - ); - name = "Targets Support Files"; - sourceTree = ""; - }; - A8E938BA084BD64451C8827B7A379E96 /* Pod */ = { - isa = PBXGroup; - children = ( - 19203D09C09EE8BBD9C9553D3EEF250E /* LICENSE */, - 3E94F2BE68E8526D7D3D4CAED94B966A /* README.md */, - DAB8DC369C66758792D87BEB8648D656 /* ScaleCodecSwift.podspec */, - ); - name = Pod; - sourceTree = ""; - }; - C0C4B2C49180074D58AF91E9E8AC8737 /* ScaleCodecSwift */ = { - isa = PBXGroup; - children = ( - 5A903C8646004BAD459BC0BF7106ED0B /* ReplaceMe.swift */, - A8E938BA084BD64451C8827B7A379E96 /* Pod */, - 1ABAE1751A90CC299162938372FAEEAC /* Support Files */, - ); - name = ScaleCodecSwift; - path = ../..; - sourceTree = ""; - }; - CBBC496EF22F84D9FD495C9CB78F85BE /* Products */ = { - isa = PBXGroup; - children = ( - 12DC422EFF79957B8069405113195BF1 /* Pods-ScaleCodecSwift_Example */, - 79459316AB6480B2CC7C59762CB9878F /* Pods-ScaleCodecSwift_Tests */, - 1A477E3A591641C98C50E041AE0F0FB6 /* ScaleCodecSwift */, - ); - name = Products; - sourceTree = ""; - }; - CF1408CF629C7361332E53B88F7BD30C = { - isa = PBXGroup; - children = ( - 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */, - 01D5C3A148AD52FD29C9D9830EA53AC9 /* Development Pods */, - D210D550F4EA176C3123ED886F8F87F5 /* Frameworks */, - CBBC496EF22F84D9FD495C9CB78F85BE /* Products */, - 8D70BBFAB3D3F1652C8290FC189E91CF /* Targets Support Files */, - ); - sourceTree = ""; - }; - D210D550F4EA176C3123ED886F8F87F5 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 578452D2E740E91742655AC8F1636D1F /* iOS */, - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 42D5890706285AD4DD31EAD67E990C1C /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 3734824E06C05131A951DAAC4E363C77 /* Pods-ScaleCodecSwift_Tests-umbrella.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 80BCA5506126B47861FAE859DE35CCB2 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - B92DEC5B5672479495EEE79F683486E2 /* Pods-ScaleCodecSwift_Example-umbrella.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 99FBD78B1B01F5827B43B12243047996 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - A2F8781448D292DE387A3E63039780A5 /* ScaleCodecSwift-umbrella.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 327EB852AC99FB550B56117AAF91EF30 /* ScaleCodecSwift */ = { - isa = PBXNativeTarget; - buildConfigurationList = F993E5854CFB6A17F2427BB8904160E3 /* Build configuration list for PBXNativeTarget "ScaleCodecSwift" */; - buildPhases = ( - 99FBD78B1B01F5827B43B12243047996 /* Headers */, - 04F0D1183A329100031EBF580453B8F1 /* Sources */, - 9C55E839657AC80E8BF15EDCFF235012 /* Frameworks */, - 62511F87689B68DC6B7A263EC9A21F79 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = ScaleCodecSwift; - productName = ScaleCodecSwift; - productReference = 1A477E3A591641C98C50E041AE0F0FB6 /* ScaleCodecSwift */; - productType = "com.apple.product-type.framework"; - }; - 4DE821331547FCB6F55CFF6DC34D2BEB /* Pods-ScaleCodecSwift_Tests */ = { - isa = PBXNativeTarget; - buildConfigurationList = BA6AC787D27E334D6B82E6FCD95E75FD /* Build configuration list for PBXNativeTarget "Pods-ScaleCodecSwift_Tests" */; - buildPhases = ( - 42D5890706285AD4DD31EAD67E990C1C /* Headers */, - 299F9AE7B002A5114AC51239111B9C63 /* Sources */, - B8389429C5B27CDC142274B86F36C4C6 /* Frameworks */, - 35B1B50D7B3B66E4FC89550743C2A722 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 4BC8679E5048B4D8FCD4FCCC84DB2DC2 /* PBXTargetDependency */, - ); - name = "Pods-ScaleCodecSwift_Tests"; - productName = Pods_ScaleCodecSwift_Tests; - productReference = 79459316AB6480B2CC7C59762CB9878F /* Pods-ScaleCodecSwift_Tests */; - productType = "com.apple.product-type.framework"; - }; - 698A4B4F8D8337D9A69FD704AA980F2B /* Pods-ScaleCodecSwift_Example */ = { - isa = PBXNativeTarget; - buildConfigurationList = 8338FB4170F8514620A17777B4FD7379 /* Build configuration list for PBXNativeTarget "Pods-ScaleCodecSwift_Example" */; - buildPhases = ( - 80BCA5506126B47861FAE859DE35CCB2 /* Headers */, - 27B2F31B7DF79B67F71FB3A3B9EAD995 /* Sources */, - 8B0F7369B57C0985270176964A46F6A3 /* Frameworks */, - 20552B63D92E1544626BC671D6308B82 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - FB44243E78A98CAA7A74C389D8FB785D /* PBXTargetDependency */, - ); - name = "Pods-ScaleCodecSwift_Example"; - productName = Pods_ScaleCodecSwift_Example; - productReference = 12DC422EFF79957B8069405113195BF1 /* Pods-ScaleCodecSwift_Example */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - BFDFE7DC352907FC980B868725387E98 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 1300; - LastUpgradeCheck = 1300; - }; - buildConfigurationList = 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - Base, - en, - ); - mainGroup = CF1408CF629C7361332E53B88F7BD30C; - productRefGroup = CBBC496EF22F84D9FD495C9CB78F85BE /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 698A4B4F8D8337D9A69FD704AA980F2B /* Pods-ScaleCodecSwift_Example */, - 4DE821331547FCB6F55CFF6DC34D2BEB /* Pods-ScaleCodecSwift_Tests */, - 327EB852AC99FB550B56117AAF91EF30 /* ScaleCodecSwift */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 20552B63D92E1544626BC671D6308B82 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 35B1B50D7B3B66E4FC89550743C2A722 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 62511F87689B68DC6B7A263EC9A21F79 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 04F0D1183A329100031EBF580453B8F1 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 93E8CD0004FABF0494111F11630414B6 /* ReplaceMe.swift in Sources */, - CF1B8DADFE7231E2B8B6472434E75373 /* ScaleCodecSwift-dummy.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 27B2F31B7DF79B67F71FB3A3B9EAD995 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - AC2623D4384749BDE7B53AEE4D61209E /* Pods-ScaleCodecSwift_Example-dummy.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 299F9AE7B002A5114AC51239111B9C63 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 7A5CAD942C9F2DFDC717B892746D7F7F /* Pods-ScaleCodecSwift_Tests-dummy.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 4BC8679E5048B4D8FCD4FCCC84DB2DC2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = "Pods-ScaleCodecSwift_Example"; - target = 698A4B4F8D8337D9A69FD704AA980F2B /* Pods-ScaleCodecSwift_Example */; - targetProxy = 147CBDFB8AA7AAF9BCCC9E611F19E4BF /* PBXContainerItemProxy */; - }; - FB44243E78A98CAA7A74C389D8FB785D /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = ScaleCodecSwift; - target = 327EB852AC99FB550B56117AAF91EF30 /* ScaleCodecSwift */; - targetProxy = 687CE176E69F96016BAA118115D1A85F /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 0BCB22B2F1B39B290372B847BC7D7B09 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = D982FD02CC7357A7A4CF334C65A14C00 /* Pods-ScaleCodecSwift_Example.debug.xcconfig */; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; - CLANG_ENABLE_OBJC_WEAK = NO; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACH_O_TYPE = staticlib; - MODULEMAP_FILE = "Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.modulemap"; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PODS_ROOT = "$(SRCROOT)"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 2956AE999F2D7ABFEDEC94D43746EDD2 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 30A7FA10B2584C9C59D67483D5A1AA9C /* Pods-ScaleCodecSwift_Tests.debug.xcconfig */; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; - CLANG_ENABLE_OBJC_WEAK = NO; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACH_O_TYPE = staticlib; - MODULEMAP_FILE = "Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.modulemap"; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PODS_ROOT = "$(SRCROOT)"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 4BE5DD7EAD7ACCA749056980F7746B40 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7725A8A09405DFEF7F23C0BF1BA71F6F /* ScaleCodecSwift.debug.xcconfig */; - buildSettings = { - CLANG_ENABLE_OBJC_WEAK = NO; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/ScaleCodecSwift/ScaleCodecSwift-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/ScaleCodecSwift/ScaleCodecSwift-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/ScaleCodecSwift/ScaleCodecSwift.modulemap"; - PRODUCT_MODULE_NAME = ScaleCodecSwift; - PRODUCT_NAME = ScaleCodecSwift; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 62B6DCC79CE5752B7C6D3A4B0B1AACD0 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 4E874735E40C7492FDF351D3D34A3BF4 /* ScaleCodecSwift.release.xcconfig */; - buildSettings = { - CLANG_ENABLE_OBJC_WEAK = NO; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/ScaleCodecSwift/ScaleCodecSwift-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/ScaleCodecSwift/ScaleCodecSwift-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/ScaleCodecSwift/ScaleCodecSwift.modulemap"; - PRODUCT_MODULE_NAME = ScaleCodecSwift; - PRODUCT_NAME = ScaleCodecSwift; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - 7EE7A78859F657F6BEFC651185B43192 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "POD_CONFIGURATION_RELEASE=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; - STRIP_INSTALLED_PRODUCT = NO; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 5.0; - SYMROOT = "${SRCROOT}/../build"; - }; - name = Release; - }; - 987E8EBBA49AAD9FC2E60362E1E13676 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = CB409CD4B5CD269E7A867716FB9FEEE2 /* Pods-ScaleCodecSwift_Example.release.xcconfig */; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; - CLANG_ENABLE_OBJC_WEAK = NO; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACH_O_TYPE = staticlib; - MODULEMAP_FILE = "Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.modulemap"; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PODS_ROOT = "$(SRCROOT)"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - D299434AB35E7FD6F7921C8EF24742FF /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "POD_CONFIGURATION_DEBUG=1", - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - PRODUCT_NAME = "$(TARGET_NAME)"; - STRIP_INSTALLED_PRODUCT = NO; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - SYMROOT = "${SRCROOT}/../build"; - }; - name = Debug; - }; - E63EAC671B1DFDD1E22D22BCFE69827C /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 92F58EAE3B4CE7913B4F77EF8B58CD5A /* Pods-ScaleCodecSwift_Tests.release.xcconfig */; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; - CLANG_ENABLE_OBJC_WEAK = NO; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACH_O_TYPE = staticlib; - MODULEMAP_FILE = "Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.modulemap"; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PODS_ROOT = "$(SRCROOT)"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - D299434AB35E7FD6F7921C8EF24742FF /* Debug */, - 7EE7A78859F657F6BEFC651185B43192 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 8338FB4170F8514620A17777B4FD7379 /* Build configuration list for PBXNativeTarget "Pods-ScaleCodecSwift_Example" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 0BCB22B2F1B39B290372B847BC7D7B09 /* Debug */, - 987E8EBBA49AAD9FC2E60362E1E13676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - BA6AC787D27E334D6B82E6FCD95E75FD /* Build configuration list for PBXNativeTarget "Pods-ScaleCodecSwift_Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2956AE999F2D7ABFEDEC94D43746EDD2 /* Debug */, - E63EAC671B1DFDD1E22D22BCFE69827C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - F993E5854CFB6A17F2427BB8904160E3 /* Build configuration list for PBXNativeTarget "ScaleCodecSwift" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4BE5DD7EAD7ACCA749056980F7746B40 /* Debug */, - 62B6DCC79CE5752B7C6D3A4B0B1AACD0 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = BFDFE7DC352907FC980B868725387E98 /* Project object */; -} diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-Info.plist b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-Info.plist deleted file mode 100644 index 2243fe6..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0.0 - CFBundleSignature - ???? - CFBundleVersion - ${CURRENT_PROJECT_VERSION} - NSPrincipalClass - - - diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-acknowledgements.markdown b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-acknowledgements.markdown deleted file mode 100644 index 23dff6e..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-acknowledgements.markdown +++ /dev/null @@ -1,26 +0,0 @@ -# Acknowledgements -This application makes use of the following third party libraries: - -## ScaleCodecSwift - -Copyright (c) 2022 TigranIsk - -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. - -Generated by CocoaPods - https://cocoapods.org diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-acknowledgements.plist b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-acknowledgements.plist deleted file mode 100644 index f521e5f..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-acknowledgements.plist +++ /dev/null @@ -1,58 +0,0 @@ - - - - - PreferenceSpecifiers - - - FooterText - This application makes use of the following third party libraries: - Title - Acknowledgements - Type - PSGroupSpecifier - - - FooterText - Copyright (c) 2022 TigranIsk <tiskandaryan@griddynamics.com> - -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. - - License - MIT - Title - ScaleCodecSwift - Type - PSGroupSpecifier - - - FooterText - Generated by CocoaPods - https://cocoapods.org - Title - - Type - PSGroupSpecifier - - - StringsTable - Acknowledgements - Title - Acknowledgements - - diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-dummy.m b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-dummy.m deleted file mode 100644 index b393cdd..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-dummy.m +++ /dev/null @@ -1,5 +0,0 @@ -#import -@interface PodsDummy_Pods_ScaleCodecSwift_Example : NSObject -@end -@implementation PodsDummy_Pods_ScaleCodecSwift_Example -@end diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-frameworks.sh b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-frameworks.sh deleted file mode 100755 index a0963ff..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-frameworks.sh +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/sh -set -e -set -u -set -o pipefail - -function on_error { - echo "$(realpath -mq "${0}"):$1: error: Unexpected failure" -} -trap 'on_error $LINENO' ERR - -if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then - # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy - # frameworks to, so exit 0 (signalling the script phase was successful). - exit 0 -fi - -echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" -mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" - -COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" -SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" -BCSYMBOLMAP_DIR="BCSymbolMaps" - - -# This protects against multiple targets copying the same framework dependency at the same time. The solution -# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html -RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") - -# Copies and strips a vendored framework -install_framework() -{ - if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then - local source="${BUILT_PRODUCTS_DIR}/$1" - elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then - local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" - elif [ -r "$1" ]; then - local source="$1" - fi - - local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" - - if [ -L "${source}" ]; then - echo "Symlinked..." - source="$(readlink "${source}")" - fi - - if [ -d "${source}/${BCSYMBOLMAP_DIR}" ]; then - # Locate and install any .bcsymbolmaps if present, and remove them from the .framework before the framework is copied - find "${source}/${BCSYMBOLMAP_DIR}" -name "*.bcsymbolmap"|while read f; do - echo "Installing $f" - install_bcsymbolmap "$f" "$destination" - rm "$f" - done - rmdir "${source}/${BCSYMBOLMAP_DIR}" - fi - - # Use filter instead of exclude so missing patterns don't throw errors. - echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" - rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" - - local basename - basename="$(basename -s .framework "$1")" - binary="${destination}/${basename}.framework/${basename}" - - if ! [ -r "$binary" ]; then - binary="${destination}/${basename}" - elif [ -L "${binary}" ]; then - echo "Destination binary is symlinked..." - dirname="$(dirname "${binary}")" - binary="${dirname}/$(readlink "${binary}")" - fi - - # Strip invalid architectures so "fat" simulator / device frameworks work on device - if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then - strip_invalid_archs "$binary" - fi - - # Resign the code if required by the build settings to avoid unstable apps - code_sign_if_enabled "${destination}/$(basename "$1")" - - # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. - if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then - local swift_runtime_libs - swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u) - for lib in $swift_runtime_libs; do - echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" - rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" - code_sign_if_enabled "${destination}/${lib}" - done - fi -} -# Copies and strips a vendored dSYM -install_dsym() { - local source="$1" - warn_missing_arch=${2:-true} - if [ -r "$source" ]; then - # Copy the dSYM into the targets temp dir. - echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" - rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" - - local basename - basename="$(basename -s .dSYM "$source")" - binary_name="$(ls "$source/Contents/Resources/DWARF")" - binary="${DERIVED_FILES_DIR}/${basename}.dSYM/Contents/Resources/DWARF/${binary_name}" - - # Strip invalid architectures from the dSYM. - if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then - strip_invalid_archs "$binary" "$warn_missing_arch" - fi - if [[ $STRIP_BINARY_RETVAL == 0 ]]; then - # Move the stripped file into its final destination. - echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" - rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.dSYM" "${DWARF_DSYM_FOLDER_PATH}" - else - # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. - mkdir -p "${DWARF_DSYM_FOLDER_PATH}" - touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.dSYM" - fi - fi -} - -# Used as a return value for each invocation of `strip_invalid_archs` function. -STRIP_BINARY_RETVAL=0 - -# Strip invalid architectures -strip_invalid_archs() { - binary="$1" - warn_missing_arch=${2:-true} - # Get architectures for current target binary - binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" - # Intersect them with the architectures we are building for - intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" - # If there are no archs supported by this binary then warn the user - if [[ -z "$intersected_archs" ]]; then - if [[ "$warn_missing_arch" == "true" ]]; then - echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." - fi - STRIP_BINARY_RETVAL=1 - return - fi - stripped="" - for arch in $binary_archs; do - if ! [[ "${ARCHS}" == *"$arch"* ]]; then - # Strip non-valid architectures in-place - lipo -remove "$arch" -output "$binary" "$binary" - stripped="$stripped $arch" - fi - done - if [[ "$stripped" ]]; then - echo "Stripped $binary of architectures:$stripped" - fi - STRIP_BINARY_RETVAL=0 -} - -# Copies the bcsymbolmap files of a vendored framework -install_bcsymbolmap() { - local bcsymbolmap_path="$1" - local destination="${BUILT_PRODUCTS_DIR}" - echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"" - rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}" -} - -# Signs a framework with the provided identity -code_sign_if_enabled() { - if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then - # Use the current code_sign_identity - echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" - local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" - - if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then - code_sign_cmd="$code_sign_cmd &" - fi - echo "$code_sign_cmd" - eval "$code_sign_cmd" - fi -} - -if [[ "$CONFIGURATION" == "Debug" ]]; then - install_framework "${BUILT_PRODUCTS_DIR}/ScaleCodecSwift/ScaleCodecSwift.framework" -fi -if [[ "$CONFIGURATION" == "Release" ]]; then - install_framework "${BUILT_PRODUCTS_DIR}/ScaleCodecSwift/ScaleCodecSwift.framework" -fi -if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then - wait -fi diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-umbrella.h b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-umbrella.h deleted file mode 100644 index badbc79..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-umbrella.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - - -FOUNDATION_EXPORT double Pods_ScaleCodecSwift_ExampleVersionNumber; -FOUNDATION_EXPORT const unsigned char Pods_ScaleCodecSwift_ExampleVersionString[]; - diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.debug.xcconfig b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.debug.xcconfig deleted file mode 100644 index 2850e8a..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.debug.xcconfig +++ /dev/null @@ -1,15 +0,0 @@ -ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES -CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ScaleCodecSwift" -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ScaleCodecSwift/ScaleCodecSwift.framework/Headers" -LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift '@executable_path/Frameworks' '@loader_path/Frameworks' -LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift -OTHER_LDFLAGS = $(inherited) -framework "ScaleCodecSwift" -OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_PODFILE_DIR_PATH = ${SRCROOT}/. -PODS_ROOT = ${SRCROOT}/Pods -PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates -USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.modulemap b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.modulemap deleted file mode 100644 index e7d4790..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module Pods_ScaleCodecSwift_Example { - umbrella header "Pods-ScaleCodecSwift_Example-umbrella.h" - - export * - module * { export * } -} diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.release.xcconfig b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.release.xcconfig deleted file mode 100644 index 2850e8a..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.release.xcconfig +++ /dev/null @@ -1,15 +0,0 @@ -ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES -CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ScaleCodecSwift" -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ScaleCodecSwift/ScaleCodecSwift.framework/Headers" -LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift '@executable_path/Frameworks' '@loader_path/Frameworks' -LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift -OTHER_LDFLAGS = $(inherited) -framework "ScaleCodecSwift" -OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_PODFILE_DIR_PATH = ${SRCROOT}/. -PODS_ROOT = ${SRCROOT}/Pods -PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates -USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-Info.plist b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-Info.plist deleted file mode 100644 index 2243fe6..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0.0 - CFBundleSignature - ???? - CFBundleVersion - ${CURRENT_PROJECT_VERSION} - NSPrincipalClass - - - diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-acknowledgements.markdown b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-acknowledgements.markdown deleted file mode 100644 index 102af75..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-acknowledgements.markdown +++ /dev/null @@ -1,3 +0,0 @@ -# Acknowledgements -This application makes use of the following third party libraries: -Generated by CocoaPods - https://cocoapods.org diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-acknowledgements.plist b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-acknowledgements.plist deleted file mode 100644 index 7acbad1..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-acknowledgements.plist +++ /dev/null @@ -1,29 +0,0 @@ - - - - - PreferenceSpecifiers - - - FooterText - This application makes use of the following third party libraries: - Title - Acknowledgements - Type - PSGroupSpecifier - - - FooterText - Generated by CocoaPods - https://cocoapods.org - Title - - Type - PSGroupSpecifier - - - StringsTable - Acknowledgements - Title - Acknowledgements - - diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-dummy.m b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-dummy.m deleted file mode 100644 index 3c68106..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-dummy.m +++ /dev/null @@ -1,5 +0,0 @@ -#import -@interface PodsDummy_Pods_ScaleCodecSwift_Tests : NSObject -@end -@implementation PodsDummy_Pods_ScaleCodecSwift_Tests -@end diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-umbrella.h b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-umbrella.h deleted file mode 100644 index ed6f2d1..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests-umbrella.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - - -FOUNDATION_EXPORT double Pods_ScaleCodecSwift_TestsVersionNumber; -FOUNDATION_EXPORT const unsigned char Pods_ScaleCodecSwift_TestsVersionString[]; - diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.debug.xcconfig b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.debug.xcconfig deleted file mode 100644 index d002a36..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.debug.xcconfig +++ /dev/null @@ -1,11 +0,0 @@ -CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ScaleCodecSwift" -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ScaleCodecSwift/ScaleCodecSwift.framework/Headers" -OTHER_LDFLAGS = $(inherited) -framework "ScaleCodecSwift" -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_PODFILE_DIR_PATH = ${SRCROOT}/. -PODS_ROOT = ${SRCROOT}/Pods -PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates -USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.modulemap b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.modulemap deleted file mode 100644 index 4dae931..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module Pods_ScaleCodecSwift_Tests { - umbrella header "Pods-ScaleCodecSwift_Tests-umbrella.h" - - export * - module * { export * } -} diff --git a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.release.xcconfig b/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.release.xcconfig deleted file mode 100644 index d002a36..0000000 --- a/Example/Pods/Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.release.xcconfig +++ /dev/null @@ -1,11 +0,0 @@ -CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ScaleCodecSwift" -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ScaleCodecSwift/ScaleCodecSwift.framework/Headers" -OTHER_LDFLAGS = $(inherited) -framework "ScaleCodecSwift" -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_PODFILE_DIR_PATH = ${SRCROOT}/. -PODS_ROOT = ${SRCROOT}/Pods -PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates -USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-Info.plist b/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-Info.plist deleted file mode 100644 index 161a9d3..0000000 --- a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - ${PRODUCT_BUNDLE_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - FMWK - CFBundleShortVersionString - 0.1.0 - CFBundleSignature - ???? - CFBundleVersion - ${CURRENT_PROJECT_VERSION} - NSPrincipalClass - - - diff --git a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-dummy.m b/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-dummy.m deleted file mode 100644 index 86f86d7..0000000 --- a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-dummy.m +++ /dev/null @@ -1,5 +0,0 @@ -#import -@interface PodsDummy_ScaleCodecSwift : NSObject -@end -@implementation PodsDummy_ScaleCodecSwift -@end diff --git a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-prefix.pch b/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-prefix.pch deleted file mode 100644 index beb2a24..0000000 --- a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-prefix.pch +++ /dev/null @@ -1,12 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - diff --git a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-umbrella.h b/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-umbrella.h deleted file mode 100644 index 0dd9188..0000000 --- a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift-umbrella.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef __OBJC__ -#import -#else -#ifndef FOUNDATION_EXPORT -#if defined(__cplusplus) -#define FOUNDATION_EXPORT extern "C" -#else -#define FOUNDATION_EXPORT extern -#endif -#endif -#endif - - -FOUNDATION_EXPORT double ScaleCodecSwiftVersionNumber; -FOUNDATION_EXPORT const unsigned char ScaleCodecSwiftVersionString[]; - diff --git a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift.debug.xcconfig b/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift.debug.xcconfig deleted file mode 100644 index 60475b8..0000000 --- a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift.debug.xcconfig +++ /dev/null @@ -1,13 +0,0 @@ -CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO -CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/ScaleCodecSwift -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift -OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_ROOT = ${SRCROOT} -PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. -PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates -PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} -SKIP_INSTALL = YES -USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift.modulemap b/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift.modulemap deleted file mode 100644 index 2e96358..0000000 --- a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module ScaleCodecSwift { - umbrella header "ScaleCodecSwift-umbrella.h" - - export * - module * { export * } -} diff --git a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift.release.xcconfig b/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift.release.xcconfig deleted file mode 100644 index 60475b8..0000000 --- a/Example/Pods/Target Support Files/ScaleCodecSwift/ScaleCodecSwift.release.xcconfig +++ /dev/null @@ -1,13 +0,0 @@ -CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO -CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/ScaleCodecSwift -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift -OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -PODS_BUILD_DIR = ${BUILD_DIR} -PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) -PODS_ROOT = ${SRCROOT} -PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. -PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates -PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} -SKIP_INSTALL = YES -USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/Example/ScaleCodecSwift.xcodeproj/project.pbxproj b/Example/ScaleCodecSwift.xcodeproj/project.pbxproj index d922e54..19f78f9 100644 --- a/Example/ScaleCodecSwift.xcodeproj/project.pbxproj +++ b/Example/ScaleCodecSwift.xcodeproj/project.pbxproj @@ -7,14 +7,34 @@ objects = { /* Begin PBXBuildFile section */ + 11353EA329396E0600744B0B /* Int128Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11353EA229396E0600744B0B /* Int128Tests.swift */; }; + 11353EA529397D4800744B0B /* UInt128Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11353EA429397D4800744B0B /* UInt128Tests.swift */; }; + 11353EA729397E1B00744B0B /* Int256Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11353EA629397E1B00744B0B /* Int256Tests.swift */; }; + 11353EA929397F5100744B0B /* UInt256Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11353EA829397F5100744B0B /* UInt256Tests.swift */; }; + 11353EAB2939803800744B0B /* Int512Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11353EAA2939803800744B0B /* Int512Tests.swift */; }; + 11353EAD293983C200744B0B /* UInt512Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11353EAC293983C200744B0B /* UInt512Tests.swift */; }; + 114126AD28FF61CA00F3A03E /* TestingEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 114126AC28FF61CA00F3A03E /* TestingEnum.swift */; }; + 114126AF28FF627500F3A03E /* EnumTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 114126AE28FF627500F3A03E /* EnumTests.swift */; }; + 11882BFD28FDE5D90029E4BD /* StructTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1111B34C28FDDFF80019844F /* StructTests.swift */; }; + 11882BFE28FDE5E30029E4BD /* AdapterProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1111B34328FDDFF70019844F /* AdapterProviderTests.swift */; }; + 11882BFF28FDE5E30029E4BD /* BoolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1111B34A28FDDFF70019844F /* BoolTests.swift */; }; + 11882C0028FDE5E30029E4BD /* NumericTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1111B34B28FDDFF80019844F /* NumericTests.swift */; }; + 11882C0128FDE5E30029E4BD /* BigUIntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1111B34528FDDFF70019844F /* BigUIntTests.swift */; }; + 11882C0228FDE5E30029E4BD /* StringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1111B34428FDDFF70019844F /* StringTests.swift */; }; + 11882C0328FDE5E80029E4BD /* TestConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1111B34828FDDFF70019844F /* TestConstants.swift */; }; + 11882C0428FDE5E80029E4BD /* BaseNumericTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1111B34728FDDFF70019844F /* BaseNumericTest.swift */; }; + 11882C0528FDE5E80029E4BD /* BaseTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1111B34928FDDFF70019844F /* BaseTest.swift */; }; + 11882C0628FDE5EC0029E4BD /* TestingStruct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1111B34228FDDFF70019844F /* TestingStruct.swift */; }; + 11920B8C291FEBDC006C4E36 /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11920B8B291FEBDC006C4E36 /* DataTests.swift */; }; 1CE54A624C137AB001FFA6C3 /* Pods_ScaleCodecSwift_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EF03485E4891F4F0A87C7E1 /* Pods_ScaleCodecSwift_Tests.framework */; }; 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; - 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; A6AD4409798F9F0A3122ADBB /* Pods_ScaleCodecSwift_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2D6C2341B483543A11ED7D71 /* Pods_ScaleCodecSwift_Example.framework */; }; + C7542D55296FD3A500D4606D /* AdapterProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7542D54296FD3A500D4606D /* AdapterProtocolTests.swift */; }; + C7B811212972809400BAE319 /* FixedSizeArrayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7B811202972809400BAE319 /* FixedSizeArrayTests.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -28,6 +48,25 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 1111B34228FDDFF70019844F /* TestingStruct.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestingStruct.swift; sourceTree = ""; }; + 1111B34328FDDFF70019844F /* AdapterProviderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdapterProviderTests.swift; sourceTree = ""; }; + 1111B34428FDDFF70019844F /* StringTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringTests.swift; sourceTree = ""; }; + 1111B34528FDDFF70019844F /* BigUIntTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BigUIntTests.swift; sourceTree = ""; }; + 1111B34728FDDFF70019844F /* BaseNumericTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseNumericTest.swift; sourceTree = ""; }; + 1111B34828FDDFF70019844F /* TestConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestConstants.swift; sourceTree = ""; }; + 1111B34928FDDFF70019844F /* BaseTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTest.swift; sourceTree = ""; }; + 1111B34A28FDDFF70019844F /* BoolTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoolTests.swift; sourceTree = ""; }; + 1111B34B28FDDFF80019844F /* NumericTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumericTests.swift; sourceTree = ""; }; + 1111B34C28FDDFF80019844F /* StructTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StructTests.swift; sourceTree = ""; }; + 11353EA229396E0600744B0B /* Int128Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Int128Tests.swift; sourceTree = ""; }; + 11353EA429397D4800744B0B /* UInt128Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UInt128Tests.swift; sourceTree = ""; }; + 11353EA629397E1B00744B0B /* Int256Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Int256Tests.swift; sourceTree = ""; }; + 11353EA829397F5100744B0B /* UInt256Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UInt256Tests.swift; sourceTree = ""; }; + 11353EAA2939803800744B0B /* Int512Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Int512Tests.swift; sourceTree = ""; }; + 11353EAC293983C200744B0B /* UInt512Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UInt512Tests.swift; sourceTree = ""; }; + 114126AC28FF61CA00F3A03E /* TestingEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestingEnum.swift; sourceTree = ""; }; + 114126AE28FF627500F3A03E /* EnumTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnumTests.swift; sourceTree = ""; }; + 11920B8B291FEBDC006C4E36 /* DataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTests.swift; sourceTree = ""; }; 1EF03485E4891F4F0A87C7E1 /* Pods_ScaleCodecSwift_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ScaleCodecSwift_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2D6C2341B483543A11ED7D71 /* Pods_ScaleCodecSwift_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ScaleCodecSwift_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACD01AFB9204008FA782 /* ScaleCodecSwift_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ScaleCodecSwift_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -39,14 +78,15 @@ 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 607FACE51AFB9204008FA782 /* ScaleCodecSwift_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ScaleCodecSwift_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 6778A64E4A551C4AE9DDC23E /* Pods-ScaleCodecSwift_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ScaleCodecSwift_Tests.release.xcconfig"; path = "Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.release.xcconfig"; sourceTree = ""; }; - 749A22C5DC43A5DCDF82C5B0 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; name = README.md; path = ../README.md; sourceTree = ""; }; - 8F6FF144D59E3C1045E7E601 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; + 749A22C5DC43A5DCDF82C5B0 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; + 8F6FF144D59E3C1045E7E601 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 94D9D7D0A540F3DBB2DB56D2 /* Pods-ScaleCodecSwift_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ScaleCodecSwift_Tests.debug.xcconfig"; path = "Target Support Files/Pods-ScaleCodecSwift_Tests/Pods-ScaleCodecSwift_Tests.debug.xcconfig"; sourceTree = ""; }; B9F5545EEDDF89E927CBD079 /* Pods-ScaleCodecSwift_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ScaleCodecSwift_Example.debug.xcconfig"; path = "Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.debug.xcconfig"; sourceTree = ""; }; + C7542D54296FD3A500D4606D /* AdapterProtocolTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdapterProtocolTests.swift; sourceTree = ""; }; + C7B811202972809400BAE319 /* FixedSizeArrayTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FixedSizeArrayTests.swift; sourceTree = ""; }; D51B06D7123C18EF5AC22025 /* Pods-ScaleCodecSwift_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ScaleCodecSwift_Example.release.xcconfig"; path = "Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example.release.xcconfig"; sourceTree = ""; }; - D91F409B4E55A15F4F873D03 /* ScaleCodecSwift.podspec */ = {isa = PBXFileReference; includeInIndex = 1; name = ScaleCodecSwift.podspec; path = ../ScaleCodecSwift.podspec; sourceTree = ""; }; + D91F409B4E55A15F4F873D03 /* ScaleCodecSwift.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = ScaleCodecSwift.podspec; path = ../ScaleCodecSwift.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -69,6 +109,25 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1111B34128FDDFF70019844F /* Types */ = { + isa = PBXGroup; + children = ( + 1111B34228FDDFF70019844F /* TestingStruct.swift */, + 114126AC28FF61CA00F3A03E /* TestingEnum.swift */, + ); + path = Types; + sourceTree = ""; + }; + 1111B34628FDDFF70019844F /* Base */ = { + isa = PBXGroup; + children = ( + 1111B34728FDDFF70019844F /* BaseNumericTest.swift */, + 1111B34828FDDFF70019844F /* TestConstants.swift */, + 1111B34928FDDFF70019844F /* BaseTest.swift */, + ); + path = Base; + sourceTree = ""; + }; 607FACC71AFB9204008FA782 = { isa = PBXGroup; children = ( @@ -115,7 +174,24 @@ 607FACE81AFB9204008FA782 /* Tests */ = { isa = PBXGroup; children = ( - 607FACEB1AFB9204008FA782 /* Tests.swift */, + C7B811202972809400BAE319 /* FixedSizeArrayTests.swift */, + 1111B34128FDDFF70019844F /* Types */, + 1111B34628FDDFF70019844F /* Base */, + C7542D54296FD3A500D4606D /* AdapterProtocolTests.swift */, + 1111B34328FDDFF70019844F /* AdapterProviderTests.swift */, + 1111B34528FDDFF70019844F /* BigUIntTests.swift */, + 1111B34A28FDDFF70019844F /* BoolTests.swift */, + 1111B34B28FDDFF80019844F /* NumericTests.swift */, + 1111B34428FDDFF70019844F /* StringTests.swift */, + 11920B8B291FEBDC006C4E36 /* DataTests.swift */, + 1111B34C28FDDFF80019844F /* StructTests.swift */, + 114126AE28FF627500F3A03E /* EnumTests.swift */, + 11353EA229396E0600744B0B /* Int128Tests.swift */, + 11353EA629397E1B00744B0B /* Int256Tests.swift */, + 11353EA829397F5100744B0B /* UInt256Tests.swift */, + 11353EA429397D4800744B0B /* UInt128Tests.swift */, + 11353EAA2939803800744B0B /* Int512Tests.swift */, + 11353EAC293983C200744B0B /* UInt512Tests.swift */, 607FACE91AFB9204008FA782 /* Supporting Files */, ); path = Tests; @@ -156,7 +232,6 @@ 94D9D7D0A540F3DBB2DB56D2 /* Pods-ScaleCodecSwift_Tests.debug.xcconfig */, 6778A64E4A551C4AE9DDC23E /* Pods-ScaleCodecSwift_Tests.release.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -227,6 +302,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -291,10 +367,14 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-ScaleCodecSwift_Example/Pods-ScaleCodecSwift_Example-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/BigInt/BigInt.framework", + "${BUILT_PRODUCTS_DIR}/CommonSwift/CommonSwift.framework", "${BUILT_PRODUCTS_DIR}/ScaleCodecSwift/ScaleCodecSwift.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BigInt.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CommonSwift.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ScaleCodecSwift.framework", ); runOnlyForDeploymentPostprocessing = 0; @@ -340,7 +420,27 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, + 11882BFE28FDE5E30029E4BD /* AdapterProviderTests.swift in Sources */, + 11353EA329396E0600744B0B /* Int128Tests.swift in Sources */, + 11882C0328FDE5E80029E4BD /* TestConstants.swift in Sources */, + 11882BFD28FDE5D90029E4BD /* StructTests.swift in Sources */, + 11882BFF28FDE5E30029E4BD /* BoolTests.swift in Sources */, + 11882C0528FDE5E80029E4BD /* BaseTest.swift in Sources */, + 11882C0128FDE5E30029E4BD /* BigUIntTests.swift in Sources */, + C7B811212972809400BAE319 /* FixedSizeArrayTests.swift in Sources */, + C7542D55296FD3A500D4606D /* AdapterProtocolTests.swift in Sources */, + 11353EA729397E1B00744B0B /* Int256Tests.swift in Sources */, + 11882C0228FDE5E30029E4BD /* StringTests.swift in Sources */, + 11353EA529397D4800744B0B /* UInt128Tests.swift in Sources */, + 11882C0628FDE5EC0029E4BD /* TestingStruct.swift in Sources */, + 11882C0428FDE5E80029E4BD /* BaseNumericTest.swift in Sources */, + 114126AD28FF61CA00F3A03E /* TestingEnum.swift in Sources */, + 114126AF28FF627500F3A03E /* EnumTests.swift in Sources */, + 11353EAD293983C200744B0B /* UInt512Tests.swift in Sources */, + 11353EA929397F5100744B0B /* UInt256Tests.swift in Sources */, + 11920B8C291FEBDC006C4E36 /* DataTests.swift in Sources */, + 11353EAB2939803800744B0B /* Int512Tests.swift in Sources */, + 11882C0028FDE5E30029E4BD /* NumericTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -419,7 +519,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -465,7 +565,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -479,6 +579,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = ScaleCodecSwift/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; @@ -494,6 +595,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = ScaleCodecSwift/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; @@ -516,6 +618,7 @@ "$(inherited)", ); INFOPLIST_FILE = Tests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -534,6 +637,7 @@ "$(inherited)", ); INFOPLIST_FILE = Tests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Example/ScaleCodecSwift.xcworkspace/contents.xcworkspacedata b/Example/ScaleCodecSwift.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..bfe3e47 --- /dev/null +++ b/Example/ScaleCodecSwift.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Example/ScaleCodecSwift/AppDelegate.swift b/Example/ScaleCodecSwift/AppDelegate.swift index 435b745..a85a418 100644 --- a/Example/ScaleCodecSwift/AppDelegate.swift +++ b/Example/ScaleCodecSwift/AppDelegate.swift @@ -1,10 +1,20 @@ -// -// AppDelegate.swift -// ScaleCodecSwift -// -// Created by TigranIsk on 10/17/2022. -// Copyright (c) 2022 TigranIsk. All rights reserved. -// +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 UIKit @@ -40,7 +50,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } - - } - diff --git a/Example/ScaleCodecSwift/ViewController.swift b/Example/ScaleCodecSwift/ViewController.swift index 73d48ee..d9aa307 100644 --- a/Example/ScaleCodecSwift/ViewController.swift +++ b/Example/ScaleCodecSwift/ViewController.swift @@ -1,10 +1,20 @@ -// -// ViewController.swift -// ScaleCodecSwift -// -// Created by TigranIsk on 10/17/2022. -// Copyright (c) 2022 TigranIsk. All rights reserved. -// +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 UIKit diff --git a/Example/Tests/AdapterProtocolTests.swift b/Example/Tests/AdapterProtocolTests.swift new file mode 100644 index 0000000..c14c754 --- /dev/null +++ b/Example/Tests/AdapterProtocolTests.swift @@ -0,0 +1,34 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 XCTest +@testable import ScaleCodecSwift + +class AdapterProtocolTests: XCTestCase { + func test() throws { + let string = UUID().uuidString + let stringAdapter = StringAdapter(coder: ScaleCoder.default()) as ScaleCodecAdaptable + let data = try stringAdapter.tryWrite(value: string) + let stringAsAny = try stringAdapter.tryRead(from: .init(data: data)) + guard let stringDecoded = stringAsAny as? String else { + XCTFail() + return + } + XCTAssertEqual(string, stringDecoded) + } +} diff --git a/Example/Tests/AdapterProviderTests.swift b/Example/Tests/AdapterProviderTests.swift new file mode 100644 index 0000000..9dc754a --- /dev/null +++ b/Example/Tests/AdapterProviderTests.swift @@ -0,0 +1,105 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 XCTest +@testable import ScaleCodecSwift + +class AdapterProviderTests: XCTestCase { + func testProvider() { + let scaleAdapterProvider = ScaleCodecAdapterProvider() + let coder = ScaleCoder(adapterProvider: scaleAdapterProvider) + + let adapter = StringAdapter(coder: coder) + + scaleAdapterProvider.setAdapter(adapter, for: String.self) + var returnedAdapter: ScaleCodecAdapter? + + do { + returnedAdapter = try scaleAdapterProvider.adapter(for: String.self) + } catch { + XCTFail("No Adapter found") + } + + XCTAssertNotNil(returnedAdapter) + } +} + +class DefaultAdapterProviderTests: XCTestCase { + func testDefaultAdapterProviderForArray() { + let adapter = try? DefaultScaleCodecAdapterProvider().adapter(for: [Int].self) + XCTAssertNotNil(adapter) + } + + func testDefaultAdapterProviderForInt8() { + testAdapter(NumericAdapter.self, for: Int8.self) + } + + func testDefaultAdapterProviderForInt16() { + testAdapter(NumericAdapter.self, for: Int16.self) + } + + func testDefaultAdapterProviderForInt32() { + testAdapter(NumericAdapter.self, for: Int32.self) + } + + func testDefaultAdapterProviderForInt() { + testAdapter(NumericAdapter.self, for: Int.self) + } + + func testDefaultAdapterProviderForInt64() { + testAdapter(NumericAdapter.self, for: Int64.self) + } + + func testDefaultAdapterProviderForUInt8() { + testAdapter(NumericAdapter.self, for: UInt8.self) + } + + func testDefaultAdapterProviderForUInt16() { + testAdapter(NumericAdapter.self, for: UInt16.self) + } + + func testDefaultAdapterProviderForUInt32() { + testAdapter(NumericAdapter.self, for: UInt32.self) + } + + func testDefaultAdapterProviderForUInt() { + testAdapter(NumericAdapter.self, for: UInt.self) + } + + func testDefaultAdapterProviderForUInt64() { + testAdapter(NumericAdapter.self, for: UInt64.self) + } + + func testDefaultAdapterProviderForBool() { + testAdapter(BoolAdapter.self, for: Bool.self) + } + + func testDefaultAdapterProviderForOptionalBool() { + testAdapter(OptionalBoolAdapter.self, for: Bool?.self) + } + + func testDefaultAdapterProviderForString() { + testAdapter(StringAdapter.self, for: String.self) + } + + private func testAdapter>(_ adapter: A.Type, for type: T.Type) { + let codecAdapter = try? DefaultScaleCodecAdapterProvider().adapter(for: T.self) + XCTAssertNotNil(codecAdapter) + XCTAssertTrue(codecAdapter is A) + } +} diff --git a/Example/Tests/Base/BaseNumericTest.swift b/Example/Tests/Base/BaseNumericTest.swift new file mode 100644 index 0000000..f0f9592 --- /dev/null +++ b/Example/Tests/Base/BaseNumericTest.swift @@ -0,0 +1,27 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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. + * + */ + +@testable import ScaleCodecSwift + +// Base numeric test. All numeric tests are subclasses of this one. +class BaseNumericTest: BaseTest where T: FixedWidthInteger { + override func setUp() { + adapter = NumericAdapter() + testValues = (0.. + * + * 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 XCTest +@testable import ScaleCodecSwift + +// A basic test object. All other tests are the subclasses of this one +class BaseTest: XCTestCase where T: Equatable { + var adapter: ScaleCodecAdapter? + var optionalAdapter: ScaleCodecAdapter? + + var coder: ScaleCoder { + ScaleCoder.default() + } + + var testValues: [T]? + var optionalTestValues: [T?]? { testValues.map { $0 + [nil] } } + + func testAdapter() throws { + // Adapter is not present for Enums and Structs + guard let adapter = adapter else { return } + + guard let testValues = testValues else { + XCTFail("No test values") + return + } + + try testValues.forEach { initialValue in + let encodedValue = try adapter.write(value: initialValue) + let decodedValue = try adapter.read(T.self, from: DataReader(data: encodedValue)) + + if initialValue != decodedValue { + print("Initial: \(initialValue) decoded: \(decodedValue)") + } + XCTAssertEqual(initialValue, decodedValue) + } + } + + func testOptionalAdapter() throws { + guard let adapter = optionalAdapter else { return } + + guard let testValues = optionalTestValues else { + XCTFail("No optional test values") + return + } + + try testValues.forEach { initialValue in + let encodedValue = try adapter.write(value: initialValue) + let decodedValue = try adapter.read(T?.self, from: DataReader(data: encodedValue)) + + if initialValue != decodedValue { + print("Initial: \(initialValue) decoded: \(decodedValue)") + } + XCTAssertEqual(initialValue, decodedValue) + } + } + + func testCoding() throws { + guard let testValues = testValues else { + XCTFail("No test values") + return + } + + try testValues.forEach { initialValue in + let encodedValue = try coder.encoder.encode(initialValue) + let decodedValue = try coder.decoder.decode(T.self, from: encodedValue) + + if initialValue != decodedValue { + print("Initial: \(initialValue) decoded: \(decodedValue)") + } + XCTAssertEqual(initialValue, decodedValue) + } + } + + func testOptionalCoding() throws { + guard let testValues = optionalTestValues else { + XCTFail("No test values") + return + } + + try testValues.forEach { initialValue in + let encodedValue = try coder.encoder.encode(initialValue) + let decodedValue = try coder.decoder.decode(T?.self, from: encodedValue) + + if initialValue != decodedValue { + print("Initial: \(initialValue) decoded: \(decodedValue)") + } + XCTAssertEqual(initialValue, decodedValue) + } + } +} diff --git a/Example/Tests/Base/TestConstants.swift b/Example/Tests/Base/TestConstants.swift new file mode 100644 index 0000000..afe3732 --- /dev/null +++ b/Example/Tests/Base/TestConstants.swift @@ -0,0 +1,23 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +enum TestConstants { + static let testingIterationsCount = 100 +} diff --git a/Example/Tests/BigUIntTests.swift b/Example/Tests/BigUIntTests.swift new file mode 100644 index 0000000..440c480 --- /dev/null +++ b/Example/Tests/BigUIntTests.swift @@ -0,0 +1,62 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 XCTest +@testable import ScaleCodecSwift +import BigInt +import CommonSwift + +class BigUIntTests: BaseTest { + private let predefinedTestCases: [(BigUInt, String)] = [ + (BigUInt("0"), "00"), + (BigUInt("1"), "04"), + (BigUInt("63"), "fc"), + (BigUInt("64"), "0101"), + (BigUInt("255"), "fd03"), + (BigUInt("511"),"fd07"), + (BigUInt("16383"), "fdff"), + (BigUInt("16384"), "02000100"), + (BigUInt("65535"), "feff0300"), + (BigUInt("1073741823"), "feffffff"), + (BigUInt("1073741824"), "0300000040"), + (BigUInt("4592230960395125066"), "134a01e750bae1ba3f") + ] + + override func setUp() { + adapter = BigUIntAdapter(coder: coder) + testValues = predefinedTestCases.map { $0.0 } + } + + func testSpecificValues() throws { + guard let adapter = adapter else { + XCTFail() + return + } + + for (value, hex) in predefinedTestCases { + let encoded = try adapter.write(value: value) + let data = Data(hex: hex) + + if encoded != data { + print("Value: \(value) encoded to \(encoded.hex) expected \(hex)") + } + + XCTAssertEqual(encoded, data) + } + } +} diff --git a/Example/Tests/BoolTests.swift b/Example/Tests/BoolTests.swift new file mode 100644 index 0000000..46e3c02 --- /dev/null +++ b/Example/Tests/BoolTests.swift @@ -0,0 +1,28 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 XCTest +@testable import ScaleCodecSwift + +class BoolTests: BaseTest { + override func setUp() { + adapter = BoolAdapter() + optionalAdapter = OptionalBoolAdapter() + testValues = [true, true, false, true, false] + } +} diff --git a/Example/Tests/DataTests.swift b/Example/Tests/DataTests.swift new file mode 100644 index 0000000..4e3dea8 --- /dev/null +++ b/Example/Tests/DataTests.swift @@ -0,0 +1,28 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 XCTest +@testable import ScaleCodecSwift + +class DataTests: BaseTest { + override func setUp() { + adapter = DataAdapter(coder: coder) + testValues = (0.. + * + * 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 BigInt +import XCTest +@testable import ScaleCodecSwift + +class EnumTests: BaseTest { + override func setUp() { + super.setUp() + + testValues = TestingEnum.allCases + } +} + +extension TestingEnum: CaseIterable { + static var allCases: [TestingEnum] = [ + .simple, + .int8(1), + .optionalInt8(1), + .nilInt8(nil), + .int16(1), + .optionalInt16(1), + .nilInt16(nil), + .int32(1), + .optionalInt32(1), + .nilInt32(nil), + .int(1), + .optionalInt(1), + .nilInt(nil), + .int64(1), + .optionalInt64(1), + .nilInt64(nil), + .uInt8(1), + .optionalUInt8(1), + .nilUInt8(nil), + .uInt16(1), + .optionalUInt16(1), + .nilUInt16(nil), + .uInt32(1), + .optionalUInt32(1), + .nilUInt32(nil), + .uInt(1), + .optionalUInt(1), + .nilUInt(nil), + .uInt64(1), + .optionalUInt64(1), + .nilUInt64(nil), + .bigUInt(BigUInt("1")), + .optionalBigUInt(BigUInt("1")), + .nilBigUInt(nil), + .bool(true), + .optionalBool(true), + .nilBool(nil), + .string(UUID().uuidString), + .optionalString(UUID().uuidString), + .nilString(nil), + .testingStruct(createTestingStruct()), + .optionalTestingStruct(createTestingStruct()), + .nilTestingStruct(nil), + .array([1, 2, 3]), + .optionalArray([1, 2, 3]), + .nilArray(nil) + ] + + private static func createTestingStruct() -> TestingStruct { + .init( + stringValue: "String Value", + optionalStringValue: "Optional String Value", + boolTrueValue: true, + boolFalseValue: false, + optionalBoolValue: false, + int8Value: Int8.random(in: Int8.min...Int8.max), + int8OptionalValue: Int8.random(in: Int8.min...Int8.max), + int16Value: Int16.random(in: Int16.min...Int16.max), + int16OptionalValue: Int16.random(in: Int16.min...Int16.max), + int32Value: Int32.random(in: Int32.min...Int32.max), + int32OptionalValue: Int32.random(in: Int32.min...Int32.max), + intValue: Int.random(in: Int.min...Int.max), + intOptionalValue: Int.random(in: Int.min...Int.max), + int64Value: Int64.random(in: Int64.min...Int64.max), + int64OptionalValue: Int64.random(in: Int64.min...Int64.max), + uInt8Value: UInt8.random(in: UInt8.min...UInt8.max), + uInt8OptionalValue: UInt8.random(in: UInt8.min...UInt8.max), + uInt16Value: UInt16.random(in: UInt16.min...UInt16.max), + uInt16OptionalValue: UInt16.random(in: UInt16.min...UInt16.max), + uInt32Value: UInt32.random(in: UInt32.min...UInt32.max), + uInt32OptionalValue: UInt32.random(in: UInt32.min...UInt32.max), + uIntValue: UInt.random(in: UInt.min...UInt.max), + uIntOptionalValue: UInt.random(in: UInt.min...UInt.max), + uInt64Value: UInt64.random(in: UInt64.min...UInt64.max), + uInt64OptionalValue: UInt64.random(in: UInt64.min...UInt64.max), + bigUIntValue: BigUInt("255"), + bigUIntOptionalValue: BigUInt("255"), + arrayValue: [1, 2, 3], + arrayOptionalValue: [1, 2, 3] + ) + } +} diff --git a/Example/Tests/FixedSizeArrayTests.swift b/Example/Tests/FixedSizeArrayTests.swift new file mode 100644 index 0000000..aca0451 --- /dev/null +++ b/Example/Tests/FixedSizeArrayTests.swift @@ -0,0 +1,3606 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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. + * + */ + +@testable import ScaleCodecSwift +import XCTest + +final class TestFixedSizedArrays: XCTestCase { + func testArray1() throws { + let codec = ScaleCoder.default() + var array1 = Array1(wrappedValue: (0..<1).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array1) + let decoded = try codec.decoder.decode(Array1.self, from: encoded) + XCTAssertEqual(array1.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array1.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array1) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray2() throws { + let codec = ScaleCoder.default() + var array2 = Array2(wrappedValue: (0..<2).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array2) + let decoded = try codec.decoder.decode(Array2.self, from: encoded) + XCTAssertEqual(array2.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array2.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array2) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray3() throws { + let codec = ScaleCoder.default() + var array3 = Array3(wrappedValue: (0..<3).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array3) + let decoded = try codec.decoder.decode(Array3.self, from: encoded) + XCTAssertEqual(array3.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array3.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array3) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray4() throws { + let codec = ScaleCoder.default() + var array4 = Array4(wrappedValue: (0..<4).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array4) + let decoded = try codec.decoder.decode(Array4.self, from: encoded) + XCTAssertEqual(array4.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array4.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array4) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray5() throws { + let codec = ScaleCoder.default() + var array5 = Array5(wrappedValue: (0..<5).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array5) + let decoded = try codec.decoder.decode(Array5.self, from: encoded) + XCTAssertEqual(array5.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array5.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array5) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray6() throws { + let codec = ScaleCoder.default() + var array6 = Array6(wrappedValue: (0..<6).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array6) + let decoded = try codec.decoder.decode(Array6.self, from: encoded) + XCTAssertEqual(array6.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array6.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array6) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray7() throws { + let codec = ScaleCoder.default() + var array7 = Array7(wrappedValue: (0..<7).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array7) + let decoded = try codec.decoder.decode(Array7.self, from: encoded) + XCTAssertEqual(array7.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array7.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array7) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray8() throws { + let codec = ScaleCoder.default() + var array8 = Array8(wrappedValue: (0..<8).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array8) + let decoded = try codec.decoder.decode(Array8.self, from: encoded) + XCTAssertEqual(array8.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array8.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array8) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray9() throws { + let codec = ScaleCoder.default() + var array9 = Array9(wrappedValue: (0..<9).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array9) + let decoded = try codec.decoder.decode(Array9.self, from: encoded) + XCTAssertEqual(array9.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array9.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array9) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray10() throws { + let codec = ScaleCoder.default() + var array10 = Array10(wrappedValue: (0..<10).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array10) + let decoded = try codec.decoder.decode(Array10.self, from: encoded) + XCTAssertEqual(array10.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array10.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array10) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray11() throws { + let codec = ScaleCoder.default() + var array11 = Array11(wrappedValue: (0..<11).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array11) + let decoded = try codec.decoder.decode(Array11.self, from: encoded) + XCTAssertEqual(array11.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array11.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array11) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray12() throws { + let codec = ScaleCoder.default() + var array12 = Array12(wrappedValue: (0..<12).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array12) + let decoded = try codec.decoder.decode(Array12.self, from: encoded) + XCTAssertEqual(array12.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array12.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array12) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray13() throws { + let codec = ScaleCoder.default() + var array13 = Array13(wrappedValue: (0..<13).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array13) + let decoded = try codec.decoder.decode(Array13.self, from: encoded) + XCTAssertEqual(array13.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array13.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array13) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray14() throws { + let codec = ScaleCoder.default() + var array14 = Array14(wrappedValue: (0..<14).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array14) + let decoded = try codec.decoder.decode(Array14.self, from: encoded) + XCTAssertEqual(array14.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array14.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array14) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray15() throws { + let codec = ScaleCoder.default() + var array15 = Array15(wrappedValue: (0..<15).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array15) + let decoded = try codec.decoder.decode(Array15.self, from: encoded) + XCTAssertEqual(array15.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array15.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array15) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray16() throws { + let codec = ScaleCoder.default() + var array16 = Array16(wrappedValue: (0..<16).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array16) + let decoded = try codec.decoder.decode(Array16.self, from: encoded) + XCTAssertEqual(array16.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array16.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array16) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray17() throws { + let codec = ScaleCoder.default() + var array17 = Array17(wrappedValue: (0..<17).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array17) + let decoded = try codec.decoder.decode(Array17.self, from: encoded) + XCTAssertEqual(array17.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array17.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array17) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray18() throws { + let codec = ScaleCoder.default() + var array18 = Array18(wrappedValue: (0..<18).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array18) + let decoded = try codec.decoder.decode(Array18.self, from: encoded) + XCTAssertEqual(array18.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array18.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array18) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray19() throws { + let codec = ScaleCoder.default() + var array19 = Array19(wrappedValue: (0..<19).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array19) + let decoded = try codec.decoder.decode(Array19.self, from: encoded) + XCTAssertEqual(array19.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array19.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array19) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray20() throws { + let codec = ScaleCoder.default() + var array20 = Array20(wrappedValue: (0..<20).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array20) + let decoded = try codec.decoder.decode(Array20.self, from: encoded) + XCTAssertEqual(array20.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array20.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array20) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray21() throws { + let codec = ScaleCoder.default() + var array21 = Array21(wrappedValue: (0..<21).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array21) + let decoded = try codec.decoder.decode(Array21.self, from: encoded) + XCTAssertEqual(array21.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array21.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array21) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray22() throws { + let codec = ScaleCoder.default() + var array22 = Array22(wrappedValue: (0..<22).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array22) + let decoded = try codec.decoder.decode(Array22.self, from: encoded) + XCTAssertEqual(array22.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array22.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array22) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray23() throws { + let codec = ScaleCoder.default() + var array23 = Array23(wrappedValue: (0..<23).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array23) + let decoded = try codec.decoder.decode(Array23.self, from: encoded) + XCTAssertEqual(array23.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array23.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array23) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray24() throws { + let codec = ScaleCoder.default() + var array24 = Array24(wrappedValue: (0..<24).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array24) + let decoded = try codec.decoder.decode(Array24.self, from: encoded) + XCTAssertEqual(array24.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array24.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array24) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray25() throws { + let codec = ScaleCoder.default() + var array25 = Array25(wrappedValue: (0..<25).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array25) + let decoded = try codec.decoder.decode(Array25.self, from: encoded) + XCTAssertEqual(array25.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array25.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array25) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray26() throws { + let codec = ScaleCoder.default() + var array26 = Array26(wrappedValue: (0..<26).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array26) + let decoded = try codec.decoder.decode(Array26.self, from: encoded) + XCTAssertEqual(array26.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array26.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array26) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray27() throws { + let codec = ScaleCoder.default() + var array27 = Array27(wrappedValue: (0..<27).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array27) + let decoded = try codec.decoder.decode(Array27.self, from: encoded) + XCTAssertEqual(array27.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array27.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array27) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray28() throws { + let codec = ScaleCoder.default() + var array28 = Array28(wrappedValue: (0..<28).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array28) + let decoded = try codec.decoder.decode(Array28.self, from: encoded) + XCTAssertEqual(array28.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array28.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array28) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray29() throws { + let codec = ScaleCoder.default() + var array29 = Array29(wrappedValue: (0..<29).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array29) + let decoded = try codec.decoder.decode(Array29.self, from: encoded) + XCTAssertEqual(array29.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array29.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array29) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray30() throws { + let codec = ScaleCoder.default() + var array30 = Array30(wrappedValue: (0..<30).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array30) + let decoded = try codec.decoder.decode(Array30.self, from: encoded) + XCTAssertEqual(array30.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array30.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array30) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray31() throws { + let codec = ScaleCoder.default() + var array31 = Array31(wrappedValue: (0..<31).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array31) + let decoded = try codec.decoder.decode(Array31.self, from: encoded) + XCTAssertEqual(array31.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array31.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array31) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray32() throws { + let codec = ScaleCoder.default() + var array32 = Array32(wrappedValue: (0..<32).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array32) + let decoded = try codec.decoder.decode(Array32.self, from: encoded) + XCTAssertEqual(array32.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array32.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array32) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray33() throws { + let codec = ScaleCoder.default() + var array33 = Array33(wrappedValue: (0..<33).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array33) + let decoded = try codec.decoder.decode(Array33.self, from: encoded) + XCTAssertEqual(array33.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array33.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array33) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray34() throws { + let codec = ScaleCoder.default() + var array34 = Array34(wrappedValue: (0..<34).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array34) + let decoded = try codec.decoder.decode(Array34.self, from: encoded) + XCTAssertEqual(array34.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array34.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array34) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray35() throws { + let codec = ScaleCoder.default() + var array35 = Array35(wrappedValue: (0..<35).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array35) + let decoded = try codec.decoder.decode(Array35.self, from: encoded) + XCTAssertEqual(array35.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array35.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array35) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray36() throws { + let codec = ScaleCoder.default() + var array36 = Array36(wrappedValue: (0..<36).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array36) + let decoded = try codec.decoder.decode(Array36.self, from: encoded) + XCTAssertEqual(array36.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array36.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array36) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray37() throws { + let codec = ScaleCoder.default() + var array37 = Array37(wrappedValue: (0..<37).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array37) + let decoded = try codec.decoder.decode(Array37.self, from: encoded) + XCTAssertEqual(array37.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array37.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array37) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray38() throws { + let codec = ScaleCoder.default() + var array38 = Array38(wrappedValue: (0..<38).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array38) + let decoded = try codec.decoder.decode(Array38.self, from: encoded) + XCTAssertEqual(array38.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array38.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array38) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray39() throws { + let codec = ScaleCoder.default() + var array39 = Array39(wrappedValue: (0..<39).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array39) + let decoded = try codec.decoder.decode(Array39.self, from: encoded) + XCTAssertEqual(array39.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array39.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array39) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray40() throws { + let codec = ScaleCoder.default() + var array40 = Array40(wrappedValue: (0..<40).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array40) + let decoded = try codec.decoder.decode(Array40.self, from: encoded) + XCTAssertEqual(array40.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array40.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array40) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray41() throws { + let codec = ScaleCoder.default() + var array41 = Array41(wrappedValue: (0..<41).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array41) + let decoded = try codec.decoder.decode(Array41.self, from: encoded) + XCTAssertEqual(array41.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array41.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array41) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray42() throws { + let codec = ScaleCoder.default() + var array42 = Array42(wrappedValue: (0..<42).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array42) + let decoded = try codec.decoder.decode(Array42.self, from: encoded) + XCTAssertEqual(array42.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array42.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array42) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray43() throws { + let codec = ScaleCoder.default() + var array43 = Array43(wrappedValue: (0..<43).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array43) + let decoded = try codec.decoder.decode(Array43.self, from: encoded) + XCTAssertEqual(array43.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array43.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array43) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray44() throws { + let codec = ScaleCoder.default() + var array44 = Array44(wrappedValue: (0..<44).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array44) + let decoded = try codec.decoder.decode(Array44.self, from: encoded) + XCTAssertEqual(array44.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array44.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array44) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray45() throws { + let codec = ScaleCoder.default() + var array45 = Array45(wrappedValue: (0..<45).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array45) + let decoded = try codec.decoder.decode(Array45.self, from: encoded) + XCTAssertEqual(array45.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array45.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array45) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray46() throws { + let codec = ScaleCoder.default() + var array46 = Array46(wrappedValue: (0..<46).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array46) + let decoded = try codec.decoder.decode(Array46.self, from: encoded) + XCTAssertEqual(array46.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array46.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array46) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray47() throws { + let codec = ScaleCoder.default() + var array47 = Array47(wrappedValue: (0..<47).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array47) + let decoded = try codec.decoder.decode(Array47.self, from: encoded) + XCTAssertEqual(array47.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array47.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array47) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray48() throws { + let codec = ScaleCoder.default() + var array48 = Array48(wrappedValue: (0..<48).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array48) + let decoded = try codec.decoder.decode(Array48.self, from: encoded) + XCTAssertEqual(array48.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array48.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array48) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray49() throws { + let codec = ScaleCoder.default() + var array49 = Array49(wrappedValue: (0..<49).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array49) + let decoded = try codec.decoder.decode(Array49.self, from: encoded) + XCTAssertEqual(array49.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array49.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array49) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray50() throws { + let codec = ScaleCoder.default() + var array50 = Array50(wrappedValue: (0..<50).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array50) + let decoded = try codec.decoder.decode(Array50.self, from: encoded) + XCTAssertEqual(array50.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array50.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array50) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray51() throws { + let codec = ScaleCoder.default() + var array51 = Array51(wrappedValue: (0..<51).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array51) + let decoded = try codec.decoder.decode(Array51.self, from: encoded) + XCTAssertEqual(array51.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array51.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array51) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray52() throws { + let codec = ScaleCoder.default() + var array52 = Array52(wrappedValue: (0..<52).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array52) + let decoded = try codec.decoder.decode(Array52.self, from: encoded) + XCTAssertEqual(array52.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array52.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array52) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray53() throws { + let codec = ScaleCoder.default() + var array53 = Array53(wrappedValue: (0..<53).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array53) + let decoded = try codec.decoder.decode(Array53.self, from: encoded) + XCTAssertEqual(array53.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array53.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array53) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray54() throws { + let codec = ScaleCoder.default() + var array54 = Array54(wrappedValue: (0..<54).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array54) + let decoded = try codec.decoder.decode(Array54.self, from: encoded) + XCTAssertEqual(array54.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array54.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array54) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray55() throws { + let codec = ScaleCoder.default() + var array55 = Array55(wrappedValue: (0..<55).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array55) + let decoded = try codec.decoder.decode(Array55.self, from: encoded) + XCTAssertEqual(array55.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array55.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array55) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray56() throws { + let codec = ScaleCoder.default() + var array56 = Array56(wrappedValue: (0..<56).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array56) + let decoded = try codec.decoder.decode(Array56.self, from: encoded) + XCTAssertEqual(array56.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array56.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array56) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray57() throws { + let codec = ScaleCoder.default() + var array57 = Array57(wrappedValue: (0..<57).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array57) + let decoded = try codec.decoder.decode(Array57.self, from: encoded) + XCTAssertEqual(array57.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array57.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array57) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray58() throws { + let codec = ScaleCoder.default() + var array58 = Array58(wrappedValue: (0..<58).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array58) + let decoded = try codec.decoder.decode(Array58.self, from: encoded) + XCTAssertEqual(array58.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array58.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array58) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray59() throws { + let codec = ScaleCoder.default() + var array59 = Array59(wrappedValue: (0..<59).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array59) + let decoded = try codec.decoder.decode(Array59.self, from: encoded) + XCTAssertEqual(array59.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array59.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array59) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray60() throws { + let codec = ScaleCoder.default() + var array60 = Array60(wrappedValue: (0..<60).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array60) + let decoded = try codec.decoder.decode(Array60.self, from: encoded) + XCTAssertEqual(array60.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array60.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array60) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray61() throws { + let codec = ScaleCoder.default() + var array61 = Array61(wrappedValue: (0..<61).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array61) + let decoded = try codec.decoder.decode(Array61.self, from: encoded) + XCTAssertEqual(array61.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array61.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array61) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray62() throws { + let codec = ScaleCoder.default() + var array62 = Array62(wrappedValue: (0..<62).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array62) + let decoded = try codec.decoder.decode(Array62.self, from: encoded) + XCTAssertEqual(array62.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array62.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array62) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray63() throws { + let codec = ScaleCoder.default() + var array63 = Array63(wrappedValue: (0..<63).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array63) + let decoded = try codec.decoder.decode(Array63.self, from: encoded) + XCTAssertEqual(array63.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array63.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array63) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray64() throws { + let codec = ScaleCoder.default() + var array64 = Array64(wrappedValue: (0..<64).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array64) + let decoded = try codec.decoder.decode(Array64.self, from: encoded) + XCTAssertEqual(array64.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array64.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array64) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray65() throws { + let codec = ScaleCoder.default() + var array65 = Array65(wrappedValue: (0..<65).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array65) + let decoded = try codec.decoder.decode(Array65.self, from: encoded) + XCTAssertEqual(array65.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array65.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array65) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray66() throws { + let codec = ScaleCoder.default() + var array66 = Array66(wrappedValue: (0..<66).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array66) + let decoded = try codec.decoder.decode(Array66.self, from: encoded) + XCTAssertEqual(array66.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array66.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array66) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray67() throws { + let codec = ScaleCoder.default() + var array67 = Array67(wrappedValue: (0..<67).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array67) + let decoded = try codec.decoder.decode(Array67.self, from: encoded) + XCTAssertEqual(array67.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array67.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array67) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray68() throws { + let codec = ScaleCoder.default() + var array68 = Array68(wrappedValue: (0..<68).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array68) + let decoded = try codec.decoder.decode(Array68.self, from: encoded) + XCTAssertEqual(array68.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array68.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array68) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray69() throws { + let codec = ScaleCoder.default() + var array69 = Array69(wrappedValue: (0..<69).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array69) + let decoded = try codec.decoder.decode(Array69.self, from: encoded) + XCTAssertEqual(array69.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array69.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array69) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray70() throws { + let codec = ScaleCoder.default() + var array70 = Array70(wrappedValue: (0..<70).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array70) + let decoded = try codec.decoder.decode(Array70.self, from: encoded) + XCTAssertEqual(array70.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array70.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array70) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray71() throws { + let codec = ScaleCoder.default() + var array71 = Array71(wrappedValue: (0..<71).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array71) + let decoded = try codec.decoder.decode(Array71.self, from: encoded) + XCTAssertEqual(array71.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array71.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array71) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray72() throws { + let codec = ScaleCoder.default() + var array72 = Array72(wrappedValue: (0..<72).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array72) + let decoded = try codec.decoder.decode(Array72.self, from: encoded) + XCTAssertEqual(array72.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array72.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array72) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray73() throws { + let codec = ScaleCoder.default() + var array73 = Array73(wrappedValue: (0..<73).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array73) + let decoded = try codec.decoder.decode(Array73.self, from: encoded) + XCTAssertEqual(array73.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array73.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array73) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray74() throws { + let codec = ScaleCoder.default() + var array74 = Array74(wrappedValue: (0..<74).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array74) + let decoded = try codec.decoder.decode(Array74.self, from: encoded) + XCTAssertEqual(array74.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array74.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array74) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray75() throws { + let codec = ScaleCoder.default() + var array75 = Array75(wrappedValue: (0..<75).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array75) + let decoded = try codec.decoder.decode(Array75.self, from: encoded) + XCTAssertEqual(array75.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array75.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array75) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray76() throws { + let codec = ScaleCoder.default() + var array76 = Array76(wrappedValue: (0..<76).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array76) + let decoded = try codec.decoder.decode(Array76.self, from: encoded) + XCTAssertEqual(array76.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array76.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array76) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray77() throws { + let codec = ScaleCoder.default() + var array77 = Array77(wrappedValue: (0..<77).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array77) + let decoded = try codec.decoder.decode(Array77.self, from: encoded) + XCTAssertEqual(array77.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array77.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array77) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray78() throws { + let codec = ScaleCoder.default() + var array78 = Array78(wrappedValue: (0..<78).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array78) + let decoded = try codec.decoder.decode(Array78.self, from: encoded) + XCTAssertEqual(array78.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array78.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array78) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray79() throws { + let codec = ScaleCoder.default() + var array79 = Array79(wrappedValue: (0..<79).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array79) + let decoded = try codec.decoder.decode(Array79.self, from: encoded) + XCTAssertEqual(array79.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array79.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array79) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray80() throws { + let codec = ScaleCoder.default() + var array80 = Array80(wrappedValue: (0..<80).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array80) + let decoded = try codec.decoder.decode(Array80.self, from: encoded) + XCTAssertEqual(array80.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array80.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array80) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray81() throws { + let codec = ScaleCoder.default() + var array81 = Array81(wrappedValue: (0..<81).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array81) + let decoded = try codec.decoder.decode(Array81.self, from: encoded) + XCTAssertEqual(array81.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array81.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array81) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray82() throws { + let codec = ScaleCoder.default() + var array82 = Array82(wrappedValue: (0..<82).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array82) + let decoded = try codec.decoder.decode(Array82.self, from: encoded) + XCTAssertEqual(array82.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array82.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array82) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray83() throws { + let codec = ScaleCoder.default() + var array83 = Array83(wrappedValue: (0..<83).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array83) + let decoded = try codec.decoder.decode(Array83.self, from: encoded) + XCTAssertEqual(array83.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array83.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array83) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray84() throws { + let codec = ScaleCoder.default() + var array84 = Array84(wrappedValue: (0..<84).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array84) + let decoded = try codec.decoder.decode(Array84.self, from: encoded) + XCTAssertEqual(array84.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array84.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array84) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray85() throws { + let codec = ScaleCoder.default() + var array85 = Array85(wrappedValue: (0..<85).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array85) + let decoded = try codec.decoder.decode(Array85.self, from: encoded) + XCTAssertEqual(array85.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array85.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array85) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray86() throws { + let codec = ScaleCoder.default() + var array86 = Array86(wrappedValue: (0..<86).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array86) + let decoded = try codec.decoder.decode(Array86.self, from: encoded) + XCTAssertEqual(array86.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array86.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array86) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray87() throws { + let codec = ScaleCoder.default() + var array87 = Array87(wrappedValue: (0..<87).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array87) + let decoded = try codec.decoder.decode(Array87.self, from: encoded) + XCTAssertEqual(array87.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array87.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array87) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray88() throws { + let codec = ScaleCoder.default() + var array88 = Array88(wrappedValue: (0..<88).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array88) + let decoded = try codec.decoder.decode(Array88.self, from: encoded) + XCTAssertEqual(array88.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array88.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array88) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray89() throws { + let codec = ScaleCoder.default() + var array89 = Array89(wrappedValue: (0..<89).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array89) + let decoded = try codec.decoder.decode(Array89.self, from: encoded) + XCTAssertEqual(array89.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array89.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array89) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray90() throws { + let codec = ScaleCoder.default() + var array90 = Array90(wrappedValue: (0..<90).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array90) + let decoded = try codec.decoder.decode(Array90.self, from: encoded) + XCTAssertEqual(array90.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array90.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array90) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray91() throws { + let codec = ScaleCoder.default() + var array91 = Array91(wrappedValue: (0..<91).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array91) + let decoded = try codec.decoder.decode(Array91.self, from: encoded) + XCTAssertEqual(array91.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array91.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array91) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray92() throws { + let codec = ScaleCoder.default() + var array92 = Array92(wrappedValue: (0..<92).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array92) + let decoded = try codec.decoder.decode(Array92.self, from: encoded) + XCTAssertEqual(array92.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array92.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array92) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray93() throws { + let codec = ScaleCoder.default() + var array93 = Array93(wrappedValue: (0..<93).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array93) + let decoded = try codec.decoder.decode(Array93.self, from: encoded) + XCTAssertEqual(array93.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array93.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array93) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray94() throws { + let codec = ScaleCoder.default() + var array94 = Array94(wrappedValue: (0..<94).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array94) + let decoded = try codec.decoder.decode(Array94.self, from: encoded) + XCTAssertEqual(array94.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array94.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array94) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray95() throws { + let codec = ScaleCoder.default() + var array95 = Array95(wrappedValue: (0..<95).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array95) + let decoded = try codec.decoder.decode(Array95.self, from: encoded) + XCTAssertEqual(array95.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array95.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array95) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray96() throws { + let codec = ScaleCoder.default() + var array96 = Array96(wrappedValue: (0..<96).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array96) + let decoded = try codec.decoder.decode(Array96.self, from: encoded) + XCTAssertEqual(array96.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array96.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array96) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray97() throws { + let codec = ScaleCoder.default() + var array97 = Array97(wrappedValue: (0..<97).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array97) + let decoded = try codec.decoder.decode(Array97.self, from: encoded) + XCTAssertEqual(array97.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array97.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array97) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray98() throws { + let codec = ScaleCoder.default() + var array98 = Array98(wrappedValue: (0..<98).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array98) + let decoded = try codec.decoder.decode(Array98.self, from: encoded) + XCTAssertEqual(array98.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array98.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array98) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray99() throws { + let codec = ScaleCoder.default() + var array99 = Array99(wrappedValue: (0..<99).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array99) + let decoded = try codec.decoder.decode(Array99.self, from: encoded) + XCTAssertEqual(array99.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array99.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array99) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray100() throws { + let codec = ScaleCoder.default() + var array100 = Array100(wrappedValue: (0..<100).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array100) + let decoded = try codec.decoder.decode(Array100.self, from: encoded) + XCTAssertEqual(array100.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array100.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array100) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray101() throws { + let codec = ScaleCoder.default() + var array101 = Array101(wrappedValue: (0..<101).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array101) + let decoded = try codec.decoder.decode(Array101.self, from: encoded) + XCTAssertEqual(array101.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array101.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array101) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray102() throws { + let codec = ScaleCoder.default() + var array102 = Array102(wrappedValue: (0..<102).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array102) + let decoded = try codec.decoder.decode(Array102.self, from: encoded) + XCTAssertEqual(array102.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array102.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array102) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray103() throws { + let codec = ScaleCoder.default() + var array103 = Array103(wrappedValue: (0..<103).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array103) + let decoded = try codec.decoder.decode(Array103.self, from: encoded) + XCTAssertEqual(array103.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array103.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array103) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray104() throws { + let codec = ScaleCoder.default() + var array104 = Array104(wrappedValue: (0..<104).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array104) + let decoded = try codec.decoder.decode(Array104.self, from: encoded) + XCTAssertEqual(array104.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array104.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array104) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray105() throws { + let codec = ScaleCoder.default() + var array105 = Array105(wrappedValue: (0..<105).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array105) + let decoded = try codec.decoder.decode(Array105.self, from: encoded) + XCTAssertEqual(array105.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array105.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array105) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray106() throws { + let codec = ScaleCoder.default() + var array106 = Array106(wrappedValue: (0..<106).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array106) + let decoded = try codec.decoder.decode(Array106.self, from: encoded) + XCTAssertEqual(array106.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array106.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array106) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray107() throws { + let codec = ScaleCoder.default() + var array107 = Array107(wrappedValue: (0..<107).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array107) + let decoded = try codec.decoder.decode(Array107.self, from: encoded) + XCTAssertEqual(array107.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array107.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array107) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray108() throws { + let codec = ScaleCoder.default() + var array108 = Array108(wrappedValue: (0..<108).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array108) + let decoded = try codec.decoder.decode(Array108.self, from: encoded) + XCTAssertEqual(array108.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array108.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array108) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray109() throws { + let codec = ScaleCoder.default() + var array109 = Array109(wrappedValue: (0..<109).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array109) + let decoded = try codec.decoder.decode(Array109.self, from: encoded) + XCTAssertEqual(array109.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array109.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array109) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray110() throws { + let codec = ScaleCoder.default() + var array110 = Array110(wrappedValue: (0..<110).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array110) + let decoded = try codec.decoder.decode(Array110.self, from: encoded) + XCTAssertEqual(array110.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array110.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array110) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray111() throws { + let codec = ScaleCoder.default() + var array111 = Array111(wrappedValue: (0..<111).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array111) + let decoded = try codec.decoder.decode(Array111.self, from: encoded) + XCTAssertEqual(array111.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array111.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array111) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray112() throws { + let codec = ScaleCoder.default() + var array112 = Array112(wrappedValue: (0..<112).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array112) + let decoded = try codec.decoder.decode(Array112.self, from: encoded) + XCTAssertEqual(array112.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array112.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array112) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray113() throws { + let codec = ScaleCoder.default() + var array113 = Array113(wrappedValue: (0..<113).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array113) + let decoded = try codec.decoder.decode(Array113.self, from: encoded) + XCTAssertEqual(array113.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array113.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array113) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray114() throws { + let codec = ScaleCoder.default() + var array114 = Array114(wrappedValue: (0..<114).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array114) + let decoded = try codec.decoder.decode(Array114.self, from: encoded) + XCTAssertEqual(array114.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array114.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array114) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray115() throws { + let codec = ScaleCoder.default() + var array115 = Array115(wrappedValue: (0..<115).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array115) + let decoded = try codec.decoder.decode(Array115.self, from: encoded) + XCTAssertEqual(array115.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array115.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array115) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray116() throws { + let codec = ScaleCoder.default() + var array116 = Array116(wrappedValue: (0..<116).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array116) + let decoded = try codec.decoder.decode(Array116.self, from: encoded) + XCTAssertEqual(array116.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array116.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array116) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray117() throws { + let codec = ScaleCoder.default() + var array117 = Array117(wrappedValue: (0..<117).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array117) + let decoded = try codec.decoder.decode(Array117.self, from: encoded) + XCTAssertEqual(array117.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array117.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array117) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray118() throws { + let codec = ScaleCoder.default() + var array118 = Array118(wrappedValue: (0..<118).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array118) + let decoded = try codec.decoder.decode(Array118.self, from: encoded) + XCTAssertEqual(array118.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array118.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array118) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray119() throws { + let codec = ScaleCoder.default() + var array119 = Array119(wrappedValue: (0..<119).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array119) + let decoded = try codec.decoder.decode(Array119.self, from: encoded) + XCTAssertEqual(array119.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array119.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array119) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray120() throws { + let codec = ScaleCoder.default() + var array120 = Array120(wrappedValue: (0..<120).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array120) + let decoded = try codec.decoder.decode(Array120.self, from: encoded) + XCTAssertEqual(array120.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array120.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array120) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray121() throws { + let codec = ScaleCoder.default() + var array121 = Array121(wrappedValue: (0..<121).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array121) + let decoded = try codec.decoder.decode(Array121.self, from: encoded) + XCTAssertEqual(array121.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array121.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array121) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray122() throws { + let codec = ScaleCoder.default() + var array122 = Array122(wrappedValue: (0..<122).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array122) + let decoded = try codec.decoder.decode(Array122.self, from: encoded) + XCTAssertEqual(array122.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array122.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array122) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray123() throws { + let codec = ScaleCoder.default() + var array123 = Array123(wrappedValue: (0..<123).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array123) + let decoded = try codec.decoder.decode(Array123.self, from: encoded) + XCTAssertEqual(array123.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array123.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array123) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray124() throws { + let codec = ScaleCoder.default() + var array124 = Array124(wrappedValue: (0..<124).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array124) + let decoded = try codec.decoder.decode(Array124.self, from: encoded) + XCTAssertEqual(array124.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array124.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array124) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray125() throws { + let codec = ScaleCoder.default() + var array125 = Array125(wrappedValue: (0..<125).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array125) + let decoded = try codec.decoder.decode(Array125.self, from: encoded) + XCTAssertEqual(array125.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array125.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array125) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray126() throws { + let codec = ScaleCoder.default() + var array126 = Array126(wrappedValue: (0..<126).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array126) + let decoded = try codec.decoder.decode(Array126.self, from: encoded) + XCTAssertEqual(array126.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array126.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array126) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray127() throws { + let codec = ScaleCoder.default() + var array127 = Array127(wrappedValue: (0..<127).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array127) + let decoded = try codec.decoder.decode(Array127.self, from: encoded) + XCTAssertEqual(array127.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array127.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array127) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray128() throws { + let codec = ScaleCoder.default() + var array128 = Array128(wrappedValue: (0..<128).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array128) + let decoded = try codec.decoder.decode(Array128.self, from: encoded) + XCTAssertEqual(array128.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array128.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array128) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray129() throws { + let codec = ScaleCoder.default() + var array129 = Array129(wrappedValue: (0..<129).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array129) + let decoded = try codec.decoder.decode(Array129.self, from: encoded) + XCTAssertEqual(array129.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array129.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array129) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray130() throws { + let codec = ScaleCoder.default() + var array130 = Array130(wrappedValue: (0..<130).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array130) + let decoded = try codec.decoder.decode(Array130.self, from: encoded) + XCTAssertEqual(array130.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array130.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array130) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray131() throws { + let codec = ScaleCoder.default() + var array131 = Array131(wrappedValue: (0..<131).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array131) + let decoded = try codec.decoder.decode(Array131.self, from: encoded) + XCTAssertEqual(array131.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array131.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array131) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray132() throws { + let codec = ScaleCoder.default() + var array132 = Array132(wrappedValue: (0..<132).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array132) + let decoded = try codec.decoder.decode(Array132.self, from: encoded) + XCTAssertEqual(array132.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array132.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array132) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray133() throws { + let codec = ScaleCoder.default() + var array133 = Array133(wrappedValue: (0..<133).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array133) + let decoded = try codec.decoder.decode(Array133.self, from: encoded) + XCTAssertEqual(array133.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array133.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array133) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray134() throws { + let codec = ScaleCoder.default() + var array134 = Array134(wrappedValue: (0..<134).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array134) + let decoded = try codec.decoder.decode(Array134.self, from: encoded) + XCTAssertEqual(array134.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array134.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array134) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray135() throws { + let codec = ScaleCoder.default() + var array135 = Array135(wrappedValue: (0..<135).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array135) + let decoded = try codec.decoder.decode(Array135.self, from: encoded) + XCTAssertEqual(array135.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array135.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array135) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray136() throws { + let codec = ScaleCoder.default() + var array136 = Array136(wrappedValue: (0..<136).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array136) + let decoded = try codec.decoder.decode(Array136.self, from: encoded) + XCTAssertEqual(array136.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array136.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array136) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray137() throws { + let codec = ScaleCoder.default() + var array137 = Array137(wrappedValue: (0..<137).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array137) + let decoded = try codec.decoder.decode(Array137.self, from: encoded) + XCTAssertEqual(array137.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array137.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array137) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray138() throws { + let codec = ScaleCoder.default() + var array138 = Array138(wrappedValue: (0..<138).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array138) + let decoded = try codec.decoder.decode(Array138.self, from: encoded) + XCTAssertEqual(array138.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array138.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array138) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray139() throws { + let codec = ScaleCoder.default() + var array139 = Array139(wrappedValue: (0..<139).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array139) + let decoded = try codec.decoder.decode(Array139.self, from: encoded) + XCTAssertEqual(array139.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array139.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array139) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray140() throws { + let codec = ScaleCoder.default() + var array140 = Array140(wrappedValue: (0..<140).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array140) + let decoded = try codec.decoder.decode(Array140.self, from: encoded) + XCTAssertEqual(array140.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array140.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array140) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray141() throws { + let codec = ScaleCoder.default() + var array141 = Array141(wrappedValue: (0..<141).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array141) + let decoded = try codec.decoder.decode(Array141.self, from: encoded) + XCTAssertEqual(array141.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array141.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array141) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray142() throws { + let codec = ScaleCoder.default() + var array142 = Array142(wrappedValue: (0..<142).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array142) + let decoded = try codec.decoder.decode(Array142.self, from: encoded) + XCTAssertEqual(array142.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array142.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array142) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray143() throws { + let codec = ScaleCoder.default() + var array143 = Array143(wrappedValue: (0..<143).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array143) + let decoded = try codec.decoder.decode(Array143.self, from: encoded) + XCTAssertEqual(array143.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array143.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array143) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray144() throws { + let codec = ScaleCoder.default() + var array144 = Array144(wrappedValue: (0..<144).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array144) + let decoded = try codec.decoder.decode(Array144.self, from: encoded) + XCTAssertEqual(array144.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array144.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array144) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray145() throws { + let codec = ScaleCoder.default() + var array145 = Array145(wrappedValue: (0..<145).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array145) + let decoded = try codec.decoder.decode(Array145.self, from: encoded) + XCTAssertEqual(array145.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array145.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array145) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray146() throws { + let codec = ScaleCoder.default() + var array146 = Array146(wrappedValue: (0..<146).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array146) + let decoded = try codec.decoder.decode(Array146.self, from: encoded) + XCTAssertEqual(array146.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array146.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array146) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray147() throws { + let codec = ScaleCoder.default() + var array147 = Array147(wrappedValue: (0..<147).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array147) + let decoded = try codec.decoder.decode(Array147.self, from: encoded) + XCTAssertEqual(array147.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array147.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array147) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray148() throws { + let codec = ScaleCoder.default() + var array148 = Array148(wrappedValue: (0..<148).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array148) + let decoded = try codec.decoder.decode(Array148.self, from: encoded) + XCTAssertEqual(array148.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array148.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array148) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray149() throws { + let codec = ScaleCoder.default() + var array149 = Array149(wrappedValue: (0..<149).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array149) + let decoded = try codec.decoder.decode(Array149.self, from: encoded) + XCTAssertEqual(array149.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array149.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array149) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray150() throws { + let codec = ScaleCoder.default() + var array150 = Array150(wrappedValue: (0..<150).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array150) + let decoded = try codec.decoder.decode(Array150.self, from: encoded) + XCTAssertEqual(array150.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array150.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array150) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray151() throws { + let codec = ScaleCoder.default() + var array151 = Array151(wrappedValue: (0..<151).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array151) + let decoded = try codec.decoder.decode(Array151.self, from: encoded) + XCTAssertEqual(array151.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array151.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array151) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray152() throws { + let codec = ScaleCoder.default() + var array152 = Array152(wrappedValue: (0..<152).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array152) + let decoded = try codec.decoder.decode(Array152.self, from: encoded) + XCTAssertEqual(array152.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array152.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array152) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray153() throws { + let codec = ScaleCoder.default() + var array153 = Array153(wrappedValue: (0..<153).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array153) + let decoded = try codec.decoder.decode(Array153.self, from: encoded) + XCTAssertEqual(array153.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array153.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array153) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray154() throws { + let codec = ScaleCoder.default() + var array154 = Array154(wrappedValue: (0..<154).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array154) + let decoded = try codec.decoder.decode(Array154.self, from: encoded) + XCTAssertEqual(array154.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array154.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array154) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray155() throws { + let codec = ScaleCoder.default() + var array155 = Array155(wrappedValue: (0..<155).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array155) + let decoded = try codec.decoder.decode(Array155.self, from: encoded) + XCTAssertEqual(array155.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array155.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array155) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray156() throws { + let codec = ScaleCoder.default() + var array156 = Array156(wrappedValue: (0..<156).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array156) + let decoded = try codec.decoder.decode(Array156.self, from: encoded) + XCTAssertEqual(array156.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array156.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array156) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray157() throws { + let codec = ScaleCoder.default() + var array157 = Array157(wrappedValue: (0..<157).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array157) + let decoded = try codec.decoder.decode(Array157.self, from: encoded) + XCTAssertEqual(array157.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array157.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array157) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray158() throws { + let codec = ScaleCoder.default() + var array158 = Array158(wrappedValue: (0..<158).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array158) + let decoded = try codec.decoder.decode(Array158.self, from: encoded) + XCTAssertEqual(array158.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array158.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array158) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray159() throws { + let codec = ScaleCoder.default() + var array159 = Array159(wrappedValue: (0..<159).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array159) + let decoded = try codec.decoder.decode(Array159.self, from: encoded) + XCTAssertEqual(array159.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array159.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array159) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray160() throws { + let codec = ScaleCoder.default() + var array160 = Array160(wrappedValue: (0..<160).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array160) + let decoded = try codec.decoder.decode(Array160.self, from: encoded) + XCTAssertEqual(array160.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array160.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array160) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray161() throws { + let codec = ScaleCoder.default() + var array161 = Array161(wrappedValue: (0..<161).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array161) + let decoded = try codec.decoder.decode(Array161.self, from: encoded) + XCTAssertEqual(array161.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array161.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array161) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray162() throws { + let codec = ScaleCoder.default() + var array162 = Array162(wrappedValue: (0..<162).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array162) + let decoded = try codec.decoder.decode(Array162.self, from: encoded) + XCTAssertEqual(array162.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array162.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array162) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray163() throws { + let codec = ScaleCoder.default() + var array163 = Array163(wrappedValue: (0..<163).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array163) + let decoded = try codec.decoder.decode(Array163.self, from: encoded) + XCTAssertEqual(array163.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array163.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array163) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray164() throws { + let codec = ScaleCoder.default() + var array164 = Array164(wrappedValue: (0..<164).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array164) + let decoded = try codec.decoder.decode(Array164.self, from: encoded) + XCTAssertEqual(array164.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array164.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array164) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray165() throws { + let codec = ScaleCoder.default() + var array165 = Array165(wrappedValue: (0..<165).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array165) + let decoded = try codec.decoder.decode(Array165.self, from: encoded) + XCTAssertEqual(array165.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array165.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array165) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray166() throws { + let codec = ScaleCoder.default() + var array166 = Array166(wrappedValue: (0..<166).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array166) + let decoded = try codec.decoder.decode(Array166.self, from: encoded) + XCTAssertEqual(array166.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array166.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array166) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray167() throws { + let codec = ScaleCoder.default() + var array167 = Array167(wrappedValue: (0..<167).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array167) + let decoded = try codec.decoder.decode(Array167.self, from: encoded) + XCTAssertEqual(array167.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array167.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array167) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray168() throws { + let codec = ScaleCoder.default() + var array168 = Array168(wrappedValue: (0..<168).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array168) + let decoded = try codec.decoder.decode(Array168.self, from: encoded) + XCTAssertEqual(array168.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array168.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array168) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray169() throws { + let codec = ScaleCoder.default() + var array169 = Array169(wrappedValue: (0..<169).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array169) + let decoded = try codec.decoder.decode(Array169.self, from: encoded) + XCTAssertEqual(array169.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array169.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array169) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray170() throws { + let codec = ScaleCoder.default() + var array170 = Array170(wrappedValue: (0..<170).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array170) + let decoded = try codec.decoder.decode(Array170.self, from: encoded) + XCTAssertEqual(array170.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array170.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array170) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray171() throws { + let codec = ScaleCoder.default() + var array171 = Array171(wrappedValue: (0..<171).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array171) + let decoded = try codec.decoder.decode(Array171.self, from: encoded) + XCTAssertEqual(array171.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array171.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array171) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray172() throws { + let codec = ScaleCoder.default() + var array172 = Array172(wrappedValue: (0..<172).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array172) + let decoded = try codec.decoder.decode(Array172.self, from: encoded) + XCTAssertEqual(array172.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array172.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array172) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray173() throws { + let codec = ScaleCoder.default() + var array173 = Array173(wrappedValue: (0..<173).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array173) + let decoded = try codec.decoder.decode(Array173.self, from: encoded) + XCTAssertEqual(array173.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array173.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array173) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray174() throws { + let codec = ScaleCoder.default() + var array174 = Array174(wrappedValue: (0..<174).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array174) + let decoded = try codec.decoder.decode(Array174.self, from: encoded) + XCTAssertEqual(array174.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array174.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array174) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray175() throws { + let codec = ScaleCoder.default() + var array175 = Array175(wrappedValue: (0..<175).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array175) + let decoded = try codec.decoder.decode(Array175.self, from: encoded) + XCTAssertEqual(array175.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array175.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array175) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray176() throws { + let codec = ScaleCoder.default() + var array176 = Array176(wrappedValue: (0..<176).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array176) + let decoded = try codec.decoder.decode(Array176.self, from: encoded) + XCTAssertEqual(array176.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array176.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array176) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray177() throws { + let codec = ScaleCoder.default() + var array177 = Array177(wrappedValue: (0..<177).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array177) + let decoded = try codec.decoder.decode(Array177.self, from: encoded) + XCTAssertEqual(array177.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array177.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array177) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray178() throws { + let codec = ScaleCoder.default() + var array178 = Array178(wrappedValue: (0..<178).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array178) + let decoded = try codec.decoder.decode(Array178.self, from: encoded) + XCTAssertEqual(array178.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array178.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array178) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray179() throws { + let codec = ScaleCoder.default() + var array179 = Array179(wrappedValue: (0..<179).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array179) + let decoded = try codec.decoder.decode(Array179.self, from: encoded) + XCTAssertEqual(array179.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array179.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array179) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray180() throws { + let codec = ScaleCoder.default() + var array180 = Array180(wrappedValue: (0..<180).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array180) + let decoded = try codec.decoder.decode(Array180.self, from: encoded) + XCTAssertEqual(array180.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array180.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array180) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray181() throws { + let codec = ScaleCoder.default() + var array181 = Array181(wrappedValue: (0..<181).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array181) + let decoded = try codec.decoder.decode(Array181.self, from: encoded) + XCTAssertEqual(array181.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array181.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array181) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray182() throws { + let codec = ScaleCoder.default() + var array182 = Array182(wrappedValue: (0..<182).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array182) + let decoded = try codec.decoder.decode(Array182.self, from: encoded) + XCTAssertEqual(array182.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array182.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array182) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray183() throws { + let codec = ScaleCoder.default() + var array183 = Array183(wrappedValue: (0..<183).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array183) + let decoded = try codec.decoder.decode(Array183.self, from: encoded) + XCTAssertEqual(array183.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array183.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array183) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray184() throws { + let codec = ScaleCoder.default() + var array184 = Array184(wrappedValue: (0..<184).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array184) + let decoded = try codec.decoder.decode(Array184.self, from: encoded) + XCTAssertEqual(array184.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array184.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array184) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray185() throws { + let codec = ScaleCoder.default() + var array185 = Array185(wrappedValue: (0..<185).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array185) + let decoded = try codec.decoder.decode(Array185.self, from: encoded) + XCTAssertEqual(array185.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array185.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array185) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray186() throws { + let codec = ScaleCoder.default() + var array186 = Array186(wrappedValue: (0..<186).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array186) + let decoded = try codec.decoder.decode(Array186.self, from: encoded) + XCTAssertEqual(array186.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array186.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array186) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray187() throws { + let codec = ScaleCoder.default() + var array187 = Array187(wrappedValue: (0..<187).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array187) + let decoded = try codec.decoder.decode(Array187.self, from: encoded) + XCTAssertEqual(array187.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array187.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array187) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray188() throws { + let codec = ScaleCoder.default() + var array188 = Array188(wrappedValue: (0..<188).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array188) + let decoded = try codec.decoder.decode(Array188.self, from: encoded) + XCTAssertEqual(array188.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array188.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array188) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray189() throws { + let codec = ScaleCoder.default() + var array189 = Array189(wrappedValue: (0..<189).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array189) + let decoded = try codec.decoder.decode(Array189.self, from: encoded) + XCTAssertEqual(array189.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array189.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array189) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray190() throws { + let codec = ScaleCoder.default() + var array190 = Array190(wrappedValue: (0..<190).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array190) + let decoded = try codec.decoder.decode(Array190.self, from: encoded) + XCTAssertEqual(array190.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array190.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array190) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray191() throws { + let codec = ScaleCoder.default() + var array191 = Array191(wrappedValue: (0..<191).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array191) + let decoded = try codec.decoder.decode(Array191.self, from: encoded) + XCTAssertEqual(array191.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array191.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array191) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray192() throws { + let codec = ScaleCoder.default() + var array192 = Array192(wrappedValue: (0..<192).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array192) + let decoded = try codec.decoder.decode(Array192.self, from: encoded) + XCTAssertEqual(array192.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array192.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array192) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray193() throws { + let codec = ScaleCoder.default() + var array193 = Array193(wrappedValue: (0..<193).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array193) + let decoded = try codec.decoder.decode(Array193.self, from: encoded) + XCTAssertEqual(array193.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array193.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array193) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray194() throws { + let codec = ScaleCoder.default() + var array194 = Array194(wrappedValue: (0..<194).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array194) + let decoded = try codec.decoder.decode(Array194.self, from: encoded) + XCTAssertEqual(array194.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array194.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array194) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray195() throws { + let codec = ScaleCoder.default() + var array195 = Array195(wrappedValue: (0..<195).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array195) + let decoded = try codec.decoder.decode(Array195.self, from: encoded) + XCTAssertEqual(array195.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array195.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array195) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray196() throws { + let codec = ScaleCoder.default() + var array196 = Array196(wrappedValue: (0..<196).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array196) + let decoded = try codec.decoder.decode(Array196.self, from: encoded) + XCTAssertEqual(array196.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array196.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array196) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray197() throws { + let codec = ScaleCoder.default() + var array197 = Array197(wrappedValue: (0..<197).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array197) + let decoded = try codec.decoder.decode(Array197.self, from: encoded) + XCTAssertEqual(array197.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array197.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array197) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray198() throws { + let codec = ScaleCoder.default() + var array198 = Array198(wrappedValue: (0..<198).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array198) + let decoded = try codec.decoder.decode(Array198.self, from: encoded) + XCTAssertEqual(array198.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array198.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array198) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray199() throws { + let codec = ScaleCoder.default() + var array199 = Array199(wrappedValue: (0..<199).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array199) + let decoded = try codec.decoder.decode(Array199.self, from: encoded) + XCTAssertEqual(array199.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array199.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array199) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray200() throws { + let codec = ScaleCoder.default() + var array200 = Array200(wrappedValue: (0..<200).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array200) + let decoded = try codec.decoder.decode(Array200.self, from: encoded) + XCTAssertEqual(array200.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array200.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array200) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray201() throws { + let codec = ScaleCoder.default() + var array201 = Array201(wrappedValue: (0..<201).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array201) + let decoded = try codec.decoder.decode(Array201.self, from: encoded) + XCTAssertEqual(array201.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array201.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array201) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray202() throws { + let codec = ScaleCoder.default() + var array202 = Array202(wrappedValue: (0..<202).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array202) + let decoded = try codec.decoder.decode(Array202.self, from: encoded) + XCTAssertEqual(array202.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array202.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array202) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray203() throws { + let codec = ScaleCoder.default() + var array203 = Array203(wrappedValue: (0..<203).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array203) + let decoded = try codec.decoder.decode(Array203.self, from: encoded) + XCTAssertEqual(array203.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array203.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array203) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray204() throws { + let codec = ScaleCoder.default() + var array204 = Array204(wrappedValue: (0..<204).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array204) + let decoded = try codec.decoder.decode(Array204.self, from: encoded) + XCTAssertEqual(array204.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array204.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array204) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray205() throws { + let codec = ScaleCoder.default() + var array205 = Array205(wrappedValue: (0..<205).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array205) + let decoded = try codec.decoder.decode(Array205.self, from: encoded) + XCTAssertEqual(array205.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array205.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array205) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray206() throws { + let codec = ScaleCoder.default() + var array206 = Array206(wrappedValue: (0..<206).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array206) + let decoded = try codec.decoder.decode(Array206.self, from: encoded) + XCTAssertEqual(array206.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array206.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array206) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray207() throws { + let codec = ScaleCoder.default() + var array207 = Array207(wrappedValue: (0..<207).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array207) + let decoded = try codec.decoder.decode(Array207.self, from: encoded) + XCTAssertEqual(array207.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array207.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array207) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray208() throws { + let codec = ScaleCoder.default() + var array208 = Array208(wrappedValue: (0..<208).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array208) + let decoded = try codec.decoder.decode(Array208.self, from: encoded) + XCTAssertEqual(array208.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array208.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array208) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray209() throws { + let codec = ScaleCoder.default() + var array209 = Array209(wrappedValue: (0..<209).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array209) + let decoded = try codec.decoder.decode(Array209.self, from: encoded) + XCTAssertEqual(array209.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array209.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array209) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray210() throws { + let codec = ScaleCoder.default() + var array210 = Array210(wrappedValue: (0..<210).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array210) + let decoded = try codec.decoder.decode(Array210.self, from: encoded) + XCTAssertEqual(array210.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array210.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array210) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray211() throws { + let codec = ScaleCoder.default() + var array211 = Array211(wrappedValue: (0..<211).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array211) + let decoded = try codec.decoder.decode(Array211.self, from: encoded) + XCTAssertEqual(array211.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array211.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array211) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray212() throws { + let codec = ScaleCoder.default() + var array212 = Array212(wrappedValue: (0..<212).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array212) + let decoded = try codec.decoder.decode(Array212.self, from: encoded) + XCTAssertEqual(array212.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array212.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array212) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray213() throws { + let codec = ScaleCoder.default() + var array213 = Array213(wrappedValue: (0..<213).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array213) + let decoded = try codec.decoder.decode(Array213.self, from: encoded) + XCTAssertEqual(array213.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array213.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array213) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray214() throws { + let codec = ScaleCoder.default() + var array214 = Array214(wrappedValue: (0..<214).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array214) + let decoded = try codec.decoder.decode(Array214.self, from: encoded) + XCTAssertEqual(array214.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array214.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array214) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray215() throws { + let codec = ScaleCoder.default() + var array215 = Array215(wrappedValue: (0..<215).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array215) + let decoded = try codec.decoder.decode(Array215.self, from: encoded) + XCTAssertEqual(array215.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array215.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array215) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray216() throws { + let codec = ScaleCoder.default() + var array216 = Array216(wrappedValue: (0..<216).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array216) + let decoded = try codec.decoder.decode(Array216.self, from: encoded) + XCTAssertEqual(array216.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array216.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array216) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray217() throws { + let codec = ScaleCoder.default() + var array217 = Array217(wrappedValue: (0..<217).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array217) + let decoded = try codec.decoder.decode(Array217.self, from: encoded) + XCTAssertEqual(array217.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array217.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array217) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray218() throws { + let codec = ScaleCoder.default() + var array218 = Array218(wrappedValue: (0..<218).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array218) + let decoded = try codec.decoder.decode(Array218.self, from: encoded) + XCTAssertEqual(array218.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array218.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array218) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray219() throws { + let codec = ScaleCoder.default() + var array219 = Array219(wrappedValue: (0..<219).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array219) + let decoded = try codec.decoder.decode(Array219.self, from: encoded) + XCTAssertEqual(array219.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array219.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array219) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray220() throws { + let codec = ScaleCoder.default() + var array220 = Array220(wrappedValue: (0..<220).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array220) + let decoded = try codec.decoder.decode(Array220.self, from: encoded) + XCTAssertEqual(array220.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array220.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array220) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray221() throws { + let codec = ScaleCoder.default() + var array221 = Array221(wrappedValue: (0..<221).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array221) + let decoded = try codec.decoder.decode(Array221.self, from: encoded) + XCTAssertEqual(array221.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array221.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array221) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray222() throws { + let codec = ScaleCoder.default() + var array222 = Array222(wrappedValue: (0..<222).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array222) + let decoded = try codec.decoder.decode(Array222.self, from: encoded) + XCTAssertEqual(array222.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array222.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array222) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray223() throws { + let codec = ScaleCoder.default() + var array223 = Array223(wrappedValue: (0..<223).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array223) + let decoded = try codec.decoder.decode(Array223.self, from: encoded) + XCTAssertEqual(array223.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array223.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array223) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray224() throws { + let codec = ScaleCoder.default() + var array224 = Array224(wrappedValue: (0..<224).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array224) + let decoded = try codec.decoder.decode(Array224.self, from: encoded) + XCTAssertEqual(array224.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array224.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array224) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray225() throws { + let codec = ScaleCoder.default() + var array225 = Array225(wrappedValue: (0..<225).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array225) + let decoded = try codec.decoder.decode(Array225.self, from: encoded) + XCTAssertEqual(array225.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array225.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array225) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray226() throws { + let codec = ScaleCoder.default() + var array226 = Array226(wrappedValue: (0..<226).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array226) + let decoded = try codec.decoder.decode(Array226.self, from: encoded) + XCTAssertEqual(array226.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array226.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array226) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray227() throws { + let codec = ScaleCoder.default() + var array227 = Array227(wrappedValue: (0..<227).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array227) + let decoded = try codec.decoder.decode(Array227.self, from: encoded) + XCTAssertEqual(array227.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array227.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array227) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray228() throws { + let codec = ScaleCoder.default() + var array228 = Array228(wrappedValue: (0..<228).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array228) + let decoded = try codec.decoder.decode(Array228.self, from: encoded) + XCTAssertEqual(array228.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array228.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array228) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray229() throws { + let codec = ScaleCoder.default() + var array229 = Array229(wrappedValue: (0..<229).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array229) + let decoded = try codec.decoder.decode(Array229.self, from: encoded) + XCTAssertEqual(array229.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array229.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array229) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray230() throws { + let codec = ScaleCoder.default() + var array230 = Array230(wrappedValue: (0..<230).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array230) + let decoded = try codec.decoder.decode(Array230.self, from: encoded) + XCTAssertEqual(array230.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array230.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array230) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray231() throws { + let codec = ScaleCoder.default() + var array231 = Array231(wrappedValue: (0..<231).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array231) + let decoded = try codec.decoder.decode(Array231.self, from: encoded) + XCTAssertEqual(array231.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array231.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array231) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray232() throws { + let codec = ScaleCoder.default() + var array232 = Array232(wrappedValue: (0..<232).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array232) + let decoded = try codec.decoder.decode(Array232.self, from: encoded) + XCTAssertEqual(array232.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array232.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array232) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray233() throws { + let codec = ScaleCoder.default() + var array233 = Array233(wrappedValue: (0..<233).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array233) + let decoded = try codec.decoder.decode(Array233.self, from: encoded) + XCTAssertEqual(array233.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array233.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array233) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray234() throws { + let codec = ScaleCoder.default() + var array234 = Array234(wrappedValue: (0..<234).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array234) + let decoded = try codec.decoder.decode(Array234.self, from: encoded) + XCTAssertEqual(array234.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array234.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array234) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray235() throws { + let codec = ScaleCoder.default() + var array235 = Array235(wrappedValue: (0..<235).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array235) + let decoded = try codec.decoder.decode(Array235.self, from: encoded) + XCTAssertEqual(array235.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array235.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array235) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray236() throws { + let codec = ScaleCoder.default() + var array236 = Array236(wrappedValue: (0..<236).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array236) + let decoded = try codec.decoder.decode(Array236.self, from: encoded) + XCTAssertEqual(array236.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array236.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array236) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray237() throws { + let codec = ScaleCoder.default() + var array237 = Array237(wrappedValue: (0..<237).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array237) + let decoded = try codec.decoder.decode(Array237.self, from: encoded) + XCTAssertEqual(array237.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array237.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array237) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray238() throws { + let codec = ScaleCoder.default() + var array238 = Array238(wrappedValue: (0..<238).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array238) + let decoded = try codec.decoder.decode(Array238.self, from: encoded) + XCTAssertEqual(array238.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array238.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array238) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray239() throws { + let codec = ScaleCoder.default() + var array239 = Array239(wrappedValue: (0..<239).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array239) + let decoded = try codec.decoder.decode(Array239.self, from: encoded) + XCTAssertEqual(array239.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array239.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array239) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray240() throws { + let codec = ScaleCoder.default() + var array240 = Array240(wrappedValue: (0..<240).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array240) + let decoded = try codec.decoder.decode(Array240.self, from: encoded) + XCTAssertEqual(array240.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array240.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array240) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray241() throws { + let codec = ScaleCoder.default() + var array241 = Array241(wrappedValue: (0..<241).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array241) + let decoded = try codec.decoder.decode(Array241.self, from: encoded) + XCTAssertEqual(array241.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array241.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array241) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray242() throws { + let codec = ScaleCoder.default() + var array242 = Array242(wrappedValue: (0..<242).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array242) + let decoded = try codec.decoder.decode(Array242.self, from: encoded) + XCTAssertEqual(array242.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array242.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array242) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray243() throws { + let codec = ScaleCoder.default() + var array243 = Array243(wrappedValue: (0..<243).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array243) + let decoded = try codec.decoder.decode(Array243.self, from: encoded) + XCTAssertEqual(array243.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array243.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array243) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray244() throws { + let codec = ScaleCoder.default() + var array244 = Array244(wrappedValue: (0..<244).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array244) + let decoded = try codec.decoder.decode(Array244.self, from: encoded) + XCTAssertEqual(array244.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array244.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array244) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray245() throws { + let codec = ScaleCoder.default() + var array245 = Array245(wrappedValue: (0..<245).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array245) + let decoded = try codec.decoder.decode(Array245.self, from: encoded) + XCTAssertEqual(array245.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array245.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array245) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray246() throws { + let codec = ScaleCoder.default() + var array246 = Array246(wrappedValue: (0..<246).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array246) + let decoded = try codec.decoder.decode(Array246.self, from: encoded) + XCTAssertEqual(array246.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array246.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array246) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray247() throws { + let codec = ScaleCoder.default() + var array247 = Array247(wrappedValue: (0..<247).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array247) + let decoded = try codec.decoder.decode(Array247.self, from: encoded) + XCTAssertEqual(array247.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array247.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array247) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray248() throws { + let codec = ScaleCoder.default() + var array248 = Array248(wrappedValue: (0..<248).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array248) + let decoded = try codec.decoder.decode(Array248.self, from: encoded) + XCTAssertEqual(array248.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array248.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array248) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray249() throws { + let codec = ScaleCoder.default() + var array249 = Array249(wrappedValue: (0..<249).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array249) + let decoded = try codec.decoder.decode(Array249.self, from: encoded) + XCTAssertEqual(array249.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array249.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array249) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray250() throws { + let codec = ScaleCoder.default() + var array250 = Array250(wrappedValue: (0..<250).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array250) + let decoded = try codec.decoder.decode(Array250.self, from: encoded) + XCTAssertEqual(array250.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array250.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array250) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray251() throws { + let codec = ScaleCoder.default() + var array251 = Array251(wrappedValue: (0..<251).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array251) + let decoded = try codec.decoder.decode(Array251.self, from: encoded) + XCTAssertEqual(array251.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array251.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array251) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray252() throws { + let codec = ScaleCoder.default() + var array252 = Array252(wrappedValue: (0..<252).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array252) + let decoded = try codec.decoder.decode(Array252.self, from: encoded) + XCTAssertEqual(array252.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array252.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array252) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray253() throws { + let codec = ScaleCoder.default() + var array253 = Array253(wrappedValue: (0..<253).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array253) + let decoded = try codec.decoder.decode(Array253.self, from: encoded) + XCTAssertEqual(array253.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array253.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array253) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray254() throws { + let codec = ScaleCoder.default() + var array254 = Array254(wrappedValue: (0..<254).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array254) + let decoded = try codec.decoder.decode(Array254.self, from: encoded) + XCTAssertEqual(array254.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array254.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array254) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray255() throws { + let codec = ScaleCoder.default() + var array255 = Array255(wrappedValue: (0..<255).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array255) + let decoded = try codec.decoder.decode(Array255.self, from: encoded) + XCTAssertEqual(array255.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array255.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array255) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } + + func testArray256() throws { + let codec = ScaleCoder.default() + var array256 = Array256(wrappedValue: (0..<256).map { _ in UUID().uuidString }) + let encoded = try codec.encoder.encode(array256) + let decoded = try codec.decoder.decode(Array256.self, from: encoded) + XCTAssertEqual(array256.wrappedValue, decoded.wrappedValue) + + func failingEncodingWithExtraElement() throws { + array256.wrappedValue.append(UUID().uuidString) + _ = try codec.encoder.encode(array256) + } + XCTAssertThrowsError(try failingEncodingWithExtraElement()) + } +} \ No newline at end of file diff --git a/Example/Tests/Int128Tests.swift b/Example/Tests/Int128Tests.swift new file mode 100644 index 0000000..5c199ec --- /dev/null +++ b/Example/Tests/Int128Tests.swift @@ -0,0 +1,34 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 XCTest +@testable import ScaleCodecSwift +import CommonSwift +import BigInt + +class Int128Tests: BaseTest { + override func setUp() { + adapter = Int128Adapter() + testValues = (0...TestConstants.testingIterationsCount) + .map { _ in + guard let data = UUID().uuidString.data(using: .utf8)?[0.. + * + * 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 XCTest +@testable import ScaleCodecSwift +import CommonSwift +import BigInt + +class Int256Tests: BaseTest { + override func setUp() { + adapter = Int256Adapter() + testValues = (0...TestConstants.testingIterationsCount) + .map { _ in + guard let data = UUID().uuidString.data(using: .utf8)?[0.. + * + * 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 XCTest +@testable import ScaleCodecSwift +import CommonSwift +import BigInt + +class Int512Tests: BaseTest { + override func setUp() { + adapter = Int512Adapter() + testValues = (0...TestConstants.testingIterationsCount) + .map { _ in + guard + let randomData1 = UUID().uuidString.data(using: .utf8), + let randomData2 = UUID().uuidString.data(using: .utf8) + else { + return BigInt(Data()) + } + + let data = (randomData1 + randomData2)[0.. + * + * 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 Foundation +import XCTest +@testable import ScaleCodecSwift + +class NumericInt8Tests: BaseNumericTest { } + +class NumericInt16Tests: BaseNumericTest { } + +class NumericInt32Tests: BaseNumericTest { } + +class NumericIntTests: BaseNumericTest { } + +class NumericInt64Tests: BaseNumericTest { } + +// MARK: - UInts + +class NumericUInt8Tests: BaseNumericTest { } + +class NumericUInt16Tests: BaseNumericTest { } + +class NumericUInt32Tests: BaseNumericTest { } + +class NumericUIntTests: BaseNumericTest { +} + +class NumericUInt64Tests: BaseNumericTest { + func testMetadataMagicNumber() { + let magicNumber: UInt64 = 1635018093 + + do { + guard let encodedValue = try adapter?.write(value: magicNumber) else { + XCTFail() + return + } + + let decodedValue = try adapter?.read(UInt64.self, from: DataReader(data: encodedValue)) + XCTAssertEqual(magicNumber, decodedValue) + } catch let error { + XCTFail(error.localizedDescription) + } + } +} diff --git a/Example/Tests/StringTests.swift b/Example/Tests/StringTests.swift new file mode 100644 index 0000000..51aa6ae --- /dev/null +++ b/Example/Tests/StringTests.swift @@ -0,0 +1,27 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 XCTest +@testable import ScaleCodecSwift + +class StringTests: BaseTest { + override func setUp() { + adapter = StringAdapter(coder: coder) + testValues = (0.. + * + * 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 BigInt +import XCTest +@testable import ScaleCodecSwift + +class StructTests: BaseTest { + override func setUp() { + super.setUp() + + let testingStruct = TestingStruct( + stringValue: "String Value", + optionalStringValue: "Optional String Value", + boolTrueValue: true, + boolFalseValue: false, + optionalBoolValue: false, + int8Value: Int8.random(in: Int8.min...Int8.max), + int8OptionalValue: Int8.random(in: Int8.min...Int8.max), + int16Value: Int16.random(in: Int16.min...Int16.max), + int16OptionalValue: Int16.random(in: Int16.min...Int16.max), + int32Value: Int32.random(in: Int32.min...Int32.max), + int32OptionalValue: Int32.random(in: Int32.min...Int32.max), + intValue: Int.random(in: Int.min...Int.max), + intOptionalValue: Int.random(in: Int.min...Int.max), + int64Value: Int64.random(in: Int64.min...Int64.max), + int64OptionalValue: Int64.random(in: Int64.min...Int64.max), + uInt8Value: UInt8.random(in: UInt8.min...UInt8.max), + uInt8OptionalValue: UInt8.random(in: UInt8.min...UInt8.max), + uInt16Value: UInt16.random(in: UInt16.min...UInt16.max), + uInt16OptionalValue: UInt16.random(in: UInt16.min...UInt16.max), + uInt32Value: UInt32.random(in: UInt32.min...UInt32.max), + uInt32OptionalValue: UInt32.random(in: UInt32.min...UInt32.max), + uIntValue: UInt.random(in: UInt.min...UInt.max), + uIntOptionalValue: UInt.random(in: UInt.min...UInt.max), + uInt64Value: UInt64.random(in: UInt64.min...UInt64.max), + uInt64OptionalValue: UInt64.random(in: UInt64.min...UInt64.max), + bigUIntValue: BigUInt("255"), + bigUIntOptionalValue: BigUInt("255"), + arrayValue: [1, 2, 3], + arrayOptionalValue: [1, 2, 3] + ) + + testValues = [testingStruct] + } +} diff --git a/Example/Tests/Tests.swift b/Example/Tests/Tests.swift deleted file mode 100644 index c0d74fe..0000000 --- a/Example/Tests/Tests.swift +++ /dev/null @@ -1,28 +0,0 @@ -import XCTest -import ScaleCodecSwift - -class Tests: XCTestCase { - - override func setUp() { - super.setUp() - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() - } - - func testExample() { - // This is an example of a functional test case. - XCTAssert(true, "Pass") - } - - func testPerformanceExample() { - // This is an example of a performance test case. - self.measure() { - // Put the code you want to measure the time of here. - } - } - -} diff --git a/Example/Tests/Types/TestingEnum.swift b/Example/Tests/Types/TestingEnum.swift new file mode 100644 index 0000000..c514d38 --- /dev/null +++ b/Example/Tests/Types/TestingEnum.swift @@ -0,0 +1,119 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 BigInt +import Foundation +import ScaleCodecSwift + +enum TestingEnum: Codable, Equatable { + enum CodingKeys: Int, CodingKey { + case simple + case int8 + case optionalInt8 + case nilInt8 + case int16 + case optionalInt16 + case nilInt16 + case int32 + case optionalInt32 + case nilInt32 + case int + case optionalInt + case nilInt + case int64 + case optionalInt64 + case nilInt64 + case uInt8 + case optionalUInt8 + case nilUInt8 + case uInt16 + case optionalUInt16 + case nilUInt16 + case uInt32 + case optionalUInt32 + case nilUInt32 + case uInt + case optionalUInt + case nilUInt + case uInt64 + case optionalUInt64 + case nilUInt64 + case bigUInt + case optionalBigUInt + case nilBigUInt + case bool + case optionalBool + case nilBool + case string + case optionalString + case nilString + case testingStruct + case optionalTestingStruct + case nilTestingStruct + case array + case optionalArray + case nilArray + } + + case simple + case int8(Int8) + case optionalInt8(Int8?) + case nilInt8(Int8?) + case int16(Int16) + case optionalInt16(Int16?) + case nilInt16(Int16?) + case int32(Int32) + case optionalInt32(Int32?) + case nilInt32(Int32?) + case int(Int) + case optionalInt(Int?) + case nilInt(Int?) + case int64(Int64) + case optionalInt64(Int64?) + case nilInt64(Int64?) + case uInt8(UInt8) + case optionalUInt8(UInt8?) + case nilUInt8(UInt8?) + case uInt16(UInt16) + case optionalUInt16(UInt16?) + case nilUInt16(UInt16?) + case uInt32(UInt32) + case optionalUInt32(UInt32?) + case nilUInt32(UInt32?) + case uInt(UInt) + case optionalUInt(UInt?) + case nilUInt(UInt?) + case uInt64(UInt64) + case optionalUInt64(UInt64?) + case nilUInt64(UInt64?) + case bigUInt(BigUInt) + case optionalBigUInt(BigUInt?) + case nilBigUInt(BigUInt?) + case bool(Bool) + case optionalBool(Bool?) + case nilBool(Bool?) + case string(String) + case optionalString(String?) + case nilString(String?) + case testingStruct(TestingStruct) + case optionalTestingStruct(TestingStruct?) + case nilTestingStruct(TestingStruct?) + case array([Int]) + case optionalArray([Int]?) + case nilArray([Int]?) +} diff --git a/Example/Tests/Types/TestingStruct.swift b/Example/Tests/Types/TestingStruct.swift new file mode 100644 index 0000000..bbb8bdb --- /dev/null +++ b/Example/Tests/Types/TestingStruct.swift @@ -0,0 +1,66 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 BigInt +import Foundation + +struct TestingStruct: Codable, Equatable { + let stringValue: String + let optionalStringValue: String? + var stringNilValue: String? = nil + let boolTrueValue: Bool + let boolFalseValue: Bool + let optionalBoolValue: Bool? + var boolNilValue: Bool? = nil + let int8Value: Int8 + let int8OptionalValue: Int8? + var int8NilValue: Int8? = nil + let int16Value: Int16 + let int16OptionalValue: Int16? + var int16NilValue: Int16? = nil + let int32Value: Int32 + let int32OptionalValue: Int32? + var int32NilValue: Int32? = nil + let intValue: Int + let intOptionalValue: Int? + var intNilValue: Int? = nil + let int64Value: Int64 + let int64OptionalValue: Int64? + var int64NilValue: Int64? = nil + let uInt8Value: UInt8 + let uInt8OptionalValue: UInt8? + var uInt8NilValue: UInt8? = nil + let uInt16Value: UInt16 + let uInt16OptionalValue: UInt16? + var uInt16NilValue: UInt16? = nil + let uInt32Value: UInt32 + let uInt32OptionalValue: UInt32? + var uInt32NilValue: UInt32? = nil + let uIntValue: UInt + let uIntOptionalValue: UInt? + var uIntNilValue: UInt? = nil + let uInt64Value: UInt64 + let uInt64OptionalValue: UInt64? + var uInt64NilValue: UInt64? = nil + let bigUIntValue: BigUInt + let bigUIntOptionalValue: BigUInt? + var bigUIntNilValue: BigUInt? = nil + let arrayValue: [Int] + let arrayOptionalValue: [Int]? + var arrayNilValue: [Int]? = nil +} diff --git a/Example/Tests/UInt128Tests.swift b/Example/Tests/UInt128Tests.swift new file mode 100644 index 0000000..de21570 --- /dev/null +++ b/Example/Tests/UInt128Tests.swift @@ -0,0 +1,34 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 XCTest +@testable import ScaleCodecSwift +import CommonSwift +import BigInt + +class UInt128Tests: BaseTest { + override func setUp() { + adapter = UInt128Adapter() + testValues = (0...TestConstants.testingIterationsCount) + .map { _ in + guard let data = UUID().uuidString.data(using: .utf8)?[0.. + * + * 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 XCTest +@testable import ScaleCodecSwift +import CommonSwift +import BigInt + +class UInt256Tests: BaseTest { + override func setUp() { + adapter = UInt256Adapter() + testValues = (0...TestConstants.testingIterationsCount) + .map { _ in + guard let data = UUID().uuidString.data(using: .utf8)?[0.. + * + * 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 XCTest +@testable import ScaleCodecSwift +import CommonSwift +import BigInt + +class UInt512Tests: BaseTest { + override func setUp() { + adapter = UInt512Adapter() + testValues = (0...TestConstants.testingIterationsCount) + .map { _ in + guard + let randomData1 = UUID().uuidString.data(using: .utf8), + let randomData2 = UUID().uuidString.data(using: .utf8) + else { + return BigUInt(Data()) + } + + let data = (randomData1 + randomData2)[0.. -[![CI Status](https://img.shields.io/travis/TigranIsk/ScaleCodecSwift.svg?style=flat)](https://travis-ci.org/TigranIsk/ScaleCodecSwift) -[![Version](https://img.shields.io/cocoapods/v/ScaleCodecSwift.svg?style=flat)](https://cocoapods.org/pods/ScaleCodecSwift) -[![License](https://img.shields.io/cocoapods/l/ScaleCodecSwift.svg?style=flat)](https://cocoapods.org/pods/ScaleCodecSwift) -[![Platform](https://img.shields.io/cocoapods/p/ScaleCodecSwift.svg?style=flat)](https://cocoapods.org/pods/ScaleCodecSwift) + + + Sublab logo + -## Example + -To run the example project, clone the repo, and run `pod install` from the Example directory first. +[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/scale-codec-swift)](https://img.shields.io/cocoapods/v/scale-codec-swift) +[![Swift](https://img.shields.io/badge/Swift-5.0.0-orange?style=flat-square)](https://img.shields.io/badge/Swift-5.0.0-Orange?style=flat-square) +[![Telegram channel](https://img.shields.io/badge/chat-telegram-green.svg?logo=telegram)](https://t.me/sublabsupport) +[![GitHub License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) -## Requirements +# Sublab's Scale Codec Swift library + +This is a Swift repository which implements [Parity's SCALE codec](https://docs.substrate.io/reference/scale-codec/) in a designated way. + +This repository aims to provide easy to use interface using Swift's Codable family of protocols via natively formatted SCALE Encoder and Decoder. + +Unfortunately, Swift misses reflection and static size array in it and to avoid Objective-C backed types usage we generated static size arrays for sizes from 1 to 256 and using some workarounds for existing types like *enum* with *CodingKey*. + +## Sublab + +At Sublab we're making mobile-first libraries for developers in [Substrate](https://substrate.io) ecosystem. However, we seek our libraries to be available not only for mobile Apple OS or Android OS, but compatible with any Swift/Kotlin environment: web servers, desktop apps, and whatnot. + +Our mission is to to develop fully native open-source libraries for mobile platforms in Polkadot and Kusama ecosystems, covering everything with reliable unit-tests and providing rich documentation to the developers community. + +Our goal is to have more developers to come into the world of development of client applications in Substrate ecosystem, as we find this as most promising and intelligent blockchain project we ever seen. Thus, we as mobile development gurus trying to create enormously professional libraries which might be very complicated under the hood, but very simple and convenient for final developers. ## Installation -ScaleCodecSwift is available through [CocoaPods](https://cocoapods.org). To install -it, simply add the following line to your Podfile: +[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your `Podfile`: ```ruby pod 'ScaleCodecSwift' ``` -## Author +## Documentation + +- Our GitBook: [https://docs.sublab.dev/swift-libraries/scale-codec-library](https://docs.sublab.dev/swift-libraries/scale-codec-library) +- API reference: [https://api-reference.sublab.dev/scale-codec-swift/](https://api-reference.sublab.dev/scale-codec-swift/) + +## Contributing -TigranIsk, tiger@sublab.dev +Please look into our [contribution guide](CONTRIBUTING.md) and [code of conduct](CODE_OF_CONDUCT.md) prior to contributing. -## License +## Contacts -ScaleCodecSwift is available under the MIT license. See the LICENSE file for more info. +- Website: [sublab.dev](https://sublab.dev) +- E-mail: [info@sublab.dev](mailto:info@sublab.dev) +- Telegram support channel: [t.me/sublabsupport](t.me/sublabsupport) +- Twitter: [twitter.com/sublabdev](https://twitter.com/sublabdev) diff --git a/ScaleCodecFixedArrayGenerator b/ScaleCodecFixedArrayGenerator new file mode 100755 index 0000000..f61ebcc Binary files /dev/null and b/ScaleCodecFixedArrayGenerator differ diff --git a/ScaleCodecSwift.podspec b/ScaleCodecSwift.podspec index 5cb9683..60c5efb 100644 --- a/ScaleCodecSwift.podspec +++ b/ScaleCodecSwift.podspec @@ -1,42 +1,13 @@ -# -# Be sure to run `pod lib lint ScaleCodecSwift.podspec' to ensure this is a -# valid spec before submitting. -# -# Any lines starting with a # are optional, but their use is encouraged -# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html -# - Pod::Spec.new do |s| s.name = 'ScaleCodecSwift' - s.version = '0.1.0' - s.summary = 'A short description of ScaleCodecSwift.' - -# This description is used to generate tags and improve search results. -# * Think: What does it do? Why did you write it? What is the focus? -# * Try to keep it short, snappy and to the point. -# * Write the description between the DESC delimiters below. -# * Finally, don't worry about the indent, CocoaPods strips it! - - s.description = <<-DESC -TODO: Add long description of the pod here. - DESC - - s.homepage = 'https://github.com/TigranIsk/ScaleCodecSwift' - # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' - s.license = { :type => 'MIT', :file => 'LICENSE' } - s.author = { 'TigranIsk' => 'tiskandaryan@griddynamics.com' } - s.source = { :git => 'https://github.com/TigranIsk/ScaleCodecSwift.git', :tag => s.version.to_s } - # s.social_media_url = 'https://twitter.com/' - - s.ios.deployment_target = '10.0' - + s.version = '1.0.0' + s.summary = 'Pure Swift library for Substrate\'s SCALE codec.' + s.homepage = 'https://github.com/sublabdev/scale-codec-swift' + s.license = { :type => 'Apache 2.0', :file => 'LICENSE' } + s.author = { 'Substrate Laboratory' => 'info@sublab.dev' } + s.source = { :git => 'https://github.com/sublabdev/scale-codec-swift.git', :tag => s.version.to_s } + s.ios.deployment_target = '13.0' s.source_files = 'ScaleCodecSwift/Classes/**/*' - - # s.resource_bundles = { - # 'ScaleCodecSwift' => ['ScaleCodecSwift/Assets/*.png'] - # } - - # s.public_header_files = 'Pod/Classes/**/*.h' - # s.frameworks = 'UIKit', 'MapKit' - # s.dependency 'AFNetworking', '~> 2.3' + s.dependency 'CommonSwift', '~> 1.0.0' + s.dependency 'BigInt', '~> 5.0.0' end diff --git a/ScaleCodecSwift/Classes/Adapters/ArrayAdapter.swift b/ScaleCodecSwift/Classes/Adapters/ArrayAdapter.swift new file mode 100644 index 0000000..7d7e15e --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/ArrayAdapter.swift @@ -0,0 +1,50 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 BigInt +import Foundation + +/// An adapter for handling encoding and decoding of Arrays +public final class ArrayAdapter: ScaleCodecAdapter<[T]> { + private let coder: ScaleCoder + + public init(coder: ScaleCoder) { + self.coder = coder + } + + public override func read(_ type: [T].Type?, from reader: DataReader) throws -> [T] { + let count = try coder.decoder.decode(BigUInt.self, from: reader) + return try (0.. Data { + try value + .map { try coder.encoder.encode($0) } + .reduce(try coder.encoder.encode(BigUInt(value.count))) { $0 + $1 } + } +} + +extension Array: ScaleGenericCodable where Element: Codable { + init(from reader: DataReader, coder: ScaleCoder) throws { + self = try ArrayAdapter(coder: coder).read([Element].self, from: reader) + } + + func write(coder: ScaleCoder) throws -> Data { + try ArrayAdapter(coder: coder).write(value: self) + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/BigUIntAdapter.swift b/ScaleCodecSwift/Classes/Adapters/BigUIntAdapter.swift new file mode 100644 index 0000000..497b3c3 --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/BigUIntAdapter.swift @@ -0,0 +1,123 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation +import BigInt +import CommonSwift + +fileprivate enum BigUIntCompressingError: Swift.Error { + case tooBigValue + case noCompressedData +} + +/// Adapter for BigUInt +public final class BigUIntAdapter: ScaleCodecAdapter { + private let coder: ScaleCoder + + public init(coder: ScaleCoder) { + self.coder = coder + } + + public override func read(_ type: BigUInt.Type?, from reader: DataReader) throws -> BigUInt { + let first = try coder.decoder.decode(UInt8.self, from: reader) + let mode = first & 0b11 + let value = first | 0b11 + + switch mode { + case 0b00: + return BigUInt(UInt8(value) >> 2) + case 0b01: + return BigUInt(try readRest(of: UInt16.self, value: value, dataReader: reader)) + case 0b10: + return BigUInt(try readRest(of: UInt32.self, value: value, dataReader: reader)) + default: + let count = value >> 2 + 4 + let data = Data(try (0.. Data { + switch value { + case (0..<1 << (UInt8.bitWidth - 2)): return try coder.encoder.encode((UInt8(value) << 2)) + case (0..<1 << (UInt16.bitWidth - 2)): return try coder.encoder.encode((UInt16(value) << 2 | 0b01)) + case (0..<1 << (UInt32.bitWidth - 2)): return try coder.encoder.encode((UInt32(value) << 2 | 0b10)) + default: + let data = value.compressData() + let count = UInt8(data.count - 4) << 2 | 0b11 + return Data([count]) + data + } + } + + private func readRest( + of type: T.Type, + value: UInt8, + dataReader: DataReader + ) throws -> BigUInt where T: Codable { + let bytesLeft = UInt8(type.bitWidth / UInt8.bitWidth) - 1 + let data = Data([value] + (try (0..().read(type, from: DataReader(data: data))) >> 2 + } +} + +// Since in 'BigUInt' library we have a custom conformance to Codable which is not conforming to ScaleCodec principles +// We need to override it with an extension conforming to ScaleGenericCodable, as we prioritize it over the default Codable implementations +extension BigUInt: ScaleGenericCodable { + init(from reader: DataReader, coder: ScaleCoder) throws { + self = try BigUIntAdapter(coder: coder).read(BigUInt.self, from: reader) + } + + func write(coder: ScaleCoder) throws -> Data { + try BigUIntAdapter(coder: coder).write(value: self) + } +} + + +// MARK: BigUInt Extension +private extension BigUInt { + // Initializes BigUInt from a compressed data by adding the missing zeroes at the end + init(compressedData: Data) throws { + self.init() + + switch compressedData.count { + case (0...UInt8.byteWidth): self = BigUInt(UInt8(littleEndian: compressedData.fillingZeroesAtEnd(byteWidth: UInt8.byteWidth).withUnsafeBytes { $0.load(as: UInt8.self) })) + case (0...UInt16.byteWidth): self = BigUInt(UInt16(littleEndian: compressedData.fillingZeroesAtEnd(byteWidth: UInt16.byteWidth).withUnsafeBytes { $0.load(as: UInt16.self) })) + case (0...UInt32.byteWidth): self = BigUInt(UInt32(littleEndian: compressedData.fillingZeroesAtEnd(byteWidth: UInt32.byteWidth).withUnsafeBytes { $0.load(as: UInt32.self) })) + case (0...UInt64.byteWidth): self = BigUInt(UInt64(littleEndian: compressedData.fillingZeroesAtEnd(byteWidth: UInt64.byteWidth).withUnsafeBytes { $0.load(as: UInt64.self) })) + default: + var dataCount = compressedData.count + if dataCount % UInt64.byteWidth != 0 { + dataCount = Int(ceil((Double(dataCount) / Double(UInt64.byteWidth)))) * UInt64.byteWidth + } + + let data = compressedData.fillingZeroesAtEnd(byteWidth: dataCount) + self = BigUInt(Data(data.reversed())) + } + } + + /// Compresses `BigUInt` + /// - Returns: A `Data` from `BigUInt` without zeroes at the end + func compressData() -> Data { + Data(serialize().reversed()).removingZeroesAtEnd + } +} + +// MARK: - FixedWidthInteger Extension +private extension FixedWidthInteger { + static var byteWidth: Int { bitWidth / 8 } +} diff --git a/ScaleCodecSwift/Classes/Adapters/BoolAdapter.swift b/ScaleCodecSwift/Classes/Adapters/BoolAdapter.swift new file mode 100644 index 0000000..62779aa --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/BoolAdapter.swift @@ -0,0 +1,52 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// An adapter for Bool type +public final class BoolAdapter: ScaleCodecAdapter { + public override init() {} + + public override func read(_ type: Bool.Type?, from reader: DataReader) throws -> Bool { + try reader.readByte() == 1 + } + + public override func write(value: Bool) throws -> Data { + Data([value ? 1 : 0]) + } +} + +/// An adapter for Bool? type +public final class OptionalBoolAdapter: ScaleCodecAdapter { + private enum Error: Swift.Error { + case invalidValue(UInt8) + } + + public override func read(_ type: Bool?.Type?, from reader: DataReader) throws -> Bool? { + switch try reader.readByte() { + case 0: return nil + case 1: return true + case 2: return false + default: throw Error.invalidValue(3) + } + } + + public override func write(value: Bool?) throws -> Data { + Data([value.map { $0 ? 1 : 2 } ?? 0]) + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/DataAdapter.swift b/ScaleCodecSwift/Classes/Adapters/DataAdapter.swift new file mode 100644 index 0000000..3ce6c69 --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/DataAdapter.swift @@ -0,0 +1,36 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// An adapter to handle read and write operations for Data +public final class DataAdapter: ScaleCodecAdapter { + let arrayAdapter: ArrayAdapter + + public init(coder: ScaleCoder) { + arrayAdapter = .init(coder: coder) + } + + public override func read(_ type: Data.Type?, from reader: DataReader) throws -> Data { + Data(try arrayAdapter.read([UInt8].self, from: reader)) + } + + public override func write(value: Data) throws -> Data { + try arrayAdapter.write(value: value.map { $0 }) + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/Int128Adapter.swift b/ScaleCodecSwift/Classes/Adapters/Int128Adapter.swift new file mode 100644 index 0000000..f480929 --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/Int128Adapter.swift @@ -0,0 +1,33 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation +import CommonSwift + +/// An adapter to handle read and write operations for Int128 +public final class Int128Adapter: ScaleCodecAdapter { + public override init() {} + + public override func read(_ type: Int128.Type?, from reader: DataReader) throws -> Int128 { + try Data(reader.read(size: Int128.size)).int128() + } + + public override func write(value: Int128) throws -> Data { + value.data() + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/Int256Adapter.swift b/ScaleCodecSwift/Classes/Adapters/Int256Adapter.swift new file mode 100644 index 0000000..6785f6d --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/Int256Adapter.swift @@ -0,0 +1,33 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation +import CommonSwift + +/// An adapter to handle read and write operations for Int256 +public final class Int256Adapter: ScaleCodecAdapter { + public override init() {} + + public override func read(_ type: Int256.Type?, from reader: DataReader) throws -> Int256 { + try Data(reader.read(size: Int256.size)).int256() + } + + public override func write(value: Int256) throws -> Data { + value.data() + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/Int512Adapter.swift b/ScaleCodecSwift/Classes/Adapters/Int512Adapter.swift new file mode 100644 index 0000000..14fca8b --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/Int512Adapter.swift @@ -0,0 +1,33 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation +import CommonSwift + +/// An adapter to handle read and write operations for Int512 +public final class Int512Adapter: ScaleCodecAdapter { + public override init() {} + + public override func read(_ type: Int512.Type?, from reader: DataReader) throws -> Int512 { + try Data(reader.read(size: Int512.size)).int512() + } + + public override func write(value: Int512) throws -> Data { + value.data() + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/NumericAdapter.swift b/ScaleCodecSwift/Classes/Adapters/NumericAdapter.swift new file mode 100644 index 0000000..c74bde5 --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/NumericAdapter.swift @@ -0,0 +1,46 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// A generic numeric adapter that handles read and write operations for numeric types (conforming to `FixedWidthInteger` protocol) +public final class NumericAdapter: ScaleCodecAdapter where T: Codable { + public override init() {} + + public override func read(_ type: T.Type?, from reader: DataReader) throws -> T { + let stride = MemoryLayout.stride + return Self.fromData(try reader.read(size: stride)) + } + + public static func fromData(_ data: Data) -> T { + fromData(data.map { $0 }) + } + + static func fromData(_ data: [UInt8]) -> T { + T(littleEndian: data.withUnsafeBytes { $0.load(as: T.self) }) + } + + public override func write(value: T) throws -> Data { + Self.toData(value) + } + + public static func toData(_ value: T) -> Data { + var value = value + return withUnsafeBytes(of: &value) { Data($0) } + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/OptionalAdapter.swift b/ScaleCodecSwift/Classes/Adapters/OptionalAdapter.swift new file mode 100644 index 0000000..c6537f0 --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/OptionalAdapter.swift @@ -0,0 +1,57 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// A generic adapter that handles read and write operations for optionali types (conforming to `Codable` protocol) +public final class OptionalAdapter: ScaleCodecAdapter { + private let coder: ScaleCoder + + public init(coder: ScaleCoder) { + self.coder = coder + } + + public override func read(_ type: T?.Type?, from reader: DataReader) throws -> T? { + let isNil = try reader.readByte() == 0 + + guard !isNil else { + return nil + } + + return try coder.decoder.decode(T.self, from: reader) + } + + public override func write(value: T?) throws -> Data { + guard let value = value else { + return .init([0]) + } + + let encoded = try coder.encoder.encode(value) + return .init([1]) + encoded + } +} + +extension Optional: ScaleGenericCodable where Wrapped: Codable { + init(from reader: DataReader, coder: ScaleCoder) throws { + self = try OptionalAdapter(coder: coder).read(Wrapped?.self, from: reader) + } + + func write(coder: ScaleCoder) throws -> Data { + try OptionalAdapter(coder: coder).write(value: self) + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/ScaleEncodedDataAdapter.swift b/ScaleCodecSwift/Classes/Adapters/ScaleEncodedDataAdapter.swift new file mode 100644 index 0000000..a5673cd --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/ScaleEncodedDataAdapter.swift @@ -0,0 +1,29 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +final class ScaleEncodedDataAdapter: ScaleCodecAdapter { + override func read(_ type: ScaleEncodedData.Type?, from reader: DataReader) throws -> ScaleEncodedData { + fatalError("shouldn't be used for reading purpose") + } + + override func write(value: ScaleEncodedData) throws -> Data { + value.value + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/StringAdapter.swift b/ScaleCodecSwift/Classes/Adapters/StringAdapter.swift new file mode 100644 index 0000000..a943c92 --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/StringAdapter.swift @@ -0,0 +1,51 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// An adapter to handle read and write operations for String +public final class StringAdapter: ScaleCodecAdapter { + enum Error: Swift.Error { + case readError(Data) + case writeError(String) + } + + let dataAdapter: DataAdapter + + public init(coder: ScaleCoder) { + dataAdapter = .init(coder: coder) + } + + public override func read(_ type: String.Type?, from reader: DataReader) throws -> String { + let data = try dataAdapter.read(Data.self, from: reader) + + guard let result = String(data: .init(data), encoding: .utf8) else { + throw Error.readError(.init(data)) + } + + return result + } + + public override func write(value: String) throws -> Data { + guard let data = value.data(using: .utf8) else { + throw Error.writeError(value) + } + + return try dataAdapter.write(value: data) + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/UInt128Adapter.swift b/ScaleCodecSwift/Classes/Adapters/UInt128Adapter.swift new file mode 100644 index 0000000..e4ee820 --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/UInt128Adapter.swift @@ -0,0 +1,33 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation +import CommonSwift + +/// An adapter to handle read and write operations for UInt128 +public final class UInt128Adapter: ScaleCodecAdapter { + public override init() {} + + public override func read(_ type: UInt128.Type?, from reader: DataReader) throws -> UInt128 { + try Data(reader.read(size: UInt128.size)).uInt128() + } + + public override func write(value: UInt128) throws -> Data { + value.data() + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/UInt256Adapter.swift b/ScaleCodecSwift/Classes/Adapters/UInt256Adapter.swift new file mode 100644 index 0000000..2194a5e --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/UInt256Adapter.swift @@ -0,0 +1,33 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation +import CommonSwift + +/// An adapter to handle read and write operations for UInt256 +public final class UInt256Adapter: ScaleCodecAdapter { + public override init() {} + + public override func read(_ type: UInt256.Type?, from reader: DataReader) throws -> UInt256 { + try Data(reader.read(size: UInt256.size)).uInt256() + } + + public override func write(value: UInt256) throws -> Data { + value.data() + } +} diff --git a/ScaleCodecSwift/Classes/Adapters/UInt512Adapter.swift b/ScaleCodecSwift/Classes/Adapters/UInt512Adapter.swift new file mode 100644 index 0000000..ac36d01 --- /dev/null +++ b/ScaleCodecSwift/Classes/Adapters/UInt512Adapter.swift @@ -0,0 +1,33 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation +import CommonSwift + +/// An adapter to handle read and write operations for UInt512 +public final class UInt512Adapter: ScaleCodecAdapter { + public override init() {} + + public override func read(_ type: UInt512.Type?, from reader: DataReader) throws -> UInt512 { + try Data(reader.read(size: UInt512.size)).uInt512() + } + + public override func write(value: UInt512) throws -> Data { + value.data() + } +} diff --git a/ScaleCodecSwift/Classes/Coder/ScaleCoder.swift b/ScaleCodecSwift/Classes/Coder/ScaleCoder.swift new file mode 100644 index 0000000..d222c21 --- /dev/null +++ b/ScaleCodecSwift/Classes/Coder/ScaleCoder.swift @@ -0,0 +1,48 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// An object that holds an encoder and a decoder +public final class ScaleCoder { + /// Encoder used to encode (write) data from a specified type to Data + public let encoder: ScaleEncoder + /// Decoder used to decode (read) data to a specified type + public let decoder: ScaleDecoder + + public let adapterProvider: ScaleCodecAdapterProvider + + public init(adapterProvider: ScaleCodecAdapterProvider) { + self.adapterProvider = adapterProvider + self.encoder = ScaleEncoder(adapterProvider: adapterProvider) + self.decoder = ScaleDecoder(adapterProvider: adapterProvider) + } + + /// Creates a default coder that handles all the standard types + /// - Returns: A default `ScaleCoder` created using the default adapter provider + public static func `default`() -> ScaleCoder { + .init(adapterProvider: DefaultScaleCodecAdapterProvider()) + } + + /// A transaction object for scale coded + /// - Returns: An object which is used to decode (by appending additional values if needed) and encode + /// `Codable` types + public func transaction() -> ScaleCodecTransaction { + ScaleCodecTransaction(encoder: encoder) + } +} diff --git a/ScaleCodecSwift/Classes/Decoder/ScaleDecoder.swift b/ScaleCodecSwift/Classes/Decoder/ScaleDecoder.swift new file mode 100644 index 0000000..c291592 --- /dev/null +++ b/ScaleCodecSwift/Classes/Decoder/ScaleDecoder.swift @@ -0,0 +1,185 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// An interface for encoder provider +protocol ScaleDecoderProvider { + /// Provides an encoder + /// - Parameters: + /// - dataReader: A `DataReader` that holds and reads the `Data` + /// - adapterProvider: An object that provides adapters to handle read and write opertations + /// - codingPath: An array of `CodingKey` objects + /// - userInfo: A dict containing user-defined `CodingUserInfoKey` as keys + /// - Returns: A decoder container + func decoder( + dataReader: DataReader, + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey], + userInfo: [CodingUserInfoKey: Any] + ) -> Decoder +} + +/// A default interface for providing decoding functionality +protocol ScaleDecoding { + func decode(_ type: T.Type, from reader: DataReader) throws -> T where T : Decodable +} + +// MARK: - Decoding, ScaleDecoderProvider +/// Handles scale decoding +public final class ScaleDecoder: ScaleDecoding, ScaleDecoderProvider { + private let codingPath: [CodingKey] + private let userInfo: [CodingUserInfoKey: Any] + private let adapterProvider: ScaleCodecAdapterProvider + + /// Creates a scale decoder + /// - Parameters: + /// - adapterProvider: An object that provides adapters based on a type being decoded + /// - codingPath: An array of `CodingKey` objects + /// - userInfo: A dict containing user-defined `CodingUserInfoKey` as keys + public init( + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey] = [], + userInfo: [CodingUserInfoKey: Any] = [:] + ) { + self.adapterProvider = adapterProvider + self.codingPath = codingPath + self.userInfo = userInfo + } + + /// Decodes a generic type `T` from provided `Data` + /// - Parameters: + /// - type: A type to which provided `Data` should be decoded + /// - data: The data that needs to be decoded into a type + /// - Returns: A decoded type + public func decode(_ type: T.Type, from data: Data) throws -> T { + try decode(type, from: DataReader(data: data)) + } + + private var testTuples = [(AnyClass, Date)]() + + func decode(_ type: T.Type, from dataReader: DataReader) throws -> T { + let currentTime = Date() + let currentOffset = dataReader.offset + + do { + // Types like Ints, Strings etc will be resolved via their custom adapters + // Types with custom optional adapters will be resolved here as well (the main cause of this 'if' condition) + // Other types will be resolved via GenericAdapter though types like array and all other optionals will be resolved + // via their custom adapters + // Struct, Enums will throw 'No adapter found' error thus should be resolved via basic containers + + return try adapterProvider.adapter(for: type).read(type, from: dataReader) + } catch ScaleCodecAdapterProvider.Error.noAdapterFound { + // No adapter found hence resolving via the default way + } catch let error { + throw error + } + + dataReader.offset = currentOffset + + let decoder = decoder( + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + + return try T(from: decoder) + } + + /// Initializes `ScaleDecoderContainer` which provides a specific container (keyed, unkeyed and single value) based on a type that needs to be decoded + /// - Parameters: + /// - codingPath: An array of `CodingKey` objects + /// - userInfo: A dict containing user-defined + /// - Returns: `ScaleDecoderContainer` object + func decoder( + dataReader: DataReader, + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey], + userInfo: [CodingUserInfoKey: Any] + ) -> Decoder { + ScaleDecoderContainer( + decoderProvider: self, + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + } +} + +// Handles containers for decoding +private final class ScaleDecoderContainer: Decoder { + + var codingPath: [CodingKey] + var userInfo: [CodingUserInfoKey : Any] + + private let decoderProvider: ScaleDecoderProvider + private let dataReader: DataReader + private let adapterProvider: ScaleCodecAdapterProvider + + init( + decoderProvider: ScaleDecoderProvider, + dataReader: DataReader, + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey] = [], + userInfo: [CodingUserInfoKey: Any] = [:] + ) { + self.decoderProvider = decoderProvider + self.dataReader = dataReader + self.adapterProvider = adapterProvider + self.codingPath = codingPath + self.userInfo = userInfo + } + + // Returns a single value decoding container + func singleValueContainer() throws -> SingleValueDecodingContainer { + ScaleSingleValueDecodingContainer( + decoderProvider: decoderProvider, + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + } + + // Returns an unkeyed decoding container + func unkeyedContainer() throws -> UnkeyedDecodingContainer { + try ScaleUnkeyedDecodingContainer( + decoderProvider: decoderProvider, + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + } + + // Returns a keyed decoding container + func container(keyedBy type: Key.Type) throws -> KeyedDecodingContainer where Key : CodingKey { + let container = ScaleKeyedDecodingContainer( + decoderProvider: decoderProvider, + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + + return KeyedDecodingContainer(container) + } +} diff --git a/ScaleCodecSwift/Classes/Decoder/ScaleKeyedDecodingContainer.swift b/ScaleCodecSwift/Classes/Decoder/ScaleKeyedDecodingContainer.swift new file mode 100644 index 0000000..6160e50 --- /dev/null +++ b/ScaleCodecSwift/Classes/Decoder/ScaleKeyedDecodingContainer.swift @@ -0,0 +1,276 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +final class ScaleKeyedDecodingContainer: KeyedDecodingContainerProtocol { + + // MARK: - KeyedDecodingContainerProtocol + + typealias Key = K + + var codingPath: [CodingKey] + let userInfo: [CodingUserInfoKey: Any] + + var allKeys: [K] = [] + + func contains(_ key: K) -> Bool { + allKeys.contains { $0.stringValue == key.stringValue && $0.intValue == key.intValue } + } + + // MARK: - Init + + private let decoderProvider: ScaleDecoderProvider + private let dataReader: DataReader + private let adapterProvider: ScaleCodecAdapterProvider + + init( + decoderProvider: ScaleDecoderProvider, + dataReader: DataReader, + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey], + userInfo: [CodingUserInfoKey: Any] + ) { + self.decoderProvider = decoderProvider + self.dataReader = dataReader + self.adapterProvider = adapterProvider + self.codingPath = codingPath + self.userInfo = userInfo + + tryDecodeIndex() + } + + // Trying to decode an index which is used for getting a specific key + private func tryDecodeIndex() { + let currentOffset = dataReader.offset + let index: UInt8 + + do { + index = try nestedSingleValueDecodingContainer().decode(UInt8.self) + } catch { + dataReader.offset = currentOffset + return + } + + guard let key = K(intValue: Int(index)) else { + dataReader.offset = currentOffset + return + } + + allKeys = [key] + } + + // MARK: - Decoding + // Decodes generic optional values for a specified key + private func decodeIfPresent(_ type: T.Type, forKey key: K, decoder: () throws -> T) throws -> T? { + let isPresent = try nestedSingleValueDecodingContainer(forKey: key).decode(Bool.self) + return isPresent ? try decoder() : nil + } + // Decodes nil values for a specified key + func decodeNil(forKey key: K) throws -> Bool { + nestedSingleValueDecodingContainer(forKey: key).decodeNil() + } + // Decodes to Bool values for a specified key + func decode(_ type: Bool.Type, forKey key: K) throws -> Bool { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodes to optional Bool values for a specified key + func decodeIfPresent(_ type: Bool.Type, forKey key: K) throws -> Bool? { + try nestedSingleValueDecodingContainer(forKey: key).read(Bool?.self) + } + // Decodes to String values for a specified key + func decode(_ type: String.Type, forKey key: K) throws -> String { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodes to optional String values for a specified key + func decodeIfPresent(_ type: String.Type, forKey key: K) throws -> String? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodes to Int values for a specified key + func decode(_ type: Int.Type, forKey key: K) throws -> Int { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodes to optional Int values for a specified key + func decodeIfPresent(_ type: Int.Type, forKey key: K) throws -> Int? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodes to Int8 values for a specified key + func decode(_ type: Int8.Type, forKey key: K) throws -> Int8 { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodes to optional Int8 values for a specified key + func decodeIfPresent(_ type: Int8.Type, forKey key: K) throws -> Int8? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodes to Int16 values for a specified key + func decode(_ type: Int16.Type, forKey key: K) throws -> Int16 { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodes to optional Int16 values for a specified key + func decodeIfPresent(_ type: Int16.Type, forKey key: K) throws -> Int16? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodes to Int32 values for a specified key + func decode(_ type: Int32.Type, forKey key: K) throws -> Int32 { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodes to optional Int32 values for a specified key + func decodeIfPresent(_ type: Int32.Type, forKey key: K) throws -> Int32? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodes to Int64 values for a specified key + func decode(_ type: Int64.Type, forKey key: K) throws -> Int64 { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodes to optional Int64 values for a specified key + func decodeIfPresent(_ type: Int64.Type, forKey key: K) throws -> Int64? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodes to UInt values for a specified key + func decode(_ type: UInt.Type, forKey key: K) throws -> UInt { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodets to optional UInt values for a specified key + func decodeIfPresent(_ type: UInt.Type, forKey key: K) throws -> UInt? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodets to UInt8 values for a specified key + func decode(_ type: UInt8.Type, forKey key: K) throws -> UInt8 { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodets to optional UInt8 values for a specified key + func decodeIfPresent(_ type: UInt8.Type, forKey key: K) throws -> UInt8? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodets to UInt16 values for a specified key + func decode(_ type: UInt16.Type, forKey key: K) throws -> UInt16 { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodets to optional UInt16 values for a specified key + func decodeIfPresent(_ type: UInt16.Type, forKey key: K) throws -> UInt16? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodets to UInt32 values for a specified key + func decode(_ type: UInt32.Type, forKey key: K) throws -> UInt32 { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodets to optional UInt32 values for a specified key + func decodeIfPresent(_ type: UInt32.Type, forKey key: K) throws -> UInt32? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodets to UInt64 values for a specified key + func decode(_ type: UInt64.Type, forKey key: K) throws -> UInt64 { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodets to optional UInt64 values for a specified key + func decodeIfPresent(_ type: UInt64.Type, forKey key: K) throws -> UInt64? { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + // Decodets to generict T values for a specified key + func decode(_ type: T.Type, forKey key: K) throws -> T where T : Decodable { + try nestedSingleValueDecodingContainer(forKey: key).read(type) + } + // Decodes to optional T values for a specified key + func decodeIfPresent(_ type: T.Type, forKey key: K) throws -> T? where T : Decodable { + try decodeIfPresent(type, forKey: key) { + try decode(type, forKey: key) + } + } + + private func nestedCodingPath(forKey key: CodingKey? = nil) -> [CodingKey] { + if let key = key { + return codingPath + [key] + } + + return codingPath + } + // Provides a nested scale single value decoding container + private func nestedSingleValueDecodingContainer(forKey key: K? = nil) -> ScaleSingleValueDecodingContainer { + ScaleSingleValueDecodingContainer( + decoderProvider: decoderProvider, + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: nestedCodingPath(forKey: key), + userInfo: userInfo + ) + } + // Provides a nested scale keyed decoding container + func nestedContainer( + keyedBy type: NestedKey.Type, + forKey key: K + ) throws -> KeyedDecodingContainer where NestedKey : CodingKey { + let container = ScaleKeyedDecodingContainer( + decoderProvider: decoderProvider, + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + return KeyedDecodingContainer(container) + } + // Provides a nested scale unkeyed decoding container + func nestedUnkeyedContainer(forKey key: K) throws -> UnkeyedDecodingContainer { + try ScaleUnkeyedDecodingContainer( + decoderProvider: decoderProvider, + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + } + + func superDecoder() throws -> Decoder { + decoderProvider.decoder( + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + } + + func superDecoder(forKey key: K) throws -> Decoder { + decoderProvider.decoder( + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: nestedCodingPath(forKey: key), + userInfo: userInfo + ) + } +} diff --git a/ScaleCodecSwift/Classes/Decoder/ScaleSingleValueDecodingContainer.swift b/ScaleCodecSwift/Classes/Decoder/ScaleSingleValueDecodingContainer.swift new file mode 100644 index 0000000..d0232f3 --- /dev/null +++ b/ScaleCodecSwift/Classes/Decoder/ScaleSingleValueDecodingContainer.swift @@ -0,0 +1,126 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +final class ScaleSingleValueDecodingContainer: SingleValueDecodingContainer { + private enum ScaleSingleValueDecodingError: Swift.Error { + case noAdapter + case decodingError + } + + // MARK: - SingleValueDecodingContainer + + var codingPath: [CodingKey] + let userInfo: [CodingUserInfoKey: Any] + + // MARK: - Init + + private let decoderProvider: ScaleDecoderProvider + private var dataReader: DataReader + private let adapterProvider: ScaleCodecAdapterProvider + + init( + decoderProvider: ScaleDecoderProvider, + dataReader: DataReader, + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey], + userInfo: [CodingUserInfoKey: Any] + ) { + self.decoderProvider = decoderProvider + self.dataReader = dataReader + self.adapterProvider = adapterProvider + self.codingPath = codingPath + self.userInfo = userInfo + } + + // MARK: - Decoding + // Decodes nil values + func decodeNil() -> Bool { + do { + let result = (((try dataReader.read(size: 1).first.map { $0 == 0b0 }) as Bool??)) == true + dataReader.offset -= 1 + + return result + } catch { + assertionFailure() + return false + } + } + // Decodes Bool types + func decode(_ type: Bool.Type) throws -> Bool { + try read(type) + } + // Decodes String types + func decode(_ type: String.Type) throws -> String { + try read(type) + } + // Decodes Int types + func decode(_ type: Int.Type) throws -> Int { + try read(type) + } + // Decodes Int8 types + func decode(_ type: Int8.Type) throws -> Int8 { + try read(type) + } + // Decodes Int16 types + func decode(_ type: Int16.Type) throws -> Int16 { + try read(type) + } + // Decodes Int32 types + func decode(_ type: Int32.Type) throws -> Int32 { + try read(type) + } + // Decodes Int64 types + func decode(_ type: Int64.Type) throws -> Int64 { + try read(type) + } + // Decodes UInt types + func decode(_ type: UInt.Type) throws -> UInt { + try read(type) + } + // Decodes UInt8 types + func decode(_ type: UInt8.Type) throws -> UInt8 { + try read(type) + } + // Decodes UInt16 types + func decode(_ type: UInt16.Type) throws -> UInt16 { + try read(type) + } + // Decodes UInt32 types + func decode(_ type: UInt32.Type) throws -> UInt32 { + try read(type) + } + // Decodes UInt64 types + func decode(_ type: UInt64.Type) throws -> UInt64 { + try read(type) + } + // Decodes generic T types + func decode(_ type: T.Type) throws -> T { + try read(type) + } + + // MARK: - Private + // Reads generic T types + func read(_ type: T.Type) throws -> T { + try adapterProvider.coder.decoder.decode( + T.self, + from: dataReader + ) + } +} diff --git a/ScaleCodecSwift/Classes/Decoder/ScaleUnkeyedDecodingContainer.swift b/ScaleCodecSwift/Classes/Decoder/ScaleUnkeyedDecodingContainer.swift new file mode 100644 index 0000000..a57540d --- /dev/null +++ b/ScaleCodecSwift/Classes/Decoder/ScaleUnkeyedDecodingContainer.swift @@ -0,0 +1,238 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +final class ScaleUnkeyedDecodingContainer: UnkeyedDecodingContainer { + + // MARK: - UnkeyedDecodingContainer + + var codingPath: [CodingKey] + let userInfo: [CodingUserInfoKey: Any] + + var count: Int? = nil + var isAtEnd: Bool { + count.map { $0 == currentIndex } ?? true + } + var currentIndex = 0 + + // MARK: - Init + + private let decoderProvider: ScaleDecoderProvider + private let dataReader: DataReader + private let adapterProvider: ScaleCodecAdapterProvider + + init( + decoderProvider: ScaleDecoderProvider, + dataReader: DataReader, + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey], + userInfo: [CodingUserInfoKey: Any] + ) throws { + self.decoderProvider = decoderProvider + self.dataReader = dataReader + self.adapterProvider = adapterProvider + self.codingPath = codingPath + self.userInfo = userInfo + + currentIndex = 0 // drop index after reading count + } + + // MARK: - Decoding + + private func decodeIfPresent(_ type: T.Type, decoder: () throws -> T) throws -> T? { + let isPresent = try nestedSingleValueDecodingContainer().decode(Bool.self) + return isPresent ? try decoder() : nil + } + + // Decodes nil value + func decodeNil() throws -> Bool { + nestedSingleValueDecodingContainer().decodeNil() + } + // Decodes to Bool type + func decode(_ type: Bool.Type) throws -> Bool { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional Bool type + func decodeIfPresent(_ type: Bool.Type) throws -> Bool? { + try nestedSingleValueDecodingContainer().read(Bool?.self) + } + // Decodes to String type + func decode(_ type: String.Type) throws -> String { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional String type + func decodeIfPresent(_ type: String.Type) throws -> String? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to Int type + func decode(_ type: Int.Type) throws -> Int { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional Int type + func decodeIfPresent(_ type: Int.Type) throws -> Int? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to Int8 type + func decode(_ type: Int8.Type) throws -> Int8 { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional Int8 type + func decodeIfPresent(_ type: Int8.Type) throws -> Int8? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to Int16 type + func decode(_ type: Int16.Type) throws -> Int16 { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional Int16 type + func decodeIfPresent(_ type: Int16.Type) throws -> Int16? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to Int32 type + func decode(_ type: Int32.Type) throws -> Int32 { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional Int32 type + func decodeIfPresent(_ type: Int32.Type) throws -> Int32? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to Int64 type + func decode(_ type: Int64.Type) throws -> Int64 { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional In64 type + func decodeIfPresent(_ type: Int64.Type) throws -> Int64? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to UInt type + func decode(_ type: UInt.Type) throws -> UInt { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional UInt type + func decodeIfPresent(_ type: UInt.Type) throws -> UInt? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to UInt8 type + func decode(_ type: UInt8.Type) throws -> UInt8 { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional UInt8 type + func decodeIfPresent(_ type: UInt8.Type) throws -> UInt8? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to UInt16 type + func decode(_ type: UInt16.Type) throws -> UInt16 { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional UInt16 type + func decodeIfPresent(_ type: UInt16.Type) throws -> UInt16? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to UInt32 type + func decode(_ type: UInt32.Type) throws -> UInt32 { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional UInt32 type + func decodeIfPresent(_ type: UInt32.Type) throws -> UInt32? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to UInt64 type + func decode(_ type: UInt64.Type) throws -> UInt64 { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional UInt64 type + func decodeIfPresent(_ type: UInt64.Type) throws -> UInt64? { + try decodeIfPresent(type) { + try decode(type) + } + } + // Decodes to generic T type + func decode(_ type: T.Type) throws -> T where T : Decodable { + try nestedSingleValueDecodingContainer().read(type) + } + // Decodes to optional generic T type + func decodeIfPresent(_ type: T.Type) throws -> T? where T : Decodable { + try decodeIfPresent(type) { + try decode(type) + } + } + // Provides a nested single value decoding container + private func nestedSingleValueDecodingContainer() -> ScaleSingleValueDecodingContainer { + currentIndex += 1 + return ScaleSingleValueDecodingContainer( + decoderProvider: decoderProvider, + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + } + // Provides a nested scale keyed decoding container + func nestedContainer( + keyedBy type: NestedKey.Type + ) throws -> KeyedDecodingContainer where NestedKey : CodingKey { + let container = ScaleKeyedDecodingContainer( + decoderProvider: decoderProvider, + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + return KeyedDecodingContainer(container) + } + // Provides a nested scale unkeyed decoding container + func nestedUnkeyedContainer() throws -> UnkeyedDecodingContainer { + try ScaleUnkeyedDecodingContainer( + decoderProvider: decoderProvider, + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + } + + func superDecoder() throws -> Decoder { + decoderProvider.decoder( + dataReader: dataReader, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + } +} diff --git a/ScaleCodecSwift/Classes/Encoder/ScaleEncoder.swift b/ScaleCodecSwift/Classes/Encoder/ScaleEncoder.swift new file mode 100644 index 0000000..7f526a5 --- /dev/null +++ b/ScaleCodecSwift/Classes/Encoder/ScaleEncoder.swift @@ -0,0 +1,187 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// A default interface for providing encoding functionality +protocol ScaleEncoding { + /// Encodes value of type `T` to Data + /// - Parameters: + /// - value: A value of type `T` that needs to be encoded + /// - Returns: An encoded Data + func encode(_ value: T) throws -> Data where T : Encodable +} + +/// An interface that contains Data that needs to be encoded +protocol ScaleEncodingContainer { + var data: Data { get } +} + +/// An interface for encoder provider +protocol ScaleEncoderProvider { + /// Provides an encoder + /// - Parameters: + /// - codingPath: An array of `CodingKey` objects + /// - userInfo: A dict containing user-defined `CodingUserInfoKey` as keys + /// - Returns: An encoder container + func encoder( + codingPath: [CodingKey], + userInfo: [CodingUserInfoKey: Any] + ) -> Encoder & ScaleEncodingContainer +} + +extension ScaleEncoderProvider { + // A default implementation of the protocol's method + func encoder(codingPath: [CodingKey]) -> Encoder & ScaleEncodingContainer{ + encoder(codingPath: codingPath, userInfo: [:]) + } + + // Encoding without coding paths + func encoder(userInfo: [CodingUserInfoKey: Any]) -> Encoder & ScaleEncodingContainer { + encoder(codingPath: [], userInfo: userInfo) + } + + // Encoding without coding paths and user info + func encoder() -> Encoder & ScaleEncodingContainer { + encoder(codingPath: [], userInfo: [:]) + } +} + +// MARK: - Encoding, ScaleEncoderProvider +/// Handles scale encoding +public final class ScaleEncoder: ScaleEncoding, ScaleEncoderProvider { + private let codingPath: [CodingKey] + private let userInfo: [CodingUserInfoKey: Any] + private let adapterProvider: ScaleCodecAdapterProvider + + /// Creates a scale encoder + /// - Parameters: + /// - adapterProvider: An object that provides adapters based on a type being encoded + /// - codingPath: An array of `CodingKey` objects + /// - userInfo: A dict containing user-defined `CodingUserInfoKey` as keys + public init( + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey] = [], + userInfo: [CodingUserInfoKey: Any] = [:] + ) { + self.adapterProvider = adapterProvider + self.codingPath = codingPath + self.userInfo = userInfo + } + + /// Initializes `ScaleEncoderContainer` which provides a specific container (keyed, unkeyed and single value) based on a type that needs to be encoded + /// - Parameters: + /// - codingPath: An array of `CodingKey` objects + /// - userInfo: A dict containing user-defined + /// - Returns: `ScaleEncoderContainer` + func encoder( + codingPath: [CodingKey], + userInfo: [CodingUserInfoKey: Any] + ) -> Encoder & ScaleEncodingContainer { + ScaleEncoderContainer( + provider: self, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + } + + /// Encodes a generic type `T` + /// - Parameters: + /// - value: A value of a generic type `T`. T should conform to `Encodable` protocol + /// - Returns: Encoded `Data` + public func encode(_ value: T) throws -> Data { + if let data = try? adapterProvider.adapter(for: T.self).write(value: value) { + // Types like Ints, Strings etc will be resolved via their custom adapters + // Types with custom optional adapters will be resolved here as well (the main cause of this 'if' condition) + // Other types will be resolved via GenericAdapter though types like array and all other optionals will be resolved + // via their custom adapters + // Struct, Enums will throw 'No adapter found' error thus should be resolved via basic containers + return data + } + + let encoder = encoder() + + try value.encode(to: encoder) + return encoder.data + } +} + +// MARK: - ScaleEncoderContainer +private final class ScaleEncoderContainer: Encoder, ScaleEncodingContainer { + var codingPath: [CodingKey] + var userInfo: [CodingUserInfoKey: Any] + + private let provider: ScaleEncoderProvider + private var container: ScaleEncodingContainer? + private let adapterProvider: ScaleCodecAdapterProvider + + fileprivate var data: Data { + container?.data ?? Data() + } + + fileprivate init( + provider: ScaleEncoderProvider, + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey] = [], + userInfo: [CodingUserInfoKey: Any] = [:]) { + self.provider = provider + self.adapterProvider = adapterProvider + self.codingPath = codingPath + self.userInfo = userInfo + } + + // Returns a keyed encoding container + func container(keyedBy type: Key.Type) -> KeyedEncodingContainer where Key : CodingKey { + let container = ScaleKeyedEncodingContainer( + encoderProvider: provider, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + + self.container = container + return KeyedEncodingContainer(container) + } + + // Returns an unkeyed encoding container + func unkeyedContainer() -> UnkeyedEncodingContainer { + let container = ScaleUnkeyedEncodingContainer( + encoderProvider: provider, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + + self.container = container + return container + } + + // Returns a single value encoding container + func singleValueContainer() -> SingleValueEncodingContainer { + let container = ScaleSingleValueEncodingContainer( + encoderProvider: provider, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + + self.container = container + return container + } +} diff --git a/ScaleCodecSwift/Classes/Encoder/ScaleKeyedEncodingContainer.swift b/ScaleCodecSwift/Classes/Encoder/ScaleKeyedEncodingContainer.swift new file mode 100644 index 0000000..4269283 --- /dev/null +++ b/ScaleCodecSwift/Classes/Encoder/ScaleKeyedEncodingContainer.swift @@ -0,0 +1,277 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +final class ScaleKeyedEncodingContainer: KeyedEncodingContainerProtocol, ScaleEncodingContainer { + + // MARK: - KeyedEncodingContainerProtocol + + typealias Key = K + + let codingPath: [CodingKey] + let userInfo: [CodingUserInfoKey: Any] + + // MARK: - ScaleEncodingContainer + + private var keys: [K] = [] + private var containers: [ScaleEncodingContainer] = [] + private let adapterProvider: ScaleCodecAdapterProvider + + var data: Data { + containers.reduce(Data()) { $0 + $1.data } + } + + // MARK: - Init + + private let encoderProvider: ScaleEncoderProvider + + init( + encoderProvider: ScaleEncoderProvider, + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey] = [], + userInfo: [CodingUserInfoKey: Any] = [:] + ) { + self.encoderProvider = encoderProvider + self.adapterProvider = adapterProvider + self.codingPath = codingPath + self.userInfo = userInfo + + encodeIndexIfNeeded() + } + + // This method is used only for Enums + private func encodeIndexIfNeeded() { + guard let index = codingPath.first?.intValue else { + return + } + + do { + try nestedSingleValueEncodingContainer().encode(UInt8(index)) + } catch { + assertionFailure() + } + } + + // MARK: - Encoding + + // Encodes generic optional values for a specified key + private func encodeIfPresent(_ value: T?, forKey key: K, encoder: (T) throws -> Void) throws { + if let value = value { + try nestedSingleValueEncodingContainer(forKey: key).encodeNotNil() + try encoder(value) + } else { + try nestedSingleValueEncodingContainer(forKey: key).encodeNil() + } + } + + // Encodes nil values for a specified key + func encodeNil(forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encodeNil() + } + + // Encodes Bool values for a specified key + func encode(_ value: Bool, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional Bool values for a specified key + func encodeIfPresent(_ value: Bool?, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes String values for a specified key + func encode(_ value: String, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional String values for a specified key + func encodeIfPresent(_ value: String?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes Int values for a specified key + func encode(_ value: Int, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional Int values for a specified key + func encodeIfPresent(_ value: Int?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes Int8 values for a specified key + func encode(_ value: Int8, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional Int8 values for a specified key + func encodeIfPresent(_ value: Int8?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes Int16 values for a specified key + func encode(_ value: Int16, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional Int16 values for a specified key + func encodeIfPresent(_ value: Int16?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes Int32 values for a specified key + func encode(_ value: Int32, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional Int32 values for a specified key + func encodeIfPresent(_ value: Int32?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes Int64 values for a specified key + func encode(_ value: Int64, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional Int64 values for a specified key + func encodeIfPresent(_ value: Int64?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes UInt values for a specified key + func encode(_ value: UInt, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional UInt values for a specified key + func encodeIfPresent(_ value: UInt?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes UInt8 values for a specified key + func encode(_ value: UInt8, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional UInt8 values for a specified key + func encodeIfPresent(_ value: UInt8?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes UInt16 values for a specified key + func encode(_ value: UInt16, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional UInt16 values for a specified key + func encodeIfPresent(_ value: UInt16?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes UInt32 values for a specified key + func encode(_ value: UInt32, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional UInt32 values for a specified key + func encodeIfPresent(_ value: UInt32?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes UInt64 values for a specified key + func encode(_ value: UInt64, forKey key: K) throws { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional UInt64 values for a specified key + func encodeIfPresent(_ value: UInt64?, forKey key: K) throws { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + // Encodes generic T values for a specified key + func encode(_ value: T, forKey key: K) throws where T : Encodable { + try nestedSingleValueEncodingContainer(forKey: key).encode(value) + } + // Encodes optional T values for a specified key + func encodeIfPresent(_ value: T?, forKey key: K) throws where T : Encodable { + try encodeIfPresent(value, forKey: key) { + try encode($0, forKey: key) + } + } + + private func nestedCodingPath(forKey key: CodingKey? = nil) -> [CodingKey] { + if let key = key { + return codingPath + [key] + } + + return codingPath + } + + // Provides a nested scale single value encoding container + private func nestedSingleValueEncodingContainer(forKey key: K? = nil, append: Bool = true) -> ScaleSingleValueEncodingContainer { + let container = ScaleSingleValueEncodingContainer( + encoderProvider: encoderProvider, + adapterProvider: adapterProvider, + codingPath: nestedCodingPath(forKey: key), + userInfo: userInfo + ) + + if append { + containers.append(container) + } + + return container + } + + // Provides a nested scale keyed encoding container + func nestedContainer( + keyedBy keyType: NestedKey.Type, + forKey key: K + ) -> KeyedEncodingContainer where NestedKey : CodingKey { + let container = ScaleKeyedEncodingContainer( + encoderProvider: encoderProvider, + adapterProvider: adapterProvider, + codingPath: nestedCodingPath(forKey: key), + userInfo: userInfo + ) + + containers.append(container) + return KeyedEncodingContainer(container) + } + + // Provides a nested scale unkeyed encoding container + func nestedUnkeyedContainer(forKey key: K) -> UnkeyedEncodingContainer { + let container = ScaleUnkeyedEncodingContainer( + encoderProvider: encoderProvider, + adapterProvider: adapterProvider, + codingPath: nestedCodingPath(forKey: key), + userInfo: userInfo + ) + + containers.append(container) + return container + } + + func superEncoder() -> Encoder { + encoderProvider.encoder(codingPath: codingPath, userInfo: userInfo) + } + + func superEncoder(forKey key: K) -> Encoder { + encoderProvider.encoder(codingPath: nestedCodingPath(forKey: key), userInfo: userInfo) + } +} diff --git a/ScaleCodecSwift/Classes/Encoder/ScaleSingleValueEncodingContainer.swift b/ScaleCodecSwift/Classes/Encoder/ScaleSingleValueEncodingContainer.swift new file mode 100644 index 0000000..e764d79 --- /dev/null +++ b/ScaleCodecSwift/Classes/Encoder/ScaleSingleValueEncodingContainer.swift @@ -0,0 +1,148 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +final class ScaleSingleValueEncodingContainer: SingleValueEncodingContainer, ScaleEncodingContainer { + private enum ScaleSingleValueEncodingError: Swift.Error { + case noAdapter + } + + // MARK: - SingleValueEncodingContainer + + let codingPath: [CodingKey] + let userInfo: [CodingUserInfoKey: Any] + + // MARK: - ScaleEncodingContainer + + private var _data: Data? + private let adapterProvider: ScaleCodecAdapterProvider + var data: Data { _data ?? Data() } + + // MARK: - Init + + private let encoderProvider: ScaleEncoderProvider + + init( + encoderProvider: ScaleEncoderProvider, + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey] = [], + userInfo: [CodingUserInfoKey: Any] = [:] + ) { + self.encoderProvider = encoderProvider + self.adapterProvider = adapterProvider + self.codingPath = codingPath + self.userInfo = userInfo + } + + // MARK: - Encoding + // Checks whether the provided value can be encoded or not + private func checkCanEncode(value: Any?) throws { + guard _data == nil else { + let context = EncodingError.Context( + codingPath: codingPath, + debugDescription: "Single value container already contains encoded value" + ) + + throw EncodingError.invalidValue(value as Any, context) + } + } + + // Encodes nil values + func encodeNil() throws { + try checkCanEncode(value: nil) + _data = Data([0]) + } + // Encodes not nil values + func encodeNotNil() throws { + try checkCanEncode(value: nil) + _data = Data([1]) + } + // Encodes Bool values + func encode(_ value: Bool) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes optional Bool values + func encode(_ value: Bool?) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes Int values + func encode(_ value: Int) throws { + try checkCanEncode(value: value) + _data = try write(value) + + } + // Encodes Int8 values + func encode(_ value: Int8) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes Int16 values + func encode(_ value: Int16) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes Int32 values + func encode(_ value: Int32) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes Int64 values + func encode(_ value: Int64) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes UInt values + func encode(_ value: UInt) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes UInt8 values + func encode(_ value: UInt8) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes UInt16 values + func encode(_ value: UInt16) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes UInt32 values + func encode(_ value: UInt32) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes UInt64 values + func encode(_ value: UInt64) throws { + try checkCanEncode(value: value) + _data = try write(value) + } + // Encodes generic T values + func encode(_ value: T) throws where T : Encodable { + try checkCanEncode(value: value) + _data = try write(value) + } + + // MARK: - Private + // Writes generic T types + func write(_ value: T) throws -> Data { + try adapterProvider.coder.encoder.encode(value) + } +} diff --git a/ScaleCodecSwift/Classes/Encoder/ScaleUnkeyedEncodingContainer.swift b/ScaleCodecSwift/Classes/Encoder/ScaleUnkeyedEncodingContainer.swift new file mode 100644 index 0000000..9592dcf --- /dev/null +++ b/ScaleCodecSwift/Classes/Encoder/ScaleUnkeyedEncodingContainer.swift @@ -0,0 +1,149 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +final class ScaleUnkeyedEncodingContainer: UnkeyedEncodingContainer, ScaleEncodingContainer { + + // MARK: - UnkeyedEncodingContainer + + let codingPath: [CodingKey] + let userInfo: [CodingUserInfoKey: Any] + + var count: Int { containers.count} + + // MARK: - ScaleEncodingContainer + + private var containers: [ScaleEncodingContainer] = [] + + var data: Data { + containers.reduce(Data()) { $0 + $1.data } + } + + // MARK: - Init + + private let encoderProvider: ScaleEncoderProvider + private let adapterProvider: ScaleCodecAdapterProvider + + init( + encoderProvider: ScaleEncoderProvider, + adapterProvider: ScaleCodecAdapterProvider, + codingPath: [CodingKey] = [], + userInfo: [CodingUserInfoKey: Any] = [:] + ) { + self.encoderProvider = encoderProvider + self.adapterProvider = adapterProvider + self.codingPath = codingPath + self.userInfo = userInfo + } + + // MARK: - Encoding + + // Encodes nil values using nested single value encoding container + func encodeNil() throws { + try nestedSingleValueEncodingContainer().encodeNil() + } + // Encodes Bool values using nested single value encoding container + func encode(_ value: Bool) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes String values using nested single value encoding container + func encode(_ value: String) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes Int values using nested single value encoding container + func encode(_ value: Int) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes Int8 values using nested single value encoding container + func encode(_ value: Int8) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes Int16 values using nested single value encoding container + func encode(_ value: Int16) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes Int32 values using nested single value encoding container + func encode(_ value: Int32) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes Int64 values using nested single value encoding container + func encode(_ value: Int64) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes UInt values using nested single value encoding container + func encode(_ value: UInt) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes UInt8 values using nested single value encoding container + func encode(_ value: UInt8) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes UInt16 values using nested single value encoding container + func encode(_ value: UInt16) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes UInt32 values using nested single value encoding container + func encode(_ value: UInt32) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes UInt64 values using nested single value encoding container + func encode(_ value: UInt64) throws { + try nestedSingleValueEncodingContainer().encode(value) + } + // Encodes generic T values using nested single value encoding container + func encode(_ value: T) throws where T : Encodable { + try nestedSingleValueEncodingContainer().encode(value) + } + // Provides a nested single value encoding container + private func nestedSingleValueEncodingContainer() throws -> ScaleSingleValueEncodingContainer { + let container = ScaleSingleValueEncodingContainer( + encoderProvider: encoderProvider, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + + containers.append(container) + return container + } + // Provides a nested scale keyed encoding container + func nestedContainer( + keyedBy keyType: NestedKey.Type + ) -> KeyedEncodingContainer where NestedKey : CodingKey { + KeyedEncodingContainer(ScaleKeyedEncodingContainer( + encoderProvider: encoderProvider, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo) + ) + } + // Provides a nested unkeyed encoding container + func nestedUnkeyedContainer() -> UnkeyedEncodingContainer { + ScaleUnkeyedEncodingContainer( + encoderProvider: encoderProvider, + adapterProvider: adapterProvider, + codingPath: codingPath, + userInfo: userInfo + ) + } + + func superEncoder() -> Encoder { + encoderProvider.encoder(codingPath: codingPath, userInfo: userInfo) + } +} diff --git a/ScaleCodecSwift/Classes/ReplaceMe.swift b/ScaleCodecSwift/Classes/ReplaceMe.swift deleted file mode 100644 index e69de29..0000000 diff --git a/ScaleCodecSwift/Classes/Scale/AdapterProvider/AdapterProvider.swift b/ScaleCodecSwift/Classes/Scale/AdapterProvider/AdapterProvider.swift new file mode 100644 index 0000000..31351b1 --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/AdapterProvider/AdapterProvider.swift @@ -0,0 +1,37 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation +import CommonSwift + +/// Handles providing or creating of a `ScaleCodecAdapter` object +public struct AdapterProvider { + let instance: (any ScaleCodecAdaptable)? + let factory: ScaleCodecAdapterFactory? + + public init(instance: (any ScaleCodecAdaptable)? = nil, factory: ScaleCodecAdapterFactory? = nil) { + self.instance = instance + self.factory = factory + } + + /// Creates or provides an existing (under it's `instance` property) adapter + /// - Returns: An adapter either created or cached + public func adapter() -> ScaleCodecAdapter? { + (instance as? ScaleCodecAdapter) ?? (factory?.make() as? ScaleCodecAdapter) ?? nil + } +} diff --git a/ScaleCodecSwift/Classes/Scale/AdapterProvider/DefaultAdapterProvider/DefaultGenericAdapterProviderFactory.swift b/ScaleCodecSwift/Classes/Scale/AdapterProvider/DefaultAdapterProvider/DefaultGenericAdapterProviderFactory.swift new file mode 100644 index 0000000..6dbe0c0 --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/AdapterProvider/DefaultAdapterProvider/DefaultGenericAdapterProviderFactory.swift @@ -0,0 +1,34 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// An adapter provider factory for a generic type +struct DefaultGenericAdapterProviderFactory: ScaleCodecAdapterFactory { + private let coder: ScaleCoder + + init(coder: ScaleCoder) { + self.coder = coder + } + + /// Makes a generic adapter for a generic type `T` + /// - Returns: A generic adapter for a generic type `T` + func make() -> ScaleCodecAdapter { + DefaultGenericAdapter(coder: coder) + } +} diff --git a/ScaleCodecSwift/Classes/Scale/AdapterProvider/DefaultAdapterProvider/DefaultScaleCodecAdapterProvider.swift b/ScaleCodecSwift/Classes/Scale/AdapterProvider/DefaultAdapterProvider/DefaultScaleCodecAdapterProvider.swift new file mode 100644 index 0000000..1da81cc --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/AdapterProvider/DefaultAdapterProvider/DefaultScaleCodecAdapterProvider.swift @@ -0,0 +1,147 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation +import CommonSwift + +/// Default scale codec adapter provider which provides adapter for the main by default supported types. The adapters for those types are set during the provider's initialization, so no additional step is required for that. +/// Also, the coder for the provider can be accessed directly +final public class DefaultScaleCodecAdapterProvider: ScaleCodecAdapterProvider { + override public init() { + super.init() + + // Bool + provideBool() + provideOptionalBool() + + // Int + provideInt8() + provideInt16() + provideInt32() + provideInt() + provideInt64() + provideInt128() + provideInt256() + provideInt512() + + // UInt + provideUInt8() + provideUInt16() + provideUInt32() + provideUInt() + provideUInt64() + provideUInt128() + provideUInt256() + provideUInt512() + + // String + provideString() + + // Generic + provideGeneric() + + // Data + provideData() + } + + // Methods for setting adapters for specific types + private func provideBool() { + setAdapter(BoolAdapter(), for: Bool.self) + } + + private func provideOptionalBool() { + setAdapter(OptionalBoolAdapter(), for: Bool?.self) + } + + private func provideInt8() { + setAdapter(NumericAdapter(), for: Int8.self) + } + + private func provideInt16() { + setAdapter(NumericAdapter(), for: Int16.self) + } + + private func provideInt32() { + setAdapter(NumericAdapter(), for: Int32.self) + } + + private func provideInt() { + setAdapter(NumericAdapter(), for: Int.self) + } + + private func provideInt64() { + setAdapter(NumericAdapter(), for: Int64.self) + } + + private func provideUInt8() { + setAdapter(NumericAdapter(), for: UInt8.self) + } + + private func provideUInt16() { + setAdapter(NumericAdapter(), for: UInt16.self) + } + + private func provideUInt32() { + setAdapter(NumericAdapter(), for: UInt32.self) + } + + private func provideUInt() { + setAdapter(NumericAdapter(), for: UInt.self) + } + + private func provideUInt64() { + setAdapter(NumericAdapter(), for: UInt64.self) + } + + private func provideInt128() { + setAdapter(Int128Adapter(), for: Int128.self) + } + + private func provideUInt128() { + setAdapter( UInt128Adapter(), for: UInt128.self) + } + + private func provideInt256() { + setAdapter(Int256Adapter(), for: Int256.self) + } + + private func provideUInt256() { + setAdapter(UInt256Adapter(), for: UInt256.self) + } + + private func provideInt512() { + setAdapter(Int512Adapter(), for: Int512.self) + } + + private func provideUInt512() { + setAdapter(UInt512Adapter(), for: UInt512.self) + } + + private func provideString() { + setAdapter(StringAdapter(coder: coder), for: String.self) + } + + private func provideData() { + setAdapter(DataAdapter(coder: coder), for: Data.self) + setAdapter(ScaleEncodedDataAdapter(), for: ScaleEncodedData.self) + } + + private func provideGeneric() { + addGenericAdapter(DefaultGenericAdapterProviderFactory(coder: coder)) + } +} diff --git a/ScaleCodecSwift/Classes/Scale/AdapterProvider/ScaleCodecAdapterProvider/ScaleCodecAdapterFactory.swift b/ScaleCodecSwift/Classes/Scale/AdapterProvider/ScaleCodecAdapterProvider/ScaleCodecAdapterFactory.swift new file mode 100644 index 0000000..e2ea629 --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/AdapterProvider/ScaleCodecAdapterProvider/ScaleCodecAdapterFactory.swift @@ -0,0 +1,26 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// Scale codec adapter factory interface +public protocol ScaleCodecAdapterFactory { + /// Makes an adapter for a generic type `T` + /// - Returns: An adapter for a generic type `T` + func make() -> ScaleCodecAdapter +} diff --git a/ScaleCodecSwift/Classes/Scale/AdapterProvider/ScaleCodecAdapterProvider/ScaleCodecAdapterProvider.swift b/ScaleCodecSwift/Classes/Scale/AdapterProvider/ScaleCodecAdapterProvider/ScaleCodecAdapterProvider.swift new file mode 100644 index 0000000..42c0b7d --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/AdapterProvider/ScaleCodecAdapterProvider/ScaleCodecAdapterProvider.swift @@ -0,0 +1,107 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// Adapter provider that provides adapters based on the specified types +open class ScaleCodecAdapterProvider { + /// Error cases that might appear while attempting to provide an adapter for a specified type + enum Error: Swift.Error { + case noOptionalAdapterProvided + case noGenericAdapterProvided + case noAdapterFound + } + + private var adapters: [TypeWrapper: AdapterProvider] = [:] + private var genericAdapters: [AdapterProvider] = [] + + private var matchCache: [TypeWrapper: AdapterProvider] = [:] + + lazy var coder = ScaleCoder(adapterProvider: self) + + public init() { } + + /// Provides an adapter for a specified type + /// - Parameters: + /// - type: A generic type for which an adapter should be found + /// - Returns: An adapter for a provided type + public func adapter(for type: T.Type) throws -> ScaleCodecAdapter { + if let adapter = (try adapterProvider(for: type)?.adapter()) as? ScaleCodecAdapter { + return adapter + } + + return genericAdapter(for: type) + } + + /// Provides a generic adapter for a specified custom (or not directlye supported) type + /// - Parameters: + /// - type: A generic type for which an adapter should be found + /// - Returns: A generic adapter for a provided custom (or not directly supported) type + private func genericAdapter(for type: T.Type) -> ScaleCodecAdapter { + GenericAdapter(providers: genericAdapters) { [weak self] provider in + self?.matchCache[TypeWrapper(type: type)] = provider + } + } + + /// Provides an adapter provider for a specified type + /// - Parameters: + /// - type: A generic type for which an adapter provider should be found + /// - Returns: An adapter provider for a provided type + private func adapterProvider(for type: T.Type) throws -> AdapterProvider? { + if let provider = matchCache[TypeWrapper(type: type)] { + return provider + } + + return adapters[TypeWrapper(type: type)] + } + + /// Caches an adapter for a specified type + /// - Parameters: + /// - adapter: An adapter to cache + /// - type: A type for which it needs to be cached + public func setAdapter(_ adapter: ScaleCodecAdapter, for type: T.Type) { + adapters[TypeWrapper(type: type)] = .init(instance: adapter) + } + + /// Caches an adapter using a factory for a specified type + /// - Parameters: + /// - factory: A factory from which an adapter is created later + /// - type: A type for which it needs to be cached + public func setAdapter(_ factory: ScaleCodecAdapterFactory, for type: T.Type) { + adapters[TypeWrapper(type: type)] = .init(factory: factory) + } + + /// Caches a generic adapter + /// - Parameters: + /// - factory: A factory from which an adapter is created later + public func addGenericAdapter(_ factory: ScaleCodecAdapterFactory) { + genericAdapters.append(.init(factory: factory)) + } +} + +// MARK: - Private + +private extension ScaleCodecAdapterProvider { + var encoder: ScaleEncoder { + coder.encoder + } + + var decoder: ScaleDecoder { + coder.decoder + } +} diff --git a/ScaleCodecSwift/Classes/Scale/AdapterProvider/TypeWrapper.swift b/ScaleCodecSwift/Classes/Scale/AdapterProvider/TypeWrapper.swift new file mode 100644 index 0000000..b64ad2f --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/AdapterProvider/TypeWrapper.swift @@ -0,0 +1,33 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// A wrapper over a type. The wrapper conforms to `Hashable` protocol, +/// since it is used as a key when caching adapters +struct TypeWrapper: Hashable { + let type: Any.Type + + func hash(into hasher: inout Hasher) { + String(describing: type).hash(into: &hasher) + } + + static func == (lhs: TypeWrapper, rhs: TypeWrapper) -> Bool { + lhs.hashValue == rhs.hashValue + } +} diff --git a/ScaleCodecSwift/Classes/Scale/DataReader.swift b/ScaleCodecSwift/Classes/Scale/DataReader.swift new file mode 100644 index 0000000..ae9297d --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/DataReader.swift @@ -0,0 +1,77 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// Handles `Data` reading +public final class DataReader { + private enum Error: Swift.Error { + case invalidDataOffset + } + + /// Actual data to read + public let data: Data + /// An offset that shows how much has been read + public var offset = 0 + private var lastReadSize = 0 + + public init(data: Data) { + self.data = data + } + + public var dataWithOffset: Data { + data[offset.. [UInt8] { + let endIndex = offset + size + + guard endIndex <= data.count else { + throw Error.invalidDataOffset + } + + let result = data[offset.. UInt8 { + try read(size: 1)[0] + } + /// Reads data till the end + /// /// - Returns: A byte array as result of reading the `Data` + public func readToEnd() throws -> [UInt8] { + try read(size: data.count - offset) + } + + /// Reverts the offset + public func revert(offset: Int) { + self.offset -= offset + } + /// Reverts the offset to the last read size + public func revertLast() { + revert(offset: lastReadSize) + } +} diff --git a/ScaleCodecSwift/Classes/Scale/GenericAdapter/DefaultGenericAdapter.swift b/ScaleCodecSwift/Classes/Scale/GenericAdapter/DefaultGenericAdapter.swift new file mode 100644 index 0000000..f1234ff --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/GenericAdapter/DefaultGenericAdapter.swift @@ -0,0 +1,58 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// Generic adapter used for custom types that do not have their own adapter +public final class DefaultGenericAdapter: ScaleCodecAdapter { + private let coder: ScaleCoder + + public init(coder: ScaleCoder) { + self.coder = coder + } + + /// Reads (decodes) data to specified type + /// - Parameters: + /// - type: The type to which should attempt to decode the data + /// - reader: DataReader which contains the data that needs to be decoded and handles reading it + /// - Returns: Decoded value of the provided type + public override func read(_ type: T.Type?, from reader: DataReader) throws -> T { + if let type = type as? ScaleGenericCodable.Type { + if let value = try type.init(from: reader, coder: coder) as? T { + return value + } else { + // Shouldn't happen + assertionFailure() + } + } + + throw ScaleCodecAdapterProvider.Error.noAdapterFound + } + + /// Writes (encodes) the value + /// - Parameters: + /// - value: The value to encode + /// - Returns: The encoded Data + public override func write(value: T) throws -> Data { + if let value = value as? ScaleGenericCodable { + return try value.write(coder: coder) + } + + throw ScaleCodecAdapterProvider.Error.noAdapterFound + } +} diff --git a/ScaleCodecSwift/Classes/Scale/GenericAdapter/GenericAdapter.swift b/ScaleCodecSwift/Classes/Scale/GenericAdapter/GenericAdapter.swift new file mode 100644 index 0000000..9fab138 --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/GenericAdapter/GenericAdapter.swift @@ -0,0 +1,62 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +final class GenericAdapter: ScaleCodecAdapter { + private let providers: [AdapterProvider] + private let onMatch: (AdapterProvider) -> Void + + init(providers: [AdapterProvider], onMatch: @escaping (AdapterProvider) -> Void) { + self.providers = providers + self.onMatch = onMatch + super.init() + } + + override func read(_ type: T.Type?, from reader: DataReader) throws -> T { + for provider in providers { + let offsetBeforeTry = reader.offset + do { + guard let adapter = provider.adapter() as? ScaleCodecAdapter else { continue } + let value = try adapter.read(type, from: reader) + onMatch(provider) + return value + } catch { + // Reset offset to position before failed reading + reader.offset = offsetBeforeTry + } + } + + throw ScaleCodecAdapterProvider.Error.noAdapterFound + } + + override func write(value: T) throws -> Data { + for provider in providers { + do { + guard let adapter = provider.adapter() as? ScaleCodecAdapter else { continue } + let data = try adapter.write(value: value) + onMatch(provider) + return data + } catch { + // For debugging purpose + } + } + + throw ScaleCodecAdapterProvider.Error.noAdapterFound + } +} diff --git a/ScaleCodecSwift/Classes/Scale/GenericAdapter/ScaleGenericCodable.swift b/ScaleCodecSwift/Classes/Scale/GenericAdapter/ScaleGenericCodable.swift new file mode 100644 index 0000000..39caf4c --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/GenericAdapter/ScaleGenericCodable.swift @@ -0,0 +1,33 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// An interface for a type that can be handled by `GenericAdapter` +protocol ScaleGenericCodable { + /// An initializer of the type + /// - Parameters: + /// - reader: DataReader with a data to encode/decode + /// - coder: + init(from reader: DataReader, coder: ScaleCoder) throws + /// Writes (encodes) a scale generic codable value via encoder + /// - Parameters: + /// - coder: A coder that encodes the generic codable value + /// - Returns: An encoded Data + func write(coder: ScaleCoder) throws -> Data +} diff --git a/ScaleCodecSwift/Classes/Scale/ScaleCodecAdapter.swift b/ScaleCodecSwift/Classes/Scale/ScaleCodecAdapter.swift new file mode 100644 index 0000000..9cb2d5f --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/ScaleCodecAdapter.swift @@ -0,0 +1,63 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// A default protocol to which all values used in `ScaleCodecAdapter` should conform +public protocol ScaleCodecAdaptable { + func tryRead(from reader: DataReader) throws -> Any + func tryWrite(value: Any) throws -> Data +} + +/// Provides a default interface for adapters +open class ScaleCodecAdapter: ScaleCodecAdaptable { + enum Error: Swift.Error { + case typeMismatch + } + + public init() {} + + /// Reads (decodes) data to specified type + /// - Parameters: + /// - type: The type to which should attempt to decode the data + /// - reader: DataReader which contains the data that needs to be decoded and handles reading it + /// - Returns: Decoded value of the provided type + open func read(_ type: T.Type?, from reader: DataReader) throws -> T { + fatalError("not implemented") + } + + public func tryRead(from reader: DataReader) throws -> Any { + return try read(nil, from: reader) + } + + /// Writes (encodes) the value + /// - Parameters: + /// - value: The value to encode + /// - Returns: The encoded Data + open func write(value: T) throws -> Data { + fatalError("not implemented") + } + + public func tryWrite(value: Any) throws -> Data { + guard let value = value as? T else { + throw Error.typeMismatch + } + + return try write(value: value) + } +} diff --git a/ScaleCodecSwift/Classes/Scale/ScaleCodecTransaction.swift b/ScaleCodecSwift/Classes/Scale/ScaleCodecTransaction.swift new file mode 100644 index 0000000..877512a --- /dev/null +++ b/ScaleCodecSwift/Classes/Scale/ScaleCodecTransaction.swift @@ -0,0 +1,44 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// Handles Scale Codec transaction for `Codable` types. Provides an mechanism for encoding and appending multiple +/// values, conforming to `Codable` and decode them. +public final class ScaleCodecTransaction { + private let encoder: ScaleEncoder + private var data = Data() + + init(encoder: ScaleEncoder) { + self.encoder = encoder + } + + /// Appends additional `Codable` objects to existing encoded data + /// - Returns: Returns `self` with updated encoded data + @discardableResult + public func append(_ value: T) throws -> Self { + data += try encoder.encode(value) + return self + } + + /// Decodes the existing encoded data + /// - Returns: An accumulated data of previously encoded objects + public func commit() -> Data { + data + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array1.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array1.swift new file mode 100644 index 0000000..0bf0064 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array1.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array1 + Encodable + +/// An array with 1 element +@propertyWrapper public struct Array1 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array1 + Encodable + +extension Array1: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 1 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array1 + Decodable + +extension Array1: Decodable where Element : Decodable { + /// Creates a fixed array with 1 element using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<1).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array10.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array10.swift new file mode 100644 index 0000000..7c32fea --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array10.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array10 + Encodable + +/// An array with 10 elements +@propertyWrapper public struct Array10 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array10 + Encodable + +extension Array10: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 10 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array10 + Decodable + +extension Array10: Decodable where Element : Decodable { + /// Creates a fixed array with 10 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<10).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array100.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array100.swift new file mode 100644 index 0000000..f5aeccb --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array100.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array100 + Encodable + +/// An array with 100 elements +@propertyWrapper public struct Array100 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array100 + Encodable + +extension Array100: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 100 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array100 + Decodable + +extension Array100: Decodable where Element : Decodable { + /// Creates a fixed array with 100 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<100).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array101.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array101.swift new file mode 100644 index 0000000..7c924fb --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array101.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array101 + Encodable + +/// An array with 101 elements +@propertyWrapper public struct Array101 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array101 + Encodable + +extension Array101: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 101 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array101 + Decodable + +extension Array101: Decodable where Element : Decodable { + /// Creates a fixed array with 101 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<101).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array102.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array102.swift new file mode 100644 index 0000000..699ce51 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array102.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array102 + Encodable + +/// An array with 102 elements +@propertyWrapper public struct Array102 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array102 + Encodable + +extension Array102: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 102 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array102 + Decodable + +extension Array102: Decodable where Element : Decodable { + /// Creates a fixed array with 102 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<102).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array103.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array103.swift new file mode 100644 index 0000000..8d0bfa5 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array103.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array103 + Encodable + +/// An array with 103 elements +@propertyWrapper public struct Array103 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array103 + Encodable + +extension Array103: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 103 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array103 + Decodable + +extension Array103: Decodable where Element : Decodable { + /// Creates a fixed array with 103 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<103).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array104.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array104.swift new file mode 100644 index 0000000..a45a202 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array104.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array104 + Encodable + +/// An array with 104 elements +@propertyWrapper public struct Array104 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array104 + Encodable + +extension Array104: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 104 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array104 + Decodable + +extension Array104: Decodable where Element : Decodable { + /// Creates a fixed array with 104 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<104).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array105.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array105.swift new file mode 100644 index 0000000..600a9f7 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array105.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array105 + Encodable + +/// An array with 105 elements +@propertyWrapper public struct Array105 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array105 + Encodable + +extension Array105: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 105 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array105 + Decodable + +extension Array105: Decodable where Element : Decodable { + /// Creates a fixed array with 105 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<105).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array106.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array106.swift new file mode 100644 index 0000000..6894e79 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array106.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array106 + Encodable + +/// An array with 106 elements +@propertyWrapper public struct Array106 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array106 + Encodable + +extension Array106: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 106 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array106 + Decodable + +extension Array106: Decodable where Element : Decodable { + /// Creates a fixed array with 106 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<106).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array107.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array107.swift new file mode 100644 index 0000000..b58755d --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array107.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array107 + Encodable + +/// An array with 107 elements +@propertyWrapper public struct Array107 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array107 + Encodable + +extension Array107: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 107 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array107 + Decodable + +extension Array107: Decodable where Element : Decodable { + /// Creates a fixed array with 107 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<107).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array108.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array108.swift new file mode 100644 index 0000000..e4e748a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array108.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array108 + Encodable + +/// An array with 108 elements +@propertyWrapper public struct Array108 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array108 + Encodable + +extension Array108: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 108 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array108 + Decodable + +extension Array108: Decodable where Element : Decodable { + /// Creates a fixed array with 108 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<108).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array109.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array109.swift new file mode 100644 index 0000000..62fe921 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array109.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array109 + Encodable + +/// An array with 109 elements +@propertyWrapper public struct Array109 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array109 + Encodable + +extension Array109: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 109 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array109 + Decodable + +extension Array109: Decodable where Element : Decodable { + /// Creates a fixed array with 109 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<109).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array11.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array11.swift new file mode 100644 index 0000000..ba58e4b --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array11.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array11 + Encodable + +/// An array with 11 elements +@propertyWrapper public struct Array11 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array11 + Encodable + +extension Array11: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 11 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array11 + Decodable + +extension Array11: Decodable where Element : Decodable { + /// Creates a fixed array with 11 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<11).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array110.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array110.swift new file mode 100644 index 0000000..d9a9f7c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array110.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array110 + Encodable + +/// An array with 110 elements +@propertyWrapper public struct Array110 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array110 + Encodable + +extension Array110: Encodable where Element : Encodable { + // Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 110 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array110 + Decodable + +extension Array110: Decodable where Element : Decodable { + /// Creates a fixed array with 110 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<110).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array111.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array111.swift new file mode 100644 index 0000000..9226c24 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array111.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array111 + Encodable + +/// An array with 111 elements +@propertyWrapper public struct Array111 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array111 + Encodable + +extension Array111: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 111 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array111 + Decodable + +extension Array111: Decodable where Element : Decodable { + /// Creates a fixed array with 111 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<111).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array112.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array112.swift new file mode 100644 index 0000000..9e7b4b8 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array112.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array112 + Encodable + +/// An array with 112 elements +@propertyWrapper public struct Array112 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array112 + Encodable + +extension Array112: Encodable where Element : Encodable { + // Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 112 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array112 + Decodable + +extension Array112: Decodable where Element : Decodable { + /// Creates a fixed array with 112 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<112).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array113.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array113.swift new file mode 100644 index 0000000..5994dec --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array113.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array113 + Encodable + +/// An array with 113 elements +@propertyWrapper public struct Array113 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array113 + Encodable + +extension Array113: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 113 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array113 + Decodable + +extension Array113: Decodable where Element : Decodable { + /// Creates a fixed array with 113 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<113).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array114.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array114.swift new file mode 100644 index 0000000..ecaaf95 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array114.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array114 + Encodable + +/// An array with 114 elements +@propertyWrapper public struct Array114 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array114 + Encodable + +extension Array114: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 114 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array114 + Decodable + +extension Array114: Decodable where Element : Decodable { + /// Creates a fixed array with 114 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<114).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array115.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array115.swift new file mode 100644 index 0000000..f51d14b --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array115.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array115 + Encodable + +/// An array with 115 elements +@propertyWrapper public struct Array115 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array115 + Encodable + +extension Array115: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 115 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array115 + Decodable + +extension Array115: Decodable where Element : Decodable { + /// Creates a fixed array with 115 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<115).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array116.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array116.swift new file mode 100644 index 0000000..d8aa95b --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array116.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array116 + Encodable + +/// An array with 116 elements +@propertyWrapper public struct Array116 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array116 + Encodable + +extension Array116: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 116 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array116 + Decodable + +extension Array116: Decodable where Element : Decodable { + /// Creates a fixed array with 116 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<116).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array117.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array117.swift new file mode 100644 index 0000000..4476e8a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array117.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array117 + Encodable + +/// An array with 117 elements +@propertyWrapper public struct Array117 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array117 + Encodable + +extension Array117: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 117 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array117 + Decodable + +extension Array117: Decodable where Element : Decodable { + /// Creates a fixed array with 117 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<117).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array118.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array118.swift new file mode 100644 index 0000000..1f2e088 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array118.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array118 + Encodable + +/// An array with 118 elements +@propertyWrapper public struct Array118 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array118 + Encodable + +extension Array118: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 118 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array118 + Decodable + +extension Array118: Decodable where Element : Decodable { + /// Creates a fixed array with 118 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<118).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array119.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array119.swift new file mode 100644 index 0000000..0746839 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array119.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array119 + Encodable + +/// An array with 119 elements +@propertyWrapper public struct Array119 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array119 + Encodable + +extension Array119: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 119 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array119 + Decodable + +extension Array119: Decodable where Element : Decodable { + /// Creates a fixed array with 119 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<119).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array12.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array12.swift new file mode 100644 index 0000000..a0f7561 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array12.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array12 + Encodable + +/// An array with 12 elements +@propertyWrapper public struct Array12 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array12 + Encodable + +extension Array12: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 12 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array12 + Decodable + +extension Array12: Decodable where Element : Decodable { + /// Creates a fixed array with 12 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<12).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array120.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array120.swift new file mode 100644 index 0000000..3c4c92b --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array120.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array120 + Encodable + +/// An array with 120 elements +@propertyWrapper public struct Array120 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array120 + Encodable + +extension Array120: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 120 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array120 + Decodable + +extension Array120: Decodable where Element : Decodable { + /// Creates a fixed array with 120 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<120).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array121.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array121.swift new file mode 100644 index 0000000..492023f --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array121.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array121 + Encodable + +/// An array with 121 elements +@propertyWrapper public struct Array121 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array121 + Encodable + +extension Array121: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 121 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array121 + Decodable + +extension Array121: Decodable where Element : Decodable { + /// Creates a fixed array with 121 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<121).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array122.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array122.swift new file mode 100644 index 0000000..453e57c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array122.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array122 + Encodable + +/// An array with 122 elements +@propertyWrapper public struct Array122 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array122 + Encodable + +extension Array122: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 122 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array122 + Decodable + +extension Array122: Decodable where Element : Decodable { + /// Creates a fixed array with 122 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<122).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array123.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array123.swift new file mode 100644 index 0000000..b0b2b40 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array123.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array123 + Encodable + +/// An array with 123 elements +@propertyWrapper public struct Array123 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array123 + Encodable + +extension Array123: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 123 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array123 + Decodable + +extension Array123: Decodable where Element : Decodable { + /// Creates a fixed array with 123 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<123).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array124.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array124.swift new file mode 100644 index 0000000..99e3271 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array124.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array124 + Encodable + +/// An array with 124 elements +@propertyWrapper public struct Array124 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array124 + Encodable + +extension Array124: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 124 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array124 + Decodable + +extension Array124: Decodable where Element : Decodable { + /// Creates a fixed array with 124 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<124).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array125.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array125.swift new file mode 100644 index 0000000..0722ded --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array125.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array125 + Encodable + +/// An array with 125 elements +@propertyWrapper public struct Array125 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array125 + Encodable + +extension Array125: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 125 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array125 + Decodable + +extension Array125: Decodable where Element : Decodable { + /// Creates a fixed array with 125 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<125).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array126.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array126.swift new file mode 100644 index 0000000..101c6b4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array126.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array126 + Encodable + +/// An array with 126 elements +@propertyWrapper public struct Array126 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array126 + Encodable + +extension Array126: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 126 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array126 + Decodable + +extension Array126: Decodable where Element : Decodable { + // Creates a fixed array with 126 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<126).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array127.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array127.swift new file mode 100644 index 0000000..8d45d5d --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array127.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array127 + Encodable + +/// An array with 127 elements +@propertyWrapper public struct Array127 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array127 + Encodable + +extension Array127: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 127 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array127 + Decodable + +extension Array127: Decodable where Element : Decodable { + /// Creates a fixed array with 127 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<127).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array128.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array128.swift new file mode 100644 index 0000000..0bd50ac --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array128.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array128 + Encodable + +/// An array with 128 elements +@propertyWrapper public struct Array128 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array128 + Encodable + +extension Array128: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 128 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array128 + Decodable + +extension Array128: Decodable where Element : Decodable { + /// Creates a fixed array with 128 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<128).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array129.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array129.swift new file mode 100644 index 0000000..1033982 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array129.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array129 + Encodable + +/// An array with 129 elements +@propertyWrapper public struct Array129 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array129 + Encodable + +extension Array129: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 129 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array129 + Decodable + +extension Array129: Decodable where Element : Decodable { + /// Creates a fixed array with 129 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<129).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array13.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array13.swift new file mode 100644 index 0000000..2d88f7c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array13.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array13 + Encodable + +/// An array with 13 elements +@propertyWrapper public struct Array13 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array13 + Encodable + +extension Array13: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 13 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array13 + Decodable + +extension Array13: Decodable where Element : Decodable { + /// Creates a fixed array with 13 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<13).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array130.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array130.swift new file mode 100644 index 0000000..21e2938 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array130.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array130 + Encodable + +/// An array with 130 elements +@propertyWrapper public struct Array130 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array130 + Encodable + +extension Array130: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 130 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array130 + Decodable + +extension Array130: Decodable where Element : Decodable { + /// Creates a fixed array with 130 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<130).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array131.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array131.swift new file mode 100644 index 0000000..0c4e6ff --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array131.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array131 + Encodable + +/// An array with 131 elements +@propertyWrapper public struct Array131 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array131 + Encodable + +extension Array131: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 131 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array131 + Decodable + +extension Array131: Decodable where Element : Decodable { + /// Creates a fixed array with 131 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<131).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array132.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array132.swift new file mode 100644 index 0000000..1d23073 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array132.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array132 + Encodable + +/// An array with 132 elements +@propertyWrapper public struct Array132 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array132 + Encodable + +extension Array132: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 132 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array132 + Decodable + +extension Array132: Decodable where Element : Decodable { + /// Creates a fixed array with 132 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<132).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array133.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array133.swift new file mode 100644 index 0000000..c30a4b4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array133.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array133 + Encodable + +/// An array with 133 elements +@propertyWrapper public struct Array133 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array133 + Encodable + +extension Array133: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 133 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array133 + Decodable + +extension Array133: Decodable where Element : Decodable { + /// Creates a fixed array with 133 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<133).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array134.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array134.swift new file mode 100644 index 0000000..fdbb1d1 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array134.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array134 + Encodable + +/// An array with 134 elements +@propertyWrapper public struct Array134 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array134 + Encodable + +extension Array134: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 134 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array134 + Decodable + +extension Array134: Decodable where Element : Decodable { + /// Creates a fixed array with 134 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<134).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array135.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array135.swift new file mode 100644 index 0000000..7b57286 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array135.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array135 + Encodable + +/// An array with 135 elements +@propertyWrapper public struct Array135 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array135 + Encodable + +extension Array135: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 135 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array135 + Decodable + +extension Array135: Decodable where Element : Decodable { + /// Creates a fixed array with 135 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<135).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array136.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array136.swift new file mode 100644 index 0000000..fe6c194 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array136.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array136 + Encodable + +/// An array with 136 elements +@propertyWrapper public struct Array136 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array136 + Encodable + +extension Array136: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 136 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array136 + Decodable + +extension Array136: Decodable where Element : Decodable { + /// Creates a fixed array with 136 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<136).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array137.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array137.swift new file mode 100644 index 0000000..4cd3881 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array137.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array137 + Encodable + +/// An array with 137 elements +@propertyWrapper public struct Array137 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array137 + Encodable + +extension Array137: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 137 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array137 + Decodable + +extension Array137: Decodable where Element : Decodable { + /// Creates a fixed array with 137 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<137).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array138.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array138.swift new file mode 100644 index 0000000..96e790e --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array138.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array138 + Encodable + +/// An array with 138 elements +@propertyWrapper public struct Array138 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array138 + Encodable + +extension Array138: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 138 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array138 + Decodable + +extension Array138: Decodable where Element : Decodable { + /// Creates a fixed array with 138 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<138).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array139.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array139.swift new file mode 100644 index 0000000..fd3163f --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array139.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array139 + Encodable + +/// An array with 139 elements +@propertyWrapper public struct Array139 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array139 + Encodable + +extension Array139: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 139 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array139 + Decodable + +extension Array139: Decodable where Element : Decodable { + /// Creates a fixed array with 139 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<139).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array14.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array14.swift new file mode 100644 index 0000000..5ee2215 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array14.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array14 + Encodable + +/// An array with 14 elements +@propertyWrapper public struct Array14 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array14 + Encodable + +extension Array14: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 14 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array14 + Decodable + +extension Array14: Decodable where Element : Decodable { + /// Creates a fixed array with 14 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<14).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array140.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array140.swift new file mode 100644 index 0000000..1d506e4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array140.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array140 + Encodable + +/// An array with 140 elements +@propertyWrapper public struct Array140 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array140 + Encodable + +extension Array140: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 140 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array140 + Decodable + +extension Array140: Decodable where Element : Decodable { + /// Creates a fixed array with 140 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<140).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array141.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array141.swift new file mode 100644 index 0000000..233dd63 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array141.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array141 + Encodable + +/// An array with 141 elements +@propertyWrapper public struct Array141 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array141 + Encodable + +extension Array141: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 141 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array141 + Decodable + +extension Array141: Decodable where Element : Decodable { + /// Creates a fixed array with 141 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<141).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array142.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array142.swift new file mode 100644 index 0000000..cc74682 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array142.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array142 + Encodable + +/// An array with 142 elements +@propertyWrapper public struct Array142 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array142 + Encodable + +extension Array142: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 142 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array142 + Decodable + +extension Array142: Decodable where Element : Decodable { + /// Creates a fixed array with 142 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<142).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array143.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array143.swift new file mode 100644 index 0000000..e1acf5f --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array143.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array143 + Encodable + +/// An array with 143 elements +@propertyWrapper public struct Array143 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array143 + Encodable + +extension Array143: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 143 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array143 + Decodable + +extension Array143: Decodable where Element : Decodable { + /// Creates a fixed array with 143 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<143).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array144.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array144.swift new file mode 100644 index 0000000..2b97674 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array144.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array144 + Encodable + +/// An array with 144 elements +@propertyWrapper public struct Array144 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array144 + Encodable + +extension Array144: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 144 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array144 + Decodable + +extension Array144: Decodable where Element : Decodable { + /// Creates a fixed array with 144 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<144).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array145.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array145.swift new file mode 100644 index 0000000..1e3ddd1 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array145.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array145 + Encodable + +/// An array with 145 elements +@propertyWrapper public struct Array145 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array145 + Encodable + +extension Array145: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 145 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array145 + Decodable + +extension Array145: Decodable where Element : Decodable { + /// Creates a fixed array with 145 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<145).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array146.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array146.swift new file mode 100644 index 0000000..1b7c181 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array146.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array146 + Encodable + +/// An array with 146 elements +@propertyWrapper public struct Array146 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array146 + Encodable + +extension Array146: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 146 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array146 + Decodable + +extension Array146: Decodable where Element : Decodable { + /// Creates a fixed array with 146 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<146).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array147.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array147.swift new file mode 100644 index 0000000..843fca9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array147.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array147 + Encodable + +/// An array with 147 elements +@propertyWrapper public struct Array147 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array147 + Encodable + +extension Array147: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 147 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array147 + Decodable + +extension Array147: Decodable where Element : Decodable { + /// Creates a fixed array with 147 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<147).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array148.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array148.swift new file mode 100644 index 0000000..93a7566 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array148.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array148 + Encodable + +/// An array with 148 elements +@propertyWrapper public struct Array148 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array148 + Encodable + +extension Array148: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 148 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array148 + Decodable + +extension Array148: Decodable where Element : Decodable { + /// Creates a fixed array with 148 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<148).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array149.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array149.swift new file mode 100644 index 0000000..69ad35c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array149.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array149 + Encodable + +/// An array with 149 elements +@propertyWrapper public struct Array149 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array149 + Encodable + +extension Array149: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 149 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array149 + Decodable + +extension Array149: Decodable where Element : Decodable { + /// Creates a fixed array with 149 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<149).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array15.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array15.swift new file mode 100644 index 0000000..ae055e9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array15.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array15 + Encodable + +/// An array with 15 elements +@propertyWrapper public struct Array15 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array15 + Encodable + +extension Array15: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 15 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array15 + Decodable + +extension Array15: Decodable where Element : Decodable { + /// Creates a fixed array with 15 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<15).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array150.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array150.swift new file mode 100644 index 0000000..b608794 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array150.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array150 + Encodable + +/// An array with 150 elements +@propertyWrapper public struct Array150 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array150 + Encodable + +extension Array150: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 150 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array150 + Decodable + +extension Array150: Decodable where Element : Decodable { + /// Creates a fixed array with 150 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<150).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array151.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array151.swift new file mode 100644 index 0000000..c414a09 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array151.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array151 + Encodable + +/// An array with 151 elements +@propertyWrapper public struct Array151 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array151 + Encodable + +extension Array151: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 151 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array151 + Decodable + +extension Array151: Decodable where Element : Decodable { + /// Creates a fixed array with 151 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<151).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array152.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array152.swift new file mode 100644 index 0000000..df1a8ca --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array152.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array152 + Encodable + +/// An array with 152 elements +@propertyWrapper public struct Array152 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array152 + Encodable + +extension Array152: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 152 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array152 + Decodable + +extension Array152: Decodable where Element : Decodable { + /// Creates a fixed array with 152 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<152).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array153.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array153.swift new file mode 100644 index 0000000..4439e86 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array153.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array153 + Encodable + +/// An array with 153 elements +@propertyWrapper public struct Array153 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array153 + Encodable + +extension Array153: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 153 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array153 + Decodable + +extension Array153: Decodable where Element : Decodable { + /// Creates a fixed array with 153 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<153).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array154.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array154.swift new file mode 100644 index 0000000..8cfcb18 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array154.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array154 + Encodable + +/// An array with 154 elements +@propertyWrapper public struct Array154 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array154 + Encodable + +extension Array154: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 154 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array154 + Decodable + +extension Array154: Decodable where Element : Decodable { + /// Creates a fixed array with 154 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<154).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array155.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array155.swift new file mode 100644 index 0000000..35c2970 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array155.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array155 + Encodable + +/// An array with 155 elements +@propertyWrapper public struct Array155 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array155 + Encodable + +extension Array155: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 155 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array155 + Decodable + +extension Array155: Decodable where Element : Decodable { + /// Creates a fixed array with 155 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<155).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array156.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array156.swift new file mode 100644 index 0000000..80cbc22 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array156.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array156 + Encodable + +/// An array with 156 elements +@propertyWrapper public struct Array156 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array156 + Encodable + +extension Array156: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 156 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array156 + Decodable + +extension Array156: Decodable where Element : Decodable { + /// Creates a fixed array with 156 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<156).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array157.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array157.swift new file mode 100644 index 0000000..3c28ee3 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array157.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array157 + Encodable + +/// An array with 157 elements +@propertyWrapper public struct Array157 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array157 + Encodable + +extension Array157: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 157 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array157 + Decodable + +extension Array157: Decodable where Element : Decodable { + /// Creates a fixed array with 157 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<157).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array158.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array158.swift new file mode 100644 index 0000000..e7b90fa --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array158.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array158 + Encodable + +/// An array with 158 elements +@propertyWrapper public struct Array158 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array158 + Encodable + +extension Array158: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 158 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array158 + Decodable + +extension Array158: Decodable where Element : Decodable { + /// Creates a fixed array with 158 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<158).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array159.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array159.swift new file mode 100644 index 0000000..cef9eef --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array159.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array159 + Encodable + +/// An array with 159 elements +@propertyWrapper public struct Array159 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array159 + Encodable + +extension Array159: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 159 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array159 + Decodable + +extension Array159: Decodable where Element : Decodable { + /// Creates a fixed array with 159 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<159).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array16.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array16.swift new file mode 100644 index 0000000..dd60c87 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array16.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array16 + Encodable + +/// An array with 16 elements +@propertyWrapper public struct Array16 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array16 + Encodable + +extension Array16: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 16 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array16 + Decodable + +extension Array16: Decodable where Element : Decodable { + /// Creates a fixed array with 16 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<16).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array160.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array160.swift new file mode 100644 index 0000000..65e6bc9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array160.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array160 + Encodable + +/// An array with 160 elements +@propertyWrapper public struct Array160 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array160 + Encodable + +extension Array160: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 160 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array160 + Decodable + +extension Array160: Decodable where Element : Decodable { + /// Creates a fixed array with 160 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<160).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array161.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array161.swift new file mode 100644 index 0000000..6fccc79 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array161.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array161 + Encodable + +/// An array with 161 elements +@propertyWrapper public struct Array161 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array161 + Encodable + +extension Array161: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 161 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array161 + Decodable + +extension Array161: Decodable where Element : Decodable { + /// Creates a fixed array with 161 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<161).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array162.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array162.swift new file mode 100644 index 0000000..c57b33d --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array162.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array162 + Encodable + +/// An array with 162 elements +@propertyWrapper public struct Array162 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array162 + Encodable + +extension Array162: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 162 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array162 + Decodable + +extension Array162: Decodable where Element : Decodable { + /// Creates a fixed array with 162 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<162).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array163.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array163.swift new file mode 100644 index 0000000..34163c3 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array163.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array163 + Encodable + +/// An array with 163 elements +@propertyWrapper public struct Array163 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array163 + Encodable + +extension Array163: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 163 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array163 + Decodable + +extension Array163: Decodable where Element : Decodable { + /// Creates a fixed array with 163 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<163).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array164.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array164.swift new file mode 100644 index 0000000..687add8 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array164.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array164 + Encodable + +/// An array with 164 elements +@propertyWrapper public struct Array164 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array164 + Encodable + +extension Array164: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 164 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array164 + Decodable + +extension Array164: Decodable where Element : Decodable { + /// Creates a fixed array with 164 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<164).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array165.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array165.swift new file mode 100644 index 0000000..a7e206d --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array165.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array165 + Encodable + +/// An array with 165 elements +@propertyWrapper public struct Array165 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array165 + Encodable + +extension Array165: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 165 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array165 + Decodable + +extension Array165: Decodable where Element : Decodable { + /// Creates a fixed array with 165 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<165).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array166.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array166.swift new file mode 100644 index 0000000..14e8f66 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array166.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array166 + Encodable + +/// An array with 166 elements +@propertyWrapper public struct Array166 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array166 + Encodable + +extension Array166: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 166 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array166 + Decodable + +extension Array166: Decodable where Element : Decodable { + /// Creates a fixed array with 166 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<166).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array167.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array167.swift new file mode 100644 index 0000000..782486d --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array167.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array167 + Encodable + +/// An array with 167 elements +@propertyWrapper public struct Array167 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array167 + Encodable + +extension Array167: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 167 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array167 + Decodable + +extension Array167: Decodable where Element : Decodable { + /// Creates a fixed array with 167 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<167).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array168.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array168.swift new file mode 100644 index 0000000..b3319ea --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array168.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array168 + Encodable + +/// An array with 168 elements +@propertyWrapper public struct Array168 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array168 + Encodable + +extension Array168: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 168 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array168 + Decodable + +extension Array168: Decodable where Element : Decodable { + /// Creates a fixed array with 168 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<168).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array169.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array169.swift new file mode 100644 index 0000000..e9f305e --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array169.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array169 + Encodable + +/// An array with 169 elements +@propertyWrapper public struct Array169 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array169 + Encodable + +extension Array169: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 169 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array169 + Decodable + +extension Array169: Decodable where Element : Decodable { + /// Creates a fixed array with 169 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<169).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array17.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array17.swift new file mode 100644 index 0000000..2dcfe25 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array17.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array17 + Encodable + +/// An array with 17 elements +@propertyWrapper public struct Array17 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array17 + Encodable + +extension Array17: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 17 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array17 + Decodable + +extension Array17: Decodable where Element : Decodable { + /// Creates a fixed array with 17 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<17).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array170.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array170.swift new file mode 100644 index 0000000..f2151a6 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array170.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array170 + Encodable + +/// An array with 170 elements +@propertyWrapper public struct Array170 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array170 + Encodable + +extension Array170: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 170 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array170 + Decodable + +extension Array170: Decodable where Element : Decodable { + /// Creates a fixed array with 170 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<170).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array171.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array171.swift new file mode 100644 index 0000000..98d3572 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array171.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array171 + Encodable + +/// An array with 171 elements +@propertyWrapper public struct Array171 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array171 + Encodable + +extension Array171: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 171 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array171 + Decodable + +extension Array171: Decodable where Element : Decodable { + /// Creates a fixed array with 171 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<171).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array172.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array172.swift new file mode 100644 index 0000000..df082e2 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array172.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array172 + Encodable + +/// An array with 172 elements +@propertyWrapper public struct Array172 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array172 + Encodable + +extension Array172: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 172 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array172 + Decodable + +extension Array172: Decodable where Element : Decodable { + /// Creates a fixed array with 172 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<172).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array173.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array173.swift new file mode 100644 index 0000000..218e973 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array173.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array173 + Encodable + +/// An array with 173 elements +@propertyWrapper public struct Array173 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array173 + Encodable + +extension Array173: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 173 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array173 + Decodable + +extension Array173: Decodable where Element : Decodable { + /// Creates a fixed array with 173 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<173).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array174.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array174.swift new file mode 100644 index 0000000..e86b03a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array174.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array174 + Encodable + +/// An array with 174 elements +@propertyWrapper public struct Array174 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array174 + Encodable + +extension Array174: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 174 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array174 + Decodable + +extension Array174: Decodable where Element : Decodable { + /// Creates a fixed array with 174 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<174).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array175.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array175.swift new file mode 100644 index 0000000..3acdc06 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array175.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array175 + Encodable + +/// An array with 175 elements +@propertyWrapper public struct Array175 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array175 + Encodable + +extension Array175: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 175 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array175 + Decodable + +extension Array175: Decodable where Element : Decodable { + /// Creates a fixed array with 175 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<175).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array176.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array176.swift new file mode 100644 index 0000000..ac3f580 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array176.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array176 + Encodable + +/// An array with 176 elements +@propertyWrapper public struct Array176 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array176 + Encodable + +extension Array176: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 176 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array176 + Decodable + +extension Array176: Decodable where Element : Decodable { + /// Creates a fixed array with 176 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<176).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array177.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array177.swift new file mode 100644 index 0000000..0789114 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array177.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array177 + Encodable + +/// An array with 177 elements +@propertyWrapper public struct Array177 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array177 + Encodable + +extension Array177: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 177 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array177 + Decodable + +extension Array177: Decodable where Element : Decodable { + /// Creates a fixed array with 177 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<177).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array178.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array178.swift new file mode 100644 index 0000000..0c5ead7 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array178.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array178 + Encodable + +/// An array with 178 elements +@propertyWrapper public struct Array178 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array178 + Encodable + +extension Array178: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 178 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array178 + Decodable + +extension Array178: Decodable where Element : Decodable { + /// Creates a fixed array with 178 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<178).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array179.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array179.swift new file mode 100644 index 0000000..a578dc8 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array179.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array179 + Encodable + +/// An array with 179 elements +@propertyWrapper public struct Array179 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array179 + Encodable + +extension Array179: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 179 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array179 + Decodable + +extension Array179: Decodable where Element : Decodable { + /// Creates a fixed array with 179 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<179).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array18.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array18.swift new file mode 100644 index 0000000..50eb072 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array18.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array18 + Encodable + +/// An array with 18 elements +@propertyWrapper public struct Array18 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array18 + Encodable + +extension Array18: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 18 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array18 + Decodable + +extension Array18: Decodable where Element : Decodable { + /// Creates a fixed array with 18 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<18).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array180.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array180.swift new file mode 100644 index 0000000..4bd528b --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array180.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array180 + Encodable + +/// An array with 180 elements +@propertyWrapper public struct Array180 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array180 + Encodable + +extension Array180: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 180 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array180 + Decodable + +extension Array180: Decodable where Element : Decodable { + /// Creates a fixed array with 180 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<180).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array181.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array181.swift new file mode 100644 index 0000000..dedab9c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array181.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array181 + Encodable + +/// An array with 181 elements +@propertyWrapper public struct Array181 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array181 + Encodable + +extension Array181: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 181 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array181 + Decodable + +extension Array181: Decodable where Element : Decodable { + /// Creates a fixed array with 181 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<181).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array182.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array182.swift new file mode 100644 index 0000000..860dcff --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array182.swift @@ -0,0 +1,56 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array182 + Encodable + +/// Creates a fixed array with 182 elements using the provided decoder, by decoding its each element +/// - Parameters: +/// - decoder: Decoder, used to create the array +@propertyWrapper public struct Array182 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array182 + Encodable + +extension Array182: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 182 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array182 + Decodable + +extension Array182: Decodable where Element : Decodable { + /// Creates a fixed array with 182 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<182).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array183.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array183.swift new file mode 100644 index 0000000..d5b1d6e --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array183.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array183 + Encodable + +/// An array with 183 elements +@propertyWrapper public struct Array183 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array183 + Encodable + +extension Array183: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 183 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array183 + Decodable + +extension Array183: Decodable where Element : Decodable { + /// Creates a fixed array with 183 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<183).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array184.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array184.swift new file mode 100644 index 0000000..4b60a76 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array184.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array184 + Encodable + +/// An array with 184 elements +@propertyWrapper public struct Array184 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array184 + Encodable + +extension Array184: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 184 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array184 + Decodable + +extension Array184: Decodable where Element : Decodable { + /// Creates a fixed array with 184 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<184).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array185.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array185.swift new file mode 100644 index 0000000..1538b14 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array185.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array185 + Encodable + +/// An array with 185 elements +@propertyWrapper public struct Array185 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array185 + Encodable + +extension Array185: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 185 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array185 + Decodable + +extension Array185: Decodable where Element : Decodable { + /// Creates a fixed array with 185 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<185).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array186.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array186.swift new file mode 100644 index 0000000..2274088 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array186.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array186 + Encodable + +/// An array with 186 elements +@propertyWrapper public struct Array186 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array186 + Encodable + +extension Array186: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 186 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array186 + Decodable + +extension Array186: Decodable where Element : Decodable { + /// Creates a fixed array with 186 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<186).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array187.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array187.swift new file mode 100644 index 0000000..65ca01c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array187.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array187 + Encodable + +/// An array with 187 elements +@propertyWrapper public struct Array187 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array187 + Encodable + +extension Array187: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 187 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array187 + Decodable + +extension Array187: Decodable where Element : Decodable { + /// Creates a fixed array with 187 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<187).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array188.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array188.swift new file mode 100644 index 0000000..4ac5724 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array188.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array188 + Encodable + +/// An array with 188 elements +@propertyWrapper public struct Array188 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array188 + Encodable + +extension Array188: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 188 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array188 + Decodable + +extension Array188: Decodable where Element : Decodable { + /// Creates a fixed array with 188 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<188).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array189.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array189.swift new file mode 100644 index 0000000..219d7e9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array189.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array189 + Encodable + +/// An array with 189 elements +@propertyWrapper public struct Array189 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array189 + Encodable + +extension Array189: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 189 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array189 + Decodable + +extension Array189: Decodable where Element : Decodable { + /// Creates a fixed array with 189 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<189).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array19.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array19.swift new file mode 100644 index 0000000..f7eac88 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array19.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array19 + Encodable + +/// An array with 19 elements +@propertyWrapper public struct Array19 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array19 + Encodable + +extension Array19: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 19 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array19 + Decodable + +extension Array19: Decodable where Element : Decodable { + /// Creates a fixed array with 19 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<19).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array190.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array190.swift new file mode 100644 index 0000000..70bf08c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array190.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array190 + Encodable + +/// An array with 190 elements +@propertyWrapper public struct Array190 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array190 + Encodable + +extension Array190: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 190 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array190 + Decodable + +extension Array190: Decodable where Element : Decodable { + /// Creates a fixed array with 190 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<190).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array191.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array191.swift new file mode 100644 index 0000000..b4b14a9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array191.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array191 + Encodable + +/// An array with 191 elements +@propertyWrapper public struct Array191 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array191 + Encodable + +extension Array191: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 191 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array191 + Decodable + +extension Array191: Decodable where Element : Decodable { + /// Creates a fixed array with 191 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<191).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array192.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array192.swift new file mode 100644 index 0000000..ae04a74 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array192.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array192 + Encodable + +/// An array with 192 elements +@propertyWrapper public struct Array192 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array192 + Encodable + +extension Array192: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 192 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array192 + Decodable + +extension Array192: Decodable where Element : Decodable { + /// Creates a fixed array with 192 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<192).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array193.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array193.swift new file mode 100644 index 0000000..86dda7e --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array193.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array193 + Encodable + +/// An array with 193 elements +@propertyWrapper public struct Array193 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array193 + Encodable + +extension Array193: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 193 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array193 + Decodable + +extension Array193: Decodable where Element : Decodable { + /// Creates a fixed array with 193 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<193).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array194.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array194.swift new file mode 100644 index 0000000..d528276 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array194.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array194 + Encodable + +/// An array with 194 elements +@propertyWrapper public struct Array194 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array194 + Encodable + +extension Array194: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 194 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array194 + Decodable + +extension Array194: Decodable where Element : Decodable { + /// Creates a fixed array with 194 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<194).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array195.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array195.swift new file mode 100644 index 0000000..40ba115 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array195.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array195 + Encodable + +/// An array with 195 elements +@propertyWrapper public struct Array195 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array195 + Encodable + +extension Array195: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 195 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array195 + Decodable + +extension Array195: Decodable where Element : Decodable { + /// Creates a fixed array with 195 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<195).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array196.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array196.swift new file mode 100644 index 0000000..8968cfa --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array196.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array196 + Encodable + +/// An array with 196 elements +@propertyWrapper public struct Array196 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array196 + Encodable + +extension Array196: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 196 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array196 + Decodable + +extension Array196: Decodable where Element : Decodable { + /// Creates a fixed array with 196 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<196).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array197.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array197.swift new file mode 100644 index 0000000..91c0408 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array197.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array197 + Encodable + +/// An array with 197 elements +@propertyWrapper public struct Array197 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array197 + Encodable + +extension Array197: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 197 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array197 + Decodable + +extension Array197: Decodable where Element : Decodable { + /// Creates a fixed array with 197 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<197).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array198.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array198.swift new file mode 100644 index 0000000..bc965dd --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array198.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array198 + Encodable + +/// An array with 198 elements +@propertyWrapper public struct Array198 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array198 + Encodable + +extension Array198: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 198 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array198 + Decodable + +extension Array198: Decodable where Element : Decodable { + /// Creates a fixed array with 198 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<198).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array199.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array199.swift new file mode 100644 index 0000000..d8a11a3 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array199.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array199 + Encodable + +/// An array with 199 elements +@propertyWrapper public struct Array199 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array199 + Encodable + +extension Array199: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 199 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array199 + Decodable + +extension Array199: Decodable where Element : Decodable { + /// Creates a fixed array with 199 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<199).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array2.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array2.swift new file mode 100644 index 0000000..6dc6c09 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array2.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array2 + Encodable + +/// An array with 2 elements +@propertyWrapper public struct Array2 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array2 + Encodable + +extension Array2: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 2 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array2 + Decodable + +extension Array2: Decodable where Element : Decodable { + /// Creates a fixed array with 2 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<2).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array20.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array20.swift new file mode 100644 index 0000000..8b6317a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array20.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array20 + Encodable + +/// An array with 20 elements +@propertyWrapper public struct Array20 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array20 + Encodable + +extension Array20: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 20 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array20 + Decodable + +extension Array20: Decodable where Element : Decodable { + /// Creates a fixed array with 20 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<20).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array200.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array200.swift new file mode 100644 index 0000000..59760e2 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array200.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array200 + Encodable + +/// An array with 200 elements +@propertyWrapper public struct Array200 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array200 + Encodable + +extension Array200: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 200 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array200 + Decodable + +extension Array200: Decodable where Element : Decodable { + /// Creates a fixed array with 200 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<200).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array201.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array201.swift new file mode 100644 index 0000000..b6691b4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array201.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array201 + Encodable + +/// An array with 201 elements +@propertyWrapper public struct Array201 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array201 + Encodable + +extension Array201: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 201 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array201 + Decodable + +extension Array201: Decodable where Element : Decodable { + /// Creates a fixed array with 201 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<201).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array202.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array202.swift new file mode 100644 index 0000000..cc32a5c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array202.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array202 + Encodable + +/// An array with 202 elements +@propertyWrapper public struct Array202 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array202 + Encodable + +extension Array202: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 202 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array202 + Decodable + +extension Array202: Decodable where Element : Decodable { + /// Creates a fixed array with 202 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<202).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array203.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array203.swift new file mode 100644 index 0000000..2c56973 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array203.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array203 + Encodable + +/// An array with 203 elements +@propertyWrapper public struct Array203 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array203 + Encodable + +extension Array203: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 203 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array203 + Decodable + +extension Array203: Decodable where Element : Decodable { + /// Creates a fixed array with 203 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<203).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array204.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array204.swift new file mode 100644 index 0000000..d1fe3f9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array204.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array204 + Encodable + +/// An array with 204 elements +@propertyWrapper public struct Array204 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array204 + Encodable + +extension Array204: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 204 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array204 + Decodable + +extension Array204: Decodable where Element : Decodable { + /// Creates a fixed array with 204 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<204).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array205.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array205.swift new file mode 100644 index 0000000..75e566a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array205.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array205 + Encodable + +/// An array with 205 elements +@propertyWrapper public struct Array205 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array205 + Encodable + +extension Array205: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 205 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array205 + Decodable + +extension Array205: Decodable where Element : Decodable { + /// Creates a fixed array with 205 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<205).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array206.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array206.swift new file mode 100644 index 0000000..8bf98dc --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array206.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array206 + Encodable + +/// An array with 206 elements +@propertyWrapper public struct Array206 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array206 + Encodable + +extension Array206: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 206 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array206 + Decodable + +extension Array206: Decodable where Element : Decodable { + /// Creates a fixed array with 206 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<206).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array207.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array207.swift new file mode 100644 index 0000000..fc5f731 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array207.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array207 + Encodable + +/// An array with 207 elements +@propertyWrapper public struct Array207 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array207 + Encodable + +extension Array207: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 207 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array207 + Decodable + +extension Array207: Decodable where Element : Decodable { + /// Creates a fixed array with 207 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<207).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array208.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array208.swift new file mode 100644 index 0000000..f6b5e60 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array208.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array208 + Encodable + +/// An array with 208 elements +@propertyWrapper public struct Array208 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array208 + Encodable + +extension Array208: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 208 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array208 + Decodable + +extension Array208: Decodable where Element : Decodable { + /// Creates a fixed array with 208 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<208).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array209.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array209.swift new file mode 100644 index 0000000..3d0c187 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array209.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array209 + Encodable + +/// An array with 209 elements +@propertyWrapper public struct Array209 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array209 + Encodable + +extension Array209: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 209 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array209 + Decodable + +extension Array209: Decodable where Element : Decodable { + /// Creates a fixed array with 209 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<209).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array21.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array21.swift new file mode 100644 index 0000000..e02d7aa --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array21.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array21 + Encodable + +/// An array with 21 elements +@propertyWrapper public struct Array21 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array21 + Encodable + +extension Array21: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 21 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array21 + Decodable + +extension Array21: Decodable where Element : Decodable { + /// Creates a fixed array with 21 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<21).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array210.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array210.swift new file mode 100644 index 0000000..34b0ef4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array210.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array210 + Encodable + +/// An array with 210 elements +@propertyWrapper public struct Array210 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array210 + Encodable + +extension Array210: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 210 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array210 + Decodable + +extension Array210: Decodable where Element : Decodable { + /// Creates a fixed array with 210 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<210).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array211.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array211.swift new file mode 100644 index 0000000..69ea86a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array211.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array211 + Encodable + +/// An array with 211 elements +@propertyWrapper public struct Array211 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array211 + Encodable + +extension Array211: Encodable where Element : Encodable { + // Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 211 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array211 + Decodable + +extension Array211: Decodable where Element : Decodable { + /// Creates a fixed array with 211 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<211).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array212.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array212.swift new file mode 100644 index 0000000..031ec97 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array212.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array212 + Encodable + +/// An array with 100 elements +@propertyWrapper public struct Array212 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array212 + Encodable + +extension Array212: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 212 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array212 + Decodable + +extension Array212: Decodable where Element : Decodable { + /// Creates a fixed array with 212 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<212).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array213.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array213.swift new file mode 100644 index 0000000..0d3ff72 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array213.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array213 + Encodable + +/// An array with 213 elements +@propertyWrapper public struct Array213 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array213 + Encodable + +extension Array213: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 213 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array213 + Decodable + +extension Array213: Decodable where Element : Decodable { + /// Creates a fixed array with 213 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<213).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array214.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array214.swift new file mode 100644 index 0000000..c9518ad --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array214.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array214 + Encodable + +/// An array with 214 elements +@propertyWrapper public struct Array214 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array214 + Encodable + +extension Array214: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 214 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array214 + Decodable + +extension Array214: Decodable where Element : Decodable { + /// Creates a fixed array with 214 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<214).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array215.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array215.swift new file mode 100644 index 0000000..c0a448a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array215.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array215 + Encodable + +/// An array with 215 elements +@propertyWrapper public struct Array215 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array215 + Encodable + +extension Array215: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 215 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array215 + Decodable + +extension Array215: Decodable where Element : Decodable { + /// Creates a fixed array with 215 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<215).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array216.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array216.swift new file mode 100644 index 0000000..1cc7db8 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array216.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array216 + Encodable + +/// An array with 216 elements +@propertyWrapper public struct Array216 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array216 + Encodable + +extension Array216: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 216 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array216 + Decodable + +extension Array216: Decodable where Element : Decodable { + /// Creates a fixed array with 216 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<216).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array217.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array217.swift new file mode 100644 index 0000000..7559cbf --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array217.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array217 + Encodable + +/// An array with 217 elements +@propertyWrapper public struct Array217 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array217 + Encodable + +extension Array217: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 217 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array217 + Decodable + +extension Array217: Decodable where Element : Decodable { + /// Creates a fixed array with 217 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<217).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array218.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array218.swift new file mode 100644 index 0000000..1afb88f --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array218.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array218 + Encodable + +/// An array with 218 elements +@propertyWrapper public struct Array218 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array218 + Encodable + +extension Array218: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 218 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array218 + Decodable + +extension Array218: Decodable where Element : Decodable { + /// Creates a fixed array with 218 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<218).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array219.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array219.swift new file mode 100644 index 0000000..46d0717 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array219.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array219 + Encodable + +/// An array with 219 elements +@propertyWrapper public struct Array219 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array219 + Encodable + +extension Array219: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 219 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array219 + Decodable + +extension Array219: Decodable where Element : Decodable { + /// Creates a fixed array with 219 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<219).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array22.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array22.swift new file mode 100644 index 0000000..846182d --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array22.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array22 + Encodable + +/// An array with 22 elements +@propertyWrapper public struct Array22 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array22 + Encodable + +extension Array22: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 22 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array22 + Decodable + +extension Array22: Decodable where Element : Decodable { + /// Creates a fixed array with 22 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<22).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array220.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array220.swift new file mode 100644 index 0000000..6dbc9e4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array220.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array220 + Encodable + +/// An array with 220 elements +@propertyWrapper public struct Array220 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array220 + Encodable + +extension Array220: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 220 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array220 + Decodable + +extension Array220: Decodable where Element : Decodable { + /// Creates a fixed array with 220 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<220).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array221.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array221.swift new file mode 100644 index 0000000..852db1a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array221.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array221 + Encodable + +/// An array with 221 elements +@propertyWrapper public struct Array221 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array221 + Encodable + +extension Array221: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 221 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array221 + Decodable + +extension Array221: Decodable where Element : Decodable { + /// Creates a fixed array with 221 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<221).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array222.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array222.swift new file mode 100644 index 0000000..4690fa2 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array222.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array222 + Encodable + +/// An array with 222 elements +@propertyWrapper public struct Array222 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array222 + Encodable + +extension Array222: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 222 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array222 + Decodable + +extension Array222: Decodable where Element : Decodable { + /// Creates a fixed array with 222 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<222).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array223.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array223.swift new file mode 100644 index 0000000..2105e87 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array223.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array223 + Encodable + +/// An array with 223 elements +@propertyWrapper public struct Array223 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array223 + Encodable + +extension Array223: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 223 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array223 + Decodable + +extension Array223: Decodable where Element : Decodable { + /// Creates a fixed array with 223 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<223).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array224.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array224.swift new file mode 100644 index 0000000..e079a7c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array224.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array224 + Encodable + +/// An array with 224 elements +@propertyWrapper public struct Array224 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array224 + Encodable + +extension Array224: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 224 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array224 + Decodable + +extension Array224: Decodable where Element : Decodable { + /// Creates a fixed array with 224 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<224).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array225.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array225.swift new file mode 100644 index 0000000..2b6e964 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array225.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array225 + Encodable + +/// An array with 225 elements +@propertyWrapper public struct Array225 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array225 + Encodable + +extension Array225: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 225 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array225 + Decodable + +extension Array225: Decodable where Element : Decodable { + /// Creates a fixed array with 225 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<225).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array226.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array226.swift new file mode 100644 index 0000000..cf2ebf0 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array226.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array226 + Encodable + +/// An array with 226 elements +@propertyWrapper public struct Array226 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array226 + Encodable + +extension Array226: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 226 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array226 + Decodable + +extension Array226: Decodable where Element : Decodable { + /// Creates a fixed array with 226 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<226).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array227.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array227.swift new file mode 100644 index 0000000..9890c6c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array227.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array227 + Encodable + +/// An array with 227 elements +@propertyWrapper public struct Array227 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array227 + Encodable + +extension Array227: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 227 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array227 + Decodable + +extension Array227: Decodable where Element : Decodable { + /// Creates a fixed array with 227 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<227).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array228.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array228.swift new file mode 100644 index 0000000..d15af85 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array228.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array228 + Encodable + +/// An array with 228 elements +@propertyWrapper public struct Array228 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array228 + Encodable + +extension Array228: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 228 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array228 + Decodable + +extension Array228: Decodable where Element : Decodable { + /// Creates a fixed array with 228 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<228).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array229.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array229.swift new file mode 100644 index 0000000..e7750e1 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array229.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array229 + Encodable + +/// An array with 229 elements +@propertyWrapper public struct Array229 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array229 + Encodable + +extension Array229: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 229 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array229 + Decodable + +extension Array229: Decodable where Element : Decodable { + /// Creates a fixed array with 229 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<229).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array23.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array23.swift new file mode 100644 index 0000000..a6a87fa --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array23.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array23 + Encodable + +/// An array with 23 elements +@propertyWrapper public struct Array23 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array23 + Encodable + +extension Array23: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 23 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array23 + Decodable + +extension Array23: Decodable where Element : Decodable { + /// Creates a fixed array with 23 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<23).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array230.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array230.swift new file mode 100644 index 0000000..dcad4bf --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array230.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array230 + Encodable + +/// An array with 230 elements +@propertyWrapper public struct Array230 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array230 + Encodable + +extension Array230: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 230 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array230 + Decodable + +extension Array230: Decodable where Element : Decodable { + /// Creates a fixed array with 230 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<230).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array231.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array231.swift new file mode 100644 index 0000000..c2a2bdd --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array231.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array231 + Encodable + +/// An array with 231 elements +@propertyWrapper public struct Array231 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array231 + Encodable + +extension Array231: Encodable where Element : Encodable { + // Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 231 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array231 + Decodable + +extension Array231: Decodable where Element : Decodable { + /// Creates a fixed array with 231 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<231).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array232.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array232.swift new file mode 100644 index 0000000..3779e8c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array232.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array232 + Encodable + +/// An array with 232 elements +@propertyWrapper public struct Array232 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array232 + Encodable + +extension Array232: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 232 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array232 + Decodable + +extension Array232: Decodable where Element : Decodable { + /// Creates a fixed array with 232 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<232).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array233.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array233.swift new file mode 100644 index 0000000..06d3f9d --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array233.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array233 + Encodable + +/// An array with 233 elements +@propertyWrapper public struct Array233 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array233 + Encodable + +extension Array233: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 233 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array233 + Decodable + +extension Array233: Decodable where Element : Decodable { + /// Creates a fixed array with 233 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<233).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array234.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array234.swift new file mode 100644 index 0000000..c1dc72d --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array234.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array234 + Encodable + +/// An array with 234 elements +@propertyWrapper public struct Array234 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array234 + Encodable + +extension Array234: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 234 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array234 + Decodable + +extension Array234: Decodable where Element : Decodable { + /// Creates a fixed array with 234 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<234).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array235.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array235.swift new file mode 100644 index 0000000..d97e7c2 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array235.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array235 + Encodable + +/// An array with 235 elements +@propertyWrapper public struct Array235 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array235 + Encodable + +extension Array235: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 235 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array235 + Decodable + +extension Array235: Decodable where Element : Decodable { + /// Creates a fixed array with 235 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<235).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array236.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array236.swift new file mode 100644 index 0000000..007e0ef --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array236.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array236 + Encodable + +/// An array with 236 elements +@propertyWrapper public struct Array236 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array236 + Encodable + +extension Array236: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 236 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array236 + Decodable + +extension Array236: Decodable where Element : Decodable { + /// Creates a fixed array with 236 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<236).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array237.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array237.swift new file mode 100644 index 0000000..07afc3e --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array237.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array237 + Encodable + +/// An array with 237 elements +@propertyWrapper public struct Array237 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array237 + Encodable + +extension Array237: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 237 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array237 + Decodable + +extension Array237: Decodable where Element : Decodable { + /// Creates a fixed array with 237 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<237).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array238.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array238.swift new file mode 100644 index 0000000..a672470 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array238.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array238 + Encodable + +/// An array with 238 elements +@propertyWrapper public struct Array238 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array238 + Encodable + +extension Array238: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 238 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array238 + Decodable + +extension Array238: Decodable where Element : Decodable { + /// Creates a fixed array with 238 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<238).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array239.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array239.swift new file mode 100644 index 0000000..83e91f9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array239.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array239 + Encodable + +/// An array with 239 elements +@propertyWrapper public struct Array239 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array239 + Encodable + +extension Array239: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 239 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array239 + Decodable + +extension Array239: Decodable where Element : Decodable { + /// Creates a fixed array with 239 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<239).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array24.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array24.swift new file mode 100644 index 0000000..2e73c70 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array24.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array24 + Encodable + +/// An array with 24 elements +@propertyWrapper public struct Array24 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array24 + Encodable + +extension Array24: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 24 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array24 + Decodable + +extension Array24: Decodable where Element : Decodable { + /// Creates a fixed array with 24 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<24).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array240.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array240.swift new file mode 100644 index 0000000..35b59a4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array240.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array240 + Encodable + +/// An array with 240 elements +@propertyWrapper public struct Array240 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array240 + Encodable + +extension Array240: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 240 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array240 + Decodable + +extension Array240: Decodable where Element : Decodable { + /// Creates a fixed array with 240 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<240).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array241.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array241.swift new file mode 100644 index 0000000..57767b0 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array241.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array241 + Encodable + +/// An array with 241 elements +@propertyWrapper public struct Array241 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array241 + Encodable + +extension Array241: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 241 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array241 + Decodable + +extension Array241: Decodable where Element : Decodable { + /// Creates a fixed array with 241 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<241).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array242.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array242.swift new file mode 100644 index 0000000..da5a184 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array242.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array242 + Encodable + +/// An array with 242 elements +@propertyWrapper public struct Array242 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array242 + Encodable + +extension Array242: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 242 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array242 + Decodable + +extension Array242: Decodable where Element : Decodable { + /// Creates a fixed array with 242 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<242).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array243.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array243.swift new file mode 100644 index 0000000..c338c39 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array243.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array243 + Encodable + +/// An array with 243 elements +@propertyWrapper public struct Array243 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array243 + Encodable + +extension Array243: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 243 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array243 + Decodable + +extension Array243: Decodable where Element : Decodable { + /// Creates a fixed array with 243 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<243).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array244.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array244.swift new file mode 100644 index 0000000..6d3e0c8 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array244.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array244 + Encodable + +/// An array with 244 elements +@propertyWrapper public struct Array244 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array244 + Encodable + +extension Array244: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 244 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array244 + Decodable + +extension Array244: Decodable where Element : Decodable { + /// Creates a fixed array with 244 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<244).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array245.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array245.swift new file mode 100644 index 0000000..d601960 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array245.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array245 + Encodable + +/// An array with 245 elements +@propertyWrapper public struct Array245 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array245 + Encodable + +extension Array245: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 245 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array245 + Decodable + +extension Array245: Decodable where Element : Decodable { + /// Creates a fixed array with 245 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<245).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array246.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array246.swift new file mode 100644 index 0000000..9fd8626 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array246.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array246 + Encodable + +/// An array with 246 elements +@propertyWrapper public struct Array246 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array246 + Encodable + +extension Array246: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 246 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array246 + Decodable + +extension Array246: Decodable where Element : Decodable { + /// Creates a fixed array with 246 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<246).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array247.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array247.swift new file mode 100644 index 0000000..03523a9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array247.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array247 + Encodable + +/// An array with 247 elements +@propertyWrapper public struct Array247 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array247 + Encodable + +extension Array247: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 247 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array247 + Decodable + +extension Array247: Decodable where Element : Decodable { + /// Creates a fixed array with 247 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<247).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array248.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array248.swift new file mode 100644 index 0000000..605a5a3 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array248.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array248 + Encodable + +/// An array with 248 elements +@propertyWrapper public struct Array248 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array248 + Encodable + +extension Array248: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 248 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array248 + Decodable + +extension Array248: Decodable where Element : Decodable { + /// Creates a fixed array with 248 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<248).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array249.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array249.swift new file mode 100644 index 0000000..76b3e7e --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array249.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array249 + Encodable + +/// An array with 249 elements +@propertyWrapper public struct Array249 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array249 + Encodable + +extension Array249: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 249 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array249 + Decodable + +extension Array249: Decodable where Element : Decodable { + /// Creates a fixed array with 249 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<249).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array25.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array25.swift new file mode 100644 index 0000000..af126e5 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array25.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array25 + Encodable + +/// An array with 25 elements +@propertyWrapper public struct Array25 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array25 + Encodable + +extension Array25: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 25 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array25 + Decodable + +extension Array25: Decodable where Element : Decodable { + /// Creates a fixed array with 25 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<25).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array250.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array250.swift new file mode 100644 index 0000000..3ae98b0 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array250.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array250 + Encodable + +/// An array with 250 elements +@propertyWrapper public struct Array250 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array250 + Encodable + +extension Array250: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 250 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array250 + Decodable + +extension Array250: Decodable where Element : Decodable { + /// Creates a fixed array with 250 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<250).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array251.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array251.swift new file mode 100644 index 0000000..837b5c4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array251.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array251 + Encodable + +/// An array with 251 elements +@propertyWrapper public struct Array251 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array251 + Encodable + +extension Array251: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 251 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array251 + Decodable + +extension Array251: Decodable where Element : Decodable { + /// Creates a fixed array with 251 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<251).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array252.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array252.swift new file mode 100644 index 0000000..71ff572 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array252.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array252 + Encodable + +/// An array with 252 elements +@propertyWrapper public struct Array252 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array252 + Encodable + +extension Array252: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 252 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array252 + Decodable + +extension Array252: Decodable where Element : Decodable { + /// Creates a fixed array with 252 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<252).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array253.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array253.swift new file mode 100644 index 0000000..2385b52 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array253.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array253 + Encodable + +/// An array with 253 elements +@propertyWrapper public struct Array253 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array253 + Encodable + +extension Array253: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 253 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array253 + Decodable + +extension Array253: Decodable where Element : Decodable { + /// Creates a fixed array with 253 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<253).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array254.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array254.swift new file mode 100644 index 0000000..472523b --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array254.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array254 + Encodable + +/// An array with 254 elements +@propertyWrapper public struct Array254 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array254 + Encodable + +extension Array254: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 254 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array254 + Decodable + +extension Array254: Decodable where Element : Decodable { + /// Creates a fixed array with 254 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<254).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array255.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array255.swift new file mode 100644 index 0000000..15a27d8 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array255.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array255 + Encodable + +/// An array with 255 elements +@propertyWrapper public struct Array255 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array255 + Encodable + +extension Array255: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 255 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array255 + Decodable + +extension Array255: Decodable where Element : Decodable { + /// Creates a fixed array with 255 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<255).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array256.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array256.swift new file mode 100644 index 0000000..a1d626b --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array256.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array256 + Encodable + +/// An array with 256 elements +@propertyWrapper public struct Array256 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array256 + Encodable + +extension Array256: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 256 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array256 + Decodable + +extension Array256: Decodable where Element : Decodable { + /// Creates a fixed array with 256 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<256).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array26.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array26.swift new file mode 100644 index 0000000..7e366ce --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array26.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array26 + Encodable + +/// An array with 26 elements +@propertyWrapper public struct Array26 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array26 + Encodable + +extension Array26: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 26 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array26 + Decodable + +extension Array26: Decodable where Element : Decodable { + /// Creates a fixed array with 26 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<26).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array27.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array27.swift new file mode 100644 index 0000000..d7743f6 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array27.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array27 + Encodable + +/// An array with 27 elements +@propertyWrapper public struct Array27 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array27 + Encodable + +extension Array27: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 27 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array27 + Decodable + +extension Array27: Decodable where Element : Decodable { + /// Creates a fixed array with 27 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<27).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array28.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array28.swift new file mode 100644 index 0000000..1e9d872 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array28.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array28 + Encodable + +/// An array with 28 elements +@propertyWrapper public struct Array28 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array28 + Encodable + +extension Array28: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 28 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array28 + Decodable + +extension Array28: Decodable where Element : Decodable { + /// Creates a fixed array with 28 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<28).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array29.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array29.swift new file mode 100644 index 0000000..64477c2 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array29.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array29 + Encodable + +/// An array with 29 elements +@propertyWrapper public struct Array29 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array29 + Encodable + +extension Array29: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 29 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array29 + Decodable + +extension Array29: Decodable where Element : Decodable { + /// Creates a fixed array with 29 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<29).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array3.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array3.swift new file mode 100644 index 0000000..9846eec --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array3.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array3 + Encodable + +/// An array with 3 elements +@propertyWrapper public struct Array3 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array3 + Encodable + +extension Array3: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 3 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array3 + Decodable + +extension Array3: Decodable where Element : Decodable { + /// Creates a fixed array with 3 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<3).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array30.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array30.swift new file mode 100644 index 0000000..a1bc094 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array30.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array30 + Encodable + +/// An array with 30 elements +@propertyWrapper public struct Array30 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array30 + Encodable + +extension Array30: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 30 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array30 + Decodable + +extension Array30: Decodable where Element : Decodable { + /// Creates a fixed array with 30 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<30).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array31.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array31.swift new file mode 100644 index 0000000..91f231f --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array31.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array31 + Encodable + +/// An array with 31 elements +@propertyWrapper public struct Array31 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array31 + Encodable + +extension Array31: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 31 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array31 + Decodable + +extension Array31: Decodable where Element : Decodable { + /// Creates a fixed array with 31 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<31).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array32.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array32.swift new file mode 100644 index 0000000..07f08e2 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array32.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array32 + Encodable + +/// An array with 32 elements +@propertyWrapper public struct Array32 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array32 + Encodable + +extension Array32: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 32 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array32 + Decodable + +extension Array32: Decodable where Element : Decodable { + /// Creates a fixed array with 32 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<32).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array33.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array33.swift new file mode 100644 index 0000000..98f338b --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array33.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array33 + Encodable + +/// An array with 33 elements +@propertyWrapper public struct Array33 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array33 + Encodable + +extension Array33: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 33 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array33 + Decodable + +extension Array33: Decodable where Element : Decodable { + /// Creates a fixed array with 33 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<33).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array34.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array34.swift new file mode 100644 index 0000000..2e3bc2a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array34.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array34 + Encodable + +/// An array with 34 elements +@propertyWrapper public struct Array34 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array34 + Encodable + +extension Array34: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 34 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array34 + Decodable + +extension Array34: Decodable where Element : Decodable { + /// Creates a fixed array with 34 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<34).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array35.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array35.swift new file mode 100644 index 0000000..4f3c71b --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array35.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array35 + Encodable + +/// An array with 35 elements +@propertyWrapper public struct Array35 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array35 + Encodable + +extension Array35: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 35 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array35 + Decodable + +extension Array35: Decodable where Element : Decodable { + /// Creates a fixed array with 35 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<35).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array36.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array36.swift new file mode 100644 index 0000000..40b5a93 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array36.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array36 + Encodable + +/// An array with 36 elements +@propertyWrapper public struct Array36 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array36 + Encodable + +extension Array36: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 36 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array36 + Decodable + +extension Array36: Decodable where Element : Decodable { + /// Creates a fixed array with 36 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<36).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array37.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array37.swift new file mode 100644 index 0000000..3b6497c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array37.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array37 + Encodable + +/// An array with 37 elements +@propertyWrapper public struct Array37 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array37 + Encodable + +extension Array37: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 37 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array37 + Decodable + +extension Array37: Decodable where Element : Decodable { + /// Creates a fixed array with 37 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<37).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array38.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array38.swift new file mode 100644 index 0000000..ff0779a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array38.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array38 + Encodable + +/// An array with 38 elements +@propertyWrapper public struct Array38 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array38 + Encodable + +extension Array38: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 38 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array38 + Decodable + +extension Array38: Decodable where Element : Decodable { + /// Creates a fixed array with 38 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<38).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array39.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array39.swift new file mode 100644 index 0000000..b38a387 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array39.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array39 + Encodable + +/// An array with 39 elements +@propertyWrapper public struct Array39 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array39 + Encodable + +extension Array39: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 39 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array39 + Decodable + +extension Array39: Decodable where Element : Decodable { + /// Creates a fixed array with 39 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<39).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array4.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array4.swift new file mode 100644 index 0000000..81affdb --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array4.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array4 + Encodable + +/// An array with 4 elements +@propertyWrapper public struct Array4 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array4 + Encodable + +extension Array4: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 4 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array4 + Decodable + +extension Array4: Decodable where Element : Decodable { + /// Creates a fixed array with 4 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<4).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array40.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array40.swift new file mode 100644 index 0000000..0465c02 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array40.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array40 + Encodable + +/// An array with 40 elements +@propertyWrapper public struct Array40 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array40 + Encodable + +extension Array40: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 40 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array40 + Decodable + +extension Array40: Decodable where Element : Decodable { + /// Creates a fixed array with 40 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<40).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array41.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array41.swift new file mode 100644 index 0000000..3a8f0fb --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array41.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array41 + Encodable + +/// An array with 41 elements +@propertyWrapper public struct Array41 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array41 + Encodable + +extension Array41: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 41 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array41 + Decodable + +extension Array41: Decodable where Element : Decodable { + /// Creates a fixed array with 41 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<41).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array42.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array42.swift new file mode 100644 index 0000000..ab8f23f --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array42.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array42 + Encodable + +/// An array with 42 elements +@propertyWrapper public struct Array42 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array42 + Encodable + +extension Array42: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 42 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array42 + Decodable + +extension Array42: Decodable where Element : Decodable { + /// Creates a fixed array with 42 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<42).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array43.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array43.swift new file mode 100644 index 0000000..b7112df --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array43.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array43 + Encodable + +/// An array with 43 elements +@propertyWrapper public struct Array43 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array43 + Encodable + +extension Array43: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 43 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array43 + Decodable + +extension Array43: Decodable where Element : Decodable { + /// Creates a fixed array with 43 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<43).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array44.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array44.swift new file mode 100644 index 0000000..61130fc --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array44.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array44 + Encodable + +/// An array with 44 elements +@propertyWrapper public struct Array44 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array44 + Encodable + +extension Array44: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 44 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array44 + Decodable + +extension Array44: Decodable where Element : Decodable { + /// Creates a fixed array with 44 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<44).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array45.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array45.swift new file mode 100644 index 0000000..1fdd4a2 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array45.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array45 + Encodable + +/// An array with 45 elements +@propertyWrapper public struct Array45 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array45 + Encodable + +extension Array45: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 45 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array45 + Decodable + +extension Array45: Decodable where Element : Decodable { + /// Creates a fixed array with 45 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<45).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array46.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array46.swift new file mode 100644 index 0000000..1669cda --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array46.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array46 + Encodable + +/// An array with 46 elements +@propertyWrapper public struct Array46 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array46 + Encodable + +extension Array46: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 46 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array46 + Decodable + +extension Array46: Decodable where Element : Decodable { + /// Creates a fixed array with 46 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<46).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array47.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array47.swift new file mode 100644 index 0000000..cfca701 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array47.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array47 + Encodable + +/// An array with 47 elements +@propertyWrapper public struct Array47 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array47 + Encodable + +extension Array47: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 47 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array47 + Decodable + +extension Array47: Decodable where Element : Decodable { + /// Creates a fixed array with 47 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<47).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array48.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array48.swift new file mode 100644 index 0000000..94c91d0 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array48.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array48 + Encodable + +/// An array with 48 elements +@propertyWrapper public struct Array48 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array48 + Encodable + +extension Array48: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 48 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array48 + Decodable + +extension Array48: Decodable where Element : Decodable { + /// Creates a fixed array with 48 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<48).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array49.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array49.swift new file mode 100644 index 0000000..ca0b866 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array49.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array49 + Encodable + +/// An array with 49 elements +@propertyWrapper public struct Array49 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array49 + Encodable + +extension Array49: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 49 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array49 + Decodable + +extension Array49: Decodable where Element : Decodable { + /// Creates a fixed array with 49 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<49).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array5.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array5.swift new file mode 100644 index 0000000..566f8d9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array5.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array5 + Encodable + +/// An array with 5 elements +@propertyWrapper public struct Array5 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array5 + Encodable + +extension Array5: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 5 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array5 + Decodable + +extension Array5: Decodable where Element : Decodable { + /// Creates a fixed array with 5 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<5).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array50.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array50.swift new file mode 100644 index 0000000..e43e534 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array50.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array50 + Encodable + +/// An array with 50 elements +@propertyWrapper public struct Array50 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array50 + Encodable + +extension Array50: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 50 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array50 + Decodable + +extension Array50: Decodable where Element : Decodable { + /// Creates a fixed array with 50 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<50).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array51.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array51.swift new file mode 100644 index 0000000..a68fc5c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array51.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array51 + Encodable + +/// An array with 51 elements +@propertyWrapper public struct Array51 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array51 + Encodable + +extension Array51: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 51 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array51 + Decodable + +extension Array51: Decodable where Element : Decodable { + /// Creates a fixed array with 51 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<51).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array52.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array52.swift new file mode 100644 index 0000000..2135508 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array52.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array52 + Encodable + +/// An array with 52 elements +@propertyWrapper public struct Array52 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array52 + Encodable + +extension Array52: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 52 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array52 + Decodable + +extension Array52: Decodable where Element : Decodable { + /// Creates a fixed array with 52 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<52).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array53.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array53.swift new file mode 100644 index 0000000..99f2a17 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array53.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array53 + Encodable + +/// An array with 53 elements +@propertyWrapper public struct Array53 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array53 + Encodable + +extension Array53: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 53 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array53 + Decodable + +extension Array53: Decodable where Element : Decodable { + /// Creates a fixed array with 53 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<53).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array54.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array54.swift new file mode 100644 index 0000000..2f506a9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array54.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array54 + Encodable + +/// An array with 54 elements +@propertyWrapper public struct Array54 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array54 + Encodable + +extension Array54: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 54 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array54 + Decodable + +extension Array54: Decodable where Element : Decodable { + /// Creates a fixed array with 54 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<54).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array55.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array55.swift new file mode 100644 index 0000000..92c00b3 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array55.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array55 + Encodable + +/// An array with 55 elements +@propertyWrapper public struct Array55 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array55 + Encodable + +extension Array55: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 55 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array55 + Decodable + +extension Array55: Decodable where Element : Decodable { + /// Creates a fixed array with 55 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<55).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array56.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array56.swift new file mode 100644 index 0000000..64b65cf --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array56.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array56 + Encodable + +/// An array with 56 elements +@propertyWrapper public struct Array56 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array56 + Encodable + +extension Array56: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 56 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array56 + Decodable + +extension Array56: Decodable where Element : Decodable { + /// Creates a fixed array with 56 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<56).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array57.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array57.swift new file mode 100644 index 0000000..d65ec89 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array57.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array57 + Encodable + +/// An array with 57 elements +@propertyWrapper public struct Array57 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array57 + Encodable + +extension Array57: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 57 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array57 + Decodable + +extension Array57: Decodable where Element : Decodable { + /// Creates a fixed array with 57 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<57).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array58.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array58.swift new file mode 100644 index 0000000..f093a16 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array58.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array58 + Encodable + +/// An array with 58 elements +@propertyWrapper public struct Array58 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array58 + Encodable + +extension Array58: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 58 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array58 + Decodable + +extension Array58: Decodable where Element : Decodable { + /// Creates a fixed array with 58 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<58).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array59.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array59.swift new file mode 100644 index 0000000..226f7ca --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array59.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array59 + Encodable + +/// An array with 59 elements +@propertyWrapper public struct Array59 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array59 + Encodable + +extension Array59: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 59 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array59 + Decodable + +extension Array59: Decodable where Element : Decodable { + /// Creates a fixed array with 59 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<59).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array6.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array6.swift new file mode 100644 index 0000000..a86d14f --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array6.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array6 + Encodable + +/// An array with 6 elements +@propertyWrapper public struct Array6 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array6 + Encodable + +extension Array6: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 6 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array6 + Decodable + +extension Array6: Decodable where Element : Decodable { + /// Creates a fixed array with 6 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<6).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array60.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array60.swift new file mode 100644 index 0000000..e45ef97 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array60.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array60 + Encodable + +/// An array with 60 elements +@propertyWrapper public struct Array60 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array60 + Encodable + +extension Array60: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 60 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array60 + Decodable + +extension Array60: Decodable where Element : Decodable { + /// Creates a fixed array with 60 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<60).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array61.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array61.swift new file mode 100644 index 0000000..fcc035c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array61.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array61 + Encodable + +/// An array with 61 elements +@propertyWrapper public struct Array61 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array61 + Encodable + +extension Array61: Encodable where Element : Encodable { + // Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 61 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array61 + Decodable + +extension Array61: Decodable where Element : Decodable { + /// Creates a fixed array with 61 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<61).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array62.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array62.swift new file mode 100644 index 0000000..e5ba280 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array62.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array62 + Encodable + +/// An array with 62 elements +@propertyWrapper public struct Array62 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array62 + Encodable + +extension Array62: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 62 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array62 + Decodable + +extension Array62: Decodable where Element : Decodable { + /// Creates a fixed array with 62 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<62).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array63.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array63.swift new file mode 100644 index 0000000..026d646 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array63.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array63 + Encodable + +/// An array with 63 elements +@propertyWrapper public struct Array63 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array63 + Encodable + +extension Array63: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 63 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array63 + Decodable + +extension Array63: Decodable where Element : Decodable { + /// Creates a fixed array with 63 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<63).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array64.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array64.swift new file mode 100644 index 0000000..1a70590 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array64.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array64 + Encodable + +/// An array with 64 elements +@propertyWrapper public struct Array64 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array64 + Encodable + +extension Array64: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 64 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array64 + Decodable + +extension Array64: Decodable where Element : Decodable { + /// Creates a fixed array with 64 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<64).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array65.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array65.swift new file mode 100644 index 0000000..5398b33 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array65.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array65 + Encodable + +/// An array with 65 elements +@propertyWrapper public struct Array65 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array65 + Encodable + +extension Array65: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 65 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array65 + Decodable + +extension Array65: Decodable where Element : Decodable { + /// Creates a fixed array with 65 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<65).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array66.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array66.swift new file mode 100644 index 0000000..cea99ba --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array66.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array66 + Encodable + +/// An array with 66 elements +@propertyWrapper public struct Array66 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array66 + Encodable + +extension Array66: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 66 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array66 + Decodable + +extension Array66: Decodable where Element : Decodable { + /// Creates a fixed array with 66 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<66).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array67.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array67.swift new file mode 100644 index 0000000..731ca27 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array67.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array67 + Encodable + +/// An array with 67 elements +@propertyWrapper public struct Array67 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array67 + Encodable + +extension Array67: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 67 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array67 + Decodable + +extension Array67: Decodable where Element : Decodable { + /// Creates a fixed array with 67 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<67).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array68.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array68.swift new file mode 100644 index 0000000..bcf797d --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array68.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array68 + Encodable + +/// An array with 68 elements +@propertyWrapper public struct Array68 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array68 + Encodable + +extension Array68: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 68 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array68 + Decodable + +extension Array68: Decodable where Element : Decodable { + /// Creates a fixed array with 68 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<68).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array69.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array69.swift new file mode 100644 index 0000000..2fb7011 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array69.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array69 + Encodable + +/// An array with 69 elements +@propertyWrapper public struct Array69 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array69 + Encodable + +extension Array69: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 69 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array69 + Decodable + +extension Array69: Decodable where Element : Decodable { + /// Creates a fixed array with 69 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<69).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array7.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array7.swift new file mode 100644 index 0000000..ea446ec --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array7.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array7 + Encodable + +/// An array with 7 elements +@propertyWrapper public struct Array7 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array7 + Encodable + +extension Array7: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 7 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array7 + Decodable + +extension Array7: Decodable where Element : Decodable { + /// Creates a fixed array with 7 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<7).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array70.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array70.swift new file mode 100644 index 0000000..e2548f4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array70.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array70 + Encodable + +/// An array with 70 elements +@propertyWrapper public struct Array70 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array70 + Encodable + +extension Array70: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 70 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array70 + Decodable + +extension Array70: Decodable where Element : Decodable { + /// Creates a fixed array with 70 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<70).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array71.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array71.swift new file mode 100644 index 0000000..0ed84cf --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array71.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array71 + Encodable + +/// An array with 71 elements +@propertyWrapper public struct Array71 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array71 + Encodable + +extension Array71: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 71 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array71 + Decodable + +extension Array71: Decodable where Element : Decodable { + /// Creates a fixed array with 71 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<71).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array72.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array72.swift new file mode 100644 index 0000000..5a4f340 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array72.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array72 + Encodable + +/// An array with 72 elements +@propertyWrapper public struct Array72 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array72 + Encodable + +extension Array72: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 72 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array72 + Decodable + +extension Array72: Decodable where Element : Decodable { + /// Creates a fixed array with 72 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<72).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array73.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array73.swift new file mode 100644 index 0000000..2996e5a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array73.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array73 + Encodable + +/// An array with 73 elements +@propertyWrapper public struct Array73 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array73 + Encodable + +extension Array73: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 73 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array73 + Decodable + +extension Array73: Decodable where Element : Decodable { + /// Creates a fixed array with 73 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<73).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array74.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array74.swift new file mode 100644 index 0000000..e8a3823 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array74.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array74 + Encodable + +/// An array with 74 elements +@propertyWrapper public struct Array74 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array74 + Encodable + +extension Array74: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 74 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array74 + Decodable + +extension Array74: Decodable where Element : Decodable { + /// Creates a fixed array with 74 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<74).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array75.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array75.swift new file mode 100644 index 0000000..6298bb6 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array75.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array75 + Encodable + +/// An array with 75 elements +@propertyWrapper public struct Array75 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array75 + Encodable + +extension Array75: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 75 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array75 + Decodable + +extension Array75: Decodable where Element : Decodable { + /// Creates a fixed array with 75 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<75).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array76.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array76.swift new file mode 100644 index 0000000..2b97afd --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array76.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array76 + Encodable + +/// An array with 76 elements +@propertyWrapper public struct Array76 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array76 + Encodable + +extension Array76: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 76 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array76 + Decodable + +extension Array76: Decodable where Element : Decodable { + /// Creates a fixed array with 76 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<76).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array77.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array77.swift new file mode 100644 index 0000000..ae09962 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array77.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array77 + Encodable + +/// An array with 77 elements +@propertyWrapper public struct Array77 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array77 + Encodable + +extension Array77: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 77 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array77 + Decodable + +extension Array77: Decodable where Element : Decodable { + /// Creates a fixed array with 77 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<77).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array78.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array78.swift new file mode 100644 index 0000000..d0929e5 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array78.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array78 + Encodable + +/// An array with 78 elements +@propertyWrapper public struct Array78 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array78 + Encodable + +extension Array78: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 78 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array78 + Decodable + +extension Array78: Decodable where Element : Decodable { + /// Creates a fixed array with 78 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<78).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array79.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array79.swift new file mode 100644 index 0000000..fe01ac4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array79.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array79 + Encodable + +/// An array with 79 elements +@propertyWrapper public struct Array79 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array79 + Encodable + +extension Array79: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 79 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array79 + Decodable + +extension Array79: Decodable where Element : Decodable { + /// Creates a fixed array with 79 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<79).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array8.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array8.swift new file mode 100644 index 0000000..eb42a37 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array8.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array8 + Encodable + +/// An array with 8 elements +@propertyWrapper public struct Array8 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array8 + Encodable + +extension Array8: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 8 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array8 + Decodable + +extension Array8: Decodable where Element : Decodable { + /// Creates a fixed array with 8 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<8).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array80.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array80.swift new file mode 100644 index 0000000..ac0c8c8 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array80.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array80 + Encodable + +/// An array with 80 elements +@propertyWrapper public struct Array80 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array80 + Encodable + +extension Array80: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 80 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array80 + Decodable + +extension Array80: Decodable where Element : Decodable { + /// Creates a fixed array with 80 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<80).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array81.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array81.swift new file mode 100644 index 0000000..395fecc --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array81.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array81 + Encodable + +/// An array with 81 elements +@propertyWrapper public struct Array81 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array81 + Encodable + +extension Array81: Encodable where Element : Encodable { + // Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 81 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array81 + Decodable + +extension Array81: Decodable where Element : Decodable { + /// Creates a fixed array with 81 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<81).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array82.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array82.swift new file mode 100644 index 0000000..9d9973c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array82.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array82 + Encodable + +/// An array with 82 elements +@propertyWrapper public struct Array82 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array82 + Encodable + +extension Array82: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 82 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array82 + Decodable + +extension Array82: Decodable where Element : Decodable { + /// Creates a fixed array with 82 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<82).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array83.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array83.swift new file mode 100644 index 0000000..0c3ab27 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array83.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array83 + Encodable + +/// An array with 83 elements +@propertyWrapper public struct Array83 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array83 + Encodable + +extension Array83: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 83 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array83 + Decodable + +extension Array83: Decodable where Element : Decodable { + /// Creates a fixed array with 83 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<83).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array84.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array84.swift new file mode 100644 index 0000000..94fcb2a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array84.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array84 + Encodable + +/// An array with 84 elements +@propertyWrapper public struct Array84 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array84 + Encodable + +extension Array84: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 84 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array84 + Decodable + +extension Array84: Decodable where Element : Decodable { + /// Creates a fixed array with 84 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<84).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array85.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array85.swift new file mode 100644 index 0000000..290a399 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array85.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array85 + Encodable + +/// An array with 85 elements +@propertyWrapper public struct Array85 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array85 + Encodable + +extension Array85: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 85 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array85 + Decodable + +extension Array85: Decodable where Element : Decodable { + /// Creates a fixed array with 85 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<85).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array86.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array86.swift new file mode 100644 index 0000000..d8d17f4 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array86.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array86 + Encodable + +/// An array with 86 elements +@propertyWrapper public struct Array86 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array86 + Encodable + +extension Array86: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 86 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array86 + Decodable + +extension Array86: Decodable where Element : Decodable { + /// Creates a fixed array with 86 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<86).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array87.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array87.swift new file mode 100644 index 0000000..ee2b069 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array87.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array87 + Encodable + +/// An array with 87 elements +@propertyWrapper public struct Array87 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array87 + Encodable + +extension Array87: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 87 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array87 + Decodable + +extension Array87: Decodable where Element : Decodable { + /// Creates a fixed array with 87 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<87).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array88.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array88.swift new file mode 100644 index 0000000..b6eab19 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array88.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array88 + Encodable + +/// An array with 88 elements +@propertyWrapper public struct Array88 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array88 + Encodable + +extension Array88: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 88 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array88 + Decodable + +extension Array88: Decodable where Element : Decodable { + /// Creates a fixed array with 88 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<88).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array89.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array89.swift new file mode 100644 index 0000000..125b5c2 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array89.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array89 + Encodable + +/// An array with 89 elements +@propertyWrapper public struct Array89 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array89 + Encodable + +extension Array89: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 89 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array89 + Decodable + +extension Array89: Decodable where Element : Decodable { + /// Creates a fixed array with 89 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<89).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array9.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array9.swift new file mode 100644 index 0000000..0d6e65b --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array9.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array9 + Encodable + +/// An array with 9 elements +@propertyWrapper public struct Array9 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array9 + Encodable + +extension Array9: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 9 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array9 + Decodable + +extension Array9: Decodable where Element : Decodable { + /// Creates a fixed array with 9 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<9).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array90.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array90.swift new file mode 100644 index 0000000..e20cbf3 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array90.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array90 + Encodable + +/// An array with 90 elements +@propertyWrapper public struct Array90 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array90 + Encodable + +extension Array90: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 90 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array90 + Decodable + +extension Array90: Decodable where Element : Decodable { + /// Creates a fixed array with 90 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<90).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array91.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array91.swift new file mode 100644 index 0000000..e41e87a --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array91.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array91 + Encodable + +/// An array with 91 elements +@propertyWrapper public struct Array91 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array91 + Encodable + +extension Array91: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 91 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array91 + Decodable + +extension Array91: Decodable where Element : Decodable { + /// Creates a fixed array with 91 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<91).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array92.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array92.swift new file mode 100644 index 0000000..b1b8f74 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array92.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array92 + Encodable + +/// An array with 92 elements +@propertyWrapper public struct Array92 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array92 + Encodable + +extension Array92: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 92 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array92 + Decodable + +extension Array92: Decodable where Element : Decodable { + /// Creates a fixed array with 92 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<92).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array93.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array93.swift new file mode 100644 index 0000000..ae3cbc0 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array93.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array93 + Encodable + +/// An array with 93 elements +@propertyWrapper public struct Array93 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array93 + Encodable + +extension Array93: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 93 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array93 + Decodable + +extension Array93: Decodable where Element : Decodable { + /// Creates a fixed array with 93 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<93).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array94.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array94.swift new file mode 100644 index 0000000..e804e6c --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array94.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array94 + Encodable + +/// An array with 94 elements +@propertyWrapper public struct Array94 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array94 + Encodable + +extension Array94: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 94 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array94 + Decodable + +extension Array94: Decodable where Element : Decodable { + /// Creates a fixed array with 94 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<94).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array95.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array95.swift new file mode 100644 index 0000000..e9ba721 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array95.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array95 + Encodable + +/// An array with 95 elements +@propertyWrapper public struct Array95 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array95 + Encodable + +extension Array95: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 95 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array95 + Decodable + +extension Array95: Decodable where Element : Decodable { + /// Creates a fixed array with 95 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<95).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array96.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array96.swift new file mode 100644 index 0000000..d10a1a9 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array96.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array96 + Encodable + +/// An array with 96 elements +@propertyWrapper public struct Array96 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array96 + Encodable + +extension Array96: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 96 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array96 + Decodable + +extension Array96: Decodable where Element : Decodable { + /// Creates a fixed array with 96 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<96).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array97.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array97.swift new file mode 100644 index 0000000..75d8fea --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array97.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array97 + Encodable + +/// An array with 97 elements +@propertyWrapper public struct Array97 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array97 + Encodable + +extension Array97: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 97 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array97 + Decodable + +extension Array97: Decodable where Element : Decodable { + /// Creates a fixed array with 97 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<97).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array98.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array98.swift new file mode 100644 index 0000000..9ca2d09 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array98.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array98 + Encodable + +/// An array with 98 elements +@propertyWrapper public struct Array98 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array98 + Encodable + +extension Array98: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 98 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array98 + Decodable + +extension Array98: Decodable where Element : Decodable { + /// Creates a fixed array with 98 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<98).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/Array99.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/Array99.swift new file mode 100644 index 0000000..dd8429e --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/Array99.swift @@ -0,0 +1,54 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +// MARK: - Array99 + Encodable + +/// An array with 99 elements +@propertyWrapper public struct Array99 { + public var wrappedValue: [Element] + public init(wrappedValue: [Element]) { + self.wrappedValue = wrappedValue + } +} + +// MARK: - Array99 + Encodable + +extension Array99: Encodable where Element : Encodable { + /// Encodes the array via provided encoder + /// - Parameters: + /// - encoder: An encoder that is used to encode the array + public func encode(to encoder: Encoder) throws { + guard wrappedValue.count == 99 else { throw FixedArrayError.invalidSize } + var container = encoder.unkeyedContainer() + try wrappedValue.forEach { try container.encode($0) } + } +} + +// MARK: - Array99 + Decodable + +extension Array99: Decodable where Element : Decodable { + /// Creates a fixed array with 99 elements using the provided decoder, by decoding its each element + /// - Parameters: + /// - decoder: Decoder, used to create the array + public init(from decoder: Decoder) throws { + var container = try decoder.unkeyedContainer() + wrappedValue = try (0..<99).map { _ in try container.decode(Element.self) } + } +} diff --git a/ScaleCodecSwift/Classes/Types/FixedArrays/FixedArrayError.swift b/ScaleCodecSwift/Classes/Types/FixedArrays/FixedArrayError.swift new file mode 100644 index 0000000..6a83bb6 --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/FixedArrays/FixedArrayError.swift @@ -0,0 +1,24 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// Fixed array error +enum FixedArrayError: Swift.Error { + case invalidSize +} diff --git a/ScaleCodecSwift/Classes/Types/ScaleEncodedData.swift b/ScaleCodecSwift/Classes/Types/ScaleEncodedData.swift new file mode 100644 index 0000000..f64308d --- /dev/null +++ b/ScaleCodecSwift/Classes/Types/ScaleEncodedData.swift @@ -0,0 +1,35 @@ +/** + * + * Copyright 2023 SUBSTRATE LABORATORY LLC + * + * 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 Foundation + +/// A wrapper over scale encoded data +public struct ScaleEncodedData: Codable { + public let value: Data + public init(value: Data) { + self.value = value + } +} + +extension Data { + /// Converts `Data` to scale encoded + /// - Returns: A scale encoded `Data` + public func asScaleEncoded() -> ScaleEncodedData { + .init(value: self) + } +}