Repository navigation
add global enterprise toggle, control escrow type #1634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { expect } from 'chai' | ||
| import { ethers } from 'ethers' | ||
| import { getEscrowAddressForChain } from '../../utils/address.js' | ||
| import { Escrow } from '../../components/core/utils/escrow.js' | ||
| import { retrieveChunkEvents } from '../../components/Indexer/utils.js' | ||
| // processor.js first: importing a processor module directly trips the processors' import cycle | ||
| import '../../components/Indexer/processor.js' | ||
| import { EscrowEventProcessor } from '../../components/Indexer/processors/EscrowEventProcessor.js' | ||
| import { OceanNodeConfig } from '../../@types/OceanNode.js' | ||
|
|
||
| // Addresses from the bundled ocean-contracts address file. | ||
| // Optimism: both Escrow and EnterpriseEscrow are deployed. | ||
| const CHAIN_WITH_ENTERPRISE = 10 | ||
| const ESCROW_ON_OPTIMISM = '0x9497d1d64F2aFeBcd4f9916Eef3d9094E5Df962f' | ||
| const ENTERPRISE_ESCROW_ON_OPTIMISM = '0x7b0576CF01E868bce46cca91b2a8E674141b0355' | ||
| // Base: only Escrow is deployed. | ||
| const CHAIN_WITHOUT_ENTERPRISE = 8453 | ||
| const ESCROW_ON_BASE = '0x09c9a4010E106b9673DcD58AB021a2C84457f323' | ||
| const UNKNOWN_CHAIN = 999999999 | ||
|
|
||
| describe('Escrow contract selection (IS_ENTERPRISE)', () => { | ||
| describe('getEscrowAddressForChain', () => { | ||
| it('returns Escrow when not enterprise, even where EnterpriseEscrow is deployed', () => { | ||
| expect(getEscrowAddressForChain(CHAIN_WITH_ENTERPRISE)).to.equal(ESCROW_ON_OPTIMISM) | ||
| expect(getEscrowAddressForChain(CHAIN_WITH_ENTERPRISE, false)).to.equal( | ||
| ESCROW_ON_OPTIMISM | ||
| ) | ||
| }) | ||
|
|
||
| it('returns EnterpriseEscrow for an enterprise node', () => { | ||
| expect(getEscrowAddressForChain(CHAIN_WITH_ENTERPRISE, true)).to.equal( | ||
| ENTERPRISE_ESCROW_ON_OPTIMISM | ||
| ) | ||
| }) | ||
|
|
||
| it('falls back to Escrow for an enterprise node where EnterpriseEscrow is missing', () => { | ||
| expect(getEscrowAddressForChain(CHAIN_WITHOUT_ENTERPRISE, true)).to.equal( | ||
| ESCROW_ON_BASE | ||
| ) | ||
| }) | ||
|
|
||
| it('returns null on a chain without any escrow', () => { | ||
| expect(getEscrowAddressForChain(UNKNOWN_CHAIN)).to.equal(null) | ||
| expect(getEscrowAddressForChain(UNKNOWN_CHAIN, true)).to.equal(null) | ||
| }) | ||
| }) | ||
|
|
||
| it('core Escrow pays through the contract matching the toggle', () => { | ||
| const community = new Escrow({} as any, 3600, {} as any, null) | ||
| const enterprise = new Escrow({} as any, 3600, {} as any, null, false, true) | ||
| expect(community.getEscrowContractAddressForChain(CHAIN_WITH_ENTERPRISE)).to.equal( | ||
| ESCROW_ON_OPTIMISM | ||
| ) | ||
| expect(enterprise.getEscrowContractAddressForChain(CHAIN_WITH_ENTERPRISE)).to.equal( | ||
| ENTERPRISE_ESCROW_ON_OPTIMISM | ||
| ) | ||
| }) | ||
|
|
||
| it('indexer escrow processor tracks the same contract as core Escrow', () => { | ||
| const processorAddress = (isEnterprise: boolean) => | ||
| ( | ||
| new EscrowEventProcessor(CHAIN_WITH_ENTERPRISE, { | ||
| isEnterprise | ||
| } as OceanNodeConfig) as any | ||
| ).escrowAddress | ||
| expect(processorAddress(false)).to.equal(ESCROW_ON_OPTIMISM) | ||
| expect(processorAddress(true)).to.equal(ENTERPRISE_ESCROW_ON_OPTIMISM) | ||
| }) | ||
|
|
||
| it('indexer chunk query address-filters escrow events on EnterpriseEscrow', async () => { | ||
| const calls: any[] = [] | ||
| const provider = { | ||
| getLogs: (filter: any): Promise<ethers.Log[]> => { | ||
| calls.push(filter) | ||
| return Promise.resolve([]) | ||
| } | ||
| } | ||
| await retrieveChunkEvents(null as any, provider as any, CHAIN_WITH_ENTERPRISE, 0, 10) | ||
| await retrieveChunkEvents( | ||
| null as any, | ||
| provider as any, | ||
| CHAIN_WITH_ENTERPRISE, | ||
| 0, | ||
| 10, | ||
| true | ||
| ) | ||
| const escrowFilters = calls.filter((c) => c.address !== undefined) | ||
| expect(escrowFilters.map((c) => c.address)).to.deep.equal([ | ||
| ESCROW_ON_OPTIMISM, | ||
| ENTERPRISE_ESCROW_ON_OPTIMISM | ||
| ]) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.