@asseteragmbh/wallet-connector 0.1.0 → 0.2.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 +61 -0
- package/dist/{chunk-L7EBYABA.js → chunk-ILCYZXH2.js} +3 -3
- package/dist/{chunk-L7EBYABA.js.map → chunk-ILCYZXH2.js.map} +1 -1
- package/dist/{chunk-QPNIGEP4.js → chunk-PD2FAZ7O.js} +3 -3
- package/dist/{chunk-QPNIGEP4.js.map → chunk-PD2FAZ7O.js.map} +1 -1
- package/dist/{chunk-N6D53D3G.js → chunk-SU2ZKBZD.js} +24 -3
- package/dist/chunk-SU2ZKBZD.js.map +1 -0
- package/dist/index.cjs +307 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -1
- package/dist/index.d.ts +72 -1
- package/dist/index.js +284 -2
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs +26 -0
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +61 -2
- package/dist/protocol.d.ts +61 -2
- package/dist/protocol.js +1 -1
- package/dist/rainbowkit.cjs.map +1 -1
- package/dist/rainbowkit.js +3 -3
- package/dist/wagmi.cjs.map +1 -1
- package/dist/wagmi.js +3 -3
- package/package.json +2 -2
- package/dist/chunk-N6D53D3G.js.map +0 -1
package/dist/protocol.d.ts
CHANGED
|
@@ -20,10 +20,32 @@
|
|
|
20
20
|
*
|
|
21
21
|
* The pop-up stays open while the partner uses the wallet (ADR-0054, "the wallet tab must stay open"). When it is
|
|
22
22
|
* closed, the opener sees `disconnect` (or notices `popup.closed`) and must reconnect from a user click.
|
|
23
|
+
*
|
|
24
|
+
* ## Onboarding
|
|
25
|
+
*
|
|
26
|
+
* Onboarding is a second flow on the same wallet origin, for a partner that wants the client to get an Assetera
|
|
27
|
+
* Wallet (a new one, or the one the client already has). The partner opens
|
|
28
|
+
* `${walletUrl}${ONBOARD_PATH}?origin=<partner origin>&v=<version>&chain=<CAIP-2 chain id>[&add=1]` from a user
|
|
29
|
+
* click. The pop-up checks the claimed origin against its partner list, signs the client in through SSO, runs the
|
|
30
|
+
* wizard (accept the wallet terms, create the wallet) and then posts `onboarded` (or `onboard-cancelled`) to
|
|
31
|
+
* `window.opener` with `targetOrigin` = the partner origin. `add=1` asks for one more wallet even when the client
|
|
32
|
+
* already has one.
|
|
33
|
+
*
|
|
34
|
+
* After `onboarded` the pop-up STAYS OPEN and answers `request` messages for `personal_sign` by the onboarded
|
|
35
|
+
* address (plus `eth_accounts` and `eth_chainId`), with the same `response` messages as `/connect`. That is how
|
|
36
|
+
* the partner gets the ownership signature it needs to register the wallet with its own compliance service: the
|
|
37
|
+
* wallet itself never calls a regulated service (ADR-0059 D3), and a second `window.open` after an asynchronous
|
|
38
|
+
* step would be blocked by the browser. The partner closes the pop-up when it is done.
|
|
39
|
+
*
|
|
40
|
+
* The opener accepts messages only when `event.origin` is the wallet origin AND `event.source` is the pop-up
|
|
41
|
+
* it opened. The wizard never returns a private key or a token, only the wallet address and signatures the
|
|
42
|
+
* client approved.
|
|
23
43
|
*/
|
|
24
44
|
declare const PROTOCOL_VERSION: 1;
|
|
25
45
|
/** The pop-up route on the wallet origin. */
|
|
26
46
|
declare const CONNECT_PATH = "/connect";
|
|
47
|
+
/** The onboarding wizard route on the wallet origin. */
|
|
48
|
+
declare const ONBOARD_PATH = "/onboard";
|
|
27
49
|
/** Every message carries this prefix in `type`, so both sides can ignore unrelated `postMessage` traffic. */
|
|
28
50
|
declare const MESSAGE_PREFIX: "assetera-wallet:";
|
|
29
51
|
/**
|
|
@@ -92,7 +114,30 @@ type EventMessage = {
|
|
|
92
114
|
event: "disconnect";
|
|
93
115
|
data: RpcError;
|
|
94
116
|
};
|
|
95
|
-
|
|
117
|
+
/**
|
|
118
|
+
* The onboarding wizard finished: the client accepted the wallet terms and has an Assetera Wallet on `chain`.
|
|
119
|
+
* `created` is `true` when the wallet was created in this run, `false` when the wizard returned the client's
|
|
120
|
+
* existing wallet. The wallet is not registered with any compliance service; that is the partner's step.
|
|
121
|
+
*/
|
|
122
|
+
interface OnboardedMessage {
|
|
123
|
+
type: `${typeof MESSAGE_PREFIX}onboarded`;
|
|
124
|
+
v: typeof PROTOCOL_VERSION;
|
|
125
|
+
address: `0x${string}`;
|
|
126
|
+
chain: string;
|
|
127
|
+
created: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated Sent by wallet versions that registered the wallet themselves (before ADR-0059). Ignored.
|
|
130
|
+
*/
|
|
131
|
+
status?: "approved" | "pending";
|
|
132
|
+
}
|
|
133
|
+
/** The onboarding wizard did not produce a wallet. `message` is optional diagnostics for the partner. */
|
|
134
|
+
interface OnboardCancelledMessage {
|
|
135
|
+
type: `${typeof MESSAGE_PREFIX}onboard-cancelled`;
|
|
136
|
+
v: typeof PROTOCOL_VERSION;
|
|
137
|
+
reason: "user" | "refused" | "error";
|
|
138
|
+
message?: string;
|
|
139
|
+
}
|
|
140
|
+
type WalletToPartnerMessage = ReadyMessage | ResponseMessage | EventMessage | OnboardedMessage | OnboardCancelledMessage;
|
|
96
141
|
interface RequestMessage {
|
|
97
142
|
type: `${typeof MESSAGE_PREFIX}request`;
|
|
98
143
|
v: typeof PROTOCOL_VERSION;
|
|
@@ -112,7 +157,21 @@ declare function isResponseMessage(value: unknown): value is ResponseMessage;
|
|
|
112
157
|
declare function isEventMessage(value: unknown): value is EventMessage;
|
|
113
158
|
declare function isRequestMessage(value: unknown): value is RequestMessage;
|
|
114
159
|
declare function isDisconnectMessage(value: unknown): value is DisconnectMessage;
|
|
160
|
+
declare function isOnboardedMessage(value: unknown): value is OnboardedMessage;
|
|
161
|
+
declare function isOnboardCancelledMessage(value: unknown): value is OnboardCancelledMessage;
|
|
162
|
+
/** A CAIP-2 EVM chain id, for example `eip155:80002` (Polygon Amoy) or `eip155:1` (mainnet). */
|
|
163
|
+
declare function isCaip2EvmChain(value: string): boolean;
|
|
115
164
|
/** The URL the partner opens. `partnerOrigin` is `window.location.origin` of the partner page. */
|
|
116
165
|
declare function connectUrl(walletUrl: string, partnerOrigin: string): string;
|
|
166
|
+
/**
|
|
167
|
+
* The URL the partner opens for the onboarding wizard. `partnerOrigin` is `window.location.origin` of the
|
|
168
|
+
* partner page; `chain` is the CAIP-2 chain id the new wallet should be created on; `locale` is passed as `lang`
|
|
169
|
+
* when the partner wants a specific wizard language.
|
|
170
|
+
*/
|
|
171
|
+
declare function onboardUrl(walletUrl: string, partnerOrigin: string, options: {
|
|
172
|
+
chain: string;
|
|
173
|
+
locale?: string;
|
|
174
|
+
add?: boolean;
|
|
175
|
+
}): string;
|
|
117
176
|
|
|
118
|
-
export { CONNECT_PATH, type DisconnectMessage, type EventMessage, MESSAGE_PREFIX, PROTOCOL_VERSION, type PartnerToWalletMessage, type ReadyMessage, type RequestMessage, type ResponseMessage, type RpcError, RpcErrorCode, SUPPORTED_METHODS, type SupportedMethod, type WalletToPartnerMessage, connectUrl, isDisconnectMessage, isEventMessage, isReadyMessage, isRequestMessage, isResponseMessage, isSupportedMethod };
|
|
177
|
+
export { CONNECT_PATH, type DisconnectMessage, type EventMessage, MESSAGE_PREFIX, ONBOARD_PATH, type OnboardCancelledMessage, type OnboardedMessage, PROTOCOL_VERSION, type PartnerToWalletMessage, type ReadyMessage, type RequestMessage, type ResponseMessage, type RpcError, RpcErrorCode, SUPPORTED_METHODS, type SupportedMethod, type WalletToPartnerMessage, connectUrl, isCaip2EvmChain, isDisconnectMessage, isEventMessage, isOnboardCancelledMessage, isOnboardedMessage, isReadyMessage, isRequestMessage, isResponseMessage, isSupportedMethod, onboardUrl };
|
package/dist/protocol.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CONNECT_PATH, MESSAGE_PREFIX, PROTOCOL_VERSION, RpcErrorCode, SUPPORTED_METHODS, connectUrl, isDisconnectMessage, isEventMessage, isReadyMessage, isRequestMessage, isResponseMessage, isSupportedMethod } from './chunk-
|
|
1
|
+
export { CONNECT_PATH, MESSAGE_PREFIX, ONBOARD_PATH, PROTOCOL_VERSION, RpcErrorCode, SUPPORTED_METHODS, connectUrl, isCaip2EvmChain, isDisconnectMessage, isEventMessage, isOnboardCancelledMessage, isOnboardedMessage, isReadyMessage, isRequestMessage, isResponseMessage, isSupportedMethod, onboardUrl } from './chunk-SU2ZKBZD.js';
|
|
2
2
|
//# sourceMappingURL=protocol.js.map
|
|
3
3
|
//# sourceMappingURL=protocol.js.map
|
package/dist/rainbowkit.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/icon.ts","../src/protocol.ts","../src/provider.ts","../src/wagmi.ts","../src/rainbowkit.ts"],"names":["request","active","createConnector","getAddress","UserRejectedRequestError","ChainNotConfiguredError","numberToHex"],"mappings":";;;;;;;;AAMA,IAAM,QAAA,GACJ,mSAAA;AAOK,IAAM,oBAAA,GAAuB,CAAA,mBAAA,EAAsB,kBAAA,CAAmB,QAAQ,CAAC,CAAA,CAAA;;;ACU/E,IAAM,gBAAA,GAAmB,CAAA;AAGzB,IAAM,YAAA,GAAe,UAAA;AAGrB,IAAM,cAAA,GAAiB,kBAAA;AAMvB,IAAM,iBAAA,GAAoB;AAAA,EAC/B,qBAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,4BAAA;AAAA,EACA,eAAA;AAAA,EACA,sBAAA;AAAA,EACA;AACF,CAAA;AAIO,SAAS,kBAAkB,MAAA,EAA2C;AAC3E,EAAA,OAAQ,iBAAA,CAAwC,SAAS,MAAM,CAAA;AACjE;AAGO,IAAM,YAAA,GAAe;AAAA,EAEZ;AAAA,EAEd,YAAA,EAAc,IAAA;AAAA;AAAA,EAEd,iBAAA,EAAmB,IAAA;AAAA;AAAA,EAEnB,YAAA,EAAc,IAOhB,CAAA;AAqEA,SAAS,SAAS,KAAA,EAAkD;AAClE,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA;AAChD;AAEA,SAAS,OAAA,CAAQ,OAAg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BAAkB,QAAA,EAAU;AAC1B,MAAA,IAAI,QAAA,CAAS,MAAA,KAAW,CAAA,EAAG,IAAA,CAAK,YAAA,EAAa;AAAA;AAE3C,QAAA,MAAA,CAAO,OAAA,CAAQ,KAAK,QAAA,EAAU;AAAA,UAC5B,UAAU,QAAA,CAAS,GAAA,CAAI,CAAC,OAAA,KAAYH,eAAA,CAAW,OAAO,CAAC;AAAA,SACxD,CAAA;AAAA,IACL,CAAA;AAAA,IAEA,eAAe,KAAA,EAAO;AACpB,MAAA,MAAA,CAAO,OAAA,CAAQ,KAAK,QAAA,EAAU,EAAE,SAAS,MAAA,CAAO,KAAK,GAAG,CAAA;AAAA,IAC1D,CAAA;AAAA,IAEA,YAAA,GAAe;AACb,MAAA,MAAA,CAAO,OAAA,CAAQ,KAAK,YAAY,CAAA;AAChC,MAAA,IAAI,QAAA,0BAAkC,QAAQ,CAAA;AAAA,IAChD;AAAA,GACF,CAAE,CAAA;AACJ;;;ACvIO,SAAS,sBAAsB,OAAA,EAAqD;AACzF,EAAA,OAAO,OAAO;AAAA,IACZ,EAAA,EAAI,kBAAA;AAAA,IACJ,IAAA,EAAM,oBAAA;AAAA,IACN,OAAA,EAAS,oBAAA;AAAA,IACT,cAAA,EAAgB,SAAA;AAAA,IAChB,SAAA,EAAW,IAAA;AAAA,IACX,eAAA,EAAiB,CAAC,aAAA,KAChBD,oBAAAA,CAAgB,CAAC,MAAA,MAAY;AAAA,MAC3B,GAAG,eAAe,EAAE,SAAA,EAAW,QAAQ,SAAA,EAAW,EAAE,MAAM,CAAA;AAAA,MAC1D,GAAG;AAAA,KACL,CAAE;AAAA,GACN,CAAA;AACF","file":"rainbowkit.cjs","sourcesContent":["/**\n * The wallet's mark as an inline data-URI, shared by the wagmi connector's `icon` and RainbowKit's `iconUrl`.\n *\n * It is intentionally tiny and dependency-free: a rounded dark square with a stylised \"A\". Keeping it as a\n * data URI means a partner app renders the wallet entry before its own bundle loads the wallet origin.\n */\nconst ICON_SVG =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"128\" height=\"128\" viewBox=\"0 0 128 128\" fill=\"none\">' +\n '<rect width=\"128\" height=\"128\" rx=\"28\" fill=\"#1a1a2e\"/>' +\n '<path fill=\"#ffffff\" fill-rule=\"evenodd\" d=\"M64 24 100 104H80.5L73.6 86H54.4L47.5 104H28L64 24Z' +\n 'm-4.5 44.5h9L64 54.4 59.5 68.5Z\"/>' +\n \"</svg>\";\n\n/** `data:image/svg+xml,...` representation of the Assetera Wallet mark. */\nexport const ASSETERA_WALLET_ICON = `data:image/svg+xml,${encodeURIComponent(ICON_SVG)}`;\n","/**\n * The pop-up protocol between a partner page (the opener) and the Assetera Wallet (the pop-up) — ADR-0054 D3/D4.\n *\n * This file is the CONTRACT. The connector in this package speaks the opener side; AsseteraWalletFront's\n * `/connect` page speaks the pop-up side and imports these types from `@asseteragmbh/wallet-connector/protocol`.\n * Change it only in a backwards-compatible way, or bump `PROTOCOL_VERSION` and support both on the wallet side:\n * partner sites upgrade on their own schedule.\n *\n * ## The handshake\n *\n * 1. The partner opens `${walletUrl}${CONNECT_PATH}?origin=<partner origin>&v=<version>` from a user click.\n * 2. The pop-up checks the claimed origin against its allowlist (D4). If listed, it posts `ready` to\n * `window.opener` with `targetOrigin` = that origin. The browser delivers it ONLY if the opener really is\n * that origin, so a page cannot claim someone else's origin and still hear the answer.\n * 3. The opener waits for `ready` from the wallet origin, then sends `request`s with `targetOrigin` = the wallet\n * origin. The pop-up accepts a message only when `event.origin` is the allowed origin from step 2 AND\n * `event.source === window.opener`, and answers with `targetOrigin` = that origin. Nothing else is accepted.\n *\n * ## Lifetime\n *\n * The pop-up stays open while the partner uses the wallet (ADR-0054, \"the wallet tab must stay open\"). When it is\n * closed, the opener sees `disconnect` (or notices `popup.closed`) and must reconnect from a user click.\n */\n\nexport const PROTOCOL_VERSION = 1 as const;\n\n/** The pop-up route on the wallet origin. */\nexport const CONNECT_PATH = \"/connect\";\n\n/** Every message carries this prefix in `type`, so both sides can ignore unrelated `postMessage` traffic. */\nexport const MESSAGE_PREFIX = \"assetera-wallet:\" as const;\n\n/**\n * The EIP-1193 methods the pop-up answers (ADR-0054 D3). Anything else is refused with 4200. Read-only chain\n * calls (`eth_call`, `eth_getBalance`, …) do not go through the pop-up; wagmi sends them to its own transports.\n */\nexport const SUPPORTED_METHODS = [\n \"eth_requestAccounts\",\n \"eth_accounts\",\n \"eth_chainId\",\n \"wallet_switchEthereumChain\",\n \"personal_sign\",\n \"eth_signTypedData_v4\",\n \"eth_sendTransaction\",\n] as const;\n\nexport type SupportedMethod = (typeof SUPPORTED_METHODS)[number];\n\nexport function isSupportedMethod(method: string): method is SupportedMethod {\n return (SUPPORTED_METHODS as readonly string[]).includes(method);\n}\n\n/** EIP-1193 / EIP-1474 error codes the pop-up uses. */\nexport const RpcErrorCode = {\n /** The client rejected the request in the pop-up. */\n UserRejected: 4001,\n /** Not connected yet (no `eth_requestAccounts` approved in this pop-up). */\n Unauthorized: 4100,\n /** The method is not in SUPPORTED_METHODS. */\n UnsupportedMethod: 4200,\n /** The pop-up closed, or the wallet session ended. */\n Disconnected: 4900,\n /** `wallet_switchEthereumChain` to a chain the wallet does not offer. */\n UnrecognizedChain: 4902,\n /** Malformed params. */\n InvalidParams: -32602,\n /** Anything unexpected inside the wallet. */\n Internal: -32603,\n} as const;\n\nexport type RpcErrorCode = (typeof RpcErrorCode)[keyof typeof RpcErrorCode];\n\nexport interface RpcError {\n code: number;\n message: string;\n data?: unknown;\n}\n\n// --- pop-up → opener ---------------------------------------------------------------------------------\n\n/** The pop-up is loaded and accepts requests from this opener. */\nexport interface ReadyMessage {\n type: `${typeof MESSAGE_PREFIX}ready`;\n v: typeof PROTOCOL_VERSION;\n /** Shown to the partner for diagnostics only; the partner must not rely on it for anything. */\n walletVersion?: string;\n}\n\n/** The answer to one `request`, matched by `id`. Exactly one of `result` / `error`. */\nexport type ResponseMessage =\n | { type: `${typeof MESSAGE_PREFIX}response`; v: typeof PROTOCOL_VERSION; id: string; result: unknown }\n | { type: `${typeof MESSAGE_PREFIX}response`; v: typeof PROTOCOL_VERSION; id: string; error: RpcError };\n\n/** EIP-1193 provider events, forwarded to the partner. */\nexport type EventMessage =\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"accountsChanged\";\n data: `0x${string}`[];\n }\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"chainChanged\";\n data: `0x${string}`;\n }\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"disconnect\";\n data: RpcError;\n };\n\nexport type WalletToPartnerMessage = ReadyMessage | ResponseMessage | EventMessage;\n\n// --- opener → pop-up ---------------------------------------------------------------------------------\n\nexport interface RequestMessage {\n type: `${typeof MESSAGE_PREFIX}request`;\n v: typeof PROTOCOL_VERSION;\n /** Unique per request within one connection; the response carries it back. */\n id: string;\n method: string;\n params?: unknown[] | Record<string, unknown>;\n}\n\n/** The partner disconnects (for example the user clicked \"Disconnect\" in the partner page). */\nexport interface DisconnectMessage {\n type: `${typeof MESSAGE_PREFIX}disconnect`;\n v: typeof PROTOCOL_VERSION;\n}\n\nexport type PartnerToWalletMessage = RequestMessage | DisconnectMessage;\n\n// --- guards ------------------------------------------------------------------------------------------\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction hasType(value: unknown, suffix: string): value is Record<string, unknown> {\n return isRecord(value) && value.type === `${MESSAGE_PREFIX}${suffix}` && value.v === PROTOCOL_VERSION;\n}\n\nexport function isReadyMessage(value: unknown): value is ReadyMessage {\n return hasType(value, \"ready\");\n}\n\nexport function isResponseMessage(value: unknown): value is ResponseMessage {\n return (\n hasType(value, \"response\") &&\n typeof value.id === \"string\" &&\n (\"result\" in value || (isRecord(value.error) && typeof value.error.code === \"number\"))\n );\n}\n\nexport function isEventMessage(value: unknown): value is EventMessage {\n return (\n hasType(value, \"event\") &&\n (value.event === \"accountsChanged\" || value.event === \"chainChanged\" || value.event === \"disconnect\")\n );\n}\n\nexport function isRequestMessage(value: unknown): value is RequestMessage {\n return hasType(value, \"request\") && typeof value.id === \"string\" && typeof value.method === \"string\";\n}\n\nexport function isDisconnectMessage(value: unknown): value is DisconnectMessage {\n return hasType(value, \"disconnect\");\n}\n\n/** The URL the partner opens. `partnerOrigin` is `window.location.origin` of the partner page. */\nexport function connectUrl(walletUrl: string, partnerOrigin: string): string {\n const url = new URL(CONNECT_PATH, walletUrl);\n url.searchParams.set(\"origin\", partnerOrigin);\n url.searchParams.set(\"v\", String(PROTOCOL_VERSION));\n return url.toString();\n}\n","/**\n * EIP-1193 provider for the Assetera Wallet pop-up — the opener side of the ADR-0054 D3/D4 protocol.\n *\n * The provider owns a single pop-up (`window.open(connectUrl(...), \"assetera-wallet\", ...)`) and speaks the\n * wire format defined in `./protocol`. It never touches Dynamic, React, wagmi or viem, so a partner can use it\n * on its own or through the wagmi / RainbowKit adapters in this package.\n */\nimport {\n MESSAGE_PREFIX,\n PROTOCOL_VERSION,\n RpcErrorCode,\n connectUrl,\n isEventMessage,\n isReadyMessage,\n isResponseMessage,\n isSupportedMethod,\n type DisconnectMessage,\n type EventMessage,\n type RequestMessage,\n type ResponseMessage,\n} from \"./protocol\";\n\n/** Arguments accepted by `request`, mirroring EIP-1193. */\nexport interface RequestArguments {\n method: string;\n params?: unknown[] | Record<string, unknown>;\n}\n\n/** EIP-1193 provider events emitted by the pop-up. */\nexport type ProviderEvent = \"accountsChanged\" | \"chainChanged\" | \"connect\" | \"disconnect\";\n\n/**\n * Listener shape for EIP-1193 provider events. `never[]` accepts a listener with any concrete parameter list\n * (for example wagmi's `(accounts: string[]) => void`), while internal emission stays type-safe via a cast.\n */\nexport type ProviderListener = (...args: never[]) => void;\n\n/** The EIP-1193 surface returned by {@link createAsseteraWalletProvider}. */\nexport interface AsseteraWalletProvider {\n request(args: RequestArguments): Promise<unknown>;\n on(event: ProviderEvent, listener: ProviderListener): void;\n removeListener(event: ProviderEvent, listener: ProviderListener): void;\n disconnect(): void;\n}\n\n/** Options for {@link createAsseteraWalletProvider}. */\nexport interface AsseteraWalletProviderOptions {\n /** Base URL of the wallet origin, e.g. `https://wallet.playground.assetera.com`. */\n walletUrl: string;\n /** Chain id used before the wallet reports one, and as the local `eth_chainId` fallback. */\n defaultChainId: number;\n /** `window.open` feature string. Defaults to `\"popup,width=420,height=720\"`. */\n popupFeatures?: string;\n}\n\n/**\n * EIP-1193 error carrying a JSON-RPC `code` (and optional `data`). This is what every rejected `request`\n * throws, so wagmi maps the wallet's `4001` / `4100` / `4200` / `4900` correctly.\n */\nexport class ProviderRpcError extends Error {\n readonly code: number;\n readonly data?: unknown;\n\n constructor(code: number, message: string, data?: unknown) {\n super(message);\n this.name = \"ProviderRpcError\";\n this.code = code;\n this.data = data;\n }\n}\n\nconst DEFAULT_POPUP_FEATURES = \"popup,width=420,height=720\";\nconst POPUP_NAME = \"assetera-wallet\";\nconst CLOSE_POLL_MS = 500;\n\n/** Methods that show the user a signature / transaction prompt, so the pop-up should be focused first. */\nconst SIGNING_METHODS: ReadonlySet<string> = new Set([\n \"personal_sign\",\n \"eth_signTypedData_v4\",\n \"eth_sendTransaction\",\n]);\n\ninterface PendingRequest {\n resolve: (value: unknown) => void;\n reject: (reason: unknown) => void;\n}\n\ninterface Deferred<T> {\n promise: Promise<T>;\n resolve: (value: T) => void;\n reject: (reason: unknown) => void;\n}\n\nfunction createDeferred<T>(): Deferred<T> {\n let resolve!: (value: T) => void;\n let reject!: (reason: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n // The `ready` deferred is rejected when the pop-up closes even if no request is waiting on it; mark the\n // promise as handled so that rejection is not reported as an unhandled promise rejection.\n void promise.catch(() => {});\n return { promise, resolve, reject };\n}\n\nfunction toHexChainId(chainId: number): string {\n return `0x${chainId.toString(16)}`;\n}\n\n/**\n * Create the EIP-1193 provider that talks to the Assetera Wallet pop-up.\n *\n * Call `request` from a user gesture: `eth_requestAccounts` opens the pop-up synchronously (before any\n * `await`) so the browser treats it as part of the click and does not block it.\n */\nexport function createAsseteraWalletProvider(options: AsseteraWalletProviderOptions): AsseteraWalletProvider {\n const { defaultChainId } = options;\n const walletOrigin = new URL(options.walletUrl).origin;\n const popupFeatures = options.popupFeatures ?? DEFAULT_POPUP_FEATURES;\n\n let popup: Window | null = null;\n /** Resolves when the *current* pop-up posts `ready`. Replaced when a new pop-up is opened. */\n let ready = createDeferred<void>();\n let accounts: string[] = [];\n let chainIdHex: string | null = null;\n /** Set when the wallet itself told us the session ended (as opposed to the user merely closing the tab). */\n let walletDisconnected = false;\n const pending = new Map<string, PendingRequest>();\n const listeners = new Map<ProviderEvent, Set<(...args: unknown[]) => void>>();\n let closeTimer: ReturnType<typeof setInterval> | null = null;\n\n function currentChainId(): string {\n return chainIdHex ?? toHexChainId(defaultChainId);\n }\n\n function blockedError(): ProviderRpcError {\n return new ProviderRpcError(\n RpcErrorCode.Disconnected,\n \"The Assetera Wallet pop-up was blocked by the browser. The pop-up must be opened from a user click \" +\n \"(for example a button press) and then the request retried.\",\n );\n }\n\n function disconnectedError(message = \"The Assetera Wallet pop-up was closed.\"): ProviderRpcError {\n return new ProviderRpcError(RpcErrorCode.Disconnected, message);\n }\n\n function emit(event: ProviderEvent, ...args: unknown[]): void {\n const set = listeners.get(event);\n if (!set) return;\n for (const listener of set) {\n try {\n listener(...args);\n } catch (error) {\n console.error(`[assetera-wallet] listener for \"${event}\" threw`, error);\n }\n }\n }\n\n function addListener(event: ProviderEvent, listener: ProviderListener): void {\n let set = listeners.get(event);\n if (!set) {\n set = new Set<(...args: unknown[]) => void>();\n listeners.set(event, set);\n }\n set.add(listener as (...args: unknown[]) => void);\n }\n\n function removeEventListener(event: ProviderEvent, listener: ProviderListener): void {\n listeners.get(event)?.delete(listener as (...args: unknown[]) => void);\n }\n\n function stopClosePolling(): void {\n if (closeTimer !== null) {\n clearInterval(closeTimer);\n closeTimer = null;\n }\n }\n\n function startClosePolling(): void {\n if (closeTimer !== null) return;\n closeTimer = setInterval(() => {\n if (popup?.closed) handlePopupClosed();\n }, CLOSE_POLL_MS);\n }\n\n function rejectAllPending(error: ProviderRpcError): void {\n for (const request of pending.values()) request.reject(error);\n pending.clear();\n }\n\n /**\n * The pop-up was closed by the user (or the wallet app).\n *\n * We deliberately KEEP `accounts` / `chainIdHex` cached: the dApp stays \"connected\" in React state and does\n * not flicker back to a disconnected UI. Because a pop-up cannot be reopened without a user gesture, the next\n * signing request reopens it from the caller's click. `disconnect` is only emitted when the close actually\n * interrupted work (a request was pending) or when the wallet itself announced the disconnect.\n */\n function handlePopupClosed(): void {\n const hadPending = pending.size > 0;\n stopClosePolling();\n const closedPopup = popup;\n popup = null;\n const closedReady = ready;\n ready = createDeferred<void>();\n const error = disconnectedError();\n if (closedPopup) closedReady.reject(error);\n rejectAllPending(error);\n const shouldEmit = hadPending || walletDisconnected;\n walletDisconnected = false;\n if (shouldEmit) emit(\"disconnect\", error);\n }\n\n /**\n * Open the pop-up, or focus and reuse it when it is still around. Must stay synchronous (it is called before\n * any `await` in `request`) so it runs inside the caller's user activation.\n */\n function openPopup(): Window | null {\n if (popup && !popup.closed) {\n popup.focus();\n return popup;\n }\n if (typeof window === \"undefined\") return null;\n const opened = window.open(\n connectUrl(options.walletUrl, window.location.origin),\n POPUP_NAME,\n popupFeatures,\n );\n if (!opened) return null;\n popup = opened;\n ready = createDeferred<void>();\n walletDisconnected = false;\n startClosePolling();\n return opened;\n }\n\n function sendRequest(method: string, params?: RequestArguments[\"params\"]): Promise<unknown> {\n const active = popup;\n if (!active || active.closed) return Promise.reject(disconnectedError());\n const id = crypto.randomUUID();\n const message: RequestMessage = {\n type: `${MESSAGE_PREFIX}request`,\n v: PROTOCOL_VERSION,\n id,\n method,\n ...(params === undefined ? {} : { params }),\n };\n return new Promise<unknown>((resolve, reject) => {\n pending.set(id, { resolve, reject });\n active.postMessage(message, walletOrigin);\n });\n }\n\n function handleResponse(message: ResponseMessage): void {\n const request = pending.get(message.id);\n if (!request) return;\n pending.delete(message.id);\n if (\"error\" in message) {\n request.reject(new ProviderRpcError(message.error.code, message.error.message, message.error.data));\n } else {\n request.resolve(message.result);\n }\n }\n\n function handleEventMessage(message: EventMessage): void {\n if (message.event === \"accountsChanged\") {\n accounts = [...message.data];\n emit(\"accountsChanged\", [...accounts]);\n return;\n }\n if (message.event === \"chainChanged\") {\n chainIdHex = message.data;\n emit(\"chainChanged\", chainIdHex);\n return;\n }\n walletDisconnected = true;\n emit(\"disconnect\", new ProviderRpcError(message.data.code, message.data.message, message.data.data));\n }\n\n function onWindowMessage(event: MessageEvent): void {\n if (event.origin !== walletOrigin) return;\n if (popup === null || (event.source as unknown) !== popup) return;\n const data: unknown = event.data;\n if (isReadyMessage(data)) {\n ready.resolve(undefined);\n return;\n }\n if (isResponseMessage(data)) {\n handleResponse(data);\n return;\n }\n if (isEventMessage(data)) handleEventMessage(data);\n }\n\n if (typeof window !== \"undefined\") window.addEventListener(\"message\", onWindowMessage);\n\n function request({ method, params }: RequestArguments): Promise<unknown> {\n if (typeof window === \"undefined\") {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.Disconnected,\n \"The Assetera Wallet provider can only run in a browser.\",\n ),\n );\n }\n // Read-only chain calls go through wagmi's own transports; the pop-up refuses everything else.\n if (!isSupportedMethod(method)) {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.UnsupportedMethod,\n `The Assetera Wallet pop-up does not support the method \"${method}\".`,\n ),\n );\n }\n // Answered locally, without a pop-up, so wagmi can read the connection before the user clicks.\n if (method === \"eth_accounts\") return Promise.resolve([...accounts]);\n if (method === \"eth_chainId\") return Promise.resolve(currentChainId());\n\n // Opening the pop-up MUST happen synchronously, before the first `await`, to stay in the click.\n if (method === \"eth_requestAccounts\") {\n const active = openPopup();\n if (!active) return Promise.reject(blockedError());\n return ready.promise\n .then(() => sendRequest(\"eth_requestAccounts\", params))\n .then((result) => {\n accounts = Array.isArray(result) ? (result as string[]) : [];\n emit(\"accountsChanged\", [...accounts]);\n emit(\"connect\", { chainId: currentChainId() });\n return [...accounts];\n });\n }\n\n // Every other supported method needs an approved connection.\n if (accounts.length === 0) {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.Unauthorized,\n \"Connect to the Assetera Wallet first (eth_requestAccounts).\",\n ),\n );\n }\n const active = openPopup();\n if (!active) return Promise.reject(blockedError());\n if (SIGNING_METHODS.has(method)) active.focus();\n return ready.promise.then(() => sendRequest(method, params));\n }\n\n function disconnect(): void {\n const active = popup;\n if (active && !active.closed) {\n const message: DisconnectMessage = {\n type: `${MESSAGE_PREFIX}disconnect`,\n v: PROTOCOL_VERSION,\n };\n active.postMessage(message, walletOrigin);\n active.close();\n }\n stopClosePolling();\n popup = null;\n const closedReady = ready;\n ready = createDeferred<void>();\n closedReady.reject(disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n rejectAllPending(disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n accounts = [];\n chainIdHex = null;\n walletDisconnected = false;\n emit(\"disconnect\", disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n }\n\n function on(event: ProviderEvent, listener: ProviderListener): void {\n addListener(event, listener);\n }\n\n function removeListener(event: ProviderEvent, listener: ProviderListener): void {\n removeEventListener(event, listener);\n }\n\n return { request, on, removeListener, disconnect };\n}\n","/**\n * wagmi v2 connector for the Assetera Wallet pop-up (ADR-0054 D3).\n *\n * Built with `createConnector` from `@wagmi/core`, following the structure of wagmi's own `injected` connector.\n * `@wagmi/core`, `viem` and wagmi are peer dependencies so a partner app keeps a single copy of them on the\n * page. The connector is intentionally thin: all protocol work lives in {@link createAsseteraWalletProvider}.\n */\nimport { ChainNotConfiguredError, createConnector, type Connector } from \"@wagmi/core\";\nimport { getAddress, numberToHex, UserRejectedRequestError } from \"viem\";\nimport { ASSETERA_WALLET_ICON } from \"./icon\";\nimport { createAsseteraWalletProvider, type AsseteraWalletProvider } from \"./provider\";\n\n/** Stable connector id, used by wagmi for storage keys and RainbowKit for the wallet entry. */\nexport const ASSETERA_WALLET_ID = \"assetera-wallet\";\n/** Product name, exactly \"Assetera Wallet\". */\nexport const ASSETERA_WALLET_NAME = \"Assetera Wallet\";\n/** Connector `type` reported to wagmi. */\nexport const ASSETERA_WALLET_TYPE = \"asseteraWallet\";\n\n/** Parameters accepted by {@link asseteraWallet}. */\nexport interface AsseteraWalletParameters {\n /** Base URL of the wallet origin, e.g. `https://wallet.playground.assetera.com`. */\n walletUrl: string;\n}\n\n/**\n * Create the wagmi connector for the Assetera Wallet pop-up.\n *\n * `connect()` must be called from a user click: `eth_requestAccounts` opens the pop-up, and a pop-up cannot be\n * opened without transient user activation.\n */\nexport function asseteraWallet(parameters: AsseteraWalletParameters) {\n type Provider = AsseteraWalletProvider;\n\n let provider: Provider | undefined;\n let accountsChanged: Connector[\"onAccountsChanged\"] | undefined;\n let chainChanged: Connector[\"onChainChanged\"] | undefined;\n let disconnectHandler: Connector[\"onDisconnect\"] | undefined;\n\n function removeProviderListeners(activeProvider: Provider): void {\n if (accountsChanged) {\n activeProvider.removeListener(\"accountsChanged\", accountsChanged);\n accountsChanged = undefined;\n }\n if (chainChanged) {\n activeProvider.removeListener(\"chainChanged\", chainChanged);\n chainChanged = undefined;\n }\n if (disconnectHandler) {\n activeProvider.removeListener(\"disconnect\", disconnectHandler);\n disconnectHandler = undefined;\n }\n }\n\n return createConnector<Provider>((config) => ({\n id: ASSETERA_WALLET_ID,\n name: ASSETERA_WALLET_NAME,\n type: ASSETERA_WALLET_TYPE,\n icon: ASSETERA_WALLET_ICON,\n\n async connect({ chainId, withCapabilities } = {}) {\n const activeProvider = await this.getProvider();\n const requested = (await activeProvider.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n const addresses = requested.map((account) => getAddress(account));\n\n // Forward the pop-up's own events into wagmi's emitter.\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this);\n activeProvider.on(\"accountsChanged\", accountsChanged);\n }\n if (!chainChanged) {\n chainChanged = this.onChainChanged.bind(this);\n activeProvider.on(\"chainChanged\", chainChanged);\n }\n if (!disconnectHandler) {\n disconnectHandler = this.onDisconnect.bind(this);\n activeProvider.on(\"disconnect\", disconnectHandler);\n }\n\n // Switch to the requested chain when the caller asked for one.\n let currentChainId = await this.getChainId();\n if (chainId && currentChainId !== chainId) {\n const chain = await this.switchChain!({ chainId }).catch((error) => {\n if (error?.code === UserRejectedRequestError.code) throw error;\n return { id: currentChainId };\n });\n currentChainId = chain?.id ?? currentChainId;\n }\n\n return {\n accounts: (withCapabilities\n ? addresses.map((address) => ({ address, capabilities: {} }))\n : addresses) as never,\n chainId: currentChainId,\n };\n },\n\n async disconnect() {\n if (!provider) return;\n removeProviderListeners(provider);\n provider.disconnect();\n },\n\n async getAccounts() {\n const activeProvider = await this.getProvider();\n const requested = (await activeProvider.request({ method: \"eth_accounts\" })) as string[];\n return requested.map((account) => getAddress(account));\n },\n\n async getChainId() {\n const activeProvider = await this.getProvider();\n return Number(await activeProvider.request({ method: \"eth_chainId\" }));\n },\n\n async getProvider() {\n // One provider per connector, created lazily so a partner that never connects pays nothing.\n if (!provider) {\n provider = createAsseteraWalletProvider({\n walletUrl: parameters.walletUrl,\n defaultChainId: config.chains[0].id,\n });\n }\n return provider;\n },\n\n /**\n * Always `false`: opening the pop-up requires a user click, so there is nothing to reconnect to on page\n * load. Returning `true` would make wagmi attempt an automatic reconnect that the browser blocks; the\n * partner app must drive `connect()` from a click instead.\n */\n async isAuthorized() {\n return false;\n },\n\n async switchChain({ chainId }) {\n const chain = config.chains.find((candidate) => candidate.id === chainId);\n if (!chain) throw new ChainNotConfiguredError();\n const activeProvider = await this.getProvider();\n await activeProvider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n this.onChainChanged(numberToHex(chainId));\n return chain;\n },\n\n onAccountsChanged(accounts) {\n if (accounts.length === 0) this.onDisconnect();\n else\n config.emitter.emit(\"change\", {\n accounts: accounts.map((account) => getAddress(account)),\n });\n },\n\n onChainChanged(chain) {\n config.emitter.emit(\"change\", { chainId: Number(chain) });\n },\n\n onDisconnect() {\n config.emitter.emit(\"disconnect\");\n if (provider) removeProviderListeners(provider);\n },\n }));\n}\n","/**\n * RainbowKit wallet entry for the Assetera Wallet pop-up (ADR-0054 D3).\n *\n * RainbowKit 2.2 custom wallets wrap a wagmi connector with their own `rkDetails`; this mirrors RainbowKit's\n * built-in wallets (see the \"Creating a custom wallet\" guide). Use it through `connectorsForWallets`:\n *\n * ```ts\n * connectorsForWallets(\n * [{ groupName: \"Assetera\", wallets: [asseteraRainbowWallet({ walletUrl: \"https://wallet…\" })] }],\n * { appName, projectId },\n * );\n * ```\n */\nimport type { Wallet } from \"@rainbow-me/rainbowkit\";\nimport { createConnector } from \"@wagmi/core\";\nimport { ASSETERA_WALLET_ICON } from \"./icon\";\nimport { ASSETERA_WALLET_ID, ASSETERA_WALLET_NAME, asseteraWallet } from \"./wagmi\";\n\n/** Options accepted by {@link asseteraRainbowWallet}. */\nexport interface AsseteraRainbowWalletOptions {\n /** Base URL of the wallet origin, e.g. `https://wallet.playground.assetera.com`. */\n walletUrl: string;\n}\n\n/**\n * Create the RainbowKit wallet entry for the Assetera Wallet pop-up.\n *\n * Returns a FUNCTION that returns the {@link Wallet}, not the wallet itself: `connectorsForWallets` expects its\n * `wallets` list to hold `CreateWalletFn`s (like `metaMaskWallet`) and calls each one with its own options.\n */\nexport function asseteraRainbowWallet(options: AsseteraRainbowWalletOptions): () => Wallet {\n return () => ({\n id: ASSETERA_WALLET_ID,\n name: ASSETERA_WALLET_NAME,\n iconUrl: ASSETERA_WALLET_ICON,\n iconBackground: \"#1a1a2e\",\n installed: true,\n createConnector: (walletDetails) =>\n createConnector((config) => ({\n ...asseteraWallet({ walletUrl: options.walletUrl })(config),\n ...walletDetails,\n })),\n });\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/icon.ts","../src/protocol.ts","../src/provider.ts","../src/wagmi.ts","../src/rainbowkit.ts"],"names":["request","active","createConnector","getAddress","UserRejectedRequestError","ChainNotConfiguredError","numberToHex"],"mappings":";;;;;;;;AAMA,IAAM,QAAA,GACJ,mSAAA;AAOK,IAAM,oBAAA,GAAuB,CAAA,mBAAA,EAAsB,kBAAA,CAAmB,QAAQ,CAAC,CAAA,CAAA;;;AC8B/E,IAAM,gBAAA,GAAmB,CAAA;AAGzB,IAAM,YAAA,GAAe,UAAA;AAMrB,IAAM,cAAA,GAAiB,kBAAA;AAMvB,IAAM,iBAAA,GAAoB;AAAA,EAC/B,qBAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,4BAAA;AAAA,EACA,eAAA;AAAA,EACA,sBAAA;AAAA,EACA;AACF,CAAA;AAIO,SAAS,kBAAkB,MAAA,EAA2C;AAC3E,EAAA,OAAQ,iBAAA,CAAwC,SAAS,MAAM,CAAA;AACjE;AAGO,IAAM,YAAA,GAAe;AAAA,EAEZ;AAAA,EAEd,YAAA,EAAc,IAAA;AAAA;AAAA,EAEd,iBAAA,EAAmB,IAAA;AAAA;AAAA,EAEnB,YAAA,EAAc,IAOhB,CAAA;AA+FA,SAAS,SAAS,KAAA,EAAkD;AAClE,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA;AAChD;AAEA,SAAS,OAAA,CAAQ,OAAgB,MAAA,EAAkD;AACjF,EAAA,OAAO,QAAA,CAAS,KAAK,CAAA,IAAK,KAAA,CAAM,IAAA,KAAS,CAAA,EAAG,cAAc,CAAA,EAAG,MAAM,CAAA,CAAA,IAAM,KAAA,CAAM,CAAA,KAAM,gBAAA;AACvF;AAEO,SAAS,eAAe,KAAA,EAAuC;AACpE,EAAA,OAAO,OAAA,CAAQ,OAAO,OAAO,CAAA;AAC/B;AAEO,SAAS,kBAAkB,KAAA,EAA0C;AAC1E,EAAA,OACE,QAAQ,KAAA,EAAO,UAAU,CAA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,KAAK,QAAA,EAAU,EAAE,SAAS,MAAA,CAAO,KAAK,GAAG,CAAA;AAAA,IAC1D,CAAA;AAAA,IAEA,YAAA,GAAe;AACb,MAAA,MAAA,CAAO,OAAA,CAAQ,KAAK,YAAY,CAAA;AAChC,MAAA,IAAI,QAAA,0BAAkC,QAAQ,CAAA;AAAA,IAChD;AAAA,GACF,CAAE,CAAA;AACJ;;;ACvIO,SAAS,sBAAsB,OAAA,EAAqD;AACzF,EAAA,OAAO,OAAO;AAAA,IACZ,EAAA,EAAI,kBAAA;AAAA,IACJ,IAAA,EAAM,oBAAA;AAAA,IACN,OAAA,EAAS,oBAAA;AAAA,IACT,cAAA,EAAgB,SAAA;AAAA,IAChB,SAAA,EAAW,IAAA;AAAA,IACX,eAAA,EAAiB,CAAC,aAAA,KAChBD,oBAAAA,CAAgB,CAAC,MAAA,MAAY;AAAA,MAC3B,GAAG,eAAe,EAAE,SAAA,EAAW,QAAQ,SAAA,EAAW,EAAE,MAAM,CAAA;AAAA,MAC1D,GAAG;AAAA,KACL,CAAE;AAAA,GACN,CAAA;AACF","file":"rainbowkit.cjs","sourcesContent":["/**\n * The wallet's mark as an inline data-URI, shared by the wagmi connector's `icon` and RainbowKit's `iconUrl`.\n *\n * It is intentionally tiny and dependency-free: a rounded dark square with a stylised \"A\". Keeping it as a\n * data URI means a partner app renders the wallet entry before its own bundle loads the wallet origin.\n */\nconst ICON_SVG =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"128\" height=\"128\" viewBox=\"0 0 128 128\" fill=\"none\">' +\n '<rect width=\"128\" height=\"128\" rx=\"28\" fill=\"#1a1a2e\"/>' +\n '<path fill=\"#ffffff\" fill-rule=\"evenodd\" d=\"M64 24 100 104H80.5L73.6 86H54.4L47.5 104H28L64 24Z' +\n 'm-4.5 44.5h9L64 54.4 59.5 68.5Z\"/>' +\n \"</svg>\";\n\n/** `data:image/svg+xml,...` representation of the Assetera Wallet mark. */\nexport const ASSETERA_WALLET_ICON = `data:image/svg+xml,${encodeURIComponent(ICON_SVG)}`;\n","/**\n * The pop-up protocol between a partner page (the opener) and the Assetera Wallet (the pop-up) — ADR-0054 D3/D4.\n *\n * This file is the CONTRACT. The connector in this package speaks the opener side; AsseteraWalletFront's\n * `/connect` page speaks the pop-up side and imports these types from `@asseteragmbh/wallet-connector/protocol`.\n * Change it only in a backwards-compatible way, or bump `PROTOCOL_VERSION` and support both on the wallet side:\n * partner sites upgrade on their own schedule.\n *\n * ## The handshake\n *\n * 1. The partner opens `${walletUrl}${CONNECT_PATH}?origin=<partner origin>&v=<version>` from a user click.\n * 2. The pop-up checks the claimed origin against its allowlist (D4). If listed, it posts `ready` to\n * `window.opener` with `targetOrigin` = that origin. The browser delivers it ONLY if the opener really is\n * that origin, so a page cannot claim someone else's origin and still hear the answer.\n * 3. The opener waits for `ready` from the wallet origin, then sends `request`s with `targetOrigin` = the wallet\n * origin. The pop-up accepts a message only when `event.origin` is the allowed origin from step 2 AND\n * `event.source === window.opener`, and answers with `targetOrigin` = that origin. Nothing else is accepted.\n *\n * ## Lifetime\n *\n * The pop-up stays open while the partner uses the wallet (ADR-0054, \"the wallet tab must stay open\"). When it is\n * closed, the opener sees `disconnect` (or notices `popup.closed`) and must reconnect from a user click.\n *\n * ## Onboarding\n *\n * Onboarding is a second flow on the same wallet origin, for a partner that wants the client to get an Assetera\n * Wallet (a new one, or the one the client already has). The partner opens\n * `${walletUrl}${ONBOARD_PATH}?origin=<partner origin>&v=<version>&chain=<CAIP-2 chain id>[&add=1]` from a user\n * click. The pop-up checks the claimed origin against its partner list, signs the client in through SSO, runs the\n * wizard (accept the wallet terms, create the wallet) and then posts `onboarded` (or `onboard-cancelled`) to\n * `window.opener` with `targetOrigin` = the partner origin. `add=1` asks for one more wallet even when the client\n * already has one.\n *\n * After `onboarded` the pop-up STAYS OPEN and answers `request` messages for `personal_sign` by the onboarded\n * address (plus `eth_accounts` and `eth_chainId`), with the same `response` messages as `/connect`. That is how\n * the partner gets the ownership signature it needs to register the wallet with its own compliance service: the\n * wallet itself never calls a regulated service (ADR-0059 D3), and a second `window.open` after an asynchronous\n * step would be blocked by the browser. The partner closes the pop-up when it is done.\n *\n * The opener accepts messages only when `event.origin` is the wallet origin AND `event.source` is the pop-up\n * it opened. The wizard never returns a private key or a token, only the wallet address and signatures the\n * client approved.\n */\n\nexport const PROTOCOL_VERSION = 1 as const;\n\n/** The pop-up route on the wallet origin. */\nexport const CONNECT_PATH = \"/connect\";\n\n/** The onboarding wizard route on the wallet origin. */\nexport const ONBOARD_PATH = \"/onboard\";\n\n/** Every message carries this prefix in `type`, so both sides can ignore unrelated `postMessage` traffic. */\nexport const MESSAGE_PREFIX = \"assetera-wallet:\" as const;\n\n/**\n * The EIP-1193 methods the pop-up answers (ADR-0054 D3). Anything else is refused with 4200. Read-only chain\n * calls (`eth_call`, `eth_getBalance`, …) do not go through the pop-up; wagmi sends them to its own transports.\n */\nexport const SUPPORTED_METHODS = [\n \"eth_requestAccounts\",\n \"eth_accounts\",\n \"eth_chainId\",\n \"wallet_switchEthereumChain\",\n \"personal_sign\",\n \"eth_signTypedData_v4\",\n \"eth_sendTransaction\",\n] as const;\n\nexport type SupportedMethod = (typeof SUPPORTED_METHODS)[number];\n\nexport function isSupportedMethod(method: string): method is SupportedMethod {\n return (SUPPORTED_METHODS as readonly string[]).includes(method);\n}\n\n/** EIP-1193 / EIP-1474 error codes the pop-up uses. */\nexport const RpcErrorCode = {\n /** The client rejected the request in the pop-up. */\n UserRejected: 4001,\n /** Not connected yet (no `eth_requestAccounts` approved in this pop-up). */\n Unauthorized: 4100,\n /** The method is not in SUPPORTED_METHODS. */\n UnsupportedMethod: 4200,\n /** The pop-up closed, or the wallet session ended. */\n Disconnected: 4900,\n /** `wallet_switchEthereumChain` to a chain the wallet does not offer. */\n UnrecognizedChain: 4902,\n /** Malformed params. */\n InvalidParams: -32602,\n /** Anything unexpected inside the wallet. */\n Internal: -32603,\n} as const;\n\nexport type RpcErrorCode = (typeof RpcErrorCode)[keyof typeof RpcErrorCode];\n\nexport interface RpcError {\n code: number;\n message: string;\n data?: unknown;\n}\n\n// --- pop-up → opener ---------------------------------------------------------------------------------\n\n/** The pop-up is loaded and accepts requests from this opener. */\nexport interface ReadyMessage {\n type: `${typeof MESSAGE_PREFIX}ready`;\n v: typeof PROTOCOL_VERSION;\n /** Shown to the partner for diagnostics only; the partner must not rely on it for anything. */\n walletVersion?: string;\n}\n\n/** The answer to one `request`, matched by `id`. Exactly one of `result` / `error`. */\nexport type ResponseMessage =\n | { type: `${typeof MESSAGE_PREFIX}response`; v: typeof PROTOCOL_VERSION; id: string; result: unknown }\n | { type: `${typeof MESSAGE_PREFIX}response`; v: typeof PROTOCOL_VERSION; id: string; error: RpcError };\n\n/** EIP-1193 provider events, forwarded to the partner. */\nexport type EventMessage =\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"accountsChanged\";\n data: `0x${string}`[];\n }\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"chainChanged\";\n data: `0x${string}`;\n }\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"disconnect\";\n data: RpcError;\n };\n\n/**\n * The onboarding wizard finished: the client accepted the wallet terms and has an Assetera Wallet on `chain`.\n * `created` is `true` when the wallet was created in this run, `false` when the wizard returned the client's\n * existing wallet. The wallet is not registered with any compliance service; that is the partner's step.\n */\nexport interface OnboardedMessage {\n type: `${typeof MESSAGE_PREFIX}onboarded`;\n v: typeof PROTOCOL_VERSION;\n address: `0x${string}`;\n chain: string;\n created: boolean;\n /**\n * @deprecated Sent by wallet versions that registered the wallet themselves (before ADR-0059). Ignored.\n */\n status?: \"approved\" | \"pending\";\n}\n\n/** The onboarding wizard did not produce a wallet. `message` is optional diagnostics for the partner. */\nexport interface OnboardCancelledMessage {\n type: `${typeof MESSAGE_PREFIX}onboard-cancelled`;\n v: typeof PROTOCOL_VERSION;\n reason: \"user\" | \"refused\" | \"error\";\n message?: string;\n}\n\nexport type WalletToPartnerMessage =\n ReadyMessage | ResponseMessage | EventMessage | OnboardedMessage | OnboardCancelledMessage;\n\n// --- opener → pop-up ---------------------------------------------------------------------------------\n\nexport interface RequestMessage {\n type: `${typeof MESSAGE_PREFIX}request`;\n v: typeof PROTOCOL_VERSION;\n /** Unique per request within one connection; the response carries it back. */\n id: string;\n method: string;\n params?: unknown[] | Record<string, unknown>;\n}\n\n/** The partner disconnects (for example the user clicked \"Disconnect\" in the partner page). */\nexport interface DisconnectMessage {\n type: `${typeof MESSAGE_PREFIX}disconnect`;\n v: typeof PROTOCOL_VERSION;\n}\n\nexport type PartnerToWalletMessage = RequestMessage | DisconnectMessage;\n\n// --- guards ------------------------------------------------------------------------------------------\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction hasType(value: unknown, suffix: string): value is Record<string, unknown> {\n return isRecord(value) && value.type === `${MESSAGE_PREFIX}${suffix}` && value.v === PROTOCOL_VERSION;\n}\n\nexport function isReadyMessage(value: unknown): value is ReadyMessage {\n return hasType(value, \"ready\");\n}\n\nexport function isResponseMessage(value: unknown): value is ResponseMessage {\n return (\n hasType(value, \"response\") &&\n typeof value.id === \"string\" &&\n (\"result\" in value || (isRecord(value.error) && typeof value.error.code === \"number\"))\n );\n}\n\nexport function isEventMessage(value: unknown): value is EventMessage {\n return (\n hasType(value, \"event\") &&\n (value.event === \"accountsChanged\" || value.event === \"chainChanged\" || value.event === \"disconnect\")\n );\n}\n\nexport function isRequestMessage(value: unknown): value is RequestMessage {\n return hasType(value, \"request\") && typeof value.id === \"string\" && typeof value.method === \"string\";\n}\n\nexport function isDisconnectMessage(value: unknown): value is DisconnectMessage {\n return hasType(value, \"disconnect\");\n}\n\n/** `0x` followed by exactly 40 hexadecimal digits, the shape of an EVM address. */\nconst EVM_ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;\n\nexport function isOnboardedMessage(value: unknown): value is OnboardedMessage {\n return (\n hasType(value, \"onboarded\") &&\n typeof value.address === \"string\" &&\n EVM_ADDRESS_RE.test(value.address) &&\n typeof value.chain === \"string\" &&\n // `created` is new; an older wallet sent `status` instead and always created or reused a wallet.\n (typeof value.created === \"boolean\" || value.status === \"approved\" || value.status === \"pending\")\n );\n}\n\nexport function isOnboardCancelledMessage(value: unknown): value is OnboardCancelledMessage {\n return (\n hasType(value, \"onboard-cancelled\") &&\n (value.reason === \"user\" || value.reason === \"refused\" || value.reason === \"error\")\n );\n}\n\n/** A CAIP-2 EVM chain id, for example `eip155:80002` (Polygon Amoy) or `eip155:1` (mainnet). */\nexport function isCaip2EvmChain(value: string): boolean {\n return /^eip155:\\d{1,32}$/.test(value);\n}\n\n/** The URL the partner opens. `partnerOrigin` is `window.location.origin` of the partner page. */\nexport function connectUrl(walletUrl: string, partnerOrigin: string): string {\n const url = new URL(CONNECT_PATH, walletUrl);\n url.searchParams.set(\"origin\", partnerOrigin);\n url.searchParams.set(\"v\", String(PROTOCOL_VERSION));\n return url.toString();\n}\n\n/**\n * The URL the partner opens for the onboarding wizard. `partnerOrigin` is `window.location.origin` of the\n * partner page; `chain` is the CAIP-2 chain id the new wallet should be created on; `locale` is passed as `lang`\n * when the partner wants a specific wizard language.\n */\nexport function onboardUrl(\n walletUrl: string,\n partnerOrigin: string,\n options: { chain: string; locale?: string; add?: boolean },\n): string {\n const url = new URL(ONBOARD_PATH, walletUrl);\n url.searchParams.set(\"origin\", partnerOrigin);\n url.searchParams.set(\"v\", String(PROTOCOL_VERSION));\n url.searchParams.set(\"chain\", options.chain);\n if (options.locale !== undefined) url.searchParams.set(\"lang\", options.locale);\n if (options.add) url.searchParams.set(\"add\", \"1\");\n return url.toString();\n}\n","/**\n * EIP-1193 provider for the Assetera Wallet pop-up — the opener side of the ADR-0054 D3/D4 protocol.\n *\n * The provider owns a single pop-up (`window.open(connectUrl(...), \"assetera-wallet\", ...)`) and speaks the\n * wire format defined in `./protocol`. It never touches Dynamic, React, wagmi or viem, so a partner can use it\n * on its own or through the wagmi / RainbowKit adapters in this package.\n */\nimport {\n MESSAGE_PREFIX,\n PROTOCOL_VERSION,\n RpcErrorCode,\n connectUrl,\n isEventMessage,\n isReadyMessage,\n isResponseMessage,\n isSupportedMethod,\n type DisconnectMessage,\n type EventMessage,\n type RequestMessage,\n type ResponseMessage,\n} from \"./protocol\";\n\n/** Arguments accepted by `request`, mirroring EIP-1193. */\nexport interface RequestArguments {\n method: string;\n params?: unknown[] | Record<string, unknown>;\n}\n\n/** EIP-1193 provider events emitted by the pop-up. */\nexport type ProviderEvent = \"accountsChanged\" | \"chainChanged\" | \"connect\" | \"disconnect\";\n\n/**\n * Listener shape for EIP-1193 provider events. `never[]` accepts a listener with any concrete parameter list\n * (for example wagmi's `(accounts: string[]) => void`), while internal emission stays type-safe via a cast.\n */\nexport type ProviderListener = (...args: never[]) => void;\n\n/** The EIP-1193 surface returned by {@link createAsseteraWalletProvider}. */\nexport interface AsseteraWalletProvider {\n request(args: RequestArguments): Promise<unknown>;\n on(event: ProviderEvent, listener: ProviderListener): void;\n removeListener(event: ProviderEvent, listener: ProviderListener): void;\n disconnect(): void;\n}\n\n/** Options for {@link createAsseteraWalletProvider}. */\nexport interface AsseteraWalletProviderOptions {\n /** Base URL of the wallet origin, e.g. `https://wallet.playground.assetera.com`. */\n walletUrl: string;\n /** Chain id used before the wallet reports one, and as the local `eth_chainId` fallback. */\n defaultChainId: number;\n /** `window.open` feature string. Defaults to `\"popup,width=420,height=720\"`. */\n popupFeatures?: string;\n}\n\n/**\n * EIP-1193 error carrying a JSON-RPC `code` (and optional `data`). This is what every rejected `request`\n * throws, so wagmi maps the wallet's `4001` / `4100` / `4200` / `4900` correctly.\n */\nexport class ProviderRpcError extends Error {\n readonly code: number;\n readonly data?: unknown;\n\n constructor(code: number, message: string, data?: unknown) {\n super(message);\n this.name = \"ProviderRpcError\";\n this.code = code;\n this.data = data;\n }\n}\n\nconst DEFAULT_POPUP_FEATURES = \"popup,width=420,height=720\";\nconst POPUP_NAME = \"assetera-wallet\";\nconst CLOSE_POLL_MS = 500;\n\n/** Methods that show the user a signature / transaction prompt, so the pop-up should be focused first. */\nconst SIGNING_METHODS: ReadonlySet<string> = new Set([\n \"personal_sign\",\n \"eth_signTypedData_v4\",\n \"eth_sendTransaction\",\n]);\n\ninterface PendingRequest {\n resolve: (value: unknown) => void;\n reject: (reason: unknown) => void;\n}\n\ninterface Deferred<T> {\n promise: Promise<T>;\n resolve: (value: T) => void;\n reject: (reason: unknown) => void;\n}\n\nfunction createDeferred<T>(): Deferred<T> {\n let resolve!: (value: T) => void;\n let reject!: (reason: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n // The `ready` deferred is rejected when the pop-up closes even if no request is waiting on it; mark the\n // promise as handled so that rejection is not reported as an unhandled promise rejection.\n void promise.catch(() => {});\n return { promise, resolve, reject };\n}\n\nfunction toHexChainId(chainId: number): string {\n return `0x${chainId.toString(16)}`;\n}\n\n/**\n * Create the EIP-1193 provider that talks to the Assetera Wallet pop-up.\n *\n * Call `request` from a user gesture: `eth_requestAccounts` opens the pop-up synchronously (before any\n * `await`) so the browser treats it as part of the click and does not block it.\n */\nexport function createAsseteraWalletProvider(options: AsseteraWalletProviderOptions): AsseteraWalletProvider {\n const { defaultChainId } = options;\n const walletOrigin = new URL(options.walletUrl).origin;\n const popupFeatures = options.popupFeatures ?? DEFAULT_POPUP_FEATURES;\n\n let popup: Window | null = null;\n /** Resolves when the *current* pop-up posts `ready`. Replaced when a new pop-up is opened. */\n let ready = createDeferred<void>();\n let accounts: string[] = [];\n let chainIdHex: string | null = null;\n /** Set when the wallet itself told us the session ended (as opposed to the user merely closing the tab). */\n let walletDisconnected = false;\n const pending = new Map<string, PendingRequest>();\n const listeners = new Map<ProviderEvent, Set<(...args: unknown[]) => void>>();\n let closeTimer: ReturnType<typeof setInterval> | null = null;\n\n function currentChainId(): string {\n return chainIdHex ?? toHexChainId(defaultChainId);\n }\n\n function blockedError(): ProviderRpcError {\n return new ProviderRpcError(\n RpcErrorCode.Disconnected,\n \"The Assetera Wallet pop-up was blocked by the browser. The pop-up must be opened from a user click \" +\n \"(for example a button press) and then the request retried.\",\n );\n }\n\n function disconnectedError(message = \"The Assetera Wallet pop-up was closed.\"): ProviderRpcError {\n return new ProviderRpcError(RpcErrorCode.Disconnected, message);\n }\n\n function emit(event: ProviderEvent, ...args: unknown[]): void {\n const set = listeners.get(event);\n if (!set) return;\n for (const listener of set) {\n try {\n listener(...args);\n } catch (error) {\n console.error(`[assetera-wallet] listener for \"${event}\" threw`, error);\n }\n }\n }\n\n function addListener(event: ProviderEvent, listener: ProviderListener): void {\n let set = listeners.get(event);\n if (!set) {\n set = new Set<(...args: unknown[]) => void>();\n listeners.set(event, set);\n }\n set.add(listener as (...args: unknown[]) => void);\n }\n\n function removeEventListener(event: ProviderEvent, listener: ProviderListener): void {\n listeners.get(event)?.delete(listener as (...args: unknown[]) => void);\n }\n\n function stopClosePolling(): void {\n if (closeTimer !== null) {\n clearInterval(closeTimer);\n closeTimer = null;\n }\n }\n\n function startClosePolling(): void {\n if (closeTimer !== null) return;\n closeTimer = setInterval(() => {\n if (popup?.closed) handlePopupClosed();\n }, CLOSE_POLL_MS);\n }\n\n function rejectAllPending(error: ProviderRpcError): void {\n for (const request of pending.values()) request.reject(error);\n pending.clear();\n }\n\n /**\n * The pop-up was closed by the user (or the wallet app).\n *\n * We deliberately KEEP `accounts` / `chainIdHex` cached: the dApp stays \"connected\" in React state and does\n * not flicker back to a disconnected UI. Because a pop-up cannot be reopened without a user gesture, the next\n * signing request reopens it from the caller's click. `disconnect` is only emitted when the close actually\n * interrupted work (a request was pending) or when the wallet itself announced the disconnect.\n */\n function handlePopupClosed(): void {\n const hadPending = pending.size > 0;\n stopClosePolling();\n const closedPopup = popup;\n popup = null;\n const closedReady = ready;\n ready = createDeferred<void>();\n const error = disconnectedError();\n if (closedPopup) closedReady.reject(error);\n rejectAllPending(error);\n const shouldEmit = hadPending || walletDisconnected;\n walletDisconnected = false;\n if (shouldEmit) emit(\"disconnect\", error);\n }\n\n /**\n * Open the pop-up, or focus and reuse it when it is still around. Must stay synchronous (it is called before\n * any `await` in `request`) so it runs inside the caller's user activation.\n */\n function openPopup(): Window | null {\n if (popup && !popup.closed) {\n popup.focus();\n return popup;\n }\n if (typeof window === \"undefined\") return null;\n const opened = window.open(\n connectUrl(options.walletUrl, window.location.origin),\n POPUP_NAME,\n popupFeatures,\n );\n if (!opened) return null;\n popup = opened;\n ready = createDeferred<void>();\n walletDisconnected = false;\n startClosePolling();\n return opened;\n }\n\n function sendRequest(method: string, params?: RequestArguments[\"params\"]): Promise<unknown> {\n const active = popup;\n if (!active || active.closed) return Promise.reject(disconnectedError());\n const id = crypto.randomUUID();\n const message: RequestMessage = {\n type: `${MESSAGE_PREFIX}request`,\n v: PROTOCOL_VERSION,\n id,\n method,\n ...(params === undefined ? {} : { params }),\n };\n return new Promise<unknown>((resolve, reject) => {\n pending.set(id, { resolve, reject });\n active.postMessage(message, walletOrigin);\n });\n }\n\n function handleResponse(message: ResponseMessage): void {\n const request = pending.get(message.id);\n if (!request) return;\n pending.delete(message.id);\n if (\"error\" in message) {\n request.reject(new ProviderRpcError(message.error.code, message.error.message, message.error.data));\n } else {\n request.resolve(message.result);\n }\n }\n\n function handleEventMessage(message: EventMessage): void {\n if (message.event === \"accountsChanged\") {\n accounts = [...message.data];\n emit(\"accountsChanged\", [...accounts]);\n return;\n }\n if (message.event === \"chainChanged\") {\n chainIdHex = message.data;\n emit(\"chainChanged\", chainIdHex);\n return;\n }\n walletDisconnected = true;\n emit(\"disconnect\", new ProviderRpcError(message.data.code, message.data.message, message.data.data));\n }\n\n function onWindowMessage(event: MessageEvent): void {\n if (event.origin !== walletOrigin) return;\n if (popup === null || (event.source as unknown) !== popup) return;\n const data: unknown = event.data;\n if (isReadyMessage(data)) {\n ready.resolve(undefined);\n return;\n }\n if (isResponseMessage(data)) {\n handleResponse(data);\n return;\n }\n if (isEventMessage(data)) handleEventMessage(data);\n }\n\n if (typeof window !== \"undefined\") window.addEventListener(\"message\", onWindowMessage);\n\n function request({ method, params }: RequestArguments): Promise<unknown> {\n if (typeof window === \"undefined\") {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.Disconnected,\n \"The Assetera Wallet provider can only run in a browser.\",\n ),\n );\n }\n // Read-only chain calls go through wagmi's own transports; the pop-up refuses everything else.\n if (!isSupportedMethod(method)) {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.UnsupportedMethod,\n `The Assetera Wallet pop-up does not support the method \"${method}\".`,\n ),\n );\n }\n // Answered locally, without a pop-up, so wagmi can read the connection before the user clicks.\n if (method === \"eth_accounts\") return Promise.resolve([...accounts]);\n if (method === \"eth_chainId\") return Promise.resolve(currentChainId());\n\n // Opening the pop-up MUST happen synchronously, before the first `await`, to stay in the click.\n if (method === \"eth_requestAccounts\") {\n const active = openPopup();\n if (!active) return Promise.reject(blockedError());\n return ready.promise\n .then(() => sendRequest(\"eth_requestAccounts\", params))\n .then((result) => {\n accounts = Array.isArray(result) ? (result as string[]) : [];\n emit(\"accountsChanged\", [...accounts]);\n emit(\"connect\", { chainId: currentChainId() });\n return [...accounts];\n });\n }\n\n // Every other supported method needs an approved connection.\n if (accounts.length === 0) {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.Unauthorized,\n \"Connect to the Assetera Wallet first (eth_requestAccounts).\",\n ),\n );\n }\n const active = openPopup();\n if (!active) return Promise.reject(blockedError());\n if (SIGNING_METHODS.has(method)) active.focus();\n return ready.promise.then(() => sendRequest(method, params));\n }\n\n function disconnect(): void {\n const active = popup;\n if (active && !active.closed) {\n const message: DisconnectMessage = {\n type: `${MESSAGE_PREFIX}disconnect`,\n v: PROTOCOL_VERSION,\n };\n active.postMessage(message, walletOrigin);\n active.close();\n }\n stopClosePolling();\n popup = null;\n const closedReady = ready;\n ready = createDeferred<void>();\n closedReady.reject(disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n rejectAllPending(disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n accounts = [];\n chainIdHex = null;\n walletDisconnected = false;\n emit(\"disconnect\", disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n }\n\n function on(event: ProviderEvent, listener: ProviderListener): void {\n addListener(event, listener);\n }\n\n function removeListener(event: ProviderEvent, listener: ProviderListener): void {\n removeEventListener(event, listener);\n }\n\n return { request, on, removeListener, disconnect };\n}\n","/**\n * wagmi v2 connector for the Assetera Wallet pop-up (ADR-0054 D3).\n *\n * Built with `createConnector` from `@wagmi/core`, following the structure of wagmi's own `injected` connector.\n * `@wagmi/core`, `viem` and wagmi are peer dependencies so a partner app keeps a single copy of them on the\n * page. The connector is intentionally thin: all protocol work lives in {@link createAsseteraWalletProvider}.\n */\nimport { ChainNotConfiguredError, createConnector, type Connector } from \"@wagmi/core\";\nimport { getAddress, numberToHex, UserRejectedRequestError } from \"viem\";\nimport { ASSETERA_WALLET_ICON } from \"./icon\";\nimport { createAsseteraWalletProvider, type AsseteraWalletProvider } from \"./provider\";\n\n/** Stable connector id, used by wagmi for storage keys and RainbowKit for the wallet entry. */\nexport const ASSETERA_WALLET_ID = \"assetera-wallet\";\n/** Product name, exactly \"Assetera Wallet\". */\nexport const ASSETERA_WALLET_NAME = \"Assetera Wallet\";\n/** Connector `type` reported to wagmi. */\nexport const ASSETERA_WALLET_TYPE = \"asseteraWallet\";\n\n/** Parameters accepted by {@link asseteraWallet}. */\nexport interface AsseteraWalletParameters {\n /** Base URL of the wallet origin, e.g. `https://wallet.playground.assetera.com`. */\n walletUrl: string;\n}\n\n/**\n * Create the wagmi connector for the Assetera Wallet pop-up.\n *\n * `connect()` must be called from a user click: `eth_requestAccounts` opens the pop-up, and a pop-up cannot be\n * opened without transient user activation.\n */\nexport function asseteraWallet(parameters: AsseteraWalletParameters) {\n type Provider = AsseteraWalletProvider;\n\n let provider: Provider | undefined;\n let accountsChanged: Connector[\"onAccountsChanged\"] | undefined;\n let chainChanged: Connector[\"onChainChanged\"] | undefined;\n let disconnectHandler: Connector[\"onDisconnect\"] | undefined;\n\n function removeProviderListeners(activeProvider: Provider): void {\n if (accountsChanged) {\n activeProvider.removeListener(\"accountsChanged\", accountsChanged);\n accountsChanged = undefined;\n }\n if (chainChanged) {\n activeProvider.removeListener(\"chainChanged\", chainChanged);\n chainChanged = undefined;\n }\n if (disconnectHandler) {\n activeProvider.removeListener(\"disconnect\", disconnectHandler);\n disconnectHandler = undefined;\n }\n }\n\n return createConnector<Provider>((config) => ({\n id: ASSETERA_WALLET_ID,\n name: ASSETERA_WALLET_NAME,\n type: ASSETERA_WALLET_TYPE,\n icon: ASSETERA_WALLET_ICON,\n\n async connect({ chainId, withCapabilities } = {}) {\n const activeProvider = await this.getProvider();\n const requested = (await activeProvider.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n const addresses = requested.map((account) => getAddress(account));\n\n // Forward the pop-up's own events into wagmi's emitter.\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this);\n activeProvider.on(\"accountsChanged\", accountsChanged);\n }\n if (!chainChanged) {\n chainChanged = this.onChainChanged.bind(this);\n activeProvider.on(\"chainChanged\", chainChanged);\n }\n if (!disconnectHandler) {\n disconnectHandler = this.onDisconnect.bind(this);\n activeProvider.on(\"disconnect\", disconnectHandler);\n }\n\n // Switch to the requested chain when the caller asked for one.\n let currentChainId = await this.getChainId();\n if (chainId && currentChainId !== chainId) {\n const chain = await this.switchChain!({ chainId }).catch((error) => {\n if (error?.code === UserRejectedRequestError.code) throw error;\n return { id: currentChainId };\n });\n currentChainId = chain?.id ?? currentChainId;\n }\n\n return {\n accounts: (withCapabilities\n ? addresses.map((address) => ({ address, capabilities: {} }))\n : addresses) as never,\n chainId: currentChainId,\n };\n },\n\n async disconnect() {\n if (!provider) return;\n removeProviderListeners(provider);\n provider.disconnect();\n },\n\n async getAccounts() {\n const activeProvider = await this.getProvider();\n const requested = (await activeProvider.request({ method: \"eth_accounts\" })) as string[];\n return requested.map((account) => getAddress(account));\n },\n\n async getChainId() {\n const activeProvider = await this.getProvider();\n return Number(await activeProvider.request({ method: \"eth_chainId\" }));\n },\n\n async getProvider() {\n // One provider per connector, created lazily so a partner that never connects pays nothing.\n if (!provider) {\n provider = createAsseteraWalletProvider({\n walletUrl: parameters.walletUrl,\n defaultChainId: config.chains[0].id,\n });\n }\n return provider;\n },\n\n /**\n * Always `false`: opening the pop-up requires a user click, so there is nothing to reconnect to on page\n * load. Returning `true` would make wagmi attempt an automatic reconnect that the browser blocks; the\n * partner app must drive `connect()` from a click instead.\n */\n async isAuthorized() {\n return false;\n },\n\n async switchChain({ chainId }) {\n const chain = config.chains.find((candidate) => candidate.id === chainId);\n if (!chain) throw new ChainNotConfiguredError();\n const activeProvider = await this.getProvider();\n await activeProvider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n this.onChainChanged(numberToHex(chainId));\n return chain;\n },\n\n onAccountsChanged(accounts) {\n if (accounts.length === 0) this.onDisconnect();\n else\n config.emitter.emit(\"change\", {\n accounts: accounts.map((account) => getAddress(account)),\n });\n },\n\n onChainChanged(chain) {\n config.emitter.emit(\"change\", { chainId: Number(chain) });\n },\n\n onDisconnect() {\n config.emitter.emit(\"disconnect\");\n if (provider) removeProviderListeners(provider);\n },\n }));\n}\n","/**\n * RainbowKit wallet entry for the Assetera Wallet pop-up (ADR-0054 D3).\n *\n * RainbowKit 2.2 custom wallets wrap a wagmi connector with their own `rkDetails`; this mirrors RainbowKit's\n * built-in wallets (see the \"Creating a custom wallet\" guide). Use it through `connectorsForWallets`:\n *\n * ```ts\n * connectorsForWallets(\n * [{ groupName: \"Assetera\", wallets: [asseteraRainbowWallet({ walletUrl: \"https://wallet…\" })] }],\n * { appName, projectId },\n * );\n * ```\n */\nimport type { Wallet } from \"@rainbow-me/rainbowkit\";\nimport { createConnector } from \"@wagmi/core\";\nimport { ASSETERA_WALLET_ICON } from \"./icon\";\nimport { ASSETERA_WALLET_ID, ASSETERA_WALLET_NAME, asseteraWallet } from \"./wagmi\";\n\n/** Options accepted by {@link asseteraRainbowWallet}. */\nexport interface AsseteraRainbowWalletOptions {\n /** Base URL of the wallet origin, e.g. `https://wallet.playground.assetera.com`. */\n walletUrl: string;\n}\n\n/**\n * Create the RainbowKit wallet entry for the Assetera Wallet pop-up.\n *\n * Returns a FUNCTION that returns the {@link Wallet}, not the wallet itself: `connectorsForWallets` expects its\n * `wallets` list to hold `CreateWalletFn`s (like `metaMaskWallet`) and calls each one with its own options.\n */\nexport function asseteraRainbowWallet(options: AsseteraRainbowWalletOptions): () => Wallet {\n return () => ({\n id: ASSETERA_WALLET_ID,\n name: ASSETERA_WALLET_NAME,\n iconUrl: ASSETERA_WALLET_ICON,\n iconBackground: \"#1a1a2e\",\n installed: true,\n createConnector: (walletDetails) =>\n createConnector((config) => ({\n ...asseteraWallet({ walletUrl: options.walletUrl })(config),\n ...walletDetails,\n })),\n });\n}\n"]}
|
package/dist/rainbowkit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ASSETERA_WALLET_ICON, ASSETERA_WALLET_NAME, ASSETERA_WALLET_ID, asseteraWallet } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
import { ASSETERA_WALLET_ICON, ASSETERA_WALLET_NAME, ASSETERA_WALLET_ID, asseteraWallet } from './chunk-ILCYZXH2.js';
|
|
2
|
+
import './chunk-PD2FAZ7O.js';
|
|
3
|
+
import './chunk-SU2ZKBZD.js';
|
|
4
4
|
import { createConnector } from '@wagmi/core';
|
|
5
5
|
|
|
6
6
|
function asseteraRainbowWallet(options) {
|
package/dist/wagmi.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/icon.ts","../src/protocol.ts","../src/provider.ts","../src/wagmi.ts"],"names":["request","active","createConnector","getAddress","UserRejectedRequestError","Ch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MAAA,CAAO,OAAA,CAAQ,KAAK,YAAY,CAAA;AAChC,MAAA,IAAI,QAAA,0BAAkC,QAAQ,CAAA;AAAA,IAChD;AAAA,GACF,CAAE,CAAA;AACJ","file":"wagmi.cjs","sourcesContent":["/**\n * The wallet's mark as an inline data-URI, shared by the wagmi connector's `icon` and RainbowKit's `iconUrl`.\n *\n * It is intentionally tiny and dependency-free: a rounded dark square with a stylised \"A\". Keeping it as a\n * data URI means a partner app renders the wallet entry before its own bundle loads the wallet origin.\n */\nconst ICON_SVG =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"128\" height=\"128\" viewBox=\"0 0 128 128\" fill=\"none\">' +\n '<rect width=\"128\" height=\"128\" rx=\"28\" fill=\"#1a1a2e\"/>' +\n '<path fill=\"#ffffff\" fill-rule=\"evenodd\" d=\"M64 24 100 104H80.5L73.6 86H54.4L47.5 104H28L64 24Z' +\n 'm-4.5 44.5h9L64 54.4 59.5 68.5Z\"/>' +\n \"</svg>\";\n\n/** `data:image/svg+xml,...` representation of the Assetera Wallet mark. */\nexport const ASSETERA_WALLET_ICON = `data:image/svg+xml,${encodeURIComponent(ICON_SVG)}`;\n","/**\n * The pop-up protocol between a partner page (the opener) and the Assetera Wallet (the pop-up) — ADR-0054 D3/D4.\n *\n * This file is the CONTRACT. The connector in this package speaks the opener side; AsseteraWalletFront's\n * `/connect` page speaks the pop-up side and imports these types from `@asseteragmbh/wallet-connector/protocol`.\n * Change it only in a backwards-compatible way, or bump `PROTOCOL_VERSION` and support both on the wallet side:\n * partner sites upgrade on their own schedule.\n *\n * ## The handshake\n *\n * 1. The partner opens `${walletUrl}${CONNECT_PATH}?origin=<partner origin>&v=<version>` from a user click.\n * 2. The pop-up checks the claimed origin against its allowlist (D4). If listed, it posts `ready` to\n * `window.opener` with `targetOrigin` = that origin. The browser delivers it ONLY if the opener really is\n * that origin, so a page cannot claim someone else's origin and still hear the answer.\n * 3. The opener waits for `ready` from the wallet origin, then sends `request`s with `targetOrigin` = the wallet\n * origin. The pop-up accepts a message only when `event.origin` is the allowed origin from step 2 AND\n * `event.source === window.opener`, and answers with `targetOrigin` = that origin. Nothing else is accepted.\n *\n * ## Lifetime\n *\n * The pop-up stays open while the partner uses the wallet (ADR-0054, \"the wallet tab must stay open\"). When it is\n * closed, the opener sees `disconnect` (or notices `popup.closed`) and must reconnect from a user click.\n */\n\nexport const PROTOCOL_VERSION = 1 as const;\n\n/** The pop-up route on the wallet origin. */\nexport const CONNECT_PATH = \"/connect\";\n\n/** Every message carries this prefix in `type`, so both sides can ignore unrelated `postMessage` traffic. */\nexport const MESSAGE_PREFIX = \"assetera-wallet:\" as const;\n\n/**\n * The EIP-1193 methods the pop-up answers (ADR-0054 D3). Anything else is refused with 4200. Read-only chain\n * calls (`eth_call`, `eth_getBalance`, …) do not go through the pop-up; wagmi sends them to its own transports.\n */\nexport const SUPPORTED_METHODS = [\n \"eth_requestAccounts\",\n \"eth_accounts\",\n \"eth_chainId\",\n \"wallet_switchEthereumChain\",\n \"personal_sign\",\n \"eth_signTypedData_v4\",\n \"eth_sendTransaction\",\n] as const;\n\nexport type SupportedMethod = (typeof SUPPORTED_METHODS)[number];\n\nexport function isSupportedMethod(method: string): method is SupportedMethod {\n return (SUPPORTED_METHODS as readonly string[]).includes(method);\n}\n\n/** EIP-1193 / EIP-1474 error codes the pop-up uses. */\nexport const RpcErrorCode = {\n /** The client rejected the request in the pop-up. */\n UserRejected: 4001,\n /** Not connected yet (no `eth_requestAccounts` approved in this pop-up). */\n Unauthorized: 4100,\n /** The method is not in SUPPORTED_METHODS. */\n UnsupportedMethod: 4200,\n /** The pop-up closed, or the wallet session ended. */\n Disconnected: 4900,\n /** `wallet_switchEthereumChain` to a chain the wallet does not offer. */\n UnrecognizedChain: 4902,\n /** Malformed params. */\n InvalidParams: -32602,\n /** Anything unexpected inside the wallet. */\n Internal: -32603,\n} as const;\n\nexport type RpcErrorCode = (typeof RpcErrorCode)[keyof typeof RpcErrorCode];\n\nexport interface RpcError {\n code: number;\n message: string;\n data?: unknown;\n}\n\n// --- pop-up → opener ---------------------------------------------------------------------------------\n\n/** The pop-up is loaded and accepts requests from this opener. */\nexport interface ReadyMessage {\n type: `${typeof MESSAGE_PREFIX}ready`;\n v: typeof PROTOCOL_VERSION;\n /** Shown to the partner for diagnostics only; the partner must not rely on it for anything. */\n walletVersion?: string;\n}\n\n/** The answer to one `request`, matched by `id`. Exactly one of `result` / `error`. */\nexport type ResponseMessage =\n | { type: `${typeof MESSAGE_PREFIX}response`; v: typeof PROTOCOL_VERSION; id: string; result: unknown }\n | { type: `${typeof MESSAGE_PREFIX}response`; v: typeof PROTOCOL_VERSION; id: string; error: RpcError };\n\n/** EIP-1193 provider events, forwarded to the partner. */\nexport type EventMessage =\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"accountsChanged\";\n data: `0x${string}`[];\n }\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"chainChanged\";\n data: `0x${string}`;\n }\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"disconnect\";\n data: RpcError;\n };\n\nexport type WalletToPartnerMessage = ReadyMessage | ResponseMessage | EventMessage;\n\n// --- opener → pop-up ---------------------------------------------------------------------------------\n\nexport interface RequestMessage {\n type: `${typeof MESSAGE_PREFIX}request`;\n v: typeof PROTOCOL_VERSION;\n /** Unique per request within one connection; the response carries it back. */\n id: string;\n method: string;\n params?: unknown[] | Record<string, unknown>;\n}\n\n/** The partner disconnects (for example the user clicked \"Disconnect\" in the partner page). */\nexport interface DisconnectMessage {\n type: `${typeof MESSAGE_PREFIX}disconnect`;\n v: typeof PROTOCOL_VERSION;\n}\n\nexport type PartnerToWalletMessage = RequestMessage | DisconnectMessage;\n\n// --- guards ------------------------------------------------------------------------------------------\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction hasType(value: unknown, suffix: string): value is Record<string, unknown> {\n return isRecord(value) && value.type === `${MESSAGE_PREFIX}${suffix}` && value.v === PROTOCOL_VERSION;\n}\n\nexport function isReadyMessage(value: unknown): value is ReadyMessage {\n return hasType(value, \"ready\");\n}\n\nexport function isResponseMessage(value: unknown): value is ResponseMessage {\n return (\n hasType(value, \"response\") &&\n typeof value.id === \"string\" &&\n (\"result\" in value || (isRecord(value.error) && typeof value.error.code === \"number\"))\n );\n}\n\nexport function isEventMessage(value: unknown): value is EventMessage {\n return (\n hasType(value, \"event\") &&\n (value.event === \"accountsChanged\" || value.event === \"chainChanged\" || value.event === \"disconnect\")\n );\n}\n\nexport function isRequestMessage(value: unknown): value is RequestMessage {\n return hasType(value, \"request\") && typeof value.id === \"string\" && typeof value.method === \"string\";\n}\n\nexport function isDisconnectMessage(value: unknown): value is DisconnectMessage {\n return hasType(value, \"disconnect\");\n}\n\n/** The URL the partner opens. `partnerOrigin` is `window.location.origin` of the partner page. */\nexport function connectUrl(walletUrl: string, partnerOrigin: string): string {\n const url = new URL(CONNECT_PATH, walletUrl);\n url.searchParams.set(\"origin\", partnerOrigin);\n url.searchParams.set(\"v\", String(PROTOCOL_VERSION));\n return url.toString();\n}\n","/**\n * EIP-1193 provider for the Assetera Wallet pop-up — the opener side of the ADR-0054 D3/D4 protocol.\n *\n * The provider owns a single pop-up (`window.open(connectUrl(...), \"assetera-wallet\", ...)`) and speaks the\n * wire format defined in `./protocol`. It never touches Dynamic, React, wagmi or viem, so a partner can use it\n * on its own or through the wagmi / RainbowKit adapters in this package.\n */\nimport {\n MESSAGE_PREFIX,\n PROTOCOL_VERSION,\n RpcErrorCode,\n connectUrl,\n isEventMessage,\n isReadyMessage,\n isResponseMessage,\n isSupportedMethod,\n type DisconnectMessage,\n type EventMessage,\n type RequestMessage,\n type ResponseMessage,\n} from \"./protocol\";\n\n/** Arguments accepted by `request`, mirroring EIP-1193. */\nexport interface RequestArguments {\n method: string;\n params?: unknown[] | Record<string, unknown>;\n}\n\n/** EIP-1193 provider events emitted by the pop-up. */\nexport type ProviderEvent = \"accountsChanged\" | \"chainChanged\" | \"connect\" | \"disconnect\";\n\n/**\n * Listener shape for EIP-1193 provider events. `never[]` accepts a listener with any concrete parameter list\n * (for example wagmi's `(accounts: string[]) => void`), while internal emission stays type-safe via a cast.\n */\nexport type ProviderListener = (...args: never[]) => void;\n\n/** The EIP-1193 surface returned by {@link createAsseteraWalletProvider}. */\nexport interface AsseteraWalletProvider {\n request(args: RequestArguments): Promise<unknown>;\n on(event: ProviderEvent, listener: ProviderListener): void;\n removeListener(event: ProviderEvent, listener: ProviderListener): void;\n disconnect(): void;\n}\n\n/** Options for {@link createAsseteraWalletProvider}. */\nexport interface AsseteraWalletProviderOptions {\n /** Base URL of the wallet origin, e.g. `https://wallet.playground.assetera.com`. */\n walletUrl: string;\n /** Chain id used before the wallet reports one, and as the local `eth_chainId` fallback. */\n defaultChainId: number;\n /** `window.open` feature string. Defaults to `\"popup,width=420,height=720\"`. */\n popupFeatures?: string;\n}\n\n/**\n * EIP-1193 error carrying a JSON-RPC `code` (and optional `data`). This is what every rejected `request`\n * throws, so wagmi maps the wallet's `4001` / `4100` / `4200` / `4900` correctly.\n */\nexport class ProviderRpcError extends Error {\n readonly code: number;\n readonly data?: unknown;\n\n constructor(code: number, message: string, data?: unknown) {\n super(message);\n this.name = \"ProviderRpcError\";\n this.code = code;\n this.data = data;\n }\n}\n\nconst DEFAULT_POPUP_FEATURES = \"popup,width=420,height=720\";\nconst POPUP_NAME = \"assetera-wallet\";\nconst CLOSE_POLL_MS = 500;\n\n/** Methods that show the user a signature / transaction prompt, so the pop-up should be focused first. */\nconst SIGNING_METHODS: ReadonlySet<string> = new Set([\n \"personal_sign\",\n \"eth_signTypedData_v4\",\n \"eth_sendTransaction\",\n]);\n\ninterface PendingRequest {\n resolve: (value: unknown) => void;\n reject: (reason: unknown) => void;\n}\n\ninterface Deferred<T> {\n promise: Promise<T>;\n resolve: (value: T) => void;\n reject: (reason: unknown) => void;\n}\n\nfunction createDeferred<T>(): Deferred<T> {\n let resolve!: (value: T) => void;\n let reject!: (reason: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n // The `ready` deferred is rejected when the pop-up closes even if no request is waiting on it; mark the\n // promise as handled so that rejection is not reported as an unhandled promise rejection.\n void promise.catch(() => {});\n return { promise, resolve, reject };\n}\n\nfunction toHexChainId(chainId: number): string {\n return `0x${chainId.toString(16)}`;\n}\n\n/**\n * Create the EIP-1193 provider that talks to the Assetera Wallet pop-up.\n *\n * Call `request` from a user gesture: `eth_requestAccounts` opens the pop-up synchronously (before any\n * `await`) so the browser treats it as part of the click and does not block it.\n */\nexport function createAsseteraWalletProvider(options: AsseteraWalletProviderOptions): AsseteraWalletProvider {\n const { defaultChainId } = options;\n const walletOrigin = new URL(options.walletUrl).origin;\n const popupFeatures = options.popupFeatures ?? DEFAULT_POPUP_FEATURES;\n\n let popup: Window | null = null;\n /** Resolves when the *current* pop-up posts `ready`. Replaced when a new pop-up is opened. */\n let ready = createDeferred<void>();\n let accounts: string[] = [];\n let chainIdHex: string | null = null;\n /** Set when the wallet itself told us the session ended (as opposed to the user merely closing the tab). */\n let walletDisconnected = false;\n const pending = new Map<string, PendingRequest>();\n const listeners = new Map<ProviderEvent, Set<(...args: unknown[]) => void>>();\n let closeTimer: ReturnType<typeof setInterval> | null = null;\n\n function currentChainId(): string {\n return chainIdHex ?? toHexChainId(defaultChainId);\n }\n\n function blockedError(): ProviderRpcError {\n return new ProviderRpcError(\n RpcErrorCode.Disconnected,\n \"The Assetera Wallet pop-up was blocked by the browser. The pop-up must be opened from a user click \" +\n \"(for example a button press) and then the request retried.\",\n );\n }\n\n function disconnectedError(message = \"The Assetera Wallet pop-up was closed.\"): ProviderRpcError {\n return new ProviderRpcError(RpcErrorCode.Disconnected, message);\n }\n\n function emit(event: ProviderEvent, ...args: unknown[]): void {\n const set = listeners.get(event);\n if (!set) return;\n for (const listener of set) {\n try {\n listener(...args);\n } catch (error) {\n console.error(`[assetera-wallet] listener for \"${event}\" threw`, error);\n }\n }\n }\n\n function addListener(event: ProviderEvent, listener: ProviderListener): void {\n let set = listeners.get(event);\n if (!set) {\n set = new Set<(...args: unknown[]) => void>();\n listeners.set(event, set);\n }\n set.add(listener as (...args: unknown[]) => void);\n }\n\n function removeEventListener(event: ProviderEvent, listener: ProviderListener): void {\n listeners.get(event)?.delete(listener as (...args: unknown[]) => void);\n }\n\n function stopClosePolling(): void {\n if (closeTimer !== null) {\n clearInterval(closeTimer);\n closeTimer = null;\n }\n }\n\n function startClosePolling(): void {\n if (closeTimer !== null) return;\n closeTimer = setInterval(() => {\n if (popup?.closed) handlePopupClosed();\n }, CLOSE_POLL_MS);\n }\n\n function rejectAllPending(error: ProviderRpcError): void {\n for (const request of pending.values()) request.reject(error);\n pending.clear();\n }\n\n /**\n * The pop-up was closed by the user (or the wallet app).\n *\n * We deliberately KEEP `accounts` / `chainIdHex` cached: the dApp stays \"connected\" in React state and does\n * not flicker back to a disconnected UI. Because a pop-up cannot be reopened without a user gesture, the next\n * signing request reopens it from the caller's click. `disconnect` is only emitted when the close actually\n * interrupted work (a request was pending) or when the wallet itself announced the disconnect.\n */\n function handlePopupClosed(): void {\n const hadPending = pending.size > 0;\n stopClosePolling();\n const closedPopup = popup;\n popup = null;\n const closedReady = ready;\n ready = createDeferred<void>();\n const error = disconnectedError();\n if (closedPopup) closedReady.reject(error);\n rejectAllPending(error);\n const shouldEmit = hadPending || walletDisconnected;\n walletDisconnected = false;\n if (shouldEmit) emit(\"disconnect\", error);\n }\n\n /**\n * Open the pop-up, or focus and reuse it when it is still around. Must stay synchronous (it is called before\n * any `await` in `request`) so it runs inside the caller's user activation.\n */\n function openPopup(): Window | null {\n if (popup && !popup.closed) {\n popup.focus();\n return popup;\n }\n if (typeof window === \"undefined\") return null;\n const opened = window.open(\n connectUrl(options.walletUrl, window.location.origin),\n POPUP_NAME,\n popupFeatures,\n );\n if (!opened) return null;\n popup = opened;\n ready = createDeferred<void>();\n walletDisconnected = false;\n startClosePolling();\n return opened;\n }\n\n function sendRequest(method: string, params?: RequestArguments[\"params\"]): Promise<unknown> {\n const active = popup;\n if (!active || active.closed) return Promise.reject(disconnectedError());\n const id = crypto.randomUUID();\n const message: RequestMessage = {\n type: `${MESSAGE_PREFIX}request`,\n v: PROTOCOL_VERSION,\n id,\n method,\n ...(params === undefined ? {} : { params }),\n };\n return new Promise<unknown>((resolve, reject) => {\n pending.set(id, { resolve, reject });\n active.postMessage(message, walletOrigin);\n });\n }\n\n function handleResponse(message: ResponseMessage): void {\n const request = pending.get(message.id);\n if (!request) return;\n pending.delete(message.id);\n if (\"error\" in message) {\n request.reject(new ProviderRpcError(message.error.code, message.error.message, message.error.data));\n } else {\n request.resolve(message.result);\n }\n }\n\n function handleEventMessage(message: EventMessage): void {\n if (message.event === \"accountsChanged\") {\n accounts = [...message.data];\n emit(\"accountsChanged\", [...accounts]);\n return;\n }\n if (message.event === \"chainChanged\") {\n chainIdHex = message.data;\n emit(\"chainChanged\", chainIdHex);\n return;\n }\n walletDisconnected = true;\n emit(\"disconnect\", new ProviderRpcError(message.data.code, message.data.message, message.data.data));\n }\n\n function onWindowMessage(event: MessageEvent): void {\n if (event.origin !== walletOrigin) return;\n if (popup === null || (event.source as unknown) !== popup) return;\n const data: unknown = event.data;\n if (isReadyMessage(data)) {\n ready.resolve(undefined);\n return;\n }\n if (isResponseMessage(data)) {\n handleResponse(data);\n return;\n }\n if (isEventMessage(data)) handleEventMessage(data);\n }\n\n if (typeof window !== \"undefined\") window.addEventListener(\"message\", onWindowMessage);\n\n function request({ method, params }: RequestArguments): Promise<unknown> {\n if (typeof window === \"undefined\") {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.Disconnected,\n \"The Assetera Wallet provider can only run in a browser.\",\n ),\n );\n }\n // Read-only chain calls go through wagmi's own transports; the pop-up refuses everything else.\n if (!isSupportedMethod(method)) {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.UnsupportedMethod,\n `The Assetera Wallet pop-up does not support the method \"${method}\".`,\n ),\n );\n }\n // Answered locally, without a pop-up, so wagmi can read the connection before the user clicks.\n if (method === \"eth_accounts\") return Promise.resolve([...accounts]);\n if (method === \"eth_chainId\") return Promise.resolve(currentChainId());\n\n // Opening the pop-up MUST happen synchronously, before the first `await`, to stay in the click.\n if (method === \"eth_requestAccounts\") {\n const active = openPopup();\n if (!active) return Promise.reject(blockedError());\n return ready.promise\n .then(() => sendRequest(\"eth_requestAccounts\", params))\n .then((result) => {\n accounts = Array.isArray(result) ? (result as string[]) : [];\n emit(\"accountsChanged\", [...accounts]);\n emit(\"connect\", { chainId: currentChainId() });\n return [...accounts];\n });\n }\n\n // Every other supported method needs an approved connection.\n if (accounts.length === 0) {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.Unauthorized,\n \"Connect to the Assetera Wallet first (eth_requestAccounts).\",\n ),\n );\n }\n const active = openPopup();\n if (!active) return Promise.reject(blockedError());\n if (SIGNING_METHODS.has(method)) active.focus();\n return ready.promise.then(() => sendRequest(method, params));\n }\n\n function disconnect(): void {\n const active = popup;\n if (active && !active.closed) {\n const message: DisconnectMessage = {\n type: `${MESSAGE_PREFIX}disconnect`,\n v: PROTOCOL_VERSION,\n };\n active.postMessage(message, walletOrigin);\n active.close();\n }\n stopClosePolling();\n popup = null;\n const closedReady = ready;\n ready = createDeferred<void>();\n closedReady.reject(disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n rejectAllPending(disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n accounts = [];\n chainIdHex = null;\n walletDisconnected = false;\n emit(\"disconnect\", disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n }\n\n function on(event: ProviderEvent, listener: ProviderListener): void {\n addListener(event, listener);\n }\n\n function removeListener(event: ProviderEvent, listener: ProviderListener): void {\n removeEventListener(event, listener);\n }\n\n return { request, on, removeListener, disconnect };\n}\n","/**\n * wagmi v2 connector for the Assetera Wallet pop-up (ADR-0054 D3).\n *\n * Built with `createConnector` from `@wagmi/core`, following the structure of wagmi's own `injected` connector.\n * `@wagmi/core`, `viem` and wagmi are peer dependencies so a partner app keeps a single copy of them on the\n * page. The connector is intentionally thin: all protocol work lives in {@link createAsseteraWalletProvider}.\n */\nimport { ChainNotConfiguredError, createConnector, type Connector } from \"@wagmi/core\";\nimport { getAddress, numberToHex, UserRejectedRequestError } from \"viem\";\nimport { ASSETERA_WALLET_ICON } from \"./icon\";\nimport { createAsseteraWalletProvider, type AsseteraWalletProvider } from \"./provider\";\n\n/** Stable connector id, used by wagmi for storage keys and RainbowKit for the wallet entry. */\nexport const ASSETERA_WALLET_ID = \"assetera-wallet\";\n/** Product name, exactly \"Assetera Wallet\". */\nexport const ASSETERA_WALLET_NAME = \"Assetera Wallet\";\n/** Connector `type` reported to wagmi. */\nexport const ASSETERA_WALLET_TYPE = \"asseteraWallet\";\n\n/** Parameters accepted by {@link asseteraWallet}. */\nexport interface AsseteraWalletParameters {\n /** Base URL of the wallet origin, e.g. `https://wallet.playground.assetera.com`. */\n walletUrl: string;\n}\n\n/**\n * Create the wagmi connector for the Assetera Wallet pop-up.\n *\n * `connect()` must be called from a user click: `eth_requestAccounts` opens the pop-up, and a pop-up cannot be\n * opened without transient user activation.\n */\nexport function asseteraWallet(parameters: AsseteraWalletParameters) {\n type Provider = AsseteraWalletProvider;\n\n let provider: Provider | undefined;\n let accountsChanged: Connector[\"onAccountsChanged\"] | undefined;\n let chainChanged: Connector[\"onChainChanged\"] | undefined;\n let disconnectHandler: Connector[\"onDisconnect\"] | undefined;\n\n function removeProviderListeners(activeProvider: Provider): void {\n if (accountsChanged) {\n activeProvider.removeListener(\"accountsChanged\", accountsChanged);\n accountsChanged = undefined;\n }\n if (chainChanged) {\n activeProvider.removeListener(\"chainChanged\", chainChanged);\n chainChanged = undefined;\n }\n if (disconnectHandler) {\n activeProvider.removeListener(\"disconnect\", disconnectHandler);\n disconnectHandler = undefined;\n }\n }\n\n return createConnector<Provider>((config) => ({\n id: ASSETERA_WALLET_ID,\n name: ASSETERA_WALLET_NAME,\n type: ASSETERA_WALLET_TYPE,\n icon: ASSETERA_WALLET_ICON,\n\n async connect({ chainId, withCapabilities } = {}) {\n const activeProvider = await this.getProvider();\n const requested = (await activeProvider.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n const addresses = requested.map((account) => getAddress(account));\n\n // Forward the pop-up's own events into wagmi's emitter.\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this);\n activeProvider.on(\"accountsChanged\", accountsChanged);\n }\n if (!chainChanged) {\n chainChanged = this.onChainChanged.bind(this);\n activeProvider.on(\"chainChanged\", chainChanged);\n }\n if (!disconnectHandler) {\n disconnectHandler = this.onDisconnect.bind(this);\n activeProvider.on(\"disconnect\", disconnectHandler);\n }\n\n // Switch to the requested chain when the caller asked for one.\n let currentChainId = await this.getChainId();\n if (chainId && currentChainId !== chainId) {\n const chain = await this.switchChain!({ chainId }).catch((error) => {\n if (error?.code === UserRejectedRequestError.code) throw error;\n return { id: currentChainId };\n });\n currentChainId = chain?.id ?? currentChainId;\n }\n\n return {\n accounts: (withCapabilities\n ? addresses.map((address) => ({ address, capabilities: {} }))\n : addresses) as never,\n chainId: currentChainId,\n };\n },\n\n async disconnect() {\n if (!provider) return;\n removeProviderListeners(provider);\n provider.disconnect();\n },\n\n async getAccounts() {\n const activeProvider = await this.getProvider();\n const requested = (await activeProvider.request({ method: \"eth_accounts\" })) as string[];\n return requested.map((account) => getAddress(account));\n },\n\n async getChainId() {\n const activeProvider = await this.getProvider();\n return Number(await activeProvider.request({ method: \"eth_chainId\" }));\n },\n\n async getProvider() {\n // One provider per connector, created lazily so a partner that never connects pays nothing.\n if (!provider) {\n provider = createAsseteraWalletProvider({\n walletUrl: parameters.walletUrl,\n defaultChainId: config.chains[0].id,\n });\n }\n return provider;\n },\n\n /**\n * Always `false`: opening the pop-up requires a user click, so there is nothing to reconnect to on page\n * load. Returning `true` would make wagmi attempt an automatic reconnect that the browser blocks; the\n * partner app must drive `connect()` from a click instead.\n */\n async isAuthorized() {\n return false;\n },\n\n async switchChain({ chainId }) {\n const chain = config.chains.find((candidate) => candidate.id === chainId);\n if (!chain) throw new ChainNotConfiguredError();\n const activeProvider = await this.getProvider();\n await activeProvider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n this.onChainChanged(numberToHex(chainId));\n return chain;\n },\n\n onAccountsChanged(accounts) {\n if (accounts.length === 0) this.onDisconnect();\n else\n config.emitter.emit(\"change\", {\n accounts: accounts.map((account) => getAddress(account)),\n });\n },\n\n onChainChanged(chain) {\n config.emitter.emit(\"change\", { chainId: Number(chain) });\n },\n\n onDisconnect() {\n config.emitter.emit(\"disconnect\");\n if (provider) removeProviderListeners(provider);\n },\n }));\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/icon.ts","../src/protocol.ts","../src/provider.ts","../src/wagmi.ts"],"names":["request","active","createConnector","getAddress","UserRejectedRequestError","ChainNotConfiguredError","numberToHex"],"mappings":";;;;;;;;AAMA,IAAM,QAAA,GACJ,mSAAA;AAOK,IAAM,oBAAA,GAAuB,CAAA,mBAAA,EAAsB,kBAAA,CAAmB,QAAQ,CAAC,CAAA,CAAA;;;AC8B/E,IAAM,gBAAA,GAAmB,CAAA;AAGzB,IAAM,YAAA,GAAe,UAAA;AAMrB,IAAM,cAAA,GAAiB,kBAAA;AAMvB,IAAM,iBAAA,GAAoB;AAAA,EAC/B,qBAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,4BAAA;AAAA,EACA,eAAA;AAAA,EACA,sBAAA;AAAA,EACA;AACF,CAAA;AAIO,SAAS,kBAAkB,MAAA,EAA2C;AAC3E,EAAA,OAAQ,iBAAA,CAAwC,SAAS,MAAM,CAAA;AACjE;AAGO,IAAM,YAAA,GAAe;AAAA,EAEZ;AAAA,EAEd,YAAA,EAAc,IAAA;AAAA;AAAA,EAE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C,EAAE,SAASC,gBAAA,CAAY,OAAO,GAAG;AAAA,OAC3C,CAAA;AACD,MAAA,IAAA,CAAK,cAAA,CAAeA,gBAAA,CAAY,OAAO,CAAC,CAAA;AACxC,MAAA,OAAO,KAAA;AAAA,IACT,CAAA;AAAA,IAEA,kBAAkB,QAAA,EAAU;AAC1B,MAAA,IAAI,QAAA,CAAS,MAAA,KAAW,CAAA,EAAG,IAAA,CAAK,YAAA,EAAa;AAAA;AAE3C,QAAA,MAAA,CAAO,OAAA,CAAQ,KAAK,QAAA,EAAU;AAAA,UAC5B,UAAU,QAAA,CAAS,GAAA,CAAI,CAAC,OAAA,KAAYH,eAAA,CAAW,OAAO,CAAC;AAAA,SACxD,CAAA;AAAA,IACL,CAAA;AAAA,IAEA,eAAe,KAAA,EAAO;AACpB,MAAA,MAAA,CAAO,OAAA,CAAQ,KAAK,QAAA,EAAU,EAAE,SAAS,MAAA,CAAO,KAAK,GAAG,CAAA;AAAA,IAC1D,CAAA;AAAA,IAEA,YAAA,GAAe;AACb,MAAA,MAAA,CAAO,OAAA,CAAQ,KAAK,YAAY,CAAA;AAChC,MAAA,IAAI,QAAA,0BAAkC,QAAQ,CAAA;AAAA,IAChD;AAAA,GACF,CAAE,CAAA;AACJ","file":"wagmi.cjs","sourcesContent":["/**\n * The wallet's mark as an inline data-URI, shared by the wagmi connector's `icon` and RainbowKit's `iconUrl`.\n *\n * It is intentionally tiny and dependency-free: a rounded dark square with a stylised \"A\". Keeping it as a\n * data URI means a partner app renders the wallet entry before its own bundle loads the wallet origin.\n */\nconst ICON_SVG =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"128\" height=\"128\" viewBox=\"0 0 128 128\" fill=\"none\">' +\n '<rect width=\"128\" height=\"128\" rx=\"28\" fill=\"#1a1a2e\"/>' +\n '<path fill=\"#ffffff\" fill-rule=\"evenodd\" d=\"M64 24 100 104H80.5L73.6 86H54.4L47.5 104H28L64 24Z' +\n 'm-4.5 44.5h9L64 54.4 59.5 68.5Z\"/>' +\n \"</svg>\";\n\n/** `data:image/svg+xml,...` representation of the Assetera Wallet mark. */\nexport const ASSETERA_WALLET_ICON = `data:image/svg+xml,${encodeURIComponent(ICON_SVG)}`;\n","/**\n * The pop-up protocol between a partner page (the opener) and the Assetera Wallet (the pop-up) — ADR-0054 D3/D4.\n *\n * This file is the CONTRACT. The connector in this package speaks the opener side; AsseteraWalletFront's\n * `/connect` page speaks the pop-up side and imports these types from `@asseteragmbh/wallet-connector/protocol`.\n * Change it only in a backwards-compatible way, or bump `PROTOCOL_VERSION` and support both on the wallet side:\n * partner sites upgrade on their own schedule.\n *\n * ## The handshake\n *\n * 1. The partner opens `${walletUrl}${CONNECT_PATH}?origin=<partner origin>&v=<version>` from a user click.\n * 2. The pop-up checks the claimed origin against its allowlist (D4). If listed, it posts `ready` to\n * `window.opener` with `targetOrigin` = that origin. The browser delivers it ONLY if the opener really is\n * that origin, so a page cannot claim someone else's origin and still hear the answer.\n * 3. The opener waits for `ready` from the wallet origin, then sends `request`s with `targetOrigin` = the wallet\n * origin. The pop-up accepts a message only when `event.origin` is the allowed origin from step 2 AND\n * `event.source === window.opener`, and answers with `targetOrigin` = that origin. Nothing else is accepted.\n *\n * ## Lifetime\n *\n * The pop-up stays open while the partner uses the wallet (ADR-0054, \"the wallet tab must stay open\"). When it is\n * closed, the opener sees `disconnect` (or notices `popup.closed`) and must reconnect from a user click.\n *\n * ## Onboarding\n *\n * Onboarding is a second flow on the same wallet origin, for a partner that wants the client to get an Assetera\n * Wallet (a new one, or the one the client already has). The partner opens\n * `${walletUrl}${ONBOARD_PATH}?origin=<partner origin>&v=<version>&chain=<CAIP-2 chain id>[&add=1]` from a user\n * click. The pop-up checks the claimed origin against its partner list, signs the client in through SSO, runs the\n * wizard (accept the wallet terms, create the wallet) and then posts `onboarded` (or `onboard-cancelled`) to\n * `window.opener` with `targetOrigin` = the partner origin. `add=1` asks for one more wallet even when the client\n * already has one.\n *\n * After `onboarded` the pop-up STAYS OPEN and answers `request` messages for `personal_sign` by the onboarded\n * address (plus `eth_accounts` and `eth_chainId`), with the same `response` messages as `/connect`. That is how\n * the partner gets the ownership signature it needs to register the wallet with its own compliance service: the\n * wallet itself never calls a regulated service (ADR-0059 D3), and a second `window.open` after an asynchronous\n * step would be blocked by the browser. The partner closes the pop-up when it is done.\n *\n * The opener accepts messages only when `event.origin` is the wallet origin AND `event.source` is the pop-up\n * it opened. The wizard never returns a private key or a token, only the wallet address and signatures the\n * client approved.\n */\n\nexport const PROTOCOL_VERSION = 1 as const;\n\n/** The pop-up route on the wallet origin. */\nexport const CONNECT_PATH = \"/connect\";\n\n/** The onboarding wizard route on the wallet origin. */\nexport const ONBOARD_PATH = \"/onboard\";\n\n/** Every message carries this prefix in `type`, so both sides can ignore unrelated `postMessage` traffic. */\nexport const MESSAGE_PREFIX = \"assetera-wallet:\" as const;\n\n/**\n * The EIP-1193 methods the pop-up answers (ADR-0054 D3). Anything else is refused with 4200. Read-only chain\n * calls (`eth_call`, `eth_getBalance`, …) do not go through the pop-up; wagmi sends them to its own transports.\n */\nexport const SUPPORTED_METHODS = [\n \"eth_requestAccounts\",\n \"eth_accounts\",\n \"eth_chainId\",\n \"wallet_switchEthereumChain\",\n \"personal_sign\",\n \"eth_signTypedData_v4\",\n \"eth_sendTransaction\",\n] as const;\n\nexport type SupportedMethod = (typeof SUPPORTED_METHODS)[number];\n\nexport function isSupportedMethod(method: string): method is SupportedMethod {\n return (SUPPORTED_METHODS as readonly string[]).includes(method);\n}\n\n/** EIP-1193 / EIP-1474 error codes the pop-up uses. */\nexport const RpcErrorCode = {\n /** The client rejected the request in the pop-up. */\n UserRejected: 4001,\n /** Not connected yet (no `eth_requestAccounts` approved in this pop-up). */\n Unauthorized: 4100,\n /** The method is not in SUPPORTED_METHODS. */\n UnsupportedMethod: 4200,\n /** The pop-up closed, or the wallet session ended. */\n Disconnected: 4900,\n /** `wallet_switchEthereumChain` to a chain the wallet does not offer. */\n UnrecognizedChain: 4902,\n /** Malformed params. */\n InvalidParams: -32602,\n /** Anything unexpected inside the wallet. */\n Internal: -32603,\n} as const;\n\nexport type RpcErrorCode = (typeof RpcErrorCode)[keyof typeof RpcErrorCode];\n\nexport interface RpcError {\n code: number;\n message: string;\n data?: unknown;\n}\n\n// --- pop-up → opener ---------------------------------------------------------------------------------\n\n/** The pop-up is loaded and accepts requests from this opener. */\nexport interface ReadyMessage {\n type: `${typeof MESSAGE_PREFIX}ready`;\n v: typeof PROTOCOL_VERSION;\n /** Shown to the partner for diagnostics only; the partner must not rely on it for anything. */\n walletVersion?: string;\n}\n\n/** The answer to one `request`, matched by `id`. Exactly one of `result` / `error`. */\nexport type ResponseMessage =\n | { type: `${typeof MESSAGE_PREFIX}response`; v: typeof PROTOCOL_VERSION; id: string; result: unknown }\n | { type: `${typeof MESSAGE_PREFIX}response`; v: typeof PROTOCOL_VERSION; id: string; error: RpcError };\n\n/** EIP-1193 provider events, forwarded to the partner. */\nexport type EventMessage =\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"accountsChanged\";\n data: `0x${string}`[];\n }\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"chainChanged\";\n data: `0x${string}`;\n }\n | {\n type: `${typeof MESSAGE_PREFIX}event`;\n v: typeof PROTOCOL_VERSION;\n event: \"disconnect\";\n data: RpcError;\n };\n\n/**\n * The onboarding wizard finished: the client accepted the wallet terms and has an Assetera Wallet on `chain`.\n * `created` is `true` when the wallet was created in this run, `false` when the wizard returned the client's\n * existing wallet. The wallet is not registered with any compliance service; that is the partner's step.\n */\nexport interface OnboardedMessage {\n type: `${typeof MESSAGE_PREFIX}onboarded`;\n v: typeof PROTOCOL_VERSION;\n address: `0x${string}`;\n chain: string;\n created: boolean;\n /**\n * @deprecated Sent by wallet versions that registered the wallet themselves (before ADR-0059). Ignored.\n */\n status?: \"approved\" | \"pending\";\n}\n\n/** The onboarding wizard did not produce a wallet. `message` is optional diagnostics for the partner. */\nexport interface OnboardCancelledMessage {\n type: `${typeof MESSAGE_PREFIX}onboard-cancelled`;\n v: typeof PROTOCOL_VERSION;\n reason: \"user\" | \"refused\" | \"error\";\n message?: string;\n}\n\nexport type WalletToPartnerMessage =\n ReadyMessage | ResponseMessage | EventMessage | OnboardedMessage | OnboardCancelledMessage;\n\n// --- opener → pop-up ---------------------------------------------------------------------------------\n\nexport interface RequestMessage {\n type: `${typeof MESSAGE_PREFIX}request`;\n v: typeof PROTOCOL_VERSION;\n /** Unique per request within one connection; the response carries it back. */\n id: string;\n method: string;\n params?: unknown[] | Record<string, unknown>;\n}\n\n/** The partner disconnects (for example the user clicked \"Disconnect\" in the partner page). */\nexport interface DisconnectMessage {\n type: `${typeof MESSAGE_PREFIX}disconnect`;\n v: typeof PROTOCOL_VERSION;\n}\n\nexport type PartnerToWalletMessage = RequestMessage | DisconnectMessage;\n\n// --- guards ------------------------------------------------------------------------------------------\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction hasType(value: unknown, suffix: string): value is Record<string, unknown> {\n return isRecord(value) && value.type === `${MESSAGE_PREFIX}${suffix}` && value.v === PROTOCOL_VERSION;\n}\n\nexport function isReadyMessage(value: unknown): value is ReadyMessage {\n return hasType(value, \"ready\");\n}\n\nexport function isResponseMessage(value: unknown): value is ResponseMessage {\n return (\n hasType(value, \"response\") &&\n typeof value.id === \"string\" &&\n (\"result\" in value || (isRecord(value.error) && typeof value.error.code === \"number\"))\n );\n}\n\nexport function isEventMessage(value: unknown): value is EventMessage {\n return (\n hasType(value, \"event\") &&\n (value.event === \"accountsChanged\" || value.event === \"chainChanged\" || value.event === \"disconnect\")\n );\n}\n\nexport function isRequestMessage(value: unknown): value is RequestMessage {\n return hasType(value, \"request\") && typeof value.id === \"string\" && typeof value.method === \"string\";\n}\n\nexport function isDisconnectMessage(value: unknown): value is DisconnectMessage {\n return hasType(value, \"disconnect\");\n}\n\n/** `0x` followed by exactly 40 hexadecimal digits, the shape of an EVM address. */\nconst EVM_ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;\n\nexport function isOnboardedMessage(value: unknown): value is OnboardedMessage {\n return (\n hasType(value, \"onboarded\") &&\n typeof value.address === \"string\" &&\n EVM_ADDRESS_RE.test(value.address) &&\n typeof value.chain === \"string\" &&\n // `created` is new; an older wallet sent `status` instead and always created or reused a wallet.\n (typeof value.created === \"boolean\" || value.status === \"approved\" || value.status === \"pending\")\n );\n}\n\nexport function isOnboardCancelledMessage(value: unknown): value is OnboardCancelledMessage {\n return (\n hasType(value, \"onboard-cancelled\") &&\n (value.reason === \"user\" || value.reason === \"refused\" || value.reason === \"error\")\n );\n}\n\n/** A CAIP-2 EVM chain id, for example `eip155:80002` (Polygon Amoy) or `eip155:1` (mainnet). */\nexport function isCaip2EvmChain(value: string): boolean {\n return /^eip155:\\d{1,32}$/.test(value);\n}\n\n/** The URL the partner opens. `partnerOrigin` is `window.location.origin` of the partner page. */\nexport function connectUrl(walletUrl: string, partnerOrigin: string): string {\n const url = new URL(CONNECT_PATH, walletUrl);\n url.searchParams.set(\"origin\", partnerOrigin);\n url.searchParams.set(\"v\", String(PROTOCOL_VERSION));\n return url.toString();\n}\n\n/**\n * The URL the partner opens for the onboarding wizard. `partnerOrigin` is `window.location.origin` of the\n * partner page; `chain` is the CAIP-2 chain id the new wallet should be created on; `locale` is passed as `lang`\n * when the partner wants a specific wizard language.\n */\nexport function onboardUrl(\n walletUrl: string,\n partnerOrigin: string,\n options: { chain: string; locale?: string; add?: boolean },\n): string {\n const url = new URL(ONBOARD_PATH, walletUrl);\n url.searchParams.set(\"origin\", partnerOrigin);\n url.searchParams.set(\"v\", String(PROTOCOL_VERSION));\n url.searchParams.set(\"chain\", options.chain);\n if (options.locale !== undefined) url.searchParams.set(\"lang\", options.locale);\n if (options.add) url.searchParams.set(\"add\", \"1\");\n return url.toString();\n}\n","/**\n * EIP-1193 provider for the Assetera Wallet pop-up — the opener side of the ADR-0054 D3/D4 protocol.\n *\n * The provider owns a single pop-up (`window.open(connectUrl(...), \"assetera-wallet\", ...)`) and speaks the\n * wire format defined in `./protocol`. It never touches Dynamic, React, wagmi or viem, so a partner can use it\n * on its own or through the wagmi / RainbowKit adapters in this package.\n */\nimport {\n MESSAGE_PREFIX,\n PROTOCOL_VERSION,\n RpcErrorCode,\n connectUrl,\n isEventMessage,\n isReadyMessage,\n isResponseMessage,\n isSupportedMethod,\n type DisconnectMessage,\n type EventMessage,\n type RequestMessage,\n type ResponseMessage,\n} from \"./protocol\";\n\n/** Arguments accepted by `request`, mirroring EIP-1193. */\nexport interface RequestArguments {\n method: string;\n params?: unknown[] | Record<string, unknown>;\n}\n\n/** EIP-1193 provider events emitted by the pop-up. */\nexport type ProviderEvent = \"accountsChanged\" | \"chainChanged\" | \"connect\" | \"disconnect\";\n\n/**\n * Listener shape for EIP-1193 provider events. `never[]` accepts a listener with any concrete parameter list\n * (for example wagmi's `(accounts: string[]) => void`), while internal emission stays type-safe via a cast.\n */\nexport type ProviderListener = (...args: never[]) => void;\n\n/** The EIP-1193 surface returned by {@link createAsseteraWalletProvider}. */\nexport interface AsseteraWalletProvider {\n request(args: RequestArguments): Promise<unknown>;\n on(event: ProviderEvent, listener: ProviderListener): void;\n removeListener(event: ProviderEvent, listener: ProviderListener): void;\n disconnect(): void;\n}\n\n/** Options for {@link createAsseteraWalletProvider}. */\nexport interface AsseteraWalletProviderOptions {\n /** Base URL of the wallet origin, e.g. `https://wallet.playground.assetera.com`. */\n walletUrl: string;\n /** Chain id used before the wallet reports one, and as the local `eth_chainId` fallback. */\n defaultChainId: number;\n /** `window.open` feature string. Defaults to `\"popup,width=420,height=720\"`. */\n popupFeatures?: string;\n}\n\n/**\n * EIP-1193 error carrying a JSON-RPC `code` (and optional `data`). This is what every rejected `request`\n * throws, so wagmi maps the wallet's `4001` / `4100` / `4200` / `4900` correctly.\n */\nexport class ProviderRpcError extends Error {\n readonly code: number;\n readonly data?: unknown;\n\n constructor(code: number, message: string, data?: unknown) {\n super(message);\n this.name = \"ProviderRpcError\";\n this.code = code;\n this.data = data;\n }\n}\n\nconst DEFAULT_POPUP_FEATURES = \"popup,width=420,height=720\";\nconst POPUP_NAME = \"assetera-wallet\";\nconst CLOSE_POLL_MS = 500;\n\n/** Methods that show the user a signature / transaction prompt, so the pop-up should be focused first. */\nconst SIGNING_METHODS: ReadonlySet<string> = new Set([\n \"personal_sign\",\n \"eth_signTypedData_v4\",\n \"eth_sendTransaction\",\n]);\n\ninterface PendingRequest {\n resolve: (value: unknown) => void;\n reject: (reason: unknown) => void;\n}\n\ninterface Deferred<T> {\n promise: Promise<T>;\n resolve: (value: T) => void;\n reject: (reason: unknown) => void;\n}\n\nfunction createDeferred<T>(): Deferred<T> {\n let resolve!: (value: T) => void;\n let reject!: (reason: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n // The `ready` deferred is rejected when the pop-up closes even if no request is waiting on it; mark the\n // promise as handled so that rejection is not reported as an unhandled promise rejection.\n void promise.catch(() => {});\n return { promise, resolve, reject };\n}\n\nfunction toHexChainId(chainId: number): string {\n return `0x${chainId.toString(16)}`;\n}\n\n/**\n * Create the EIP-1193 provider that talks to the Assetera Wallet pop-up.\n *\n * Call `request` from a user gesture: `eth_requestAccounts` opens the pop-up synchronously (before any\n * `await`) so the browser treats it as part of the click and does not block it.\n */\nexport function createAsseteraWalletProvider(options: AsseteraWalletProviderOptions): AsseteraWalletProvider {\n const { defaultChainId } = options;\n const walletOrigin = new URL(options.walletUrl).origin;\n const popupFeatures = options.popupFeatures ?? DEFAULT_POPUP_FEATURES;\n\n let popup: Window | null = null;\n /** Resolves when the *current* pop-up posts `ready`. Replaced when a new pop-up is opened. */\n let ready = createDeferred<void>();\n let accounts: string[] = [];\n let chainIdHex: string | null = null;\n /** Set when the wallet itself told us the session ended (as opposed to the user merely closing the tab). */\n let walletDisconnected = false;\n const pending = new Map<string, PendingRequest>();\n const listeners = new Map<ProviderEvent, Set<(...args: unknown[]) => void>>();\n let closeTimer: ReturnType<typeof setInterval> | null = null;\n\n function currentChainId(): string {\n return chainIdHex ?? toHexChainId(defaultChainId);\n }\n\n function blockedError(): ProviderRpcError {\n return new ProviderRpcError(\n RpcErrorCode.Disconnected,\n \"The Assetera Wallet pop-up was blocked by the browser. The pop-up must be opened from a user click \" +\n \"(for example a button press) and then the request retried.\",\n );\n }\n\n function disconnectedError(message = \"The Assetera Wallet pop-up was closed.\"): ProviderRpcError {\n return new ProviderRpcError(RpcErrorCode.Disconnected, message);\n }\n\n function emit(event: ProviderEvent, ...args: unknown[]): void {\n const set = listeners.get(event);\n if (!set) return;\n for (const listener of set) {\n try {\n listener(...args);\n } catch (error) {\n console.error(`[assetera-wallet] listener for \"${event}\" threw`, error);\n }\n }\n }\n\n function addListener(event: ProviderEvent, listener: ProviderListener): void {\n let set = listeners.get(event);\n if (!set) {\n set = new Set<(...args: unknown[]) => void>();\n listeners.set(event, set);\n }\n set.add(listener as (...args: unknown[]) => void);\n }\n\n function removeEventListener(event: ProviderEvent, listener: ProviderListener): void {\n listeners.get(event)?.delete(listener as (...args: unknown[]) => void);\n }\n\n function stopClosePolling(): void {\n if (closeTimer !== null) {\n clearInterval(closeTimer);\n closeTimer = null;\n }\n }\n\n function startClosePolling(): void {\n if (closeTimer !== null) return;\n closeTimer = setInterval(() => {\n if (popup?.closed) handlePopupClosed();\n }, CLOSE_POLL_MS);\n }\n\n function rejectAllPending(error: ProviderRpcError): void {\n for (const request of pending.values()) request.reject(error);\n pending.clear();\n }\n\n /**\n * The pop-up was closed by the user (or the wallet app).\n *\n * We deliberately KEEP `accounts` / `chainIdHex` cached: the dApp stays \"connected\" in React state and does\n * not flicker back to a disconnected UI. Because a pop-up cannot be reopened without a user gesture, the next\n * signing request reopens it from the caller's click. `disconnect` is only emitted when the close actually\n * interrupted work (a request was pending) or when the wallet itself announced the disconnect.\n */\n function handlePopupClosed(): void {\n const hadPending = pending.size > 0;\n stopClosePolling();\n const closedPopup = popup;\n popup = null;\n const closedReady = ready;\n ready = createDeferred<void>();\n const error = disconnectedError();\n if (closedPopup) closedReady.reject(error);\n rejectAllPending(error);\n const shouldEmit = hadPending || walletDisconnected;\n walletDisconnected = false;\n if (shouldEmit) emit(\"disconnect\", error);\n }\n\n /**\n * Open the pop-up, or focus and reuse it when it is still around. Must stay synchronous (it is called before\n * any `await` in `request`) so it runs inside the caller's user activation.\n */\n function openPopup(): Window | null {\n if (popup && !popup.closed) {\n popup.focus();\n return popup;\n }\n if (typeof window === \"undefined\") return null;\n const opened = window.open(\n connectUrl(options.walletUrl, window.location.origin),\n POPUP_NAME,\n popupFeatures,\n );\n if (!opened) return null;\n popup = opened;\n ready = createDeferred<void>();\n walletDisconnected = false;\n startClosePolling();\n return opened;\n }\n\n function sendRequest(method: string, params?: RequestArguments[\"params\"]): Promise<unknown> {\n const active = popup;\n if (!active || active.closed) return Promise.reject(disconnectedError());\n const id = crypto.randomUUID();\n const message: RequestMessage = {\n type: `${MESSAGE_PREFIX}request`,\n v: PROTOCOL_VERSION,\n id,\n method,\n ...(params === undefined ? {} : { params }),\n };\n return new Promise<unknown>((resolve, reject) => {\n pending.set(id, { resolve, reject });\n active.postMessage(message, walletOrigin);\n });\n }\n\n function handleResponse(message: ResponseMessage): void {\n const request = pending.get(message.id);\n if (!request) return;\n pending.delete(message.id);\n if (\"error\" in message) {\n request.reject(new ProviderRpcError(message.error.code, message.error.message, message.error.data));\n } else {\n request.resolve(message.result);\n }\n }\n\n function handleEventMessage(message: EventMessage): void {\n if (message.event === \"accountsChanged\") {\n accounts = [...message.data];\n emit(\"accountsChanged\", [...accounts]);\n return;\n }\n if (message.event === \"chainChanged\") {\n chainIdHex = message.data;\n emit(\"chainChanged\", chainIdHex);\n return;\n }\n walletDisconnected = true;\n emit(\"disconnect\", new ProviderRpcError(message.data.code, message.data.message, message.data.data));\n }\n\n function onWindowMessage(event: MessageEvent): void {\n if (event.origin !== walletOrigin) return;\n if (popup === null || (event.source as unknown) !== popup) return;\n const data: unknown = event.data;\n if (isReadyMessage(data)) {\n ready.resolve(undefined);\n return;\n }\n if (isResponseMessage(data)) {\n handleResponse(data);\n return;\n }\n if (isEventMessage(data)) handleEventMessage(data);\n }\n\n if (typeof window !== \"undefined\") window.addEventListener(\"message\", onWindowMessage);\n\n function request({ method, params }: RequestArguments): Promise<unknown> {\n if (typeof window === \"undefined\") {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.Disconnected,\n \"The Assetera Wallet provider can only run in a browser.\",\n ),\n );\n }\n // Read-only chain calls go through wagmi's own transports; the pop-up refuses everything else.\n if (!isSupportedMethod(method)) {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.UnsupportedMethod,\n `The Assetera Wallet pop-up does not support the method \"${method}\".`,\n ),\n );\n }\n // Answered locally, without a pop-up, so wagmi can read the connection before the user clicks.\n if (method === \"eth_accounts\") return Promise.resolve([...accounts]);\n if (method === \"eth_chainId\") return Promise.resolve(currentChainId());\n\n // Opening the pop-up MUST happen synchronously, before the first `await`, to stay in the click.\n if (method === \"eth_requestAccounts\") {\n const active = openPopup();\n if (!active) return Promise.reject(blockedError());\n return ready.promise\n .then(() => sendRequest(\"eth_requestAccounts\", params))\n .then((result) => {\n accounts = Array.isArray(result) ? (result as string[]) : [];\n emit(\"accountsChanged\", [...accounts]);\n emit(\"connect\", { chainId: currentChainId() });\n return [...accounts];\n });\n }\n\n // Every other supported method needs an approved connection.\n if (accounts.length === 0) {\n return Promise.reject(\n new ProviderRpcError(\n RpcErrorCode.Unauthorized,\n \"Connect to the Assetera Wallet first (eth_requestAccounts).\",\n ),\n );\n }\n const active = openPopup();\n if (!active) return Promise.reject(blockedError());\n if (SIGNING_METHODS.has(method)) active.focus();\n return ready.promise.then(() => sendRequest(method, params));\n }\n\n function disconnect(): void {\n const active = popup;\n if (active && !active.closed) {\n const message: DisconnectMessage = {\n type: `${MESSAGE_PREFIX}disconnect`,\n v: PROTOCOL_VERSION,\n };\n active.postMessage(message, walletOrigin);\n active.close();\n }\n stopClosePolling();\n popup = null;\n const closedReady = ready;\n ready = createDeferred<void>();\n closedReady.reject(disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n rejectAllPending(disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n accounts = [];\n chainIdHex = null;\n walletDisconnected = false;\n emit(\"disconnect\", disconnectedError(\"Disconnected from the Assetera Wallet.\"));\n }\n\n function on(event: ProviderEvent, listener: ProviderListener): void {\n addListener(event, listener);\n }\n\n function removeListener(event: ProviderEvent, listener: ProviderListener): void {\n removeEventListener(event, listener);\n }\n\n return { request, on, removeListener, disconnect };\n}\n","/**\n * wagmi v2 connector for the Assetera Wallet pop-up (ADR-0054 D3).\n *\n * Built with `createConnector` from `@wagmi/core`, following the structure of wagmi's own `injected` connector.\n * `@wagmi/core`, `viem` and wagmi are peer dependencies so a partner app keeps a single copy of them on the\n * page. The connector is intentionally thin: all protocol work lives in {@link createAsseteraWalletProvider}.\n */\nimport { ChainNotConfiguredError, createConnector, type Connector } from \"@wagmi/core\";\nimport { getAddress, numberToHex, UserRejectedRequestError } from \"viem\";\nimport { ASSETERA_WALLET_ICON } from \"./icon\";\nimport { createAsseteraWalletProvider, type AsseteraWalletProvider } from \"./provider\";\n\n/** Stable connector id, used by wagmi for storage keys and RainbowKit for the wallet entry. */\nexport const ASSETERA_WALLET_ID = \"assetera-wallet\";\n/** Product name, exactly \"Assetera Wallet\". */\nexport const ASSETERA_WALLET_NAME = \"Assetera Wallet\";\n/** Connector `type` reported to wagmi. */\nexport const ASSETERA_WALLET_TYPE = \"asseteraWallet\";\n\n/** Parameters accepted by {@link asseteraWallet}. */\nexport interface AsseteraWalletParameters {\n /** Base URL of the wallet origin, e.g. `https://wallet.playground.assetera.com`. */\n walletUrl: string;\n}\n\n/**\n * Create the wagmi connector for the Assetera Wallet pop-up.\n *\n * `connect()` must be called from a user click: `eth_requestAccounts` opens the pop-up, and a pop-up cannot be\n * opened without transient user activation.\n */\nexport function asseteraWallet(parameters: AsseteraWalletParameters) {\n type Provider = AsseteraWalletProvider;\n\n let provider: Provider | undefined;\n let accountsChanged: Connector[\"onAccountsChanged\"] | undefined;\n let chainChanged: Connector[\"onChainChanged\"] | undefined;\n let disconnectHandler: Connector[\"onDisconnect\"] | undefined;\n\n function removeProviderListeners(activeProvider: Provider): void {\n if (accountsChanged) {\n activeProvider.removeListener(\"accountsChanged\", accountsChanged);\n accountsChanged = undefined;\n }\n if (chainChanged) {\n activeProvider.removeListener(\"chainChanged\", chainChanged);\n chainChanged = undefined;\n }\n if (disconnectHandler) {\n activeProvider.removeListener(\"disconnect\", disconnectHandler);\n disconnectHandler = undefined;\n }\n }\n\n return createConnector<Provider>((config) => ({\n id: ASSETERA_WALLET_ID,\n name: ASSETERA_WALLET_NAME,\n type: ASSETERA_WALLET_TYPE,\n icon: ASSETERA_WALLET_ICON,\n\n async connect({ chainId, withCapabilities } = {}) {\n const activeProvider = await this.getProvider();\n const requested = (await activeProvider.request({\n method: \"eth_requestAccounts\",\n })) as string[];\n const addresses = requested.map((account) => getAddress(account));\n\n // Forward the pop-up's own events into wagmi's emitter.\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this);\n activeProvider.on(\"accountsChanged\", accountsChanged);\n }\n if (!chainChanged) {\n chainChanged = this.onChainChanged.bind(this);\n activeProvider.on(\"chainChanged\", chainChanged);\n }\n if (!disconnectHandler) {\n disconnectHandler = this.onDisconnect.bind(this);\n activeProvider.on(\"disconnect\", disconnectHandler);\n }\n\n // Switch to the requested chain when the caller asked for one.\n let currentChainId = await this.getChainId();\n if (chainId && currentChainId !== chainId) {\n const chain = await this.switchChain!({ chainId }).catch((error) => {\n if (error?.code === UserRejectedRequestError.code) throw error;\n return { id: currentChainId };\n });\n currentChainId = chain?.id ?? currentChainId;\n }\n\n return {\n accounts: (withCapabilities\n ? addresses.map((address) => ({ address, capabilities: {} }))\n : addresses) as never,\n chainId: currentChainId,\n };\n },\n\n async disconnect() {\n if (!provider) return;\n removeProviderListeners(provider);\n provider.disconnect();\n },\n\n async getAccounts() {\n const activeProvider = await this.getProvider();\n const requested = (await activeProvider.request({ method: \"eth_accounts\" })) as string[];\n return requested.map((account) => getAddress(account));\n },\n\n async getChainId() {\n const activeProvider = await this.getProvider();\n return Number(await activeProvider.request({ method: \"eth_chainId\" }));\n },\n\n async getProvider() {\n // One provider per connector, created lazily so a partner that never connects pays nothing.\n if (!provider) {\n provider = createAsseteraWalletProvider({\n walletUrl: parameters.walletUrl,\n defaultChainId: config.chains[0].id,\n });\n }\n return provider;\n },\n\n /**\n * Always `false`: opening the pop-up requires a user click, so there is nothing to reconnect to on page\n * load. Returning `true` would make wagmi attempt an automatic reconnect that the browser blocks; the\n * partner app must drive `connect()` from a click instead.\n */\n async isAuthorized() {\n return false;\n },\n\n async switchChain({ chainId }) {\n const chain = config.chains.find((candidate) => candidate.id === chainId);\n if (!chain) throw new ChainNotConfiguredError();\n const activeProvider = await this.getProvider();\n await activeProvider.request({\n method: \"wallet_switchEthereumChain\",\n params: [{ chainId: numberToHex(chainId) }],\n });\n this.onChainChanged(numberToHex(chainId));\n return chain;\n },\n\n onAccountsChanged(accounts) {\n if (accounts.length === 0) this.onDisconnect();\n else\n config.emitter.emit(\"change\", {\n accounts: accounts.map((account) => getAddress(account)),\n });\n },\n\n onChainChanged(chain) {\n config.emitter.emit(\"change\", { chainId: Number(chain) });\n },\n\n onDisconnect() {\n config.emitter.emit(\"disconnect\");\n if (provider) removeProviderListeners(provider);\n },\n }));\n}\n"]}
|
package/dist/wagmi.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ASSETERA_WALLET_ID, ASSETERA_WALLET_NAME, ASSETERA_WALLET_TYPE, asseteraWallet } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { ASSETERA_WALLET_ID, ASSETERA_WALLET_NAME, ASSETERA_WALLET_TYPE, asseteraWallet } from './chunk-ILCYZXH2.js';
|
|
2
|
+
import './chunk-PD2FAZ7O.js';
|
|
3
|
+
import './chunk-SU2ZKBZD.js';
|
|
4
4
|
//# sourceMappingURL=wagmi.js.map
|
|
5
5
|
//# sourceMappingURL=wagmi.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asseteragmbh/wallet-connector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Connect a partner site to the Assetera Wallet pop-up: an EIP-1193 provider, a wagmi connector and a RainbowKit wallet entry (ADR-0054 D3).",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"directory": "packages/wallet-connector"
|
|
11
11
|
},
|
|
12
12
|
"publishConfig": {
|
|
13
|
-
"access": "
|
|
13
|
+
"access": "public",
|
|
14
14
|
"registry": "https://registry.npmjs.org/"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|