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:
parent
43008ad619
commit
d37ed63dc7
@ -1,7 +1,13 @@
|
|||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
|
import { Contract } from 'web3-eth-contract'
|
||||||
import { AbiItem } from 'web3-utils'
|
import { AbiItem } from 'web3-utils'
|
||||||
import { Config, ConfigHelper } from '../config'
|
import { Config, ConfigHelper } from '../config'
|
||||||
import { amountToUnits, getFairGasPrice, unitsToAmount } from '../utils'
|
import {
|
||||||
|
amountToUnits,
|
||||||
|
getFairGasPrice,
|
||||||
|
setContractDefaults,
|
||||||
|
unitsToAmount
|
||||||
|
} from '../utils'
|
||||||
|
|
||||||
export abstract class SmartContract {
|
export abstract class SmartContract {
|
||||||
public web3: Web3
|
public web3: Web3
|
||||||
@ -47,4 +53,11 @@ export abstract class SmartContract {
|
|||||||
async getFairGasPrice(): Promise<string> {
|
async getFairGasPrice(): Promise<string> {
|
||||||
return getFairGasPrice(this.web3, this.config)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user