@tuwaio/nova-payments 0.0.0-stage → 0.0.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 FOP Tkach Oleksandr
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,117 @@
1
- # Temporary Holding Version
1
+ # @tuwaio/nova-payments
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![NPM Version](https://img.shields.io/npm/v/@tuwaio/nova-payments.svg)](https://www.npmjs.com/package/@tuwaio/nova-payments)
4
+ [![License](https://img.shields.io/npm/l/@tuwaio/nova-payments.svg)](https://github.com/TuwaIO/nova-uikit/blob/main/packages/nova-payments/LICENSE)
5
+
6
+ `@tuwaio/nova-payments` is the payments Layer 7 (L7) package of **Nova UI Kit**, the user interface project of TUWA Stage 4 ("User Interface"). It renders the checkout of a [Quasar Payments](https://docs.tuwa.io/quasar) invoice from its checkout token: the order with its lines, tax and deadline, the steps of the payment and its outcome, in a modal (a sheet from the bottom on a phone), in the page, or on a page of its own. It keeps no payment state of its own: the checkout store of [`@tuwaio/quasar-sdk/checkout`](https://docs.tuwa.io/quasar) reads the invoice and follows it, and no secret key reaches the browser.
7
+
8
+ > [!NOTE]
9
+ > The package is in development: the checkout speaks English for now; the other five languages of Quasar invoices arrive in the next release.
10
+
11
+ ---
12
+
13
+ ## 💾 Installation
14
+
15
+ ```bash
16
+ pnpm add @tuwaio/nova-payments @tuwaio/quasar-sdk @tuwaio/nova-core @tuwaio/nova-connect @tuwaio/nova-transactions @tuwaio/satellite-react @tuwaio/pulsar-core @tuwaio/orbit-core zustand react framer-motion @heroicons/react @radix-ui/react-dialog @web3icons/react @web3icons/common clsx tailwind-merge
17
+ ```
18
+
19
+ The checkout connects wallets through Nova Connect (`NovaConnectProvider` of `@tuwaio/nova-connect`, with its own peers) when the app sets it up; apps that connect wallets differently pass `onConnectWallet`, and without either the buyer pays with a QR code.
20
+
21
+ Import the stylesheets of `@tuwaio/nova-core` (theme variables), of `@tuwaio/nova-transactions` (the confirm and paid steps reuse its progress) and of this package (Tailwind CSS v4 utilities prefixed with `novapay:`):
22
+
23
+ ```css
24
+ @import '@tuwaio/nova-core/dist/index.css';
25
+ @import '@tuwaio/nova-transactions/dist/index.css';
26
+ @import '@tuwaio/nova-payments/dist/index.css';
27
+ ```
28
+
29
+ ---
30
+
31
+ ## 🚀 Usage
32
+
33
+ Issue the invoice on your server with `@tuwaio/quasar-sdk` and pass its `checkoutToken` to the checkout:
34
+
35
+ ```tsx
36
+ 'use client';
37
+
38
+ import { PaymentCheckout } from '@tuwaio/nova-payments';
39
+ import { useState } from 'react';
40
+
41
+ export function Checkout({ token }: { token: string }) {
42
+ const [open, setOpen] = useState(false);
43
+ return (
44
+ <>
45
+ <button type="button" onClick={() => setOpen(true)}>
46
+ Pay
47
+ </button>
48
+ <PaymentCheckout token={token} open={open} onOpenChange={setOpen} />
49
+ </>
50
+ );
51
+ }
52
+ ```
53
+
54
+ `display="inline"` renders it in the page and `display="page"` centers it, as the Quasar payment page does. `NovaPaymentsProvider` sets the Quasar API for a Community Edition node (`baseUrl`) and replaces labels.
55
+
56
+ To pay from a wallet in the browser, give the provider the chain adapters of your app (`@tuwaio/nova-payments/evm` needs `@wagmi/core` and `viem`; `@tuwaio/nova-payments/solana` needs `@solana/kit`, `@solana-program/system`, `@solana-program/token` and `@tuwaio/orbit-solana`) and, optionally, your Pulsar store: a payment the wallet sends after the buyer closed the checkout goes to it, and Nova Transactions shows its toast.
57
+
58
+ ```tsx
59
+ 'use client';
60
+
61
+ import { NovaPaymentsProvider } from '@tuwaio/nova-payments';
62
+ import { paymentsEVMAdapter } from '@tuwaio/nova-payments/evm';
63
+ import { paymentsSolanaAdapter } from '@tuwaio/nova-payments/solana';
64
+ import type { Transaction } from '@tuwaio/pulsar-core';
65
+ import type { Config } from '@wagmi/core';
66
+ import type { ReactNode } from 'react';
67
+
68
+ export function Payments({
69
+ wagmiConfig,
70
+ injectExternalPendingTxs,
71
+ children,
72
+ }: {
73
+ wagmiConfig: Config;
74
+ injectExternalPendingTxs: (transactions: Transaction[]) => Promise<void>;
75
+ children: ReactNode;
76
+ }) {
77
+ return (
78
+ <NovaPaymentsProvider
79
+ adapters={[
80
+ paymentsEVMAdapter(wagmiConfig),
81
+ paymentsSolanaAdapter({ rpcUrls: { devnet: 'https://api.devnet.solana.com' } }),
82
+ ]}
83
+ pulsar={{ injectExternalPendingTxs }}
84
+ >
85
+ {children}
86
+ </NovaPaymentsProvider>
87
+ );
88
+ }
89
+ ```
90
+
91
+ After the payment the checkout shows its outcome: confirming, paid with the receipt and the way back to the invoice's `successUrl` (a visible countdown with "Stay here"; `autoReturnSeconds`, `0` for none), and for a subscription the optional automatic payments (ERC-7715). Underpaid, held, refunded, expired, cancelled and corrected invoices get their own outcome with "Contact <seller>" (`onContact` replaces the link). `onPaid` tells the page once the invoice is paid; fulfil orders from the `invoice.paid` webhook on your server. Closing the checkout before anything is sent asks first.
92
+
93
+ ---
94
+
95
+ ## 🌍 Languages and accessibility
96
+
97
+ The checkout follows the language of the invoice; the buyer changes it in the menu next to the close button, which also sets the language of the documents still to be issued. The checkout aims at WCAG 2.2 AA: the steps are an ordered list with the current one marked, the deadline is announced 10, 5 and 1 minutes before it ends, focus stays in the modal, and animations follow `prefers-reduced-motion`.
98
+
99
+ ---
100
+
101
+ ## 🗄️ Browser Storage
102
+
103
+ The checkout saves nothing to `localStorage` or cookies. A payment it hands over to your Pulsar store is kept by that store (`createPulsarStore` persists its pool under its own name).
104
+
105
+ ## 🌐 External Services
106
+
107
+ The checkout routes of the Quasar API (`baseUrl`, Quasar Cloud by default): `GET /v1/payments/checkout/{token}`, its event stream and logo, and the `POST` routes of the steps (`buyer`, `locale`, `quote`, `submit`, `relay`; the wallet calls the `paymaster` route for sponsored calls). The `permission` route takes the automatic payments of a subscription. The EVM adapter reads balances and fee estimates through the RPC transports of your wagmi config, the Solana adapter through its `rpcUrls` (else the public endpoint of the cluster); links to transactions open the chain's block explorer (the explorer of the wagmi chain, the Solana Explorer). The wallet asks the buyer before every signature, transaction or permission.
108
+
109
+ ---
110
+
111
+ ## 🤝 Contributing & Support
112
+
113
+ Contributions are welcome! Please read our main **[Contribution Guidelines](https://github.com/TuwaIO/workflows/blob/main/CONTRIBUTING.md)**.
114
+
115
+ ## 📄 License
116
+
117
+ This project is licensed under the **Apache-2.0 License** - see the [LICENSE](https://github.com/TuwaIO/nova-uikit/blob/main/packages/nova-payments/LICENSE) file for details.
@@ -0,0 +1 @@
1
+ 'use strict';var o=class extends Error{constructor(e,t,s){super(t,s);this.kind=e;this.name="PaymentWalletError";}kind},i=4001,c=/user (rejected|denied|declined|cancell?ed)|(rejected|denied|declined|cancell?ed) by (the )?user/i,d=(n,r)=>typeof n=="object"&&n!==null?n[r]:void 0;function l(n){let r=new Set;for(let e=n;e!=null&&!r.has(e);){if(r.add(e),e instanceof o)return e.kind;if(d(e,"code")===i||d(e,"name")==="UserRejectedRequestError")return "declined";let t=d(e,"message");if(typeof t=="string"&&c.test(t))return "declined";e=d(e,"cause");}return "failed"}exports.a=o;exports.b=l;
@@ -0,0 +1 @@
1
+ 'use strict';var r={common:{close:"Close",retry:"Try again",loading:"Loading the checkout\u2026",dialogTitle:"Pay {merchant}"},error:{title:"The checkout can't be opened",notFound:"This payment link is wrong or no longer works. Ask the seller for a new one.",generic:"Something went wrong. Try again in a moment."},steps:{details:"Details",method:"Method",pay:"Pay",confirm:"Confirm",autoPay:"Auto-pay",progress:"Step {current} of {total}: {name}",label:"Payment steps"},language:{button:"Language: {language}",title:"Language",note:"Your invoice and receipt use this language too.",noteAfterPaid:"Your receipt stays in the language it was issued in."},method:{title:"Choose how to pay",subtitle:"The price locks for {minutes} minutes when you continue.",token:"Token",networks:"{count} networks",network:"{symbol} network",yourWallet:"Your wallet",popular:"Popular",noGasFee:"No gas fee",buyerPaysGas:"You pay the network fee",discount:"\u2212{percent}%",markup:"+{percent}%",payWith:"Pay with",wallet:"Wallet",walletHint:"MetaMask, Rabby, Phantom\u2026",qr:"QR code",qrHint:"Phone wallet",continue:"Continue",quoting:"Getting the price\u2026",agreeBoth:"By continuing you agree to the seller's {terms} and {refundPolicy}.",agreeOne:"By continuing you agree to the seller's {link}.",noMethods:"This invoice cannot be paid with any method right now. Contact the seller.",methodUnavailable:"This page cannot take this method. Choose another one.",payerNotExpected:"The seller asked for this invoice to be paid from another wallet. Connect that wallet.",rateLimited:"Too many tries. Wait a minute and try again."},buyer:{title:"Your details",subtitle:"The seller needs them for the invoice and the receipt.",email:"Email",name:"Name",companyName:"Company",addressLine1:"Address",addressLine2:"Address, line 2",postalCode:"Postal code",city:"City",country:"Country",chooseCountry:"Choose a country",taxId:"VAT or tax ID",registrationNumber:"Company number",optional:"optional",companyInvoice:"I need an invoice for my company",required:"Required",invalidEmail:"Enter an email like name@example.com",invalidCountry:"Choose a country from the list",continue:"Continue"},pay:{title:"Pay",walletLine:"{address} \xB7 {network}",change:"Change",changeWallet:"Change wallet",youSend:"You send",copyAmount:"Copy amount",copied:"Copied",onNetwork:"on {network}",fiatValue:"= {amount} {currency}",priceLocked:"Price locked for {time}",refreshPrice:"Refresh price",priceEnding:"This price ends in {time}. Keep it?",keepPrice:"Keep this price \xB7 +{minutes} min",priceExpired:"The price lock ran out.",newPrice:"Get a new price",rate:"Rate",rateValue:"1 {symbol} = {price} {currency}",networkFee:"Network fee",merchantPaysGas:"{merchant} pays \xB7 you only sign",gasEstimate:"\u2248 {amount} \xB7 from your wallet",gasFromWallet:"Paid from your wallet",to:"To",invoiceTotal:"Invoice total",transferFee:"Token transfer fee {percent}%",merchantReceives:"{merchant} receives",transferFeeNote:"The token's contract keeps a fee on every transfer, so you send a bit more for the invoice to be paid in full.",signToPay:"Sign to pay {amount}",payAmount:"Pay {amount}",switchTo:"Switch to {network}",connect:"Connect a wallet",back:"Back to methods",payWithGas:"Pay with gas instead",payGasless:"Let {merchant} pay the gas",disclaimer:"Payments go straight to {merchant} and can't be reversed; refunds come from the seller. Paying wallets are screened against sanctions lists.",wrongNetwork:"Wrong network",wrongNetworkText:"Your wallet is on {current}. This payment goes on {network}.",switchHint:"Your wallet asks you to approve the switch.",notEnough:"Not enough",walletHas:"Your wallet has {amount} on {network}",shortBy:"{short} short of {need}.",payFromBalance:"Pay from what this wallet has",youHave:"You have {amount}",topUp:"Or add {symbol} to this wallet and come back:",getToken:"Get {symbol}",connectUnavailable:"This page has no wallet connection. Pay with a QR code instead.",declined:"You declined the request in {wallet}.",tryAgain:"Try again",failed:"The payment failed on {network}. Only the network fee was spent; the invoice is still open.",payAgain:"Pay again",unsupported:"{wallet} can't make this payment.",screeningUnavailable:"The wallet check is unavailable right now.",retryLater:"Try again in a minute",noAnswer:"The payment server did not answer. Check your connection and try again.",txTitle:"Payment to {merchant}",txDescription:"{amount} \xB7 {invoice}"},walletPrompt:{signIn:"Sign in {wallet}",confirmIn:"Confirm in {wallet}",switchIn:"Approve the switch in {wallet}",signText:"Sign the transfer of {amount} to {merchant} on {network}. No gas: {merchant} pays the network fee.",confirmText:"Confirm the transfer of {amount} to {merchant} on {network}.",check:"Check in {wallet} before signing",amount:"Amount",to:"To",network:"Network",priceLocked:"Price locked",notOpened:"The wallet window didn't open?",tryAgain:"Try again",stillWaiting:"No window? Open {wallet}: the request waits there.",cancel:"Cancel",submitting:"Handing the payment to Quasar\u2026"},qr:{solanaTitle:"Scan with a Solana wallet",solanaHint:"Open Phantom, Solflare or Backpack",scanStep:"Scan the code (Solana Pay)",approveStep:"Approve the amount below",solanaCode:"QR code of a Solana Pay request for {amount}",waiting:"Waiting for the payment\u2026",exchangeWarning:"Send from your own wallet, not from an exchange: an exchange drops the payment reference, and the payment would wait for a manual check.",openInWallet:"Open in wallet app",handoffTitle:"Pay on your phone",handoffHint:"Scan with the phone camera: this checkout opens there, and you pay with your mobile wallet.",handoffCode:"QR code that opens this checkout on your phone",handoffNote:"This page follows the payment and shows the receipt when it arrives.",copyLink:"Copy link",back:"Back to methods"},confirm:{title:"Confirming your payment",hint:"Usually under a minute on {network}.",sent:"Sent",confirming:"Confirming",confirmed:"Confirmed",paid:"Paid",failed:"Failed",network:"Network",amount:"Amount",transaction:"Transaction",from:"From",canClose:"You can close this window: the payment keeps going, and the seller sends the receipt.",viewOnExplorer:"View on the explorer",copyHash:"Copy the transaction"},paid:{title:"Payment received",summary:"on {network} \xB7 {date}",receipt:"Receipt",receiptHint:"PDF of the payment, also kept by the seller",download:"Download",refunded:"Refunded {amount} {currency}",back:"Back to {merchant}",returning:"Returning to {merchant} in {seconds} s",stay:"Stay here",autoPayOffer:"Pay the next periods automatically",autoPayActive:"Automatic payments are on."},autoPay:{title:"Pay next periods automatically?",subtitle:"Optional. Without it, you get an invoice each period and pay it yourself.",allow:"You allow {merchant} to take",limit:"up to {amount}",every:"every {period}",from:"From",to:"To",validUntil:"Valid until",validUntilValue:"{date}, or until you cancel",invoices:"Each charge comes with an invoice and a receipt by email.",cap:"{merchant} can't take more than this limit in a period.",turnOff:"Turn it off any time: cancel the subscription, or revoke the permission in your wallet.",confirm:"Allow automatic payments",skip:"Not now, I'll pay each invoice",walletNote:"Your wallet shows this permission (ERC-7715) before you approve it.",approveIn:"Approve in {wallet}",unavailable:"{wallet} can't allow automatic payments."},outcome:{underpaidTitle:"Part of the payment arrived",underpaidText:"{received} of {total} received.",underpaidRest:"Send the rest, {rest}, from the same wallet on {network}.",underpaidNote:"Until the rest arrives, {merchant} sees the invoice as underpaid. It stays payable until {date}.",payRest:"Pay the rest",heldTitle:"Payment received, {merchant} is checking it",heldScreening:"{merchant} checks the payment before confirming the order.",heldLate:"The payment arrived after the invoice closed. {merchant} accepts it or returns it.",heldOverpaid:"You sent more than the invoice. {merchant} confirms the order or returns the difference to your wallet.",heldNote:"The seller contacts you if anything is needed.",refundedTitle:"Refunded",refundedText:"{merchant} refunded this invoice: {amount} {currency}.",expiredTitle:"This invoice has expired",expiredText:"It was payable until {date}. Ask {merchant} for a new one; nothing was charged.",expiredNote:"A payment sent after the deadline is held for the seller to refund or accept.",cancelledTitle:"This invoice was cancelled",cancelledText:"{merchant} cancelled it; nothing was charged.",replacedTitle:"{merchant} corrected this invoice",replacedText:"{number} replaces it. This invoice can no longer be paid.",replacedPaid:"Already paid? Your payment moved to the new invoice.",openReplacement:"Open {number}",blockedTitle:"This wallet can't pay this invoice",blockedText:"The wallet check did not pass. Nothing was sent. Connect another wallet or contact {merchant}.",useAnotherWallet:"Use another wallet",contact:"Contact {merchant}",contactSubject:"Invoice {number}"},leave:{title:"Leave the checkout?",text:"Nothing is sent yet. The invoice stays open until {date}: reopen it from the link in your email or on the seller's site.",textNoDate:"Nothing is sent yet. The invoice stays open: reopen it from the link in your email or on the seller's site.",price:"The locked price is released; you get a new one when you come back.",stay:"Stay and pay",leave:"Leave"},summary:{test:"Test",testHint:"Test invoice: it is paid on a test network.",sellerDetails:"Seller details",registration:"Company number",taxId:"VAT ID",terms:"Terms",refundPolicy:"Refund policy",privacy:"Privacy",sellerRole:"{seller} is the seller. Quasar is the payment software: it never holds your funds and is not a party to this purchase.",payWithin:"Pay within",until:"until {date}",minutesLeft:"{minutes} minutes left to pay",oneMinuteLeft:"1 minute left to pay",invoice:"Invoice",quantity:"{quantity} \xD7 {price}",subtotal:"Subtotal",taxRate:"VAT {rate}%",tax:"VAT",total:"Total",secured:"Secured by Quasar",help:"Help",compact:"{count} items \xB7 incl. VAT {tax}",showOrder:"Details"}};function c(t,n){return t.replace(/\{(\w+)\}/g,(a,e)=>e in n?String(n[e]):a)}function m(t,n){let a=[],e="",i=0;for(let o of t.matchAll(/\{(\w+)\}/g))e+=t.slice(i,o.index),i=(o.index??0)+o[0].length,o[1]in n?(e&&a.push(e),a.push(n[o[1]]),e=""):e+=o[0];return e+=t.slice(i),e&&a.push(e),a}var u=[{code:"en",name:"English",short:"EN"},{code:"zh-CN",name:"\u7B80\u4F53\u4E2D\u6587",short:"ZH"},{code:"es",name:"Espa\xF1ol",short:"ES"},{code:"ru",name:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",short:"RU"},{code:"uk",name:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430",short:"UK"},{code:"it",name:"Italiano",short:"IT"}],s={en:r};function y(t){return t&&s[t]||r}function w(t,n){if(!n)return t;let a={...t};for(let e of Object.keys(n))n[e]&&Object.assign(a,{[e]:{...t[e],...n[e]}});return a}exports.a=r;exports.b=c;exports.c=m;exports.d=u;exports.e=y;exports.f=w;
@@ -0,0 +1 @@
1
+ var r={common:{close:"Close",retry:"Try again",loading:"Loading the checkout\u2026",dialogTitle:"Pay {merchant}"},error:{title:"The checkout can't be opened",notFound:"This payment link is wrong or no longer works. Ask the seller for a new one.",generic:"Something went wrong. Try again in a moment."},steps:{details:"Details",method:"Method",pay:"Pay",confirm:"Confirm",autoPay:"Auto-pay",progress:"Step {current} of {total}: {name}",label:"Payment steps"},language:{button:"Language: {language}",title:"Language",note:"Your invoice and receipt use this language too.",noteAfterPaid:"Your receipt stays in the language it was issued in."},method:{title:"Choose how to pay",subtitle:"The price locks for {minutes} minutes when you continue.",token:"Token",networks:"{count} networks",network:"{symbol} network",yourWallet:"Your wallet",popular:"Popular",noGasFee:"No gas fee",buyerPaysGas:"You pay the network fee",discount:"\u2212{percent}%",markup:"+{percent}%",payWith:"Pay with",wallet:"Wallet",walletHint:"MetaMask, Rabby, Phantom\u2026",qr:"QR code",qrHint:"Phone wallet",continue:"Continue",quoting:"Getting the price\u2026",agreeBoth:"By continuing you agree to the seller's {terms} and {refundPolicy}.",agreeOne:"By continuing you agree to the seller's {link}.",noMethods:"This invoice cannot be paid with any method right now. Contact the seller.",methodUnavailable:"This page cannot take this method. Choose another one.",payerNotExpected:"The seller asked for this invoice to be paid from another wallet. Connect that wallet.",rateLimited:"Too many tries. Wait a minute and try again."},buyer:{title:"Your details",subtitle:"The seller needs them for the invoice and the receipt.",email:"Email",name:"Name",companyName:"Company",addressLine1:"Address",addressLine2:"Address, line 2",postalCode:"Postal code",city:"City",country:"Country",chooseCountry:"Choose a country",taxId:"VAT or tax ID",registrationNumber:"Company number",optional:"optional",companyInvoice:"I need an invoice for my company",required:"Required",invalidEmail:"Enter an email like name@example.com",invalidCountry:"Choose a country from the list",continue:"Continue"},pay:{title:"Pay",walletLine:"{address} \xB7 {network}",change:"Change",changeWallet:"Change wallet",youSend:"You send",copyAmount:"Copy amount",copied:"Copied",onNetwork:"on {network}",fiatValue:"= {amount} {currency}",priceLocked:"Price locked for {time}",refreshPrice:"Refresh price",priceEnding:"This price ends in {time}. Keep it?",keepPrice:"Keep this price \xB7 +{minutes} min",priceExpired:"The price lock ran out.",newPrice:"Get a new price",rate:"Rate",rateValue:"1 {symbol} = {price} {currency}",networkFee:"Network fee",merchantPaysGas:"{merchant} pays \xB7 you only sign",gasEstimate:"\u2248 {amount} \xB7 from your wallet",gasFromWallet:"Paid from your wallet",to:"To",invoiceTotal:"Invoice total",transferFee:"Token transfer fee {percent}%",merchantReceives:"{merchant} receives",transferFeeNote:"The token's contract keeps a fee on every transfer, so you send a bit more for the invoice to be paid in full.",signToPay:"Sign to pay {amount}",payAmount:"Pay {amount}",switchTo:"Switch to {network}",connect:"Connect a wallet",back:"Back to methods",payWithGas:"Pay with gas instead",payGasless:"Let {merchant} pay the gas",disclaimer:"Payments go straight to {merchant} and can't be reversed; refunds come from the seller. Paying wallets are screened against sanctions lists.",wrongNetwork:"Wrong network",wrongNetworkText:"Your wallet is on {current}. This payment goes on {network}.",switchHint:"Your wallet asks you to approve the switch.",notEnough:"Not enough",walletHas:"Your wallet has {amount} on {network}",shortBy:"{short} short of {need}.",payFromBalance:"Pay from what this wallet has",youHave:"You have {amount}",topUp:"Or add {symbol} to this wallet and come back:",getToken:"Get {symbol}",connectUnavailable:"This page has no wallet connection. Pay with a QR code instead.",declined:"You declined the request in {wallet}.",tryAgain:"Try again",failed:"The payment failed on {network}. Only the network fee was spent; the invoice is still open.",payAgain:"Pay again",unsupported:"{wallet} can't make this payment.",screeningUnavailable:"The wallet check is unavailable right now.",retryLater:"Try again in a minute",noAnswer:"The payment server did not answer. Check your connection and try again.",txTitle:"Payment to {merchant}",txDescription:"{amount} \xB7 {invoice}"},walletPrompt:{signIn:"Sign in {wallet}",confirmIn:"Confirm in {wallet}",switchIn:"Approve the switch in {wallet}",signText:"Sign the transfer of {amount} to {merchant} on {network}. No gas: {merchant} pays the network fee.",confirmText:"Confirm the transfer of {amount} to {merchant} on {network}.",check:"Check in {wallet} before signing",amount:"Amount",to:"To",network:"Network",priceLocked:"Price locked",notOpened:"The wallet window didn't open?",tryAgain:"Try again",stillWaiting:"No window? Open {wallet}: the request waits there.",cancel:"Cancel",submitting:"Handing the payment to Quasar\u2026"},qr:{solanaTitle:"Scan with a Solana wallet",solanaHint:"Open Phantom, Solflare or Backpack",scanStep:"Scan the code (Solana Pay)",approveStep:"Approve the amount below",solanaCode:"QR code of a Solana Pay request for {amount}",waiting:"Waiting for the payment\u2026",exchangeWarning:"Send from your own wallet, not from an exchange: an exchange drops the payment reference, and the payment would wait for a manual check.",openInWallet:"Open in wallet app",handoffTitle:"Pay on your phone",handoffHint:"Scan with the phone camera: this checkout opens there, and you pay with your mobile wallet.",handoffCode:"QR code that opens this checkout on your phone",handoffNote:"This page follows the payment and shows the receipt when it arrives.",copyLink:"Copy link",back:"Back to methods"},confirm:{title:"Confirming your payment",hint:"Usually under a minute on {network}.",sent:"Sent",confirming:"Confirming",confirmed:"Confirmed",paid:"Paid",failed:"Failed",network:"Network",amount:"Amount",transaction:"Transaction",from:"From",canClose:"You can close this window: the payment keeps going, and the seller sends the receipt.",viewOnExplorer:"View on the explorer",copyHash:"Copy the transaction"},paid:{title:"Payment received",summary:"on {network} \xB7 {date}",receipt:"Receipt",receiptHint:"PDF of the payment, also kept by the seller",download:"Download",refunded:"Refunded {amount} {currency}",back:"Back to {merchant}",returning:"Returning to {merchant} in {seconds} s",stay:"Stay here",autoPayOffer:"Pay the next periods automatically",autoPayActive:"Automatic payments are on."},autoPay:{title:"Pay next periods automatically?",subtitle:"Optional. Without it, you get an invoice each period and pay it yourself.",allow:"You allow {merchant} to take",limit:"up to {amount}",every:"every {period}",from:"From",to:"To",validUntil:"Valid until",validUntilValue:"{date}, or until you cancel",invoices:"Each charge comes with an invoice and a receipt by email.",cap:"{merchant} can't take more than this limit in a period.",turnOff:"Turn it off any time: cancel the subscription, or revoke the permission in your wallet.",confirm:"Allow automatic payments",skip:"Not now, I'll pay each invoice",walletNote:"Your wallet shows this permission (ERC-7715) before you approve it.",approveIn:"Approve in {wallet}",unavailable:"{wallet} can't allow automatic payments."},outcome:{underpaidTitle:"Part of the payment arrived",underpaidText:"{received} of {total} received.",underpaidRest:"Send the rest, {rest}, from the same wallet on {network}.",underpaidNote:"Until the rest arrives, {merchant} sees the invoice as underpaid. It stays payable until {date}.",payRest:"Pay the rest",heldTitle:"Payment received, {merchant} is checking it",heldScreening:"{merchant} checks the payment before confirming the order.",heldLate:"The payment arrived after the invoice closed. {merchant} accepts it or returns it.",heldOverpaid:"You sent more than the invoice. {merchant} confirms the order or returns the difference to your wallet.",heldNote:"The seller contacts you if anything is needed.",refundedTitle:"Refunded",refundedText:"{merchant} refunded this invoice: {amount} {currency}.",expiredTitle:"This invoice has expired",expiredText:"It was payable until {date}. Ask {merchant} for a new one; nothing was charged.",expiredNote:"A payment sent after the deadline is held for the seller to refund or accept.",cancelledTitle:"This invoice was cancelled",cancelledText:"{merchant} cancelled it; nothing was charged.",replacedTitle:"{merchant} corrected this invoice",replacedText:"{number} replaces it. This invoice can no longer be paid.",replacedPaid:"Already paid? Your payment moved to the new invoice.",openReplacement:"Open {number}",blockedTitle:"This wallet can't pay this invoice",blockedText:"The wallet check did not pass. Nothing was sent. Connect another wallet or contact {merchant}.",useAnotherWallet:"Use another wallet",contact:"Contact {merchant}",contactSubject:"Invoice {number}"},leave:{title:"Leave the checkout?",text:"Nothing is sent yet. The invoice stays open until {date}: reopen it from the link in your email or on the seller's site.",textNoDate:"Nothing is sent yet. The invoice stays open: reopen it from the link in your email or on the seller's site.",price:"The locked price is released; you get a new one when you come back.",stay:"Stay and pay",leave:"Leave"},summary:{test:"Test",testHint:"Test invoice: it is paid on a test network.",sellerDetails:"Seller details",registration:"Company number",taxId:"VAT ID",terms:"Terms",refundPolicy:"Refund policy",privacy:"Privacy",sellerRole:"{seller} is the seller. Quasar is the payment software: it never holds your funds and is not a party to this purchase.",payWithin:"Pay within",until:"until {date}",minutesLeft:"{minutes} minutes left to pay",oneMinuteLeft:"1 minute left to pay",invoice:"Invoice",quantity:"{quantity} \xD7 {price}",subtotal:"Subtotal",taxRate:"VAT {rate}%",tax:"VAT",total:"Total",secured:"Secured by Quasar",help:"Help",compact:"{count} items \xB7 incl. VAT {tax}",showOrder:"Details"}};function c(t,n){return t.replace(/\{(\w+)\}/g,(a,e)=>e in n?String(n[e]):a)}function m(t,n){let a=[],e="",i=0;for(let o of t.matchAll(/\{(\w+)\}/g))e+=t.slice(i,o.index),i=(o.index??0)+o[0].length,o[1]in n?(e&&a.push(e),a.push(n[o[1]]),e=""):e+=o[0];return e+=t.slice(i),e&&a.push(e),a}var u=[{code:"en",name:"English",short:"EN"},{code:"zh-CN",name:"\u7B80\u4F53\u4E2D\u6587",short:"ZH"},{code:"es",name:"Espa\xF1ol",short:"ES"},{code:"ru",name:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",short:"RU"},{code:"uk",name:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430",short:"UK"},{code:"it",name:"Italiano",short:"IT"}],s={en:r};function y(t){return t&&s[t]||r}function w(t,n){if(!n)return t;let a={...t};for(let e of Object.keys(n))n[e]&&Object.assign(a,{[e]:{...t[e],...n[e]}});return a}export{r as a,c as b,m as c,u as d,y as e,w as f};
@@ -0,0 +1 @@
1
+ var o=class extends Error{constructor(e,t,s){super(t,s);this.kind=e;this.name="PaymentWalletError";}kind},i=4001,c=/user (rejected|denied|declined|cancell?ed)|(rejected|denied|declined|cancell?ed) by (the )?user/i,d=(n,r)=>typeof n=="object"&&n!==null?n[r]:void 0;function l(n){let r=new Set;for(let e=n;e!=null&&!r.has(e);){if(r.add(e),e instanceof o)return e.kind;if(d(e,"code")===i||d(e,"name")==="UserRejectedRequestError")return "declined";let t=d(e,"message");if(typeof t=="string"&&c.test(t))return "declined";e=d(e,"cause");}return "failed"}export{o as a,l as b};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk2GRM2VF3_cjs=require('../chunk-2GRM2VF3.cjs'),orbitCore=require('@tuwaio/orbit-core'),pulsarCore=require('@tuwaio/pulsar-core'),core=require('@wagmi/core'),viem=require('viem');var B=18e4;function l(e){let c=orbitCore.toEvmChainId(e);if(c===void 0)throw new Error(`${e} is not an EVM chain`);return c}function p(e){if(e.family!=="eip155")throw new Error(`${e.chainId} is not an EVM chain`);return e}function N(e){return e.token==="native"?{to:e.to,value:BigInt(e.amount)}:{to:e.token,data:viem.encodeFunctionData({abi:viem.erc20Abi,functionName:"transfer",args:[e.to,BigInt(e.amount)]})}}function V(e){let c=()=>{let a=core.getConnection(e).connector;if(a?.id==="safe"||a?.type==="safe")throw new chunk2GRM2VF3_cjs.a("unsupported","A Safe wallet cannot pay this checkout")};return {family:"eip155",getBalance:async({chainId:a,account:n,token:t})=>{let s=l(a);return t==="native"?(await core.getBalance(e,{address:n,chainId:s})).value:core.readContract(e,{address:t,abi:viem.erc20Abi,functionName:"balanceOf",args:[n],chainId:s})},estimateFee:async({instructions:a,account:n})=>{let t=p(a),s=await core.estimateGas(e,{account:n,chainId:t.chainId,...N(t)}),r=await core.estimateFeesPerGas(e,{chainId:t.chainId}),d=r.maxFeePerGas??r.gasPrice;if(d===void 0)return null;let o=e.chains.find(i=>i.id===t.chainId)?.nativeCurrency;return {amount:s*d,decimals:o?.decimals??18,symbol:o?.symbol??"ETH"}},canSponsorCalls:async({chainId:a,account:n})=>{try{return (await core.getCapabilities(e,{account:n,chainId:l(a)})).paymasterService?.supported===!0}catch{return false}},switchChain:async a=>{await core.switchChain(e,{chainId:l(a)});},sendTransfer:async({instructions:a,account:n})=>{let t=p(a);return c(),t.token==="native"?core.sendTransaction(e,{account:n,chainId:t.chainId,to:t.to,value:BigInt(t.amount)}):core.writeContract(e,{account:n,chainId:t.chainId,address:t.token,abi:viem.erc20Abi,functionName:"transfer",args:[t.to,BigInt(t.amount)]})},signTransferAuthorization:async({typedData:a,account:n})=>(await core.getConnectorClient(e,{chainId:Number(a.domain.chainId)})).request({method:"eth_signTypedData_v4",params:[n,JSON.stringify(a)]}),sendSponsoredCalls:async({calls:a,paymasterUrl:n,chainId:t,account:s,onSent:r})=>{c();let{id:d}=await core.sendCalls(e,{account:s,chainId:l(t),calls:a.map(u=>({to:u.to,value:BigInt(u.value),data:u.data})),capabilities:{paymasterService:{url:n}}});r?.();let o=await core.waitForCallsStatus(e,{id:d,timeout:B}),i=o.status==="success"?o.receipts?.at(-1)?.transactionHash:void 0;if(!i)throw new chunk2GRM2VF3_cjs.a("failed","The sponsored payment failed");return i},explorerUrl:({chainId:a,txKey:n})=>{let s=e.chains.find(r=>r.id===orbitCore.toEvmChainId(a))?.blockExplorers?.default.url;return s?`${s}/tx/${n}`:void 0},requestPermission:async({request:a,account:n})=>{let s=await(await core.getConnectorClient(e,{chainId:Number.parseInt(a.chainId,16)})).request({method:"wallet_requestExecutionPermissions",params:[{...a,from:n}]}),[r]=Array.isArray(s)?s:[s];if(!r?.context||!r.delegationManager)throw new chunk2GRM2VF3_cjs.a("failed","The wallet did not grant the permission");return {context:r.context,delegationManager:r.delegationManager,dependencies:r.dependencies??[]}},pulsarTransaction:({txKey:a,instructions:n,account:t,connectorType:s,title:r,description:d,payload:o})=>{let i=p(n);return {adapter:orbitCore.OrbitAdapter.EVM,tracker:pulsarCore.TransactionTracker.Ethereum,txKey:a,hash:a,chainId:i.chainId,from:t,to:i.token==="native"?i.to:i.token,type:"payment",connectorType:s,title:r,description:d,payload:o,pending:true,localTimestamp:Math.floor(Date.now()/1e3),isTrackedModalOpen:false}}}}exports.paymentsEVMAdapter=V;
@@ -0,0 +1,33 @@
1
+ import { Config } from '@wagmi/core';
2
+ import { P as PaymentsAdapter } from '../types-Bmj8ctqc.cjs';
3
+ import '@tuwaio/pulsar-core';
4
+ import '@tuwaio/quasar-sdk/checkout';
5
+
6
+ /**
7
+ * The adapter that pays EVM methods of a Nova Payments checkout from the wallet connected through wagmi (the config
8
+ * Satellite Connect and Nova Connect use). It reads balances and estimates fees on the network, asks the wallet to
9
+ * switch networks, sends the transfer (native coin or ERC-20 `transfer`), signs the EIP-3009 authorization of a gasless
10
+ * quote with `eth_signTypedData_v4` exactly as Quasar issued it, and sends sponsored calls with `wallet_sendCalls` and
11
+ * the checkout's ERC-7677 paymaster. A Safe wallet is refused: it returns a Safe transaction hash, not the transaction
12
+ * Quasar follows. Pass it in `adapters` of `NovaPaymentsProvider`.
13
+ *
14
+ * Side effects: RPC reads through the wagmi transports; wallet prompts.
15
+ *
16
+ * @param config - The wagmi config of the app.
17
+ * @returns The EVM adapter.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * import { NovaPaymentsProvider } from '@tuwaio/nova-payments';
22
+ * import { paymentsEVMAdapter } from '@tuwaio/nova-payments/evm';
23
+ *
24
+ * const adapters = [paymentsEVMAdapter(wagmiConfig)];
25
+ *
26
+ * export function Payments({ children }: { children: React.ReactNode }) {
27
+ * return <NovaPaymentsProvider adapters={adapters}>{children}</NovaPaymentsProvider>;
28
+ * }
29
+ * ```
30
+ */
31
+ declare function paymentsEVMAdapter(config: Config): PaymentsAdapter;
32
+
33
+ export { paymentsEVMAdapter };
@@ -0,0 +1,33 @@
1
+ import { Config } from '@wagmi/core';
2
+ import { P as PaymentsAdapter } from '../types-Bmj8ctqc.js';
3
+ import '@tuwaio/pulsar-core';
4
+ import '@tuwaio/quasar-sdk/checkout';
5
+
6
+ /**
7
+ * The adapter that pays EVM methods of a Nova Payments checkout from the wallet connected through wagmi (the config
8
+ * Satellite Connect and Nova Connect use). It reads balances and estimates fees on the network, asks the wallet to
9
+ * switch networks, sends the transfer (native coin or ERC-20 `transfer`), signs the EIP-3009 authorization of a gasless
10
+ * quote with `eth_signTypedData_v4` exactly as Quasar issued it, and sends sponsored calls with `wallet_sendCalls` and
11
+ * the checkout's ERC-7677 paymaster. A Safe wallet is refused: it returns a Safe transaction hash, not the transaction
12
+ * Quasar follows. Pass it in `adapters` of `NovaPaymentsProvider`.
13
+ *
14
+ * Side effects: RPC reads through the wagmi transports; wallet prompts.
15
+ *
16
+ * @param config - The wagmi config of the app.
17
+ * @returns The EVM adapter.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * import { NovaPaymentsProvider } from '@tuwaio/nova-payments';
22
+ * import { paymentsEVMAdapter } from '@tuwaio/nova-payments/evm';
23
+ *
24
+ * const adapters = [paymentsEVMAdapter(wagmiConfig)];
25
+ *
26
+ * export function Payments({ children }: { children: React.ReactNode }) {
27
+ * return <NovaPaymentsProvider adapters={adapters}>{children}</NovaPaymentsProvider>;
28
+ * }
29
+ * ```
30
+ */
31
+ declare function paymentsEVMAdapter(config: Config): PaymentsAdapter;
32
+
33
+ export { paymentsEVMAdapter };
@@ -0,0 +1 @@
1
+ import {a}from'../chunk-XAUJNVKC.js';import {OrbitAdapter,toEvmChainId}from'@tuwaio/orbit-core';import {TransactionTracker}from'@tuwaio/pulsar-core';import {getConnectorClient,sendCalls,waitForCallsStatus,sendTransaction,writeContract,switchChain,getCapabilities,estimateGas,estimateFeesPerGas,getBalance,readContract,getConnection}from'@wagmi/core';import {erc20Abi,encodeFunctionData}from'viem';var B=18e4;function l(e){let c=toEvmChainId(e);if(c===void 0)throw new Error(`${e} is not an EVM chain`);return c}function p(e){if(e.family!=="eip155")throw new Error(`${e.chainId} is not an EVM chain`);return e}function N(e){return e.token==="native"?{to:e.to,value:BigInt(e.amount)}:{to:e.token,data:encodeFunctionData({abi:erc20Abi,functionName:"transfer",args:[e.to,BigInt(e.amount)]})}}function V(e){let c=()=>{let a$1=getConnection(e).connector;if(a$1?.id==="safe"||a$1?.type==="safe")throw new a("unsupported","A Safe wallet cannot pay this checkout")};return {family:"eip155",getBalance:async({chainId:a,account:n,token:t})=>{let s=l(a);return t==="native"?(await getBalance(e,{address:n,chainId:s})).value:readContract(e,{address:t,abi:erc20Abi,functionName:"balanceOf",args:[n],chainId:s})},estimateFee:async({instructions:a,account:n})=>{let t=p(a),s=await estimateGas(e,{account:n,chainId:t.chainId,...N(t)}),r=await estimateFeesPerGas(e,{chainId:t.chainId}),d=r.maxFeePerGas??r.gasPrice;if(d===void 0)return null;let o=e.chains.find(i=>i.id===t.chainId)?.nativeCurrency;return {amount:s*d,decimals:o?.decimals??18,symbol:o?.symbol??"ETH"}},canSponsorCalls:async({chainId:a,account:n})=>{try{return (await getCapabilities(e,{account:n,chainId:l(a)})).paymasterService?.supported===!0}catch{return false}},switchChain:async a=>{await switchChain(e,{chainId:l(a)});},sendTransfer:async({instructions:a,account:n})=>{let t=p(a);return c(),t.token==="native"?sendTransaction(e,{account:n,chainId:t.chainId,to:t.to,value:BigInt(t.amount)}):writeContract(e,{account:n,chainId:t.chainId,address:t.token,abi:erc20Abi,functionName:"transfer",args:[t.to,BigInt(t.amount)]})},signTransferAuthorization:async({typedData:a,account:n})=>(await getConnectorClient(e,{chainId:Number(a.domain.chainId)})).request({method:"eth_signTypedData_v4",params:[n,JSON.stringify(a)]}),sendSponsoredCalls:async({calls:a$1,paymasterUrl:n,chainId:t,account:s,onSent:r})=>{c();let{id:d}=await sendCalls(e,{account:s,chainId:l(t),calls:a$1.map(u=>({to:u.to,value:BigInt(u.value),data:u.data})),capabilities:{paymasterService:{url:n}}});r?.();let o=await waitForCallsStatus(e,{id:d,timeout:B}),i=o.status==="success"?o.receipts?.at(-1)?.transactionHash:void 0;if(!i)throw new a("failed","The sponsored payment failed");return i},explorerUrl:({chainId:a,txKey:n})=>{let s=e.chains.find(r=>r.id===toEvmChainId(a))?.blockExplorers?.default.url;return s?`${s}/tx/${n}`:void 0},requestPermission:async({request:a$1,account:n})=>{let s=await(await getConnectorClient(e,{chainId:Number.parseInt(a$1.chainId,16)})).request({method:"wallet_requestExecutionPermissions",params:[{...a$1,from:n}]}),[r]=Array.isArray(s)?s:[s];if(!r?.context||!r.delegationManager)throw new a("failed","The wallet did not grant the permission");return {context:r.context,delegationManager:r.delegationManager,dependencies:r.dependencies??[]}},pulsarTransaction:({txKey:a,instructions:n,account:t,connectorType:s,title:r,description:d,payload:o})=>{let i=p(n);return {adapter:OrbitAdapter.EVM,tracker:TransactionTracker.Ethereum,txKey:a,hash:a,chainId:i.chainId,from:t,to:i.token==="native"?i.to:i.token,type:"payment",connectorType:s,title:r,description:d,payload:o,pending:true,localTimestamp:Math.floor(Date.now()/1e3),isTrackedModalOpen:false}}}}export{V as paymentsEVMAdapter};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk4TPU7WSP_cjs=require('../chunk-4TPU7WSP.cjs');Object.defineProperty(exports,"CHECKOUT_LOCALES",{enumerable:true,get:function(){return chunk4TPU7WSP_cjs.d}});Object.defineProperty(exports,"defaultLabels",{enumerable:true,get:function(){return chunk4TPU7WSP_cjs.a}});Object.defineProperty(exports,"formatLabel",{enumerable:true,get:function(){return chunk4TPU7WSP_cjs.b}});Object.defineProperty(exports,"formatLabelParts",{enumerable:true,get:function(){return chunk4TPU7WSP_cjs.c}});Object.defineProperty(exports,"labelsForLocale",{enumerable:true,get:function(){return chunk4TPU7WSP_cjs.e}});Object.defineProperty(exports,"mergeLabels",{enumerable:true,get:function(){return chunk4TPU7WSP_cjs.f}});
@@ -0,0 +1,29 @@
1
+ import { N as NovaPaymentsLabels } from '../locales-DtReb4Tp.cjs';
2
+ export { C as CHECKOUT_LOCALES, a as CheckoutLocale, b as NovaPaymentsLabelOverrides, l as labelsForLocale, m as mergeLabels } from '../locales-DtReb4Tp.cjs';
3
+
4
+ /**
5
+ * The English labels of Nova Payments, the default for every language until its own labels are added.
6
+ */
7
+ declare const defaultLabels: NovaPaymentsLabels;
8
+
9
+ /**
10
+ * Replaces the `{name}` placeholders of a label with values; unknown placeholders are kept.
11
+ *
12
+ * @param label - A label with placeholders, for example `Step {current} of {total}`.
13
+ * @param values - The value of each placeholder.
14
+ * @returns The label with the values.
15
+ */
16
+ declare function formatLabel(label: string, values: Record<string, string | number>): string;
17
+
18
+ /**
19
+ * Splits a label at its `{name}` placeholders and puts the values in their place, for values that are not text, such
20
+ * as links. Unknown placeholders stay as they are.
21
+ *
22
+ * @typeParam T - Type of the values.
23
+ * @param label - A label with placeholders, for example `You agree to the {terms}.`.
24
+ * @param values - The value of each placeholder.
25
+ * @returns The text parts and the values, in order (empty texts left out).
26
+ */
27
+ declare function formatLabelParts<T>(label: string, values: Record<string, T>): (string | T)[];
28
+
29
+ export { NovaPaymentsLabels, defaultLabels, formatLabel, formatLabelParts };
@@ -0,0 +1,29 @@
1
+ import { N as NovaPaymentsLabels } from '../locales-DtReb4Tp.js';
2
+ export { C as CHECKOUT_LOCALES, a as CheckoutLocale, b as NovaPaymentsLabelOverrides, l as labelsForLocale, m as mergeLabels } from '../locales-DtReb4Tp.js';
3
+
4
+ /**
5
+ * The English labels of Nova Payments, the default for every language until its own labels are added.
6
+ */
7
+ declare const defaultLabels: NovaPaymentsLabels;
8
+
9
+ /**
10
+ * Replaces the `{name}` placeholders of a label with values; unknown placeholders are kept.
11
+ *
12
+ * @param label - A label with placeholders, for example `Step {current} of {total}`.
13
+ * @param values - The value of each placeholder.
14
+ * @returns The label with the values.
15
+ */
16
+ declare function formatLabel(label: string, values: Record<string, string | number>): string;
17
+
18
+ /**
19
+ * Splits a label at its `{name}` placeholders and puts the values in their place, for values that are not text, such
20
+ * as links. Unknown placeholders stay as they are.
21
+ *
22
+ * @typeParam T - Type of the values.
23
+ * @param label - A label with placeholders, for example `You agree to the {terms}.`.
24
+ * @param values - The value of each placeholder.
25
+ * @returns The text parts and the values, in order (empty texts left out).
26
+ */
27
+ declare function formatLabelParts<T>(label: string, values: Record<string, T>): (string | T)[];
28
+
29
+ export { NovaPaymentsLabels, defaultLabels, formatLabel, formatLabelParts };
@@ -0,0 +1 @@
1
+ export{d as CHECKOUT_LOCALES,a as defaultLabels,b as formatLabel,c as formatLabelParts,e as labelsForLocale,f as mergeLabels}from'../chunk-BK3GAYTJ.js';