@rhinestone/sdk 0.8.0 → 0.8.2
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.
- package/README.md +4 -4
- package/dist/src/accounts/index.d.ts.map +1 -0
- package/dist/src/accounts/index.test.d.ts +2 -0
- package/dist/src/accounts/index.test.d.ts.map +1 -0
- package/dist/src/accounts/index.test.js +35 -0
- package/dist/src/accounts/nexus.d.ts.map +1 -0
- package/dist/src/accounts/nexus.test.d.ts +2 -0
- package/dist/src/accounts/nexus.test.d.ts.map +1 -0
- package/dist/src/accounts/nexus.test.js +39 -0
- package/dist/src/accounts/safe.d.ts.map +1 -0
- package/dist/src/accounts/safe.test.d.ts +2 -0
- package/dist/src/accounts/safe.test.d.ts.map +1 -0
- package/dist/src/accounts/safe.test.js +39 -0
- package/dist/src/accounts/utils.d.ts.map +1 -0
- package/dist/src/accounts/utils.test.d.ts +2 -0
- package/dist/src/accounts/utils.test.d.ts.map +1 -0
- package/dist/src/accounts/utils.test.js +49 -0
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/{execution → src/execution}/index.js +13 -1
- package/dist/src/execution/smart-session.d.ts.map +1 -0
- package/dist/src/execution/smart-session.test.d.ts +2 -0
- package/dist/src/execution/smart-session.test.d.ts.map +1 -0
- package/dist/src/execution/smart-session.test.js +133 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/modules/abi/smart-sessions.d.ts +104 -0
- package/dist/src/modules/abi/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/common.d.ts.map +1 -0
- package/dist/src/modules/index.d.ts.map +1 -0
- package/dist/src/modules/index.test.d.ts +2 -0
- package/dist/src/modules/index.test.d.ts.map +1 -0
- package/dist/src/modules/index.test.js +104 -0
- package/dist/src/modules/omni-account.d.ts.map +1 -0
- package/dist/src/modules/validators/core.d.ts +8 -0
- package/dist/src/modules/validators/core.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/core.js +0 -2
- package/dist/src/modules/validators/core.test.d.ts +2 -0
- package/dist/src/modules/validators/core.test.d.ts.map +1 -0
- package/dist/src/modules/validators/core.test.js +101 -0
- package/dist/src/modules/validators/index.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/smart-sessions.d.ts +34 -0
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions.test.d.ts +2 -0
- package/dist/src/modules/validators/smart-sessions.test.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions.test.js +226 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -0
- package/dist/{orchestrator → src/orchestrator}/consts.d.ts +2 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -0
- package/dist/{orchestrator → src/orchestrator}/consts.js +2 -2
- package/dist/src/orchestrator/error.d.ts.map +1 -0
- package/dist/src/orchestrator/index.d.ts.map +1 -0
- package/dist/{orchestrator → src/orchestrator}/registry.d.ts +4 -1
- package/dist/src/orchestrator/registry.d.ts.map +1 -0
- package/dist/{orchestrator → src/orchestrator}/registry.js +9 -0
- package/dist/{orchestrator → src/orchestrator}/types.d.ts +14 -15
- package/dist/src/orchestrator/types.d.ts.map +1 -0
- package/dist/src/orchestrator/utils.d.ts.map +1 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/test/consts.d.ts +9 -0
- package/dist/test/consts.d.ts.map +1 -0
- package/dist/test/consts.js +20 -0
- package/package.json +1 -1
- package/dist/accounts/index.d.ts.map +0 -1
- package/dist/accounts/nexus.d.ts.map +0 -1
- package/dist/accounts/safe.d.ts.map +0 -1
- package/dist/accounts/utils.d.ts.map +0 -1
- package/dist/execution/index.d.ts.map +0 -1
- package/dist/execution/smart-session.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/modules/abi/smart-sessions.d.ts +0 -42
- package/dist/modules/abi/smart-sessions.d.ts.map +0 -1
- package/dist/modules/common.d.ts.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/omni-account.d.ts.map +0 -1
- package/dist/modules/validators/core.d.ts +0 -23
- package/dist/modules/validators/core.d.ts.map +0 -1
- package/dist/modules/validators/index.d.ts.map +0 -1
- package/dist/modules/validators/smart-sessions.d.ts.map +0 -1
- package/dist/orchestrator/client.d.ts.map +0 -1
- package/dist/orchestrator/consts.d.ts.map +0 -1
- package/dist/orchestrator/error.d.ts.map +0 -1
- package/dist/orchestrator/index.d.ts.map +0 -1
- package/dist/orchestrator/registry.d.ts.map +0 -1
- package/dist/orchestrator/types.d.ts.map +0 -1
- package/dist/orchestrator/utils.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- /package/dist/{accounts → src/accounts}/index.d.ts +0 -0
- /package/dist/{accounts → src/accounts}/index.js +0 -0
- /package/dist/{accounts → src/accounts}/nexus.d.ts +0 -0
- /package/dist/{accounts → src/accounts}/nexus.js +0 -0
- /package/dist/{accounts → src/accounts}/safe.d.ts +0 -0
- /package/dist/{accounts → src/accounts}/safe.js +0 -0
- /package/dist/{accounts → src/accounts}/utils.d.ts +0 -0
- /package/dist/{accounts → src/accounts}/utils.js +0 -0
- /package/dist/{execution → src/execution}/index.d.ts +0 -0
- /package/dist/{execution → src/execution}/smart-session.d.ts +0 -0
- /package/dist/{execution → src/execution}/smart-session.js +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{modules → src/modules}/abi/smart-sessions.js +0 -0
- /package/dist/{modules → src/modules}/common.d.ts +0 -0
- /package/dist/{modules → src/modules}/common.js +0 -0
- /package/dist/{modules → src/modules}/index.d.ts +0 -0
- /package/dist/{modules → src/modules}/index.js +0 -0
- /package/dist/{modules → src/modules}/omni-account.d.ts +0 -0
- /package/dist/{modules → src/modules}/omni-account.js +0 -0
- /package/dist/{modules → src/modules}/validators/index.d.ts +0 -0
- /package/dist/{modules → src/modules}/validators/index.js +0 -0
- /package/dist/{modules → src/modules}/validators/smart-sessions.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/client.d.ts +0 -0
- /package/dist/{orchestrator → src/orchestrator}/client.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/error.d.ts +0 -0
- /package/dist/{orchestrator → src/orchestrator}/error.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/index.d.ts +0 -0
- /package/dist/{orchestrator → src/orchestrator}/index.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/types.js +0 -0
- /package/dist/{orchestrator → src/orchestrator}/utils.d.ts +0 -0
- /package/dist/{orchestrator → src/orchestrator}/utils.js +0 -0
- /package/dist/{types.d.ts → src/types.d.ts} +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
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 index_1 = require("./index");
|
|
6
|
+
(0, vitest_1.describe)('Modules', () => {
|
|
7
|
+
(0, vitest_1.describe)('Setup', () => {
|
|
8
|
+
(0, vitest_1.test)('should use ownable validator for ECDSA owners', () => {
|
|
9
|
+
const config = {
|
|
10
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
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('0x2483DA3A338895199E5e538530213157e931Bf06');
|
|
19
|
+
(0, vitest_1.expect)(setup.validators[0].type).toBe(1n);
|
|
20
|
+
});
|
|
21
|
+
(0, vitest_1.test)('should use webauthn validator for passkey owners', () => {
|
|
22
|
+
const config = {
|
|
23
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
24
|
+
owners: {
|
|
25
|
+
type: 'passkey',
|
|
26
|
+
account: consts_1.passkeyAccount,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const setup = (0, index_1.getSetup)(config);
|
|
30
|
+
(0, vitest_1.expect)(setup.validators).toHaveLength(1);
|
|
31
|
+
(0, vitest_1.expect)(setup.validators[0].address).toBe('0x2f167e55d42584f65e2e30a748f41ee75a311414');
|
|
32
|
+
(0, vitest_1.expect)(setup.validators[0].type).toBe(1n);
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.test)('should use smart session validator when sessions are enabled', () => {
|
|
35
|
+
const config = {
|
|
36
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
37
|
+
owners: {
|
|
38
|
+
type: 'ecdsa',
|
|
39
|
+
accounts: [consts_1.accountA],
|
|
40
|
+
threshold: 1,
|
|
41
|
+
},
|
|
42
|
+
sessions: [
|
|
43
|
+
{
|
|
44
|
+
owners: {
|
|
45
|
+
type: 'ecdsa',
|
|
46
|
+
accounts: [consts_1.accountB],
|
|
47
|
+
threshold: 1,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
const setup = (0, index_1.getSetup)(config);
|
|
53
|
+
const smartSessionValidator = setup.validators.find((validator) => validator.address === '0x00000000002b0ecfbd0496ee71e01257da0e37de');
|
|
54
|
+
if (!smartSessionValidator) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
(0, vitest_1.expect)(smartSessionValidator.type).toBe(1n);
|
|
58
|
+
});
|
|
59
|
+
(0, vitest_1.test)('should use smart session compatibility fallback for safe accounts with sessions', () => {
|
|
60
|
+
const config = {
|
|
61
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
62
|
+
owners: {
|
|
63
|
+
type: 'ecdsa',
|
|
64
|
+
accounts: [consts_1.accountA],
|
|
65
|
+
threshold: 1,
|
|
66
|
+
},
|
|
67
|
+
sessions: [
|
|
68
|
+
{
|
|
69
|
+
owners: {
|
|
70
|
+
type: 'ecdsa',
|
|
71
|
+
accounts: [consts_1.accountB],
|
|
72
|
+
threshold: 1,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
account: {
|
|
77
|
+
type: 'safe',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
const setup = (0, index_1.getSetup)(config);
|
|
81
|
+
const smartSessionFallback = setup.fallbacks.find((fallback) => fallback.address === '0x12cae64c42f362e7d5a847c2d33388373f629177');
|
|
82
|
+
(0, vitest_1.expect)(smartSessionFallback).toBeDefined();
|
|
83
|
+
if (!smartSessionFallback) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
(0, vitest_1.expect)(smartSessionFallback.type).toBe(3n);
|
|
87
|
+
});
|
|
88
|
+
vitest_1.test.todo('using the omni account should install the necessary modules');
|
|
89
|
+
});
|
|
90
|
+
(0, vitest_1.describe)('WebAuthn Validator Signature', () => {
|
|
91
|
+
(0, vitest_1.test)('default', () => {
|
|
92
|
+
const signature = (0, index_1.getWebauthnValidatorSignature)({
|
|
93
|
+
webauthn: {
|
|
94
|
+
authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d00000000',
|
|
95
|
+
clientDataJSON: '{"type":"webauthn.get","challenge":"tbxXNFS9X_4Byr1cMwqKrIGB-_30a0QhZ6y7ucM0BOE","origin":"http://localhost:3000","crossOrigin":false, "other_keys_can_be_added_here":"do not compare clientDataJSON against a template. See https://goo.gl/yabPex"}',
|
|
96
|
+
typeIndex: 44941127272049826721201904734628716258498742255959991581049806490182030242267n,
|
|
97
|
+
},
|
|
98
|
+
signature: '0x00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001635bc6d0f68ff895cae8a288ecf7542a6a9cd555df784b73e1e2ea7e9104b1db15e9015d280cb19527881c625fee43fd3a405d5b0d199a8c8e6589a7381209e40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f47b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22746278584e465339585f3442797231634d77714b724947422d5f3330613051685a36793775634d30424f45222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73652c20226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f796162506578227d000000000000000000000000',
|
|
99
|
+
usePrecompiled: true,
|
|
100
|
+
});
|
|
101
|
+
(0, vitest_1.expect)(signature).toEqual('0x00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120635bc6d0f68ff895cae8a288ecf7542a6a9cd555df784b73e1e2ea7e9104b1db00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f47b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22746278584e465339585f3442797231634d77714b724947422d5f3330613051685a36793775634d30424f45222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73652c20226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f796162506578227d000000000000000000000000');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-account.d.ts","sourceRoot":"","sources":["../../../modules/omni-account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,QAAA,MAAM,kCAAkC,EAAE,OACI,CAAA;AAE9C,QAAA,MAAM,kCAAkC,EAAE,OACI,CAAA;AAC9C,QAAA,MAAM,2BAA2B,EAAE,OACW,CAAA;AAE9C,QAAA,MAAM,YAAY,EAAE,OAAsD,CAAA;AAC1E,QAAA,MAAM,qBAAqB,EAAE,OACiB,CAAA;AAC9C,QAAA,MAAM,yBAAyB,EAAE,OACa,CAAA;AAE9C,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EAClC,2BAA2B,EAC3B,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,GAC1B,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Hex } from 'viem';
|
|
2
|
+
import type { OwnerSet, RhinestoneAccountConfig } from '../../types';
|
|
3
|
+
import { type Module } from '../common';
|
|
4
|
+
declare function getOwnerValidator(config: RhinestoneAccountConfig): Module;
|
|
5
|
+
declare function getMockSignature(ownerSet: OwnerSet): Hex;
|
|
6
|
+
declare function getValidator(owners: OwnerSet): Module;
|
|
7
|
+
export { getOwnerValidator, getValidator, getMockSignature };
|
|
8
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../modules/validators/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,GAAG,EAIT,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAEpE,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,WAAW,CAAA;AAwBjE,iBAAS,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,UAEzD;AAED,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAUjD;AAED,iBAAS,YAAY,CAAC,MAAM,EAAE,QAAQ,UAarC;AAkGD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOwnerValidator = getOwnerValidator;
|
|
4
4
|
exports.getValidator = getValidator;
|
|
5
|
-
exports.getOwnableValidator = getOwnableValidator;
|
|
6
|
-
exports.getWebAuthnValidator = getWebAuthnValidator;
|
|
7
5
|
exports.getMockSignature = getMockSignature;
|
|
8
6
|
const viem_1 = require("viem");
|
|
9
7
|
const common_1 = require("../common");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.test.d.ts","sourceRoot":"","sources":["../../../../modules/validators/core.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const viem_1 = require("viem");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const consts_1 = require("../../../test/consts");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const core_1 = require("./core");
|
|
8
|
+
(0, vitest_1.describe)('Validators Core', () => {
|
|
9
|
+
(0, vitest_1.describe)('Validator', () => {
|
|
10
|
+
(0, vitest_1.test)('ECDSA: single address', () => {
|
|
11
|
+
const validator = (0, core_1.getValidator)({
|
|
12
|
+
type: 'ecdsa',
|
|
13
|
+
accounts: [consts_1.accountA],
|
|
14
|
+
});
|
|
15
|
+
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
16
|
+
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
17
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x2483DA3A338895199E5e538530213157e931Bf06');
|
|
18
|
+
(0, vitest_1.expect)(validator.initData).toEqual('0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.test)('ECDSA: two addresses', () => {
|
|
21
|
+
const validator = (0, core_1.getValidator)({
|
|
22
|
+
type: 'ecdsa',
|
|
23
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
26
|
+
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
27
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x2483DA3A338895199E5e538530213157e931Bf06');
|
|
28
|
+
(0, vitest_1.expect)(validator.initData).toEqual('0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
29
|
+
});
|
|
30
|
+
(0, vitest_1.test)('ECDSA: three addresses, custom threshold', () => {
|
|
31
|
+
const validator = (0, core_1.getValidator)({
|
|
32
|
+
type: 'ecdsa',
|
|
33
|
+
accounts: [consts_1.accountA, consts_1.accountB, consts_1.accountC],
|
|
34
|
+
threshold: 2,
|
|
35
|
+
});
|
|
36
|
+
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
37
|
+
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
38
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x2483DA3A338895199E5e538530213157e931Bf06');
|
|
39
|
+
(0, vitest_1.expect)(validator.initData).toEqual('0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.test)('Passkey', () => {
|
|
42
|
+
const validator = (0, core_1.getValidator)({
|
|
43
|
+
type: 'passkey',
|
|
44
|
+
account: consts_1.passkeyAccount,
|
|
45
|
+
});
|
|
46
|
+
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
47
|
+
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
48
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x2f167e55d42584f65e2e30a748f41ee75a311414');
|
|
49
|
+
(0, vitest_1.expect)(validator.initData).toEqual('0x580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a');
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
(0, vitest_1.describe)('Mock Signature', () => {
|
|
53
|
+
(0, vitest_1.test)('ECDSA: single address', () => {
|
|
54
|
+
const signature = (0, core_1.getMockSignature)({
|
|
55
|
+
type: 'ecdsa',
|
|
56
|
+
accounts: [consts_1.accountA],
|
|
57
|
+
});
|
|
58
|
+
(0, vitest_1.expect)((0, viem_1.size)(signature)).toEqual(65);
|
|
59
|
+
});
|
|
60
|
+
(0, vitest_1.test)('ECDSA: multiple addresses', () => {
|
|
61
|
+
const signature = (0, core_1.getMockSignature)({
|
|
62
|
+
type: 'ecdsa',
|
|
63
|
+
accounts: [consts_1.accountA, consts_1.accountB, consts_1.accountC],
|
|
64
|
+
});
|
|
65
|
+
(0, vitest_1.expect)((0, viem_1.size)(signature)).toEqual(3 * 65);
|
|
66
|
+
});
|
|
67
|
+
(0, vitest_1.test)('Passkey', () => {
|
|
68
|
+
const signature = (0, core_1.getMockSignature)({
|
|
69
|
+
type: 'passkey',
|
|
70
|
+
account: consts_1.passkeyAccount,
|
|
71
|
+
});
|
|
72
|
+
// Should have the proper schema
|
|
73
|
+
(0, viem_1.decodeAbiParameters)([
|
|
74
|
+
{
|
|
75
|
+
type: 'bytes',
|
|
76
|
+
name: 'authenticatorData',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'string',
|
|
80
|
+
name: 'clientDataJSON',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'uint256',
|
|
84
|
+
name: 'challengeIndex',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: 'uint256',
|
|
88
|
+
name: 'typeIndex',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'uint256',
|
|
92
|
+
name: 'r',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: 'uint256',
|
|
96
|
+
name: 's',
|
|
97
|
+
},
|
|
98
|
+
], signature);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../modules/validators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,+BAA+B,EAC/B,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,sBAAsB,EACtB,gCAAgC,EACjC,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,gCAAgC,EAChC,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,+BAA+B,GAChC,CAAA"}
|
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
import { type Address, type Chain, type Hex, type PublicClient } from 'viem';
|
|
2
2
|
import type { RhinestoneAccountConfig, Session } from '../../types';
|
|
3
3
|
import { type Module } from '../common';
|
|
4
|
+
interface SessionData {
|
|
5
|
+
sessionValidator: Address;
|
|
6
|
+
sessionValidatorInitData: Hex;
|
|
7
|
+
salt: Hex;
|
|
8
|
+
userOpPolicies: readonly UserOpPolicy[];
|
|
9
|
+
erc7739Policies: {
|
|
10
|
+
allowedERC7739Content: readonly AllowedERC7739Content[];
|
|
11
|
+
erc1271Policies: readonly ERC1271Policy[];
|
|
12
|
+
};
|
|
13
|
+
actions: readonly ActionData[];
|
|
14
|
+
permitERC4337Paymaster: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface UserOpPolicy {
|
|
17
|
+
policy: Address;
|
|
18
|
+
initData: Hex;
|
|
19
|
+
}
|
|
20
|
+
interface ERC1271Policy {
|
|
21
|
+
policy: Address;
|
|
22
|
+
initData: Hex;
|
|
23
|
+
}
|
|
24
|
+
interface AllowedERC7739Content {
|
|
25
|
+
appDomainSeparator: Hex;
|
|
26
|
+
contentName: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
interface ActionData {
|
|
29
|
+
actionTarget: Address;
|
|
30
|
+
actionTargetSelector: Hex;
|
|
31
|
+
actionPolicies: readonly PolicyData[];
|
|
32
|
+
}
|
|
33
|
+
interface PolicyData {
|
|
34
|
+
policy: Address;
|
|
35
|
+
initData: Hex;
|
|
36
|
+
}
|
|
4
37
|
type SmartSessionModeType = typeof SMART_SESSION_MODE_USE | typeof SMART_SESSION_MODE_ENABLE | typeof SMART_SESSION_MODE_UNSAFE_ENABLE;
|
|
5
38
|
declare const SMART_SESSIONS_VALIDATOR_ADDRESS: Address;
|
|
6
39
|
declare const SMART_SESSION_MODE_USE = "0x00";
|
|
@@ -26,4 +59,5 @@ declare function getAccountEIP712Domain(client: PublicClient, account: Address):
|
|
|
26
59
|
salt: `0x${string}`;
|
|
27
60
|
}>;
|
|
28
61
|
export { SMART_SESSION_MODE_USE, SMART_SESSION_MODE_ENABLE, SMART_SESSIONS_VALIDATOR_ADDRESS, getSmartSessionValidator, getEnableSessionCall, encodeSmartSessionSignature, getPermissionId, getAccountEIP712Domain, isSessionEnabled, getSessionAllowedERC7739Content, };
|
|
62
|
+
export type { SessionData };
|
|
29
63
|
//# sourceMappingURL=smart-sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-sessions.d.ts","sourceRoot":"","sources":["../../../../modules/validators/smart-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAKV,KAAK,GAAG,EAIR,KAAK,YAAY,EAKlB,MAAM,MAAM,CAAA;AAMb,OAAO,KAAK,EAEV,uBAAuB,EACvB,OAAO,EAER,MAAM,aAAa,CAAA;AAEpB,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,WAAW,CAAA;AAWjE,UAAU,WAAW;IACnB,gBAAgB,EAAE,OAAO,CAAA;IACzB,wBAAwB,EAAE,GAAG,CAAA;IAC7B,IAAI,EAAE,GAAG,CAAA;IACT,cAAc,EAAE,SAAS,YAAY,EAAE,CAAA;IACvC,eAAe,EAAE;QACf,qBAAqB,EAAE,SAAS,qBAAqB,EAAE,CAAA;QACvD,eAAe,EAAE,SAAS,aAAa,EAAE,CAAA;KAC1C,CAAA;IACD,OAAO,EAAE,SAAS,UAAU,EAAE,CAAA;IAC9B,sBAAsB,EAAE,OAAO,CAAA;CAChC;AAED,UAAU,YAAY;IACpB,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,GAAG,CAAA;CACd;AAED,UAAU,aAAa;IACrB,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,GAAG,CAAA;CACd;AAED,UAAU,qBAAqB;IAC7B,kBAAkB,EAAE,GAAG,CAAA;IACvB,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CAC/B;AAED,UAAU,UAAU;IAClB,YAAY,EAAE,OAA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file":"smart-sessions.test.d.ts","sourceRoot":"","sources":["../../../../modules/validators/smart-sessions.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,226 @@
|
|
|
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 smart_sessions_1 = require("../abi/smart-sessions");
|
|
8
|
+
const common_1 = require("../common");
|
|
9
|
+
const smart_sessions_2 = require("./smart-sessions");
|
|
10
|
+
(0, vitest_1.describe)('Smart Sessions', () => {
|
|
11
|
+
(0, vitest_1.describe)('Permission ID', () => {
|
|
12
|
+
(0, vitest_1.test)('default', () => {
|
|
13
|
+
(0, vitest_1.expect)((0, smart_sessions_2.getPermissionId)({
|
|
14
|
+
owners: {
|
|
15
|
+
type: 'ecdsa',
|
|
16
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
17
|
+
},
|
|
18
|
+
})).toBe('0xa16d89135da22ae1b97b6ac6ebc047dce282640bbbf56059958d96527b720344');
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.test)('with salt', () => {
|
|
21
|
+
(0, vitest_1.expect)((0, smart_sessions_2.getPermissionId)({
|
|
22
|
+
owners: {
|
|
23
|
+
type: 'ecdsa',
|
|
24
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
25
|
+
},
|
|
26
|
+
salt: '0x97340e1cfff3319c76ef22b2bc9d3231071d550125d68c9d4a8972823f166320',
|
|
27
|
+
})).toBe('0x85ff7cd77e7e0f8fbc2e42c86cdb948e4c79ac5a5e4595def4c38d7ed804eef9');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
(0, vitest_1.describe)('Smart Session Validator', () => {
|
|
31
|
+
(0, vitest_1.test)('no session', () => {
|
|
32
|
+
(0, vitest_1.expect)((0, smart_sessions_2.getSmartSessionValidator)({
|
|
33
|
+
owners: {
|
|
34
|
+
type: 'ecdsa',
|
|
35
|
+
accounts: [consts_1.accountA],
|
|
36
|
+
},
|
|
37
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
38
|
+
})).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
(0, vitest_1.test)('empty session list', () => {
|
|
41
|
+
(0, vitest_1.expect)((0, smart_sessions_2.getSmartSessionValidator)({
|
|
42
|
+
owners: {
|
|
43
|
+
type: 'ecdsa',
|
|
44
|
+
accounts: [consts_1.accountA],
|
|
45
|
+
},
|
|
46
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
47
|
+
sessions: [],
|
|
48
|
+
})).not.toBeNull();
|
|
49
|
+
});
|
|
50
|
+
(0, vitest_1.test)('single session', () => {
|
|
51
|
+
const validator = (0, smart_sessions_2.getSmartSessionValidator)({
|
|
52
|
+
owners: {
|
|
53
|
+
type: 'ecdsa',
|
|
54
|
+
accounts: [consts_1.accountA],
|
|
55
|
+
},
|
|
56
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
57
|
+
sessions: [
|
|
58
|
+
{
|
|
59
|
+
owners: {
|
|
60
|
+
type: 'ecdsa',
|
|
61
|
+
accounts: [consts_1.accountA],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
(0, vitest_1.expect)(validator).not.toBeNull();
|
|
67
|
+
(0, vitest_1.expect)(validator?.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
68
|
+
(0, vitest_1.expect)(validator && (0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.describe)('Enable Session Call', () => {
|
|
72
|
+
vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
73
|
+
const actual = await importOriginal();
|
|
74
|
+
return {
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
...actual,
|
|
77
|
+
createPublicClient: vitest_1.vi.fn().mockReturnValue({
|
|
78
|
+
readContract: vitest_1.vi.fn(),
|
|
79
|
+
}),
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
const client = viem_1.createPublicClient;
|
|
83
|
+
client.mockImplementation((_) => {
|
|
84
|
+
return {
|
|
85
|
+
readContract: (params) => {
|
|
86
|
+
if (params.functionName === 'DOMAIN_SEPARATOR') {
|
|
87
|
+
return '0xf5f6dfa751763cc5278cba45d03ea9797c1660b2cb7f5ffd188fa3e8523abdca';
|
|
88
|
+
}
|
|
89
|
+
throw new Error('Unknown function call');
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
const TARGET = '0x063DFbDb1610EC7BbfA1fFBE603Ac5aA1B67a935';
|
|
94
|
+
const SELECTOR = '0x12345678';
|
|
95
|
+
const FALLBACK_TARGET = '0x0000000000000000000000000000000000000001';
|
|
96
|
+
const FALLBACK_SELECTOR = '0x00000001';
|
|
97
|
+
(0, vitest_1.test)('default', async () => {
|
|
98
|
+
const call = await (0, smart_sessions_2.getEnableSessionCall)(chains_1.mainnet, {
|
|
99
|
+
owners: {
|
|
100
|
+
type: 'ecdsa',
|
|
101
|
+
accounts: [consts_1.accountA],
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
const sessionData = toSessionData(call);
|
|
105
|
+
// Should have a fallback action
|
|
106
|
+
(0, vitest_1.expect)(sessionData.actions.some((action) => action.actionTarget === FALLBACK_TARGET &&
|
|
107
|
+
action.actionTargetSelector === FALLBACK_SELECTOR)).toEqual(true);
|
|
108
|
+
});
|
|
109
|
+
(0, vitest_1.test)('with action', async () => {
|
|
110
|
+
const call = await (0, smart_sessions_2.getEnableSessionCall)(chains_1.mainnet, {
|
|
111
|
+
owners: {
|
|
112
|
+
type: 'ecdsa',
|
|
113
|
+
accounts: [consts_1.accountA],
|
|
114
|
+
},
|
|
115
|
+
actions: [
|
|
116
|
+
{
|
|
117
|
+
target: TARGET,
|
|
118
|
+
selector: SELECTOR,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
});
|
|
122
|
+
const sessionData = toSessionData(call);
|
|
123
|
+
// Should have the action
|
|
124
|
+
(0, vitest_1.expect)(sessionData.actions.some((action) => action.actionTarget === TARGET &&
|
|
125
|
+
action.actionTargetSelector === SELECTOR)).toEqual(true);
|
|
126
|
+
// Should not have the fallback action
|
|
127
|
+
(0, vitest_1.expect)(sessionData.actions.some((action) => action.actionTarget === FALLBACK_TARGET &&
|
|
128
|
+
action.actionTargetSelector === FALLBACK_SELECTOR)).toEqual(false);
|
|
129
|
+
});
|
|
130
|
+
(0, vitest_1.test)('with policy', async () => {
|
|
131
|
+
const call = await (0, smart_sessions_2.getEnableSessionCall)(chains_1.mainnet, {
|
|
132
|
+
owners: {
|
|
133
|
+
type: 'ecdsa',
|
|
134
|
+
accounts: [consts_1.accountA],
|
|
135
|
+
},
|
|
136
|
+
policies: [
|
|
137
|
+
{
|
|
138
|
+
type: 'sudo',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
type: 'universal-action',
|
|
142
|
+
rules: [
|
|
143
|
+
{
|
|
144
|
+
condition: 'equal',
|
|
145
|
+
calldataOffset: 0n,
|
|
146
|
+
referenceValue: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
});
|
|
152
|
+
const sessionData = toSessionData(call);
|
|
153
|
+
// Should have two policies
|
|
154
|
+
(0, vitest_1.expect)(sessionData.userOpPolicies.length).toEqual(2);
|
|
155
|
+
(0, vitest_1.expect)((0, viem_1.isAddress)(sessionData.userOpPolicies[0].policy)).toEqual(true);
|
|
156
|
+
(0, vitest_1.expect)((0, viem_1.isHex)(sessionData.userOpPolicies[0].initData)).toEqual(true);
|
|
157
|
+
(0, vitest_1.expect)((0, viem_1.isAddress)(sessionData.userOpPolicies[1].policy)).toEqual(true);
|
|
158
|
+
(0, vitest_1.expect)((0, viem_1.isHex)(sessionData.userOpPolicies[1].initData)).toEqual(true);
|
|
159
|
+
});
|
|
160
|
+
(0, vitest_1.test)('with action policy', async () => {
|
|
161
|
+
const call = await (0, smart_sessions_2.getEnableSessionCall)(chains_1.mainnet, {
|
|
162
|
+
owners: {
|
|
163
|
+
type: 'ecdsa',
|
|
164
|
+
accounts: [consts_1.accountA],
|
|
165
|
+
},
|
|
166
|
+
actions: [
|
|
167
|
+
{
|
|
168
|
+
target: TARGET,
|
|
169
|
+
selector: SELECTOR,
|
|
170
|
+
policies: [
|
|
171
|
+
{
|
|
172
|
+
type: 'sudo',
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
type: 'universal-action',
|
|
176
|
+
rules: [
|
|
177
|
+
{
|
|
178
|
+
condition: 'equal',
|
|
179
|
+
calldataOffset: 0n,
|
|
180
|
+
referenceValue: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
});
|
|
188
|
+
const sessionData = toSessionData(call);
|
|
189
|
+
// Should have the action
|
|
190
|
+
const action = sessionData.actions.find((action) => action.actionTarget === TARGET &&
|
|
191
|
+
action.actionTargetSelector === SELECTOR);
|
|
192
|
+
(0, vitest_1.expect)(action).toBeDefined();
|
|
193
|
+
if (!action) {
|
|
194
|
+
throw new Error('No action');
|
|
195
|
+
}
|
|
196
|
+
// Should have 2 policies
|
|
197
|
+
const actionPolicies = action.actionPolicies;
|
|
198
|
+
(0, vitest_1.expect)(actionPolicies.length).toEqual(2);
|
|
199
|
+
(0, vitest_1.expect)((0, viem_1.isAddress)(actionPolicies[0].policy)).toEqual(true);
|
|
200
|
+
(0, vitest_1.expect)((0, viem_1.isHex)(actionPolicies[0].initData)).toEqual(true);
|
|
201
|
+
(0, vitest_1.expect)((0, viem_1.isAddress)(actionPolicies[1].policy)).toEqual(true);
|
|
202
|
+
(0, vitest_1.expect)((0, viem_1.isHex)(actionPolicies[1].initData)).toEqual(true);
|
|
203
|
+
});
|
|
204
|
+
function toSessionData(call) {
|
|
205
|
+
(0, vitest_1.expect)((0, viem_1.isHex)(call.data)).toEqual(true);
|
|
206
|
+
(0, vitest_1.expect)((0, viem_1.isAddress)(call.to)).toEqual(true);
|
|
207
|
+
const decoded = (0, viem_1.decodeFunctionData)({
|
|
208
|
+
abi: smart_sessions_1.enableSessionsAbi,
|
|
209
|
+
data: call.data,
|
|
210
|
+
});
|
|
211
|
+
(0, vitest_1.expect)(decoded.functionName).toEqual('enableSessions');
|
|
212
|
+
(0, vitest_1.expect)(decoded.args.length).toEqual(1);
|
|
213
|
+
(0, vitest_1.expect)(decoded.args[0].length).toEqual(1);
|
|
214
|
+
const session = decoded.args[0][0];
|
|
215
|
+
return session;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
(0, vitest_1.describe)('Encode Smart Session Signature', () => {
|
|
219
|
+
(0, vitest_1.test)('use mode', () => {
|
|
220
|
+
const permissionId = '0xa16d89135da22ae1b97b6ac6ebc047dce282640bbbf56059958d96527b720344';
|
|
221
|
+
const signature = '0xabcdef';
|
|
222
|
+
const sessionSignature = (0, smart_sessions_2.encodeSmartSessionSignature)(smart_sessions_2.SMART_SESSION_MODE_USE, permissionId, signature);
|
|
223
|
+
(0, vitest_1.expect)(sessionSignature).toEqual('0x00a16d89135da22ae1b97b6ac6ebc047dce282640bbbf56059958d96527b720344abcdef');
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../orchestrator/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAU,KAAK,GAAG,EAAE,MAAM,MAAM,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAG7D,OAAO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,EAAE,MAAM,CAAA;KAAE,CAAC;IAuBlE,OAAO,CAAC,UAAU;CA6DnB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const PROD_ORCHESTRATOR_URL = "https://orchestrator.rhinestone.
|
|
2
|
-
declare const DEV_ORCHESTRATOR_URL = "https://dev.orchestrator.rhinestone.
|
|
1
|
+
declare const PROD_ORCHESTRATOR_URL = "https://orchestrator.rhinestone.dev";
|
|
2
|
+
declare const DEV_ORCHESTRATOR_URL = "https://dev.orchestrator.rhinestone.dev";
|
|
3
3
|
declare const RHINESTONE_SPOKE_POOL_ADDRESS = "0x000000000060f6e853447881951574cdd0663530";
|
|
4
4
|
export { PROD_ORCHESTRATOR_URL, DEV_ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS, };
|
|
5
5
|
//# sourceMappingURL=consts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../orchestrator/consts.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,qBAAqB,wCAAwC,CAAA;AACnE,QAAA,MAAM,oBAAoB,4CAA4C,CAAA;AACtE,QAAA,MAAM,6BAA6B,+CACW,CAAA;AAE9C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,GAC9B,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RHINESTONE_SPOKE_POOL_ADDRESS = exports.DEV_ORCHESTRATOR_URL = exports.PROD_ORCHESTRATOR_URL = void 0;
|
|
4
|
-
const PROD_ORCHESTRATOR_URL = 'https://orchestrator.rhinestone.
|
|
4
|
+
const PROD_ORCHESTRATOR_URL = 'https://orchestrator.rhinestone.dev';
|
|
5
5
|
exports.PROD_ORCHESTRATOR_URL = PROD_ORCHESTRATOR_URL;
|
|
6
|
-
const DEV_ORCHESTRATOR_URL = 'https://dev.orchestrator.rhinestone.
|
|
6
|
+
const DEV_ORCHESTRATOR_URL = 'https://dev.orchestrator.rhinestone.dev';
|
|
7
7
|
exports.DEV_ORCHESTRATOR_URL = DEV_ORCHESTRATOR_URL;
|
|
8
8
|
const RHINESTONE_SPOKE_POOL_ADDRESS = '0x000000000060f6e853447881951574cdd0663530';
|
|
9
9
|
exports.RHINESTONE_SPOKE_POOL_ADDRESS = RHINESTONE_SPOKE_POOL_ADDRESS;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../orchestrator/error.ts"],"names":[],"mappings":"AAAA,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAK;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;gBAErB,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,OAAO,CAAC,EAAE,GAAG,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;IAQD,IAAI,OAAO,WAEV;IAED,IAAI,OAAO,QAEV;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,OAAO,WAEV;CACF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,iBAAiB,CAE5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAyB,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,SAA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nB,uBAAuB,EACvB,uBAAuB,GACxB,CAAA"}
|
|
@@ -13,5 +13,8 @@ declare function getChainById(chainId: number): Chain | undefined;
|
|
|
13
13
|
declare function isTestnet(chainId: number): boolean;
|
|
14
14
|
declare function isTokenAddressSupported(address: Address, chainId: number): boolean;
|
|
15
15
|
declare function getSupportedTokens(chainId: number): TokenConfig[];
|
|
16
|
-
|
|
16
|
+
declare function getDefaultAccountAccessList(): {
|
|
17
|
+
chainIds: (1 | 10 | 8453 | 42161)[];
|
|
18
|
+
};
|
|
19
|
+
export { getTokenSymbol, getTokenAddress, getTokenRootBalanceSlot, getTokenBalanceSlot, getWethAddress, getHookAddress, getSameChainModuleAddress, getTargetModuleAddress, getRhinestoneSpokePoolAddress, getChainById, getSupportedTokens, isTestnet, isTokenAddressSupported, getDefaultAccountAccessList, };
|
|
17
20
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAcb,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,iBAAS,cAAc,CAAC,KAAK,EAAE,KAAK,0UAoCnC;AAwCD,iBAAS,uBAAuB,CAC9B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,GACpB,MAAM,GAAG,IAAI,CAqJf;AAED,iBAAS,mBAAmB,CAC1B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,OAAO,GACtB,GAAG,CAgBL;AAED,iBAAS,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,iBAAS,yBAAyB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED,iBAAS,sBAAsB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,iBAAS,6BAA6B,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,iBAAS,cAAc,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAWtE;AAED,iBAAS,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAkBtE;AAED,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,qBAkBpC;AAED,iBAAS,SAAS,CAAC,OAAO,EAAE,MAAM,WAMjC;AAED,iBAAS,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAW3E;AAED,iBAAS,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAkB1D;AAkBD,iBAAS,2BAA2B;;EAInC;AAED,OAAO,EACL,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,6BAA6B,EAC7B,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,uBAAuB,EACvB,2BAA2B,GAC5B,CAAA"}
|
|
@@ -13,6 +13,7 @@ exports.getChainById = getChainById;
|
|
|
13
13
|
exports.getSupportedTokens = getSupportedTokens;
|
|
14
14
|
exports.isTestnet = isTestnet;
|
|
15
15
|
exports.isTokenAddressSupported = isTokenAddressSupported;
|
|
16
|
+
exports.getDefaultAccountAccessList = getDefaultAccountAccessList;
|
|
16
17
|
const viem_1 = require("viem");
|
|
17
18
|
const chains_1 = require("viem/chains");
|
|
18
19
|
function getWethAddress(chain) {
|
|
@@ -271,6 +272,9 @@ function getTokenSymbol(tokenAddress, chainId) {
|
|
|
271
272
|
throw new Error(`Unsupported token address ${tokenAddress} for chain ${chainId}`);
|
|
272
273
|
}
|
|
273
274
|
function getTokenAddress(tokenSymbol, chainId) {
|
|
275
|
+
if (chainId === 137 && tokenSymbol === 'ETH') {
|
|
276
|
+
throw new Error(`Chain ${chainId} does not allow for ETH to be used`);
|
|
277
|
+
}
|
|
274
278
|
if (tokenSymbol === 'ETH') {
|
|
275
279
|
return viem_1.zeroAddress;
|
|
276
280
|
}
|
|
@@ -356,3 +360,8 @@ function getTokenDecimals(symbol) {
|
|
|
356
360
|
throw new Error(`Symbol not supported: ${symbol}`);
|
|
357
361
|
}
|
|
358
362
|
}
|
|
363
|
+
function getDefaultAccountAccessList() {
|
|
364
|
+
return {
|
|
365
|
+
chainIds: [chains_1.mainnet.id, chains_1.base.id, chains_1.arbitrum.id, chains_1.optimism.id],
|
|
366
|
+
};
|
|
367
|
+
}
|