diff --git a/docs.json b/docs.json index f795e6a..08fbd57 100644 --- a/docs.json +++ b/docs.json @@ -64,7 +64,6 @@ "mini-apps/commands/send-transaction", "mini-apps/commands/chat", "mini-apps/commands/sign-message", - "mini-apps/commands/sign-typed-data", "mini-apps/commands/share-contacts", "mini-apps/commands/request-permission", "mini-apps/commands/get-permissions", diff --git a/mini-apps/commands/sign-typed-data.mdx b/mini-apps/commands/sign-typed-data.mdx deleted file mode 100644 index 97699c4..0000000 --- a/mini-apps/commands/sign-typed-data.mdx +++ /dev/null @@ -1,163 +0,0 @@ ---- -title: "Sign Typed Data" -"og:image": "/images/docs/docs-meta.png" -"twitter:image": "/images/docs/docs-meta.png" ---- - -Sign Typed Data lets you create an [EIP-712 signature](https://eips.ethereum.org/EIPS/eip-712). - -**Use Case:** This command is essential for applications that require structured data to be signed. - -**Example:** An insurance platform that requires users to sign typed data to confirm the terms of their insurance policy. - -> Note: The `EIP712Domain` must always include `chainId`. -> -> On **Worldchain**, only custom typed data is permitted. -> -> - SafeTx and Permit/Permit2 types are not allowed. -> -> On **all other chains**, any valid EIP-712 structure is supported, including SafeTx and Permit types. - -```ts -{ - types: { - YourTypes: [ - { type: 'bytes', name: 'data' }, - { type: 'uint8', name: 'operation' }, - ], - EIP712Domain: [ - { type: 'uint256', name: 'chainId' }, - { type: 'address', name: 'verifyingContract' }, - ], - }, - domain: { - chainId: 480, - verifyingContract: "0x1234...", - }, - primaryType: 'YourTypes', - message:{ data: '0xffffffff', operation: 15} -} -``` - -## Using the command - - - - ### Sending the command & handling the response - - ```tsx - import type { TypedData, TypedDataDomain } from 'abitype' - - export type SignTypedDataInput = { - types: TypedData - primaryType: string - message: Record - domain: TypedDataDomain - } - ``` - - ```tsx - type MiniAppSignTypedDataSuccessPayload = { - status: 'success' - signature: string - address: string - version: number - } - ``` - - ```tsx app/page.tsx - import { MiniKit, SignTypedDataInput } from '@worldcoin/minikit-js' - - const signAndVerifyTypedData = async () => { - if (!MiniKit.isInstalled()) { - return - } - - const {finalPayload} = await MiniKit.commandsAsync.signTypedData( - somePayloadforEIP712 as SignTypedDataInput; - ); - - if (payload.status === 'success') { - const messageHash = hashSafeMessage(signTypedDataPayload) - - const isValid = await ( - await Safe.init({ - provider: 'https://worldchain-mainnet.g.alchemy.com/v2/your-api-key', - safeAddress: payload.address, - }) - ).isValidSignature(messageHash, payload.signature) - - // Checks functionally if the signature is correct - if (isValid) { - console.log('Signature is valid') - } - } - }; - ``` - - - - ### Sending the command - - ```tsx - import type { TypedData, TypedDataDomain } from 'abitype' - - export type SignTypedDataInput = { - types: TypedData - primaryType: string - message: Record - domain: TypedDataDomain - } - ``` - - ```tsx app/page.tsx - import { MiniKit, SignTypedDataInput } from '@worldcoin/minikit-js' - - const onSignTypedData = () => { - const payload = MiniKit.commands.signTypedData( - somePayloadforEIP712 as SignTypedDataInput; - ); - }; - ``` - - ### Receiving the response - - Verifying the signature. Note permit2 payloads and safe operations are not permitted in this command. - - ```tsx - type MiniAppSignTypedDataSuccessPayload = { - status: 'success' - signature: string - address: string - version: number - } - ``` - - ```tsx app/page.tsx - import { MiniKit, ResponseEvent } from '@worldcoin/minikit-js' - useEffect(() => { - if (!MiniKit.isInstalled()) { - return - } - - MiniKit.subscribe(ResponseEvent.MiniAppSignTypedData, async (payload: MiniAppSignTypedDataPayload) => { - if (payload.status === 'success') { - const messageHash = hashSafeMessage(signTypedDataPayload) - - const isValid = await ( - await Safe.init({ - provider: 'https://worldchain-mainnet.g.alchemy.com/v2/your-api-key', - safeAddress: payload.address, - }) - ).isValidSignature(messageHash, payload.signature) - - // Checks functionally if the signature is correct - if (isValid) { - console.log('Signature is valid') - } - } - }) - }, []) - ``` - - \ No newline at end of file diff --git a/mini-apps/quick-start/commands.mdx b/mini-apps/quick-start/commands.mdx index ea22f7e..cd851a3 100644 --- a/mini-apps/quick-start/commands.mdx +++ b/mini-apps/quick-start/commands.mdx @@ -1,8 +1,6 @@ --- title: "Commands" -description: "Overview of Mini App commands" -"og:image": "/images/docs/docs-meta.png" -"twitter:image": "/images/docs/docs-meta.png" +description: "Overview of Mini App commands: verify with World ID, pay, wallet auth, send transactions, share contacts, notifications, and more." --- import { QRCodeGenerator } from "/snippets/qr-code-generator.jsx"; @@ -55,12 +53,6 @@ Try our preview mini app to get a sense of how commands work. Scan the QR code b Sign personal messages with your wallet - - Sign Typed Data - - Sign EIP-712 payloads with your wallet - - Share Contacts @@ -85,9 +77,11 @@ Try our preview mini app to get a sense of how commands work. Scan the QR code b Share Native OS share modal - + Chat - Send Messages and Create Groups in World Chat + + Send Messages and Create Groups in World Chat + Quick Actions