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

Upgrades to bos-workspace v1 #572

Merged
merged 8 commits into from
May 20, 2024
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
11 changes: 5 additions & 6 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
cache: "yarn"
- name: Install dependencies
run: npm ci
run: yarn install --frozen-lockfile
- name: Run code formatting check
run: npm run fmt:check
run: yarn run fmt:check
playwright-tests:
name: Playwright tests
runs-on: ubuntu-latest
Expand All @@ -27,11 +27,10 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
cache: "yarn"
- name: Install dependencies
run: |
npm ci
npm install bos-workspace
yarn add bos-workspace
npx playwright install-deps
npx playwright install
- name: Run tests
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ This repository holds the front-end widgets for [PotLock](https://app.potlock.or
1. Install packages

```cmd
npm install
yarn install
```

2. Start dev environment

```cmd
npm run dev
yarn dev
```

This will start a gateway at http://127.0.0.1:8080 which will render your local widgets. The entry point for this app is [potlock.near/widget/Index](http://127.0.0.1:8080/potlock.near/widget/Index).
This will start a gateway at <http://127.0.0.1:8080> which will render your local widgets. The entry point for this app is [potlock.near/widget/Index](http://127.0.0.1:8080/potlock.near/widget/Index).

## Testing framework

Expand Down
8 changes: 8 additions & 0 deletions apps/potlock/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"potlock_new": "potlock.near",
"devs": "devs.near",
"mob": "mob.near",
"near": "near",
"socialdb": "social.near",
"gateway_url": "https://nearbuilders.org"
}
8 changes: 8 additions & 0 deletions apps/potlock/aliases.testnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"potlock_new": "potlock.testnet",
"devs": "neardevs.testnet",
"mob": "mike.testnet",
"near": "discom.testnet",
"socialdb": "v1.social08.testnet",
"gateway_url": "https://test.nearbuilders.org"
}
9 changes: 8 additions & 1 deletion apps/potlock/bos.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"appAccount": "potlock.near"
"account": "old.potlock.near",
"aliases": ["./aliases.mainnet.json"],
"overrides": {
"testnet": {
"account": "old.potlock.testnet",
"aliases": ["./aliases.testnet.json"]
}
}
}
3 changes: 3 additions & 0 deletions apps/potlock/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"old.potlock.near": {}
}
4 changes: 2 additions & 2 deletions apps/potlock/widget/Cart/AddToCart.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { handleCallback, item, text } = props;

const { addItemsToCart, removeItemsFromCart, itemExistsInCart } = VM.require(
"potlock.near/widget/SDK.cart"
"${config_account}/widget/SDK.cart"
) ?? {
addItemsToCart: () => {},
removeItemsFromCart: () => {},
Expand All @@ -12,7 +12,7 @@ const existsInCart = itemExistsInCart(item);

return (
<Widget
src={"potlock.near/widget/Components.Button"}
src={"${config_account}/widget/Components.Button"}
props={{
type: "tertiary",
text: text || (existsInCart ? "Remove from cart" : "Add to cart"),
Expand Down
6 changes: 3 additions & 3 deletions apps/potlock/widget/Cart/BreakdownSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ const {
chef,
chefFeeBasisPoints,
} = props;
const { basisPointsToPercent } = VM.require("potlock.near/widget/utils") || {
const { basisPointsToPercent } = VM.require("${config_account}/widget/utils") || {
basisPointsToPercent: () => 0,
};

const { SUPPORTED_FTS } = VM.require("potlock.near/widget/constants") || {
const { SUPPORTED_FTS } = VM.require("${config_account}/widget/constants") || {
SUPPORTED_FTS: {},
};

let DonateSDK =
VM.require("potlock.near/widget/SDK.donate") ||
VM.require("${config_account}/widget/SDK.donate") ||
(() => ({
getConfig: () => {},
}));
Expand Down
2 changes: 1 addition & 1 deletion apps/potlock/widget/Cart/CartModalItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if (!profile) return "";
return (
<ItemContainer>
<Widget
src="mob.near/widget/ProfileImage"
src="${alias_mob}/widget/ProfileImage"
props={{
accountId: props.projectId,
style: {
Expand Down
16 changes: 8 additions & 8 deletions apps/potlock/widget/Cart/Checkout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const IPFS_BASE_URL = "https://nftstorage.link/ipfs/";
// IPFS_BASE_URL + "bafkreifuvrxly3wuy4xdmavmdeb2o47nv6pzxwz3xmy6zvkxv76e55lj3y";

const { getCart, getCartItemCount, removeItemsFromCart } = VM.require(
"potlock.near/widget/SDK.cart"
"${config_account}/widget/SDK.cart"
) || {
getCart: () => {},
getCartItemCount: () => 0,
Expand Down Expand Up @@ -220,7 +220,7 @@ const twitterIntent = useMemo(() => {
const twitterIntentBase = "https://twitter.com/intent/tweet?text=";

// if more than one recipient, share the Explore Projects page; otherwise, share the project page
let url = DEFAULT_GATEWAY + `potlock.near/widget/Index?referrerId=${context.accountId}`;
let url = DEFAULT_GATEWAY + `${config_account}/widget/Index?referrerId=${context.accountId}`;
if (recipientIds.length === 1) {
url = url + `&tab=project&projectId=${recipientIds[0]}`;
} else {
Expand Down Expand Up @@ -273,7 +273,7 @@ return (
<Title>Thanks for donating!</Title>
{twitterIntent && (
<Widget
src={"potlock.near/widget/Components.Button"}
src={"${config_account}/widget/Components.Button"}
props={{
href: twitterIntent,
target: "_blank",
Expand All @@ -287,7 +287,7 @@ return (
/>
)}
<Widget
src={"potlock.near/widget/Components.Button"}
src={"${config_account}/widget/Components.Button"}
props={{
href: props.hrefWithParams(`?tab=projects`),
type: twitterIntent ? "secondary" : "primary",
Expand All @@ -307,7 +307,7 @@ return (
) : (
props.checkoutSuccessTxHash && (
<Widget
src={"potlock.near/widget/Components.Button"}
src={"${config_account}/widget/Components.Button"}
props={{
href: `https://nearblocks.io/txns/${props.checkoutSuccessTxHash}`,
target: "_blank",
Expand All @@ -329,7 +329,7 @@ return (
<ActionsContainer>
<InnerContainer>
<Widget
src={"potlock.near/widget/Inputs.Checkbox"}
src={"${config_account}/widget/Inputs.Checkbox"}
props={{
id: "masterSelector",
disabled: numCartItems === 0,
Expand Down Expand Up @@ -380,7 +380,7 @@ return (
const checked = state.selectedProjectIds.includes(projectId);
return (
<Widget
src={"potlock.near/widget/Cart.CheckoutItem"}
src={"${config_account}/widget/Cart.CheckoutItem"}
props={{
...props,
cartItem: cart[projectId],
Expand Down Expand Up @@ -413,7 +413,7 @@ return (
</ColumnLeft>
<ColumnRight>
<Widget
src={"potlock.near/widget/Cart.CheckoutBreakdown"}
src={"${config_account}/widget/Cart.CheckoutBreakdown"}
props={{
...props,
projectId: projectId,
Expand Down
12 changes: 6 additions & 6 deletions apps/potlock/widget/Cart/CheckoutBreakdown.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const { yoctosToNear } = VM.require("potlock.near/widget/utils") || { yoctosToNear: () => "" };
const { SUPPORTED_FTS } = VM.require("potlock.near/widget/constants") || {
const { yoctosToNear } = VM.require("${config_account}/widget/utils") || { yoctosToNear: () => "" };
const { SUPPORTED_FTS } = VM.require("${config_account}/widget/constants") || {
SUPPORTED_FTS: {},
};

const { getCart, clearCart } = VM.require("potlock.near/widget/SDK.cart") || {
const { getCart, clearCart } = VM.require("${config_account}/widget/SDK.cart") || {
getCart: () => {},
clearCart: () => {},
};

const cart = getCart();

const PotSDK = VM.require("potlock.near/widget/SDK.pot") || {
const PotSDK = VM.require("${config_account}/widget/SDK.pot") || {
asyncGetDonationsForDonor: () => {},
};

let DonateSDK =
VM.require("potlock.near/widget/SDK.donate") ||
VM.require("${config_account}/widget/SDK.donate") ||
(() => ({
asyncGetDonationsForDonor: () => {},
getContractId: () => "",
Expand Down Expand Up @@ -280,7 +280,7 @@ return (
</TotalContainer>
)}
<Widget
src={"potlock.near/widget/Components.Button"}
src={"${config_account}/widget/Components.Button"}
props={{
type: "primary",
text: `Process Donation`,
Expand Down
20 changes: 11 additions & 9 deletions apps/potlock/widget/Cart/CheckoutItem.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const { basisPointsToPercent } = VM.require("potlock.near/widget/utils") || {
const { basisPointsToPercent } = VM.require("${config_account}/widget/utils") || {
basisPointsToPercent: () => 0,
};
const { SUPPORTED_FTS } = VM.require("potlock.near/widget/constants") || {
const { SUPPORTED_FTS } = VM.require("${config_account}/widget/constants") || {
SUPPORTED_FTS: {},
};

const { removeItemsFromCart, updateItemInCart } = VM.require("potlock.near/widget/SDK.cart") || {
const { removeItemsFromCart, updateItemInCart } = VM.require(
"${config_account}/widget/SDK.cart"
) || {
removeItemsFromCart: () => {},
updateItemInCart: () => {},
};
Expand Down Expand Up @@ -171,7 +173,7 @@ return (
<ItemContainer>
<ItemLeft>
<Widget
src={"potlock.near/widget/Inputs.Checkbox"}
src={"${config_account}/widget/Inputs.Checkbox"}
props={{
id: "selector-" + projectId,
checked,
Expand All @@ -182,7 +184,7 @@ return (
<ItemRight>
<ImageContainer>
<Widget
src="mob.near/widget/ProfileImage"
src="${alias_mob}/widget/ProfileImage"
props={{
accountId: projectId,
style: {
Expand All @@ -203,7 +205,7 @@ return (
{profile.name ?? ""}
</Title>
<Widget
src={"potlock.near/widget/Pots.Tag"}
src={"${config_account}/widget/Pots.Tag"}
props={{
...props,
backgroundColor: isPotDonation ? "#FEF6EE" : "#F6F5F3",
Expand All @@ -219,7 +221,7 @@ return (
</Row>
<Description>{profile.description ?? ""}</Description>
<Widget
src={"potlock.near/widget/Inputs.Text"}
src={"${config_account}/widget/Inputs.Text"}
props={{
label: "Amount",
placeholder: "0",
Expand All @@ -241,7 +243,7 @@ return (
},
preInputChildren: (
<Widget
src={"potlock.near/widget/Inputs.Select"}
src={"${config_account}/widget/Inputs.Select"}
props={{
noLabel: true,
placeholder: "",
Expand Down Expand Up @@ -277,7 +279,7 @@ return (
}}
/>
<Widget
src={"potlock.near/widget/Cart.BreakdownSummary"}
src={"${config_account}/widget/Cart.BreakdownSummary"}
props={{
...props,
ftIcon: itemToken.icon,
Expand Down
10 changes: 5 additions & 5 deletions apps/potlock/widget/Cart/Modal.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { getCartItemCount, getCart, removeItemsFromCart } = VM.require(
"potlock.near/widget/SDK.cart"
"${config_account}/widget/SDK.cart"
) ?? {
getCartItemCount: () => 0,
getCart: () => {},
Expand Down Expand Up @@ -131,7 +131,7 @@ const CartModal = ({ Trigger }) => {
(Object.keys(cart) ?? []).map((projectId) => {
return (
<Widget
src={"potlock.near/widget/Cart.CartModalItem"}
src={"${config_account}/widget/Cart.CartModalItem"}
props={{
...props,
projectId,
Expand All @@ -148,13 +148,13 @@ const CartModal = ({ Trigger }) => {
)}
<ButtonContainer>
<Widget
src={"potlock.near/widget/Components.Button"}
src={"${config_account}/widget/Components.Button"}
props={{
type: "primary",
text: "Proceed to donate",
disabled: numCartItems === 0,
href: href({
widgetSrc: "potlock.near/widget/Index",
widgetSrc: "${config_account}/widget/Index",
params: { tab: "cart", referrerId: props.referrerId },
}),
style: {
Expand All @@ -164,7 +164,7 @@ const CartModal = ({ Trigger }) => {
}}
/>
<Widget
src={"potlock.near/widget/Components.Button"}
src={"${config_account}/widget/Components.Button"}
props={{
type: numCartItems === 0 ? "primary" : "secondary",
text: "Continue shopping",
Expand Down
4 changes: 2 additions & 2 deletions apps/potlock/widget/Cart/NavItem.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { getCartItemCount } = VM.require("potlock.near/widget/SDK.cart") ?? {
const { getCartItemCount } = VM.require("${config_account}/widget/SDK.cart") ?? {
getCartItemCount: () => 0,
};

const { CartModal } = VM.require("potlock.near/widget/Cart.Modal") ?? {
const { CartModal } = VM.require("${config_account}/widget/Cart.Modal") ?? {
CartModal: () => <></>,
};

Expand Down
2 changes: 1 addition & 1 deletion apps/potlock/widget/Components/AccountsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ return (
<MembersListItem>
<MembersListItemLeft>
<Widget
src="mob.near/widget/ProfileImage"
src="${alias_mob}/widget/ProfileImage"
props={{
accountId,
style: {
Expand Down
2 changes: 1 addition & 1 deletion apps/potlock/widget/Components/AccountsStack.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ return (
{accounts.map((accountId, idx) => {
return (
<Widget
src="mob.near/widget/ProfileImage"
src="${alias_mob}/widget/ProfileImage"
props={{
accountId,
style: {
Expand Down
4 changes: 2 additions & 2 deletions apps/potlock/widget/Components/Banner.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
let PotFactorySDK =
VM.require("potlock.near/widget/SDK.potfactory") ||
VM.require("${config_account}/widget/SDK.potfactory") ||
(() => ({
getPots: () => {},
}));

const PotSDK = VM.require("potlock.near/widget/SDK.pot") || {
const PotSDK = VM.require("${config_account}/widget/SDK.pot") || {
asyncGetConfig: () => {},
};

Expand Down
Loading
Loading