diff --git a/src/components/Footer/Footer.svelte b/src/components/Footer/Footer.svelte index 8526af4..9655339 100644 --- a/src/components/Footer/Footer.svelte +++ b/src/components/Footer/Footer.svelte @@ -35,7 +35,7 @@ {isOnImprintPage ? 'Back' : 'Imprint and Terms & Conditions'} diff --git a/src/components/curator-actions/CuratorActions.svelte b/src/components/curator-actions/CuratorActions.svelte index a92b07a..e42ed6c 100644 --- a/src/components/curator-actions/CuratorActions.svelte +++ b/src/components/curator-actions/CuratorActions.svelte @@ -1,8 +1,6 @@
#{bounty.id} {bounty.description ?? ''}
-

- Please use a descriptive title and add info about the task and beneficiary in the description. -

+

Please use a descriptive title.

@@ -103,13 +101,24 @@

- +

+ + Add several in one transaction + + +

diff --git a/src/components/curator-actions/child-bounties/operations/BatchAllChildBountyCalls.svelte b/src/components/curator-actions/child-bounties/operations/BatchAllChildBountyCalls.svelte index 3ce4556..8af4b76 100644 --- a/src/components/curator-actions/child-bounties/operations/BatchAllChildBountyCalls.svelte +++ b/src/components/curator-actions/child-bounties/operations/BatchAllChildBountyCalls.svelte @@ -1,11 +1,11 @@ + + diff --git a/src/routes/curator-actions/batch/create/+page.svelte b/src/routes/curator-actions/batch/create/+page.svelte new file mode 100644 index 0000000..4b48d55 --- /dev/null +++ b/src/routes/curator-actions/batch/create/+page.svelte @@ -0,0 +1,189 @@ + + +
+

ADD MULTIPLE NEW CHILD BOUNTIES

+ + {#if error} +

+ {error} +

+ {/if} + + {#if bounty && !error} +

+ #{bounty.id} + {bounty.description ?? ''} +

+ +
+
+ {#each childBounties as child, index} +
+ Child bounty #{index + 1} + +
+ + + + +

+ +

+
+
+ {/each} + + {#if childBounties.length < 10} +

+ +

+ {/if} +
+ +

+ +

+ +
+

Estimated basic fee:

+

+
+ +

+ +

+
+ {/if} +
+ + diff --git a/src/routes/curator-actions/batch/everything/+page.svelte b/src/routes/curator-actions/batch/everything/+page.svelte new file mode 100644 index 0000000..31c8793 --- /dev/null +++ b/src/routes/curator-actions/batch/everything/+page.svelte @@ -0,0 +1,286 @@ + + +
+

BATCH ALL CALLS FOR MULTIPLE CHILD BOUNTIES

+ + {#if error} +

+ {error} +

+ {/if} + + {#if bounty && !error} +

+ #{bounty.id} + {bounty.description ?? ''} +

+ +
+
+

Executed actions:

+ +
    +
  1. Create a new child bounty.
  2. +
  3. Assign the connected account as sub-curator.
  4. +
  5. Accept the sub-curator role.
  6. +
  7. Award the child bounty to the provided beneficiary.
  8. +
  9. Claim the child bounty.
  10. +
+
+ +

+ Currently, the child bounty’s index is estimated by incrementing the highest available on + the blockchain. To create multiple bounties in one batch transaction, Bounty Manager + increments this index by 1 for each additional bounty.
Please note: if multiple child + bounties are assigned the same index, or if another bounty creates a child between this transaction’s + creation and confirmation, this transaction will fail. +

+ + + +
+ {#each childBounties as child, index} +
+ Child bounty #{index + 1} + +
+ + + + + + + + +

+ +

+
+
+ {/each} + + {#if childBounties.length < 10} +

+ +

+ {/if} +
+ +

+ +

+ +
+

Estimated basic fee:

+

+
+ +

+ For the highest likelihood of success, ensure that the signatories confirm the transaction + as soon as possible +

+ +

+ +

+
+ {/if} +
+ + diff --git a/src/routes/curator-actions/batch/getBountyCuratorError.ts b/src/routes/curator-actions/batch/getBountyCuratorError.ts new file mode 100644 index 0000000..7e8c962 --- /dev/null +++ b/src/routes/curator-actions/batch/getBountyCuratorError.ts @@ -0,0 +1,23 @@ +import type { Bounty } from '../../../types/bounty'; + +export function getBountyCuratorError( + bountyId: number, + bounties: Bounty[], + bounty?: Bounty, + curator?: string +) { + if (bounties.length === 0) return; + + if (Number.isNaN(bountyId)) { + return 'Bounty ID not provided'; + } + if (!bounty) { + return `Cannot find active bounty #${bountyId}`; + } + if (!bounty.curator) { + return `The bounty "#${bounty.id} ${bounty.description ?? ''}" doesn’t have a curator yet`; + } + if (bounty.curator !== curator) { + return `Connect with account ${bounty.curator} to manage the bounty "#${bounty.id} ${bounty.description ?? ''}"`; + } +} diff --git a/src/utils/getAllChildBountyCalls.ts b/src/utils/getAllChildBountyCalls.ts new file mode 100644 index 0000000..78e2da9 --- /dev/null +++ b/src/utils/getAllChildBountyCalls.ts @@ -0,0 +1,56 @@ +import { get } from 'svelte/store'; +import { Binary } from 'polkadot-api'; +import { MultiAddress } from '@polkadot-api/descriptors'; +import { dotApi } from '../stores'; +import { convertFormattedDotToPlanck } from './polkadot'; + +export function getAllChildBountyCalls({ + parent_bounty_id, + child_bounty_id, + title, + value, + curator, + beneficiary, + fee +}: { + parent_bounty_id: number; + child_bounty_id: number; + title: string; + value: string; + curator: string; + beneficiary: string; + fee: string; +}) { + const $dotApi = get(dotApi); + + const add = $dotApi.tx.ChildBounties.add_child_bounty({ + parent_bounty_id, + value: convertFormattedDotToPlanck(value), + description: Binary.fromText(title) + }); + + const propose = $dotApi.tx.ChildBounties.propose_curator({ + parent_bounty_id, + child_bounty_id, + curator: MultiAddress.Id(curator), + fee: convertFormattedDotToPlanck(fee) + }); + + const accept = $dotApi.tx.ChildBounties.accept_curator({ + parent_bounty_id, + child_bounty_id + }); + + const award = $dotApi.tx.ChildBounties.award_child_bounty({ + parent_bounty_id, + child_bounty_id, + beneficiary: MultiAddress.Id(beneficiary) + }); + + const claim = $dotApi.tx.ChildBounties.claim_child_bounty({ + parent_bounty_id, + child_bounty_id + }); + + return [add, propose, accept, award, claim].map(({ decodedCall }) => decodedCall); +}