Skip to content

Commit 425dc10

Browse files
authored
examples/fungible/web-frontend: remove hardcoded account types (#3770)
## Motivation The Web frontend for `fungible` is broken due to recent changes in our ownership structures. ## Proposal Remove the `User:` or `Application:` prefix that previously indicated the account type, as this is now encoded into the `AccountOwner`. ## Test Plan Performed a mutation in the frontend and got a hash back. ## Release Plan - These changes should be backported to the latest `testnet` branch, then - be released in a new SDK
1 parent 955249c commit 425dc10

File tree

2 files changed

+14
-66
lines changed

2 files changed

+14
-66
lines changed

examples/fungible/web-frontend/src/App.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
import Header from "./components/Header";
1414
import ErrorMessage from "./components/ErrorMessage";
1515
import DialogSuccess from "./components/DialogSuccess";
16-
import Radio from './components/Radio';
1716
import { IconLoader } from "./assets/icons/Loader";
1817

1918
const GET_BALANCE = gql`
@@ -43,7 +42,7 @@ const MAKE_PAYMENT = gql`
4342
`;
4443

4544
const NOTIFICATION_SUBSCRIPTION = gql`
46-
subscription Notifications($chainId: ID!) {
45+
subscription Notifications($chainId: ChainId!) {
4746
notifications(chainId: $chainId)
4847
}
4948
`;
@@ -57,21 +56,29 @@ function App({ chainId, owner }: AppProps) {
5756
const [recipient, setRecipient] = useState("");
5857
const [targetChain, setTargetChain] = useState("");
5958
const [amount, setAmount] = useState("");
60-
const [typeAccount, setTypeAccount] = useState("User");
6159
const [error, setError] = useState("");
6260
const [openDialog, setOpenDialog] = useState(false);
6361

6462
let [
6563
balanceQuery,
6664
{ data: balanceData, called: balanceCalled, error: balanceError },
6765
] = useLazyQuery<AccountsQuery>(GET_BALANCE, {
66+
onError: (error) => {
67+
console.error('failed to query balance', error);
68+
},
6869
fetchPolicy: "network-only",
69-
variables: { owner: `${owner}` },
70+
variables: { owner },
7071
});
7172

7273
useSubscription(NOTIFICATION_SUBSCRIPTION, {
7374
variables: { chainId: chainId },
74-
onData: () => balanceQuery(),
75+
onError: () => {
76+
console.log('failed to subscribe to notifications');
77+
},
78+
onData: () => {
79+
console.log('querying balance');
80+
balanceQuery();
81+
},
7582
});
7683

7784
if (!balanceCalled) {
@@ -101,7 +108,6 @@ function App({ chainId, owner }: AppProps) {
101108
setRecipient("");
102109
setAmount("");
103110
setError("");
104-
setTypeAccount("User")
105111
setOpenDialog(true);
106112
},
107113
});
@@ -132,10 +138,10 @@ function App({ chainId, owner }: AppProps) {
132138
amount,
133139
targetAccount: {
134140
chainId: targetChain,
135-
owner: `${typeAccount}:${recipient}`,
141+
owner: `${recipient}`,
136142
},
137143
},
138-
}).then((r) => console.log("payment made: " + r));
144+
}).then((r) => console.log("payment made", r));
139145
};
140146

141147
const isMaxBalance = useMemo(() => {
@@ -211,12 +217,6 @@ function App({ chainId, owner }: AppProps) {
211217
required
212218
/>
213219
</div>
214-
<div className="flex w-full flex-col gap-y-4">
215-
<label className="font-bold" htmlFor="typeAccount">
216-
Type Account:
217-
</label>
218-
<Radio checked={typeAccount} setChecked={setTypeAccount}/>
219-
</div>
220220
<div className="flex w-full flex-col gap-y-4">
221221
<label className="font-bold" htmlFor="recipient">
222222
Recipient Account:

examples/fungible/web-frontend/src/components/Radio.tsx

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)