@flayerlabs/gamemode-gate 0.3.0 → 0.4.0

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 ADDED
@@ -0,0 +1,75 @@
1
+ # Deploying a gate
2
+
3
+ A gate is your game's own server: it runs your rules, holds your signing key, and signs what your
4
+ rules award. This package gives you the assembled server; you give it a process, a Postgres, and an
5
+ environment. One process serves one chain.
6
+
7
+ Who holds what: the signing key is yours — the game developer's, nobody else's — and it never leaves your
8
+ gate. Flaunch neither holds nor registers it: a creator who launches through your game writes your
9
+ signer's address — the address only, read from your `/config` — into their pool's own on-chain parameters, and the
10
+ contract trusts it for that pool alone. Nothing on Flaunch's side has to know your key exists, and
11
+ a compromise of your key can only ever touch pools whose creators chose your game.
12
+
13
+ ## The entrypoint
14
+
15
+ Your repo imports your rules module and calls `startGate`:
16
+
17
+ ```ts
18
+ import { startGate } from '@flayerlabs/gamemode-gate';
19
+ import { rules, config } from './src/game/rules.js';
20
+
21
+ await startGate(rules, config);
22
+ ```
23
+
24
+ Boot refuses loudly on anything misconfigured (wrong-chain RPC, a calculator address with no code,
25
+ the demo signing key, the demo session secret) — see `assertSecureConfig`. A gate that boots is a
26
+ gate whose signatures a swap can actually verify.
27
+
28
+ ## Environment
29
+
30
+ | Variable | Required | Meaning |
31
+ | --- | --- | --- |
32
+ | `CHAIN_ID` | yes | The one chain this process serves. `84532` (Base Sepolia) is in the address book; any other chain needs both address overrides below. |
33
+ | `RPC_URL` | yes | An endpoint for that chain. Boot checks its `eth_chainId` matches. |
34
+ | `SIGNER_PRIVATE_KEY` | yes | Your key, generated by you, never shared — least of all with Flaunch. Its address is what launches name as their trusted signer; a key shared between two environments makes one gate's bug mint authorisations against the other's pools. |
35
+ | `DATABASE_URL` | yes | Postgres. Migrations run at boot. |
36
+ | `SESSION_SECRET` | yes | At least 32 characters, not the demo fallback. |
37
+ | `SIGN_IN_DOMAIN` | yes | The page the player is looking at when they sign in — the embedding site (e.g. `flaunch.gg`), not the game and not this gate. |
38
+ | `GATE_ORIGIN` | yes | This gate's own public https origin (e.g. `https://gate.example.com`) — the audience its sessions are scoped to. Configured, never derived from a request header. |
39
+ | `ALLOWED_ORIGINS` | yes | Comma-separated origins allowed to call this gate: your game's Moongate origin(s) and the flaunch page origins. |
40
+ | `PORT` | no | Default `8790`. |
41
+ | `POSITION_MANAGER`, `SPEND_GATED_CALCULATOR` | no | Address-book overrides. Set both only with addresses read back from the chain in question — a wrong address fails silently (see `chain/chains.ts`). |
42
+ | `SETTLER` | no | The address that may lift the gate early or rotate the signer on-chain. Defaults to the signing key's address; the gate expires on chain by itself either way. |
43
+ | `WALLET_CAP_WEI` | no | Advertised per-wallet cap for launches through this gate. Default 0.025 ETH. |
44
+ | `ROUND_MS` | no | Advertised round length. Default 90000. |
45
+ | `MIN_LOBBY_LEAD_MS`, `GATE_ENDS_AT_GRACE_S` | no | Defaults 60000 and 10. |
46
+ | `POINTS_PER_DOLLAR`, `USD_PER_ETH` | no | Your game's economy. Defaults 100 and 3000; boot refuses an economy your `rewardBounds` cannot honour. |
47
+
48
+ ## Railway shape
49
+
50
+ 1. A service running your gate repo (build → `node dist/main.js` or however your repo boots
51
+ `startGate`), plus an attached Postgres whose URL lands in `DATABASE_URL`.
52
+ 2. Set the variables above. Generate `SIGNER_PRIVATE_KEY` and `SESSION_SECRET` fresh for each
53
+ environment.
54
+ 3. The service needs a public HTTPS domain: game submission validates your `gateOrigin` as public
55
+ HTTPS (no localhost, no IPs), and the browser's CSP only lets your game call the origin you
56
+ submitted.
57
+
58
+ ## Smoke sequence
59
+
60
+ ```
61
+ curl https://<gate>/health → { "ok": true }
62
+ curl https://<gate>/config → chainId must be the chain you meant; note "signer"
63
+ ```
64
+
65
+ The `signer` in `/config` is the address a launch must name for this gate to adopt it — the create
66
+ flow reads it from here. If `/config` is missing, the process was built without `announce`
67
+ (an old build) and launch tooling cannot see this gate.
68
+
69
+ ## Hand it to Flaunch
70
+
71
+ The public https origin you just smoke-tested is exactly the Gate URL you enter when you submit
72
+ your game at `flaunch.gg/game-mode/create` — with the gate option enabled. A game submitted without
73
+ it is hosted as a passive game: its security policy allows no gate connection at all, so a launch
74
+ through it can never open a room. The origin must be public https (no localhost, no IPs, no
75
+ wildcards), because the game's browser policy only permits the origin you submitted.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Every chain this gate knows how to serve, and the addresses that belong to it.
3
+ *
4
+ * The address book lives in the repo rather than in the environment because a wrong address fails
5
+ * in the worst possible way: `readContract` against an address with no code returns empty rather
6
+ * than throwing, so adoption refuses every coin as "not a game launch" and the mistake presents as
7
+ * an application bug a long way from the variable that caused it. An entry that is ABSENT makes
8
+ * boot refuse and name the variable to set; an entry that is WRONG fails silently. Absent is
9
+ * strictly better than guessed, so record only addresses that have been read back from the chain
10
+ * in question.
11
+ *
12
+ * Base mainnet (8453) is deliberately missing: none of this stack is deployed there, and it is
13
+ * gated on the audit and the multisig handover. Robinhood (4663) is deliberately missing too —
14
+ * that chain is served by the legacy gate, and this library refusing it keeps the two stacks from
15
+ * being pointed at each other by a copied env file.
16
+ */
17
+ export interface GateDeployment {
18
+ positionManager: `0x${string}`;
19
+ spendGatedCalculator: `0x${string}`;
20
+ /**
21
+ * Which `flaunch()` struct the chain's PositionManager takes. V1_2 deployments carry two extra
22
+ * fair-launch fields ('legacy11'); the newer nine-field shape is 'current9'. Getting this wrong
23
+ * is an ABI revert at launch time, so it is recorded per chain rather than guessed.
24
+ */
25
+ flaunchVariant: 'legacy11' | 'current9';
26
+ }
27
+ export declare const DEPLOYMENTS: Record<number, GateDeployment>;
28
+ /** The deployment for a chain, or undefined for one this library has no address book for. */
29
+ export declare function deploymentFor(chainId: number): GateDeployment | undefined;
30
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/chain/chains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;IAC/B,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,cAAc,EAAE,UAAU,GAAG,UAAU,CAAC;CACzC;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAWtD,CAAC;AAEF,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEzE"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Every chain this gate knows how to serve, and the addresses that belong to it.
3
+ *
4
+ * The address book lives in the repo rather than in the environment because a wrong address fails
5
+ * in the worst possible way: `readContract` against an address with no code returns empty rather
6
+ * than throwing, so adoption refuses every coin as "not a game launch" and the mistake presents as
7
+ * an application bug a long way from the variable that caused it. An entry that is ABSENT makes
8
+ * boot refuse and name the variable to set; an entry that is WRONG fails silently. Absent is
9
+ * strictly better than guessed, so record only addresses that have been read back from the chain
10
+ * in question.
11
+ *
12
+ * Base mainnet (8453) is deliberately missing: none of this stack is deployed there, and it is
13
+ * gated on the audit and the multisig handover. Robinhood (4663) is deliberately missing too —
14
+ * that chain is served by the legacy gate, and this library refusing it keeps the two stacks from
15
+ * being pointed at each other by a copied env file.
16
+ */
17
+ export const DEPLOYMENTS = {
18
+ /**
19
+ * Base Sepolia — the reference chain. Deployed 2026-08-16 (flaunch-contracts
20
+ * SpendGatedGate.s.sol); both PositionManager fee-calculator slots were read back holding the
21
+ * dispatcher, and the calculator resolves each pool's own paired token (VPT-13).
22
+ */
23
+ 84532: {
24
+ positionManager: '0x4E7cB1e6800a7B297B38BddcecAF9Ca5b6616FDC',
25
+ spendGatedCalculator: '0x8cbbE6b4cFA5Ccf68399Dbf1429d91A21097ebA5',
26
+ flaunchVariant: 'legacy11',
27
+ },
28
+ };
29
+ /** The deployment for a chain, or undefined for one this library has no address book for. */
30
+ export function deploymentFor(chainId) {
31
+ return DEPLOYMENTS[chainId];
32
+ }
33
+ //# sourceMappingURL=chains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chain/chains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAaH,MAAM,CAAC,MAAM,WAAW,GAAmC;IACzD;;;;OAIG;IACH,KAAK,EAAE;QACL,eAAe,EAAE,4CAA4C;QAC7D,oBAAoB,EAAE,4CAA4C;QAClE,cAAc,EAAE,UAAU;KAC3B;CACF,CAAC;AAEF,6FAA6F;AAC7F,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { PublicClient } from 'viem';
2
+ /** The demo's session-secret fallback, which every copy of this repo shares. */
3
+ export declare const DEMO_SESSION_SECRET = "dev-secret-that-is-long-enough-to-pass";
4
+ export interface SecureConfig {
5
+ chainId: number;
6
+ signerPrivateKey: string;
7
+ spendGatedCalculator: `0x${string}`;
8
+ sessionSecret: string;
9
+ }
10
+ export declare function assertSecureConfig(client: PublicClient, config: SecureConfig): Promise<void>;
11
+ //# sourceMappingURL=secure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure.d.ts","sourceRoot":"","sources":["../../src/chain/secure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAezC,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,2CAA2C,CAAC;AAE5E,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBlG"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The boot-time refusals {@link PayloadSigner}'s doc comment promises.
3
+ *
4
+ * Every check here guards against a failure that is otherwise silent at the worst moment: a signer
5
+ * built against the wrong chain or a placeholder calculator produces signatures every swap rejects
6
+ * as `InvalidSigner` — at claim time, inside a window that will not come back, with nothing in the
7
+ * gate's own logs. Refusing to boot is the only place the mistake is cheap.
8
+ */
9
+ /** The demo's constant signing key. Funding it, or serving real rounds with it, is the mistake. */
10
+ const DEMO_SIGNING_KEY = `0x${'11'.repeat(32)}`;
11
+ const ZERO_KEY = `0x${'00'.repeat(32)}`;
12
+ /** The demo's session-secret fallback, which every copy of this repo shares. */
13
+ export const DEMO_SESSION_SECRET = 'dev-secret-that-is-long-enough-to-pass';
14
+ export async function assertSecureConfig(client, config) {
15
+ const key = config.signerPrivateKey.toLowerCase();
16
+ if (key === DEMO_SIGNING_KEY || key === ZERO_KEY) {
17
+ throw new Error('SIGNER_PRIVATE_KEY is the demo constant — a real gate needs its own key');
18
+ }
19
+ if (config.sessionSecret === DEMO_SESSION_SECRET) {
20
+ throw new Error('SESSION_SECRET is the demo fallback — set a secret of your own');
21
+ }
22
+ // The one check that catches a copied env file: signatures bind to CHAIN_ID through the EIP-712
23
+ // domain, so signing for one chain against another's RPC yields authorizations nothing accepts.
24
+ const chainId = await client.getChainId();
25
+ if (chainId !== config.chainId) {
26
+ throw new Error(`RPC_URL answers chain ${chainId}, but CHAIN_ID is ${config.chainId}`);
27
+ }
28
+ // A calculator with no code is a placeholder or another chain's address; either way every read
29
+ // against it returns empty rather than throwing, which is the silent failure mode this file
30
+ // exists to catch.
31
+ const code = await client.getCode({ address: config.spendGatedCalculator });
32
+ if (!code || code === '0x') {
33
+ throw new Error(`SPEND_GATED_CALCULATOR ${config.spendGatedCalculator} holds no code on chain ${chainId}`);
34
+ }
35
+ }
36
+ //# sourceMappingURL=secure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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AAO,EAAE,CAAC,CAAC;IAC7G,CAAC;AACH,CAAC"}
package/dist/demo.d.ts CHANGED
@@ -14,6 +14,12 @@ export interface DemoOptions<Config, State, Event, Action, PublicView, PlayerVie
14
14
  pointsPerDollar?: number;
15
15
  usdPerEth?: number;
16
16
  roundId?: string;
17
+ /**
18
+ * The chain the EIP-712 domain names. Default 8453, kept from when this was the only option; a
19
+ * demo standing in for a Base Sepolia gate passes 84532 so its signatures carry the same domain
20
+ * a real one would. No chain is consulted either way.
21
+ */
22
+ chainId?: number;
17
23
  /** Exact origin where this demo gate will listen. Default `http://127.0.0.1:4000`. */
18
24
  gateOrigin?: string;
19
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../src/demo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AA+B5D,MAAM,WAAW,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU;IAC/E,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,0FAA0F;IAC1F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB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Ae,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,eAAe,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,aAAa,EAAE,KAAK,MAAM,EAAE,CAAC;IAC7B,wFAAwF;IACxF,SAAS,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACjD,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;CACf;AAID;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EACvF,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,GACzE,OAAO,CAAC,IAAI,CAAC,CAmGf"}
package/dist/demo.js CHANGED
@@ -35,7 +35,7 @@ const ETH = 1000000000000000000n;
35
35
  * is the one part of this that genuinely differs between games.
36
36
  */
37
37
  export async function createDemoGate(options) {
38
- const { game, config, databaseUrl = process.env.DATABASE_URL ?? 'postgres://postgres:gamemode@127.0.0.1:55439/gamemode', lobbyMs = 8_000, roundMs = 10 * 60_000, walletCapWei = ETH / 40n, pointsPerDollar = 100, usdPerEth = 3_000, roundId = 'dev', gateOrigin = 'http://127.0.0.1:4000', } = options;
38
+ const { game, config, databaseUrl = process.env.DATABASE_URL ?? 'postgres://postgres:gamemode@127.0.0.1:55439/gamemode', lobbyMs = 8_000, roundMs = 10 * 60_000, walletCapWei = ETH / 40n, pointsPerDollar = 100, usdPerEth = 3_000, roundId = 'dev', chainId = 8453, gateOrigin = 'http://127.0.0.1:4000', } = options;
39
39
  // The same check the real gate runs at boot. A demo that silently used an impossible economy
40
40
  // would teach a builder that their numbers work when they do not.
41
41
  const maxPointsPerPlayer = game.rewardBounds(config).maxPointsPerPlayer;
@@ -66,6 +66,7 @@ export async function createDemoGate(options) {
66
66
  scoreAuthority: 'rules',
67
67
  poolId: DEMO_POOL_ID,
68
68
  });
69
+ const signer = new PayloadSigner(DEMO_SIGNING_KEY, chainId, DEMO_CALCULATOR);
69
70
  const app = createGate({
70
71
  pool,
71
72
  game,
@@ -73,9 +74,25 @@ export async function createDemoGate(options) {
73
74
  pointsPerDollar,
74
75
  usdPerEth,
75
76
  sessions: new Sessions(process.env.SESSION_SECRET ?? 'dev-secret-that-is-long-enough-to-pass', 'localhost', gateOrigin),
76
- claims: new Claims(pool, new Ledger(pool), new PayloadSigner(DEMO_SIGNING_KEY, 8453, DEMO_CALCULATOR)),
77
+ claims: new Claims(pool, new Ledger(pool), signer),
77
78
  // Anything, because this is a laptop and the browser is on some port nobody can predict.
78
79
  allowedOrigins: true,
80
+ // The same self-description a real gate serves, so tooling built against /config works here.
81
+ announce: () => ({
82
+ chainId,
83
+ contracts: { positionManager: DEMO_CALCULATOR, spendGatedCalculator: DEMO_CALCULATOR },
84
+ signer: signer.address,
85
+ settler: signer.address,
86
+ walletCapWei: walletCapWei.toString(),
87
+ roundDurationMs: roundMs,
88
+ minLobbyLeadMs: lobbyMs,
89
+ gateEndsAtGraceS: 10,
90
+ flaunchVariant: 'legacy11',
91
+ requiresEoa: false,
92
+ accepting: true,
93
+ publicLaunchesOpen: true,
94
+ privateLaunches: false,
95
+ }),
79
96
  });
80
97
  const wallet = privateKeyToAccount(DEMO_WALLET_KEY);
81
98
  const purchases = [];
package/dist/demo.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"demo.js","sourceRoot":"","sources":["../src/demo.ts"],"names":[],"mappings":"AAAA,OAAO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AAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC5D,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QAC/C,SAAS,EAAE,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,EAAG,OAAO,CAAC,IAA4B,CAAC,OAAO,EAAE,CAAC;KAChG,CAAC,CAAC,CAAC;IACJ,GAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,EAAE;QACtC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAA+B,CAAC;QAChE,SAAS,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAChD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACnF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -23,4 +23,15 @@ export type { GameRegistryOptions } from './game-registry.js';
23
23
  export type { GameServerAwardReceipt, GameServerAwardRefusal, GameServerAwardRequest, GameServerPlayerRefusal, GameServerPlayerResult, GameServerPlayerStanding, } from './game-server-awards.js';
24
24
  export { PLAYER_JOIN_TICKET_TTL_MS, verifyPlayerJoinTicket } from './player-join-tickets.js';
25
25
  export type { VerifiedPlayerJoin, VerifyPlayerJoinTicketOptions } from './player-join-tickets.js';
26
+ /**
27
+ * The deployment story: {@link startGate} turns a rules module and an environment into a running
28
+ * gate (see DEPLOY.md), and the pieces below it stay exported for anyone wiring their own.
29
+ */
30
+ export { startGate, resolveGateEnv } from './main.js';
31
+ export type { ResolvedGateConfig, StartedGate, StartGateOverrides } from './main.js';
32
+ export type { GateAnnouncement } from './server.js';
33
+ export { NotSignedIn } from './sessions.js';
34
+ export { DEPLOYMENTS, deploymentFor } from './chain/chains.js';
35
+ export type { GateDeployment } from './chain/chains.js';
36
+ export { assertSecureConfig } from './chain/secure.js';
26
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EACL,MAAM,EACN,0BAA0B,EAC1B,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC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AC;AAC7F,YAAY,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAElG;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACtD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACrF,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -12,4 +12,12 @@ export { createDemoGate } from './demo.js';
12
12
  export { InvalidRegistration, RegistrationConflict, checkRegistration, disableGameRegistration, gateOrigin, pinGameRegistration, resolveGameRegistration, securityProfile, } from './registry.js';
13
13
  export { createGameRegistry } from './game-registry.js';
14
14
  export { PLAYER_JOIN_TICKET_TTL_MS, verifyPlayerJoinTicket } from './player-join-tickets.js';
15
+ /**
16
+ * The deployment story: {@link startGate} turns a rules module and an environment into a running
17
+ * gate (see DEPLOY.md), and the pieces below it stay exported for anyone wiring their own.
18
+ */
19
+ export { startGate, resolveGateEnv } from './main.js';
20
+ export { NotSignedIn } from './sessions.js';
21
+ export { DEPLOYMENTS, deploymentFor } from './chain/chains.js';
22
+ export { assertSecureConfig } from './chain/secure.js';
15
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EACL,MAAM,EACN,0BAA0B,EAC1B,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAWrB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;AAExE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,UAAU,EACV,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAUxD,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAG7F;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/main.d.ts ADDED
@@ -0,0 +1,84 @@
1
+ import pg from 'pg';
2
+ import { type PublicClient } from 'viem';
3
+ import type { FastifyInstance } from 'fastify';
4
+ import type { GameModule } from '@flayerlabs/gamemode-spec';
5
+ import { type GateDeployment } from './chain/chains.js';
6
+ /**
7
+ * A production gate from an environment, assembled and checked.
8
+ *
9
+ * Until this file, every component existed and nothing joined them: the only `createGate` call
10
+ * sites were tests and the chain-free demo, so "run a gate against a real chain" meant writing this
11
+ * bootstrap yourself. A gate is still your game's own server — your repo imports your rules module
12
+ * and calls {@link startGate} — but the wiring, the address book and the refusals are the same for
13
+ * everyone, so they live here.
14
+ *
15
+ * Configuration is refused loudly rather than defaulted quietly. The failure mode this guards
16
+ * against is not a crash but a gate that boots, adopts nothing, and signs authorizations nothing
17
+ * accepts — see {@link assertSecureConfig} and the address-book note in chain/chains.ts.
18
+ */
19
+ type Env = Record<string, string | undefined>;
20
+ export interface ResolvedGateConfig {
21
+ chainId: number;
22
+ rpcUrl: string;
23
+ signerPrivateKey: `0x${string}`;
24
+ databaseUrl: string;
25
+ sessionSecret: string;
26
+ /** The page the player is looking at — the embedding site, not the game or this gate. */
27
+ signInDomain: string;
28
+ /** This gate's own public origin — the SIWE audience. Configured, never derived from a header. */
29
+ gateOrigin: string;
30
+ allowedOrigins: (string | RegExp)[];
31
+ port: number;
32
+ deployment: GateDeployment;
33
+ /** Announced to launch tooling; the creator's launch writes it into the pool. */
34
+ walletCapWei: bigint;
35
+ roundDurationMs: number;
36
+ minLobbyLeadMs: number;
37
+ gateEndsAtGraceS: number;
38
+ pointsPerDollar: number;
39
+ usdPerEth: number;
40
+ /** May lift the gate early or rotate the signer on-chain. Defaults to the signing key's address. */
41
+ settler: `0x${string}` | null;
42
+ }
43
+ /**
44
+ * Read and validate the environment, pure so a test can feed it a plain object.
45
+ *
46
+ * The contract, all read here and nowhere else:
47
+ * CHAIN_ID required; must have an address-book entry unless both overrides are set
48
+ * RPC_URL required
49
+ * SIGNER_PRIVATE_KEY required; this gate's own key, never shared between environments
50
+ * DATABASE_URL required
51
+ * SESSION_SECRET required, at least 32 characters, not the demo fallback
52
+ * SIGN_IN_DOMAIN required; the embedding page the player sees (e.g. flaunch.gg)
53
+ * GATE_ORIGIN required; this gate's own public https origin (the SIWE audience)
54
+ * ALLOWED_ORIGINS required; comma-separated origins that may call this gate
55
+ * PORT default 8790
56
+ * POSITION_MANAGER optional address-book override
57
+ * SPEND_GATED_CALCULATOR optional address-book override
58
+ * FLAUNCH_VARIANT optional; only meaningful alongside the overrides
59
+ * SETTLER optional; defaults to the signing key's own address
60
+ * WALLET_CAP_WEI default 0.025 ETH
61
+ * ROUND_MS default 90000
62
+ * MIN_LOBBY_LEAD_MS default 60000
63
+ * GATE_ENDS_AT_GRACE_S default 10
64
+ * POINTS_PER_DOLLAR default 100
65
+ * USD_PER_ETH default 3000
66
+ */
67
+ export declare function resolveGateEnv(env: Env): ResolvedGateConfig;
68
+ export interface StartedGate {
69
+ app: FastifyInstance;
70
+ port: number;
71
+ /** The address launches must name as their trusted signer for this gate to adopt them. */
72
+ signer: `0x${string}`;
73
+ pool: pg.Pool;
74
+ }
75
+ export interface StartGateOverrides {
76
+ env?: Env;
77
+ /** Injectable for tests; a real boot builds its own from RPC_URL. */
78
+ client?: PublicClient;
79
+ /** False builds and checks everything but never binds a port. */
80
+ listen?: boolean;
81
+ }
82
+ export declare function startGate<Config, State, Event, Action, PublicView, PlayerView>(game: GameModule<Config, State, Event, Action, PublicView, PlayerView>, gameConfig: Config, overrides?: StartGateOverrides): Promise<StartedGate>;
83
+ export {};
84
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAuC,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAU5D,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGvE;;;;;;;;;;;;GAYG;AAEH,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,KAAK,MAAM,EAAE,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,yFAAyF;IACzF,YAAY,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,cAAc,CAAC;IAC3B,iFAAiF;IACjF,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,oGAAoG;IACpG,OAAO,EAAE,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;CAC/B;AAuBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,kBAAkB,CA4D3D;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,eAAe,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,0FAA0F;IAC1F,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,qEAAqE;IACrE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,iEAAiE;IACjE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAClF,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,EACtE,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,kBAAuB,GACjC,OAAO,CAAC,WAAW,CAAC,CAwEtB"}
package/dist/main.js ADDED
@@ -0,0 +1,180 @@
1
+ import pg from 'pg';
2
+ import { createPublicClient, http, isAddress } from 'viem';
3
+ import { createGate } from './server.js';
4
+ import { Ledger } from './ledger.js';
5
+ import { Claims } from './claims.js';
6
+ import { Sessions } from './sessions.js';
7
+ import { PayloadSigner } from './chain/signer.js';
8
+ import { Discovery } from './chain/discover.js';
9
+ import { Settlement } from './settlement.js';
10
+ import { migrate } from './store.js';
11
+ import { resolveEconomy } from './economy.js';
12
+ import { deploymentFor } from './chain/chains.js';
13
+ import { assertSecureConfig } from './chain/secure.js';
14
+ function required(env, name) {
15
+ const value = env[name];
16
+ if (!value)
17
+ throw new Error(`${name} is not set — the gate refuses to guess it`);
18
+ return value;
19
+ }
20
+ function integer(env, name, fallback) {
21
+ const raw = env[name];
22
+ if (raw === undefined || raw === '')
23
+ return fallback;
24
+ const value = Number(raw);
25
+ if (!Number.isSafeInteger(value) || value < 0)
26
+ throw new Error(`${name} must be a non-negative integer`);
27
+ return value;
28
+ }
29
+ function address(env, name) {
30
+ const raw = env[name];
31
+ if (raw === undefined || raw === '')
32
+ return null;
33
+ if (!isAddress(raw))
34
+ throw new Error(`${name} is not an address`);
35
+ return raw;
36
+ }
37
+ /**
38
+ * Read and validate the environment, pure so a test can feed it a plain object.
39
+ *
40
+ * The contract, all read here and nowhere else:
41
+ * CHAIN_ID required; must have an address-book entry unless both overrides are set
42
+ * RPC_URL required
43
+ * SIGNER_PRIVATE_KEY required; this gate's own key, never shared between environments
44
+ * DATABASE_URL required
45
+ * SESSION_SECRET required, at least 32 characters, not the demo fallback
46
+ * SIGN_IN_DOMAIN required; the embedding page the player sees (e.g. flaunch.gg)
47
+ * GATE_ORIGIN required; this gate's own public https origin (the SIWE audience)
48
+ * ALLOWED_ORIGINS required; comma-separated origins that may call this gate
49
+ * PORT default 8790
50
+ * POSITION_MANAGER optional address-book override
51
+ * SPEND_GATED_CALCULATOR optional address-book override
52
+ * FLAUNCH_VARIANT optional; only meaningful alongside the overrides
53
+ * SETTLER optional; defaults to the signing key's own address
54
+ * WALLET_CAP_WEI default 0.025 ETH
55
+ * ROUND_MS default 90000
56
+ * MIN_LOBBY_LEAD_MS default 60000
57
+ * GATE_ENDS_AT_GRACE_S default 10
58
+ * POINTS_PER_DOLLAR default 100
59
+ * USD_PER_ETH default 3000
60
+ */
61
+ export function resolveGateEnv(env) {
62
+ const chainId = Number(required(env, 'CHAIN_ID'));
63
+ if (!Number.isSafeInteger(chainId) || chainId <= 0)
64
+ throw new Error('CHAIN_ID must be a positive integer');
65
+ const recorded = deploymentFor(chainId);
66
+ const positionManager = address(env, 'POSITION_MANAGER') ?? recorded?.positionManager ?? null;
67
+ const spendGatedCalculator = address(env, 'SPEND_GATED_CALCULATOR') ?? recorded?.spendGatedCalculator ?? null;
68
+ if (!positionManager || !spendGatedCalculator) {
69
+ throw new Error(`chain ${chainId} has no recorded deployment — set POSITION_MANAGER and SPEND_GATED_CALCULATOR ` +
70
+ `with addresses read back from that chain, or use a chain from the address book`);
71
+ }
72
+ const variantOverride = env['FLAUNCH_VARIANT'];
73
+ if (variantOverride !== undefined && variantOverride !== 'legacy11' && variantOverride !== 'current9') {
74
+ throw new Error(`FLAUNCH_VARIANT must be legacy11 or current9, not ${variantOverride}`);
75
+ }
76
+ const flaunchVariant = variantOverride ?? recorded?.flaunchVariant ?? 'legacy11';
77
+ const signerPrivateKey = required(env, 'SIGNER_PRIVATE_KEY');
78
+ if (!/^0x[0-9a-fA-F]{64}$/.test(signerPrivateKey)) {
79
+ throw new Error('SIGNER_PRIVATE_KEY must be a 32-byte hex key');
80
+ }
81
+ /**
82
+ * An entry may carry one `*` in its host — `https://*.flayer.dev` — because preview deployments
83
+ * mint a fresh subdomain per deploy, and a gate that names only yesterday's refuses today's
84
+ * embed with a CORS failure the page can only report as "stuck". The wildcard spans exactly one
85
+ * label: it must not make `https://*.dev` mean the whole internet by accident.
86
+ */
87
+ const allowedOrigins = required(env, 'ALLOWED_ORIGINS')
88
+ .split(',')
89
+ .map((origin) => origin.trim())
90
+ .filter((origin) => origin.length > 0)
91
+ .map((origin) => origin.includes('*')
92
+ ? new RegExp(`^${origin.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '[a-z0-9-]+')}$`)
93
+ : origin);
94
+ if (allowedOrigins.length === 0)
95
+ throw new Error('ALLOWED_ORIGINS names no origins');
96
+ return {
97
+ chainId,
98
+ rpcUrl: required(env, 'RPC_URL'),
99
+ signerPrivateKey: signerPrivateKey,
100
+ databaseUrl: required(env, 'DATABASE_URL'),
101
+ sessionSecret: required(env, 'SESSION_SECRET'),
102
+ signInDomain: required(env, 'SIGN_IN_DOMAIN'),
103
+ gateOrigin: required(env, 'GATE_ORIGIN'),
104
+ allowedOrigins,
105
+ port: integer(env, 'PORT', 8790),
106
+ deployment: { positionManager, spendGatedCalculator, flaunchVariant },
107
+ walletCapWei: BigInt(env['WALLET_CAP_WEI'] ?? 25000000000000000n.toString()),
108
+ roundDurationMs: integer(env, 'ROUND_MS', 90_000),
109
+ minLobbyLeadMs: integer(env, 'MIN_LOBBY_LEAD_MS', 60_000),
110
+ gateEndsAtGraceS: integer(env, 'GATE_ENDS_AT_GRACE_S', 10),
111
+ pointsPerDollar: integer(env, 'POINTS_PER_DOLLAR', 100),
112
+ usdPerEth: integer(env, 'USD_PER_ETH', 3_000),
113
+ settler: address(env, 'SETTLER'),
114
+ };
115
+ }
116
+ export async function startGate(game, gameConfig, overrides = {}) {
117
+ const config = resolveGateEnv(overrides.env ?? process.env);
118
+ // The same refusal the demo makes: an economy that cannot pay out is caught before anyone plays.
119
+ const economy = resolveEconomy({
120
+ maxPointsPerPlayer: game.rewardBounds(gameConfig).maxPointsPerPlayer,
121
+ walletCapWei: config.walletCapWei,
122
+ pointsPerDollar: config.pointsPerDollar,
123
+ usdPerEth: config.usdPerEth,
124
+ });
125
+ if (!economy.ok) {
126
+ throw new Error(`That economy does not work: ${economy.problem}. Try ${economy.suggestedPointsPerDollar} points per dollar.`);
127
+ }
128
+ const client = overrides.client ?? createPublicClient({ transport: http(config.rpcUrl) });
129
+ await assertSecureConfig(client, {
130
+ chainId: config.chainId,
131
+ signerPrivateKey: config.signerPrivateKey,
132
+ spendGatedCalculator: config.deployment.spendGatedCalculator,
133
+ sessionSecret: config.sessionSecret,
134
+ });
135
+ const pool = new pg.Pool({ connectionString: config.databaseUrl });
136
+ await migrate(pool);
137
+ const ledger = new Ledger(pool);
138
+ const signer = new PayloadSigner(config.signerPrivateKey, config.chainId, config.deployment.spendGatedCalculator);
139
+ const settler = config.settler ?? signer.address;
140
+ const announce = () => ({
141
+ chainId: config.chainId,
142
+ contracts: {
143
+ positionManager: config.deployment.positionManager,
144
+ spendGatedCalculator: config.deployment.spendGatedCalculator,
145
+ },
146
+ signer: signer.address,
147
+ settler,
148
+ walletCapWei: config.walletCapWei.toString(),
149
+ roundDurationMs: config.roundDurationMs,
150
+ minLobbyLeadMs: config.minLobbyLeadMs,
151
+ gateEndsAtGraceS: config.gateEndsAtGraceS,
152
+ flaunchVariant: config.deployment.flaunchVariant,
153
+ requiresEoa: false,
154
+ accepting: true,
155
+ publicLaunchesOpen: true,
156
+ privateLaunches: false,
157
+ });
158
+ const app = createGate({
159
+ pool,
160
+ game,
161
+ config: gameConfig,
162
+ pointsPerDollar: config.pointsPerDollar,
163
+ usdPerEth: config.usdPerEth,
164
+ sessions: new Sessions(config.sessionSecret, config.signInDomain, config.gateOrigin),
165
+ claims: new Claims(pool, ledger, signer),
166
+ discovery: new Discovery(client, {
167
+ positionManager: config.deployment.positionManager,
168
+ spendGatedCalculator: config.deployment.spendGatedCalculator,
169
+ signer: signer.address,
170
+ }),
171
+ settlement: new Settlement(pool, ledger, client, config.deployment.spendGatedCalculator),
172
+ allowedOrigins: config.allowedOrigins,
173
+ announce,
174
+ });
175
+ if (overrides.listen !== false) {
176
+ await app.listen({ port: config.port, host: '0.0.0.0' });
177
+ }
178
+ return { app, port: config.port, signer: signer.address, pool };
179
+ }
180
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,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