@ledgerhq/live-common 34.45.0 → 34.45.1-nightly.0
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 +3 -1
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.d.ts +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/accountBridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/index.js +4 -2
- package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +4 -4
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +10 -10
- package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib/bridge/generic-alpaca/broadcast.d.ts +1 -1
- package/lib/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/broadcast.js.map +1 -1
- package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts +17 -0
- package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/buildSubAccounts.js +75 -0
- package/lib/bridge/generic-alpaca/buildSubAccounts.js.map +1 -0
- package/lib/bridge/generic-alpaca/createTransaction.d.ts +17 -9
- package/lib/bridge/generic-alpaca/createTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/createTransaction.js +36 -10
- package/lib/bridge/generic-alpaca/createTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/currencyBridge.d.ts +1 -1
- package/lib/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/currencyBridge.js.map +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +9 -0
- package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getAccountShape.js +66 -37
- package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/getTransactionStatus.js +27 -15
- package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts +5 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/prepareTransaction.js +28 -5
- package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.d.ts +1 -1
- package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signOperation.js +68 -13
- package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/index.d.ts +1 -1
- package/lib/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signer/index.js +38 -5
- package/lib/bridge/generic-alpaca/signer/index.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts +2 -0
- package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/signer/signTransaction.js +8 -1
- package/lib/bridge/generic-alpaca/signer/signTransaction.js.map +1 -1
- package/lib/bridge/generic-alpaca/signer/types.d.ts +3 -0
- package/lib/bridge/generic-alpaca/signer/types.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +70 -46
- package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
- package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/tests/signOperation.test.js +25 -22
- package/lib/bridge/generic-alpaca/tests/signOperation.test.js.map +1 -1
- package/lib/bridge/generic-alpaca/tests/utils.test.d.ts.map +1 -0
- package/lib/bridge/generic-alpaca/{utils.test.js → tests/utils.test.js} +1 -1
- package/lib/bridge/generic-alpaca/tests/utils.test.js.map +1 -0
- package/lib/bridge/generic-alpaca/utils.d.ts +36 -1
- package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +130 -14
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/impl.d.ts.map +1 -1
- package/lib/bridge/impl.js +5 -4
- package/lib/bridge/impl.js.map +1 -1
- package/lib/e2e/enum/Account.js +4 -4
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/AppInfos.d.ts +1 -1
- package/lib/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib/e2e/enum/AppInfos.js +1 -1
- package/lib/e2e/enum/AppInfos.js.map +1 -1
- package/lib/e2e/enum/Currency.d.ts +3 -1
- package/lib/e2e/enum/Currency.d.ts.map +1 -1
- package/lib/e2e/enum/Currency.js +102 -42
- package/lib/e2e/enum/Currency.js.map +1 -1
- package/lib/e2e/enum/Network.d.ts +34 -0
- package/lib/e2e/enum/Network.d.ts.map +1 -0
- package/lib/e2e/enum/Network.js +38 -0
- package/lib/e2e/enum/Network.js.map +1 -0
- package/lib/e2e/speculos.js +2 -2
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/exchange/index.d.ts.map +1 -1
- package/lib/exchange/index.js +1 -0
- package/lib/exchange/index.js.map +1 -1
- package/lib/families/evm/config.js +1 -1
- package/lib/families/evm/config.js.map +1 -1
- package/lib/families/stellar/bridge/logic.d.ts +1 -1
- package/lib/families/stellar/bridge/logic.d.ts.map +1 -1
- package/lib/families/stellar/bridge/logic.js +1 -1
- package/lib/families/stellar/bridge/logic.js.map +1 -1
- package/lib/families/stellar/bridge/mock.js +2 -2
- package/lib/families/stellar/bridge/mock.js.map +1 -1
- package/lib/families/stellar/setup.d.ts +3 -6
- package/lib/families/stellar/setup.d.ts.map +1 -1
- package/lib/families/stellar/setup.js +3 -12
- package/lib/families/stellar/setup.js.map +1 -1
- package/lib/families/xrp/bridge/mock.js +2 -2
- package/lib/families/xrp/bridge/mock.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +4 -2
- package/lib/featureFlags/defaultFeatures.js.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 +12 -14
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/generated/transaction.d.ts +1 -1
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.js +229 -14
- package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.js.map +1 -1
- package/lib/modularDrawer/enums.d.ts +0 -1
- package/lib/modularDrawer/enums.d.ts.map +1 -1
- package/lib/modularDrawer/enums.js +0 -1
- package/lib/modularDrawer/enums.js.map +1 -1
- package/lib/modularDrawer/useModularDrawerVisibility.d.ts +7 -1
- package/lib/modularDrawer/useModularDrawerVisibility.d.ts.map +1 -1
- package/lib/modularDrawer/useModularDrawerVisibility.js +18 -2
- package/lib/modularDrawer/useModularDrawerVisibility.js.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib-es/__tests__/test-helpers/bridge.js +3 -1
- package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/accountBridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/index.js +4 -2
- package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +4 -4
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +10 -10
- package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/broadcast.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/broadcast.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts +17 -0
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.js +65 -0
- package/lib-es/bridge/generic-alpaca/buildSubAccounts.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/createTransaction.d.ts +17 -9
- package/lib-es/bridge/generic-alpaca/createTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/createTransaction.js +35 -9
- package/lib-es/bridge/generic-alpaca/createTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/currencyBridge.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +9 -0
- package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getAccountShape.js +66 -37
- package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +27 -15
- package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts +5 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js +26 -4
- package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signOperation.js +65 -13
- package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.d.ts +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/index.js +39 -6
- package/lib-es/bridge/generic-alpaca/signer/index.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts +2 -0
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.js +6 -0
- package/lib-es/bridge/generic-alpaca/signer/signTransaction.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/signer/types.d.ts +3 -0
- package/lib-es/bridge/generic-alpaca/signer/types.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +70 -46
- package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
- package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js +25 -22
- package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/tests/utils.test.d.ts.map +1 -0
- package/lib-es/bridge/generic-alpaca/{utils.test.js → tests/utils.test.js} +1 -1
- package/lib-es/bridge/generic-alpaca/tests/utils.test.js.map +1 -0
- package/lib-es/bridge/generic-alpaca/utils.d.ts +36 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +130 -14
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/impl.d.ts.map +1 -1
- package/lib-es/bridge/impl.js +5 -4
- package/lib-es/bridge/impl.js.map +1 -1
- package/lib-es/e2e/enum/Account.js +4 -4
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/AppInfos.d.ts +1 -1
- package/lib-es/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib-es/e2e/enum/AppInfos.js +1 -1
- package/lib-es/e2e/enum/AppInfos.js.map +1 -1
- package/lib-es/e2e/enum/Currency.d.ts +3 -1
- package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
- package/lib-es/e2e/enum/Currency.js +102 -42
- package/lib-es/e2e/enum/Currency.js.map +1 -1
- package/lib-es/e2e/enum/Network.d.ts +34 -0
- package/lib-es/e2e/enum/Network.d.ts.map +1 -0
- package/lib-es/e2e/enum/Network.js +35 -0
- package/lib-es/e2e/enum/Network.js.map +1 -0
- package/lib-es/e2e/speculos.js +2 -2
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/exchange/index.d.ts.map +1 -1
- package/lib-es/exchange/index.js +1 -0
- package/lib-es/exchange/index.js.map +1 -1
- package/lib-es/families/evm/config.js +1 -1
- package/lib-es/families/evm/config.js.map +1 -1
- package/lib-es/families/stellar/bridge/logic.d.ts +1 -1
- package/lib-es/families/stellar/bridge/logic.d.ts.map +1 -1
- package/lib-es/families/stellar/bridge/logic.js +1 -1
- package/lib-es/families/stellar/bridge/logic.js.map +1 -1
- package/lib-es/families/stellar/bridge/mock.js +2 -2
- package/lib-es/families/stellar/bridge/mock.js.map +1 -1
- package/lib-es/families/stellar/setup.d.ts +3 -6
- package/lib-es/families/stellar/setup.d.ts.map +1 -1
- package/lib-es/families/stellar/setup.js +2 -10
- package/lib-es/families/stellar/setup.js.map +1 -1
- package/lib-es/families/xrp/bridge/mock.js +2 -2
- package/lib-es/families/xrp/bridge/mock.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +4 -2
- package/lib-es/featureFlags/defaultFeatures.js.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/generated/transaction.d.ts +1 -1
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.js +229 -14
- package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.js.map +1 -1
- package/lib-es/modularDrawer/enums.d.ts +0 -1
- package/lib-es/modularDrawer/enums.d.ts.map +1 -1
- package/lib-es/modularDrawer/enums.js +0 -1
- package/lib-es/modularDrawer/enums.js.map +1 -1
- package/lib-es/modularDrawer/useModularDrawerVisibility.d.ts +7 -1
- package/lib-es/modularDrawer/useModularDrawerVisibility.d.ts.map +1 -1
- package/lib-es/modularDrawer/useModularDrawerVisibility.js +18 -2
- package/lib-es/modularDrawer/useModularDrawerVisibility.js.map +1 -1
- package/package.json +7 -5
- package/src/__tests__/test-helpers/bridge.ts +3 -1
- package/src/bridge/generic-alpaca/accountBridge.ts +1 -4
- package/src/bridge/generic-alpaca/alpaca/index.ts +7 -2
- package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +17 -22
- package/src/bridge/generic-alpaca/broadcast.ts +1 -4
- package/src/bridge/generic-alpaca/buildSubAccounts.ts +110 -0
- package/src/bridge/generic-alpaca/createTransaction.ts +48 -18
- package/src/bridge/generic-alpaca/currencyBridge.ts +1 -1
- package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +13 -4
- package/src/bridge/generic-alpaca/getAccountShape.ts +84 -46
- package/src/bridge/generic-alpaca/getTransactionStatus.ts +46 -22
- package/src/bridge/generic-alpaca/prepareTransaction.ts +41 -7
- package/src/bridge/generic-alpaca/signOperation.ts +88 -18
- package/src/bridge/generic-alpaca/signer/index.ts +43 -7
- package/src/bridge/generic-alpaca/signer/signTransaction.ts +11 -0
- package/src/bridge/generic-alpaca/signer/types.ts +1 -0
- package/src/bridge/generic-alpaca/tests/estimateMaxSpendable.test.ts +72 -47
- package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +1 -1
- package/src/bridge/generic-alpaca/tests/signOperation.test.ts +28 -26
- package/src/bridge/generic-alpaca/{utils.test.ts → tests/utils.test.ts} +1 -1
- package/src/bridge/generic-alpaca/utils.ts +158 -18
- package/src/bridge/impl.ts +5 -4
- package/src/e2e/enum/Account.ts +4 -4
- package/src/e2e/enum/AppInfos.ts +1 -1
- package/src/e2e/enum/Currency.ts +102 -40
- package/src/e2e/enum/Network.ts +33 -0
- package/src/e2e/speculos.ts +2 -2
- package/src/exchange/index.ts +1 -0
- package/src/families/evm/config.ts +1 -1
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +184 -1887
- package/src/families/stellar/bridge/logic.ts +1 -1
- package/src/families/stellar/bridge/mock.ts +2 -2
- package/src/families/stellar/setup.ts +2 -22
- package/src/families/xrp/bridge/mock.ts +2 -2
- package/src/featureFlags/defaultFeatures.ts +4 -2
- package/src/generated/bridge/js.ts +0 -2
- package/src/modularDrawer/__test__/useModularDrawerVisibility.test.ts +345 -14
- package/src/modularDrawer/enums.ts +0 -1
- package/src/modularDrawer/useModularDrawerVisibility.ts +26 -2
- package/lib/bridge/generic-alpaca/utils.test.d.ts.map +0 -1
- package/lib/bridge/generic-alpaca/utils.test.js.map +0 -1
- package/lib/families/canton/bridge.integration.test.d.ts +0 -2
- package/lib/families/canton/bridge.integration.test.d.ts.map +0 -1
- package/lib/families/canton/bridge.integration.test.js +0 -7
- package/lib/families/canton/bridge.integration.test.js.map +0 -1
- package/lib-es/bridge/generic-alpaca/utils.test.d.ts.map +0 -1
- package/lib-es/bridge/generic-alpaca/utils.test.js.map +0 -1
- package/lib-es/families/canton/bridge.integration.test.d.ts +0 -2
- package/lib-es/families/canton/bridge.integration.test.d.ts.map +0 -1
- package/lib-es/families/canton/bridge.integration.test.js +0 -5
- package/lib-es/families/canton/bridge.integration.test.js.map +0 -1
- package/src/families/canton/bridge.integration.test.ts +0 -6
- /package/lib/bridge/generic-alpaca/{utils.test.d.ts → tests/utils.test.d.ts} +0 -0
- /package/lib-es/bridge/generic-alpaca/{utils.test.d.ts → tests/utils.test.d.ts} +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useModularDrawerVisibility.js","sourceRoot":"","sources":["../../src/modularDrawer/useModularDrawerVisibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"useModularDrawerVisibility.js","sourceRoot":"","sources":["../../src/modularDrawer/useModularDrawerVisibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAQhD,MAAM,UAAU,0BAA0B,CAAC,EACzC,2BAA2B,GAG5B;IACC,MAAM,oBAAoB,GAAG,UAAU,CAAC,2BAA2B,CAAC,CAAC;IAErE,MAAM,sBAAsB,GAAG,WAAW,CACxC,CAAC,MAAkC,EAAE,EAAE;QACrC,IAAI,CAAC,oBAAoB,EAAE,OAAO;YAAE,OAAO,KAAK,CAAC;QAEjD,IAAI,MAAM,CAAC,QAAQ,KAAK,qBAAqB,CAAC,QAAQ,EAAE;YACtD,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;YACjF,IAAI,CAAC,gBAAgB;gBAAE,OAAO,KAAK,CAAC;YAEpC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;YAC7B,MAAM,OAAO,GAAG,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,IAAI,EAAE,CAAC;YACvE,MAAM,OAAO,GAAG,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,IAAI,EAAE,CAAC;YAEvE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBACtD,OAAO,KAAK,CAAC;aACd;YAED,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAC/B,OAAO,KAAK,CAAC;aACd;YAED,OAAO,IAAI,CAAC;SACb;QAED,OAAO,oBAAoB,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;IACjE,CAAC,EACD,CAAC,oBAAoB,CAAC,CACvB,CAAC;IAEF,OAAO;QACL,sBAAsB;KACvB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ledgerhq/live-common",
|
3
3
|
"description": "Common ground for the Ledger Live apps",
|
4
|
-
"version": "34.45.0",
|
4
|
+
"version": "34.45.1-nightly.0",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
7
7
|
"url": "https://github.com/LedgerHQ/ledger-live.git"
|
@@ -111,6 +111,7 @@
|
|
111
111
|
"@ledgerhq/wallet-api-client": "^1.9.1",
|
112
112
|
"@ledgerhq/wallet-api-core": "^1.21.1",
|
113
113
|
"@ledgerhq/wallet-api-server": "^1.10.1",
|
114
|
+
"@stellar/stellar-sdk": "^11.3.0",
|
114
115
|
"@stricahq/typhonjs": "^3.0.0",
|
115
116
|
"@taquito/ledger-signer": "^22.0.0",
|
116
117
|
"@ton-community/ton-ledger": "^7.2.0",
|
@@ -168,9 +169,9 @@
|
|
168
169
|
"@ledgerhq/coin-canton": "^0.2.1",
|
169
170
|
"@ledgerhq/coin-cardano": "^0.11.1",
|
170
171
|
"@ledgerhq/coin-casper": "^2.0.8",
|
171
|
-
"@ledgerhq/coin-celo": "^1.2.0",
|
172
|
+
"@ledgerhq/coin-celo": "^1.2.1-nightly.0",
|
172
173
|
"@ledgerhq/coin-cosmos": "^0.16.6",
|
173
|
-
"@ledgerhq/coin-evm": "^2.
|
174
|
+
"@ledgerhq/coin-evm": "^2.28.0-nightly.0",
|
174
175
|
"@ledgerhq/coin-filecoin": "^1.10.0",
|
175
176
|
"@ledgerhq/coin-framework": "^6.1.0",
|
176
177
|
"@ledgerhq/coin-hedera": "^1.10.0",
|
@@ -207,7 +208,7 @@
|
|
207
208
|
"@ledgerhq/hw-app-near": "^6.31.5",
|
208
209
|
"@ledgerhq/hw-app-polkadot": "^6.34.5",
|
209
210
|
"@ledgerhq/hw-app-str": "^7.2.5",
|
210
|
-
"@ledgerhq/hw-app-sui": "^1.
|
211
|
+
"@ledgerhq/hw-app-sui": "^1.3.0-nightly.0",
|
211
212
|
"@ledgerhq/hw-app-tezos": "^6.31.5",
|
212
213
|
"@ledgerhq/hw-app-trx": "^6.31.5",
|
213
214
|
"@ledgerhq/hw-app-vet": "^0.5.13",
|
@@ -224,7 +225,7 @@
|
|
224
225
|
"@ledgerhq/live-network": "^2.0.15",
|
225
226
|
"@ledgerhq/live-nft": "^0.8.17",
|
226
227
|
"@ledgerhq/live-promise": "^0.1.1",
|
227
|
-
"@ledgerhq/live-signer-evm": "^0.7.0",
|
228
|
+
"@ledgerhq/live-signer-evm": "^0.7.1-nightly.0",
|
228
229
|
"@ledgerhq/live-signer-solana": "^0.5.2",
|
229
230
|
"@ledgerhq/live-signer-canton": "^0.2.1",
|
230
231
|
"@ledgerhq/live-wallet": "^0.12.1",
|
@@ -299,6 +300,7 @@
|
|
299
300
|
"test": "pnpm ci-test-unit",
|
300
301
|
"ci-test-unit": "env-cmd -f .ci.unit.env pnpm jest --ci --updateSnapshot && git diff --exit-code src",
|
301
302
|
"ci-test-integration": "env-cmd -f .ci.integration.env pnpm jest --ci --updateSnapshot --passWithNoTests",
|
303
|
+
"ci-test-integration:debug": "env-cmd -f .ci.integration.env node --inspect-wait ./node_modules/jest/bin/jest.js --runInBand --ci --updateSnapshot --passWithNoTests",
|
302
304
|
"test-bridge": "env-cmd -f .ci.bridge.env pnpm jest --ci --updateSnapshot --passWithNoTests --runInBand",
|
303
305
|
"test-bridge-update": "UPDATE_BACKEND_MOCKS=1 env-cmd -f .ci.integration.env pnpm jest --ci --updateSnapshot --passWithNoTests",
|
304
306
|
"test-account-migration": "tsx src/__tests__/migration/account-migration.ts",
|
@@ -253,7 +253,9 @@ export function testBridge<T extends TransactionCommon>(data: DatasetTest<T>): v
|
|
253
253
|
account,
|
254
254
|
});
|
255
255
|
expect(estimation.gte(0)).toBe(true);
|
256
|
-
|
256
|
+
if (!(account.spendableBalance.lt(0) && estimation.eq(0))) {
|
257
|
+
expect(estimation.lte(account.spendableBalance)).toBe(true);
|
258
|
+
}
|
257
259
|
|
258
260
|
for (const sub of account.subAccounts || []) {
|
259
261
|
const estimation = await accountBridge.estimateMaxSpendable({
|
@@ -15,10 +15,7 @@ import { createTransaction } from "./createTransaction";
|
|
15
15
|
import { genericBroadcast } from "./broadcast";
|
16
16
|
import { genericSignOperation } from "./signOperation";
|
17
17
|
|
18
|
-
export function getAlpacaAccountBridge(
|
19
|
-
network: string,
|
20
|
-
kind: "local" | "remote",
|
21
|
-
): AccountBridge<any> {
|
18
|
+
export function getAlpacaAccountBridge(network: string, kind: string): AccountBridge<any> {
|
22
19
|
const signer = getSigner(network);
|
23
20
|
return {
|
24
21
|
sync: makeSync({ getAccountShape: genericGetAccountShape(network, kind) }),
|
@@ -1,19 +1,24 @@
|
|
1
1
|
import { createApi as createXrpApi } from "@ledgerhq/coin-xrp/api/index";
|
2
|
+
import { createApi as createStellarApi } from "@ledgerhq/coin-stellar/api/index";
|
2
3
|
import { getCurrencyConfiguration } from "../../../config";
|
3
4
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
4
5
|
import { getNetworkAlpacaApi } from "./network/network-alpaca";
|
5
6
|
import { Api } from "@ledgerhq/coin-framework/api/types";
|
6
7
|
import { XrpCoinConfig } from "@ledgerhq/coin-xrp/config";
|
8
|
+
import { StellarCoinConfig } from "@ledgerhq/coin-stellar/config";
|
7
9
|
|
8
|
-
export function getAlpacaApi(network
|
10
|
+
export function getAlpacaApi(network, kind): Api<any> {
|
9
11
|
if (kind === "local") {
|
10
12
|
switch (network) {
|
11
13
|
case "ripple":
|
12
14
|
case "xrp":
|
13
15
|
return createXrpApi(
|
14
16
|
getCurrencyConfiguration<XrpCoinConfig>(getCryptoCurrencyById("ripple")),
|
17
|
+
) as Api<any>; // FIXME: createXrpApi returns a strongly typed Api<XrpSender>, fix Api<any> to allow it
|
18
|
+
case "stellar":
|
19
|
+
return createStellarApi(
|
20
|
+
getCurrencyConfiguration<StellarCoinConfig>(getCryptoCurrencyById("stellar")),
|
15
21
|
) as Api<any>;
|
16
|
-
// as unknown as Api<any>; // FIXME: createXrpApi returns a strongly typed Api<XrpSender>, fix Api<any> to allow it
|
17
22
|
}
|
18
23
|
}
|
19
24
|
return getNetworkAlpacaApi(network) satisfies Partial<Api<any>> as Api<any>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
Account,
|
1
|
+
import type {
|
3
2
|
Balance,
|
4
3
|
Block,
|
5
4
|
BlockInfo,
|
@@ -7,10 +6,9 @@ import {
|
|
7
6
|
FeeEstimation,
|
8
7
|
Pagination,
|
9
8
|
TransactionIntent,
|
10
|
-
Transaction,
|
11
9
|
TransactionValidation,
|
12
|
-
AccountInfo,
|
13
10
|
Api,
|
11
|
+
AssetInfo,
|
14
12
|
Cursor,
|
15
13
|
Page,
|
16
14
|
Stake,
|
@@ -18,7 +16,7 @@ import {
|
|
18
16
|
} from "@ledgerhq/coin-framework/api/index";
|
19
17
|
import network from "@ledgerhq/live-network";
|
20
18
|
|
21
|
-
function adaptOp(backendOp:
|
19
|
+
function adaptOp<T extends AssetInfo>(backendOp: Operation<T>): Operation<T> {
|
22
20
|
const { date } = backendOp.tx;
|
23
21
|
const newDate = new Date(date);
|
24
22
|
|
@@ -31,7 +29,7 @@ function adaptOp(backendOp: any): Operation<any> {
|
|
31
29
|
|
32
30
|
const ALPACA_URL = "http://0.0.0.0:3000";
|
33
31
|
|
34
|
-
const buildBroadcast =
|
32
|
+
const buildBroadcast = networkFamily =>
|
35
33
|
async function broadcast(signedOperation: string): Promise<string> {
|
36
34
|
const { data } = await network<
|
37
35
|
{
|
@@ -50,7 +48,7 @@ const buildBroadcast = (networkFamily: string) =>
|
|
50
48
|
return data.transactionIdentifier;
|
51
49
|
};
|
52
50
|
|
53
|
-
const buildCombine =
|
51
|
+
const buildCombine = networkFamily =>
|
54
52
|
async function combine(tx: string, signature: string, pubKey?: string): Promise<string> {
|
55
53
|
const { data } = await network<
|
56
54
|
{
|
@@ -69,7 +67,7 @@ const buildCombine = (networkFamily: string) =>
|
|
69
67
|
return data.signedTransaction;
|
70
68
|
};
|
71
69
|
|
72
|
-
const buildEstimateFees =
|
70
|
+
const buildEstimateFees = networkFamily =>
|
73
71
|
async function estimateFees(intent: TransactionIntent<any>): Promise<FeeEstimation> {
|
74
72
|
const { data } = await network<{ fee: string }, unknown>({
|
75
73
|
method: "POST",
|
@@ -86,11 +84,8 @@ const buildEstimateFees = (networkFamily: string) =>
|
|
86
84
|
};
|
87
85
|
};
|
88
86
|
|
89
|
-
const buildValidateIntent =
|
90
|
-
async function validateIntent(
|
91
|
-
account: Account,
|
92
|
-
transaction: Transaction,
|
93
|
-
): Promise<TransactionValidation> {
|
87
|
+
const buildValidateIntent = networkFamily =>
|
88
|
+
async function validateIntent(transaction: TransactionIntent): Promise<TransactionValidation> {
|
94
89
|
const { data } = await network<
|
95
90
|
{
|
96
91
|
errors: Record<string, Error>;
|
@@ -105,7 +100,6 @@ const buildValidateIntent = (networkFamily: string) =>
|
|
105
100
|
url: `${ALPACA_URL}/${networkFamily}/transaction/validate`,
|
106
101
|
data: {
|
107
102
|
transaction,
|
108
|
-
account,
|
109
103
|
},
|
110
104
|
});
|
111
105
|
return data;
|
@@ -122,13 +116,14 @@ const buildGetBalance = (networkFamily: string) =>
|
|
122
116
|
{
|
123
117
|
value: BigInt(data.value),
|
124
118
|
asset: data.asset,
|
119
|
+
locked: BigInt(data?.locked ?? "0"),
|
125
120
|
},
|
126
121
|
];
|
127
122
|
};
|
128
123
|
|
129
|
-
const
|
130
|
-
async function
|
131
|
-
const { data } = await network<
|
124
|
+
const buildGetSequence = (networkFamily: string) =>
|
125
|
+
async function getSequence(address: string): Promise<number> {
|
126
|
+
const { data } = await network<number, unknown>({
|
132
127
|
method: "GET",
|
133
128
|
url: `${ALPACA_URL}/${networkFamily}/account/${address}/info`,
|
134
129
|
});
|
@@ -136,10 +131,10 @@ const buildGetAccountInfo = (networkFamily: string) =>
|
|
136
131
|
return data;
|
137
132
|
};
|
138
133
|
|
139
|
-
const buildListOperations =
|
134
|
+
const buildListOperations = networkFamily =>
|
140
135
|
async function listOperations(
|
141
136
|
address: string,
|
142
|
-
pagination: Pagination,
|
137
|
+
pagination: Pagination = { minHeight: 0 },
|
143
138
|
): Promise<[Operation<any>[], string]> {
|
144
139
|
const { data } = await network<{ operations: Operation<any>[] }, unknown>({
|
145
140
|
method: "GET",
|
@@ -151,7 +146,7 @@ const buildListOperations = (networkFamily: string) =>
|
|
151
146
|
return [data.operations.map(op => adaptOp(op)), ""];
|
152
147
|
};
|
153
148
|
|
154
|
-
const buildLastBlock =
|
149
|
+
const buildLastBlock = networkFamily =>
|
155
150
|
async function lastBlock(): Promise<BlockInfo> {
|
156
151
|
const { data } = await network<any, unknown>({
|
157
152
|
method: "GET",
|
@@ -164,7 +159,7 @@ const buildLastBlock = (networkFamily: string) =>
|
|
164
159
|
};
|
165
160
|
};
|
166
161
|
|
167
|
-
const buildCraftTransaction =
|
162
|
+
const buildCraftTransaction = networkFamily =>
|
168
163
|
async function craftTransaction(intent: TransactionIntent<any>): Promise<string> {
|
169
164
|
const { data } = await network<any, unknown>({
|
170
165
|
method: "POST",
|
@@ -186,7 +181,7 @@ export const getNetworkAlpacaApi = (networkFamily: string) =>
|
|
186
181
|
validateIntent: buildValidateIntent(networkFamily),
|
187
182
|
estimateFees: buildEstimateFees(networkFamily),
|
188
183
|
getBalance: buildGetBalance(networkFamily),
|
189
|
-
|
184
|
+
getSequence: buildGetSequence(networkFamily),
|
190
185
|
listOperations: buildListOperations(networkFamily),
|
191
186
|
lastBlock: buildLastBlock(networkFamily),
|
192
187
|
craftTransaction: buildCraftTransaction(networkFamily),
|
@@ -2,10 +2,7 @@ import { AccountBridge, TransactionCommon } from "@ledgerhq/types-live";
|
|
2
2
|
import { patchOperationWithHash } from "../../operation";
|
3
3
|
import { getAlpacaApi } from "./alpaca";
|
4
4
|
|
5
|
-
export const genericBroadcast: (
|
6
|
-
network: string,
|
7
|
-
kind: "local" | "remote",
|
8
|
-
) => AccountBridge<TransactionCommon>["broadcast"] =
|
5
|
+
export const genericBroadcast: (network, kind) => AccountBridge<TransactionCommon>["broadcast"] =
|
9
6
|
(network, kind) =>
|
10
7
|
async ({ signedOperation: { signature, operation } }) => {
|
11
8
|
const hash = await getAlpacaApi(network, kind).broadcast(signature);
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import BigNumber from "bignumber.js";
|
2
|
+
import { emptyHistoryCache } from "@ledgerhq/coin-framework/account/index";
|
3
|
+
import type { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
4
|
+
import type { Operation, SyncConfig, TokenAccount } from "@ledgerhq/types-live";
|
5
|
+
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
6
|
+
import { listTokensForCryptoCurrency } from "@ledgerhq/cryptoassets";
|
7
|
+
import { AssetInfo, Balance } from "@ledgerhq/coin-framework/api/types";
|
8
|
+
import { findTokenById } from "@ledgerhq/cryptoassets/tokens";
|
9
|
+
|
10
|
+
export interface OperationCommon extends Operation {
|
11
|
+
extra: Record<string, any>;
|
12
|
+
}
|
13
|
+
|
14
|
+
export const getAssetIdFromTokenId = (tokenId: string): string => tokenId.split("/")[2];
|
15
|
+
|
16
|
+
export const getAssetIdFromAsset = (asset: AssetInfo) =>
|
17
|
+
asset.type !== "native" && "assetReference" in asset && "assetOwner" in asset
|
18
|
+
? `${asset.assetReference}:${asset.assetOwner}`
|
19
|
+
: "";
|
20
|
+
|
21
|
+
function buildTokenAccount({
|
22
|
+
parentAccountId,
|
23
|
+
assetBalance,
|
24
|
+
token,
|
25
|
+
operations,
|
26
|
+
}: {
|
27
|
+
parentAccountId: string;
|
28
|
+
assetBalance: Balance;
|
29
|
+
token: TokenCurrency;
|
30
|
+
operations: OperationCommon[];
|
31
|
+
}): TokenAccount {
|
32
|
+
const assetId = getAssetIdFromTokenId(token.id);
|
33
|
+
const id = `${parentAccountId}+${assetId}`;
|
34
|
+
const balance = new BigNumber(assetBalance.value.toString() || "0");
|
35
|
+
|
36
|
+
// TODO: recheck this logic
|
37
|
+
const spendableBalance = new BigNumber(assetBalance.value.toString()).minus(
|
38
|
+
new BigNumber(assetBalance.locked?.toString() || "0"),
|
39
|
+
);
|
40
|
+
|
41
|
+
const tokenOperations = operations.map(op => ({
|
42
|
+
...op,
|
43
|
+
id: encodeOperationId(id, op.hash, op.extra?.ledgerOpType),
|
44
|
+
accountId: id,
|
45
|
+
type: op.extra?.ledgerOpType,
|
46
|
+
value: op.extra?.assetAmount ? new BigNumber(op.extra?.assetAmount) : op.value,
|
47
|
+
}));
|
48
|
+
|
49
|
+
return {
|
50
|
+
type: "TokenAccount",
|
51
|
+
id,
|
52
|
+
parentId: parentAccountId,
|
53
|
+
token,
|
54
|
+
operationsCount: operations.length,
|
55
|
+
operations: tokenOperations,
|
56
|
+
pendingOperations: [],
|
57
|
+
balance,
|
58
|
+
spendableBalance: spendableBalance,
|
59
|
+
swapHistory: [],
|
60
|
+
creationDate: operations.length > 0 ? operations[operations.length - 1].date : new Date(),
|
61
|
+
balanceHistoryCache: emptyHistoryCache, // calculated in the jsHelpers
|
62
|
+
};
|
63
|
+
}
|
64
|
+
|
65
|
+
export function buildSubAccounts({
|
66
|
+
currency,
|
67
|
+
accountId,
|
68
|
+
assetsBalance,
|
69
|
+
syncConfig,
|
70
|
+
operations,
|
71
|
+
}: {
|
72
|
+
currency: CryptoCurrency;
|
73
|
+
accountId: string;
|
74
|
+
assetsBalance: Balance[];
|
75
|
+
syncConfig: SyncConfig;
|
76
|
+
operations: OperationCommon[];
|
77
|
+
}): TokenAccount[] | undefined {
|
78
|
+
const { blacklistedTokenIds = [] } = syncConfig;
|
79
|
+
const allTokens = listTokensForCryptoCurrency(currency);
|
80
|
+
|
81
|
+
if (allTokens.length === 0 || assetsBalance.length === 0) {
|
82
|
+
return undefined;
|
83
|
+
}
|
84
|
+
const tokenAccounts: TokenAccount[] = [];
|
85
|
+
assetsBalance
|
86
|
+
.filter(b => b.asset.type !== "native") // NOTE: this could be removed, keeping here while fixing things up
|
87
|
+
.map(balance => {
|
88
|
+
const token = findToken(currency, balance);
|
89
|
+
// NOTE: for future tokens, will need to check over currencyName/standard(erc20,trc10,trc20, etc)/id
|
90
|
+
if (token && !blacklistedTokenIds.includes(token.id)) {
|
91
|
+
tokenAccounts.push(
|
92
|
+
buildTokenAccount({
|
93
|
+
parentAccountId: accountId,
|
94
|
+
assetBalance: balance,
|
95
|
+
token,
|
96
|
+
operations: operations.filter(
|
97
|
+
op =>
|
98
|
+
op.extra.assetReference === balance.asset?.["assetReference"] &&
|
99
|
+
op.extra.assetOwner === balance.asset?.["assetOwner"], // NOTE: we could narrow type
|
100
|
+
),
|
101
|
+
}),
|
102
|
+
);
|
103
|
+
}
|
104
|
+
});
|
105
|
+
return tokenAccounts;
|
106
|
+
}
|
107
|
+
|
108
|
+
export function findToken(currency: CryptoCurrency, balance: Balance): TokenCurrency | undefined {
|
109
|
+
return findTokenById(`${currency.family}/asset/${getAssetIdFromAsset(balance.asset)}`);
|
110
|
+
}
|
@@ -1,27 +1,57 @@
|
|
1
|
-
import { Account, TransactionCommon } from "@ledgerhq/types-live";
|
1
|
+
import { Account, TokenAccount, TransactionCommon } from "@ledgerhq/types-live";
|
2
2
|
import BigNumber from "bignumber.js";
|
3
3
|
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
4
4
|
|
5
|
+
export enum NetworkCongestionLevel {
|
6
|
+
LOW = "LOW",
|
7
|
+
MEDIUM = "MEDIUM",
|
8
|
+
HIGH = "HIGH",
|
9
|
+
}
|
10
|
+
|
5
11
|
export type NetworkInfo = {
|
6
|
-
|
7
|
-
serverFee: BigNumber;
|
8
|
-
baseReserve: BigNumber;
|
12
|
+
fees: BigNumber;
|
9
13
|
};
|
10
14
|
|
11
|
-
export function createTransaction(account: Account): TransactionCommon & {
|
15
|
+
export function createTransaction(account: Account | TokenAccount): TransactionCommon & {
|
12
16
|
family: string;
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
fees?: BigNumber | null;
|
18
|
+
tag?: number | null | undefined;
|
19
|
+
feeCustomUnit?: Unit | null | undefined;
|
20
|
+
memoType?: string | null;
|
21
|
+
memoValue?: string | null;
|
22
|
+
mode?: "send" | "changeTrust";
|
23
|
+
assetReference?: string;
|
24
|
+
assetOwner?: string;
|
25
|
+
networkInfo?: NetworkInfo | null;
|
17
26
|
} {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
const currency =
|
28
|
+
account.type === "TokenAccount" ? account.token.parentCurrency : account.currency;
|
29
|
+
switch (currency.family) {
|
30
|
+
case "xrp":
|
31
|
+
case "ripple":
|
32
|
+
return {
|
33
|
+
family: currency.family,
|
34
|
+
amount: BigNumber(0),
|
35
|
+
recipient: "",
|
36
|
+
fees: null,
|
37
|
+
tag: undefined,
|
38
|
+
feeCustomUnit: null, // NOTE: XRP does not use custom units for fees anymore
|
39
|
+
};
|
40
|
+
case "stellar":
|
41
|
+
return {
|
42
|
+
family: currency.family,
|
43
|
+
amount: new BigNumber(0),
|
44
|
+
fees: null,
|
45
|
+
recipient: "",
|
46
|
+
memoValue: null,
|
47
|
+
memoType: null,
|
48
|
+
useAllAmount: false,
|
49
|
+
mode: "send",
|
50
|
+
assetReference: "",
|
51
|
+
assetOwner: "",
|
52
|
+
networkInfo: null,
|
53
|
+
};
|
54
|
+
default:
|
55
|
+
throw new Error(`Unsupported currency family: ${currency.family}`);
|
56
|
+
}
|
27
57
|
}
|
@@ -3,7 +3,7 @@ import { CurrencyBridge } from "@ledgerhq/types-live";
|
|
3
3
|
import { genericGetAccountShape } from "./getAccountShape";
|
4
4
|
import { getSigner } from "./signer";
|
5
5
|
|
6
|
-
export function getAlpacaCurrencyBridge(network: string, kind:
|
6
|
+
export function getAlpacaCurrencyBridge(network: string, kind: string): CurrencyBridge {
|
7
7
|
return {
|
8
8
|
preload: () => Promise.resolve({}),
|
9
9
|
hydrate: () => {
|
@@ -6,21 +6,30 @@ import { transactionToIntent } from "./utils";
|
|
6
6
|
import BigNumber from "bignumber.js";
|
7
7
|
|
8
8
|
export function genericEstimateMaxSpendable(
|
9
|
-
network
|
10
|
-
kind
|
9
|
+
network,
|
10
|
+
kind,
|
11
11
|
): AccountBridge<any>["estimateMaxSpendable"] {
|
12
12
|
return async ({ account, parentAccount, transaction }) => {
|
13
|
+
if (account.type === "TokenAccount") {
|
14
|
+
return account.spendableBalance;
|
15
|
+
}
|
13
16
|
const mainAccount = getMainAccount(account, parentAccount);
|
14
|
-
|
15
17
|
const draftTransaction = {
|
16
18
|
...createTransaction(account as any),
|
17
19
|
...transaction,
|
18
20
|
amount: mainAccount.spendableBalance,
|
21
|
+
useAllAmount: true,
|
22
|
+
fees: transaction?.fees ? BigInt(transaction.fees.toString()) : 0n,
|
19
23
|
};
|
20
24
|
const fees = await getAlpacaApi(network, kind).estimateFees(
|
21
25
|
transactionToIntent(mainAccount, draftTransaction),
|
22
26
|
);
|
23
|
-
|
27
|
+
const { amount } = await getAlpacaApi(network, kind).validateIntent(
|
28
|
+
transactionToIntent(account, { ...draftTransaction }),
|
29
|
+
);
|
30
|
+
if (network === "stellar") {
|
31
|
+
return amount > 0 ? new BigNumber(amount.toString()) : new BigNumber(0);
|
32
|
+
}
|
24
33
|
const bnFee = BigNumber(fees.value.toString());
|
25
34
|
return BigNumber.max(0, account.spendableBalance.minus(bnFee));
|
26
35
|
};
|
@@ -3,59 +3,97 @@ import { GetAccountShape, mergeOps } from "@ledgerhq/coin-framework/bridge/jsHel
|
|
3
3
|
import BigNumber from "bignumber.js";
|
4
4
|
import { getAlpacaApi } from "./alpaca";
|
5
5
|
import { adaptCoreOperationToLiveOperation, extractBalance } from "./utils";
|
6
|
+
import { inferSubOperations } from "@ledgerhq/coin-framework/serialization";
|
7
|
+
import { findToken } from "./buildSubAccounts";
|
8
|
+
import { buildSubAccounts, OperationCommon } from "./buildSubAccounts";
|
6
9
|
|
7
|
-
export function genericGetAccountShape(network: string, kind:
|
8
|
-
return async info => {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
derivationMode,
|
17
|
-
});
|
18
|
-
|
19
|
-
const blockInfo = await getAlpacaApi(network, kind).lastBlock();
|
20
|
-
|
21
|
-
const balances = await getAlpacaApi(network, kind).getBalance(address);
|
22
|
-
const nativeBalance = extractBalance(balances, "native");
|
23
|
-
const balance = BigNumber(nativeBalance.value.toString());
|
24
|
-
|
25
|
-
let spendableBalance: BigNumber;
|
26
|
-
if (nativeBalance.locked) {
|
27
|
-
spendableBalance = BigNumber.max(
|
28
|
-
balance.minus(BigNumber(nativeBalance.locked.toString())),
|
29
|
-
BigNumber(0),
|
30
|
-
);
|
31
|
-
} else {
|
32
|
-
spendableBalance = initialAccount?.spendableBalance || balance;
|
10
|
+
export function genericGetAccountShape(network: string, kind: string): GetAccountShape {
|
11
|
+
return async (info, syncConfig) => {
|
12
|
+
const { address, initialAccount, currency, derivationMode } = info;
|
13
|
+
const alpacaApi = getAlpacaApi(network, kind);
|
14
|
+
|
15
|
+
if (alpacaApi.getChainSpecificRules) {
|
16
|
+
const chainSpecificValidation = alpacaApi.getChainSpecificRules();
|
17
|
+
if (chainSpecificValidation.getAccountShape) {
|
18
|
+
chainSpecificValidation.getAccountShape(address);
|
33
19
|
}
|
34
|
-
|
20
|
+
}
|
21
|
+
|
22
|
+
const accountId = encodeAccountId({
|
23
|
+
type: "js",
|
24
|
+
version: "2",
|
25
|
+
currencyId: currency.id,
|
26
|
+
xpubOrAddress: address,
|
27
|
+
derivationMode,
|
28
|
+
});
|
29
|
+
|
30
|
+
const blockInfo = await alpacaApi.lastBlock();
|
31
|
+
const balanceRes = await alpacaApi.getBalance(address);
|
32
|
+
const nativeAsset = extractBalance(balanceRes, "native");
|
33
|
+
|
34
|
+
const assetsBalance = balanceRes
|
35
|
+
.filter(b => b.asset.type !== "native")
|
36
|
+
.filter(b => findToken(currency, b));
|
37
|
+
|
38
|
+
const nativeBalance = BigInt(nativeAsset?.value ?? "0");
|
39
|
+
|
40
|
+
const spendableBalance = BigInt(nativeBalance - BigInt(nativeAsset?.locked ?? "0"));
|
35
41
|
|
36
|
-
|
42
|
+
const oldOps = (initialAccount?.operations || []) as OperationCommon[];
|
43
|
+
const lastPagingToken = oldOps[0]?.extra?.pagingToken || "";
|
37
44
|
|
38
|
-
|
39
|
-
|
40
|
-
|
45
|
+
const blockHeight = oldOps.length ? (oldOps[0].blockHeight ?? 0) + 1 : 0;
|
46
|
+
const paginationParams: any = { minHeight: blockHeight };
|
47
|
+
if (lastPagingToken) {
|
48
|
+
paginationParams.lastPagingToken = lastPagingToken;
|
49
|
+
}
|
50
|
+
|
51
|
+
const [newCoreOps] = await alpacaApi.listOperations(address, paginationParams);
|
52
|
+
const newOps = newCoreOps.map(op =>
|
53
|
+
adaptCoreOperationToLiveOperation(accountId, op),
|
54
|
+
) as OperationCommon[];
|
55
|
+
const mergedOps = mergeOps(oldOps, newOps) as OperationCommon[];
|
56
|
+
|
57
|
+
const assetOperations: OperationCommon[] = [];
|
58
|
+
mergedOps.forEach(operation => {
|
59
|
+
if (
|
60
|
+
operation?.extra?.assetReference &&
|
61
|
+
operation?.extra?.assetOwner &&
|
62
|
+
!["OPT_IN", "OPT_OUT"].includes(operation.type)
|
63
|
+
) {
|
64
|
+
assetOperations.push(operation);
|
65
|
+
}
|
66
|
+
});
|
41
67
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
68
|
+
const subAccounts =
|
69
|
+
buildSubAccounts({
|
70
|
+
currency,
|
71
|
+
accountId,
|
72
|
+
assetsBalance,
|
73
|
+
syncConfig,
|
74
|
+
operations: assetOperations,
|
75
|
+
}) || [];
|
76
|
+
|
77
|
+
const operationsWithSubs = mergedOps.map(op => {
|
78
|
+
const subOperations = inferSubOperations(op.hash, subAccounts);
|
46
79
|
|
47
80
|
return {
|
48
|
-
|
49
|
-
|
50
|
-
blockHeight: operations.length === 0 ? 0 : blockInfo.height || initialAccount?.blockHeight,
|
51
|
-
balance,
|
52
|
-
spendableBalance,
|
53
|
-
operations,
|
54
|
-
operationsCount: operations.length,
|
81
|
+
...op,
|
82
|
+
subOperations,
|
55
83
|
};
|
56
|
-
}
|
57
|
-
|
58
|
-
|
59
|
-
|
84
|
+
});
|
85
|
+
|
86
|
+
const res = {
|
87
|
+
id: accountId,
|
88
|
+
xpub: address,
|
89
|
+
blockHeight:
|
90
|
+
operationsWithSubs.length === 0 ? 0 : blockInfo.height || initialAccount?.blockHeight,
|
91
|
+
balance: new BigNumber(nativeBalance.toString()),
|
92
|
+
spendableBalance: new BigNumber(spendableBalance.toString()),
|
93
|
+
operations: operationsWithSubs,
|
94
|
+
subAccounts,
|
95
|
+
operationsCount: operationsWithSubs.length,
|
96
|
+
};
|
97
|
+
return res;
|
60
98
|
};
|
61
99
|
}
|