Skip to content

Commit

Permalink
Merge pull request #136 from rainlanguage/2024-01-25-rm-trailing-whit…
Browse files Browse the repository at this point in the history
…espace

2024 01 25 rm trailing whitespace
  • Loading branch information
thedavidmeister authored Jan 26, 2024
2 parents 2071363 + 7070b8e commit 3165498
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 36 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rainix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ jobs:
env:
ETH_RPC_URL: ${{ secrets.CI_DEPLOY_RPC_URL }}
ETHERSCAN_API_KEY: ${{ secrets.EXPLORER_VERIFICATION_KEY }}
DEPLOY_VERIFIER: 'etherscan'
run: nix run .#${{ matrix.task }}
24 changes: 21 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
{
"editor.rulers": [80],
"svelte.enable-ts-plugin": true
}
"editor.rulers": [80],
"svelte.enable-ts-plugin": true,
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file"
},
"[javascript][svelte][typescript]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"eslint.lintTask.enable": true
}
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"svelte"
]
}
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
typeshare crates/subgraph/src/types/orders.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/orders.ts;
typeshare tauri-app/src-tauri/src/toast.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/toast.ts;
typeshare tauri-app/src-tauri/src/transaction_status.rs --lang=typescript --output-file=tauri-app/src/lib/typeshare/transactionStatus.ts;
# Fix linting of generated types
cd tauri-app && npm i && npm run lint
'';
additionalBuildInputs = [
pkgs.typeshare
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions tauri-app/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
extraFileExtensions: ['.svelte', '.ts']
},
env: {
browser: true,
Expand All @@ -27,5 +27,9 @@ module.exports = {
parser: '@typescript-eslint/parser'
}
}
]
],
rules: {
'no-console': 'error',
'no-trailing-spaces': 'error'
}
};
3 changes: 1 addition & 2 deletions tauri-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
"lint": "eslint --fix src"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions tauri-app/src/lib/InputLedgerWallet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { invoke } from '@tauri-apps/api';
import { isAddress } from 'viem';
import { toasts } from '$lib/stores/toasts';
import { ToastMessageType } from './typeshare/toast';
const maskOptions = {
mask: Number,
Expand Down Expand Up @@ -38,9 +39,8 @@
});
walletAddress = res;
} catch (error) {
console.error(error);
toasts.add({
message_type: 'Error',
message_type: ToastMessageType.Error,
text: `Ledger error: ${error}`,
});
}
Expand Down
1 change: 1 addition & 0 deletions tauri-app/src/lib/InputTokenAmount.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
value = detail.value;
try {
valueRaw = parseUnits(detail.unmaskedValue, decimals);
// eslint-disable-next-line no-empty
} catch (e) {}
}
Expand Down
6 changes: 2 additions & 4 deletions tauri-app/src/lib/ModalVaultDeposit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
async function execute() {
isSubmitting = true;
try {
await vaultDeposit(vault.vault.vault_id, vault.token.id, amountRaw);
reset();
} catch (e) {}
await vaultDeposit(vault.vault.vault_id, vault.token.id, amountRaw);
reset();
isSubmitting = false;
}
</script>
Expand Down
12 changes: 3 additions & 9 deletions tauri-app/src/lib/ModalVaultWithdraw.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
let amountGTBalance: boolean;
let isSubmitting = false;
$: {
try {
amountGTBalance = amountRaw > vault.balance;
} catch (e) {}
}
$: amountGTBalance = amountRaw > vault.balance;
function reset() {
amount = '';
Expand All @@ -25,10 +21,8 @@
async function execute() {
isSubmitting = true;
try {
await vaultWithdraw(vault.vault.vault_id, vault.token.id, amountRaw);
reset();
} catch (e) {}
await vaultWithdraw(vault.vault.vault_id, vault.token.id, amountRaw);
reset();
isSubmitting = false;
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion tauri-app/src/lib/stores/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function updateChainId() {
}
}

export const activeChain = derived(chainId, (val) => {
export const activeChain = derived(chainId, (val) => {
return find(Object.values(chains), (c) => c.id === val);
});

Expand Down
2 changes: 1 addition & 1 deletion tauri-app/src/lib/stores/vaultDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function useVaultDetailStore() {
localStorage.setItem(STORAGE_KEY, JSON.stringify({}));
}
});

async function refetch(id: string) {
const res: VaultDetail = await invoke("vault_detail", {id, subgraphArgs: { url: get(subgraphUrl)} });
update((value) => {
Expand Down
2 changes: 1 addition & 1 deletion tauri-app/src/lib/stores/vaultsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function useVaultsListStore() {
localStorage.setItem(STORAGE_KEY, JSON.stringify([]));
}
});

async function refetch() {
const res: Array<VaultsListItem> = await invoke("vaults_list", {subgraphArgs: { url: get(subgraphUrl)} });
set(res);
Expand Down
21 changes: 15 additions & 6 deletions tauri-app/src/lib/utils/vaultDeposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@ import { get } from 'svelte/store';
import { invoke } from '@tauri-apps/api';
import { rpcUrl, orderbookAddress, walletDerivationIndex } from '../stores/settings';
import { chainId } from '$lib/stores/chain';
import { toasts } from '$lib/stores/toasts';
import { ToastMessageType } from '$lib/typeshare/toast';

export async function vaultDeposit(vaultId: bigint, token: string, amount: bigint) {
await invoke("vault_deposit", {
depositArgs: {
try {
await invoke("vault_deposit", {
depositArgs: {
vault_id: vaultId.toString(),
token,
amount: amount.toString(),
},
transactionArgs: {
},
transactionArgs: {
rpc_url: get(rpcUrl),
orderbook_address: get(orderbookAddress),
derivation_index: get(walletDerivationIndex),
chain_id: get(chainId),
max_priority_fee_per_gas: '400000000000',
max_fee_per_gas: '400000000000',
}
}
});
}
} catch(e) {
toasts.add({
message_type: ToastMessageType.Error,
text: e as string
});
}
};
11 changes: 10 additions & 1 deletion tauri-app/src/lib/utils/vaultWithdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { get } from 'svelte/store';
import { invoke } from '@tauri-apps/api';
import { rpcUrl, orderbookAddress, walletDerivationIndex } from '../stores/settings';
import { chainId } from '$lib/stores/chain';
import { toasts } from '$lib/stores/toasts';
import { ToastMessageType } from '$lib/typeshare/toast';

export async function vaultWithdraw(vaultId: bigint, token: string, targetAmount: bigint) {
try {
await invoke("vault_withdraw", {
withdrawArgs: {
vault_id: vaultId.toString(),
Expand All @@ -19,4 +22,10 @@ export async function vaultWithdraw(vaultId: bigint, token: string, targetAmount
max_fee_per_gas: '400000000000',
}
});
};
} catch(e) {
toasts.add({
message_type: ToastMessageType.Error,
text: e as string
});
}
};
2 changes: 1 addition & 1 deletion tauri-app/src/routes/settings/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { Alert, Heading, Label, Input, Helper, Button } from 'flowbite-svelte';
import { Alert, Heading, Label, Input, Helper } from 'flowbite-svelte';
import BadgeExternalLink from '$lib/BadgeExternalLink.svelte';
import {
rpcUrl,
Expand Down
3 changes: 3 additions & 0 deletions tauri-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import checker from 'vite-plugin-checker';
export default defineConfig({
plugins: [sveltekit(), checker({
typescript: true,
eslint: {
lintCommand: 'eslint src',
},
})],


Expand Down

0 comments on commit 3165498

Please sign in to comment.