feat(sdk): add confidentialTransferAndCall to Token methods [SDK-168]#423
Open
ghermet wants to merge 3 commits into
Open
feat(sdk): add confidentialTransferAndCall to Token methods [SDK-168]#423ghermet wants to merge 3 commits into
ghermet wants to merge 3 commits into
Conversation
Adds confidentialTransferAndCall and confidentialTransferFromAndCall on the ERC-7984 confidential-token surface so callers can invoke a recipient's receiver hook (onConfidentialTransferReceived) in a single transaction. The caller crafts the opaque data payload; the SDK does not encode, validate, or interpret it. - contracts/encrypted.ts: confidentialTransferAndCallContract, confidentialTransferFromAndCallContract pure builders - token.ts: Token.confidentialTransferAndCall / FromAndCall mirroring the existing confidentialTransfer / FromAndCall, with the same balance validation, encryption, and callback semantics - sdk-events: transferAndCall / transferFromAndCall operation strings for clean error attribution (events reuse TransferSubmitted / FromSubmitted shapes) - query/: confidentialTransferAndCallMutationOptions and confidentialTransferFromAndCallMutationOptions - react-sdk: useConfidentialTransferAndCall (with optimistic balance) and useConfidentialTransferFromAndCall hooks Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… [SDK-168] Deploys OpenZeppelin's ERC7984ReceiverMock (already vendored under the wrapper deps) alongside the existing test tokens and drives useConfidentialTransferAndCall end-to-end from both the Vite and Next.js test apps. - contracts: deploy ERC7984ReceiverMock and expose its address as `confidentialReceiver` in deployments.json - test-components: TransferAndCallForm with recipient/amount/data inputs - test-nextjs / test-vite: /transfer-and-call route + sidebar entry - playwright: transfer-and-call.spec.ts asserts a success path (abi.encode(uint8(1)) → ConfidentialTransferCallback(true), balance decreases) and a revert path (abi.encode(uint8(2)) → InvalidInput, surfaces a transfer error) - playwright fixtures: expose `confidentialReceiver` from deployments Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Regenerates the api-report files to expose the new `confidentialTransferAndCall` / `confidentialTransferFromAndCall` methods on `Token`, their query params, and the matching `useConfidentialTransferAndCall` / `useConfidentialTransferFromAndCall` React hooks added in b6c38d2. CI api-report check was the only red gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Public API Changes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes SDK-168.
Adds
Token.confidentialTransferAndCallandToken.confidentialTransferFromAndCallon the ERC-7984 confidential-token surface so callers can invoke a recipient's receiver hook (onConfidentialTransferReceived) in a single transaction. The caller crafts the opaquedatapayload; the SDK does not encode, validate, or interpret it.This is the confidential-token level (ERC-7984), distinct from the shielding
transferAndCallwork in SDK-144/145 (ERC-1363 on the underlying).Changes
packages/sdk/src/contracts/encrypted.ts—confidentialTransferAndCallContractandconfidentialTransferFromAndCallContractpure builders.packages/sdk/src/token/token.ts—Token.confidentialTransferAndCall(to, amount, data, options?)andToken.confidentialTransferFromAndCall(from, to, amount, data, callbacks?), mirroring the non-AndCallvariants' balance validation, encryption, and callback semantics.packages/sdk/src/events/sdk-events.ts— newtransferAndCall/transferFromAndCalloperations (reuseTransferSubmitted/TransferFromSubmittedevent shapes for clean error attribution).packages/sdk/src/query/transfer-and-call.ts+transfer-from-and-call.ts— TanStack mutation options factories.packages/react-sdk/src/transfer/use-confidential-transfer-and-call.ts+use-confidential-transfer-from-and-call.ts— hooks (with optimistic balance for the sender variant).Tests
packages/sdk/src/contracts/__tests__/contracts.test.tsandpackages/sdk/src/token/__tests__/token.test.ts(10 new tests) —dataforwarding, balance validation, error mapping.test/playwright/tests/transfer-and-call.spec.ts) — drivesuseConfidentialTransferAndCallagainst OpenZeppelin'sERC7984ReceiverMock, deployed viacontracts/script/Deploy.s.sol. Asserts both the success path (abi.encode(uint8(1))→ confidential balance decreases) and a revert path (abi.encode(uint8(2))→InvalidInputsurfaces as a transfer error). Passes on Vite and Next.js.Test plan
pnpm typecheckcleanpnpm lintcleanpnpm test:run— 1504 passing (10 new unit tests)pnpm e2e:test:vite --grep transferAndCall— 2/2 passpnpm e2e:test:nextjs --grep transferAndCall— 2/2 pass🤖 Generated with Claude Code