Skip to content

Commit

Permalink
✨ Refacto 2020
Browse files Browse the repository at this point in the history
  • Loading branch information
Errorname committed Nov 5, 2020
1 parent dabf8d7 commit 14617ea
Show file tree
Hide file tree
Showing 16 changed files with 21,549 additions and 16,357 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "get-crypto-lucky"
}
}
21 changes: 21 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
'on':
push:
branches:
- master
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GET_CRYPTO_LUCKY }}'
channelId: live
projectId: get-crypto-lucky
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
17 changes: 17 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on PR
'on': pull_request
jobs:
build_and_preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GET_CRYPTO_LUCKY }}'
projectId: get-crypto-lucky
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
66 changes: 66 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*
firebase-debug.*.log*

# Firebase cache
.firebase/

# Firebase config

# Uncomment this if you'd like others to create their own Firebase project.
# For a team working on the same Firebase project(s), it is recommended to leave
# it commented so all members can deploy to the same project(s) in .firebaserc.
# .firebaserc

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Thibaud Courtoison
Copyright (c) 2020 Thibaud Courtoison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# GetCryptoLucky
Random cryptocoins address pair key generator checking for lucky balance
# 🍀 GetCryptoLucky 🤞

Generate random cryptocurrency wallets and check for lucky balance

Hosted on Firebase

## Dependencies

- [jQuery 3.2.1](https://jquery.com)
- [Vue 2.5.1](https://vuejs.org)
- [CoinKey 2.0.0](https://github.com/cryptocoinjs/coinkey)
- [CoinInfo 2.0.0](https://github.com/cryptocoinjs/coininfo)
- [CoinKey 3.0.0](https://github.com/cryptocoinjs/coinkey)
- [CoinInfo 3.0.0](https://github.com/cryptocoinjs/coininfo)
- [Spectre 0.4.7](https://github.com/picturepan2/spectre)
232 changes: 112 additions & 120 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,129 +1,121 @@
var app = new Vue({
el: '#app',
data: {
machine: null,
spinning: false,
addresses: [],
address: null,
found_address: null,
coins: window.coins,
faq: window.faq
},
mounted: function() {
this.initMachine();
for (var code in this.coins) {
this.initCoin(this.coins[code]);
}
},
methods: {
initMachine: function() {
this.machine = new CryptoSlots({
elem: '.machine',
before_spin: function() {
app.spinning = true;
},
after_spin: function() {
app.spinning = false;
app.address = app.found_address;
app.addresses.unshift(app.address);
}
});
},
initCoin: function(coin) {
$.ajax('https://api.cryptonator.com/api/ticker/'+coin.code+'-usd',{
success: function(data) {
coin.price = parseFloat(data.ticker.price);
}
});
},
pickRandomCoin: function() {
var keys = Object.keys(this.coins);
return this.coins[keys[Math.floor(keys.length * Math.random())]];
},
createPair: function(coin) {
return coinkey.createRandom(coininfo(coin.code));
},
checkBalance: function(coin, address, callback) {
//callback(0);
var url = coin.api.url.replace('{address}',address);
var success = function(data) {
callback(coin.api.callback(data));
}
if (coin.api.proxy) {
$.ajax('proxy.php',{
data: {
csurl: url
},
success: (data) => {return success(JSON.parse(data))},
error: this.getLucky
});
} else {
$.ajax(url,{
success: success,
error: this.getLucky
});
}
},
generateDraw: function(address) {
var coin = address.coin.name.toLowerCase();
if (address.amount > 0) {
// If there is an amount => Jackpot 5 same coin
return [coin,coin,coin,coin,coin];
}
// First col is the address's coin
var draw = [coin];
var good = 1;
// 2nd, 3rd and 4th are random with a 1/3 probability for the same as 1st
// The 5th also as a 1/3 probability if there isn't already 4 good coins
// Otherwise, the 5th will never be the same coin
for (var i = 0; i < 4; i++) {
if (good < 4 && Math.floor(Math.random()*3) == 0) {
draw.push(coin);
good++;
} else {
var randomCoin;
do {
randomCoin = this.pickRandomCoin().name.toLowerCase();
} while (randomCoin == coin);
draw.push(randomCoin);
}
}
el: '#app',
data: {
machine: null,
spinning: false,
addresses: [],
address: null,
found_address: null,
coins: window.coins,
faq: window.faq,
},
mounted: function () {
this.initMachine()
for (var code in this.coins) {
this.initCoin(this.coins[code])
}
},
methods: {
initMachine: function () {
this.machine = new CryptoSlots({
elem: '.machine',
before_spin: function () {
app.spinning = true
},
after_spin: function () {
app.spinning = false
app.address = app.found_address
app.addresses.unshift(app.address)
},
})
},
initCoin: function (coin) {
$.ajax('https://api.cryptonator.com/api/ticker/' + coin.code + '-usd', {
success: function (data) {
coin.price = parseFloat(data.ticker.price)
},
})
},
pickRandomCoin: function () {
var keys = Object.keys(this.coins)
return this.coins[keys[Math.floor(keys.length * Math.random())]]
},
createPair: function (coin) {
return coinkey.createRandom(coininfo(coin.code))
},
checkBalance: function (coin, address, callback) {
var url = coin.api.url.replace('{address}', address)

return draw;
},
getLucky: function() {
fetch(url)
.then((r) => r.json())
.then(coin.api.getUnits)
.then(callback)
.catch(console.log)
},
generateDraw: function (address) {
var coin = address.coin.name.toLowerCase().replace(' ', '-')
if (address.amount > 0) {
// If there is an amount => Jackpot 5 same coin
return [coin, coin, coin, coin, coin]
}
// First col is the address's coin
var draw = [coin]
var good = 1
// 2nd, 3rd and 4th are random with a 1/3 probability for the same as 1st
// The 5th also as a 1/3 probability if there isn't already 4 good coins
// Otherwise, the 5th will never be the same coin
for (var i = 0; i < 4; i++) {
if (good < 4 && Math.floor(Math.random() * 3) == 0) {
draw.push(coin)
good++
} else {
var randomCoin
do {
randomCoin = this.pickRandomCoin().name.toLowerCase().replace(' ', '-')
} while (randomCoin == coin)
draw.push(randomCoin)
}
}

var coin = this.pickRandomCoin();
var pair = this.createPair(coin);
return draw
},
getLucky: function () {
var coin = this.pickRandomCoin()
var pair = this.createPair(coin)

this.machine.spin();
this.machine.spin()

address = pair.publicAddress;
address = pair.publicAddress

var start_timestamp = (+ new Date());
this.checkBalance(coin, address, function(amount) {
var start_timestamp = +new Date()
this.checkBalance(
coin,
address,
function (amount) {
if (amount > 0) {
alert('OMG!!! You found an wallet with coins in it!! 🤯')
}

if (amount > 0) {
alert('OMG!!! You found an address with coins on it!!');
}
var address = {
coin: coin,
amount: amount,
price: amount * (coin.price || 0),
pair: pair,
}

var address = {
coin: coin,
amount: amount,
price: amount * (coin.price || 0),
pair: pair
};
this.found_address = address

this.found_address = address;

var duration = (+ new Date())-start_timestamp;
var machine_time_left = (1000 - duration) > 0 ? (1000 - duration) : 1;
setTimeout(function() {
this.machine.setDraw(this.generateDraw(address));
this.machine.stop();
}.bind(this),machine_time_left);

}.bind(this));
}
}
});
var duration = +new Date() - start_timestamp
var machine_time_left = 1000 - duration > 0 ? 1000 - duration : 1
setTimeout(
function () {
this.machine.setDraw(this.generateDraw(address))
this.machine.stop()
}.bind(this),
machine_time_left
)
}.bind(this)
)
},
},
})
Loading

0 comments on commit 14617ea

Please sign in to comment.