@rhinestone/sdk 1.4.1 → 1.5.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 (131) hide show
  1. package/README.md +89 -1
  2. package/dist/src/accounts/index.d.ts +1 -0
  3. package/dist/src/accounts/index.d.ts.map +1 -1
  4. package/dist/src/accounts/index.js +8 -2
  5. package/dist/src/accounts/json-rpc/providers.js +1 -1
  6. package/dist/src/accounts/signing/common.d.ts +8 -2
  7. package/dist/src/accounts/signing/common.d.ts.map +1 -1
  8. package/dist/src/auth/provider.d.ts +7 -0
  9. package/dist/src/auth/provider.d.ts.map +1 -0
  10. package/dist/src/auth/provider.js +41 -0
  11. package/dist/src/execution/index.d.ts +3 -2
  12. package/dist/src/execution/index.d.ts.map +1 -1
  13. package/dist/src/execution/index.js +11 -9
  14. package/dist/src/execution/utils.d.ts +7 -2
  15. package/dist/src/execution/utils.d.ts.map +1 -1
  16. package/dist/src/execution/utils.js +109 -20
  17. package/dist/src/index.d.ts +3 -3
  18. package/dist/src/index.d.ts.map +1 -1
  19. package/dist/src/index.js +6 -5
  20. package/dist/src/jwt-server/digest.d.ts +11 -0
  21. package/dist/src/jwt-server/digest.d.ts.map +1 -0
  22. package/dist/src/jwt-server/digest.js +22 -0
  23. package/dist/src/jwt-server/express.d.ts +16 -0
  24. package/dist/src/jwt-server/express.d.ts.map +1 -0
  25. package/dist/src/jwt-server/express.js +24 -0
  26. package/dist/src/jwt-server/handlers.d.ts +10 -0
  27. package/dist/src/jwt-server/handlers.d.ts.map +1 -0
  28. package/dist/src/jwt-server/handlers.js +41 -0
  29. package/dist/src/jwt-server/index.d.ts +8 -0
  30. package/dist/src/jwt-server/index.d.ts.map +1 -0
  31. package/dist/src/jwt-server/index.js +18 -0
  32. package/dist/src/jwt-server/jcs.d.ts +12 -0
  33. package/dist/src/jwt-server/jcs.d.ts.map +1 -0
  34. package/dist/src/jwt-server/jcs.js +60 -0
  35. package/dist/src/jwt-server/signer.d.ts +18 -0
  36. package/dist/src/jwt-server/signer.d.ts.map +1 -0
  37. package/dist/src/jwt-server/signer.js +71 -0
  38. package/dist/src/jwt-server/sponsorship.d.ts +19 -0
  39. package/dist/src/jwt-server/sponsorship.d.ts.map +1 -0
  40. package/dist/src/jwt-server/sponsorship.js +56 -0
  41. package/dist/src/jwt-server/web.d.ts +4 -0
  42. package/dist/src/jwt-server/web.d.ts.map +1 -0
  43. package/dist/src/jwt-server/web.js +27 -0
  44. package/dist/src/modules/validators/index.d.ts +2 -2
  45. package/dist/src/modules/validators/index.d.ts.map +1 -1
  46. package/dist/src/modules/validators/index.js +4 -1
  47. package/dist/src/modules/validators/policies/claim/permit2.d.ts +55 -0
  48. package/dist/src/modules/validators/policies/claim/permit2.d.ts.map +1 -0
  49. package/dist/src/modules/validators/policies/claim/permit2.js +239 -0
  50. package/dist/src/modules/validators/policies/claim/types.d.ts +12 -0
  51. package/dist/src/modules/validators/policies/claim/types.d.ts.map +1 -0
  52. package/dist/src/modules/validators/policies/claim/types.js +18 -0
  53. package/dist/src/modules/validators/smart-sessions.d.ts +15 -4
  54. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
  55. package/dist/src/modules/validators/smart-sessions.js +63 -19
  56. package/dist/src/orchestrator/client.d.ts +9 -4
  57. package/dist/src/orchestrator/client.d.ts.map +1 -1
  58. package/dist/src/orchestrator/client.js +29 -17
  59. package/dist/src/orchestrator/consts.d.ts +3 -2
  60. package/dist/src/orchestrator/consts.d.ts.map +1 -1
  61. package/dist/src/orchestrator/consts.js +4 -2
  62. package/dist/src/orchestrator/index.d.ts +4 -3
  63. package/dist/src/orchestrator/index.d.ts.map +1 -1
  64. package/dist/src/orchestrator/index.js +2 -2
  65. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  66. package/dist/src/orchestrator/registry.js +5 -1
  67. package/dist/src/orchestrator/types.d.ts +6 -1
  68. package/dist/src/orchestrator/types.d.ts.map +1 -1
  69. package/dist/src/types.d.ts +64 -3
  70. package/dist/src/types.d.ts.map +1 -1
  71. package/package.json +18 -4
  72. package/dist/src/accounts/index.test.d.ts +0 -2
  73. package/dist/src/accounts/index.test.d.ts.map +0 -1
  74. package/dist/src/accounts/index.test.js +0 -33
  75. package/dist/src/accounts/json-rpc/index.test.d.ts +0 -2
  76. package/dist/src/accounts/json-rpc/index.test.d.ts.map +0 -1
  77. package/dist/src/accounts/json-rpc/index.test.js +0 -35
  78. package/dist/src/accounts/json-rpc/providers.test.d.ts +0 -2
  79. package/dist/src/accounts/json-rpc/providers.test.d.ts.map +0 -1
  80. package/dist/src/accounts/json-rpc/providers.test.js +0 -43
  81. package/dist/src/accounts/kernel.test.d.ts +0 -2
  82. package/dist/src/accounts/kernel.test.d.ts.map +0 -1
  83. package/dist/src/accounts/kernel.test.js +0 -132
  84. package/dist/src/accounts/nexus.test.d.ts +0 -2
  85. package/dist/src/accounts/nexus.test.d.ts.map +0 -1
  86. package/dist/src/accounts/nexus.test.js +0 -118
  87. package/dist/src/accounts/safe.test.d.ts +0 -2
  88. package/dist/src/accounts/safe.test.d.ts.map +0 -1
  89. package/dist/src/accounts/safe.test.js +0 -168
  90. package/dist/src/accounts/signing/passkeys.test.d.ts +0 -2
  91. package/dist/src/accounts/signing/passkeys.test.d.ts.map +0 -1
  92. package/dist/src/accounts/signing/passkeys.test.js +0 -88
  93. package/dist/src/accounts/startale.test.d.ts +0 -2
  94. package/dist/src/accounts/startale.test.d.ts.map +0 -1
  95. package/dist/src/accounts/startale.test.js +0 -189
  96. package/dist/src/accounts/utils.test.d.ts +0 -2
  97. package/dist/src/accounts/utils.test.d.ts.map +0 -1
  98. package/dist/src/accounts/utils.test.js +0 -49
  99. package/dist/src/actions/ecdsa.test.d.ts +0 -2
  100. package/dist/src/actions/ecdsa.test.d.ts.map +0 -1
  101. package/dist/src/actions/ecdsa.test.js +0 -99
  102. package/dist/src/actions/passkeys.test.d.ts +0 -2
  103. package/dist/src/actions/passkeys.test.d.ts.map +0 -1
  104. package/dist/src/actions/passkeys.test.js +0 -54
  105. package/dist/src/actions/recovery.test.d.ts +0 -2
  106. package/dist/src/actions/recovery.test.d.ts.map +0 -1
  107. package/dist/src/actions/recovery.test.js +0 -168
  108. package/dist/src/execution/utils.test.d.ts +0 -2
  109. package/dist/src/execution/utils.test.d.ts.map +0 -1
  110. package/dist/src/execution/utils.test.js +0 -205
  111. package/dist/src/modules/index.test.d.ts +0 -2
  112. package/dist/src/modules/index.test.d.ts.map +0 -1
  113. package/dist/src/modules/index.test.js +0 -81
  114. package/dist/src/modules/validators/core.test.d.ts +0 -2
  115. package/dist/src/modules/validators/core.test.d.ts.map +0 -1
  116. package/dist/src/modules/validators/core.test.js +0 -101
  117. package/dist/src/modules/validators/smart-sessions.test.d.ts +0 -2
  118. package/dist/src/modules/validators/smart-sessions.test.d.ts.map +0 -1
  119. package/dist/src/modules/validators/smart-sessions.test.js +0 -61
  120. package/dist/src/orchestrator/registry.test.d.ts +0 -2
  121. package/dist/src/orchestrator/registry.test.d.ts.map +0 -1
  122. package/dist/src/orchestrator/registry.test.js +0 -154
  123. package/dist/src/utils/index.test.d.ts +0 -2
  124. package/dist/src/utils/index.test.d.ts.map +0 -1
  125. package/dist/src/utils/index.test.js +0 -42
  126. package/dist/test/consts.d.ts +0 -10
  127. package/dist/test/consts.d.ts.map +0 -1
  128. package/dist/test/consts.js +0 -22
  129. package/dist/test/utils/utils.d.ts +0 -5
  130. package/dist/test/utils/utils.d.ts.map +0 -1
  131. package/dist/test/utils/utils.js +0 -20
@@ -1,99 +0,0 @@
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({ apiKey: 'test' });
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({ apiKey: 'test' });
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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=passkeys.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"passkeys.test.d.ts","sourceRoot":"","sources":["../../../actions/passkeys.test.ts"],"names":[],"mappings":""}
@@ -1,54 +0,0 @@
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({ apiKey: 'test' });
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({ apiKey: 'test' });
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
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=recovery.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recovery.test.d.ts","sourceRoot":"","sources":["../../../actions/recovery.test.ts"],"names":[],"mappings":""}
@@ -1,168 +0,0 @@
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({ apiKey: 'test' });
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({ apiKey: 'test' });
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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=utils.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../execution/utils.test.ts"],"names":[],"mappings":""}
@@ -1,205 +0,0 @@
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 utils_1 = require("./utils");
8
- const mockGetIntentRoute = vitest_1.vi.fn();
9
- vitest_1.vi.mock('../orchestrator', () => ({
10
- getOrchestrator: () => ({
11
- getIntentRoute: mockGetIntentRoute,
12
- }),
13
- }));
14
- (0, vitest_1.describe)('hashErc7739TypedDataForSolady', () => {
15
- const verifierDomain = {
16
- name: 'Startale',
17
- version: '1.0.0',
18
- chainId: 421614,
19
- verifyingContract: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
20
- salt: '0x0000000000000000000000000000000000000000000000000000000000000000',
21
- };
22
- (0, vitest_1.test)('simple typed data', () => {
23
- const hash = (0, utils_1.hashErc7739TypedDataForSolady)({
24
- domain: {
25
- name: 'TestApp',
26
- version: '1',
27
- chainId: 421614,
28
- verifyingContract: '0x1234567890abcdef1234567890abcdef12345678',
29
- },
30
- types: {
31
- Greeting: [
32
- { name: 'text', type: 'string' },
33
- { name: 'value', type: 'uint256' },
34
- ],
35
- },
36
- primaryType: 'Greeting',
37
- message: {
38
- text: 'Hello',
39
- value: 42n,
40
- },
41
- verifierDomain,
42
- });
43
- (0, vitest_1.expect)(hash).toEqual('0xacd2d65e9986501bb617b90505f4b527ee4eac3c29ac4fea21bb74d8e754e61b');
44
- });
45
- (0, vitest_1.test)('nested types', () => {
46
- const hash = (0, utils_1.hashErc7739TypedDataForSolady)({
47
- domain: {
48
- name: 'TestApp',
49
- version: '1',
50
- chainId: 84532,
51
- verifyingContract: '0x1234567890abcdef1234567890abcdef12345678',
52
- },
53
- types: {
54
- Order: [
55
- { name: 'sender', type: 'address' },
56
- { name: 'amount', type: 'uint256' },
57
- { name: 'detail', type: 'Detail' },
58
- ],
59
- Detail: [
60
- { name: 'nonce', type: 'uint256' },
61
- { name: 'deadline', type: 'uint256' },
62
- ],
63
- },
64
- primaryType: 'Order',
65
- message: {
66
- sender: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
67
- amount: 1000000n,
68
- detail: {
69
- nonce: 1n,
70
- deadline: 1700000000n,
71
- },
72
- },
73
- verifierDomain: {
74
- ...verifierDomain,
75
- chainId: 84532,
76
- },
77
- });
78
- (0, vitest_1.expect)(hash).toEqual('0x1ea8d31e9198ac601c92ab8f54b7ff1ff41a7d4956566c1a0825a5ade5d5d045');
79
- });
80
- (0, vitest_1.test)('different verifier chainId produces different hash', () => {
81
- const params = {
82
- domain: {
83
- name: 'TestApp',
84
- version: '1',
85
- chainId: 421614,
86
- verifyingContract: '0x1234567890abcdef1234567890abcdef12345678',
87
- },
88
- types: {
89
- Greeting: [
90
- { name: 'text', type: 'string' },
91
- { name: 'value', type: 'uint256' },
92
- ],
93
- },
94
- primaryType: 'Greeting',
95
- message: {
96
- text: 'Hello',
97
- value: 42n,
98
- },
99
- };
100
- const hashSameChain = (0, utils_1.hashErc7739TypedDataForSolady)({
101
- ...params,
102
- verifierDomain,
103
- });
104
- const hashCrossChain = (0, utils_1.hashErc7739TypedDataForSolady)({
105
- ...params,
106
- verifierDomain: {
107
- ...verifierDomain,
108
- chainId: 84532,
109
- },
110
- });
111
- (0, vitest_1.expect)(hashSameChain).not.toEqual(hashCrossChain);
112
- (0, vitest_1.expect)(hashCrossChain).toEqual('0x685f60853ef1d5fcbb3021db370b6f3c1c099f1fb42f08f9ba4e6b9b7c8c941a');
113
- });
114
- });
115
- (0, vitest_1.describe)('prepareTransactionAsIntent', () => {
116
- (0, vitest_1.beforeEach)(() => {
117
- mockGetIntentRoute.mockReset();
118
- });
119
- (0, vitest_1.test)('includes auxiliaryFunds in options when provided', async () => {
120
- const auxiliaryFunds = {
121
- [chains_1.arbitrum.id]: {
122
- '0xaf88d065e77c8cC2239327C5EDb3A432268e5831': 500000000n,
123
- },
124
- };
125
- mockGetIntentRoute.mockResolvedValue({
126
- intentOp: {},
127
- intentCost: {},
128
- });
129
- await (0, utils_1.prepareTransactionAsIntent)({
130
- owners: { type: 'ecdsa', accounts: [consts_1.accountA], threshold: 1 },
131
- apiKey: 'test',
132
- }, [chains_1.arbitrum], chains_1.base, [], undefined, [{ address: viem_1.zeroAddress, amount: 1n }], undefined, false, undefined, undefined, undefined, undefined, undefined, auxiliaryFunds, undefined, undefined);
133
- (0, vitest_1.expect)(mockGetIntentRoute).toHaveBeenCalledOnce();
134
- const intentInput = mockGetIntentRoute.mock.calls[0][0];
135
- (0, vitest_1.expect)(intentInput.options.auxiliaryFunds).toEqual(auxiliaryFunds);
136
- });
137
- (0, vitest_1.test)('does not include auxiliaryFunds in options when not provided', async () => {
138
- mockGetIntentRoute.mockResolvedValue({
139
- intentOp: {},
140
- intentCost: {},
141
- });
142
- await (0, utils_1.prepareTransactionAsIntent)({
143
- owners: { type: 'ecdsa', accounts: [consts_1.accountA], threshold: 1 },
144
- apiKey: 'test',
145
- }, [chains_1.arbitrum], chains_1.base, [], undefined, [{ address: viem_1.zeroAddress, amount: 1n }], undefined, false, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined);
146
- (0, vitest_1.expect)(mockGetIntentRoute).toHaveBeenCalledOnce();
147
- const intentInput = mockGetIntentRoute.mock.calls[0][0];
148
- (0, vitest_1.expect)(intentInput.options.auxiliaryFunds).toBeUndefined();
149
- });
150
- });
151
- const makeSession = (chainId) => ({
152
- chain: { id: chainId },
153
- owners: {
154
- type: 'ecdsa',
155
- accounts: [consts_1.accountA],
156
- threshold: 1,
157
- },
158
- });
159
- (0, vitest_1.describe)('resolveSessionForChain', () => {
160
- (0, vitest_1.test)('single session returns session for any chain', () => {
161
- const signers = {
162
- type: 'experimental_session',
163
- session: makeSession(chains_1.mainnet.id),
164
- };
165
- const result = (0, utils_1.resolveSessionForChain)(signers, chains_1.optimism.id);
166
- (0, vitest_1.expect)(result).toBeDefined();
167
- (0, vitest_1.expect)(result.session).toBe(signers.session);
168
- });
169
- (0, vitest_1.test)('single session with enableData returns enableData', () => {
170
- const enableData = {
171
- userSignature: '0x00',
172
- hashesAndChainIds: [],
173
- sessionToEnableIndex: 0,
174
- };
175
- const signers = {
176
- type: 'experimental_session',
177
- session: makeSession(chains_1.mainnet.id),
178
- enableData,
179
- };
180
- const result = (0, utils_1.resolveSessionForChain)(signers, chains_1.mainnet.id);
181
- (0, vitest_1.expect)(result.enableData).toBe(enableData);
182
- });
183
- (0, vitest_1.test)('per-chain sessions returns correct session per chain', () => {
184
- const mainnetSession = makeSession(chains_1.mainnet.id);
185
- const optimismSession = makeSession(chains_1.optimism.id);
186
- const signers = {
187
- type: 'experimental_session',
188
- sessions: {
189
- [chains_1.mainnet.id]: { session: mainnetSession },
190
- [chains_1.optimism.id]: { session: optimismSession },
191
- },
192
- };
193
- (0, vitest_1.expect)((0, utils_1.resolveSessionForChain)(signers, chains_1.mainnet.id).session).toBe(mainnetSession);
194
- (0, vitest_1.expect)((0, utils_1.resolveSessionForChain)(signers, chains_1.optimism.id).session).toBe(optimismSession);
195
- });
196
- (0, vitest_1.test)('per-chain sessions throws for missing chain', () => {
197
- const signers = {
198
- type: 'experimental_session',
199
- sessions: {
200
- [chains_1.mainnet.id]: { session: makeSession(chains_1.mainnet.id) },
201
- },
202
- };
203
- (0, vitest_1.expect)(() => (0, utils_1.resolveSessionForChain)(signers, chains_1.optimism.id)).toThrow(`No session configured for chain ${chains_1.optimism.id}`);
204
- });
205
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../modules/index.test.ts"],"names":[],"mappings":""}
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const consts_1 = require("../../test/consts");
5
- const common_1 = require("./common");
6
- const index_1 = require("./index");
7
- (0, vitest_1.describe)('Modules', () => {
8
- (0, vitest_1.describe)('Setup', () => {
9
- (0, vitest_1.test)('should use ownable validator for ECDSA owners', () => {
10
- const config = {
11
- owners: {
12
- type: 'ecdsa',
13
- accounts: [consts_1.accountA],
14
- threshold: 1,
15
- },
16
- };
17
- const setup = (0, index_1.getSetup)(config);
18
- (0, vitest_1.expect)(setup.validators[0].address).toBe('0x000000000013fdb5234e4e3162a810f54d9f7e98');
19
- (0, vitest_1.expect)(setup.validators[0].type).toBe(common_1.MODULE_TYPE_ID_VALIDATOR);
20
- });
21
- (0, vitest_1.test)('should use webauthn validator for passkey owners', () => {
22
- const config = {
23
- owners: {
24
- type: 'passkey',
25
- accounts: [consts_1.passkeyAccount],
26
- },
27
- };
28
- const setup = (0, index_1.getSetup)(config);
29
- (0, vitest_1.expect)(setup.validators).toHaveLength(1);
30
- (0, vitest_1.expect)(setup.validators[0].address).toBe('0x0000000000578c4cb0e472a5462da43c495c3f33');
31
- (0, vitest_1.expect)(setup.validators[0].type).toBe(common_1.MODULE_TYPE_ID_VALIDATOR);
32
- });
33
- (0, vitest_1.test)('should use smart session validator when sessions are enabled', () => {
34
- const config = {
35
- owners: {
36
- type: 'ecdsa',
37
- accounts: [consts_1.accountA],
38
- threshold: 1,
39
- },
40
- sessions: [
41
- {
42
- owners: {
43
- type: 'ecdsa',
44
- accounts: [consts_1.accountB],
45
- threshold: 1,
46
- },
47
- },
48
- ],
49
- };
50
- const setup = (0, index_1.getSetup)(config);
51
- const smartSessionValidator = setup.validators.find((validator) => validator.address === '0x00000000008bdaba73cd9815d79069c247eb4bda');
52
- if (!smartSessionValidator) {
53
- return;
54
- }
55
- (0, vitest_1.expect)(smartSessionValidator.type).toBe(common_1.MODULE_TYPE_ID_VALIDATOR);
56
- });
57
- (0, vitest_1.test)('should use smart session compatibility fallback for safe accounts with sessions', () => {
58
- const config = {
59
- owners: {
60
- type: 'ecdsa',
61
- accounts: [consts_1.accountA],
62
- threshold: 1,
63
- },
64
- experimental_sessions: {
65
- enabled: true,
66
- },
67
- account: {
68
- type: 'safe',
69
- },
70
- };
71
- const setup = (0, index_1.getSetup)(config);
72
- const smartSessionFallback = setup.fallbacks.find((fallback) => fallback.address === '0x000000000052e9685932845660777DF43C2dC496');
73
- (0, vitest_1.expect)(smartSessionFallback).toBeDefined();
74
- if (!smartSessionFallback) {
75
- return;
76
- }
77
- (0, vitest_1.expect)(smartSessionFallback.type).toBe(common_1.MODULE_TYPE_ID_FALLBACK);
78
- });
79
- vitest_1.test.todo('using the omni account should install the necessary modules');
80
- });
81
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=core.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.test.d.ts","sourceRoot":"","sources":["../../../../modules/validators/core.test.ts"],"names":[],"mappings":""}