@reown/appkit-common-react-native 0.0.0-feat-multichain-20250520183003 → 0.0.0-feat-onramp-20250602154313
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/utils/ConstantsUtil.js +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/PresetsUtil.js +3 -34
- package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
- package/lib/commonjs/utils/TypeUtil.js +0 -104
- package/lib/commonjs/utils/TypeUtil.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +1 -1
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/PresetsUtil.js +3 -34
- package/lib/module/utils/PresetsUtil.js.map +1 -1
- package/lib/module/utils/TypeUtil.js +0 -96
- package/lib/module/utils/TypeUtil.js.map +1 -1
- package/lib/typescript/utils/PresetsUtil.d.ts +1 -1
- package/lib/typescript/utils/PresetsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TypeUtil.d.ts +0 -175
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/utils/ConstantsUtil.ts +1 -1
- package/src/utils/PresetsUtil.ts +3 -36
- package/src/utils/TypeUtil.ts +0 -280
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ConstantsUtil = void 0;
|
|
7
7
|
const ConstantsUtil = exports.ConstantsUtil = {
|
|
8
|
-
VERSION: '0.0.0-feat-
|
|
8
|
+
VERSION: '0.0.0-feat-onramp-20250602154313',
|
|
9
9
|
EIP155: 'eip155',
|
|
10
10
|
ADD_CHAIN_METHOD: 'wallet_addEthereumChain',
|
|
11
11
|
WC_NAME_SUFFIX: '.reown.id',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ConstantsUtil","exports","VERSION","EIP155","ADD_CHAIN_METHOD","WC_NAME_SUFFIX","WC_NAME_SUFFIX_LEGACY","BLOCKCHAIN_API_RPC_URL","BLOCKCHAIN_API_RPC_URL_STAGING","PULSE_API_URL","API_URL","WALLET_CONNECT_CONNECTOR_ID","COINBASE_CONNECTOR_ID","AUTH_CONNECTOR_ID","COINBASE_EXPLORER_ID","USDT_CONTRACT_ADDRESSES"],"sourceRoot":"../../../src","sources":["utils/ConstantsUtil.ts"],"mappings":";;;;;;AAAO,MAAMA,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG;EAC3BE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"names":["ConstantsUtil","exports","VERSION","EIP155","ADD_CHAIN_METHOD","WC_NAME_SUFFIX","WC_NAME_SUFFIX_LEGACY","BLOCKCHAIN_API_RPC_URL","BLOCKCHAIN_API_RPC_URL_STAGING","PULSE_API_URL","API_URL","WALLET_CONNECT_CONNECTOR_ID","COINBASE_CONNECTOR_ID","AUTH_CONNECTOR_ID","COINBASE_EXPLORER_ID","USDT_CONTRACT_ADDRESSES"],"sourceRoot":"../../../src","sources":["utils/ConstantsUtil.ts"],"mappings":";;;;;;AAAO,MAAMA,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG;EAC3BE,OAAO,EAAE,kCAAkC;EAE3CC,MAAM,EAAE,QAAQ;EAChBC,gBAAgB,EAAE,yBAAyB;EAE3CC,cAAc,EAAE,WAAW;EAC3BC,qBAAqB,EAAE,SAAS;EAEhCC,sBAAsB,EAAE,+BAA+B;EACvDC,8BAA8B,EAAE,uCAAuC;EACvEC,aAAa,EAAE,iCAAiC;EAChDC,OAAO,EAAE,2BAA2B;EAEpCC,2BAA2B,EAAE,eAAe;EAC5CC,qBAAqB,EAAE,gBAAgB;EACvCC,iBAAiB,EAAE,YAAY;EAE/BC,oBAAoB,EAAE,kEAAkE;EAExFC,uBAAuB,EAAE;EACvB;EACA,4CAA4C;EAC5C;EACA,4CAA4C;EAC5C;EACA,4CAA4C;EAC5C;EACA,4CAA4C;EAC5C;EACA,4CAA4C;EAC5C;EACA,4CAA4C;EAC5C;EACA,4CAA4C;AAEhD,CAAC"}
|
|
@@ -9,11 +9,11 @@ const PresetsUtil = exports.PresetsUtil = {
|
|
|
9
9
|
ConnectorExplorerIds: {
|
|
10
10
|
[_ConstantsUtil.ConstantsUtil.COINBASE_CONNECTOR_ID]: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa'
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
EIP155NetworkImageIds: {
|
|
13
13
|
// Ethereum
|
|
14
14
|
1: 'ba0ba0cd-17c6-4806-ad93-f9d174f17900',
|
|
15
15
|
// Arbitrum
|
|
16
|
-
42161: '
|
|
16
|
+
42161: '600a9a04-c1b9-42ca-6785-9b4b6ff85200',
|
|
17
17
|
// Avalanche
|
|
18
18
|
43114: '30c46e53-e989-45fb-4549-be3bd4eb3b00',
|
|
19
19
|
// Binance Smart Chain
|
|
@@ -24,20 +24,6 @@ const PresetsUtil = exports.PresetsUtil = {
|
|
|
24
24
|
10: 'ab9c186a-c52f-464b-2906-ca59d760a400',
|
|
25
25
|
// Polygon
|
|
26
26
|
137: '41d04d42-da3b-4453-8506-668cc0727900',
|
|
27
|
-
// Mantle
|
|
28
|
-
5000: 'e86fae9b-b770-4eea-e520-150e12c81100',
|
|
29
|
-
// Hedera Mainnet
|
|
30
|
-
295: '6a97d510-cac8-4e58-c7ce-e8681b044c00',
|
|
31
|
-
// Sepolia
|
|
32
|
-
11_155_111: 'e909ea0a-f92a-4512-c8fc-748044ea6800',
|
|
33
|
-
// Base Sepolia
|
|
34
|
-
84532: 'a18a7ecd-e307-4360-4746-283182228e00',
|
|
35
|
-
// Unichain Sepolia
|
|
36
|
-
1301: '4eeea7ef-0014-4649-5d1d-07271a80f600',
|
|
37
|
-
// Unichain Mainnet
|
|
38
|
-
130: '2257980a-3463-48c6-cbac-a42d2a956e00',
|
|
39
|
-
// Monad Testnet
|
|
40
|
-
10_143: '0a728e83-bacb-46db-7844-948f05434900',
|
|
41
27
|
// Gnosis
|
|
42
28
|
100: '02b53f6a-e3d4-479e-1cb4-21178987d100',
|
|
43
29
|
// EVMos
|
|
@@ -61,24 +47,7 @@ const PresetsUtil = exports.PresetsUtil = {
|
|
|
61
47
|
// Base
|
|
62
48
|
8453: '7289c336-3981-4081-c5f4-efc26ac64a00',
|
|
63
49
|
// Aurora
|
|
64
|
-
1313161554: '3ff73439-a619-4894-9262-4470c773a100'
|
|
65
|
-
// Ronin Mainnet
|
|
66
|
-
2020: 'b8101fc0-9c19-4b6f-ec65-f6dfff106e00',
|
|
67
|
-
// Saigon Testnet (a.k.a. Ronin)
|
|
68
|
-
2021: 'b8101fc0-9c19-4b6f-ec65-f6dfff106e00',
|
|
69
|
-
// Berachain Mainnet
|
|
70
|
-
80094: 'e329c2c9-59b0-4a02-83e4-212ff3779900',
|
|
71
|
-
// Abstract Mainnet
|
|
72
|
-
2741: 'fc2427d1-5af9-4a9c-8da5-6f94627cd900',
|
|
73
|
-
// Solana networks
|
|
74
|
-
/// Mainnet
|
|
75
|
-
'5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': 'a1b58899-f671-4276-6a5e-56ca5bd59700',
|
|
76
|
-
/// Testnet
|
|
77
|
-
'4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z': 'a1b58899-f671-4276-6a5e-56ca5bd59700',
|
|
78
|
-
// Bitcoin
|
|
79
|
-
'000000000019d6689c085ae165831e93': '0b4838db-0161-4ffe-022d-532bf03dba00',
|
|
80
|
-
// Bitcoin Testnet
|
|
81
|
-
'000000000933ea01ad0ee984209779ba': '39354064-d79b-420b-065d-f980c4b78200'
|
|
50
|
+
1313161554: '3ff73439-a619-4894-9262-4470c773a100'
|
|
82
51
|
},
|
|
83
52
|
ConnectorNamesMap: {
|
|
84
53
|
[_ConstantsUtil.ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]: 'WalletConnect',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ConstantsUtil","require","PresetsUtil","exports","ConnectorExplorerIds","ConstantsUtil","COINBASE_CONNECTOR_ID","
|
|
1
|
+
{"version":3,"names":["_ConstantsUtil","require","PresetsUtil","exports","ConnectorExplorerIds","ConstantsUtil","COINBASE_CONNECTOR_ID","EIP155NetworkImageIds","ConnectorNamesMap","WALLET_CONNECT_CONNECTOR_ID","AUTH_CONNECTOR_ID","ConnectorImageIds","ConnectorTypesMap","RpcChainIds"],"sourceRoot":"../../../src","sources":["utils/PresetsUtil.ts"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzBE,oBAAoB,EAAE;IACpB,CAACC,4BAAa,CAACC,qBAAqB,GAClC;EACJ,CAA2B;EAE3BC,qBAAqB,EAAE;IACrB;IACA,CAAC,EAAE,sCAAsC;IACzC;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,EAAE,EAAE,sCAAsC;IAC1C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,EAAE,EAAE,sCAAsC;IAC1C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,OAAO,EAAE,sCAAsC;IAC/C;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,UAAU,EAAE;EACd,CAA2B;EAE3BC,iBAAiB,EAAE;IACjB,CAACH,4BAAa,CAACI,2BAA2B,GAAG,eAAe;IAC5D,CAACJ,4BAAa,CAACC,qBAAqB,GAAG,iBAAiB;IACxD,CAACD,4BAAa,CAACK,iBAAiB,GAAG;EACrC,CAA2B;EAE3BC,iBAAiB,EAAE;IACjB,CAACN,4BAAa,CAACC,qBAAqB,GAAG,sCAAsC;IAC7E,CAACD,4BAAa,CAACI,2BAA2B,GAAG;EAC/C,CAA2B;EAE3BG,iBAAiB,EAAE;IACjB,CAACP,4BAAa,CAACI,2BAA2B,GAAG,gBAAgB;IAC7D,CAACJ,4BAAa,CAACC,qBAAqB,GAAG,UAAU;IACjD,CAACD,4BAAa,CAACK,iBAAiB,GAAG;EACrC,CAAkC;EAElCG,WAAW,EAAE;EACX;EACA,CAAC;EACD;EACA,CAAC;EACD;EACA,QAAQ;EACR;EACA,EAAE;EACF;EACA,GAAG;EACH;EACA,KAAK;EACL;EACA,MAAM;EACN;EACA,GAAG;EACH;EACA,KAAK;EACL;EACA,KAAK;EACL;EACA,UAAU;EACV;EACA,UAAU;EACV;EACA,EAAE;EACF;EACA,EAAE;EACF;EACA,KAAK;EACL;EACA,KAAK;EACL;EACA,GAAG;EACH;EACA,IAAI;EACJ;EACA,KAAK;EACL;EACA,OAAO;EACP;EACA,GAAG;EACH;EACA,GAAG;EACH;EACA,GAAG;AAEP,CAAC"}
|
|
@@ -1,106 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.WalletConnector = exports.SolanaBaseAdapter = exports.EVMAdapter = exports.BlockchainAdapter = void 0;
|
|
7
|
-
var _events = require("events");
|
|
8
|
-
//********** Adapter Event Payloads **********//
|
|
9
|
-
|
|
10
|
-
//********** Adapter Event Map **********//
|
|
11
|
-
|
|
12
|
-
//********** Adapter Types **********//
|
|
13
|
-
class BlockchainAdapter extends _events.EventEmitter {
|
|
14
|
-
// Typed emit method
|
|
15
|
-
emit(event, payload) {
|
|
16
|
-
return super.emit(event, payload);
|
|
17
|
-
}
|
|
18
|
-
constructor({
|
|
19
|
-
projectId,
|
|
20
|
-
supportedNamespace
|
|
21
|
-
}) {
|
|
22
|
-
super();
|
|
23
|
-
this.projectId = projectId;
|
|
24
|
-
this.supportedNamespace = supportedNamespace;
|
|
25
|
-
}
|
|
26
|
-
setConnector(connector) {
|
|
27
|
-
this.connector = connector;
|
|
28
|
-
this.subscribeToEvents();
|
|
29
|
-
}
|
|
30
|
-
removeConnector() {
|
|
31
|
-
this.connector = undefined;
|
|
32
|
-
}
|
|
33
|
-
getProvider() {
|
|
34
|
-
if (!this.connector) throw new Error('No active connector');
|
|
35
|
-
return this.connector.getProvider();
|
|
36
|
-
}
|
|
37
|
-
subscribeToEvents() {
|
|
38
|
-
const provider = this.connector?.getProvider();
|
|
39
|
-
if (!provider) return;
|
|
40
|
-
provider.on('chainChanged', this.onChainChanged.bind(this));
|
|
41
|
-
provider.on('accountsChanged', this.onAccountsChanged.bind(this));
|
|
42
|
-
provider.on('disconnect', this.onDisconnect.bind(this));
|
|
43
|
-
}
|
|
44
|
-
onChainChanged(chainId) {
|
|
45
|
-
const _chains = this.getAccounts()?.map(account => account.split(':')[1]);
|
|
46
|
-
const shouldEmit = _chains?.some(chain => chain === chainId);
|
|
47
|
-
if (shouldEmit) {
|
|
48
|
-
this.emit('chainChanged', {
|
|
49
|
-
chainId,
|
|
50
|
-
namespace: this.getSupportedNamespace()
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
onAccountsChanged(accounts) {
|
|
55
|
-
const _accounts = this.getAccounts();
|
|
56
|
-
const shouldEmit = _accounts?.some(account => {
|
|
57
|
-
const accountAddress = account.split(':')[2];
|
|
58
|
-
return accountAddress !== undefined && accounts.includes(accountAddress);
|
|
59
|
-
});
|
|
60
|
-
if (shouldEmit) {
|
|
61
|
-
this.emit('accountsChanged', {
|
|
62
|
-
accounts,
|
|
63
|
-
namespace: this.getSupportedNamespace()
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
onDisconnect() {
|
|
68
|
-
this.emit('disconnect', {
|
|
69
|
-
namespace: this.getSupportedNamespace()
|
|
70
|
-
});
|
|
71
|
-
const provider = this.connector?.getProvider();
|
|
72
|
-
if (provider) {
|
|
73
|
-
provider.off('chainChanged', this.onChainChanged.bind(this));
|
|
74
|
-
provider.off('accountsChanged', this.onAccountsChanged.bind(this));
|
|
75
|
-
provider.off('disconnect', this.onDisconnect.bind(this));
|
|
76
|
-
}
|
|
77
|
-
this.connector = undefined;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.BlockchainAdapter = BlockchainAdapter;
|
|
81
|
-
class EVMAdapter extends BlockchainAdapter {
|
|
82
|
-
// ens logic
|
|
83
|
-
}
|
|
84
|
-
exports.EVMAdapter = EVMAdapter;
|
|
85
|
-
class SolanaBaseAdapter extends BlockchainAdapter {}
|
|
86
|
-
|
|
87
|
-
//********** Connector Types **********//
|
|
88
|
-
exports.SolanaBaseAdapter = SolanaBaseAdapter;
|
|
89
|
-
class WalletConnector extends _events.EventEmitter {
|
|
90
|
-
constructor({
|
|
91
|
-
type,
|
|
92
|
-
provider
|
|
93
|
-
}) {
|
|
94
|
-
super();
|
|
95
|
-
this.type = type;
|
|
96
|
-
this.provider = provider;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
//********** Provider Types **********//
|
|
101
|
-
|
|
102
|
-
//TODO: rename this and remove the old one ConnectorType
|
|
103
|
-
|
|
104
|
-
//********** Others **********//
|
|
105
|
-
exports.WalletConnector = WalletConnector;
|
|
106
2
|
//# sourceMappingURL=TypeUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/TypeUtil.ts"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ConstantsUtil","VERSION","EIP155","ADD_CHAIN_METHOD","WC_NAME_SUFFIX","WC_NAME_SUFFIX_LEGACY","BLOCKCHAIN_API_RPC_URL","BLOCKCHAIN_API_RPC_URL_STAGING","PULSE_API_URL","API_URL","WALLET_CONNECT_CONNECTOR_ID","COINBASE_CONNECTOR_ID","AUTH_CONNECTOR_ID","COINBASE_EXPLORER_ID","USDT_CONTRACT_ADDRESSES"],"sourceRoot":"../../../src","sources":["utils/ConstantsUtil.ts"],"mappings":"AAAA,OAAO,MAAMA,aAAa,GAAG;EAC3BC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"names":["ConstantsUtil","VERSION","EIP155","ADD_CHAIN_METHOD","WC_NAME_SUFFIX","WC_NAME_SUFFIX_LEGACY","BLOCKCHAIN_API_RPC_URL","BLOCKCHAIN_API_RPC_URL_STAGING","PULSE_API_URL","API_URL","WALLET_CONNECT_CONNECTOR_ID","COINBASE_CONNECTOR_ID","AUTH_CONNECTOR_ID","COINBASE_EXPLORER_ID","USDT_CONTRACT_ADDRESSES"],"sourceRoot":"../../../src","sources":["utils/ConstantsUtil.ts"],"mappings":"AAAA,OAAO,MAAMA,aAAa,GAAG;EAC3BC,OAAO,EAAE,kCAAkC;EAE3CC,MAAM,EAAE,QAAQ;EAChBC,gBAAgB,EAAE,yBAAyB;EAE3CC,cAAc,EAAE,WAAW;EAC3BC,qBAAqB,EAAE,SAAS;EAEhCC,sBAAsB,EAAE,+BAA+B;EACvDC,8BAA8B,EAAE,uCAAuC;EACvEC,aAAa,EAAE,iCAAiC;EAChDC,OAAO,EAAE,2BAA2B;EAEpCC,2BAA2B,EAAE,eAAe;EAC5CC,qBAAqB,EAAE,gBAAgB;EACvCC,iBAAiB,EAAE,YAAY;EAE/BC,oBAAoB,EAAE,kEAAkE;EAExFC,uBAAuB,EAAE;EACvB;EACA,4CAA4C;EAC5C;EACA,4CAA4C;EAC5C;EACA,4CAA4C;EAC5C;EACA,4CAA4C;EAC5C;EACA,4CAA4C;EAC5C;EACA,4CAA4C;EAC5C;EACA,4CAA4C;AAEhD,CAAC"}
|
|
@@ -3,11 +3,11 @@ export const PresetsUtil = {
|
|
|
3
3
|
ConnectorExplorerIds: {
|
|
4
4
|
[ConstantsUtil.COINBASE_CONNECTOR_ID]: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa'
|
|
5
5
|
},
|
|
6
|
-
|
|
6
|
+
EIP155NetworkImageIds: {
|
|
7
7
|
// Ethereum
|
|
8
8
|
1: 'ba0ba0cd-17c6-4806-ad93-f9d174f17900',
|
|
9
9
|
// Arbitrum
|
|
10
|
-
42161: '
|
|
10
|
+
42161: '600a9a04-c1b9-42ca-6785-9b4b6ff85200',
|
|
11
11
|
// Avalanche
|
|
12
12
|
43114: '30c46e53-e989-45fb-4549-be3bd4eb3b00',
|
|
13
13
|
// Binance Smart Chain
|
|
@@ -18,20 +18,6 @@ export const PresetsUtil = {
|
|
|
18
18
|
10: 'ab9c186a-c52f-464b-2906-ca59d760a400',
|
|
19
19
|
// Polygon
|
|
20
20
|
137: '41d04d42-da3b-4453-8506-668cc0727900',
|
|
21
|
-
// Mantle
|
|
22
|
-
5000: 'e86fae9b-b770-4eea-e520-150e12c81100',
|
|
23
|
-
// Hedera Mainnet
|
|
24
|
-
295: '6a97d510-cac8-4e58-c7ce-e8681b044c00',
|
|
25
|
-
// Sepolia
|
|
26
|
-
11_155_111: 'e909ea0a-f92a-4512-c8fc-748044ea6800',
|
|
27
|
-
// Base Sepolia
|
|
28
|
-
84532: 'a18a7ecd-e307-4360-4746-283182228e00',
|
|
29
|
-
// Unichain Sepolia
|
|
30
|
-
1301: '4eeea7ef-0014-4649-5d1d-07271a80f600',
|
|
31
|
-
// Unichain Mainnet
|
|
32
|
-
130: '2257980a-3463-48c6-cbac-a42d2a956e00',
|
|
33
|
-
// Monad Testnet
|
|
34
|
-
10_143: '0a728e83-bacb-46db-7844-948f05434900',
|
|
35
21
|
// Gnosis
|
|
36
22
|
100: '02b53f6a-e3d4-479e-1cb4-21178987d100',
|
|
37
23
|
// EVMos
|
|
@@ -55,24 +41,7 @@ export const PresetsUtil = {
|
|
|
55
41
|
// Base
|
|
56
42
|
8453: '7289c336-3981-4081-c5f4-efc26ac64a00',
|
|
57
43
|
// Aurora
|
|
58
|
-
1313161554: '3ff73439-a619-4894-9262-4470c773a100'
|
|
59
|
-
// Ronin Mainnet
|
|
60
|
-
2020: 'b8101fc0-9c19-4b6f-ec65-f6dfff106e00',
|
|
61
|
-
// Saigon Testnet (a.k.a. Ronin)
|
|
62
|
-
2021: 'b8101fc0-9c19-4b6f-ec65-f6dfff106e00',
|
|
63
|
-
// Berachain Mainnet
|
|
64
|
-
80094: 'e329c2c9-59b0-4a02-83e4-212ff3779900',
|
|
65
|
-
// Abstract Mainnet
|
|
66
|
-
2741: 'fc2427d1-5af9-4a9c-8da5-6f94627cd900',
|
|
67
|
-
// Solana networks
|
|
68
|
-
/// Mainnet
|
|
69
|
-
'5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': 'a1b58899-f671-4276-6a5e-56ca5bd59700',
|
|
70
|
-
/// Testnet
|
|
71
|
-
'4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z': 'a1b58899-f671-4276-6a5e-56ca5bd59700',
|
|
72
|
-
// Bitcoin
|
|
73
|
-
'000000000019d6689c085ae165831e93': '0b4838db-0161-4ffe-022d-532bf03dba00',
|
|
74
|
-
// Bitcoin Testnet
|
|
75
|
-
'000000000933ea01ad0ee984209779ba': '39354064-d79b-420b-065d-f980c4b78200'
|
|
44
|
+
1313161554: '3ff73439-a619-4894-9262-4470c773a100'
|
|
76
45
|
},
|
|
77
46
|
ConnectorNamesMap: {
|
|
78
47
|
[ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]: 'WalletConnect',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ConstantsUtil","PresetsUtil","ConnectorExplorerIds","COINBASE_CONNECTOR_ID","
|
|
1
|
+
{"version":3,"names":["ConstantsUtil","PresetsUtil","ConnectorExplorerIds","COINBASE_CONNECTOR_ID","EIP155NetworkImageIds","ConnectorNamesMap","WALLET_CONNECT_CONNECTOR_ID","AUTH_CONNECTOR_ID","ConnectorImageIds","ConnectorTypesMap","RpcChainIds"],"sourceRoot":"../../../src","sources":["utils/PresetsUtil.ts"],"mappings":"AACA,SAASA,aAAa,QAAQ,iBAAiB;AAE/C,OAAO,MAAMC,WAAW,GAAG;EACzBC,oBAAoB,EAAE;IACpB,CAACF,aAAa,CAACG,qBAAqB,GAClC;EACJ,CAA2B;EAE3BC,qBAAqB,EAAE;IACrB;IACA,CAAC,EAAE,sCAAsC;IACzC;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,EAAE,EAAE,sCAAsC;IAC1C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,EAAE,EAAE,sCAAsC;IAC1C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,OAAO,EAAE,sCAAsC;IAC/C;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,UAAU,EAAE;EACd,CAA2B;EAE3BC,iBAAiB,EAAE;IACjB,CAACL,aAAa,CAACM,2BAA2B,GAAG,eAAe;IAC5D,CAACN,aAAa,CAACG,qBAAqB,GAAG,iBAAiB;IACxD,CAACH,aAAa,CAACO,iBAAiB,GAAG;EACrC,CAA2B;EAE3BC,iBAAiB,EAAE;IACjB,CAACR,aAAa,CAACG,qBAAqB,GAAG,sCAAsC;IAC7E,CAACH,aAAa,CAACM,2BAA2B,GAAG;EAC/C,CAA2B;EAE3BG,iBAAiB,EAAE;IACjB,CAACT,aAAa,CAACM,2BAA2B,GAAG,gBAAgB;IAC7D,CAACN,aAAa,CAACG,qBAAqB,GAAG,UAAU;IACjD,CAACH,aAAa,CAACO,iBAAiB,GAAG;EACrC,CAAkC;EAElCG,WAAW,EAAE;EACX;EACA,CAAC;EACD;EACA,CAAC;EACD;EACA,QAAQ;EACR;EACA,EAAE;EACF;EACA,GAAG;EACH;EACA,KAAK;EACL;EACA,MAAM;EACN;EACA,GAAG;EACH;EACA,KAAK;EACL;EACA,KAAK;EACL;EACA,UAAU;EACV;EACA,UAAU;EACV;EACA,EAAE;EACF;EACA,EAAE;EACF;EACA,KAAK;EACL;EACA,KAAK;EACL;EACA,GAAG;EACH;EACA,IAAI;EACJ;EACA,KAAK;EACL;EACA,OAAO;EACP;EACA,GAAG;EACH;EACA,GAAG;EACH;EACA,GAAG;AAEP,CAAC"}
|
|
@@ -1,98 +1,2 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
1
|
|
|
3
|
-
//********** Adapter Event Payloads **********//
|
|
4
|
-
|
|
5
|
-
//********** Adapter Event Map **********//
|
|
6
|
-
|
|
7
|
-
//********** Adapter Types **********//
|
|
8
|
-
export class BlockchainAdapter extends EventEmitter {
|
|
9
|
-
// Typed emit method
|
|
10
|
-
emit(event, payload) {
|
|
11
|
-
return super.emit(event, payload);
|
|
12
|
-
}
|
|
13
|
-
constructor({
|
|
14
|
-
projectId,
|
|
15
|
-
supportedNamespace
|
|
16
|
-
}) {
|
|
17
|
-
super();
|
|
18
|
-
this.projectId = projectId;
|
|
19
|
-
this.supportedNamespace = supportedNamespace;
|
|
20
|
-
}
|
|
21
|
-
setConnector(connector) {
|
|
22
|
-
this.connector = connector;
|
|
23
|
-
this.subscribeToEvents();
|
|
24
|
-
}
|
|
25
|
-
removeConnector() {
|
|
26
|
-
this.connector = undefined;
|
|
27
|
-
}
|
|
28
|
-
getProvider() {
|
|
29
|
-
if (!this.connector) throw new Error('No active connector');
|
|
30
|
-
return this.connector.getProvider();
|
|
31
|
-
}
|
|
32
|
-
subscribeToEvents() {
|
|
33
|
-
const provider = this.connector?.getProvider();
|
|
34
|
-
if (!provider) return;
|
|
35
|
-
provider.on('chainChanged', this.onChainChanged.bind(this));
|
|
36
|
-
provider.on('accountsChanged', this.onAccountsChanged.bind(this));
|
|
37
|
-
provider.on('disconnect', this.onDisconnect.bind(this));
|
|
38
|
-
}
|
|
39
|
-
onChainChanged(chainId) {
|
|
40
|
-
const _chains = this.getAccounts()?.map(account => account.split(':')[1]);
|
|
41
|
-
const shouldEmit = _chains?.some(chain => chain === chainId);
|
|
42
|
-
if (shouldEmit) {
|
|
43
|
-
this.emit('chainChanged', {
|
|
44
|
-
chainId,
|
|
45
|
-
namespace: this.getSupportedNamespace()
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
onAccountsChanged(accounts) {
|
|
50
|
-
const _accounts = this.getAccounts();
|
|
51
|
-
const shouldEmit = _accounts?.some(account => {
|
|
52
|
-
const accountAddress = account.split(':')[2];
|
|
53
|
-
return accountAddress !== undefined && accounts.includes(accountAddress);
|
|
54
|
-
});
|
|
55
|
-
if (shouldEmit) {
|
|
56
|
-
this.emit('accountsChanged', {
|
|
57
|
-
accounts,
|
|
58
|
-
namespace: this.getSupportedNamespace()
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
onDisconnect() {
|
|
63
|
-
this.emit('disconnect', {
|
|
64
|
-
namespace: this.getSupportedNamespace()
|
|
65
|
-
});
|
|
66
|
-
const provider = this.connector?.getProvider();
|
|
67
|
-
if (provider) {
|
|
68
|
-
provider.off('chainChanged', this.onChainChanged.bind(this));
|
|
69
|
-
provider.off('accountsChanged', this.onAccountsChanged.bind(this));
|
|
70
|
-
provider.off('disconnect', this.onDisconnect.bind(this));
|
|
71
|
-
}
|
|
72
|
-
this.connector = undefined;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
export class EVMAdapter extends BlockchainAdapter {
|
|
76
|
-
// ens logic
|
|
77
|
-
}
|
|
78
|
-
export class SolanaBaseAdapter extends BlockchainAdapter {}
|
|
79
|
-
|
|
80
|
-
//********** Connector Types **********//
|
|
81
|
-
|
|
82
|
-
export class WalletConnector extends EventEmitter {
|
|
83
|
-
constructor({
|
|
84
|
-
type,
|
|
85
|
-
provider
|
|
86
|
-
}) {
|
|
87
|
-
super();
|
|
88
|
-
this.type = type;
|
|
89
|
-
this.provider = provider;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
//********** Provider Types **********//
|
|
94
|
-
|
|
95
|
-
//TODO: rename this and remove the old one ConnectorType
|
|
96
|
-
|
|
97
|
-
//********** Others **********//
|
|
98
2
|
//# sourceMappingURL=TypeUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/TypeUtil.ts"],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConnectorType } from './TypeUtil';
|
|
2
2
|
export declare const PresetsUtil: {
|
|
3
3
|
ConnectorExplorerIds: Record<string, string>;
|
|
4
|
-
|
|
4
|
+
EIP155NetworkImageIds: Record<string, string>;
|
|
5
5
|
ConnectorNamesMap: Record<string, string>;
|
|
6
6
|
ConnectorImageIds: Record<string, string>;
|
|
7
7
|
ConnectorTypesMap: Record<string, ConnectorType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresetsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/PresetsUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,eAAO,MAAM,WAAW;;;;;;;
|
|
1
|
+
{"version":3,"file":"PresetsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/PresetsUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,eAAO,MAAM,WAAW;;;;;;;CAgHvB,CAAC"}
|
|
@@ -1,51 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
export type CaipAddress = `${string}:${string}:${string}`;
|
|
4
|
-
export type CaipNetworkId = `${string}:${string}`;
|
|
5
|
-
export type ChainNamespace = 'eip155' | 'solana' | 'polkadot' | 'bip122';
|
|
6
|
-
export type Network = {
|
|
7
|
-
id: number | string;
|
|
8
|
-
name: string;
|
|
9
|
-
nativeCurrency: {
|
|
10
|
-
name: string;
|
|
11
|
-
symbol: string;
|
|
12
|
-
decimals: number;
|
|
13
|
-
};
|
|
14
|
-
rpcUrls: {
|
|
15
|
-
default: {
|
|
16
|
-
http: readonly string[];
|
|
17
|
-
};
|
|
18
|
-
[key: string]: {
|
|
19
|
-
http: readonly string[];
|
|
20
|
-
} | undefined;
|
|
21
|
-
};
|
|
22
|
-
blockExplorers?: {
|
|
23
|
-
default: {
|
|
24
|
-
name: string;
|
|
25
|
-
url: string;
|
|
26
|
-
};
|
|
27
|
-
[key: string]: {
|
|
28
|
-
name: string;
|
|
29
|
-
url: string;
|
|
30
|
-
} | undefined;
|
|
31
|
-
};
|
|
32
|
-
chainNamespace?: ChainNamespace;
|
|
33
|
-
caipNetworkId?: CaipNetworkId;
|
|
34
|
-
testnet?: boolean;
|
|
35
|
-
deprecatedCaipNetworkId?: CaipNetworkId;
|
|
36
|
-
};
|
|
37
|
-
export type AppKitNetwork = Network & {
|
|
38
|
-
chainNamespace: ChainNamespace;
|
|
39
|
-
caipNetworkId: CaipNetworkId;
|
|
40
|
-
testnet?: boolean;
|
|
41
|
-
deprecatedCaipNetworkId?: CaipNetworkId;
|
|
42
|
-
};
|
|
43
|
-
export interface CaipNetwork {
|
|
44
|
-
id: CaipNetworkId;
|
|
45
|
-
name?: string;
|
|
46
|
-
imageId?: string;
|
|
47
|
-
imageUrl?: string;
|
|
48
|
-
}
|
|
49
1
|
export interface Balance {
|
|
50
2
|
name: string;
|
|
51
3
|
symbol: string;
|
|
@@ -127,133 +79,6 @@ export type ThemeMode = 'dark' | 'light';
|
|
|
127
79
|
export interface ThemeVariables {
|
|
128
80
|
accent?: string;
|
|
129
81
|
}
|
|
130
|
-
export interface Token {
|
|
131
|
-
address: string;
|
|
132
|
-
image?: string;
|
|
133
|
-
}
|
|
134
|
-
export type Tokens = Record<CaipNetworkId, Token>;
|
|
135
82
|
export type ConnectorType = 'WALLET_CONNECT' | 'COINBASE' | 'AUTH' | 'EXTERNAL';
|
|
136
|
-
export type AccountsChangedEvent = {
|
|
137
|
-
accounts: string[];
|
|
138
|
-
namespace: ChainNamespace;
|
|
139
|
-
};
|
|
140
|
-
export type ChainChangedEvent = {
|
|
141
|
-
chainId: string;
|
|
142
|
-
namespace: ChainNamespace;
|
|
143
|
-
};
|
|
144
|
-
export type DisconnectEvent = {
|
|
145
|
-
namespace: ChainNamespace;
|
|
146
|
-
};
|
|
147
|
-
export type BalanceChangedEvent = {
|
|
148
|
-
namespace: ChainNamespace;
|
|
149
|
-
address: CaipAddress;
|
|
150
|
-
balance: {
|
|
151
|
-
amount: string;
|
|
152
|
-
symbol: string;
|
|
153
|
-
contractAddress?: ContractAddress;
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
export interface AdapterEvents {
|
|
157
|
-
accountsChanged: (event: AccountsChangedEvent) => void;
|
|
158
|
-
chainChanged: (event: ChainChangedEvent) => void;
|
|
159
|
-
disconnect: (event: DisconnectEvent) => void;
|
|
160
|
-
balanceChanged: (event: BalanceChangedEvent) => void;
|
|
161
|
-
}
|
|
162
|
-
export declare abstract class BlockchainAdapter extends EventEmitter {
|
|
163
|
-
projectId: string;
|
|
164
|
-
connector?: WalletConnector;
|
|
165
|
-
supportedNamespace: ChainNamespace;
|
|
166
|
-
emit<K extends keyof AdapterEvents>(event: K, payload: Parameters<AdapterEvents[K]>[0]): boolean;
|
|
167
|
-
constructor({ projectId, supportedNamespace }: {
|
|
168
|
-
projectId: string;
|
|
169
|
-
supportedNamespace: ChainNamespace;
|
|
170
|
-
});
|
|
171
|
-
setConnector(connector: WalletConnector): void;
|
|
172
|
-
removeConnector(): void;
|
|
173
|
-
getProvider(): Provider;
|
|
174
|
-
subscribeToEvents(): void;
|
|
175
|
-
onChainChanged(chainId: string): void;
|
|
176
|
-
onAccountsChanged(accounts: string[]): void;
|
|
177
|
-
onDisconnect(): void;
|
|
178
|
-
abstract disconnect(): Promise<void>;
|
|
179
|
-
abstract getSupportedNamespace(): ChainNamespace;
|
|
180
|
-
abstract getBalance(params: GetBalanceParams): Promise<GetBalanceResponse>;
|
|
181
|
-
abstract getAccounts(): CaipAddress[] | undefined;
|
|
182
|
-
abstract switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
183
|
-
}
|
|
184
|
-
export declare abstract class EVMAdapter extends BlockchainAdapter {
|
|
185
|
-
}
|
|
186
|
-
export declare abstract class SolanaBaseAdapter extends BlockchainAdapter {
|
|
187
|
-
}
|
|
188
|
-
export interface GetBalanceParams {
|
|
189
|
-
address?: CaipAddress;
|
|
190
|
-
network?: AppKitNetwork;
|
|
191
|
-
tokens?: Tokens;
|
|
192
|
-
}
|
|
193
|
-
type ContractAddress = CaipAddress;
|
|
194
|
-
export interface GetBalanceResponse {
|
|
195
|
-
amount: string;
|
|
196
|
-
symbol: string;
|
|
197
|
-
contractAddress?: ContractAddress;
|
|
198
|
-
}
|
|
199
|
-
interface BaseNamespace {
|
|
200
|
-
chains?: CaipNetworkId[];
|
|
201
|
-
accounts: CaipAddress[];
|
|
202
|
-
methods: string[];
|
|
203
|
-
events: string[];
|
|
204
|
-
}
|
|
205
|
-
type Namespace = BaseNamespace;
|
|
206
|
-
export type Namespaces = Record<string, Namespace>;
|
|
207
|
-
export type ProposalNamespaces = Record<string, Omit<Namespace, 'accounts'> & Required<Pick<Namespace, 'chains'>>>;
|
|
208
|
-
export declare abstract class WalletConnector extends EventEmitter {
|
|
209
|
-
type: New_ConnectorType;
|
|
210
|
-
protected provider: Provider;
|
|
211
|
-
protected namespaces?: Namespaces;
|
|
212
|
-
protected wallet?: WalletInfo;
|
|
213
|
-
constructor({ type, provider }: {
|
|
214
|
-
type: New_ConnectorType;
|
|
215
|
-
provider: Provider;
|
|
216
|
-
});
|
|
217
|
-
abstract connect(opts: {
|
|
218
|
-
namespaces?: ProposalNamespaces;
|
|
219
|
-
defaultChain?: CaipNetworkId;
|
|
220
|
-
}): Promise<Namespaces | undefined>;
|
|
221
|
-
abstract disconnect(): Promise<void>;
|
|
222
|
-
abstract getProvider(): Provider;
|
|
223
|
-
abstract getNamespaces(): Namespaces;
|
|
224
|
-
abstract getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
|
|
225
|
-
abstract getWalletInfo(): WalletInfo | undefined;
|
|
226
|
-
abstract switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
227
|
-
}
|
|
228
|
-
export interface Provider {
|
|
229
|
-
connect<T>(params?: any): Promise<T>;
|
|
230
|
-
disconnect(): Promise<void>;
|
|
231
|
-
request<T = unknown>(args: RequestArguments, chain?: string | undefined, expiry?: number | undefined): Promise<T>;
|
|
232
|
-
on(event: string, listener: (args?: any) => void): any;
|
|
233
|
-
off(event: string, listener: (args?: any) => void): any;
|
|
234
|
-
}
|
|
235
|
-
export interface RequestArguments {
|
|
236
|
-
method: string;
|
|
237
|
-
params?: unknown[] | Record<string, unknown> | object | undefined;
|
|
238
|
-
}
|
|
239
|
-
export type New_ConnectorType = 'walletconnect' | 'coinbase' | 'auth';
|
|
240
|
-
export interface ConnectionResponse {
|
|
241
|
-
accounts: string[];
|
|
242
|
-
chainId: string;
|
|
243
|
-
[key: string]: any;
|
|
244
|
-
}
|
|
245
|
-
export interface WalletInfo {
|
|
246
|
-
name?: string;
|
|
247
|
-
icon?: string;
|
|
248
|
-
description?: string;
|
|
249
|
-
url?: string;
|
|
250
|
-
icons?: string[];
|
|
251
|
-
redirect?: {
|
|
252
|
-
native?: string;
|
|
253
|
-
universal?: string;
|
|
254
|
-
linkMode?: boolean;
|
|
255
|
-
};
|
|
256
|
-
[key: string]: unknown;
|
|
257
|
-
}
|
|
258
83
|
export {};
|
|
259
84
|
//# sourceMappingURL=TypeUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/TypeUtil.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TypeUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/TypeUtil.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
package/src/utils/PresetsUtil.ts
CHANGED
|
@@ -7,11 +7,11 @@ export const PresetsUtil = {
|
|
|
7
7
|
'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa'
|
|
8
8
|
} as Record<string, string>,
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
EIP155NetworkImageIds: {
|
|
11
11
|
// Ethereum
|
|
12
12
|
1: 'ba0ba0cd-17c6-4806-ad93-f9d174f17900',
|
|
13
13
|
// Arbitrum
|
|
14
|
-
42161: '
|
|
14
|
+
42161: '600a9a04-c1b9-42ca-6785-9b4b6ff85200',
|
|
15
15
|
// Avalanche
|
|
16
16
|
43114: '30c46e53-e989-45fb-4549-be3bd4eb3b00',
|
|
17
17
|
// Binance Smart Chain
|
|
@@ -22,20 +22,6 @@ export const PresetsUtil = {
|
|
|
22
22
|
10: 'ab9c186a-c52f-464b-2906-ca59d760a400',
|
|
23
23
|
// Polygon
|
|
24
24
|
137: '41d04d42-da3b-4453-8506-668cc0727900',
|
|
25
|
-
// Mantle
|
|
26
|
-
5000: 'e86fae9b-b770-4eea-e520-150e12c81100',
|
|
27
|
-
// Hedera Mainnet
|
|
28
|
-
295: '6a97d510-cac8-4e58-c7ce-e8681b044c00',
|
|
29
|
-
// Sepolia
|
|
30
|
-
11_155_111: 'e909ea0a-f92a-4512-c8fc-748044ea6800',
|
|
31
|
-
// Base Sepolia
|
|
32
|
-
84532: 'a18a7ecd-e307-4360-4746-283182228e00',
|
|
33
|
-
// Unichain Sepolia
|
|
34
|
-
1301: '4eeea7ef-0014-4649-5d1d-07271a80f600',
|
|
35
|
-
// Unichain Mainnet
|
|
36
|
-
130: '2257980a-3463-48c6-cbac-a42d2a956e00',
|
|
37
|
-
// Monad Testnet
|
|
38
|
-
10_143: '0a728e83-bacb-46db-7844-948f05434900',
|
|
39
25
|
// Gnosis
|
|
40
26
|
100: '02b53f6a-e3d4-479e-1cb4-21178987d100',
|
|
41
27
|
// EVMos
|
|
@@ -59,26 +45,7 @@ export const PresetsUtil = {
|
|
|
59
45
|
// Base
|
|
60
46
|
8453: '7289c336-3981-4081-c5f4-efc26ac64a00',
|
|
61
47
|
// Aurora
|
|
62
|
-
1313161554: '3ff73439-a619-4894-9262-4470c773a100'
|
|
63
|
-
// Ronin Mainnet
|
|
64
|
-
2020: 'b8101fc0-9c19-4b6f-ec65-f6dfff106e00',
|
|
65
|
-
// Saigon Testnet (a.k.a. Ronin)
|
|
66
|
-
2021: 'b8101fc0-9c19-4b6f-ec65-f6dfff106e00',
|
|
67
|
-
// Berachain Mainnet
|
|
68
|
-
80094: 'e329c2c9-59b0-4a02-83e4-212ff3779900',
|
|
69
|
-
// Abstract Mainnet
|
|
70
|
-
2741: 'fc2427d1-5af9-4a9c-8da5-6f94627cd900',
|
|
71
|
-
|
|
72
|
-
// Solana networks
|
|
73
|
-
/// Mainnet
|
|
74
|
-
'5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': 'a1b58899-f671-4276-6a5e-56ca5bd59700',
|
|
75
|
-
/// Testnet
|
|
76
|
-
'4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z': 'a1b58899-f671-4276-6a5e-56ca5bd59700',
|
|
77
|
-
|
|
78
|
-
// Bitcoin
|
|
79
|
-
'000000000019d6689c085ae165831e93': '0b4838db-0161-4ffe-022d-532bf03dba00',
|
|
80
|
-
// Bitcoin Testnet
|
|
81
|
-
'000000000933ea01ad0ee984209779ba': '39354064-d79b-420b-065d-f980c4b78200'
|
|
48
|
+
1313161554: '3ff73439-a619-4894-9262-4470c773a100'
|
|
82
49
|
} as Record<string, string>,
|
|
83
50
|
|
|
84
51
|
ConnectorNamesMap: {
|
package/src/utils/TypeUtil.ts
CHANGED
|
@@ -1,46 +1,3 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
|
|
3
|
-
export type CaipAddress = `${string}:${string}:${string}`;
|
|
4
|
-
|
|
5
|
-
export type CaipNetworkId = `${string}:${string}`;
|
|
6
|
-
|
|
7
|
-
export type ChainNamespace = 'eip155' | 'solana' | 'polkadot' | 'bip122';
|
|
8
|
-
|
|
9
|
-
export type Network = {
|
|
10
|
-
// Core viem/chain properties
|
|
11
|
-
id: number | string;
|
|
12
|
-
name: string;
|
|
13
|
-
nativeCurrency: { name: string; symbol: string; decimals: number };
|
|
14
|
-
rpcUrls: {
|
|
15
|
-
default: { http: readonly string[] };
|
|
16
|
-
[key: string]: { http: readonly string[] } | undefined;
|
|
17
|
-
};
|
|
18
|
-
blockExplorers?: {
|
|
19
|
-
default: { name: string; url: string };
|
|
20
|
-
[key: string]: { name: string; url: string } | undefined;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// AppKit specific / CAIP properties (Optional in type, but needed in practice)
|
|
24
|
-
chainNamespace?: ChainNamespace; // e.g., 'eip155'
|
|
25
|
-
caipNetworkId?: CaipNetworkId; // e.g., 'eip155:1'
|
|
26
|
-
testnet?: boolean;
|
|
27
|
-
deprecatedCaipNetworkId?: CaipNetworkId; // for Solana deprecated id
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type AppKitNetwork = Network & {
|
|
31
|
-
chainNamespace: ChainNamespace; // e.g., 'eip155'
|
|
32
|
-
caipNetworkId: CaipNetworkId; // e.g., 'eip155:1'
|
|
33
|
-
testnet?: boolean;
|
|
34
|
-
deprecatedCaipNetworkId?: CaipNetworkId; // for Solana deprecated id
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export interface CaipNetwork {
|
|
38
|
-
id: CaipNetworkId;
|
|
39
|
-
name?: string;
|
|
40
|
-
imageId?: string;
|
|
41
|
-
imageUrl?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
1
|
export interface Balance {
|
|
45
2
|
name: string;
|
|
46
3
|
symbol: string;
|
|
@@ -137,241 +94,4 @@ export interface ThemeVariables {
|
|
|
137
94
|
accent?: string;
|
|
138
95
|
}
|
|
139
96
|
|
|
140
|
-
export interface Token {
|
|
141
|
-
address: string;
|
|
142
|
-
image?: string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export type Tokens = Record<CaipNetworkId, Token>;
|
|
146
|
-
|
|
147
97
|
export type ConnectorType = 'WALLET_CONNECT' | 'COINBASE' | 'AUTH' | 'EXTERNAL';
|
|
148
|
-
|
|
149
|
-
//********** Adapter Event Payloads **********//
|
|
150
|
-
export type AccountsChangedEvent = {
|
|
151
|
-
accounts: string[];
|
|
152
|
-
namespace: ChainNamespace;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export type ChainChangedEvent = {
|
|
156
|
-
chainId: string;
|
|
157
|
-
namespace: ChainNamespace;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export type DisconnectEvent = {
|
|
161
|
-
namespace: ChainNamespace;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export type BalanceChangedEvent = {
|
|
165
|
-
namespace: ChainNamespace;
|
|
166
|
-
address: CaipAddress;
|
|
167
|
-
balance: {
|
|
168
|
-
amount: string;
|
|
169
|
-
symbol: string;
|
|
170
|
-
contractAddress?: ContractAddress;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
//********** Adapter Event Map **********//
|
|
175
|
-
export interface AdapterEvents {
|
|
176
|
-
accountsChanged: (event: AccountsChangedEvent) => void;
|
|
177
|
-
chainChanged: (event: ChainChangedEvent) => void;
|
|
178
|
-
disconnect: (event: DisconnectEvent) => void;
|
|
179
|
-
balanceChanged: (event: BalanceChangedEvent) => void;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
//********** Adapter Types **********//
|
|
183
|
-
export abstract class BlockchainAdapter extends EventEmitter {
|
|
184
|
-
public projectId: string;
|
|
185
|
-
public connector?: WalletConnector;
|
|
186
|
-
public supportedNamespace: ChainNamespace;
|
|
187
|
-
|
|
188
|
-
// Typed emit method
|
|
189
|
-
override emit<K extends keyof AdapterEvents>(
|
|
190
|
-
event: K,
|
|
191
|
-
payload: Parameters<AdapterEvents[K]>[0]
|
|
192
|
-
): boolean {
|
|
193
|
-
return super.emit(event, payload);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
constructor({
|
|
197
|
-
projectId,
|
|
198
|
-
supportedNamespace
|
|
199
|
-
}: {
|
|
200
|
-
projectId: string;
|
|
201
|
-
supportedNamespace: ChainNamespace;
|
|
202
|
-
}) {
|
|
203
|
-
super();
|
|
204
|
-
this.projectId = projectId;
|
|
205
|
-
this.supportedNamespace = supportedNamespace;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
setConnector(connector: WalletConnector) {
|
|
209
|
-
this.connector = connector;
|
|
210
|
-
this.subscribeToEvents();
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
removeConnector() {
|
|
214
|
-
this.connector = undefined;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
getProvider(): Provider {
|
|
218
|
-
if (!this.connector) throw new Error('No active connector');
|
|
219
|
-
|
|
220
|
-
return this.connector.getProvider();
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
subscribeToEvents(): void {
|
|
224
|
-
const provider = this.connector?.getProvider();
|
|
225
|
-
if (!provider) return;
|
|
226
|
-
|
|
227
|
-
provider.on('chainChanged', this.onChainChanged.bind(this));
|
|
228
|
-
provider.on('accountsChanged', this.onAccountsChanged.bind(this));
|
|
229
|
-
provider.on('disconnect', this.onDisconnect.bind(this));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
onChainChanged(chainId: string): void {
|
|
233
|
-
const _chains = this.getAccounts()?.map(account => account.split(':')[1]);
|
|
234
|
-
const shouldEmit = _chains?.some(chain => chain === chainId);
|
|
235
|
-
|
|
236
|
-
if (shouldEmit) {
|
|
237
|
-
this.emit('chainChanged', { chainId, namespace: this.getSupportedNamespace() });
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
onAccountsChanged(accounts: string[]): void {
|
|
242
|
-
const _accounts = this.getAccounts();
|
|
243
|
-
const shouldEmit = _accounts?.some(account => {
|
|
244
|
-
const accountAddress = account.split(':')[2];
|
|
245
|
-
|
|
246
|
-
return accountAddress !== undefined && accounts.includes(accountAddress);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
if (shouldEmit) {
|
|
250
|
-
this.emit('accountsChanged', { accounts, namespace: this.getSupportedNamespace() });
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
onDisconnect(): void {
|
|
255
|
-
this.emit('disconnect', { namespace: this.getSupportedNamespace() });
|
|
256
|
-
|
|
257
|
-
const provider = this.connector?.getProvider();
|
|
258
|
-
if (provider) {
|
|
259
|
-
provider.off('chainChanged', this.onChainChanged.bind(this));
|
|
260
|
-
provider.off('accountsChanged', this.onAccountsChanged.bind(this));
|
|
261
|
-
provider.off('disconnect', this.onDisconnect.bind(this));
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
this.connector = undefined;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
abstract disconnect(): Promise<void>;
|
|
268
|
-
abstract getSupportedNamespace(): ChainNamespace;
|
|
269
|
-
abstract getBalance(params: GetBalanceParams): Promise<GetBalanceResponse>;
|
|
270
|
-
abstract getAccounts(): CaipAddress[] | undefined;
|
|
271
|
-
abstract switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export abstract class EVMAdapter extends BlockchainAdapter {
|
|
275
|
-
// ens logic
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export abstract class SolanaBaseAdapter extends BlockchainAdapter {}
|
|
279
|
-
|
|
280
|
-
export interface GetBalanceParams {
|
|
281
|
-
address?: CaipAddress;
|
|
282
|
-
network?: AppKitNetwork;
|
|
283
|
-
tokens?: Tokens;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
type ContractAddress = CaipAddress;
|
|
287
|
-
|
|
288
|
-
export interface GetBalanceResponse {
|
|
289
|
-
amount: string;
|
|
290
|
-
symbol: string;
|
|
291
|
-
contractAddress?: ContractAddress;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
//********** Connector Types **********//
|
|
295
|
-
interface BaseNamespace {
|
|
296
|
-
chains?: CaipNetworkId[];
|
|
297
|
-
accounts: CaipAddress[];
|
|
298
|
-
methods: string[];
|
|
299
|
-
events: string[];
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
type Namespace = BaseNamespace;
|
|
303
|
-
|
|
304
|
-
export type Namespaces = Record<string, Namespace>;
|
|
305
|
-
|
|
306
|
-
export type ProposalNamespaces = Record<
|
|
307
|
-
string,
|
|
308
|
-
Omit<Namespace, 'accounts'> & Required<Pick<Namespace, 'chains'>>
|
|
309
|
-
>;
|
|
310
|
-
|
|
311
|
-
export abstract class WalletConnector extends EventEmitter {
|
|
312
|
-
public type: New_ConnectorType;
|
|
313
|
-
protected provider: Provider;
|
|
314
|
-
protected namespaces?: Namespaces;
|
|
315
|
-
protected wallet?: WalletInfo;
|
|
316
|
-
|
|
317
|
-
constructor({ type, provider }: { type: New_ConnectorType; provider: Provider }) {
|
|
318
|
-
super();
|
|
319
|
-
this.type = type;
|
|
320
|
-
this.provider = provider;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
abstract connect(opts: {
|
|
324
|
-
namespaces?: ProposalNamespaces;
|
|
325
|
-
defaultChain?: CaipNetworkId;
|
|
326
|
-
}): Promise<Namespaces | undefined>;
|
|
327
|
-
abstract disconnect(): Promise<void>;
|
|
328
|
-
abstract getProvider(): Provider;
|
|
329
|
-
abstract getNamespaces(): Namespaces;
|
|
330
|
-
abstract getChainId(namespace: ChainNamespace): CaipNetworkId | undefined;
|
|
331
|
-
abstract getWalletInfo(): WalletInfo | undefined;
|
|
332
|
-
abstract switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
//********** Provider Types **********//
|
|
336
|
-
|
|
337
|
-
export interface Provider {
|
|
338
|
-
connect<T>(params?: any): Promise<T>;
|
|
339
|
-
disconnect(): Promise<void>;
|
|
340
|
-
request<T = unknown>(
|
|
341
|
-
args: RequestArguments,
|
|
342
|
-
chain?: string | undefined,
|
|
343
|
-
expiry?: number | undefined
|
|
344
|
-
): Promise<T>;
|
|
345
|
-
on(event: string, listener: (args?: any) => void): any;
|
|
346
|
-
off(event: string, listener: (args?: any) => void): any;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
export interface RequestArguments {
|
|
350
|
-
method: string;
|
|
351
|
-
params?: unknown[] | Record<string, unknown> | object | undefined;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
//TODO: rename this and remove the old one ConnectorType
|
|
355
|
-
export type New_ConnectorType = 'walletconnect' | 'coinbase' | 'auth';
|
|
356
|
-
|
|
357
|
-
//********** Others **********//
|
|
358
|
-
|
|
359
|
-
export interface ConnectionResponse {
|
|
360
|
-
accounts: string[];
|
|
361
|
-
chainId: string;
|
|
362
|
-
[key: string]: any;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export interface WalletInfo {
|
|
366
|
-
name?: string;
|
|
367
|
-
icon?: string;
|
|
368
|
-
description?: string;
|
|
369
|
-
url?: string;
|
|
370
|
-
icons?: string[];
|
|
371
|
-
redirect?: {
|
|
372
|
-
native?: string;
|
|
373
|
-
universal?: string;
|
|
374
|
-
linkMode?: boolean;
|
|
375
|
-
};
|
|
376
|
-
[key: string]: unknown;
|
|
377
|
-
}
|