-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: working on adding types everywhere possible
- Loading branch information
1 parent
54e59e8
commit 2cc363d
Showing
8 changed files
with
132 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
import { MeshContext } from "@graphql-mesh/runtime"; | ||
import { fetch } from "@whatwg-node/fetch"; | ||
import { Headers, fetch } from "@whatwg-node/fetch"; | ||
import { MeshContext } from "./.mesh"; | ||
|
||
type ContextModified = MeshContext & { | ||
token: string; | ||
apiKey: string; | ||
}; | ||
|
||
export default function patchedFetch( | ||
url: string, | ||
init: any, | ||
context: MeshContext | ||
init: RequestInit, | ||
context: ContextModified | ||
) { | ||
console.debug(url, init.headers); | ||
init.headers["Authorization"] = | ||
"Bearer your-token"; | ||
|
||
const headers = new Headers(); | ||
headers.set( | ||
"accept", | ||
"application/graphql-response+json application/json multipart/mixed" | ||
); | ||
headers.set("content-type", "application/json"); | ||
headers.set("Authorization", `Bearer ${context.token}`); | ||
headers.set("X-Api-Key", context.apiKey); | ||
init.headers = headers; | ||
console.log(url, init); | ||
return fetch(url, init); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,15 @@ | ||
import { createWalletNonce_mutationMutation } from "../.mesh"; | ||
|
||
export class Auth { | ||
private sdk: any; | ||
|
||
constructor(sdk: any) { | ||
this.sdk = sdk; | ||
} | ||
|
||
async createWalletNounce( | ||
wallet: string | ||
): Promise<createWalletNonce_mutationMutation> { | ||
return await this.sdk.createWalletNonce_mutation({ input: { wallet } }); | ||
} | ||
} |
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,19 @@ | ||
import { Auth } from "./Auth"; | ||
import { PDA } from "./PDA"; | ||
import { getMeshSDK, MeshContext } from "../.mesh"; | ||
|
||
export class Gateway { | ||
// public auth: Auth; | ||
public pda: PDA; | ||
private sdk: any; | ||
|
||
constructor({ apiKey, token }: { apiKey: string; token: string }) { | ||
if (!apiKey && !token) throw new Error("No token found"); | ||
this.sdk = getMeshSDK({ | ||
apiKey, | ||
token, | ||
}); | ||
// this.auth = new Auth(); | ||
this.pda = new PDA(this.sdk); | ||
} | ||
} |
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,14 @@ | ||
import { CreatePDAInput, createPDA_mutationMutation } from "../.mesh"; | ||
|
||
export class PDA { | ||
private sdk: any; | ||
|
||
constructor(sdk: any) { | ||
this.sdk = sdk; | ||
} | ||
async createPDA( | ||
pdaInput: CreatePDAInput | ||
): Promise<createPDA_mutationMutation> { | ||
return await this.sdk.createPDA_mutation({ input: pdaInput }); | ||
} | ||
} |
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,7 @@ | ||
export enum UserIdentifierType { | ||
EMAIL, | ||
EVM, | ||
GATEWAY_ID, | ||
SOLANA, | ||
USER_ID, | ||
} |