Skip to content

Commit 54dba2f

Browse files
authored
Merge pull request #199 from hypercerts-org/fix/funding-receipt-field-types-clean
feat: add #text variant to funding receipt from/to unions
2 parents 070c5fb + 03a75e1 commit 54dba2f

4 files changed

Lines changed: 67 additions & 6 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hypercerts-org/lexicon": minor
3+
---
4+
5+
Add `#text` variant to funding receipt `from`/`to` unions for free-text identifiers (names, wallet addresses, etc.)

SCHEMAS.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ Overall score for an evaluation on a numeric scale.
265265

266266
| Property | Type | Required | Description | Comments |
267267
| ---------------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
268-
| `from` | `union` || The sender of the funds (either an account DID or a strong reference to a record). Optional — omit to represent anonymity. | |
269-
| `to` | `union` || The recipient of the funds (either an account DID or a strong reference to a record). | |
268+
| `from` | `union` || The sender of the funds (a free-text string, an account DID, or a strong reference to a record). Optional — omit to represent anonymity. | |
269+
| `to` | `union` || The recipient of the funds (a free-text string, an account DID, or a strong reference to a record). | |
270270
| `amount` | `string` || Amount of funding received as a numeric string (e.g. '1000.50'). | maxLength: 50 |
271271
| `currency` | `string` || Currency of the payment (e.g. EUR, USD, ETH). | maxLength: 10 |
272272
| `paymentRail` | `string` || How the funds were transferred (e.g. bank_transfer, credit_card, onchain, cash, check, payment_processor). | maxLength: 50 |
@@ -277,6 +277,16 @@ Overall score for an evaluation on a numeric scale.
277277
| `occurredAt` | `string` || Timestamp when the payment occurred. | |
278278
| `createdAt` | `string` || Client-declared timestamp when this receipt record was created. | |
279279

280+
#### Defs
281+
282+
##### `org.hypercerts.funding.receipt#text`
283+
284+
A free-text string value (e.g. a display name, wallet address, or other identifier).
285+
286+
| Property | Type | Required | Description |
287+
| -------- | -------- | -------- | ----------------- |
288+
| `value` | `string` || The string value. |
289+
280290
---
281291

282292
### `org.hypercerts.workscope.cel`

lexicons/org/hypercerts/funding/receipt.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@
1212
"properties": {
1313
"from": {
1414
"type": "union",
15-
"description": "The sender of the funds (either an account DID or a strong reference to a record). Optional — omit to represent anonymity.",
16-
"refs": ["app.certified.defs#did", "com.atproto.repo.strongRef"]
15+
"description": "The sender of the funds (a free-text string, an account DID, or a strong reference to a record). Optional — omit to represent anonymity.",
16+
"refs": [
17+
"#text",
18+
"app.certified.defs#did",
19+
"com.atproto.repo.strongRef"
20+
]
1721
},
1822
"to": {
1923
"type": "union",
20-
"description": "The recipient of the funds (either an account DID or a strong reference to a record).",
21-
"refs": ["app.certified.defs#did", "com.atproto.repo.strongRef"]
24+
"description": "The recipient of the funds (a free-text string, an account DID, or a strong reference to a record).",
25+
"refs": [
26+
"#text",
27+
"app.certified.defs#did",
28+
"com.atproto.repo.strongRef"
29+
]
2230
},
2331
"amount": {
2432
"type": "string",
@@ -67,6 +75,18 @@
6775
}
6876
}
6977
}
78+
},
79+
"text": {
80+
"type": "object",
81+
"description": "A free-text string value (e.g. a display name, wallet address, or other identifier).",
82+
"required": ["value"],
83+
"properties": {
84+
"value": {
85+
"type": "string",
86+
"description": "The string value.",
87+
"maxLength": 2048
88+
}
89+
}
7090
}
7191
}
7292
}

tests/validate-funding-receipt.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,32 @@ describe("org.hypercerts.funding.receipt", () => {
7474
expect(result.success).toBe(true);
7575
});
7676

77+
it("should accept 'to' as a text string", () => {
78+
const result = FundingReceipt.validateMain({
79+
$type: ids.OrgHypercertsFundingReceipt,
80+
to: {
81+
$type: "org.hypercerts.funding.receipt#text",
82+
value: "Alice",
83+
},
84+
amount: "1000.00",
85+
currency: "USD",
86+
createdAt: "2024-01-01T00:00:00Z",
87+
});
88+
expect(result.success).toBe(true);
89+
});
90+
91+
it("should accept 'from' as a text string", () => {
92+
const result = FundingReceipt.validateMain({
93+
$type: ids.OrgHypercertsFundingReceipt,
94+
...validBase,
95+
from: {
96+
$type: "org.hypercerts.funding.receipt#text",
97+
value: "0x1234567890abcdef1234567890abcdef12345678",
98+
},
99+
});
100+
expect(result.success).toBe(true);
101+
});
102+
77103
it("should accept a valid record with all optional fields present", () => {
78104
const result = FundingReceipt.validateMain({
79105
$type: ids.OrgHypercertsFundingReceipt,

0 commit comments

Comments
 (0)