From a4ce55f36d6361975609ed736649977594b8b1b6 Mon Sep 17 00:00:00 2001
From: liangping <18786721@qq.com>
Date: Fri, 26 Nov 2021 18:51:26 +0800
Subject: [PATCH] finish price chart & trading panel
---
src/libs/data/data.js | 7 +-
src/views/OsmosisTrade.vue | 51 +++--
src/views/components/KlineTrade/PlaceForm.vue | 184 ++++++++++++++++--
src/views/components/tvjs/index.vue | 27 ++-
4 files changed, 231 insertions(+), 38 deletions(-)
diff --git a/src/libs/data/data.js b/src/libs/data/data.js
index 3d91ac45..a19c679c 100644
--- a/src/libs/data/data.js
+++ b/src/libs/data/data.js
@@ -142,6 +142,7 @@ function getHdPath(address) {
}
export async function sign(device, chainId, signerAddress, messages, fee, memo, signerData) {
+ console.log(device, signerData)
let transport
let signer
switch (device) {
@@ -159,13 +160,13 @@ export async function sign(device, chainId, signerAddress, messages, fee, memo,
throw new Error('Please install keplr extension')
}
await window.keplr.enable(chainId)
- // signer = window.getOfflineSigner(chainId)
- signer = window.getOfflineSignerOnlyAmino(chainId)
+ signer = window.getOfflineSigner(chainId)
+ // signer = window.getOfflineSignerOnlyAmino(chainId)
}
// Ensure the address has some tokens to spend
const client = await SigningStargateClient.offline(signer)
- return client.signAmino(device === 'keplr' ? signerAddress : toSignAddress(signerAddress), messages, fee, memo, signerData)
+ return client.sign(device === 'keplr' ? signerAddress : toSignAddress(signerAddress), messages, fee, memo, signerData)
// return signDirect(signer, signerAddress, messages, fee, memo, signerData)
}
diff --git a/src/views/OsmosisTrade.vue b/src/views/OsmosisTrade.vue
index f3004af0..278f020c 100644
--- a/src/views/OsmosisTrade.vue
+++ b/src/views/OsmosisTrade.vue
@@ -72,11 +72,10 @@
-
-
-
-
+
x[0])
+ const data = this.marketData.prices.map(x => x[1])
+ console.log('chart data:', data)
+ return {
+ labels,
+ datasets: [
+ {
+ label: 'Price',
+ data,
+ backgroundColor: 'rgba(54, 162, 235, 0.2)',
+ borderColor: 'rgba(54, 162, 235, 1)',
+ borderWidth: 1,
+ pointStyle: 'dash',
+ barThickness: 15,
+ },
+ ],
+ }
+ }
+ return { labels: [], datasets: [] }
+ },
},
created() {
const base = this.$route.params?.base || 'ATOM'
const target = this.$route.params?.target || 'OSMO'
this.init(base, target)
// 所有方法添加到 $http.osmosis
- this.$http.osmosis.getOHCL4Pairs(
- this.$http.osmosis.getCoinGeckoId(base),
- this.$http.osmosis.getCoinGeckoId(target),
- ).then(data => {
- this.klineData = data
+ // this.$http.osmosis.getOHCL4Pairs(
+ // this.$http.osmosis.getCoinGeckoId(base),
+ // this.$http.osmosis.getCoinGeckoId(target),
+ // ).then(data => {
+ // this.klineData = data
+ // })
+ this.$http.getMarketChart(14, 'cosmos').then(res => {
+ console.log('market data', res)
+ this.marketData = res
})
this.$http.osmosis.getDenomTraces().then(x => {
this.denomTrace = x
diff --git a/src/views/components/KlineTrade/PlaceForm.vue b/src/views/components/KlineTrade/PlaceForm.vue
index 9172bd2b..3b541127 100644
--- a/src/views/components/KlineTrade/PlaceForm.vue
+++ b/src/views/components/KlineTrade/PlaceForm.vue
@@ -1,6 +1,6 @@
-
+
- Available {{ computeAccounts }}
-
- Price
- -
- {{ price }} {{ target }}
+
-
+ 1 {{ base }} ≈ {{ price }} {{ target }}
- - Fee
- -
+
- Swap Fee
+ -
{{ fee }}%
-
+
+ Amount
+ Available {{ available }} {{ type === 0 ? target: base }}
+
+
-
+
+ Total
+ ≈${{ localPrice }}
+
-
+
@@ -105,11 +111,44 @@
+
+
+
+ Keplr
+
+
+ Ledger(USB)
+
+
+ Ledger(BLE)
+
+
+
{{ type === 0 ? `Buy ${ base }` : `Sell ${ base }` }}
@@ -123,10 +162,17 @@
+
+
+ {{ error }}
+
+
Note
@@ -143,11 +189,14 @@