Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve blockchain transaction processing feedback #622

Merged
merged 4 commits into from
Nov 5, 2023
Merged
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
553 changes: 383 additions & 170 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
"vitest-github-actions-reporter": "^0.10.0"
},
"dependencies": {
"@aave/math-utils": "^1.20.0",
"@sentry/sveltekit": "^7.74.0",
"@aave/math-utils": "^1.21.0",
"@sentry/sveltekit": "^7.77.0",
"@trading-strategy-ai/web-top-node": "^0.1.0-beta.10",
"@tryghost/content-api": "^1.11.8",
"@types/d3-array": "^3.2.0",
"@wagmi/core": "^1.4.2",
"@wagmi/core": "^1.4.5",
"@walletconnect/modal": "^2.6.2",
"@web3modal/ethereum": "^2.7.1",
"assert-ts": "^0.3.4",
Expand All @@ -75,7 +75,7 @@
"svelte-inview": "^4.0.1",
"svelte-spinner": "^2.0.2",
"typesense": "^1.7.1",
"viem": "^1.10.14"
"viem": "^1.18.4"
},
"optionalDependencies": {
"chartiq": "github:tradingstrategy-ai/chartiq-dist#v9.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/routes/wizard/connect-wallet/success/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="connect-wallet-success">
<p>
Congratulations! You have successfully connected your wallet to Trading Strategy. You can now begin investing in
Congratulations! You have successfully connected your wallet to Trading Strategy. You can now deposit funds in
<strong>{$wizard.data.strategyName}</strong> and other strategies. Click "Done" to return to the strategy overview. Happy
trading!
</p>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/wizard/deposit/balance/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{@const href = buyNativeCurrencyUrl(chainId)}
<div in:fade>
<Alert status="warning" size="md">
<strong>{nativeCurrency.symbol}</strong> is required to pay gas fees when investing in this strategy.
<strong>{nativeCurrency.symbol}</strong> is required to pay gas fees when participating in this strategy.
<Button
slot="cta"
size="sm"
Expand Down
4 changes: 2 additions & 2 deletions src/routes/wizard/deposit/introduction/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<div class="deposit-introduction">
<p>
Ready to invest in <strong>{$wizard.data.strategyName}</strong>? Deposit USDC to add this strategy to your DeFi
trading portfolio. Connect your wallet, review your balances, enter your desired investment amount, and make your
Ready to deposit in <strong>{$wizard.data.strategyName}</strong>? Deposit USDC to add this strategy to your DeFi
trading portfolio. Connect your wallet, review your balances, enter your desired deposit amount, and make your
payment. Let's get started!
</p>
</div>
25 changes: 15 additions & 10 deletions src/routes/wizard/deposit/payment/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { captureException } from '@sentry/sveltekit';
import { wizard } from 'wizard/store';
import { tweened } from 'svelte/motion';
import { cubicOut } from 'svelte/easing';
Expand All @@ -23,6 +24,7 @@
let paymentInput: MoneyInput;

const progressBar = tweened(0, { easing: cubicOut });
const viewTransactionCopy = 'Click the transaction ID above to view the status in the blockchain explorer.';

// Disable the "Cancel" button once a transaction has been initiated
$: wizard.toggleComplete('meta:no-return', transactionId !== undefined);
Expand Down Expand Up @@ -78,7 +80,8 @@
},

fail(err) {
console.error('authorizeTransfer error:', err);
const eventId = captureException(err);
console.error('authorizeTransfer error:', eventId, err);
if (err.name === 'UnknownRpcError' && err.details.includes('eth_signTypedData_v4')) {
errorMessage = `
Authorization failed because your wallet does not support typed data signatures.
Expand All @@ -105,7 +108,8 @@
},

fail(err) {
console.error('confirmPayment error:', err);
const eventId = captureException(err);
console.error('confirmPayment error:', eventId, err);
errorMessage = 'Payment confirmation from wallet account failed. ';
errorMessage += err.shortMessage ?? 'Failure reason unknown.';
return 'failed';
Expand Down Expand Up @@ -139,18 +143,19 @@
finish(receipt) {
if (receipt.status !== 'success') {
console.error('waitForTransaction reverted:', receipt);
errorMessage = 'Transaction execution reverted. See blockchain explorer for details.';
errorMessage = `Transaction execution reverted. ${viewTransactionCopy}`;
return 'failed';
}
return 'completed';
},

fail(err) {
console.error('waitForTransaction error:', err);
const eventId = captureException(err);
console.error('waitForTransaction error:', eventId, err);
if (err.name === 'CallExecutionError') {
errorMessage = `${err.shortMessage} See blockchain explorer for details.`;
errorMessage = `${err.shortMessage} ${viewTransactionCopy}`;
} else {
errorMessage = 'Unable to verify transaction status. See blockchain explorer for details.';
errorMessage = `Unable to verify transaction status. ${viewTransactionCopy}`;
}
return 'failed';
}
Expand Down Expand Up @@ -238,8 +243,8 @@
<Button submit disabled={!paymentValue}>Make payment</Button>

<Alert size="sm" status="warning" title="Notice">
Investing in crypto trading carries significant risks. Past performance is not indicative of future results.
Only invest funds you are willing to lose.
Depositing funds in crypto trading strategies carries significant risk. Past performance is not indicative of
future results. Only deposit funds you are willing to lose.
</Alert>
{/if}

Expand All @@ -266,8 +271,8 @@

{#if $payment === 'processing'}
<Alert size="sm" status="info" title="Payment processing">
The duration of processing may vary based on factors such as blockchain congestion and gas specified. Click
the transaction ID above to view the status in the blockchain explorer.
The duration of processing may vary based on factors such as blockchain congestion and gas specified.
{viewTransactionCopy}
</Alert>
{/if}

Expand Down
6 changes: 3 additions & 3 deletions src/routes/wizard/deposit/success/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<VaultBalance {contracts} {address} />

<p>
Congratulations! You've successfully invested in <strong>{strategyName}</strong>. Keep an eye on your progress and
returns. Please remember that investing in crypto / DeFi trading strategies carries significant risk. Click "Done"
to return to the strategy.
Congratulations! You've successfully deposited in <strong>{strategyName}</strong>. Keep an eye on your progress and
returns. Please remember that participating in crypto / DeFi trading strategies carries significant risk. Click
"Done" to return to the strategy.
</p>
</Grid>
2 changes: 1 addition & 1 deletion src/routes/wizard/redeem/deposit-status/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
{@const href = buyNativeCurrencyUrl(chainId)}
<div in:fade>
<Alert status="warning" size="md">
<strong>{nativeCurrency.symbol}</strong> is required to pay gas fees when investing in this strategy.
<strong>{nativeCurrency.symbol}</strong> is required to pay gas fees when redeeming from this strategy.
<Button
slot="cta"
size="sm"
Expand Down
18 changes: 11 additions & 7 deletions src/routes/wizard/redeem/shares-redemption/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { captureException } from '@sentry/sveltekit';
import { wizard } from 'wizard/store';
import { tweened } from 'svelte/motion';
import { cubicOut } from 'svelte/easing';
Expand All @@ -21,6 +22,7 @@
let sharesInput: MoneyInput;

const progressBar = tweened(0, { easing: cubicOut });
const viewTransactionCopy = 'Click the transaction ID above to view the status in the blockchain explorer.';

// Disable the "Cancel" button once a transaction has been initiated
$: wizard.toggleComplete('meta:no-return', transactionId !== undefined);
Expand Down Expand Up @@ -65,7 +67,8 @@
},

fail(err) {
console.error('confirmRedemption error:', err);
const eventId = captureException(err);
console.error('confirmRedemption error:', eventId, err);
errorMessage = err.shortMessage ?? 'Redemption confirmation from wallet account failed.';
return 'failed';
}
Expand Down Expand Up @@ -98,18 +101,19 @@
finish(receipt) {
if (receipt.status !== 'success') {
console.error('waitForTransaction reverted:', receipt);
errorMessage = 'Transaction execution reverted. See blockchain explorer for details.';
errorMessage = `Transaction execution reverted. ${viewTransactionCopy}`;
return 'failed';
}
return 'completed';
},

fail(err) {
console.error('waitForTransaction error:', err);
const eventId = captureException(err);
console.error('waitForTransaction error:', eventId, err);
if (err.name === 'CallExecutionError') {
errorMessage = `${err.shortMessage} See blockchain explorer for details.`;
errorMessage = `${err.shortMessage} ${viewTransactionCopy}`;
} else {
errorMessage = 'Unable to verify transaction status. See blockchain explorer for details.';
errorMessage = `Unable to verify transaction status. ${viewTransactionCopy}`;
}
return 'failed';
}
Expand Down Expand Up @@ -204,8 +208,8 @@

{#if $redemption === 'processing'}
<Alert size="sm" status="info" title="Redemption processing">
The duration of processing may vary based on factors such as blockchain congestion and gas specified. Click
the transaction ID above to view the status in the blockchain explorer.
The duration of processing may vary based on factors such as blockchain congestion and gas specified.
{viewTransactionCopy}
</Alert>
{/if}

Expand Down
Loading