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
4 changes: 2 additions & 2 deletions packages/bitbadgesjs-sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/bitbadgesjs-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bitbadges",
"description": "BitBadges — programmable tokens on Cosmos. SDK, CLI, and builder tools for humans and agents. (Previously published as 'bitbadgesjs-sdk'.)",
"version": "0.41.2",
"version": "0.42.0",
"license": "MIT",
"keywords": [
"bitbadges",
Expand Down
15 changes: 15 additions & 0 deletions packages/bitbadgesjs-sdk/src/api-indexer/standards-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ export interface iPaymentRequestInfo {
status: 'pending' | 'paid' | 'denied' | 'expired';
}

/**
* Core details for the Crowdfund standard.
*
* `funded` is derived from the success tracker (the on-chain handler having
* run). `expired` covers any post-deadline state where success hasn't
* executed — without an escrow read we can't distinguish "goal met but not
* yet withdrawn" from "goal not met".
*
* @category Standards Info
*/
export interface iCrowdfundInfo {
status: 'active' | 'expired' | 'funded';
}

/**
* Core details for the Auction standard.
*
Expand Down Expand Up @@ -66,6 +80,7 @@ export interface iPredictionMarketInfo {
export interface iStandardsInfo {
Bounty?: iBountyInfo;
PaymentRequest?: iPaymentRequestInfo;
Crowdfund?: iCrowdfundInfo;
Auction?: iAuctionInfo;
'Prediction Market'?: iPredictionMarketInfo;
}
33 changes: 33 additions & 0 deletions packages/bitbadgesjs-sdk/src/api-indexer/verify-standards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,37 @@ function verifyBounty(value: any): StandardViolation[] {
return violations;
}

// ============================================================
// Crowdfund Validator
// ============================================================

function verifyCrowdfund(value: any): StandardViolation[] {
const violations: StandardViolation[] = [];
const std = 'Crowdfund';
const approvals = getApprovals(value);

// Must have 2 token IDs (refund + progress)
const tokenIds = value.validTokenIds;
if (!Array.isArray(tokenIds) || tokenIds.length !== 1 || tokenIds[0]?.start !== 1n || tokenIds[0]?.end !== 2n) {
violations.push({ standard: std, field: 'validTokenIds', message: 'Crowdfund collections MUST have validTokenIds = [{ start: "1", end: "2" }] (refund + progress tokens).' });
}

// Must have at least 4 approvals
if (approvals.length < 4) {
violations.push({ standard: std, field: 'collectionApprovals', message: `Crowdfund requires at least 4 approvals (deposit-refund, deposit-progress, success, refund). Found ${approvals.length}.` });
}

// Check mint approvals have overrides
for (const a of getMintApprovals(value)) {
const ac = a.approvalCriteria || {};
if (ac.overridesFromOutgoingApprovals !== true && ac.overridesFromOutgoingApprovals !== 'true') {
violations.push({ standard: std, field: `collectionApprovals[${a.approvalId}].overridesFromOutgoingApprovals`, message: `Mint approval "${a.approvalId}" MUST have overridesFromOutgoingApprovals: true.` });
}
}

return violations;
}

// ============================================================
// Auction Validator
// ============================================================
Expand Down Expand Up @@ -1011,6 +1042,7 @@ const STANDARD_VALIDATORS: Record<string, (value: any) => StandardViolation[]> =
'Non-Transferable': verifyNonTransferable,
Bounty: verifyBounty,
PaymentRequest: verifyPaymentRequest,
Crowdfund: verifyCrowdfund,
Auction: verifyAuction,
Products: verifyProducts,
'Prediction Market': verifyPredictionMarket,
Expand Down Expand Up @@ -1041,6 +1073,7 @@ const STANDARD_ALIASES: Record<string, string> = {
PaymentRequest: 'PaymentRequest',
'Payment Request': 'PaymentRequest',
Invoice: 'PaymentRequest',
Crowdfund: 'Crowdfund',
Auction: 'Auction',
Products: 'Products',
'Product Catalog': 'Products',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('tokenTypeInference catalog helpers', () => {
'quest',
'bounty',
'payment-request',
'crowdfund',
'auction',
'product-catalog',
'prediction-market'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const STANDARD_TO_TOKEN_TYPE: ReadonlyArray<{ standard: string; skillId:
{ standard: 'Quest', skillId: 'quest' },
{ standard: 'Bounty', skillId: 'bounty' },
{ standard: 'PaymentRequest', skillId: 'payment-request' },
{ standard: 'Crowdfund', skillId: 'crowdfund' },
{ standard: 'Auction', skillId: 'auction' },
{ standard: 'Products', skillId: 'product-catalog' },
{ standard: 'Prediction Market', skillId: 'prediction-market' },
Expand Down
Loading
Loading