Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.

Commit cb75e9f

Browse files
committed
fix: review comments
1 parent 5b68252 commit cb75e9f

2 files changed

Lines changed: 110 additions & 15 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { APIError } from '@coinbase/onchainkit/api';
2+
import { LifecycleStatus, Signature } from '@coinbase/onchainkit/signature';
3+
import { encodeAbiParameters } from 'viem';
4+
import App from './App.tsx';
5+
6+
const SCHEMA_UID = '0xf58b8b212ef75ee8cd7e8d803c37c03e0519890502d5e99ee2412aae1456cafe';
7+
const EAS_CONTRACT = '0x4200000000000000000000000000000000000021';
8+
9+
export function EIP712Signature() {
10+
const domain = {
11+
name: 'EAS Attestation',
12+
version: '1.0.0',
13+
chainId: 8453,
14+
verifyingContract: EAS_CONTRACT,
15+
} as const;
16+
17+
const types = {
18+
Attest: [
19+
{ name: 'schema', type: 'bytes32' },
20+
{ name: 'recipient', type: 'address' },
21+
{ name: 'time', type: 'uint64' },
22+
{ name: 'revocable', type: 'bool' },
23+
{ name: 'refUID', type: 'bytes32' },
24+
{ name: 'data', type: 'bytes' },
25+
{ name: 'value', type: 'uint256' },
26+
],
27+
} as const;
28+
29+
const message = {
30+
schema: SCHEMA_UID,
31+
recipient: '0x0000000000000000000000000000000000000000',
32+
time: BigInt(0),
33+
revocable: false,
34+
refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
35+
data: encodeAbiParameters([{ type: 'string' }], ['test attestation']) as `0x${string}`,
36+
value: BigInt(0),
37+
} as const;
38+
39+
const handleOnSuccess = (signature: string) => {
40+
console.log(signature);
41+
};
42+
43+
const handleOnStatus = (status: LifecycleStatus) => {
44+
console.log(status);
45+
};
46+
47+
const handleOnError = (error: APIError) => {
48+
console.log(error);
49+
};
50+
51+
return (
52+
<App>
53+
<div style={{ width: '200px' }}>
54+
<Signature
55+
domain={domain}
56+
types={types}
57+
message={message}
58+
primaryType="Attest"
59+
label="EIP712"
60+
onSuccess={handleOnSuccess}
61+
onStatus={handleOnStatus}
62+
onError={handleOnError}
63+
resetAfter={1000}
64+
/>
65+
</div>
66+
</App>
67+
);
68+
}
69+
70+
export function PersonalSignSignature() {
71+
const handleOnSuccess = (signature: string) => {
72+
console.log(signature);
73+
};
74+
75+
const handleOnStatus = (status: LifecycleStatus) => {
76+
console.log(status);
77+
};
78+
79+
const handleOnError = (error: APIError) => {
80+
console.log(error);
81+
};
82+
83+
return (
84+
<App>
85+
<div style={{ width: '200px' }}>
86+
<Signature
87+
message="test message"
88+
label="personal_sign"
89+
onSuccess={handleOnSuccess}
90+
onStatus={handleOnStatus}
91+
onError={handleOnError}
92+
resetAfter={1000}
93+
/>
94+
</div>
95+
</App>
96+
);
97+
}

apps/base-docs/docs/pages/builderkits/onchainkit/signature/signature.mdx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
---
22
title: <Signature /> · OnchainKit
3-
description: The `<Signature />` components provide a high-level wrap around the entire transaction flow. It handles the transaction lifecycle, including gas estimation, fee sponsorship, and status updates.
3+
description: The `<Signature />` component supports signing EIP712 and personal_sign messages.
44
---
55

6-
import { Avatar, Name } from '@coinbase/onchainkit/identity';
7-
import {
8-
Signature,
9-
SignatureButton,
10-
SignatureStatus,
11-
SignatureLabel,
12-
SignatureToast,
13-
SignatureIcon,
14-
} from '@coinbase/onchainkit/signature';
15-
import { Wallet, ConnectWallet } from '@coinbase/onchainkit/wallet';
16-
import TransactionWrapper from '@/components/TransactionWrapper';
6+
import { EIP712Signature, PersonalSignSignature } from '@/components/SignatureComponents';
177

188
# `<Signature />`
199

@@ -70,7 +60,9 @@ export const message = {
7060
<Signature
7161
domain={domain}
7262
types={types}
63+
primaryType="Attest"
7364
message={message}
65+
label="Sign EIP712"
7466
onSuccess={(signature: string) => console.log(signature)}
7567
/>
7668
```
@@ -112,17 +104,22 @@ export const message = {
112104

113105
:::
114106

107+
<EIP712Signature />
108+
115109
### Default implementation for personal_sign messages
116110

117-
```tsx twoslash
111+
```tsx twoslash [Signature.tsx]
118112
import { Signature } from '@coinbase/onchainkit/signature';
119113

120114
<Signature
121115
message="Hello, OnchainKit!"
116+
label="Personal_Sign me"
122117
onSuccess={(signature: string) => console.log(signature)}
123118
/>
124119
```
125120

121+
<PersonalSignSignature />
122+
126123
## Components
127124

128125
The Signature components provide a complete signature flow:
@@ -140,7 +137,7 @@ The Signature components provide a complete signature flow:
140137
### `<SignatureStatus />` and `<SignatureToast />` subcomponents
141138

142139
- `<SignatureLabel />` - Displays status text ("Success", "Confirm in wallet", etc.)
143-
- `<SignatureIcon />` - Shows status icons (spinner, success, error)
140+
- `<SignatureIcon />` - Shows status icons (pending, success, error)
144141

145142
## Component API
146143

@@ -160,6 +157,7 @@ Main wrapper component that manages the signature flow.
160157
message="Hello World"
161158

162159
// Optional props
160+
label="Sign"
163161
onSuccess={(signature: string) => {}}
164162
onError={(error: APIError) => {}}
165163
onStatus={(status: LifecycleStatus) => {}}
@@ -260,7 +258,7 @@ Custom error handling:
260258

261259
## Message Types
262260

263-
The component supports two types of signatures:
261+
The `<Signature />` component supports two types of messages:
264262

265263
### EIP-712 Typed Data
266264

0 commit comments

Comments
 (0)