Skip to content

Commit

Permalink
update to use new JSON API
Browse files Browse the repository at this point in the history
  • Loading branch information
fulldecent committed Sep 12, 2024
1 parent 0b5c6ee commit c13582a
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 366 deletions.
17 changes: 4 additions & 13 deletions _layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="{{ site.url | escape }}{{ page.permalink | escape }}" />

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.6.0/font/bootstrap-icons.css" integrity="sha256-xI9svxPNgINGMuNc6T4pgY5QN385llAJtoyzuf3rcbI=" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" integrity="sha256-9kPW/n5nn53j4WMRYAxe9c1rCY96Oogo/MKSVdKzPmI=" crossorigin="anonymous">

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ethers.umd.min.js" integrity="sha256-hhyZwmdi3z8gOlk+hH86uTyHPFbQQ4j9JGWW/pE+kks=" crossorigin="anonymous"></script>
<!--<link rel="stylesheet" href="https://tenthousandsu.com/assets/main.css">-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/anchor.min.js" integrity="sha256-0WMZ9PF4b2hTF66Eglv/9H5Vwk6lnOG4AbmCJxo96WQ=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ethers.umd.min.js" integrity="sha256-dOAMPiqczTEubVFU+cywkR0bNMtJvIIgJEopKgp3PCE=" crossorigin="anonymous"></script>
</head>
<body class="bg-light">
<nav class="navbar" style="background-color: #ffd700">
<div class="container-fluid">
<a class="navbar-brand text-dark" href="/">Su Squares&trade; <i class="bi bi-wrench"></i> Tools &amp; Tricks</a>
<a class="navbar-brand text-dark" href="/">Su Squares&trade; <i class="bi bi-wrench"></i> tools &amp; tricks</a>
</div>
</nav>

<main class="container-fluid container-xl py-5">
{{ content }}
</main>
<script>
// Add anchors on DOMContentLoaded
document.addEventListener('DOMContentLoaded', function(event) {
anchors.add();
});
</script>
</body>
</html>
46 changes: 0 additions & 46 deletions all-available.html

This file was deleted.

66 changes: 0 additions & 66 deletions all-minted.html

This file was deleted.

70 changes: 0 additions & 70 deletions all-personalized-on-main-contract.html

This file was deleted.

70 changes: 0 additions & 70 deletions all-personalized.html

This file was deleted.

15 changes: 7 additions & 8 deletions grant.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Grant Squares
title: Grant squares
layout: page
---
<h1>Grant tokens</h1>
Expand Down Expand Up @@ -38,20 +38,19 @@ <h2>Log</h2>

document.getElementById("grant").addEventListener("click", async function() {
await ethereum.request({ method: "eth_requestAccounts" });
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const suSquaresContract = new ethers.Contract(suSquaresAddress, suSquaresABI, provider);
const suSquaresContractWithSigner = suSquaresContract.connect(signer);
const provider = new ethers.BrowserProvider(window.ethereum); // Updated for Ethers v6
const signer = await provider.getSigner(); // 'getSigner' now returns a Promise in Ethers v6
const suSquaresContract = new ethers.Contract(suSquaresAddress, suSquaresABI, signer); // No need for 'connect' method in Ethers v6

const address = document.getElementById("address").value;
const tokenId = parseInt(document.getElementById("tokenId").value);
const tx = await suSquaresContractWithSigner.grantToken(tokenId, address, { gasLimit: 200000 });
const tx = await suSquaresContract.grantToken(tokenId, address, { gasLimit: 200000 });

// You must log it
// Log the transaction
document.getElementById("log").innerText += tokenId + " https://etherscan.io/tx/" + tx.hash + "\n";
});

document.getElementById("clear").addEventListener("click", async function() {
document.getElementById("clear").addEventListener("click", function() {
document.getElementById("log").innerText = "";
});

Expand Down
41 changes: 41 additions & 0 deletions list-available.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: Every available Square
layout: page
---
<h1>{{ page.title }}</h1>
<table class="table" id="results">
<tr><th>Square</th></tr>
</table>

<script>
const attributesPromise = fetch("/assets/attributes.json").then(response => response.json());
const squaresPromise = fetch("https://tenthousandsu.com/build/squarePersonalizations.json").then(response => response.json());

Promise.all([attributesPromise, squaresPromise]).then(([attributesData, allData]) => {
const columns = Object.keys(attributesData[Object.keys(attributesData)[0]]);
let availableSquareNumbers = [];

for (let squareNumber = 1; squareNumber <= 10000; squareNumber++) {
if (allData[squareNumber - 1] === null) {
availableSquareNumbers.push(squareNumber);
}
}

const table = document.getElementById("results");
for (let i = 0; i < columns.length; i++) {
const header = document.createElement('th');
header.innerText = columns[i];
table.rows[0].appendChild(header);
}

availableSquareNumbers.forEach(squareNumber => {
const row = table.insertRow(-1);
const cell = row.insertCell(0);
cell.innerText = squareNumber;
for (let i = 0; i < columns.length; i++) {
const dataCell = row.insertCell(i + 1);
dataCell.innerHTML = attributesData[squareNumber - 1][columns[i]];
}
});
});
</script>
Loading

0 comments on commit c13582a

Please sign in to comment.