Skip to content

Commit e665251

Browse files
andrew-fleming0xiskemnul
authored
Bump to compact 0.28.0 (#62)
Co-authored-by: 0xisk <0xisk@proton.me> Co-authored-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com>
1 parent e61cd0e commit e665251

25 files changed

Lines changed: 135 additions & 113 deletions

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ runs:
4343
if: ${{ inputs.skip-compact != 'true' }}
4444
uses: midnightntwrk/setup-compact-action@4130145456ad3f45934788dd4a65647eb283e658 # loose commit/not released
4545
with:
46-
compact-version: "0.26.0"
46+
compact-version: "0.28.0"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ Confirm your Compact toolchain:
4646
```bash
4747
$ compact compile --version
4848

49-
Compactc version: 0.26.0
50-
0.26.0
49+
Compactc version: 0.28.0
50+
0.28.0
5151
```
5252

5353
## Getting started

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
"types": "turbo run types",
1616
"clean": "turbo run clean"
1717
},
18-
"dependencies": {
19-
"@midnight-ntwrk/compact-runtime": "^0.9.0"
20-
},
2118
"devDependencies": {
2219
"@biomejs/biome": "2.3.8",
23-
"@midnight-ntwrk/ledger": "^4.0.0",
20+
"@midnight-ntwrk/ledger-v7": "^7.0.0",
2421
"@midnight-ntwrk/zswap": "^4.0.0",
2522
"@types/node": "24.10.1",
2623
"ts-node": "^10.9.2",

packages/cli/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Verify your Compact installation:
2323

2424
```bash
2525
$ compact compile --version
26-
Compactc version: 0.26.0
26+
Compactc version: 0.28.0
2727
```
2828

2929
## Binaries
@@ -52,7 +52,7 @@ compact-compiler [options]
5252
| `--out <directory>` | Output directory for compiled artifacts | `artifacts` |
5353
| `--hierarchical` | Preserve source directory structure in output | `false` |
5454
| `--skip-zk` | Skip zero-knowledge proof generation | `false` |
55-
| `+<version>` | Use specific toolchain version (e.g., `+0.26.0`) | (default) |
55+
| `+<version>` | Use specific toolchain version (e.g., `+0.28.0`) | (default) |
5656

5757
### Environment Variables
5858

@@ -102,7 +102,7 @@ compact-compiler --dir security
102102
compact-compiler --skip-zk
103103

104104
# Use specific toolchain version
105-
compact-compiler +0.26.0
105+
compact-compiler +0.28.0
106106

107107
# Custom source and output directories
108108
compact-compiler --src contracts --out build
@@ -155,7 +155,7 @@ import { CompactCompiler } from '@openzeppelin/compact-tools-cli';
155155
const compiler = new CompactCompiler({
156156
flags: '--skip-zk',
157157
targetDir: 'security',
158-
version: '0.26.0',
158+
version: '0.28.0',
159159
hierarchical: true,
160160
srcDir: 'src',
161161
outDir: 'artifacts',
@@ -167,7 +167,7 @@ await compiler.compile();
167167
const compiler = CompactCompiler.fromArgs([
168168
'--dir', 'security',
169169
'--skip-zk',
170-
'+0.26.0'
170+
'+0.28.0'
171171
]);
172172

173173
await compiler.compile();
@@ -196,7 +196,7 @@ class CompactBuilder {
196196
interface CompilerOptions {
197197
flags?: string; // Compiler flags (e.g., '--skip-zk --verbose')
198198
targetDir?: string; // Subdirectory within srcDir to compile
199-
version?: string; // Toolchain version (e.g., '0.26.0')
199+
version?: string; // Toolchain version (e.g., '0.28.0')
200200
hierarchical?: boolean; // Preserve directory structure in output
201201
srcDir?: string; // Source directory (default: 'src')
202202
outDir?: string; // Output directory (default: 'artifacts')
@@ -233,15 +233,15 @@ yarn clean
233233

234234
## Output Example
235235

236-
```
236+
```bash
237237
ℹ [COMPILE] Compact compiler started
238-
ℹ [COMPILE] Compact developer tools: compact 0.1.0
239-
ℹ [COMPILE] Compact toolchain: Compactc version: 0.26.0
238+
ℹ [COMPILE] Compact developer tools: compact 0.2.0
239+
ℹ [COMPILE] Compact toolchain: Compactc version: 0.28.0
240240
ℹ [COMPILE] Found 2 .compact file(s) to compile
241241
✔ [COMPILE] [1/2] Compiled AccessControl.compact
242-
Compactc version: 0.26.0
242+
Compactc version: 0.28.0
243243
✔ [COMPILE] [2/2] Compiled Token.compact
244-
Compactc version: 0.26.0
244+
Compactc version: 0.28.0
245245
```
246246

247247
## License

packages/simulator/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ allowing you to simulate contract behavior locally without blockchain deployment
1515

1616
```typescript
1717
import { createSimulator } from '@openzeppelin-compact/contracts-simulator';
18-
import { Contract, ledger } from './artifacts/MyContract/contract/index.cjs';
18+
import { Contract, ledger } from './artifacts/MyContract/contract/index.js';
1919

2020
// 1. Define your contract arguments type
2121
type MyContractArgs = readonly [owner: Uint8Array, value: bigint];
@@ -46,7 +46,7 @@ The base simulator acts as a configuration class that the actual simulator will
4646

4747
```typescript
4848
import { createSimulator } from '@openzeppelin-compact/contracts-simulator';
49-
import { Contract as MyContract, ledger } from './artifacts/MyContract/contract/index.cjs';
49+
import { Contract as MyContract, ledger } from './artifacts/MyContract/contract/index.js';
5050
import { MyContractWitnesses, MyContractPrivateState } from './MyContractWitnesses.js';
5151

5252
// Define contract constructor arguments as a tuple type

packages/simulator/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"clean": "git clean -fXd"
3131
},
3232
"devDependencies": {
33-
"@midnight-ntwrk/ledger": "^4.0.0",
33+
"@midnight-ntwrk/ledger-v7": "^7.0.0",
3434
"@midnight-ntwrk/zswap": "^4.0.0",
3535
"@tsconfig/node24": "^24.0.3",
3636
"@types/node": "24.10.1",
@@ -39,6 +39,6 @@
3939
"vitest": "^4.0.15"
4040
},
4141
"dependencies": {
42-
"@midnight-ntwrk/compact-runtime": "^0.9.0"
42+
"@midnight-ntwrk/compact-runtime": "0.14.0"
4343
}
4444
}

packages/simulator/src/core/AbstractSimulator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type {
22
CircuitContext,
33
CoinPublicKey,
4-
ContractState,
4+
StateValue,
55
} from '@midnight-ntwrk/compact-runtime';
66
import type {
77
ContextlessCircuits,
@@ -79,12 +79,12 @@ export abstract class AbstractSimulator<P, L>
7979
}
8080

8181
/**
82-
* Retrieves the original contract state from the circuit context.
82+
* Retrieves the current contract state data.
8383
*
84-
* @returns The current contract state from the blockchain
84+
* @returns The current state value containing the ledger data
8585
*/
86-
public getContractState(): ContractState {
87-
return this.circuitContext.originalState;
86+
public getContractState(): StateValue {
87+
return this.circuitContext.currentQueryContext.state.state;
8888
}
8989

9090
/**

packages/simulator/src/core/CircuitContextManager.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
type ConstructorContext,
55
type ContractAddress,
66
type ContractState,
7-
constructorContext,
7+
CostModel,
8+
createConstructorContext,
89
type EncodedZswapLocalState,
910
QueryContext,
1011
} from '@midnight-ntwrk/compact-runtime';
@@ -44,22 +45,22 @@ export class CircuitContextManager<P> {
4445
contractAddress: ContractAddress,
4546
...contractArgs: any[]
4647
) {
47-
const initCtx = constructorContext(privateState, coinPK);
48+
const initCtx = createConstructorContext(privateState, coinPK);
4849

4950
const {
5051
currentPrivateState,
5152
currentContractState,
5253
currentZswapLocalState,
5354
} = contract.initialState(initCtx, ...contractArgs);
5455

56+
// Extract ChargedState from the compiler-generated ContractState
57+
const chargedState = currentContractState.data;
58+
5559
this.context = {
5660
currentPrivateState,
5761
currentZswapLocalState,
58-
originalState: currentContractState,
59-
transactionContext: new QueryContext(
60-
currentContractState.data,
61-
contractAddress,
62-
),
62+
currentQueryContext: new QueryContext(chargedState, contractAddress),
63+
costModel: CostModel.initialCostModel(),
6364
};
6465
}
6566

packages/simulator/src/core/ContractSimulator.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ export abstract class ContractSimulator<P, L> extends AbstractSimulator<P, L> {
3535
*/
3636
public getCallerContext(): CircuitContext<P> {
3737
const activeCaller = this.callerOverride || this.persistentCallerOverride;
38+
const baseCtx = this.circuitContext;
3839

3940
return {
40-
...this.circuitContext,
41+
currentPrivateState: baseCtx.currentPrivateState,
42+
currentQueryContext: baseCtx.currentQueryContext,
4143
currentZswapLocalState: activeCaller
4244
? emptyZswapLocalState(activeCaller)
43-
: this.circuitContext.currentZswapLocalState,
45+
: baseCtx.currentZswapLocalState,
46+
costModel: baseCtx.costModel,
47+
gasLimit: baseCtx.gasLimit,
4448
};
4549
}
4650

packages/simulator/src/factory/createSimulator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { WitnessContext } from '@midnight-ntwrk/compact-runtime';
2-
import { sampleContractAddress } from '@midnight-ntwrk/zswap';
2+
import { dummyContractAddress } from '@midnight-ntwrk/compact-runtime';
33
import { CircuitContextManager } from '../core/CircuitContextManager.js';
44
import { ContractSimulator } from '../core/ContractSimulator.js';
55
import type { IMinimalContract } from '../types/Contract.js';
@@ -49,7 +49,7 @@ export function createSimulator<
4949
privateState = config.defaultPrivateState(),
5050
witnesses = config.witnessesFactory(),
5151
coinPK = '0'.repeat(64),
52-
contractAddress = sampleContractAddress(),
52+
contractAddress = dummyContractAddress(),
5353
} = options;
5454

5555
this._witnesses = witnesses;
@@ -65,7 +65,7 @@ export function createSimulator<
6565
...processedArgs,
6666
);
6767

68-
this.contractAddress = this.circuitContext.transactionContext.address;
68+
this.contractAddress = this.circuitContext.currentQueryContext.address;
6969
}
7070

7171
public _pureCircuitProxy?: ContextlessCircuits<
@@ -143,7 +143,7 @@ export function createSimulator<
143143
*/
144144
getPublicState(): L {
145145
return config.ledgerExtractor(
146-
this.circuitContext.transactionContext.state,
146+
this.circuitContext.currentQueryContext.state.state,
147147
);
148148
}
149149

@@ -191,7 +191,7 @@ export function createSimulator<
191191
return {
192192
ledger: this.getPublicState(),
193193
privateState: circuitCtx.currentPrivateState,
194-
contractAddress: circuitCtx.transactionContext.address,
194+
contractAddress: circuitCtx.currentQueryContext.address,
195195
};
196196
}
197197
};

0 commit comments

Comments
 (0)