Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ declarations

# Local Netlify folder
.netlify

/plugins
/.idea
2 changes: 1 addition & 1 deletion src/Backend/GameLogic/ContractCaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ContractCaller {
): Promise<T> {
for (let i = 0; i < ContractCaller.MAX_RETRIES; i++) {
try {
return await this.callQueue.add(() => contractViewFunction(...args));
return await contractViewFunction(...args);
} catch (e) {
await sleep(1000 * 2 ** i + Math.random() * 100);
}
Expand Down
7 changes: 4 additions & 3 deletions src/Backend/GameLogic/GameManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ class GameManager extends EventEmitter {
}
);

this.minerManager.startExplore();
//this.minerManager.startExplore();
}

/**
Expand Down Expand Up @@ -1792,7 +1792,8 @@ class GameManager extends EventEmitter {
forces: number,
silver: number,
artifactMoved?: ArtifactId,
bypassChecks = false
bypassChecks = false,
distMax: number | null = null
): GameManager {
if (this.checkGameHasEnded()) return this;
localStorage.setItem(`${this.getAccount()?.toLowerCase()}-fromPlanet`, from);
Expand Down Expand Up @@ -1821,7 +1822,7 @@ class GameManager extends EventEmitter {
const xDiff = newX - oldX;
const yDiff = newY - oldY;

const distMax = Math.ceil(Math.sqrt(xDiff ** 2 + yDiff ** 2));
distMax = distMax || Math.ceil(Math.sqrt(xDiff ** 2 + yDiff ** 2));

const shipsMoved = forces;
const silverMoved = silver;
Expand Down
19 changes: 10 additions & 9 deletions src/Backend/Network/TxExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class TxExecutor extends EventEmitter {
const [txReceipt, rejectTxReceipt, receiptPromise] = deferred<providers.TransactionReceipt>();

if (overrides.gasPrice === undefined) {
const gwei = EthersBN.from('1000000000');
const gwei = EthersBN.from('1010000000');
const userGasPriceGwei = this.uiStateStorageManager.getUIDataItem(
UIDataKey.gasFeeGwei
) as number;
Expand Down Expand Up @@ -167,14 +167,15 @@ export class TxExecutor extends EventEmitter {
this.lastTransaction = time_submitted;
txRequest.onTransactionResponse(submitted);

const confirmed = await this.eth.waitForTransaction(submitted.hash);
time_confirmed = Date.now();
txRequest.onTransactionReceipt(confirmed);

if (confirmed.status !== 1) {
time_errored = time_confirmed;
error = new Error('transaction reverted');
}
this.eth.waitForTransaction(submitted.hash).then((confirmed) => {
time_confirmed = Date.now();
txRequest.onTransactionReceipt(confirmed);

if (confirmed.status !== 1) {
time_errored = time_confirmed;
error = new Error('transaction reverted');
}
}).catch(txRequest.onReceiptError);
} catch (e) {
console.error(e);
time_errored = Date.now();
Expand Down
22 changes: 12 additions & 10 deletions src/Backend/Storage/PersistentChunkStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,21 @@ class PersistentChunkStore implements ChunkStore {
// if the chunk was loaded from storage, then we don't need to recommit it
// unless it can be promoted (which shouldn't ever happen, but we handle
// just in case)
public updateChunk(e: ExploredChunkData, loadedFromStorage = false): void {
if (this.hasMinedChunk(e.chunkFootprint)) {
public updateChunk(e: ExploredChunkData, loadedFromStorage = false, override = false): void {
if (override !== this.hasMinedChunk(e.chunkFootprint)) {
return;
}
const tx: DBTx = [];

// if this is a mega-chunk, delete all smaller chunks inside of it
const minedSubChunks = this.getMinedSubChunks(e);
for (const subChunk of minedSubChunks) {
tx.push({
type: DBActionType.DELETE,
dbKey: getChunkKey(subChunk.chunkFootprint),
});
if (!override) {
// if this is a mega-chunk, delete all smaller chunks inside of it
const minedSubChunks = this.getMinedSubChunks(e);
for (const subChunk of minedSubChunks) {
tx.push({
type: DBActionType.DELETE,
dbKey: getChunkKey(subChunk.chunkFootprint),
});
}
}

addToChunkMap(
Expand Down Expand Up @@ -285,7 +287,7 @@ class PersistentChunkStore implements ChunkStore {
}

// can stop here, if we're just loading into in-memory store from storage
if (loadedFromStorage) {
if (!override && loadedFromStorage) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Backend/Utils/SnarkArgsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class SnarkArgsHelper {
r: number,
distMax: number
): Promise<MoveSnarkContractCallArgs> {
const cacheKey = `${x1}-${y1}-${x2}-${y2}-${r}-${distMax}`;
const cacheKey = `${x1}-${y1}-${x2}-${y2}-${distMax}`;
const cachedResult = this.moveSnarkCache.get(cacheKey);
if (cachedResult) {
console.log('MOVE: retrieved snark args from cache');
Expand Down
5 changes: 3 additions & 2 deletions src/Frontend/Views/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import React, { useState, useEffect } from 'react';
import styled, { keyframes, css } from 'styled-components';
import { UIDataKey } from '../../Backend/Storage/UIStateStorageManager';
import { EthTxType } from '@darkforest_eth/types';
import { EthTxType, EthTxStatus } from '@darkforest_eth/types';
import NotificationManager, {
NotificationInfo,
NotificationType,
Expand Down Expand Up @@ -120,7 +120,8 @@ export function NotificationsPane() {
const newArr = _.clone(arr);
for (let i = 0; i < arr.length; i++) {
if (arr[i].id === notif.id) {
newArr[i] = notif;
if (notif.txStatus === EthTxStatus.Confirm) newArr.splice(i, 1);
else newArr[i] = notif;
return newArr;
}
}
Expand Down
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ module.exports = {
// The string values are fallbacks if the env variable is not set
new EnvironmentPlugin({
NODE_ENV: 'development',
DEFAULT_RPC: 'https://rpc.xdaichain.com/', // or 'https://rpc-df.xdaichain.com/'
// default: 'https://rpc.xdaichain.com/'
DEFAULT_RPC: 'http://localhost:8555', // or 'https://rpc-df.xdaichain.com/'
CONVERSATION_API_HOST: isProd ? 'https://api.zkga.me' : 'http://localhost:3000',
LEADERBOARD_API: isProd ? 'https://api.zkga.me' : 'http://localhost:3000',
WEBSERVER_URL: isProd ? 'https://api.zkga.me' : 'http://localhost:3000',
Expand Down
Loading