@reown/appkit-core-react-native 0.0.0-feat-multichain-20250731180941 → 0.0.0-feat-multichain-20250801190527
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 +3 -19
- package/lib/commonjs/controllers/ApiController.js.map +1 -1
- package/lib/commonjs/controllers/AssetController.js +0 -4
- package/lib/commonjs/controllers/AssetController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionsController.js +0 -15
- package/lib/commonjs/controllers/ConnectionsController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js +1 -4
- package/lib/commonjs/controllers/OptionsController.js.map +1 -1
- package/lib/commonjs/controllers/RouterController.js.map +1 -1
- package/lib/commonjs/controllers/WcController.js +73 -0
- package/lib/commonjs/controllers/WcController.js.map +1 -0
- package/lib/commonjs/index.js +7 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/AssetUtil.js +7 -4
- package/lib/commonjs/utils/AssetUtil.js.map +1 -1
- package/lib/commonjs/utils/StorageUtil.js +0 -46
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/commonjs/utils/TypeUtil.js +0 -4
- package/lib/commonjs/utils/TypeUtil.js.map +1 -1
- package/lib/module/controllers/ApiController.js +4 -20
- package/lib/module/controllers/ApiController.js.map +1 -1
- package/lib/module/controllers/AssetController.js +0 -4
- package/lib/module/controllers/AssetController.js.map +1 -1
- package/lib/module/controllers/ConnectionsController.js +0 -15
- package/lib/module/controllers/ConnectionsController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js +1 -4
- package/lib/module/controllers/OptionsController.js.map +1 -1
- package/lib/module/controllers/RouterController.js.map +1 -1
- package/lib/module/controllers/WcController.js +70 -0
- package/lib/module/controllers/WcController.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/AssetUtil.js +7 -4
- package/lib/module/utils/AssetUtil.js.map +1 -1
- package/lib/module/utils/StorageUtil.js +0 -46
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/module/utils/TypeUtil.js +0 -4
- package/lib/module/utils/TypeUtil.js.map +1 -1
- package/lib/typescript/controllers/ApiController.d.ts +0 -2
- package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/AssetController.d.ts +0 -2
- package/lib/typescript/controllers/AssetController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/OptionsController.d.ts +1 -3
- package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/RouterController.d.ts +2 -4
- package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
- package/lib/typescript/controllers/WcController.d.ts +28 -0
- package/lib/typescript/controllers/WcController.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/AssetUtil.d.ts +2 -1
- package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
- package/lib/typescript/utils/StorageUtil.d.ts +1 -7
- package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TypeUtil.d.ts +6 -23
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/controllers/ApiController.ts +3 -20
- package/src/controllers/AssetController.ts +0 -6
- package/src/controllers/ConnectionsController.ts +0 -22
- package/src/controllers/OptionsController.ts +2 -7
- package/src/controllers/RouterController.ts +2 -4
- package/src/controllers/WcController.ts +94 -0
- package/src/index.ts +1 -5
- package/src/utils/AssetUtil.ts +9 -4
- package/src/utils/StorageUtil.ts +0 -68
- package/src/utils/TypeUtil.ts +7 -28
- package/lib/commonjs/controllers/ConnectionController.js +0 -123
- package/lib/commonjs/controllers/ConnectionController.js.map +0 -1
- package/lib/module/controllers/ConnectionController.js +0 -120
- package/lib/module/controllers/ConnectionController.js.map +0 -1
- package/lib/typescript/controllers/ConnectionController.d.ts +0 -55
- package/lib/typescript/controllers/ConnectionController.d.ts.map +0 -1
- package/src/controllers/ConnectionController.ts +0 -185
package/src/utils/StorageUtil.ts
CHANGED
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
} from './TypeUtil';
|
|
10
10
|
import {
|
|
11
11
|
DateUtil,
|
|
12
|
-
type SocialProvider,
|
|
13
12
|
type ConnectorType,
|
|
14
13
|
type ChainNamespace,
|
|
15
14
|
type WalletDeepLink,
|
|
@@ -153,73 +152,6 @@ export const StorageUtil = {
|
|
|
153
152
|
}
|
|
154
153
|
},
|
|
155
154
|
|
|
156
|
-
async setConnectedWalletImageUrl(url: string) {
|
|
157
|
-
try {
|
|
158
|
-
await OptionsController.getStorage().setItem(
|
|
159
|
-
ConstantsUtil.STORAGE_KEYS.CONNECTED_WALLET_IMAGE_URL,
|
|
160
|
-
url
|
|
161
|
-
);
|
|
162
|
-
} catch {
|
|
163
|
-
console.info('Unable to set Connected Wallet Image URL');
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
async getConnectedWalletImageUrl() {
|
|
168
|
-
try {
|
|
169
|
-
return await OptionsController.getStorage().getItem(
|
|
170
|
-
ConstantsUtil.STORAGE_KEYS.CONNECTED_WALLET_IMAGE_URL
|
|
171
|
-
);
|
|
172
|
-
} catch {
|
|
173
|
-
console.info('Unable to get Connected Wallet Image URL');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return undefined;
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
async removeConnectedWalletImageUrl() {
|
|
180
|
-
try {
|
|
181
|
-
await OptionsController.getStorage().removeItem(
|
|
182
|
-
ConstantsUtil.STORAGE_KEYS.CONNECTED_WALLET_IMAGE_URL
|
|
183
|
-
);
|
|
184
|
-
} catch (e) {
|
|
185
|
-
console.error(e);
|
|
186
|
-
console.info('Unable to remove Connected Wallet Image URL');
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
async setConnectedSocialProvider(provider: SocialProvider) {
|
|
191
|
-
try {
|
|
192
|
-
await OptionsController.getStorage().setItem(
|
|
193
|
-
ConstantsUtil.STORAGE_KEYS.CONNECTED_SOCIAL,
|
|
194
|
-
provider
|
|
195
|
-
);
|
|
196
|
-
} catch {
|
|
197
|
-
console.info('Unable to set Connected Social Provider');
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
async getConnectedSocialProvider(): Promise<SocialProvider | undefined> {
|
|
202
|
-
try {
|
|
203
|
-
const provider = await OptionsController.getStorage().getItem<SocialProvider>(
|
|
204
|
-
ConstantsUtil.STORAGE_KEYS.CONNECTED_SOCIAL
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
return provider ?? undefined;
|
|
208
|
-
} catch {
|
|
209
|
-
console.info('Unable to get Connected Social Provider');
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return undefined;
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
async removeConnectedSocialProvider() {
|
|
216
|
-
try {
|
|
217
|
-
await OptionsController.getStorage().removeItem(ConstantsUtil.STORAGE_KEYS.CONNECTED_SOCIAL);
|
|
218
|
-
} catch {
|
|
219
|
-
console.info('Unable to remove Connected Social Provider');
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
|
|
223
155
|
async setOnRampPreferredCountry(country: OnRampCountry) {
|
|
224
156
|
try {
|
|
225
157
|
await OptionsController.getStorage().setItem(
|
package/src/utils/TypeUtil.ts
CHANGED
|
@@ -340,7 +340,6 @@ export interface Token {
|
|
|
340
340
|
image?: string;
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
-
// -- OptionsController Types ---------------------------------------------------
|
|
344
343
|
export type CustomWallet = Pick<
|
|
345
344
|
WcWallet,
|
|
346
345
|
| 'id'
|
|
@@ -356,6 +355,13 @@ export type CustomWallet = Pick<
|
|
|
356
355
|
| 'play_store'
|
|
357
356
|
>;
|
|
358
357
|
|
|
358
|
+
export type UniversalProviderConfigOverride = {
|
|
359
|
+
methods?: Record<string, string[]>;
|
|
360
|
+
chains?: Record<string, string[]>;
|
|
361
|
+
events?: Record<string, string[]>;
|
|
362
|
+
rpcMap?: Record<string, string>;
|
|
363
|
+
};
|
|
364
|
+
|
|
359
365
|
// -- EventsController Types ----------------------------------------------------
|
|
360
366
|
export type EventName =
|
|
361
367
|
| 'MODAL_LOADED'
|
|
@@ -750,33 +756,6 @@ export type Event =
|
|
|
750
756
|
};
|
|
751
757
|
};
|
|
752
758
|
|
|
753
|
-
// -- Send Controller Types -------------------------------------
|
|
754
|
-
export type EstimateGasTransactionArgs = {
|
|
755
|
-
chainNamespace?: 'eip155';
|
|
756
|
-
address: `0x${string}`;
|
|
757
|
-
to: `0x${string}`;
|
|
758
|
-
data: `0x${string}`;
|
|
759
|
-
};
|
|
760
|
-
|
|
761
|
-
export interface SendTransactionArgs {
|
|
762
|
-
to: `0x${string}`;
|
|
763
|
-
data: `0x${string}`;
|
|
764
|
-
value: bigint;
|
|
765
|
-
gas?: bigint;
|
|
766
|
-
gasPrice: bigint;
|
|
767
|
-
address: `0x${string}`;
|
|
768
|
-
chainNamespace?: 'eip155';
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
export interface WriteContractArgs {
|
|
772
|
-
receiverAddress: `0x${string}`;
|
|
773
|
-
tokenAmount: bigint;
|
|
774
|
-
tokenAddress: `0x${string}`;
|
|
775
|
-
fromAddress: `0x${string}`;
|
|
776
|
-
method: 'send' | 'transfer' | 'call';
|
|
777
|
-
abi: any;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
759
|
// -- Swap Controller Types -------------------------------------
|
|
781
760
|
export type SwapToken = {
|
|
782
761
|
name: string;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ConnectionController = void 0;
|
|
7
|
-
var _valtio = require("valtio");
|
|
8
|
-
var _utils = require("valtio/utils");
|
|
9
|
-
var _CoreHelperUtil = require("../utils/CoreHelperUtil");
|
|
10
|
-
var _StorageUtil = require("../utils/StorageUtil");
|
|
11
|
-
// -- Types --------------------------------------------- //
|
|
12
|
-
|
|
13
|
-
// -- State --------------------------------------------- //
|
|
14
|
-
const state = (0, _valtio.proxy)({
|
|
15
|
-
wcError: false
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// -- Controller ---------------------------------------- //
|
|
19
|
-
const ConnectionController = exports.ConnectionController = {
|
|
20
|
-
state,
|
|
21
|
-
subscribeKey(key, callback) {
|
|
22
|
-
return (0, _utils.subscribeKey)(state, key, callback);
|
|
23
|
-
},
|
|
24
|
-
_getClient() {
|
|
25
|
-
if (!state._client) {
|
|
26
|
-
throw new Error('ConnectionController client not set');
|
|
27
|
-
}
|
|
28
|
-
return state._client;
|
|
29
|
-
},
|
|
30
|
-
setClient(client) {
|
|
31
|
-
state._client = (0, _valtio.ref)(client);
|
|
32
|
-
},
|
|
33
|
-
connectWalletConnect(walletUniversalLink) {
|
|
34
|
-
state.wcPromise = this._getClient().connectWalletConnect(uri => {
|
|
35
|
-
state.wcUri = uri;
|
|
36
|
-
state.wcPairingExpiry = _CoreHelperUtil.CoreHelperUtil.getPairingExpiry();
|
|
37
|
-
}, walletUniversalLink);
|
|
38
|
-
},
|
|
39
|
-
async signMessage(message) {
|
|
40
|
-
return this._getClient().signMessage(message);
|
|
41
|
-
},
|
|
42
|
-
setWcLinking(wcLinking) {
|
|
43
|
-
state.wcLinking = wcLinking;
|
|
44
|
-
},
|
|
45
|
-
removeWcLinking() {
|
|
46
|
-
state.wcLinking = undefined;
|
|
47
|
-
},
|
|
48
|
-
setWcError(wcError) {
|
|
49
|
-
state.wcError = wcError;
|
|
50
|
-
},
|
|
51
|
-
setPressedWallet(wallet) {
|
|
52
|
-
state.pressedWallet = wallet;
|
|
53
|
-
},
|
|
54
|
-
removePressedWallet() {
|
|
55
|
-
state.pressedWallet = undefined;
|
|
56
|
-
},
|
|
57
|
-
setWcPromise(wcPromise) {
|
|
58
|
-
state.wcPromise = wcPromise;
|
|
59
|
-
},
|
|
60
|
-
setWcUri(wcUri) {
|
|
61
|
-
state.wcUri = wcUri;
|
|
62
|
-
state.wcPairingExpiry = _CoreHelperUtil.CoreHelperUtil.getPairingExpiry();
|
|
63
|
-
},
|
|
64
|
-
setRecentWallets(wallets) {
|
|
65
|
-
state.recentWallets = wallets;
|
|
66
|
-
},
|
|
67
|
-
async setConnectedWalletImageUrl(url) {
|
|
68
|
-
state.connectedWalletImageUrl = url;
|
|
69
|
-
if (url) {
|
|
70
|
-
await _StorageUtil.StorageUtil.setConnectedWalletImageUrl(url);
|
|
71
|
-
} else {
|
|
72
|
-
_StorageUtil.StorageUtil.removeConnectedWalletImageUrl();
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
setConnectedSocialProvider(provider) {
|
|
76
|
-
state.connectedSocialProvider = provider;
|
|
77
|
-
if (provider) {
|
|
78
|
-
_StorageUtil.StorageUtil.setConnectedSocialProvider(provider);
|
|
79
|
-
} else {
|
|
80
|
-
_StorageUtil.StorageUtil.removeConnectedSocialProvider();
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
parseUnits(value, decimals) {
|
|
84
|
-
return this._getClient().parseUnits(value, decimals);
|
|
85
|
-
},
|
|
86
|
-
formatUnits(value, decimals) {
|
|
87
|
-
return this._getClient().formatUnits(value, decimals);
|
|
88
|
-
},
|
|
89
|
-
async sendTransaction(args) {
|
|
90
|
-
return this._getClient().sendTransaction(args);
|
|
91
|
-
},
|
|
92
|
-
async estimateGas(args) {
|
|
93
|
-
return this._getClient()?.estimateGas(args);
|
|
94
|
-
},
|
|
95
|
-
async writeContract(args) {
|
|
96
|
-
return this._getClient().writeContract(args);
|
|
97
|
-
},
|
|
98
|
-
async getEnsAddress(value) {
|
|
99
|
-
return this._getClient().getEnsAddress(value);
|
|
100
|
-
},
|
|
101
|
-
async getEnsAvatar(value) {
|
|
102
|
-
return this._getClient().getEnsAvatar(value);
|
|
103
|
-
},
|
|
104
|
-
clearUri() {
|
|
105
|
-
state.wcUri = undefined;
|
|
106
|
-
state.wcPairingExpiry = undefined;
|
|
107
|
-
state.wcPromise = undefined;
|
|
108
|
-
state.wcLinking = undefined;
|
|
109
|
-
},
|
|
110
|
-
resetWcConnection() {
|
|
111
|
-
this.clearUri();
|
|
112
|
-
state.pressedWallet = undefined;
|
|
113
|
-
ConnectionController.setConnectedWalletImageUrl(undefined);
|
|
114
|
-
// ConnectorController.setConnectedConnector(undefined);
|
|
115
|
-
_StorageUtil.StorageUtil.removeWalletConnectDeepLink();
|
|
116
|
-
},
|
|
117
|
-
async disconnect() {
|
|
118
|
-
this.resetWcConnection();
|
|
119
|
-
// remove transactions
|
|
120
|
-
// RouterController.reset('Connect');
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=ConnectionController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_valtio","require","_utils","_CoreHelperUtil","_StorageUtil","state","proxy","wcError","ConnectionController","exports","subscribeKey","key","callback","subKey","_getClient","_client","Error","setClient","client","ref","connectWalletConnect","walletUniversalLink","wcPromise","uri","wcUri","wcPairingExpiry","CoreHelperUtil","getPairingExpiry","signMessage","message","setWcLinking","wcLinking","removeWcLinking","undefined","setWcError","setPressedWallet","wallet","pressedWallet","removePressedWallet","setWcPromise","setWcUri","setRecentWallets","wallets","recentWallets","setConnectedWalletImageUrl","url","connectedWalletImageUrl","StorageUtil","removeConnectedWalletImageUrl","setConnectedSocialProvider","provider","connectedSocialProvider","removeConnectedSocialProvider","parseUnits","value","decimals","formatUnits","sendTransaction","args","estimateGas","writeContract","getEnsAddress","getEnsAvatar","clearUri","resetWcConnection","removeWalletConnectDeepLink","disconnect"],"sourceRoot":"../../../src","sources":["controllers/ConnectionController.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,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AED,MAAMC,UAAUA,CAAA,EAAG;IACjB,IAAI,CAACF,iBAAiB,CAAC,CAAC;IACxB;IACA;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { proxy, ref } from 'valtio';
|
|
4
|
-
import { subscribeKey as subKey } from 'valtio/utils';
|
|
5
|
-
import { CoreHelperUtil } from '../utils/CoreHelperUtil';
|
|
6
|
-
import { StorageUtil } from '../utils/StorageUtil';
|
|
7
|
-
|
|
8
|
-
// -- Types --------------------------------------------- //
|
|
9
|
-
|
|
10
|
-
// -- State --------------------------------------------- //
|
|
11
|
-
const state = proxy({
|
|
12
|
-
wcError: false
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// -- Controller ---------------------------------------- //
|
|
16
|
-
export const ConnectionController = {
|
|
17
|
-
state,
|
|
18
|
-
subscribeKey(key, callback) {
|
|
19
|
-
return subKey(state, key, callback);
|
|
20
|
-
},
|
|
21
|
-
_getClient() {
|
|
22
|
-
if (!state._client) {
|
|
23
|
-
throw new Error('ConnectionController client not set');
|
|
24
|
-
}
|
|
25
|
-
return state._client;
|
|
26
|
-
},
|
|
27
|
-
setClient(client) {
|
|
28
|
-
state._client = ref(client);
|
|
29
|
-
},
|
|
30
|
-
connectWalletConnect(walletUniversalLink) {
|
|
31
|
-
state.wcPromise = this._getClient().connectWalletConnect(uri => {
|
|
32
|
-
state.wcUri = uri;
|
|
33
|
-
state.wcPairingExpiry = CoreHelperUtil.getPairingExpiry();
|
|
34
|
-
}, walletUniversalLink);
|
|
35
|
-
},
|
|
36
|
-
async signMessage(message) {
|
|
37
|
-
return this._getClient().signMessage(message);
|
|
38
|
-
},
|
|
39
|
-
setWcLinking(wcLinking) {
|
|
40
|
-
state.wcLinking = wcLinking;
|
|
41
|
-
},
|
|
42
|
-
removeWcLinking() {
|
|
43
|
-
state.wcLinking = undefined;
|
|
44
|
-
},
|
|
45
|
-
setWcError(wcError) {
|
|
46
|
-
state.wcError = wcError;
|
|
47
|
-
},
|
|
48
|
-
setPressedWallet(wallet) {
|
|
49
|
-
state.pressedWallet = wallet;
|
|
50
|
-
},
|
|
51
|
-
removePressedWallet() {
|
|
52
|
-
state.pressedWallet = undefined;
|
|
53
|
-
},
|
|
54
|
-
setWcPromise(wcPromise) {
|
|
55
|
-
state.wcPromise = wcPromise;
|
|
56
|
-
},
|
|
57
|
-
setWcUri(wcUri) {
|
|
58
|
-
state.wcUri = wcUri;
|
|
59
|
-
state.wcPairingExpiry = CoreHelperUtil.getPairingExpiry();
|
|
60
|
-
},
|
|
61
|
-
setRecentWallets(wallets) {
|
|
62
|
-
state.recentWallets = wallets;
|
|
63
|
-
},
|
|
64
|
-
async setConnectedWalletImageUrl(url) {
|
|
65
|
-
state.connectedWalletImageUrl = url;
|
|
66
|
-
if (url) {
|
|
67
|
-
await StorageUtil.setConnectedWalletImageUrl(url);
|
|
68
|
-
} else {
|
|
69
|
-
StorageUtil.removeConnectedWalletImageUrl();
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
setConnectedSocialProvider(provider) {
|
|
73
|
-
state.connectedSocialProvider = provider;
|
|
74
|
-
if (provider) {
|
|
75
|
-
StorageUtil.setConnectedSocialProvider(provider);
|
|
76
|
-
} else {
|
|
77
|
-
StorageUtil.removeConnectedSocialProvider();
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
parseUnits(value, decimals) {
|
|
81
|
-
return this._getClient().parseUnits(value, decimals);
|
|
82
|
-
},
|
|
83
|
-
formatUnits(value, decimals) {
|
|
84
|
-
return this._getClient().formatUnits(value, decimals);
|
|
85
|
-
},
|
|
86
|
-
async sendTransaction(args) {
|
|
87
|
-
return this._getClient().sendTransaction(args);
|
|
88
|
-
},
|
|
89
|
-
async estimateGas(args) {
|
|
90
|
-
return this._getClient()?.estimateGas(args);
|
|
91
|
-
},
|
|
92
|
-
async writeContract(args) {
|
|
93
|
-
return this._getClient().writeContract(args);
|
|
94
|
-
},
|
|
95
|
-
async getEnsAddress(value) {
|
|
96
|
-
return this._getClient().getEnsAddress(value);
|
|
97
|
-
},
|
|
98
|
-
async getEnsAvatar(value) {
|
|
99
|
-
return this._getClient().getEnsAvatar(value);
|
|
100
|
-
},
|
|
101
|
-
clearUri() {
|
|
102
|
-
state.wcUri = undefined;
|
|
103
|
-
state.wcPairingExpiry = undefined;
|
|
104
|
-
state.wcPromise = undefined;
|
|
105
|
-
state.wcLinking = undefined;
|
|
106
|
-
},
|
|
107
|
-
resetWcConnection() {
|
|
108
|
-
this.clearUri();
|
|
109
|
-
state.pressedWallet = undefined;
|
|
110
|
-
ConnectionController.setConnectedWalletImageUrl(undefined);
|
|
111
|
-
// ConnectorController.setConnectedConnector(undefined);
|
|
112
|
-
StorageUtil.removeWalletConnectDeepLink();
|
|
113
|
-
},
|
|
114
|
-
async disconnect() {
|
|
115
|
-
this.resetWcConnection();
|
|
116
|
-
// remove transactions
|
|
117
|
-
// RouterController.reset('Connect');
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
//# sourceMappingURL=ConnectionController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["proxy","ref","subscribeKey","subKey","CoreHelperUtil","StorageUtil","state","wcError","ConnectionController","key","callback","_getClient","_client","Error","setClient","client","connectWalletConnect","walletUniversalLink","wcPromise","uri","wcUri","wcPairingExpiry","getPairingExpiry","signMessage","message","setWcLinking","wcLinking","removeWcLinking","undefined","setWcError","setPressedWallet","wallet","pressedWallet","removePressedWallet","setWcPromise","setWcUri","setRecentWallets","wallets","recentWallets","setConnectedWalletImageUrl","url","connectedWalletImageUrl","removeConnectedWalletImageUrl","setConnectedSocialProvider","provider","connectedSocialProvider","removeConnectedSocialProvider","parseUnits","value","decimals","formatUnits","sendTransaction","args","estimateGas","writeContract","getEnsAddress","getEnsAvatar","clearUri","resetWcConnection","removeWalletConnectDeepLink","disconnect"],"sourceRoot":"../../../src","sources":["controllers/Con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C;EAC3C,CAAC;EAED,MAAMC,UAAUA,CAAA,EAAG;IACjB,IAAI,CAACF,iBAAiB,CAAC,CAAC;IACxB;IACA;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { SocialProvider, WalletDeepLink } from '@reown/appkit-common-react-native';
|
|
2
|
-
import type { EstimateGasTransactionArgs, SendTransactionArgs, WcWallet, WriteContractArgs } from '../utils/TypeUtil';
|
|
3
|
-
export interface ConnectionControllerClient {
|
|
4
|
-
connectWalletConnect: (onUri: (uri: string) => void, walletUniversalLink?: string) => Promise<void>;
|
|
5
|
-
signMessage: (message: string) => Promise<string>;
|
|
6
|
-
sendTransaction: (args: SendTransactionArgs) => Promise<`0x${string}` | null>;
|
|
7
|
-
parseUnits: (value: string, decimals: number) => bigint;
|
|
8
|
-
formatUnits: (value: bigint, decimals: number) => string;
|
|
9
|
-
writeContract: (args: WriteContractArgs) => Promise<`0x${string}` | null>;
|
|
10
|
-
estimateGas: (args: EstimateGasTransactionArgs) => Promise<bigint>;
|
|
11
|
-
disconnect: () => Promise<void>;
|
|
12
|
-
getEnsAddress: (value: string) => Promise<false | string>;
|
|
13
|
-
getEnsAvatar: (value: string) => Promise<false | string>;
|
|
14
|
-
}
|
|
15
|
-
export interface ConnectionControllerState {
|
|
16
|
-
_client?: ConnectionControllerClient;
|
|
17
|
-
wcUri?: string;
|
|
18
|
-
wcPromise?: Promise<void>;
|
|
19
|
-
wcPairingExpiry?: number;
|
|
20
|
-
wcLinking?: WalletDeepLink;
|
|
21
|
-
wcError?: boolean;
|
|
22
|
-
pressedWallet?: WcWallet;
|
|
23
|
-
recentWallets?: WcWallet[];
|
|
24
|
-
connectedWalletImageUrl?: string;
|
|
25
|
-
connectedSocialProvider?: SocialProvider;
|
|
26
|
-
}
|
|
27
|
-
export declare const ConnectionController: {
|
|
28
|
-
state: ConnectionControllerState;
|
|
29
|
-
subscribeKey<K extends keyof ConnectionControllerState>(key: K, callback: (value: ConnectionControllerState[K]) => void): () => void;
|
|
30
|
-
_getClient(): ConnectionControllerClient;
|
|
31
|
-
setClient(client: ConnectionControllerClient): void;
|
|
32
|
-
connectWalletConnect(walletUniversalLink?: string): void;
|
|
33
|
-
signMessage(message: string): Promise<string>;
|
|
34
|
-
setWcLinking(wcLinking: ConnectionControllerState['wcLinking']): void;
|
|
35
|
-
removeWcLinking(): void;
|
|
36
|
-
setWcError(wcError: ConnectionControllerState['wcError']): void;
|
|
37
|
-
setPressedWallet(wallet: ConnectionControllerState['pressedWallet']): void;
|
|
38
|
-
removePressedWallet(): void;
|
|
39
|
-
setWcPromise(wcPromise: ConnectionControllerState['wcPromise']): void;
|
|
40
|
-
setWcUri(wcUri: ConnectionControllerState['wcUri']): void;
|
|
41
|
-
setRecentWallets(wallets: ConnectionControllerState['recentWallets']): void;
|
|
42
|
-
setConnectedWalletImageUrl(url: ConnectionControllerState['connectedWalletImageUrl']): Promise<void>;
|
|
43
|
-
setConnectedSocialProvider(provider: ConnectionControllerState['connectedSocialProvider']): void;
|
|
44
|
-
parseUnits(value: string, decimals: number): bigint;
|
|
45
|
-
formatUnits(value: bigint, decimals: number): string;
|
|
46
|
-
sendTransaction(args: SendTransactionArgs): Promise<`0x${string}` | null>;
|
|
47
|
-
estimateGas(args: EstimateGasTransactionArgs): Promise<bigint>;
|
|
48
|
-
writeContract(args: WriteContractArgs): Promise<`0x${string}` | null>;
|
|
49
|
-
getEnsAddress(value: string): Promise<string | false>;
|
|
50
|
-
getEnsAvatar(value: string): Promise<string | false>;
|
|
51
|
-
clearUri(): void;
|
|
52
|
-
resetWcConnection(): void;
|
|
53
|
-
disconnect(): Promise<void>;
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=ConnectionController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionController.d.ts","sourceRoot":"","sources":["../../../src/controllers/ConnectionController.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cA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C,IAAI,CAAC,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,uBAAuB,CAAC,EAAE,cAAc,CAAC;CAC1C;AAUD,eAAO,MAAM,oBAAoB;;uHAKsB,IAAI;;sBAavC,0BAA0B;+CAID,MAAM;yBAOtB,MAAM;4BAIT,yBAAyB,CAAC,WAAW,CAAC;;wBAQ1C,yBAAyB,CAAC,SAAS,CAAC;6BAI/B,yBAAyB,CAAC,eAAe,CAAC;;4BAQ3C,yBAAyB,CAAC,WAAW,CAAC;oBAI9C,yBAAyB,CAAC,OAAO,CAAC;8BAKxB,yBAAyB,CAAC,eAAe,CAAC;oCAI9B,yBAAyB,CAAC,yBAAyB,CAAC;yCAUrD,yBAAyB,CAAC,yBAAyB,CAAC;sBAUvE,MAAM,YAAY,MAAM;uBAIvB,MAAM,YAAY,MAAM;0BAIf,mBAAmB;sBAIvB,0BAA0B;wBAGxB,iBAAiB;yBAIhB,MAAM;wBAIP,MAAM;;;;CAwBjC,CAAC"}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { proxy, ref } from 'valtio';
|
|
2
|
-
import { subscribeKey as subKey } from 'valtio/utils';
|
|
3
|
-
import type { SocialProvider, WalletDeepLink } from '@reown/appkit-common-react-native';
|
|
4
|
-
import { CoreHelperUtil } from '../utils/CoreHelperUtil';
|
|
5
|
-
import { StorageUtil } from '../utils/StorageUtil';
|
|
6
|
-
import type {
|
|
7
|
-
EstimateGasTransactionArgs,
|
|
8
|
-
SendTransactionArgs,
|
|
9
|
-
WcWallet,
|
|
10
|
-
WriteContractArgs
|
|
11
|
-
} from '../utils/TypeUtil';
|
|
12
|
-
|
|
13
|
-
// -- Types --------------------------------------------- //
|
|
14
|
-
|
|
15
|
-
export interface ConnectionControllerClient {
|
|
16
|
-
connectWalletConnect: (
|
|
17
|
-
onUri: (uri: string) => void,
|
|
18
|
-
walletUniversalLink?: string
|
|
19
|
-
) => Promise<void>;
|
|
20
|
-
signMessage: (message: string) => Promise<string>;
|
|
21
|
-
sendTransaction: (args: SendTransactionArgs) => Promise<`0x${string}` | null>;
|
|
22
|
-
parseUnits: (value: string, decimals: number) => bigint;
|
|
23
|
-
formatUnits: (value: bigint, decimals: number) => string;
|
|
24
|
-
writeContract: (args: WriteContractArgs) => Promise<`0x${string}` | null>;
|
|
25
|
-
estimateGas: (args: EstimateGasTransactionArgs) => Promise<bigint>;
|
|
26
|
-
disconnect: () => Promise<void>;
|
|
27
|
-
getEnsAddress: (value: string) => Promise<false | string>;
|
|
28
|
-
getEnsAvatar: (value: string) => Promise<false | string>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface ConnectionControllerState {
|
|
32
|
-
_client?: ConnectionControllerClient;
|
|
33
|
-
wcUri?: string;
|
|
34
|
-
wcPromise?: Promise<void>;
|
|
35
|
-
wcPairingExpiry?: number;
|
|
36
|
-
wcLinking?: WalletDeepLink;
|
|
37
|
-
wcError?: boolean;
|
|
38
|
-
pressedWallet?: WcWallet;
|
|
39
|
-
recentWallets?: WcWallet[];
|
|
40
|
-
connectedWalletImageUrl?: string; //TODO: remove this
|
|
41
|
-
connectedSocialProvider?: SocialProvider; // TODO: remove this
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
type StateKey = keyof ConnectionControllerState;
|
|
45
|
-
|
|
46
|
-
// -- State --------------------------------------------- //
|
|
47
|
-
const state = proxy<ConnectionControllerState>({
|
|
48
|
-
wcError: false
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// -- Controller ---------------------------------------- //
|
|
52
|
-
export const ConnectionController = {
|
|
53
|
-
state,
|
|
54
|
-
|
|
55
|
-
subscribeKey<K extends StateKey>(
|
|
56
|
-
key: K,
|
|
57
|
-
callback: (value: ConnectionControllerState[K]) => void
|
|
58
|
-
) {
|
|
59
|
-
return subKey(state, key, callback);
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
_getClient() {
|
|
63
|
-
if (!state._client) {
|
|
64
|
-
throw new Error('ConnectionController client not set');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return state._client;
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
setClient(client: ConnectionControllerClient) {
|
|
71
|
-
state._client = ref(client);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
connectWalletConnect(walletUniversalLink?: string) {
|
|
75
|
-
state.wcPromise = this._getClient().connectWalletConnect(uri => {
|
|
76
|
-
state.wcUri = uri;
|
|
77
|
-
state.wcPairingExpiry = CoreHelperUtil.getPairingExpiry();
|
|
78
|
-
}, walletUniversalLink);
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
async signMessage(message: string) {
|
|
82
|
-
return this._getClient().signMessage(message);
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
setWcLinking(wcLinking: ConnectionControllerState['wcLinking']) {
|
|
86
|
-
state.wcLinking = wcLinking;
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
removeWcLinking() {
|
|
90
|
-
state.wcLinking = undefined;
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
setWcError(wcError: ConnectionControllerState['wcError']) {
|
|
94
|
-
state.wcError = wcError;
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
setPressedWallet(wallet: ConnectionControllerState['pressedWallet']) {
|
|
98
|
-
state.pressedWallet = wallet;
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
removePressedWallet() {
|
|
102
|
-
state.pressedWallet = undefined;
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
setWcPromise(wcPromise: ConnectionControllerState['wcPromise']) {
|
|
106
|
-
state.wcPromise = wcPromise;
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
setWcUri(wcUri: ConnectionControllerState['wcUri']) {
|
|
110
|
-
state.wcUri = wcUri;
|
|
111
|
-
state.wcPairingExpiry = CoreHelperUtil.getPairingExpiry();
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
setRecentWallets(wallets: ConnectionControllerState['recentWallets']) {
|
|
115
|
-
state.recentWallets = wallets;
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
async setConnectedWalletImageUrl(url: ConnectionControllerState['connectedWalletImageUrl']) {
|
|
119
|
-
state.connectedWalletImageUrl = url;
|
|
120
|
-
|
|
121
|
-
if (url) {
|
|
122
|
-
await StorageUtil.setConnectedWalletImageUrl(url);
|
|
123
|
-
} else {
|
|
124
|
-
StorageUtil.removeConnectedWalletImageUrl();
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
setConnectedSocialProvider(provider: ConnectionControllerState['connectedSocialProvider']) {
|
|
129
|
-
state.connectedSocialProvider = provider;
|
|
130
|
-
|
|
131
|
-
if (provider) {
|
|
132
|
-
StorageUtil.setConnectedSocialProvider(provider);
|
|
133
|
-
} else {
|
|
134
|
-
StorageUtil.removeConnectedSocialProvider();
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
parseUnits(value: string, decimals: number) {
|
|
139
|
-
return this._getClient().parseUnits(value, decimals);
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
formatUnits(value: bigint, decimals: number) {
|
|
143
|
-
return this._getClient().formatUnits(value, decimals);
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
async sendTransaction(args: SendTransactionArgs) {
|
|
147
|
-
return this._getClient().sendTransaction(args);
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
async estimateGas(args: EstimateGasTransactionArgs) {
|
|
151
|
-
return this._getClient()?.estimateGas(args);
|
|
152
|
-
},
|
|
153
|
-
async writeContract(args: WriteContractArgs) {
|
|
154
|
-
return this._getClient().writeContract(args);
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
async getEnsAddress(value: string) {
|
|
158
|
-
return this._getClient().getEnsAddress(value);
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
async getEnsAvatar(value: string) {
|
|
162
|
-
return this._getClient().getEnsAvatar(value);
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
clearUri() {
|
|
166
|
-
state.wcUri = undefined;
|
|
167
|
-
state.wcPairingExpiry = undefined;
|
|
168
|
-
state.wcPromise = undefined;
|
|
169
|
-
state.wcLinking = undefined;
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
resetWcConnection() {
|
|
173
|
-
this.clearUri();
|
|
174
|
-
state.pressedWallet = undefined;
|
|
175
|
-
ConnectionController.setConnectedWalletImageUrl(undefined);
|
|
176
|
-
// ConnectorController.setConnectedConnector(undefined);
|
|
177
|
-
StorageUtil.removeWalletConnectDeepLink();
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
async disconnect() {
|
|
181
|
-
this.resetWcConnection();
|
|
182
|
-
// remove transactions
|
|
183
|
-
// RouterController.reset('Connect');
|
|
184
|
-
}
|
|
185
|
-
};
|