Skip to content

Commit

Permalink
chore: Update blockchainData package (#2222)
Browse files Browse the repository at this point in the history
  • Loading branch information
allan-almeida-imtbl authored Sep 27, 2024
1 parent 36c88a5 commit 3dff9ed
Show file tree
Hide file tree
Showing 34 changed files with 5,689 additions and 126 deletions.
24 changes: 22 additions & 2 deletions packages/blockchain-data/sdk/src/blockchain-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export class BlockchainData {

private readonly metadata: mr.MetadataApi;

private readonly crafting: mr.CraftingApi;

constructor(moduleConfig: BlockchainDataModuleConfiguration) {
this.config = new BlockchainDataConfiguration(moduleConfig);

Expand All @@ -32,6 +34,7 @@ export class BlockchainData {
this.nftOwners = new mr.NftOwnersApi(this.config.apiConfig);
this.tokens = new mr.TokensApi(this.config.apiConfig);
this.metadata = new mr.MetadataApi(this.config.apiConfig);
this.crafting = new mr.CraftingApi(this.config.apiConfig);
}

/**
Expand Down Expand Up @@ -195,13 +198,13 @@ export class BlockchainData {
*/
public async listNFTsByAccountAddress(
request: Types.ListNFTsByAccountAddressRequestParams,
): Promise<Types.ListNFTsResult> {
): Promise<Types.ListNFTsByOwnerResult> {
return (await this.nfts
.listNFTsByAccountAddress(request)
.then((res) => res.data)
.catch((err) => {
throw formatError(err);
})) as Types.ListNFTsResult;
})) as Types.ListNFTsByOwnerResult;
}

/**
Expand Down Expand Up @@ -458,4 +461,21 @@ export class BlockchainData {
throw formatError(err);
})) as Types.MetadataRefreshRateLimitResult;
}

/**
* Sign a crafting payload
* @param request - the request object containing the parameters to be provided in the API request
* @returns a promise that resolves with the signature result
* @throws {@link index.APIError}
*/
public async signCraftingPayload(
request: Types.SignCraftingPayloadRequestParams,
): Promise<Types.SignCraftingResult> {
return (await this.crafting
.signCraftingPayload(request)
.then((res) => res.data)
.catch((err) => {
throw formatError(err);
})) as Types.SignCraftingResult;
}
}
27 changes: 25 additions & 2 deletions packages/internal/generated-clients/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -------------------------------------------------
# Combined clients
# -------------------------------------------------

.PHONY: generate-imx-openapi
generate-imx-openapi: get-imx-openapi generate-imx-api-client

Expand Down Expand Up @@ -42,15 +46,34 @@ generate-mr-api-client:
-o /app/src/multi-rollup \
-c /app/config/mr.config.json

# When running this command, ensure files not relevant to blockchain data are manually removed
# -------------------------------------------------
# Seperate clients
# -------------------------------------------------

.PHONY: generate-blockchain-data
generate-blockchain-data: get-blockchain-data-openapi generate-blockchain-data-client

.PHONY: get-blockchain-data-openapi
get-blockchain-data-openapi:
rimraf src/blockchain-data-openapi.json && touch src/blockchain-data-openapi.json && \
curl -H "Accept: application/json+v3" \
https://imtbl-sdk.s3.us-east-2.amazonaws.com/openapi/indexer-mr-oas.json \
-o src/blockchain-data-openapi.json

# TODO
.PHONY: generate-blockchain-data-client
generate-blockchain-data-client:

# TODO remove once combined with API functions in above command
.PHONY: generate-blockchain-data-types
generate-blockchain-data-types:
rimraf src/blockchain-data && \
mkdir src/blockchain-data && \
docker run --rm -v $(shell pwd):/app openapitools/openapi-generator-cli:v7.0.1 generate \
--inline-schema-options REFACTOR_ALLOF_INLINE_SCHEMAS=true \
-i ./app/src/mr-openapi.json \
-i ./app/src/blockchain-data-openapi.json \
-g typescript-axios \
-o /app/src/blockchain-data \
-c /app/config/blockchain-data.config.json \
--additional-properties=stringEnums=true

Loading

0 comments on commit 3dff9ed

Please sign in to comment.