-
Notifications
You must be signed in to change notification settings - Fork 102
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
feat: integrate with divvy protocol #6492
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6492 +/- ##
==========================================
+ Coverage 89.04% 89.08% +0.04%
==========================================
Files 732 732
Lines 31847 31930 +83
Branches 6139 6150 +11
==========================================
+ Hits 28358 28446 +88
+ Misses 3442 3287 -155
- Partials 47 197 +150
... and 68 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! 🚀
I like that this saves complexity for builders!
Like we discussed, I'm just slightly sad that they need to know about this extra transaction if they access the returned prepared transactions. But I don't have a good alternative 🤷 🤔
@@ -22,3 +35,153 @@ export function isRegistrationTransaction(tx: TransactionRequest | SerializableT | |||
return false | |||
} | |||
} | |||
|
|||
export async function createRegistrationTransactions({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: to make it more explicit about what it does
export async function createRegistrationTransactions({ | |
export async function createRegistrationTransactionsIfNeeded({ |
src/viem/prepareTransactions.test.ts
Outdated
@@ -139,6 +142,57 @@ describe('prepareTransactions module', () => { | |||
} | |||
const mockPublicClient = {} as unknown as jest.Mocked<(typeof publicClient)[Network.Celo]> | |||
describe('prepareTransactions function', () => { | |||
it('adds divvi registration transactions to the prepared transactions if there are any', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('adds divvi registration transactions to the prepared transactions if there are any', async () => { | |
it('adds divvi registration transactions to the prepared transactions if needed', async () => { |
nonce = yield* call( | ||
sendPreparedRegistrationTransactions, | ||
preparedRegistrationTransactions, | ||
networkId, | ||
wallet, | ||
nonce | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this shouldn't be waiting for registration TX receipt internally.
Otherwise it degrades the UX, especially on networks with longer block times.
Can we spawn the wait in sendPreparedRegistrationTransactions
instead?
src/viem/saga.test.ts
Outdated
const mockSendPreparedRegistrationTransactions = jest.fn() | ||
jest.mock('src/divviProtocol/registerReferral', () => ({ | ||
...jest.requireActual('src/divviProtocol/registerReferral'), | ||
sendPreparedRegistrationTransactions: (...args: any[]) => | ||
mockSendPreparedRegistrationTransactions(...args), | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this pattern is a bit nicer for type-safety
const mockSendPreparedRegistrationTransactions = jest.fn() | |
jest.mock('src/divviProtocol/registerReferral', () => ({ | |
...jest.requireActual('src/divviProtocol/registerReferral'), | |
sendPreparedRegistrationTransactions: (...args: any[]) => | |
mockSendPreparedRegistrationTransactions(...args), | |
})) | |
import { sendPreparedRegistrationTransactions } from 'src/divviProtocol/registerReferral' | |
jest.mock('src/divviProtocol/registerReferral', () => ({ | |
...jest.requireActual('src/divviProtocol/registerReferral'), | |
sendPreparedRegistrationTransactions: jest.fn() | |
})) | |
const mockSendPreparedRegistrationTransactions = jest.mocked(sendPreparedRegistrationTransactions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i actually did try this pattern before and lost a bunch of time trying to fix the the typescript error Argument of type 'number' is not assignable to parameter of type 'never'.
when i try to do mockSendPreparedRegistrationTransactions.mockResolvedValue(11)
. and now i realise, it's a generator function and i don't need to mock it like this at all 🤦🏻♀️ i've updated this test to provide mocks via .provide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already approved with a suggestion.
Logger.error( | ||
`${TAG}/sendPreparedRegistrationTransactions`, | ||
`Failed to send or parse prepared registration transaction`, | ||
error | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we wanna let this bubble up?
so we don't send the other transactions if we're not able to submit the TX for registering?
reducing the chance to have unattributed transactions
Description
This PR integrates the divvy protocol into the transaction flows:
Test plan
Related issues
Backwards compatibility
Network scalability
If a new NetworkId and/or Network are added in the future, the changes in this PR will: