-
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.
Merge pull request #22 from hollow-leaf/feat/frontend
feat: integration and UIUX improvement
- Loading branch information
Showing
32 changed files
with
487 additions
and
193 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"io/ioutil" | ||
"log" | ||
"net/http" | ||
"strconv" | ||
) | ||
|
||
type Metadata struct { | ||
Description string `json:"description"` | ||
External_url string `json:"external_url"` | ||
Image string `json:"image"` | ||
Name string `json:"name"` | ||
Attributes []Attribute `json:"attributes"` | ||
} | ||
|
||
type Attribute struct { | ||
Trait_type string `json:"trait_type"` | ||
Value string `json:"value"` | ||
} | ||
|
||
type Res struct { | ||
Id int `json:"id"` | ||
Res string `json:"res"` | ||
} | ||
|
||
const HOST = "https://psyduck-app.wayneies1206.workers.dev" | ||
|
||
func main() { | ||
const file_count = 540 | ||
for i := 0; i <= file_count; i++ { | ||
fmt.Println(i) | ||
content, err := ioutil.ReadFile(`/Users/zhengweilin/Downloads/outputsss/` + strconv.FormatUint(uint64(i), 10) + `.json`) | ||
if err != nil { | ||
log.Fatal("Error when opening file: ", err) | ||
} | ||
|
||
var payload Metadata | ||
err = json.Unmarshal(content, &payload) | ||
if err != nil { | ||
log.Fatal("Error during Unmarshal(): ", err) | ||
} | ||
|
||
if payload.Image != "" { | ||
fmt.Println("UPLOAD") | ||
uploadResult(i, payload.Image) | ||
} | ||
} | ||
} | ||
|
||
func uploadResult(id int, uri string) { | ||
jsonString := fmt.Sprintf("{\"URI\":\"%s\",\"id\":%d}", uri, id) | ||
_, err := http.Post(HOST+"/nftURIById", "application/json", bytes.NewReader([]byte(jsonString))) | ||
if err != nil { | ||
fmt.Println("Upload fail: %d", id) | ||
} | ||
} | ||
|
||
func getResult(id int) { | ||
jsonString := fmt.Sprintf("{\"id\":%d}", id) | ||
res, err := http.Post(HOST+"/getNftURIById", "application/json", bytes.NewReader([]byte(jsonString))) | ||
if err != nil { | ||
fmt.Println("Upload fail: %d", id) | ||
} else { | ||
fmt.Println(res.Body) | ||
|
||
} | ||
} |
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
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 was deleted.
Oops, something went wrong.
Binary file not shown.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
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,38 @@ | ||
import { blackstoneABI } from '@/contracts/blackstone' | ||
import { useAccount, useWriteContract } from 'wagmi' | ||
import { Message } from './message' | ||
|
||
export function MintNftButton(props: {price: number}) { | ||
const { address, isConnected, isDisconnected } = useAccount() | ||
|
||
const { writeContract, isError, isSuccess, error, isPending } = useWriteContract() | ||
|
||
async function mintHandler () { | ||
console.log(123) | ||
writeContract({ | ||
abi: blackstoneABI, | ||
address: '0x585a1DDaB9116F483d367bCa6eb64797252051c8', | ||
functionName: 'publicSaleMint', | ||
args: [ | ||
1 | ||
], | ||
value: BigInt(1000000000000) | ||
}) | ||
} | ||
|
||
return ( | ||
<div> | ||
<div className="flex flex-col justify-center items-center"> | ||
{isConnected? | ||
<button onClick={mintHandler} type="button" className="text-white bg-gradient-to-r from-purple-500 to-pink-500 hover:bg-gradient-to-l focus:ring-4 focus:outline-none focus:ring-purple-200 dark:focus:ring-purple-800 font-medium rounded-full text-xl px-10 py-6 text-center me-2 mb-2">Mint Now!</button> | ||
: | ||
<button type="button" className="text-white bg-gray-200 hover:bg-gradient-to-l focus:ring-4 focus:outline-none focus:ring-purple-200 dark:focus:ring-purple-800 font-medium rounded-full text-xl px-10 py-6 text-center me-2 mb-2" disabled>Mint Now!</button> | ||
} | ||
{isConnected?<></> | ||
: | ||
<p className='text-gray-400'>Connect wallet and mint!</p> | ||
} | ||
</div> | ||
</div> | ||
) | ||
} |
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
Oops, something went wrong.