Skip to content

Commit

Permalink
Merge pull request #30 from nova-wallet/feature/batch-fallback
Browse files Browse the repository at this point in the history
Add fallback to alternative batch name
  • Loading branch information
ERussel authored Oct 10, 2022
2 parents 2fadfd8 + 3e3b832 commit 2714b4c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
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 = '1.4.1'
s.version = '1.5.0'
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
14 changes: 12 additions & 2 deletions SubstrateSdk/Classes/Extrinsic/ExtrinsicBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,19 @@ public class ExtrinsicBuilder {
return calls[0]
}

let callName = shouldUseAtomicBatch ? KnowRuntimeModule.Utitlity.batchAll : KnowRuntimeModule.Utitlity.batch
let callName: String

if shouldUseAtomicBatch {
if metadata.getCall(from: KnowRuntimeModule.Utility.name, with: KnowRuntimeModule.Utility.batchAll) != nil {
callName = KnowRuntimeModule.Utility.batchAll
} else {
callName = KnowRuntimeModule.Utility.batchAtomic
}
} else {
callName = KnowRuntimeModule.Utility.batch
}

let call = RuntimeCall(moduleName: KnowRuntimeModule.Utitlity.name,
let call = RuntimeCall(moduleName: KnowRuntimeModule.Utility.name,
callName: callName,
args: BatchArgs(calls: calls))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Foundation

public struct KnowRuntimeModule {
public struct Utitlity {
public struct Utility {
public static let name = "Utility"
public static let batch = "batch"
public static let batchAll = "batch_all"
public static let batchAtomic = "batch_atomic"
}
}
8 changes: 4 additions & 4 deletions Tests/ExtrinsicBuilder/ExtrinsicBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class ExtrinsicBuilderTests: XCTestCase {
}

let expectedJsonCalls = try calls.toScaleCompatibleJSON()
let expectedCall = try RuntimeCall(moduleName: KnowRuntimeModule.Utitlity.name,
callName: KnowRuntimeModule.Utitlity.batch,
let expectedCall = try RuntimeCall(moduleName: KnowRuntimeModule.Utility.name,
callName: KnowRuntimeModule.Utility.batch,
args: BatchArgs(calls: expectedJsonCalls.arrayValue!))
.toScaleCompatibleJSON()

Expand Down Expand Up @@ -64,8 +64,8 @@ class ExtrinsicBuilderTests: XCTestCase {
}

let expectedJsonCalls = try calls.toScaleCompatibleJSON()
let expectedCall = try RuntimeCall(moduleName: KnowRuntimeModule.Utitlity.name,
callName: KnowRuntimeModule.Utitlity.batchAll,
let expectedCall = try RuntimeCall(moduleName: KnowRuntimeModule.Utility.name,
callName: KnowRuntimeModule.Utility.batchAll,
args: BatchArgs(calls: expectedJsonCalls.arrayValue!))
.toScaleCompatibleJSON()

Expand Down

0 comments on commit 2714b4c

Please sign in to comment.