Skip to content

Commit

Permalink
docs: add FederationService docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlwn123 committed Dec 5, 2024
1 parent 7464ec2 commit 9a8bf15
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
6 changes: 5 additions & 1 deletion docs/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ const FedimintWalletSidebar = [
{
text: 'FederationService',
base: '/core/FedimintWallet/FederationService/',
items: [{ text: 'Docs TODO' }],
items: [
{ text: 'getConfig()', link: 'getConfig' },
{ text: 'getFederationId()', link: 'getFederationId' },
{ text: 'getInviteCode()', link: 'getInviteCode' },
],
},
{
text: 'RecoveryService',
Expand Down
15 changes: 15 additions & 0 deletions docs/core/FedimintWallet/FederationService/getConfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Redeem Ecash

### `federation.getConfig()`

Access configuration details about a connected federation.

```ts twoslash
// @esModuleInterop
import { FedimintWallet } from '@fedimint/core-web'

const wallet = new FedimintWallet()
wallet.open()

const config = await wallet.federation.getConfig() // [!code focus]
```
15 changes: 15 additions & 0 deletions docs/core/FedimintWallet/FederationService/getFederationId.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Redeem Ecash

### `federation.getFederationId()`

Access the `federationId` of the connected Federation.

```ts twoslash
// @esModuleInterop
import { FedimintWallet } from '@fedimint/core-web'

const wallet = new FedimintWallet()
wallet.open()

const config = await wallet.federation.getFederationId() // [!code focus]
```
17 changes: 17 additions & 0 deletions docs/core/FedimintWallet/FederationService/getInviteCode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Redeem Ecash

### `federation.getInviteCode()`

Access the invite code for the connected federation.

```ts twoslash
// @esModuleInterop
import { FedimintWallet } from '@fedimint/core-web'

const wallet = new FedimintWallet()
wallet.open()

const peerId = 0 // Index of the guardian to ask for the invite code // [!code focus]

const inviteCode = await wallet.federation.getInviteCode(peerId) // [!code focus]
```
2 changes: 1 addition & 1 deletion packages/core-web/src/services/FederationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class FederationService {
return await this.client.rpcSingle<string>('', 'get_federation_id', {})
}

async getInviteCode(peer: number) {
async getInviteCode(peer: number = 0) {
return await this.client.rpcSingle<string | null>('', 'get_invite_code', {
peer,
})
Expand Down

0 comments on commit 9a8bf15

Please sign in to comment.