1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

add getContract() to SmartContract class

This commit is contained in:
Miquel A. Cabot 2022-06-09 11:01:50 +02:00
parent 43008ad619
commit d37ed63dc7

View File

@ -1,7 +1,13 @@
import Web3 from 'web3'
import { Contract } from 'web3-eth-contract'
import { AbiItem } from 'web3-utils'
import { Config, ConfigHelper } from '../config'
import { amountToUnits, getFairGasPrice, unitsToAmount } from '../utils'
import {
amountToUnits,
getFairGasPrice,
setContractDefaults,
unitsToAmount
} from '../utils'
export abstract class SmartContract {
public web3: Web3
@ -47,4 +53,11 @@ export abstract class SmartContract {
async getFairGasPrice(): Promise<string> {
return getFairGasPrice(this.web3, this.config)
}
getContract(address: string, account?: string): Contract {
const contract = new this.web3.eth.Contract(this.abi, address, {
from: account
})
return setContractDefaults(contract, this.config)
}
}