diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a7d8e6f..57af3e2 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,4 +1,4 @@ -name: Build and release - staging +name: Build and test - staging on: pull_request: diff --git a/.github/workflows/create-prerelease-sdk.yml b/.github/workflows/create-prerelease-sdk.yml index 05a6eb3..4015838 100644 --- a/.github/workflows/create-prerelease-sdk.yml +++ b/.github/workflows/create-prerelease-sdk.yml @@ -3,9 +3,7 @@ name: Build and release - staging on: push: branches: - - main - - dev/* - - develop/* + - develop jobs: build-and-test: @@ -64,6 +62,9 @@ jobs: node-version: 20 cache: 'pnpm' + - name: Install dependencies + run: pnpm install + - name: Prepare prerelease semantic if: github.ref != 'refs/heads/main' run: mv .releaserc.prerelease.yaml .releaserc.yaml diff --git a/.github/workflows/create-release-sdk.yml b/.github/workflows/create-release-sdk.yml new file mode 100644 index 0000000..ef5d4bb --- /dev/null +++ b/.github/workflows/create-release-sdk.yml @@ -0,0 +1,91 @@ +name: Build and release + +on: + push: + branches: + - main + +jobs: + build-and-test: + name: Build and test + runs-on: ubuntu-latest + environment: test + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + run_install: false + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Run tests + run: pnpm test + + semantic-release: + needs: build-and-test + if: "!contains(github.event.head_commit.message, '[skip ci]')" + + name: Semantic Release + runs-on: ubuntu-latest + environment: staging + permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for npm provenance + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + run_install: false + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v4 + id: semantic # Need an `id` for output variables + with: + extra_plugins: | + @semantic-release/commit-analyzer + @semantic-release/release-notes-generator + @semantic-release/changelog + @semantic-release/github + @semantic-release/npm + env: + GITHUB_TOKEN: ${{ secrets.GH_PA_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Do something when a new release published + if: steps.semantic.outputs.new_release_published == 'true' + run: | + echo ${{ steps.semantic.outputs.new_release_version }} + echo ${{ steps.semantic.outputs.new_release_major_version }} + echo ${{ steps.semantic.outputs.new_release_minor_version }} + echo ${{ steps.semantic.outputs.new_release_patch_version }} \ No newline at end of file diff --git a/.github/workflows/dryrun-release-ci-sdk.yml b/.github/workflows/dryrun-release-ci-sdk.yml new file mode 100644 index 0000000..bc36e06 --- /dev/null +++ b/.github/workflows/dryrun-release-ci-sdk.yml @@ -0,0 +1,91 @@ +name: Build and release - staging + +on: + pull_request: + +jobs: + build-and-test: + name: Build and test + runs-on: ubuntu-latest + environment: test + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + run_install: false + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Run tests + run: pnpm test + + semantic-release: + needs: build-and-test + if: "!contains(github.event.head_commit.message, '[skip ci]')" + + name: Semantic Release + runs-on: ubuntu-latest + environment: staging + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + run_install: false + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Prepare prerelease semantic + if: github.ref != 'refs/heads/main' + run: mv .releaserc.prerelease.yaml .releaserc.yaml + + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v4 + id: semantic # Need an `id` for output variables + with: + dry_run: true + extra_plugins: | + @semantic-release/commit-analyzer + @semantic-release/release-notes-generator + @semantic-release/changelog + @semantic-release/github + @semantic-release/npm + env: + GITHUB_TOKEN: ${{ secrets.GH_PA_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Do something when a new release published + if: steps.semantic.outputs.new_release_published == 'true' + run: | + echo ${{ steps.semantic.outputs.new_release_version }} + echo ${{ steps.semantic.outputs.new_release_major_version }} + echo ${{ steps.semantic.outputs.new_release_minor_version }} + echo ${{ steps.semantic.outputs.new_release_patch_version }} \ No newline at end of file diff --git a/.releaserc.prerelease.yaml b/.releaserc.prerelease.yaml index 1779894..a9dacf9 100644 --- a/.releaserc.prerelease.yaml +++ b/.releaserc.prerelease.yaml @@ -8,13 +8,5 @@ plugins: branches: - "+([0-9])?(.{+([0-9]),x}).x" - main - - name: dev/* - prerelease: "beta" - - name: develop/* - prerelease: 'beta' - - name: hotfix/* - prerelease: '${name.replace(/^hotfix\//g, "fix-").replace(/\//g, "-")}' - - name: fix/* - prerelease: '${name.replace(/^fix\//g, "fix-").replace(/\//g, "-")}' - - name: feat/init + - name: develop prerelease: 'beta' diff --git a/.releaserc.yaml b/.releaserc.yaml index f3b48f5..1dffe20 100644 --- a/.releaserc.yaml +++ b/.releaserc.yaml @@ -2,7 +2,6 @@ plugins: - "@semantic-release/commit-analyzer" - "@semantic-release/release-notes-generator" - "@semantic-release/changelog" - - "@semantic-release/git" - "@semantic-release/github" - "@semantic-release/npm" diff --git a/eslint.config.mjs b/eslint.config.mjs index d9fa4b0..158f6de 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -4,8 +4,8 @@ import tseslint from "typescript-eslint"; export default [ - {files: ["**/*.{js,mjs,cjs,ts}"]}, - {languageOptions: { globals: {...globals.browser, ...globals.node} }}, + { files: ["**/*.{js,mjs,cjs,ts}"] }, + { languageOptions: { globals: { ...globals.browser, ...globals.node } } }, pluginJs.configs.recommended, ...tseslint.configs.recommended, ]; \ No newline at end of file diff --git a/lib/hypercerts-api b/lib/hypercerts-api index b082eb2..8c970ab 160000 --- a/lib/hypercerts-api +++ b/lib/hypercerts-api @@ -1 +1 @@ -Subproject commit b082eb2e44aae0444a77af622f6be65d92098cff +Subproject commit 8c970abf10af5291b6e8137fc6be371d4d3cfe83 diff --git a/package.json b/package.json index 1dc6bee..da7aa12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hypercerts-org/sdk", - "version": "2.0.0-alpha.37", + "version": "2.1.1", "description": "SDK for hypercerts protocol", "repository": "git@github.com:hypercerts-org/hypercerts-sdk.git", "author": "Hypercerts team", @@ -22,7 +22,7 @@ ], "dependencies": { "@graphql-typed-document-node/core": "^3.2.0", - "@hypercerts-org/contracts": "2.0.0-alpha.7", + "@hypercerts-org/contracts": "2.0.0-alpha.9", "@openzeppelin/merkle-tree": "^1.0.7", "@swc/core": "^1.6.3", "ajv": "^8.11.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ed88ba5..f9d2c72 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^3.2.0 version: 3.2.0(graphql@16.9.0) '@hypercerts-org/contracts': - specifier: 2.0.0-alpha.7 - version: 2.0.0-alpha.7(@nomicfoundation/hardhat-ethers@3.0.6(ethers@5.7.2)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5)))(@swc/core@1.7.10)(@types/node@20.14.15)(ethers@5.7.2)(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5) + specifier: 2.0.0-alpha.9 + version: 2.0.0-alpha.9(@nomicfoundation/hardhat-ethers@3.0.6(ethers@5.7.2)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5)))(@swc/core@1.7.10)(@types/node@20.14.15)(ethers@5.7.2)(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5) '@openzeppelin/merkle-tree': specifier: ^1.0.7 version: 1.0.7 @@ -693,8 +693,8 @@ packages: resolution: {integrity: sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==} engines: {node: '>=18.18'} - '@hypercerts-org/contracts@2.0.0-alpha.7': - resolution: {integrity: sha512-rnITsv1vcRsVtJxYCaHWXT9xk+5xjRRub1hJ9XqOrs0+HAvZTwBzTsoNWjjUlrW37loYHGxm5pRD+omFfeBbsw==} + '@hypercerts-org/contracts@2.0.0-alpha.9': + resolution: {integrity: sha512-bhYtN0hnO/MGbkyHtikMSzY5IVXFZ16FCsbonZBxglZeg0XUZHHzA7DokZkQOmFydG3MBmg5QewLCXwOHp3T7A==} '@ibm-cloud/openapi-ruleset-utilities@1.3.2': resolution: {integrity: sha512-pDZ+YTawZBAMgxfGG0JeCizh7Brmz8h4WRQaJvfJaRfgfdFmp5xZ64oqvnpJQ16XjCdNMBkTB6NJCZjQzq1gpQ==} @@ -4902,7 +4902,7 @@ snapshots: '@humanwhocodes/retry@0.3.0': {} - '@hypercerts-org/contracts@2.0.0-alpha.7(@nomicfoundation/hardhat-ethers@3.0.6(ethers@5.7.2)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5)))(@swc/core@1.7.10)(@types/node@20.14.15)(ethers@5.7.2)(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5)': + '@hypercerts-org/contracts@2.0.0-alpha.9(@nomicfoundation/hardhat-ethers@3.0.6(ethers@5.7.2)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5)))(@swc/core@1.7.10)(@types/node@20.14.15)(ethers@5.7.2)(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5)': dependencies: '@tenderly/hardhat-tenderly': 2.3.0(@nomicfoundation/hardhat-ethers@3.0.6(ethers@5.7.2)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5)))(@swc/core@1.7.10)(@types/node@20.14.15)(ethers@5.7.2)(hardhat@2.22.8(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5)) hardhat: 2.22.8(ts-node@10.9.2(@swc/core@1.7.10)(@types/node@20.14.15)(typescript@5.4.5))(typescript@5.4.5) diff --git a/src/__generated__/api.ts b/src/__generated__/api.ts index 63157fe..738eadf 100644 --- a/src/__generated__/api.ts +++ b/src/__generated__/api.ts @@ -10,6 +10,11 @@ import type { AxiosRequestConfig, AxiosResponse } from 'axios' +export type DeleteHyperboardParams = { +adminAddress: string; +signature: string; +}; + export type ValidateOrder200DataItem = { id: string; invalidated: boolean; @@ -22,14 +27,73 @@ export type ValidateOrder200 = { success: boolean; }; +export type UpdateOrderNonce200Data = { + address: string; + chain_id: number; + created_at: string; + nonce_counter: number; +}; + export type UpdateOrderNonce200 = { + data: UpdateOrderNonce200Data; + message: string; + success: boolean; +}; + +export type DeleteOrder200 = { data: unknown; message: string; success: boolean; }; +export type DeleteOrderBody = { + orderId: string; + signature: string; +}; + +export type StoreOrder201AnyOfFourData = { + additionalParameters: string; + amounts: number[]; + chainId: number; + collection: string; + collectionType: number; + createdAt: string; + currency: string; + endTime: number; + globalNonce: string; + hash: string; + hypercert_id: string; + id: string; + invalidated: boolean; + itemIds: string[]; + orderNonce: string; + price: string; + quoteType: number; + signature: string; + signer: string; + startTime: number; + status: string; + strategyId: number; + subsetNonce: number; + validator_codes: number[]; +}; + +export type StoreOrder201AnyOfFour = { + data: StoreOrder201AnyOfFourData; + error?: unknown; + message: string; + success: boolean; +}; + +export type StoreOrder201AnyOfTwoData = { + id: string; + order: PickAdditionalParametersStringAmountsNumberArrayChainIdNumberCollectionStringCollectionTypeNumberCreatedAtStringCurrencyStringEndTimeNumberGlobalNonceStringIdStringInvalidatedBooleanItemIdsStringArrayOrderNonceStringPriceStringQuoteTypeNumberSignatureStringSignerStringStartTimeNumberStrategyIdNumberSubsetNonceNumberValidatorCodesNumberArrayExcludeKeyofAdditionalParametersStringAmountsNumberArrayChainIdNumberCollectionStringCollectionTypeNumberCreatedAtStringCurrencyStringEndTimeNumberGlobalNonceStringIdStringInvalidatedBooleanItemIdsStringArrayOrderNonceStringPriceStringQuoteTypeNumberSignatureStringSignerStringStartTimeNumberStrategyIdNumberSubsetNonceNumberValidatorCodesNumberArrayIdOrCreatedAtOrInvalidatedOrValidatorCodes; + valid: boolean; + validatorCodes: OrderValidatorCode[]; +}; + export type StoreOrder201AnyOfTwo = { - data: unknown; + data: StoreOrder201AnyOfTwoData; error?: unknown; message: string; success: boolean; @@ -42,7 +106,7 @@ export type StoreOrder201AnyOf = { success: boolean; }; -export type StoreOrder201 = StoreOrder201AnyOf | StoreOrder201AnyOfTwo; +export type StoreOrder201 = StoreOrder201AnyOf | StoreOrder201AnyOfTwo | StoreOrder201AnyOfFour; /** * Interface for validating an allow list dump. @@ -60,11 +124,122 @@ export interface StoreAllowListRequest { totalUnits?: string; } +export type HyperboardUpdateRequestCollectionsItemHypercertsItem = { + factor: number; + hypercertId: string; +}; + +export type HyperboardUpdateRequestCollectionsItem = { + description: string; + hypercerts: HyperboardUpdateRequestCollectionsItemHypercertsItem[]; + id?: string; + title: string; +}; + +/** + * Interface for updating a hyperboard + */ +export interface HyperboardUpdateRequest { + adminAddress: string; + backgroundImg?: string; + borderColor: string; + chainIds: number[]; + collections: HyperboardUpdateRequestCollectionsItem[]; + id: string; + signature: string; + title: string; +} + +export type HyperboardCreateRequestCollectionsItemHypercertsItem = { + factor: number; + hypercertId: string; +}; + +export type HyperboardCreateRequestCollectionsItem = { + description: string; + hypercerts: HyperboardCreateRequestCollectionsItemHypercertsItem[]; + id?: string; + title: string; +}; + +/** + * Interface for creating a hyperboard + */ +export interface HyperboardCreateRequest { + adminAddress: string; + backgroundImg?: string; + borderColor: string; + chainIds: number[]; + collections: HyperboardCreateRequestCollectionsItem[]; + signature: string; + title: string; +} + +export type ApiResponseIdStringOrNullErrors = RecordStringStringOrStringArray | Error[]; + +/** + * @nullable + */ +export type ApiResponseIdStringOrNullData = { + id: string; +} | null; + +/** + * Interface for a generic API response. + */ +export interface ApiResponseIdStringOrNull { + /** @nullable */ + data?: ApiResponseIdStringOrNullData; + errors?: ApiResponseIdStringOrNullErrors; + message?: string; + success: boolean; +} + +/** + * Response for a created hyperboard + */ +export type HyperboardCreateResponse = ApiResponseIdStringOrNull; + export interface ValidateOrderRequest { chainId: number; tokenIds: string[]; } +export interface UpdateOrderNonceRequest { + address: string; + chainId: number; +} + +export interface CreateOrderRequest { + additionalParameters: string; + amounts: number[]; + chainId: number; + collection: string; + collectionType: number; + currency: string; + endTime: number; + globalNonce: string; + itemIds: string[]; + orderNonce: string; + price: string; + quoteType: number; + signature: string; + signer: string; + startTime: number; + strategyId: number; + subsetNonce: number; +} + +/** + * From T, pick a set of properties whose keys are in the union K + */ +export interface PickAdditionalParametersStringAmountsNumberArrayChainIdNumberCollectionStringCollectionTypeNumberCreatedAtStringCurrencyStringEndTimeNumberGlobalNonceStringIdStringInvalidatedBooleanItemIdsStringArrayOrderNonceStringPriceStringQuoteTypeNumberSignatureStringSignerStringStartTimeNumberStrategyIdNumberSubsetNonceNumberValidatorCodesNumberArrayExcludeKeyofAdditionalParametersStringAmountsNumberArrayChainIdNumberCollectionStringCollectionTypeNumberCreatedAtStringCurrencyStringEndTimeNumberGlobalNonceStringIdStringInvalidatedBooleanItemIdsStringArrayOrderNonceStringPriceStringQuoteTypeNumberSignatureStringSignerStringStartTimeNumberStrategyIdNumberSubsetNonceNumberValidatorCodesNumberArrayIdOrCreatedAtOrInvalidatedOrValidatorCodes { [key: string]: unknown } + +/** + * Construct a type with the properties of T except for those in type K. + */ +export type OmitAdditionalParametersStringAmountsNumberArrayChainIdNumberCollectionStringCollectionTypeNumberCreatedAtStringCurrencyStringEndTimeNumberGlobalNonceStringIdStringInvalidatedBooleanItemIdsStringArrayOrderNonceStringPriceStringQuoteTypeNumberSignatureStringSignerStringStartTimeNumberStrategyIdNumberSubsetNonceNumberValidatorCodesNumberArrayIdOrCreatedAtOrInvalidatedOrValidatorCodes = PickAdditionalParametersStringAmountsNumberArrayChainIdNumberCollectionStringCollectionTypeNumberCreatedAtStringCurrencyStringEndTimeNumberGlobalNonceStringIdStringInvalidatedBooleanItemIdsStringArrayOrderNonceStringPriceStringQuoteTypeNumberSignatureStringSignerStringStartTimeNumberStrategyIdNumberSubsetNonceNumberValidatorCodesNumberArrayExcludeKeyofAdditionalParametersStringAmountsNumberArrayChainIdNumberCollectionStringCollectionTypeNumberCreatedAtStringCurrencyStringEndTimeNumberGlobalNonceStringIdStringInvalidatedBooleanItemIdsStringArrayOrderNonceStringPriceStringQuoteTypeNumberSignatureStringSignerStringStartTimeNumberStrategyIdNumberSubsetNonceNumberValidatorCodesNumberArrayIdOrCreatedAtOrInvalidatedOrValidatorCodes; + /** * Error errors returned by the order validator contract */ @@ -117,30 +292,17 @@ export const OrderValidatorCode = { NUMBER_902: 902, } as const; -export interface UpdateOrderNonceRequest { - address: string; - chainId: number; +/** + * Interface for validating metadata. + */ +export interface ValidateMetadataRequest { + metadata: HypercertMetadata; } -export interface CreateOrderRequest { - additionalParameters: string; - amounts: number[]; - chainId: number; - collection: string; - collectionType: number; - currency: string; - endTime: number; - globalNonce: string; - itemIds: string[]; - orderNonce: string; - price: string; - quoteType: number; - signature: string; - signer: string; - startTime: number; - strategyId: number; - subsetNonce: number; -} +/** + * Interface for a validation response. + */ +export type ValidationResponse = ApiResponseValidationResult; export type ApiResponseValidationResultErrors = RecordStringStringOrStringArray | Error[]; @@ -163,11 +325,6 @@ export interface ApiResponseValidationResult { success: boolean; } -/** - * Interface for a validation response. - */ -export type ValidationResponse = ApiResponseValidationResult; - export type HypercertMetadataPropertiesItem = { trait_type?: string; value?: string; @@ -184,7 +341,7 @@ export interface HypercertMetadata { description: string; /** An url pointing to the external website of the project */ external_url?: string; - hypercert?: HypercertClaimdata; + hypercert?: HypercertClaimdata361; /** A URI pointing to a resource with mime type image/* representing the asset to which this token represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive. */ image: string; /** Identifies the asset to which this token represents */ @@ -196,13 +353,6 @@ export interface HypercertMetadata { version?: string; } -/** - * Interface for validating metadata. - */ -export interface ValidateMetadataRequest { - metadata: HypercertMetadata; -} - /** * Interface for storing metadata and allow list dump on IPFS. */ @@ -222,7 +372,7 @@ export interface StoreMetadataRequest { /** * Work time period. The value is UNIX time in seconds from epoch. */ -export type HypercertClaimdataWorkTimeframe = { +export type HypercertClaimdata361WorkTimeframe = { display_value?: string; name?: string; value?: number[]; @@ -232,7 +382,7 @@ export type HypercertClaimdataWorkTimeframe = { /** * Scopes of work */ -export type HypercertClaimdataWorkScope = { +export type HypercertClaimdata361WorkScope = { display_value?: string; excludes?: string[]; name?: string; @@ -243,7 +393,7 @@ export type HypercertClaimdataWorkScope = { /** * Rights */ -export type HypercertClaimdataRights = { +export type HypercertClaimdata361Rights = { display_value?: string; excludes?: string[]; name?: string; @@ -254,7 +404,7 @@ export type HypercertClaimdataRights = { /** * Impact time period. The value is UNIX time in seconds from epoch. */ -export type HypercertClaimdataImpactTimeframe = { +export type HypercertClaimdata361ImpactTimeframe = { display_value?: string; name?: string; value?: number[]; @@ -264,7 +414,7 @@ export type HypercertClaimdataImpactTimeframe = { /** * Scopes of impact */ -export type HypercertClaimdataImpactScope = { +export type HypercertClaimdata361ImpactScope = { display_value?: string; excludes?: string[]; name?: string; @@ -275,7 +425,7 @@ export type HypercertClaimdataImpactScope = { /** * Contributors */ -export type HypercertClaimdataContributors = { +export type HypercertClaimdata361Contributors = { display_value?: string; name?: string; value?: string[]; @@ -285,33 +435,26 @@ export type HypercertClaimdataContributors = { /** * Properties of an impact claim */ -export interface HypercertClaimdata { +export interface HypercertClaimdata361 { /** Contributors */ - contributors: HypercertClaimdataContributors; + contributors: HypercertClaimdata361Contributors; /** Scopes of impact */ - impact_scope: HypercertClaimdataImpactScope; + impact_scope: HypercertClaimdata361ImpactScope; /** Impact time period. The value is UNIX time in seconds from epoch. */ - impact_timeframe: HypercertClaimdataImpactTimeframe; + impact_timeframe: HypercertClaimdata361ImpactTimeframe; /** Rights */ - rights?: HypercertClaimdataRights; + rights?: HypercertClaimdata361Rights; /** Scopes of work */ - work_scope: HypercertClaimdataWorkScope; + work_scope: HypercertClaimdata361WorkScope; /** Work time period. The value is UNIX time in seconds from epoch. */ - work_timeframe: HypercertClaimdataWorkTimeframe; + work_timeframe: HypercertClaimdata361WorkTimeframe; [key: string]: unknown; } -export type ApiResponseErrors = RecordStringStringOrStringArray | Error[]; - /** - * Interface for a generic API response. + * Interface for a storage response. */ -export interface ApiResponse { - data?: unknown; - errors?: ApiResponseErrors; - message?: string; - success: boolean; -} +export type StorageResponse = ApiResponseCidString; export type ApiResponseCidStringErrors = RecordStringStringOrStringArray | Error[]; @@ -330,9 +473,48 @@ export interface ApiResponseCidString { } /** - * Interface for a storage response. + * Interface for a user add or update request. */ -export type StorageResponse = ApiResponseCidString; +export interface AddOrUpdateUserRequest { + avatar: string; + chain_id: number; + display_name: string; + signature: string; +} + +export type ApiResponseErrors = RecordStringStringOrStringArray | Error[]; + +/** + * Interface for a generic API response. + */ +export interface ApiResponse { + data?: unknown; + errors?: ApiResponseErrors; + message?: string; + success: boolean; +} + +export type ApiResponseAddressStringOrNullErrors = RecordStringStringOrStringArray | Error[]; + +/** + * @nullable + */ +export type ApiResponseAddressStringOrNullData = { + address: string; +} | null; + +/** + * Interface for a generic API response. + */ +export interface ApiResponseAddressStringOrNull { + /** @nullable */ + data?: ApiResponseAddressStringOrNullData; + errors?: ApiResponseAddressStringOrNullErrors; + message?: string; + success: boolean; +} + +export type AddOrUpdateUserResponse = ApiResponseAddressStringOrNull; export interface Error { message: string; @@ -350,6 +532,19 @@ export interface RecordStringStringOrStringArray {[key: string]: string | string /** + * Add or update a user + */ +export const addOrUpdateUser = >( + address: string, + addOrUpdateUserRequest: AddOrUpdateUserRequest, options?: AxiosRequestConfig + ): Promise => { + return axios.post( + `/v1/users/${address}`, + addOrUpdateUserRequest,options + ); + } + +/** * Submits a new hypercert metadata object for validation and storage on IPFS. When an allowlist URI is provided the service will validate the allowlist data before storing the metadata. Note that this might lead to a race condition when uploading metadata and the allowlist separately in rapid succession. @@ -415,6 +610,18 @@ export const storeOrder = >( ); } +/** + * Delete order from database + */ +export const deleteOrder = >( + deleteOrderBody: DeleteOrderBody, options?: AxiosRequestConfig + ): Promise => { + return axios.delete( + `/v1/marketplace/orders`,{data: + deleteOrderBody, ...options} + ); + } + /** * Updates and returns the order nonce for a user on a specific chain. */ @@ -439,6 +646,39 @@ export const validateOrder = >( ); } +/** + * Create a new hyperboard. Creates the collections passed to it automatically. + */ +export const createHyperboard = >( + hyperboardCreateRequest: HyperboardCreateRequest, options?: AxiosRequestConfig + ): Promise => { + return axios.post( + `/v1/hyperboards`, + hyperboardCreateRequest,options + ); + } + +export const updateHyperboard = >( + hyperboardId: string, + hyperboardUpdateRequest: HyperboardUpdateRequest, options?: AxiosRequestConfig + ): Promise => { + return axios.patch( + `/v1/hyperboards/${hyperboardId}`, + hyperboardUpdateRequest,options + ); + } + +export const deleteHyperboard = >( + hyperboardId: string, + params: DeleteHyperboardParams, options?: AxiosRequestConfig + ): Promise => { + return axios.delete( + `/v1/hyperboards/${hyperboardId}`,{ + ...options, + params: {...params, ...options?.params},} + ); + } + /** * Submits a new allowlist for validation and storage on IPFS. While we maintain a database of allowlists, the allowlist itself is stored on IPFS. Try to keep a backup of the allowlist for recovery purposes. @@ -468,12 +708,17 @@ export const validateAllowList = export type StoreMetadataResult = AxiosResponse export type StoreMetadataWithAllowlistResult = AxiosResponse export type ValidateMetadataResult = AxiosResponse export type ValidateMetadataWithAllowlistResult = AxiosResponse export type StoreOrderResult = AxiosResponse +export type DeleteOrderResult = AxiosResponse export type UpdateOrderNonceResult = AxiosResponse export type ValidateOrderResult = AxiosResponse +export type CreateHyperboardResult = AxiosResponse +export type UpdateHyperboardResult = AxiosResponse +export type DeleteHyperboardResult = AxiosResponse export type StoreAllowListResult = AxiosResponse export type ValidateAllowListResult = AxiosResponse diff --git a/src/constants.ts b/src/constants.ts index 7ffc6c2..bf08378 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -41,6 +41,11 @@ const DEPLOYMENTS: { [key in SupportedChainIds]: Deployment } = { addresses: deployments[84532], isTestnet: true, } as const, + 42161: { + chainId: 42161, + addresses: deployments[42161], + isTestnet: false, + } as const, 421614: { chainId: 421614, addresses: deployments[421614], diff --git a/src/types/client.ts b/src/types/client.ts index 7b25abc..ec792db 100644 --- a/src/types/client.ts +++ b/src/types/client.ts @@ -5,7 +5,7 @@ import { ByteArray, Hex, PublicClient, WalletClient } from "viem"; import { AxiosRequestConfig } from "axios"; export type TestChainIds = 11155111 | 84532 | 421614; -export type ProductionChainIds = 10 | 42220 | 8453; +export type ProductionChainIds = 10 | 42220 | 8453 | 42161; /** * Enum to verify the supported chainIds diff --git a/src/utils/config.ts b/src/utils/config.ts index 3db836b..b4ac2a8 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -17,7 +17,8 @@ import { createPublicClient, http } from "viem"; * - 11155111: Sepolia * - 84532: Base Sepolia * - 8453: Base Mainnet - * - 421613: Arbitrum Sepolia + * - 42161: Arbitrum One + * - 421614: Arbitrum Sepolia * * @param config - An object containing any configuration values to override. This should be a partial HypercertClientConfig object. * @returns The final configuration object for the Hypercert client. @@ -39,6 +40,7 @@ export const getConfig = ( }; const chainId = _config.walletClient?.chain?.id; + // eslint-disable-next-line @typescript-eslint/no-unused-vars const writeAbleChainIds = Object.entries(_config.deployments).map(([_, deployment]) => deployment.chainId); if (!_config.walletClient) { @@ -73,6 +75,7 @@ export const getConfig = ( */ export const getDeploymentsForEnvironment = (environment: Environment) => { const deployments = Object.fromEntries( + // eslint-disable-next-line @typescript-eslint/no-unused-vars Object.entries(DEPLOYMENTS).filter(([_, deployment]) => { if (deployment.isTestnet && environment === "test") { return deployment; @@ -105,6 +108,7 @@ export const getDeploymentsForChainId = (chainId: SupportedChainIds) => { logger.info("Indexer", "getDeploymentsForChainId", { chainId }); const deployments = Object.fromEntries( + // eslint-disable-next-line @typescript-eslint/no-unused-vars Object.entries(DEPLOYMENTS).filter(([_, deployment]) => { if (deployment.chainId === chainId) { return deployment;