@cofhe/mock-contracts 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/contracts/ABITest.sol +99 -0
- package/contracts/MockACL.sol +5 -1
- package/dist/index.d.mts +15 -6
- package/dist/index.d.ts +15 -6
- package/dist/index.js +1538 -1473
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1538 -1473
- package/dist/index.mjs.map +1 -1
- package/foundry.toml +3 -0
- package/package.json +5 -5
- package/src/MockACL.ts +433 -371
- package/src/MockQueryDecrypter.ts +231 -229
- package/src/MockTaskManager.ts +719 -717
- package/src/MockZkVerifier.ts +175 -173
- package/src/TestBed.ts +199 -197
- package/src/types.ts +12 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @cofhe/mock-contracts Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ac47e2f: Add `PermitUtils.checkValidityOnChain` to validate permits against the on-chain deployed ACL (source of truth).
|
|
8
|
+
- 0000d5e: Mock contracts deployed to alternate fixed addresses to avoid collision with hardhat pre-compiles.
|
|
9
|
+
|
|
10
|
+
## 0.2.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 8fda09a: Removes `Promise<boolean>` return type from `client.connect(...)`, instead throws an error if the connection fails.
|
|
15
|
+
- e0caeca: Adds `environment: 'node' | 'web' | 'hardhat' | 'react'` option to config. Exposed via `client.config.enviroment`. Automatically populated appropriately within the various `createCofhesdkConfig` functions.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- e121108: Fix ACL permission invalid issue. MockACL needs real deployment since etching doesn't call the constructor, so the EIP712 is uninitialized. Also adds additional utility functions to hardhat-plugin:
|
|
20
|
+
|
|
21
|
+
- `hre.cofhesdk.connectWithHardhatSigner(client, signer)` - Connect to client with hardhat ethers signer.
|
|
22
|
+
- `hre.cofhesdk.createBatteriesIncludedCofhesdkClient()` - Creates a batteries included client with signer connected.
|
|
23
|
+
- `hre.cofhesdk.mocks.getMockTaskManager()` - Gets deployed Mock Taskmanager
|
|
24
|
+
- `hre.cofhesdk.mocks.getMockACL()` - Gets deployed Mock ACL
|
|
25
|
+
|
|
3
26
|
## 0.1.1
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
pragma solidity ^0.8.13;
|
|
3
|
+
|
|
4
|
+
import '@fhenixprotocol/cofhe-contracts/FHE.sol';
|
|
5
|
+
|
|
6
|
+
contract ABITest {
|
|
7
|
+
euint32 public eNumber;
|
|
8
|
+
uint256 public numberHash;
|
|
9
|
+
|
|
10
|
+
euint8 public eUint8;
|
|
11
|
+
euint16 public eUint16;
|
|
12
|
+
euint32 public eUint32;
|
|
13
|
+
euint64 public eUint64;
|
|
14
|
+
euint128 public eUint128;
|
|
15
|
+
ebool public eBool;
|
|
16
|
+
eaddress public eAddress;
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
eUint8 = FHE.asEuint8(1);
|
|
20
|
+
eUint16 = FHE.asEuint16(1);
|
|
21
|
+
eUint32 = FHE.asEuint32(1);
|
|
22
|
+
eUint64 = FHE.asEuint64(1);
|
|
23
|
+
eUint128 = FHE.asEuint128(1);
|
|
24
|
+
eBool = FHE.asEbool(true);
|
|
25
|
+
eAddress = FHE.asEaddress(address(0));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
struct ContainsEncryptedInput {
|
|
29
|
+
uint256 value;
|
|
30
|
+
InEuint32 encryptedInput;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
struct ContainsEncryptedResult {
|
|
34
|
+
uint256 value;
|
|
35
|
+
euint32 encryptedResult;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// INPUTS
|
|
39
|
+
|
|
40
|
+
function fnNoEncryptedInputs(uint8 value) public {}
|
|
41
|
+
|
|
42
|
+
function fnEncryptedInput(InEuint32 memory inNumber) public {}
|
|
43
|
+
|
|
44
|
+
function fnBlendedInputsIncludingEncryptedInput(uint256 value, InEuint32 memory inNumber) public {}
|
|
45
|
+
|
|
46
|
+
function fnAllEncryptedInputs(
|
|
47
|
+
InEuint8 memory inEuint8,
|
|
48
|
+
InEuint16 memory inEuint16,
|
|
49
|
+
InEuint32 memory inEuint32,
|
|
50
|
+
InEuint64 memory inEuint64,
|
|
51
|
+
InEuint128 memory inEuint128,
|
|
52
|
+
InEbool memory inEbool,
|
|
53
|
+
InEaddress memory inEaddress
|
|
54
|
+
) public {}
|
|
55
|
+
|
|
56
|
+
function fnStructContainsEncryptedInput(ContainsEncryptedInput memory containsEncryptedInput) public {}
|
|
57
|
+
|
|
58
|
+
function fnArrayContainsEncryptedInput(InEuint32[] memory inEuint32Array) public {}
|
|
59
|
+
|
|
60
|
+
function fnTupleContainsEncryptedInput(InEuint32[2] memory inEuint32Array) public {}
|
|
61
|
+
|
|
62
|
+
// OUTPUTS
|
|
63
|
+
|
|
64
|
+
function fnReturnNoEncrypted() public pure returns (uint256) {
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function fnReturnEncrypted() public view returns (euint32) {
|
|
69
|
+
return eUint32;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function fnReturnBlendedIncludingEncrypted() public view returns (uint256, euint32) {
|
|
73
|
+
return (1, eUint32);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function fnReturnEncryptedArray() public view returns (euint32[] memory) {
|
|
77
|
+
euint32[] memory encryptedArray = new euint32[](1);
|
|
78
|
+
encryptedArray[0] = eUint32;
|
|
79
|
+
return encryptedArray;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function fnReturnEncryptedStruct() public view returns (ContainsEncryptedResult memory) {
|
|
83
|
+
ContainsEncryptedResult memory encryptedResult = ContainsEncryptedResult({ value: 1, encryptedResult: eUint32 });
|
|
84
|
+
return encryptedResult;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function fnReturnAllEncrypted() public view returns (euint8, euint16, euint32, euint64, euint128, ebool, eaddress) {
|
|
88
|
+
return (eUint8, eUint16, eUint32, eUint64, eUint128, eBool, eAddress);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// EVENTS
|
|
92
|
+
|
|
93
|
+
event EventNoEncryptedInputs(uint8 value);
|
|
94
|
+
event EncryptedValue(euint32 value);
|
|
95
|
+
event BlendedValue(uint256 value, euint32 encryptedValue);
|
|
96
|
+
event EncryptedArray(euint32[] value);
|
|
97
|
+
event EncryptedStruct(ContainsEncryptedResult value);
|
|
98
|
+
event AllEncrypted(euint8, euint16, euint32, euint64, euint128, ebool, eaddress);
|
|
99
|
+
}
|
package/contracts/MockACL.sol
CHANGED
|
@@ -66,7 +66,7 @@ contract MockACL is MockPermissioned {
|
|
|
66
66
|
keccak256(abi.encode(uint256(keccak256('cofhe.storage.ACL')) - 1)) & ~bytes32(uint256(0xff));
|
|
67
67
|
|
|
68
68
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
69
|
-
constructor() {}
|
|
69
|
+
constructor() MockPermissioned() {}
|
|
70
70
|
|
|
71
71
|
function exists() public pure returns (bool) {
|
|
72
72
|
return true;
|
|
@@ -335,4 +335,8 @@ contract MockACL is MockPermissioned {
|
|
|
335
335
|
) public view withPermission(permission) returns (bool) {
|
|
336
336
|
return isAllowed(handle, permission.issuer);
|
|
337
337
|
}
|
|
338
|
+
|
|
339
|
+
function checkPermitValidity(Permission memory permission) public view withPermission(permission) returns (bool) {
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
338
342
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
type
|
|
1
|
+
type MockArtifact = {
|
|
2
2
|
contractName: string;
|
|
3
|
-
fixedAddress: string;
|
|
4
3
|
abi: any;
|
|
4
|
+
} & ({
|
|
5
|
+
isFixed: true;
|
|
6
|
+
fixedAddress: string;
|
|
5
7
|
deployedBytecode: string;
|
|
6
|
-
}
|
|
8
|
+
} | {
|
|
9
|
+
isFixed: false;
|
|
10
|
+
bytecode: string;
|
|
11
|
+
});
|
|
7
12
|
|
|
8
13
|
declare const MockTaskManagerArtifact: {
|
|
9
14
|
contractName: string;
|
|
15
|
+
isFixed: true;
|
|
10
16
|
fixedAddress: string;
|
|
11
17
|
abi: ({
|
|
12
18
|
type: string;
|
|
@@ -69,7 +75,7 @@ declare const MockTaskManagerArtifact: {
|
|
|
69
75
|
|
|
70
76
|
declare const MockACLArtifact: {
|
|
71
77
|
contractName: string;
|
|
72
|
-
|
|
78
|
+
isFixed: false;
|
|
73
79
|
abi: ({
|
|
74
80
|
type: string;
|
|
75
81
|
inputs: never[];
|
|
@@ -126,11 +132,12 @@ declare const MockACLArtifact: {
|
|
|
126
132
|
outputs?: undefined;
|
|
127
133
|
anonymous?: undefined;
|
|
128
134
|
})[];
|
|
129
|
-
|
|
135
|
+
bytecode: string;
|
|
130
136
|
};
|
|
131
137
|
|
|
132
138
|
declare const MockZkVerifierArtifact: {
|
|
133
139
|
contractName: string;
|
|
140
|
+
isFixed: true;
|
|
134
141
|
fixedAddress: string;
|
|
135
142
|
abi: ({
|
|
136
143
|
type: string;
|
|
@@ -177,6 +184,7 @@ declare const MockZkVerifierArtifact: {
|
|
|
177
184
|
|
|
178
185
|
declare const MockQueryDecrypterArtifact: {
|
|
179
186
|
contractName: string;
|
|
187
|
+
isFixed: true;
|
|
180
188
|
fixedAddress: string;
|
|
181
189
|
abi: ({
|
|
182
190
|
type: string;
|
|
@@ -214,6 +222,7 @@ declare const MockQueryDecrypterArtifact: {
|
|
|
214
222
|
|
|
215
223
|
declare const TestBedArtifact: {
|
|
216
224
|
contractName: string;
|
|
225
|
+
isFixed: true;
|
|
217
226
|
fixedAddress: string;
|
|
218
227
|
abi: ({
|
|
219
228
|
type: string;
|
|
@@ -258,4 +267,4 @@ declare const TestBedArtifact: {
|
|
|
258
267
|
deployedBytecode: string;
|
|
259
268
|
};
|
|
260
269
|
|
|
261
|
-
export { MockACLArtifact, MockQueryDecrypterArtifact, MockTaskManagerArtifact, MockZkVerifierArtifact,
|
|
270
|
+
export { MockACLArtifact, type MockArtifact, MockQueryDecrypterArtifact, MockTaskManagerArtifact, MockZkVerifierArtifact, TestBedArtifact };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
type
|
|
1
|
+
type MockArtifact = {
|
|
2
2
|
contractName: string;
|
|
3
|
-
fixedAddress: string;
|
|
4
3
|
abi: any;
|
|
4
|
+
} & ({
|
|
5
|
+
isFixed: true;
|
|
6
|
+
fixedAddress: string;
|
|
5
7
|
deployedBytecode: string;
|
|
6
|
-
}
|
|
8
|
+
} | {
|
|
9
|
+
isFixed: false;
|
|
10
|
+
bytecode: string;
|
|
11
|
+
});
|
|
7
12
|
|
|
8
13
|
declare const MockTaskManagerArtifact: {
|
|
9
14
|
contractName: string;
|
|
15
|
+
isFixed: true;
|
|
10
16
|
fixedAddress: string;
|
|
11
17
|
abi: ({
|
|
12
18
|
type: string;
|
|
@@ -69,7 +75,7 @@ declare const MockTaskManagerArtifact: {
|
|
|
69
75
|
|
|
70
76
|
declare const MockACLArtifact: {
|
|
71
77
|
contractName: string;
|
|
72
|
-
|
|
78
|
+
isFixed: false;
|
|
73
79
|
abi: ({
|
|
74
80
|
type: string;
|
|
75
81
|
inputs: never[];
|
|
@@ -126,11 +132,12 @@ declare const MockACLArtifact: {
|
|
|
126
132
|
outputs?: undefined;
|
|
127
133
|
anonymous?: undefined;
|
|
128
134
|
})[];
|
|
129
|
-
|
|
135
|
+
bytecode: string;
|
|
130
136
|
};
|
|
131
137
|
|
|
132
138
|
declare const MockZkVerifierArtifact: {
|
|
133
139
|
contractName: string;
|
|
140
|
+
isFixed: true;
|
|
134
141
|
fixedAddress: string;
|
|
135
142
|
abi: ({
|
|
136
143
|
type: string;
|
|
@@ -177,6 +184,7 @@ declare const MockZkVerifierArtifact: {
|
|
|
177
184
|
|
|
178
185
|
declare const MockQueryDecrypterArtifact: {
|
|
179
186
|
contractName: string;
|
|
187
|
+
isFixed: true;
|
|
180
188
|
fixedAddress: string;
|
|
181
189
|
abi: ({
|
|
182
190
|
type: string;
|
|
@@ -214,6 +222,7 @@ declare const MockQueryDecrypterArtifact: {
|
|
|
214
222
|
|
|
215
223
|
declare const TestBedArtifact: {
|
|
216
224
|
contractName: string;
|
|
225
|
+
isFixed: true;
|
|
217
226
|
fixedAddress: string;
|
|
218
227
|
abi: ({
|
|
219
228
|
type: string;
|
|
@@ -258,4 +267,4 @@ declare const TestBedArtifact: {
|
|
|
258
267
|
deployedBytecode: string;
|
|
259
268
|
};
|
|
260
269
|
|
|
261
|
-
export { MockACLArtifact, MockQueryDecrypterArtifact, MockTaskManagerArtifact, MockZkVerifierArtifact,
|
|
270
|
+
export { MockACLArtifact, type MockArtifact, MockQueryDecrypterArtifact, MockTaskManagerArtifact, MockZkVerifierArtifact, TestBedArtifact };
|