@goat-sdk/plugin-betswirl
Version:
<div align="center"> <a href="https://github.com/goat-sdk/goat">
2 lines (1 loc) • 1.76 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});var _chunkGAGGONOHjs = require('./chunk-GAGGONOH.js');var _chunkEI7MMDWYjs = require('./chunk-EI7MMDWY.js');var _core = require('@goat-sdk/core');var _zod = require('zod');var _sdkcore = require('@betswirl/sdk-core');function E(r,n){return _core.createTool.call(void 0, {name:"betswirl_getBets",description:"Get bets from BetSwirl. If no player is specified its listing the current connected player bets. If no game is specified its listing all games bets.",parameters:_zod.z.object({bettor:_chunkGAGGONOHjs.a.optional().describe("The bettor address"),game:_zod.z.nativeEnum(_sdkcore.CASINO_GAME_TYPE).optional().describe("The game to get the bets for")})},async o=>{let i=o.bettor,t=o.game,e=r.getChain().id;return await g(e,i,t,n)})}_chunkEI7MMDWYjs.a.call(void 0, E,"createGetBetsTool");async function g(r,n,o,i){try{let t=await _sdkcore.fetchBets.call(void 0, {chainId:r,theGraphKey:i,formatType:_sdkcore.FORMAT_TYPE.PRECISE},{bettor:n,game:o},void 0,5);if(t.error)throw new Error(`[${t.error.code}] Error fetching bets: ${t.error.message}`);return t.bets.map(e=>({id:String(e.id),input:e.decodedInput,betTxnHash:e.betTxnHash,betTxnLink:_sdkcore.formatTxnUrl.call(void 0, e.betTxnHash,r),betAmount:e.formattedBetAmount,token:e.token.symbol,isWin:e.isWin,payoutMultiplier:e.payoutMultiplier,rolled:e.decodedRolled,payout:e.formattedPayout,rollTxnHash:e.rollTxnHash,rollTxnLink:e.rollTxnHash?_sdkcore.formatTxnUrl.call(void 0, e.rollTxnHash,r):null,linkOnBetSwirl:`https://www.betswirl.com/${_sdkcore.slugById[r]}/casino/${e.game}/${e.id}`}))}catch(t){throw new Error(`An error occured while getting the bet: ${t}`)}}_chunkEI7MMDWYjs.a.call(void 0, g,"getSubgraphBets");exports.a = E;