Skip to content

Commit 5bd0404

Browse files
authored
Merge pull request #100 from PracticalParticle/dev
Dev
2 parents 78e74b6 + 66a81b2 commit 5bd0404

17 files changed

Lines changed: 364 additions & 94 deletions

File tree

contracts/core/base/interface/IBaseStateMachine.sol

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,6 @@ interface IBaseStateMachine {
9797
*/
9898
function hasRole(bytes32 roleHash, address wallet) external view returns (bool);
9999

100-
/**
101-
* @dev Returns if an action is supported by a function
102-
* @param functionSelector The function selector to check
103-
* @param action The action to check
104-
* @return True if the action is supported by the function, false otherwise
105-
*/
106-
function isActionSupportedByFunction(bytes4 functionSelector, EngineBlox.TxAction action) external view returns (bool);
107-
108100
/**
109101
* @dev Gets function schema information
110102
* @param functionSelector The function selector to get information for

contracts/core/execution/interface/IGuardController.sol

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,67 +94,53 @@ interface IGuardController {
9494
/**
9595
* @dev Approves and executes a time-locked transaction
9696
* @param txId The transaction ID
97-
* @param expectedOperationType The expected operation type for validation
9897
* @return txId The transaction ID (use getTransaction(txId) for full record and result)
9998
* @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_APPROVE permission for the execution function
10099
*/
101100
function approveTimeLockExecution(
102-
uint256 txId,
103-
bytes32 expectedOperationType
101+
uint256 txId
104102
) external returns (uint256);
105103

106104
/**
107105
* @dev Cancels a time-locked transaction
108106
* @param txId The transaction ID
109-
* @param expectedOperationType The expected operation type for validation
110107
* @return txId The transaction ID (use getTransaction(txId) for full record)
111108
* @notice Requires STANDARD execution type and EXECUTE_TIME_DELAY_CANCEL permission for the execution function
112109
*/
113110
function cancelTimeLockExecution(
114-
uint256 txId,
115-
bytes32 expectedOperationType
111+
uint256 txId
116112
) external returns (uint256);
117113

118114
/**
119115
* @dev Approves a time-locked transaction using a meta-transaction
120116
* @param metaTx The meta-transaction containing the transaction record and signature
121-
* @param expectedOperationType The expected operation type for validation
122-
* @param requiredSelector The handler selector for validation
123117
* @return The transaction ID (use getTransaction(txId) for full record)
124118
* @notice Requires STANDARD execution type and EXECUTE_META_APPROVE permission for the execution function
125119
*/
126120
function approveTimeLockExecutionWithMetaTx(
127-
EngineBlox.MetaTransaction memory metaTx,
128-
bytes32 expectedOperationType,
129-
bytes4 requiredSelector
121+
EngineBlox.MetaTransaction memory metaTx
130122
) external returns (uint256);
131123

132124
/**
133125
* @dev Cancels a time-locked transaction using a meta-transaction
134126
* @param metaTx The meta-transaction containing the transaction record and signature
135-
* @param expectedOperationType The expected operation type for validation
136-
* @param requiredSelector The handler selector for validation
137127
* @return The transaction ID (use getTransaction(txId) for full record)
138128
* @notice Requires STANDARD execution type and EXECUTE_META_CANCEL permission for the execution function
139129
*/
140130
function cancelTimeLockExecutionWithMetaTx(
141-
EngineBlox.MetaTransaction memory metaTx,
142-
bytes32 expectedOperationType,
143-
bytes4 requiredSelector
131+
EngineBlox.MetaTransaction memory metaTx
144132
) external returns (uint256);
145133

146134
/**
147135
* @dev Requests and approves a transaction in one step using a meta-transaction
148136
* @param metaTx The meta-transaction containing the transaction record and signature
149-
* @param requiredSelector The handler selector for validation
150137
* @return The transaction ID (use getTransaction(txId) for full record)
151138
* @notice Requires STANDARD execution type
152139
* @notice Validates function schema and permissions for the execution function (same as executeWithTimeLock)
153140
* @notice Requires EXECUTE_META_REQUEST_AND_APPROVE permission for the execution function selector
154141
*/
155142
function requestAndApproveExecution(
156-
EngineBlox.MetaTransaction memory metaTx,
157-
bytes4 requiredSelector
143+
EngineBlox.MetaTransaction memory metaTx
158144
) external returns (uint256);
159145
}
160146

contracts/core/execution/lib/definitions/GuardControllerDefinitions.sol

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,27 @@ library GuardControllerDefinitions {
4747
// GuardController: cancelTimeLockExecution(uint256)
4848
bytes4 public constant CANCEL_TIMELOCK_EXECUTION_SELECTOR = bytes4(keccak256("cancelTimeLockExecution(uint256)"));
4949

50-
// GuardController: approveTimeLockExecutionWithMetaTx(...)
51-
bytes4 public constant APPROVE_TIMELOCK_EXECUTION_META_SELECTOR = bytes4(keccak256("approveTimeLockExecutionWithMetaTx((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"));
50+
51+
// GuardController: approveTimeLockExecutionWithMetaTx(EngineBlox.MetaTransaction)
52+
bytes4 public constant APPROVE_TIMELOCK_EXECUTION_META_SELECTOR = bytes4(
53+
keccak256(
54+
"approveTimeLockExecutionWithMetaTx(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"
55+
)
56+
);
5257

53-
// GuardController: cancelTimeLockExecutionWithMetaTx(...)
54-
bytes4 public constant CANCEL_TIMELOCK_EXECUTION_META_SELECTOR = bytes4(keccak256("cancelTimeLockExecutionWithMetaTx((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"));
58+
// GuardController: cancelTimeLockExecutionWithMetaTx(EngineBlox.MetaTransaction)
59+
bytes4 public constant CANCEL_TIMELOCK_EXECUTION_META_SELECTOR = bytes4(
60+
keccak256(
61+
"cancelTimeLockExecutionWithMetaTx(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"
62+
)
63+
);
5564

56-
// GuardController: requestAndApproveExecution(...)
57-
bytes4 public constant REQUEST_AND_APPROVE_EXECUTION_SELECTOR = bytes4(keccak256("requestAndApproveExecution((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"));
65+
// GuardController: requestAndApproveExecution(EngineBlox.MetaTransaction)
66+
bytes4 public constant REQUEST_AND_APPROVE_EXECUTION_SELECTOR = bytes4(
67+
keccak256(
68+
"requestAndApproveExecution(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))"
69+
)
70+
);
5871

5972
// GuardController: guardConfigBatchRequestAndApprove(...)
6073
bytes4 public constant GUARD_CONFIG_BATCH_META_SELECTOR = bytes4(
@@ -171,7 +184,7 @@ library GuardControllerDefinitions {
171184

172185
// Schema 3: GuardController.approveTimeLockExecutionWithMetaTx
173186
schemas[3] = EngineBlox.FunctionSchema({
174-
functionSignature: "approveTimeLockExecutionWithMetaTx((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
187+
functionSignature: "approveTimeLockExecutionWithMetaTx(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
175188
functionSelector: APPROVE_TIMELOCK_EXECUTION_META_SELECTOR,
176189
operationType: CONTROLLER_OPERATION,
177190
operationName: "CONTROLLER_OPERATION",
@@ -182,7 +195,7 @@ library GuardControllerDefinitions {
182195

183196
// Schema 4: GuardController.cancelTimeLockExecutionWithMetaTx
184197
schemas[4] = EngineBlox.FunctionSchema({
185-
functionSignature: "cancelTimeLockExecutionWithMetaTx((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
198+
functionSignature: "cancelTimeLockExecutionWithMetaTx(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
186199
functionSelector: CANCEL_TIMELOCK_EXECUTION_META_SELECTOR,
187200
operationType: CONTROLLER_OPERATION,
188201
operationName: "CONTROLLER_OPERATION",
@@ -193,7 +206,7 @@ library GuardControllerDefinitions {
193206

194207
// Schema 5: GuardController.requestAndApproveExecution
195208
schemas[5] = EngineBlox.FunctionSchema({
196-
functionSignature: "requestAndApproveExecution((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
209+
functionSignature: "requestAndApproveExecution(((uint256,uint256,uint8,(address,address,uint256,uint256,bytes32,bytes4,bytes),bytes32,bytes,(address,uint256,address,uint256)),(uint256,uint256,address,bytes4,uint8,uint256,uint256,address),bytes32,bytes,bytes))",
197210
functionSelector: REQUEST_AND_APPROVE_EXECUTION_SELECTOR,
198211
operationType: CONTROLLER_OPERATION,
199212
operationName: "CONTROLLER_OPERATION",

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Bloxchain",
3-
"version": "1.0.0-alpha.13",
3+
"version": "1.0.0-alpha.15",
44
"description": "Library engine for building enterprise grade decentralized permissioned applications",
55
"type": "module",
66
"main": "truffle-config.cjs",
@@ -45,8 +45,8 @@
4545
"build:sdk:clean": "cd sdk/typescript && npm run clean && npm run build",
4646
"generate:contracts-lock": "cd package && npm install --package-lock-only",
4747
"release:prepare": "node scripts/release-prepare.cjs",
48-
"publish:contracts": "npm run release:prepare && cd package && npm publish --tag alpha.13",
49-
"publish:sdk": "npm run release:sync-versions && npm run extract-abi && npm run build:sdk && cd sdk/typescript && npm publish --tag alpha.13",
48+
"publish:contracts": "npm run release:prepare && cd package && npm publish --tag alpha.15",
49+
"publish:sdk": "npm run release:sync-versions && npm run extract-abi && npm run build:sdk && cd sdk/typescript && npm publish --tag alpha.15",
5050
"docgen": "npm run compile:hardhat && cd docgen && npm run docgen",
5151
"docgen:install": "cd docgen && npm install",
5252
"format": "prettier --config .prettierrc --write \"contracts/**/*.sol\"",

package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bloxchain/contracts",
3-
"version": "1.0.0-alpha.13",
3+
"version": "1.0.0-alpha.14",
44
"description": "Library engine for building enterprise grade decentralized permissioned applications",
55
"files": [
66
"core",

scripts/sanity-sdk/base/BaseSDKTest.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface TestResults {
2525
totalTests: number;
2626
passedTests: number;
2727
failedTests: number;
28+
skippedTests: number;
2829
startTime: number | null;
2930
endTime: number | null;
3031
}
@@ -40,6 +41,7 @@ export abstract class BaseSDKTest {
4041
totalTests: 0,
4142
passedTests: 0,
4243
failedTests: 0,
44+
skippedTests: 0,
4345
startTime: null,
4446
endTime: null,
4547
};
@@ -287,6 +289,19 @@ export abstract class BaseSDKTest {
287289
}
288290
}
289291

292+
/**
293+
* Record a skipped test (e.g. environment-specific limitation).
294+
* Does not increment passedTests; reported separately in summary.
295+
*/
296+
protected skipTest(message: string, details?: string): void {
297+
this.testResults.totalTests++;
298+
this.testResults.skippedTests++;
299+
console.log(` ⏭️ ${message}`);
300+
if (details) {
301+
console.log(` ${details}`);
302+
}
303+
}
304+
290305
/**
291306
* Assert transaction success
292307
*/
@@ -362,9 +377,10 @@ export abstract class BaseSDKTest {
362377
this.testResults.startTime && this.testResults.endTime
363378
? this.testResults.endTime - this.testResults.startTime
364379
: 0;
380+
const runTests = this.testResults.totalTests - this.testResults.skippedTests;
365381
const successRate =
366-
this.testResults.totalTests > 0
367-
? ((this.testResults.passedTests / this.testResults.totalTests) * 100).toFixed(2)
382+
runTests > 0
383+
? ((this.testResults.passedTests / runTests) * 100).toFixed(2)
368384
: '0.00';
369385

370386
console.log('\n' + '='.repeat(60));
@@ -373,7 +389,8 @@ export abstract class BaseSDKTest {
373389
console.log(`📋 Total Tests: ${this.testResults.totalTests}`);
374390
console.log(`✅ Passed: ${this.testResults.passedTests}`);
375391
console.log(`❌ Failed: ${this.testResults.failedTests}`);
376-
console.log(`📈 Success Rate: ${successRate}%`);
392+
console.log(`⏭️ Skipped: ${this.testResults.skippedTests}`);
393+
console.log(`📈 Success Rate: ${successRate}% (of ${runTests} run)`);
377394
console.log(`⏱️ Duration: ${(duration / 1000).toFixed(2)} seconds`);
378395
console.log('='.repeat(60));
379396

scripts/sanity-sdk/guard-controller/base-test.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,23 @@ export abstract class BaseGuardControllerTest extends BaseSDKTest {
702702
protected async schemaOrSupportedSetPreCheck(selector: Hex): Promise<boolean> {
703703
if (!this.guardController) return false;
704704
const norm = (s: string | Hex) => String(s).toLowerCase();
705+
706+
// Prefer an owner-scoped client for reads in case the contract now
707+
// enforces _validateAnyRole() or similar on view functions.
708+
let client: GuardController;
709+
try {
710+
const ownerWallet = this.getRoleWallet('owner');
711+
const ownerWalletName =
712+
Object.keys(this.wallets).find(
713+
(k) => this.wallets[k].address.toLowerCase() === ownerWallet.address.toLowerCase()
714+
) ?? 'wallet1';
715+
client = this.createGuardControllerWithWallet(ownerWalletName);
716+
} catch {
717+
// Fallback to the default client if role discovery or mapping fails.
718+
client = this.guardController;
719+
}
705720
try {
706-
const schema = await this.guardController.getFunctionSchema(selector);
721+
const schema = await client.getFunctionSchema(selector);
707722
const returnedSelector =
708723
(schema as any)?.functionSelector ?? (schema as any)?.functionSelectorReturn ?? (schema as any)?.[1];
709724
if (returnedSelector != null && norm(returnedSelector) === norm(selector)) {
@@ -714,7 +729,7 @@ export abstract class BaseGuardControllerTest extends BaseSDKTest {
714729
// ResourceNotFound or any revert => schema not present
715730
}
716731
try {
717-
const list = await this.guardController.getSupportedFunctions();
732+
const list = await client.getSupportedFunctions();
718733
if (Array.isArray(list) && list.some((f: Hex) => norm(f) === norm(selector))) {
719734
console.log(` 📋 getSupportedFunctions: selector ${selector} in supported set`);
720735
return true;

0 commit comments

Comments
 (0)