Skip to content

Commit

Permalink
chore: rename providerapi
Browse files Browse the repository at this point in the history
(cherry picked from commit 91a1844)
  • Loading branch information
yeager-eren committed Sep 18, 2024
1 parent 3ee70e9 commit 1e5a4fd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions wallets/core/src/namespaces/evm/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { EIP1193EventMap } from './eip1193.js';
import type { EvmActions, ProviderApi } from './types.js';
import type { EvmActions, ProviderAPI } from './types.js';
import type { Context, Subscriber } from '../../hub/namespaces/mod.js';
import type { SubscriberCleanUp } from '../../hub/namespaces/types.js';
import type { CaipAccount } from '../../types/accounts.js';
Expand All @@ -15,7 +15,7 @@ import { getAccounts, switchOrAddNetwork } from './utils.js';
export const recommended = [...commonRecommended];

export function connect(
instance: () => ProviderApi
instance: () => ProviderAPI
): FunctionWithContext<EvmActions['connect'], Context> {
return async (_context, chain) => {
const evmInstance = instance();
Expand Down Expand Up @@ -53,7 +53,7 @@ export function connect(
}

export function changeAccountSubscriber(
instance: () => ProviderApi
instance: () => ProviderAPI
): [Subscriber<EvmActions>, SubscriberCleanUp<EvmActions>] {
let eventCallback: EIP1193EventMap['accountsChanged'];

Expand Down
2 changes: 1 addition & 1 deletion wallets/core/src/namespaces/evm/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export * as before from './before.js';
export * as utils from './utils.js';
export * as builders from './builders.js';

export type { EvmActions, ProviderApi } from './types.js';
export type { EvmActions, ProviderAPI } from './types.js';
export { CAIP_NAMESPACE, CAIP_ETHEREUM_CHAIN_ID } from './constants.js';
2 changes: 1 addition & 1 deletion wallets/core/src/namespaces/evm/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface EvmActions
connect: (chain?: Chain | ChainId) => Promise<AccountsWithActiveChain>;
}

export type { EIP1193Provider as ProviderApi } from './eip1193.js';
export type { EIP1193Provider as ProviderAPI } from './eip1193.js';

// A 0x-prefixed hexadecimal string
export type ChainId = string;
Expand Down
10 changes: 5 additions & 5 deletions wallets/core/src/namespaces/evm/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Chain, ChainId, ProviderApi } from './types.js';
import type { Chain, ChainId, ProviderAPI } from './types.js';

export async function getAccounts(provider: ProviderApi) {
export async function getAccounts(provider: ProviderAPI) {
const [accounts, chainId] = await Promise.all([
provider.request({ method: 'eth_requestAccounts' }),
provider.request({ method: 'eth_chainId' }),
Expand All @@ -12,22 +12,22 @@ export async function getAccounts(provider: ProviderApi) {
};
}

export async function suggestNetwork(instance: ProviderApi, chain: Chain) {
export async function suggestNetwork(instance: ProviderAPI, chain: Chain) {
return await instance.request({
method: 'wallet_addEthereumChain',
params: [chain],
});
}

export async function switchNetwork(instance: ProviderApi, chainId: ChainId) {
export async function switchNetwork(instance: ProviderAPI, chainId: ChainId) {
return await instance.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: chainId }],
});
}

export async function switchOrAddNetwork(
instance: ProviderApi,
instance: ProviderAPI,
chain: ChainId | Chain
) {
try {
Expand Down
4 changes: 2 additions & 2 deletions wallets/core/src/namespaces/solana/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ProviderApi, SolanaActions } from './types.js';
import type { ProviderAPI, SolanaActions } from './types.js';
import type { Subscriber } from '../../hub/namespaces/mod.js';
import type { SubscriberCleanUp } from '../../hub/namespaces/types.js';
import type { AnyFunction } from '../../types/actions.js';
Expand All @@ -12,7 +12,7 @@ import { CAIP_NAMESPACE, CAIP_SOLANA_CHAIN_ID } from './constants.js';
export const recommended = [...commonRecommended];

export function changeAccountSubscriber(
instance: () => ProviderApi | undefined
instance: () => ProviderAPI | undefined
): [Subscriber<SolanaActions>, SubscriberCleanUp<SolanaActions>] {
let eventCallback: AnyFunction;

Expand Down
2 changes: 1 addition & 1 deletion wallets/core/src/namespaces/solana/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export * as and from './and.js';
export * as before from './before.js';
export * as builders from './builders.js';

export type { ProviderApi, SolanaActions } from './types.js';
export type { ProviderAPI, SolanaActions } from './types.js';
export { CAIP_NAMESPACE, CAIP_SOLANA_CHAIN_ID } from './constants.js';
2 changes: 1 addition & 1 deletion wallets/core/src/namespaces/solana/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export interface SolanaActions
* If Phantom's interface is what Solana wallets are supporting, another option would be define that type here.
*
*/
export type ProviderApi = Record<string, any>;
export type ProviderAPI = Record<string, any>;

0 comments on commit 1e5a4fd

Please sign in to comment.