@reown/appkit-core-react-native 0.0.0-feat-onramp-20250626195202 → 0.0.0-feat-multi-social-20250630195637
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/lib/commonjs/controllers/ApiController.js +11 -11
- package/lib/commonjs/controllers/ApiController.js.map +1 -1
- package/lib/commonjs/controllers/BlockchainApiController.js +102 -24
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionController.js +7 -5
- package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionsController.js +217 -0
- package/lib/commonjs/controllers/ConnectionsController.js.map +1 -0
- package/lib/commonjs/controllers/ConnectorController.js +1 -0
- package/lib/commonjs/controllers/ConnectorController.js.map +1 -1
- package/lib/commonjs/controllers/EnsController.js +4 -4
- package/lib/commonjs/controllers/EnsController.js.map +1 -1
- package/lib/commonjs/controllers/EventsController.js +4 -4
- package/lib/commonjs/controllers/EventsController.js.map +1 -1
- package/lib/commonjs/controllers/ModalController.js.map +1 -1
- package/lib/commonjs/controllers/OnRampController.js +20 -60
- package/lib/commonjs/controllers/OnRampController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js +8 -3
- package/lib/commonjs/controllers/OptionsController.js.map +1 -1
- package/lib/commonjs/controllers/RouterController.js.map +1 -1
- package/lib/commonjs/controllers/SendController.js +10 -10
- package/lib/commonjs/controllers/SendController.js.map +1 -1
- package/lib/commonjs/controllers/SwapController.js +51 -40
- package/lib/commonjs/controllers/SwapController.js.map +1 -1
- package/lib/commonjs/controllers/ThemeController.js +9 -1
- package/lib/commonjs/controllers/ThemeController.js.map +1 -1
- package/lib/commonjs/controllers/TransactionsController.js +5 -5
- package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
- package/lib/commonjs/index.js +3 -10
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/AssetUtil.js +5 -6
- package/lib/commonjs/utils/AssetUtil.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +537 -8
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/CoreHelperUtil.js +3 -3
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
- package/lib/commonjs/utils/StorageUtil.js +67 -33
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapApiUtil.js +19 -10
- package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
- package/lib/module/controllers/ApiController.js +11 -11
- package/lib/module/controllers/ApiController.js.map +1 -1
- package/lib/module/controllers/BlockchainApiController.js +102 -24
- package/lib/module/controllers/BlockchainApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionController.js +7 -5
- package/lib/module/controllers/ConnectionController.js.map +1 -1
- package/lib/module/controllers/ConnectionsController.js +212 -0
- package/lib/module/controllers/ConnectionsController.js.map +1 -0
- package/lib/module/controllers/ConnectorController.js +1 -0
- package/lib/module/controllers/ConnectorController.js.map +1 -1
- package/lib/module/controllers/EnsController.js +2 -2
- package/lib/module/controllers/EnsController.js.map +1 -1
- package/lib/module/controllers/EventsController.js +1 -1
- package/lib/module/controllers/EventsController.js.map +1 -1
- package/lib/module/controllers/ModalController.js.map +1 -1
- package/lib/module/controllers/OnRampController.js +20 -60
- package/lib/module/controllers/OnRampController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js +8 -3
- package/lib/module/controllers/OptionsController.js.map +1 -1
- package/lib/module/controllers/RouterController.js.map +1 -1
- package/lib/module/controllers/SendController.js +7 -7
- package/lib/module/controllers/SendController.js.map +1 -1
- package/lib/module/controllers/SwapController.js +51 -40
- package/lib/module/controllers/SwapController.js.map +1 -1
- package/lib/module/controllers/ThemeController.js +9 -1
- package/lib/module/controllers/ThemeController.js.map +1 -1
- package/lib/module/controllers/TransactionsController.js +3 -3
- package/lib/module/controllers/TransactionsController.js.map +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/AssetUtil.js +5 -6
- package/lib/module/utils/AssetUtil.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +537 -8
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/CoreHelperUtil.js +3 -3
- package/lib/module/utils/CoreHelperUtil.js.map +1 -1
- package/lib/module/utils/StorageUtil.js +67 -33
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/module/utils/SwapApiUtil.js +19 -10
- package/lib/module/utils/SwapApiUtil.js.map +1 -1
- package/lib/typescript/controllers/AccountController.d.ts +2 -2
- package/lib/typescript/controllers/AccountController.d.ts.map +1 -1
- package/lib/typescript/controllers/ApiController.d.ts +1 -1
- package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/BlockchainApiController.d.ts +15 -3
- package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionController.d.ts +2 -2
- package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionsController.d.ts +44 -0
- package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -0
- package/lib/typescript/controllers/ConnectorController.d.ts.map +1 -1
- package/lib/typescript/controllers/ModalController.d.ts +1 -1
- package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
- package/lib/typescript/controllers/NetworkController.d.ts +1 -1
- package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
- package/lib/typescript/controllers/OnRampController.d.ts +1 -3
- package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
- package/lib/typescript/controllers/OptionsController.d.ts +5 -2
- package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/PublicStateController.d.ts +1 -1
- package/lib/typescript/controllers/PublicStateController.d.ts.map +1 -1
- package/lib/typescript/controllers/RouterController.d.ts +4 -2
- package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
- package/lib/typescript/controllers/SwapController.d.ts +1 -1
- package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
- package/lib/typescript/controllers/ThemeController.d.ts +1 -1
- package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/AssetUtil.d.ts +2 -2
- package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts +421 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/CoreHelperUtil.d.ts +3 -3
- package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
- package/lib/typescript/utils/FetchUtil.d.ts +1 -1
- package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
- package/lib/typescript/utils/NetworkUtil.d.ts +1 -1
- package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -1
- package/lib/typescript/utils/StorageUtil.d.ts +14 -4
- package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
- package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TypeUtil.d.ts +8 -40
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/controllers/AccountController.ts +2 -2
- package/src/controllers/ApiController.ts +12 -7
- package/src/controllers/BlockchainApiController.ts +135 -27
- package/src/controllers/ConnectionController.ts +10 -8
- package/src/controllers/ConnectionsController.ts +309 -0
- package/src/controllers/ConnectorController.ts +1 -0
- package/src/controllers/EnsController.ts +2 -2
- package/src/controllers/EventsController.ts +1 -1
- package/src/controllers/ModalController.ts +2 -1
- package/src/controllers/NetworkController.ts +1 -1
- package/src/controllers/OnRampController.ts +32 -91
- package/src/controllers/OptionsController.ts +14 -13
- package/src/controllers/PublicStateController.ts +1 -1
- package/src/controllers/RouterController.ts +3 -3
- package/src/controllers/SendController.ts +7 -7
- package/src/controllers/SwapController.ts +58 -48
- package/src/controllers/ThemeController.ts +11 -2
- package/src/controllers/TransactionsController.ts +3 -3
- package/src/index.ts +5 -2
- package/src/utils/AssetUtil.ts +5 -7
- package/src/utils/ConstantsUtil.ts +542 -8
- package/src/utils/CoreHelperUtil.ts +14 -6
- package/src/utils/FetchUtil.ts +1 -1
- package/src/utils/NetworkUtil.ts +1 -1
- package/src/utils/StorageUtil.ts +82 -39
- package/src/utils/SwapApiUtil.ts +22 -10
- package/src/utils/TypeUtil.ts +13 -48
- package/lib/commonjs/controllers/WebviewController.js +0 -52
- package/lib/commonjs/controllers/WebviewController.js.map +0 -1
- package/lib/commonjs/utils/ConnectionUtil.js +0 -33
- package/lib/commonjs/utils/ConnectionUtil.js.map +0 -1
- package/lib/module/controllers/WebviewController.js +0 -47
- package/lib/module/controllers/WebviewController.js.map +0 -1
- package/lib/module/utils/ConnectionUtil.js +0 -27
- package/lib/module/utils/ConnectionUtil.js.map +0 -1
- package/lib/typescript/controllers/WebviewController.d.ts +0 -21
- package/lib/typescript/controllers/WebviewController.d.ts.map +0 -1
- package/lib/typescript/utils/ConnectionUtil.d.ts +0 -4
- package/lib/typescript/utils/ConnectionUtil.d.ts.map +0 -1
- package/src/controllers/WebviewController.ts +0 -63
- package/src/utils/ConnectionUtil.ts +0 -27
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ConnectionsController = void 0;
|
|
7
|
+
var _valtio = require("valtio");
|
|
8
|
+
var _utils = require("valtio/utils");
|
|
9
|
+
var _appkitCommonReactNative = require("@reown/appkit-common-react-native");
|
|
10
|
+
var _StorageUtil = require("../utils/StorageUtil");
|
|
11
|
+
// -- Types --------------------------------------------- //
|
|
12
|
+
|
|
13
|
+
//TODO: balance could be elsewhere
|
|
14
|
+
|
|
15
|
+
// -- State --------------------------------------------- //
|
|
16
|
+
const baseState = (0, _valtio.proxy)({
|
|
17
|
+
activeNamespace: undefined,
|
|
18
|
+
connections: new Map(),
|
|
19
|
+
networks: []
|
|
20
|
+
});
|
|
21
|
+
const derivedState = (0, _utils.derive)({
|
|
22
|
+
activeAddress: get => {
|
|
23
|
+
const snap = get(baseState);
|
|
24
|
+
if (!snap.activeNamespace) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const connection = snap.connections.get(snap.activeNamespace);
|
|
28
|
+
if (!connection || !connection.accounts || connection.accounts.length === 0) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//TODO: what happens if there are several accounts on the same chain?
|
|
33
|
+
const activeAccount = connection.accounts.find(account => account.startsWith(connection.caipNetwork));
|
|
34
|
+
return activeAccount;
|
|
35
|
+
},
|
|
36
|
+
activeBalance: get => {
|
|
37
|
+
const snap = get(baseState);
|
|
38
|
+
if (!snap.activeNamespace) return undefined;
|
|
39
|
+
const connection = snap.connections.get(snap.activeNamespace);
|
|
40
|
+
if (!connection || !connection.accounts || connection.accounts.length === 0) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const activeAccount = connection.accounts.find(account => account.startsWith(connection.caipNetwork));
|
|
44
|
+
if (!connection || !connection.balances || !activeAccount || Object.keys(connection.balances).length === 0) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return connection.balances[activeAccount];
|
|
48
|
+
},
|
|
49
|
+
activeNetwork: get => {
|
|
50
|
+
const snap = get(baseState);
|
|
51
|
+
if (!snap.activeNamespace) return undefined;
|
|
52
|
+
const connection = snap.connections.get(snap.activeNamespace);
|
|
53
|
+
if (!connection) return undefined;
|
|
54
|
+
return snap.networks.find(network => network.chainNamespace === snap.activeNamespace && network.id?.toString() === connection.caipNetwork?.split(':')[1]);
|
|
55
|
+
},
|
|
56
|
+
activeCaipNetworkId: get => {
|
|
57
|
+
const snap = get(baseState);
|
|
58
|
+
if (!snap.activeNamespace) return undefined;
|
|
59
|
+
const connection = snap.connections.get(snap.activeNamespace);
|
|
60
|
+
if (!connection) return undefined;
|
|
61
|
+
return connection.caipNetwork;
|
|
62
|
+
},
|
|
63
|
+
walletInfo: get => {
|
|
64
|
+
const snap = get(baseState);
|
|
65
|
+
if (!snap.activeNamespace) return undefined;
|
|
66
|
+
return snap.connections.get(snap.activeNamespace)?.wallet;
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
proxy: baseState // Link derived proxy to the base state proxy
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// -- Controller ---------------------------------------- //
|
|
73
|
+
const ConnectionsController = exports.ConnectionsController = {
|
|
74
|
+
state: derivedState,
|
|
75
|
+
setActiveNamespace(namespace) {
|
|
76
|
+
baseState.activeNamespace = namespace;
|
|
77
|
+
_StorageUtil.StorageUtil.setActiveNamespace(namespace);
|
|
78
|
+
},
|
|
79
|
+
storeConnection({
|
|
80
|
+
namespace,
|
|
81
|
+
adapter,
|
|
82
|
+
accounts,
|
|
83
|
+
chains,
|
|
84
|
+
wallet,
|
|
85
|
+
caipNetwork
|
|
86
|
+
}) {
|
|
87
|
+
const newConnectionEntry = {
|
|
88
|
+
balances: {},
|
|
89
|
+
caipNetwork: caipNetwork ?? chains[0],
|
|
90
|
+
adapter: (0, _valtio.ref)(adapter),
|
|
91
|
+
accounts,
|
|
92
|
+
chains,
|
|
93
|
+
wallet
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Create a new Map to ensure Valtio detects the change
|
|
97
|
+
const newConnectionsMap = new Map(baseState.connections);
|
|
98
|
+
newConnectionsMap.set(namespace, newConnectionEntry);
|
|
99
|
+
baseState.connections = newConnectionsMap;
|
|
100
|
+
},
|
|
101
|
+
updateAccounts(namespace, accounts) {
|
|
102
|
+
const connection = baseState.connections.get(namespace);
|
|
103
|
+
if (!connection) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const newConnectionsMap = new Map(baseState.connections);
|
|
107
|
+
const updatedConnection = {
|
|
108
|
+
...connection,
|
|
109
|
+
accounts
|
|
110
|
+
};
|
|
111
|
+
newConnectionsMap.set(namespace, updatedConnection);
|
|
112
|
+
baseState.connections = newConnectionsMap;
|
|
113
|
+
},
|
|
114
|
+
updateBalance(namespace, address, balance) {
|
|
115
|
+
const connection = baseState.connections.get(namespace);
|
|
116
|
+
if (!connection) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const newBalances = {
|
|
120
|
+
...connection.balances,
|
|
121
|
+
[address]: balance
|
|
122
|
+
};
|
|
123
|
+
const updatedConnection = {
|
|
124
|
+
...connection,
|
|
125
|
+
balances: newBalances
|
|
126
|
+
};
|
|
127
|
+
const newConnectionsMap = new Map(baseState.connections);
|
|
128
|
+
newConnectionsMap.set(namespace, updatedConnection);
|
|
129
|
+
baseState.connections = newConnectionsMap;
|
|
130
|
+
},
|
|
131
|
+
setActiveNetwork(namespace, networkId) {
|
|
132
|
+
const connection = baseState.connections.get(namespace);
|
|
133
|
+
if (!connection) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
baseState.connections.set(namespace, {
|
|
137
|
+
...connection,
|
|
138
|
+
caipNetwork: networkId
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
setNetworks(networks) {
|
|
142
|
+
baseState.networks = networks;
|
|
143
|
+
},
|
|
144
|
+
getConnectedNetworks() {
|
|
145
|
+
return baseState.networks.filter(network => baseState.connections.get(network.chainNamespace)?.accounts.some(account => account.startsWith(network.caipNetworkId)));
|
|
146
|
+
},
|
|
147
|
+
async disconnect(namespace, isInternal = true) {
|
|
148
|
+
const connection = baseState.connections.get(namespace);
|
|
149
|
+
if (!connection) return;
|
|
150
|
+
|
|
151
|
+
// Get the current connector from the adapter
|
|
152
|
+
const connector = connection.adapter.connector;
|
|
153
|
+
if (!connector) return;
|
|
154
|
+
|
|
155
|
+
// Find all namespaces that use the same connector
|
|
156
|
+
const namespacesUsingConnector = Array.from(baseState.connections.keys()).filter(ns => baseState.connections.get(ns)?.adapter.connector === connector);
|
|
157
|
+
|
|
158
|
+
// Unsubscribe all event listeners from the adapter
|
|
159
|
+
namespacesUsingConnector.forEach(ns => {
|
|
160
|
+
const _connection = baseState.connections.get(ns);
|
|
161
|
+
if (_connection?.adapter) {
|
|
162
|
+
_connection.adapter.removeAllListeners();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Disconnect the adapter
|
|
167
|
+
if (isInternal) {
|
|
168
|
+
await connection.adapter.disconnect();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Remove all namespaces that used this connector
|
|
172
|
+
const newConnectionsMap = new Map(baseState.connections);
|
|
173
|
+
namespacesUsingConnector.forEach(ns => {
|
|
174
|
+
newConnectionsMap.delete(ns);
|
|
175
|
+
});
|
|
176
|
+
baseState.connections = newConnectionsMap;
|
|
177
|
+
|
|
178
|
+
// Remove activeNamespace if it is in the list of namespaces using the connector
|
|
179
|
+
if (baseState.activeNamespace && (baseState.activeNamespace === namespace || namespacesUsingConnector.includes(baseState.activeNamespace))) {
|
|
180
|
+
baseState.activeNamespace = undefined;
|
|
181
|
+
_StorageUtil.StorageUtil.setActiveNamespace(undefined);
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
parseUnits(value, decimals) {
|
|
185
|
+
if (!baseState.activeNamespace) return undefined;
|
|
186
|
+
return baseState.connections.get(baseState.activeNamespace)?.adapter.parseUnits(value, decimals);
|
|
187
|
+
},
|
|
188
|
+
async signMessage(address, message) {
|
|
189
|
+
if (!baseState.activeNamespace) return undefined;
|
|
190
|
+
const [namespace, chainId, plainAddress] = address.split(':');
|
|
191
|
+
if (!namespace || namespace !== baseState.activeNamespace || !chainId || !plainAddress) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
const adapter = baseState.connections.get(baseState.activeNamespace)?.adapter;
|
|
195
|
+
if (adapter instanceof _appkitCommonReactNative.EVMAdapter && plainAddress && chainId) {
|
|
196
|
+
return adapter.signMessage(plainAddress, message, chainId);
|
|
197
|
+
}
|
|
198
|
+
return undefined;
|
|
199
|
+
},
|
|
200
|
+
async sendTransaction(args) {
|
|
201
|
+
if (!baseState.activeNamespace) return undefined;
|
|
202
|
+
const adapter = baseState.connections.get(baseState.activeNamespace)?.adapter;
|
|
203
|
+
if (adapter instanceof _appkitCommonReactNative.EVMAdapter) {
|
|
204
|
+
return adapter.sendTransaction(args);
|
|
205
|
+
}
|
|
206
|
+
return undefined;
|
|
207
|
+
},
|
|
208
|
+
async estimateGas(args) {
|
|
209
|
+
if (!baseState.activeNamespace || baseState.activeNamespace !== 'eip155') return undefined;
|
|
210
|
+
const adapter = baseState.connections.get(baseState.activeNamespace)?.adapter;
|
|
211
|
+
if (adapter instanceof _appkitCommonReactNative.EVMAdapter) {
|
|
212
|
+
return adapter.estimateGas(args);
|
|
213
|
+
}
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
//# sourceMappingURL=ConnectionsController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_valtio","require","_utils","_appkitCommonReactNative","_StorageUtil","baseState","proxy","activeNamespace","undefined","connections","Map","networks","derivedState","derive","activeAddress","get","snap","connection","accounts","length","activeAccount","find","account","startsWith","caipNetwork","activeBalance","balances","Object","keys","activeNetwork","network","chainNamespace","id","toString","split","activeCaipNetworkId","walletInfo","wallet","ConnectionsController","exports","state","setActiveNamespace","namespace","StorageUtil","storeConnection","adapter","chains","newConnectionEntry","ref","newConnectionsMap","set","updateAccounts","updatedConnection","updateBalance","address","balance","newBalances","setActiveNetwork","networkId","setNetworks","getConnectedNetworks","filter","some","caipNetworkId","disconnect","isInternal","connector","namespacesUsingConnector","Array","from","ns","forEach","_connection","removeAllListeners","delete","includes","parseUnits","value","decimals","signMessage","message","chainId","plainAddress","EVMAdapter","sendTransaction","args","estimateGas"],"sourceRoot":"../../../src","sources":["controllers/ConnectionsController.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA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EAAEC,OAAO,CAAC;IAC5D;IAEA,OAAOzE,SAAS;EAClB,CAAC;EAED,MAAM4E,eAAeA,CAACC,IAAS,EAAE;IAC/B,IAAI,CAAChF,SAAS,CAACE,eAAe,EAAE,OAAOC,SAAS;IAEhD,MAAMqC,OAAO,GAAGxC,SAAS,CAACI,WAAW,CAACM,GAAG,CAACV,SAAS,CAACE,eAAe,CAAC,EAAEsC,OAAO;IAE7E,IAAIA,OAAO,YAAYsC,mCAAU,EAAE;MACjC,OAAOtC,OAAO,CAACuC,eAAe,CAACC,IAAI,CAAC;IACtC;IAEA,OAAO7E,SAAS;EAClB,CAAC;EAED,MAAM8E,WAAWA,CAACD,IAAS,EAAE;IAC3B,IAAI,CAAChF,SAAS,CAACE,eAAe,IAAIF,SAAS,CAACE,eAAe,KAAK,QAAQ,EAAE,OAAOC,SAAS;IAE1F,MAAMqC,OAAO,GAAGxC,SAAS,CAACI,WAAW,CAACM,GAAG,CAACV,SAAS,CAACE,eAAe,CAAC,EAAEsC,OAAO;IAE7E,IAAIA,OAAO,YAAYsC,mCAAU,EAAE;MACjC,OAAOtC,OAAO,CAACyC,WAAW,CAACD,IAAI,CAAC;IAClC;IAEA,OAAO7E,SAAS;EAClB;AACF,CAAC"}
|
|
@@ -36,6 +36,7 @@ const ConnectorController = exports.ConnectorController = {
|
|
|
36
36
|
state.connectedConnector = connectorType;
|
|
37
37
|
if (saveStorage) {
|
|
38
38
|
if (connectorType) {
|
|
39
|
+
//TODO: Check this
|
|
39
40
|
_StorageUtil.StorageUtil.setConnectedConnector(connectorType);
|
|
40
41
|
} else {
|
|
41
42
|
_StorageUtil.StorageUtil.removeConnectedConnector();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_utils","require","_valtio","_StorageUtil","state","proxy","connectors","ConnectorController","exports","subscribeKey","key","callback","subKey","setConnectors","map","c","ref","addConnector","connector","getConnectors","getAuthConnector","find","type","setConnectedConnector","connectorType","saveStorage","connectedConnector","StorageUtil","removeConnectedConnector","setAuthLoading","loading","authLoading"],"sourceRoot":"../../../src","sources":["controllers/ConnectorController.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAF,OAAA;AAEA;;AASA;AACA,MAAMG,KAAK,GAAG,IAAAC,aAAK,EAA2B;EAC5CC,UAAU,EAAE;AACd,CAAC,CAAC;;AAEF;AACO,MAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG;EACjCH,KAAK;EAELK,YAAYA,CAAqBC,GAAM,EAAEC,QAAsD,EAAE;IAC/F,OAAO,IAAAC,mBAAM,EAACR,KAAK,EAAEM,GAAG,EAAEC,QAAQ,CAAC;EACrC,CAAC;EAEDE,aAAaA,CAACP,UAAkD,EAAE;IAChEF,KAAK,CAACE,UAAU,GAAGA,UAAU,CAACQ,GAAG,CAACC,CAAC,IAAI,IAAAC,WAAG,EAACD,CAAC,CAAC,CAAC;EAChD,CAAC;EAEDE,YAAYA,CAACC,SAAoB,EAAE;IACjCd,KAAK,CAACE,UAAU,GAAG,CAAC,GAAGF,KAAK,CAACE,UAAU,EAAE,IAAAU,WAAG,EAACE,SAAS,CAAC,CAAC;EAC1D,CAAC;EAEDC,aAAaA,CAAA,EAAG;IACd,OAAOf,KAAK,CAACE,UAAU;EACzB,CAAC;EAEDc,gBAAgBA,CAAA,EAAG;IACjB,OAAOhB,KAAK,CAACE,UAAU,CAACe,IAAI,CAACN,CAAC,IAAIA,CAAC,CAACO,IAAI,KAAK,MAAM,CAAC;EACtD,CAAC;EAEDC,qBAAqBA,CACnBC,aAA6D,EAC7DC,WAAW,GAAG,IAAI,EAClB;IACArB,KAAK,CAACsB,kBAAkB,GAAGF,aAAa;IAExC,IAAIC,WAAW,EAAE;MACf,IAAID,aAAa,EAAE;
|
|
1
|
+
{"version":3,"names":["_utils","require","_valtio","_StorageUtil","state","proxy","connectors","ConnectorController","exports","subscribeKey","key","callback","subKey","setConnectors","map","c","ref","addConnector","connector","getConnectors","getAuthConnector","find","type","setConnectedConnector","connectorType","saveStorage","connectedConnector","StorageUtil","removeConnectedConnector","setAuthLoading","loading","authLoading"],"sourceRoot":"../../../src","sources":["controllers/ConnectorController.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAF,OAAA;AAEA;;AASA;AACA,MAAMG,KAAK,GAAG,IAAAC,aAAK,EAA2B;EAC5CC,UAAU,EAAE;AACd,CAAC,CAAC;;AAEF;AACO,MAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG;EACjCH,KAAK;EAELK,YAAYA,CAAqBC,GAAM,EAAEC,QAAsD,EAAE;IAC/F,OAAO,IAAAC,mBAAM,EAACR,KAAK,EAAEM,GAAG,EAAEC,QAAQ,CAAC;EACrC,CAAC;EAEDE,aAAaA,CAACP,UAAkD,EAAE;IAChEF,KAAK,CAACE,UAAU,GAAGA,UAAU,CAACQ,GAAG,CAACC,CAAC,IAAI,IAAAC,WAAG,EAACD,CAAC,CAAC,CAAC;EAChD,CAAC;EAEDE,YAAYA,CAACC,SAAoB,EAAE;IACjCd,KAAK,CAACE,UAAU,GAAG,CAAC,GAAGF,KAAK,CAACE,UAAU,EAAE,IAAAU,WAAG,EAACE,SAAS,CAAC,CAAC;EAC1D,CAAC;EAEDC,aAAaA,CAAA,EAAG;IACd,OAAOf,KAAK,CAACE,UAAU;EACzB,CAAC;EAEDc,gBAAgBA,CAAA,EAAG;IACjB,OAAOhB,KAAK,CAACE,UAAU,CAACe,IAAI,CAACN,CAAC,IAAIA,CAAC,CAACO,IAAI,KAAK,MAAM,CAAC;EACtD,CAAC;EAEDC,qBAAqBA,CACnBC,aAA6D,EAC7DC,WAAW,GAAG,IAAI,EAClB;IACArB,KAAK,CAACsB,kBAAkB,GAAGF,aAAa;IAExC,IAAIC,WAAW,EAAE;MACf,IAAID,aAAa,EAAE;QACjB;QACAG,wBAAW,CAACJ,qBAAqB,CAACC,aAAa,CAAC;MAClD,CAAC,MAAM;QACLG,wBAAW,CAACC,wBAAwB,CAAC,CAAC;MACxC;IACF;EACF,CAAC;EAEDC,cAAcA,CAACC,OAAgD,EAAE;IAC/D1B,KAAK,CAAC2B,WAAW,GAAGD,OAAO;EAC7B;AACF,CAAC"}
|
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.EnsController = void 0;
|
|
7
|
-
var _utils = require("valtio/utils");
|
|
8
|
-
var
|
|
7
|
+
var _utils = require("valtio/vanilla/utils");
|
|
8
|
+
var _vanilla = require("valtio/vanilla");
|
|
9
9
|
var _BlockchainApiController = require("./BlockchainApiController");
|
|
10
10
|
// -- Types --------------------------------------------- //
|
|
11
11
|
|
|
12
12
|
// -- State --------------------------------------------- //
|
|
13
|
-
const state = (0,
|
|
13
|
+
const state = (0, _vanilla.proxy)({
|
|
14
14
|
loading: false
|
|
15
15
|
});
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ const state = (0, _valtio.proxy)({
|
|
|
18
18
|
const EnsController = exports.EnsController = {
|
|
19
19
|
state,
|
|
20
20
|
subscribe(callback) {
|
|
21
|
-
return (0,
|
|
21
|
+
return (0, _vanilla.subscribe)(state, () => callback(state));
|
|
22
22
|
},
|
|
23
23
|
subscribeKey(key, callback) {
|
|
24
24
|
return (0, _utils.subscribeKey)(state, key, callback);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_utils","require","
|
|
1
|
+
{"version":3,"names":["_utils","require","_vanilla","_BlockchainApiController","state","proxy","loading","EnsController","exports","subscribe","callback","sub","subscribeKey","key","subKey","resolveName","name","BlockchainApiController","lookupEnsName","e","error","Error","reasons","description"],"sourceRoot":"../../../src","sources":["controllers/EnsController.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAGA;;AAQA;AACA,MAAMG,KAAK,GAAG,IAAAC,cAAK,EAAqB;EACtCC,OAAO,EAAE;AACX,CAAC,CAAC;;AAEF;AACO,MAAMC,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG;EAC3BH,KAAK;EAELK,SAASA,CAACC,QAAgD,EAAE;IAC1D,OAAO,IAAAC,kBAAG,EAACP,KAAK,EAAE,MAAMM,QAAQ,CAACN,KAAK,CAAC,CAAC;EAC1C,CAAC;EAEDQ,YAAYA,CAAqBC,GAAM,EAAEH,QAAgD,EAAE;IACzF,OAAO,IAAAI,mBAAM,EAACV,KAAK,EAAES,GAAG,EAAEH,QAAQ,CAAC;EACrC,CAAC;EAED,MAAMK,WAAWA,CAACC,IAAY,EAAE;IAC9B,IAAI;MACF,OAAO,MAAMC,gDAAuB,CAACC,aAAa,CAACF,IAAI,CAAC;IAC1D,CAAC,CAAC,OAAOG,CAAC,EAAE;MACV,MAAMC,KAAK,GAAGD,CAA0B;MACxC,MAAM,IAAIE,KAAK,CAACD,KAAK,EAAEE,OAAO,GAAG,CAAC,CAAC,EAAEC,WAAW,IAAI,sBAAsB,CAAC;IAC7E;EACF;AACF,CAAC"}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.EventsController = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _vanilla = require("valtio/vanilla");
|
|
8
8
|
var _ApiController = require("./ApiController");
|
|
9
9
|
var _OptionsController = require("./OptionsController");
|
|
10
10
|
var _CoreHelperUtil = require("../utils/CoreHelperUtil");
|
|
@@ -19,7 +19,7 @@ const excluded = ['MODAL_CREATED'];
|
|
|
19
19
|
// -- Types --------------------------------------------- //
|
|
20
20
|
|
|
21
21
|
// -- State --------------------------------------------- //
|
|
22
|
-
const state = (0,
|
|
22
|
+
const state = (0, _vanilla.proxy)({
|
|
23
23
|
timestamp: Date.now(),
|
|
24
24
|
data: {
|
|
25
25
|
type: 'track',
|
|
@@ -31,10 +31,10 @@ const state = (0, _valtio.proxy)({
|
|
|
31
31
|
const EventsController = exports.EventsController = {
|
|
32
32
|
state,
|
|
33
33
|
subscribe(callback) {
|
|
34
|
-
return (0,
|
|
34
|
+
return (0, _vanilla.subscribe)(state, () => callback(state));
|
|
35
35
|
},
|
|
36
36
|
subscribeEvent(event, callback) {
|
|
37
|
-
return (0,
|
|
37
|
+
return (0, _vanilla.subscribe)(state, () => {
|
|
38
38
|
if (state.data.event === event) {
|
|
39
39
|
callback(state);
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_vanilla","require","_ApiController","_OptionsController","_CoreHelperUtil","_FetchUtil","baseUrl","CoreHelperUtil","getAnalyticsUrl","api","FetchUtil","excluded","state","proxy","timestamp","Date","now","data","type","event","EventsController","exports","subscribe","callback","sub","subscribeEvent","_sendAnalyticsEvent","includes","post","path","headers","ApiController","_getApiHeaders","body","eventId","getUUID","bundleId","getBundleId","props","sendEvent","prefetchPromise","OptionsController","enableAnalytics"],"sourceRoot":"../../../src","sources":["controllers/EventsController.ts"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAGA;AACA,MAAMK,OAAO,GAAGC,8BAAc,CAACC,eAAe,CAAC,CAAC;AAChD,MAAMC,GAAG,GAAG,IAAIC,oBAAS,CAAC;EAAEJ;AAAQ,CAAC,CAAC;AACtC,MAAMK,QAAQ,GAAG,CAAC,eAAe,CAAC;;AAElC;;AAMA;AACA,MAAMC,KAAK,GAAG,IAAAC,cAAK,EAAwB;EACzCC,SAAS,EAAEC,IAAI,CAACC,GA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c,4BAAa,CAACnB,KAAK,CAAC4B,eAAe;IAEzC,IAAIC,oCAAiB,CAAC7B,KAAK,CAAC8B,eAAe,EAAE;MAC3CtB,gBAAgB,CAACM,mBAAmB,CAACT,IAAI,EAAEH,SAAS,CAAC;IACvD;EACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_valtio","require","_AccountController","_RouterController","_PublicStateController","_EventsController","_ApiController","_ConnectorController","state","proxy","open","loading","ModalController","exports","options","ApiController","prefetchPromise","connected","AccountController","isConnected","view","RouterController","reset","isUniversalWallet","ConnectorController","connectedConnector","PublicStateController","set","EventsController","sendEvent","type","event","properties","close","setLoading"],"sourceRoot":"../../../src","sources":["controllers/ModalController.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;
|
|
1
|
+
{"version":3,"names":["_valtio","require","_AccountController","_RouterController","_PublicStateController","_EventsController","_ApiController","_ConnectorController","state","proxy","open","loading","ModalController","exports","options","ApiController","prefetchPromise","connected","AccountController","isConnected","view","RouterController","reset","isUniversalWallet","ConnectorController","connectedConnector","PublicStateController","set","EventsController","sendEvent","type","event","properties","close","setLoading"],"sourceRoot":"../../../src","sources":["controllers/ModalController.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AAEA;;AAYA;AACA,MAAMO,KAAK,GAAG,IAAAC,aAAK,EAAuB;EACxCC,IAAI,EAAE,KAAK;EACXC,OAAO,EAAE;AACX,CAAC,CAAC;;AAEF;AACO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG;EAC7BJ,KAAK;EA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-25,23 +25,23 @@ const mapErrorMessage = errorCode => {
|
|
|
25
25
|
const errorMap = {
|
|
26
26
|
[_ConstantsUtil.OnRampErrorType.AMOUNT_TOO_LOW]: {
|
|
27
27
|
type: _ConstantsUtil.OnRampErrorType.AMOUNT_TOO_LOW,
|
|
28
|
-
message: '
|
|
28
|
+
message: 'Amount is too low'
|
|
29
29
|
},
|
|
30
30
|
[_ConstantsUtil.OnRampErrorType.AMOUNT_TOO_HIGH]: {
|
|
31
31
|
type: _ConstantsUtil.OnRampErrorType.AMOUNT_TOO_HIGH,
|
|
32
|
-
message: '
|
|
32
|
+
message: 'Amount is too high'
|
|
33
33
|
},
|
|
34
34
|
[_ConstantsUtil.OnRampErrorType.INVALID_AMOUNT]: {
|
|
35
35
|
type: _ConstantsUtil.OnRampErrorType.INVALID_AMOUNT,
|
|
36
|
-
message: '
|
|
36
|
+
message: 'Please adjust amount'
|
|
37
37
|
},
|
|
38
38
|
[_ConstantsUtil.OnRampErrorType.INCOMPATIBLE_REQUEST]: {
|
|
39
39
|
type: _ConstantsUtil.OnRampErrorType.INCOMPATIBLE_REQUEST,
|
|
40
|
-
message: '
|
|
40
|
+
message: 'Try different amount or payment method'
|
|
41
41
|
},
|
|
42
42
|
[_ConstantsUtil.OnRampErrorType.BAD_REQUEST]: {
|
|
43
43
|
type: _ConstantsUtil.OnRampErrorType.BAD_REQUEST,
|
|
44
|
-
message: '
|
|
44
|
+
message: 'Try different amount or payment method'
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
return errorMap[errorCode] || {
|
|
@@ -76,19 +76,19 @@ const OnRampController = exports.OnRampController = {
|
|
|
76
76
|
state.selectedCountry = country;
|
|
77
77
|
state.loading = true;
|
|
78
78
|
if (updateCurrency) {
|
|
79
|
-
const currencyCode =
|
|
79
|
+
const currencyCode = _ConstantsUtil.ConstantsUtil.COUNTRY_CURRENCIES[country.countryCode] || 'USD';
|
|
80
80
|
const currency = state.paymentCurrencies?.find(c => c.currencyCode === currencyCode);
|
|
81
81
|
if (currency) {
|
|
82
82
|
this.setPaymentCurrency(currency);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
await Promise.all([this.fetchPaymentMethods(), this.fetchCryptoCurrencies()]);
|
|
86
|
-
this.clearQuotes();
|
|
87
86
|
state.loading = false;
|
|
88
87
|
_StorageUtil.StorageUtil.setOnRampPreferredCountry(country);
|
|
89
88
|
},
|
|
90
89
|
setSelectedPaymentMethod(paymentMethod) {
|
|
91
90
|
state.selectedPaymentMethod = paymentMethod;
|
|
91
|
+
this.clearQuotes();
|
|
92
92
|
},
|
|
93
93
|
setPurchaseCurrency(currency) {
|
|
94
94
|
state.purchaseCurrency = currency;
|
|
@@ -122,7 +122,7 @@ const OnRampController = exports.OnRampController = {
|
|
|
122
122
|
const defaultCurrency = _ConstantsUtil.ConstantsUtil.NETWORK_DEFAULT_CURRENCIES[_NetworkController.NetworkController.state.caipNetwork?.id];
|
|
123
123
|
selectedCurrency = state.purchaseCurrencies?.find(c => c.currencyCode === defaultCurrency);
|
|
124
124
|
}
|
|
125
|
-
state.purchaseCurrency = selectedCurrency
|
|
125
|
+
state.purchaseCurrency = selectedCurrency || state.purchaseCurrencies?.[0] || undefined;
|
|
126
126
|
},
|
|
127
127
|
getServiceProviderImage(serviceProviderName) {
|
|
128
128
|
if (!serviceProviderName) return undefined;
|
|
@@ -156,23 +156,6 @@ const OnRampController = exports.OnRampController = {
|
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
},
|
|
159
|
-
async fetchCountriesDefaults() {
|
|
160
|
-
try {
|
|
161
|
-
let countriesDefaults = await _StorageUtil.StorageUtil.getOnRampCountriesDefaults();
|
|
162
|
-
if (!countriesDefaults.length) {
|
|
163
|
-
countriesDefaults = (await _BlockchainApiController.BlockchainApiController.fetchOnRampCountriesDefaults()) ?? [];
|
|
164
|
-
if (countriesDefaults.length) {
|
|
165
|
-
_StorageUtil.StorageUtil.setOnRampCountriesDefaults(countriesDefaults);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
state.countriesDefaults = countriesDefaults;
|
|
169
|
-
} catch (error) {
|
|
170
|
-
state.error = {
|
|
171
|
-
type: _ConstantsUtil.OnRampErrorType.FAILED_TO_LOAD_COUNTRIES,
|
|
172
|
-
message: 'Failed to load countries defaults'
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
159
|
async fetchServiceProviders() {
|
|
177
160
|
try {
|
|
178
161
|
let serviceProviders = await _StorageUtil.StorageUtil.getOnRampServiceProviders();
|
|
@@ -195,7 +178,7 @@ const OnRampController = exports.OnRampController = {
|
|
|
195
178
|
const paymentMethods = await _BlockchainApiController.BlockchainApiController.fetchOnRampPaymentMethods({
|
|
196
179
|
countries: state.selectedCountry?.countryCode
|
|
197
180
|
});
|
|
198
|
-
const defaultCountryPaymentMethods =
|
|
181
|
+
const defaultCountryPaymentMethods = _ConstantsUtil.ConstantsUtil.COUNTRY_DEFAULT_PAYMENT_METHOD[state.selectedCountry?.countryCode];
|
|
199
182
|
state.paymentMethods = paymentMethods?.sort((a, b) => {
|
|
200
183
|
const aIndex = defaultCountryPaymentMethods?.indexOf(a.paymentMethod);
|
|
201
184
|
const bIndex = defaultCountryPaymentMethods?.indexOf(b.paymentMethod);
|
|
@@ -204,7 +187,8 @@ const OnRampController = exports.OnRampController = {
|
|
|
204
187
|
if (bIndex === -1) return -1;
|
|
205
188
|
return aIndex - bIndex;
|
|
206
189
|
}) || [];
|
|
207
|
-
state.selectedPaymentMethod =
|
|
190
|
+
state.selectedPaymentMethod = paymentMethods?.[0] || undefined;
|
|
191
|
+
this.clearQuotes();
|
|
208
192
|
} catch (error) {
|
|
209
193
|
state.error = {
|
|
210
194
|
type: _ConstantsUtil.OnRampErrorType.FAILED_TO_LOAD_METHODS,
|
|
@@ -248,7 +232,7 @@ const OnRampController = exports.OnRampController = {
|
|
|
248
232
|
}
|
|
249
233
|
state.paymentCurrencies = fiatCurrencies || [];
|
|
250
234
|
if (countryCode) {
|
|
251
|
-
currencyCode =
|
|
235
|
+
currencyCode = _ConstantsUtil.ConstantsUtil.COUNTRY_CURRENCIES[countryCode];
|
|
252
236
|
}
|
|
253
237
|
const preferredCurrency = await _StorageUtil.StorageUtil.getOnRampPreferredFiatCurrency();
|
|
254
238
|
const defaultCurrency = preferredCurrency || fiatCurrencies?.find(c => c.currencyCode === currencyCode) || fiatCurrencies?.[0] || undefined;
|
|
@@ -284,47 +268,26 @@ const OnRampController = exports.OnRampController = {
|
|
|
284
268
|
return;
|
|
285
269
|
}
|
|
286
270
|
state.quotesLoading = true;
|
|
287
|
-
state.selectedQuote = undefined;
|
|
288
|
-
state.selectedServiceProvider = undefined;
|
|
289
271
|
state.error = undefined;
|
|
290
272
|
this.abortGetQuotes(false);
|
|
291
273
|
quotesAbortController = new AbortController();
|
|
292
|
-
const currentSignal = quotesAbortController.signal;
|
|
293
274
|
try {
|
|
294
275
|
const body = {
|
|
295
276
|
countryCode: state.selectedCountry?.countryCode,
|
|
277
|
+
paymentMethodType: state.selectedPaymentMethod?.paymentMethod,
|
|
296
278
|
destinationCurrencyCode: state.purchaseCurrency?.currencyCode,
|
|
297
279
|
sourceAmount: state.paymentAmount,
|
|
298
280
|
sourceCurrencyCode: state.paymentCurrency?.currencyCode,
|
|
299
281
|
walletAddress: _AccountController.AccountController.state.address
|
|
300
282
|
};
|
|
301
|
-
const response = await _BlockchainApiController.BlockchainApiController.getOnRampQuotes(body,
|
|
283
|
+
const response = await _BlockchainApiController.BlockchainApiController.getOnRampQuotes(body, quotesAbortController.signal);
|
|
302
284
|
if (!response || !response.length) {
|
|
303
285
|
throw new Error('No quotes available');
|
|
304
286
|
}
|
|
305
287
|
const quotes = response.sort((a, b) => b.customerScore - a.customerScore);
|
|
306
288
|
state.quotes = quotes;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const isValidPaymentMethod = state.selectedPaymentMethod && quotes.some(quote => quote.paymentMethodType === state.selectedPaymentMethod?.paymentMethod);
|
|
310
|
-
if (!isValidPaymentMethod) {
|
|
311
|
-
const countryMethods = state.countriesDefaults?.find(d => d.countryCode === state.selectedCountry?.countryCode)?.defaultPaymentMethods || [];
|
|
312
|
-
const availableQuoteMethods = new Set(quotes.map(q => q.paymentMethodType));
|
|
313
|
-
let newPaymentMethodType;
|
|
314
|
-
for (const dpm of countryMethods) {
|
|
315
|
-
if (availableQuoteMethods.has(dpm)) {
|
|
316
|
-
newPaymentMethodType = dpm;
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if (newPaymentMethodType) {
|
|
321
|
-
state.selectedPaymentMethod = state.paymentMethods.find(m => m.paymentMethod === newPaymentMethodType) || state.paymentMethods.find(method => method.paymentMethod === quotes[0]?.paymentMethodType);
|
|
322
|
-
} else {
|
|
323
|
-
state.selectedPaymentMethod = state.paymentMethods.find(method => method.paymentMethod === quotes[0]?.paymentMethodType);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
state.selectedQuote = quotes.find(quote => quote.paymentMethodType === state.selectedPaymentMethod?.paymentMethod);
|
|
327
|
-
state.selectedServiceProvider = state.serviceProviders.find(sp => sp.serviceProvider === state.selectedQuote?.serviceProvider);
|
|
289
|
+
state.selectedQuote = quotes[0];
|
|
290
|
+
state.selectedServiceProvider = state.serviceProviders.find(sp => sp.serviceProvider === quotes[0]?.serviceProvider);
|
|
328
291
|
} catch (error) {
|
|
329
292
|
if (error.name === 'AbortError') {
|
|
330
293
|
// Do nothing, another request was made
|
|
@@ -340,9 +303,7 @@ const OnRampController = exports.OnRampController = {
|
|
|
340
303
|
this.clearQuotes();
|
|
341
304
|
state.error = mapErrorMessage(error?.code || 'UNKNOWN_ERROR');
|
|
342
305
|
} finally {
|
|
343
|
-
|
|
344
|
-
state.quotesLoading = false;
|
|
345
|
-
}
|
|
306
|
+
state.quotesLoading = false;
|
|
346
307
|
}
|
|
347
308
|
},
|
|
348
309
|
canGenerateQuote() {
|
|
@@ -383,7 +344,7 @@ const OnRampController = exports.OnRampController = {
|
|
|
383
344
|
if (!quote) {
|
|
384
345
|
throw new Error('Invalid quote');
|
|
385
346
|
}
|
|
386
|
-
const
|
|
347
|
+
const widget = await _BlockchainApiController.BlockchainApiController.getOnRampWidget({
|
|
387
348
|
countryCode: quote.countryCode,
|
|
388
349
|
destinationCurrencyCode: quote.destinationCurrencyCode,
|
|
389
350
|
paymentMethodType: quote.paymentMethodType,
|
|
@@ -392,8 +353,7 @@ const OnRampController = exports.OnRampController = {
|
|
|
392
353
|
sourceCurrencyCode: quote.sourceCurrencyCode,
|
|
393
354
|
walletAddress: _AccountController.AccountController.state.address,
|
|
394
355
|
redirectUrl: metadata?.redirect?.universal ?? metadata?.redirect?.native
|
|
395
|
-
};
|
|
396
|
-
const widget = await _BlockchainApiController.BlockchainApiController.getOnRampWidget(body);
|
|
356
|
+
});
|
|
397
357
|
if (!widget || !widget.widgetUrl) {
|
|
398
358
|
throw new Error('Invalid widget response');
|
|
399
359
|
}
|
|
@@ -435,7 +395,7 @@ const OnRampController = exports.OnRampController = {
|
|
|
435
395
|
try {
|
|
436
396
|
await this.fetchCountries();
|
|
437
397
|
await this.fetchServiceProviders();
|
|
438
|
-
await Promise.all([this.
|
|
398
|
+
await Promise.all([this.fetchPaymentMethods(), this.fetchFiatLimits(), this.fetchCryptoCurrencies(), this.fetchFiatCurrencies()]);
|
|
439
399
|
} catch (error) {
|
|
440
400
|
if (!state.error) {
|
|
441
401
|
state.error = {
|