Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ jobs:
working-directory: ${{ github.workspace }}/barge
run: |
bash -x start_ocean.sh --no-node --with-typesense 2>&1 > start_ocean.log &
env:
CONTRACTS_VERSION: '2.9.0'
- run: npm ci
- run: npm run build
- run: docker image ls
Expand Down Expand Up @@ -226,6 +228,8 @@ jobs:
working-directory: ${{ github.workspace }}/barge
run: |
bash -x start_ocean.sh --no-node --with-typesense 2>&1 > start_ocean.log &
env:
CONTRACTS_VERSION: '2.9.0'
- run: docker image ls
- name: Delete default runner images
run: |
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@libp2p/upnp-nat": "^4.0.9",
"@libp2p/websockets": "^10.1.2",
"@multiformats/multiaddr": "^12.2.3",
"@oceanprotocol/contracts": "^2.7.0",
"@oceanprotocol/contracts": "^2.9.0",
"@oceanprotocol/ddo-js": "^0.4.0",
"axios": "^1.15.0",
"base58-js": "^2.0.0",
Expand Down
3 changes: 3 additions & 0 deletions src/@types/Escrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ export interface EscrowEvent {
maxLockedAmount?: string
maxLockSeconds?: string
maxLockCounts?: string
oldAmount?: string
newAmount?: string
newExpiry?: string
}
1 change: 1 addition & 0 deletions src/components/Indexer/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const EVENT_PROCESSOR_MAP: Record<string, ProcessorConstructor> = {
[EVENTS.ADDRESS_REMOVED]: AddressRemovedEventProcessor,
[EVENTS.ESCROW_AUTH]: EscrowEventProcessor,
[EVENTS.ESCROW_LOCK]: EscrowEventProcessor,
[EVENTS.ESCROW_RELOCK]: EscrowEventProcessor,
[EVENTS.ESCROW_CLAIMED]: EscrowEventProcessor,
[EVENTS.ESCROW_CANCELED]: EscrowEventProcessor,
[EVENTS.ESCROW_DEPOSIT]: EscrowEventProcessor,
Expand Down
10 changes: 10 additions & 0 deletions src/components/Indexer/processors/EscrowEventProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class EscrowEventProcessor extends BaseEventProcessor {
case EVENTS.ESCROW_AUTH:
record.payer = addr(args.payer)
record.payee = addr(args.payee)
record.token = addr(args.token)
record.maxLockedAmount = num(args.maxLockedAmount)
record.maxLockSeconds = num(args.maxLockSeconds)
record.maxLockCounts = num(args.maxLockCounts)
Expand All @@ -69,6 +70,15 @@ export class EscrowEventProcessor extends BaseEventProcessor {
record.expiry = num(args.expiry)
record.token = addr(args.token)
break
case EVENTS.ESCROW_RELOCK:
record.payer = addr(args.payer)
record.payee = addr(args.payee)
record.jobId = num(args.jobId)
record.oldAmount = num(args.oldAmount)
record.newAmount = num(args.newAmount)
record.newExpiry = num(args.newExpiry)
record.token = addr(args.token)
break
case EVENTS.ESCROW_CLAIMED:
record.payee = addr(args.payee)
record.jobId = num(args.jobId)
Expand Down
5 changes: 4 additions & 1 deletion src/components/database/ElasticSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ export const elasticSchemas: ElasticsearchSchemas = {
proof: { type: 'text' },
maxLockedAmount: { type: 'text' },
maxLockSeconds: { type: 'text' },
maxLockCounts: { type: 'text' }
maxLockCounts: { type: 'text' },
oldAmount: { type: 'text' },
newAmount: { type: 'text' },
newExpiry: { type: 'text' }
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/database/TypesenseSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ export const typesenseSchemas: TypesenseSchemas = {
{ name: 'proof', type: 'string', optional: true, index: false },
{ name: 'maxLockedAmount', type: 'string', optional: true },
{ name: 'maxLockSeconds', type: 'string', optional: true },
{ name: 'maxLockCounts', type: 'string', optional: true }
{ name: 'maxLockCounts', type: 'string', optional: true },
// ReLock event fields (uint256 kept as raw strings)
{ name: 'oldAmount', type: 'string', optional: true },
{ name: 'newAmount', type: 'string', optional: true },
{ name: 'newExpiry', type: 'string', optional: true }
]
}
}
36 changes: 35 additions & 1 deletion src/test/integration/escrow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ describe('Indexer stores Escrow contract events', () => {
const event = events[0]
expect(event.payer).to.equal(payerAddress.toLowerCase())
expect(event.payee).to.equal(payeeAddress.toLowerCase())
expect(event.token).to.equal(paymentToken.toLowerCase())
expect(event.maxLockedAmount).to.equal(depositAmount.toString())
expect(event.maxLockCounts).to.equal('10')
})
Expand Down Expand Up @@ -223,6 +224,39 @@ describe('Indexer stores Escrow contract events', () => {
expect(event.token).to.equal(paymentToken.toLowerCase())
})

it('indexes a ReLock event', async function () {
if (!escrowAddress || !paymentToken) this.skip()
this.timeout(DEFAULT_TEST_TIMEOUT * 3)

// reLock adjusts the amount/expiry of the lock created in the previous test
// for the same jobId, preserving the original creation timestamp. The new
// expiry is a duration-from-now capped by (creationTimestamp + maxLockSeconds),
// so use a value well below `expiry` (== maxLockSeconds) to leave headroom for
// the wall-clock time spent waiting on the Lock event to be indexed above.
const newLockAmount = parseUnits('20', 18)
const reLockExpiry = Math.floor(expiry / 2)
const tx = await escrowContract
.connect(publisherAccount)
.reLock(jobId, paymentToken, payerAddress, newLockAmount, reLockExpiry)
const receipt = await tx.wait()
const reLockTxHash = receipt.hash

const events = await waitForEscrowEvents({
txHash: reLockTxHash,
eventType: EVENTS.ESCROW_RELOCK
})
assert(events && events.length > 0, 'ReLock event should be indexed')
const event = events[0]
expect(event.payer).to.equal(payerAddress.toLowerCase())
expect(event.payee).to.equal(payeeAddress.toLowerCase())
expect(event.jobId).to.equal(jobId.toString())
expect(event.oldAmount).to.equal(lockAmount.toString())
expect(event.newAmount).to.equal(newLockAmount.toString())
expect(event.token).to.equal(paymentToken.toLowerCase())
// expiry is emitted as an absolute timestamp; just assert it is populated
assert(event.newExpiry, 'newExpiry should be populated')
})

it('returns indexed events through the EscrowEventsHandler (query command)', async function () {
if (!escrowAddress || !paymentToken) this.skip()
this.timeout(DEFAULT_TEST_TIMEOUT)
Expand All @@ -246,7 +280,7 @@ describe('Indexer stores Escrow contract events', () => {

it('respects offset and size pagination', async function () {
if (!escrowAddress || !paymentToken) this.skip()
// Deposit, Auth and Lock are all indexed for this chain by now (>= 2 rows).
// Deposit, Auth, Lock and ReLock are all indexed for this chain by now (>= 2 rows).
const page = await database.escrow.search({ chainId }, 0, 2)
assert(page && page.length === 2, 'size should cap the page to 2 rows')

Expand Down
10 changes: 8 additions & 2 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export const EVENTS = {
// Escrow contract events. Values must equal the on-chain event name.
ESCROW_AUTH: 'Auth',
ESCROW_LOCK: 'Lock',
ESCROW_RELOCK: 'ReLock',
ESCROW_CLAIMED: 'Claimed',
ESCROW_CANCELED: 'Canceled',
ESCROW_DEPOSIT: 'Deposit',
Expand All @@ -141,6 +142,7 @@ export const EVENTS = {
export const ESCROW_EVENTS = [
EVENTS.ESCROW_AUTH,
EVENTS.ESCROW_LOCK,
EVENTS.ESCROW_RELOCK,
EVENTS.ESCROW_CLAIMED,
EVENTS.ESCROW_CANCELED,
EVENTS.ESCROW_DEPOSIT,
Expand Down Expand Up @@ -227,14 +229,18 @@ export const EVENT_HASHES: Hashes = {
type: EVENTS.NEW_ACCESS_LIST,
text: 'NewAccessList(address,address)'
},
'0x118cb6c6a02e26bfdb39cab8d70573499942c4ee3f0d7616d3c4100fe9163d9d': {
'0x5a3021f46552b1ac3c96e967ff1ecfeb100603ccc2940941cad97db3ee2baec7': {
type: EVENTS.ESCROW_AUTH,
text: 'Auth(address,address,uint256,uint256,uint256)'
text: 'Auth(address,address,address,uint256,uint256,uint256)'
},
'0xb746b0421b0b98debe76bb312ec9fb701603af22ddb107f7e639b0187e4ff880': {
type: EVENTS.ESCROW_LOCK,
text: 'Lock(address,address,uint256,uint256,uint256,address)'
},
'0x1ccec59cf72b2788d240da471a5a929af5babf4b9f1f5edafbe4ccb832d20211': {
type: EVENTS.ESCROW_RELOCK,
text: 'ReLock(address,address,uint256,uint256,uint256,uint256,address)'
},
'0x77aeb72af8b0efaf7fd8c746d2fb78653ae489dd88dea7a851cb354e4cdc4eed': {
type: EVENTS.ESCROW_CLAIMED,
text: 'Claimed(address,uint256,address,address,uint256,bytes)'
Expand Down
Loading