@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,54 @@
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 passkeys_1 = require("./passkeys");
9
+ const accountAddress = '0x36C03e7D593F7B2C6b06fC18B5f4E9a4A29C99b0';
10
+ (0, vitest_1.describe)('Passkeys Actions', () => {
11
+ (0, vitest_1.describe)('Install WebAuthn Validator', async () => {
12
+ const rhinestone = new __1.RhinestoneSDK();
13
+ const rhinestoneAccount = await rhinestone.createAccount({
14
+ owners: {
15
+ type: 'ecdsa',
16
+ accounts: [consts_1.accountA],
17
+ },
18
+ });
19
+ (0, vitest_1.test)('', async () => {
20
+ const calls = await (0, utils_1.resolveCallInputs)([
21
+ (0, passkeys_1.enable)({
22
+ pubKey: consts_1.passkeyAccount.publicKey,
23
+ authenticatorId: consts_1.passkeyAccount.id,
24
+ }),
25
+ ], rhinestoneAccount.config, chains_1.base, accountAddress);
26
+ (0, vitest_1.expect)(calls).toEqual([
27
+ {
28
+ to: accountAddress,
29
+ value: 0n,
30
+ data: '0x9517e29f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000578c4cb0e472a5462da43c495c3f33000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d10000000000000000000000000000000000000000000000000000000000000000',
31
+ },
32
+ ]);
33
+ });
34
+ });
35
+ (0, vitest_1.describe)('Uninstall WebAuthn Validator', async () => {
36
+ const rhinestone = new __1.RhinestoneSDK();
37
+ const rhinestoneAccount = await rhinestone.createAccount({
38
+ owners: {
39
+ type: 'ecdsa',
40
+ accounts: [consts_1.accountA],
41
+ },
42
+ });
43
+ (0, vitest_1.test)('', async () => {
44
+ const calls = await (0, utils_1.resolveCallInputs)([(0, passkeys_1.disable)()], rhinestoneAccount.config, chains_1.base, accountAddress);
45
+ (0, vitest_1.expect)(calls).toEqual([
46
+ {
47
+ to: accountAddress,
48
+ value: 0n,
49
+ data: '0xa71763a800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000578c4cb0e472a5462da43c495c3f3300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000',
50
+ },
51
+ ]);
52
+ });
53
+ });
54
+ });
@@ -0,0 +1,33 @@
1
+ import { type Account, type Address, type Chain } from 'viem';
2
+ import type { CalldataInput, LazyCallInput, OwnableValidatorConfig, RhinestoneConfig, WebauthnValidatorConfig } from '../types';
3
+ /**
4
+ * Set up social recovery
5
+ * @param guardians Guardians to use for recovery
6
+ * @param threshold Threshold for the guardians
7
+ * @returns Calls to set up social recovery
8
+ */
9
+ declare function enable(guardians: Account[], threshold?: number): LazyCallInput;
10
+ /**
11
+ * Recover an account's ownership (ECDSA)
12
+ * @param address Account address
13
+ * @param newOwners New owners
14
+ * @param chain Chain to recover ownership on
15
+ * @param provider Provider to use for the recovery
16
+ * @returns Calls to recover ownership
17
+ */
18
+ declare function recoverEcdsaOwnership(address: Address, newOwners: OwnableValidatorConfig, chain: Chain, config: RhinestoneConfig): Promise<CalldataInput[]>;
19
+ /**
20
+ * Recover an account's ownership (Passkey)
21
+ * @param address Account address
22
+ * @param oldCredentials Old credentials to be replaced (with pubKeyX, pubKeyY)
23
+ * @param newOwners New passkey owners
24
+ * @param chain Chain to recover ownership on
25
+ * @param provider Provider to use for the recovery
26
+ * @returns Calls to recover ownership
27
+ */
28
+ declare function recoverPasskeyOwnership(address: Address, oldCredentials: {
29
+ pubKeyX: bigint;
30
+ pubKeyY: bigint;
31
+ }[], newOwners: WebauthnValidatorConfig, chain: Chain, config: RhinestoneConfig): Promise<CalldataInput[]>;
32
+ export { enable, recoverEcdsaOwnership, recoverPasskeyOwnership };
33
+ //# sourceMappingURL=recovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../../../actions/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EAEX,MAAM,MAAM,CAAA;AASb,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,UAAU,CAAA;AAQjB;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,SAAS,SAAI,GAAG,aAAa,CAOlE;AAED;;;;;;;GAOG;AACH,iBAAe,qBAAqB,CAClC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,sBAAsB,EACjC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,aAAa,EAAE,CAAC,CAwG1B;AAED;;;;;;;;GAQG;AACH,iBAAe,uBAAuB,CACpC,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,EACtD,SAAS,EAAE,uBAAuB,EAClC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,aAAa,EAAE,CAAC,CA0F1B;AAED,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,CAAA"}
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enable = enable;
4
+ exports.recoverEcdsaOwnership = recoverEcdsaOwnership;
5
+ exports.recoverPasskeyOwnership = recoverPasskeyOwnership;
6
+ const viem_1 = require("viem");
7
+ const accounts_1 = require("../accounts");
8
+ const json_rpc_1 = require("../accounts/json-rpc");
9
+ const utils_1 = require("../execution/utils");
10
+ const core_1 = require("../modules/validators/core");
11
+ const ecdsa_1 = require("./ecdsa");
12
+ const passkeys_1 = require("./passkeys");
13
+ /**
14
+ * Set up social recovery
15
+ * @param guardians Guardians to use for recovery
16
+ * @param threshold Threshold for the guardians
17
+ * @returns Calls to set up social recovery
18
+ */
19
+ function enable(guardians, threshold = 1) {
20
+ const module = (0, core_1.getSocialRecoveryValidator)(guardians, threshold);
21
+ return {
22
+ async resolve({ config }) {
23
+ return (0, accounts_1.getModuleInstallationCalls)(config, module);
24
+ },
25
+ };
26
+ }
27
+ /**
28
+ * Recover an account's ownership (ECDSA)
29
+ * @param address Account address
30
+ * @param newOwners New owners
31
+ * @param chain Chain to recover ownership on
32
+ * @param provider Provider to use for the recovery
33
+ * @returns Calls to recover ownership
34
+ */
35
+ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
36
+ const publicClient = (0, viem_1.createPublicClient)({
37
+ chain,
38
+ transport: (0, json_rpc_1.createTransport)(chain, config.provider),
39
+ });
40
+ // Read the existing config
41
+ const results = await publicClient.multicall({
42
+ contracts: [
43
+ {
44
+ address: core_1.OWNABLE_VALIDATOR_ADDRESS,
45
+ abi: [
46
+ {
47
+ inputs: [
48
+ { internalType: 'address', name: 'account', type: 'address' },
49
+ ],
50
+ name: 'getOwners',
51
+ outputs: [
52
+ {
53
+ internalType: 'address[]',
54
+ name: 'ownersArray',
55
+ type: 'address[]',
56
+ },
57
+ ],
58
+ stateMutability: 'view',
59
+ type: 'function',
60
+ },
61
+ ],
62
+ functionName: 'getOwners',
63
+ args: [address],
64
+ },
65
+ {
66
+ address: core_1.OWNABLE_VALIDATOR_ADDRESS,
67
+ abi: [
68
+ {
69
+ inputs: [
70
+ { internalType: 'address', name: 'account', type: 'address' },
71
+ ],
72
+ name: 'threshold',
73
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
74
+ stateMutability: 'view',
75
+ type: 'function',
76
+ },
77
+ ],
78
+ functionName: 'threshold',
79
+ args: [address],
80
+ },
81
+ ],
82
+ });
83
+ const existingOwnersResult = results[0];
84
+ const existingThresholdResult = results[1];
85
+ if (existingOwnersResult.error || existingThresholdResult.error) {
86
+ throw new Error('Failed to read existing owners or threshold');
87
+ }
88
+ const existingOwners = existingOwnersResult.result;
89
+ const existingThreshold = existingThresholdResult.result;
90
+ const normalizedExistingOwners = existingOwners.map((owner) => owner.toLowerCase());
91
+ const callInputs = [];
92
+ // Convert new owners config to addresses and threshold
93
+ const newOwnerAddresses = newOwners.accounts
94
+ .map((account) => account.address.toLowerCase())
95
+ .sort();
96
+ const newThreshold = newOwners.threshold ?? 1;
97
+ // Check if threshold needs to be updated
98
+ if (Number(existingThreshold) !== newThreshold) {
99
+ callInputs.push((0, ecdsa_1.changeThreshold)(newThreshold));
100
+ }
101
+ const ownersToAdd = newOwnerAddresses.filter((owner) => !normalizedExistingOwners.includes(owner));
102
+ const ownersToRemove = normalizedExistingOwners.filter((owner) => !newOwnerAddresses.includes(owner));
103
+ // Maintain the list as making changes to keep track of the previous owner for removals
104
+ // Note: new owners are added to the START of the linked list
105
+ let currentOwners = [...normalizedExistingOwners];
106
+ for (const owner of ownersToAdd) {
107
+ callInputs.push((0, ecdsa_1.addOwner)(owner));
108
+ currentOwners.unshift(owner);
109
+ }
110
+ for (const ownerToRemove of ownersToRemove) {
111
+ const ownerIndex = currentOwners.indexOf(ownerToRemove);
112
+ let prevOwner;
113
+ if (ownerIndex === 0) {
114
+ // If it's the first owner, use the sentinel address
115
+ prevOwner = '0x0000000000000000000000000000000000000001';
116
+ }
117
+ else {
118
+ prevOwner = currentOwners[ownerIndex - 1];
119
+ }
120
+ callInputs.push((0, ecdsa_1.removeOwner)(prevOwner, ownerToRemove));
121
+ currentOwners = currentOwners.filter((owner) => owner !== ownerToRemove);
122
+ }
123
+ const calls = await (0, utils_1.resolveCallInputs)(callInputs, config, chain, address);
124
+ return calls;
125
+ }
126
+ /**
127
+ * Recover an account's ownership (Passkey)
128
+ * @param address Account address
129
+ * @param oldCredentials Old credentials to be replaced (with pubKeyX, pubKeyY)
130
+ * @param newOwners New passkey owners
131
+ * @param chain Chain to recover ownership on
132
+ * @param provider Provider to use for the recovery
133
+ * @returns Calls to recover ownership
134
+ */
135
+ async function recoverPasskeyOwnership(address, oldCredentials, newOwners, chain, config) {
136
+ const publicClient = (0, viem_1.createPublicClient)({
137
+ chain,
138
+ transport: (0, json_rpc_1.createTransport)(chain, config.provider),
139
+ });
140
+ const existingThreshold = await publicClient.readContract({
141
+ address: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
142
+ abi: [
143
+ {
144
+ inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
145
+ name: 'threshold',
146
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
147
+ stateMutability: 'view',
148
+ type: 'function',
149
+ },
150
+ ],
151
+ functionName: 'threshold',
152
+ args: [address],
153
+ });
154
+ const callInputs = [];
155
+ // Convert new owners config to credentials and threshold
156
+ const newCredentials = newOwners.accounts.map((account) => {
157
+ const publicKey = account.publicKey;
158
+ // Parse the public key hex string to extract x and y coordinates
159
+ const publicKeyBytes = publicKey.startsWith('0x')
160
+ ? publicKey.slice(2)
161
+ : publicKey;
162
+ // The public key is 64 bytes: 32 bytes for x, 32 bytes for y
163
+ const x = BigInt(`0x${publicKeyBytes.slice(0, 64)}`);
164
+ const y = BigInt(`0x${publicKeyBytes.slice(64, 128)}`);
165
+ return {
166
+ pubKeyX: x,
167
+ pubKeyY: y,
168
+ requireUV: false, // Default to false for now
169
+ };
170
+ });
171
+ const newThreshold = newOwners.threshold ?? 1;
172
+ // Check if threshold needs to be updated
173
+ if (Number(existingThreshold) !== newThreshold) {
174
+ callInputs.push((0, passkeys_1.changeThreshold)(newThreshold));
175
+ }
176
+ // Compare existing and new credentials to determine what to add/remove
177
+ const existingCredentialKeys = oldCredentials.map((cred) => `${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`);
178
+ const newCredentialKeys = newCredentials.map((cred) => `${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`);
179
+ // Find credentials to add (new ones not in existing)
180
+ const credentialsToAdd = newCredentials.filter((cred) => !existingCredentialKeys.includes(`${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`));
181
+ // Find credentials to remove (existing ones not in new)
182
+ const credentialsToRemove = oldCredentials.filter((cred) => !newCredentialKeys.includes(`${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`));
183
+ // Remove old credentials first (important for security in recovery scenarios)
184
+ for (const credential of credentialsToRemove) {
185
+ callInputs.push((0, passkeys_1.removeOwner)(credential.pubKeyX, credential.pubKeyY));
186
+ }
187
+ // Then add new credentials
188
+ for (const credential of credentialsToAdd) {
189
+ callInputs.push((0, passkeys_1.addOwner)(credential.pubKeyX, credential.pubKeyY, credential.requireUV));
190
+ }
191
+ const calls = await (0, utils_1.resolveCallInputs)(callInputs, config, chain, address);
192
+ return calls;
193
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=recovery.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recovery.test.d.ts","sourceRoot":"","sources":["../../../actions/recovery.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const viem_1 = require("viem");
4
+ const chains_1 = require("viem/chains");
5
+ const vitest_1 = require("vitest");
6
+ const consts_1 = require("../../test/consts");
7
+ const __1 = require("..");
8
+ const utils_1 = require("../execution/utils");
9
+ const recovery_1 = require("./recovery");
10
+ const accountAddress = '0x36C03e7D593F7B2C6b06fC18B5f4E9a4A29C99b0';
11
+ // Mock viem
12
+ vitest_1.vi.mock('viem', async (importOriginal) => {
13
+ const actual = await importOriginal();
14
+ return {
15
+ // @ts-ignore
16
+ ...actual,
17
+ createPublicClient: vitest_1.vi.fn(),
18
+ };
19
+ });
20
+ (0, vitest_1.describe)('Recovery Actions', () => {
21
+ (0, vitest_1.describe)('Set Up Recovery', async () => {
22
+ const rhinestone = new __1.RhinestoneSDK();
23
+ const rhinestoneAccount = await rhinestone.createAccount({
24
+ owners: {
25
+ type: 'ecdsa',
26
+ accounts: [consts_1.accountA],
27
+ },
28
+ });
29
+ (0, vitest_1.test)('Single Guardian', async () => {
30
+ const calls = await (0, utils_1.resolveCallInputs)([(0, recovery_1.enable)([consts_1.accountB], 1)], rhinestoneAccount.config, chains_1.base, accountAddress);
31
+ (0, vitest_1.expect)(calls).toEqual([
32
+ {
33
+ to: accountAddress,
34
+ value: 0n,
35
+ data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a04d053b3c8021e8d5bf641816c42daa75d8b597000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
36
+ },
37
+ ]);
38
+ });
39
+ (0, vitest_1.test)('Guardian Multi-Sig', async () => {
40
+ const calls = await (0, utils_1.resolveCallInputs)([(0, recovery_1.enable)([consts_1.accountB, consts_1.accountC, consts_1.accountD], 2)], rhinestoneAccount.config, chains_1.base, accountAddress);
41
+ (0, vitest_1.expect)(calls).toEqual([
42
+ {
43
+ to: accountAddress,
44
+ value: 0n,
45
+ data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a04d053b3c8021e8d5bf641816c42daa75d8b597000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
46
+ },
47
+ ]);
48
+ });
49
+ });
50
+ (0, vitest_1.describe)('Recover', () => {
51
+ const rhinestone = new __1.RhinestoneSDK();
52
+ const accountPromise = rhinestone.createAccount({
53
+ owners: {
54
+ type: 'ecdsa',
55
+ accounts: [consts_1.accountA],
56
+ },
57
+ });
58
+ const mockPublicClient = {
59
+ readContract: vitest_1.vi.fn(),
60
+ multicall: vitest_1.vi.fn(),
61
+ };
62
+ (0, vitest_1.beforeEach)(() => {
63
+ const createPublicClientMock = viem_1.createPublicClient;
64
+ createPublicClientMock.mockReturnValue(mockPublicClient);
65
+ vitest_1.vi.clearAllMocks();
66
+ });
67
+ (0, vitest_1.test)('1/1 Owners - Single owner to different single owner', async () => {
68
+ const rhinestoneAccount = await accountPromise;
69
+ // Initial state
70
+ mockPublicClient.multicall.mockResolvedValueOnce([
71
+ { result: [consts_1.accountA.address.toLowerCase()], status: 'success' },
72
+ { result: 1n, status: 'success' },
73
+ ]);
74
+ const newOwners = {
75
+ type: 'ecdsa',
76
+ accounts: [consts_1.accountB],
77
+ threshold: 1,
78
+ };
79
+ const result = await (0, recovery_1.recoverEcdsaOwnership)(accountAddress, newOwners, chains_1.base, rhinestoneAccount.config);
80
+ (0, vitest_1.expect)(mockPublicClient.multicall).toHaveBeenCalledTimes(1);
81
+ (0, vitest_1.expect)(result).toEqual([
82
+ {
83
+ to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
84
+ value: 0n,
85
+ data: '0x7065cb480000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
86
+ },
87
+ {
88
+ to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
89
+ value: 0n,
90
+ data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
91
+ },
92
+ ]);
93
+ });
94
+ (0, vitest_1.test)('1/N Owners - Single owner to multiple owners', async () => {
95
+ const rhinestoneAccount = await accountPromise;
96
+ // Initial state
97
+ mockPublicClient.multicall.mockResolvedValueOnce([
98
+ {
99
+ result: [
100
+ consts_1.accountA.address.toLowerCase(),
101
+ consts_1.accountB.address.toLowerCase(),
102
+ consts_1.accountC.address.toLowerCase(),
103
+ ],
104
+ status: 'success',
105
+ },
106
+ { result: 1n, status: 'success' },
107
+ ]);
108
+ const newOwners = {
109
+ type: 'ecdsa',
110
+ accounts: [consts_1.accountB, consts_1.accountC, consts_1.accountD],
111
+ threshold: 1,
112
+ };
113
+ const result = await (0, recovery_1.recoverEcdsaOwnership)(accountAddress, newOwners, chains_1.base, rhinestoneAccount.config);
114
+ (0, vitest_1.expect)(mockPublicClient.multicall).toHaveBeenCalledTimes(1);
115
+ (0, vitest_1.expect)(result).toEqual([
116
+ {
117
+ to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
118
+ value: 0n,
119
+ data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
120
+ },
121
+ {
122
+ to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
123
+ value: 0n,
124
+ data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
125
+ },
126
+ ]);
127
+ });
128
+ (0, vitest_1.test)('M/N Owners - Multiple owners to different multiple owners', async () => {
129
+ const rhinestoneAccount = await accountPromise;
130
+ // Initial state
131
+ mockPublicClient.multicall.mockResolvedValueOnce([
132
+ {
133
+ result: [
134
+ consts_1.accountA.address.toLowerCase(),
135
+ consts_1.accountB.address.toLowerCase(),
136
+ consts_1.accountC.address.toLowerCase(),
137
+ ],
138
+ status: 'success',
139
+ },
140
+ { result: 2n, status: 'success' },
141
+ ]);
142
+ const newOwners = {
143
+ type: 'ecdsa',
144
+ accounts: [consts_1.accountB, consts_1.accountD],
145
+ threshold: 2,
146
+ };
147
+ const result = await (0, recovery_1.recoverEcdsaOwnership)(accountAddress, newOwners, chains_1.base, rhinestoneAccount.config);
148
+ (0, vitest_1.expect)(mockPublicClient.multicall).toHaveBeenCalledTimes(1);
149
+ (0, vitest_1.expect)(result).toEqual([
150
+ {
151
+ to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
152
+ value: 0n,
153
+ data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
154
+ },
155
+ {
156
+ to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
157
+ value: 0n,
158
+ data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
159
+ },
160
+ {
161
+ to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
162
+ value: 0n,
163
+ data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596',
164
+ },
165
+ ]);
166
+ });
167
+ });
168
+ });
@@ -1,5 +1,11 @@
1
1
  import type { Hex } from 'viem';
2
2
  import type { SessionDetails } from '../execution/smart-session';
3
+ /**
4
+ * Encode a smart session signature
5
+ * @param sessionDetails Session details
6
+ * @param sessionSignature Session signature
7
+ * @returns Encoded smart session signature
8
+ */
3
9
  declare function encodeSmartSessionSignature(sessionDetails: SessionDetails, sessionSignature: Hex): `0x${string}`;
4
10
  export { encodeSmartSessionSignature };
5
11
  //# sourceMappingURL=smart-session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../actions/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE,iBAAS,2BAA2B,CAClC,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,GAAG,iBAQtB;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAA"}
1
+ {"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../actions/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE;;;;;GAKG;AACH,iBAAS,2BAA2B,CAClC,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,GAAG,iBAQtB;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAA"}
@@ -2,6 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.encodeSmartSessionSignature = encodeSmartSessionSignature;
4
4
  const smart_sessions_1 = require("../modules/validators/smart-sessions");
5
+ /**
6
+ * Encode a smart session signature
7
+ * @param sessionDetails Session details
8
+ * @param sessionSignature Session signature
9
+ * @returns Encoded smart session signature
10
+ */
5
11
  function encodeSmartSessionSignature(sessionDetails, sessionSignature) {
6
12
  return (0, smart_sessions_1.encodeSmartSessionSignature)(sessionDetails.mode, sessionDetails.enableSessionData.permissionId, sessionSignature, sessionDetails.enableSessionData);
7
13
  }
@@ -0,0 +1,5 @@
1
+ import { AccountConfigurationNotSupportedError, AccountError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError } from '../accounts';
2
+ import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError } from '../execution';
3
+ import { AuthenticationRequiredError, InsufficientBalanceError, IntentNotFoundError, InvalidApiKeyError, InvalidIntentSignatureError, isOrchestratorError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError } from '../orchestrator';
4
+ export { isAccountError, AccountError, AccountConfigurationNotSupportedError, Eip7702AccountMustHaveEoaError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, Eip7702NotSupportedForAccountError, WalletClientNoConnectedAccountError, isExecutionError, ExecutionError, IntentFailedError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError, isOrchestratorError, AuthenticationRequiredError, InsufficientBalanceError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,EACrC,YAAY,EACZ,8BAA8B,EAC9B,kCAAkC,EAClC,wCAAwC,EACxC,4BAA4B,EAC5B,cAAc,EACd,kCAAkC,EAClC,4BAA4B,EAC5B,mCAAmC,EACpC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EAChC,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,uCAAuC,EACvC,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAEL,cAAc,EACd,YAAY,EACZ,qCAAqC,EACrC,8BAA8B,EAC9B,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,kCAAkC,EAClC,kCAAkC,EAClC,mCAAmC,EAEnC,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,gCAAgC,EAChC,yBAAyB,EACzB,uBAAuB,EAEvB,mBAAmB,EACnB,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,uCAAuC,EACvC,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,CAAA"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnsupportedTokenError = exports.UnsupportedChainIdError = exports.UnsupportedChainError = exports.TokenNotSupportedError = exports.IntentNotFoundError = exports.OrchestratorError = exports.OnlyOneTargetTokenAmountCanBeUnsetError = exports.NoPathFoundError = exports.InvalidIntentSignatureError = exports.InvalidApiKeyError = exports.InsufficientBalanceError = exports.AuthenticationRequiredError = exports.isOrchestratorError = exports.SignerNotSupportedError = exports.SessionChainRequiredError = exports.OrderPathRequiredForIntentsError = exports.IntentFailedError = exports.ExecutionError = exports.isExecutionError = exports.WalletClientNoConnectedAccountError = exports.Eip7702NotSupportedForAccountError = exports.SigningNotSupportedForAccountError = exports.SmartSessionsNotEnabledError = exports.FactoryArgsNotAvailableError = exports.ExistingEip7702AccountsNotSupportedError = exports.Eip7702AccountMustHaveEoaError = exports.AccountConfigurationNotSupportedError = exports.AccountError = exports.isAccountError = void 0;
4
+ const accounts_1 = require("../accounts");
5
+ Object.defineProperty(exports, "AccountConfigurationNotSupportedError", { enumerable: true, get: function () { return accounts_1.AccountConfigurationNotSupportedError; } });
6
+ Object.defineProperty(exports, "AccountError", { enumerable: true, get: function () { return accounts_1.AccountError; } });
7
+ Object.defineProperty(exports, "Eip7702AccountMustHaveEoaError", { enumerable: true, get: function () { return accounts_1.Eip7702AccountMustHaveEoaError; } });
8
+ Object.defineProperty(exports, "Eip7702NotSupportedForAccountError", { enumerable: true, get: function () { return accounts_1.Eip7702NotSupportedForAccountError; } });
9
+ Object.defineProperty(exports, "ExistingEip7702AccountsNotSupportedError", { enumerable: true, get: function () { return accounts_1.ExistingEip7702AccountsNotSupportedError; } });
10
+ Object.defineProperty(exports, "FactoryArgsNotAvailableError", { enumerable: true, get: function () { return accounts_1.FactoryArgsNotAvailableError; } });
11
+ Object.defineProperty(exports, "isAccountError", { enumerable: true, get: function () { return accounts_1.isAccountError; } });
12
+ Object.defineProperty(exports, "SigningNotSupportedForAccountError", { enumerable: true, get: function () { return accounts_1.SigningNotSupportedForAccountError; } });
13
+ Object.defineProperty(exports, "SmartSessionsNotEnabledError", { enumerable: true, get: function () { return accounts_1.SmartSessionsNotEnabledError; } });
14
+ Object.defineProperty(exports, "WalletClientNoConnectedAccountError", { enumerable: true, get: function () { return accounts_1.WalletClientNoConnectedAccountError; } });
15
+ const execution_1 = require("../execution");
16
+ Object.defineProperty(exports, "ExecutionError", { enumerable: true, get: function () { return execution_1.ExecutionError; } });
17
+ Object.defineProperty(exports, "IntentFailedError", { enumerable: true, get: function () { return execution_1.IntentFailedError; } });
18
+ Object.defineProperty(exports, "isExecutionError", { enumerable: true, get: function () { return execution_1.isExecutionError; } });
19
+ Object.defineProperty(exports, "OrderPathRequiredForIntentsError", { enumerable: true, get: function () { return execution_1.OrderPathRequiredForIntentsError; } });
20
+ Object.defineProperty(exports, "SessionChainRequiredError", { enumerable: true, get: function () { return execution_1.SessionChainRequiredError; } });
21
+ Object.defineProperty(exports, "SignerNotSupportedError", { enumerable: true, get: function () { return execution_1.SignerNotSupportedError; } });
22
+ const orchestrator_1 = require("../orchestrator");
23
+ Object.defineProperty(exports, "AuthenticationRequiredError", { enumerable: true, get: function () { return orchestrator_1.AuthenticationRequiredError; } });
24
+ Object.defineProperty(exports, "InsufficientBalanceError", { enumerable: true, get: function () { return orchestrator_1.InsufficientBalanceError; } });
25
+ Object.defineProperty(exports, "IntentNotFoundError", { enumerable: true, get: function () { return orchestrator_1.IntentNotFoundError; } });
26
+ Object.defineProperty(exports, "InvalidApiKeyError", { enumerable: true, get: function () { return orchestrator_1.InvalidApiKeyError; } });
27
+ Object.defineProperty(exports, "InvalidIntentSignatureError", { enumerable: true, get: function () { return orchestrator_1.InvalidIntentSignatureError; } });
28
+ Object.defineProperty(exports, "isOrchestratorError", { enumerable: true, get: function () { return orchestrator_1.isOrchestratorError; } });
29
+ Object.defineProperty(exports, "NoPathFoundError", { enumerable: true, get: function () { return orchestrator_1.NoPathFoundError; } });
30
+ Object.defineProperty(exports, "OnlyOneTargetTokenAmountCanBeUnsetError", { enumerable: true, get: function () { return orchestrator_1.OnlyOneTargetTokenAmountCanBeUnsetError; } });
31
+ Object.defineProperty(exports, "OrchestratorError", { enumerable: true, get: function () { return orchestrator_1.OrchestratorError; } });
32
+ Object.defineProperty(exports, "TokenNotSupportedError", { enumerable: true, get: function () { return orchestrator_1.TokenNotSupportedError; } });
33
+ Object.defineProperty(exports, "UnsupportedChainError", { enumerable: true, get: function () { return orchestrator_1.UnsupportedChainError; } });
34
+ Object.defineProperty(exports, "UnsupportedChainIdError", { enumerable: true, get: function () { return orchestrator_1.UnsupportedChainIdError; } });
35
+ Object.defineProperty(exports, "UnsupportedTokenError", { enumerable: true, get: function () { return orchestrator_1.UnsupportedTokenError; } });