@ab-org/sdk-core 0.0.1 → 0.1.1
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.d.ts +536 -16
- package/dist/index.js +1776 -16
- package/package.json +5 -3
- package/dist/core/capabilities.d.ts +0 -32
- package/dist/core/capabilities.js +0 -88
- package/dist/core/chains.d.ts +0 -23
- package/dist/core/chains.js +0 -83
- package/dist/core/errors.d.ts +0 -9
- package/dist/core/errors.js +0 -51
- package/dist/core/sessionStore.d.ts +0 -26
- package/dist/core/sessionStore.js +0 -129
- package/dist/core/types.d.ts +0 -75
- package/dist/core/types.js +0 -1
- package/dist/core/walletConnector.d.ts +0 -29
- package/dist/core/walletConnector.js +0 -153
- package/dist/core/walletExecution.d.ts +0 -22
- package/dist/core/walletExecution.js +0 -89
- package/dist/hooks/useAccount.d.ts +0 -11
- package/dist/hooks/useAccount.js +0 -32
- package/dist/hooks/useWalletConnect.d.ts +0 -16
- package/dist/hooks/useWalletConnect.js +0 -24
- package/dist/providers/base.d.ts +0 -15
- package/dist/providers/base.js +0 -30
- package/dist/providers/plugin/injectedEvmProvider.d.ts +0 -112
- package/dist/providers/plugin/injectedEvmProvider.js +0 -326
- package/dist/providers/plugin/injectedWalletRegistry.d.ts +0 -9
- package/dist/providers/plugin/injectedWalletRegistry.js +0 -34
- package/dist/providers/plugin/metamaskProvider.d.ts +0 -1
- package/dist/providers/plugin/metamaskProvider.js +0 -1
- package/dist/providers/social/baseSocialProvider.d.ts +0 -21
- package/dist/providers/social/baseSocialProvider.js +0 -11
- package/dist/providers/social/cubeSignerAuth.d.ts +0 -89
- package/dist/providers/social/cubeSignerAuth.js +0 -128
- package/dist/providers/social/cubistEvmWalletProvider.d.ts +0 -9
- package/dist/providers/social/cubistEvmWalletProvider.js +0 -175
- package/dist/providers/social/cubistProvider.d.ts +0 -52
- package/dist/providers/social/cubistProvider.js +0 -160
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { sessionStore } from "./sessionStore.js";
|
|
2
|
-
import { createWalletExecutionClient } from "./walletExecution.js";
|
|
3
|
-
const ADAPTER_STORAGE_KEY = "ab:wallet:adapterId";
|
|
4
|
-
function getStorage() {
|
|
5
|
-
try {
|
|
6
|
-
return typeof localStorage !== "undefined" ? localStorage : null;
|
|
7
|
-
}
|
|
8
|
-
catch {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function persistAdapterId(adapterId) {
|
|
13
|
-
const storage = getStorage();
|
|
14
|
-
if (!storage)
|
|
15
|
-
return;
|
|
16
|
-
if (!adapterId) {
|
|
17
|
-
storage.removeItem(ADAPTER_STORAGE_KEY);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
storage.setItem(ADAPTER_STORAGE_KEY, adapterId);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function readPersistedAdapterId() {
|
|
24
|
-
const storage = getStorage();
|
|
25
|
-
if (!storage)
|
|
26
|
-
return null;
|
|
27
|
-
return storage.getItem(ADAPTER_STORAGE_KEY);
|
|
28
|
-
}
|
|
29
|
-
export class WalletConnector {
|
|
30
|
-
constructor(adapters) {
|
|
31
|
-
this.adapters = adapters;
|
|
32
|
-
this.currentAdapterId = null;
|
|
33
|
-
this.currentAdapterId = readPersistedAdapterId();
|
|
34
|
-
}
|
|
35
|
-
getAdapterById(adapterId) {
|
|
36
|
-
const adapter = this.adapters.find((item) => item.id === adapterId);
|
|
37
|
-
if (!adapter)
|
|
38
|
-
throw new Error(`Wallet adapter ${adapterId} not registered`);
|
|
39
|
-
return adapter;
|
|
40
|
-
}
|
|
41
|
-
getCurrentAdapter(session = sessionStore.getState().session) {
|
|
42
|
-
return ((this.currentAdapterId
|
|
43
|
-
? this.adapters.find((item) => item.id === this.currentAdapterId)
|
|
44
|
-
: undefined) ??
|
|
45
|
-
this.adapters.find((item) => item.getProvider() === session?.provider));
|
|
46
|
-
}
|
|
47
|
-
clearActiveSession() {
|
|
48
|
-
this.currentAdapterId = null;
|
|
49
|
-
persistAdapterId(null);
|
|
50
|
-
sessionStore.clearSession();
|
|
51
|
-
}
|
|
52
|
-
requireActiveSession() {
|
|
53
|
-
const session = sessionStore.getState().session;
|
|
54
|
-
if (!session) {
|
|
55
|
-
throw new Error("Wallet session missing");
|
|
56
|
-
}
|
|
57
|
-
return session;
|
|
58
|
-
}
|
|
59
|
-
async connect(adapterId, args) {
|
|
60
|
-
const adapter = this.getAdapterById(adapterId);
|
|
61
|
-
const currentAdapter = this.getCurrentAdapter();
|
|
62
|
-
if (currentAdapter && currentAdapter.id !== adapter.id) {
|
|
63
|
-
await currentAdapter.disconnect();
|
|
64
|
-
this.clearActiveSession();
|
|
65
|
-
}
|
|
66
|
-
sessionStore.setConnecting(true);
|
|
67
|
-
try {
|
|
68
|
-
const session = await adapter.connect(args);
|
|
69
|
-
this.currentAdapterId = adapter.id;
|
|
70
|
-
persistAdapterId(adapter.id);
|
|
71
|
-
sessionStore.setSession(session);
|
|
72
|
-
sessionStore.setBalance(null);
|
|
73
|
-
return session;
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
sessionStore.setConnecting(false);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async disconnect() {
|
|
80
|
-
const adapter = this.getCurrentAdapter();
|
|
81
|
-
if (!adapter)
|
|
82
|
-
return;
|
|
83
|
-
await adapter?.disconnect();
|
|
84
|
-
this.clearActiveSession();
|
|
85
|
-
}
|
|
86
|
-
rehydrateSession(adapterId, session) {
|
|
87
|
-
this.currentAdapterId = adapterId;
|
|
88
|
-
persistAdapterId(adapterId);
|
|
89
|
-
sessionStore.rehydrateSession(session);
|
|
90
|
-
sessionStore.setBalance(null);
|
|
91
|
-
return session;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Attempt to silently reconnect a wallet whose session was rehydrated
|
|
95
|
-
* from localStorage. Uses the adapter's `reconnect()` if available,
|
|
96
|
-
* falling back to `connect()` for backward compatibility.
|
|
97
|
-
*
|
|
98
|
-
* Returns the restored session on success, or `null` if reconnection
|
|
99
|
-
* is not possible (e.g. wallet extension removed, social session expired).
|
|
100
|
-
*/
|
|
101
|
-
async tryAutoReconnect() {
|
|
102
|
-
const state = sessionStore.getState();
|
|
103
|
-
if (!state.session)
|
|
104
|
-
return null;
|
|
105
|
-
const adapterId = this.currentAdapterId ?? readPersistedAdapterId();
|
|
106
|
-
if (!adapterId)
|
|
107
|
-
return null;
|
|
108
|
-
const adapter = this.adapters.find((a) => a.id === adapterId);
|
|
109
|
-
if (!adapter)
|
|
110
|
-
return null;
|
|
111
|
-
sessionStore.setConnecting(true);
|
|
112
|
-
try {
|
|
113
|
-
const session = adapter.reconnect
|
|
114
|
-
? await adapter.reconnect(state.session)
|
|
115
|
-
: null;
|
|
116
|
-
if (!session)
|
|
117
|
-
return null;
|
|
118
|
-
this.currentAdapterId = adapterId;
|
|
119
|
-
persistAdapterId(adapterId);
|
|
120
|
-
sessionStore.rehydrateSession(session);
|
|
121
|
-
return session;
|
|
122
|
-
}
|
|
123
|
-
catch {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
finally {
|
|
127
|
-
sessionStore.setConnecting(false);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
supportsCapability(capability) {
|
|
131
|
-
const session = this.requireActiveSession();
|
|
132
|
-
return createWalletExecutionClient(session).supports(capability);
|
|
133
|
-
}
|
|
134
|
-
async requestCurrentProvider(payload) {
|
|
135
|
-
return this.requireActiveSession().provider.request(payload);
|
|
136
|
-
}
|
|
137
|
-
async sendEvmTransaction(transaction) {
|
|
138
|
-
const session = this.requireActiveSession();
|
|
139
|
-
return createWalletExecutionClient(session).sendTransaction(transaction);
|
|
140
|
-
}
|
|
141
|
-
async signEvmTransaction(transaction) {
|
|
142
|
-
const session = this.requireActiveSession();
|
|
143
|
-
return createWalletExecutionClient(session).signTransaction(transaction);
|
|
144
|
-
}
|
|
145
|
-
async signMessage(message) {
|
|
146
|
-
const session = this.requireActiveSession();
|
|
147
|
-
return createWalletExecutionClient(session).signMessage(message);
|
|
148
|
-
}
|
|
149
|
-
async signTypedData(typedData) {
|
|
150
|
-
const session = this.requireActiveSession();
|
|
151
|
-
return createWalletExecutionClient(session).signTypedData(typedData);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type SessionCapabilityCheck, type WalletCapability } from "./capabilities.js";
|
|
2
|
-
import type { EvmTransactionRequest, WalletSession } from "./types.js";
|
|
3
|
-
export interface WalletExecutionClient {
|
|
4
|
-
readonly session: WalletSession;
|
|
5
|
-
readonly capabilities: WalletCapability[];
|
|
6
|
-
supports(capability: WalletCapability): boolean;
|
|
7
|
-
sendTransaction(transaction: EvmTransactionRequest, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
8
|
-
signTransaction(transaction: EvmTransactionRequest, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
9
|
-
signMessage(message: string, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
10
|
-
signTypedData(typedData: Record<string, unknown>, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
11
|
-
}
|
|
12
|
-
export declare const getWalletExecutionCapabilities: (session?: WalletSession | null) => WalletCapability[];
|
|
13
|
-
export declare const createWalletExecutionClient: (session?: WalletSession | null) => WalletExecutionClient;
|
|
14
|
-
export declare const createWalletExecutionController: () => {
|
|
15
|
-
readonly session: WalletSession | null;
|
|
16
|
-
readonly capabilities: string[];
|
|
17
|
-
supports(capability: WalletCapability): boolean;
|
|
18
|
-
sendTransaction(transaction: EvmTransactionRequest, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
19
|
-
signTransaction(transaction: EvmTransactionRequest, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
20
|
-
signMessage(message: string, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
21
|
-
signTypedData(typedData: Record<string, unknown>, check?: Omit<SessionCapabilityCheck, "capability">): Promise<string>;
|
|
22
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { assertSessionCapability, } from "./capabilities.js";
|
|
2
|
-
import { sessionStore } from "./sessionStore.js";
|
|
3
|
-
const requireSession = (session) => {
|
|
4
|
-
const resolvedSession = session ?? sessionStore.getState().session;
|
|
5
|
-
if (!resolvedSession) {
|
|
6
|
-
throw new Error("Wallet session missing");
|
|
7
|
-
}
|
|
8
|
-
return resolvedSession;
|
|
9
|
-
};
|
|
10
|
-
const performCapabilityCheck = (session, capability, check) => {
|
|
11
|
-
assertSessionCapability(session, {
|
|
12
|
-
capability,
|
|
13
|
-
chain: check?.chain ?? session.chainContext?.walletChain ?? session.chain,
|
|
14
|
-
token: check?.token,
|
|
15
|
-
amount: check?.amount,
|
|
16
|
-
appId: check?.appId,
|
|
17
|
-
origin: check?.origin,
|
|
18
|
-
now: check?.now,
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
export const getWalletExecutionCapabilities = (session) => requireSession(session).capabilities ?? [];
|
|
22
|
-
export const createWalletExecutionClient = (session) => {
|
|
23
|
-
const resolvedSession = requireSession(session);
|
|
24
|
-
return {
|
|
25
|
-
session: resolvedSession,
|
|
26
|
-
capabilities: resolvedSession.capabilities ?? [],
|
|
27
|
-
supports(capability) {
|
|
28
|
-
return this.capabilities.length === 0 || this.capabilities.includes(capability);
|
|
29
|
-
},
|
|
30
|
-
async sendTransaction(transaction, check) {
|
|
31
|
-
performCapabilityCheck(resolvedSession, "eth_sendTransaction", {
|
|
32
|
-
...check,
|
|
33
|
-
amount: check?.amount ?? transaction.value,
|
|
34
|
-
});
|
|
35
|
-
return resolvedSession.provider.request({
|
|
36
|
-
method: "eth_sendTransaction",
|
|
37
|
-
params: [{ ...transaction, from: transaction.from ?? resolvedSession.address }],
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
async signTransaction(transaction, check) {
|
|
41
|
-
performCapabilityCheck(resolvedSession, "eth_signTransaction", {
|
|
42
|
-
...check,
|
|
43
|
-
amount: check?.amount ?? transaction.value,
|
|
44
|
-
});
|
|
45
|
-
return resolvedSession.provider.request({
|
|
46
|
-
method: "eth_signTransaction",
|
|
47
|
-
params: [{ ...transaction, from: transaction.from ?? resolvedSession.address }],
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
async signMessage(message, check) {
|
|
51
|
-
performCapabilityCheck(resolvedSession, "personal_sign", check);
|
|
52
|
-
return resolvedSession.provider.request({
|
|
53
|
-
method: "personal_sign",
|
|
54
|
-
params: [message, resolvedSession.address],
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
async signTypedData(typedData, check) {
|
|
58
|
-
performCapabilityCheck(resolvedSession, "eth_signTypedData_v4", check);
|
|
59
|
-
return resolvedSession.provider.request({
|
|
60
|
-
method: "eth_signTypedData_v4",
|
|
61
|
-
params: [resolvedSession.address, JSON.stringify(typedData)],
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
export const createWalletExecutionController = () => ({
|
|
67
|
-
get session() {
|
|
68
|
-
return sessionStore.getState().session;
|
|
69
|
-
},
|
|
70
|
-
get capabilities() {
|
|
71
|
-
return sessionStore.getState().session?.capabilities ?? [];
|
|
72
|
-
},
|
|
73
|
-
supports(capability) {
|
|
74
|
-
const session = requireSession();
|
|
75
|
-
return createWalletExecutionClient(session).supports(capability);
|
|
76
|
-
},
|
|
77
|
-
sendTransaction(transaction, check) {
|
|
78
|
-
return createWalletExecutionClient().sendTransaction(transaction, check);
|
|
79
|
-
},
|
|
80
|
-
signTransaction(transaction, check) {
|
|
81
|
-
return createWalletExecutionClient().signTransaction(transaction, check);
|
|
82
|
-
},
|
|
83
|
-
signMessage(message, check) {
|
|
84
|
-
return createWalletExecutionClient().signMessage(message, check);
|
|
85
|
-
},
|
|
86
|
-
signTypedData(typedData, check) {
|
|
87
|
-
return createWalletExecutionClient().signTypedData(typedData, check);
|
|
88
|
-
},
|
|
89
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const createAccountController: () => {
|
|
2
|
-
readonly session: import("../index.js").WalletSession | null;
|
|
3
|
-
readonly address: string | null;
|
|
4
|
-
readonly chain: import("../index.js").SupportedChain | null;
|
|
5
|
-
readonly balance: import("../index.js").BalanceInfo | null;
|
|
6
|
-
readonly isConnected: boolean;
|
|
7
|
-
readonly currentProvider: import("../index.js").WalletProvider | null;
|
|
8
|
-
readonly chainContext: import("../index.js").ChainContext | null;
|
|
9
|
-
readonly capabilities: string[];
|
|
10
|
-
readonly capabilityPolicy: import("../index.js").SessionCapabilityPolicy | null;
|
|
11
|
-
};
|
package/dist/hooks/useAccount.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { sessionStore } from "../core/sessionStore.js";
|
|
2
|
-
export const createAccountController = () => {
|
|
3
|
-
return {
|
|
4
|
-
get session() {
|
|
5
|
-
return sessionStore.getState().session;
|
|
6
|
-
},
|
|
7
|
-
get address() {
|
|
8
|
-
return sessionStore.getState().session?.address ?? null;
|
|
9
|
-
},
|
|
10
|
-
get chain() {
|
|
11
|
-
return sessionStore.getState().session?.chain ?? null;
|
|
12
|
-
},
|
|
13
|
-
get balance() {
|
|
14
|
-
return sessionStore.getState().balance;
|
|
15
|
-
},
|
|
16
|
-
get isConnected() {
|
|
17
|
-
return Boolean(sessionStore.getState().session);
|
|
18
|
-
},
|
|
19
|
-
get currentProvider() {
|
|
20
|
-
return sessionStore.getState().session?.provider ?? null;
|
|
21
|
-
},
|
|
22
|
-
get chainContext() {
|
|
23
|
-
return sessionStore.getState().session?.chainContext ?? null;
|
|
24
|
-
},
|
|
25
|
-
get capabilities() {
|
|
26
|
-
return sessionStore.getState().session?.capabilities ?? [];
|
|
27
|
-
},
|
|
28
|
-
get capabilityPolicy() {
|
|
29
|
-
return sessionStore.getState().session?.capabilityPolicy ?? null;
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { WalletConnector } from "../core/walletConnector.js";
|
|
2
|
-
import type { WalletCapability } from "../core/capabilities.js";
|
|
3
|
-
import type { WalletConnectArgs, WalletSession } from "../core/types.js";
|
|
4
|
-
export interface WalletConnectControllerOptions {
|
|
5
|
-
connector: WalletConnector;
|
|
6
|
-
defaultAdapterId?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const createWalletConnectController: ({ connector, defaultAdapterId, }: WalletConnectControllerOptions) => {
|
|
9
|
-
readonly openModal: (adapterId?: string | undefined, args?: WalletConnectArgs) => Promise<void>;
|
|
10
|
-
readonly disconnect: () => Promise<void>;
|
|
11
|
-
readonly rehydrate: (adapterId: string, session: WalletSession) => WalletSession;
|
|
12
|
-
readonly tryAutoReconnect: () => Promise<WalletSession | null>;
|
|
13
|
-
readonly supports: (capability: WalletCapability) => boolean;
|
|
14
|
-
readonly isConnected: boolean;
|
|
15
|
-
readonly isConnecting: boolean;
|
|
16
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { sessionStore } from "../core/sessionStore.js";
|
|
2
|
-
export const createWalletConnectController = ({ connector, defaultAdapterId, }) => {
|
|
3
|
-
return {
|
|
4
|
-
openModal: async (adapterId = defaultAdapterId, args) => {
|
|
5
|
-
if (!adapterId)
|
|
6
|
-
throw new Error("No adapter id provided");
|
|
7
|
-
await connector.connect(adapterId, args);
|
|
8
|
-
},
|
|
9
|
-
disconnect: () => connector.disconnect(),
|
|
10
|
-
rehydrate: (adapterId, session) => connector.rehydrateSession(adapterId, session),
|
|
11
|
-
tryAutoReconnect: () => connector.tryAutoReconnect(),
|
|
12
|
-
supports(capability) {
|
|
13
|
-
if (!sessionStore.getState().session)
|
|
14
|
-
return false;
|
|
15
|
-
return connector.supportsCapability(capability);
|
|
16
|
-
},
|
|
17
|
-
get isConnected() {
|
|
18
|
-
return Boolean(sessionStore.getState().session);
|
|
19
|
-
},
|
|
20
|
-
get isConnecting() {
|
|
21
|
-
return sessionStore.getState().isConnecting;
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
};
|
package/dist/providers/base.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ProviderCategory, WalletAdapter, WalletConnectArgs, WalletProvider, WalletSession } from "../core/types.js";
|
|
2
|
-
export declare abstract class AbstractProvider implements WalletAdapter {
|
|
3
|
-
abstract readonly id: string;
|
|
4
|
-
abstract readonly title: string;
|
|
5
|
-
abstract readonly category: ProviderCategory;
|
|
6
|
-
protected currentSession: WalletSession | null;
|
|
7
|
-
abstract connect(args?: WalletConnectArgs): Promise<WalletSession>;
|
|
8
|
-
disconnect(): Promise<void>;
|
|
9
|
-
protected setSession(session: WalletSession): WalletSession;
|
|
10
|
-
protected clearSession(): void;
|
|
11
|
-
protected get session(): WalletSession | null;
|
|
12
|
-
protected requireSession(message?: string): WalletSession;
|
|
13
|
-
getProvider(): WalletProvider | null;
|
|
14
|
-
reconnect(_persistedSession: WalletSession): Promise<WalletSession | null>;
|
|
15
|
-
}
|
package/dist/providers/base.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export class AbstractProvider {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.currentSession = null;
|
|
4
|
-
}
|
|
5
|
-
async disconnect() {
|
|
6
|
-
this.clearSession();
|
|
7
|
-
}
|
|
8
|
-
setSession(session) {
|
|
9
|
-
this.currentSession = session;
|
|
10
|
-
return session;
|
|
11
|
-
}
|
|
12
|
-
clearSession() {
|
|
13
|
-
this.currentSession = null;
|
|
14
|
-
}
|
|
15
|
-
get session() {
|
|
16
|
-
return this.currentSession;
|
|
17
|
-
}
|
|
18
|
-
requireSession(message = `${this.title} session missing`) {
|
|
19
|
-
if (!this.currentSession) {
|
|
20
|
-
throw new Error(message);
|
|
21
|
-
}
|
|
22
|
-
return this.currentSession;
|
|
23
|
-
}
|
|
24
|
-
getProvider() {
|
|
25
|
-
return this.currentSession?.provider ?? null;
|
|
26
|
-
}
|
|
27
|
-
async reconnect(_persistedSession) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { AbstractProvider } from "../base.js";
|
|
2
|
-
import type { WalletConnectArgs, WalletProvider, WalletSession } from "../../core/types.js";
|
|
3
|
-
export interface InjectedEthereumProvider extends WalletProvider {
|
|
4
|
-
request<T = unknown>(args: {
|
|
5
|
-
method: string;
|
|
6
|
-
params?: unknown[];
|
|
7
|
-
}): Promise<T>;
|
|
8
|
-
providers?: InjectedEthereumProvider[];
|
|
9
|
-
isMetaMask?: boolean;
|
|
10
|
-
isCoinbaseWallet?: boolean;
|
|
11
|
-
isTrust?: boolean;
|
|
12
|
-
isTrustWallet?: boolean;
|
|
13
|
-
isPhantom?: boolean;
|
|
14
|
-
isRabby?: boolean;
|
|
15
|
-
isOkxWallet?: boolean;
|
|
16
|
-
isBitKeep?: boolean;
|
|
17
|
-
isRainbow?: boolean;
|
|
18
|
-
isZerion?: boolean;
|
|
19
|
-
isBraveWallet?: boolean;
|
|
20
|
-
isBitget?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface EIP6963ProviderInfo {
|
|
23
|
-
uuid: string;
|
|
24
|
-
name: string;
|
|
25
|
-
icon: string;
|
|
26
|
-
rdns: string;
|
|
27
|
-
}
|
|
28
|
-
export interface EIP6963ProviderDetail {
|
|
29
|
-
info: EIP6963ProviderInfo;
|
|
30
|
-
provider: InjectedEthereumProvider;
|
|
31
|
-
}
|
|
32
|
-
declare global {
|
|
33
|
-
interface Window {
|
|
34
|
-
ethereum?: InjectedEthereumProvider;
|
|
35
|
-
okxwallet?: InjectedEthereumProvider | {
|
|
36
|
-
ethereum?: InjectedEthereumProvider;
|
|
37
|
-
};
|
|
38
|
-
coinbaseWalletExtension?: InjectedEthereumProvider;
|
|
39
|
-
trustwallet?: InjectedEthereumProvider | {
|
|
40
|
-
ethereum?: InjectedEthereumProvider;
|
|
41
|
-
};
|
|
42
|
-
phantom?: {
|
|
43
|
-
ethereum?: InjectedEthereumProvider;
|
|
44
|
-
};
|
|
45
|
-
rabby?: InjectedEthereumProvider;
|
|
46
|
-
bitkeep?: InjectedEthereumProvider | {
|
|
47
|
-
ethereum?: InjectedEthereumProvider;
|
|
48
|
-
};
|
|
49
|
-
rainbow?: {
|
|
50
|
-
ethereum?: InjectedEthereumProvider;
|
|
51
|
-
};
|
|
52
|
-
zerionWallet?: InjectedEthereumProvider;
|
|
53
|
-
bitget?: InjectedEthereumProvider | {
|
|
54
|
-
ethereum?: InjectedEthereumProvider;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
export declare function discoverEIP6963Providers(): EIP6963ProviderDetail[];
|
|
59
|
-
export declare function findInjectedProvider(predicate: (provider: InjectedEthereumProvider) => boolean): InjectedEthereumProvider | undefined;
|
|
60
|
-
export declare function findEIP6963Provider(predicate: (detail: EIP6963ProviderDetail) => boolean): InjectedEthereumProvider | undefined;
|
|
61
|
-
export interface InjectedWalletConfig {
|
|
62
|
-
id: string;
|
|
63
|
-
title: string;
|
|
64
|
-
resolveProvider: () => InjectedEthereumProvider | undefined;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Force wallet to BSC_TENDERLY (chainId 3131). If the chain is missing (4902), add it then switch.
|
|
68
|
-
* Call after external wallet connect so subsequent business runs on Tenderly BSC.
|
|
69
|
-
*/
|
|
70
|
-
export declare function switchToFallbackBscTestnet(provider: InjectedEthereumProvider): Promise<void>;
|
|
71
|
-
export declare class InjectedEvmProvider extends AbstractProvider {
|
|
72
|
-
private config;
|
|
73
|
-
private injected?;
|
|
74
|
-
readonly id: string;
|
|
75
|
-
readonly title: string;
|
|
76
|
-
readonly category: "plugin";
|
|
77
|
-
constructor(config: InjectedWalletConfig, injected?: InjectedEthereumProvider | undefined);
|
|
78
|
-
isAvailable(): boolean;
|
|
79
|
-
protected get client(): InjectedEthereumProvider;
|
|
80
|
-
connect(_args?: WalletConnectArgs): Promise<WalletSession>;
|
|
81
|
-
reconnect(_persistedSession: WalletSession): Promise<WalletSession | null>;
|
|
82
|
-
}
|
|
83
|
-
export declare class MetaMaskProvider extends InjectedEvmProvider {
|
|
84
|
-
constructor(injected?: InjectedEthereumProvider);
|
|
85
|
-
}
|
|
86
|
-
export declare class OKXProvider extends InjectedEvmProvider {
|
|
87
|
-
constructor(injected?: InjectedEthereumProvider);
|
|
88
|
-
}
|
|
89
|
-
export declare class CoinbaseWalletProvider extends InjectedEvmProvider {
|
|
90
|
-
constructor(injected?: InjectedEthereumProvider);
|
|
91
|
-
}
|
|
92
|
-
export declare class TrustWalletProvider extends InjectedEvmProvider {
|
|
93
|
-
constructor(injected?: InjectedEthereumProvider);
|
|
94
|
-
}
|
|
95
|
-
export declare class PhantomProvider extends InjectedEvmProvider {
|
|
96
|
-
constructor(injected?: InjectedEthereumProvider);
|
|
97
|
-
}
|
|
98
|
-
export declare class RabbyProvider extends InjectedEvmProvider {
|
|
99
|
-
constructor(injected?: InjectedEthereumProvider);
|
|
100
|
-
}
|
|
101
|
-
export declare class RainbowProvider extends InjectedEvmProvider {
|
|
102
|
-
constructor(injected?: InjectedEthereumProvider);
|
|
103
|
-
}
|
|
104
|
-
export declare class ZerionProvider extends InjectedEvmProvider {
|
|
105
|
-
constructor(injected?: InjectedEthereumProvider);
|
|
106
|
-
}
|
|
107
|
-
export declare class BraveWalletProvider extends InjectedEvmProvider {
|
|
108
|
-
constructor(injected?: InjectedEthereumProvider);
|
|
109
|
-
}
|
|
110
|
-
export declare class BitgetProvider extends InjectedEvmProvider {
|
|
111
|
-
constructor(injected?: InjectedEthereumProvider);
|
|
112
|
-
}
|