Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support v16 #31

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ mainnet page: https://continuum.tomoima525.com/
- Continuum generates MerkleProof from MerkleTree
- On the client side, users generate a zkSNARK proof using the MerkleProof
- Users submit the proof to the contract. Once verified, NFT will be issued.
<p align="center">
<img width="1000" alt="Screen Shot 2022-05-09 at 7 13 55 AM" src="https://user-images.githubusercontent.com/6277118/167317950-2158f5a9-7c1b-498c-94d9-c981f2877386.png">
</p>
<p align="center">
<img width="1000" alt="Screen Shot 2022-05-09 at 7 13 55 AM" src="https://user-images.githubusercontent.com/6277118/167317950-2158f5a9-7c1b-498c-94d9-c981f2877386.png">
</p>

You can find more details on https://speakerdeck.com/tomoima525/continuum-background-checker-with-zero-knowledge-proof or https://www.youtube.com/watch?v=bco4cvXuQUE

# Preparation

Call `yarn install --ignore-engines` at the root of the project. (ipfs contains node v16. It is used in Lambda but not required for the whole project)
Call `yarn install` at the root of the project. Note that this package requires node >= 16

### Github auth

Expand Down
3 changes: 2 additions & 1 deletion packages/cdk/functions/genMetadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
import { NFTStorage, File } from 'nft.storage';
import screenshot from './screenshot';
import { groupQuery } from '/opt/nodejs/dynamodb-utils';
import { URLSearchParams } from 'url';

const headers = {
'Access-Control-Allow-Origin': '*',
Expand Down Expand Up @@ -75,7 +76,7 @@ async function storeNFT({
export const handler = async function (
event: APIGatewayProxyEvent,
): Promise<APIGatewayProxyResult> {
console.log('==== env', process.env.AWS_EXECUTION_ENV);
// console.log('==== env', process.env.AWS_EXECUTION_ENV);
const requestBody = JSON.parse(event.body || '');
const address = requestBody?.address as string;
const groupId = requestBody?.groupId as string;
Expand Down
3 changes: 0 additions & 3 deletions packages/cdk/functions/genMetadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"build": "tsc --project ./tsconfig.json --skipLibCheck"
},
"engines": {
"npm": ">=7.0.0",
"node": ">=16.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// work around to run in node16
// https://github.com/alixaxel/chrome-aws-lambda/issues/268
process.env.AWS_EXECUTION_ENV = 'AWS_Lambda_nodejs14.x';
import chrome from 'chrome-aws-lambda';
process.env.AWS_EXECUTION_ENV = 'AWS_Lambda_nodejs16.x';
import chrome from '@sparticuz/chrome-aws-lambda';
export default chrome;
2 changes: 1 addition & 1 deletion packages/cdk/functions/layers/chrome/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"chrome-aws-lambda": "^10.1.0",
"@sparticuz/chrome-aws-lambda": "^14.1.0",
"puppeteer-core": "10.1.0"
}
}
14 changes: 7 additions & 7 deletions packages/cdk/functions/layers/chrome/nodejs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
# yarn lockfile v1


"@sparticuz/chrome-aws-lambda@^14.1.0":
version "14.1.0"
resolved "https://registry.yarnpkg.com/@sparticuz/chrome-aws-lambda/-/chrome-aws-lambda-14.1.0.tgz#432de2dd6a8fd3d83025b35df51af40facf77fd1"
integrity sha512-Ef6MWjPyiHE94KOPtWP4Gd0KMh4W3MKBtni5gszgBeXQrB8QS3rEr8zZU21Axw9GmGyizTCbSZnYkPcgRB6lAQ==
dependencies:
lambdafs "^2.0.3"

"@types/node@*":
version "17.0.31"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.31.tgz#a5bb84ecfa27eec5e1c802c6bbf8139bdb163a5d"
Expand Down Expand Up @@ -66,13 +73,6 @@ chownr@^1.1.1:
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b"
integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==

chrome-aws-lambda@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/chrome-aws-lambda/-/chrome-aws-lambda-10.1.0.tgz#ac43b4cdfc1fbb2275c62effada560858099501e"
integrity sha512-NZQVf+J4kqG4sVhRm3WNmOfzY0OtTSm+S8rg77pwePa9RCYHzhnzRs8YvNI6L9tALIW6RpmefWiPURt3vURXcw==
dependencies:
lambdafs "^2.0.3"

concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
Expand Down
54 changes: 28 additions & 26 deletions packages/cdk/lib/group-lambda-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,34 +131,36 @@ export class GroupLambdaStack extends Construct {
);
props.continuumTable.grantReadWriteData(this.createMerkleProofV2Lambda);

// Work around to use nft.storage which is supported node 16+
// https://fusebit.io/blog/run-every-nodejs-version-in-lambda
// https://github.com/fusebit/everynode
// https://github.com/aws/aws-lambda-base-images/issues/14
const customNodeLayer = lambda.LayerVersion.fromLayerVersionArn(
this.genMetadataLambda = new lambda_nodejs.NodejsFunction(
this,
'customNode',
'arn:aws:lambda:us-west-2:072686360478:layer:node-16_14_2:1',
);

this.genMetadataLambda = new lambda.Function(this, 'genMetadata', {
runtime: new lambda.Runtime('nodejs16.x', lambda.RuntimeFamily.NODEJS),
handler: 'index.handler',
code: lambda.Code.fromAsset(
path.join(`${__dirname}/../`, 'functions', 'genMetadata'),
),
environment: {
TableName: props.continuumTable.tableName,
SITE_URL:
deployEnv() === 'dev'
? 'https://continuum-swart.vercel.app'
: 'https://continuum.tomoima525.com',
nftstorage_key_id: `continuum_nft_key_${deployEnv()}`,
'genMetadata',
{
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'handler',
entry: path.join(
`${__dirname}/../`,
'functions',
'genMetadata/index.ts',
),
environment: {
TableName: props.continuumTable.tableName,
SITE_URL:
deployEnv() === 'dev'
? 'https://continuum-swart.vercel.app'
: 'https://continuum.tomoima525.com',
nftstorage_key_id: `continuum_nft_key_${deployEnv()}`,
},
timeout: Duration.minutes(1),
memorySize: 1536,
bundling: {
externalModules: [
'aws-sdk', // Use the 'aws-sdk' available in the Lambda runtime
'@sparticuz/chrome-aws-lambda', // Do not include this to prevent `/var/bin/chrome.br` does not exist error
],
},
layers: [props.dbUtilLayer, props.chromeLayer],
},
timeout: Duration.minutes(1),
memorySize: 1536,
layers: [props.dbUtilLayer, customNodeLayer, props.chromeLayer],
});
);
props.continuumTable.grantReadWriteData(this.genMetadataLambda);
this.genMetadataLambda.addToRolePolicy(props.secretManagerPolicy);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/cdk/lib/layer-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class LambdaLayerSetup extends Construct {
compatibleRuntimes: [
lambda.Runtime.NODEJS_12_X,
lambda.Runtime.NODEJS_14_X,
lambda.Runtime.NODEJS_16_X,
],
code: lambda.Code.fromAsset('functions/layers/cdk-crypto'),
description: 'crypto components',
Expand All @@ -22,7 +23,7 @@ export class LambdaLayerSetup extends Construct {
compatibleRuntimes: [
lambda.Runtime.NODEJS_12_X,
lambda.Runtime.NODEJS_14_X,
new lambda.Runtime('nodejs16.x', lambda.RuntimeFamily.NODEJS),
lambda.Runtime.NODEJS_16_X,
],
code: lambda.Code.fromAsset('functions/layers/dynamodb'),
description: 'dynamodb utility components',
Expand All @@ -32,7 +33,7 @@ export class LambdaLayerSetup extends Construct {
compatibleRuntimes: [
lambda.Runtime.NODEJS_12_X,
lambda.Runtime.NODEJS_14_X,
new lambda.Runtime('nodejs16.x', lambda.RuntimeFamily.NODEJS),
lambda.Runtime.NODEJS_16_X,
],
code: lambda.Code.fromAsset('functions/layers/chrome'),
description: 'chrome components',
Expand Down
4 changes: 2 additions & 2 deletions packages/cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"devDependencies": {
"@types/jest": "^26.0.10",
"@types/node": "10.17.27",
"aws-cdk": "^2.22.0",
"aws-cdk": "^2.24.1",
"jest": "^26.4.2",
"ts-jest": "^26.2.0",
"ts-node": "^9.0.0",
"typescript": "~3.9.7"
},
"dependencies": {
"aws-cdk-lib": "^2.22.0",
"aws-cdk-lib": "^2.24.1",
"constructs": "^10.0.0",
"source-map-support": "^0.5.16"
}
Expand Down
1 change: 1 addition & 0 deletions packages/continuum-web/src/hooks/useMint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default function useMint(): ReturnParameters {
wasmFilePath: './semaphore.wasm',
zkeyFilePath: './semaphore_final.zkey',
};
console.log('=== tt', { groupId, identityCommitment });
// Step 1 fetch leaves
const result = await (
await fetch(
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4024,10 +4024,10 @@ available-typed-arrays@^1.0.5:
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==

aws-cdk-lib@^2.22.0:
version "2.22.0"
resolved "https://registry.yarnpkg.com/aws-cdk-lib/-/aws-cdk-lib-2.22.0.tgz#21b13764eff8c44cfe8ab03509a173ee8b661475"
integrity sha512-Orz+c746XGm1QBJKb3Wh6qH2rpmHdYMS5A4Wk91niYzrY4Q2kck/XLeQtEwOzscbW2Hqwc6vXTEpkldAI2pzGw==
aws-cdk-lib@^2.24.1:
version "2.24.1"
resolved "https://registry.yarnpkg.com/aws-cdk-lib/-/aws-cdk-lib-2.24.1.tgz#197d10216b384850c01205acc8e4818838964302"
integrity sha512-xGeEX+9wPGppSiIUdf/JTLMmqMikGhlSi7bjijl3lwncZtySkdjX0j+W2A1fuKp0S8Yd2axkwVkltIMxzNH/gw==
dependencies:
"@balena/dockerignore" "^1.0.2"
case "1.6.3"
Expand All @@ -4036,7 +4036,7 @@ aws-cdk-lib@^2.22.0:
jsonschema "^1.4.0"
minimatch "^3.1.2"
punycode "^2.1.1"
semver "^7.3.6"
semver "^7.3.7"
yaml "1.10.2"

aws-cdk@^2.20.0:
Expand All @@ -4046,10 +4046,10 @@ aws-cdk@^2.20.0:
optionalDependencies:
fsevents "2.3.2"

aws-cdk@^2.22.0:
version "2.22.0"
resolved "https://registry.yarnpkg.com/aws-cdk/-/aws-cdk-2.22.0.tgz#3d0a3158f228f398faed49d73372f8aa351034bf"
integrity sha512-oF3VCv/rtuLk8eLb6CBEWvEobabG8q05ersawGEy9CBhKbKNjfY1FDz6gc3ssksTwfcJqyJms2l/BQlLMBjugw==
aws-cdk@^2.24.1:
version "2.24.1"
resolved "https://registry.yarnpkg.com/aws-cdk/-/aws-cdk-2.24.1.tgz#88c3ece3c01674fbed4e131f3391aa199b5e3871"
integrity sha512-fDcJW7tLbqsCvWB3eZY6glRrjRE45VqLT+JuKz3C2jIe6qXkwV8dBwYXElwY/tTCh/hDlpWtCNMRdhmrdE25GQ==
optionalDependencies:
fsevents "2.3.2"

Expand Down Expand Up @@ -14287,7 +14287,7 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.2.1, semver@^7.3.4, semver@^7.3.6:
semver@^7.2.1, semver@^7.3.4, semver@^7.3.7:
version "7.3.7"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f"
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
Expand Down