@bloxchain/sdk 1.0.0-alpha

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.
Files changed (132) hide show
  1. package/README.md +338 -0
  2. package/abi/BareBlox.abi.json +1341 -0
  3. package/abi/BaseStateMachine.abi.json +1308 -0
  4. package/abi/ControlBlox.abi.json +6210 -0
  5. package/abi/EngineBlox.abi.json +872 -0
  6. package/abi/GuardController.abi.json +3045 -0
  7. package/abi/IDefinition.abi.json +94 -0
  8. package/abi/RoleBlox.abi.json +4569 -0
  9. package/abi/RuntimeRBAC.abi.json +1857 -0
  10. package/abi/RuntimeRBACDefinitions.abi.json +133 -0
  11. package/abi/SecureBlox.abi.json +4085 -0
  12. package/abi/SecureOwnable.abi.json +4085 -0
  13. package/abi/SecureOwnableDefinitions.abi.json +354 -0
  14. package/abi/SimpleRWA20.abi.json +5545 -0
  15. package/abi/SimpleRWA20Definitions.abi.json +172 -0
  16. package/abi/SimpleVault.abi.json +5208 -0
  17. package/abi/SimpleVaultDefinitions.abi.json +250 -0
  18. package/dist/abi/BaseStateMachine.abi.json +1308 -0
  19. package/dist/abi/GuardController.abi.json +3045 -0
  20. package/dist/abi/IDefinition.abi.json +94 -0
  21. package/dist/abi/RuntimeRBAC.abi.json +1857 -0
  22. package/dist/abi/SecureOwnable.abi.json +4085 -0
  23. package/dist/contracts/BaseStateMachine.d.ts +83 -0
  24. package/dist/contracts/BaseStateMachine.d.ts.map +1 -0
  25. package/dist/contracts/BaseStateMachine.js +251 -0
  26. package/dist/contracts/BaseStateMachine.js.map +1 -0
  27. package/dist/contracts/GuardController.d.ts +120 -0
  28. package/dist/contracts/GuardController.d.ts.map +1 -0
  29. package/dist/contracts/GuardController.js +149 -0
  30. package/dist/contracts/GuardController.js.map +1 -0
  31. package/dist/contracts/RuntimeRBAC.d.ts +56 -0
  32. package/dist/contracts/RuntimeRBAC.d.ts.map +1 -0
  33. package/dist/contracts/RuntimeRBAC.js +57 -0
  34. package/dist/contracts/RuntimeRBAC.js.map +1 -0
  35. package/dist/contracts/SecureOwnable.d.ts +41 -0
  36. package/dist/contracts/SecureOwnable.d.ts.map +1 -0
  37. package/dist/contracts/SecureOwnable.js +82 -0
  38. package/dist/contracts/SecureOwnable.js.map +1 -0
  39. package/dist/index.d.ts +30 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +32 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/interfaces/base.index.d.ts +18 -0
  44. package/dist/interfaces/base.index.d.ts.map +1 -0
  45. package/dist/interfaces/base.index.js +2 -0
  46. package/dist/interfaces/base.index.js.map +1 -0
  47. package/dist/interfaces/base.state.machine.index.d.ts +72 -0
  48. package/dist/interfaces/base.state.machine.index.d.ts.map +1 -0
  49. package/dist/interfaces/base.state.machine.index.js +2 -0
  50. package/dist/interfaces/base.state.machine.index.js.map +1 -0
  51. package/dist/interfaces/core.access.index.d.ts +37 -0
  52. package/dist/interfaces/core.access.index.d.ts.map +1 -0
  53. package/dist/interfaces/core.access.index.js +2 -0
  54. package/dist/interfaces/core.access.index.js.map +1 -0
  55. package/dist/interfaces/core.execution.index.d.ts +44 -0
  56. package/dist/interfaces/core.execution.index.d.ts.map +1 -0
  57. package/dist/interfaces/core.execution.index.js +2 -0
  58. package/dist/interfaces/core.execution.index.js.map +1 -0
  59. package/dist/interfaces/core.security.index.d.ts +83 -0
  60. package/dist/interfaces/core.security.index.d.ts.map +1 -0
  61. package/dist/interfaces/core.security.index.js +2 -0
  62. package/dist/interfaces/core.security.index.js.map +1 -0
  63. package/dist/interfaces/definition.index.d.ts +38 -0
  64. package/dist/interfaces/definition.index.d.ts.map +1 -0
  65. package/dist/interfaces/definition.index.js +2 -0
  66. package/dist/interfaces/definition.index.js.map +1 -0
  67. package/dist/interfaces/lib.index.d.ts +83 -0
  68. package/dist/interfaces/lib.index.d.ts.map +1 -0
  69. package/dist/interfaces/lib.index.js +2 -0
  70. package/dist/interfaces/lib.index.js.map +1 -0
  71. package/dist/lib/Definition.d.ts +84 -0
  72. package/dist/lib/Definition.d.ts.map +1 -0
  73. package/dist/lib/Definition.js +159 -0
  74. package/dist/lib/Definition.js.map +1 -0
  75. package/dist/lib/EngineBlox.d.ts +167 -0
  76. package/dist/lib/EngineBlox.d.ts.map +1 -0
  77. package/dist/lib/EngineBlox.js +266 -0
  78. package/dist/lib/EngineBlox.js.map +1 -0
  79. package/dist/types/base.state.machine.index.d.ts +45 -0
  80. package/dist/types/base.state.machine.index.d.ts.map +1 -0
  81. package/dist/types/base.state.machine.index.js +49 -0
  82. package/dist/types/base.state.machine.index.js.map +1 -0
  83. package/dist/types/core.access.index.d.ts +51 -0
  84. package/dist/types/core.access.index.d.ts.map +1 -0
  85. package/dist/types/core.access.index.js +41 -0
  86. package/dist/types/core.access.index.js.map +1 -0
  87. package/dist/types/core.execution.index.d.ts +36 -0
  88. package/dist/types/core.execution.index.d.ts.map +1 -0
  89. package/dist/types/core.execution.index.js +30 -0
  90. package/dist/types/core.execution.index.js.map +1 -0
  91. package/dist/types/core.security.index.d.ts +36 -0
  92. package/dist/types/core.security.index.d.ts.map +1 -0
  93. package/dist/types/core.security.index.js +37 -0
  94. package/dist/types/core.security.index.js.map +1 -0
  95. package/dist/types/definition.index.d.ts +36 -0
  96. package/dist/types/definition.index.d.ts.map +1 -0
  97. package/dist/types/definition.index.js +4 -0
  98. package/dist/types/definition.index.js.map +1 -0
  99. package/dist/types/lib.index.d.ts +66 -0
  100. package/dist/types/lib.index.d.ts.map +1 -0
  101. package/dist/types/lib.index.js +68 -0
  102. package/dist/types/lib.index.js.map +1 -0
  103. package/dist/utils/bitmap.d.ts +75 -0
  104. package/dist/utils/bitmap.d.ts.map +1 -0
  105. package/dist/utils/bitmap.js +124 -0
  106. package/dist/utils/bitmap.js.map +1 -0
  107. package/dist/utils/contract-errors.d.ts +536 -0
  108. package/dist/utils/contract-errors.d.ts.map +1 -0
  109. package/dist/utils/contract-errors.js +412 -0
  110. package/dist/utils/contract-errors.js.map +1 -0
  111. package/dist/utils/erc20/ERC20Token.abi.json +217 -0
  112. package/dist/utils/erc20/erc20Token.d.ts +83 -0
  113. package/dist/utils/erc20/erc20Token.d.ts.map +1 -0
  114. package/dist/utils/erc20/erc20Token.js +173 -0
  115. package/dist/utils/erc20/erc20Token.js.map +1 -0
  116. package/dist/utils/interface-ids.d.ts +59 -0
  117. package/dist/utils/interface-ids.d.ts.map +1 -0
  118. package/dist/utils/interface-ids.js +149 -0
  119. package/dist/utils/interface-ids.js.map +1 -0
  120. package/dist/utils/metaTx/metaTransaction.d.ts +138 -0
  121. package/dist/utils/metaTx/metaTransaction.d.ts.map +1 -0
  122. package/dist/utils/metaTx/metaTransaction.js +271 -0
  123. package/dist/utils/metaTx/metaTransaction.js.map +1 -0
  124. package/dist/utils/validations.d.ts +104 -0
  125. package/dist/utils/validations.d.ts.map +1 -0
  126. package/dist/utils/validations.js +254 -0
  127. package/dist/utils/validations.js.map +1 -0
  128. package/dist/utils/viem-error-handler.d.ts +48 -0
  129. package/dist/utils/viem-error-handler.d.ts.map +1 -0
  130. package/dist/utils/viem-error-handler.js +172 -0
  131. package/dist/utils/viem-error-handler.js.map +1 -0
  132. package/package.json +65 -0
@@ -0,0 +1,83 @@
1
+ import { Address, Hex } from 'viem';
2
+ import { TransactionResult, TransactionOptions } from './base.index';
3
+ import { TxRecord, MetaTransaction, MetaTxParams } from './lib.index';
4
+ import { TxAction } from '../types/lib.index';
5
+ /**
6
+ * Interface for SecureOwnable contract events
7
+ */
8
+ export interface OwnershipTransferRequestEvent {
9
+ currentOwner: Address;
10
+ newOwner: Address;
11
+ }
12
+ export interface OwnershipTransferCancelledEvent {
13
+ txId: bigint;
14
+ }
15
+ export interface OwnershipTransferUpdatedEvent {
16
+ oldOwner: Address;
17
+ newOwner: Address;
18
+ }
19
+ export interface BroadcasterUpdateRequestEvent {
20
+ currentBroadcaster: Address;
21
+ newBroadcaster: Address;
22
+ }
23
+ export interface BroadcasterUpdateCancelledEvent {
24
+ txId: bigint;
25
+ }
26
+ export interface BroadcasterUpdatedEvent {
27
+ oldBroadcaster: Address;
28
+ newBroadcaster: Address;
29
+ }
30
+ export interface RecoveryAddressUpdatedEvent {
31
+ oldRecovery: Address;
32
+ newRecovery: Address;
33
+ }
34
+ export interface TimeLockPeriodUpdatedEvent {
35
+ oldPeriod: bigint;
36
+ newPeriod: bigint;
37
+ }
38
+ /**
39
+ * Interface for SecureOwnable contract state
40
+ */
41
+ export interface SecureOwnableState {
42
+ owner: Address;
43
+ broadcaster: Address;
44
+ recoveryAddress: Address;
45
+ timeLockPeriodSec: bigint;
46
+ operationHistory: Map<bigint, TxRecord>;
47
+ }
48
+ /**
49
+ * Interface for SecureOwnable contract methods
50
+ */
51
+ export interface ISecureOwnable {
52
+ transferOwnershipRequest(options: TransactionOptions): Promise<TransactionResult>;
53
+ transferOwnershipDelayedApproval(txId: bigint, options: TransactionOptions): Promise<TransactionResult>;
54
+ transferOwnershipApprovalWithMetaTx(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
55
+ transferOwnershipCancellation(txId: bigint, options: TransactionOptions): Promise<TransactionResult>;
56
+ transferOwnershipCancellationWithMetaTx(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
57
+ updateBroadcasterRequest(newBroadcaster: Address, options: TransactionOptions): Promise<TransactionResult>;
58
+ updateBroadcasterDelayedApproval(txId: bigint, options: TransactionOptions): Promise<TransactionResult>;
59
+ updateBroadcasterApprovalWithMetaTx(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
60
+ updateBroadcasterCancellation(txId: bigint, options: TransactionOptions): Promise<TransactionResult>;
61
+ updateBroadcasterCancellationWithMetaTx(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
62
+ updateRecoveryExecutionOptions(newRecoveryAddress: Address): Promise<Hex>;
63
+ updateRecoveryRequestAndApprove(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
64
+ updateTimeLockExecutionOptions(newTimeLockPeriodSec: bigint): Promise<Hex>;
65
+ updateTimeLockRequestAndApprove(metaTx: MetaTransaction, options: TransactionOptions): Promise<TransactionResult>;
66
+ createMetaTxParams(handlerContract: Address, handlerSelector: Hex, action: TxAction, deadline: bigint, maxGasPrice: bigint, signer: Address): Promise<MetaTxParams>;
67
+ generateUnsignedMetaTransactionForNew(requester: Address, target: Address, value: bigint, gasLimit: bigint, operationType: Hex, executionSelector: Hex, executionParams: Hex, metaTxParams: MetaTxParams): Promise<MetaTransaction>;
68
+ generateUnsignedMetaTransactionForExisting(txId: bigint, metaTxParams: MetaTxParams): Promise<MetaTransaction>;
69
+ getTransactionHistory(fromTxId: bigint, toTxId: bigint): Promise<TxRecord[]>;
70
+ getTransaction(txId: bigint): Promise<TxRecord>;
71
+ getPendingTransactions(): Promise<bigint[]>;
72
+ getTimeLockPeriodSec(): Promise<bigint>;
73
+ getSupportedOperationTypes(): Promise<Hex[]>;
74
+ getSupportedRoles(): Promise<Hex[]>;
75
+ getSupportedFunctions(): Promise<Hex[]>;
76
+ hasRole(roleHash: Hex, wallet: Address): Promise<boolean>;
77
+ isActionSupportedByFunction(functionSelector: Hex, action: TxAction): Promise<boolean>;
78
+ getSignerNonce(signer: Address): Promise<bigint>;
79
+ getActiveRolePermissions(roleHash: Hex): Promise<any[]>;
80
+ initialized(): Promise<boolean>;
81
+ supportsInterface(interfaceId: Hex): Promise<boolean>;
82
+ }
83
+ //# sourceMappingURL=core.security.index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.security.index.d.ts","sourceRoot":"","sources":["../../interfaces/core.security.index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACtE,OA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AE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACxD,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAGhC,iBAAiB,CAAC,WAAW,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=core.security.index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.security.index.js","sourceRoot":"","sources":["../../interfaces/core.security.index.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import { Address, Hex } from 'viem';
2
+ import { FunctionSchema, RolePermission } from '../types/definition.index';
3
+ /**
4
+ * TypeScript interface for IDefinition
5
+ * This interface allows interaction with any definition library that implements IDefinition.sol
6
+ *
7
+ * Note: IDefinition only provides getFunctionSchemas() and getRolePermissions()
8
+ * Operation types must be derived from function schemas or queried from BaseStateMachine
9
+ */
10
+ export interface IDefinition {
11
+ /**
12
+ * Returns all function schema definitions
13
+ * @returns Array of function schema definitions
14
+ */
15
+ getFunctionSchemas(): Promise<FunctionSchema[]>;
16
+ /**
17
+ * Returns all role hashes and their corresponding function permissions
18
+ * @returns RolePermission struct containing roleHashes and functionPermissions arrays
19
+ */
20
+ getRolePermissions(): Promise<RolePermission>;
21
+ }
22
+ /**
23
+ * Configuration options for Definitions client
24
+ */
25
+ export interface DefinitionsConfig {
26
+ contractAddress: Address;
27
+ chainId: number;
28
+ rpcUrl?: string;
29
+ }
30
+ /**
31
+ * Result of contract method calls
32
+ */
33
+ export interface ContractResult<T> {
34
+ data: T;
35
+ blockNumber: bigint;
36
+ transactionHash: Hex;
37
+ }
38
+ //# sourceMappingURL=definition.index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.index.d.ts","sourceRoot":"","sources":["../../interfaces/definition.index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EACL,cAAc,EACd,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,kBAAkB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAEhD;;;OAGG;IACH,kBAAkB,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC;IACR,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,GAAG,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definition.index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.index.js","sourceRoot":"","sources":["../../interfaces/definition.index.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
1
+ import { Address, Hex } from 'viem';
2
+ import { TxStatus, TxAction } from '../types/lib.index';
3
+ /**
4
+ * Payment and transaction related interfaces
5
+ */
6
+ export interface PaymentDetails {
7
+ recipient: Address;
8
+ nativeTokenAmount: bigint;
9
+ erc20TokenAddress: Address;
10
+ erc20TokenAmount: bigint;
11
+ }
12
+ export interface TxParams {
13
+ requester: Address;
14
+ target: Address;
15
+ value: bigint;
16
+ gasLimit: bigint;
17
+ operationType: Hex;
18
+ executionSelector: Hex;
19
+ executionParams: Hex;
20
+ }
21
+ export interface MetaTxParams {
22
+ chainId: bigint;
23
+ nonce: bigint;
24
+ handlerContract: Address;
25
+ handlerSelector: Hex;
26
+ action: TxAction;
27
+ deadline: bigint;
28
+ maxGasPrice: bigint;
29
+ signer: Address;
30
+ }
31
+ export interface TxRecord {
32
+ txId: bigint;
33
+ releaseTime: bigint;
34
+ status: TxStatus;
35
+ params: TxParams;
36
+ message: Hex;
37
+ result: Hex;
38
+ payment: PaymentDetails;
39
+ }
40
+ export interface MetaTransaction {
41
+ txRecord: TxRecord;
42
+ params: MetaTxParams;
43
+ message: Hex;
44
+ signature: Hex;
45
+ data: Hex;
46
+ }
47
+ /**
48
+ * State management interfaces
49
+ */
50
+ export interface SecureOperationState {
51
+ txRecords: Map<bigint, TxRecord>;
52
+ roles: Map<Hex, Address>;
53
+ authorizedSigners: Map<Address, boolean>;
54
+ allowedRolesForFunction: Map<Hex, Hex[]>;
55
+ supportedOperationTypes: Map<Hex, boolean>;
56
+ operationTypeNames: Map<Hex, string>;
57
+ txCounter: bigint;
58
+ metaTxNonce: bigint;
59
+ timeLockPeriodSec: bigint;
60
+ supportedOperationTypesList: Hex[];
61
+ }
62
+ /**
63
+ * Event interfaces
64
+ */
65
+ export interface RequestedTxEvent {
66
+ txId: bigint;
67
+ releaseTime: bigint;
68
+ target: Address;
69
+ executionSelector: Hex;
70
+ executionParams: Hex;
71
+ }
72
+ export interface TxApprovedEvent {
73
+ txId: bigint;
74
+ }
75
+ export interface TxCancelledEvent {
76
+ txId: bigint;
77
+ }
78
+ export interface TxExecutedEvent {
79
+ txId: bigint;
80
+ success: boolean;
81
+ result: string;
82
+ }
83
+ //# sourceMappingURL=lib.index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.index.d.ts","sourceRoot":"","sources":["../../interfaces/lib.index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AA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AAuB,EAAE,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3C,kBAAkB,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,2BAA2B,EAAE,GAAG,EAAE,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,EAAE,GAAG,CAAC;IACvB,eAAe,EAAE,GAAG,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=lib.index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.index.js","sourceRoot":"","sources":["../../interfaces/lib.index.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,84 @@
1
+ import { PublicClient, WalletClient, Address, Chain, Hex } from 'viem';
2
+ import { IDefinition, DefinitionsConfig } from '../interfaces/definition.index';
3
+ import { FunctionSchema, RolePermission } from '../types/definition.index';
4
+ /**
5
+ * Definitions class for interacting with any definition library
6
+ * that implements the IDefinition interface
7
+ *
8
+ * This class provides type-safe access to contract definitions including:
9
+ * - Operation types and their configurations
10
+ * - Function schemas and permissions
11
+ * - Role-based access control definitions
12
+ *
13
+ * Note: Workflow-related functionality has been moved to the separate Workflow class
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const definitions = new Definitions(
18
+ * publicClient,
19
+ * walletClient,
20
+ * '0x1234...',
21
+ * chain
22
+ * );
23
+ *
24
+ * // Get function schemas
25
+ * const schemas = await definitions.getFunctionSchemas();
26
+ * ```
27
+ */
28
+ export declare class Definitions implements IDefinition {
29
+ protected client: PublicClient;
30
+ protected walletClient: WalletClient | undefined;
31
+ protected contractAddress: Address;
32
+ protected chain: Chain;
33
+ protected config: DefinitionsConfig;
34
+ constructor(client: PublicClient, walletClient: WalletClient | undefined, contractAddress: Address, chain: Chain, config?: Partial<DefinitionsConfig>);
35
+ /**
36
+ * Returns all function schema definitions
37
+ * @returns Array of function schema definitions
38
+ */
39
+ getFunctionSchemas(): Promise<FunctionSchema[]>;
40
+ /**
41
+ * Returns all role hashes and their corresponding function permissions
42
+ * @returns RolePermission struct containing roleHashes and functionPermissions arrays
43
+ */
44
+ getRolePermissions(): Promise<RolePermission>;
45
+ /**
46
+ * Utility method to get operation type by name from function schemas
47
+ * @param operationName The name of the operation to find
48
+ * @returns The operation type hash if found, undefined otherwise
49
+ */
50
+ getOperationTypeByName(operationName: string): Promise<Hex | undefined>;
51
+ /**
52
+ * Utility method to get function schema by selector
53
+ * @param functionSelector The function selector to find
54
+ * @returns The function schema if found, undefined otherwise
55
+ */
56
+ getFunctionSchemaBySelector(functionSelector: Hex): Promise<FunctionSchema | undefined>;
57
+ /**
58
+ * Utility method to check if a role has permission for a function
59
+ * Note: This checks if the role is in the roleHashes array at the same index
60
+ * as the functionPermission that matches the functionSelector
61
+ * @param roleHash The role hash to check
62
+ * @param functionSelector The function selector to check permission for
63
+ * @returns True if the role has permission, false otherwise
64
+ */
65
+ hasRolePermission(roleHash: Hex, functionSelector: Hex): Promise<boolean>;
66
+ /**
67
+ * Utility method to get all roles that can execute a specific function
68
+ * Note: Returns roles from roleHashes array where corresponding functionPermission matches
69
+ * @param functionSelector The function selector to check
70
+ * @returns Array of role hashes that can execute the function
71
+ */
72
+ getRolesForFunction(functionSelector: Hex): Promise<Hex[]>;
73
+ /**
74
+ * Get contract configuration
75
+ * @returns The current contract configuration
76
+ */
77
+ getConfig(): DefinitionsConfig;
78
+ /**
79
+ * Update contract configuration
80
+ * @param config Partial configuration to update
81
+ */
82
+ updateConfig(config: Partial<DefinitionsConfig>): void;
83
+ }
84
+ //# sourceMappingURL=Definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Definition.d.ts","sourceRoot":"","sources":["../../lib/Definition.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACvE,OAAO,EACL,WAAW,EACX,iBAAiB,EAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,cAAc,EACd,cAAc,EAEf,MAAM,2BAA2B,CAAC;AAOnC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,WAAY,YAAW,WAAW;IAC7C,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC;IAC/B,SAAS,CAAC,YAAY,EAAE,YAAY,GAAG,SAAS,CAAC;IACjD,SAAS,CAAC,eAAe,EAAE,OAAO,CAAC;IACnC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;IACvB,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBAGlC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,eAAe,EAAE,OAAO,EACxB,KAAK,EAAE,KAAK,EACZ,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAarC;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAsBrD;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,cAAc,CAAC;IAqBnD;;;;OAIG;IACG,sBAAsB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;IAM7E;;;;OAIG;IACG,2BAA2B,CAAC,gBAAgB,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAK7F;;;;;;;OAOG;IACG,iBAAiB,CAAC,QAAQ,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAc/E;;;;;OAKG;IACG,mBAAmB,CAAC,gBAAgB,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAchE;;;OAGG;IACH,SAAS,IAAI,iBAAiB;IAI9B;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI;CAGvD"}
@@ -0,0 +1,159 @@
1
+ import { fromContractValue } from '../utils/bitmap';
2
+ // Import the ABI
3
+ import IDefinitionABI from '../abi/IDefinition.abi.json';
4
+ /**
5
+ * Definitions class for interacting with any definition library
6
+ * that implements the IDefinition interface
7
+ *
8
+ * This class provides type-safe access to contract definitions including:
9
+ * - Operation types and their configurations
10
+ * - Function schemas and permissions
11
+ * - Role-based access control definitions
12
+ *
13
+ * Note: Workflow-related functionality has been moved to the separate Workflow class
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const definitions = new Definitions(
18
+ * publicClient,
19
+ * walletClient,
20
+ * '0x1234...',
21
+ * chain
22
+ * );
23
+ *
24
+ * // Get function schemas
25
+ * const schemas = await definitions.getFunctionSchemas();
26
+ * ```
27
+ */
28
+ export class Definitions {
29
+ constructor(client, walletClient, contractAddress, chain, config) {
30
+ this.client = client;
31
+ this.walletClient = walletClient;
32
+ this.contractAddress = contractAddress;
33
+ this.chain = chain;
34
+ this.config = {
35
+ contractAddress,
36
+ chainId: chain.id,
37
+ ...config
38
+ };
39
+ }
40
+ /**
41
+ * Returns all function schema definitions
42
+ * @returns Array of function schema definitions
43
+ */
44
+ async getFunctionSchemas() {
45
+ try {
46
+ const result = await this.client.readContract({
47
+ address: this.contractAddress,
48
+ abi: IDefinitionABI,
49
+ functionName: 'getFunctionSchemas'
50
+ });
51
+ return result.map((item) => ({
52
+ functionSignature: item.functionSignature,
53
+ functionSelector: item.functionSelector,
54
+ operationType: item.operationType,
55
+ operationName: item.operationName,
56
+ supportedActionsBitmap: fromContractValue(item.supportedActionsBitmap), // uint16
57
+ isProtected: item.isProtected,
58
+ handlerForSelectors: item.handlerForSelectors.map((selector) => selector)
59
+ }));
60
+ }
61
+ catch (error) {
62
+ throw new Error(`Failed to get function schemas: ${error instanceof Error ? error.message : 'Unknown error'}`);
63
+ }
64
+ }
65
+ /**
66
+ * Returns all role hashes and their corresponding function permissions
67
+ * @returns RolePermission struct containing roleHashes and functionPermissions arrays
68
+ */
69
+ async getRolePermissions() {
70
+ try {
71
+ const result = await this.client.readContract({
72
+ address: this.contractAddress,
73
+ abi: IDefinitionABI,
74
+ functionName: 'getRolePermissions'
75
+ });
76
+ return {
77
+ roleHashes: result.roleHashes.map((hash) => hash),
78
+ functionPermissions: result.functionPermissions.map((perm) => ({
79
+ functionSelector: perm.functionSelector,
80
+ grantedActionsBitmap: fromContractValue(perm.grantedActionsBitmap), // uint16
81
+ handlerForSelectors: perm.handlerForSelectors.map((selector) => selector)
82
+ }))
83
+ };
84
+ }
85
+ catch (error) {
86
+ throw new Error(`Failed to get role permissions: ${error instanceof Error ? error.message : 'Unknown error'}`);
87
+ }
88
+ }
89
+ /**
90
+ * Utility method to get operation type by name from function schemas
91
+ * @param operationName The name of the operation to find
92
+ * @returns The operation type hash if found, undefined otherwise
93
+ */
94
+ async getOperationTypeByName(operationName) {
95
+ const schemas = await this.getFunctionSchemas();
96
+ const schema = schemas.find(s => s.operationName === operationName);
97
+ return schema?.operationType;
98
+ }
99
+ /**
100
+ * Utility method to get function schema by selector
101
+ * @param functionSelector The function selector to find
102
+ * @returns The function schema if found, undefined otherwise
103
+ */
104
+ async getFunctionSchemaBySelector(functionSelector) {
105
+ const schemas = await this.getFunctionSchemas();
106
+ return schemas.find(schema => schema.functionSelector === functionSelector);
107
+ }
108
+ /**
109
+ * Utility method to check if a role has permission for a function
110
+ * Note: This checks if the role is in the roleHashes array at the same index
111
+ * as the functionPermission that matches the functionSelector
112
+ * @param roleHash The role hash to check
113
+ * @param functionSelector The function selector to check permission for
114
+ * @returns True if the role has permission, false otherwise
115
+ */
116
+ async hasRolePermission(roleHash, functionSelector) {
117
+ const rolePermissions = await this.getRolePermissions();
118
+ // RolePermissions uses parallel arrays: roleHashes[i] corresponds to functionPermissions[i]
119
+ for (let i = 0; i < rolePermissions.roleHashes.length && i < rolePermissions.functionPermissions.length; i++) {
120
+ if (rolePermissions.roleHashes[i] === roleHash &&
121
+ rolePermissions.functionPermissions[i].functionSelector === functionSelector) {
122
+ return true;
123
+ }
124
+ }
125
+ return false;
126
+ }
127
+ /**
128
+ * Utility method to get all roles that can execute a specific function
129
+ * Note: Returns roles from roleHashes array where corresponding functionPermission matches
130
+ * @param functionSelector The function selector to check
131
+ * @returns Array of role hashes that can execute the function
132
+ */
133
+ async getRolesForFunction(functionSelector) {
134
+ const rolePermissions = await this.getRolePermissions();
135
+ const roles = [];
136
+ // RolePermissions uses parallel arrays: roleHashes[i] corresponds to functionPermissions[i]
137
+ for (let i = 0; i < rolePermissions.roleHashes.length && i < rolePermissions.functionPermissions.length; i++) {
138
+ if (rolePermissions.functionPermissions[i].functionSelector === functionSelector) {
139
+ roles.push(rolePermissions.roleHashes[i]);
140
+ }
141
+ }
142
+ return roles;
143
+ }
144
+ /**
145
+ * Get contract configuration
146
+ * @returns The current contract configuration
147
+ */
148
+ getConfig() {
149
+ return { ...this.config };
150
+ }
151
+ /**
152
+ * Update contract configuration
153
+ * @param config Partial configuration to update
154
+ */
155
+ updateConfig(config) {
156
+ this.config = { ...this.config, ...config };
157
+ }
158
+ }
159
+ //# sourceMappingURL=Definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Definition.js","sourceRoot":"","sources":["../../lib/Definition.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,iBA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AAC,CAAC,CAAC,CAAC,gBAAgB,KAAK,gBAAgB,EAAE,CAAC;gBACjF,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,MAAkC;QAC7C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9C,CAAC;CACF"}
@@ -0,0 +1,167 @@
1
+ import { Address, Hex, PublicClient } from 'viem';
2
+ import { TxAction } from '../types/lib.index';
3
+ import { Uint16Bitmap } from '../utils/bitmap';
4
+ /**
5
+ * @title EngineBlox Library SDK
6
+ * @dev Provides access to public library constants and pure functions from EngineBlox.sol
7
+ *
8
+ * This module exposes all accessible constants and pure/view functions from the EngineBlox library
9
+ * that don't require storage access (no `self` parameter). Functions meant for delegatecall
10
+ * (those using `self`) are excluded.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { EngineBlox } from '@bloxchain/sdk/lib/EngineBlox';
15
+ *
16
+ * // Access constants
17
+ * const protocolName = EngineBlox.PROTOCOL_NAME_HASH;
18
+ * const version = `${EngineBlox.VERSION_MAJOR}.${EngineBlox.VERSION_MINOR}.${EngineBlox.VERSION_PATCH}`;
19
+ *
20
+ * // Use pure functions
21
+ * const signer = EngineBlox.recoverSigner(messageHash, signature);
22
+ *
23
+ * // Use bitmap helpers
24
+ * const hasAction = EngineBlox.hasActionInBitmap(bitmap, TxAction.EXECUTE_TIME_DELAY_REQUEST);
25
+ * ```
26
+ */
27
+ export declare class EngineBlox {
28
+ /**
29
+ * Protocol name hash (keccak256("Bloxchain"))
30
+ */
31
+ static readonly PROTOCOL_NAME_HASH: Hex;
32
+ /**
33
+ * Major version number
34
+ */
35
+ static readonly VERSION_MAJOR: number;
36
+ /**
37
+ * Minor version number
38
+ */
39
+ static readonly VERSION_MINOR: number;
40
+ /**
41
+ * Patch version number
42
+ */
43
+ static readonly VERSION_PATCH: number;
44
+ /**
45
+ * Native token transfer selector (reserved signature for simple ETH transfers)
46
+ * Computed as bytes4(keccak256("__bloxchain_native_transfer__()"))
47
+ */
48
+ static readonly NATIVE_TRANSFER_SELECTOR: Hex;
49
+ /**
50
+ * Native token transfer operation type hash
51
+ */
52
+ static readonly NATIVE_TRANSFER_OPERATION: Hex;
53
+ /**
54
+ * Payment update selector (reserved signature for payment detail updates)
55
+ * Computed as bytes4(keccak256("__bloxchain_update_payment__()"))
56
+ */
57
+ static readonly UPDATE_PAYMENT_SELECTOR: Hex;
58
+ /**
59
+ * Payment update operation type hash
60
+ */
61
+ static readonly UPDATE_PAYMENT_OPERATION: Hex;
62
+ /**
63
+ * Owner role hash
64
+ */
65
+ static readonly OWNER_ROLE: Hex;
66
+ /**
67
+ * Broadcaster role hash
68
+ */
69
+ static readonly BROADCASTER_ROLE: Hex;
70
+ /**
71
+ * Recovery role hash
72
+ */
73
+ static readonly RECOVERY_ROLE: Hex;
74
+ /**
75
+ * @dev Recovers the signer address from a message hash and signature
76
+ * @param messageHash The hash of the message that was signed (bytes32)
77
+ * @param signature The signature to recover the address from (65 bytes)
78
+ * @returns Promise that resolves to the address of the signer
79
+ * @throws Error if signature is invalid or recovery fails
80
+ *
81
+ * @notice This matches the contract's recoverSigner function which uses
82
+ * messageHash.toEthSignedMessageHash() to convert to EIP-191 format
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const messageHash = "0x1234...";
87
+ * const signature = "0xabcd...";
88
+ * const signer = await EngineBlox.recoverSigner(messageHash, signature);
89
+ * ```
90
+ */
91
+ static recoverSigner(messageHash: Hex, signature: Hex): Promise<Address>;
92
+ /**
93
+ * @dev Checks if a function selector exists in a contract's bytecode
94
+ * @param client PublicClient instance for reading contract bytecode
95
+ * @param contractAddress The address of the contract to check
96
+ * @param selector The 4-byte function selector to search for
97
+ * @returns Promise that resolves to true if the selector is found in the contract's function selector dispatch table
98
+ *
99
+ * @notice Searches the first 2KB where function selectors are stored in the dispatch table
100
+ * @notice This is a heuristic check - false positives are possible but unlikely
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const exists = await EngineBlox.selectorExistsInContract(
105
+ * publicClient,
106
+ * '0x1234...',
107
+ * '0xabcd1234'
108
+ * );
109
+ * ```
110
+ */
111
+ static selectorExistsInContract(client: PublicClient, contractAddress: Address, selector: Hex): Promise<boolean>;
112
+ /**
113
+ * @dev Checks if a TxAction is present in a bitmap
114
+ * @param bitmap The bitmap to check
115
+ * @param action The TxAction to check for
116
+ * @returns True if the action is present in the bitmap
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const hasAction = EngineBlox.hasActionInBitmap(bitmap, TxAction.EXECUTE_TIME_DELAY_REQUEST);
121
+ * ```
122
+ */
123
+ static hasActionInBitmap(bitmap: Uint16Bitmap, action: TxAction): boolean;
124
+ /**
125
+ * @dev Adds a TxAction to a bitmap
126
+ * @param bitmap The original bitmap
127
+ * @param action The TxAction to add
128
+ * @returns The updated bitmap with the action added
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const newBitmap = EngineBlox.addActionToBitmap(bitmap, TxAction.EXECUTE_TIME_DELAY_REQUEST);
133
+ * ```
134
+ */
135
+ static addActionToBitmap(bitmap: Uint16Bitmap, action: TxAction): Uint16Bitmap;
136
+ /**
137
+ * @dev Creates a bitmap from an array of TxActions
138
+ * @param actions Array of TxActions to convert to bitmap
139
+ * @returns Bitmap representation of the actions
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const bitmap = EngineBlox.createBitmapFromActions([
144
+ * TxAction.EXECUTE_TIME_DELAY_REQUEST,
145
+ * TxAction.EXECUTE_TIME_DELAY_APPROVE
146
+ * ]);
147
+ * ```
148
+ */
149
+ static createBitmapFromActions(actions: TxAction[]): Uint16Bitmap;
150
+ /**
151
+ * @dev Converts a bitmap to an array of TxActions
152
+ * @param bitmap The bitmap to convert
153
+ * @returns Array of TxActions represented by the bitmap
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const actions = EngineBlox.convertBitmapToActions(bitmap);
158
+ * // Returns [TxAction.EXECUTE_TIME_DELAY_REQUEST, TxAction.EXECUTE_TIME_DELAY_APPROVE]
159
+ * ```
160
+ */
161
+ static convertBitmapToActions(bitmap: Uint16Bitmap): TxAction[];
162
+ }
163
+ /**
164
+ * Default export for convenience
165
+ */
166
+ export default EngineBlox;
167
+ //# sourceMappingURL=EngineBlox.d.ts.map