Skip to content

Commit

Permalink
pull develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Viterbo committed Nov 29, 2023
2 parents 0dbf5f4 + 31c68d3 commit 81ee7be
Show file tree
Hide file tree
Showing 19 changed files with 322 additions and 127 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telos-web-wallet",
"version": "2.3.2",
"version": "2.3.3",
"description": "A Web Wallet for Telos",
"productName": "Telos Web Wallet",
"private": true,
Expand Down
28 changes: 24 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<script lang="ts">
import { useChainStore } from 'src/antelope';
import { getAntelope, useChainStore } from 'src/antelope';
import { ComplexMessage } from 'src/antelope/config';
import EVMChainSettings from 'src/antelope/chains/EVMChainSettings';
import { TELOS_CHAIN_IDS } from 'src/antelope/chains/chain-constants';
import packageInfo from '../package.json';
import { defineComponent } from 'vue';
export default {
export const isTodayBeforeTelosCloudDown = new Date().getTime() < new Date('2023-12-31').getTime();
export default defineComponent({
name: 'App',
created() {
const appVersionJustUpdated = 'UPDATED_NOTIFY_USER';
Expand Down Expand Up @@ -42,7 +46,6 @@ export default {
},
mounted() {
const chainSettings = useChainStore().currentChain.settings as EVMChainSettings;
// if the organization using this application is Telos, import Fathom analytics
if (TELOS_CHAIN_IDS.includes(chainSettings.getChainId())) {
const script = document.createElement('script');
Expand All @@ -52,8 +55,25 @@ export default {
script.defer = true;
document.body.appendChild(script);
}
if (isTodayBeforeTelosCloudDown) {
getAntelope().config.notifyRememberInfoHandler(
this.$t('temporal.telos_cloud_discontinued_title'),
[{
tag: 'p',
class: 'c-notify__message--subtitle',
text: this.$t('temporal.telos_cloud_discontinued_message_title'),
}, {
tag: 'p',
class: '',
text: this.$t('temporal.telos_cloud_discontinued_message_body'),
}],
'',
'telos-cloud-discontinued',
);
}
},
};
});
</script>

<template>
Expand Down
7 changes: 6 additions & 1 deletion src/antelope/chains/EVMChainSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export default abstract class EVMChainSettings implements ChainSettings {

async updateIndexerHealthState() {
// resolve if this chain has indexer api support and is working fine

const promise =
Promise.resolve(this.hasIndexerSupport())
.then(hasIndexerSupport =>
Expand Down Expand Up @@ -371,6 +370,12 @@ export default abstract class EVMChainSettings implements ChainSettings {
supply: nftResponse.supply,
}));

// we fix the supportedInterfaces property if it is undefined in the response but present in the request
Object.values(response.contracts).forEach((contract) => {
contract.supportedInterfaces = contract.supportedInterfaces ||
params.type ? [params.type?.toLowerCase() as string] : undefined;
});

this.processNftContractsCalldata(response.contracts);
const shapedNftData = this.shapeNftRawData(shapedIndexerNftData, response.contracts);
return this.processNftRawData(shapedNftData);
Expand Down
71 changes: 66 additions & 5 deletions src/antelope/stores/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,16 @@ export const useContractStore = defineStore(store_name, {
return resolve(this.createAndStoreVerifiedContract(label, addressLower, metadata, creationInfo, suspectedToken));
}

const contract = await this.createAndStoreContractFromTokenList(label, address, suspectedToken, creationInfo);
if (contract) {
this.trace('fetchContractUsingHyperion', 'returning contract from token list', address, contract);
return resolve(contract);
const tokenContract = await this.createAndStoreContractFromTokenList(label, address, suspectedToken, creationInfo);
if (tokenContract) {
this.trace('fetchContractUsingHyperion', 'returning contract from token list', address, tokenContract);
return resolve(tokenContract);
}

const suspectedTokenContract = await this.createAndStoreContractFromSuspectedType(label, address, suspectedToken, creationInfo);
if (suspectedTokenContract) {
this.trace('fetchContractUsingHyperion', 'returning contract from suspected type', address, suspectedTokenContract);
return resolve(suspectedTokenContract);
}

if (creationInfo) {
Expand Down Expand Up @@ -393,6 +399,16 @@ export const useContractStore = defineStore(store_name, {
},

// utility functions ---------------------
/**
* This function creates a verified contract based on its metadata and creation info,
* which was used to verify this contract previously.
* @param label identifies the chain
* @param address address of the contract
* @param metadata verified metadata of the contract
* @param creationInfo creation info of the contract
* @param suspectedType type of the contract. It can be 'erc20', 'erc721' or 'erc1155'
* @returns the contract
*/
async createAndStoreVerifiedContract(
label: string,
address:string,
Expand All @@ -413,6 +429,13 @@ export const useContractStore = defineStore(store_name, {
} as EvmContractFactoryData);
},

/**
* This function creates an empty contract based on its creation info.
* @param label identifies the chain
* @param address address of the contract
* @param creationInfo creation info of the contract
* @returns the contract
*/
async createAndStoreEmptyContract(
label: string,
address:string,
Expand All @@ -423,10 +446,19 @@ export const useContractStore = defineStore(store_name, {
name: `0x${address.slice(0, 16)}...`,
address,
creationInfo,
supportedInterfaces: [],
supportedInterfaces: undefined,
} as EvmContractFactoryData);
},

/**
* This function tries to create a contract based on the known token list.
* If the address is not in the list, it will return null.
* @param label identifies the chain
* @param address address of the contract
* @param suspectedType type of the contract. It can be 'erc20', 'erc721' or 'erc1155'
* @param creationInfo creation info of the contract
* @returns the contract or null if the address is not in the token list
*/
async createAndStoreContractFromTokenList(
label:string,
address:string,
Expand All @@ -449,6 +481,35 @@ export const useContractStore = defineStore(store_name, {
}
},

/**
* This function tries to create a contract from a suspected type (using the corresponding known ABI).
* It will return null if the type is not supported.
* @param label identifies the chain
* @param address address of the contract
* @param suspectedType type of the contract. It can be 'erc20', 'erc721' or 'erc1155'
* @param creationInfo creation info of the contract
* @returns the contract or null if the type is not supported
*/
async createAndStoreContractFromSuspectedType(
label:string,
address:string,
suspectedType:string,
creationInfo:EvmContractCreationInfo | null,
): Promise<EvmContract | null> {
const abi = this.getTokenABI(suspectedType);
if (abi) {
return this.createAndStoreContract(label, address, {
name: `0x${address.slice(0, 16)}...`,
address,
creationInfo,
abi,
supportedInterfaces: [suspectedType],
} as EvmContractFactoryData);
} else {
return null;
}
},

// commits -----
createAndStoreContract(label: string, address: string, metadata: EvmContractFactoryData): EvmContract {
const network = useChainStore().getChain(label).settings.getNetwork();
Expand Down
1 change: 1 addition & 0 deletions src/antelope/stores/nfts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export const useNftsStore = defineStore(store_name, {
const new_filter = {
...toRaw(this.__pagination_filter),
tokenId,
type,
};

// If we already have a contract for that network and contract, we search for the NFT in that list first
Expand Down
6 changes: 4 additions & 2 deletions src/antelope/stores/utils/nft-utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IndexerNftMetadata, NFTSourceTypes, NftSourceType } from 'src/antelope/types';
import { urlIsAudio, urlIsPicture, urlIsVideo } from 'src/antelope/stores/utils/media-utils';

export const IPFS_GATEWAY = 'https://cloudflare-ipfs.com/ipfs/';
export const IPFS_GATEWAY = 'https://ipfs.telos.net/ipfs/';

/**
* Given an imageCache URL, tokenUri, and metadata, extract the image URL, mediaType, and mediaSource
Expand Down Expand Up @@ -109,7 +109,9 @@ export async function extractNftMetadata(
}
}

if (metadata?.image?.includes(IPFS_GATEWAY)) {
const metadataImageIsMediaUrl = await urlIsVideo(metadata?.image ?? '') || await urlIsAudio(metadata?.image ?? '') || urlIsPicture(metadata?.image ?? '');

if (metadata?.image?.includes(IPFS_GATEWAY) && !metadataImageIsMediaUrl) {
mediaType = await determineIpfsMediaType(metadata?.image);

if (mediaType === NFTSourceTypes.IMAGE) {
Expand Down
1 change: 1 addition & 0 deletions src/antelope/types/Filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ export interface IndexerCollectionNftsFilter extends IndexerPaginationFilter {
includeAbi?: boolean; // indicate whether to include abi
tokenId?: string; // only query results for a specific token ID
includeTokenIdSupply?: boolean;
type?: NftTokenInterface;
}
5 changes: 3 additions & 2 deletions src/antelope/wallets/authenticators/WalletConnectAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ export class WalletConnectAuth extends EVMAuthenticator {
if (typeof provider === 'undefined') {
this.usingQR = true;
} else {
const providerAddress = (provider._state?.accounts) ? provider._state?.accounts[0] : '';
const providerAddress = (provider._state?.accounts) ? provider._state?.accounts[0]??'' : '';
this.trace('walletConnectLogin', 'providerAddress:', providerAddress, 'address:', address);
const sameAddress = providerAddress.toLocaleLowerCase() === address.toLocaleLowerCase();
this.usingQR = !sameAddress;
this.trace('walletConnectLogin', 'providerAddress:', providerAddress, 'address:', address, 'sameAddress:', sameAddress);
this.trace('walletConnectLogin', 'sameAddress:', sameAddress);
}
this.trace('walletConnectLogin', 'using QR:', this.usingQR);

Expand Down
33 changes: 33 additions & 0 deletions src/assets/evm/brave_lion.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icon--arrow-diagonal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/assets/icon--info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 81ee7be

Please sign in to comment.