diff --git a/package.json b/package.json index 489deaf..cf4fde0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@syndicateio/syndicate-node", - "version": "0.0.428", + "version": "0.0.441", "private": false, "repository": "https://github.com/SyndicateProtocol/syndicate-node", "main": "./index.js", @@ -11,9 +11,9 @@ "prepack": "cp -rv dist/. ." }, "dependencies": { + "@ungap/url-search-params": "0.2.2", "url-join": "4.0.1", "@types/url-join": "4.0.1", - "@ungap/url-search-params": "0.2.2", "js-base64": "3.7.2", "axios": "0.27.2" }, diff --git a/src/Client.ts b/src/Client.ts index ac41139..9fc3e5c 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -3,8 +3,8 @@ */ import * as core from "./core"; -import { Transact } from "./api/resources/transact/client/Client"; import { Funding } from "./api/resources/funding/client/Client"; +import { Transact } from "./api/resources/transact/client/Client"; import { Wallet } from "./api/resources/wallet/client/Client"; export declare namespace SyndicateClient { @@ -20,18 +20,18 @@ export declare namespace SyndicateClient { export class SyndicateClient { constructor(protected readonly _options: SyndicateClient.Options) {} - protected _transact: Transact | undefined; - - public get transact(): Transact { - return (this._transact ??= new Transact(this._options)); - } - protected _funding: Funding | undefined; public get funding(): Funding { return (this._funding ??= new Funding(this._options)); } + protected _transact: Transact | undefined; + + public get transact(): Transact { + return (this._transact ??= new Transact(this._options)); + } + protected _wallet: Wallet | undefined; public get wallet(): Wallet { diff --git a/src/api/resources/funding/client/Client.ts b/src/api/resources/funding/client/Client.ts index 5796730..ba05e35 100644 --- a/src/api/resources/funding/client/Client.ts +++ b/src/api/resources/funding/client/Client.ts @@ -48,7 +48,7 @@ export class Funding { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@syndicateio/syndicate-node", - "X-Fern-SDK-Version": "0.0.428", + "X-Fern-SDK-Version": "0.0.441", }, contentType: "application/json", queryParameters: _queryParams, diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 6d9a8bc..728fa3f 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -1,3 +1,3 @@ -export * as transact from "./transact"; export * as funding from "./funding"; +export * as transact from "./transact"; export * as wallet from "./wallet"; diff --git a/src/api/resources/transact/client/Client.ts b/src/api/resources/transact/client/Client.ts index f2a367e..b9daccc 100644 --- a/src/api/resources/transact/client/Client.ts +++ b/src/api/resources/transact/client/Client.ts @@ -40,7 +40,7 @@ export class Transact { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@syndicateio/syndicate-node", - "X-Fern-SDK-Version": "0.0.428", + "X-Fern-SDK-Version": "0.0.441", }, contentType: "application/json", body: await serializers.transact.SendTransactionRequest.jsonOrThrow(request, { diff --git a/src/api/resources/wallet/client/Client.ts b/src/api/resources/wallet/client/Client.ts index 51af04b..d8778fb 100644 --- a/src/api/resources/wallet/client/Client.ts +++ b/src/api/resources/wallet/client/Client.ts @@ -38,7 +38,7 @@ export class Wallet { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@syndicateio/syndicate-node", - "X-Fern-SDK-Version": "0.0.428", + "X-Fern-SDK-Version": "0.0.441", }, contentType: "application/json", body: await serializers.wallet.CreateWalletRequest.jsonOrThrow(request, { @@ -104,7 +104,7 @@ export class Wallet { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@syndicateio/syndicate-node", - "X-Fern-SDK-Version": "0.0.428", + "X-Fern-SDK-Version": "0.0.441", }, contentType: "application/json", body: await serializers.wallet.RetireWalletRequest.jsonOrThrow(request, { @@ -148,6 +148,65 @@ export class Wallet { } } + /** + * Toggle a wallet's isActive status + * @throws {@link Syndicate.wallet.WalletNotFoundError} + */ + public async toggleIsActive( + request: Syndicate.wallet.ToggleIsActiveRequest, + requestOptions?: Wallet.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin(environments.SyndicateEnvironment.Production, "/wallet/toggleIsActive"), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@syndicateio/syndicate-node", + "X-Fern-SDK-Version": "0.0.441", + }, + contentType: "application/json", + body: await serializers.wallet.ToggleIsActiveRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.wallet.Wallet.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Syndicate.wallet.WalletNotFoundError(); + default: + throw new errors.SyndicateError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.SyndicateError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.SyndicateTimeoutError(); + case "unknown": + throw new errors.SyndicateError({ + message: _response.error.errorMessage, + }); + } + } + /** * Get a transaction request by id * @throws {@link Syndicate.wallet.TransactionNotFoundError} @@ -167,7 +226,7 @@ export class Wallet { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@syndicateio/syndicate-node", - "X-Fern-SDK-Version": "0.0.428", + "X-Fern-SDK-Version": "0.0.441", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, @@ -242,7 +301,7 @@ export class Wallet { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@syndicateio/syndicate-node", - "X-Fern-SDK-Version": "0.0.428", + "X-Fern-SDK-Version": "0.0.441", }, contentType: "application/json", queryParameters: _queryParams, @@ -306,7 +365,7 @@ export class Wallet { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@syndicateio/syndicate-node", - "X-Fern-SDK-Version": "0.0.428", + "X-Fern-SDK-Version": "0.0.441", }, contentType: "application/json", queryParameters: _queryParams, @@ -391,7 +450,7 @@ export class Wallet { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@syndicateio/syndicate-node", - "X-Fern-SDK-Version": "0.0.428", + "X-Fern-SDK-Version": "0.0.441", }, contentType: "application/json", queryParameters: _queryParams, @@ -442,7 +501,7 @@ export class Wallet { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@syndicateio/syndicate-node", - "X-Fern-SDK-Version": "0.0.428", + "X-Fern-SDK-Version": "0.0.441", }, contentType: "application/json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, diff --git a/src/api/resources/wallet/errors/WalletNotFoundError.ts b/src/api/resources/wallet/errors/WalletNotFoundError.ts new file mode 100644 index 0000000..92bf492 --- /dev/null +++ b/src/api/resources/wallet/errors/WalletNotFoundError.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../../../errors"; + +export class WalletNotFoundError extends errors.SyndicateError { + constructor() { + super({ + statusCode: 404, + }); + Object.setPrototypeOf(this, WalletNotFoundError.prototype); + } +} diff --git a/src/api/resources/wallet/errors/index.ts b/src/api/resources/wallet/errors/index.ts index 9cdf9d7..3c66206 100644 --- a/src/api/resources/wallet/errors/index.ts +++ b/src/api/resources/wallet/errors/index.ts @@ -1,4 +1,5 @@ export * from "./CreateWalletError"; export * from "./RetireWalletError"; +export * from "./WalletNotFoundError"; export * from "./TransactionNotFoundError"; export * from "./GetWalletsError"; diff --git a/src/api/resources/wallet/types/ToggleIsActiveRequest.ts b/src/api/resources/wallet/types/ToggleIsActiveRequest.ts new file mode 100644 index 0000000..bea7888 --- /dev/null +++ b/src/api/resources/wallet/types/ToggleIsActiveRequest.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ToggleIsActiveRequest { + projectId: string; + walletAddress: string; +} diff --git a/src/api/resources/wallet/types/TransactionStatus.ts b/src/api/resources/wallet/types/TransactionStatus.ts index 6742d50..162d321 100644 --- a/src/api/resources/wallet/types/TransactionStatus.ts +++ b/src/api/resources/wallet/types/TransactionStatus.ts @@ -2,10 +2,11 @@ * This file was auto-generated by Fern from our API Definition. */ -export type TransactionStatus = "PENDING" | "SUBMITTED" | "CONFIRMED"; +export type TransactionStatus = "PENDING" | "PROCESSED" | "SUBMITTED" | "CONFIRMED"; export const TransactionStatus = { Pending: "PENDING", + Processed: "PROCESSED", Submitted: "SUBMITTED", Confirmed: "CONFIRMED", } as const; diff --git a/src/api/resources/wallet/types/index.ts b/src/api/resources/wallet/types/index.ts index 4c68be0..36e0274 100644 --- a/src/api/resources/wallet/types/index.ts +++ b/src/api/resources/wallet/types/index.ts @@ -4,6 +4,7 @@ export * from "./WalletType"; export * from "./CreateWalletResponse"; export * from "./CreateWalletErrorBody"; export * from "./WalletWithTxCountAndBalance"; +export * from "./ToggleIsActiveRequest"; export * from "./RetireWalletRequest"; export * from "./RetireWalletResponse"; export * from "./TransactionResponse"; diff --git a/src/serialization/resources/index.ts b/src/serialization/resources/index.ts index 6d9a8bc..728fa3f 100644 --- a/src/serialization/resources/index.ts +++ b/src/serialization/resources/index.ts @@ -1,3 +1,3 @@ -export * as transact from "./transact"; export * as funding from "./funding"; +export * as transact from "./transact"; export * as wallet from "./wallet"; diff --git a/src/serialization/resources/wallet/types/ToggleIsActiveRequest.ts b/src/serialization/resources/wallet/types/ToggleIsActiveRequest.ts new file mode 100644 index 0000000..2f390a4 --- /dev/null +++ b/src/serialization/resources/wallet/types/ToggleIsActiveRequest.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as Syndicate from "../../../../api"; +import * as core from "../../../../core"; + +export const ToggleIsActiveRequest: core.serialization.ObjectSchema< + serializers.wallet.ToggleIsActiveRequest.Raw, + Syndicate.wallet.ToggleIsActiveRequest +> = core.serialization.object({ + projectId: core.serialization.string(), + walletAddress: core.serialization.string(), +}); + +export declare namespace ToggleIsActiveRequest { + interface Raw { + projectId: string; + walletAddress: string; + } +} diff --git a/src/serialization/resources/wallet/types/TransactionStatus.ts b/src/serialization/resources/wallet/types/TransactionStatus.ts index 4ad6226..63d8f2d 100644 --- a/src/serialization/resources/wallet/types/TransactionStatus.ts +++ b/src/serialization/resources/wallet/types/TransactionStatus.ts @@ -9,8 +9,8 @@ import * as core from "../../../../core"; export const TransactionStatus: core.serialization.Schema< serializers.wallet.TransactionStatus.Raw, Syndicate.wallet.TransactionStatus -> = core.serialization.enum_(["PENDING", "SUBMITTED", "CONFIRMED"]); +> = core.serialization.enum_(["PENDING", "PROCESSED", "SUBMITTED", "CONFIRMED"]); export declare namespace TransactionStatus { - type Raw = "PENDING" | "SUBMITTED" | "CONFIRMED"; + type Raw = "PENDING" | "PROCESSED" | "SUBMITTED" | "CONFIRMED"; } diff --git a/src/serialization/resources/wallet/types/index.ts b/src/serialization/resources/wallet/types/index.ts index 4c68be0..36e0274 100644 --- a/src/serialization/resources/wallet/types/index.ts +++ b/src/serialization/resources/wallet/types/index.ts @@ -4,6 +4,7 @@ export * from "./WalletType"; export * from "./CreateWalletResponse"; export * from "./CreateWalletErrorBody"; export * from "./WalletWithTxCountAndBalance"; +export * from "./ToggleIsActiveRequest"; export * from "./RetireWalletRequest"; export * from "./RetireWalletResponse"; export * from "./TransactionResponse";