-
Notifications
You must be signed in to change notification settings - Fork 71
Remove circular dependencies, fix imports and improve build #1881
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
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dce77b1
first pass
paulo-ocean 795dcc3
2nd pass
paulo-ocean bd519f3
3rd pass
paulo-ocean bf94e10
4th pass
paulo-ocean 60d0272
done
paulo-ocean 8533904
fix import on test
paulo-ocean 7a7e27b
Merge branch 'main' into issue-1872-circular-deps
paulo-ocean 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
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,90 @@ | ||
| import { ethers, Signer } from 'ethers' | ||
| import { NftFactory } from '../contracts/NFTFactory' | ||
| import fs from 'fs' | ||
| // eslint-disable-next-line import/no-named-default | ||
| import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20Template.sol/IERC20Template.json' | ||
| // eslint-disable-next-line import/no-named-default | ||
| import { default as Addresses } from '@oceanprotocol/contracts/addresses/address.json' | ||
| /** | ||
| * Get the artifacts address from the address.json file | ||
| * either from the env or from the ocean-contracts dir | ||
| * @returns data or null | ||
| */ | ||
| export function getOceanArtifactsAdresses(): any { | ||
| try { | ||
| if (process.env.ADDRESS_FILE) { | ||
| // eslint-disable-next-line security/detect-non-literal-fs-filename | ||
| const data = fs.readFileSync(process.env.ADDRESS_FILE, 'utf8') | ||
| return JSON.parse(data) | ||
| } | ||
| return Addresses | ||
| } catch (error) { | ||
| return Addresses | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Get the artifacts address from the address.json file, for the given chain | ||
| * either from the env or from the ocean-contracts dir, safer than above, because sometimes the network name | ||
| * is mispeled, best example "optimism_sepolia" vs "optimism-sepolia" | ||
| * @returns data or null | ||
| */ | ||
| export function getOceanArtifactsAdressesByChainId(chain: number): any { | ||
| try { | ||
| // eslint-disable-next-line security/detect-non-literal-fs-filename | ||
| const data = getOceanArtifactsAdresses() | ||
| if (data) { | ||
| const networks = Object.keys(data) | ||
| for (const network of networks) { | ||
| if (data[network].chainId === chain) { | ||
| return data[network] | ||
| } | ||
| } | ||
| } | ||
| } catch (error) { | ||
| console.error(error) | ||
| } | ||
| return null | ||
| } | ||
| /** | ||
| * Use this function to accurately calculate the template index, and also checking if the template is active | ||
| * @param owner the signer account | ||
| * @param nftContractAddress the nft contract address, usually artifactsAddresses.ERC721Factory | ||
| * @param template the template ID or template address (from smart contract getId() function) | ||
| * @returns index of the template on the list | ||
| */ | ||
| export async function calculateActiveTemplateIndex( | ||
| owner: Signer, | ||
| nftContractAddress: string, // addresses.ERC721Factory, | ||
| template: string | number | ||
| ): Promise<number> { | ||
| // is an ID number? | ||
| const isTemplateID = typeof template === 'number' | ||
|
|
||
| const factoryERC721 = new NftFactory(nftContractAddress, owner) | ||
| const currentTokenCount = await factoryERC721.getCurrentTokenTemplateCount() | ||
| for (let i = 1; i <= currentTokenCount; i++) { | ||
| const tokenTemplate = await factoryERC721.getTokenTemplate(i) | ||
|
|
||
| const erc20Template = new ethers.Contract( | ||
| tokenTemplate.templateAddress, | ||
| ERC20Template.abi, | ||
| owner | ||
| ) | ||
|
|
||
| // check for ID | ||
| if (isTemplateID) { | ||
| const id = await erc20Template.connect(owner).getId() | ||
| if (tokenTemplate.isActive && id.toString() === template.toString()) { | ||
| return i | ||
| } | ||
| } else if ( | ||
| tokenTemplate.isActive && | ||
| tokenTemplate.templateAddress === template.toString() | ||
| ) { | ||
| return i | ||
| } | ||
| } | ||
| // if nothing is found it returns -1 | ||
| return -1 | ||
| } |
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.