Open AndreasGassmann opened 1 year ago
I would recommend to compare backend and web TypeScript settings, in particular:
"compilerOptions": {
"composite": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictPropertyInitialization": false
}
Hi all,
the build will still fail even after adding those lines in tsconfig.json
, the errors are the same as @AndreasGassmann
You can also try to downgrade typescript libraries; I've seen the same errors after upgrading to the last versions: https://discord.com/channels/484437221055922177/1176450974873813073/1177569477521584179
@AndreasGassmann After a lot of time spent with the same issue in Angular I came to a bunch of conclusions:
o1js
relies on topLevelAwait
feature. Angular by its own rules doesn't come with topLevelAwait
as a default configuration and therefore it is not considered a bug
if something dependent on that is not working. The flag is enabled there by Webpack, not by Angular, they take no responsibility.o1js
is doing some really strange function-string operations with the WebWorkers which most probably confuses Angular and the mechanisms underneath. I think that with Angular's latest release (v17), the o1js team should prioritize the support for Angular because it is getting more popular than ever.
As part of the Mina Navigators Hackathon, we built a project with multiple components. We used
o1js
successfully in the backend to create and deploy a contract. However, we struggled to useo1js
in a frontend, created with the Angular framework.After doing
npm i o1js
and trying to use it, this was the error:Error message
```bash Error: node_modules/o1js/dist/node/bindings/crypto/bindings/curve.d.ts:4:24 - error TS2307: Cannot find module 'src/lib/ml/base.js' or its corresponding type declarations. 4 import { MlPair } from 'src/lib/ml/base.js'; ~~~~~~~~~~~~~~~~~~~~ Error: node_modules/o1js/dist/node/bindings/crypto/bindings/kimchi-types.d.ts:8:43 - error TS2307: Cannot find module '../../compiled/node_bindings/plonk_wasm.cjs' or its corresponding type declarations. 8 import type { WasmFpSrs, WasmFqSrs } from '../../compiled/node_bindings/plonk_wasm.cjs'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: node_modules/o1js/dist/node/bindings/js/node/node-backend.d.ts:4:34 - error TS2307: Cannot find module '../../compiled/node_bindings/plonk_wasm.cjs' or its corresponding type declarations. 4 export const wasm: typeof import("../../compiled/node_bindings/plonk_wasm.cjs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: node_modules/o1js/dist/node/bindings/js/wrapper.d.ts:2:42 - error TS2307: Cannot find module '../compiled/node_bindings/plonk_wasm.cjs' or its corresponding type declarations. 2 export function getWasm(): typeof import("../compiled/node_bindings/plonk_wasm.cjs"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: node_modules/o1js/dist/node/lib/proof-system/prover-keys.d.ts:8:62 - error TS2307: Cannot find module '../../bindings/compiled/node_bindings/plonk_wasm.cjs' or its corresponding type declarations. 8 import { WasmPastaFpPlonkIndex, WasmPastaFqPlonkIndex } from '../../bindings/compiled/node_bindings/plonk_wasm.cjs'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: node_modules/o1js/dist/node/snarky.d.ts:27:8 - error TS2307: Cannot find module './bindings/compiled/node_bindings/plonk_wasm.cjs' or its corresponding type declarations. 27 } from './bindings/compiled/node_bindings/plonk_wasm.cjs'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```I then tried to import the
web
part directly, but there were even more errors.Error message
```bash ./src/app/app.component.ts:1:0-42 - Error: Module not found: Error: Package path ./dist/web is not exported from package /Users/main/Programming/Personal/mina-zk-hack/frontend/node_modules/o1js (see exports field in /Users/main/Programming/Personal/mina-zk-hack/frontend/node_modules/o1js/package.json) Error: node_modules/o1js/dist/web/bindings/lib/provable-snarky.d.ts:1:10 - error TS2305: Module '"../../snarky.js"' has no exported member 'Provable'. 1 import { Provable, ProvablePure } from '../../snarky.js'; ~~~~~~~~ Error: node_modules/o1js/dist/web/bindings/lib/provable-snarky.d.ts:1:20 - error TS2305: Module '"../../snarky.js"' has no exported member 'ProvablePure'. 1 import { Provable, ProvablePure } from '../../snarky.js'; ~~~~~~~~~~~~ Error: node_modules/o1js/dist/web/index.d.ts:1:15 - error TS2305: Module '"./snarky.js"' has no exported member 'ProvablePure'. 1 export type { ProvablePure } from './snarky.js'; ~~~~~~~~~~~~ Error: node_modules/o1js/dist/web/lib/account_update.d.ts:316:21 - error TS2503: Cannot find namespace 'Pickles'. 316 previousProofs: Pickles.Proof[]; ~~~~~~~ Error: node_modules/o1js/dist/web/lib/account_update.d.ts:734:38 - error TS2694: Namespace '"/Users/main/Programming/Personal/mina-zk-hack/frontend/node_modules/o1js/dist/web/snarky"' has no exported member 'ProvablePure'. 734 type: import("../snarky.js").ProvablePure<{ ~~~~~~~~~~~~ Error: node_modules/o1js/dist/web/lib/account_update.d.ts:807:47 - error TS2694: Namespace '"/Users/main/Programming/Personal/mina-zk-hack/frontend/node_modules/o1js/dist/web/snarky"' has no exported member 'ProvablePure'. 807 callerContextType: import("../snarky.js").ProvablePure<{ ~~~~~~~~~~~~ Error: node_modules/o1js/dist/web/lib/account_update.d.ts:896:54 - error TS2694: Namespace '"/Users/main/Programming/Personal/mina-zk-hack/frontend/node_modules/o1js/dist/web/snarky"' has no exported member 'ProvablePure'. 896 declare let ZkappPublicInput: import("../snarky.js").ProvablePure<{ ~~~~~~~~~~~~ Error: node_modules/o1js/dist/web/lib/circuit.d.ts:1:10 - error TS2305: Module '"../snarky.js"' has no exported member 'ProvablePure'. 1 import { ProvablePure, Snarky } from '../snarky.js'; ~~~~~~~~~~~~ Error: node_modules/o1js/dist/web/lib/circuit.d.ts:101:12 - error TS2503: Cannot find namespace 'Snarky'. 101 value: Snarky.Keypair; ~~~~~~ Error: node_modules/o1js/dist/web/lib/circuit.d.ts:102:24 - error TS2503: Cannot find namespace 'Snarky'. 102 constructor(value: Snarky.Keypair); ~~~~~~ Error: node_modules/o1js/dist/web/lib/circuit.d.ts:113:48 - error TS2694: Namespace '"/Users/main/Programming/Personal/mina-zk-hack/frontend/node_modules/o1js/dist/web/snarky"' has no exported member 'Gate'. 113 constraintSystem(): import("../snarky.js").Gate[]; ~~~~ Error: node_modules/o1js/dist/web/lib/circuit.d.ts:119:12 - error TS2503: Cannot find namespace 'Snarky'. 119 value: Snarky.Proof; ~~~~~~ Error: node_modules/o1js/dist/web/lib/circuit.d.ts:120:24 - error TS2503: Cannot find namespace 'Snarky'. 120 constructor(value: Snarky.Proof); ~~~~~~ Error: node_modules/o1js/dist/web/lib/circuit.d.ts:126:12 - error TS2503: Cannot find namespace 'Snarky'. 126 value: Snarky.VerificationKey; ~~~~~~ Error: node_modules/o1js/dist/web/lib/circuit.d.ts:127:24 - error TS2503: Cannot find namespace 'Snarky'. 127 constructor(value: Snarky.VerificationKey); ~~~~~~ Error: node_modules/o1js/dist/web/lib/circuit_value.d.ts:2:10 - error TS2305: Module '"../snarky.js"' has no exported member 'ProvablePure'. 2 import { ProvablePure } from '../snarky.js'; ~~~~~~~~~~~~ Error: node_modules/o1js/dist/web/lib/nullifier.d.ts:30:28 - error TS2694: Namespace '"/Users/main/Programming/Personal/mina-zk-hack/frontend/node_modules/o1js/dist/web/snarky"' has no exported member 'ProvablePure'. 30 } & import("../snarky.js").ProvablePure<{ ~~~~~~~~~~~~ Error: node_modules/o1js/dist/web/lib/proof_system.d.ts:1:10 - error TS2305: Module '"../snarky.js"' has no exported member 'ProvablePure'. 1 import { ProvablePure, Pickles, Gate } from '../snarky.js'; ~~~~~~~~~~~~ Error: node_modules/o1js/dist/web/lib/proof_system.d.ts:1:33 - error TS2305: Module '"../snarky.js"' has no exported member 'Gate'. 1 import { ProvablePure, Pickles, Gate } from '../snarky.js'; ~~~~ Error: node_modules/o1js/dist/web/lib/proof_system.d.ts:23:12 - error TS2503: Cannot find namespace 'Pickles'. 23 proof: Pickles.Proof; ~~~~~~~ Error: node_modules/o1js/dist/web/lib/proof_system.d.ts:31:16 - error TS2503: Cannot find namespace 'Pickles'. 31 proof: Pickles.Proof; ~~~~~~~ Error: node_modules/o1js/dist/web/lib/proof_system.d.ts:186:14 - error TS2503: Cannot find namespace 'Pickles'. 186 provers: Pickles.Prover[]; ~~~~~~~ Error: node_modules/o1js/dist/web/lib/proof_system.d.ts:187:25 - error TS2503: Cannot find namespace 'Pickles'. 187 verify: (statement: Pickles.StatementSo I went back to the original
import { PublicKey } from 'o1js'
and fixed the error. There seem to be some invalid paths, which I was able to address by creating this script:With this "fix", I was able to run the page. However, there were some new errors:
And also this:
But even with those errors,
o1js
seems to work as it was able to create a PublicKey. I then went ahead and imported theSmartContract
class I created, but then the whole thing breaks completely, again.That's the contract I tried to interact with:
https://github.com/Acurast/mina-zkoracles/blob/main/contracts/src/AcurastPriceOracle.ts#L47
That's where I gave up and used the GraphQL API to fetch the contract state.
Another part of our application is that we would like to deploy a smart contract directly from the frontend. For this, it seems we could use
SmartContract.compile()
together withSmartContract.deploy(...)
.Any help would be appreciated.
PS: There is another issue open about issues with Angular, but I don't think it's directly related, so I opened a new one: https://github.com/o1-labs/o1js/issues/910