-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove indirect KeyAgent dependency on ObservableWallet
1. KeyAgent depends on InputResolver, which in is implemented by a util that depends on ObservableWallet. Since ObservableWallet depends on KeyAgent, it makes it a circular dependency. It was worked around by having LazyWalletUtil and setupWallet utils. This commit replaces the KeyAgent->InputResolver dependency with an extra TxContext argument for signTransaction method, as well as removes the obsolete utils. 2. Addresses are stored by both KeyAgent and PersonalWallet. This commit consolidates address storage in PersonalWallet, making KeyAgent stateless and establishing single source of truth. Notes: - remove createAsyncKeyAgent tests instead of refactoring them, because AsyncKeyAgent is no longer required and should be removed. - extract address discovery and storage from PersonalWallet into a new AddressTracker component BREAKING CHANGE: remove KeyAgent.knownAddresses - remove AsyncKeyAgent.knownAddresses$ - remove LazyWalletUtil and setupWallet utils - replace KeyAgent dependency on InputResolver with props passed to sign method - re-purpose AddressManager to Bip32Account: addresses are now stored only by the wallet
- Loading branch information
1 parent
8a6db2a
commit 8dcfbc4
Showing
106 changed files
with
2,189 additions
and
2,561 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Bip32PublicKeyHex, SodiumBip32Ed25519 } from '@cardano-sdk/crypto'; | ||
import { Cardano } from '@cardano-sdk/core'; | ||
import { GroupedAddress, KeyAgent, KeyAgentType } from '@cardano-sdk/key-management'; | ||
|
||
const accountIndex = 0; | ||
const chainId = Cardano.ChainIds.Preview; | ||
const extendedAccountPublicKey = Bip32PublicKeyHex( | ||
'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' | ||
); | ||
|
||
export const createMockKeyAgent = (deriveAddressesReturn: GroupedAddress[] = []): jest.Mocked<KeyAgent> => { | ||
const remainingDeriveAddressesReturn = [...deriveAddressesReturn]; | ||
return { | ||
accountIndex, | ||
bip32Ed25519: new SodiumBip32Ed25519(), | ||
chainId, | ||
deriveAddress: jest.fn().mockImplementation(async () => remainingDeriveAddressesReturn.shift()), | ||
derivePublicKey: jest.fn(), | ||
exportRootPrivateKey: jest.fn(), | ||
extendedAccountPublicKey, | ||
serializableData: { | ||
__typename: KeyAgentType.InMemory, | ||
accountIndex, | ||
chainId, | ||
encryptedRootPrivateKeyBytes: [], | ||
extendedAccountPublicKey | ||
}, | ||
signBlob: jest.fn(), | ||
signTransaction: jest.fn() | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './StubKeyAgent'; | ||
export * from './createMockKeyAgent'; | ||
export * from './localNetworkChainId'; | ||
export * from './util'; | ||
export * from './handle-util'; |
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
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.