@rhinestone/sdk 1.0.0-alpha.9 → 1.0.0-beta.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/accounts/error.d.ts +38 -3
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +55 -7
- package/dist/src/accounts/index.d.ts +30 -15
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +284 -140
- package/dist/src/accounts/index.test.js +3 -5
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +14 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +15 -0
- package/dist/src/accounts/kernel.d.ts +4 -3
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +32 -6
- package/dist/src/accounts/kernel.test.js +41 -19
- package/dist/src/accounts/nexus.d.ts +11 -4
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +182 -25
- package/dist/src/accounts/nexus.test.js +44 -18
- 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 +88 -58
- package/dist/src/accounts/safe.test.js +40 -14
- package/dist/src/accounts/signing/common.d.ts +27 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +145 -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 +47 -0
- package/dist/src/accounts/signing/passkeys.d.ts +36 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +125 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.test.js +88 -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 +35 -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 +9 -14
- package/dist/src/accounts/utils.d.ts +4 -4
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +3 -40
- package/dist/src/accounts/walletClient.d.ts +7 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +38 -0
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +23 -38
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +29 -294
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- 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/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +35 -0
- package/dist/src/execution/compact.d.ts +150 -7
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +112 -95
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +34 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +62 -42
- package/dist/src/execution/permit2.d.ts +148 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +282 -0
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/types.d.ts +35 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +36 -27
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +357 -103
- package/dist/src/index.d.ts +41 -22
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +199 -65
- package/dist/src/modules/common.d.ts +10 -4
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +22 -1
- package/dist/src/modules/index.d.ts +4 -18
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +15 -63
- package/dist/src/modules/index.test.js +9 -26
- package/dist/src/modules/omni-account.d.ts +2 -1
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +3 -1
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +4 -0
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +64 -41
- package/dist/src/modules/validators/core.test.js +7 -7
- package/dist/src/modules/validators/smart-sessions.js +3 -3
- package/dist/src/modules/validators/smart-sessions.test.js +4 -7
- package/dist/src/orchestrator/client.d.ts +4 -4
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +30 -15
- package/dist/src/orchestrator/index.d.ts +2 -3
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -3
- package/dist/src/orchestrator/registry.d.ts +1 -23
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +37 -33
- package/dist/src/orchestrator/registry.test.js +7 -7
- package/dist/src/orchestrator/types.d.ts +97 -29
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- 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 +74 -10
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +72 -1
- package/dist/src/actions/index.test.d.ts.map +0 -1
- package/dist/src/actions/index.test.js +0 -302
- package/dist/src/orchestrator/registry.json +0 -365
- /package/dist/src/{actions → accounts/json-rpc}/index.test.d.ts +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const viem_1 = require("viem");
|
|
4
|
+
const chains_1 = require("viem/chains");
|
|
5
|
+
const vitest_1 = require("vitest");
|
|
6
|
+
const consts_1 = require("../../test/consts");
|
|
7
|
+
const __1 = require("..");
|
|
8
|
+
const utils_1 = require("../execution/utils");
|
|
9
|
+
const recovery_1 = require("./recovery");
|
|
10
|
+
const accountAddress = '0x36C03e7D593F7B2C6b06fC18B5f4E9a4A29C99b0';
|
|
11
|
+
// Mock viem
|
|
12
|
+
vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
13
|
+
const actual = await importOriginal();
|
|
14
|
+
return {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
...actual,
|
|
17
|
+
createPublicClient: vitest_1.vi.fn(),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.describe)('Recovery Actions', () => {
|
|
21
|
+
(0, vitest_1.describe)('Set Up Recovery', async () => {
|
|
22
|
+
const rhinestone = new __1.RhinestoneSDK();
|
|
23
|
+
const rhinestoneAccount = await rhinestone.createAccount({
|
|
24
|
+
owners: {
|
|
25
|
+
type: 'ecdsa',
|
|
26
|
+
accounts: [consts_1.accountA],
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
(0, vitest_1.test)('Single Guardian', async () => {
|
|
30
|
+
const calls = await (0, utils_1.resolveCallInputs)([(0, recovery_1.enable)([consts_1.accountB], 1)], rhinestoneAccount.config, chains_1.base, accountAddress);
|
|
31
|
+
(0, vitest_1.expect)(calls).toEqual([
|
|
32
|
+
{
|
|
33
|
+
to: accountAddress,
|
|
34
|
+
value: 0n,
|
|
35
|
+
data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a04d053b3c8021e8d5bf641816c42daa75d8b597000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
|
|
36
|
+
},
|
|
37
|
+
]);
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.test)('Guardian Multi-Sig', async () => {
|
|
40
|
+
const calls = await (0, utils_1.resolveCallInputs)([(0, recovery_1.enable)([consts_1.accountB, consts_1.accountC, consts_1.accountD], 2)], rhinestoneAccount.config, chains_1.base, accountAddress);
|
|
41
|
+
(0, vitest_1.expect)(calls).toEqual([
|
|
42
|
+
{
|
|
43
|
+
to: accountAddress,
|
|
44
|
+
value: 0n,
|
|
45
|
+
data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a04d053b3c8021e8d5bf641816c42daa75d8b597000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
(0, vitest_1.describe)('Recover', () => {
|
|
51
|
+
const rhinestone = new __1.RhinestoneSDK();
|
|
52
|
+
const accountPromise = rhinestone.createAccount({
|
|
53
|
+
owners: {
|
|
54
|
+
type: 'ecdsa',
|
|
55
|
+
accounts: [consts_1.accountA],
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const mockPublicClient = {
|
|
59
|
+
readContract: vitest_1.vi.fn(),
|
|
60
|
+
multicall: vitest_1.vi.fn(),
|
|
61
|
+
};
|
|
62
|
+
(0, vitest_1.beforeEach)(() => {
|
|
63
|
+
const createPublicClientMock = viem_1.createPublicClient;
|
|
64
|
+
createPublicClientMock.mockReturnValue(mockPublicClient);
|
|
65
|
+
vitest_1.vi.clearAllMocks();
|
|
66
|
+
});
|
|
67
|
+
(0, vitest_1.test)('1/1 Owners - Single owner to different single owner', async () => {
|
|
68
|
+
const rhinestoneAccount = await accountPromise;
|
|
69
|
+
// Initial state
|
|
70
|
+
mockPublicClient.multicall.mockResolvedValueOnce([
|
|
71
|
+
{ result: [consts_1.accountA.address.toLowerCase()], status: 'success' },
|
|
72
|
+
{ result: 1n, status: 'success' },
|
|
73
|
+
]);
|
|
74
|
+
const newOwners = {
|
|
75
|
+
type: 'ecdsa',
|
|
76
|
+
accounts: [consts_1.accountB],
|
|
77
|
+
threshold: 1,
|
|
78
|
+
};
|
|
79
|
+
const result = await (0, recovery_1.recoverEcdsaOwnership)(accountAddress, newOwners, chains_1.base, rhinestoneAccount.config);
|
|
80
|
+
(0, vitest_1.expect)(mockPublicClient.multicall).toHaveBeenCalledTimes(1);
|
|
81
|
+
(0, vitest_1.expect)(result).toEqual([
|
|
82
|
+
{
|
|
83
|
+
to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
|
|
84
|
+
value: 0n,
|
|
85
|
+
data: '0x7065cb480000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
|
|
89
|
+
value: 0n,
|
|
90
|
+
data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
91
|
+
},
|
|
92
|
+
]);
|
|
93
|
+
});
|
|
94
|
+
(0, vitest_1.test)('1/N Owners - Single owner to multiple owners', async () => {
|
|
95
|
+
const rhinestoneAccount = await accountPromise;
|
|
96
|
+
// Initial state
|
|
97
|
+
mockPublicClient.multicall.mockResolvedValueOnce([
|
|
98
|
+
{
|
|
99
|
+
result: [
|
|
100
|
+
consts_1.accountA.address.toLowerCase(),
|
|
101
|
+
consts_1.accountB.address.toLowerCase(),
|
|
102
|
+
consts_1.accountC.address.toLowerCase(),
|
|
103
|
+
],
|
|
104
|
+
status: 'success',
|
|
105
|
+
},
|
|
106
|
+
{ result: 1n, status: 'success' },
|
|
107
|
+
]);
|
|
108
|
+
const newOwners = {
|
|
109
|
+
type: 'ecdsa',
|
|
110
|
+
accounts: [consts_1.accountB, consts_1.accountC, consts_1.accountD],
|
|
111
|
+
threshold: 1,
|
|
112
|
+
};
|
|
113
|
+
const result = await (0, recovery_1.recoverEcdsaOwnership)(accountAddress, newOwners, chains_1.base, rhinestoneAccount.config);
|
|
114
|
+
(0, vitest_1.expect)(mockPublicClient.multicall).toHaveBeenCalledTimes(1);
|
|
115
|
+
(0, vitest_1.expect)(result).toEqual([
|
|
116
|
+
{
|
|
117
|
+
to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
|
|
118
|
+
value: 0n,
|
|
119
|
+
data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
|
|
123
|
+
value: 0n,
|
|
124
|
+
data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
125
|
+
},
|
|
126
|
+
]);
|
|
127
|
+
});
|
|
128
|
+
(0, vitest_1.test)('M/N Owners - Multiple owners to different multiple owners', async () => {
|
|
129
|
+
const rhinestoneAccount = await accountPromise;
|
|
130
|
+
// Initial state
|
|
131
|
+
mockPublicClient.multicall.mockResolvedValueOnce([
|
|
132
|
+
{
|
|
133
|
+
result: [
|
|
134
|
+
consts_1.accountA.address.toLowerCase(),
|
|
135
|
+
consts_1.accountB.address.toLowerCase(),
|
|
136
|
+
consts_1.accountC.address.toLowerCase(),
|
|
137
|
+
],
|
|
138
|
+
status: 'success',
|
|
139
|
+
},
|
|
140
|
+
{ result: 2n, status: 'success' },
|
|
141
|
+
]);
|
|
142
|
+
const newOwners = {
|
|
143
|
+
type: 'ecdsa',
|
|
144
|
+
accounts: [consts_1.accountB, consts_1.accountD],
|
|
145
|
+
threshold: 2,
|
|
146
|
+
};
|
|
147
|
+
const result = await (0, recovery_1.recoverEcdsaOwnership)(accountAddress, newOwners, chains_1.base, rhinestoneAccount.config);
|
|
148
|
+
(0, vitest_1.expect)(mockPublicClient.multicall).toHaveBeenCalledTimes(1);
|
|
149
|
+
(0, vitest_1.expect)(result).toEqual([
|
|
150
|
+
{
|
|
151
|
+
to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
|
|
152
|
+
value: 0n,
|
|
153
|
+
data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
|
|
157
|
+
value: 0n,
|
|
158
|
+
data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
|
|
162
|
+
value: 0n,
|
|
163
|
+
data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596',
|
|
164
|
+
},
|
|
165
|
+
]);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { Hex } from 'viem';
|
|
2
2
|
import type { SessionDetails } from '../execution/smart-session';
|
|
3
|
+
/**
|
|
4
|
+
* Encode a smart session signature
|
|
5
|
+
* @param sessionDetails Session details
|
|
6
|
+
* @param sessionSignature Session signature
|
|
7
|
+
* @returns Encoded smart session signature
|
|
8
|
+
*/
|
|
3
9
|
declare function encodeSmartSessionSignature(sessionDetails: SessionDetails, sessionSignature: Hex): `0x${string}`;
|
|
4
10
|
export { encodeSmartSessionSignature };
|
|
5
11
|
//# sourceMappingURL=smart-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../actions/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE,iBAAS,2BAA2B,CAClC,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,GAAG,iBAQtB;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../actions/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE;;;;;GAKG;AACH,iBAAS,2BAA2B,CAClC,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,GAAG,iBAQtB;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAA"}
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.encodeSmartSessionSignature = encodeSmartSessionSignature;
|
|
4
4
|
const smart_sessions_1 = require("../modules/validators/smart-sessions");
|
|
5
|
+
/**
|
|
6
|
+
* Encode a smart session signature
|
|
7
|
+
* @param sessionDetails Session details
|
|
8
|
+
* @param sessionSignature Session signature
|
|
9
|
+
* @returns Encoded smart session signature
|
|
10
|
+
*/
|
|
5
11
|
function encodeSmartSessionSignature(sessionDetails, sessionSignature) {
|
|
6
12
|
return (0, smart_sessions_1.encodeSmartSessionSignature)(sessionDetails.mode, sessionDetails.enableSessionData.permissionId, sessionSignature, sessionDetails.enableSessionData);
|
|
7
13
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AccountConfigurationNotSupportedError, AccountError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError } from '../accounts';
|
|
2
|
+
import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError } from '../execution';
|
|
3
|
+
import { AuthenticationRequiredError, InsufficientBalanceError, IntentNotFoundError, InvalidApiKeyError, InvalidIntentSignatureError, isOrchestratorError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError } from '../orchestrator';
|
|
4
|
+
export { isAccountError, AccountError, AccountConfigurationNotSupportedError, Eip7702AccountMustHaveEoaError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, Eip7702NotSupportedForAccountError, WalletClientNoConnectedAccountError, isExecutionError, ExecutionError, IntentFailedError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError, isOrchestratorError, AuthenticationRequiredError, InsufficientBalanceError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,EACrC,YAAY,EACZ,8BAA8B,EAC9B,kCAAkC,EAClC,wCAAwC,EACxC,4BAA4B,EAC5B,cAAc,EACd,kCAAkC,EAClC,4BAA4B,EAC5B,mCAAmC,EACpC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EAChC,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,uCAAuC,EACvC,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAEL,cAAc,EACd,YAAY,EACZ,qCAAqC,EACrC,8BAA8B,EAC9B,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,kCAAkC,EAClC,kCAAkC,EAClC,mCAAmC,EAEnC,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,gCAAgC,EAChC,yBAAyB,EACzB,uBAAuB,EAEvB,mBAAmB,EACnB,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,uCAAuC,EACvC,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnsupportedTokenError = exports.UnsupportedChainIdError = exports.UnsupportedChainError = exports.TokenNotSupportedError = exports.IntentNotFoundError = exports.OrchestratorError = exports.OnlyOneTargetTokenAmountCanBeUnsetError = exports.NoPathFoundError = exports.InvalidIntentSignatureError = exports.InvalidApiKeyError = exports.InsufficientBalanceError = exports.AuthenticationRequiredError = exports.isOrchestratorError = exports.SignerNotSupportedError = exports.SessionChainRequiredError = exports.OrderPathRequiredForIntentsError = exports.IntentFailedError = exports.ExecutionError = exports.isExecutionError = exports.WalletClientNoConnectedAccountError = exports.Eip7702NotSupportedForAccountError = exports.SigningNotSupportedForAccountError = exports.SmartSessionsNotEnabledError = exports.FactoryArgsNotAvailableError = exports.ExistingEip7702AccountsNotSupportedError = exports.Eip7702AccountMustHaveEoaError = exports.AccountConfigurationNotSupportedError = exports.AccountError = exports.isAccountError = void 0;
|
|
4
|
+
const accounts_1 = require("../accounts");
|
|
5
|
+
Object.defineProperty(exports, "AccountConfigurationNotSupportedError", { enumerable: true, get: function () { return accounts_1.AccountConfigurationNotSupportedError; } });
|
|
6
|
+
Object.defineProperty(exports, "AccountError", { enumerable: true, get: function () { return accounts_1.AccountError; } });
|
|
7
|
+
Object.defineProperty(exports, "Eip7702AccountMustHaveEoaError", { enumerable: true, get: function () { return accounts_1.Eip7702AccountMustHaveEoaError; } });
|
|
8
|
+
Object.defineProperty(exports, "Eip7702NotSupportedForAccountError", { enumerable: true, get: function () { return accounts_1.Eip7702NotSupportedForAccountError; } });
|
|
9
|
+
Object.defineProperty(exports, "ExistingEip7702AccountsNotSupportedError", { enumerable: true, get: function () { return accounts_1.ExistingEip7702AccountsNotSupportedError; } });
|
|
10
|
+
Object.defineProperty(exports, "FactoryArgsNotAvailableError", { enumerable: true, get: function () { return accounts_1.FactoryArgsNotAvailableError; } });
|
|
11
|
+
Object.defineProperty(exports, "isAccountError", { enumerable: true, get: function () { return accounts_1.isAccountError; } });
|
|
12
|
+
Object.defineProperty(exports, "SigningNotSupportedForAccountError", { enumerable: true, get: function () { return accounts_1.SigningNotSupportedForAccountError; } });
|
|
13
|
+
Object.defineProperty(exports, "SmartSessionsNotEnabledError", { enumerable: true, get: function () { return accounts_1.SmartSessionsNotEnabledError; } });
|
|
14
|
+
Object.defineProperty(exports, "WalletClientNoConnectedAccountError", { enumerable: true, get: function () { return accounts_1.WalletClientNoConnectedAccountError; } });
|
|
15
|
+
const execution_1 = require("../execution");
|
|
16
|
+
Object.defineProperty(exports, "ExecutionError", { enumerable: true, get: function () { return execution_1.ExecutionError; } });
|
|
17
|
+
Object.defineProperty(exports, "IntentFailedError", { enumerable: true, get: function () { return execution_1.IntentFailedError; } });
|
|
18
|
+
Object.defineProperty(exports, "isExecutionError", { enumerable: true, get: function () { return execution_1.isExecutionError; } });
|
|
19
|
+
Object.defineProperty(exports, "OrderPathRequiredForIntentsError", { enumerable: true, get: function () { return execution_1.OrderPathRequiredForIntentsError; } });
|
|
20
|
+
Object.defineProperty(exports, "SessionChainRequiredError", { enumerable: true, get: function () { return execution_1.SessionChainRequiredError; } });
|
|
21
|
+
Object.defineProperty(exports, "SignerNotSupportedError", { enumerable: true, get: function () { return execution_1.SignerNotSupportedError; } });
|
|
22
|
+
const orchestrator_1 = require("../orchestrator");
|
|
23
|
+
Object.defineProperty(exports, "AuthenticationRequiredError", { enumerable: true, get: function () { return orchestrator_1.AuthenticationRequiredError; } });
|
|
24
|
+
Object.defineProperty(exports, "InsufficientBalanceError", { enumerable: true, get: function () { return orchestrator_1.InsufficientBalanceError; } });
|
|
25
|
+
Object.defineProperty(exports, "IntentNotFoundError", { enumerable: true, get: function () { return orchestrator_1.IntentNotFoundError; } });
|
|
26
|
+
Object.defineProperty(exports, "InvalidApiKeyError", { enumerable: true, get: function () { return orchestrator_1.InvalidApiKeyError; } });
|
|
27
|
+
Object.defineProperty(exports, "InvalidIntentSignatureError", { enumerable: true, get: function () { return orchestrator_1.InvalidIntentSignatureError; } });
|
|
28
|
+
Object.defineProperty(exports, "isOrchestratorError", { enumerable: true, get: function () { return orchestrator_1.isOrchestratorError; } });
|
|
29
|
+
Object.defineProperty(exports, "NoPathFoundError", { enumerable: true, get: function () { return orchestrator_1.NoPathFoundError; } });
|
|
30
|
+
Object.defineProperty(exports, "OnlyOneTargetTokenAmountCanBeUnsetError", { enumerable: true, get: function () { return orchestrator_1.OnlyOneTargetTokenAmountCanBeUnsetError; } });
|
|
31
|
+
Object.defineProperty(exports, "OrchestratorError", { enumerable: true, get: function () { return orchestrator_1.OrchestratorError; } });
|
|
32
|
+
Object.defineProperty(exports, "TokenNotSupportedError", { enumerable: true, get: function () { return orchestrator_1.TokenNotSupportedError; } });
|
|
33
|
+
Object.defineProperty(exports, "UnsupportedChainError", { enumerable: true, get: function () { return orchestrator_1.UnsupportedChainError; } });
|
|
34
|
+
Object.defineProperty(exports, "UnsupportedChainIdError", { enumerable: true, get: function () { return orchestrator_1.UnsupportedChainIdError; } });
|
|
35
|
+
Object.defineProperty(exports, "UnsupportedTokenError", { enumerable: true, get: function () { return orchestrator_1.UnsupportedTokenError; } });
|
|
@@ -1,8 +1,151 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type {
|
|
3
|
-
declare const COMPACT_ADDRESS = "
|
|
4
|
-
declare function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { type Hex } from 'viem';
|
|
2
|
+
import type { IntentOp } from '../orchestrator/types';
|
|
3
|
+
declare const COMPACT_ADDRESS = "0x73d2dc0c21fca4ec1601895d50df7f5624f07d3f";
|
|
4
|
+
declare function getCompactTypedData(intentOp: IntentOp): {
|
|
5
|
+
readonly domain: {
|
|
6
|
+
readonly name: "The Compact";
|
|
7
|
+
readonly version: "1";
|
|
8
|
+
readonly chainId: bigint;
|
|
9
|
+
readonly verifyingContract: "0x73d2dc0c21fca4ec1601895d50df7f5624f07d3f";
|
|
10
|
+
};
|
|
11
|
+
readonly types: {
|
|
12
|
+
readonly MultichainCompact: readonly [{
|
|
13
|
+
readonly name: "sponsor";
|
|
14
|
+
readonly type: "address";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "nonce";
|
|
17
|
+
readonly type: "uint256";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "expires";
|
|
20
|
+
readonly type: "uint256";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "elements";
|
|
23
|
+
readonly type: "Element[]";
|
|
24
|
+
}];
|
|
25
|
+
readonly Element: readonly [{
|
|
26
|
+
readonly name: "arbiter";
|
|
27
|
+
readonly type: "address";
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "chainId";
|
|
30
|
+
readonly type: "uint256";
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "commitments";
|
|
33
|
+
readonly type: "Lock[]";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "mandate";
|
|
36
|
+
readonly type: "Mandate";
|
|
37
|
+
}];
|
|
38
|
+
readonly Lock: readonly [{
|
|
39
|
+
readonly name: "lockTag";
|
|
40
|
+
readonly type: "bytes12";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "token";
|
|
43
|
+
readonly type: "address";
|
|
44
|
+
}, {
|
|
45
|
+
readonly name: "amount";
|
|
46
|
+
readonly type: "uint256";
|
|
47
|
+
}];
|
|
48
|
+
readonly Mandate: readonly [{
|
|
49
|
+
readonly name: "target";
|
|
50
|
+
readonly type: "Target";
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "v";
|
|
53
|
+
readonly type: "uint8";
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "minGas";
|
|
56
|
+
readonly type: "uint128";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "originOps";
|
|
59
|
+
readonly type: "Op[]";
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "destOps";
|
|
62
|
+
readonly type: "Op[]";
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "q";
|
|
65
|
+
readonly type: "bytes32";
|
|
66
|
+
}];
|
|
67
|
+
readonly Target: readonly [{
|
|
68
|
+
readonly name: "recipient";
|
|
69
|
+
readonly type: "address";
|
|
70
|
+
}, {
|
|
71
|
+
readonly name: "tokenOut";
|
|
72
|
+
readonly type: "Token[]";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "targetChain";
|
|
75
|
+
readonly type: "uint256";
|
|
76
|
+
}, {
|
|
77
|
+
readonly name: "fillExpiry";
|
|
78
|
+
readonly type: "uint256";
|
|
79
|
+
}];
|
|
80
|
+
readonly Token: readonly [{
|
|
81
|
+
readonly name: "token";
|
|
82
|
+
readonly type: "address";
|
|
83
|
+
}, {
|
|
84
|
+
readonly name: "amount";
|
|
85
|
+
readonly type: "uint256";
|
|
86
|
+
}];
|
|
87
|
+
readonly Op: readonly [{
|
|
88
|
+
readonly name: "to";
|
|
89
|
+
readonly type: "address";
|
|
90
|
+
}, {
|
|
91
|
+
readonly name: "value";
|
|
92
|
+
readonly type: "uint256";
|
|
93
|
+
}, {
|
|
94
|
+
readonly name: "data";
|
|
95
|
+
readonly type: "bytes";
|
|
96
|
+
}];
|
|
97
|
+
};
|
|
98
|
+
readonly primaryType: "MultichainCompact";
|
|
99
|
+
readonly message: {
|
|
100
|
+
readonly sponsor: `0x${string}`;
|
|
101
|
+
readonly nonce: bigint;
|
|
102
|
+
readonly expires: bigint;
|
|
103
|
+
readonly elements: {
|
|
104
|
+
arbiter: `0x${string}`;
|
|
105
|
+
chainId: bigint;
|
|
106
|
+
commitments: {
|
|
107
|
+
lockTag: `0x${string}`;
|
|
108
|
+
token: `0x${string}`;
|
|
109
|
+
amount: bigint;
|
|
110
|
+
}[];
|
|
111
|
+
mandate: {
|
|
112
|
+
target: {
|
|
113
|
+
recipient: `0x${string}`;
|
|
114
|
+
tokenOut: {
|
|
115
|
+
token: `0x${string}`;
|
|
116
|
+
amount: bigint;
|
|
117
|
+
}[];
|
|
118
|
+
targetChain: bigint;
|
|
119
|
+
fillExpiry: bigint;
|
|
120
|
+
};
|
|
121
|
+
v: number;
|
|
122
|
+
minGas: bigint;
|
|
123
|
+
originOps: {
|
|
124
|
+
to: `0x${string}`;
|
|
125
|
+
value: bigint;
|
|
126
|
+
data: `0x${string}`;
|
|
127
|
+
}[];
|
|
128
|
+
destOps: {
|
|
129
|
+
to: `0x${string}`;
|
|
130
|
+
value: bigint;
|
|
131
|
+
data: `0x${string}`;
|
|
132
|
+
}[];
|
|
133
|
+
q: `0x${string}`;
|
|
134
|
+
};
|
|
135
|
+
}[];
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Get the compact digest for signing
|
|
140
|
+
* @param intentOp The intent operation
|
|
141
|
+
* @returns The digest hash
|
|
142
|
+
*/
|
|
143
|
+
declare function getCompactDigest(intentOp: IntentOp): Hex;
|
|
144
|
+
/**
|
|
145
|
+
* Get the Permit2 digest for signing
|
|
146
|
+
* @param intentOp The intent operation
|
|
147
|
+
* @returns The digest hash
|
|
148
|
+
*/
|
|
149
|
+
declare function getPermit2Digest(intentOp: IntentOp): Hex;
|
|
150
|
+
export { COMPACT_ADDRESS, getCompactTypedData, getCompactDigest, getPermit2Digest, };
|
|
8
151
|
//# sourceMappingURL=compact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../../execution/compact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../../execution/compact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAA0C,MAAM,MAAM,CAAA;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAGrD,QAAA,MAAM,eAAe,+CAA+C,CAAA;AA8CpE,iBAAS,mBAAmB,CAAC,QAAQ,EAAE,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmD9C;AAED;;;;GAIG;AACH,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAGjD;AAED;;;;GAIG;AACH,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAGjD;AAED,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,GACjB,CAAA"}
|
|
@@ -1,105 +1,122 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.COMPACT_ADDRESS = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
4
|
+
exports.getCompactTypedData = getCompactTypedData;
|
|
5
|
+
exports.getCompactDigest = getCompactDigest;
|
|
6
|
+
exports.getPermit2Digest = getPermit2Digest;
|
|
7
7
|
const viem_1 = require("viem");
|
|
8
|
-
const
|
|
8
|
+
const permit2_1 = require("./permit2");
|
|
9
|
+
const COMPACT_ADDRESS = '0x73d2dc0c21fca4ec1601895d50df7f5624f07d3f';
|
|
9
10
|
exports.COMPACT_ADDRESS = COMPACT_ADDRESS;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
// Define the typed data structure as const to preserve type safety
|
|
12
|
+
const COMPACT_TYPED_DATA_TYPES = {
|
|
13
|
+
MultichainCompact: [
|
|
14
|
+
{ name: 'sponsor', type: 'address' },
|
|
15
|
+
{ name: 'nonce', type: 'uint256' },
|
|
16
|
+
{ name: 'expires', type: 'uint256' },
|
|
17
|
+
{ name: 'elements', type: 'Element[]' },
|
|
18
|
+
],
|
|
19
|
+
Element: [
|
|
20
|
+
{ name: 'arbiter', type: 'address' },
|
|
21
|
+
{ name: 'chainId', type: 'uint256' },
|
|
22
|
+
{ name: 'commitments', type: 'Lock[]' },
|
|
23
|
+
{ name: 'mandate', type: 'Mandate' },
|
|
24
|
+
],
|
|
25
|
+
Lock: [
|
|
26
|
+
{ name: 'lockTag', type: 'bytes12' },
|
|
27
|
+
{ name: 'token', type: 'address' },
|
|
28
|
+
{ name: 'amount', type: 'uint256' },
|
|
29
|
+
],
|
|
30
|
+
Mandate: [
|
|
31
|
+
{ name: 'target', type: 'Target' },
|
|
32
|
+
{ name: 'v', type: 'uint8' },
|
|
33
|
+
{ name: 'minGas', type: 'uint128' },
|
|
34
|
+
{ name: 'originOps', type: 'Op[]' },
|
|
35
|
+
{ name: 'destOps', type: 'Op[]' },
|
|
36
|
+
{ name: 'q', type: 'bytes32' },
|
|
37
|
+
],
|
|
38
|
+
Target: [
|
|
39
|
+
{ name: 'recipient', type: 'address' },
|
|
40
|
+
{ name: 'tokenOut', type: 'Token[]' },
|
|
41
|
+
{ name: 'targetChain', type: 'uint256' },
|
|
42
|
+
{ name: 'fillExpiry', type: 'uint256' },
|
|
43
|
+
],
|
|
44
|
+
Token: [
|
|
45
|
+
{ name: 'token', type: 'address' },
|
|
46
|
+
{ name: 'amount', type: 'uint256' },
|
|
47
|
+
],
|
|
48
|
+
Op: [
|
|
49
|
+
{ name: 'to', type: 'address' },
|
|
50
|
+
{ name: 'value', type: 'uint256' },
|
|
51
|
+
{ name: 'data', type: 'bytes' },
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
function getCompactTypedData(intentOp) {
|
|
55
|
+
const typedData = {
|
|
56
|
+
domain: {
|
|
57
|
+
name: 'The Compact',
|
|
58
|
+
version: '1',
|
|
59
|
+
chainId: BigInt(intentOp.elements[0].chainId),
|
|
60
|
+
verifyingContract: '0x73d2dc0c21fca4ec1601895d50df7f5624f07d3f',
|
|
61
|
+
},
|
|
62
|
+
types: COMPACT_TYPED_DATA_TYPES,
|
|
63
|
+
primaryType: 'MultichainCompact',
|
|
64
|
+
message: {
|
|
65
|
+
sponsor: intentOp.sponsor,
|
|
66
|
+
nonce: BigInt(intentOp.nonce),
|
|
67
|
+
expires: BigInt(intentOp.expires),
|
|
68
|
+
elements: intentOp.elements.map((element) => ({
|
|
69
|
+
arbiter: element.arbiter,
|
|
70
|
+
chainId: BigInt(element.chainId),
|
|
71
|
+
commitments: element.idsAndAmounts.map((token) => ({
|
|
72
|
+
lockTag: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 0, 12),
|
|
73
|
+
token: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 12, 32),
|
|
74
|
+
amount: BigInt(token[1]),
|
|
75
|
+
})),
|
|
76
|
+
mandate: {
|
|
77
|
+
target: {
|
|
78
|
+
recipient: element.mandate.recipient,
|
|
79
|
+
tokenOut: element.mandate.tokenOut.map((token) => ({
|
|
80
|
+
token: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 12, 32),
|
|
81
|
+
amount: BigInt(token[1]),
|
|
82
|
+
})),
|
|
83
|
+
targetChain: BigInt(element.mandate.destinationChainId),
|
|
84
|
+
fillExpiry: BigInt(element.mandate.fillDeadline),
|
|
85
|
+
},
|
|
86
|
+
v: element.mandate.v || 0,
|
|
87
|
+
minGas: BigInt(element.mandate.minGas || '0'),
|
|
88
|
+
originOps: element.mandate.preClaimOps.map((op) => ({
|
|
89
|
+
to: op.to,
|
|
90
|
+
value: BigInt(op.value),
|
|
91
|
+
data: op.data,
|
|
92
|
+
})),
|
|
93
|
+
destOps: element.mandate.destinationOps.map((op) => ({
|
|
94
|
+
to: op.to,
|
|
95
|
+
value: BigInt(op.value),
|
|
96
|
+
data: op.data,
|
|
97
|
+
})),
|
|
98
|
+
q: (0, viem_1.keccak256)(element.mandate.qualifier.encodedVal),
|
|
27
99
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
args: [lockTag(), account],
|
|
31
|
-
}),
|
|
32
|
-
value,
|
|
100
|
+
})),
|
|
101
|
+
},
|
|
33
102
|
};
|
|
103
|
+
return typedData;
|
|
34
104
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
name: 'depositERC20',
|
|
44
|
-
inputs: [
|
|
45
|
-
{
|
|
46
|
-
name: 'token',
|
|
47
|
-
type: 'address',
|
|
48
|
-
internalType: 'address',
|
|
49
|
-
},
|
|
50
|
-
{ name: 'lockTag', type: 'bytes12', internalType: 'bytes12' },
|
|
51
|
-
{ name: 'amount', type: 'uint256', internalType: 'uint256' },
|
|
52
|
-
{ name: 'recipient', type: 'address', internalType: 'address' },
|
|
53
|
-
],
|
|
54
|
-
outputs: [{ name: 'id', type: 'uint256', internalType: 'uint256' }],
|
|
55
|
-
stateMutability: 'nonpayable',
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
functionName: 'depositERC20',
|
|
59
|
-
args: [tokenAddress, lockTag(), amount, account],
|
|
60
|
-
}),
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function getApproveErc20Call(tokenAddress, amount) {
|
|
64
|
-
return {
|
|
65
|
-
to: tokenAddress,
|
|
66
|
-
value: 0n,
|
|
67
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
68
|
-
abi: viem_1.erc20Abi,
|
|
69
|
-
functionName: 'approve',
|
|
70
|
-
args: [COMPACT_ADDRESS, amount],
|
|
71
|
-
}),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function toCompactFlag(allocator) {
|
|
75
|
-
const addrBytes = Buffer.from(allocator.slice(2), 'hex');
|
|
76
|
-
let leadingZeroNibbles = 0;
|
|
77
|
-
for (const byte of addrBytes) {
|
|
78
|
-
if (byte === 0) {
|
|
79
|
-
leadingZeroNibbles += 2;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
if (byte >> 4 === 0)
|
|
83
|
-
leadingZeroNibbles += 1;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (leadingZeroNibbles >= 18)
|
|
88
|
-
return 15;
|
|
89
|
-
if (leadingZeroNibbles >= 4)
|
|
90
|
-
return leadingZeroNibbles - 3;
|
|
91
|
-
return 0;
|
|
92
|
-
}
|
|
93
|
-
function usingAllocatorId(allocator = ALLOCATOR_ADDRESS) {
|
|
94
|
-
const compactFlag = BigInt(toCompactFlag(allocator));
|
|
95
|
-
const last88Bits = BigInt(`0x${allocator.slice(-22)}`); // Extract last 88 bits (11 bytes * 2 hex chars per byte)
|
|
96
|
-
return (compactFlag << 88n) | last88Bits;
|
|
105
|
+
/**
|
|
106
|
+
* Get the compact digest for signing
|
|
107
|
+
* @param intentOp The intent operation
|
|
108
|
+
* @returns The digest hash
|
|
109
|
+
*/
|
|
110
|
+
function getCompactDigest(intentOp) {
|
|
111
|
+
const typedData = getCompactTypedData(intentOp);
|
|
112
|
+
return (0, viem_1.hashTypedData)(typedData);
|
|
97
113
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Get the Permit2 digest for signing
|
|
116
|
+
* @param intentOp The intent operation
|
|
117
|
+
* @returns The digest hash
|
|
118
|
+
*/
|
|
119
|
+
function getPermit2Digest(intentOp) {
|
|
120
|
+
const typedData = (0, permit2_1.getTypedData)(intentOp);
|
|
121
|
+
return (0, viem_1.hashTypedData)(typedData);
|
|
105
122
|
}
|