-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
58 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
sdk/src/utils/simulationErrorHandler.ts → sdk/src/utils/errorHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import { BaseError, ContractFunctionRevertedError } from "viem"; | ||
import { ActionType } from "./constants"; | ||
|
||
export function handleSimulationError(err: unknown): never { | ||
export function handleError(type: ActionType, err: unknown): never { | ||
if (err instanceof BaseError) { | ||
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError); | ||
if (revertError instanceof ContractFunctionRevertedError) { | ||
const errorName = revertError.data?.errorName ?? ""; | ||
console.error(`Failing with ${errorName}`); | ||
throw new Error(`${type} failed with ${errorName}`); | ||
} | ||
} else { | ||
console.error(err); | ||
throw new Error(`${type} failed with ${err}`); | ||
} | ||
|
||
throw new Error("Simulation failed"); | ||
throw new Error("${type} failed"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
import axios from "axios"; | ||
|
||
export function stringifyWhereClause(whereClauseObj: Record<string, unknown>) { | ||
const json = JSON.stringify(whereClauseObj); | ||
return json.replace(/"([^"]+)":/g, "$1:"); | ||
} | ||
|
||
export function subgraphCall(query: string, url: string) { | ||
return axios.post( | ||
url, | ||
{ query }, | ||
{ | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
}, | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import axios from "axios"; | ||
|
||
export const getIPFSContent = async (ipfsHash: string): Promise<string> => { | ||
// Use the Cloudflare IPFS gateway URL | ||
const ipfsGatewayUrl = `https://cloudflare-ipfs.com/ipfs/${ipfsHash}`; | ||
// Make a request to the IPFS gateway | ||
const response = await axios.get(ipfsGatewayUrl); | ||
return response.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters