Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Megachain #31

Merged
merged 36 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
567afdf
fix(games): fix game coin name
shrpne Jul 14, 2023
95789ab
feat(megachain): add farmers page
shrpne Jul 14, 2023
bb474ca
feat: add gaming farmers bought amount
shrpne Jul 17, 2023
c3d192a
feat(topup): add spot miners redirect into topup to be used by telegr…
shrpne Jul 17, 2023
fd9b546
feat(megachain): add meganet farmers card
shrpne Jul 17, 2023
b49dfe4
fix(megachain): fix farmers amount available to sell
shrpne Jul 17, 2023
79211fd
fix(megachain): fix farmers amount available to sell
shrpne Jul 17, 2023
539cd10
farming bots text upd
2z2z2z Jul 17, 2023
57119a6
farmers-card fix
2z2z2z Jul 17, 2023
e4b78d7
buy-with-crypto in farmers hide
2z2z2z Jul 17, 2023
20923a9
fix(megachain): minor fixes
shrpne Jul 17, 2023
b4994ce
ru fix
2z2z2z Jul 17, 2023
63a9039
feat: MetagardenBuySpot - add support of buy direction
shrpne Jul 17, 2023
3e4c7da
buy farmer via Tg button
2z2z2z Jul 18, 2023
f6900c1
feat(megachain): display address in farmers buy form
shrpne Jul 18, 2023
edb7f55
feat: count cloudflare-kv keys; fix tests
shrpne Jul 18, 2023
02c5737
minter-address-label upd
2z2z2z Jul 19, 2023
26e632d
feat(buy): add universal token buy page
shrpne Jul 20, 2023
16f7421
activate Referral Card
2z2z2z Jul 20, 2023
0d04606
feat(buy): update telegram buy links to use orders
shrpne Jul 20, 2023
f2ab15d
buy FARMER button in /farming
2z2z2z Jul 20, 2023
bdea209
fix(topup): fix card2Minter url
shrpne Jul 20, 2023
c0248bd
ref hide
2z2z2z Jul 21, 2023
04bb844
feat(buy): reorder and add buy options
shrpne Jul 21, 2023
d7d469b
feat(buy): add option to fetch external address for telegram
shrpne Jul 21, 2023
747a08e
buy-button in index
2z2z2z Jul 21, 2023
15880b2
feat(buy): move telegram buy option to separate component, add new tg…
shrpne Jul 21, 2023
0e40908
feat(buy): update fetching heist address
shrpne Jul 21, 2023
340aad3
feat(buy): fetch SNATCH user address for telegram bot
shrpne Jul 24, 2023
f5e187e
feat(buy): add custom MEGA buy option
shrpne Jul 24, 2023
e7662e5
ref on
2z2z2z Jul 25, 2023
cda04f9
Remove game balance + Heist upd
2z2z2z Jul 25, 2023
18a3f5d
text upd
2z2z2z Jul 25, 2023
49516b8
feat(games): update game covers
shrpne Aug 9, 2023
e5702ad
send button in games
2z2z2z Aug 28, 2023
9006019
update: replace infura
shrpne Aug 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ APP_STAKING_API_URL=https://msp-api.minter.network/v1/
APP_REFERRAL_API_URL=https://mrs-api.minter.network/v1/
APP_PORTFOLIO_API_URL=https://portfolio-api.honee.app/v1/
APP_HUB_API_URL=https://hub-api.minter.network/
APP_ETHEREUM_API_URL=https://mainnet.infura.io/v3/0ab122c0f98043eda95266a862528e4c
APP_ETHEREUM_API_URL=https://rpc.ankr.com/eth
APP_BSC_API_URL=https://bsc-dataseed.binance.org/
APP_HUB_ETHEREUM_CONTRACT_ADDRESS=0x897c27Fa372AA730D4C75B1243E7EA38879194E2
APP_HUB_BSC_CONTRACT_ADDRESS=0xF5b0ed82a0b3e11567081694cC66c3df133f7C8F
Expand Down
2 changes: 1 addition & 1 deletion .env.master
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ APP_REFERRAL_API_URL=https://mrs-api.minter.network/v1/
APP_PORTFOLIO_API_URL=https://portfolio-api.honee.app/v1/
APP_METAGARDEN_API_URL=https://metagarden-claim-api.honee.app/v1/
APP_HUB_API_URL=https://hub-api.minter.network/
APP_ETHEREUM_API_URL=https://mainnet.infura.io/v3/0ab122c0f98043eda95266a862528e4c
APP_ETHEREUM_API_URL=https://rpc.ankr.com/eth
#APP_BSC_API_URL=https://bsc-dataseed.binance.org/
#APP_BSC_API_URL=https://bscrpc.com/
APP_BSC_API_URL=https://rpc.ankr.com/bsc/
Expand Down
2 changes: 1 addition & 1 deletion .env.megachain
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ APP_REFERRAL_API_URL=https://mrs-api.minter.network/v1/
APP_PORTFOLIO_API_URL=https://portfolio-api.honee.app/v1/
APP_METAGARDEN_API_URL=https://metagarden-claim-api.honee.app/v1/
APP_HUB_API_URL=https://hub-api.minter.network/
APP_ETHEREUM_API_URL=https://mainnet.infura.io/v3/0ab122c0f98043eda95266a862528e4c
APP_ETHEREUM_API_URL=https://rpc.ankr.com/eth
#APP_BSC_API_URL=https://bsc-dataseed.binance.org/
#APP_BSC_API_URL=https://bscrpc.com/
APP_BSC_API_URL=https://rpc.ankr.com/bsc/
Expand Down
2 changes: 1 addition & 1 deletion .env.megagamer
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ APP_REFERRAL_API_URL=https://mrs-api.minter.network/v1/
APP_PORTFOLIO_API_URL=https://portfolio-api.honee.app/v1/
APP_METAGARDEN_API_URL=https://metagarden-claim-api.honee.app/v1/
APP_HUB_API_URL=https://hub-api.minter.network/
APP_ETHEREUM_API_URL=https://mainnet.infura.io/v3/0ab122c0f98043eda95266a862528e4c
APP_ETHEREUM_API_URL=https://rpc.ankr.com/eth
#APP_BSC_API_URL=https://bsc-dataseed.binance.org/
#APP_BSC_API_URL=https://bscrpc.com/
APP_BSC_API_URL=https://rpc.ankr.com/bsc/
Expand Down
16 changes: 15 additions & 1 deletion api/cloudflare-kv.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const instance = axios.create({
// adapter: cacheAdapterEnhancer(getDefaultAdapter(), { enabledByDefault: false}),
headers: {
// @todo encrypt stored data with user private key
Authorization: `Bearer 8mjOb9lWZBKBN13E73uYY2FSHLAkdxTDNWs0sVkd`,
},
});
addToCamelInterceptor(instance);
Expand All @@ -28,3 +27,18 @@ export function getStoredValue(address) {
return response.data;
});
}

/**
* @param {object} [params]
* @param {string} [params.cursor]
* @param {number} [params.limit] - 1000 by default
* @return {Promise<{result: any, resultInfo: {count: number, cursor: string}}>}}
*/
export function listKeys(params) {
return instance.get('keys', {
params,
})
.then((response) => {
return response.data;
});
}
77 changes: 77 additions & 0 deletions api/heist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import axios from 'axios';
import {cacheAdapterEnhancer, Cache} from 'axios-extensions';
import {HEIST_BSC_API_URL, HEIST_BNB_MEGA_SWAP_API_URL} from "~/assets/variables.js";
import {getDefaultAdapter} from '~/assets/axios-default-adapter.js';
import addToCamelInterceptor from '~/assets/axios-to-camel.js';

const instance = axios.create({
baseURL: HEIST_BSC_API_URL,
// adapter: cacheAdapterEnhancer(getDefaultAdapter(), { enabledByDefault: false}),
});
// addToCamelInterceptor(instance);


/**
* @return {Promise<string>}
*/
export function getHeistAddress() {
if (!window.getTelegramWebApp) {
return Promise.reject(new Error('Not a TWA'));
}
// @TODO authorized tg user id can be used if not in TWA
return window.getTelegramWebApp()
.then((WebApp) => {
if (!WebApp.initDataUnsafe?.hash) {
throw new Error('No data from Telegram Bot');
}
const urlSearchParams = new URLSearchParams();
urlSearchParams.append("req_data", WebApp.initData);

return instance.get('me', {
params: urlSearchParams,
});
})
.then((response) => {
return response.data.address;
});
}

/**
* @return {Promise<string>}
*/
export function getHeistAddressFromId() {
if (!window.getTelegramWebApp) {
return Promise.reject(new Error('Not a TWA'));
}
return window.getTelegramWebApp()
.then((WebApp) => {
const userId = WebApp.initDataUnsafe?.user?.id;
if (!userId) {
throw new Error('No data from Telegram Bot');
}
return instance.get('address', {
params: {
id: userId,
},
});
})
.then((response) => {
return response.data.address;
});
}

/**
* @return {Promise<string>}
*/
export function getBnbMegaSwapAddress() {
return getHeistAddress()
.then((heistAddress) => {
return axios.get('wallet?recipient=' + heistAddress, {
baseURL: HEIST_BNB_MEGA_SWAP_API_URL,
});
})
.then((response) => {
return response.data.address;
});
}

16 changes: 16 additions & 0 deletions api/metagarden.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ export function getSpotInfo(privateKey) {
.then((response) => response.data.data);
}

/**
* @param {string} privateKey
* @return {Promise<{total: number, addressTotal: number}>}
*/
export function getSpotFarmerInfo(privateKey) {
if (!privateKey) {
throw new Error('PK needed to get spots info');
}
return instance.get('farmer/info', {
ecdsaAuth: {
privateKey,
},
})
.then((response) => response.data);
}

// export const getSpotInfo = () => getSpotInfoDebug('Mx531bdb3a6ab6faa0b6adba80cedeb86a6dbbea67');

/**
Expand Down
13 changes: 13 additions & 0 deletions api/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ export function getUserPortfolioNotificationList(privateKey) {
.then((response) => response.data.data);
}

/**
* @param {string} address
* @param {string} token
* @return {Promise<number>}
*/
export function createBuyOrder(address, token) {
return instance.post('/order', {
address,
token,
})
.then((response) => response.data.orderId);
}

export function sendAddress(telegramId, address, initData) {
return instance.post('/users/address', toSnake({
telegramId,
Expand Down
1 change: 1 addition & 0 deletions assets/axios-default-adapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from 'axios';
import adapters from 'axios/lib/adapters/adapters.js';
// import adapters from 'axios/unsafe/adapters/adapters.js';

const getAdapter = adapters.getAdapter;

Expand Down
38 changes: 0 additions & 38 deletions assets/img/auth-bg.svg

This file was deleted.

Binary file added assets/img/game-carrots-mafia-card.jpg
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 assets/img/game-carrots-mafia-card@2x.jpg
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 assets/img/game-chess-card.jpg
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 assets/img/game-chess-card@2x.jpg
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 assets/img/game-heist-card.jpg
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 assets/img/game-heist-card@2x.jpg
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 assets/img/game-miner-card.jpg
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 assets/img/game-miner-card@2x.jpg
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 assets/img/game-perfect-city-card.jpg
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 assets/img/game-perfect-city-card@2x.jpg
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 assets/img/game-snatch-card.jpg
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 assets/img/game-snatch-card@2x.jpg
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 assets/img/game-wonder-card.jpg
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 assets/img/game-wonder-card@2x.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
9 changes: 9 additions & 0 deletions assets/img/megachain-farmers-blobs.svg
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 assets/img/megachain-farmers-price.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 assets/img/megachain-farmers-price@2x.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 assets/img/megachain-farmers.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 assets/img/megachain-farmers@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/less/include/forms.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
.button--very-narrow {padding-inline: 6px;}
.button--medium {min-width: auto; width: 100%;}
.button--small {padding: 6px 13px; font-size: 14px; line-height: 18px;}
.button__content {display: inline-flex; align-items: center;}
//.button--icon {padding-left: 48px;}
//.button__icon {position: absolute; left: 28px; top: 50%; transform: translate(-50%, -50%);}
.button__icon {margin: -2px 8px -2px -2px; fill: currentColor;}
Expand Down
9 changes: 5 additions & 4 deletions assets/less/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

background: @c-mega-bg; color: #fff;
.wallet__action-button .color-main-light {display: none;}
.card--light-grey, .card--metagarden-game, .card:not([class="^card--"]) {.card--megachain();}
.card--light-grey, .card--metagarden-game, .card:not([class*="card--"]) {.card--megachain();}
.card:has(.card--light-grey) {}
.card--invert {border: none; background: transparent !important; /* important to override inline styles from custom color */}
//.card--invert .card.card__content {border-top: none;}
Expand Down Expand Up @@ -198,9 +198,6 @@
.auth__subtitle {text-align: center; font-size: 16px;}
.auth__subtitle-2 {text-align: center; font-size: 20px; line-height: 24px; font-weight: 700;}
.auth__p {text-align: center; font-size: 14px; line-height: 17px;}
/*@media (min-width: @breakpoint-medium-up) {
.auth__body {background-image: url(../img/auth-bg.svg); background-position: 50% 10%; background-repeat: no-repeat;}
}*/


.v-transition-toast-enter-active, .v-transition-toast-leave-active {
Expand Down Expand Up @@ -263,6 +260,8 @@
.card--megachain {background: @c-mega-bg; color: #fff; box-shadow: none; border: 1px solid @c-mega-border;}
.card--megachain-welcome { background: url(../img/megachain-welcome.svg) no-repeat center top #037940;}
.card--megachain-buy-block {background: url(../img/megachain-buy-block.svg) no-repeat left top;}
.card--megachain-farming {background: #1d2892;}
.card--megachain-farming--blobs {background-image: url('/img/megachain-farmers-blobs.svg'); background-position: center top; background-repeat: no-repeat;}
.card--extended-card {
.card__action-head {
margin: 0 0 152px 0 !important;
Expand Down Expand Up @@ -366,6 +365,8 @@

.card__cover {border-radius: 16px 16px 0 0; vertical-align: top; width: 100%;}
.card__badge {.u-h--uppercase(); position: absolute; bottom: 16px; right: 0; padding: 4px 8px; box-shadow: 0px 2px 2px rgba(0,0,0, 0.25); border-radius: 8px 0px 0px 8px; color: @c-black;}
.card__badge--top {bottom: auto; top: 16px;}
.card__badge--megachain-farmers {background: #00AD45; color: #fff; font-size: 16px; line-height: 20px; text-transform: none; padding: 6px 16px; letter-spacing: 0;}
.card__badge--coming-soon {background: #faff00;}

@media (min-width: @breakpoint-medium-up) {
Expand Down
27 changes: 25 additions & 2 deletions assets/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import decode from 'entity-decode';
import prettyNum, {PRECISION_SETTING} from 'pretty-num';
import prettyNum, {PRECISION_SETTING, ROUNDING_MODE} from 'pretty-num';
import stripZeros from 'pretty-num/src/strip-zeros';
import fromExponential from 'from-exponential';
import parseISO from "date-fns/esm/parseISO";
Expand Down Expand Up @@ -61,8 +61,17 @@ export function getEvmAddressUrl(chainId, hash) {
}

export function getCard2MinterUrl({address, returnUrl, finishUrl, coin = 'BIP'}) {
const query = queryToString({address, returnUrl, finishUrl, coin});
returnUrl = removeHash(returnUrl);
finishUrl = removeHash(finishUrl);
const query = queryToString({coin, address, returnUrl, finishUrl});
return `${CARD_TO_MINTER_HOST}/?${query}`;

function removeHash(url) {
if (!url) {
return url;
}
return url.replace(/#.*$/, '');
}
}

/**
Expand Down Expand Up @@ -134,6 +143,20 @@ export function prettyRound(value) {
return prettyNumber(value, 0);
}

/**
* @param {string|number} value
* @return {string}
*/
export function prettyFloor(value) {
return decode(prettyNum(value, {
precision: 0,
precisionSetting: undefined,
roundingMode: ROUNDING_MODE.FLOOR,
separateOneDigit: false,
thousandsSeparator: '&#x202F;',
}));
}

/**
* Ensure value to have from 2 to 8 decimal digits
* @param {string|number} value
Expand Down
21 changes: 21 additions & 0 deletions assets/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export const FARM_API_URL = 'https://yf.chainik.io/api/v1/';
export const CARD_TO_MINTER_HOST = process.env.APP_CARD_TO_MINTER_HOST;
export const CARD_TO_MINTER_API_URL = 'https://card-api.minter.trade/v1/';
export const CLOUDFLARE_KV_API_URL = 'https://exchanges-proxy.bip.dev/honee-cloudflare-kv/';
export const HEIST_BSC_API_URL = 'https://heist-bsc-api.dl-dev.ru/';
export const HEIST_BNB_MEGA_SWAP_API_URL = 'https://exchanges-proxy.bip.dev/heist-bnb-mega-swap/';
export const TELEGRAM_AUTH_BOT_NAME = IS_SUBAPP_MEGACHAIN || IS_SUBAPP_MEGAGAMER ? 'MetagardenBot' : 'HoneePremiumBot';
export const TELEGRAM_AUTH_HOST = IS_SUBAPP_MEGACHAIN || IS_SUBAPP_MEGAGAMER ? 'https://metagarden-bot.minter.network' : 'https://premium-bot.honee.app';
export const TELEGRAM_AUTH_API_URL = TELEGRAM_AUTH_HOST + '/api/v1/';
Expand Down Expand Up @@ -285,6 +287,25 @@ export const TX_STATUS = {
FAILURE: false,
};

export const SPOT_DATA = {
MGMINER: {
card2CardToken: '_SPOT',
plural: 'Miners',
pluralRu: 'Майнеров',
priceUsd: 320,
minAmount: 0.1,
buyAddress: 'Mxfb758e0516e3ced06eb90387b7fee61ecaad0000',
},
FARMER: {
card2CardToken: '_FARMER',
plural: 'Farmers',
pluralRu: 'Фармеров',
priceUsd: 100,
minAmount: 1,
buyAddress: 'Mx852c9e9befeb187de6968fc7ac75033ba0b0d111',
},
};

/**
* @typedef {number} ChainId
*/
2 changes: 1 addition & 1 deletion components/Action.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const addLiquidityAction = {
* @type {Object.<string, (ActionItemRaw | function(actionPathParts: Array<string>): ActionItemRaw)>}
*/
const actionList = {
buy: {
'hub-buy': {
params: ['coinToGet'],
component: HubBuyForm,
tags: [],
Expand Down
Loading
Loading