@mezo-org/passport 0.1.0-dev.0

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 ADDED
@@ -0,0 +1 @@
1
+ # mezo-org/passport
@@ -0,0 +1,25 @@
1
+ import { Chain, WalletList } from "@rainbow-me/rainbowkit";
2
+ import { Config, CreateConfigParameters } from "wagmi";
3
+ export declare const defaultConfig: {
4
+ transports: {
5
+ 31611: import("viem").HttpTransport;
6
+ };
7
+ walletConnectProjectId: string;
8
+ chains: [Chain, ...Chain[]];
9
+ multiInjectedProviderDiscovery: boolean;
10
+ };
11
+ export declare function getDefaultWallets(relayApiKey: string): WalletList;
12
+ type WagmiConfigParameters = Omit<CreateConfigParameters, "client" | "connectors" | "chains" | "wallets" | "transports">;
13
+ type GetDefaultConfigParameters = WagmiConfigParameters & {
14
+ appName: string;
15
+ appDescription?: string;
16
+ appUrl?: string;
17
+ appIcon?: string;
18
+ bitcoinWallets?: WalletList;
19
+ walletConnectProjectId?: string;
20
+ chains?: [Chain, ...Chain[]];
21
+ relayApiKey: string;
22
+ };
23
+ export declare function getConfig({ appName, relayApiKey, bitcoinWallets, walletConnectProjectId, ...restParameters }: GetDefaultConfigParameters): Config;
24
+ export {};
25
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAoB,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;AAQtD,eAAO,MAAM,aAAa;;;;;;;CAKzB,CAAA;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU,CAkBjE;AAED,KAAK,qBAAqB,GAAG,IAAI,CAC/B,sBAAsB,EACtB,QAAQ,GAAG,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,CAC9D,CAAA;AACD,KAAK,0BAA0B,GAAG,qBAAqB,GAAG;IACxD,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,UAAU,CAAA;IAC3B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,wBAAgB,SAAS,CAAC,EACxB,OAAO,EACP,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,GAAG,cAAc,EAClB,EAAE,0BAA0B,GAAG,MAAM,CAQrC"}
@@ -0,0 +1,41 @@
1
+ import { http } from "viem";
2
+ import { matsnetTestnetChain } from "@mezo-org/orangekit";
3
+ import { getDefaultConfig } from "@rainbow-me/rainbowkit";
4
+ import { CHAIN_ID, RPC_BY_NETWORK } from "./constants";
5
+ import { getOKXWallet, getUnisatWallet, getXverseWallet } from "./wallet";
6
+ const transports = {
7
+ [CHAIN_ID.testnet]: http(RPC_BY_NETWORK.testnet),
8
+ };
9
+ export const defaultConfig = {
10
+ transports,
11
+ walletConnectProjectId: "",
12
+ chains: [matsnetTestnetChain],
13
+ multiInjectedProviderDiscovery: true,
14
+ };
15
+ export function getDefaultWallets(relayApiKey) {
16
+ const bitcoinWalletConfig = {
17
+ rpcUrl: RPC_BY_NETWORK.testnet,
18
+ chainId: CHAIN_ID.testnet,
19
+ // TODO: This will be removed once we merge passport relay worked is merged
20
+ relayApiKey,
21
+ };
22
+ const unisatWallet = getUnisatWallet(bitcoinWalletConfig);
23
+ const okxWallet = getOKXWallet(bitcoinWalletConfig);
24
+ const xverseWallet = getXverseWallet(bitcoinWalletConfig);
25
+ return [
26
+ {
27
+ groupName: "Bitcoin",
28
+ wallets: [unisatWallet, okxWallet, xverseWallet],
29
+ },
30
+ ];
31
+ }
32
+ export function getConfig({ appName, relayApiKey, bitcoinWallets, walletConnectProjectId, ...restParameters }) {
33
+ return getDefaultConfig({
34
+ ...defaultConfig,
35
+ appName,
36
+ wallets: [...getDefaultWallets(relayApiKey), ...(bitcoinWallets ?? [])],
37
+ projectId: walletConnectProjectId ?? defaultConfig.walletConnectProjectId,
38
+ ...restParameters,
39
+ });
40
+ }
41
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAS,gBAAgB,EAAc,MAAM,wBAAwB,CAAA;AAE5E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEzE,MAAM,UAAU,GAAG;IACjB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;CACjD,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,UAAU;IACV,sBAAsB,EAAE,EAAE;IAC1B,MAAM,EAAE,CAAC,mBAAmB,CAAwB;IACpD,8BAA8B,EAAE,IAAI;CACrC,CAAA;AAED,MAAM,UAAU,iBAAiB,CAAC,WAAmB;IACnD,MAAM,mBAAmB,GAAG;QAC1B,MAAM,EAAE,cAAc,CAAC,OAAO;QAC9B,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,2EAA2E;QAC3E,WAAW;KACZ,CAAA;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAA;IACzD,MAAM,SAAS,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAA;IACnD,MAAM,YAAY,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAA;IAEzD,OAAO;QACL;YACE,SAAS,EAAE,SAAS;YACpB,OAAO,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,YAAY,CAAC;SACjD;KACF,CAAA;AACH,CAAC;AAiBD,MAAM,UAAU,SAAS,CAAC,EACxB,OAAO,EACP,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,GAAG,cAAc,EACU;IAC3B,OAAO,gBAAgB,CAAC;QACtB,GAAG,aAAa;QAChB,OAAO;QACP,OAAO,EAAE,CAAC,GAAG,iBAAiB,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;QACvE,SAAS,EAAE,sBAAsB,IAAI,aAAa,CAAC,sBAAsB;QACzE,GAAG,cAAc;KAClB,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const CHAIN_ID: {
2
+ testnet: 31611;
3
+ };
4
+ export declare const RPC_BY_NETWORK: {
5
+ testnet: "https://rpc.test.mezo.org";
6
+ };
7
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;CAEpB,CAAA;AAED,eAAO,MAAM,cAAc;;CAE1B,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { matsnetTestnetChain } from "@mezo-org/orangekit";
2
+ export const CHAIN_ID = {
3
+ testnet: matsnetTestnetChain.id,
4
+ };
5
+ export const RPC_BY_NETWORK = {
6
+ testnet: matsnetTestnetChain.rpcUrls.default.http[0],
7
+ };
8
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAEzD,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,mBAAmB,CAAC,EAAE;CAChC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CACrD,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { useBitcoinAccount, useSendBitcoin, useSendTransaction, useSubscribeToConnectedToUnsupportedBitcoinAddress, useSubscribeToConnectorEvent, useSubscribeToWalletNetworkDoesNotMatchProviderChain, } from "@mezo-org/orangekit";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { useBitcoinAccount, useSendBitcoin, useSendTransaction, useSubscribeToConnectedToUnsupportedBitcoinAddress, useSubscribeToConnectorEvent, useSubscribeToWalletNetworkDoesNotMatchProviderChain, } from "@mezo-org/orangekit";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from "./config";
2
+ export * from "./constants";
3
+ export * from "./hooks";
4
+ export * from "./wallet";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from "./config";
2
+ export * from "./constants";
3
+ export * from "./hooks";
4
+ export * from "./wallet";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { getOKXWallet, getUnisatWallet, getXverseWallet, BitcoinWalletConnectionError, WalletNetworkDoesNotMatchProviderChainError, isUnsupportedBitcoinAddressError, isWalletNetworkDoesNotMatchProviderChainError, } from "@mezo-org/orangekit";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,4BAA4B,EAC5B,2CAA2C,EAC3C,gCAAgC,EAChC,6CAA6C,GAC9C,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { getOKXWallet, getUnisatWallet, getXverseWallet, BitcoinWalletConnectionError, WalletNetworkDoesNotMatchProviderChainError, isUnsupportedBitcoinAddressError, isWalletNetworkDoesNotMatchProviderChainError, } from "@mezo-org/orangekit";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,4BAA4B,EAC5B,2CAA2C,EAC3C,gCAAgC,EAChC,6CAA6C,GAC9C,MAAM,qBAAqB,CAAA"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@mezo-org/passport",
3
+ "version": "0.1.0-dev.0",
4
+ "main": "dist/src/index.js",
5
+ "license": "GPL-3.0-only",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "format": "npm run lint:js && npm run lint:config",
9
+ "format:fix": "npm run lint:js:fix && npm run lint:config:fix",
10
+ "lint:js": "eslint .",
11
+ "lint:js:fix": "eslint . --fix",
12
+ "lint:config": "prettier -c '**/*.@(json|yaml|toml)'",
13
+ "lint:config:fix": "prettier -w '**/*.@(json|yaml|toml)'",
14
+ "test": "jest --verbose"
15
+ },
16
+ "files": [
17
+ "dist/",
18
+ "src/"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/thesis/orangekit.git",
23
+ "directory": "typescript/react"
24
+ },
25
+ "devDependencies": {
26
+ "@babel/preset-env": "^7.23.7",
27
+ "@thesis-co/eslint-config": "github:thesis/eslint-config#7b9bc8c",
28
+ "@types/jest": "^29.5.12",
29
+ "@types/node": "^20.11.30",
30
+ "@types/react": "^18.2.64",
31
+ "eslint": "^8.54.0",
32
+ "jest": "^29.7.0",
33
+ "prettier": "^3.1.0",
34
+ "ts-jest": "^29.1.2",
35
+ "ts-node": "^10.9.2",
36
+ "typescript": "^5.4.3"
37
+ },
38
+ "dependencies": {
39
+ "@mezo-org/orangekit": "1.0.0-beta.36-dev.0",
40
+ "@rainbow-me/rainbowkit": "2.0.2",
41
+ "react": "^18.2.0",
42
+ "viem": "2.8.16",
43
+ "wagmi": "2.5.12"
44
+ }
45
+ }
package/src/config.ts ADDED
@@ -0,0 +1,68 @@
1
+ import { http } from "viem"
2
+ import { matsnetTestnetChain } from "@mezo-org/orangekit"
3
+ import { Chain, getDefaultConfig, WalletList } from "@rainbow-me/rainbowkit"
4
+ import { Config, CreateConfigParameters } from "wagmi"
5
+ import { CHAIN_ID, RPC_BY_NETWORK } from "./constants"
6
+ import { getOKXWallet, getUnisatWallet, getXverseWallet } from "./wallet"
7
+
8
+ const transports = {
9
+ [CHAIN_ID.testnet]: http(RPC_BY_NETWORK.testnet),
10
+ }
11
+
12
+ export const defaultConfig = {
13
+ transports,
14
+ walletConnectProjectId: "",
15
+ chains: [matsnetTestnetChain] as [Chain, ...Chain[]],
16
+ multiInjectedProviderDiscovery: true,
17
+ }
18
+
19
+ export function getDefaultWallets(relayApiKey: string): WalletList {
20
+ const bitcoinWalletConfig = {
21
+ rpcUrl: RPC_BY_NETWORK.testnet,
22
+ chainId: CHAIN_ID.testnet,
23
+ // TODO: This will be removed once we merge passport relay worked is merged
24
+ relayApiKey,
25
+ }
26
+
27
+ const unisatWallet = getUnisatWallet(bitcoinWalletConfig)
28
+ const okxWallet = getOKXWallet(bitcoinWalletConfig)
29
+ const xverseWallet = getXverseWallet(bitcoinWalletConfig)
30
+
31
+ return [
32
+ {
33
+ groupName: "Bitcoin",
34
+ wallets: [unisatWallet, okxWallet, xverseWallet],
35
+ },
36
+ ]
37
+ }
38
+
39
+ type WagmiConfigParameters = Omit<
40
+ CreateConfigParameters,
41
+ "client" | "connectors" | "chains" | "wallets" | "transports"
42
+ >
43
+ type GetDefaultConfigParameters = WagmiConfigParameters & {
44
+ appName: string
45
+ appDescription?: string
46
+ appUrl?: string
47
+ appIcon?: string
48
+ bitcoinWallets?: WalletList
49
+ walletConnectProjectId?: string
50
+ chains?: [Chain, ...Chain[]]
51
+ relayApiKey: string
52
+ }
53
+
54
+ export function getConfig({
55
+ appName,
56
+ relayApiKey,
57
+ bitcoinWallets,
58
+ walletConnectProjectId,
59
+ ...restParameters
60
+ }: GetDefaultConfigParameters): Config {
61
+ return getDefaultConfig({
62
+ ...defaultConfig,
63
+ appName,
64
+ wallets: [...getDefaultWallets(relayApiKey), ...(bitcoinWallets ?? [])],
65
+ projectId: walletConnectProjectId ?? defaultConfig.walletConnectProjectId,
66
+ ...restParameters,
67
+ })
68
+ }
@@ -0,0 +1,9 @@
1
+ import { matsnetTestnetChain } from "@mezo-org/orangekit"
2
+
3
+ export const CHAIN_ID = {
4
+ testnet: matsnetTestnetChain.id,
5
+ }
6
+
7
+ export const RPC_BY_NETWORK = {
8
+ testnet: matsnetTestnetChain.rpcUrls.default.http[0],
9
+ }
@@ -0,0 +1,8 @@
1
+ export {
2
+ useBitcoinAccount,
3
+ useSendBitcoin,
4
+ useSendTransaction,
5
+ useSubscribeToConnectedToUnsupportedBitcoinAddress,
6
+ useSubscribeToConnectorEvent,
7
+ useSubscribeToWalletNetworkDoesNotMatchProviderChain,
8
+ } from "@mezo-org/orangekit"
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./config"
2
+ export * from "./constants"
3
+ export * from "./hooks"
4
+ export * from "./wallet"
@@ -0,0 +1,9 @@
1
+ export {
2
+ getOKXWallet,
3
+ getUnisatWallet,
4
+ getXverseWallet,
5
+ BitcoinWalletConnectionError,
6
+ WalletNetworkDoesNotMatchProviderChainError,
7
+ isUnsupportedBitcoinAddressError,
8
+ isWalletNetworkDoesNotMatchProviderChainError,
9
+ } from "@mezo-org/orangekit"