Skip to content
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

Add support for map of contract addresses in getInstance function #239

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

yavrsky
Copy link

@yavrsky yavrsky commented Dec 30, 2024

What was done

  • Enhanced the getInstance function in the Project class to support passing a map of contract addresses.

Motivation

  • Improved the flexibility and functionality of the skale-contracts library by enabling the getInstance function to accept a set of contract addresses in addition to the alias and main contract address.
  • This feature is particularly useful for scenarios where:
    - No main contract address is defined for a specific project.
    - Additional or alternative contract configurations are required for different use cases.

No need for QA to test

@yavrsky yavrsky requested a review from DimaStebaev as a code owner December 30, 2024 15:42
@yavrsky yavrsky changed the title Set of contract addresses as argument in getInstance function Enhance getInstance Function to Support Map of Contract Addresses for Greater Flexibility in skale-contracts Jan 8, 2025
@yavrsky yavrsky changed the title Enhance getInstance Function to Support Map of Contract Addresses for Greater Flexibility in skale-contracts Add Support for map of contract addresses in getInstance function Jan 8, 2025
@yavrsky yavrsky changed the title Add Support for map of contract addresses in getInstance function Add support for map of contract addresses in getInstance function Jan 8, 2025
if (this.network.adapter.isAddress(aliasOrAddress)) {
return this.getInstanceByAddress(aliasOrAddress);
getInstance (target: string | MainContractAddress | ContractAddressMap) {
const isStringAndAddress =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition can be simplified.

getAbiFilename (version: string) {
return `${this.metadata.name}-${version}-abi.json`;
}

createInstance (address: string): Instance<ContractType> {
createInstance (target: MainContractAddress | ContractAddressMap)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let it be address in assumption that ContractAddressMap is also an "address" in some sense?
For me target is too confusion because it's not clear what to pass.

@yavrsky yavrsky self-assigned this Jan 8, 2025
) {
this.project = project;
this.address = address;
if (typeof address === "string") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with isContractAddressMap?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance getInstance function to support contract address maps in project class
2 participants