@crossmint/client-sdk-react-ui 1.1.0-alpha.0 → 1.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/src/components/embed/EmbeddedCheckoutIFrame.tsx +14 -9
- package/src/components/embed/crypto/CryptoEmbeddedCheckout.tsx +11 -0
- package/src/components/embed/crypto/CryptoEmbeddedCheckoutIFrame.tsx +88 -0
- package/src/components/embed/fiat/FiatEmbeddedCheckoutIFrame.tsx +10 -0
- package/src/components/embed/index.tsx +3 -4
- package/src/components/hosted/CrossmintPayButton.tsx +9 -2
- package/src/consts/version.ts +1 -1
- package/src/components/embed/CryptoEmbeddedCheckout.tsx +0 -13
- /package/src/components/embed/{FiatPaymentElement_OLD.tsx → fiat/FiatPaymentElement_OLD.tsx} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Ft=Object.create;var P=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames,k=Object.getOwnPropertySymbols,Bt=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var q=(t,e,n)=>e in t?P(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,u=(t,e)=>{for(var n in e||(e={}))A.call(e,n)&&q(t,n,e[n]);if(k)for(var n of k(e))J.call(e,n)&&q(t,n,e[n]);return t};var T=(t,e)=>{var n={};for(var r in t)A.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&k)for(var r of k(t))e.indexOf(r)<0&&J.call(t,r)&&(n[r]=t[r]);return n};var Rt=(t,e)=>{for(var n in e)P(t,n,{get:e[n],enumerable:!0})},K=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Lt(e))!A.call(t,s)&&s!==n&&P(t,s,{get:()=>e[s],enumerable:!(r=Ot(e,s))||r.enumerable});return t};var D=(t,e,n)=>(n=t!=null?Ft(Bt(t)):{},K(e||!t||!t.__esModule?P(n,"default",{value:t,enumerable:!0}):n,t)),_t=t=>K(P({},"__esModule",{value:!0}),t);var v=(t,e,n)=>new Promise((r,s)=>{var d=o=>{try{c(n.next(o))}catch(i){s(i)}},l=o=>{try{c(n.throw(o))}catch(i){s(i)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(d,l);c((n=n.apply(t,e)).next())});var Vt={};Rt(Vt,{CrossmintEvents:()=>B.CrossmintEvents,CrossmintNFTCollectionView:()=>Mt,CrossmintNFTDetail:()=>Ut,CrossmintPayButton:()=>Ht,CrossmintPaymentElement:()=>At,useCrossmintEvents:()=>B.useCrossmintEvents});module.exports=_t(Vt);var w=require("@crossmint/client-sdk-base");var y="1.1.0-alpha.2";var Q=require("react/jsx-runtime");function Mt(t){(0,w.assertValidNFTCollectionViewProps)(t);let e=(0,w.getNFTCollectionViewSrc)(t,y);return(0,Q.jsx)("iframe",{src:e,width:"100%",height:"100%",style:{flexGrow:"1",border:"none",margin:"0",padding:"0"},role:"nft-collection-view"})}var x=require("@crossmint/client-sdk-base");var X=require("react/jsx-runtime");function Ut(t){(0,x.assertValidValidateNFTDetailProps)(t);let e=(0,x.getNFTDetailSrc)(t,y);return(0,X.jsx)("iframe",{src:e,width:"100%",height:"100%",style:{flexGrow:"1",border:"none",margin:"0",padding:"0"},role:"nft-details"})}var O=require("@crossmint/client-sdk-base");var nt=require("@crossmint/client-sdk-base");var j=D(require("bs58"),1),tt=require("react"),p=require("@crossmint/client-sdk-base");var E=require("react"),N=require("@crossmint/client-sdk-base");var Z=require("react/jsx-runtime");function H(n){var r=n,{onInternalEvent:t}=r,e=T(r,["onInternalEvent"]);let{getUrl:s,listenToEvents:d,listenToInternalEvents:l,emitInternalEvent:c}=(0,N.crossmintIFrameService)(e),[o,i]=(0,E.useState)(0),[m]=(0,E.useState)(s(e));return(0,E.useEffect)(()=>{let a=d(C=>{var f;(f=e.onEvent)==null||f.call(e,C.data)});return()=>{a()}},[]),(0,E.useEffect)(()=>{let a=l(C=>{let{type:f,payload:R}=C.data;f===N.IncomingInternalEvents.UI_HEIGHT_CHANGED&&i(R.height),t==null||t(C.data)});return()=>{a()}},[]),(0,Z.jsx)("iframe",{src:m,id:"crossmint-embedded-checkout.iframe",role:"crossmint-embedded-checkout.iframe",allow:"payment *",style:{border:"none !important",padding:"0px !important",width:"100% !important",minWidth:"100% !important",overflow:"hidden !important",display:"block !important",userSelect:"none",transform:"translate(0px) !important",opacity:"1",transition:"ease 0s, opacity 0.4s ease 0.1s",height:`${o}px`}})}var et=require("react/jsx-runtime");function V(t){let{emitInternalEvent:e}=(0,p.crossmintIFrameService)(t),{signer:n,paymentMethod:r}=t;function s(o){let{type:i,payload:m}=o;if(i===p.IncomingInternalEvents.CRYPTO_PAYMENT_INCOMING_TRANSACTION){let{serializedTransaction:a}=m;console.log("[Crossmint] Received incoming transaction",a),d(a)}}function d(o){return v(this,null,function*(){try{let i;switch(r){case"SOL":i=yield l(n,o);break;case"ETH":i=yield c(n,o);break;default:throw new Error(`Unsupported payment method ${r}`)}console.log("[Crossmint] Signed and sent transaction",i),e({type:p.OutgoingInternalEvents.CRYPTO_PAYMENT_USER_ACCEPTED,payload:{txId:i}})}catch(i){console.error("[Crossmint] Failed to sign and send transaction",i),e({type:p.OutgoingInternalEvents.CRYPTO_PAYMENT_USER_REJECTED,payload:{}})}})}function l(o,i){return v(this,null,function*(){let{Transaction:m}=yield import("@solana/web3.js"),a=m.from(j.default.decode(i));return console.log("[Crossmint] Deserialized SOL transaction",a),yield o.signAndSendTransaction(a)})}function c(o,i){return v(this,null,function*(){let{parse:m}=yield import("@ethersproject/transactions"),a=m(i);return console.log("[Crossmint] Deserialized ETH transaction",a),yield o.signAndSendTransaction(a)})}return(0,tt.useEffect)(()=>{e({type:"params-update",payload:(0,p.embeddedCheckoutPropsToUpdatableParamsPayload)(t)})},[t.signer,t.recipient,t.mintConfig,t.locale,t.whPassThroughArgs]),(0,et.jsx)(H,u({onInternalEvent:s},t))}var rt=require("react/jsx-runtime");function ot(t){if(!(0,nt.isCryptoEmbeddedCheckoutPropsWithSigner)(t))throw new Error("Invalid parameters: signer is required in versions < 2.0.0");return(0,rt.jsx)(V,u({},t))}var g=require("react"),F=require("@crossmint/client-sdk-base"),st=require("react/jsx-runtime");function it(t){let[e,n]=(0,g.useState)(0),{getIframeUrl:r,listenToEvents:s,emitQueryParams:d}=(0,F.crossmintPaymentService_OLD)(t),{listenToEvents:l}=(0,F.crossmintUiService_OLD)({environment:t.environment}),[c]=(0,g.useState)(r());return(0,g.useEffect)(()=>{let o=s(i=>{var m;return(m=t.onEvent)==null?void 0:m.call(t,i.data)});return()=>{o&&o()}},[]),(0,g.useEffect)(()=>{let o=l(i=>{let{type:m,payload:a}=i.data;switch(m){case"ui:height.changed":n(a.height);break;default:return}});return()=>{o&&o()}},[]),(0,g.useEffect)(()=>{d({recipient:t.recipient,mintConfig:t.mintConfig,locale:t.locale,whPassThroughArgs:t.whPassThroughArgs})},[t.recipient,t.mintConfig,t.locale,t.whPassThroughArgs]),(0,st.jsx)("iframe",{src:c,id:"crossmint-embedded-checkout.iframe",role:"crossmint-embedded-checkout.iframe",allow:"payment *",style:{border:"none !important",padding:"0px !important",width:"100% !important",minWidth:"100% !important",overflow:"hidden !important",display:"block !important",userSelect:"none",transform:"translate(0px) !important",opacity:"1",transition:"ease 0s, opacity 0.4s ease 0.1s",height:`${e}px`}})}var G=require("react/jsx-runtime");function At(t){if((0,O.isFiatEmbeddedCheckoutProps)(t))return(0,G.jsx)(it,u({},t));if((0,O.isCryptoEmbeddedCheckoutProps)(t))return(0,G.jsx)(ot,u({},t));throw new Error("Unsupported: Fiat is the only supported payment method.")}var lt=require("react"),ut=require("react"),b=require("@crossmint/client-sdk-base");var L=require("react");function Y(){let[t,e]=(0,L.useState)(!0);return(0,L.useEffect)(()=>{e(!1)},[]),{isServerSideRendering:t}}var mt=require("react-jss"),Dt="#1e1e1e",at=t=>t==="light",ct=t=>({buttonBgColor:at(t)?"white":Dt,paragraphColor:at(t)?"black":"white"}),dt=(0,mt.createUseStyles)({"@global":{"@import":"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')"},crossmintButton:{display:"flex","flex-direction":"row","align-items":"center",padding:"0.875rem 0.875rem","font-weight":"900",transition:"opacity ease-in-out 0.25s","border-radius":"0.5rem","font-family":'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif',outline:"none",border:"none","box-shadow":"0px 8px 15px rgba(0, 0, 0, 0.1)","justify-content":"center",background:({buttonBgColor:t})=>t,"&:hover:enabled":{opacity:"0.6",cursor:"pointer"}},crossmintImg:{width:"21px",height:"21px","margin-right":"0.875rem"},crossmintParagraph:{color:({paragraphColor:t})=>t,margin:"0"}});var h=require("react/jsx-runtime");function Ht(t){let z=t,{className:e,disabled:n,onClick:r,style:s,tabIndex:d,theme:l="dark",mintTo:c,emailTo:o,listingId:i,auctionId:m,showOverlay:a=!0,mintConfig:C,whPassThroughArgs:f,environment:R,paymentMethod:S,preferredSigninMethod:pt,dismissOverlayOnClick:ht,prepay:gt,locale:W="en-US",currency:Ct="usd",successCallbackURL:ft="",failureCallbackURL:yt="",loginEmail:Et="",projectId:bt,getButtonText:_,checkoutProps:$={experimental:!1,display:"same-tab",paymentMethods:["fiat","ETH","SOL"]}}=z,M=T(z,["className","disabled","onClick","style","tabIndex","theme","mintTo","emailTo","listingId","auctionId","showOverlay","mintConfig","whPassThroughArgs","environment","paymentMethod","preferredSigninMethod","dismissOverlayOnClick","prepay","locale","currency","successCallbackURL","failureCallbackURL","loginEmail","projectId","getButtonText","checkoutProps"]),Pt="clientId"in M?M.clientId:M.collectionId,[I,St]=(0,ut.useState)(!1),{isServerSideRendering:It}=Y(),{connect:kt}=(0,b.crossmintModalService)({clientId:Pt,projectId:bt,showOverlay:a,dismissOverlayOnClick:ht,setConnecting:St,libVersion:y,environment:R,clientName:b.clientNames.reactUi,locale:W,currency:Ct,successCallbackURL:ft,failureCallbackURL:yt,loginEmail:Et}),{getButtonText:Tt,handleClick:vt}=(0,b.crossmintPayButtonService)({onClick:r,connecting:I,paymentMethod:S,locale:W,checkoutProps:$}),wt=Nt=>vt(Nt,()=>{kt(C,c,o,i,f,S,pt,gt,$)}),U=dt(ct(l)),xt=(0,lt.useMemo)(()=>(0,h.jsx)("span",{className:U.crossmintParagraph,role:"button-paragraph",children:_!=null?_(I,S||"fiat"):Tt(I)}),[I,_,S]);return(0,h.jsx)(h.Fragment,{children:!It&&(0,h.jsxs)("button",{className:`${U.crossmintButton} ${e||""}`,disabled:n,onClick:wt,style:u({},s),tabIndex:d,children:[(0,h.jsx)("img",{className:U.crossmintImg,src:"https://www.crossmint.io/assets/crossmint/logo.svg",alt:"Crossmint logo"}),xt]})})}var B=require("@crossmint/client-sdk-base");0&&(module.exports={CrossmintEvents,CrossmintNFTCollectionView,CrossmintNFTDetail,CrossmintPayButton,CrossmintPaymentElement,useCrossmintEvents});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/components/CrossmintNFTCollectionView.tsx","../src/consts/version.ts","../src/components/CrossmintNFTDetail.tsx","../src/components/embed/index.tsx","../src/components/embed/FiatPaymentElement_OLD.tsx","../src/components/hosted/CrossmintPayButton.tsx","../src/hooks/useEnvironment.ts","../src/components/hosted/styles.ts"],"sourcesContent":["export * from \"./components\";\n\nexport { CrossmintEvents, useCrossmintEvents } from \"@crossmint/client-sdk-base\";\nexport type { CrossmintEvent, CrossmintEventMap } from \"@crossmint/client-sdk-base\";\n","import {\n NFTCollectionViewProps,\n assertValidNFTCollectionViewProps,\n getNFTCollectionViewSrc,\n} from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTCollectionView(props: NFTCollectionViewProps) {\n assertValidNFTCollectionViewProps(props);\n\n const src = getNFTCollectionViewSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-collection-view\"\n />\n );\n}\n","export const LIB_VERSION = \"1.1.0-alpha.0\";\n","import { NFTDetailProps, assertValidValidateNFTDetailProps, getNFTDetailSrc } from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTDetail(props: NFTDetailProps) {\n assertValidValidateNFTDetailProps(props);\n\n const src = getNFTDetailSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-details\"\n />\n );\n}\n","import {\n CrossmintEmbeddedCheckoutProps,\n isCryptoEmbeddedCheckoutProps,\n isFiatEmbeddedCheckoutProps,\n} from \"@crossmint/client-sdk-base\";\n\nimport { CrossmintCryptoEmbeddedCheckout } from \"./CryptoEmbeddedCheckout\";\nimport { CrossmintFiatPaymentElement_OLD } from \"./FiatPaymentElement_OLD\";\n\n// TODO: Rename to CrossmintEmbeddedCheckout\nexport function CrossmintPaymentElement(props: CrossmintEmbeddedCheckoutProps) {\n if (isFiatEmbeddedCheckoutProps(props)) {\n return <CrossmintFiatPaymentElement_OLD {...props} />;\n }\n if (isCryptoEmbeddedCheckoutProps(props)) {\n throw new Error(\"Unsupported: Fiat is the only supported payment method.\");\n // return <CrossmintCryptoEmbeddedCheckout {...props} />;\n }\n throw new Error(\"Unsupported: Fiat is the only supported payment method.\");\n}\n","import { useEffect, useState } from \"react\";\n\nimport type { FiatEmbeddedCheckoutProps } from \"@crossmint/client-sdk-base\";\nimport { crossmintPaymentService_OLD, crossmintUiService_OLD } from \"@crossmint/client-sdk-base\";\n\nexport function CrossmintFiatPaymentElement_OLD(props: FiatEmbeddedCheckoutProps) {\n const [height, setHeight] = useState(0);\n const { getIframeUrl, listenToEvents, emitQueryParams } = crossmintPaymentService_OLD(props);\n const { listenToEvents: listenToUiEvents } = crossmintUiService_OLD({ environment: props.environment });\n const [url] = useState(getIframeUrl());\n\n useEffect(() => {\n const clearListener = listenToEvents((event) => props.onEvent?.(event.data));\n\n return () => {\n if (clearListener) {\n clearListener();\n }\n };\n }, []);\n\n useEffect(() => {\n const clearListener = listenToUiEvents((event: MessageEvent<any>) => {\n const { type, payload } = event.data;\n\n switch (type) {\n case \"ui:height.changed\":\n setHeight(payload.height);\n break;\n default:\n return;\n }\n });\n\n return () => {\n if (clearListener) {\n clearListener();\n }\n };\n }, []);\n\n useEffect(() => {\n emitQueryParams({\n recipient: props.recipient,\n mintConfig: props.mintConfig,\n locale: props.locale,\n whPassThroughArgs: props.whPassThroughArgs,\n });\n }, [props.recipient, props.mintConfig, props.locale, props.whPassThroughArgs]);\n\n return (\n <iframe\n src={url}\n id=\"crossmint-embedded-checkout.iframe\"\n role=\"crossmint-embedded-checkout.iframe\"\n allow=\"payment *\"\n style={{\n border: \"none !important\",\n padding: \"0px !important\",\n width: \"100% !important\",\n minWidth: \"100% !important\",\n overflow: \"hidden !important\",\n display: \"block !important\",\n userSelect: \"none\",\n transform: \"translate(0px) !important\",\n opacity: \"1\",\n transition: \"ease 0s, opacity 0.4s ease 0.1s\",\n height: `${height}px`,\n }}\n ></iframe>\n );\n}\n","import { CSSProperties, MouseEvent, useMemo } from \"react\";\nimport { useState } from \"react\";\n\nimport {\n CrossmintPayButtonProps,\n clientNames,\n crossmintModalService,\n crossmintPayButtonService,\n} from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../../consts/version\";\nimport useEnvironment from \"../../hooks/useEnvironment\";\nimport { formatProps, useStyles } from \"./styles\";\n\nexport type CrossmintPayButtonReactProps = CrossmintPayButtonProps & {\n onClick?: (e: MouseEvent<HTMLButtonElement>) => void;\n style?: CSSProperties;\n};\n\nexport function CrossmintPayButton(buttonProps: CrossmintPayButtonReactProps) {\n const {\n className,\n disabled,\n onClick,\n style,\n tabIndex,\n theme = \"dark\",\n mintTo,\n emailTo,\n listingId,\n auctionId,\n showOverlay = true,\n mintConfig,\n whPassThroughArgs,\n environment,\n paymentMethod,\n preferredSigninMethod,\n dismissOverlayOnClick,\n prepay,\n locale = \"en-US\",\n currency = \"usd\",\n successCallbackURL = \"\",\n failureCallbackURL = \"\",\n loginEmail = \"\",\n projectId,\n getButtonText,\n ...props\n } = buttonProps;\n\n const collectionId = \"clientId\" in props ? props.clientId : props.collectionId;\n\n const [connecting, setConnecting] = useState(false);\n const { isServerSideRendering } = useEnvironment();\n\n const { connect } = crossmintModalService({\n clientId: collectionId,\n projectId,\n showOverlay,\n dismissOverlayOnClick,\n setConnecting,\n libVersion: LIB_VERSION,\n environment,\n clientName: clientNames.reactUi,\n locale,\n currency,\n successCallbackURL,\n failureCallbackURL,\n loginEmail,\n });\n\n const { getButtonText: getButtonTextInternal, handleClick } = crossmintPayButtonService({\n onClick,\n connecting,\n paymentMethod,\n locale,\n });\n\n const _handleClick = (event: MouseEvent<HTMLButtonElement>) =>\n handleClick(event, () => {\n connect(\n mintConfig,\n mintTo,\n emailTo,\n listingId,\n whPassThroughArgs,\n paymentMethod,\n preferredSigninMethod,\n prepay\n );\n });\n\n const classes = useStyles(formatProps(theme));\n\n const content = useMemo(() => {\n return (\n <span className={classes.crossmintParagraph} role=\"button-paragraph\">\n {getButtonText != null\n ? getButtonText(connecting, paymentMethod || \"fiat\")\n : getButtonTextInternal(connecting)}\n </span>\n );\n }, [connecting, getButtonText, paymentMethod]);\n\n return (\n <>\n {!isServerSideRendering && (\n <button\n className={`${classes.crossmintButton} ${className || \"\"}`}\n disabled={disabled}\n onClick={_handleClick}\n style={{ ...style }}\n tabIndex={tabIndex}\n >\n <img\n className={classes.crossmintImg}\n src=\"https://www.crossmint.io/assets/crossmint/logo.svg\"\n alt=\"Crossmint logo\"\n />\n {content}\n </button>\n )}\n </>\n );\n}\n","import { useEffect, useState } from \"react\";\r\n\r\nexport default function useEnvironment() {\r\n const [isServerSideRendering, setIsServerSideRendering] = useState(true);\r\n useEffect(() => {\r\n setIsServerSideRendering(false);\r\n }, []);\r\n\r\n return { isServerSideRendering };\r\n}\r\n","import { createUseStyles } from \"react-jss\";\n\nconst DARK_BG = \"#1e1e1e\";\n\ninterface CustomStylingProps {\n buttonBgColor?: string;\n paragraphColor?: string;\n}\n\nconst themeIsLight = (theme: string) => theme === \"light\";\n\nexport const formatProps = (theme: string): CustomStylingProps => ({\n buttonBgColor: themeIsLight(theme) ? \"white\" : DARK_BG,\n paragraphColor: themeIsLight(theme) ? \"black\" : \"white\",\n});\n\nexport const useStyles = createUseStyles({\n \"@global\": {\n \"@import\":\n \"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')\",\n },\n crossmintButton: {\n display: \"flex\",\n \"flex-direction\": \"row\",\n \"align-items\": \"center\",\n padding: \"0.875rem 0.875rem\",\n \"font-weight\": \"900\",\n transition: \"opacity ease-in-out 0.25s\",\n \"border-radius\": \"0.5rem\",\n \"font-family\": `\"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif`,\n outline: \"none\",\n border: \"none\",\n \"box-shadow\": \"0px 8px 15px rgba(0, 0, 0, 0.1)\",\n \"justify-content\": \"center\",\n background: ({ buttonBgColor }: CustomStylingProps) => buttonBgColor,\n\n \"&:hover:enabled\": {\n opacity: \"0.6\",\n cursor: \"pointer\",\n },\n },\n crossmintImg: {\n width: \"21px\",\n height: \"21px\",\n \"margin-right\": \"0.875rem\",\n },\n crossmintParagraph: {\n color: ({ paragraphColor }: CustomStylingProps) => paragraphColor,\n margin: \"0\",\n },\n});\n"],"mappings":"s2BAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,sEAAAE,GAAA,uBAAAC,GAAA,uBAAAC,GAAA,4BAAAC,GAAA,6DAAAC,GAAAN,ICAA,IAAAO,EAIO,sCCJA,IAAMC,EAAc,gBDcnB,IAAAC,EAAA,6BAND,SAASC,GAA2BC,EAA+B,IACtE,qCAAkCA,CAAK,EAEvC,IAAMC,KAAM,2BAAwBD,EAAOE,CAAW,EAEtD,SACI,OAAC,UACG,IAAKD,EACL,MAAM,OACN,OAAO,OACP,MAAO,CACH,SAAU,IACV,OAAQ,OACR,OAAQ,IACR,QAAS,GACb,EACA,KAAK,sBACT,CAER,CE3BA,IAAAE,EAAmF,sCAU3E,IAAAC,EAAA,6BAND,SAASC,GAAmBC,EAAuB,IACtD,qCAAkCA,CAAK,EAEvC,IAAMC,KAAM,mBAAgBD,EAAOE,CAAW,EAE9C,SACI,OAAC,UACG,IAAKD,EACL,MAAM,OACN,OAAO,OACP,MAAO,CACH,SAAU,IACV,OAAQ,OACR,OAAQ,IACR,QAAS,GACb,EACA,KAAK,cACT,CAER,CCvBA,IAAAE,EAIO,sCCJP,IAAAC,EAAoC,iBAGpCC,EAAoE,sCAgD5DC,EAAA,6BA9CD,SAASC,EAAgCC,EAAkC,CAC9E,GAAM,CAACC,EAAQC,CAAS,KAAI,YAAS,CAAC,EAChC,CAAE,aAAAC,EAAc,eAAAC,EAAgB,gBAAAC,CAAgB,KAAI,+BAA4BL,CAAK,EACrF,CAAE,eAAgBM,CAAiB,KAAI,0BAAuB,CAAE,YAAaN,EAAM,WAAY,CAAC,EAChG,CAACO,CAAG,KAAI,YAASJ,EAAa,CAAC,EAErC,sBAAU,IAAM,CACZ,IAAMK,EAAgBJ,EAAgBK,GAAO,CAZrD,IAAAC,EAYwD,OAAAA,EAAAV,EAAM,UAAN,YAAAU,EAAA,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ACA,qBACA,qBACA,aACA,YACA,kBAIE4B,GAAe,aAAcF,EAAQA,EAAM,SAAWA,EAAM,aAE5D,CAACG,EAAYC,EAAa,KAAI,YAAS,EAAK,EAC5C,CAAE,sBAAAC,EAAsB,EAAIC,EAAe,EAE3C,CAAE,QAAAC,EAAQ,KAAI,yBAAsB,CACtC,SAAUL,GACV,UAAAJ,GACA,YAAAb,EACA,sBAAAM,EACA,cAAAa,GACA,WAAYI,EACZ,YAAApB,EACA,WAAY,cAAY,QACxB,OAAAK,EACA,SAAAC,GACA,mBAAAC,GACA,mBAAAC,GACA,WAAAC,EACJ,CAAC,EAEK,CAAE,cAAeY,GAAuB,YAAAC,EAAY,KAAI,6BAA0B,CACpF,QAAAjC,EACA,WAAA0B,EACA,cAAAd,EACA,OAAAI,CACJ,CAAC,EAEKkB,GAAgBC,IAClBF,GAAYE,GAAO,IAAM,CACrBL,GACIrB,EACAL,EACAC,EACAC,EACAI,EACAE,EACAC,EACAE,CACJ,CACJ,CAAC,EAECqB,EAAUC,EAAUC,EAAYnC,CAAK,CAAC,EAEtCoC,MAAU,WAAQ,OAEhB,OAAC,QAAK,UAAWH,EAAQ,mBAAoB,KAAK,mBAC7C,SAAAd,GAAiB,KACZA,EAAcI,EAAYd,GAAiB,MAAM,EACjDoB,GAAsBN,CAAU,EAC1C,EAEL,CAACA,EAAYJ,EAAeV,CAAa,CAAC,EAE7C,SACI,mBACK,UAACgB,OACE,QAAC,UACG,UAAW,GAAGQ,EAAQ,eAAe,IAAItC,GAAa,EAAE,GACxD,SAAUC,EACV,QAASmC,GACT,MAAOM,EAAA,GAAKvC,GACZ,SAAUC,EAEV,oBAAC,OACG,UAAWkC,EAAQ,aACnB,IAAI,qDACJ,IAAI,iBACR,EACCG,IACL,EAER,CAER,CNzHA,IAAAE,EAAoD","names":["src_exports","__export","CrossmintNFTCollectionView","CrossmintNFTDetail","CrossmintPayButton","CrossmintPaymentElement","__toCommonJS","import_client_sdk_base","LIB_VERSION","import_jsx_runtime","CrossmintNFTCollectionView","props","src","LIB_VERSION","import_client_sdk_base","import_jsx_runtime","CrossmintNFTDetail","props","src","LIB_VERSION","import_client_sdk_base","import_react","import_client_sdk_base","import_jsx_runtime","CrossmintFiatPaymentElement_OLD","props","height","setHeight","getIframeUrl","listenToEvents","emitQueryParams","listenToUiEvents","url","clearListener","event","_a","type","payload","import_jsx_runtime","CrossmintPaymentElement","props","CrossmintFiatPaymentElement_OLD","__spreadValues","import_react","import_client_sdk_base","import_react","useEnvironment","isServerSideRendering","setIsServerSideRendering","import_react_jss","DARK_BG","themeIsLight","theme","formatProps","useStyles","buttonBgColor","paragraphColor","import_jsx_runtime","CrossmintPayButton","buttonProps","_a","className","disabled","onClick","style","tabIndex","theme","mintTo","emailTo","listingId","auctionId","showOverlay","mintConfig","whPassThroughArgs","environment","paymentMethod","preferredSigninMethod","dismissOverlayOnClick","prepay","locale","currency","successCallbackURL","failureCallbackURL","loginEmail","projectId","getButtonText","props","__objRest","collectionId","connecting","setConnecting","isServerSideRendering","useEnvironment","connect","LIB_VERSION","getButtonTextInternal","handleClick","_handleClick","event","classes","useStyles","formatProps","content","__spreadValues","import_client_sdk_base"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/components/CrossmintNFTCollectionView.tsx","../src/consts/version.ts","../src/components/CrossmintNFTDetail.tsx","../src/components/embed/index.tsx","../src/components/embed/crypto/CryptoEmbeddedCheckout.tsx","../src/components/embed/crypto/CryptoEmbeddedCheckoutIFrame.tsx","../src/components/embed/EmbeddedCheckoutIFrame.tsx","../src/components/embed/fiat/FiatPaymentElement_OLD.tsx","../src/components/hosted/CrossmintPayButton.tsx","../src/hooks/useEnvironment.ts","../src/components/hosted/styles.ts"],"sourcesContent":["export * from \"./components\";\n\nexport { CrossmintEvents, useCrossmintEvents } from \"@crossmint/client-sdk-base\";\nexport type { CrossmintEvent, CrossmintEventMap } from \"@crossmint/client-sdk-base\";\n","import {\n NFTCollectionViewProps,\n assertValidNFTCollectionViewProps,\n getNFTCollectionViewSrc,\n} from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTCollectionView(props: NFTCollectionViewProps) {\n assertValidNFTCollectionViewProps(props);\n\n const src = getNFTCollectionViewSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-collection-view\"\n />\n );\n}\n","export const LIB_VERSION = \"1.1.0-alpha.2\";\n","import { NFTDetailProps, assertValidValidateNFTDetailProps, getNFTDetailSrc } from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTDetail(props: NFTDetailProps) {\n assertValidValidateNFTDetailProps(props);\n\n const src = getNFTDetailSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-details\"\n />\n );\n}\n","import {\n CrossmintEmbeddedCheckoutProps,\n isCryptoEmbeddedCheckoutProps,\n isFiatEmbeddedCheckoutProps,\n} from \"@crossmint/client-sdk-base\";\n\nimport { CrossmintCryptoEmbeddedCheckout } from \"./crypto/CryptoEmbeddedCheckout\";\nimport { CrossmintFiatPaymentElement_OLD } from \"./fiat/FiatPaymentElement_OLD\";\n\n// TODO: Rename to CrossmintEmbeddedCheckout\nexport function CrossmintPaymentElement(props: CrossmintEmbeddedCheckoutProps) {\n if (isFiatEmbeddedCheckoutProps(props)) {\n return <CrossmintFiatPaymentElement_OLD {...props} />;\n }\n if (isCryptoEmbeddedCheckoutProps(props)) {\n return <CrossmintCryptoEmbeddedCheckout {...props} />;\n }\n throw new Error(\"Unsupported: Fiat is the only supported payment method.\");\n}\n","import { CryptoEmbeddedCheckoutProps, isCryptoEmbeddedCheckoutPropsWithSigner } from \"@crossmint/client-sdk-base\";\n\nimport CryptoEmbeddedCheckoutIFrame from \"./CryptoEmbeddedCheckoutIFrame\";\n\nexport function CrossmintCryptoEmbeddedCheckout(props: CryptoEmbeddedCheckoutProps) {\n if (!isCryptoEmbeddedCheckoutPropsWithSigner(props)) {\n throw new Error(\"Invalid parameters: signer is required in versions < 2.0.0\");\n }\n\n return <CryptoEmbeddedCheckoutIFrame {...props} />;\n}\n","import bs58 from \"bs58\";\nimport { useEffect } from \"react\";\n\nimport {\n CryptoEmbeddedCheckoutPropsWithSigner,\n ETHEmbeddedCheckoutSigner,\n IncomingInternalEvent,\n IncomingInternalEvents,\n OutgoingInternalEvents,\n SOLEmbeddedCheckoutSigner,\n crossmintIFrameService,\n embeddedCheckoutPropsToUpdatableParamsPayload,\n} from \"@crossmint/client-sdk-base\";\n\nimport CrossmintEmbeddedCheckoutIFrame from \"../EmbeddedCheckoutIFrame\";\n\nexport default function CryptoEmbeddedCheckoutIFrame(props: CryptoEmbeddedCheckoutPropsWithSigner) {\n const { emitInternalEvent } = crossmintIFrameService(props);\n\n const { signer, paymentMethod } = props;\n\n function onInternalEvent(event: IncomingInternalEvent) {\n const { type, payload } = event;\n\n if (type === IncomingInternalEvents.CRYPTO_PAYMENT_INCOMING_TRANSACTION) {\n const { serializedTransaction } = payload;\n console.log(\"[Crossmint] Received incoming transaction\", serializedTransaction);\n handleIncomingTransaction(serializedTransaction);\n }\n }\n\n async function handleIncomingTransaction(serializedTransaction: string) {\n try {\n let txId: string;\n switch (paymentMethod) {\n case \"SOL\":\n txId = await handleSOLTransaction(signer, serializedTransaction);\n break;\n case \"ETH\":\n txId = await handleETHTransaction(signer, serializedTransaction);\n break;\n default:\n throw new Error(`Unsupported payment method ${paymentMethod}`);\n }\n\n console.log(\"[Crossmint] Signed and sent transaction\", txId);\n emitInternalEvent({\n type: OutgoingInternalEvents.CRYPTO_PAYMENT_USER_ACCEPTED,\n payload: {\n txId,\n },\n });\n } catch (e) {\n console.error(\"[Crossmint] Failed to sign and send transaction\", e);\n emitInternalEvent({\n type: OutgoingInternalEvents.CRYPTO_PAYMENT_USER_REJECTED,\n payload: {},\n });\n }\n }\n\n async function handleSOLTransaction(signer: SOLEmbeddedCheckoutSigner, serializedTransaction: string) {\n // @ts-ignore - Error becasue we dont use 'module' field in tsconfig, which is expected because we use tsup to compile\n const { Transaction } = await import(\"@solana/web3.js\");\n const transaction = Transaction.from(bs58.decode(serializedTransaction));\n console.log(\"[Crossmint] Deserialized SOL transaction\", transaction);\n\n return await signer.signAndSendTransaction(transaction);\n }\n\n async function handleETHTransaction(signer: ETHEmbeddedCheckoutSigner, serializedTransaction: string) {\n // @ts-ignore - Error becasue we dont use 'module' field in tsconfig, which is expected because we use tsup to compile\n const { parse: parseTransaction } = await import(\"@ethersproject/transactions\");\n const transaction = parseTransaction(serializedTransaction);\n console.log(\"[Crossmint] Deserialized ETH transaction\", transaction);\n\n return await signer.signAndSendTransaction(transaction);\n }\n\n useEffect(() => {\n emitInternalEvent({\n type: \"params-update\",\n payload: embeddedCheckoutPropsToUpdatableParamsPayload(props),\n });\n }, [props.signer, props.recipient, props.mintConfig, props.locale, props.whPassThroughArgs]);\n\n return <CrossmintEmbeddedCheckoutIFrame onInternalEvent={onInternalEvent} {...props} />;\n}\n","import { useEffect, useState } from \"react\";\n\nimport { IncomingInternalEvent, IncomingInternalEvents, crossmintIFrameService } from \"@crossmint/client-sdk-base\";\nimport { CrossmintEmbeddedCheckoutProps } from \"@crossmint/client-sdk-base\";\n\ntype CrossmintEmbeddedCheckoutIFrameProps = CrossmintEmbeddedCheckoutProps & {\n onInternalEvent?: (event: IncomingInternalEvent) => void;\n};\n\nexport default function CrossmintEmbeddedCheckoutIFrame({\n onInternalEvent,\n ...props\n}: CrossmintEmbeddedCheckoutIFrameProps) {\n const { getUrl, listenToEvents, listenToInternalEvents, emitInternalEvent } = crossmintIFrameService(props);\n\n const [height, setHeight] = useState(0);\n const [url] = useState(getUrl(props));\n\n // Public events\n useEffect(() => {\n const clearListener = listenToEvents((event) => {\n props.onEvent?.(event.data);\n });\n\n return () => {\n clearListener();\n };\n }, []);\n\n // Internal events\n useEffect(() => {\n const clearListener = listenToInternalEvents((event) => {\n const { type, payload } = event.data;\n\n if (type === IncomingInternalEvents.UI_HEIGHT_CHANGED) {\n setHeight(payload.height);\n }\n\n onInternalEvent?.(event.data);\n });\n\n return () => {\n clearListener();\n };\n }, []);\n\n // TODO: Emit updatable parameters\n\n return (\n <iframe\n src={url}\n id=\"crossmint-embedded-checkout.iframe\"\n role=\"crossmint-embedded-checkout.iframe\"\n allow=\"payment *\"\n style={{\n border: \"none !important\",\n padding: \"0px !important\",\n width: \"100% !important\",\n minWidth: \"100% !important\",\n overflow: \"hidden !important\",\n display: \"block !important\",\n userSelect: \"none\",\n transform: \"translate(0px) !important\",\n opacity: \"1\",\n transition: \"ease 0s, opacity 0.4s ease 0.1s\",\n height: `${height}px`,\n }}\n />\n );\n}\n","import { useEffect, useState } from \"react\";\n\nimport type { FiatEmbeddedCheckoutProps } from \"@crossmint/client-sdk-base\";\nimport { crossmintPaymentService_OLD, crossmintUiService_OLD } from \"@crossmint/client-sdk-base\";\n\nexport function CrossmintFiatPaymentElement_OLD(props: FiatEmbeddedCheckoutProps) {\n const [height, setHeight] = useState(0);\n const { getIframeUrl, listenToEvents, emitQueryParams } = crossmintPaymentService_OLD(props);\n const { listenToEvents: listenToUiEvents } = crossmintUiService_OLD({ environment: props.environment });\n const [url] = useState(getIframeUrl());\n\n useEffect(() => {\n const clearListener = listenToEvents((event) => props.onEvent?.(event.data));\n\n return () => {\n if (clearListener) {\n clearListener();\n }\n };\n }, []);\n\n useEffect(() => {\n const clearListener = listenToUiEvents((event: MessageEvent<any>) => {\n const { type, payload } = event.data;\n\n switch (type) {\n case \"ui:height.changed\":\n setHeight(payload.height);\n break;\n default:\n return;\n }\n });\n\n return () => {\n if (clearListener) {\n clearListener();\n }\n };\n }, []);\n\n useEffect(() => {\n emitQueryParams({\n recipient: props.recipient,\n mintConfig: props.mintConfig,\n locale: props.locale,\n whPassThroughArgs: props.whPassThroughArgs,\n });\n }, [props.recipient, props.mintConfig, props.locale, props.whPassThroughArgs]);\n\n return (\n <iframe\n src={url}\n id=\"crossmint-embedded-checkout.iframe\"\n role=\"crossmint-embedded-checkout.iframe\"\n allow=\"payment *\"\n style={{\n border: \"none !important\",\n padding: \"0px !important\",\n width: \"100% !important\",\n minWidth: \"100% !important\",\n overflow: \"hidden !important\",\n display: \"block !important\",\n userSelect: \"none\",\n transform: \"translate(0px) !important\",\n opacity: \"1\",\n transition: \"ease 0s, opacity 0.4s ease 0.1s\",\n height: `${height}px`,\n }}\n ></iframe>\n );\n}\n","import { CSSProperties, MouseEvent, useMemo } from \"react\";\nimport { useState } from \"react\";\n\nimport {\n CrossmintPayButtonProps,\n clientNames,\n crossmintModalService,\n crossmintPayButtonService, CheckoutProps,\n} from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../../consts/version\";\nimport useEnvironment from \"../../hooks/useEnvironment\";\nimport { formatProps, useStyles } from \"./styles\";\n\nexport type CrossmintPayButtonReactProps = CrossmintPayButtonProps & {\n onClick?: (e: MouseEvent<HTMLButtonElement>) => void;\n style?: CSSProperties;\n};\n\nexport function CrossmintPayButton(buttonProps: CrossmintPayButtonReactProps) {\n const {\n className,\n disabled,\n onClick,\n style,\n tabIndex,\n theme = \"dark\",\n mintTo,\n emailTo,\n listingId,\n auctionId,\n showOverlay = true,\n mintConfig,\n whPassThroughArgs,\n environment,\n paymentMethod,\n preferredSigninMethod,\n dismissOverlayOnClick,\n prepay,\n locale = \"en-US\",\n currency = \"usd\",\n successCallbackURL = \"\",\n failureCallbackURL = \"\",\n loginEmail = \"\",\n projectId,\n getButtonText,\n checkoutProps = {\n experimental: false,\n display: \"same-tab\",\n paymentMethods: [\"fiat\", \"ETH\", \"SOL\"],\n } as CheckoutProps,\n ...props\n } = buttonProps;\n\n const collectionId = \"clientId\" in props ? props.clientId : props.collectionId;\n\n const [connecting, setConnecting] = useState(false);\n const { isServerSideRendering } = useEnvironment();\n\n const { connect } = crossmintModalService({\n clientId: collectionId,\n projectId,\n showOverlay,\n dismissOverlayOnClick,\n setConnecting,\n libVersion: LIB_VERSION,\n environment,\n clientName: clientNames.reactUi,\n locale,\n currency,\n successCallbackURL,\n failureCallbackURL,\n loginEmail,\n });\n\n const { getButtonText: getButtonTextInternal, handleClick } = crossmintPayButtonService({\n onClick,\n connecting,\n paymentMethod,\n locale,\n checkoutProps\n });\n\n const _handleClick = (event: MouseEvent<HTMLButtonElement>) =>\n handleClick(event, () => {\n connect(\n mintConfig,\n mintTo,\n emailTo,\n listingId,\n whPassThroughArgs,\n paymentMethod,\n preferredSigninMethod,\n prepay,\n checkoutProps\n );\n });\n\n const classes = useStyles(formatProps(theme));\n\n const content = useMemo(() => {\n return (\n <span className={classes.crossmintParagraph} role=\"button-paragraph\">\n {getButtonText != null\n ? getButtonText(connecting, paymentMethod || \"fiat\")\n : getButtonTextInternal(connecting)}\n </span>\n );\n }, [connecting, getButtonText, paymentMethod]);\n\n return (\n <>\n {!isServerSideRendering && (\n <button\n className={`${classes.crossmintButton} ${className || \"\"}`}\n disabled={disabled}\n onClick={_handleClick}\n style={{ ...style }}\n tabIndex={tabIndex}\n >\n <img\n className={classes.crossmintImg}\n src=\"https://www.crossmint.io/assets/crossmint/logo.svg\"\n alt=\"Crossmint logo\"\n />\n {content}\n </button>\n )}\n </>\n );\n}\n","import { useEffect, useState } from \"react\";\r\n\r\nexport default function useEnvironment() {\r\n const [isServerSideRendering, setIsServerSideRendering] = useState(true);\r\n useEffect(() => {\r\n setIsServerSideRendering(false);\r\n }, []);\r\n\r\n return { isServerSideRendering };\r\n}\r\n","import { createUseStyles } from \"react-jss\";\n\nconst DARK_BG = \"#1e1e1e\";\n\ninterface CustomStylingProps {\n buttonBgColor?: string;\n paragraphColor?: string;\n}\n\nconst themeIsLight = (theme: string) => theme === \"light\";\n\nexport const formatProps = (theme: string): CustomStylingProps => ({\n buttonBgColor: themeIsLight(theme) ? \"white\" : DARK_BG,\n paragraphColor: themeIsLight(theme) ? \"black\" : \"white\",\n});\n\nexport const useStyles = createUseStyles({\n \"@global\": {\n \"@import\":\n \"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')\",\n },\n crossmintButton: {\n display: \"flex\",\n \"flex-direction\": \"row\",\n \"align-items\": \"center\",\n padding: \"0.875rem 0.875rem\",\n \"font-weight\": \"900\",\n transition: \"opacity ease-in-out 0.25s\",\n \"border-radius\": \"0.5rem\",\n \"font-family\": `\"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif`,\n outline: \"none\",\n border: \"none\",\n \"box-shadow\": \"0px 8px 15px rgba(0, 0, 0, 0.1)\",\n \"justify-content\": \"center\",\n background: ({ buttonBgColor }: CustomStylingProps) => buttonBgColor,\n\n \"&:hover:enabled\": {\n opacity: \"0.6\",\n cursor: \"pointer\",\n },\n },\n crossmintImg: {\n width: \"21px\",\n height: \"21px\",\n \"margin-right\": \"0.875rem\",\n },\n crossmintParagraph: {\n color: ({ paragraphColor }: CustomStylingProps) => paragraphColor,\n margin: \"0\",\n },\n});\n"],"mappings":"ksCAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,sEAAAE,GAAA,uBAAAC,GAAA,uBAAAC,GAAA,4BAAAC,GAAA,6DAAAC,GAAAN,ICAA,IAAAO,EAIO,sCCJA,IAAMC,EAAc,gBDcnB,IAAAC,EAAA,6BAND,SAASC,GAA2BC,EAA+B,IACtE,qCAAkCA,CAAK,EAEvC,IAAMC,KAAM,2BAAwBD,EAAOE,CAAW,EAEtD,SACI,OAAC,UACG,IAAKD,EACL,MAAM,OACN,OAAO,OACP,MAAO,CACH,SAAU,IACV,OAAQ,OACR,OAAQ,IACR,QAAS,GACb,EACA,KAAK,sBACT,CAER,CE3BA,IAAAE,EAAmF,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","CrossmintNFTDetail","CrossmintPayButton","CrossmintPaymentElement","__toCommonJS","import_client_sdk_base","LIB_VERSION","import_jsx_runtime","CrossmintNFTCollectionView","props","src","LIB_VERSION","import_client_sdk_base","import_jsx_runtime","CrossmintNFTDetail","props","src","LIB_VERSION","import_client_sdk_base","import_client_sdk_base","import_bs58","import_react","import_client_sdk_base","import_react","import_client_sdk_base","import_jsx_runtime","CrossmintEmbeddedCheckoutIFrame","_a","_b","onInternalEvent","props","__objRest","getUrl","listenToEvents","listenToInternalEvents","emitInternalEvent","height","setHeight","url","clearListener","event","type","payload","import_jsx_runtime","CryptoEmbeddedCheckoutIFrame","props","emitInternalEvent","signer","paymentMethod","onInternalEvent","event","type","payload","serializedTransaction","handleIncomingTransaction","__async","txId","handleSOLTransaction","handleETHTransaction","e","Transaction","transaction","bs58","parseTransaction","CrossmintEmbeddedCheckoutIFrame","__spreadValues","import_jsx_runtime","CrossmintCryptoEmbeddedCheckout","props","CryptoEmbeddedCheckoutIFrame","__spreadValues","import_react","import_client_sdk_base","import_jsx_runtime","CrossmintFiatPaymentElement_OLD","props","height","setHeight","getIframeUrl","listenToEvents","emitQueryParams","listenToUiEvents","url","clearListener","event","_a","type","payload","import_jsx_runtime","CrossmintPaymentElement","props","CrossmintFiatPaymentElement_OLD","__spreadValues","CrossmintCryptoEmbeddedCheckout","import_react","import_client_sdk_base","import_react","useEnvironment","isServerSideRendering","setIsServerSideRendering","import_react_jss","DARK_BG","themeIsLight","theme","formatProps","useStyles","buttonBgColor","paragraphColor","import_jsx_runtime","CrossmintPayButton","buttonProps","_a","className","disabled","onClick","style","tabIndex","theme","mintTo","emailTo","listingId","auctionId","showOverlay","mintConfig","whPassThroughArgs","environment","paymentMethod","preferredSigninMethod","dismissOverlayOnClick","prepay","locale","currency","successCallbackURL","failureCallbackURL","loginEmail","projectId","getButtonText","checkoutProps","props","__objRest","collectionId","connecting","setConnecting","isServerSideRendering","useEnvironment","connect","LIB_VERSION","getButtonTextInternal","handleClick","_handleClick","event","classes","useStyles","formatProps","content","__spreadValues","import_client_sdk_base"]}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ct=Object.defineProperty;var y=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var B=(t,e,n)=>e in t?ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,u=(t,e)=>{for(var n in e||(e={}))R.call(e,n)&&B(t,n,e[n]);if(y)for(var n of y(e))_.call(e,n)&&B(t,n,e[n]);return t};var E=(t,e)=>{var n={};for(var i in t)R.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&y)for(var i of y(t))e.indexOf(i)<0&&_.call(t,i)&&(n[i]=t[i]);return n};var b=(t,e,n)=>new Promise((i,m)=>{var d=o=>{try{c(n.next(o))}catch(r){m(r)}},l=o=>{try{c(n.throw(o))}catch(r){m(r)}},c=o=>o.done?i(o.value):Promise.resolve(o.value).then(d,l);c((n=n.apply(t,e)).next())});import{assertValidNFTCollectionViewProps as dt,getNFTCollectionViewSrc as lt}from"@crossmint/client-sdk-base";var g="1.1.0-alpha.2";import{jsx as ut}from"react/jsx-runtime";function Jt(t){dt(t);let e=lt(t,g);return ut("iframe",{src:e,width:"100%",height:"100%",style:{flexGrow:"1",border:"none",margin:"0",padding:"0"},role:"nft-collection-view"})}import{assertValidValidateNFTDetailProps as pt,getNFTDetailSrc as ht}from"@crossmint/client-sdk-base";import{jsx as gt}from"react/jsx-runtime";function te(t){pt(t);let e=ht(t,g);return gt("iframe",{src:e,width:"100%",height:"100%",style:{flexGrow:"1",border:"none",margin:"0",padding:"0"},role:"nft-details"})}import{isCryptoEmbeddedCheckoutProps as Ft,isFiatEmbeddedCheckoutProps as Ot}from"@crossmint/client-sdk-base";import{isCryptoEmbeddedCheckoutPropsWithSigner as Tt}from"@crossmint/client-sdk-base";import Et from"bs58";import{useEffect as bt}from"react";import{IncomingInternalEvents as Pt,OutgoingInternalEvents as A,crossmintIFrameService as St,embeddedCheckoutPropsToUpdatableParamsPayload as It}from"@crossmint/client-sdk-base";import{useEffect as M,useState as U}from"react";import{IncomingInternalEvents as Ct,crossmintIFrameService as ft}from"@crossmint/client-sdk-base";import{jsx as yt}from"react/jsx-runtime";function T(n){var i=n,{onInternalEvent:t}=i,e=E(i,["onInternalEvent"]);let{getUrl:m,listenToEvents:d,listenToInternalEvents:l,emitInternalEvent:c}=ft(e),[o,r]=U(0),[a]=U(m(e));return M(()=>{let s=d(p=>{var h;(h=e.onEvent)==null||h.call(e,p.data)});return()=>{s()}},[]),M(()=>{let s=l(p=>{let{type:h,payload:P}=p.data;h===Ct.UI_HEIGHT_CHANGED&&r(P.height),t==null||t(p.data)});return()=>{s()}},[]),yt("iframe",{src:a,id:"crossmint-embedded-checkout.iframe",role:"crossmint-embedded-checkout.iframe",allow:"payment *",style:{border:"none !important",padding:"0px !important",width:"100% !important",minWidth:"100% !important",overflow:"hidden !important",display:"block !important",userSelect:"none",transform:"translate(0px) !important",opacity:"1",transition:"ease 0s, opacity 0.4s ease 0.1s",height:`${o}px`}})}import{jsx as kt}from"react/jsx-runtime";function v(t){let{emitInternalEvent:e}=St(t),{signer:n,paymentMethod:i}=t;function m(o){let{type:r,payload:a}=o;if(r===Pt.CRYPTO_PAYMENT_INCOMING_TRANSACTION){let{serializedTransaction:s}=a;console.log("[Crossmint] Received incoming transaction",s),d(s)}}function d(o){return b(this,null,function*(){try{let r;switch(i){case"SOL":r=yield l(n,o);break;case"ETH":r=yield c(n,o);break;default:throw new Error(`Unsupported payment method ${i}`)}console.log("[Crossmint] Signed and sent transaction",r),e({type:A.CRYPTO_PAYMENT_USER_ACCEPTED,payload:{txId:r}})}catch(r){console.error("[Crossmint] Failed to sign and send transaction",r),e({type:A.CRYPTO_PAYMENT_USER_REJECTED,payload:{}})}})}function l(o,r){return b(this,null,function*(){let{Transaction:a}=yield import("@solana/web3.js"),s=a.from(Et.decode(r));return console.log("[Crossmint] Deserialized SOL transaction",s),yield o.signAndSendTransaction(s)})}function c(o,r){return b(this,null,function*(){let{parse:a}=yield import("@ethersproject/transactions"),s=a(r);return console.log("[Crossmint] Deserialized ETH transaction",s),yield o.signAndSendTransaction(s)})}return bt(()=>{e({type:"params-update",payload:It(t)})},[t.signer,t.recipient,t.mintConfig,t.locale,t.whPassThroughArgs]),kt(T,u({onInternalEvent:m},t))}import{jsx as vt}from"react/jsx-runtime";function D(t){if(!Tt(t))throw new Error("Invalid parameters: signer is required in versions < 2.0.0");return vt(v,u({},t))}import{useEffect as w,useState as H}from"react";import{crossmintPaymentService_OLD as wt,crossmintUiService_OLD as xt}from"@crossmint/client-sdk-base";import{jsx as Nt}from"react/jsx-runtime";function V(t){let[e,n]=H(0),{getIframeUrl:i,listenToEvents:m,emitQueryParams:d}=wt(t),{listenToEvents:l}=xt({environment:t.environment}),[c]=H(i());return w(()=>{let o=m(r=>{var a;return(a=t.onEvent)==null?void 0:a.call(t,r.data)});return()=>{o&&o()}},[]),w(()=>{let o=l(r=>{let{type:a,payload:s}=r.data;switch(a){case"ui:height.changed":n(s.height);break;default:return}});return()=>{o&&o()}},[]),w(()=>{d({recipient:t.recipient,mintConfig:t.mintConfig,locale:t.locale,whPassThroughArgs:t.whPassThroughArgs})},[t.recipient,t.mintConfig,t.locale,t.whPassThroughArgs]),Nt("iframe",{src:c,id:"crossmint-embedded-checkout.iframe",role:"crossmint-embedded-checkout.iframe",allow:"payment *",style:{border:"none !important",padding:"0px !important",width:"100% !important",minWidth:"100% !important",overflow:"hidden !important",display:"block !important",userSelect:"none",transform:"translate(0px) !important",opacity:"1",transition:"ease 0s, opacity 0.4s ease 0.1s",height:`${e}px`}})}import{jsx as G}from"react/jsx-runtime";function Re(t){if(Ot(t))return G(V,u({},t));if(Ft(t))return G(D,u({},t));throw new Error("Unsupported: Fiat is the only supported payment method.")}import{useMemo as Mt}from"react";import{useState as Ut}from"react";import{clientNames as At,crossmintModalService as Dt,crossmintPayButtonService as Ht}from"@crossmint/client-sdk-base";import{useEffect as Lt,useState as Bt}from"react";function x(){let[t,e]=Bt(!0);return Lt(()=>{e(!1)},[]),{isServerSideRendering:t}}import{createUseStyles as Rt}from"react-jss";var _t="#1e1e1e",Y=t=>t==="light",W=t=>({buttonBgColor:Y(t)?"white":_t,paragraphColor:Y(t)?"black":"white"}),$=Rt({"@global":{"@import":"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')"},crossmintButton:{display:"flex","flex-direction":"row","align-items":"center",padding:"0.875rem 0.875rem","font-weight":"900",transition:"opacity ease-in-out 0.25s","border-radius":"0.5rem","font-family":'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif',outline:"none",border:"none","box-shadow":"0px 8px 15px rgba(0, 0, 0, 0.1)","justify-content":"center",background:({buttonBgColor:t})=>t,"&:hover:enabled":{opacity:"0.6",cursor:"pointer"}},crossmintImg:{width:"21px",height:"21px","margin-right":"0.875rem"},crossmintParagraph:{color:({paragraphColor:t})=>t,margin:"0"}});import{Fragment as Gt,jsx as N,jsxs as Vt}from"react/jsx-runtime";function Ze(t){let L=t,{className:e,disabled:n,onClick:i,style:m,tabIndex:d,theme:l="dark",mintTo:c,emailTo:o,listingId:r,auctionId:a,showOverlay:s=!0,mintConfig:p,whPassThroughArgs:h,environment:P,paymentMethod:C,preferredSigninMethod:z,dismissOverlayOnClick:q,prepay:J,locale:F="en-US",currency:K="usd",successCallbackURL:Q="",failureCallbackURL:X="",loginEmail:Z="",projectId:j,getButtonText:S,checkoutProps:O={experimental:!1,display:"same-tab",paymentMethods:["fiat","ETH","SOL"]}}=L,I=E(L,["className","disabled","onClick","style","tabIndex","theme","mintTo","emailTo","listingId","auctionId","showOverlay","mintConfig","whPassThroughArgs","environment","paymentMethod","preferredSigninMethod","dismissOverlayOnClick","prepay","locale","currency","successCallbackURL","failureCallbackURL","loginEmail","projectId","getButtonText","checkoutProps"]),tt="clientId"in I?I.clientId:I.collectionId,[f,et]=Ut(!1),{isServerSideRendering:nt}=x(),{connect:ot}=Dt({clientId:tt,projectId:j,showOverlay:s,dismissOverlayOnClick:q,setConnecting:et,libVersion:g,environment:P,clientName:At.reactUi,locale:F,currency:K,successCallbackURL:Q,failureCallbackURL:X,loginEmail:Z}),{getButtonText:rt,handleClick:it}=Ht({onClick:i,connecting:f,paymentMethod:C,locale:F,checkoutProps:O}),st=mt=>it(mt,()=>{ot(p,c,o,r,h,C,z,J,O)}),k=$(W(l)),at=Mt(()=>N("span",{className:k.crossmintParagraph,role:"button-paragraph",children:S!=null?S(f,C||"fiat"):rt(f)}),[f,S,C]);return N(Gt,{children:!nt&&Vt("button",{className:`${k.crossmintButton} ${e||""}`,disabled:n,onClick:st,style:u({},m),tabIndex:d,children:[N("img",{className:k.crossmintImg,src:"https://www.crossmint.io/assets/crossmint/logo.svg",alt:"Crossmint logo"}),at]})})}import{CrossmintEvents as sn,useCrossmintEvents as an}from"@crossmint/client-sdk-base";export{sn as CrossmintEvents,Jt as CrossmintNFTCollectionView,te as CrossmintNFTDetail,Ze as CrossmintPayButton,Re as CrossmintPaymentElement,an as useCrossmintEvents};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/CrossmintNFTCollectionView.tsx","../src/consts/version.ts","../src/components/CrossmintNFTDetail.tsx","../src/components/embed/index.tsx","../src/components/embed/FiatPaymentElement_OLD.tsx","../src/components/hosted/CrossmintPayButton.tsx","../src/hooks/useEnvironment.ts","../src/components/hosted/styles.ts","../src/index.ts"],"sourcesContent":["import {\n NFTCollectionViewProps,\n assertValidNFTCollectionViewProps,\n getNFTCollectionViewSrc,\n} from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTCollectionView(props: NFTCollectionViewProps) {\n assertValidNFTCollectionViewProps(props);\n\n const src = getNFTCollectionViewSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-collection-view\"\n />\n );\n}\n","export const LIB_VERSION = \"1.1.0-alpha.0\";\n","import { NFTDetailProps, assertValidValidateNFTDetailProps, getNFTDetailSrc } from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTDetail(props: NFTDetailProps) {\n assertValidValidateNFTDetailProps(props);\n\n const src = getNFTDetailSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-details\"\n />\n );\n}\n","import {\n CrossmintEmbeddedCheckoutProps,\n isCryptoEmbeddedCheckoutProps,\n isFiatEmbeddedCheckoutProps,\n} from \"@crossmint/client-sdk-base\";\n\nimport { CrossmintCryptoEmbeddedCheckout } from \"./CryptoEmbeddedCheckout\";\nimport { CrossmintFiatPaymentElement_OLD } from \"./FiatPaymentElement_OLD\";\n\n// TODO: Rename to CrossmintEmbeddedCheckout\nexport function CrossmintPaymentElement(props: CrossmintEmbeddedCheckoutProps) {\n if (isFiatEmbeddedCheckoutProps(props)) {\n return <CrossmintFiatPaymentElement_OLD {...props} />;\n }\n if (isCryptoEmbeddedCheckoutProps(props)) {\n throw new Error(\"Unsupported: Fiat is the only supported payment method.\");\n // return <CrossmintCryptoEmbeddedCheckout {...props} />;\n }\n throw new Error(\"Unsupported: Fiat is the only supported payment method.\");\n}\n","import { useEffect, useState } from \"react\";\n\nimport type { FiatEmbeddedCheckoutProps } from \"@crossmint/client-sdk-base\";\nimport { crossmintPaymentService_OLD, crossmintUiService_OLD } from \"@crossmint/client-sdk-base\";\n\nexport function CrossmintFiatPaymentElement_OLD(props: FiatEmbeddedCheckoutProps) {\n const [height, setHeight] = useState(0);\n const { getIframeUrl, listenToEvents, emitQueryParams } = crossmintPaymentService_OLD(props);\n const { listenToEvents: listenToUiEvents } = crossmintUiService_OLD({ environment: props.environment });\n const [url] = useState(getIframeUrl());\n\n useEffect(() => {\n const clearListener = listenToEvents((event) => props.onEvent?.(event.data));\n\n return () => {\n if (clearListener) {\n clearListener();\n }\n };\n }, []);\n\n useEffect(() => {\n const clearListener = listenToUiEvents((event: MessageEvent<any>) => {\n const { type, payload } = event.data;\n\n switch (type) {\n case \"ui:height.changed\":\n setHeight(payload.height);\n break;\n default:\n return;\n }\n });\n\n return () => {\n if (clearListener) {\n clearListener();\n }\n };\n }, []);\n\n useEffect(() => {\n emitQueryParams({\n recipient: props.recipient,\n mintConfig: props.mintConfig,\n locale: props.locale,\n whPassThroughArgs: props.whPassThroughArgs,\n });\n }, [props.recipient, props.mintConfig, props.locale, props.whPassThroughArgs]);\n\n return (\n <iframe\n src={url}\n id=\"crossmint-embedded-checkout.iframe\"\n role=\"crossmint-embedded-checkout.iframe\"\n allow=\"payment *\"\n style={{\n border: \"none !important\",\n padding: \"0px !important\",\n width: \"100% !important\",\n minWidth: \"100% !important\",\n overflow: \"hidden !important\",\n display: \"block !important\",\n userSelect: \"none\",\n transform: \"translate(0px) !important\",\n opacity: \"1\",\n transition: \"ease 0s, opacity 0.4s ease 0.1s\",\n height: `${height}px`,\n }}\n ></iframe>\n );\n}\n","import { CSSProperties, MouseEvent, useMemo } from \"react\";\nimport { useState } from \"react\";\n\nimport {\n CrossmintPayButtonProps,\n clientNames,\n crossmintModalService,\n crossmintPayButtonService,\n} from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../../consts/version\";\nimport useEnvironment from \"../../hooks/useEnvironment\";\nimport { formatProps, useStyles } from \"./styles\";\n\nexport type CrossmintPayButtonReactProps = CrossmintPayButtonProps & {\n onClick?: (e: MouseEvent<HTMLButtonElement>) => void;\n style?: CSSProperties;\n};\n\nexport function CrossmintPayButton(buttonProps: CrossmintPayButtonReactProps) {\n const {\n className,\n disabled,\n onClick,\n style,\n tabIndex,\n theme = \"dark\",\n mintTo,\n emailTo,\n listingId,\n auctionId,\n showOverlay = true,\n mintConfig,\n whPassThroughArgs,\n environment,\n paymentMethod,\n preferredSigninMethod,\n dismissOverlayOnClick,\n prepay,\n locale = \"en-US\",\n currency = \"usd\",\n successCallbackURL = \"\",\n failureCallbackURL = \"\",\n loginEmail = \"\",\n projectId,\n getButtonText,\n ...props\n } = buttonProps;\n\n const collectionId = \"clientId\" in props ? props.clientId : props.collectionId;\n\n const [connecting, setConnecting] = useState(false);\n const { isServerSideRendering } = useEnvironment();\n\n const { connect } = crossmintModalService({\n clientId: collectionId,\n projectId,\n showOverlay,\n dismissOverlayOnClick,\n setConnecting,\n libVersion: LIB_VERSION,\n environment,\n clientName: clientNames.reactUi,\n locale,\n currency,\n successCallbackURL,\n failureCallbackURL,\n loginEmail,\n });\n\n const { getButtonText: getButtonTextInternal, handleClick } = crossmintPayButtonService({\n onClick,\n connecting,\n paymentMethod,\n locale,\n });\n\n const _handleClick = (event: MouseEvent<HTMLButtonElement>) =>\n handleClick(event, () => {\n connect(\n mintConfig,\n mintTo,\n emailTo,\n listingId,\n whPassThroughArgs,\n paymentMethod,\n preferredSigninMethod,\n prepay\n );\n });\n\n const classes = useStyles(formatProps(theme));\n\n const content = useMemo(() => {\n return (\n <span className={classes.crossmintParagraph} role=\"button-paragraph\">\n {getButtonText != null\n ? getButtonText(connecting, paymentMethod || \"fiat\")\n : getButtonTextInternal(connecting)}\n </span>\n );\n }, [connecting, getButtonText, paymentMethod]);\n\n return (\n <>\n {!isServerSideRendering && (\n <button\n className={`${classes.crossmintButton} ${className || \"\"}`}\n disabled={disabled}\n onClick={_handleClick}\n style={{ ...style }}\n tabIndex={tabIndex}\n >\n <img\n className={classes.crossmintImg}\n src=\"https://www.crossmint.io/assets/crossmint/logo.svg\"\n alt=\"Crossmint logo\"\n />\n {content}\n </button>\n )}\n </>\n );\n}\n","import { useEffect, useState } from \"react\";\r\n\r\nexport default function useEnvironment() {\r\n const [isServerSideRendering, setIsServerSideRendering] = useState(true);\r\n useEffect(() => {\r\n setIsServerSideRendering(false);\r\n }, []);\r\n\r\n return { isServerSideRendering };\r\n}\r\n","import { createUseStyles } from \"react-jss\";\n\nconst DARK_BG = \"#1e1e1e\";\n\ninterface CustomStylingProps {\n buttonBgColor?: string;\n paragraphColor?: string;\n}\n\nconst themeIsLight = (theme: string) => theme === \"light\";\n\nexport const formatProps = (theme: string): CustomStylingProps => ({\n buttonBgColor: themeIsLight(theme) ? \"white\" : DARK_BG,\n paragraphColor: themeIsLight(theme) ? \"black\" : \"white\",\n});\n\nexport const useStyles = createUseStyles({\n \"@global\": {\n \"@import\":\n \"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')\",\n },\n crossmintButton: {\n display: \"flex\",\n \"flex-direction\": \"row\",\n \"align-items\": \"center\",\n padding: \"0.875rem 0.875rem\",\n \"font-weight\": \"900\",\n transition: \"opacity ease-in-out 0.25s\",\n \"border-radius\": \"0.5rem\",\n \"font-family\": `\"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif`,\n outline: \"none\",\n border: \"none\",\n \"box-shadow\": \"0px 8px 15px rgba(0, 0, 0, 0.1)\",\n \"justify-content\": \"center\",\n background: ({ buttonBgColor }: CustomStylingProps) => buttonBgColor,\n\n \"&:hover:enabled\": {\n opacity: \"0.6\",\n cursor: \"pointer\",\n },\n },\n crossmintImg: {\n width: \"21px\",\n height: \"21px\",\n \"margin-right\": \"0.875rem\",\n },\n crossmintParagraph: {\n color: ({ paragraphColor }: CustomStylingProps) => paragraphColor,\n margin: \"0\",\n },\n});\n","export * from \"./components\";\n\nexport { CrossmintEvents, useCrossmintEvents } from \"@crossmint/client-sdk-base\";\nexport type { CrossmintEvent, CrossmintEventMap } from \"@crossmint/client-sdk-base\";\n"],"mappings":"6fAAA,OAEI,qCAAAA,GACA,2BAAAC,OACG,6BCJA,IAAMC,EAAc,gBDcnB,cAAAC,OAAA,oBAND,SAASC,GAA2BC,EAA+B,CACtEC,GAAkCD,CAAK,EAEvC,IAAME,EAAMC,GAAwBH,EAAOI,CAAW,EAEtD,OACIN,GAAC,UACG,IAAKI,EACL,MAAM,OACN,OAAO,OACP,MAAO,CACH,SAAU,IACV,OAAQ,OACR,OAAQ,IACR,QAAS,GACb,EACA,KAAK,sBACT,CAER,CE3BA,OAAyB,qCAAAG,GAAmC,mBAAAC,OAAuB,6BAU3E,cAAAC,OAAA,oBAND,SAASC,GAAmBC,EAAuB,CACtDC,GAAkCD,CAAK,EAEvC,IAAME,EAAMC,GAAgBH,EAAOI,CAAW,EAE9C,OACIN,GAAC,UACG,IAAKI,EACL,MAAM,OACN,OAAO,OACP,MAAO,CACH,SAAU,IACV,OAAQ,OACR,OAAQ,IACR,QAAS,GACb,EACA,KAAK,cACT,CAER,CCvBA,OAEI,iCAAAG,GACA,+BAAAC,OACG,6BCJP,OAAS,aAAAC,EAAW,YAAAC,MAAgB,QAGpC,OAAS,+BAAAC,GAA6B,0BAAAC,OAA8B,6BAgD5D,cAAAC,OAAA,oBA9CD,SAASC,EAAgCC,EAAkC,CAC9E,GAAM,CAACC,EAAQC,CAAS,EAAIP,EAAS,CAAC,EAChC,CAAE,aAAAQ,EAAc,eAAAC,EAAgB,gBAAAC,CAAgB,EAAIT,GAA4BI,CAAK,EACrF,CAAE,eAAgBM,CAAiB,EAAIT,GAAuB,CAAE,YAAaG,EAAM,WAAY,CAAC,EAChG,CAACO,CAAG,EAAIZ,EAASQ,EAAa,CAAC,EAErC,OAAAT,EAAU,IAAM,CACZ,IAAMc,EAAgBJ,EAAgBK,GAAO,CAZrD,IAAAC,EAYwD,OAAAA,EAAAV,EAAM,UAAN,YAAAU,EA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iBACR,EACCG,GACL,EAER,CAER,CGzHA,OAAS,mBAAAG,GAAiB,sBAAAC,OAA0B","names":["assertValidNFTCollectionViewProps","getNFTCollectionViewSrc","LIB_VERSION","jsx","CrossmintNFTCollectionView","props","assertValidNFTCollectionViewProps","src","getNFTCollectionViewSrc","LIB_VERSION","assertValidValidateNFTDetailProps","getNFTDetailSrc","jsx","CrossmintNFTDetail","props","assertValidValidateNFTDetailProps","src","getNFTDetailSrc","LIB_VERSION","isCryptoEmbeddedCheckoutProps","isFiatEmbeddedCheckoutProps","useEffect","useState","crossmintPaymentService_OLD","crossmintUiService_OLD","jsx","CrossmintFiatPaymentElement_OLD","props","height","setHeight","getIframeUrl","listenToEvents","emitQueryParams","listenToUiEvents","url","clearListener","event","_a","type","payload","jsx","CrossmintPaymentElement","props","isFiatEmbeddedCheckoutProps","CrossmintFiatPaymentElement_OLD","__spreadValues","isCryptoEmbeddedCheckoutProps","useMemo","useState","clientNames","crossmintModalService","crossmintPayButtonService","useEffect","useState","useEnvironment","isServerSideRendering","setIsServerSideRendering","createUseStyles","DARK_BG","themeIsLight","theme","formatProps","useStyles","buttonBgColor","paragraphColor","Fragment","jsx","jsxs","CrossmintPayButton","buttonProps","_a","className","disabled","onClick","style","tabIndex","theme","mintTo","emailTo","listingId","auctionId","showOverlay","mintConfig","whPassThroughArgs","environment","paymentMethod","preferredSigninMethod","dismissOverlayOnClick","prepay","locale","currency","successCallbackURL","failureCallbackURL","loginEmail","projectId","getButtonText","props","__objRest","collectionId","connecting","setConnecting","useState","isServerSideRendering","useEnvironment","connect","crossmintModalService","LIB_VERSION","clientNames","getButtonTextInternal","handleClick","crossmintPayButtonService","_handleClick","event","classes","useStyles","formatProps","content","useMemo","__spreadValues","CrossmintEvents","useCrossmintEvents"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/CrossmintNFTCollectionView.tsx","../src/consts/version.ts","../src/components/CrossmintNFTDetail.tsx","../src/components/embed/index.tsx","../src/components/embed/crypto/CryptoEmbeddedCheckout.tsx","../src/components/embed/crypto/CryptoEmbeddedCheckoutIFrame.tsx","../src/components/embed/EmbeddedCheckoutIFrame.tsx","../src/components/embed/fiat/FiatPaymentElement_OLD.tsx","../src/components/hosted/CrossmintPayButton.tsx","../src/hooks/useEnvironment.ts","../src/components/hosted/styles.ts","../src/index.ts"],"sourcesContent":["import {\n NFTCollectionViewProps,\n assertValidNFTCollectionViewProps,\n getNFTCollectionViewSrc,\n} from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTCollectionView(props: NFTCollectionViewProps) {\n assertValidNFTCollectionViewProps(props);\n\n const src = getNFTCollectionViewSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-collection-view\"\n />\n );\n}\n","export const LIB_VERSION = \"1.1.0-alpha.2\";\n","import { NFTDetailProps, assertValidValidateNFTDetailProps, getNFTDetailSrc } from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../consts/version\";\n\nexport function CrossmintNFTDetail(props: NFTDetailProps) {\n assertValidValidateNFTDetailProps(props);\n\n const src = getNFTDetailSrc(props, LIB_VERSION);\n\n return (\n <iframe\n src={src}\n width=\"100%\"\n height=\"100%\"\n style={{\n flexGrow: \"1\",\n border: \"none\",\n margin: \"0\",\n padding: \"0\",\n }}\n role=\"nft-details\"\n />\n );\n}\n","import {\n CrossmintEmbeddedCheckoutProps,\n isCryptoEmbeddedCheckoutProps,\n isFiatEmbeddedCheckoutProps,\n} from \"@crossmint/client-sdk-base\";\n\nimport { CrossmintCryptoEmbeddedCheckout } from \"./crypto/CryptoEmbeddedCheckout\";\nimport { CrossmintFiatPaymentElement_OLD } from \"./fiat/FiatPaymentElement_OLD\";\n\n// TODO: Rename to CrossmintEmbeddedCheckout\nexport function CrossmintPaymentElement(props: CrossmintEmbeddedCheckoutProps) {\n if (isFiatEmbeddedCheckoutProps(props)) {\n return <CrossmintFiatPaymentElement_OLD {...props} />;\n }\n if (isCryptoEmbeddedCheckoutProps(props)) {\n return <CrossmintCryptoEmbeddedCheckout {...props} />;\n }\n throw new Error(\"Unsupported: Fiat is the only supported payment method.\");\n}\n","import { CryptoEmbeddedCheckoutProps, isCryptoEmbeddedCheckoutPropsWithSigner } from \"@crossmint/client-sdk-base\";\n\nimport CryptoEmbeddedCheckoutIFrame from \"./CryptoEmbeddedCheckoutIFrame\";\n\nexport function CrossmintCryptoEmbeddedCheckout(props: CryptoEmbeddedCheckoutProps) {\n if (!isCryptoEmbeddedCheckoutPropsWithSigner(props)) {\n throw new Error(\"Invalid parameters: signer is required in versions < 2.0.0\");\n }\n\n return <CryptoEmbeddedCheckoutIFrame {...props} />;\n}\n","import bs58 from \"bs58\";\nimport { useEffect } from \"react\";\n\nimport {\n CryptoEmbeddedCheckoutPropsWithSigner,\n ETHEmbeddedCheckoutSigner,\n IncomingInternalEvent,\n IncomingInternalEvents,\n OutgoingInternalEvents,\n SOLEmbeddedCheckoutSigner,\n crossmintIFrameService,\n embeddedCheckoutPropsToUpdatableParamsPayload,\n} from \"@crossmint/client-sdk-base\";\n\nimport CrossmintEmbeddedCheckoutIFrame from \"../EmbeddedCheckoutIFrame\";\n\nexport default function CryptoEmbeddedCheckoutIFrame(props: CryptoEmbeddedCheckoutPropsWithSigner) {\n const { emitInternalEvent } = crossmintIFrameService(props);\n\n const { signer, paymentMethod } = props;\n\n function onInternalEvent(event: IncomingInternalEvent) {\n const { type, payload } = event;\n\n if (type === IncomingInternalEvents.CRYPTO_PAYMENT_INCOMING_TRANSACTION) {\n const { serializedTransaction } = payload;\n console.log(\"[Crossmint] Received incoming transaction\", serializedTransaction);\n handleIncomingTransaction(serializedTransaction);\n }\n }\n\n async function handleIncomingTransaction(serializedTransaction: string) {\n try {\n let txId: string;\n switch (paymentMethod) {\n case \"SOL\":\n txId = await handleSOLTransaction(signer, serializedTransaction);\n break;\n case \"ETH\":\n txId = await handleETHTransaction(signer, serializedTransaction);\n break;\n default:\n throw new Error(`Unsupported payment method ${paymentMethod}`);\n }\n\n console.log(\"[Crossmint] Signed and sent transaction\", txId);\n emitInternalEvent({\n type: OutgoingInternalEvents.CRYPTO_PAYMENT_USER_ACCEPTED,\n payload: {\n txId,\n },\n });\n } catch (e) {\n console.error(\"[Crossmint] Failed to sign and send transaction\", e);\n emitInternalEvent({\n type: OutgoingInternalEvents.CRYPTO_PAYMENT_USER_REJECTED,\n payload: {},\n });\n }\n }\n\n async function handleSOLTransaction(signer: SOLEmbeddedCheckoutSigner, serializedTransaction: string) {\n // @ts-ignore - Error becasue we dont use 'module' field in tsconfig, which is expected because we use tsup to compile\n const { Transaction } = await import(\"@solana/web3.js\");\n const transaction = Transaction.from(bs58.decode(serializedTransaction));\n console.log(\"[Crossmint] Deserialized SOL transaction\", transaction);\n\n return await signer.signAndSendTransaction(transaction);\n }\n\n async function handleETHTransaction(signer: ETHEmbeddedCheckoutSigner, serializedTransaction: string) {\n // @ts-ignore - Error becasue we dont use 'module' field in tsconfig, which is expected because we use tsup to compile\n const { parse: parseTransaction } = await import(\"@ethersproject/transactions\");\n const transaction = parseTransaction(serializedTransaction);\n console.log(\"[Crossmint] Deserialized ETH transaction\", transaction);\n\n return await signer.signAndSendTransaction(transaction);\n }\n\n useEffect(() => {\n emitInternalEvent({\n type: \"params-update\",\n payload: embeddedCheckoutPropsToUpdatableParamsPayload(props),\n });\n }, [props.signer, props.recipient, props.mintConfig, props.locale, props.whPassThroughArgs]);\n\n return <CrossmintEmbeddedCheckoutIFrame onInternalEvent={onInternalEvent} {...props} />;\n}\n","import { useEffect, useState } from \"react\";\n\nimport { IncomingInternalEvent, IncomingInternalEvents, crossmintIFrameService } from \"@crossmint/client-sdk-base\";\nimport { CrossmintEmbeddedCheckoutProps } from \"@crossmint/client-sdk-base\";\n\ntype CrossmintEmbeddedCheckoutIFrameProps = CrossmintEmbeddedCheckoutProps & {\n onInternalEvent?: (event: IncomingInternalEvent) => void;\n};\n\nexport default function CrossmintEmbeddedCheckoutIFrame({\n onInternalEvent,\n ...props\n}: CrossmintEmbeddedCheckoutIFrameProps) {\n const { getUrl, listenToEvents, listenToInternalEvents, emitInternalEvent } = crossmintIFrameService(props);\n\n const [height, setHeight] = useState(0);\n const [url] = useState(getUrl(props));\n\n // Public events\n useEffect(() => {\n const clearListener = listenToEvents((event) => {\n props.onEvent?.(event.data);\n });\n\n return () => {\n clearListener();\n };\n }, []);\n\n // Internal events\n useEffect(() => {\n const clearListener = listenToInternalEvents((event) => {\n const { type, payload } = event.data;\n\n if (type === IncomingInternalEvents.UI_HEIGHT_CHANGED) {\n setHeight(payload.height);\n }\n\n onInternalEvent?.(event.data);\n });\n\n return () => {\n clearListener();\n };\n }, []);\n\n // TODO: Emit updatable parameters\n\n return (\n <iframe\n src={url}\n id=\"crossmint-embedded-checkout.iframe\"\n role=\"crossmint-embedded-checkout.iframe\"\n allow=\"payment *\"\n style={{\n border: \"none !important\",\n padding: \"0px !important\",\n width: \"100% !important\",\n minWidth: \"100% !important\",\n overflow: \"hidden !important\",\n display: \"block !important\",\n userSelect: \"none\",\n transform: \"translate(0px) !important\",\n opacity: \"1\",\n transition: \"ease 0s, opacity 0.4s ease 0.1s\",\n height: `${height}px`,\n }}\n />\n );\n}\n","import { useEffect, useState } from \"react\";\n\nimport type { FiatEmbeddedCheckoutProps } from \"@crossmint/client-sdk-base\";\nimport { crossmintPaymentService_OLD, crossmintUiService_OLD } from \"@crossmint/client-sdk-base\";\n\nexport function CrossmintFiatPaymentElement_OLD(props: FiatEmbeddedCheckoutProps) {\n const [height, setHeight] = useState(0);\n const { getIframeUrl, listenToEvents, emitQueryParams } = crossmintPaymentService_OLD(props);\n const { listenToEvents: listenToUiEvents } = crossmintUiService_OLD({ environment: props.environment });\n const [url] = useState(getIframeUrl());\n\n useEffect(() => {\n const clearListener = listenToEvents((event) => props.onEvent?.(event.data));\n\n return () => {\n if (clearListener) {\n clearListener();\n }\n };\n }, []);\n\n useEffect(() => {\n const clearListener = listenToUiEvents((event: MessageEvent<any>) => {\n const { type, payload } = event.data;\n\n switch (type) {\n case \"ui:height.changed\":\n setHeight(payload.height);\n break;\n default:\n return;\n }\n });\n\n return () => {\n if (clearListener) {\n clearListener();\n }\n };\n }, []);\n\n useEffect(() => {\n emitQueryParams({\n recipient: props.recipient,\n mintConfig: props.mintConfig,\n locale: props.locale,\n whPassThroughArgs: props.whPassThroughArgs,\n });\n }, [props.recipient, props.mintConfig, props.locale, props.whPassThroughArgs]);\n\n return (\n <iframe\n src={url}\n id=\"crossmint-embedded-checkout.iframe\"\n role=\"crossmint-embedded-checkout.iframe\"\n allow=\"payment *\"\n style={{\n border: \"none !important\",\n padding: \"0px !important\",\n width: \"100% !important\",\n minWidth: \"100% !important\",\n overflow: \"hidden !important\",\n display: \"block !important\",\n userSelect: \"none\",\n transform: \"translate(0px) !important\",\n opacity: \"1\",\n transition: \"ease 0s, opacity 0.4s ease 0.1s\",\n height: `${height}px`,\n }}\n ></iframe>\n );\n}\n","import { CSSProperties, MouseEvent, useMemo } from \"react\";\nimport { useState } from \"react\";\n\nimport {\n CrossmintPayButtonProps,\n clientNames,\n crossmintModalService,\n crossmintPayButtonService, CheckoutProps,\n} from \"@crossmint/client-sdk-base\";\n\nimport { LIB_VERSION } from \"../../consts/version\";\nimport useEnvironment from \"../../hooks/useEnvironment\";\nimport { formatProps, useStyles } from \"./styles\";\n\nexport type CrossmintPayButtonReactProps = CrossmintPayButtonProps & {\n onClick?: (e: MouseEvent<HTMLButtonElement>) => void;\n style?: CSSProperties;\n};\n\nexport function CrossmintPayButton(buttonProps: CrossmintPayButtonReactProps) {\n const {\n className,\n disabled,\n onClick,\n style,\n tabIndex,\n theme = \"dark\",\n mintTo,\n emailTo,\n listingId,\n auctionId,\n showOverlay = true,\n mintConfig,\n whPassThroughArgs,\n environment,\n paymentMethod,\n preferredSigninMethod,\n dismissOverlayOnClick,\n prepay,\n locale = \"en-US\",\n currency = \"usd\",\n successCallbackURL = \"\",\n failureCallbackURL = \"\",\n loginEmail = \"\",\n projectId,\n getButtonText,\n checkoutProps = {\n experimental: false,\n display: \"same-tab\",\n paymentMethods: [\"fiat\", \"ETH\", \"SOL\"],\n } as CheckoutProps,\n ...props\n } = buttonProps;\n\n const collectionId = \"clientId\" in props ? props.clientId : props.collectionId;\n\n const [connecting, setConnecting] = useState(false);\n const { isServerSideRendering } = useEnvironment();\n\n const { connect } = crossmintModalService({\n clientId: collectionId,\n projectId,\n showOverlay,\n dismissOverlayOnClick,\n setConnecting,\n libVersion: LIB_VERSION,\n environment,\n clientName: clientNames.reactUi,\n locale,\n currency,\n successCallbackURL,\n failureCallbackURL,\n loginEmail,\n });\n\n const { getButtonText: getButtonTextInternal, handleClick } = crossmintPayButtonService({\n onClick,\n connecting,\n paymentMethod,\n locale,\n checkoutProps\n });\n\n const _handleClick = (event: MouseEvent<HTMLButtonElement>) =>\n handleClick(event, () => {\n connect(\n mintConfig,\n mintTo,\n emailTo,\n listingId,\n whPassThroughArgs,\n paymentMethod,\n preferredSigninMethod,\n prepay,\n checkoutProps\n );\n });\n\n const classes = useStyles(formatProps(theme));\n\n const content = useMemo(() => {\n return (\n <span className={classes.crossmintParagraph} role=\"button-paragraph\">\n {getButtonText != null\n ? getButtonText(connecting, paymentMethod || \"fiat\")\n : getButtonTextInternal(connecting)}\n </span>\n );\n }, [connecting, getButtonText, paymentMethod]);\n\n return (\n <>\n {!isServerSideRendering && (\n <button\n className={`${classes.crossmintButton} ${className || \"\"}`}\n disabled={disabled}\n onClick={_handleClick}\n style={{ ...style }}\n tabIndex={tabIndex}\n >\n <img\n className={classes.crossmintImg}\n src=\"https://www.crossmint.io/assets/crossmint/logo.svg\"\n alt=\"Crossmint logo\"\n />\n {content}\n </button>\n )}\n </>\n );\n}\n","import { useEffect, useState } from \"react\";\r\n\r\nexport default function useEnvironment() {\r\n const [isServerSideRendering, setIsServerSideRendering] = useState(true);\r\n useEffect(() => {\r\n setIsServerSideRendering(false);\r\n }, []);\r\n\r\n return { isServerSideRendering };\r\n}\r\n","import { createUseStyles } from \"react-jss\";\n\nconst DARK_BG = \"#1e1e1e\";\n\ninterface CustomStylingProps {\n buttonBgColor?: string;\n paragraphColor?: string;\n}\n\nconst themeIsLight = (theme: string) => theme === \"light\";\n\nexport const formatProps = (theme: string): CustomStylingProps => ({\n buttonBgColor: themeIsLight(theme) ? \"white\" : DARK_BG,\n paragraphColor: themeIsLight(theme) ? \"black\" : \"white\",\n});\n\nexport const useStyles = createUseStyles({\n \"@global\": {\n \"@import\":\n \"url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap')\",\n },\n crossmintButton: {\n display: \"flex\",\n \"flex-direction\": \"row\",\n \"align-items\": \"center\",\n padding: \"0.875rem 0.875rem\",\n \"font-weight\": \"900\",\n transition: \"opacity ease-in-out 0.25s\",\n \"border-radius\": \"0.5rem\",\n \"font-family\": `\"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif`,\n outline: \"none\",\n border: \"none\",\n \"box-shadow\": \"0px 8px 15px rgba(0, 0, 0, 0.1)\",\n \"justify-content\": \"center\",\n background: ({ buttonBgColor }: CustomStylingProps) => buttonBgColor,\n\n \"&:hover:enabled\": {\n opacity: \"0.6\",\n cursor: \"pointer\",\n },\n },\n crossmintImg: {\n width: \"21px\",\n height: \"21px\",\n \"margin-right\": \"0.875rem\",\n },\n crossmintParagraph: {\n color: ({ paragraphColor }: CustomStylingProps) => paragraphColor,\n margin: \"0\",\n },\n});\n","export * from \"./components\";\n\nexport { CrossmintEvents, useCrossmintEvents } from \"@crossmint/client-sdk-base\";\nexport type { CrossmintEvent, CrossmintEventMap } from \"@crossmint/client-sdk-base\";\n"],"mappings":"0sBAAA,OAEI,qCAAAA,GACA,2BAAAC,OACG,6BCJA,IAAMC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,CAAC,EAEKgB,GAAgBC,IAClBH,GAAYG,GAAO,IAAM,CACrBR,GACIvB,EACAL,EACAC,EACAC,EACAI,EACAE,EACAC,EACAE,EACAQ,CACJ,CACJ,CAAC,EAECkB,EAAUC,EAAUC,EAAYxC,CAAK,CAAC,EAEtCyC,GAAUC,GAAQ,IAEhBpD,EAAC,QAAK,UAAWgD,EAAQ,mBAAoB,KAAK,mBAC7C,SAAAnB,GAAiB,KACZA,EAAcK,EAAYf,GAAiB,MAAM,EACjDwB,GAAsBT,CAAU,EAC1C,EAEL,CAACA,EAAYL,EAAeV,CAAa,CAAC,EAE7C,OACInB,EAAAD,GAAA,CACK,UAACsC,IACEpC,GAAC,UACG,UAAW,GAAG+C,EAAQ,eAAe,IAAI3C,GAAa,EAAE,GACxD,SAAUC,EACV,QAASwC,GACT,MAAOO,EAAA,GAAK7C,GACZ,SAAUC,EAEV,UAAAT,EAAC,OACG,UAAWgD,EAAQ,aACnB,IAAI,qDACJ,IAAI,iBACR,EACCG,IACL,EAER,CAER,CGhIA,OAAS,mBAAAG,GAAiB,sBAAAC,OAA0B","names":["assertValidNFTCollectionViewProps","getNFTCollectionViewSrc","LIB_VERSION","jsx","CrossmintNFTCollectionView","props","assertValidNFTCollectionViewProps","src","getNFTCollectionViewSrc","LIB_VERSION","assertValidValidateNFTDetailProps","getNFTDetailSrc","jsx","CrossmintNFTDetail","props","assertValidValidateNFTDetailProps","src","getNFTDetailSrc","LIB_VERSION","isCryptoEmbeddedCheckoutProps","isFiatEmbeddedCheckoutProps","isCryptoEmbeddedCheckoutPropsWithSigner","bs58","useEffect","IncomingInternalEvents","OutgoingInternalEvents","crossmintIFrameService","embeddedCheckoutPropsToUpdatableParamsPayload","useEffect","useState","IncomingInternalEvents","crossmintIFrameService","jsx","CrossmintEmbeddedCheckoutIFrame","_a","_b","onInternalEvent","props","__objRest","getUrl","listenToEvents","listenToInternalEvents","emitInternalEvent","crossmintIFrameService","height","setHeight","useState","url","useEffect","clearListener","event","type","payload","IncomingInternalEvents","jsx","CryptoEmbeddedCheckoutIFrame","props","emitInternalEvent","crossmintIFrameService","signer","paymentMethod","onInternalEvent","event","type","payload","IncomingInternalEvents","serializedTransaction","handleIncomingTransaction","__async","txId","handleSOLTransaction","handleETHTransaction","OutgoingInternalEvents","e","Transaction","transaction","bs58","parseTransaction","useEffect","embeddedCheckoutPropsToUpdatableParamsPayload","CrossmintEmbeddedCheckoutIFrame","__spreadValues","jsx","CrossmintCryptoEmbeddedCheckout","props","isCryptoEmbeddedCheckoutPropsWithSigner","CryptoEmbeddedCheckoutIFrame","__spreadValues","useEffect","useState","crossmintPaymentService_OLD","crossmintUiService_OLD","jsx","CrossmintFiatPaymentElement_OLD","props","height","setHeight","getIframeUrl","listenToEvents","emitQueryParams","listenToUiEvents","url","clearListener","event","_a","type","payload","jsx","CrossmintPaymentElement","props","isFiatEmbeddedCheckoutProps","CrossmintFiatPaymentElement_OLD","__spreadValues","isCryptoEmbeddedCheckoutProps","CrossmintCryptoEmbeddedCheckout","useMemo","useState","clientNames","crossmintModalService","crossmintPayButtonService","useEffect","useState","useEnvironment","isServerSideRendering","setIsServerSideRendering","createUseStyles","DARK_BG","themeIsLight","theme","formatProps","useStyles","buttonBgColor","paragraphColor","Fragment","jsx","jsxs","CrossmintPayButton","buttonProps","_a","className","disabled","onClick","style","tabIndex","theme","mintTo","emailTo","listingId","auctionId","showOverlay","mintConfig","whPassThroughArgs","environment","paymentMethod","preferredSigninMethod","dismissOverlayOnClick","prepay","locale","currency","successCallbackURL","failureCallbackURL","loginEmail","projectId","getButtonText","checkoutProps","props","__objRest","collectionId","connecting","setConnecting","useState","isServerSideRendering","useEnvironment","connect","crossmintModalService","LIB_VERSION","clientNames","getButtonTextInternal","handleClick","crossmintPayButtonService","_handleClick","event","classes","useStyles","formatProps","content","useMemo","__spreadValues","CrossmintEvents","useCrossmintEvents"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossmint/client-sdk-react-ui",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.2",
|
|
4
4
|
"author": "Paella Labs Inc",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/Crossmint/crossmint-client-sdk",
|
|
@@ -30,7 +30,10 @@
|
|
|
30
30
|
"test": "jest"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@crossmint/client-sdk-base": "1.1.0-alpha.
|
|
33
|
+
"@crossmint/client-sdk-base": "1.1.0-alpha.2",
|
|
34
|
+
"@ethersproject/transactions": "5.7.0",
|
|
35
|
+
"@solana/web3.js": "1.78.5",
|
|
36
|
+
"bs58": "5.0.0",
|
|
34
37
|
"react-jss": "10.10.0"
|
|
35
38
|
},
|
|
36
39
|
"peerDependencies": {
|
|
@@ -43,5 +46,5 @@
|
|
|
43
46
|
"react": "18.2.0",
|
|
44
47
|
"react-dom": "18.2.0"
|
|
45
48
|
},
|
|
46
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "6442e075dcc56a82d25fb63b1e96e6e0fc342b71"
|
|
47
50
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
|
|
3
|
-
import { crossmintIFrameService } from "@crossmint/client-sdk-base";
|
|
3
|
+
import { IncomingInternalEvent, IncomingInternalEvents, crossmintIFrameService } from "@crossmint/client-sdk-base";
|
|
4
4
|
import { CrossmintEmbeddedCheckoutProps } from "@crossmint/client-sdk-base";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type CrossmintEmbeddedCheckoutIFrameProps = CrossmintEmbeddedCheckoutProps & {
|
|
7
|
+
onInternalEvent?: (event: IncomingInternalEvent) => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default function CrossmintEmbeddedCheckoutIFrame({
|
|
11
|
+
onInternalEvent,
|
|
12
|
+
...props
|
|
13
|
+
}: CrossmintEmbeddedCheckoutIFrameProps) {
|
|
14
|
+
const { getUrl, listenToEvents, listenToInternalEvents, emitInternalEvent } = crossmintIFrameService(props);
|
|
8
15
|
|
|
9
16
|
const [height, setHeight] = useState(0);
|
|
10
17
|
const [url] = useState(getUrl(props));
|
|
@@ -25,13 +32,11 @@ export default function CrossmintEmbeddedCheckoutIFrame(props: CrossmintEmbedded
|
|
|
25
32
|
const clearListener = listenToInternalEvents((event) => {
|
|
26
33
|
const { type, payload } = event.data;
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
setHeight(payload.height);
|
|
31
|
-
break;
|
|
32
|
-
default:
|
|
33
|
-
return;
|
|
35
|
+
if (type === IncomingInternalEvents.UI_HEIGHT_CHANGED) {
|
|
36
|
+
setHeight(payload.height);
|
|
34
37
|
}
|
|
38
|
+
|
|
39
|
+
onInternalEvent?.(event.data);
|
|
35
40
|
});
|
|
36
41
|
|
|
37
42
|
return () => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CryptoEmbeddedCheckoutProps, isCryptoEmbeddedCheckoutPropsWithSigner } from "@crossmint/client-sdk-base";
|
|
2
|
+
|
|
3
|
+
import CryptoEmbeddedCheckoutIFrame from "./CryptoEmbeddedCheckoutIFrame";
|
|
4
|
+
|
|
5
|
+
export function CrossmintCryptoEmbeddedCheckout(props: CryptoEmbeddedCheckoutProps) {
|
|
6
|
+
if (!isCryptoEmbeddedCheckoutPropsWithSigner(props)) {
|
|
7
|
+
throw new Error("Invalid parameters: signer is required in versions < 2.0.0");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return <CryptoEmbeddedCheckoutIFrame {...props} />;
|
|
11
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import bs58 from "bs58";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
CryptoEmbeddedCheckoutPropsWithSigner,
|
|
6
|
+
ETHEmbeddedCheckoutSigner,
|
|
7
|
+
IncomingInternalEvent,
|
|
8
|
+
IncomingInternalEvents,
|
|
9
|
+
OutgoingInternalEvents,
|
|
10
|
+
SOLEmbeddedCheckoutSigner,
|
|
11
|
+
crossmintIFrameService,
|
|
12
|
+
embeddedCheckoutPropsToUpdatableParamsPayload,
|
|
13
|
+
} from "@crossmint/client-sdk-base";
|
|
14
|
+
|
|
15
|
+
import CrossmintEmbeddedCheckoutIFrame from "../EmbeddedCheckoutIFrame";
|
|
16
|
+
|
|
17
|
+
export default function CryptoEmbeddedCheckoutIFrame(props: CryptoEmbeddedCheckoutPropsWithSigner) {
|
|
18
|
+
const { emitInternalEvent } = crossmintIFrameService(props);
|
|
19
|
+
|
|
20
|
+
const { signer, paymentMethod } = props;
|
|
21
|
+
|
|
22
|
+
function onInternalEvent(event: IncomingInternalEvent) {
|
|
23
|
+
const { type, payload } = event;
|
|
24
|
+
|
|
25
|
+
if (type === IncomingInternalEvents.CRYPTO_PAYMENT_INCOMING_TRANSACTION) {
|
|
26
|
+
const { serializedTransaction } = payload;
|
|
27
|
+
console.log("[Crossmint] Received incoming transaction", serializedTransaction);
|
|
28
|
+
handleIncomingTransaction(serializedTransaction);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function handleIncomingTransaction(serializedTransaction: string) {
|
|
33
|
+
try {
|
|
34
|
+
let txId: string;
|
|
35
|
+
switch (paymentMethod) {
|
|
36
|
+
case "SOL":
|
|
37
|
+
txId = await handleSOLTransaction(signer, serializedTransaction);
|
|
38
|
+
break;
|
|
39
|
+
case "ETH":
|
|
40
|
+
txId = await handleETHTransaction(signer, serializedTransaction);
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
throw new Error(`Unsupported payment method ${paymentMethod}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log("[Crossmint] Signed and sent transaction", txId);
|
|
47
|
+
emitInternalEvent({
|
|
48
|
+
type: OutgoingInternalEvents.CRYPTO_PAYMENT_USER_ACCEPTED,
|
|
49
|
+
payload: {
|
|
50
|
+
txId,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error("[Crossmint] Failed to sign and send transaction", e);
|
|
55
|
+
emitInternalEvent({
|
|
56
|
+
type: OutgoingInternalEvents.CRYPTO_PAYMENT_USER_REJECTED,
|
|
57
|
+
payload: {},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function handleSOLTransaction(signer: SOLEmbeddedCheckoutSigner, serializedTransaction: string) {
|
|
63
|
+
// @ts-ignore - Error becasue we dont use 'module' field in tsconfig, which is expected because we use tsup to compile
|
|
64
|
+
const { Transaction } = await import("@solana/web3.js");
|
|
65
|
+
const transaction = Transaction.from(bs58.decode(serializedTransaction));
|
|
66
|
+
console.log("[Crossmint] Deserialized SOL transaction", transaction);
|
|
67
|
+
|
|
68
|
+
return await signer.signAndSendTransaction(transaction);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function handleETHTransaction(signer: ETHEmbeddedCheckoutSigner, serializedTransaction: string) {
|
|
72
|
+
// @ts-ignore - Error becasue we dont use 'module' field in tsconfig, which is expected because we use tsup to compile
|
|
73
|
+
const { parse: parseTransaction } = await import("@ethersproject/transactions");
|
|
74
|
+
const transaction = parseTransaction(serializedTransaction);
|
|
75
|
+
console.log("[Crossmint] Deserialized ETH transaction", transaction);
|
|
76
|
+
|
|
77
|
+
return await signer.signAndSendTransaction(transaction);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
emitInternalEvent({
|
|
82
|
+
type: "params-update",
|
|
83
|
+
payload: embeddedCheckoutPropsToUpdatableParamsPayload(props),
|
|
84
|
+
});
|
|
85
|
+
}, [props.signer, props.recipient, props.mintConfig, props.locale, props.whPassThroughArgs]);
|
|
86
|
+
|
|
87
|
+
return <CrossmintEmbeddedCheckoutIFrame onInternalEvent={onInternalEvent} {...props} />;
|
|
88
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FiatEmbeddedCheckoutProps } from "@crossmint/client-sdk-base";
|
|
2
|
+
|
|
3
|
+
import CrossmintEmbeddedCheckoutIFrame from "../EmbeddedCheckoutIFrame";
|
|
4
|
+
|
|
5
|
+
export default function FiatEmbeddedCheckoutIFrame(props: FiatEmbeddedCheckoutProps) {
|
|
6
|
+
throw new Error(
|
|
7
|
+
"Unsupported: This component should not be called yet, as its a placeholder for the v2 fiat checkout."
|
|
8
|
+
);
|
|
9
|
+
return <CrossmintEmbeddedCheckoutIFrame {...props} />;
|
|
10
|
+
}
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
isFiatEmbeddedCheckoutProps,
|
|
5
5
|
} from "@crossmint/client-sdk-base";
|
|
6
6
|
|
|
7
|
-
import { CrossmintCryptoEmbeddedCheckout } from "./CryptoEmbeddedCheckout";
|
|
8
|
-
import { CrossmintFiatPaymentElement_OLD } from "./FiatPaymentElement_OLD";
|
|
7
|
+
import { CrossmintCryptoEmbeddedCheckout } from "./crypto/CryptoEmbeddedCheckout";
|
|
8
|
+
import { CrossmintFiatPaymentElement_OLD } from "./fiat/FiatPaymentElement_OLD";
|
|
9
9
|
|
|
10
10
|
// TODO: Rename to CrossmintEmbeddedCheckout
|
|
11
11
|
export function CrossmintPaymentElement(props: CrossmintEmbeddedCheckoutProps) {
|
|
@@ -13,8 +13,7 @@ export function CrossmintPaymentElement(props: CrossmintEmbeddedCheckoutProps) {
|
|
|
13
13
|
return <CrossmintFiatPaymentElement_OLD {...props} />;
|
|
14
14
|
}
|
|
15
15
|
if (isCryptoEmbeddedCheckoutProps(props)) {
|
|
16
|
-
|
|
17
|
-
// return <CrossmintCryptoEmbeddedCheckout {...props} />;
|
|
16
|
+
return <CrossmintCryptoEmbeddedCheckout {...props} />;
|
|
18
17
|
}
|
|
19
18
|
throw new Error("Unsupported: Fiat is the only supported payment method.");
|
|
20
19
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
CrossmintPayButtonProps,
|
|
6
6
|
clientNames,
|
|
7
7
|
crossmintModalService,
|
|
8
|
-
crossmintPayButtonService,
|
|
8
|
+
crossmintPayButtonService, CheckoutProps,
|
|
9
9
|
} from "@crossmint/client-sdk-base";
|
|
10
10
|
|
|
11
11
|
import { LIB_VERSION } from "../../consts/version";
|
|
@@ -44,6 +44,11 @@ export function CrossmintPayButton(buttonProps: CrossmintPayButtonReactProps) {
|
|
|
44
44
|
loginEmail = "",
|
|
45
45
|
projectId,
|
|
46
46
|
getButtonText,
|
|
47
|
+
checkoutProps = {
|
|
48
|
+
experimental: false,
|
|
49
|
+
display: "same-tab",
|
|
50
|
+
paymentMethods: ["fiat", "ETH", "SOL"],
|
|
51
|
+
} as CheckoutProps,
|
|
47
52
|
...props
|
|
48
53
|
} = buttonProps;
|
|
49
54
|
|
|
@@ -73,6 +78,7 @@ export function CrossmintPayButton(buttonProps: CrossmintPayButtonReactProps) {
|
|
|
73
78
|
connecting,
|
|
74
79
|
paymentMethod,
|
|
75
80
|
locale,
|
|
81
|
+
checkoutProps
|
|
76
82
|
});
|
|
77
83
|
|
|
78
84
|
const _handleClick = (event: MouseEvent<HTMLButtonElement>) =>
|
|
@@ -85,7 +91,8 @@ export function CrossmintPayButton(buttonProps: CrossmintPayButtonReactProps) {
|
|
|
85
91
|
whPassThroughArgs,
|
|
86
92
|
paymentMethod,
|
|
87
93
|
preferredSigninMethod,
|
|
88
|
-
prepay
|
|
94
|
+
prepay,
|
|
95
|
+
checkoutProps
|
|
89
96
|
);
|
|
90
97
|
});
|
|
91
98
|
|
package/src/consts/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.1.0-alpha.
|
|
1
|
+
export const LIB_VERSION = "1.1.0-alpha.2";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CryptoEmbeddedCheckoutProps } from "@crossmint/client-sdk-base";
|
|
2
|
-
|
|
3
|
-
import CrossmintEmbeddedCheckoutIFrame from "./EmbeddedCheckoutIFrame";
|
|
4
|
-
|
|
5
|
-
export function CrossmintCryptoEmbeddedCheckout(props: CryptoEmbeddedCheckoutProps) {
|
|
6
|
-
const { signer } = props;
|
|
7
|
-
|
|
8
|
-
if (signer == null) {
|
|
9
|
-
throw new Error("Invalid parameters: signer is required in versions < 2.0.0");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return <CrossmintEmbeddedCheckoutIFrame {...props} />;
|
|
13
|
-
}
|
/package/src/components/embed/{FiatPaymentElement_OLD.tsx → fiat/FiatPaymentElement_OLD.tsx}
RENAMED
|
File without changes
|