Skip to content

Commit

Permalink
Misc patches (#160)
Browse files Browse the repository at this point in the history
* try patch macos dylib issue

* try one dir level up

* patch

* assume dylib path ./ means src-tauri

* add all mac gmp libs

* update tauri rust deps

* ci build

* update libra-types

* bump version

* test release profile

* language

* creating file in wrong order.

* try patch macos dylib issue

* add all mac gmp libs

* update libra-types

* bump version

* language

* creating file in wrong order.

* update  to libra 6.9.0-rc.7

* patch cargo lock

* update cargo lock

* bump version

* update cargo.lock

* scaffold account deletion

* remove prepended 0s from account view

* patch

* patch account display

* format accounts

* patch transfer issues. Confirm migration can reuse old keys

* lint

* macOs replace vcpkg build libgmp for homebrew

* patch-ui issues in account creation
  • Loading branch information
0o-de-lally authored Nov 22, 2023
1 parent f7ec081 commit b4812a2
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 63 deletions.
Binary file modified src-tauri/libgmp.10.dylib
Binary file not shown.
Binary file modified src-tauri/libgmp.a
Binary file not shown.
Binary file modified src-tauri/libgmp.dylib
Binary file not shown.
Binary file modified src-tauri/libgmpxx.4.dylib
Binary file not shown.
Binary file modified src-tauri/libgmpxx.a
Binary file not shown.
Binary file modified src-tauri/libgmpxx.dylib
Binary file not shown.
28 changes: 5 additions & 23 deletions src-tauri/src/commands/wallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,28 +181,10 @@ pub async fn switch_profile(account: AccountAddress) -> Result<CarpeProfile, Car
#[tauri::command]
pub fn remove_accounts() -> Result<String, CarpeError> {
// Note: this only removes the account tracking, doesn't delete account on chain.
todo!()

// let db_path = configs::default_accounts_db_path();
// dbg!(&db_path);
// if db_path.exists() {
// match fs::remove_file(&db_path) {
// Ok(_) => return Ok("removed all accounts".to_owned()),
// _ => {
// return Err(CarpeError::misc(&format!(
// "unable to delete account file found at {:?}",
// &db_path
// )));
// }
// }
// }
// return Err(CarpeError::misc(
// &format!(
// "No accounts to remove. No account file found at {:?}",
// &db_path
// )
// .to_owned(),
// ));
let mut cfg = configs::get_cfg()?;
cfg.user_profiles = vec![];
cfg.save_file()?;
Ok("removed all accounts".to_owned())
}

pub fn danger_get_keys(mnemonic: String) -> Result<KeyChain, anyhow::Error> {
Expand All @@ -213,7 +195,7 @@ pub fn danger_get_keys(mnemonic: String) -> Result<KeyChain, anyhow::Error> {
fn get_short(acc: AccountAddress) -> String {
// let's check if this is a legacy/founder key, it will have 16 zeros at the start, and that's not a useful nickname
if acc.to_string()[..32] == *"00000000000000000000000000000000" {
return acc.to_string()[33..36].to_owned();
return acc.to_string()[32..35].to_owned();
}
acc.to_string()[..3].to_owned()
}
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.canary.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"package": {
"productName": "carpe-canary",
"version": "1.0.0-6"
"version": "1.0.0-7"
},
"build": {
"distDir": "../dist",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"package": {
"productName": "carpe",
"version": "1.0.0-6"
"version": "1.0.0-7"
},
"build": {
"distDir": "../dist",
Expand Down
6 changes: 4 additions & 2 deletions src/components/Nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import { Link, useLocation } from 'svelte-navigator'
import { _ } from '../lang/i18n'
import { routes } from '../modules/routes'
// import { init_preferences } from '../modules/preferences'
// views
import AccountSwitcher from './wallet/AccountSwitcher.svelte'
import { signingAccount } from '../modules/accounts'
// import MakeWholeLink from "./make-whole/MakeWholeLink.svelte";
// init_preferences()
Expand All @@ -29,6 +29,8 @@
><span class="uk-text-muted" uk-icon="icon: arrow-left; ratio: 2" /></Link
>
{/if}

{#if !$signingAccount}
<div class="uk-navbar-center">
<ul class="uk-navbar-nav uk-flex">
<li class="uk-padding {$location_store.pathname.includes('wallet') ? 'uk-active' : ''}">
Expand All @@ -46,7 +48,7 @@
<!--<li><MakeWholeLink /></li>-->
</ul>
</div>

{/if}
<!-- {#if $isInit} -->
<div class="uk-navbar-right">
<ul class="uk-navbar-nav">
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/AccountSettings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
invoke('remove_accounts', {})
.then((res: string) => {
responses.set(res)
notify_success('accounts removed successfully')
notify_success('Accounts removed successfully')
refreshAccounts()
})
.catch((e) => {
Expand Down
11 changes: 5 additions & 6 deletions src/components/txs/Transactions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { responses } from '../../modules/debug'
import { notify_success } from '../../modules/carpeNotify'
import { printUnscaledCoins, printCoins, unscaledCoins} from '../../modules/coinHelpers'
import { signingAccount } from '../../modules/accounts'
import { formatAccount, signingAccount } from '../../modules/accounts'
import type { CarpeProfile } from '../../modules/accounts'
import { raise_error } from '../../modules/carpeError'
Expand Down Expand Up @@ -37,7 +37,8 @@
let checkMessage = ''
$: isReceiverValid = account && receiver && re.test(receiver) && receiver != account.account;
$: isValidAmount = account && amount > 0 && amount < unscaledCoins(account.balance);
$: isValidAmount = account && amount > 0 && amount < unscaledCoins(account.balance.unlocked);
$: checkMessage = account && amount > unscaledCoins(account.balance)
? $_("txs.transfer.error_amount_greater_than_balance")
: receiver && receiver.toUpperCase() == account.account.toUpperCase()
Expand Down Expand Up @@ -106,7 +107,6 @@
</h2>
</div>
{#if account}
<!-- <div id="coinTransferDialog" uk-modal> -->
<div>
{#if waitingConfirmation}
<h2 class="uk-text-muted uk-text-uppercase">
Expand All @@ -115,7 +115,7 @@
<p>{$_('txs.transfer.please_confirm')}</p>
<p class="uk-text-uppercase">
{$_('txs.transfer.sender')}:
<span class="uk-text-bold">{account.account}</span>
<span class="uk-text-bold">{formatAccount(account.account)}</span>
</p>
<p class="uk-text-uppercase">
{$_('txs.transfer.receiver')}:
Expand All @@ -142,7 +142,7 @@
<div class="uk-width-3-4@s">
<label class="uk-form-label" for="sender-text">{$_('txs.transfer.sender')} </label>
<div>
{account.account}
{formatAccount(account.account)}
</div>
</div>
<div class="uk-width-1-4@s">
Expand Down Expand Up @@ -206,5 +206,4 @@
{/if}
</div>
{/if}
<!-- </div> -->
</main>
13 changes: 1 addition & 12 deletions src/components/wallet/AccountFromMnemSubmit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,10 @@
isSubmitting = true
addAccount(InitType.Mnem, mnem_string.trim())
.then(() => {
if (isNewAccount) {
// NOTE: this is for the keygen option, which shares this component
UIkit.modal('#submit-confirmation-modal').hide() // known bug https://github.com/uikit/uikit/issues/1370
}
})
.catch(() => {
if (isNewAccount) {
UIkit.modal('#submit-confirmation-modal').hide()
}
isSubmitting = false
})
.finally(() => {
isSubmitting = false
mnem_string = null
UIkit.modal('#submit-confirmation-modal').hide()
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/wallet/AccountsList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { _ } from 'svelte-i18n'
import UIkit from 'uikit'
import Icons from 'uikit/dist/js/uikit-icons'
import { allAccounts, signingAccount } from '../../modules/accounts'
import { allAccounts, formatAccount, signingAccount } from '../../modules/accounts'
import { printCoins, unscaledCoins } from '../../modules/coinHelpers'
import IconMining from '../icons/IconMining.svelte'
import { minerLoopEnabled } from '../../modules/miner'
Expand Down Expand Up @@ -46,7 +46,7 @@
{/if}
</td>
<td>{a.nickname}</td>
<td class="uk-text-truncate">{a.account}</td>
<td class="uk-text-truncate">{formatAccount(a.account)}</td>
<td>{a.auth_key.slice(0, 5)}...</td>
<td>{printCoins(a.balance.unlocked)}</td>
<td class="uk-text-right">
Expand Down
51 changes: 36 additions & 15 deletions src/components/wallet/Keygen.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,29 @@
invoke('keygen', {})
.then((res: NewKeygen) => {
tempDangerDisplayMnem = res.mnem
res.mnem = null;
res.mnem = null
responses.set(JSON.stringify(res))
signingAccount.set(res.entry)
hide = false
})
.catch((e) => raise_error(e, true, 'do_keygen'))
}
onDestroy(() => tempDangerDisplayMnem = null)
onDestroy(() => (tempDangerDisplayMnem = null))
</script>

<main>
<div class="uk-flex uk-flex-center">
<!-- <div class="uk-flex uk-flex-center">
<h3 class="uk-text-light uk-text-muted uk-text-uppercase">
{$_('wallet.keygen.title')}
</h3>
</div>
</div> -->

{#if $signingAccount.account && !hide}
{#if $signingAccount && $signingAccount.account && !hide}
<div class="uk-margin uk-card uk-card-default uk-card-body uk-text-muted">
<h5 class="uk-text-muted uk-text-uppercase">{$_('wallet.keygen.account_address')}</h5>
<p class="uk-text-emphasis uk-text-uppercase">{$signingAccount.account}</p>


<h5 class="uk-text-muted uk-text-uppercase uk-text-danger">
{$_('wallet.keygen.securite_recovery_phrase')}
</h5>
Expand All @@ -70,16 +68,39 @@
</button>
</div>
{:else}
<div class="uk-flex uk-flex-center">
<h3 class="uk-text-light uk-text-muted uk-text-center">
{$_('wallet.keygen.description')}
</h3>

<div class="uk-card uk-card-default uk-align-center uk-width-1-2@m">
<div class="uk-card-header">
<div class="uk-grid-small uk-flex-middle" uk-grid>
<div class="uk-width-expand">
<h3 class="uk-card-title uk-margin-remove-bottom uk-text-muted uk-text-uppercase">{$_('wallet.keygen.title')}</h3>
</div>
</div>
</div>
<div class="uk-card-body">
<p>{$_('wallet.keygen.description')}</p>
</div>
<div class="uk-card-footer">

<div class="uk-position-center">
<button class="uk-button uk-button-secondary uk-align-right" on:click={do_keygen}>
{$_('wallet.keygen.btn_generate_keys')}
</button>
<button class="uk-button uk-button-secondary" on:click={do_keygen}>{$_('wallet.keygen.btn_generate_keys')}</button>
</div>
</div>


<!-- <div class="uk-card uk-card-default uk-card-body">
<div class="uk-flex uk-child-width-1-2">
<div class=" uk-margin-left">
<h3 class="uk-text-light uk-text-muted uk-text">
{$_('wallet.keygen.description')}
</h3>
</div>
<div class="uk-align-center">
<button class="uk-button uk-button-secondary" on:click={do_keygen}>
{$_('wallet.keygen.btn_generate_keys')}
</button>
</div>
</div>
</div> -->
{/if}
</main>
4 changes: 4 additions & 0 deletions src/modules/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ export const makeWhole = writable<object>()
export const canMigrate = writable<boolean>(false)
export const migrateSuccess = writable<boolean>()
export const migrateInProgress = writable<boolean>()

export const formatAccount = (acc: string): string => {
return acc.replace('00000000000000000000000000000000', '')
}

0 comments on commit b4812a2

Please sign in to comment.