@bitpay-labs/bitcore-wallet-service 11.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.coveralls.yml +1 -0
- package/.travis.yml +27 -0
- package/DKG-flow.png +0 -0
- package/DSG-flow.png +0 -0
- package/Dockerfile +18 -0
- package/Installation.md +138 -0
- package/LICENCE +22 -0
- package/Makefile +5 -0
- package/README.md +429 -0
- package/TSS.md +136 -0
- package/bws.example.config.js +451 -0
- package/package.json +119 -0
- package/scripts/checkCopayerIds.js +118 -0
- package/scripts/clean_db.mongodb +5 -0
- package/scripts/deleteDupAddresses.mongo +6 -0
- package/scripts/deleteWallet.mongo +18 -0
- package/scripts/delme.ts +468 -0
- package/scripts/findEmail.js +32 -0
- package/scripts/fixAddressType.js +98 -0
- package/scripts/getSolStats2.js +81 -0
- package/scripts/migrateToNamedTestnets.js +191 -0
- package/scripts/migrateWalletsNetwork.js +204 -0
- package/scripts/preview-email.js +359 -0
- package/scripts/purgeNotifications.js +107 -0
- package/scripts/resetV8registration.mongo +21 -0
- package/scripts/v8tool-list.ts +93 -0
- package/scripts/v8tool.ts +82 -0
- package/scripts/walletStats.js +290 -0
- package/src/app.ts +28 -0
- package/src/bcmonitor/bcmonitor.ts +11 -0
- package/src/bws.ts +85 -0
- package/src/cleanfiatrates/cleanfiatrates.ts +9 -0
- package/src/config.ts +540 -0
- package/src/db/.empty +0 -0
- package/src/deprecated-serverMessages.ts +15 -0
- package/src/emailservice/emailservice.ts +11 -0
- package/src/externalservices/banxa.ts +261 -0
- package/src/externalservices/changelly.ts +371 -0
- package/src/externalservices/coingecko.ts +453 -0
- package/src/externalservices/moonpay.ts +435 -0
- package/src/externalservices/oneInch.ts +169 -0
- package/src/externalservices/ramp.ts +259 -0
- package/src/externalservices/sardine.ts +237 -0
- package/src/externalservices/simplex.ts +281 -0
- package/src/externalservices/thorswap.ts +197 -0
- package/src/externalservices/transak.ts +320 -0
- package/src/externalservices/wyre.ts +131 -0
- package/src/fiatrateservice/fiatrateservice.ts +15 -0
- package/src/index.ts +9 -0
- package/src/lib/bchaddresstranslator.ts +59 -0
- package/src/lib/blockchainexplorer.ts +84 -0
- package/src/lib/blockchainexplorers/v8/client.ts +177 -0
- package/src/lib/blockchainexplorers/v8.ts +730 -0
- package/src/lib/blockchainmonitor.ts +423 -0
- package/src/lib/chain/arb/index.ts +8 -0
- package/src/lib/chain/base/index.ts +8 -0
- package/src/lib/chain/bch/index.ts +40 -0
- package/src/lib/chain/btc/index.ts +991 -0
- package/src/lib/chain/doge/index.ts +387 -0
- package/src/lib/chain/eth/abi-erc20.ts +222 -0
- package/src/lib/chain/eth/abi-invoice.ts +277 -0
- package/src/lib/chain/eth/index.ts +657 -0
- package/src/lib/chain/index.ts +178 -0
- package/src/lib/chain/ltc/index.ts +9 -0
- package/src/lib/chain/matic/index.ts +8 -0
- package/src/lib/chain/op/index.ts +8 -0
- package/src/lib/chain/sol/index.ts +349 -0
- package/src/lib/chain/xrp/index.ts +338 -0
- package/src/lib/cleanfiatrates.ts +160 -0
- package/src/lib/common/constants.ts +231 -0
- package/src/lib/common/defaults.ts +436 -0
- package/src/lib/common/index.ts +11 -0
- package/src/lib/common/services.ts +43 -0
- package/src/lib/common/utils.ts +506 -0
- package/src/lib/emailservice.ts +741 -0
- package/src/lib/errors/clienterror.ts +44 -0
- package/src/lib/errors/errordefinitions.ts +158 -0
- package/src/lib/expressapp.ts +2415 -0
- package/src/lib/fiatrateproviders/bitpay.ts +20 -0
- package/src/lib/fiatrateproviders/bitstamp.ts +16 -0
- package/src/lib/fiatrateproviders/index.ts +8 -0
- package/src/lib/fiatrateproviders/provider.d.ts +10 -0
- package/src/lib/fiatrateservice.ts +338 -0
- package/src/lib/iconsconfig.ts +31 -0
- package/src/lib/index.ts +0 -0
- package/src/lib/lock.ts +112 -0
- package/src/lib/logger.ts +77 -0
- package/src/lib/messagebroker.ts +42 -0
- package/src/lib/model/address.ts +226 -0
- package/src/lib/model/addressmanager.ts +138 -0
- package/src/lib/model/advertisement.ts +84 -0
- package/src/lib/model/copayer.ts +162 -0
- package/src/lib/model/email.ts +103 -0
- package/src/lib/model/index.ts +12 -0
- package/src/lib/model/notification.ts +77 -0
- package/src/lib/model/preferences.ts +79 -0
- package/src/lib/model/pushnotificationsub.ts +50 -0
- package/src/lib/model/session.ts +65 -0
- package/src/lib/model/tsskeygen.ts +154 -0
- package/src/lib/model/tsssign.ts +136 -0
- package/src/lib/model/txconfirmationsub.ts +50 -0
- package/src/lib/model/txnote.ts +60 -0
- package/src/lib/model/txproposal.ts +561 -0
- package/src/lib/model/txproposal_legacy.ts +236 -0
- package/src/lib/model/txproposalaction.ts +48 -0
- package/src/lib/model/wallet.ts +359 -0
- package/src/lib/notificationbroadcaster.ts +17 -0
- package/src/lib/pushnotificationsservice.ts +802 -0
- package/src/lib/routes/helpers/error.ts +51 -0
- package/src/lib/routes/helpers/index.ts +1 -0
- package/src/lib/routes/middleware/authRequest.ts +117 -0
- package/src/lib/routes/middleware/authTssRequest.ts +66 -0
- package/src/lib/routes/middleware/createWalletLimiter.ts +21 -0
- package/src/lib/routes/middleware/log.ts +63 -0
- package/src/lib/routes/middleware/verifyTssMessage.ts +37 -0
- package/src/lib/routes/tss.ts +123 -0
- package/src/lib/server.ts +5342 -0
- package/src/lib/stats.ts +174 -0
- package/src/lib/storage.ts +1919 -0
- package/src/lib/tss.ts +446 -0
- package/src/lib/updatestats.ts +291 -0
- package/src/messagebroker/messagebroker.ts +18 -0
- package/src/pushnotificationsservice/pushnotificationsservice.ts +11 -0
- package/src/serverMessages.ts +30 -0
- package/src/types/chain.d.ts +62 -0
- package/src/types/emailservice.d.ts +11 -0
- package/src/types/expressapp.d.ts +15 -0
- package/src/types/externalservices.d.ts +41 -0
- package/src/types/notifications.d.ts +8 -0
- package/src/types/pushnotificationservice.d.ts +51 -0
- package/src/types/server.d.ts +24 -0
- package/src/updatestats/updatestats.ts +10 -0
- package/start-docker.sh +18 -0
- package/start.sh +38 -0
- package/static/images/down-arrow-green.png +0 -0
- package/static/images/failed-icon.png +0 -0
- package/static/images/green-check.png +0 -0
- package/static/images/person-plus.png +0 -0
- package/static/images/up-arrow-gray.png +0 -0
- package/static/images/writing-gray.png +0 -0
- package/stop.sh +19 -0
- package/templates/en/new_copayer.html +13 -0
- package/templates/en/new_copayer.plain +2 -0
- package/templates/en/new_incoming_tx.html +11 -0
- package/templates/en/new_incoming_tx.plain +2 -0
- package/templates/en/new_incoming_tx_testnet.html +13 -0
- package/templates/en/new_incoming_tx_testnet.plain +2 -0
- package/templates/en/new_outgoing_tx.html +11 -0
- package/templates/en/new_outgoing_tx.plain +2 -0
- package/templates/en/new_tx_proposal.html +13 -0
- package/templates/en/new_tx_proposal.plain +2 -0
- package/templates/en/new_zero_outgoing_tx.html +13 -0
- package/templates/en/new_zero_outgoing_tx.plain +2 -0
- package/templates/en/tx_confirmation.html +13 -0
- package/templates/en/tx_confirmation.plain +2 -0
- package/templates/en/tx_confirmation_receiver.html +13 -0
- package/templates/en/tx_confirmation_receiver.plain +2 -0
- package/templates/en/tx_confirmation_sender.html +13 -0
- package/templates/en/tx_confirmation_sender.plain +2 -0
- package/templates/en/txp_finally_rejected.html +13 -0
- package/templates/en/txp_finally_rejected.plain +2 -0
- package/templates/en/wallet_complete.html +13 -0
- package/templates/en/wallet_complete.plain +2 -0
- package/templates/es/new_copayer.html +13 -0
- package/templates/es/new_copayer.plain +2 -0
- package/templates/es/new_incoming_tx.html +11 -0
- package/templates/es/new_incoming_tx.plain +2 -0
- package/templates/es/new_incoming_tx_testnet.html +13 -0
- package/templates/es/new_incoming_tx_testnet.plain +2 -0
- package/templates/es/new_outgoing_tx.html +11 -0
- package/templates/es/new_outgoing_tx.plain +2 -0
- package/templates/es/new_tx_proposal.html +13 -0
- package/templates/es/new_tx_proposal.plain +2 -0
- package/templates/es/new_zero_outgoing_tx.html +13 -0
- package/templates/es/new_zero_outgoing_tx.plain +2 -0
- package/templates/es/tx_confirmation.html +13 -0
- package/templates/es/tx_confirmation.plain +2 -0
- package/templates/es/tx_confirmation_receiver.html +13 -0
- package/templates/es/tx_confirmation_receiver.plain +2 -0
- package/templates/es/tx_confirmation_sender.html +13 -0
- package/templates/es/tx_confirmation_sender.plain +2 -0
- package/templates/es/txp_finally_rejected.html +13 -0
- package/templates/es/txp_finally_rejected.plain +2 -0
- package/templates/es/wallet_complete.html +13 -0
- package/templates/es/wallet_complete.plain +2 -0
- package/templates/fr/new_copayer.html +13 -0
- package/templates/fr/new_copayer.plain +2 -0
- package/templates/fr/new_incoming_tx.html +11 -0
- package/templates/fr/new_incoming_tx.plain +2 -0
- package/templates/fr/new_incoming_tx_testnet.html +13 -0
- package/templates/fr/new_incoming_tx_testnet.plain +2 -0
- package/templates/fr/new_outgoing_tx.html +11 -0
- package/templates/fr/new_outgoing_tx.plain +2 -0
- package/templates/fr/new_tx_proposal.html +13 -0
- package/templates/fr/new_tx_proposal.plain +2 -0
- package/templates/fr/new_zero_outgoing_tx.html +13 -0
- package/templates/fr/new_zero_outgoing_tx.plain +2 -0
- package/templates/fr/tx_confirmation.html +13 -0
- package/templates/fr/tx_confirmation.plain +2 -0
- package/templates/fr/tx_confirmation_receiver.html +13 -0
- package/templates/fr/tx_confirmation_receiver.plain +2 -0
- package/templates/fr/tx_confirmation_sender.html +13 -0
- package/templates/fr/tx_confirmation_sender.plain +2 -0
- package/templates/fr/txp_finally_rejected.html +13 -0
- package/templates/fr/txp_finally_rejected.plain +2 -0
- package/templates/fr/wallet_complete.html +13 -0
- package/templates/fr/wallet_complete.plain +2 -0
- package/templates/ja/new_copayer.html +13 -0
- package/templates/ja/new_copayer.plain +2 -0
- package/templates/ja/new_incoming_tx.html +11 -0
- package/templates/ja/new_incoming_tx.plain +2 -0
- package/templates/ja/new_incoming_tx_testnet.html +13 -0
- package/templates/ja/new_incoming_tx_testnet.plain +2 -0
- package/templates/ja/new_outgoing_tx.html +11 -0
- package/templates/ja/new_outgoing_tx.plain +2 -0
- package/templates/ja/new_tx_proposal.html +13 -0
- package/templates/ja/new_tx_proposal.plain +2 -0
- package/templates/ja/new_zero_outgoing_tx.html +13 -0
- package/templates/ja/new_zero_outgoing_tx.plain +2 -0
- package/templates/ja/tx_confirmation.html +13 -0
- package/templates/ja/tx_confirmation.plain +2 -0
- package/templates/ja/tx_confirmation_receiver.html +13 -0
- package/templates/ja/tx_confirmation_receiver.plain +2 -0
- package/templates/ja/tx_confirmation_sender.html +13 -0
- package/templates/ja/tx_confirmation_sender.plain +2 -0
- package/templates/ja/txp_finally_rejected.html +13 -0
- package/templates/ja/txp_finally_rejected.plain +2 -0
- package/templates/ja/wallet_complete.html +13 -0
- package/templates/ja/wallet_complete.plain +2 -0
- package/templates/master-template.html +494 -0
- package/test/bchaddresstranslator.test.ts +50 -0
- package/test/blockchainexplorer.test.ts +66 -0
- package/test/chain/bch.test.ts +115 -0
- package/test/chain/btc.test.ts +331 -0
- package/test/chain/doge.test.ts +347 -0
- package/test/chain/eth.test.ts +21 -0
- package/test/chain/ltc.test.ts +328 -0
- package/test/chain/matic.test.ts +21 -0
- package/test/chain/xrp.test.ts +206 -0
- package/test/expressapp.test.ts +513 -0
- package/test/integration/bcmonitor.test.ts +381 -0
- package/test/integration/cashAddrMigration.test.ts +127 -0
- package/test/integration/data/tss/2of3/index.ts +3 -0
- package/test/integration/data/tss/2of3/party0.key.ts +5 -0
- package/test/integration/data/tss/2of3/party1.key.ts +5 -0
- package/test/integration/data/tss/2of3/party2.key.ts +5 -0
- package/test/integration/emailnotifications.test.ts +864 -0
- package/test/integration/externalservices/banxa.test.ts +373 -0
- package/test/integration/externalservices/changelly.test.ts +515 -0
- package/test/integration/externalservices/coinGecko.test.ts +284 -0
- package/test/integration/externalservices/moonpay.test.ts +569 -0
- package/test/integration/externalservices/oneInch.test.ts +162 -0
- package/test/integration/externalservices/ramp.test.ts +475 -0
- package/test/integration/externalservices/sardine.test.ts +352 -0
- package/test/integration/externalservices/simplex.test.ts +384 -0
- package/test/integration/externalservices/thorswap.test.ts +309 -0
- package/test/integration/externalservices/transak.test.ts +410 -0
- package/test/integration/externalservices/wyre.test.ts +270 -0
- package/test/integration/fiatrateservice.test.ts +979 -0
- package/test/integration/helpers.ts +694 -0
- package/test/integration/history.test.ts +1142 -0
- package/test/integration/hugetx.ts +6986 -0
- package/test/integration/pushNotifications.test.ts +1523 -0
- package/test/integration/server.test.ts +10740 -0
- package/test/integration/tss.test.ts +340 -0
- package/test/lock.test.ts +224 -0
- package/test/model/address.test.ts +187 -0
- package/test/model/addressmanager.test.ts +146 -0
- package/test/model/advertisement.test.ts +31 -0
- package/test/model/copayer.test.ts +131 -0
- package/test/model/txproposal.test.ts +185 -0
- package/test/model/wallet.test.ts +191 -0
- package/test/storage.test.ts +430 -0
- package/test/test-config.ts +12 -0
- package/test/testdata.ts +388 -0
- package/test/utils.test.ts +457 -0
- package/test/v8.test.ts +332 -0
- package/ts_build/package.json +119 -0
- package/ts_build/scripts/delme.d.ts +2 -0
- package/ts_build/scripts/delme.d.ts.map +1 -0
- package/ts_build/scripts/delme.js +453 -0
- package/ts_build/scripts/delme.js.map +1 -0
- package/ts_build/scripts/v8tool-list.d.ts +3 -0
- package/ts_build/scripts/v8tool-list.d.ts.map +1 -0
- package/ts_build/scripts/v8tool-list.js +80 -0
- package/ts_build/scripts/v8tool-list.js.map +1 -0
- package/ts_build/scripts/v8tool.d.ts +3 -0
- package/ts_build/scripts/v8tool.d.ts.map +1 -0
- package/ts_build/scripts/v8tool.js +69 -0
- package/ts_build/scripts/v8tool.js.map +1 -0
- package/ts_build/src/app.d.ts +3 -0
- package/ts_build/src/app.d.ts.map +1 -0
- package/ts_build/src/app.js +29 -0
- package/ts_build/src/app.js.map +1 -0
- package/ts_build/src/bcmonitor/bcmonitor.d.ts +3 -0
- package/ts_build/src/bcmonitor/bcmonitor.d.ts.map +1 -0
- package/ts_build/src/bcmonitor/bcmonitor.js +16 -0
- package/ts_build/src/bcmonitor/bcmonitor.js.map +1 -0
- package/ts_build/src/bws.d.ts +3 -0
- package/ts_build/src/bws.d.ts.map +1 -0
- package/ts_build/src/bws.js +98 -0
- package/ts_build/src/bws.js.map +1 -0
- package/ts_build/src/cleanfiatrates/cleanfiatrates.d.ts +3 -0
- package/ts_build/src/cleanfiatrates/cleanfiatrates.d.ts.map +1 -0
- package/ts_build/src/cleanfiatrates/cleanfiatrates.js +11 -0
- package/ts_build/src/cleanfiatrates/cleanfiatrates.js.map +1 -0
- package/ts_build/src/config.d.ts +3 -0
- package/ts_build/src/config.d.ts.map +1 -0
- package/ts_build/src/config.js +256 -0
- package/ts_build/src/config.js.map +1 -0
- package/ts_build/src/deprecated-serverMessages.d.ts +10 -0
- package/ts_build/src/deprecated-serverMessages.d.ts.map +1 -0
- package/ts_build/src/deprecated-serverMessages.js +20 -0
- package/ts_build/src/deprecated-serverMessages.js.map +1 -0
- package/ts_build/src/emailservice/emailservice.d.ts +3 -0
- package/ts_build/src/emailservice/emailservice.d.ts.map +1 -0
- package/ts_build/src/emailservice/emailservice.js +16 -0
- package/ts_build/src/emailservice/emailservice.js.map +1 -0
- package/ts_build/src/externalservices/banxa.d.ts +11 -0
- package/ts_build/src/externalservices/banxa.d.ts.map +1 -0
- package/ts_build/src/externalservices/banxa.js +254 -0
- package/ts_build/src/externalservices/banxa.js.map +1 -0
- package/ts_build/src/externalservices/changelly.d.ts +18 -0
- package/ts_build/src/externalservices/changelly.d.ts.map +1 -0
- package/ts_build/src/externalservices/changelly.js +356 -0
- package/ts_build/src/externalservices/changelly.js.map +1 -0
- package/ts_build/src/externalservices/coingecko.d.ts +43 -0
- package/ts_build/src/externalservices/coingecko.d.ts.map +1 -0
- package/ts_build/src/externalservices/coingecko.js +416 -0
- package/ts_build/src/externalservices/coingecko.js.map +1 -0
- package/ts_build/src/externalservices/moonpay.d.ts +19 -0
- package/ts_build/src/externalservices/moonpay.d.ts.map +1 -0
- package/ts_build/src/externalservices/moonpay.js +397 -0
- package/ts_build/src/externalservices/moonpay.js.map +1 -0
- package/ts_build/src/externalservices/oneInch.d.ts +11 -0
- package/ts_build/src/externalservices/oneInch.d.ts.map +1 -0
- package/ts_build/src/externalservices/oneInch.js +179 -0
- package/ts_build/src/externalservices/oneInch.js.map +1 -0
- package/ts_build/src/externalservices/ramp.d.ts +12 -0
- package/ts_build/src/externalservices/ramp.d.ts.map +1 -0
- package/ts_build/src/externalservices/ramp.js +256 -0
- package/ts_build/src/externalservices/ramp.js.map +1 -0
- package/ts_build/src/externalservices/sardine.d.ts +10 -0
- package/ts_build/src/externalservices/sardine.d.ts.map +1 -0
- package/ts_build/src/externalservices/sardine.js +232 -0
- package/ts_build/src/externalservices/sardine.js.map +1 -0
- package/ts_build/src/externalservices/simplex.d.ts +11 -0
- package/ts_build/src/externalservices/simplex.d.ts.map +1 -0
- package/ts_build/src/externalservices/simplex.js +261 -0
- package/ts_build/src/externalservices/simplex.js.map +1 -0
- package/ts_build/src/externalservices/thorswap.d.ts +9 -0
- package/ts_build/src/externalservices/thorswap.d.ts.map +1 -0
- package/ts_build/src/externalservices/thorswap.js +206 -0
- package/ts_build/src/externalservices/thorswap.js.map +1 -0
- package/ts_build/src/externalservices/transak.d.ts +13 -0
- package/ts_build/src/externalservices/transak.d.ts.map +1 -0
- package/ts_build/src/externalservices/transak.js +311 -0
- package/ts_build/src/externalservices/transak.js.map +1 -0
- package/ts_build/src/externalservices/wyre.d.ts +7 -0
- package/ts_build/src/externalservices/wyre.d.ts.map +1 -0
- package/ts_build/src/externalservices/wyre.js +144 -0
- package/ts_build/src/externalservices/wyre.js.map +1 -0
- package/ts_build/src/fiatrateservice/fiatrateservice.d.ts +3 -0
- package/ts_build/src/fiatrateservice/fiatrateservice.d.ts.map +1 -0
- package/ts_build/src/fiatrateservice/fiatrateservice.js +20 -0
- package/ts_build/src/fiatrateservice/fiatrateservice.js.map +1 -0
- package/ts_build/src/index.d.ts +8 -0
- package/ts_build/src/index.d.ts.map +1 -0
- package/ts_build/src/index.js +11 -0
- package/ts_build/src/index.js.map +1 -0
- package/ts_build/src/lib/bchaddresstranslator.d.ts +5 -0
- package/ts_build/src/lib/bchaddresstranslator.d.ts.map +1 -0
- package/ts_build/src/lib/bchaddresstranslator.js +66 -0
- package/ts_build/src/lib/bchaddresstranslator.js.map +1 -0
- package/ts_build/src/lib/blockchainexplorer.d.ts +3 -0
- package/ts_build/src/lib/blockchainexplorer.d.ts.map +1 -0
- package/ts_build/src/lib/blockchainexplorer.js +87 -0
- package/ts_build/src/lib/blockchainexplorer.js.map +1 -0
- package/ts_build/src/lib/blockchainexplorers/v8/client.d.ts +31 -0
- package/ts_build/src/lib/blockchainexplorers/v8/client.d.ts.map +1 -0
- package/ts_build/src/lib/blockchainexplorers/v8/client.js +191 -0
- package/ts_build/src/lib/blockchainexplorers/v8/client.js.map +1 -0
- package/ts_build/src/lib/blockchainexplorers/v8.d.ts +91 -0
- package/ts_build/src/lib/blockchainexplorers/v8.d.ts.map +1 -0
- package/ts_build/src/lib/blockchainexplorers/v8.js +662 -0
- package/ts_build/src/lib/blockchainexplorers/v8.js.map +1 -0
- package/ts_build/src/lib/blockchainmonitor.d.ts +32 -0
- package/ts_build/src/lib/blockchainmonitor.d.ts.map +1 -0
- package/ts_build/src/lib/blockchainmonitor.js +413 -0
- package/ts_build/src/lib/blockchainmonitor.js.map +1 -0
- package/ts_build/src/lib/chain/arb/index.d.ts +5 -0
- package/ts_build/src/lib/chain/arb/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/arb/index.js +12 -0
- package/ts_build/src/lib/chain/arb/index.js.map +1 -0
- package/ts_build/src/lib/chain/base/index.d.ts +5 -0
- package/ts_build/src/lib/chain/base/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/base/index.js +12 -0
- package/ts_build/src/lib/chain/base/index.js.map +1 -0
- package/ts_build/src/lib/chain/bch/index.d.ts +9 -0
- package/ts_build/src/lib/chain/bch/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/bch/index.js +43 -0
- package/ts_build/src/lib/chain/bch/index.js.map +1 -0
- package/ts_build/src/lib/chain/btc/index.d.ts +65 -0
- package/ts_build/src/lib/chain/btc/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/btc/index.js +829 -0
- package/ts_build/src/lib/chain/btc/index.js.map +1 -0
- package/ts_build/src/lib/chain/doge/index.d.ts +9 -0
- package/ts_build/src/lib/chain/doge/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/doge/index.js +338 -0
- package/ts_build/src/lib/chain/doge/index.js.map +1 -0
- package/ts_build/src/lib/chain/eth/abi-erc20.d.ts +39 -0
- package/ts_build/src/lib/chain/eth/abi-erc20.d.ts.map +1 -0
- package/ts_build/src/lib/chain/eth/abi-erc20.js +226 -0
- package/ts_build/src/lib/chain/eth/abi-erc20.js.map +1 -0
- package/ts_build/src/lib/chain/eth/abi-invoice.d.ts +42 -0
- package/ts_build/src/lib/chain/eth/abi-invoice.d.ts.map +1 -0
- package/ts_build/src/lib/chain/eth/abi-invoice.js +281 -0
- package/ts_build/src/lib/chain/eth/abi-invoice.js.map +1 -0
- package/ts_build/src/lib/chain/eth/index.d.ts +66 -0
- package/ts_build/src/lib/chain/eth/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/eth/index.js +516 -0
- package/ts_build/src/lib/chain/eth/index.js.map +1 -0
- package/ts_build/src/lib/chain/index.d.ts +40 -0
- package/ts_build/src/lib/chain/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/index.js +143 -0
- package/ts_build/src/lib/chain/index.js.map +1 -0
- package/ts_build/src/lib/chain/ltc/index.d.ts +6 -0
- package/ts_build/src/lib/chain/ltc/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/ltc/index.js +12 -0
- package/ts_build/src/lib/chain/ltc/index.js.map +1 -0
- package/ts_build/src/lib/chain/matic/index.d.ts +5 -0
- package/ts_build/src/lib/chain/matic/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/matic/index.js +12 -0
- package/ts_build/src/lib/chain/matic/index.js.map +1 -0
- package/ts_build/src/lib/chain/op/index.d.ts +5 -0
- package/ts_build/src/lib/chain/op/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/op/index.js +12 -0
- package/ts_build/src/lib/chain/op/index.js.map +1 -0
- package/ts_build/src/lib/chain/sol/index.d.ts +52 -0
- package/ts_build/src/lib/chain/sol/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/sol/index.js +305 -0
- package/ts_build/src/lib/chain/sol/index.js.map +1 -0
- package/ts_build/src/lib/chain/xrp/index.d.ts +46 -0
- package/ts_build/src/lib/chain/xrp/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/xrp/index.js +300 -0
- package/ts_build/src/lib/chain/xrp/index.js.map +1 -0
- package/ts_build/src/lib/cleanfiatrates.d.ts +13 -0
- package/ts_build/src/lib/cleanfiatrates.d.ts.map +1 -0
- package/ts_build/src/lib/cleanfiatrates.js +176 -0
- package/ts_build/src/lib/cleanfiatrates.js.map +1 -0
- package/ts_build/src/lib/common/constants.d.ts +387 -0
- package/ts_build/src/lib/common/constants.d.ts.map +1 -0
- package/ts_build/src/lib/common/constants.js +234 -0
- package/ts_build/src/lib/common/constants.js.map +1 -0
- package/ts_build/src/lib/common/defaults.d.ts +326 -0
- package/ts_build/src/lib/common/defaults.d.ts.map +1 -0
- package/ts_build/src/lib/common/defaults.js +356 -0
- package/ts_build/src/lib/common/defaults.js.map +1 -0
- package/ts_build/src/lib/common/index.d.ts +793 -0
- package/ts_build/src/lib/common/index.d.ts.map +1 -0
- package/ts_build/src/lib/common/index.js +14 -0
- package/ts_build/src/lib/common/index.js.map +1 -0
- package/ts_build/src/lib/common/services.d.ts +34 -0
- package/ts_build/src/lib/common/services.d.ts.map +1 -0
- package/ts_build/src/lib/common/services.js +44 -0
- package/ts_build/src/lib/common/services.js.map +1 -0
- package/ts_build/src/lib/common/utils.d.ts +47 -0
- package/ts_build/src/lib/common/utils.d.ts.map +1 -0
- package/ts_build/src/lib/common/utils.js +385 -0
- package/ts_build/src/lib/common/utils.js.map +1 -0
- package/ts_build/src/lib/emailservice.d.ts +62 -0
- package/ts_build/src/lib/emailservice.d.ts.map +1 -0
- package/ts_build/src/lib/emailservice.js +727 -0
- package/ts_build/src/lib/emailservice.js.map +1 -0
- package/ts_build/src/lib/errors/clienterror.d.ts +11 -0
- package/ts_build/src/lib/errors/clienterror.d.ts.map +1 -0
- package/ts_build/src/lib/errors/clienterror.js +46 -0
- package/ts_build/src/lib/errors/clienterror.js.map +1 -0
- package/ts_build/src/lib/errors/errordefinitions.d.ts +76 -0
- package/ts_build/src/lib/errors/errordefinitions.d.ts.map +1 -0
- package/ts_build/src/lib/errors/errordefinitions.js +82 -0
- package/ts_build/src/lib/errors/errordefinitions.js.map +1 -0
- package/ts_build/src/lib/expressapp.d.ts +8 -0
- package/ts_build/src/lib/expressapp.d.ts.map +1 -0
- package/ts_build/src/lib/expressapp.js +2221 -0
- package/ts_build/src/lib/expressapp.js.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/bitpay.d.ts +3 -0
- package/ts_build/src/lib/fiatrateproviders/bitpay.d.ts.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/bitpay.js +22 -0
- package/ts_build/src/lib/fiatrateproviders/bitpay.js.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/bitstamp.d.ts +3 -0
- package/ts_build/src/lib/fiatrateproviders/bitstamp.d.ts.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/bitstamp.js +18 -0
- package/ts_build/src/lib/fiatrateproviders/bitstamp.js.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/index.d.ts +3 -0
- package/ts_build/src/lib/fiatrateproviders/index.d.ts.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/index.js +8 -0
- package/ts_build/src/lib/fiatrateproviders/index.js.map +1 -0
- package/ts_build/src/lib/fiatrateservice.d.ts +18 -0
- package/ts_build/src/lib/fiatrateservice.d.ts.map +1 -0
- package/ts_build/src/lib/fiatrateservice.js +313 -0
- package/ts_build/src/lib/fiatrateservice.js.map +1 -0
- package/ts_build/src/lib/iconsconfig.d.ts +2 -0
- package/ts_build/src/lib/iconsconfig.d.ts.map +1 -0
- package/ts_build/src/lib/iconsconfig.js +31 -0
- package/ts_build/src/lib/iconsconfig.js.map +1 -0
- package/ts_build/src/lib/index.d.ts +1 -0
- package/ts_build/src/lib/index.d.ts.map +1 -0
- package/ts_build/src/lib/index.js +1 -0
- package/ts_build/src/lib/index.js.map +1 -0
- package/ts_build/src/lib/lock.d.ts +14 -0
- package/ts_build/src/lib/lock.d.ts.map +1 -0
- package/ts_build/src/lib/lock.js +55 -0
- package/ts_build/src/lib/lock.js.map +1 -0
- package/ts_build/src/lib/logger.d.ts +7 -0
- package/ts_build/src/lib/logger.d.ts.map +1 -0
- package/ts_build/src/lib/logger.js +95 -0
- package/ts_build/src/lib/logger.js.map +1 -0
- package/ts_build/src/lib/messagebroker.d.ts +11 -0
- package/ts_build/src/lib/messagebroker.d.ts.map +1 -0
- package/ts_build/src/lib/messagebroker.js +77 -0
- package/ts_build/src/lib/messagebroker.js.map +1 -0
- package/ts_build/src/lib/model/address.d.ts +47 -0
- package/ts_build/src/lib/model/address.d.ts.map +1 -0
- package/ts_build/src/lib/model/address.js +158 -0
- package/ts_build/src/lib/model/address.js.map +1 -0
- package/ts_build/src/lib/model/addressmanager.d.ts +41 -0
- package/ts_build/src/lib/model/addressmanager.d.ts.map +1 -0
- package/ts_build/src/lib/model/addressmanager.js +103 -0
- package/ts_build/src/lib/model/addressmanager.js.map +1 -0
- package/ts_build/src/lib/model/advertisement.d.ts +38 -0
- package/ts_build/src/lib/model/advertisement.d.ts.map +1 -0
- package/ts_build/src/lib/model/advertisement.js +68 -0
- package/ts_build/src/lib/model/advertisement.js.map +1 -0
- package/ts_build/src/lib/model/copayer.d.ts +48 -0
- package/ts_build/src/lib/model/copayer.d.ts.map +1 -0
- package/ts_build/src/lib/model/copayer.js +116 -0
- package/ts_build/src/lib/model/copayer.js.map +1 -0
- package/ts_build/src/lib/model/email.d.ts +23 -0
- package/ts_build/src/lib/model/email.d.ts.map +1 -0
- package/ts_build/src/lib/model/email.js +84 -0
- package/ts_build/src/lib/model/email.js.map +1 -0
- package/ts_build/src/lib/model/index.d.ts +13 -0
- package/ts_build/src/lib/model/index.d.ts.map +1 -0
- package/ts_build/src/lib/model/index.js +28 -0
- package/ts_build/src/lib/model/index.js.map +1 -0
- package/ts_build/src/lib/model/notification.d.ts +23 -0
- package/ts_build/src/lib/model/notification.d.ts.map +1 -0
- package/ts_build/src/lib/model/notification.js +40 -0
- package/ts_build/src/lib/model/notification.js.map +1 -0
- package/ts_build/src/lib/model/preferences.d.ts +37 -0
- package/ts_build/src/lib/model/preferences.d.ts.map +1 -0
- package/ts_build/src/lib/model/preferences.js +61 -0
- package/ts_build/src/lib/model/preferences.js.map +1 -0
- package/ts_build/src/lib/model/pushnotificationsub.d.ts +23 -0
- package/ts_build/src/lib/model/pushnotificationsub.d.ts.map +1 -0
- package/ts_build/src/lib/model/pushnotificationsub.js +40 -0
- package/ts_build/src/lib/model/pushnotificationsub.js.map +1 -0
- package/ts_build/src/lib/model/session.d.ts +22 -0
- package/ts_build/src/lib/model/session.d.ts.map +1 -0
- package/ts_build/src/lib/model/session.js +52 -0
- package/ts_build/src/lib/model/session.js.map +1 -0
- package/ts_build/src/lib/model/tsskeygen.d.ts +67 -0
- package/ts_build/src/lib/model/tsskeygen.d.ts.map +1 -0
- package/ts_build/src/lib/model/tsskeygen.js +69 -0
- package/ts_build/src/lib/model/tsskeygen.js.map +1 -0
- package/ts_build/src/lib/model/tsssign.d.ts +70 -0
- package/ts_build/src/lib/model/tsssign.d.ts.map +1 -0
- package/ts_build/src/lib/model/tsssign.js +54 -0
- package/ts_build/src/lib/model/tsssign.js.map +1 -0
- package/ts_build/src/lib/model/txconfirmationsub.d.ts +23 -0
- package/ts_build/src/lib/model/txconfirmationsub.d.ts.map +1 -0
- package/ts_build/src/lib/model/txconfirmationsub.js +40 -0
- package/ts_build/src/lib/model/txconfirmationsub.js.map +1 -0
- package/ts_build/src/lib/model/txnote.d.ts +23 -0
- package/ts_build/src/lib/model/txnote.d.ts.map +1 -0
- package/ts_build/src/lib/model/txnote.js +46 -0
- package/ts_build/src/lib/model/txnote.js.map +1 -0
- package/ts_build/src/lib/model/txproposal.d.ts +196 -0
- package/ts_build/src/lib/model/txproposal.d.ts.map +1 -0
- package/ts_build/src/lib/model/txproposal.js +382 -0
- package/ts_build/src/lib/model/txproposal.js.map +1 -0
- package/ts_build/src/lib/model/txproposal_legacy.d.ts +93 -0
- package/ts_build/src/lib/model/txproposal_legacy.d.ts.map +1 -0
- package/ts_build/src/lib/model/txproposal_legacy.js +185 -0
- package/ts_build/src/lib/model/txproposal_legacy.js.map +1 -0
- package/ts_build/src/lib/model/txproposalaction.d.ts +21 -0
- package/ts_build/src/lib/model/txproposalaction.d.ts.map +1 -0
- package/ts_build/src/lib/model/txproposalaction.js +37 -0
- package/ts_build/src/lib/model/txproposalaction.js.map +1 -0
- package/ts_build/src/lib/model/wallet.d.ts +110 -0
- package/ts_build/src/lib/model/wallet.d.ts.map +1 -0
- package/ts_build/src/lib/model/wallet.js +224 -0
- package/ts_build/src/lib/model/wallet.js.map +1 -0
- package/ts_build/src/lib/notificationbroadcaster.d.ts +6 -0
- package/ts_build/src/lib/notificationbroadcaster.d.ts.map +1 -0
- package/ts_build/src/lib/notificationbroadcaster.js +19 -0
- package/ts_build/src/lib/notificationbroadcaster.js.map +1 -0
- package/ts_build/src/lib/pushnotificationsservice.d.ts +56 -0
- package/ts_build/src/lib/pushnotificationsservice.d.ts.map +1 -0
- package/ts_build/src/lib/pushnotificationsservice.js +721 -0
- package/ts_build/src/lib/pushnotificationsservice.js.map +1 -0
- package/ts_build/src/lib/routes/helpers/error.d.ts +10 -0
- package/ts_build/src/lib/routes/helpers/error.d.ts.map +1 -0
- package/ts_build/src/lib/routes/helpers/error.js +54 -0
- package/ts_build/src/lib/routes/helpers/error.js.map +1 -0
- package/ts_build/src/lib/routes/helpers/index.d.ts +2 -0
- package/ts_build/src/lib/routes/helpers/index.d.ts.map +1 -0
- package/ts_build/src/lib/routes/helpers/index.js +18 -0
- package/ts_build/src/lib/routes/helpers/index.js.map +1 -0
- package/ts_build/src/lib/routes/middleware/authRequest.d.ts +6 -0
- package/ts_build/src/lib/routes/middleware/authRequest.d.ts.map +1 -0
- package/ts_build/src/lib/routes/middleware/authRequest.js +106 -0
- package/ts_build/src/lib/routes/middleware/authRequest.js.map +1 -0
- package/ts_build/src/lib/routes/middleware/authTssRequest.d.ts +3 -0
- package/ts_build/src/lib/routes/middleware/authTssRequest.d.ts.map +1 -0
- package/ts_build/src/lib/routes/middleware/authTssRequest.js +56 -0
- package/ts_build/src/lib/routes/middleware/authTssRequest.js.map +1 -0
- package/ts_build/src/lib/routes/middleware/createWalletLimiter.d.ts +4 -0
- package/ts_build/src/lib/routes/middleware/createWalletLimiter.d.ts.map +1 -0
- package/ts_build/src/lib/routes/middleware/createWalletLimiter.js +28 -0
- package/ts_build/src/lib/routes/middleware/createWalletLimiter.js.map +1 -0
- package/ts_build/src/lib/routes/middleware/log.d.ts +9 -0
- package/ts_build/src/lib/routes/middleware/log.d.ts.map +1 -0
- package/ts_build/src/lib/routes/middleware/log.js +52 -0
- package/ts_build/src/lib/routes/middleware/log.js.map +1 -0
- package/ts_build/src/lib/routes/middleware/verifyTssMessage.d.ts +2 -0
- package/ts_build/src/lib/routes/middleware/verifyTssMessage.d.ts.map +1 -0
- package/ts_build/src/lib/routes/middleware/verifyTssMessage.js +34 -0
- package/ts_build/src/lib/routes/middleware/verifyTssMessage.js.map +1 -0
- package/ts_build/src/lib/routes/tss.d.ts +14 -0
- package/ts_build/src/lib/routes/tss.d.ts.map +1 -0
- package/ts_build/src/lib/routes/tss.js +120 -0
- package/ts_build/src/lib/routes/tss.js.map +1 -0
- package/ts_build/src/lib/server.d.ts +250 -0
- package/ts_build/src/lib/server.d.ts.map +1 -0
- package/ts_build/src/lib/server.js +4115 -0
- package/ts_build/src/lib/server.js.map +1 -0
- package/ts_build/src/lib/stats.d.ts +17 -0
- package/ts_build/src/lib/stats.d.ts.map +1 -0
- package/ts_build/src/lib/stats.js +203 -0
- package/ts_build/src/lib/stats.js.map +1 -0
- package/ts_build/src/lib/storage.d.ts +163 -0
- package/ts_build/src/lib/storage.d.ts.map +1 -0
- package/ts_build/src/lib/storage.js +1513 -0
- package/ts_build/src/lib/storage.js.map +1 -0
- package/ts_build/src/lib/tss.d.ts +70 -0
- package/ts_build/src/lib/tss.d.ts.map +1 -0
- package/ts_build/src/lib/tss.js +379 -0
- package/ts_build/src/lib/tss.js.map +1 -0
- package/ts_build/src/lib/updatestats.d.ts +16 -0
- package/ts_build/src/lib/updatestats.d.ts.map +1 -0
- package/ts_build/src/lib/updatestats.js +308 -0
- package/ts_build/src/lib/updatestats.js.map +1 -0
- package/ts_build/src/messagebroker/messagebroker.d.ts +3 -0
- package/ts_build/src/messagebroker/messagebroker.d.ts.map +1 -0
- package/ts_build/src/messagebroker/messagebroker.js +20 -0
- package/ts_build/src/messagebroker/messagebroker.js.map +1 -0
- package/ts_build/src/pushnotificationsservice/pushnotificationsservice.d.ts +3 -0
- package/ts_build/src/pushnotificationsservice/pushnotificationsservice.d.ts.map +1 -0
- package/ts_build/src/pushnotificationsservice/pushnotificationsservice.js +16 -0
- package/ts_build/src/pushnotificationsservice/pushnotificationsservice.js.map +1 -0
- package/ts_build/src/serverMessages.d.ts +2 -0
- package/ts_build/src/serverMessages.d.ts.map +1 -0
- package/ts_build/src/serverMessages.js +35 -0
- package/ts_build/src/serverMessages.js.map +1 -0
- package/ts_build/src/updatestats/updatestats.d.ts +3 -0
- package/ts_build/src/updatestats/updatestats.d.ts.map +1 -0
- package/ts_build/src/updatestats/updatestats.js +15 -0
- package/ts_build/src/updatestats/updatestats.js.map +1 -0
- package/ts_build/templates/en/new_copayer.html +13 -0
- package/ts_build/templates/en/new_copayer.plain +2 -0
- package/ts_build/templates/en/new_incoming_tx.html +11 -0
- package/ts_build/templates/en/new_incoming_tx.plain +2 -0
- package/ts_build/templates/en/new_incoming_tx_testnet.html +13 -0
- package/ts_build/templates/en/new_incoming_tx_testnet.plain +2 -0
- package/ts_build/templates/en/new_outgoing_tx.html +11 -0
- package/ts_build/templates/en/new_outgoing_tx.plain +2 -0
- package/ts_build/templates/en/new_tx_proposal.html +13 -0
- package/ts_build/templates/en/new_tx_proposal.plain +2 -0
- package/ts_build/templates/en/new_zero_outgoing_tx.html +13 -0
- package/ts_build/templates/en/new_zero_outgoing_tx.plain +2 -0
- package/ts_build/templates/en/tx_confirmation.html +13 -0
- package/ts_build/templates/en/tx_confirmation.plain +2 -0
- package/ts_build/templates/en/tx_confirmation_receiver.html +13 -0
- package/ts_build/templates/en/tx_confirmation_receiver.plain +2 -0
- package/ts_build/templates/en/tx_confirmation_sender.html +13 -0
- package/ts_build/templates/en/tx_confirmation_sender.plain +2 -0
- package/ts_build/templates/en/txp_finally_rejected.html +13 -0
- package/ts_build/templates/en/txp_finally_rejected.plain +2 -0
- package/ts_build/templates/en/wallet_complete.html +13 -0
- package/ts_build/templates/en/wallet_complete.plain +2 -0
- package/ts_build/templates/es/new_copayer.html +13 -0
- package/ts_build/templates/es/new_copayer.plain +2 -0
- package/ts_build/templates/es/new_incoming_tx.html +11 -0
- package/ts_build/templates/es/new_incoming_tx.plain +2 -0
- package/ts_build/templates/es/new_incoming_tx_testnet.html +13 -0
- package/ts_build/templates/es/new_incoming_tx_testnet.plain +2 -0
- package/ts_build/templates/es/new_outgoing_tx.html +11 -0
- package/ts_build/templates/es/new_outgoing_tx.plain +2 -0
- package/ts_build/templates/es/new_tx_proposal.html +13 -0
- package/ts_build/templates/es/new_tx_proposal.plain +2 -0
- package/ts_build/templates/es/new_zero_outgoing_tx.html +13 -0
- package/ts_build/templates/es/new_zero_outgoing_tx.plain +2 -0
- package/ts_build/templates/es/tx_confirmation.html +13 -0
- package/ts_build/templates/es/tx_confirmation.plain +2 -0
- package/ts_build/templates/es/tx_confirmation_receiver.html +13 -0
- package/ts_build/templates/es/tx_confirmation_receiver.plain +2 -0
- package/ts_build/templates/es/tx_confirmation_sender.html +13 -0
- package/ts_build/templates/es/tx_confirmation_sender.plain +2 -0
- package/ts_build/templates/es/txp_finally_rejected.html +13 -0
- package/ts_build/templates/es/txp_finally_rejected.plain +2 -0
- package/ts_build/templates/es/wallet_complete.html +13 -0
- package/ts_build/templates/es/wallet_complete.plain +2 -0
- package/ts_build/templates/fr/new_copayer.html +13 -0
- package/ts_build/templates/fr/new_copayer.plain +2 -0
- package/ts_build/templates/fr/new_incoming_tx.html +11 -0
- package/ts_build/templates/fr/new_incoming_tx.plain +2 -0
- package/ts_build/templates/fr/new_incoming_tx_testnet.html +13 -0
- package/ts_build/templates/fr/new_incoming_tx_testnet.plain +2 -0
- package/ts_build/templates/fr/new_outgoing_tx.html +11 -0
- package/ts_build/templates/fr/new_outgoing_tx.plain +2 -0
- package/ts_build/templates/fr/new_tx_proposal.html +13 -0
- package/ts_build/templates/fr/new_tx_proposal.plain +2 -0
- package/ts_build/templates/fr/new_zero_outgoing_tx.html +13 -0
- package/ts_build/templates/fr/new_zero_outgoing_tx.plain +2 -0
- package/ts_build/templates/fr/tx_confirmation.html +13 -0
- package/ts_build/templates/fr/tx_confirmation.plain +2 -0
- package/ts_build/templates/fr/tx_confirmation_receiver.html +13 -0
- package/ts_build/templates/fr/tx_confirmation_receiver.plain +2 -0
- package/ts_build/templates/fr/tx_confirmation_sender.html +13 -0
- package/ts_build/templates/fr/tx_confirmation_sender.plain +2 -0
- package/ts_build/templates/fr/txp_finally_rejected.html +13 -0
- package/ts_build/templates/fr/txp_finally_rejected.plain +2 -0
- package/ts_build/templates/fr/wallet_complete.html +13 -0
- package/ts_build/templates/fr/wallet_complete.plain +2 -0
- package/ts_build/templates/ja/new_copayer.html +13 -0
- package/ts_build/templates/ja/new_copayer.plain +2 -0
- package/ts_build/templates/ja/new_incoming_tx.html +11 -0
- package/ts_build/templates/ja/new_incoming_tx.plain +2 -0
- package/ts_build/templates/ja/new_incoming_tx_testnet.html +13 -0
- package/ts_build/templates/ja/new_incoming_tx_testnet.plain +2 -0
- package/ts_build/templates/ja/new_outgoing_tx.html +11 -0
- package/ts_build/templates/ja/new_outgoing_tx.plain +2 -0
- package/ts_build/templates/ja/new_tx_proposal.html +13 -0
- package/ts_build/templates/ja/new_tx_proposal.plain +2 -0
- package/ts_build/templates/ja/new_zero_outgoing_tx.html +13 -0
- package/ts_build/templates/ja/new_zero_outgoing_tx.plain +2 -0
- package/ts_build/templates/ja/tx_confirmation.html +13 -0
- package/ts_build/templates/ja/tx_confirmation.plain +2 -0
- package/ts_build/templates/ja/tx_confirmation_receiver.html +13 -0
- package/ts_build/templates/ja/tx_confirmation_receiver.plain +2 -0
- package/ts_build/templates/ja/tx_confirmation_sender.html +13 -0
- package/ts_build/templates/ja/tx_confirmation_sender.plain +2 -0
- package/ts_build/templates/ja/txp_finally_rejected.html +13 -0
- package/ts_build/templates/ja/txp_finally_rejected.plain +2 -0
- package/ts_build/templates/ja/wallet_complete.html +13 -0
- package/ts_build/templates/ja/wallet_complete.plain +2 -0
- package/ts_build/templates/master-template.html +494 -0
- package/ts_build/test/bchaddresstranslator.test.d.ts +2 -0
- package/ts_build/test/bchaddresstranslator.test.d.ts.map +1 -0
- package/ts_build/test/bchaddresstranslator.test.js +76 -0
- package/ts_build/test/bchaddresstranslator.test.js.map +1 -0
- package/ts_build/test/blockchainexplorer.test.d.ts +2 -0
- package/ts_build/test/blockchainexplorer.test.d.ts.map +1 -0
- package/ts_build/test/blockchainexplorer.test.js +98 -0
- package/ts_build/test/blockchainexplorer.test.js.map +1 -0
- package/ts_build/test/chain/bch.test.d.ts +2 -0
- package/ts_build/test/chain/bch.test.d.ts.map +1 -0
- package/ts_build/test/chain/bch.test.js +135 -0
- package/ts_build/test/chain/bch.test.js.map +1 -0
- package/ts_build/test/chain/btc.test.d.ts +2 -0
- package/ts_build/test/chain/btc.test.d.ts.map +1 -0
- package/ts_build/test/chain/btc.test.js +310 -0
- package/ts_build/test/chain/btc.test.js.map +1 -0
- package/ts_build/test/chain/doge.test.d.ts +2 -0
- package/ts_build/test/chain/doge.test.d.ts.map +1 -0
- package/ts_build/test/chain/doge.test.js +343 -0
- package/ts_build/test/chain/doge.test.js.map +1 -0
- package/ts_build/test/chain/eth.test.d.ts +2 -0
- package/ts_build/test/chain/eth.test.d.ts.map +1 -0
- package/ts_build/test/chain/eth.test.js +51 -0
- package/ts_build/test/chain/eth.test.js.map +1 -0
- package/ts_build/test/chain/ltc.test.d.ts +2 -0
- package/ts_build/test/chain/ltc.test.d.ts.map +1 -0
- package/ts_build/test/chain/ltc.test.js +323 -0
- package/ts_build/test/chain/ltc.test.js.map +1 -0
- package/ts_build/test/chain/matic.test.d.ts +2 -0
- package/ts_build/test/chain/matic.test.d.ts.map +1 -0
- package/ts_build/test/chain/matic.test.js +51 -0
- package/ts_build/test/chain/matic.test.js.map +1 -0
- package/ts_build/test/chain/xrp.test.d.ts +2 -0
- package/ts_build/test/chain/xrp.test.d.ts.map +1 -0
- package/ts_build/test/chain/xrp.test.js +228 -0
- package/ts_build/test/chain/xrp.test.js.map +1 -0
- package/ts_build/test/expressapp.test.d.ts +2 -0
- package/ts_build/test/expressapp.test.d.ts.map +1 -0
- package/ts_build/test/expressapp.test.js +523 -0
- package/ts_build/test/expressapp.test.js.map +1 -0
- package/ts_build/test/integration/bcmonitor.test.d.ts +2 -0
- package/ts_build/test/integration/bcmonitor.test.d.ts.map +1 -0
- package/ts_build/test/integration/bcmonitor.test.js +375 -0
- package/ts_build/test/integration/bcmonitor.test.js.map +1 -0
- package/ts_build/test/integration/cashAddrMigration.test.d.ts +2 -0
- package/ts_build/test/integration/cashAddrMigration.test.d.ts.map +1 -0
- package/ts_build/test/integration/cashAddrMigration.test.js +147 -0
- package/ts_build/test/integration/cashAddrMigration.test.js.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/index.d.ts +4 -0
- package/ts_build/test/integration/data/tss/2of3/index.d.ts.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/index.js +20 -0
- package/ts_build/test/integration/data/tss/2of3/index.js.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party0.key.d.ts +6 -0
- package/ts_build/test/integration/data/tss/2of3/party0.key.d.ts.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party0.key.js +9 -0
- package/ts_build/test/integration/data/tss/2of3/party0.key.js.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party1.key.d.ts +6 -0
- package/ts_build/test/integration/data/tss/2of3/party1.key.d.ts.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party1.key.js +9 -0
- package/ts_build/test/integration/data/tss/2of3/party1.key.js.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party2.key.d.ts +6 -0
- package/ts_build/test/integration/data/tss/2of3/party2.key.d.ts.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party2.key.js +9 -0
- package/ts_build/test/integration/data/tss/2of3/party2.key.js.map +1 -0
- package/ts_build/test/integration/emailnotifications.test.d.ts +2 -0
- package/ts_build/test/integration/emailnotifications.test.d.ts.map +1 -0
- package/ts_build/test/integration/emailnotifications.test.js +805 -0
- package/ts_build/test/integration/emailnotifications.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/banxa.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/banxa.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/banxa.test.js +382 -0
- package/ts_build/test/integration/externalservices/banxa.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/changelly.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/changelly.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/changelly.test.js +509 -0
- package/ts_build/test/integration/externalservices/changelly.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/coinGecko.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/coinGecko.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/coinGecko.test.js +295 -0
- package/ts_build/test/integration/externalservices/coinGecko.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/moonpay.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/moonpay.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/moonpay.test.js +567 -0
- package/ts_build/test/integration/externalservices/moonpay.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/oneInch.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/oneInch.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/oneInch.test.js +182 -0
- package/ts_build/test/integration/externalservices/oneInch.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/ramp.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/ramp.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/ramp.test.js +459 -0
- package/ts_build/test/integration/externalservices/ramp.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/sardine.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/sardine.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/sardine.test.js +364 -0
- package/ts_build/test/integration/externalservices/sardine.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/simplex.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/simplex.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/simplex.test.js +383 -0
- package/ts_build/test/integration/externalservices/simplex.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/thorswap.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/thorswap.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/thorswap.test.js +316 -0
- package/ts_build/test/integration/externalservices/thorswap.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/transak.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/transak.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/transak.test.js +409 -0
- package/ts_build/test/integration/externalservices/transak.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/wyre.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/wyre.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/wyre.test.js +281 -0
- package/ts_build/test/integration/externalservices/wyre.test.js.map +1 -0
- package/ts_build/test/integration/fiatrateservice.test.d.ts +2 -0
- package/ts_build/test/integration/fiatrateservice.test.d.ts.map +1 -0
- package/ts_build/test/integration/fiatrateservice.test.js +838 -0
- package/ts_build/test/integration/fiatrateservice.test.js.map +1 -0
- package/ts_build/test/integration/helpers.d.ts +57 -0
- package/ts_build/test/integration/helpers.d.ts.map +1 -0
- package/ts_build/test/integration/helpers.js +633 -0
- package/ts_build/test/integration/helpers.js.map +1 -0
- package/ts_build/test/integration/history.test.d.ts +2 -0
- package/ts_build/test/integration/history.test.d.ts.map +1 -0
- package/ts_build/test/integration/history.test.js +1064 -0
- package/ts_build/test/integration/history.test.js.map +1 -0
- package/ts_build/test/integration/hugetx.d.ts +46 -0
- package/ts_build/test/integration/hugetx.d.ts.map +1 -0
- package/ts_build/test/integration/hugetx.js +6459 -0
- package/ts_build/test/integration/hugetx.js.map +1 -0
- package/ts_build/test/integration/pushNotifications.test.d.ts +2 -0
- package/ts_build/test/integration/pushNotifications.test.d.ts.map +1 -0
- package/ts_build/test/integration/pushNotifications.test.js +1379 -0
- package/ts_build/test/integration/pushNotifications.test.js.map +1 -0
- package/ts_build/test/integration/server.test.d.ts +2 -0
- package/ts_build/test/integration/server.test.d.ts.map +1 -0
- package/ts_build/test/integration/server.test.js +9980 -0
- package/ts_build/test/integration/server.test.js.map +1 -0
- package/ts_build/test/integration/tss.test.d.ts +2 -0
- package/ts_build/test/integration/tss.test.d.ts.map +1 -0
- package/ts_build/test/integration/tss.test.js +360 -0
- package/ts_build/test/integration/tss.test.js.map +1 -0
- package/ts_build/test/lock.test.d.ts +2 -0
- package/ts_build/test/lock.test.d.ts.map +1 -0
- package/ts_build/test/lock.test.js +226 -0
- package/ts_build/test/lock.test.js.map +1 -0
- package/ts_build/test/model/address.test.d.ts +2 -0
- package/ts_build/test/model/address.test.d.ts.map +1 -0
- package/ts_build/test/model/address.test.js +209 -0
- package/ts_build/test/model/address.test.js.map +1 -0
- package/ts_build/test/model/addressmanager.test.d.ts +2 -0
- package/ts_build/test/model/addressmanager.test.d.ts.map +1 -0
- package/ts_build/test/model/addressmanager.test.js +178 -0
- package/ts_build/test/model/addressmanager.test.js.map +1 -0
- package/ts_build/test/model/advertisement.test.d.ts +2 -0
- package/ts_build/test/model/advertisement.test.d.ts.map +1 -0
- package/ts_build/test/model/advertisement.test.js +61 -0
- package/ts_build/test/model/advertisement.test.js.map +1 -0
- package/ts_build/test/model/copayer.test.d.ts +2 -0
- package/ts_build/test/model/copayer.test.d.ts.map +1 -0
- package/ts_build/test/model/copayer.test.js +161 -0
- package/ts_build/test/model/copayer.test.js.map +1 -0
- package/ts_build/test/model/txproposal.test.d.ts +2 -0
- package/ts_build/test/model/txproposal.test.d.ts.map +1 -0
- package/ts_build/test/model/txproposal.test.js +198 -0
- package/ts_build/test/model/txproposal.test.js.map +1 -0
- package/ts_build/test/model/wallet.test.d.ts +2 -0
- package/ts_build/test/model/wallet.test.d.ts.map +1 -0
- package/ts_build/test/model/wallet.test.js +215 -0
- package/ts_build/test/model/wallet.test.js.map +1 -0
- package/ts_build/test/storage.test.d.ts +2 -0
- package/ts_build/test/storage.test.d.ts.map +1 -0
- package/ts_build/test/storage.test.js +433 -0
- package/ts_build/test/storage.test.js.map +1 -0
- package/ts_build/test/test-config.d.ts +8 -0
- package/ts_build/test/test-config.d.ts.map +1 -0
- package/ts_build/test/test-config.js +14 -0
- package/ts_build/test/test-config.js.map +1 -0
- package/ts_build/test/testdata.d.ts +91 -0
- package/ts_build/test/testdata.d.ts.map +1 -0
- package/ts_build/test/testdata.js +304 -0
- package/ts_build/test/testdata.js.map +1 -0
- package/ts_build/test/utils.test.d.ts +2 -0
- package/ts_build/test/utils.test.d.ts.map +1 -0
- package/ts_build/test/utils.test.js +450 -0
- package/ts_build/test/utils.test.js.map +1 -0
- package/ts_build/test/v8.test.d.ts +2 -0
- package/ts_build/test/v8.test.d.ts.map +1 -0
- package/ts_build/test/v8.test.js +341 -0
- package/ts_build/test/v8.test.js.map +1 -0
- package/tsconfig.json +43 -0
- package/tsconfig.prod.json +6 -0
|
@@ -0,0 +1,802 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import * as async from 'async';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import 'source-map-support/register';
|
|
6
|
+
import Mustache from 'mustache';
|
|
7
|
+
import request from 'request';
|
|
8
|
+
import defaultRequest from 'request';
|
|
9
|
+
import sjcl from 'sjcl';
|
|
10
|
+
import config from '../config';
|
|
11
|
+
import { Common } from './common';
|
|
12
|
+
import logger from './logger';
|
|
13
|
+
import { MessageBroker } from './messagebroker';
|
|
14
|
+
import { INotification, IPreferences, Preferences } from './model';
|
|
15
|
+
import { Storage } from './storage';
|
|
16
|
+
|
|
17
|
+
const Utils = Common.Utils;
|
|
18
|
+
const Defaults = Common.Defaults;
|
|
19
|
+
const Constants = Common.Constants;
|
|
20
|
+
|
|
21
|
+
const PUSHNOTIFICATIONS_TYPES = {
|
|
22
|
+
NewCopayer: {
|
|
23
|
+
filename: 'new_copayer'
|
|
24
|
+
},
|
|
25
|
+
WalletComplete: {
|
|
26
|
+
filename: 'wallet_complete'
|
|
27
|
+
},
|
|
28
|
+
NewTxProposal: {
|
|
29
|
+
filename: 'new_tx_proposal'
|
|
30
|
+
},
|
|
31
|
+
NewOutgoingTx: {
|
|
32
|
+
filename: ['new_outgoing_tx', 'new_zero_outgoing_tx']
|
|
33
|
+
},
|
|
34
|
+
NewIncomingTx: {
|
|
35
|
+
filename: ['new_incoming_tx']
|
|
36
|
+
},
|
|
37
|
+
TxProposalFinallyRejected: {
|
|
38
|
+
filename: 'txp_finally_rejected'
|
|
39
|
+
},
|
|
40
|
+
TxConfirmation: {
|
|
41
|
+
filename: ['tx_confirmation_sender', 'tx_confirmation_receiver']
|
|
42
|
+
},
|
|
43
|
+
NewAddress: {
|
|
44
|
+
dataOnly: true
|
|
45
|
+
},
|
|
46
|
+
ScanFinished: {
|
|
47
|
+
dataOnly: true,
|
|
48
|
+
broadcastToActiveUsers: true
|
|
49
|
+
},
|
|
50
|
+
NewBlock: {
|
|
51
|
+
dataOnly: true,
|
|
52
|
+
broadcastToActiveUsers: true
|
|
53
|
+
},
|
|
54
|
+
TxProposalAcceptedBy: {
|
|
55
|
+
dataOnly: true
|
|
56
|
+
},
|
|
57
|
+
TxProposalFinallyAccepted: {
|
|
58
|
+
dataOnly: true
|
|
59
|
+
},
|
|
60
|
+
TxProposalRejectedBy: {
|
|
61
|
+
dataOnly: true
|
|
62
|
+
},
|
|
63
|
+
TxProposalRemoved: {
|
|
64
|
+
dataOnly: true
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export interface IPushNotificationService {
|
|
69
|
+
templatePath: string;
|
|
70
|
+
defaultLanguage: string;
|
|
71
|
+
defaultUnit: string;
|
|
72
|
+
subjectPrefix: string;
|
|
73
|
+
pushServerUrl: string;
|
|
74
|
+
pushServerUrlBraze: string;
|
|
75
|
+
availableLanguages: string;
|
|
76
|
+
authorizationKey: string;
|
|
77
|
+
authorizationKeyBraze: string;
|
|
78
|
+
messageBroker: any;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class PushNotificationsService {
|
|
82
|
+
request: request.RequestAPI<any, any, any>;
|
|
83
|
+
templatePath: string;
|
|
84
|
+
defaultLanguage: string;
|
|
85
|
+
defaultUnit: string;
|
|
86
|
+
subjectPrefix: string;
|
|
87
|
+
pushServerUrl: string;
|
|
88
|
+
pushServerUrlBraze: string;
|
|
89
|
+
availableLanguages: string;
|
|
90
|
+
authorizationKey: string;
|
|
91
|
+
authorizationKeyBraze: string;
|
|
92
|
+
storage: Storage;
|
|
93
|
+
messageBroker: any;
|
|
94
|
+
|
|
95
|
+
start(opts, cb) {
|
|
96
|
+
opts = opts || {};
|
|
97
|
+
this.request = opts.request || defaultRequest;
|
|
98
|
+
|
|
99
|
+
const _readDirectories = (basePath, cb) => {
|
|
100
|
+
fs.readdir(basePath, (err, files) => {
|
|
101
|
+
if (err) return cb(err);
|
|
102
|
+
async.filter(
|
|
103
|
+
files,
|
|
104
|
+
(file, next: (err: boolean) => void) => {
|
|
105
|
+
fs.stat(path.join(basePath, file), (err, stats) => {
|
|
106
|
+
return next(!err && stats.isDirectory());
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
dirs => {
|
|
110
|
+
return cb(null, dirs);
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
this.templatePath = path.normalize(
|
|
117
|
+
(opts.pushNotificationsOpts.templatePath || __dirname + '../../templates') + '/'
|
|
118
|
+
);
|
|
119
|
+
this.defaultLanguage = opts.pushNotificationsOpts.defaultLanguage || 'en';
|
|
120
|
+
this.defaultUnit = opts.pushNotificationsOpts.defaultUnit || 'btc';
|
|
121
|
+
this.subjectPrefix = opts.pushNotificationsOpts.subjectPrefix || '';
|
|
122
|
+
this.pushServerUrl = opts.pushNotificationsOpts.pushServerUrl;
|
|
123
|
+
this.authorizationKey = opts.pushNotificationsOpts.authorizationKey;
|
|
124
|
+
this.pushServerUrlBraze = opts.pushNotificationsOpts.pushServerUrlBraze;
|
|
125
|
+
this.authorizationKeyBraze = opts.pushNotificationsOpts.authorizationKeyBraze;
|
|
126
|
+
|
|
127
|
+
if (!this.authorizationKey && !this.authorizationKeyBraze)
|
|
128
|
+
return cb(new Error('Missing authorizationKey attribute in configuration.'));
|
|
129
|
+
|
|
130
|
+
async.parallel(
|
|
131
|
+
[
|
|
132
|
+
done => {
|
|
133
|
+
_readDirectories(this.templatePath, (err, res) => {
|
|
134
|
+
this.availableLanguages = res;
|
|
135
|
+
done(err);
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
done => {
|
|
139
|
+
if (opts.storage) {
|
|
140
|
+
this.storage = opts.storage;
|
|
141
|
+
done();
|
|
142
|
+
} else {
|
|
143
|
+
this.storage = new Storage();
|
|
144
|
+
this.storage.connect(opts.storageOpts, done);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
done => {
|
|
148
|
+
this.messageBroker = opts.messageBroker || new MessageBroker(opts.messageBrokerOpts);
|
|
149
|
+
this.messageBroker.onMessage(_.bind(this._sendPushNotifications, this));
|
|
150
|
+
done();
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
err => {
|
|
154
|
+
if (err) {
|
|
155
|
+
logger.error('ERROR:' + err);
|
|
156
|
+
}
|
|
157
|
+
return cb(err);
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
_sendPushNotifications(notification, cb) {
|
|
163
|
+
cb = cb || function() {};
|
|
164
|
+
|
|
165
|
+
const notifType = _.cloneDeep(PUSHNOTIFICATIONS_TYPES[notification?.type]);
|
|
166
|
+
if (!notifType) return cb();
|
|
167
|
+
|
|
168
|
+
if (notification.type === 'NewIncomingTx') {
|
|
169
|
+
notifType.filename = notifType.filename[0];
|
|
170
|
+
if (notification.data.network && notification.data.network !== 'mainnet') {
|
|
171
|
+
notification.data.networkStr = ' on ' + notification.data.network;
|
|
172
|
+
} else {
|
|
173
|
+
notification.data.networkStr = '';
|
|
174
|
+
}
|
|
175
|
+
} else if (notification.type === 'NewOutgoingTx') {
|
|
176
|
+
// Handle zero amount ETH transactions to contract addresses
|
|
177
|
+
notifType.filename = notification.data.amount !== 0 ? notifType.filename[0] : notifType.filename[1];
|
|
178
|
+
} else if (notification.type === 'TxConfirmation') {
|
|
179
|
+
if (notification.data && !notification.data.amount) {
|
|
180
|
+
// backward compatibility
|
|
181
|
+
notifType.filename = 'tx_confirmation';
|
|
182
|
+
} else {
|
|
183
|
+
notifType.filename = notification.isCreator ? notifType.filename[0] : notifType.filename[1];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
logger.debug('Notification received: ' + notification.type);
|
|
188
|
+
logger.debug(JSON.stringify(notification));
|
|
189
|
+
|
|
190
|
+
this._checkShouldSendNotif(notification, (err, should) => {
|
|
191
|
+
if (err) return cb(err);
|
|
192
|
+
|
|
193
|
+
logger.debug('Should send notification: ' + should);
|
|
194
|
+
if (!should) return cb();
|
|
195
|
+
|
|
196
|
+
this._getRecipientsList(notification, notifType, (err, recipientsList) => {
|
|
197
|
+
if (err) return cb(err);
|
|
198
|
+
|
|
199
|
+
async.waterfall(
|
|
200
|
+
[
|
|
201
|
+
next => {
|
|
202
|
+
this._readAndApplyTemplates(notification, notifType, recipientsList, next);
|
|
203
|
+
},
|
|
204
|
+
(contents, next) => {
|
|
205
|
+
this._getSubscriptions(notification, notifType, recipientsList, contents, next);
|
|
206
|
+
},
|
|
207
|
+
(subs, next) => {
|
|
208
|
+
const notifications = _.map(subs, sub => {
|
|
209
|
+
if (notification.type === 'NewTxProposal' && sub.copayerId === notification.creatorId) return;
|
|
210
|
+
|
|
211
|
+
const tokenAddress =
|
|
212
|
+
notification.data && notification.data.tokenAddress ? notification.data.tokenAddress : null;
|
|
213
|
+
const multisigContractAddress =
|
|
214
|
+
notification.data && notification.data.multisigContractAddress
|
|
215
|
+
? notification.data.multisigContractAddress
|
|
216
|
+
: null;
|
|
217
|
+
|
|
218
|
+
let notificationData: any;
|
|
219
|
+
|
|
220
|
+
const walletId = sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(notification.walletId || sub.walletId));
|
|
221
|
+
const copayerId = sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(sub.copayerId));
|
|
222
|
+
const notification_type = notification.type;
|
|
223
|
+
// chain and network are needed for NewBlock notifications
|
|
224
|
+
const chain = notification?.data?.chain || notification?.data?.coin;
|
|
225
|
+
const coin = chain; // backwards compatibility
|
|
226
|
+
const network = notification?.data?.network ? Utils.getNetworkName(chain, notification.data.network) : null;
|
|
227
|
+
|
|
228
|
+
if (sub.token) {
|
|
229
|
+
notificationData = {
|
|
230
|
+
to: sub.token,
|
|
231
|
+
priority: 'high',
|
|
232
|
+
restricted_package_name: sub.packageName,
|
|
233
|
+
data: {
|
|
234
|
+
walletId,
|
|
235
|
+
tokenAddress,
|
|
236
|
+
multisigContractAddress,
|
|
237
|
+
copayerId,
|
|
238
|
+
notification_type,
|
|
239
|
+
coin, // not really coin value it's chain
|
|
240
|
+
chain,
|
|
241
|
+
network
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
if (!notifType.dataOnly) {
|
|
246
|
+
notificationData.data.title = sub?.plain?.subject;
|
|
247
|
+
notificationData.data.body = sub?.plain?.body;
|
|
248
|
+
notificationData.notification = {
|
|
249
|
+
title: sub?.plain?.subject,
|
|
250
|
+
body: sub?.plain?.body,
|
|
251
|
+
sound: 'default',
|
|
252
|
+
click_action: 'FCM_PLUGIN_ACTIVITY',
|
|
253
|
+
icon: 'fcm_push_icon'
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (sub.externalUserId) {
|
|
259
|
+
const title = sub?.plain?.subject;
|
|
260
|
+
const body = sub?.plain?.body;
|
|
261
|
+
const extras = {
|
|
262
|
+
walletId,
|
|
263
|
+
copayerId,
|
|
264
|
+
notification_type,
|
|
265
|
+
coin, // not really coin value it's chain
|
|
266
|
+
chain,
|
|
267
|
+
network,
|
|
268
|
+
tokenAddress,
|
|
269
|
+
multisigContractAddress,
|
|
270
|
+
title,
|
|
271
|
+
body
|
|
272
|
+
};
|
|
273
|
+
const custom_uri = `bitpay://wallet?walletId=${walletId}&tokenAddress=${tokenAddress}&multisigContractAddress=${multisigContractAddress}&copayerId=${copayerId}&coin=${coin}&chain=${chain}&network=${network}¬ification_type=${notification_type}&title=${title}&body=${body}`;
|
|
274
|
+
notificationData = {
|
|
275
|
+
external_user_ids: [sub.externalUserId],
|
|
276
|
+
messages: {
|
|
277
|
+
apple_push: {
|
|
278
|
+
alert: {
|
|
279
|
+
title,
|
|
280
|
+
body
|
|
281
|
+
},
|
|
282
|
+
extra: extras,
|
|
283
|
+
custom_uri
|
|
284
|
+
},
|
|
285
|
+
android_push: {
|
|
286
|
+
alert: body,
|
|
287
|
+
title,
|
|
288
|
+
extra: extras,
|
|
289
|
+
custom_uri
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
if (notifType.dataOnly) {
|
|
294
|
+
notificationData.messages.apple_push['content-available'] = true;
|
|
295
|
+
notificationData.messages.android_push['send_to_sync'] = true;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return notificationData;
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
if (
|
|
302
|
+
notifications &&
|
|
303
|
+
notifications[0] &&
|
|
304
|
+
notifications[0].notification &&
|
|
305
|
+
subs.length > Defaults.PUSH_NOTIFICATION_LIMIT
|
|
306
|
+
) {
|
|
307
|
+
logger.warn(
|
|
308
|
+
`The recipient list for this push notification is greater than the established limit (${Defaults.PUSH_NOTIFICATION_LIMIT})`
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
return next(err, notifications);
|
|
312
|
+
},
|
|
313
|
+
(notifications, next) => {
|
|
314
|
+
async.each(
|
|
315
|
+
notifications,
|
|
316
|
+
(notification: any, next) => {
|
|
317
|
+
if (notification && notification.external_user_ids) {
|
|
318
|
+
this._makeBrazeRequest(notification, (err, response) => {
|
|
319
|
+
if (err) logger.error('An error occurred making a braze push notification request:' + err);
|
|
320
|
+
if (response) {
|
|
321
|
+
// logger.debug('Request status: ' + response.statusCode);
|
|
322
|
+
// logger.debug('Request message: ' + response.statusMessage);
|
|
323
|
+
// logger.debug('Request body: ' + response.request.body);
|
|
324
|
+
}
|
|
325
|
+
next();
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// if external_user_ids is not set use old version firebase token
|
|
329
|
+
} else if (notification && notification.to) {
|
|
330
|
+
this._makeRequest(notification, (err, response) => {
|
|
331
|
+
if (err) logger.error('An error occurred making a firebase push notification request:' + err);
|
|
332
|
+
if (response) {
|
|
333
|
+
// logger.debug('Request status: ' + response.statusCode);
|
|
334
|
+
// logger.debug('Request message: ' + response.statusMessage);
|
|
335
|
+
// logger.debug('Request body: ' + response.request.body);
|
|
336
|
+
}
|
|
337
|
+
next();
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
err => {
|
|
342
|
+
return next(err);
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
],
|
|
347
|
+
err => {
|
|
348
|
+
if (err) {
|
|
349
|
+
logger.error('An error ocurred generating notification:' + err);
|
|
350
|
+
}
|
|
351
|
+
return cb(err);
|
|
352
|
+
}
|
|
353
|
+
);
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
_checkShouldSendNotif(notification, cb) {
|
|
359
|
+
if (notification.type != 'NewTxProposal') return cb(null, true);
|
|
360
|
+
this.storage.fetchWallet(notification.walletId, (err, wallet) => {
|
|
361
|
+
return cb(err, wallet && wallet.m > 1);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
_getRecipientsList(notification, notificationType, cb) {
|
|
366
|
+
if (notificationType.broadcastToActiveUsers) return cb(null, []);
|
|
367
|
+
|
|
368
|
+
this.storage.fetchWallet(notification.walletId, (err, wallet) => {
|
|
369
|
+
if (err) return cb(err);
|
|
370
|
+
if (!wallet) return cb(null, []);
|
|
371
|
+
|
|
372
|
+
let unit;
|
|
373
|
+
if (wallet.coin != Defaults.COIN) {
|
|
374
|
+
switch (wallet.coin) {
|
|
375
|
+
case 'pax':
|
|
376
|
+
unit = 'usdp'; // backwards compatibility
|
|
377
|
+
break;
|
|
378
|
+
default:
|
|
379
|
+
unit = wallet.coin;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
this.storage.fetchPreferences<Preferences[]>(notification.walletId, null, (err, preferences) => {
|
|
384
|
+
if (err) logger.error('%o', err);
|
|
385
|
+
if (_.isEmpty(preferences)) preferences = [];
|
|
386
|
+
|
|
387
|
+
const recipientPreferences = _.compact(
|
|
388
|
+
_.map(preferences, p => {
|
|
389
|
+
if (!_.includes(this.availableLanguages, p.language)) {
|
|
390
|
+
if (p.language) logger.warn('Language for notifications "' + p.language + '" not available.');
|
|
391
|
+
p.language = this.defaultLanguage;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return {
|
|
395
|
+
copayerId: p.copayerId,
|
|
396
|
+
language: p.language || this.defaultLanguage,
|
|
397
|
+
unit: unit || p.unit || this.defaultUnit
|
|
398
|
+
};
|
|
399
|
+
})
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
const copayers = _.keyBy(recipientPreferences, 'copayerId');
|
|
403
|
+
|
|
404
|
+
const recipientsList = _.compact(
|
|
405
|
+
_.map(wallet.copayers, copayer => {
|
|
406
|
+
const p = copayers[copayer.id] || {
|
|
407
|
+
language: this.defaultLanguage,
|
|
408
|
+
unit: this.defaultUnit
|
|
409
|
+
};
|
|
410
|
+
return {
|
|
411
|
+
walletId: notification.walletId,
|
|
412
|
+
copayerId: copayer.id,
|
|
413
|
+
language: p.language || this.defaultLanguage,
|
|
414
|
+
unit: unit || p.unit || this.defaultUnit
|
|
415
|
+
};
|
|
416
|
+
})
|
|
417
|
+
);
|
|
418
|
+
return cb(null, recipientsList);
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
_readAndApplyTemplates(notification, notifType, recipientsList, cb) {
|
|
424
|
+
if (!notifType.filename) return cb(null, []);
|
|
425
|
+
|
|
426
|
+
async.map(
|
|
427
|
+
recipientsList,
|
|
428
|
+
(recipient: { language: string }, next) => {
|
|
429
|
+
async.waterfall(
|
|
430
|
+
[
|
|
431
|
+
next => {
|
|
432
|
+
this._getDataForTemplate(notification, recipient, next);
|
|
433
|
+
},
|
|
434
|
+
(data, next) => {
|
|
435
|
+
async.map(
|
|
436
|
+
['plain', 'html'],
|
|
437
|
+
(type, next) => {
|
|
438
|
+
this._loadTemplate(notifType, recipient, '.' + type, (err, template) => {
|
|
439
|
+
if (err && type == 'html') return next();
|
|
440
|
+
if (err) return next(err);
|
|
441
|
+
|
|
442
|
+
this._applyTemplate(template, data, (err, res) => {
|
|
443
|
+
return next(err, [type, res]);
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
},
|
|
447
|
+
(err, res) => {
|
|
448
|
+
return next(err, _.fromPairs(res.filter(Boolean) as any[]));
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
},
|
|
452
|
+
(result, next) => {
|
|
453
|
+
next(null, result);
|
|
454
|
+
}
|
|
455
|
+
],
|
|
456
|
+
(err, res) => {
|
|
457
|
+
next(err, [recipient.language, res]);
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
},
|
|
461
|
+
(err, res) => {
|
|
462
|
+
return cb(err, _.fromPairs(res.filter(Boolean) as any[]));
|
|
463
|
+
}
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
async _getDataForTemplate(notification: INotification, recipient, cb) {
|
|
468
|
+
const UNIT_LABELS = {
|
|
469
|
+
btc: 'BTC',
|
|
470
|
+
bit: 'bits',
|
|
471
|
+
bch: 'BCH',
|
|
472
|
+
eth: 'ETH',
|
|
473
|
+
matic: 'MATIC',
|
|
474
|
+
xrp: 'XRP',
|
|
475
|
+
doge: 'DOGE',
|
|
476
|
+
ltc: 'LTC',
|
|
477
|
+
usdc: 'USDC',
|
|
478
|
+
pyusd: 'PYUSD',
|
|
479
|
+
usdp: 'USDP',
|
|
480
|
+
gusd: 'GUSD',
|
|
481
|
+
busd: 'BUSD',
|
|
482
|
+
dai: 'DAI',
|
|
483
|
+
wbtc: 'WBTC',
|
|
484
|
+
shib: 'SHIB',
|
|
485
|
+
ape: 'APE',
|
|
486
|
+
euroc: 'EUROC',
|
|
487
|
+
usdt: 'USDT',
|
|
488
|
+
weth: 'WETH',
|
|
489
|
+
'usdc.e': 'USDC.e',
|
|
490
|
+
sol: 'SOL'
|
|
491
|
+
};
|
|
492
|
+
const data = _.cloneDeep(notification.data);
|
|
493
|
+
data.subjectPrefix = _.trim(this.subjectPrefix + ' ');
|
|
494
|
+
if (data.amount) {
|
|
495
|
+
try {
|
|
496
|
+
let unit = recipient.unit.toLowerCase();
|
|
497
|
+
let label = UNIT_LABELS[unit];
|
|
498
|
+
const opts = {} as any;
|
|
499
|
+
if (data.tokenAddress) {
|
|
500
|
+
const tokenAddress = data.tokenAddress.toLowerCase();
|
|
501
|
+
if (Constants.ETH_TOKEN_OPTS[tokenAddress]) {
|
|
502
|
+
unit = Constants.ETH_TOKEN_OPTS[tokenAddress].symbol.toLowerCase();
|
|
503
|
+
label = UNIT_LABELS[unit];
|
|
504
|
+
} else if (Constants.MATIC_TOKEN_OPTS[tokenAddress]) {
|
|
505
|
+
unit = Constants.MATIC_TOKEN_OPTS[tokenAddress].symbol.toLowerCase();
|
|
506
|
+
label = UNIT_LABELS[unit];
|
|
507
|
+
} else if (Constants.ARB_TOKEN_OPTS[tokenAddress]) {
|
|
508
|
+
unit = Constants.ARB_TOKEN_OPTS[tokenAddress].symbol.toLowerCase();
|
|
509
|
+
label = UNIT_LABELS[unit];
|
|
510
|
+
} else if (Constants.OP_TOKEN_OPTS[tokenAddress]) {
|
|
511
|
+
unit = Constants.OP_TOKEN_OPTS[tokenAddress].symbol.toLowerCase();
|
|
512
|
+
label = UNIT_LABELS[unit];
|
|
513
|
+
} else if (Constants.BASE_TOKEN_OPTS[tokenAddress]) {
|
|
514
|
+
unit = Constants.BASE_TOKEN_OPTS[tokenAddress].symbol.toLowerCase();
|
|
515
|
+
label = UNIT_LABELS[unit];
|
|
516
|
+
} else if (Constants.SOL_TOKEN_OPTS[tokenAddress]) {
|
|
517
|
+
unit = Constants.SOL_TOKEN_OPTS[tokenAddress].symbol.toLowerCase();
|
|
518
|
+
label = UNIT_LABELS[unit];
|
|
519
|
+
} else {
|
|
520
|
+
let customTokensData;
|
|
521
|
+
let tokenData;
|
|
522
|
+
try {
|
|
523
|
+
customTokensData = await this.getTokenData(data.address.coin);
|
|
524
|
+
tokenData = customTokensData.find(t => t.address === tokenAddress);
|
|
525
|
+
} catch {
|
|
526
|
+
return cb(new Error('Could not get custom tokens data'));
|
|
527
|
+
}
|
|
528
|
+
if (tokenData) {
|
|
529
|
+
// check for eth tokens
|
|
530
|
+
unit = tokenData.symbol.toLowerCase();
|
|
531
|
+
label = unit.toUpperCase();
|
|
532
|
+
opts.toSatoshis = 10 ** tokenData.decimals;
|
|
533
|
+
opts.decimals = {
|
|
534
|
+
maxDecimals: 6,
|
|
535
|
+
minDecimals: 2
|
|
536
|
+
};
|
|
537
|
+
} else {
|
|
538
|
+
return cb(new Error(`Push notifications for unsupported tokens are not allowed: ${tokenAddress}`));
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
data.amount = Utils.formatAmount(+data.amount, unit, opts) + ' ' + label;
|
|
543
|
+
} catch (ex) {
|
|
544
|
+
return cb(new Error('Could not format amount' + ex));
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
this.storage.fetchWallet(notification.walletId, (err, wallet) => {
|
|
549
|
+
if (err || !wallet) return cb(err);
|
|
550
|
+
|
|
551
|
+
data.walletId = wallet.id;
|
|
552
|
+
data.walletName = wallet.name;
|
|
553
|
+
data.walletM = wallet.m;
|
|
554
|
+
data.walletN = wallet.n;
|
|
555
|
+
|
|
556
|
+
const copayer = wallet.copayers.find(c => c.id === notification.creatorId);
|
|
557
|
+
/*
|
|
558
|
+
*var copayer = _.find(wallet.copayers, {
|
|
559
|
+
* id: notification.creatorId
|
|
560
|
+
*});
|
|
561
|
+
*/
|
|
562
|
+
|
|
563
|
+
if (copayer) {
|
|
564
|
+
data.copayerId = copayer.id;
|
|
565
|
+
data.copayerName = copayer.name;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (notification.type == 'TxProposalFinallyRejected' && data.rejectedBy) {
|
|
569
|
+
const rejectors = _.map(data.rejectedBy, copayerId => {
|
|
570
|
+
return wallet.copayers.find(c => c.id === copayerId).name;
|
|
571
|
+
});
|
|
572
|
+
data.rejectorsNames = rejectors.join(', ');
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
return cb(null, data);
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
_applyTemplate(template, data, cb) {
|
|
580
|
+
if (!data) return cb(new Error('Could not apply template to empty data'));
|
|
581
|
+
|
|
582
|
+
let error;
|
|
583
|
+
const result = _.mapValues(template, t => {
|
|
584
|
+
try {
|
|
585
|
+
return Mustache.render(t, data);
|
|
586
|
+
} catch (e) {
|
|
587
|
+
logger.error('Could not apply data to template: %o', e);
|
|
588
|
+
error = e;
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
if (error) return cb(error);
|
|
593
|
+
return cb(null, result);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
_loadTemplate(notifType, recipient, extension, cb) {
|
|
597
|
+
this._readTemplateFile(recipient.language, notifType.filename + extension, (err, template) => {
|
|
598
|
+
if (err) return cb(err);
|
|
599
|
+
return cb(null, this._compileTemplate(template, extension));
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
_readTemplateFile(language, filename, cb) {
|
|
604
|
+
const fullFilename = path.join(this.templatePath, language, filename);
|
|
605
|
+
fs.readFile(fullFilename, 'utf8', (err, template) => {
|
|
606
|
+
if (err) {
|
|
607
|
+
return cb(new Error('Could not read template file ' + fullFilename + err));
|
|
608
|
+
}
|
|
609
|
+
return cb(null, template);
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
_compileTemplate(template, extension) {
|
|
614
|
+
const lines = template.split('\n');
|
|
615
|
+
if (extension == '.html') {
|
|
616
|
+
lines.unshift('');
|
|
617
|
+
}
|
|
618
|
+
return {
|
|
619
|
+
subject: lines[0],
|
|
620
|
+
body: _.tail(lines).join('\n')
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
_getSubscriptions(notification, notifType, recipientsList, contents, cb) {
|
|
625
|
+
if (notifType.broadcastToActiveUsers) {
|
|
626
|
+
this.storage.fetchLatestPushNotificationSubs((err, subs) => {
|
|
627
|
+
if (err) return cb(err);
|
|
628
|
+
|
|
629
|
+
const allSubsWithToken = _.uniqBy(
|
|
630
|
+
_.reject(subs, sub => !sub.walletId || sub.externalUserId),
|
|
631
|
+
'token'
|
|
632
|
+
);
|
|
633
|
+
const allSubsWithExternalId = _.uniqBy(
|
|
634
|
+
_.reject(subs, sub => !sub.walletId || sub.token),
|
|
635
|
+
'externalUserId'
|
|
636
|
+
);
|
|
637
|
+
// if copayerid is associated to externalUserId use Braze subscriptions
|
|
638
|
+
// avoid multiple notifications
|
|
639
|
+
const allSubs = allSubsWithExternalId.length > 0 ? allSubsWithExternalId : allSubsWithToken;
|
|
640
|
+
const chainOrCoin = notification.data.chain || notification.data.coin;
|
|
641
|
+
const networkInfo = notification.data.network;
|
|
642
|
+
const hasChainNetworkInfo = chainOrCoin && networkInfo;
|
|
643
|
+
const chainNetworkMessage = hasChainNetworkInfo ? ` [${chainOrCoin}/${networkInfo}]` : '';
|
|
644
|
+
|
|
645
|
+
logger.info(
|
|
646
|
+
`Sending ${notification.type}${chainNetworkMessage} notifications to: ${allSubs.length} devices`
|
|
647
|
+
);
|
|
648
|
+
return cb(null, allSubs);
|
|
649
|
+
});
|
|
650
|
+
} else {
|
|
651
|
+
async.map(
|
|
652
|
+
recipientsList,
|
|
653
|
+
(recipient: IPreferences, next) => {
|
|
654
|
+
const content = contents ? contents[recipient.language] : null;
|
|
655
|
+
|
|
656
|
+
this.storage.fetchPushNotificationSubs(recipient.copayerId, (err, subs) => {
|
|
657
|
+
if (err) return next(err);
|
|
658
|
+
|
|
659
|
+
const subscriptions = subs && subs.length ? subs.map(obj => ({ ...obj, plain: content?.plain })) : subs;
|
|
660
|
+
const allSubsWithToken = _.uniqBy(
|
|
661
|
+
_.reject(subscriptions, sub => !sub.walletId || sub.externalUserId),
|
|
662
|
+
'token'
|
|
663
|
+
);
|
|
664
|
+
const allSubsWithExternalId = _.uniqBy(
|
|
665
|
+
_.reject(subscriptions, sub => !sub.walletId || sub.token),
|
|
666
|
+
'externalUserId'
|
|
667
|
+
);
|
|
668
|
+
// if copayerid is associated to externalUserId use Braze subscriptions
|
|
669
|
+
// avoid multiple notifications
|
|
670
|
+
const allSubs = allSubsWithExternalId.length > 0 ? allSubsWithExternalId : allSubsWithToken;
|
|
671
|
+
return next(err, allSubs);
|
|
672
|
+
});
|
|
673
|
+
},
|
|
674
|
+
(err, allSubs) => {
|
|
675
|
+
if (err) return cb(err);
|
|
676
|
+
return cb(null, _.flatten(allSubs));
|
|
677
|
+
}
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
_makeRequest(opts, cb) {
|
|
683
|
+
this.request(
|
|
684
|
+
{
|
|
685
|
+
url: this.pushServerUrl + '/send',
|
|
686
|
+
method: 'POST',
|
|
687
|
+
json: true,
|
|
688
|
+
headers: {
|
|
689
|
+
'Content-Type': 'application/json',
|
|
690
|
+
Authorization: 'key=' + this.authorizationKey
|
|
691
|
+
},
|
|
692
|
+
body: opts
|
|
693
|
+
},
|
|
694
|
+
cb
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
_makeBrazeRequest(opts, cb) {
|
|
699
|
+
this.request(
|
|
700
|
+
{
|
|
701
|
+
url: this.pushServerUrlBraze + '/messages/send',
|
|
702
|
+
method: 'POST',
|
|
703
|
+
json: true,
|
|
704
|
+
headers: {
|
|
705
|
+
'Content-Type': 'application/json',
|
|
706
|
+
Authorization: 'Bearer ' + this.authorizationKeyBraze
|
|
707
|
+
},
|
|
708
|
+
body: opts
|
|
709
|
+
},
|
|
710
|
+
cb
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
private coinGeckoGetCredentials() {
|
|
715
|
+
if (!config.coinGecko) throw new Error('coinGecko missing credentials');
|
|
716
|
+
|
|
717
|
+
const credentials = {
|
|
718
|
+
API: config.coinGecko.api,
|
|
719
|
+
API_KEY: config.coinGecko.apiKey,
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
return credentials;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
getTokenData(chain: string): Promise<Array<{
|
|
726
|
+
chainId: number;
|
|
727
|
+
address: string;
|
|
728
|
+
symbol: string;
|
|
729
|
+
name: string;
|
|
730
|
+
decimals: number;
|
|
731
|
+
logoURI: string;
|
|
732
|
+
}>> {
|
|
733
|
+
return new Promise((resolve, reject) => {
|
|
734
|
+
const cacheKey = `cgTokenList:${chain}`;
|
|
735
|
+
const credentials = this.coinGeckoGetCredentials();
|
|
736
|
+
|
|
737
|
+
this.storage.checkAndUseGlobalCache(cacheKey, Defaults.COIN_GECKO_CACHE_DURATION, (err, values, oldvalues) => {
|
|
738
|
+
if (err) logger.warn('Cache check failed', err);
|
|
739
|
+
if (values) return resolve(values);
|
|
740
|
+
|
|
741
|
+
const assetPlatformMap = {
|
|
742
|
+
eth: 'ethereum',
|
|
743
|
+
matic: 'polygon-pos',
|
|
744
|
+
pol: 'polygon-pos',
|
|
745
|
+
arb: 'arbitrum-one',
|
|
746
|
+
base: 'base',
|
|
747
|
+
op: 'optimistic-ethereum',
|
|
748
|
+
sol: 'solana',
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
const assetId = assetPlatformMap[chain];
|
|
752
|
+
if (!assetId) return reject(new Error(`Unsupported chain '${chain}'`));
|
|
753
|
+
|
|
754
|
+
const URL: string = `${credentials.API}/v3/token_lists/${assetId}/all.json`;
|
|
755
|
+
const headers = {
|
|
756
|
+
'Content-Type': 'application/json',
|
|
757
|
+
'Accept': 'application/json',
|
|
758
|
+
'x-cg-pro-api-key': credentials.API_KEY
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
this.request.get(
|
|
762
|
+
URL,
|
|
763
|
+
{
|
|
764
|
+
headers,
|
|
765
|
+
json: true
|
|
766
|
+
},
|
|
767
|
+
(err, data) => {
|
|
768
|
+
const tokens = data?.body?.tokens;
|
|
769
|
+
const status = data?.body?.status;
|
|
770
|
+
if (err) {
|
|
771
|
+
logger.warn('An error occured while retrieving the token list', err);
|
|
772
|
+
if (oldvalues) {
|
|
773
|
+
logger.warn('Using old cached values');
|
|
774
|
+
return resolve(oldvalues);
|
|
775
|
+
}
|
|
776
|
+
return reject(err.body ?? err);
|
|
777
|
+
} else if (status?.error_code === 429 && oldvalues) {
|
|
778
|
+
return resolve(oldvalues);
|
|
779
|
+
} else {
|
|
780
|
+
if (!tokens) {
|
|
781
|
+
if (oldvalues) {
|
|
782
|
+
logger.warn('No token list available... using old cached values');
|
|
783
|
+
return resolve(oldvalues);
|
|
784
|
+
}
|
|
785
|
+
return reject(new Error(`Could not get tokens list. Code: ${status?.error_code}. Error: ${status?.error_message || 'Unknown error'}`));
|
|
786
|
+
}
|
|
787
|
+
const updatedTokens = tokens.map(token => {
|
|
788
|
+
if (token.logoURI?.includes('/thumb/')) {
|
|
789
|
+
token.logoURI = token.logoURI.replace('/thumb/', '/large/');
|
|
790
|
+
}
|
|
791
|
+
return token;
|
|
792
|
+
});
|
|
793
|
+
this.storage.storeGlobalCache(cacheKey, updatedTokens, storeErr => {
|
|
794
|
+
if (storeErr) logger.warn('Could not cache token list', storeErr);
|
|
795
|
+
return resolve(updatedTokens);
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
});
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
}
|