feat(midnight-sdk): ratify Ecrecover trees with client signing#809
feat(midnight-sdk): ratify Ecrecover trees with client signing#809Rubilmax wants to merge 3 commits into
Conversation
|
One compatibility caveat with router/onchain behavior: the new In this PR, await EcrecoverRatifierUtils.ratify({ tree, walletClient: delegateWallet });Delegated signing is still possible through the precomputed-signature path: const typedData = EcrecoverRatifierUtils.typedData({ tree, chainId });
const signature = await delegateWallet.signTypedData({
account: delegateAccount,
...typedData,
});
const items = await EcrecoverRatifierUtils.ratify({ tree, signature });Could we document that distinction explicitly (or rename the error/docs to say this wallet-client overload is maker-only)? Otherwise SDK users may think delegated signing is unsupported, even though it remains compatible with router/onchain when using the manual signature path. |
Summary
EcrecoverRatifierUtils.ratify/signto accept a viemClientplus explicitaccountfor local Ecrecover signing.client.chain.id; callers no longer passchainIdtoratify.verifyTypedDatawithout wrapping viem/noble errors in an SDK-specific error.Protocol Check
morpho-org/midnightEcrecoverRatifieraccepts_signer == offer.maker || IMidnight(MIDNIGHT).isAuthorized(offer.maker, _signer).verifyTypedDatareturnsisAddressEqual(getAddress(address), await recoverTypedDataAddress(...)); malformed signatures throw from the underlying recovery path.Validation
pnpm --filter @morpho-org/midnight-sdk buildpnpm --filter @morpho-org/midnight-sdk testpnpm exec biome check packages/midnight-sdk/src/signatures/EcrecoverRatifierUtils.ts packages/midnight-sdk/src/signatures/EcrecoverRatifierUtils.test.ts packages/midnight-sdk/src/errors.ts .changeset/add-midnight-sdk.md