Skip to content

Commit

Permalink
Add script to auto-generate SDK (#264)
Browse files Browse the repository at this point in the history
* Add generate typescript SDK

* Update operation names for SDK

* Add script to generate SDK
  • Loading branch information
adam-maj authored Oct 26, 2023
1 parent cb00704 commit a80ae20
Show file tree
Hide file tree
Showing 150 changed files with 273 additions and 152 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dev:worker": "nodemon --watch 'src/worker/**/*.ts' --watch 'core/**/*.ts' --watch 'src/**/*.ts' --exec 'npx tsx ./src/worker/index.ts' --files src/worker/index.ts",
"dev:infra": "docker compose -f ./docker-compose-infra.yml up -d",
"build": "yarn && rm -rf dist && tsc -p ./tsconfig.json --outDir dist",
"generate:sdk": "npx tsx ./src/scripts/generate-sdk",
"prisma:setup:dev": "npx tsx ./src/db/scripts/setup.ts",
"prisma:setup:prod": "npx tsx ./dist/src/db/scripts/setup.js",
"start": "yarn prisma:setup:prod && (yarn start:server & yarn start:worker)",
Expand Down Expand Up @@ -92,6 +93,7 @@
"eslint-config-prettier": "^8.7.0",
"hardhat": "^2.1.2",
"nodemon": "^2.0.21",
"openapi-typescript-codegen": "^0.25.0",
"prettier": "^2.8.7",
"prompts": "^2.4.2",
"supertest": "^6.3.3",
Expand Down
2 changes: 1 addition & 1 deletion server/api/auth/access-tokens/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function createAccessToken(fastify: FastifyInstance) {
summary: "Create a new access token",
description: "Create a new access token",
tags: ["Access Tokens"],
operationId: "createAccessToken",
operationId: "create",
body: BodySchema,
response: {
[StatusCodes.OK]: ReplySchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/auth/access-tokens/getAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function getAllAccessTokens(fastify: FastifyInstance) {
summary: "Get all access tokens",
description: "Get all access tokens",
tags: ["Access Tokens"],
operationId: "getAllAccessTokens",
operationId: "getAll",
response: {
[StatusCodes.OK]: ReplySchema,
},
Expand Down
2 changes: 1 addition & 1 deletion server/api/auth/access-tokens/revoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function revokeAccessToken(fastify: FastifyInstance) {
summary: "Revoke an access token",
description: "Revoke an access token",
tags: ["Access Tokens"],
operationId: "revokeAccessToken",
operationId: "revoke",
body: BodySchema,
response: {
[StatusCodes.OK]: ReplySchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/auth/permissions/getAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function getAllPermissions(fastify: FastifyInstance) {
summary: "Get all permissions",
description: "Get all users with their corresponding permissions",
tags: ["Permissions"],
operationId: "getAllPermissions",
operationId: "getAll",
response: {
[StatusCodes.OK]: ReplySchema,
},
Expand Down
2 changes: 1 addition & 1 deletion server/api/auth/permissions/grant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function grantPermissions(fastify: FastifyInstance) {
summary: "Grant permissions to user",
description: "Grant permissions to a user",
tags: ["Permissions"],
operationId: "grantPermissions",
operationId: "grant",
body: BodySchema,
response: {
[StatusCodes.OK]: ReplySchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/auth/permissions/revoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function revokePermissions(fastify: FastifyInstance) {
summary: "Revoke permissions from user",
description: "Revoke a user's permissions",
tags: ["Permissions"],
operationId: "revokePermissions",
operationId: "revoke",
body: BodySchema,
response: {
[StatusCodes.OK]: ReplySchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/backend-wallet/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const createWallet = async (fastify: FastifyInstance) => {
summary: "Create backend wallet",
description: "Create a backend wallet.",
tags: ["Backend Wallet"],
operationId: "backendWallet_create",
operationId: "create",
body: BodySchema,
response: {
...standardResponseSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/backend-wallet/getAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function getAll(fastify: FastifyInstance) {
summary: "Get all backend wallets",
description: "Get all backend wallets.",
tags: ["Backend Wallet"],
operationId: "backendWallet_getAll",
operationId: "getAll",
response: {
...standardResponseSchema,
[StatusCodes.OK]: responseSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/backend-wallet/getBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function getBalance(fastify: FastifyInstance) {
summary: "Get balance",
description: "Get the native balance for a backend wallet.",
tags: ["Backend Wallet"],
operationId: "backendWallet_getBalance",
operationId: "getBalance",
params: requestSchema,
response: {
...standardResponseSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/backend-wallet/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const importWallet = async (fastify: FastifyInstance) => {
summary: "Import backend wallet",
description: "Import an existing wallet as a backend wallet.",
tags: ["Backend Wallet"],
operationId: "backendWallet_import",
operationId: "import",
body: RequestBodySchema,
response: {
...standardResponseSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/backend-wallet/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function sendTransaction(fastify: FastifyInstance) {
summary: "Send a raw transaction",
description: "Send a raw transaction with transaction parameters",
tags: ["Backend Wallet"],
operationId: "walletSendTransaction",
operationId: "sendTransaction",
params: ParamsSchema,
body: requestBodySchema,
headers: Type.Omit(walletAuthSchema, ["x-account-address"]),
Expand Down
2 changes: 1 addition & 1 deletion server/api/backend-wallet/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function transfer(fastify: FastifyInstance) {
description:
"Transfer native or ERC20 tokens from this wallet to another wallet",
tags: ["Backend Wallet"],
operationId: "backendWallet_transfer",
operationId: "transfer",
params: requestSchema,
body: requestBodySchema,
headers: Type.Omit(walletAuthSchema, ["x-account-address"]),
Expand Down
2 changes: 1 addition & 1 deletion server/api/chain/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function getChainData(fastify: FastifyInstance) {
summary: "Get chain details",
description: "Get details about a chain.",
tags: ["Chain"],
operationId: "chain",
operationId: "get",
querystring: chainRequestQuerystringSchema,
response: {
...standardResponseSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/chain/getAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function getAllChainData(fastify: FastifyInstance) {
summary: "Get all chain details",
description: "Get details about all supported chains.",
tags: ["Chain"],
operationId: "getAllChainData",
operationId: "getAll",
response: {
...standardResponseSchema,
[StatusCodes.OK]: responseSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const getAllAdmins = async (fastify: FastifyInstance) => {
summary: "Get all admins",
description: "Get all admins for a smart account.",
tags: ["Account"],
operationId: "account:get-all-admins",
operationId: "getAllAdmins",
params: contractParamSchema,
response: {
...standardResponseSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const getAllSessions = async (fastify: FastifyInstance) => {
summary: "Get all session keys",
description: "Get all session keys for a smart account.",
tags: ["Account"],
operationId: "account:get-all-sessions",
operationId: "getAllSessions",
params: contractParamSchema,
response: {
...standardResponseSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/account/write/grantAdmin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const grantAdmin = async (fastify: FastifyInstance) => {
summary: "Grant admin",
description: "Grant a smart account's admin permission.",
tags: ["Account"],
operationId: "account:grant-admin",
operationId: "grantAdmin",
headers: walletAuthSchema,
params: contractParamSchema,
body: BodySchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const grantSession = async (fastify: FastifyInstance) => {
summary: "Create session key",
description: "Create a session key for a smart account.",
tags: ["Account"],
operationId: "account:grant-session",
operationId: "grantSession",
params: contractParamSchema,
headers: walletAuthSchema,
body: BodySchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const revokeAdmin = async (fastify: FastifyInstance) => {
summary: "Revoke admin",
description: "Revoke a smart account's admin permission.",
tags: ["Account"],
operationId: "account:revoke-admin",
operationId: "revokeAdmin",
headers: walletAuthSchema,
params: contractParamSchema,
body: BodySchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const revokeSession = async (fastify: FastifyInstance) => {
summary: "Revoke session key",
description: "Revoke a session key for a smart account.",
tags: ["Account"],
operationId: "account:revoke-session",
operationId: "revokeSession",
params: contractParamSchema,
headers: walletAuthSchema,
body: BodySchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const updateSession = async (fastify: FastifyInstance) => {
summary: "Update session key",
description: "Update a session key for a smart account.",
tags: ["Account"],
operationId: "account:update-session",
operationId: "updateSession",
params: contractParamSchema,
headers: walletAuthSchema,
body: BodySchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const getAllAccounts = async (fastify: FastifyInstance) => {
summary: "Get all smart accounts",
description: "Get all the smart accounts for this account factory.",
tags: ["Account Factory"],
operationId: "account-factory:get-all-accounts",
operationId: "getAllAccounts",
params: contractParamSchema,
response: {
...standardResponseSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getAssociatedAccounts = async (fastify: FastifyInstance) => {
description:
"Get all the smart accounts for this account factory associated with the specific admin wallet.",
tags: ["Account Factory"],
operationId: "account-factory:get-associated-accounts",
operationId: "getAssociatedAccounts",
params: contractParamSchema,
querystring: QuerySchema,
response: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const isAccountDeployed = async (fastify: FastifyInstance) => {
description:
"Check if a smart account has been deployed to the blockchain.",
tags: ["Account Factory"],
operationId: "account-factory:is-account-deployed",
operationId: "isAccountDeployed",
params: contractParamSchema,
querystring: QuerySchema,
response: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const predictAccountAddress = async (fastify: FastifyInstance) => {
summary: "Predict smart account address",
description: "Get the counterfactual address of a smart account.",
tags: ["Account Factory"],
operationId: "account-factory:predict-account-address",
operationId: "predictAccountAddress",
params: contractParamSchema,
querystring: QuerySchema,
response: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const createAccount = async (fastify: FastifyInstance) => {
summary: "Create smart account",
description: "Create a smart account for this account factory.",
tags: ["Account Factory"],
operationId: "account-factory:create-account",
operationId: "createAccount",
params: contractParamSchema,
headers: walletAuthSchema,
body: BodySchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/read/balanceOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function erc1155BalanceOf(fastify: FastifyInstance) {
description:
"Get the balance of a specific wallet address for this ERC-1155 contract.",
tags: ["ERC1155"],
operationId: "erc1155_balanceOf",
operationId: "balanceOf",
params: requestSchema,
querystring: querystringSchema,
response: {
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/read/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function erc1155Get(fastify: FastifyInstance) {
summary: "Get details",
description: "Get the details for a token in an ERC-1155 contract.",
tags: ["ERC1155"],
operationId: "erc1155_get",
operationId: "get",
params: requestSchema,
querystring: querystringSchema,
response: {
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/read/getAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function erc1155GetAll(fastify: FastifyInstance) {
summary: "Get all details",
description: "Get details for all tokens in an ERC-1155 contract.",
tags: ["ERC1155"],
operationId: "erc1155_getAll",
operationId: "getAll",
params: requestSchema,
querystring: querystringSchema,
response: {
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/read/getOwned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function erc1155GetOwned(fastify: FastifyInstance) {
description:
"Get all tokens in an ERC-1155 contract owned by a specific wallet.",
tags: ["ERC1155"],
operationId: "erc1155_getOwned",
operationId: "getOwned",
params: requestSchema,
querystring: querystringSchema,
response: {
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/read/isApproved.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function erc1155IsApproved(fastify: FastifyInstance) {
description:
"Check if the specific wallet has approved transfers from a specific operator wallet.",
tags: ["ERC1155"],
operationId: "erc1155_isApproved",
operationId: "isApproved",
params: requestSchema,
querystring: querystringSchema,
response: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function erc1155SignatureGenerate(fastify: FastifyInstance) {
description:
"Generate a signature granting access for another wallet to mint tokens from this ERC-721 contract. This method is typically called by the token contract owner.",
tags: ["ERC1155"],
operationId: "erc1155_signature_generate",
operationId: "signatureGenerate",
params: requestSchema,
body: requestBodySchema,
response: {
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/read/totalCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function erc1155TotalCount(fastify: FastifyInstance) {
description:
"Get the total supply in circulation for this ERC-1155 contract.",
tags: ["ERC1155"],
operationId: "erc1155_totalCount",
operationId: "totalCount",
params: requestSchema,
response: {
...standardResponseSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/read/totalSupply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function erc1155TotalSupply(fastify: FastifyInstance) {
description:
"Get the total supply in circulation for this ERC-1155 contract.",
tags: ["ERC1155"],
operationId: "erc1155_totalSupply",
operationId: "totalSupply",
params: requestSchema,
querystring: querystringSchema,
response: {
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/write/airdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function erc1155airdrop(fastify: FastifyInstance) {
summary: "Airdrop tokens",
description: "Airdrop ERC-1155 tokens to specific wallets.",
tags: ["ERC1155"],
operationId: "erc1155_airdrop",
operationId: "airdrop",
params: requestSchema,
body: requestBodySchema,
headers: walletAuthSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/write/burn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function erc1155burn(fastify: FastifyInstance) {
summary: "Burn token",
description: "Burn ERC-1155 tokens in the caller wallet.",
tags: ["ERC1155"],
operationId: "erc1155_burn",
operationId: "burn",
params: requestSchema,
body: requestBodySchema,
headers: walletAuthSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/write/burnBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function erc1155burnBatch(fastify: FastifyInstance) {
summary: "Burn tokens (batch)",
description: "Burn a batch of ERC-1155 tokens in the caller wallet.",
tags: ["ERC1155"],
operationId: "erc1155_burnBatch",
operationId: "burnBatch",
params: requestSchema,
body: requestBodySchema,
headers: walletAuthSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/write/claimTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function erc1155claimTo(fastify: FastifyInstance) {
summary: "Claim tokens to wallet",
description: "Claim ERC-1155 tokens to a specific wallet.",
tags: ["ERC1155"],
operationId: "erc1155_claimTo",
operationId: "claimTo",
params: requestSchema,
body: requestBodySchema,
headers: walletAuthSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/write/lazyMint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function erc1155lazyMint(fastify: FastifyInstance) {
summary: "Lazy mint",
description: "Lazy mint ERC-1155 tokens to be claimed in the future.",
tags: ["ERC1155"],
operationId: "erc1155_lazyMint",
operationId: "lazyMint",
params: requestSchema,
body: requestBodySchema,
headers: walletAuthSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function erc1155mintBatchTo(fastify: FastifyInstance) {
description:
"Mint ERC-1155 tokens to multiple wallets in one transaction.",
tags: ["ERC1155"],
operationId: "erc1155_mintBatchTo",
operationId: "mintBatchTo",
params: requestSchema,
body: requestBodySchema,
headers: walletAuthSchema,
Expand Down
2 changes: 1 addition & 1 deletion server/api/contract/extensions/erc1155/write/mintTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function erc1155mintTo(fastify: FastifyInstance) {
summary: "Mint tokens",
description: "Mint ERC-1155 tokens to a specific wallet.",
tags: ["ERC1155"],
operationId: "erc1155_mintTo",
operationId: "mintTo",
params: requestSchema,
body: requestBodySchema,
headers: walletAuthSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function erc1155SetApprovalForAll(fastify: FastifyInstance) {
description:
"Approve or remove operator as an operator for the caller. Operators can call transferFrom or safeTransferFrom for any token owned by the caller.",
tags: ["ERC1155"],
operationId: "erc1155_setApprovalForAll",
operationId: "setApprovalForAll",
params: requestSchema,
body: requestBodySchema,
headers: walletAuthSchema,
Expand Down
Loading

0 comments on commit a80ae20

Please sign in to comment.