Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests #330

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion run/models/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ module.exports = (sequelize, DataTypes) => {
timestamp: {
type: DataTypes.DATE,
set(value) {
this.setDataValue('timestamp', moment.unix(value).format());
if (String(value).length > 10)
this.setDataValue('timestamp', moment(value).format());
else
this.setDataValue('timestamp', moment.unix(value).format());
}
},
transactionsCount: DataTypes.INTEGER,
Expand Down
5 changes: 4 additions & 1 deletion run/models/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,10 @@ module.exports = (sequelize, DataTypes) => {
timestamp: {
type: DataTypes.DATE,
set(value) {
this.setDataValue('timestamp', moment.unix(value).format());
if (value.length > 10)
this.setDataValue('timestamp', moment(value).format());
else
this.setDataValue('timestamp', moment.unix(value).format());
}
},
tokenDecimals: DataTypes.INTEGER,
Expand Down
9 changes: 8 additions & 1 deletion run/models/tokenbalancechangeevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const {
Model
} = require('sequelize');
const moment = require('moment');
module.exports = (sequelize, DataTypes) => {
class TokenBalanceChangeEvent extends Model {
/**
Expand All @@ -19,7 +20,13 @@ module.exports = (sequelize, DataTypes) => {
blockNumber: DataTypes.INTEGER,
timestamp: {
primaryKey: true,
type: DataTypes.DATE
type: DataTypes.DATE,
set(value) {
if (String(value).length > 10)
this.setDataValue('timestamp', moment(value).format());
else
this.setDataValue('timestamp', moment.unix(value).format());
}
},
token: DataTypes.STRING,
address: DataTypes.STRING,
Expand Down
9 changes: 8 additions & 1 deletion run/models/tokentransferevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const {
Model
} = require('sequelize');
const moment = require('moment');
module.exports = (sequelize, DataTypes) => {
class TokenTransferEvent extends Model {
/**
Expand All @@ -18,7 +19,13 @@ module.exports = (sequelize, DataTypes) => {
blockNumber: DataTypes.INTEGER,
timestamp: {
primaryKey: true,
type: DataTypes.DATE
type: DataTypes.DATE,
set(value) {
if (String(value).length > 10)
this.setDataValue('timestamp', moment(value).format());
else
this.setDataValue('timestamp', moment.unix(value).format());
}
},
amount: DataTypes.NUMERIC,
token: DataTypes.STRING,
Expand Down
17 changes: 15 additions & 2 deletions run/models/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ module.exports = (sequelize, DataTypes) => {
timestamp: {
type: DataTypes.DATE,
set(value) {
this.setDataValue('timestamp', moment.unix(value).format());
if (String(value).length > 10)
this.setDataValue('timestamp', moment(value).format());
else
this.setDataValue('timestamp', moment.unix(value).format());
}
},
to: {
Expand All @@ -262,7 +265,17 @@ module.exports = (sequelize, DataTypes) => {
transactionIndex: DataTypes.INTEGER,
type: DataTypes.INTEGER,
v: DataTypes.INTEGER,
value: DataTypes.STRING,
value: {
type: DataTypes.STRING,
set(value) {
this.setDataValue('value', value.toString(10));
},
get() {
console.log(this.getDataValue('value'))
console.log(this.getDataValue('value').toString(10))
return this.getDataValue('value') ? this.getDataValue('value').toString(10) : null
}
},
storage: DataTypes.JSON,
raw: DataTypes.JSON,
formattedBalanceChanges: {
Expand Down
9 changes: 8 additions & 1 deletion run/models/transactionevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const {
Model
} = require('sequelize');
const moment = require('moment');
module.exports = (sequelize, DataTypes) => {
class TransactionEvent extends Model {
/**
Expand All @@ -19,7 +20,13 @@ module.exports = (sequelize, DataTypes) => {
blockNumber: DataTypes.INTEGER,
timestamp: {
type: DataTypes.DATE,
primaryKey: true
primaryKey: true,
set(value) {
if (String(value).length > 10)
this.setDataValue('timestamp', moment(value).format());
else
this.setDataValue('timestamp', moment.unix(value).format());
}
},
transactionFee: DataTypes.STRING,
gasPrice: DataTypes.STRING,
Expand Down
6 changes: 3 additions & 3 deletions src/components/HashLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
&nbsp;(<router-link :to="`/address/${hash}/${tokenId}`">#{{ tokenId }}</router-link>)
</span>
<span v-if="hash && !copied && !notCopiable">
&nbsp; <v-icon @click="copyHash()" x-small>mdi-content-copy</v-icon><input type="hidden" :id="`copyElement-${hash}`" :value="hash">
&nbsp;<v-icon @click="copyHash()" x-small>mdi-content-copy</v-icon><input type="hidden" :id="`copyElement-${hash}`" :value="hash">
</span>
<span v-if="copied">
&nbsp; <v-icon x-small>mdi-check</v-icon>
Expand Down Expand Up @@ -75,10 +75,10 @@ export default {
return this.hash;
}
else if (this.xsHash) {
return `${this.hash.slice(0, 5)}...${this.hash.slice(-5)}`;
return `${this.hash.slice(0, 5)}...${this.hash.slice(-4)}`;
}
else {
return `${this.hash.slice(0, 10)}...${this.hash.slice(-5)}`;
return `${this.hash.slice(0, 8)}...${this.hash.slice(-4)}`;
}
},
name() {
Expand Down
5 changes: 4 additions & 1 deletion src/components/Metamask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default {
chainId: this.formattedExpectedChainId,
chainName: this.publicExplorer.name,
rpcUrls: [this.rpcServer],
blockExplorerUrls: [this.publicExplorer.domain]
blockExplorerUrls: [this.publicExplorerDomain]
}
]
}).catch(console.log);
Expand All @@ -87,6 +87,9 @@ export default {
'currentWorkspace',
'theme'
]),
publicExplorerDomain() {
return this.publicExplorer.domain.startsWith('https://') ? this.publicExplorer.domain : `https://${this.publicExplorerDomain}`;
},
isChainValid: function() {
return this.formattedExpectedChainId === this.chainId;
},
Expand Down
24 changes: 12 additions & 12 deletions tests/unit/components/__snapshots__/HashLink.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,61 @@

exports[`HashLink.vue Should display a full link to the address 1`] = `
<span><!----> <a href="/address/0x2D481eeb2bA97955CD081Cf218f453A817259AB1" class="">0x2D481eeb2bA97955CD081Cf218f453A817259AB1</a> <!----> <span>
&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>
&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>
<!----></span>
`;

exports[`HashLink.vue Should display a shortened link to the address 1`] = `
<span><!----> <a href="/address/0x2D481eeb2bA97955CD081Cf218f453A817259AB1" class="">0x2D481eeb...59AB1</a> <!----> <span>
&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>
<span><!----> <a href="/address/0x2D481eeb2bA97955CD081Cf218f453A817259AB1" class="">0x2D481e...9AB1</a> <!----> <span>
&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>
<!----></span>
`;

exports[`HashLink.vue Should display link to token if tokenId is passed 1`] = `
<span><!----> <a href="/address/0x123" class="">Ethernal</a> <span>
&nbsp;(<a href="/address/0x123/1" class="">#1</a>)
</span> <span>
&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>
&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>
<!----></span>
`;

exports[`HashLink.vue Should display smaller hash if xsHash option is passed 1`] = `
<span><!----> <a href="/address/0xed5af388653567af2f388e6224dc7c4b3241c544" class="">0xed5...1c544</a> <!----> <span>
&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>
<span><!----> <a href="/address/0xed5af388653567af2f388e6224dc7c4b3241c544" class="">0xed5...c544</a> <!----> <span>
&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>
<!----></span>
`;

exports[`HashLink.vue Should display the contract name when no token 1`] = `
<span><!----> <a href="/address/0x123" class="">My Contract</a> <!----> <span>
&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>
&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>
<!----></span>
`;

exports[`HashLink.vue Should display the name for the 0x0 address 1`] = `
<span><!----> <a href="/address/0x0000000000000000000000000000000000000000" class="">Black Hole</a> <!----> <span>
&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>
&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>
<!----></span>
`;

exports[`HashLink.vue Should display the token name if available & no token symbol 1`] = `
<span><!----> <a href="/address/0x123" class="">My Contract</a> <!----> <span>
&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>
&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>
<!----></span>
`;

exports[`HashLink.vue Should display the token name if symbol but flag withTokenName 1`] = `
<span><!----> <a href="/address/0x123" class="">Ethernal</a> <!----> <span>
&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>
&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>
<!----></span>
`;

exports[`HashLink.vue Should display the token symbol if available 1`] = `
<span><!----> <a href="/address/0x123" class="">My Contract</a> <!----> <span>
&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>
&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>
<!----></span>
`;

exports[`HashLink.vue Should not be copiable if the notCopiable flag is passed 1`] = `<span><!----> <a href="/address/0x2D481eeb2bA97955CD081Cf218f453A817259AB1" class="">0x2D481eeb...59AB1</a> <!----> <!----> <!----></span>`;
exports[`HashLink.vue Should not be copiable if the notCopiable flag is passed 1`] = `<span><!----> <a href="/address/0x2D481eeb2bA97955CD081Cf218f453A817259AB1" class="">0x2D481e...9AB1</a> <!----> <!----> <!----></span>`;

exports[`HashLink.vue Should not create links 1`] = `<span><!----> My Contract <!----> <!----> <!----></span>`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ exports[`TransactionFunctionCall.vue Should display transaction call 1`] = `

<div class="ml-4" style="white-space: pre;"><span class="ml-4"><span>address dst: </span> <span>
(<a id="switchFormatted">Display Raw</a> <!---->)
<span class=""><span><span><!----> <a href="/address/0xc00e94Cb662C3520282E6f5717214004A7f26888" class="">0xc00e94Cb...26888</a> <!----> <span>
&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>
<span class=""><span><span><!----> <a href="/address/0xc00e94Cb662C3520282E6f5717214004A7f26888" class="">0xc00e94...6888</a> <!----> <span>
&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>
<!----></span></span></span></span></span>
</div>
<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>
Expand Down Expand Up @@ -52,8 +52,8 @@ exports[`TransactionFunctionCall.vue Should load erc20 abi if function is detect

<div class="ml-4" style="white-space: pre;"><span class="ml-4"><span>address _to: </span> <span>
(<a id="switchFormatted">Display Raw</a> <!---->)
<span class=""><span><span><!----> <a href="/address/0xc00e94Cb662C3520282E6f5717214004A7f26888" class="">0xc00e94Cb...26888</a> <!----> <span>
&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>
<span class=""><span><span><!----> <a href="/address/0xc00e94Cb662C3520282E6f5717214004A7f26888" class="">0xc00e94...6888</a> <!----> <span>
&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>
<!----></span></span></span></span></span>
</div>
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ exports[`TransactionsList.vue Should not display transactions count 1`] = `
<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>
</svg>
<div class="v-progress-circular__info"></div>
</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>
&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>
</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>
&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>
<!----></span>
</td>
<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>
Expand All @@ -218,12 +218,12 @@ exports[`TransactionsList.vue Should not display transactions count 1`] = `
</td>
<td class="text-start">
<!----> <span><!----> <a href="/address/0x0" class="">0x0...0x0</a> <!----> <span>
&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>
&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>
<!----></span>
</td>
<td class="text-start">
<!----> <span><!----> <a href="/address/Ox1" class="">Ox1...Ox1</a> <!----> <span>
&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>
&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>
<!----></span>
</td>
<td class="text-start">
Expand Down
Loading