mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
getEventData refactor
This commit is contained in:
parent
122fc40f63
commit
63e01ee858
@ -555,27 +555,37 @@ export class OceanPool extends Pool {
|
||||
return results
|
||||
}
|
||||
|
||||
private getEventData(action: string, poolAddress: string, data: any): PoolAction {
|
||||
const result = Object()
|
||||
result.action = action
|
||||
result.poolAddress = poolAddress
|
||||
result.caller = data.returnValues[0]
|
||||
result.transactionHash = data.transactionHash
|
||||
result.blockNumber = data.blockNumber
|
||||
private getEventData(action: string, poolAddress: string, data: EventData): PoolAction {
|
||||
let result: PoolAction = {
|
||||
poolAddress,
|
||||
caller: data.returnValues[0],
|
||||
transactionHash: data.transactionHash,
|
||||
blockNumber: data.blockNumber
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case 'swap':
|
||||
result.tokenIn = data.returnValues[1]
|
||||
result.tokenOut = data.returnValues[2]
|
||||
result.tokenAmountIn = data.returnValues[3]
|
||||
result.tokenAmountOut = data.returnValues[4]
|
||||
result = {
|
||||
...result,
|
||||
tokenIn: data.returnValues[1],
|
||||
tokenOut: data.returnValues[2],
|
||||
tokenAmountIn: data.returnValues[3],
|
||||
tokenAmountOut: data.returnValues[4]
|
||||
}
|
||||
break
|
||||
case 'join':
|
||||
result.tokenIn = data.returnValues[1]
|
||||
result.tokenAmountIn = data.returnValues[2]
|
||||
result = {
|
||||
...result,
|
||||
tokenIn: data.returnValues[1],
|
||||
tokenAmountIn: data.returnValues[2]
|
||||
}
|
||||
break
|
||||
case 'exit':
|
||||
result.tokenOut = data.returnValues[1]
|
||||
result.tokenAmountOut = data.returnValues[2]
|
||||
result = {
|
||||
...result,
|
||||
tokenOut: data.returnValues[1],
|
||||
tokenAmountOut: data.returnValues[2]
|
||||
}
|
||||
break
|
||||
}
|
||||
return result
|
||||
|
@ -1,7 +1,7 @@
|
||||
import defaultFixedRateExchangeABI from '@oceanprotocol/contracts/artifacts/FixedRateExchange.json'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
import { Contract } from 'web3-eth-contract'
|
||||
import { Contract, EventData } from 'web3-eth-contract'
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
import Web3 from 'web3'
|
||||
|
||||
@ -434,17 +434,13 @@ export class OceanFixedRateExchange {
|
||||
return result
|
||||
}
|
||||
|
||||
private getEventData(data: any): FixedPricedSwap {
|
||||
private getEventData(data: EventData): FixedPricedSwap {
|
||||
const result: FixedPricedSwap = {
|
||||
exchangeID: null,
|
||||
caller: null,
|
||||
baseTokenAmount: null,
|
||||
dataTokenAmount: null
|
||||
exchangeID: data.returnValues[0],
|
||||
caller: data.returnValues[1],
|
||||
baseTokenAmount: data.returnValues[2],
|
||||
dataTokenAmount: data.returnValues[3]
|
||||
}
|
||||
result.exchangeID = data.returnValues[0]
|
||||
result.caller = data.returnValues[1]
|
||||
result.baseTokenAmount = data.returnValues[2]
|
||||
result.dataTokenAmount = data.returnValues[3]
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user