Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ yarn-error.log*
.env.test.local
.env.production.local
.env
.env.backup

# turbo
.turbo
Binary file modified .yarn/install-state.gz
Binary file not shown.
3 changes: 3 additions & 0 deletions .yarn/versions/c1145127.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
undecided:
- lit-privacy
- ts
40 changes: 25 additions & 15 deletions packages/lit-actions/lit-actions/proofOfMembership.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,29 @@ export default `const generateProofOfIdentity = async () => {
contractAddress: tokenAddress,
standardContractType: tokenType,
chain,
method: 'balanceOf',
parameters: [
address
],
method: "balanceOf",
parameters: [address],
returnValueTest: {
comparator: '>',
value: '0'
}
}
]
comparator: ">",
value: "0",
},
},
];
// check lit conditions
const result = await LitActions.checkConditions({conditions, authSig, chain});
const result = await LitActions.checkConditions({
conditions,
authSig,
chain,
});
// return if balance is 0
if(!result) {
if (!result) {
console.log("Zero Balance. No Membership found.");
LitActions.setResponse({
response: JSON.stringify({
success: false,
data: { balance: 0 },
}),
});
return;
}
// user has balance > 0
Expand All @@ -42,9 +50,11 @@ export default `const generateProofOfIdentity = async () => {
32
);

const toSign = ethers.utils.keccak256(ethers.utils.hexlify(
ethers.utils.concat([identityProof, parsedBlockNumber, publicSignal])
));
const toSign = ethers.utils.keccak256(
ethers.utils.hexlify(
ethers.utils.concat([identityProof, parsedBlockNumber, publicSignal])
)
);

const sigShare = await LitActions.ethPersonalSignMessageEcdsa({
message: toSign,
Expand All @@ -54,4 +64,4 @@ export default `const generateProofOfIdentity = async () => {
};

generateProofOfIdentity();
`;
`
4 changes: 4 additions & 0 deletions packages/lit-actions/test/proofOfMembership.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ describe("generateProofOfMembership", () => {
MembershipFingerprint,
PKP_Membership
);
console.log(proofOfMembershipOutput)
if(!proofOfMembershipOutput.response?.success && proofOfMembershipOutput.response?.data?.balance === 0){
throw Error("No balance found.");
}
if (proofOfMembershipOutput.signatures?.sig1 === undefined) {
console.log("No signature was done because no membership found");
}
Expand Down
2 changes: 1 addition & 1 deletion packages/lit-privacy-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lit-privacy-sdk",
"version": "1.0.2",
"version": "1.0.4",
"description": "",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
Expand Down
34 changes: 23 additions & 11 deletions packages/lit-privacy-sdk/src/LitPrivacy/LitPrivacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,20 @@ export default class LitPrivacy extends LitPrivacyConstants {
LitPrivacy.MEMBERSHIP_PROOF_SIGNER_PKP.PUBLIC_KEY,
LitPrivacy.LIT_ACTIONS_CID.PROOF_OF_MEMBERSHIP
);
// check if no membership found
if (
// @ts-ignore
!proofOfMembershipOutput.response?.success && // @ts-ignore
proofOfMembershipOutput.response?.data?.balance === 0
) {
console.log("No signature was done because no membership found");
throw Error("No signature was done because no membership found.");
}
// the returned output will have signature under `sig1` property
// check if the user has correct membership or not by ensuring signature is generated
if (proofOfMembershipOutput.signatures?.sig1 === undefined) {
console.log("No signature was done because no membership found");
throw Error(
"Failed generating Proof of Membership. Either the wallet doesn't contain the token or check the parameters"
);
console.log("Check parameters passed to LitAction");
throw Error("Check parameters passed to LitAction.");
}

// this is the final membership proof generated from Lit Action
Expand Down Expand Up @@ -218,13 +225,18 @@ export default class LitPrivacy extends LitPrivacyConstants {
data: transactionData.data as string,
};

// Without a specific API key, the relay request will fail!
// Go to https://relay.gelato.network to get a testnet API key with 1Balance.
// Send a relay request using Gelato Relay!
const relayResponse = await relay.sponsoredCall(request, gelatoApiKey);

console.log(relayResponse);
return relayResponse.taskId;
try {
// Without a specific API key, the relay request will fail!
// Go to https://relay.gelato.network to get a testnet API key with 1Balance.
// Send a relay request using Gelato Relay!
const relayResponse = await relay.sponsoredCall(request, gelatoApiKey);
console.log(relayResponse);
return relayResponse.taskId;
} catch (e) {
console.error("Realy call failed.");
console.error(e);
return -1;
}
}

async executeLitAction(fingerprint: any, PKP: string, litActionCid: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/lit-privacy-sdk/src/config/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const PROOF_OF_IDENTITY_ACTION_CID: string= "QmTVqamJEKyprAG8DFuEuCnVQGitnWeQWu3ctRjYEVVAuS";
export const PROOF_OF_MEMBERSHIP_ACTION_CID: string= "QmNVsvPnyHUKU8qSFRbxKuSCN1P3wRPBuYpgEFngNXuuHs";
export const PROOF_OF_MEMBERSHIP_ACTION_CID: string= "Qmc4g16oXLPoYEAVi3t3UsCzTiH5JrEqsrW7hLYjvfwbBh";
export const IDENTITY_PROOF_SIGNER_PKP_PUBLIC_KEY: string= "0x04d45f2109cf7a1cfcd7519a87d0f405d1f5d55398ed9d80896944ca932581eff4a98a4d8059ebba3cc6d9f996744a33ba990144021b32355dc7c4ddb8a7d58eeb";
export const IDENTITY_PROOF_SIGNER_PKP_ADDRESS: string= "0x5846D64aA8de4eb9a0245D00f1963Db4FEE1e31F";
export const MEMBERSHIP_PROOF_SIGNER_PKP_PUBLIC_KEY: string= "0x04275b2c585bf9761bbba3997535116100b627a05dd86c434cbe4ab1ddc5917c33857b33cce39dccf30782b66892b07886547ebd6ef3888b82d47a7501ad11556b";
Expand Down