From ac5b0b837062b1f62fd3611e257eef90783cc471 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Wed, 15 May 2024 18:18:39 +0200 Subject: [PATCH] Update the Acre SDK constructor Add Acre subgraph api - used to fetch deposits data. --- sdk/src/acre.ts | 12 +++++++++++- sdk/src/index.ts | 1 + sdk/test/modules/staking.test.ts | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sdk/src/acre.ts b/sdk/src/acre.ts index 0523f69a9..95b1cd599 100644 --- a/sdk/src/acre.ts +++ b/sdk/src/acre.ts @@ -7,6 +7,7 @@ import Tbtc from "./modules/tbtc" import { VoidSigner } from "./lib/utils" import { BitcoinProvider, BitcoinNetwork } from "./lib/bitcoin" import { getChainIdByNetwork } from "./lib/ethereum/network" +import AcreSubgraphApi from "./lib/api/AcreSubgraphApi" class Acre { readonly #tbtc: Tbtc @@ -19,21 +20,26 @@ class Acre { public readonly staking: StakingModule + readonly #acreSubgraph: AcreSubgraphApi + constructor( contracts: AcreContracts, bitcoinProvider: BitcoinProvider, orangeKit: OrangeKitSdk, tbtc: Tbtc, + acreSubgraphApi: AcreSubgraphApi, ) { this.contracts = contracts this.#tbtc = tbtc this.#orangeKit = orangeKit + this.#acreSubgraph = acreSubgraphApi this.#bitcoinProvider = bitcoinProvider this.staking = new StakingModule( this.contracts, this.#bitcoinProvider, this.#orangeKit, this.#tbtc, + this.#acreSubgraph, ) } @@ -99,8 +105,12 @@ class Acre { tbtcApiUrl, contracts.bitcoinDepositor, ) + const subgraph = new AcreSubgraphApi( + // TODO: Set correct url based on the network + "https://api.studio.thegraph.com/query/73600/acre/version/latest", + ) - return new Acre(contracts, bitcoinProvider, orangeKit, tbtc) + return new Acre(contracts, bitcoinProvider, orangeKit, tbtc, subgraph) } } diff --git a/sdk/src/index.ts b/sdk/src/index.ts index aa6eb58a0..526aa4936 100644 --- a/sdk/src/index.ts +++ b/sdk/src/index.ts @@ -3,6 +3,7 @@ export * from "./lib/contracts" export * from "./lib/eip712-signer" export * from "./lib/ethereum" export * from "./lib/utils" +export { DepositStatus } from "./lib/api/TbtcApi" export * from "./modules/staking" diff --git a/sdk/test/modules/staking.test.ts b/sdk/test/modules/staking.test.ts index e70a42be0..c58148928 100644 --- a/sdk/test/modules/staking.test.ts +++ b/sdk/test/modules/staking.test.ts @@ -15,6 +15,7 @@ import { MockOrangeKitSdk } from "../utils/mock-orangekit" import { MockTbtc } from "../utils/mock-tbtc" import { DepositReceipt } from "../../src/modules/tbtc" import { MockBitcoinProvider } from "../utils/mock-bitcoin-provider" +import AcreSubgraphApi from "../../src/lib/api/AcreSubgraphApi" const stakingModuleData: { initializeDeposit: { @@ -118,6 +119,7 @@ describe("Staking", () => { // 'MockOrangeKitSdk' but required in type 'OrangeKitSdk'. orangeKit, tbtc, + {} as AcreSubgraphApi, ) describe("initializeStake", () => {