plutosdk 1.0.2-beta.1 → 1.0.2-beta.3

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.
@@ -13,8 +13,8 @@ import walletManager from '../../utils/WalletManager';
13
13
  import ContentBg from '../ContentBg';
14
14
  import BlurMask from '../BlurMask';
15
15
  import ContentTitle from '../ContentTitle';
16
- import SignInInfo from '../CheckInInfo';
17
- import SignInButton from '../CheckInButton';
16
+ import CheckInInfo from '../CheckInInfo';
17
+ import CheckInButton from '../CheckInButton';
18
18
  import Toast from '../Toast';
19
19
  import Loading from '../Loading';
20
20
  /**
@@ -80,7 +80,7 @@ export default class CheckIn extends PureComponent {
80
80
  */
81
81
  render() {
82
82
  const { showSlide } = this.state;
83
- return (_jsxs(Box, Object.assign({ sx: { width: 1, height: 1, position: 'relative' } }, { children: [_jsx(BlurMask, {}), _jsxs(Box, Object.assign({ sx: { width: 1, height: 1, position: 'relative' } }, { children: [_jsx(Box, { sx: { width: 1, height: 1, position: 'fixed' }, onClick: this.onClickClose }), _jsx(Box, Object.assign({ sx: { width: 1, position: 'absolute', bottom: 40, pointerEvents: 'none' } }, { children: _jsx(Slide, Object.assign({ direction: 'up', in: showSlide, mountOnEnter: true, unmountOnExit: true, timeout: { enter: 600, exit: 600 }, onEntered: this.onEntered, onExited: this.onExited }, { children: _jsxs(Box, Object.assign({ sx: { width: '96%', maxWidth: 430, m: '0 auto', position: 'relative', pointerEvents: 'auto' } }, { children: [_jsx(ContentBg, {}), _jsx(ContentTitle, { title: 'Claim' }), _jsx(SignInInfo, {}), _jsx(Stack, Object.assign({ spacing: 2, sx: { mx: 5, pb: 4 } }, { children: _jsx(SignInButton, { onClickSignIn: this.onClickSignIn }) }))] })) })) }))] }))] })));
83
+ return (_jsxs(Box, Object.assign({ sx: { width: 1, height: 1, position: 'relative' } }, { children: [_jsx(BlurMask, {}), _jsxs(Box, Object.assign({ sx: { width: 1, height: 1, position: 'relative' } }, { children: [_jsx(Box, { sx: { width: 1, height: 1, position: 'fixed' }, onClick: this.onClickClose }), _jsx(Box, Object.assign({ sx: { width: 1, position: 'absolute', bottom: 40, pointerEvents: 'none' } }, { children: _jsx(Slide, Object.assign({ direction: 'up', in: showSlide, mountOnEnter: true, unmountOnExit: true, timeout: { enter: 600, exit: 600 }, onEntered: this.onEntered, onExited: this.onExited }, { children: _jsxs(Box, Object.assign({ sx: { width: '96%', maxWidth: 430, m: '0 auto', position: 'relative', pointerEvents: 'auto' } }, { children: [_jsx(ContentBg, {}), _jsx(ContentTitle, { title: 'Claim' }), _jsx(CheckInInfo, {}), _jsx(Stack, Object.assign({ spacing: 2, sx: { mx: 5, pb: 4 } }, { children: _jsx(CheckInButton, { onClickSignIn: this.onClickSignIn }) }))] })) })) }))] }))] })));
84
84
  }
85
85
  /**
86
86
  *
@@ -1,7 +1,9 @@
1
1
  import { MouseEventHandler, PureComponent } from 'react';
2
2
  interface IProps {
3
- content: string;
4
- icon: string;
3
+ currency: string;
4
+ price: number;
5
+ oldPrice: number;
6
+ discount: number;
5
7
  onClickPay: MouseEventHandler<HTMLButtonElement>;
6
8
  }
7
9
  /**
@@ -3,6 +3,7 @@ import { PureComponent } from 'react';
3
3
  import Box from '@mui/material/Box';
4
4
  import Button from '@mui/material/Button';
5
5
  import { getRes } from '../../utils/Utils';
6
+ import { CURRENCY, CURRENCY_ICON, CURRENCY_NAME } from '../../utils/constant';
6
7
  import StrokeText from '../StrokeText';
7
8
  /**
8
9
  *
@@ -12,7 +13,11 @@ export default class PayButton extends PureComponent {
12
13
  *
13
14
  */
14
15
  render() {
15
- const { content, icon, onClickPay } = this.props;
16
- return (_jsx(Box, Object.assign({ sx: { height: 50, position: 'relative' } }, { children: _jsxs(Button, Object.assign({ sx: { width: 1, height: 1, borderRadius: 3 }, variant: 'contained', onClick: onClickPay }, { children: [_jsx(Box, { sx: { width: 1, height: 1, position: 'absolute', top: 0, borderImage: `url(${getRes('button_2.png')})`, borderWidth: 20, borderStyle: 'solid', borderImageRepeat: 'repeat', borderImageSlice: '20 fill' } }), _jsx(Box, { component: 'img', src: icon, sx: { width: 30, height: 30, mr: 1, position: 'relative' } }), _jsx(StrokeText, { content: content, fontSize: 22, color: '#fff', strokeColor: '#4a7408', strokeWidth: 3 })] })) })));
16
+ const { currency, price, oldPrice, discount, onClickPay } = this.props;
17
+ const icon = getRes(CURRENCY_ICON[currency]);
18
+ const name = CURRENCY_NAME[currency];
19
+ const priceStr = `${currency == CURRENCY.star ? price : price.toFixed(2)} ${name}`;
20
+ const oldPriceStr = `\xa0${currency == CURRENCY.star ? oldPrice : oldPrice.toFixed(2)} ${name}\xa0`;
21
+ return (_jsxs(Box, Object.assign({ sx: { height: 50, position: 'relative' } }, { children: [_jsxs(Button, Object.assign({ sx: { width: 1, height: 1, borderRadius: 3 }, variant: 'contained', onClick: onClickPay }, { children: [_jsx(Box, { sx: { width: 1, height: 1, position: 'absolute', top: 0, borderImage: `url(${getRes('button_2.png')})`, borderWidth: 20, borderStyle: 'solid', borderImageRepeat: 'repeat', borderImageSlice: '20 fill' } }), _jsx(Box, { component: 'img', src: icon, sx: { width: 30, height: 30, mr: 1, position: 'relative' } }), _jsx(StrokeText, { content: priceStr, fontSize: 22, color: '#fff', strokeColor: '#4a7408', strokeWidth: 3 }), _jsx(Box, { sx: { width: '10px' } }), discount > 0 ? (_jsx(StrokeText, { content: oldPriceStr, fontSize: 14, color: '#fff', strokeColor: '#4a7408', strokeWidth: 2, decorationLine: true })) : null] })), discount > 0 ? (_jsx(Box, Object.assign({ sx: { top: -12, right: -20, bottom: 0, left: -20, position: 'absolute', pointerEvents: 'none' } }, { children: _jsxs(Box, Object.assign({ sx: { width: 62, height: 50, rotate: '-20deg', position: 'relative', float: 'right', display: 'inline-block' } }, { children: [_jsx(Box, { component: 'img', src: getRes('sale_off.png'), sx: { width: 62, height: 50, position: 'absolute', display: 'block' } }), _jsx(Box, Object.assign({ sx: { top: 6, width: 62, height: 25, textAlign: 'center', color: '#fff', fontSize: 16, fontWeight: 'bold', position: 'absolute' } }, { children: `${discount * 100}%` })), _jsx(Box, Object.assign({ sx: { bottom: 6, width: 62, height: 25, textAlign: 'center', color: '#fff', fontSize: 16, fontWeight: 'bold', position: 'absolute' } }, { children: "OFF" }))] })) }))) : null] })));
17
22
  }
18
23
  }
@@ -6,7 +6,7 @@ import Stack from '@mui/material/Stack';
6
6
  import PubSub from 'pubsub-js';
7
7
  import { CHAIN } from '@tonconnect/ui';
8
8
  import { CODE, CURRENCY, PS_PURCHASE_COMPLETED, PS_SWITCH_PAGE, PAGE_ID, PAY_TYPE, TOKEN_NAME } from '../../utils/constant';
9
- import { getRes, isAppleClient, onMobile } from '../../utils/Utils';
9
+ import { isAppleClient, onMobile } from '../../utils/Utils';
10
10
  import Config from '../../utils/Config';
11
11
  import user from '../../utils/User';
12
12
  import platform from '../../utils/Platform';
@@ -145,9 +145,9 @@ export default class Purchase extends PureComponent {
145
145
  *
146
146
  */
147
147
  render() {
148
- const { ton, usdt, cati, star } = user.purchaseData;
148
+ const { ton, tonOld, tonDiscount, usdt, usdtOld, usdtDiscount, cati, catiOld, catiDiscount, star, starOld, starDiscount } = user.purchaseData;
149
149
  const { showSlide } = this.state;
150
- return (_jsxs(Box, Object.assign({ sx: { width: 1, height: 1, position: 'relative' } }, { children: [_jsx(BlurMask, {}), _jsxs(Box, Object.assign({ sx: { width: 1, height: 1, position: 'relative', overflowY: 'auto', '::-webkit-scrollbar': { display: 'none' } } }, { children: [_jsx(Box, { sx: { width: 1, height: 1, position: 'fixed' }, onClick: this.onClickClose }), _jsx(Box, Object.assign({ sx: { width: '100%', position: 'absolute', pointerEvents: 'none', '@media (orientation: portrait)': { bottom: 20 }, '@media (orientation: landscape)': { top: 10 } } }, { children: _jsx(Slide, Object.assign({ direction: 'up', in: showSlide, mountOnEnter: true, unmountOnExit: true, timeout: { enter: 600, exit: 600 }, onExited: this.onExited }, { children: _jsxs(Box, Object.assign({ sx: { width: 1, maxWidth: 430, m: '0 auto', position: 'relative', pointerEvents: 'auto' } }, { children: [_jsx(ContentBg, {}), _jsx(ContentTitle, { title: 'Purchase' }), _jsx(PurchaseInfo, {}), _jsxs(Stack, Object.assign({ spacing: 2, sx: { mx: 5, pb: 4 } }, { children: [Config.TEST_MODE || (!onMobile() && !isAppleClient()) ? (_jsxs(_Fragment, { children: [_jsx(PayButton, { content: `${cati.toFixed(2)} CATI`, icon: getRes('coin_cati.png'), onClickPay: this.onClickCati }), _jsx(PayButton, { content: `${ton.toFixed(2)} TON`, icon: getRes('coin_ton.png'), onClickPay: this.onClickTon }), _jsx(PayButton, { content: `${usdt.toFixed(2)} USDT`, icon: getRes('coin_usdt.png'), onClickPay: this.onClickUsdt })] })) : null, _jsx(PayButton, { content: `${star} Star`, icon: getRes('coin_star.png'), onClickPay: this.onClickStar })] }))] })) })) }))] }))] })));
150
+ return (_jsxs(Box, Object.assign({ sx: { width: 1, height: 1, position: 'relative' } }, { children: [_jsx(BlurMask, {}), _jsxs(Box, Object.assign({ sx: { width: 1, height: 1, position: 'relative', overflowY: 'auto', '::-webkit-scrollbar': { display: 'none' } } }, { children: [_jsx(Box, { sx: { width: 1, height: 1, position: 'fixed' }, onClick: this.onClickClose }), _jsx(Box, Object.assign({ sx: { width: '100%', position: 'absolute', pointerEvents: 'none', '@media (orientation: portrait)': { bottom: 20 }, '@media (orientation: landscape)': { top: 10 } } }, { children: _jsx(Slide, Object.assign({ direction: 'up', in: showSlide, mountOnEnter: true, unmountOnExit: true, timeout: { enter: 600, exit: 600 }, onExited: this.onExited }, { children: _jsxs(Box, Object.assign({ sx: { width: 1, maxWidth: 430, m: '0 auto', position: 'relative', pointerEvents: 'auto' } }, { children: [_jsx(ContentBg, {}), _jsx(ContentTitle, { title: 'Purchase' }), _jsx(PurchaseInfo, {}), _jsxs(Stack, Object.assign({ spacing: 2, sx: { mx: 5, pb: 4 } }, { children: [Config.TEST_MODE || (!onMobile() && !isAppleClient()) ? (_jsxs(_Fragment, { children: [_jsx(PayButton, { currency: CURRENCY.cati, price: cati, oldPrice: catiOld, discount: catiDiscount, onClickPay: this.onClickCati }), _jsx(PayButton, { currency: CURRENCY.ton, price: ton, oldPrice: tonOld, discount: tonDiscount, onClickPay: this.onClickTon }), _jsx(PayButton, { currency: CURRENCY.usdt, price: usdt, oldPrice: usdtOld, discount: usdtDiscount, onClickPay: this.onClickUsdt })] })) : null, _jsx(PayButton, { currency: CURRENCY.star, price: star, oldPrice: starOld, discount: starDiscount, onClickPay: this.onClickStar })] }))] })) })) }))] }))] })));
151
151
  }
152
152
  /**
153
153
  *
@@ -5,6 +5,7 @@ interface IProps {
5
5
  color: string;
6
6
  strokeColor: string;
7
7
  strokeWidth: number;
8
+ decorationLine?: boolean;
8
9
  }
9
10
  /**
10
11
  *
@@ -9,7 +9,7 @@ export default class StrokeText extends PureComponent {
9
9
  *
10
10
  */
11
11
  render() {
12
- const { content, fontSize, color, strokeColor, strokeWidth } = this.props;
12
+ const { content, fontSize, color, strokeColor, strokeWidth, decorationLine } = this.props;
13
13
  const sx = {
14
14
  color: color,
15
15
  fontSize: fontSize,
@@ -17,6 +17,9 @@ export default class StrokeText extends PureComponent {
17
17
  position: 'relative',
18
18
  zIndex: 0,
19
19
  textTransform: 'none',
20
+ textDecorationLine: decorationLine ? 'line-through' : 'none',
21
+ textDecorationColor: '#f30808',
22
+ textDecorationThickness: '0.1em',
20
23
  '&:after': {
21
24
  content: 'attr(content)',
22
25
  WebkitTextStrokeColor: strokeColor,
@@ -20,20 +20,35 @@ export interface IPurchase {
20
20
  name?: string;
21
21
  productId?: string;
22
22
  orderId?: string;
23
- ton?: number;
23
+ customData?: string;
24
+ orderNo?: string;
24
25
  usdt?: number;
26
+ usdtOld?: number;
27
+ usdtDiscount?: number;
28
+ ton?: number;
29
+ tonOld?: number;
30
+ tonDiscount?: number;
25
31
  cati?: number;
32
+ catiOld?: number;
33
+ catiDiscount?: number;
26
34
  star?: number;
27
- customData?: string;
28
- orderNo?: string;
35
+ starOld?: number;
36
+ starDiscount?: number;
29
37
  }
30
- export interface IOrder {
38
+ export interface IPayOrder {
31
39
  amount: string;
32
40
  orderNo: string;
33
41
  payload: string;
34
42
  payLink: string;
35
43
  address: string;
36
44
  }
45
+ export interface IQueryOrder {
46
+ name: string;
47
+ productId: string;
48
+ orderId: string;
49
+ orderNo: string;
50
+ customData: string;
51
+ }
37
52
  export interface ICheckIn {
38
53
  name?: string;
39
54
  orderId?: string;
package/lib/main.js CHANGED
@@ -43,6 +43,10 @@ const start = () => {
43
43
  *
44
44
  */
45
45
  const run = () => {
46
+ //删除路径里Telegram参数
47
+ const baseUrl = location.origin + location.pathname + location.search;
48
+ history.replaceState(null, null, baseUrl);
49
+ //
46
50
  if (document.body) {
47
51
  start();
48
52
  return;
package/lib/sdk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILogin, IPurchase } from './interface';
1
+ import { ILogin, IQueryOrder } from './interface';
2
2
  /**
3
3
  *
4
4
  */
@@ -59,7 +59,7 @@ export declare const consumePurchase: (orderNo: string) => Promise<void>;
59
59
  /**
60
60
  *
61
61
  */
62
- export declare const queryPurchses: () => Promise<IPurchase[]>;
62
+ export declare const queryPurchses: () => Promise<IQueryOrder[]>;
63
63
  /**
64
64
  *
65
65
  * @param type
package/lib/sdk.js CHANGED
@@ -404,7 +404,7 @@ class Sdk {
404
404
  code: CODE.NotInit,
405
405
  message: 'Pluto sdk not initialize'
406
406
  });
407
- } //
407
+ }
408
408
  return platform.reqUnfinishRecord();
409
409
  }
410
410
  /**
@@ -1,4 +1,4 @@
1
- import { IGame, ILogin, IOrder, IPurchase } from "../interface";
1
+ import { IGame, ILogin, IPayOrder, IQueryOrder } from "../interface";
2
2
  import { CURRENCY, PAY_TYPE } from './constant';
3
3
  /**
4
4
  *
@@ -29,7 +29,7 @@ declare class Platform {
29
29
  * @param payType
30
30
  * @param currency
31
31
  */
32
- reqOrder(payType: PAY_TYPE, currency: CURRENCY): Promise<IOrder>;
32
+ reqOrder(payType: PAY_TYPE, currency: CURRENCY): Promise<IPayOrder>;
33
33
  /**
34
34
  *
35
35
  * @param orderNo
@@ -38,7 +38,7 @@ declare class Platform {
38
38
  /**
39
39
  *
40
40
  */
41
- reqUnfinishRecord(): Promise<IPurchase[]>;
41
+ reqUnfinishRecord(): Promise<IQueryOrder[]>;
42
42
  /**
43
43
  *
44
44
  * @param name
@@ -81,15 +81,35 @@ class Platform {
81
81
  */
82
82
  reqPurchase(productId, name, orderId, amount, customData) {
83
83
  return Api.priceExchange(amount).then(data => {
84
+ const usdt = parseFloat(data['usdt']) || 0;
85
+ const ton = parseFloat(data['ton']) || 0;
86
+ const cati = parseFloat(data['cati']) || 0;
87
+ const star = parseInt(data['star']) || 0;
88
+ const usdtOff = parseFloat(data['usdtoff']) || 0;
89
+ const tonOff = parseFloat(data['tonoff']) || 0;
90
+ const catiOff = parseFloat(data['catioff']) || 0;
91
+ const starOff = parseFloat(data['staroff']) || 0;
92
+ const usdtDiscount = parseFloat(data['usdtdiscount']) || 0;
93
+ const tonDiscount = parseFloat(data['tondiscount']) || 0;
94
+ const catiDiscount = parseFloat(data['catidiscount']) || 0;
95
+ const starDiscount = parseFloat(data['stardiscount']) || 0;
84
96
  user.purchaseData = {
85
97
  name: name,
86
98
  productId: productId,
87
99
  orderId: orderId,
88
- usdt: parseFloat(data['usdt']),
89
- ton: parseFloat(data['ton']),
90
- cati: parseFloat(data['cati']),
91
- star: parseInt(data['star']),
92
- customData: customData
100
+ customData: customData,
101
+ usdt: usdtDiscount ? usdtOff : usdt,
102
+ usdtOld: usdt,
103
+ usdtDiscount: usdtDiscount,
104
+ ton: tonDiscount ? tonOff : ton,
105
+ tonOld: ton,
106
+ tonDiscount: tonDiscount,
107
+ cati: catiDiscount ? catiOff : cati,
108
+ catiOld: cati,
109
+ catiDiscount: catiDiscount,
110
+ star: starDiscount ? starOff : star,
111
+ starOld: star,
112
+ starDiscount: starDiscount
93
113
  };
94
114
  });
95
115
  }
@@ -102,7 +122,6 @@ class Platform {
102
122
  const { productId, name, orderId, usdt, customData } = user.purchaseData;
103
123
  return Api.order(productId, name, orderId, usdt, payType, currency, customData).then(data => {
104
124
  user.purchaseData.orderNo = data['orderNo'];
105
- //
106
125
  return {
107
126
  amount: data['amount'],
108
127
  orderNo: data['orderNo'],
@@ -63,8 +63,8 @@ export declare enum PAY_TYPE {
63
63
  tonConnect = 2
64
64
  }
65
65
  export declare enum CURRENCY {
66
- ton = "TON",
67
66
  usdt = "USDT",
67
+ ton = "TON",
68
68
  cati = "CATI",
69
69
  star = "STAR"
70
70
  }
@@ -76,3 +76,15 @@ export declare enum ORIENTATION_TYPE {
76
76
  portrait = 1,
77
77
  landscape = 2
78
78
  }
79
+ export declare const CURRENCY_NAME: {
80
+ USDT: string;
81
+ TON: string;
82
+ CATI: string;
83
+ STAR: string;
84
+ };
85
+ export declare const CURRENCY_ICON: {
86
+ USDT: string;
87
+ TON: string;
88
+ CATI: string;
89
+ STAR: string;
90
+ };
@@ -67,8 +67,8 @@ export var PAY_TYPE;
67
67
  })(PAY_TYPE || (PAY_TYPE = {}));
68
68
  export var CURRENCY;
69
69
  (function (CURRENCY) {
70
- CURRENCY["ton"] = "TON";
71
70
  CURRENCY["usdt"] = "USDT";
71
+ CURRENCY["ton"] = "TON";
72
72
  CURRENCY["cati"] = "CATI";
73
73
  CURRENCY["star"] = "STAR";
74
74
  })(CURRENCY || (CURRENCY = {}));
@@ -82,3 +82,15 @@ export var ORIENTATION_TYPE;
82
82
  ORIENTATION_TYPE[ORIENTATION_TYPE["portrait"] = 1] = "portrait";
83
83
  ORIENTATION_TYPE[ORIENTATION_TYPE["landscape"] = 2] = "landscape";
84
84
  })(ORIENTATION_TYPE || (ORIENTATION_TYPE = {}));
85
+ export const CURRENCY_NAME = {
86
+ [CURRENCY.usdt]: 'USDT',
87
+ [CURRENCY.ton]: 'TON',
88
+ [CURRENCY.cati]: 'CATI',
89
+ [CURRENCY.star]: 'Star'
90
+ };
91
+ export const CURRENCY_ICON = {
92
+ [CURRENCY.usdt]: 'coin_usdt.png',
93
+ [CURRENCY.ton]: 'coin_ton.png',
94
+ [CURRENCY.cati]: 'coin_cati.png',
95
+ [CURRENCY.star]: 'coin_star.png'
96
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plutosdk",
3
- "version": "1.0.2-beta.1",
3
+ "version": "1.0.2-beta.3",
4
4
  "author": "pluto",
5
5
  "main": "./lib/index.js",
6
6
  "files": [