Skip to content

Commit

Permalink
base
Browse files Browse the repository at this point in the history
  • Loading branch information
Miandic committed Jan 5, 2023
1 parent 2c02e6a commit c766ec1
Show file tree
Hide file tree
Showing 18 changed files with 350 additions and 0 deletions.
1 change: 1 addition & 0 deletions contract/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pk
Empty file added contract/build/.gitkeep
Empty file.
Empty file added contract/build/boc/.gitkeep
Empty file.
Empty file added contract/fift/.gitkeep
Empty file.
12 changes: 12 additions & 0 deletions contract/fift/data.fif
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"TonUtil.fif" include
"Asm.fif" include

"build/contract.pk" load-generate-keypair // generate key pair
constant private_key // save private to constant
constant public_key // save public to constant

<b
0 32 u, // seqno
0 32 u, // subwallet-id
public_key B, // add bin public key to cell
b>
21 changes: 21 additions & 0 deletions contract/fift/examples/parse_get_cell.fif
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"Color.fif" include
.s // prints stack

// you will see that integer and cell slice are in stack

// print seqno (it is just int in stack)
."🤗 Seqno as int from " ^green ."GET" ^reset ." method is: "

swap // get seqno as int on top of stack
(dump) // dump to string
type // print it to output
cr // print endline

<s dup 32 u@ // get seqno from cell
swap ref@ // get ref on first cell
<s 64 u@ // get message from second cell
swap // get seqno from cell to top

."🤗 Seqno as int from cell from " ^green ."GET" ^reset ." method is: " (dump) type cr

."🥳 Message from ref cell: " (dump) type cr
79 changes: 79 additions & 0 deletions contract/fift/usage.fif
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/fift -s
"TonUtil.fif" include
"GetOpt.fif" include

{ show-options-help 1 halt } : usage

"" =: comment // comment for simple transfers
true =: allow-bounce
false =: force-bounce
3 =: send-mode // mode for SENDRAWMSG: +1 - sender pays fees, +2 - ignore errors
60 =: timeout // external message expires in 60 seconds
variable extra-currencies
{ extra-currencies @ cc+ extra-currencies ! } : extra-cc+!

begin-options
" <filename-base> <dest-addr> <subwallet-id> <seqno> <amount> [-x <extra-amount>*<extra-currency-id>] [-n|-b] [-t<timeout>] [-B <body-boc>] [-C <comment>] [<savefile>]" +cr +tab
+"Creates a request to advanced wallet created by new-wallet-v3.fif, with private key loaded from file <filename-base>.pk "
+"and address from <filename-base>.addr, and saves it into <savefile>.boc ('wallet-query.boc' by default)"
disable-digit-options generic-help-setopt
"n" "--no-bounce" { false =: allow-bounce } short-long-option
"Clears bounce flag" option-help
"b" "--force-bounce" { true =: force-bounce } short-long-option
"Forces bounce flag" option-help
"x" "--extra" { $>xcc extra-cc+! } short-long-option-arg
"Indicates the amount of extra currencies to be transfered" option-help
"t" "--timeout" { parse-int =: timeout } short-long-option-arg
"Sets expiration timeout in seconds (" timeout (.) $+ +" by default)" option-help
"B" "--body" { =: body-fift-file } short-long-option-arg
"Sets the payload of the transfer message" option-help
"C" "--comment" { =: comment } short-long-option-arg
"Sets the comment to be sent in the transfer message" option-help
"m" "--mode" { parse-int =: send-mode } short-long-option-arg
"Sets transfer mode (0..255) for SENDRAWMSG (" send-mode (.) $+ +" by default)"
option-help
"h" "--help" { usage } short-long-option
"Shows a help message" option-help
parse-options

$# dup 5 < swap 6 > or ' usage if
6 :$1..n

true constant bounce
$1 =: file-base
$2 bounce parse-load-address force-bounce or allow-bounce and =: bounce 2=: dest_addr
$3 parse-int =: subwallet_id
$4 parse-int =: seqno
$5 $>cc extra-cc+! extra-currencies @ 2=: amount
$6 "wallet-query" replace-if-null =: savefile
subwallet_id (.) 1 ' $+ does : +subwallet

file-base +subwallet +".addr" dup file-exists? { drop file-base +".addr" } ifnot
load-address
2dup 2constant wallet_addr
."INFO: 👀 Source wallet address = " 2dup 6 .Addr cr
file-base +".pk" load-keypair nip constant wallet_pk

def? body-fift-file { @' body-fift-file include } { comment simple-transfer-body } cond
constant body-cell

."INFO: 👋 Send " dest_addr 2dup bounce 7 + .Addr ." = "
."subwallet_id=0x" subwallet_id x.
."seqno=0x" seqno x. ."bounce=" bounce . cr
."INFO: 🧟 Body of transfer message is " body-cell <s csr.

// create a message
<b b{01} s, bounce 1 i, b{000} s, dest_addr Addr, amount Gram+cc, 0 9 64 32 + + u,
body-cell <s 2dup 1 s-fits-with? not rot over 1 i, -rot { drop body-cell ref, } { s, } cond
b>

<b subwallet_id 32 u, now timeout + 32 u, seqno 32 u, send-mode 8 u, swap ref, b>

dup hashu wallet_pk ed25519_sign_uint
<b b{1000100} s, wallet_addr addr, 0 Gram, b{00} s,
swap B, swap <s s, b>

2 boc+>B

saveboc // it is defined in build/cli.fif (or /tmp if in script mode)
// it is project-specific lib from tlcli thats specify needed locations
Empty file added contract/func/code.func
Empty file.
4 changes: 4 additions & 0 deletions contract/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
contract:
data: fift/data.fif
func:
- func/code.func
Empty file added contract/tests/.gitkeep
Empty file.
Binary file added generated/merge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added generated/merge_bp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added generated/random.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added generated/random_bp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import cv2
import numpy as np

def create_blank(width, height, rgb_color=(0, 0, 0)):
# Create black blank image
image = np.zeros((height, width, 3), np.uint8)

# Since OpenCV uses BGR, convert the color first
color = tuple(reversed(rgb_color))
# Fill image with color
image[:] = color

return image

# Create new blank 300x300 red image

def randomize():
width, height = 1024, 1024
image = create_blank(width, height, rgb_color=(0, 0, 0))
for i in range(0, width):
for j in range(0, height):
b = np.random.randint(-10, 10)
g = np.random.randint(-10, 10)
r = np.random.randint(-10, 10)
image[i, j] = image[i-1, j-1] + [b, g, r]
return image

def generate_content(frame, type):
if type == 'random':
for i in range(384, 640):
for j in range(384, 640):
b = np.random.randint(0, 255)
g = np.random.randint(0, 255)
r = np.random.randint(0, 255)
frame[i, j] = [b, g, r]
return frame
elif type == 'merge':
for i in range(384, 640):
for j in range(384, 640):
frame[i, j] = (frame[i-1, j] + frame[i, j-1]) / 2
return frame
elif type == 'random_bp':
for i in range(384, 640, 8):
for j in range(384, 640, 8):
b = np.random.randint(0, 255)
g = np.random.randint(0, 255)
r = np.random.randint(0, 255)
for k in range(i, i+8):
for l in range(j, j+8):
frame[k, l] = [b, g, r]
return frame
elif type == 'merge_bp':
for i in range(384, 640, 8):
for j in range(384, 640, 8):
for k in range(i, i+8):
for l in range(j, j+8):
frame[k, l] = (frame[i-1, j] + frame[i, j-1]) / 2
return frame


'''
out = cv2.VideoWriter('output.avi', cv2.VideoWriter_fourcc(*'XVID'), 20.0, (640,480))
for i in range(0, 100):
frame = randomize()
frame = generate_content(frame)
out.write(frame)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
out.release()
'''

frame = randomize()
frame = generate_content(frame, 'random')
cv2.imwrite('generated/random.png', frame)

frame = randomize()
frame = generate_content(frame, 'merge')
cv2.imwrite('generated/merge.png', frame)

frame = randomize()
frame = generate_content(frame, 'random_bp')
cv2.imwrite('generated/random_bp.png', frame)

frame = randomize()
frame = generate_content(frame, 'merge_bp')
cv2.imwrite('generated/merge_bp.png', frame)
31 changes: 31 additions & 0 deletions web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<title>AR-NFT</title>
<script src="main.js" charset="utf-8"></script>
<link rel="stylesheet" href="style.css">

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Andada+Pro&family=Anton&family=Archivo&family=BioRhyme&family=Cormorant&family=Encode+Sans&family=Epilogue&family=Hahmlet&family=Inter&family=JetBrains+Mono&family=Lato&family=Lora&family=Manrope&family=Montserrat&family=Nunito&family=Old+Standard+TT&family=Open+Sans&family=Oswald&family=Oxygen&family=Playfair+Display&family=Poppins&family=Raleway&family=Roboto&family=Sora&family=Source+Sans+Pro&family=Spectral&family=Work+Sans&display=swap" rel="stylesheet">



<script>
$(window).on('load', () => {
main_load()
})
</script>
</head>
<body>
<header>
<div class="logo"></div>
<div class="title">absolutely random NFT generator</div>
<div class="about">about</div>
</header>
</body>
</html>
87 changes: 87 additions & 0 deletions web/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
var deviceWidth = window.screen.width;

fonts = ["'Andada Pro', serif", "'Anton', sans-serif", "'Archivo', sans-serif", "'BioRhyme', serif", "'Cormorant', serif", "'Encode Sans', sans-serif", "'Epilogue', sans-serif", "'Hahmlet', serif", "'Inter', sans-serif", "'JetBrains Mono', monospace", "'Lato', sans-serif", "'Lora', serif", "'Manrope', sans-serif", "'Montserrat', sans-serif", "'Nunito', sans-serif", "'Old Standard TT', serif", "'Open Sans', sans-serif", "'Oswald', sans-serif", "'Oxygen', sans-serif", "'Playfair Display', serif", "'Poppins', sans-serif", "'Raleway', sans-serif", "'Roboto', sans-serif", "'Sora', sans-serif", "'Source Sans Pro', sans-serif", "'Spectral', serif", "'Work Sans', sans-serif"]

const generate_header = () => {
var img = Array(deviceWidth)
var tmp = Array(100)
for (var i = 0; i < deviceWidth; i++) {
img[i] = tmp
for (var j = 0; j < 100; j++) {
b = Math.floor(Math.random() * 256);
g = Math.floor(Math.random() * 256);
r = Math.floor(Math.random() * 256);
img[i][j] = [b, g, r]
}
}
cv.imwrite("header.png", img);
console.log("header.png generated");
}

const shuffle = (array) => {
let i = array.length
let j;

while (i != 0) {
j = Math.floor(Math.random() * i);
i--;
[array[i], array[j]] = [array[j], array[i]];
}

return array;
}

const main_load = async () => {

// change title coloure
document.getElementsByClassName("title")[0].style.color = "rgb(255, 255, 255)";
// change title font
document.getElementsByClassName("title")[0].style.fontFamily = "Comic Sans MS";
// generate array of 20 random colours (colour is an array of 3 numbers)
var colours = Array(27)
for (var i = 0; i < 27; i++) {
colours[i] = Array(3)
for (var j = 0; j < 3; j++) {
colours[i][j] = Math.floor(Math.random() * 256);
}
}
shuffle(fonts)
for (var i = 0; i < 26; i++) {
document.getElementsByClassName("title")[0].style.color = "rgb(" + colours[i][0] + ", " + colours[i][1] + ", " + colours[i][2] + ")";
document.getElementsByClassName("title")[0].style.fontFamily = fonts[i];
await new Promise(r => setTimeout(r, 100));
console.log("font: " + fonts[i]);
}

}


/*
font-family: 'Andada Pro', serif;
font-family: 'Anton', sans-serif;
font-family: 'Archivo', sans-serif;
font-family: 'BioRhyme', serif;
font-family: 'Cormorant', serif;
font-family: 'Encode Sans', sans-serif;
font-family: 'Epilogue', sans-serif;
font-family: 'Hahmlet', serif;
font-family: 'Inter', sans-serif;
font-family: 'JetBrains Mono', monospace;
font-family: 'Lato', sans-serif;
font-family: 'Lora', serif;
font-family: 'Manrope', sans-serif;
font-family: 'Montserrat', sans-serif;
font-family: 'Nunito', sans-serif;
font-family: 'Old Standard TT', serif;
font-family: 'Open Sans', sans-serif;
font-family: 'Oswald', sans-serif;
font-family: 'Oxygen', sans-serif;
font-family: 'Playfair Display', serif;
font-family: 'Poppins', sans-serif;
font-family: 'Raleway', sans-serif;
font-family: 'Roboto', sans-serif;
font-family: 'Sora', sans-serif;
font-family: 'Source Sans Pro', sans-serif;
font-family: 'Spectral', serif;
font-family: 'Work Sans', sans-serif;
*/
27 changes: 27 additions & 0 deletions web/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@import url('https://fonts.googleapis.com/css2?family=Andada+Pro&family=Anton&family=Archivo&family=BioRhyme&family=Cormorant&family=Encode+Sans&family=Epilogue&family=Hahmlet&family=Inter&family=JetBrains+Mono&family=Lato&family=Lora&family=Manrope&family=Montserrat&family=Nunito&family=Old+Standard+TT&family=Open+Sans&family=Oswald&family=Oxygen&family=Playfair+Display&family=Poppins&family=Raleway&family=Roboto&family=Sora&family=Source+Sans+Pro&family=Spectral&family=Work+Sans&display=swap');




header {
height: 35px;
display: flex;
justify-content: space-around;
align-items: center;
}

.logo {
width: 200px;
align-items: center;
}

.title {
width: 500px;
text-align: center;
font-size: 20px;
}

.about {
width: 200px;
text-align: center;
}

0 comments on commit c766ec1

Please sign in to comment.