Skip to content

Commit

Permalink
Merge pull request #162 from TosiDrop/fix-stake-address
Browse files Browse the repository at this point in the history
fix: stake address translation
  • Loading branch information
wolf31o2 authored Jun 4, 2022
2 parents 61a791b + 195e5ef commit 6133073
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
FROM node:16 AS base

FROM base AS builder
WORKDIR /code
COPY . .
RUN cd client && npm run build
RUN cd server && npm run build
WORKDIR /code/client
COPY client .
RUN npm run build
WORKDIR /code/server
COPY server .
RUN npm run build

FROM base AS final
WORKDIR /app
COPY --from=builder --chmod=555 /code/docker-entrypoint.sh .
COPY --from=builder /code/server/index.ts /code/server/package.json /code/server/tsconfig.json ./server/
COPY --from=builder /code/server/utils ./server/utils/
COPY --from=builder /code/server/node_modules ./server/node_modules/
COPY --from=builder /code/client/src/entities/ ./client/src/entities/
COPY --from=builder /code/client/src/services/ ./client/src/services/
COPY --from=builder /code/client/build/ ./client/build/
COPY --chmod=555 docker-entrypoint.sh .
ENTRYPOINT ["/app/docker-entrypoint.sh"]
3 changes: 3 additions & 0 deletions client/src/services/claim.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export async function getSettings() {
}

export async function getStakeKey(addr: string) {
if (addr.slice(0, 5) == "stake") {
return {staking_address: addr};
}
const response = await axios.get(`/getstakekey?address=${addr}`);
return response.data;
}
6 changes: 5 additions & 1 deletion server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ app.get("/getstakekey", async (req: any, res: any) => {
let address = queryObject.address as string;
let translatedAddress;

if (!address) return res.send({ error: "Address seems invalid" });
if (!address) return res.send({ error: "Input missing or invalid address" });
if (!VM_KOIOS_URL) return res.send({ error: "KOIOS URL is not defined" });

const prefix = address.slice(0, 5);
Expand All @@ -207,6 +207,10 @@ app.get("/getstakekey", async (req: any, res: any) => {
if (CARDANO_NETWORK === CardanoNetwork.testnet)
return res.send({ error: "Inserted address is for mainnet" });
break;
case prefix === "stake":
// We were given a stake address, pass it through
return res.send({ staking_address: address });
break;
default:
return res.send({ error: "Address seems invalid" });
}
Expand Down

0 comments on commit 6133073

Please sign in to comment.