mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Allow Disenser as optional contract.
This commit is contained in:
parent
13287d1706
commit
be95da79df
@ -49,7 +49,7 @@ export class Keeper extends Instantiable {
|
||||
try {
|
||||
keeper.instances = await objectPromiseAll({
|
||||
// Main contracts
|
||||
dispenser: Dispenser.getInstance(config),
|
||||
dispenser: undefined, // Optional
|
||||
token: OceanToken.getInstance(config),
|
||||
didRegistry: DIDRegistry.getInstance(config),
|
||||
// Managers
|
||||
@ -78,6 +78,13 @@ export class Keeper extends Instantiable {
|
||||
return
|
||||
}
|
||||
|
||||
// Optionals
|
||||
try {
|
||||
keeper.instances.dispenser = await Dispenser.getInstance(config)
|
||||
} catch {
|
||||
keeper.logger.warn('Dispenser not available on this network.')
|
||||
}
|
||||
|
||||
// Main contracts
|
||||
keeper.dispenser = keeper.instances.dispenser
|
||||
keeper.token = keeper.instances.token
|
||||
|
@ -111,6 +111,9 @@ export default class Account extends Instantiable {
|
||||
*/
|
||||
public async requestTokens(amount: number | string): Promise<string> {
|
||||
amount = String(amount)
|
||||
if (!this.ocean.keeper.dispenser) {
|
||||
throw new Error('Dispenser not available on this network.')
|
||||
}
|
||||
try {
|
||||
await this.ocean.keeper.dispenser.requestTokens(amount, this.id)
|
||||
} catch (e) {
|
||||
|
Loading…
Reference in New Issue
Block a user