@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, PublicClient, WalletClient, Chain } from 'viem';
2
+ import { TransactionOptions, TransactionResult } from '../../interfaces/base.index';
3
+ /**
4
+ * @title ERC20TokenContract
5
+ * @notice A contract for interacting with ERC20 tokens
6
+ * @dev Implements standard ERC20 token functionality according to EIP-20
7
+ */
8
+ declare class ERC20Token {
9
+ protected client: PublicClient;
10
+ protected walletClient?: WalletClient;
11
+ protected tokenAddress: Address;
12
+ protected chain: Chain;
13
+ /**
14
+ * @notice Creates a new ERC20TokenContract instance
15
+ * @param client The viem PublicClient instance for blockchain interactions
16
+ * @param walletClient Optional WalletClient for signing transactions
17
+ * @param tokenAddress The address of the ERC20 token contract
18
+ * @param chain The chain object for the network
19
+ */
20
+ constructor(client: PublicClient, walletClient: WalletClient | undefined, tokenAddress: Address, chain: Chain);
21
+ /**
22
+ * @notice Gets the token balance of an account
23
+ * @param account The address to check the balance of
24
+ * @return The token balance of the account as a string
25
+ */
26
+ balanceOf(account: Address): Promise<string>;
27
+ /**
28
+ * @notice Transfers tokens to a specified address
29
+ * @param to The address to transfer tokens to
30
+ * @param amount The amount of tokens to transfer
31
+ * @param options Transaction options including the sender address
32
+ * @return TransactionResult containing hash and wait function
33
+ */
34
+ transfer(to: Address, amount: string, options: TransactionOptions): Promise<TransactionResult>;
35
+ /**
36
+ * @notice Approves a spender to spend tokens on behalf of the owner
37
+ * @dev Overrides any existing allowance and emits Approval event
38
+ * @param spender The address authorized to spend tokens
39
+ * @param amount The amount of tokens the spender is approved to use
40
+ * @param options Transaction options including the sender address
41
+ * @return TransactionResult containing hash and wait function
42
+ */
43
+ approve(spender: Address, amount: string, options: TransactionOptions): Promise<TransactionResult>;
44
+ /**
45
+ * @notice Transfers tokens from one address to another using the allowance mechanism
46
+ * @dev Requires sufficient allowance and emits Transfer event
47
+ * @param from The address to transfer tokens from
48
+ * @param to The address to transfer tokens to
49
+ * @param amount The amount of tokens to transfer
50
+ * @param options Transaction options including the sender address
51
+ * @return TransactionResult containing hash and wait function
52
+ */
53
+ transferFrom(from: Address, to: Address, amount: string, options: TransactionOptions): Promise<TransactionResult>;
54
+ /**
55
+ * @notice Gets the total supply of the token
56
+ * @return The total token supply as a string
57
+ */
58
+ totalSupply(): Promise<string>;
59
+ /**
60
+ * @notice Gets the amount of tokens that a spender is allowed to spend on behalf of an owner
61
+ * @param owner The address that owns the tokens
62
+ * @param spender The address authorized to spend tokens
63
+ * @return The remaining number of tokens that spender is allowed to spend
64
+ */
65
+ allowance(owner: Address, spender: Address): Promise<string>;
66
+ /**
67
+ * @notice Gets the token symbol
68
+ * @return The symbol of the token
69
+ */
70
+ symbol(): Promise<string>;
71
+ /**
72
+ * @notice Gets the number of decimals used by the token
73
+ * @return The number of decimals
74
+ */
75
+ decimals(): Promise<number>;
76
+ /**
77
+ * @notice Gets the name of the token
78
+ * @return The name of the token
79
+ */
80
+ name(): Promise<string>;
81
+ }
82
+ export default ERC20Token;
83
+ //# sourceMappingURL=erc20Token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc20Token.d.ts","sourceRoot":"","sources":["../../../utils/erc20/erc20Token.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,KAAK,EAEN,MAAM,MAAM,CAAC;AAMd,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEpF;;;;GAIG;AACH,cAAM,UAAU;IACd,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC;IAC/B,SAAS,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACtC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC;IAChC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;IAEvB;;;;;;OAMG;gBAED,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,YAAY,EAAE,OAAO,EACrB,KAAK,EAAE,KAAK;IAQd;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAUlD;;;;;;OAMG;IACG,QAAQ,CACZ,EAAE,EAAE,OAAO,EACX,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC;IAiB7B;;;;;;;OAOG;IACG,OAAO,CACX,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC;IAiB7B;;;;;;;;OAQG;IACG,YAAY,CAChB,IAAI,EAAE,OAAO,EACb,EAAE,EAAE,OAAO,EACX,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC;IAiB7B;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IASpC;;;;;OAKG;IACG,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAUlE;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAQ/B;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IASjC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;CAQ9B;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,173 @@
1
+ import ERC20ABI from './ERC20Token.abi.json';
2
+ // Parse and type the ABI
3
+ const ERC20TokenABI = ERC20ABI;
4
+ /**
5
+ * @title ERC20TokenContract
6
+ * @notice A contract for interacting with ERC20 tokens
7
+ * @dev Implements standard ERC20 token functionality according to EIP-20
8
+ */
9
+ class ERC20Token {
10
+ /**
11
+ * @notice Creates a new ERC20TokenContract instance
12
+ * @param client The viem PublicClient instance for blockchain interactions
13
+ * @param walletClient Optional WalletClient for signing transactions
14
+ * @param tokenAddress The address of the ERC20 token contract
15
+ * @param chain The chain object for the network
16
+ */
17
+ constructor(client, walletClient, tokenAddress, chain) {
18
+ this.client = client;
19
+ this.walletClient = walletClient;
20
+ this.tokenAddress = tokenAddress;
21
+ this.chain = chain;
22
+ }
23
+ /**
24
+ * @notice Gets the token balance of an account
25
+ * @param account The address to check the balance of
26
+ * @return The token balance of the account as a string
27
+ */
28
+ async balanceOf(account) {
29
+ const result = await this.client.readContract({
30
+ address: this.tokenAddress,
31
+ abi: ERC20TokenABI,
32
+ functionName: 'balanceOf',
33
+ args: [account]
34
+ });
35
+ return result.toString();
36
+ }
37
+ /**
38
+ * @notice Transfers tokens to a specified address
39
+ * @param to The address to transfer tokens to
40
+ * @param amount The amount of tokens to transfer
41
+ * @param options Transaction options including the sender address
42
+ * @return TransactionResult containing hash and wait function
43
+ */
44
+ async transfer(to, amount, options) {
45
+ if (!this.walletClient)
46
+ throw new Error('Wallet client is required');
47
+ const hash = await this.walletClient.writeContract({
48
+ chain: this.chain,
49
+ address: this.tokenAddress,
50
+ abi: ERC20TokenABI,
51
+ functionName: 'transfer',
52
+ args: [to, amount],
53
+ account: options.from
54
+ });
55
+ return {
56
+ hash,
57
+ wait: () => this.client.waitForTransactionReceipt({ hash })
58
+ };
59
+ }
60
+ /**
61
+ * @notice Approves a spender to spend tokens on behalf of the owner
62
+ * @dev Overrides any existing allowance and emits Approval event
63
+ * @param spender The address authorized to spend tokens
64
+ * @param amount The amount of tokens the spender is approved to use
65
+ * @param options Transaction options including the sender address
66
+ * @return TransactionResult containing hash and wait function
67
+ */
68
+ async approve(spender, amount, options) {
69
+ if (!this.walletClient)
70
+ throw new Error('Wallet client is required');
71
+ const hash = await this.walletClient.writeContract({
72
+ chain: this.chain,
73
+ address: this.tokenAddress,
74
+ abi: ERC20TokenABI,
75
+ functionName: 'approve',
76
+ args: [spender, amount],
77
+ account: options.from
78
+ });
79
+ return {
80
+ hash,
81
+ wait: () => this.client.waitForTransactionReceipt({ hash })
82
+ };
83
+ }
84
+ /**
85
+ * @notice Transfers tokens from one address to another using the allowance mechanism
86
+ * @dev Requires sufficient allowance and emits Transfer event
87
+ * @param from The address to transfer tokens from
88
+ * @param to The address to transfer tokens to
89
+ * @param amount The amount of tokens to transfer
90
+ * @param options Transaction options including the sender address
91
+ * @return TransactionResult containing hash and wait function
92
+ */
93
+ async transferFrom(from, to, amount, options) {
94
+ if (!this.walletClient)
95
+ throw new Error('Wallet client is required');
96
+ const hash = await this.walletClient.writeContract({
97
+ chain: this.chain,
98
+ address: this.tokenAddress,
99
+ abi: ERC20TokenABI,
100
+ functionName: 'transferFrom',
101
+ args: [from, to, amount],
102
+ account: options.from
103
+ });
104
+ return {
105
+ hash,
106
+ wait: () => this.client.waitForTransactionReceipt({ hash })
107
+ };
108
+ }
109
+ /**
110
+ * @notice Gets the total supply of the token
111
+ * @return The total token supply as a string
112
+ */
113
+ async totalSupply() {
114
+ const result = await this.client.readContract({
115
+ address: this.tokenAddress,
116
+ abi: ERC20TokenABI,
117
+ functionName: 'totalSupply'
118
+ });
119
+ return result.toString();
120
+ }
121
+ /**
122
+ * @notice Gets the amount of tokens that a spender is allowed to spend on behalf of an owner
123
+ * @param owner The address that owns the tokens
124
+ * @param spender The address authorized to spend tokens
125
+ * @return The remaining number of tokens that spender is allowed to spend
126
+ */
127
+ async allowance(owner, spender) {
128
+ const result = await this.client.readContract({
129
+ address: this.tokenAddress,
130
+ abi: ERC20TokenABI,
131
+ functionName: 'allowance',
132
+ args: [owner, spender]
133
+ });
134
+ return result.toString();
135
+ }
136
+ /**
137
+ * @notice Gets the token symbol
138
+ * @return The symbol of the token
139
+ */
140
+ async symbol() {
141
+ return await this.client.readContract({
142
+ address: this.tokenAddress,
143
+ abi: ERC20TokenABI,
144
+ functionName: 'symbol'
145
+ });
146
+ }
147
+ /**
148
+ * @notice Gets the number of decimals used by the token
149
+ * @return The number of decimals
150
+ */
151
+ async decimals() {
152
+ const result = await this.client.readContract({
153
+ address: this.tokenAddress,
154
+ abi: ERC20TokenABI,
155
+ functionName: 'decimals'
156
+ });
157
+ return Number(result);
158
+ }
159
+ /**
160
+ * @notice Gets the name of the token
161
+ * @return The name of the token
162
+ */
163
+ async name() {
164
+ const result = await this.client.readContract({
165
+ address: this.tokenAddress,
166
+ abi: ERC20TokenABI,
167
+ functionName: 'name'
168
+ });
169
+ return result;
170
+ }
171
+ }
172
+ export default ERC20Token;
173
+ //# sourceMappingURL=erc20Token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc20Token.js","sourceRoot":"","sources":["../../../utils/erc20/erc20Token.tsx"],"names":[],"mappings":"AAOA,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAE7C,yBAAyB;AACzB,MAAM,aAAa,GAAG,QAAe,CAAC;AAItC;;;;GAIG;AACH,MAAM,UAAU;IAMd;;;;;;OAMG;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ED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { Hex } from 'viem';
2
+ /**
3
+ * Interface IDs for component detection
4
+ * These match the interface IDs calculated by Solidity's type(Interface).interfaceId
5
+ *
6
+ * NOTE: These values are calculated from function signatures and should match
7
+ * the values returned by Solidity's type(Interface).interfaceId.
8
+ * If there are discrepancies, verify against the actual Solidity contract interfaces.
9
+ */
10
+ export declare const INTERFACE_IDS: {
11
+ readonly IBaseStateMachine: `0x${string}`;
12
+ readonly ISecureOwnable: `0x${string}`;
13
+ readonly IRuntimeRBAC: `0x${string}`;
14
+ readonly IGuardController: `0x${string}`;
15
+ };
16
+ /**
17
+ * Helper function to check if a contract supports a specific interface
18
+ * @param contract The contract instance (must have supportsInterface method)
19
+ * @param interfaceId The interface ID to check
20
+ * @returns Promise<boolean> indicating if the interface is supported
21
+ */
22
+ export declare function supportsInterface(contract: {
23
+ supportsInterface: (interfaceId: Hex) => Promise<boolean>;
24
+ }, interfaceId: Hex): Promise<boolean>;
25
+ /**
26
+ * Helper functions to check for specific component interfaces
27
+ */
28
+ export declare const ComponentDetection: {
29
+ /**
30
+ * Check if contract supports IBaseStateMachine interface
31
+ */
32
+ isBaseStateMachine(contract: {
33
+ supportsInterface: (interfaceId: Hex) => Promise<boolean>;
34
+ }): Promise<boolean>;
35
+ /**
36
+ * Check if contract supports ISecureOwnable interface
37
+ */
38
+ isSecureOwnable(contract: {
39
+ supportsInterface: (interfaceId: Hex) => Promise<boolean>;
40
+ }): Promise<boolean>;
41
+ /**
42
+ * Check if contract has SecureOwnable features by checking for specific functions
43
+ */
44
+ hasSecureOwnableFeatures(contract: any): Promise<boolean>;
45
+ /**
46
+ * Check if contract supports IRuntimeRBAC interface
47
+ */
48
+ isRuntimeRBAC(contract: {
49
+ supportsInterface: (interfaceId: Hex) => Promise<boolean>;
50
+ }): Promise<boolean>;
51
+ /**
52
+ * Check if contract supports IGuardController interface
53
+ */
54
+ isGuardController(contract: {
55
+ supportsInterface: (interfaceId: Hex) => Promise<boolean>;
56
+ }): Promise<boolean>;
57
+ };
58
+ export default INTERFACE_IDS;
59
+ //# sourceMappingURL=interface-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface-ids.d.ts","sourceRoot":"","sources":["../../utils/interface-ids.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAsB,MAAM,MAAM,CAAC;AAqB/C;;;;;;;GAOG;AAIH,eAAO,MAAM,aAAa;;;;;CAqEhB,CAAC;AAEX;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE;IAAE,iBAAiB,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,EACvE,WAAW,EAAE,GAAG,GACf,OAAO,CAAC,OAAO,CAAC,CAElB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;OAEG;iCACgC;QAAE,iBAAiB,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAInH;;OAEG;8BAC6B;QAAE,iBAAiB,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhH;;OAEG;uCACsC,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAY/D;;OAEG;4BAC2B;QAAE,iBAAiB,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9G;;OAEG;gCAC+B;QAAE,iBAAiB,EAAE,CAAC,WAAW,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAGnH,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,149 @@
1
+ import { keccak256, toBytes } from 'viem';
2
+ /**
3
+ * Utility to calculate ERC165 interface ID from function signatures
4
+ * Interface ID is the XOR of all function selectors (first 4 bytes of keccak256)
5
+ */
6
+ function calculateInterfaceId(signatures) {
7
+ if (signatures.length === 0) {
8
+ return '0x00000000';
9
+ }
10
+ let interfaceId = 0n;
11
+ for (const sig of signatures) {
12
+ const selector = keccak256(toBytes(sig)).slice(0, 10); // First 4 bytes (10 chars with 0x)
13
+ interfaceId = interfaceId ^ BigInt(selector);
14
+ }
15
+ // Format as 4-byte hex string
16
+ return `0x${interfaceId.toString(16).padStart(8, '0')}`;
17
+ }
18
+ /**
19
+ * Interface IDs for component detection
20
+ * These match the interface IDs calculated by Solidity's type(Interface).interfaceId
21
+ *
22
+ * NOTE: These values are calculated from function signatures and should match
23
+ * the values returned by Solidity's type(Interface).interfaceId.
24
+ * If there are discrepancies, verify against the actual Solidity contract interfaces.
25
+ */
26
+ // IBaseStateMachine interface ID
27
+ // Calculated from all functions in IBaseStateMachine interface
28
+ export const INTERFACE_IDS = {
29
+ // IBaseStateMachine - XOR of all function selectors
30
+ IBaseStateMachine: calculateInterfaceId([
31
+ 'createMetaTxParams(address,bytes4,uint8,uint256,uint256,address)',
32
+ 'generateUnsignedMetaTransactionForNew(address,address,uint256,uint256,bytes32,bytes4,bytes,(uint256,uint256,address,bytes4,uint256,uint256,address))',
33
+ 'generateUnsignedMetaTransactionForExisting(uint256,(uint256,uint256,address,bytes4,uint256,uint256,address))',
34
+ 'getTransactionHistory(uint256,uint256)',
35
+ 'getTransaction(uint256)',
36
+ 'getPendingTransactions()',
37
+ 'hasRole(bytes32,address)',
38
+ 'isActionSupportedByFunction(bytes4,uint8)',
39
+ 'getActiveRolePermissions(bytes32)',
40
+ 'getSignerNonce(address)',
41
+ 'getSupportedOperationTypes()',
42
+ 'getSupportedRoles()',
43
+ 'getSupportedFunctions()',
44
+ 'getTimeLockPeriodSec()',
45
+ 'initialized()'
46
+ ]),
47
+ // ISecureOwnable - XOR of all function selectors in ISecureOwnable interface
48
+ ISecureOwnable: calculateInterfaceId([
49
+ 'transferOwnershipRequest()',
50
+ 'transferOwnershipDelayedApproval(uint256)',
51
+ 'transferOwnershipApprovalWithMetaTx(((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))',
52
+ 'transferOwnershipCancellation(uint256)',
53
+ 'transferOwnershipCancellationWithMetaTx(((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))',
54
+ 'updateBroadcasterRequest(address)',
55
+ 'updateBroadcasterDelayedApproval(uint256)',
56
+ 'updateBroadcasterApprovalWithMetaTx(((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))',
57
+ 'updateBroadcasterCancellation(uint256)',
58
+ 'updateBroadcasterCancellationWithMetaTx(((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))',
59
+ 'updateRecoveryExecutionParams(address)',
60
+ 'updateRecoveryRequestAndApprove(((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))',
61
+ 'updateTimeLockExecutionParams(uint256)',
62
+ 'updateTimeLockRequestAndApprove(((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))'
63
+ ]),
64
+ // IRuntimeRBAC - XOR of all function selectors in IRuntimeRBAC interface
65
+ IRuntimeRBAC: calculateInterfaceId([
66
+ 'createRole(string,uint256)',
67
+ 'updateRole(bytes32,string,uint256)',
68
+ 'deleteRole(bytes32)',
69
+ 'addWalletToRole(bytes32,address)',
70
+ 'revokeWallet(bytes32,address)',
71
+ 'replaceWalletInRole(bytes32,address,address)',
72
+ 'addFunctionPermissionToRole(bytes32,bytes4,uint8)',
73
+ 'removeFunctionPermissionFromRole(bytes32,bytes4)',
74
+ 'getRuntimeRoles()',
75
+ 'getAllRoles()',
76
+ 'getRoleInfo(bytes32)',
77
+ 'hasRole(bytes32,address)',
78
+ 'getWalletsInRole(bytes32)',
79
+ 'getRolePermissions(bytes32)',
80
+ 'isRoleProtected(bytes32)',
81
+ 'getRoleWalletCount(bytes32)',
82
+ 'isRoleAtCapacity(bytes32)'
83
+ ]),
84
+ // IGuardController - XOR of all function selectors in IGuardController interface
85
+ IGuardController: calculateInterfaceId([
86
+ 'initialize(address,address,address,uint256,address)',
87
+ 'executeWithTimeLock(address,uint256,bytes4,bytes,uint256,bytes32)',
88
+ 'approveTimeLockExecution(uint256,bytes32)',
89
+ 'cancelTimeLockExecution(uint256,bytes32)',
90
+ '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),bytes32,bytes4)',
91
+ '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),bytes32,bytes4)',
92
+ '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),bytes4)'
93
+ ])
94
+ };
95
+ /**
96
+ * Helper function to check if a contract supports a specific interface
97
+ * @param contract The contract instance (must have supportsInterface method)
98
+ * @param interfaceId The interface ID to check
99
+ * @returns Promise<boolean> indicating if the interface is supported
100
+ */
101
+ export async function supportsInterface(contract, interfaceId) {
102
+ return contract.supportsInterface(interfaceId);
103
+ }
104
+ /**
105
+ * Helper functions to check for specific component interfaces
106
+ */
107
+ export const ComponentDetection = {
108
+ /**
109
+ * Check if contract supports IBaseStateMachine interface
110
+ */
111
+ async isBaseStateMachine(contract) {
112
+ return supportsInterface(contract, INTERFACE_IDS.IBaseStateMachine);
113
+ },
114
+ /**
115
+ * Check if contract supports ISecureOwnable interface
116
+ */
117
+ async isSecureOwnable(contract) {
118
+ return supportsInterface(contract, INTERFACE_IDS.ISecureOwnable);
119
+ },
120
+ /**
121
+ * Check if contract has SecureOwnable features by checking for specific functions
122
+ */
123
+ async hasSecureOwnableFeatures(contract) {
124
+ try {
125
+ // Check if transferOwnershipRequest exists
126
+ if (typeof contract.transferOwnershipRequest === 'function') {
127
+ return true;
128
+ }
129
+ return false;
130
+ }
131
+ catch {
132
+ return false;
133
+ }
134
+ },
135
+ /**
136
+ * Check if contract supports IRuntimeRBAC interface
137
+ */
138
+ async isRuntimeRBAC(contract) {
139
+ return supportsInterface(contract, INTERFACE_IDS.IRuntimeRBAC);
140
+ },
141
+ /**
142
+ * Check if contract supports IGuardController interface
143
+ */
144
+ async isGuardController(contract) {
145
+ return supportsInterface(contract, INTERFACE_IDS.IGuardController);
146
+ }
147
+ };
148
+ export default INTERFACE_IDS;
149
+ //# sourceMappingURL=interface-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface-ids.js","sourceRoot":"","sources":["../../utils/interface-ids.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/C;;;GAGG;AAC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Aa,CAAC,QAAuE;QACzF,OAAO,iBAAiB,CAAC,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CAAC,QAAuE;QAC7F,OAAO,iBAAiB,CAAC,QAAQ,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACrE,CAAC;CACF,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,138 @@
1
+ import { Address, Hex, PublicClient, WalletClient, Chain } from 'viem';
2
+ import { MetaTransaction, MetaTxParams, TxParams } from '../../interfaces/lib.index';
3
+ import { TxAction } from '../../types/lib.index';
4
+ /**
5
+ * @title MetaTransactionSigner
6
+ * @dev Standardized utility for creating and signing meta-transactions
7
+ *
8
+ * This utility leverages the contract's own EIP-712 message hash generation
9
+ * to avoid JavaScript replication issues and ensure signature compatibility.
10
+ *
11
+ * Architecture:
12
+ * - Step 1: Create unsigned meta-transaction (contract generates message hash)
13
+ * - Step 2: Sign the message hash (programmatic or external wallet)
14
+ * - Step 3: Verify signature and return complete meta-transaction
15
+ *
16
+ * Key Features:
17
+ * - Contract-based message hash generation
18
+ * - Separated unsigned creation and signing steps
19
+ * - Support for programmatic and frontend wallet signing
20
+ * - Type-safe meta-transaction creation
21
+ * - Automatic signature verification
22
+ * - Support for both new and existing transactions
23
+ *
24
+ * Security: Uses the contract's generateUnsignedForNewMetaTx/generateUnsignedForExistingMetaTx
25
+ * functions to ensure exact EIP-712 compliance with the on-chain implementation.
26
+ */
27
+ export declare class MetaTransactionSigner {
28
+ private client;
29
+ private walletClient?;
30
+ private contractAddress;
31
+ private chain;
32
+ constructor(client: PublicClient, walletClient: WalletClient | undefined, contractAddress: Address, chain: Chain);
33
+ /**
34
+ * @dev Creates an unsigned meta-transaction for a new operation
35
+ * @param txParams Transaction parameters
36
+ * @param metaTxParams Meta-transaction parameters
37
+ * @returns Unsigned meta-transaction ready for signing
38
+ */
39
+ createUnsignedMetaTransactionForNew(txParams: TxParams, metaTxParams: MetaTxParams): Promise<MetaTransaction>;
40
+ /**
41
+ * @dev Creates an unsigned meta-transaction for an existing operation
42
+ * @param txId Existing transaction ID
43
+ * @param metaTxParams Meta-transaction parameters
44
+ * @returns Unsigned meta-transaction ready for signing
45
+ */
46
+ createUnsignedMetaTransactionForExisting(txId: bigint, metaTxParams: MetaTxParams): Promise<MetaTransaction>;
47
+ /**
48
+ * @dev Signs an unsigned meta-transaction using private key (for remote Ganache compatibility)
49
+ * @param unsignedMetaTx Unsigned meta-transaction
50
+ * @param signerAddress Address of the signer
51
+ * @param privateKey Private key for signing (required for remote Ganache)
52
+ * @returns Complete signed meta-transaction
53
+ */
54
+ signMetaTransaction(unsignedMetaTx: MetaTransaction, signerAddress: Address, privateKey: Hex): Promise<MetaTransaction>;
55
+ /**
56
+ * @dev Creates a signed meta-transaction with external signature (for frontend wallets)
57
+ * @param unsignedMetaTx Unsigned meta-transaction
58
+ * @param signature External signature from wallet
59
+ * @returns Complete signed meta-transaction
60
+ */
61
+ createSignedMetaTransactionWithSignature(unsignedMetaTx: MetaTransaction, signature: Hex): Promise<MetaTransaction>;
62
+ /**
63
+ * @dev Creates a signed meta-transaction for a new operation (convenience method)
64
+ * @param txParams Transaction parameters
65
+ * @param metaTxParams Meta-transaction parameters
66
+ * @param signerAddress Address of the signer
67
+ * @param privateKey Private key for signing (required for remote Ganache)
68
+ * @returns Complete signed meta-transaction
69
+ */
70
+ createSignedMetaTransactionForNew(txParams: TxParams, metaTxParams: MetaTxParams, signerAddress: Address, privateKey: Hex): Promise<MetaTransaction>;
71
+ /**
72
+ * @dev Creates a signed meta-transaction for an existing transaction (convenience method)
73
+ * @param txId Existing transaction ID
74
+ * @param metaTxParams Meta-transaction parameters
75
+ * @param signerAddress Address of the signer
76
+ * @param privateKey Private key for signing (required for remote Ganache)
77
+ * @returns Complete signed meta-transaction
78
+ */
79
+ createSignedMetaTransactionForExisting(txId: bigint, metaTxParams: MetaTxParams, signerAddress: Address, privateKey: Hex): Promise<MetaTransaction>;
80
+ /**
81
+ * @dev Generates unsigned meta-transaction for new operation using contract
82
+ * @param txParams Transaction parameters
83
+ * @param metaTxParams Meta-transaction parameters
84
+ * @returns Complete MetaTransaction from contract (with data field populated)
85
+ */
86
+ private generateUnsignedMetaTransactionForNew;
87
+ /**
88
+ * @dev Generates unsigned meta-transaction for existing operation using contract
89
+ * @param txId Transaction ID
90
+ * @param metaTxParams Meta-transaction parameters
91
+ * @returns Complete MetaTransaction from contract (with data field populated)
92
+ */
93
+ private generateUnsignedMetaTransactionForExisting;
94
+ /**
95
+ * @dev Verifies a signature against a message hash and expected signer
96
+ * @param messageHash The message hash
97
+ * @param signature The signature to verify
98
+ * @param expectedSigner The expected signer address
99
+ */
100
+ private verifySignature;
101
+ /**
102
+ * @dev Gets the contract ABI for meta-transaction functions
103
+ * Uses BaseStateMachine ABI to match the actual deployed contract
104
+ * @returns Contract ABI
105
+ */
106
+ private getContractABI;
107
+ }
108
+ /**
109
+ * @dev Helper functions for creating meta-transaction parameters
110
+ */
111
+ export declare class MetaTransactionBuilder {
112
+ /**
113
+ * @dev Creates meta-transaction parameters
114
+ * @param handlerContract Handler contract address
115
+ * @param handlerSelector Handler function selector
116
+ * @param action Transaction action
117
+ * @param deadline Deadline timestamp
118
+ * @param maxGasPrice Maximum gas price
119
+ * @param signer Signer address
120
+ * @param chainId Chain ID (optional, defaults to current chain)
121
+ * @param nonce Nonce (optional, will be fetched from contract)
122
+ * @returns Meta-transaction parameters
123
+ */
124
+ static createMetaTxParams(handlerContract: Address, handlerSelector: Hex, action: TxAction, deadline: bigint, maxGasPrice: bigint, signer: Address, chainId: bigint, nonce?: bigint): MetaTxParams;
125
+ /**
126
+ * @dev Creates transaction parameters
127
+ * @param requester Requester address
128
+ * @param target Target contract address
129
+ * @param value Value to send
130
+ * @param gasLimit Gas limit
131
+ * @param operationType Operation type
132
+ * @param executionSelector Execution selector (bytes4)
133
+ * @param executionParams Execution parameters
134
+ * @returns Transaction parameters
135
+ */
136
+ static createTxParams(requester: Address, target: Address, value: bigint, gasLimit: bigint, operationType: Hex, executionSelector: Hex, executionParams: Hex): TxParams;
137
+ }
138
+ //# sourceMappingURL=metaTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metaTransaction.d.ts","sourceRoot":"","sources":["../../../utils/metaTx/metaTransaction.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,YAAY,EACZ,YAAY,EACZ,KAAK,EACN,MAAM,MAAM,CAAC;AACd,OAAO,EACL,eAAe,EAEf,YAAY,EACZ,QAAQ,EACT,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAC,CAAe;IACpC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,KAAK,CAAQ;gBAGnB,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,eAAe,EAAE,OAAO,EACxB,KAAK,EAAE,KAAK;IAQd;;;;;OAKG;IACG,mCAAmC,CACvC,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,eAAe,CAAC;IAK3B;;;;;OAKG;IACG,wCAAwC,CAC5C,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,eAAe,CAAC;IAa3B;;;;;;OAMG;IACG,mBAAmB,CACvB,cAAc,EAAE,eAAe,EAC/B,aAAa,EAAE,OAAO,EACtB,UAAU,EAAE,GAAG,GACd,OAAO,CAAC,eAAe,CAAC;IA4B3B;;;;;OAKG;IACG,wCAAwC,CAC5C,cAAc,EAAE,eAAe,EAC/B,SAAS,EAAE,GAAG,GACb,OAAO,CAAC,eAAe,CAAC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