Skip to content

Commit

Permalink
breaking-change: Blockchain Data types (#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
allan-almeida-imtbl authored Feb 1, 2024
1 parent 0195845 commit 051db2d
Show file tree
Hide file tree
Showing 116 changed files with 5,678 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/packages/config @immutable/sdk
/packages/internal/version-check @immutable/sdk
/packages/internal/generated-clients @immutable/sdk
/packages/internal/generated-clients/src/blockchain-data @immutable/assets
/packages/internal/toolkit @immutable/wallets
/packages/internal/cryptofiat @immutable/wallets
/packages/internal/dex @immutable/tokens
Expand Down
8 changes: 3 additions & 5 deletions packages/blockchain-data/sample-app/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import { Environment, ImmutableConfiguration } from '@imtbl/config';
import {
BlockchainData,
BlockchainDataModuleConfiguration,
ChainsTypes,
Types,
} from '@imtbl/blockchain-data';
import { PageLayout } from '@/components/PageLayout';

export default function Home() {
const [response, setResponse] = useState<ChainsTypes.ListChainsResult | null>(
null,
);
const [response, setResponse] = useState<Types.ListChainsResult | null>(null);

useEffect(() => {
async function getData() {
Expand All @@ -28,7 +26,7 @@ export default function Home() {
const client = new BlockchainData(config);

try {
const request: ChainsTypes.ListChainsRequestParams = {};
const request: Types.ListChainsRequestParams = {};
const response = await client.listChains(request);
setResponse(response);
} catch (error) {
Expand Down
25 changes: 8 additions & 17 deletions packages/blockchain-data/sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import {
mr,
ActivitiesTypes,
ChainsTypes,
CollectionsTypes,
MetadataTypes,
NFTOwnersTypes,
NFTsTypes,
TokensTypes,
} from '@imtbl/generated-clients';
import { mr, BlockchainData as Types } from '@imtbl/generated-clients';

import { APIError } from './types/errors';
import { BlockchainData } from './blockchain-data';
import { BlockchainDataModuleConfiguration } from './config';

/**
* @deprecated since version 1.1.5
* Please use Types.ActivityType instead
* import { Types } from '@imtbl/blockchain-data'
*/
type ActivityType = mr.ActivityType;

export {
ActivitiesTypes,
ChainsTypes,
CollectionsTypes,
MetadataTypes,
NFTOwnersTypes,
NFTsTypes,
TokensTypes,
Types,
APIError,
BlockchainData,
BlockchainDataModuleConfiguration,
Expand Down
16 changes: 14 additions & 2 deletions packages/internal/generated-clients/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ generate-imx-api-client:
-i ./app/src/imx-openapi.json \
-g typescript-axios \
-o /app/src/imx \
-c /app/imx.config.json
-c /app/config/imx.config.json

.PHONY: generate-mr-api-client
generate-mr-api-client:
Expand All @@ -40,4 +40,16 @@ generate-mr-api-client:
-i ./app/src/mr-openapi.json \
-g typescript-axios \
-o /app/src/multi-rollup \
-c /app/mr.config.json
-c /app/config/mr.config.json

.PHONY: generate-blockchain-data-types
generate-blockchain-data-types:
rm -rf 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 \
-g typescript-axios \
-o /app/src/blockchain-data \
-c /app/config/blockchain-data.config.json \
--additional-properties=stringEnums=true
13 changes: 12 additions & 1 deletion packages/internal/generated-clients/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const imxApiClients = new ImxApiClients(imxApiConfig.getSandbox());
### Immutable Multi-Rollup

```typescript
import { MultiRollupApiClients, multiRollupConfig } from '@imtbl/generated-clients';
import {
MultiRollupApiClients,
multiRollupConfig,
} from '@imtbl/generated-clients';

const mrApiClients = new MultiRollupApiClients(multiRollupConfig.sandbox);
```
Expand Down Expand Up @@ -57,3 +60,11 @@ Run the following command to regenerate the Immutable multi-rollup clients:
```bash
make generate-mr-openapi
```

## View generators

To inspect underlying generator files, run:

```bash
openapi-generator author template -g typescript-axios -o src/templates
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"supportsES6": true,
"npmVersion": "6.9.0",
"typescriptThreePlus": true,
"withSeparateModelsAndApi": true,
"modelPackage": "models",
"apiPackage": "domain",
"useSingleRequestParameter": true,
"templateDir": "app/templates/blockchain-data",
"files": {
"index.mustache": {
"templateType": "SupportingFiles",
"destinationFilename": "index.ts"
},
"apiInner.mustache": {
"templateType": "API",
"destinationFilename": ".ts"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"modelPackage": "models",
"apiPackage": "domain",
"useSingleRequestParameter": true,
"templateDir": "app/src/templates",
"templateDir": "app/templates/mr",
"files": {
"api-types.mustache": {
"templateType": "API",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
.gitignore
.npmignore
.openapi-generator-ignore
api.ts
base.ts
common.ts
configuration.ts
domain/activities-api.ts
domain/chains-api.ts
domain/collections-api.ts
domain/metadata-api.ts
domain/nft-owners-api.ts
domain/nfts-api.ts
domain/orders-api.ts
domain/passport-api.ts
domain/tokens-api.ts
git_push.sh
index.ts
models/active-order-status.ts
models/activity-asset.ts
models/activity-details.ts
models/activity-native-token.ts
models/activity-nft.ts
models/activity-token.ts
models/activity-type.ts
models/activity.ts
models/apierror400-all-of.ts
models/apierror400.ts
models/apierror401-all-of.ts
models/apierror401.ts
models/apierror403-all-of.ts
models/apierror403.ts
models/apierror404-all-of.ts
models/apierror404.ts
models/apierror429-all-of.ts
models/apierror429.ts
models/apierror500-all-of.ts
models/apierror500.ts
models/apierror501-all-of.ts
models/apierror501.ts
models/basic-apierror.ts
models/blockchain-metadata.ts
models/burn.ts
models/cancel-orders-request-body.ts
models/cancel-orders-result-data.ts
models/cancel-orders-result.ts
models/cancelled-order-status.ts
models/chain-with-details-all-of.ts
models/chain-with-details.ts
models/chain.ts
models/collection-contract-type.ts
models/collection-metadata.ts
models/collection.ts
models/create-counterfactual-address-request-deprecated.ts
models/create-counterfactual-address-request.ts
models/create-counterfactual-address-res-deprecated.ts
models/create-counterfactual-address-res.ts
models/create-listing-request-body.ts
models/deposit.ts
models/erc1155-item.ts
models/erc20-item.ts
models/erc721-item.ts
models/expired-order-status.ts
models/failed-order-cancellation.ts
models/fee.ts
models/filled-order-status.ts
models/fulfillable-order.ts
models/fulfillment-data-request.ts
models/fulfillment-data200-response-result.ts
models/fulfillment-data200-response.ts
models/get-activity-result.ts
models/get-collection-result.ts
models/get-contract-abi-res.ts
models/get-linked-addresses-res-deprecated.ts
models/get-linked-addresses-res.ts
models/get-metadata-result.ts
models/get-mint-request-result.ts
models/get-nftresult.ts
models/get-token-result.ts
models/inactive-order-status.ts
models/index.ts
models/item.ts
models/list-activities-result.ts
models/list-chains-result.ts
models/list-collection-owners-result.ts
models/list-collections-result.ts
models/list-listings-result.ts
models/list-metadata-result.ts
models/list-nftowners-result.ts
models/list-nfts-by-owner-result.ts
models/list-nfts-result.ts
models/list-tokens-result.ts
models/list-trade-result.ts
models/listing-result.ts
models/metadata-refresh-rate-limit-result.ts
models/metadata.ts
models/mint-asset.ts
models/mint-request-error-message.ts
models/mint-request-status.ts
models/mint.ts
models/native-item.ts
models/nft.ts
models/nftcontract-type.ts
models/nftmetadata-attribute-value.ts
models/nftmetadata-attribute.ts
models/nftmetadata-attributes.ts
models/nftowner.ts
models/nftsale.ts
models/nftwith-balance.ts
models/nftwith-metadata-attributes.ts
models/nftwith-owner.ts
models/order-status-name.ts
models/order-status.ts
models/order.ts
models/page.ts
models/pending-order-status.ts
models/protocol-data.ts
models/refresh-collection-metadata-request.ts
models/refresh-collection-metadata-result.ts
models/refresh-metadata-by-id.ts
models/refresh-metadata-by-idall-of.ts
models/refresh-metadata-by-idrequest.ts
models/refresh-metadata-by-token-id.ts
models/refresh-metadata-by-token-idall-of.ts
models/refresh-nftmetadata-by-token-idrequest.ts
models/refreshable-nftattributes.ts
models/sale-fee.ts
models/sale-payment-token.ts
models/sale-payment.ts
models/token-contract-type.ts
models/token.ts
models/trade-blockchain-metadata.ts
models/trade-result.ts
models/trade.ts
models/transfer.ts
models/unfulfillable-order.ts
models/withdrawal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.1
21 changes: 21 additions & 0 deletions packages/internal/generated-clients/src/blockchain-data/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* tslint:disable */
/* eslint-disable */
/**
* Immutable zkEVM API
* Immutable Multi Rollup API
*
* The version of the OpenAPI document: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

export * from './domain/activities-api';
export * from './domain/chains-api';
export * from './domain/collections-api';
export * from './domain/metadata-api';
export * from './domain/nft-owners-api';
export * from './domain/nfts-api';
export * from './domain/tokens-api';
Loading

0 comments on commit 051db2d

Please sign in to comment.