mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-06-16 01:13:25 +02:00
* Adding providerFee to Order in the schema * Adding ProviderFee to subgraph.template.yaml * Creating order utils * Saving providerFee as a string * Saving providerFee as an array of all previous provider fees * Creating test for providerFee * Removing arrary from providerFee * Updating or Creating OrderResue provider fee * lint:fix * Creating additional tests for testing providerFees on Order and reuseOrder * lint:fix * Updating JSON string notation * Fixing first test * fixing second test: testing provider fees after calling reuseOrder on a using a previous txId * added providerFeeValidUntil Co-authored-by: mihaisc <mihai@oceanprotocol.com>
28 lines
608 B
TypeScript
28 lines
608 B
TypeScript
import { Order } from '../../@types/schema'
|
|
|
|
export function getOrderId(
|
|
tx: string,
|
|
tokenAddress: string,
|
|
fromAddress: string
|
|
): string {
|
|
return `${tx}-${tokenAddress}-${fromAddress}`
|
|
}
|
|
|
|
export function createOrder(orderId: string): Order {
|
|
const order = new Order(orderId)
|
|
return order
|
|
}
|
|
|
|
export function getOrder(
|
|
transactionHash: string,
|
|
address: string,
|
|
transactionFrom: string
|
|
): Order {
|
|
const orderId = getOrderId(transactionHash, address, transactionFrom)
|
|
let newOrder = Order.load(orderId)
|
|
if (newOrder === null) {
|
|
newOrder = createOrder(orderId)
|
|
}
|
|
return newOrder
|
|
}
|