diff --git a/Example/Podfile.lock b/Example/Podfile.lock index f4b146c..2e41ddb 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -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) @@ -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 diff --git a/SubstrateSdk.podspec b/SubstrateSdk.podspec index db66738..962cc2d 100644 --- a/SubstrateSdk.podspec +++ b/SubstrateSdk.podspec @@ -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' diff --git a/SubstrateSdk/Classes/Extrinsic/ExtrinsicBuilder.swift b/SubstrateSdk/Classes/Extrinsic/ExtrinsicBuilder.swift index c93eb4d..3a8a23d 100644 --- a/SubstrateSdk/Classes/Extrinsic/ExtrinsicBuilder.swift +++ b/SubstrateSdk/Classes/Extrinsic/ExtrinsicBuilder.swift @@ -12,6 +12,7 @@ public protocol ExtrinsicBuilderProtocol: AnyObject { func with(runtimeJsonContext: RuntimeJsonContext) -> Self func with(signaturePayloadFormat: ExtrinsicSignaturePayloadFormat) -> Self func adding(call: T) throws -> Self + func adding(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 @@ -61,6 +62,7 @@ public enum ExtrinsicBuilderError: Error { case missingAddress case unsupportedSignedExtension(_ value: String) case unsupportedBatch + case indexOutOfBounds } public class ExtrinsicBuilder { @@ -329,6 +331,17 @@ extension ExtrinsicBuilder: ExtrinsicBuilderProtocol { return self } + + public func adding(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())