hive-stream 3.0.5 → 3.1.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.
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validateProjectName = validateProjectName;
7
+ exports.generateProjectFiles = generateProjectFiles;
8
+ exports.writeProjectFiles = writeProjectFiles;
9
+ exports.isDirectoryUsable = isDirectoryUsable;
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const templates_1 = require("./templates");
13
+ const NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
14
+ function validateProjectName(name) {
15
+ if (!name) {
16
+ return 'Project name is required.';
17
+ }
18
+ if (name.length > 214) {
19
+ return 'Project name must be 214 characters or fewer.';
20
+ }
21
+ if (!NAME_PATTERN.test(name)) {
22
+ return 'Project name must be lowercase and may only contain letters, numbers, dots, hyphens, and underscores.';
23
+ }
24
+ return null;
25
+ }
26
+ function indent(lines, spaces) {
27
+ const pad = ' '.repeat(spaces);
28
+ return lines
29
+ .map((line) => (line.length > 0 ? `${pad}${line}` : line))
30
+ .join('\n');
31
+ }
32
+ function generatePackageJson(options) {
33
+ const pkg = {
34
+ name: options.name,
35
+ version: '0.1.0',
36
+ description: `A Hive blockchain app built with hive-stream.`,
37
+ main: 'dist/index.js',
38
+ scripts: {
39
+ dev: 'ts-node src/index.ts',
40
+ build: 'tsc',
41
+ start: 'node dist/index.js'
42
+ },
43
+ dependencies: {
44
+ 'hive-stream': `^${options.hiveStreamVersion}`,
45
+ zod: '^3.25.76'
46
+ },
47
+ devDependencies: {
48
+ '@types/node': '^24.1.0',
49
+ 'ts-node': '^10.9.2',
50
+ typescript: '^5.9.2'
51
+ }
52
+ };
53
+ return `${JSON.stringify(pkg, null, 4)}\n`;
54
+ }
55
+ function generateTsconfig() {
56
+ const tsconfig = {
57
+ compilerOptions: {
58
+ target: 'es2022',
59
+ module: 'commonjs',
60
+ moduleResolution: 'node',
61
+ outDir: 'dist',
62
+ rootDir: 'src',
63
+ strict: true,
64
+ esModuleInterop: true,
65
+ skipLibCheck: true,
66
+ forceConsistentCasingInFileNames: true,
67
+ resolveJsonModule: true
68
+ },
69
+ include: ['src']
70
+ };
71
+ return `${JSON.stringify(tsconfig, null, 4)}\n`;
72
+ }
73
+ function generateGitignore() {
74
+ return [
75
+ 'node_modules/',
76
+ 'dist/',
77
+ '.env',
78
+ '*.db',
79
+ '*.log',
80
+ ''
81
+ ].join('\n');
82
+ }
83
+ function generateEnvExample(options, adapter) {
84
+ const lines = [
85
+ '# Your Hive account name (without the @)',
86
+ `HIVE_USERNAME=${options.username}`,
87
+ '',
88
+ '# Private posting key: used for posts, comments, votes, and custom_json',
89
+ 'HIVE_POSTING_KEY=',
90
+ '',
91
+ '# Private active key: required for transfers and other financial operations',
92
+ 'HIVE_ACTIVE_KEY='
93
+ ];
94
+ if (adapter.envLines.length > 0) {
95
+ lines.push('');
96
+ lines.push(...adapter.envLines.map((line) => line.replace(/APP_NAME_PLACEHOLDER/g, envSafeName(options.name))));
97
+ }
98
+ lines.push('');
99
+ if (options.api) {
100
+ lines.push('# Built-in HTTP API server');
101
+ lines.push('API_ENABLED=true');
102
+ lines.push('API_PORT=5001');
103
+ }
104
+ else {
105
+ lines.push('# Uncomment to enable the built-in HTTP API server');
106
+ lines.push('# API_ENABLED=true');
107
+ lines.push('# API_PORT=5001');
108
+ }
109
+ lines.push('');
110
+ return lines.join('\n');
111
+ }
112
+ function envSafeName(name) {
113
+ return name.replace(/[^a-z0-9_-]/g, '-');
114
+ }
115
+ function generateIndex(options, template, adapter) {
116
+ const namedImports = ['Streamer', 'loadEnv', adapter.importName, ...template.imports]
117
+ .sort((a, b) => a.localeCompare(b));
118
+ const sections = [];
119
+ sections.push(`import { ${namedImports.join(', ')} } from 'hive-stream';`);
120
+ sections.push('');
121
+ sections.push(`import { GreetingContract } from './contracts/greeting.contract';`);
122
+ sections.push('');
123
+ sections.push(`loadEnv();`);
124
+ sections.push('');
125
+ sections.push(`const HIVE_USERNAME = process.env.HIVE_USERNAME ?? '${options.username}';`);
126
+ sections.push('');
127
+ sections.push(`async function main() {`);
128
+ sections.push(` // env: true reads HIVE_USERNAME, HIVE_POSTING_KEY, HIVE_ACTIVE_KEY,`);
129
+ sections.push(` // API_ENABLED, and other settings from .env`);
130
+ sections.push(` const streamer = new Streamer({ env: true });`);
131
+ sections.push('');
132
+ sections.push(` await streamer.registerAdapter(${adapter.construct.replace(/APP_NAME_PLACEHOLDER/g, envSafeName(options.name))});`);
133
+ sections.push('');
134
+ sections.push(` await streamer.registerContract(GreetingContract);`);
135
+ if (template.registrations.length > 0) {
136
+ sections.push(indent(template.registrations, 4));
137
+ }
138
+ if (template.setup.length > 0) {
139
+ sections.push('');
140
+ sections.push(indent(template.setup, 4));
141
+ }
142
+ sections.push('');
143
+ sections.push(` await streamer.start();`);
144
+ sections.push('');
145
+ sections.push(` console.log('${options.name} is streaming the Hive blockchain. Press Ctrl+C to stop.');`);
146
+ sections.push('');
147
+ sections.push(` process.on('SIGINT', () => {`);
148
+ sections.push(` void streamer.stop().then(() => {`);
149
+ sections.push(` process.exit(0);`);
150
+ sections.push(` });`);
151
+ sections.push(` });`);
152
+ sections.push(`}`);
153
+ sections.push('');
154
+ sections.push(`main().catch((error) => {`);
155
+ sections.push(` console.error(error);`);
156
+ sections.push(` process.exit(1);`);
157
+ sections.push(`});`);
158
+ sections.push('');
159
+ return sections.join('\n');
160
+ }
161
+ function generateGreetingContract() {
162
+ return `import { action, defineContract } from 'hive-stream';
163
+ import { z } from 'zod';
164
+
165
+ const greetSchema = z.object({
166
+ name: z.string().min(1).max(80)
167
+ });
168
+
169
+ // A minimal custom contract. Users call it by broadcasting a custom_json
170
+ // operation with id 'hivestream' and this JSON:
171
+ // {"hive_stream":{"contract":"greeting","action":"greet","payload":{"name":"Hive"}}}
172
+ export const GreetingContract = defineContract({
173
+ name: 'greeting',
174
+ actions: {
175
+ greet: action(async (payload, ctx) => {
176
+ const data = greetSchema.parse(payload);
177
+
178
+ console.log(\`Hello, \${data.name}! Greeted by @\${ctx.sender} in block \${ctx.block.number}.\`);
179
+ }, {
180
+ trigger: 'custom_json'
181
+ })
182
+ }
183
+ });
184
+ `;
185
+ }
186
+ function generateReadme(options, template, adapter) {
187
+ const lines = [];
188
+ lines.push(`# ${options.name}`);
189
+ lines.push('');
190
+ lines.push(`A Hive blockchain app built with [hive-stream](https://github.com/Vheissu/hive-stream), using the **${template.label}** template and **${adapter.label}** for persistence.`);
191
+ lines.push('');
192
+ lines.push('## Getting started');
193
+ lines.push('');
194
+ lines.push('```bash');
195
+ lines.push('npm install');
196
+ lines.push('cp .env.example .env # then fill in your Hive account and keys');
197
+ lines.push('npm run dev');
198
+ lines.push('```');
199
+ lines.push('');
200
+ lines.push('Your app streams blocks from the Hive blockchain and reacts to operations addressed to it. Contract actions are invoked by transfers (with a JSON memo) or custom_json operations using the `hivestream` id and the `hive_stream` payload wrapper.');
201
+ lines.push('');
202
+ if (template.usage.length > 0) {
203
+ lines.push('## Try it');
204
+ lines.push('');
205
+ for (const example of template.usage) {
206
+ lines.push(`### ${example.title}`);
207
+ lines.push('');
208
+ lines.push(example.description);
209
+ lines.push('');
210
+ lines.push('```json');
211
+ lines.push(example.payload);
212
+ lines.push('```');
213
+ lines.push('');
214
+ }
215
+ }
216
+ lines.push('## Custom contracts');
217
+ lines.push('');
218
+ lines.push('A starter contract lives in `src/contracts/greeting.contract.ts`. Define actions with `defineContract` and `action`, validate payloads with zod, and register the contract in `src/index.ts`. Actions can be triggered by `custom_json`, `transfer`, `time`, escrow, and recurrent transfer operations.');
219
+ lines.push('');
220
+ if (options.api) {
221
+ lines.push('## HTTP API');
222
+ lines.push('');
223
+ lines.push('The built-in API server is enabled in `.env` and serves contract state and events at `http://localhost:5001`.');
224
+ lines.push('');
225
+ }
226
+ lines.push('## Learn more');
227
+ lines.push('');
228
+ lines.push('- [hive-stream documentation](https://github.com/Vheissu/hive-stream/blob/master/DOCUMENTATION.md)');
229
+ lines.push('- [Hive developer portal](https://developers.hive.io)');
230
+ lines.push('');
231
+ return lines.join('\n');
232
+ }
233
+ function generateProjectFiles(options) {
234
+ const template = (0, templates_1.getTemplate)(options.template);
235
+ if (!template) {
236
+ throw new Error(`Unknown template '${options.template}'.`);
237
+ }
238
+ const adapter = (0, templates_1.getAdapter)(options.adapter);
239
+ if (!adapter) {
240
+ throw new Error(`Unknown adapter '${options.adapter}'.`);
241
+ }
242
+ const nameError = validateProjectName(options.name);
243
+ if (nameError) {
244
+ throw new Error(nameError);
245
+ }
246
+ const files = {
247
+ 'package.json': generatePackageJson(options),
248
+ 'tsconfig.json': generateTsconfig(),
249
+ '.gitignore': generateGitignore(),
250
+ '.env.example': generateEnvExample(options, adapter),
251
+ 'README.md': generateReadme(options, template, adapter),
252
+ 'src/index.ts': generateIndex(options, template, adapter),
253
+ 'src/contracts/greeting.contract.ts': generateGreetingContract()
254
+ };
255
+ return { files, template, adapter };
256
+ }
257
+ function writeProjectFiles(targetDir, files) {
258
+ const written = [];
259
+ for (const [relativePath, contents] of Object.entries(files)) {
260
+ const fullPath = path_1.default.join(targetDir, relativePath);
261
+ fs_1.default.mkdirSync(path_1.default.dirname(fullPath), { recursive: true });
262
+ fs_1.default.writeFileSync(fullPath, contents, 'utf8');
263
+ written.push(relativePath);
264
+ }
265
+ return written;
266
+ }
267
+ function isDirectoryUsable(targetDir) {
268
+ if (!fs_1.default.existsSync(targetDir)) {
269
+ return { usable: true };
270
+ }
271
+ const stats = fs_1.default.statSync(targetDir);
272
+ if (!stats.isDirectory()) {
273
+ return { usable: false, reason: 'A file with that name already exists.' };
274
+ }
275
+ const entries = fs_1.default.readdirSync(targetDir).filter((entry) => entry !== '.git');
276
+ if (entries.length > 0) {
277
+ return { usable: false, reason: 'Directory already exists and is not empty.' };
278
+ }
279
+ return { usable: true };
280
+ }
281
+ //# sourceMappingURL=scaffold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/cli/scaffold.ts"],"names":[],"mappings":";;;;;AAsBA,kDAcC;AA8OD,oDA8BC;AAED,8CAYC;AAED,8CAkBC;AAlVD,4CAAoB;AACpB,gDAAwB;AAExB,2CAA6F;AAiB7F,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAE9C,SAAgB,mBAAmB,CAAC,IAAY;IAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,2BAA2B,CAAC;IACvC,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QACpB,OAAO,+CAA+C,CAAC;IAC3D,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,OAAO,uGAAuG,CAAC;IACnH,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAS,MAAM,CAAC,KAAe,EAAE,MAAc;IAC3C,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/B,OAAO,KAAK;SACP,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SACzD,IAAI,CAAC,IAAI,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAwB;IACjD,MAAM,GAAG,GAAG;QACR,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,+CAA+C;QAC5D,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE;YACL,GAAG,EAAE,sBAAsB;YAC3B,KAAK,EAAE,KAAK;YACZ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AC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,SAAgB,iBAAiB,CAAC,SAAiB;IAC/C,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED,MAAM,KAAK,GAAG,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAErC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;QACvB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,uCAAuC,EAAE,CAAC;IAC9E,CAAC;IAED,MAAM,OAAO,GAAG,YAAE,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;IAE9E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,4CAA4C,EAAE,CAAC;IACnF,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,28 @@
1
+ export type TemplateId = 'minimal' | 'game' | 'exchange' | 'social' | 'blog' | 'token' | 'assets';
2
+ export type AdapterId = 'sqlite' | 'mongodb' | 'postgresql';
3
+ export interface UsageExample {
4
+ title: string;
5
+ description: string;
6
+ payload: string;
7
+ }
8
+ export interface TemplateDefinition {
9
+ id: TemplateId;
10
+ label: string;
11
+ description: string;
12
+ imports: string[];
13
+ registrations: string[];
14
+ setup: string[];
15
+ usage: UsageExample[];
16
+ }
17
+ export interface AdapterDefinition {
18
+ id: AdapterId;
19
+ label: string;
20
+ description: string;
21
+ importName: string;
22
+ construct: string;
23
+ envLines: string[];
24
+ }
25
+ export declare const TEMPLATES: TemplateDefinition[];
26
+ export declare const ADAPTERS: AdapterDefinition[];
27
+ export declare function getTemplate(id: string): TemplateDefinition | undefined;
28
+ export declare function getAdapter(id: string): AdapterDefinition | undefined;
@@ -0,0 +1,329 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ADAPTERS = exports.TEMPLATES = void 0;
4
+ exports.getTemplate = getTemplate;
5
+ exports.getAdapter = getAdapter;
6
+ const wrap = (contract, actionName, payload) => {
7
+ return `{"hive_stream":{"contract":"${contract}","action":"${actionName}","payload":${payload}}}`;
8
+ };
9
+ exports.TEMPLATES = [
10
+ {
11
+ id: 'minimal',
12
+ label: 'Minimal',
13
+ description: 'A bare streamer with subscriptions and a custom contract to build on.',
14
+ imports: [],
15
+ registrations: [],
16
+ setup: [
17
+ `streamer.onTransfer(HIVE_USERNAME, (op, blockNumber) => {`,
18
+ ` console.log(\`Received \${op.amount} from @\${op.from} in block \${blockNumber}\`);`,
19
+ `});`,
20
+ ``,
21
+ `streamer.onPost((op, blockNumber) => {`,
22
+ ` console.log(\`New post by @\${op.author} in block \${blockNumber}\`);`,
23
+ `});`
24
+ ],
25
+ usage: [
26
+ {
27
+ title: 'Call the greeting contract',
28
+ description: 'Broadcast a custom_json operation with id `hivestream`:',
29
+ payload: wrap('greeting', 'greet', '{"name":"Hive"}')
30
+ }
31
+ ]
32
+ },
33
+ {
34
+ id: 'game',
35
+ label: 'Game',
36
+ description: 'Provably-fair games of chance: dice, coinflip, roulette, and rock-paper-scissors.',
37
+ imports: [
38
+ 'createCoinflipContract',
39
+ 'createDiceContract',
40
+ 'createRouletteContract',
41
+ 'createRpsContract'
42
+ ],
43
+ registrations: [
44
+ `await streamer.registerContract(createDiceContract({ account: HIVE_USERNAME }));`,
45
+ `await streamer.registerContract(createCoinflipContract({ account: HIVE_USERNAME }));`,
46
+ `await streamer.registerContract(createRouletteContract({ account: HIVE_USERNAME }));`,
47
+ `await streamer.registerContract(createRpsContract({ account: HIVE_USERNAME }));`
48
+ ],
49
+ setup: [],
50
+ usage: [
51
+ {
52
+ title: 'Roll the dice',
53
+ description: 'Send HIVE to your app account with this transfer memo:',
54
+ payload: wrap('dice', 'roll', '{"roll":50}')
55
+ },
56
+ {
57
+ title: 'Flip a coin',
58
+ description: 'Send HIVE with this transfer memo:',
59
+ payload: wrap('coinflip', 'flip', '{"guess":"heads"}')
60
+ },
61
+ {
62
+ title: 'Spin the roulette wheel',
63
+ description: 'Send HIVE with this transfer memo:',
64
+ payload: wrap('roulette', 'spin', '{"betType":"color","value":"red"}')
65
+ },
66
+ {
67
+ title: 'Play rock-paper-scissors',
68
+ description: 'Send HIVE with this transfer memo:',
69
+ payload: wrap('rps', 'play', '{"move":"rock"}')
70
+ }
71
+ ]
72
+ },
73
+ {
74
+ id: 'exchange',
75
+ label: 'Exchange',
76
+ description: 'An on-chain order book exchange with deposits, orders, and a matching engine.',
77
+ imports: ['createExchangeContract', 'TimeAction'],
78
+ registrations: [
79
+ `await streamer.registerContract(createExchangeContract({`,
80
+ ` account: HIVE_USERNAME,`,
81
+ ` feeAccount: HIVE_USERNAME,`,
82
+ ` makerFeeBps: 10,`,
83
+ ` takerFeeBps: 20`,
84
+ `}));`
85
+ ],
86
+ setup: [
87
+ `// Run the order matcher every 30 seconds and snapshot the order book`,
88
+ `await streamer.registerAction(new TimeAction('30s', 'exchange-matcher', 'exchange', 'matchOrders', { limit: 50, snapshot: true, depth: 20 }));`
89
+ ],
90
+ usage: [
91
+ {
92
+ title: 'Create a trading pair',
93
+ description: 'Broadcast a custom_json operation with id `hivestream`:',
94
+ payload: wrap('exchange', 'createPair', '{"base":"HIVE","quote":"HBD"}')
95
+ },
96
+ {
97
+ title: 'Deposit funds',
98
+ description: 'Send HIVE or HBD to your app account with this transfer memo:',
99
+ payload: wrap('exchange', 'deposit', '{}')
100
+ },
101
+ {
102
+ title: 'Place an order',
103
+ description: 'Broadcast a custom_json operation with id `hivestream`:',
104
+ payload: wrap('exchange', 'placeOrder', '{"side":"buy","base":"HIVE","quote":"HBD","price":"2","amount":"5"}')
105
+ }
106
+ ]
107
+ },
108
+ {
109
+ id: 'social',
110
+ label: 'Social',
111
+ description: 'A social platform backend: fan clubs, subscriptions, tips, and post streaming.',
112
+ imports: [
113
+ 'createFanClubContract',
114
+ 'createSubscriptionContract',
115
+ 'createTipJarContract'
116
+ ],
117
+ registrations: [
118
+ `await streamer.registerContract(createFanClubContract());`,
119
+ `await streamer.registerContract(createSubscriptionContract());`,
120
+ `await streamer.registerContract(createTipJarContract());`
121
+ ],
122
+ setup: [
123
+ `streamer.onPost((op, blockNumber) => {`,
124
+ ` console.log(\`New post by @\${op.author}: \${op.permlink} (block \${blockNumber})\`);`,
125
+ `});`,
126
+ ``,
127
+ `streamer.onComment((op, blockNumber) => {`,
128
+ ` console.log(\`New comment by @\${op.author} on @\${op.parent_author}/\${op.parent_permlink} (block \${blockNumber})\`);`,
129
+ `});`
130
+ ],
131
+ usage: [
132
+ {
133
+ title: 'Create a fan club',
134
+ description: 'Broadcast a custom_json operation with id `hivestream`:',
135
+ payload: wrap('fanclub', 'createClub', '{"clubId":"my-club","title":"My Club","joinPrice":"1.000","asset":"HIVE"}')
136
+ },
137
+ {
138
+ title: 'Join a fan club',
139
+ description: 'Send the join price to your app account with this transfer memo:',
140
+ payload: wrap('fanclub', 'joinClub', '{"clubId":"my-club"}')
141
+ },
142
+ {
143
+ title: 'Create a subscription plan',
144
+ description: 'Broadcast a custom_json operation with id `hivestream`:',
145
+ payload: wrap('subscription', 'createPlan', '{"planId":"monthly","title":"Monthly Supporter","price":"5.000","asset":"HIVE","intervalDays":30}')
146
+ },
147
+ {
148
+ title: 'Leave a tip',
149
+ description: 'Send any amount to your app account with this transfer memo:',
150
+ payload: wrap('tipjar', 'tip', '{"message":"Great work!"}')
151
+ }
152
+ ]
153
+ },
154
+ {
155
+ id: 'blog',
156
+ label: 'Blog',
157
+ description: 'A blogging backend: paywalled content, tips, and post/comment streaming.',
158
+ imports: ['createPaywallContract', 'createTipJarContract'],
159
+ registrations: [
160
+ `await streamer.registerContract(createPaywallContract());`,
161
+ `await streamer.registerContract(createTipJarContract());`
162
+ ],
163
+ setup: [
164
+ `streamer.onPost((op, blockNumber) => {`,
165
+ ` console.log(\`New post by @\${op.author}: \${op.permlink} (block \${blockNumber})\`);`,
166
+ `});`,
167
+ ``,
168
+ `streamer.onComment((op, blockNumber) => {`,
169
+ ` console.log(\`New comment by @\${op.author} on @\${op.parent_author}/\${op.parent_permlink} (block \${blockNumber})\`);`,
170
+ `});`
171
+ ],
172
+ usage: [
173
+ {
174
+ title: 'Create a paywalled resource',
175
+ description: 'Broadcast a custom_json operation with id `hivestream`:',
176
+ payload: wrap('paywall', 'createResource', '{"resourceId":"premium-post","title":"Premium Post","price":"1.000","asset":"HBD","accessDays":30}')
177
+ },
178
+ {
179
+ title: 'Buy access',
180
+ description: 'Send the price to your app account with this transfer memo:',
181
+ payload: wrap('paywall', 'grantAccess', '{"resourceId":"premium-post"}')
182
+ },
183
+ {
184
+ title: 'Leave a tip',
185
+ description: 'Send any amount to your app account with this transfer memo:',
186
+ payload: wrap('tipjar', 'tip', '{"message":"Loved this post!"}')
187
+ }
188
+ ]
189
+ },
190
+ {
191
+ id: 'token',
192
+ label: 'Token & NFT',
193
+ description: 'Custom tokens and NFT collections with minting, transfers, and a marketplace.',
194
+ imports: ['createNFTContract', 'createTokenContract'],
195
+ registrations: [
196
+ `await streamer.registerContract(createTokenContract());`,
197
+ `await streamer.registerContract(createNFTContract({ name: 'nft' }));`
198
+ ],
199
+ setup: [],
200
+ usage: [
201
+ {
202
+ title: 'Create a token',
203
+ description: 'Broadcast a custom_json operation with id `hivestream`:',
204
+ payload: wrap('token', 'createToken', '{"symbol":"MYTOKEN","name":"My Token","maxSupply":"1000000","precision":3}')
205
+ },
206
+ {
207
+ title: 'Issue tokens',
208
+ description: 'Broadcast a custom_json operation with id `hivestream` (token creator only):',
209
+ payload: wrap('token', 'issueTokens', '{"symbol":"MYTOKEN","to":"some-account","amount":"100"}')
210
+ },
211
+ {
212
+ title: 'Create an NFT collection',
213
+ description: 'Broadcast a custom_json operation with id `hivestream`:',
214
+ payload: wrap('nft', 'createCollection', '{"symbol":"MYNFT","name":"My Collection"}')
215
+ }
216
+ ]
217
+ },
218
+ {
219
+ id: 'assets',
220
+ label: 'Assets & Tickets',
221
+ description: 'Non-custodial NFTs and event tickets: batch minting, direct peer-to-peer sales, and on-chain state checkpoints.',
222
+ imports: [
223
+ 'createCheckpointContract',
224
+ 'createNFTContract',
225
+ 'createTicketingContract',
226
+ 'TimeAction'
227
+ ],
228
+ registrations: [
229
+ `await streamer.registerContract(createNFTContract({ name: 'nft' }));`,
230
+ `await streamer.registerContract(createTicketingContract());`,
231
+ `await streamer.registerContract(createCheckpointContract({`,
232
+ ` account: HIVE_USERNAME,`,
233
+ ` tables: ['nft_collections', 'nft_tokens', 'nft_listings', 'ticket_events', 'tickets', 'ticket_listings']`,
234
+ `}));`
235
+ ],
236
+ setup: [
237
+ `// Publish a verifiable state hash on-chain every hour so anyone running`,
238
+ `// this open-source app can confirm they derive the same state`,
239
+ `await streamer.registerAction(new TimeAction('1h', 'state-checkpoint', 'checkpoint', 'publishCheckpoint', {}));`
240
+ ],
241
+ usage: [
242
+ {
243
+ title: 'Create an NFT collection',
244
+ description: 'Broadcast a custom_json operation with id `hivestream`:',
245
+ payload: wrap('nft', 'createCollection', '{"symbol":"TICKETS","name":"Event Tickets","maxSupply":1000}')
246
+ },
247
+ {
248
+ title: 'Batch mint numbered editions',
249
+ description: 'Broadcast a custom_json operation with id `hivestream` (collection creator only):',
250
+ payload: wrap('nft', 'mintBatchNFT', '{"collectionSymbol":"TICKETS","to":"some-account","editions":{"baseTokenId":"GA","count":100}}')
251
+ },
252
+ {
253
+ title: 'List an NFT for sale',
254
+ description: 'Broadcast a custom_json operation with id `hivestream` (token owner only):',
255
+ payload: wrap('nft', 'listNFT', '{"collectionSymbol":"TICKETS","tokenId":"GA-1","price":"5.000","currency":"HIVE"}')
256
+ },
257
+ {
258
+ title: 'Buy an NFT non-custodially',
259
+ description: 'Send the exact price directly to the seller with this transfer memo (funds never touch the app account):',
260
+ payload: wrap('nft', 'buyNFTDirect', '{"collectionSymbol":"TICKETS","tokenId":"GA-1"}')
261
+ },
262
+ {
263
+ title: 'Create a ticketed event',
264
+ description: 'Broadcast a custom_json operation with id `hivestream`:',
265
+ payload: wrap('ticketing', 'createEvent', '{"eventId":"launch-party","title":"Launch Party","venue":"Online","startsAt":"2026-12-01T18:00:00Z","ticketPrice":"2.000","asset":"HBD","capacity":500}')
266
+ },
267
+ {
268
+ title: 'Buy a ticket',
269
+ description: 'Send the ticket price to your app account with this transfer memo:',
270
+ payload: wrap('ticketing', 'purchaseTicket', '{"eventId":"launch-party","ticketId":"launch-party:1"}')
271
+ },
272
+ {
273
+ title: 'Transfer a ticket',
274
+ description: 'Broadcast a custom_json operation with id `hivestream` (ticket owner only):',
275
+ payload: wrap('ticketing', 'transferTicket', '{"ticketId":"launch-party:1","to":"friend-account"}')
276
+ },
277
+ {
278
+ title: 'List a ticket for resale',
279
+ description: 'Broadcast a custom_json operation with id `hivestream` (ticket owner only):',
280
+ payload: wrap('ticketing', 'listTicket', '{"ticketId":"launch-party:1","price":"3.000"}')
281
+ },
282
+ {
283
+ title: 'Buy a resale ticket non-custodially',
284
+ description: 'Send the resale price directly to the seller with this transfer memo (funds never touch the app account):',
285
+ payload: wrap('ticketing', 'buyTicketDirect', '{"ticketId":"launch-party:1"}')
286
+ }
287
+ ]
288
+ }
289
+ ];
290
+ exports.ADAPTERS = [
291
+ {
292
+ id: 'sqlite',
293
+ label: 'SQLite',
294
+ description: 'Zero-config local database. Great for development and single-node apps.',
295
+ importName: 'SqliteAdapter',
296
+ construct: `new SqliteAdapter()`,
297
+ envLines: []
298
+ },
299
+ {
300
+ id: 'mongodb',
301
+ label: 'MongoDB',
302
+ description: 'Document database for apps that need external or shared persistence.',
303
+ importName: 'MongodbAdapter',
304
+ construct: `new MongodbAdapter(process.env.MONGODB_URI ?? 'mongodb://localhost:27017', process.env.MONGODB_DATABASE ?? 'APP_NAME_PLACEHOLDER')`,
305
+ envLines: [
306
+ '# MongoDB connection',
307
+ 'MONGODB_URI=mongodb://localhost:27017',
308
+ 'MONGODB_DATABASE=APP_NAME_PLACEHOLDER'
309
+ ]
310
+ },
311
+ {
312
+ id: 'postgresql',
313
+ label: 'PostgreSQL',
314
+ description: 'SQL database with support for SQL-backed contract state.',
315
+ importName: 'PostgreSQLAdapter',
316
+ construct: `new PostgreSQLAdapter({ connectionString: process.env.DATABASE_URL ?? 'postgres://localhost:5432/APP_NAME_PLACEHOLDER' })`,
317
+ envLines: [
318
+ '# PostgreSQL connection',
319
+ 'DATABASE_URL=postgres://localhost:5432/APP_NAME_PLACEHOLDER'
320
+ ]
321
+ }
322
+ ];
323
+ function getTemplate(id) {
324
+ return exports.TEMPLATES.find((template) => template.id === id);
325
+ }
326
+ function getAdapter(id) {
327
+ return exports.ADAPTERS.find((adapter) => adapter.id === id);
328
+ }
329
+ //# sourceMappingURL=templates.js.map