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

Nikos/5603/some default properties cannot set from contract class #5756

Merged

Conversation

nikoulai
Copy link
Contributor

Description

closes #5603

Checklist for 4.x:

  • I have selected the correct 4.x base branch.
  • Within the description, the feature or issue is discussed in detail or an issue is linked.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added any required tests for the changes I made
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules.
  • I ran yarn successfully
  • I ran yarn lint successfully
  • I ran yarn build:web successfully
  • I ran yarn test:unit successfully
  • I ran yarn test:integration successfully
  • I ran compile:contracts successfully
  • I have tested my code.
  • I have updated the corresponding CHANGELOG.md file in the packages I have edited.

@nikoulai nikoulai self-assigned this Jan 13, 2023
@nikoulai nikoulai added the 4.x 4.0 related label Jan 13, 2023
@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) January 16, 2023 09:43 Inactive
@cloudflare-pages
Copy link

cloudflare-pages bot commented Jan 16, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6c75f77
Status: ✅  Deploy successful!
Preview URL: https://db5c845c.web3-js-docs.pages.dev
Branch Preview URL: https://nikos-5603-some-default-prop.web3-js-docs.pages.dev

View logs

@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) January 24, 2023 11:21 Inactive
@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) January 24, 2023 11:22 Inactive
@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) January 24, 2023 11:23 Inactive
@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) January 27, 2023 12:07 Inactive
@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) January 27, 2023 12:08 Inactive
@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) February 3, 2023 13:01 Inactive
@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) February 3, 2023 15:19 Inactive
@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) February 3, 2023 15:50 Inactive
@spacesailor24
Copy link
Contributor

I think contractContext is just a copy of the context, which comes from self.getContextObject() here (any case), and subscribing doesn't have the effect we want.

@nikoulai contractContext is not a copy, it's a reference to the Web3Context the user is providing

const web3Context = new Web3Context('http://127.0.0.1:8545');
web3Context.defaultBlock = 'pending';

const contract = new Contract([], { syncWithContext: true }, web3Context);
console.log(contract.defaultBlock); // latest

web3Context.defaultBlock = 'earliest';

console.log(contract.defaultBlock); // earliest

(the console.log(contract.defaultBlock); // latest is a bug, as contract.defaultBlock should be pending as it's supposed to be set by web3Context)

The above code works as expected, but only if the following

if (contractContext !== undefined) {
    this.suscribeToGlobalEvents(contractContext);
}

occurs after the new line:

this.syncWithContext = (options as ContractInitOptions)?.syncWithContext ?? false;

@spacesailor24
Copy link
Contributor

@nikoulai I created an issue (#5817) to track calling suscribeToContextEvents within Contract's constructor as the needed fixes are not apart of the scope of the PR

Copy link
Contributor

@spacesailor24 spacesailor24 left a comment

Choose a reason for hiding this comment

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

G2g after above comment is addressed

@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) February 7, 2023 05:54 Inactive
@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) February 7, 2023 05:56 Inactive
@github-actions github-actions bot temporarily deployed to Preview: (nikos/5603/some-default-properties-cannot-set-from-Contract-class) February 7, 2023 05:56 Inactive
…ract-class' of https://github.com/web3/web3.js into nikos/5603/some-default-properties-cannot-set-from-Contract-class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x 4.0 related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants