-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feat: Alpha Release Iteration #7
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a30794e
chore: add lint GH
crypblizz8 666b6c8
chore: forgot the step
crypblizz8 e1d908c
chore: update engine due to node17+
crypblizz8 73c1a16
chore: 17+
crypblizz8 39c8552
chore: node20 min
crypblizz8 2c4b487
chore: add node20 base
crypblizz8 2d1032c
feat: add in example code and extra instructions
crypblizz8 faa4ebd
chore: app dir
crypblizz8 5cf7f3b
chore: refactor and add programs
crypblizz8 d172363
chore: add pyth env
crypblizz8 9cb0eff
chore: prettier
crypblizz8 18fde77
chore: publish test
crypblizz8 a30b59f
chore: rename build GH
crypblizz8 8c50051
chore: refactor as release yaml
crypblizz8 2dae6d6
chore: readme and images
crypblizz8 2350510
chore: upgrade to latest package 0.1.0
crypblizz8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm run check | ||
- run: npm run format -- --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- env: | ||
NODE_AUTH_TOKEN: | ||
${{ secrets.NPM_TOKEN }} | ||
- run: npm install | ||
- run: npm run release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["next/core-web-vitals", "next/typescript"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"trailingComma": "all", | ||
"tabWidth": 2, | ||
"arrowParens": "always", | ||
"semi": true, | ||
"useTabs": false, | ||
"singleQuote": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## Nextjs Example for Create Nillion App (CNA) | ||
|
||
 | ||
|
||
Welcome the Nextjs Example for CNA. | ||
|
||
Once the CLI insturctions have finished, you can run the developent server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
pnpm dev | ||
# or | ||
bun dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
Then follow the rest of the instructions from the Quickstart guide [here.](https://github.com/NillionNetwork/awesome-nillion/issues/2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use client"; | ||
|
||
import { ReactNode } from "react"; | ||
|
||
import { NillionProvider } from "@nillion/client-react-hooks"; | ||
|
||
export const ClientWrapper: React.FC<{ children: ReactNode }> = ({ | ||
children, | ||
}) => { | ||
return <NillionProvider network="devnet">{children}</NillionProvider>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
"use client"; | ||
|
||
import { type FC, useState } from "react"; | ||
import { | ||
NadaValue, | ||
NadaValues, | ||
NamedValue, | ||
PartyName, | ||
ProgramBindings, | ||
ProgramId, | ||
} from "@nillion/client-core"; | ||
import { useNilCompute, useNillion } from "@nillion/client-react-hooks"; | ||
|
||
export const Compute: FC = () => { | ||
const { client } = useNillion(); | ||
const nilCompute = useNilCompute(); | ||
const [programId, setProgramId] = useState<ProgramId | string>(""); | ||
const [copiedComputeOutputID, setCopiedComputeOutputID] = useState(false); | ||
|
||
const handleClick = () => { | ||
if (!programId) throw new Error("compute: program id required"); | ||
|
||
const bindings = ProgramBindings.create(programId) | ||
.addInputParty(PartyName.parse("Party1"), client.partyId) | ||
.addOutputParty(PartyName.parse("Party1"), client.partyId); | ||
|
||
// Note: This is hardcoded for demo purposes. | ||
// Feel free to change the NamedValue to your required program values. | ||
const values = NadaValues.create() | ||
.insert(NamedValue.parse("my_int1"), NadaValue.createSecretInteger(2)) | ||
.insert(NamedValue.parse("my_int2"), NadaValue.createSecretInteger(4)); | ||
|
||
nilCompute.execute({ bindings, values }); | ||
}; | ||
|
||
return ( | ||
<div className="border border-gray-400 rounded-lg p-4 w-full max-w-md"> | ||
<h2 className="text-2xl font-bold mb-4">Compute</h2> | ||
<input | ||
className="w-full p-2 mb-4 border border-gray-300 rounded text-black" | ||
placeholder="Program id" | ||
value={programId} | ||
onChange={(e) => setProgramId(e.target.value)} | ||
/> | ||
<button | ||
className={`flex items-center justify-center px-4 py-2 border rounded text-black mb-4 ${ | ||
nilCompute.isLoading || !programId | ||
? "opacity-50 cursor-not-allowed bg-gray-200" | ||
: "bg-white hover:bg-gray-100" | ||
}`} | ||
onClick={handleClick} | ||
disabled={nilCompute.isLoading || !programId} | ||
> | ||
{nilCompute.isLoading ? ( | ||
<div className="w-5 h-5 border-t-2 border-b-2 border-gray-900 rounded-full animate-spin"></div> | ||
) : ( | ||
"Compute" | ||
)} | ||
</button> | ||
<p className="my-2 italic text-sm mt-2"> | ||
Current values are 4 & 2. Refer to ComputeOutput.tsx | ||
</p> | ||
<ul className="list-disc pl-5 mt-4"> | ||
<li className="mt-2">Status: {nilCompute.status}</li> | ||
<li className="mt-2"> | ||
Compute output id: | ||
{nilCompute.isSuccess ? ( | ||
<> | ||
{`${nilCompute.data?.substring(0, 4)}...${nilCompute.data?.substring(nilCompute.data.length - 4)}`} | ||
<button | ||
onClick={() => { | ||
setCopiedComputeOutputID(true); | ||
navigator.clipboard.writeText(nilCompute.data); | ||
setTimeout(() => setCopiedComputeOutputID(false), 2000); | ||
}} | ||
> | ||
{!copiedComputeOutputID ? " 📋" : " ✅"} | ||
</button> | ||
</> | ||
) : ( | ||
"idle" | ||
)} | ||
</li> | ||
</ul> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"use client"; | ||
|
||
import { type FC, useState } from "react"; | ||
import { useNilComputeOutput } from "@nillion/client-react-hooks"; | ||
import { ComputeOutputId } from "@nillion/client-core"; | ||
|
||
export const ComputeOutput: FC = () => { | ||
const nilComputeOutput = useNilComputeOutput(); | ||
const [computeId, setComputeId] = useState<ComputeOutputId | string>(""); | ||
|
||
const handleClick = () => { | ||
if (!computeId) throw new Error("compute-output: Compute id is required"); | ||
nilComputeOutput.execute({ id: computeId }); | ||
}; | ||
|
||
let computeOutput = "idle"; | ||
if (nilComputeOutput.isSuccess) { | ||
computeOutput = JSON.stringify(nilComputeOutput.data, (key, value) => { | ||
if (typeof value === "bigint") { | ||
return value.toString(); | ||
} | ||
return value; | ||
}); | ||
} | ||
|
||
return ( | ||
<div className="border border-gray-400 rounded-lg p-4 w-full max-w-md"> | ||
<h2 className="text-2xl font-bold mb-4">Compute Output</h2> | ||
<input | ||
className="w-full p-2 mb-4 border border-gray-300 rounded text-black" | ||
placeholder="Compute output id" | ||
value={computeId} | ||
onChange={(e) => setComputeId(e.target.value)} | ||
/> | ||
<button | ||
className={`flex items-center justify-center px-4 py-2 border rounded text-black ${ | ||
!computeId || nilComputeOutput.isLoading | ||
? "opacity-50 cursor-not-allowed bg-gray-200" | ||
: "bg-white hover:bg-gray-100" | ||
}`} | ||
onClick={handleClick} | ||
disabled={!computeId || nilComputeOutput.isLoading} | ||
> | ||
{nilComputeOutput.isLoading ? ( | ||
<div className="w-5 h-5 border-t-2 border-b-2 border-gray-900 rounded-full animate-spin"></div> | ||
) : ( | ||
"Fetch" | ||
)} | ||
</button> | ||
<ul className="list-disc pl-5 mt-4"> | ||
<li className="mt-2">Status: {nilComputeOutput.status}</li> | ||
<li className="mt-2">Output: {computeOutput}</li> | ||
</ul> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add in when ready