Skip to content

Commit

Permalink
update for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
enemycnt committed Jan 16, 2023
1 parent 1aa966c commit 5b6521e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 237 deletions.
13 changes: 7 additions & 6 deletions examples/erc20-react-example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,15 @@ function App(): JSX.Element {
if (
metaIsConnected &&
sygmaInstance !== undefined &&
sygmaInstance.bridgeSetup
sygmaInstance.bridgeSetup &&
isReady
) {
void handleConnect();
void getAccountData(sygmaInstance);
setValue("from", sygmaInstance.bridgeSetup?.chain1.domainId);
setValue("to", sygmaInstance.bridgeSetup?.chain2.domainId);
}
}, [metaIsConnected]);
}, [metaIsConnected, sygmaInstance, isReady]);

const submit = async (values: {
amount: string;
Expand Down Expand Up @@ -265,10 +266,10 @@ function App(): JSX.Element {
if (!metaIsConnected) {
return window.ethereum
.request({ method: "eth_requestAccounts" })
.then((r) => {
console.log("request to unlock metamask", r);
.then((result) => {
console.log("request to unlock metamask", result);

const [addr] = r as string[];
const [addr] = result as string[];
setMetaIsConnected(true);
if (accountData) {
accountData.address = addr;
Expand Down Expand Up @@ -363,7 +364,7 @@ function App(): JSX.Element {
<>
<form
action=""
onSubmit={void handleSubmit(submit)}
onSubmit={(...args) => void handleSubmit(submit)(...args)}
style={{
display: "flex",
flexDirection: "column",
Expand Down
13 changes: 7 additions & 6 deletions examples/erc721-react-example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,15 @@ function App(): JSX.Element {
if (
metaIsConnected &&
sygmaInstance !== undefined &&
sygmaInstance.bridgeSetup
sygmaInstance.bridgeSetup &&
isReady
) {
void handleConnect();
void getAccountData(sygmaInstance);
setValue("from", sygmaInstance.bridgeSetup?.chain1.domainId);
setValue("to", sygmaInstance.bridgeSetup?.chain2.domainId);
}
}, [metaIsConnected]);
}, [metaIsConnected, sygmaInstance, isReady]);

const submit = async (values: {
amount: string;
Expand Down Expand Up @@ -268,9 +269,9 @@ function App(): JSX.Element {
if (!metaIsConnected) {
return window.ethereum
.request({ method: "eth_requestAccounts" })
.then((r) => {
console.log("request to unlock metamask", r);
const [addr] = r as string[];
.then((result) => {
console.log("request to unlock metamask", result);
const [addr] = result as string[];
setMetaIsConnected(true);
if (accountData) {
accountData.address = addr;
Expand Down Expand Up @@ -365,7 +366,7 @@ function App(): JSX.Element {
<>
<form
action=""
onSubmit={void handleSubmit(submit)}
onSubmit={(...args) => void handleSubmit(submit)(...args)}
style={{
display: "flex",
flexDirection: "column",
Expand Down
Loading

0 comments on commit 5b6521e

Please sign in to comment.