Connected: {shortenHex(padAddress(address), 4)}
Connected: {address}
{/if} ``` -------------------------------- ### Publish Svelte Library to npm Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/ui/README.md Steps to publish a Svelte library to npm. This involves updating the 'name' and potentially adding a 'license' field in 'package.json'. The 'npm publish' command then uploads the library. Ensure your package is correctly configured and versioned. ```shell # Go into the package.json and give your package the desired name through the "name" option. # Also consider adding a "license" field and point it to a LICENSE file. # To publish your library to [npm](https://www.npmjs.com): npm publish ``` -------------------------------- ### Manage Phantom Wallet State (Svelte) Source: https://github.com/runelabsxyz/ponziland/blob/main/pkgs/account/README.md Provides access to reactive state variables for the Phantom (Solana) wallet, such as connection status and wallet address. It also exposes methods for connecting to and disconnecting from the Phantom wallet. ```svelte ``` -------------------------------- ### SQL Schema for Consumer Cursor Tracking Source: https://github.com/runelabsxyz/ponziland/blob/main/scraps/EVENT_STREAM.md Defines the unlogged table 'consumer_cursors' in SQL for tracking the last processed event ID by each consumer. This table is crucial for crash recovery and ensures event ordering. An index on 'updated_at' is included for optimization. ```sql CREATE UNLOGGED TABLE consumer_cursors ( consumer_id UUID PRIMARY KEY, last_event_id UUID NOT NULL, updated_at TIMESTAMP NOT NULL ); -- Index for faster lookups CREATE INDEX consumer_cursors_updated_at_idx ON consumer_cursors(updated_at); ``` -------------------------------- ### List Authorized Tokens - Rust Indexer API Source: https://context7.com/runelabsxyz/ponziland/llms.txt Provides a list of all tokens that are authorized for use in land purchases and staking within the Ponziland ecosystem. Includes the symbol and contract address for each token. ```bash curl http://localhost:3000/tokens # Response: [ { "symbol": "ETH", "address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" }, { "symbol": "STRK", "address": "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d" }, { "symbol": "USDC", "address": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8" } ] ``` -------------------------------- ### BuildingLand Class for State Management Source: https://context7.com/runelabsxyz/ponziland/llms.txt Represents an owned land with full state management, providing typed access to land properties and stake information. It includes methods for creating land instances, updating stake information, and accessing properties like owner, level, sellPrice, stakeAmount, and token. It also offers a static `is` method for type checking. ```typescript // client/src/lib/api/land/building_land.ts import { BuildingLand } from '$lib/api/land/building_land'; import type { Land, LandStake } from '$lib/models.gen'; // Create from Dojo model const land: Land = { location: 100, owner: '0x123...', sell_price: 1000n, token_used: '0xabc...', block_date_bought: 1697500000n, level: { Zero: {} } }; const buildingLand = new BuildingLand(land); // Update stake information const landStake: LandStake = { location: 100, amount: 500n, neighbors_info_packed: 0n, accumulated_taxes_fee: 0n }; buildingLand.updateStake(landStake); // Access typed properties console.log(buildingLand.owner); // '0x123...' console.log(buildingLand.level); // 'Zero' | 'First' | 'Second' console.log(buildingLand.sellPrice); // CurrencyAmount instance console.log(buildingLand.stakeAmount); // CurrencyAmount instance console.log(buildingLand.token); // Token { symbol, address, decimals } // Check land type if (BuildingLand.is(someLand)) { // TypeScript knows someLand is BuildingLand const owner = someLand.owner; } ``` -------------------------------- ### Query Land Information Source: https://context7.com/runelabsxyz/ponziland/llms.txt Retrieve comprehensive land and stake data for gameplay calculations. ```APIDOC ## Query Land Information ### Description Retrieve comprehensive land and stake data for gameplay calculations. ### Method (Implied action within smart contract, not a direct HTTP endpoint) ### Endpoint (N/A - Smart Contract Action) ### Parameters (N/A - Smart Contract Action) ### Request Example ```cairo // Get complete land details let (land, land_stake) = actions.get_land(100_u16); ``` ### Response #### Land Properties - **location** (u16) - grid position - **owner** (ContractAddress) - **sell_price** (u256) - **token_used** (ContractAddress) - stake/sale token - **block_date_bought** (u64) - timestamp - **level** (Level enum) #### LandStake Properties - **amount** (u256) - staked tokens - **neighbors_info_packed** (u128) - packed neighbor data - **accumulated_taxes_fee** (u128) #### Yield Information ```cairo // Get yield information let yield_info = actions.get_neighbors_yield(100_u16); // Returns LandYieldInfo with per-neighbor yield rates and remaining stake time ``` ``` -------------------------------- ### TypeScript Currency Amount Handling and Operations Source: https://context7.com/runelabsxyz/ponziland/llms.txt Demonstrates the creation and manipulation of currency amounts using the CurrencyAmount utility. It covers creating amounts from unscaled and scaled values, performing arithmetic operations like addition, subtraction, multiplication, and division, and conducting comparisons between amounts. Dependencies include the CurrencyAmount class itself. ```typescript // client/src/lib/utils/CurrencyAmount.ts import { CurrencyAmount } from '$lib/utils/CurrencyAmount'; const token = { symbol: 'ETH', address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', decimals: 18 }; // Create from unscaled (wei) amount const amount = CurrencyAmount.fromUnscaled(1000000000000000000n, token); console.log(amount.toFixed(4)); // "1.0000" console.log(amount.toSignificant(3)); // "1.00" // Create from scaled (human) amount const amount2 = CurrencyAmount.fromScaled('1.5', token); console.log(amount2.unscaled); // 1500000000000000000n // Arithmetic operations const sum = amount.add(amount2); const diff = amount.subtract(amount2); const product = amount.multiply(2); const quotient = amount.divide(2); // Comparisons if (amount.greaterThan(amount2)) { console.log('Amount 1 is larger'); } ``` -------------------------------- ### Wrapped Contract Actions with Auto Approval Source: https://context7.com/runelabsxyz/ponziland/llms.txt Provides utility functions to execute game actions (buy, bid, increaseStake) with automatic ERC20 token approval. It simplifies contract interactions by handling the 'approve' call before executing the main action, ensuring tokens are approved for the required amounts. All methods return a transaction hash and wait for confirmation. ```typescript // client/src/lib/api/contracts/approve.ts import { wrappedActions } from '$lib/api/contracts/approve'; import { DojoProvider } from '@dojoengine/core'; const provider = new DojoProvider(/* ... */); const { actions } = await wrappedActions(provider); // Buy land with automatic token approval // Approves currentToken for buy price and tokenForSale for stake await actions.buy( account, 100n, // land_location '0xabc...', // tokenForSale 1000n, // sellPrice 500n, // amountToStake '0xdef...', // currentToken (token to pay with) 1000n // buyPrice (current price of land) ); // Bid on auction with automatic approval await actions.bid( account, 50n, // land_location '0xabc...', // tokenForSale 2000n, 800n, // amountToStake '0xdef...', // buyingToken 1500n // currentPrice (auction price) ); // Increase stake with automatic approval await actions.increaseStake( account, 100n, // land_location '0xabc...', // stakingToken 300n // amountToStake ); // All methods return transaction hash and wait for confirmation ``` -------------------------------- ### Proxy Paymaster Requests - Rust API Source: https://context7.com/runelabsxyz/ponziland/llms.txt This API endpoint proxies paymaster requests to the AVNU paymaster service using an API key. It forwards requests for gasless transactions and returns proxied responses or handles errors. ```bash curl -X POST http://localhost:3000/api/paymaster \ -H "Content-Type: application/json" \ -d '{ \ "method": "pm_getPaymasterData", \ "params": { \ "calls": [{ \ "to": "0x...", \ "selector": "0x...", \ "calldata": ["0x1", "0x2"] \ }] \ } \ }' # Response proxied from AVNU paymaster: { "paymasterData": { "paymaster": "0x...", "paymasterDataLength": 2, "paymasterData": ["0x...", "0x..."] } } # Error handling: # - 500 if proxy request fails # - Preserves original status codes from paymaster ```