@rhinestone/sdk 0.0.0-dev-20260318153046 → 0.0.0-dev-20260318201613
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/dist/src/accounts/startale.d.ts +2 -1
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +71 -18
- package/dist/src/accounts/startale.test.js +77 -22
- package/dist/src/execution/utils.d.ts +15 -2
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +122 -6
- package/dist/src/execution/utils.test.js +101 -0
- package/dist/src/orchestrator/consts.d.ts +1 -1
- package/dist/src/orchestrator/consts.js +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import type { Address, Chain, Hex, PublicClient } from 'viem';
|
|
|
2
2
|
import type { Module } from '../modules/common';
|
|
3
3
|
import type { OwnerSet, RhinestoneAccountConfig } from '../types';
|
|
4
4
|
import type { ValidatorConfig } from './utils';
|
|
5
|
+
declare const K1_DEFAULT_VALIDATOR_ADDRESS: Address;
|
|
5
6
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
6
7
|
factory: `0x${string}`;
|
|
7
8
|
factoryData: `0x${string}`;
|
|
@@ -21,5 +22,5 @@ declare function getInstallData(module: Module): `0x${string}`;
|
|
|
21
22
|
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
22
23
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
23
24
|
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
24
|
-
export { getEip712Domain, getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getGuardianSmartAccount, };
|
|
25
|
+
export { K1_DEFAULT_VALIDATOR_ADDRESS, getEip712Domain, getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getGuardianSmartAccount, };
|
|
25
26
|
//# sourceMappingURL=startale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startale.d.ts","sourceRoot":"","sources":["../../../accounts/startale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAc7D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"startale.d.ts","sourceRoot":"","sources":["../../../accounts/startale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAc7D,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE5D,OAAO,KAAK,EAEV,QAAQ,EACR,uBAAuB,EAExB,MAAM,UAAU,CAAA;AAWjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,QAAA,MAAM,4BAA4B,EAAE,OACU,CAAA;AAW9C,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;SAwErD;AAoFD,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAmClD;AAED,iBAAS,eAAe,CAAC,MAAM,EAAE,uBAAuB,EAAE,KAAK,EAAE,KAAK;;;;;;EAarE;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBAErC;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAQvE;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,oKAUlC;AAED,iBAAe,uBAAuB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,EACnB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,oKAUlC;AAED,OAAO,EACL,4BAA4B,EAC5B,eAAe,EACf,cAAc,EACd,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,uBAAuB,GACxB,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.K1_DEFAULT_VALIDATOR_ADDRESS = void 0;
|
|
3
4
|
exports.getEip712Domain = getEip712Domain;
|
|
4
5
|
exports.getInstallData = getInstallData;
|
|
5
6
|
exports.getAddress = getAddress;
|
|
@@ -9,9 +10,11 @@ exports.getSmartAccount = getSmartAccount;
|
|
|
9
10
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
10
11
|
const viem_1 = require("viem");
|
|
11
12
|
const modules_1 = require("../modules");
|
|
13
|
+
const core_1 = require("../modules/validators/core");
|
|
12
14
|
const error_1 = require("./error");
|
|
13
15
|
const nexus_1 = require("./nexus");
|
|
14
16
|
const K1_DEFAULT_VALIDATOR_ADDRESS = '0x00000072f286204bb934ed49d8969e86f7dec7b1';
|
|
17
|
+
exports.K1_DEFAULT_VALIDATOR_ADDRESS = K1_DEFAULT_VALIDATOR_ADDRESS;
|
|
15
18
|
const STARTALE_VERSION = '1.0.0';
|
|
16
19
|
const IMPLEMENTATION_ADDRESS = '0x000000b8f5f723a680d3d7ee624fe0bc84a6e05a';
|
|
17
20
|
const FACTORY_ADDRESS = '0x0000003b3e7b530b4f981ae80d9350392defef90';
|
|
@@ -50,7 +53,74 @@ function getDeployArgs(config) {
|
|
|
50
53
|
const account = config.account;
|
|
51
54
|
const salt = account?.salt ?? viem_1.zeroHash;
|
|
52
55
|
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
53
|
-
const
|
|
56
|
+
const ownerValidator = (0, core_1.getOwnerValidator)(config);
|
|
57
|
+
const isK1 = ownerValidator.address.toLowerCase() ===
|
|
58
|
+
K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
59
|
+
if (isK1 &&
|
|
60
|
+
config.owners &&
|
|
61
|
+
'accounts' in config.owners &&
|
|
62
|
+
config.owners.accounts.length > 1) {
|
|
63
|
+
throw new error_1.AccountConfigurationNotSupportedError('K1 validator only supports a single owner', 'startale');
|
|
64
|
+
}
|
|
65
|
+
const initData = isK1
|
|
66
|
+
? getK1InitData(config, moduleSetup)
|
|
67
|
+
: getOwnableInitData(moduleSetup);
|
|
68
|
+
const factoryData = (0, viem_1.encodeFunctionData)({
|
|
69
|
+
abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
|
|
70
|
+
functionName: 'createAccount',
|
|
71
|
+
args: [initData, salt],
|
|
72
|
+
});
|
|
73
|
+
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
74
|
+
abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
|
|
75
|
+
functionName: 'initializeAccount',
|
|
76
|
+
args: [initData],
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
factory: FACTORY_ADDRESS,
|
|
80
|
+
factoryData,
|
|
81
|
+
salt,
|
|
82
|
+
implementation: IMPLEMENTATION_ADDRESS,
|
|
83
|
+
initializationCallData,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function getK1InitData(config, moduleSetup) {
|
|
87
|
+
const ownerAddress = config.owners.accounts[0]
|
|
88
|
+
.address;
|
|
89
|
+
const validators = moduleSetup.validators.filter((v) => v.address.toLowerCase() !== K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase());
|
|
90
|
+
return (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [
|
|
91
|
+
BOOTSTRAP_ADDRESS,
|
|
92
|
+
(0, viem_1.encodeFunctionData)({
|
|
93
|
+
abi: (0, viem_1.parseAbi)([
|
|
94
|
+
'struct BootstrapConfig {address module;bytes initData;}',
|
|
95
|
+
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
96
|
+
'function initWithDefaultValidatorAndOtherModules(bytes calldata defaultValidatorInitData,BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external payable',
|
|
97
|
+
]),
|
|
98
|
+
functionName: 'initWithDefaultValidatorAndOtherModules',
|
|
99
|
+
args: [
|
|
100
|
+
ownerAddress,
|
|
101
|
+
validators.map((v) => ({
|
|
102
|
+
module: v.address,
|
|
103
|
+
initData: v.initData,
|
|
104
|
+
})),
|
|
105
|
+
moduleSetup.executors.map((e) => ({
|
|
106
|
+
module: e.address,
|
|
107
|
+
initData: e.initData,
|
|
108
|
+
})),
|
|
109
|
+
{
|
|
110
|
+
module: viem_1.zeroAddress,
|
|
111
|
+
initData: '0x',
|
|
112
|
+
},
|
|
113
|
+
moduleSetup.fallbacks.map((f) => ({
|
|
114
|
+
module: f.address,
|
|
115
|
+
initData: f.initData,
|
|
116
|
+
})),
|
|
117
|
+
[],
|
|
118
|
+
],
|
|
119
|
+
}),
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
function getOwnableInitData(moduleSetup) {
|
|
123
|
+
return (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [
|
|
54
124
|
BOOTSTRAP_ADDRESS,
|
|
55
125
|
(0, viem_1.encodeFunctionData)({
|
|
56
126
|
abi: (0, viem_1.parseAbi)([
|
|
@@ -80,23 +150,6 @@ function getDeployArgs(config) {
|
|
|
80
150
|
],
|
|
81
151
|
}),
|
|
82
152
|
]);
|
|
83
|
-
const factoryData = (0, viem_1.encodeFunctionData)({
|
|
84
|
-
abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
|
|
85
|
-
functionName: 'createAccount',
|
|
86
|
-
args: [initData, salt],
|
|
87
|
-
});
|
|
88
|
-
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
89
|
-
abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
|
|
90
|
-
functionName: 'initializeAccount',
|
|
91
|
-
args: [initData],
|
|
92
|
-
});
|
|
93
|
-
return {
|
|
94
|
-
factory: FACTORY_ADDRESS,
|
|
95
|
-
factoryData,
|
|
96
|
-
salt,
|
|
97
|
-
implementation: IMPLEMENTATION_ADDRESS,
|
|
98
|
-
initializationCallData,
|
|
99
|
-
};
|
|
100
153
|
}
|
|
101
154
|
function getAddress(config) {
|
|
102
155
|
const deployArgs = getDeployArgs(config);
|
|
@@ -3,71 +3,125 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const vitest_1 = require("vitest");
|
|
4
4
|
const consts_1 = require("../../test/consts");
|
|
5
5
|
const common_1 = require("../modules/common");
|
|
6
|
+
const error_1 = require("./error");
|
|
6
7
|
const startale_1 = require("./startale");
|
|
7
8
|
const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
8
9
|
(0, vitest_1.describe)('Accounts: Startale', () => {
|
|
9
10
|
(0, vitest_1.describe)('Deploy Args', () => {
|
|
10
|
-
(0, vitest_1.test)('ECDSA
|
|
11
|
+
(0, vitest_1.test)('ECDSA owner (default/ownable)', () => {
|
|
11
12
|
const result = (0, startale_1.getDeployArgs)({
|
|
12
13
|
account: {
|
|
13
14
|
type: 'startale',
|
|
14
15
|
},
|
|
15
16
|
owners: {
|
|
16
17
|
type: 'ecdsa',
|
|
17
|
-
accounts: [consts_1.accountA
|
|
18
|
+
accounts: [consts_1.accountA],
|
|
18
19
|
},
|
|
19
20
|
});
|
|
20
21
|
(0, vitest_1.expect)(result).not.toBeNull();
|
|
21
22
|
const { factory, factoryData, salt, implementation, initializationCallData, } = result;
|
|
22
23
|
(0, vitest_1.expect)(factory).toEqual('0x0000003b3e7b530b4f981ae80d9350392defef90');
|
|
23
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
24
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000552a5fae3db7a8f3917c435448f49ba6a9000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003040984b2f700000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e9800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f6c02c78ded62973b43bfa523b247da0994869360000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
24
25
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
25
26
|
(0, vitest_1.expect)(implementation).toEqual('0x000000b8f5f723a680d3d7ee624fe0bc84a6e05a');
|
|
26
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
27
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a141900000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000552a5fae3db7a8f3917c435448f49ba6a9000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003040984b2f700000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e9800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f6c02c78ded62973b43bfa523b247da0994869360000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
27
28
|
});
|
|
28
|
-
(0, vitest_1.test)('
|
|
29
|
+
(0, vitest_1.test)('ECDSA owner with K1 module override', () => {
|
|
29
30
|
const result = (0, startale_1.getDeployArgs)({
|
|
30
31
|
account: {
|
|
31
32
|
type: 'startale',
|
|
32
33
|
},
|
|
33
34
|
owners: {
|
|
34
|
-
type: '
|
|
35
|
-
accounts: [consts_1.
|
|
35
|
+
type: 'ecdsa',
|
|
36
|
+
accounts: [consts_1.accountA],
|
|
37
|
+
module: startale_1.K1_DEFAULT_VALIDATOR_ADDRESS,
|
|
36
38
|
},
|
|
37
39
|
});
|
|
38
40
|
(0, vitest_1.expect)(result).not.toBeNull();
|
|
39
41
|
const { factory, factoryData, salt, implementation, initializationCallData, } = result;
|
|
40
42
|
(0, vitest_1.expect)(factory).toEqual('0x0000003b3e7b530b4f981ae80d9350392defef90');
|
|
41
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
43
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000552a5fae3db7a8f3917c435448f49ba6a9000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002645888596b00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000014F6C02c78Ded62973b43bfa523B247dA09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
42
44
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
43
45
|
(0, vitest_1.expect)(implementation).toEqual('0x000000b8f5f723a680d3d7ee624fe0bc84a6e05a');
|
|
44
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
46
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a1419000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000552a5fae3db7a8f3917c435448f49ba6a9000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002645888596b00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000014F6C02c78Ded62973b43bfa523B247dA09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.test)('Default and K1 produce different addresses', () => {
|
|
49
|
+
const defaultResult = (0, startale_1.getAddress)({
|
|
50
|
+
account: { type: 'startale' },
|
|
51
|
+
owners: { type: 'ecdsa', accounts: [consts_1.accountA] },
|
|
52
|
+
});
|
|
53
|
+
const k1Result = (0, startale_1.getAddress)({
|
|
54
|
+
account: { type: 'startale' },
|
|
55
|
+
owners: {
|
|
56
|
+
type: 'ecdsa',
|
|
57
|
+
accounts: [consts_1.accountA],
|
|
58
|
+
module: startale_1.K1_DEFAULT_VALIDATOR_ADDRESS,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
(0, vitest_1.expect)(defaultResult).not.toEqual(k1Result);
|
|
62
|
+
});
|
|
63
|
+
(0, vitest_1.test)('Passkey owner (default/ownable)', () => {
|
|
64
|
+
const result = (0, startale_1.getDeployArgs)({
|
|
65
|
+
account: {
|
|
66
|
+
type: 'startale',
|
|
67
|
+
},
|
|
68
|
+
owners: {
|
|
69
|
+
type: 'passkey',
|
|
70
|
+
accounts: [consts_1.passkeyAccount],
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
(0, vitest_1.expect)(result).not.toBeNull();
|
|
74
|
+
});
|
|
75
|
+
(0, vitest_1.test)('Multiple ECDSA owners (default/ownable)', () => {
|
|
76
|
+
const result = (0, startale_1.getDeployArgs)({
|
|
77
|
+
account: {
|
|
78
|
+
type: 'startale',
|
|
79
|
+
},
|
|
80
|
+
owners: {
|
|
81
|
+
type: 'ecdsa',
|
|
82
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
(0, vitest_1.expect)(result).not.toBeNull();
|
|
86
|
+
});
|
|
87
|
+
(0, vitest_1.test)('Multiple ECDSA owners with K1 throws', () => {
|
|
88
|
+
(0, vitest_1.expect)(() => (0, startale_1.getDeployArgs)({
|
|
89
|
+
account: {
|
|
90
|
+
type: 'startale',
|
|
91
|
+
},
|
|
92
|
+
owners: {
|
|
93
|
+
type: 'ecdsa',
|
|
94
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
95
|
+
module: startale_1.K1_DEFAULT_VALIDATOR_ADDRESS,
|
|
96
|
+
},
|
|
97
|
+
})).toThrow(error_1.AccountConfigurationNotSupportedError);
|
|
45
98
|
});
|
|
46
99
|
});
|
|
47
100
|
(0, vitest_1.describe)('Get Address', () => {
|
|
48
|
-
(0, vitest_1.test)('ECDSA
|
|
101
|
+
(0, vitest_1.test)('ECDSA owner (default/ownable)', () => {
|
|
49
102
|
const address = (0, startale_1.getAddress)({
|
|
50
103
|
account: {
|
|
51
104
|
type: 'startale',
|
|
52
105
|
},
|
|
53
106
|
owners: {
|
|
54
107
|
type: 'ecdsa',
|
|
55
|
-
accounts: [consts_1.accountA
|
|
108
|
+
accounts: [consts_1.accountA],
|
|
56
109
|
},
|
|
57
110
|
});
|
|
58
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
111
|
+
(0, vitest_1.expect)(address).toEqual('0x8cdf27ccdec0ae54029a67b2edb5391e438aa023');
|
|
59
112
|
});
|
|
60
|
-
(0, vitest_1.test)('
|
|
113
|
+
(0, vitest_1.test)('ECDSA owner with K1 module override', () => {
|
|
61
114
|
const address = (0, startale_1.getAddress)({
|
|
62
115
|
account: {
|
|
63
116
|
type: 'startale',
|
|
64
117
|
},
|
|
65
118
|
owners: {
|
|
66
|
-
type: '
|
|
67
|
-
accounts: [consts_1.
|
|
119
|
+
type: 'ecdsa',
|
|
120
|
+
accounts: [consts_1.accountA],
|
|
121
|
+
module: startale_1.K1_DEFAULT_VALIDATOR_ADDRESS,
|
|
68
122
|
},
|
|
69
123
|
});
|
|
70
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
124
|
+
(0, vitest_1.expect)(address).toEqual('0x701aa66d3a6b9c095a2dee8e650a285615cae7eb');
|
|
71
125
|
});
|
|
72
126
|
(0, vitest_1.test)('initData with address fallback', () => {
|
|
73
127
|
const expectedAddress = '0x229ca553b9863b0c8f2f03d4287cb8c73e2bede7';
|
|
@@ -86,26 +140,27 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
86
140
|
(0, vitest_1.expect)(address).toEqual(expectedAddress);
|
|
87
141
|
});
|
|
88
142
|
(0, vitest_1.test)('initData with factory decodes correctly', () => {
|
|
89
|
-
// First get the real deploy args to get valid factory/factoryData
|
|
90
143
|
const deployArgs = (0, startale_1.getDeployArgs)({
|
|
91
144
|
account: { type: 'startale' },
|
|
92
|
-
owners: { type: 'ecdsa', accounts: [consts_1.accountA
|
|
145
|
+
owners: { type: 'ecdsa', accounts: [consts_1.accountA] },
|
|
93
146
|
});
|
|
94
147
|
(0, vitest_1.expect)(deployArgs).not.toBeNull();
|
|
95
148
|
const { factory, factoryData } = deployArgs;
|
|
96
|
-
|
|
149
|
+
const addressFromDeploy = (0, startale_1.getAddress)({
|
|
150
|
+
account: { type: 'startale' },
|
|
151
|
+
owners: { type: 'ecdsa', accounts: [consts_1.accountA] },
|
|
152
|
+
});
|
|
97
153
|
const address = (0, startale_1.getAddress)({
|
|
98
154
|
account: { type: 'startale' },
|
|
99
155
|
owners: { type: 'ecdsa', accounts: [consts_1.accountA] },
|
|
100
156
|
initData: {
|
|
101
|
-
address:
|
|
157
|
+
address: addressFromDeploy,
|
|
102
158
|
factory,
|
|
103
159
|
factoryData,
|
|
104
160
|
intentExecutorInstalled: true,
|
|
105
161
|
},
|
|
106
162
|
});
|
|
107
|
-
|
|
108
|
-
(0, vitest_1.expect)(address).toEqual('0x614ea8885429c480a83deddd2e050d411da36d4b');
|
|
163
|
+
(0, vitest_1.expect)(address).toEqual(addressFromDeploy);
|
|
109
164
|
});
|
|
110
165
|
});
|
|
111
166
|
(0, vitest_1.describe)('Get Install Data', () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Address, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type SignableMessage, type SignedAuthorization, type SignedAuthorizationList, type TypedData, type TypedDataDefinition } from 'viem';
|
|
1
|
+
import { type Address, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type SignableMessage, type SignedAuthorization, type SignedAuthorizationList, type TypedData, type TypedDataDefinition, type TypedDataDomain } from 'viem';
|
|
2
2
|
import { type UserOperation } from 'viem/account-abstraction';
|
|
3
3
|
import { type IntentOp, type IntentRoute } from '../orchestrator';
|
|
4
4
|
import { type AuxiliaryFunds, type OriginSignature, type SettlementLayer } from '../orchestrator/types';
|
|
@@ -81,6 +81,19 @@ declare function signIntent(config: RhinestoneConfig, intentOp: IntentOp, target
|
|
|
81
81
|
declare function submitIntentInternal(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: Chain, intentOp: IntentOp, originSignatures: OriginSignature[], destinationSignature: Hex, targetExecutionSignature: Hex | undefined, authorizations: SignedAuthorizationList, dryRun: boolean): Promise<TransactionResult>;
|
|
82
82
|
declare function getValidatorAccount(config: RhinestoneConfig, signers: SignerSet | undefined, publicClient: PublicClient, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">> | null | undefined>;
|
|
83
83
|
declare function parseCalls(calls: CalldataInput[], chainId: number): Call[];
|
|
84
|
-
|
|
84
|
+
declare function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, verifierDomain, }: {
|
|
85
|
+
domain: TypedDataDomain;
|
|
86
|
+
types: TypedData;
|
|
87
|
+
primaryType: string;
|
|
88
|
+
message: Record<string, unknown>;
|
|
89
|
+
verifierDomain: {
|
|
90
|
+
name: string;
|
|
91
|
+
version: string;
|
|
92
|
+
chainId: number;
|
|
93
|
+
verifyingContract: Address;
|
|
94
|
+
salt: Hex;
|
|
95
|
+
};
|
|
96
|
+
}): Hex;
|
|
97
|
+
export { prepareTransaction, getTransactionMessages, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, getTargetExecutionSignature, hashErc7739TypedDataForSolady, };
|
|
85
98
|
export type { IntentRoute, TransactionResult, PreparedTransactionData, PreparedUserOperationData, SignedTransactionData, SignedUserOperationData, UserOperationResult, };
|
|
86
99
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAMV,KAAK,uBAAuB,EAC5B,KAAK,GAAG,EAOR,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAErB,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AAsCjC,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,MAAM,iBAAiB,CAAA;AAMxB,OAAO,EAEL,KAAK,cAAc,EAGnB,KAAK,eAAe,EACpB,KAAK,eAAe,EAIrB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAEV,IAAI,EACJ,aAAa,EACb,SAAS,EAET,uBAAuB,EACvB,gBAAgB,EAChB,SAAS,EAET,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,WAAW,EACX,wBAAwB,EACzB,MAAM,UAAU,CAAA;AASjB,UAAU,mBAAmB;IAC3B,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,iBAAiB;IACzB,IAAI,EAAE,QAAQ,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,UAAU,uBAAuB;IAC/B,WAAW,EAAE,WAAW,CAAA;IACxB,WAAW,EAAE,WAAW,CAAA;CACzB;AAED,UAAU,yBAAyB;IACjC,aAAa,EAAE,aAAa,CAAA;IAC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|
20
20
|
exports.resolveCallInputs = resolveCallInputs;
|
|
21
21
|
exports.getIntentAccount = getIntentAccount;
|
|
22
22
|
exports.getTargetExecutionSignature = getTargetExecutionSignature;
|
|
23
|
+
exports.hashErc7739TypedDataForSolady = hashErc7739TypedDataForSolady;
|
|
23
24
|
const viem_1 = require("viem");
|
|
24
25
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
25
26
|
const erc7739_1 = require("viem/experimental/erc7739");
|
|
26
27
|
const accounts_1 = require("../accounts");
|
|
28
|
+
const startale_1 = require("../accounts/startale");
|
|
27
29
|
const utils_1 = require("../accounts/utils");
|
|
28
30
|
const modules_1 = require("../modules");
|
|
29
31
|
const validators_1 = require("../modules/validators");
|
|
@@ -450,19 +452,31 @@ async function signIntent(config, intentOp, targetChain, signers, targetExecutio
|
|
|
450
452
|
};
|
|
451
453
|
}
|
|
452
454
|
async function getDestinationSignature(config, signers, validator, isRoot, targetChain, destination, originSignatures, targetExecution) {
|
|
453
|
-
//
|
|
455
|
+
// Smart sessions require a separate destination signature because the
|
|
456
|
+
// session enable data differs per chain
|
|
454
457
|
if (signers?.type === 'experimental_session') {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
458
|
+
return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
|
|
459
|
+
}
|
|
460
|
+
// ERC-7739 with K1 validator requires a separate destination signature because
|
|
461
|
+
// the account's eip712Domain() returns the target chain's chainId, which differs
|
|
462
|
+
// from the origin chain used for the last origin signature
|
|
463
|
+
const isK1Validator = validator.address.toLowerCase() ===
|
|
464
|
+
startale_1.K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
465
|
+
if (isK1Validator && (0, core_1.supportsEip712)(validator)) {
|
|
466
|
+
return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
|
|
460
467
|
}
|
|
461
468
|
const lastOriginSignature = originSignatures.at(-1);
|
|
462
469
|
return typeof lastOriginSignature === 'object'
|
|
463
470
|
? lastOriginSignature.preClaimSig
|
|
464
471
|
: (lastOriginSignature ?? '0x');
|
|
465
472
|
}
|
|
473
|
+
async function signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution) {
|
|
474
|
+
const destinationChain = (0, registry_1.getChainById)(targetChain.id);
|
|
475
|
+
const destinationSignatures = await signIntentTypedData(config, signers, validator, isRoot, destination, destinationChain, targetExecution);
|
|
476
|
+
return typeof destinationSignatures === 'object'
|
|
477
|
+
? destinationSignatures.preClaimSig
|
|
478
|
+
: (destinationSignatures ?? '0x');
|
|
479
|
+
}
|
|
466
480
|
function getIntentMessages(config, intentOp) {
|
|
467
481
|
const address = (0, accounts_1.getAddress)(config);
|
|
468
482
|
const intentExecutor = (0, modules_1.getIntentExecutor)(config);
|
|
@@ -504,6 +518,11 @@ function getTargetExecutionMessage(config, intentOp) {
|
|
|
504
518
|
}
|
|
505
519
|
async function signIntentTypedData(config, signers, validator, isRoot, parameters, chain, targetExecution) {
|
|
506
520
|
if ((0, core_1.supportsEip712)(validator)) {
|
|
521
|
+
const isK1Validator = validator.address.toLowerCase() ===
|
|
522
|
+
startale_1.K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
523
|
+
if (isK1Validator) {
|
|
524
|
+
return await signErc7739IntentTypedData(config, signers, validator, isRoot, parameters, chain);
|
|
525
|
+
}
|
|
507
526
|
return await (0, accounts_1.getTypedDataPackedSignature)(config, signers, chain, {
|
|
508
527
|
address: validator.address,
|
|
509
528
|
isRoot,
|
|
@@ -785,3 +804,100 @@ function validateTokenSymbols(chain, tokenAddressOrSymbols) {
|
|
|
785
804
|
}
|
|
786
805
|
}
|
|
787
806
|
}
|
|
807
|
+
// Signs intent typed data using ERC-7739 nested EIP-712 for Startale accounts.
|
|
808
|
+
// Uses a Solady-compatible TypedDataSign hash and wraps the signature with
|
|
809
|
+
// the app domain separator and contents hash for on-chain verification.
|
|
810
|
+
async function signErc7739IntentTypedData(config, signers, validator, isRoot, parameters, chain) {
|
|
811
|
+
const verifierDomain = (0, accounts_1.getEip712Domain)(config, chain);
|
|
812
|
+
const hash = hashErc7739TypedDataForSolady({
|
|
813
|
+
domain: parameters.domain,
|
|
814
|
+
types: parameters.types,
|
|
815
|
+
primaryType: parameters.primaryType,
|
|
816
|
+
message: parameters.message,
|
|
817
|
+
verifierDomain,
|
|
818
|
+
});
|
|
819
|
+
return await (0, accounts_1.getEip1271Signature)(config, signers, chain, {
|
|
820
|
+
address: validator.address,
|
|
821
|
+
isRoot,
|
|
822
|
+
}, hash, (signature) => (0, erc7739_1.wrapTypedDataSignature)({
|
|
823
|
+
domain: parameters.domain,
|
|
824
|
+
primaryType: parameters.primaryType,
|
|
825
|
+
types: parameters.types,
|
|
826
|
+
message: parameters.message,
|
|
827
|
+
signature,
|
|
828
|
+
}));
|
|
829
|
+
}
|
|
830
|
+
// Computes an ERC-7739 TypedDataSign hash compatible with Solady's ERC1271
|
|
831
|
+
// on-chain verification. Solady constructs the TypedDataSign type string by
|
|
832
|
+
// appending the contentsType directly after the TypedDataSign definition,
|
|
833
|
+
// which differs from viem's standard EIP-712 encodeType that re-sorts all
|
|
834
|
+
// referenced types alphabetically.
|
|
835
|
+
function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, verifierDomain, }) {
|
|
836
|
+
// Standard EIP-712 encodeType for the original content type
|
|
837
|
+
function encodeTypeString(primary, allTypes) {
|
|
838
|
+
const deps = new Set();
|
|
839
|
+
function findDeps(t) {
|
|
840
|
+
const match = t.match(/^\w*/);
|
|
841
|
+
const typeName = match?.[0];
|
|
842
|
+
if (!typeName || deps.has(typeName) || !allTypes[typeName])
|
|
843
|
+
return;
|
|
844
|
+
deps.add(typeName);
|
|
845
|
+
for (const field of allTypes[typeName])
|
|
846
|
+
findDeps(field.type);
|
|
847
|
+
}
|
|
848
|
+
findDeps(primary);
|
|
849
|
+
deps.delete(primary);
|
|
850
|
+
const sorted = [primary, ...Array.from(deps).sort()];
|
|
851
|
+
return sorted
|
|
852
|
+
.map((t) => `${t}(${allTypes[t].map((f) => `${f.type} ${f.name}`).join(',')})`)
|
|
853
|
+
.join('');
|
|
854
|
+
}
|
|
855
|
+
const contentsType = encodeTypeString(primaryType, types);
|
|
856
|
+
const contentsName = primaryType;
|
|
857
|
+
// Construct TypedDataSign type string matching Solady's on-chain encoding:
|
|
858
|
+
// TypedDataSign(<contentsName> contents,...salt) + contentsType
|
|
859
|
+
const typedDataSignTypeString = `TypedDataSign(${contentsName} contents,string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)${contentsType}`;
|
|
860
|
+
const typedDataSignTypeHash = (0, viem_1.keccak256)((0, viem_1.toHex)(typedDataSignTypeString));
|
|
861
|
+
// Hash the original content struct
|
|
862
|
+
const contentsHash = (0, viem_1.hashStruct)({
|
|
863
|
+
data: message,
|
|
864
|
+
primaryType,
|
|
865
|
+
types: types,
|
|
866
|
+
});
|
|
867
|
+
// Compute the TypedDataSign struct hash
|
|
868
|
+
const structHash = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
|
|
869
|
+
{ type: 'bytes32' },
|
|
870
|
+
{ type: 'bytes32' },
|
|
871
|
+
{ type: 'bytes32' },
|
|
872
|
+
{ type: 'bytes32' },
|
|
873
|
+
{ type: 'uint256' },
|
|
874
|
+
{ type: 'address' },
|
|
875
|
+
{ type: 'bytes32' },
|
|
876
|
+
], [
|
|
877
|
+
typedDataSignTypeHash,
|
|
878
|
+
contentsHash,
|
|
879
|
+
(0, viem_1.keccak256)((0, viem_1.toHex)(verifierDomain.name)),
|
|
880
|
+
(0, viem_1.keccak256)((0, viem_1.toHex)(verifierDomain.version)),
|
|
881
|
+
BigInt(verifierDomain.chainId),
|
|
882
|
+
verifierDomain.verifyingContract,
|
|
883
|
+
verifierDomain.salt,
|
|
884
|
+
]));
|
|
885
|
+
// Compute the app domain separator
|
|
886
|
+
const domainTypes = [];
|
|
887
|
+
if (domain.name)
|
|
888
|
+
domainTypes.push({ name: 'name', type: 'string' });
|
|
889
|
+
if (domain.version)
|
|
890
|
+
domainTypes.push({ name: 'version', type: 'string' });
|
|
891
|
+
if (domain.chainId)
|
|
892
|
+
domainTypes.push({ name: 'chainId', type: 'uint256' });
|
|
893
|
+
if (domain.verifyingContract)
|
|
894
|
+
domainTypes.push({ name: 'verifyingContract', type: 'address' });
|
|
895
|
+
if (domain.salt)
|
|
896
|
+
domainTypes.push({ name: 'salt', type: 'bytes32' });
|
|
897
|
+
const appDomainSeparator = (0, viem_1.hashDomain)({
|
|
898
|
+
domain,
|
|
899
|
+
types: { EIP712Domain: domainTypes },
|
|
900
|
+
});
|
|
901
|
+
// Final hash: keccak256("\x19\x01" || appDomainSep || structHash)
|
|
902
|
+
return (0, viem_1.keccak256)((0, viem_1.concat)(['0x1901', appDomainSeparator, structHash]));
|
|
903
|
+
}
|
|
@@ -11,6 +11,107 @@ vitest_1.vi.mock('../orchestrator', () => ({
|
|
|
11
11
|
getIntentRoute: mockGetIntentRoute,
|
|
12
12
|
}),
|
|
13
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
|
+
});
|
|
14
115
|
(0, vitest_1.describe)('prepareTransactionAsIntent', () => {
|
|
15
116
|
(0, vitest_1.beforeEach)(() => {
|
|
16
117
|
mockGetIntentRoute.mockReset();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const PROD_ORCHESTRATOR_URL = "https://v1.orchestrator.rhinestone.dev";
|
|
2
2
|
declare const RHINESTONE_SPOKE_POOL_ADDRESS = "0x000000000060f6e853447881951574cdd0663530";
|
|
3
|
-
declare const SDK_VERSION = "0.0.0-dev-
|
|
3
|
+
declare const SDK_VERSION = "0.0.0-dev-20260318201613";
|
|
4
4
|
export { PROD_ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS, SDK_VERSION };
|
|
5
5
|
//# sourceMappingURL=consts.d.ts.map
|
|
@@ -5,5 +5,5 @@ const PROD_ORCHESTRATOR_URL = 'https://v1.orchestrator.rhinestone.dev';
|
|
|
5
5
|
exports.PROD_ORCHESTRATOR_URL = PROD_ORCHESTRATOR_URL;
|
|
6
6
|
const RHINESTONE_SPOKE_POOL_ADDRESS = '0x000000000060f6e853447881951574cdd0663530';
|
|
7
7
|
exports.RHINESTONE_SPOKE_POOL_ADDRESS = RHINESTONE_SPOKE_POOL_ADDRESS;
|
|
8
|
-
const SDK_VERSION = '0.0.0-dev-
|
|
8
|
+
const SDK_VERSION = '0.0.0-dev-20260318201613';
|
|
9
9
|
exports.SDK_VERSION = SDK_VERSION;
|