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
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
private getEventData(action: string, poolAddress: string, data: any): PoolAction {
|
private getEventData(action: string, poolAddress: string, data: EventData): PoolAction {
|
||||||
const result = Object()
|
let result: PoolAction = {
|
||||||
result.action = action
|
poolAddress,
|
||||||
result.poolAddress = poolAddress
|
caller: data.returnValues[0],
|
||||||
result.caller = data.returnValues[0]
|
transactionHash: data.transactionHash,
|
||||||
result.transactionHash = data.transactionHash
|
blockNumber: data.blockNumber
|
||||||
result.blockNumber = data.blockNumber
|
}
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'swap':
|
case 'swap':
|
||||||
result.tokenIn = data.returnValues[1]
|
result = {
|
||||||
result.tokenOut = data.returnValues[2]
|
...result,
|
||||||
result.tokenAmountIn = data.returnValues[3]
|
tokenIn: data.returnValues[1],
|
||||||
result.tokenAmountOut = data.returnValues[4]
|
tokenOut: data.returnValues[2],
|
||||||
|
tokenAmountIn: data.returnValues[3],
|
||||||
|
tokenAmountOut: data.returnValues[4]
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case 'join':
|
case 'join':
|
||||||
result.tokenIn = data.returnValues[1]
|
result = {
|
||||||
result.tokenAmountIn = data.returnValues[2]
|
...result,
|
||||||
|
tokenIn: data.returnValues[1],
|
||||||
|
tokenAmountIn: data.returnValues[2]
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case 'exit':
|
case 'exit':
|
||||||
result.tokenOut = data.returnValues[1]
|
result = {
|
||||||
result.tokenAmountOut = data.returnValues[2]
|
...result,
|
||||||
|
tokenOut: data.returnValues[1],
|
||||||
|
tokenAmountOut: data.returnValues[2]
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import defaultFixedRateExchangeABI from '@oceanprotocol/contracts/artifacts/FixedRateExchange.json'
|
import defaultFixedRateExchangeABI from '@oceanprotocol/contracts/artifacts/FixedRateExchange.json'
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import { TransactionReceipt } from 'web3-core'
|
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 { AbiItem } from 'web3-utils/types'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
|
|
||||||
@ -434,17 +434,13 @@ export class OceanFixedRateExchange {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private getEventData(data: any): FixedPricedSwap {
|
private getEventData(data: EventData): FixedPricedSwap {
|
||||||
const result: FixedPricedSwap = {
|
const result: FixedPricedSwap = {
|
||||||
exchangeID: null,
|
exchangeID: data.returnValues[0],
|
||||||
caller: null,
|
caller: data.returnValues[1],
|
||||||
baseTokenAmount: null,
|
baseTokenAmount: data.returnValues[2],
|
||||||
dataTokenAmount: null
|
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
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user