Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "template-front-end0",
"name": "Algo-hack",
"homepage": "https://JoE11-y.github.io/Algo-hack",
"version": "0.1.0",
"private": true,
Expand Down
41 changes: 14 additions & 27 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ const App = () => {
if (!connector) {
console.log("No connection");
return;
} else {
console.log("We have connection", connector);
}

const { accounts } = connector;

if (accounts.length !== 0) {
const account = accounts[0];
console.log("Found an authorized account:", account);
setCurrentAccount(account);
} else {
setCurrentAccount(null);
console.log("No authorized account found");
}
return
}

setCurrentAccount(null);

} catch (error) {
console.log(error);
}
Expand All @@ -45,7 +44,6 @@ const App = () => {

if (!connector.connected) {
await connector.createSession();
console.log("Creating new connector session");
}

if (connector.connected) {
Expand All @@ -60,10 +58,7 @@ const App = () => {
}
// Get provided accounts
const { accounts } = payload.params[0];
console.log(
"connector.on connect: Connected an account with address:",
accounts[0]
);

setConnector(connector);
setCurrentAccount(accounts[0]);
});
Expand Down Expand Up @@ -91,7 +86,7 @@ const App = () => {

const closeConnection = async () => {
connector.killSession();
console.log("Killing session for wallet with address: ", currentAccount);

setConnector(null);
};

Expand Down Expand Up @@ -160,20 +155,15 @@ const App = () => {
} else {
// Sign & submit the transaction with algoconnect wallet
let signedTxn = await myAlgoConnect.signTransaction(txn.toByte());
console.log("Signed transaction with txID: %s", txId);
await algodClient.sendRawTransaction(signedTxn.blob).do();
}

await algosdk.waitForConfirmation(algodClient, txId, 2);
let transactionResponse = await algodClient
.pendingTransactionInformation(txId)
.do();
console.log("Called app-id:", transactionResponse["txn"]["txn"]["apid"]);
if (transactionResponse["global-state-delta"] !== undefined) {
console.log(
"Global State updated:",
transactionResponse["global-state-delta"]
);

await getCount();
}

Expand Down Expand Up @@ -225,20 +215,17 @@ const App = () => {
} else {
// Sign & submit the transaction with algoconnect wallet
let signedTxn = await myAlgoConnect.signTransaction(txn.toByte());
console.log("Signed transaction with txID: %s", txId);

await algodClient.sendRawTransaction(signedTxn.blob).do();
}

await algosdk.waitForConfirmation(algodClient, txId, 2);
let transactionResponse = await algodClient
.pendingTransactionInformation(txId)
.do();
console.log("Called app-id:", transactionResponse["txn"]["txn"]["apid"]);

if (transactionResponse["global-state-delta"] !== undefined) {
console.log(
"Global State updated:",
transactionResponse["global-state-delta"]
);

await getCount();
}
setLoading1(false);
Expand All @@ -254,15 +241,15 @@ const App = () => {
.do();
let globalState = [];
globalState = applicationInfoResponse["params"]["global-state"];
console.log("count is: ", globalState[0]["value"]["uint"]);

setGlobalCount(globalState[0]["value"]["uint"]);
};

useEffect(() => {
checkIfWalletIsConnected();

getCount();
console.log("currentAccount:", currentAccount);

}, [currentAccount, connector, checkIfWalletIsConnected]);

return (
Expand Down