Skip to content

Commit

Permalink
Setup widgets and bootstrap account (#214)
Browse files Browse the repository at this point in the history
I have setup 4 accounts
`widgets.treasury-factory.near` for all widgets
`bootstrap.treasury-factory.near` for initial/template (app.jsx) widgets

and for testing:
`test-widgets.treasury-factory.near`
`test-bootstrap.treasury-factory.near`

Things to note:
1) The testing accounts folder is symlinked to the prod account, so we
only need to make changes in prod account folder
2) The testing instances is linked to testing widgets account
(`test-widgets.treasury-factory.near`) while prod instances are linked
to prod
3) After merging this PR, we should start raising PR against `staging`
branch (I will change the rules of the repo), which will deploy to
testing instances, widget and bootstrap account, and once everything is
tested we can create PR against `main` which will deploy to all prod
accounts
4) The reference widget for the self create flow will be
`bootstrap.treasury-factory.near` for prod and
`test-bootstrap.treasury-factory.near` for testing.
  • Loading branch information
Megha-Dev-19 authored Jan 15, 2025
1 parent b80b765 commit c9c82e4
Show file tree
Hide file tree
Showing 116 changed files with 454 additions and 37 deletions.
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"
}
1 change: 0 additions & 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
4 changes: 2 additions & 2 deletions instances/treasury-factory.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"REPL_DEVHUB": "devhub.near",
"REPL_DEVHUB_CONTRACT": "devhub.near",
"REPL_BASE_DEPLOYMENT_ACCOUNT": "treasury-factory.near",
"REPL_DEVDAO_ACCOUNT": "treasury-devdao.near",
"REPL_DEVDAO_ACCOUNT": "widgets.treasury-factory.near",
"REPL_SPUTNIK_FACTORY_ACCOUNT": "sputnik-dao.near",
"REPL_FACTORY_REFERENCE_ACCOUNT": "treasury-testing.near",
"REPL_FACTORY_REFERENCE_ACCOUNT": "bootstrap.treasury-factory.near",
"REPL_NEAR": "near",
"REPL_MOB": "mob.near",
"REPL_SOCIAL_CONTRACT": "social.near",
Expand Down
2 changes: 1 addition & 1 deletion instances/treasury-infinex.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"REPL_BASE_DEPLOYMENT_ACCOUNT": "treasury-devdao.near",
"REPL_BASE_DEPLOYMENT_ACCOUNT": "widgets.treasury-factory.near",
"REPL_INSTANCE": "treasury-infinex.near",
"REPL_TREASURY": "infinex.sputnik-dao.near"
}
1 change: 0 additions & 1 deletion instances/treasury-infinex.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
2 changes: 1 addition & 1 deletion instances/treasury-templar.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"REPL_BASE_DEPLOYMENT_ACCOUNT": "treasury-devdao.near",
"REPL_BASE_DEPLOYMENT_ACCOUNT": "widgets.treasury-factory.near",
"REPL_INSTANCE": "treasury-templar.near",
"REPL_TREASURY": "templar.sputnik-dao.near"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"REPL_BASE_DEPLOYMENT_ACCOUNT": "treasury-devdao.near",
"REPL_BASE_DEPLOYMENT_ACCOUNT": "test-widgets.treasury-factory.near",
"REPL_INSTANCE": "treasury-testing-infinex.near",
"REPL_TREASURY": "testing-treasury.sputnik-dao.near"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
return {
appName: "Treasury",
navbarLinks: [
{
title: "Dashboard",
Expand Down
2 changes: 1 addition & 1 deletion instances/treasury-testing.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"REPL_BASE_DEPLOYMENT_ACCOUNT": "treasury-devdao.near",
"REPL_BASE_DEPLOYMENT_ACCOUNT": "test-widgets.treasury-factory.near",
"REPL_INSTANCE": "treasury-testing.near",
"REPL_TREASURY": "testing-astradao.sputnik-dao.near",
"REPL_PROPOSALS_CACHE_URL": "https://devhub-cache-api-rs.fly.dev"
Expand Down
Loading

0 comments on commit c9c82e4

Please sign in to comment.