-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
343a0e0
commit 6843b19
Showing
7 changed files
with
106 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
export const arcadianHeadImages = []; | ||
|
||
export async function queryArcadian(id) { | ||
const partsUrl = | ||
'https://nftstorage.link/ipfs/bafybeib2ir3zpgd3cmizcv7shekjeftcwq7apjib6i5gz2sjc4vajwtgiy'; | ||
|
||
// this is the same url that you get from querying token uri from the contract | ||
const url = 'https://api.arcadians.io/' + id; | ||
|
||
return new Promise((resolve, reject) => { | ||
// create a GET request | ||
var xhr = new XMLHttpRequest(); | ||
xhr.onload = () => { | ||
if (xhr.readyState === xhr.DONE) { | ||
if (xhr.status !== 200) reject(null); | ||
let gender = 'female'; | ||
var data = JSON.parse(xhr.response); | ||
console.log('data', data); | ||
|
||
const headPart = data.attributes.find( | ||
(trait) => trait.trait_type === 'Head' | ||
); | ||
const genderPart = data.attributes.find( | ||
(trait) => trait.trait_type === 'Class' | ||
); | ||
if (genderPart.value.match('Male')) gender = 'male'; | ||
const headUrl = headPart.value.toLowerCase().replaceAll(' ', '-'); | ||
var img = new Image(); | ||
img.src = `${partsUrl}/${gender}/head/${headUrl}.png`; | ||
img.addEventListener( | ||
'load', | ||
() => { | ||
localStorage.setItem('Arcadian #' + id, xhr.response); | ||
arcadianHeadImages.push(img); | ||
resolve(img); | ||
}, | ||
false | ||
); | ||
} | ||
}; | ||
xhr.open('GET', url); | ||
xhr.send(); | ||
}); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export const GOAL_COLLISION = 'gc'; | ||
export const ARCADIAN_ADDED = 'aa'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|