-
Notifications
You must be signed in to change notification settings - Fork 271
/
ecosystem.ts
54 lines (53 loc) · 1.51 KB
/
ecosystem.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import type { ThirdwebClient } from "../../../client/client.js";
import type { Wallet } from "../../interfaces/wallet.js";
import type {
CreateWalletArgs,
EcosystemWalletId,
} from "../../wallet-types.js";
import { createEcosystemWallet } from "../core/wallet/ecosystem-core.js";
/**
* Creates an ecosystem wallet.
* @param createOptions - configuration options
* @returns The created ecosystem wallet.
* @example
* ```ts
* import { ecosystemWallet } from "thirdweb/wallets";
*
* const wallet = ecosystemWallet("ecosystem.hooli");
*
* const account = await wallet.connect({
* client,
* chain,
* strategy: "google",
* });
* ```
*
* Connect to a restricted ecosystem wallet with your designated partner ID
* @note The parnter ID will be provided to you by the ecosystem with which you're integrating.
* ```ts
* import { ecosystemWallet } from "thirdweb/wallets";
* const wallet = ecosystemWallet("ecosystem.hooli", {
* partnerId: "..."
* });
* ```
* @wallet
*/
export function ecosystemWallet(
...args: CreateWalletArgs<EcosystemWalletId>
): Wallet<EcosystemWalletId> {
const [ecosystemId, createOptions] = args;
return createEcosystemWallet({
id: ecosystemId,
createOptions,
connectorFactory: async (client: ThirdwebClient) => {
const { InAppWebConnector } = await import("./lib/web-connector.js");
return new InAppWebConnector({
client,
ecosystem: {
id: ecosystemId,
partnerId: createOptions?.partnerId,
},
});
},
});
}