-
Notifications
You must be signed in to change notification settings - Fork 8
[sdk]: Add IntentsV2 #264
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
[sdk]: Add IntentsV2 #264
Conversation
8a40e99 to
a988a99
Compare
royvardhan
left a comment
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.
Thinking....
|
Since filler will be heavily dependent on this class. I will add cache service here when I work on the filler. |
| if (intentGatewayV2Address) { | ||
| const paramsSlot5 = pad(toHex(5n), { size: 32 }) as HexString | ||
| const currentSlot5Value = await this.dest.client.getStorageAt({ | ||
| address: intentGatewayV2Address, | ||
| slot: paramsSlot5, | ||
| }) | ||
| // Set solverSelection to 0x00 while preserving dispatcher | ||
| const currentValue = currentSlot5Value || "0x" + "0".repeat(64) | ||
| const newSlot5Value = (currentValue.slice(0, 24) + "00" + currentValue.slice(26)) as HexString | ||
| overrides.push({ | ||
| address: intentGatewayV2Address, | ||
| stateDiff: [{ slot: paramsSlot5, value: newSlot5Value }], | ||
| }) | ||
| } |
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'm not sure why we need to query this at all before overriding it.
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.
Because this slot contains the dispatcher and the solver selection packed.
If we are not changing the dispatcher address then we can have the dispatcher stored locally and can override without querying first.
| // ========================================================================= | ||
|
|
||
| /** Builds state overrides for token balances and allowances to enable gas estimation */ | ||
| private async buildTokenStateOverrides( |
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.
this method should not be 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.
Ohh yeah, missed this. It was using tracer before, now using config values.
| let protocolFeeInNativeToken = await this.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(() => | ||
| this.dest.quoteNative(postRequest, postRequestFeeInDestFeeToken).catch(() => 0n), | ||
| ) |
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.
A bit confusing as to why we don't just use the dest.quoteNative exclusively?
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.
Because direct contract call for IntentGateway.quoteNative() is just one rpc call. This will fail for some chains where we have the wrapper.
While EvmChain.quoteNative() is three rpc calls:
host.perByteFee()
host.feeToken()
uniswap.getAmountsIn()
Related to #263
Adds
IntentGatewayV2class to the SDK for interacting with the V2 intent gateway contract.preparePlaceOrder- Generates session key, stores it, and returns placeOrder calldataestimateFillOrderV2- Estimates gas used for filling an order, includes smart account verification costs.prepareSubmitBid- Constructs UserOperation for fillers to submit bids to HyperbridgesignSolverSelection- Signs EIP-712 solver selection with stored session key