Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions copy-builtin-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const communityModules = [{ path: path.join(rootdir, 'node_modules/@airgap-commu

function createAirGapModule(module) {
const packageJson = require(`./${path.join(module.path, 'package.json')}`)
const namespace = module.path.split('/').slice(-1)[0]
const namespace = path.basename(module.path)
const outputDir = path.join(assetsdir, `protocol_modules/${namespace}`)
const outputFile = 'index.browserify.js'

Expand All @@ -84,7 +84,8 @@ function createAirGapModule(module) {
}

function copyCommunityModule(module) {
const namespace = module.path.split('/').slice(-1)[0]
console.log('MODULE PATH:', module.path)
const namespace = path.basename(module.path)
const outputDir = path.join(assetsdir, `protocol_modules/${namespace}`)

fs.mkdirSync(outputDir, { recursive: true })
Expand Down
9 changes: 9 additions & 0 deletions src/app/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,12 @@ pre {
.transparent {
--background: none transparent !important;
}

airgap-account-item ion-label div {
display: block !important;
}

airgap-account-item ion-label div p {
text-align: left;
margin-left: 0;
}
11 changes: 11 additions & 0 deletions src/app/pages/account-add/account-add.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ <h2>
<ion-checkbox [(ngModel)]="singleSelectedProtocol.isHDWallet" (ionChange)="toggleHDWallet()" slot="end"></ion-checkbox>
</ion-item>

<ion-item class="ion-no-padding" lines="full">
<ion-label position="stacked" color="primary">
Nome da conta
</ion-label>

<ion-input
[(ngModel)]="accountLabel"
placeholder="Ex.: Carteira 10"
></ion-input>
</ion-item>

<ng-container *ngIf="isBip39PassphraseEnabled">
<ion-item class="ion-no-padding" *ngIf="isBip39PassphraseEnabled" lines="full">
<ion-label position="stacked" color="primary">BIP-39 Passphrase</ion-label>
Expand Down
14 changes: 8 additions & 6 deletions src/app/pages/account-add/account-add.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class AccountAddPage {
public isBip39PassphraseEnabled: boolean = BIP39_PASSPHRASE_ENABLED
public revealBip39Passphrase: boolean = false
public bip39Passphrase: string = ''
public accountLabel: string = ''

public isAppAdvancedMode$: Observable<boolean> = this.storageService
.subscribe(VaultStorageKey.ADVANCED_MODE_TYPE)
Expand Down Expand Up @@ -182,12 +183,13 @@ export class AccountAddPage {
selectedProtocols.map(async (protocolWrapper: ProtocolWrapper) => {
const protocol = protocolWrapper.protocol
return {
protocolIdentifier: await protocol.getIdentifier(),
isHDWallet: protocolWrapper.isHDWallet,
customDerivationPath: protocolWrapper.customDerivationPath ?? (await protocol.getStandardDerivationPath()),
bip39Passphrase: this.bip39Passphrase,
isActive: true
}
protocolIdentifier: await protocol.getIdentifier(),
isHDWallet: protocolWrapper.isHDWallet,
customDerivationPath: protocolWrapper.customDerivationPath ?? (await protocol.getStandardDerivationPath()),
bip39Passphrase: this.bip39Passphrase,
isActive: true,
label: this.accountLabel
}
})
)
)
Expand Down
16 changes: 13 additions & 3 deletions src/app/pages/account-address/account-address.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@ <h2 class="ion-no-margin">{{ protocolName }} {{ protocolSymbol }}</h2>
<span class="selectable typography--mono">{{ wallet.derivationPath }}</span>
</p>
<p *ngIf="isAppAdvancedMode$ | async">
<ion-chip color="light" *ngIf="wallet.isExtendedPublicKey">HD Wallet</ion-chip>
<ion-chip color="light" *ngIf="secret.fingerprint !== wallet.masterFingerprint">BIP39 passphrase</ion-chip>
</p>
<ion-chip color="light" *ngIf="wallet.isExtendedPublicKey">
HD Wallet
</ion-chip>

<ion-chip color="light" *ngIf="wallet.masterFingerprint">
Master Fingerprint:
{{ wallet.masterFingerprint }}
</ion-chip>

<ion-chip color="light" *ngIf="secret.fingerprint !== wallet.masterFingerprint">
BIP39 Passphrase
</ion-chip>
</p>
</ion-col>
</ion-row>

Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/accounts-list/accounts-list.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
<ng-container *ngIf="deleteView">
<ion-item>
<ion-checkbox slot="start" (ionChange)="onWalletSelected($event, wallet)"></ion-checkbox>
<airgap-account-item [wallet]="wallet" (click)="goToReceiveAddress(wallet)"></airgap-account-item>
<airgap-account-item [wallet]="wallet" [label]="wallet.label" (click)="goToReceiveAddress(wallet)"></airgap-account-item>
</ion-item>
</ng-container>

<ng-container *ngIf="!deleteView">
<airgap-account-item [wallet]="wallet" (click)="goToReceiveAddress(wallet)"></airgap-account-item>
<airgap-account-item [wallet]="wallet" [label]="wallet.label" (click)="goToReceiveAddress(wallet)"></airgap-account-item>
</ng-container>
<ion-item-options side="end">
<ion-item-option (click)="delete(wallet)">
Expand Down
1 change: 1 addition & 0 deletions src/app/services/iac/iac.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ export class IACService extends BaseIACService {
baseWallet.status
)
correctWallet.addresses = baseWallet.addresses
correctWallet.label = baseWallet.label
} catch (e) {
if (e.message === 'PROTOCOL_NOT_SUPPORTED') {
correctWallet = baseWallet
Expand Down
27 changes: 23 additions & 4 deletions src/app/services/secrets/secrets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
customDerivationPath: string
bip39Passphrase: string
isActive: boolean
label?: string
}
@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -125,6 +126,8 @@
serializedWallet.status ?? AirGapWalletStatus.ACTIVE
)
airGapWallet.addresses = serializedWallet.addresses
airGapWallet.label = serializedWallet.label

return airGapWallet
})
)
Expand Down Expand Up @@ -299,12 +302,12 @@
if (isBtc) {
// BTC protocols: Always HD, increment account index
const lastIndices = existingWallets.map((wallet) => {
const match = wallet.derivationPath.match(/(\d+)[h']?\/?$/)

Check warning on line 305 in src/app/services/secrets/secrets.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Simplify this regular expression to reduce its runtime, as it has super-linear performance due to backtracking.

See more on https://sonarcloud.io/project/issues?id=airgap-it_airgap-vault&issues=AZ9LqjMYl4MEWjVrJK4N&open=AZ9LqjMYl4MEWjVrJK4N&pullRequest=297
return match ? parseInt(match[1], 10) : 0
})
const maxIndex = Math.max(...lastIndices)
const nextIndex = maxIndex + 1
const newPath = standardPath.replace(/(\d+)([h']?)(\/?)?$/, `${nextIndex}$2$3`)

Check warning on line 310 in src/app/services/secrets/secrets.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Simplify this regular expression to reduce its runtime, as it has super-linear performance due to backtracking.

See more on https://sonarcloud.io/project/issues?id=airgap-it_airgap-vault&issues=AZ9LqjMYl4MEWjVrJK4O&open=AZ9LqjMYl4MEWjVrJK4O&pullRequest=297
return { derivationPath: newPath, isHDWallet: true }
} else if (supportsHD) {
// HD-capable protocols (ETH, OP, etc.): First is HD, subsequent are non-HD
Expand All @@ -325,12 +328,12 @@
// Non-HD protocols: Increment last number in path
// e.g., m/44h/1729h/0h/0h -> m/44h/1729h/0h/1h
const lastIndices = existingWallets.map((wallet) => {
const match = wallet.derivationPath.match(/(\d+)[h']?\/?$/)

Check warning on line 331 in src/app/services/secrets/secrets.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Simplify this regular expression to reduce its runtime, as it has super-linear performance due to backtracking.

See more on https://sonarcloud.io/project/issues?id=airgap-it_airgap-vault&issues=AZ9LqjMYl4MEWjVrJK4P&open=AZ9LqjMYl4MEWjVrJK4P&pullRequest=297
return match ? parseInt(match[1], 10) : 0
})
const maxIndex = Math.max(...lastIndices)
const nextIndex = maxIndex + 1
const newPath = standardPath.replace(/(\d+)([h']?)(\/?)?$/, `${nextIndex}$2$3`)

Check warning on line 336 in src/app/services/secrets/secrets.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Simplify this regular expression to reduce its runtime, as it has super-linear performance due to backtracking.

See more on https://sonarcloud.io/project/issues?id=airgap-it_airgap-vault&issues=AZ9LqjMYl4MEWjVrJK4Q&open=AZ9LqjMYl4MEWjVrJK4Q&pullRequest=297
return { derivationPath: newPath, isHDWallet: false }
}
}
Expand Down Expand Up @@ -494,8 +497,12 @@
if (storedSecret === undefined) {
return secret
}
const wallets: SerializedAirGapWallet[] = await Promise.all(secret.wallets.slice(0).map((wallet: AirGapWallet) => wallet.toJSON()))
for (let i = 0; i < storedSecret.wallets.length; ++i) {

const wallets: SerializedAirGapWallet[] = await Promise.all(
secret.wallets.slice(0).map((wallet: AirGapWallet) => wallet.toJSON())
)

for (let i = 0; i < storedSecret.wallets.length; ++i) {
const serializedWallet = storedSecret.wallets[i] as unknown as SerializedAirGapWallet

const filtered: (AirGapWallet | SerializedAirGapWallet | undefined)[] = await Promise.all(
Expand All @@ -513,9 +520,20 @@
wallets.push(serializedWallet)
}
}

const result = MnemonicSecret.init(secret)
result.wallets = wallets as unknown as AirGapWallet[]
return result
result.wallets = wallets.map((wallet: SerializedAirGapWallet) => {
const original = secret.wallets.find(
(w) => w.publicKey === wallet.publicKey
)

return {
...wallet,
label: original?.label ?? wallet.label ?? ''
} as unknown as AirGapWallet
})

return result
})
)

Expand Down Expand Up @@ -624,6 +642,7 @@

const addresses: string[] = await wallet.deriveAddresses(1)
wallet.addresses = addresses
wallet.label = config.label

return wallet
}
Expand Down