Skip to content
Merged
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
1 change: 1 addition & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@fontsource/ibm-plex-mono": "^5.0.13",
"@latticexyz/common": "2.0.11",
"@latticexyz/dev-tools": "2.0.11",
"@latticexyz/faucet": "^2.1.1",
"@latticexyz/react": "2.0.11",
"@latticexyz/recs": "2.0.11",
"@latticexyz/schema-type": "2.0.11",
Expand Down
42 changes: 41 additions & 1 deletion packages/client/src/lib/mud/createBurner.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { type ContractWrite } from '@latticexyz/common';
import { transactionQueue, writeObserver } from '@latticexyz/common/actions';
import { garnet } from '@latticexyz/common/chains';
import { createClient as createFaucetClient } from '@latticexyz/faucet';
import { getComponentValue, overridableComponent } from '@latticexyz/recs';
import { encodeEntity } from '@latticexyz/store-sync/recs';
import { callFrom } from '@latticexyz/world/internal';
import IWorldAbi from 'contracts/out/IWorld.sol/IWorld.abi.json';
import { share, Subject } from 'rxjs';
import { type Address, createWalletClient, getContract, type Hex } from 'viem';
import {
type Address,
createWalletClient,
getContract,
type Hex,
parseEther,
} from 'viem';

import { createSystemCalls } from '../mud/createSystemCalls';
import { type SetupNetworkResult } from '../mud/setupNetwork';
import { DEFAULT_CHAIN_ID } from '../web3';
import { createViemClientConfig } from './createViemClientConfig';
import { getBurnerAccount } from './getBurnerAccount';

Expand Down Expand Up @@ -73,6 +82,37 @@ export function createBurner(
},
}),
);

if (DEFAULT_CHAIN_ID === garnet.id) {
const address = walletClient.account.address;
// eslint-disable-next-line no-console
console.info('[Dev Faucet]: Player address -> ', address);

const faucetClient = createFaucetClient({
url: 'https://ultimate-dominion-faucet.onrender.com/trpc',
});

const requestDrip = async () => {
const balance = await network.publicClient.getBalance({ address });
// eslint-disable-next-line no-console
console.info(`[Dev Faucet]: Player balance -> ${balance}`);
const lowBalance = balance < parseEther('0.00001');
if (lowBalance) {
// eslint-disable-next-line no-console
console.info(
'[Dev Faucet]: Balance is low, dripping funds to player',
);

await faucetClient.drip.mutate({
address,
});
}
};

requestDrip();
// Request a drip every 20 seconds
setInterval(requestDrip, 20000);
}
}

/*
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/worlds.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"17069": {
"address": "0xbd771cc07e789128cc2c6b5890550f00d988506a",
"blockNumber": 6261456
"address": "0xc7f99b650dbff93da2c81f0b3c284000399e6f0f",
"blockNumber": 6378309
},
"31337": {
"address": "0xfc24a8bb029316490d86f202f4173dd9b19a1c96"
Expand Down
Loading