Skip to content

Commit df75eb8

Browse files
authored
[feat] add inscription api (#453)
1 parent 09ded1f commit df75eb8

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

example/safe_inscription.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const { MixinApi } = require('..');
2+
const keystore = require('../keystore.json');
3+
const { v4 } = require('uuid');
4+
5+
const main = async () => {
6+
console.log(keystore);
7+
8+
const client = MixinApi({ keystore });
9+
const collection = await client.safe.fetchInscriptionCollection('b3979998b8b5e705d553288bffd96d4e1cc719f3ae0b01ecac8539e1df81c16f');
10+
console.log('collection: ', collection);
11+
const item = await client.safe.fetchInscriptionItem('94d20f04829dcfb2c6d3cdb7ba94b3f6b402eb0537d6aa48f76e14d21e84c784');
12+
console.log('item: ', item);
13+
14+
// const items = await client.safe.fetchInscriptionItems('b3979998b8b5e705d553288bffd96d4e1cc719f3ae0b01ecac8539e1df81c16f');
15+
// for (const item of items) {
16+
// console.log('item: ', item);
17+
// }
18+
};
19+
20+
main();

src/client/safe.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type {
77
SafeDepositEntryResponse,
88
SafePendingDepositRequest,
99
SafePendingDepositResponse,
10+
SafeCollection,
11+
SafeCollectible,
1012
SafeSnapshot,
1113
SafeSnapshotsRequest,
1214
SafeWithdrawalFee,
@@ -48,6 +50,15 @@ export const SafeKeystoreClient = (axiosInstance: AxiosInstance, keystore: Keyst
4850
}),
4951

5052
fetchSafeSnapshot: (id: string): Promise<SafeSnapshot> => axiosInstance.get<unknown, SafeSnapshot>(`/safe/snapshots/${id}`),
53+
54+
fetchInscriptionCollection: (collectionHash: string): Promise<SafeCollection> => axiosInstance.get<unknown, SafeCollection>(`/safe/inscriptions/collections/${collectionHash}`),
55+
56+
fetchInscriptionItem: (inscriptionHash: string): Promise<SafeCollectible> => axiosInstance.get<unknown, SafeCollectible>(`/safe/inscriptions/items/${inscriptionHash}`),
57+
58+
fetchInscriptionItems: (collectionHash: string, offset?: number): Promise<SafeCollectible[]> =>
59+
axiosInstance.get<unknown, SafeCollectible[]>(`/safe/inscriptions/collections/${collectionHash}/items`, {
60+
params: offset && offset > 0 ? { offset } : undefined,
61+
}),
5162
});
5263
export const SafeClient = buildClient(SafeKeystoreClient);
5364

src/client/types/safe.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,33 @@ export interface SafeWithdrawalFee {
107107
asset_id: string;
108108
priority: number;
109109
}
110+
111+
export interface SafeCollection {
112+
asset_key: string;
113+
collection_hash: string;
114+
description: string;
115+
icon_url: string;
116+
kernel_asset_id: string;
117+
minimum_price: string;
118+
name: string;
119+
supply: string;
120+
symbol: string;
121+
type: string;
122+
unit: string;
123+
created_at: string;
124+
updated_at: string;
125+
}
126+
127+
export interface SafeCollectible {
128+
collection_hash: string;
129+
content_type: string;
130+
content_url: string;
131+
inscription_hash: string;
132+
occupied_by: string;
133+
owner: string;
134+
recipient: string;
135+
sequence: number;
136+
type: string;
137+
created_at: string;
138+
updated_at: string;
139+
}

0 commit comments

Comments
 (0)