@crossmint/client-sdk-base
Advanced tools
Comparing version 0.1.3-alpha.1 to 0.1.3-alpha.2
@@ -17,5 +17,6 @@ declare function generateClientId(): string; | ||
declare type theme = "light" | "dark"; | ||
declare type paymentMethods = "fiat" | "ETH"; | ||
declare type paymentMethods = "fiat" | "ETH" | "SOL"; | ||
declare const paymentMethodIsEth: (paymentMethod?: paymentMethods | undefined) => boolean; | ||
declare type SigninMethods = "metamask"; | ||
declare const paymentMethodIsSol: (paymentMethod?: paymentMethods | undefined) => boolean; | ||
declare type SigninMethods = "metamask" | "solana"; | ||
declare enum mintingContractTypes { | ||
@@ -92,3 +93,3 @@ CANDY_MACHINE = "candy-machine", | ||
checkProps: ({ collectionTitle, collectionDescription, collectionPhoto }: any) => any[]; | ||
getButtonText: (connecting: boolean) => "Connecting..." | "Buy with ETH" | "Buy with credit card"; | ||
getButtonText: (connecting: boolean) => "Connecting..." | "Buy with ETH" | "Buy with SOL" | "Buy with credit card"; | ||
shouldHideButton: ({ hideMintOnInactiveClient, status }: any) => any; | ||
@@ -122,2 +123,2 @@ handleClick: (event: any, cb: () => void) => void; | ||
export { BaseButtonProps, CrossmintModalServiceReturn, CrossmintPayButtonProps, OnboardingQueryParams, PayButtonConfig, SigninMethods, baseUrls, clientNames, crossmintModalService, crossmintPayButtonService, crossmintStatusButtonService, crossmintStatusService, customHeaders, generateClientId, mintingContractTypes, onboardingRequestStatusResponse, paymentMethodIsEth, paymentMethods }; | ||
export { BaseButtonProps, CrossmintModalServiceReturn, CrossmintPayButtonProps, OnboardingQueryParams, PayButtonConfig, SigninMethods, baseUrls, clientNames, crossmintModalService, crossmintPayButtonService, crossmintStatusButtonService, crossmintStatusService, customHeaders, generateClientId, mintingContractTypes, onboardingRequestStatusResponse, paymentMethodIsEth, paymentMethodIsSol, paymentMethods }; |
@@ -1,1 +0,1 @@ | ||
import{v4 as x}from"uuid";function H(){return x()}var X=(e=>(e.reactUi="client-sdk-react-ui",e.vanillaUi="client-sdk-vanilla-ui",e))(X||{}),_=(o=>(o.prod="https://www.crossmint.io",o.staging="https://staging.crossmint.io/",o.dev="http://localhost:3001",o))(_||{}),U=(e=>(e.clientVersion="X-Client-Version",e.clientName="X-Client-Name",e))(U||{}),T=t=>t==="ETH",D=(o=>(o.CANDY_MACHINE="candy-machine",o.SOLANA_AUCTION="solana-auction",o.ERC_721="erc-721",o))(D||{}),N=(r=>(r.WAITING_SUBMISSION="waiting-submission",r.PENDING="pending",r.REJECTED="rejected",r.ACCEPTED="accepted",r.INVALID="invalid",r))(N||{});var y=(t="")=>{let n=["prod","production"];return t==="staging"?"https://staging.crossmint.io/":n.includes(t)||!t?"https://www.crossmint.io":t};var O="__crossmint-overlay__",R=()=>{let t=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);return t?parseInt(t[2]):null};function A(){let t=window.innerWidth/2-200,n=window.innerHeight/2-375,e=R();return`${e&&e>99?"popup=true,":""}height=750,width=400,left=${t},top=${n},resizable=yes,scrollbars=yes,toolbar=yes,menubar=true,location=no,directories=no, status=yes`}var k=()=>{let t=document.createElement("div");t.setAttribute("id",O);let n={width:"100vw",height:"100vh","background-color":"rgba(0, 0, 0, 0.5)",position:"fixed","z-index":"99999999",top:"0",left:"0"};Object.assign(t.style,n),document.body.appendChild(t)},L=()=>{let t=document.getElementById(O);t&&t.remove()};function F({clientId:t,libVersion:n,showOverlay:e,setConnecting:o,environment:a,clientName:r}){let f=(d,c,i,u,h,I,C,S,P,v)=>{let w=y(a),E=encodeURIComponent(`${w}/checkout/mint?${(()=>{let g={clientId:t,closeOnSuccess:"false",clientName:r,clientVersion:n,mintConfig:JSON.stringify(d)};return c&&(g.collectionTitle=c),i&&(g.collectionDescription=i),u&&(g.collectionPhoto=u),h&&(g.mintTo=h),I&&(g.emailTo=I),C&&(g.listingId=C),S&&(g.whPassThroughArgs=JSON.stringify(S)),P&&(g.paymentMethod=P),v&&(g.preferredSigninMethod=v),new URLSearchParams(g).toString()})()}`),M=`${w}/signin?callbackUrl=${E}`,B=window.open(M,"popUpWindow",A());if(B){l(B),e&&k();return}o(!1),window.open(M,"_blank")||console.error("Failed to open popup window and new tab")},s=(d,c,i,u,h,I,C,S,P,v)=>{o(!0),f(d,c,i,u,h,I,C,S,P,v)};function l(d){let c=setInterval(function(){d.closed&&(clearInterval(c),o(!1),e&&L())},500)}return{connect:s}}function tt({onClick:t,connecting:n,paymentMethod:e}){return{checkProps:({collectionTitle:s,collectionDescription:l,collectionPhoto:d})=>{let c=s,i=l,u=d;return s==="<TITLE_FOR_YOUR_COLLECTION>"&&(console.warn("No collection title specified. Please add a collection title to your <CrossmintPayButton />"),c=""),l==="<DESCRIPTION_OF_YOUR_COLLECTION>"&&(console.warn("No collection description specified. Please add a collection description to your <CrossmintPayButton />"),i=""),d==="<OPT_URL_TO_PHOTO_COVER>"&&(console.warn("No collection photo specified. Please add a collection photo to your <CrossmintPayButton />"),u=""),[c,i,u]},getButtonText:s=>s?"Connecting...":T(e)?"Buy with ETH":"Buy with credit card",shouldHideButton:({hideMintOnInactiveClient:s,status:l})=>s&&l!=="accepted",handleClick:(s,l)=>{t&&t(s),!n&&(s.defaultPrevented||l())}}}var V=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function b(t){return typeof t=="string"&&V.test(t)}var $=t=>{try{return b(t)}catch(n){return console.error(n),!1}};function rt({libVersion:t,clientId:n,platformId:e,auctionId:o,mintConfig:a,setStatus:r,environment:f,clientName:s}){async function l(){if(!n||n===""||n==="<YOUR_CLIENT_ID>"){console.error("You must enter your own Crossmint client ID in <CrossmintPayButton clientId=XXX>");return}if(!$(n)){console.error("The clientId passed to is invalid. Make sure to pass the clientId obtained from the crossmint team, with format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX");return}let i=y(f),u=await fetch(`${i}/api/crossmint/onboardingRequests/${n}/status`,{headers:{["X-Client-Version"]:t,["X-Client-Name"]:s}});if(u.status===200){let h=await u.json();r(h.status)}else r("invalid")}let d=()=>{let i=y(f);window.open(`${i}/developers/onboarding?${c()}`,"_blank")},c=()=>{let i={clientId:n};return e&&(i.platformId=e),o&&(i.auctionId=o),a&&(i.mintConfig=JSON.stringify(a)),new URLSearchParams(i).toString()};return{fetchClientIntegration:l,goToOnboarding:d}}function at({onClick:t}){return{getButtonText:a=>{switch(a){case"invalid":return"Invalid clientId";case"waiting-submission":return"Click here to setup Crossmint";case"pending":return"Your application is under review";case"accepted":return"You're good to go!";case"rejected":return"Your application was rejected"}},isButtonDisabled:a=>a!=="waiting-submission",handleClick:(a,r,f)=>{t&&t(a),r==="waiting-submission"&&f()}}}export{_ as baseUrls,X as clientNames,F as crossmintModalService,tt as crossmintPayButtonService,at as crossmintStatusButtonService,rt as crossmintStatusService,U as customHeaders,H as generateClientId,D as mintingContractTypes,N as onboardingRequestStatusResponse,T as paymentMethodIsEth}; | ||
import{v4 as N}from"uuid";function H(){return N()}var E=(e=>(e.reactUi="client-sdk-react-ui",e.vanillaUi="client-sdk-vanilla-ui",e))(E||{}),x=(o=>(o.prod="https://www.crossmint.io",o.staging="https://staging.crossmint.io/",o.dev="http://localhost:3001",o))(x||{}),X=(e=>(e.clientVersion="X-Client-Version",e.clientName="X-Client-Name",e))(X||{}),W=t=>t==="ETH",J=t=>t==="SOL",_=(o=>(o.CANDY_MACHINE="candy-machine",o.SOLANA_AUCTION="solana-auction",o.ERC_721="erc-721",o))(_||{}),U=(r=>(r.WAITING_SUBMISSION="waiting-submission",r.PENDING="pending",r.REJECTED="rejected",r.ACCEPTED="accepted",r.INVALID="invalid",r))(U||{});var y=(t="")=>{let n=["prod","production"];return t==="staging"?"https://staging.crossmint.io/":n.includes(t)||!t?"https://www.crossmint.io":t};var T="__crossmint-overlay__",D=()=>{let t=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);return t?parseInt(t[2]):null};function R(){let t=window.innerWidth/2-200,n=window.innerHeight/2-375,e=D();return`${e&&e>99?"popup=true,":""}height=750,width=400,left=${t},top=${n},resizable=yes,scrollbars=yes,toolbar=yes,menubar=true,location=no,directories=no, status=yes`}var A=()=>{let t=document.createElement("div");t.setAttribute("id",T);let n={width:"100vw",height:"100vh","background-color":"rgba(0, 0, 0, 0.5)",position:"fixed","z-index":"99999999",top:"0",left:"0"};Object.assign(t.style,n),document.body.appendChild(t)},L=()=>{let t=document.getElementById(T);t&&t.remove()};function z({clientId:t,libVersion:n,showOverlay:e,setConnecting:o,environment:a,clientName:r}){let f=(d,c,i,u,h,I,S,C,P,v)=>{let M=y(a),O=encodeURIComponent(`${M}/checkout/mint?${(()=>{let g={clientId:t,closeOnSuccess:"false",clientName:r,clientVersion:n,mintConfig:JSON.stringify(d)};return c&&(g.collectionTitle=c),i&&(g.collectionDescription=i),u&&(g.collectionPhoto=u),h&&(g.mintTo=h),I&&(g.emailTo=I),S&&(g.listingId=S),C&&(g.whPassThroughArgs=JSON.stringify(C)),P&&(g.paymentMethod=P),v&&(g.preferredSigninMethod=v),new URLSearchParams(g).toString()})()}`),b=`${M}/signin?callbackUrl=${O}`,B=window.open(b,"popUpWindow",R());if(B){l(B),e&&A();return}o(!1),window.open(b,"_blank")||console.error("Failed to open popup window and new tab")},s=(d,c,i,u,h,I,S,C,P,v)=>{o(!0),f(d,c,i,u,h,I,S,C,P,v)};function l(d){let c=setInterval(function(){d.closed&&(clearInterval(c),o(!1),e&&L())},500)}return{connect:s}}function Z({onClick:t,connecting:n,paymentMethod:e}){return{checkProps:({collectionTitle:s,collectionDescription:l,collectionPhoto:d})=>{let c=s,i=l,u=d;return s==="<TITLE_FOR_YOUR_COLLECTION>"&&(console.warn("No collection title specified. Please add a collection title to your <CrossmintPayButton />"),c=""),l==="<DESCRIPTION_OF_YOUR_COLLECTION>"&&(console.warn("No collection description specified. Please add a collection description to your <CrossmintPayButton />"),i=""),d==="<OPT_URL_TO_PHOTO_COVER>"&&(console.warn("No collection photo specified. Please add a collection photo to your <CrossmintPayButton />"),u=""),[c,i,u]},getButtonText:s=>{if(s)return"Connecting...";switch(e){case"ETH":return"Buy with ETH";case"SOL":return"Buy with SOL";default:return"Buy with credit card"}},shouldHideButton:({hideMintOnInactiveClient:s,status:l})=>s&&l!=="accepted",handleClick:(s,l)=>{t&&t(s),!n&&(s.defaultPrevented||l())}}}var k=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function w(t){return typeof t=="string"&&k.test(t)}var V=t=>{try{return w(t)}catch(n){return console.error(n),!1}};function it({libVersion:t,clientId:n,platformId:e,auctionId:o,mintConfig:a,setStatus:r,environment:f,clientName:s}){async function l(){if(!n||n===""||n==="<YOUR_CLIENT_ID>"){console.error("You must enter your own Crossmint client ID in <CrossmintPayButton clientId=XXX>");return}if(!V(n)){console.error("The clientId passed to is invalid. Make sure to pass the clientId obtained from the crossmint team, with format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX");return}let i=y(f),u=await fetch(`${i}/api/crossmint/onboardingRequests/${n}/status`,{headers:{["X-Client-Version"]:t,["X-Client-Name"]:s}});if(u.status===200){let h=await u.json();r(h.status)}else r("invalid")}let d=()=>{let i=y(f);window.open(`${i}/developers/onboarding?${c()}`,"_blank")},c=()=>{let i={clientId:n};return e&&(i.platformId=e),o&&(i.auctionId=o),a&&(i.mintConfig=JSON.stringify(a)),new URLSearchParams(i).toString()};return{fetchClientIntegration:l,goToOnboarding:d}}function st({onClick:t}){return{getButtonText:a=>{switch(a){case"invalid":return"Invalid clientId";case"waiting-submission":return"Click here to setup Crossmint";case"pending":return"Your application is under review";case"accepted":return"You're good to go!";case"rejected":return"Your application was rejected"}},isButtonDisabled:a=>a!=="waiting-submission",handleClick:(a,r,f)=>{t&&t(a),r==="waiting-submission"&&f()}}}export{x as baseUrls,E as clientNames,z as crossmintModalService,Z as crossmintPayButtonService,st as crossmintStatusButtonService,it as crossmintStatusService,X as customHeaders,H as generateClientId,_ as mintingContractTypes,U as onboardingRequestStatusResponse,W as paymentMethodIsEth,J as paymentMethodIsSol}; |
{ | ||
"name": "@crossmint/client-sdk-base", | ||
"version": "0.1.3-alpha.1", | ||
"version": "0.1.3-alpha.2", | ||
"author": "Paella Labs Inc", | ||
@@ -34,3 +34,3 @@ "license": "Apache-2.0", | ||
}, | ||
"gitHead": "e385eef7fa9c9c995352993f92352d03af1d8eef" | ||
"gitHead": "e25a4b840ca9f552ab091917e4fb846d30b22da2" | ||
} |
@@ -19,7 +19,7 @@ export enum clientNames { | ||
export type paymentMethods = "fiat" | "ETH"; | ||
export type paymentMethods = "fiat" | "ETH" | "SOL"; | ||
export const paymentMethodIsEth = (paymentMethod?: paymentMethods) => paymentMethod === "ETH"; | ||
export const paymentMethodIsSol = (paymentMethod?: paymentMethods) => paymentMethod === "SOL"; | ||
// TODO: Add more signin methods when needed | ||
export type SigninMethods = "metamask"; | ||
export type SigninMethods = "metamask" | "solana"; | ||
@@ -26,0 +26,0 @@ export enum mintingContractTypes { |
@@ -1,2 +0,7 @@ | ||
import { onboardingRequestStatusResponse, paymentMethodIsEth, paymentMethods } from "../models/types"; | ||
import { | ||
onboardingRequestStatusResponse, | ||
paymentMethodIsEth, | ||
paymentMethodIsSol, | ||
paymentMethods, | ||
} from "../models/types"; | ||
@@ -33,5 +38,13 @@ interface IProps { | ||
const getButtonText = (connecting: boolean) => { | ||
if (connecting) return "Connecting..."; | ||
if (paymentMethodIsEth(paymentMethod)) return "Buy with ETH"; | ||
return "Buy with credit card"; | ||
if (connecting) { | ||
return "Connecting..."; | ||
} | ||
switch (paymentMethod) { | ||
case "ETH": | ||
return "Buy with ETH"; | ||
case "SOL": | ||
return "Buy with SOL"; | ||
default: | ||
return "Buy with credit card"; | ||
} | ||
}; | ||
@@ -38,0 +51,0 @@ const shouldHideButton = ({ hideMintOnInactiveClient, status }: any) => |
Sorry, the diff of this file is not supported yet
43266
589