@ic-pay/icpay-widget 1.1.46 → 1.1.48

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.
@@ -36,6 +36,8 @@ type CommonConfig = {
36
36
  publishableKey: string;
37
37
  apiUrl?: string;
38
38
  icHost?: string;
39
+ chainName?: string;
40
+ chainId?: number;
39
41
  metadata?: Record<string, any>;
40
42
  derivationOrigin?: string;
41
43
  actorProvider?: (canisterId: string, idl: any) => any;
@@ -830,7 +830,7 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var K=Fe`
830
830
  `}
831
831
  </div>
832
832
  </div>
833
- `}import{LitElement as tt,html as pe,css as it}from"lit";import{customElement as nt,property as st,state as L}from"lit/decorators.js";import{IcpayError as De}from"@ic-pay/icpay-sdk";var Z={WALLET_NOT_CONNECTED:"WALLET_NOT_CONNECTED",WALLET_USER_CANCELLED:"WALLET_USER_CANCELLED",WALLET_SIGNATURE_REJECTED:"WALLET_SIGNATURE_REJECTED",INSUFFICIENT_BALANCE:"INSUFFICIENT_BALANCE",NETWORK_ERROR:"NETWORK_ERROR",API_ERROR:"API_ERROR",LEDGER_NOT_FOUND:"LEDGER_NOT_FOUND",TRANSACTION_FAILED:"TRANSACTION_FAILED",TRANSACTION_TIMEOUT:"TRANSACTION_TIMEOUT",UNKNOWN_ERROR:"UNKNOWN_ERROR"},Ye={onError:r=>{console.error("[ICPay Widget] Error:",r)},onUserCancelled:()=>{console.log("[ICPay Widget] User cancelled the action")},onInsufficientBalance:r=>{console.warn("[ICPay Widget] Insufficient balance:",r.message)},onWalletError:r=>{console.warn("[ICPay Widget] Wallet error:",r.message)},onNetworkError:r=>{console.error("[ICPay Widget] Network error:",r.message)}};function U(r,d=Ye){r instanceof De?(d.onError(r),r.isUserCancelled()?d.onUserCancelled?.():r.isBalanceError()?d.onInsufficientBalance?.(r):r.isWalletError()?d.onWalletError?.(r):r.isNetworkError()&&d.onNetworkError?.(r)):(console.error("[ICPay Widget] Unknown error:",r),d.onError(new De({code:Z.UNKNOWN_ERROR,message:r instanceof Error?r.message:"An unknown error occurred",details:r})))}var qe={[Z.WALLET_NOT_CONNECTED]:"Please connect your wallet to continue",[Z.WALLET_USER_CANCELLED]:"User have rejected the transfer",[Z.WALLET_SIGNATURE_REJECTED]:"User have rejected the transfer",[Z.INSUFFICIENT_BALANCE]:"Insufficient balance for this transaction",[Z.NETWORK_ERROR]:"Network error. Please try again",[Z.API_ERROR]:"Service temporarily unavailable",[Z.LEDGER_NOT_FOUND]:"Selected token is not supported",[Z.TRANSACTION_FAILED]:"Transaction failed. Please try again",[Z.TRANSACTION_TIMEOUT]:"Transaction timed out. Please try again",[Z.UNKNOWN_ERROR]:"Something went wrong. Please try again"};function $(r){return qe[r.code]||r.message||"An error occurred"}function D(r){return!r.isUserCancelled()}function B(r){return null}function z(r){return r.isUserCancelled()?"info":r.isBalanceError()||r.isWalletError()?"warning":"error"}import{LitElement as Ze,html as re,css as Je}from"lit";import{customElement as Xe,property as ae}from"lit/decorators.js";import{query as Be}from"lit/decorators.js";var H=class extends Ze{constructor(){super(...arguments);this.options=[];this.value=null;this.defaultSymbol="ICP";this.mode="buttons";this.open=!1;this.showLabel=!0;this.menuPos={left:0,top:0,width:0}}connectedCallback(){super.connectedCallback();try{de(this,this.theme)}catch{}}updated(e){if(e.has("theme"))try{de(this,this.theme)}catch{}}firstUpdated(){let e=i=>{if(!this.open)return;i.composedPath().includes(this)||this.closeDropdown()},t=i=>{i.key==="Escape"&&this.open&&this.closeDropdown()};this._onDocClick=e,this._onKey=t,window.addEventListener("click",e),window.addEventListener("keydown",t)}disconnectedCallback(){super.disconnectedCallback();let e=this._onDocClick,t=this._onKey;e&&window.removeEventListener("click",e),t&&window.removeEventListener("keydown",t)}get effectiveSymbol(){if(this.value)return this.value;let e=this.options?.[0]?.symbol;return this.defaultSymbol||e||"ICP"}getOptionBySymbol(e){return(this.options||[]).find(t=>t.symbol===e)}getLogoUrl(e){return`https://widget.icpay.org/ledger/${String(e||"").toLowerCase()}.svg`}onSelect(e){this.value=e,this.requestUpdate("value"),this.open=!1,this.dispatchEvent(new CustomEvent("icpay-token-change",{detail:{symbol:e},bubbles:!0,composed:!0}))}toggleDropdown(){this.open=!this.open}closeDropdown(){this.open=!1}render(){let e=this.options||[];if(this.mode==="none"||e.length<=1){let i=e.length===1?e[0].symbol:this.effectiveSymbol;return this.value!==i&&queueMicrotask(()=>this.onSelect(i)),re``}if(this.mode==="dropdown"){let i=this.effectiveSymbol,s=this.getOptionBySymbol(i)||{symbol:i,label:i};return re`
833
+ `}import{LitElement as tt,html as pe,css as it}from"lit";import{customElement as nt,property as st,state as L}from"lit/decorators.js";import{IcpayError as De}from"@ic-pay/icpay-sdk";var Z={WALLET_NOT_CONNECTED:"WALLET_NOT_CONNECTED",WALLET_USER_CANCELLED:"WALLET_USER_CANCELLED",WALLET_SIGNATURE_REJECTED:"WALLET_SIGNATURE_REJECTED",INSUFFICIENT_BALANCE:"INSUFFICIENT_BALANCE",NETWORK_ERROR:"NETWORK_ERROR",API_ERROR:"API_ERROR",LEDGER_NOT_FOUND:"LEDGER_NOT_FOUND",TRANSACTION_FAILED:"TRANSACTION_FAILED",TRANSACTION_TIMEOUT:"TRANSACTION_TIMEOUT",UNKNOWN_ERROR:"UNKNOWN_ERROR"},Ye={onError:r=>{console.error("[ICPay Widget] Error:",r)},onUserCancelled:()=>{console.log("[ICPay Widget] User cancelled the action")},onInsufficientBalance:r=>{console.warn("[ICPay Widget] Insufficient balance:",r.message)},onWalletError:r=>{console.warn("[ICPay Widget] Wallet error:",r.message)},onNetworkError:r=>{console.error("[ICPay Widget] Network error:",r.message)}};function U(r,d=Ye){r instanceof De?(d.onError(r),r.isUserCancelled()?d.onUserCancelled?.():r.isBalanceError()?d.onInsufficientBalance?.(r):r.isWalletError()?d.onWalletError?.(r):r.isNetworkError()&&d.onNetworkError?.(r)):(console.error("[ICPay Widget] Unknown error:",r),d.onError(new De({code:Z.UNKNOWN_ERROR,message:r instanceof Error?r.message:"An unknown error occurred",details:r})))}var qe={[Z.WALLET_NOT_CONNECTED]:"Please connect your wallet to continue",[Z.WALLET_USER_CANCELLED]:"User have rejected the transfer",[Z.WALLET_SIGNATURE_REJECTED]:"User have rejected the transfer",[Z.INSUFFICIENT_BALANCE]:"Insufficient balance for this transaction",[Z.NETWORK_ERROR]:"Network error. Please try again",[Z.API_ERROR]:"Service temporarily unavailable",[Z.LEDGER_NOT_FOUND]:"Selected token is not supported",[Z.TRANSACTION_FAILED]:"Transaction failed. Please try again",[Z.TRANSACTION_TIMEOUT]:"Transaction timed out. Please try again",[Z.UNKNOWN_ERROR]:"Something went wrong. Please try again"};function $(r){return qe[r.code]||r.message||"An error occurred"}function D(r){return!r.isUserCancelled()}function B(r){return null}function z(r){return r.isUserCancelled()?"info":r.isBalanceError()||r.isWalletError()?"warning":"error"}import{LitElement as Ze,html as re,css as Je}from"lit";import{customElement as Xe,property as ae}from"lit/decorators.js";import{query as Be}from"lit/decorators.js";var H=class extends Ze{constructor(){super(...arguments);this.options=[];this.value=null;this.defaultSymbol="ICP";this.mode="buttons";this.open=!1;this.showLabel=!0;this.menuPos={left:0,top:0,width:0}}connectedCallback(){super.connectedCallback();try{de(this,this.theme)}catch{}}updated(e){if(e.has("theme"))try{de(this,this.theme)}catch{}}firstUpdated(){let e=i=>{if(!this.open)return;i.composedPath().includes(this)||this.closeDropdown()},t=i=>{i.key==="Escape"&&this.open&&this.closeDropdown()};this._onDocClick=e,this._onKey=t,window.addEventListener("click",e),window.addEventListener("keydown",t)}disconnectedCallback(){super.disconnectedCallback();let e=this._onDocClick,t=this._onKey;e&&window.removeEventListener("click",e),t&&window.removeEventListener("keydown",t)}get effectiveSymbol(){if(this.value)return this.value;let e=this.options?.[0]?.symbol;return this.defaultSymbol||e||"ICP"}getOptionBySymbol(e){return(this.options||[]).find(t=>t.symbol===e)}getLogoUrl(e){let t=String(e||"").toLowerCase(),i=(this.getAttribute("chain-name")||window?.ICPay?.config?.chainName||"IC").toLowerCase();return`${window?.ICPay?.config?.widgetBaseUrl||"https://widget.icpay.org"}/img/tokens/${i}/${t}.svg`}onSelect(e){this.value=e,this.requestUpdate("value"),this.open=!1,this.dispatchEvent(new CustomEvent("icpay-token-change",{detail:{symbol:e},bubbles:!0,composed:!0}))}toggleDropdown(){this.open=!this.open}closeDropdown(){this.open=!1}render(){let e=this.options||[];if(this.mode==="none"||e.length<=1){let i=e.length===1?e[0].symbol:this.effectiveSymbol;return this.value!==i&&queueMicrotask(()=>this.onSelect(i)),re``}if(this.mode==="dropdown"){let i=this.effectiveSymbol,s=this.getOptionBySymbol(i)||{symbol:i,label:i};return re`
834
834
  ${this.showLabel?re`<label class="icpay-dropdown-label">Payment method</label>`:null}
835
835
  <div class="dropdown-wrapper">
836
836
  <div class="dropdown-trigger ${this.open?"open":""}" @click=${()=>this.toggleDropdown()}>
@@ -1499,4 +1499,4 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var K=Fe`
1499
1499
  .top-row { grid-template-columns: 1fr; }
1500
1500
  }
1501
1501
  `],n([Ct({type:Object})],w.prototype,"config",2),n([I()],w.prototype,"amountUsd",2),n([I()],w.prototype,"hasUserAmount",2),n([I()],w.prototype,"selectedSymbol",2),n([I()],w.prototype,"processing",2),n([I()],w.prototype,"succeeded",2),n([I()],w.prototype,"availableLedgers",2),n([I()],w.prototype,"errorMessage",2),n([I()],w.prototype,"errorSeverity",2),n([I()],w.prototype,"errorAction",2),n([I()],w.prototype,"walletConnected",2),n([I()],w.prototype,"pendingAction",2),n([I()],w.prototype,"showWalletModal",2),n([I()],w.prototype,"showOnrampModal",2),n([I()],w.prototype,"onrampSessionId",2),n([I()],w.prototype,"onrampPaymentIntentId",2),n([I()],w.prototype,"onrampErrorMessage",2),n([I()],w.prototype,"oisyReadyToPay",2),n([I()],w.prototype,"lastWalletId",2),w=n([Ot("icpay-amount-input")],w);export{K as a,de as b,g as c,j as d,S as e,f,m as g,E as h,b as i,v as j,w as k};
1502
- //# sourceMappingURL=chunk-EEWBUAJY.js.map
1502
+ //# sourceMappingURL=chunk-DDCE2AR4.js.map