From 33c0395f014de21d1e2986ac3b7ba24f0b74f1c2 Mon Sep 17 00:00:00 2001 From: kopy-kat Date: Wed, 17 Dec 2025 15:20:47 +0000 Subject: [PATCH 1/3] feat: add contract remediation changes --- src/execution/compact.ts | 22 ++++++++-------------- src/execution/permit2.ts | 24 +++++++++--------------- src/execution/singleChainOps.ts | 24 ++++++++++++++++++------ src/execution/utils.ts | 6 +----- src/orchestrator/types.ts | 12 ++++++++---- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/execution/compact.ts b/src/execution/compact.ts index aaa540e1..2aadcc0b 100644 --- a/src/execution/compact.ts +++ b/src/execution/compact.ts @@ -25,10 +25,9 @@ const COMPACT_TYPED_DATA_TYPES = { ], Mandate: [ { name: 'target', type: 'Target' }, - { name: 'v', type: 'uint8' }, { name: 'minGas', type: 'uint128' }, - { name: 'originOps', type: 'Op[]' }, - { name: 'destOps', type: 'Op[]' }, + { name: 'originOps', type: 'Op' }, + { name: 'destOps', type: 'Op' }, { name: 'q', type: 'bytes32' }, ], Target: [ @@ -42,6 +41,10 @@ const COMPACT_TYPED_DATA_TYPES = { { name: 'amount', type: 'uint256' }, ], Op: [ + { name: 'vt', type: 'bytes32' }, + { name: 'ops', type: 'Ops[]' }, + ], + Ops: [ { name: 'to', type: 'address' }, { name: 'value', type: 'uint256' }, { name: 'data', type: 'bytes' }, @@ -80,18 +83,9 @@ function getCompactTypedData(intentOp: IntentOp) { targetChain: BigInt(element.mandate.destinationChainId), fillExpiry: BigInt(element.mandate.fillDeadline), }, - v: element.mandate.v, minGas: BigInt(element.mandate.minGas), - originOps: element.mandate.preClaimOps.map((op) => ({ - to: op.to, - value: BigInt(op.value), - data: op.data, - })), - destOps: element.mandate.destinationOps.map((op) => ({ - to: op.to, - value: BigInt(op.value), - data: op.data, - })), + originOps: element.mandate.preClaimOps, + destOps: element.mandate.destinationOps, q: keccak256(element.mandate.qualifier.encodedVal), }, })), diff --git a/src/execution/permit2.ts b/src/execution/permit2.ts index 58233ece..94c0d970 100644 --- a/src/execution/permit2.ts +++ b/src/execution/permit2.ts @@ -63,17 +63,20 @@ function getTypedData( { name: 'targetChain', type: 'uint256' }, { name: 'fillExpiry', type: 'uint256' }, ], - Op: [ + Ops: [ { name: 'to', type: 'address' }, { name: 'value', type: 'uint256' }, { name: 'data', type: 'bytes' }, ], + Op: [ + { name: 'vt', type: 'bytes32' }, + { name: 'ops', type: 'Ops[]' }, + ], Mandate: [ { name: 'target', type: 'Target' }, - { name: 'v', type: 'uint8' }, { name: 'minGas', type: 'uint128' }, - { name: 'originOps', type: 'Op[]' }, - { name: 'destOps', type: 'Op[]' }, + { name: 'originOps', type: 'Op' }, + { name: 'destOps', type: 'Op' }, { name: 'q', type: 'bytes32' }, ], PermitBatchWitnessTransferFrom: [ @@ -100,18 +103,9 @@ function getTypedData( targetChain: BigInt(mandate.destinationChainId), fillExpiry: BigInt(mandate.fillDeadline), }, - v: mandate.v, minGas: BigInt(mandate.minGas), - originOps: mandate.preClaimOps.map((op) => ({ - to: op.to, - value: BigInt(op.value), - data: op.data, - })), - destOps: mandate.destinationOps.map((op) => ({ - to: op.to, - value: BigInt(op.value), - data: op.data, - })), + originOps: mandate.preClaimOps, + destOps: mandate.destinationOps, q: keccak256(mandate.qualifier.encodedVal), }, }, diff --git a/src/execution/singleChainOps.ts b/src/execution/singleChainOps.ts index 22e15568..63d78afc 100644 --- a/src/execution/singleChainOps.ts +++ b/src/execution/singleChainOps.ts @@ -1,5 +1,5 @@ -import type { Address } from 'viem' -import type { Execution, IntentOpElement } from '../orchestrator/types' +import { type Address, zeroAddress } from 'viem' +import type { IntentOpElement } from '../orchestrator/types' function getTypedData( account: Address, @@ -7,8 +7,6 @@ function getTypedData( element: IntentOpElement, nonce: bigint, ) { - const ops: Execution[] = element.mandate.destinationOps - return { domain: { name: 'IntentExecutor', @@ -20,9 +18,18 @@ function getTypedData( SingleChainOps: [ { name: 'account', type: 'address' }, { name: 'nonce', type: 'uint256' }, - { name: 'ops', type: 'Op[]' }, + { name: 'op', type: 'Op' }, + { name: 'gasRefund', type: 'GasRefund' }, ], Op: [ + { name: 'vt', type: 'bytes32' }, + { name: 'ops', type: 'Ops[]' }, + ], + GasRefund: [ + { name: 'token', type: 'address' }, + { name: 'exchangeRate', type: 'uint256' }, + ], + Ops: [ { name: 'to', type: 'address' }, { name: 'value', type: 'uint256' }, { name: 'data', type: 'bytes' }, @@ -32,7 +39,12 @@ function getTypedData( message: { account, nonce, - ops, + op: element.mandate.destinationOps, + // todo + gasRefund: { + token: zeroAddress, + exchangeRate: 0n, + }, }, } } diff --git a/src/execution/utils.ts b/src/execution/utils.ts index 19acd78e..9ab63cc9 100644 --- a/src/execution/utils.ts +++ b/src/execution/utils.ts @@ -702,11 +702,7 @@ async function prepareTransactionAsIntent( })), recipient, account: intentAccount, - destinationExecutions: calls.map((call) => ({ - to: call.to, - value: call.value.toString(), - data: call.data, - })), + destinationExecutions: calls, destinationGasUnits: gasLimit, accountAccessList, options: { diff --git a/src/orchestrator/types.ts b/src/orchestrator/types.ts index e9e3a175..0934e1af 100644 --- a/src/orchestrator/types.ts +++ b/src/orchestrator/types.ts @@ -63,7 +63,7 @@ interface Claim { interface Execution { to: Address - value: string + value: bigint data: Hex } @@ -146,13 +146,18 @@ interface IntentCost { } } +export interface Op { + vt: Hex + ops: Execution[] +} + interface IntentOpElementMandate { recipient: Address tokenOut: [[string, string]] destinationChainId: string fillDeadline: string - destinationOps: Execution[] - preClaimOps: Execution[] + destinationOps: Op + preClaimOps: Op qualifier: { settlementContext: { settlementLayer: SettlementLayer @@ -162,7 +167,6 @@ interface IntentOpElementMandate { } encodedVal: Hex } - v: number minGas: string } From f163a3c3b5ffbefa3bd803eef758ca65dca66269 Mon Sep 17 00:00:00 2001 From: kopy-kat Date: Wed, 17 Dec 2025 15:21:19 +0000 Subject: [PATCH 2/3] chore: changeset --- .changeset/chatty-rice-beam.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/chatty-rice-beam.md diff --git a/.changeset/chatty-rice-beam.md b/.changeset/chatty-rice-beam.md new file mode 100644 index 00000000..8547f0f8 --- /dev/null +++ b/.changeset/chatty-rice-beam.md @@ -0,0 +1,5 @@ +--- +"@rhinestone/sdk": patch +--- + +contract remediation changes From 91a4fec433f6602bf791b14d358e5e330bcfdefb Mon Sep 17 00:00:00 2001 From: kopy-kat Date: Thu, 18 Dec 2025 10:57:22 +0000 Subject: [PATCH 3/3] fix: orch mock --- test/orchestrator.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/test/orchestrator.ts b/test/orchestrator.ts index afa18467..81d6a933 100644 --- a/test/orchestrator.ts +++ b/test/orchestrator.ts @@ -1,3 +1,4 @@ +import { zeroHash } from 'viem' import { vi } from 'vitest' export function createOrchestratorMock() { @@ -52,16 +53,18 @@ export function createOrchestratorMock() { ], destinationChainId: '8453', fillDeadline: '1751908044', - destinationOps: [ - { - to: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', - value: '3', - data: '0x', - }, - ], - v: 27, + destinationOps: { + vt: '0x0203000000000000000000000000000000000000000000000000000000000000', + ops: [ + { + to: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045', + value: '3', + data: '0x', + }, + ], + }, minGas: 1000000000000000000n, - preClaimOps: [], + preClaimOps: { vt: zeroHash, ops: [] }, qualifier: { settlementContext: { settlementLayer: 'SAME_CHAIN',