diff --git a/package.json b/package.json index c9102256..7f0a2e28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "btc-assets-api", - "version": "2.5.2", + "version": "2.5.3", "title": "Bitcoin/RGB++ Assets API", "description": "", "main": "index.js", diff --git a/src/routes/rgbpp/address.ts b/src/routes/rgbpp/address.ts index 37b6a9cd..a2e09211 100644 --- a/src/routes/rgbpp/address.ts +++ b/src/routes/rgbpp/address.ts @@ -5,7 +5,13 @@ import { ZodTypeProvider } from 'fastify-type-provider-zod'; import { CKBTransaction, Cell, IsomorphicTransaction, Script, XUDTBalance } from './types'; import z from 'zod'; import { Env } from '../../env'; -import { isScriptEqual, buildPreLockArgs, getXudtTypeScript, isTypeAssetSupported } from '@rgbpp-sdk/ckb'; +import { + isScriptEqual, + buildPreLockArgs, + getXudtTypeScript, + isTypeAssetSupported, + isUtxoAirdropBadgeType, +} from '@rgbpp-sdk/ckb'; import { groupBy, uniq } from 'lodash'; import { BI } from '@ckb-lumos/lumos'; import { UTXO } from '../../services/bitcoin/schema'; @@ -116,7 +122,7 @@ const addressRoutes: FastifyPluginCallback, Server, ZodType { schema: { description: ` - Get RGB++ balance by btc address, support xUDT only for now. + Get RGB++ balance by btc address, support xUDT, compatible-xUDT and Pre-claim UTXO Airdrop Badge for now. An address with more than 50 pending BTC transactions is uncommon. However, if such a situation arises, it potentially affecting the returned total_amount. @@ -155,7 +161,10 @@ const addressRoutes: FastifyPluginCallback, Server, ZodType const { no_cache } = request.query; const typeScript = getTypeScript(request.query.type_script); - if (!typeScript || !isTypeAssetSupported(typeScript, IS_MAINNET)) { + if ( + !typeScript || + !(isTypeAssetSupported(typeScript, IS_MAINNET) || isUtxoAirdropBadgeType(typeScript, IS_MAINNET)) + ) { throw fastify.httpErrors.badRequest('Unsupported type asset'); } diff --git a/src/routes/rgbpp/assets.ts b/src/routes/rgbpp/assets.ts index e4e4a651..e40b8693 100644 --- a/src/routes/rgbpp/assets.ts +++ b/src/routes/rgbpp/assets.ts @@ -5,7 +5,7 @@ import z from 'zod'; import { Cell, Script, SporeTypeInfo, XUDTTypeInfo } from './types'; import { UTXO } from '../../services/bitcoin/schema'; import { getTypeScript } from '../../utils/typescript'; -import { IndexerCell, isSporeTypeSupported, isUDTTypeSupported } from '@rgbpp-sdk/ckb'; +import { IndexerCell, isSporeTypeSupported, isUDTTypeSupported, isUtxoAirdropBadgeType } from '@rgbpp-sdk/ckb'; import { computeScriptHash } from '@ckb-lumos/lumos/utils'; import { getSporeConfig, unpackToRawClusterData, unpackToRawSporeData } from '../../utils/spore'; import { SearchKey } from '../../services/rgbpp'; @@ -144,7 +144,9 @@ const assetsRoute: FastifyPluginCallback, Server, ZodTypePr if (!typeScript) { return null; } - if (isUDTTypeSupported(typeScript, IS_MAINNET)) { + // The pre-claimed airdrop badge type script asset is not fully compatible with the standard xUDT + // type script and its token info and metadata should be decoded from the info cells. + if (isUDTTypeSupported(typeScript, IS_MAINNET) || isUtxoAirdropBadgeType(typeScript, IS_MAINNET)) { const infoCell = await fastify.ckb.getInfoCellData(typeScript); const typeHash = computeScriptHash(typeScript); if (!infoCell) {