-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from porters-xyz/tkn-api
Tkn api
- Loading branch information
Showing
12 changed files
with
163 additions
and
93 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
30 changes: 30 additions & 0 deletions
30
web-portal/backend/src/providers/rpc/PortersJsonRpcProvider.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { JsonRpcProvider, FetchRequest } from "ethers"; | ||
|
||
export class PortersJsonRpcProvider extends JsonRpcProvider { | ||
async fetchData<T = any>(request: FetchRequest): Promise<T> { | ||
const url = new URL(request.url); | ||
console.log('calling endpoint', { | ||
hostname: url.hostname, | ||
port: 443, | ||
path: url.pathname, | ||
method: request.method || 'POST', | ||
headers: { | ||
...request.headers, | ||
Host: url.hostname, | ||
}, | ||
}); | ||
|
||
// Ensure the Host header is set | ||
request.headers['Host'] = url.hostname; | ||
|
||
// Perform the HTTP request using fetch | ||
const response = await fetch(request.url, { | ||
method: request.method || 'POST', | ||
headers: request.headers, | ||
body: request.body, | ||
}); | ||
|
||
const body = await response.json(); | ||
return body as T; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export interface AddressInfo { | ||
eth: string; | ||
optimism: string; | ||
arbitrum: string; | ||
avax: string; | ||
bsc: string; | ||
base: string; | ||
cronos: string; | ||
fantom: string; | ||
gnosis: string; | ||
polygon: string; | ||
goerli_testnet: string; | ||
sepolia_testnet: string; | ||
near: string; | ||
solana: string; | ||
tron: string; | ||
ziliqa: string; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { AddressInfo } from "./AddressInfo"; | ||
|
||
export interface TokenInfo { | ||
contractAddress: string; | ||
name: string; | ||
url: string; | ||
avatar: string; | ||
description: string; | ||
notice: string; | ||
version: string; | ||
decimals: string; | ||
twitter: string; | ||
github: string; | ||
dweb: string; // Assuming this is a string representation of the bytes | ||
addresses: AddressInfo; | ||
} |
Oops, something went wrong.