@beampay/checkout 1.1.1 → 2.0.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.
@@ -1,17 +1,17 @@
1
1
  import { type Config } from '@wagmi/core';
2
- import type { CheckoutOptions, OrderStatus } from '../types';
2
+ import type { CheckoutInit, OrderStatus, PayableOrder } from '../types';
3
3
  export type PayStep = 'switching' | 'approving' | 'confirming' | 'pending';
4
4
  /**
5
5
  * Drive a full signed-order payment to completion:
6
6
  * ensure-connected → switch chain → (approve if ERC-20) → pay → wait receipt →
7
7
  * poll getOrder() until payer is set. Returns the confirmed OrderStatus.
8
8
  */
9
- export declare function runPayment(config: Config, opts: CheckoutOptions, onStep: (step: PayStep) => void): Promise<OrderStatus>;
9
+ export declare function runPayment(config: Config, opts: PayableOrder, onStep: (step: PayStep) => void): Promise<OrderStatus>;
10
10
  export declare class BeamPayCheckout {
11
- private opts;
11
+ private init;
12
12
  private root;
13
13
  readonly config: Config;
14
- constructor(opts: CheckoutOptions);
14
+ constructor(init: CheckoutInit);
15
15
  mount(selector: string | HTMLElement): this;
16
16
  private openModal;
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pay-controller.d.ts","sourceRoot":"","sources":["../../src/controllers/pay-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAKZ,MAAM,aAAa,CAAA;AAUpB,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAG5D,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,SAAS,CAAA;AAY1E;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAC9B,OAAO,CAAC,WAAW,CAAC,CAyDtB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,IAAI,CAA2B;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;gBAEX,IAAI,EAAE,eAAe;IAKjC,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAoB3C,OAAO,CAAC,SAAS;CAkBlB"}
1
+ {"version":3,"file":"pay-controller.d.ts","sourceRoot":"","sources":["../../src/controllers/pay-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAKZ,MAAM,aAAa,CAAA;AAUpB,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGvE,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,SAAS,CAAA;AAY1E;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAC9B,OAAO,CAAC,WAAW,CAAC,CAyDtB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,IAAI,CAA2B;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;gBAEX,IAAI,EAAE,YAAY;IAK9B,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAiB3C,OAAO,CAAC,SAAS;CAkBlB"}
@@ -0,0 +1,20 @@
1
+ import { type OrderEnvelope } from '@beampay/schemas';
2
+ import type { OrderSource, PayableOrder } from '../types';
3
+ /**
4
+ * Resolve an OrderSource into a validated, signed OrderEnvelope.
5
+ *
6
+ * - Mode A (`order`) — validate the inline envelope.
7
+ * - Mode B (`link`) — parse a beampay-web flat-query pay link.
8
+ * - Mode C (`createOrder`) — call the merchant backend (at pay time), then validate.
9
+ */
10
+ export declare function resolveOrder(source: OrderSource): Promise<OrderEnvelope>;
11
+ /**
12
+ * Parse a beampay-web pay link into a signed OrderEnvelope. Accepts a full href
13
+ * or a bare query string. The link is the SAME flat-query format `/create`
14
+ * emits and `/pay` reads (`?chain=…&merchant=…&sig=…`) — one link format across
15
+ * the workspace.
16
+ */
17
+ export declare function parsePayLink(input: string): OrderEnvelope;
18
+ /** Convert a validated envelope into the viem-typed shape the on-chain layer submits. */
19
+ export declare function toPayableOrder(env: OrderEnvelope): PayableOrder;
20
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/controllers/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,kBAAkB,CAAA;AAG1E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEzD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAK9E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAuBzD;AAED,yFAAyF;AACzF,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,YAAY,CAe/D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resolve.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.test.d.ts","sourceRoot":"","sources":["../../src/controllers/resolve.test.ts"],"names":[],"mappings":""}
@@ -1,9 +1,7 @@
1
1
  import { LitElement } from 'lit';
2
- import type { CheckoutOptions } from '../types';
3
2
  export declare class PayButton extends LitElement {
4
- opts?: CheckoutOptions;
5
3
  static styles: import("lit").CSSResult;
6
4
  private handleClick;
7
- render(): import("lit-html").TemplateResult<1>;
5
+ render(): import("lit").TemplateResult<1>;
8
6
  }
9
7
  //# sourceMappingURL=pay-button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pay-button.d.ts","sourceRoot":"","sources":["../../src/elements/pay-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAA;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,qBACa,SAAU,SAAQ,UAAU;IACP,IAAI,CAAC,EAAE,eAAe,CAAA;IAEtD,OAAgB,MAAM,0BAerB;IAED,OAAO,CAAC,WAAW;IAIV,MAAM;CAGhB"}
1
+ {"version":3,"file":"pay-button.d.ts","sourceRoot":"","sources":["../../src/elements/pay-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAA;AAG3C,qBACa,SAAU,SAAQ,UAAU;IACvC,OAAgB,MAAM,0BAerB;IAED,OAAO,CAAC,WAAW;IAIV,MAAM;CAGhB"}
@@ -2,25 +2,31 @@ import { type Config } from '@wagmi/core';
2
2
  import { LitElement } from 'lit';
3
3
  import './wallet-picker';
4
4
  import './status-screen';
5
- import type { CheckoutOptions } from '../types';
5
+ import type { CheckoutInit } from '../types';
6
6
  export declare class PayModal extends LitElement {
7
- opts?: CheckoutOptions;
7
+ init?: CheckoutInit;
8
8
  config?: Config;
9
9
  private step;
10
10
  private progress;
11
11
  private errorMsg;
12
12
  private order?;
13
+ private env?;
14
+ private payable?;
13
15
  static styles: import("lit").CSSResult;
14
16
  connectedCallback(): void;
17
+ /** Resolve the order source (inline / link / callback) before showing payment. */
18
+ private prepare;
15
19
  private close;
16
20
  private get amountLabel();
17
- render(): import("lit-html").TemplateResult<1>;
21
+ render(): import("lit").TemplateResult<1>;
22
+ private renderPreparing;
18
23
  private renderConnect;
19
24
  private renderConfirm;
20
25
  private renderPending;
21
26
  private renderSuccess;
22
27
  private renderError;
23
28
  private renderTxLink;
29
+ private fail;
24
30
  private submitPayment;
25
31
  }
26
32
  //# sourceMappingURL=pay-modal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pay-modal.d.ts","sourceRoot":"","sources":["../../src/elements/pay-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAA;AAK3C,OAAO,iBAAiB,CAAA;AACxB,OAAO,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAA;AAW5D,qBACa,QAAS,SAAQ,UAAU;IACN,IAAI,CAAC,EAAE,eAAe,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACtC,OAAO,CAAC,IAAI,CAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,KAAK,CAAC,CAAa;IAEpC,OAAgB,MAAM,0BAyBrB;IAEQ,iBAAiB;IAS1B,OAAO,CAAC,KAAK;IAIb,OAAO,KAAK,WAAW,GAKtB;IAEQ,MAAM;IAkBf,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,aAAa,CA4BpB;CACF"}
1
+ {"version":3,"file":"pay-modal.d.ts","sourceRoot":"","sources":["../../src/elements/pay-modal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAA;AAM3C,OAAO,iBAAiB,CAAA;AACxB,OAAO,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,YAAY,EAA6B,MAAM,UAAU,CAAA;AAWvE,qBACa,QAAS,SAAQ,UAAU;IACN,IAAI,CAAC,EAAE,YAAY,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACtC,OAAO,CAAC,IAAI,CAAoB;IAChC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,KAAK,CAAC,CAAa;IAC3B,OAAO,CAAC,GAAG,CAAC,CAAe;IACpC,OAAO,CAAC,OAAO,CAAC,CAAc;IAE9B,OAAgB,MAAM,0BAyBrB;IAEQ,iBAAiB;IAK1B,kFAAkF;YACpE,OAAO;IAkBrB,OAAO,CAAC,KAAK;IAIb,OAAO,KAAK,WAAW,GAKtB;IAEQ,MAAM;IAuBf,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,aAAa,CAmBpB;CACF"}
@@ -6,7 +6,7 @@ export declare class StatusScreen extends LitElement {
6
6
  static styles: import("lit").CSSResult;
7
7
  private get icon();
8
8
  private get label();
9
- render(): import("lit-html").TemplateResult<1>;
9
+ render(): import("lit").TemplateResult<1>;
10
10
  }
11
11
  export {};
12
12
  //# sourceMappingURL=status-screen.d.ts.map
@@ -12,6 +12,6 @@ export declare class WalletPicker extends LitElement {
12
12
  private handleAnnounce;
13
13
  private get wcConnector();
14
14
  private connectWith;
15
- render(): import("lit-html").TemplateResult<1>;
15
+ render(): import("lit").TemplateResult<1>;
16
16
  }
17
17
  //# sourceMappingURL=wallet-picker.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  export { BeamPayCheckout } from './controllers/pay-controller';
2
+ export { parsePayLink } from './controllers/resolve';
3
+ export type { CheckoutInit, DisplayOpts, OrderEnvelope, OrderSource, OrderState, OrderStatus, } from './types';
2
4
  import { BeamPayCheckout } from './controllers/pay-controller';
5
+ import type { CheckoutInit, DisplayOpts } from './types';
3
6
  export declare const BeamPay: {
4
- init(opts: ConstructorParameters<typeof BeamPayCheckout>[0]): BeamPayCheckout;
7
+ /** Mount the widget from any order source (Mode A inline, B link, or C callback). */
8
+ init(opts: CheckoutInit): BeamPayCheckout;
9
+ /** Mode B convenience — build the widget from a beampay-web flat-query pay link. */
10
+ fromLink(href: string, display?: DisplayOpts): BeamPayCheckout;
5
11
  };
6
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAG9D,eAAO,MAAM,OAAO;eACP,qBAAqB,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;CAG5D,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,YAAY,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,WAAW,EACX,UAAU,EACV,WAAW,GACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAGxD,eAAO,MAAM,OAAO;IAClB,qFAAqF;eAC1E,YAAY;IAGvB,oFAAoF;mBACrE,MAAM,YAAW,WAAW;CAG5C,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import type { Config } from '@wagmi/core';
2
2
  import type { Address, Hex } from 'viem';
3
3
  import { type ChainKey } from '../chains';
4
- import type { BeamPayCheckoutOptions } from '../types';
4
+ import type { PayableOrder } from '../types';
5
5
  export declare function getRouterAddress(chain: ChainKey): Address;
6
6
  /** Minimal ERC-20 surface the widget needs (allowance + approve). */
7
7
  export declare const erc20Abi: readonly [{
@@ -40,7 +40,7 @@ export declare const erc20Abi: readonly [{
40
40
  * deployed signature: pay(merchant, receiver, token, amount, orderId, signer,
41
41
  * createdAt, expiresAt, signature). Native path attaches msg.value = amount.
42
42
  */
43
- export declare function buildPayRequest(chain: ChainKey, opts: BeamPayCheckoutOptions): {
43
+ export declare function buildPayRequest(chain: ChainKey, opts: PayableOrder): {
44
44
  address: `0x${string}`;
45
45
  abi: import("viem").Abi;
46
46
  functionName: "pay";
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/lib/router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,EAAE,KAAK,QAAQ,EAAmB,MAAM,WAAW,CAAA;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAItD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAMzD;AAED,qEAAqE;AACrE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBX,CAAA;AAEV;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,sBAAsB;;;;;;EAoB5E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOlF;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,EACf,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,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AG,OAAO,CAE9C"}
package/dist/types.d.ts CHANGED
@@ -1,33 +1,26 @@
1
+ import type { OrderEnvelope } from '@beampay/schemas';
1
2
  import type { Address, Hex } from 'viem';
3
+ import type { ChainKey } from './chains';
4
+ export type { OrderEnvelope };
2
5
  /**
3
- * Options passed to BeamPay.init() / new BeamPayCheckout().
6
+ * Where the widget gets its signed order from. The widget NEVER signs — the
7
+ * merchant (or an on-chain delegate) signs the EIP-712 Order off-chain; the
8
+ * widget only submits the buyer's `pay()`.
4
9
  *
5
- * Carries a full v1.4 signed order the merchant (or a delegate) signs the
6
- * EIP-712 Order off-chain (e.g. via beampay-web /create) and the resulting
7
- * envelope is handed to the widget. The widget never signs; it only submits
8
- * the user's `pay()` transaction.
10
+ * - `order` Mode A (inline, push): a pre-signed envelope handed in directly.
11
+ * - `link` — Mode B (pay link, push): a beampay-web `?chain=…&sig=…` link.
12
+ * - `createOrder` Mode C (callback, pull): called at pay time to fetch a freshly
13
+ * signed envelope from the merchant's own backend (dynamic price).
9
14
  */
10
- export interface BeamPayCheckoutOptions {
11
- /** Chain key: 'bsc' | 'ethereum' | 'bsc-testnet'. */
12
- chain: string;
13
- /** Order owner — order-key namespace, event index, refund caller. */
14
- merchant: Address;
15
- /** v1.4 signed payout destination — may differ from `merchant`. */
16
- receiver: Address;
17
- /** Token contract address, or NATIVE_TOKEN sentinel for BNB/ETH. */
18
- token: Address;
19
- /** Amount in token base units (wei), as a decimal string. */
20
- amount: string;
21
- /** Merchant-scoped unique 32-byte order id (hex). */
22
- orderId: Hex;
23
- /** EIP-712 signer recovered on-chain (merchant or merchant's delegate). */
24
- signer: Address;
25
- /** Order creation timestamp, unix seconds (uint64). */
26
- createdAt: number;
27
- /** Order expiry timestamp, unix seconds (uint64). */
28
- expiresAt: number;
29
- /** 65-byte EIP-712 signature, hex-encoded. */
30
- signature: Hex;
15
+ export type OrderSource = {
16
+ order: OrderEnvelope;
17
+ } | {
18
+ link: string;
19
+ } | {
20
+ createOrder: (ctx?: unknown) => Promise<OrderEnvelope>;
21
+ };
22
+ /** Display + behavior options, independent of where the order comes from. */
23
+ export interface DisplayOpts {
31
24
  /** Token decimals — display only (amount stays in wei). Defaults to 18. */
32
25
  decimals?: number;
33
26
  /** Token symbol — display only (e.g. 'tUSDT'). */
@@ -39,8 +32,24 @@ export interface BeamPayCheckoutOptions {
39
32
  /** Called on any error (wallet rejection, tx failure, poll timeout). */
40
33
  onError?: (err: Error) => void;
41
34
  }
42
- /** Back-compat alias elements import `CheckoutOptions`. */
43
- export type CheckoutOptions = BeamPayCheckoutOptions;
35
+ /** Options passed to BeamPay.init() / new BeamPayCheckout(). */
36
+ export type CheckoutInit = OrderSource & DisplayOpts;
37
+ /**
38
+ * A signed order in the viem-typed shape the on-chain layer submits. Produced
39
+ * from an OrderEnvelope by `toPayableOrder()`.
40
+ */
41
+ export interface PayableOrder {
42
+ chain: ChainKey;
43
+ merchant: Address;
44
+ receiver: Address;
45
+ token: Address;
46
+ amount: string;
47
+ orderId: Hex;
48
+ signer: Address;
49
+ createdAt: number;
50
+ expiresAt: number;
51
+ signature: Hex;
52
+ }
44
53
  /** On-chain / API order status */
45
54
  export type OrderState = 'pending' | 'paid' | 'failed' | 'expired' | 'refunded';
46
55
  export interface OrderStatus {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAA;IACb,qEAAqE;IACrE,QAAQ,EAAE,OAAO,CAAA;IACjB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAA;IACjB,oEAAoE;IACpE,KAAK,EAAE,OAAO,CAAA;IACd,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,OAAO,EAAE,GAAG,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AAG,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,UAAU,CAAA;IACjB,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAA;CAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beampay/checkout",
3
- "version": "1.1.1",
3
+ "version": "2.0.0",
4
4
  "description": "Framework-agnostic embeddable checkout widget for BeamPay",
5
5
  "type": "module",
6
6
  "main": "./dist/checkout.iife.js",
@@ -15,21 +15,9 @@
15
15
  "files": [
16
16
  "dist"
17
17
  ],
18
- "scripts": {
19
- "dev": "vite",
20
- "build": "vite build && tsc --emitDeclarationOnly --declaration --outDir dist",
21
- "build:demo": "vite build --config vite.demo.config.ts",
22
- "preview": "vite preview",
23
- "lint": "biome check src e2e",
24
- "fix": "biome check --write src e2e",
25
- "typecheck": "tsc --noEmit",
26
- "test": "vitest run",
27
- "e2e": "playwright test",
28
- "release:bundle": "echo 'TODO: upload dist/checkout.iife.js to Cloudflare R2 beam-cdn/checkout/v1.js'",
29
- "release:npm": "echo 'TODO: npm publish --access public'"
30
- },
31
18
  "dependencies": {
32
19
  "@beampay/contracts-abi": "^0.3.0",
20
+ "@beampay/schemas": "^0.9.0",
33
21
  "@wagmi/connectors": "^5.1",
34
22
  "@wagmi/core": "^2.16",
35
23
  "@walletconnect/ethereum-provider": "^2.17",
@@ -55,5 +43,18 @@
55
43
  "repository": {
56
44
  "type": "git",
57
45
  "url": "https://github.com/BeamPayFun/beampay-checkout"
46
+ },
47
+ "scripts": {
48
+ "dev": "vite",
49
+ "build": "vite build && tsc --emitDeclarationOnly --declaration --outDir dist",
50
+ "build:demo": "vite build --config vite.demo.config.ts",
51
+ "preview": "vite preview",
52
+ "lint": "biome check src e2e",
53
+ "fix": "biome check --write src e2e",
54
+ "typecheck": "tsc --noEmit",
55
+ "test": "vitest run",
56
+ "e2e": "playwright test",
57
+ "release:bundle": "echo 'TODO: upload dist/checkout.iife.js to Cloudflare R2 beam-cdn/checkout/v1.js'",
58
+ "release:npm": "echo 'TODO: npm publish --access public'"
58
59
  }
59
- }
60
+ }