-
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.
Merge pull request #269 from enkryptcom/develop
Release: v1.16.0
- Loading branch information
Showing
183 changed files
with
5,720 additions
and
2,931 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { | ||
CoinGeckoToken, | ||
CoinGeckoTokenMarket, | ||
CoingeckPlatforms, | ||
} from "./types"; | ||
|
||
interface getCoinGeckoTokenInfoAllType { | ||
data: { | ||
getCoinGeckoTokenInfoAll: { | ||
id: string; | ||
symbol: string; | ||
name: string; | ||
platforms: { | ||
platform: string; | ||
address: string; | ||
}[]; | ||
}[]; | ||
}; | ||
} | ||
const ETHVM_BASE = `https://api-v2.ethvm.dev/`; | ||
|
||
const ethvmPost = (requestData: string): Promise<any> => { | ||
return fetch(ETHVM_BASE, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: requestData, | ||
}).then((res) => res.json()); | ||
}; | ||
|
||
export const getAllPlatformData = (): Promise<CoinGeckoToken[]> => { | ||
return ethvmPost( | ||
'{"operationName":null,"variables":{},"query":"{\\n getCoinGeckoTokenInfoAll {\\n id\\n symbol\\n name\\n platforms {\\n platform\\n address\\n }\\n }\\n}\\n"}' | ||
).then((json: getCoinGeckoTokenInfoAllType) => { | ||
const retResponse: CoinGeckoToken[] = []; | ||
json.data.getCoinGeckoTokenInfoAll.forEach((item) => { | ||
const { id, name, symbol, platforms } = item; | ||
const cgPlatforms: CoingeckPlatforms = {}; | ||
platforms.forEach((p) => { | ||
cgPlatforms[p.platform] = p.address; | ||
}); | ||
const token: CoinGeckoToken = { | ||
id, | ||
name, | ||
symbol, | ||
platforms: cgPlatforms, | ||
}; | ||
retResponse.push(token); | ||
}); | ||
return retResponse; | ||
}); | ||
}; | ||
|
||
export const getUSDPriceById = (id: string): Promise<string | null> => { | ||
return ethvmPost( | ||
'{"operationName":null,"variables":{},"query":"{\\n getCoinGeckoTokenMarketDataByIds(coinGeckoTokenIds: [\\"' + | ||
id + | ||
'\\"]) {\\n current_price\\n }\\n}\\n"}' | ||
) | ||
.then((json) => { | ||
return json.data.getCoinGeckoTokenMarketDataByIds[0] | ||
? json.data.getCoinGeckoTokenMarketDataByIds[0].current_price.toString() | ||
: null; | ||
}) | ||
.catch(() => null); | ||
}; | ||
|
||
export const getMarketInfoByIDs = ( | ||
ids: string[] | ||
): Promise<Array<CoinGeckoTokenMarket | null>> => { | ||
const params = ids.map((i) => '\\"' + i + '\\"').join(", "); | ||
return ethvmPost( | ||
'{"operationName":null,"variables":{},"query":"{\\n getCoinGeckoTokenMarketDataByIds(coinGeckoTokenIds: [' + | ||
params + | ||
']) {\\n id\\n symbol\\n name\\n image\\n market_cap\\n market_cap_rank\\n high_24h\\n low_24h\\n price_change_24h\\n price_change_percentage_24h\\n sparkline_in_7d {\\n price\\n }\\n price_change_percentage_7d_in_currency\\n current_price\\n }\\n}\\n"}' | ||
).then((json) => { | ||
return json.data.getCoinGeckoTokenMarketDataByIds as CoinGeckoTokenMarket[]; | ||
}); | ||
}; |
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
22 changes: 22 additions & 0 deletions
22
packages/extension/src/providers/bitcoin/libs/btc-fee-handler.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,22 @@ | ||
import { GasPriceTypes } from "@/providers/common/types"; | ||
|
||
const BTCFeeHandler = async (): Promise<Record<GasPriceTypes, number>> => { | ||
return fetch(`https://bitcoiner.live/api/fees/estimates/latest`) | ||
.then((res) => res.json()) | ||
.then((json) => { | ||
return { | ||
[GasPriceTypes.FASTEST]: Math.ceil(json.estimates["30"].sat_per_vbyte), | ||
[GasPriceTypes.FAST]: Math.ceil(json.estimates["60"].sat_per_vbyte), | ||
[GasPriceTypes.REGULAR]: Math.ceil(json.estimates["120"].sat_per_vbyte), | ||
[GasPriceTypes.ECONOMY]: Math.ceil(json.estimates["180"].sat_per_vbyte), | ||
}; | ||
}) | ||
.catch(() => ({ | ||
[GasPriceTypes.FASTEST]: 25, | ||
[GasPriceTypes.FAST]: 20, | ||
[GasPriceTypes.REGULAR]: 10, | ||
[GasPriceTypes.ECONOMY]: 5, | ||
})); | ||
}; | ||
|
||
export default BTCFeeHandler; |
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
Oops, something went wrong.
af22390
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/cd62991cc8901b8e5a0d74373e1df00131153b3a97c17553cdab7cb108b53543
firefox:
https://www.virustotal.com/gui/file/b2e8e32511fea193ea01571292400cdfb6822a38895fc669a481cfcd146b5aad
af22390
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/f6123193d11e3b3e9e1cbfa6551a1870a755464d941d21092124a72f3221c258
firefox:
https://www.virustotal.com/gui/file/ce719896b5038ab878548975ac813631c82b230d3c2a61f06239c7a2f64ff643