@flayerlabs/gamemode-gate 0.1.0 → 0.3.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/README.md +81 -2
- package/dist/bearer.d.ts +3 -0
- package/dist/bearer.d.ts.map +1 -0
- package/dist/bearer.js +8 -0
- package/dist/bearer.js.map +1 -0
- package/dist/demo.d.ts.map +1 -1
- package/dist/demo.js +6 -1
- package/dist/demo.js.map +1 -1
- package/dist/economy.d.ts +9 -0
- package/dist/economy.d.ts.map +1 -1
- package/dist/economy.js +2 -2
- package/dist/economy.js.map +1 -1
- package/dist/game-registry.d.ts.map +1 -1
- package/dist/game-registry.js +6 -8
- package/dist/game-registry.js.map +1 -1
- package/dist/game-server-awards.d.ts +76 -0
- package/dist/game-server-awards.d.ts.map +1 -0
- package/dist/game-server-awards.js +172 -0
- package/dist/game-server-awards.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/ledger.d.ts +0 -2
- package/dist/ledger.d.ts.map +1 -1
- package/dist/ledger.js +0 -7
- package/dist/ledger.js.map +1 -1
- package/dist/player-join-tickets.d.ts +29 -0
- package/dist/player-join-tickets.d.ts.map +1 -0
- package/dist/player-join-tickets.js +112 -0
- package/dist/player-join-tickets.js.map +1 -0
- package/dist/registry.d.ts +5 -9
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +24 -4
- package/dist/registry.js.map +1 -1
- package/dist/room.d.ts +8 -2
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +50 -9
- package/dist/room.js.map +1 -1
- package/dist/server.d.ts +16 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +162 -10
- package/dist/server.js.map +1 -1
- package/dist/sessions.d.ts +2 -0
- package/dist/sessions.d.ts.map +1 -1
- package/dist/sessions.js +4 -0
- package/dist/sessions.js.map +1 -1
- package/dist/store.d.ts +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +53 -0
- package/dist/store.js.map +1 -1
- package/package.json +2 -2
- package/src/bearer.ts +8 -0
- package/src/demo.ts +6 -1
- package/src/economy.ts +11 -2
- package/src/game-registry.ts +12 -10
- package/src/game-server-awards.ts +285 -0
- package/src/index.ts +13 -0
- package/src/ledger.ts +0 -10
- package/src/player-join-tickets.ts +151 -0
- package/src/registry.ts +34 -10
- package/src/room.ts +70 -9
- package/src/server.ts +231 -22
- package/src/sessions.ts +5 -0
- package/src/store.ts +53 -0
package/src/store.ts
CHANGED
|
@@ -10,8 +10,16 @@ import type { Pool, PoolClient } from 'pg';
|
|
|
10
10
|
export const SCHEMA = `
|
|
11
11
|
create table if not exists rounds (
|
|
12
12
|
id text primary key,
|
|
13
|
+
game_id text not null check (game_id <> ''),
|
|
13
14
|
wei_per_point numeric(78,0) not null check (wei_per_point > 0),
|
|
14
15
|
wallet_cap_wei numeric(78,0) not null check (wallet_cap_wei > 0),
|
|
16
|
+
-- The two settings that produced wei_per_point, frozen beside it. They are gate-process config,
|
|
17
|
+
-- so an operator who restarts with a new ETH price must not retroactively change what a round
|
|
18
|
+
-- was priced at.
|
|
19
|
+
points_per_dollar double precision not null check (points_per_dollar > 0),
|
|
20
|
+
usd_per_eth double precision not null check (usd_per_eth > 0),
|
|
21
|
+
max_points_per_player bigint not null check (max_points_per_player > 0),
|
|
22
|
+
score_authority text not null check (score_authority in ('rules', 'external-server')),
|
|
15
23
|
pool_id text not null,
|
|
16
24
|
opens_at bigint not null,
|
|
17
25
|
closes_at bigint not null,
|
|
@@ -29,6 +37,37 @@ create table if not exists rounds (
|
|
|
29
37
|
constraint rounds_books_tail check (books_close_at >= closes_at)
|
|
30
38
|
);
|
|
31
39
|
|
|
40
|
+
-- A developer may already have run the first published schema without creating any rounds. Add
|
|
41
|
+
-- the new authority fields in place for that empty setup. Existing round data needs a deliberate
|
|
42
|
+
-- reset because its original reward bound cannot be reconstructed safely.
|
|
43
|
+
alter table rounds
|
|
44
|
+
add column if not exists game_id text check (game_id <> '');
|
|
45
|
+
alter table rounds
|
|
46
|
+
add column if not exists max_points_per_player bigint check (max_points_per_player > 0);
|
|
47
|
+
alter table rounds
|
|
48
|
+
add column if not exists score_authority text check (score_authority in ('rules', 'external-server'));
|
|
49
|
+
alter table rounds
|
|
50
|
+
add column if not exists points_per_dollar double precision check (points_per_dollar > 0);
|
|
51
|
+
alter table rounds
|
|
52
|
+
add column if not exists usd_per_eth double precision check (usd_per_eth > 0);
|
|
53
|
+
do $$
|
|
54
|
+
begin
|
|
55
|
+
if exists (
|
|
56
|
+
select 1 from rounds
|
|
57
|
+
where game_id is null or max_points_per_player is null or score_authority is null
|
|
58
|
+
or points_per_dollar is null or usd_per_eth is null
|
|
59
|
+
) then
|
|
60
|
+
raise exception 'pre-release round rows cannot be upgraded safely'
|
|
61
|
+
using hint = 'Delete the pre-release round data, then run migrate(pool) again.';
|
|
62
|
+
end if;
|
|
63
|
+
end
|
|
64
|
+
$$;
|
|
65
|
+
alter table rounds alter column game_id set not null;
|
|
66
|
+
alter table rounds alter column max_points_per_player set not null;
|
|
67
|
+
alter table rounds alter column score_authority set not null;
|
|
68
|
+
alter table rounds alter column points_per_dollar set not null;
|
|
69
|
+
alter table rounds alter column usd_per_eth set not null;
|
|
70
|
+
|
|
32
71
|
create table if not exists balances (
|
|
33
72
|
round_id text not null references rounds(id) on delete cascade,
|
|
34
73
|
player text not null,
|
|
@@ -61,6 +100,18 @@ create table if not exists claims (
|
|
|
61
100
|
|
|
62
101
|
create index if not exists claims_by_player on claims (round_id, player) where status = 'held';
|
|
63
102
|
|
|
103
|
+
-- Trusted creator servers use one stable event id for every score increment. The event and the
|
|
104
|
+
-- balance update commit together, so a retry can recover the first result without paying twice.
|
|
105
|
+
create table if not exists award_events (
|
|
106
|
+
round_id text not null references rounds(id) on delete cascade,
|
|
107
|
+
event_id varchar(128) not null check (event_id <> ''),
|
|
108
|
+
player text not null,
|
|
109
|
+
points bigint not null check (points > 0),
|
|
110
|
+
total_points bigint not null check (total_points >= points),
|
|
111
|
+
created_at timestamptz not null default now(),
|
|
112
|
+
primary key (round_id, event_id)
|
|
113
|
+
);
|
|
114
|
+
|
|
64
115
|
-- Which game a coin plays. Addresses are chain-local, so the pin is one row per (chain, coin).
|
|
65
116
|
create table if not exists registrations (
|
|
66
117
|
chain_id bigint not null check (chain_id > 0),
|
|
@@ -68,8 +119,10 @@ create table if not exists registrations (
|
|
|
68
119
|
game_id text not null check (game_id <> ''),
|
|
69
120
|
gate_origin text not null check (gate_origin <> ''),
|
|
70
121
|
deploy_id text not null check (deploy_id <> ''),
|
|
122
|
+
game_server_origins text[] not null default '{}'::text[],
|
|
71
123
|
disabled_at timestamptz,
|
|
72
124
|
updated_at timestamptz not null default now(),
|
|
125
|
+
constraint registrations_game_server_origins_bounded check (cardinality(game_server_origins) <= 4),
|
|
73
126
|
primary key (chain_id, coin)
|
|
74
127
|
);
|
|
75
128
|
|