Skip to content

Commit

Permalink
Release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Sep 27, 2023
1 parent 4806bc5 commit f424f61
Show file tree
Hide file tree
Showing 141 changed files with 3,688 additions and 1 deletion.
1 change: 1 addition & 0 deletions .fernignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Specify files that shouldn't be modified by Fern
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: ci

on: [push]

jobs:
compile:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3

- name: Compile
run: yarn && yarn build

publish:
needs: [ compile ]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3

- name: Install dependencies
run: yarn install

- name: Build
run: yarn build

- name: Publish to npm
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules
.DS_Store
/dist
/Client.d.ts
/Client.js
/environments.d.ts
/environments.js
/index.d.ts
/index.js
/api
/core
/errors
/serialization
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
src
.gitignore
.github
.fernignore
.prettierrc.yml
tsconfig.json
yarn.lock
2 changes: 2 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tabWidth: 4
printWidth: 120
1 change: 0 additions & 1 deletion README.md

This file was deleted.

25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@syndicateio/syndicate-node",
"version": "1.0.0",
"private": false,
"repository": "https://github.com/SyndicateProtocol/syndicate-node",
"main": "./index.js",
"types": "./index.d.ts",
"scripts": {
"format": "prettier --write 'src/**/*.ts'",
"build": "tsc",
"prepack": "cp -rv dist/. ."
},
"dependencies": {
"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"
},
"devDependencies": {
"@types/node": "17.0.33",
"prettier": "2.7.1",
"typescript": "4.6.4"
}
}
33 changes: 33 additions & 0 deletions src/Client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as core from "./core";
import { Transact } from "./api/resources/transact/client/Client";
import { Wallet } from "./api/resources/wallet/client/Client";

export declare namespace SyndicateClient {
interface Options {
token: core.Supplier<core.BearerToken>;
}

interface RequestOptions {
timeoutInSeconds?: number;
}
}

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 _wallet: Wallet | undefined;

public get wallet(): Wallet {
return (this._wallet ??= new Wallet(this._options));
}
}
1 change: 1 addition & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./resources";
2 changes: 2 additions & 0 deletions src/api/resources/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * as transact from "./transact";
export * as wallet from "./wallet";
110 changes: 110 additions & 0 deletions src/api/resources/transact/client/Client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as core from "../../../../core";
import * as Syndicate from "../../..";
import * as serializers from "../../../../serialization";
import * as environments from "../../../../environments";
import urlJoin from "url-join";
import * as errors from "../../../../errors";

export declare namespace Transact {
interface Options {
token: core.Supplier<core.BearerToken>;
}

interface RequestOptions {
timeoutInSeconds?: number;
}
}

export class Transact {
constructor(protected readonly _options: Transact.Options) {}

/**
* Send transaction to blockchain
* @throws {@link Syndicate.transact.MalformedFunctionDataError}
* @throws {@link Syndicate.transact.ImATeapotError}
* @throws {@link Syndicate.transact.InternalError}
* @throws {@link Syndicate.transact.InvalidRequestIdError}
*/
public async sendTransaction(
request: Syndicate.transact.SendTransactionRequest,
requestOptions?: Transact.RequestOptions
): Promise<Syndicate.transact.SendTransactionResponse> {
const _response = await core.fetcher({
url: urlJoin(environments.SyndicateEnvironment.Production, "/transact/sendTransaction"),
method: "POST",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@syndicateio/syndicate-node",
"X-Fern-SDK-Version": "1.0.0",
},
contentType: "application/json",
body: await serializers.transact.SendTransactionRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "strip",
}),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
});
if (_response.ok) {
return await serializers.transact.SendTransactionResponse.parseOrThrow(_response.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
});
}

if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 400:
throw new Syndicate.transact.MalformedFunctionDataError(
await serializers.transact.ErrorWithMessage.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
case 418:
throw new Syndicate.transact.ImATeapotError();
case 500:
throw new Syndicate.transact.InternalError();
case 422:
throw new Syndicate.transact.InvalidRequestIdError(
await serializers.transact.ErrorWithMessage.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
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,
});
}
}

protected async _getAuthorizationHeader() {
return `Bearer ${await core.Supplier.get(this._options.token)}`;
}
}
1 change: 1 addition & 0 deletions src/api/resources/transact/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
14 changes: 14 additions & 0 deletions src/api/resources/transact/errors/ImATeapotError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";

export class ImATeapotError extends errors.SyndicateError {
constructor() {
super({
statusCode: 418,
});
Object.setPrototypeOf(this, ImATeapotError.prototype);
}
}
14 changes: 14 additions & 0 deletions src/api/resources/transact/errors/InternalError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";

export class InternalError extends errors.SyndicateError {
constructor() {
super({
statusCode: 500,
});
Object.setPrototypeOf(this, InternalError.prototype);
}
}
16 changes: 16 additions & 0 deletions src/api/resources/transact/errors/InvalidRequestIdError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";
import * as Syndicate from "../../..";

export class InvalidRequestIdError extends errors.SyndicateError {
constructor(body: Syndicate.transact.ErrorWithMessage) {
super({
statusCode: 422,
body: body,
});
Object.setPrototypeOf(this, InvalidRequestIdError.prototype);
}
}
16 changes: 16 additions & 0 deletions src/api/resources/transact/errors/MalformedFunctionDataError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";
import * as Syndicate from "../../..";

export class MalformedFunctionDataError extends errors.SyndicateError {
constructor(body: Syndicate.transact.ErrorWithMessage) {
super({
statusCode: 400,
body: body,
});
Object.setPrototypeOf(this, MalformedFunctionDataError.prototype);
}
}
4 changes: 4 additions & 0 deletions src/api/resources/transact/errors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./ImATeapotError";
export * from "./InternalError";
export * from "./MalformedFunctionDataError";
export * from "./InvalidRequestIdError";
3 changes: 3 additions & 0 deletions src/api/resources/transact/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./types";
export * from "./errors";
export * from "./client";
7 changes: 7 additions & 0 deletions src/api/resources/transact/types/ErrorWithMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export interface ErrorWithMessage {
message: string;
}
18 changes: 18 additions & 0 deletions src/api/resources/transact/types/SendTransactionRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export interface SendTransactionRequest {
/** (Optional) ID of the request. Needs to be a valid UUID. If provided, it will be saved and returned as the transactionId of the response. If not provided, we will generate one for you and return it as the transactionId. */
requestId?: string;
/** ID of the project you want this request to be sent from */
projectId: string;
/** The contract address to send request to */
contractAddress: string;
/** The chain ID for the network (e.g. 1 for Ethereum Mainnet, 137 for Polygon Mainnet, 80001 for Polygon Mumbai). For a complete list of chain IDs, see [ChainList](https://chainlist.org/?search=&testnets=true). */
chainId: number;
/** The human readable signature to call on the contract */
functionSignature: string;
/** (Optional) The function arguments for the transaction if any. The keys are the argument names or index from the provided function signature and the values are the argument values. */
args?: Record<string, unknown>;
}
7 changes: 7 additions & 0 deletions src/api/resources/transact/types/SendTransactionResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export interface SendTransactionResponse {
transactionId: string;
}
3 changes: 3 additions & 0 deletions src/api/resources/transact/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./ErrorWithMessage";
export * from "./SendTransactionRequest";
export * from "./SendTransactionResponse";
Loading

0 comments on commit f424f61

Please sign in to comment.