Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sczembor committed Dec 9, 2023
2 parents d32eb63 + 4e1481b commit 8f9abbf
Show file tree
Hide file tree
Showing 71 changed files with 14,189 additions and 4,232 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/deploy-widgets-mainnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Deploy 'QuestVerse' App Components to Mainnet

on:
push:
branches: [main]

jobs:
deploy-mainnet:
uses: nearbuilders/bos-workspace/.github/workflows/deploy.yml@main
with:
deploy-env: "mainnet"
app-name: "QuestVerse"
working-directory: "questverse-widgets"
deploy-account-address: ${{ vars.PROD_SIGNER_ACCOUNT_ID }}
signer-account-address: ${{ vars.PROD_SIGNER_ACCOUNT_ID }}
signer-public-key: ${{ vars.PROD_SIGNER_PUBLIC_KEY }}
secrets:
SIGNER_PRIVATE_KEY: ${{ secrets.PROD_SIGNER_PRIVATE_KEY }}
3 changes: 2 additions & 1 deletion questverse-widgets/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
/build
/node_modules
.vscode
.DS_Store
17 changes: 17 additions & 0 deletions questverse-widgets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Getting Started

```
npm install
```

Then, run the command:

```
npm run dev
```

This will serve the widgets from `http://127.0.0.1:4040/`.

Go to [everything.dev/flags](https://everything.dev) and paste this value there.

Once set, see the locally served app at [bos.questverse.near/widget/app](https://everything.dev/bos.questverse.near/widget/app).
8 changes: 8 additions & 0 deletions questverse-widgets/apps/QuestVerse/bos.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"appAccount": "bos.questverse.near",
"aliases": {
"QUESTVERSE_CONTRACT": "v1.questverse.near",
"QUERYAPI_CONTRACT": "queryapi.dataplatform.near",
"API_SIGNER_SERVICE": "https://"
}
}
76 changes: 76 additions & 0 deletions questverse-widgets/apps/QuestVerse/widget/app.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const { page, ...passProps } = props;

const { AppLayout } = VM.require(
"/*__@appAccount__*//widget/components.Layout"
);

if (!AppLayout) {
return <p>Loading modules...</p>;
}

// CSS styles to be used across the app.
// Define fonts here, as well as any other global styles.
const Theme = styled.div`
a {
color: inherit;
}
width: 100%;
height: 100vh;
`;

if (!page) {
// If no page is specified, we default to the feed page TEMP
page = "dashboard";
}

// This is our navigation, rendering the page based on the page parameter
function Page() {
const routes = page.split(".");
switch (routes[0]) {
case "dashboard": {
return (
<Widget
src="/*__@appAccount__*//widget/pages.Dashboard"
props={passProps}
/>
);
}
case "discover": {
return (
<Widget
src="/*__@appAccount__*//widget/pages.Discover"
props={passProps}
/>
);
}
case "create": {
return (
<Widget
src="/*__@appAccount__*//widget/pages.Create"
props={passProps}
/>
);
}
case "quest": {
return (
<Widget
src="/*__@appAccount__*//widget/pages.Quest"
props={passProps}
/>
);
}
default: {
// TODO: 404 page
return <p>404</p>;
}
}
}

return (
<Theme>
<AppLayout page={page}>
<Page />
</AppLayout>
</Theme>
);
46 changes: 46 additions & 0 deletions questverse-widgets/apps/QuestVerse/widget/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const Toolbar = styled.div`
margin-left: 20px;
@media only screen and (max-width: 1061px) {
margin: 10px 0 0 0;
}
`;

const registryContract = "registry.i-am-human.near";
const issuer = "fractal.i-am-human.near";

// SBT verification
let isVerified = false;
const userSBTs = Near.view("registry.i-am-human.near", "sbt_tokens_by_owner", {
account: context.accountId,
});

for (let i = 0; i < userSBTs.length; i++) {
if ("fractal.i-am-human.near" == userSBTs[i][0]) {
isVerified = true;
}
}

return (
<div className="d-flex p-3 px-4 align-items-center rounded justify-content-between bg-black">
<h3 className="mt-2" style={{ fontFamily: "Courier", color: "white" }}>
<Link to="//*__@appAccount__*//widget/app">
<b>QuestVerse</b>
</Link>
</h3>
<Toolbar>
{!isVerified ? (
<Widget
src="hack.near/widget/n.style"
props={{
Link: {
text: "Get Verified",
href: "https://i-am-human.app/",
},
}}
/>
) : (
<Widget src="hack.near/widget/start" />
)}
</Toolbar>
</div>
);
60 changes: 60 additions & 0 deletions questverse-widgets/apps/QuestVerse/widget/components/Layout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const Container = styled.div`
display: flex;
flex-direction: column;
width: 100%;
height: auto;
min-height: 100vh;
background: #f4f4f4;
margin-top: calc(-1 * var(--body-top-padding));
`;

const ContentContainer = styled.div`
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
`;

const Header = styled.div`
background: black;
`;

const registryContract = "registry.i-am-human.near";
const issuer = "fractal.i-am-human.near";

// SBT verification
let isVerified = false;
const userSBTs = Near.view("registry.i-am-human.near", "sbt_tokens_by_owner", {
account: props.accountId ?? context.accountId,
});

for (let i = 0; i < userSBTs.length; i++) {
if ("fractal.i-am-human.near" == userSBTs[i][0]) {
isVerified = true;
}
}

const AppHeader = ({ page }) => (
<Widget src="/*__@appAccount__*//widget/components.Header" props={{ page }} />
);

const Footer = ({ page }) => {
return <></>;
};

function AppLayout({ page, children }) {
return (
<>
<Container>
<AppHeader page={page} />
<ContentContainer>{children}</ContentContainer>
<Footer page={page} />
</Container>
</>
);
}

return { AppLayout };
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// import StepOne from "./StepOne";
// const { StepOne } = require("bos.questverse.near/newQuestComponents.StepOne");

const { fetch_step_one_data } = VM.require(
"/*__@appAccount__*//widget/data.data_stepOne"
);
const stepOneData = fetch_step_one_data();
// const {stepOneData, stepTwoData} = VM.require("bos.questverse.near/module/data_all"); I can do it like this
// const { StepOne } = require("./bos.questverse.near/newQuestComponents.StepTwo");

State.init({
step: 1,
formData: {
//STEP 1
selectedCurrency: "",
selectedOption: "",
selectedFields: [],
//STEP 2
// audienceGroups: [],

//STEP 3


//
},
});

function handleNext(data) {
State.update({
formData: { ...state.formData, ...data },
step: state.step + 1,
});
}

function handlePrevious() {
State.update({
step: state.step + 1,
});
}

function renderStep() {
switch (step) {
case 1:
return (
<Widget
src={"/*__@appAccount__*//widget/components.createQuestSteps.stepOne"}
props={{
data: stepOneData,
onNext: handleNext,
}}
/>
);
case 2:
return <StepTwo onNext={handleNext} />;
// case 3:
// return <StepThree data={} onNext={handleNext} onPrevious={handlePrevious} />;
default:
return (
<Widget
src={"/*__@appAccount__*//widget/components.createQuestSteps.stepOne"}
props={{
data: stepOneData,
onNext: handleNext,
}}
/>
);
}
}

return (
<div>
<h1>Create Quest</h1>
{renderStep()}

{state.step !== 1 && (
<button type="button" onClick={handlePrevious}>
Previous
</button>
)}

{state.step === totalSteps && <button type="submit">Submit</button>}
</div>
);

//I wanted to pass in all JSON configs here



/**
*
* JSON -> Functions w req
*
*
*/



/**
*
*
* CREATE QUEST
*/
Loading

0 comments on commit 8f9abbf

Please sign in to comment.