From b299c22cbec8a5cf2bbcc221c21e220919290f90 Mon Sep 17 00:00:00 2001 From: LixvYang <2690688423@qq.com> Date: Fri, 26 Dec 2025 18:24:31 +0800 Subject: [PATCH] [feat] add inscription api --- example/safe_inscription.js | 20 ++++++++++++++++++++ src/client/safe.ts | 11 +++++++++++ src/client/types/safe.ts | 30 ++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 example/safe_inscription.js diff --git a/example/safe_inscription.js b/example/safe_inscription.js new file mode 100644 index 00000000..cb7f47fb --- /dev/null +++ b/example/safe_inscription.js @@ -0,0 +1,20 @@ +const { MixinApi } = require('..'); +const keystore = require('../keystore.json'); +const { v4 } = require('uuid'); + +const main = async () => { + console.log(keystore); + + const client = MixinApi({ keystore }); + const collection = await client.safe.fetchInscriptionCollection('b3979998b8b5e705d553288bffd96d4e1cc719f3ae0b01ecac8539e1df81c16f'); + console.log('collection: ', collection); + const item = await client.safe.fetchInscriptionItem('94d20f04829dcfb2c6d3cdb7ba94b3f6b402eb0537d6aa48f76e14d21e84c784'); + console.log('item: ', item); + + // const items = await client.safe.fetchInscriptionItems('b3979998b8b5e705d553288bffd96d4e1cc719f3ae0b01ecac8539e1df81c16f'); + // for (const item of items) { + // console.log('item: ', item); + // } +}; + +main(); diff --git a/src/client/safe.ts b/src/client/safe.ts index 2f223d2f..695d99c8 100644 --- a/src/client/safe.ts +++ b/src/client/safe.ts @@ -7,6 +7,8 @@ import type { SafeDepositEntryResponse, SafePendingDepositRequest, SafePendingDepositResponse, + SafeCollection, + SafeCollectible, SafeSnapshot, SafeSnapshotsRequest, SafeWithdrawalFee, @@ -48,6 +50,15 @@ export const SafeKeystoreClient = (axiosInstance: AxiosInstance, keystore: Keyst }), fetchSafeSnapshot: (id: string): Promise => axiosInstance.get(`/safe/snapshots/${id}`), + + fetchInscriptionCollection: (collectionHash: string): Promise => axiosInstance.get(`/safe/inscriptions/collections/${collectionHash}`), + + fetchInscriptionItem: (inscriptionHash: string): Promise => axiosInstance.get(`/safe/inscriptions/items/${inscriptionHash}`), + + fetchInscriptionItems: (collectionHash: string, offset?: number): Promise => + axiosInstance.get(`/safe/inscriptions/collections/${collectionHash}/items`, { + params: offset && offset > 0 ? { offset } : undefined, + }), }); export const SafeClient = buildClient(SafeKeystoreClient); diff --git a/src/client/types/safe.ts b/src/client/types/safe.ts index dea65394..b98af739 100644 --- a/src/client/types/safe.ts +++ b/src/client/types/safe.ts @@ -107,3 +107,33 @@ export interface SafeWithdrawalFee { asset_id: string; priority: number; } + +export interface SafeCollection { + asset_key: string; + collection_hash: string; + description: string; + icon_url: string; + kernel_asset_id: string; + minimum_price: string; + name: string; + supply: string; + symbol: string; + type: string; + unit: string; + created_at: string; + updated_at: string; +} + +export interface SafeCollectible { + collection_hash: string; + content_type: string; + content_url: string; + inscription_hash: string; + occupied_by: string; + owner: string; + recipient: string; + sequence: number; + type: string; + created_at: string; + updated_at: string; +}