-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add derivation path to metadata
- Loading branch information
Showing
4 changed files
with
29 additions
and
28 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -249,7 +249,7 @@ class WalletCacheServiceTests: XCTestCase { | |
func testMetadata() { | ||
let mainentDomain = [TezosDomainsReverseRecord(id: "123", address: "tz1abc123", owner: "tz1abc123", expiresAtUtc: nil, domain: TezosDomainsDomain(name: "blah.tez", address: "tz1abc123"))] | ||
let ghostnetDomain = [TezosDomainsReverseRecord(id: "123", address: "tz1abc123", owner: "tz1abc123", expiresAtUtc: nil, domain: TezosDomainsDomain(name: "blah.gho", address: "tz1abc123"))] | ||
let metadata1 = WalletMetadata(address: "tz1abc123", hdWalletGroupName: nil, mainnetDomains: mainentDomain, ghostnetDomains: ghostnetDomain, type: .hd, children: [], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true, customDerivationPath: nil) | ||
let metadata1 = WalletMetadata(address: "tz1abc123", derivationPath: nil, hdWalletGroupName: nil, mainnetDomains: mainentDomain, ghostnetDomains: ghostnetDomain, type: .hd, children: [], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true) | ||
|
||
XCTAssert(metadata1.hasMainnetDomain()) | ||
XCTAssert(metadata1.hasGhostnetDomain()) | ||
|
@@ -264,7 +264,7 @@ class WalletCacheServiceTests: XCTestCase { | |
|
||
|
||
|
||
let metadata2 = WalletMetadata(address: "tz1def456", hdWalletGroupName: nil, type: .hd, children: [], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true, customDerivationPath: nil) | ||
let metadata2 = WalletMetadata(address: "tz1def456", derivationPath: nil, hdWalletGroupName: nil, type: .hd, children: [], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true) | ||
|
||
XCTAssert(!metadata2.hasMainnetDomain()) | ||
XCTAssert(!metadata2.hasGhostnetDomain()) | ||
|
@@ -273,20 +273,20 @@ class WalletCacheServiceTests: XCTestCase { | |
func testMetadataList() { | ||
let mainentDomain = TezosDomainsReverseRecord(id: "123", address: "tz1abc123", owner: "tz1abc123", expiresAtUtc: nil, domain: TezosDomainsDomain(name: "blah.tez", address: "tz1abc123")) | ||
let ghostnetDomain = TezosDomainsReverseRecord(id: "123", address: "tz1abc123", owner: "tz1abc123", expiresAtUtc: nil, domain: TezosDomainsDomain(name: "blah.gho", address: "tz1abc123")) | ||
let child = WalletMetadata(address: "tz1child", hdWalletGroupName: nil, type: .hd, children: [], isChild: true, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true, customDerivationPath: nil) | ||
let updatedWatch = WalletMetadata(address: "tz1jkl", hdWalletGroupName: nil, mainnetDomains: [], ghostnetDomains: [], type: .hd, children: [], isChild: false, isWatchOnly: true, bas58EncodedPublicKey: "blah", backedUp: true, customDerivationPath: nil) | ||
let child = WalletMetadata(address: "tz1child", derivationPath: nil, hdWalletGroupName: nil, type: .hd, children: [], isChild: true, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true) | ||
let updatedWatch = WalletMetadata(address: "tz1jkl", derivationPath: nil, hdWalletGroupName: nil, mainnetDomains: [], ghostnetDomains: [], type: .hd, children: [], isChild: false, isWatchOnly: true, bas58EncodedPublicKey: "blah", backedUp: true) | ||
|
||
let hd: [WalletMetadata] = [ | ||
WalletMetadata(address: "tz1abc123", hdWalletGroupName: nil, mainnetDomains: [], ghostnetDomains: [], type: .hd, children: [child], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true, customDerivationPath: nil) | ||
WalletMetadata(address: "tz1abc123", derivationPath: nil, hdWalletGroupName: nil, mainnetDomains: [], ghostnetDomains: [], type: .hd, children: [child], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true) | ||
] | ||
let social: [WalletMetadata] = [ | ||
WalletMetadata(address: "tz1def", hdWalletGroupName: nil, socialUsername: "[email protected]", socialType: .google, type: .social, children: [], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true, customDerivationPath: nil) | ||
WalletMetadata(address: "tz1def", derivationPath: nil, hdWalletGroupName: nil, socialUsername: "[email protected]", socialType: .google, type: .social, children: [], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true) | ||
] | ||
let linear: [WalletMetadata] = [ | ||
WalletMetadata(address: "tz1ghi", hdWalletGroupName: nil, type: .regular, children: [], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true, customDerivationPath: nil) | ||
WalletMetadata(address: "tz1ghi", derivationPath: nil, hdWalletGroupName: nil, type: .regular, children: [], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true) | ||
] | ||
let watch: [WalletMetadata] = [ | ||
WalletMetadata(address: "tz1jkl", hdWalletGroupName: nil, type: .hd, children: [], isChild: false, isWatchOnly: true, bas58EncodedPublicKey: "", backedUp: true, customDerivationPath: nil) | ||
WalletMetadata(address: "tz1jkl", derivationPath: nil, hdWalletGroupName: nil, type: .hd, children: [], isChild: false, isWatchOnly: true, bas58EncodedPublicKey: "", backedUp: true) | ||
] | ||
|
||
let list = WalletMetadataList(socialWallets: social, hdWallets: hd, linearWallets: linear, ledgerWallets: [], watchWallets: watch) | ||
|
@@ -333,7 +333,7 @@ class WalletCacheServiceTests: XCTestCase { | |
func testWatchWallet() { | ||
XCTAssert(walletCacheService.deleteAllCacheAndKeys()) | ||
|
||
let watchWallet = WalletMetadata(address: "tz1jkl", hdWalletGroupName: nil, mainnetDomains: [], ghostnetDomains: [], type: .hd, children: [], isChild: false, isWatchOnly: true, bas58EncodedPublicKey: "", backedUp: true, customDerivationPath: nil) | ||
let watchWallet = WalletMetadata(address: "tz1jkl", derivationPath: nil, hdWalletGroupName: nil, mainnetDomains: [], ghostnetDomains: [], type: .hd, children: [], isChild: false, isWatchOnly: true, bas58EncodedPublicKey: "", backedUp: true) | ||
|
||
do { | ||
try walletCacheService.cacheWatchWallet(metadata: watchWallet) | ||
|
@@ -354,7 +354,7 @@ class WalletCacheServiceTests: XCTestCase { | |
XCTFail("Should not error: \(error)") | ||
} | ||
|
||
let watchWallet = WalletMetadata(address: MockConstants.defaultLinearWallet.address, hdWalletGroupName: nil, mainnetDomains: [], ghostnetDomains: [], type: .hd, children: [], isChild: false, isWatchOnly: true, bas58EncodedPublicKey: "", backedUp: true, customDerivationPath: nil) | ||
let watchWallet = WalletMetadata(address: MockConstants.defaultLinearWallet.address, derivationPath: nil, hdWalletGroupName: nil, mainnetDomains: [], ghostnetDomains: [], type: .hd, children: [], isChild: false, isWatchOnly: true, bas58EncodedPublicKey: "", backedUp: true) | ||
|
||
do { | ||
try walletCacheService.cacheWatchWallet(metadata: watchWallet) | ||
|
@@ -368,7 +368,7 @@ class WalletCacheServiceTests: XCTestCase { | |
XCTAssert(walletCacheService.deleteAllCacheAndKeys()) | ||
|
||
// Add watch and confirm | ||
let watchWallet = WalletMetadata(address: MockConstants.defaultLinearWallet.address, hdWalletGroupName: nil, mainnetDomains: [], ghostnetDomains: [], type: .hd, children: [], isChild: false, isWatchOnly: true, bas58EncodedPublicKey: "", backedUp: true, customDerivationPath: nil) | ||
let watchWallet = WalletMetadata(address: MockConstants.defaultLinearWallet.address, derivationPath: nil, hdWalletGroupName: nil, mainnetDomains: [], ghostnetDomains: [], type: .hd, children: [], isChild: false, isWatchOnly: true, bas58EncodedPublicKey: "", backedUp: true) | ||
|
||
do { | ||
try walletCacheService.cacheWatchWallet(metadata: watchWallet) | ||
|
@@ -403,14 +403,13 @@ class WalletCacheServiceTests: XCTestCase { | |
try walletCacheService.cache(wallet: ledgerWallet, childOfIndex: nil, backedUp: true) | ||
try walletCacheService.cache(wallet: ledgerWalletChild1, childOfIndex: 0, backedUp: true) | ||
try walletCacheService.cache(wallet: ledgerWalletChild2, childOfIndex: 0, backedUp: true) | ||
try walletCacheService.cache(wallet: ledgerWalletChild3, childOfIndex: 0, backedUp: true, customDerivationPath: ledgerWalletChild3.derivationPath) | ||
try walletCacheService.cache(wallet: ledgerWalletChild3, childOfIndex: 0, backedUp: true) | ||
|
||
let list1 = walletCacheService.readMetadataFromDiskAndDecrypt() | ||
let ledgers1 = list1.ledgerWallets | ||
let excludedCount = ledgers1[0].childCountExcludingCustomDerivationPaths() | ||
XCTAssert(ledgers1.count == 1, ledgers1.count.description) | ||
XCTAssert(ledgers1[0].children.count == 3, ledgers1[0].children.count.description) | ||
XCTAssert(excludedCount == 2, excludedCount.description) | ||
XCTAssert(ledgers1[0].children.last?.derivationPath == "m/44'/1729'/147'/62'", ledgers1[0].children.last?.derivationPath ?? "-") | ||
|
||
|
||
let _ = WalletCacheService().deleteWallet(withAddress: "tz1abc", parentIndex: nil) | ||
|