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

Smart contract sdk support #508

Merged
merged 38 commits into from
Oct 24, 2024
Merged

Smart contract sdk support #508

merged 38 commits into from
Oct 24, 2024

Conversation

nplasterer
Copy link
Contributor

Pulled and cleaned up the SDK pieces from #501

@nplasterer nplasterer self-assigned this Oct 2, 2024
@nplasterer nplasterer changed the base branch from main to beta October 2, 2024 22:24
@nplasterer nplasterer changed the base branch from beta to main October 20, 2024 18:07
@nplasterer nplasterer marked this pull request as ready for review October 24, 2024 03:15
@nplasterer nplasterer requested a review from a team as a code owner October 24, 2024 03:15
self.module = module
self.address = address
self.walletType = walletType
self.chainId = chainId
self.blockNumber = blockNumber
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need the block number to be stored on the signer. That should get resolved at the time of signing, not on instantiation, since the block number keeps incrementing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We store it on the SigningKey so it only gets passed in from the SigningKey which means we only have it when the signing key is present which is only when something is being signed. Unfortunately with the bridge this is how it has to be passed. But this and the below shouldn't be exposed to users so it should be an internal matter.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. I can approve the PR. Still feels wrong to get that block number even one second before we actually sign the message, since it's going to be older than the block the signature was actually generated on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm okay maybe we need to rethink how I have this setup inside the other sdks as well. 🤔

As they all work the same with the block number as part of the signingKey https://github.com/xmtp/xmtp-android/blob/main/library/src/main/java/org/xmtp/android/library/SigningKey.kt#L31-L34 But maybe it should be passed as a param to create instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally it would get pulled from the chain at the same time you are signing the message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another way of thinking about it would be to have a getBlockNumber method that is only implemented on SCWs, which we could call from our SDKs when we are gathering a smart contract signature.

historySyncUrl?: string | undefined,
walletType?: WalletType | undefined,
chainId?: number | undefined,
blockNumber?: number | undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think we need the block number here either. This only matters when you are actually signing something.

@nplasterer nplasterer merged commit 8199e76 into main Oct 24, 2024
5 of 6 checks passed
@nplasterer nplasterer deleted the np/smart-contract-sdk-support branch October 24, 2024 23:00
Copy link

🎉 This PR is included in version 2.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants