- Head over to your Gnosis Safe, where you should find the transaction
- request within the WalletConnect Safe App. After signing the transaction,
- it will be proposed to your safe.
-
-
- Once quorum has been reached and the transaction is executed, the
- Workstreams UI will update accordingly.
-
-
-
-
-
-
-
-
diff --git a/src/lib/components/BalanceButton.svelte b/src/lib/components/BalanceButton.svelte
index 3e1a5d11..fa3db7a7 100644
--- a/src/lib/components/BalanceButton.svelte
+++ b/src/lib/components/BalanceButton.svelte
@@ -7,19 +7,15 @@
import * as modal from '$lib/utils/modal';
import drips from '$lib/stores/drips';
import { currencyFormat, padFloatString } from '$lib/utils/format';
- import { workstreamsStore } from '$lib/stores/workstreams';
+ import workstreamsStore from '$lib/stores/workstreams';
import LoadingDots from './LoadingDots.svelte';
import { goto } from '$app/navigation';
import StepperModal from '$lib/components/StepperModal/index.svelte';
import Intro from '$lib/components/WithdrawSteps/Intro.svelte';
- import { walletStore } from '$lib/stores/wallet/wallet';
- import AwaitingSafeTransactionStep from './AwaitingSafeTransactionStep.svelte';
-
- const estimates = workstreamsStore.estimates;
$: currentCycleBalanceEstimate =
- $estimates.earnedInCurrentCycle !== undefined &&
- currencyFormat($estimates.earnedInCurrentCycle);
+ $workstreamsStore.earnedInCurrentCycle !== undefined &&
+ currencyFormat($workstreamsStore.earnedInCurrentCycle);
$: withdrawable =
$drips.collectable && currencyFormat($drips.collectable.wei);
@@ -30,7 +26,7 @@
currentCycleBalanceEstimate &&
currencyFormat(
($drips.collectable?.wei ?? BigInt(0)) +
- ($estimates.earnedInCurrentCycle?.wei ?? BigInt(0))
+ ($workstreamsStore.earnedInCurrentCycle?.wei ?? BigInt(0))
);
$: formattedCycleEnd = $drips.cycle && {
@@ -48,7 +44,7 @@
async function collect() {
modal.show(StepperModal, undefined, {
- steps: [Intro, $walletStore.safe?.ready && AwaitingSafeTransactionStep]
+ steps: [Intro]
});
}
diff --git a/src/lib/components/Connect/Button.svelte b/src/lib/components/Connect/Button.svelte
index 57633a91..20fd95eb 100644
--- a/src/lib/components/Connect/Button.svelte
+++ b/src/lib/components/Connect/Button.svelte
@@ -9,7 +9,6 @@
import LoadingDots from '../LoadingDots.svelte';
import StepperModal from '../StepperModal/index.svelte';
import ChooseWallet from './steps/ChooseWallet.svelte';
- import LinkSafe from './steps/LinkSafe.svelte';
import clearStores from '$lib/stores/utils/clearStores';
import connectStores from '$lib/stores/utils/connectStores';
import isMobile from '$lib/stores/isMobile';
@@ -29,7 +28,7 @@
hover = false;
},
{
- steps: [ChooseWallet, LinkSafe]
+ steps: [ChooseWallet]
}
);
}
@@ -38,8 +37,7 @@
await tick();
if ($walletStore.ready) {
- const { provider: localProvider, safe } = $walletStore;
- const provider = safe?.provider ?? localProvider;
+ const { provider } = $walletStore;
if (!provider) throw new Error('Unable to get provider');
diff --git a/src/lib/components/Connect/steps/LinkSafe.svelte b/src/lib/components/Connect/steps/LinkSafe.svelte
deleted file mode 100644
index eb5a1028..00000000
--- a/src/lib/components/Connect/steps/LinkSafe.svelte
+++ /dev/null
@@ -1,128 +0,0 @@
-
-
-{#if safeAddresses}
-
- Link your Gnosis Safe
-
- We detected a Gnosis Safe associated with your account. If you link it,
- you'll be interacting with Workstreams on behalf of your safe, and all
- transactions will require a quorum.
-
-
- To connect, open the WalletConnect Safe App
- within your Gnosis Safe by navigating to
- Apps
- →
- WalletConnect. Then, press
- Connect safe
- below, copy the connection URL to your clipboard, and paste it into the connection
- link field in the WalletConnect Safe App.
-
-
- If you skip this, you'll be using Workstreams with your
- previously-connected wallet.
-
-
-
-
-
-
-
-{:else}
-
-{/if}
-
-
diff --git a/src/lib/components/CreateModal.svelte b/src/lib/components/CreateModal.svelte
index f8736693..a8c44d64 100644
--- a/src/lib/components/CreateModal.svelte
+++ b/src/lib/components/CreateModal.svelte
@@ -9,17 +9,13 @@
import * as modal from '$lib/utils/modal';
import Modal from '$components/Modal.svelte';
- import { getConfig } from '$lib/config';
- import {
- Currency,
- WorkstreamState,
- type Workstream,
- type WorkstreamInput
- } from '$lib/stores/workstreams/types';
import { utils } from 'ethers';
- import { workstreamsStore } from '$lib/stores/workstreams';
+ import workstreamsStore from '$lib/stores/workstreams';
import ensNames from '$lib/stores/ensNames';
import { walletStore } from '$lib/stores/wallet/wallet';
+ import drips from '$lib/stores/drips';
+ import { cidToBase10 } from '$lib/utils/cid';
+ import { toWei } from 'drips-sdk';
const durationOptions = [
{ value: '1', title: 'Days' },
@@ -106,6 +102,9 @@
async function createWorkstream() {
creatingWorkstream = true;
+ const { address } = $walletStore;
+ if (!address) throw new Error('Connect wallet first');
+
const daiPerDay =
parseInt(total) / (parseInt(duration) * parseInt(durationUnit));
const weiPerDay = utils.parseUnits(daiPerDay.toString());
@@ -114,31 +113,39 @@
const chainId = $walletStore.network?.chainId;
if (!chainId) throw new Error('Unable to determine chain ID');
-
- let input: WorkstreamInput = {
- ratePerSecond: {
- currency: Currency.DAI,
- wei: weiPerSecond.toString()
- },
- title,
- desc: description,
- chainId,
- durationDays: parseInt(duration) * parseInt(durationUnit),
- assignTo: assigneeAddress,
- state: WorkstreamState.ACTIVE
- };
+ if (!assigneeAddress) throw new Error('Assignee address is missing');
try {
- const res = await fetch(`${getConfig().API_URL_BASE}/workstreams`, {
- method: 'POST',
- credentials: 'include',
- body: JSON.stringify(input)
+ const cid = await workstreamsStore.createWorkstream({
+ creator: address,
+ amountPerSecond: {
+ currency: 'dai',
+ wei: weiPerSecond.toBigInt()
+ },
+ streamTarget: {
+ currency: 'dai',
+ wei: weiPerDay.toBigInt() * BigInt(parseInt(duration))
+ },
+ title,
+ description,
+ createdAt: new Date(),
+ receiver: assigneeAddress
});
- const workstream: Workstream = await res.json();
+ const call = await drips.createDrip(
+ assigneeAddress,
+ {
+ currency: 'dai',
+ wei: weiPerSecond.toBigInt()
+ },
+ BigInt(cidToBase10(cid)),
+ toWei('10').toBigInt()
+ );
+
+ await call.tx.wait(1);
// Push the new workstream into the state so it shows up on the dashboard.
- await workstreamsStore.getWorkstream(workstream.id);
+ await workstreamsStore.fetchWorkstream(cid.toString());
} catch (e) {
return;
}
diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte
index 1a577404..09cac914 100644
--- a/src/lib/components/Header.svelte
+++ b/src/lib/components/Header.svelte
@@ -62,7 +62,7 @@
>
- Customize your stream below. When you confirm, the Workstream will be
- activated, but it will only start streaming funds once the setup transaction
- has been executed by your connected Gnosis Safe.
-
- You need to allow the Radicle Drips contract to access the DAI in your
- Gnosis Safe before creating a stream. After clicking Allow drips contract
- below, you'll find a transaction prompt within the Gnosis Safe app. After you
- sign the transaction and it reaches quorum and is executed by your safe, re-trigger
- the payment setup flow and you'll be able to proceed.
-
-
-
diff --git a/src/lib/components/SetUpPaymentSteps/steps/gnosis-safe/WaitingForConfirmation.svelte b/src/lib/components/SetUpPaymentSteps/steps/gnosis-safe/WaitingForConfirmation.svelte
deleted file mode 100644
index 8d0f980a..00000000
--- a/src/lib/components/SetUpPaymentSteps/steps/gnosis-safe/WaitingForConfirmation.svelte
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- Continue in your Gnosis Safe
-
-
- Your workstream won't start streaming funds until the proposed transaction
- reaches quorum and is executed by your Gnosis Safe. Head over to your safe
- now, sign the transaction, and execute it after it's reached quorum. You can re-propose the transaction anytime by clicking on "Set up stream"
- again.
-