@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.
@@ -0,0 +1 @@
1
+ import {a}from'../chunk-XAUJNVKC.js';import {address,pipe,createTransactionMessage,setTransactionMessageFeePayerSigner,setTransactionMessageLifetimeUsingBlockhash,appendTransactionMessageInstructions,getBase58Decoder,signAndSendTransactionMessageWithSigners,AccountRole}from'@solana/kit';import {getTransferSolInstruction}from'@solana-program/system';import {findAssociatedTokenPda,getCreateAssociatedTokenIdempotentInstruction,getTransferCheckedInstruction,TOKEN_PROGRAM_ADDRESS}from'@solana-program/token';import {OrbitAdapter}from'@tuwaio/orbit-core';import {getSolanaExplorerLink,createSolanaTransactionSendingSigner,createSolanaClientWithCache,getCluster}from'@tuwaio/orbit-solana';import {TransactionTracker}from'@tuwaio/pulsar-core';var y=address("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),A=5000n,W=165n;function f(r){if(r.family!=="solana")throw new Error(`${r.chainId} is not a Solana chain`);return r}function g(r){if(!r.startsWith("solana:"))throw new Error(`${r} is not a Solana chain`);return getCluster({cluster:r})}var k=(r,l)=>({...r,accounts:[...r.accounts??[],{address:address(l),role:AccountRole.READONLY}]});function V({rpcUrls:r}={}){let l=n=>createSolanaClientWithCache({rpcUrlOrMoniker:g(n),rpcUrls:r}).rpc,T=async(n,t)=>{let{value:e}=await l(n).getAccountInfo(t,{encoding:"jsonParsed"}).send();if(!e)throw new Error(`${t} is not a token mint`);if(e.owner===TOKEN_PROGRAM_ADDRESS)return TOKEN_PROGRAM_ADDRESS;if(e.owner!==y)throw new Error(`${t} is not a token mint`);if(e.data.parsed?.info?.extensions?.find(o=>o.extension==="transferHook")?.state?.programId)throw new a("unsupported","A token with a transfer hook is paid with the QR code");return y},S=async n=>{let t=address(n.token),e=await T(n.chainId,t),[a]=await findAssociatedTokenPda({owner:address(n.to),mint:t,tokenProgram:e});return {mint:t,tokenProgram:e,account:a}},I=async(n,t)=>{let e=BigInt(n.amount);if(n.token==="native"){let c=getTransferSolInstruction({source:t,destination:address(n.to),amount:e});return [k(c,n.reference)]}let{mint:a,tokenProgram:o,account:s}=await S(n),[d]=await findAssociatedTokenPda({owner:t.address,mint:a,tokenProgram:o}),u=getCreateAssociatedTokenIdempotentInstruction({payer:t,ata:s,owner:address(n.to),mint:a,tokenProgram:o}),m=getTransferCheckedInstruction({source:d,mint:a,destination:s,authority:t,amount:e,decimals:n.decimals},{programAddress:o});return [u,k(m,n.reference)]};return {family:"solana",getBalance:async({chainId:n,account:t,token:e})=>{let a=l(n);if(e==="native")return (await a.getBalance(address(t)).send()).value;let{value:o}=await a.getTokenAccountsByOwner(address(t),{mint:address(e)},{encoding:"jsonParsed"}).send();return o.reduce((s,d)=>s+BigInt(d.account.data.parsed.info.tokenAmount.amount),0n)},estimateFee:async({instructions:n})=>{let t=f(n);if(t.token==="native")return {amount:A,decimals:9,symbol:"SOL"};let{account:e}=await S(t),a=l(t.chainId),{value:o}=await a.getAccountInfo(e,{encoding:"base64"}).send(),s=o?0n:await a.getMinimumBalanceForRentExemption(W).send();return {amount:A+s,decimals:9,symbol:"SOL"}},sendTransfer:async({instructions:n,account:t,connection:e})=>{let a$1=f(n),o=e?.connectedAccount;if(!o||o.address!==t)throw new a("unsupported","No connected Solana account to sign with");let s;try{s=createSolanaTransactionSendingSigner(o,g(a$1.chainId));}catch(c){throw new a("unsupported","The wallet cannot send this transaction",{cause:c})}let d=await I(a$1,s),{value:u}=await l(a$1.chainId).getLatestBlockhash().send(),m=pipe(createTransactionMessage({version:0}),c=>setTransactionMessageFeePayerSigner(s,c),c=>setTransactionMessageLifetimeUsingBlockhash(u,c),c=>appendTransactionMessageInstructions(d,c));return getBase58Decoder().decode(await signAndSendTransactionMessageWithSigners(m))},explorerUrl:({chainId:n,txKey:t})=>getSolanaExplorerLink(`/tx/${t}`,g(n)),pulsarTransaction:({txKey:n,instructions:t,account:e,connectorType:a,title:o,description:s,payload:d})=>{let u=f(t),m=r?.[g(u.chainId)];return {adapter:OrbitAdapter.SOLANA,tracker:TransactionTracker.Solana,txKey:n,chainId:u.chainId,...m?{rpcUrl:m}:{},from:e,type:"payment",connectorType:a,title:o,description:s,payload:d,pending:true,localTimestamp:Math.floor(Date.now()/1e3),isTrackedModalOpen:false}}}}export{V as paymentsSolanaAdapter};
@@ -0,0 +1,241 @@
1
+ import { Transaction } from '@tuwaio/pulsar-core';
2
+ import { CheckoutMethod, PaymentInstructions, TransferAuthorizationTypedData, PermissionRequest, GrantPermissionParams } from '@tuwaio/quasar-sdk/checkout';
3
+
4
+ /**
5
+ * @file The connected wallet and the payment methods as the method step needs them: CAIP identifiers, the payer of a
6
+ * method, QR payments, discounts and markups.
7
+ */
8
+
9
+ /** The chain family of a payment method or wallet. */
10
+ type PaymentFamily = 'eip155' | 'solana';
11
+ /** The wallet connected through Satellite Connect, as the checkout uses it. */
12
+ interface CheckoutWallet {
13
+ /** The account address. */
14
+ address: string;
15
+ /** CAIP-2 chain the wallet is on (Solana clusters as their genesis-hash ID). */
16
+ chainId: string;
17
+ /** Its chain family. */
18
+ family: PaymentFamily;
19
+ /** Connector type of Satellite Connect (`evm:metamask`). */
20
+ connectorType: string;
21
+ /** The wallet id for `WalletIcon` of `@tuwaio/nova-core` (`metamask`). */
22
+ walletId: string;
23
+ /** The wallet name to show. */
24
+ name: string;
25
+ /** The Satellite Connect connection itself, for the chain adapters (the Solana adapter signs with its account). */
26
+ connection: unknown;
27
+ }
28
+ /**
29
+ * The name of a wallet from its connector type.
30
+ *
31
+ * @param connectorType - Connector type of Satellite Connect, for example `evm:metamask`.
32
+ * @returns The name, for example `MetaMask`.
33
+ */
34
+ declare function walletLabel(connectorType: string): string;
35
+ /**
36
+ * The connected wallet of Satellite Connect in CAIP identifiers.
37
+ *
38
+ * @param connection - The active connection of the Satellite store: `address`, `chainId` (an EVM number or a Solana
39
+ * cluster), `connectorType`.
40
+ * @returns The wallet, or `null` without a connection or with a chain the checkout cannot read.
41
+ */
42
+ declare function connectedWallet(connection: {
43
+ address: string;
44
+ chainId: string | number;
45
+ connectorType: string;
46
+ } | null | undefined): CheckoutWallet | null;
47
+ /**
48
+ * The chain family of a payment method.
49
+ *
50
+ * @param method - The method.
51
+ * @returns `eip155` or `solana`; `null` for another namespace.
52
+ */
53
+ declare function methodFamily(method: CheckoutMethod): PaymentFamily | null;
54
+ /**
55
+ * The payer of a method for the connected wallet: its address on the method's chain. A wallet of the other family
56
+ * cannot pay it; a wallet on another chain of the family pays after switching (the quote names the method's chain).
57
+ *
58
+ * @param wallet - The connected wallet.
59
+ * @param method - The method.
60
+ * @returns The CAIP-10 account, or `null`.
61
+ */
62
+ declare function payerFor(wallet: CheckoutWallet | null, method: CheckoutMethod): string | null;
63
+ /**
64
+ * Whether a method can be paid by scanning a QR code with a phone: Solana with Solana Pay, an EVM method only through
65
+ * the payment page opened on the phone.
66
+ *
67
+ * @param method - The method.
68
+ * @param payUrl - The payment page of the invoice (its `payUrl`), if the app has it.
69
+ * @returns Whether the QR option applies.
70
+ */
71
+ declare function canPayWithQr(method: CheckoutMethod, payUrl?: string | null): boolean;
72
+ /**
73
+ * The discount or markup of a method, as the token and network options show it.
74
+ *
75
+ * @param method - The method.
76
+ * @returns `discount` or `markup` with the percent (`'1.5'`), or `null` for neither.
77
+ */
78
+ declare function priceAdjustment(method: CheckoutMethod): {
79
+ kind: 'discount' | 'markup';
80
+ percent: string;
81
+ } | null;
82
+ /**
83
+ * The name of a method's network, from the chain names of `@tuwaio/nova-core`.
84
+ *
85
+ * @param chainId - CAIP-2 chain of the method (`eip155:8453`, `solana:EtWT…`).
86
+ * @returns The name (`Base`, `Solana Devnet`), `Unknown` for a chain nova-core does not list.
87
+ */
88
+ declare function networkName(chainId: string): string;
89
+ /**
90
+ * The token of a method as a chain reads its balance, from its CAIP-19 asset.
91
+ *
92
+ * @param method - The payment method.
93
+ * @returns The token contract or mint, or `native` for the coin of the chain (a `slip44` asset, or none).
94
+ */
95
+ declare function methodToken(method: CheckoutMethod): string;
96
+
97
+ /** A fee in the native coin of a chain, in its base units. */
98
+ interface NativeFee {
99
+ /** The amount, in base units. */
100
+ amount: bigint;
101
+ /** Decimals of the native coin. */
102
+ decimals: number;
103
+ /** Symbol of the native coin. */
104
+ symbol: string;
105
+ }
106
+ /** A payment the wallet sent, with the texts of its transaction, for {@link PaymentsAdapter.pulsarTransaction}. */
107
+ interface PulsarTransactionParams {
108
+ /** The transaction hash (EVM) or signature (Solana). */
109
+ txKey: string;
110
+ /** What the wallet sent. */
111
+ instructions: PaymentInstructions;
112
+ /** The sender. */
113
+ account: string;
114
+ /** The connector of the wallet (`evm:metamask`). */
115
+ connectorType: string;
116
+ /** Title of the transaction (at most 100 characters). */
117
+ title: string;
118
+ /** Description of the transaction (at most 300 characters). */
119
+ description: string;
120
+ /** What the transaction pays: `quasarInvoice` is the invoice ID. */
121
+ payload: Record<string, string>;
122
+ }
123
+ /**
124
+ * What the checkout needs from a chain family to pay from the connected wallet. `@tuwaio/nova-payments/evm` and
125
+ * `@tuwaio/nova-payments/solana` make them; the checkout itself imports no chain library. Chains are CAIP-2 IDs, and
126
+ * amounts base units. A method that fails because of the wallet throws `PaymentWalletError` (or the wallet library's
127
+ * error, which the checkout reads with `walletErrorKind`).
128
+ */
129
+ interface PaymentsAdapter {
130
+ /** The chain family it pays on. */
131
+ family: PaymentFamily;
132
+ /**
133
+ * Reads a balance from the network in the browser (no request to Quasar).
134
+ *
135
+ * @param params - The chain, the account and the token (`native` for the coin of the chain).
136
+ * @returns The balance, in base units.
137
+ */
138
+ getBalance: (params: {
139
+ chainId: string;
140
+ account: string;
141
+ token: string;
142
+ }) => Promise<bigint>;
143
+ /**
144
+ * Estimates the network fee of the transfer, paid in the native coin.
145
+ *
146
+ * @param params - What the wallet sends and the sender.
147
+ * @returns The fee, or `null` when it cannot be estimated.
148
+ */
149
+ estimateFee?: (params: {
150
+ instructions: PaymentInstructions;
151
+ account: string;
152
+ }) => Promise<NativeFee | null>;
153
+ /**
154
+ * Whether the wallet sends `wallet_sendCalls` with the `paymasterService` capability on the chain (EIP-5792,
155
+ * ERC-7677).
156
+ *
157
+ * @param params - The chain and the account.
158
+ * @returns `true` when sponsored calls are possible.
159
+ */
160
+ canSponsorCalls?: (params: {
161
+ chainId: string;
162
+ account: string;
163
+ }) => Promise<boolean>;
164
+ /**
165
+ * Asks the wallet to switch to the chain of the payment.
166
+ *
167
+ * @param chainId - The chain.
168
+ */
169
+ switchChain?: (chainId: string) => Promise<void>;
170
+ /**
171
+ * Sends the transfer the quote describes, with the wallet's prompt.
172
+ *
173
+ * @param params - The quote's instructions, the sender, and the Satellite Connect connection of the wallet (the
174
+ * Solana adapter signs with its Wallet Standard account).
175
+ * @returns The transaction hash (EVM) or signature (Solana).
176
+ */
177
+ sendTransfer: (params: {
178
+ instructions: PaymentInstructions;
179
+ account: string;
180
+ connection?: unknown;
181
+ }) => Promise<string>;
182
+ /**
183
+ * Signs the EIP-3009 authorization of a gasless quote (`eth_signTypedData_v4`), with the wallet's prompt.
184
+ *
185
+ * @param params - The typed data and the signer.
186
+ * @returns The 65-byte signature.
187
+ */
188
+ signTransferAuthorization?: (params: {
189
+ typedData: TransferAuthorizationTypedData;
190
+ account: string;
191
+ }) => Promise<string>;
192
+ /**
193
+ * Sends the sponsored calls of a gasless quote with `wallet_sendCalls` and the paymaster, with the wallet's prompt,
194
+ * and waits for the transaction that carries them.
195
+ *
196
+ * @param params - The calls, the paymaster URL of the checkout, the chain, the sender, and `onSent`, called once the
197
+ * wallet accepted the calls (before they are included).
198
+ * @returns The hash of the transaction (not the batch ID), as Quasar expects it.
199
+ */
200
+ /**
201
+ * The link of a transaction on a block explorer of its chain.
202
+ *
203
+ * @param params - The chain and the transaction hash or signature.
204
+ * @returns The link, or `undefined` when the chain has no known explorer.
205
+ */
206
+ explorerUrl?: (params: {
207
+ chainId: string;
208
+ txKey: string;
209
+ }) => string | undefined;
210
+ /**
211
+ * Asks the wallet for the ERC-7715 permission of a subscription's automatic payments, with the wallet's prompt.
212
+ *
213
+ * @param params - The request of the checkout's auto-charge offer and the granting account.
214
+ * @returns What the wallet granted, for `grantPermission` of the checkout store (without the payer).
215
+ */
216
+ requestPermission?: (params: {
217
+ request: PermissionRequest;
218
+ account: string;
219
+ }) => Promise<Omit<GrantPermissionParams, 'payer'>>;
220
+ /**
221
+ * Describes a sent payment as a pending transaction of `@tuwaio/pulsar-core`, so that the app's Pulsar store tracks
222
+ * it (and Nova Transactions shows its toast) once the checkout closes.
223
+ *
224
+ * @param params - The payment and the texts of its transaction.
225
+ * @returns The pending transaction, for `injectExternalPendingTxs` of the Pulsar store.
226
+ */
227
+ pulsarTransaction?: (params: PulsarTransactionParams) => Transaction;
228
+ sendSponsoredCalls?: (params: {
229
+ calls: {
230
+ to: string;
231
+ value: string;
232
+ data: string;
233
+ }[];
234
+ paymasterUrl: string;
235
+ chainId: string;
236
+ account: string;
237
+ onSent?: () => void;
238
+ }) => Promise<string>;
239
+ }
240
+
241
+ export { type CheckoutWallet as C, type NativeFee as N, type PaymentsAdapter as P, type PaymentFamily as a, type PulsarTransactionParams as b, canPayWithQr as c, connectedWallet as d, methodToken as e, priceAdjustment as f, methodFamily as m, networkName as n, payerFor as p, walletLabel as w };
@@ -0,0 +1,241 @@
1
+ import { Transaction } from '@tuwaio/pulsar-core';
2
+ import { CheckoutMethod, PaymentInstructions, TransferAuthorizationTypedData, PermissionRequest, GrantPermissionParams } from '@tuwaio/quasar-sdk/checkout';
3
+
4
+ /**
5
+ * @file The connected wallet and the payment methods as the method step needs them: CAIP identifiers, the payer of a
6
+ * method, QR payments, discounts and markups.
7
+ */
8
+
9
+ /** The chain family of a payment method or wallet. */
10
+ type PaymentFamily = 'eip155' | 'solana';
11
+ /** The wallet connected through Satellite Connect, as the checkout uses it. */
12
+ interface CheckoutWallet {
13
+ /** The account address. */
14
+ address: string;
15
+ /** CAIP-2 chain the wallet is on (Solana clusters as their genesis-hash ID). */
16
+ chainId: string;
17
+ /** Its chain family. */
18
+ family: PaymentFamily;
19
+ /** Connector type of Satellite Connect (`evm:metamask`). */
20
+ connectorType: string;
21
+ /** The wallet id for `WalletIcon` of `@tuwaio/nova-core` (`metamask`). */
22
+ walletId: string;
23
+ /** The wallet name to show. */
24
+ name: string;
25
+ /** The Satellite Connect connection itself, for the chain adapters (the Solana adapter signs with its account). */
26
+ connection: unknown;
27
+ }
28
+ /**
29
+ * The name of a wallet from its connector type.
30
+ *
31
+ * @param connectorType - Connector type of Satellite Connect, for example `evm:metamask`.
32
+ * @returns The name, for example `MetaMask`.
33
+ */
34
+ declare function walletLabel(connectorType: string): string;
35
+ /**
36
+ * The connected wallet of Satellite Connect in CAIP identifiers.
37
+ *
38
+ * @param connection - The active connection of the Satellite store: `address`, `chainId` (an EVM number or a Solana
39
+ * cluster), `connectorType`.
40
+ * @returns The wallet, or `null` without a connection or with a chain the checkout cannot read.
41
+ */
42
+ declare function connectedWallet(connection: {
43
+ address: string;
44
+ chainId: string | number;
45
+ connectorType: string;
46
+ } | null | undefined): CheckoutWallet | null;
47
+ /**
48
+ * The chain family of a payment method.
49
+ *
50
+ * @param method - The method.
51
+ * @returns `eip155` or `solana`; `null` for another namespace.
52
+ */
53
+ declare function methodFamily(method: CheckoutMethod): PaymentFamily | null;
54
+ /**
55
+ * The payer of a method for the connected wallet: its address on the method's chain. A wallet of the other family
56
+ * cannot pay it; a wallet on another chain of the family pays after switching (the quote names the method's chain).
57
+ *
58
+ * @param wallet - The connected wallet.
59
+ * @param method - The method.
60
+ * @returns The CAIP-10 account, or `null`.
61
+ */
62
+ declare function payerFor(wallet: CheckoutWallet | null, method: CheckoutMethod): string | null;
63
+ /**
64
+ * Whether a method can be paid by scanning a QR code with a phone: Solana with Solana Pay, an EVM method only through
65
+ * the payment page opened on the phone.
66
+ *
67
+ * @param method - The method.
68
+ * @param payUrl - The payment page of the invoice (its `payUrl`), if the app has it.
69
+ * @returns Whether the QR option applies.
70
+ */
71
+ declare function canPayWithQr(method: CheckoutMethod, payUrl?: string | null): boolean;
72
+ /**
73
+ * The discount or markup of a method, as the token and network options show it.
74
+ *
75
+ * @param method - The method.
76
+ * @returns `discount` or `markup` with the percent (`'1.5'`), or `null` for neither.
77
+ */
78
+ declare function priceAdjustment(method: CheckoutMethod): {
79
+ kind: 'discount' | 'markup';
80
+ percent: string;
81
+ } | null;
82
+ /**
83
+ * The name of a method's network, from the chain names of `@tuwaio/nova-core`.
84
+ *
85
+ * @param chainId - CAIP-2 chain of the method (`eip155:8453`, `solana:EtWT…`).
86
+ * @returns The name (`Base`, `Solana Devnet`), `Unknown` for a chain nova-core does not list.
87
+ */
88
+ declare function networkName(chainId: string): string;
89
+ /**
90
+ * The token of a method as a chain reads its balance, from its CAIP-19 asset.
91
+ *
92
+ * @param method - The payment method.
93
+ * @returns The token contract or mint, or `native` for the coin of the chain (a `slip44` asset, or none).
94
+ */
95
+ declare function methodToken(method: CheckoutMethod): string;
96
+
97
+ /** A fee in the native coin of a chain, in its base units. */
98
+ interface NativeFee {
99
+ /** The amount, in base units. */
100
+ amount: bigint;
101
+ /** Decimals of the native coin. */
102
+ decimals: number;
103
+ /** Symbol of the native coin. */
104
+ symbol: string;
105
+ }
106
+ /** A payment the wallet sent, with the texts of its transaction, for {@link PaymentsAdapter.pulsarTransaction}. */
107
+ interface PulsarTransactionParams {
108
+ /** The transaction hash (EVM) or signature (Solana). */
109
+ txKey: string;
110
+ /** What the wallet sent. */
111
+ instructions: PaymentInstructions;
112
+ /** The sender. */
113
+ account: string;
114
+ /** The connector of the wallet (`evm:metamask`). */
115
+ connectorType: string;
116
+ /** Title of the transaction (at most 100 characters). */
117
+ title: string;
118
+ /** Description of the transaction (at most 300 characters). */
119
+ description: string;
120
+ /** What the transaction pays: `quasarInvoice` is the invoice ID. */
121
+ payload: Record<string, string>;
122
+ }
123
+ /**
124
+ * What the checkout needs from a chain family to pay from the connected wallet. `@tuwaio/nova-payments/evm` and
125
+ * `@tuwaio/nova-payments/solana` make them; the checkout itself imports no chain library. Chains are CAIP-2 IDs, and
126
+ * amounts base units. A method that fails because of the wallet throws `PaymentWalletError` (or the wallet library's
127
+ * error, which the checkout reads with `walletErrorKind`).
128
+ */
129
+ interface PaymentsAdapter {
130
+ /** The chain family it pays on. */
131
+ family: PaymentFamily;
132
+ /**
133
+ * Reads a balance from the network in the browser (no request to Quasar).
134
+ *
135
+ * @param params - The chain, the account and the token (`native` for the coin of the chain).
136
+ * @returns The balance, in base units.
137
+ */
138
+ getBalance: (params: {
139
+ chainId: string;
140
+ account: string;
141
+ token: string;
142
+ }) => Promise<bigint>;
143
+ /**
144
+ * Estimates the network fee of the transfer, paid in the native coin.
145
+ *
146
+ * @param params - What the wallet sends and the sender.
147
+ * @returns The fee, or `null` when it cannot be estimated.
148
+ */
149
+ estimateFee?: (params: {
150
+ instructions: PaymentInstructions;
151
+ account: string;
152
+ }) => Promise<NativeFee | null>;
153
+ /**
154
+ * Whether the wallet sends `wallet_sendCalls` with the `paymasterService` capability on the chain (EIP-5792,
155
+ * ERC-7677).
156
+ *
157
+ * @param params - The chain and the account.
158
+ * @returns `true` when sponsored calls are possible.
159
+ */
160
+ canSponsorCalls?: (params: {
161
+ chainId: string;
162
+ account: string;
163
+ }) => Promise<boolean>;
164
+ /**
165
+ * Asks the wallet to switch to the chain of the payment.
166
+ *
167
+ * @param chainId - The chain.
168
+ */
169
+ switchChain?: (chainId: string) => Promise<void>;
170
+ /**
171
+ * Sends the transfer the quote describes, with the wallet's prompt.
172
+ *
173
+ * @param params - The quote's instructions, the sender, and the Satellite Connect connection of the wallet (the
174
+ * Solana adapter signs with its Wallet Standard account).
175
+ * @returns The transaction hash (EVM) or signature (Solana).
176
+ */
177
+ sendTransfer: (params: {
178
+ instructions: PaymentInstructions;
179
+ account: string;
180
+ connection?: unknown;
181
+ }) => Promise<string>;
182
+ /**
183
+ * Signs the EIP-3009 authorization of a gasless quote (`eth_signTypedData_v4`), with the wallet's prompt.
184
+ *
185
+ * @param params - The typed data and the signer.
186
+ * @returns The 65-byte signature.
187
+ */
188
+ signTransferAuthorization?: (params: {
189
+ typedData: TransferAuthorizationTypedData;
190
+ account: string;
191
+ }) => Promise<string>;
192
+ /**
193
+ * Sends the sponsored calls of a gasless quote with `wallet_sendCalls` and the paymaster, with the wallet's prompt,
194
+ * and waits for the transaction that carries them.
195
+ *
196
+ * @param params - The calls, the paymaster URL of the checkout, the chain, the sender, and `onSent`, called once the
197
+ * wallet accepted the calls (before they are included).
198
+ * @returns The hash of the transaction (not the batch ID), as Quasar expects it.
199
+ */
200
+ /**
201
+ * The link of a transaction on a block explorer of its chain.
202
+ *
203
+ * @param params - The chain and the transaction hash or signature.
204
+ * @returns The link, or `undefined` when the chain has no known explorer.
205
+ */
206
+ explorerUrl?: (params: {
207
+ chainId: string;
208
+ txKey: string;
209
+ }) => string | undefined;
210
+ /**
211
+ * Asks the wallet for the ERC-7715 permission of a subscription's automatic payments, with the wallet's prompt.
212
+ *
213
+ * @param params - The request of the checkout's auto-charge offer and the granting account.
214
+ * @returns What the wallet granted, for `grantPermission` of the checkout store (without the payer).
215
+ */
216
+ requestPermission?: (params: {
217
+ request: PermissionRequest;
218
+ account: string;
219
+ }) => Promise<Omit<GrantPermissionParams, 'payer'>>;
220
+ /**
221
+ * Describes a sent payment as a pending transaction of `@tuwaio/pulsar-core`, so that the app's Pulsar store tracks
222
+ * it (and Nova Transactions shows its toast) once the checkout closes.
223
+ *
224
+ * @param params - The payment and the texts of its transaction.
225
+ * @returns The pending transaction, for `injectExternalPendingTxs` of the Pulsar store.
226
+ */
227
+ pulsarTransaction?: (params: PulsarTransactionParams) => Transaction;
228
+ sendSponsoredCalls?: (params: {
229
+ calls: {
230
+ to: string;
231
+ value: string;
232
+ data: string;
233
+ }[];
234
+ paymasterUrl: string;
235
+ chainId: string;
236
+ account: string;
237
+ onSent?: () => void;
238
+ }) => Promise<string>;
239
+ }
240
+
241
+ export { type CheckoutWallet as C, type NativeFee as N, type PaymentsAdapter as P, type PaymentFamily as a, type PulsarTransactionParams as b, canPayWithQr as c, connectedWallet as d, methodToken as e, priceAdjustment as f, methodFamily as m, networkName as n, payerFor as p, walletLabel as w };
package/package.json CHANGED
@@ -1,6 +1,154 @@
1
1
  {
2
2
  "name": "@tuwaio/nova-payments",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.0",
4
+ "private": false,
5
+ "author": "Oleksandr Tkach",
6
+ "license": "Apache-2.0",
7
+ "description": "L7 payments package of Nova UI Kit (TUWA): the checkout of Quasar Payments invoices, with crypto payments from a wallet or a QR code, in a modal, inline or on a page.",
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
17
+ },
18
+ "./i18n": {
19
+ "types": "./dist/i18n/index.d.ts",
20
+ "import": "./dist/i18n/index.js",
21
+ "require": "./dist/i18n/index.cjs"
22
+ },
23
+ "./evm": {
24
+ "types": "./dist/evm/index.d.ts",
25
+ "import": "./dist/evm/index.js",
26
+ "require": "./dist/evm/index.cjs"
27
+ },
28
+ "./solana": {
29
+ "types": "./dist/solana/index.d.ts",
30
+ "import": "./dist/solana/index.js",
31
+ "require": "./dist/solana/index.cjs"
32
+ },
33
+ "./dist/index.css": "./dist/index.css"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "socket.json"
41
+ ],
42
+ "scripts": {
43
+ "build": "tsup && pnpm exec postcss ./src/styles/app.css -o ./dist/index.css",
44
+ "test": "vitest run"
45
+ },
46
+ "keywords": [
47
+ "react",
48
+ "web3",
49
+ "payments",
50
+ "checkout",
51
+ "crypto-payments",
52
+ "stablecoins",
53
+ "invoice",
54
+ "quasar",
55
+ "ui",
56
+ "components",
57
+ "tailwind",
58
+ "i18n",
59
+ "accessibility",
60
+ "nova",
61
+ "tuwa"
62
+ ],
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "git+https://github.com/TuwaIO/nova-uikit.git",
66
+ "directory": "packages/nova-payments"
67
+ },
68
+ "homepage": "https://github.com/TuwaIO/nova-uikit",
69
+ "bugs": {
70
+ "url": "https://github.com/TuwaIO/nova-uikit/issues"
71
+ },
72
+ "contributors": [
73
+ {
74
+ "name": "Oleksandr Tkach",
75
+ "url": "https://github.com/Argeare5"
76
+ }
77
+ ],
78
+ "peerDependencies": {
79
+ "@heroicons/react": "2.x.x",
80
+ "@solana-program/system": ">=0.15",
81
+ "@solana-program/token": ">=0.17",
82
+ "@solana/kit": ">=8.2",
83
+ "@tuwaio/nova-connect": ">=0.10",
84
+ "@tuwaio/nova-core": ">=0.10",
85
+ "@tuwaio/nova-transactions": ">=0.9",
86
+ "@tuwaio/orbit-core": ">=0.5",
87
+ "@tuwaio/orbit-solana": ">=0.5",
88
+ "@tuwaio/pulsar-core": ">=0.10",
89
+ "@tuwaio/quasar-sdk": ">=0.6",
90
+ "@tuwaio/satellite-react": ">=0.9",
91
+ "@wagmi/core": "3.x.x",
92
+ "framer-motion": "12.x.x || 13.x.x || 14.x.x",
93
+ "react": ">=19.2.3",
94
+ "viem": "2.x.x",
95
+ "zustand": "5.x.x"
96
+ },
97
+ "peerDependenciesMeta": {
98
+ "@solana-program/system": {
99
+ "optional": true
100
+ },
101
+ "@solana-program/token": {
102
+ "optional": true
103
+ },
104
+ "@solana/kit": {
105
+ "optional": true
106
+ },
107
+ "@tuwaio/orbit-solana": {
108
+ "optional": true
109
+ },
110
+ "@wagmi/core": {
111
+ "optional": true
112
+ },
113
+ "viem": {
114
+ "optional": true
115
+ }
116
+ },
117
+ "devDependencies": {
118
+ "@heroicons/react": "^2.2.0",
119
+ "@radix-ui/react-dialog": "^1.2.0",
120
+ "@solana-program/system": "^0.15.0",
121
+ "@solana-program/token": "^0.17.0",
122
+ "@solana/kit": "^8.4.0",
123
+ "@tailwindcss/postcss": "^4.3.3",
124
+ "@tuwaio/nova-connect": "workspace:^",
125
+ "@tuwaio/nova-core": "workspace:^",
126
+ "@tuwaio/nova-transactions": "workspace:^",
127
+ "@tuwaio/orbit-core": "0.5.1",
128
+ "@tuwaio/orbit-solana": "0.5.0",
129
+ "@tuwaio/pulsar-core": "0.10.0",
130
+ "@tuwaio/quasar-sdk": "1.0.0-feat-payments-alpha.5.0e5bec2",
131
+ "@tuwaio/satellite-core": "^0.9.0",
132
+ "@tuwaio/satellite-react": "^0.9.0",
133
+ "@types/react": "^19.3.0",
134
+ "@wagmi/core": "^3.6.5",
135
+ "@web3icons/common": "^0.11.53",
136
+ "@web3icons/react": "^4.1.24",
137
+ "autoprefixer": "^10.6.1",
138
+ "clsx": "^2.1.1",
139
+ "framer-motion": "14.0.0",
140
+ "postcss": "^8.5.29",
141
+ "postcss-cli": "^12.0.0",
142
+ "react": "^19.3.0",
143
+ "tailwind-merge": "^3.7.0",
144
+ "tailwindcss": "^4.3.3",
145
+ "tsup": "^8.5.1",
146
+ "typescript": "6.0.3",
147
+ "viem": "^2.57.3",
148
+ "vitest": "^5.0.3",
149
+ "zustand": "^5.0.15"
150
+ },
151
+ "dependencies": {
152
+ "uqr": "^0.1.3"
153
+ }
154
+ }
package/socket.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://socket.dev/config/schema.json",
3
+ "version": 1,
4
+ "issueRules": {
5
+ "networkAccess": "ignore",
6
+ "envVars": "ignore",
7
+ "filesystemAccess": "ignore",
8
+ "shellAccess": "ignore",
9
+ "minifiedFile": "ignore",
10
+ "obfuscatedFile": "ignore",
11
+ "urlStrings": "ignore",
12
+ "unpopularPackage": "ignore",
13
+ "unstableOwnership": "ignore",
14
+ "newAuthor": "ignore",
15
+ "gptAnomaly": "ignore"
16
+ }
17
+ }