@coinflowlabs/react-native 0.1.0 → 0.1.2

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.
@@ -1,4 +1,18 @@
1
1
  /// <reference types="react" />
2
- import { CoinflowPurchaseProps } from '@coinflowlabs/react';
3
2
  import { WithStyles } from './CoinflowWebView';
3
+ import { Connection, Signer, Transaction } from '@solana/web3.js';
4
+ import { CoinflowEnvs, SubsetWalletContextState } from './ReactNativeCoinflowUtils';
5
+ import { OnSuccessMethod } from './IFrameWalletConnector';
6
+ type CoinflowPurchaseProps = {
7
+ wallet: SubsetWalletContextState;
8
+ merchantId: string;
9
+ connection: Connection;
10
+ amount?: number;
11
+ env?: CoinflowEnvs;
12
+ onSuccess?: OnSuccessMethod;
13
+ transaction?: Transaction;
14
+ partialSigners?: Signer[];
15
+ debugTx?: boolean;
16
+ };
4
17
  export declare function CoinflowPurchase({ wallet, merchantId, env, connection, onSuccess, transaction, amount, partialSigners, debugTx, style, }: CoinflowPurchaseProps & WithStyles): JSX.Element | null;
18
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"CoinflowPurchase.js","sourceRoot":"","sources":["../src/CoinflowPurchase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,eAAe,EAAa,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EACN,UAAU,EACV,GAAG,EACH,UAAU,EACV,SAAS,EACT,WAAW,EACX,MAAM,EACN,cAAc,EACd,OAAO,GAAG,KAAK,EACf,KAAK,GAC8B;IACnC,MAAM,EAAC,UAAU,EAAE,oBAAoB,EAAC,GAAG,eAAe,CAAC;QACzD,MAAM;QACN,UAAU;QACV,SAAS;QACT,cAAc;QACd,OAAO;KACR,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,CAAC,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,KAAK,GACZ,CACH,CAAC;AACJ,CAAC"}
@@ -1,7 +1,16 @@
1
1
  import React from 'react';
2
2
  import WebView from 'react-native-webview';
3
- import { CoinflowIFrameProps } from '@coinflowlabs/react';
4
3
  import { StyleProp, ViewStyle } from 'react-native';
4
+ import { CoinflowEnvs } from './ReactNativeCoinflowUtils';
5
+ import { Transaction } from '@solana/web3.js';
6
+ type CoinflowIFrameProps = {
7
+ publicKey: string;
8
+ IFrameRef: React.RefObject<HTMLIFrameElement>;
9
+ env?: CoinflowEnvs;
10
+ route: string;
11
+ amount?: number;
12
+ transaction?: Transaction;
13
+ };
5
14
  export type CoinflowWebViewProps = Omit<CoinflowIFrameProps, 'IFrameRef'> & {
6
15
  handleIframeMessages: ({ data }: {
7
16
  data: string;
@@ -12,3 +21,4 @@ export type WithStyles = {
12
21
  style?: StyleProp<ViewStyle>;
13
22
  };
14
23
  export declare function CoinflowWebView({ publicKey, env, route, transaction, amount, handleIframeMessages, WebViewRef, style, }: CoinflowWebViewProps & WithStyles): JSX.Element;
24
+ export {};
@@ -1,9 +1,9 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import WebView from 'react-native-webview';
3
- import { CoinflowUtils } from '@coinflowlabs/react';
3
+ import { ReactNativeCoinflowUtils, } from './ReactNativeCoinflowUtils';
4
4
  export function CoinflowWebView({ publicKey, env, route, transaction, amount, handleIframeMessages, WebViewRef, style, }) {
5
5
  const url = useMemo(() => {
6
- return CoinflowUtils.getCoinflowUrl({
6
+ return ReactNativeCoinflowUtils.getCoinflowUrl({
7
7
  amount,
8
8
  env,
9
9
  publicKey,
@@ -1 +1 @@
1
- {"version":3,"file":"CoinflowWebView.js","sourceRoot":"","sources":["../src/CoinflowWebView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAsB,aAAa,EAAC,MAAM,qBAAqB,CAAC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AG;YACH,SAAS;YACT,KAAK;YACL,WAAW;SACZ,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IAEjD,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CACJ,oBAAC,OAAO,IACN,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,CAAC;aACR;YACD,KAAK;SACN,EACD,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,EAAC,GAAG,EAAE,GAAG,EAAC,EAClB,SAAS,EAAE,KAAK,CAAC,EAAE,CACjB,oBAAoB,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI,EAAC,CAAC,GAEtD,CACH,EACD,CAAC,GAAG,CAAC,CACN,CAAC;AACJ,CAAC"}
@@ -1,4 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { CoinflowWithdrawProps } from '@coinflowlabs/react';
3
2
  import { WithStyles } from './CoinflowWebView';
3
+ import { Connection } from '@solana/web3.js';
4
+ import { CoinflowEnvs, SubsetWalletContextState } from './ReactNativeCoinflowUtils';
5
+ import { OnSuccessMethod } from './IFrameWalletConnector';
6
+ type CoinflowWithdrawProps = {
7
+ wallet: SubsetWalletContextState;
8
+ merchantId: string;
9
+ connection: Connection;
10
+ env?: CoinflowEnvs;
11
+ onSuccess?: OnSuccessMethod;
12
+ };
4
13
  export declare function CoinflowWithdraw({ wallet, merchantId, env, connection, onSuccess, style, }: CoinflowWithdrawProps & WithStyles): JSX.Element | null;
14
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"CoinflowWithdraw.js","sourceRoot":"","sources":["../src/CoinflowWithdraw.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAa,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,MAAM,UAAU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,EAAE,aAAa,UAAU,EAAE,EAChC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Connection, Signer } from '@solana/web3.js';
2
+ import { SubsetWalletContextState } from './ReactNativeCoinflowUtils';
3
+ export type WalletCall = {
4
+ method: string;
5
+ data: string;
6
+ };
7
+ export type OnSuccessMethod = (params: string) => void | Promise<void>;
8
+ type Props = {
9
+ wallet: SubsetWalletContextState;
10
+ connection: Connection;
11
+ onSuccess?: OnSuccessMethod;
12
+ partialSigners?: Signer[];
13
+ debugTx?: boolean;
14
+ sendIFrameMessage: (message: string) => void;
15
+ };
16
+ export declare function useHandleIFrameMessages({ wallet, connection, onSuccess, partialSigners, debugTx, sendIFrameMessage, }: Props): {
17
+ handleIframeMessages: ({ data }: {
18
+ data: string;
19
+ }) => Promise<void>;
20
+ };
21
+ export {};
@@ -0,0 +1,108 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useCallback } from 'react';
11
+ import base58 from 'bs58';
12
+ import { Transaction } from '@solana/web3.js';
13
+ export function useHandleIFrameMessages({ wallet, connection, onSuccess, partialSigners, debugTx = false, sendIFrameMessage, }) {
14
+ const handleSignMessage = useCallback(({ data }) => __awaiter(this, void 0, void 0, function* () {
15
+ if (!wallet.signMessage)
16
+ return;
17
+ const signature = yield wallet.signMessage(base58.decode(data));
18
+ sendIFrameMessage(base58.encode(signature));
19
+ }), [sendIFrameMessage, wallet]);
20
+ const sendTransactionDebug = useCallback((tx) => __awaiter(this, void 0, void 0, function* () {
21
+ if (!wallet.signTransaction)
22
+ throw new Error('Wallet does not support sign transaction');
23
+ const signedTx = yield wallet.signTransaction(tx);
24
+ const serializedTx = signedTx.serialize();
25
+ const signature = yield connection.sendRawTransaction(serializedTx, {
26
+ skipPreflight: true,
27
+ });
28
+ sendIFrameMessage(signature);
29
+ }), [connection, sendIFrameMessage, wallet]);
30
+ const handleSendTransaction = useCallback(({ data }) => __awaiter(this, void 0, void 0, function* () {
31
+ const tx = Transaction.from(base58.decode(data));
32
+ // Partially sign the transaction with any partial signers if needed
33
+ const partiallySign = (signer) => {
34
+ const requiredSignatures = tx.signatures.map(sig => sig.publicKey.toString());
35
+ const shouldSign = requiredSignatures.includes(signer.publicKey.toString());
36
+ if (shouldSign)
37
+ tx.partialSign(signer);
38
+ };
39
+ if (partialSigners) {
40
+ partialSigners.forEach(partiallySign);
41
+ }
42
+ if (debugTx) {
43
+ yield sendTransactionDebug(tx);
44
+ return;
45
+ }
46
+ const signature = yield wallet.sendTransaction(tx, connection);
47
+ sendIFrameMessage(signature);
48
+ }), [
49
+ connection,
50
+ debugTx,
51
+ partialSigners,
52
+ sendIFrameMessage,
53
+ sendTransactionDebug,
54
+ wallet,
55
+ ]);
56
+ const handleIframeMessages = useCallback(({ data }) => __awaiter(this, void 0, void 0, function* () {
57
+ try {
58
+ if (!wallet)
59
+ return;
60
+ const parsedData = parseJSON(data);
61
+ if (!parsedData)
62
+ return;
63
+ switch (parsedData.method) {
64
+ case 'signMessage': {
65
+ yield handleSignMessage(parsedData);
66
+ break;
67
+ }
68
+ case 'sendTransaction': {
69
+ yield handleSendTransaction(parsedData);
70
+ break;
71
+ }
72
+ case 'success': {
73
+ if (onSuccess)
74
+ onSuccess(data);
75
+ break;
76
+ }
77
+ default: {
78
+ throw new Error(`Unsupported Wallet Method ${parsedData.method}, must be signMessage or signTransaction`);
79
+ }
80
+ }
81
+ }
82
+ catch (e) {
83
+ console.error('handleIframeMessages', e);
84
+ sendIFrameMessage('ERROR');
85
+ }
86
+ }), [
87
+ handleSignMessage,
88
+ handleSendTransaction,
89
+ onSuccess,
90
+ sendIFrameMessage,
91
+ wallet,
92
+ ]);
93
+ return { handleIframeMessages };
94
+ }
95
+ function parseJSON(data) {
96
+ try {
97
+ const res = JSON.parse(data);
98
+ if (!res.method)
99
+ return null;
100
+ if (!res.data)
101
+ return null;
102
+ return res;
103
+ }
104
+ catch (e) {
105
+ return null;
106
+ }
107
+ }
108
+ //# sourceMappingURL=IFrameWalletConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IFrameWalletConnector.js","sourceRoot":"","sources":["../src/IFrameWalletConnector.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AAClC,OAAO,MAAM,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAqB,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAgBhE,MAAM,UAAU,uBAAuB,CAAC,EACtC,MAAM,EACN,UAAU,EACV,SAAS,EACT,cAAc,EACd,OAAO,GAAG,KAAK,EACf,iBAAiB,GACX;IACN,MAAM,iBAAiB,GAAG,WAAW,CACnC,CAAO,EAAC,IAAI,EAAa,EAAE,EAAE;QAC3B,IAAI,CAAC,MAAM,CAAC,WAAW;YAAE,OAAO;QAChC,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAChE,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAA,EACD,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAC5B,CAAC;IAEF,MAAM,oBAAoB,GAAG,WAAW,CACtC,CAAO,EAAe,EAAE,EAAE;QACxB,IAAI,CAAC,MAAM,CAAC,eAAe;YACzB,MAAM,IAAI,KAAK,CAAC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,IAAI,CAAC,GAAG,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAC3B,OAAO,GAAG,CAAC;KACZ;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,IAAI,CAAC;KACb;AACH,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Transaction } from '@solana/web3.js';
2
+ import { WalletContextState } from '@solana/wallet-adapter-react';
3
+ export type CoinflowEnvs = 'prod' | 'staging' | 'sandbox' | 'local';
4
+ export type SubsetWalletContextState = Pick<WalletContextState, 'signTransaction' | 'signMessage' | 'connected' | 'publicKey' | 'sendTransaction'>;
5
+ export declare class ReactNativeCoinflowUtils {
6
+ env: CoinflowEnvs;
7
+ url: string;
8
+ constructor(env?: CoinflowEnvs);
9
+ static getCoinflowBaseUrl(env?: CoinflowEnvs): string;
10
+ static getCoinflowUrl({ route, env, amount, publicKey, transaction, }: {
11
+ route: string;
12
+ publicKey: string;
13
+ env?: CoinflowEnvs;
14
+ amount?: number;
15
+ transaction?: Transaction;
16
+ }): string;
17
+ }
@@ -0,0 +1,35 @@
1
+ import base58 from 'bs58';
2
+ export class ReactNativeCoinflowUtils {
3
+ constructor(env) {
4
+ this.env = env !== null && env !== void 0 ? env : 'prod';
5
+ if (this.env === 'prod')
6
+ this.url = 'https://api.coinflow.cash';
7
+ else if (this.env === 'local')
8
+ this.url = 'http://localhost:5000';
9
+ else
10
+ this.url = `https://api-${this.env}.coinflow.cash`;
11
+ }
12
+ static getCoinflowBaseUrl(env) {
13
+ if (!env || env === 'prod')
14
+ return 'https://coinflow.cash';
15
+ if (env === 'local')
16
+ return 'http://localhost:3000';
17
+ return `https://${env}.coinflow.cash`;
18
+ }
19
+ static getCoinflowUrl({ route, env, amount, publicKey, transaction, }) {
20
+ const url = new URL(route, ReactNativeCoinflowUtils.getCoinflowBaseUrl(env));
21
+ url.searchParams.append('pubkey', publicKey);
22
+ if (transaction) {
23
+ const serializedTx = base58.encode(transaction.serialize({
24
+ requireAllSignatures: false,
25
+ verifySignatures: false,
26
+ }));
27
+ url.searchParams.append('transaction', serializedTx);
28
+ }
29
+ if (amount) {
30
+ url.searchParams.append('amount', amount.toString());
31
+ }
32
+ return url.toString();
33
+ }
34
+ }
35
+ //# sourceMappingURL=ReactNativeCoinflowUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactNativeCoinflowUtils.js","sourceRoot":"","sources":["../src/ReactNativeCoinflowUtils.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,MAAM,CAAC;AAc1B,MAAM,OAAO,wBAAwB;IAInC,YAAY,GAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,MAAM,CAAC;QACzB,IAAI,IAAI,CAAC,GAAG,KAAK,MAAM;YAAE,IAAI,CAAC,GAAG,GAAG,2BAA2B,CAAC;aAC3D,IAAI,IAAI,CAAC,GAAG,KAAK,OAAO;YAAE,IAAI,CAAC,GAAG,GAAG,uBAAuB,CAAC;;YAC7D,IAAI,CAAC,GAAG,GAAG,eAAe,IAAI,CAAC,GAAG,gBAAgB,CAAC;IAC1D,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,GAAkB;QAC1C,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,MAAM;YAAE,OAAO,uBAAuB,CAAC;QAC3D,IAAI,GAAG,KAAK,OAAO;YAAE,OAAO,uBAAuB,CAAC;QAEpD,OAAO,WAAW,GAAG,gBAAgB,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,EACpB,KAAK,EACL,GAAG,EACH,MAAM,EACN,SAAS,EACT,WAAW,GAOZ;QACC,MAAM,GAAG,GAAG,IAAI,GAAG,CACjB,KAAK,EACL,wBAAwB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CACjD,CAAC;QACF,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC7C,IAAI,WAAW,EAAE;YACf,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAChC,WAAW,CAAC,SAAS,CAAC;gBACpB,oBAAoB,EAAE,KAAK;gBAC3B,gBAAgB,EAAE,KAAK;aACxB,CAAC,CACH,CAAC;YACF,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;SACtD;QACD,IAAI,MAAM,EAAE;YACV,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;SACtD;QACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;CACF"}
package/build/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- import { CoinflowUtils } from '@coinflowlabs/react';
2
- export { CoinflowUtils };
3
1
  export * from './CoinflowWithdraw';
4
2
  export * from './CoinflowPurchase';
package/build/index.js CHANGED
@@ -1,5 +1,3 @@
1
- import { CoinflowUtils } from '@coinflowlabs/react';
2
- export { CoinflowUtils };
3
1
  export * from './CoinflowWithdraw';
4
2
  export * from './CoinflowPurchase';
5
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAC,aAAa,EAAC,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
@@ -1,9 +1,19 @@
1
1
  /// <reference types="react" />
2
2
  import { WebView } from 'react-native-webview';
3
- import { IFrameWalletProps } from '@coinflowlabs/react';
3
+ import { OnSuccessMethod } from './IFrameWalletConnector';
4
+ import { Connection, Signer } from '@solana/web3.js';
5
+ import { SubsetWalletContextState } from './ReactNativeCoinflowUtils';
6
+ type IFrameWalletProps = {
7
+ wallet: SubsetWalletContextState;
8
+ connection: Connection;
9
+ onSuccess?: OnSuccessMethod;
10
+ partialSigners?: Signer[];
11
+ debugTx?: boolean;
12
+ };
4
13
  export declare function useIframeWallet({ wallet, connection, onSuccess, partialSigners, debugTx, }: IFrameWalletProps): {
5
14
  WebViewRef: import("react").RefObject<WebView<{}>>;
6
15
  handleIframeMessages: ({ data }: {
7
16
  data: string;
8
17
  }) => Promise<void>;
9
18
  };
19
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useRef } from 'react';
2
- import { useHandleIFrameMessages } from '@coinflowlabs/react';
2
+ import { useHandleIFrameMessages, } from './IFrameWalletConnector';
3
3
  export function useIframeWallet({ wallet, connection, onSuccess, partialSigners, debugTx = false, }) {
4
4
  const WebViewRef = useRef(null);
5
5
  const sendIFrameMessage = useCallback((message) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useIframeWallet.js","sourceRoot":"","sources":["../src/useIframeWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAC,uBAAuB,EAAoB,MAAM,qBAAqB,CAAC;AAE/E,MAAM,UAAU,eAAe,CAAC,EAC9B,MAAM,EACN,UAAU,EACV,SAAS,EACT,cAAc,EACd,OAAO,GAAG,KAAK,GACG;IAClB,MAAM,UAAU,GAAG,MAAM,CAAU,IAAI,CAAC,CAAC;IAEzC,MAAM,iBAAiB,GAAG,WAAW,CACnC,CAAC,OAAe,EAAE,EAAE;QAClB,IAAI,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,CAAA;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACpE,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC,EACD,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,MAAM,EAAC,oBAAoB,EAAC,GAAG,uBAAuB,CAAC;QACrD,MAAM;QACN,UAAU;QACV,SAAS;QACT,cAAc;QACd,OAAO;QACP,iBAAiB;KAClB,CAAC,CAAC;IAEH,OAAO,EAAC,UAAU,EAAE,oBAAoB,EAAC,CAAC;AAC5C,CAAC"}
1
+ {"version":3,"file":"useIframeWallet.js","sourceRoot":"","sources":["../src/useIframeWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAE1C,OAAO,EAEL,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AAYjC,MAAM,UAAU,eAAe,CAAC,EAC9B,MAAM,EACN,UAAU,EACV,SAAS,EACT,cAAc,EACd,OAAO,GAAG,KAAK,GACG;IAClB,MAAM,UAAU,GAAG,MAAM,CAAU,IAAI,CAAC,CAAC;IAEzC,MAAM,iBAAiB,GAAG,WAAW,CACnC,CAAC,OAAe,EAAE,EAAE;QAClB,IAAI,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,CAAA;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACpE,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC,EACD,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,MAAM,EAAC,oBAAoB,EAAC,GAAG,uBAAuB,CAAC;QACrD,MAAM;QACN,UAAU;QACV,SAAS;QACT,cAAc;QACd,OAAO;QACP,iBAAiB;KAClB,CAAC,CAAC;IAEH,OAAO,EAAC,UAAU,EAAE,oBAAoB,EAAC,CAAC;AAC5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinflowlabs/react-native",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "React Native Component for Coinflow Withdraw",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -22,11 +22,10 @@
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": ">=16",
25
- "react-native": ">=0.66.0"
25
+ "react-native": ">=0.66.0",
26
+ "react-native-webview": ">=11.16.0"
26
27
  },
27
28
  "dependencies": {
28
- "@coinflowlabs/react": "*",
29
- "react-native-webview": "^11.25.0",
30
29
  "bs58": "^5.0.0",
31
30
  "@solana/web3.js": "^1.69.0"
32
31
  },