Skip to content

Commit a59908e

Browse files
authored
fix tests (#330)
1 parent 85f508c commit a59908e

11 files changed

+74
-31
lines changed

run/models/block.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ module.exports = (sequelize, DataTypes) => {
5555
timestamp: {
5656
type: DataTypes.DATE,
5757
set(value) {
58-
this.setDataValue('timestamp', moment.unix(value).format());
58+
if (String(value).length > 10)
59+
this.setDataValue('timestamp', moment(value).format());
60+
else
61+
this.setDataValue('timestamp', moment.unix(value).format());
5962
}
6063
},
6164
transactionsCount: DataTypes.INTEGER,

run/models/contract.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,10 @@ module.exports = (sequelize, DataTypes) => {
519519
timestamp: {
520520
type: DataTypes.DATE,
521521
set(value) {
522-
this.setDataValue('timestamp', moment.unix(value).format());
522+
if (value.length > 10)
523+
this.setDataValue('timestamp', moment(value).format());
524+
else
525+
this.setDataValue('timestamp', moment.unix(value).format());
523526
}
524527
},
525528
tokenDecimals: DataTypes.INTEGER,

run/models/tokenbalancechangeevent.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
const {
33
Model
44
} = require('sequelize');
5+
const moment = require('moment');
56
module.exports = (sequelize, DataTypes) => {
67
class TokenBalanceChangeEvent extends Model {
78
/**
@@ -19,7 +20,13 @@ module.exports = (sequelize, DataTypes) => {
1920
blockNumber: DataTypes.INTEGER,
2021
timestamp: {
2122
primaryKey: true,
22-
type: DataTypes.DATE
23+
type: DataTypes.DATE,
24+
set(value) {
25+
if (String(value).length > 10)
26+
this.setDataValue('timestamp', moment(value).format());
27+
else
28+
this.setDataValue('timestamp', moment.unix(value).format());
29+
}
2330
},
2431
token: DataTypes.STRING,
2532
address: DataTypes.STRING,

run/models/tokentransferevent.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
const {
33
Model
44
} = require('sequelize');
5+
const moment = require('moment');
56
module.exports = (sequelize, DataTypes) => {
67
class TokenTransferEvent extends Model {
78
/**
@@ -18,7 +19,13 @@ module.exports = (sequelize, DataTypes) => {
1819
blockNumber: DataTypes.INTEGER,
1920
timestamp: {
2021
primaryKey: true,
21-
type: DataTypes.DATE
22+
type: DataTypes.DATE,
23+
set(value) {
24+
if (String(value).length > 10)
25+
this.setDataValue('timestamp', moment(value).format());
26+
else
27+
this.setDataValue('timestamp', moment.unix(value).format());
28+
}
2229
},
2330
amount: DataTypes.NUMERIC,
2431
token: DataTypes.STRING,

run/models/transaction.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ module.exports = (sequelize, DataTypes) => {
247247
timestamp: {
248248
type: DataTypes.DATE,
249249
set(value) {
250-
this.setDataValue('timestamp', moment.unix(value).format());
250+
if (String(value).length > 10)
251+
this.setDataValue('timestamp', moment(value).format());
252+
else
253+
this.setDataValue('timestamp', moment.unix(value).format());
251254
}
252255
},
253256
to: {
@@ -262,7 +265,17 @@ module.exports = (sequelize, DataTypes) => {
262265
transactionIndex: DataTypes.INTEGER,
263266
type: DataTypes.INTEGER,
264267
v: DataTypes.INTEGER,
265-
value: DataTypes.STRING,
268+
value: {
269+
type: DataTypes.STRING,
270+
set(value) {
271+
this.setDataValue('value', value.toString(10));
272+
},
273+
get() {
274+
console.log(this.getDataValue('value'))
275+
console.log(this.getDataValue('value').toString(10))
276+
return this.getDataValue('value') ? this.getDataValue('value').toString(10) : null
277+
}
278+
},
266279
storage: DataTypes.JSON,
267280
raw: DataTypes.JSON,
268281
formattedBalanceChanges: {

run/models/transactionevent.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
const {
33
Model
44
} = require('sequelize');
5+
const moment = require('moment');
56
module.exports = (sequelize, DataTypes) => {
67
class TransactionEvent extends Model {
78
/**
@@ -19,7 +20,13 @@ module.exports = (sequelize, DataTypes) => {
1920
blockNumber: DataTypes.INTEGER,
2021
timestamp: {
2122
type: DataTypes.DATE,
22-
primaryKey: true
23+
primaryKey: true,
24+
set(value) {
25+
if (String(value).length > 10)
26+
this.setDataValue('timestamp', moment(value).format());
27+
else
28+
this.setDataValue('timestamp', moment.unix(value).format());
29+
}
2330
},
2431
transactionFee: DataTypes.STRING,
2532
gasPrice: DataTypes.STRING,

src/components/HashLink.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
&nbsp;(<router-link :to="`/address/${hash}/${tokenId}`">#{{ tokenId }}</router-link>)
1313
</span>
1414
<span v-if="hash && !copied && !notCopiable">
15-
&nbsp; <v-icon @click="copyHash()" x-small>mdi-content-copy</v-icon><input type="hidden" :id="`copyElement-${hash}`" :value="hash">
15+
&nbsp;<v-icon @click="copyHash()" x-small>mdi-content-copy</v-icon><input type="hidden" :id="`copyElement-${hash}`" :value="hash">
1616
</span>
1717
<span v-if="copied">
1818
&nbsp; <v-icon x-small>mdi-check</v-icon>
@@ -75,10 +75,10 @@ export default {
7575
return this.hash;
7676
}
7777
else if (this.xsHash) {
78-
return `${this.hash.slice(0, 5)}...${this.hash.slice(-5)}`;
78+
return `${this.hash.slice(0, 5)}...${this.hash.slice(-4)}`;
7979
}
8080
else {
81-
return `${this.hash.slice(0, 10)}...${this.hash.slice(-5)}`;
81+
return `${this.hash.slice(0, 8)}...${this.hash.slice(-4)}`;
8282
}
8383
},
8484
name() {

src/components/Metamask.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default {
6464
chainId: this.formattedExpectedChainId,
6565
chainName: this.publicExplorer.name,
6666
rpcUrls: [this.rpcServer],
67-
blockExplorerUrls: [this.publicExplorer.domain]
67+
blockExplorerUrls: [this.publicExplorerDomain]
6868
}
6969
]
7070
}).catch(console.log);
@@ -87,6 +87,9 @@ export default {
8787
'currentWorkspace',
8888
'theme'
8989
]),
90+
publicExplorerDomain() {
91+
return this.publicExplorer.domain.startsWith('https://') ? this.publicExplorer.domain : `https://${this.publicExplorerDomain}`;
92+
},
9093
isChainValid: function() {
9194
return this.formattedExpectedChainId === this.chainId;
9295
},

tests/unit/components/__snapshots__/HashLink.spec.js.snap

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,61 @@
22

33
exports[`HashLink.vue Should display a full link to the address 1`] = `
44
<span><!----> <a href="/address/0x2D481eeb2bA97955CD081Cf218f453A817259AB1" class="">0x2D481eeb2bA97955CD081Cf218f453A817259AB1</a> <!----> <span>
5-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x2D481eeb2bA97955CD081Cf218f453A817259AB1" value="0x2D481eeb2bA97955CD081Cf218f453A817259AB1"></span>
5+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x2D481eeb2bA97955CD081Cf218f453A817259AB1" value="0x2D481eeb2bA97955CD081Cf218f453A817259AB1"></span>
66
<!----></span>
77
`;
88
99
exports[`HashLink.vue Should display a shortened link to the address 1`] = `
10-
<span><!----> <a href="/address/0x2D481eeb2bA97955CD081Cf218f453A817259AB1" class="">0x2D481eeb...59AB1</a> <!----> <span>
11-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x2D481eeb2bA97955CD081Cf218f453A817259AB1" value="0x2D481eeb2bA97955CD081Cf218f453A817259AB1"></span>
10+
<span><!----> <a href="/address/0x2D481eeb2bA97955CD081Cf218f453A817259AB1" class="">0x2D481e...9AB1</a> <!----> <span>
11+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x2D481eeb2bA97955CD081Cf218f453A817259AB1" value="0x2D481eeb2bA97955CD081Cf218f453A817259AB1"></span>
1212
<!----></span>
1313
`;
1414
1515
exports[`HashLink.vue Should display link to token if tokenId is passed 1`] = `
1616
<span><!----> <a href="/address/0x123" class="">Ethernal</a> <span>
1717
&nbsp;(<a href="/address/0x123/1" class="">#1</a>)
1818
</span> <span>
19-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x123" value="0x123"></span>
19+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x123" value="0x123"></span>
2020
<!----></span>
2121
`;
2222
2323
exports[`HashLink.vue Should display smaller hash if xsHash option is passed 1`] = `
24-
<span><!----> <a href="/address/0xed5af388653567af2f388e6224dc7c4b3241c544" class="">0xed5...1c544</a> <!----> <span>
25-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0xed5af388653567af2f388e6224dc7c4b3241c544" value="0xed5af388653567af2f388e6224dc7c4b3241c544"></span>
24+
<span><!----> <a href="/address/0xed5af388653567af2f388e6224dc7c4b3241c544" class="">0xed5...c544</a> <!----> <span>
25+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0xed5af388653567af2f388e6224dc7c4b3241c544" value="0xed5af388653567af2f388e6224dc7c4b3241c544"></span>
2626
<!----></span>
2727
`;
2828
2929
exports[`HashLink.vue Should display the contract name when no token 1`] = `
3030
<span><!----> <a href="/address/0x123" class="">My Contract</a> <!----> <span>
31-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x123" value="0x123"></span>
31+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x123" value="0x123"></span>
3232
<!----></span>
3333
`;
3434
3535
exports[`HashLink.vue Should display the name for the 0x0 address 1`] = `
3636
<span><!----> <a href="/address/0x0000000000000000000000000000000000000000" class="">Black Hole</a> <!----> <span>
37-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x0000000000000000000000000000000000000000" value="0x0000000000000000000000000000000000000000"></span>
37+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x0000000000000000000000000000000000000000" value="0x0000000000000000000000000000000000000000"></span>
3838
<!----></span>
3939
`;
4040
4141
exports[`HashLink.vue Should display the token name if available & no token symbol 1`] = `
4242
<span><!----> <a href="/address/0x123" class="">My Contract</a> <!----> <span>
43-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x123" value="0x123"></span>
43+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x123" value="0x123"></span>
4444
<!----></span>
4545
`;
4646
4747
exports[`HashLink.vue Should display the token name if symbol but flag withTokenName 1`] = `
4848
<span><!----> <a href="/address/0x123" class="">Ethernal</a> <!----> <span>
49-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x123" value="0x123"></span>
49+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x123" value="0x123"></span>
5050
<!----></span>
5151
`;
5252
5353
exports[`HashLink.vue Should display the token symbol if available 1`] = `
5454
<span><!----> <a href="/address/0x123" class="">My Contract</a> <!----> <span>
55-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x123" value="0x123"></span>
55+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x123" value="0x123"></span>
5656
<!----></span>
5757
`;
5858
59-
exports[`HashLink.vue Should not be copiable if the notCopiable flag is passed 1`] = `<span><!----> <a href="/address/0x2D481eeb2bA97955CD081Cf218f453A817259AB1" class="">0x2D481eeb...59AB1</a> <!----> <!----> <!----></span>`;
59+
exports[`HashLink.vue Should not be copiable if the notCopiable flag is passed 1`] = `<span><!----> <a href="/address/0x2D481eeb2bA97955CD081Cf218f453A817259AB1" class="">0x2D481e...9AB1</a> <!----> <!----> <!----></span>`;
6060
6161
exports[`HashLink.vue Should not create links 1`] = `<span><!----> My Contract <!----> <!----> <!----></span>`;
6262

tests/unit/components/__snapshots__/TransactionFunctionCall.spec.js.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ exports[`TransactionFunctionCall.vue Should display transaction call 1`] = `
77
88
<div class="ml-4" style="white-space: pre;"><span class="ml-4"><span>address dst: </span> <span>
99
(<a id="switchFormatted">Display Raw</a> <!---->)
10-
<span class=""><span><span><!----> <a href="/address/0xc00e94Cb662C3520282E6f5717214004A7f26888" class="">0xc00e94Cb...26888</a> <!----> <span>
11-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0xc00e94Cb662C3520282E6f5717214004A7f26888" value="0xc00e94Cb662C3520282E6f5717214004A7f26888"></span>
10+
<span class=""><span><span><!----> <a href="/address/0xc00e94Cb662C3520282E6f5717214004A7f26888" class="">0xc00e94...6888</a> <!----> <span>
11+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0xc00e94Cb662C3520282E6f5717214004A7f26888" value="0xc00e94Cb662C3520282E6f5717214004A7f26888"></span>
1212
<!----></span></span></span></span></span>
1313
</div>
1414
<div class="ml-4" style="white-space: pre;"><span class="ml-4"><span>uint256 rawAmount: </span> <span><!----> <span class="" style="white-space: break-spaces;">1</span></span></span></div>
@@ -52,8 +52,8 @@ exports[`TransactionFunctionCall.vue Should load erc20 abi if function is detect
5252
5353
<div class="ml-4" style="white-space: pre;"><span class="ml-4"><span>address _to: </span> <span>
5454
(<a id="switchFormatted">Display Raw</a> <!---->)
55-
<span class=""><span><span><!----> <a href="/address/0xc00e94Cb662C3520282E6f5717214004A7f26888" class="">0xc00e94Cb...26888</a> <!----> <span>
56-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0xc00e94Cb662C3520282E6f5717214004A7f26888" value="0xc00e94Cb662C3520282E6f5717214004A7f26888"></span>
55+
<span class=""><span><span><!----> <a href="/address/0xc00e94Cb662C3520282E6f5717214004A7f26888" class="">0xc00e94...6888</a> <!----> <span>
56+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0xc00e94Cb662C3520282E6f5717214004A7f26888" value="0xc00e94Cb662C3520282E6f5717214004A7f26888"></span>
5757
<!----></span></span></span></span></span>
5858
</div>
5959
<div class="ml-4" style="white-space: pre;"><span class="ml-4"><span>uint256 _value: </span> <span><!----> <span class="" style="white-space: break-spaces;">1</span></span></span></div>

tests/unit/components/__snapshots__/TransactionsList.spec.js.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ exports[`TransactionsList.vue Should not display transactions count 1`] = `
206206
<circle fill="transparent" cx="45.714285714285715" cy="45.714285714285715" r="20" stroke-width="5.714285714285714" stroke-dasharray="125.664" stroke-dashoffset="125.66370614359172px" class="v-progress-circular__overlay"></circle>
207207
</svg>
208208
<div class="v-progress-circular__info"></div>
209-
</div> <i aria-hidden="true" aria-haspopup="true" aria-expanded="false" class="v-icon notranslate mr-2 mdi mdi-help-circle theme--light grey--text text--lighten-1" style="font-size: 16px; display: none;"></i> <i aria-hidden="true" aria-haspopup="true" aria-expanded="false" class="v-icon notranslate mr-2 mdi mdi-alert-circle theme--light error--text text--lighten-1" style="font-size: 16px; display: none;"></i> <span><!----> <a href="/transaction/0x060034486a819816df57d01eefccbe161d7019f9f3c235e18af07468fb194ef0" class="">0x06003448...94ef0</a> <!----> <span>
210-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x060034486a819816df57d01eefccbe161d7019f9f3c235e18af07468fb194ef0" value="0x060034486a819816df57d01eefccbe161d7019f9f3c235e18af07468fb194ef0"></span>
209+
</div> <i aria-hidden="true" aria-haspopup="true" aria-expanded="false" class="v-icon notranslate mr-2 mdi mdi-help-circle theme--light grey--text text--lighten-1" style="font-size: 16px; display: none;"></i> <i aria-hidden="true" aria-haspopup="true" aria-expanded="false" class="v-icon notranslate mr-2 mdi mdi-alert-circle theme--light error--text text--lighten-1" style="font-size: 16px; display: none;"></i> <span><!----> <a href="/transaction/0x060034486a819816df57d01eefccbe161d7019f9f3c235e18af07468fb194ef0" class="">0x060034...4ef0</a> <!----> <span>
210+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x060034486a819816df57d01eefccbe161d7019f9f3c235e18af07468fb194ef0" value="0x060034486a819816df57d01eefccbe161d7019f9f3c235e18af07468fb194ef0"></span>
211211
<!----></span>
212212
</td>
213213
<td class="text-start"><span><span class="v-chip v-chip--label theme--light v-size--small color--text primary lighten-1"><span class="v-chip__content">0xa9059cbb</span></span></span></td>
@@ -218,12 +218,12 @@ exports[`TransactionsList.vue Should not display transactions count 1`] = `
218218
</td>
219219
<td class="text-start">
220220
<!----> <span><!----> <a href="/address/0x0" class="">0x0...0x0</a> <!----> <span>
221-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x0" value="0x0"></span>
221+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-0x0" value="0x0"></span>
222222
<!----></span>
223223
</td>
224224
<td class="text-start">
225225
<!----> <span><!----> <a href="/address/Ox1" class="">Ox1...Ox1</a> <!----> <span>
226-
&nbsp; <button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-Ox1" value="Ox1"></span>
226+
&nbsp;<button type="button" class="v-icon notranslate v-icon--link mdi mdi-content-copy theme--light" style="font-size: 12px;"></button><input type="hidden" id="copyElement-Ox1" value="Ox1"></span>
227227
<!----></span>
228228
</td>
229229
<td class="text-start">

0 commit comments

Comments
 (0)