@worldcoin/minikit-js 1.11.0 → 2.0.0-dev.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/README.md +107 -0
- package/build/address-book.cjs +81 -0
- package/build/address-book.d.cts +3 -0
- package/build/address-book.d.ts +3 -0
- package/build/address-book.js +54 -0
- package/build/chunk-2UPJKPQ6.js +272 -0
- package/build/chunk-EHBM7OXH.js +596 -0
- package/build/chunk-LHHKY77D.js +274 -0
- package/build/chunk-TGXD24YD.js +279 -0
- package/build/chunk-Z2UGRZJ2.js +1635 -0
- package/build/command-exports.cjs +1762 -0
- package/build/command-exports.d.cts +105 -0
- package/build/command-exports.d.ts +105 -0
- package/build/command-exports.js +129 -0
- package/build/connector/index.cjs +2601 -0
- package/build/connector/index.d.cts +55 -0
- package/build/connector/index.d.ts +55 -0
- package/build/connector/index.js +90 -0
- package/build/index.cjs +1634 -1627
- package/build/index.d.cts +143 -671
- package/build/index.d.ts +143 -671
- package/build/index.js +7 -206
- package/build/minikit-provider.cjs +1650 -948
- package/build/minikit-provider.d.cts +2 -1
- package/build/minikit-provider.d.ts +2 -1
- package/build/minikit-provider.js +13 -2
- package/build/provider-DeDUsLbs.d.cts +43 -0
- package/build/provider-DeDUsLbs.d.ts +43 -0
- package/build/siwe-exports.cjs +249 -0
- package/build/siwe-exports.d.cts +10 -0
- package/build/siwe-exports.d.ts +10 -0
- package/build/siwe-exports.js +8 -0
- package/build/types-CC2x79HX.d.ts +525 -0
- package/build/types-CSyzFDPt.d.cts +223 -0
- package/build/types-CSyzFDPt.d.ts +223 -0
- package/build/types-_jfLbcJW.d.cts +525 -0
- package/package.json +73 -11
- package/build/chunk-62NZ34E4.js +0 -2092
- package/index.ts +0 -29
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { W as WorldAppProvider } from '../provider-DeDUsLbs.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* World App Wagmi Connector
|
|
5
|
+
*
|
|
6
|
+
* Thin wrapper that delegates to the shared EIP-1193 provider from
|
|
7
|
+
* `@worldcoin/minikit-js`. All auth and RPC logic lives in the provider;
|
|
8
|
+
* this connector just adapts the interface for wagmi.
|
|
9
|
+
*/
|
|
10
|
+
type WorldAppConnectorOptions = {
|
|
11
|
+
/** Custom name for the connector */
|
|
12
|
+
name?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Create a World App connector for Wagmi
|
|
16
|
+
*
|
|
17
|
+
* When running inside World App, this connector uses native MiniKit commands
|
|
18
|
+
* via the shared EIP-1193 provider. It should be placed first in the
|
|
19
|
+
* connectors list so it's used automatically in World App.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { createConfig } from 'wagmi';
|
|
24
|
+
* import { worldApp } from '@worldcoin/minikit-js/wagmi';
|
|
25
|
+
*
|
|
26
|
+
* const wagmiConfig = createConfig({
|
|
27
|
+
* connectors: [
|
|
28
|
+
* worldApp(), // Uses native MiniKit in World App
|
|
29
|
+
* injected(), // Fallback for web
|
|
30
|
+
* walletConnect({ ... }),
|
|
31
|
+
* ],
|
|
32
|
+
* // ...
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function worldApp(options?: WorldAppConnectorOptions): (config: any) => {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
type: "worldApp";
|
|
40
|
+
setup(): Promise<void>;
|
|
41
|
+
connect(_parameters?: any): Promise<any>;
|
|
42
|
+
disconnect(): Promise<void>;
|
|
43
|
+
getAccounts(): Promise<readonly `0x${string}`[]>;
|
|
44
|
+
getChainId(): Promise<number>;
|
|
45
|
+
getProvider(): Promise<WorldAppProvider>;
|
|
46
|
+
isAuthorized(): Promise<boolean>;
|
|
47
|
+
switchChain({ chainId }: {
|
|
48
|
+
chainId: number;
|
|
49
|
+
}): Promise<any>;
|
|
50
|
+
onAccountsChanged(_accounts: string[]): void;
|
|
51
|
+
onChainChanged(_chainId: string): void;
|
|
52
|
+
onDisconnect(): void;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { type WorldAppConnectorOptions, worldApp };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { W as WorldAppProvider } from '../provider-DeDUsLbs.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* World App Wagmi Connector
|
|
5
|
+
*
|
|
6
|
+
* Thin wrapper that delegates to the shared EIP-1193 provider from
|
|
7
|
+
* `@worldcoin/minikit-js`. All auth and RPC logic lives in the provider;
|
|
8
|
+
* this connector just adapts the interface for wagmi.
|
|
9
|
+
*/
|
|
10
|
+
type WorldAppConnectorOptions = {
|
|
11
|
+
/** Custom name for the connector */
|
|
12
|
+
name?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Create a World App connector for Wagmi
|
|
16
|
+
*
|
|
17
|
+
* When running inside World App, this connector uses native MiniKit commands
|
|
18
|
+
* via the shared EIP-1193 provider. It should be placed first in the
|
|
19
|
+
* connectors list so it's used automatically in World App.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { createConfig } from 'wagmi';
|
|
24
|
+
* import { worldApp } from '@worldcoin/minikit-js/wagmi';
|
|
25
|
+
*
|
|
26
|
+
* const wagmiConfig = createConfig({
|
|
27
|
+
* connectors: [
|
|
28
|
+
* worldApp(), // Uses native MiniKit in World App
|
|
29
|
+
* injected(), // Fallback for web
|
|
30
|
+
* walletConnect({ ... }),
|
|
31
|
+
* ],
|
|
32
|
+
* // ...
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function worldApp(options?: WorldAppConnectorOptions): (config: any) => {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
type: "worldApp";
|
|
40
|
+
setup(): Promise<void>;
|
|
41
|
+
connect(_parameters?: any): Promise<any>;
|
|
42
|
+
disconnect(): Promise<void>;
|
|
43
|
+
getAccounts(): Promise<readonly `0x${string}`[]>;
|
|
44
|
+
getChainId(): Promise<number>;
|
|
45
|
+
getProvider(): Promise<WorldAppProvider>;
|
|
46
|
+
isAuthorized(): Promise<boolean>;
|
|
47
|
+
switchChain({ chainId }: {
|
|
48
|
+
chainId: number;
|
|
49
|
+
}): Promise<any>;
|
|
50
|
+
onAccountsChanged(_accounts: string[]): void;
|
|
51
|
+
onChainChanged(_chainId: string): void;
|
|
52
|
+
onDisconnect(): void;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { type WorldAppConnectorOptions, worldApp };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
_clearAddress,
|
|
3
|
+
_getAddress,
|
|
4
|
+
_setAddress,
|
|
5
|
+
getWorldAppProvider
|
|
6
|
+
} from "../chunk-TGXD24YD.js";
|
|
7
|
+
import {
|
|
8
|
+
setWagmiConfig
|
|
9
|
+
} from "../chunk-2UPJKPQ6.js";
|
|
10
|
+
import {
|
|
11
|
+
MiniKit
|
|
12
|
+
} from "../chunk-EHBM7OXH.js";
|
|
13
|
+
import "../chunk-Z2UGRZJ2.js";
|
|
14
|
+
import "../chunk-LHHKY77D.js";
|
|
15
|
+
|
|
16
|
+
// src/connector/connector.ts
|
|
17
|
+
function worldApp(options = {}) {
|
|
18
|
+
const name = options.name ?? "World App";
|
|
19
|
+
return createConnectorFn(name);
|
|
20
|
+
}
|
|
21
|
+
function createConnectorFn(name) {
|
|
22
|
+
return (config) => {
|
|
23
|
+
setWagmiConfig(config);
|
|
24
|
+
const provider = getWorldAppProvider();
|
|
25
|
+
return {
|
|
26
|
+
id: "worldApp",
|
|
27
|
+
name,
|
|
28
|
+
type: "worldApp",
|
|
29
|
+
async setup() {
|
|
30
|
+
const existing = MiniKit.user?.walletAddress;
|
|
31
|
+
if (existing) {
|
|
32
|
+
_setAddress(existing);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
async connect(_parameters) {
|
|
37
|
+
const accounts = await provider.request({
|
|
38
|
+
method: "eth_requestAccounts"
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
accounts,
|
|
42
|
+
chainId: 480
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
async disconnect() {
|
|
46
|
+
_clearAddress();
|
|
47
|
+
},
|
|
48
|
+
async getAccounts() {
|
|
49
|
+
const addr = _getAddress();
|
|
50
|
+
if (addr) return [addr];
|
|
51
|
+
if (!MiniKit.isInWorldApp()) return [];
|
|
52
|
+
try {
|
|
53
|
+
const accounts = await provider.request({
|
|
54
|
+
method: "eth_requestAccounts"
|
|
55
|
+
});
|
|
56
|
+
if (Array.isArray(accounts) && accounts.length > 0 && typeof accounts[0] === "string") {
|
|
57
|
+
_setAddress(accounts[0]);
|
|
58
|
+
return [_getAddress()];
|
|
59
|
+
}
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
return [];
|
|
63
|
+
},
|
|
64
|
+
async getChainId() {
|
|
65
|
+
return 480;
|
|
66
|
+
},
|
|
67
|
+
async getProvider() {
|
|
68
|
+
return provider;
|
|
69
|
+
},
|
|
70
|
+
async isAuthorized() {
|
|
71
|
+
return MiniKit.isInWorldApp() && !!_getAddress();
|
|
72
|
+
},
|
|
73
|
+
async switchChain({ chainId }) {
|
|
74
|
+
if (chainId !== 480) {
|
|
75
|
+
throw new Error("World App only supports World Chain (chainId: 480)");
|
|
76
|
+
}
|
|
77
|
+
return config.chains.find((c) => c.id === 480) ?? config.chains[0];
|
|
78
|
+
},
|
|
79
|
+
onAccountsChanged(_accounts) {
|
|
80
|
+
},
|
|
81
|
+
onChainChanged(_chainId) {
|
|
82
|
+
},
|
|
83
|
+
onDisconnect() {
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
worldApp
|
|
90
|
+
};
|