Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
6bba49c
very hack proof-of-concept of a batch call
kasparkallas Sep 5, 2023
426ed67
add reference to SuperUpgrader and the permit token
kasparkallas Sep 5, 2023
04cbb36
update viem & wagmi
kasparkallas Sep 6, 2023
651534b
working with batch call and signature
kasparkallas Sep 6, 2023
d930617
working last contract solution
kasparkallas Sep 7, 2023
84d91f1
add goerli support
kasparkallas Sep 8, 2023
7b40528
make batch call payable
kasparkallas Sep 8, 2023
5cbb9bd
handle non-permit tokens
kasparkallas Sep 8, 2023
4142377
make it possible to unbatch
kasparkallas Sep 8, 2023
80969c2
add error logging
kasparkallas Sep 8, 2023
a124605
Revert "add error logging"
kasparkallas Sep 8, 2023
e5922d7
merge master
kasparkallas Sep 15, 2023
355bfa7
fix rendering issue
kasparkallas Sep 15, 2023
81017eb
improve transaction handling for robustness and fail-modes
kasparkallas Sep 15, 2023
9e8b9e3
merge transaction improvement branch
kasparkallas Sep 15, 2023
e5f558a
ui clean-up
kasparkallas Sep 15, 2023
e81876a
merge
kasparkallas Sep 15, 2023
435702e
generate for new contract
kasparkallas Sep 15, 2023
3056bcd
change function call
kasparkallas Sep 15, 2023
bde00ab
add force write btn
kasparkallas Sep 16, 2023
445cf65
improve TX handling
kasparkallas Sep 18, 2023
267bc3e
giMerge remote-tracking branch 'origin/master' into transaction-handl…
kasparkallas Sep 18, 2023
935841d
merge
kasparkallas Sep 18, 2023
623a851
add spacing and borders to list items
kasparkallas Sep 18, 2023
87e9c37
handle feedback
kasparkallas Sep 18, 2023
a461379
show skip button when TX fails
kasparkallas Sep 18, 2023
490712d
enlarge close button
kasparkallas Sep 18, 2023
a15ee91
flip the condition
kasparkallas Sep 18, 2023
2be5f6f
move transaction view title closer to the close icon
kasparkallas Sep 18, 2023
5daabd6
don't go out of bounds of the array
kasparkallas Sep 19, 2023
965dddc
add error boundary
kasparkallas Sep 19, 2023
355071f
be more forceful with the force transaction btn
kasparkallas Sep 19, 2023
14680f8
concat with errors abi to give viem/wagmi info for decoding
kasparkallas Sep 19, 2023
b3e4001
remove hover and add check when completed
kasparkallas Sep 19, 2023
3bf1bf2
merge
kasparkallas Sep 19, 2023
123492d
Fix create flow and modify flow cases
Sep 19, 2023
304a7a2
Merge branch 'master' into transaction-handling-improvements-for-gnos…
Sep 19, 2023
e71f968
Fix up approval test case
Sep 19, 2023
2193641
update contract address
kasparkallas Sep 19, 2023
7354d45
merge master
kasparkallas Sep 20, 2023
0bf351d
clean-up
kasparkallas Sep 20, 2023
2f3f085
fix status colors
kasparkallas Sep 20, 2023
0a81ad2
guarantee transactions are mapped before proceeding
kasparkallas Sep 20, 2023
928aa2b
Fix up test cases again
Sep 20, 2023
dba4a14
small clean-up
kasparkallas Sep 20, 2023
de24bbd
Merge branch 'transaction-handling-improvements-for-gnosis-safe' of h…
kasparkallas Sep 20, 2023
231df78
use cacheOnBlock when mapping commands
kasparkallas Sep 20, 2023
46a3778
merge
kasparkallas Sep 20, 2023
5d35a03
Adjust the icon colors
Sep 20, 2023
895ac7b
Merge branch 'transaction-handling-improvements-for-gnosis-safe' of h…
Sep 20, 2023
101225d
fix duplicate contract writes
kasparkallas Sep 20, 2023
63d71cf
re-render when fetch status changes
kasparkallas Sep 20, 2023
04b575b
merge
kasparkallas Sep 20, 2023
06eeba8
add cache key and stale time to tx preparation
kasparkallas Sep 21, 2023
58faa66
merge
kasparkallas Sep 21, 2023
0e89f30
move batch call switch
kasparkallas Sep 21, 2023
c3af8e7
fix batch call
kasparkallas Sep 21, 2023
ee1769f
the definite working solution for batch call
kasparkallas Sep 22, 2023
c0fd457
refactor for better readability
kasparkallas Sep 22, 2023
a3dbfae
add link to mint permit underlying token & use permit super token as …
kasparkallas Sep 22, 2023
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
5 changes: 0 additions & 5 deletions .changeset/nasty-insects-live.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/neat-impalas-sparkle.md

This file was deleted.

4 changes: 2 additions & 2 deletions apps/hosted-widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"react": "^18.2.0",
"react-blockies": "^1.4.1",
"react-dom": "^18.2.0",
"viem": "^1.11.0",
"wagmi": "^1.4.2",
"viem": "^1.10.9",
"wagmi": "^1.4.1",
"zod": "^3.21.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/hosted-widget/src/utils/deleteDemoFlow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cfAv1ForwarderABI } from "@superfluid-finance/widget";
import { getContract } from "viem";
import { polygonMumbai } from "wagmi/chains";
import { polygonMumbai } from "viem/chains";

import { wagmiConfigDemo } from "../DEMO-wagmi";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import {
FlowRate,
supportedNetworks,
} from "@superfluid-finance/widget";
import superTokenList from "@superfluid-finance/widget/tokenlist";
import Image from "next/image";
import { FC, ReactNode, useMemo } from "react";
import { getAddress } from "viem";

import NetworkAvatar from "../NetworkAvatar";
import { widgetTokenList } from "../widget-preview/WidgetPreview";

type PaymentOptionRowProps = {
label: string;
Expand Down Expand Up @@ -91,11 +91,11 @@ const PaymentOptionView: FC<PaymentOptionViewProps> = ({

const token = useMemo(
() =>
Object.values(superTokenList.tokens).find(
Object.values(widgetTokenList.tokens).find(
(token) =>
token.address.toLowerCase() === superToken.address.toLowerCase(),
),
[superTokenList, superToken.address],
[superToken.address],
);

const flowRateValue = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { ZodError } from "zod";

import InputWrapper, { InputInfo } from "../form/InputWrapper";
import NetworkAvatar from "../NetworkAvatar";
import { WidgetProps } from "../widget-preview/WidgetPreview";
import { WidgetProps, widgetTokenList } from "../widget-preview/WidgetPreview";

export type PaymentOptionWithSuperTokenAndNetwork = {
network: NetworkAssetInfo;
Expand Down Expand Up @@ -85,7 +85,7 @@ const SelectPaymentOption: FC<PaymentOptionSelectorProps> = ({

if (value.superToken) {
setSelectedToken(
tokenList.tokens.find(
widgetTokenList.tokens.find(
({ address }) =>
address.toLowerCase() === value.superToken.address.toLowerCase(),
) ?? null,
Expand Down Expand Up @@ -180,7 +180,7 @@ const SelectPaymentOption: FC<PaymentOptionSelectorProps> = ({
const network = supportedNetworks.find(
({ name }) => name === selectedNetwork?.name,
);
return tokenList.tokens.filter(
return widgetTokenList.tokens.filter(
(token) =>
token.chainId === network?.id && token.tags?.includes("supertoken"),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box } from "@mui/material";
import { FC } from "react";

import Link from "../../Link";
import { goerliPermitTokens } from "../widget-preview/WidgetPreview";

const TermsAndPrivacy: FC = () => (
<Box
Expand All @@ -12,6 +13,19 @@ const TermsAndPrivacy: FC = () => (
left: "540px",
}}
>
<Link
sx={{
fontWeight: 600,
}}
target="_blank"
href={`https://goerli.etherscan.io/token/${
goerliPermitTokens.find((x) => (x.tags ?? []).includes("underlying"))!
.address
}#writeContract#F4`}
>
{"Click here to mint Permit Super Token's underlying token on Goerli!"}
</Link>
<br />
<Link
data-testid="terms-link"
href="https://www.superfluid.finance/termsofuse/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import SuperfluidWidget, {
ProductDetails,
WalletManager,
} from "@superfluid-finance/widget";
import tokenList from "@superfluid-finance/widget/tokenlist";
import tokenList, {
SuperTokenList,
TokenInfo,
} from "@superfluid-finance/widget/tokenlist";
import { useWeb3Modal } from "@web3modal/react";
import {
createContext,
Expand All @@ -18,6 +21,70 @@ import {

import useFontLoader from "../../hooks/useFontLoader";

const mumbaiPermitTokens: TokenInfo[] = [
{
address: "0x50c988f2c2cce525cc2067c93b8c4a43ec62a166",
name: "PERMIT: Super fUSDC Fake Token",
symbol: "pfUSDCx",
decimals: 18,
chainId: 80001,
extensions: {
superTokenInfo: {
type: "Wrapper",
underlyingTokenAddress: "0x60974a03baaa984ea79f4590ac1e88aaae31158a",
},
},
logoURI:
"https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/usdc/icon.svg",
tags: ["supertoken", "testnet"],
},
{
address: "0x60974a03baaa984ea79f4590ac1e88aaae31158a",
name: "PERMIT: fUSDC Fake Token",
symbol: "pfUSDC",
decimals: 18,
chainId: 80001,
logoURI:
"https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/usdc/icon.svg",
tags: ["permit", "underlying", "testnet"],
},
];

export const goerliPermitTokens: TokenInfo[] = [
{
address: "0x19E6F96A887D0a27d60ef63942d7BF707fb1aD08",
name: "PERMIT: Super fUSDC Fake Token",
symbol: "pfUSDCx",
decimals: 18,
chainId: 5,
extensions: {
superTokenInfo: {
type: "Wrapper",
underlyingTokenAddress: "0xc3cA859682786B0f97Fa9c1239C249cbBb20cDaC",
},
},
logoURI:
"https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/usdc/icon.svg",
tags: ["supertoken", "testnet"],
},
{
address: "0xc3cA859682786B0f97Fa9c1239C249cbBb20cDaC",
name: "PERMIT: fUSDC Fake Token",
symbol: "pfUSDC",
decimals: 18,
chainId: 5,
logoURI:
"https://raw.githubusercontent.com/superfluid-finance/assets/master/public/tokens/usdc/icon.svg",
tags: ["permit", "underlying", "testnet"],
},
];

export const widgetTokenList = {
...tokenList,
tokens: [...goerliPermitTokens, ...tokenList.tokens],
// ...mumbaiPermitTokens,
} as SuperTokenList;

export interface FontSettings {
family: string;
category: string;
Expand Down Expand Up @@ -98,7 +165,7 @@ const switchLayout = (
<SuperfluidWidget
productDetails={productDetails}
paymentDetails={paymentDetails}
tokenList={tokenList}
tokenList={widgetTokenList}
type={layout}
theme={theme}
walletManager={walletManager}
Expand All @@ -111,7 +178,7 @@ const switchLayout = (
<SuperfluidWidget
productDetails={productDetails}
paymentDetails={paymentDetails}
tokenList={tokenList}
tokenList={widgetTokenList}
type={layout}
theme={theme}
walletManager={walletManager}
Expand Down
8 changes: 6 additions & 2 deletions apps/widget-builder/src/hooks/useDemoMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import {
} from "@superfluid-finance/widget";
import { useCallback } from "react";
import { useFormContext } from "react-hook-form";
import { Address } from "viem";

import {
DisplaySettings,
goerliPermitTokens,
Layout,
WidgetProps,
} from "../components/widget-preview/WidgetPreview";
Expand Down Expand Up @@ -111,10 +113,12 @@ const demoPaymentDetails: PaymentDetails = {
const defaultPaymentDetails: PaymentDetails = {
paymentOptions: [
{
receiverAddress: "0xf26ce9749f29e61c25d0333bce2301cb2dfd3a22", // rebounder
receiverAddress: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", // vitalik.eth
chainId: supportedNetwork.goerli.id,
superToken: {
address: "0x8ae68021f6170e5a766be613cea0d75236ecca9a", // fUSDCx
address: goerliPermitTokens.find((x) =>
(x.tags ?? []).includes("supertoken"),
)!.address as Address,
},
flowRate: {
amountEther: "1",
Expand Down
2 changes: 1 addition & 1 deletion examples/b2b-service-demo/src/utils/deleteDemoFlow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cfAv1ForwarderABI } from "@superfluid-finance/widget";
import { getContract } from "viem";
import { polygonMumbai } from "wagmi/chains";
import { polygonMumbai } from "viem/chains";

import configuration from "@/configuration";

Expand Down
2 changes: 1 addition & 1 deletion examples/donation-demo/src/utils/deleteDemoFlow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cfAv1ForwarderABI } from "@superfluid-finance/widget";
import { getContract } from "viem";
import { polygonMumbai } from "wagmi/chains";
import { polygonMumbai } from "viem/chains";

import configuration from "@/configuration";

Expand Down
2 changes: 1 addition & 1 deletion examples/gated-community-demo/src/utils/deleteDemoFlow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cfAv1ForwarderABI } from "@superfluid-finance/widget";
import { getContract } from "viem";
import { polygonMumbai } from "wagmi/chains";
import { polygonMumbai } from "viem/chains";

import configuration from "@/configuration";

Expand Down
4 changes: 2 additions & 2 deletions examples/widget-vite-react-rainbowkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"@superfluid-finance/widget": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"viem": "^1.11.0",
"wagmi": "^1.4.2",
"viem": "^1.8.1",
"wagmi": "^1.3.10",
"zod": "^3.22.2"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"packageManager": "pnpm@8.6.1",
"pnpm": {
"overrides": {
"eslint-plugin-react-hooks": "5.0.0-canary-41f0e9dae-20230907"
"react-hook-form": "~7.44.3",
"eslint-plugin-react-hooks": "5.0.0-canary-7118f5dd7-20230705"
}
}
}
5 changes: 3 additions & 2 deletions packages/widget/src/CommandHandlerContext.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { createContext, useContext } from "react";

import { CommandHandlingAggregate, State } from "./CommandHandlerState.js";
import { State } from "./CommandHandlerState.js";
import { Command } from "./commands.js";
import { ContractWrite } from "./ContractWrite.js";
import { ContractWriteResult } from "./ContractWriteManager.js";

// TODO(KK): nested structure
export type CommandHandlerContextValue = {
status: State["status"];
commands: ReadonlyArray<CommandHandlingAggregate>;
commands: ReadonlyArray<Command>;
contractWrites: ReadonlyArray<ContractWrite>;
contractWriteResults: ReadonlyArray<ContractWriteResult>;
sessionId: string | null;
submitCommands: (commands: ReadonlyArray<Command>) => void;
setContractWrites: (contractWrites: ReadonlyArray<ContractWrite>) => void;
writeIndex: number;
handleNextWrite: (currentWriteIndex: number) => void;
};
Expand Down
Loading