diff --git a/app/src/App.svelte b/app/src/App.svelte
index 3e58ee8..11d8b52 100644
--- a/app/src/App.svelte
+++ b/app/src/App.svelte
@@ -9,9 +9,17 @@
import Home from "./lib/Home.svelte";
import { writable } from "svelte/store";
import Create from "./lib/Create.svelte";
+ import { Web3 } from "web3";
+ import ABI from "./assets/ABI.json";
const activeAcc = writable("");
+ const web3 = new Web3(window.ethereum);
+ const contract = new web3.eth.Contract(
+ ABI,
+ "0xa2C4C4b2d39C93E443885a4e1a818FFFbbDB5Ef5",
+ );
+
async function connect() {
if (!window.ethereum) {
alert("Please install MetaMask!");
@@ -82,13 +90,13 @@
-
+
-
+
-
+
diff --git a/app/src/assets/ABI.json b/app/src/assets/ABI.json
index a18c9b8..907e92d 100644
--- a/app/src/assets/ABI.json
+++ b/app/src/assets/ABI.json
@@ -334,6 +334,30 @@
"stateMutability": "nonpayable",
"type": "function"
},
+ {
+ "inputs": [
+ {
+ "internalType": "address",
+ "name": "",
+ "type": "address"
+ },
+ {
+ "internalType": "uint256",
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "name": "createdItems",
+ "outputs": [
+ {
+ "internalType": "uint256",
+ "name": "",
+ "type": "uint256"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
{
"inputs": [
{
@@ -353,6 +377,25 @@
"stateMutability": "view",
"type": "function"
},
+ {
+ "inputs": [
+ {
+ "internalType": "address",
+ "name": "userAddress",
+ "type": "address"
+ }
+ ],
+ "name": "getCreatedItemTokens",
+ "outputs": [
+ {
+ "internalType": "uint256[]",
+ "name": "",
+ "type": "uint256[]"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
{
"inputs": [
{
@@ -399,6 +442,25 @@
"stateMutability": "view",
"type": "function"
},
+ {
+ "inputs": [
+ {
+ "internalType": "uint256",
+ "name": "tokenId",
+ "type": "uint256"
+ }
+ ],
+ "name": "getUserHistory",
+ "outputs": [
+ {
+ "internalType": "address[]",
+ "name": "",
+ "type": "address[]"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
{
"inputs": [
{
diff --git a/app/src/lib/Create.svelte b/app/src/lib/Create.svelte
index 9f4d7cd..6a733b5 100644
--- a/app/src/lib/Create.svelte
+++ b/app/src/lib/Create.svelte
@@ -1,10 +1,9 @@
-
Your digital passport for your physical items
-
-
-
-
Create a new Item Passport now!
+
Your digital passport for your physical items
+
+
+
+
Create a new Item Passport now!
-
-
-
+
+{#if activeAcc}
+ You created these items:
+ {#await contract.methods.getCreatedItemTokens(activeAcc).call() then tokenList}
+ {#each tokenList as tokenId}
+
+
+
+
+
+ {/each}
+ {/await}
+{/if}
\ No newline at end of file
+ }
+ .notlink {
+ color: whitesmoke;
+ }
+
diff --git a/app/src/lib/Passport.svelte b/app/src/lib/Passport.svelte
index c4d0696..36b4dcc 100644
--- a/app/src/lib/Passport.svelte
+++ b/app/src/lib/Passport.svelte
@@ -1,30 +1,20 @@
-{#await contract.methods.getPassport(tokenId).call()}
- loading nft data
-{:then data}
+
{#if edit}
@@ -56,8 +44,11 @@
+
+
{/if}
-{/await}
+
+
\ No newline at end of file
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/lib/PassportCard.svelte b/app/src/lib/PassportCard.svelte
index f23430e..0975f2c 100644
--- a/app/src/lib/PassportCard.svelte
+++ b/app/src/lib/PassportCard.svelte
@@ -14,7 +14,9 @@
{/if}
{desc}
- Item Website
+ {#if url}
+ Item Website
+ {/if}
diff --git a/app/src/lib/PassportList.svelte b/app/src/lib/PassportList.svelte
new file mode 100644
index 0000000..e69de29
diff --git a/app/src/lib/PassportLoader.svelte b/app/src/lib/PassportLoader.svelte
new file mode 100644
index 0000000..11c4ea7
--- /dev/null
+++ b/app/src/lib/PassportLoader.svelte
@@ -0,0 +1,10 @@
+
+
+{#await contract.methods.getPassport(tokenId).call()}
+ loading nft data
+{:then data}
+
+{/await}
\ No newline at end of file
diff --git a/app/src/lib/TransferOwner.svelte b/app/src/lib/TransferOwner.svelte
new file mode 100644
index 0000000..0dda461
--- /dev/null
+++ b/app/src/lib/TransferOwner.svelte
@@ -0,0 +1,52 @@
+
+
+
+
+
diff --git a/contract/src/ItemBlocks.sol b/contract/src/ItemBlocks.sol
index 0c9fa37..94da082 100644
--- a/contract/src/ItemBlocks.sol
+++ b/contract/src/ItemBlocks.sol
@@ -15,10 +15,10 @@ contract ItemBlocks is ERC721, Ownable {
mapping (uint256 => Passport) public itemPassports;
mapping (uint256 => address[]) public allItemOwners;
- mapping (address => uint256[]) public userItems;
+ mapping (address => uint256[]) public createdItems;
constructor(address initialOwner)
- ERC721("ItemBlocksTest6", "IB6")
+ ERC721("ItemBlocksTest8", "IB8")
Ownable(initialOwner)
{}
@@ -69,6 +69,8 @@ contract ItemBlocks is ERC721, Ownable {
function updateOwnership(address currentOwnerAddress, address nextOwnerAddress, uint256 tokenId) public{
if (allItemOwners[tokenId].length == 0){
allItemOwners[tokenId].push(nextOwnerAddress);
+ createdItems[nextOwnerAddress].push(tokenId);
+
}else{
safeTransferFrom(currentOwnerAddress, nextOwnerAddress, tokenId);
allItemOwners[tokenId].push(nextOwnerAddress);
@@ -81,8 +83,7 @@ contract ItemBlocks is ERC721, Ownable {
return allItemOwners[tokenId];
}
- function getUserItemTokens(address userAddress) public view returns(uint256[] memory) {
-
- return userItems[userAddress];
+ function getCreatedItemTokens(address userAddress) public view returns(uint256[] memory) {
+ return createdItems[userAddress];
}
-}
\ No newline at end of file
+}