@phala/pay 0.12.2 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -175,7 +175,6 @@ import { PaymentElement } from "@phala/pay-react";
175
175
  createQuote={(option, { idempotencyKey }) =>
176
176
  api.createTopUp({ amount: 2500, chain_id: option.chain_id, asset: option.asset, idempotencyKey })
177
177
  }
178
- createDepositAddress={() => api.depositAddress()} // optional: "Use a deposit address"
179
178
  apiBase="https://pay.example.com"
180
179
  renderDetail={(option) => (option.asset === "usdc" ? "$1.00" : "Market rate")}
181
180
  onSuccess={() => router.refresh()}
@@ -187,7 +186,7 @@ import { PaymentElement } from "@phala/pay-react";
187
186
  `{ clientSecret, expectedAddress, apiBase? }`; `apiBase` falls back to the prop. A rejection
188
187
  shows "Could not start the payment. Try again." and calls `onError(error)`. To show your own
189
188
  reason in that alert instead, pass `errorMessage(cause)`: a non-empty string replaces the text,
190
- and `null` or `undefined` keeps it. It applies to `createDepositAddress` too.
189
+ and `null` or `undefined` keeps it.
191
190
  - Create the quote with `idempotencyKey` as its `Idempotency-Key`, not an order id of yours: the
192
191
  key is a new random UUID for each quote the payer asks for (another option or amount, or a new
193
192
  quote after going back from one) and the same only when they retry after `createQuote` failed
@@ -198,46 +197,12 @@ import { PaymentElement } from "@phala/pay-react";
198
197
  a retry would reuse a key with another body.
199
198
  - After the quote: the checkout, and a way back to the options ("Back") until a payment is on its
200
199
  way, then "Start a new payment" once it is credited or does not complete.
201
- - `createDepositAddress(option)` adds one quiet line at the end of the form, "Paying from an
202
- exchange? Use a deposit address", for payers sending from an exchange or any wallet: it resolves
203
- with the deposit address's `address` and `networks` and, to follow its payments, `clientSecret`;
204
- the element shows `<DepositAddress>` at the chosen option, which states the per-transfer limits.
205
- - **Deposit-address mode.** Without `createQuote`, submit calls `createDepositAddress(option)` once
206
- and shows that address as the way to pay, with no secondary line: the customer's one fixed address
207
- instead of a new quote per payment. `depositAmountAtomic(option, token)` names the token amount to
208
- ask for in the token's smallest unit (`undefined` for any amount); it is called once the address
209
- is created, with its token for the chosen option, whose `decimals` give the unit. The address view
210
- then states the amount and network once, pays it with `Pay with <wallet name>`
211
- (`payDepositAddressWithWallet`: exactly that amount, then a transaction-hash hint), and keeps a QR
212
- code that requests the amount (EIP-681 `uint256`) and the address to copy behind "Pay from an
213
- exchange or another wallet". It follows the payment the wallet sent, by its hash, or else the
214
- newest one that arrives after the address was first read, on one status line; `onChange` reports
215
- it as `payment`, and `onDepositSuccess(payment)` is called once when it is credited. An address
216
- that does not take the chosen token on the chosen network is a `createDepositAddress` failure. To
217
- resume after a reload, keep `onDepositSent(txHash, chainId)`'s values and pass them back as
218
- `depositTxHash`, with that option as `value` or `defaultValue`: the element calls
219
- `createDepositAddress` at once and shows that payment's status (no way to pay again) until it is
220
- credited.
221
-
222
- ```tsx
223
- <PaymentElement
224
- options={paymentOptions(config.assets)}
225
- amount={2500}
226
- // POST /v1/deposit_addresses on your backend: { address, networks, clientSecret }
227
- createDepositAddress={() => api.depositAddress()}
228
- // 25 of a $1 stablecoin: cents × 10^(decimals − 2)
229
- depositAmountAtomic={(option, token) => (2500n * 10n ** BigInt(token.decimals)) / 100n}
230
- apiBase="https://pay.example.com"
231
- onDepositSuccess={() => router.refresh()}
232
- />
233
- ```
234
-
235
200
  - Your own content: `children` go inside the form, under the token and network and above the
236
201
  element's button, while the payer chooses. With `hideSubmit`, put your summary and your
237
202
  `type="submit"` button there, and the deposit-address line follows your button:
238
203
 
239
204
  ```tsx
240
- <PaymentElement hideSubmit options={options} createQuote={createQuote} createDepositAddress={createDepositAddress}>
205
+ <PaymentElement hideSubmit options={options} createQuote={createQuote}>
241
206
  <OrderSummary />
242
207
  <Button type="submit">Continue to pay $25.00</Button>
243
208
  </PaymentElement>
@@ -247,10 +212,9 @@ import { PaymentElement } from "@phala/pay-react";
247
212
  button `type="submit" form={id}` (or call `requestSubmit()` on the form with that id). The
248
213
  element is a `<form>`: do not nest it in another one.
249
214
  - `value` and `onOptionChange` control the choice (`defaultValue` sets the first one otherwise);
250
- `onChange({ step, checkout, payment })` reports each step (`options`, `creating`, `checkout`,
251
- `deposit_address`) and, while paying, each checkout status change or, with
252
- `depositAmountAtomic`, each change of the deposit address's payment; `onSuccess`, `onExpire`,
253
- `onWalletError`, `walletClient`, `pollInterval`, and `appearance` are `<Checkout>`'s.
215
+ `onChange({ step, checkout })` reports each step (`options`, `creating`, `checkout`) and each
216
+ checkout status change; `onSuccess`, `onExpire`, `onWalletError`, `walletClient`, `pollInterval`,
217
+ and `appearance` are `<Checkout>`'s.
254
218
 
255
219
  ### Payment options
256
220
 
@@ -328,22 +292,8 @@ not report loading. Unchanged polls, callback replacements,
328
292
  and reconnecting alone do not trigger it. Use it to update your page without additional polling;
329
293
  fulfil from the `deposit.credited` webhook.
330
294
 
331
- With `amountAtomic` (an amount of the token at `chainId` and `asset`, which then stay fixed), it
332
- asks for that amount instead: the amount and network stated once, a `Pay with <wallet name>` button
333
- (`walletClient`, `buttonText`, and `onWalletError` as `<Checkout>`'s), and "Pay from an exchange or
334
- another wallet" revealing a QR code that requests exactly the amount and the address to copy (shown
335
- at once when the browser has no wallet). With `clientSecret` and `apiBase` it follows that payment
336
- (the wallet's transaction by its hash, else the newest payment that arrives after the address was
337
- first read) on one status line, calls `onPaymentChange(payment)` as it changes and `onSuccess(payment)`
338
- once it is credited, and replaces the ways to pay with that status once it is on its way.
339
- `onSent(txHash, chainId)` reports the wallet's transaction; pass it back as `txHash` after a
340
- reload to follow that payment again.
341
-
342
- `depositAddressTransfer(network, asset)` reads and checks one token's amount-less EIP-681
343
- `payment_uri` without React; `payDepositAddressWithWallet(wallet, { network, asset, amountAtomic,
344
- clientSecret?, apiBase? })` pays an amount of it from a wallet as `payWithWallet` pays a quote
345
- (connect, switch chain, balance check, `transfer`), then, with `clientSecret` and `apiBase`, hints
346
- the transaction with its `chain_id` without waiting on the hint, and resolves with the hash.
295
+ `depositAddressTransfer(network, asset)` reads and checks one token's amountless EIP-681
296
+ `payment_uri` without React. `<DepositAddress>` accepts any amount within its per-transfer limits.
347
297
 
348
298
  ## Appearance
349
299
 
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export { depositAddressTransfer, parseTransferUri, quoteTransfer, type DepositAd
7
7
  export { parseClientQuote, quoteIdFromClientSecret, type ClientQuote } from "./quote.js";
8
8
  export { assetIconName, assetName, assetSymbol, iconMonogram, type IconName } from "./icon-names.js";
9
9
  export { paymentOptionLabel, paymentOptions, samePaymentOption, type NetworkPaymentOption, type PaymentNetwork, type PaymentOption, } from "./options.js";
10
- export { INJECTED_WALLET_UUID, WalletError, payDepositAddressWithWallet, payWithWallet, watchWallets, type EthereumProvider, type PayDepositAddressOptions, type Wallet, type WalletErrorCode, type WalletInfo, } from "./wallet.js";
10
+ export { INJECTED_WALLET_UUID, WalletError, payWithWallet, watchWallets, type EthereumProvider, type Wallet, type WalletErrorCode, type WalletInfo, } from "./wallet.js";
11
11
  export { networkIcon, assetIcon } from "./icons.js";
12
12
  export type { CheckoutParams } from "./shared/checkout-params.js";
13
13
  export { submitTransaction, type SubmitTransactionOptions } from "./transactions.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,SAAS,EACT,cAAc,EACd,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACL,gCAAgC,EAChC,yBAAyB,EACzB,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,6BAA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KAAK,gBAAgB,EACrB,KAAK,MAAM,EACX,KAAK,eAAe,EACpB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ export { depositAddressTransfer, parseTransferUri, quoteTransfer, } from "./paym
7
7
  export { parseClientQuote, quoteIdFromClientSecret } from "./quote.js";
8
8
  export { assetIconName, assetName, assetSymbol, iconMonogram } from "./icon-names.js";
9
9
  export { paymentOptionLabel, paymentOptions, samePaymentOption, } from "./options.js";
10
- export { INJECTED_WALLET_UUID, WalletError, payDepositAddressWithWallet, payWithWallet, watchWallets, } from "./wallet.js";
10
+ export { INJECTED_WALLET_UUID, WalletError, payWithWallet, watchWallets, } from "./wallet.js";
11
11
  export { networkIcon, assetIcon } from "./icons.js";
12
12
  export { submitTransaction } from "./transactions.js";
13
13
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,SAAS,EACT,cAAc,EACd,aAAa,GAQd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAwB,MAAM,aAAa,CAAC;AAC7D,OAAO,EACL,gCAAgC,EAChC,yBAAyB,EACzB,sBAAsB,GAKvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,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CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAiB,MAAM,iBAAiB,CAAC;AACrG,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,GAIlB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,YAAY,GAKb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGpD,OAAO,EAAE,iBAAiB,EAAiC,MAAM,mBAAmB,CAAC"}
package/dist/quote.d.ts CHANGED
@@ -17,8 +17,13 @@ export interface ClientQuote {
17
17
  chain_id: number;
18
18
  /** The exact token amount to send, in the token's smallest unit, as a decimal string. */
19
19
  amount_atomic: string;
20
- /** The quote's single-use deposit address. */
20
+ /** The customer's fixed deposit address on the chosen network. */
21
21
  address: string;
22
+ deposit_address: string | null;
23
+ deposit_address_version: number | null;
24
+ replaced_by: string | null;
25
+ /** Exclusive start of the price window, Unix seconds. */
26
+ window_start: number;
22
27
  /** The EIP-681 payment request: token transfer of `amount_atomic` to `address`. */
23
28
  payment_uri: string;
24
29
  /** Unix seconds; after this the address must no longer be shown. */
@@ -1 +1 @@
1
- {"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,QAAQ,EAAE,OAAO,CAAC;IAClB,iGAAiG;IACjG,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;IACrD,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,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;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;;OAKG;IACH,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;IACtF,8EAA8E;IAC9E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;OAIG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;OAIG;IACH,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAKD,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAMpE;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CA4D5D"}
package/dist/quote.js CHANGED
@@ -30,6 +30,10 @@ export function parseClientQuote(value) {
30
30
  !/^\d+$/.test(v["amount_atomic"]) ||
31
31
  typeof v["address"] !== "string" ||
32
32
  !/^0x[0-9a-fA-F]{40}$/.test(v["address"]) ||
33
+ !(v["deposit_address"] === null || typeof v["deposit_address"] === "string") ||
34
+ !(v["deposit_address_version"] === null || isSafeInteger(v["deposit_address_version"])) ||
35
+ !(v["replaced_by"] === null || typeof v["replaced_by"] === "string") ||
36
+ !isSafeInteger(v["window_start"]) ||
33
37
  typeof v["payment_uri"] !== "string" ||
34
38
  !isSafeInteger(v["expires_at"]) ||
35
39
  !(cancelRequestedAt === undefined || cancelRequestedAt === null || isSafeInteger(cancelRequestedAt)) ||
@@ -51,6 +55,10 @@ export function parseClientQuote(value) {
51
55
  chain_id: v["chain_id"],
52
56
  amount_atomic: v["amount_atomic"],
53
57
  address: v["address"],
58
+ deposit_address: v["deposit_address"],
59
+ deposit_address_version: v["deposit_address_version"],
60
+ replaced_by: v["replaced_by"],
61
+ window_start: v["window_start"],
54
62
  payment_uri: v["payment_uri"],
55
63
  expires_at: v["expires_at"],
56
64
  ...(cancelRequestedAt === undefined ? {} : { cancel_requested_at: cancelRequestedAt }),
package/dist/quote.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"quote.js","sourceRoot":"","sources":["../src/quote.ts"],"names":[],"mappings":"AAkDA,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AAC5E,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAU,CAAC;AAErG,oFAAoF;AACpF,MAAM,UAAU,uBAAuB,CAAC,YAAoB;IAC1D,MAAM,KAAK,GAAG,mCAAmC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACrE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,MAAM,aAAa,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC;IACzC,MAAM,cAAc,G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AQ,CAAC,KAAK,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC"}
package/dist/wallet.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { type Hash, type WalletClient } from "viem";
2
- import { type DepositAddressAsset, type DepositAddressNetwork } from "./payment.js";
3
2
  import type { ClientQuote } from "./quote.js";
4
3
  /** EIP-6963 provider info. */
5
4
  export interface WalletInfo {
@@ -44,28 +43,4 @@ export declare class WalletError extends Error {
44
43
  * it; the checkout's status follows the payment from there.
45
44
  */
46
45
  export declare function payWithWallet(wallet: WalletClient | EthereumProvider, quote: ClientQuote): Promise<Hash>;
47
- export interface PayDepositAddressOptions {
48
- /** The network to pay on, from the deposit address's `networks`. */
49
- network: DepositAddressNetwork;
50
- /** The token to pay in, from that network's `assets`. */
51
- asset: DepositAddressAsset;
52
- /** The token amount to send, in the smallest unit; positive. */
53
- amountAtomic: bigint;
54
- /**
55
- * The address's `client_secret`. With `apiBase`, the transaction hash is sent to the service as
56
- * a best-effort hint once the wallet broadcasts it, so the payment is found within about a block.
57
- */
58
- clientSecret?: string | undefined;
59
- /** The service origin; needed with `clientSecret`. */
60
- apiBase?: string | undefined;
61
- }
62
- /**
63
- * Pays `amountAtomic` of a token to a customer's deposit address from a wallet, as `payWithWallet`
64
- * pays a quote: connects, switches to (or adds) the network's chain, checks the token balance, and
65
- * sends the ERC-20 `transfer` that the token's `payment_uri` states, for exactly that amount. Then,
66
- * with `clientSecret` and `apiBase`, it hints the transaction to the service without waiting for
67
- * or failing on it. Resolves with the transaction hash once the wallet has broadcast it; follow the
68
- * payment in the address's `payments` by that hash.
69
- */
70
- export declare function payDepositAddressWithWallet(wallet: WalletClient | EthereumProvider, { network, asset, amountAtomic, clientSecret, apiBase }: PayDepositAddressOptions): Promise<Hash>;
71
46
  //# sourceMappingURL=wallet.d.ts.map
@@ -1 +1 @@
1
-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AC5B;AAED,iGAAiG;AACjG,eAAO,MAAM,oBAAoB,aAAa,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAa9E;AA8BD,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,YAAY,GACZ,aAAa,GACb,sBAAsB,GACtB,QAAQ,CAAC;AAEb,qBAAa,WAAY,SAAQ,KAAK;IAIlC,QAAQ,CAAC,IAAI,EAAE,eAAe;IAHhC,SAAkB,IAAI,iBAAiB;gBAG5B,IAAI,EAAE,eAAe,EAC9B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,GAAG,gBAAgB,EACvC,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CAIf"}
package/dist/wallet.js CHANGED
@@ -1,10 +1,10 @@
1
- import { submitTransaction, submitWalletTransaction } from "./transactions.js";
1
+ import { submitWalletTransaction } from "./transactions.js";
2
2
  import { createStore } from "mipd";
3
3
  import { BaseError, createWalletClient, custom, erc20Abi, SwitchChainError, UserRejectedRequestError, } from "viem";
4
4
  import { readContract } from "viem/actions";
5
5
  import { knownChain, networkName } from "./chains.js";
6
6
  import { formatUnitsGrouped } from "./format.js";
7
- import { depositAddressTransfer, quoteTransfer, } from "./payment.js";
7
+ import { quoteTransfer, } from "./payment.js";
8
8
  /** The legacy `window.ethereum` provider, offered when no wallet announces itself (EIP-6963). */
9
9
  export const INJECTED_WALLET_UUID = "injected";
10
10
  /**
@@ -72,25 +72,6 @@ export async function payWithWallet(wallet, quote) {
72
72
  submitWalletTransaction(quote, hash);
73
73
  return hash;
74
74
  }
75
- /**
76
- * Pays `amountAtomic` of a token to a customer's deposit address from a wallet, as `payWithWallet`
77
- * pays a quote: connects, switches to (or adds) the network's chain, checks the token balance, and
78
- * sends the ERC-20 `transfer` that the token's `payment_uri` states, for exactly that amount. Then,
79
- * with `clientSecret` and `apiBase`, it hints the transaction to the service without waiting for
80
- * or failing on it. Resolves with the transaction hash once the wallet has broadcast it; follow the
81
- * payment in the address's `payments` by that hash.
82
- */
83
- export async function payDepositAddressWithWallet(wallet, { network, asset, amountAtomic, clientSecret, apiBase }) {
84
- if (amountAtomic <= 0n) {
85
- throw new TypeError("amountAtomic must be positive");
86
- }
87
- const transfer = { ...depositAddressTransfer(network, asset), amount: amountAtomic };
88
- const hash = await sendTransfer(wallet, transfer, asset.asset, asset.decimals);
89
- if (clientSecret !== undefined && apiBase !== undefined) {
90
- void submitTransaction({ apiBase, clientSecret, transactionHash: hash, chainId: transfer.chainId }).catch(() => undefined);
91
- }
92
- return hash;
93
- }
94
75
  async function sendTransfer(wallet, transfer, asset, decimals) {
95
76
  const client = isWalletClient(wallet) ? wallet : createWalletClient({ transport: custom(wallet) });
96
77
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,wBAAwB,GAIzB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,aAAa,GAId,MAAM,cAAc,CAAC;AAsBtB,iGAAiG;AACjG,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,Y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AAE,IAAI,KAAK,gBAAgB,CAAC,IAAI,CAAC;QAChG,CAAC,CAAC,KAAK,IAAI,CACZ,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phala/pay",
3
- "version": "0.12.2",
3
+ "version": "0.13.0",
4
4
  "description": "Phala Pay framework-free browser client",
5
5
  "keywords": [
6
6
  "crypto",
package/src/index.ts CHANGED
@@ -47,11 +47,9 @@ export {
47
47
  export {
48
48
  INJECTED_WALLET_UUID,
49
49
  WalletError,
50
- payDepositAddressWithWallet,
51
50
  payWithWallet,
52
51
  watchWallets,
53
52
  type EthereumProvider,
54
- type PayDepositAddressOptions,
55
53
  type Wallet,
56
54
  type WalletErrorCode,
57
55
  type WalletInfo,
package/src/quote.ts CHANGED
@@ -17,8 +17,13 @@ export interface ClientQuote {
17
17
  chain_id: number;
18
18
  /** The exact token amount to send, in the token's smallest unit, as a decimal string. */
19
19
  amount_atomic: string;
20
- /** The quote's single-use deposit address. */
20
+ /** The customer's fixed deposit address on the chosen network. */
21
21
  address: string;
22
+ deposit_address: string | null;
23
+ deposit_address_version: number | null;
24
+ replaced_by: string | null;
25
+ /** Exclusive start of the price window, Unix seconds. */
26
+ window_start: number;
22
27
  /** The EIP-681 payment request: token transfer of `amount_atomic` to `address`. */
23
28
  payment_uri: string;
24
29
  /** Unix seconds; after this the address must no longer be shown. */
@@ -83,6 +88,10 @@ export function parseClientQuote(value: unknown): ClientQuote {
83
88
  !/^\d+$/.test(v["amount_atomic"]) ||
84
89
  typeof v["address"] !== "string" ||
85
90
  !/^0x[0-9a-fA-F]{40}$/.test(v["address"]) ||
91
+ !(v["deposit_address"] === null || typeof v["deposit_address"] === "string") ||
92
+ !(v["deposit_address_version"] === null || isSafeInteger(v["deposit_address_version"])) ||
93
+ !(v["replaced_by"] === null || typeof v["replaced_by"] === "string") ||
94
+ !isSafeInteger(v["window_start"]) ||
86
95
  typeof v["payment_uri"] !== "string" ||
87
96
  !isSafeInteger(v["expires_at"]) ||
88
97
  !(cancelRequestedAt === undefined || cancelRequestedAt === null || isSafeInteger(cancelRequestedAt)) ||
@@ -105,6 +114,10 @@ export function parseClientQuote(value: unknown): ClientQuote {
105
114
  chain_id: v["chain_id"],
106
115
  amount_atomic: v["amount_atomic"],
107
116
  address: v["address"],
117
+ deposit_address: v["deposit_address"],
118
+ deposit_address_version: v["deposit_address_version"],
119
+ replaced_by: v["replaced_by"],
120
+ window_start: v["window_start"],
108
121
  payment_uri: v["payment_uri"],
109
122
  expires_at: v["expires_at"],
110
123
  ...(cancelRequestedAt === undefined ? {} : { cancel_requested_at: cancelRequestedAt }),
package/src/wallet.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { submitTransaction, submitWalletTransaction } from "./transactions.js";
1
+ import { submitWalletTransaction } from "./transactions.js";
2
2
  import { createStore } from "mipd";
3
3
  import {
4
4
  BaseError,
@@ -15,10 +15,7 @@ import { readContract } from "viem/actions";
15
15
  import { knownChain, networkName } from "./chains.js";
16
16
  import { formatUnitsGrouped } from "./format.js";
17
17
  import {
18
- depositAddressTransfer,
19
18
  quoteTransfer,
20
- type DepositAddressAsset,
21
- type DepositAddressNetwork,
22
19
  type TokenTransfer,
23
20
  } from "./payment.js";
24
21
  import type { ClientQuote } from "./quote.js";
@@ -130,47 +127,6 @@ export async function payWithWallet(
130
127
  return hash;
131
128
  }
132
129
 
133
- export interface PayDepositAddressOptions {
134
- /** The network to pay on, from the deposit address's `networks`. */
135
- network: DepositAddressNetwork;
136
- /** The token to pay in, from that network's `assets`. */
137
- asset: DepositAddressAsset;
138
- /** The token amount to send, in the smallest unit; positive. */
139
- amountAtomic: bigint;
140
- /**
141
- * The address's `client_secret`. With `apiBase`, the transaction hash is sent to the service as
142
- * a best-effort hint once the wallet broadcasts it, so the payment is found within about a block.
143
- */
144
- clientSecret?: string | undefined;
145
- /** The service origin; needed with `clientSecret`. */
146
- apiBase?: string | undefined;
147
- }
148
-
149
- /**
150
- * Pays `amountAtomic` of a token to a customer's deposit address from a wallet, as `payWithWallet`
151
- * pays a quote: connects, switches to (or adds) the network's chain, checks the token balance, and
152
- * sends the ERC-20 `transfer` that the token's `payment_uri` states, for exactly that amount. Then,
153
- * with `clientSecret` and `apiBase`, it hints the transaction to the service without waiting for
154
- * or failing on it. Resolves with the transaction hash once the wallet has broadcast it; follow the
155
- * payment in the address's `payments` by that hash.
156
- */
157
- export async function payDepositAddressWithWallet(
158
- wallet: WalletClient | EthereumProvider,
159
- { network, asset, amountAtomic, clientSecret, apiBase }: PayDepositAddressOptions,
160
- ): Promise<Hash> {
161
- if (amountAtomic <= 0n) {
162
- throw new TypeError("amountAtomic must be positive");
163
- }
164
- const transfer = { ...depositAddressTransfer(network, asset), amount: amountAtomic };
165
- const hash = await sendTransfer(wallet, transfer, asset.asset, asset.decimals);
166
- if (clientSecret !== undefined && apiBase !== undefined) {
167
- void submitTransaction({ apiBase, clientSecret, transactionHash: hash, chainId: transfer.chainId }).catch(
168
- () => undefined,
169
- );
170
- }
171
- return hash;
172
- }
173
-
174
130
  async function sendTransfer(
175
131
  wallet: WalletClient | EthereumProvider,
176
132
  transfer: TokenTransfer,