diff options
author | Sebastian <sebasjm@gmail.com> | 2021-06-30 18:24:08 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2021-06-30 18:24:08 -0300 |
commit | 23dab91ee9e2ffcac381cc27183716b6881e0a88 (patch) | |
tree | 0d809cd5183c1712fd27e4ac42276ff58b3a84ae /packages/taler-wallet-webextension/src/hooks/useProvidersByCurrency.ts | |
parent | 05e89a3cf7bc2e04ecb88be87ab5c14bb66d71e7 (diff) | |
download | wallet-core-23dab91ee9e2ffcac381cc27183716b6881e0a88.tar.xz |
first backup list prototype
Diffstat (limited to 'packages/taler-wallet-webextension/src/hooks/useProvidersByCurrency.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/hooks/useProvidersByCurrency.ts | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/packages/taler-wallet-webextension/src/hooks/useProvidersByCurrency.ts b/packages/taler-wallet-webextension/src/hooks/useProvidersByCurrency.ts new file mode 100644 index 000000000..9b600ee2b --- /dev/null +++ b/packages/taler-wallet-webextension/src/hooks/useProvidersByCurrency.ts @@ -0,0 +1,88 @@ +import { Amounts } from "@gnu-taler/taler-util"; +// import { ProviderInfo } from "@gnu-taler/taler-wallet-core/src/operations/backup/index.js"; + + +export interface ProvidersByCurrency { + [s:string] : any | undefined +} + +const list = { + "trustedAuditors": [], + "trustedExchanges": [ + { + "currency": "ARS", + "exchangeBaseUrl": "http://exchange.taler:8081/", + "exchangeMasterPub": "WHA6G542TW8B10N3E857M3P252HV7B896TSP1HP6NREG96ADA4MG" + }, + { + "currency": "KUDOS", + "exchangeBaseUrl": "https://exchange.demo.taler.net/", + "exchangeMasterPub": "FH1Y8ZMHCTPQ0YFSZECDH8C9407JR3YN0MF1706PTG24Q4NEWGV0" + }, + { + "currency": "USD", + "exchangeBaseUrl": "https://exchange.demo.taler.net/", + "exchangeMasterPub": "FH1Y8ZMHCTPQ0YFSZECDH8C9407JR3YN0MF1706PTG24Q4NEWGV0" + }, + { + "currency": "EUR", + "exchangeBaseUrl": "https://exchange.demo.taler.net/", + "exchangeMasterPub": "FH1Y8ZMHCTPQ0YFSZECDH8C9407JR3YN0MF1706PTG24Q4NEWGV0" + } + ] +} + +const status = { + "deviceId": "thenameofthisdevice", + "walletRootPub": "83DYRKK262TG72H1SD09CTWXQFC151P2DXF9WYH30J8EQ7EAZMCG", + "providers": [ + { + "active": false, + "syncProviderBaseUrl": "http://sync.demo.taler.net/", + "paymentProposalIds": [], + "paymentStatus": { + "type": "unpaid" + }, + "terms": { + "annualFee": "KUDOS:0.1", + "storageLimitInMegabytes": 16, + "supportedProtocolVersion": "0.0" + } + }, { + "active": true, + "syncProviderBaseUrl": "http://sync.taler:9967/", + "lastSuccessfulBackupTimestamp": { + "t_ms": 1625063925078 + }, + "paymentProposalIds": [ + "43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG" + ], + "paymentStatus": { + "type": "paid", + "paidUntil": { + "t_ms": 1656599921000 + } + }, + "terms": { + "annualFee": "ARS:1", + "storageLimitInMegabytes": 16, + "supportedProtocolVersion": "0.0" + } + } + + ] +} + +export function useProvidersByCurrency(): ProvidersByCurrency { + const currencies = list.trustedExchanges.map(e => e.currency) + const providerByCurrency = status.providers.reduce((p, c) => { + if (c.terms) { + p[Amounts.parseOrThrow(c.terms.annualFee).currency] = c + } + return p + }, {} as Record<string, any | undefined>) + + + return providerByCurrency +} + |