@reown/appkit-ethers-react-native 0.0.0-feat-onramp-20250602135932 → 0.0.0-feat-multichain-20250604171123
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/adapter.js +79 -0
- package/lib/commonjs/adapter.js.map +1 -0
- package/lib/commonjs/helpers.js +33 -0
- package/lib/commonjs/helpers.js.map +1 -0
- package/lib/commonjs/index.js +3 -174
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/adapter.js +72 -0
- package/lib/module/adapter.js.map +1 -0
- package/lib/module/helpers.js +25 -0
- package/lib/module/helpers.js.map +1 -0
- package/lib/module/index.js +2 -133
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/adapter.d.ts +13 -0
- package/lib/typescript/adapter.d.ts.map +1 -0
- package/lib/typescript/helpers.d.ts +3 -0
- package/lib/typescript/helpers.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +2 -39
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +6 -10
- package/src/adapter.ts +94 -0
- package/src/helpers.ts +25 -0
- package/src/index.tsx +2 -164
- package/lib/commonjs/client.js +0 -861
- package/lib/commonjs/client.js.map +0 -1
- package/lib/commonjs/utils/defaultConfig.js +0 -18
- package/lib/commonjs/utils/defaultConfig.js.map +0 -1
- package/lib/commonjs/utils/helpers.js +0 -27
- package/lib/commonjs/utils/helpers.js.map +0 -1
- package/lib/module/client.js +0 -853
- package/lib/module/client.js.map +0 -1
- package/lib/module/utils/defaultConfig.js +0 -12
- package/lib/module/utils/defaultConfig.js.map +0 -1
- package/lib/module/utils/helpers.js +0 -20
- package/lib/module/utils/helpers.js.map +0 -1
- package/lib/typescript/client.d.ts +0 -65
- package/lib/typescript/client.d.ts.map +0 -1
- package/lib/typescript/utils/defaultConfig.d.ts +0 -7
- package/lib/typescript/utils/defaultConfig.d.ts.map +0 -1
- package/lib/typescript/utils/helpers.d.ts +0 -10
- package/lib/typescript/utils/helpers.d.ts.map +0 -1
- package/src/client.ts +0 -1077
- package/src/utils/defaultConfig.ts +0 -19
- package/src/utils/helpers.ts +0 -27
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EthersAdapter = void 0;
|
|
7
|
+
var _appkitCommonReactNative = require("@reown/appkit-common-react-native");
|
|
8
|
+
var _appkitScaffoldUtilsReactNative = require("@reown/appkit-scaffold-utils-react-native");
|
|
9
|
+
var _helpers = require("./helpers");
|
|
10
|
+
class EthersAdapter extends _appkitCommonReactNative.EVMAdapter {
|
|
11
|
+
static supportedNamespace = 'eip155';
|
|
12
|
+
constructor(configParams) {
|
|
13
|
+
super({
|
|
14
|
+
projectId: configParams.projectId,
|
|
15
|
+
supportedNamespace: EthersAdapter.supportedNamespace
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async getBalance(params) {
|
|
19
|
+
const {
|
|
20
|
+
network,
|
|
21
|
+
address
|
|
22
|
+
} = params;
|
|
23
|
+
if (!this.connector) throw new Error('No active connector');
|
|
24
|
+
if (!network) throw new Error('No network provided');
|
|
25
|
+
const balanceAddress = address || this.getAccounts()?.find(account => account.includes(network.id.toString()));
|
|
26
|
+
const balance = {
|
|
27
|
+
amount: '0.00',
|
|
28
|
+
symbol: network.nativeCurrency.symbol || 'ETH'
|
|
29
|
+
};
|
|
30
|
+
if (!balanceAddress) return balance;
|
|
31
|
+
const account = balanceAddress.split(':')[2];
|
|
32
|
+
const rpcUrl = network.rpcUrls.default.http?.[0];
|
|
33
|
+
if (!rpcUrl || !account) return balance;
|
|
34
|
+
try {
|
|
35
|
+
const wei = await (0, _helpers.getEthBalance)(rpcUrl, account);
|
|
36
|
+
balance.amount = (0, _helpers.formatEther)(wei);
|
|
37
|
+
this.emit('balanceChanged', {
|
|
38
|
+
address: balanceAddress,
|
|
39
|
+
balance
|
|
40
|
+
});
|
|
41
|
+
return balance;
|
|
42
|
+
} catch {
|
|
43
|
+
return balance;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async switchNetwork(network) {
|
|
47
|
+
if (!this.connector) throw new Error('No active connector');
|
|
48
|
+
const provider = this.connector.getProvider();
|
|
49
|
+
if (!provider) throw new Error('No active provider');
|
|
50
|
+
try {
|
|
51
|
+
await provider.request({
|
|
52
|
+
method: 'wallet_switchEthereumChain',
|
|
53
|
+
params: [{
|
|
54
|
+
chainId: _appkitScaffoldUtilsReactNative.EthersHelpersUtil.numberToHexString(Number(network.id))
|
|
55
|
+
}] //TODO: check util
|
|
56
|
+
}, `${EthersAdapter.supportedNamespace}:${network.id}`);
|
|
57
|
+
} catch (switchError) {
|
|
58
|
+
const message = switchError?.message;
|
|
59
|
+
if (/(?<temp1>user rejected)/u.test(message?.toLowerCase())) {
|
|
60
|
+
throw new Error('Chain is not supported');
|
|
61
|
+
}
|
|
62
|
+
throw switchError;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
getAccounts() {
|
|
66
|
+
if (!this.connector) throw new Error('No active connector');
|
|
67
|
+
const namespaces = this.connector.getNamespaces();
|
|
68
|
+
return namespaces[this.getSupportedNamespace()]?.accounts;
|
|
69
|
+
}
|
|
70
|
+
disconnect() {
|
|
71
|
+
if (!this.connector) throw new Error('EthersAdapter:disconnect - No active connector');
|
|
72
|
+
return this.connector.disconnect();
|
|
73
|
+
}
|
|
74
|
+
getSupportedNamespace() {
|
|
75
|
+
return EthersAdapter.supportedNamespace;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.EthersAdapter = EthersAdapter;
|
|
79
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_appkitCommonReactNative","require","_appkitScaffoldUtilsReactNative","_helpers","EthersAdapter","EVMAdapter","supportedNamespace","constructor","configParams","projectId","getBalance","params","network","address","connector","Error","balanceAddress","getAccounts","find","account","includes","id","toString","balance","amount","symbol","nativeCurrency","split","rpcUrl","rpcUrls","default","http","wei","getEthBalance","formatEther","emit","switchNetwork","provider","getProvider","request","method","chainId","EthersHelpersUtil","numberToHexString","Number","switchError","message","test","toLowerCase","namespaces","getNamespaces","getSupportedNamespace","accounts","disconnect","exports"],"sourceRoot":"../../src","sources":["adapter.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAQA,IAAAC,+BAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEO,MAAMG,aAAa,SAASC,mCAAU,CAAC;EAC5C,OAAeC,kBAAkB,GAAmB,QAAQ;EAE5DC,WAAWA,CAACC,YAAmC,EAAE;IAC/C,KAAK,CAAC;MACJC,SAAS,EAAED,YAAY,CAACC,SAAS;MACjCH,kBAAkB,EAAEF,aAAa,CAACE;IACpC,CAAC,CAAC;EACJ;EAEA,MAAMI,UAAUA,CAACC,MAAwB,EAA+B;IACtE,MAAM;MAAEC,OAAO;MAAEC;IAAQ,CAAC,GAAGF,MAAM;IAEnC,IAAI,CAAC,IAAI,CAACG,SAAS,EAAE,MAAM,IAAIC,KAAK,CAAC,qBAAqB,CAAC;IAC3D,IAAI,CAACH,OAAO,EAAE,MAAM,IAAIG,KAAK,CAAC,qBAAqB,CAAC;IAEpD,MAAMC,cAAc,GAClBH,OAAO,IAAI,IAAI,CAACI,WAAW,CAAC,CAAC,EAAEC,IAAI,CAACC,OAAO,IAAIA,OAAO,CAACC,QAAQ,CAACR,OAAO,CAACS,EAAE,CAACC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEzF,MAAMC,OAA2B,GAAG;MAClCC,MAAM,EAAE,MAAM;MACdC,MAAM,EAAEb,OAAO,CAACc,cAAc,CAACD,MAAM,IAAI;IAC3C,CAAC;IAED,IAAI,CAACT,cAAc,EAAE,OAAOO,OAAO;IAEnC,MAAMJ,OAAO,GAAGH,cAAc,CAACW,KAAK,CAAC,GAAG,CAAC,CAAC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D,MAAM,IAAIjC,KAAK,CAAC,wBAAwB,CAAC;MAC3C;MAEA,MAAM8B,WAAW;IACnB;EACF;EAEA5B,WAAWA,CAAA,EAA8B;IACvC,IAAI,CAAC,IAAI,CAACH,SAAS,EAAE,MAAM,IAAIC,KAAK,CAAC,qBAAqB,CAAC;IAC3D,MAAMkC,UAAU,GAAG,IAAI,CAACnC,SAAS,CAACoC,aAAa,CAAC,CAAC;IAEjD,OAAOD,UAAU,CAAC,IAAI,CAACE,qBAAqB,CAAC,CAAC,CAAC,EAAEC,QAAQ;EAC3D;EAEAC,UAAUA,CAAA,EAAkB;IAC1B,IAAI,CAAC,IAAI,CAACvC,SAAS,EAAE,MAAM,IAAIC,KAAK,CAAC,gDAAgD,CAAC;IAEtF,OAAO,IAAI,CAACD,SAAS,CAACuC,UAAU,CAAC,CAAC;EACpC;EAEAF,qBAAqBA,CAAA,EAAmB;IACtC,OAAO/C,aAAa,CAACE,kBAAkB;EACzC;AACF;AAACgD,OAAA,CAAAlD,aAAA,GAAAA,aAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatEther = void 0;
|
|
7
|
+
exports.getEthBalance = getEthBalance;
|
|
8
|
+
// Helper to convert Wei (as string or bigint) to ETH
|
|
9
|
+
const formatEther = wei => {
|
|
10
|
+
return (Number(wei) / 1e18).toString();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Raw JSON-RPC for balance lookup
|
|
14
|
+
exports.formatEther = formatEther;
|
|
15
|
+
async function getEthBalance(rpcUrl, address) {
|
|
16
|
+
const body = {
|
|
17
|
+
jsonrpc: '2.0',
|
|
18
|
+
method: 'eth_getBalance',
|
|
19
|
+
params: [address, 'latest'],
|
|
20
|
+
id: 1
|
|
21
|
+
};
|
|
22
|
+
const response = await fetch(rpcUrl, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json'
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify(body)
|
|
28
|
+
});
|
|
29
|
+
const json = await response.json();
|
|
30
|
+
if (json.error) throw new Error(json.error.message);
|
|
31
|
+
return BigInt(json.result); // result is hex string
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["formatEther","wei","Number","toString","exports","getEthBalance","rpcUrl","address","body","jsonrpc","method","params","id","response","fetch","headers","JSON","stringify","json","error","Error","message","BigInt","result"],"sourceRoot":"../../src","sources":["helpers.ts"],"mappings":";;;;;;;AAAA;AACO,MAAMA,WAAW,GAAIC,GAAW,IAAa;EAClD,OAAO,CAACC,MAAM,CAACD,GAAG,CAAC,GAAG,IAAI,EAAEE,QAAQ,CAAC,CAAC;AACxC,CAAC;;AAED;AAAAC,OAAA,CAAAJ,WAAA,GAAAA,WAAA;AACO,eAAeK,aAAaA,CAACC,MAAc,EAAEC,OAAe,EAAmB;EACpF,MAAMC,IAAI,GAAG;IACXC,OAAO,EAAE,KAAK;IACdC,MAAM,EAAE,gBAAgB;IACxBC,MAAM,EAAE,CAACJ,OAAO,EAAE,QAAQ,CAAC;IAC3BK,EAAE,EAAE;EACN,CAAC;EAED,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAACR,MAAM,EAAE;IACnCI,MAAM,EAAE,MAAM;IACdK,OAAO,EAAE;MAAE,cAAc,EAAE;IAAmB,CAAC;IAC/CP,IAAI,EAAEQ,IAAI,CAACC,SAAS,CAACT,IAAI;EAC3B,CAAC,CAAC;EAEF,MAAMU,IAAI,GAAG,MAAML,QAAQ,CAACK,IAAI,CAAC,CAAC;EAClC,IAAIA,IAAI,CAACC,KAAK,EAAE,MAAM,IAAIC,KAAK,CAACF,IAAI,CAACC,KAAK,CAACE,OAAO,CAAC;EAEnD,OAAOC,MAAM,CAACJ,IAAI,CAACK,MAAM,CAAC,CAAC,CAAC;AAC9B"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,182 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "EthersAdapter", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _adapter.EthersAdapter;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _appkitScaffoldReactNative.AppKit;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "AppKitButton", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _appkitScaffoldReactNative.AppKitButton;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "ConnectButton", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _appkitScaffoldReactNative.ConnectButton;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "NetworkButton", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _appkitScaffoldReactNative.NetworkButton;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
exports.createAppKit = createAppKit;
|
|
37
|
-
Object.defineProperty(exports, "defaultConfig", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () {
|
|
40
|
-
return _defaultConfig.defaultConfig;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
exports.useAppKit = useAppKit;
|
|
44
|
-
exports.useAppKitAccount = useAppKitAccount;
|
|
45
|
-
exports.useAppKitError = useAppKitError;
|
|
46
|
-
exports.useAppKitEventSubscription = useAppKitEventSubscription;
|
|
47
|
-
exports.useAppKitEvents = useAppKitEvents;
|
|
48
|
-
exports.useAppKitProvider = useAppKitProvider;
|
|
49
|
-
exports.useAppKitState = useAppKitState;
|
|
50
|
-
exports.useDisconnect = useDisconnect;
|
|
51
|
-
exports.useWalletInfo = useWalletInfo;
|
|
52
|
-
var _react = require("react");
|
|
53
|
-
var _valtio = require("valtio");
|
|
54
|
-
var _appkitScaffoldUtilsReactNative = require("@reown/appkit-scaffold-utils-react-native");
|
|
55
|
-
var _appkitScaffoldReactNative = require("@reown/appkit-scaffold-react-native");
|
|
56
|
-
var _appkitCommonReactNative = require("@reown/appkit-common-react-native");
|
|
57
|
-
var _defaultConfig = require("./utils/defaultConfig");
|
|
58
|
-
var _client = require("./client");
|
|
59
|
-
// -- Types -------------------------------------------------------------------
|
|
60
|
-
|
|
61
|
-
// -- Setup -------------------------------------------------------------------
|
|
62
|
-
let modal;
|
|
63
|
-
function createAppKit(options) {
|
|
64
|
-
if (!modal) {
|
|
65
|
-
modal = new _client.AppKit({
|
|
66
|
-
...options,
|
|
67
|
-
_sdkVersion: `react-native-ethers-${_appkitCommonReactNative.ConstantsUtil.VERSION}`
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return modal;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// -- Hooks -------------------------------------------------------------------
|
|
74
|
-
function useAppKit() {
|
|
75
|
-
if (!modal) {
|
|
76
|
-
throw new Error('Please call "createAppKit" before using "useAppKit" hook');
|
|
77
|
-
}
|
|
78
|
-
async function open(options) {
|
|
79
|
-
await modal?.open(options);
|
|
80
|
-
}
|
|
81
|
-
async function close() {
|
|
82
|
-
await modal?.close();
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
open,
|
|
86
|
-
close
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function useAppKitState() {
|
|
90
|
-
if (!modal) {
|
|
91
|
-
throw new Error('Please call "createAppKit" before using "useAppKitState" hook');
|
|
92
|
-
}
|
|
93
|
-
const [state, setState] = (0, _react.useState)(modal.getState());
|
|
94
|
-
(0, _react.useEffect)(() => {
|
|
95
|
-
const unsubscribe = modal?.subscribeState(newState => {
|
|
96
|
-
if (newState) setState({
|
|
97
|
-
...newState
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
return () => {
|
|
101
|
-
unsubscribe?.();
|
|
102
|
-
};
|
|
103
|
-
}, []);
|
|
104
|
-
return state;
|
|
105
|
-
}
|
|
106
|
-
function useAppKitProvider() {
|
|
107
|
-
const {
|
|
108
|
-
provider,
|
|
109
|
-
providerType
|
|
110
|
-
} = (0, _valtio.useSnapshot)(_appkitScaffoldUtilsReactNative.EthersStoreUtil.state);
|
|
111
|
-
const walletProvider = provider;
|
|
112
|
-
const walletProviderType = providerType;
|
|
113
|
-
return {
|
|
114
|
-
walletProvider,
|
|
115
|
-
walletProviderType
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function useDisconnect() {
|
|
119
|
-
async function disconnect() {
|
|
120
|
-
await modal?.disconnect();
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
disconnect
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function useAppKitAccount() {
|
|
127
|
-
const {
|
|
128
|
-
address,
|
|
129
|
-
isConnected,
|
|
130
|
-
chainId
|
|
131
|
-
} = (0, _valtio.useSnapshot)(_appkitScaffoldUtilsReactNative.EthersStoreUtil.state);
|
|
132
|
-
return {
|
|
133
|
-
address,
|
|
134
|
-
isConnected,
|
|
135
|
-
chainId
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function useWalletInfo() {
|
|
139
|
-
if (!modal) {
|
|
140
|
-
throw new Error('Please call "createAppKit" before using "useWalletInfo" hook');
|
|
141
|
-
}
|
|
142
|
-
const walletInfo = (0, _react.useSyncExternalStore)(modal.subscribeWalletInfo, modal.getWalletInfo, modal.getWalletInfo);
|
|
143
|
-
return {
|
|
144
|
-
walletInfo
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function useAppKitError() {
|
|
148
|
-
const {
|
|
149
|
-
error
|
|
150
|
-
} = (0, _valtio.useSnapshot)(_appkitScaffoldUtilsReactNative.EthersStoreUtil.state);
|
|
151
|
-
return {
|
|
152
|
-
error
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function useAppKitEvents(callback) {
|
|
156
|
-
if (!modal) {
|
|
157
|
-
throw new Error('Please call "createAppKit" before using "useAppKitEvents" hook');
|
|
158
|
-
}
|
|
159
|
-
const [event, setEvents] = (0, _react.useState)(modal.getEvent());
|
|
160
|
-
(0, _react.useEffect)(() => {
|
|
161
|
-
const unsubscribe = modal?.subscribeEvents(newEvent => {
|
|
162
|
-
setEvents({
|
|
163
|
-
...newEvent
|
|
164
|
-
});
|
|
165
|
-
callback?.(newEvent);
|
|
166
|
-
});
|
|
167
|
-
return () => {
|
|
168
|
-
unsubscribe?.();
|
|
169
|
-
};
|
|
170
|
-
}, [callback]);
|
|
171
|
-
return event;
|
|
172
|
-
}
|
|
173
|
-
function useAppKitEventSubscription(event, callback) {
|
|
174
|
-
if (!modal) {
|
|
175
|
-
throw new Error('Please call "createAppKit" before using "useAppKitEventSubscription" hook');
|
|
176
|
-
}
|
|
177
|
-
(0, _react.useEffect)(() => {
|
|
178
|
-
const unsubscribe = modal?.subscribeEvent(event, callback);
|
|
179
|
-
return () => {
|
|
180
|
-
unsubscribe?.();
|
|
181
|
-
};
|
|
182
|
-
}, [callback, event]);
|
|
183
|
-
}
|
|
12
|
+
var _adapter = require("./adapter");
|
|
184
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_adapter","require"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { EVMAdapter } from '@reown/appkit-common-react-native';
|
|
2
|
+
import { EthersHelpersUtil } from '@reown/appkit-scaffold-utils-react-native';
|
|
3
|
+
import { formatEther, getEthBalance } from './helpers';
|
|
4
|
+
export class EthersAdapter extends EVMAdapter {
|
|
5
|
+
static supportedNamespace = 'eip155';
|
|
6
|
+
constructor(configParams) {
|
|
7
|
+
super({
|
|
8
|
+
projectId: configParams.projectId,
|
|
9
|
+
supportedNamespace: EthersAdapter.supportedNamespace
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async getBalance(params) {
|
|
13
|
+
const {
|
|
14
|
+
network,
|
|
15
|
+
address
|
|
16
|
+
} = params;
|
|
17
|
+
if (!this.connector) throw new Error('No active connector');
|
|
18
|
+
if (!network) throw new Error('No network provided');
|
|
19
|
+
const balanceAddress = address || this.getAccounts()?.find(account => account.includes(network.id.toString()));
|
|
20
|
+
const balance = {
|
|
21
|
+
amount: '0.00',
|
|
22
|
+
symbol: network.nativeCurrency.symbol || 'ETH'
|
|
23
|
+
};
|
|
24
|
+
if (!balanceAddress) return balance;
|
|
25
|
+
const account = balanceAddress.split(':')[2];
|
|
26
|
+
const rpcUrl = network.rpcUrls.default.http?.[0];
|
|
27
|
+
if (!rpcUrl || !account) return balance;
|
|
28
|
+
try {
|
|
29
|
+
const wei = await getEthBalance(rpcUrl, account);
|
|
30
|
+
balance.amount = formatEther(wei);
|
|
31
|
+
this.emit('balanceChanged', {
|
|
32
|
+
address: balanceAddress,
|
|
33
|
+
balance
|
|
34
|
+
});
|
|
35
|
+
return balance;
|
|
36
|
+
} catch {
|
|
37
|
+
return balance;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async switchNetwork(network) {
|
|
41
|
+
if (!this.connector) throw new Error('No active connector');
|
|
42
|
+
const provider = this.connector.getProvider();
|
|
43
|
+
if (!provider) throw new Error('No active provider');
|
|
44
|
+
try {
|
|
45
|
+
await provider.request({
|
|
46
|
+
method: 'wallet_switchEthereumChain',
|
|
47
|
+
params: [{
|
|
48
|
+
chainId: EthersHelpersUtil.numberToHexString(Number(network.id))
|
|
49
|
+
}] //TODO: check util
|
|
50
|
+
}, `${EthersAdapter.supportedNamespace}:${network.id}`);
|
|
51
|
+
} catch (switchError) {
|
|
52
|
+
const message = switchError?.message;
|
|
53
|
+
if (/(?<temp1>user rejected)/u.test(message?.toLowerCase())) {
|
|
54
|
+
throw new Error('Chain is not supported');
|
|
55
|
+
}
|
|
56
|
+
throw switchError;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
getAccounts() {
|
|
60
|
+
if (!this.connector) throw new Error('No active connector');
|
|
61
|
+
const namespaces = this.connector.getNamespaces();
|
|
62
|
+
return namespaces[this.getSupportedNamespace()]?.accounts;
|
|
63
|
+
}
|
|
64
|
+
disconnect() {
|
|
65
|
+
if (!this.connector) throw new Error('EthersAdapter:disconnect - No active connector');
|
|
66
|
+
return this.connector.disconnect();
|
|
67
|
+
}
|
|
68
|
+
getSupportedNamespace() {
|
|
69
|
+
return EthersAdapter.supportedNamespace;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EVMAdapter","EthersHelpersUtil","formatEther","getEthBalance","EthersAdapter","supportedNamespace","constructor","configParams","projectId","getBalance","params","network","address","connector","Error","balanceAddress","getAccounts","find","account","includes","id","toString","balance","amount","symbol","nativeCurrency","split","rpcUrl","rpcUrls","default","http","wei","emit","switchNetwork","provider","getProvider","request","method","chainId","numberToHexString","Number","switchError","message","test","toLowerCase","namespaces","getNamespaces","getSupportedNamespace","accounts","disconnect"],"sourceRoot":"../../src","sources":["adapter.ts"],"mappings":"AAAA,SACEA,UAAU,QAML,mCAAmC;AAC1C,SAASC,iBAAiB,QAAQ,2CAA2C;AAC7E,SAASC,WAAW,EAAEC,aAAa,QAAQ,WAAW;AAEtD,OAAO,MAAMC,aAAa,SAASJ,UAAU,CAAC;EAC5C,OAAeK,kBAAkB,GAAmB,QAAQ;EA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E,MAAM,IAAIC,KAAK,CAAC,gDAAgD,CAAC;IAEtF,OAAO,IAAI,CAACD,SAAS,CAACoC,UAAU,CAAC,CAAC;EACpC;EAEAF,qBAAqBA,CAAA,EAAmB;IACtC,OAAO3C,aAAa,CAACC,kBAAkB;EACzC;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Helper to convert Wei (as string or bigint) to ETH
|
|
2
|
+
export const formatEther = wei => {
|
|
3
|
+
return (Number(wei) / 1e18).toString();
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
// Raw JSON-RPC for balance lookup
|
|
7
|
+
export async function getEthBalance(rpcUrl, address) {
|
|
8
|
+
const body = {
|
|
9
|
+
jsonrpc: '2.0',
|
|
10
|
+
method: 'eth_getBalance',
|
|
11
|
+
params: [address, 'latest'],
|
|
12
|
+
id: 1
|
|
13
|
+
};
|
|
14
|
+
const response = await fetch(rpcUrl, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: {
|
|
17
|
+
'Content-Type': 'application/json'
|
|
18
|
+
},
|
|
19
|
+
body: JSON.stringify(body)
|
|
20
|
+
});
|
|
21
|
+
const json = await response.json();
|
|
22
|
+
if (json.error) throw new Error(json.error.message);
|
|
23
|
+
return BigInt(json.result); // result is hex string
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["formatEther","wei","Number","toString","getEthBalance","rpcUrl","address","body","jsonrpc","method","params","id","response","fetch","headers","JSON","stringify","json","error","Error","message","BigInt","result"],"sourceRoot":"../../src","sources":["helpers.ts"],"mappings":"AAAA;AACA,OAAO,MAAMA,WAAW,GAAIC,GAAW,IAAa;EAClD,OAAO,CAACC,MAAM,CAACD,GAAG,CAAC,GAAG,IAAI,EAAEE,QAAQ,CAAC,CAAC;AACxC,CAAC;;AAED;AACA,OAAO,eAAeC,aAAaA,CAACC,MAAc,EAAEC,OAAe,EAAmB;EACpF,MAAMC,IAAI,GAAG;IACXC,OAAO,EAAE,KAAK;IACdC,MAAM,EAAE,gBAAgB;IACxBC,MAAM,EAAE,CAACJ,OAAO,EAAE,QAAQ,CAAC;IAC3BK,EAAE,EAAE;EACN,CAAC;EAED,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAACR,MAAM,EAAE;IACnCI,MAAM,EAAE,MAAM;IACdK,OAAO,EAAE;MAAE,cAAc,EAAE;IAAmB,CAAC;IAC/CP,IAAI,EAAEQ,IAAI,CAACC,SAAS,CAACT,IAAI;EAC3B,CAAC,CAAC;EAEF,MAAMU,IAAI,GAAG,MAAML,QAAQ,CAACK,IAAI,CAAC,CAAC;EAClC,IAAIA,IAAI,CAACC,KAAK,EAAE,MAAM,IAAIC,KAAK,CAACF,IAAI,CAACC,KAAK,CAACE,OAAO,CAAC;EAEnD,OAAOC,MAAM,CAACJ,IAAI,CAACK,MAAM,CAAC,CAAC,CAAC;AAC9B"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,134 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { EthersStoreUtil } from '@reown/appkit-scaffold-utils-react-native';
|
|
4
|
-
export { AccountButton, AppKitButton, ConnectButton, NetworkButton, AppKit } from '@reown/appkit-scaffold-react-native';
|
|
5
|
-
import { ConstantsUtil } from '@reown/appkit-common-react-native';
|
|
6
|
-
export { defaultConfig } from './utils/defaultConfig';
|
|
7
|
-
import { AppKit } from './client';
|
|
8
|
-
|
|
9
|
-
// -- Types -------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
// -- Setup -------------------------------------------------------------------
|
|
12
|
-
let modal;
|
|
13
|
-
export function createAppKit(options) {
|
|
14
|
-
if (!modal) {
|
|
15
|
-
modal = new AppKit({
|
|
16
|
-
...options,
|
|
17
|
-
_sdkVersion: `react-native-ethers-${ConstantsUtil.VERSION}`
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return modal;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// -- Hooks -------------------------------------------------------------------
|
|
24
|
-
export function useAppKit() {
|
|
25
|
-
if (!modal) {
|
|
26
|
-
throw new Error('Please call "createAppKit" before using "useAppKit" hook');
|
|
27
|
-
}
|
|
28
|
-
async function open(options) {
|
|
29
|
-
await modal?.open(options);
|
|
30
|
-
}
|
|
31
|
-
async function close() {
|
|
32
|
-
await modal?.close();
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
open,
|
|
36
|
-
close
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export function useAppKitState() {
|
|
40
|
-
if (!modal) {
|
|
41
|
-
throw new Error('Please call "createAppKit" before using "useAppKitState" hook');
|
|
42
|
-
}
|
|
43
|
-
const [state, setState] = useState(modal.getState());
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const unsubscribe = modal?.subscribeState(newState => {
|
|
46
|
-
if (newState) setState({
|
|
47
|
-
...newState
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
return () => {
|
|
51
|
-
unsubscribe?.();
|
|
52
|
-
};
|
|
53
|
-
}, []);
|
|
54
|
-
return state;
|
|
55
|
-
}
|
|
56
|
-
export function useAppKitProvider() {
|
|
57
|
-
const {
|
|
58
|
-
provider,
|
|
59
|
-
providerType
|
|
60
|
-
} = useSnapshot(EthersStoreUtil.state);
|
|
61
|
-
const walletProvider = provider;
|
|
62
|
-
const walletProviderType = providerType;
|
|
63
|
-
return {
|
|
64
|
-
walletProvider,
|
|
65
|
-
walletProviderType
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export function useDisconnect() {
|
|
69
|
-
async function disconnect() {
|
|
70
|
-
await modal?.disconnect();
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
disconnect
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
export function useAppKitAccount() {
|
|
77
|
-
const {
|
|
78
|
-
address,
|
|
79
|
-
isConnected,
|
|
80
|
-
chainId
|
|
81
|
-
} = useSnapshot(EthersStoreUtil.state);
|
|
82
|
-
return {
|
|
83
|
-
address,
|
|
84
|
-
isConnected,
|
|
85
|
-
chainId
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
export function useWalletInfo() {
|
|
89
|
-
if (!modal) {
|
|
90
|
-
throw new Error('Please call "createAppKit" before using "useWalletInfo" hook');
|
|
91
|
-
}
|
|
92
|
-
const walletInfo = useSyncExternalStore(modal.subscribeWalletInfo, modal.getWalletInfo, modal.getWalletInfo);
|
|
93
|
-
return {
|
|
94
|
-
walletInfo
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
export function useAppKitError() {
|
|
98
|
-
const {
|
|
99
|
-
error
|
|
100
|
-
} = useSnapshot(EthersStoreUtil.state);
|
|
101
|
-
return {
|
|
102
|
-
error
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
export function useAppKitEvents(callback) {
|
|
106
|
-
if (!modal) {
|
|
107
|
-
throw new Error('Please call "createAppKit" before using "useAppKitEvents" hook');
|
|
108
|
-
}
|
|
109
|
-
const [event, setEvents] = useState(modal.getEvent());
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
const unsubscribe = modal?.subscribeEvents(newEvent => {
|
|
112
|
-
setEvents({
|
|
113
|
-
...newEvent
|
|
114
|
-
});
|
|
115
|
-
callback?.(newEvent);
|
|
116
|
-
});
|
|
117
|
-
return () => {
|
|
118
|
-
unsubscribe?.();
|
|
119
|
-
};
|
|
120
|
-
}, [callback]);
|
|
121
|
-
return event;
|
|
122
|
-
}
|
|
123
|
-
export function useAppKitEventSubscription(event, callback) {
|
|
124
|
-
if (!modal) {
|
|
125
|
-
throw new Error('Please call "createAppKit" before using "useAppKitEventSubscription" hook');
|
|
126
|
-
}
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
const unsubscribe = modal?.subscribeEvent(event, callback);
|
|
129
|
-
return () => {
|
|
130
|
-
unsubscribe?.();
|
|
131
|
-
};
|
|
132
|
-
}, [callback, event]);
|
|
133
|
-
}
|
|
1
|
+
import { EthersAdapter } from './adapter';
|
|
2
|
+
export { EthersAdapter };
|
|
134
3
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["EthersAdapter"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,QAAQ,WAAW;AACzC,SAASA,aAAa"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EVMAdapter, type AppKitNetwork, type CaipAddress, type ChainNamespace, type GetBalanceParams, type GetBalanceResponse } from '@reown/appkit-common-react-native';
|
|
2
|
+
export declare class EthersAdapter extends EVMAdapter {
|
|
3
|
+
private static supportedNamespace;
|
|
4
|
+
constructor(configParams: {
|
|
5
|
+
projectId: string;
|
|
6
|
+
});
|
|
7
|
+
getBalance(params: GetBalanceParams): Promise<GetBalanceResponse>;
|
|
8
|
+
switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
9
|
+
getAccounts(): CaipAddress[] | undefined;
|
|
10
|
+
disconnect(): Promise<void>;
|
|
11
|
+
getSupportedNamespace(): ChainNamespace;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,mCAAmC,CAAC;AAI3C,qBAAa,aAAc,SAAQ,UAAU;IAC3C,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA4B;gBAEjD,YAAY,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE;IAOzC,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgCjE,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB1D,WAAW,IAAI,WAAW,EAAE,GAAG,SAAS;IAOxC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B,qBAAqB,IAAI,cAAc;CAGxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,MAEzC,CAAC;AAGF,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBpF"}
|
|
@@ -1,40 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import type { EventName, EventsControllerState } from '@reown/appkit-scaffold-react-native';
|
|
4
|
-
export { defaultConfig } from './utils/defaultConfig';
|
|
5
|
-
import { AppKit, type AppKitOptions } from './client';
|
|
6
|
-
export type { AppKitOptions } from './client';
|
|
7
|
-
type OpenOptions = Parameters<AppKit['open']>[0];
|
|
8
|
-
export declare function createAppKit(options: AppKitOptions): AppKit;
|
|
9
|
-
export declare function useAppKit(): {
|
|
10
|
-
open: (options?: OpenOptions) => Promise<void>;
|
|
11
|
-
close: () => Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
export declare function useAppKitState(): {
|
|
14
|
-
selectedNetworkId: number | undefined;
|
|
15
|
-
open: boolean;
|
|
16
|
-
};
|
|
17
|
-
export declare function useAppKitProvider(): {
|
|
18
|
-
walletProvider: Provider | undefined;
|
|
19
|
-
walletProviderType: "WALLET_CONNECT" | "COINBASE" | "AUTH" | "EXTERNAL" | undefined;
|
|
20
|
-
};
|
|
21
|
-
export declare function useDisconnect(): {
|
|
22
|
-
disconnect: () => Promise<void>;
|
|
23
|
-
};
|
|
24
|
-
export declare function useAppKitAccount(): {
|
|
25
|
-
address: `0x${string}` | undefined;
|
|
26
|
-
isConnected: boolean;
|
|
27
|
-
chainId: number | undefined;
|
|
28
|
-
};
|
|
29
|
-
export declare function useWalletInfo(): {
|
|
30
|
-
walletInfo: import("@reown/appkit-scaffold-react-native").ConnectedWalletInfo;
|
|
31
|
-
};
|
|
32
|
-
export declare function useAppKitError(): {
|
|
33
|
-
error: unknown;
|
|
34
|
-
};
|
|
35
|
-
export declare function useAppKitEvents(callback?: (newEvent: EventsControllerState) => void): {
|
|
36
|
-
timestamp: number;
|
|
37
|
-
data: import("@reown/appkit-scaffold-react-native").Event;
|
|
38
|
-
};
|
|
39
|
-
export declare function useAppKitEventSubscription(event: EventName, callback: (newEvent: EventsControllerState) => void): void;
|
|
1
|
+
import { EthersAdapter } from './adapter';
|
|
2
|
+
export { EthersAdapter };
|
|
40
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,CAAC"}
|