@multiplatform.one/web3 7.25.0 → 7.26.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/dist/cjs/core/family.cjs +88 -0
- package/dist/cjs/core/family.native.js +115 -0
- package/dist/cjs/core/family.native.js.map +1 -0
- package/dist/cjs/core/index.cjs +41 -0
- package/dist/cjs/core/index.native.js +44 -0
- package/dist/cjs/core/index.native.js.map +1 -0
- package/dist/cjs/core/message.cjs +89 -0
- package/dist/cjs/core/message.native.js +104 -0
- package/dist/cjs/core/message.native.js.map +1 -0
- package/dist/cjs/core/names.cjs +51 -0
- package/dist/cjs/core/names.native.js +95 -0
- package/dist/cjs/core/names.native.js.map +1 -0
- package/dist/cjs/core/react.cjs +48 -0
- package/dist/cjs/core/react.native.js +52 -0
- package/dist/cjs/core/react.native.js.map +1 -0
- package/dist/cjs/core/store.cjs +450 -0
- package/dist/cjs/core/store.native.js +637 -0
- package/dist/cjs/core/store.native.js.map +1 -0
- package/dist/cjs/core/types.cjs +18 -0
- package/dist/cjs/core/types.native.js +21 -0
- package/dist/cjs/core/types.native.js.map +1 -0
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/index.native.js +1 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/core/family.mjs +62 -0
- package/dist/esm/core/family.mjs.map +1 -0
- package/dist/esm/core/family.native.js +86 -0
- package/dist/esm/core/family.native.js.map +1 -0
- package/dist/esm/core/index.mjs +7 -0
- package/dist/esm/core/index.mjs.map +1 -0
- package/dist/esm/core/index.native.js +7 -0
- package/dist/esm/core/index.native.js.map +1 -0
- package/dist/esm/core/message.mjs +63 -0
- package/dist/esm/core/message.mjs.map +1 -0
- package/dist/esm/core/message.native.js +75 -0
- package/dist/esm/core/message.native.js.map +1 -0
- package/dist/esm/core/names.mjs +25 -0
- package/dist/esm/core/names.mjs.map +1 -0
- package/dist/esm/core/names.native.js +66 -0
- package/dist/esm/core/names.native.js.map +1 -0
- package/dist/esm/core/react.mjs +21 -0
- package/dist/esm/core/react.mjs.map +1 -0
- package/dist/esm/core/react.native.js +22 -0
- package/dist/esm/core/react.native.js.map +1 -0
- package/dist/esm/core/store.mjs +424 -0
- package/dist/esm/core/store.mjs.map +1 -0
- package/dist/esm/core/store.native.js +608 -0
- package/dist/esm/core/store.native.js.map +1 -0
- package/dist/esm/core/types.mjs +2 -0
- package/dist/esm/core/types.mjs.map +1 -0
- package/dist/esm/core/types.native.js +2 -0
- package/dist/esm/core/types.native.js.map +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +1 -0
- package/dist/esm/index.native.js.map +1 -1
- package/dist/jsx/core/family.mjs +62 -0
- package/dist/jsx/core/family.mjs.map +1 -0
- package/dist/jsx/core/family.native.js +115 -0
- package/dist/jsx/core/family.native.js.map +1 -0
- package/dist/jsx/core/index.mjs +7 -0
- package/dist/jsx/core/index.mjs.map +1 -0
- package/dist/jsx/core/index.native.js +44 -0
- package/dist/jsx/core/index.native.js.map +1 -0
- package/dist/jsx/core/message.mjs +63 -0
- package/dist/jsx/core/message.mjs.map +1 -0
- package/dist/jsx/core/message.native.js +104 -0
- package/dist/jsx/core/message.native.js.map +1 -0
- package/dist/jsx/core/names.mjs +25 -0
- package/dist/jsx/core/names.mjs.map +1 -0
- package/dist/jsx/core/names.native.js +95 -0
- package/dist/jsx/core/names.native.js.map +1 -0
- package/dist/jsx/core/react.mjs +21 -0
- package/dist/jsx/core/react.mjs.map +1 -0
- package/dist/jsx/core/react.native.js +52 -0
- package/dist/jsx/core/react.native.js.map +1 -0
- package/dist/jsx/core/store.mjs +424 -0
- package/dist/jsx/core/store.mjs.map +1 -0
- package/dist/jsx/core/store.native.js +637 -0
- package/dist/jsx/core/store.native.js.map +1 -0
- package/dist/jsx/core/types.mjs +2 -0
- package/dist/jsx/core/types.mjs.map +1 -0
- package/dist/jsx/core/types.native.js +21 -0
- package/dist/jsx/core/types.native.js.map +1 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +1 -0
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +1 -0
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +6 -6
- package/src/core/family.spec.ts +117 -0
- package/src/core/family.ts +103 -0
- package/src/core/imports.spec.ts +82 -0
- package/src/core/index.ts +47 -0
- package/src/core/message.spec.ts +178 -0
- package/src/core/message.ts +119 -0
- package/src/core/names.ts +29 -0
- package/src/core/react.spec.tsx +75 -0
- package/src/core/react.ts +34 -0
- package/src/core/store.spec.ts +890 -0
- package/src/core/store.ts +558 -0
- package/src/core/types.ts +96 -0
- package/src/index.ts +4 -0
- package/types/core/family.d.ts +44 -0
- package/types/core/family.d.ts.map +1 -0
- package/types/core/index.d.ts +7 -0
- package/types/core/index.d.ts.map +1 -0
- package/types/core/message.d.ts +44 -0
- package/types/core/message.d.ts.map +1 -0
- package/types/core/names.d.ts +7 -0
- package/types/core/names.d.ts.map +1 -0
- package/types/core/react.d.ts +14 -0
- package/types/core/react.d.ts.map +1 -0
- package/types/core/store.d.ts +64 -0
- package/types/core/store.d.ts.map +1 -0
- package/types/core/types.d.ts +88 -0
- package/types/core/types.d.ts.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ScreenDef } from "@multiplatform.one/connectkit";
|
|
2
|
+
import type { ComponentType, ReactNode } from "react";
|
|
3
|
+
import { type WalletMessageRegistry, type WalletMessageSpec } from "./message";
|
|
4
|
+
import type { ConnectionDriver } from "./types";
|
|
5
|
+
/** What a family package hands the core: `eth({chains})`, `sol({rpcUrl})`, `gpg()`. */
|
|
6
|
+
export interface WalletFamilyDefinition {
|
|
7
|
+
/** Short family id, the one the Keycloak message names: `eth`, `sol`, `sui`, `btc`, `gpg`. */
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly label: string;
|
|
10
|
+
/** Other names callers use for the family, such as the ecosystem name `evm` for `eth`. */
|
|
11
|
+
readonly aliases?: readonly string[];
|
|
12
|
+
readonly message: WalletMessageSpec;
|
|
13
|
+
/**
|
|
14
|
+
* Makes the family's connection driver. The store calls it once, the first
|
|
15
|
+
* time it needs the family, so a family nobody touches starts nothing.
|
|
16
|
+
*/
|
|
17
|
+
readonly driver?: () => ConnectionDriver;
|
|
18
|
+
/** Signs without a wallet connection (GPG). Such a family has no driver. */
|
|
19
|
+
readonly connectionless?: boolean;
|
|
20
|
+
/** Modal screens the family contributes. */
|
|
21
|
+
readonly screens?: readonly ScreenDef[];
|
|
22
|
+
/** A provider the family needs mounted around the app. */
|
|
23
|
+
readonly Provider?: ComponentType<{
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export interface WalletFamily extends WalletFamilyDefinition {
|
|
28
|
+
readonly aliases: readonly string[];
|
|
29
|
+
readonly connectionless: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Validates a family definition and freezes it. */
|
|
32
|
+
export declare function defineWalletFamily(definition: WalletFamilyDefinition): WalletFamily;
|
|
33
|
+
export interface FamilyRegistry {
|
|
34
|
+
/** In the order the app listed them, which is the connect list's order. */
|
|
35
|
+
readonly families: readonly WalletFamily[];
|
|
36
|
+
/** The family for an id or alias, or undefined. */
|
|
37
|
+
get(family: string): WalletFamily | undefined;
|
|
38
|
+
/** The family for an id or alias. Throws naming the registered families. */
|
|
39
|
+
require(family: string): WalletFamily;
|
|
40
|
+
readonly messages: WalletMessageRegistry;
|
|
41
|
+
}
|
|
42
|
+
/** The families one app registered. Refuses a family, id or alias registered twice. */
|
|
43
|
+
export declare function createFamilyRegistry(families: readonly WalletFamily[]): FamilyRegistry;
|
|
44
|
+
//# sourceMappingURL=family.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"family.d.ts","sourceRoot":"","sources":["../../src/core/family.ts"],"names":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AC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;IAC9C,4EAA4E;IAC5E,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;CAC1C;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,GAAG,cAAc,CAsBtF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createFamilyRegistry, defineWalletFamily, type FamilyRegistry, type WalletFamily, type WalletFamilyDefinition, } from "./family";
|
|
2
|
+
export { createMessageRegistry, formatWalletMessage, type MessageFamily, type WalletMessageRegistry, type WalletMessageSpec, } from "./message";
|
|
3
|
+
export { createConnectionStore, defaultConnectionStorageKey, type ConnectionStore, type ConnectionStoreOptions, type FamilyConnector, } from "./store";
|
|
4
|
+
export { ConnectionProvider, useConnection, useConnectionStore, type ConnectionProviderProps, } from "./react";
|
|
5
|
+
export type { ConnectionDriver, ConnectionState, ConnectionStatus, ConnectionStorage, DriverAccount, DriverConnectOptions, DriverState, SavedConnection, WalletConnector, } from "./types";
|
|
6
|
+
export { UnsupportedClientMethodError, type ChainClient, type ClientCapability, type ClientFamily, } from "../clients/types";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,sBAAsB,GAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,GACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,4BAA4B,EAC5B,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { WalletMessageOptions } from "../message/buildWalletMessage";
|
|
2
|
+
/**
|
|
3
|
+
* How one family's sign-in message differs from the shared envelope. A family
|
|
4
|
+
* package defines its spec; the envelope (domain line, statement, URI, Version,
|
|
5
|
+
* Chain ID, Nonce, Issued At) is the same bytes the Keycloak verifiers parse.
|
|
6
|
+
*/
|
|
7
|
+
export interface WalletMessageSpec {
|
|
8
|
+
/** First-line text after the domain, which the verifiers content-sniff. */
|
|
9
|
+
readonly header: string;
|
|
10
|
+
/** Default statement. Null means none. */
|
|
11
|
+
readonly statement: string | null;
|
|
12
|
+
/** The `Chain ID:` value when the caller gives none. Null omits the line. */
|
|
13
|
+
readonly chainId: string | null;
|
|
14
|
+
/** Whether the message names the signer's address. GPG's identity is its key. Default true. */
|
|
15
|
+
readonly address?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Honour a numeric `chainId` option. Only EVM chain ids are numbers; elsewhere
|
|
18
|
+
* a number is a connector's synthetic id and is ignored.
|
|
19
|
+
*/
|
|
20
|
+
readonly numericChainId?: boolean;
|
|
21
|
+
/** EIP-4361 keeps an empty line where an omitted statement would be. */
|
|
22
|
+
readonly keepStatementLine?: boolean;
|
|
23
|
+
/** Canonical address form, such as EIP-55 for EVM. */
|
|
24
|
+
readonly normalizeAddress?: (address: string) => string;
|
|
25
|
+
}
|
|
26
|
+
export interface MessageFamily {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly aliases?: readonly string[];
|
|
29
|
+
readonly message: WalletMessageSpec;
|
|
30
|
+
}
|
|
31
|
+
export interface WalletMessageRegistry {
|
|
32
|
+
/** Registered family ids, in registration order. */
|
|
33
|
+
readonly families: readonly string[];
|
|
34
|
+
/** The family id for an id or alias, or undefined. */
|
|
35
|
+
resolve(family: string): string | undefined;
|
|
36
|
+
spec(family: string): WalletMessageSpec | undefined;
|
|
37
|
+
/** Builds the sign-in message. Throws for a family nobody registered. */
|
|
38
|
+
build(family: string, opts: WalletMessageOptions): string;
|
|
39
|
+
}
|
|
40
|
+
/** Builds one sign-in message from a family spec. `family` only names the family in errors. */
|
|
41
|
+
export declare function formatWalletMessage(spec: WalletMessageSpec, opts: WalletMessageOptions, family?: string): string;
|
|
42
|
+
/** The message half of the family registry: family id or alias to spec. */
|
|
43
|
+
export declare function createMessageRegistry(families: Iterable<MessageFamily>): WalletMessageRegistry;
|
|
44
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/core/message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAG1E;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,+FAA+F;IAC/F,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,wEAAwE;IACxE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC,sDAAsD;IACtD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CACzD;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;CACrC;AAED,MAAM,WAAW,qBAAqB;IACpC,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,sDAAsD;IACtD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5C,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAAC;IACpD,yEAAyE;IACzE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAAC;CAC3D;AAaD,+FAA+F;AAC/F,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,iBAAiB,EACvB,IAAI,EAAE,oBAAoB,EAC1B,MAAM,SAAW,GAChB,MAAM,CAiCR;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,CAAC,aAAa,CAAC,GAAG,qBAAqB,CAsB9F"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function assertName(kind: string, name: unknown): asserts name is string;
|
|
2
|
+
/** Maps every id and alias to its entry's id, refusing a name two entries claim. */
|
|
3
|
+
export declare function nameTable(entries: Iterable<{
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly aliases?: readonly string[];
|
|
6
|
+
}>): Map<string, string>;
|
|
7
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../src/core/names.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAI9E;AAED,oFAAoF;AACpF,wBAAgB,SAAS,CACvB,OAAO,EAAE,QAAQ,CAAC;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,GAC/E,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBrB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { ConnectionStore } from "./store";
|
|
3
|
+
import type { ConnectionState } from "./types";
|
|
4
|
+
export interface ConnectionProviderProps {
|
|
5
|
+
store: ConnectionStore;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/** Makes one connection store the app's. Web3Provider mounts this once it owns a store. */
|
|
9
|
+
export declare function ConnectionProvider({ store, children }: ConnectionProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<ConnectionStore | null>>;
|
|
10
|
+
/** The store under the nearest ConnectionProvider, for connect, disconnect and reconnect. */
|
|
11
|
+
export declare function useConnectionStore(): ConnectionStore;
|
|
12
|
+
/** The active connection: status, family, connector, address, chainId and client. */
|
|
13
|
+
export declare function useConnection(): ConnectionState;
|
|
14
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/core/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI/C,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,2FAA2F;AAC3F,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,uBAAuB,mGAE9E;AAED,6FAA6F;AAC7F,wBAAgB,kBAAkB,IAAI,eAAe,CAIpD;AAED,qFAAqF;AACrF,wBAAgB,aAAa,IAAI,eAAe,CAG/C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type FamilyRegistry, type WalletFamily } from "./family";
|
|
2
|
+
import type { ConnectionState, ConnectionStorage, DriverConnectOptions, WalletConnector } from "./types";
|
|
3
|
+
export declare const defaultConnectionStorageKey = "mpo.web3.connection";
|
|
4
|
+
export interface ConnectionStoreOptions {
|
|
5
|
+
families: readonly WalletFamily[] | FamilyRegistry;
|
|
6
|
+
/**
|
|
7
|
+
* Where the last connection is remembered. Defaults to localStorage when the
|
|
8
|
+
* platform has one; null keeps nothing, so nothing is restored.
|
|
9
|
+
*/
|
|
10
|
+
storage?: ConnectionStorage | null;
|
|
11
|
+
storageKey?: string;
|
|
12
|
+
/**
|
|
13
|
+
* How long, in milliseconds, a driver's disconnect may take before the store
|
|
14
|
+
* stops waiting for it. Defaults to 10 seconds. Infinity waits for as long
|
|
15
|
+
* as the driver takes; a negative value waits for nothing.
|
|
16
|
+
*/
|
|
17
|
+
closeTimeout?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface FamilyConnector {
|
|
20
|
+
readonly family: string;
|
|
21
|
+
readonly connector: WalletConnector;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Holds the one active wallet connection across every registered family.
|
|
25
|
+
* Only the active family's driver is listened to, so a second driver that
|
|
26
|
+
* reports an account (wagmi restoring on its own, say) changes nothing.
|
|
27
|
+
*/
|
|
28
|
+
export interface ConnectionStore {
|
|
29
|
+
getState(): ConnectionState;
|
|
30
|
+
subscribe(listener: () => void): () => void;
|
|
31
|
+
readonly registry: FamilyRegistry;
|
|
32
|
+
/**
|
|
33
|
+
* Every connectable family's connectors, merged in family order. The same
|
|
34
|
+
* array comes back until the list changes.
|
|
35
|
+
*/
|
|
36
|
+
connectors(): readonly FamilyConnector[];
|
|
37
|
+
/** Called when any family's connector list changes. */
|
|
38
|
+
subscribeConnectors(listener: () => void): () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Connects one family's connector, first closing any other connection.
|
|
41
|
+
* Remembers {family, connectorId} on success.
|
|
42
|
+
*/
|
|
43
|
+
connect(family: string, connectorId: string, options?: DriverConnectOptions): Promise<ConnectionState>;
|
|
44
|
+
/** Closes the active connection and forgets it. */
|
|
45
|
+
disconnect(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Restores the remembered connection through its own driver only. Concurrent
|
|
48
|
+
* calls share one attempt; no other driver is asked. A disconnect from the
|
|
49
|
+
* wallet side keeps the record, so a later reconnect() can restore it.
|
|
50
|
+
*/
|
|
51
|
+
reconnect(): Promise<ConnectionState>;
|
|
52
|
+
/**
|
|
53
|
+
* Stops listening to every driver and to this store's listeners, and refuses
|
|
54
|
+
* later connects. It closes nothing: the connection and the attempt live at
|
|
55
|
+
* that moment stay open on their drivers for whatever takes over, such as a
|
|
56
|
+
* store remounted on the same drivers. A late result of an attempt cancelled
|
|
57
|
+
* before destroy() still closes its own connector unless another store holds
|
|
58
|
+
* it through the same driver object; a store on a fresh driver over the same
|
|
59
|
+
* wallet cannot be told apart from this one's leftover.
|
|
60
|
+
*/
|
|
61
|
+
destroy(): void;
|
|
62
|
+
}
|
|
63
|
+
export declare function createConnectionStore(options: ConnectionStoreOptions): ConnectionStore;
|
|
64
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,cAA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AsB,GAAG,eAAe,CAsbtF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ChainClient } from "../clients/types";
|
|
2
|
+
/** Where a connection is: none, being opened by the user, being restored silently, or open. */
|
|
3
|
+
export type ConnectionStatus = "disconnected" | "connecting" | "reconnecting" | "connected";
|
|
4
|
+
/** One wallet a driver can connect, as the connect list shows it. */
|
|
5
|
+
export interface WalletConnector {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly icon?: string;
|
|
9
|
+
/** The wallet is present here now: an injected extension, an installed app. */
|
|
10
|
+
readonly installed?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** The account a driver connected. */
|
|
13
|
+
export interface DriverAccount {
|
|
14
|
+
/** Chain-native address. */
|
|
15
|
+
readonly address: string;
|
|
16
|
+
/** EVM numeric chain id, or a CAIP-2 style id (`solana:mainnet`). */
|
|
17
|
+
readonly chainId?: number | string;
|
|
18
|
+
}
|
|
19
|
+
export interface DriverState {
|
|
20
|
+
readonly status: ConnectionStatus;
|
|
21
|
+
readonly connectorId: string | null;
|
|
22
|
+
readonly account: DriverAccount | null;
|
|
23
|
+
}
|
|
24
|
+
export interface DriverConnectOptions {
|
|
25
|
+
/** Called with a pairing URI when the connector hands off to another app or device. */
|
|
26
|
+
onDisplayUri?: (uri: string) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The engine behind one wallet family's connections: wagmi for EVM, the light
|
|
30
|
+
* driver for adapter-based families. The connection store drives it and holds
|
|
31
|
+
* the one active connection; a driver never decides which family is active.
|
|
32
|
+
*/
|
|
33
|
+
export interface ConnectionDriver {
|
|
34
|
+
/** The connectors this driver can drive, in list order. */
|
|
35
|
+
connectors(): readonly WalletConnector[];
|
|
36
|
+
/**
|
|
37
|
+
* Called when the connector list changes: an EIP-6963 or Wallet Standard
|
|
38
|
+
* wallet announcing itself late. Without it the list is read once per call.
|
|
39
|
+
*/
|
|
40
|
+
watchConnectors?(listener: () => void): () => void;
|
|
41
|
+
getState(): DriverState;
|
|
42
|
+
/** Called on every state change: account, chain, connector, or a disconnect from the wallet side. */
|
|
43
|
+
subscribe(listener: () => void): () => void;
|
|
44
|
+
/** Prompts the user. Rejects when they decline or the wallet fails. */
|
|
45
|
+
connect(connectorId: string, options?: DriverConnectOptions): Promise<DriverAccount>;
|
|
46
|
+
/**
|
|
47
|
+
* Closes every connection the driver holds, or with a connectorId only that
|
|
48
|
+
* connector's, doing nothing when it is not open.
|
|
49
|
+
*/
|
|
50
|
+
disconnect(connectorId?: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Restores a connector the user authorised before, without prompting.
|
|
53
|
+
* Resolves null only when the wallet says it is no longer authorised, which
|
|
54
|
+
* makes the store forget it. A connector that is not available yet (an
|
|
55
|
+
* EIP-6963 wallet still to announce itself) rejects instead, and the store
|
|
56
|
+
* keeps it for the next restore.
|
|
57
|
+
*/
|
|
58
|
+
reconnect(connectorId: string): Promise<DriverAccount | null>;
|
|
59
|
+
/**
|
|
60
|
+
* The per-chain client for the current account, or null. The store asks
|
|
61
|
+
* again only when the connector, address or chain changes.
|
|
62
|
+
*/
|
|
63
|
+
client?(state: DriverState): ChainClient | null | Promise<ChainClient | null>;
|
|
64
|
+
}
|
|
65
|
+
/** What `useConnection()` returns: the single active connection across every family. */
|
|
66
|
+
export interface ConnectionState {
|
|
67
|
+
readonly status: ConnectionStatus;
|
|
68
|
+
readonly family: string | null;
|
|
69
|
+
readonly connector: WalletConnector | null;
|
|
70
|
+
readonly address: string | null;
|
|
71
|
+
readonly chainId: number | string | null;
|
|
72
|
+
readonly client: ChainClient | null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Where the store remembers the last connection. localStorage, wagmi's storage
|
|
76
|
+
* and React Native AsyncStorage all fit.
|
|
77
|
+
*/
|
|
78
|
+
export interface ConnectionStorage {
|
|
79
|
+
getItem(key: string): string | null | undefined | Promise<string | null | undefined>;
|
|
80
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
81
|
+
removeItem(key: string): void | Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
/** The persisted record: which family and connector to restore, nothing else. */
|
|
84
|
+
export interface SavedConnection {
|
|
85
|
+
readonly family: string;
|
|
86
|
+
readonly connectorId: string;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,+FAA+F;AAC/F,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,YAAY,GAAG,cAAc,GAAG,WAAW,CAAC;AAE5F,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,4BAA4B;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,oBAAoB;IACnC,uFAAuF;IACvF,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED;;;;GAIG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OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACrF,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B"}
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAEhB,eAAe,EACf,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAEtB,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,iBAAiB,IAAI,0BAA0B,EAC/C,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,iBAA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