@solworks/poll-api-client 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +2 -1
- package/dist/client.js +11 -0
- package/package.json +2 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PollClientConfig, Bet, UserAccount, UserProfile, Balance, Wager, LeaderboardEntry, Friend, WalletTransaction, Notification, StreakInfo, ProbabilityPoint, CreateBetParams, PlaceWagerParams, VoteParams, CancelWagerParams, ApiToken } from './types.js';
|
|
1
|
+
import type { PollClientConfig, Bet, UserAccount, UserProfile, Balance, Wager, LeaderboardEntry, Friend, WalletTransaction, Notification, StreakInfo, ProbabilityPoint, CreateBetParams, PlaceWagerParams, VoteParams, CancelWagerParams, ApiToken, Side } from './types.js';
|
|
2
2
|
export declare class PollClient {
|
|
3
3
|
private apiUrl;
|
|
4
4
|
private token;
|
|
@@ -22,6 +22,7 @@ export declare class PollClient {
|
|
|
22
22
|
createBet(params: CreateBetParams): Promise<Bet>;
|
|
23
23
|
joinBet(marketPubkey: string): Promise<unknown>;
|
|
24
24
|
placeWager(params: PlaceWagerParams): Promise<unknown>;
|
|
25
|
+
validateWagerSide(betAddress: string, side: Side): Promise<void>;
|
|
25
26
|
cancelWager(params: CancelWagerParams): Promise<unknown>;
|
|
26
27
|
initiateVote(marketPubkey: string): Promise<unknown>;
|
|
27
28
|
vote(params: VoteParams): Promise<unknown>;
|
package/dist/client.js
CHANGED
|
@@ -134,6 +134,17 @@ export class PollClient {
|
|
|
134
134
|
async placeWager(params) {
|
|
135
135
|
return this.request('POST', '/api/bets-usdc/wager', params);
|
|
136
136
|
}
|
|
137
|
+
async validateWagerSide(betAddress, side) {
|
|
138
|
+
const wagers = await this.getMyWagers();
|
|
139
|
+
const existing = wagers.find((w) => {
|
|
140
|
+
const addr = w.betAddress ??
|
|
141
|
+
w.programBetBetAddress;
|
|
142
|
+
return addr === betAddress && w.amount > 0;
|
|
143
|
+
});
|
|
144
|
+
if (existing && existing.outcome !== side) {
|
|
145
|
+
throw new PollApiError(400, `You already have a "${existing.outcome}" wager on this bet. You can only add to your existing side — you cannot wager "${side}".`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
137
148
|
async cancelWager(params) {
|
|
138
149
|
return this.request('POST', '/api/bets-usdc/wager/cancel', params);
|
|
139
150
|
}
|
package/package.json
CHANGED