Skip to content

Commit

Permalink
fix(dapp): implement horizaontal scroll for continents card
Browse files Browse the repository at this point in the history
  • Loading branch information
timi-codes committed May 22, 2024
1 parent 208ac9b commit 54cc021
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions client/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { toast } from "sonner";

export function shortenAddress(address: string) {
console.log(address)
let shortenedAddress = address ? address.slice(0, 5) + "..." + address.slice(-5) : "";
return shortenedAddress;
}
Expand All @@ -25,15 +26,13 @@ export const transformIPFSURL = (url: string) => {
};



type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
export type FetchAPIResponse<T> = {
success: boolean;
data: T;
message?: string;
};


export const fetchAPI = async <T>(
path: string,
method: HttpMethod = "GET",
Expand All @@ -49,4 +48,42 @@ export const fetchAPI = async <T>(

const data = await response.json() as T;
return data as FetchAPIResponse<T>;;
};
};

export const showError = (message: string ) => {

if (message.includes("insufficient funds")) {
toast.error("Insufficient funds", {
description: "You do not have enough funds to place this bid. Please top up your wallet and try again. The cost of transaction is calculated as `gas * gas fee + value`",
position: "top-left",
})
}

if (message.includes("Ownable: caller is not the owner")) {
toast.error("Transaction failed", {
description: "You can start an auction only if you own the continent",
position: "top-left",
});
}

if (message.includes("Continent does not exist")) {
toast.error("Transaction failed", {
description: "Continent does not exist",
position: "top-left",
});
}

if (message.includes("You already own this continent")) {
toast.error("Transaction failed", {
description: "You already own this continent",
position: "top-left",
});
}

if (message.includes("Not enough Ether sent to cover citizenship tax")) {
toast.error("Transaction failed", {
description: "Not enough Ether sent to cover citizenship tax",
position: "top-left",
});
}
}

0 comments on commit 54cc021

Please sign in to comment.