Skip to content

Commit

Permalink
feat: ledger shielded accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjasiuk committed Jan 21, 2025
1 parent 278292b commit dee92ad
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 18 deletions.
7 changes: 2 additions & 5 deletions apps/extension/src/App/Accounts/ParentAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
KeyListItem,
Stack,
} from "@namada/components";
import { AccountType, DerivedAccount } from "@namada/types";
import { DerivedAccount } from "@namada/types";
import { ParentAccountsFooter } from "App/Accounts/ParentAccountsFooter";
import { PageHeader } from "App/Common";
import routes from "App/routes";
Expand All @@ -27,14 +27,11 @@ export const ParentAccounts = (): JSX.Element => {
accounts: allAccounts,
changeActiveAccountId,
} = useContext(AccountContext);

// We check which accounts need to be re-imported
const accounts = allAccounts
.filter((account) => account.parentId)
.map((account) => {
const outdated =
account.type !== AccountType.Ledger &&
typeof account.pseudoExtendedKey === "undefined";
const outdated = typeof account.pseudoExtendedKey === "undefined";

const parent = parentAccounts.find((pa) => pa.id === account.parentId);
invariant(parent, `Parent account not found for account ${account.id}`);
Expand Down
4 changes: 2 additions & 2 deletions apps/extension/src/Setup/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export const Setup: React.FC = () => {

const prettyAccountSecret =
accountSecret.t === "Mnemonic" ? "mnemonic"
: accountSecret.t === "PrivateKey" ? "private key"
: assertNever(accountSecret);
: accountSecret.t === "PrivateKey" ? "private key"
: assertNever(accountSecret);
setCompletionStatusInfo(`Encrypting and storing ${prettyAccountSecret}.`);

// Create parent account
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/Setup/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DeriveAccountDetails, LedgerAccountDetails } from "./types";

// Wrap account management calls with extension requester instance
export class AccountManager {
constructor(private readonly requester: ExtensionRequester) {}
constructor(private readonly requester: ExtensionRequester) { }

/**
* Set password for the extension
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/background/keyring/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const handleQueryAccountsMsg: (
const output =
query && query.accountId ?
await service.queryAccountsByParentId(query.accountId)
: await service.queryAccounts();
: await service.queryAccounts();

return output;
};
Expand Down
8 changes: 4 additions & 4 deletions apps/extension/src/background/keyring/keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class KeyRing {
protected readonly sdkService: SdkService,
protected readonly utilityStore: KVStore<UtilityStore>,
protected readonly localStorage: LocalStorage
) {}
) { }

public get status(): KeyRingStatus {
return this._status;
Expand Down Expand Up @@ -463,7 +463,7 @@ export class KeyRing {
const deriveFn = (
type === AccountType.PrivateKey ?
this.deriveTransparentAccount
: this.deriveShieldedAccount).bind(this);
: this.deriveShieldedAccount).bind(this);

const { secret } = await this.getParentSecret(parentId);
const info = deriveFn(secret, derivationPath, parentAccount);
Expand Down Expand Up @@ -746,13 +746,13 @@ export class KeyRing {
const key =
disposableKey ?
disposableKey.privateKey
: await this.getSigningKey(signer);
: await this.getSigningKey(signer);

// If disposable key is provided, use it to map real address to spending key
const spendingKeys =
disposableKey ?
[await this.getSpendingKey(disposableKey.realAddress)]
: [];
: [];

const { signing } = this.sdkService.getSdk();

Expand Down
1 change: 1 addition & 0 deletions apps/namadillo/src/App/Ibc/IbcTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const IbcTransfer = (): JSX.Element => {
walletAddress: sourceAddress,
})
);
console.log("userAssets", userAssets);

// Local State
const [shielded, setShielded] = useState<boolean>(true);
Expand Down
2 changes: 1 addition & 1 deletion apps/namadillo/src/App/NamadaTransfer/NamadaTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const NamadaTransfer: React.FC = () => {
const account = defaultAccounts.data?.find((account) =>
shielded ?
account.type === AccountType.ShieldedKeys
: account.type !== AccountType.ShieldedKeys
: account.type !== AccountType.ShieldedKeys
);
const sourceAddress = account?.address;
const selectedAssetAddress = searchParams.get(params.asset) || undefined;
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Ledger {
/**
* @param namadaApp - Inititalized NamadaApp class from Zondax package
*/
private constructor(public readonly namadaApp: NamadaApp) {}
private constructor(public readonly namadaApp: NamadaApp) { }

/**
* Initialize and return Ledger class instance with initialized Transport
Expand Down Expand Up @@ -255,7 +255,7 @@ export class Ledger {
* Check if Zip32 is supported by the installed app's version.
* Throws error if app is not initialized
* @async
* @retuns boolean
* @returns boolean
*/
public async isZip32Supported(): Promise<boolean> {
const {
Expand All @@ -277,7 +277,7 @@ export class Ledger {
} = await this.status();
throw new Error(
`This method requires Zip32 and is unsupported in ${appVersion}! ` +
`Please update to at least ${LEDGER_MIN_VERSION_ZIP32}!`
`Please update to at least ${LEDGER_MIN_VERSION_ZIP32}!`
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Sdk {
public readonly cryptoMemory: WebAssembly.Memory,
public readonly url: string,
public readonly nativeToken: string
) {}
) { }

/**
* Re-initialize wasm instances and return this instance
Expand Down

0 comments on commit dee92ad

Please sign in to comment.