Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions example/safe_inscription.js
Original file line number Diff line number Diff line change
@@ -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();
11 changes: 11 additions & 0 deletions src/client/safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import type {
SafeDepositEntryResponse,
SafePendingDepositRequest,
SafePendingDepositResponse,
SafeCollection,
SafeCollectible,
SafeSnapshot,
SafeSnapshotsRequest,
SafeWithdrawalFee,
Expand Down Expand Up @@ -48,6 +50,15 @@ export const SafeKeystoreClient = (axiosInstance: AxiosInstance, keystore: Keyst
}),

fetchSafeSnapshot: (id: string): Promise<SafeSnapshot> => axiosInstance.get<unknown, SafeSnapshot>(`/safe/snapshots/${id}`),

fetchInscriptionCollection: (collectionHash: string): Promise<SafeCollection> => axiosInstance.get<unknown, SafeCollection>(`/safe/inscriptions/collections/${collectionHash}`),

fetchInscriptionItem: (inscriptionHash: string): Promise<SafeCollectible> => axiosInstance.get<unknown, SafeCollectible>(`/safe/inscriptions/items/${inscriptionHash}`),

fetchInscriptionItems: (collectionHash: string, offset?: number): Promise<SafeCollectible[]> =>
axiosInstance.get<unknown, SafeCollectible[]>(`/safe/inscriptions/collections/${collectionHash}/items`, {
params: offset && offset > 0 ? { offset } : undefined,
}),
});
export const SafeClient = buildClient(SafeKeystoreClient);

Expand Down
30 changes: 30 additions & 0 deletions src/client/types/safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}