Skip to content

Commit

Permalink
Merge branch 'main' into style-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
frol authored Jan 13, 2025
2 parents bc25d2a + e4f6dc2 commit 2c1320a
Show file tree
Hide file tree
Showing 15 changed files with 753 additions and 465 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/deploy-treasury-factory-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@ on:
workflow_dispatch: # This allows manual triggering

jobs:
test:
uses: ./.github/workflows/test-treasury-fatctory-contract.yml

deploy:
name: Deploy to production
needs: [test]
runs-on: ubuntu-latest
environment: "treasury-factory.near"
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/latest/download/cargo-near-installer.sh | sh
- name: Deploy
run: |
cargo near deploy --no-docker "${{ vars.TREASURY_FACTORY_ACCOUNT_ID }}" \
cargo build # TODO: Remove this step once https://github.com/near/cargo-near/issues/287 is fixed
cargo near deploy build-non-reproducible-wasm "${{ vars.NEAR_SOCIAL_ACCOUNT_ID }}" \
without-init-call \
network-config mainnet \
--signer-public-key "${{ vars.TREASURY_FACTORY_ACCOUNT_PUBLIC_KEY }}" \
--signer-private-key "${{ secrets.TREASURY_FACTORY_ACCOUNT_PRIVATE_KEY }}" \
sign-with-plaintext-private-key \
--signer-public-key "${{ vars.NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY }}" \
--signer-private-key "${{ secrets.NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY }}" \
send
working-directory: ./web4/treasury-factory
working-directory: ./treasury-factory
1 change: 1 addition & 0 deletions instances/treasury-factory.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"REPL_BASE_DEPLOYMENT_ACCOUNT": "treasury-factory.near",
"REPL_DEVDAO_ACCOUNT": "treasury-devdao.near",
"REPL_SPUTNIK_FACTORY_ACCOUNT": "sputnik-dao.near",
"REPL_FACTORY_REFERENCE_ACCOUNT": "treasury-testing.near",
"REPL_NEAR": "near",
"REPL_MOB": "mob.near",
"REPL_SOCIAL_CONTRACT": "social.near",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
const { alertMsg, setAlertMsg, onChange, defaultValue, postfix } = props;
const {
alertMsg,
setAlertMsg,
onChange,
defaultValue,
postfix,
placeholder,
skipValdation,
} = props;

const [value, setValue] = useState(defaultValue ?? "");

const checkAccountAvailable = async (accountId) => {
const checkAccountAvailability = async (accountId, postfix) => {
if (accountId.length === 0) return;

asyncFetch(`${REPL_RPC_URL}`, {
Expand Down Expand Up @@ -30,32 +38,48 @@ const checkAccountAvailable = async (accountId) => {
if (!err) errMsg = `Account ${accountId}${postfix} already been taken`;
else if (err.name !== "UNKNOWN_ACCOUNT") errMsg = err?.info?.error_message;

setAlertMsg(errMsg);
const newAlertMsg = alertMsg ?? {};
newAlertMsg[postfix] = errMsg;
setAlertMsg(newAlertMsg);
});
};

useEffect(() => {
if (!skipValdation) {
const handler = setTimeout(() => {
checkAccountAvailability(value, ".near");
checkAccountAvailability(value, ".sputnik-dao.near");
}, 500);

return () => {
clearTimeout(handler);
};
}
}, [value]);

return (
<div className="account-field position-relative d-flex align-items-center">
<input
type="text"
placeholder="app-account"
placeholder={placeholder}
value={value}
onChange={(e) => {
const v = e.target.value;
checkAccountAvailable(v);
setValue(v);
onChange(v);
}}
/>
<div
style={{
position: "absolute",
right: "0px",
borderLeft: "1px solid var(--bs-border-color)",
}}
className="py-2 px-3"
>
{postfix}
</div>
{postfix && (
<div
style={{
position: "absolute",
right: "0px",
borderLeft: "1px solid var(--bs-border-color)",
}}
className="py-2 px-3"
>
{postfix}
</div>
)}
</div>
);
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,24 @@ const ListItem = ({ member, key }) => (
</div>

<ActionButtons className="d-flex gap-3 align-items-center justify-content-end w-25">
{key > 0 && (
<>
<i
role="button"
className="bi bi-pencil"
onClick={() => {
setFields({
accountId: member.accountId,
permissions: member.permissions,
});
setShowAddMemberModal(true);
}}
/>
<i
role="button"
className="bi bi-trash text-danger"
onClick={() =>
setMembers(
members.filter((m) => m.accountId !== member.accountId)
)
}
/>
</>
)}
<i
role="button"
className="bi bi-pencil"
onClick={() => {
setFields({
accountId: member.accountId,
permissions: member.permissions,
});
setShowAddMemberModal(true);
}}
/>
<i
role="button"
className="bi bi-trash text-danger"
onClick={() =>
setMembers(members.filter((m) => m.accountId !== member.accountId))
}
/>
</ActionButtons>
</Item>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ const { getNearBalances } = VM.require(
);
if (!getNearBalances) return <></>;

const baseUrl = "https://api.pikespeak.ai";
const REQUIRED_BALANCE = 12;
const REQUIRED_BALANCE = 9;

let balance = getNearBalances(context.accountId);
balance = balance ? parseFloat(balance.availableParsed) : 0;
Expand Down Expand Up @@ -78,7 +77,7 @@ return (
/>
<SummaryListItem
title="Frontend BOS Widget Hosting"
value={6}
value={3}
info="Estimated one-time costs to store info in BOS"
/>
<b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ return (
alertMsg,
setAlertMsg,
defaultValue: formFields.accountName,
postfix: ".near",
onChange: (v) =>
setFormFields({
...formFields,
accountName: v,
}),
placeholder: "app-account",
}}
/>

{alertMsg && (
{(alertMsg[".near"] || alertMsg[".sputnik-dao.near"]) && (
<Widget
src={`${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/components.Info`}
props={{
type: "alert",
text: alertMsg,
text: alertMsg[".near"] || alertMsg[".sputnik-dao.near"],
}}
/>
)}
Expand All @@ -47,7 +47,10 @@ return (
</Link>
<Link
className={`btn btn-primary w-100 ${
!alertMsg && formFields.accountName ? "" : "disabled"
!(alertMsg[".near"] || alertMsg[".sputnik-dao.near"]) &&
formFields.accountName
? ""
: "disabled"
}`}
href={`/${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/app?page=create-treasury&step=2`}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ if (!formFields.sputnikAccountName)
return (
<>
<div>
<h3>Create Sputnik DAO Account</h3>
<h3>Add Sputnik DAO Display Name</h3>
<p>
Enter the name for your treasury's Sputnik DAO account. This is where
the funds for your treasury will be held.
Enter the display name for your treasury's Sputnik DAO account. The
funds for your treasury will be held in{" "}
<b>{formFields.accountName}.sputnik-dao.near</b>.
</p>
</div>

Expand All @@ -27,12 +28,13 @@ return (
alertMsg,
setAlertMsg,
defaultValue: formFields.sputnikAccountName,
postfix: ".sputnik-dao.near",
onChange: (v) =>
setFormFields({
...formFields,
sputnikAccountName: v,
}),
skipValdation: true,
placeholder: "Display name",
}}
/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { formFields } = props;

const REQUIRED_BALANCE = 12;
const REQUIRED_BALANCE = 9;

const [showCongratsModal, setShowCongratsModal] = useState(false);

Expand Down Expand Up @@ -156,18 +156,20 @@ function createDao() {
contractName: `${REPL_BASE_DEPLOYMENT_ACCOUNT}`,
methodName: "create_instance",
args: {
name: `${formFields.sputnikAccountName}`,
name: `${formFields.accountName}`,
sputnik_dao_factory_account_id: `${REPL_SPUTNIK_FACTORY_ACCOUNT}`,
social_db_account_id: `${REPL_SOCIAL_CONTRACT}`,
widget_reference_account_id: `${formFields.accountName}.${REPL_NEAR}`,
widget_reference_account_id: `${REPL_FACTORY_REFERENCE_ACCOUNT}`,
create_dao_args: btoa(JSON.stringify(createDaoConfig)),
},
gas: 300000000000000,
deposit: Big(REQUIRED_BALANCE).mul(Big(10).pow(24)).toFixed(),
},
]);

Storage.privateSet("accountName", formFields.accountName);
setTimeout(() => {
Storage.privateSet("accountName", formFields.accountName);
}, 1000);
}

const CongratsItem = ({ title, link }) => (
Expand Down Expand Up @@ -254,6 +256,7 @@ return (
: "-"}
</div>
</div>

<Link
href={`/${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/app?page=create-treasury&step=1`}
>
Expand All @@ -262,13 +265,26 @@ return (
</div>
</Section>

<Section>
<Section withBorder>
<div className="d-flex justify-content-between align-items-center">
<div>
<label>Sputnik Account Name</label>
<div>
{formFields.accountName
? `${formFields.accountName}.sputnik-dao.near`
: "-"}
</div>
</div>
</div>
</Section>

<Section>
<div className="d-flex justify-content-between align-items-center">
<div>
<label>Sputnik Account Display Name</label>
<div>
{formFields.sputnikAccountName
? `${formFields.sputnikAccountName}.sputnik-dao.near`
? `${formFields.sputnikAccountName}`
: "-"}
</div>
</div>
Expand Down Expand Up @@ -311,7 +327,7 @@ return (
/>
<SummaryListItem
title="Frontend BOS Widget Hosting"
value={6}
value={3}
info="Estimated one-time costs to store info in BOS"
/>
<b>
Expand Down
Loading

0 comments on commit 2c1320a

Please sign in to comment.