@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.
Files changed (101) hide show
  1. package/README.md +4 -2
  2. package/dist/_lib/cluster-convergence.d.ts.map +1 -1
  3. package/dist/_lib/cluster-convergence.js +1 -1
  4. package/dist/_lib/cluster-convergence.js.map +1 -1
  5. package/dist/_lib/deposit-verification.d.ts +91 -0
  6. package/dist/_lib/deposit-verification.d.ts.map +1 -0
  7. package/dist/_lib/deposit-verification.js +265 -0
  8. package/dist/_lib/deposit-verification.js.map +1 -0
  9. package/dist/_lib/env.d.ts.map +1 -1
  10. package/dist/_lib/env.js +9 -7
  11. package/dist/_lib/env.js.map +1 -1
  12. package/dist/_lib/error-message.d.ts +7 -0
  13. package/dist/_lib/error-message.d.ts.map +1 -0
  14. package/dist/_lib/error-message.js +21 -0
  15. package/dist/_lib/error-message.js.map +1 -0
  16. package/dist/_lib/order-deadline.d.ts +23 -0
  17. package/dist/_lib/order-deadline.d.ts.map +1 -1
  18. package/dist/_lib/order-deadline.js +40 -6
  19. package/dist/_lib/order-deadline.js.map +1 -1
  20. package/dist/_lib/payment-guard.d.ts +59 -0
  21. package/dist/_lib/payment-guard.d.ts.map +1 -0
  22. package/dist/_lib/payment-guard.js +188 -0
  23. package/dist/_lib/payment-guard.js.map +1 -0
  24. package/dist/_lib/payment-lock.d.ts +27 -0
  25. package/dist/_lib/payment-lock.d.ts.map +1 -0
  26. package/dist/_lib/payment-lock.js +199 -0
  27. package/dist/_lib/payment-lock.js.map +1 -0
  28. package/dist/_lib/payment-record.d.ts +76 -0
  29. package/dist/_lib/payment-record.d.ts.map +1 -0
  30. package/dist/_lib/payment-record.js +84 -0
  31. package/dist/_lib/payment-record.js.map +1 -0
  32. package/dist/_lib/runtime-env.d.ts.map +1 -1
  33. package/dist/_lib/runtime-env.js +5 -0
  34. package/dist/_lib/runtime-env.js.map +1 -1
  35. package/dist/_lib/subscription-client.d.ts +192 -15
  36. package/dist/_lib/subscription-client.d.ts.map +1 -1
  37. package/dist/_lib/subscription-client.js +44 -2
  38. package/dist/_lib/subscription-client.js.map +1 -1
  39. package/dist/_lib/swap-payment.d.ts +54 -0
  40. package/dist/_lib/swap-payment.d.ts.map +1 -0
  41. package/dist/_lib/swap-payment.js +203 -0
  42. package/dist/_lib/swap-payment.js.map +1 -0
  43. package/dist/_lib/xrp-payment.d.ts +48 -0
  44. package/dist/_lib/xrp-payment.d.ts.map +1 -0
  45. package/dist/_lib/xrp-payment.js +117 -0
  46. package/dist/_lib/xrp-payment.js.map +1 -0
  47. package/dist/_lib/xrpl-login-signer.d.ts +16 -1
  48. package/dist/_lib/xrpl-login-signer.d.ts.map +1 -1
  49. package/dist/_lib/xrpl-login-signer.js +25 -1
  50. package/dist/_lib/xrpl-login-signer.js.map +1 -1
  51. package/dist/commands/billing.d.ts +5 -3
  52. package/dist/commands/billing.d.ts.map +1 -1
  53. package/dist/commands/billing.js +12 -6
  54. package/dist/commands/billing.js.map +1 -1
  55. package/dist/commands/deploy.d.ts +1 -1
  56. package/dist/commands/deploy.js +2 -2
  57. package/dist/commands/deploy.js.map +1 -1
  58. package/dist/commands/faucet.d.ts +1 -1
  59. package/dist/commands/faucet.d.ts.map +1 -1
  60. package/dist/commands/faucet.js +2 -7
  61. package/dist/commands/faucet.js.map +1 -1
  62. package/dist/commands/list.d.ts.map +1 -1
  63. package/dist/commands/list.js +4 -2
  64. package/dist/commands/list.js.map +1 -1
  65. package/dist/commands/redeploy.d.ts +4 -3
  66. package/dist/commands/redeploy.d.ts.map +1 -1
  67. package/dist/commands/redeploy.js +5 -4
  68. package/dist/commands/redeploy.js.map +1 -1
  69. package/dist/commands/renew.d.ts +47 -4
  70. package/dist/commands/renew.d.ts.map +1 -1
  71. package/dist/commands/renew.js +338 -9
  72. package/dist/commands/renew.js.map +1 -1
  73. package/dist/commands/status.d.ts.map +1 -1
  74. package/dist/commands/status.js +22 -2
  75. package/dist/commands/status.js.map +1 -1
  76. package/dist/commands/subscribe.d.ts +39 -3
  77. package/dist/commands/subscribe.d.ts.map +1 -1
  78. package/dist/commands/subscribe.js +424 -110
  79. package/dist/commands/subscribe.js.map +1 -1
  80. package/dist/commands/topup.d.ts +33 -7
  81. package/dist/commands/topup.d.ts.map +1 -1
  82. package/dist/commands/topup.js +148 -16
  83. package/dist/commands/topup.js.map +1 -1
  84. package/dist/commands/upgrade.d.ts +7 -0
  85. package/dist/commands/upgrade.d.ts.map +1 -1
  86. package/dist/commands/upgrade.js +35 -5
  87. package/dist/commands/upgrade.js.map +1 -1
  88. package/dist/commands/verify.d.ts.map +1 -1
  89. package/dist/commands/verify.js +8 -2
  90. package/dist/commands/verify.js.map +1 -1
  91. package/dist/index.d.ts +1 -1
  92. package/dist/index.js +1 -1
  93. package/package.json +9 -9
  94. package/dist/__tests__/helpers/fixtures-image-hygiene.d.ts +0 -18
  95. package/dist/__tests__/helpers/fixtures-image-hygiene.d.ts.map +0 -1
  96. package/dist/__tests__/helpers/fixtures-image-hygiene.js +0 -42
  97. package/dist/__tests__/helpers/fixtures-image-hygiene.js.map +0 -1
  98. package/dist/__tests__/helpers/fixtures.d.ts +0 -48
  99. package/dist/__tests__/helpers/fixtures.d.ts.map +0 -1
  100. package/dist/__tests__/helpers/fixtures.js +0 -79
  101. package/dist/__tests__/helpers/fixtures.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"subscription-client.js","sourceRoot":"","sources":["../../src/_lib/subscription-client.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,iEAOmC;AAGnC,2CAAmD;AACnD,2DAA2D;AAuO3D;;;;;;;;GAQG;AACH,MAAa,kBAAkB;IAC7B,iFAAiF;IAChE,MAAM,CAAS;IACf,GAAG,CAAwB;IAC3B,IAAI,CAAa;IACjB,IAAI,CAAoD;IAEzE,YAAY,IAA+B;QACzC,IAAI,CAAC,MAAM,GAAG,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AAE,IAAI,CAAC;QAC9C,IAAI,EAAE,CAAI,IAAY,EAAE,CAAU,EAAE,EAAE,CAAC,IAAI,CAAI,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,GAAG,EAAE,WAAW,CAAC,KAAK,CAAsB;QAC5C,KAAK,EAAE,WAAW,CAAC,OAAO,CAAwB;QAClD,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAyB;QACrD,OAAO,EAAE,WAAW,CAAC,SAAS,CAA0B;QACxD,SAAS,EAAE,WAAW,CAAC,WAAW,CAA4B;QAC9D,iBAAiB,EAAE,WAAW,CAAC,mBAAmB,CAAoC;QACtF,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAyB;QACrD,YAAY,EAAE,CAAC,CAAqB,EAAE,EAAE;YACtC,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;QACD,YAAY,EAAE,GAAG,EAAE,CAAC,KAAK;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,54 @@
1
+ import type { DepositInstructions, PaymentAssetOption, SwapPaymentInstruction } from './subscription-client';
2
+ /** What the builder asked for, to check the answer against. */
3
+ export type SwapAsk = {
4
+ ticker: string;
5
+ network?: string;
6
+ refundAddress: string;
7
+ refundExtraId?: string;
8
+ };
9
+ /** The swap instruction of a deposit, or `undefined` when the order is not paid through a swap. */
10
+ export declare function swapPaymentOf(deposit: Pick<DepositInstructions, 'swap'>): SwapPaymentInstruction | undefined;
11
+ /**
12
+ * Check a swap instruction before it is shown. `ask` is what this run asked for (absent on a resume that named
13
+ * no asset: the stored instructions are then the contract, and are only checked for being well-formed).
14
+ */
15
+ export declare function assertSwapPaymentConsistent(swap: SwapPaymentInstruction, ask: SwapAsk | undefined): void;
16
+ /**
17
+ * Never put a lapsed quote's payin address in front of a payer: the provider no longer honours its price. The
18
+ * platform opens a NEW exchange for a lapsed quote when the builder re-runs and names the asset and the SAME
19
+ * refund address again (and only while the provider does not report a payment to the old one as received), so the
20
+ * refusal says exactly that. The command it suggests is built from the validator's answer, so every value in it is
21
+ * quoted.
22
+ */
23
+ export declare function assertSwapQuoteLive(swap: SwapPaymentInstruction): void;
24
+ /** Has the platform already counted the builder's swap payment (the order is `paid` or `converting`)? Then nothing is to be sent. */
25
+ export declare function swapPaymentCounted(swap: Pick<SwapPaymentInstruction, 'status'>): boolean;
26
+ /** The payment lines of a swap order's instructions. */
27
+ export declare function renderSwapPayment(swap: SwapPaymentInstruction): void;
28
+ /**
29
+ * Find the asset a builder asked to pay in among what `GET /subscription/payment-assets` offers, and refuse,
30
+ * before anything is created, what the validator would refuse: an asset it does not offer (or no swap
31
+ * payments at all), a ticker on several networks with none named, and an asset whose refund address needs a
32
+ * memo that was not given. Returns the listing entry, whose `network` is the one to send.
33
+ */
34
+ export declare function resolveSwapListing(assets: readonly PaymentAssetOption[], ask: SwapAsk): PaymentAssetOption;
35
+ /**
36
+ * The swap fields of a smart-app create (`POST /api/v3/smart-apps`): the asset as a symbol, the network it
37
+ * travels on (the listing's, else the one asked for), and the builder's refund address and memo.
38
+ */
39
+ export declare function swapCreateFields(ask: SwapAsk, listing?: Pick<PaymentAssetOption, 'network'>): {
40
+ paymentAsset: string;
41
+ paymentNetwork?: string;
42
+ refundAddress: string;
43
+ refundExtraId?: string;
44
+ };
45
+ /** The same fields in the shape of a subscription request (`POST /api/v3/subscription/request`). */
46
+ export declare function swapRequestFields(ask: SwapAsk, listing?: Pick<PaymentAssetOption, 'network'>): {
47
+ paymentAsset: {
48
+ symbol: string;
49
+ network?: string;
50
+ };
51
+ refundAddress: string;
52
+ refundExtraId?: string;
53
+ };
54
+ //# sourceMappingURL=swap-payment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swap-payment.d.ts","sourceRoot":"","sources":["../../src/_lib/swap-payment.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE7G,+DAA+D;AAC/D,MAAM,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EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,CAOvG"}
@@ -0,0 +1,203 @@
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.swapPaymentOf = swapPaymentOf;
7
+ exports.assertSwapPaymentConsistent = assertSwapPaymentConsistent;
8
+ exports.assertSwapQuoteLive = assertSwapQuoteLive;
9
+ exports.swapPaymentCounted = swapPaymentCounted;
10
+ exports.renderSwapPayment = renderSwapPayment;
11
+ exports.resolveSwapListing = resolveSwapListing;
12
+ exports.swapCreateFields = swapCreateFields;
13
+ exports.swapRequestFields = swapRequestFields;
14
+ /**
15
+ * #3699 PR3 — paying a subscription in another asset (`hsuite subscribe --pay-with btc`).
16
+ *
17
+ * The validator opens a fixed-rate exchange at a swap provider that lands the order's exact XRP due on the
18
+ * subscription's deposit account, and answers `depositInstructions.swap`: what the BUILDER must send, to which
19
+ * provider address, until when, and the refund address the provider returns the funds to. This CLI holds an XRPL
20
+ * key, not a BTC one: it cannot spend those assets and NEVER tries. It checks what it is told, prints it for a
21
+ * human who sends the funds from their own wallet, and stops (the same exit as `--no-autopay`); re-running
22
+ * `hsuite subscribe` once the platform has counted the payment mints the NFT.
23
+ *
24
+ * It shows a human where to send real money, so it refuses an instruction that names another asset than the one
25
+ * asked for, a REFUND address that is not the builder's own (a hostile validator would keep the refund), a
26
+ * payin address or memo that is not a plain token, an amount it cannot read, or a quote past its deadline.
27
+ */
28
+ const chalk_1 = __importDefault(require("chalk"));
29
+ /** The swap instruction of a deposit, or `undefined` when the order is not paid through a swap. */
30
+ function swapPaymentOf(deposit) {
31
+ return deposit.swap;
32
+ }
33
+ const show = (value) => JSON.stringify(String(value).slice(0, 60));
34
+ /** Printable, no whitespace: what an address or a memo is made of. */
35
+ const ADDRESS = /^[\x21-\x7e]{1,256}$/;
36
+ const EXTRA_ID = /^[\x21-\x7e]{1,128}$/;
37
+ const SLUG = /^[A-Za-z0-9]{1,32}$/;
38
+ const PROVIDER = /^[a-z0-9_-]{1,32}$/;
39
+ const POSITIVE_DECIMAL = /^(?=.*[1-9])\d+(\.\d+)?$/;
40
+ /**
41
+ * Check a swap instruction before it is shown. `ask` is what this run asked for (absent on a resume that named
42
+ * no asset: the stored instructions are then the contract, and are only checked for being well-formed).
43
+ */
44
+ function assertSwapPaymentConsistent(swap, ask) {
45
+ const refuse = (why) => {
46
+ throw new Error(`the swap payment instruction ${why} — nothing was paid`);
47
+ };
48
+ if (typeof swap.payinAddress !== 'string' || !ADDRESS.test(swap.payinAddress)) {
49
+ refuse(`names a payin address that is not a plain address (${show(swap.payinAddress)})`);
50
+ }
51
+ if (swap.payinExtraId !== undefined && (typeof swap.payinExtraId !== 'string' || !EXTRA_ID.test(swap.payinExtraId))) {
52
+ refuse(`names a payin memo that is not a plain token (${show(swap.payinExtraId)})`);
53
+ }
54
+ if (typeof swap.amount !== 'string' || !POSITIVE_DECIMAL.test(swap.amount) || swap.amount.length > 40) {
55
+ refuse(`names an amount that is not a positive plain decimal (${show(swap.amount)})`);
56
+ }
57
+ if (typeof swap.asset !== 'string' || !SLUG.test(swap.asset) || typeof swap.network !== 'string' || !SLUG.test(swap.network)) {
58
+ refuse(`names an asset or network that is not a plain ticker (${show(swap.asset)} on ${show(swap.network)})`);
59
+ }
60
+ if (typeof swap.validUntil !== 'string' || Number.isNaN(new Date(swap.validUntil).getTime())) {
61
+ refuse(`names a deadline that cannot be read (${show(swap.validUntil)})`);
62
+ }
63
+ if (typeof swap.refundAddress !== 'string' || !ADDRESS.test(swap.refundAddress)) {
64
+ refuse(`names a refund address that is not a plain address (${show(swap.refundAddress)})`);
65
+ }
66
+ // Everything below is PRINTED to a terminal: a hostile validator must not smuggle escape sequences in.
67
+ if (swap.refundExtraId !== undefined && (typeof swap.refundExtraId !== 'string' || !EXTRA_ID.test(swap.refundExtraId))) {
68
+ refuse(`names a refund memo that is not a plain token (${show(swap.refundExtraId)})`);
69
+ }
70
+ if (typeof swap.provider !== 'string' || !PROVIDER.test(swap.provider)) {
71
+ refuse(`names a provider that is not a plain name (${show(swap.provider)})`);
72
+ }
73
+ if (typeof swap.toAmountXrp !== 'string' || !POSITIVE_DECIMAL.test(swap.toAmountXrp) || swap.toAmountXrp.length > 40) {
74
+ refuse(`names a payout that is not a positive plain decimal (${show(swap.toAmountXrp)})`);
75
+ }
76
+ if (!ask)
77
+ return;
78
+ if (swap.asset.toLowerCase() !== ask.ticker.toLowerCase()) {
79
+ refuse(`is for ${show(swap.asset)}, not the ${show(ask.ticker.toUpperCase())} that was asked for`);
80
+ }
81
+ if (ask.network !== undefined && swap.network.toLowerCase() !== ask.network.toLowerCase()) {
82
+ refuse(`is for the network ${show(swap.network)}, not the ${show(ask.network)} that was asked for`);
83
+ }
84
+ // The refund goes where the BUILDER said, or the funds of a failed swap are not theirs.
85
+ if (swap.refundAddress !== ask.refundAddress) {
86
+ refuse(`refunds to ${show(swap.refundAddress)}, not the refund address you gave (${show(ask.refundAddress)})`);
87
+ }
88
+ if ((swap.refundExtraId ?? undefined) !== (ask.refundExtraId ?? undefined)) {
89
+ refuse(`refunds with the memo ${show(swap.refundExtraId)}, not the one you gave (${show(ask.refundExtraId)})`);
90
+ }
91
+ }
92
+ /** A value safe to paste into a shell as one word: plain characters as they are, anything else single-quoted. */
93
+ function shellWord(value) {
94
+ return /^[A-Za-z0-9._:/@-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
95
+ }
96
+ /**
97
+ * Never put a lapsed quote's payin address in front of a payer: the provider no longer honours its price. The
98
+ * platform opens a NEW exchange for a lapsed quote when the builder re-runs and names the asset and the SAME
99
+ * refund address again (and only while the provider does not report a payment to the old one as received), so the
100
+ * refusal says exactly that. The command it suggests is built from the validator's answer, so every value in it is
101
+ * quoted.
102
+ */
103
+ function assertSwapQuoteLive(swap) {
104
+ if (new Date(swap.validUntil).getTime() > Date.now())
105
+ return;
106
+ const command = [
107
+ 'hsuite subscribe',
108
+ `--pay-with ${shellWord(swap.asset.toLowerCase())}`,
109
+ `--pay-network ${shellWord(swap.network)}`,
110
+ `--refund-address ${shellWord(swap.refundAddress)}`,
111
+ ...(swap.refundExtraId !== undefined ? [`--refund-extra-id ${shellWord(swap.refundExtraId)}`] : []),
112
+ ].join(' ');
113
+ throw new Error(`the swap quote for ${swap.asset} expired at ${new Date(swap.validUntil).toLocaleString()}: do NOT send anything to ` +
114
+ `${swap.payinAddress} (the provider no longer honours its price). ` +
115
+ `To be offered a NEW quote, re-run \`${command}\`: the platform opens a new exchange for the same deposit account ` +
116
+ 'once this one has lapsed unpaid, and this CLI prints where to send it (it never pays). ' +
117
+ 'If you ALREADY sent it in time, do nothing: the provider\'s payout is still honoured for a few hours after the deadline, ' +
118
+ 'the platform opens no new quote while the provider reports your payment as received, and re-running `hsuite subscribe` later picks it up.');
119
+ }
120
+ /** Has the platform already counted the builder's swap payment (the order is `paid` or `converting`)? Then nothing is to be sent. */
121
+ function swapPaymentCounted(swap) {
122
+ return swap.status === 'paid' || swap.status === 'converting';
123
+ }
124
+ /** The payment lines of a swap order's instructions. */
125
+ function renderSwapPayment(swap) {
126
+ const minutes = Math.max(0, Math.round((new Date(swap.validUntil).getTime() - Date.now()) / 60_000));
127
+ console.log(chalk_1.default.bold.yellow(`\n Send ${swap.amount} ${swap.asset} (network ${swap.network}) from your OWN wallet:`));
128
+ console.log(chalk_1.default.gray(` amount: ${swap.amount} ${swap.asset}`));
129
+ console.log(chalk_1.default.gray(` network: ${swap.network}`));
130
+ console.log(chalk_1.default.gray(` to: ${swap.payinAddress}`));
131
+ if (swap.payinExtraId !== undefined) {
132
+ console.log(chalk_1.default.gray(` memo: ${swap.payinExtraId} (REQUIRED on the payment — without it the provider cannot match it)`));
133
+ }
134
+ console.log(chalk_1.default.gray(` deadline: ${new Date(swap.validUntil).toLocaleString()} (${minutes} min remaining)`));
135
+ console.log(chalk_1.default.gray(` refund: ${swap.refundAddress}${swap.refundExtraId !== undefined ? ` (memo ${swap.refundExtraId})` : ''} — ` +
136
+ 'where the provider returns your funds if the swap cannot complete'));
137
+ console.log(chalk_1.default.gray(` the provider (${swap.provider}) lands ${swap.toAmountXrp} XRP on your deposit account; the platform converts it ` +
138
+ 'into your subscription deposit. Send exactly this amount, before the deadline.'));
139
+ console.log(chalk_1.default.cyan(' hsuite does not send this for you: it holds an XRPL key, not a key for this asset.'));
140
+ }
141
+ /** The most alternatives listed in a refusal. */
142
+ const MAX_LISTED = 24;
143
+ /**
144
+ * Find the asset a builder asked to pay in among what `GET /subscription/payment-assets` offers, and refuse,
145
+ * before anything is created, what the validator would refuse: an asset it does not offer (or no swap
146
+ * payments at all), a ticker on several networks with none named, and an asset whose refund address needs a
147
+ * memo that was not given. Returns the listing entry, whose `network` is the one to send.
148
+ */
149
+ function resolveSwapListing(assets, ask) {
150
+ const swaps = assets.filter((a) => a.kind === 'swap');
151
+ const ticker = ask.ticker.toLowerCase();
152
+ const T = ticker.toUpperCase();
153
+ const listed = swaps.filter((a) => a.symbol.toLowerCase() === ticker);
154
+ if (listed.length === 0) {
155
+ if (swaps.length === 0) {
156
+ throw new Error(`${T} cannot be paid: this network offers no swap payments (they are off, or no swap provider is configured). ` +
157
+ 'Pay in hsuite or xrp. Nothing was created.');
158
+ }
159
+ const names = [...new Set(swaps.map((a) => a.symbol))].slice(0, MAX_LISTED).join(', ');
160
+ throw new Error(`${T} is not offered for swap payments on this network. Offered: ${names}. Nothing was created.`);
161
+ }
162
+ let chosen;
163
+ if (ask.network !== undefined) {
164
+ chosen = listed.find((a) => a.network === ask.network.toLowerCase());
165
+ if (!chosen) {
166
+ throw new Error(`${T} is not offered on the network ${show(ask.network)} (offered on: ${listed.map((a) => a.network).join(', ')}). Nothing was created.`);
167
+ }
168
+ }
169
+ else if (listed.length === 1) {
170
+ chosen = listed[0];
171
+ }
172
+ else {
173
+ // Never guessed: a payment sent on another chain than the one the builder meant is lost.
174
+ throw new Error(`${T} travels on more than one network (${listed.map((a) => a.network).join(', ')}): say which with --pay-network. Nothing was created.`);
175
+ }
176
+ if (chosen.refundExtraIdRequired === true && ask.refundExtraId === undefined) {
177
+ throw new Error(`${T} refund addresses take a memo / tag: give yours with --refund-extra-id. Nothing was created.`);
178
+ }
179
+ return chosen;
180
+ }
181
+ /**
182
+ * The swap fields of a smart-app create (`POST /api/v3/smart-apps`): the asset as a symbol, the network it
183
+ * travels on (the listing's, else the one asked for), and the builder's refund address and memo.
184
+ */
185
+ function swapCreateFields(ask, listing) {
186
+ const network = listing?.network ?? ask.network;
187
+ return {
188
+ paymentAsset: ask.ticker.toUpperCase(),
189
+ ...(network !== undefined ? { paymentNetwork: network } : {}),
190
+ refundAddress: ask.refundAddress,
191
+ ...(ask.refundExtraId !== undefined ? { refundExtraId: ask.refundExtraId } : {}),
192
+ };
193
+ }
194
+ /** The same fields in the shape of a subscription request (`POST /api/v3/subscription/request`). */
195
+ function swapRequestFields(ask, listing) {
196
+ const network = listing?.network ?? ask.network;
197
+ return {
198
+ paymentAsset: { symbol: ask.ticker.toUpperCase(), ...(network !== undefined ? { network } : {}) },
199
+ refundAddress: ask.refundAddress,
200
+ ...(ask.refundExtraId !== undefined ? { refundExtraId: ask.refundExtraId } : {}),
201
+ };
202
+ }
203
+ //# sourceMappingURL=swap-payment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swap-payment.js","sourceRoot":"","sources":["../../src/_lib/swap-payment.ts"],"names":[],"mappings":";;;;;AAqBA,sCAEC;AAcD,kEA8CC;AAcD,kDAiBC;AAGD,gDAEC;AAGD,8CAuBC;AAWD,gDAmCC;AAMD,4CAWC;AAGD,8CAUC;AA7ND;;;;;;;;;;;;;GAaG;AACH,kDAA0B;AAM1B,mGAAmG;AACnG,SAAgB,aAAa,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C"}
@@ -0,0 +1,48 @@
1
+ import type { DepositInstructions } from './subscription-client';
2
+ /**
3
+ * What a subscription is paid in. `hsuite` is the default (HST, on XRPL its ledger code); `xrp` is paid by
4
+ * this CLI; `swap` is any other asset (BTC, ETH, ...), paid through a swap provider by the builder from their
5
+ * own wallet (#3699 PR3): the CLI prints where to send it and never pays it.
6
+ */
7
+ export type PayWith = 'hsuite' | 'xrp' | 'swap';
8
+ /** The values `--pay-with` accepts, for the option text and the refusal. */
9
+ export declare const PAY_WITH_VALUES: readonly ["hsuite", "xrp", "<swap asset: btc, eth, usdt, ...>"];
10
+ /** What `--pay-with` named: the kind, and for a swap the lower-case ticker. */
11
+ export type PayChoice = {
12
+ kind: PayWith;
13
+ asset?: string;
14
+ };
15
+ /**
16
+ * Parse `--pay-with` (case-insensitive; omitted = hsuite). `hsuite` / `hst` and `xrp` are themselves; any other
17
+ * ticker is a SWAP asset (the validator decides whether it is payable: see `GET /subscription/payment-assets`).
18
+ * Throws, before anything is sent, on a value that is not a ticker.
19
+ */
20
+ export declare function parsePayChoice(raw: string | undefined): PayChoice;
21
+ /** Parse `--pay-network` (a swap asset's network, e.g. `trx` for USDT): letters and digits, lower-cased. */
22
+ export declare function parsePayNetwork(raw: string | undefined): string | undefined;
23
+ /** The XRP instruction of a deposit, or `undefined` when the order is priced in HST. */
24
+ export type XrpPay = NonNullable<DepositInstructions['pay']>;
25
+ export declare function xrpPaymentOf(deposit: Pick<DepositInstructions, 'pay'>): XrpPay | undefined;
26
+ /**
27
+ * The CLI pays exactly what the response tells it to, so it checks what it is told before anything is signed
28
+ * or shown: the instruction pays the deposit account the SAME response names (a hostile validator or gateway
29
+ * cannot point the payment elsewhere), for a positive count of drops, with a 32-bit destination tag.
30
+ */
31
+ export declare function assertXrpPaymentConsistent(deposit: Pick<DepositInstructions, 'walletAddress'>, pay: XrpPay): void;
32
+ /**
33
+ * Drops (a plain integer string) as XRP, exact, with the trailing zeros dropped ('99960000000' → '99960',
34
+ * '1500000' → '1.5'). Throws on anything that is not a non-negative integer: an amount that cannot be read
35
+ * is never paid.
36
+ */
37
+ export declare function dropsToXrp(drops: string): string;
38
+ /**
39
+ * The Payment that pays an XRP order: XRP drops to the order's deposit account, with its Destination Tag.
40
+ * `Amount` is the drops STRING the quote asks, verbatim (never re-derived), and the tag is always present
41
+ * (`0` included): the platform attributes the payment by it.
42
+ */
43
+ export declare function buildXrpPaymentTx(account: string, pay: XrpPay): Record<string, unknown>;
44
+ /** The XUMM deeplink of an XRP order's payment: the tag rides it (`dt=`), `0` included. */
45
+ export declare function xrpSendDeeplink(pay: XrpPay): string;
46
+ /** The payment lines of an XRP order's instructions, in the style of the HST ones. */
47
+ export declare function renderXrpPayment(d: Pick<DepositInstructions, 'amount' | 'tokenId' | 'walletAddress'>, pay: XrpPay): void;
48
+ //# sourceMappingURL=xrp-payment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xrp-payment.d.ts","sourceRoot":"","sources":["../../src/_lib/xrp-payment.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAEhD,4EAA4E;AAC5E,eAAO,MAAM,eAAe,iEAAkE,CAAC;AAK/F,+EAA+E;AAC/E,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAOjE;AAED,4GAA4G;AAC5G,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAK3E;AAED,wFAAwF;AACxF,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7D,wBAAgB,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,GAAG,MAAM,GAAG,SAAS,CAE1F;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAWjH;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQvF;AAED,2FAA2F;AAC3F,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,SAAS,GAAG,eAAe,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAUxH"}
@@ -0,0 +1,117 @@
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.PAY_WITH_VALUES = void 0;
7
+ exports.parsePayChoice = parsePayChoice;
8
+ exports.parsePayNetwork = parsePayNetwork;
9
+ exports.xrpPaymentOf = xrpPaymentOf;
10
+ exports.assertXrpPaymentConsistent = assertXrpPaymentConsistent;
11
+ exports.dropsToXrp = dropsToXrp;
12
+ exports.buildXrpPaymentTx = buildXrpPaymentTx;
13
+ exports.xrpSendDeeplink = xrpSendDeeplink;
14
+ exports.renderXrpPayment = renderXrpPayment;
15
+ /**
16
+ * #3699 PR2 — paying a subscription in XRP (`hsuite subscribe --pay-with xrp`).
17
+ *
18
+ * The validator prices the order in XRP and says what to send in `depositInstructions.pay`: an XRP Payment
19
+ * of `pay.amount` DROPS to `pay.address` carrying `pay.destinationTag`. The tag is how the payment is matched
20
+ * to the order; a payment without it is not attributed. The HST fields of the same instructions describe what
21
+ * the deposit account ends up holding once the platform has converted the XRP into it, inside the account.
22
+ * Nothing here signs or submits: it parses the option, reads the instruction and builds the transaction and
23
+ * the text the command prints.
24
+ */
25
+ const chalk_1 = __importDefault(require("chalk"));
26
+ /** The values `--pay-with` accepts, for the option text and the refusal. */
27
+ exports.PAY_WITH_VALUES = ['hsuite', 'xrp', '<swap asset: btc, eth, usdt, ...>'];
28
+ /** A swap asset's ticker or network as the CLI accepts it: letters and digits, the same shape the validator reads. */
29
+ const TICKER = /^[A-Za-z0-9]{1,32}$/;
30
+ /**
31
+ * Parse `--pay-with` (case-insensitive; omitted = hsuite). `hsuite` / `hst` and `xrp` are themselves; any other
32
+ * ticker is a SWAP asset (the validator decides whether it is payable: see `GET /subscription/payment-assets`).
33
+ * Throws, before anything is sent, on a value that is not a ticker.
34
+ */
35
+ function parsePayChoice(raw) {
36
+ if (raw === undefined)
37
+ return { kind: 'hsuite' };
38
+ const value = raw.trim().toLowerCase();
39
+ if (value === 'hsuite' || value === 'hst')
40
+ return { kind: 'hsuite' };
41
+ if (value === 'xrp')
42
+ return { kind: 'xrp' };
43
+ if (TICKER.test(value))
44
+ return { kind: 'swap', asset: value };
45
+ throw new Error(`unknown --pay-with ${JSON.stringify(raw.slice(0, 40))}. Valid: ${exports.PAY_WITH_VALUES.join(', ')}`);
46
+ }
47
+ /** Parse `--pay-network` (a swap asset's network, e.g. `trx` for USDT): letters and digits, lower-cased. */
48
+ function parsePayNetwork(raw) {
49
+ if (raw === undefined)
50
+ return undefined;
51
+ const value = raw.trim().toLowerCase();
52
+ if (!TICKER.test(value))
53
+ throw new Error(`unknown --pay-network ${JSON.stringify(raw.slice(0, 40))}: a network name is letters and digits only (e.g. btc, eth, trx)`);
54
+ return value;
55
+ }
56
+ function xrpPaymentOf(deposit) {
57
+ return deposit.pay?.asset === 'XRP' ? deposit.pay : undefined;
58
+ }
59
+ /**
60
+ * The CLI pays exactly what the response tells it to, so it checks what it is told before anything is signed
61
+ * or shown: the instruction pays the deposit account the SAME response names (a hostile validator or gateway
62
+ * cannot point the payment elsewhere), for a positive count of drops, with a 32-bit destination tag.
63
+ */
64
+ function assertXrpPaymentConsistent(deposit, pay) {
65
+ const show = (value) => JSON.stringify(String(value).slice(0, 48));
66
+ if (pay.address !== deposit.walletAddress) {
67
+ throw new Error(`the XRP payment instruction pays ${show(pay.address)}, not the deposit account ${show(deposit.walletAddress)} — nothing was paid`);
68
+ }
69
+ if (typeof pay.amount !== 'string' || !/^[1-9]\d{0,16}$/.test(pay.amount)) {
70
+ throw new Error(`the XRP payment amount ${show(pay.amount)} is not a positive count of drops — nothing was paid`);
71
+ }
72
+ if (!Number.isInteger(pay.destinationTag) || pay.destinationTag < 0 || pay.destinationTag > 0xffffffff) {
73
+ throw new Error(`the XRP payment destination tag ${show(pay.destinationTag)} is not a 32-bit unsigned integer — nothing was paid`);
74
+ }
75
+ }
76
+ /**
77
+ * Drops (a plain integer string) as XRP, exact, with the trailing zeros dropped ('99960000000' → '99960',
78
+ * '1500000' → '1.5'). Throws on anything that is not a non-negative integer: an amount that cannot be read
79
+ * is never paid.
80
+ */
81
+ function dropsToXrp(drops) {
82
+ if (!/^\d+$/.test(drops))
83
+ throw new Error(`not a count of drops: ${JSON.stringify(drops)}`);
84
+ const padded = BigInt(drops).toString().padStart(7, '0');
85
+ const whole = padded.slice(0, -6);
86
+ const fraction = padded.slice(-6).replace(/0+$/, '');
87
+ return fraction === '' ? whole : `${whole}.${fraction}`;
88
+ }
89
+ /**
90
+ * The Payment that pays an XRP order: XRP drops to the order's deposit account, with its Destination Tag.
91
+ * `Amount` is the drops STRING the quote asks, verbatim (never re-derived), and the tag is always present
92
+ * (`0` included): the platform attributes the payment by it.
93
+ */
94
+ function buildXrpPaymentTx(account, pay) {
95
+ return {
96
+ TransactionType: 'Payment',
97
+ Account: account,
98
+ Destination: pay.address,
99
+ Amount: pay.amount,
100
+ DestinationTag: pay.destinationTag,
101
+ };
102
+ }
103
+ /** The XUMM deeplink of an XRP order's payment: the tag rides it (`dt=`), `0` included. */
104
+ function xrpSendDeeplink(pay) {
105
+ return (`xumm://xrpl/send?to=${encodeURIComponent(pay.address)}` +
106
+ `&amount=${encodeURIComponent(dropsToXrp(pay.amount))}` +
107
+ `&dt=${encodeURIComponent(String(pay.destinationTag))}`);
108
+ }
109
+ /** The payment lines of an XRP order's instructions, in the style of the HST ones. */
110
+ function renderXrpPayment(d, pay) {
111
+ console.log(chalk_1.default.gray(` amount: ${dropsToXrp(pay.amount)} XRP (${pay.amount} drops)`));
112
+ console.log(chalk_1.default.gray(` to: ${pay.address}`));
113
+ console.log(chalk_1.default.gray(` tag: ${pay.destinationTag} (Destination Tag — REQUIRED on the payment)`));
114
+ console.log(chalk_1.default.gray(` the platform converts it into ${d.amount} HST (${d.tokenId}) inside the deposit account; ` +
115
+ 'the buffer in the price covers the exchange, and any XRP left over is returned to the protocol'));
116
+ }
117
+ //# sourceMappingURL=xrp-payment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xrp-payment.js","sourceRoot":"","sources":["../../src/_lib/xrp-payment.ts"],"names":[],"mappings":";;;;;;AAkCA,wCAOC;AAGD,0CAKC;AAID,oCAEC;AAOD,gEAWC;AAOD,gCAMC;AAOD,8CAQC;AAGD,0CAMC;AAGD,4CAUC;AA3HD;;;;;;;;;GASG;AACH,kDAA0B;AAU1B,4EAA4E;AAC/D,QAAA,eAAe,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,mCAAmC,CAAU,CAAC;AAE/F,sHAAsH;AACtH,MAAM,MAAM,GAAG,qBAAqB,CAAC;AAKrC;;;;GAIG;AACH,SAAgB,cAAc,CAAC,GAAuB;IACpD,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE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AC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,qCAAqC,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC,OAAO,gCAAgC;QAC7F,gGAAgG,CACnG,CACF,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The ONE way the CLI derives an XRPL signing identity from a seed (#3506 A3
3
- * MEDIUM-1 fix).
3
+ * MEDIUM-1 fix; #3667 for the payment/trustline/accept transactions).
4
4
  *
5
5
  * Both `SubscriptionClient.authenticate()` (validator web3-auth login) and
6
6
  * `hsuite subscribe`'s entity-create-intent signing MUST use the exact SAME
@@ -36,4 +36,19 @@ export type XrplLoginSigner = {
36
36
  * command that never touches XRPL never pays for it.
37
37
  */
38
38
  export declare function buildXrplLoginSigner(address: string, seed: string): Promise<XrplLoginSigner>;
39
+ /**
40
+ * Signs PREPARED (autofilled) XRPL transactions with the seed's OWN key (#3667):
41
+ * `ripple-keypairs.deriveKeypair(seed)` — the same derivation {@link buildXrplLoginSigner}
42
+ * logs in with — handed to `xrpl.Wallet`'s signing. The transaction's `Account` is
43
+ * whatever the caller put there (`XRPL_ADDRESS`), so a `RegularKey` setup, whose seed
44
+ * is NOT the master key, signs correctly as that account.
45
+ *
46
+ * NEVER `xrpl.Wallet.fromSeed(seed)`: it forces ed25519, so a secp256k1 seed signed
47
+ * `hsuite subscribe`'s deposit, `topup`'s credit, `faucet`'s TrustSet and the NFT accept
48
+ * with a key the account does not have — the create succeeded (its intent already used
49
+ * this derivation, #3648) and the auto-pay then failed, leaving a pending subscription.
50
+ *
51
+ * Synchronous on purpose: the `walletSignFactory` seams that call it are.
52
+ */
53
+ export declare function buildXrplTxSigner(seed: string): (tx: Record<string, unknown>) => string;
39
54
  //# sourceMappingURL=xrpl-login-signer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xrpl-login-signer.d.ts","sourceRoot":"","sources":["../../src/_lib/xrpl-login-signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,MAAM,eAAe,GAAG;IAC5B,uFAAuF;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,8GAA8G;IAC9G,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,CAAC,CAW1B"}
1
+ {"version":3,"file":"xrpl-login-signer.d.ts","sourceRoot":"","sources":["../../src/_lib/xrpl-login-signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,MAAM,eAAe,GAAG;IAC5B,uFAAuF;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,8GAA8G;IAC9G,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,CAAC,CAW1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAQvF"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /**
3
3
  * The ONE way the CLI derives an XRPL signing identity from a seed (#3506 A3
4
- * MEDIUM-1 fix).
4
+ * MEDIUM-1 fix; #3667 for the payment/trustline/accept transactions).
5
5
  *
6
6
  * Both `SubscriptionClient.authenticate()` (validator web3-auth login) and
7
7
  * `hsuite subscribe`'s entity-create-intent signing MUST use the exact SAME
@@ -58,6 +58,7 @@ var __importStar = (this && this.__importStar) || (function () {
58
58
  })();
59
59
  Object.defineProperty(exports, "__esModule", { value: true });
60
60
  exports.buildXrplLoginSigner = buildXrplLoginSigner;
61
+ exports.buildXrplTxSigner = buildXrplTxSigner;
61
62
  /**
62
63
  * Build the CLI's XRPL login/signing identity. `ripple-keypairs` is a
63
64
  * transitive dep of `xrpl` (a CLI runtime dep); imported lazily so a CLI
@@ -75,4 +76,27 @@ async function buildXrplLoginSigner(address, seed) {
75
76
  },
76
77
  };
77
78
  }
79
+ /**
80
+ * Signs PREPARED (autofilled) XRPL transactions with the seed's OWN key (#3667):
81
+ * `ripple-keypairs.deriveKeypair(seed)` — the same derivation {@link buildXrplLoginSigner}
82
+ * logs in with — handed to `xrpl.Wallet`'s signing. The transaction's `Account` is
83
+ * whatever the caller put there (`XRPL_ADDRESS`), so a `RegularKey` setup, whose seed
84
+ * is NOT the master key, signs correctly as that account.
85
+ *
86
+ * NEVER `xrpl.Wallet.fromSeed(seed)`: it forces ed25519, so a secp256k1 seed signed
87
+ * `hsuite subscribe`'s deposit, `topup`'s credit, `faucet`'s TrustSet and the NFT accept
88
+ * with a key the account does not have — the create succeeded (its intent already used
89
+ * this derivation, #3648) and the auto-pay then failed, leaving a pending subscription.
90
+ *
91
+ * Synchronous on purpose: the `walletSignFactory` seams that call it are.
92
+ */
93
+ function buildXrplTxSigner(seed) {
94
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
95
+ const { Wallet } = require('xrpl');
96
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
97
+ const { deriveKeypair } = require('ripple-keypairs');
98
+ const { publicKey, privateKey } = deriveKeypair(seed);
99
+ const wallet = new Wallet(publicKey, privateKey);
100
+ return (tx) => wallet.sign(tx).tx_blob;
101
+ }
78
102
  //# sourceMappingURL=xrpl-login-signer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"xrpl-login-signer.js","sourceRoot":"","sources":["../../src/_lib/xrp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,CAAC,WAAW,EAAE,CAAC;YAC/E,OAAO,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACzC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,8DAA8D;IAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,8DAA8D;IAC9D,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACrD,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACjD,OAAO,CAAC,EAA2B,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAiB,CAAC;AAC5E,CAAC"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * `hsuite billing` — pretty-print the billing ledger.
2
+ * `hsuite billing` — pretty-print the billing history.
3
3
  */
4
4
  import { Command } from 'commander';
5
- import { SubscriptionClient } from '../_lib/subscription-client';
5
+ import { SubscriptionClient, type BillingLedgerResponse } from '../_lib/subscription-client';
6
6
  type BillingOpts = {
7
7
  env: string;
8
8
  gateway?: string;
@@ -11,7 +11,9 @@ type BillingOpts = {
11
11
  offset?: string;
12
12
  clientFactory?: (baseUrl: string) => SubscriptionClient;
13
13
  };
14
- export declare function runBilling(opts: BillingOpts): Promise<import("../_lib/subscription-client").BillingLedgerResponse>;
14
+ export declare function runBilling(opts: BillingOpts): Promise<BillingLedgerResponse>;
15
+ /** One entry as a table row: what it was for, its status, what arrived, the first transaction, and when. */
16
+ export declare function formatBillingRow(entry: BillingLedgerResponse['entries'][number]): string;
15
17
  export declare const billingCommand: Command;
16
18
  export {};
17
19
  //# sourceMappingURL=billing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/commands/billing.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,kBAAkB,CAAC;CACzD,CAAC;AAEF,wBAAsB,UAAU,CAAC,IAAI,EAAE,WAAW,wEAUjD;AAED,eAAO,MAAM,cAAc,SAoCvB,CAAC"}
1
+ {"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/commands/billing.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAG7F,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,kBAAkB,CAAC;CACzD,CAAC;AAEF,wBAAsB,UAAU,CAAC,IAAI,EAAE,WAAW,kCAUjD;AAED,4GAA4G;AAC5G,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAMxF;AAED,eAAO,MAAM,cAAc,SA+BvB,CAAC"}