@rango-dev/wallets-react 0.26.1-next.3 → 0.27.0
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/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/legacy/constants.d.ts +2 -0
- package/dist/legacy/constants.d.ts.map +1 -0
- package/dist/legacy/helpers.d.ts +6 -2
- package/dist/legacy/helpers.d.ts.map +1 -1
- package/dist/legacy/types.d.ts +4 -12
- package/dist/legacy/types.d.ts.map +1 -1
- package/dist/legacy/useAutoConnect.d.ts +4 -5
- package/dist/legacy/useAutoConnect.d.ts.map +1 -1
- package/dist/legacy/useLegacyProviders.d.ts +1 -5
- package/dist/legacy/useLegacyProviders.d.ts.map +1 -1
- package/dist/wallets-react.build.json +1 -1
- package/package.json +7 -15
- package/src/legacy/constants.ts +1 -0
- package/src/legacy/helpers.ts +92 -17
- package/src/legacy/types.ts +6 -14
- package/src/legacy/useAutoConnect.ts +16 -8
- package/src/legacy/useLegacyProviders.ts +7 -45
- package/src/provider.tsx +3 -3
- package/dist/hub/autoConnect.d.ts +0 -9
- package/dist/hub/autoConnect.d.ts.map +0 -1
- package/dist/hub/constants.d.ts +0 -3
- package/dist/hub/constants.d.ts.map +0 -1
- package/dist/hub/helpers.d.ts +0 -19
- package/dist/hub/helpers.d.ts.map +0 -1
- package/dist/hub/lastConnectedWallets.d.ts +0 -16
- package/dist/hub/lastConnectedWallets.d.ts.map +0 -1
- package/dist/hub/mod.d.ts +0 -3
- package/dist/hub/mod.d.ts.map +0 -1
- package/dist/hub/types.d.ts +0 -4
- package/dist/hub/types.d.ts.map +0 -1
- package/dist/hub/useHubAdapter.d.ts +0 -10
- package/dist/hub/useHubAdapter.d.ts.map +0 -1
- package/dist/hub/useHubRefs.d.ts +0 -7
- package/dist/hub/useHubRefs.d.ts.map +0 -1
- package/dist/hub/utils.d.ts +0 -38
- package/dist/hub/utils.d.ts.map +0 -1
- package/dist/legacy/autoConnect.d.ts +0 -8
- package/dist/legacy/autoConnect.d.ts.map +0 -1
- package/dist/legacy/mod.d.ts +0 -5
- package/dist/legacy/mod.d.ts.map +0 -1
- package/dist/legacy/utils.d.ts +0 -3
- package/dist/legacy/utils.d.ts.map +0 -1
- package/dist/test-utils/env.d.ts +0 -7
- package/dist/test-utils/env.d.ts.map +0 -1
- package/dist/test-utils/fixtures.d.ts +0 -14
- package/dist/test-utils/fixtures.d.ts.map +0 -1
- package/dist/useProviders.d.ts +0 -4
- package/dist/useProviders.d.ts.map +0 -1
- package/src/hub/autoConnect.ts +0 -186
- package/src/hub/constants.ts +0 -2
- package/src/hub/helpers.ts +0 -67
- package/src/hub/lastConnectedWallets.ts +0 -117
- package/src/hub/mod.ts +0 -2
- package/src/hub/types.ts +0 -12
- package/src/hub/useHubAdapter.ts +0 -337
- package/src/hub/useHubRefs.ts +0 -41
- package/src/hub/utils.ts +0 -389
- package/src/legacy/autoConnect.ts +0 -78
- package/src/legacy/mod.ts +0 -13
- package/src/legacy/utils.ts +0 -7
- package/src/test-utils/env.ts +0 -10
- package/src/test-utils/fixtures.ts +0 -238
- package/src/useProviders.ts +0 -120
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
|
|
2
|
-
import type { BlockchainMeta, GenericSigner } from 'rango-types';
|
|
3
|
-
import type { EvmTransaction } from 'rango-types/mainApi';
|
|
4
|
-
|
|
5
|
-
import { DefaultSignerFactory, TransactionType } from 'rango-types';
|
|
6
|
-
|
|
7
|
-
export const legacyAddress = '0x000000000000000000000000000000000000dead';
|
|
8
|
-
|
|
9
|
-
export class MockEvmSigner implements GenericSigner<EvmTransaction> {
|
|
10
|
-
async signMessage(
|
|
11
|
-
_msg: string,
|
|
12
|
-
_address: string,
|
|
13
|
-
_chainId: string | null
|
|
14
|
-
): Promise<string> {
|
|
15
|
-
return '0x';
|
|
16
|
-
}
|
|
17
|
-
async signAndSendTx(
|
|
18
|
-
_tx: EvmTransaction,
|
|
19
|
-
_address: string,
|
|
20
|
-
_chainId: string | null
|
|
21
|
-
): Promise<{ hash: string; response?: any }> {
|
|
22
|
-
return {
|
|
23
|
-
hash: '0x',
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const legacyProvider: LegacyProviderInterface = {
|
|
29
|
-
config: {
|
|
30
|
-
type: 'legacy-garbage',
|
|
31
|
-
},
|
|
32
|
-
async connect({ network }) {
|
|
33
|
-
// we added a timeout to simulate requesting to extension for connection.
|
|
34
|
-
return await new Promise((resolve, reject) => {
|
|
35
|
-
setTimeout(() => {
|
|
36
|
-
// This is useful for simulating error scenarios.
|
|
37
|
-
if (network === 'When Airdrop?') {
|
|
38
|
-
reject(
|
|
39
|
-
'please stay tuned we shall announce the detailed information soon.'
|
|
40
|
-
);
|
|
41
|
-
} else {
|
|
42
|
-
resolve([
|
|
43
|
-
{
|
|
44
|
-
accounts: [legacyAddress],
|
|
45
|
-
chainId: network || '',
|
|
46
|
-
},
|
|
47
|
-
]);
|
|
48
|
-
}
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
50
|
-
}, 10);
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
getInstance() {
|
|
54
|
-
return {};
|
|
55
|
-
},
|
|
56
|
-
async getSigners() {
|
|
57
|
-
const signers = new DefaultSignerFactory();
|
|
58
|
-
signers.registerSigner(TransactionType.EVM, new MockEvmSigner());
|
|
59
|
-
return signers;
|
|
60
|
-
},
|
|
61
|
-
getWalletInfo() {
|
|
62
|
-
return {
|
|
63
|
-
name: 'legacy garbage wallet',
|
|
64
|
-
color: '#000',
|
|
65
|
-
img: 'https://...',
|
|
66
|
-
installLink: 'https://...',
|
|
67
|
-
supportedChains: [],
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const blockchainsMeta: BlockchainMeta[] = [
|
|
73
|
-
{
|
|
74
|
-
name: 'BTC',
|
|
75
|
-
defaultDecimals: 8,
|
|
76
|
-
addressPatterns: [
|
|
77
|
-
'^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-z]{39,59}$',
|
|
78
|
-
],
|
|
79
|
-
feeAssets: [
|
|
80
|
-
{
|
|
81
|
-
blockchain: 'BTC',
|
|
82
|
-
symbol: 'BTC',
|
|
83
|
-
address: null,
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BTC/icon.svg',
|
|
87
|
-
displayName: 'Bitcoin',
|
|
88
|
-
shortName: 'BTC',
|
|
89
|
-
sort: 12,
|
|
90
|
-
color: '#F7931A',
|
|
91
|
-
enabled: true,
|
|
92
|
-
type: TransactionType.TRANSFER,
|
|
93
|
-
chainId: null,
|
|
94
|
-
info: {
|
|
95
|
-
infoType: 'TransferMetaInfo',
|
|
96
|
-
blockExplorerUrls: ['https://www.blockchain.com/btc/'],
|
|
97
|
-
addressUrl: 'https://www.blockchain.com/btc/address/{wallet}',
|
|
98
|
-
transactionUrl: 'https://www.blockchain.com/btc/tx/{txHash}',
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
name: 'ETH',
|
|
103
|
-
defaultDecimals: 18,
|
|
104
|
-
addressPatterns: ['^(0x)[0-9A-Fa-f]{40}$'],
|
|
105
|
-
feeAssets: [
|
|
106
|
-
{
|
|
107
|
-
blockchain: 'ETH',
|
|
108
|
-
symbol: 'ETH',
|
|
109
|
-
address: null,
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/ETH/icon.svg',
|
|
113
|
-
displayName: 'Ethereum',
|
|
114
|
-
shortName: 'ETH',
|
|
115
|
-
sort: 0,
|
|
116
|
-
color: '#ecf0f1',
|
|
117
|
-
enabled: true,
|
|
118
|
-
type: TransactionType.EVM,
|
|
119
|
-
chainId: '0x1',
|
|
120
|
-
info: {
|
|
121
|
-
infoType: 'EvmMetaInfo',
|
|
122
|
-
chainName: 'Ethereum Mainnet',
|
|
123
|
-
nativeCurrency: {
|
|
124
|
-
name: 'ETH',
|
|
125
|
-
symbol: 'ETH',
|
|
126
|
-
decimals: 18,
|
|
127
|
-
},
|
|
128
|
-
rpcUrls: ['https://rpc.ankr.com/eth'],
|
|
129
|
-
blockExplorerUrls: ['https://etherscan.io'],
|
|
130
|
-
addressUrl: 'https://etherscan.io/address/{wallet}',
|
|
131
|
-
transactionUrl: 'https://etherscan.io/tx/{txHash}',
|
|
132
|
-
enableGasV2: true,
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: 'SOLANA',
|
|
137
|
-
defaultDecimals: 9,
|
|
138
|
-
addressPatterns: ['^[1-9A-HJ-NP-Za-km-z]{32,44}$'],
|
|
139
|
-
feeAssets: [
|
|
140
|
-
{
|
|
141
|
-
blockchain: 'SOLANA',
|
|
142
|
-
symbol: 'SOL',
|
|
143
|
-
address: null,
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/SOLANA/icon.svg',
|
|
147
|
-
displayName: 'Solana',
|
|
148
|
-
shortName: 'Solana',
|
|
149
|
-
sort: 20,
|
|
150
|
-
color: '#708DD2',
|
|
151
|
-
enabled: true,
|
|
152
|
-
type: TransactionType.SOLANA,
|
|
153
|
-
chainId: 'mainnet-beta',
|
|
154
|
-
info: {
|
|
155
|
-
infoType: 'SolanaMetaInfo',
|
|
156
|
-
blockExplorerUrls: ['https://solscan.io/'],
|
|
157
|
-
addressUrl: 'https://solscan.io/account/{wallet}',
|
|
158
|
-
transactionUrl: 'https://solscan.io/tx/{txHash}',
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: 'COSMOS',
|
|
163
|
-
defaultDecimals: 6,
|
|
164
|
-
addressPatterns: ['^(cosmos1)[0-9a-z]{38}$'],
|
|
165
|
-
feeAssets: [
|
|
166
|
-
{
|
|
167
|
-
blockchain: 'COSMOS',
|
|
168
|
-
symbol: 'ATOM',
|
|
169
|
-
address: null,
|
|
170
|
-
},
|
|
171
|
-
],
|
|
172
|
-
logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/COSMOS/icon.svg',
|
|
173
|
-
displayName: 'Cosmos',
|
|
174
|
-
shortName: 'Cosmos',
|
|
175
|
-
sort: 15,
|
|
176
|
-
color: '#2E3148',
|
|
177
|
-
enabled: true,
|
|
178
|
-
type: TransactionType.COSMOS,
|
|
179
|
-
chainId: 'cosmoshub-4',
|
|
180
|
-
info: {
|
|
181
|
-
infoType: 'CosmosMetaInfo',
|
|
182
|
-
experimental: false,
|
|
183
|
-
rpc: 'https://cosmos-rpc.polkachu.com',
|
|
184
|
-
rest: 'https://lcd-cosmoshub.blockapsis.com',
|
|
185
|
-
cosmostationLcdUrl: 'https://lcd-cosmoshub.blockapsis.com',
|
|
186
|
-
cosmostationApiUrl: 'https://cosmos-rpc.polkachu.com',
|
|
187
|
-
cosmostationDenomTracePath: '/ibc/apps/transfer/v1/denom_traces/',
|
|
188
|
-
mintScanName: 'cosmos',
|
|
189
|
-
chainName: 'Cosmos',
|
|
190
|
-
stakeCurrency: {
|
|
191
|
-
coinDenom: 'ATOM',
|
|
192
|
-
coinMinimalDenom: 'uatom',
|
|
193
|
-
coinDecimals: 6,
|
|
194
|
-
coinGeckoId: 'cosmos',
|
|
195
|
-
coinImageUrl: '/tokens/blockchain/cosmos.svg',
|
|
196
|
-
},
|
|
197
|
-
bip44: {
|
|
198
|
-
coinType: 118,
|
|
199
|
-
},
|
|
200
|
-
bech32Config: {
|
|
201
|
-
bech32PrefixAccAddr: 'cosmos',
|
|
202
|
-
bech32PrefixAccPub: 'cosmospub',
|
|
203
|
-
bech32PrefixValAddr: 'cosmosvaloper',
|
|
204
|
-
bech32PrefixValPub: 'cosmosvaloperpub',
|
|
205
|
-
bech32PrefixConsAddr: 'cosmosvalcons',
|
|
206
|
-
bech32PrefixConsPub: 'cosmosvalconspub',
|
|
207
|
-
},
|
|
208
|
-
currencies: [
|
|
209
|
-
{
|
|
210
|
-
coinDenom: 'ATOM',
|
|
211
|
-
coinMinimalDenom: 'uatom',
|
|
212
|
-
coinDecimals: 6,
|
|
213
|
-
coinGeckoId: 'cosmos',
|
|
214
|
-
coinImageUrl: '/tokens/blockchain/cosmos.svg',
|
|
215
|
-
},
|
|
216
|
-
],
|
|
217
|
-
feeCurrencies: [
|
|
218
|
-
{
|
|
219
|
-
coinDenom: 'ATOM',
|
|
220
|
-
coinMinimalDenom: 'uatom',
|
|
221
|
-
coinDecimals: 6,
|
|
222
|
-
coinGeckoId: 'cosmos',
|
|
223
|
-
coinImageUrl: '/tokens/blockchain/cosmos.svg',
|
|
224
|
-
},
|
|
225
|
-
],
|
|
226
|
-
features: ['stargate', 'ibc-transfer'],
|
|
227
|
-
explorerUrlToTx: 'https://www.mintscan.io/cosmos/txs/{txHash}',
|
|
228
|
-
gasPriceStep: {
|
|
229
|
-
low: 0.01,
|
|
230
|
-
average: 0.025,
|
|
231
|
-
high: 0.04,
|
|
232
|
-
},
|
|
233
|
-
blockExplorerUrls: ['https://www.mintscan.io/cosmos/'],
|
|
234
|
-
addressUrl: 'https://www.mintscan.io/cosmos/account/{wallet}',
|
|
235
|
-
transactionUrl: 'https://www.mintscan.io/cosmos/txs/{txHash}',
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
];
|
package/src/useProviders.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ExtendedWalletInfo,
|
|
3
|
-
ProviderContext,
|
|
4
|
-
ProviderProps,
|
|
5
|
-
Providers,
|
|
6
|
-
} from './index.js';
|
|
7
|
-
import type { ConnectResult } from './legacy/mod.js';
|
|
8
|
-
import type { LegacyState } from '@rango-dev/wallets-core/legacy';
|
|
9
|
-
import type { SignerFactory } from 'rango-types';
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
findProviderByType,
|
|
13
|
-
separateLegacyAndHubProviders,
|
|
14
|
-
useHubAdapter,
|
|
15
|
-
} from './hub/mod.js';
|
|
16
|
-
import { useLegacyProviders } from './legacy/mod.js';
|
|
17
|
-
|
|
18
|
-
/*
|
|
19
|
-
* We have two separate interface for our providers: legacy and hub.
|
|
20
|
-
* This hook sits between this two interface by keeping old interface as main API and try to add Hub providers by using an adapter.
|
|
21
|
-
* For gradual migrating and backward compatibility, we are supporting hub by an adapter besides of the old one.
|
|
22
|
-
*/
|
|
23
|
-
function useProviders(props: ProviderProps) {
|
|
24
|
-
const { providers, ...restProps } = props;
|
|
25
|
-
const [legacyProviders, hubProviders] = separateLegacyAndHubProviders(
|
|
26
|
-
providers,
|
|
27
|
-
{
|
|
28
|
-
isExperimentalEnabled: restProps.configs?.isExperimentalEnabled,
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const legacyApi = useLegacyProviders({
|
|
33
|
-
...restProps,
|
|
34
|
-
providers: legacyProviders,
|
|
35
|
-
});
|
|
36
|
-
const hubApi = useHubAdapter({
|
|
37
|
-
...restProps,
|
|
38
|
-
providers: hubProviders,
|
|
39
|
-
allVersionedProviders: providers,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const api: ProviderContext = {
|
|
43
|
-
canSwitchNetworkTo(type, network): boolean {
|
|
44
|
-
if (findProviderByType(hubProviders, type)) {
|
|
45
|
-
return hubApi.canSwitchNetworkTo(type, network);
|
|
46
|
-
}
|
|
47
|
-
return legacyApi.canSwitchNetworkTo(type, network);
|
|
48
|
-
},
|
|
49
|
-
async connect(type, network): Promise<ConnectResult[]> {
|
|
50
|
-
const hubProvider = findProviderByType(hubProviders, type);
|
|
51
|
-
if (hubProvider) {
|
|
52
|
-
return await hubApi.connect(type, network);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return await legacyApi.connect(type, network);
|
|
56
|
-
},
|
|
57
|
-
async disconnect(type): Promise<void> {
|
|
58
|
-
const hubProvider = findProviderByType(hubProviders, type);
|
|
59
|
-
if (hubProvider) {
|
|
60
|
-
return await hubApi.disconnect(type);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return await legacyApi.disconnect(type);
|
|
64
|
-
},
|
|
65
|
-
async disconnectAll() {
|
|
66
|
-
return await Promise.allSettled([
|
|
67
|
-
hubApi.disconnectAll(),
|
|
68
|
-
legacyApi.disconnectAll(),
|
|
69
|
-
]);
|
|
70
|
-
},
|
|
71
|
-
async getSigners(type): Promise<SignerFactory> {
|
|
72
|
-
const hubProvider = findProviderByType(hubProviders, type);
|
|
73
|
-
if (hubProvider) {
|
|
74
|
-
return hubApi.getSigners(type);
|
|
75
|
-
}
|
|
76
|
-
return legacyApi.getSigners(type);
|
|
77
|
-
},
|
|
78
|
-
getWalletInfo(type): ExtendedWalletInfo {
|
|
79
|
-
const hubProvider = findProviderByType(hubProviders, type);
|
|
80
|
-
if (hubProvider) {
|
|
81
|
-
return hubApi.getWalletInfo(type);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return legacyApi.getWalletInfo(type);
|
|
85
|
-
},
|
|
86
|
-
providers(): Providers {
|
|
87
|
-
let output: Providers = {};
|
|
88
|
-
if (hubProviders.length > 0) {
|
|
89
|
-
output = { ...output, ...hubApi.providers() };
|
|
90
|
-
}
|
|
91
|
-
if (legacyProviders.length > 0) {
|
|
92
|
-
output = { ...output, ...legacyApi.providers() };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return output;
|
|
96
|
-
},
|
|
97
|
-
state(type): LegacyState {
|
|
98
|
-
const hubProvider = findProviderByType(hubProviders, type);
|
|
99
|
-
|
|
100
|
-
if (hubProvider) {
|
|
101
|
-
return hubApi.state(type);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return legacyApi.state(type);
|
|
105
|
-
},
|
|
106
|
-
async suggestAndConnect(type, network): Promise<ConnectResult> {
|
|
107
|
-
const hubProvider = findProviderByType(hubProviders, type);
|
|
108
|
-
|
|
109
|
-
if (hubProvider) {
|
|
110
|
-
return hubApi.suggestAndConnect(type, network);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return await legacyApi.suggestAndConnect(type, network);
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
return api;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export { useProviders };
|