@hsuite/smart-engines-cli 1.9.0 → 2.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.
- package/README.md +4 -2
- package/dist/_lib/cluster-convergence.d.ts.map +1 -1
- package/dist/_lib/cluster-convergence.js +1 -1
- package/dist/_lib/cluster-convergence.js.map +1 -1
- package/dist/_lib/deposit-verification.d.ts +91 -0
- package/dist/_lib/deposit-verification.d.ts.map +1 -0
- package/dist/_lib/deposit-verification.js +265 -0
- package/dist/_lib/deposit-verification.js.map +1 -0
- package/dist/_lib/env.d.ts.map +1 -1
- package/dist/_lib/env.js +9 -7
- package/dist/_lib/env.js.map +1 -1
- package/dist/_lib/error-message.d.ts +7 -0
- package/dist/_lib/error-message.d.ts.map +1 -0
- package/dist/_lib/error-message.js +21 -0
- package/dist/_lib/error-message.js.map +1 -0
- package/dist/_lib/order-deadline.d.ts +23 -0
- package/dist/_lib/order-deadline.d.ts.map +1 -1
- package/dist/_lib/order-deadline.js +40 -6
- package/dist/_lib/order-deadline.js.map +1 -1
- package/dist/_lib/payment-guard.d.ts +59 -0
- package/dist/_lib/payment-guard.d.ts.map +1 -0
- package/dist/_lib/payment-guard.js +188 -0
- package/dist/_lib/payment-guard.js.map +1 -0
- package/dist/_lib/payment-lock.d.ts +27 -0
- package/dist/_lib/payment-lock.d.ts.map +1 -0
- package/dist/_lib/payment-lock.js +199 -0
- package/dist/_lib/payment-lock.js.map +1 -0
- package/dist/_lib/payment-record.d.ts +76 -0
- package/dist/_lib/payment-record.d.ts.map +1 -0
- package/dist/_lib/payment-record.js +84 -0
- package/dist/_lib/payment-record.js.map +1 -0
- package/dist/_lib/runtime-env.d.ts.map +1 -1
- package/dist/_lib/runtime-env.js +5 -0
- package/dist/_lib/runtime-env.js.map +1 -1
- package/dist/_lib/subscription-client.d.ts +192 -15
- package/dist/_lib/subscription-client.d.ts.map +1 -1
- package/dist/_lib/subscription-client.js +44 -2
- package/dist/_lib/subscription-client.js.map +1 -1
- package/dist/_lib/swap-payment.d.ts +54 -0
- package/dist/_lib/swap-payment.d.ts.map +1 -0
- package/dist/_lib/swap-payment.js +203 -0
- package/dist/_lib/swap-payment.js.map +1 -0
- package/dist/_lib/xrp-payment.d.ts +48 -0
- package/dist/_lib/xrp-payment.d.ts.map +1 -0
- package/dist/_lib/xrp-payment.js +117 -0
- package/dist/_lib/xrp-payment.js.map +1 -0
- package/dist/_lib/xrpl-login-signer.d.ts +16 -1
- package/dist/_lib/xrpl-login-signer.d.ts.map +1 -1
- package/dist/_lib/xrpl-login-signer.js +25 -1
- package/dist/_lib/xrpl-login-signer.js.map +1 -1
- package/dist/commands/billing.d.ts +5 -3
- package/dist/commands/billing.d.ts.map +1 -1
- package/dist/commands/billing.js +12 -6
- package/dist/commands/billing.js.map +1 -1
- package/dist/commands/deploy.d.ts +1 -1
- package/dist/commands/deploy.js +2 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/faucet.d.ts +1 -1
- package/dist/commands/faucet.d.ts.map +1 -1
- package/dist/commands/faucet.js +2 -7
- package/dist/commands/faucet.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +4 -2
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/redeploy.d.ts +4 -3
- package/dist/commands/redeploy.d.ts.map +1 -1
- package/dist/commands/redeploy.js +5 -4
- package/dist/commands/redeploy.js.map +1 -1
- package/dist/commands/renew.d.ts +47 -4
- package/dist/commands/renew.d.ts.map +1 -1
- package/dist/commands/renew.js +338 -9
- package/dist/commands/renew.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +22 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/subscribe.d.ts +39 -3
- package/dist/commands/subscribe.d.ts.map +1 -1
- package/dist/commands/subscribe.js +424 -110
- package/dist/commands/subscribe.js.map +1 -1
- package/dist/commands/topup.d.ts +33 -7
- package/dist/commands/topup.d.ts.map +1 -1
- package/dist/commands/topup.js +148 -16
- package/dist/commands/topup.js.map +1 -1
- package/dist/commands/upgrade.d.ts +7 -0
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +35 -5
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +8 -2
- package/dist/commands/verify.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +9 -9
- package/dist/__tests__/helpers/fixtures-image-hygiene.d.ts +0 -18
- package/dist/__tests__/helpers/fixtures-image-hygiene.d.ts.map +0 -1
- package/dist/__tests__/helpers/fixtures-image-hygiene.js +0 -42
- package/dist/__tests__/helpers/fixtures-image-hygiene.js.map +0 -1
- package/dist/__tests__/helpers/fixtures.d.ts +0 -48
- package/dist/__tests__/helpers/fixtures.d.ts.map +0 -1
- package/dist/__tests__/helpers/fixtures.js +0 -79
- package/dist/__tests__/helpers/fixtures.js.map +0 -1
|
@@ -51,7 +51,9 @@ exports.renderReserveSurcharge = renderReserveSurcharge;
|
|
|
51
51
|
* second subscription, no second deposit wallet).
|
|
52
52
|
* 5. Render the deposit instructions.
|
|
53
53
|
* 6. AUTO-PAY the deposit from the dev wallet over the XRPL testnet (HST
|
|
54
|
-
* Payment with a SendMax covering the 0.25% transfer fee
|
|
54
|
+
* Payment with a SendMax covering the 0.25% transfer fee; with
|
|
55
|
+
* `--pay-with xrp`, an XRP Payment of the quoted drops carrying the order's
|
|
56
|
+
* Destination Tag, #3699 PR2). `--no-autopay`
|
|
55
57
|
* skips this and prints instructions for manual (XUMM) payment; re-running
|
|
56
58
|
* `hsuite subscribe` afterwards resumes the saved entity. A RESUMED run first
|
|
57
59
|
* asks GET /status and never pays a deposit the platform reports credited
|
|
@@ -81,12 +83,19 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
81
83
|
const ora_1 = __importDefault(require("ora"));
|
|
82
84
|
const smart_engines_sdk_1 = require("@hsuite/smart-engines-sdk");
|
|
83
85
|
const env_1 = require("../_lib/env");
|
|
86
|
+
const deposit_verification_1 = require("../_lib/deposit-verification");
|
|
84
87
|
const decimal_compare_1 = require("../_lib/decimal-compare");
|
|
88
|
+
const payment_record_1 = require("../_lib/payment-record");
|
|
89
|
+
const payment_lock_1 = require("../_lib/payment-lock");
|
|
90
|
+
const error_message_1 = require("../_lib/error-message");
|
|
91
|
+
const payment_guard_1 = require("../_lib/payment-guard");
|
|
85
92
|
const create_outcome_1 = require("../_lib/create-outcome");
|
|
86
93
|
const subscription_client_1 = require("../_lib/subscription-client");
|
|
87
94
|
const subscription_env_1 = require("../_lib/subscription-env");
|
|
88
95
|
const order_deadline_1 = require("../_lib/order-deadline");
|
|
89
96
|
const xrpl_login_signer_1 = require("../_lib/xrpl-login-signer");
|
|
97
|
+
const xrp_payment_1 = require("../_lib/xrp-payment");
|
|
98
|
+
const swap_payment_1 = require("../_lib/swap-payment");
|
|
90
99
|
/** Public XRPL testnet websocket endpoint (matches `hsuite init` + faucet). */
|
|
91
100
|
const XRPL_TESTNET_WSS = 'wss://s.altnet.rippletest.net:51233';
|
|
92
101
|
/**
|
|
@@ -105,11 +114,10 @@ function defaultXrplClientFactory(wss) {
|
|
|
105
114
|
const { Client } = require('xrpl');
|
|
106
115
|
return new Client(wss);
|
|
107
116
|
}
|
|
108
|
-
function
|
|
117
|
+
function defaultHashSignedTx(txBlob) {
|
|
109
118
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
110
|
-
const {
|
|
111
|
-
|
|
112
|
-
return (tx) => wallet.sign(tx).tx_blob;
|
|
119
|
+
const { hashes } = require('xrpl');
|
|
120
|
+
return hashes.hashSignedTx(txBlob);
|
|
113
121
|
}
|
|
114
122
|
/**
|
|
115
123
|
* Default entity-create-intent signer (#3506 A3, MEDIUM-1 fix): the SAME
|
|
@@ -137,12 +145,43 @@ async function defaultIntentSignerFactory(address, seed) {
|
|
|
137
145
|
* this and exits the process.
|
|
138
146
|
*/
|
|
139
147
|
async function runSubscribe(opts) {
|
|
148
|
+
// #3917 item 3 — one paying run per env file: the guard that stops a second payment reads the
|
|
149
|
+
// env file's record and asks the ledger long before this run writes its own, so two runs on one
|
|
150
|
+
// env file could both pass it. The lock is the env file's, shared with `hsuite topup`.
|
|
151
|
+
return (0, payment_lock_1.withPaymentLock)(opts.env, 'hsuite subscribe', () => runSubscribeLocked(opts));
|
|
152
|
+
}
|
|
153
|
+
/** The body of {@link runSubscribe}, run while it holds the env file's payment lock. */
|
|
154
|
+
async function runSubscribeLocked(opts) {
|
|
140
155
|
const env = (0, env_1.readEnv)(opts.env);
|
|
141
156
|
const { address, seed } = (0, subscription_env_1.requireXrplCreds)(env);
|
|
142
157
|
const tier = opts.tier;
|
|
143
158
|
if (!VALID_TIERS.includes(tier)) {
|
|
144
159
|
throw new Error(`unknown tier "${opts.tier}". Valid: ${VALID_TIERS.join(', ')}`);
|
|
145
160
|
}
|
|
161
|
+
// #3699 PR2 — parsed before anything is sent: an unknown asset is a mistake, not a default.
|
|
162
|
+
const payChoice = (0, xrp_payment_1.parsePayChoice)(opts.payWith);
|
|
163
|
+
const payWith = payChoice.kind;
|
|
164
|
+
const payNetwork = (0, xrp_payment_1.parsePayNetwork)(opts.payNetwork);
|
|
165
|
+
// #3699 PR3 — a SWAP asset (anything but hsuite and xrp) is paid by the builder from their own wallet, and the
|
|
166
|
+
// provider needs somewhere to return the funds if the swap cannot complete: the builder's own address, REQUIRED.
|
|
167
|
+
// Everything the swap needs is known, and refused, before a single request is made.
|
|
168
|
+
let swapAsk;
|
|
169
|
+
if (payWith === 'swap') {
|
|
170
|
+
const refundAddress = opts.refundAddress?.trim();
|
|
171
|
+
if (!refundAddress) {
|
|
172
|
+
throw new Error(`--pay-with ${payChoice.asset} needs --refund-address <your ${String(payChoice.asset).toUpperCase()} address>: ` +
|
|
173
|
+
'the swap provider returns your funds to it if the swap cannot complete. Nothing was created.');
|
|
174
|
+
}
|
|
175
|
+
swapAsk = {
|
|
176
|
+
ticker: String(payChoice.asset),
|
|
177
|
+
...(payNetwork !== undefined ? { network: payNetwork } : {}),
|
|
178
|
+
refundAddress,
|
|
179
|
+
...(opts.refundExtraId?.trim() ? { refundExtraId: opts.refundExtraId.trim() } : {}),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
else if (opts.refundAddress !== undefined || opts.refundExtraId !== undefined || payNetwork !== undefined) {
|
|
183
|
+
throw new Error('--refund-address, --refund-extra-id and --pay-network apply only to a swap asset (--pay-with btc, eth, usdt, ...). Nothing was created.');
|
|
184
|
+
}
|
|
146
185
|
const baseUrl = (0, subscription_env_1.requireValidatorUrl)(env, { gateway: opts.gateway });
|
|
147
186
|
const client = (opts.clientFactory ??
|
|
148
187
|
((b) => new subscription_client_1.SubscriptionClient({ baseUrl: b, auth: { chain: 'xrpl', address, seed } })))(baseUrl);
|
|
@@ -185,38 +224,31 @@ async function runSubscribe(opts) {
|
|
|
185
224
|
resumedFrom = `the unfinished create recorded in ${opts.env}`;
|
|
186
225
|
}
|
|
187
226
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
appId = preexistingAppId;
|
|
192
|
-
// Say so: the platform's stored subscription decides the tier and the amount,
|
|
193
|
-
// so the --tier / --app-name this run was started with have no effect on it.
|
|
194
|
-
console.log(chalk_1.default.gray(` resuming smart-app entity ${appId} (from ${resumedFrom}) — ` +
|
|
195
|
-
'it keeps the tier and name it was created with; --tier and --app-name are ignored'));
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
227
|
+
// #3506 A3 / A2c — the cluster's network every intent is signed for, fetched ONCE and only when a
|
|
228
|
+
// run actually signs (a fresh create, or the deposit request of a resumed run).
|
|
229
|
+
const resolveIntentNetwork = async () => {
|
|
198
230
|
// #3506 A3 — every legitimate customer create carries a signed intent.
|
|
199
231
|
// `GET /api/v3/discovery/network` is the PUBLIC, ingress-routed source of
|
|
200
232
|
// the cluster's GenesisConfig.network — the exact value every responder
|
|
201
233
|
// compares the intent's `network` field against (HIGH-2: genesis/status
|
|
202
234
|
// is NOT on the ingress allow-list and 404s through the gateway).
|
|
203
|
-
const
|
|
204
|
-
if (!
|
|
235
|
+
const discovered = await (0, smart_engines_sdk_1.fetchIntentNetwork)(baseUrl);
|
|
236
|
+
if (!discovered.ok) {
|
|
205
237
|
// HIGH-1(a): a 404 means this cluster predates signed create intents
|
|
206
238
|
// (#3635 + this endpoint haven't shipped there yet). Refuse BEFORE
|
|
207
239
|
// creating anything — an old validator would otherwise silently strip
|
|
208
240
|
// `creationIntent`, create a RANDOM-id entity, and the post-create
|
|
209
241
|
// assert below would then throw, orphaning that entity + its pending
|
|
210
242
|
// subscription on every retry.
|
|
211
|
-
if (
|
|
243
|
+
if (discovered.status === 404) {
|
|
212
244
|
throw new Error('cannot build a signed entity-create intent: GET /api/v3/discovery/network ' +
|
|
213
245
|
'was not found (404) — this cluster predates signed create intents; upgrade ' +
|
|
214
246
|
'the cluster (ship #3635 + this endpoint) before running `hsuite subscribe`.');
|
|
215
247
|
}
|
|
216
248
|
throw new Error('cannot build a signed entity-create intent: GET /api/v3/discovery/network ' +
|
|
217
|
-
`failed (status ${
|
|
249
|
+
`failed (status ${discovered.status}) — refusing to create without a verified network`);
|
|
218
250
|
}
|
|
219
|
-
const network =
|
|
251
|
+
const network = discovered.network;
|
|
220
252
|
// #3506 A3 LOW-1 (lying/misconfigured gateway, mainnet-only guard):
|
|
221
253
|
// `HSUITE_NETWORK` records which HSUITE CLUSTER `VALIDATOR_URL`/
|
|
222
254
|
// `SMART_HOST_URL` were resolved from (`hsuite init`, see `init.ts:
|
|
@@ -243,17 +275,77 @@ async function runSubscribe(opts) {
|
|
|
243
275
|
'entity-create intent unless HSUITE_NETWORK=mainnet (possible lying or ' +
|
|
244
276
|
'misconfigured gateway)');
|
|
245
277
|
}
|
|
278
|
+
return network;
|
|
279
|
+
};
|
|
280
|
+
let networkOnce;
|
|
281
|
+
const intentNetwork = () => (networkOnce ??= resolveIntentNetwork());
|
|
282
|
+
let signerOnce;
|
|
283
|
+
const intentSigner = () => (signerOnce ??= Promise.resolve((opts.intentSignerFactory ?? defaultIntentSignerFactory)(address, seed)));
|
|
284
|
+
// #3506 A2c — the deposit wallet of the subscription is created under the DEVELOPER's own signed
|
|
285
|
+
// intent too: this wallet signs the canonical `subscription` deposit rule, built HERE from the
|
|
286
|
+
// cluster's reported deposit token (the validator rebuilds it from the signed message and refuses
|
|
287
|
+
// any difference), bound to the smart-app `forAppId`. Valid ~10 minutes: signed right before it is
|
|
288
|
+
// sent, and signed afresh for every send.
|
|
289
|
+
const signDepositIntent = async (forAppId) => {
|
|
290
|
+
const network = await intentNetwork();
|
|
291
|
+
const tokenId = await client.depositTokenId('xrpl');
|
|
292
|
+
if (!tokenId) {
|
|
293
|
+
throw new Error('cannot build a signed deposit-wallet intent: GET /api/v3/subscription/config reports no ' +
|
|
294
|
+
'deposit token for xrpl — this cluster predates payer-signed deposit wallets (#3506 A2c); ' +
|
|
295
|
+
'upgrade the cluster before running `hsuite subscribe`.');
|
|
296
|
+
}
|
|
297
|
+
const { proof, intent } = await (0, smart_engines_sdk_1.signDepositWalletIntent)(await intentSigner(), {
|
|
298
|
+
network,
|
|
299
|
+
depositType: 'subscription',
|
|
300
|
+
chain: 'xrpl',
|
|
301
|
+
tokenId,
|
|
302
|
+
appId: forAppId,
|
|
303
|
+
});
|
|
304
|
+
// #3506 — kept BEFORE the proof is sent: the wallet may be created even if the answer is lost, and
|
|
305
|
+
// every payment made at its address (this run's, `topup`, `upgrade`) is verified against it. A
|
|
306
|
+
// wallet this CLI could not later verify is not created.
|
|
307
|
+
(0, deposit_verification_1.rememberDepositIntent)(opts.env, forAppId, intent);
|
|
308
|
+
return proof;
|
|
309
|
+
};
|
|
310
|
+
let appId;
|
|
311
|
+
let created;
|
|
312
|
+
/** The swap asset's entry in what the network offers, when this run created the entity (#3699 PR3). */
|
|
313
|
+
let swapListing;
|
|
314
|
+
if (preexistingAppId) {
|
|
315
|
+
appId = preexistingAppId;
|
|
316
|
+
// Say so: the platform's stored subscription decides the tier and the amount,
|
|
317
|
+
// so the --tier / --app-name this run was started with have no effect on it.
|
|
318
|
+
console.log(chalk_1.default.gray(` resuming smart-app entity ${appId} (from ${resumedFrom}) — ` +
|
|
319
|
+
'it keeps the tier and name it was created with; --tier and --app-name are ignored'));
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
// #3699 PR3 — a swap asset is checked against what this network offers BEFORE anything is signed or created:
|
|
323
|
+
// an asset it does not offer, a ticker on several networks with none named, and a refund memo it needs and
|
|
324
|
+
// was not given are all refused here, with nothing made.
|
|
325
|
+
if (swapAsk) {
|
|
326
|
+
let offered;
|
|
327
|
+
try {
|
|
328
|
+
offered = (await client.paymentAssets()).assets;
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
throw new Error(`could not read what this network can be paid in (GET /api/v3/subscription/payment-assets): ${(0, error_message_1.errorMessage)(err)} — ` +
|
|
332
|
+
'it may predate swap payments. Nothing was created.', { cause: err });
|
|
333
|
+
}
|
|
334
|
+
swapListing = (0, swap_payment_1.resolveSwapListing)(offered, swapAsk);
|
|
335
|
+
}
|
|
336
|
+
const network = await intentNetwork();
|
|
246
337
|
// The developer authors the rule CLIENT-SIDE (the wallet signs its hash) —
|
|
247
338
|
// the standard default, byte-identical to what the validator would
|
|
248
339
|
// otherwise synthesize server-side for the same deployment path.
|
|
249
340
|
const validatorRules = (0, smart_engines_sdk_1.buildDefaultSmartAppValidatorRules)();
|
|
250
|
-
const
|
|
251
|
-
const { proof: creationIntent, entityId: expectedEntityId } = await (0, smart_engines_sdk_1.signEntityCreateIntent)(intentSigner, {
|
|
341
|
+
const { proof: creationIntent, entityId: expectedEntityId } = await (0, smart_engines_sdk_1.signEntityCreateIntent)(await intentSigner(), {
|
|
252
342
|
network,
|
|
253
343
|
entityType: 'smart-app',
|
|
254
344
|
chain: 'xrpl',
|
|
255
345
|
rule: validatorRules,
|
|
256
346
|
});
|
|
347
|
+
// #3506 A2c — and the deposit wallet's intent, bound to the entityId the app intent derives.
|
|
348
|
+
const depositCreationIntent = await signDepositIntent(expectedEntityId);
|
|
257
349
|
// #3766 — record the create as PENDING before the request leaves: it is a long synchronous
|
|
258
350
|
// ceremony and this client gives up first, so "no answer" must not be mistaken for "nothing
|
|
259
351
|
// was created". Refuses (nothing sent) when the record cannot be kept.
|
|
@@ -275,6 +367,11 @@ async function runSubscribe(opts) {
|
|
|
275
367
|
// binding this create to it (and to a leader-independent entityId).
|
|
276
368
|
validatorRules,
|
|
277
369
|
creationIntent,
|
|
370
|
+
depositCreationIntent,
|
|
371
|
+
// #3699 PR2 — priced in XRP when asked; omitted (= HSUITE) otherwise, as ever.
|
|
372
|
+
...(payWith === 'xrp' ? { paymentAsset: 'XRP' } : {}),
|
|
373
|
+
// #3699 PR3 — a swap asset, its network and the builder's refund address.
|
|
374
|
+
...(swapAsk ? (0, swap_payment_1.swapCreateFields)(swapAsk, swapListing) : {}),
|
|
278
375
|
});
|
|
279
376
|
}
|
|
280
377
|
catch (err) {
|
|
@@ -282,9 +379,9 @@ async function runSubscribe(opts) {
|
|
|
282
379
|
// The platform rejected the request, or it never left this machine: nothing was created,
|
|
283
380
|
// so nothing is pending and the next run creates normally.
|
|
284
381
|
clearPendingCreate(opts.env);
|
|
285
|
-
throw new Error(`smart-app entity creation failed: ${errorMessage(err)}`, { cause: err });
|
|
382
|
+
throw new Error(`smart-app entity creation failed: ${(0, error_message_1.errorMessage)(err)}`, { cause: err });
|
|
286
383
|
}
|
|
287
|
-
throw new Error(`smart-app entity creation failed: ${errorMessage(err)}${unknownCreateNote(expectedEntityId, opts.env, inv)}`, { cause: err });
|
|
384
|
+
throw new Error(`smart-app entity creation failed: ${(0, error_message_1.errorMessage)(err)}${unknownCreateNote(expectedEntityId, opts.env, inv)}`, { cause: err });
|
|
288
385
|
}
|
|
289
386
|
if (!created?.appId) {
|
|
290
387
|
// The platform answered (even with an empty 2xx body), but without the entity: it may well
|
|
@@ -314,7 +411,7 @@ async function runSubscribe(opts) {
|
|
|
314
411
|
`The server created an ORPHANED entity at appId "${created.appId}" (a subscription ` +
|
|
315
412
|
`may exist on it, unaffiliated with your wallet). Do NOT retry blindly. Record ` +
|
|
316
413
|
`"${created.appId}" and investigate the cluster (bug, stale validator missing ` +
|
|
317
|
-
`#3635, or compromise) before creating again. Original error: ${errorMessage(err)}`);
|
|
414
|
+
`#3635, or compromise) before creating again. Original error: ${(0, error_message_1.errorMessage)(err)}`);
|
|
318
415
|
}
|
|
319
416
|
appId = created.appId;
|
|
320
417
|
// #3754 — record the entity BEFORE any further step (deposit instructions,
|
|
@@ -334,18 +431,35 @@ async function runSubscribe(opts) {
|
|
|
334
431
|
let deposit = created?.depositInstructions;
|
|
335
432
|
let subscriptionId = created?.subscriptionId;
|
|
336
433
|
if (!deposit) {
|
|
434
|
+
const requestBody = {
|
|
435
|
+
appId,
|
|
436
|
+
developerAccountId: address,
|
|
437
|
+
chain: 'xrpl',
|
|
438
|
+
appName,
|
|
439
|
+
selectedTier: tier,
|
|
440
|
+
selectedNetworks: ['xrpl'],
|
|
441
|
+
...(payWith === 'xrp' ? { paymentAsset: 'XRP' } : {}),
|
|
442
|
+
...(swapAsk ? (0, swap_payment_1.swapRequestFields)(swapAsk, swapListing) : {}),
|
|
443
|
+
};
|
|
337
444
|
try {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
445
|
+
// #3506 A2c — the request creates the deposit wallet only when this node has none. A RESUMED
|
|
446
|
+
// run almost always asks about a wallet that exists (the idempotent replay), so it first asks
|
|
447
|
+
// WITHOUT an intent: no discovery call, no signature. Only the validator's answer that a wallet
|
|
448
|
+
// would have to be created (`deposit_intent_required`) makes it sign, once, afresh.
|
|
449
|
+
try {
|
|
450
|
+
requested = await client.request(requestBody);
|
|
451
|
+
}
|
|
452
|
+
catch (err) {
|
|
453
|
+
if (!(0, smart_engines_sdk_1.isDepositIntentRequiredError)(err))
|
|
454
|
+
throw err;
|
|
455
|
+
requested = await client.request({
|
|
456
|
+
...requestBody,
|
|
457
|
+
depositCreationIntent: await signDepositIntent(appId),
|
|
458
|
+
});
|
|
459
|
+
}
|
|
346
460
|
}
|
|
347
461
|
catch (err) {
|
|
348
|
-
throw new Error(`subscription request failed: ${errorMessage(err)}${unpaidNote(appId, opts.env, inv)}`, {
|
|
462
|
+
throw new Error(`subscription request failed: ${(0, error_message_1.errorMessage)(err)}${unpaidNote(appId, opts.env, inv)}`, {
|
|
349
463
|
cause: err,
|
|
350
464
|
});
|
|
351
465
|
}
|
|
@@ -381,6 +495,7 @@ async function runSubscribe(opts) {
|
|
|
381
495
|
const status = standing.subscriptionNftSerial || standing.chainNfts?.xrpl?.nftId
|
|
382
496
|
? standing
|
|
383
497
|
: await pollStatus(client, appId, sleep, opts, (s) => Boolean(s.subscriptionNftSerial) || Boolean(s.chainNfts?.xrpl?.nftId), opts.nftPollAttempts ?? 24);
|
|
498
|
+
(0, payment_guard_1.clearPendingPayment)(opts.env, appId, payment_record_1.PENDING_PAYMENT_KEY); // active: whatever was paid has been credited
|
|
384
499
|
const nftAccepted = await acceptSubscriptionNft(opts, address, seed, sleep, status);
|
|
385
500
|
return {
|
|
386
501
|
appId,
|
|
@@ -404,6 +519,23 @@ async function runSubscribe(opts) {
|
|
|
404
519
|
throw paid ? paidThenFailed(err, paid, appId, opts.env, inv) : err;
|
|
405
520
|
}
|
|
406
521
|
};
|
|
522
|
+
// #3506 — the address the validator that answered gave, checked through a validator it did NOT
|
|
523
|
+
// answer from (the payer's own signed intent decides which wallet is meant), before it is shown or
|
|
524
|
+
// paid. A swap order is the exception: the builder sends to the provider, not to this account.
|
|
525
|
+
const verifyDeposit = async (d) => {
|
|
526
|
+
try {
|
|
527
|
+
const verified = await (0, deposit_verification_1.verifyDepositForPayment)({
|
|
528
|
+
envPath: opts.env,
|
|
529
|
+
appId,
|
|
530
|
+
baseUrl,
|
|
531
|
+
...(opts.depositVerifierFactory ? { factory: opts.depositVerifierFactory } : {}),
|
|
532
|
+
}, { address: d.walletAddress, chain: d.chain });
|
|
533
|
+
console.log(chalk_1.default.gray(` ${(0, deposit_verification_1.describeVerified)(verified)}`));
|
|
534
|
+
}
|
|
535
|
+
catch (err) {
|
|
536
|
+
throw new Error(`${(0, error_message_1.errorMessage)(err)}${unpaidNote(appId, opts.env, inv)}`, { cause: err });
|
|
537
|
+
}
|
|
538
|
+
};
|
|
407
539
|
if (creditedAs) {
|
|
408
540
|
// Credited, so there is nothing left to pay — however the run was started
|
|
409
541
|
// (`--no-autopay` only governs PAYING): carry on to mint + accept. This is
|
|
@@ -419,6 +551,84 @@ async function runSubscribe(opts) {
|
|
|
419
551
|
'Try again in a minute: a retry can reach a node that has it.'
|
|
420
552
|
: 'no depositInstructions for the created entity — server contract violation');
|
|
421
553
|
}
|
|
554
|
+
// #3699 PR3 — an order paid through a swap: the builder sends the source asset to the PROVIDER from their own
|
|
555
|
+
// wallet. This CLI holds an XRPL key and cannot spend it, so it checks what it is told, prints it, and stops
|
|
556
|
+
// (as `--no-autopay` does): it never pays, whatever else the instructions carry. A lapsed swap quote is not
|
|
557
|
+
// shown at all: the platform requotes it (a NEW exchange) when this run names the asset and the refund address
|
|
558
|
+
// again, which is the request above, so what comes back is a live quote or a refusal that says why.
|
|
559
|
+
const swapInstruction = (0, swap_payment_1.swapPaymentOf)(deposit);
|
|
560
|
+
if (swapInstruction) {
|
|
561
|
+
if (payWith === 'xrp') {
|
|
562
|
+
throw new Error('asked to pay in XRP, but this subscription is already priced through a swap ' +
|
|
563
|
+
`(${swapInstruction.asset}) — nothing was paid${unpaidNote(appId, opts.env, inv)} ` +
|
|
564
|
+
`Re-run without --pay-with to see the ${swapInstruction.asset} instructions.`);
|
|
565
|
+
}
|
|
566
|
+
try {
|
|
567
|
+
(0, swap_payment_1.assertSwapPaymentConsistent)(swapInstruction, swapAsk);
|
|
568
|
+
// A payout that has already been counted is past its deadline by nature: nothing is left to send, so the
|
|
569
|
+
// deadline is not held against it.
|
|
570
|
+
if (!(0, swap_payment_1.swapPaymentCounted)(swapInstruction))
|
|
571
|
+
(0, swap_payment_1.assertSwapQuoteLive)(swapInstruction);
|
|
572
|
+
}
|
|
573
|
+
catch (err) {
|
|
574
|
+
throw new Error(`${(0, error_message_1.errorMessage)(err)}${unpaidNote(appId, opts.env, inv)}`, { cause: err });
|
|
575
|
+
}
|
|
576
|
+
if ((0, swap_payment_1.swapPaymentCounted)(swapInstruction)) {
|
|
577
|
+
console.log(chalk_1.default.cyan(`\n Your ${swapInstruction.asset} swap payment has been counted (order ${swapInstruction.status}): the platform is converting it ` +
|
|
578
|
+
'into your subscription deposit. Do NOT send it again. Re-run `hsuite subscribe` in a minute to mint + accept the NFT.\n'));
|
|
579
|
+
return {
|
|
580
|
+
appId,
|
|
581
|
+
subscriptionId,
|
|
582
|
+
tier,
|
|
583
|
+
status: standing?.status ?? requested?.status ?? 'pending_deposit',
|
|
584
|
+
depositPaid: false,
|
|
585
|
+
nftAccepted: false,
|
|
586
|
+
swapPaymentCounted: true,
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
renderDepositInstructions(deposit, preexistingAppId ? undefined : tier, appId);
|
|
590
|
+
// #3506 — the independent check covers the XRPL deposit account only. What the builder SENDS goes to
|
|
591
|
+
// the swap provider's pay-in address (and memo), which the validator that answered gave and nothing
|
|
592
|
+
// here can confirm: say so rather than let a verified-looking line sit next to it.
|
|
593
|
+
console.log(chalk_1.default.yellow(' NOTE: the pay-in address and memo above come from the validator that answered. The independent ' +
|
|
594
|
+
'deposit-address check covers the XRPL deposit account, not a swap provider\'s pay-in address, so they ' +
|
|
595
|
+
'are NOT verified: confirm them with the swap provider before you send.'));
|
|
596
|
+
console.log(chalk_1.default.cyan(` Send the ${swapInstruction.asset} above from your own wallet, then re-run \`hsuite subscribe\` ` +
|
|
597
|
+
'once it has been counted to mint + accept the NFT. Nothing is paid by this command.\n'));
|
|
598
|
+
return {
|
|
599
|
+
appId,
|
|
600
|
+
subscriptionId,
|
|
601
|
+
tier,
|
|
602
|
+
status: standing?.status ?? requested?.status ?? 'pending_deposit',
|
|
603
|
+
depositPaid: false,
|
|
604
|
+
nftAccepted: false,
|
|
605
|
+
awaitingSwapPayment: true,
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
// #3699 pre-arming item 4 — the REMAINDER of an underpaid swap order is plain XRP instructions to the same deposit
|
|
609
|
+
// account and tag (no new exchange): the one answer to a swap request that is neither a swap nor the wrong asset.
|
|
610
|
+
const isSwapRemainder = deposit.swapRemainder === true && (0, xrp_payment_1.xrpPaymentOf)(deposit) !== undefined;
|
|
611
|
+
// #3699 PR3 — asked for a swap asset, answered with something else: it would be paid in the wrong asset.
|
|
612
|
+
if (payWith === 'swap' && !isSwapRemainder) {
|
|
613
|
+
throw new Error(`asked to pay in ${String(payChoice.asset).toUpperCase()} through a swap, but the validator did not price this ` +
|
|
614
|
+
`subscription that way (no swap payment instruction came back) — nothing was paid${unpaidNote(appId, opts.env, inv)} ` +
|
|
615
|
+
'Re-run without --pay-with to pay in HSUITE, or check GET /api/v3/subscription/payment-assets.');
|
|
616
|
+
}
|
|
617
|
+
// #3699 pre-arming item 4 — a remainder that has been counted (the XRP is on the deposit account, the platform is
|
|
618
|
+
// converting it) is not to be sent again, however this run was started and whatever its deadline says.
|
|
619
|
+
if (isSwapRemainder && (deposit.orderStatus === 'paid' || deposit.orderStatus === 'converting')) {
|
|
620
|
+
console.log(chalk_1.default.cyan(`\n Your remainder payment has been counted (order ${deposit.orderStatus}): the platform is converting it into your subscription deposit. ` +
|
|
621
|
+
'Do NOT send it again. Re-run `hsuite subscribe` in a minute to mint + accept the NFT.\n'));
|
|
622
|
+
return {
|
|
623
|
+
appId,
|
|
624
|
+
subscriptionId,
|
|
625
|
+
tier,
|
|
626
|
+
status: standing?.status ?? requested?.status ?? 'pending_deposit',
|
|
627
|
+
depositPaid: false,
|
|
628
|
+
nftAccepted: false,
|
|
629
|
+
swapPaymentCounted: true,
|
|
630
|
+
};
|
|
631
|
+
}
|
|
422
632
|
// #3699 D8 / #3765 — never put an expired quote in front of a payer, on EITHER path:
|
|
423
633
|
// requote first if the deadline has already passed, then show / pay the NEW amount and tag.
|
|
424
634
|
// (A manual payer used to be shown whatever the replay re-attached, expired or not.)
|
|
@@ -427,11 +637,50 @@ async function runSubscribe(opts) {
|
|
|
427
637
|
}
|
|
428
638
|
catch (err) {
|
|
429
639
|
throw new Error(`could not requote the expired quote for order ${deposit.orderId ?? 'n/a'}: ` +
|
|
430
|
-
`${errorMessage(err)}${unpaidNote(appId, opts.env, inv)}`, { cause: err });
|
|
640
|
+
`${(0, error_message_1.errorMessage)(err)}${unpaidNote(appId, opts.env, inv)}`, { cause: err });
|
|
431
641
|
}
|
|
642
|
+
// #3699 PR2 — `--pay-with xrp` is only ever answered with an order priced in XRP. A validator that
|
|
643
|
+
// hands HST instructions to an XRP request (or an older one that ignores the asset) would have this run
|
|
644
|
+
// pay HST, the asset the builder did not ask to pay in: refuse HERE, before anything is signed.
|
|
645
|
+
if (payWith === 'xrp' && !(0, xrp_payment_1.xrpPaymentOf)(deposit)) {
|
|
646
|
+
throw new Error('asked to pay in XRP, but the validator priced this subscription in HSUITE (no XRP payment ' +
|
|
647
|
+
`instruction came back) — nothing was paid${unpaidNote(appId, opts.env, inv)} ` +
|
|
648
|
+
'Re-run without --pay-with to pay in HSUITE.');
|
|
649
|
+
}
|
|
650
|
+
// #3699 PR2 — an XRP instruction is paid exactly as given: check it pays THIS deposit account before
|
|
651
|
+
// it is shown or signed.
|
|
652
|
+
const instructedXrp = (0, xrp_payment_1.xrpPaymentOf)(deposit);
|
|
653
|
+
if (instructedXrp) {
|
|
654
|
+
try {
|
|
655
|
+
(0, xrp_payment_1.assertXrpPaymentConsistent)(deposit, instructedXrp);
|
|
656
|
+
}
|
|
657
|
+
catch (err) {
|
|
658
|
+
throw new Error(`${(0, error_message_1.errorMessage)(err)}${unpaidNote(appId, opts.env, inv)}`, { cause: err });
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
// #3506 — nothing below shows or pays an address that was not verified.
|
|
662
|
+
await verifyDeposit(deposit);
|
|
432
663
|
// A resumed entity keeps the tier it was created with, which this run's
|
|
433
664
|
// --tier says nothing about: print the tier only for an entity created now.
|
|
434
665
|
renderDepositInstructions(deposit, preexistingAppId ? undefined : tier, appId);
|
|
666
|
+
// #3699 pre-arming item 4 — the builder chose to pay this subscription in another asset, and what is left of it is a
|
|
667
|
+
// small amount of XRP: this run does not pay it on their behalf, however it was started, unless they ask it to
|
|
668
|
+
// (`--pay-with xrp`). It prints what is owed and stops, as it does for a swap.
|
|
669
|
+
if (isSwapRemainder && payWith !== 'xrp') {
|
|
670
|
+
console.log(chalk_1.default.cyan(' This is the REMAINDER of your swap payment: the XRP the swap delivered fell short of what the subscription now costs, ' +
|
|
671
|
+
'and this is what is left, as XRP to the same deposit account and tag (no new swap is opened). ' +
|
|
672
|
+
'Send it from your own wallet, or re-run `hsuite subscribe --pay-with xrp` to have this CLI pay it from your XRPL wallet. ' +
|
|
673
|
+
'Nothing is paid by this command.\n'));
|
|
674
|
+
return {
|
|
675
|
+
appId,
|
|
676
|
+
subscriptionId,
|
|
677
|
+
tier,
|
|
678
|
+
status: standing?.status ?? requested?.status ?? 'pending_deposit',
|
|
679
|
+
depositPaid: false,
|
|
680
|
+
nftAccepted: false,
|
|
681
|
+
awaitingSwapRemainder: true,
|
|
682
|
+
};
|
|
683
|
+
}
|
|
435
684
|
// Step 3: auto-pay the deposit from the dev wallet (unless --no-autopay).
|
|
436
685
|
if (opts.autopay === false) {
|
|
437
686
|
renderManualPaymentHint(deposit);
|
|
@@ -445,7 +694,7 @@ async function runSubscribe(opts) {
|
|
|
445
694
|
};
|
|
446
695
|
}
|
|
447
696
|
try {
|
|
448
|
-
paid = await payDeposit(opts, address, seed, deposit);
|
|
697
|
+
paid = await payDeposit(opts, address, seed, deposit, appId);
|
|
449
698
|
}
|
|
450
699
|
catch (err) {
|
|
451
700
|
// #3754 — the entity exists whether or not this payment did (it is already
|
|
@@ -457,6 +706,7 @@ async function runSubscribe(opts) {
|
|
|
457
706
|
}
|
|
458
707
|
// Step 3: poll /status until the deposit is confirmed and ready to mint.
|
|
459
708
|
await afterDeposit(() => pollStatus(client, appId, sleep, opts, (s) => isReadyToMint(s.status)));
|
|
709
|
+
(0, payment_guard_1.clearPendingPayment)(opts.env, appId, payment_record_1.PENDING_PAYMENT_KEY); // credited: the platform has counted the payment this CLI recorded
|
|
460
710
|
// Step 4: POST /mint — kicks off the async NFT mint. Tolerate a non-2xx here
|
|
461
711
|
// (the server may still be finalizing); the status poll below is the source of
|
|
462
712
|
// truth for whether the NFT actually minted.
|
|
@@ -467,7 +717,7 @@ async function runSubscribe(opts) {
|
|
|
467
717
|
}
|
|
468
718
|
}
|
|
469
719
|
catch (err) {
|
|
470
|
-
console.log(chalk_1.default.yellow(` mint HTTP error (tolerated, will poll status): ${errorMessage(err)}`));
|
|
720
|
+
console.log(chalk_1.default.yellow(` mint HTTP error (tolerated, will poll status): ${(0, error_message_1.errorMessage)(err)}`));
|
|
471
721
|
}
|
|
472
722
|
// Step 5: poll until the NFT serial is set OR the minted NFT coordinates
|
|
473
723
|
// appear on /status (the NFT mints asynchronously via the mint subscriber).
|
|
@@ -505,23 +755,6 @@ function toDnsSafeName(name) {
|
|
|
505
755
|
.replace(/-+$/g, '');
|
|
506
756
|
return slug.length > 0 ? slug : 'smart-app';
|
|
507
757
|
}
|
|
508
|
-
/**
|
|
509
|
-
* A printable reason for whatever was thrown. An `Error` gives its message (its
|
|
510
|
-
* name when the message is empty); a thrown string is itself; anything else is
|
|
511
|
-
* JSON — never "undefined" and never "[object Object]".
|
|
512
|
-
*/
|
|
513
|
-
function errorMessage(err) {
|
|
514
|
-
if (err instanceof Error)
|
|
515
|
-
return err.message || err.name;
|
|
516
|
-
if (typeof err === 'string')
|
|
517
|
-
return err;
|
|
518
|
-
try {
|
|
519
|
-
return JSON.stringify(err) ?? String(err);
|
|
520
|
-
}
|
|
521
|
-
catch {
|
|
522
|
-
return String(err);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
758
|
/** `value` as one shell word: left as is when it is plain, else single-quoted. */
|
|
526
759
|
function shellQuote(value) {
|
|
527
760
|
return /^[A-Za-z0-9_@%+=:,./-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
@@ -546,42 +779,38 @@ function unpaidNote(appId, envPath, inv) {
|
|
|
546
779
|
return (` — smart-app entity ${appId} is saved and NOTHING has been paid. Re-run ` +
|
|
547
780
|
`\`${resumeCommand(appId, envPath, resumeFlags(inv))}\` to resume it (that will NOT create a second entity).`);
|
|
548
781
|
}
|
|
549
|
-
/**
|
|
550
|
-
* The deposit payment left this process but no verdict came back (a timeout, a
|
|
551
|
-
* dropped websocket …): it may still validate. A plain "fix the cause and re-run"
|
|
552
|
-
* would invite a second payment, so it gets its own message (see `paymentFailure`).
|
|
553
|
-
*/
|
|
554
|
-
class PaymentOutcomeUnknownError extends Error {
|
|
555
|
-
constructor(cause) {
|
|
556
|
-
super(errorMessage(cause), { cause });
|
|
557
|
-
this.name = 'PaymentOutcomeUnknownError';
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
782
|
/** The error for a payment that did not go through (or may not have) — see {@link PaymentOutcomeUnknownError}. */
|
|
561
783
|
function paymentFailure(err, ctx) {
|
|
562
784
|
const entity = `smart-app entity ${ctx.appId} (subscription ${ctx.subscriptionId ?? 'n/a'}, ` +
|
|
563
785
|
`order ${ctx.deposit.orderId ?? 'n/a'})`;
|
|
564
786
|
if (err instanceof DepositAlreadyOnLedgerError) {
|
|
565
|
-
return new Error(`${errorMessage(err)} (the order is covered at ${err.threshold} HST) — it looks paid, but the platform has not ` +
|
|
787
|
+
return new Error(`${(0, error_message_1.errorMessage)(err)} (the order is covered at ${err.threshold} HST) — it looks paid, but the platform has not ` +
|
|
566
788
|
`credited it yet. NOT paying again. ${entity} is saved. Give the platform about a minute, then run ` +
|
|
567
789
|
`\`${resumeCommand(ctx.appId, ctx.envPath, resumeFlags(ctx.inv, true))}\` — it cannot pay, and it mints and ` +
|
|
568
790
|
'accepts the NFT once the platform credits the deposit. If that balance is NOT a payment for this ' +
|
|
569
791
|
'order, the same command prints what to pay by hand.', { cause: err });
|
|
570
792
|
}
|
|
571
|
-
if (err instanceof
|
|
572
|
-
return new Error(`${errorMessage(err)} —
|
|
793
|
+
if (err instanceof payment_guard_1.RecordedPaymentLandedError) {
|
|
794
|
+
return new Error(`${(0, error_message_1.errorMessage)(err)} (validated tesSUCCESS) — it looks paid, but the platform has not credited it ` +
|
|
795
|
+
`yet. NOT paying again, whatever the quote asks now. ${entity} is saved. Give the platform about a ` +
|
|
796
|
+
`minute, then run \`${resumeCommand(ctx.appId, ctx.envPath, resumeFlags(ctx.inv, true))}\` — it cannot ` +
|
|
797
|
+
'pay, and it mints and accepts the NFT once the platform credits the deposit. If the platform ' +
|
|
798
|
+
'instead reports the order underpaid, the same command prints what to pay by hand.', { cause: err });
|
|
799
|
+
}
|
|
800
|
+
if (err instanceof payment_guard_1.PaymentOutcomeUnknownError) {
|
|
801
|
+
return new Error(`${(0, error_message_1.errorMessage)(err)} — the payment was submitted but its outcome is UNKNOWN: it may still ` +
|
|
573
802
|
`validate. ${entity} is saved. BEFORE re-running, check whether ${ctx.address} already sent ` +
|
|
574
803
|
`HST to ${ctx.deposit.walletAddress} (an XRPL testnet explorer shows it): re-running can pay ` +
|
|
575
804
|
'AGAIN. If it did go through, wait about a minute and run ' +
|
|
576
805
|
`\`${resumeCommand(ctx.appId, ctx.envPath, resumeFlags(ctx.inv, true))}\` — it cannot pay, and it ` +
|
|
577
806
|
'mints and accepts the NFT once the platform credits the deposit.', { cause: err });
|
|
578
807
|
}
|
|
579
|
-
return new Error(`${errorMessage(err)} — ${entity} is NOT orphaned. Fix the cause, then re-run ` +
|
|
808
|
+
return new Error(`${(0, error_message_1.errorMessage)(err)} — ${entity} is NOT orphaned. Fix the cause, then re-run ` +
|
|
580
809
|
`\`${resumeCommand(ctx.appId, ctx.envPath, resumeFlags(ctx.inv))}\` to resume it — that will NOT create a second entity.`, { cause: err });
|
|
581
810
|
}
|
|
582
811
|
/** The error for a step that failed AFTER this run's deposit payment validated. */
|
|
583
812
|
function paidThenFailed(err, receipt, appId, envPath, inv) {
|
|
584
|
-
return new Error(`${errorMessage(err)} — the deposit payment${receipt.hash ? ` (tx ${receipt.hash})` : ''} WAS validated ` +
|
|
813
|
+
return new Error(`${(0, error_message_1.errorMessage)(err)} — the deposit payment${receipt.hash ? ` (tx ${receipt.hash})` : ''} WAS validated ` +
|
|
585
814
|
'on the ledger: do NOT pay again. Give the platform about a minute to credit it, then run ' +
|
|
586
815
|
`\`${resumeCommand(appId, envPath, resumeFlags(inv, true))}\` — it cannot pay, and it finishes minting ` +
|
|
587
816
|
'and accepting the NFT.', { cause: err });
|
|
@@ -600,7 +829,7 @@ async function readStandingBeforePaying(client, appId, envPath, inv) {
|
|
|
600
829
|
standing = await client.status(appId);
|
|
601
830
|
}
|
|
602
831
|
catch (err) {
|
|
603
|
-
throw new Error(`could not read where subscription ${appId} stands (${errorMessage(err)})${unpaidNote(appId, envPath, inv)}`, { cause: err });
|
|
832
|
+
throw new Error(`could not read where subscription ${appId} stands (${(0, error_message_1.errorMessage)(err)})${unpaidNote(appId, envPath, inv)}`, { cause: err });
|
|
604
833
|
}
|
|
605
834
|
if (standing.hasSubscription === false) {
|
|
606
835
|
throw new Error(`the platform that answered has no subscription for smart-app entity ${appId} that this wallet ` +
|
|
@@ -625,7 +854,7 @@ function persistCreatedEntity(envPath, appId, inv) {
|
|
|
625
854
|
}
|
|
626
855
|
catch (err) {
|
|
627
856
|
throw new Error(`smart-app entity ${appId} was created but could not be saved to ${envPath} ` +
|
|
628
|
-
`(${errorMessage(err)}). Nothing has been paid. Re-run ` +
|
|
857
|
+
`(${(0, error_message_1.errorMessage)(err)}). Nothing has been paid. Re-run ` +
|
|
629
858
|
`\`${resumeCommand(appId, envPath, resumeFlags(inv))}\` to resume it.`, { cause: err });
|
|
630
859
|
}
|
|
631
860
|
// The create has its verdict now: it is no longer pending.
|
|
@@ -652,7 +881,7 @@ function recordPendingCreate(envPath, entityId, until) {
|
|
|
652
881
|
(0, env_1.upsertEnv)(envPath, { [create_outcome_1.PENDING_CREATE_KEY]: (0, create_outcome_1.formatPendingCreate)({ appId: entityId, until }) });
|
|
653
882
|
}
|
|
654
883
|
catch (err) {
|
|
655
|
-
throw new Error(`cannot record the create of smart-app entity ${entityId} in ${envPath} (${errorMessage(err)}) — ` +
|
|
884
|
+
throw new Error(`cannot record the create of smart-app entity ${entityId} in ${envPath} (${(0, error_message_1.errorMessage)(err)}) — ` +
|
|
656
885
|
'refusing to send it: a create this CLI cannot keep track of could be orphaned. ' +
|
|
657
886
|
'Nothing was created and nothing has been paid.', { cause: err });
|
|
658
887
|
}
|
|
@@ -714,7 +943,7 @@ async function reconcileUnfinishedCreate(client, env, envPath, inv) {
|
|
|
714
943
|
standing = await client.status(pending.appId);
|
|
715
944
|
}
|
|
716
945
|
catch (err) {
|
|
717
|
-
throw new Error(`${earlier}, and the platform could not be asked whether it exists (${errorMessage(err)}) — ` +
|
|
946
|
+
throw new Error(`${earlier}, and the platform could not be asked whether it exists (${(0, error_message_1.errorMessage)(err)}) — ` +
|
|
718
947
|
`nothing has been created or paid now. Re-run \`${rerunCommand(envPath, inv)}\` in a minute. ` +
|
|
719
948
|
forgetPendingHint(envPath), { cause: err });
|
|
720
949
|
}
|
|
@@ -747,7 +976,7 @@ function saveEnv(envPath, updates) {
|
|
|
747
976
|
return true;
|
|
748
977
|
}
|
|
749
978
|
catch (err) {
|
|
750
|
-
console.log(chalk_1.default.yellow(`\n could not write ${envPath} (${errorMessage(err)}) — add these by hand:`));
|
|
979
|
+
console.log(chalk_1.default.yellow(`\n could not write ${envPath} (${(0, error_message_1.errorMessage)(err)}) — add these by hand:`));
|
|
751
980
|
for (const [key, value] of Object.entries(updates)) {
|
|
752
981
|
console.log(chalk_1.default.yellow(` ${key}=${value}`));
|
|
753
982
|
}
|
|
@@ -774,19 +1003,37 @@ function saveEnv(envPath, updates) {
|
|
|
774
1003
|
* the ledger and the payment is refused ({@link DepositAlreadyOnLedgerError}) when the account
|
|
775
1004
|
* already holds what the quote asks, or when that balance cannot be read at all.
|
|
776
1005
|
*
|
|
1006
|
+
* #3917 item 3 — and BEFORE that, the payment an earlier run recorded for this entity (its signed
|
|
1007
|
+
* hash, written before it was submitted) is looked up on the ledger: delivered → refused
|
|
1008
|
+
* ({@link RecordedPaymentLandedError}); still able to land → refused as unknown
|
|
1009
|
+
* ({@link PaymentOutcomeUnknownError}); failed or past its `LastLedgerSequence` without landing →
|
|
1010
|
+
* it delivered nothing, and this run pays. The hash of the payment THIS run signs is recorded
|
|
1011
|
+
* before it is submitted (and a payment that cannot be recorded is not submitted).
|
|
1012
|
+
*
|
|
777
1013
|
* Requires tesSUCCESS. Always disconnects. A thrown wait for the verdict (the
|
|
778
1014
|
* blob is already out) surfaces as {@link PaymentOutcomeUnknownError}; a `tec*` /
|
|
779
1015
|
* `tem*` verdict is a plain failure — nothing was delivered.
|
|
780
1016
|
*/
|
|
781
|
-
async function payDeposit(opts, address, seed, deposit) {
|
|
1017
|
+
async function payDeposit(opts, address, seed, deposit, appId) {
|
|
782
1018
|
if (deposit.chain !== 'xrpl') {
|
|
783
1019
|
throw new Error(`auto-pay only supports XRPL deposits (got chain=${deposit.chain}); ` +
|
|
784
1020
|
'use --no-autopay and pay manually');
|
|
785
1021
|
}
|
|
786
|
-
const walletSign = (opts.walletSignFactory ??
|
|
1022
|
+
const walletSign = (opts.walletSignFactory ?? xrpl_login_signer_1.buildXrplTxSigner)(seed);
|
|
787
1023
|
const client = (opts.xrplClientFactory ?? defaultXrplClientFactory)(XRPL_TESTNET_WSS);
|
|
788
1024
|
await client.connect();
|
|
789
1025
|
try {
|
|
1026
|
+
// #3917 item 3 — what became of the payment an earlier run SENT decides first; the balance
|
|
1027
|
+
// below cannot tell whose HST it holds, so a requote at a higher price used to be paid again.
|
|
1028
|
+
await (0, payment_guard_1.refuseIfRecordedPaymentMayLand)(client, opts.env, appId, payment_record_1.PENDING_PAYMENT_KEY);
|
|
1029
|
+
// #3699 PR2 — an order priced in XRP is paid in XRP: the quoted drops, with the order's tag. The HST
|
|
1030
|
+
// line of the deposit account says nothing about it (the platform converts the XRP into HST inside the
|
|
1031
|
+
// account), so the HST-balance guard below does not apply; the recorded-payment guard above, which asks
|
|
1032
|
+
// the ledger what became of the payment an earlier run sent, is what stops a second payment.
|
|
1033
|
+
const xrpPay = (0, xrp_payment_1.xrpPaymentOf)(deposit);
|
|
1034
|
+
if (xrpPay) {
|
|
1035
|
+
return await signRecordAndSubmit(client, walletSign, opts, (0, xrp_payment_1.buildXrpPaymentTx)(address, xrpPay), appId);
|
|
1036
|
+
}
|
|
790
1037
|
const { issuer, balance } = await readDepositHstLine(client, deposit.walletAddress);
|
|
791
1038
|
// #3771 — the LEDGER is the one source of truth every cluster agrees on: a deposit
|
|
792
1039
|
// account that already holds what this quote asks has been paid, whatever a replica's
|
|
@@ -802,25 +1049,7 @@ async function payDeposit(opts, address, seed, deposit) {
|
|
|
802
1049
|
SendMax: { currency: 'HST', issuer, value: sendMax },
|
|
803
1050
|
...(deposit.destinationTag !== undefined ? { DestinationTag: deposit.destinationTag } : {}),
|
|
804
1051
|
};
|
|
805
|
-
|
|
806
|
-
const txBlob = walletSign(prepared);
|
|
807
|
-
let result;
|
|
808
|
-
try {
|
|
809
|
-
result = await client.submitAndWait(txBlob);
|
|
810
|
-
}
|
|
811
|
-
catch (err) {
|
|
812
|
-
// The blob has left this process: the ledger may still validate it.
|
|
813
|
-
throw new PaymentOutcomeUnknownError(err);
|
|
814
|
-
}
|
|
815
|
-
const code = result.result?.meta?.TransactionResult;
|
|
816
|
-
if (code === undefined) {
|
|
817
|
-
// No verdict in the answer: not a failure the ledger reported.
|
|
818
|
-
throw new PaymentOutcomeUnknownError(new Error('deposit Payment came back with no transaction result'));
|
|
819
|
-
}
|
|
820
|
-
if (code !== 'tesSUCCESS') {
|
|
821
|
-
throw new Error(`deposit Payment failed: ${code}`);
|
|
822
|
-
}
|
|
823
|
-
return { hash: result.result?.hash };
|
|
1052
|
+
return await signRecordAndSubmit(client, walletSign, opts, tx, appId);
|
|
824
1053
|
}
|
|
825
1054
|
finally {
|
|
826
1055
|
// A failing disconnect (a dead socket) must not replace the error that got us here — above all
|
|
@@ -828,6 +1057,41 @@ async function payDeposit(opts, address, seed, deposit) {
|
|
|
828
1057
|
await client.disconnect().catch(() => undefined);
|
|
829
1058
|
}
|
|
830
1059
|
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Autofill, sign, RECORD and submit a deposit Payment, and require `tesSUCCESS` (shared by the HST and the
|
|
1062
|
+
* XRP deposit). The signed hash is recorded BEFORE the blob leaves this process (as the pending create is,
|
|
1063
|
+
* #3766): from here on a crash, a timeout or a requote cannot make a later run forget it may already have
|
|
1064
|
+
* paid. A thrown wait for the verdict (the blob is out) is {@link PaymentOutcomeUnknownError}; a `tec*` /
|
|
1065
|
+
* `tem*` verdict is a plain failure: nothing was delivered.
|
|
1066
|
+
*/
|
|
1067
|
+
async function signRecordAndSubmit(client, walletSign, opts, tx, appId) {
|
|
1068
|
+
const prepared = await client.autofill(tx);
|
|
1069
|
+
const txBlob = walletSign(prepared);
|
|
1070
|
+
(0, payment_guard_1.recordPendingPayment)(opts.env, {
|
|
1071
|
+
appId,
|
|
1072
|
+
txHash: (opts.hashSignedTx ?? defaultHashSignedTx)(txBlob),
|
|
1073
|
+
...(typeof prepared.LastLedgerSequence === 'number'
|
|
1074
|
+
? { lastLedgerSequence: prepared.LastLedgerSequence }
|
|
1075
|
+
: {}),
|
|
1076
|
+
}, payment_record_1.PENDING_PAYMENT_KEY);
|
|
1077
|
+
let result;
|
|
1078
|
+
try {
|
|
1079
|
+
result = await client.submitAndWait(txBlob);
|
|
1080
|
+
}
|
|
1081
|
+
catch (err) {
|
|
1082
|
+
// The blob has left this process: the ledger may still validate it.
|
|
1083
|
+
throw new payment_guard_1.PaymentOutcomeUnknownError(err);
|
|
1084
|
+
}
|
|
1085
|
+
const code = result.result?.meta?.TransactionResult;
|
|
1086
|
+
if (code === undefined) {
|
|
1087
|
+
// No verdict in the answer: not a failure the ledger reported.
|
|
1088
|
+
throw new payment_guard_1.PaymentOutcomeUnknownError(new Error('deposit Payment came back with no transaction result'));
|
|
1089
|
+
}
|
|
1090
|
+
if (code !== 'tesSUCCESS') {
|
|
1091
|
+
throw new Error(`deposit Payment failed: ${code}`);
|
|
1092
|
+
}
|
|
1093
|
+
return { hash: result.result?.hash };
|
|
1094
|
+
}
|
|
831
1095
|
/**
|
|
832
1096
|
* Read the deposit account's HST trust line: the HST issuer and what the account holds.
|
|
833
1097
|
*
|
|
@@ -919,7 +1183,17 @@ async function pollStatus(client, appId, sleep, opts, done, maxAttempts) {
|
|
|
919
1183
|
// wall-clock deadline — whichever comes first.
|
|
920
1184
|
let attempt = 0;
|
|
921
1185
|
while (true) {
|
|
922
|
-
|
|
1186
|
+
// A node that has not replicated the row yet answers a retryable 503 (#4081): the same "not there yet" this loop
|
|
1187
|
+
// already waits through when it is told `not_found`.
|
|
1188
|
+
let status;
|
|
1189
|
+
try {
|
|
1190
|
+
status = await client.status(appId);
|
|
1191
|
+
}
|
|
1192
|
+
catch (err) {
|
|
1193
|
+
if (!(0, subscription_client_1.isSubscriptionNotReplicatedYet)(err))
|
|
1194
|
+
throw err;
|
|
1195
|
+
status = (0, subscription_client_1.notYetReplicatedStatus)(appId);
|
|
1196
|
+
}
|
|
923
1197
|
if (done(status))
|
|
924
1198
|
return status;
|
|
925
1199
|
attempt += 1;
|
|
@@ -965,7 +1239,7 @@ async function acceptSubscriptionNft(opts, address, seed, sleep, status) {
|
|
|
965
1239
|
// Explicit override wins; otherwise use the issuer the status now exposes.
|
|
966
1240
|
const issuer = opts.nftIssuer ?? xrplNft?.issuerAddress;
|
|
967
1241
|
const client = (opts.xrplClientFactory ?? defaultXrplClientFactory)(XRPL_TESTNET_WSS);
|
|
968
|
-
const walletSign = (opts.walletSignFactory ??
|
|
1242
|
+
const walletSign = (opts.walletSignFactory ?? xrpl_login_signer_1.buildXrplTxSigner)(seed);
|
|
969
1243
|
const attempts = opts.acceptAttempts ?? 10;
|
|
970
1244
|
const retryMs = opts.acceptRetryMs ?? opts.pollIntervalMs ?? 5000;
|
|
971
1245
|
await client.connect();
|
|
@@ -1073,15 +1347,27 @@ function renderDepositInstructions(d, tier, appId) {
|
|
|
1073
1347
|
if (tier)
|
|
1074
1348
|
console.log(chalk_1.default.gray(` tier: ${tier}`));
|
|
1075
1349
|
console.log(chalk_1.default.gray(` chain: ${d.chain}`));
|
|
1350
|
+
// #3699 PR3 — paid through a swap: what to SEND is the source asset, to the provider.
|
|
1351
|
+
const swapPay = (0, swap_payment_1.swapPaymentOf)(d);
|
|
1352
|
+
if (swapPay) {
|
|
1353
|
+
(0, swap_payment_1.renderSwapPayment)(swapPay);
|
|
1354
|
+
renderReserveSurcharge(d);
|
|
1355
|
+
console.log('');
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
const xrpPay = (0, xrp_payment_1.xrpPaymentOf)(d);
|
|
1359
|
+
if (xrpPay) {
|
|
1360
|
+
// #3699 PR2 — priced in XRP: what to SEND is the XRP payment; the HST lines say what it becomes.
|
|
1361
|
+
(0, xrp_payment_1.renderXrpPayment)(d, xrpPay);
|
|
1362
|
+
renderReserveSurcharge(d);
|
|
1363
|
+
(0, order_deadline_1.renderOrderDeadline)(d);
|
|
1364
|
+
console.log('');
|
|
1365
|
+
return;
|
|
1366
|
+
}
|
|
1076
1367
|
console.log(chalk_1.default.gray(` amount: ${d.amount} HST (token ${d.tokenId})`));
|
|
1077
1368
|
renderReserveSurcharge(d);
|
|
1078
1369
|
console.log(chalk_1.default.gray(` to: ${d.walletAddress}`));
|
|
1079
|
-
|
|
1080
|
-
// wallet whose "destination tag" field was left empty) is not attributed to this order.
|
|
1081
|
-
// `!== undefined`, not truthiness: 0 is a valid tag.
|
|
1082
|
-
if (d.destinationTag !== undefined) {
|
|
1083
|
-
console.log(chalk_1.default.gray(` tag: ${d.destinationTag} (Destination Tag — REQUIRED on the payment)`));
|
|
1084
|
-
}
|
|
1370
|
+
(0, order_deadline_1.renderDestinationTag)(d); // #3765
|
|
1085
1371
|
(0, order_deadline_1.renderOrderDeadline)(d);
|
|
1086
1372
|
console.log('');
|
|
1087
1373
|
}
|
|
@@ -1099,6 +1385,9 @@ function renderReserveSurcharge(d) {
|
|
|
1099
1385
|
function renderManualPaymentHint(d) {
|
|
1100
1386
|
const xummDeeplink = buildXummDeeplink(d);
|
|
1101
1387
|
console.log(chalk_1.default.cyan(' --no-autopay: pay the deposit manually, then re-run `hsuite subscribe`.'));
|
|
1388
|
+
if ((0, xrp_payment_1.xrpPaymentOf)(d)) {
|
|
1389
|
+
console.log(chalk_1.default.cyan(' Send the XRP amount above with the Destination Tag — without the tag it is not matched to your order.'));
|
|
1390
|
+
}
|
|
1102
1391
|
console.log(chalk_1.default.cyan(' XUMM deeplink:'));
|
|
1103
1392
|
console.log(chalk_1.default.cyan(` ${xummDeeplink}\n`));
|
|
1104
1393
|
}
|
|
@@ -1106,11 +1395,14 @@ function buildXummDeeplink(d) {
|
|
|
1106
1395
|
if (d.chain !== 'xrpl') {
|
|
1107
1396
|
return `(no deeplink: chain=${d.chain})`;
|
|
1108
1397
|
}
|
|
1398
|
+
// #3699 PR2 — an XRP order is paid in plain XRP (drops converted to XRP in the link), tag included.
|
|
1399
|
+
const xrpPay = (0, xrp_payment_1.xrpPaymentOf)(d);
|
|
1400
|
+
if (xrpPay)
|
|
1401
|
+
return (0, xrp_payment_1.xrpSendDeeplink)(xrpPay);
|
|
1109
1402
|
// Minimal Xumm deeplink shape; full IssuedCurrency requires a JSON payload
|
|
1110
1403
|
// pushed through https://xumm.app/sign — for the CLI we surface the raw tx
|
|
1111
1404
|
// params so the user can paste them into their wallet.
|
|
1112
|
-
|
|
1113
|
-
return `xumm://xrpl/send?to=${encodeURIComponent(d.walletAddress)}&amount=${encodeURIComponent(d.amount)}&token=${encodeURIComponent(d.tokenId)}${tag}`;
|
|
1405
|
+
return (0, order_deadline_1.xummSendDeeplink)(d);
|
|
1114
1406
|
}
|
|
1115
1407
|
exports.subscribeCommand = new commander_1.Command('subscribe')
|
|
1116
1408
|
.description('Subscribe a smart-app: create DKG entity → auto-pay deposit → mint → accept subscription NFT (mint-first)')
|
|
@@ -1119,7 +1411,17 @@ exports.subscribeCommand = new commander_1.Command('subscribe')
|
|
|
1119
1411
|
.option('--tier <tier>', 'Subscription tier (builder|growth|scale|enterprise)', 'builder')
|
|
1120
1412
|
.option('--app-id <id>', 'Resume an already-created entity by its appId (defaults to SUBSCRIPTION_APP_ID env). When unset, subscribe CREATES the DKG entity and uses its entityId.')
|
|
1121
1413
|
.option('--app-name <name>', 'Smart-app display name')
|
|
1122
|
-
.option('--no-autopay', 'Skip auto-paying the
|
|
1414
|
+
.option('--no-autopay', 'Skip auto-paying the deposit; print instructions for manual (XUMM) payment')
|
|
1415
|
+
.option('--pay-with <asset>', 'Asset to pay the subscription in: hsuite (default), xrp, or a swap asset such as btc, eth, usdt (see ' +
|
|
1416
|
+
'GET /api/v3/subscription/payment-assets for what the network offers). With xrp the validator quotes the price in ' +
|
|
1417
|
+
'XRP (the HST/XRP market plus a buffer) and the deposit is an XRP payment of the quoted amount with the order\'s ' +
|
|
1418
|
+
'Destination Tag; the platform converts it into HST inside the deposit account. With a swap asset the validator ' +
|
|
1419
|
+
'opens a fixed-rate exchange at a swap provider and prints where YOU send the asset (--refund-address is required): ' +
|
|
1420
|
+
'this command never pays it. A validator with that payment off, or no HST/XRP market, refuses, and nothing is created.')
|
|
1421
|
+
.option('--pay-network <network>', 'Swap assets only: the network the --pay-with ticker travels on when it has several (e.g. --pay-with usdt --pay-network trx).')
|
|
1422
|
+
.option('--refund-address <address>', 'REQUIRED for a swap asset (--pay-with btc, eth, usdt, ...): YOUR address on that asset\'s network, where the swap ' +
|
|
1423
|
+
'provider returns your funds if the swap cannot complete. The CLI cannot send these assets: it prints where YOU send them.')
|
|
1424
|
+
.option('--refund-extra-id <memo>', 'Swap assets only: the memo / tag of --refund-address, for an asset whose addresses take one (XLM, ATOM, ...).')
|
|
1123
1425
|
.option('--nft-issuer <address>', 'Optional override for the XRPL subscription-NFT issuer. No longer required: the /status response now exposes chainNfts.xrpl (nftId + issuerAddress) and the offer is resolved from it automatically. Defaults to SUBSCRIPTION_NFT_ISSUER env.')
|
|
1124
1426
|
.action(async (opts) => {
|
|
1125
1427
|
console.log(chalk_1.default.bold.cyan('\n hsuite subscribe\n'));
|
|
@@ -1138,11 +1440,17 @@ exports.subscribeCommand = new commander_1.Command('subscribe')
|
|
|
1138
1440
|
result = await runSubscribe(opts);
|
|
1139
1441
|
}
|
|
1140
1442
|
catch (err) {
|
|
1141
|
-
spinner.fail(errorMessage(err));
|
|
1443
|
+
spinner.fail((0, error_message_1.errorMessage)(err));
|
|
1142
1444
|
process.exit(1);
|
|
1143
1445
|
}
|
|
1144
1446
|
if (!result.depositPaid) {
|
|
1145
|
-
spinner.info(
|
|
1447
|
+
spinner.info(result.swapPaymentCounted
|
|
1448
|
+
? `subscription requested (appId=${result.appId}) — your swap payment is counted, converting`
|
|
1449
|
+
: result.awaitingSwapPayment
|
|
1450
|
+
? `subscription requested (appId=${result.appId}) — waiting for YOUR swap payment (see above)`
|
|
1451
|
+
: result.awaitingSwapRemainder
|
|
1452
|
+
? `subscription requested (appId=${result.appId}) — waiting for the XRP remainder of your swap payment (see above)`
|
|
1453
|
+
: `subscription requested (appId=${result.appId}) — deposit not paid (--no-autopay)`);
|
|
1146
1454
|
const updates = {
|
|
1147
1455
|
SUBSCRIPTION_APP_ID: result.appId,
|
|
1148
1456
|
APP_ID: result.appId,
|
|
@@ -1150,7 +1458,13 @@ exports.subscribeCommand = new commander_1.Command('subscribe')
|
|
|
1150
1458
|
if (saveEnv(opts.env, updates)) {
|
|
1151
1459
|
console.log(chalk_1.default.gray(`\n wrote SUBSCRIPTION_APP_ID to ${opts.env}`));
|
|
1152
1460
|
}
|
|
1153
|
-
console.log(chalk_1.default.yellow(
|
|
1461
|
+
console.log(chalk_1.default.yellow(result.swapPaymentCounted
|
|
1462
|
+
? '\n Wait for the conversion, then re-run `hsuite subscribe` to mint + accept the NFT.\n'
|
|
1463
|
+
: result.awaitingSwapPayment
|
|
1464
|
+
? '\n Send the swap payment from your own wallet, then re-run `hsuite subscribe` to mint + accept the NFT.\n'
|
|
1465
|
+
: result.awaitingSwapRemainder
|
|
1466
|
+
? '\n Send the XRP remainder from your own wallet (or re-run with `--pay-with xrp` to have this CLI pay it), then re-run `hsuite subscribe` to mint + accept the NFT.\n'
|
|
1467
|
+
: '\n Pay the deposit, then re-run `hsuite subscribe` to mint + accept the NFT.\n'));
|
|
1154
1468
|
return;
|
|
1155
1469
|
}
|
|
1156
1470
|
spinner.succeed(`subscription active (appId=${result.appId})`);
|