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

weekly promotion of develop to main #458

Merged
merged 15 commits into from
Jul 8, 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
33 changes: 33 additions & 0 deletions .github/workflows/web4-deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy to production
on:
push:
branches: [main]
paths:
- web4contract/**

defaults:
run:
working-directory: ./web4contract

jobs:
test:
uses: ./.github/workflows/web4-test.yml

deploy-staging:
name: Deploy to production
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cargo-near CLI
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/download/cargo-near-v0.6.2/cargo-near-installer.sh | sh
- name: Deploy to production
run: |
cargo near deploy "${{ vars.BOS_DEPLOY_ACCOUNT_ID }}" \
without-init-call \
network-config "mainnet" \
sign-with-plaintext-private-key \
--signer-public-key "${{ vars.BOS_SIGNER_PUBLIC_KEY }}" \
--signer-private-key "${{ secrets.BOS_BUILDDAO_SIGNER_PRIVATE_KEY }}" \
send
58 changes: 58 additions & 0 deletions .github/workflows/web4-deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Deploy to staging
on:
pull_request:
paths:
- web4contract/**

defaults:
run:
working-directory: ./web4contract

jobs:
test:
uses: ./.github/workflows/web4-test.yml

deploy-staging:
name: Deploy to staging subaccount
permissions:
pull-requests: write
needs: [test]
runs-on: ubuntu-latest
env:
NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID: gh-${{ github.event.number }}.${{ vars.BOS_TESTNET_SIGNER_ACCOUNT_ID }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install near CLI
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.11.1/near-cli-rs-installer.sh | sh
- name: Create staging account
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: |
near account create-account fund-myself "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" '10 NEAR' \
use-manually-provided-public-key "${{ vars.BOS_TESTNET_SIGNER_PUBLIC_KEY }}" \
sign-as "${{ vars.BOS_TESTNET_SIGNER_ACCOUNT_ID }}" \
network-config "testnet" \
sign-with-plaintext-private-key \
--signer-public-key "${{ vars.BOS_TESTNET_SIGNER_PUBLIC_KEY }}" \
--signer-private-key "${{ secrets.BOS_BUILDDAO_TESTNET_SIGNER_PRIVATE_KEY }}" \
send

- name: Install cargo-near CLI
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/download/cargo-near-v0.6.2/cargo-near-installer.sh | sh
- name: Deploy to staging
run: |
cargo near deploy "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" \
without-init-call \
network-config "testnet" \
sign-with-plaintext-private-key \
--signer-public-key "${{ vars.BOS_TESTNET_SIGNER_PUBLIC_KEY }}" \
--signer-private-key "${{ secrets.BOS_BUILDDAO_TESTNET_SIGNER_PRIVATE_KEY }}" \
send

- name: Comment on pull request
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr comment "${{ github.event.number }}" --body "Staging contract is deployed to ["'`'"${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}"'`'" account](https://explorer.testnet.near.org/accounts/${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }})"
36 changes: 36 additions & 0 deletions .github/workflows/web4-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test
on:
workflow_call:

defaults:
run:
working-directory: ./web4contract

jobs:
code-formatting:
name: Code Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: cargo fmt --check

code-linter:
name: Code Linter
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run cargo clippy
run: |
rustup component add clippy
cargo clippy --all-features --workspace --tests -- --warn clippy::all --warn clippy::nursery

tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run cargo test
run: cargo test
31 changes: 31 additions & 0 deletions .github/workflows/web4-undeploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Undeploy staging
on:
pull_request:
types: [closed]
paths:
- web4contract/**

defaults:
run:
working-directory: ./web4contract

jobs:
cleanup-staging:
name: Cleanup staging account
runs-on: ubuntu-latest
env:
NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID: gh-${{ github.event.number }}.${{ vars.BOS_TESTNET_SIGNER_ACCOUNT_ID }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install near CLI
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.11.1/near-cli-rs-installer.sh | sh
- name: Remove staging account
run: |
near account delete-account "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" \
beneficiary "${{ vars.BOS_TESTNET_SIGNER_ACCOUNT_ID }}" \
network-config "testnet" \
sign-with-plaintext-private-key \
--signer-public-key "${{ vars.BOS_TESTNET_SIGNER_PUBLIC_KEY }}" \
--signer-private-key "${{ secrets.BOS_BUILDDAO_TESTNET_SIGNER_PRIVATE_KEY }}" \
send
17 changes: 17 additions & 0 deletions apps/new/widget/Index.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Build DAO",
"description": "Support Systems for Open Web Projects",
"linktree": {
"website": "nearbuilders.org"
},
"image": {
"ipfs_cid": "bafkreie5hd6cfckrpyx6nmtgwzlmsd356nh2e6pqeryond3b54ejqeszqi"
},
"tags": {
"build": "",
"dao": "",
"public-goods": "",
"open-source": "",
"app": ""
}
}
30 changes: 17 additions & 13 deletions apps/new/widget/page/project/tabs/Overview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,23 @@ return (
</p>
</div>
<div className="d-flex gap-5">
<div className="section">
<p className="heading">Location</p>
<p className="description d-flex align-items-center gap-2">
<MapIcon /> {location ?? "No Location"}
</p>
</div>
<div className="section">
<p className="heading">Team Size</p>
<p className="description d-flex align-items-center gap-2">
<i className="bi bi-person"></i>
{teamSize || "unspecified"}
</p>
</div>
{location && (
<div className="section">
<p className="heading">Location</p>
<p className="description d-flex align-items-center gap-2">
<MapIcon /> {location ?? "No Location"}
</p>
</div>
)}
{teamSize && (
<div className="section">
<p className="heading">Team Size</p>
<p className="description d-flex align-items-center gap-2">
<i className="bi bi-person"></i>
{teamSize || "unspecified"}
</p>
</div>
)}
</div>
<div className="section">
<p className="heading">Contributors</p>
Expand Down
7 changes: 5 additions & 2 deletions apps/new/widget/page/project/tabs/Task.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ const { normalize } = VM.require("${alias_devs}/widget/lib.stringUtils") || {
normalize: () => {},
};

const { getProjectMeta } = VM.require("${alias_new}/widget/lib.projects") || {
const { getProjectMeta, getProjectIdFromPath } = VM.require(
"${alias_new}/widget/lib.projects",
) || {
getProjectMeta: () => {},
getProjectIdFromPath: () => {},
};

const { id } = props;
Expand Down Expand Up @@ -136,7 +139,7 @@ const Wrapper = styled.div`
}
`;

const projectID = normalize(project?.title, "-");
const projectID = getProjectIdFromPath(id);

const StatusValues = {
PROPOSED: "proposed",
Expand Down
8 changes: 7 additions & 1 deletion apps/new/widget/page/projects/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,15 @@ const [projectIdForSocialDB, setProjectId] = useState(null); // for edit changes
const [contributorSearchTerm, setContributorSearch] = useState("");
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [showDeleteSuccessModal, setShowDeleteSuccessModal] = useState(false);
const [onCreateLoader, setCreateLoader] = useState(false);

function removeWhiteSpace(str) {
return str.replace(/\s/g, "-").toLowerCase();
}

function convertArrayToObject(array) {
const obj = {};
array.forEach((value, index) => {
(array ?? []).forEach((value, index) => {
obj[value] = "";
});
return obj;
Expand Down Expand Up @@ -568,6 +569,7 @@ const DeleteConfirmationModal = () => {
};

function onCreateProject() {
setCreateLoader(true);
const projectID = isEditScreen ? projectIdForSocialDB : normalize(title, "-");
const project = {
title,
Expand Down Expand Up @@ -651,8 +653,10 @@ function onCreateProject() {
} else {
Social.set(data, {
onCommit: () => {
setCreateLoader(false);
setShowSuccessModal(true);
},
onCancel: () => setCreateLoader(false),
});
}
}
Expand Down Expand Up @@ -759,6 +763,7 @@ const DeleteProjectBtn = () => {
<Button
variant="outline"
className="destructive"
loading={showDeleteModal}
onClick={() => setShowDeleteModal(true)}
>
Delete Project
Expand Down Expand Up @@ -943,6 +948,7 @@ const SecondScreen = () => {
variant="primary"
onClick={onCreateProject}
disabled={invalidContributorFound}
loading={onCreateLoader}
>
{isEditScreen ? "Save Changes" : "Create"}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion apps/old/widget/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function Button({
return (
<StyledButton
id={id}
disabled={disabled}
disabled={disabled || loading}
key={`Button-${type ?? "Normal"}-${variant ?? "Default"}-${id}`}
className={className}
variant={variant}
Expand Down
62 changes: 53 additions & 9 deletions apps/old/widget/components/UploadField.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
const initialMsg = (
<>
<i className="bi bi-cloud-upload"></i>
<div className="d-flex flex-column gap-2">
<p>Choose a file or drag & drop it here.</p>
<p className="secondary">JPEG, PNG, PDF, and MP4 formats, up to 50 MB.</p>
</div>
</>
);

const [img, setImg] = useState("");
const [msg, setMsg] = useState("Upload");
const [displayText, setDisplayText] = useState(initialMsg);

const SpinningIcon = styled.i`
animation: spin 0.8s linear infinite;
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
`;
const uploadFile = (files) => {
setMsg("Uploading...");
setDisplayText(
<>
<SpinningIcon className="bi bi-arrow-repeat" />
<p>Uploading...</p>
</>,
);
asyncFetch("https://ipfs.near.social/add", {
method: "POST",
headers: { Accept: "application/json" },
body: files[0],
})
.catch((e) => {
console.error(e);
setMsg("Failed to upload");
console.error("Upload error:", e);
setDisplayText(
<>
<i className="bi bi-exclamation-triangle text-danger"></i>
<p>Failed to upload. Please try again.</p>
</>,
);
})
.then((res) => {
setImg(res.body.cid);
Expand All @@ -18,6 +50,22 @@ const uploadFile = (files) => {
ipfs_cid: res.body.cid,
});
}
if (res.body.cid) {
setDisplayText(
<>
<i className="bi bi-check-circle text-success"></i>
<p>Upload successful!</p>
</>,
);
setTimeout(() => setDisplayText(""), 1500);
} else {
setDisplayText(
<>
<i className="bi bi-exclamation-triangle text-danger"></i>
<p>Failed to upload. Please try again.</p>
</>,
);
}
});
};

Expand Down Expand Up @@ -102,11 +150,7 @@ const UploadedImage = styled.img`

return (
<UploadContainer background={background}>
<i class="bi bi-cloud-upload"></i>
<div className="d-flex flex-column gap-2">
<p>Choose a file or drag & drop it here.</p>
<p className="secondary">JPEG, PNG, PDF, and MP4 formats, up to 50 MB.</p>
</div>
{msg}
<ButtonContainer>
<Button>
<Files
Expand Down
2 changes: 1 addition & 1 deletion apps/old/widget/components/User.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const Overlay = (props) => (
<Link
className="link-dark text-truncate d-inline-flex mw-100"
to={href({
widgetSrc: "${config_index}",
widgetSrc: "${alias_new}/widget/Index",
params: {
page: "profile",
accountId,
Expand Down
Loading
Loading