cppay-sdk 0.0.2-beta.5 → 0.0.2-beta.6
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/react.cjs +1 -6
- package/dist/react.js +118 -295
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,
|
|
2
|
-
let props = %s;
|
|
3
|
-
<%s {...props} />
|
|
4
|
-
React keys must be passed directly to JSX without using spread:
|
|
5
|
-
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),p=o(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=d():t.exports=f()})),m=p(),h=({open:e,onClose:t,apiKey:n,orderId:r,amount:i,onSuccess:a,onError:o})=>{let s=(0,u.useMemo)(()=>new l.t(n),[n]),[c,d]=(0,u.useState)(`select`),[f,p]=(0,u.useState)(!1),[h,g]=(0,u.useState)([]),[_,v]=(0,u.useState)(``),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(null),C=(0,u.useMemo)(()=>h.find(e=>e.chain===_),[h,_]),w=(0,u.useMemo)(()=>C?.tokens||[],[C]),T=(0,u.useMemo)(()=>w.find(e=>e.symbol===y),[w,y]),E=(0,u.useMemo)(()=>y?(parseFloat(i)/1).toFixed(6):`0`,[i,y,1]),D=async()=>{try{p(!0);let e=await s.getSupportedChains();g(e),e.length>0&&v(e[0].chain)}catch(e){o?.(e)}finally{p(!1)}},O=async()=>{if(!(!_||!y))try{p(!0);let e=await s.createPayment({paymentChain:_,paymentToken:y,orderId:r,amount:E});S({paymentId:e.paymentId,paymentAmount:e.paymentAmount,receiveAddress:T?.receiveAddresses[0]||``}),d(`payment`)}catch(e){o?.(e)}finally{p(!1)}},k=async()=>{if(x)try{p(!0),await s.checkPaymentStatus(x.paymentId,1e3),a?.(x.paymentId),j()}catch(e){o?.(e)}finally{p(!1)}},A=async()=>{x?.receiveAddress&&await navigator.clipboard.writeText(x.receiveAddress)},j=()=>{t(),setTimeout(()=>{d(`select`),S(null)},300)};return(0,u.useEffect)(()=>{e&&h.length===0&&D()},[e]),(0,u.useEffect)(()=>{w.length>0&&b(w[0].symbol)},[w]),e?(0,m.jsx)(`div`,{className:`_cppay-overlay`,onClick:e=>e.target===e.currentTarget&&j(),children:(0,m.jsxs)(`div`,{className:`_cppay-dialog`,children:[(0,m.jsxs)(`div`,{className:`_cppay-header`,children:[(0,m.jsx)(`h2`,{className:`_cppay-title`,children:c===`select`?`选择支付方式`:`完成支付`}),(0,m.jsx)(`button`,{onClick:j,disabled:f,className:`_cppay-close-btn`,children:(0,m.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,m.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]}),(0,m.jsx)(`div`,{className:`_cppay-content`,children:c===`select`?(0,m.jsxs)(`div`,{children:[(0,m.jsxs)(`div`,{className:`_cppay-section`,children:[(0,m.jsx)(`label`,{className:`_cppay-label`,children:`支付网络`}),(0,m.jsx)(`div`,{className:`_cppay-grid`,children:h.map(e=>(0,m.jsxs)(`button`,{onClick:()=>v(e.chain),className:`_cppay-select-btn ${_===e.chain?`_cppay-selected`:``}`,children:[e.icon&&(0,m.jsx)(`img`,{src:e.icon,alt:e.chain}),(0,m.jsx)(`span`,{children:e.chain})]},e.chain))})]}),(0,m.jsxs)(`div`,{className:`_cppay-section`,children:[(0,m.jsx)(`label`,{className:`_cppay-label`,children:`支付代币`}),(0,m.jsx)(`div`,{className:`_cppay-grid`,children:w.map(e=>(0,m.jsxs)(`button`,{onClick:()=>b(e.symbol),className:`_cppay-select-btn ${y===e.symbol?`_cppay-selected`:``}`,children:[e.icon&&(0,m.jsx)(`img`,{src:e.icon,alt:e.symbol}),(0,m.jsx)(`span`,{children:e.symbol})]},e.symbol))})]}),(0,m.jsx)(`div`,{className:`_cppay-section`,children:(0,m.jsx)(`div`,{className:`_cppay-price-box`,children:(0,m.jsxs)(`div`,{className:`_cppay-price-row`,children:[(0,m.jsx)(`span`,{className:`_cppay-price-label`,children:`支付金额`}),(0,m.jsxs)(`div`,{className:`_cppay-price-amount`,children:[(0,m.jsxs)(`div`,{className:`_cppay-price-main`,children:[E,` `,y]}),(0,m.jsxs)(`div`,{className:`_cppay-price-sub`,children:[`≈ $`,i]})]})]})})}),(0,m.jsx)(`div`,{className:`_cppay-section`,children:(0,m.jsx)(`button`,{onClick:O,disabled:!_||!y||f,className:`_cppay-btn _cppay-btn-primary`,children:f?`处理中...`:`继续支付`})})]}):x&&(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`_cppay-qr-container`,children:(0,m.jsx)(`div`,{className:`_cppay-qr-placeholder`,children:(0,m.jsx)(`span`,{children:`扫码支付`})})}),(0,m.jsxs)(`div`,{className:`_cppay-section`,children:[(0,m.jsxs)(`div`,{className:`_cppay-info-box`,children:[(0,m.jsx)(`div`,{className:`_cppay-info-label`,children:`支付金额`}),(0,m.jsxs)(`div`,{className:`_cppay-info-value`,children:[x.paymentAmount,` `,y]})]}),(0,m.jsxs)(`div`,{className:`_cppay-info-box`,children:[(0,m.jsx)(`div`,{className:`_cppay-info-label`,children:`支付地址`}),(0,m.jsxs)(`div`,{className:`_cppay-address-row`,children:[(0,m.jsx)(`code`,{children:x.receiveAddress}),(0,m.jsx)(`button`,{onClick:A,className:`_cppay-copy-btn`,title:`复制地址`,children:(0,m.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,m.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})})})]})]})]}),(0,m.jsx)(`div`,{className:`_cppay-section`,children:(0,m.jsx)(`button`,{onClick:k,disabled:f,className:`_cppay-btn _cppay-btn-primary`,children:f?`检查支付状态...`:`我已完成支付`})}),(0,m.jsx)(`div`,{className:`_cppay-section`,children:(0,m.jsx)(`button`,{onClick:()=>d(`select`),disabled:f,className:`_cppay-btn _cppay-btn-secondary`,children:`更改支付方式`})})]})})]})}):null},g=u.default.memo(h);exports.PaymentDialog=g,exports.t=c;
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./cppay-rxbtyzyZ.cjs`);;/* empty css */let l=require(`react`);l=s(l);let u=require(`react/jsx-runtime`);var d=({open:e,onClose:t,apiKey:n,orderId:r,amount:i,onSuccess:a,onError:o})=>{let s=(0,l.useMemo)(()=>new c.t(n),[n]),[d,f]=(0,l.useState)(`select`),[p,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)([]),[_,v]=(0,l.useState)(``),[y,b]=(0,l.useState)(``),[x,S]=(0,l.useState)(null),C=(0,l.useMemo)(()=>h.find(e=>e.chain===_),[h,_]),w=(0,l.useMemo)(()=>C?.tokens||[],[C]),T=(0,l.useMemo)(()=>w.find(e=>e.symbol===y),[w,y]),E=(0,l.useMemo)(()=>y?(parseFloat(i)/1).toFixed(6):`0`,[i,y,1]),D=async()=>{try{m(!0);let e=await s.getSupportedChains();g(e),e.length>0&&v(e[0].chain)}catch(e){o?.(e)}finally{m(!1)}},O=async()=>{if(!(!_||!y))try{m(!0);let e=await s.createPayment({paymentChain:_,paymentToken:y,orderId:r,amount:E});S({paymentId:e.paymentId,paymentAmount:e.paymentAmount,receiveAddress:T?.receiveAddresses[0]||``}),f(`payment`)}catch(e){o?.(e)}finally{m(!1)}},k=async()=>{if(x)try{m(!0),await s.checkPaymentStatus(x.paymentId,1e3),a?.(x.paymentId),j()}catch(e){o?.(e)}finally{m(!1)}},A=async()=>{x?.receiveAddress&&await navigator.clipboard.writeText(x.receiveAddress)},j=()=>{t(),setTimeout(()=>{f(`select`),S(null)},300)};return(0,l.useEffect)(()=>{e&&h.length===0&&D()},[e]),(0,l.useEffect)(()=>{w.length>0&&b(w[0].symbol)},[w]),e?(0,u.jsx)(`div`,{className:`_cppay-overlay`,onClick:e=>e.target===e.currentTarget&&j(),children:(0,u.jsxs)(`div`,{className:`_cppay-dialog`,children:[(0,u.jsxs)(`div`,{className:`_cppay-header`,children:[(0,u.jsx)(`h2`,{className:`_cppay-title`,children:d===`select`?`选择支付方式`:`完成支付`}),(0,u.jsx)(`button`,{onClick:j,disabled:p,className:`_cppay-close-btn`,children:(0,u.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,u.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]}),(0,u.jsx)(`div`,{className:`_cppay-content`,children:d===`select`?(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[(0,u.jsx)(`label`,{className:`_cppay-label`,children:`支付网络`}),(0,u.jsx)(`div`,{className:`_cppay-grid`,children:h.map(e=>(0,u.jsxs)(`button`,{onClick:()=>v(e.chain),className:`_cppay-select-btn ${_===e.chain?`_cppay-selected`:``}`,children:[e.icon&&(0,u.jsx)(`img`,{src:e.icon,alt:e.chain}),(0,u.jsx)(`span`,{children:e.chain})]},e.chain))})]}),(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[(0,u.jsx)(`label`,{className:`_cppay-label`,children:`支付代币`}),(0,u.jsx)(`div`,{className:`_cppay-grid`,children:w.map(e=>(0,u.jsxs)(`button`,{onClick:()=>b(e.symbol),className:`_cppay-select-btn ${y===e.symbol?`_cppay-selected`:``}`,children:[e.icon&&(0,u.jsx)(`img`,{src:e.icon,alt:e.symbol}),(0,u.jsx)(`span`,{children:e.symbol})]},e.symbol))})]}),(0,u.jsx)(`div`,{className:`_cppay-section`,children:(0,u.jsx)(`div`,{className:`_cppay-price-box`,children:(0,u.jsxs)(`div`,{className:`_cppay-price-row`,children:[(0,u.jsx)(`span`,{className:`_cppay-price-label`,children:`支付金额`}),(0,u.jsxs)(`div`,{className:`_cppay-price-amount`,children:[(0,u.jsxs)(`div`,{className:`_cppay-price-main`,children:[E,` `,y]}),(0,u.jsxs)(`div`,{className:`_cppay-price-sub`,children:[`≈ $`,i]})]})]})})}),(0,u.jsx)(`div`,{className:`_cppay-section`,children:(0,u.jsx)(`button`,{onClick:O,disabled:!_||!y||p,className:`_cppay-btn _cppay-btn-primary`,children:p?`处理中...`:`继续支付`})})]}):x&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`_cppay-qr-container`,children:(0,u.jsx)(`div`,{className:`_cppay-qr-placeholder`,children:(0,u.jsx)(`span`,{children:`扫码支付`})})}),(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[(0,u.jsxs)(`div`,{className:`_cppay-info-box`,children:[(0,u.jsx)(`div`,{className:`_cppay-info-label`,children:`支付金额`}),(0,u.jsxs)(`div`,{className:`_cppay-info-value`,children:[x.paymentAmount,` `,y]})]}),(0,u.jsxs)(`div`,{className:`_cppay-info-box`,children:[(0,u.jsx)(`div`,{className:`_cppay-info-label`,children:`支付地址`}),(0,u.jsxs)(`div`,{className:`_cppay-address-row`,children:[(0,u.jsx)(`code`,{children:x.receiveAddress}),(0,u.jsx)(`button`,{onClick:A,className:`_cppay-copy-btn`,title:`复制地址`,children:(0,u.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,u.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})})})]})]})]}),(0,u.jsx)(`div`,{className:`_cppay-section`,children:(0,u.jsx)(`button`,{onClick:k,disabled:p,className:`_cppay-btn _cppay-btn-primary`,children:p?`检查支付状态...`:`我已完成支付`})}),(0,u.jsx)(`div`,{className:`_cppay-section`,children:(0,u.jsx)(`button`,{onClick:()=>f(`select`),disabled:p,className:`_cppay-btn _cppay-btn-secondary`,children:`更改支付方式`})})]})})]})}):null},f=l.default.memo(d);exports.PaymentDialog=f,exports.t=s;
|
package/dist/react.js
CHANGED
|
@@ -1,256 +1,79 @@
|
|
|
1
1
|
import { t as cppay_default } from "./cppay-gIC4-2qD.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import React, { useEffect, useMemo, useState } from "react";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function n(e, n, r) {
|
|
10
|
-
var i = null;
|
|
11
|
-
if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
|
|
12
|
-
else r = n;
|
|
13
|
-
return n = r.ref, {
|
|
14
|
-
$$typeof: t,
|
|
15
|
-
type: e,
|
|
16
|
-
key: i,
|
|
17
|
-
ref: n === void 0 ? null : n,
|
|
18
|
-
props: r
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
e.jsx = n, e.jsxs = n;
|
|
22
|
-
})), require_react_jsx_runtime_development = /* @__PURE__ */ __commonJSMin(((e) => {
|
|
23
|
-
process.env.NODE_ENV !== "production" && (function() {
|
|
24
|
-
function t(e) {
|
|
25
|
-
if (e == null) return null;
|
|
26
|
-
if (typeof e == "function") return e.$$typeof === k ? null : e.displayName || e.name || null;
|
|
27
|
-
if (typeof e == "string") return e;
|
|
28
|
-
switch (e) {
|
|
29
|
-
case v: return "Fragment";
|
|
30
|
-
case b: return "Profiler";
|
|
31
|
-
case y: return "StrictMode";
|
|
32
|
-
case w: return "Suspense";
|
|
33
|
-
case T: return "SuspenseList";
|
|
34
|
-
case O: return "Activity";
|
|
35
|
-
}
|
|
36
|
-
if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
|
|
37
|
-
case _: return "Portal";
|
|
38
|
-
case S: return e.displayName || "Context";
|
|
39
|
-
case x: return (e._context.displayName || "Context") + ".Consumer";
|
|
40
|
-
case C:
|
|
41
|
-
var n = e.render;
|
|
42
|
-
return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
|
|
43
|
-
case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
|
|
44
|
-
case D:
|
|
45
|
-
n = e._payload, e = e._init;
|
|
46
|
-
try {
|
|
47
|
-
return t(e(n));
|
|
48
|
-
} catch {}
|
|
49
|
-
}
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
function n(e) {
|
|
53
|
-
return "" + e;
|
|
54
|
-
}
|
|
55
|
-
function r(e) {
|
|
56
|
-
try {
|
|
57
|
-
n(e);
|
|
58
|
-
var t = !1;
|
|
59
|
-
} catch {
|
|
60
|
-
t = !0;
|
|
61
|
-
}
|
|
62
|
-
if (t) {
|
|
63
|
-
t = console;
|
|
64
|
-
var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
65
|
-
return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function i(e) {
|
|
69
|
-
if (e === v) return "<>";
|
|
70
|
-
if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
|
|
71
|
-
try {
|
|
72
|
-
var n = t(e);
|
|
73
|
-
return n ? "<" + n + ">" : "<...>";
|
|
74
|
-
} catch {
|
|
75
|
-
return "<...>";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function a() {
|
|
79
|
-
var e = A.A;
|
|
80
|
-
return e === null ? null : e.getOwner();
|
|
81
|
-
}
|
|
82
|
-
function s() {
|
|
83
|
-
return Error("react-stack-top-frame");
|
|
84
|
-
}
|
|
85
|
-
function c(e) {
|
|
86
|
-
if (j.call(e, "key")) {
|
|
87
|
-
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
88
|
-
if (t && t.isReactWarning) return !1;
|
|
89
|
-
}
|
|
90
|
-
return e.key !== void 0;
|
|
91
|
-
}
|
|
92
|
-
function l(e, t) {
|
|
93
|
-
function n() {
|
|
94
|
-
P || (P = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
|
|
95
|
-
}
|
|
96
|
-
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
97
|
-
get: n,
|
|
98
|
-
configurable: !0
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
function u() {
|
|
102
|
-
var e = t(this.type);
|
|
103
|
-
return F[e] || (F[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
|
|
104
|
-
}
|
|
105
|
-
function d(e, t, n, r, i, a) {
|
|
106
|
-
var o = n.ref;
|
|
107
|
-
return e = {
|
|
108
|
-
$$typeof: g,
|
|
109
|
-
type: e,
|
|
110
|
-
key: t,
|
|
111
|
-
props: n,
|
|
112
|
-
_owner: r
|
|
113
|
-
}, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
|
|
114
|
-
enumerable: !1,
|
|
115
|
-
value: null
|
|
116
|
-
}) : Object.defineProperty(e, "ref", {
|
|
117
|
-
enumerable: !1,
|
|
118
|
-
get: u
|
|
119
|
-
}), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
120
|
-
configurable: !1,
|
|
121
|
-
enumerable: !1,
|
|
122
|
-
writable: !0,
|
|
123
|
-
value: 0
|
|
124
|
-
}), Object.defineProperty(e, "_debugInfo", {
|
|
125
|
-
configurable: !1,
|
|
126
|
-
enumerable: !1,
|
|
127
|
-
writable: !0,
|
|
128
|
-
value: null
|
|
129
|
-
}), Object.defineProperty(e, "_debugStack", {
|
|
130
|
-
configurable: !1,
|
|
131
|
-
enumerable: !1,
|
|
132
|
-
writable: !0,
|
|
133
|
-
value: i
|
|
134
|
-
}), Object.defineProperty(e, "_debugTask", {
|
|
135
|
-
configurable: !1,
|
|
136
|
-
enumerable: !1,
|
|
137
|
-
writable: !0,
|
|
138
|
-
value: a
|
|
139
|
-
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
140
|
-
}
|
|
141
|
-
function f(e, n, i, o, s, u) {
|
|
142
|
-
var f = n.children;
|
|
143
|
-
if (f !== void 0) if (o) if (M(f)) {
|
|
144
|
-
for (o = 0; o < f.length; o++) p(f[o]);
|
|
145
|
-
Object.freeze && Object.freeze(f);
|
|
146
|
-
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
147
|
-
else p(f);
|
|
148
|
-
if (j.call(n, "key")) {
|
|
149
|
-
f = t(e);
|
|
150
|
-
var m = Object.keys(n).filter(function(e) {
|
|
151
|
-
return e !== "key";
|
|
152
|
-
});
|
|
153
|
-
o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, f, m, f), R[f + o] = !0);
|
|
154
|
-
}
|
|
155
|
-
if (f = null, i !== void 0 && (r(i), f = "" + i), c(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
|
|
156
|
-
else i = n;
|
|
157
|
-
return f && l(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, i, a(), s, u);
|
|
158
|
-
}
|
|
159
|
-
function p(e) {
|
|
160
|
-
m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
161
|
-
}
|
|
162
|
-
function m(e) {
|
|
163
|
-
return typeof e == "object" && !!e && e.$$typeof === g;
|
|
164
|
-
}
|
|
165
|
-
var h = __require("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
|
|
166
|
-
return null;
|
|
167
|
-
};
|
|
168
|
-
h = { react_stack_bottom_frame: function(e) {
|
|
169
|
-
return e();
|
|
170
|
-
} };
|
|
171
|
-
var P, F = {}, I = h.react_stack_bottom_frame.bind(h, s)(), L = N(i(s)), R = {};
|
|
172
|
-
e.Fragment = v, e.jsx = function(e, t, n) {
|
|
173
|
-
var r = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
174
|
-
return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
|
|
175
|
-
}, e.jsxs = function(e, t, n) {
|
|
176
|
-
var r = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
177
|
-
return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
|
|
178
|
-
};
|
|
179
|
-
})();
|
|
180
|
-
})), import_jsx_runtime = (/* @__PURE__ */ __commonJSMin(((e, t) => {
|
|
181
|
-
process.env.NODE_ENV === "production" ? t.exports = require_react_jsx_runtime_production() : t.exports = require_react_jsx_runtime_development();
|
|
182
|
-
})))(), PaymentDialog_default = React.memo(({ open: t, onClose: a, apiKey: o, orderId: s, amount: c, onSuccess: u, onError: d }) => {
|
|
183
|
-
let f = useMemo(() => new cppay_default(o), [o]), [p, m] = useState("select"), [h, g] = useState(!1), [_, v] = useState([]), [y, b] = useState(""), [x, S] = useState(""), [C, w] = useState(null), T = useMemo(() => _.find((e) => e.chain === y), [_, y]), E = useMemo(() => T?.tokens || [], [T]), D = useMemo(() => E.find((e) => e.symbol === x), [E, x]), O = useMemo(() => x ? (parseFloat(c) / 1).toFixed(6) : "0", [
|
|
184
|
-
c,
|
|
185
|
-
x,
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var PaymentDialog_default = React.memo(({ open: o, onClose: s, apiKey: c, orderId: l, amount: u, onSuccess: d, onError: f }) => {
|
|
6
|
+
let p = useMemo(() => new cppay_default(c), [c]), [m, h] = useState("select"), [g, _] = useState(!1), [v, y] = useState([]), [b, x] = useState(""), [S, C] = useState(""), [w, T] = useState(null), E = useMemo(() => v.find((t) => t.chain === b), [v, b]), D = useMemo(() => E?.tokens || [], [E]), O = useMemo(() => D.find((t) => t.symbol === S), [D, S]), k = useMemo(() => S ? (parseFloat(u) / 1).toFixed(6) : "0", [
|
|
7
|
+
u,
|
|
8
|
+
S,
|
|
186
9
|
1
|
|
187
|
-
]),
|
|
10
|
+
]), A = async () => {
|
|
188
11
|
try {
|
|
189
|
-
|
|
190
|
-
let
|
|
191
|
-
|
|
192
|
-
} catch (
|
|
193
|
-
|
|
12
|
+
_(!0);
|
|
13
|
+
let t = await p.getSupportedChains();
|
|
14
|
+
y(t), t.length > 0 && x(t[0].chain);
|
|
15
|
+
} catch (t) {
|
|
16
|
+
f?.(t);
|
|
194
17
|
} finally {
|
|
195
|
-
|
|
18
|
+
_(!1);
|
|
196
19
|
}
|
|
197
|
-
},
|
|
198
|
-
if (!(!
|
|
199
|
-
|
|
200
|
-
let
|
|
201
|
-
paymentChain:
|
|
202
|
-
paymentToken:
|
|
203
|
-
orderId:
|
|
204
|
-
amount:
|
|
20
|
+
}, j = async () => {
|
|
21
|
+
if (!(!b || !S)) try {
|
|
22
|
+
_(!0);
|
|
23
|
+
let t = await p.createPayment({
|
|
24
|
+
paymentChain: b,
|
|
25
|
+
paymentToken: S,
|
|
26
|
+
orderId: l,
|
|
27
|
+
amount: k
|
|
205
28
|
});
|
|
206
|
-
|
|
207
|
-
paymentId:
|
|
208
|
-
paymentAmount:
|
|
209
|
-
receiveAddress:
|
|
210
|
-
}),
|
|
211
|
-
} catch (
|
|
212
|
-
|
|
29
|
+
T({
|
|
30
|
+
paymentId: t.paymentId,
|
|
31
|
+
paymentAmount: t.paymentAmount,
|
|
32
|
+
receiveAddress: O?.receiveAddresses[0] || ""
|
|
33
|
+
}), h("payment");
|
|
34
|
+
} catch (t) {
|
|
35
|
+
f?.(t);
|
|
213
36
|
} finally {
|
|
214
|
-
|
|
37
|
+
_(!1);
|
|
215
38
|
}
|
|
216
|
-
},
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
} catch (
|
|
220
|
-
|
|
39
|
+
}, M = async () => {
|
|
40
|
+
if (w) try {
|
|
41
|
+
_(!0), await p.checkPaymentStatus(w.paymentId, 1e3), d?.(w.paymentId), P();
|
|
42
|
+
} catch (t) {
|
|
43
|
+
f?.(t);
|
|
221
44
|
} finally {
|
|
222
|
-
|
|
45
|
+
_(!1);
|
|
223
46
|
}
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
|
|
47
|
+
}, N = async () => {
|
|
48
|
+
w?.receiveAddress && await navigator.clipboard.writeText(w.receiveAddress);
|
|
49
|
+
}, P = () => {
|
|
50
|
+
s(), setTimeout(() => {
|
|
51
|
+
h("select"), T(null);
|
|
229
52
|
}, 300);
|
|
230
53
|
};
|
|
231
54
|
return useEffect(() => {
|
|
232
|
-
|
|
233
|
-
}, [
|
|
234
|
-
|
|
235
|
-
}, [
|
|
55
|
+
o && v.length === 0 && A();
|
|
56
|
+
}, [o]), useEffect(() => {
|
|
57
|
+
D.length > 0 && C(D[0].symbol);
|
|
58
|
+
}, [D]), o ? /* @__PURE__ */ jsx("div", {
|
|
236
59
|
className: "_cppay-overlay",
|
|
237
|
-
onClick: (
|
|
238
|
-
children: /* @__PURE__ */
|
|
60
|
+
onClick: (t) => t.target === t.currentTarget && P(),
|
|
61
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
239
62
|
className: "_cppay-dialog",
|
|
240
|
-
children: [/* @__PURE__ */
|
|
63
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
241
64
|
className: "_cppay-header",
|
|
242
|
-
children: [/* @__PURE__ */
|
|
65
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
243
66
|
className: "_cppay-title",
|
|
244
|
-
children:
|
|
245
|
-
}), /* @__PURE__ */
|
|
246
|
-
onClick:
|
|
247
|
-
disabled:
|
|
67
|
+
children: m === "select" ? "选择支付方式" : "完成支付"
|
|
68
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
69
|
+
onClick: P,
|
|
70
|
+
disabled: g,
|
|
248
71
|
className: "_cppay-close-btn",
|
|
249
|
-
children: /* @__PURE__ */
|
|
72
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
250
73
|
fill: "none",
|
|
251
74
|
stroke: "currentColor",
|
|
252
75
|
viewBox: "0 0 24 24",
|
|
253
|
-
children: /* @__PURE__ */
|
|
76
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
254
77
|
strokeLinecap: "round",
|
|
255
78
|
strokeLinejoin: "round",
|
|
256
79
|
strokeWidth: 2,
|
|
@@ -258,117 +81,117 @@ var __commonJSMin = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t
|
|
|
258
81
|
})
|
|
259
82
|
})
|
|
260
83
|
})]
|
|
261
|
-
}), /* @__PURE__ */
|
|
84
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
262
85
|
className: "_cppay-content",
|
|
263
|
-
children:
|
|
264
|
-
/* @__PURE__ */
|
|
86
|
+
children: m === "select" ? /* @__PURE__ */ jsxs("div", { children: [
|
|
87
|
+
/* @__PURE__ */ jsxs("div", {
|
|
265
88
|
className: "_cppay-section",
|
|
266
|
-
children: [/* @__PURE__ */
|
|
89
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
267
90
|
className: "_cppay-label",
|
|
268
91
|
children: "支付网络"
|
|
269
|
-
}), /* @__PURE__ */
|
|
92
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
270
93
|
className: "_cppay-grid",
|
|
271
|
-
children:
|
|
272
|
-
onClick: () =>
|
|
273
|
-
className: `_cppay-select-btn ${
|
|
274
|
-
children: [
|
|
275
|
-
src:
|
|
276
|
-
alt:
|
|
277
|
-
}), /* @__PURE__ */
|
|
278
|
-
},
|
|
94
|
+
children: v.map((t) => /* @__PURE__ */ jsxs("button", {
|
|
95
|
+
onClick: () => x(t.chain),
|
|
96
|
+
className: `_cppay-select-btn ${b === t.chain ? "_cppay-selected" : ""}`,
|
|
97
|
+
children: [t.icon && /* @__PURE__ */ jsx("img", {
|
|
98
|
+
src: t.icon,
|
|
99
|
+
alt: t.chain
|
|
100
|
+
}), /* @__PURE__ */ jsx("span", { children: t.chain })]
|
|
101
|
+
}, t.chain))
|
|
279
102
|
})]
|
|
280
103
|
}),
|
|
281
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ jsxs("div", {
|
|
282
105
|
className: "_cppay-section",
|
|
283
|
-
children: [/* @__PURE__ */
|
|
106
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
284
107
|
className: "_cppay-label",
|
|
285
108
|
children: "支付代币"
|
|
286
|
-
}), /* @__PURE__ */
|
|
109
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
287
110
|
className: "_cppay-grid",
|
|
288
|
-
children:
|
|
289
|
-
onClick: () =>
|
|
290
|
-
className: `_cppay-select-btn ${
|
|
291
|
-
children: [
|
|
292
|
-
src:
|
|
293
|
-
alt:
|
|
294
|
-
}), /* @__PURE__ */
|
|
295
|
-
},
|
|
111
|
+
children: D.map((t) => /* @__PURE__ */ jsxs("button", {
|
|
112
|
+
onClick: () => C(t.symbol),
|
|
113
|
+
className: `_cppay-select-btn ${S === t.symbol ? "_cppay-selected" : ""}`,
|
|
114
|
+
children: [t.icon && /* @__PURE__ */ jsx("img", {
|
|
115
|
+
src: t.icon,
|
|
116
|
+
alt: t.symbol
|
|
117
|
+
}), /* @__PURE__ */ jsx("span", { children: t.symbol })]
|
|
118
|
+
}, t.symbol))
|
|
296
119
|
})]
|
|
297
120
|
}),
|
|
298
|
-
/* @__PURE__ */
|
|
121
|
+
/* @__PURE__ */ jsx("div", {
|
|
299
122
|
className: "_cppay-section",
|
|
300
|
-
children: /* @__PURE__ */
|
|
123
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
301
124
|
className: "_cppay-price-box",
|
|
302
|
-
children: /* @__PURE__ */
|
|
125
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
303
126
|
className: "_cppay-price-row",
|
|
304
|
-
children: [/* @__PURE__ */
|
|
127
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
305
128
|
className: "_cppay-price-label",
|
|
306
129
|
children: "支付金额"
|
|
307
|
-
}), /* @__PURE__ */
|
|
130
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
308
131
|
className: "_cppay-price-amount",
|
|
309
|
-
children: [/* @__PURE__ */
|
|
132
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
310
133
|
className: "_cppay-price-main",
|
|
311
134
|
children: [
|
|
312
|
-
|
|
135
|
+
k,
|
|
313
136
|
" ",
|
|
314
|
-
|
|
137
|
+
S
|
|
315
138
|
]
|
|
316
|
-
}), /* @__PURE__ */
|
|
139
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
317
140
|
className: "_cppay-price-sub",
|
|
318
|
-
children: ["≈ $",
|
|
141
|
+
children: ["≈ $", u]
|
|
319
142
|
})]
|
|
320
143
|
})]
|
|
321
144
|
})
|
|
322
145
|
})
|
|
323
146
|
}),
|
|
324
|
-
/* @__PURE__ */
|
|
147
|
+
/* @__PURE__ */ jsx("div", {
|
|
325
148
|
className: "_cppay-section",
|
|
326
|
-
children: /* @__PURE__ */
|
|
327
|
-
onClick:
|
|
328
|
-
disabled: !
|
|
149
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
150
|
+
onClick: j,
|
|
151
|
+
disabled: !b || !S || g,
|
|
329
152
|
className: "_cppay-btn _cppay-btn-primary",
|
|
330
|
-
children:
|
|
153
|
+
children: g ? "处理中..." : "继续支付"
|
|
331
154
|
})
|
|
332
155
|
})
|
|
333
|
-
] }) :
|
|
334
|
-
/* @__PURE__ */
|
|
156
|
+
] }) : w && /* @__PURE__ */ jsxs("div", { children: [
|
|
157
|
+
/* @__PURE__ */ jsx("div", {
|
|
335
158
|
className: "_cppay-qr-container",
|
|
336
|
-
children: /* @__PURE__ */
|
|
159
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
337
160
|
className: "_cppay-qr-placeholder",
|
|
338
|
-
children: /* @__PURE__ */
|
|
161
|
+
children: /* @__PURE__ */ jsx("span", { children: "扫码支付" })
|
|
339
162
|
})
|
|
340
163
|
}),
|
|
341
|
-
/* @__PURE__ */
|
|
164
|
+
/* @__PURE__ */ jsxs("div", {
|
|
342
165
|
className: "_cppay-section",
|
|
343
|
-
children: [/* @__PURE__ */
|
|
166
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
344
167
|
className: "_cppay-info-box",
|
|
345
|
-
children: [/* @__PURE__ */
|
|
168
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
346
169
|
className: "_cppay-info-label",
|
|
347
170
|
children: "支付金额"
|
|
348
|
-
}), /* @__PURE__ */
|
|
171
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
349
172
|
className: "_cppay-info-value",
|
|
350
173
|
children: [
|
|
351
|
-
|
|
174
|
+
w.paymentAmount,
|
|
352
175
|
" ",
|
|
353
|
-
|
|
176
|
+
S
|
|
354
177
|
]
|
|
355
178
|
})]
|
|
356
|
-
}), /* @__PURE__ */
|
|
179
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
357
180
|
className: "_cppay-info-box",
|
|
358
|
-
children: [/* @__PURE__ */
|
|
181
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
359
182
|
className: "_cppay-info-label",
|
|
360
183
|
children: "支付地址"
|
|
361
|
-
}), /* @__PURE__ */
|
|
184
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
362
185
|
className: "_cppay-address-row",
|
|
363
|
-
children: [/* @__PURE__ */
|
|
364
|
-
onClick:
|
|
186
|
+
children: [/* @__PURE__ */ jsx("code", { children: w.receiveAddress }), /* @__PURE__ */ jsx("button", {
|
|
187
|
+
onClick: N,
|
|
365
188
|
className: "_cppay-copy-btn",
|
|
366
189
|
title: "复制地址",
|
|
367
|
-
children: /* @__PURE__ */
|
|
190
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
368
191
|
fill: "none",
|
|
369
192
|
stroke: "currentColor",
|
|
370
193
|
viewBox: "0 0 24 24",
|
|
371
|
-
children: /* @__PURE__ */
|
|
194
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
372
195
|
strokeLinecap: "round",
|
|
373
196
|
strokeLinejoin: "round",
|
|
374
197
|
strokeWidth: 2,
|
|
@@ -379,20 +202,20 @@ var __commonJSMin = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t
|
|
|
379
202
|
})]
|
|
380
203
|
})]
|
|
381
204
|
}),
|
|
382
|
-
/* @__PURE__ */
|
|
205
|
+
/* @__PURE__ */ jsx("div", {
|
|
383
206
|
className: "_cppay-section",
|
|
384
|
-
children: /* @__PURE__ */
|
|
385
|
-
onClick:
|
|
386
|
-
disabled:
|
|
207
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
208
|
+
onClick: M,
|
|
209
|
+
disabled: g,
|
|
387
210
|
className: "_cppay-btn _cppay-btn-primary",
|
|
388
|
-
children:
|
|
211
|
+
children: g ? "检查支付状态..." : "我已完成支付"
|
|
389
212
|
})
|
|
390
213
|
}),
|
|
391
|
-
/* @__PURE__ */
|
|
214
|
+
/* @__PURE__ */ jsx("div", {
|
|
392
215
|
className: "_cppay-section",
|
|
393
|
-
children: /* @__PURE__ */
|
|
394
|
-
onClick: () =>
|
|
395
|
-
disabled:
|
|
216
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
217
|
+
onClick: () => h("select"),
|
|
218
|
+
disabled: g,
|
|
396
219
|
className: "_cppay-btn _cppay-btn-secondary",
|
|
397
220
|
children: "更改支付方式"
|
|
398
221
|
})
|