Skip to content

Commit

Permalink
Update @nimiq/utils and @nimiq/vue-components for switch to CryptoCom…
Browse files Browse the repository at this point in the history
…pare

CoinGecko is becoming increasingly strict with unauthenticated access to their
API without API key. For example, wallet.nimiq.com has already been blocked from
unauthenticated access, thus the Wallet has been switched to CryptoCompare as
fiat api provider, while hub.nimiq.com and keyguard.nimiq.com are not currently
blocked, i.e. in the hub, we wouldn't have to switch yet, but for consistent
exchange rates with the Wallet, we already switch now.
  • Loading branch information
danimoh committed Jul 7, 2024
1 parent bdc2096 commit a70af6a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@nimiq/oasis-api": "^1.1.1",
"@nimiq/rpc": "^0.4.1",
"@nimiq/style": "^0.8.2",
"@nimiq/utils": "^0.5.2",
"@nimiq/utils": "^0.11.1",
"@nimiq/vue-components": "https://github.com/nimiq/vue-components#build/hub",
"@opengsn/common": "^2.2.5",
"@sentry/vue": "^6.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/CheckoutCardEthereum.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { createEthereumRequestLink } from '@nimiq/utils';
import { Currency, createEthereumRequestLink } from '@nimiq/utils';
import { ParsedEtherDirectPaymentOptions } from '../lib/paymentOptions/EtherPaymentOptions';
import CheckoutCardExternal from './CheckoutCardExternal.vue';
import { FormattableNumber } from '@nimiq/utils';
Expand All @@ -13,7 +13,7 @@ export default class CheckoutCardEthereum
const paymentOptions = this.paymentOptions;
const protocolSpecific = paymentOptions.protocolSpecific;
if (!protocolSpecific.recipient) return '#';
return createEthereumRequestLink(protocolSpecific.recipient, {
return createEthereumRequestLink(protocolSpecific.recipient, Currency.ETH, {
amount: paymentOptions.amount,
gasLimit: protocolSpecific.gasLimit,
gasPrice: protocolSpecific.gasPrice,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/RequestTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ParsedNimiqSpecifics, ParsedNimiqDirectPaymentOptions } from './pa
import type { ParsedEtherSpecifics, ParsedEtherDirectPaymentOptions } from './paymentOptions/EtherPaymentOptions';
import type { ParsedBitcoinSpecifics, ParsedBitcoinDirectPaymentOptions } from './paymentOptions/BitcoinPaymentOptions';
import type { SwapAsset } from '@nimiq/fastspot-api';
import type { FiatApiSupportedFiatCurrency } from '@nimiq/utils';
import type { FiatCurrency } from '@nimiq/utils';

export interface ParsedBasicRequest {
kind: RequestType;
Expand Down Expand Up @@ -104,7 +104,7 @@ export interface ParsedCreateCashlinkRequest extends ParsedBasicRequest {
value?: number;
message?: string;
theme: CashlinkTheme;
fiatCurrency?: FiatApiSupportedFiatCurrency;
fiatCurrency?: FiatCurrency;
returnLink: boolean;
skipSharing: boolean;
}
Expand Down
13 changes: 9 additions & 4 deletions src/views/CashlinkCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ import {
SmallPage,
Tooltip,
} from '@nimiq/vue-components';
import { FiatApiSupportedCryptoCurrency, getExchangeRates, setCoingeckoApiUrl } from '@nimiq/utils';
import { CryptoCurrency, Provider, getExchangeRates } from '@nimiq/utils';
@Component({components: {
Account,
Expand Down Expand Up @@ -172,6 +172,8 @@ class CashlinkCreate extends Vue {
private static readonly TRANSACTION_SIZE = 171; // 166 + 5 bytes extraData for funding a cashlink
private static readonly FIAT_API_PROVIDER = Provider.CryptoCompare;
public $refs!: {
createCashlinkTooltipTarget: PageBody,
amountWithFee: AmountWithFee,
Expand Down Expand Up @@ -286,10 +288,13 @@ class CashlinkCreate extends Vue {
if (this.request.fiatCurrency) {
const fiatCurrency = this.request.fiatCurrency;
setCoingeckoApiUrl('https://nq-coingecko-proxy.deno.dev/api/v3');
const refreshFiatRate = () => {
getExchangeRates([FiatApiSupportedCryptoCurrency.NIM], [fiatCurrency]).then((prices) => {
this.fiatRate = prices[FiatApiSupportedCryptoCurrency.NIM][fiatCurrency] || null;
getExchangeRates(
[CryptoCurrency.NIM],
[fiatCurrency],
CashlinkCreate.FIAT_API_PROVIDER,
).then((prices) => {
this.fiatRate = prices[CryptoCurrency.NIM][fiatCurrency] || null;
}).catch((error) => {
this.$captureException!(error);
console.error(error);
Expand Down
2 changes: 1 addition & 1 deletion vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ module.exports = {
// Add dependencies here which should be transpiled by babel-loader via @vue/cli-plugin-babel. This is needed as our
// Webpack version is too old to process some modern js syntax in the listed dependencies.
// When changing to Webpack 5, some or all can probably be removed.
transpileDependencies: [],
transpileDependencies: ['@nimiq/utils'],

// For iOS debugging in BrowserStack, BrowserStack's localhost tunnel bs-local.com needs to be used, see
// https://www.browserstack.com/docs/live/local-testing/ios-troubleshooting-guide. However, on bs-local.com features
Expand Down
31 changes: 12 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2101,27 +2101,20 @@
resolved "https://registry.yarnpkg.com/@nimiq/style/-/style-0.8.5.tgz#36a8bd8f58d55ee3e8ea5b249e51a116638e3b90"
integrity sha512-il2+hrodQ7iL4ARPwfGmGvrEYgtMHAoQSbcyapxEQEG7vDYj5r+ssuhKB+oYmdRUxA1/HvyGDnWG3XenKvQyIA==

"@nimiq/utils@^0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@nimiq/utils/-/utils-0.5.2.tgz#4d5a6195e2f051a8a56b11a75ea3c38667a86e04"
integrity sha512-9VRttvkL1nilCxJIaRQH8uoIX3UqbUp+NiQJFVYnaBgu4In6YOP02LcIhUHUnv5v85avVQdhygJTUnKxp5IRmQ==
dependencies:
big-integer "^1.6.44"

"@nimiq/utils@^0.9.1":
version "0.9.1"
resolved "https://registry.yarnpkg.com/@nimiq/utils/-/utils-0.9.1.tgz#74b59394b1bbda9fb17efa4affd0edb555f3514e"
integrity sha512-YuN2mHefo8law/W4F4I2pAZ+kf5vKnI345ExmAP0Hfefu2Y0fPEoULewEelDwvl9YXxmT+vHKCVH0DHK4508dw==
"@nimiq/utils@^0.11.1":
version "0.11.1"
resolved "https://registry.yarnpkg.com/@nimiq/utils/-/utils-0.11.1.tgz#fe9c61fdead9b8e25a892a539b2b870cdd9cc51c"
integrity sha512-jwRInTkMPzyPsQN3iyf8s82mO/ChnbVtj5IzqXj9EO0PSOPd4Ix2ApIN/3NClfDfWo6HzE6NkSZOgry18p4jow==
dependencies:
big-integer "^1.6.44"

"@nimiq/vue-components@https://github.com/nimiq/vue-components#build/hub":
version "0.1.0"
resolved "https://github.com/nimiq/vue-components#8199bd47a55303a89b4ccfc55f3bee75bd5fe76a"
resolved "https://github.com/nimiq/vue-components#a6eb8059ec52f92751b0cf9d14393db94bea7497"
dependencies:
"@nimiq/iqons" "^1.6.0"
"@nimiq/style" "^0.8.5"
"@nimiq/utils" "^0.9.1"
"@nimiq/utils" "^0.11.1"
big-integer "^1.6.44"
input-format "^0.2.8"
js-sha3 "^0.8.0"
Expand Down Expand Up @@ -2533,9 +2526,9 @@
integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==

"@types/offscreencanvas@^2019.6.4":
version "2019.7.0"
resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d"
integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg==
version "2019.7.3"
resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz#90267db13f64d6e9ccb5ae3eac92786a7c77a516"
integrity sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==

"@types/parse-json@^4.0.0":
version "4.0.2"
Expand Down Expand Up @@ -3867,9 +3860,9 @@ bfj@^6.1.1:
tryer "^1.0.0"

big-integer@^1.6.44, big-integer@^1.6.48:
version "1.6.51"
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686"
integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==
version "1.6.52"
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.52.tgz#60a887f3047614a8e1bffe5d7173490a97dc8c85"
integrity sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==

big.js@^3.1.3:
version "3.2.0"
Expand Down

0 comments on commit a70af6a

Please sign in to comment.