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

use getContract() in SideStacking

This commit is contained in:
Miquel A. Cabot 2022-06-09 11:31:17 +02:00
parent ccd62ddecf
commit 70f9c1697e

View File

@ -20,7 +20,7 @@ export class SideStaking extends SmartContract {
ssAddress: string, ssAddress: string,
datatokenAddress: string datatokenAddress: string
): Promise<string> { ): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods result = await sideStaking.methods
@ -44,7 +44,7 @@ export class SideStaking extends SmartContract {
datatokenAddress: string datatokenAddress: string
): Promise<string> { ): Promise<string> {
try { try {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
result = await sideStaking.methods result = await sideStaking.methods
.getDatatokenCurrentCirculatingSupply(datatokenAddress) .getDatatokenCurrentCirculatingSupply(datatokenAddress)
@ -65,7 +65,7 @@ export class SideStaking extends SmartContract {
ssAddress: string, ssAddress: string,
datatokenAddress: string datatokenAddress: string
): Promise<string> { ): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods.getPublisherAddress(datatokenAddress).call() result = await sideStaking.methods.getPublisherAddress(datatokenAddress).call()
@ -82,7 +82,7 @@ export class SideStaking extends SmartContract {
* @return {String} * @return {String}
*/ */
async getBaseToken(ssAddress: string, datatokenAddress: string): Promise<string> { async getBaseToken(ssAddress: string, datatokenAddress: string): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods.getBaseTokenAddress(datatokenAddress).call() result = await sideStaking.methods.getBaseTokenAddress(datatokenAddress).call()
@ -99,7 +99,7 @@ export class SideStaking extends SmartContract {
* @return {String} * @return {String}
*/ */
async getPoolAddress(ssAddress: string, datatokenAddress: string): Promise<string> { async getPoolAddress(ssAddress: string, datatokenAddress: string): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods.getPoolAddress(datatokenAddress).call() result = await sideStaking.methods.getPoolAddress(datatokenAddress).call()
@ -119,7 +119,7 @@ export class SideStaking extends SmartContract {
ssAddress: string, ssAddress: string,
datatokenAddress: string datatokenAddress: string
): Promise<string> { ): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods.getBaseTokenBalance(datatokenAddress).call() result = await sideStaking.methods.getBaseTokenBalance(datatokenAddress).call()
@ -141,7 +141,7 @@ export class SideStaking extends SmartContract {
datatokenAddress: string, datatokenAddress: string,
tokenDecimals?: number tokenDecimals?: number
): Promise<string> { ): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods.getDatatokenBalance(datatokenAddress).call() result = await sideStaking.methods.getDatatokenBalance(datatokenAddress).call()
@ -159,7 +159,7 @@ export class SideStaking extends SmartContract {
* @return {String} end block for vesting amount * @return {String} end block for vesting amount
*/ */
async getvestingEndBlock(ssAddress: string, datatokenAddress: string): Promise<string> { async getvestingEndBlock(ssAddress: string, datatokenAddress: string): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods.getvestingEndBlock(datatokenAddress).call() result = await sideStaking.methods.getvestingEndBlock(datatokenAddress).call()
@ -181,7 +181,7 @@ export class SideStaking extends SmartContract {
datatokenAddress: string, datatokenAddress: string,
tokenDecimals?: number tokenDecimals?: number
): Promise<string> { ): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods.getvestingAmount(datatokenAddress).call() result = await sideStaking.methods.getvestingAmount(datatokenAddress).call()
@ -202,7 +202,7 @@ export class SideStaking extends SmartContract {
ssAddress: string, ssAddress: string,
datatokenAddress: string datatokenAddress: string
): Promise<string> { ): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods.getvestingLastBlock(datatokenAddress).call() result = await sideStaking.methods.getvestingLastBlock(datatokenAddress).call()
@ -224,7 +224,7 @@ export class SideStaking extends SmartContract {
datatokenAddress: string, datatokenAddress: string,
tokenDecimals?: number tokenDecimals?: number
): Promise<string> { ): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods.getvestingAmountSoFar(datatokenAddress).call() result = await sideStaking.methods.getvestingAmountSoFar(datatokenAddress).call()
@ -249,8 +249,7 @@ export class SideStaking extends SmartContract {
datatokenAddress: string, datatokenAddress: string,
contractInstance?: Contract contractInstance?: Contract
): Promise<number> { ): Promise<number> {
const sideStaking = const sideStaking = contractInstance || this.getContract(ssAddress)
contractInstance || new this.web3.eth.Contract(this.abi as AbiItem[], ssAddress)
return estimateGas(account, sideStaking.methods.getVesting, datatokenAddress) return estimateGas(account, sideStaking.methods.getVesting, datatokenAddress)
} }
@ -267,7 +266,7 @@ export class SideStaking extends SmartContract {
ssAddress: string, ssAddress: string,
datatokenAddress: string datatokenAddress: string
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
const estGas = await estimateGas( const estGas = await estimateGas(
@ -304,8 +303,7 @@ export class SideStaking extends SmartContract {
swapFee: number, swapFee: number,
contractInstance?: Contract contractInstance?: Contract
): Promise<number> { ): Promise<number> {
const sideStaking = const sideStaking = contractInstance || this.getContract(ssAddress)
contractInstance || new this.web3.eth.Contract(this.abi as AbiItem[], ssAddress)
return estimateGas( return estimateGas(
account, account,
@ -330,7 +328,7 @@ export class SideStaking extends SmartContract {
poolAddress: string, poolAddress: string,
swapFee: number swapFee: number
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
const estGas = await estimateGas( const estGas = await estimateGas(
@ -361,7 +359,7 @@ export class SideStaking extends SmartContract {
* @return {String} * @return {String}
*/ */
async getRouter(ssAddress: string): Promise<string> { async getRouter(ssAddress: string): Promise<string> {
const sideStaking = new this.web3.eth.Contract(this.abi, ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {
result = await sideStaking.methods.router().call() result = await sideStaking.methods.router().call()