Skip to content

Commit

Permalink
fix: update typescript wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow committed Oct 9, 2024
1 parent 1746851 commit ce15189
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
7 changes: 1 addition & 6 deletions wrappers/fedimint-ts/src/FedimintClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
MintValidateResponse,
OnchainAwaitDepositRequest,
OnchainAwaitDepositResponse,
OnchainDepositAddressRequest,
OnchainDepositAddressResponse,
OnchainWithdrawRequest,
OnchainWithdrawResponse,
Expand Down Expand Up @@ -612,17 +611,13 @@ export class FedimintClient {
public onchain = {
/**
* Creates a new bitcoin deposit address to peg in bitcoin to the federation.
* @param timeout - The number of seconds for the fedimint-clientd to watch for a deposit to the created address
*/
createDepositAddress: async (
timeout: number,
federationId?: string
): Promise<OnchainDepositAddressResponse> => {
const request: OnchainDepositAddressRequest = { timeout };

return await this.postWithFederationId<OnchainDepositAddressResponse>(
"/onchain/deposit-address",
request,
{},
federationId
);
},
Expand Down
7 changes: 2 additions & 5 deletions wrappers/fedimint-ts/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@ export interface OperationOutput {
outcome?: any;
}

export interface OnchainDepositAddressRequest {
timeout: number;
}

export interface OnchainDepositAddressResponse {
operationId: string;
address: string;
tweakIdx: number;
}

export interface OnchainAwaitDepositRequest {
Expand Down Expand Up @@ -239,7 +236,7 @@ export interface MintEncodeNotesRequest {
}

export interface MintEncodeNotesResponse {
notes: string;
notesJson: string;
}

export interface MintReissueRequest {
Expand Down
16 changes: 10 additions & 6 deletions wrappers/fedimint-ts/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ async function main() {
logInputAndOutput({ notes: mintData.notes }, data);
// `/v2/mint/encode-notes`
logMethod("/v2/mint/encode-notes");
data = await fedimintClient.mint.encodeNotes(data.notesJson);
logInputAndOutput({ notesJson: data.notesJson }, data);
const encodeData = await fedimintClient.mint.encodeNotes(data.notesJson);
logInputAndOutput({ notesJson: data.notesJson }, encodeData);
// `/v2/mint/validate`
logMethod("/v2/mint/validate");
data = await fedimintClient.mint.validate(mintData.notes);
Expand All @@ -219,12 +219,16 @@ async function main() {
// ONCHAIN METHODS
// `/v2/onchain/deposit-address`
logMethod("/v2/onchain/deposit-address");
data = await fedimintClient.onchain.createDepositAddress(1000);
logInputAndOutput({ timeout: 1000 }, data);
data = await fedimintClient.onchain.createDepositAddress();
logInputAndOutput({}, data);
// `/v2/onchain/withdraw`
logMethod("/v2/onchain/withdraw");
data = await fedimintClient.onchain.withdraw(data.address, 1000);
logInputAndOutput({ address: data.address, amountSat: 1000 }, data);
const withdrawData = await fedimintClient.onchain.withdraw(
data.address,
1000
);
console.log("Withdrew: ", withdrawData);
logInputAndOutput({ address: data.address, amountSat: 1000 }, withdrawData);
// // `/v2/onchain/await-deposit`
// logMethod("/v2/onchain/await-deposit");
// data = await fedimintClient.onchain.awaitDeposit(data.operationId);
Expand Down

0 comments on commit ce15189

Please sign in to comment.