@rango-dev/wallets-core 0.43.1-next.0 → 0.43.1-next.10
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/builders/namespace.d.ts.map +1 -1
- package/dist/hub/hub.d.ts +1 -0
- package/dist/hub/hub.d.ts.map +1 -1
- package/dist/hub/namespaces/namespace.d.ts +1 -0
- package/dist/hub/namespaces/namespace.d.ts.map +1 -1
- package/dist/hub/provider/provider.d.ts.map +1 -1
- package/dist/hub/store/mod.js +1 -1
- package/dist/hub/store/mod.js.map +2 -2
- package/dist/hub/store/providers.d.ts +26 -2
- package/dist/hub/store/providers.d.ts.map +1 -1
- package/dist/legacy/mod.d.ts +1 -1
- package/dist/legacy/mod.d.ts.map +1 -1
- package/dist/legacy/mod.js +1 -1
- package/dist/legacy/mod.js.map +2 -2
- package/dist/legacy/types.d.ts +12 -12
- package/dist/legacy/types.d.ts.map +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +3 -3
- package/dist/namespaces/common/mod.d.ts +1 -1
- package/dist/namespaces/common/mod.d.ts.map +1 -1
- package/dist/namespaces/common/mod.js +1 -1
- package/dist/namespaces/common/mod.js.map +2 -2
- package/dist/namespaces/common/types.d.ts +0 -4
- package/dist/namespaces/common/types.d.ts.map +1 -1
- package/dist/namespaces/evm/mod.d.ts +0 -1
- package/dist/namespaces/evm/mod.d.ts.map +1 -1
- package/dist/namespaces/evm/mod.js +1 -1
- package/dist/namespaces/evm/mod.js.map +4 -4
- package/dist/namespaces/solana/actions.d.ts +3 -1
- package/dist/namespaces/solana/actions.d.ts.map +1 -1
- package/dist/namespaces/solana/mod.d.ts +0 -1
- package/dist/namespaces/solana/mod.d.ts.map +1 -1
- package/dist/namespaces/solana/mod.js +1 -1
- package/dist/namespaces/solana/mod.js.map +4 -4
- package/dist/namespaces/solana/utils.d.ts +7 -0
- package/dist/namespaces/solana/utils.d.ts.map +1 -0
- package/dist/namespaces/sui/actions.d.ts +5 -1
- package/dist/namespaces/sui/actions.d.ts.map +1 -1
- package/dist/namespaces/sui/builders.d.ts +1 -0
- package/dist/namespaces/sui/builders.d.ts.map +1 -1
- package/dist/namespaces/sui/mod.d.ts +1 -2
- package/dist/namespaces/sui/mod.d.ts.map +1 -1
- package/dist/namespaces/sui/mod.js +1 -1
- package/dist/namespaces/sui/mod.js.map +4 -4
- package/dist/namespaces/sui/utils.d.ts +4 -0
- package/dist/namespaces/sui/utils.d.ts.map +1 -1
- package/dist/namespaces/utxo/mod.d.ts +0 -1
- package/dist/namespaces/utxo/mod.d.ts.map +1 -1
- package/dist/namespaces/utxo/mod.js +1 -1
- package/dist/namespaces/utxo/mod.js.map +4 -4
- package/dist/wallets-core.build.json +1 -1
- package/package.json +1 -1
- package/src/builders/namespace.ts +31 -2
- package/src/hub/hub.ts +13 -0
- package/src/hub/namespaces/namespace.test.ts +21 -0
- package/src/hub/namespaces/namespace.ts +3 -1
- package/src/hub/provider/provider.test.ts +2 -1
- package/src/hub/provider/provider.ts +2 -0
- package/src/hub/store/providers.ts +45 -2
- package/src/hub/store/selectors.ts +1 -1
- package/src/hub/store/store.test.ts +20 -0
- package/src/legacy/mod.ts +1 -0
- package/src/legacy/types.ts +13 -12
- package/src/namespaces/common/mod.ts +1 -1
- package/src/namespaces/common/types.ts +0 -5
- package/src/namespaces/evm/mod.ts +0 -1
- package/src/namespaces/solana/actions.ts +29 -2
- package/src/namespaces/solana/mod.ts +0 -1
- package/src/namespaces/solana/utils.ts +12 -0
- package/src/namespaces/sui/actions.ts +26 -1
- package/src/namespaces/sui/builders.ts +3 -0
- package/src/namespaces/sui/mod.ts +1 -2
- package/src/namespaces/sui/utils.ts +11 -2
- package/src/namespaces/utxo/mod.ts +0 -1
- package/dist/namespaces/evm/chains.d.ts +0 -5
- package/dist/namespaces/evm/chains.d.ts.map +0 -1
- package/dist/namespaces/solana/chains.d.ts +0 -3
- package/dist/namespaces/solana/chains.d.ts.map +0 -1
- package/dist/namespaces/sui/chains.d.ts +0 -3
- package/dist/namespaces/sui/chains.d.ts.map +0 -1
- package/dist/namespaces/utxo/chains.d.ts +0 -3
- package/dist/namespaces/utxo/chains.d.ts.map +0 -1
- package/src/namespaces/evm/chains.ts +0 -14
- package/src/namespaces/solana/chains.ts +0 -6
- package/src/namespaces/sui/chains.ts +0 -6
- package/src/namespaces/utxo/chains.ts +0 -6
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { ProviderAPI, SolanaActions } from './types.js';
|
|
2
|
-
import type { Subscriber } from '../../hub/namespaces/mod.js';
|
|
2
|
+
import type { Context, Subscriber } from '../../hub/namespaces/mod.js';
|
|
3
3
|
import type { SubscriberCleanUp } from '../../hub/namespaces/types.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { CaipAccount } from '../../types/accounts.js';
|
|
5
|
+
import type { AnyFunction, FunctionWithContext } from '../../types/actions.js';
|
|
5
6
|
|
|
6
7
|
import { AccountId } from 'caip';
|
|
7
8
|
|
|
8
9
|
import { recommended as commonRecommended } from '../common/actions.js';
|
|
9
10
|
|
|
10
11
|
import { CAIP_NAMESPACE, CAIP_SOLANA_CHAIN_ID } from './constants.js';
|
|
12
|
+
import { getAccounts } from './utils.js';
|
|
11
13
|
|
|
12
14
|
export const recommended = [...commonRecommended];
|
|
13
15
|
|
|
@@ -64,3 +66,28 @@ export function changeAccountSubscriber(
|
|
|
64
66
|
},
|
|
65
67
|
];
|
|
66
68
|
}
|
|
69
|
+
export function connect(
|
|
70
|
+
instance: () => ProviderAPI
|
|
71
|
+
): FunctionWithContext<SolanaActions['connect'], Context> {
|
|
72
|
+
return async () => {
|
|
73
|
+
const solanaInstance = instance();
|
|
74
|
+
const result = await getAccounts(solanaInstance);
|
|
75
|
+
|
|
76
|
+
if (Array.isArray(result)) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
'Expecting solana response to be a single value, not an array.'
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return result.accounts.map(
|
|
83
|
+
(account) =>
|
|
84
|
+
AccountId.format({
|
|
85
|
+
address: account,
|
|
86
|
+
chainId: {
|
|
87
|
+
namespace: CAIP_NAMESPACE,
|
|
88
|
+
reference: CAIP_SOLANA_CHAIN_ID,
|
|
89
|
+
},
|
|
90
|
+
}) as CaipAccount
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -3,7 +3,6 @@ export * as after from './after.js';
|
|
|
3
3
|
export * as and from './and.js';
|
|
4
4
|
export * as before from './before.js';
|
|
5
5
|
export * as builders from './builders.js';
|
|
6
|
-
export * as chains from './chains.js';
|
|
7
6
|
|
|
8
7
|
export type { ProviderAPI, SolanaActions } from './types.js';
|
|
9
8
|
export { CAIP_NAMESPACE, CAIP_SOLANA_CHAIN_ID } from './constants.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ProviderAPI } from './types.js';
|
|
2
|
+
|
|
3
|
+
import { LegacyNetworks } from '../../legacy/mod.js';
|
|
4
|
+
|
|
5
|
+
export async function getAccounts(provider: ProviderAPI) {
|
|
6
|
+
const solanaResponse = await provider.connect();
|
|
7
|
+
const account = solanaResponse.publicKey.toString();
|
|
8
|
+
return {
|
|
9
|
+
accounts: [account],
|
|
10
|
+
chainId: LegacyNetworks.SOLANA,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { SuiActions } from './types.js';
|
|
2
2
|
import type { Subscriber } from '../../hub/namespaces/mod.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
CanEagerConnect,
|
|
5
|
+
SubscriberCleanUp,
|
|
6
|
+
} from '../../hub/namespaces/types.js';
|
|
4
7
|
import type { StandardEventsChangeProperties } from '@mysten/wallet-standard';
|
|
5
8
|
|
|
6
9
|
import { AccountId } from 'caip';
|
|
@@ -60,3 +63,25 @@ export function changeAccountSubscriber(
|
|
|
60
63
|
},
|
|
61
64
|
];
|
|
62
65
|
}
|
|
66
|
+
interface CanEagerConnectParams {
|
|
67
|
+
name: string;
|
|
68
|
+
}
|
|
69
|
+
export function canEagerConnect(
|
|
70
|
+
params: CanEagerConnectParams
|
|
71
|
+
): CanEagerConnect<SuiActions> {
|
|
72
|
+
return async () => {
|
|
73
|
+
const wallet = getInstanceOrThrow(params.name);
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const connectResult = await wallet.features['standard:connect'].connect({
|
|
77
|
+
silent: true,
|
|
78
|
+
});
|
|
79
|
+
if (connectResult.accounts.length) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -39,3 +39,6 @@ export const connect = (params: ConnectParams) =>
|
|
|
39
39
|
.and(connectAndUpdateStateForSingleNetwork)
|
|
40
40
|
.before(intoConnecting)
|
|
41
41
|
.after(intoConnectionFinished);
|
|
42
|
+
|
|
43
|
+
export const canEagerConnect = () =>
|
|
44
|
+
new ActionBuilder<SuiActions, 'canEagerConnect'>('canEagerConnect');
|
|
@@ -2,7 +2,6 @@ export type { ProviderAPI, SuiActions } from './types.js';
|
|
|
2
2
|
|
|
3
3
|
export * as actions from './actions.js';
|
|
4
4
|
export * as builders from './builders.js';
|
|
5
|
-
export
|
|
6
|
-
export { getInstanceOrThrow } from './utils.js';
|
|
5
|
+
export { getInstanceOrThrow, getInstance } from './utils.js';
|
|
7
6
|
|
|
8
7
|
export { CAIP_NAMESPACE, CAIP_SUI_CHAIN_ID } from './constants.js';
|
|
@@ -15,7 +15,7 @@ type SuiWalletStandard = WalletWithFeatures<
|
|
|
15
15
|
/**
|
|
16
16
|
* @param name each wallet has a name in WalletStandard. you should pass that value
|
|
17
17
|
*/
|
|
18
|
-
export function
|
|
18
|
+
export function getInstance(name: string): SuiWalletStandard | undefined {
|
|
19
19
|
const wallet = getWallets()
|
|
20
20
|
.get()
|
|
21
21
|
.find(
|
|
@@ -23,11 +23,20 @@ export function getInstanceOrThrow(name: string): SuiWalletStandard {
|
|
|
23
23
|
wallet.name === name && wallet.chains.includes(SUI_MAINNET_CHAIN)
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
+
return wallet as SuiWalletStandard;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param name each wallet has a name in WalletStandard. you should pass that value
|
|
31
|
+
*/
|
|
32
|
+
export function getInstanceOrThrow(name: string): SuiWalletStandard {
|
|
33
|
+
const wallet = getInstance(name);
|
|
34
|
+
|
|
26
35
|
if (!wallet) {
|
|
27
36
|
throw new Error(
|
|
28
37
|
"We couldn't find the Sui instance on your wallet. It may be fixed by refreshing the page."
|
|
29
38
|
);
|
|
30
39
|
}
|
|
31
40
|
|
|
32
|
-
return wallet
|
|
41
|
+
return wallet;
|
|
33
42
|
}
|
|
@@ -3,7 +3,6 @@ export * as after from './after.js';
|
|
|
3
3
|
export * as and from './and.js';
|
|
4
4
|
export * as before from './before.js';
|
|
5
5
|
export * as builders from './builders.js';
|
|
6
|
-
export * as chains from './chains.js';
|
|
7
6
|
|
|
8
7
|
export type { ProviderAPI, UtxoActions } from './types.js';
|
|
9
8
|
export { CAIP_NAMESPACE, CAIP_BITCOIN_CHAIN_ID } from './constants.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../src/namespaces/evm/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,eAAO,MAAM,QAAQ,EAAE,KAGtB,CAAC;AACF,eAAO,MAAM,OAAO,EAAE,KAGrB,CAAC;AACF,eAAO,MAAM,IAAI,EAAE,KAGlB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../src/namespaces/solana/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,eAAO,MAAM,MAAM,EAAE,KAGpB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../src/namespaces/sui/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,eAAO,MAAM,GAAG,EAAE,KAGjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../src/namespaces/utxo/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,eAAO,MAAM,OAAO,EAAE,KAGrB,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Chain } from '../common/types.js';
|
|
2
|
-
|
|
3
|
-
export const ethereum: Chain = {
|
|
4
|
-
name: 'ETH',
|
|
5
|
-
logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/ETH/icon.svg',
|
|
6
|
-
};
|
|
7
|
-
export const polygon: Chain = {
|
|
8
|
-
name: 'POLYGON',
|
|
9
|
-
logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/POLYGON/icon.svg',
|
|
10
|
-
};
|
|
11
|
-
export const base: Chain = {
|
|
12
|
-
name: 'BASE',
|
|
13
|
-
logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BASE/icon.svg',
|
|
14
|
-
};
|