-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate SDK with tBTC API for deposit creation (#377)
In this PR we integrate Acre SDK with [tBTC API](https://github.com/thesis/acre-bots/tree/main/tbtc-api). In deposit flow, SDK will interact with the tBTC API in the following cases: - to backup the generated deposit receipt (this will replace Sentry deposit registration) - the data are stored in Cloudflare D1 database named `reveals`. - to create a deposit and initialize bridging (this will replace OpenZeppelin Defender relayer integration) - the data are stored in Cloudflare D1 database named `deposits`. Initially, the deposit is stored with the status `QUEUED` in the DB, Ethereum transaction is not sent yet. The relayer bot runs periodically goes through the `QUEUED` deposits, and submits the `initializeDeposit` transaction. Refs: thesis/acre-bots#12 Closes: #340 Closes: #323
- Loading branch information
Showing
28 changed files
with
851 additions
and
500 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export * from "./ledger-live-signer" | ||
export * from "./relayer-depositor-proxy" |
This file was deleted.
Oops, something went wrong.
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
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,4 @@ | ||
module.exports = { | ||
export default { | ||
preset: "ts-jest", | ||
testPathIgnorePatterns: ["<rootDir>/dist/", "<rootDir>/node_modules/"], | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Represents an abstract HTTP API. | ||
*/ | ||
export default abstract class HttpApi { | ||
#apiUrl: string | ||
|
||
constructor(apiUrl: string) { | ||
this.#apiUrl = apiUrl | ||
} | ||
|
||
/** | ||
* Factory function for running GET requests. | ||
* @param endpoint API endpoint. | ||
* @param requestInit Additional data passed to request. | ||
* @returns API response. | ||
*/ | ||
protected async getRequest( | ||
endpoint: string, | ||
requestInit?: RequestInit, | ||
): Promise<Response> { | ||
return fetch(new URL(endpoint, this.#apiUrl), { | ||
credentials: "include", | ||
...requestInit, | ||
}) | ||
} | ||
|
||
/** | ||
* Factory function for running POST requests. | ||
* @param endpoint API endpoint, | ||
* @param body Data passed to POST request. | ||
* @param requestInit Additional data passed to request. | ||
* @returns API response. | ||
*/ | ||
protected async postRequest( | ||
endpoint: string, | ||
body: unknown, | ||
requestInit?: RequestInit, | ||
): Promise<Response> { | ||
return fetch(new URL(endpoint, this.#apiUrl), { | ||
method: "POST", | ||
body: JSON.stringify(body), | ||
credentials: "include", | ||
headers: { "Content-Type": "application/json" }, | ||
...requestInit, | ||
}) | ||
} | ||
} |
Oops, something went wrong.