@monygroupcorp/micro-web3 1.2.3 → 1.3.0
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/micro-web3.cjs +2 -2
- package/dist/micro-web3.cjs.map +1 -1
- package/dist/micro-web3.esm.js +2 -2
- package/dist/micro-web3.esm.js.map +1 -1
- package/dist/micro-web3.umd.js +2 -2
- package/dist/micro-web3.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/components/BondingCurve/BondingCurve.js +80 -116
- package/src/components/Display/BalanceDisplay.js +37 -61
- package/src/components/Display/PriceDisplay.js +43 -71
- package/src/components/FloatingWalletButton/FloatingWalletButton.js +106 -151
- package/src/components/Ipfs/IpfsImage.js +83 -107
- package/src/components/Modal/ApprovalModal.js +92 -149
- package/src/components/SettingsModal/SettingsModal.js +364 -341
- package/src/components/Swap/SwapButton.js +9 -45
- package/src/components/Swap/SwapInputs.js +46 -108
- package/src/components/Swap/SwapInterface.js +216 -597
- package/src/components/Swap/TransactionOptions.js +70 -179
- package/src/components/SyncProgressBar/SyncProgressBar.js +183 -215
- package/src/components/Util/MessagePopup.js +26 -24
- package/src/components/Wallet/WalletModal.js +45 -44
- package/src/components/WalletButton/WalletButton.js +193 -185
- package/src/services/WalletService.js +53 -20
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Component } from '@monygroupcorp/microact';
|
|
1
|
+
import { Component, h } from '@monygroupcorp/microact';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* SwapButton Component
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* Main swap action button with state management.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
8
|
* @class SwapButton
|
|
9
9
|
* @extends Component
|
|
10
10
|
*/
|
|
@@ -16,36 +16,7 @@ export class SwapButton extends Component {
|
|
|
16
16
|
* @param {Function} props.onClick - Callback when button is clicked
|
|
17
17
|
*/
|
|
18
18
|
constructor(props = {}) {
|
|
19
|
-
super();
|
|
20
|
-
this.props = props;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Update component props
|
|
25
|
-
* @param {Object} newProps - New props to merge
|
|
26
|
-
*/
|
|
27
|
-
updateProps(newProps) {
|
|
28
|
-
const oldProps = { ...this.props };
|
|
29
|
-
this.props = { ...this.props, ...newProps };
|
|
30
|
-
|
|
31
|
-
// Only update if the button text would actually change
|
|
32
|
-
const oldText = oldProps.direction === 'buy' ? 'Buy $EXEC' : 'Sell $EXEC';
|
|
33
|
-
const newText = this.props.direction === 'buy' ? 'Buy $EXEC' : 'Sell $EXEC';
|
|
34
|
-
|
|
35
|
-
if (oldText !== newText || oldProps.disabled !== this.props.disabled) {
|
|
36
|
-
// Only update if something actually changed
|
|
37
|
-
if (this.element) {
|
|
38
|
-
const button = this.element.querySelector('.swap-button');
|
|
39
|
-
if (button) {
|
|
40
|
-
button.textContent = newText;
|
|
41
|
-
if (this.props.disabled) {
|
|
42
|
-
button.disabled = true;
|
|
43
|
-
} else {
|
|
44
|
-
button.disabled = false;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
19
|
+
super(props);
|
|
49
20
|
}
|
|
50
21
|
|
|
51
22
|
/**
|
|
@@ -59,23 +30,16 @@ export class SwapButton extends Component {
|
|
|
59
30
|
}
|
|
60
31
|
}
|
|
61
32
|
|
|
62
|
-
events() {
|
|
63
|
-
return {
|
|
64
|
-
'click .swap-button': (e) => this.handleClick(e)
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
33
|
render() {
|
|
69
34
|
const { direction, disabled } = this.props;
|
|
70
35
|
const buttonText = direction === 'buy' ? 'Buy $EXEC' : 'Sell $EXEC';
|
|
71
36
|
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
37
|
+
return h('button', {
|
|
38
|
+
className: 'swap-button',
|
|
39
|
+
disabled: disabled,
|
|
40
|
+
onClick: this.bind(this.handleClick)
|
|
41
|
+
}, buttonText);
|
|
77
42
|
}
|
|
78
43
|
}
|
|
79
44
|
|
|
80
45
|
export default SwapButton;
|
|
81
|
-
|
|
@@ -1,77 +1,8 @@
|
|
|
1
|
-
import { Component } from '@monygroupcorp/microact';
|
|
1
|
+
import { Component, h } from '@monygroupcorp/microact';
|
|
2
2
|
|
|
3
3
|
export class SwapInputs extends Component {
|
|
4
4
|
constructor(props = {}) {
|
|
5
5
|
super(props);
|
|
6
|
-
this.props = {
|
|
7
|
-
balances: { eth: '0', exec: '0' },
|
|
8
|
-
...props
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Update component props
|
|
14
|
-
* @param {Object} newProps - New props to merge
|
|
15
|
-
*/
|
|
16
|
-
updateProps(newProps) {
|
|
17
|
-
this.props = { ...this.props, ...newProps };
|
|
18
|
-
// Don't call update() directly as it will destroy input elements and lose focus
|
|
19
|
-
// Instead, update only the parts that changed
|
|
20
|
-
this.updateSelectively(newProps);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Update only specific parts of the UI without destroying inputs
|
|
25
|
-
* @param {Object} changedProps - Props that changed
|
|
26
|
-
*/
|
|
27
|
-
updateSelectively(changedProps) {
|
|
28
|
-
if (!this.element) return;
|
|
29
|
-
|
|
30
|
-
if (changedProps.direction !== undefined || changedProps.freeMint !== undefined || changedProps.balances !== undefined) {
|
|
31
|
-
const { balances, direction, freeMint } = this.props;
|
|
32
|
-
const formattedEthBalance = parseFloat(balances.eth || 0).toFixed(6);
|
|
33
|
-
const formattedExecBalance = parseInt(balances.exec || 0).toLocaleString();
|
|
34
|
-
const availableExecBalance = direction === 'sell' && freeMint
|
|
35
|
-
? `Available: ${(parseInt(balances.exec || 0) - 1000000).toLocaleString()}`
|
|
36
|
-
: `Balance: ${formattedExecBalance}`;
|
|
37
|
-
|
|
38
|
-
const balanceDisplays = this.element.querySelectorAll('.token-balance');
|
|
39
|
-
balanceDisplays.forEach((display, index) => {
|
|
40
|
-
const isTopInput = index === 0;
|
|
41
|
-
if (direction === 'buy') {
|
|
42
|
-
display.textContent = isTopInput ? `Balance: ${formattedEthBalance}` : `Balance: ${formattedExecBalance}`;
|
|
43
|
-
} else {
|
|
44
|
-
display.textContent = isTopInput ? availableExecBalance : `Balance: ${formattedEthBalance}`;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const tokenSymbols = this.element.querySelectorAll('.token-symbol');
|
|
49
|
-
tokenSymbols.forEach((symbol, index) => {
|
|
50
|
-
const isTopInput = index === 0;
|
|
51
|
-
if (direction === 'buy') {
|
|
52
|
-
symbol.textContent = isTopInput ? 'ETH' : '$EXEC';
|
|
53
|
-
} else {
|
|
54
|
-
symbol.textContent = isTopInput ? '$EXEC' : 'ETH';
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const topInput = this.element.querySelector('.top-input');
|
|
60
|
-
const bottomInput = this.element.querySelector('.bottom-input');
|
|
61
|
-
|
|
62
|
-
if (changedProps.calculatingAmount !== undefined || changedProps.execAmount !== undefined || changedProps.ethAmount !== undefined) {
|
|
63
|
-
const { direction, ethAmount, execAmount, calculatingAmount } = this.props;
|
|
64
|
-
|
|
65
|
-
if (topInput && !topInput.matches(':focus')) {
|
|
66
|
-
topInput.value = direction === 'buy' ? ethAmount : execAmount;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (bottomInput && !bottomInput.matches(':focus')) {
|
|
70
|
-
bottomInput.value = direction === 'buy'
|
|
71
|
-
? (calculatingAmount ? 'Loading...' : execAmount)
|
|
72
|
-
: (calculatingAmount ? 'Loading...' : ethAmount);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
6
|
}
|
|
76
7
|
|
|
77
8
|
/**
|
|
@@ -86,52 +17,59 @@ export class SwapInputs extends Component {
|
|
|
86
17
|
}
|
|
87
18
|
}
|
|
88
19
|
|
|
89
|
-
events() {
|
|
90
|
-
return {
|
|
91
|
-
'input .top-input': (e) => this.handleInput(e, 'top'),
|
|
92
|
-
'input .bottom-input': (e) => this.handleInput(e, 'bottom')
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
20
|
render() {
|
|
97
|
-
const { direction, ethAmount, execAmount, calculatingAmount, freeMint, balances } = this.props;
|
|
98
|
-
|
|
21
|
+
const { direction, ethAmount, execAmount, calculatingAmount, freeMint, balances = { eth: '0', exec: '0' } } = this.props;
|
|
22
|
+
|
|
99
23
|
const formattedEthBalance = parseFloat(balances.eth || 0).toFixed(6);
|
|
100
24
|
const formattedExecBalance = parseInt(balances.exec || 0).toLocaleString();
|
|
101
|
-
|
|
25
|
+
|
|
102
26
|
const availableExecBalance = direction === 'sell' && freeMint
|
|
103
27
|
? `Available: ${(parseInt(balances.exec || 0) - 1000000).toLocaleString()}`
|
|
104
28
|
: `Balance: ${formattedExecBalance}`;
|
|
105
29
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
30
|
+
const topValue = direction === 'buy' ? ethAmount : execAmount;
|
|
31
|
+
const bottomValue = direction === 'buy'
|
|
32
|
+
? (calculatingAmount ? 'Loading...' : execAmount)
|
|
33
|
+
: (calculatingAmount ? 'Loading...' : ethAmount);
|
|
34
|
+
|
|
35
|
+
const topSymbol = direction === 'buy' ? 'ETH' : '$EXEC';
|
|
36
|
+
const bottomSymbol = direction === 'buy' ? '$EXEC' : 'ETH';
|
|
37
|
+
|
|
38
|
+
const topBalance = direction === 'buy' ? `Balance: ${formattedEthBalance}` : availableExecBalance;
|
|
39
|
+
const bottomBalance = direction === 'buy' ? `Balance: ${formattedExecBalance}` : `Balance: ${formattedEthBalance}`;
|
|
40
|
+
|
|
41
|
+
return h('div', { className: 'swap-inputs' },
|
|
42
|
+
h('div', { className: 'input-container' },
|
|
43
|
+
h('input', {
|
|
44
|
+
type: 'text',
|
|
45
|
+
className: 'top-input',
|
|
46
|
+
value: topValue,
|
|
47
|
+
placeholder: '0.0',
|
|
48
|
+
pattern: '^[0-9]*[.]?[0-9]*$',
|
|
49
|
+
onInput: (e) => this.handleInput(e, 'top')
|
|
50
|
+
}),
|
|
51
|
+
h('div', { className: 'token-info' },
|
|
52
|
+
h('span', { className: 'token-symbol' }, topSymbol),
|
|
53
|
+
h('span', { className: 'token-balance' }, topBalance)
|
|
54
|
+
)
|
|
55
|
+
),
|
|
56
|
+
h('div', { className: 'direction-switch-slot' }),
|
|
57
|
+
h('div', { className: 'input-container' },
|
|
58
|
+
h('input', {
|
|
59
|
+
type: 'text',
|
|
60
|
+
className: 'bottom-input',
|
|
61
|
+
value: bottomValue,
|
|
62
|
+
placeholder: '0.0',
|
|
63
|
+
pattern: '^[0-9]*[.]?[0-9]*$',
|
|
64
|
+
onInput: (e) => this.handleInput(e, 'bottom')
|
|
65
|
+
}),
|
|
66
|
+
h('div', { className: 'token-info' },
|
|
67
|
+
h('span', { className: 'token-symbol' }, bottomSymbol),
|
|
68
|
+
h('span', { className: 'token-balance' }, bottomBalance)
|
|
69
|
+
)
|
|
70
|
+
)
|
|
71
|
+
);
|
|
133
72
|
}
|
|
134
73
|
}
|
|
135
74
|
|
|
136
75
|
export default SwapInputs;
|
|
137
|
-
|