Skip to content

Commit 4fed49a

Browse files
committed
reformat code
1 parent b96c5dc commit 4fed49a

File tree

4 files changed

+113
-119
lines changed

4 files changed

+113
-119
lines changed

docs/js_sdk/ammpool_api.md

Lines changed: 75 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,116 +2,115 @@
22

33
## getAmmPoolConf
44

5-
```javascript
6-
const { ammpools, pairs } = await api.getAmmPoolConf();
5+
```typescript
6+
const { ammpools, pairs } = await api.getAmmPoolConf();
77
```
88

99
## getAmmPoolUserRewards
1010

11-
```javascript
12-
const response: any = await api.getAmmPoolUserRewards({
13-
owner: acc.accountId.toString(),
14-
});
11+
```typescript
12+
const response: any = await api.getAmmPoolUserRewards({
13+
owner: acc.accountId.toString(),
14+
});
1515
```
1616

1717
## getAmmPoolActivityRules
1818

19-
```javascript
20-
const response: any = await api.getAmmPoolActivityRules();
19+
```typescript
20+
const response: any = await api.getAmmPoolActivityRules();
2121
```
2222

2323
## getAmmPoolStats
2424

25-
```javascript
26-
const response: any = await api.getAmmPoolStats();
25+
```typescript
26+
const response: any = await api.getAmmPoolStats();
2727
```
2828

2929
## getAmmPoolSnapshot
3030

31-
```javascript
32-
const request: GetAmmPoolSnapshotRequest = {
33-
poolAddress,
34-
};
35-
36-
const response = await api.getAmmPoolSnapshot(request, acc.apiKey);
31+
```typescript
32+
const request: GetAmmPoolSnapshotRequest = {
33+
poolAddress,
34+
};
35+
const response = await api.getAmmPoolSnapshot(request, acc.apiKey);
3736
```
3837

3938
## getAmmPoolBalances
4039

41-
```javascript
42-
const response = await api.getAmmPoolBalances();
40+
```typescript
41+
const response = await api.getAmmPoolBalances();
4342
```
4443

4544
## getAmmPoolTrades
4645

47-
```javascript
48-
const request: GetAmmPoolTradesRequest = {
49-
ammPoolAddress: poolAddress,
50-
};
51-
52-
const response = await api.getAmmPoolTrades(request);
46+
```typescript
47+
const request: GetAmmPoolTradesRequest = {
48+
ammPoolAddress: poolAddress,
49+
};
50+
51+
const response = await api.getAmmPoolTrades(request);
5352
```
5453

5554
## getUserAmmPoolTxs
5655

57-
```javascript
58-
const request: GetUserAmmPoolTxsRequest = {
59-
accountId: acc.accountId,
60-
};
61-
62-
const response = await api.getUserAmmPoolTxs(request, acc.apiKey);
56+
```typescript
57+
const request: GetUserAmmPoolTxsRequest = {
58+
accountId: acc.accountId,
59+
};
60+
61+
const response = await api.getUserAmmPoolTxs(request, acc.apiKey);
6362
```
6463

6564
## joinAmmPool
6665

67-
```javascript
68-
const request2: JoinAmmPoolRequest = {
69-
owner: acc.address,
70-
poolAddress,
71-
joinTokens: {
72-
pooled: [
73-
{ tokenId: "1", volume: "1000000000000000000000" },
74-
{ tokenId: "0", volume: "1000000000000000000" },
75-
],
76-
minimumLp: { tokenId: "4", volume: "100000" },
77-
},
78-
storageIds: [storageId_1.offchainId, storageId.offchainId],
79-
fee: "1000000000000000000",
80-
};
81-
82-
const patch: AmmPoolRequestPatch = {
83-
chainId: ChainId.GORLI,
84-
ammName: "LRCETH-Pool",
85-
poolAddress,
86-
eddsaKey: acc.eddsaKey,
87-
};
88-
89-
const response = await api.joinAmmPool(request2, patch, acc.apiKey);
66+
```typescript
67+
const request2: JoinAmmPoolRequest = {
68+
owner: acc.address,
69+
poolAddress,
70+
joinTokens: {
71+
pooled: [
72+
{ tokenId: "1", volume: "1000000000000000000000" },
73+
{ tokenId: "0", volume: "1000000000000000000" },
74+
],
75+
minimumLp: { tokenId: "4", volume: "100000" },
76+
},
77+
storageIds: [storageId_1.offchainId, storageId.offchainId],
78+
fee: "1000000000000000000",
79+
};
80+
81+
const patch: AmmPoolRequestPatch = {
82+
chainId: ChainId.GORLI,
83+
ammName: "LRCETH-Pool",
84+
poolAddress,
85+
eddsaKey: acc.eddsaKey,
86+
};
87+
88+
const response = await api.joinAmmPool(request2, patch, acc.apiKey);
9089
```
9190

9291
## exitAmmPool
9392

94-
```javascript
95-
const request2: ExitAmmPoolRequest = {
96-
owner: acc.address,
97-
poolAddress,
98-
exitTokens: {
99-
unPooled: [
100-
{ tokenId: "1", volume: "1000000000000000000000" },
101-
{ tokenId: "0", volume: "1000000000000000000" },
102-
],
103-
burned: { tokenId: "4", volume: "100000" },
104-
},
105-
storageId: storageId_1.offchainId,
106-
maxFee: "1000000000000000000",
107-
};
108-
109-
const patch: AmmPoolRequestPatch = {
110-
chainId: ChainId.GORLI,
111-
ammName: "LRCETH-Pool",
112-
poolAddress,
113-
eddsaKey: acc.eddsaKey,
114-
};
115-
116-
const response = await api.exitAmmPool(request2, patch, acc.apiKey);
93+
```typescript
94+
const request2: ExitAmmPoolRequest = {
95+
owner: acc.address,
96+
poolAddress,
97+
exitTokens: {
98+
unPooled: [
99+
{ tokenId: "1", volume: "1000000000000000000000" },
100+
{ tokenId: "0", volume: "1000000000000000000" },
101+
],
102+
burned: { tokenId: "4", volume: "100000" },
103+
},
104+
storageId: storageId_1.offchainId,
105+
maxFee: "1000000000000000000",
106+
};
107+
108+
const patch: AmmPoolRequestPatch = {
109+
chainId: ChainId.GORLI,
110+
ammName: "LRCETH-Pool",
111+
poolAddress,
112+
eddsaKey: acc.eddsaKey,
113+
};
114+
115+
const response = await api.exitAmmPool(request2, patch, acc.apiKey);
117116
```

docs/js_sdk/contract_api.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Contract API
22

33
## getNonce
4-
5-
```javascript
4+
```typescript
65
const nonce = await contract.getNonce(web3, acc.address);
76
```

src/api/contract_api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export async function signEthereumTx(web3: any, account: any, rawTx: any, chainI
101101
const common = new Common({ chain: chainId })
102102

103103
// console.log('rawTx:', rawTx)
104-
105104
const ethTx = Transaction.fromTxData(rawTx, { common })
106105

107106
// console.log('ethTx:', ethTx)

src/tests/contract.test.ts

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import { loopring_exported_account as acc, web3 } from './utils'
99

1010
import { ExchangeAPI } from '../api/exchange_api'
1111
import { sleep } from '../utils';
12+
import { deposit } from '../api/contract_api';
13+
import { JSONOutput } from 'typedoc';
14+
import { TokenInfo } from '../defs';
1215

1316
// start ganache-cli before
1417
// ganache-cli --debug --chainId=5 --account="0xadc22517f2de0093429e5365b042da0ec9299353943db0f0cc104743c69104cf,1000e+18" --secure --unlock "0xfF7d59D9316EBA168837E3eF924BCDFd64b237D8"
@@ -82,83 +85,77 @@ const gasLimit = 200000
8285

8386
describe('contract test', function () {
8487

85-
beforeEach(async () => {
88+
beforeEach(() => {
8689
api = new ExchangeAPI({ chainId: ChainId.GOERLI })
87-
88-
})
89-
afterEach(async () => {
90-
await sleep(500)
91-
9290
})
9391

94-
it('approveZero_LRC', async () => {
95-
92+
it('approveMax_LRC', async () => {
9693
const nonce = await contract.getNonce(web3, acc.address)
97-
98-
const response = await contract.approveZero(web3, acc.address, lrc.address,
94+
await sleep(200)
95+
const response = await contract.approveMax(web3, acc.address, lrc.address,
9996
acc.depositAddr, gasPrice, gasLimit, ChainId.GOERLI, nonce, true)
10097

101-
console.log(`nonce: ${nonce} approveZero: ${response}`)
98+
console.log(`nonce: ${nonce} approveMax: ${JSON.stringify(response)}`)
10299
}, DEFAULT_TIMEOUT)
103100

104-
it('approveMax_LRC', async () => {
105-
101+
it('deposit_LRC2', async () => {
106102
const nonce = await contract.getNonce(web3, acc.address)
103+
await sleep(200)
104+
const response = await contract.deposit(web3, acc.address, acc.exchangeAddr,
105+
lrc, 11, 0, gasPrice, gasLimit, ChainId.GOERLI, nonce, true)
107106

108-
const response = await contract.approveMax(web3, acc.address, lrc.address,
109-
acc.depositAddr, gasPrice, gasLimit, ChainId.GOERLI, nonce, true)
110-
111-
console.log(`nonce: ${nonce} approveMax: ${response}`)
107+
console.log(`nonce: ${nonce} deposit_LRC: `, response)
112108
}, DEFAULT_TIMEOUT)
113109

114110
it('approveMax_ETH test', async () => {
115-
116111
const nonce = await contract.getNonce(web3, acc.address)
117-
112+
await sleep(200)
118113
const response = await contract.approveMax(web3, acc.address, eth.address,
119114
acc.depositAddr, gasPrice, gasLimit, ChainId.GOERLI, nonce, true)
120115

121116
console.log(`nonce: ${nonce} approveMax: ${response}`)
122117
}, DEFAULT_TIMEOUT)
123118

124-
it('deposit_LRC2', async () => {
125-
126-
const nonce = await contract.getNonce(web3, acc.address)
127-
128-
const response = await contract.deposit(web3, acc.address, acc.exchangeAddr,
129-
lrc, 11, 0, gasPrice, gasLimit, ChainId.GOERLI, nonce, false)
119+
130120

131-
console.log(`nonce: ${nonce} deposit_LRC: `, response)
132-
}, DEFAULT_TIMEOUT)
133121

134122
it('deposit_LRC1', async () => {
135-
136123
const nonce = await contract.getNonce(web3, acc.address)
137-
124+
await sleep(200)
138125
const response = await contract.deposit(web3, acc.address, acc.exchangeAddr,
139126
lrc, 1, 0, gasPrice, gasLimit, ChainId.GOERLI, nonce, true)
140127

141128
console.log(`nonce: ${nonce} deposit_LRC: `, response)
142129
}, DEFAULT_TIMEOUT)
130+
131+
//TODO: test for hardware wallet
132+
// it('deposit_ETH test', async () => {
133+
// const nonce = await contract.getNonce(web3, acc.address)
134+
// await sleep(200)
135+
// const response = await contract.deposit(web3, acc.address, acc.exchangeAddr,
136+
// eth, 0.1, 0, gasPrice, parseInt(eth.gasAmounts.deposit), ChainId.GOERLI, nonce, false)
137+
//
138+
// console.log(`nonce: ${nonce} deposit_ETH: ${response}`)
139+
// }, DEFAULT_TIMEOUT)
143140

144-
it('deposit_ETH test', async () => {
145-
141+
it('forceWithdrawal test', async () => {
146142
const nonce = await contract.getNonce(web3, acc.address)
147-
148-
const response = await contract.deposit(web3, acc.address, acc.exchangeAddr,
149-
eth, 0.1, 0, gasPrice, parseInt(eth.gasAmounts.deposit), ChainId.GOERLI, nonce, true)
143+
await sleep(200)
144+
const response = await contract.forceWithdrawal(web3, acc.address, acc.accountId, acc.exchangeAddr,
145+
eth, 0, gasPrice, gasLimit, ChainId.GOERLI, nonce, true)
150146

151147
console.log(`nonce: ${nonce} deposit_ETH: ${response}`)
152148
}, DEFAULT_TIMEOUT)
153-
154-
it('forceWithdrawal test', async () => {
149+
150+
it('approveZero_LRC', async () => {
155151

156152
const nonce = await contract.getNonce(web3, acc.address)
153+
await sleep(200)
154+
const response = await contract.approveZero(web3, acc.address, lrc.address,
155+
acc.depositAddr, gasPrice, gasLimit, ChainId.GOERLI, nonce, true)
157156

158-
const response = await contract.forceWithdrawal(web3, acc.address, acc.accountId, acc.exchangeAddr,
159-
eth, 0, gasPrice, gasLimit, ChainId.GOERLI, nonce, true)
160-
161-
console.log(`nonce: ${nonce} deposit_ETH: ${response}`)
157+
console.log(`nonce: ${nonce} approveZero: ${response}`)
162158
}, DEFAULT_TIMEOUT)
163159

160+
164161
})

0 commit comments

Comments
 (0)