Skip to content

Commit 20b1385

Browse files
authored
Merge pull request #526 from comdex-official/18-01-23-changes
Updated emission pages and more page text.
2 parents 54173ff + 5fea20b commit 20b1385

File tree

27 files changed

+3544
-1002
lines changed

27 files changed

+3544
-1002
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"@mantine/core": "^5.9.4",
2020
"@mantine/hooks": "^5.9.4",
2121
"@restart/context": "^2.1.4",
22+
"@tharsis/proto": "^0.1.20",
23+
"@tharsis/provider": "^0.2.4",
24+
"@tharsis/transactions": "^0.2.6",
2225
"@testing-library/jest-dom": "^5.16.4",
2326
"@testing-library/react": "^13.2.0",
2427
"antd": "^5.0.0",

src/assets/images/svg/svg-sprite.svg

Lines changed: 89 additions & 0 deletions
Loading

src/assets/scss/custom.scss

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,21 @@ button {
163163
}
164164

165165
.ant-tooltip-inner {
166-
background-color: $tooltip-bg-light !important;
166+
background-color: $tooltip-bg-light;
167167
color: $tooltip-color-dark;
168168
font-size: $font-size-sm - 2;
169169
min-height: 20px;
170170
padding: 2px 3px;
171171
line-height: 12px;
172-
border-radius: 3px !important;
172+
border-radius: 5px !important;
173173

174174
.dark-mode & {
175-
background-color: $tooltip-bg-light;
176-
color: $tooltip-color-dark;
175+
// background-color: $tooltip-bg-light;
176+
// color: $tooltip-color-dark;
177+
178+
background-color: #232231;
179+
border: 1px solid #fff;
180+
color: white;
177181
}
178182
}
179183
}
@@ -1418,6 +1422,7 @@ button {
14181422
}
14191423
}
14201424
}
1425+
14211426
.comdex-steps,
14221427
.ant-steps-horizontal:not(.ant-steps-label-vertical) {
14231428
.ant-steps-item {

src/config/ibc_assets.json

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
"rest": "https://devnet.cswap.one/vega-rest",
88
"coinDenom": "ATOM",
99
"coinMinimalDenom": "uatom",
10+
"symbol": "ATOM",
1011
"coinDecimals": 6,
1112
"coinType": 118,
1213
"prefix": "cosmos",
13-
"channel": "channel-636",
14+
"channel": "channel-835",
1415
"comdexChannel": "channel-1",
1516
"ibcDenomHash": "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9",
1617
"logoURI": "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/images/atom.svg",
@@ -24,10 +25,11 @@
2425
"rest": "https://osmot.rest.comdex.one",
2526
"coinDenom": "OSMO",
2627
"coinMinimalDenom": "uosmo",
28+
"symbol": "OSMO",
2729
"coinDecimals": 6,
2830
"coinType": 118,
2931
"prefix": "osmo",
30-
"channel": "channel-951",
32+
"channel": "channel-1498",
3133
"comdexChannel": "channel-0",
3234
"ibcDenomHash": "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518",
3335
"logoURI": "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/images/osmo.svg",
@@ -39,27 +41,47 @@
3941
"chainName": "Axelar-Test",
4042
"coinDenom": "USDC",
4143
"coinMinimalDenom": "uusdc",
44+
"symbol": "USDC",
4245
"coinDecimals": 6,
4346
"coinType": 118,
4447
"channel": "channel-62",
4548
"comdexChannel": "channel-18",
4649
"ibcDenomHash": "ibc/EF8A76D0FD3F3F45D8DB7FEBFCF921206DF58CA41493ED16D69BF7B4E061C60C",
50+
"logoURI": "https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/uausdc L@3x.png",
51+
"coinGeckoId": "axlusdc",
4752
"depositUrlOverride": "https://testnet.satellite.money/?source=ethereum&destination=comdex&asset_denom=uausdc&destination_address=",
4853
"withdrawUrlOverride": "https://testnet.satellite.money/?source=comdex&destination=ethereum&asset_denom=uausdc&destination_address="
49-
5054
},
5155
{
5256
"chainId": "axelar-testnet-lisbon-3",
5357
"chainName": "Axelar-Test",
5458
"coinDenom": "WETH",
5559
"coinMinimalDenom": "weth-wei",
60+
"symbol": "WETH",
5661
"coinDecimals": 18,
5762
"coinType": 118,
5863
"channel": "channel-62",
5964
"comdexChannel": "channel-18",
6065
"ibcDenomHash": "ibc/A99459944FD67B5711735B4B4D3FE30BA45328E94D437C78E47CA8DEFA781E49",
66+
"logoURI": "https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth-wei L@3x.png",
67+
"coinGeckoId": "axlweth",
6168
"depositUrlOverride": "https://testnet.satellite.money/?source=ethereum&destination=comdex&asset_denom=weth-wei&destination_address=",
6269
"withdrawUrlOverride": "https://testnet.satellite.money/?source=comdex&destination=ethereum&asset_denom=weth-wei&destination_address="
70+
},
71+
{
72+
"chainId": "stride-1",
73+
"chainName": "Stride",
74+
"coinDenom": "stake",
75+
"coinMinimalDenom": "stake",
76+
"symbol": "STAKE",
77+
"coinDecimals": 6,
78+
"coinType": 118,
79+
"channel": "channel-62",
80+
"comdexChannel": "channel-18",
81+
"ibcDenomHash": "stake",
82+
"logoURI": "https://raw.githubusercontent.com/cosmos/chain-registry/master/stride/images/statom.png",
83+
"coinGeckoId": "stake",
84+
"explorerUrlToTx": "https://explorer.theta-testnet.polypore.xyz/transactions/{txHash}"
6385
}
6486
]
6587
}

src/constants/common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const ZERO_DOLLAR_DECIMALS = 0;
1111
export const TOTAL_ACTIVITY = 5;
1212
export const TOTAL_VEHARBOR_ACTIVITY = 4;
1313
export const DEFAULT_CHAIN_ID_FOR_CLAIM_AIRDROP = 1;
14+
export const HARBOR_ASSET_ID = 9;
1415

1516

1617
export const PRODUCT_ID = Number(envConfig?.[app]?.appId);

src/containers/Assets/Deposit/index.js

Lines changed: 119 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ import { toDecimals, truncateString } from "../../../utils/string";
2222
import variables from "../../../utils/variables";
2323
import "./index.scss";
2424

25+
import { createTxRaw } from "@tharsis/proto";
26+
import { generateEndpointAccount } from "@tharsis/provider";
27+
import {
28+
generateEndpointBroadcast,
29+
generatePostBodyBroadcast
30+
} from "@tharsis/provider/dist/rest/broadcast";
31+
import { createTxIBCMsgTransfer } from "@tharsis/transactions";
32+
import Long from "long";
33+
2534
const Deposit = ({ lang, chain, address, handleRefresh, balances, assetMap }) => {
2635
const [isModalOpen, setIsModalOpen] = useState(false);
2736
const [sourceAddress, setSourceAddress] = useState("");
@@ -84,25 +93,131 @@ const Deposit = ({ lang, chain, address, handleRefresh, balances, assetMap }) =>
8493
setIsModalOpen(true);
8594
};
8695

87-
const signIBCTx = () => {
96+
97+
const handleEvmIBC = async () => {
8898
setInProgress(true);
8999

100+
try {
101+
const timeout = Math.floor(new Date().getTime() / 1000) + 600;
102+
const timeoutTimestampNanoseconds =
103+
Long.fromNumber(timeout).multiply(1_000_000_000);
104+
105+
const ibcMsg = {
106+
receiver: address,
107+
sender: sourceAddress,
108+
sourceChannel: chain.destChannelId,
109+
sourcePort: "transfer",
110+
timeoutTimestamp: String(timeoutTimestampNanoseconds),
111+
amount: getAmount(amount, assetMap[chain?.ibcDenomHash]?.decimals),
112+
denom: chain?.coinMinimalDenom,
113+
revisionNumber: Number(proofHeight.revision_number),
114+
revisionHeight: Number(proofHeight.revision_height) + 100,
115+
};
116+
const chainInfoForMsg = {
117+
chainId: comdex.chainId || 0,
118+
cosmosChainId: chain.chainInfo?.chainId,
119+
};
120+
121+
let accountResponse = await fetch(
122+
`${chain.chainInfo?.rest}${generateEndpointAccount(sourceAddress)}`
123+
);
124+
let accountResult = await accountResponse.json();
125+
126+
const sender = {
127+
accountAddress: accountResult.account.base_account.address,
128+
sequence: accountResult.account.base_account.sequence,
129+
accountNumber: accountResult.account.base_account.account_number,
130+
pubkey: accountResult.account.base_account.pub_key?.key || "",
131+
};
132+
133+
const fee = {
134+
amount: "20",
135+
denom: chain.chainInfo?.coinMinimalDenom,
136+
gas: "200000",
137+
};
138+
139+
const transferMsg = createTxIBCMsgTransfer(
140+
chainInfoForMsg,
141+
sender,
142+
fee,
143+
"ibc_transfer",
144+
ibcMsg
145+
);
146+
147+
const sign = await window?.keplr?.signDirect(
148+
chain.chainInfo?.chainId,
149+
sourceAddress,
150+
{
151+
bodyBytes: transferMsg.signDirect.body.serializeBinary(),
152+
authInfoBytes: transferMsg.signDirect.authInfo.serializeBinary(),
153+
chainId: chainInfoForMsg.cosmosChainId,
154+
accountNumber: new Long(sender.accountNumber),
155+
},
156+
{ isEthereum: true }
157+
);
158+
159+
if (sign !== undefined) {
160+
let rawTx = createTxRaw(
161+
sign.signed.bodyBytes,
162+
sign.signed.authInfoBytes,
163+
[new Uint8Array(Buffer.from(sign.signature.signature, "base64"))]
164+
);
165+
166+
// Broadcast it
167+
const postOptions = {
168+
method: "POST",
169+
headers: { "Content-Type": "application/json" },
170+
body: generatePostBodyBroadcast(rawTx),
171+
};
172+
try {
173+
let broadcastPost = await fetch(
174+
`${chain.chainInfo?.rest}/${generateEndpointBroadcast()}`,
175+
postOptions
176+
);
177+
let response = await broadcastPost.json();
178+
179+
if (response.tx_response?.txhash) {
180+
message.loading(
181+
"Transaction Broadcasting, Waiting for transaction to be included in the block"
182+
);
183+
184+
handleHash(response.tx_response?.txhash);
185+
}
186+
} catch (e) {
187+
resetValues();
188+
return;
189+
}
190+
}
191+
} catch (e) {
192+
resetValues();
193+
return;
194+
}
195+
};
196+
197+
const signIBCTx = () => {
90198
if (!proofHeight?.revision_height) {
91199
message.error("Unable to get the latest block height");
92-
setInProgress(false);
93200
return;
94201
}
202+
203+
if (chain?.chainInfo?.features?.includes("eth-address-gen")) {
204+
// handle evm based token deposits
205+
return handleEvmIBC();
206+
}
207+
208+
setInProgress(true);
209+
95210
const data = {
96211
msg: {
97212
typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
98213
value: {
99214
source_port: "transfer",
100215
source_channel: chain.destChannelId,
101216
token: {
102-
denom: chain.coinMinimalDenom,
217+
denom: chain?.coinMinimalDenom,
103218
amount: getAmount(
104219
amount,
105-
assetMap[chain?.ibcDenomHash]?.decimals
220+
assetMap[chain?.coinMinimalDenom]?.decimals
106221
),
107222
},
108223
sender: sourceAddress,
@@ -120,7 +235,6 @@ const Deposit = ({ lang, chain, address, handleRefresh, balances, assetMap }) =>
120235
};
121236

122237
aminoSignIBCTx(chain.chainInfo, data, (error, result) => {
123-
setInProgress(false);
124238
if (error) {
125239
if (result?.transactionHash) {
126240
message.error(
@@ -135,7 +249,6 @@ const Deposit = ({ lang, chain, address, handleRefresh, balances, assetMap }) =>
135249
}
136250

137251
resetValues();
138-
139252
return;
140253
}
141254

src/containers/Assets/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
commaSeparatorWithRounding,
1616
denomConversion,
1717
} from "../../utils/coin";
18-
import { commaSeparator, marketPrice } from "../../utils/number";
18+
import { commaSeparator, formateNumberDecimalsAuto, marketPrice } from "../../utils/number";
1919
import { iconNameFromDenom } from "../../utils/string";
2020
import variables from "../../utils/variables";
2121
import Deposit from "./Deposit";
@@ -88,7 +88,7 @@ const Assets = ({
8888
align: "center",
8989
render: (price) => (
9090
<>
91-
<p>${commaSeparator(Number(Math.floor(price * Math.pow(10, DOLLAR_DECIMALS)) / Math.pow(10, DOLLAR_DECIMALS)))}</p>
91+
${formateNumberDecimalsAuto({ price: Number(price) || 0 })}
9292
</>
9393
),
9494
},

src/containers/Dashboard/index.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,10 @@
315315
background-size: cover;
316316
background-repeat: no-repeat;
317317
background-position: center;
318+
318319
@media only screen and (min-width: 1800px) {
319-
background-size: 110%;
320+
background-size: 100%;
321+
height: 14rem;
320322
}
321323
@media only screen and (min-width: 1030px) and (max-width: 1060px) {
322324
background-size: contain;

0 commit comments

Comments
 (0)