├── .bundle
└── config
├── .gitignore
├── LICENSE
├── Podfile
├── Podfile.lock
├── README.md
├── StubTest
├── Resources
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ └── LaunchScreen.storyboard
│ └── Info.plist
└── Sources
│ ├── AppDelegate.swift
│ └── Base.lproj
│ └── Main.storyboard
├── WavesKeeperExample
├── KeeperExample.xcodeproj
│ └── project.pbxproj
├── KeeperExample
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ ├── phone.imageset
│ │ │ ├── Contents.json
│ │ │ ├── phone@2x.png
│ │ │ └── phone@3x.png
│ │ └── settings.imageset
│ │ │ ├── Contents.json
│ │ │ ├── settings@2x.png
│ │ │ └── settings@3x.png
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Constants.swift
│ ├── CustomNavigationViewController.swift
│ ├── Info.plist
│ ├── KeeperViewController.swift
│ ├── SDKViewController.swift
│ └── Transactions.swift
├── Podfile
└── Podfile.lock
├── WavesSDK.podspec
├── WavesSDK.xcodeproj
├── project.pbxproj
└── xcshareddata
│ └── xcschemes
│ └── WavesSDKTests.xcscheme
├── WavesSDK
├── Info.plist
├── Sources
│ ├── Assisstants
│ │ ├── CachePolicyPlugin.swift
│ │ ├── ContentType.swift
│ │ ├── DictionaryEncoder.swift
│ │ ├── DispatchQueuePool.swift
│ │ ├── Encodable+Base64.swift
│ │ ├── NetworkError.swift
│ │ ├── Protocols
│ │ │ ├── DataServicesProtocol.swift
│ │ │ ├── MatcherServicesProtocol.swift
│ │ │ ├── NodeServicesProtocol.swift
│ │ │ ├── ServicesProtocol.swift
│ │ │ └── WavesServicesProtocol.swift
│ │ ├── String+Waves.swift
│ │ ├── Type
│ │ │ ├── DataServices.swift
│ │ │ ├── InternalWavesService.swift
│ │ │ ├── MatcherServices.swift
│ │ │ ├── NodeServices.swift
│ │ │ └── WavesServices.swift
│ │ ├── WavesEnvironment.swift
│ │ ├── WavesKeeper+Decodable.swift
│ │ ├── WavesKeeper.swift
│ │ └── WavesSDK.swift
│ ├── Services
│ │ ├── Data
│ │ │ ├── DataServiceTypes.swift
│ │ │ ├── Models
│ │ │ │ ├── AliasData.swift
│ │ │ │ ├── AssetData.swift
│ │ │ │ ├── CandleData.swift
│ │ │ │ ├── MassTransferTransaction.swift
│ │ │ │ ├── PairPriceData.swift
│ │ │ │ ├── PairsRateData.swift
│ │ │ │ ├── ResponseData.swift
│ │ │ │ └── TransactionData.swift
│ │ │ ├── Queries
│ │ │ │ ├── CandleFiltersDataQuery.swift
│ │ │ │ ├── ExchangeFiltersDataQuery.swift
│ │ │ │ └── MassTransferDataQuery.swift
│ │ │ ├── Services
│ │ │ │ ├── AliasDataService.swift
│ │ │ │ ├── AssetsDataService.swift
│ │ │ │ ├── CandlesDataService.swift
│ │ │ │ ├── PairsPriceDataService.swift
│ │ │ │ ├── Protocols
│ │ │ │ │ ├── AliasDataServiceProtocol.swift
│ │ │ │ │ ├── AssetsDataServiceProtocol.swift
│ │ │ │ │ ├── CandlesDataServiceProtocol.swift
│ │ │ │ │ ├── PairsPriceDataServiceProtocol.swift
│ │ │ │ │ └── TransactionsDataServiceProtocol.swift
│ │ │ │ └── TransactionsDataService.swift
│ │ │ └── Targets
│ │ │ │ ├── AliasDataTarget.swift
│ │ │ │ ├── AssetsDataTarget.swift
│ │ │ │ ├── CandlesDataTarget.swift
│ │ │ │ ├── PairsPriceDataTarget.swift
│ │ │ │ ├── PairsRateDataTarget.swift
│ │ │ │ └── TransactionsDataTarget.swift
│ │ ├── Matcher
│ │ │ ├── MatcherServiceTypes.swift
│ │ │ ├── Models
│ │ │ │ ├── MarketMatcher.swift
│ │ │ │ ├── OrderBookMatcher.swift
│ │ │ │ └── OrderMatcher.swift
│ │ │ ├── Queries
│ │ │ │ └── BalanceMatcherQuery.swift
│ │ │ ├── Services
│ │ │ │ ├── BalanceMatcherService.swift
│ │ │ │ ├── OrderBookMatcherService.swift
│ │ │ │ ├── Protocols
│ │ │ │ │ ├── BalanceMatcherServiceProtocol.swift
│ │ │ │ │ ├── OrderBookMatcherServiceProtocol.swift
│ │ │ │ │ └── PublicKeyMatcherServiceProtocol.swift
│ │ │ │ └── PublicKeyMatcherService.swift
│ │ │ └── Targets
│ │ │ │ ├── BalanceMatcherTarget.swift
│ │ │ │ ├── OrderBookMatcherTarget.swift
│ │ │ │ └── PublicKeyMatcherTarget.swift
│ │ └── Node
│ │ │ ├── Models
│ │ │ ├── AccountAssetsBalanceNode.swift
│ │ │ ├── AccountBalanceNode.swift
│ │ │ ├── AddressData.swift
│ │ │ ├── AddressScriptInfoNode.swift
│ │ │ ├── AssetDetailNode.swift
│ │ │ ├── BlockNode.swift
│ │ │ ├── Transactions
│ │ │ │ ├── AliasTransactionNode.swift
│ │ │ │ ├── BurnTransactionNode.swift
│ │ │ │ ├── DataTransactionNode.swift
│ │ │ │ ├── ExchangeTransactionNode.swift
│ │ │ │ ├── InvokeScriptTransactionNode.swift
│ │ │ │ ├── IssueTransactionNode.swift
│ │ │ │ ├── LeaseCancelTransactionNode.swift
│ │ │ │ ├── LeaseTransactionNode.swift
│ │ │ │ ├── MassTransferTransactionNode.swift
│ │ │ │ ├── ReissueTransactionNode.swift
│ │ │ │ ├── SetAssetScriptTransactionNode.swift
│ │ │ │ ├── SetScriptTransactionNode.swift
│ │ │ │ ├── SponsorshipTransactionNode.swift
│ │ │ │ ├── TransactionContainersNode.swift
│ │ │ │ ├── TransferTransactionNode.swift
│ │ │ │ ├── UnrecognisedTransactionNode.swift
│ │ │ │ └── UpdateAssetInfoTransactionNode.swift
│ │ │ └── UtilsNode.swift
│ │ │ ├── NodeTargetTypes.swift
│ │ │ ├── Queries
│ │ │ ├── BaseTransactionQueryProtocol.swift
│ │ │ └── TransactionNodeQuery.swift
│ │ │ ├── Services
│ │ │ ├── AddressesNodeService.swift
│ │ │ ├── AssetsNodeService.swift
│ │ │ ├── BlocksNodeService.swift
│ │ │ ├── LeasingNodeService.swift
│ │ │ ├── Protocols
│ │ │ │ ├── AddressesNodeServiceProtocol.swift
│ │ │ │ ├── AssetsNodeServiceProtocol.swift
│ │ │ │ ├── BlocksNodeServiceProtocol.swift
│ │ │ │ ├── LeasingNodeServiceProtocol.swift
│ │ │ │ ├── TransactionNodeServiceProtocol.swift
│ │ │ │ └── UtilsNodeServiceProtocol.swift
│ │ │ ├── TransactionNodeService.swift
│ │ │ └── UtilsNodeService.swift
│ │ │ └── Targets
│ │ │ ├── AddressesNodeTarget.swift
│ │ │ ├── AssetsNodeTarget.swift
│ │ │ ├── BlocksNodeTarget.swift
│ │ │ ├── LeasingNodeTarget.swift
│ │ │ ├── TransactionNodeTarget.swift
│ │ │ └── UtilsNodeTarget.swift
│ ├── Signature
│ │ ├── SignatureProtocol.swift
│ │ ├── TransactionSign.swift
│ │ ├── TransactionSignatureProtocol.swift
│ │ ├── TransactionSignatureV1.swift
│ │ ├── TransactionSignatureV2.swift
│ │ └── TransactionType.swift
│ └── WavesSDKConstants.swift
└── WavesSDK.h
├── WavesSDKCrypto.podspec
├── WavesSDKCrypto
├── Info.plist
├── Sources
│ ├── WavesCrypto.swift
│ └── Words.swift
├── Vendors
│ ├── Base58Encoder
│ │ └── Sources
│ │ │ ├── Base58Encoder.swift
│ │ │ ├── base58.c
│ │ │ └── base58.h
│ ├── Blake2
│ │ └── Sources
│ │ │ ├── api.h
│ │ │ ├── blake2-impl.h
│ │ │ ├── blake2.h
│ │ │ ├── blake2b-ref.c
│ │ │ ├── crypto_generichash.c
│ │ │ ├── crypto_generichash.h
│ │ │ ├── crypto_generichash_blake2b.h
│ │ │ ├── export.h
│ │ │ ├── generichash_blake2_api.c
│ │ │ ├── generichash_blake2b.c
│ │ │ ├── randombytes.h
│ │ │ ├── utils.c
│ │ │ └── utils.h
│ ├── Curve25519
│ │ └── Sources
│ │ │ ├── Curve25519
│ │ │ └── curve25519-donna.c
│ │ │ ├── Objc
│ │ │ ├── Curve25519.h
│ │ │ ├── Curve25519.m
│ │ │ ├── Ed25519.h
│ │ │ ├── Ed25519.m
│ │ │ ├── Randomness.h
│ │ │ └── Randomness.m
│ │ │ └── ed25519
│ │ │ ├── additions
│ │ │ ├── compare.c
│ │ │ ├── compare.h
│ │ │ ├── crypto_hash_sha512.h
│ │ │ ├── curve_sigs.c
│ │ │ ├── curve_sigs.h
│ │ │ ├── sign_modified.c
│ │ │ ├── zeroize.c
│ │ │ └── zeroize.h
│ │ │ ├── api.h
│ │ │ ├── base.h
│ │ │ ├── base2.h
│ │ │ ├── d.h
│ │ │ ├── d2.h
│ │ │ ├── fe.h
│ │ │ ├── fe_0.c
│ │ │ ├── fe_1.c
│ │ │ ├── fe_add.c
│ │ │ ├── fe_cmov.c
│ │ │ ├── fe_copy.c
│ │ │ ├── fe_frombytes.c
│ │ │ ├── fe_invert.c
│ │ │ ├── fe_isnegative.c
│ │ │ ├── fe_isnonzero.c
│ │ │ ├── fe_mul.c
│ │ │ ├── fe_neg.c
│ │ │ ├── fe_pow22523.c
│ │ │ ├── fe_sq.c
│ │ │ ├── fe_sq2.c
│ │ │ ├── fe_sub.c
│ │ │ ├── fe_tobytes.c
│ │ │ ├── ge.h
│ │ │ ├── ge_add.c
│ │ │ ├── ge_add.h
│ │ │ ├── ge_double_scalarmult.c
│ │ │ ├── ge_frombytes.c
│ │ │ ├── ge_madd.c
│ │ │ ├── ge_madd.h
│ │ │ ├── ge_msub.c
│ │ │ ├── ge_msub.h
│ │ │ ├── ge_p1p1_to_p2.c
│ │ │ ├── ge_p1p1_to_p3.c
│ │ │ ├── ge_p2_0.c
│ │ │ ├── ge_p2_dbl.c
│ │ │ ├── ge_p2_dbl.h
│ │ │ ├── ge_p3_0.c
│ │ │ ├── ge_p3_dbl.c
│ │ │ ├── ge_p3_to_cached.c
│ │ │ ├── ge_p3_to_p2.c
│ │ │ ├── ge_p3_tobytes.c
│ │ │ ├── ge_precomp_0.c
│ │ │ ├── ge_scalarmult_base.c
│ │ │ ├── ge_sub.c
│ │ │ ├── ge_sub.h
│ │ │ ├── ge_tobytes.c
│ │ │ ├── nacl_includes
│ │ │ ├── crypto_int32.h
│ │ │ ├── crypto_int64.h
│ │ │ ├── crypto_sign.h
│ │ │ ├── crypto_sign_edwards25519sha512batch.h
│ │ │ ├── crypto_uint32.h
│ │ │ ├── crypto_uint64.h
│ │ │ └── crypto_verify_32.h
│ │ │ ├── nacl_sha512
│ │ │ ├── blocks.c
│ │ │ └── hash.c
│ │ │ ├── open.c
│ │ │ ├── pow22523.h
│ │ │ ├── pow225521.h
│ │ │ ├── sc.h
│ │ │ ├── sc_muladd.c
│ │ │ ├── sc_reduce.c
│ │ │ ├── sign.c
│ │ │ └── sqrtm1.h
│ └── Keccak
│ │ └── Sources
│ │ ├── keccak.c
│ │ └── keccak.h
└── WavesSDKCrypto.h
├── WavesSDKExamples
├── Podfile
├── Podfile.lock
├── WavesSDKExamples.xcodeproj
│ └── project.pbxproj
└── WavesSDKExamples
│ ├── Resources
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ └── LaunchScreen.storyboard
│ └── Info.plist
│ └── Sources
│ ├── AppDelegate.swift
│ ├── AssetListViewController.swift
│ └── Base.lproj
│ └── Main.storyboard
├── WavesSDKExtensions.podspec
├── WavesSDKExtensions
├── Info.plist
├── InternalWavesSDKExtensions.h
└── Sources
│ ├── Extensions
│ ├── Any+Name.swift
│ ├── Array
│ │ ├── Array+Extension.swift
│ │ └── Array+Sort.swift
│ ├── Assert+Message.swift
│ ├── Bundle+Version.swift
│ ├── Date
│ │ ├── DateExtension+Sync.swift
│ │ ├── DateFormatter+ISO.swift
│ │ └── DateFormatter+Once.swift
│ ├── Dictionary+Json.swift
│ ├── DispatchTimeInterval.swift
│ ├── Encodable+Dictionary.swift
│ ├── JSONDecoder+TimestampDiff.swift
│ ├── JSONDecoder
│ │ ├── JSONDecoder+JSON.swift
│ │ └── JSONDecoder+Rx.swift
│ ├── NSObject+AssociatedObject.swift
│ ├── NumberFormatter+Once.swift
│ ├── ObjectDestructor.swift
│ ├── ObservableType+Weak.swift
│ ├── Optional+Hashable.swift
│ ├── RxSwift+Scheduler.swift
│ ├── String
│ │ ├── String+Bytes.swift
│ │ ├── String+Escaped.swift
│ │ ├── String+UInt.swift
│ │ ├── String+URL.swift
│ │ └── String+Utils.swift
│ ├── Thread+Assisstants.swift
│ └── UInt8+Assisstants.swift
│ └── Type
│ ├── Runtime.swift
│ ├── SweetLogger
│ ├── ObservableType+SweetLogger.swift
│ ├── SweetLogger.swift
│ ├── SweetLoggerConsole.swift
│ └── SweetLoggerProtocol.swift
│ └── TSUD.swift
└── WavesSDKTests
├── Info.plist
├── WavesCryptoTest.swift
├── WavesServicesBroadcastTransactionsTest.swift
└── WavesServicesTest.swift
/.bundle/config:
--------------------------------------------------------------------------------
1 | ---
2 | BUNDLE_PATH: "Temp/vendor/bundle"
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## OS X files
2 | .DS_Store
3 | .DS_Store?
4 | .Trashes
5 | .Spotlight-V100
6 | *.swp
7 |
8 | ## Xcode build files
9 | DerivedData/
10 | build/
11 |
12 | ## Xcode private settings
13 | *.pbxuser
14 | !default.pbxuser
15 | *.mode1v3
16 | !default.mode1v3
17 | *.mode2v3
18 | !default.mode2v3
19 | *.perspectivev3
20 | !default.perspectivev3
21 | xcuserdata/
22 |
23 | ## Other
24 | *.xccheckout
25 | *.moved-aside
26 | *.xcuserstate
27 | *.xcscmblueprint
28 |
29 | ## Obj-C/Swift specific
30 | *.hmap
31 | *.ipa
32 | *.dSYM.zip
33 | *.dSYM
34 |
35 | ## Playgrounds
36 | timeline.xctimeline
37 | playground.xcworkspace
38 |
39 | # CocoaPods
40 | Pods/
41 | *.xcworkspace
42 |
43 | # Temp
44 | Temp/
45 |
46 | # Ingore Service Plist
47 | *.GoogleService-Info.plist
48 | *.Fabric-Info.plist
49 | WavesWallet-iOS/Resources/Fabric-Info.plist
50 | WavesWallet-iOS/Resources/GoogleService-Info.plist
51 | WavesWallet-iOS/Resources/GoogleService-Info-Dev\.plist
52 | WavesWallet-iOS/Resources/GoogleService-Info-Prod\.plist
53 | WavesWallet-iOS/Resources/GoogleService-Info-Test\.plist
54 | WavesWallet-iOS/Resources/Appsflyer-Info\.plist
55 | WavesWallet-iOS/Resources/Appsflyer-Info.plist
56 | WavesWallet-iOS/Resources/AppSpector-Info\.plist
57 | WavesWallet-iOS/Resources/Sentry\.io-Info\.plist
58 | WavesWallet-iOS/Resources/Sentry-io-Info\.plist
59 |
60 | # Ingore Fastlane
61 | fastlane/report\.xml
62 | fastlane/README\.md
63 |
64 | # Ingore Env
65 | \.env
66 |
67 | # Ingore Bundle vendor
68 | vendor/
69 | Vendor/
70 | WavesWallet-iOS/Resources/Sentry-io-Info\.plist
71 | WavesWallet-iOS/Resources/Amplitude-Info.plist
72 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 WavesPlatform
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '11.0'
2 |
3 | use_frameworks!(true)
4 |
5 |
6 | target 'WavesSDKTests' do
7 |
8 | inherit! :search_paths
9 | pod 'Fakery'
10 | pod 'Nimble'
11 | # pod 'RxTest'
12 |
13 | #TODO: How it fix?
14 | pod 'RxSwift'
15 | pod 'Moya'
16 | pod 'Moya/RxSwift'
17 | end
18 |
19 | # Pods for WavesSDK
20 | target 'StubTest' do
21 | inherit! :search_paths
22 | end
23 |
24 | # Pods for InternalWavesSDKExtensionsK
25 | target 'WavesSDKExtensions' do
26 | inherit! :search_paths
27 | pod 'RxSwift'
28 | end
29 |
30 | # Pods for InternalWavesSDK
31 | target 'WavesSDK' do
32 |
33 | inherit! :search_paths
34 | pod 'RxSwift'
35 | pod 'Moya'
36 | pod 'Moya/RxSwift'
37 | end
38 |
39 |
--------------------------------------------------------------------------------
/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Alamofire (4.8.2)
3 | - Fakery (4.0.0)
4 | - Moya (12.0.1):
5 | - Moya/Core (= 12.0.1)
6 | - Moya/Core (12.0.1):
7 | - Alamofire (~> 4.1)
8 | - Result (~> 4.0)
9 | - Moya/RxSwift (12.0.1):
10 | - Moya/Core
11 | - RxSwift (~> 4.0)
12 | - Nimble (8.0.2)
13 | - Result (4.1.0)
14 | - RxSwift (4.5.0)
15 |
16 | DEPENDENCIES:
17 | - Fakery
18 | - Moya
19 | - Moya/RxSwift
20 | - Nimble
21 | - RxSwift
22 |
23 | SPEC REPOS:
24 | https://github.com/cocoapods/specs.git:
25 | - Alamofire
26 | - Fakery
27 | - Moya
28 | - Nimble
29 | - Result
30 | - RxSwift
31 |
32 | SPEC CHECKSUMS:
33 | Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3
34 | Fakery: 476f6d947de432f84703acc830a1e7166330299b
35 | Moya: cf730b3cd9e005401ef37a85143aa141a12fd38f
36 | Nimble: 622629381bda1dd5678162f21f1368cec7cbba60
37 | Result: bd966fac789cc6c1563440b348ab2598cc24d5c7
38 | RxSwift: f172070dfd1a93d70a9ab97a5a01166206e1c575
39 |
40 | PODFILE CHECKSUM: e63fbc46526e9f529679af7668827c4f512f9df4
41 |
42 | COCOAPODS: 1.7.4
43 |
--------------------------------------------------------------------------------
/StubTest/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/StubTest/Resources/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/StubTest/Resources/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/StubTest/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | NSAppTransportSecurity
24 |
25 | NSAllowsArbitraryLoads
26 |
27 |
28 | UILaunchStoryboardName
29 | LaunchScreen
30 | UIMainStoryboardFile
31 | Main
32 | UIRequiredDeviceCapabilities
33 |
34 | armv7
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UISupportedInterfaceOrientations~ipad
43 |
44 | UIInterfaceOrientationPortrait
45 | UIInterfaceOrientationPortraitUpsideDown
46 | UIInterfaceOrientationLandscapeLeft
47 | UIInterfaceOrientationLandscapeRight
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/StubTest/Sources/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // WavesSDK
4 | //
5 | // Created by rprokofev on 03/04/2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import WavesSDK
11 | import WavesSDKExtensions
12 |
13 | @UIApplicationMain
14 | class AppDelegate: UIResponder, UIApplicationDelegate {
15 |
16 | var window: UIWindow?
17 |
18 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
19 |
20 |
21 | SweetLogger.current.add(plugins: [SweetLoggerConsole(visibleLevels: [.network, .error], isShortLog: false)])
22 | SweetLogger.current.visibleLevels = [.network, .error]
23 |
24 | WavesSDK.initialization(servicesPlugins: .init(data: [],
25 | node: [],
26 | matcher: []),
27 | enviroment: .init(server: .mainNet, timestampServerDiff: 0))
28 |
29 |
30 |
31 | return true
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/StubTest/Sources/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Assets.xcassets/phone.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "phone@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "phone@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Assets.xcassets/phone.imageset/phone@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavesplatform/WavesSDK-iOS/1eec11107cc4cf3af60c767f21260baf1a3c7c99/WavesKeeperExample/KeeperExample/Assets.xcassets/phone.imageset/phone@2x.png
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Assets.xcassets/phone.imageset/phone@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavesplatform/WavesSDK-iOS/1eec11107cc4cf3af60c767f21260baf1a3c7c99/WavesKeeperExample/KeeperExample/Assets.xcassets/phone.imageset/phone@3x.png
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Assets.xcassets/settings.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "settings@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "filename" : "settings@3x.png",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Assets.xcassets/settings.imageset/settings@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavesplatform/WavesSDK-iOS/1eec11107cc4cf3af60c767f21260baf1a3c7c99/WavesKeeperExample/KeeperExample/Assets.xcassets/settings.imageset/settings@2x.png
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Assets.xcassets/settings.imageset/settings@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavesplatform/WavesSDK-iOS/1eec11107cc4cf3af60c767f21260baf1a3c7c99/WavesKeeperExample/KeeperExample/Assets.xcassets/settings.imageset/settings@3x.png
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Constants.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 |
3 | enum GlobalConstants {
4 | enum Colors {
5 | static let blue = UIColor.init(red: 31.0/255.0, green: 90.0/255.0, blue: 246.0/255.0, alpha: 1)
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/CustomNavigationViewController.swift:
--------------------------------------------------------------------------------
1 | // Copyright © 2019 Waves. All rights reserved.
2 | //
3 |
4 | import UIKit
5 |
6 | class CustomNavigationViewController: UINavigationController {
7 |
8 | override func viewDidLoad() {
9 | super.viewDidLoad()
10 |
11 | }
12 |
13 | override var preferredStatusBarStyle: UIStatusBarStyle {
14 | return .lightContent
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/WavesKeeperExample/KeeperExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleURLTypes
20 |
21 |
22 | CFBundleTypeRole
23 | Editor
24 | CFBundleURLIconFile
25 |
26 | CFBundleURLName
27 | keeperExample
28 | CFBundleURLSchemes
29 |
30 | keeperExample
31 |
32 |
33 |
34 | CFBundleVersion
35 | 1
36 | LSRequiresIPhoneOS
37 |
38 | UILaunchStoryboardName
39 | LaunchScreen
40 | UIMainStoryboardFile
41 | Main
42 | UIRequiredDeviceCapabilities
43 |
44 | armv7
45 |
46 | UIStatusBarStyle
47 | UIStatusBarStyleDefault
48 | UISupportedInterfaceOrientations
49 |
50 | UIInterfaceOrientationPortrait
51 |
52 | UISupportedInterfaceOrientations~ipad
53 |
54 | UIInterfaceOrientationPortrait
55 | UIInterfaceOrientationPortraitUpsideDown
56 | UIInterfaceOrientationLandscapeLeft
57 | UIInterfaceOrientationLandscapeRight
58 |
59 | UIViewControllerBasedStatusBarAppearance
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/WavesKeeperExample/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '11.0'
2 |
3 | # Ignore all warnings from all pods
4 | inhibit_all_warnings!
5 |
6 | use_frameworks!(true)
7 |
8 | # Pods for WavesWallet-iOS
9 | target 'KeeperExample' do
10 | project 'KeeperExample.xcodeproj'
11 |
12 | pod "WavesSDK", :git => "git@github.com:wavesplatform/WavesSDK-iOS.git", :branch => "develop"
13 | pod 'CryptoSwift'
14 | pod 'TextFieldEffects'
15 |
16 | end
17 |
--------------------------------------------------------------------------------
/WavesKeeperExample/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Alamofire (4.9.0)
3 | - CryptoSwift (1.0.0)
4 | - Moya (12.0.1):
5 | - Moya/Core (= 12.0.1)
6 | - Moya/Core (12.0.1):
7 | - Alamofire (~> 4.1)
8 | - Result (~> 4.0)
9 | - Moya/RxSwift (12.0.1):
10 | - Moya/Core
11 | - RxSwift (~> 4.0)
12 | - Result (4.1.0)
13 | - RxSwift (4.5.0)
14 | - TextFieldEffects (1.6.0)
15 | - WavesSDK (0.1.9):
16 | - Moya (~> 12.0.1)
17 | - Moya/RxSwift (~> 12.0.1)
18 | - RxSwift (~> 4.0)
19 | - WavesSDKCrypto
20 | - WavesSDKExtensions
21 | - WavesSDKCrypto (0.1.9):
22 | - WavesSDKExtensions
23 | - WavesSDKExtensions (0.1.9):
24 | - RxSwift (~> 4.0)
25 |
26 | DEPENDENCIES:
27 | - CryptoSwift
28 | - TextFieldEffects
29 | - "WavesSDK (from `git@github.com:wavesplatform/WavesSDK-iOS.git`, branch `develop`)"
30 |
31 | SPEC REPOS:
32 | https://github.com/cocoapods/specs.git:
33 | - Alamofire
34 | - CryptoSwift
35 | - Moya
36 | - Result
37 | - RxSwift
38 | - TextFieldEffects
39 | - WavesSDKCrypto
40 | - WavesSDKExtensions
41 |
42 | EXTERNAL SOURCES:
43 | WavesSDK:
44 | :branch: develop
45 | :git: "git@github.com:wavesplatform/WavesSDK-iOS.git"
46 |
47 | CHECKOUT OPTIONS:
48 | WavesSDK:
49 | :commit: cc135790205e7a13ba4ebdf67a1c7e4268c2091d
50 | :git: "git@github.com:wavesplatform/WavesSDK-iOS.git"
51 |
52 | SPEC CHECKSUMS:
53 | Alamofire: afc3e7c6db61476cb45cdd23fed06bad03bbc321
54 | CryptoSwift: d81eeaa59dc5a8d03720fe919a6fd07b51f7439f
55 | Moya: cf730b3cd9e005401ef37a85143aa141a12fd38f
56 | Result: bd966fac789cc6c1563440b348ab2598cc24d5c7
57 | RxSwift: f172070dfd1a93d70a9ab97a5a01166206e1c575
58 | TextFieldEffects: 529b8aff706fb40f82c41c780c0777941a893796
59 | WavesSDK: f0513d8e00c4b0d8e0bfc1a05678a886e8d0c927
60 | WavesSDKCrypto: 1a9205f4ac4a2a17fb6fd981d3b518f81487b379
61 | WavesSDKExtensions: 040099258b4d793ef8eb08fda45ba8cd66ea04d8
62 |
63 | PODFILE CHECKSUM: 3f9383a1fc178113cf358039b20745a9b197cf84
64 |
65 | COCOAPODS: 1.7.5
66 |
--------------------------------------------------------------------------------
/WavesSDK.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |spec|
2 |
3 | spec.name = 'WavesSDK'
4 | spec.version = '0.1.9'
5 | spec.ios.deployment_target = '11.0'
6 | spec.requires_arc = true
7 | spec.swift_version = '5.0'
8 |
9 | spec.license = { :type => 'MIT License', :file => 'LICENSE' }
10 | spec.homepage = 'https://wavesplatform.com'
11 | spec.authors = { 'Mefilt' => 'mefilt@gmail.com', }
12 | spec.summary = 'Extensions are helping for developer fast write code'
13 |
14 | spec.source_files = 'WavesSDK/Sources/**/*.{swift}'
15 | spec.source = { :git => 'https://github.com/wavesplatform/WavesSDK-iOS.git', :tag => 'v' + spec.version.to_s}
16 |
17 | spec.ios.framework = 'Foundation'
18 | spec.ios.framework = 'UIKit'
19 |
20 | spec.dependency 'RxSwift', '~> 4.0'
21 | spec.dependency 'Moya', '~> 12.0.1'
22 | spec.dependency 'Moya/RxSwift', '~> 12.0.1'
23 | spec.dependency 'WavesSDKExtensions'
24 | spec.dependency 'WavesSDKCrypto'
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/WavesSDK/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 0.1.7
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/CachePolicyPlugin.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CachePolicyPlugin.swift
3 | // WavesSDK
4 | //
5 | // Created by rprokofev on 07.04.2020.
6 | // Copyright © 2020 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 |
12 | public protocol CachePolicyTarget {
13 | var cachePolicy: URLRequest.CachePolicy { get }
14 | }
15 |
16 | public final class CachePolicyPlugin: PluginType {
17 |
18 | public init() { }
19 |
20 | public func prepare(_ request: URLRequest, target: TargetType) -> URLRequest {
21 |
22 | if let cachePolicyGettable = target as? CachePolicyTarget {
23 | var mutableRequest = request
24 | mutableRequest.cachePolicy = cachePolicyGettable.cachePolicy
25 | return mutableRequest
26 | }
27 |
28 | return request
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/ContentType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ContentType.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 07/05/2019.
6 | //
7 |
8 | import Foundation
9 |
10 | public enum ContentType {
11 | case applicationJson
12 | case applicationCsv
13 | }
14 |
15 | public extension ContentType {
16 | var headers: [String: String] {
17 | switch self {
18 | case .applicationCsv:
19 | return ["Content-type": "application/csv"]
20 |
21 | case .applicationJson:
22 | return ["Content-type": "application/json"]
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/DispatchQueuePool.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DispatchQueuePool.swift
3 | // WavesSDK
4 | //
5 | // Created by rprokofev on 17.12.2020.
6 | // Copyright © 2020 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | struct DispatchQueuePool {
12 | static let userInteractive = DispatchQueue(label: "WavesSDK", qos: .userInteractive,
13 | attributes: .concurrent,
14 | autoreleaseFrequency: .inherit,
15 | target: nil)
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/Encodable+Base64.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Encodable+Base64.swift
3 | // WavesSDK
4 | //
5 | // Created by rprokofev on 04.09.2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | public extension Encodable {
13 |
14 | var encodableToBase64: String? {
15 | guard let data = try? JSONEncoder().encode(self) else {
16 | return nil
17 | }
18 |
19 | return data.base64EncodedString()
20 | }
21 | }
22 |
23 | public extension String {
24 |
25 | func decodableBase64ToObject() -> T? {
26 |
27 | guard let newData = Data(base64Encoded: self) else { return nil }
28 |
29 |
30 | do {
31 | let object = try JSONDecoder().decode(T.self, from: newData)
32 | return object
33 | } catch let error {
34 | print("error \(error)")
35 | }
36 |
37 | return nil
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/Protocols/DataServicesProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DataServicesProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 28/05/2019.
6 | //
7 |
8 | import Foundation
9 |
10 | public protocol DataServicesProtocol {
11 |
12 | var aliasDataService: AliasDataServiceProtocol { get }
13 | var assetsDataService: AssetsDataServiceProtocol { get }
14 | var candlesDataService: CandlesDataServiceProtocol { get }
15 | var pairsPriceDataService: PairsPriceDataServiceProtocol { get }
16 | var transactionsDataService: TransactionsDataServiceProtocol { get }
17 | }
18 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/Protocols/MatcherServicesProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MatcherServicesProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 28/05/2019.
6 | //
7 |
8 | import Foundation
9 |
10 | public protocol MatcherServicesProtocol {
11 |
12 | var balanceMatcherService: BalanceMatcherServiceProtocol { get }
13 | var orderBookMatcherService: OrderBookMatcherServiceProtocol { get }
14 | var publicKeyMatcherService: PublicKeyMatcherServiceProtocol { get }
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/Protocols/NodeServicesProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NodeServicesProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 28/05/2019.
6 | //
7 |
8 | import Foundation
9 |
10 | public protocol NodeServicesProtocol {
11 |
12 | var addressesNodeService: AddressesNodeServiceProtocol { get }
13 | var assetsNodeService: AssetsNodeServiceProtocol { get }
14 | var blocksNodeService: BlocksNodeServiceProtocol { get }
15 | var leasingNodeService: LeasingNodeServiceProtocol { get }
16 | var transactionNodeService: TransactionNodeServiceProtocol { get }
17 | var utilsNodeService: UtilsNodeServiceProtocol { get }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/Protocols/ServicesProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ServicesProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 28/05/2019.
6 | //
7 |
8 | import Foundation
9 | import Moya
10 |
11 | extension InternalWavesService {
12 |
13 | static func moyaProvider(plugins: [PluginType]) -> MoyaProvider {
14 | return MoyaProvider(callbackQueue: DispatchQueuePool.userInteractive,
15 | plugins: plugins)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/Protocols/WavesServicesProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // WavesServicesProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 28/05/2019.
6 | //
7 |
8 | import Foundation
9 |
10 | public protocol WavesServicesProtocol {
11 |
12 | var nodeServices: NodeServicesProtocol { get }
13 | var dataServices: DataServicesProtocol { get }
14 | var matcherServices: MatcherServicesProtocol { get }
15 | }
16 |
17 | protocol InternalWavesServiceProtocol {
18 | var enviroment: WavesEnvironment { get set }
19 | }
20 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/String+Waves.swift:
--------------------------------------------------------------------------------
1 | //
2 | // String+Waves.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 21/05/2019.
6 | //
7 |
8 | import Foundation
9 | import WavesSDKExtensions
10 |
11 | public extension String {
12 |
13 | var normalizeWavesAssetId: String {
14 | if self == WavesSDKConstants.wavesAssetId {
15 | return ""
16 | } else {
17 | return self
18 | }
19 | }
20 |
21 | var normalizeToNullWavesAssetId: Any {
22 |
23 | let assetId = self.normalizeWavesAssetId
24 |
25 | if assetId.isEmpty {
26 | return NSNull()
27 | } else {
28 | return assetId
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/Type/InternalWavesService.swift:
--------------------------------------------------------------------------------
1 | //
2 | // InternalWavesService.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 03/06/2019.
6 | //
7 |
8 | import Foundation
9 |
10 | internal class InternalWavesService: InternalWavesServiceProtocol {
11 |
12 | private var internalEenviroment: WavesEnvironment
13 |
14 | internal(set) public var enviroment: WavesEnvironment {
15 |
16 | get {
17 | objc_sync_enter(self)
18 | defer { objc_sync_exit(self) }
19 | return internalEenviroment
20 | }
21 |
22 | set {
23 | objc_sync_enter(self)
24 | defer { objc_sync_exit(self) }
25 | internalEenviroment = newValue
26 | }
27 | }
28 |
29 | init(enviroment: WavesEnvironment) {
30 | self.internalEenviroment = enviroment
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/Type/MatcherServices.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MatcherServices.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 03/06/2019.
6 | //
7 |
8 | import Foundation
9 | import Moya
10 |
11 | internal final class MatcherServices: InternalWavesService, MatcherServicesProtocol {
12 |
13 | private(set) var balanceMatcherService: BalanceMatcherServiceProtocol
14 |
15 | private(set) var orderBookMatcherService: OrderBookMatcherServiceProtocol
16 |
17 | private(set) var publicKeyMatcherService: PublicKeyMatcherServiceProtocol
18 |
19 | override var enviroment: WavesEnvironment {
20 |
21 | didSet {
22 |
23 | [balanceMatcherService,
24 | orderBookMatcherService,
25 | publicKeyMatcherService]
26 | .map { $0 as? InternalWavesService }
27 | .compactMap { $0 }
28 | .forEach { $0.enviroment = enviroment }
29 | }
30 | }
31 |
32 | init(plugins: [PluginType],
33 | enviroment: WavesEnvironment) {
34 |
35 |
36 | balanceMatcherService = BalanceMatcherService(balanceProvider: MatcherServices.moyaProvider(plugins: plugins), enviroment: enviroment)
37 | orderBookMatcherService = OrderBookMatcherService(orderBookProvider: MatcherServices.moyaProvider(plugins: plugins), enviroment: enviroment)
38 | publicKeyMatcherService = PublicKeyMatcherService(publicKeyProvider: MatcherServices.moyaProvider(plugins: plugins), enviroment: enviroment)
39 |
40 | super.init(enviroment: enviroment)
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Assisstants/Type/WavesServices.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ServicesFactoryProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 07/05/2019.
6 | //
7 |
8 | import Foundation
9 | import Moya
10 |
11 | internal final class WavesServices: InternalWavesService, WavesServicesProtocol {
12 |
13 | private(set) var nodeServices: NodeServicesProtocol
14 | private(set) var dataServices: DataServicesProtocol
15 | private(set) var matcherServices: MatcherServicesProtocol
16 |
17 | override var enviroment: WavesEnvironment {
18 |
19 | didSet {
20 |
21 | [nodeServices,
22 | dataServices,
23 | matcherServices]
24 | .map { $0 as? InternalWavesService }
25 | .compactMap { $0 }
26 | .forEach { $0.enviroment = enviroment }
27 | }
28 | }
29 |
30 | init(enviroment: WavesEnvironment,
31 | dataServicePlugins: [PluginType],
32 | nodeServicePlugins: [PluginType],
33 | matcherServicePlugins: [PluginType]) {
34 |
35 | self.nodeServices = NodeServices(plugins: nodeServicePlugins,
36 | enviroment: enviroment)
37 |
38 | self.dataServices = DataServices(plugins: dataServicePlugins,
39 | enviroment: enviroment)
40 |
41 | self.matcherServices = MatcherServices(plugins: matcherServicePlugins,
42 | enviroment: enviroment)
43 |
44 | super.init(enviroment: enviroment)
45 |
46 | self.enviroment = enviroment
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/DataServiceTypes.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DataService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 09.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 |
12 | public enum DataService {}
13 |
14 | public extension DataService {
15 | internal enum Target {}
16 | enum DTO {}
17 | enum Query {}
18 | }
19 |
20 | protocol DataTargetType: TargetType {
21 | var dataUrl: URL { get }
22 | }
23 |
24 | extension DataTargetType {
25 |
26 | private var dataVersion: String {
27 | return "/v0"
28 | }
29 |
30 | var baseURL: URL { return URL(string: "\(dataUrl.relativeString)\(dataVersion)")! }
31 |
32 | var sampleData: Data {
33 | return Data()
34 | }
35 |
36 | var headers: [String: String]? {
37 | return ContentType.applicationJson.headers
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Models/AliasData.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AliasApi.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 1/30/19.
6 | // Copyright © 2019 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DataService.DTO {
12 |
13 | struct Alias: Decodable {
14 | public let alias: String
15 | public let address: String
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Models/AssetData.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Asset.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 09.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DataService.DTO {
12 | struct Asset: Decodable {
13 | public let ticker: String?
14 | public let id: String
15 | public let name: String
16 | public let precision: Int
17 | public let description: String
18 | public let height: Int64
19 | public let timestamp: Date
20 | public let sender: String
21 | public let quantity: Int64
22 | public let reissuable: Bool
23 | public let hasScript: Bool
24 | public let minSponsoredFee: Int64?
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Models/CandleData.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CandleApi.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 12/23/18.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DataService.DTO {
12 | struct Chart: Decodable {
13 |
14 | public struct Candle: Decodable {
15 | public let time: Date
16 | public let volume: Double?
17 | public let close: Double?
18 | public let high: Double?
19 | public let low: Double?
20 | public let open: Double?
21 | }
22 |
23 | public let candles: [Candle]
24 |
25 | public init(candles: [Candle]) {
26 | self.candles = candles
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Models/PairPriceData.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PairApi.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 12/26/18.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DataService.DTO {
12 |
13 | struct PairPrice: Decodable {
14 |
15 | public let firstPrice: Double
16 | public let lastPrice: Double
17 | public let volume: Double
18 | public let volumeWaves: Double?
19 | public let quoteVolume: Double?
20 | }
21 |
22 | struct PairPriceSearch: Decodable {
23 |
24 | public let data: PairPrice
25 | public let amountAsset: String
26 | public let priceAsset: String
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Models/PairsRateData.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PairsRateData.swift
3 | // WavesSDK
4 | //
5 | // Created by Pavel Gubin on 22.01.2020.
6 | // Copyright © 2020 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DataService.DTO {
12 |
13 | struct PairRate {
14 | public let amountAssetId: String
15 | public let priceAssetId: String
16 | public let rate: Double
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Models/ResponseData.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Response.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 09.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DataService {
12 | struct Response: Decodable {
13 | public let type: String
14 | public let data: T
15 | public let isLastPage: Bool?
16 | public let lastCursor: String?
17 |
18 | public init(type: String, data: T, isLastPage: Bool?, lastCursor: String?) {
19 | self.type = type
20 | self.data = data
21 | self.isLastPage = isLastPage
22 | self.lastCursor = lastCursor
23 | }
24 |
25 | enum CodingKeys: String, CodingKey {
26 | case type = "__type"
27 | case data
28 | case isLastPage
29 | case lastCursor
30 | }
31 | }
32 |
33 | struct OptionalResponse: Decodable {
34 | public let type: String
35 | public let data: T?
36 | public let isLastPage: Bool?
37 | public let lastCursor: String?
38 |
39 | enum CodingKeys: String, CodingKey {
40 | case type = "__type"
41 | case data
42 | case isLastPage
43 | case lastCursor
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Models/TransactionData.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Transaction.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 09.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DataService.DTO {
12 |
13 | enum OrderType: String, Decodable {
14 | case sell
15 | case buy
16 | }
17 |
18 | struct Pair: Decodable {
19 | public let amountAsset: String
20 | public let priceAsset: String
21 | }
22 |
23 | struct Order: Decodable {
24 | public let id: String
25 | public let senderPublicKey: String
26 | public let matcherPublicKey: String
27 | public let assetPair: Pair
28 | public let orderType: OrderType
29 | public let price: Double
30 | public let sender: String
31 | public let amount: Double
32 | public let timestamp: Date
33 | public let expiration: Date
34 | public let matcherFee: Double
35 | public let signature: String
36 | }
37 |
38 | struct ExchangeTransaction: Decodable {
39 | public let id: String
40 | public let timestamp: Date
41 | public let height: Int64
42 | public let type: Int
43 | public let fee: Double
44 | public let sender: String
45 | public let senderPublicKey: String
46 | public let buyMatcherFee: Double
47 | public let sellMatcherFee: Double
48 | public let price: Double
49 | public let amount: Double
50 | public let order1: Order
51 | public let order2: Order
52 | }
53 | }
54 |
55 | extension DataService.DTO.ExchangeTransaction {
56 |
57 | public var orderType: DataService.DTO.OrderType {
58 | let order = order1.timestamp > order2.timestamp ? order1 : order2
59 | return order.orderType
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Queries/CandleFiltersDataQuery.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CandleFilters.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 12/23/18.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DataService.Query {
12 |
13 | struct CandleFilters: Codable {
14 | public let amountAsset: String
15 | public let priceAsset: String
16 | public let timeStart: Int64
17 | public let timeEnd: Int64
18 | public let interval: String
19 | public let matcher: String?
20 |
21 | public init(amountAsset: String, priceAsset: String, timeStart: Int64, timeEnd: Int64, interval: String, matcher: String?) {
22 | self.amountAsset = amountAsset
23 | self.priceAsset = priceAsset
24 | self.timeStart = timeStart
25 | self.timeEnd = timeEnd
26 | self.interval = interval
27 | self.matcher = matcher
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Queries/ExchangeFiltersDataQuery.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ExchangeFilters.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 09.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DataService.Query {
12 | struct ExchangeFilters: Codable {
13 | // Address of a matcher which sent the transaction
14 | public let matcher: String?
15 | // Address of a trader-participant in a transaction — an ORDER sender
16 | public let sender: String?
17 | // Time range filter, start. Defaults to first transaction's time_stamp in db.
18 | public let timeStart: String?
19 | // Time range filter, end. Defaults to now.
20 | public let timeEnd: String?
21 | // Asset ID of the amount asset.
22 | public let amountAsset: String?
23 | // Asset ID of the price asset.
24 | public let priceAsset: String?
25 | // Cursor in base64 encoding. Holds information about timestamp, id, sort.
26 | public let after: String?
27 | // Sort order. Gonna be rewritten by cursor's sort if present.
28 | public var sort: String = "desc"
29 | // How many transactions to await in response.
30 | public let limit: Int
31 |
32 | public init(matcher: String?, sender: String?, timeStart: String?, timeEnd: String?, amountAsset: String?, priceAsset: String?, after: String?, sort: String = "desc", limit: Int) {
33 | self.matcher = matcher
34 | self.sender = sender
35 | self.timeStart = timeStart
36 | self.timeEnd = timeEnd
37 | self.amountAsset = amountAsset
38 | self.priceAsset = priceAsset
39 | self.after = after
40 | self.sort = sort
41 | self.limit = limit
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Queries/MassTransferDataQuery.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MassTransferDataQuery.swift
3 | // WavesSDK
4 | //
5 | // Created by vvisotskiy on 10.03.2020.
6 | // Copyright © 2020 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | extension DataService.Query {
12 |
13 | /// Способы сортировок
14 | public enum SortOrder: String, Encodable, Hashable {
15 | /// по возростанию
16 | case asc
17 |
18 | /// по убыванию
19 | case desc
20 | }
21 |
22 | public struct MassTransferDataQuery: Encodable, Hashable {
23 |
24 | ///
25 | public let senders: [String]?
26 |
27 | /// (ISO-8601 or timestamp in milliseconds)
28 | public let timeStart: String?
29 |
30 | /// (ISO-8601 or timestamp in milliseconds)
31 | public let timeEnd: String?
32 |
33 | ///
34 | public let recipient: String
35 |
36 | /// Фильтрация транзакций по asset id
37 | public let assetId: String?
38 |
39 | /// Курсор последней записи в списке (base64 строчка которая держит в себе инфу по оффсету, таймстампа и тд)
40 | public let after: String?
41 |
42 | /// признак сортировки
43 | public let sort: SortOrder
44 |
45 | /// признак предела загрузки за один раз
46 | public let limit: UInt?
47 |
48 | public init(senders: [String]?,
49 | timeStart: String?,
50 | timeEnd: String?,
51 | recipient: String,
52 | assetId: String?,
53 | after: String?,
54 | sort: SortOrder = .desc,
55 | limit: UInt?) {
56 | self.timeStart = timeStart
57 | self.timeEnd = timeEnd
58 | self.recipient = recipient
59 | self.assetId = assetId
60 | self.after = after
61 | self.sort = sort
62 | self.limit = limit
63 | self.senders = senders
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Services/AliasDataService.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AliasDataService.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 06/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 | import Moya
11 |
12 | final class AliasDataService: InternalWavesService, AliasDataServiceProtocol {
13 |
14 | private let aliasProvider: MoyaProvider
15 |
16 | init(aliasProvider: MoyaProvider, enviroment: WavesEnvironment) {
17 | self.aliasProvider = aliasProvider
18 | super.init(enviroment: enviroment)
19 | }
20 |
21 | public func alias(name: String) -> Observable {
22 |
23 | return self
24 | .aliasProvider
25 | .rx
26 | .request(DataService.Target.Alias(dataUrl: enviroment.dataUrl,
27 | kind: .alias(name: name)))
28 | .filterSuccessfulStatusAndRedirectCodes()
29 | .catchError({ (error) -> Single in
30 | return Single.error(NetworkError.error(by: error))
31 | })
32 | .map(DataService.Response.self)
33 | .map { $0.data }
34 | .asObservable()
35 | }
36 |
37 | public func aliases(address: String) -> Observable<[DataService.DTO.Alias]> {
38 |
39 | return self
40 | .aliasProvider
41 | .rx
42 | .request(DataService.Target.Alias(dataUrl: enviroment.dataUrl,
43 | kind: .list(address: address)))
44 | .filterSuccessfulStatusAndRedirectCodes()
45 | .catchError({ (error) -> Single in
46 | return Single.error(NetworkError.error(by: error))
47 | })
48 | .map(DataService.Response<[DataService.Response]>.self)
49 | .map { $0.data.map { $0.data } }
50 | .asObservable()
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Services/CandlesDataService.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CandlesDataService.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 06/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 | import Moya
11 |
12 | final class CandlesDataService: InternalWavesService, CandlesDataServiceProtocol {
13 |
14 | private let candlesProvider: MoyaProvider
15 |
16 | init(candlesProvider: MoyaProvider, enviroment: WavesEnvironment) {
17 | self.candlesProvider = candlesProvider
18 | super.init(enviroment: enviroment)
19 | }
20 |
21 | public func candles(query: DataService.Query.CandleFilters) -> Observable {
22 |
23 | return self
24 | .candlesProvider
25 | .rx
26 | .request(.init(query: query,
27 | dataUrl: enviroment.dataUrl))
28 | .filterSuccessfulStatusAndRedirectCodes()
29 | .catchError({ (error) -> Single in
30 | return Single.error(NetworkError.error(by: error))
31 | })
32 | .map(DataService.Response<[DataService.Response]>.self,
33 | atKeyPath: nil,
34 | using: JSONDecoder.isoDecoderBySyncingTimestamp(enviroment.timestampServerDiff),
35 | failsOnEmptyData: false)
36 | .map({ (response) -> DataService.DTO.Chart in
37 | return DataService.DTO.Chart(candles: response.data.map { $0.data } )
38 | })
39 | .asObservable()
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Services/Protocols/AliasDataServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AliasDataServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol AliasDataServiceProtocol {
12 |
13 | /**
14 | Get address for alias
15 | */
16 | func alias(name: String) -> Observable
17 |
18 | /**
19 | Get a list of aliases for a given address
20 | */
21 | func aliases(address: String) -> Observable<[DataService.DTO.Alias]>
22 | }
23 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Services/Protocols/AssetsDataServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AssetsDataServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol AssetsDataServiceProtocol {
12 |
13 | /**
14 | Get a list of assets info from a list of IDs
15 | */
16 | func assets(ids: [String]) -> Observable<[DataService.DTO.Asset?]>
17 |
18 | /**
19 | Get asset info by asset ID
20 | */
21 | func asset(id: String) -> Observable
22 |
23 | func searchAssets(search: String, limit: Int) -> Observable<[DataService.DTO.Asset]>
24 | }
25 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Services/Protocols/CandlesDataServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CandlesDataServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol CandlesDataServiceProtocol {
12 |
13 | /**
14 | Get candles by amount and price assets. Maximum amount of candles in response – 1440.
15 | */
16 | func candles(query: DataService.Query.CandleFilters) -> Observable
17 | }
18 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Services/Protocols/PairsPriceDataServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PairsPriceDataService.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol PairsPriceDataServiceProtocol {
12 | /**
13 | Get pair info by amount and price assets
14 | */
15 | func pairsPrice(query: DataService.Query.PairsPrice) -> Observable<[DataService.DTO.PairPrice?]>
16 | func pairsRate(query: DataService.Query.PairsRate) -> Observable<[DataService.DTO.PairRate]>
17 | func searchByAsset(query: DataService.Query.PairsPriceSearch) -> Observable<[DataService.DTO.PairPriceSearch]>
18 | }
19 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Services/Protocols/TransactionsDataServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionsDataServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol TransactionsDataServiceProtocol {
12 |
13 | /**
14 | Get a list of exchange transactions by applying filters
15 | */
16 | func transactionsExchange(query: DataService.Query.ExchangeFilters) -> Observable<[DataService.DTO.ExchangeTransaction]>
17 |
18 | func getMassTransferTransactions(query: DataService.Query.MassTransferDataQuery)
19 | -> Observable>
20 | }
21 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Targets/AliasDataTarget.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AliasApiService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 1/30/19.
6 | // Copyright © 2019 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 |
12 | extension DataService.Target {
13 |
14 | struct Alias {
15 | enum Kind {
16 | case alias(name: String)
17 | case list(address: String)
18 | }
19 |
20 | let dataUrl: URL
21 | let kind: Kind
22 | }
23 | }
24 |
25 | extension DataService.Target.Alias: DataTargetType {
26 |
27 | private enum Constants {
28 | static let aliases = "aliases"
29 | static let address = "address"
30 | }
31 |
32 | var path: String {
33 | switch kind {
34 |
35 | case .alias(let name):
36 | return Constants.aliases + "/" + "\(name)"
37 |
38 | case .list:
39 | return Constants.aliases
40 | }
41 | }
42 |
43 | var method: Moya.Method {
44 | return .get
45 | }
46 |
47 | var task: Task {
48 | switch kind {
49 | case .alias:
50 | return .requestPlain
51 |
52 | case .list(let address):
53 | return .requestParameters(parameters: [Constants.address : address], encoding: URLEncoding.default)
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Targets/AssetsDataTarget.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AssetsService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 06.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 | import WavesSDKExtensions
12 |
13 | extension DataService.Target {
14 |
15 | struct Assets {
16 | enum Kind {
17 | /**
18 | Response:
19 | - API.Response<[API.Response]>.self
20 | */
21 | case getAssets(ids: [String])
22 | /**
23 | Response:
24 | - API.Response.self
25 | */
26 | case getAsset(id: String)
27 |
28 | case search(text: String, limit: Int)
29 | }
30 |
31 | let kind: Kind
32 | let dataUrl: URL
33 | }
34 | }
35 |
36 | extension DataService.Target.Assets: DataTargetType {
37 | fileprivate enum Constants {
38 | static let assets = "assets"
39 | static let ids = "ids"
40 | }
41 |
42 | var path: String {
43 | switch kind {
44 | case .getAsset(let id):
45 | return Constants.assets + "/" + "\(id)".urlEscaped
46 | case .getAssets, .search:
47 | return Constants.assets
48 | }
49 | }
50 |
51 | var method: Moya.Method {
52 | switch kind {
53 | case .getAsset:
54 | return .get
55 | case .getAssets, .search:
56 | return .post
57 | }
58 | }
59 |
60 | var task: Task {
61 | switch kind {
62 | case .getAssets(let ids):
63 | return Task.requestParameters(parameters: [Constants.ids: ids],
64 | encoding: JSONEncoding.default)
65 |
66 | case .search(let string, let limit):
67 | return Task.requestParameters(parameters: ["search": string, "limit": limit],
68 | encoding: JSONEncoding.default)
69 | case .getAsset:
70 | return .requestPlain
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Targets/CandlesDataTarget.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CandlesApiService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 12/22/18.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 | import WavesSDKExtensions
12 |
13 | extension DataService.Target {
14 |
15 | struct Candles {
16 | let query: DataService.Query.CandleFilters
17 | let dataUrl: URL
18 | }
19 | }
20 |
21 | private enum Constants {
22 | static let candles: String = "candles"
23 | }
24 |
25 | extension DataService.Target.Candles: DataTargetType {
26 |
27 | var path: String {
28 | return "/\(Constants.candles)/\(query.amountAsset)/\(query.priceAsset)"
29 | }
30 |
31 | var method: Moya.Method {
32 | return .get
33 | }
34 |
35 | var task: Task {
36 | return .requestParameters(parameters: query.dictionary, encoding: URLEncoding.default)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Data/Targets/TransactionsDataTarget.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionsService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 09.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 |
12 | extension DataService.Target {
13 |
14 | struct Transactions {
15 | enum Kind {
16 |
17 | /**
18 | Response:
19 | - API.Response<[API.Response.self
20 | */
21 | case getExchange(id: String)
22 | case getExchangeWithFilters(DataService.Query.ExchangeFilters)
23 |
24 | case getMassTransferTransactions(DataService.Query.MassTransferDataQuery)
25 | }
26 |
27 | let kind: Kind
28 | let dataUrl: URL
29 | }
30 | }
31 |
32 | extension DataService.Target.Transactions: DataTargetType {
33 |
34 | private enum Constants {
35 | static let exchange = "transactions/exchange"
36 | static let massTransfer = "transactions/mass-transfer"
37 | }
38 |
39 | var path: String {
40 | switch kind {
41 | case .getExchange(let id): return Constants.exchange + "/\(id)".urlEscaped
42 |
43 | case .getExchangeWithFilters: return Constants.exchange
44 |
45 | case .getMassTransferTransactions: return Constants.massTransfer
46 | }
47 | }
48 |
49 | var method: Moya.Method {
50 | switch kind {
51 | case .getExchange, .getExchangeWithFilters, .getMassTransferTransactions:
52 | return .get
53 | }
54 | }
55 |
56 | var task: Task {
57 | switch kind {
58 | case .getExchange:
59 | return .requestPlain
60 |
61 | case .getExchangeWithFilters(let filter):
62 | return .requestParameters(parameters: filter.dictionary, encoding: URLEncoding.default)
63 |
64 | case .getMassTransferTransactions(let query):
65 | return .requestParameters(parameters: query.dictionary, encoding: URLEncoding.default)
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Matcher/MatcherServiceTypes.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MatcherServiceTypes.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 20.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 |
12 | public enum MatcherService {}
13 |
14 | public extension MatcherService {
15 | enum DTO {}
16 | enum Query {}
17 | internal enum Target {}
18 | }
19 |
20 | protocol MatcherTargetType: TargetType {
21 | var matcherUrl: URL { get }
22 | }
23 |
24 | extension MatcherTargetType {
25 |
26 | var baseURL: URL { return matcherUrl }
27 |
28 | var sampleData: Data {
29 | return Data()
30 | }
31 |
32 | var headers: [String: String]? {
33 | return ContentType.applicationJson.headers
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Matcher/Models/MarketMatcher.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MarketApi.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 12/23/18.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension MatcherService.DTO {
12 |
13 | struct Market: Decodable {
14 | public struct AssetInfo: Decodable {
15 | public let decimals: Int
16 | }
17 |
18 | public let amountAsset: String
19 | public let amountAssetName: String
20 | public let amountAssetInfo: AssetInfo?
21 |
22 | public let priceAsset: String
23 | public let priceAssetName: String
24 | public let priceAssetInfo: AssetInfo?
25 | }
26 |
27 | struct MarketResponse: Decodable {
28 | public let markets: [Market]
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Matcher/Models/OrderBookMatcher.swift:
--------------------------------------------------------------------------------
1 | //
2 | // OrderBookApi.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 12/17/18.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension MatcherService.DTO {
12 |
13 | struct OrderBook: Decodable {
14 |
15 | public struct Pair: Decodable {
16 | public let amountAsset: String
17 | public let priceAsset: String
18 | }
19 |
20 | public struct Value: Decodable {
21 | public let amount: Int64
22 | public let price: Int64
23 | }
24 |
25 | public let date: Date
26 | public let pair: Pair
27 | public let bids: [Value]
28 | public let asks: [Value]
29 |
30 | private enum CodingKeys: String, CodingKey {
31 | case date = "timestamp"
32 | case pair, bids, asks
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Matcher/Models/OrderMatcher.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MyOrderMatcher.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 12/26/18.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension MatcherService.DTO {
12 |
13 | struct Order: Decodable {
14 |
15 | public struct AssetPair: Decodable {
16 | public let amountAsset: String?
17 | public let priceAsset: String?
18 | }
19 |
20 | public enum OrderType: String, Decodable {
21 | case sell
22 | case buy
23 | }
24 |
25 | public enum Status: String, Decodable {
26 | case Accepted
27 | case PartiallyFilled
28 | case Cancelled
29 | case Filled
30 | }
31 |
32 | public let id: String
33 | public let type: OrderType
34 | public let amount: Int64
35 | public let price: Int64
36 | public let filled: Int64
37 | public let status: Status
38 | public let timestamp: Date
39 |
40 | public let fee: Int64?
41 | public let feeAsset: String?
42 | public let assetPair: AssetPair
43 | }
44 |
45 | struct SettingRateFee {
46 | public let assetId: String
47 | public let rate: Double
48 | }
49 |
50 | struct Setting: Decodable {
51 | public let priceAssets: [String]
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Matcher/Services/BalanceMatcherService.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BalanceMatcherService.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 06/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 | import Moya
11 |
12 | final class BalanceMatcherService: InternalWavesService, BalanceMatcherServiceProtocol {
13 |
14 | private let balanceProvider: MoyaProvider
15 |
16 | init(balanceProvider: MoyaProvider, enviroment: WavesEnvironment) {
17 | self.balanceProvider = balanceProvider
18 | super.init(enviroment: enviroment)
19 | }
20 |
21 | public func balanceReserved(query: MatcherService.Query.ReservedBalances) -> Observable<[String: Int64]> {
22 |
23 | return self
24 | .balanceProvider
25 | .rx
26 | .request(.init(kind: .getReservedBalances(query),
27 | matcherUrl: enviroment.matcherUrl))
28 | .filterSuccessfulStatusAndRedirectCodes()
29 | .catchError({ (error) -> Single in
30 | return Single.error(NetworkError.error(by: error))
31 | })
32 | .map([String: Int64].self)
33 | .asObservable()
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Matcher/Services/Protocols/BalanceMatcherServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BalanceMatcherServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import RxSwift
9 | import Moya
10 |
11 | public protocol BalanceMatcherServiceProtocol {
12 |
13 |
14 | /**
15 | Get non-zero balance of open orders
16 | */
17 |
18 | func balanceReserved(query: MatcherService.Query.ReservedBalances) -> Observable<[String: Int64]>
19 |
20 | }
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Matcher/Services/Protocols/OrderBookMatcherServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // OrderBookMatcherServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol OrderBookMatcherServiceProtocol {
12 |
13 | /**
14 | Get orderbook for a given Asset Pair
15 | */
16 | func orderBook(amountAsset: String, priceAsset: String) -> Observable
17 |
18 | /**
19 | Get the all open trading markets along with trading pairs meta data
20 | */
21 | func orderbook() -> Observable
22 |
23 |
24 | /**
25 | Get OrderResponse History for a given Asset Pair and Public Key
26 | */
27 | func myOrders(query: MatcherService.Query.GetMyOrders) -> Observable<[MatcherService.DTO.Order]>
28 |
29 |
30 | /**
31 | Get OrderResponse History for a all assets and Public Key
32 | */
33 |
34 | func allMyOrders(query: MatcherService.Query.GetAllMyOrders) -> Observable<[MatcherService.DTO.Order]>
35 |
36 | /**
37 | Cancel previously submitted order if it's not already filled completely
38 | */
39 | func cancelOrder(query: MatcherService.Query.CancelOrder) -> Observable
40 |
41 |
42 | /**
43 | Cancel previously submitted orders if it's not already filled completely
44 | */
45 | func cancelAllOrders(query: MatcherService.Query.CancelAllOrders) -> Observable
46 |
47 | /**
48 | Place a new limit order (buy or sell)
49 | */
50 | func createOrder(query: MatcherService.Query.CreateOrder) -> Observable
51 |
52 | /**
53 | Place a new market order (buy or sell)
54 | */
55 | func createMarketOrder(query: MatcherService.Query.CreateOrder) -> Observable
56 |
57 |
58 | /**
59 | Rate get for calculate fee
60 | */
61 | func settingsRatesFee() -> Observable<[MatcherService.DTO.SettingRateFee]>
62 |
63 | //TODO: need documents
64 | func settings() -> Observable
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Matcher/Services/Protocols/PublicKeyMatcherServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PublicKeyMatcherServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol PublicKeyMatcherServiceProtocol {
12 |
13 | /**
14 | Get matcher public key
15 | */
16 | func publicKey() -> Observable
17 | }
18 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Matcher/Services/PublicKeyMatcherService.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PublicKeyMatcherService.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 06/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 | import Moya
11 |
12 | final class PublicKeyMatcherService: InternalWavesService, PublicKeyMatcherServiceProtocol {
13 |
14 | private let publicKeyProvider: MoyaProvider
15 |
16 | init(publicKeyProvider: MoyaProvider, enviroment: WavesEnvironment) {
17 | self.publicKeyProvider = publicKeyProvider
18 | super.init(enviroment: enviroment)
19 | }
20 |
21 | public func publicKey() -> Observable {
22 |
23 | return self
24 | .publicKeyProvider
25 | .rx
26 | .request(.init(matcherUrl: enviroment.matcherUrl))
27 | .filterSuccessfulStatusAndRedirectCodes()
28 | .catchError({ (error) -> Single in
29 | return Single.error(NetworkError.error(by: error))
30 | })
31 | .flatMap({ (response) -> Single in
32 |
33 | do {
34 | guard let key = try JSONSerialization.jsonObject(with: response.data, options: .allowFragments) as? String else {
35 | return Single.error(NetworkError.none)
36 | }
37 | return Single.just(key)
38 | } catch let error {
39 | return Single.error(error)
40 | }
41 | })
42 | .asObservable()
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Matcher/Targets/PublicKeyMatcherTarget.swift:
--------------------------------------------------------------------------------
1 | //
2 | // MatcherService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 12/26/18.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 |
12 | extension MatcherService.Target {
13 |
14 | struct MatcherPublicKey {
15 | var matcherUrl: URL
16 | }
17 | }
18 |
19 | extension MatcherService.Target.MatcherPublicKey: MatcherTargetType {
20 |
21 | private enum Constants {
22 | static let matcher: String = "matcher"
23 | }
24 |
25 | var path: String {
26 | return Constants.matcher
27 | }
28 |
29 | var method: Moya.Method {
30 | return .get
31 | }
32 |
33 | var task: Task {
34 | return .requestPlain
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/AccountAssetsBalanceNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AssetBalanceNodeService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 09.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 |
13 | struct AddressAssetBalance: Decodable {
14 | public let address: String
15 | public let assetId: String
16 | public let balance: Int64
17 | }
18 |
19 | struct AddressAssetsBalance: Decodable {
20 | public let address: String
21 | public let balances: [AssetBalance]
22 | }
23 |
24 | struct AssetBalance: Decodable {
25 |
26 | public struct IssueTransaction: Decodable {
27 | public let type: Int64
28 | public let id: String
29 | public let sender: String
30 | public let senderPublicKey: String
31 | public let fee: Int64
32 | public let timestamp: Date
33 | public let signature: String?
34 | public let proofs: [String]?
35 | public let version: Int64
36 | public let assetId: String
37 | public let name: String
38 | public let quantity: Int64
39 | public let reissuable: Bool
40 | public let decimals: Int64
41 | public let description: String
42 | public let script: String?
43 | }
44 |
45 | public let assetId: String
46 | public let balance: Int64
47 | public let reissuable: Bool
48 | public let minSponsoredAssetFee: Int64?
49 | public let sponsorBalance: Int64?
50 | public let quantity: Int64
51 | public let issueTransaction: IssueTransaction?
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/AccountBalanceNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AddressBalanceNodeService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 09.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 | struct AddressBalance: Decodable {
13 | public let address: String
14 | public let confirmations: Int64
15 | public let balance: Int64
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/AddressData.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AddressData.swift
3 | // WavesSDK
4 | //
5 | // Created by vvisotskiy on 25.03.2020.
6 | // Copyright © 2020 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | extension NodeService.DTO {
12 | public struct AddressesData: Decodable {
13 | public let type: String
14 | public let value: Int64
15 | public let key: String
16 |
17 | public init(type: String, value: Int64, key: String) {
18 | self.type = type
19 | self.value = value
20 | self.key = key
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/AddressScriptInfoNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AddressScriptInfo.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 21/01/2019.
6 | // Copyright © 2019 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 |
13 | struct AddressScriptInfo: Decodable {
14 | public let address: String
15 | public let complexity: Int64
16 | public let extraFee: Int64?
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/AssetDetailNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AssetDetailNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 21/01/2019.
6 | // Copyright © 2019 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 |
13 | struct AssetDetail: Decodable {
14 | public let assetId: String
15 | public let issueHeight: Int64
16 | public let issueTimestamp: Int64
17 | public let issuer: String
18 | public let name: String
19 | public let description: String
20 | public let decimals: Int64
21 | public let reissuable: Bool
22 | public let quantity: Int64
23 | public let scripted: Bool?
24 | public let minSponsoredAssetFee: Int64?
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/BlockNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BlockNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 10.09.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 | struct Block: Decodable {
13 | public let height: Int64
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/Transactions/AliasTransactionNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionAliasNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 07/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 | /**
13 | The Alias transaction creates short readable alias for address
14 | */
15 | struct AliasTransaction: Codable {
16 | public let type: Int
17 | public let id: String
18 | public let sender: String
19 | public let senderPublicKey: String
20 | public let fee: Int64
21 | public let timestamp: Date
22 | public let version: Int
23 | public let height: Int64?
24 |
25 | public let signature: String?
26 | public let proofs: [String]?
27 |
28 | /**
29 | Alias, short name for address in Waves blockchain.
30 | Alias bytes must be in [4;30]
31 | Alphabet: -.0123456789@_abcdefghijklmnopqrstuvwxyz
32 | */
33 | public let alias: String
34 |
35 | public let applicationStatus: String?
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/Transactions/BurnTransactionNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionBurnNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 07/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 |
13 | /**
14 | The Burn transaction irreversible deletes amount of some asset
15 | It's impossible to burn WAVES with the burn transaction.
16 | */
17 | struct BurnTransaction: Codable {
18 | public let type: Int
19 | public let id: String
20 | public let sender: String
21 | public let senderPublicKey: String
22 | public let fee: Int64
23 | public let timestamp: Date
24 | public let version: Int
25 | public let height: Int64?
26 | public let signature: String?
27 | public let proofs: [String]?
28 | public let chainId: UInt8?
29 |
30 | /**
31 | Id of burnable asset in Waves blockchain, different for main and test net
32 | */
33 | public let assetId: String
34 | /**
35 | Amount of asset to burn in satoshi
36 | */
37 | public let amount: Int64
38 | public let applicationStatus: String?
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/Transactions/LeaseCancelTransactionNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionLeaseCancelNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 07/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 |
13 | /**
14 | The Cancel leasing transaction reverse [LeaseTransaction].
15 | Lease cancel transaction is used to to cancel
16 | and discontinue the WAVES leasing process to a Waves node.
17 | */
18 | struct LeaseCancelTransaction: Codable {
19 | public let type: Int
20 | public let id: String
21 | public let sender: String
22 | public let senderPublicKey: String
23 | public let fee: Int64
24 | public let timestamp: Date
25 | public let version: Int
26 | public let height: Int64?
27 | public let signature: String?
28 | public let proofs: [String]?
29 | public let chainId: UInt8?
30 | /**
31 | Id of Leasing Transaction to cancel
32 | */
33 | public let leaseId: String
34 | public let lease: NodeService.DTO.LeaseTransaction?
35 | public let applicationStatus: String?
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/Transactions/LeaseTransactionNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionLeaseNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 18.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 | /**
13 | The Leasing transaction leases amount of Waves to node operator.
14 | it can be address or alias by Proof-of-Stake consensus. It will perform at non-node address.
15 | You always can reverse the any leased amount by [LeaseCancelTransaction]
16 | */
17 | struct LeaseTransaction: Codable {
18 | public let id: String
19 | public let originTransactionID: String?
20 | public let sender, recipient: String
21 | public let amount: Int64
22 | public let height: Int64?
23 | public let status: String?
24 | public let type: Int?
25 | public let senderPublicKey: String?
26 | public let fee: Int64?
27 | public let feeAssetID: String?
28 | public let timestamp: Date?
29 | public let proofs: [String]?
30 | public let version: Int?
31 | }
32 |
33 | struct LeaseResponse: Codable {
34 | public let id: String
35 | public let sender: String
36 | public let recipient: String
37 | public let amount: Int64
38 | public let height: Int64
39 | public var status: String?
40 |
41 | public init(
42 | id: String,
43 | sender: String,
44 | recipient: String,
45 | height: Int64,
46 | amount: Int64,
47 | status: String?) {
48 | self.id = id
49 | self.sender = sender
50 | self.height = height
51 | self.amount = amount
52 | self.recipient = recipient
53 | self.status = status
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/Transactions/ReissueTransactionNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionReissueNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 07/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 |
13 | /**
14 | The Reissue transaction is used to give the ability to reissue more tokens of an asset
15 | by specifying the amount and the asset id. Only quantity and reissuable can be new values
16 | */
17 | struct ReissueTransaction: Codable {
18 | public let type: Int
19 | public let id: String
20 | public let sender: String
21 | public let senderPublicKey: String
22 | public let fee: Int64
23 | public let timestamp: Date
24 | public let version: Int
25 | public let height: Int64?
26 | public let signature: String?
27 | public let proofs: [String]?
28 | public let chainId: UInt8?
29 |
30 | /**
31 | Id of asset that should be changed
32 | */
33 | public let assetId: String
34 | /**
35 | Quantity defines the total tokens supply that your asset will contain
36 | */
37 | public let quantity: Int64
38 | /**
39 | Reissuability allows for additional tokens creation that will be added
40 | to the total token supply of asset.
41 | A non-reissuable asset will be permanently limited to the total token supply
42 | defined during the transaction.
43 | */
44 | public let reissuable: Bool
45 | public let applicationStatus: String?
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/Transactions/SetAssetScriptTransactionNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AssetScriptTransactionNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 22/01/2019.
6 | // Copyright © 2019 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 | /**
13 | Set asset script transaction (set script to asset)
14 |
15 | You can only update script of asset, that was issued before by [IssueTransaction]
16 |
17 | An asset script is a script that is attached to an asset with a set asset script transaction.
18 | An asset with the attached script is called a smart asset.
19 | You can attach a script to an asset only during the creation of the asset.
20 | Script can be developed with [Waves Ride IDE]({https://ide.wavesplatform.com/)
21 |
22 | Smart assets are unique virtual currency tokens that may represent a tangible real-world asset,
23 | or a non-tangible ownership that can be purchased, sold, or exchanged as defined
24 | by the rules of a script on the Waves blockchain network.
25 |
26 | Only the issuer of that asset can change the asset's script.
27 | */
28 | struct SetAssetScriptTransaction: Codable {
29 | public let type: Int
30 | public let id: String
31 | public let sender: String
32 | public let senderPublicKey: String
33 | public let fee: Int64
34 | public let timestamp: Date
35 | public let height: Int64?
36 | public let signature: String?
37 | public let proofs: [String]?
38 | public let chainId: UInt8?
39 | public let version: Int
40 |
41 | /**
42 | Selected for script asset Id
43 | */
44 | public let assetId: String
45 |
46 | /**
47 | Base64 binary string with Waves Ride script
48 | You can use "base64:compiledScriptStringInBase64" and just "compiledScriptStringInBase64".
49 | Can't be empty string
50 | */
51 | public let script: String?
52 | public let applicationStatus: String?
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/Transactions/UnrecognisedTransactionNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UnrecognisedTransactionNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 31.08.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 | struct UnrecognisedTransaction: Codable {
13 | /**
14 | ID of the transaction type. Correct values in [1; 16]
15 | */
16 | public let type: Int
17 | public let id: String
18 | public let sender: String
19 | /**
20 | Account public key of the sender in Base58
21 | */
22 | public let senderPublicKey: String
23 | /**
24 | A transaction fee is a fee that an account owner pays to send a transaction.
25 | Transaction fee in WAVELET
26 | */
27 | public let fee: Int64
28 | /**
29 | Unix time of sending of transaction to blockchain, must be in current time +/- half of hour
30 | */
31 | public let timestamp: Date
32 | public let height: Int64
33 | public let applicationStatus: String?
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/Transactions/UpdateAssetInfoTransactionNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionIssueNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 07/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 | struct UpdateAssetInfoTransaction: Codable {
13 | public let type: Int
14 | public let id: String
15 | public let sender: String
16 | public let senderPublicKey: String
17 | public let fee: Int64
18 | public let feeAssetId: String?
19 | public let timestamp: Date
20 | public let version: Int
21 | public let height: Int64?
22 | public let chainId: UInt8?
23 | public let proofs: [String]?
24 | public let assetId: String
25 |
26 | /**
27 | Name of your new asset byte length must be in [4,16]
28 | */
29 | public let name: String
30 |
31 | /**
32 | Description of your new asset byte length must be in [0;1000]
33 | */
34 | public let description: String
35 |
36 | public let applicationStatus: String?
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Models/UtilsNode.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UtilsNode.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 3/12/19.
6 | // Copyright © 2019 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NodeService.DTO {
12 | enum Utils {}
13 | }
14 |
15 | public extension NodeService.DTO.Utils {
16 |
17 | struct Time: Decodable {
18 | public let system: Int64
19 | public let NTP: Int64
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/NodeTargetTypes.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NodeTargetType.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 09.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Moya
11 |
12 | public enum NodeService {}
13 |
14 | public extension NodeService {
15 | enum DTO {}
16 | enum Query {}
17 | internal enum Target {}
18 | }
19 |
20 | protocol NodeTargetType: TargetType {
21 | var nodeUrl: URL { get }
22 | }
23 |
24 | extension NodeTargetType {
25 |
26 | var baseURL: URL { return nodeUrl }
27 |
28 | var sampleData: Data {
29 | return Data()
30 | }
31 |
32 | var headers: [String: String]? {
33 | return ContentType.applicationJson.headers
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Queries/BaseTransactionQueryProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BaseTransactionQueryProtocol.swift
3 | // WavesSDKExample
4 | //
5 | // Created by rprokofev on 04.07.2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public protocol BaseTransactionQueryProtocol {
12 | /**
13 | ID of the transaction type. Correct values in [1; 16]
14 | */
15 | var type: Int { get }
16 |
17 | /**
18 | Version number of the data structure of the transaction.
19 | The value has to be equal to 1, 2 or 3
20 | */
21 | var version: Int { get }
22 |
23 | /**
24 | Determines the network where the transaction will be published to.
25 | T or 84 in bytes for test network,
26 | W or 87 in for main network
27 | */
28 | var chainId: UInt8 { get }
29 |
30 | /**
31 | A transaction fee is a fee that an account owner pays to send a transaction.
32 | Transaction fee in WAVELET
33 | [Wiki about Fee](https://docs.wavesplatform.com/en/blockchain/transaction-fee.html)
34 | */
35 | var fee: Int64 { get }
36 |
37 | /**
38 | Unix time of sending of transaction to blockchain, must be in current time +/- 1.5 hour
39 | */
40 | var timestamp: Int64 { get }
41 |
42 | /**
43 | Account public key of the sender in Base58
44 | */
45 | var senderPublicKey: String { get }
46 |
47 | /**
48 | Signatures v2 string set.
49 | A transaction signature is a digital signature
50 | with which the sender confirms the ownership of the outgoing transaction.
51 | If the array is empty, then S= 3. If the array is not empty,
52 | then S = 3 + 2 × N + (P1 + P2 + ... + Pn), where N is the number of proofs in the array,
53 | Pn is the size on N-th proof in bytes.
54 | The maximum number of proofs in the array is 8. The maximum size of each proof is 64 bytes
55 | */
56 | var proofs: [String] { get }
57 | }
58 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Services/BlocksNodeService.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BlocksNodeTarget.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 30/04/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 | import Moya
11 |
12 | final class BlocksNodeService: InternalWavesService, BlocksNodeServiceProtocol {
13 |
14 | private let blocksProvider: MoyaProvider
15 |
16 | init(blocksProvider: MoyaProvider, enviroment: WavesEnvironment) {
17 | self.blocksProvider = blocksProvider
18 | super.init(enviroment: enviroment)
19 | }
20 |
21 | public func height(address: String) -> Observable {
22 |
23 | return self
24 | .blocksProvider
25 | .rx
26 | .request(NodeService.Target.Blocks(nodeUrl: enviroment.nodeUrl,
27 | kind: .height))
28 | .filterSuccessfulStatusAndRedirectCodes()
29 | .catchError({ (error) -> Single in
30 | return Single.error(NetworkError.error(by: error))
31 | })
32 | .map(NodeService.DTO.Block.self)
33 | .asObservable()
34 | }
35 | }
36 |
37 |
38 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Services/LeasingNodeService.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LeasingNodeService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 18.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import RxSwift
11 | import Moya
12 |
13 | final class LeasingNodeService: InternalWavesService, LeasingNodeServiceProtocol {
14 |
15 | private let leasingProvider: MoyaProvider
16 |
17 | init(leasingProvider: MoyaProvider, enviroment: WavesEnvironment) {
18 | self.leasingProvider = leasingProvider
19 | super.init(enviroment: enviroment)
20 | }
21 |
22 | public func leasingActiveTransactions(by address: String) -> Observable<[NodeService.DTO.LeaseResponse]> {
23 |
24 | return self
25 | .leasingProvider
26 | .rx
27 | .request(.init(kind: .getActive(address: address),
28 | nodeUrl: enviroment.nodeUrl))
29 | .filterSuccessfulStatusAndRedirectCodes()
30 | .catchError({ (error) -> Single in
31 | return Single.error(NetworkError.error(by: error))
32 | })
33 | .map([NodeService.DTO.LeaseResponse].self, atKeyPath: nil, using: JSONDecoder.decoderBySyncingTimestamp(enviroment.timestampServerDiff), failsOnEmptyData: false)
34 | .asObservable()
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Services/Protocols/AddressesNodeServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AddressesNodeServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public extension NodeService.DTO {
12 | struct WavesBalance: Decodable {
13 | public let id: String
14 | public let balance: Int64
15 |
16 | public init(id: String, balance: Int64) {
17 | self.id = id
18 | self.balance = balance
19 | }
20 | }
21 | }
22 |
23 | public protocol AddressesNodeServiceProtocol {
24 | /**
25 | Account's Waves balance
26 | - Parameter: address Address
27 | */
28 | func addressBalance(address: String) -> Observable
29 |
30 | /**
31 | Account's script additional info
32 | - Parameter: address Address
33 | */
34 |
35 | func scriptInfo(address: String) -> Observable
36 |
37 | func getAddressData(address: String, key: String) -> Observable
38 |
39 | func addressesBalance(addresses: [String]) -> Observable<[NodeService.DTO.WavesBalance]>
40 | }
41 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Services/Protocols/AssetsNodeServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AssetsNodeServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol AssetsNodeServiceProtocol {
12 |
13 | /**
14 | Account's balances for all assets by address
15 | - Parameter: address Address
16 | */
17 |
18 | func assetsBalances(address: String) -> Observable
19 |
20 | /**
21 | Account's assetId balance by address
22 | - Parameter: address Address
23 | - Parameter: assetId AssetId
24 | */
25 | func assetBalance(address: String, assetId: String) -> Observable
26 |
27 | /**
28 | Provides detailed information about given asset
29 | - Parameter: assetId Asset Id
30 | */
31 | func assetDetails(assetId: String) -> Observable
32 | }
33 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Services/Protocols/BlocksNodeServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BlocksNodeServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol BlocksNodeServiceProtocol {
12 |
13 | /**
14 | Get current Waves block-chain height
15 | - Parameter: address Address of account
16 | */
17 | func height(address: String) -> Observable
18 | }
19 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Services/Protocols/LeasingNodeServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LeasingNodeServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol LeasingNodeServiceProtocol {
12 |
13 | /**
14 | Active leasing transactions of account
15 | - Parameter: address Address
16 | */
17 | func leasingActiveTransactions(by address: String) -> Observable<[NodeService.DTO.LeaseResponse]>
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Services/Protocols/TransactionNodeServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionNodeServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol TransactionNodeServiceProtocol {
12 |
13 | /**
14 | Broadcast transaction one of type = [0; 16]
15 | */
16 |
17 | func transactions(query: NodeService.Query.Transaction) -> Observable
18 |
19 | /**
20 | Get list of transactions where specified address has been involved
21 | - Parameter: address Address
22 | - Parameter: limit Number of transactions to be returned. Max is last 1000.
23 | */
24 |
25 | func transactions(by address: String, offset: Int, limit: Int) -> Observable
26 | }
27 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Services/Protocols/UtilsNodeServiceProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UtilsNodeServiceProtocol.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 22/05/2019.
6 | //
7 |
8 | import Foundation
9 | import RxSwift
10 |
11 | public protocol UtilsNodeServiceProtocol {
12 |
13 | /**
14 | Current Node time (UTC)
15 | */
16 | func time() -> Observable
17 |
18 | func transactionSerialize(query: NodeService.Query.Transaction)-> Observable<[Int]>
19 | }
20 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Services/UtilsNodeService.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UtilsNodeService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 3/12/19.
6 | // Copyright © 2019 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import RxSwift
11 | import Moya
12 |
13 | final class UtilsNodeService: InternalWavesService, UtilsNodeServiceProtocol {
14 |
15 | private let utilsProvider: MoyaProvider
16 |
17 | init(utilsProvider: MoyaProvider, enviroment: WavesEnvironment) {
18 | self.utilsProvider = utilsProvider
19 | super.init(enviroment: enviroment)
20 | }
21 |
22 | private struct Utils: Decodable {
23 | let bytes: [Int]
24 | }
25 |
26 | func transactionSerialize(query: NodeService.Query.Transaction)-> Observable<[Int]> {
27 |
28 | return self
29 | .utilsProvider
30 | .rx
31 | .request(.init(nodeUrl: enviroment.nodeUrl,
32 | kind: .transactionSerialize(query)))
33 | .filterSuccessfulStatusAndRedirectCodes()
34 | .catchError({ (error) -> Single in
35 | return Single.error(NetworkError.error(by: error))
36 | })
37 | .map(Utils.self, atKeyPath: nil, using: JSONDecoder.decoderBySyncingTimestamp(enviroment.timestampServerDiff), failsOnEmptyData: false)
38 | .map { $0.bytes }
39 | .asObservable()
40 | }
41 |
42 |
43 | public func time() -> Observable {
44 |
45 | return utilsProvider
46 | .rx
47 | .request(.init(nodeUrl: enviroment.nodeUrl, kind: .time))
48 | .filterSuccessfulStatusAndRedirectCodes()
49 | .catchError({ (error) -> Single in
50 | return Single.error(NetworkError.error(by: error))
51 | })
52 | .map(NodeService.DTO.Utils.Time.self)
53 | .asObservable()
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Targets/BlocksNodeTarget.swift:
--------------------------------------------------------------------------------
1 | //
2 | // BlockNodeService.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 10.09.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import WavesSDKExtensions
11 | import Moya
12 |
13 | extension NodeService.Target {
14 |
15 | struct Blocks {
16 | enum Kind {
17 | /**
18 | Response:
19 | - Node.DTO.Block
20 | */
21 | case height
22 | }
23 |
24 | var nodeUrl: URL
25 | let kind: Kind
26 | }
27 | }
28 |
29 | extension NodeService.Target.Blocks: NodeTargetType {
30 | var modelType: Encodable.Type {
31 | return String.self
32 | }
33 |
34 | fileprivate enum Constants {
35 | static let blocks = "blocks"
36 | static let height = "height"
37 | }
38 |
39 | var path: String {
40 | switch kind {
41 | case .height:
42 | return Constants.blocks + "/" + Constants.height
43 | }
44 | }
45 |
46 | var method: Moya.Method {
47 | switch kind {
48 | case .height:
49 | return .get
50 | }
51 | }
52 |
53 | var task: Task {
54 | switch kind {
55 | case .height:
56 | return .requestPlain
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Targets/LeasingNodeTarget.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LeasingNodeTarget.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 30/04/2019.
6 | //
7 |
8 | import Foundation
9 | import WavesSDKExtensions
10 | import Moya
11 |
12 | extension NodeService.Target {
13 |
14 | struct Leasing {
15 | enum Kind {
16 | /**
17 | Response:
18 | - [Node.Model.LeasingTransaction].self
19 | */
20 | case getActive(address: String)
21 | }
22 |
23 | var kind: Kind
24 | var nodeUrl: URL
25 | }
26 | }
27 |
28 | extension NodeService.Target.Leasing: NodeTargetType {
29 | var modelType: Encodable.Type {
30 | return String.self
31 | }
32 |
33 | fileprivate enum Constants {
34 | static let leasing = "leasing"
35 | static let active = "active"
36 | static let address = "address"
37 | }
38 |
39 | var path: String {
40 | switch kind {
41 | case .getActive(let address):
42 | return Constants.leasing + "/" + Constants.active + "/" + "\(address)".urlEscaped
43 | }
44 | }
45 |
46 | var method: Moya.Method {
47 | switch kind {
48 | case .getActive:
49 | return .get
50 | }
51 | }
52 |
53 | var task: Task {
54 | switch kind {
55 | case .getActive:
56 | return .requestPlain
57 | }
58 | }
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Services/Node/Targets/UtilsNodeTarget.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UtilsNodeTarget.swift
3 | // Alamofire
4 | //
5 | // Created by rprokofev on 30/04/2019.
6 | //
7 |
8 | import Foundation
9 | import WavesSDKExtensions
10 | import Moya
11 |
12 | extension NodeService.Target {
13 |
14 | struct Utils {
15 | enum Kind {
16 | case time
17 |
18 | case transactionSerialize(NodeService.Query.Transaction)
19 | }
20 |
21 | var nodeUrl: URL
22 | let kind: Kind
23 | }
24 | }
25 |
26 | extension NodeService.Target.Utils: NodeTargetType {
27 |
28 | private enum Constants {
29 | static let utils = "utils"
30 | static let time = "time"
31 | }
32 |
33 | var path: String {
34 | switch kind {
35 | case .time:
36 | return Constants.utils + "/" + Constants.time
37 |
38 | case .transactionSerialize:
39 | return "/utils/transactionSerialize"
40 | }
41 | }
42 |
43 | var method: Moya.Method {
44 | switch kind {
45 | case .time:
46 | return .get
47 | case .transactionSerialize:
48 | return .post
49 | }
50 | }
51 |
52 | var task: Task {
53 | switch kind {
54 | case .time:
55 | return .requestPlain
56 |
57 | case .transactionSerialize(let specification):
58 | return .requestParameters(parameters: specification.params, encoding: JSONEncoding.default)
59 | }
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Signature/SignatureProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Interface.swift
3 | // WavesSDKUI
4 | //
5 | // Created by rprokofev on 23/05/2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import WavesSDKCrypto
11 | import WavesSDKExtensions
12 |
13 | public protocol SignatureProtocol {
14 |
15 | var bytesStructure: WavesSDKCrypto.Bytes { get }
16 |
17 | func signature(privateKey: WavesSDKCrypto.PrivateKey) -> WavesSDKCrypto.Bytes?
18 |
19 | func signature(privateKey: WavesSDKCrypto.PrivateKey) -> String?
20 |
21 | var id: String { get }
22 | }
23 |
24 | public extension SignatureProtocol {
25 |
26 | func signature(seed: Seed) -> WavesSDKCrypto.Bytes? {
27 | return WavesCrypto.shared.signBytes(bytes: bytesStructure, seed: seed)
28 | }
29 |
30 | func signature(seed: Seed) -> String? {
31 | guard let bytes: Bytes = signature(seed: seed) else { return nil }
32 | return WavesCrypto.shared.base58encode(input: bytes)
33 | }
34 |
35 | func signature(privateKey: WavesSDKCrypto.PrivateKey) -> WavesSDKCrypto.Bytes? {
36 | return WavesCrypto.shared.signBytes(bytes: bytesStructure, privateKey: privateKey)
37 | }
38 |
39 | func signature(privateKey: WavesSDKCrypto.PrivateKey) -> String? {
40 | guard let bytes: Bytes = signature(privateKey: privateKey) else { return nil }
41 | return WavesCrypto.shared.base58encode(input: bytes)
42 | }
43 |
44 | var id: String {
45 | return WavesCrypto.shared.base58encode(input: WavesCrypto.shared.blake2b256(input: bytesStructure)) ?? ""
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Signature/TransactionSignatureProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionSignatureProtocol.swift
3 | // WavesSDKUI
4 | //
5 | // Created by rprokofev on 23/05/2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public protocol TransactionSignatureProtocol: SignatureProtocol {
12 |
13 | var version: Int { get }
14 |
15 | var type: TransactionType { get }
16 | }
17 |
18 | extension TransactionSignatureProtocol {
19 |
20 | public var typeByte: Int8 {
21 | return type.rawValue
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/Signature/TransactionType.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TransactionType.swift
3 | // WavesSDKExample
4 | //
5 | // Created by rprokofev on 01.07.2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | @frozen public enum TransactionType: Int8 {
12 | case issue = 3
13 | case transfer = 4
14 | case reissue = 5
15 | case burn = 6
16 | case exchange = 7
17 | case createLease = 8
18 | case cancelLease = 9
19 | case createAlias = 10
20 | case massTransfer = 11
21 | case data = 12
22 | case script = 13
23 | case sponsorship = 14
24 | case assetScript = 15
25 | case invokeScript = 16
26 | case updateAssetInfo = 17
27 |
28 | var int: Int {
29 | return Int(self.rawValue)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/WavesSDK/Sources/WavesSDKConstants.swift:
--------------------------------------------------------------------------------
1 | //
2 | // GlobalConstants.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 16/10/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import WavesSDKExtensions
11 |
12 | public enum WavesSDKConstants {
13 | public static let aliasNameMinLimitSymbols: Int = 4
14 | public static let aliasNameMaxLimitSymbols: Int = 30
15 | public static let wavesAssetId = "WAVES"
16 | public static let WavesTransactionFeeAmount: Int64 = 100000
17 | public static let WavesDecimals: Int = 8
18 | public static let FiatDecimals: Int = 2
19 | public static let appstoreURL: URL = URL(string: "https://apps.apple.com/ua/app/id1233158971")!
20 |
21 | public enum UrlScheme {
22 | #if DEBUG
23 | static let wallet: String = "waves-dev"
24 | #elseif TEST
25 | static let wallet: String = "waves-test"
26 | #else
27 | static let wallet: String = "waves"
28 | #endif
29 | }
30 | }
31 |
32 | public enum RegEx {
33 | static let alias = "^[a-z0-9\\.@_-]*$"
34 |
35 | public static func alias(_ alias: String) -> Bool {
36 | do {
37 | let regex = try NSRegularExpression(pattern: RegEx.alias)
38 | return regex.matches(in: alias, options: NSRegularExpression.MatchingOptions.withTransparentBounds, range: NSRange(location: 0, length: alias.count)).count > 0
39 | } catch let e {
40 | SweetLogger.error(e)
41 | return false
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/WavesSDK/WavesSDK.h:
--------------------------------------------------------------------------------
1 | //
2 | // InternalWavesSDK.h
3 | // InternalWavesSDK
4 | //
5 | // Created by rprokofev on 27.06.2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for InternalWavesSDK.
12 | FOUNDATION_EXPORT double WavesSDKVersionNumber;
13 |
14 | //! Project version string for InternalWavesSDK.
15 | FOUNDATION_EXPORT const unsigned char WavesSDKVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/WavesSDKCrypto.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |spec|
2 |
3 | spec.name = 'WavesSDKCrypto'
4 | spec.version = '0.1.9'
5 | spec.ios.deployment_target = '11.0'
6 | spec.requires_arc = true
7 | spec.swift_version = '5.0'
8 |
9 | spec.license = { :type => 'MIT License', :file => 'LICENSE' }
10 | spec.homepage = 'https://wavesplatform.com'
11 | spec.authors = { 'Mefilt' => 'mefilt@gmail.com', }
12 |
13 | spec.summary = 'WavesSDK – it is mobile libraries for easy and simple co-working Waves blockchain platform and any mobile app'
14 |
15 | spec.source = { 'git' => 'https://github.com/wavesplatform/WavesSDK-iOS.git', :tag => 'v' + spec.version.to_s }
16 |
17 |
18 |
19 | spec.source_files =
20 | 'WavesSDKCrypto/Sources/*.{swift}',
21 | 'WavesSDKCrypto/Vendors/Curve25519/Sources/Curve25519/curve25519-donna.c',
22 | 'WavesSDKCrypto/Vendors/Curve25519/Sources/Objc/*.{h,m}',
23 | 'WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/*.{c,h}',
24 | 'WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/additions/*.{c,h}',
25 | 'WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/nacl_sha512/*.{c,h}',
26 | 'WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/nacl_includes/*.{c,h}',
27 | 'WavesSDKCrypto/Vendors/Blake2/Sources/*.{h,c}',
28 | 'WavesSDKCrypto/Vendors/Base58Encoder/Sources/*.{h,c,swift}',
29 | 'WavesSDKCrypto/Vendors/Keccak/Sources/*{h,c}'
30 |
31 | spec.public_header_files =
32 | 'WavesSDKCrypto/Vendors/Curve25519/Sources/Objc/*.{h}',
33 | 'WavesSDKCrypto/Vendors/Blake2/Sources/blake2.h',
34 | 'WavesSDKCrypto/Vendors/Blake2/Sources/crypto_generichash_blake2b.h',
35 | 'WavesSDKCrypto/Vendors/Blake2/Sources/export.h',
36 | 'WavesSDKCrypto/Vendors/Base58Encoder/Sources/*.{h}',
37 | 'WavesSDKCrypto/Vendors/Keccak/Sources/*{h}'
38 |
39 | spec.ios.framework = 'Foundation'
40 | spec.ios.framework = 'UIKit'
41 | spec.ios.framework = 'Security'
42 | spec.dependency 'WavesSDKExtensions'
43 |
44 | end
45 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 0.1.7
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Base58Encoder/Sources/base58.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBBASE58_H
2 | #define LIBBASE58_H
3 |
4 | #include
5 | #include
6 |
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 |
11 | extern bool (*b58_sha256_impl)(void *, const void *, size_t);
12 |
13 | extern bool b58tobin(void *bin, size_t *binsz, const char *b58, size_t b58sz);
14 | extern int b58check(const void *bin, size_t binsz, const char *b58, size_t b58sz);
15 |
16 | extern bool b58enc(char *b58, size_t *b58sz, const void *bin, size_t binsz);
17 | extern bool b58check_enc(char *b58c, size_t *b58c_sz, unsigned char ver, const void *data, size_t datasz);
18 |
19 | #ifdef __cplusplus
20 | }
21 | #endif
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Blake2/Sources/api.h:
--------------------------------------------------------------------------------
1 |
2 | #include "crypto_generichash_blake2b.h"
3 |
4 | #define crypto_generichash_blake2b crypto_generichash_blake2b_ref
5 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Blake2/Sources/crypto_generichash.c:
--------------------------------------------------------------------------------
1 |
2 | #include "crypto_generichash.h"
3 |
4 | size_t
5 | crypto_generichash_bytes(void)
6 | {
7 | return crypto_generichash_BYTES;
8 | }
9 |
10 | size_t
11 | crypto_generichash_bytes_min(void)
12 | {
13 | return crypto_generichash_BYTES_MIN;
14 | }
15 |
16 | size_t
17 | crypto_generichash_bytes_max(void)
18 | {
19 | return crypto_generichash_BYTES_MAX;
20 | }
21 |
22 | size_t
23 | crypto_generichash_keybytes(void)
24 | {
25 | return crypto_generichash_KEYBYTES;
26 | }
27 |
28 | size_t
29 | crypto_generichash_keybytes_min(void)
30 | {
31 | return crypto_generichash_KEYBYTES_MIN;
32 | }
33 |
34 | size_t
35 | crypto_generichash_keybytes_max(void)
36 | {
37 | return crypto_generichash_KEYBYTES_MAX;
38 | }
39 |
40 | size_t
41 | crypto_generichash_blockbytes(void)
42 | {
43 | return crypto_generichash_BLOCKBYTES;
44 | }
45 |
46 | const char *crypto_generichash_primitive(void)
47 | {
48 | return crypto_generichash_PRIMITIVE;
49 | }
50 |
51 | int
52 | crypto_generichash(unsigned char *out, size_t outlen, const unsigned char *in,
53 | unsigned long long inlen, const unsigned char *key,
54 | size_t keylen)
55 | {
56 | return crypto_generichash_blake2b(out, outlen, in, inlen, key, keylen);
57 | }
58 |
59 | int
60 | crypto_generichash_init(crypto_generichash_state *state,
61 | const unsigned char *key,
62 | const size_t keylen, const size_t outlen)
63 | {
64 | return crypto_generichash_blake2b_init
65 | ((crypto_generichash_blake2b_state *) state,
66 | key, keylen, outlen);
67 | }
68 |
69 | int
70 | crypto_generichash_update(crypto_generichash_state *state,
71 | const unsigned char *in,
72 | unsigned long long inlen)
73 | {
74 | return crypto_generichash_blake2b_update
75 | ((crypto_generichash_blake2b_state *) state, in, inlen);
76 | }
77 |
78 | int
79 | crypto_generichash_final(crypto_generichash_state *state,
80 | unsigned char *out, const size_t outlen)
81 | {
82 | return crypto_generichash_blake2b_final
83 | ((crypto_generichash_blake2b_state *) state, out, outlen);
84 | }
85 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Blake2/Sources/export.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __SODIUM_EXPORT_H__
3 | #define __SODIUM_EXPORT_H__
4 |
5 | #ifndef __GNUC__
6 | # ifdef __attribute__
7 | # undef __attribute__
8 | # endif
9 | # define __attribute__(a)
10 | #endif
11 |
12 | #ifdef SODIUM_STATIC
13 | # define SODIUM_EXPORT
14 | #else
15 | # if defined(_MSC_VER)
16 | # ifdef DLL_EXPORT
17 | # define SODIUM_EXPORT __declspec(dllexport)
18 | # else
19 | # define SODIUM_EXPORT __declspec(dllimport)
20 | # endif
21 | # else
22 | # if defined(__SUNPRO_C)
23 | # define SODIUM_EXPORT __attribute__ __global
24 | # elif defined(_MSG_VER)
25 | # define SODIUM_EXPORT extern __declspec(dllexport)
26 | # else
27 | # define SODIUM_EXPORT __attribute__ ((visibility ("default")))
28 | # endif
29 | # endif
30 | #endif
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Blake2/Sources/generichash_blake2_api.c:
--------------------------------------------------------------------------------
1 | #include "crypto_generichash_blake2b.h"
2 |
3 | size_t
4 | crypto_generichash_blake2b_bytes_min(void) {
5 | return crypto_generichash_blake2b_BYTES_MIN;
6 | }
7 |
8 | size_t
9 | crypto_generichash_blake2b_bytes_max(void) {
10 | return crypto_generichash_blake2b_BYTES_MAX;
11 | }
12 |
13 | size_t
14 | crypto_generichash_blake2b_keybytes_min(void) {
15 | return crypto_generichash_blake2b_KEYBYTES_MIN;
16 | }
17 |
18 | size_t
19 | crypto_generichash_blake2b_keybytes_max(void) {
20 | return crypto_generichash_blake2b_KEYBYTES_MAX;
21 | }
22 |
23 | size_t
24 | crypto_generichash_blake2b_blockbytes(void) {
25 | return crypto_generichash_blake2b_BLOCKBYTES;
26 | }
27 |
28 | const char *
29 | crypto_generichash_blake2b_blockbytes_primitive(void) {
30 | return "blake2b";
31 | }
32 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Blake2/Sources/generichash_blake2b.c:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 | #include
5 |
6 | #include "api.h"
7 | #include "blake2.h"
8 |
9 | int
10 | crypto_generichash_blake2b(unsigned char *out, size_t outlen,
11 | const unsigned char *in, unsigned long long inlen,
12 | const unsigned char *key, size_t keylen)
13 | {
14 | if (outlen <= 0U || outlen > BLAKE2B_OUTBYTES ||
15 | keylen > BLAKE2B_KEYBYTES || inlen > UINT64_MAX) {
16 | return -1;
17 | }
18 | assert(outlen <= UINT8_MAX);
19 | assert(keylen <= UINT8_MAX);
20 |
21 | return blake2b((uint8_t *) out, in, key,
22 | (uint8_t) outlen, (uint64_t) inlen, (uint8_t) keylen);
23 | }
24 |
25 | int
26 | crypto_generichash_blake2b_init(crypto_generichash_blake2b_state *state,
27 | const unsigned char *key,
28 | const size_t keylen, const size_t outlen)
29 | {
30 | if (outlen <= 0U || outlen > BLAKE2B_OUTBYTES ||
31 | keylen > BLAKE2B_KEYBYTES) {
32 | return -1;
33 | }
34 | assert(outlen <= UINT8_MAX);
35 | assert(keylen <= UINT8_MAX);
36 | if (blake2b_init(state, (uint8_t) outlen) != 0) {
37 | return -1;
38 | }
39 | if (key != NULL && keylen > 0U &&
40 | blake2b_init_key(state, (uint8_t) outlen, key, keylen) != 0) {
41 | return -1;
42 | }
43 | return 0;
44 | }
45 |
46 | int
47 | crypto_generichash_blake2b_update(crypto_generichash_blake2b_state *state,
48 | const unsigned char *in,
49 | unsigned long long inlen)
50 | {
51 | return blake2b_update(state, (const uint8_t *) in, (uint64_t) inlen);
52 | }
53 |
54 | int
55 | crypto_generichash_blake2b_final(crypto_generichash_blake2b_state *state,
56 | unsigned char *out,
57 | const size_t outlen)
58 | {
59 | assert(outlen <= UINT8_MAX);
60 | return blake2b_final(state, (uint8_t *) out, (uint8_t) outlen);
61 | }
62 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Blake2/Sources/randombytes.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef randombytes_H
3 | #define randombytes_H
4 |
5 | #include
6 |
7 | #include
8 | #include
9 |
10 | #include "export.h"
11 |
12 | #ifdef __cplusplus
13 | extern "C" {
14 | #endif
15 |
16 | typedef struct randombytes_implementation {
17 | const char *(*implementation_name)(void);
18 | uint32_t (*random)(void);
19 | void (*stir)(void);
20 | uint32_t (*uniform)(const uint32_t upper_bound);
21 | void (*buf)(void * const buf, const size_t size);
22 | int (*close)(void);
23 | } randombytes_implementation;
24 |
25 | SODIUM_EXPORT
26 | int randombytes_set_implementation(randombytes_implementation *impl);
27 |
28 | SODIUM_EXPORT
29 | void randombytes(unsigned char * const buf, const unsigned long long buf_len);
30 |
31 | SODIUM_EXPORT
32 | const char *randombytes_implementation_name(void);
33 |
34 | SODIUM_EXPORT
35 | uint32_t randombytes_random(void);
36 |
37 | SODIUM_EXPORT
38 | void randombytes_stir(void);
39 |
40 | SODIUM_EXPORT
41 | uint32_t randombytes_uniform(const uint32_t upper_bound);
42 |
43 | SODIUM_EXPORT
44 | void randombytes_buf(void * const buf, const size_t size);
45 |
46 | SODIUM_EXPORT
47 | int randombytes_close(void);
48 |
49 | #ifdef __cplusplus
50 | }
51 | #endif
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Blake2/Sources/utils.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __SODIUM_UTILS_H__
3 | #define __SODIUM_UTILS_H__
4 |
5 | #include
6 |
7 | #include "export.h"
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | #if defined(__cplusplus) || !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
14 | # define _SODIUM_C99(X)
15 | #else
16 | # define _SODIUM_C99(X) X
17 | #endif
18 |
19 | unsigned char *_sodium_alignedcalloc(unsigned char ** const unaligned_p,
20 | const size_t len);
21 |
22 | SODIUM_EXPORT
23 | void sodium_memzero(void * const pnt, const size_t len);
24 |
25 | SODIUM_EXPORT
26 | int sodium_memcmp(const void * const b1_, const void * const b2_, size_t size);
27 |
28 | SODIUM_EXPORT
29 | char *sodium_bin2hex(char * const hex, const size_t hexlen,
30 | const unsigned char *bin, const size_t binlen);
31 |
32 | #ifdef __cplusplus
33 | }
34 | #endif
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/Objc/Curve25519.h:
--------------------------------------------------------------------------------
1 | //
2 | // Curve25519.h
3 | //
4 | // Created by Frederic Jacobs on 22/07/14.
5 | // Copyright (c) 2014 Open Whisper Systems. All rights reserved.
6 | //
7 |
8 | #import
9 |
10 | #define ECCKeyLength 32
11 | #define ECCSignatureLength 64
12 |
13 | @interface ECKeyPair : NSObject {
14 | uint8_t publicKey [ECCKeyLength];
15 | uint8_t privateKey[ECCKeyLength];
16 | }
17 |
18 | -(NSData*) publicKey;
19 | -(NSData*) privateKey;
20 |
21 | @end
22 |
23 | @interface Curve25519 : NSObject
24 |
25 | /**
26 | * Generate a 32-byte shared secret from a public key and a key pair using curve25519.
27 | *
28 | * @param theirPublicKey public curve25519 key
29 | * @param keyPair curve25519 key pair
30 | *
31 | * @return 32-byte shared secret derived from ECDH with curve25519 public key and key pair.
32 | */
33 |
34 | + (NSData*)generateSharedSecretFromPublicKey:(NSData*)theirPublicKey andKeyPair:(ECKeyPair*)keyPair;
35 |
36 | /**
37 | * Generate a curve25519 key pair
38 | *
39 | * @return curve25519 key pair.
40 | */
41 |
42 | + (ECKeyPair*)generateKeyPair:(NSData*)seed;
43 |
44 | + (NSData*)sign:(NSData*)data withPrivateKey:(NSData*)key;
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/Objc/Ed25519.h:
--------------------------------------------------------------------------------
1 | //
2 | // Ed25519.h
3 | //
4 | // Created by Frederic Jacobs on 22/07/14.
5 | // Copyright (c) 2014 Open Whisper Systems. All rights reserved.
6 | //
7 |
8 | #import
9 |
10 | @class ECKeyPair;
11 |
12 | @interface Ed25519 : NSObject
13 |
14 | /**
15 | * ed25519 signature of a message with a curve25519 key pair.
16 | *
17 | * @param data data to be signed
18 | * @param keyPair curve25519 32-byte key pair.
19 | *
20 | * @return The ed25519 64-bytes signature.
21 | */
22 |
23 | +(NSData*)sign:(NSData*)data withKeyPair:(ECKeyPair*)keyPair;
24 |
25 | /**
26 | * Verify ed25519 signature with 32-bytes Curve25519 key pair. Throws an NSInvalid
27 | *
28 | * @param signature ed25519 64-byte signature.
29 | * @param pubKey public key of the signer.
30 | * @param data data to be checked against the signature.
31 | *
32 | * @return Returns TRUE if the signature is valid, false if it's not.
33 | */
34 |
35 | +(BOOL)verifySignature:(NSData*)signature publicKey:(NSData*)pubKey data:(NSData*)data;
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/Objc/Ed25519.m:
--------------------------------------------------------------------------------
1 | //
2 | // Ed25519.m
3 | // BuildTests
4 | //
5 | // Created by Frederic Jacobs on 22/07/14.
6 | // Copyright (c) 2014 Open Whisper Systems. All rights reserved.
7 | //
8 |
9 | #import "Ed25519.h"
10 | #import "Curve25519.h"
11 |
12 | @interface ECKeyPair ()
13 | -(NSData*) sign:(NSData*)data;
14 | @end
15 |
16 | extern int curve25519_verify(const unsigned char* signature, /* 64 bytes */
17 | const unsigned char* curve25519_pubkey, /* 32 bytes */
18 | const unsigned char* msg, const unsigned long msg_len);
19 |
20 | @implementation Ed25519
21 |
22 | +(NSData*)sign:(NSData*)data withKeyPair:(ECKeyPair*)keyPair{
23 |
24 | if ([data length] < 1) {
25 | @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Data needs to be at least one byte" userInfo:nil];
26 | }
27 |
28 | return [keyPair sign:data];
29 | }
30 |
31 | +(BOOL)verifySignature:(NSData*)signature publicKey:(NSData*)pubKey data:(NSData*)data{
32 |
33 | if ([data length] < 1) {
34 | @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Data needs to be at least one byte" userInfo:nil];
35 | }
36 |
37 | if ([pubKey length] != ECCKeyLength) {
38 | @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Public Key isn't 32 bytes" userInfo:nil];
39 | }
40 |
41 | if ([signature length] != ECCSignatureLength) {
42 | @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Signature isn't 64 bytes" userInfo:nil];
43 | }
44 |
45 | BOOL success = (curve25519_verify([signature bytes], [pubKey bytes], [data bytes], [data length]) == 0);
46 |
47 | return success;
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/Objc/Randomness.h:
--------------------------------------------------------------------------------
1 | //
2 | // Randomness.h
3 | // AxolotlKit
4 | //
5 | // Created by Frederic Jacobs on 21/07/14.
6 | // Copyright (c) 2014 Frederic Jacobs. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Randomness : NSObject
12 |
13 | /**
14 | * Generates a given number of cryptographically secure bytes using SecRandomCopyBytes.
15 | *
16 | * @param numberBytes The number of bytes to be generated.
17 | *
18 | * @return Random Bytes.
19 | */
20 |
21 | +(NSData*) generateRandomBytes:(int)numberBytes;
22 |
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/Objc/Randomness.m:
--------------------------------------------------------------------------------
1 | //
2 | // Randomness.m
3 | // AxolotlKit
4 | //
5 | // Created by Frederic Jacobs on 21/07/14.
6 | // Copyright (c) 2014 Frederic Jacobs. All rights reserved.
7 | //
8 |
9 | #import "Randomness.h"
10 |
11 | @implementation Randomness
12 |
13 | +(NSData*) generateRandomBytes:(int)numberBytes {
14 | /* used to generate db master key, and to generate signaling key, both at install */
15 | NSMutableData* randomBytes = [NSMutableData dataWithLength:numberBytes];
16 | int err = 0;
17 | err = SecRandomCopyBytes(kSecRandomDefault,numberBytes,[randomBytes mutableBytes]);
18 | if(err != noErr && [randomBytes length] != numberBytes) {
19 | @throw [NSException exceptionWithName:@"random problem" reason:@"problem generating the random " userInfo:nil];
20 | }
21 | return [NSData dataWithData:randomBytes];
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/additions/compare.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "compare.h"
3 |
4 | /* Const-time comparison from SUPERCOP, but here it's only used for
5 | signature verification, so doesn't need to be const-time. But
6 | copied the nacl version anyways. */
7 | int crypto_verify_32_ref(const unsigned char *x, const unsigned char *y)
8 | {
9 | unsigned int differentbits = 0;
10 | #define F(i) differentbits |= x[i] ^ y[i];
11 | F(0)
12 | F(1)
13 | F(2)
14 | F(3)
15 | F(4)
16 | F(5)
17 | F(6)
18 | F(7)
19 | F(8)
20 | F(9)
21 | F(10)
22 | F(11)
23 | F(12)
24 | F(13)
25 | F(14)
26 | F(15)
27 | F(16)
28 | F(17)
29 | F(18)
30 | F(19)
31 | F(20)
32 | F(21)
33 | F(22)
34 | F(23)
35 | F(24)
36 | F(25)
37 | F(26)
38 | F(27)
39 | F(28)
40 | F(29)
41 | F(30)
42 | F(31)
43 | return (1 & ((differentbits - 1) >> 8)) - 1;
44 | }
45 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/additions/compare.h:
--------------------------------------------------------------------------------
1 | #ifndef __COMPARE_H__
2 | #define __COMPARE_H__
3 |
4 | int crypto_verify_32_ref(const unsigned char *b1, const unsigned char *b2);
5 |
6 | #endif
7 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/additions/crypto_hash_sha512.h:
--------------------------------------------------------------------------------
1 | #ifndef crypto_hash_sha512_H
2 | #define crypto_hash_sha512_H
3 |
4 | extern int crypto_hash_sha512(unsigned char *,const unsigned char *,unsigned long long);
5 |
6 | #endif
7 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/additions/curve_sigs.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __CURVE_SIGS_H__
3 | #define __CURVE_SIGS_H__
4 |
5 | void curve25519_keygen(unsigned char* curve25519_pubkey_out, /* 32 bytes */
6 | const unsigned char* curve25519_privkey_in); /* 32 bytes */
7 |
8 | /* returns 0 on success */
9 | int curve25519_sign(unsigned char* signature_out, /* 64 bytes */
10 | const unsigned char* curve25519_privkey, /* 32 bytes */
11 | const unsigned char* msg, const unsigned long msg_len,
12 | const unsigned char* random); /* 64 bytes */
13 |
14 | /* returns 0 on success */
15 | int curve25519_verify(const unsigned char* signature, /* 64 bytes */
16 | const unsigned char* curve25519_pubkey, /* 32 bytes */
17 | const unsigned char* msg, const unsigned long msg_len);
18 |
19 | /* helper function - modified version of crypto_sign() to use
20 | explicit private key. In particular:
21 |
22 | sk : private key
23 | pk : public key
24 | msg : message
25 | prefix : 0xFE || [0xFF]*31
26 | random : 64 bytes random
27 | q : main subgroup order
28 |
29 | The prefix is chosen to distinguish the two SHA512 uses below, since
30 | prefix is an invalid encoding for R (it would encode a "field element"
31 | of 2^255 - 2). 0xFF*32 is set aside for use in ECDH protocols, which
32 | is why the first byte here ix 0xFE.
33 |
34 | sig_nonce = SHA512(prefix || sk || msg || random) % q
35 | R = g^sig_nonce
36 | M = SHA512(R || pk || m)
37 | S = sig_nonce + (m * sk)
38 | signature = (R || S)
39 | */
40 | int crypto_sign_modified(
41 | unsigned char *sm,
42 | const unsigned char *m,unsigned long long mlen,
43 | const unsigned char *sk, /* Curve/Ed25519 private key */
44 | const unsigned char *pk, /* Ed25519 public key */
45 | const unsigned char *random /* 64 bytes random to hash into nonce */
46 | );
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/additions/sign_modified.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "crypto_sign.h"
3 | #include "crypto_hash_sha512.h"
4 | #include "ge.h"
5 | #include "sc.h"
6 | #include "zeroize.h"
7 |
8 | /* NEW: Compare to pristine crypto_sign()
9 | Uses explicit private key for nonce derivation and as scalar,
10 | instead of deriving both from a master key.
11 | */
12 | int crypto_sign_modified(
13 | unsigned char *sm,
14 | const unsigned char *m,unsigned long long mlen,
15 | const unsigned char *sk, const unsigned char* pk,
16 | const unsigned char* random
17 | )
18 | {
19 | unsigned char nonce[64];
20 | unsigned char hram[64];
21 | ge_p3 R;
22 | int count=0;
23 |
24 | memmove(sm + 64,m,mlen);
25 | memmove(sm + 32,sk,32); /* NEW: Use privkey directly for nonce derivation */
26 |
27 | /* NEW : add prefix to separate hash uses - see .h */
28 | sm[0] = 0xFE;
29 | for (count = 1; count < 32; count++)
30 | sm[count] = 0xFF;
31 |
32 | /* NEW: add suffix of random data */
33 | memmove(sm + mlen + 64, random, 64);
34 |
35 | crypto_hash_sha512(nonce,sm,mlen + 128);
36 | memmove(sm + 32,pk,32);
37 |
38 | sc_reduce(nonce);
39 | ge_scalarmult_base(&R,nonce);
40 | ge_p3_tobytes(sm,&R);
41 |
42 | crypto_hash_sha512(hram,sm,mlen + 64);
43 | sc_reduce(hram);
44 | sc_muladd(sm + 32,hram,sk,nonce); /* NEW: Use privkey directly */
45 |
46 | return 0;
47 | }
48 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/additions/zeroize.c:
--------------------------------------------------------------------------------
1 | #include "zeroize.h"
2 |
3 | void zeroize(unsigned char* b, size_t len)
4 | {
5 | size_t count = 0;
6 | unsigned long retval = 0;
7 | volatile unsigned char *p = b;
8 |
9 | for (count = 0; count < len; count++)
10 | p[count] = 0;
11 | }
12 |
13 | void zeroize_stack()
14 | {
15 | unsigned char m[ZEROIZE_STACK_SIZE];
16 | zeroize(m, sizeof m);
17 | }
18 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/additions/zeroize.h:
--------------------------------------------------------------------------------
1 | #ifndef __ZEROIZE_H__
2 | #define __ZEROIZE_H__
3 |
4 | #include
5 |
6 | #define ZEROIZE_STACK_SIZE 2048
7 |
8 | void zeroize(unsigned char* b, size_t len);
9 |
10 | void zeroize_stack();
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/api.h:
--------------------------------------------------------------------------------
1 | #define CRYPTO_SECRETKEYBYTES 64
2 | #define CRYPTO_PUBLICKEYBYTES 32
3 | #define CRYPTO_BYTES 64
4 | #define CRYPTO_DETERMINISTIC 1
5 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/d.h:
--------------------------------------------------------------------------------
1 | -10913610,13857413,-15372611,6949391,114729,-8787816,-6275908,-3247719,-18696448,-12055116
2 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/d2.h:
--------------------------------------------------------------------------------
1 | -21827239,-5839606,-30745221,13898782,229458,15978800,-12551817,-6495438,29715968,9444199
2 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe.h:
--------------------------------------------------------------------------------
1 | #ifndef FE_H
2 | #define FE_H
3 |
4 | #include "crypto_int32.h"
5 |
6 | typedef crypto_int32 fe[10];
7 |
8 | /*
9 | fe means field element.
10 | Here the field is \Z/(2^255-19).
11 | An element t, entries t[0]...t[9], represents the integer
12 | t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9].
13 | Bounds on each t[i] vary depending on context.
14 | */
15 |
16 | #define fe_frombytes crypto_sign_ed25519_ref10_fe_frombytes
17 | #define fe_tobytes crypto_sign_ed25519_ref10_fe_tobytes
18 | #define fe_copy crypto_sign_ed25519_ref10_fe_copy
19 | #define fe_isnonzero crypto_sign_ed25519_ref10_fe_isnonzero
20 | #define fe_isnegative crypto_sign_ed25519_ref10_fe_isnegative
21 | #define fe_0 crypto_sign_ed25519_ref10_fe_0
22 | #define fe_1 crypto_sign_ed25519_ref10_fe_1
23 | #define fe_cswap crypto_sign_ed25519_ref10_fe_cswap
24 | #define fe_cmov crypto_sign_ed25519_ref10_fe_cmov
25 | #define fe_add crypto_sign_ed25519_ref10_fe_add
26 | #define fe_sub crypto_sign_ed25519_ref10_fe_sub
27 | #define fe_neg crypto_sign_ed25519_ref10_fe_neg
28 | #define fe_mul crypto_sign_ed25519_ref10_fe_mul
29 | #define fe_sq crypto_sign_ed25519_ref10_fe_sq
30 | #define fe_sq2 crypto_sign_ed25519_ref10_fe_sq2
31 | #define fe_mul121666 crypto_sign_ed25519_ref10_fe_mul121666
32 | #define fe_invert crypto_sign_ed25519_ref10_fe_invert
33 | #define fe_pow22523 crypto_sign_ed25519_ref10_fe_pow22523
34 |
35 | extern void fe_frombytes(fe,const unsigned char *);
36 | extern void fe_tobytes(unsigned char *,const fe);
37 |
38 | extern void fe_copy(fe,const fe);
39 | extern int fe_isnonzero(const fe);
40 | extern int fe_isnegative(const fe);
41 | extern void fe_0(fe);
42 | extern void fe_1(fe);
43 | extern void fe_cswap(fe,fe,unsigned int);
44 | extern void fe_cmov(fe,const fe,unsigned int);
45 |
46 | extern void fe_add(fe,const fe,const fe);
47 | extern void fe_sub(fe,const fe,const fe);
48 | extern void fe_neg(fe,const fe);
49 | extern void fe_mul(fe,const fe,const fe);
50 | extern void fe_sq(fe,const fe);
51 | extern void fe_sq2(fe,const fe);
52 | extern void fe_mul121666(fe,const fe);
53 | extern void fe_invert(fe,const fe);
54 | extern void fe_pow22523(fe,const fe);
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_0.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 |
3 | /*
4 | h = 0
5 | */
6 |
7 | void fe_0(fe h)
8 | {
9 | h[0] = 0;
10 | h[1] = 0;
11 | h[2] = 0;
12 | h[3] = 0;
13 | h[4] = 0;
14 | h[5] = 0;
15 | h[6] = 0;
16 | h[7] = 0;
17 | h[8] = 0;
18 | h[9] = 0;
19 | }
20 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_1.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 |
3 | /*
4 | h = 1
5 | */
6 |
7 | void fe_1(fe h)
8 | {
9 | h[0] = 1;
10 | h[1] = 0;
11 | h[2] = 0;
12 | h[3] = 0;
13 | h[4] = 0;
14 | h[5] = 0;
15 | h[6] = 0;
16 | h[7] = 0;
17 | h[8] = 0;
18 | h[9] = 0;
19 | }
20 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_add.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 |
3 | /*
4 | h = f + g
5 | Can overlap h with f or g.
6 |
7 | Preconditions:
8 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
9 | |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
10 |
11 | Postconditions:
12 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
13 | */
14 |
15 | void fe_add(fe h,const fe f,const fe g)
16 | {
17 | crypto_int32 f0 = f[0];
18 | crypto_int32 f1 = f[1];
19 | crypto_int32 f2 = f[2];
20 | crypto_int32 f3 = f[3];
21 | crypto_int32 f4 = f[4];
22 | crypto_int32 f5 = f[5];
23 | crypto_int32 f6 = f[6];
24 | crypto_int32 f7 = f[7];
25 | crypto_int32 f8 = f[8];
26 | crypto_int32 f9 = f[9];
27 | crypto_int32 g0 = g[0];
28 | crypto_int32 g1 = g[1];
29 | crypto_int32 g2 = g[2];
30 | crypto_int32 g3 = g[3];
31 | crypto_int32 g4 = g[4];
32 | crypto_int32 g5 = g[5];
33 | crypto_int32 g6 = g[6];
34 | crypto_int32 g7 = g[7];
35 | crypto_int32 g8 = g[8];
36 | crypto_int32 g9 = g[9];
37 | crypto_int32 h0 = f0 + g0;
38 | crypto_int32 h1 = f1 + g1;
39 | crypto_int32 h2 = f2 + g2;
40 | crypto_int32 h3 = f3 + g3;
41 | crypto_int32 h4 = f4 + g4;
42 | crypto_int32 h5 = f5 + g5;
43 | crypto_int32 h6 = f6 + g6;
44 | crypto_int32 h7 = f7 + g7;
45 | crypto_int32 h8 = f8 + g8;
46 | crypto_int32 h9 = f9 + g9;
47 | h[0] = h0;
48 | h[1] = h1;
49 | h[2] = h2;
50 | h[3] = h3;
51 | h[4] = h4;
52 | h[5] = h5;
53 | h[6] = h6;
54 | h[7] = h7;
55 | h[8] = h8;
56 | h[9] = h9;
57 | }
58 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_cmov.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 |
3 | /*
4 | Replace (f,g) with (g,g) if b == 1;
5 | replace (f,g) with (f,g) if b == 0.
6 |
7 | Preconditions: b in {0,1}.
8 | */
9 |
10 | void fe_cmov(fe f,const fe g,unsigned int b)
11 | {
12 | crypto_int32 f0 = f[0];
13 | crypto_int32 f1 = f[1];
14 | crypto_int32 f2 = f[2];
15 | crypto_int32 f3 = f[3];
16 | crypto_int32 f4 = f[4];
17 | crypto_int32 f5 = f[5];
18 | crypto_int32 f6 = f[6];
19 | crypto_int32 f7 = f[7];
20 | crypto_int32 f8 = f[8];
21 | crypto_int32 f9 = f[9];
22 | crypto_int32 g0 = g[0];
23 | crypto_int32 g1 = g[1];
24 | crypto_int32 g2 = g[2];
25 | crypto_int32 g3 = g[3];
26 | crypto_int32 g4 = g[4];
27 | crypto_int32 g5 = g[5];
28 | crypto_int32 g6 = g[6];
29 | crypto_int32 g7 = g[7];
30 | crypto_int32 g8 = g[8];
31 | crypto_int32 g9 = g[9];
32 | crypto_int32 x0 = f0 ^ g0;
33 | crypto_int32 x1 = f1 ^ g1;
34 | crypto_int32 x2 = f2 ^ g2;
35 | crypto_int32 x3 = f3 ^ g3;
36 | crypto_int32 x4 = f4 ^ g4;
37 | crypto_int32 x5 = f5 ^ g5;
38 | crypto_int32 x6 = f6 ^ g6;
39 | crypto_int32 x7 = f7 ^ g7;
40 | crypto_int32 x8 = f8 ^ g8;
41 | crypto_int32 x9 = f9 ^ g9;
42 | b = -b;
43 | x0 &= b;
44 | x1 &= b;
45 | x2 &= b;
46 | x3 &= b;
47 | x4 &= b;
48 | x5 &= b;
49 | x6 &= b;
50 | x7 &= b;
51 | x8 &= b;
52 | x9 &= b;
53 | f[0] = f0 ^ x0;
54 | f[1] = f1 ^ x1;
55 | f[2] = f2 ^ x2;
56 | f[3] = f3 ^ x3;
57 | f[4] = f4 ^ x4;
58 | f[5] = f5 ^ x5;
59 | f[6] = f6 ^ x6;
60 | f[7] = f7 ^ x7;
61 | f[8] = f8 ^ x8;
62 | f[9] = f9 ^ x9;
63 | }
64 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_copy.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 |
3 | /*
4 | h = f
5 | */
6 |
7 | void fe_copy(fe h,const fe f)
8 | {
9 | crypto_int32 f0 = f[0];
10 | crypto_int32 f1 = f[1];
11 | crypto_int32 f2 = f[2];
12 | crypto_int32 f3 = f[3];
13 | crypto_int32 f4 = f[4];
14 | crypto_int32 f5 = f[5];
15 | crypto_int32 f6 = f[6];
16 | crypto_int32 f7 = f[7];
17 | crypto_int32 f8 = f[8];
18 | crypto_int32 f9 = f[9];
19 | h[0] = f0;
20 | h[1] = f1;
21 | h[2] = f2;
22 | h[3] = f3;
23 | h[4] = f4;
24 | h[5] = f5;
25 | h[6] = f6;
26 | h[7] = f7;
27 | h[8] = f8;
28 | h[9] = f9;
29 | }
30 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_invert.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 |
3 | void fe_invert(fe out,const fe z)
4 | {
5 | fe t0;
6 | fe t1;
7 | fe t2;
8 | fe t3;
9 | int i;
10 |
11 | #include "pow225521.h"
12 |
13 | return;
14 | }
15 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_isnegative.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 |
3 | /*
4 | return 1 if f is in {1,3,5,...,q-2}
5 | return 0 if f is in {0,2,4,...,q-1}
6 |
7 | Preconditions:
8 | |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
9 | */
10 |
11 | int fe_isnegative(const fe f)
12 | {
13 | unsigned char s[32];
14 | fe_tobytes(s,f);
15 | return s[0] & 1;
16 | }
17 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_isnonzero.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 | #include "crypto_verify_32.h"
3 |
4 | /*
5 | return 1 if f == 0
6 | return 0 if f != 0
7 |
8 | Preconditions:
9 | |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
10 | */
11 |
12 | static const unsigned char zero[32];
13 |
14 | int fe_isnonzero(const fe f)
15 | {
16 | unsigned char s[32];
17 | fe_tobytes(s,f);
18 | return crypto_verify_32(s,zero);
19 | }
20 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_neg.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 |
3 | /*
4 | h = -f
5 |
6 | Preconditions:
7 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
8 |
9 | Postconditions:
10 | |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
11 | */
12 |
13 | void fe_neg(fe h,const fe f)
14 | {
15 | crypto_int32 f0 = f[0];
16 | crypto_int32 f1 = f[1];
17 | crypto_int32 f2 = f[2];
18 | crypto_int32 f3 = f[3];
19 | crypto_int32 f4 = f[4];
20 | crypto_int32 f5 = f[5];
21 | crypto_int32 f6 = f[6];
22 | crypto_int32 f7 = f[7];
23 | crypto_int32 f8 = f[8];
24 | crypto_int32 f9 = f[9];
25 | crypto_int32 h0 = -f0;
26 | crypto_int32 h1 = -f1;
27 | crypto_int32 h2 = -f2;
28 | crypto_int32 h3 = -f3;
29 | crypto_int32 h4 = -f4;
30 | crypto_int32 h5 = -f5;
31 | crypto_int32 h6 = -f6;
32 | crypto_int32 h7 = -f7;
33 | crypto_int32 h8 = -f8;
34 | crypto_int32 h9 = -f9;
35 | h[0] = h0;
36 | h[1] = h1;
37 | h[2] = h2;
38 | h[3] = h3;
39 | h[4] = h4;
40 | h[5] = h5;
41 | h[6] = h6;
42 | h[7] = h7;
43 | h[8] = h8;
44 | h[9] = h9;
45 | }
46 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_pow22523.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 |
3 | void fe_pow22523(fe out,const fe z)
4 | {
5 | fe t0;
6 | fe t1;
7 | fe t2;
8 | int i;
9 |
10 | #include "pow22523.h"
11 |
12 | return;
13 | }
14 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/fe_sub.c:
--------------------------------------------------------------------------------
1 | #include "fe.h"
2 |
3 | /*
4 | h = f - g
5 | Can overlap h with f or g.
6 |
7 | Preconditions:
8 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
9 | |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
10 |
11 | Postconditions:
12 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
13 | */
14 |
15 | void fe_sub(fe h,const fe f,const fe g)
16 | {
17 | crypto_int32 f0 = f[0];
18 | crypto_int32 f1 = f[1];
19 | crypto_int32 f2 = f[2];
20 | crypto_int32 f3 = f[3];
21 | crypto_int32 f4 = f[4];
22 | crypto_int32 f5 = f[5];
23 | crypto_int32 f6 = f[6];
24 | crypto_int32 f7 = f[7];
25 | crypto_int32 f8 = f[8];
26 | crypto_int32 f9 = f[9];
27 | crypto_int32 g0 = g[0];
28 | crypto_int32 g1 = g[1];
29 | crypto_int32 g2 = g[2];
30 | crypto_int32 g3 = g[3];
31 | crypto_int32 g4 = g[4];
32 | crypto_int32 g5 = g[5];
33 | crypto_int32 g6 = g[6];
34 | crypto_int32 g7 = g[7];
35 | crypto_int32 g8 = g[8];
36 | crypto_int32 g9 = g[9];
37 | crypto_int32 h0 = f0 - g0;
38 | crypto_int32 h1 = f1 - g1;
39 | crypto_int32 h2 = f2 - g2;
40 | crypto_int32 h3 = f3 - g3;
41 | crypto_int32 h4 = f4 - g4;
42 | crypto_int32 h5 = f5 - g5;
43 | crypto_int32 h6 = f6 - g6;
44 | crypto_int32 h7 = f7 - g7;
45 | crypto_int32 h8 = f8 - g8;
46 | crypto_int32 h9 = f9 - g9;
47 | h[0] = h0;
48 | h[1] = h1;
49 | h[2] = h2;
50 | h[3] = h3;
51 | h[4] = h4;
52 | h[5] = h5;
53 | h[6] = h6;
54 | h[7] = h7;
55 | h[8] = h8;
56 | h[9] = h9;
57 | }
58 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_add.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | /*
4 | r = p + q
5 | */
6 |
7 | void ge_add(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q)
8 | {
9 | fe t0;
10 | #include "ge_add.h"
11 | }
12 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_frombytes.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | static const fe d = {
4 | #include "d.h"
5 | } ;
6 |
7 | static const fe sqrtm1 = {
8 | #include "sqrtm1.h"
9 | } ;
10 |
11 | int ge_frombytes_negate_vartime(ge_p3 *h,const unsigned char *s)
12 | {
13 | fe u;
14 | fe v;
15 | fe v3;
16 | fe vxx;
17 | fe check;
18 |
19 | fe_frombytes(h->Y,s);
20 | fe_1(h->Z);
21 | fe_sq(u,h->Y);
22 | fe_mul(v,u,d);
23 | fe_sub(u,u,h->Z); /* u = y^2-1 */
24 | fe_add(v,v,h->Z); /* v = dy^2+1 */
25 |
26 | fe_sq(v3,v);
27 | fe_mul(v3,v3,v); /* v3 = v^3 */
28 | fe_sq(h->X,v3);
29 | fe_mul(h->X,h->X,v);
30 | fe_mul(h->X,h->X,u); /* x = uv^7 */
31 |
32 | fe_pow22523(h->X,h->X); /* x = (uv^7)^((q-5)/8) */
33 | fe_mul(h->X,h->X,v3);
34 | fe_mul(h->X,h->X,u); /* x = uv^3(uv^7)^((q-5)/8) */
35 |
36 | fe_sq(vxx,h->X);
37 | fe_mul(vxx,vxx,v);
38 | fe_sub(check,vxx,u); /* vx^2-u */
39 | if (fe_isnonzero(check)) {
40 | fe_add(check,vxx,u); /* vx^2+u */
41 | if (fe_isnonzero(check)) return -1;
42 | fe_mul(h->X,h->X,sqrtm1);
43 | }
44 |
45 | if (fe_isnegative(h->X) == (s[31] >> 7))
46 | fe_neg(h->X,h->X);
47 |
48 | fe_mul(h->T,h->X,h->Y);
49 | return 0;
50 | }
51 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_madd.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | /*
4 | r = p + q
5 | */
6 |
7 | void ge_madd(ge_p1p1 *r,const ge_p3 *p,const ge_precomp *q)
8 | {
9 | fe t0;
10 | #include "ge_madd.h"
11 | }
12 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_msub.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | /*
4 | r = p - q
5 | */
6 |
7 | void ge_msub(ge_p1p1 *r,const ge_p3 *p,const ge_precomp *q)
8 | {
9 | fe t0;
10 | #include "ge_msub.h"
11 | }
12 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_p1p1_to_p2.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | /*
4 | r = p
5 | */
6 |
7 | extern void ge_p1p1_to_p2(ge_p2 *r,const ge_p1p1 *p)
8 | {
9 | fe_mul(r->X,p->X,p->T);
10 | fe_mul(r->Y,p->Y,p->Z);
11 | fe_mul(r->Z,p->Z,p->T);
12 | }
13 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_p1p1_to_p3.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | /*
4 | r = p
5 | */
6 |
7 | extern void ge_p1p1_to_p3(ge_p3 *r,const ge_p1p1 *p)
8 | {
9 | fe_mul(r->X,p->X,p->T);
10 | fe_mul(r->Y,p->Y,p->Z);
11 | fe_mul(r->Z,p->Z,p->T);
12 | fe_mul(r->T,p->X,p->Y);
13 | }
14 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_p2_0.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | void ge_p2_0(ge_p2 *h)
4 | {
5 | fe_0(h->X);
6 | fe_1(h->Y);
7 | fe_1(h->Z);
8 | }
9 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_p2_dbl.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | /*
4 | r = 2 * p
5 | */
6 |
7 | void ge_p2_dbl(ge_p1p1 *r,const ge_p2 *p)
8 | {
9 | fe t0;
10 | #include "ge_p2_dbl.h"
11 | }
12 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_p2_dbl.h:
--------------------------------------------------------------------------------
1 |
2 | /* qhasm: enter ge_p2_dbl */
3 |
4 | /* qhasm: fe X1 */
5 |
6 | /* qhasm: fe Y1 */
7 |
8 | /* qhasm: fe Z1 */
9 |
10 | /* qhasm: fe A */
11 |
12 | /* qhasm: fe AA */
13 |
14 | /* qhasm: fe XX */
15 |
16 | /* qhasm: fe YY */
17 |
18 | /* qhasm: fe B */
19 |
20 | /* qhasm: fe X3 */
21 |
22 | /* qhasm: fe Y3 */
23 |
24 | /* qhasm: fe Z3 */
25 |
26 | /* qhasm: fe T3 */
27 |
28 | /* qhasm: XX=X1^2 */
29 | /* asm 1: fe_sq(>XX=fe#1,XX=r->X,X); */
31 | fe_sq(r->X,p->X);
32 |
33 | /* qhasm: YY=Y1^2 */
34 | /* asm 1: fe_sq(>YY=fe#3,YY=r->Z,Y); */
36 | fe_sq(r->Z,p->Y);
37 |
38 | /* qhasm: B=2*Z1^2 */
39 | /* asm 1: fe_sq2(>B=fe#4,B=r->T,Z); */
41 | fe_sq2(r->T,p->Z);
42 |
43 | /* qhasm: A=X1+Y1 */
44 | /* asm 1: fe_add(>A=fe#2,A=r->Y,X,Y); */
46 | fe_add(r->Y,p->X,p->Y);
47 |
48 | /* qhasm: AA=A^2 */
49 | /* asm 1: fe_sq(>AA=fe#5,AA=t0,Y); */
51 | fe_sq(t0,r->Y);
52 |
53 | /* qhasm: Y3=YY+XX */
54 | /* asm 1: fe_add(>Y3=fe#2,Y3=r->Y,Z,X); */
56 | fe_add(r->Y,r->Z,r->X);
57 |
58 | /* qhasm: Z3=YY-XX */
59 | /* asm 1: fe_sub(>Z3=fe#3,Z3=r->Z,Z,X); */
61 | fe_sub(r->Z,r->Z,r->X);
62 |
63 | /* qhasm: X3=AA-Y3 */
64 | /* asm 1: fe_sub(>X3=fe#1,X3=r->X,Y); */
66 | fe_sub(r->X,t0,r->Y);
67 |
68 | /* qhasm: T3=B-Z3 */
69 | /* asm 1: fe_sub(>T3=fe#4,T3=r->T,T,Z); */
71 | fe_sub(r->T,r->T,r->Z);
72 |
73 | /* qhasm: return */
74 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_p3_0.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | void ge_p3_0(ge_p3 *h)
4 | {
5 | fe_0(h->X);
6 | fe_1(h->Y);
7 | fe_1(h->Z);
8 | fe_0(h->T);
9 | }
10 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_p3_dbl.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | /*
4 | r = 2 * p
5 | */
6 |
7 | void ge_p3_dbl(ge_p1p1 *r,const ge_p3 *p)
8 | {
9 | ge_p2 q;
10 | ge_p3_to_p2(&q,p);
11 | ge_p2_dbl(r,&q);
12 | }
13 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_p3_to_cached.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | /*
4 | r = p
5 | */
6 |
7 | static const fe d2 = {
8 | #include "d2.h"
9 | } ;
10 |
11 | extern void ge_p3_to_cached(ge_cached *r,const ge_p3 *p)
12 | {
13 | fe_add(r->YplusX,p->Y,p->X);
14 | fe_sub(r->YminusX,p->Y,p->X);
15 | fe_copy(r->Z,p->Z);
16 | fe_mul(r->T2d,p->T,d2);
17 | }
18 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_p3_to_p2.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | /*
4 | r = p
5 | */
6 |
7 | extern void ge_p3_to_p2(ge_p2 *r,const ge_p3 *p)
8 | {
9 | fe_copy(r->X,p->X);
10 | fe_copy(r->Y,p->Y);
11 | fe_copy(r->Z,p->Z);
12 | }
13 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_p3_tobytes.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | void ge_p3_tobytes(unsigned char *s,const ge_p3 *h)
4 | {
5 | fe recip;
6 | fe x;
7 | fe y;
8 |
9 | fe_invert(recip,h->Z);
10 | fe_mul(x,h->X,recip);
11 | fe_mul(y,h->Y,recip);
12 | fe_tobytes(s,y);
13 | s[31] ^= fe_isnegative(x) << 7;
14 | }
15 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_precomp_0.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | void ge_precomp_0(ge_precomp *h)
4 | {
5 | fe_1(h->yplusx);
6 | fe_1(h->yminusx);
7 | fe_0(h->xy2d);
8 | }
9 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_sub.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | /*
4 | r = p - q
5 | */
6 |
7 | void ge_sub(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q)
8 | {
9 | fe t0;
10 | #include "ge_sub.h"
11 | }
12 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/ge_tobytes.c:
--------------------------------------------------------------------------------
1 | #include "ge.h"
2 |
3 | void ge_tobytes(unsigned char *s,const ge_p2 *h)
4 | {
5 | fe recip;
6 | fe x;
7 | fe y;
8 |
9 | fe_invert(recip,h->Z);
10 | fe_mul(x,h->X,recip);
11 | fe_mul(y,h->Y,recip);
12 | fe_tobytes(s,y);
13 | s[31] ^= fe_isnegative(x) << 7;
14 | }
15 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/nacl_includes/crypto_int32.h:
--------------------------------------------------------------------------------
1 | #ifndef crypto_int32_h
2 | #define crypto_int32_h
3 |
4 | typedef int crypto_int32;
5 |
6 | #endif
7 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/nacl_includes/crypto_int64.h:
--------------------------------------------------------------------------------
1 | #ifndef crypto_int64_h
2 | #define crypto_int64_h
3 |
4 | typedef long long crypto_int64;
5 |
6 | #endif
7 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/nacl_includes/crypto_sign.h:
--------------------------------------------------------------------------------
1 | #ifndef crypto_sign_H
2 | #define crypto_sign_H
3 |
4 | #include "crypto_sign_edwards25519sha512batch.h"
5 |
6 | #define crypto_sign crypto_sign_edwards25519sha512batch
7 | #define crypto_sign_open crypto_sign_edwards25519sha512batch_open
8 | #define crypto_sign_keypair crypto_sign_edwards25519sha512batch_keypair
9 | #define crypto_sign_BYTES crypto_sign_edwards25519sha512batch_BYTES
10 | #define crypto_sign_PUBLICKEYBYTES crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES
11 | #define crypto_sign_SECRETKEYBYTES crypto_sign_edwards25519sha512batch_SECRETKEYBYTES
12 | #define crypto_sign_PRIMITIVE "edwards25519sha512batch"
13 | #define crypto_sign_IMPLEMENTATION crypto_sign_edwards25519sha512batch_IMPLEMENTATION
14 | #define crypto_sign_VERSION crypto_sign_edwards25519sha512batch_VERSION
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/nacl_includes/crypto_sign_edwards25519sha512batch.h:
--------------------------------------------------------------------------------
1 | #ifndef crypto_sign_edwards25519sha512batch_H
2 | #define crypto_sign_edwards25519sha512batch_H
3 |
4 | #define crypto_sign_edwards25519sha512batch_ref10_SECRETKEYBYTES 64
5 | #define crypto_sign_edwards25519sha512batch_ref10_PUBLICKEYBYTES 32
6 | #define crypto_sign_edwards25519sha512batch_ref10_BYTES 64
7 | #ifdef __cplusplus
8 | #include
9 | extern std::string crypto_sign_edwards25519sha512batch_ref10(const std::string &,const std::string &);
10 | extern std::string crypto_sign_edwards25519sha512batch_ref10_open(const std::string &,const std::string &);
11 | extern std::string crypto_sign_edwards25519sha512batch_ref10_keypair(std::string *);
12 | extern "C" {
13 | #endif
14 | extern int crypto_sign_edwards25519sha512batch_ref10(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
15 | extern int crypto_sign_edwards25519sha512batch_ref10_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
16 | extern int crypto_sign_edwards25519sha512batch_ref10_keypair(unsigned char *,unsigned char *);
17 | #ifdef __cplusplus
18 | }
19 | #endif
20 |
21 | #define crypto_sign_edwards25519sha512batch crypto_sign_edwards25519sha512batch_ref10
22 | #define crypto_sign_edwards25519sha512batch_open crypto_sign_edwards25519sha512batch_ref10_open
23 | #define crypto_sign_edwards25519sha512batch_keypair crypto_sign_edwards25519sha512batch_ref10_keypair
24 | #define crypto_sign_edwards25519sha512batch_BYTES crypto_sign_edwards25519sha512batch_ref10_BYTES
25 | #define crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES crypto_sign_edwards25519sha512batch_ref10_PUBLICKEYBYTES
26 | #define crypto_sign_edwards25519sha512batch_SECRETKEYBYTES crypto_sign_edwards25519sha512batch_ref10_SECRETKEYBYTES
27 | #define crypto_sign_edwards25519sha512batch_IMPLEMENTATION "crypto_sign/edwards25519sha512batch/ref10"
28 | #ifndef crypto_sign_edwards25519sha512batch_ref10_VERSION
29 | #define crypto_sign_edwards25519sha512batch_ref10_VERSION "-"
30 | #endif
31 | #define crypto_sign_edwards25519sha512batch_VERSION crypto_sign_edwards25519sha512batch_ref10_VERSION
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/nacl_includes/crypto_uint32.h:
--------------------------------------------------------------------------------
1 | #ifndef crypto_uint32_h
2 | #define crypto_uint32_h
3 |
4 | typedef unsigned int crypto_uint32;
5 |
6 | #endif
7 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/nacl_includes/crypto_uint64.h:
--------------------------------------------------------------------------------
1 | #ifndef crypto_uint64_h
2 | #define crypto_uint64_h
3 |
4 | typedef unsigned long long crypto_uint64;
5 |
6 | #endif
7 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/nacl_includes/crypto_verify_32.h:
--------------------------------------------------------------------------------
1 | #ifndef crypto_verify_32_H
2 | #define crypto_verify_32_H
3 |
4 | #define crypto_verify_32_ref_BYTES 32
5 | #ifdef __cplusplus
6 | #include
7 | extern "C" {
8 | #endif
9 | extern int crypto_verify_32_ref(const unsigned char *,const unsigned char *);
10 | #ifdef __cplusplus
11 | }
12 | #endif
13 |
14 | #define crypto_verify_32 crypto_verify_32_ref
15 | #define crypto_verify_32_BYTES crypto_verify_32_ref_BYTES
16 | #define crypto_verify_32_IMPLEMENTATION "crypto_verify/32/ref"
17 | #ifndef crypto_verify_32_ref_VERSION
18 | #define crypto_verify_32_ref_VERSION "-"
19 | #endif
20 | #define crypto_verify_32_VERSION crypto_verify_32_ref_VERSION
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/nacl_sha512/hash.c:
--------------------------------------------------------------------------------
1 | /*
2 | 20080913
3 | D. J. Bernstein
4 | Public domain.
5 | */
6 |
7 | #include
8 | typedef uint64_t uint64;
9 |
10 | extern int crypto_hashblocks_sha512(unsigned char *statebytes,const unsigned char *in,unsigned long long inlen);
11 |
12 | #define blocks crypto_hashblocks_sha512
13 |
14 | static const unsigned char iv[64] = {
15 | 0x6a,0x09,0xe6,0x67,0xf3,0xbc,0xc9,0x08,
16 | 0xbb,0x67,0xae,0x85,0x84,0xca,0xa7,0x3b,
17 | 0x3c,0x6e,0xf3,0x72,0xfe,0x94,0xf8,0x2b,
18 | 0xa5,0x4f,0xf5,0x3a,0x5f,0x1d,0x36,0xf1,
19 | 0x51,0x0e,0x52,0x7f,0xad,0xe6,0x82,0xd1,
20 | 0x9b,0x05,0x68,0x8c,0x2b,0x3e,0x6c,0x1f,
21 | 0x1f,0x83,0xd9,0xab,0xfb,0x41,0xbd,0x6b,
22 | 0x5b,0xe0,0xcd,0x19,0x13,0x7e,0x21,0x79
23 | } ;
24 |
25 | int crypto_hash_sha512(unsigned char *out,const unsigned char *in,unsigned long long inlen)
26 | {
27 | unsigned char h[64];
28 | unsigned char padded[256];
29 | int i;
30 | unsigned long long bytes = inlen;
31 |
32 | for (i = 0;i < 64;++i) h[i] = iv[i];
33 |
34 | blocks(h,in,inlen);
35 | in += inlen;
36 | inlen &= 127;
37 | in -= inlen;
38 |
39 | for (i = 0;i < inlen;++i) padded[i] = in[i];
40 | padded[inlen] = 0x80;
41 |
42 | if (inlen < 112) {
43 | for (i = inlen + 1;i < 119;++i) padded[i] = 0;
44 | padded[119] = bytes >> 61;
45 | padded[120] = bytes >> 53;
46 | padded[121] = bytes >> 45;
47 | padded[122] = bytes >> 37;
48 | padded[123] = bytes >> 29;
49 | padded[124] = bytes >> 21;
50 | padded[125] = bytes >> 13;
51 | padded[126] = bytes >> 5;
52 | padded[127] = bytes << 3;
53 | blocks(h,padded,128);
54 | } else {
55 | for (i = inlen + 1;i < 247;++i) padded[i] = 0;
56 | padded[247] = bytes >> 61;
57 | padded[248] = bytes >> 53;
58 | padded[249] = bytes >> 45;
59 | padded[250] = bytes >> 37;
60 | padded[251] = bytes >> 29;
61 | padded[252] = bytes >> 21;
62 | padded[253] = bytes >> 13;
63 | padded[254] = bytes >> 5;
64 | padded[255] = bytes << 3;
65 | blocks(h,padded,256);
66 | }
67 |
68 | for (i = 0;i < 64;++i) out[i] = h[i];
69 |
70 | return 0;
71 | }
72 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/open.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "crypto_sign.h"
3 | #include "crypto_hash_sha512.h"
4 | #include "crypto_verify_32.h"
5 | #include "ge.h"
6 | #include "sc.h"
7 |
8 | int crypto_sign_open(
9 | unsigned char *m,unsigned long long *mlen,
10 | const unsigned char *sm,unsigned long long smlen,
11 | const unsigned char *pk
12 | )
13 | {
14 | unsigned char pkcopy[32];
15 | unsigned char rcopy[32];
16 | unsigned char scopy[32];
17 | unsigned char h[64];
18 | unsigned char rcheck[32];
19 | ge_p3 A;
20 | ge_p2 R;
21 |
22 | if (smlen < 64) goto badsig;
23 | if (sm[63] & 224) goto badsig;
24 | if (ge_frombytes_negate_vartime(&A,pk) != 0) goto badsig;
25 |
26 | memmove(pkcopy,pk,32);
27 | memmove(rcopy,sm,32);
28 | memmove(scopy,sm + 32,32);
29 |
30 | memmove(m,sm,smlen);
31 | memmove(m + 32,pkcopy,32);
32 | crypto_hash_sha512(h,m,smlen);
33 | sc_reduce(h);
34 |
35 | ge_double_scalarmult_vartime(&R,h,&A,scopy);
36 | ge_tobytes(rcheck,&R);
37 | if (crypto_verify_32(rcheck,rcopy) == 0) {
38 | memmove(m,m + 64,smlen - 64);
39 | memset(m + smlen - 64,0,64);
40 | *mlen = smlen - 64;
41 | return 0;
42 | }
43 |
44 | badsig:
45 | *mlen = -1;
46 | memset(m,0,smlen);
47 | return -1;
48 | }
49 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/sc.h:
--------------------------------------------------------------------------------
1 | #ifndef SC_H
2 | #define SC_H
3 |
4 | /*
5 | The set of scalars is \Z/l
6 | where l = 2^252 + 27742317777372353535851937790883648493.
7 | */
8 |
9 | #define sc_reduce crypto_sign_ed25519_ref10_sc_reduce
10 | #define sc_muladd crypto_sign_ed25519_ref10_sc_muladd
11 |
12 | extern void sc_reduce(unsigned char *);
13 | extern void sc_muladd(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/sign.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "crypto_sign.h"
3 | #include "crypto_hash_sha512.h"
4 | #include "ge.h"
5 | #include "sc.h"
6 |
7 | int crypto_sign(
8 | unsigned char *sm,unsigned long long *smlen,
9 | const unsigned char *m,unsigned long long mlen,
10 | const unsigned char *sk
11 | )
12 | {
13 | unsigned char pk[32];
14 | unsigned char az[64];
15 | unsigned char nonce[64];
16 | unsigned char hram[64];
17 | ge_p3 R;
18 |
19 | memmove(pk,sk + 32,32);
20 |
21 | crypto_hash_sha512(az,sk,32);
22 | az[0] &= 248;
23 | az[31] &= 63;
24 | az[31] |= 64;
25 |
26 | *smlen = mlen + 64;
27 | memmove(sm + 64,m,mlen);
28 | memmove(sm + 32,az + 32,32);
29 | crypto_hash_sha512(nonce,sm + 32,mlen + 32);
30 | memmove(sm + 32,pk,32);
31 |
32 | sc_reduce(nonce);
33 | ge_scalarmult_base(&R,nonce);
34 | ge_p3_tobytes(sm,&R);
35 |
36 | crypto_hash_sha512(hram,sm,mlen + 64);
37 | sc_reduce(hram);
38 | sc_muladd(sm + 32,hram,az,nonce);
39 |
40 | return 0;
41 | }
42 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Curve25519/Sources/ed25519/sqrtm1.h:
--------------------------------------------------------------------------------
1 | -32595792,-7943725,9377950,3500415,12389472,-272473,-25146209,-2005654,326686,11406482
2 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/Vendors/Keccak/Sources/keccak.h:
--------------------------------------------------------------------------------
1 | // keccak.h
2 | // 19-Nov-11 Markku-Juhani O. Saarinen
3 |
4 | #ifndef KECCAK_H
5 | #define KECCAK_H
6 |
7 | #include
8 | #include
9 |
10 | #ifndef KECCAK_ROUNDS
11 | #define KECCAK_ROUNDS 24
12 | #endif
13 |
14 | #ifndef ROTL64
15 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y))))
16 | #endif
17 |
18 | // compute a keccak hash (md) of given byte length from "in"
19 | int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen);
20 |
21 | // update the state
22 | void keccakf(uint64_t st[25], int norounds);
23 |
24 | #endif
25 |
26 |
--------------------------------------------------------------------------------
/WavesSDKCrypto/WavesSDKCrypto.h:
--------------------------------------------------------------------------------
1 | //
2 | // InternalWavesSDKCrypto.h
3 | // InternalWavesSDKCrypto
4 | //
5 | // Created by rprokofev on 27.06.2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | #ifdef __OBJC__
10 | #import
11 | #else
12 | #ifndef FOUNDATION_EXPORT
13 | #if defined(__cplusplus)
14 | #define FOUNDATION_EXPORT extern "C"
15 | #else
16 | #define FOUNDATION_EXPORT extern
17 | #endif
18 | #endif
19 | #endif
20 |
21 |
22 | #import "Curve25519.h"
23 | #import "Ed25519.h"
24 | #import "Randomness.h"
25 | #import "crypto_generichash_blake2b.h"
26 | #import "base58.h"
27 | #import "keccak.h"
28 |
29 | //! Project version number for InternalWavesSDKCrypto.
30 | FOUNDATION_EXPORT double WavesSDKCryptoVersionNumber;
31 |
32 | //! Project version string for InternalWavesSDKCrypto.
33 | FOUNDATION_EXPORT const unsigned char WavesSDKCryptoVersionString[];
34 |
35 | // In this header, you should import all the public headers of your framework using statements like #import
36 |
37 |
38 |
--------------------------------------------------------------------------------
/WavesSDKExamples/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '11.0'
2 |
3 | use_frameworks!(true)
4 |
5 |
6 | target 'WavesSDKExamples' do
7 | inherit! :search_paths
8 | pod 'WavesSDK'
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/WavesSDKExamples/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Alamofire (4.8.2)
3 | - Moya (12.0.1):
4 | - Moya/Core (= 12.0.1)
5 | - Moya/Core (12.0.1):
6 | - Alamofire (~> 4.1)
7 | - Result (~> 4.0)
8 | - Moya/RxSwift (12.0.1):
9 | - Moya/Core
10 | - RxSwift (~> 4.0)
11 | - Result (4.1.0)
12 | - RxSwift (4.5.0)
13 | - WavesSDK (0.1.7):
14 | - Moya (~> 12.0.1)
15 | - Moya/RxSwift (~> 12.0.1)
16 | - RxSwift (~> 4.0)
17 | - WavesSDKCrypto
18 | - WavesSDKExtensions
19 | - WavesSDKCrypto (0.1.7):
20 | - WavesSDKExtensions
21 | - WavesSDKExtensions (0.1.7):
22 | - RxSwift (~> 4.0)
23 |
24 | DEPENDENCIES:
25 | - WavesSDK
26 |
27 | SPEC REPOS:
28 | https://github.com/cocoapods/specs.git:
29 | - Alamofire
30 | - Moya
31 | - Result
32 | - RxSwift
33 | - WavesSDK
34 | - WavesSDKCrypto
35 | - WavesSDKExtensions
36 |
37 | SPEC CHECKSUMS:
38 | Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3
39 | Moya: cf730b3cd9e005401ef37a85143aa141a12fd38f
40 | Result: bd966fac789cc6c1563440b348ab2598cc24d5c7
41 | RxSwift: f172070dfd1a93d70a9ab97a5a01166206e1c575
42 | WavesSDK: 4212f8b34a3e732cac52facb216466122f94b12d
43 | WavesSDKCrypto: 05aab03ff2c6a8b5c98d6d1b38e557f4799756e3
44 | WavesSDKExtensions: b0b46dd85aed81fd14e184da35582fda66da29d8
45 |
46 | PODFILE CHECKSUM: 0c51b5e2a57fe87859a8f4018538d3545907b878
47 |
48 | COCOAPODS: 1.7.4
49 |
--------------------------------------------------------------------------------
/WavesSDKExamples/WavesSDKExamples/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/WavesSDKExamples/WavesSDKExamples/Resources/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/WavesSDKExamples/WavesSDKExamples/Resources/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/WavesSDKExamples/WavesSDKExamples/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | NSAppTransportSecurity
24 |
25 | NSAllowsArbitraryLoads
26 |
27 |
28 | UILaunchStoryboardName
29 | LaunchScreen
30 | UIMainStoryboardFile
31 | Main
32 | UIRequiredDeviceCapabilities
33 |
34 | armv7
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UISupportedInterfaceOrientations~ipad
43 |
44 | UIInterfaceOrientationPortrait
45 | UIInterfaceOrientationPortraitUpsideDown
46 | UIInterfaceOrientationLandscapeLeft
47 | UIInterfaceOrientationLandscapeRight
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/WavesSDKExamples/WavesSDKExamples/Sources/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // WavesSDK
4 | //
5 | // Created by rprokofev on 03/04/2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import WavesSDK
11 | import WavesSDKExtensions
12 |
13 | @UIApplicationMain
14 | class AppDelegate: UIResponder, UIApplicationDelegate {
15 |
16 | var window: UIWindow?
17 |
18 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
19 |
20 |
21 | SweetLogger.current.add(plugins: [SweetLoggerConsole(visibleLevels: [.network, .error], isShortLog: false)])
22 | SweetLogger.current.visibleLevels = [.network, .error]
23 |
24 | WavesSDK.initialization(servicesPlugins: .init(data: [],
25 | node: [],
26 | matcher: []),
27 | enviroment: .init(server: .mainNet, timestampServerDiff: 0))
28 |
29 |
30 |
31 | return true
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/WavesSDKExtensions.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |spec|
2 |
3 | spec.name = 'WavesSDKExtensions'
4 | spec.version = '0.1.9'
5 | spec.ios.deployment_target = '11.0'
6 | spec.requires_arc = true
7 | spec.swift_version = '5.0'
8 |
9 | spec.license = { :type => 'MIT License', :file => 'LICENSE' }
10 | spec.homepage = 'https://wavesplatform.com'
11 | spec.authors = { 'Mefilt' => 'mefilt@gmail.com', }
12 | spec.summary = 'WavesSDK – it is mobile libraries for easy and simple co-working Waves blockchain platform and any mobile app'
13 |
14 | spec.source_files = 'WavesSDKExtensions/Sources/**/*.{swift}'
15 | spec.source = { :git => 'https://github.com/wavesplatform/WavesSDK-iOS.git', :tag => 'v' + spec.version.to_s}
16 |
17 | spec.ios.framework = 'Foundation'
18 | spec.ios.framework = 'UIKit'
19 |
20 | spec.dependency 'RxSwift', '~> 4.0'
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 0.1.7
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/InternalWavesSDKExtensions.h:
--------------------------------------------------------------------------------
1 | //
2 | // InternalWavesSDKExtensions.h
3 | // InternalWavesSDKExtensions
4 | //
5 | // Created by rprokofev on 27.06.2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for InternalWavesSDKExtensions.
12 | FOUNDATION_EXPORT double InternalWavesSDKExtensionsVersionNumber;
13 |
14 | //! Project version string for InternalWavesSDKExtensions.
15 | FOUNDATION_EXPORT const unsigned char InternalWavesSDKExtensionsVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Any+Name.swift:
--------------------------------------------------------------------------------
1 | //
2 | // String+ClassName.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 05/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public func nameType(_ any: Any.Type) -> String {
12 | return String(describing: any)
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Array/Array+Extension.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ArrayExtension.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Alexey Koloskov on 26/04/2017.
6 | // Copyright © 2017 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension Collection where Indices.Iterator.Element == Index {
12 |
13 | /// Returns the element at the specified index iff it is within bounds, otherwise nil.
14 | subscript (safe index: Index) -> Iterator.Element? {
15 | return indices.contains(index) ? self[index] : nil
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Array/Array+Sort.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Array+Sort.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Pavel Gubin on 7/18/18.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension Array {
12 | mutating func shuffle() {
13 | for i in 0 ..< Swift.max((count - 1), 0) {
14 | let j = Int(arc4random_uniform(UInt32(count - i))) + i
15 | swapAt(i, j)
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Assert+Message.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Asset+Message.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 31.08.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public func assertMethodDontSupported() {
12 | assert(true, "Method don't supported")
13 | }
14 |
15 | public func assertVarDontSupported() {
16 | assert(true, "Method don't supported")
17 | }
18 |
19 | public func assertMethodNeedOverriding() {
20 | assert(true, "Method need overriding")
21 | }
22 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Date/DateExtension+Sync.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | public extension Date {
4 |
5 | func millisecondsSince1970(timestampDiff: Int64) -> Int64 {
6 | return millisecondsSince1970 - timestampDiff
7 | }
8 |
9 | var millisecondsSince1970: Int64 {
10 | return Int64(self.timeIntervalSince1970 * 1000.0)
11 | }
12 |
13 |
14 | init(milliseconds: Int64) {
15 | self = Date(timeIntervalSince1970: TimeInterval(milliseconds / 1000))
16 | }
17 |
18 | init(timestampDecoder from: Decoder, timestampDiff: Int64) {
19 | if let container = try? from.singleValueContainer(),
20 | let miliseconds = try? container.decode(Int64.self) {
21 | self = Date(milliseconds: miliseconds + timestampDiff)
22 | }
23 | else {
24 | self = Date()
25 | }
26 | }
27 |
28 | init(timestampDecoderSeconds from: Decoder, timestampDiff: Int64) {
29 | if let container = try? from.singleValueContainer(),
30 | let miliseconds = try? container.decode(Int64.self) {
31 | self = Date(milliseconds: miliseconds * 1000 + timestampDiff)
32 | }
33 | else {
34 | self = Date()
35 | }
36 | }
37 |
38 | init(isoDecoder from: Decoder, timestampDiff: Int64) {
39 |
40 | let formatter = DateFormatter.iso()
41 |
42 | if let container = try? from.singleValueContainer(),
43 | let stringDate = try? container.decode(String.self),
44 | let date = formatter.date(from: stringDate) {
45 | self = date.addingTimeInterval(TimeInterval(timestampDiff) / 1000)
46 | }
47 | else {
48 | self = Date()
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Date/DateFormatter+ISO.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DateFormatter+ISO.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 23.08.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DateFormatter {
12 |
13 | private enum Constants {
14 | static let key: String = "dateFormatter.iso"
15 | }
16 |
17 | static func iso() -> DateFormatter {
18 |
19 | let dateFormatter = Thread
20 | .threadSharedObject(key: Constants.key,
21 | create: { return DateFormatter() })
22 | let enUSPosixLocale = Locale(identifier: "en_US_POSIX")
23 | dateFormatter.locale = enUSPosixLocale
24 | dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
25 |
26 | return dateFormatter
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Date/DateFormatter+Once.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DateFormatter+Once.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 29/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension DateFormatter {
12 |
13 | static func sharedFormatter(key: String) -> DateFormatter {
14 | return Thread
15 | .threadSharedObject(key: key,
16 | create: { return DateFormatter() })
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Dictionary+Json.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Dictionary+Json.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 08/09/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension Dictionary {
12 | var prettyJSON: String? {
13 | do {
14 | let data: Data = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted)
15 | return String(data: data, encoding: .utf8)
16 | } catch _ {
17 | return nil
18 | }
19 | }
20 | }
21 |
22 | public extension Array {
23 | var prettyJSON: String? {
24 | do {
25 | let data: Data = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted)
26 | return String(data: data, encoding: .utf8)
27 | } catch _ {
28 | return nil
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/DispatchTimeInterval.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DispatchTimeInterval.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 02/10/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension Int {
12 |
13 | var seconds: DispatchTimeInterval {
14 | return DispatchTimeInterval.seconds(self)
15 | }
16 |
17 | var second: DispatchTimeInterval {
18 | return seconds
19 | }
20 |
21 | var milliseconds: DispatchTimeInterval {
22 | return DispatchTimeInterval.milliseconds(self)
23 | }
24 |
25 | var millisecond: DispatchTimeInterval {
26 | return milliseconds
27 | }
28 |
29 | }
30 |
31 | public extension DispatchTimeInterval {
32 | var fromNow: DispatchTime {
33 | return DispatchTime.now() + self
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Encodable+Dictionary.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Encodable+Dictionary.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 09.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension Encodable {
12 |
13 | subscript(key: String) -> Any? {
14 | return dictionary[key]
15 | }
16 |
17 | var data: Data? {
18 | return try? JSONEncoder().encode(self)
19 | }
20 |
21 | var dictionary: [String: Any] {
22 | guard let data = data else { return [:] }
23 | return (try? JSONSerialization.jsonObject(with: data)) as? [String: Any] ?? [:]
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/JSONDecoder+TimestampDiff.swift:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // JSONDecoder+Date.swift
4 | // Alamofire
5 | //
6 | // Created by rprokofev on 30/04/2019.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension JSONDecoder {
12 |
13 | static func decoderBySyncingTimestamp(_ timestampServerDiff: Int64) -> JSONDecoder {
14 |
15 | let decoder = JSONDecoder()
16 | decoder.dateDecodingStrategy = .custom { decoder in
17 | return Date(timestampDecoder: decoder, timestampDiff: timestampServerDiff)
18 | }
19 |
20 | return decoder
21 | }
22 |
23 | static func isoDecoderBySyncingTimestamp(_ timestampServerDiff: Int64) -> JSONDecoder {
24 |
25 | let decoder = JSONDecoder()
26 | decoder.dateDecodingStrategy = .custom { decoder in
27 | return Date(isoDecoder: decoder, timestampDiff: timestampServerDiff)
28 | }
29 |
30 | return decoder
31 | }
32 |
33 | static func decoderByDateWithSecond(_ timestampServerDiff: Int64) -> JSONDecoder {
34 |
35 | let decoder = JSONDecoder()
36 | decoder.dateDecodingStrategy = .custom { decoder in
37 | return Date(timestampDecoderSeconds: decoder, timestampDiff: timestampServerDiff)
38 | }
39 |
40 | return decoder
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/JSONDecoder/JSONDecoder+JSON.swift:
--------------------------------------------------------------------------------
1 | //
2 | // JSONDecoder+JSON.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 13.09.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension JSONDecoder {
12 |
13 | static func decode(json fileName: String) -> Model? {
14 | let decoder = JSONDecoder()
15 | guard let path = Bundle.main.url(forResource: fileName, withExtension: "json") else {
16 | return nil
17 | }
18 | guard let data = try? Data(contentsOf: path) else {
19 | return nil
20 | }
21 |
22 | return try? decoder.decode(Model.self, from: data)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/JSONDecoder/JSONDecoder+Rx.swift:
--------------------------------------------------------------------------------
1 | //
2 | // JSONDecodable+Rx.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 21/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import RxSwift
11 |
12 | fileprivate enum Constants {
13 | static let dateFormatterKey = "waves.dateFormatter"
14 | }
15 |
16 | public extension JSONDecoder {
17 |
18 | static func decode(type: Type.Type, json name: String) -> Observable {
19 |
20 | return Observable.create { (observer) -> Disposable in
21 |
22 | do {
23 | let decoder = JSONDecoder()
24 |
25 | let dateFormate = DateFormatter.sharedFormatter(key: Constants.dateFormatterKey)
26 | dateFormate.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
27 | decoder.dateDecodingStrategy = .formatted(dateFormate)
28 |
29 | let file = Bundle.main.path(forResource: name, ofType: "json")!
30 | let data = try Data(contentsOf: URL(fileURLWithPath: file))
31 | let element = try decoder.decode(type, from: data)
32 |
33 | observer.onNext(element)
34 | } catch let error {
35 | SweetLogger.debug(error)
36 | observer.onError(error)
37 | }
38 | return Disposables.create()
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/NSObject+AssociatedObject.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+AssociatedObject.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 10/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NSObject {
12 |
13 | func associatedObject(for key: UnsafeRawPointer) -> T? {
14 | return objc_getAssociatedObject(self, key) as? T
15 | }
16 |
17 | func setAssociatedObject(_ object: T, for key: UnsafeRawPointer) {
18 | objc_setAssociatedObject(self, key, object, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/NumberFormatter+Once.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NumberFormatter+Once.swift
3 | // WavesSDKExtensions
4 | //
5 | // Created by Sergey Gusev on 24.12.2020.
6 | // Copyright © 2020 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension NumberFormatter {
12 |
13 | static func sharedFormatter(key: String) -> NumberFormatter {
14 | return Thread
15 | .threadSharedObject(key: key,
16 | create: { return NumberFormatter() })
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/ObjectDestructor.swift:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // ObjectDestructor.swift
4 | // WavesWallet-iOS
5 | //
6 | // Created by mefilt on 16.08.2018.
7 | // Copyright © 2018 Waves Platform. All rights reserved.
8 | //
9 |
10 | import Foundation
11 |
12 | public final class ObjectDestructor {
13 |
14 | let dealloc: (() -> Void)
15 |
16 | init(dealloc: @escaping (() -> Void)) {
17 | self.dealloc = dealloc
18 | }
19 |
20 | deinit {
21 | dealloc()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Optional+Hashable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Optional+Hashable.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 11.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | #if swift(>=4.2)
12 | #else
13 | extension Optional: Sequence where Wrapped: Sequence {
14 | public typealias Element = Wrapped.Iterator.Element
15 | public typealias Iterator = AnyIterator
16 |
17 | public func makeIterator() -> AnyIterator {
18 | return self.map { AnyIterator($0.makeIterator()) }
19 | ?? AnyIterator(EmptyCollection().makeIterator())
20 | }
21 | }
22 | #endif
23 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/RxSwift+Scheduler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // RxSwift+Scheduler.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 10/10/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import RxSwift
11 |
12 | public var myDefaultScheduler: SchedulerType = MainScheduler.asyncInstance
13 | public var myWorkScheduler: SchedulerType = ConcurrentDispatchQueueScheduler(qos: .default)
14 |
15 | public extension ObservableType {
16 |
17 | /**
18 | Makes the observable Subscribe to io thread and Observe on main thread
19 | */
20 | func composeIoToMainThreads() -> Observable {
21 | return self.subscribeOn(myWorkScheduler)
22 | .observeOn(myDefaultScheduler)
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/String/String+Bytes.swift:
--------------------------------------------------------------------------------
1 | //
2 | // String+Bytes.swift
3 | // WavesSDKExtensions
4 | //
5 | // Created by Pavel Gubin on 09.07.2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension String {
12 |
13 | var toBytes: [UInt8] {
14 | return [UInt8](self.utf8)
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/String/String+Escaped.swift:
--------------------------------------------------------------------------------
1 | //
2 | // String+Escaped.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 08.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension String {
12 | var urlEscaped: String {
13 | return addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/String/String+UInt.swift:
--------------------------------------------------------------------------------
1 | //
2 | // String+UInt.swift
3 | // Base58
4 | //
5 | // Created by rprokofev on 10/04/2019.
6 | //
7 |
8 | import Foundation
9 |
10 | public extension String {
11 | func toUInt() -> UInt? {
12 | let scanner = Scanner(string: self)
13 | var u: UInt64 = 0
14 | if scanner.scanUnsignedLongLong(&u) && scanner.isAtEnd {
15 | return UInt(u)
16 | }
17 | return nil
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/String/String+URL.swift:
--------------------------------------------------------------------------------
1 | //
2 | // String+URL.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 22/10/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension String {
12 |
13 | var isValidUrl: Bool {
14 | let urlRegEx = "[(http(s)?)://(www\\.)?a-zA-Z0-9@:%._\\+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\\+.~#?&//=]*)"
15 | let urlTest = NSPredicate(format:"SELF MATCHES %@", urlRegEx)
16 | let result = urlTest.evaluate(with: self)
17 | return result
18 | }
19 |
20 | func urlByAdding(params: [String : String]) -> String {
21 |
22 | var url = self
23 | for key in params.keys {
24 | if let value = params[key] {
25 | if (url as NSString).range(of: "?").location == NSNotFound {
26 | url.append("?")
27 | }
28 |
29 | if url.last != "?" {
30 | url.append("&")
31 | }
32 | url.append(key + "=" + value)
33 | }
34 | }
35 | return url
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/String/String+Utils.swift:
--------------------------------------------------------------------------------
1 | //
2 | // StringExtension.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Alexey Koloskov on 03/05/2017.
6 | // Copyright © 2017 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension String {
12 |
13 | func trimmingLeadingWhitespace() -> String {
14 | let range = (self as NSString).range(of: "^\\s*", options: [.regularExpression])
15 | return (self as NSString).replacingCharacters(in: range, with: "")
16 | }
17 |
18 | func removeCharacters(from forbiddenChars: CharacterSet) -> String {
19 | let passed = unicodeScalars.filter { !forbiddenChars.contains($0) }
20 | return String(String.UnicodeScalarView(passed))
21 | }
22 |
23 | func removeCharacters(from: String) -> String {
24 | return removeCharacters(from: CharacterSet(charactersIn: from))
25 | }
26 |
27 | static func random(length: Int, letters: String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") -> String {
28 | return String((0.. [UInt8] {
36 | return Array(utf8).arrayWithSize()
37 | }
38 |
39 | //TODO: Rename
40 | func arrayWithSize32() -> [UInt8] {
41 | return Array(utf8).arrayWithSize32()
42 | }
43 | }
44 |
45 | public extension Array where Element == UInt8 {
46 |
47 | //TODO: Rename
48 | func arrayWithSize() -> [UInt8] {
49 | let b: [UInt8] = self
50 | return toByteArray(Int16(Swift.min(Int(Int16.max), b.count))) + b
51 | }
52 |
53 | //TODO: Rename
54 | func arrayWithSize32() -> [UInt8] {
55 | let b: [UInt8] = self
56 | return toByteArray(Int32(b.count)) + b
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/Thread+Assisstants.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Thread+Assisstants.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 29/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public extension Thread {
12 |
13 | static func threadSharedObject(key: String, create: () -> T) -> T {
14 | if let cachedObj = Thread.current.threadDictionary[key] as? T {
15 | return cachedObj
16 | } else {
17 | let newObject = create()
18 | Thread.current.threadDictionary[key] = newObject
19 | return newObject
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Extensions/UInt8+Assisstants.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UInt8+Byte.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by mefilt on 23.07.2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public func toByteArray(_ value: T) -> [UInt8] {
12 | var value = value
13 | return (withUnsafeBytes(of: &value) { Array($0) }).reversed()
14 | }
15 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Type/Runtime.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Runtime.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by Prokofev Ruslan on 10/08/2018.
6 | // Copyright © 2018 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public enum Runtime {
12 | public static func swizzle(for forClass: AnyClass, original: Selector, swizzled: Selector) {
13 | let originalMethod = class_getInstanceMethod(forClass, original)!
14 | let swizzledMethod = class_getInstanceMethod(forClass, swizzled)!
15 | method_exchangeImplementations(originalMethod, swizzledMethod)
16 | }
17 |
18 | public static func swizzleClass(for forClass: AnyClass, original: Selector, swizzled: Selector) {
19 | let originalMethod = class_getClassMethod(forClass, original)!
20 | let swizzledMethod = class_getClassMethod(forClass, swizzled)!
21 | method_exchangeImplementations(originalMethod, swizzledMethod)
22 | }
23 | }
24 |
25 | public struct Swizzle {
26 |
27 | public typealias Initializer = (() -> Void)
28 | public let initializers: [Initializer]
29 |
30 | public init(initializers: [Initializer]) {
31 | self.initializers = initializers
32 | }
33 |
34 | public func start() {
35 | initializers.forEach { call in
36 | call()
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Type/SweetLogger/SweetLoggerConsole.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SweetLoggerConsole.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by rprokofev on 27/02/2019.
6 | // Copyright © 2019 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public final class SweetLoggerConsole: SweetLoggerProtocol {
12 |
13 | public var visibleLevels: [SweetLoggerLevel]
14 |
15 | public var isShortLog = true
16 |
17 | public init(visibleLevels: [SweetLoggerLevel],
18 | isShortLog: Bool) {
19 |
20 | self.visibleLevels = visibleLevels
21 | self.isShortLog = isShortLog
22 | }
23 |
24 | public func send(message: @escaping @autoclosure () -> Any,
25 | level: SweetLoggerLevel,
26 | file: String,
27 | function: String,
28 | line: Int,
29 | context: Any?,
30 | type: Any.Type? = nil)
31 | {
32 | guard visibleLevels.contains(level) == true else { return }
33 |
34 | var nameClass = ""
35 | if let type = type {
36 | nameClass = nameType(type)
37 | }
38 |
39 | let message = "\(level.nameLevel) \(nameClass) 👉 \(message()) 👈"
40 |
41 | DispatchQueue.main.async {
42 | print(message)
43 |
44 | if self.isShortLog {
45 | return
46 | }
47 | let fileLast = String(file.split(separator: "/").last ?? "")
48 | print(fileLast)
49 | print(line)
50 | print(function)
51 | }
52 | }
53 | }
54 |
55 | private extension SweetLoggerLevel {
56 |
57 | var nameLevel: String {
58 |
59 | switch self {
60 | case .debug:
61 | return "🐞 Debug:"
62 | case .error:
63 | return "‼️ Error:"
64 | case .info:
65 | return "🦄 Info:"
66 | case .verbose:
67 | return "🌈 Verbose"
68 | case .warning:
69 | return "🎯 Warning:"
70 | case .network:
71 | return "🛰 Network:"
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/WavesSDKExtensions/Sources/Type/SweetLogger/SweetLoggerProtocol.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SweetLoggerProtocol.swift
3 | // WavesWallet-iOS
4 | //
5 | // Created by rprokofev on 27/02/2019.
6 | // Copyright © 2019 Waves Platform. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public enum SweetLoggerLevel {
12 | case error
13 | case debug
14 | case warning
15 | case verbose
16 | case info
17 | case network
18 | }
19 |
20 | public protocol SweetLoggerProtocol {
21 |
22 | func send(message: @escaping @autoclosure () -> Any,
23 | level: SweetLoggerLevel,
24 | file: String,
25 | function: String,
26 | line: Int,
27 | context: Any?,
28 | type: Any.Type?)
29 |
30 | var visibleLevels: [SweetLoggerLevel] { get }
31 | }
32 |
--------------------------------------------------------------------------------
/WavesSDKTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WavesSDKTests/WavesServicesTest.swift:
--------------------------------------------------------------------------------
1 | //
2 | // WaveSDKTransactions.swift
3 | // WavesSDKTests
4 | //
5 | // Created by rprokofev on 28.06.2019.
6 | // Copyright © 2019 Waves. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import XCTest
11 | import WavesSDK
12 | import WavesSDKCrypto
13 | import WavesSDKExtensions
14 |
15 | class WavesServicesTest: XCTestCase {
16 |
17 | var chainId: UInt8!
18 | var seed: String!
19 | var address: String!
20 | var senderPublicKey: String!
21 |
22 | override func setUp() {
23 |
24 | SweetLogger.current.add(plugins: [SweetLoggerConsole(visibleLevels: [.network, .error], isShortLog: false)])
25 | SweetLogger.current.visibleLevels = [.network, .error]
26 |
27 | WavesSDK.initialization(servicesPlugins: .init(data: [],
28 | node: [],
29 | matcher: []),
30 | enviroment: .init(server: .testNet, timestampServerDiff: 0))
31 |
32 | //TODO: Loading Seed
33 | self.seed = "great ivory wealth decide crowd devote fiction wool net ethics dog hurry cost aunt daring"
34 |
35 | guard let chainId = WavesSDK.shared.enviroment.chainId else { return }
36 | guard let address = WavesCrypto.shared.address(seed: seed, chainId: chainId) else { return }
37 | guard let senderPublicKey = WavesCrypto.shared.publicKey(seed: seed) else { return }
38 |
39 | self.chainId = chainId
40 | self.address = address
41 | self.senderPublicKey = senderPublicKey
42 | }
43 |
44 | override func tearDown() {}
45 |
46 | }
47 |
--------------------------------------------------------------------------------