Skip to content

Commit

Permalink
refactor: remove buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Mar 18, 2024
1 parent 3d9ea1e commit fd570ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/dev/utils/fetchFrame.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { bytesToHex, hexToBytes } from '@noble/curves/abstract/utils'
import { ed25519 } from '@noble/curves/ed25519'
import { blake3 } from '@noble/hashes/blake3'
import { toBytes } from '@noble/hashes/utils'

import {
FarcasterNetwork,
Expand Down Expand Up @@ -48,11 +49,11 @@ export async function fetchFrame(parameters: FetchFrameParameters) {
buttonIndex,
castId: {
fid: BigInt(castId.fid),
hash: Buffer.from(hexToBytes(castId.hash.slice(2))),
hash: hexToBytes(castId.hash.slice(2)),
},
inputText: inputText ? Buffer.from(inputText) : undefined,
state: state ? Buffer.from(state) : undefined,
url: Buffer.from(url),
inputText: inputText ? toBytes(inputText) : undefined,
state: state ? toBytes(state) : undefined,
url: toBytes(url),
// TODO: Add transactionId
})

Expand All @@ -77,7 +78,7 @@ export async function fetchFrame(parameters: FetchFrameParameters) {
signatureScheme: SignatureScheme.ED25519,
signer: ed25519.getPublicKey(privateKeyBytes),
})
const messageBytes = Buffer.from(message.toBinary()).toString('hex')
const messageBytes = bytesToHex(message.toBinary())

const t0 = performance.now()
let response: Response | undefined
Expand Down
4 changes: 3 additions & 1 deletion templates/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"type": "module",
"scripts": {
"dev": "next dev",
"deploy": "vercel",
"build": "next build",
"start": "next start",
"lint": "next lint"
Expand All @@ -19,6 +20,7 @@
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18"
"@types/react-dom": "^18",
"vercel": "^32.4.1"
}
}

0 comments on commit fd570ed

Please sign in to comment.