Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
bbc47a1
Added the basic logic
Oct 18, 2022
d0b4359
Added Enum tests
Oct 21, 2022
88f6adb
added open init to ScaleCodecAdapterProvider
Oct 31, 2022
4165ee3
Replaced open with public
Oct 31, 2022
721cacb
Update version
Oct 31, 2022
c0c5ac8
Made ScaleCoder public
Nov 4, 2022
416d263
Updated version
Nov 4, 2022
f1c0389
Made DefaultAdapterProvider public
Nov 4, 2022
75b7a81
Updated version
Nov 4, 2022
92094fb
Made decoder and encoder public, updated version
Nov 4, 2022
836738a
Fixed count coding for array
Nov 10, 2022
95f4a4f
Added DataAdapter with its tests; updated StringAdapter to use Data i…
Nov 12, 2022
d4837d4
Added adapters for Int128, UInt128, Int256, UInt256, Int512 and UInt5…
Dec 2, 2022
89343c4
Updated podspec
Dec 2, 2022
99f0fc1
Downgraded BigInt version to match with the one used in other libs
Dec 2, 2022
74b0162
Added documentation comments
Dec 8, 2022
fbe9654
Added a static method to ScaleCoder to return a default one
Dec 8, 2022
a226e43
Added a markdown file explaining ScaleCoder's functionality
Dec 16, 2022
33c9289
Moved the documentation in a separate folder
Dec 20, 2022
7837157
Updated Readme.md file by added a link to documentation
Dec 20, 2022
1f16ca3
Added ScaleCodecTransaction
Jan 5, 2023
f6fb2fb
Updated ScaleCodecTransaction's logic and renamed defaultCoder to def…
Jan 7, 2023
5aa1053
Made ScaleCodecTransaction methods public and added some debugging co…
Jan 8, 2023
85d4a2b
Made DataReader public
posplaw Jan 11, 2023
cdcb835
Made AdapterProvider public
posplaw Jan 11, 2023
3cc184e
Fixed visibility build errors
posplaw Jan 11, 2023
9189972
Made all adapters public
posplaw Jan 11, 2023
34808a7
Made adapters inits public
posplaw Jan 11, 2023
36a7b87
Added public inits to default initiated adapters
posplaw Jan 11, 2023
167f056
Added numeric from/to data functions
posplaw Jan 11, 2023
2b7b482
Made codec adapter init public
posplaw Jan 11, 2023
483bcdc
Made scale codec adapter fully public
posplaw Jan 11, 2023
c27ab28
Conformed adapters to public base class
posplaw Jan 11, 2023
f1dd71e
Fixed visibility
posplaw Jan 11, 2023
6144bc6
Removed generics conformance to codable sub protocols
posplaw Jan 11, 2023
18d0227
Added abstract read/writes
posplaw Jan 11, 2023
20e21c6
Refactored codec a bit
posplaw Jan 11, 2023
f80ddb9
Made adapter provider methods public
posplaw Jan 11, 2023
e0514ad
Properly redesigned generic adapter
posplaw Jan 11, 2023
427b3e5
Removed Pods
Jan 11, 2023
3129c00
Added gitignore file
Jan 11, 2023
c78feb4
Added a version to dependency in Podfile
Jan 11, 2023
91d1d55
Made AdapterProvider's refactoring by dividing it into smaller pieces…
Jan 11, 2023
b931857
Optimized Any adaptable funcs
posplaw Jan 12, 2023
360fcd8
Removed third-party pod version from Podfile.
Jan 12, 2023
6e2711d
Removed not required prints
Jan 12, 2023
e40476d
Upgraded BigInt version from 3.1 to 5.0.0
Jan 12, 2023
0807822
Fixed a comment
Jan 14, 2023
40b68e6
Added ScaleEncodedData for skipping scale serialization
posplaw Jan 14, 2023
86cc59c
Merge branch 'dev' of https://github.com/sublabdev/scale-codec-swift …
posplaw Jan 14, 2023
d5394f8
Moved to proper place
posplaw Jan 14, 2023
4955ab5
Added fixed size arrays and their generator, generated sizes from 1 t…
posplaw Jan 14, 2023
f9f77c4
Fixed coding of ScaleEncodedData
posplaw Jan 14, 2023
081c3d7
Fixed pod lock
posplaw Jan 14, 2023
4c9f22a
Added documentation comments for fixed arrays, ScaleEncodedData and …
Jan 14, 2023
79cf397
Updated license file
posplaw Jan 15, 2023
26f841c
Added license headers
posplaw Jan 15, 2023
697bc9a
Made classes final
Jan 15, 2023
d0849c0
Update README.md
TigranIsk Jan 16, 2023
f433a61
Cleaned podspec
posplaw Jan 16, 2023
5159b91
Merge branch 'main'
posplaw Jan 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 41 additions & 0 deletions Doc/ScaleCoder.md
Original file line number Diff line number Diff line change
@@ -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`.
5 changes: 5 additions & 0 deletions Example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### CocoaPods ###
Pods/

## User settings
xcuserdata/
4 changes: 3 additions & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
27 changes: 24 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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
22 changes: 0 additions & 22 deletions Example/Pods/Local Podspecs/ScaleCodecSwift.podspec.json

This file was deleted.

16 changes: 0 additions & 16 deletions Example/Pods/Manifest.lock

This file was deleted.

776 changes: 0 additions & 776 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading