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

represent whether signed and/or proven within Transaction type + rework prove method #1567

Merged
merged 27 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
688304b
enable chaining prove, typedocs
harrysolovay Apr 12, 2024
4b359d2
get rid of needless console log in example
harrysolovay Apr 12, 2024
abdf47d
improve TransactionPromise typing
harrysolovay Apr 12, 2024
ed4d448
revert example change
harrysolovay Apr 12, 2024
e8a23da
typing mania
harrysolovay Apr 12, 2024
d718c28
remove default type param and clean up example
harrysolovay Apr 12, 2024
a10a4c4
add signed type to Transaction and TransactionPromise
harrysolovay Apr 12, 2024
f365521
fix signature of sendTransaction in mina-instance
harrysolovay Apr 12, 2024
38e0874
add todo comment
harrysolovay Apr 12, 2024
f990ce6
make proof plural
harrysolovay Apr 12, 2024
1ad5726
add to changelog
harrysolovay Apr 12, 2024
9a4354c
clean up changelog sentence
harrysolovay Apr 12, 2024
f3a0276
more changelog cleanup
harrysolovay Apr 12, 2024
02c6f47
Transaction shadowing in the same file
harrysolovay Apr 13, 2024
9b4bfe8
remove changelog heading
harrysolovay Apr 13, 2024
e9f47ab
fix merge conflicts
harrysolovay Apr 16, 2024
dc59a79
fix integration test error
harrysolovay Apr 16, 2024
3bf2b8e
sync w upstream and fix merge conflicts
harrysolovay Apr 17, 2024
ea5e13b
make proofs into a method
harrysolovay Apr 17, 2024
442c340
clean up reducer-composite eg
harrysolovay Apr 17, 2024
68c7fab
Merge branch 'main' into prove-in-chain
MartinMinkov Apr 17, 2024
ed7b7c0
Merge branch 'prove-in-chain' of github.com:harrysolovay/o1js into pr…
MartinMinkov Apr 17, 2024
c60ac20
feat(local-blockchain): fix support for actions
MartinMinkov Apr 17, 2024
02f9777
feat(examples): fixup examples causing issues in integration tests
MartinMinkov Apr 17, 2024
c60ecf0
chore(mina): update mina submodule to latest commit for up-to-date fe…
MartinMinkov Apr 17, 2024
155a12b
fix(fake-proof.ts): change the way contractProof is extracted from tx…
MartinMinkov Apr 17, 2024
8e76633
fix(on-chain-state-mgmt-zkapp-ui.js): change proof extraction from tr…
MartinMinkov Apr 17, 2024
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
20 changes: 16 additions & 4 deletions src/examples/chaining-tx-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
SmartContract,
Mina,
AccountUpdate,
TransactionPromise,
} from 'o1js';

class SimpleZkapp extends SmartContract {
Expand Down Expand Up @@ -52,10 +53,21 @@ await Mina.transaction(sender, async () => {
console.log('initial state: ' + zkapp.x.get());

console.log('increment');
const incrementTx = Mina.transaction(sender, async () => {

await Mina.transaction(sender, async () => {
await zkapp.increment();
}).sign([senderKey]);
await incrementTx.then((v) => v.prove());
await incrementTx.send().wait();
})
.sign([senderKey])
.prove()
.send()
.wait();

console.log('final state: ' + zkapp.x.get());

const a = Mina.transaction(sender, async () => {
await zkapp.increment();
});
a satisfies TransactionPromise<false, false>;
const b = a.prove() satisfies TransactionPromise<true, false>;
const c = b.sign([senderKey]) satisfies TransactionPromise<true, true>;
await c.send().wait();
47 changes: 26 additions & 21 deletions src/examples/zkapps/simple-zkapp-with-proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ let { verificationKey: trivialVerificationKey } = await TrivialZkapp.compile();
// submitting transactions? or is this an irrelevant use case?
// would also improve the return type -- `Proof` instead of `(Proof | undefined)[]`
console.log('prove (trivial zkapp)');
let [trivialProof] = await (
await Mina.transaction(feePayer, async () => {
await new TrivialZkapp(zkappAddress2).proveSomething(Field(1));
})
).prove();
let [trivialProof] = await Mina.transaction(feePayer, async () => {
await new TrivialZkapp(zkappAddress2).proveSomething(Field(1));
}).prove().proof;

trivialProof = await testJsonRoundtripAndVerify(
TrivialProof,
Expand All @@ -81,19 +79,22 @@ let { verificationKey } = await NotSoSimpleZkapp.compile();
let zkapp = new NotSoSimpleZkapp(zkappAddress);

console.log('deploy');
let tx = await Mina.transaction(feePayer, async () => {
await Mina.transaction(feePayer, async () => {
AccountUpdate.fundNewAccount(feePayer);
await zkapp.deploy();
});
await tx.prove();
await tx.sign([feePayerKey, zkappKey]).send();
})
.prove()
.sign([feePayerKey, zkappKey])
.send();

console.log('initialize');
tx = await Mina.transaction(feePayer, async () => {
let tx = Mina.transaction(feePayer, async () => {
await zkapp.initialize(trivialProof!);
});
let [proof] = await tx.prove();
await tx.sign([feePayerKey]).send();
})
.prove()
.sign([feePayerKey]);
let [proof] = await tx.proof;
await tx.send();

proof = await testJsonRoundtripAndVerify(
NotSoSimpleZkapp.Proof(),
Expand All @@ -104,11 +105,13 @@ proof = await testJsonRoundtripAndVerify(
console.log('initial state: ' + zkapp.x.get());

console.log('update');
tx = await Mina.transaction(feePayer, async () => {
tx = Mina.transaction(feePayer, async () => {
await zkapp.update(Field(3), proof!, trivialProof!);
});
[proof] = await tx.prove();
await tx.sign([feePayerKey]).send();
})
.prove()
.sign([feePayerKey]);
[proof] = await tx.proof;
await tx.send();

proof = await testJsonRoundtripAndVerify(
NotSoSimpleZkapp.Proof(),
Expand All @@ -119,11 +122,13 @@ proof = await testJsonRoundtripAndVerify(
console.log('state 2: ' + zkapp.x.get());

console.log('update');
tx = await Mina.transaction(feePayer, async () => {
tx = Mina.transaction(feePayer, async () => {
await zkapp.update(Field(3), proof!, trivialProof!);
});
[proof] = await tx.prove();
await tx.sign([feePayerKey]).send();
})
.prove()
.sign([feePayerKey]);
[proof] = await tx.proof;
await tx.send();

proof = await testJsonRoundtripAndVerify(
NotSoSimpleZkapp.Proof(),
Expand Down
Loading