@ledgerhq/live-common 34.36.0 → 34.37.0-next.1
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/lib/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib/__tests__/test-helpers/bridge.js +4 -4
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/apps/config.d.ts.map +1 -1
- package/lib/apps/config.js +6 -0
- package/lib/apps/config.js.map +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.d.ts +3 -0
- package/lib/bridge/generic-alpaca/accountBridge.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/accountBridge.js +34 -0
- package/lib/bridge/generic-alpaca/accountBridge.js.map +1 -0
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts +3 -0
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/alpaca/index.js +20 -0
- package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -0
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +16 -0
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +123 -0
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -0
- package/lib/bridge/generic-alpaca/broadcast.d.ts +3 -0
- package/lib/bridge/generic-alpaca/broadcast.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/broadcast.js +11 -0
- package/lib/bridge/generic-alpaca/broadcast.js.map +1 -0
- package/lib/bridge/generic-alpaca/createTransaction.d.ts +16 -0
- package/lib/bridge/generic-alpaca/createTransaction.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/createTransaction.js +20 -0
- package/lib/bridge/generic-alpaca/createTransaction.js.map +1 -0
- package/lib/bridge/generic-alpaca/currencyBridge.d.ts +3 -0
- package/lib/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/currencyBridge.js +20 -0
- package/lib/bridge/generic-alpaca/currencyBridge.js.map +1 -0
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts +3 -0
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +26 -0
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -0
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts +3 -0
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/getAccountShape.js +58 -0
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -0
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts +3 -0
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/getTransactionStatus.js +36 -0
- package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -0
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts +3 -0
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/prepareTransaction.js +21 -0
- package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -0
- package/lib/bridge/generic-alpaca/signOperation.d.ts +7 -0
- package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/signOperation.js +49 -0
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -0
- package/lib/bridge/generic-alpaca/signer/index.d.ts +11 -0
- package/lib/bridge/generic-alpaca/signer/index.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/signer/index.js +28 -0
- package/lib/bridge/generic-alpaca/signer/index.js.map +1 -0
- package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts +5 -0
- package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/signer/signTransaction.js +11 -0
- package/lib/bridge/generic-alpaca/signer/signTransaction.js.map +1 -0
- package/lib/bridge/generic-alpaca/signer/types.d.ts +5 -0
- package/lib/bridge/generic-alpaca/signer/types.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/signer/types.js +3 -0
- package/lib/bridge/generic-alpaca/signer/types.js.map +1 -0
- package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.d.ts +2 -0
- package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +90 -0
- package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +1 -0
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.d.ts +2 -0
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js +53 -0
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -0
- package/lib/bridge/generic-alpaca/tests/signOperation.test.d.ts +2 -0
- package/lib/bridge/generic-alpaca/tests/signOperation.test.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/tests/signOperation.test.js +79 -0
- package/lib/bridge/generic-alpaca/tests/signOperation.test.js.map +1 -0
- package/lib/bridge/generic-alpaca/utils.d.ts +6 -0
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/utils.js +55 -0
- package/lib/bridge/generic-alpaca/utils.js.map +1 -0
- package/lib/bridge/impl.d.ts.map +1 -1
- package/lib/bridge/impl.js +59 -3
- package/lib/bridge/impl.js.map +1 -1
- package/lib/config/index.d.ts +3 -2
- package/lib/config/index.d.ts.map +1 -1
- package/lib/config/index.js +9 -1
- package/lib/config/index.js.map +1 -1
- package/lib/config/sharedConfig.d.ts.map +1 -1
- package/lib/config/sharedConfig.js +7 -0
- package/lib/config/sharedConfig.js.map +1 -1
- package/lib/e2e/enum/OperationType.d.ts +5 -0
- package/lib/e2e/enum/OperationType.d.ts.map +1 -0
- package/lib/e2e/enum/OperationType.js +9 -0
- package/lib/e2e/enum/OperationType.js.map +1 -0
- package/lib/e2e/enum/{Swap.d.ts → Provider.d.ts} +2 -1
- package/lib/e2e/enum/Provider.d.ts.map +1 -0
- package/lib/e2e/enum/{Swap.js → Provider.js} +2 -1
- package/lib/e2e/enum/Provider.js.map +1 -0
- package/lib/e2e/index.d.ts +4 -2
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/models/BuySell.d.ts +2 -0
- package/lib/e2e/models/BuySell.d.ts.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/families/casper/bridge.integration.test.js +2 -2
- package/lib/families/casper/bridge.integration.test.js.map +1 -1
- package/lib/families/casper/config.d.ts +2 -2
- package/lib/families/casper/config.d.ts.map +1 -1
- package/lib/families/casper/config.js +4 -0
- package/lib/families/casper/config.js.map +1 -1
- package/lib/families/casper/setup.d.ts +1 -1
- package/lib/families/casper/setup.d.ts.map +1 -1
- package/lib/families/casper/setup.js +7 -4
- package/lib/families/casper/setup.js.map +1 -1
- package/lib/families/casper/types.d.ts +1 -1
- package/lib/families/casper/types.d.ts.map +1 -1
- package/lib/families/casper/types.js +1 -1
- package/lib/families/casper/types.js.map +1 -1
- package/lib/families/xrp/setup.d.ts +3 -6
- package/lib/families/xrp/setup.d.ts.map +1 -1
- package/lib/families/xrp/setup.js +1 -7
- package/lib/families/xrp/setup.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +2 -0
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/generated/bridge/js.d.ts +0 -1
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +4 -6
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/hooks/useOFACGeoBlockCheck.d.ts +8 -0
- package/lib/hooks/useOFACGeoBlockCheck.d.ts.map +1 -0
- package/lib/hooks/useOFACGeoBlockCheck.js +32 -0
- package/lib/hooks/useOFACGeoBlockCheck.js.map +1 -0
- package/lib/hw/connectAppEventMapper.d.ts.map +1 -1
- package/lib/hw/connectAppEventMapper.js +4 -4
- package/lib/hw/connectAppEventMapper.js.map +1 -1
- package/lib/sanction/errors.d.ts +13 -0
- package/lib/sanction/errors.d.ts.map +1 -0
- package/lib/sanction/errors.js +36 -0
- package/lib/sanction/errors.js.map +1 -0
- package/lib/sanction/index.d.ts +3 -0
- package/lib/sanction/index.d.ts.map +1 -0
- package/lib/sanction/index.js +51 -0
- package/lib/sanction/index.js.map +1 -0
- package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js +4 -4
- package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib-es/apps/config.d.ts.map +1 -1
- package/lib-es/apps/config.js +6 -0
- package/lib-es/apps/config.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.d.ts +3 -0
- package/lib-es/bridge/generic-alpaca/accountBridge.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/accountBridge.js +27 -0
- package/lib-es/bridge/generic-alpaca/accountBridge.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts +3 -0
- package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/alpaca/index.js +16 -0
- package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +16 -0
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +116 -0
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/broadcast.d.ts +3 -0
- package/lib-es/bridge/generic-alpaca/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/broadcast.js +7 -0
- package/lib-es/bridge/generic-alpaca/broadcast.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/createTransaction.d.ts +16 -0
- package/lib-es/bridge/generic-alpaca/createTransaction.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/createTransaction.js +13 -0
- package/lib-es/bridge/generic-alpaca/createTransaction.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts +3 -0
- package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/currencyBridge.js +16 -0
- package/lib-es/bridge/generic-alpaca/currencyBridge.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts +3 -0
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +19 -0
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts +3 -0
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +51 -0
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts +3 -0
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +29 -0
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts +3 -0
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js +14 -0
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/signOperation.d.ts +7 -0
- package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/signOperation.js +45 -0
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/signer/index.d.ts +11 -0
- package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/signer/index.js +21 -0
- package/lib-es/bridge/generic-alpaca/signer/index.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts +5 -0
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.js +7 -0
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/signer/types.d.ts +5 -0
- package/lib-es/bridge/generic-alpaca/signer/types.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/signer/types.js +2 -0
- package/lib-es/bridge/generic-alpaca/signer/types.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.d.ts +2 -0
- package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +62 -0
- package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.d.ts +2 -0
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js +48 -0
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/tests/signOperation.test.d.ts +2 -0
- package/lib-es/bridge/generic-alpaca/tests/signOperation.test.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js +77 -0
- package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/utils.d.ts +6 -0
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/utils.js +46 -0
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -0
- package/lib-es/bridge/impl.d.ts.map +1 -1
- package/lib-es/bridge/impl.js +59 -3
- package/lib-es/bridge/impl.js.map +1 -1
- package/lib-es/config/index.d.ts +3 -2
- package/lib-es/config/index.d.ts.map +1 -1
- package/lib-es/config/index.js +8 -1
- package/lib-es/config/index.js.map +1 -1
- package/lib-es/config/sharedConfig.d.ts.map +1 -1
- package/lib-es/config/sharedConfig.js +7 -0
- package/lib-es/config/sharedConfig.js.map +1 -1
- package/lib-es/e2e/enum/OperationType.d.ts +5 -0
- package/lib-es/e2e/enum/OperationType.d.ts.map +1 -0
- package/lib-es/e2e/enum/OperationType.js +6 -0
- package/lib-es/e2e/enum/OperationType.js.map +1 -0
- package/lib-es/e2e/enum/{Swap.d.ts → Provider.d.ts} +2 -1
- package/lib-es/e2e/enum/Provider.d.ts.map +1 -0
- package/lib-es/e2e/enum/{Swap.js → Provider.js} +2 -1
- package/lib-es/e2e/enum/Provider.js.map +1 -0
- package/lib-es/e2e/index.d.ts +4 -2
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/models/BuySell.d.ts +2 -0
- package/lib-es/e2e/models/BuySell.d.ts.map +1 -1
- package/lib-es/env.react.d.ts +1 -1
- package/lib-es/env.react.d.ts.map +1 -1
- package/lib-es/families/casper/bridge.integration.test.js +1 -1
- package/lib-es/families/casper/bridge.integration.test.js.map +1 -1
- package/lib-es/families/casper/config.d.ts +2 -2
- package/lib-es/families/casper/config.d.ts.map +1 -1
- package/lib-es/families/casper/config.js +4 -0
- package/lib-es/families/casper/config.js.map +1 -1
- package/lib-es/families/casper/setup.d.ts +1 -1
- package/lib-es/families/casper/setup.d.ts.map +1 -1
- package/lib-es/families/casper/setup.js +6 -3
- package/lib-es/families/casper/setup.js.map +1 -1
- package/lib-es/families/casper/types.d.ts +1 -1
- package/lib-es/families/casper/types.d.ts.map +1 -1
- package/lib-es/families/casper/types.js +1 -1
- package/lib-es/families/casper/types.js.map +1 -1
- package/lib-es/families/xrp/setup.d.ts +3 -6
- package/lib-es/families/xrp/setup.d.ts.map +1 -1
- package/lib-es/families/xrp/setup.js +2 -7
- package/lib-es/families/xrp/setup.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +2 -0
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/generated/bridge/js.d.ts +0 -1
- package/lib-es/generated/bridge/js.d.ts.map +1 -1
- package/lib-es/generated/bridge/js.js +0 -2
- package/lib-es/generated/bridge/js.js.map +1 -1
- package/lib-es/hooks/useOFACGeoBlockCheck.d.ts +8 -0
- package/lib-es/hooks/useOFACGeoBlockCheck.d.ts.map +1 -0
- package/lib-es/hooks/useOFACGeoBlockCheck.js +28 -0
- package/lib-es/hooks/useOFACGeoBlockCheck.js.map +1 -0
- package/lib-es/hw/connectAppEventMapper.d.ts.map +1 -1
- package/lib-es/hw/connectAppEventMapper.js +5 -5
- package/lib-es/hw/connectAppEventMapper.js.map +1 -1
- package/lib-es/sanction/errors.d.ts +13 -0
- package/lib-es/sanction/errors.d.ts.map +1 -0
- package/lib-es/sanction/errors.js +29 -0
- package/lib-es/sanction/errors.js.map +1 -0
- package/lib-es/sanction/index.d.ts +3 -0
- package/lib-es/sanction/index.d.ts.map +1 -0
- package/lib-es/sanction/index.js +44 -0
- package/lib-es/sanction/index.js.map +1 -0
- package/package.json +53 -52
- package/src/__tests__/test-helpers/bridge.ts +2 -4
- package/src/apps/config.ts +6 -0
- package/src/bridge/generic-alpaca/accountBridge.ts +32 -0
- package/src/bridge/generic-alpaca/alpaca/index.ts +20 -0
- package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +182 -0
- package/src/bridge/generic-alpaca/broadcast.ts +11 -0
- package/src/bridge/generic-alpaca/createTransaction.ts +27 -0
- package/src/bridge/generic-alpaca/currencyBridge.ts +17 -0
- package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +27 -0
- package/src/bridge/generic-alpaca/getAccountShape.ts +62 -0
- package/src/bridge/generic-alpaca/getTransactionStatus.ts +38 -0
- package/src/bridge/generic-alpaca/prepareTransaction.ts +22 -0
- package/src/bridge/generic-alpaca/signOperation.ts +83 -0
- package/src/bridge/generic-alpaca/signer/index.ts +33 -0
- package/src/bridge/generic-alpaca/signer/signTransaction.ts +13 -0
- package/src/bridge/generic-alpaca/signer/types.ts +4 -0
- package/src/bridge/generic-alpaca/tests/estimateMaxSpendable.test.ts +76 -0
- package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +66 -0
- package/src/bridge/generic-alpaca/tests/signOperation.test.ts +96 -0
- package/src/bridge/generic-alpaca/utils.ts +63 -0
- package/src/bridge/impl.ts +87 -5
- package/src/config/index.ts +11 -2
- package/src/config/sharedConfig.ts +8 -0
- package/src/e2e/enum/OperationType.ts +4 -0
- package/src/e2e/enum/{Swap.ts → Provider.ts} +1 -0
- package/src/e2e/models/BuySell.ts +2 -0
- package/src/families/casper/bridge.integration.test.ts +1 -1
- package/src/families/casper/config.ts +6 -2
- package/src/families/casper/setup.ts +10 -3
- package/src/families/casper/types.ts +1 -1
- package/src/families/xrp/setup.ts +2 -15
- package/src/featureFlags/defaultFeatures.ts +2 -0
- package/src/generated/bridge/js.ts +0 -2
- package/src/hooks/useOFACGeoBlockCheck.ts +37 -0
- package/src/hw/connectAppEventMapper.ts +4 -4
- package/src/sanction/errors.ts +31 -0
- package/src/sanction/index.ts +59 -0
- package/lib/e2e/enum/Swap.d.ts.map +0 -1
- package/lib/e2e/enum/Swap.js.map +0 -1
- package/lib-es/e2e/enum/Swap.d.ts.map +0 -1
- package/lib-es/e2e/enum/Swap.js.map +0 -1
@@ -0,0 +1,83 @@
|
|
1
|
+
import { Observable } from "rxjs";
|
2
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
3
|
+
import type {
|
4
|
+
Account,
|
5
|
+
DeviceId,
|
6
|
+
SignOperationEvent,
|
7
|
+
AccountBridge,
|
8
|
+
TransactionCommon,
|
9
|
+
} from "@ledgerhq/types-live";
|
10
|
+
import { getAlpacaApi } from "./alpaca";
|
11
|
+
import { buildOptimisticOperation, transactionToIntent } from "./utils";
|
12
|
+
import { FeeNotLoaded } from "@ledgerhq/errors";
|
13
|
+
import { Result } from "@ledgerhq/coin-framework/derivation";
|
14
|
+
import { MapMemo, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Sign Transaction with Ledger hardware
|
18
|
+
*/
|
19
|
+
export const genericSignOperation =
|
20
|
+
(network, kind) =>
|
21
|
+
(signerContext: SignerContext<any>): AccountBridge<TransactionCommon>["signOperation"] =>
|
22
|
+
({
|
23
|
+
account,
|
24
|
+
transaction,
|
25
|
+
deviceId,
|
26
|
+
}: {
|
27
|
+
account: Account;
|
28
|
+
transaction: TransactionCommon;
|
29
|
+
deviceId: DeviceId;
|
30
|
+
}): Observable<SignOperationEvent> =>
|
31
|
+
new Observable(o => {
|
32
|
+
async function main() {
|
33
|
+
if (!transaction["fees"]) throw new FeeNotLoaded();
|
34
|
+
o.next({ type: "device-signature-requested" });
|
35
|
+
|
36
|
+
const { publicKey } = (await signerContext(deviceId, signer =>
|
37
|
+
signer.getAddress(account.freshAddressPath),
|
38
|
+
)) as Result;
|
39
|
+
|
40
|
+
const transactionIntent = transactionToIntent(account, transaction);
|
41
|
+
transactionIntent.senderPublicKey = publicKey;
|
42
|
+
// NOTE: is setting the memo here instead of transactionToIntent sensible?
|
43
|
+
const txWithMemo = transactionIntent as TransactionIntent<any, MapMemo<string, string>>;
|
44
|
+
if (transaction["tag"]) {
|
45
|
+
const txMemo = String(transaction["tag"]);
|
46
|
+
txWithMemo.memo = {
|
47
|
+
type: "map",
|
48
|
+
memos: new Map(),
|
49
|
+
};
|
50
|
+
txWithMemo.memo.memos.set("destinationTag", txMemo);
|
51
|
+
}
|
52
|
+
|
53
|
+
const unsigned = await getAlpacaApi(network, kind).craftTransaction({
|
54
|
+
...txWithMemo,
|
55
|
+
});
|
56
|
+
const transactionSignature: string = await signerContext(deviceId, signer =>
|
57
|
+
signer.signTransaction(account.freshAddressPath, unsigned),
|
58
|
+
);
|
59
|
+
o.next({ type: "device-signature-granted" });
|
60
|
+
|
61
|
+
const signed = await getAlpacaApi(network, kind).combine(
|
62
|
+
unsigned,
|
63
|
+
transactionSignature,
|
64
|
+
publicKey,
|
65
|
+
);
|
66
|
+
|
67
|
+
const operation = buildOptimisticOperation(account, transaction);
|
68
|
+
// NOTE: we set the transactionSequenceNumber before on the operation
|
69
|
+
// now that we create it in craftTransaction, we might need to return it back from craftTransaction also
|
70
|
+
o.next({
|
71
|
+
type: "signed",
|
72
|
+
signedOperation: {
|
73
|
+
operation,
|
74
|
+
signature: signed,
|
75
|
+
},
|
76
|
+
});
|
77
|
+
}
|
78
|
+
|
79
|
+
main().then(
|
80
|
+
() => o.complete(),
|
81
|
+
e => o.error(e),
|
82
|
+
);
|
83
|
+
});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
2
|
+
import xrpGetAddress from "@ledgerhq/coin-xrp/signer/getAddress";
|
3
|
+
import { CreateSigner, executeWithSigner } from "../../setup";
|
4
|
+
import Xrp from "@ledgerhq/hw-app-xrp";
|
5
|
+
|
6
|
+
import Transport from "@ledgerhq/hw-transport";
|
7
|
+
import { signTransaction } from "./signTransaction";
|
8
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
9
|
+
import { SignTransactionOptions } from "./types";
|
10
|
+
|
11
|
+
export type AlpacaSigner = {
|
12
|
+
getAddress: GetAddressFn;
|
13
|
+
signTransaction?: (deviceId: string, opts: SignTransactionOptions) => Promise<string>;
|
14
|
+
signMessage?: (message: string) => Promise<string>;
|
15
|
+
context: SignerContext<any>;
|
16
|
+
};
|
17
|
+
|
18
|
+
export function getSigner(network): AlpacaSigner {
|
19
|
+
switch (network) {
|
20
|
+
case "ripple":
|
21
|
+
case "xrp": {
|
22
|
+
const createSigner: CreateSigner<Xrp> = (transport: Transport) => {
|
23
|
+
return new Xrp(transport);
|
24
|
+
};
|
25
|
+
return {
|
26
|
+
getAddress: xrpGetAddress(executeWithSigner(createSigner)),
|
27
|
+
signTransaction: signTransaction(executeWithSigner(createSigner)),
|
28
|
+
context: executeWithSigner(createSigner),
|
29
|
+
};
|
30
|
+
}
|
31
|
+
}
|
32
|
+
throw new Error(`signer for ${network} not implemented`);
|
33
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
2
|
+
import { XrpSigner } from "@ledgerhq/coin-xrp/index";
|
3
|
+
import { SignTransactionOptions } from "./types";
|
4
|
+
|
5
|
+
export const signTransaction = (signerContext: SignerContext<XrpSigner>) => {
|
6
|
+
return async (deviceId: string, { path, rawTxHex }: SignTransactionOptions) => {
|
7
|
+
const signedTx = await signerContext(deviceId, signer =>
|
8
|
+
signer.signTransaction(path, rawTxHex),
|
9
|
+
);
|
10
|
+
|
11
|
+
return signedTx;
|
12
|
+
};
|
13
|
+
};
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import BigNumber from "bignumber.js";
|
2
|
+
import { genericEstimateMaxSpendable } from "../estimateMaxSpendable";
|
3
|
+
import * as alpaca from "../alpaca";
|
4
|
+
import { Account } from "@ledgerhq/types-live";
|
5
|
+
|
6
|
+
// Mock the alpaca API
|
7
|
+
jest.mock("../alpaca", () => ({
|
8
|
+
getAlpacaApi: jest.fn(),
|
9
|
+
}));
|
10
|
+
|
11
|
+
const mockedGetAlpacaApi = alpaca.getAlpacaApi as jest.Mock;
|
12
|
+
|
13
|
+
// Dummy data
|
14
|
+
const dummyAccount = {
|
15
|
+
id: "js:2:ripple:r123:",
|
16
|
+
type: "Account", // <-- this is mandatory for getMainAccount to work
|
17
|
+
spendableBalance: new BigNumber(50000000),
|
18
|
+
currency: { id: "ripple", name: "XRP", units: [{ name: "XRP", magnitude: 6 }] },
|
19
|
+
freshAddress: "r123",
|
20
|
+
} as unknown as Account;
|
21
|
+
|
22
|
+
describe("genericEstimateMaxSpendable", () => {
|
23
|
+
afterEach(() => {
|
24
|
+
jest.clearAllMocks();
|
25
|
+
});
|
26
|
+
|
27
|
+
it("subtracts estimated fee from spendable balance", async () => {
|
28
|
+
mockedGetAlpacaApi.mockReturnValue({
|
29
|
+
estimateFees: jest.fn().mockResolvedValue({ value: 10000n }), // 0.01 XRP
|
30
|
+
});
|
31
|
+
|
32
|
+
const estimate = genericEstimateMaxSpendable("xrp", "local");
|
33
|
+
const result = await estimate({
|
34
|
+
account: dummyAccount,
|
35
|
+
parentAccount: null,
|
36
|
+
transaction: {},
|
37
|
+
});
|
38
|
+
|
39
|
+
expect(result.toString()).toBe("49990000"); // 50_000_000 - 10_000
|
40
|
+
});
|
41
|
+
|
42
|
+
it("returns 0 if fee is higher than spendable", async () => {
|
43
|
+
const poorAccount = {
|
44
|
+
...dummyAccount,
|
45
|
+
spendableBalance: new BigNumber(5000), // very low
|
46
|
+
};
|
47
|
+
|
48
|
+
mockedGetAlpacaApi.mockReturnValue({
|
49
|
+
estimateFees: jest.fn().mockResolvedValue({ value: 10000n }),
|
50
|
+
});
|
51
|
+
|
52
|
+
const estimate = genericEstimateMaxSpendable("xrp", "local");
|
53
|
+
const result = await estimate({
|
54
|
+
account: poorAccount,
|
55
|
+
parentAccount: null,
|
56
|
+
transaction: {},
|
57
|
+
});
|
58
|
+
|
59
|
+
expect(result.toString()).toBe("0");
|
60
|
+
});
|
61
|
+
|
62
|
+
it("returns full spendable balance if fee is 0", async () => {
|
63
|
+
mockedGetAlpacaApi.mockReturnValue({
|
64
|
+
estimateFees: jest.fn().mockResolvedValue({ value: 0n }),
|
65
|
+
});
|
66
|
+
|
67
|
+
const estimate = genericEstimateMaxSpendable("xrp", "local");
|
68
|
+
const result = await estimate({
|
69
|
+
account: dummyAccount,
|
70
|
+
parentAccount: null,
|
71
|
+
transaction: {},
|
72
|
+
});
|
73
|
+
|
74
|
+
expect(result.toString()).toBe("50000000");
|
75
|
+
});
|
76
|
+
});
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { genericPrepareTransaction } from "../prepareTransaction";
|
2
|
+
import { getAlpacaApi } from "../alpaca";
|
3
|
+
import { transactionToIntent } from "../utils";
|
4
|
+
import BigNumber from "bignumber.js";
|
5
|
+
import type { TransactionCommon } from "@ledgerhq/types-live";
|
6
|
+
|
7
|
+
jest.mock("../alpaca", () => ({
|
8
|
+
getAlpacaApi: jest.fn(),
|
9
|
+
}));
|
10
|
+
|
11
|
+
jest.mock("../utils", () => ({
|
12
|
+
transactionToIntent: jest.fn(),
|
13
|
+
}));
|
14
|
+
|
15
|
+
describe("genericPrepareTransaction", () => {
|
16
|
+
const network = "testnet";
|
17
|
+
const kind = "local";
|
18
|
+
|
19
|
+
const account = {
|
20
|
+
id: "test-account",
|
21
|
+
address: "0xabc",
|
22
|
+
} as any;
|
23
|
+
|
24
|
+
const baseTransaction: TransactionCommon & { fees: BigNumber } = {
|
25
|
+
amount: new BigNumber(100_000),
|
26
|
+
fees: new BigNumber(500),
|
27
|
+
recipient: "0xrecipient",
|
28
|
+
};
|
29
|
+
|
30
|
+
const txIntent = { mock: "intent" };
|
31
|
+
|
32
|
+
beforeEach(() => {
|
33
|
+
jest.clearAllMocks();
|
34
|
+
(transactionToIntent as jest.Mock).mockReturnValue(txIntent);
|
35
|
+
});
|
36
|
+
|
37
|
+
it("updates fees if they differ", async () => {
|
38
|
+
const newFee = new BigNumber(700);
|
39
|
+
|
40
|
+
(getAlpacaApi as jest.Mock).mockReturnValue({
|
41
|
+
estimateFees: jest.fn().mockResolvedValue({ value: newFee }),
|
42
|
+
});
|
43
|
+
|
44
|
+
const prepareTransaction = genericPrepareTransaction(network, kind);
|
45
|
+
const result = await prepareTransaction(account, { ...baseTransaction });
|
46
|
+
|
47
|
+
expect((result as any).fees.toString()).toBe(newFee.toString());
|
48
|
+
expect(transactionToIntent).toHaveBeenCalledWith(
|
49
|
+
account,
|
50
|
+
expect.objectContaining(baseTransaction),
|
51
|
+
);
|
52
|
+
});
|
53
|
+
|
54
|
+
it("returns original transaction if fees are the same", async () => {
|
55
|
+
const sameFee = baseTransaction.fees;
|
56
|
+
|
57
|
+
(getAlpacaApi as jest.Mock).mockReturnValue({
|
58
|
+
estimateFees: jest.fn().mockResolvedValue({ value: sameFee }),
|
59
|
+
});
|
60
|
+
|
61
|
+
const prepareTransaction = genericPrepareTransaction(network, kind);
|
62
|
+
const result = await prepareTransaction(account, { ...baseTransaction });
|
63
|
+
|
64
|
+
expect(result).toStrictEqual(baseTransaction);
|
65
|
+
});
|
66
|
+
});
|
@@ -0,0 +1,96 @@
|
|
1
|
+
import { lastValueFrom } from "rxjs";
|
2
|
+
import { toArray } from "rxjs/operators";
|
3
|
+
import { genericSignOperation } from "../signOperation";
|
4
|
+
import { FeeNotLoaded } from "@ledgerhq/errors";
|
5
|
+
import { getAlpacaApi } from "../alpaca";
|
6
|
+
import { buildOptimisticOperation, transactionToIntent } from "../utils";
|
7
|
+
|
8
|
+
jest.mock("../alpaca", () => ({
|
9
|
+
getAlpacaApi: jest.fn(),
|
10
|
+
}));
|
11
|
+
|
12
|
+
jest.mock("../utils", () => ({
|
13
|
+
buildOptimisticOperation: jest.fn(),
|
14
|
+
transactionToIntent: jest.fn(),
|
15
|
+
}));
|
16
|
+
|
17
|
+
describe("genericSignOperation", () => {
|
18
|
+
const network = "xrp";
|
19
|
+
const kind = "local";
|
20
|
+
|
21
|
+
const mockSignerContext = jest.fn();
|
22
|
+
const mockSigner = {
|
23
|
+
getAddress: jest.fn(),
|
24
|
+
signTransaction: jest.fn(),
|
25
|
+
};
|
26
|
+
|
27
|
+
const account = {
|
28
|
+
freshAddressPath: "44'/144'/0'/0/0",
|
29
|
+
address: "rTestAddress",
|
30
|
+
} as any;
|
31
|
+
|
32
|
+
const transaction = {
|
33
|
+
amount: 100_000n,
|
34
|
+
fees: 500n,
|
35
|
+
tag: 1234,
|
36
|
+
} as any;
|
37
|
+
|
38
|
+
const deviceId = "mockDevice";
|
39
|
+
|
40
|
+
const txIntent = {
|
41
|
+
memo: {
|
42
|
+
type: "map",
|
43
|
+
memos: new Map(),
|
44
|
+
},
|
45
|
+
};
|
46
|
+
|
47
|
+
const unsignedTx = "unsignedTx";
|
48
|
+
const signedTx = "signedTx";
|
49
|
+
const pubKey = "pubKey";
|
50
|
+
|
51
|
+
beforeEach(() => {
|
52
|
+
jest.clearAllMocks();
|
53
|
+
|
54
|
+
(getAlpacaApi as jest.Mock).mockReturnValue({
|
55
|
+
craftTransaction: jest.fn().mockResolvedValue(unsignedTx),
|
56
|
+
combine: jest.fn().mockResolvedValue(signedTx),
|
57
|
+
});
|
58
|
+
|
59
|
+
(transactionToIntent as jest.Mock).mockReturnValue(txIntent);
|
60
|
+
(buildOptimisticOperation as jest.Mock).mockReturnValue({ id: "mock-op" });
|
61
|
+
|
62
|
+
mockSigner.getAddress.mockResolvedValue({ publicKey: pubKey });
|
63
|
+
mockSigner.signTransaction.mockResolvedValue("sig");
|
64
|
+
mockSignerContext.mockImplementation(async (_deviceId, cb) => cb(mockSigner));
|
65
|
+
});
|
66
|
+
|
67
|
+
it("emits full sign operation flow", async () => {
|
68
|
+
const signOperation = genericSignOperation(network, kind)(mockSignerContext);
|
69
|
+
const observable = signOperation({ account, transaction, deviceId });
|
70
|
+
|
71
|
+
const events = await lastValueFrom(observable.pipe(toArray()));
|
72
|
+
|
73
|
+
expect(events[0]).toEqual({ type: "device-signature-requested" });
|
74
|
+
expect(events[1]).toEqual({ type: "device-signature-granted" });
|
75
|
+
expect(events[2]).toEqual({
|
76
|
+
type: "signed",
|
77
|
+
signedOperation: {
|
78
|
+
operation: { id: "mock-op" },
|
79
|
+
signature: signedTx,
|
80
|
+
},
|
81
|
+
});
|
82
|
+
|
83
|
+
expect(transactionToIntent).toHaveBeenCalledWith(account, transaction);
|
84
|
+
expect(txIntent.memo.memos.get("destinationTag")).toBe("1234");
|
85
|
+
});
|
86
|
+
|
87
|
+
it("throws FeeNotLoaded if fees are missing", async () => {
|
88
|
+
const txWithoutFees = { ...transaction };
|
89
|
+
delete txWithoutFees.fees;
|
90
|
+
|
91
|
+
const signOperation = genericSignOperation(network, kind)(mockSignerContext);
|
92
|
+
const observable = signOperation({ account, transaction: txWithoutFees, deviceId });
|
93
|
+
|
94
|
+
await expect(observable.toPromise()).rejects.toThrow(FeeNotLoaded);
|
95
|
+
});
|
96
|
+
});
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
2
|
+
import { Account, Operation, OperationType, TransactionCommon } from "@ledgerhq/types-live";
|
3
|
+
import {
|
4
|
+
Operation as CoreOperation,
|
5
|
+
Asset,
|
6
|
+
TransactionIntent,
|
7
|
+
} from "@ledgerhq/coin-framework/api/types";
|
8
|
+
import BigNumber from "bignumber.js";
|
9
|
+
import { fromBigNumberToBigInt } from "@ledgerhq/coin-framework/utils";
|
10
|
+
|
11
|
+
export function adaptCoreOperationToLiveOperation(
|
12
|
+
accountId: string,
|
13
|
+
op: CoreOperation<Asset>,
|
14
|
+
): Operation {
|
15
|
+
return {
|
16
|
+
id: encodeOperationId(accountId, op.tx.hash, op.type),
|
17
|
+
hash: op.tx.hash,
|
18
|
+
accountId,
|
19
|
+
type: op.type as OperationType,
|
20
|
+
value: new BigNumber(op.value.toString()),
|
21
|
+
fee: new BigNumber(op.tx.fees.toString()),
|
22
|
+
blockHash: op.tx.block.hash,
|
23
|
+
blockHeight: op.tx.block.height,
|
24
|
+
senders: op.senders,
|
25
|
+
recipients: op.recipients,
|
26
|
+
date: op.tx.date,
|
27
|
+
transactionSequenceNumber: op.details?.sequence as number,
|
28
|
+
extra: {},
|
29
|
+
};
|
30
|
+
}
|
31
|
+
|
32
|
+
export function transactionToIntent(
|
33
|
+
_account: Account,
|
34
|
+
transaction: TransactionCommon,
|
35
|
+
): TransactionIntent<any> {
|
36
|
+
return {
|
37
|
+
type: "Payment",
|
38
|
+
sender: _account.freshAddress,
|
39
|
+
recipient: transaction.recipient,
|
40
|
+
amount: fromBigNumberToBigInt(transaction.amount, BigInt(0)),
|
41
|
+
asset: null,
|
42
|
+
};
|
43
|
+
}
|
44
|
+
|
45
|
+
export const buildOptimisticOperation = (
|
46
|
+
account: Account,
|
47
|
+
transaction: TransactionCommon,
|
48
|
+
): Operation => {
|
49
|
+
return {
|
50
|
+
id: encodeOperationId(account.id, "", "OUT"),
|
51
|
+
hash: "",
|
52
|
+
type: "OUT",
|
53
|
+
value: transaction.amount,
|
54
|
+
fee: transaction["fees"] ?? BigNumber(0),
|
55
|
+
blockHash: null,
|
56
|
+
blockHeight: null,
|
57
|
+
senders: [account.freshAddress.toString()],
|
58
|
+
recipients: [transaction.recipient],
|
59
|
+
accountId: account.id,
|
60
|
+
date: new Date(),
|
61
|
+
extra: {},
|
62
|
+
};
|
63
|
+
};
|
package/src/bridge/impl.ts
CHANGED
@@ -1,11 +1,29 @@
|
|
1
|
+
import { isAddressSanctioned } from "../sanction";
|
1
2
|
import { CurrencyNotSupported } from "@ledgerhq/errors";
|
2
|
-
import { decodeAccountId, getMainAccount } from "../account";
|
3
3
|
import { getEnv } from "@ledgerhq/live-env";
|
4
|
+
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
5
|
+
import {
|
6
|
+
Account,
|
7
|
+
AccountBridge,
|
8
|
+
AccountLike,
|
9
|
+
CurrencyBridge,
|
10
|
+
TransactionStatusCommon,
|
11
|
+
} from "@ledgerhq/types-live";
|
12
|
+
import { decodeAccountId, getMainAccount } from "../account";
|
4
13
|
import { checkAccountSupported } from "../account/index";
|
5
14
|
import jsBridges from "../generated/bridge/js";
|
6
15
|
import mockBridges from "../generated/bridge/mock";
|
7
|
-
import
|
8
|
-
import {
|
16
|
+
import { RecipientAddressSanctionedError, UserAddressSanctionedError } from "../sanction/errors";
|
17
|
+
import { getAlpacaCurrencyBridge } from "./generic-alpaca/currencyBridge";
|
18
|
+
import { getAlpacaAccountBridge } from "./generic-alpaca/accountBridge";
|
19
|
+
import { TransactionCommon } from "@ledgerhq/types-live";
|
20
|
+
|
21
|
+
const alpacaized = {
|
22
|
+
xrp: true,
|
23
|
+
};
|
24
|
+
|
25
|
+
let accountBridgeInstance: AccountBridge<any> | null = null;
|
26
|
+
let currencyBridgeInstance: CurrencyBridge | null = null;
|
9
27
|
|
10
28
|
export const getCurrencyBridge = (currency: CryptoCurrency): CurrencyBridge => {
|
11
29
|
if (getEnv("MOCK")) {
|
@@ -16,6 +34,13 @@ export const getCurrencyBridge = (currency: CryptoCurrency): CurrencyBridge => {
|
|
16
34
|
});
|
17
35
|
}
|
18
36
|
|
37
|
+
if (alpacaized[currency.family]) {
|
38
|
+
if (!currencyBridgeInstance) {
|
39
|
+
currencyBridgeInstance = getAlpacaCurrencyBridge(currency.family, "local");
|
40
|
+
}
|
41
|
+
return currencyBridgeInstance;
|
42
|
+
}
|
43
|
+
|
19
44
|
const jsBridge = jsBridges[currency.family];
|
20
45
|
if (jsBridge) {
|
21
46
|
return jsBridge.currencyBridge;
|
@@ -57,9 +82,66 @@ export function getAccountBridgeByFamily(family: string, accountId?: string): Ac
|
|
57
82
|
}
|
58
83
|
}
|
59
84
|
|
85
|
+
if (alpacaized[family]) {
|
86
|
+
if (!accountBridgeInstance) {
|
87
|
+
accountBridgeInstance = getAlpacaAccountBridge(family, "local");
|
88
|
+
}
|
89
|
+
return accountBridgeInstance;
|
90
|
+
}
|
91
|
+
|
60
92
|
const jsBridge = jsBridges[family];
|
61
93
|
if (!jsBridge) {
|
62
|
-
throw new CurrencyNotSupported("currency bridge not found " + family);
|
94
|
+
throw new CurrencyNotSupported("account currency bridge not found " + family);
|
63
95
|
}
|
64
|
-
return jsBridge.accountBridge;
|
96
|
+
return wrapAccountBridge(jsBridge.accountBridge);
|
97
|
+
}
|
98
|
+
|
99
|
+
function wrapAccountBridge<T extends TransactionCommon>(
|
100
|
+
bridge: AccountBridge<T>,
|
101
|
+
): AccountBridge<T> {
|
102
|
+
return {
|
103
|
+
...bridge,
|
104
|
+
getTransactionStatus: async (...args) => {
|
105
|
+
const blockchainSpecific = await bridge.getTransactionStatus(...args);
|
106
|
+
const common = await commonGetTransactionStatus(...args);
|
107
|
+
const merged = mergeResults(blockchainSpecific, common);
|
108
|
+
return merged;
|
109
|
+
},
|
110
|
+
};
|
111
|
+
}
|
112
|
+
|
113
|
+
function mergeResults(
|
114
|
+
blockchainSpecific: TransactionStatusCommon,
|
115
|
+
common: Partial<TransactionStatusCommon>,
|
116
|
+
): TransactionStatusCommon {
|
117
|
+
const errors = { ...blockchainSpecific.errors, ...common.errors };
|
118
|
+
const warnings = { ...blockchainSpecific.warnings, ...common.warnings };
|
119
|
+
return { ...blockchainSpecific, errors, warnings };
|
120
|
+
}
|
121
|
+
|
122
|
+
async function commonGetTransactionStatus(
|
123
|
+
account: Account,
|
124
|
+
transaction: TransactionCommon,
|
125
|
+
): Promise<Partial<TransactionStatusCommon>> {
|
126
|
+
const errors: Record<string, Error> = {};
|
127
|
+
const warnings: Record<string, Error> = {};
|
128
|
+
|
129
|
+
let recipientIsBlacklisted = false;
|
130
|
+
if (transaction.recipient && transaction.recipient !== "") {
|
131
|
+
recipientIsBlacklisted = await isAddressSanctioned(account.currency, transaction.recipient);
|
132
|
+
if (recipientIsBlacklisted) {
|
133
|
+
errors.recipient = new RecipientAddressSanctionedError();
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
const userIsBlacklisted = await isAddressSanctioned(account.currency, account.freshAddress);
|
138
|
+
if (userIsBlacklisted) {
|
139
|
+
errors.amount = new UserAddressSanctionedError();
|
140
|
+
}
|
141
|
+
|
142
|
+
if (userIsBlacklisted || recipientIsBlacklisted) {
|
143
|
+
// Send log
|
144
|
+
}
|
145
|
+
|
146
|
+
return { errors, warnings };
|
65
147
|
}
|
package/src/config/index.ts
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
|
2
2
|
import { ConfigInfo, LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
3
|
-
import { CurrencyConfig } from "@ledgerhq/coin-framework/config";
|
3
|
+
import { CurrencyConfig, SharedConfig } from "@ledgerhq/coin-framework/config";
|
4
4
|
|
5
5
|
export type CurrencyLiveConfigDefinition = Partial<
|
6
6
|
Record<`config_currency_${CryptoCurrencyId}`, ConfigInfo>
|
7
7
|
>;
|
8
8
|
|
9
|
+
const getSharedConfiguration = (): SharedConfig => {
|
10
|
+
const config = LiveConfig.getValueByKey("config_currency");
|
11
|
+
if (!config) {
|
12
|
+
throw new Error("Configuration config_currency not found, please check Firebase Remote Config");
|
13
|
+
}
|
14
|
+
|
15
|
+
return config;
|
16
|
+
};
|
17
|
+
|
9
18
|
const getCurrencyConfiguration = <T extends CurrencyConfig>(
|
10
19
|
currency: CryptoCurrency,
|
11
20
|
): T & Record<string, unknown> => {
|
@@ -17,4 +26,4 @@ const getCurrencyConfiguration = <T extends CurrencyConfig>(
|
|
17
26
|
return currencyData;
|
18
27
|
};
|
19
28
|
|
20
|
-
export { getCurrencyConfiguration };
|
29
|
+
export { getCurrencyConfiguration, getSharedConfiguration };
|
@@ -36,6 +36,13 @@ const countervaluesConfig: ConfigSchema = {
|
|
36
36
|
},
|
37
37
|
};
|
38
38
|
|
39
|
+
const sharedCurrencyConfig: ConfigSchema = {
|
40
|
+
config_currency: {
|
41
|
+
type: "object",
|
42
|
+
default: {},
|
43
|
+
},
|
44
|
+
};
|
45
|
+
|
39
46
|
const liveCommonConfig: ConfigSchema = {
|
40
47
|
...appConfig,
|
41
48
|
};
|
@@ -67,4 +74,5 @@ export const liveConfig: ConfigSchema = {
|
|
67
74
|
...iconConfig,
|
68
75
|
...tonConfig,
|
69
76
|
...suiConfig,
|
77
|
+
...sharedCurrencyConfig,
|
70
78
|
};
|
@@ -15,6 +15,7 @@ export class Provider {
|
|
15
15
|
static readonly UNISWAP = new Provider("uniswap", "Uniswap", false, false, false);
|
16
16
|
static readonly LIFI = new Provider("lifi", "LI.FI", false, true, false);
|
17
17
|
static readonly CIC = new Provider("cic", "CIC", false, true, true);
|
18
|
+
static readonly COINBASE = new Provider("coinbase", "Coinbase", false, true, true);
|
18
19
|
|
19
20
|
static getNameByUiName(uiName: string): string {
|
20
21
|
const provider = Object.values(Provider).find(p => p.uiName === uiName);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { AccountType } from "../enum/Account";
|
2
|
+
import { OperationType } from "../enum/OperationType";
|
2
3
|
|
3
4
|
export interface Fiat {
|
4
5
|
locale: string;
|
@@ -9,4 +10,5 @@ export interface BuySell {
|
|
9
10
|
crypto: AccountType;
|
10
11
|
fiat: Fiat;
|
11
12
|
amount: string;
|
13
|
+
operation: OperationType;
|
12
14
|
}
|
@@ -1,12 +1,16 @@
|
|
1
|
-
import {
|
1
|
+
import { CurrencyLiveConfigDefinition } from "../../config";
|
2
2
|
|
3
|
-
export const casperConfig:
|
3
|
+
export const casperConfig: CurrencyLiveConfigDefinition = {
|
4
4
|
config_currency_casper: {
|
5
5
|
type: "object",
|
6
6
|
default: {
|
7
7
|
status: {
|
8
8
|
type: "active",
|
9
9
|
},
|
10
|
+
infra: {
|
11
|
+
API_CASPER_NODE_ENDPOINT: "https://casper.coin.ledger.com/node/",
|
12
|
+
API_CASPER_INDEXER: "https://casper.coin.ledger.com/indexer/",
|
13
|
+
},
|
10
14
|
},
|
11
15
|
},
|
12
16
|
};
|