@chipi-stack/starknet-connector 0.2.0 → 0.4.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 CHANGED
@@ -1,15 +1,19 @@
1
1
  # @chipi-stack/starknet-connector
2
2
 
3
- **"Connect with Chipi"** — a [starknet-react](https://starknet-react.com) /
3
+ **"Connect with Chipi"**, a [starknet-react](https://starknet-react.com) /
4
4
  [get-starknet](https://github.com/starknet-io/get-starknet) connector that lets
5
5
  any Starknet dApp connect to a **Chipi hosted smart-account wallet** (passkey,
6
- gasless via paymaster). No browser extension, no WalletConnect, no whitelisting
7
- — add the package to your own dApp and it just works.
6
+ gasless via paymaster). No browser extension, no WalletConnect, no whitelisting,
7
+ just add the package to your own dApp and it works.
8
8
 
9
9
  ```bash
10
10
  npm install @chipi-stack/starknet-connector
11
11
  ```
12
12
 
13
+ Ships both ESM and CommonJS. Versions before 0.3.0 were ESM-only and failed
14
+ under any CommonJS resolver (plain Node, `tsx`, `ts-node`, Jest) with
15
+ `ERR_PACKAGE_PATH_NOT_EXPORTED`. Bundlers were never affected.
16
+
13
17
  ## Use it
14
18
 
15
19
  Add one connector to your `StarknetConfig`:
@@ -36,7 +40,7 @@ export function App({ children }) {
36
40
 
37
41
  That's it. Your existing `useConnect` / `useAccount` flow now offers "Connect
38
42
  with Chipi", and `account.signMessage(...)` / `account.execute(...)` route to the
39
- user's Chipi wallet — **gasless**, signed with their passkey.
43
+ user's Chipi wallet, **gasless**, signed with their passkey.
40
44
 
41
45
  ## How it works
42
46
 
@@ -50,11 +54,11 @@ account.execute(calls)
50
54
  └─ wallet_addInvokeTransaction ─► user approves ─► sponsored tx ─► tx hash
51
55
  ```
52
56
 
53
- - The connector is **transport only** — it opens the hosted wallet in a popup and
57
+ - The connector is **transport only**: it opens the hosted wallet in a popup and
54
58
  forwards get-starknet `wallet_*` RPC calls over `postMessage`. It holds no
55
59
  keys and signs nothing itself.
56
60
  - The hosted wallet renders a **decoded approval** for every sign/execute (it
57
- shows the actual intent — token, amount, spender — and hard-blocks typed data
61
+ shows the actual intent, token, amount, spender, and hard-blocks typed data
58
62
  it can't read), then runs the real passkey + paymaster path.
59
63
  - `account()` wraps the channel in a `starknet.js` `WalletAccount`, so the dApp
60
64
  uses a standard `AccountInterface`.
@@ -68,38 +72,78 @@ chipi({
68
72
  name: "Connect with Chipi", // display name
69
73
  icon: "data:image/svg+xml;base64,...", // display icon
70
74
  register: true, // self-register on window (default)
75
+ transport: {
76
+ openTimeoutMs: 180_000, // ready handshake; on timeout the popup is closed
77
+ requestTimeoutMs: 120_000, // per request; 0 disables
78
+ },
71
79
  });
72
80
  ```
73
81
 
74
- `chipi(options)` is a thin wrapper — `new ChipiConnector(options)` still works
82
+ `chipi(options)` is a thin wrapper: `new ChipiConnector(options)` still works
75
83
  identically if you prefer instantiating the class directly.
76
84
 
85
+ ## Events and errors
86
+
87
+ - The connector forwards the wallet's `accountsChanged` / `networkChanged` as
88
+ starknet-react `change` events (`{ account, chainId }`); an empty account list
89
+ emits `disconnect`.
90
+ - `connect({ chainIdHint })` rejects with `code: "UNSUPPORTED_CHAIN"` for any
91
+ chain other than mainnet (`SN_MAIN`), before opening a popup.
92
+ - A request that gets no answer within `requestTimeoutMs` rejects with
93
+ `code: "REQUEST_TIMEOUT"`.
94
+ - If the user closes the wallet window, later requests reject with
95
+ `code: "POPUP_CLOSED"` instead of reopening it (browsers block popups outside
96
+ a click). Call `connect()` again from a click.
97
+ - `disconnect()` closes the popup and removes `window.starknet_chipi`; the next
98
+ `connect()` registers it again.
99
+
77
100
  ## Compatibility
78
101
 
79
102
  - `@starknet-react/core` **>= 3** (peer) · tested against `5.x`
80
- - `starknet` **>= 8.1.2** (peer) — `WalletAccount.connect` is identical across 8/9
103
+ - `starknet` **>= 8.1.2** (peer); `WalletAccount.connect` is identical across 8/9
81
104
  - **Starknet mainnet** (v1). The wallet is mainnet-only.
82
105
 
83
106
  ## Discovery
84
107
 
85
108
  Instantiating the connector also **self-registers** the wallet on `window`
86
- (`window.starknet_chipi` + a `starknet:announceWallet` event — the get-starknet /
109
+ (`window.starknet_chipi` + a `starknet:announceWallet` event, the get-starknet /
87
110
  Starknet-Wallet-Standard discovery path), so dApps that _scan_ for wallets find
88
- "Connect with Chipi" even if they don't import this package — no whitelisting,
111
+ "Connect with Chipi" even if they don't import this package, no whitelisting,
89
112
  no coordination with us required. Pass `register: false` to opt out (e.g. to
90
113
  avoid a duplicate entry in a picker that already lists the connector
91
114
  explicitly). It's a no-op during SSR. You can also call
92
115
  `registerChipiWallet(swo)` directly.
93
116
 
117
+ ### Wallet Standard (get-starknet v5+ discovery)
118
+
119
+ For dApps that discover wallets through the Wallet Standard
120
+ (`@starknet-io/get-starknet-discovery`, `@starknet-start/react`), register Chipi
121
+ as a `WalletWithStarknetFeatures` (`starknet:walletApi`, `standard:connect`,
122
+ `standard:disconnect`, `standard:events`) backed by the same popup:
123
+
124
+ ```ts
125
+ import { registerChipiStandardWallet } from "@chipi-stack/starknet-connector";
126
+
127
+ const unregister = registerChipiStandardWallet({
128
+ walletUrl: "https://wallet.chipipay.com", // default
129
+ });
130
+ // later: unregister();
131
+ ```
132
+
133
+ It dispatches `wallet-standard:register-wallet` and answers
134
+ `wallet-standard:app-ready`, with no extra dependency. Accounts are on
135
+ `starknet:0x534e5f4d41494e` (mainnet). `connect({ silent: true })` never opens a
136
+ popup. Use `createChipiStandardWallet(options)` to build the wallet object
137
+ without registering it.
138
+
94
139
  ## Notes / limits (v1)
95
140
 
96
141
  - **Popup-based** (external dApps). The in-app-browser ("parent") mode is in the
97
- transport but not exposed yet — the hosted wallet side handles it in a later
142
+ transport but not exposed yet; the hosted wallet side handles it in a later
98
143
  release.
99
- - Mainnet only — pass a mainnet `provider`.
144
+ - Mainnet only, pass a mainnet `provider`.
100
145
  - One approval at a time; a dApp that fires two prompts truly simultaneously has
101
146
  its second request rejected (most dApps serialize).
102
147
 
103
148
  MIT · [docs.chipipay.com](https://docs.chipipay.com) ·
104
- [example](https://github.com/chipi-pay/build-with-chipi/tree/feat/connect-with-chipi-tutorial/tutorials/03-connect-with-chipi)
105
- (pending merge — [PR #22](https://github.com/chipi-pay/build-with-chipi/pull/22))
149
+ [example](https://github.com/chipi-pay/build-with-chipi/tree/main/tutorials/03-connect-with-chipi)