admin管理员组文章数量:1353174
I'm learning Midnight's tooling and compact language. I currently have two contracts: apact:
module a {
export sealed ledger num: Uint<8>;
}
bpact:
import "a";
constructor() {
num = 10;
}
Is it expected for typescript target files generated by compactc to be empty and look like this:
import type * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
export type Witnesses<T> = {
}
export type ImpureCircuits<T> = {
}
export type PureCircuits = {
}
export type Circuits<T> = {
}
export type Ledger = {
}
export type ContractReferenceLocations = any;
export declare const contractReferenceLocations : ContractReferenceLocations;
export declare class Contract<T, W extends Witnesses<T> = Witnesses<T>> {
witnesses: W;
circuits: Circuits<T>;
impureCircuits: ImpureCircuits<T>;
constructor(witnesses: W);
initialState(context: __compactRuntime.ConstructorContext<T>): __compactRuntime.ConstructorResult<T>;
}
export declare function ledger(state: __compactRuntime.StateValue): Ledger;
export declare const pureCircuits: PureCircuits;
I'm learning Midnight's tooling and compact language. I currently have two contracts: apact:
module a {
export sealed ledger num: Uint<8>;
}
bpact:
import "a";
constructor() {
num = 10;
}
Is it expected for typescript target files generated by compactc to be empty and look like this:
import type * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
export type Witnesses<T> = {
}
export type ImpureCircuits<T> = {
}
export type PureCircuits = {
}
export type Circuits<T> = {
}
export type Ledger = {
}
export type ContractReferenceLocations = any;
export declare const contractReferenceLocations : ContractReferenceLocations;
export declare class Contract<T, W extends Witnesses<T> = Witnesses<T>> {
witnesses: W;
circuits: Circuits<T>;
impureCircuits: ImpureCircuits<T>;
constructor(witnesses: W);
initialState(context: __compactRuntime.ConstructorContext<T>): __compactRuntime.ConstructorResult<T>;
}
export declare function ledger(state: __compactRuntime.StateValue): Ledger;
export declare const pureCircuits: PureCircuits;
Share
Improve this question
edited yesterday
lolocoding
635 bronze badges
asked Mar 31 at 19:40
Petlover620Petlover620
1572 silver badges13 bronze badges
1 Answer
Reset to default 2Hey @petlover620,
Yes, that's expected. That contract actually does have a ledger field num
in its public state, but the field's not been exported from the contract (bpact
) so it's not visible from the DApp's JS code. You need:
export { num };
in bpact
for that. If contract b
doesn't re-export members of module a
then they're "private" from the JS code.
It's moderately confusing that export
does something (slightly) different in a module definition (makes it available to Compact code that imports the module) and at the top level of a contract (makes it available to the JS code).
The compiler is sometimes aggressive about throwing away unneeded code, but in this case you can see that the constructor is there even when you don't re-export the module's field. Search for 10n
in index.cjs
to see it.
本文标签: blockchainIs it expected for typescript target files generated by compactc to be emptyStack Overflow
版权声明:本文标题:blockchain - Is it expected for typescript target files generated by compactc to be empty? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743924397a2562689.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论