Skip to content

Commit

Permalink
Remove ETH top-up bonus offer
Browse files Browse the repository at this point in the history
  • Loading branch information
kewbish committed May 6, 2023
1 parent 5108074 commit a8ea85c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 148 deletions.
Binary file modified build.crx
Binary file not shown.
2 changes: 1 addition & 1 deletion landing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h2 class="display mx-auto text-center mb-3">get started</h2>
<a href="https://chrome.google.com/webstore/detail/cobweb/agdomcadfhkpkcjceenogkiglbhgpclg" class="btn glassy-cw-btn mt-1" role="button">download</a>
</div>
<div class="col">
<p>Cobweb is MIT-licensed and fully open source - the source is <a href="https://github.com/kewbish/cobweb">available on GitHub</a> should you wish to build from source. The checksum of the current version is <code style="word-break:break-all;">5b29cc1cfefd9db1e69fce3bf787b1fa7368b4be769b3c7d426311d45089ba9b</code>.
<p>Cobweb is MIT-licensed and fully open source - the source is <a href="https://github.com/kewbish/cobweb">available on GitHub</a> should you wish to build from source. The checksum of the current version is <code style="word-break:break-all;">a0f59c908c6d6f65a22348d2abfe51c01ee530072da6a8ded98e84fd1ef3dda5</code>.
</p>
<a href="https://github.com/kewbish/cobweb" class="btn glassy-cw-btn mt-1" role="button">view source</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Cobweb",
"version": "0.0.8",
"version": "0.0.9",
"description": "A Web3-based tool enabling creative teens to learn and earn on the blockchain.",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Cobweb",
"description": "A Web3-based tool empowering teens to learn and earn on the blockchain.",
"version": "0.0.8",
"version": "0.0.9",
"background": { "service_worker": "background.bundle.js" },
"action": {
"default_popup": "popup.html",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Popup/CobwebInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const CobwebInfo = () => {
onClick={requestVerification}
disabled={reactRequested}
>
{!reactRequested ? "Request verification + ETH" : "Requested!"}
{!reactRequested ? "Request verification" : "Requested!"}
</button>
</div>
) : null}
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Popup/components/InfoPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const InfoPopover = ({
text,
moreSquare = true,
darker,
id = "info-popover",
}: {
text: string;
moreSquare?: boolean;
darker?: boolean;
id?: string;
}) => {
useEffect(() => {
const popover = new bootstrap.Popover(
document.getElementById("info-popover")
);
const popover = new bootstrap.Popover(document.getElementById(id));
return () => {
try {
popover.dispose();
Expand All @@ -30,7 +30,7 @@ const InfoPopover = ({
<img
src={IconSvg}
alt="Information icon"
id="info-popover"
id={id}
data-bs-toggle="popover"
data-bs-trigger="hover focus"
data-bs-placement="bottom"
Expand Down
20 changes: 11 additions & 9 deletions src/pages/Popup/components/OnboardingCarousel.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useState } from "react";
import { useChromeStorageLocal } from "use-chrome-storage";
import { toast } from "../../shared/toast";
import InfoPopover from "../components/InfoPopover";
// @ts-expect-error
import bootstrap from "bootstrap/dist/js/bootstrap.bundle";
import InfoPopover from "../components/InfoPopover";

const Onboarding = () => {
const [hasJoined, setHasJoined] = useState(false);
Expand Down Expand Up @@ -209,7 +209,7 @@ const Onboarding = () => {
.
</p>
<p style={{ fontSize: 16 }}>
To get started, you'll need to have some Ether in your wallet, and
To get started, you'll need to have some ETH in your wallet, and
upgrade it by clicking 'Manage balances'. Learn more{" "}
<a
href="https://github.com/kewbish/cobweb/wiki/Balances-&-Balances-Pages"
Expand All @@ -228,15 +228,19 @@ const Onboarding = () => {
style={{ height: 180, marginBottom: "0.75rem" }}
>
<p style={{ fontSize: 16 }} className="mb-1 d-inline">
To help you get started, we're offering a limited-time 0.003 ETH
(~$5) top-up to your account! Verify your account to request the
ETH tokens and get started.
We're excited for you to begin your blockchain journey with
Cobweb!
<br />
<br />
Verify your account to get started.
</p>
<InfoPopover
text={
"Please note verification is performed manually. We reserve the right to not offer ETH but will always register you into the community."
"Please note verification is performed manually. We reserve the right to not register you into the Cobweb community."
}
moreSquare={true}
darker={true}
id={"verification-popover"}
/>
<br />
<div className="d-flex align-items-center">
Expand All @@ -246,9 +250,7 @@ const Onboarding = () => {
disabled={hasJoined}
onClick={joinCobweb}
>
{hasJoined
? "Thanks, and welcome!"
: "Request verification + ETHx"}
{hasJoined ? "Thanks, and welcome!" : "Request verification"}
</button>
</div>
</div>
Expand Down
132 changes: 1 addition & 131 deletions worker/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { ethers } from "ethers";
import { Framework } from "@superfluid-finance/sdk-core";

export interface Env {
COBWEB_KV: KVNamespace;
ADMIN_KEY: string;
Expand Down Expand Up @@ -33,131 +30,6 @@ const worker = {
);
};

const addNewUser = async () => {
const auth = request.headers.get("Authorization") ?? "";
if (env.ENVIRONMENT === "dev") {
logger(request.headers.get("Authorization") ?? "null", "AUTH");
}

if (
atob(auth.substring(auth.lastIndexOf(" ") + 1)).endsWith(
`:${env.ADMIN_KEY}`
)
) {
const provider = new ethers.providers.InfuraProvider(
env.ENVIRONMENT === "dev" ? "goerli" : "homestead",
{
projectSecret: env.INFURA_API_KEY,
projectId: env.INFURA_ID,
}
);
if (env.ENVIRONMENT === "dev") {
logger(
"Connected to Infura on chain " +
(await provider.getNetwork()).chainId +
".",
"ETH"
);
}

const params = new URLSearchParams(new URL(request.url).search);
const identifier = params.get("identifier");
const address = params.get("address");

if (identifier && address && ethers.utils.isAddress(address)) {
await env.COBWEB_KV.put(address.toLowerCase(), identifier);
const total = await env.COBWEB_KV.get("total");
if (!total) {
await env.COBWEB_KV.put("total", String(100));
}
if (total) {
await env.COBWEB_KV.put("total", String(parseInt(total) - 1));
if (env.ENVIRONMENT === "dev") {
logger(
String(parseInt(total) - 1) + " giveaways remaining.",
"ETH"
);
}
}
const sf = await Framework.create({
chainId: env.ENVIRONMENT === "dev" ? 5 : 1,
provider,
});
const sfToken = await sf.loadSuperToken(env.SF_TOKEN_ADDRESS);
const wallet = new ethers.Wallet(env.MASTER_WALLET_PKEY);
const signer = wallet.connect(provider);
const transferOperation = sfToken.transfer({
receiver: address,
amount: ethers.utils.formatEther(0.2 / 500),
});
try {
transferOperation
.exec(signer)
.then((transaction) => transaction.wait())
.then((transaction) => {
if (env.ENVIRONMENT === "dev") {
logger(String(transaction), "ETH");
}
return new Response(
JSON.stringify({
message: `Associated ${identifier} to ${address} and transferred starter ETH.`,
}),
{
...HEADERS,
status: 200,
}
);
})
.catch((err) => {
if (env.ENVIRONMENT === "dev") {
logger("Error - " + err, "ERROR");
}
return new Response(
JSON.stringify({ error: "Could not transfer" }),
{
...HEADERS,
status: 500,
}
);
});
} catch (err) {
if (env.ENVIRONMENT === "dev") {
logger("Error - " + err, "ERROR");
}
return new Response(
JSON.stringify({ error: "Could not transfer" }),
{
...HEADERS,
status: 500,
}
);
}
}
if (env.ENVIRONMENT === "dev") {
logger("Could not get params - " + params, "PARAMS");
}
return new Response(
JSON.stringify({ error: "No address or no identifier provided" }),
{
...HEADERS,
status: 400,
}
);
} else {
if (env.ENVIRONMENT === "dev") {
logger(
"Unauthorized, attempted: " +
atob(auth.substring(auth.lastIndexOf(" ") + 1)),
"AUTH"
);
}
return new Response(JSON.stringify({ error: "Unauthorized" }), {
...HEADERS,
status: 401,
});
}
};

const returnUserInformation = async (): Promise<Response> => {
const params = new URLSearchParams(new URL(request.url).search);
const address = params.get("address");
Expand Down Expand Up @@ -256,9 +128,7 @@ const worker = {

try {
const url = new URL(request.url);
if (url.pathname === "/add") {
return addNewUser();
} else if (url.pathname === "/request") {
if (url.pathname === "/request") {
return requestNewUser();
} else if (url.pathname === "/report") {
return reportUser();
Expand Down

0 comments on commit a8ea85c

Please sign in to comment.