@goat-sdk/plugin-opensea
Version:
<div align="center"> <a href="https://github.com/goat-sdk/goat">
2 lines (1 loc) • 2 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});var _chunk5HIAOR67js = require('./chunk-5HIAOR67.js');var _core = require('@goat-sdk/core');function u(n,e,o,t){var s=arguments.length,i=s<3?e:t===null?t=Object.getOwnPropertyDescriptor(e,o):t,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(n,e,o,t);else for(var p=n.length-1;p>=0;p--)(r=n[p])&&(i=(s<3?r(i):s>3?r(e,o,i):r(e,o))||i);return s>3&&i&&Object.defineProperty(e,o,i),i}_chunk5HIAOR67js.a.call(void 0, u,"_ts_decorate");function a(n,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,e)}_chunk5HIAOR67js.a.call(void 0, a,"_ts_metadata");var l=class{static{_chunk5HIAOR67js.a.call(void 0, this,"OpenseaService")}constructor(e){this.apiKey=e}async getNftCollectionStatistics(e){let o;try{o=await(await fetch(`https://api.opensea.io/api/v2/collections/${e.collectionSlug}/stats`,{headers:{accept:"application/json","x-api-key":this.apiKey}})).json()}catch(t){throw new Error(`Failed to get NFT collection statistics: ${t}`)}return o}async getNftSales(e){let o;try{o=await(await fetch(`https://api.opensea.io/api/v2/events/collection/${e.collectionSlug}?event_type=sale&limit=5`,{headers:{accept:"application/json","x-api-key":this.apiKey}})).json()}catch(t){throw new Error(`Failed to get NFT sales: ${t}`)}return o.asset_events.map(t=>({name:t.nft.name,seller:t.seller,buyer:t.buyer,price:Number(t.payment.quantity)/10**18}))}};u([_core.Tool.call(void 0, {description:"Get NFT collection statistics"}),a("design:type",Function),a("design:paramtypes",[typeof _chunk5HIAOR67js.b>"u"?Object:_chunk5HIAOR67js.b]),a("design:returntype",Promise)],l.prototype,"getNftCollectionStatistics",null);u([_core.Tool.call(void 0, {description:"Get recent NFT Sales"}),a("design:type",Function),a("design:paramtypes",[typeof _chunk5HIAOR67js.c>"u"?Object:_chunk5HIAOR67js.c]),a("design:returntype",Promise)],l.prototype,"getNftSales",null);exports.a = l;