|
2 | 2 | * Subscription Example - Buyer (Client) |
3 | 3 | * |
4 | 4 | * Run a specific scenario via --scenario flag: |
5 | | - * npx ts-node buyer.ts --scenario 1 # First-time subscription |
6 | | - * npx ts-node buyer.ts --scenario 2 # Subsequent job (reuse active subscription) |
7 | | - * npx ts-node buyer.ts --scenario 3 # Non-subscription offering (fixed-price) |
| 5 | + * npx ts-node buyer.ts --scenario 1 # Subscription offering |
| 6 | + * npx ts-node buyer.ts --scenario 2 # Non-subscription offering (fixed-price) |
8 | 7 | * |
9 | 8 | * Default: scenario 1 |
10 | 9 | * |
11 | 10 | * Scenarios: |
12 | | - * 1. First-Time Subscription |
13 | | - * - No prior subscription exists |
| 11 | + * 1. Subscription Offering |
14 | 12 | * - Seller creates PAYABLE_REQUEST_SUBSCRIPTION memo |
15 | 13 | * - Buyer pays subscription; job proceeds to delivery |
16 | 14 | * |
17 | | - * 2. Subsequent Job with Active Subscription |
18 | | - * - Valid subscription already exists (run Scenario 1 first) |
19 | | - * - initiateJob reuses the existing account |
20 | | - * - Seller accepts and creates requirement directly; buyer accepts without payment |
21 | | - * |
22 | | - * 3. Non-Subscription Offering (Fixed-Price) |
23 | | - * - Uses a non-subscription offering (jobOfferings[0]) |
| 15 | + * 2. Non-Subscription Offering (Fixed-Price) |
| 16 | + * - Uses a non-subscription offering (jobOfferings[1]) |
24 | 17 | * - Seller accepts and creates a payable requirement |
25 | 18 | * - Buyer pays and advances to delivery |
26 | 19 | */ |
@@ -134,44 +127,30 @@ async function buyer() { |
134 | 127 |
|
135 | 128 | switch (SCENARIO) { |
136 | 129 | case 1: { |
137 | | - console.log("--- Scenario 1: First-Time Subscription ---\n"); |
| 130 | + console.log("--- Scenario 1: Subscription Offering ---\n"); |
138 | 131 | const jobId1 = await subscriptionOffering.initiateJob( |
139 | 132 | {}, |
140 | 133 | undefined, |
141 | 134 | new Date(Date.now() + 1000 * 60 * 15), // 15 min job expiry |
142 | 135 | SUBSCRIPTION_TIER, |
143 | 136 | ); |
144 | | - console.log(`\nBuyer: [Scenario 1 — First-Time Subscription] Job ${jobId1} initiated`); |
| 137 | + console.log(`\nBuyer: [Scenario 1 — Subscription Offering] Job ${jobId1} initiated`); |
145 | 138 | break; |
146 | 139 | } |
147 | 140 |
|
148 | 141 | case 2: { |
149 | | - // Requires Scenario 1 to have been run first (valid subscription must exist) |
150 | | - console.log("--- Scenario 2: Subsequent Job with Active Subscription ---\n"); |
151 | | - console.log("(Ensure Scenario 1 has been run first so a valid subscription exists)\n"); |
152 | | - const jobId2 = await subscriptionOffering.initiateJob( |
153 | | - {}, |
154 | | - undefined, |
155 | | - new Date(Date.now() + 1000 * 60 * 15), // 15 min job expiry |
156 | | - SUBSCRIPTION_TIER, |
157 | | - ); |
158 | | - console.log(`\nBuyer: [Scenario 2 — Reusing Active Subscription] Job ${jobId2} initiated`); |
159 | | - break; |
160 | | - } |
161 | | - |
162 | | - case 3: { |
163 | | - console.log("--- Scenario 3: Non-Subscription Offering (Fixed-Price) ---\n"); |
164 | | - const jobId3 = await fixedOffering.initiateJob( |
| 142 | + console.log("--- Scenario 2: Non-Subscription Offering (Fixed-Price) ---\n"); |
| 143 | + const jobId2 = await fixedOffering.initiateJob( |
165 | 144 | {}, |
166 | 145 | undefined, |
167 | 146 | new Date(Date.now() + 1000 * 60 * 15), // 15 min job expiry |
168 | 147 | ); |
169 | | - console.log(`\nBuyer: [Scenario 3 — Fixed-Price Job] Job ${jobId3} initiated`); |
| 148 | + console.log(`\nBuyer: [Scenario 2 — Fixed-Price Job] Job ${jobId2} initiated`); |
170 | 149 | break; |
171 | 150 | } |
172 | 151 |
|
173 | 152 | default: |
174 | | - console.error(`Unknown scenario: ${SCENARIO}. Use --scenario 1, 2, or 3.`); |
| 153 | + console.error(`Unknown scenario: ${SCENARIO}. Use --scenario 1 or 2.`); |
175 | 154 | process.exit(1); |
176 | 155 | } |
177 | 156 | } |
|
0 commit comments