@@ -4,7 +4,7 @@ import { Interface, WebSocketProvider, ethers } from 'ethers'
4
4
import type { ErrorEvent , WebSocket } from 'ws'
5
5
import type { ContractAddress } from '@ora-io/utils'
6
6
import { debug } from '../debug'
7
- import { ContractManager } from './contract'
7
+ import { RekuContractManager } from './contract'
8
8
9
9
export interface RekuProviderManagerOptions {
10
10
/**
@@ -21,7 +21,7 @@ export type RekuProviderManagerEvent = 'error' | 'close'
21
21
22
22
export class RekuProviderManager {
23
23
private _provider ?: ethers . JsonRpcProvider | ethers . WebSocketProvider
24
- private _contracts : Map < ContractAddress , ContractManager > = new Map ( )
24
+ private _contracts : Map < ContractAddress , RekuContractManager > = new Map ( )
25
25
26
26
private _heartbeatInterval = 10 * 1000
27
27
@@ -54,20 +54,20 @@ export class RekuProviderManager {
54
54
return this . _contracts
55
55
}
56
56
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 {
60
60
if ( this . _provider ) {
61
61
if ( abi instanceof Interface || Array . isArray ( abi ) ) {
62
62
if ( ! abi )
63
63
throw new Error ( 'ABI must be provided when address is a string' )
64
64
65
- const contract = new ContractManager ( address , abi , this . _provider )
65
+ const contract = new RekuContractManager ( address , abi , this . _provider )
66
66
this . _contracts . set ( address , contract )
67
67
return contract
68
68
}
69
69
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 )
71
71
this . _contracts . set ( address , contract )
72
72
return contract
73
73
}
@@ -155,10 +155,10 @@ export class RekuProviderManager {
155
155
// reconnect provider
156
156
this . connect ( )
157
157
// reset contracts
158
- const contracts : Map < ContractAddress , ContractManager > = new Map ( )
158
+ const contracts : Map < ContractAddress , RekuContractManager > = new Map ( )
159
159
this . _contracts . forEach ( ( contract ) => {
160
160
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 )
162
162
contract . listeners . forEach ( ( listener , event ) => {
163
163
newContract . addListener ( event , listener )
164
164
} )
0 commit comments