Skip to content

Commit

Permalink
Merge pull request #35 from lens-protocol/release/0.1.0-alpha.29
Browse files Browse the repository at this point in the history
Release/0.1.0 alpha.29
  • Loading branch information
cesarenaldi authored Sep 27, 2023
2 parents 400d3a9 + c9ad2cc commit 1b2b6b2
Show file tree
Hide file tree
Showing 24 changed files with 97 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-cows-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lens-protocol/metadata': patch
---

**fix:** `orCondition` and `andCondition` input type
5 changes: 5 additions & 0 deletions .changeset/flat-zoos-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lens-protocol/metadata': patch
---

**chore:** creates internal `accessCondition` builder
2 changes: 2 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"cold-goats-reply",
"cuddly-falcons-fry",
"eighty-pears-tie",
"fair-cows-matter",
"fair-walls-prove",
"few-drinks-hope",
"flat-zoos-breathe",
"fresh-wolves-tap",
"gold-steaks-brake",
"grumpy-hairs-carry",
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @lens-protocol/metadata

## 0.1.0-alpha.29

### Patch Changes

- 286daa4: **fix:** `orCondition` and `andCondition` input type
- 1cacc5a: **chore:** creates internal `accessCondition` builder

## 0.1.0-alpha.28

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions docs/functions/andCondition-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1>Function andCondition</h1></div>
<h4>Type Parameters</h4>
<ul class="tsd-type-parameter-list">
<li>
<h4><span class="tsd-kind-type-parameter">T</span><span class="tsd-signature-symbol"> extends </span><a href="../types/AnyCondition.html" class="tsd-signature-type tsd-kind-type-alias">AnyCondition</a><span class="tsd-signature-symbol">[]</span></h4></li></ul></section>
<h4><span class="tsd-kind-type-parameter">T</span><span class="tsd-signature-symbol"> extends </span><a href="../types/SimpleCondition.html" class="tsd-signature-type tsd-kind-type-alias">SimpleCondition</a><span class="tsd-signature-symbol">[]</span></h4></li></ul></section>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
Expand All @@ -34,7 +34,7 @@ <h5><span class="tsd-kind-parameter">criteria</span>: <span class="tsd-signature
<h4 class="tsd-returns-title">Returns <a href="../types/AndCondition.html" class="tsd-signature-type tsd-kind-type-alias">AndCondition</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type tsd-kind-type-parameter">T</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">&gt;</span></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L226">src/builders/encryption.ts:226</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L229">src/builders/encryption.ts:229</a></li></ul></aside></li></ul></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/functions/collectCondition-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h5><span class="tsd-kind-parameter">input</span>: <a href="../types/CollectCond
<h4 class="tsd-returns-title">Returns <a href="../types/CollectCondition.html" class="tsd-signature-type tsd-kind-type-alias">CollectCondition</a></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L42">src/builders/encryption.ts:42</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L45">src/builders/encryption.ts:45</a></li></ul></aside></li></ul></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/functions/eoaOwnershipCondition-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h5><span class="tsd-kind-parameter">input</span>: <a href="../types/EoaOwnershi
<h4 class="tsd-returns-title">Returns <a href="../types/EoaOwnershipCondition.html" class="tsd-signature-type tsd-kind-type-alias">EoaOwnershipCondition</a></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L62">src/builders/encryption.ts:62</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L65">src/builders/encryption.ts:65</a></li></ul></aside></li></ul></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/functions/erc1155OwnershipCondition.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h5><span class="tsd-kind-parameter">input</span>: <a href="../types/Erc721Owner
<h4 class="tsd-returns-title">Returns <a href="../types/NftOwnershipCondition.html" class="tsd-signature-type tsd-kind-type-alias">NftOwnershipCondition</a></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L173">src/builders/encryption.ts:173</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L176">src/builders/encryption.ts:176</a></li></ul></aside></li></ul></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/functions/erc20OwnershipCondition-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h5><span class="tsd-kind-parameter">input</span>: <a href="../types/Erc20Owners
<h4 class="tsd-returns-title">Returns <a href="../types/Erc20OwnershipCondition.html" class="tsd-signature-type tsd-kind-type-alias">Erc20OwnershipCondition</a></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L105">src/builders/encryption.ts:105</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L108">src/builders/encryption.ts:108</a></li></ul></aside></li></ul></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/functions/erc721OwnershipCondition.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h5><span class="tsd-kind-parameter">input</span>: <a href="../types/Erc721Owner
<h4 class="tsd-returns-title">Returns <a href="../types/NftOwnershipCondition.html" class="tsd-signature-type tsd-kind-type-alias">NftOwnershipCondition</a></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L145">src/builders/encryption.ts:145</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L148">src/builders/encryption.ts:148</a></li></ul></aside></li></ul></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/functions/followCondition-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h5><span class="tsd-kind-parameter">input</span>: <a href="../types/FollowCondi
<h4 class="tsd-returns-title">Returns <a href="../types/FollowCondition.html" class="tsd-signature-type tsd-kind-type-alias">FollowCondition</a></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L212">src/builders/encryption.ts:212</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L215">src/builders/encryption.ts:215</a></li></ul></aside></li></ul></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
4 changes: 2 additions & 2 deletions docs/functions/orCondition-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1>Function orCondition</h1></div>
<h4>Type Parameters</h4>
<ul class="tsd-type-parameter-list">
<li>
<h4><span class="tsd-kind-type-parameter">T</span><span class="tsd-signature-symbol"> extends </span><a href="../types/AnyCondition.html" class="tsd-signature-type tsd-kind-type-alias">AnyCondition</a><span class="tsd-signature-symbol">[]</span></h4></li></ul></section>
<h4><span class="tsd-kind-type-parameter">T</span><span class="tsd-signature-symbol"> extends </span><a href="../types/SimpleCondition.html" class="tsd-signature-type tsd-kind-type-alias">SimpleCondition</a><span class="tsd-signature-symbol">[]</span></h4></li></ul></section>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
Expand All @@ -34,7 +34,7 @@ <h5><span class="tsd-kind-parameter">criteria</span>: <span class="tsd-signature
<h4 class="tsd-returns-title">Returns <a href="../types/OrCondition.html" class="tsd-signature-type tsd-kind-type-alias">OrCondition</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type tsd-kind-type-parameter">T</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">&gt;</span></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L240">src/builders/encryption.ts:240</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L243">src/builders/encryption.ts:243</a></li></ul></aside></li></ul></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/functions/profileOwnershipCondition-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h5><span class="tsd-kind-parameter">input</span>: <a href="../types/ProfileOwne
<h4 class="tsd-returns-title">Returns <a href="../types/ProfileOwnershipCondition.html" class="tsd-signature-type tsd-kind-type-alias">ProfileOwnershipCondition</a></h4>
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L193">src/builders/encryption.ts:193</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L196">src/builders/encryption.ts:196</a></li></ul></aside></li></ul></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/types/CollectConditionDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h5><span class="tsd-kind-property">this<wbr/>Publication</span><span class="tsd
</div>
<div class="tsd-comment tsd-typography"></div></li></ul></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L27">src/builders/encryption.ts:27</a></li></ul></aside></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L30">src/builders/encryption.ts:30</a></li></ul></aside></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/types/EoaOwnershipConditionDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h5><span class="tsd-kind-property">address</span><span class="tsd-signature-sym
</div>
<div class="tsd-comment tsd-typography"></div></li></ul></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L51">src/builders/encryption.ts:51</a></li></ul></aside></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L54">src/builders/encryption.ts:54</a></li></ul></aside></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/types/Erc1155OwnershipConditionDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h5><span class="tsd-kind-property">token<wbr/>Ids</span><span class="tsd-signat
</div>
<div class="tsd-comment tsd-typography"></div></li></ul></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L157">src/builders/encryption.ts:157</a></li></ul></aside></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L160">src/builders/encryption.ts:160</a></li></ul></aside></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/types/Erc20OwnershipConditionDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h4>Example</h4><pre><code class="language-ts"><span class="hl-0">1.5</span><br/
</code><button>Copy</button></pre>
</div></li></ul></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L71">src/builders/encryption.ts:71</a></li></ul></aside></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L74">src/builders/encryption.ts:74</a></li></ul></aside></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/types/Erc721OwnershipConditionDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h5><code class="tsd-tag ts-flagOptional">Optional</code> <span class="tsd-kind-
</div>
<div class="tsd-comment tsd-typography"></div></li></ul></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L129">src/builders/encryption.ts:129</a></li></ul></aside></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L132">src/builders/encryption.ts:132</a></li></ul></aside></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/types/FollowConditionDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h4>Type declaration</h4>
<li class="tsd-parameter">
<h5><span class="tsd-kind-property">follow</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5></li></ul></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L204">src/builders/encryption.ts:204</a></li></ul></aside></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L207">src/builders/encryption.ts:207</a></li></ul></aside></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/types/NetworkAddressDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h5><span class="tsd-kind-property">chain<wbr/>Id</span><span class="tsd-signatu
</div>
<div class="tsd-comment tsd-typography"></div></li></ul></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L118">src/builders/encryption.ts:118</a></li></ul></aside></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L121">src/builders/encryption.ts:121</a></li></ul></aside></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion docs/types/ProfileOwnershipConditionDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h4>Type declaration</h4>
<li class="tsd-parameter">
<h5><span class="tsd-kind-property">profile<wbr/>Id</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5></li></ul></div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L185">src/builders/encryption.ts:185</a></li></ul></aside></div>
<li>Defined in <a href="https://github.com/lens-protocol/metadata/blob/main/src/builders/encryption.ts#L188">src/builders/encryption.ts:188</a></li></ul></aside></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lens-protocol/metadata",
"version": "0.1.0-alpha.28",
"version": "0.1.0-alpha.29",
"description": "Lens Protocol Metadata Standards",
"type": "module",
"main": "./dist/index.cjs",
Expand Down
39 changes: 39 additions & 0 deletions src/builders/__tests__/encryption.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
collectCondition,
eoaOwnershipCondition,
erc20OwnershipCondition,
accessCondition,
} from '../encryption.js';

describe(`Given the encryption access condition helpers`, () => {
Expand Down Expand Up @@ -267,4 +268,42 @@ describe(`Given the encryption access condition helpers`, () => {
).toThrowError('Should have at most 5 conditions');
});
});

describe(`when using the "${accessCondition.name}" helper`, () => {
it('should return a valid AccessCondition', () => {
const condition = accessCondition([
profileOwnershipCondition({ profileId: '0x01' }),
andCondition([
followCondition({ follow: '0x02' }),
collectCondition({ publicationId: '0x03', thisPublication: false }),
]),
]);

expect(condition).toMatchInlineSnapshot(`
{
"criteria": [
{
"profileId": "0x01",
"type": "PROFILE_OWNERSHIP",
},
{
"criteria": [
{
"follow": "0x02",
"type": "FOLLOW",
},
{
"publicationId": "0x03",
"thisPublication": false,
"type": "COLLECT",
},
],
"type": "AND",
},
],
"type": "OR",
}
`);
});
});
});
21 changes: 19 additions & 2 deletions src/builders/encryption.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { evaluate } from './ValidationError';
import { amount } from '../primitives';
import {
AccessCondition,
AccessConditionSchema,
AndCondition,
AndConditionSchema,
AnyCondition,
Expand All @@ -21,6 +23,7 @@ import {
OrConditionSchema,
ProfileOwnershipCondition,
ProfileOwnershipConditionSchema,
SimpleCondition,
refineNftOwnershipCondition,
} from '../publication';

Expand Down Expand Up @@ -223,7 +226,7 @@ export function followCondition(input: FollowConditionDetails): FollowCondition
*
* @category Helpers
*/
export function andCondition<T extends AnyCondition[]>(criteria: T): AndCondition<T[number]> {
export function andCondition<T extends SimpleCondition[]>(criteria: T): AndCondition<T[number]> {
return evaluate(
AndConditionSchema.safeParse({
type: ConditionType.AND,
Expand All @@ -237,11 +240,25 @@ export function andCondition<T extends AnyCondition[]>(criteria: T): AndConditio
*
* @category Helpers
*/
export function orCondition<T extends AnyCondition[]>(criteria: T): OrCondition<T[number]> {
export function orCondition<T extends SimpleCondition[]>(criteria: T): OrCondition<T[number]> {
return evaluate(
OrConditionSchema.safeParse({
type: ConditionType.OR,
criteria,
}),
);
}

/**
* Creates the access condition specification for a given publication.
*
* @internal
*/
export function accessCondition(criteria: AnyCondition[]): AccessCondition {
return evaluate(
AccessConditionSchema.safeParse({
type: ConditionType.OR,
criteria,
}),
);
}

0 comments on commit 1b2b6b2

Please sign in to comment.