This repository was archived by the owner on Feb 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmp.js
More file actions
71 lines (58 loc) · 2.1 KB
/
tmp.js
File metadata and controls
71 lines (58 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// @ts-check
// @deno-types="https://esm.sh/v114/@superfluid-finance/sdk-core@0.6.3/dist/module/index.d.ts"
import { Framework } from "./build/superfluid.js";
import { ethers } from "https://esm.sh/ethers@5.6.5?target=es2020";
// import { ethers } from "https://esm.sh/hardhat@2.13.1?target=es2020";
/// <reference path="./global.d.ts" />
//where the Superfluid logic takes place
export async function updateFlowAsOperator(sender, recipient, flowRate) {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const chainId = await window.ethereum.request({ method: "eth_chainId" });
const sf = await Framework.create({
chainId: Number(chainId),
provider: provider,
});
// const daix = await sf.loadSuperToken("fDAIx");
const daix = await sf.loadSuperToken("ETHx");
console.log({ daix });
console.log("sender: ", sender);
console.log("receiver: ", recipient);
console.log("flow rate : ", flowRate);
console.log("signer: ", signer);
try {
// const updateFlowOperation = daix.updateFlowByOperator({
// sender: sender,
// receiver: recipient,
// flowRate: flowRate,
// // userData?: string
// });
//
const updateFlowOperation = daix.createFlowByOperator({
sender: sender,
receiver: recipient,
flowRate: flowRate,
// userData?: string
});
console.log(updateFlowOperation);
console.log("Updating your stream...");
const result = await updateFlowOperation.exec(signer);
console.log(result);
console.log(
`Congrats - you've just updated your money stream!
View Your Stream At: https://app.superfluid.finance/dashboard/${recipient}
Network: Goerli
Super Token: DAIx
Sender: 0xDCB45e4f6762C3D7C61a00e96Fb94ADb7Cf27721
Receiver: ${recipient},
FlowRate: ${flowRate}
`,
);
} catch (error) {
console.log(
"Hmmm, your transaction threw an error. Make sure that this stream exists, and that you've entered a valid Ethereum address!",
);
console.error(error);
}
}
Object.assign(globalThis, { updateFlowAsOperator });