Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ledger Live App #655

Merged
merged 71 commits into from
Dec 14, 2023
Merged

Ledger Live App #655

merged 71 commits into from
Dec 14, 2023

Commits on Oct 31, 2023

  1. Create useEmbedFeatureFlag hook

    This hook will check if there is an `isEmbed` query param in the page url. If it
    is, then it will save that value in local storage. We will use that param in our
    manifest.json file for our Ledger Live App.
    michalsmiarowski committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    e476476 View commit details
    Browse the repository at this point in the history
  2. Make only tBTC section available

    For Ledger Live App we only need tBTC page.
    michalsmiarowski committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    a69c707 View commit details
    Browse the repository at this point in the history
  3. Hide sidebar

    Since we only have tbtc section in our Ledger Live App the Sidebar is not
    needed, so we hide it if the `isEmbed` flag is set to true.
    michalsmiarowski committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    5155964 View commit details
    Browse the repository at this point in the history

Commits on Nov 1, 2023

  1. Create LedgerLiveAppManager class

    The `LedgerLiveAppManager` will be a core for all the logic used in the
    LedgerLive app. It will contain two separate managers for ethereum and bitcoin
    transactions.
    
    For ethereum manager we also have to create a separate LedgerLiveApp signer that
    implements Signer class from Ethers. It is needed so that we can pass it to our
    new tbtc-v2 SDK and use it to sign transactions and communicatin with the
    contracts. This way we won't have to change anything in the SDK just for the
    LedgerLive implementation and we keep it clean.
    
    In this commit only ethereum manager is created. In the future we should also
    create bitcoinManager and put it here, which allow the user to send bitcoins to
    a specific bitcoin address.
    michalsmiarowski committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    a7f76ed View commit details
    Browse the repository at this point in the history
  2. Put ledgerLiveAppManager inside threshold-ts lib

    The Threshold Ledger Live App will show only tbtc flow so it makes sense to put
    the `ledgerLiveAppManager` inside our `threshold-ts` lib in `TBTC` class.
    Besides, we will use the signer from that class and pass it to our tbtc-v2 SDK.
    michalsmiarowski committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    8b066bb View commit details
    Browse the repository at this point in the history
  3. Add possibility to connect ledger ethereum account

    As of now it will only allow to use goerli accounts. Left TODOs around the
    places to not forget to fix that.
    
    I've created `useRequestEthereumAccount` which actually works similar to
    `useRequestAccount` from `@ledgerhq/wallet-api-client-react`, but it uses our
    ledgerLiveManager under the hood. This way it will save the account in our
    signer, which then will be used in our tbtc-v2 SDK to interact with contracts.
    
    Since we save our connected address in redux store we will now display
    it when the address is connected instead of getting the `account`
    property from `useWeb3React` hook.
    michalsmiarowski committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    e9645da View commit details
    Browse the repository at this point in the history
  4. Fix minting flow not siplaying for connected users

    Minting flow was not displaying for connected users in Ledger Live app. I've
    fixed it by checking if the address is present in redux store. Since we save it
    for normal wallets and also for wallets in ledger live app, it will work for
    both.
    michalsmiarowski committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    8bcd830 View commit details
    Browse the repository at this point in the history
  5. Assign eth address from the store to the form

    Assign eth address from the redux store to the provide data form. It will be an
    address that will be used to generate deposit address.
    michalsmiarowski committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    b6c1814 View commit details
    Browse the repository at this point in the history
  6. Make account property private in ledger signer

    We don't want to allow the account to be changed outside of the
    ledgerLive etherumManager so we are making the `account` property inside
    `LedgerLiveEthereum` signer private. The account should be changed by using
    `connectAccount` method in our manager.
    michalsmiarowski committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    f13fb80 View commit details
    Browse the repository at this point in the history
  7. Create LedgerLiveAppBitcoinManager

    This class will manage all bitcoin transactions/message signing inside the
    Ledger Live app. Besides I've also renamed `EthereumManager` to
    `LedgerLiveAppEthereumManager` to make it more specific.
    michalsmiarowski committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    4f8266f View commit details
    Browse the repository at this point in the history
  8. Change name for LedgerLiveEthereumSigner class

    `LedgerLiveEthereumSigner` -> `LedgerLiveAppEthereumSigner`
    michalsmiarowski committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    b059feb View commit details
    Browse the repository at this point in the history
  9. Make two separate hooks for bitcoin and ethereum

    Makes two separate requestAccount hook for bitcoin and for ethereum networks.
    michalsmiarowski committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    62d0f96 View commit details
    Browse the repository at this point in the history
  10. Make it possible to connect bitcoin account

    We want to connect bitcoin account at step 2 of the minting flow. For this case
    I've created a separate button that allows the user to connect a bitcoin account
    inside ledger live app. After that he will be able to send the bitcoins form the
    account he had choosen to a deposit address that he just generated.
    michalsmiarowski committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    100b0c6 View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2023

  1. Rewamp (1) - install wallet-connect-client-react

    I've decided to rewamp the whole implementation as it seems that we don't really
    need to keep everything in ledgerLiveAppManager. The idea now is to keep only
    LedgerLiveAppEthereumSigner (which in the future will be placed in tbtc-v2 SDK)
    for integrating with contracts, and create a context for ledger live app where
    we will keep connected ethereum and bitcoin addresses.
    
    The LedgerLiveAppEthereumSigner will use `@ledgerhq/wallet-api-client` package,
    and for the rest things (connecting ethereum wallet, connecting bitcoin wallet,
    sending bitcoins to address), we will use `wallet-connect-client-react` lib.
    
    The first step is to install the `wallet-connect-client-react`
    michalsmiarowski committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    dad6a2e View commit details
    Browse the repository at this point in the history
  2. Rewamp (2) - TransportProvider

    Adds TransportProvider needed for `wallet-api-client-react`. This will allow us
    to use the hooks from the libs (like `useRequestAccount` etc.).
    michalsmiarowski committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    b222469 View commit details
    Browse the repository at this point in the history
  3. Rewamp (3) - LedgerLiveAppContext

    This context is where we will store our eth and btc addresses for ledger live
    app.
    
    Why we need it?
    
    We have to detect when the address is changed in our LedgerLiveApp and then
    update our signer inside threshold lib in `ThresholdContext`. For website we
    could just detect it with our `useWeb3React` hook, but in this case it is not
    that simple. The only way in the previous implementation was to get the actual
    address from the redux store, but this required to move `<ReduxProvider>` above
    the `<ThresholdProvider`, which might broke the app in some places.
    
    That's why I've decided to create a separate context foe Ledger Live App and
    keep all data about connected accounts there. We will put the context above
    `ThresholdContext` so we can use it there and later we will make sure to save
    the account there each time we use `useRequestAccount` hook from
    `wallet-api-client-react`.
    michalsmiarowski committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    edf9afd View commit details
    Browse the repository at this point in the history
  4. Rewamp (4) - use ledger's wallet api for react

    This is probably final step (or one of the final steps) in this rewamp. There
    are few bigger changes in this commit:
    
    1. Remove `LedgerLiveAppManager` completely
    
    We won't need that class anymore. The only thing we need is
    `LedgerLiveAppEthereumSigner` to interact with eth contracts. The rest thigns
    (like connecting wallets, and sending bitcoins) will be handled with hooks from
    ledger's wallet-api for react.
    
    2. Store `LedgerLiveAppEthereumSigner` instance in our `TBTC` class in
    `thershold-ts` lib.
    
    We also remove the need to pass anything related to ledger live app through
    `ThresholdConfig`, like we did with `LedgerLiveAppManager`. The Ledger Live App
    Signer will be created inside the class if necessary.
    
    3. Refactor `useRequestEthereumAccount` and `useRequestBitcoinAccount`
    
    Those hooks will now use `useRequestAccount` hook from
    `@ledgerht/wallet-api-client-react`, but additionaly the `requestAccount` method
    will save the bitcoin/ethereum account in the LedgerLiveContext and ethereum
    account in the LedgerLiveAppEthereumSigner (through TBTC method).
    michalsmiarowski committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    7b5105e View commit details
    Browse the repository at this point in the history
  5. Rewamp (5) - create useIsActive hook

    This hook will work both in website view and inside the Ledger Live App. If
    `isEmbed` flag is set to false it will return the values based on the
    `useWeb3React` hook. If it's true the returned values will be based on
    `LedgerLiveApp` context.
    michalsmiarowski committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    46344d7 View commit details
    Browse the repository at this point in the history
  6. Add the possibility to upload JSON file

    For this we've added `Continue` button in Step 1 - it is visible only if the app
    is embed. The `useIsActive` hook is used to get the proper account base on the
    `isEmbed` feature flag.
    michalsmiarowski committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    e50f783 View commit details
    Browse the repository at this point in the history
  7. Refactor useEffect inside useRequestAccount hooks

    For both bitcoin and ethereum hooks we can just save the account address
    immidietely to the LedgerLiveApp Context - we don't have to check if the address
    is undefined or not in the if statements like before.
    
    Additionally we can also save the eth account for the
    LedgerLiveAppEthereumSigner using one-liner.
    
    I've also remove saving bitcoin address to the LedgerLiveApp signer. It was a
    mistake. Only eth addresses should be saved there, since it is a signer for
    ethereum chain.
    michalsmiarowski committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    7d6d897 View commit details
    Browse the repository at this point in the history
  8. Store Account object in Ledger Live App Context

    I've decided to store Account object (from ledger's wallet-api) in Ledger Live
    App Context, instead of just account address. This will be helpful when sending
    a bitcoin transaction, because it need the account id, that is stored in Account
    object.
    michalsmiarowski committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    ad0c843 View commit details
    Browse the repository at this point in the history

Commits on Nov 3, 2023

  1. Allow sending bitcoins to deposit address

    Creates `useSendBitcoinTransaction` hook that use `useSignAndBroadcast` hook
    from `ledgerhq/wallet-api-client-react` under the hood. This will send a
    specific amount of bitcoins to a specific address.
    michalsmiarowski committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    95acc74 View commit details
    Browse the repository at this point in the history
  2. Add bignumber.js to package.json

    Unfortunately we need `bignumber.js` library in our dApp to work with ledger's
    wallet-api. Unfortunately, because we already use `BigNumber` lib from `ethers`
    for our calcuulations.
    
    The commit changes only `package.json` because `yarn.lock` already contains
    `bignumber.js` registry, since it's a dependency of wallet-api.
    michalsmiarowski committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    efe582f View commit details
    Browse the repository at this point in the history
  3. Change Signer class that LedgerSigner extends from

    Extending `LedgerLiveAppEthereumSigner` from `Signer` class from `ethers` lib
    did not work as expected when passing it to tbtc-v2 SDK. The SDK did not
    recognize that it was an instance of Signer.
    
    What works is changing the way we import `Signer` class - instead of doing it
    from `ethers` we now do it from `@ethersproject/abstract-signer`.
    michalsmiarowski committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    5d4be01 View commit details
    Browse the repository at this point in the history
  4. Pass ledgerLiveAppEhereumSigner to Threshold lib

    I've decided to add additional property to thresholdConfig.ethereum:
    `ledgerLiveAppEthereumSigner`. This will allow us to pass the signer when
    creating a new instance of TBTC.
    
    It will be useful when connecting account. Our threshold library reinitializes
    all classed inside and we don't want to lose the data from our signer
    (especcially the connected address that we store there). That's why we pass an
    old signer from therhols lib to `updateConfig` method when we connect an
    account.
    michalsmiarowski committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    4051270 View commit details
    Browse the repository at this point in the history
  5. Install tbtc-v2.ts SDK as a separate package

    Since the version 2 of `tbtc-v2.ts` lib is not implemented in our dApp yet, I've
    decided to install it as a separate package for now. This way it will be easier
    to change things, once the integration is ready.
    michalsmiarowski committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    3f5d279 View commit details
    Browse the repository at this point in the history

Commits on Nov 6, 2023

  1. Implement minting flow with SDK v2

    Implements whole minting process with tbtc-v2.ts SDK (v2). The implement process
    is being implemented in a separate PR, so this is a quick implementation to make
    the whole process easier once the implementation PR is merged (and to make sure
    it will work with new SDK).
    
    For this, I've created a separate methods in our `TBTC` class (in `threshold-ts`
    lib) and I've added `SdkV2` at the end, so it will be easier to determinate
    which method is related to the new SDK. It will also be easier to integrate the
    changes once the SDK implementation PR is done (I hope :D).
    
    For example now, in `TBTC` class we have two methods:
    - `calculateDepositAddress` - which uses old tbtc-v2.ts version
    - `calculateDepositAddressSdkV2` - which uses new tbtc-v2.ts version.
    
    All the minting flow is using `SdkV2` methods now.
    michalsmiarowski committed Nov 6, 2023
    Configuration menu
    Copy the full SHA
    168aaed View commit details
    Browse the repository at this point in the history
  2. Implement Resume Deposit with SDK v2

    Implements resuming deposit (from file) with SDK v2.
    
    For that we have to create deposit receipt from the values that we store in the
    file. Since those values are in plain text we have to change them to `Hex`
    objects (except `depositor`). Then, we initiate deposit object from receipt and
    calculate the correct btc deposit address.
    michalsmiarowski committed Nov 6, 2023
    Configuration menu
    Copy the full SHA
    a35eeaf View commit details
    Browse the repository at this point in the history
  3. Implement reveal deposit for ledger live app

    Implements reveal deposit functionalityin ledger live app. For this we create a
    separate `useSendLedgerLiveAppTransactionFromFn` hook, that is a copy of
    `useSendTransactionFromFn`, but changed in a way to work with our LedgerLiveApp
    Signer.
    
    We then check which hook should we use inside `useRevealDepositTrnasaction`,
    based on the `isEmbed` flag.
    
    We are also adding `await` to `sendTransaction` method in
    `LedgerLiveAppEthereumSigner`, because we need to return that transaction
    response (not promise) from that function.
    michalsmiarowski committed Nov 6, 2023
    Configuration menu
    Copy the full SHA
    ef13ab8 View commit details
    Browse the repository at this point in the history
  4. Fix fetching Bridge Activity in Ledger Live App

    The fetching was not working in Ledger Live App, because it used the account
    from `useWeb3React` hook, which doesn't work here. I've replaced it with
    `useIsActive` hook, which returns either web3 account or connected ledger
    account based on `isEmbed` flag.
    
    The bridge activity still uses the old version of tbtc-v2.ts, but I don't think
    it's necessary to fix that in this PR. The main reason to use a new SDK in this
    PR is to see if the LedgerLiveAppEthereumSigner will work properly with it.
    michalsmiarowski committed Nov 6, 2023
    Configuration menu
    Copy the full SHA
    39e589c View commit details
    Browse the repository at this point in the history
  5. Fix no ongoingRequest error

    There was an error when doing a reveal that displayed `no ongoingReques:
    <request_id>`. It was happening because we were using a separate transport
    object in our LedgerLiveAppEthereumSigner, and a separate one for our react
    hooks. The one in our react hook was always connected and we didn't disconnect
    it after doing a transaction. This way, when we used our LedgerLiveApp Signer we
    had two transport objects connected, and two returned the same message, but the
    second time the message was already cleared.
    
    As a workaround we will save the transport object that we use in react in a
    separate context and we connect it only before doing a transaction, and
    disconnect it right after.
    michalsmiarowski committed Nov 6, 2023
    Configuration menu
    Copy the full SHA
    234fda3 View commit details
    Browse the repository at this point in the history
  6. Fix minting success page redirect

    There was a bug when, after doing a reveal, the use was not redirected to
    minting success page. It happened, because the transaction receipt, that we were
    getting with `provider.getTransactionReceipt(txHash)` method in
    `useSendLedgerLiveAppTransactionFromFn`, was not found (because it was not mined
    yet).
    
    I've implemented a fix based on our `useSendTransactionFromFn` hook. We are now
    getting a `TransactionResponse` object using `provider.getTransaction(txHash)`
    method and the wait for the transaction to be mined with `.wait()` method. This
    method will return a `TransactionReceipt` object once the transaction is mined.
    michalsmiarowski committed Nov 6, 2023
    Configuration menu
    Copy the full SHA
    46afb9b View commit details
    Browse the repository at this point in the history

Commits on Nov 7, 2023

  1. Disconnect transport when requesting eth account

    The walletApiTransport was not disconnected properly after requesting and eth
    account in `useRequestEthereumAccount()` hook. This leads to `no ongoingRequest`
    error when doing a contract transaction that uses `wallet-api-client`. I've
    actually used `connect()` instead of `disconnect()` by mistake.
    
    For more context please see 234fda3.
    michalsmiarowski committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    d04a69a View commit details
    Browse the repository at this point in the history
  2. Handle async SDK initialization

    The SDK in our Threshold lib is initialized asynchronously - the
    `_handleSdkInitialization` method returns a Promise. We need to know whenever
    the SDK is initializing or not, becuase ther might be a situation when we want
    to call a function and the SDK is in the middle of initializing.
    
    Such case happens right now for `findUtxoEffect`, after disconnecting and
    reconnecting the wallet at step 2 of the minting flow. The deposit data is
    updated in the store which triggers the `findUtxo` effect, but it can find any
    UTXOs, because `deposit` object is not yet initialized and the SDK is in the
    middle of initializing with a new signer.
    
    Becuase of that I've decided to make `_handleSdkInitialization` method public
    and rename it to `initializeSdk`. We thenn put it in `useInitializeSdk` hook
    where we can use state to indicate if the sdk is initializing or not. We also
    check if the SDK is initialized with signer or not - this will allow us to wait
    with data fetch until the we know the signer is initialized with signer.
    Finally, we call the `initiateSdk` method in our `ThresholdContext` and save the
    state data (`isSdkInitializing` and `isSdkInitializedWithSigner`) in our
    context.
    
    Now we only need to initialize `deposit` object in our `findUtxo` effect. We
    just check there if `deposit` is defined, and if it's not, we are taking the
    data from the redux store and use it to initialize deposit object, befor we call
    `findAllUnspentTransactionOutputsSdkV2` method.
    michalsmiarowski committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    947c8a5 View commit details
    Browse the repository at this point in the history
  3. Fix fetching token amount in Ledger Live App

    For the tbtc balance to fetch property (in Ledger Live App) we have to use the
    `useIsActive` hook to get the account based on the `isEmbed` flag. This will
    return Leger Live App connected account, if the app is run in Ledger Live, or
    web3 account, if the app is run on the browser.
    michalsmiarowski committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    7b86fba View commit details
    Browse the repository at this point in the history
  4. Fix Connect Wallet submit button for Ledger Live

    Fixes `Connect Wallet` submit button (that shows up instead of a real submit
    button when wallet is not connected). The button did open selectWallet modal in
    LedgerLive app, when in this case it should request the account.
    michalsmiarowski committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    9a44303 View commit details
    Browse the repository at this point in the history
  5. Return prefixed tx hash when revealing a deposit

    I've noticed that we should actually return an already prefixed tx hash from the
    method in our TBTC class. This way we don't have to add prefix in
    `useSendLedgerLiveAppTransactionFromFn` hook.
    michalsmiarowski committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    efef52d View commit details
    Browse the repository at this point in the history
  6. Implement unminting flow with SDK v1

    Note: This flow will work only with the newest version of tbtc-v2.ts that is not
    yet released. Once it is I will update the version in a separate commit.
    
    Implements whole unminting process with tbtc-v2.ts SDK (v2). The unminting process
    is being implemented in a separate PR, so this is a quick implementation to make
    the whole process easier once the implementation PR is merged (and to make sure
    it will work with new SDK).
    
    For this, I've created a separate method in our `TBTC` class:
    `requestRedemptionSdkV2`, which is then used in `useRquestRedemption` hook.
    michalsmiarowski committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    1fe279f View commit details
    Browse the repository at this point in the history
  7. Fix building a redemption link

    After requesting a redemption the error appears, because we used address from
    `useWeb3React` hook to build redemption details account. The error also appeard
    after connecting the account, when we have unmint in our Bridge Activity.
    
    This commit fixes that. It uses account from `useIsActive` hook instead of the
    one from `useWeb3React` hook.
    michalsmiarowski committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    ff28f60 View commit details
    Browse the repository at this point in the history
  8. Add manifest.json file for Ledger Live App

    Adds manifest.json file to the repository. It is a config file that allows
    external applications and dApps to be integrated inside the Ledger Live software
    as a Live app and interact with all provided features.
    michalsmiarowski committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    ae7804d View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2023

  1. Display Continue mint button only for Live App

    We should display Continue Mint button in Step 1 of the minting flow only when
    the `isEmbed` flag is set to true (which means that only if our dApp is run
    inside Ledger Live as Live App.
    michalsmiarowski committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    fb0c3a2 View commit details
    Browse the repository at this point in the history
  2. Add a posisbility to send exact amount of BTC

    Adds an input form that allows the user to enter bitcoin amount that he wants to
    send to the deposit address. It will only show when `isEmbed` flag is set to
    true.
    
    There were some additional changes required to make it possible.
    
    First of all, I've adedd additional parameter to `TokenBalanceInputProps` -
    `tokenDecimals`. This way it will be possible to pass that parameter to
    `TokenBalanceInput` component through `FormikTokenBalanceInput` component, and
    it will allow to specify the input for the token we want to use. For example,
    without that, whenever we put the amount in `FormikTokenBalanceInput`, it will
    automatically convert that to wei (amount*10^18), which means that we can't use
    it with bitcoin, that has only 8 decimal places. After the change, we can pass
    `tokenDecimals = 8`, to make the `FormikTokenBalanceInput` working for bitcoin
    amounts.
    
    Second of all, there were some changes needed in `stc/utils/forms`, espcially
    with the `defaultGreaterThanMsg` and `defaultLessThanMsg`. The form uses
    `formatTokenAmount` which also worked with default 18 decimals and 2 precision.
    This means, that when we've put a value that is greater than our bitcoin balance
    (let's say our btc balance is 0.66666), it would siplay an error: The value
    should be less than or equal `~0.67` + it would break the app. To fix that we
    have to pass 8 decimals nad 8 precision there.
    michalsmiarowski committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    15617dd View commit details
    Browse the repository at this point in the history
  3. Improve data loading after connecting account

    This improves data loading with SDK v2 when we connect a wallet. Right now the
    problem is that when we've genrated a deposit address (so we are at step 2 of
    the minting flow), then refresh the page and then connect again, the page will
    show step 1 (provide data) for a second before displaying loading state and then
    step 2 (when we finished before we refreshed a page).
    
    This commit fixes that, and it won't show step 1 in such case. Still, there is
    small issue, because before SDK v2, the data was laoded just after connecting an
    account and now you have to wait ~1sec for it to start loading (due to sdk
    async initialization). I will attempt to fix that in future commits.
    michalsmiarowski committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    4d6d4e1 View commit details
    Browse the repository at this point in the history

Commits on Nov 9, 2023

  1. Trigger loading state for step 2 ASAP

    When the user had deposit data in local storage and connects the wallet, there
    was like ~1 seconds delay before it showed the loading state of the mintin step.
    With old tbtc-v2.ts version it started loading as soon as user connected the
    wallet. This commit fixes that for SDK v2. I've also described this issue in the
    previous commit: `4d6d4e185d16750db687a1dfe6b94b37a3f8e2f0`.
    michalsmiarowski committed Nov 9, 2023
    Configuration menu
    Copy the full SHA
    fa1aad0 View commit details
    Browse the repository at this point in the history

Commits on Nov 22, 2023

  1. Configuration menu
    Copy the full SHA
    bf3c3e3 View commit details
    Browse the repository at this point in the history

Commits on Nov 23, 2023

  1. Improve passing Ledger Live signer to threshold-ts

    The LedgerLiveAppEthereumSigner is now passed in `providerOrSigner` property of
    the `EthereumConfig` type. When the user is not connected we will use the
    default threshold lib provider, and when he conects the wallet we will pass the
    signer through ThresholdContext's useEffect (as `providerOrSigner` prop).
    
    The signer will also be stored in `LedgerLiveAppContext` so that we can update
    it's account in the dApp, and we will be sure we use the same instance of it.
    michalsmiarowski committed Nov 23, 2023
    Configuration menu
    Copy the full SHA
    bfffe4f View commit details
    Browse the repository at this point in the history
  2. Simplify contexts

    useContext(LedgerLiveAppContext) -> useLedgerLiveApp()
    useContext(WalletApiReactTransportContext) -> useWalletApiReactTransport()
    michalsmiarowski committed Nov 23, 2023
    Configuration menu
    Copy the full SHA
    c0db65b View commit details
    Browse the repository at this point in the history

Commits on Nov 27, 2023

  1. Use ledger live app signer from tbtc-v2.ts

    Removes `ledger-live-app-eth-signer` folder and imports the ledger live app
    signer from `tbtc-v2.ts` lib instead.
    michalsmiarowski committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    ceec2f1 View commit details
    Browse the repository at this point in the history
  2. Fix disconnecting account for ledger live app

    fetchTvl() function did not work properly in LedgerLiveApp, when we diconnected
    an account. It happened, because the ledger live signer account was set to
    undefined and it used it as `provideOrSigner` instead of default threshold lib
    provider (`fetchTvl()` happened before the threshold lib was reinitialized after
    account disconnected).
    
    This commit fixed that.
    michalsmiarowski committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    bf790b6 View commit details
    Browse the repository at this point in the history
  3. Improve useInitializeTbtcSdk hook

    Moves `setIsInitializing(false)` line at the very end, so that it properly
    indicated that the initialization wass completed and the resty of the
    parameters, like `isInitialized` and `setIsInitializedWithSigner`, are set.
    michalsmiarowski committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    b91165a View commit details
    Browse the repository at this point in the history
  4. Fix unmint page throwing error

    The unmint page was not loaded properly when we connect the account. It happened
    because fo the mistake in 4d6d4e1. The
    `<Outlet>` should be displayed when sdk is NOT initialing anymore, not when it's
    initializing.
    michalsmiarowski committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    ac67427 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    1749ac5 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    1de4b84 View commit details
    Browse the repository at this point in the history
  7. Fix useGetBlock hook

    We have to check if the providerOrSigner from threshold lib is an instance of
    `LedgerLiveEthereumSigner`. If yes then we won't call `getProviderOrSigner`
    method.
    michalsmiarowski committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    df20497 View commit details
    Browse the repository at this point in the history
  8. Fix tbtc balance not displaying in Ledger Live App

    The balance was displayed only when `active` property from `useWeb3React` hook
    was set to true, which was wrong, because it should use `isActive` property from
    `useIsActive` hook.
    michalsmiarowski committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    d8c4335 View commit details
    Browse the repository at this point in the history

Commits on Nov 28, 2023

  1. Remove useSendLedgerLiveAppTransactionFromFn

    The `useSendLedgerLiveAppTransactionFromFn` hook is very similar to
    `useSendTransactionFromFn` hook so I think it would be best to keep it all in
    one hook to avoid code duplication.
    michalsmiarowski committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    e3bcd82 View commit details
    Browse the repository at this point in the history
  2. Rename useEmbedFeatureFlag hook

    `useEmbedFeatureFlag` -> `useIsEmbed`
    michalsmiarowski committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    e0ade29 View commit details
    Browse the repository at this point in the history

Commits on Dec 8, 2023

  1. Improve manifest

    michalsmiarowski committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    a65ca81 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    03fc8c4 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    af42575 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f65103a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    1958cfa View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    683115e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    84a6bf7 View commit details
    Browse the repository at this point in the history

Commits on Dec 13, 2023

  1. Detect properly if application is embed

    To this point we detected if the application is embed in Ledger Live App by
    checking if it had `?embed=true` query parameter in the url and then saving it
    it local storage. It was problematic because the query parameter would have to
    be in the url only once to apply that change, so refreshing the page would not
    reset that state (which is good for ledger live app, but bad is someone pass
    that query parameter on the website - he would have to remove it manually from
    the local storage).
    
    To resolve this I've created `useDetectIfEmbed` hook that detects if application
    is Embed based on the `?embed=true` query parameter and saves that information
    to local storage (under `isEmbed` property).  Besides that it will also set
    `?embed=true` query parameter for every url if the `isEmbed` property is set to
    true in local storage. This will persist the embed flag when the user refreshes
    the page unless he removes the `?embed=true` query parameter from the url.
    
    This will produce the result we desire - it will persist the embed mode for
    ledger live app and remove it on the website once the query parameter is not
    provided in the url.
    michalsmiarowski committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    6903e90 View commit details
    Browse the repository at this point in the history
  2. Remove embed param from "homepageUrl" in manifest

    The param is needed only in "url".
    michalsmiarowski committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    790c240 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    aa77615 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    2e5ce7d View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    f90bfc8 View commit details
    Browse the repository at this point in the history
  6. Remove unnecessary change in import order

    Let's keep it the same as it is on `main` branch.
    michalsmiarowski committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    c0a6e36 View commit details
    Browse the repository at this point in the history
  7. Extract send bitcoins form to separate file

    Extracts `SendBitcoinsToDepositAddressForm` to a separate file to make the
    `MakeDeposit` file cleaner.
    michalsmiarowski committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    a993ab7 View commit details
    Browse the repository at this point in the history