Skip to content

Commit 81c6213

Browse files
iwbrhwfyxiaowheat
authored andcommitted
[Lightcone_v2.js] Update method to create account (#297)
* inprogress * fix bug && try-catch
1 parent 8ad8b03 commit 81c6213

File tree

7 files changed

+219
-155
lines changed

7 files changed

+219
-155
lines changed

packages/lightcone_v2.js/src/lib/wallet/config/index.ts

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import settings from './settings'
1+
import settings from './settings';
22

33
const data = require('./data');
44
const config = data.configs;
@@ -7,8 +7,8 @@ const txs = config.txs;
77
const projects = data.projects;
88

99
function requestWhiteList() {
10-
const url = "//raw.githubusercontent.com/Loopring/mock-relay-data/master/whiteList.json";
11-
return fetch(url, {method: 'GET'}).then((res) => res.json())
10+
const url = '//raw.githubusercontent.com/Loopring/mock-relay-data/master/whiteList.json';
11+
return fetch(url, {method: 'GET'}).then((res) => res.json());
1212
}
1313

1414
async function isinWhiteList(address) {
@@ -18,96 +18,111 @@ async function isinWhiteList(address) {
1818
});
1919
}
2020

21+
function initTokenConfig() {
22+
const tokens = [];
23+
tokens.push({
24+
'symbol': 'LRC',
25+
'digits': 18,
26+
'address': '0x4FF214811F164dAB1889c83b1fe2c8c27d3dB615',
27+
'precision': 6,
28+
});
29+
settings.setTokensConfig(tokens);
30+
}
31+
2132
function getChainId() {
22-
return config.chainId
33+
return config.chainId;
2334
}
2435

2536
function getTokenBySymbol(symbol) {
2637
if (!symbol) {
27-
return {}
38+
return {};
2839
}
29-
return getTokens().find(token => token.symbol.toLowerCase() === symbol.toLowerCase()) || {}
40+
return getTokens().find(token => token.symbol.toLowerCase() === symbol.toLowerCase()) || {};
3041
}
3142

3243
function getTokenByAddress(address) {
3344
if (!address) {
34-
return {}
45+
return {};
3546
}
36-
return getTokens().find(token => token.address.toLowerCase() === address.toLowerCase())
47+
return getTokens().find(token => token.address.toLowerCase() === address.toLowerCase());
3748
}
3849

3950
function getCustomTokens() {
40-
return getTokens().filter(token => token.custom)
51+
return getTokens().filter(token => token.custom);
4152
}
4253

4354
function getTokens() {
44-
return settings.getTokensConfig()
55+
return settings.getTokensConfig();
4556
}
4657

4758
function getMarketByPair(pair) {
4859
if (pair) {
4960
const pairArr = pair.split('-');
5061
if (pairArr && pairArr.length === 2) {
51-
return getMarketBySymbol(pairArr[0], pairArr[1])
62+
return getMarketBySymbol(pairArr[0], pairArr[1]);
5263
}
5364
}
5465
}
5566

5667
function getProjectByName(name) {
5768
if (!name) {
58-
return {}
69+
return {};
5970
}
60-
return projects.find(project => project.name.toLowerCase() === name.toLowerCase())
71+
return projects.find(project => project.name.toLowerCase() === name.toLowerCase());
6172
}
6273

6374
function getProjectById(id) {
6475
if (!id) {
65-
return {}
76+
return {};
6677
}
67-
return projects.find(project => project.projectId === id)
78+
return projects.find(project => project.projectId === id);
6879
}
6980

7081
function getProjectByLrx(lrx) {
7182
if (!lrx) {
72-
return {}
83+
return {};
7384
}
74-
return projects.find(project => project.lrx.toLowerCase() === lrx.toLowerCase())
85+
return projects.find(project => project.lrx.toLowerCase() === lrx.toLowerCase());
7586
}
7687

7788
function getSupportedMarketsTokenR() {
78-
return settings.getMarketR()
89+
return settings.getMarketR();
7990
}
8091

8192
function isSupportedMarket(market) {
82-
if (!market) return false;
93+
if (!market) {
94+
return false;
95+
}
8396
const pair = market.split('-');
84-
if (pair.length !== 2) return false;
97+
if (pair.length !== 2) {
98+
return false;
99+
}
85100
return getMarkets().find(m => {
86-
return (m.tokenx === pair[0].toUpperCase() && m.tokeny === pair[1].toUpperCase()) || (m.tokenx === pair[1].toUpperCase() && m.tokeny === pair[0].toUpperCase())
87-
})
101+
return (m.tokenx === pair[0].toUpperCase() && m.tokeny === pair[1].toUpperCase()) || (m.tokenx === pair[1].toUpperCase() && m.tokeny === pair[0].toUpperCase());
102+
});
88103
}
89104

90105
function getMarketBySymbol(tokenx, tokeny) {
91106
if (tokenx && tokeny) {
92107
return getMarkets().find(market => {
93-
return (market.tokenx === tokenx && market.tokeny === tokeny) || (market.tokenx === tokeny && market.tokeny === tokenx)
94-
}
108+
return (market.tokenx === tokenx && market.tokeny === tokeny) || (market.tokenx === tokeny && market.tokeny === tokenx);
109+
}
95110
) || {
96-
"pricePrecision": 8
97-
}
111+
'pricePrecision': 8
112+
};
98113
} else {
99114
return {
100-
"pricePrecision": 8
101-
}
115+
'pricePrecision': 8
116+
};
102117
}
103118
}
104119

105120
function getMarketsByTokenR(token) {
106-
return getMarkets().filter(item => item.tokeny === token)
121+
return getMarkets().filter(item => item.tokeny === token);
107122
}
108123

109124
function getMarketsByTokenL(token) {
110-
return getMarkets().filter(item => item.tokenx === token)
125+
return getMarkets().filter(item => item.tokenx === token);
111126
}
112127

113128
function getTokenSupportedMarket(token) {
@@ -117,51 +132,54 @@ function getTokenSupportedMarket(token) {
117132
if (supportedToken.includes(token)) {
118133
const markets = getMarketsByTokenR(token);
119134
if (markets) {
120-
foundMarket = markets[0].tokenx + "-" + markets[0].tokeny
135+
foundMarket = markets[0].tokenx + '-' + markets[0].tokeny;
121136
}
122137
} else {
123138
const tokenR = supportedToken.find((x, i) => {
124-
const market = token + "-" + x;
139+
const market = token + '-' + x;
125140
if (isSupportedMarket(market)) {
126-
return true
141+
return true;
127142
}
128143
});
129-
if (tokenR) foundMarket = token + "-" + tokenR
144+
if (tokenR) {
145+
foundMarket = token + '-' + tokenR;
146+
}
130147
}
131148
}
132-
return foundMarket
149+
return foundMarket;
133150
}
134151

135152
function getTokenSupportedMarkets(token) {
136153
const leftMarket = getMarketsByTokenL(token);
137154
const rightMarket = getMarketsByTokenR(token);
138-
return [...leftMarket, ...rightMarket]
155+
return [...leftMarket, ...rightMarket];
139156
}
140157

141158
function getMarkets() {
142-
return settings.getMarketPairs()
159+
return settings.getMarketPairs();
143160
}
144161

145162
function getGasLimitByType(type) {
146163
if (type) {
147-
return txs.find(tx => type === tx.type)
164+
return txs.find(tx => type === tx.type);
148165
}
149166

150167
}
151168

152169
function getWalletAddress() {
153-
return config.walletAddress
170+
return config.walletAddress;
154171
}
155172

156173
function getDelegateAddress() {
157174
return config.delegateAddress;
158175
}
159176

160177
function getWallets() {
161-
return data.wallets
178+
return data.wallets;
162179
}
163180

164181
export default {
182+
initTokenConfig,
165183
getTokenBySymbol,
166184
getTokenByAddress,
167185
getTokens,

packages/lightcone_v2.js/src/proto_src/service_dex.proto

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ import "data_types.proto";
3434
message DexConfigurations {
3535
uint64 dex_id = 1;
3636
string dex_address = 2;
37-
string deposit_fee_eth = 3; // FDS
38-
string onchain_withdrawal_fee_eth = 4; // FDS
39-
types.TokenID offchain_withdrawal_fee_token_id = 5; // 前端无需设计展示,以withdraw token为准
40-
string offchain_withdrawal_fee_amount = 6; // FDS
41-
string order_cancellation_fee_eth = 7; // FDS
42-
bool in_maintainance = 8;
37+
string account_creation_fee_eth = 3; // FDS
38+
string account_update_fee_eth = 4; // FDS
39+
string deposit_fee_eth = 5; // FDS
40+
string onchain_withdrawal_fee_eth = 6; // FDS
41+
types.TokenID offchain_withdrawal_fee_token_id = 7; // 前端无需设计展示,以withdraw token为准
42+
string offchain_withdrawal_fee_amount = 8; // FDS
43+
string order_cancellation_fee_eth = 9; // FDS
44+
bool in_maintainance = 10;
4345
}
4446

4547
message TokenInfo {

0 commit comments

Comments
 (0)