@rhinestone/deposit-modal 0.3.0-alpha.9 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +76 -0
  2. package/dist/{DepositModalReown-I7I3KLD2.mjs → DepositModalReown-G7UX4IBZ.mjs} +6 -4
  3. package/dist/{DepositModalReown-XUA47RYZ.cjs → DepositModalReown-MECHBE6P.cjs} +9 -7
  4. package/dist/{QRCode-KG47KTGX.cjs → QRCode-5DXFNKI2.cjs} +1 -1
  5. package/dist/{QRCode-YJ3EGWQS.mjs → QRCode-WUC652SH.mjs} +1 -1
  6. package/dist/{WithdrawModalReown-KN2DGOXR.mjs → WithdrawModalReown-CUJAFUQM.mjs} +5 -4
  7. package/dist/{WithdrawModalReown-JATYMQYP.cjs → WithdrawModalReown-WJ6VBZKK.cjs} +8 -7
  8. package/dist/{constants-DqVn968d.d.ts → caip-CsslyHGL.d.cts} +11 -1
  9. package/dist/{constants-DqVn968d.d.cts → caip-CsslyHGL.d.ts} +11 -1
  10. package/dist/{chunk-TJG2AFPS.mjs → chunk-3C35DVPE.mjs} +1048 -829
  11. package/dist/{chunk-SZIYS42B.mjs → chunk-6YRDD462.mjs} +63 -3
  12. package/dist/chunk-AJHFNHG3.cjs +295 -0
  13. package/dist/chunk-BAEB5AFZ.mjs +212 -0
  14. package/dist/{chunk-KE4MRCFN.mjs → chunk-DZQD3DAV.mjs} +26 -17
  15. package/dist/{chunk-G5Q4QBWX.cjs → chunk-LEL6GMEQ.cjs} +111 -102
  16. package/dist/{chunk-7JIDIX27.cjs → chunk-MILJQWPT.cjs} +73 -13
  17. package/dist/{chunk-MMXUBBGK.cjs → chunk-MQIJZNTP.cjs} +1026 -807
  18. package/dist/{chunk-4BUMVXPS.mjs → chunk-QYSCCX4K.mjs} +2237 -871
  19. package/dist/chunk-R5CPOBCF.cjs +212 -0
  20. package/dist/{chunk-OISMGA2L.mjs → chunk-R5WDHHVM.mjs} +2 -12
  21. package/dist/{chunk-ZVG4JDKZ.cjs → chunk-SPUZLWQS.cjs} +2285 -919
  22. package/dist/chunk-TQ2AYMWS.mjs +295 -0
  23. package/dist/{chunk-KIPKYPNF.cjs → chunk-ULEAK63T.cjs} +6 -16
  24. package/dist/constants.cjs +6 -2
  25. package/dist/constants.d.cts +1 -1
  26. package/dist/constants.d.ts +1 -1
  27. package/dist/constants.mjs +5 -1
  28. package/dist/deposit.cjs +6 -4
  29. package/dist/deposit.d.cts +4 -4
  30. package/dist/deposit.d.ts +4 -4
  31. package/dist/deposit.mjs +5 -3
  32. package/dist/index.cjs +21 -6
  33. package/dist/index.d.cts +4 -3
  34. package/dist/index.d.ts +4 -3
  35. package/dist/index.mjs +22 -7
  36. package/dist/polymarket.cjs +64 -0
  37. package/dist/polymarket.d.cts +57 -0
  38. package/dist/polymarket.d.ts +57 -0
  39. package/dist/polymarket.mjs +64 -0
  40. package/dist/styles.css +719 -75
  41. package/dist/{types-D8Q4TMk7.d.cts → types-RzfAD14B.d.cts} +65 -2
  42. package/dist/{types-D8Q4TMk7.d.ts → types-RzfAD14B.d.ts} +65 -2
  43. package/dist/withdraw.cjs +5 -4
  44. package/dist/withdraw.d.cts +4 -4
  45. package/dist/withdraw.d.ts +4 -4
  46. package/dist/withdraw.mjs +4 -3
  47. package/package.json +55 -18
@@ -0,0 +1,64 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+ var _chunkR5CPOBCFcjs = require('./chunk-R5CPOBCF.cjs');
6
+ require('./chunk-AJHFNHG3.cjs');
7
+ require('./chunk-MILJQWPT.cjs');
8
+
9
+ // src/core/dapp-imports/polymarket/account.ts
10
+
11
+
12
+
13
+
14
+
15
+
16
+ var _viem = require('viem');
17
+ var _chains = require('viem/chains');
18
+ async function getPolymarketAccount(params) {
19
+ const { rpcUrl, signal } = params;
20
+ if (typeof params.eoa !== "string" || !_viem.isAddress.call(void 0, params.eoa)) {
21
+ throw new TypeError(
22
+ `getPolymarketAccount: invalid EOA address: ${String(params.eoa)}`
23
+ );
24
+ }
25
+ const eoa = _viem.getAddress.call(void 0, params.eoa);
26
+ const proxyWallet = await _chunkR5CPOBCFcjs.fetchPolymarketProxyWallet.call(void 0, eoa, signal);
27
+ if (!proxyWallet) return null;
28
+ throwIfAborted(signal);
29
+ let balances = { pusd: 0n, usdce: 0n };
30
+ try {
31
+ balances = await _chunkR5CPOBCFcjs.readPolymarketBalances.call(void 0, {
32
+ publicClient: polygonClient(rpcUrl),
33
+ proxyWallet
34
+ });
35
+ } catch (e) {
36
+ }
37
+ throwIfAborted(signal);
38
+ const pusd = toTokenBalance(balances.pusd);
39
+ const usdce = toTokenBalance(balances.usdce);
40
+ return {
41
+ eoa,
42
+ proxyWallet,
43
+ chainId: _chunkR5CPOBCFcjs.POLYMARKET_POLYGON_CHAIN_ID,
44
+ pusd,
45
+ usdce,
46
+ totalUsd: pusd.usd + usdce.usd
47
+ };
48
+ }
49
+ function toTokenBalance(raw) {
50
+ const formatted = _viem.formatUnits.call(void 0, raw, 6);
51
+ const usd = Number(formatted);
52
+ return { raw, formatted, usd: Number.isFinite(usd) ? usd : 0 };
53
+ }
54
+ function polygonClient(rpcUrl) {
55
+ return _viem.createPublicClient.call(void 0, { chain: _chains.polygon, transport: _viem.http.call(void 0, rpcUrl) });
56
+ }
57
+ function throwIfAborted(signal) {
58
+ if (_optionalChain([signal, 'optionalAccess', _ => _.aborted])) {
59
+ throw _nullishCoalesce(signal.reason, () => ( new DOMException("Aborted", "AbortError")));
60
+ }
61
+ }
62
+
63
+
64
+ exports.getPolymarketAccount = getPolymarketAccount;
@@ -0,0 +1,57 @@
1
+ import { Address } from 'viem';
2
+
3
+ declare const POLYMARKET_POLYGON_CHAIN_ID = 137;
4
+
5
+ /**
6
+ * Headless Polymarket account lookup, exported via the
7
+ * `@rhinestone/deposit-modal/polymarket` subpath so a consumer can render
8
+ * the user's Polymarket address + balance in their own UI (no React, no
9
+ * modal, no wallet-connect stack in the bundle).
10
+ */
11
+
12
+ interface PolymarketTokenBalance {
13
+ /** Base units (6 decimals). */
14
+ raw: bigint;
15
+ /** `formatUnits(raw, 6)`. */
16
+ formatted: string;
17
+ /** 1:1 for pUSD and USDC.e. */
18
+ usd: number;
19
+ }
20
+ interface PolymarketAccount {
21
+ eoa: Address;
22
+ /** Present even when balances are zero. */
23
+ proxyWallet: Address;
24
+ chainId: typeof POLYMARKET_POLYGON_CHAIN_ID;
25
+ pusd: PolymarketTokenBalance;
26
+ usdce: PolymarketTokenBalance;
27
+ totalUsd: number;
28
+ }
29
+ /**
30
+ * Looks up the Polymarket proxy wallet for an EOA and reads its pUSD and
31
+ * USDC.e balances on Polygon.
32
+ *
33
+ * - Resolves `null` ONLY when the EOA has no Polymarket proxy at all.
34
+ * Found-but-empty resolves a full account with zeroed balances — the
35
+ * address is the headline.
36
+ * - A failed balance read (RPC outage) also resolves the account with
37
+ * zeroed balances rather than rejecting.
38
+ * - Transient Gamma failures (network, 5xx) and aborts reject, so a
39
+ * caller never mistakes an outage for "no account".
40
+ *
41
+ * The balance reported here is "what exists" at the proxy. The modal's
42
+ * own availability check additionally verifies the EOA can MOVE those
43
+ * funds (Safe owner / deposit-wallet owner) — an account whose EOA owns
44
+ * neither reports a balance here but routes to the modal's home screen
45
+ * when opened via `initialDappImport`.
46
+ *
47
+ * `signal` cancels the Gamma profile fetch and short-circuits between
48
+ * steps; an in-flight RPC balance read itself is not cancellable.
49
+ */
50
+ declare function getPolymarketAccount(params: {
51
+ eoa: Address | string;
52
+ /** Overrides the default public Polygon RPC. */
53
+ rpcUrl?: string;
54
+ signal?: AbortSignal;
55
+ }): Promise<PolymarketAccount | null>;
56
+
57
+ export { type PolymarketAccount, type PolymarketTokenBalance, getPolymarketAccount };
@@ -0,0 +1,57 @@
1
+ import { Address } from 'viem';
2
+
3
+ declare const POLYMARKET_POLYGON_CHAIN_ID = 137;
4
+
5
+ /**
6
+ * Headless Polymarket account lookup, exported via the
7
+ * `@rhinestone/deposit-modal/polymarket` subpath so a consumer can render
8
+ * the user's Polymarket address + balance in their own UI (no React, no
9
+ * modal, no wallet-connect stack in the bundle).
10
+ */
11
+
12
+ interface PolymarketTokenBalance {
13
+ /** Base units (6 decimals). */
14
+ raw: bigint;
15
+ /** `formatUnits(raw, 6)`. */
16
+ formatted: string;
17
+ /** 1:1 for pUSD and USDC.e. */
18
+ usd: number;
19
+ }
20
+ interface PolymarketAccount {
21
+ eoa: Address;
22
+ /** Present even when balances are zero. */
23
+ proxyWallet: Address;
24
+ chainId: typeof POLYMARKET_POLYGON_CHAIN_ID;
25
+ pusd: PolymarketTokenBalance;
26
+ usdce: PolymarketTokenBalance;
27
+ totalUsd: number;
28
+ }
29
+ /**
30
+ * Looks up the Polymarket proxy wallet for an EOA and reads its pUSD and
31
+ * USDC.e balances on Polygon.
32
+ *
33
+ * - Resolves `null` ONLY when the EOA has no Polymarket proxy at all.
34
+ * Found-but-empty resolves a full account with zeroed balances — the
35
+ * address is the headline.
36
+ * - A failed balance read (RPC outage) also resolves the account with
37
+ * zeroed balances rather than rejecting.
38
+ * - Transient Gamma failures (network, 5xx) and aborts reject, so a
39
+ * caller never mistakes an outage for "no account".
40
+ *
41
+ * The balance reported here is "what exists" at the proxy. The modal's
42
+ * own availability check additionally verifies the EOA can MOVE those
43
+ * funds (Safe owner / deposit-wallet owner) — an account whose EOA owns
44
+ * neither reports a balance here but routes to the modal's home screen
45
+ * when opened via `initialDappImport`.
46
+ *
47
+ * `signal` cancels the Gamma profile fetch and short-circuits between
48
+ * steps; an in-flight RPC balance read itself is not cancellable.
49
+ */
50
+ declare function getPolymarketAccount(params: {
51
+ eoa: Address | string;
52
+ /** Overrides the default public Polygon RPC. */
53
+ rpcUrl?: string;
54
+ signal?: AbortSignal;
55
+ }): Promise<PolymarketAccount | null>;
56
+
57
+ export { type PolymarketAccount, type PolymarketTokenBalance, getPolymarketAccount };
@@ -0,0 +1,64 @@
1
+ import {
2
+ POLYMARKET_POLYGON_CHAIN_ID,
3
+ fetchPolymarketProxyWallet,
4
+ readPolymarketBalances
5
+ } from "./chunk-BAEB5AFZ.mjs";
6
+ import "./chunk-TQ2AYMWS.mjs";
7
+ import "./chunk-6YRDD462.mjs";
8
+
9
+ // src/core/dapp-imports/polymarket/account.ts
10
+ import {
11
+ createPublicClient,
12
+ formatUnits,
13
+ getAddress,
14
+ http,
15
+ isAddress
16
+ } from "viem";
17
+ import { polygon } from "viem/chains";
18
+ async function getPolymarketAccount(params) {
19
+ const { rpcUrl, signal } = params;
20
+ if (typeof params.eoa !== "string" || !isAddress(params.eoa)) {
21
+ throw new TypeError(
22
+ `getPolymarketAccount: invalid EOA address: ${String(params.eoa)}`
23
+ );
24
+ }
25
+ const eoa = getAddress(params.eoa);
26
+ const proxyWallet = await fetchPolymarketProxyWallet(eoa, signal);
27
+ if (!proxyWallet) return null;
28
+ throwIfAborted(signal);
29
+ let balances = { pusd: 0n, usdce: 0n };
30
+ try {
31
+ balances = await readPolymarketBalances({
32
+ publicClient: polygonClient(rpcUrl),
33
+ proxyWallet
34
+ });
35
+ } catch {
36
+ }
37
+ throwIfAborted(signal);
38
+ const pusd = toTokenBalance(balances.pusd);
39
+ const usdce = toTokenBalance(balances.usdce);
40
+ return {
41
+ eoa,
42
+ proxyWallet,
43
+ chainId: POLYMARKET_POLYGON_CHAIN_ID,
44
+ pusd,
45
+ usdce,
46
+ totalUsd: pusd.usd + usdce.usd
47
+ };
48
+ }
49
+ function toTokenBalance(raw) {
50
+ const formatted = formatUnits(raw, 6);
51
+ const usd = Number(formatted);
52
+ return { raw, formatted, usd: Number.isFinite(usd) ? usd : 0 };
53
+ }
54
+ function polygonClient(rpcUrl) {
55
+ return createPublicClient({ chain: polygon, transport: http(rpcUrl) });
56
+ }
57
+ function throwIfAborted(signal) {
58
+ if (signal?.aborted) {
59
+ throw signal.reason ?? new DOMException("Aborted", "AbortError");
60
+ }
61
+ }
62
+ export {
63
+ getPolymarketAccount
64
+ };