Skip to content

Commit a9c4e16

Browse files
committed
feat(reku): ContractManager rename to RekuContractManager
1 parent 3ff9603 commit a9c4e16

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

packages/reku/src/provider/contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ContractAddress, Fn } from '@ora-io/utils'
22
import type { Interface, InterfaceAbi } from 'ethers'
33
import { ethers } from 'ethers'
44

5-
export class ContractManager {
5+
export class RekuContractManager {
66
private _contract?: ethers.Contract
77
private _listeners: Map<ethers.ContractEventName, Fn> = new Map()
88

packages/reku/src/provider/provider.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Interface, WebSocketProvider, ethers } from 'ethers'
44
import type { ErrorEvent, WebSocket } from 'ws'
55
import type { ContractAddress } from '@ora-io/utils'
66
import { debug } from '../debug'
7-
import { ContractManager } from './contract'
7+
import { RekuContractManager } from './contract'
88

99
export interface RekuProviderManagerOptions {
1010
/**
@@ -21,7 +21,7 @@ export type RekuProviderManagerEvent = 'error' | 'close'
2121

2222
export class RekuProviderManager {
2323
private _provider?: ethers.JsonRpcProvider | ethers.WebSocketProvider
24-
private _contracts: Map<ContractAddress, ContractManager> = new Map()
24+
private _contracts: Map<ContractAddress, RekuContractManager> = new Map()
2525

2626
private _heartbeatInterval = 10 * 1000
2727

@@ -54,20 +54,20 @@ export class RekuProviderManager {
5454
return this._contracts
5555
}
5656

57-
addContract(address: ContractAddress, contract: ethers.Contract): ContractManager | undefined
58-
addContract(address: ContractAddress, abi: Interface | InterfaceAbi): ContractManager | undefined
59-
addContract(address: ContractAddress, abi: Interface | InterfaceAbi | ethers.Contract): ContractManager | undefined {
57+
addContract(address: ContractAddress, contract: ethers.Contract): RekuContractManager | undefined
58+
addContract(address: ContractAddress, abi: Interface | InterfaceAbi): RekuContractManager | undefined
59+
addContract(address: ContractAddress, abi: Interface | InterfaceAbi | ethers.Contract): RekuContractManager | undefined {
6060
if (this._provider) {
6161
if (abi instanceof Interface || Array.isArray(abi)) {
6262
if (!abi)
6363
throw new Error('ABI must be provided when address is a string')
6464

65-
const contract = new ContractManager(address, abi, this._provider)
65+
const contract = new RekuContractManager(address, abi, this._provider)
6666
this._contracts.set(address, contract)
6767
return contract
6868
}
6969
else if (abi instanceof ethers.Contract) {
70-
const contract = new ContractManager(address, abi.interface, this._provider)
70+
const contract = new RekuContractManager(address, abi.interface, this._provider)
7171
this._contracts.set(address, contract)
7272
return contract
7373
}
@@ -155,10 +155,10 @@ export class RekuProviderManager {
155155
// reconnect provider
156156
this.connect()
157157
// reset contracts
158-
const contracts: Map<ContractAddress, ContractManager> = new Map()
158+
const contracts: Map<ContractAddress, RekuContractManager> = new Map()
159159
this._contracts.forEach((contract) => {
160160
if (this._provider) {
161-
const newContract = new ContractManager(contract.address, contract.abi, this._provider)
161+
const newContract = new RekuContractManager(contract.address, contract.abi, this._provider)
162162
contract.listeners.forEach((listener, event) => {
163163
newContract.addListener(event, listener)
164164
})

packages/reku/tests/contract.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { ethers } from 'ethers'
22
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
33
import { sleep } from '@ora-io/utils'
4-
import { ContractManager } from '../src/provider/contract'
4+
import { RekuContractManager } from '../src/provider/contract'
55

6-
describe('ContractManager', () => {
7-
let contractManager: ContractManager
6+
describe('RekuContractManager', () => {
7+
let contractManager: RekuContractManager
88
const address = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
99
const abi: string[] = [
1010
'event Transfer(address indexed from, address indexed to, uint256 value)',
@@ -13,7 +13,7 @@ describe('ContractManager', () => {
1313
const provider = new ethers.WebSocketProvider('wss://ethereum-rpc.publicnode.com')
1414

1515
beforeEach(() => {
16-
contractManager = new ContractManager(address, abi, provider)
16+
contractManager = new RekuContractManager(address, abi, provider)
1717
})
1818

1919
afterEach(() => {

0 commit comments

Comments
 (0)