Skip to content

Commit

Permalink
Update the Acre SDK constructor
Browse files Browse the repository at this point in the history
Add Acre subgraph api - used to fetch deposits data.
  • Loading branch information
r-czajkowski committed May 15, 2024
1 parent 54b7269 commit ac5b0b8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sdk/src/acre.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)
}

Expand Down Expand Up @@ -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)
}
}

Expand Down
1 change: 1 addition & 0 deletions sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions sdk/test/modules/staking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -118,6 +119,7 @@ describe("Staking", () => {
// 'MockOrangeKitSdk' but required in type 'OrangeKitSdk'.
orangeKit,
tbtc,
{} as AcreSubgraphApi,
)

describe("initializeStake", () => {
Expand Down

0 comments on commit ac5b0b8

Please sign in to comment.