@charterlabs/rhinestone-sdk 0.2.7-dev.3 → 0.2.7-dev.4

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 (130) hide show
  1. package/dist/src/accounts/error.d.ts +38 -3
  2. package/dist/src/accounts/error.d.ts.map +1 -1
  3. package/dist/src/accounts/error.js +55 -7
  4. package/dist/src/accounts/index.d.ts +28 -20
  5. package/dist/src/accounts/index.d.ts.map +1 -1
  6. package/dist/src/accounts/index.js +196 -21
  7. package/dist/src/accounts/index.test.js +2 -4
  8. package/dist/src/accounts/json-rpc/index.d.ts +5 -0
  9. package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
  10. package/dist/src/accounts/json-rpc/index.js +16 -0
  11. package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
  12. package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
  13. package/dist/src/accounts/json-rpc/providers.js +52 -0
  14. package/dist/src/accounts/kernel.d.ts +1 -1
  15. package/dist/src/accounts/kernel.d.ts.map +1 -1
  16. package/dist/src/accounts/kernel.js +29 -1
  17. package/dist/src/accounts/kernel.test.js +35 -8
  18. package/dist/src/accounts/nexus.d.ts +4 -3
  19. package/dist/src/accounts/nexus.d.ts.map +1 -1
  20. package/dist/src/accounts/nexus.js +82 -14
  21. package/dist/src/accounts/nexus.test.js +33 -6
  22. package/dist/src/accounts/safe.d.ts.map +1 -1
  23. package/dist/src/accounts/safe.js +85 -53
  24. package/dist/src/accounts/safe.test.js +33 -6
  25. package/dist/src/accounts/signing/common.d.ts +4 -4
  26. package/dist/src/accounts/signing/common.d.ts.map +1 -1
  27. package/dist/src/accounts/signing/common.js +21 -9
  28. package/dist/src/accounts/signing/message.d.ts +1 -1
  29. package/dist/src/accounts/signing/message.d.ts.map +1 -1
  30. package/dist/src/accounts/signing/message.js +6 -6
  31. package/dist/src/accounts/signing/passkeys.d.ts +8 -1
  32. package/dist/src/accounts/signing/passkeys.d.ts.map +1 -1
  33. package/dist/src/accounts/signing/passkeys.js +35 -0
  34. package/dist/src/accounts/signing/passkeys.test.js +15 -0
  35. package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
  36. package/dist/src/accounts/signing/typedData.js +2 -2
  37. package/dist/src/accounts/startale.test.js +0 -4
  38. package/dist/src/accounts/utils.d.ts +4 -4
  39. package/dist/src/accounts/utils.d.ts.map +1 -1
  40. package/dist/src/accounts/utils.js +3 -40
  41. package/dist/src/accounts/walletClient.d.ts +7 -0
  42. package/dist/src/accounts/walletClient.d.ts.map +1 -0
  43. package/dist/src/accounts/walletClient.js +38 -0
  44. package/dist/src/actions/compact.d.ts +13 -0
  45. package/dist/src/actions/compact.d.ts.map +1 -0
  46. package/dist/src/actions/compact.js +210 -0
  47. package/dist/src/actions/ecdsa.d.ts +35 -0
  48. package/dist/src/actions/ecdsa.d.ts.map +1 -0
  49. package/dist/src/actions/ecdsa.js +114 -0
  50. package/dist/src/actions/ecdsa.test.d.ts +2 -0
  51. package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
  52. package/dist/src/actions/ecdsa.test.js +99 -0
  53. package/dist/src/actions/index.d.ts +23 -166
  54. package/dist/src/actions/index.d.ts.map +1 -1
  55. package/dist/src/actions/index.js +25 -544
  56. package/dist/src/actions/mfa.d.ts +37 -0
  57. package/dist/src/actions/mfa.d.ts.map +1 -0
  58. package/dist/src/actions/mfa.js +133 -0
  59. package/dist/src/actions/passkeys.d.ts +37 -0
  60. package/dist/src/actions/passkeys.d.ts.map +1 -0
  61. package/dist/src/actions/passkeys.js +129 -0
  62. package/dist/src/actions/passkeys.test.d.ts +2 -0
  63. package/dist/src/actions/passkeys.test.d.ts.map +1 -0
  64. package/dist/src/actions/passkeys.test.js +54 -0
  65. package/dist/src/actions/recovery.d.ts +33 -0
  66. package/dist/src/actions/recovery.d.ts.map +1 -0
  67. package/dist/src/actions/recovery.js +193 -0
  68. package/dist/src/actions/recovery.test.d.ts +2 -0
  69. package/dist/src/actions/recovery.test.d.ts.map +1 -0
  70. package/dist/src/actions/recovery.test.js +168 -0
  71. package/dist/src/errors/index.d.ts +5 -0
  72. package/dist/src/errors/index.d.ts.map +1 -0
  73. package/dist/src/errors/index.js +35 -0
  74. package/dist/src/execution/compact.d.ts +24 -8
  75. package/dist/src/execution/compact.d.ts.map +1 -1
  76. package/dist/src/execution/compact.js +29 -103
  77. package/dist/src/execution/error.d.ts +2 -9
  78. package/dist/src/execution/error.d.ts.map +1 -1
  79. package/dist/src/execution/error.js +4 -13
  80. package/dist/src/execution/index.d.ts +33 -22
  81. package/dist/src/execution/index.d.ts.map +1 -1
  82. package/dist/src/execution/index.js +57 -41
  83. package/dist/src/execution/permit2.d.ts +148 -0
  84. package/dist/src/execution/permit2.d.ts.map +1 -0
  85. package/dist/src/execution/permit2.js +282 -0
  86. package/dist/src/execution/smart-session.d.ts +3 -3
  87. package/dist/src/execution/smart-session.d.ts.map +1 -1
  88. package/dist/src/execution/types.d.ts +35 -0
  89. package/dist/src/execution/types.d.ts.map +1 -0
  90. package/dist/src/execution/types.js +2 -0
  91. package/dist/src/execution/utils.d.ts +36 -28
  92. package/dist/src/execution/utils.d.ts.map +1 -1
  93. package/dist/src/execution/utils.js +245 -91
  94. package/dist/src/index.d.ts +37 -19
  95. package/dist/src/index.d.ts.map +1 -1
  96. package/dist/src/index.js +130 -66
  97. package/dist/src/modules/common.d.ts +10 -4
  98. package/dist/src/modules/common.d.ts.map +1 -1
  99. package/dist/src/modules/common.js +22 -1
  100. package/dist/src/modules/index.d.ts +3 -2
  101. package/dist/src/modules/index.d.ts.map +1 -1
  102. package/dist/src/modules/index.js +16 -13
  103. package/dist/src/modules/index.test.js +8 -11
  104. package/dist/src/modules/read.d.ts.map +1 -1
  105. package/dist/src/modules/read.js +4 -0
  106. package/dist/src/modules/validators/core.d.ts +5 -3
  107. package/dist/src/modules/validators/core.d.ts.map +1 -1
  108. package/dist/src/modules/validators/core.js +29 -10
  109. package/dist/src/modules/validators/core.test.js +4 -4
  110. package/dist/src/modules/validators/smart-sessions.test.js +0 -3
  111. package/dist/src/modules/validators/webauthn-contract.d.ts.map +1 -1
  112. package/dist/src/orchestrator/client.d.ts +2 -1
  113. package/dist/src/orchestrator/client.d.ts.map +1 -1
  114. package/dist/src/orchestrator/client.js +36 -14
  115. package/dist/src/orchestrator/consts.d.ts +1 -2
  116. package/dist/src/orchestrator/consts.d.ts.map +1 -1
  117. package/dist/src/orchestrator/consts.js +1 -3
  118. package/dist/src/orchestrator/registry.d.ts +3 -25
  119. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  120. package/dist/src/orchestrator/registry.js +82 -46
  121. package/dist/src/orchestrator/registry.test.js +7 -7
  122. package/dist/src/orchestrator/types.d.ts +35 -31
  123. package/dist/src/orchestrator/types.d.ts.map +1 -1
  124. package/dist/src/types.d.ts +64 -9
  125. package/dist/src/types.d.ts.map +1 -1
  126. package/package.json +73 -2
  127. package/dist/src/actions/index.test.d.ts +0 -2
  128. package/dist/src/actions/index.test.d.ts.map +0 -1
  129. package/dist/src/actions/index.test.js +0 -302
  130. package/dist/src/orchestrator/registry.json +0 -365
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.depositEther = depositEther;
4
+ exports.enableEtherWithdrawal = enableEtherWithdrawal;
5
+ exports.disableEtherWithdrawal = disableEtherWithdrawal;
6
+ exports.withdrawEther = withdrawEther;
7
+ exports.depositErc20 = depositErc20;
8
+ exports.enableErc20Withdrawal = enableErc20Withdrawal;
9
+ exports.disableErc20Withdrawal = disableErc20Withdrawal;
10
+ exports.withdrawErc20 = withdrawErc20;
11
+ exports.approveErc20 = approveErc20;
12
+ const viem_1 = require("viem");
13
+ const compact_1 = require("../execution/compact");
14
+ const ALLOCATOR_ADDRESS = '0xd93ed1dd9f1f0b523e4d77233809dc2ee22928c6';
15
+ const DEFAULT_RESET_PERIOD = 6;
16
+ const DEFAULT_SCOPE = 0;
17
+ function depositEther(value) {
18
+ return {
19
+ async resolve({ accountAddress }) {
20
+ return {
21
+ to: compact_1.COMPACT_ADDRESS,
22
+ data: (0, viem_1.encodeFunctionData)({
23
+ abi: [
24
+ {
25
+ type: 'function',
26
+ name: 'depositNative',
27
+ inputs: [
28
+ { name: 'lockTag', type: 'bytes12', internalType: 'bytes12' },
29
+ { name: 'recipient', type: 'address', internalType: 'address' },
30
+ ],
31
+ outputs: [
32
+ { name: 'id', type: 'uint256', internalType: 'uint256' },
33
+ ],
34
+ stateMutability: 'payable',
35
+ },
36
+ ],
37
+ functionName: 'depositNative',
38
+ args: [lockTag(), accountAddress],
39
+ }),
40
+ value,
41
+ };
42
+ },
43
+ };
44
+ }
45
+ function enableEtherWithdrawal() {
46
+ const id = (0, viem_1.concat)([lockTag(), viem_1.zeroAddress]);
47
+ return enableForcedWithdrawal(BigInt(id));
48
+ }
49
+ function disableEtherWithdrawal() {
50
+ const id = (0, viem_1.concat)([lockTag(), viem_1.zeroAddress]);
51
+ return disableForcedWithdrawal(BigInt(id));
52
+ }
53
+ function withdrawEther(value) {
54
+ return {
55
+ async resolve({ accountAddress }) {
56
+ const id = (0, viem_1.concat)([lockTag(), viem_1.zeroAddress]);
57
+ return forcedWithdrawal(BigInt(id), accountAddress, value);
58
+ },
59
+ };
60
+ }
61
+ function depositErc20(tokenAddress, amount) {
62
+ return {
63
+ async resolve({ accountAddress }) {
64
+ return {
65
+ to: compact_1.COMPACT_ADDRESS,
66
+ value: 0n,
67
+ data: (0, viem_1.encodeFunctionData)({
68
+ abi: [
69
+ {
70
+ type: 'function',
71
+ name: 'depositERC20',
72
+ inputs: [
73
+ { name: 'token', type: 'address', internalType: 'address' },
74
+ { name: 'lockTag', type: 'bytes12', internalType: 'bytes12' },
75
+ { name: 'amount', type: 'uint256', internalType: 'uint256' },
76
+ { name: 'recipient', type: 'address', internalType: 'address' },
77
+ ],
78
+ outputs: [
79
+ { name: 'id', type: 'uint256', internalType: 'uint256' },
80
+ ],
81
+ stateMutability: 'nonpayable',
82
+ },
83
+ ],
84
+ functionName: 'depositERC20',
85
+ args: [tokenAddress, lockTag(), amount, accountAddress],
86
+ }),
87
+ };
88
+ },
89
+ };
90
+ }
91
+ function enableErc20Withdrawal(tokenAddress) {
92
+ const id = (0, viem_1.concat)([lockTag(), tokenAddress]);
93
+ return enableForcedWithdrawal(BigInt(id));
94
+ }
95
+ function disableErc20Withdrawal(tokenAddress) {
96
+ const id = (0, viem_1.concat)([lockTag(), tokenAddress]);
97
+ return disableForcedWithdrawal(BigInt(id));
98
+ }
99
+ function withdrawErc20(tokenAddress, amount) {
100
+ return {
101
+ async resolve({ accountAddress }) {
102
+ const id = (0, viem_1.concat)([lockTag(), tokenAddress]);
103
+ return forcedWithdrawal(BigInt(id), accountAddress, amount);
104
+ },
105
+ };
106
+ }
107
+ function enableForcedWithdrawal(id) {
108
+ return {
109
+ to: compact_1.COMPACT_ADDRESS,
110
+ data: (0, viem_1.encodeFunctionData)({
111
+ abi: [
112
+ {
113
+ type: 'function',
114
+ name: 'enableForcedWithdrawal',
115
+ inputs: [{ name: 'id', type: 'uint256', internalType: 'uint256' }],
116
+ outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],
117
+ stateMutability: 'nonpayable',
118
+ },
119
+ ],
120
+ functionName: 'enableForcedWithdrawal',
121
+ args: [id],
122
+ }),
123
+ value: 0n,
124
+ };
125
+ }
126
+ function disableForcedWithdrawal(id) {
127
+ return {
128
+ to: compact_1.COMPACT_ADDRESS,
129
+ data: (0, viem_1.encodeFunctionData)({
130
+ abi: [
131
+ {
132
+ type: 'function',
133
+ name: 'disableForcedWithdrawal',
134
+ inputs: [{ name: 'id', type: 'uint256', internalType: 'uint256' }],
135
+ outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],
136
+ stateMutability: 'nonpayable',
137
+ },
138
+ ],
139
+ functionName: 'disableForcedWithdrawal',
140
+ args: [id],
141
+ }),
142
+ value: 0n,
143
+ };
144
+ }
145
+ function forcedWithdrawal(id, recipient, amount) {
146
+ return {
147
+ to: compact_1.COMPACT_ADDRESS,
148
+ data: (0, viem_1.encodeFunctionData)({
149
+ abi: [
150
+ {
151
+ type: 'function',
152
+ name: 'forcedWithdrawal',
153
+ inputs: [
154
+ { name: 'id', type: 'uint256', internalType: 'uint256' },
155
+ { name: 'recipient', type: 'address', internalType: 'address' },
156
+ { name: 'amount', type: 'uint256', internalType: 'uint256' },
157
+ ],
158
+ outputs: [{ name: '', type: 'bool', internalType: 'bool' }],
159
+ stateMutability: 'nonpayable',
160
+ },
161
+ ],
162
+ functionName: 'forcedWithdrawal',
163
+ args: [id, recipient, amount],
164
+ }),
165
+ value: 0n,
166
+ };
167
+ }
168
+ function approveErc20(tokenAddress, amount) {
169
+ return {
170
+ to: tokenAddress,
171
+ value: 0n,
172
+ data: (0, viem_1.encodeFunctionData)({
173
+ abi: viem_1.erc20Abi,
174
+ functionName: 'approve',
175
+ args: [compact_1.COMPACT_ADDRESS, amount],
176
+ }),
177
+ };
178
+ }
179
+ function toCompactFlag(allocator) {
180
+ const addrBytes = Buffer.from(allocator.slice(2), 'hex');
181
+ let leadingZeroNibbles = 0;
182
+ for (const byte of addrBytes) {
183
+ if (byte === 0) {
184
+ leadingZeroNibbles += 2;
185
+ }
186
+ else {
187
+ if (byte >> 4 === 0)
188
+ leadingZeroNibbles += 1;
189
+ break;
190
+ }
191
+ }
192
+ if (leadingZeroNibbles >= 18)
193
+ return 15;
194
+ if (leadingZeroNibbles >= 4)
195
+ return leadingZeroNibbles - 3;
196
+ return 0;
197
+ }
198
+ function usingAllocatorId(allocator = ALLOCATOR_ADDRESS) {
199
+ const compactFlag = BigInt(toCompactFlag(allocator));
200
+ const last88Bits = BigInt(`0x${allocator.slice(-22)}`); // Extract last 88 bits (11 bytes * 2 hex chars per byte)
201
+ return (compactFlag << 88n) | last88Bits;
202
+ }
203
+ function lockTag() {
204
+ const allocatorId = usingAllocatorId(ALLOCATOR_ADDRESS);
205
+ const tagBig = (BigInt(DEFAULT_SCOPE) << 255n) |
206
+ (BigInt(DEFAULT_RESET_PERIOD) << 252n) |
207
+ (allocatorId << 160n);
208
+ const hex = tagBig.toString(16).slice(0, 24);
209
+ return `0x${hex}`;
210
+ }
@@ -0,0 +1,35 @@
1
+ import { type Address } from 'viem';
2
+ import type { CalldataInput, LazyCallInput } from '../types';
3
+ /**
4
+ * Enable ECDSA authentication
5
+ * @param owners Owners to use for authentication
6
+ * @param threshold Threshold for the owners
7
+ * @returns Calls to enable ECDSA authentication
8
+ */
9
+ declare function enable(owners: Address[], threshold?: number): LazyCallInput;
10
+ /**
11
+ * Disable ECDSA authentication
12
+ * @returns Calls to disable ECDSA authentication
13
+ */
14
+ declare function disable(): LazyCallInput;
15
+ /**
16
+ * Add an ECDSA owner
17
+ * @param owner Owner address
18
+ * @returns Call to add the owner
19
+ */
20
+ declare function addOwner(owner: Address): CalldataInput;
21
+ /**
22
+ * Remove an ECDSA owner
23
+ * @param prevOwner Previous owner address
24
+ * @param ownerToRemove Owner to remove
25
+ * @returns Call to remove the owner
26
+ */
27
+ declare function removeOwner(prevOwner: Address, ownerToRemove: Address): CalldataInput;
28
+ /**
29
+ * Change an account's signer threshold (ECDSA)
30
+ * @param newThreshold New threshold
31
+ * @returns Call to change the threshold
32
+ */
33
+ declare function changeThreshold(newThreshold: number): CalldataInput;
34
+ export { addOwner, removeOwner, changeThreshold, disable, enable };
35
+ //# sourceMappingURL=ecdsa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../actions/ecdsa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,MAAM,CAAA;AASvD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE5D;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,SAAS,SAAI,GAAG,aAAa,CAO/D;AAED;;;GAGG;AACH,iBAAS,OAAO,IAAI,aAAa,CAOhC;AAED;;;;GAIG;AACH,iBAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAkB/C;AAED;;;;;GAKG;AACH,iBAAS,WAAW,CAClB,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,OAAO,GACrB,aAAa,CAqBf;AAED;;;;GAIG;AACH,iBAAS,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAoB5D;AAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addOwner = addOwner;
4
+ exports.removeOwner = removeOwner;
5
+ exports.changeThreshold = changeThreshold;
6
+ exports.disable = disable;
7
+ exports.enable = enable;
8
+ const viem_1 = require("viem");
9
+ const accounts_1 = require("../accounts");
10
+ const core_1 = require("../modules/validators/core");
11
+ /**
12
+ * Enable ECDSA authentication
13
+ * @param owners Owners to use for authentication
14
+ * @param threshold Threshold for the owners
15
+ * @returns Calls to enable ECDSA authentication
16
+ */
17
+ function enable(owners, threshold = 1) {
18
+ const module = (0, core_1.getOwnableValidator)(threshold, owners);
19
+ return {
20
+ async resolve({ config }) {
21
+ return (0, accounts_1.getModuleInstallationCalls)(config, module);
22
+ },
23
+ };
24
+ }
25
+ /**
26
+ * Disable ECDSA authentication
27
+ * @returns Calls to disable ECDSA authentication
28
+ */
29
+ function disable() {
30
+ const module = (0, core_1.getOwnableValidator)(1, []);
31
+ return {
32
+ async resolve({ config }) {
33
+ return (0, accounts_1.getModuleUninstallationCalls)(config, module);
34
+ },
35
+ };
36
+ }
37
+ /**
38
+ * Add an ECDSA owner
39
+ * @param owner Owner address
40
+ * @returns Call to add the owner
41
+ */
42
+ function addOwner(owner) {
43
+ return {
44
+ to: core_1.OWNABLE_VALIDATOR_ADDRESS,
45
+ value: 0n,
46
+ data: (0, viem_1.encodeFunctionData)({
47
+ abi: [
48
+ {
49
+ inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
50
+ name: 'addOwner',
51
+ outputs: [],
52
+ stateMutability: 'nonpayable',
53
+ type: 'function',
54
+ },
55
+ ],
56
+ functionName: 'addOwner',
57
+ args: [owner],
58
+ }),
59
+ };
60
+ }
61
+ /**
62
+ * Remove an ECDSA owner
63
+ * @param prevOwner Previous owner address
64
+ * @param ownerToRemove Owner to remove
65
+ * @returns Call to remove the owner
66
+ */
67
+ function removeOwner(prevOwner, ownerToRemove) {
68
+ return {
69
+ to: core_1.OWNABLE_VALIDATOR_ADDRESS,
70
+ value: 0n,
71
+ data: (0, viem_1.encodeFunctionData)({
72
+ abi: [
73
+ {
74
+ inputs: [
75
+ { internalType: 'address', name: 'prevOwner', type: 'address' },
76
+ { internalType: 'address', name: 'owner', type: 'address' },
77
+ ],
78
+ name: 'removeOwner',
79
+ outputs: [],
80
+ stateMutability: 'nonpayable',
81
+ type: 'function',
82
+ },
83
+ ],
84
+ functionName: 'removeOwner',
85
+ args: [prevOwner, ownerToRemove],
86
+ }),
87
+ };
88
+ }
89
+ /**
90
+ * Change an account's signer threshold (ECDSA)
91
+ * @param newThreshold New threshold
92
+ * @returns Call to change the threshold
93
+ */
94
+ function changeThreshold(newThreshold) {
95
+ return {
96
+ to: core_1.OWNABLE_VALIDATOR_ADDRESS,
97
+ value: 0n,
98
+ data: (0, viem_1.encodeFunctionData)({
99
+ abi: [
100
+ {
101
+ inputs: [
102
+ { internalType: 'uint256', name: '_threshold', type: 'uint256' },
103
+ ],
104
+ name: 'setThreshold',
105
+ outputs: [],
106
+ stateMutability: 'nonpayable',
107
+ type: 'function',
108
+ },
109
+ ],
110
+ functionName: 'setThreshold',
111
+ args: [BigInt(newThreshold)],
112
+ }),
113
+ };
114
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ecdsa.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecdsa.test.d.ts","sourceRoot":"","sources":["../../../actions/ecdsa.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chains_1 = require("viem/chains");
4
+ const vitest_1 = require("vitest");
5
+ const consts_1 = require("../../test/consts");
6
+ const utils_1 = require("../execution/utils");
7
+ const index_1 = require("../index");
8
+ const ecdsa_1 = require("./ecdsa");
9
+ const MOCK_OWNER_A = '0xd1aefebdceefc094f1805b241fa5e6db63a9181a';
10
+ const MOCK_OWNER_B = '0xeddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817';
11
+ const MOCK_OWNER_C = '0xb31e76f19defe76edc4b7eceeb4b0a2d6ddaca39';
12
+ const accountAddress = '0x36C03e7D593F7B2C6b06fC18B5f4E9a4A29C99b0';
13
+ (0, vitest_1.describe)('ECDSA Actions', () => {
14
+ (0, vitest_1.describe)('Install Ownable Validator', async () => {
15
+ const rhinestone = new index_1.RhinestoneSDK();
16
+ const rhinestoneAccount = await rhinestone.createAccount({
17
+ owners: {
18
+ type: 'ecdsa',
19
+ accounts: [consts_1.accountA],
20
+ },
21
+ });
22
+ (0, vitest_1.test)('1/1 Owners', async () => {
23
+ const calls = await (0, utils_1.resolveCallInputs)([(0, ecdsa_1.enable)([MOCK_OWNER_A])], rhinestoneAccount.config, chains_1.base, accountAddress);
24
+ (0, vitest_1.expect)(calls).toEqual([
25
+ {
26
+ to: accountAddress,
27
+ value: 0n,
28
+ data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e9800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a',
29
+ },
30
+ ]);
31
+ });
32
+ (0, vitest_1.test)('1/N Owners', async () => {
33
+ const calls = await (0, utils_1.resolveCallInputs)([(0, ecdsa_1.enable)([MOCK_OWNER_A, MOCK_OWNER_B])], rhinestoneAccount.config, chains_1.base, accountAddress);
34
+ (0, vitest_1.expect)(calls).toEqual([
35
+ {
36
+ to: accountAddress,
37
+ value: 0n,
38
+ data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e98000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
39
+ },
40
+ ]);
41
+ });
42
+ (0, vitest_1.test)('M/N Owners', async () => {
43
+ const calls = await (0, utils_1.resolveCallInputs)([(0, ecdsa_1.enable)([MOCK_OWNER_A, MOCK_OWNER_B, MOCK_OWNER_C], 2)], rhinestoneAccount.config, chains_1.base, accountAddress);
44
+ (0, vitest_1.expect)(calls).toEqual([
45
+ {
46
+ to: accountAddress,
47
+ value: 0n,
48
+ data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e98000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b31e76f19defe76edc4b7eceeb4b0a2d6ddaca39000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
49
+ },
50
+ ]);
51
+ });
52
+ });
53
+ (0, vitest_1.describe)('Uninstall Ownable Validator', async () => {
54
+ const rhinestone = new index_1.RhinestoneSDK();
55
+ const rhinestoneAccount = await rhinestone.createAccount({
56
+ owners: {
57
+ type: 'ecdsa',
58
+ accounts: [consts_1.accountA],
59
+ },
60
+ });
61
+ (0, vitest_1.test)('', async () => {
62
+ const calls = await (0, utils_1.resolveCallInputs)([(0, ecdsa_1.disable)()], rhinestoneAccount.config, chains_1.base, accountAddress);
63
+ (0, vitest_1.expect)(calls).toEqual([
64
+ {
65
+ to: accountAddress,
66
+ value: 0n,
67
+ data: '0xa71763a80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e9800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000',
68
+ },
69
+ ]);
70
+ });
71
+ });
72
+ (0, vitest_1.describe)('Add Owner', () => {
73
+ (0, vitest_1.test)('', () => {
74
+ (0, vitest_1.expect)((0, ecdsa_1.addOwner)(MOCK_OWNER_A)).toEqual({
75
+ to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
76
+ value: 0n,
77
+ data: '0x7065cb48000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a',
78
+ });
79
+ });
80
+ });
81
+ (0, vitest_1.describe)('Remove Owner', () => {
82
+ (0, vitest_1.test)('', () => {
83
+ (0, vitest_1.expect)((0, ecdsa_1.removeOwner)(MOCK_OWNER_A, MOCK_OWNER_B)).toEqual({
84
+ to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
85
+ value: 0n,
86
+ data: '0xfbe5ce0a000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
87
+ });
88
+ });
89
+ });
90
+ (0, vitest_1.describe)('Set Threshold', () => {
91
+ (0, vitest_1.test)('', () => {
92
+ (0, vitest_1.expect)((0, ecdsa_1.changeThreshold)(1)).toEqual({
93
+ to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
94
+ value: 0n,
95
+ data: '0x960bfe040000000000000000000000000000000000000000000000000000000000000001',
96
+ });
97
+ });
98
+ });
99
+ });
@@ -1,167 +1,24 @@
1
- import { type Address, type Chain, type Hex } from 'viem';
2
- import type { RhinestoneAccount } from '..';
3
- import { type WebauthnCredential } from '../modules/validators/core';
4
- import type { Call, OwnableValidatorConfig, OwnerSet, ProviderConfig, Recovery, WebauthnValidatorConfig } from '../types';
5
- import { encodeSmartSessionSignature } from './smart-session';
6
- /**
7
- * Set up social recovery
8
- * @param rhinestoneAccount Account to set up social recovery on
9
- * @param guardians Guardians to use for recovery
10
- * @param threshold Threshold for the guardians
11
- * @returns Calls to set up social recovery
12
- */
13
- declare function setUpRecovery({ rhinestoneAccount, guardians, threshold, }: {
14
- rhinestoneAccount: RhinestoneAccount;
15
- } & Recovery): Call[];
16
- /**
17
- * Recover an account's ownership
18
- * @param address Account address
19
- * @param newOwners New owners
20
- * @param chain Chain to recover ownership on
21
- * @param provider Provider to use for the recovery
22
- * @returns Calls to recover ownership
23
- * @deprecated Use `recoverEcdsaOwnership` or `recoverPasskeyOwnership` instead
24
- */
25
- declare function recover(address: Address, newOwners: OwnerSet, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
26
- /**
27
- * Enable ECDSA authentication
28
- * @param rhinestoneAccount Account to enable ECDSA authentication on
29
- * @param owners Owners to use for authentication
30
- * @param threshold Threshold for the owners
31
- * @returns Calls to enable ECDSA authentication
32
- */
33
- declare function enableEcdsa({ rhinestoneAccount, owners, threshold, }: {
34
- rhinestoneAccount: RhinestoneAccount;
35
- owners: Address[];
36
- threshold?: number;
37
- }): Call[];
38
- /**
39
- * Enable passkeys authentication
40
- * @param rhinestoneAccount Account to enable passkeys authentication on
41
- * @param pubKey Public key for the passkey
42
- * @param authenticatorId Authenticator ID for the passkey
43
- * @returns Calls to enable passkeys authentication
44
- */
45
- declare function enablePasskeys({ rhinestoneAccount, pubKey, authenticatorId, }: {
46
- rhinestoneAccount: RhinestoneAccount;
47
- } & WebauthnCredential): Call[];
48
- /**
49
- * Disable ECDSA authentication
50
- * @param rhinestoneAccount Account to disable ECDSA authentication on
51
- * @returns Calls to disable ECDSA authentication
52
- */
53
- declare function disableEcdsa({ rhinestoneAccount, }: {
54
- rhinestoneAccount: RhinestoneAccount;
55
- }): Call[];
56
- /**
57
- * Disable passkeys (WebAuthn) authentication
58
- * @param rhinestoneAccount Account to disable passkeys authentication on
59
- * @returns Calls to disable passkeys authentication
60
- */
61
- declare function disablePasskeys({ rhinestoneAccount, }: {
62
- rhinestoneAccount: RhinestoneAccount;
63
- }): Call[];
64
- /**
65
- * Add an ECDSA owner
66
- * @param owner Owner address
67
- * @returns Call to add the owner
68
- */
69
- declare function addOwner(owner: Address): Call;
70
- /**
71
- * Remove an ECDSA owner
72
- * @param prevOwner Previous owner address
73
- * @param ownerToRemove Owner to remove
74
- * @returns Call to remove the owner
75
- */
76
- declare function removeOwner(prevOwner: Address, ownerToRemove: Address): Call;
77
- /**
78
- * Change an account's signer threshold (ECDSA)
79
- * @param newThreshold New threshold
80
- * @returns Call to change the threshold
81
- */
82
- declare function changeThreshold(newThreshold: number): Call;
83
- /**
84
- * Add a passkey owner
85
- * @param pubKeyX Public key X
86
- * @param pubKeyY Public key Y
87
- * @param requireUserVerification Whether to require user verification
88
- * @returns Call to add the passkey owner
89
- */
90
- declare function addPasskeyOwner(pubKeyX: bigint, pubKeyY: bigint, requireUserVerification: boolean): Call;
91
- /**
92
- * Remove a passkey owner
93
- * @param pubKeyX Public key X
94
- * @param pubKeyY Public key Y
95
- * @returns Call to remove the passkey owner
96
- */
97
- declare function removePasskeyOwner(pubKeyX: bigint, pubKeyY: bigint): Call;
98
- /**
99
- * Change an account's signer threshold (passkey)
100
- * @param newThreshold New threshold
101
- * @returns Call to change the threshold
102
- */
103
- declare function changePasskeyThreshold(newThreshold: number): Call;
104
- /**
105
- * Recover an account's ownership (ECDSA)
106
- * @param address Account address
107
- * @param newOwners New owners
108
- * @param chain Chain to recover ownership on
109
- * @param provider Provider to use for the recovery
110
- * @returns Calls to recover ownership
111
- */
112
- declare function recoverEcdsaOwnership(address: Address, newOwners: OwnableValidatorConfig, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
113
- /**
114
- * Recover an account's ownership (Passkey)
115
- * @param address Account address
116
- * @param oldCredentials Old credentials to be replaced (with pubKeyX, pubKeyY)
117
- * @param newOwners New passkey owners
118
- * @param chain Chain to recover ownership on
119
- * @param provider Provider to use for the recovery
120
- * @returns Calls to recover ownership
121
- */
122
- declare function recoverPasskeyOwnership(address: Address, oldCredentials: {
123
- pubKeyX: bigint;
124
- pubKeyY: bigint;
125
- }[], newOwners: WebauthnValidatorConfig, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
126
- /**
127
- * Enable multi-factor authentication
128
- * @param rhinestoneAccount Account to enable multi-factor authentication on
129
- * @param validators List of validators to use
130
- * @param threshold Threshold for the validators
131
- * @returns Calls to enable multi-factor authentication
132
- */
133
- declare function enableMultiFactor({ rhinestoneAccount, validators, threshold, }: {
134
- rhinestoneAccount: RhinestoneAccount;
135
- validators: (OwnableValidatorConfig | WebauthnValidatorConfig | null)[];
136
- threshold?: number;
137
- }): Call[];
138
- /**
139
- * Disable multi-factor authentication
140
- * @param rhinestoneAccount Account to disable multi-factor authentication on
141
- * @returns Calls to disable multi-factor authentication
142
- */
143
- declare function disableMultiFactor({ rhinestoneAccount, }: {
144
- rhinestoneAccount: RhinestoneAccount;
145
- }): Call[];
146
- /**
147
- * Change the multi-factor threshold
148
- * @param newThreshold New threshold
149
- * @returns Call to change the threshold
150
- */
151
- declare function changeMultiFactorThreshold(newThreshold: number): Call;
152
- /**
153
- * Set a sub-validator (multi-factor)
154
- * @param id Validator ID
155
- * @param validator Validator module
156
- * @returns Call to set the sub-validator
157
- */
158
- declare function setSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): Call;
159
- /**
160
- * Remove a sub-validator (multi-factor)
161
- * @param id Validator ID
162
- * @param validator Validator module
163
- * @returns Call to remove the sub-validator
164
- */
165
- declare function removeSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): Call;
166
- export { enableEcdsa, enablePasskeys, disableEcdsa, disablePasskeys, addOwner, removeOwner, changeThreshold, addPasskeyOwner, removePasskeyOwner, changePasskeyThreshold, recover, recoverEcdsaOwnership, recoverPasskeyOwnership, setUpRecovery, encodeSmartSessionSignature, enableMultiFactor, disableMultiFactor, changeMultiFactorThreshold, setSubValidator, removeSubValidator, };
1
+ import type { Address, Hex } from 'viem';
2
+ import { type ModuleType } from '../modules/common';
3
+ import type { LazyCallInput } from '../types';
4
+ interface ModuleInput {
5
+ type: ModuleType;
6
+ address: Address;
7
+ initData?: Hex;
8
+ deInitData?: Hex;
9
+ additionalContext?: Hex;
10
+ }
11
+ /**
12
+ * Install a custom module
13
+ * @param module Module to install
14
+ * @returns Calls to install the module
15
+ */
16
+ declare function installModule(module: ModuleInput): LazyCallInput;
17
+ /**
18
+ * Uninstall a custom module
19
+ * @param module Module to uninstall
20
+ * @returns Calls to uninstall the module
21
+ */
22
+ declare function uninstallModule(module: ModuleInput): LazyCallInput;
23
+ export { installModule, uninstallModule };
167
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAGV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;AAM3C,OAAO,EASL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EACV,IAAI,EACJ,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,uBAAuB,EACxB,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAA;AAE7D;;;;;;GAMG;AACH,iBAAS,aAAa,CAAC,EACrB,iBAAiB,EACjB,SAAS,EACT,SAAa,GACd,EAAE;IACD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