-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
156 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...es/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/telos/configs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { NetworkNames } from "@enkryptcom/types"; | ||
|
||
const NetworkEndpoints: Record<string, string> = { | ||
[NetworkNames.Telos]: "https://api.teloscan.io/", | ||
}; | ||
|
||
export { NetworkEndpoints }; |
88 changes: 88 additions & 0 deletions
88
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/telos/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import cacheFetch from "@/libs/cache-fetch"; | ||
import { EvmNetwork } from "@/providers/ethereum/types/evm-network"; | ||
import { | ||
Activity, | ||
ActivityStatus, | ||
ActivityType, | ||
EthereumRawInfo, | ||
} from "@/types/activity"; | ||
import { BaseNetwork } from "@/types/base-network"; | ||
import { numberToHex } from "web3-utils"; | ||
import { decodeTx } from "../../../transaction/decoder"; | ||
import { NetworkEndpoints } from "./configs"; | ||
import { TelosTXType } from "./types"; | ||
const TTL = 30000; | ||
const getAddressActivity = async ( | ||
address: string, | ||
endpoint: string | ||
): Promise<EthereumRawInfo[]> => { | ||
return cacheFetch( | ||
{ | ||
url: `${endpoint}v1/address/${address}/transactions`, | ||
}, | ||
TTL | ||
).then((res) => { | ||
if (!res.success) return []; | ||
const results = res.results as TelosTXType[]; | ||
const newResults = results.map((tx) => { | ||
const rawTx: EthereumRawInfo = { | ||
blockHash: "0x", | ||
blockNumber: numberToHex(tx.blockNumber), | ||
contractAddress: tx.contractAddress | ||
? tx.contractAddress.toLowerCase() | ||
: null, | ||
data: tx.input, | ||
effectiveGasPrice: tx.gasPrice, | ||
from: tx.from.toLowerCase(), | ||
to: tx.to === "" ? null : tx.to.toLowerCase(), | ||
gas: tx.gasLimit, | ||
gasUsed: tx.gasused, | ||
nonce: numberToHex(tx.nonce), | ||
status: tx.status === "0x1" ? true : false, | ||
transactionHash: tx.hash, | ||
value: tx.value, | ||
timestamp: tx.timestamp, | ||
}; | ||
return rawTx; | ||
}); | ||
return newResults.slice(0, 50) as EthereumRawInfo[]; | ||
}); | ||
}; | ||
export default async ( | ||
network: BaseNetwork, | ||
address: string | ||
): Promise<Activity[]> => { | ||
address = address.toLowerCase(); | ||
const enpoint = | ||
NetworkEndpoints[network.name as keyof typeof NetworkEndpoints]; | ||
const activities = await getAddressActivity(address, enpoint); | ||
const Promises = activities.map((activity) => { | ||
return decodeTx(activity, network as EvmNetwork).then((txData) => { | ||
return { | ||
from: activity.from, | ||
to: activity.contractAddress | ||
? activity.contractAddress | ||
: txData.tokenTo!, | ||
isIncoming: activity.from !== address, | ||
network: network.name, | ||
rawInfo: activity, | ||
status: activity.status | ||
? ActivityStatus.success | ||
: ActivityStatus.failed, | ||
timestamp: activity.timestamp ? activity.timestamp : 0, | ||
value: txData.tokenValue, | ||
transactionHash: activity.transactionHash, | ||
type: ActivityType.transaction, | ||
nonce: activity.nonce, | ||
token: { | ||
decimals: txData.tokenDecimals, | ||
icon: txData.tokenImage, | ||
name: txData.tokenName, | ||
symbol: txData.tokenSymbol, | ||
price: txData.currentPriceUSD.toString(), | ||
}, | ||
}; | ||
}); | ||
}); | ||
return Promise.all(Promises); | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/telos/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export interface TelosTXType { | ||
gasused: string; | ||
contractAddress: string; | ||
index: number; | ||
nonce: number; | ||
input: string; | ||
gasLimit: string; | ||
blockNumber: number; | ||
from: string; | ||
to: string; | ||
value: string; | ||
hash: string; | ||
timestamp: number; | ||
gasPrice: string; | ||
status: "0x1" | "0x0"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/extension/src/providers/ethereum/networks/tlos.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CoingeckoPlatform, NetworkNames } from "@enkryptcom/types"; | ||
import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network"; | ||
import assetsInfoHandler from "@/providers/ethereum/libs/assets-handlers/assetinfo-mew"; | ||
import { TelosActivity } from "../libs/activity-handlers"; | ||
import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; | ||
|
||
const ethOptions: EvmNetworkOptions = { | ||
name: NetworkNames.Telos, | ||
name_long: "Telos EVM", | ||
homePage: "https://www.telos.net", | ||
blockExplorerTX: "https://www.teloscan.io/tx/[[txHash]]", | ||
blockExplorerAddr: "https://www.teloscan.io/address/[[address]]", | ||
chainID: "0x28", | ||
isTestNetwork: false, | ||
currencyName: "TLOS", | ||
currencyNameLong: "Telos", | ||
node: "wss://telos.drpc.org", | ||
icon: require("./icons/telos.svg"), | ||
coingeckoID: "telos", | ||
coingeckoPlatform: CoingeckoPlatform.Telos, | ||
assetsInfoHandler, | ||
activityHandler: wrapActivityHandler(TelosActivity), | ||
}; | ||
|
||
const eth = new EvmNetwork(ethOptions); | ||
|
||
export default eth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9896d91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Virus total analysis
chrome:
https://www.virustotal.com/gui/file/dda4dfb85fe51ef9e014d253071f1dbf59c86258b1f6302f7d8b10b4659dd953
firefox:
https://www.virustotal.com/gui/file/6927f84864f944f5f7c24aa4e731de71ff8564ac59b6cd7d6b988ff06fd77123