@reown/appkit-core-react-native 0.0.0-feat-wallet-features-20240925132010 → 0.0.0-fix-email-login-20241010173711

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.
Files changed (140) hide show
  1. package/lib/commonjs/controllers/AccountController.js +1 -25
  2. package/lib/commonjs/controllers/AccountController.js.map +1 -1
  3. package/lib/commonjs/controllers/ApiController.js +3 -3
  4. package/lib/commonjs/controllers/ApiController.js.map +1 -1
  5. package/lib/commonjs/controllers/BlockchainApiController.js +0 -84
  6. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  7. package/lib/commonjs/controllers/ConnectionController.js +0 -19
  8. package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
  9. package/lib/commonjs/controllers/EventsController.js +15 -1
  10. package/lib/commonjs/controllers/EventsController.js.map +1 -1
  11. package/lib/commonjs/controllers/ModalController.js +1 -1
  12. package/lib/commonjs/controllers/ModalController.js.map +1 -1
  13. package/lib/commonjs/controllers/NetworkController.js +0 -3
  14. package/lib/commonjs/controllers/NetworkController.js.map +1 -1
  15. package/lib/commonjs/controllers/OptionsController.js +1 -1
  16. package/lib/commonjs/controllers/OptionsController.js.map +1 -1
  17. package/lib/commonjs/controllers/RouterController.js +1 -22
  18. package/lib/commonjs/controllers/RouterController.js.map +1 -1
  19. package/lib/commonjs/index.js +0 -35
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/utils/ConstantsUtil.js +1 -2
  22. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  23. package/lib/commonjs/utils/CoreHelperUtil.js +0 -33
  24. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  25. package/lib/commonjs/utils/FetchUtil.js.map +1 -1
  26. package/lib/commonjs/utils/TypeUtil.js +0 -4
  27. package/lib/module/controllers/AccountController.js +1 -25
  28. package/lib/module/controllers/AccountController.js.map +1 -1
  29. package/lib/module/controllers/ApiController.js +3 -3
  30. package/lib/module/controllers/ApiController.js.map +1 -1
  31. package/lib/module/controllers/BlockchainApiController.js +0 -84
  32. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  33. package/lib/module/controllers/ConnectionController.js +0 -19
  34. package/lib/module/controllers/ConnectionController.js.map +1 -1
  35. package/lib/module/controllers/EventsController.js +15 -1
  36. package/lib/module/controllers/EventsController.js.map +1 -1
  37. package/lib/module/controllers/ModalController.js +1 -1
  38. package/lib/module/controllers/ModalController.js.map +1 -1
  39. package/lib/module/controllers/NetworkController.js +0 -3
  40. package/lib/module/controllers/NetworkController.js.map +1 -1
  41. package/lib/module/controllers/OptionsController.js +1 -1
  42. package/lib/module/controllers/OptionsController.js.map +1 -1
  43. package/lib/module/controllers/RouterController.js +1 -22
  44. package/lib/module/controllers/RouterController.js.map +1 -1
  45. package/lib/module/index.js +0 -6
  46. package/lib/module/index.js.map +1 -1
  47. package/lib/module/utils/ConstantsUtil.js +1 -2
  48. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  49. package/lib/module/utils/CoreHelperUtil.js +0 -33
  50. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  51. package/lib/module/utils/FetchUtil.js.map +1 -1
  52. package/lib/module/utils/TypeUtil.js +1 -1
  53. package/lib/typescript/controllers/AccountController.d.ts +0 -4
  54. package/lib/typescript/controllers/AccountController.d.ts.map +1 -1
  55. package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
  56. package/lib/typescript/controllers/BlockchainApiController.d.ts +1 -6
  57. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  58. package/lib/typescript/controllers/ConnectionController.d.ts +1 -13
  59. package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
  60. package/lib/typescript/controllers/EventsController.d.ts +6 -0
  61. package/lib/typescript/controllers/EventsController.d.ts.map +1 -1
  62. package/lib/typescript/controllers/NetworkController.d.ts +0 -1
  63. package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
  64. package/lib/typescript/controllers/RouterController.d.ts +1 -13
  65. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  66. package/lib/typescript/index.d.ts +26 -18
  67. package/lib/typescript/index.d.ts.map +1 -1
  68. package/lib/typescript/utils/ConstantsUtil.d.ts +0 -1
  69. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  70. package/lib/typescript/utils/CoreHelperUtil.d.ts +0 -6
  71. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  72. package/lib/typescript/utils/FetchUtil.d.ts +0 -3
  73. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  74. package/lib/typescript/utils/TypeUtil.d.ts +0 -137
  75. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  76. package/package.json +5 -5
  77. package/readme.md +1 -1
  78. package/src/controllers/AccountController.ts +1 -35
  79. package/src/controllers/ApiController.ts +7 -3
  80. package/src/controllers/BlockchainApiController.ts +1 -88
  81. package/src/controllers/ConnectionController.ts +1 -37
  82. package/src/controllers/EventsController.ts +13 -1
  83. package/src/controllers/ModalController.ts +1 -1
  84. package/src/controllers/NetworkController.ts +0 -6
  85. package/src/controllers/OptionsController.ts +1 -1
  86. package/src/controllers/RouterController.ts +10 -52
  87. package/src/index.ts +30 -41
  88. package/src/utils/ConstantsUtil.ts +1 -3
  89. package/src/utils/CoreHelperUtil.ts +1 -38
  90. package/src/utils/FetchUtil.ts +0 -4
  91. package/src/utils/TypeUtil.ts +0 -169
  92. package/lib/commonjs/controllers/EnsController.js +0 -35
  93. package/lib/commonjs/controllers/EnsController.js.map +0 -1
  94. package/lib/commonjs/controllers/SendController.js +0 -176
  95. package/lib/commonjs/controllers/SendController.js.map +0 -1
  96. package/lib/commonjs/controllers/SwapController.js +0 -91
  97. package/lib/commonjs/controllers/SwapController.js.map +0 -1
  98. package/lib/commonjs/controllers/TransactionsController.js +0 -112
  99. package/lib/commonjs/controllers/TransactionsController.js.map +0 -1
  100. package/lib/commonjs/utils/ApiUtil.js +0 -18
  101. package/lib/commonjs/utils/ApiUtil.js.map +0 -1
  102. package/lib/commonjs/utils/SwapApiUtil.js +0 -23
  103. package/lib/commonjs/utils/SwapApiUtil.js.map +0 -1
  104. package/lib/commonjs/utils/SwapCalculationUtil.js +0 -24
  105. package/lib/commonjs/utils/SwapCalculationUtil.js.map +0 -1
  106. package/lib/module/controllers/EnsController.js +0 -30
  107. package/lib/module/controllers/EnsController.js.map +0 -1
  108. package/lib/module/controllers/SendController.js +0 -171
  109. package/lib/module/controllers/SendController.js.map +0 -1
  110. package/lib/module/controllers/SwapController.js +0 -86
  111. package/lib/module/controllers/SwapController.js.map +0 -1
  112. package/lib/module/controllers/TransactionsController.js +0 -107
  113. package/lib/module/controllers/TransactionsController.js.map +0 -1
  114. package/lib/module/utils/ApiUtil.js +0 -12
  115. package/lib/module/utils/ApiUtil.js.map +0 -1
  116. package/lib/module/utils/SwapApiUtil.js +0 -17
  117. package/lib/module/utils/SwapApiUtil.js.map +0 -1
  118. package/lib/module/utils/SwapCalculationUtil.js +0 -19
  119. package/lib/module/utils/SwapCalculationUtil.js.map +0 -1
  120. package/lib/typescript/controllers/EnsController.d.ts +0 -10
  121. package/lib/typescript/controllers/EnsController.d.ts.map +0 -1
  122. package/lib/typescript/controllers/SendController.d.ts +0 -41
  123. package/lib/typescript/controllers/SendController.d.ts.map +0 -1
  124. package/lib/typescript/controllers/SwapController.d.ts +0 -29
  125. package/lib/typescript/controllers/SwapController.d.ts.map +0 -1
  126. package/lib/typescript/controllers/TransactionsController.d.ts +0 -21
  127. package/lib/typescript/controllers/TransactionsController.d.ts.map +0 -1
  128. package/lib/typescript/utils/ApiUtil.d.ts +0 -5
  129. package/lib/typescript/utils/ApiUtil.d.ts.map +0 -1
  130. package/lib/typescript/utils/SwapApiUtil.d.ts +0 -4
  131. package/lib/typescript/utils/SwapApiUtil.d.ts.map +0 -1
  132. package/lib/typescript/utils/SwapCalculationUtil.d.ts +0 -5
  133. package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +0 -1
  134. package/src/controllers/EnsController.ts +0 -39
  135. package/src/controllers/SendController.ts +0 -234
  136. package/src/controllers/SwapController.ts +0 -108
  137. package/src/controllers/TransactionsController.ts +0 -142
  138. package/src/utils/ApiUtil.ts +0 -18
  139. package/src/utils/SwapApiUtil.ts +0 -19
  140. package/src/utils/SwapCalculationUtil.ts +0 -21
@@ -1,108 +0,0 @@
1
- import { subscribeKey as subKey } from 'valtio/utils';
2
- import { proxy, subscribe as sub } from 'valtio';
3
-
4
- import { ConstantsUtil } from '../utils/ConstantsUtil';
5
- import { SwapApiUtil } from '../utils/SwapApiUtil';
6
- import { NetworkController } from './NetworkController';
7
- import { BlockchainApiController } from './BlockchainApiController';
8
- import { OptionsController } from './OptionsController';
9
- import { SwapCalculationUtil } from '../utils/SwapCalculationUtil';
10
-
11
- // -- Constants ---------------------------------------- //
12
- export const INITIAL_GAS_LIMIT = 150000;
13
- export const TO_AMOUNT_DECIMALS = 6;
14
-
15
- // -- Types --------------------------------------------- //
16
-
17
- export interface SwapControllerState {
18
- // Input values
19
- networkPrice: string;
20
- networkTokenSymbol: string;
21
-
22
- // Tokens
23
- tokensPriceMap: Record<string, number>;
24
-
25
- // Calculations
26
- gasFee: string;
27
- gasPriceInUSD?: number;
28
- }
29
-
30
- type StateKey = keyof SwapControllerState;
31
-
32
- // -- State --------------------------------------------- //
33
- const initialState: SwapControllerState = {
34
- // Input values
35
- networkPrice: '0',
36
- networkTokenSymbol: '',
37
-
38
- // Tokens
39
- tokensPriceMap: {},
40
-
41
- // Calculations
42
- gasFee: '0',
43
- gasPriceInUSD: 0
44
- };
45
-
46
- const state = proxy<SwapControllerState>(initialState);
47
-
48
- // -- Controller ---------------------------------------- //
49
- export const SwapController = {
50
- state,
51
-
52
- subscribe(callback: (newState: SwapControllerState) => void) {
53
- return sub(state, () => callback(state));
54
- },
55
-
56
- subscribeKey<K extends StateKey>(key: K, callback: (value: SwapControllerState[K]) => void) {
57
- return subKey(state, key, callback);
58
- },
59
-
60
- getParams() {
61
- const caipNetwork = NetworkController.state.caipNetwork;
62
- const networkAddress = `${caipNetwork?.id}:${ConstantsUtil.NATIVE_TOKEN_ADDRESS}`;
63
-
64
- return {
65
- networkAddress
66
- };
67
- },
68
-
69
- resetState() {
70
- state.tokensPriceMap = initialState.tokensPriceMap;
71
- state.networkPrice = initialState.networkPrice;
72
- state.networkTokenSymbol = initialState.networkTokenSymbol;
73
- },
74
-
75
- //this
76
- async getNetworkTokenPrice() {
77
- const { networkAddress } = this.getParams();
78
-
79
- const response = await BlockchainApiController.fetchTokenPrice({
80
- projectId: OptionsController.state.projectId,
81
- addresses: [networkAddress]
82
- });
83
- const token = response?.fungibles?.[0];
84
- const price = token?.price.toString() || '0';
85
- state.tokensPriceMap[networkAddress] = parseFloat(price);
86
- state.networkTokenSymbol = token?.symbol || '';
87
- state.networkPrice = price;
88
- },
89
-
90
- //this
91
- async getInitialGasPrice() {
92
- const res = await SwapApiUtil.fetchGasPrice();
93
-
94
- if (!res) {
95
- return { gasPrice: null, gasPriceInUsd: null };
96
- }
97
-
98
- const value = res.standard;
99
- const gasFee = BigInt(value);
100
- const gasLimit = BigInt(INITIAL_GAS_LIMIT);
101
- const gasPrice = SwapCalculationUtil.getGasPriceInUSD(state.networkPrice, gasLimit, gasFee);
102
-
103
- state.gasFee = value;
104
- state.gasPriceInUSD = gasPrice;
105
-
106
- return { gasPrice: gasFee, gasPriceInUSD: state.gasPriceInUSD };
107
- }
108
- };
@@ -1,142 +0,0 @@
1
- import type { Transaction } from '@reown/appkit-common-react-native';
2
- import { proxy, subscribe as sub } from 'valtio/vanilla';
3
- import { OptionsController } from './OptionsController';
4
- import { EventsController } from './EventsController';
5
- import { SnackController } from './SnackController';
6
- import { NetworkController } from './NetworkController';
7
- import { BlockchainApiController } from './BlockchainApiController';
8
-
9
- // -- Types --------------------------------------------- //
10
- type TransactionByMonthMap = Record<string, Transaction[]>;
11
- type TransactionByYearMap = Record<string, TransactionByMonthMap>;
12
-
13
- export interface TransactionsControllerState {
14
- transactions: Transaction[];
15
- loading: boolean;
16
- empty: boolean;
17
- next: string | undefined;
18
- }
19
-
20
- // -- State --------------------------------------------- //
21
- const state = proxy<TransactionsControllerState>({
22
- transactions: [],
23
- loading: false,
24
- empty: false,
25
- next: undefined
26
- });
27
-
28
- // -- Controller ---------------------------------------- //
29
- export const TransactionsController = {
30
- state,
31
-
32
- subscribe(callback: (newState: TransactionsControllerState) => void) {
33
- return sub(state, () => callback(state));
34
- },
35
-
36
- async fetchTransactions(accountAddress?: string, reset?: boolean) {
37
- const { projectId } = OptionsController.state;
38
-
39
- if (!projectId || !accountAddress) {
40
- throw new Error("Transactions can't be fetched without a projectId and an accountAddress");
41
- }
42
-
43
- state.loading = true;
44
-
45
- if (reset) {
46
- state.next = undefined;
47
- }
48
-
49
- try {
50
- const response = await BlockchainApiController.fetchTransactions({
51
- account: accountAddress,
52
- projectId,
53
- cursor: state.next
54
- });
55
-
56
- const nonSpamTransactions = this.filterSpamTransactions(response?.data ?? []);
57
- let filteredTransactions = [...state.transactions, ...nonSpamTransactions];
58
- filteredTransactions = [...state.transactions, ...nonSpamTransactions];
59
-
60
- if (reset) {
61
- filteredTransactions = nonSpamTransactions;
62
- }
63
-
64
- state.loading = false;
65
-
66
- state.transactions = filteredTransactions;
67
-
68
- state.empty = nonSpamTransactions.length === 0;
69
- state.next = response?.next ? response.next : undefined;
70
- } catch (error) {
71
- EventsController.sendEvent({
72
- type: 'track',
73
- event: 'ERROR_FETCH_TRANSACTIONS',
74
- properties: {
75
- address: accountAddress,
76
- projectId,
77
- cursor: state.next,
78
- isSmartAccount: false
79
- }
80
- });
81
- SnackController.showError('Failed to fetch transactions');
82
- state.loading = false;
83
- state.empty = true;
84
- state.next = undefined;
85
- }
86
- },
87
-
88
- getTransactionsByYearAndMonth(transactions: Transaction[]) {
89
- const grouped: TransactionByYearMap = {};
90
- let filteredTransactions = this.filterByConnectedChain(transactions);
91
-
92
- filteredTransactions.forEach(transaction => {
93
- const year = new Date(transaction.metadata.minedAt).getFullYear();
94
- const month = new Date(transaction.metadata.minedAt).getMonth();
95
-
96
- const yearTransactions = grouped[year] ?? {};
97
- const monthTransactions = yearTransactions[month] ?? [];
98
-
99
- // If there's a transaction with the same id, remove the old one
100
- const newMonthTransactions = monthTransactions.filter(tx => tx.id !== transaction.id);
101
-
102
- grouped[year] = {
103
- ...yearTransactions,
104
- [month]: [...newMonthTransactions, transaction].sort(
105
- (a, b) => new Date(b.metadata.minedAt).getTime() - new Date(a.metadata.minedAt).getTime()
106
- )
107
- };
108
- });
109
-
110
- return grouped;
111
- },
112
-
113
- filterSpamTransactions(transactions: Transaction[]) {
114
- return transactions.filter(transaction => {
115
- const isAllSpam = transaction.transfers.every(
116
- transfer => transfer.nft_info?.flags.is_spam === true
117
- );
118
-
119
- return !isAllSpam;
120
- });
121
- },
122
-
123
- filterByConnectedChain(transactions: Transaction[]) {
124
- const chainId = NetworkController.state.caipNetwork?.id;
125
- const filteredTransactions = transactions.filter(
126
- transaction => transaction.metadata.chain === chainId
127
- );
128
-
129
- return filteredTransactions;
130
- },
131
-
132
- clearCursor() {
133
- state.next = undefined;
134
- },
135
-
136
- resetTransactions() {
137
- state.transactions = [];
138
- state.loading = false;
139
- state.empty = false;
140
- state.next = undefined;
141
- }
142
- };
@@ -1,18 +0,0 @@
1
- import { Platform } from 'react-native';
2
- import { CoreHelperUtil } from './CoreHelperUtil';
3
-
4
- export const ApiUtil = {
5
- getOrigin() {
6
- return CoreHelperUtil.getBundleId();
7
- },
8
-
9
- getUserAgent() {
10
- const reactNativeVersion = [
11
- Platform.constants.reactNativeVersion.major,
12
- Platform.constants.reactNativeVersion.minor,
13
- Platform.constants.reactNativeVersion.patch
14
- ].join('.');
15
-
16
- return `${Platform.OS}-${Platform.Version}@rn-${reactNativeVersion}`;
17
- }
18
- };
@@ -1,19 +0,0 @@
1
- import { BlockchainApiController } from '../controllers/BlockchainApiController';
2
- import { OptionsController } from '../controllers/OptionsController';
3
- import { NetworkController } from '../controllers/NetworkController';
4
-
5
- export const SwapApiUtil = {
6
- async fetchGasPrice() {
7
- const projectId = OptionsController.state.projectId;
8
- const caipNetwork = NetworkController.state.caipNetwork;
9
-
10
- if (!caipNetwork) {
11
- return null;
12
- }
13
-
14
- return await BlockchainApiController.fetchGasPrice({
15
- projectId,
16
- chainId: caipNetwork.id
17
- });
18
- }
19
- };
@@ -1,21 +0,0 @@
1
- // -- Types --------------------------------------------- //
2
-
3
- import { NumberUtil } from '@reown/appkit-common-react-native';
4
-
5
- // -- Util ---------------------------------------- //
6
- export const SwapCalculationUtil = {
7
- getGasPriceInEther(gas: bigint, gasPrice: bigint) {
8
- const totalGasCostInWei = gasPrice * gas;
9
- const totalGasCostInEther = Number(totalGasCostInWei) / 1e18;
10
-
11
- return totalGasCostInEther;
12
- },
13
-
14
- getGasPriceInUSD(networkPrice: string, gas: bigint, gasPrice: bigint) {
15
- const totalGasCostInEther = SwapCalculationUtil.getGasPriceInEther(gas, gasPrice);
16
- const networkPriceInUSD = NumberUtil.bigNumber(networkPrice);
17
- const gasCostInUSD = networkPriceInUSD.multipliedBy(totalGasCostInEther);
18
-
19
- return gasCostInUSD.toNumber();
20
- }
21
- };