mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
optimizations
This commit is contained in:
parent
6f645d6e8f
commit
a1916b0e04
@ -406,12 +406,9 @@ export class OceanPool extends Pool {
|
|||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < events.length; i++) {
|
for (let i = 0; i < events.length; i++) {
|
||||||
if (account) {
|
if (!account || events[i].returnValues[1] === account)
|
||||||
if (events[i].returnValues[1] === account) {
|
|
||||||
result.push(await this.getPoolDetails(events[i].returnValues[0]))
|
result.push(await this.getPoolDetails(events[i].returnValues[0]))
|
||||||
}
|
}
|
||||||
} else result.push(await this.getPoolDetails(events[i].returnValues[0]))
|
|
||||||
}
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,7 +437,7 @@ export class OceanPool extends Pool {
|
|||||||
account?: string
|
account?: string
|
||||||
): Promise<PoolTransaction[]> {
|
): Promise<PoolTransaction[]> {
|
||||||
const results: PoolTransaction[] = []
|
const results: PoolTransaction[] = []
|
||||||
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, { from: account })
|
const pool = new this.web3.eth.Contract(this.poolABI, poolAddress)
|
||||||
const dtAddress = await this.getDTAddress(poolAddress)
|
const dtAddress = await this.getDTAddress(poolAddress)
|
||||||
const myFilter: Filter = account ? { caller: account } : {}
|
const myFilter: Filter = account ? { caller: account } : {}
|
||||||
let events: EventData[]
|
let events: EventData[]
|
||||||
@ -451,14 +448,9 @@ export class OceanPool extends Pool {
|
|||||||
toBlock: 'latest'
|
toBlock: 'latest'
|
||||||
})
|
})
|
||||||
for (let i = 0; i < events.length; i++) {
|
for (let i = 0; i < events.length; i++) {
|
||||||
if (account) {
|
if (!account || events[i].returnValues[0] === account)
|
||||||
if (events[i].returnValues[0] === account) {
|
|
||||||
results.push(await this.getEventData('swap', poolAddress, dtAddress, events[i]))
|
results.push(await this.getEventData('swap', poolAddress, dtAddress, events[i]))
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
results.push(await this.getEventData('swap', poolAddress, dtAddress, events[i]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
events = await pool.getPastEvents('LOG_JOIN', {
|
events = await pool.getPastEvents('LOG_JOIN', {
|
||||||
filter: myFilter,
|
filter: myFilter,
|
||||||
@ -466,14 +458,9 @@ export class OceanPool extends Pool {
|
|||||||
toBlock: 'latest'
|
toBlock: 'latest'
|
||||||
})
|
})
|
||||||
for (let i = 0; i < events.length; i++) {
|
for (let i = 0; i < events.length; i++) {
|
||||||
if (account) {
|
if (!account || events[i].returnValues[0] === account)
|
||||||
if (events[i].returnValues[0] === account) {
|
|
||||||
results.push(await this.getEventData('join', poolAddress, dtAddress, events[i]))
|
results.push(await this.getEventData('join', poolAddress, dtAddress, events[i]))
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
results.push(await this.getEventData('join', poolAddress, dtAddress, events[i]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
events = await pool.getPastEvents('LOG_EXIT', {
|
events = await pool.getPastEvents('LOG_EXIT', {
|
||||||
filter: myFilter,
|
filter: myFilter,
|
||||||
@ -481,14 +468,9 @@ export class OceanPool extends Pool {
|
|||||||
toBlock: 'latest'
|
toBlock: 'latest'
|
||||||
})
|
})
|
||||||
for (let i = 0; i < events.length; i++) {
|
for (let i = 0; i < events.length; i++) {
|
||||||
if (account) {
|
if (!account || events[i].returnValues[0] === account)
|
||||||
if (events[i].returnValues[0] === account) {
|
|
||||||
results.push(await this.getEventData('exit', poolAddress, dtAddress, events[i]))
|
results.push(await this.getEventData('exit', poolAddress, dtAddress, events[i]))
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
results.push(await this.getEventData('exit', poolAddress, dtAddress, events[i]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
@ -500,9 +482,7 @@ export class OceanPool extends Pool {
|
|||||||
*/
|
*/
|
||||||
public async getAllPoolLogs(account: string): Promise<PoolTransaction[]> {
|
public async getAllPoolLogs(account: string): Promise<PoolTransaction[]> {
|
||||||
const results: PoolTransaction[] = []
|
const results: PoolTransaction[] = []
|
||||||
const factory = new this.web3.eth.Contract(this.factoryABI, this.factoryAddress, {
|
const factory = new this.web3.eth.Contract(this.factoryABI, this.factoryAddress)
|
||||||
from: account
|
|
||||||
})
|
|
||||||
const events = await factory.getPastEvents('BPoolRegistered', {
|
const events = await factory.getPastEvents('BPoolRegistered', {
|
||||||
filter: {},
|
filter: {},
|
||||||
fromBlock: 0,
|
fromBlock: 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user