Skip to content

Commit d3af3ce

Browse files
committed
feat(test-app): more examples for the account api
matching about 50% of the origina, spec
1 parent 5f6aac9 commit d3af3ce

File tree

4 files changed

+142
-7
lines changed

4 files changed

+142
-7
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<template>
2+
<div class="example4">
3+
<prism-editor :code="code" language="js"></prism-editor>
4+
<h2>Result</h2>
5+
<md-tabs>
6+
<md-tab id="tab-pages" md-label="Data">
7+
<md-table v-model="result.result" md-sort="blockNumber" md-sort-order="asc" md-card md-fixed-header>
8+
<md-table-toolbar>
9+
<h1 class="md-title">Users</h1>
10+
</md-table-toolbar>
11+
12+
<md-table-row slot="md-table-row" slot-scope="{ item }">
13+
<md-table-cell md-label="blockNumber" md-sort-by="blockNumber" md-numeric>{{ item.blockNumber }}</md-table-cell>
14+
<md-table-cell md-label="timeStamp" md-sort-by="timeStamp">{{ item.timeStamp }}</md-table-cell>
15+
<md-table-cell md-label="hash" md-sort-by="hash">{{ item.hash }}</md-table-cell>
16+
<md-table-cell md-label="gasUsed" md-sort-by="gasUsed">{{ item.gasUsed }}</md-table-cell>
17+
<md-table-cell md-label="gas" md-sort-by="gas">{{ item.gas }}</md-table-cell>
18+
</md-table-row>
19+
</md-table>
20+
</md-tab>
21+
<md-tab id="tab-home" md-label="JSON" exact>
22+
<vue-json-pretty :data="result"></vue-json-pretty>
23+
</md-tab>
24+
</md-tabs>
25+
</div>
26+
</template>
27+
28+
<script>
29+
import VueJsonPretty from 'vue-json-pretty'
30+
const Client = require('etherscan-api/dist/src/Client').Client
31+
const validApiKey = 'TRU5Z5MNWIEYP4F6DPH2T53IJWZIZ5GT1W'
32+
33+
export default {
34+
components: {
35+
VueJsonPretty
36+
},
37+
name: 'Example4',
38+
data () {
39+
return {
40+
code: `const client = new EtherscanClient.Client(validApiKey);
41+
const address = '0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3'
42+
const startblock = 0
43+
const endblock = 2702578
44+
const sort = 'asc'
45+
const res = await client.account('txlistinternal')(address, startblock, endblock, sort)`
46+
}
47+
},
48+
props: {
49+
msg: String
50+
},
51+
asyncComputed: {
52+
result: {
53+
get () {
54+
const client = new Client(validApiKey)
55+
const address = '0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3'
56+
const startblock = 0
57+
const endblock = 2702578
58+
const sort = 'asc'
59+
return client.account('txlistinternal')(address, startblock, endblock, sort)
60+
},
61+
default: {
62+
result: []
63+
}
64+
}
65+
}
66+
}
67+
</script>
68+
<style scoped></style>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<template>
2+
<div class="example5">
3+
<prism-editor :code="code" language="js"></prism-editor>
4+
<h2>Result</h2>
5+
<md-tabs>
6+
<md-tab id="tab-pages" md-label="Data">
7+
<md-table v-model="result.result" md-sort="blockNumber" md-sort-order="asc" md-card md-fixed-header>
8+
<md-table-toolbar>
9+
<h1 class="md-title">Users</h1>
10+
</md-table-toolbar>
11+
<md-table-row slot="md-table-row" slot-scope="{ item }">
12+
<md-table-cell md-label="blockNumber" md-sort-by="blockNumber" md-numeric>{{ item.blockNumber }}</md-table-cell>
13+
<md-table-cell md-label="timeStamp" md-sort-by="timeStamp">{{ item.timeStamp }}</md-table-cell>
14+
<md-table-cell md-label="hash" md-sort-by="hash">{{ item.hash }}</md-table-cell>
15+
<md-table-cell md-label="gasUsed" md-sort-by="gasUsed">{{ item.gasUsed }}</md-table-cell>
16+
<md-table-cell md-label="gas" md-sort-by="gas">{{ item.gas }}</md-table-cell>
17+
</md-table-row>
18+
</md-table>
19+
</md-tab>
20+
<md-tab id="tab-home" md-label="JSON" exact>
21+
<vue-json-pretty :data="result"></vue-json-pretty>
22+
</md-tab>
23+
</md-tabs>
24+
</div>
25+
</template>
26+
27+
<script>
28+
import VueJsonPretty from 'vue-json-pretty'
29+
const Client = require('etherscan-api/dist/src/Client').Client
30+
const validApiKey = 'TRU5Z5MNWIEYP4F6DPH2T53IJWZIZ5GT1W'
31+
32+
export default {
33+
components: {
34+
VueJsonPretty
35+
},
36+
name: 'Example5',
37+
data () {
38+
return {
39+
code: `const client = new EtherscanClient.Client(validApiKey);
40+
const txhash = '0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170'
41+
const startblock = 0
42+
const endblock = 999999
43+
const sort = 'asc'
44+
const promise = client.account('txlistinternaltxhash')(txhash, startblock, endblock, sort)`
45+
}
46+
},
47+
props: {
48+
msg: String
49+
},
50+
asyncComputed: {
51+
result: {
52+
get () {
53+
const client = new Client(validApiKey)
54+
const txhash = '0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170'
55+
const startblock = 0
56+
const endblock = 999999
57+
const sort = 'asc'
58+
return client.account('txlistinternaltxhash')(txhash, startblock, endblock, sort)
59+
},
60+
default: {
61+
result: []
62+
}
63+
}
64+
}
65+
}
66+
</script>
67+
<style scoped></style>

packages/test-app/src/router.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ export default new Router({
2828
},
2929
{
3030
path: '/transaction',
31-
name: 'contract',
31+
name: 'transaction',
3232
component: () => import(/* webpackChunkName: "foo" */ './views/Transaction.vue')
3333
},
3434
{
3535
path: '/block',
36-
name: 'contract',
36+
name: 'block',
3737
component: () => import(/* webpackChunkName: "foo" */ './views/Block.vue')
3838
},
3939
{

packages/test-app/src/views/Account.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616
</md-step>
1717

1818
<md-step id="fourth" md-label="Get a list of 'Internal' Transactions by Address">
19-
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias doloribus eveniet quaerat modi cumque quos sed, temporibus nemo eius amet aliquid, illo minus blanditiis tempore, dolores voluptas dolore placeat nulla.</p>
20-
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias doloribus eveniet quaerat modi cumque quos sed, temporibus nemo eius amet aliquid, illo minus blanditiis tempore, dolores voluptas dolore placeat nulla.</p>
19+
<Example4></Example4>
2120
</md-step>
2221

2322
<md-step id="fifth" md-label="Get 'Internal Transactions' by Transaction Hash">
24-
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias doloribus eveniet quaerat modi cumque quos sed, temporibus nemo eius amet aliquid, illo minus blanditiis tempore, dolores voluptas dolore placeat nulla.</p>
25-
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias doloribus eveniet quaerat modi cumque quos sed, temporibus nemo eius amet aliquid, illo minus blanditiis tempore, dolores voluptas dolore placeat nulla.</p>
23+
<Example5></Example5>
2624
</md-step>
2725
</md-steppers>
2826
</div>
@@ -32,11 +30,13 @@
3230
import Example1 from '@/components/account/Example1.vue'
3331
import Example2 from '@/components/account/Example2.vue'
3432
import Example3 from '@/components/account/Example3.vue'
33+
import Example4 from '@/components/account/Example4.vue'
34+
import Example5 from '@/components/account/Example5.vue'
3535
3636
export default {
3737
name: 'Acccount',
3838
components: {
39-
Example1, Example2, Example3
39+
Example1, Example2, Example3, Example4, Example5
4040
}
4141
}
4242
</script>

0 commit comments

Comments
 (0)