fedimint-web-sdk icon indicating copy to clipboard operation
fedimint-web-sdk copied to clipboard

Feature Request: previewFederation

Open IroncladDev opened this issue 10 months ago • 24 comments

I want to pass an invite code into a previewFederation function to get information about the federation such as API endpoints, federation ID, etc

IroncladDev avatar Jan 28 '25 15:01 IroncladDev

just work on it, you don't need assignment to start working

maan2003 avatar Mar 20 '25 15:03 maan2003

@IroncladDev @maan2003 I have investigated the issue and I have a solution, but it requires the fedimint-client rust code to be modified as well along with the webSDK. I am participating in the Summer of bitcoin 2025 and want to know if I am going in the right direction.

dhruv2185 avatar Mar 26 '25 20:03 dhruv2185

yes

maan2003 avatar Mar 26 '25 20:03 maan2003

So, am I supposed to submit a PR or just submit my solution with explanation along with the proposal only?

dhruv2185 avatar Mar 26 '25 20:03 dhruv2185

submit PRs to fedimint and websdk

maan2003 avatar Mar 26 '25 20:03 maan2003

Hi @maan2003 , I am interesting in it. So we need to create a function that give the details of federation by using there invite code. So we need to function in fedimint ( Rust). While we will use that function in websdk by editing the services code ? Please confirm
Thanks

AQIB-NAWAB avatar Mar 29 '25 05:03 AQIB-NAWAB

yes

maan2003 avatar Mar 29 '25 11:03 maan2003

yes

Thanks

AQIB-NAWAB avatar Mar 29 '25 14:03 AQIB-NAWAB

I'm repeating the question or am I misunderstanding something? but isn't this issue same as https://github.com/fedimint/fedimint-web-sdk/pull/128/commits/8b04468ae76f6c74a260cd90e3cb1c8caa7b432a#diff-18a743b7d403b74f4401d46650dc08b502829c007ab40477963c4226707d7884

parseInviteCode(inviteCode): Promise<{ url: string; federation_id: string }>

parseInviteCode takes inviteCode and returns federation ID and endpoints. this is all we want for the preview Federation takes the invite code as a parameter and returns the federation ID and API endpoints.

Please correct me if I'm wrong !

or in previewFederation the extra feature is we have to extract all info of a federation 1>getConfig 2>getFederationId 3>listOperations

this would be the key difference between previewFederation and parseInviteCode?

Akshanshkaushal avatar Apr 01 '25 06:04 Akshanshkaushal

previewFederation will make requests to federation to get its config and meta WITHOUT joining the federation

parseInviteCode is entirely local function

maan2003 avatar Apr 01 '25 07:04 maan2003

@maan2003 Got it, thanks ! I have implemented the logic in fedimint-client-wasm in the fedimint backend; now how can we use the functionality in web-sdk? Can we use it locally by using the build pkg in web-sdk, or do we have to deploy it first to use it? Please guide on this .

Akshanshkaushal avatar Apr 01 '25 09:04 Akshanshkaushal

where is the fedimint PR? you have to rebuild wasm from that commit

maan2003 avatar Apr 01 '25 09:04 maan2003

I didn't make the PR yet. OK, so firstly, have to make a Fedimint PR, then use that commit and rebuild WASM from that to use in the web SDK? But for this that PR have to merged ? Am I on the right path?

Akshanshkaushal avatar Apr 01 '25 10:04 Akshanshkaushal

Yes

maan2003 avatar Apr 01 '25 10:04 maan2003

OK, thanks, and there's no way we can test the functionality locally by using the build files from Fedimint and using that in web-SDK for testing purposes, or the only way is for the Fedimint PR to be merged, and then only can we use the functionality?

Akshanshkaushal avatar Apr 01 '25 10:04 Akshanshkaushal

you can test locally, by build wasm locally and copying it over

maan2003 avatar Apr 01 '25 10:04 maan2003

but would recommend opening a fedimint draft PR

maan2003 avatar Apr 01 '25 10:04 maan2003

Sure, Thank you for responding to the questions!

Akshanshkaushal avatar Apr 01 '25 10:04 Akshanshkaushal

@maan2003 I have submitted a Draft PR for the backend logic for previewFederation. Would you please review it ? https://github.com/fedimint/fedimint/pull/7136

Akshanshkaushal avatar Apr 01 '25 19:04 Akshanshkaushal

@maan2003 The project details on the Summer of Bitcoin page mention that we need to propose a solution to this issue. I have already included the details in my proposal on how we can plan to tackle it. Could you please clarify whether implementation is also required?

MrImmortal09 avatar Apr 01 '25 23:04 MrImmortal09

the competency tests are entirely optional. Yes, having a PR for it would be nice.

@MrImmortal09 you have already proved your competency with rest of PRs, so feel free to skip it.

maan2003 avatar Apr 02 '25 07:04 maan2003

Successfully implemented previewFederation in the backend. @maan2003 @alexlwn123, is there any other data I should include?

Image

Shortened Json output:

{
  "config": {
    "api_endpoints": {
      "0": {
        "name": "Devimint Guardian 0",
        "url": "ws://127.0.0.1:10033/"
      },
      "1": {
        "name": "Devimint Guardian 1",
        "url": "ws://127.0.0.1:10037/"
      },
      "2": {
        "name": "Devimint Guardian 2",
        "url": "ws://127.0.0.1:10041/"
      },
      "3": {
        "name": "Devimint Guardian 3",
        "url": "ws://127.0.0.1:10045/"
      }
    },
    "broadcast_public_keys": {
      "0": "03f7ecf3c94131a05cfa13d32bca5feac79fcabda720e3c2dd987bf6f1c3a69c0e",
      "1": "027039664c2b14625b2ce952829aa8de9cb1a0c96d2163517f07e4abaa93058a4c",
      "2": "0310fd5a11ade059176f86cc8c7c6fe5af962bbe9fc3e839eab61863df52010586",
      "3": "028b0a41597552249b04b96ea3a74b298a6b333d17c0425dea2d022da57c905607"
    },
    "consensus_version": {
      "major": 2,
      "minor": 1
    },
    "meta": {
      "federation_name": "Devimint Federation"
    },
    "modules": {
      "0": {
        "config": "a very big string here",
        "kind": "ln",
        "version": {
          "major": 2,
          "minor": 0
        }
      },
      "1": {
        "config": "very big string here",
        "kind": "mint",
        "version": {
          "major": 2,
          "minor": 0
        }
      },
      "2": {
        "config": "02fd0157fd012877736828736f727465646d756c746928332c...",
        "kind": "wallet",
        "version": {
          "major": 2,
          "minor": 2
        }
        "----->" : " few more configs here "
      }
    }
  },
  "federation_id": "a56c0abad73973088995e28265ce43d365db9414a78a140a715073beee3ae81c",
  "pref_url": "ws://127.0.0.1:10041/"
}

MrImmortal09 avatar Apr 03 '25 13:04 MrImmortal09

is there any other data I should include?

@MrImmortal09

Nice! Couple questions

  • What does perf_url mean? Is it just one of the guardian endpoints?
  • Thinking we should decode the hex data in the config field. Do you think it'd be better to do this on the rust side or the js?

alexlwn123 avatar Apr 04 '25 19:04 alexlwn123

  • What does perf_url mean? Is it just one of the guardian endpoints?
  • Thinking we should decode the hex data in the config field. Do you think it'd be better to do this on the rust side or the js?

Yes, the perf_url is one of the guardian endpoints — I used that term for debugging purposes. Regarding decoding the hex data, I believe it’s more appropriate to handle it on the Rust side. Decoding it in JavaScript would likely be more complex, as it would require manual parsing. Handling it in Rust allows us to return clean, structured JSON to the frontend and avoid redundant effort.

MrImmortal09 avatar Apr 05 '25 10:04 MrImmortal09

closed per https://github.com/fedimint/fedimint/pull/7200 & https://github.com/fedimint/fedimint-web-sdk/pull/155

alexlwn123 avatar Jun 04 '25 02:06 alexlwn123

Awesome

IroncladDev avatar Jun 04 '25 13:06 IroncladDev