@rhinestone/sdk 1.0.40 → 1.0.41-alpha.0

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 (208) hide show
  1. package/package.json +1 -1
  2. package/dist/src/accounts/error.d.ts +0 -114
  3. package/dist/src/accounts/error.d.ts.map +0 -1
  4. package/dist/src/accounts/error.js +0 -174
  5. package/dist/src/accounts/index.d.ts +0 -50
  6. package/dist/src/accounts/index.d.ts.map +0 -1
  7. package/dist/src/accounts/index.js +0 -669
  8. package/dist/src/accounts/index.test.d.ts +0 -2
  9. package/dist/src/accounts/index.test.d.ts.map +0 -1
  10. package/dist/src/accounts/index.test.js +0 -33
  11. package/dist/src/accounts/json-rpc/index.d.ts +0 -5
  12. package/dist/src/accounts/json-rpc/index.d.ts.map +0 -1
  13. package/dist/src/accounts/json-rpc/index.js +0 -20
  14. package/dist/src/accounts/json-rpc/index.test.d.ts +0 -2
  15. package/dist/src/accounts/json-rpc/index.test.d.ts.map +0 -1
  16. package/dist/src/accounts/json-rpc/index.test.js +0 -33
  17. package/dist/src/accounts/json-rpc/providers.d.ts +0 -5
  18. package/dist/src/accounts/json-rpc/providers.d.ts.map +0 -1
  19. package/dist/src/accounts/json-rpc/providers.js +0 -22
  20. package/dist/src/accounts/json-rpc/providers.test.d.ts +0 -2
  21. package/dist/src/accounts/json-rpc/providers.test.d.ts.map +0 -1
  22. package/dist/src/accounts/json-rpc/providers.test.js +0 -43
  23. package/dist/src/accounts/kernel.d.ts +0 -29
  24. package/dist/src/accounts/kernel.d.ts.map +0 -1
  25. package/dist/src/accounts/kernel.js +0 -297
  26. package/dist/src/accounts/kernel.test.d.ts +0 -2
  27. package/dist/src/accounts/kernel.test.d.ts.map +0 -1
  28. package/dist/src/accounts/kernel.test.js +0 -132
  29. package/dist/src/accounts/nexus.d.ts +0 -35
  30. package/dist/src/accounts/nexus.d.ts.map +0 -1
  31. package/dist/src/accounts/nexus.js +0 -471
  32. package/dist/src/accounts/nexus.test.d.ts +0 -2
  33. package/dist/src/accounts/nexus.test.d.ts.map +0 -1
  34. package/dist/src/accounts/nexus.test.js +0 -118
  35. package/dist/src/accounts/passport.d.ts +0 -12
  36. package/dist/src/accounts/passport.d.ts.map +0 -1
  37. package/dist/src/accounts/passport.js +0 -173
  38. package/dist/src/accounts/safe.d.ts +0 -35
  39. package/dist/src/accounts/safe.d.ts.map +0 -1
  40. package/dist/src/accounts/safe.js +0 -365
  41. package/dist/src/accounts/safe.test.d.ts +0 -2
  42. package/dist/src/accounts/safe.test.d.ts.map +0 -1
  43. package/dist/src/accounts/safe.test.js +0 -118
  44. package/dist/src/accounts/signing/common.d.ts +0 -27
  45. package/dist/src/accounts/signing/common.d.ts.map +0 -1
  46. package/dist/src/accounts/signing/common.js +0 -183
  47. package/dist/src/accounts/signing/message.d.ts +0 -5
  48. package/dist/src/accounts/signing/message.d.ts.map +0 -1
  49. package/dist/src/accounts/signing/message.js +0 -47
  50. package/dist/src/accounts/signing/passkeys.d.ts +0 -36
  51. package/dist/src/accounts/signing/passkeys.d.ts.map +0 -1
  52. package/dist/src/accounts/signing/passkeys.js +0 -125
  53. package/dist/src/accounts/signing/passkeys.test.d.ts +0 -2
  54. package/dist/src/accounts/signing/passkeys.test.d.ts.map +0 -1
  55. package/dist/src/accounts/signing/passkeys.test.js +0 -88
  56. package/dist/src/accounts/signing/typedData.d.ts +0 -5
  57. package/dist/src/accounts/signing/typedData.d.ts.map +0 -1
  58. package/dist/src/accounts/signing/typedData.js +0 -35
  59. package/dist/src/accounts/startale.d.ts +0 -27
  60. package/dist/src/accounts/startale.d.ts.map +0 -1
  61. package/dist/src/accounts/startale.js +0 -116
  62. package/dist/src/accounts/startale.test.d.ts +0 -2
  63. package/dist/src/accounts/startale.test.d.ts.map +0 -1
  64. package/dist/src/accounts/startale.test.js +0 -92
  65. package/dist/src/accounts/utils.d.ts +0 -33
  66. package/dist/src/accounts/utils.d.ts.map +0 -1
  67. package/dist/src/accounts/utils.js +0 -201
  68. package/dist/src/accounts/utils.test.d.ts +0 -2
  69. package/dist/src/accounts/utils.test.d.ts.map +0 -1
  70. package/dist/src/accounts/utils.test.js +0 -49
  71. package/dist/src/accounts/walletClient.d.ts +0 -34
  72. package/dist/src/accounts/walletClient.d.ts.map +0 -1
  73. package/dist/src/accounts/walletClient.js +0 -121
  74. package/dist/src/actions/compact.d.ts +0 -13
  75. package/dist/src/actions/compact.d.ts.map +0 -1
  76. package/dist/src/actions/compact.js +0 -210
  77. package/dist/src/actions/deployment.d.ts +0 -19
  78. package/dist/src/actions/deployment.d.ts.map +0 -1
  79. package/dist/src/actions/deployment.js +0 -78
  80. package/dist/src/actions/ecdsa.d.ts +0 -35
  81. package/dist/src/actions/ecdsa.d.ts.map +0 -1
  82. package/dist/src/actions/ecdsa.js +0 -114
  83. package/dist/src/actions/ecdsa.test.d.ts +0 -2
  84. package/dist/src/actions/ecdsa.test.d.ts.map +0 -1
  85. package/dist/src/actions/ecdsa.test.js +0 -99
  86. package/dist/src/actions/index.d.ts +0 -17
  87. package/dist/src/actions/index.d.ts.map +0 -1
  88. package/dist/src/actions/index.js +0 -53
  89. package/dist/src/actions/mfa.d.ts +0 -37
  90. package/dist/src/actions/mfa.d.ts.map +0 -1
  91. package/dist/src/actions/mfa.js +0 -133
  92. package/dist/src/actions/passkeys.d.ts +0 -37
  93. package/dist/src/actions/passkeys.d.ts.map +0 -1
  94. package/dist/src/actions/passkeys.js +0 -129
  95. package/dist/src/actions/passkeys.test.d.ts +0 -2
  96. package/dist/src/actions/passkeys.test.d.ts.map +0 -1
  97. package/dist/src/actions/passkeys.test.js +0 -54
  98. package/dist/src/actions/recovery.d.ts +0 -33
  99. package/dist/src/actions/recovery.d.ts.map +0 -1
  100. package/dist/src/actions/recovery.js +0 -193
  101. package/dist/src/actions/recovery.test.d.ts +0 -2
  102. package/dist/src/actions/recovery.test.d.ts.map +0 -1
  103. package/dist/src/actions/recovery.test.js +0 -168
  104. package/dist/src/actions/smart-sessions.d.ts +0 -14
  105. package/dist/src/actions/smart-sessions.d.ts.map +0 -1
  106. package/dist/src/actions/smart-sessions.js +0 -16
  107. package/dist/src/errors/index.d.ts +0 -5
  108. package/dist/src/errors/index.d.ts.map +0 -1
  109. package/dist/src/errors/index.js +0 -53
  110. package/dist/src/execution/compact.d.ts +0 -151
  111. package/dist/src/execution/compact.d.ts.map +0 -1
  112. package/dist/src/execution/compact.js +0 -122
  113. package/dist/src/execution/error.d.ts +0 -61
  114. package/dist/src/execution/error.d.ts.map +0 -1
  115. package/dist/src/execution/error.js +0 -87
  116. package/dist/src/execution/index.d.ts +0 -41
  117. package/dist/src/execution/index.d.ts.map +0 -1
  118. package/dist/src/execution/index.js +0 -233
  119. package/dist/src/execution/permit2.d.ts +0 -148
  120. package/dist/src/execution/permit2.d.ts.map +0 -1
  121. package/dist/src/execution/permit2.js +0 -291
  122. package/dist/src/execution/singleChainOps.d.ts +0 -28
  123. package/dist/src/execution/singleChainOps.d.ts.map +0 -1
  124. package/dist/src/execution/singleChainOps.js +0 -32
  125. package/dist/src/execution/smart-session.d.ts +0 -13
  126. package/dist/src/execution/smart-session.d.ts.map +0 -1
  127. package/dist/src/execution/smart-session.js +0 -178
  128. package/dist/src/execution/types.d.ts +0 -36
  129. package/dist/src/execution/types.d.ts.map +0 -1
  130. package/dist/src/execution/types.js +0 -2
  131. package/dist/src/execution/utils.d.ts +0 -83
  132. package/dist/src/execution/utils.d.ts.map +0 -1
  133. package/dist/src/execution/utils.js +0 -705
  134. package/dist/src/index.d.ts +0 -74
  135. package/dist/src/index.d.ts.map +0 -1
  136. package/dist/src/index.js +0 -317
  137. package/dist/src/modules/abi/smart-sessions.d.ts +0 -104
  138. package/dist/src/modules/abi/smart-sessions.d.ts.map +0 -1
  139. package/dist/src/modules/abi/smart-sessions.js +0 -131
  140. package/dist/src/modules/chain-abstraction.d.ts +0 -5
  141. package/dist/src/modules/chain-abstraction.d.ts.map +0 -1
  142. package/dist/src/modules/chain-abstraction.js +0 -7
  143. package/dist/src/modules/common.d.ts +0 -30
  144. package/dist/src/modules/common.d.ts.map +0 -1
  145. package/dist/src/modules/common.js +0 -42
  146. package/dist/src/modules/index.d.ts +0 -10
  147. package/dist/src/modules/index.d.ts.map +0 -1
  148. package/dist/src/modules/index.js +0 -94
  149. package/dist/src/modules/index.test.d.ts +0 -2
  150. package/dist/src/modules/index.test.d.ts.map +0 -1
  151. package/dist/src/modules/index.test.js +0 -81
  152. package/dist/src/modules/legacy.d.ts +0 -10
  153. package/dist/src/modules/legacy.d.ts.map +0 -1
  154. package/dist/src/modules/legacy.js +0 -65
  155. package/dist/src/modules/read.d.ts +0 -9
  156. package/dist/src/modules/read.d.ts.map +0 -1
  157. package/dist/src/modules/read.js +0 -125
  158. package/dist/src/modules/validators/core.d.ts +0 -29
  159. package/dist/src/modules/validators/core.d.ts.map +0 -1
  160. package/dist/src/modules/validators/core.js +0 -278
  161. package/dist/src/modules/validators/core.test.d.ts +0 -2
  162. package/dist/src/modules/validators/core.test.d.ts.map +0 -1
  163. package/dist/src/modules/validators/core.test.js +0 -101
  164. package/dist/src/modules/validators/index.d.ts +0 -4
  165. package/dist/src/modules/validators/index.d.ts.map +0 -1
  166. package/dist/src/modules/validators/index.js +0 -15
  167. package/dist/src/modules/validators/smart-sessions.d.ts +0 -96
  168. package/dist/src/modules/validators/smart-sessions.d.ts.map +0 -1
  169. package/dist/src/modules/validators/smart-sessions.js +0 -497
  170. package/dist/src/modules/validators/smart-sessions.test.d.ts +0 -2
  171. package/dist/src/modules/validators/smart-sessions.test.d.ts.map +0 -1
  172. package/dist/src/modules/validators/smart-sessions.test.js +0 -219
  173. package/dist/src/orchestrator/client.d.ts +0 -27
  174. package/dist/src/orchestrator/client.d.ts.map +0 -1
  175. package/dist/src/orchestrator/client.js +0 -354
  176. package/dist/src/orchestrator/consts.d.ts +0 -5
  177. package/dist/src/orchestrator/consts.d.ts.map +0 -1
  178. package/dist/src/orchestrator/consts.js +0 -9
  179. package/dist/src/orchestrator/error.d.ts +0 -232
  180. package/dist/src/orchestrator/error.d.ts.map +0 -1
  181. package/dist/src/orchestrator/error.js +0 -268
  182. package/dist/src/orchestrator/index.d.ts +0 -10
  183. package/dist/src/orchestrator/index.d.ts.map +0 -1
  184. package/dist/src/orchestrator/index.js +0 -57
  185. package/dist/src/orchestrator/registry.d.ts +0 -22
  186. package/dist/src/orchestrator/registry.d.ts.map +0 -1
  187. package/dist/src/orchestrator/registry.js +0 -121
  188. package/dist/src/orchestrator/registry.test.d.ts +0 -2
  189. package/dist/src/orchestrator/registry.test.d.ts.map +0 -1
  190. package/dist/src/orchestrator/registry.test.js +0 -150
  191. package/dist/src/orchestrator/types.d.ts +0 -295
  192. package/dist/src/orchestrator/types.d.ts.map +0 -1
  193. package/dist/src/orchestrator/types.js +0 -17
  194. package/dist/src/orchestrator/utils.d.ts +0 -3
  195. package/dist/src/orchestrator/utils.d.ts.map +0 -1
  196. package/dist/src/orchestrator/utils.js +0 -24
  197. package/dist/src/types.d.ts +0 -278
  198. package/dist/src/types.d.ts.map +0 -1
  199. package/dist/src/types.js +0 -2
  200. package/dist/src/utils/index.d.ts +0 -26
  201. package/dist/src/utils/index.d.ts.map +0 -1
  202. package/dist/src/utils/index.js +0 -63
  203. package/dist/test/consts.d.ts +0 -10
  204. package/dist/test/consts.d.ts.map +0 -1
  205. package/dist/test/consts.js +0 -22
  206. package/dist/test/utils/utils.d.ts +0 -5
  207. package/dist/test/utils/utils.d.ts.map +0 -1
  208. package/dist/test/utils/utils.js +0 -20
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.walletClientToAccount = walletClientToAccount;
4
- exports.wrapParaAccount = wrapParaAccount;
5
- const error_1 = require("./error");
6
- /**
7
- * Adapts a Viem/Wagmi WalletClient into an Account-like signer that the SDK can consume.
8
- * Ensures address is set and routes sign methods through the provided client.
9
- */
10
- function walletClientToAccount(walletClient) {
11
- const address = walletClient.account?.address;
12
- if (!address) {
13
- throw new error_1.WalletClientNoConnectedAccountError();
14
- }
15
- const account = {
16
- address,
17
- // EIP-191 message signing
18
- async signMessage({ message, }) {
19
- return walletClient.signMessage({ account: address, message });
20
- },
21
- // EIP-712 typed data signing
22
- async signTypedData(parameters) {
23
- const def = parameters;
24
- const signature = walletClient.signTypedData({
25
- account: address,
26
- ...def,
27
- });
28
- return signature;
29
- },
30
- // Raw transaction signing (not currently used by the SDK paths, but provided for completeness)
31
- async signTransaction(transaction) {
32
- return walletClient.signTransaction({
33
- account: address,
34
- ...transaction,
35
- });
36
- },
37
- // Preserve reference to the wallet client
38
- // This can be helpful to e.g. get the client's transport
39
- client: walletClient,
40
- };
41
- return account;
42
- }
43
- /**
44
- * Wraps a Para viem account with custom signing for Rhinestone compatibility.
45
- *
46
- * Para's MPC signatures use 0/1 v-byte recovery, but Rhinestone/Smart wallets
47
- * expect 27/28 v-byte recovery. This wrapper adjusts Para signatures automatically.
48
- *
49
- * @param viemAccount - The Para viem account to wrap
50
- * @param walletId - Optional wallet ID for Para signing operations
51
- * @returns Account compatible with Rhinestone SDK
52
- *
53
- * @example
54
- * ```ts
55
- * const paraAccount = // ... Para viem account
56
- * const wrappedAccount = wrapParaAccount(paraAccount, wallet.id)
57
- *
58
- * const rhinestoneAccount = await rhinestone.createAccount({
59
- * owners: {
60
- * type: "ecdsa",
61
- * accounts: [wrappedAccount],
62
- * },
63
- * })
64
- *
65
- * // Also works for EIP-7702 (signAuthorization uses original 0/1 v-byte)
66
- * const authorization = await wrappedAccount.signAuthorization?.({ ... })
67
- * ```
68
- */
69
- function wrapParaAccount(viemAccount, walletId) {
70
- // Store the wallet ID for signing operations (for debugging purposes)
71
- const effectiveWalletId = walletId || viemAccount.walletId || viemAccount._walletId;
72
- // Store reference for potential debugging
73
- if (effectiveWalletId) {
74
- ;
75
- viemAccount._paraWalletId = effectiveWalletId;
76
- }
77
- return {
78
- ...viemAccount,
79
- // Override signMessage to adjust v-byte for smart wallet compatibility
80
- signMessage: async ({ message }) => {
81
- if (!viemAccount.signMessage) {
82
- throw new Error('Account does not support signMessage');
83
- }
84
- const originalSignature = await viemAccount.signMessage({ message });
85
- return adjustVByte(originalSignature);
86
- },
87
- // Override signTypedData to adjust v-byte for smart wallet compatibility
88
- signTypedData: async (typedData) => {
89
- if (!viemAccount.signTypedData) {
90
- throw new Error('Account does not support signTypedData');
91
- }
92
- const originalSignature = await viemAccount.signTypedData(typedData);
93
- return adjustVByte(originalSignature);
94
- },
95
- // Keep signAuthorization as is for EIP-7702
96
- signAuthorization: viemAccount.signAuthorization
97
- ? viemAccount.signAuthorization.bind(viemAccount)
98
- : undefined,
99
- // Preserve reference to the wallet client
100
- // This can be helpful to e.g. get the client's transport
101
- client: viemAccount.client,
102
- };
103
- }
104
- /**
105
- * Adjusts the v-byte in a signature from Para's 0/1 format to Ethereum's 27/28 format.
106
- * @internal
107
- */
108
- function adjustVByte(signature) {
109
- const V_OFFSET_FOR_ETHEREUM = 27;
110
- const cleanSig = signature.startsWith('0x') ? signature.slice(2) : signature;
111
- const r = cleanSig.slice(0, 64);
112
- const s = cleanSig.slice(64, 128);
113
- let v = parseInt(cleanSig.slice(128, 130), 16);
114
- if (v < 27) {
115
- v += V_OFFSET_FOR_ETHEREUM;
116
- }
117
- const adjustedSignature = `0x${r}${s}${v
118
- .toString(16)
119
- .padStart(2, '0')}`;
120
- return adjustedSignature;
121
- }
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,210 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
1
- import type { Address, Chain } from 'viem';
2
- import type { AccountProviderConfig, RhinestoneSDKConfig } from '../types';
3
- /**
4
- * Deploy smart accounts for multiple users from a backend using a sponsor wallet.
5
- * The sponsor pays for gas, but users own and control their accounts.
6
- */
7
- declare function deployAccountsForOwners(params: {
8
- sponsorAccount: import('viem').Account;
9
- ownerAddresses: Address[];
10
- accountConfig: AccountProviderConfig;
11
- chain: Chain;
12
- sdkConfig?: RhinestoneSDKConfig;
13
- sponsored?: boolean;
14
- }): Promise<Array<{
15
- owner: Address;
16
- account: Address;
17
- }>>;
18
- export { deployAccountsForOwners };
19
- //# sourceMappingURL=deployment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../../../actions/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAO,MAAM,MAAM,CAAA;AAQ/C,OAAO,KAAK,EACV,qBAAqB,EAErB,mBAAmB,EACpB,MAAM,UAAU,CAAA;AAyCjB;;;GAGG;AACH,iBAAe,uBAAuB,CAAC,MAAM,EAAE;IAC7C,cAAc,EAAE,OAAO,MAAM,EAAE,OAAO,CAAA;IACtC,cAAc,EAAE,OAAO,EAAE,CAAA;IACzB,aAAa,EAAE,qBAAqB,CAAA;IACpC,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,CAAC,EAAE,mBAAmB,CAAA;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,GAAG,OAAO,CAAC,KAAK,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,CAmDvD;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAA"}
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deployAccountsForOwners = deployAccountsForOwners;
4
- const viem_1 = require("viem");
5
- const accounts_1 = require("../accounts");
6
- const utils_1 = require("../accounts/utils");
7
- async function deployWithCustomFactory(sponsorConfig, chain, factoryArgs) {
8
- const sponsorOwners = sponsorConfig.owners;
9
- if (!sponsorOwners ||
10
- sponsorOwners.type !== 'ecdsa' ||
11
- sponsorOwners.accounts.length === 0) {
12
- throw new Error('Sponsor must have an ECDSA account');
13
- }
14
- const sponsorAccount = sponsorOwners.accounts[0];
15
- if (!('signTransaction' in sponsorAccount)) {
16
- throw new Error('Sponsor account must be able to sign transactions');
17
- }
18
- const publicClient = (0, viem_1.createPublicClient)({
19
- chain,
20
- transport: (0, utils_1.createTransport)(chain, sponsorConfig.provider),
21
- });
22
- const walletClient = (0, viem_1.createWalletClient)({
23
- account: sponsorAccount,
24
- chain,
25
- transport: (0, utils_1.createTransport)(chain, sponsorConfig.provider),
26
- });
27
- const hash = await walletClient.sendTransaction({
28
- to: factoryArgs.factory,
29
- data: factoryArgs.factoryData,
30
- value: 0n,
31
- });
32
- await publicClient.waitForTransactionReceipt({ hash });
33
- }
34
- /**
35
- * Deploy smart accounts for multiple users from a backend using a sponsor wallet.
36
- * The sponsor pays for gas, but users own and control their accounts.
37
- */
38
- async function deployAccountsForOwners(params) {
39
- const { sponsorAccount, ownerAddresses, accountConfig, chain, sdkConfig } = params;
40
- const results = [];
41
- for (const ownerAddress of ownerAddresses) {
42
- const ownerAccountRef = {
43
- address: ownerAddress,
44
- type: 'json-rpc',
45
- };
46
- const userConfig = {
47
- account: accountConfig,
48
- owners: {
49
- type: 'ecdsa',
50
- accounts: [ownerAccountRef],
51
- threshold: 1,
52
- },
53
- ...sdkConfig,
54
- };
55
- const accountAddress = (0, accounts_1.getAddress)(userConfig);
56
- const isAlreadyDeployed = await (0, accounts_1.isDeployed)(userConfig, chain);
57
- if (isAlreadyDeployed) {
58
- results.push({ owner: ownerAddress, account: accountAddress });
59
- continue;
60
- }
61
- const sponsorConfig = {
62
- account: accountConfig,
63
- owners: {
64
- type: 'ecdsa',
65
- accounts: [sponsorAccount],
66
- threshold: 1,
67
- },
68
- ...sdkConfig,
69
- };
70
- const initCode = (0, accounts_1.getInitCode)(userConfig);
71
- if (!initCode || !('factory' in initCode)) {
72
- throw new Error('Failed to get init code for account deployment');
73
- }
74
- await deployWithCustomFactory(sponsorConfig, chain, initCode);
75
- results.push({ owner: ownerAddress, account: accountAddress });
76
- }
77
- return results;
78
- }
@@ -1,35 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,114 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ecdsa.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ecdsa.test.d.ts","sourceRoot":"","sources":["../../../actions/ecdsa.test.ts"],"names":[],"mappings":""}