@reown/appkit-core-react-native 0.0.0-develop-20240925193922 → 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 (141) 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 -3
  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 -3
  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/ModalController.d.ts.map +1 -1
  63. package/lib/typescript/controllers/NetworkController.d.ts +0 -1
  64. package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
  65. package/lib/typescript/controllers/RouterController.d.ts +1 -13
  66. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  67. package/lib/typescript/index.d.ts +26 -18
  68. package/lib/typescript/index.d.ts.map +1 -1
  69. package/lib/typescript/utils/ConstantsUtil.d.ts +0 -1
  70. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  71. package/lib/typescript/utils/CoreHelperUtil.d.ts +0 -6
  72. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  73. package/lib/typescript/utils/FetchUtil.d.ts +0 -3
  74. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  75. package/lib/typescript/utils/TypeUtil.d.ts +0 -137
  76. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  77. package/package.json +5 -5
  78. package/readme.md +1 -1
  79. package/src/controllers/AccountController.ts +1 -35
  80. package/src/controllers/ApiController.ts +7 -3
  81. package/src/controllers/BlockchainApiController.ts +1 -88
  82. package/src/controllers/ConnectionController.ts +1 -37
  83. package/src/controllers/EventsController.ts +13 -1
  84. package/src/controllers/ModalController.ts +1 -3
  85. package/src/controllers/NetworkController.ts +0 -6
  86. package/src/controllers/OptionsController.ts +1 -1
  87. package/src/controllers/RouterController.ts +10 -52
  88. package/src/index.ts +30 -41
  89. package/src/utils/ConstantsUtil.ts +1 -3
  90. package/src/utils/CoreHelperUtil.ts +1 -38
  91. package/src/utils/FetchUtil.ts +0 -4
  92. package/src/utils/TypeUtil.ts +0 -169
  93. package/lib/commonjs/controllers/EnsController.js +0 -35
  94. package/lib/commonjs/controllers/EnsController.js.map +0 -1
  95. package/lib/commonjs/controllers/SendController.js +0 -176
  96. package/lib/commonjs/controllers/SendController.js.map +0 -1
  97. package/lib/commonjs/controllers/SwapController.js +0 -91
  98. package/lib/commonjs/controllers/SwapController.js.map +0 -1
  99. package/lib/commonjs/controllers/TransactionsController.js +0 -111
  100. package/lib/commonjs/controllers/TransactionsController.js.map +0 -1
  101. package/lib/commonjs/utils/ApiUtil.js +0 -18
  102. package/lib/commonjs/utils/ApiUtil.js.map +0 -1
  103. package/lib/commonjs/utils/SwapApiUtil.js +0 -23
  104. package/lib/commonjs/utils/SwapApiUtil.js.map +0 -1
  105. package/lib/commonjs/utils/SwapCalculationUtil.js +0 -24
  106. package/lib/commonjs/utils/SwapCalculationUtil.js.map +0 -1
  107. package/lib/module/controllers/EnsController.js +0 -30
  108. package/lib/module/controllers/EnsController.js.map +0 -1
  109. package/lib/module/controllers/SendController.js +0 -171
  110. package/lib/module/controllers/SendController.js.map +0 -1
  111. package/lib/module/controllers/SwapController.js +0 -86
  112. package/lib/module/controllers/SwapController.js.map +0 -1
  113. package/lib/module/controllers/TransactionsController.js +0 -106
  114. package/lib/module/controllers/TransactionsController.js.map +0 -1
  115. package/lib/module/utils/ApiUtil.js +0 -12
  116. package/lib/module/utils/ApiUtil.js.map +0 -1
  117. package/lib/module/utils/SwapApiUtil.js +0 -17
  118. package/lib/module/utils/SwapApiUtil.js.map +0 -1
  119. package/lib/module/utils/SwapCalculationUtil.js +0 -19
  120. package/lib/module/utils/SwapCalculationUtil.js.map +0 -1
  121. package/lib/typescript/controllers/EnsController.d.ts +0 -10
  122. package/lib/typescript/controllers/EnsController.d.ts.map +0 -1
  123. package/lib/typescript/controllers/SendController.d.ts +0 -41
  124. package/lib/typescript/controllers/SendController.d.ts.map +0 -1
  125. package/lib/typescript/controllers/SwapController.d.ts +0 -29
  126. package/lib/typescript/controllers/SwapController.d.ts.map +0 -1
  127. package/lib/typescript/controllers/TransactionsController.d.ts +0 -21
  128. package/lib/typescript/controllers/TransactionsController.d.ts.map +0 -1
  129. package/lib/typescript/utils/ApiUtil.d.ts +0 -5
  130. package/lib/typescript/utils/ApiUtil.d.ts.map +0 -1
  131. package/lib/typescript/utils/SwapApiUtil.d.ts +0 -4
  132. package/lib/typescript/utils/SwapApiUtil.d.ts.map +0 -1
  133. package/lib/typescript/utils/SwapCalculationUtil.d.ts +0 -5
  134. package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +0 -1
  135. package/src/controllers/EnsController.ts +0 -39
  136. package/src/controllers/SendController.ts +0 -234
  137. package/src/controllers/SwapController.ts +0 -108
  138. package/src/controllers/TransactionsController.ts +0 -141
  139. package/src/utils/ApiUtil.ts +0 -18
  140. package/src/utils/SwapApiUtil.ts +0 -19
  141. 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,141 +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
-
59
- if (reset) {
60
- filteredTransactions = nonSpamTransactions;
61
- }
62
-
63
- state.loading = false;
64
-
65
- state.transactions = filteredTransactions;
66
-
67
- state.empty = nonSpamTransactions.length === 0;
68
- state.next = response?.next ? response.next : undefined;
69
- } catch (error) {
70
- EventsController.sendEvent({
71
- type: 'track',
72
- event: 'ERROR_FETCH_TRANSACTIONS',
73
- properties: {
74
- address: accountAddress,
75
- projectId,
76
- cursor: state.next,
77
- isSmartAccount: false
78
- }
79
- });
80
- SnackController.showError('Failed to fetch transactions');
81
- state.loading = false;
82
- state.empty = true;
83
- state.next = undefined;
84
- }
85
- },
86
-
87
- getTransactionsByYearAndMonth(transactions: Transaction[]) {
88
- const grouped: TransactionByYearMap = {};
89
- let filteredTransactions = this.filterByConnectedChain(transactions);
90
-
91
- filteredTransactions.forEach(transaction => {
92
- const year = new Date(transaction.metadata.minedAt).getFullYear();
93
- const month = new Date(transaction.metadata.minedAt).getMonth();
94
-
95
- const yearTransactions = grouped[year] ?? {};
96
- const monthTransactions = yearTransactions[month] ?? [];
97
-
98
- // If there's a transaction with the same id, remove the old one
99
- const newMonthTransactions = monthTransactions.filter(tx => tx.id !== transaction.id);
100
-
101
- grouped[year] = {
102
- ...yearTransactions,
103
- [month]: [...newMonthTransactions, transaction].sort(
104
- (a, b) => new Date(b.metadata.minedAt).getTime() - new Date(a.metadata.minedAt).getTime()
105
- )
106
- };
107
- });
108
-
109
- return grouped;
110
- },
111
-
112
- filterSpamTransactions(transactions: Transaction[]) {
113
- return transactions.filter(transaction => {
114
- const isAllSpam = transaction.transfers.every(
115
- transfer => transfer.nft_info?.flags.is_spam === true
116
- );
117
-
118
- return !isAllSpam;
119
- });
120
- },
121
-
122
- filterByConnectedChain(transactions: Transaction[]) {
123
- const chainId = NetworkController.state.caipNetwork?.id;
124
- const filteredTransactions = transactions.filter(
125
- transaction => transaction.metadata.chain === chainId
126
- );
127
-
128
- return filteredTransactions;
129
- },
130
-
131
- clearCursor() {
132
- state.next = undefined;
133
- },
134
-
135
- resetTransactions() {
136
- state.transactions = [];
137
- state.loading = false;
138
- state.empty = false;
139
- state.next = undefined;
140
- }
141
- };
@@ -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
- };