-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #479 from nova-wallet/fix/gov1-and-xcm
Governance improvements
- Loading branch information
Showing
43 changed files
with
1,074 additions
and
413 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
|
||
extension Data { | ||
func fillRightWithZeros(ifLess size: Int) -> Data { | ||
guard count < size else { | ||
return self | ||
} | ||
|
||
let neededZeros = size - count | ||
|
||
return self + Data(repeating: 0, count: neededZeros) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
novawallet/Common/Extension/SubstrateSdk/CallMetadata+TypeCheck.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Foundation | ||
import SubstrateSdk | ||
|
||
extension CallMetadata { | ||
func isArgumentTypeOf(_ name: String, closure: (String) -> Bool) -> Bool { | ||
guard let argument = arguments.first(where: { $0.name == name }) else { | ||
return false | ||
} | ||
|
||
return closure(argument.type) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
novawallet/Common/Extension/SubstrateSdk/CodingFactory+TypeCheck.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Foundation | ||
import SubstrateSdk | ||
|
||
extension RuntimeCoderFactoryProtocol { | ||
func isBytesArrayType(_ type: String) -> Bool { | ||
guard let vectorNode = getTypeNode(for: type) as? VectorNode else { | ||
return false | ||
} | ||
|
||
return getTypeNode(for: vectorNode.underlying.typeName) is U8Node | ||
} | ||
|
||
func isUInt64Type(_ type: String) -> Bool { | ||
getTypeNode(for: type) is U64Node | ||
} | ||
|
||
func isStructHasFieldsCount(_ type: String, count: Int) -> Bool { | ||
guard let structNode = getTypeNode(for: type) as? StructNode else { | ||
return false | ||
} | ||
|
||
return structNode.typeMapping.count == count | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
novawallet/Common/Extension/SubstrateSdk/StorageEntryMetadata+TypeCheck.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Foundation | ||
import SubstrateSdk | ||
|
||
extension RuntimeMetadataProtocol { | ||
func isMapStorageKeyOfType(_ storagePath: StorageCodingPath, closure: (String) -> Bool) -> Bool { | ||
guard let storage = getStorageMetadata( | ||
in: storagePath.moduleName, | ||
storageName: storagePath.itemName | ||
) else { | ||
return false | ||
} | ||
|
||
return storage.isMapKeyOfType(closure) | ||
} | ||
} | ||
|
||
extension StorageEntryMetadata { | ||
func isMapKeyOfType(_ closure: (String) -> Bool) -> Bool { | ||
switch type { | ||
case let .map(entry): | ||
return closure(entry.key) | ||
default: | ||
return false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.