Skip to content

Commit

Permalink
improve junk annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
hmisty committed Jan 8, 2024
1 parent 8c9a81c commit 6d2433b
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 10 deletions.
47 changes: 44 additions & 3 deletions scripts/controllers/addressInfoController.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,20 @@ angular.module('ethExplorer')

if (shouldGetAddressNS) getAddressNS();

getAllCryptoJunks();
// dynamically load reference for tagging gold inscriptions
// only works while all 10000 junks are inscribed and set in stone (no change anymore)
$.get('scripts/misc/punks/golden_idx.json')
.success((data) => {
console.log(data);
getAllCryptoJunks(data);
})
.fail((xhr, status, err) => {
console.log(xhr, status, err);
getAllCryptoJunks(undefined);
})
.always(() => {
console.log('loading golden_idx.json ...');
});

getJNSDAOV();
getAllJNS();
Expand Down Expand Up @@ -379,7 +392,7 @@ angular.module('ethExplorer')
});
}

function getAllCryptoJunks() {
function getAllCryptoJunks(golden_idx) {
$scope.allCryptoJunks = [];
var addr = $scope.addressId;
var contract = new web3.eth.Contract(cryptojunks_ABI, cryptojunks_contract_address);
Expand All @@ -399,10 +412,38 @@ angular.module('ethExplorer')
//var tag = token_name + ' #' + token_id;
contract.methods.tokenURI(token_id).call(function (err3, result3) {
if (err3) {
console.log(err3);
console.log(err3, token_id, result3);
} else {
var tokenURI = result3;
var tokenInfo = parseTokenURI(tokenURI);

// if we have reference data
if (golden_idx != undefined) {

const is_golden = golden_idx['golden'];
const legend_idx = golden_idx['alien'];
const rare_idx = golden_idx['ape'];
const precious_idx = golden_idx['zombie'];

if (is_golden[token_id] == '1')
tokenInfo.golden = true;
else
tokenInfo.golden = false;

id = parseInt(token_id);
if (legend_idx.indexOf(id) > -1)
tokenInfo.rarity = 'legend';
else if (rare_idx.indexOf(id) > -1)
tokenInfo.rarity = 'rare';
else if (precious_idx.indexOf(id) > -1)
tokenInfo.rarity = 'precious';
else
tokenInfo.rarity = 'normal';

console.log(token_id, tokenInfo.rarity);

}

$scope.allCryptoJunks.push({'id': token_id, 'pageId': Math.floor(token_id/100), 'tokenInfo': tokenInfo});
$scope.$apply(); // inform the data updates !
}
Expand Down
48 changes: 45 additions & 3 deletions scripts/controllers/junksInfoController.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ angular.module('ethExplorer')
// get total supply & rendering
getCryptoJunksSupply();

// DONOT DELETE. THIS WAS USED FOR INCOMPLETE INSCRIBING GOLDEN RECOGONITION.
// dynamically load reference for tagging the golden inscriptions
$.get('scripts/misc/punks/' + $scope.pageId + '.json')
/*$.get('scripts/misc/punks/' + $scope.pageId + '.json')
.success((data) => { //won't execute if json format error!
console.log(data);
getAllCryptoJunksByPage($scope.pageId, $scope.junkId, data);
Expand All @@ -55,7 +56,21 @@ angular.module('ethExplorer')
})
.always(() => {
console.log('loading ', $scope.pageId + '.json ...');
});
});*/
// dynamically load reference for tagging gold inscriptions
// only works while all 10000 junks are inscribed and set in stone (no change anymore)
$.get('scripts/misc/punks/golden_idx.json')
.success((data) => {
console.log(data);
getAllCryptoJunksByPage($scope.pageId, $scope.junkId, data);
})
.fail((xhr, status, err) => {
console.log(xhr, status, err);
getAllCryptoJunksByPage($scope.pageId);
})
.always(() => {
console.log('loading golden_idx.json ...');
});

function getCryptoJunksSupply() {
const contract = new web3.eth.Contract(cryptojunks_ABI, cryptojunks_contract_address);
Expand Down Expand Up @@ -88,13 +103,40 @@ angular.module('ethExplorer')
} else {
var tokenInfo = parseTokenURI(tokenURI);

if (references == undefined) {
// DONOT DELETE. OLD references: punk img base64. must do str comparison for user may burn and re-mint.
/*if (references == undefined) {
tokenInfo.golden = undefined;
} else {
if (tokenInfo.image.slice(22) == references[tokenId]) //is punk! set it golden
tokenInfo.golden = true;
else
tokenInfo.golden = false;
}*/
// new reference data after set in stone is golden_idx
const token_id = tokenId;
const golden_idx = references;
if (golden_idx != undefined) {
const is_golden = golden_idx['golden'];
const legend_idx = golden_idx['alien'];
const rare_idx = golden_idx['ape'];
const precious_idx = golden_idx['zombie'];

if (is_golden[token_id] == '1')
tokenInfo.golden = true;
else
tokenInfo.golden = false;

id = parseInt(token_id);
if (legend_idx.indexOf(id) > -1)
tokenInfo.rarity = 'legend';
else if (rare_idx.indexOf(id) > -1)
tokenInfo.rarity = 'rare';
else if (precious_idx.indexOf(id) > -1)
tokenInfo.rarity = 'precious';
else
tokenInfo.rarity = 'normal';

//console.log(token_id, tokenInfo.golden, tokenInfo.rarity);
}

if (tokenInfo.image == 'data:image/png;base64,')
Expand Down
Loading

0 comments on commit 6d2433b

Please sign in to comment.