@rango-dev/wallets-core 0.49.1-next.2 → 0.49.1-next.4
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/hub/store/mod.js +1 -1
- package/dist/hub/store/mod.js.map +2 -2
- package/dist/hub/store/namespaces.d.ts.map +1 -1
- package/dist/mod.d.ts +1 -0
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +2 -2
- package/dist/namespaces/common/mod.js +1 -1
- package/dist/namespaces/common/mod.js.map +1 -1
- package/dist/namespaces/evm/actions.d.ts.map +1 -1
- package/dist/namespaces/evm/builders.d.ts.map +1 -1
- package/dist/namespaces/evm/eip1193.d.ts +1 -0
- package/dist/namespaces/evm/eip1193.d.ts.map +1 -1
- package/dist/namespaces/evm/mod.js +1 -1
- package/dist/namespaces/evm/mod.js.map +3 -3
- package/dist/namespaces/solana/mod.js +1 -1
- package/dist/namespaces/solana/mod.js.map +3 -3
- package/dist/namespaces/solana/utils.d.ts.map +1 -1
- package/dist/namespaces/sui/mod.js.map +1 -1
- package/dist/namespaces/utxo/mod.js +1 -1
- package/dist/namespaces/utxo/mod.js.map +1 -1
- package/dist/types/mod.d.ts +1 -1
- package/dist/types/mod.d.ts.map +1 -1
- package/dist/wallets-core.build.json +1 -1
- package/package.json +1 -1
- package/src/hub/store/namespaces.ts +2 -1
- package/src/mod.ts +1 -0
- package/src/namespaces/evm/actions.ts +14 -4
- package/src/namespaces/evm/builders.ts +2 -12
- package/src/namespaces/evm/eip1193.ts +2 -1
- package/src/namespaces/solana/utils.ts +7 -1
- package/src/types/mod.ts +1 -1
|
@@ -40,16 +40,26 @@ export function connect(
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const providerAccounts = await getAccounts(evmInstance);
|
|
44
44
|
|
|
45
|
+
/*
|
|
46
|
+
* Ensure that the provider returns at least one valid account before proceeding.
|
|
47
|
+
* This prevents cases (e.g., MetaMask bug) where a user connects with an account
|
|
48
|
+
* that has no associated EVM address, leaving the dApp without any usable accounts.
|
|
49
|
+
*/
|
|
50
|
+
if (!providerAccounts.accounts || !providerAccounts.accounts.length) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
'No accounts were returned by the provider. Please make sure your wallet has an active EVM-compatible account selected.'
|
|
53
|
+
);
|
|
54
|
+
}
|
|
45
55
|
const formattedAccounts = formatAccountsToCAIP(
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
providerAccounts.accounts,
|
|
57
|
+
providerAccounts.chainId
|
|
48
58
|
);
|
|
49
59
|
|
|
50
60
|
return {
|
|
51
61
|
accounts: formattedAccounts,
|
|
52
|
-
network:
|
|
62
|
+
network: providerAccounts.chainId,
|
|
53
63
|
};
|
|
54
64
|
};
|
|
55
65
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { EvmActions, ProviderAPI } from './types.js';
|
|
2
2
|
|
|
3
|
-
import { AccountId } from 'caip';
|
|
4
|
-
|
|
5
3
|
import { ActionBuilder } from '../../mod.js';
|
|
6
4
|
import { ChangeAccountSubscriberBuilder } from '../common/hooks/changeAccountSubscriber.js';
|
|
7
5
|
import {
|
|
@@ -10,7 +8,7 @@ import {
|
|
|
10
8
|
intoConnectionFinished,
|
|
11
9
|
} from '../common/mod.js';
|
|
12
10
|
|
|
13
|
-
import {
|
|
11
|
+
import { formatAccountsToCAIP } from './utils.js';
|
|
14
12
|
|
|
15
13
|
// Actions
|
|
16
14
|
export const connect = () =>
|
|
@@ -39,15 +37,7 @@ export const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>
|
|
|
39
37
|
)
|
|
40
38
|
.format(async (instance, accounts) => {
|
|
41
39
|
const chainId = await instance.request({ method: 'eth_chainId' });
|
|
42
|
-
return accounts
|
|
43
|
-
AccountId.format({
|
|
44
|
-
address: account,
|
|
45
|
-
chainId: {
|
|
46
|
-
namespace: CAIP_NAMESPACE,
|
|
47
|
-
reference: chainId,
|
|
48
|
-
},
|
|
49
|
-
})
|
|
50
|
-
);
|
|
40
|
+
return formatAccountsToCAIP(accounts, chainId);
|
|
51
41
|
})
|
|
52
42
|
.addEventListener((instance, callback) => {
|
|
53
43
|
instance.on('accountsChanged', callback);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
/*
|
|
2
3
|
* These are copied from `viem` (EIP1193Provider)
|
|
3
4
|
* They have an issue with `node16`, we can not directly import from their package.
|
|
@@ -241,7 +242,6 @@ export type EIP1193Events = {
|
|
|
241
242
|
|
|
242
243
|
export type Prettify<T> = {
|
|
243
244
|
[K in keyof T]: T[K];
|
|
244
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
245
245
|
} & {};
|
|
246
246
|
|
|
247
247
|
export type RpcSchema = readonly {
|
|
@@ -1411,4 +1411,5 @@ export type EIP1474Methods = [
|
|
|
1411
1411
|
|
|
1412
1412
|
export type EIP1193Provider = EIP1193Events & {
|
|
1413
1413
|
request: EIP1193RequestFn<EIP1474Methods>;
|
|
1414
|
+
disconnect: () => void;
|
|
1414
1415
|
};
|
|
@@ -9,7 +9,13 @@ import { CAIP_NAMESPACE, CAIP_SOLANA_CHAIN_ID } from './constants.js';
|
|
|
9
9
|
|
|
10
10
|
export async function getAccounts(provider: ProviderAPI) {
|
|
11
11
|
const solanaResponse = await provider.connect();
|
|
12
|
-
|
|
12
|
+
/*
|
|
13
|
+
* Fallback for wallets like Coinbase that return no response on connect.
|
|
14
|
+
* If solanaResponse is undefined, use the provider's publicKey directly.
|
|
15
|
+
*/
|
|
16
|
+
const account = solanaResponse
|
|
17
|
+
? solanaResponse.publicKey.toString()
|
|
18
|
+
: provider.publicKey.toString();
|
|
13
19
|
return {
|
|
14
20
|
accounts: [account],
|
|
15
21
|
chainId: LegacyNetworks.SOLANA,
|
package/src/types/mod.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { AnyFunction } from './actions.js';
|
|
1
|
+
export type { AnyFunction, FunctionWithContext } from './actions.js';
|