Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup widgets and bootstrap account (#214) #217

Merged
merged 11 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dry-run
name: Dry-run production

on:
pull_request:
Expand All @@ -12,11 +12,11 @@ jobs:
matrix:
target_account:
- dry_run_command: npm run dry-run:devdao
- dry_run_command: npm run dry-run:testing
- dry_run_command: npm run dry-run:infinex
- dry_run_command: npm run dry-run:infinex-testing
- dry_run_command: npm run dry-run:templar
- dry_run_command: npm run dry-run:treasury-factory
- dry_run_command: npm run dry-run:widgets
- dry_run_command: npm run dry-run:bootstrap
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy Components to Mainnet - Devhub and Testing
name: Deploy Components to Production

on:
push:
Expand All @@ -13,16 +13,16 @@ jobs:
target_account:
- environment: treasury-devdao.near
deploy_command: npm run deploy:devdao
- environment: treasury-testing.near
deploy_command: npm run deploy:testing
- environment: treasury-infinex.near
deploy_command: npm run deploy:infinex
- environment: treasury-testing-infinex.near
deploy_command: npm run deploy:infinex-testing
- environment: treasury-templar.near
deploy_command: npm run deploy:templar
- environment: treasury-factory.near
deploy_command: npm run deploy:treasury-factory
- environment: widgets.treasury-factory.near
deploy_command: npm run deploy:widgets
- environment: bootstrap.treasury-factory.near
deploy_command: npm run deploy:bootstrap
environment: ${{ matrix.target_account.environment }}
steps:
- name: Checkout repository
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/release-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy Components to Staging

on:
push:
branches: [staging]

jobs:
deploy-widgets:
name: Deploy
runs-on: ubuntu-latest
strategy:
matrix:
target_account:
- environment: treasury-testing.near
deploy_command: npm run deploy:testing
- environment: treasury-testing-infinex.near
deploy_command: npm run deploy:infinex-testing
- environment: test-widgets.treasury-factory.near
deploy_command: npm run deploy:test-widgets
- environment: test-bootstrap.treasury-factory.near
deploy_command: npm run deploy:test-bootstrap
environment: ${{ matrix.target_account.environment }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
npm ci
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/bos-cli-rs/bos-cli-rs/releases/download/v0.3.15/bos-cli-installer.sh | sh

- name: Deploy widgets
run: |
${{ matrix.target_account.deploy_command }} -- '${{ vars.NEAR_SOCIAL_ACCOUNT_ID }}' sign-as '${{ vars.NEAR_SOCIAL_ACCOUNT_ID }}' network-config mainnet sign-with-plaintext-private-key --signer-public-key '${{ vars.NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY }}' --signer-private-key '${{ secrets.NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY }}' send
29 changes: 29 additions & 0 deletions .github/workflows/staging-dry-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Dry-run staging

on:
pull_request:
branches: [staging]

jobs:
deploy-widgets:
name: Diff from PR
runs-on: ubuntu-latest
strategy:
matrix:
target_account:
- dry_run_command: npm run dry-run:testing
- dry_run_command: npm run dry-run:infinex-testing
- dry_run_command: npm run dry-run:test-widgets
- dry_run_command: npm run dry-run:test-bootstrap
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
npm ci
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/bos-cli-rs/bos-cli-rs/releases/download/v0.3.15/bos-cli-installer.sh | sh

- name: Dry-run widgets
run: |
${{ matrix.target_account.dry_run_command }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"REPL_BASE_DEPLOYMENT_ACCOUNT": "widgets.treasury-factory.near"
}
6 changes: 6 additions & 0 deletions instances/bootstrap.treasury-factory.near/bos.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"account": "bootstrap.treasury-factory.near",
"aliasPrefix": "REPL",
"aliasesContainsPrefix": true,
"aliases": ["./aliases.mainnet.json"]
}
3 changes: 3 additions & 0 deletions instances/bootstrap.treasury-factory.near/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bootstrap.treasury-factory.near": {}
}
1 change: 1 addition & 0 deletions instances/bootstrap.treasury-factory.near/src
108 changes: 108 additions & 0 deletions instances/bootstrap.treasury-factory.near/widget/app.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* This is the main entry point for the Treasury application.
* Page route gets passed in through params, along with all other page props.
*/

const { page, ...passProps } = props;

// Import our modules
const { AppLayout } = VM.require(
"${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/components.templates.AppLayout"
) || { AppLayout: () => <></> };

const instance = context.widgetSrc?.split("/")[0] ?? "treasury-testing.near";
const treasuryDaoID =
instance.split(".near")[0] ?? "testing-astradao" + "sputnik-dao.near";
const { Theme } = VM.require(`${instance}/widget/config.css`) || {
Theme: () => <></>,
};

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

const propsToSend = { ...passProps, instance: instance };

// 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="${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.dashboard.index"
props={propsToSend}
/>
);
}
// ?page=settings
case "settings": {
return (
<Widget
src={"${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.settings.index"}
props={propsToSend}
/>
);
}
case "payments": {
return (
<Widget
src={"${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.payments.index"}
props={propsToSend}
/>
);
}

case "stake-delegation": {
return (
<Widget
src={
"${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.stake-delegation.index"
}
props={propsToSend}
/>
);
}

case "asset-exchange": {
return (
<Widget
src={
"${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.asset-exchange.index"
}
props={propsToSend}
/>
);
}

case "proposals-feed": {
return (
<Widget
src={
"${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.proposals-feed.index"
}
props={propsToSend}
/>
);
}

default: {
// TODO: 404 page
return <p>404</p>;
}
}
}

return (
<Theme>
<AppLayout
page={page}
instance={instance}
treasuryDaoID={treasuryDaoID}
accountId={context.accountId}
>
<Page />
</AppLayout>
</Theme>
);
27 changes: 27 additions & 0 deletions instances/bootstrap.treasury-factory.near/widget/config/data.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const sputnikAccount =
context.widgetSrc?.split("/")[0].split(".near")[0] ??
"testing-astradao" + "sputnik-dao.near";
return {
navbarLinks: [
{
title: "Dashboard",
href: "?page=dashboard",
},
{
title: "Payments",
href: "?page=payments",
},
{
title: "Stake Delegation",
href: "?page=stake-delegation",
},
{
title: "Settings",
href: "?page=settings",
},
],
treasuryDaoID: sputnikAccount,
showProposalSelection: false,
showKYC: false,
showReferenceProposal: false,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"REPL_BASE_DEPLOYMENT_ACCOUNT": "test-widgets.treasury-factory.near"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"account": "test-bootstrap.treasury-factory.near",
"aliasPrefix": "REPL",
"aliasesContainsPrefix": true,
"aliases": ["./aliases.mainnet.json"]
}
3 changes: 3 additions & 0 deletions instances/test-bootstrap.treasury-factory.near/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"test-bootstrap.treasury-factory.near": {}
}
1 change: 1 addition & 0 deletions instances/test-bootstrap.treasury-factory.near/src
1 change: 1 addition & 0 deletions instances/test-bootstrap.treasury-factory.near/widget
14 changes: 14 additions & 0 deletions instances/test-widgets.treasury-factory.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"REPL_DEVHUB": "devhub.near",
"REPL_DEVHUB_CONTRACT": "devhub.near",
"REPL_BASE_DEPLOYMENT_ACCOUNT": "test-widgets.treasury-factory.near",
"REPL_INSTANCE": "treasury-testing.near",
"REPL_TREASURY": "testing-astradao.sputnik-dao.near",
"REPL_NEAR": "near",
"REPL_MOB": "mob.near",
"REPL_SOCIAL_CONTRACT": "social.near",
"REPL_RPC_URL": "https://rpc.mainnet.near.org",
"REPL_PROPOSALS_CACHE_URL": "https://devhub-cache-api-rs.fly.dev",
"REPL_PIKESPEAK_KEY": "36f2b87a-7ee6-40d8-80b9-5e68e587a5b5",
"REPL_NEARBLOCKS_KEY": "DA2570E26C0242FF897A463F4DCAACA6"
}
6 changes: 6 additions & 0 deletions instances/test-widgets.treasury-factory.near/bos.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"account": "test-widgets.treasury-factory.near",
"aliasPrefix": "REPL",
"aliasesContainsPrefix": true,
"aliases": ["./aliases.mainnet.json"]
}
3 changes: 3 additions & 0 deletions instances/test-widgets.treasury-factory.near/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"test-widgets.treasury-factory.near": {}
}
1 change: 1 addition & 0 deletions instances/test-widgets.treasury-factory.near/src
1 change: 1 addition & 0 deletions instances/test-widgets.treasury-factory.near/widget
12 changes: 2 additions & 10 deletions instances/treasury-devdao.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{
"REPL_DEVHUB": "devhub.near",
"REPL_DEVHUB_CONTRACT": "devhub.near",
"REPL_BASE_DEPLOYMENT_ACCOUNT": "treasury-devdao.near",
"REPL_BASE_DEPLOYMENT_ACCOUNT": "widgets.treasury-factory.near",
"REPL_INSTANCE": "treasury-devdao.near",
"REPL_TREASURY": "devdao.sputnik-dao.near",
"REPL_NEAR": "near",
"REPL_MOB": "mob.near",
"REPL_SOCIAL_CONTRACT": "social.near",
"REPL_RPC_URL": "https://rpc.mainnet.near.org",
"REPL_PROPOSALS_CACHE_URL": "https://devhub-cache-api-rs.fly.dev",
"REPL_PIKESPEAK_KEY": "36f2b87a-7ee6-40d8-80b9-5e68e587a5b5",
"REPL_NEARBLOCKS_KEY": "DA2570E26C0242FF897A463F4DCAACA6"
"REPL_PROPOSALS_CACHE_URL": "https://devhub-cache-api-rs.fly.dev"
}
22 changes: 8 additions & 14 deletions instances/treasury-devdao.near/widget/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ const { AppLayout } = VM.require(
const instance = "${REPL_INSTANCE}";
const treasuryDaoID = "${REPL_TREASURY}";

const { Theme } = VM.require(`${instance}/widget/config.css`) || {
Theme: () => <></>,
};

if (!page) {
// If no page is specified, we default to the feed page TEMP
page = "dashboard";
Expand Down Expand Up @@ -84,14 +80,12 @@ function Page() {
}

return (
<Theme>
<AppLayout
page={page}
instance={instance}
treasuryDaoID={treasuryDaoID}
accountId={context.accountId}
>
<Page />
</AppLayout>
</Theme>
<AppLayout
page={page}
instance={instance}
treasuryDaoID={treasuryDaoID}
accountId={context.accountId}
>
<Page />
</AppLayout>
);
5 changes: 0 additions & 5 deletions instances/treasury-devdao.near/widget/config/css.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion instances/treasury-devdao.near/widget/config/data.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
return {
appName: "Treasury",
navbarLinks: [
{
title: "Dashboard",
Expand Down Expand Up @@ -49,4 +48,5 @@ return {
</defs>
</svg>
),
themeColor: "#05a36e",
};
Loading
Loading