Skip to content

Commit

Permalink
Merge pull request #62 from novasamatech/feature/extrinsic-builder-up…
Browse files Browse the repository at this point in the history
…date
  • Loading branch information
svojsu authored Aug 19, 2024
2 parents c2cac50 + 46976c9 commit db0ffc2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PODS:
- scrypt.c (0.1.1)
- secp256k1.c (0.1.2)
- Starscream (4.0.4)
- SubstrateSdk (3.2.1):
- SubstrateSdk (3.2.2):
- BigInt (~> 5.0)
- IrohaCrypto/ed25519 (~> 0.9.0)
- IrohaCrypto/Scrypt (~> 0.9.0)
Expand Down Expand Up @@ -87,7 +87,7 @@ SPEC CHECKSUMS:
scrypt.c: b42ae06183251329d2b2c620c226fb541a4a3592
secp256k1.c: db47b726585d80f027423682eb369729e61b3b20
Starscream: 5178aed56b316f13fa3bc55694e583d35dd414d9
SubstrateSdk: fe20689ad3f1bc680318a338c9e7dcde53e9c36b
SubstrateSdk: bc3da50e8e44ebb67e54fb20d5938a91ed85fc3c
SwiftLint: 4fa9579c63416865179bc416f0a92d55f009600d
TweetNacl: 3abf4d1d2082b0114e7a67410e300892448951e6
xxHash-Swift: 30bd6a7507b3b7348a277c49b1cb6346c2905ec7
Expand Down
2 changes: 1 addition & 1 deletion SubstrateSdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'SubstrateSdk'
s.version = '3.2.1'
s.version = '3.2.2'
s.summary = 'Utility library that implements clients specific logic to interact with substrate based networks'

s.homepage = 'https://github.com/nova-wallet/substrate-sdk-ios'
Expand Down
13 changes: 13 additions & 0 deletions SubstrateSdk/Classes/Extrinsic/ExtrinsicBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public protocol ExtrinsicBuilderProtocol: AnyObject {
func with(runtimeJsonContext: RuntimeJsonContext) -> Self
func with(signaturePayloadFormat: ExtrinsicSignaturePayloadFormat) -> Self
func adding<T: RuntimeCallable>(call: T) throws -> Self
func adding<T: RuntimeCallable>(call: T, at index: Int) throws -> Self
func adding(rawCall: Data) throws -> Self
func adding(extrinsicSignedExtension: ExtrinsicSignedExtending) -> Self
func wrappingCalls(for mapClosure: (JSON) throws -> JSON) throws -> Self
Expand Down Expand Up @@ -61,6 +62,7 @@ public enum ExtrinsicBuilderError: Error {
case missingAddress
case unsupportedSignedExtension(_ value: String)
case unsupportedBatch
case indexOutOfBounds
}

public class ExtrinsicBuilder {
Expand Down Expand Up @@ -329,6 +331,17 @@ extension ExtrinsicBuilder: ExtrinsicBuilderProtocol {

return self
}

public func adding<T: RuntimeCallable>(call: T, at index: Int) throws -> Self {
guard index <= calls.count else {
throw ExtrinsicBuilderError.indexOutOfBounds
}

let json = try call.toScaleCompatibleJSON(with: runtimeJsonContext?.toRawContext())
calls.insert(json, at: index)

return self
}

public func adding(rawCall: Data) throws -> Self {
let json = JSON.stringValue(rawCall.toHex())
Expand Down

0 comments on commit db0ffc2

Please sign in to comment.