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 back check for access list factory. #1889

Merged
merged 3 commits into from
Dec 18, 2024
Merged

Conversation

mariacarmina
Copy link
Member

Fixes # .

Changes proposed in this PR:

From this discussion #1868 (comment), I reopened the topic, that assignement does not check if the accessListFactory exists and throws this error for not EVM chains (for example in barge):
Error publishing asset: Cannot read properties of undefined (reading 'accessListFactory')

jamiehewitt15
jamiehewitt15 previously approved these changes Dec 10, 2024
Copy link
Member

@jamiehewitt15 jamiehewitt15 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@paulo-ocean
Copy link
Contributor

paulo-ocean commented Dec 10, 2024

this is definitely NOT OK

This:

if ('accessListFactory' in contractAddressesConfig) {
      config.accessListFactory = contractAddressesConfig.accessListFactory
}
 

Will break if contractAddressesConfig is null or undefined , which was the cause of
Error publishing asset: Cannot read properties of undefined (reading 'accessListFactory')

we cannot search for a property in something that does not exist, fyi:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/in_operator_no_object

You can simply, and safely, do as i suggested above

if(contractAddressesConfig) {
  config.accessListFactory = contractAddressesConfig.accessListFactory
}

@jamiehewitt15 jamiehewitt15 dismissed their stale review December 10, 2024 12:11

Yeah, Paulo makes a good point

@paulo-ocean
Copy link
Contributor

paulo-ocean commented Dec 18, 2024

you really like to complicate @mariacarmina , not sure why :-)

This:

if (contractAddressesConfig && 'accessListFactory' in contractAddressesConfig) {
      config.accessListFactory = contractAddressesConfig.accessListFactory
 }

Has exactly the same effect as my suggested change (bellow), except that you made you more complicate (2 checks instead of 1). Can't really understand why but anyway

if(contractAddressesConfig) {
  config.accessListFactory = contractAddressesConfig.accessListFactory
}

@mariacarmina
Copy link
Member Author

mariacarmina commented Dec 18, 2024

you really like to complicate @mariacarmina , not sure why :-)

This:

if (contractAddressesConfig && 'accessListFactory' in contractAddressesConfig) {
      config.accessListFactory = contractAddressesConfig.accessListFactory
 }

Has exactly the same effect as my suggested change (bellow), except that you made you more complicate (2 checks instead of 1). Can't really understand why but anyway

if(contractAddressesConfig) {
  config.accessListFactory = contractAddressesConfig.accessListFactory
}

I do not like to complicate @paulo-ocean :) but as I mentioned previously, the assignment is related to 'accessListFactory' -> so it is good practice to check as well if 'accessListFactory' is present in contractAddressesConfig, because not all the chains have accessListFactory key, because they are not confidential EVM. For me your check is incomplete, we surely need to check if contractAddressesConfig exists, but also if accessListFactory is present because that's what we want to assign. Please check https://github.com/oceanprotocol/contracts/blob/main/addresses/address.json and search 'AccessListFactory' and you'll see that only for oasis that key exists.

@paulo-ocean
Copy link
Contributor

paulo-ocean commented Dec 18, 2024

you really like to complicate @mariacarmina , not sure why :-)
This:

if (contractAddressesConfig && 'accessListFactory' in contractAddressesConfig) {
      config.accessListFactory = contractAddressesConfig.accessListFactory
 }

Has exactly the same effect as my suggested change (bellow), except that you made you more complicate (2 checks instead of 1). Can't really understand why but anyway

if(contractAddressesConfig) {
  config.accessListFactory = contractAddressesConfig.accessListFactory
}

I do not like to complicate @paulo-ocean :) but as I mentioned previously, the assignment is related to 'accessListFactory' -> so it is good practice to check as well if 'accessListFactory' is present in contractAddressesConfig, because not all the chains have accessListFactory key, because they are not confidential EVM. For me your check is incomplete, we surely need to check if contractAddressesConfig exists, but also if accessListFactory is present because that's what we want to assign. Please check https://github.com/oceanprotocol/contracts/blob/main/addresses/address.json and search 'AccessListFactory' and you'll see that only for oasis that key exists.

its exactly the same @mariacarmina ... but keep your ideas, i know nothing, just trying to help
but if you're curious :-), try to find the differences https://jsfiddle.net/r9evsbzy//

@mariacarmina
Copy link
Member Author

It worked with npm link on barge
Screenshot 2024-12-18 at 19 40 35

@mariacarmina mariacarmina merged commit ebd7359 into main Dec 18, 2024
11 checks passed
@mariacarmina mariacarmina deleted the fix-check-for-accesslist branch December 18, 2024 17:43
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.

3 participants