-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add metadata fetcher some hardcoded adventurers - process encrypted nft images and display - create a reveal system for the stats with some animations - add connect controller and delegation flow -- this currently has an issue with popping up braavos as well as controller for the tx
- Loading branch information
1 parent
4892130
commit d6a4538
Showing
32 changed files
with
1,044 additions
and
199 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,53 @@ | ||
import { Buffer } from "buffer"; | ||
|
||
export const fetchAdventurerMetadata = async ( | ||
gameAddress: string, | ||
tokenId: number, | ||
rpcUrl: string | ||
) => { | ||
const response = await fetch(rpcUrl, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
jsonrpc: "2.0", | ||
method: "starknet_call", | ||
params: [ | ||
{ | ||
contract_address: gameAddress, | ||
entry_point_selector: | ||
"0x0226ad7e84c1fe08eb4c525ed93cccadf9517670341304571e66f7c4f95cbe54", // token_uri | ||
calldata: [tokenId.toString(16), "0x0"], | ||
}, | ||
"pending", | ||
], | ||
id: 0, | ||
}), | ||
}); | ||
|
||
const data = await response.json(); | ||
|
||
if (response.ok) { | ||
console.log("Beast fetched successfully"); | ||
} else { | ||
console.error("Error in response:", data); | ||
} | ||
|
||
// Step 1: Convert hex strings to a single string | ||
const hexString = data.result.slice(1).join("").slice(2); // Remove '0x' prefix | ||
|
||
// Step 2: Convert hex to ASCII | ||
const fullString = hexString | ||
.match(/.{1,2}/g)! | ||
.map((hex: any) => String.fromCharCode(parseInt(hex, 16))) | ||
.join(""); | ||
|
||
const encodedString = fullString.split(",")[1]; | ||
|
||
const decodedString = Buffer.from(encodedString, "base64").toString("utf-8"); | ||
|
||
const jsonData = JSON.parse(decodedString); | ||
|
||
return jsonData; | ||
}; |
Oops, something went wrong.