@charterlabs/rhinestone-sdk 0.1.12 → 0.2.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.
- package/README.md +181 -74
- package/dist/src/accounts/index.d.ts +8 -7
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +65 -172
- package/dist/src/accounts/index.test.js +2 -3
- package/dist/src/accounts/kernel.d.ts +3 -2
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +3 -5
- package/dist/src/accounts/kernel.test.js +5 -12
- package/dist/src/accounts/nexus.d.ts +2 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +17 -17
- package/dist/src/accounts/nexus.test.js +11 -14
- package/dist/src/accounts/safe.d.ts +2 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +3 -5
- package/dist/src/accounts/safe.test.js +4 -7
- package/dist/src/accounts/signing/common.d.ts +23 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +113 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +51 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +39 -0
- package/dist/src/accounts/startale.d.ts +2 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +3 -3
- package/dist/src/accounts/startale.test.js +4 -7
- package/dist/src/actions/index.d.ts +84 -0
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +92 -0
- package/dist/src/actions/index.test.js +15 -15
- package/dist/src/actions/smart-session.d.ts +6 -0
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/execution/compact.d.ts +128 -1
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +91 -0
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +2 -3
- package/dist/src/execution/utils.d.ts +6 -5
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +37 -17
- package/dist/src/index.d.ts +8 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +89 -31
- package/dist/src/modules/index.d.ts +3 -8
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +26 -27
- package/dist/src/modules/index.test.js +1 -4
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +19 -14
- package/dist/src/modules/validators/core.test.js +4 -11
- package/dist/src/modules/validators/index.d.ts +1 -2
- package/dist/src/modules/validators/index.d.ts.map +1 -1
- package/dist/src/modules/validators/index.js +1 -13
- package/dist/src/modules/validators/smart-sessions.js +3 -3
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/orchestrator/index.d.ts +1 -2
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -3
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +2 -5
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -10,7 +10,7 @@ const MOCK_OWNER_A = '0xd1aefebdceefc094f1805b241fa5e6db63a9181a';
|
|
|
10
10
|
const MOCK_OWNER_B = '0xeddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817';
|
|
11
11
|
const MOCK_OWNER_C = '0xb31e76f19defe76edc4b7eceeb4b0a2d6ddaca39';
|
|
12
12
|
const MOCK_ACCOUNT_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
13
|
-
const accountAddress = '
|
|
13
|
+
const accountAddress = '0xc1b6c46c220dbc0ce6d13f4fb5adf70ccc1eb423';
|
|
14
14
|
// Mock viem
|
|
15
15
|
vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
16
16
|
const actual = await importOriginal();
|
|
@@ -37,7 +37,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
37
37
|
{
|
|
38
38
|
to: accountAddress,
|
|
39
39
|
value: 0n,
|
|
40
|
-
data: '
|
|
40
|
+
data: '0x9517e29f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000020c008719ba9d8aa14c7d07d122cd5e965aa8da500000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a',
|
|
41
41
|
},
|
|
42
42
|
]);
|
|
43
43
|
});
|
|
@@ -49,7 +49,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
49
49
|
{
|
|
50
50
|
to: accountAddress,
|
|
51
51
|
value: 0n,
|
|
52
|
-
data: '
|
|
52
|
+
data: '0x9517e29f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000020c008719ba9d8aa14c7d07d122cd5e965aa8da5000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
|
|
53
53
|
},
|
|
54
54
|
]);
|
|
55
55
|
});
|
|
@@ -62,7 +62,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
62
62
|
{
|
|
63
63
|
to: accountAddress,
|
|
64
64
|
value: 0n,
|
|
65
|
-
data: '
|
|
65
|
+
data: '0x9517e29f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000020c008719ba9d8aa14c7d07d122cd5e965aa8da5000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b31e76f19defe76edc4b7eceeb4b0a2d6ddaca39000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
|
|
66
66
|
},
|
|
67
67
|
]);
|
|
68
68
|
});
|
|
@@ -104,7 +104,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
104
104
|
{
|
|
105
105
|
to: accountAddress,
|
|
106
106
|
value: 0n,
|
|
107
|
-
data: '
|
|
107
|
+
data: '0xa71763a8000000000000000000000000000000000000000000000000000000000000000100000000000000000000000020c008719ba9d8aa14c7d07d122cd5e965aa8da500000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000',
|
|
108
108
|
},
|
|
109
109
|
]);
|
|
110
110
|
});
|
|
@@ -132,7 +132,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
132
132
|
(0, vitest_1.describe)('Add Owner', () => {
|
|
133
133
|
(0, vitest_1.test)('', () => {
|
|
134
134
|
(0, vitest_1.expect)((0, _1.addOwner)(MOCK_OWNER_A)).toEqual({
|
|
135
|
-
to: '
|
|
135
|
+
to: '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5',
|
|
136
136
|
value: 0n,
|
|
137
137
|
data: '0x7065cb48000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a',
|
|
138
138
|
});
|
|
@@ -141,7 +141,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
141
141
|
(0, vitest_1.describe)('Remove Owner', () => {
|
|
142
142
|
(0, vitest_1.test)('', () => {
|
|
143
143
|
(0, vitest_1.expect)((0, _1.removeOwner)(MOCK_OWNER_A, MOCK_OWNER_B)).toEqual({
|
|
144
|
-
to: '
|
|
144
|
+
to: '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5',
|
|
145
145
|
value: 0n,
|
|
146
146
|
data: '0xfbe5ce0a000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
|
|
147
147
|
});
|
|
@@ -150,7 +150,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
150
150
|
(0, vitest_1.describe)('Set Threshold', () => {
|
|
151
151
|
(0, vitest_1.test)('', () => {
|
|
152
152
|
(0, vitest_1.expect)((0, _1.changeThreshold)(1)).toEqual({
|
|
153
|
-
to: '
|
|
153
|
+
to: '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5',
|
|
154
154
|
value: 0n,
|
|
155
155
|
data: '0x960bfe040000000000000000000000000000000000000000000000000000000000000001',
|
|
156
156
|
});
|
|
@@ -216,12 +216,12 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
216
216
|
(0, vitest_1.expect)(mockPublicClient.multicall).toHaveBeenCalledTimes(1);
|
|
217
217
|
(0, vitest_1.expect)(result).toEqual([
|
|
218
218
|
{
|
|
219
|
-
to: '
|
|
219
|
+
to: '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5',
|
|
220
220
|
value: 0n,
|
|
221
221
|
data: '0x7065cb480000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
|
-
to: '
|
|
224
|
+
to: '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5',
|
|
225
225
|
value: 0n,
|
|
226
226
|
data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
227
227
|
},
|
|
@@ -249,12 +249,12 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
249
249
|
(0, vitest_1.expect)(mockPublicClient.multicall).toHaveBeenCalledTimes(1);
|
|
250
250
|
(0, vitest_1.expect)(result).toEqual([
|
|
251
251
|
{
|
|
252
|
-
to: '
|
|
252
|
+
to: '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5',
|
|
253
253
|
value: 0n,
|
|
254
254
|
data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
255
255
|
},
|
|
256
256
|
{
|
|
257
|
-
to: '
|
|
257
|
+
to: '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5',
|
|
258
258
|
value: 0n,
|
|
259
259
|
data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
260
260
|
},
|
|
@@ -282,17 +282,17 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
282
282
|
(0, vitest_1.expect)(mockPublicClient.multicall).toHaveBeenCalledTimes(1);
|
|
283
283
|
(0, vitest_1.expect)(result).toEqual([
|
|
284
284
|
{
|
|
285
|
-
to: '
|
|
285
|
+
to: '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5',
|
|
286
286
|
value: 0n,
|
|
287
287
|
data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
288
288
|
},
|
|
289
289
|
{
|
|
290
|
-
to: '
|
|
290
|
+
to: '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5',
|
|
291
291
|
value: 0n,
|
|
292
292
|
data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
293
293
|
},
|
|
294
294
|
{
|
|
295
|
-
to: '
|
|
295
|
+
to: '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5',
|
|
296
296
|
value: 0n,
|
|
297
297
|
data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596',
|
|
298
298
|
},
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { Hex } from 'viem';
|
|
2
2
|
import type { SessionDetails } from '../execution/smart-session';
|
|
3
|
+
/**
|
|
4
|
+
* Encode a smart session signature
|
|
5
|
+
* @param sessionDetails Session details
|
|
6
|
+
* @param sessionSignature Session signature
|
|
7
|
+
* @returns Encoded smart session signature
|
|
8
|
+
*/
|
|
3
9
|
declare function encodeSmartSessionSignature(sessionDetails: SessionDetails, sessionSignature: Hex): `0x${string}`;
|
|
4
10
|
export { encodeSmartSessionSignature };
|
|
5
11
|
//# sourceMappingURL=smart-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../actions/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE,iBAAS,2BAA2B,CAClC,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,GAAG,iBAQtB;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../actions/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE;;;;;GAKG;AACH,iBAAS,2BAA2B,CAClC,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,GAAG,iBAQtB;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAA"}
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.encodeSmartSessionSignature = encodeSmartSessionSignature;
|
|
4
4
|
const smart_sessions_1 = require("../modules/validators/smart-sessions");
|
|
5
|
+
/**
|
|
6
|
+
* Encode a smart session signature
|
|
7
|
+
* @param sessionDetails Session details
|
|
8
|
+
* @param sessionSignature Session signature
|
|
9
|
+
* @returns Encoded smart session signature
|
|
10
|
+
*/
|
|
5
11
|
function encodeSmartSessionSignature(sessionDetails, sessionSignature) {
|
|
6
12
|
return (0, smart_sessions_1.encodeSmartSessionSignature)(sessionDetails.mode, sessionDetails.enableSessionData.permissionId, sessionSignature, sessionDetails.enableSessionData);
|
|
7
13
|
}
|
|
@@ -1,8 +1,135 @@
|
|
|
1
1
|
import { type Address } from 'viem';
|
|
2
|
+
import type { IntentOp } from '../orchestrator/types';
|
|
2
3
|
import type { Call } from '../types';
|
|
3
4
|
declare const COMPACT_ADDRESS = "0xa2E6C7Ba8613E1534dCB990e7e4962216C0a5d58";
|
|
4
5
|
declare function getDepositEtherCall(account: Address, value: bigint): Call;
|
|
5
6
|
declare function getDepositErc20Call(account: Address, tokenAddress: Address, amount: bigint): Call;
|
|
6
7
|
declare function getApproveErc20Call(tokenAddress: Address, amount: bigint): Call;
|
|
7
|
-
|
|
8
|
+
declare function getIntentData(intentOp: IntentOp): {
|
|
9
|
+
readonly domain: {
|
|
10
|
+
readonly name: "The Compact";
|
|
11
|
+
readonly version: "1";
|
|
12
|
+
readonly chainId: bigint;
|
|
13
|
+
readonly verifyingContract: "0x73d2dc0c21fca4ec1601895d50df7f5624f07d3f";
|
|
14
|
+
};
|
|
15
|
+
readonly types: {
|
|
16
|
+
readonly MultichainCompact: readonly [{
|
|
17
|
+
readonly name: "sponsor";
|
|
18
|
+
readonly type: "address";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "nonce";
|
|
21
|
+
readonly type: "uint256";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "expires";
|
|
24
|
+
readonly type: "uint256";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "elements";
|
|
27
|
+
readonly type: "Element[]";
|
|
28
|
+
}];
|
|
29
|
+
readonly Element: readonly [{
|
|
30
|
+
readonly name: "arbiter";
|
|
31
|
+
readonly type: "address";
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: "chainId";
|
|
34
|
+
readonly type: "uint256";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "commitments";
|
|
37
|
+
readonly type: "Lock[]";
|
|
38
|
+
}, {
|
|
39
|
+
readonly name: "mandate";
|
|
40
|
+
readonly type: "Mandate";
|
|
41
|
+
}];
|
|
42
|
+
readonly Lock: readonly [{
|
|
43
|
+
readonly name: "lockTag";
|
|
44
|
+
readonly type: "bytes12";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "token";
|
|
47
|
+
readonly type: "address";
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: "amount";
|
|
50
|
+
readonly type: "uint256";
|
|
51
|
+
}];
|
|
52
|
+
readonly Mandate: readonly [{
|
|
53
|
+
readonly name: "target";
|
|
54
|
+
readonly type: "Target";
|
|
55
|
+
}, {
|
|
56
|
+
readonly name: "originOps";
|
|
57
|
+
readonly type: "Op[]";
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "destOps";
|
|
60
|
+
readonly type: "Op[]";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "q";
|
|
63
|
+
readonly type: "bytes32";
|
|
64
|
+
}];
|
|
65
|
+
readonly Target: readonly [{
|
|
66
|
+
readonly name: "recipient";
|
|
67
|
+
readonly type: "address";
|
|
68
|
+
}, {
|
|
69
|
+
readonly name: "tokenOut";
|
|
70
|
+
readonly type: "Token[]";
|
|
71
|
+
}, {
|
|
72
|
+
readonly name: "targetChain";
|
|
73
|
+
readonly type: "uint256";
|
|
74
|
+
}, {
|
|
75
|
+
readonly name: "fillExpiry";
|
|
76
|
+
readonly type: "uint256";
|
|
77
|
+
}];
|
|
78
|
+
readonly Token: readonly [{
|
|
79
|
+
readonly name: "token";
|
|
80
|
+
readonly type: "address";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "amount";
|
|
83
|
+
readonly type: "uint256";
|
|
84
|
+
}];
|
|
85
|
+
readonly Op: readonly [{
|
|
86
|
+
readonly name: "to";
|
|
87
|
+
readonly type: "address";
|
|
88
|
+
}, {
|
|
89
|
+
readonly name: "value";
|
|
90
|
+
readonly type: "uint256";
|
|
91
|
+
}, {
|
|
92
|
+
readonly name: "data";
|
|
93
|
+
readonly type: "bytes";
|
|
94
|
+
}];
|
|
95
|
+
};
|
|
96
|
+
readonly primaryType: "MultichainCompact";
|
|
97
|
+
readonly message: {
|
|
98
|
+
readonly sponsor: `0x${string}`;
|
|
99
|
+
readonly nonce: bigint;
|
|
100
|
+
readonly expires: bigint;
|
|
101
|
+
readonly elements: {
|
|
102
|
+
arbiter: `0x${string}`;
|
|
103
|
+
chainId: bigint;
|
|
104
|
+
commitments: {
|
|
105
|
+
lockTag: `0x${string}`;
|
|
106
|
+
token: `0x${string}`;
|
|
107
|
+
amount: bigint;
|
|
108
|
+
}[];
|
|
109
|
+
mandate: {
|
|
110
|
+
target: {
|
|
111
|
+
recipient: `0x${string}`;
|
|
112
|
+
tokenOut: {
|
|
113
|
+
token: `0x${string}`;
|
|
114
|
+
amount: bigint;
|
|
115
|
+
}[];
|
|
116
|
+
targetChain: bigint;
|
|
117
|
+
fillExpiry: bigint;
|
|
118
|
+
};
|
|
119
|
+
originOps: {
|
|
120
|
+
to: `0x${string}`;
|
|
121
|
+
value: bigint;
|
|
122
|
+
data: `0x${string}`;
|
|
123
|
+
}[];
|
|
124
|
+
destOps: {
|
|
125
|
+
to: `0x${string}`;
|
|
126
|
+
value: bigint;
|
|
127
|
+
data: `0x${string}`;
|
|
128
|
+
}[];
|
|
129
|
+
q: `0x${string}`;
|
|
130
|
+
};
|
|
131
|
+
}[];
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
export { COMPACT_ADDRESS, getDepositEtherCall, getDepositErc20Call, getApproveErc20Call, getIntentData, };
|
|
8
135
|
//# sourceMappingURL=compact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../../execution/compact.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../../execution/compact.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAOb,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAcpC,QAAA,MAAM,eAAe,+CAA+C,CAAA;AAKpE,iBAAS,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAqBlE;AAED,iBAAS,mBAAmB,CAC1B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,OAAO,EACrB,MAAM,EAAE,MAAM,GACb,IAAI,CA2BN;AAED,iBAAS,mBAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAUxE;AA8ED,iBAAS,aAAa,CAAC,QAAQ,EAAE,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiDxC;AAED,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GACd,CAAA"}
|
|
@@ -4,6 +4,7 @@ exports.COMPACT_ADDRESS = void 0;
|
|
|
4
4
|
exports.getDepositEtherCall = getDepositEtherCall;
|
|
5
5
|
exports.getDepositErc20Call = getDepositErc20Call;
|
|
6
6
|
exports.getApproveErc20Call = getApproveErc20Call;
|
|
7
|
+
exports.getIntentData = getIntentData;
|
|
7
8
|
const viem_1 = require("viem");
|
|
8
9
|
const COMPACT_ADDRESS = '0xa2E6C7Ba8613E1534dCB990e7e4962216C0a5d58';
|
|
9
10
|
exports.COMPACT_ADDRESS = COMPACT_ADDRESS;
|
|
@@ -103,3 +104,93 @@ function lockTag() {
|
|
|
103
104
|
const hex = tagBig.toString(16).slice(0, 24);
|
|
104
105
|
return `0x${hex}`;
|
|
105
106
|
}
|
|
107
|
+
// Define the typed data structure as const to preserve type safety
|
|
108
|
+
const COMPACT_TYPED_DATA_TYPES = {
|
|
109
|
+
MultichainCompact: [
|
|
110
|
+
{ name: 'sponsor', type: 'address' },
|
|
111
|
+
{ name: 'nonce', type: 'uint256' },
|
|
112
|
+
{ name: 'expires', type: 'uint256' },
|
|
113
|
+
{ name: 'elements', type: 'Element[]' },
|
|
114
|
+
],
|
|
115
|
+
Element: [
|
|
116
|
+
{ name: 'arbiter', type: 'address' },
|
|
117
|
+
{ name: 'chainId', type: 'uint256' },
|
|
118
|
+
{ name: 'commitments', type: 'Lock[]' },
|
|
119
|
+
{ name: 'mandate', type: 'Mandate' },
|
|
120
|
+
],
|
|
121
|
+
Lock: [
|
|
122
|
+
{ name: 'lockTag', type: 'bytes12' },
|
|
123
|
+
{ name: 'token', type: 'address' },
|
|
124
|
+
{ name: 'amount', type: 'uint256' },
|
|
125
|
+
],
|
|
126
|
+
Mandate: [
|
|
127
|
+
{ name: 'target', type: 'Target' },
|
|
128
|
+
{ name: 'originOps', type: 'Op[]' },
|
|
129
|
+
{ name: 'destOps', type: 'Op[]' },
|
|
130
|
+
{ name: 'q', type: 'bytes32' },
|
|
131
|
+
],
|
|
132
|
+
Target: [
|
|
133
|
+
{ name: 'recipient', type: 'address' },
|
|
134
|
+
{ name: 'tokenOut', type: 'Token[]' },
|
|
135
|
+
{ name: 'targetChain', type: 'uint256' },
|
|
136
|
+
{ name: 'fillExpiry', type: 'uint256' },
|
|
137
|
+
],
|
|
138
|
+
Token: [
|
|
139
|
+
{ name: 'token', type: 'address' },
|
|
140
|
+
{ name: 'amount', type: 'uint256' },
|
|
141
|
+
],
|
|
142
|
+
Op: [
|
|
143
|
+
{ name: 'to', type: 'address' },
|
|
144
|
+
{ name: 'value', type: 'uint256' },
|
|
145
|
+
{ name: 'data', type: 'bytes' },
|
|
146
|
+
],
|
|
147
|
+
};
|
|
148
|
+
function getIntentData(intentOp) {
|
|
149
|
+
const typedData = {
|
|
150
|
+
domain: {
|
|
151
|
+
name: 'The Compact',
|
|
152
|
+
version: '1',
|
|
153
|
+
chainId: BigInt(intentOp.elements[0].chainId),
|
|
154
|
+
verifyingContract: '0x73d2dc0c21fca4ec1601895d50df7f5624f07d3f',
|
|
155
|
+
},
|
|
156
|
+
types: COMPACT_TYPED_DATA_TYPES,
|
|
157
|
+
primaryType: 'MultichainCompact',
|
|
158
|
+
message: {
|
|
159
|
+
sponsor: intentOp.sponsor,
|
|
160
|
+
nonce: BigInt(intentOp.nonce),
|
|
161
|
+
expires: BigInt(intentOp.expires),
|
|
162
|
+
elements: intentOp.elements.map((element) => ({
|
|
163
|
+
arbiter: element.arbiter,
|
|
164
|
+
chainId: BigInt(element.chainId),
|
|
165
|
+
commitments: element.idsAndAmounts.map((token) => ({
|
|
166
|
+
lockTag: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 0, 12),
|
|
167
|
+
token: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 12, 32),
|
|
168
|
+
amount: BigInt(token[1]),
|
|
169
|
+
})),
|
|
170
|
+
mandate: {
|
|
171
|
+
target: {
|
|
172
|
+
recipient: element.mandate.recipient,
|
|
173
|
+
tokenOut: element.mandate.tokenOut.map((token) => ({
|
|
174
|
+
token: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 12, 32),
|
|
175
|
+
amount: BigInt(token[1]),
|
|
176
|
+
})),
|
|
177
|
+
targetChain: BigInt(element.mandate.destinationChainId),
|
|
178
|
+
fillExpiry: BigInt(element.mandate.fillDeadline),
|
|
179
|
+
},
|
|
180
|
+
originOps: element.mandate.preClaimOps.map((op) => ({
|
|
181
|
+
to: op.to,
|
|
182
|
+
value: BigInt(op.value),
|
|
183
|
+
data: op.data,
|
|
184
|
+
})),
|
|
185
|
+
destOps: element.mandate.destinationOps.map((op) => ({
|
|
186
|
+
to: op.to,
|
|
187
|
+
value: BigInt(op.value),
|
|
188
|
+
data: op.data,
|
|
189
|
+
})),
|
|
190
|
+
q: (0, viem_1.keccak256)(element.mandate.qualifier?.encodedVal ?? '0x'),
|
|
191
|
+
},
|
|
192
|
+
})),
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
return typedData;
|
|
196
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAmC,MAAM,MAAM,CAAA;AAKhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAQrD,OAAO,KAAK,EAEV,uBAAuB,EAGvB,WAAW,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EAChC,yBAAyB,EACzB,0CAA0C,EAC1C,0CAA0C,EAC3C,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAa5D,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,8BA2BzB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAmC,MAAM,MAAM,CAAA;AAKhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAQrD,OAAO,KAAK,EAEV,uBAAuB,EAGvB,WAAW,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EAChC,yBAAyB,EACzB,0CAA0C,EAC1C,0CAA0C,EAC3C,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAa5D,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,8BA2BzB;AAyID,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,iBAAiB,EACzB,uBAAuB,EAAE,OAAO;;;;;;;;;;;;GA2CjC;AAED,iBAAe,qBAAqB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,iBAAe,YAAY,CACzB,MAAM,EAAE,uBAAuB,EAC/B,UAAU,EAAE,OAAO,gDAMpB;AAED,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EAEZ,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,0CAA0C,EAC1C,0CAA0C,EAC1C,gCAAgC,EAChC,yBAAyB,GAC1B,CAAA;AACD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -84,16 +84,15 @@ async function sendTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
async function sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers, sponsored) {
|
|
87
|
-
const { intentRoute
|
|
87
|
+
const { intentRoute } = await (0, utils_2.prepareTransactionAsIntent)(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, sponsored ?? false);
|
|
88
88
|
if (!intentRoute) {
|
|
89
89
|
throw new error_1.OrderPathRequiredForIntentsError();
|
|
90
90
|
}
|
|
91
|
-
const signature = await (0, utils_2.signIntent)(config, targetChain,
|
|
91
|
+
const signature = await (0, utils_2.signIntent)(config, targetChain, intentRoute.intentOp, signers);
|
|
92
92
|
const authorizations = config.eoa
|
|
93
93
|
? await (0, utils_2.signAuthorizationsInternal)(config, {
|
|
94
94
|
type: 'intent',
|
|
95
95
|
intentRoute,
|
|
96
|
-
hash: intentHash,
|
|
97
96
|
})
|
|
98
97
|
: [];
|
|
99
98
|
return await (0, utils_2.submitIntentInternal)(config, sourceChains, targetChain, intentRoute.intentOp, signature, authorizations);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Address, type Chain, type Hex, type PublicClient, type SignedAuthorization, type SignedAuthorizationList } from 'viem';
|
|
1
|
+
import { type Address, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type SignableMessage, type SignedAuthorization, type SignedAuthorizationList, type TypedData } from 'viem';
|
|
2
2
|
import { type UserOperation } from 'viem/account-abstraction';
|
|
3
3
|
import { type IntentOp, type IntentRoute } from '../orchestrator';
|
|
4
4
|
import type { Call, CallInput, RhinestoneAccountConfig, SignerSet, TokenRequest, Transaction } from '../types';
|
|
@@ -9,12 +9,11 @@ type TransactionResult = {
|
|
|
9
9
|
} | {
|
|
10
10
|
type: 'intent';
|
|
11
11
|
id: bigint;
|
|
12
|
-
|
|
12
|
+
sourceChains?: number[];
|
|
13
13
|
targetChain: number;
|
|
14
14
|
};
|
|
15
15
|
interface IntentData {
|
|
16
16
|
type: 'intent';
|
|
17
|
-
hash: Hex;
|
|
18
17
|
intentRoute: IntentRoute;
|
|
19
18
|
}
|
|
20
19
|
interface UserOpData {
|
|
@@ -32,14 +31,16 @@ interface SignedTransactionData extends PreparedTransactionData {
|
|
|
32
31
|
declare function prepareTransaction(config: RhinestoneAccountConfig, transaction: Transaction): Promise<PreparedTransactionData>;
|
|
33
32
|
declare function signTransaction(config: RhinestoneAccountConfig, preparedTransaction: PreparedTransactionData): Promise<SignedTransactionData>;
|
|
34
33
|
declare function signAuthorizations(config: RhinestoneAccountConfig, preparedTransaction: PreparedTransactionData): Promise<SignedAuthorization[]>;
|
|
34
|
+
declare function signMessage(config: RhinestoneAccountConfig, message: SignableMessage, chain: Chain, signers: SignerSet | undefined): Promise<`0x${string}`>;
|
|
35
|
+
declare function signTypedData<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(config: RhinestoneAccountConfig, parameters: HashTypedDataParameters<typedData, primaryType>, chain: Chain, signers: SignerSet | undefined): Promise<`0x${string}`>;
|
|
35
36
|
declare function signAuthorizationsInternal(config: RhinestoneAccountConfig, data: IntentData | UserOpData): Promise<SignedAuthorization[]>;
|
|
36
37
|
declare function submitTransaction(config: RhinestoneAccountConfig, signedTransaction: SignedTransactionData, authorizations: SignedAuthorizationList): Promise<TransactionResult>;
|
|
37
38
|
declare function prepareTransactionAsIntent(config: RhinestoneAccountConfig, sourceChains: Chain[] | undefined, targetChain: Chain, callInputs: CallInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], accountAddress: Address, isSponsored: boolean, eip7702InitSignature?: Hex): Promise<IntentData>;
|
|
38
|
-
declare function signIntent(config: RhinestoneAccountConfig, targetChain: Chain,
|
|
39
|
+
declare function signIntent(config: RhinestoneAccountConfig, targetChain: Chain, intentOp: IntentOp, signers?: SignerSet): Promise<`0x${string}`>;
|
|
39
40
|
declare function getOrchestratorByChain(chainId: number, apiKey: string): import("../orchestrator").Orchestrator;
|
|
40
41
|
declare function submitIntentInternal(config: RhinestoneAccountConfig, sourceChains: Chain[] | undefined, targetChain: Chain, intentOp: IntentOp, signature: Hex, authorizations: SignedAuthorizationList): Promise<TransactionResult>;
|
|
41
42
|
declare function getValidatorAccount(config: RhinestoneAccountConfig, 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>;
|
|
42
43
|
declare function parseCalls(calls: CallInput[], chainId: number): Call[];
|
|
43
|
-
export { prepareTransaction, signTransaction, signAuthorizations, signAuthorizationsInternal, submitTransaction, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, };
|
|
44
|
+
export { prepareTransaction, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, };
|
|
44
45
|
export type { IntentData, TransactionResult, PreparedTransactionData, SignedTransactionData, };
|
|
45
46
|
//# 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,EAIV,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAIV,KAAK,uBAAuB,EAC5B,KAAK,GAAG,EAER,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EAGf,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AAuBjC,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,WAAW,EAGjB,MAAM,iBAAiB,CAAA;AAUxB,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,uBAAuB,EACvB,SAAS,EACT,YAAY,EACZ,WAAW,EACZ,MAAM,UAAU,CAAA;AAQjB,KAAK,iBAAiB,GAClB;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;CACd,GACD;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAEL,UAAU,UAAU;IAClB,IAAI,EAAE,QAAQ,CAAA;IACd,WAAW,EAAE,WAAW,CAAA;CACzB;AAED,UAAU,UAAU;IAClB,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;IACT,MAAM,EAAE,aAAa,CAAA;CACtB;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,UAAU,GAAG,UAAU,CAAA;IAC7B,WAAW,EAAE,WAAW,CAAA;CACzB;AAED,UAAU,qBAAsB,SAAQ,uBAAuB;IAC7D,SAAS,EAAE,GAAG,CAAA;CACf;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,uBAAuB,CAAC,CA2ClC;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,mBAAmB,EAAE,uBAAuB,GAC3C,OAAO,CAAC,qBAAqB,CAAC,CA8BhC;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,uBAAuB,EAC/B,mBAAmB,EAAE,uBAAuB,kCAG7C;AAED,iBAAe,WAAW,CACxB,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,SAAS,GAAG,SAAS,0BAqB/B;AAED,iBAAe,aAAa,CAC1B,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACjE,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,GAAG,MAAM,SAAS,EAEtE,MAAM,EAAE,uBAAuB,EAC/B,UAAU,EAAE,uBAAuB,CAAC,SAAS,EAAE,WAAW,CAAC,EAC3D,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,SAAS,GAAG,SAAS,0BAoB/B;AAED,iBAAe,0BAA0B,CACvC,MAAM,EAAE,uBAAuB,EAC/B,IAAI,EAAE,UAAU,GAAG,UAAU,kCAuC9B;AAED,iBAAe,iBAAiB,CAC9B,MAAM,EAAE,uBAAuB,EAC/B,iBAAiB,EAAE,qBAAqB,EACxC,cAAc,EAAE,uBAAuB,GACtC,OAAO,CAAC,iBAAiB,CAAC,CA4B5B;AAsED,iBAAe,0BAA0B,CACvC,MAAM,EAAE,uBAAuB,EAC/B,YAAY,EAAE,KAAK,EAAE,GAAG,SAAS,EACjC,WAAW,EAAE,KAAK,EAClB,UAAU,EAAE,SAAS,EAAE,EACvB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,aAAa,EAAE,YAAY,EAAE,EAC7B,cAAc,EAAE,OAAO,EACvB,WAAW,EAAE,OAAO,EACpB,oBAAoB,CAAC,EAAE,GAAG,uBAmD3B;AAED,iBAAe,UAAU,CACvB,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,SAAS,0BAqBpB;AA6FD,iBAAS,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,0CAK9D;AAED,iBAAe,oBAAoB,CACjC,MAAM,EAAE,uBAAuB,EAC/B,YAAY,EAAE,KAAK,EAAE,GAAG,SAAS,EACjC,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,GAAG,EACd,cAAc,EAAE,uBAAuB,8BA6BxC;AAED,iBAAe,mBAAmB,CAChC,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,yKA6Bb;AAiDD,iBAAS,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,CAM/D;AAmDD,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,GACX,CAAA;AACD,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACtB,CAAA"}
|
|
@@ -4,6 +4,8 @@ exports.prepareTransaction = prepareTransaction;
|
|
|
4
4
|
exports.signTransaction = signTransaction;
|
|
5
5
|
exports.signAuthorizations = signAuthorizations;
|
|
6
6
|
exports.signAuthorizationsInternal = signAuthorizationsInternal;
|
|
7
|
+
exports.signMessage = signMessage;
|
|
8
|
+
exports.signTypedData = signTypedData;
|
|
7
9
|
exports.submitTransaction = submitTransaction;
|
|
8
10
|
exports.getOrchestratorByChain = getOrchestratorByChain;
|
|
9
11
|
exports.signIntent = signIntent;
|
|
@@ -20,6 +22,7 @@ const core_1 = require("../modules/validators/core");
|
|
|
20
22
|
const orchestrator_1 = require("../orchestrator");
|
|
21
23
|
const consts_1 = require("../orchestrator/consts");
|
|
22
24
|
const registry_1 = require("../orchestrator/registry");
|
|
25
|
+
const compact_1 = require("./compact");
|
|
23
26
|
const error_1 = require("./error");
|
|
24
27
|
async function prepareTransaction(config, transaction) {
|
|
25
28
|
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, } = getTransactionParams(transaction);
|
|
@@ -56,7 +59,7 @@ async function signTransaction(config, preparedTransaction) {
|
|
|
56
59
|
signature = await signUserOp(config, chain, signers, userOp);
|
|
57
60
|
}
|
|
58
61
|
else {
|
|
59
|
-
signature = await signIntent(config, targetChain, data.
|
|
62
|
+
signature = await signIntent(config, targetChain, data.intentRoute.intentOp, signers);
|
|
60
63
|
}
|
|
61
64
|
return {
|
|
62
65
|
data,
|
|
@@ -67,6 +70,33 @@ async function signTransaction(config, preparedTransaction) {
|
|
|
67
70
|
async function signAuthorizations(config, preparedTransaction) {
|
|
68
71
|
return await signAuthorizationsInternal(config, preparedTransaction.data);
|
|
69
72
|
}
|
|
73
|
+
async function signMessage(config, message, chain, signers) {
|
|
74
|
+
const validator = getValidator(config, signers);
|
|
75
|
+
if (!validator) {
|
|
76
|
+
throw new Error('Validator not available');
|
|
77
|
+
}
|
|
78
|
+
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
79
|
+
const isRoot = validator.address === ownerValidator.address;
|
|
80
|
+
const hash = (0, viem_1.hashMessage)(message);
|
|
81
|
+
const signature = await (0, accounts_1.getPackedSignature)(config, signers, chain, {
|
|
82
|
+
address: validator.address,
|
|
83
|
+
isRoot,
|
|
84
|
+
}, hash);
|
|
85
|
+
return await (0, accounts_1.toErc6492Signature)(config, signature, chain);
|
|
86
|
+
}
|
|
87
|
+
async function signTypedData(config, parameters, chain, signers) {
|
|
88
|
+
const validator = getValidator(config, signers);
|
|
89
|
+
if (!validator) {
|
|
90
|
+
throw new Error('Validator not available');
|
|
91
|
+
}
|
|
92
|
+
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
93
|
+
const isRoot = validator.address === ownerValidator.address;
|
|
94
|
+
const signature = await (0, accounts_1.getTypedDataPackedSignature)(config, signers, chain, {
|
|
95
|
+
address: validator.address,
|
|
96
|
+
isRoot,
|
|
97
|
+
}, parameters);
|
|
98
|
+
return await (0, accounts_1.toErc6492Signature)(config, signature, chain);
|
|
99
|
+
}
|
|
70
100
|
async function signAuthorizationsInternal(config, data) {
|
|
71
101
|
const eoa = config.eoa;
|
|
72
102
|
if (!eoa) {
|
|
@@ -193,7 +223,7 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
193
223
|
account: {
|
|
194
224
|
address: accountAddress,
|
|
195
225
|
accountType: 'ERC7579',
|
|
196
|
-
setupOps
|
|
226
|
+
setupOps,
|
|
197
227
|
delegations,
|
|
198
228
|
},
|
|
199
229
|
destinationExecutions: calls,
|
|
@@ -210,24 +240,23 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
210
240
|
};
|
|
211
241
|
const orchestrator = getOrchestratorByChain(targetChain.id, config.rhinestoneApiKey);
|
|
212
242
|
const intentRoute = await orchestrator.getIntentRoute(metaIntent);
|
|
213
|
-
const intentHash = (0, orchestrator_1.getIntentOpHash)(intentRoute.intentOp);
|
|
214
243
|
return {
|
|
215
244
|
type: 'intent',
|
|
216
245
|
intentRoute,
|
|
217
|
-
hash: intentHash,
|
|
218
246
|
};
|
|
219
247
|
}
|
|
220
|
-
async function signIntent(config, targetChain,
|
|
248
|
+
async function signIntent(config, targetChain, intentOp, signers) {
|
|
221
249
|
const validator = getValidator(config, signers);
|
|
222
250
|
if (!validator) {
|
|
223
251
|
throw new Error('Validator not available');
|
|
224
252
|
}
|
|
225
253
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
226
254
|
const isRoot = validator.address === ownerValidator.address;
|
|
227
|
-
const
|
|
255
|
+
const typedData = (0, compact_1.getIntentData)(intentOp);
|
|
256
|
+
const signature = await (0, accounts_1.getTypedDataPackedSignature)(config, signers, targetChain, {
|
|
228
257
|
address: validator.address,
|
|
229
258
|
isRoot,
|
|
230
|
-
},
|
|
259
|
+
}, typedData);
|
|
231
260
|
return signature;
|
|
232
261
|
}
|
|
233
262
|
async function signUserOp(config, chain, signers, userOp) {
|
|
@@ -359,16 +388,7 @@ function getValidator(config, signers) {
|
|
|
359
388
|
}
|
|
360
389
|
// Multi-factor
|
|
361
390
|
if (withOwner.kind === 'multi-factor') {
|
|
362
|
-
|
|
363
|
-
const validators = withOwner.validators.map(validator => {
|
|
364
|
-
if (validator.type === 'ecdsa') {
|
|
365
|
-
return { type: 'ecdsa', accounts: validator.accounts, threshold: 1 };
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
return { type: 'passkey', account: validator.account, credentialIds: [] };
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
return (0, core_1.getMultiFactorValidator)(1, validators);
|
|
391
|
+
return (0, core_1.getMultiFactorValidator)(1, withOwner.validators);
|
|
372
392
|
}
|
|
373
393
|
}
|
|
374
394
|
// Smart sessions
|