Skip to content

Commit

Permalink
Merge pull request #1159 from etherisc/dependabot/npm_and_yarn/npm_an…
Browse files Browse the repository at this point in the history
…d_yarn-88119e03da

chore(deps): bump the npm_and_yarn group with 2 updates
  • Loading branch information
doerfli authored Oct 31, 2024
2 parents 70c4e79 + 759b486 commit 4ece1dd
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 35 deletions.
95 changes: 79 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"react-i18next": "^12.3.1",
"react-redux": "^9.1.2",
"redis": "^4.7.0",
"redis-om": "^0.4.3"
"redis-om": "^0.4.7",
"ulid": "^2.3.0"
},
"devDependencies": {
"@etherisc/gif-interface": "2.0.0-rc.1-0",
Expand Down
9 changes: 3 additions & 6 deletions src/pages/api/feeless/restake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { NextApiRequest, NextApiResponse } from "next";
import { getPendingRestakeRepository } from "../../../utils/feeless/pending_restake";
import { redisClient } from "../../../utils/redis";
import { EntityId } from "redis-om";
import { ulid } from "ulid";

export const STREAM_KEY = process.env.REDIS_QUEUE_STREAM_KEY ?? "feeless:signatures";

Expand Down Expand Up @@ -39,7 +40,8 @@ async function handlePost(req: NextApiRequest, res: NextApiResponse) {

// store pending application in redis
const repo = await getPendingRestakeRepository();
const savedRestake = await repo.save({
const entityId = ulid();
await repo.save(entityId, {
owner: owner,
stakeNftId: stakeNftId,
targetNftId: targetNftId,
Expand All @@ -48,11 +50,6 @@ async function handlePost(req: NextApiRequest, res: NextApiResponse) {
transactionHash: null,
timestamp: new Date(),
});
const entityId = savedRestake[EntityId];
if (! entityId) {
res.status(500).send("Failed to save pending restake");
return;
}
console.log("created pending restake", signatureId, entityId);

// push message to stream (queue)
Expand Down
26 changes: 14 additions & 12 deletions src/pages/api/feeless/stake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { NextApiRequest, NextApiResponse } from "next";
import { redisClient } from "../../../utils/redis";
import { getPendingStakeRepository } from "../../../utils/feeless/pending_stake";
import { EntityId } from "redis-om";
import { ulid } from "ulid";

export const STREAM_KEY = process.env.REDIS_QUEUE_STREAM_KEY ?? "feeless:signatures";

Expand All @@ -13,12 +14,17 @@ export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
if (process.env.NEXT_PUBLIC_FEATURE_GASLESS_TRANSACTION !== 'true') {
res.status(404).send('Unsupported feature');
} else if (req.method === 'POST') {
await handlePost(req, res);
} else {
res.status(405).send('Only POST requests allowed');
try {
if (process.env.NEXT_PUBLIC_FEATURE_GASLESS_TRANSACTION !== 'true') {
res.status(404).send('Unsupported feature');
} else if (req.method === 'POST') {
await handlePost(req, res);
} else {
res.status(405).send('Only POST requests allowed');
}
} catch (err) {
console.log(err);
throw err;
}
}

Expand All @@ -39,7 +45,8 @@ async function handlePost(req: NextApiRequest, res: NextApiResponse) {

// store pending application in redis
const repo = await getPendingStakeRepository();
const savedStake = await repo.save({
const entityId = ulid();
await repo.save(entityId, {
owner: owner,
targetNftId: targetNftId,
dipAmount: dipAmount,
Expand All @@ -48,11 +55,6 @@ async function handlePost(req: NextApiRequest, res: NextApiResponse) {
transactionHash: null,
timestamp: new Date(),
});
const entityId = savedStake[EntityId];
if (! entityId) {
res.status(500).send("Failed to save pending stake");
return;
}
console.log("created pending stake", signatureId, entityId);

// push message to stream (queue)
Expand Down

0 comments on commit 4ece1dd

Please sign in to comment.