@getpara/react-common 2.0.0-alpha.32 → 2.0.0-alpha.34

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.
@@ -21,6 +21,7 @@ export declare class ParaInternal extends ParaWeb implements InternalInterface {
21
21
  credentialId: string;
22
22
  url?: string;
23
23
  }>;
24
+ prepareLogin: () => import("@getpara/web-sdk").InternalMethodResponse<"prepareLogin">;
24
25
  linkAccount: (opts: import("@getpara/web-sdk").InternalMethodParams<"linkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"linkAccount">;
25
26
  unlinkAccount: ({ linkedAccountId, }: import("@getpara/web-sdk").InternalMethodParams<"unlinkAccount">) => import("@getpara/web-sdk").InternalMethodResponse<"unlinkAccount">;
26
27
  verifyEmailOrPhoneLink: ({ verificationCode, }: import("@getpara/web-sdk").InternalMethodParams<"verifyEmailOrPhoneLink">) => import("@getpara/web-sdk").InternalMethodResponse<"verifyEmailOrPhoneLink">;
@@ -14,6 +14,7 @@ class ParaInternal extends ParaWeb {
14
14
  this.supportedAuthMethods = super.supportedAuthMethods;
15
15
  this.constructPortalUrl = super.constructPortalUrl;
16
16
  this.getNewCredentialAndUrl = super.getNewCredentialAndUrl;
17
+ this.prepareLogin = super.prepareLogin;
17
18
  this.linkAccount = super.linkAccount;
18
19
  this.unlinkAccount = super.unlinkAccount;
19
20
  this.verifyEmailOrPhoneLink = super.verifyEmailOrPhoneLink;
@@ -1,3 +1,5 @@
1
1
  import { OnRampProps } from '../types/index.js';
2
- export declare const MoonPayEmbed: ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, setOnRampPurchase }: OnRampProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const MoonPayEmbed: ({ email, isDark, isEmbedded, onRampConfig, onRampPurchase, onSuccess, onDepositRequest, onUrlSignatureRequest, }: OnRampProps & {
3
+ onUrlSignatureRequest: (url: string) => Promise<string>;
4
+ }) => import("react/jsx-runtime").JSX.Element;
3
5
  export default MoonPayEmbed;
@@ -3,15 +3,22 @@ import {
3
3
  __async
4
4
  } from "../chunk-GOCCUU3Z.js";
5
5
  import { jsx } from "react/jsx-runtime";
6
- import { getNetworkPrefix, OnRampProvider, OnRampPurchaseStatus } from "@getpara/web-sdk";
6
+ import { OnRampProvider } from "@getpara/web-sdk";
7
7
  import { lazy, useCallback, useEffect, useMemo, useState } from "react";
8
- import { reverseCurrencyLookup, offRampSend, getCurrencyCode, safeStyled } from "../utils/index.js";
8
+ import { reverseCurrencyLookup, getCurrencyCode, safeStyled } from "../utils/index.js";
9
9
  const MOONPAY_PUBLISHABLE_KEY = "pk_live_EQva4LydtNDE0Rwd9X7SG9w58wqOzbux";
10
10
  const MOONPAY_PUBLISHABLE_KEY_TEST = "pk_test_HYobzemmTBXxcSStVA4dSED6jT";
11
- const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, setOnRampPurchase }) => {
12
- const [LazyMoonPayBuyWidget, setLazyMoonPayBuyWidget] = useState(null);
13
- const [LazyMoonPaySellWidget, setLazyMoonPaySellWidget] = useState(null);
14
- const [LazyMoonPayProvider, setLazyMoonPayProvider] = useState(null);
11
+ const MoonPayEmbed = ({
12
+ email,
13
+ isDark,
14
+ isEmbedded,
15
+ onRampConfig,
16
+ onRampPurchase,
17
+ onSuccess,
18
+ onDepositRequest,
19
+ onUrlSignatureRequest
20
+ }) => {
21
+ const [components, setComponents] = useState(null);
15
22
  useEffect(() => {
16
23
  const _LazyMoonPayBuyWidget = lazy(
17
24
  () => import("@moonpay/moonpay-react").then((mod) => ({ default: mod.MoonPayBuyWidget }))
@@ -22,28 +29,13 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
22
29
  const _LazyMoonPayProvider = lazy(
23
30
  () => import("@moonpay/moonpay-react").then((mod) => ({ default: mod.MoonPayProvider }))
24
31
  );
25
- setLazyMoonPayBuyWidget(_LazyMoonPayBuyWidget);
26
- setLazyMoonPaySellWidget(_LazyMoonPaySellWidget);
27
- setLazyMoonPayProvider(_LazyMoonPayProvider);
32
+ setComponents({
33
+ MoonPayBuyWidget: _LazyMoonPayBuyWidget,
34
+ MoonPaySellWidget: _LazyMoonPaySellWidget,
35
+ MoonPayProvider: _LazyMoonPayProvider
36
+ });
28
37
  }, []);
29
38
  const apiKey = onRampPurchase.testMode ? MOONPAY_PUBLISHABLE_KEY_TEST : MOONPAY_PUBLISHABLE_KEY;
30
- const onUrlSignatureRequested = useCallback(
31
- (url) => __async(void 0, null, function* () {
32
- if (!para.getUserId() || !onRampPurchase.walletType) {
33
- throw new Error("missing required fields");
34
- }
35
- const res = yield para.ctx.client.signMoonPayUrl(para.getUserId(), {
36
- url,
37
- type: onRampPurchase.walletType,
38
- cosmosPrefix: getNetworkPrefix(onRampPurchase.network),
39
- testMode: onRampPurchase.testMode,
40
- walletId: onRampPurchase.walletId || void 0,
41
- externalWalletAddress: onRampPurchase.externalWalletAddress || void 0
42
- });
43
- return res.data.signature;
44
- }),
45
- [onRampPurchase.walletId, onRampPurchase.walletType, para.cosmosPrefix, onRampPurchase.testMode, para]
46
- );
47
39
  const onTransactionCompleted = useCallback(
48
40
  (payload) => __async(void 0, null, function* () {
49
41
  try {
@@ -52,57 +44,39 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
52
44
  OnRampProvider.MOONPAY,
53
45
  payload.quoteCurrency.code
54
46
  );
55
- const updated = yield para.ctx.client.updateOnRampPurchase({
56
- userId: para.getUserId(),
57
- walletId: onRampPurchase.walletId,
58
- purchaseId: onRampPurchase.id,
59
- externalWalletAddress: onRampPurchase.externalWalletAddress,
60
- updates: {
61
- fiatQuantity: payload.baseCurrencyAmount.toString(),
62
- fiat: payload.baseCurrency.code,
63
- network,
64
- asset,
65
- assetQuantity: payload.quoteCurrencyAmount.toString(),
66
- status: OnRampPurchaseStatus.FINISHED
67
- }
47
+ onSuccess({
48
+ fiatQuantity: payload.baseCurrencyAmount.toString(),
49
+ fiat: payload.baseCurrency.code,
50
+ network,
51
+ asset,
52
+ assetQuantity: payload.quoteCurrencyAmount.toString()
68
53
  });
69
- setOnRampPurchase(updated);
70
- if (!isEmbedded) {
71
- setTimeout(() => {
72
- if (typeof window !== "undefined") {
73
- window.close();
74
- }
75
- }, 5e3);
76
- }
77
54
  } catch (e) {
78
- console.error(e);
55
+ throw e instanceof Error ? e : new Error(e);
79
56
  }
80
57
  }),
81
- [onRampPurchase.walletId, onRampPurchase.id, onRampPurchase.externalWalletAddress, isEmbedded]
58
+ [onRampConfig]
82
59
  );
83
60
  const onInitiateDeposit = useCallback(
84
61
  (payload) => __async(void 0, null, function* () {
85
- const txHash = yield offRampSend(para, onRampPurchase, setOnRampPurchase, {
86
- assetQuantity: payload.cryptoCurrencyAmount,
87
- fiatQuantity: payload.fiatCurrencyAmount || void 0,
88
- fiat: payload.fiatCurrency.code.toUpperCase(),
89
- destinationAddress: payload.depositWalletAddress,
90
- contractAddress: payload.cryptoCurrency.contractAddress,
91
- chainId: payload.cryptoCurrency.chainId
92
- });
93
- return { depositId: txHash, cancelTransactionOnError: false };
62
+ try {
63
+ const txHash = yield onDepositRequest({
64
+ assetQuantity: payload.cryptoCurrencyAmount,
65
+ fiatQuantity: payload.fiatCurrencyAmount || void 0,
66
+ fiat: payload.fiatCurrency.code.toUpperCase(),
67
+ destinationAddress: payload.depositWalletAddress,
68
+ contractAddress: payload.cryptoCurrency.contractAddress,
69
+ chainId: payload.cryptoCurrency.chainId
70
+ });
71
+ return { depositId: txHash, cancelTransactionOnError: false };
72
+ } catch (e) {
73
+ throw e instanceof Error ? e : new Error(e);
74
+ }
94
75
  }),
95
- [
96
- para,
97
- onRampPurchase.id,
98
- onRampPurchase.testMode,
99
- onRampPurchase.walletId,
100
- onRampPurchase.walletType,
101
- setOnRampPurchase
102
- ]
76
+ []
103
77
  );
104
78
  const embed = useMemo(() => {
105
- if (!LazyMoonPayBuyWidget || !LazyMoonPaySellWidget) {
79
+ if (!components) {
106
80
  return null;
107
81
  }
108
82
  const currencyCode = getCurrencyCode(onRampConfig, {
@@ -110,10 +84,11 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
110
84
  asset: onRampPurchase.asset,
111
85
  provider: OnRampProvider.MOONPAY
112
86
  });
113
- return onRampPurchase.type === "BUY" ? /* @__PURE__ */ jsx(
114
- LazyMoonPayBuyWidget,
87
+ return /* @__PURE__ */ jsx(components.MoonPayProvider, { apiKey, debug: onRampPurchase.testMode, children: onRampPurchase.type === "BUY" ? /* @__PURE__ */ jsx(
88
+ components.MoonPayBuyWidget,
115
89
  {
116
90
  variant: "embedded",
91
+ email,
117
92
  baseCurrencyCode: onRampPurchase.fiat,
118
93
  baseCurrencyAmount: onRampPurchase.fiatQuantity,
119
94
  currencyCode,
@@ -128,10 +103,10 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
128
103
  margin: 0
129
104
  },
130
105
  onTransactionCompleted,
131
- onUrlSignatureRequested
106
+ onUrlSignatureRequested: onUrlSignatureRequest
132
107
  }
133
108
  ) : /* @__PURE__ */ jsx(
134
- LazyMoonPaySellWidget,
109
+ components.MoonPaySellWidget,
135
110
  {
136
111
  variant: "embedded",
137
112
  visible: true,
@@ -143,30 +118,29 @@ const MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase,
143
118
  borderRadius: 0,
144
119
  margin: 0
145
120
  },
121
+ email,
146
122
  baseCurrencyCode: currencyCode,
123
+ quoteCurrencyAmount: onRampPurchase.fiatQuantity,
147
124
  refundWalletAddress: onRampPurchase.address,
148
125
  onInitiateDeposit,
149
126
  onTransactionCompleted,
150
- onUrlSignatureRequested
127
+ onUrlSignatureRequested: onUrlSignatureRequest
151
128
  }
152
- );
129
+ ) });
153
130
  }, [
131
+ apiKey,
132
+ email,
154
133
  onRampPurchase.type,
155
134
  onRampPurchase.address,
156
135
  onRampPurchase.walletId,
157
136
  onRampPurchase.walletType,
158
137
  onRampPurchase.asset,
159
- onInitiateDeposit,
138
+ onRampPurchase.testMode,
160
139
  onTransactionCompleted,
161
- onUrlSignatureRequested,
162
140
  isDark,
163
- LazyMoonPayBuyWidget,
164
- LazyMoonPaySellWidget
141
+ components
165
142
  ]);
166
- if (!LazyMoonPayProvider) {
167
- return null;
168
- }
169
- return /* @__PURE__ */ jsx(Container, { isEmbedded, children: /* @__PURE__ */ jsx(LazyMoonPayProvider, { apiKey, debug: onRampPurchase.testMode, children: embed }) });
143
+ return /* @__PURE__ */ jsx(Container, { isEmbedded, children: embed });
170
144
  };
171
145
  var MoonPayEmbed_default = MoonPayEmbed;
172
146
  const Container = safeStyled.div`
@@ -1,4 +1,4 @@
1
1
  import { OnRampProps } from '../types/index.js';
2
- export declare const RampEmbed: ({ para, appName, onRampConfig, onRampPurchase, isEmbedded, apiKey, onClose, setOnRampPurchase, }: OnRampProps & {
2
+ export declare const RampEmbed: ({ appName, email, onRampConfig, onRampPurchase, isEmbedded, apiKey, onClose, onUpdate, onDepositRequest, }: OnRampProps & {
3
3
  apiKey: string;
4
4
  }) => import("react/jsx-runtime").JSX.Element;
@@ -5,24 +5,19 @@ import {
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { useEffect, useRef } from "react";
7
7
  import { RampInstantSDK } from "@ramp-network/ramp-instant-sdk";
8
- import { Network, OnRampAsset, OnRampProvider, getPortalBaseURL } from "@getpara/web-sdk";
9
- import {
10
- getChainId,
11
- getContractAddressFromAsset,
12
- getCurrencyCodes,
13
- reverseCurrencyLookup,
14
- offRampSend
15
- } from "../utils/index.js";
8
+ import { Network, OnRampAsset, OnRampProvider } from "@getpara/web-sdk";
9
+ import { getChainId, getContractAddressFromAsset, getCurrencyCodes, reverseCurrencyLookup } from "../utils/index.js";
16
10
  const TEST_MODE_FORBIDDEN = ["ETH_ETH", "ETH_USDC"];
17
11
  const RampEmbed = ({
18
- para,
19
12
  appName,
13
+ email,
20
14
  onRampConfig,
21
15
  onRampPurchase,
22
16
  isEmbedded,
23
17
  apiKey,
24
18
  onClose,
25
- setOnRampPurchase
19
+ onUpdate,
20
+ onDepositRequest
26
21
  }) => {
27
22
  const { currencyCodes } = getCurrencyCodes(onRampConfig, {
28
23
  provider: OnRampProvider.RAMP,
@@ -38,10 +33,10 @@ const RampEmbed = ({
38
33
  swapAsset: currencyCodes.filter((code) => !onRampPurchase.testMode || !TEST_MODE_FORBIDDEN.includes(code)).join(","),
39
34
  fiatValue: onRampPurchase.fiatQuantity,
40
35
  fiatCurrency: onRampPurchase.fiat,
41
- hostLogoUrl: `${getPortalBaseURL(para.ctx)}/wordmark_black.svg`,
36
+ hostLogoUrl: `${window.location.hostname}/wordmark_black.svg`,
42
37
  hostApiKey: apiKey,
43
38
  userAddress: onRampPurchase.address,
44
- userEmailAddress: para.getEmail(),
39
+ userEmailAddress: email,
45
40
  url: (onRampPurchase == null ? void 0 : onRampPurchase.testMode) ? "https://app.demo.ramp.network" : "https://app.ramp.network",
46
41
  enabledFlows: [onRampPurchase.type === "BUY" ? "ONRAMP" : "OFFRAMP"],
47
42
  useSendCryptoCallback: true,
@@ -50,21 +45,14 @@ const RampEmbed = ({
50
45
  }).on("PURCHASE_CREATED", (e) => __async(void 0, null, function* () {
51
46
  const p = e.payload.purchase;
52
47
  const [network, asset] = onRampPurchase.testMode ? [Network.ETHEREUM, OnRampAsset.ETHEREUM] : reverseCurrencyLookup(onRampConfig.assetInfo, OnRampProvider.RAMP, p.asset.symbol) || [];
53
- const updated = yield para.ctx.client.updateOnRampPurchase({
54
- userId: para.getUserId(),
55
- walletId: onRampPurchase.walletId,
56
- externalWalletAddress: onRampPurchase.externalWalletAddress,
57
- purchaseId: onRampPurchase.id,
58
- updates: {
59
- providerKey: p.id,
60
- fiatQuantity: p.fiatValue,
61
- fiat: p.fiatCurrency,
62
- assetQuantity: p.cryptoAmount,
63
- asset,
64
- network
65
- }
48
+ onUpdate({
49
+ providerKey: p.id,
50
+ fiatQuantity: p.fiatValue,
51
+ fiat: p.fiatCurrency,
52
+ assetQuantity: p.cryptoAmount,
53
+ asset,
54
+ network
66
55
  });
67
- setOnRampPurchase(updated);
68
56
  })).on("WIDGET_CLOSE", () => __async(void 0, null, function* () {
69
57
  onClose == null ? void 0 : onClose();
70
58
  if (!isEmbedded) {
@@ -77,7 +65,7 @@ const RampEmbed = ({
77
65
  })).onSendCrypto((assetInfo, amount, address) => __async(void 0, null, function* () {
78
66
  try {
79
67
  const [network, asset] = reverseCurrencyLookup(onRampConfig.assetInfo, OnRampProvider.RAMP, assetInfo.symbol);
80
- const txHash = yield offRampSend(para, onRampPurchase, setOnRampPurchase, {
68
+ const txHash = yield onDepositRequest({
81
69
  assetQuantity: amount,
82
70
  destinationAddress: address,
83
71
  contractAddress: getContractAddressFromAsset(network, asset),
@@ -28,7 +28,9 @@ export declare const defaultEvmExternalWallet: {
28
28
  requestInfo: () => Promise<ExternalWalletInfo>;
29
29
  disconnectBase: () => Promise<void>;
30
30
  useAccount: () => any;
31
- farcasterStatus: any;
31
+ farcasterStatus: {
32
+ isPresent: false;
33
+ };
32
34
  };
33
35
  export declare const defaultSolanaExternalWallet: {
34
36
  wallets: any[];
@@ -38,4 +40,7 @@ export declare const defaultSolanaExternalWallet: {
38
40
  requestInfo: () => Promise<ExternalWalletInfo>;
39
41
  disconnectBase: () => Promise<void>;
40
42
  useWallet: () => any;
43
+ farcasterStatus: {
44
+ isPresent: false;
45
+ };
41
46
  };
@@ -29,7 +29,7 @@ const defaultEvmExternalWallet = {
29
29
  requestInfo: () => Promise.resolve({}),
30
30
  disconnectBase: () => Promise.resolve(),
31
31
  useAccount: () => void 0,
32
- farcasterStatus: void 0
32
+ farcasterStatus: { isPresent: false }
33
33
  };
34
34
  const defaultSolanaExternalWallet = {
35
35
  wallets: [],
@@ -38,7 +38,8 @@ const defaultSolanaExternalWallet = {
38
38
  signVerificationMessage: () => Promise.resolve({}),
39
39
  requestInfo: () => Promise.resolve({}),
40
40
  disconnectBase: () => Promise.resolve(),
41
- useWallet: () => void 0
41
+ useWallet: () => void 0,
42
+ farcasterStatus: { isPresent: false }
42
43
  };
43
44
  export {
44
45
  defaultCosmosExternalWallet,
@@ -77,9 +77,13 @@ export type BalanceManagement<B = string> = {
77
77
  };
78
78
  export type FarcasterMiniAppManagement = {
79
79
  farcasterStatus: {
80
+ isPresent: false;
81
+ } | {
82
+ isPresent: true;
80
83
  isConnected: false;
81
84
  address?: undefined;
82
85
  } | {
86
+ isPresent: true;
83
87
  isConnected: true;
84
88
  address: string;
85
89
  } | undefined;
@@ -89,8 +93,8 @@ export type ExternalWalletContextType<S extends SignResult = SignResult> = {
89
93
  disconnect: () => Promise<void>;
90
94
  signMessage: (_: SignArgs) => Promise<S>;
91
95
  signVerificationMessage: () => Promise<S>;
92
- requestInfo: (_: TExternalWallet) => Promise<ExternalWalletInfo>;
93
- disconnectBase: (_?: TExternalWallet) => Promise<void>;
96
+ requestInfo: (_: string) => Promise<ExternalWalletInfo>;
97
+ disconnectBase: (_?: string) => Promise<void>;
94
98
  };
95
99
  export type ExternalWalletProviderConfigBase = {
96
100
  onSwitchWallet?: (args: {
@@ -1,15 +1,17 @@
1
- import { AuthInfo } from '@getpara/user-management-client';
2
- import ParaWeb, { type OnRampConfig, type OnRampPurchase } from '@getpara/web-sdk';
1
+ import { AuthInfo, OnRampPurchaseUpdateParams } from '@getpara/user-management-client';
2
+ import { OfframpDepositRequest, type OnRampConfig, type OnRampPurchase } from '@getpara/web-sdk';
3
3
  export * from './externalWalletCommon.js';
4
4
  export type OnRampProps = {
5
5
  appName?: string;
6
- para: ParaWeb;
6
+ email?: string;
7
7
  isDark?: boolean;
8
8
  isEmbedded?: boolean;
9
9
  onClose?: () => void;
10
10
  onRampConfig: OnRampConfig;
11
11
  onRampPurchase: OnRampPurchase;
12
- setOnRampPurchase?: (_: OnRampPurchase) => void;
12
+ onDepositRequest: (_: OfframpDepositRequest) => Promise<string>;
13
+ onUpdate: (_: OnRampPurchaseUpdateParams) => Promise<void>;
14
+ onSuccess: (_: OnRampPurchaseUpdateParams) => Promise<void>;
13
15
  };
14
16
  export type ModalAuthInfo = AuthInfo & Partial<{
15
17
  pfpUrl: string | null;
@@ -32,7 +32,6 @@ export declare const NetworkAssetAddresses: {
32
32
  }[];
33
33
  export declare function getAssetFromContractAddress(network: Network, contractAddress: string): OnRampAsset | undefined;
34
34
  export declare function getContractAddressFromAsset(network: Network, asset: OnRampAsset): string | undefined;
35
- export * from './offRampSend.js';
36
35
  export * from './getDeviceLogo.js';
37
36
  export * from './getDeviceModelName.js';
38
37
  export * from './getBrowserName.js';
@@ -102,7 +102,6 @@ function getContractAddressFromAsset(network, asset) {
102
102
  }
103
103
  return (_a = NetworkAssetAddresses.find((row) => row.network === network && row.asset === asset)) == null ? void 0 : _a.address;
104
104
  }
105
- export * from "./offRampSend.js";
106
105
  export * from "./getDeviceLogo.js";
107
106
  export * from "./getDeviceModelName.js";
108
107
  export * from "./getBrowserName.js";
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@getpara/react-common",
3
- "version": "2.0.0-alpha.32",
3
+ "version": "2.0.0-alpha.34",
4
4
  "dependencies": {
5
- "@getpara/react-components": "2.0.0-alpha.32",
6
- "@getpara/web-sdk": "2.0.0-alpha.32",
5
+ "@getpara/react-components": "2.0.0-alpha.34",
6
+ "@getpara/web-sdk": "2.0.0-alpha.34",
7
7
  "@moonpay/moonpay-react": "^1.8.3",
8
8
  "@ramp-network/ramp-instant-sdk": "^4.0.5",
9
9
  "libphonenumber-js": "^1.11.7",
@@ -40,5 +40,5 @@
40
40
  ],
41
41
  "type": "module",
42
42
  "types": "dist/index.d.ts",
43
- "gitHead": "2c1a4e1ef169c177238c8b0358e84dc86f614614"
43
+ "gitHead": "cff5cb1fa7284a850e688b20a6596d435315a475"
44
44
  }
@@ -1,7 +0,0 @@
1
- import { OnRampPurchaseUpdateParams } from '@getpara/user-management-client';
2
- import Para, { OnRampPurchase } from '@getpara/web-sdk';
3
- export declare function offRampSend(para: Para, { id: purchaseId, provider, walletId, walletType, address, testMode }: Partial<OnRampPurchase>, setOnRampPurchase: (_: OnRampPurchase) => void, { assetQuantity, fiat, fiatQuantity, chainId, destinationAddress, contractAddress, }: OnRampPurchaseUpdateParams & {
4
- chainId?: string;
5
- destinationAddress: string;
6
- contractAddress?: string | null;
7
- }): Promise<string | undefined>;
@@ -1,75 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../chunk-GOCCUU3Z.js";
5
- import { hexStringToBase64 } from "@getpara/web-sdk";
6
- function offRampSend(_0, _1, _2, _3) {
7
- return __async(this, arguments, function* (para, { id: purchaseId, provider, walletId, walletType, address, testMode = false }, setOnRampPurchase, {
8
- assetQuantity,
9
- fiat,
10
- fiatQuantity,
11
- chainId,
12
- destinationAddress,
13
- contractAddress
14
- }) {
15
- var _a, _b, _c;
16
- if (!purchaseId || !walletId || !walletType || !provider) {
17
- throw new Error("Missing required fields");
18
- }
19
- try {
20
- const { tx, message, network, asset } = yield para.ctx.client.generateOffRampTx(para.getUserId(), {
21
- walletId,
22
- walletType,
23
- provider,
24
- chainId,
25
- destinationAddress,
26
- sourceAddress: address,
27
- contractAddress,
28
- testMode,
29
- assetQuantity
30
- });
31
- let signature;
32
- switch (walletType) {
33
- case "EVM":
34
- signature = (_a = yield para.signTransaction({
35
- walletId,
36
- rlpEncodedTxBase64: hexStringToBase64(tx),
37
- chainId
38
- })) == null ? void 0 : _a.signature;
39
- break;
40
- case "SOLANA":
41
- signature = (_b = yield para.signMessage({ walletId, messageBase64: message })) == null ? void 0 : _b.signature;
42
- break;
43
- default:
44
- throw new Error(`Unsupported wallet type: ${walletType}`);
45
- }
46
- const { txHash } = yield para.ctx.client.sendOffRampTx(para.getUserId(), {
47
- tx,
48
- signature: walletType === "EVM" ? `0x${signature}` : signature,
49
- sourceAddress: address,
50
- network,
51
- walletId,
52
- walletType
53
- });
54
- const updated = yield para.ctx.client.updateOnRampPurchase({
55
- userId: para.getUserId(),
56
- walletId,
57
- purchaseId,
58
- updates: {
59
- fiat,
60
- fiatQuantity,
61
- assetQuantity,
62
- network,
63
- asset
64
- }
65
- });
66
- setOnRampPurchase(updated);
67
- return txHash;
68
- } catch (e) {
69
- throw new Error(((_c = e.response) == null ? void 0 : _c.data) || e.message);
70
- }
71
- });
72
- }
73
- export {
74
- offRampSend
75
- };