@flayerlabs/gamemode-gate 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEPLOY.md +12 -6
- package/README.md +3 -0
- package/dist/chain/registry-prices.d.ts +69 -0
- package/dist/chain/registry-prices.d.ts.map +1 -0
- package/dist/chain/registry-prices.js +157 -0
- package/dist/chain/registry-prices.js.map +1 -0
- package/dist/economy.d.ts.map +1 -1
- package/dist/economy.js +12 -3
- package/dist/economy.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +10 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +33 -5
- package/dist/main.js.map +1 -1
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +18 -0
- package/dist/server.js.map +1 -1
- package/dist/version.js +2 -2
- package/package.json +2 -2
- package/src/chain/registry-prices.ts +194 -0
- package/src/economy.ts +13 -3
- package/src/index.ts +2 -0
- package/src/main.ts +39 -5
- package/src/server.ts +30 -0
- package/src/version.ts +2 -2
package/src/server.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Fastify, { type FastifyInstance, type FastifyReply, type FastifyRequest } from 'fastify';
|
|
2
2
|
import websocket from '@fastify/websocket';
|
|
3
3
|
import cors from '@fastify/cors';
|
|
4
|
+
import { isAddress } from 'viem';
|
|
4
5
|
import type { Pool } from 'pg';
|
|
5
6
|
import type { Command, GameModule, PlayerId } from '@flayerlabs/gamemode-spec';
|
|
6
7
|
import { isRefusal } from '@flayerlabs/gamemode-spec';
|
|
@@ -58,6 +59,13 @@ interface GateBaseOptions {
|
|
|
58
59
|
* refused: a gate that guessed a price would be authorising real money on a made-up number.
|
|
59
60
|
*/
|
|
60
61
|
priceFor?: PriceFor;
|
|
62
|
+
/**
|
|
63
|
+
* Serves `GET /config/spend-tokens/:address`: the announced entry for one paired token — price,
|
|
64
|
+
* symbol, decimals and the per-wallet cap a launch on it should write — or null to answer 404 for
|
|
65
|
+
* a token this gate will not run rounds on. Lets launch tooling check any pairing before a coin
|
|
66
|
+
* is paid for, without the gate having listed it in `/config` up front.
|
|
67
|
+
*/
|
|
68
|
+
announceSpendToken?: (address: `0x${string}`) => Promise<AnnouncedSpendToken | null>;
|
|
61
69
|
/** Verifies from the chain that a coin really is a game launch. */
|
|
62
70
|
discovery?: Discovery;
|
|
63
71
|
/** Keeps the ledger's view of spending level with the chain's. */
|
|
@@ -168,6 +176,12 @@ export interface GateAnnouncement {
|
|
|
168
176
|
* listed here, which is the fail-closed answer for a gate that has not been told the token's price.
|
|
169
177
|
*/
|
|
170
178
|
spendTokens?: AnnouncedSpendToken[];
|
|
179
|
+
/**
|
|
180
|
+
* The manager's PairedTokenRegistry, when it has one. Its presence means this gate prices every
|
|
181
|
+
* token the registry approves, not only `spendTokens`: ask `/config/spend-tokens/:address` for the
|
|
182
|
+
* entry of any pairing before building a launch on it.
|
|
183
|
+
*/
|
|
184
|
+
pairedTokenRegistry?: `0x${string}`;
|
|
171
185
|
requiresEoa: boolean;
|
|
172
186
|
accepting: boolean;
|
|
173
187
|
/**
|
|
@@ -686,6 +700,22 @@ function createGateRuntime<Config, State, Event, Action, PublicView, PlayerView>
|
|
|
686
700
|
const served: ServedGateAnnouncement = { ...announce(), gateVersion: GATE_VERSION };
|
|
687
701
|
return served;
|
|
688
702
|
});
|
|
703
|
+
if (options.announceSpendToken) {
|
|
704
|
+
const announceSpendToken = options.announceSpendToken;
|
|
705
|
+
app.get<{ Params: { address: string } }>('/config/spend-tokens/:address', async (request, reply) => {
|
|
706
|
+
void reply.header('access-control-allow-origin', '*');
|
|
707
|
+
// A quote moves with the market and an approval can be revoked; nothing here may be cached
|
|
708
|
+
// past the response.
|
|
709
|
+
void reply.header('cache-control', 'no-store');
|
|
710
|
+
const { address } = request.params;
|
|
711
|
+
if (!isAddress(address, { strict: false })) {
|
|
712
|
+
return reply.code(400).send({ message: 'not a token address' });
|
|
713
|
+
}
|
|
714
|
+
const entry = await announceSpendToken(address as `0x${string}`);
|
|
715
|
+
if (!entry) return reply.code(404).send({ message: 'this gate does not run rounds on that token' });
|
|
716
|
+
return entry;
|
|
717
|
+
});
|
|
718
|
+
}
|
|
689
719
|
}
|
|
690
720
|
|
|
691
721
|
app.post('/session/challenge', async (request) => {
|
package/src/version.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by scripts/write-version.mjs from package.json at build time. Do not edit.
|
|
2
2
|
/** The published version of @flayerlabs/gamemode-gate, as a literal so it survives any bundler. */
|
|
3
|
-
export const GATE_VERSION: string = "0.5.
|
|
3
|
+
export const GATE_VERSION: string = "0.5.6";
|
|
4
4
|
/** `@flayerlabs/gamemode-gate@<version>`: the text a build of this package can be searched for. */
|
|
5
|
-
export const GATE_MARKER: string = "@flayerlabs/gamemode-gate@0.5.
|
|
5
|
+
export const GATE_MARKER: string = "@flayerlabs/gamemode-gate@0.5.6";
|