Skip to content

Commit

Permalink
Reimplement stampjs
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrain99 committed Oct 22, 2024
1 parent 6cf49ef commit 2ad5956
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {
"@permaweb/aoconnect": "^0.0.54",
"@permaweb/stampjs": "file:/Users/jackfrain/Desktop/stamp/packages/stampjs",
"@permaweb/stampjs": "^1.0.0",
"@tailwindcss/typography": "^0.5.15",
"arweave-wallet-connector": "^1.0.2",
"crocks": "^0.12.4",
Expand Down
2 changes: 1 addition & 1 deletion src/components/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const Asset = ({
>
<span className="hidden md:block flex items-end">{shortHash(id)}</span>
</a>
{/* <span className="flex items-end">Stamps: ({stamps})</span> */}
<span className="flex items-end">Stamps: ({stamps})</span>
<span className="flex space-x-2 items-end">
Date: {date}
</span>
Expand Down
8 changes: 0 additions & 8 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3151,10 +3151,6 @@ html:has(.drawer-toggle:checked){
flex: 1 1 0%;
}

.cursor-not-allowed{
cursor: not-allowed;
}

.flex-col{
flex-direction: column;
}
Expand Down Expand Up @@ -3437,10 +3433,6 @@ html:has(.drawer-toggle:checked){
color: var(--fallback-su,oklch(var(--su)/var(--tw-text-opacity)));
}

.opacity-50{
opacity: 0.5;
}

.filter{
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}
Expand Down
8 changes: 3 additions & 5 deletions src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ const HomePage = () => {
}

const handleStamp = () => {
console.log('stamping disabled')
// send('stamp')
send('stamp')
}

return (
Expand Down Expand Up @@ -84,9 +83,8 @@ const HomePage = () => {
</svg>
)}
</button>
<button className="btn btn-outline btn-primary cursor-not-allowed opacity-50" onClick={handleStamp}>
stamping disabled
{/* Stamp: ({context.selected?.stamps}) */}
<button className="btn btn-outline btn-primary" onClick={handleStamp}>
Stamp ({context.selected?.stamps})
</button>
</div>
)}
Expand Down
16 changes: 6 additions & 10 deletions src/pages/show/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ const ShowPage = ({ tx, parent = false }: { tx: string, parent?: boolean }) => {
}, [])

const handleStamp = () => {
console.log('stamping disabled')
// TODO: add stamp logic
// send('stamp')
send('stamp')
}

const handleReset = async () => {
send('reset')
route("/", true)
}

console.log({ context })
return (
<>
{current === 'loading' ? (
Expand All @@ -54,9 +51,8 @@ const ShowPage = ({ tx, parent = false }: { tx: string, parent?: boolean }) => {
<nav className="flex py-4 px-4 sticky top-0 items-center justify-between">
{!parent && (
<>
<button className="btn btn-outline opacity-50 cursor-not-allowed" onClick={handleStamp}>
stamping disabled
{/* stamp ({context?.spec?.stamps}) */}
<button className="btn btn-outline" onClick={handleStamp}>
stamp ({context?.spec?.stamps})
</button>
<label for="my-drawer-2" className="btn btn-ghost text-lg drawer-button">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" className="w-6 h-6">
Expand Down Expand Up @@ -103,10 +99,10 @@ const ShowPage = ({ tx, parent = false }: { tx: string, parent?: boolean }) => {
<th>Topics</th>
<td>{context?.spec?.Topics}</td>
</tr>
{/* <tr>
<tr>
<th>Stamps</th>
<td>{context?.spec?.stamps}</td>
</tr> */}
</tr>
<tr>
<th>Height</th>
<td>{context?.spec?.BlockHeight}</td>
Expand All @@ -127,7 +123,7 @@ const ShowPage = ({ tx, parent = false }: { tx: string, parent?: boolean }) => {
<div className="card">
<div className="card-body">
<div className="card-title">Actions</div>
<button className="btn btn-sm btn-outline cursor-not-allowed opacity-50" onClick={handleStamp}>stamping disabled</button>
<button className="btn btn-sm btn-outline" onClick={handleStamp}>STAMP</button>
<a href={`/related/${tx}`} className="btn btn-sm btn-outline">View Related</a>
<a href={`/remix/${tx}`} className="btn btn-sm btn-outline">Remix</a>
<a href={`https://microscope.g8way.io/?tx=${tx}`} className="btn btn-sm btn-outline">Microscope</a>
Expand Down
34 changes: 15 additions & 19 deletions src/services/stamps.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
// import Stamps from "@permaweb/stampjs";
// import { prop } from "ramda";
import Stamps from "@permaweb/stampjs";
import { prop } from "ramda";

// const stamps = Stamps.init({});
const stamps = Stamps.init({});

export const stampCounts = (txs: string[]) => {
return Promise.resolve(txs.map(tx => ({ tx: { total: 0, vouched: 0 }})))
// return stamps.counts(txs);
return stamps.counts(txs);
}

export const stamp = (tx: string) => {
return Promise.reject("Stamping disabled")
// return stamps.hasStamped(tx).then((s) => {
// console.log({ s })
// return !s
// ? stamps
// .stamp(tx)
// .then(() => new Promise((r) => setTimeout(r, 500)))
// .then(() => stamps.count(tx).then(prop("vouched")))
// : Promise.reject("Already Stamped!")
// }
// )
return stamps.hasStamped(tx).then((s) => {
return !s
? stamps
.stamp(tx)
.then(() => new Promise((r) => setTimeout(r, 500)))
.then(() => stamps.count(tx).then(prop("vouched")))
: Promise.reject("Already Stamped!")
}
)
}

export const stampCount = (tx) => {
return Promise.resolve({ total: 0, vouched: 0 })
// stamps.count(tx).then(prop("vouched"));
}
return stamps.count(tx).then(prop("vouched"));
}

0 comments on commit 2ad5956

Please sign in to comment.