-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/user metadata upload endpoint #13
base: master
Are you sure you want to change the base?
Changes from all commits
1abb814
ff0b0d8
b584390
ba00710
d00ae68
864ed2c
49f6a52
6db4767
0f7739e
1641bd5
567e329
4e2a883
ede53b4
c1bf936
3c386d9
5249db2
5f5d1ff
c204c27
424ce38
09f178c
a258db0
4d5af03
7b3c931
3c29566
8d28919
327c0e3
15992bf
c895ff4
e0c53ec
a932478
35d37fa
dfc8d39
182d85b
3d95f7b
a9550a6
7ed9f64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { gql } from "@apollo/client"; | ||
|
||
export const createSetDefaultProfile = gql` | ||
mutation CreateSetDefaultProfileTypedData( | ||
$request: CreateSetDefaultProfileRequest! | ||
) { | ||
createSetDefaultProfileTypedData(request: $request) { | ||
id | ||
expiresAt | ||
typedData { | ||
types { | ||
SetDefaultProfileWithSig { | ||
name | ||
type | ||
} | ||
} | ||
domain { | ||
name | ||
chainId | ||
version | ||
verifyingContract | ||
} | ||
value { | ||
nonce | ||
deadline | ||
wallet | ||
profileId | ||
} | ||
} | ||
} | ||
} | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { gql } from "@apollo/client"; | ||
|
||
export const createSetProfileWithMetadata = gql` | ||
mutation CreateSetProfileMetadataTypedData( | ||
$request: CreatePublicSetProfileMetadataURIRequest! | ||
) { | ||
createSetProfileMetadataTypedData(request: $request) { | ||
id | ||
expiresAt | ||
typedData { | ||
types { | ||
SetProfileMetadataURIWithSig { | ||
name | ||
type | ||
} | ||
} | ||
domain { | ||
name | ||
chainId | ||
version | ||
verifyingContract | ||
} | ||
value { | ||
nonce | ||
deadline | ||
profileId | ||
metadata | ||
} | ||
} | ||
} | ||
} | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import classes from "../../styles/Form.module.css"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not for this PR but when refactoring/cleaning up the code, what do you think about colocating the css module files with the components, example...
This will make it easier to navigate to the css module files to make changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes sense, at the beginning it was simpler to manage the styles that way but as they increased everything got more complex haha |
||
|
||
export default function Form(props) { | ||
return ( | ||
<form onSubmit={props.onSubmit} className={classes.form}> | ||
{props.children} | ||
</form> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import classes from "../../styles/Form.module.css"; | ||
|
||
export default function Input(props) { | ||
return ( | ||
<div className={classes.field}> | ||
<label className={classes.label} htmlFor={props.id}> | ||
{props.label} | ||
</label> | ||
{props.type !== "text-area" ? ( | ||
<input | ||
className={classes.input} | ||
id={props.id} | ||
name={props.name} | ||
type={props.type} | ||
onChange={props.onChange} | ||
onBlur={props.onBlur} | ||
value={props.value || ""} | ||
/> | ||
) : ( | ||
<textarea | ||
className={classes.input} | ||
id={props.id} | ||
name={props.name} | ||
onChange={props.onChange} | ||
onBlur={props.onBlur} | ||
value={props.value || ""} | ||
></textarea> | ||
)} | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { withIronSessionApiRoute } from "iron-session/next"; | ||
import ironOptions from "../../config/ironOptions"; | ||
import { storeMetadataFileIPFS } from "../../utils/storeMetadataFileIPFS"; | ||
|
||
async function handler(req, res) { | ||
if (req.method === "POST") { | ||
return await storeUserMetadata(req, res); | ||
} else { | ||
return res | ||
.status(405) | ||
.json({ message: "Method not allowed", success: false }); | ||
} | ||
} | ||
|
||
async function storeUserMetadata(req, res) { | ||
const body = req.body; | ||
|
||
try { | ||
const file = { | ||
path: "/tmp/data.json", | ||
content: Buffer.from(body), | ||
}; | ||
|
||
const cid = await storeMetadataFileIPFS(file); | ||
|
||
return res.status(200).json({ ok: true, cid: cid }); | ||
} catch (err) { | ||
console.log(err); | ||
return res | ||
.status(500) | ||
.json({ error: "Error creating/editing user", ok: false }); | ||
} | ||
} | ||
|
||
export default withIronSessionApiRoute(handler, ironOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job using
Link
from next here 🙌