@rhinestone/sdk 1.0.0-alpha.8 → 1.0.0-beta.38

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 (153) 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 +57 -7
  4. package/dist/src/accounts/index.d.ts +30 -15
  5. package/dist/src/accounts/index.d.ts.map +1 -1
  6. package/dist/src/accounts/index.js +304 -138
  7. package/dist/src/accounts/index.test.js +3 -5
  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/index.test.d.ts.map +1 -0
  12. package/dist/src/accounts/json-rpc/index.test.js +16 -0
  13. package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
  14. package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
  15. package/dist/src/accounts/json-rpc/providers.js +14 -0
  16. package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
  17. package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
  18. package/dist/src/accounts/json-rpc/providers.test.js +15 -0
  19. package/dist/src/accounts/kernel.d.ts +4 -3
  20. package/dist/src/accounts/kernel.d.ts.map +1 -1
  21. package/dist/src/accounts/kernel.js +32 -6
  22. package/dist/src/accounts/kernel.test.js +41 -19
  23. package/dist/src/accounts/nexus.d.ts +14 -7
  24. package/dist/src/accounts/nexus.d.ts.map +1 -1
  25. package/dist/src/accounts/nexus.js +191 -34
  26. package/dist/src/accounts/nexus.test.js +44 -18
  27. package/dist/src/accounts/safe.d.ts +2 -2
  28. package/dist/src/accounts/safe.d.ts.map +1 -1
  29. package/dist/src/accounts/safe.js +88 -58
  30. package/dist/src/accounts/safe.test.js +40 -14
  31. package/dist/src/accounts/signing/common.d.ts +27 -0
  32. package/dist/src/accounts/signing/common.d.ts.map +1 -0
  33. package/dist/src/accounts/signing/common.js +145 -0
  34. package/dist/src/accounts/signing/message.d.ts +5 -0
  35. package/dist/src/accounts/signing/message.d.ts.map +1 -0
  36. package/dist/src/accounts/signing/message.js +47 -0
  37. package/dist/src/accounts/signing/passkeys.d.ts +36 -0
  38. package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
  39. package/dist/src/accounts/signing/passkeys.js +125 -0
  40. package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
  41. package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
  42. package/dist/src/accounts/signing/passkeys.test.js +88 -0
  43. package/dist/src/accounts/signing/typedData.d.ts +5 -0
  44. package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
  45. package/dist/src/accounts/signing/typedData.js +35 -0
  46. package/dist/src/accounts/startale.d.ts +20 -0
  47. package/dist/src/accounts/startale.d.ts.map +1 -0
  48. package/dist/src/accounts/startale.js +100 -0
  49. package/dist/src/accounts/startale.test.d.ts +2 -0
  50. package/dist/src/accounts/startale.test.d.ts.map +1 -0
  51. package/dist/src/accounts/startale.test.js +92 -0
  52. package/dist/src/accounts/utils.d.ts +4 -4
  53. package/dist/src/accounts/utils.d.ts.map +1 -1
  54. package/dist/src/accounts/utils.js +3 -40
  55. package/dist/src/accounts/walletClient.d.ts +7 -0
  56. package/dist/src/accounts/walletClient.d.ts.map +1 -0
  57. package/dist/src/accounts/walletClient.js +38 -0
  58. package/dist/src/actions/compact.d.ts +13 -0
  59. package/dist/src/actions/compact.d.ts.map +1 -0
  60. package/dist/src/actions/compact.js +210 -0
  61. package/dist/src/actions/ecdsa.d.ts +35 -0
  62. package/dist/src/actions/ecdsa.d.ts.map +1 -0
  63. package/dist/src/actions/ecdsa.js +114 -0
  64. package/dist/src/actions/ecdsa.test.d.ts +2 -0
  65. package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
  66. package/dist/src/actions/ecdsa.test.js +99 -0
  67. package/dist/src/actions/index.d.ts +23 -38
  68. package/dist/src/actions/index.d.ts.map +1 -1
  69. package/dist/src/actions/index.js +29 -294
  70. package/dist/src/actions/mfa.d.ts +37 -0
  71. package/dist/src/actions/mfa.d.ts.map +1 -0
  72. package/dist/src/actions/mfa.js +133 -0
  73. package/dist/src/actions/passkeys.d.ts +37 -0
  74. package/dist/src/actions/passkeys.d.ts.map +1 -0
  75. package/dist/src/actions/passkeys.js +129 -0
  76. package/dist/src/actions/passkeys.test.d.ts +2 -0
  77. package/dist/src/actions/passkeys.test.d.ts.map +1 -0
  78. package/dist/src/actions/passkeys.test.js +54 -0
  79. package/dist/src/actions/recovery.d.ts +33 -0
  80. package/dist/src/actions/recovery.d.ts.map +1 -0
  81. package/dist/src/actions/recovery.js +193 -0
  82. package/dist/src/actions/recovery.test.d.ts +2 -0
  83. package/dist/src/actions/recovery.test.d.ts.map +1 -0
  84. package/dist/src/actions/recovery.test.js +168 -0
  85. package/dist/src/actions/smart-session.d.ts +6 -0
  86. package/dist/src/actions/smart-session.d.ts.map +1 -1
  87. package/dist/src/actions/smart-session.js +6 -0
  88. package/dist/src/errors/index.d.ts +5 -0
  89. package/dist/src/errors/index.d.ts.map +1 -0
  90. package/dist/src/errors/index.js +35 -0
  91. package/dist/src/execution/compact.d.ts +150 -7
  92. package/dist/src/execution/compact.d.ts.map +1 -1
  93. package/dist/src/execution/compact.js +112 -95
  94. package/dist/src/execution/error.d.ts +2 -9
  95. package/dist/src/execution/error.d.ts.map +1 -1
  96. package/dist/src/execution/error.js +4 -13
  97. package/dist/src/execution/index.d.ts +34 -22
  98. package/dist/src/execution/index.d.ts.map +1 -1
  99. package/dist/src/execution/index.js +62 -43
  100. package/dist/src/execution/permit2.d.ts +148 -0
  101. package/dist/src/execution/permit2.d.ts.map +1 -0
  102. package/dist/src/execution/permit2.js +282 -0
  103. package/dist/src/execution/smart-session.d.ts +3 -3
  104. package/dist/src/execution/smart-session.d.ts.map +1 -1
  105. package/dist/src/execution/types.d.ts +35 -0
  106. package/dist/src/execution/types.d.ts.map +1 -0
  107. package/dist/src/execution/types.js +2 -0
  108. package/dist/src/execution/utils.d.ts +36 -27
  109. package/dist/src/execution/utils.d.ts.map +1 -1
  110. package/dist/src/execution/utils.js +357 -103
  111. package/dist/src/index.d.ts +41 -22
  112. package/dist/src/index.d.ts.map +1 -1
  113. package/dist/src/index.js +199 -65
  114. package/dist/src/modules/common.d.ts +10 -4
  115. package/dist/src/modules/common.d.ts.map +1 -1
  116. package/dist/src/modules/common.js +22 -1
  117. package/dist/src/modules/index.d.ts +4 -18
  118. package/dist/src/modules/index.d.ts.map +1 -1
  119. package/dist/src/modules/index.js +15 -63
  120. package/dist/src/modules/index.test.js +9 -26
  121. package/dist/src/modules/omni-account.d.ts +2 -1
  122. package/dist/src/modules/omni-account.d.ts.map +1 -1
  123. package/dist/src/modules/omni-account.js +3 -1
  124. package/dist/src/modules/read.d.ts.map +1 -1
  125. package/dist/src/modules/read.js +5 -0
  126. package/dist/src/modules/validators/core.d.ts +5 -3
  127. package/dist/src/modules/validators/core.d.ts.map +1 -1
  128. package/dist/src/modules/validators/core.js +64 -41
  129. package/dist/src/modules/validators/core.test.js +7 -7
  130. package/dist/src/modules/validators/smart-sessions.js +3 -3
  131. package/dist/src/modules/validators/smart-sessions.test.js +4 -7
  132. package/dist/src/orchestrator/client.d.ts +4 -4
  133. package/dist/src/orchestrator/client.d.ts.map +1 -1
  134. package/dist/src/orchestrator/client.js +30 -15
  135. package/dist/src/orchestrator/index.d.ts +2 -3
  136. package/dist/src/orchestrator/index.d.ts.map +1 -1
  137. package/dist/src/orchestrator/index.js +1 -3
  138. package/dist/src/orchestrator/registry.d.ts +1 -23
  139. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  140. package/dist/src/orchestrator/registry.js +37 -33
  141. package/dist/src/orchestrator/registry.test.js +7 -7
  142. package/dist/src/orchestrator/types.d.ts +97 -29
  143. package/dist/src/orchestrator/types.d.ts.map +1 -1
  144. package/dist/src/orchestrator/utils.d.ts +1 -3
  145. package/dist/src/orchestrator/utils.d.ts.map +1 -1
  146. package/dist/src/orchestrator/utils.js +0 -102
  147. package/dist/src/types.d.ts +74 -10
  148. package/dist/src/types.d.ts.map +1 -1
  149. package/package.json +72 -1
  150. package/dist/src/actions/index.test.d.ts.map +0 -1
  151. package/dist/src/actions/index.test.js +0 -302
  152. package/dist/src/orchestrator/registry.json +0 -365
  153. /package/dist/src/{actions → accounts/json-rpc}/index.test.d.ts +0 -0
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.walletClientToAccount = walletClientToAccount;
4
+ const error_1 = require("./error");
5
+ /**
6
+ * Adapts a Viem/Wagmi WalletClient into an Account-like signer that the SDK can consume.
7
+ * Ensures address is set and routes sign methods through the provided client.
8
+ */
9
+ function walletClientToAccount(walletClient) {
10
+ const address = walletClient.account?.address;
11
+ if (!address) {
12
+ throw new error_1.WalletClientNoConnectedAccountError();
13
+ }
14
+ const account = {
15
+ address,
16
+ // EIP-191 message signing
17
+ async signMessage({ message, }) {
18
+ return walletClient.signMessage({ account: address, message });
19
+ },
20
+ // EIP-712 typed data signing
21
+ async signTypedData(parameters) {
22
+ const def = parameters;
23
+ const signature = walletClient.signTypedData({
24
+ account: address,
25
+ ...def,
26
+ });
27
+ return signature;
28
+ },
29
+ // Raw transaction signing (not currently used by the SDK paths, but provided for completeness)
30
+ async signTransaction(transaction) {
31
+ return walletClient.signTransaction({
32
+ account: address,
33
+ ...transaction,
34
+ });
35
+ },
36
+ };
37
+ return account;
38
+ }
@@ -0,0 +1,13 @@
1
+ import { type Address } from 'viem';
2
+ import type { CalldataInput, LazyCallInput } from '../types';
3
+ declare function depositEther(value: bigint): LazyCallInput;
4
+ declare function enableEtherWithdrawal(): CalldataInput;
5
+ declare function disableEtherWithdrawal(): CalldataInput;
6
+ declare function withdrawEther(value: bigint): LazyCallInput;
7
+ declare function depositErc20(tokenAddress: Address, amount: bigint): LazyCallInput;
8
+ declare function enableErc20Withdrawal(tokenAddress: Address): CalldataInput;
9
+ declare function disableErc20Withdrawal(tokenAddress: Address): CalldataInput;
10
+ declare function withdrawErc20(tokenAddress: Address, amount: bigint): LazyCallInput;
11
+ declare function approveErc20(tokenAddress: Address, amount: bigint): CalldataInput;
12
+ export { depositEther, enableEtherWithdrawal, disableEtherWithdrawal, withdrawEther, depositErc20, enableErc20Withdrawal, disableErc20Withdrawal, withdrawErc20, approveErc20, };
13
+ //# sourceMappingURL=compact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../../actions/compact.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAMb,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAkB5D,iBAAS,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CA2BlD;AAED,iBAAS,qBAAqB,IAAI,aAAa,CAG9C;AAED,iBAAS,sBAAsB,IAAI,aAAa,CAG/C;AAED,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAOnD;AAED,iBAAS,YAAY,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CA6B1E;AAED,iBAAS,qBAAqB,CAAC,YAAY,EAAE,OAAO,GAAG,aAAa,CAGnE;AAED,iBAAS,sBAAsB,CAAC,YAAY,EAAE,OAAO,GAAG,aAAa,CAGpE;AAED,iBAAS,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAO3E;AAsED,iBAAS,YAAY,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAU1E;AAoCD,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,YAAY,GACb,CAAA"}
@@ -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 __1 = require("..");
7
+ const utils_1 = require("../execution/utils");
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 __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 __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,39 +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
- declare function setUpRecovery({ rhinestoneAccount, guardians, threshold, }: {
7
- rhinestoneAccount: RhinestoneAccount;
8
- } & Recovery): Call[];
9
- declare function recover(address: Address, newOwners: OwnerSet, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
10
- declare function enableEcdsa({ rhinestoneAccount, owners, threshold, }: {
11
- rhinestoneAccount: RhinestoneAccount;
12
- owners: Address[];
13
- threshold?: number;
14
- }): Call[];
15
- declare function enablePasskeys({ rhinestoneAccount, pubKey, authenticatorId, }: {
16
- rhinestoneAccount: RhinestoneAccount;
17
- } & WebauthnCredential): Call[];
18
- declare function disableEcdsa({ rhinestoneAccount, }: {
19
- rhinestoneAccount: RhinestoneAccount;
20
- }): Call[];
21
- declare function disablePasskeys({ rhinestoneAccount, }: {
22
- rhinestoneAccount: RhinestoneAccount;
23
- }): Call[];
24
- declare function addOwner(owner: Address): Call;
25
- declare function removeOwner(prevOwner: Address, ownerToRemove: Address): Call;
26
- declare function changeThreshold(newThreshold: number): Call;
27
- declare function enableMultiFactor({ rhinestoneAccount, validators, threshold, }: {
28
- rhinestoneAccount: RhinestoneAccount;
29
- validators: (OwnableValidatorConfig | WebauthnValidatorConfig | null)[];
30
- threshold?: number;
31
- }): Call[];
32
- declare function disableMultiFactor({ rhinestoneAccount, }: {
33
- rhinestoneAccount: RhinestoneAccount;
34
- }): Call[];
35
- declare function changeMultiFactorThreshold(newThreshold: number): Call;
36
- declare function setSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): Call;
37
- declare function removeSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): Call;
38
- export { enableEcdsa, enablePasskeys, disableEcdsa, disablePasskeys, addOwner, removeOwner, changeThreshold, recover, 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 };
39
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,E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