-
Notifications
You must be signed in to change notification settings - Fork 174
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
42 changed files
with
1,966 additions
and
1,481 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
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
10 changes: 6 additions & 4 deletions
10
packages/extension/src/providers/common/libs/new-features.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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { NetworkNames } from "@enkryptcom/types"; | ||
|
||
const newNetworks = [ | ||
NetworkNames.Kadena, | ||
NetworkNames.Rollux, | ||
NetworkNames.Syscoin, | ||
NetworkNames.Telos, | ||
NetworkNames.Blast, | ||
NetworkNames.Sanko, | ||
NetworkNames.Degen, | ||
NetworkNames.Ham, | ||
]; | ||
const newSwaps = [NetworkNames.MaticZK, NetworkNames.Base]; | ||
const newSwaps: NetworkNames[] = []; | ||
|
||
export { newNetworks, newSwaps }; |
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
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
Oops, something went wrong.