Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Sifchain/sifchain-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
mccallofthewild committed Sep 19, 2021
2 parents ec3641b + ab42bb5 commit bb285cc
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pinata-build-deploy-ui.yml
Expand Up @@ -97,7 +97,7 @@ jobs:
id: slack
uses: slackapi/slack-github-action@v1.14.0
with:
payload: "{\"pinata_url\":\"https://sifchain.mypinata.cloud/ipfs/${{ steps.pinata.outputs.hash }}\",
payload: "{\"pinata_url\":\"${{ steps.pinata.outputs.hash }}\",
\"branch\":\"${{env.SUBDOMAIN}}\",\"github_hash\": \"${{ github.sha }}\",
\"sif_url\": \"https://${{env.SUBDOMAIN}}.sifchain.finance\" }"
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/promote-cloudflare-build.yml
Expand Up @@ -9,7 +9,7 @@ on:
dest_dnslink:
description: 'to record ID'
required: true
default: '_dnslink.ipfs-dex'
default: '_dnslink.dex'

jobs:
copy_dnslink:
Expand Down
2 changes: 1 addition & 1 deletion ui/app/package.json
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "2.2.25",
"version": "2.2.29",
"private": true,
"scripts": {
"bump": "bump patch --tag --commit 'testnet release '",
Expand Down
37 changes: 36 additions & 1 deletion ui/app/src/components/TransactionDetailsModal.tsx
Expand Up @@ -81,7 +81,42 @@ export default defineComponent({
size={20}
/>
)}
{props.transactionDetails.value?.description}
{props.transactionDetails.value?.description ===
"ledger_smart_contracts_not_approved" ? (
<div class="white-space-pre-wrap text-left css-unreset my-[16px]">
It looks like you may have a MetaMask + Ledger configuration
issue. If you are using a new version of Ledger, you must select
the Ethereum app and enable contract data.
<br />
<br />
To enable contract data:
<br />
<ul>
<li>Connect and unlock your Ledger device. </li>
<li>Open the Ethereum application. </li>
<li>Press the right button to navigate to Settings. </li>
<li>Then press both buttons to validate. </li>
<li>
In the Contract data settings, press both buttons to allow
contract data in transactions.{" "}
</li>
<li>The device displays Allowed.</li>
</ul>
<a
class="underline"
href="https://teckers.co/uniswap-ledger/"
target="_blank"
rel="noopener noreferrer"
>
Here is a visual guide.
</a>
<br />
<br />
Once you've done this, try again.
</div>
) : (
props.transactionDetails.value?.description
)}
</p>
{!isLoading &&
(props.completedCta?.value != null ? (
Expand Down
2 changes: 1 addition & 1 deletion ui/app/src/hooks/useTransactionDetails.ts
Expand Up @@ -70,7 +70,7 @@ export function getPegEventDetails(pegEvent: PegEvent): TransactionDetails {
return {
heading: "Transaction Rejected",
isError: true,
description: "", // User rejected, say nothing?
description: pegEvent.tx?.memo || "",
};
}
case "tx_error": {
Expand Down
10 changes: 8 additions & 2 deletions ui/core/src/services/EthbridgeService/EthbridgeService.ts
Expand Up @@ -248,7 +248,10 @@ export default function createEthbridgeService({
console.log("lockToSifchain: handleError: ", err);
pegTx.emit({
type: "Error",
payload: parseTxFailure({ hash: "", log: err.message.toString() }),
payload: {
hash: "",
rawLog: err.message.toString(),
},
});
}

Expand Down Expand Up @@ -383,7 +386,10 @@ export default function createEthbridgeService({
console.log("burnToSifchain: handleError ERROR", err);
pegTx.emit({
type: "Error",
payload: parseTxFailure({ hash: "", log: err }),
payload: {
hash: "",
rawLog: err.message.toString(),
},
});
}

Expand Down
1 change: 1 addition & 0 deletions ui/core/src/services/EthbridgeService/types.ts
Expand Up @@ -57,4 +57,5 @@ export type TxEventPrepopulated<T extends TxEvent = TxEvent> = Omit<
"txHash"
> & {
txHash?: string;
rawLog?: string;
};
25 changes: 25 additions & 0 deletions ui/core/src/services/SifService/parseTxFailure.ts
Expand Up @@ -2,6 +2,31 @@ import { BroadcastTxFailure } from "@cosmjs/launchpad";
import { TransactionStatus } from "../../entities";
import { ErrorCode, getErrorMessage } from "../../entities/Errors";

export function parseEthereumTxFailure(txFailure: {
transactionHash: string;
rawLog?: string;
}): TransactionStatus {
if (txFailure.rawLog?.includes("LEDGER_")) {
return {
code: ErrorCode.UNKNOWN_FAILURE,
hash: txFailure.transactionHash,
memo: txFailure.rawLog,
state: "failed",
};
}

if (txFailure.rawLog?.toLowerCase().includes("error: [object object]")) {
return {
code: ErrorCode.UNKNOWN_FAILURE,
hash: txFailure.transactionHash,
state: "failed",
memo: "ledger_smart_contracts_not_approved",
};
}

return parseTxFailure(txFailure);
}

export function parseTxFailure(txFailure: {
transactionHash: string;
rawLog?: string;
Expand Down
15 changes: 13 additions & 2 deletions ui/core/src/usecases/interchain/ethereumSifchainInterchain.ts
Expand Up @@ -16,6 +16,7 @@ import { SifchainChain, EthereumChain } from "../../services/ChainsService";
import { isSupportedEVMChain } from "../utils";
import { isOriginallySifchainNativeToken } from "../peg/utils/isOriginallySifchainNativeToken";
import { createIteratorSubject } from "../../utils/iteratorSubject";
import { parseEthereumTxFailure } from "../../services/SifService/parseTxFailure";

const ETH_CONFIRMATIONS = 50;

Expand Down Expand Up @@ -63,7 +64,13 @@ export class EthereumSifchainInterchainApi
params.assetAmount,
);
} catch (error) {
emit({ type: "approve_error" });
emit({
type: "approve_error",
tx: parseEthereumTxFailure({
transactionHash: "",
rawLog: error.message,
}),
});
return;
}
emit({ type: "approved" });
Expand Down Expand Up @@ -104,7 +111,11 @@ export class EthereumSifchainInterchainApi
hash: hash,
} as SifchainInterchainTx;
} catch (transactionStatus) {
emit({ type: "tx_error", tx: transactionStatus });
console.log("catch", transactionStatus);
emit({
type: "tx_error",
tx: parseEthereumTxFailure(transactionStatus),
});
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion ui/core/src/usecases/peg/peg.ts
Expand Up @@ -29,7 +29,7 @@ export type PegApproveStartedEvent = { type: "approve_started" };
export type PegApprovedEvent = { type: "approved" };
export type PegSentEvent = { type: "sent"; tx: TransactionStatus };
export type PegTxError = { type: "tx_error"; tx: TransactionStatus };
export type PegApproveError = { type: "approve_error" };
export type PegApproveError = { type: "approve_error"; tx?: TransactionStatus };
export type PegSigningEvent = { type: "signing" };
export type PegEvent =
| PegApproveStartedEvent
Expand Down

0 comments on commit bb285cc

Please sign in to comment.