@daimo/pay 1.7.5 → 1.7.7

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/build/index.d.ts CHANGED
@@ -4,8 +4,8 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { CreateConfigParameters } from '@wagmi/core';
5
5
  import { CreateConnectorFn } from 'wagmi';
6
6
  import { CoinbaseWalletParameters } from 'wagmi/connectors';
7
- import { DaimoPayOrderView, DaimoPayUserMetadata, DaimoPayIntentStatus, DaimoPayOrderMode, DepositAddressPaymentOptionMetadata, PlatformType, ExternalPaymentOptionMetadata, WalletPaymentOption, DaimoPayOrder, ExternalPaymentOptions, DepositAddressPaymentOptions, DepositAddressPaymentOptionData, SolanaPublicKey } from '@daimo/pay-common';
8
- import { Hex, Address } from 'viem';
7
+ import { DaimoPayOrderView, PaymentStartedEvent, PaymentCompletedEvent, PaymentBouncedEvent, DaimoPayUserMetadata, DaimoPayIntentStatus, DaimoPayOrderMode, DepositAddressPaymentOptionMetadata, PlatformType, ExternalPaymentOptionMetadata, WalletPaymentOption, DaimoPayOrderWithOrg, ExternalPaymentOptions, DepositAddressPaymentOptions, DepositAddressPaymentOptionData, SolanaPublicKey } from '@daimo/pay-common';
8
+ import { Address, Hex } from 'viem';
9
9
  import { WalletName } from '@solana/wallet-adapter-base';
10
10
  import { AppRouter } from '@daimo/pay-api';
11
11
  import { CreateTRPCClient } from '@trpc/client';
@@ -133,48 +133,6 @@ declare const defaultConfig: ({ appName, appIcon, appDescription, appUrl, wallet
133
133
 
134
134
  /** Payment details and status. */
135
135
  type DaimoPayment = DaimoPayOrderView;
136
- /** Passed to both `onPayment*` event handlers and webhooks. */
137
- type DaimoPayEvent = {
138
- /**
139
- * A payment is started once the user has sent payment. Completed means
140
- * the payment was sent on the destination chain and custom contract call,
141
- * if any, was successful. Bounced means that a destination contract call
142
- * reverted and funds were refunded.
143
- */
144
- type: "payment_started" | "payment_completed" | "payment_bounced";
145
- /**
146
- * The unique ID for this payment.
147
- */
148
- paymentId: string;
149
- /**
150
- * The chain for this event--source chain for payment_started, destination
151
- * chain for payment_completed/payment_bounced.
152
- */
153
- chainId: number;
154
- /**
155
- * Payment details.
156
- */
157
- payment: DaimoPayment;
158
- };
159
- type DaimoPayStartedEvent = DaimoPayEvent & {
160
- type: "payment_started";
161
- /**
162
- * The transaction hash sent by the user, if found. (There are rare edge cases
163
- * where a payment can be paid without a txhash.) Hex for all EVM events,
164
- * Base58 for payment_started on Solana.
165
- */
166
- txHash: Hex | string | null;
167
- };
168
- type DaimoPayCompletedEvent = DaimoPayEvent & {
169
- type: "payment_completed";
170
- /** The transaction hash completing this payment. */
171
- txHash: Hex;
172
- };
173
- type DaimoPayBouncedEvent = DaimoPayEvent & {
174
- type: "payment_bounced";
175
- /** The transaction hash containing the reverted final call and refund. */
176
- txHash: Hex;
177
- };
178
136
  /** Props for DaimoPayButton. */
179
137
  type PayButtonPaymentProps = {
180
138
  /**
@@ -244,11 +202,11 @@ type PayButtonPaymentProps = {
244
202
  };
245
203
  type PayButtonCommonProps = PayButtonPaymentProps & {
246
204
  /** Called when user sends payment and transaction is seen on chain */
247
- onPaymentStarted?: (event: DaimoPayStartedEvent) => void;
205
+ onPaymentStarted?: (event: PaymentStartedEvent) => void;
248
206
  /** Called when destination transfer or call completes successfully */
249
- onPaymentCompleted?: (event: DaimoPayCompletedEvent) => void;
207
+ onPaymentCompleted?: (event: PaymentCompletedEvent) => void;
250
208
  /** Called when destination call reverts and funds are refunded */
251
- onPaymentBounced?: (event: DaimoPayBouncedEvent) => void;
209
+ onPaymentBounced?: (event: PaymentBouncedEvent) => void;
252
210
  /** Called when the modal is opened. */
253
211
  onOpen?: () => void;
254
212
  /** Called when the modal is closed. */
@@ -479,7 +437,7 @@ interface PaymentState {
479
437
  payParams: PayParams | undefined;
480
438
  generatePreviewOrder: (payParams: PayParams) => void;
481
439
  resetOrder: () => void;
482
- daimoPayOrder: DaimoPayOrder | undefined;
440
+ daimoPayOrder: DaimoPayOrderWithOrg | undefined;
483
441
  isDepositFlow: boolean;
484
442
  paymentWaitingMessage: string | undefined;
485
443
  externalPaymentOptions: ReturnType<typeof useExternalPaymentOptions>;
@@ -562,4 +520,4 @@ type PayContextValue = {
562
520
  } & useConnectCallbackProps;
563
521
 
564
522
  export { Avatar, Chain as ChainIcon, DaimoPayButton, PayContext as DaimoPayContext, DaimoPayProvider, types as Types, daimoPayVersion, defaultConfig as getDefaultConfig, useDaimoPayStatus, usePayContext, wallets };
565
- export type { All, CustomAvatarProps, CustomTheme, DaimoPayBouncedEvent, DaimoPayButtonCustomProps, DaimoPayButtonProps, DaimoPayCompletedEvent, DaimoPayContextOptions, DaimoPayEvent, DaimoPayModalOptions, DaimoPayStartedEvent, DaimoPayment, Languages, Mode, PaymentOption, Theme };
523
+ export type { All, CustomAvatarProps, CustomTheme, DaimoPayButtonCustomProps, DaimoPayButtonProps, DaimoPayContextOptions, DaimoPayModalOptions, DaimoPayment, Languages, Mode, PaymentOption, Theme };
package/build/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
- import { ExternalPaymentOptions, assert, assertNotNull, debugJson, supportedChains, ethereum, isCCTPV1Chain, getOrderDestChainId, readDaimoPayOrderID, getChainName, arbitrum as arbitrum$1, base as base$2, blast as blast$1, bsc as bsc$1, linea as linea$1, mantle as mantle$1, optimism as optimism$1, polygon as polygon$1, worldchain as worldchain$1, getAddressContraction, writeDaimoPayOrderID, DaimoPayOrderMode, DaimoPayOrderStatusDest, getChainExplorerTxUrl, DaimoPayIntentStatus, retryBackoff, DaimoPayOrderStatusSource, getDaimoPayOrderView } from '@daimo/pay-common';
2
+ import { ExternalPaymentOptions, assert, assertNotNull, debugJson, supportedChains, ethereum, isCCTPV1Chain, getOrderDestChainId, readDaimoPayOrderID, getChainName, arbitrum as arbitrum$1, base as base$2, blast as blast$1, bsc as bsc$1, linea as linea$1, mantle as mantle$1, optimism as optimism$1, polygon as polygon$1, worldchain as worldchain$1, getAddressContraction, writeDaimoPayOrderID, DaimoPayOrderMode, DaimoPayOrderStatusDest, getChainExplorerTxUrl, DaimoPayIntentStatus, retryBackoff, DaimoPayOrderStatusSource, DaimoPayEventType, getDaimoPayOrderView } from '@daimo/pay-common';
3
3
  import { Buffer } from 'buffer';
4
4
  import React, { useState, useEffect, createContext, useRef, useCallback, useLayoutEffect, useMemo, createElement } from 'react';
5
5
  import styled$1, { css, keyframes, ThemeProvider } from 'styled-components';
@@ -22,7 +22,7 @@ import { WalletSignTransactionError, WalletSendTransactionError } from '@solana/
22
22
  import { normalize } from 'viem/ens';
23
23
 
24
24
  var name = "@daimo/pay";
25
- var version = "1.7.5";
25
+ var version = "1.7.7";
26
26
  var author = "Daimo";
27
27
  var homepage = "https://pay.daimo.com";
28
28
  var license = "BSD-2-Clause license";
@@ -61,7 +61,7 @@ var keywords = [
61
61
  "crypto"
62
62
  ];
63
63
  var dependencies = {
64
- "@daimo/pay-common": "1.7.5",
64
+ "@daimo/pay-common": "1.7.7",
65
65
  "@rollup/plugin-typescript": "^12.1.2",
66
66
  "@solana/wallet-adapter-base": "^0.9.23",
67
67
  "@solana/wallet-adapter-react": "^0.15.35",
@@ -536,6 +536,7 @@ const walletConfigs = {
536
536
  },
537
537
  "metaMask, metaMask-io, io.metamask, io.metamask.mobile, metaMaskSDK": {
538
538
  name: "MetaMask",
539
+ shortName: "MetaMask",
539
540
  icon: jsx(Logos$1.MetaMask, {}),
540
541
  iconConnector: jsx(Logos$1.MetaMask, {}),
541
542
  iconShouldShrink: true,
@@ -4874,32 +4875,42 @@ const useWallets = (isMobile) => {
4874
4875
  const context = usePayContext();
4875
4876
  if (isMobile) {
4876
4877
  const mobileWallets = [];
4877
- // Add Rainbow first
4878
- mobileWallets.push({
4879
- id: "me.rainbow",
4880
- ...walletConfigs["me.rainbow"],
4881
- });
4882
- // Add MetaMask second
4883
- const metaMaskConnector = connectors.find((c) => c.id === "metaMask");
4884
- if (metaMaskConnector) {
4885
- mobileWallets.push({
4886
- id: metaMaskConnector.id,
4887
- connector: metaMaskConnector,
4888
- ...walletConfigs["metaMask, metaMask-io, io.metamask, io.metamask.mobile, metaMaskSDK"],
4889
- });
4890
- }
4891
- // Add WalletConnect and other wallets
4878
+ // Add injected wallet (if any) first
4892
4879
  connectors.forEach((connector) => {
4893
4880
  if (connector.id === "metaMask")
4894
4881
  return;
4882
+ if (connector.id === "walletConnect")
4883
+ return;
4895
4884
  if (isCoinbaseWalletConnector(connector.id))
4896
4885
  return;
4897
4886
  mobileWallets.push({
4898
4887
  id: connector.id,
4899
4888
  connector,
4900
- ...walletConfigs[connector.id],
4889
+ shortName: connector.name,
4890
+ iconConnector: jsx("img", { src: connector.icon, alt: connector.name }),
4891
+ iconShape: "squircle",
4901
4892
  });
4902
4893
  });
4894
+ function addIfNotPresent(idList) {
4895
+ if (mobileWallets.find((w) => idList.includes(w.id)))
4896
+ return;
4897
+ const wallet = assertNotNull(walletConfigs[idList], () => `missing ${idList}`);
4898
+ mobileWallets.push({
4899
+ id: idList,
4900
+ ...wallet,
4901
+ });
4902
+ }
4903
+ addIfNotPresent("me.rainbow");
4904
+ addIfNotPresent("metaMask, metaMask-io, io.metamask, io.metamask.mobile, metaMaskSDK");
4905
+ // Add WalletConnect last
4906
+ const walletConnectConnector = connectors.find((c) => c.id === "walletConnect");
4907
+ if (walletConnectConnector) {
4908
+ mobileWallets.push({
4909
+ id: walletConnectConnector.id,
4910
+ connector: walletConnectConnector,
4911
+ ...walletConfigs[walletConnectConnector.id],
4912
+ });
4913
+ }
4903
4914
  return mobileWallets;
4904
4915
  }
4905
4916
  const wallets = connectors.map((connector) => {
@@ -7477,8 +7488,9 @@ const OrderHeader = ({ minified = false, showEth = false, showSolana = false, })
7477
7488
  }
7478
7489
  })();
7479
7490
  const renderIcon = (icon, name, size = 32) => {
7480
- if (!icon)
7481
- return jsx(MetaMask, {});
7491
+ if (!icon) {
7492
+ return null;
7493
+ }
7482
7494
  return (jsx(LogoContainer$4, { "$size": size, "$zIndex": 1, style: { borderRadius: "22.5%" }, children: typeof icon === "string" ? (jsx("img", { src: icon, alt: name || "wallet", style: { maxWidth: "100%", maxHeight: "100%" } })) : (icon) }));
7483
7495
  };
7484
7496
  let walletIcon = renderIcon(connector?.icon || wcWallet?.icon, wcWallet?.name);
@@ -11995,7 +12007,7 @@ function DaimoPayButtonCustom(props) {
11995
12007
  if (!sentStart.current && hydOrder.sourceTokenAmount) {
11996
12008
  sentStart.current = true;
11997
12009
  onPaymentStarted?.({
11998
- type: DaimoPayIntentStatus.STARTED,
12010
+ type: DaimoPayEventType.PaymentStarted,
11999
12011
  paymentId: writeDaimoPayOrderID(hydOrder.id),
12000
12012
  chainId: hydOrder.sourceTokenAmount?.token.chainId,
12001
12013
  txHash: hydOrder.sourceInitiateTxHash ?? null,
@@ -12004,8 +12016,11 @@ function DaimoPayButtonCustom(props) {
12004
12016
  }
12005
12017
  if (intentStatus === DaimoPayIntentStatus.COMPLETED ||
12006
12018
  intentStatus === DaimoPayIntentStatus.BOUNCED) {
12019
+ const eventType = intentStatus === DaimoPayIntentStatus.COMPLETED
12020
+ ? DaimoPayEventType.PaymentCompleted
12021
+ : DaimoPayEventType.PaymentBounced;
12007
12022
  const event = {
12008
- type: intentStatus,
12023
+ type: eventType,
12009
12024
  paymentId: writeDaimoPayOrderID(hydOrder.id),
12010
12025
  chainId: hydOrder.destFinalCallTokenAmount.token.chainId,
12011
12026
  txHash: assertNotNull(hydOrder.destFastFinishTxHash ?? hydOrder.destClaimTxHash, `[PAY BUTTON] dest tx hash null on order ${hydOrder.id} when intent status is ${intentStatus}`),