@rhinestone/sdk 1.4.2 → 2.0.0-beta.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 +89 -1
- package/dist/src/accounts/error.d.ts +1 -1
- package/dist/src/accounts/error.js +1 -19
- package/dist/src/accounts/index.d.ts +5 -5
- package/dist/src/accounts/index.js +121 -157
- package/dist/src/accounts/json-rpc/index.d.ts +1 -1
- package/dist/src/accounts/json-rpc/index.js +8 -10
- package/dist/src/accounts/json-rpc/providers.d.ts +1 -1
- package/dist/src/accounts/json-rpc/providers.js +4 -7
- package/dist/src/accounts/kernel.d.ts +3 -3
- package/dist/src/accounts/kernel.js +66 -75
- package/dist/src/accounts/nexus.d.ts +3 -3
- package/dist/src/accounts/nexus.js +62 -73
- package/dist/src/accounts/passport.d.ts +3 -3
- package/dist/src/accounts/passport.js +9 -13
- package/dist/src/accounts/safe.d.ts +3 -3
- package/dist/src/accounts/safe.js +54 -63
- package/dist/src/accounts/signing/common.d.ts +10 -4
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +30 -36
- package/dist/src/accounts/signing/message.d.ts +2 -2
- package/dist/src/accounts/signing/message.js +10 -12
- package/dist/src/accounts/signing/passkeys.js +11 -17
- package/dist/src/accounts/signing/typedData.d.ts +1 -1
- package/dist/src/accounts/signing/typedData.js +6 -8
- package/dist/src/accounts/startale.d.ts +3 -3
- package/dist/src/accounts/startale.js +37 -47
- package/dist/src/accounts/utils.d.ts +2 -2
- package/dist/src/accounts/utils.js +22 -28
- package/dist/src/accounts/walletClient.js +4 -8
- package/dist/src/actions/compact.d.ts +1 -1
- package/dist/src/actions/compact.js +22 -35
- package/dist/src/actions/deployment.d.ts +1 -1
- package/dist/src/actions/deployment.js +11 -13
- package/dist/src/actions/ecdsa.d.ts +1 -1
- package/dist/src/actions/ecdsa.js +14 -20
- package/dist/src/actions/index.d.ts +2 -2
- package/dist/src/actions/index.js +6 -10
- package/dist/src/actions/mfa.d.ts +1 -1
- package/dist/src/actions/mfa.js +18 -24
- package/dist/src/actions/passkeys.d.ts +2 -2
- package/dist/src/actions/passkeys.js +14 -20
- package/dist/src/actions/recovery.d.ts +1 -1
- package/dist/src/actions/recovery.js +25 -29
- package/dist/src/actions/smart-sessions.d.ts +1 -1
- package/dist/src/actions/smart-sessions.js +8 -12
- package/dist/src/auth/provider.d.ts +7 -0
- package/dist/src/auth/provider.d.ts.map +1 -0
- package/dist/src/auth/provider.js +38 -0
- package/dist/src/errors/index.d.ts +3 -3
- package/dist/src/errors/index.js +10 -54
- package/dist/src/execution/compact.d.ts +3 -3
- package/dist/src/execution/compact.js +10 -18
- package/dist/src/execution/error.js +1 -11
- package/dist/src/execution/index.d.ts +9 -8
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +54 -67
- package/dist/src/execution/permit2.d.ts +5 -5
- package/dist/src/execution/permit2.js +8 -13
- package/dist/src/execution/singleChainOps.d.ts +2 -2
- package/dist/src/execution/singleChainOps.js +1 -3
- package/dist/src/execution/types.d.ts +1 -1
- package/dist/src/execution/types.js +1 -2
- package/dist/src/execution/utils.d.ts +10 -6
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +159 -162
- package/dist/src/index.d.ts +10 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +57 -67
- package/dist/src/jwt-server/digest.d.ts +11 -0
- package/dist/src/jwt-server/digest.d.ts.map +1 -0
- package/dist/src/jwt-server/digest.js +19 -0
- package/dist/src/jwt-server/express.d.ts +16 -0
- package/dist/src/jwt-server/express.d.ts.map +1 -0
- package/dist/src/jwt-server/express.js +23 -0
- package/dist/src/jwt-server/handlers.d.ts +10 -0
- package/dist/src/jwt-server/handlers.d.ts.map +1 -0
- package/dist/src/jwt-server/handlers.js +37 -0
- package/dist/src/jwt-server/index.d.ts +8 -0
- package/dist/src/jwt-server/index.d.ts.map +1 -0
- package/dist/src/jwt-server/index.js +7 -0
- package/dist/src/jwt-server/jcs.d.ts +12 -0
- package/dist/src/jwt-server/jcs.d.ts.map +1 -0
- package/dist/src/jwt-server/jcs.js +57 -0
- package/dist/src/jwt-server/signer.d.ts +18 -0
- package/dist/src/jwt-server/signer.d.ts.map +1 -0
- package/dist/src/jwt-server/signer.js +68 -0
- package/dist/src/jwt-server/sponsorship.d.ts +19 -0
- package/dist/src/jwt-server/sponsorship.d.ts.map +1 -0
- package/dist/src/jwt-server/sponsorship.js +51 -0
- package/dist/src/jwt-server/web.d.ts +4 -0
- package/dist/src/jwt-server/web.d.ts.map +1 -0
- package/dist/src/jwt-server/web.js +23 -0
- package/dist/src/modules/abi/smart-session-emissary.js +1 -3
- package/dist/src/modules/abi/smart-sessions.js +1 -4
- package/dist/src/modules/chain-abstraction.js +1 -5
- package/dist/src/modules/common.d.ts +1 -1
- package/dist/src/modules/common.js +1 -13
- package/dist/src/modules/index.d.ts +5 -5
- package/dist/src/modules/index.js +35 -50
- package/dist/src/modules/legacy.d.ts +2 -2
- package/dist/src/modules/legacy.js +11 -14
- package/dist/src/modules/read.d.ts +1 -1
- package/dist/src/modules/read.js +11 -15
- package/dist/src/modules/validators/core.d.ts +2 -2
- package/dist/src/modules/validators/core.js +26 -44
- package/dist/src/modules/validators/index.d.ts +2 -2
- package/dist/src/modules/validators/index.js +3 -19
- package/dist/src/modules/validators/policies/claim/permit2.d.ts +1 -1
- package/dist/src/modules/validators/policies/claim/permit2.js +39 -44
- package/dist/src/modules/validators/policies/claim/types.js +11 -14
- package/dist/src/modules/validators/smart-sessions.d.ts +4 -4
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +77 -97
- package/dist/src/orchestrator/client.d.ts +10 -5
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +73 -66
- package/dist/src/orchestrator/consts.d.ts +1 -1
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +2 -8
- package/dist/src/orchestrator/error.js +1 -33
- package/dist/src/orchestrator/index.d.ts +8 -7
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +8 -57
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.js +19 -33
- package/dist/src/orchestrator/types.d.ts +5 -1
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/types.js +1 -17
- package/dist/src/orchestrator/utils.js +1 -3
- package/dist/src/types.d.ts +29 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -2
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.js +9 -15
- package/package.json +29 -98
- package/dist/src/accounts/index.test.d.ts +0 -2
- package/dist/src/accounts/index.test.d.ts.map +0 -1
- package/dist/src/accounts/index.test.js +0 -33
- package/dist/src/accounts/json-rpc/index.test.d.ts +0 -2
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/index.test.js +0 -35
- package/dist/src/accounts/json-rpc/providers.test.d.ts +0 -2
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/providers.test.js +0 -43
- package/dist/src/accounts/kernel.test.d.ts +0 -2
- package/dist/src/accounts/kernel.test.d.ts.map +0 -1
- package/dist/src/accounts/kernel.test.js +0 -132
- package/dist/src/accounts/nexus.test.d.ts +0 -2
- package/dist/src/accounts/nexus.test.d.ts.map +0 -1
- package/dist/src/accounts/nexus.test.js +0 -118
- package/dist/src/accounts/safe.test.d.ts +0 -2
- package/dist/src/accounts/safe.test.d.ts.map +0 -1
- package/dist/src/accounts/safe.test.js +0 -168
- package/dist/src/accounts/signing/passkeys.test.d.ts +0 -2
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +0 -1
- package/dist/src/accounts/signing/passkeys.test.js +0 -88
- package/dist/src/accounts/startale.test.d.ts +0 -2
- package/dist/src/accounts/startale.test.d.ts.map +0 -1
- package/dist/src/accounts/startale.test.js +0 -189
- package/dist/src/accounts/utils.test.d.ts +0 -2
- package/dist/src/accounts/utils.test.d.ts.map +0 -1
- package/dist/src/accounts/utils.test.js +0 -49
- package/dist/src/actions/ecdsa.test.d.ts +0 -2
- package/dist/src/actions/ecdsa.test.d.ts.map +0 -1
- package/dist/src/actions/ecdsa.test.js +0 -99
- package/dist/src/actions/passkeys.test.d.ts +0 -2
- package/dist/src/actions/passkeys.test.d.ts.map +0 -1
- package/dist/src/actions/passkeys.test.js +0 -54
- package/dist/src/actions/recovery.test.d.ts +0 -2
- package/dist/src/actions/recovery.test.d.ts.map +0 -1
- package/dist/src/actions/recovery.test.js +0 -168
- package/dist/src/execution/signing.test.d.ts +0 -2
- package/dist/src/execution/signing.test.d.ts.map +0 -1
- package/dist/src/execution/signing.test.js +0 -465
- package/dist/src/execution/utils.test.d.ts +0 -2
- package/dist/src/execution/utils.test.d.ts.map +0 -1
- package/dist/src/execution/utils.test.js +0 -388
- package/dist/src/modules/index.test.d.ts +0 -2
- package/dist/src/modules/index.test.d.ts.map +0 -1
- package/dist/src/modules/index.test.js +0 -81
- package/dist/src/modules/validators/core.test.d.ts +0 -2
- package/dist/src/modules/validators/core.test.d.ts.map +0 -1
- package/dist/src/modules/validators/core.test.js +0 -101
- package/dist/src/modules/validators/policies/claim/permit2.test.d.ts +0 -2
- package/dist/src/modules/validators/policies/claim/permit2.test.d.ts.map +0 -1
- package/dist/src/modules/validators/policies/claim/permit2.test.js +0 -519
- package/dist/src/modules/validators/smart-sessions.test.d.ts +0 -2
- package/dist/src/modules/validators/smart-sessions.test.d.ts.map +0 -1
- package/dist/src/modules/validators/smart-sessions.test.js +0 -311
- package/dist/src/orchestrator/registry.test.d.ts +0 -2
- package/dist/src/orchestrator/registry.test.d.ts.map +0 -1
- package/dist/src/orchestrator/registry.test.js +0 -154
- package/dist/src/utils/index.test.d.ts +0 -2
- package/dist/src/utils/index.test.d.ts.map +0 -1
- package/dist/src/utils/index.test.js +0 -42
- package/dist/test/consts.d.ts +0 -10
- package/dist/test/consts.d.ts.map +0 -1
- package/dist/test/consts.js +0 -22
- package/dist/test/utils/utils.d.ts +0 -5
- package/dist/test/utils/utils.d.ts.map +0 -1
- package/dist/test/utils/utils.js +0 -20
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const viem_1 = require("viem");
|
|
37
|
-
const chains_1 = require("viem/chains");
|
|
38
|
-
const vitest_1 = require("vitest");
|
|
39
|
-
const consts_1 = require("../../test/consts");
|
|
40
|
-
const utils_1 = require("./utils");
|
|
41
|
-
const { MOCK_EMISSARY, MOCK_EIP1271, MOCK_ACCOUNT, MOCK_EXECUTOR, MOCK_VALIDATOR, mockGetEmissarySignature, mockGetEip1271Signature, mockIsSessionEnabled, MOCK_TYPED_DATA, } = vitest_1.vi.hoisted(() => {
|
|
42
|
-
const MOCK_ACCOUNT = '0x1111111111111111111111111111111111111111';
|
|
43
|
-
const MOCK_EXECUTOR = '0x2222222222222222222222222222222222222222';
|
|
44
|
-
const MOCK_VALIDATOR = '0x3333333333333333333333333333333333333333';
|
|
45
|
-
const MOCK_EMISSARY = `0x${'ee'.repeat(65)}`;
|
|
46
|
-
const MOCK_EIP1271 = `0x${'12'.repeat(65)}`;
|
|
47
|
-
const mockGetEmissarySignature = vitest_1.vi.fn().mockResolvedValue(MOCK_EMISSARY);
|
|
48
|
-
const mockGetEip1271Signature = vitest_1.vi.fn().mockResolvedValue(MOCK_EIP1271);
|
|
49
|
-
const mockIsSessionEnabled = vitest_1.vi.fn().mockResolvedValue(true);
|
|
50
|
-
const MOCK_TYPED_DATA = {
|
|
51
|
-
domain: {
|
|
52
|
-
name: 'Test',
|
|
53
|
-
version: '1',
|
|
54
|
-
chainId: 8453,
|
|
55
|
-
verifyingContract: MOCK_EXECUTOR,
|
|
56
|
-
},
|
|
57
|
-
types: {
|
|
58
|
-
Test: [{ name: 'value', type: 'uint256' }],
|
|
59
|
-
},
|
|
60
|
-
primaryType: 'Test',
|
|
61
|
-
message: { value: 1n },
|
|
62
|
-
};
|
|
63
|
-
return {
|
|
64
|
-
MOCK_EMISSARY: MOCK_EMISSARY,
|
|
65
|
-
MOCK_EIP1271: MOCK_EIP1271,
|
|
66
|
-
MOCK_ACCOUNT: MOCK_ACCOUNT,
|
|
67
|
-
MOCK_EXECUTOR: MOCK_EXECUTOR,
|
|
68
|
-
MOCK_VALIDATOR: MOCK_VALIDATOR,
|
|
69
|
-
mockGetEmissarySignature,
|
|
70
|
-
mockGetEip1271Signature,
|
|
71
|
-
mockIsSessionEnabled,
|
|
72
|
-
MOCK_TYPED_DATA,
|
|
73
|
-
};
|
|
74
|
-
});
|
|
75
|
-
vitest_1.vi.mock('../orchestrator', () => ({
|
|
76
|
-
getOrchestrator: vitest_1.vi.fn(),
|
|
77
|
-
}));
|
|
78
|
-
vitest_1.vi.mock('../accounts', () => ({
|
|
79
|
-
getAddress: vitest_1.vi.fn().mockReturnValue(MOCK_ACCOUNT),
|
|
80
|
-
getEmissarySignature: mockGetEmissarySignature,
|
|
81
|
-
getEip1271Signature: mockGetEip1271Signature,
|
|
82
|
-
getSmartAccount: vitest_1.vi.fn(),
|
|
83
|
-
getEip712Domain: vitest_1.vi.fn(),
|
|
84
|
-
getAccountProvider: vitest_1.vi.fn(),
|
|
85
|
-
getInitCode: vitest_1.vi.fn(),
|
|
86
|
-
getGuardianSmartAccount: vitest_1.vi.fn(),
|
|
87
|
-
getTypedDataPackedSignature: vitest_1.vi.fn(),
|
|
88
|
-
toErc6492Signature: vitest_1.vi.fn(),
|
|
89
|
-
is7702: vitest_1.vi.fn().mockReturnValue(false),
|
|
90
|
-
getEip7702InitCall: vitest_1.vi.fn(),
|
|
91
|
-
EoaAccountMustHaveAccountError: class extends Error {
|
|
92
|
-
},
|
|
93
|
-
EoaSigningMethodNotConfiguredError: class extends Error {
|
|
94
|
-
},
|
|
95
|
-
FactoryArgsNotAvailableError: class extends Error {
|
|
96
|
-
},
|
|
97
|
-
}));
|
|
98
|
-
vitest_1.vi.mock('../accounts/signing/common', () => ({
|
|
99
|
-
convertOwnerSetToSignerSet: vitest_1.vi.fn(),
|
|
100
|
-
}));
|
|
101
|
-
vitest_1.vi.mock('../accounts/startale', () => ({
|
|
102
|
-
K1_DEFAULT_VALIDATOR_ADDRESS: '0x0000000000000000000000000000000000000000',
|
|
103
|
-
}));
|
|
104
|
-
vitest_1.vi.mock('../accounts/utils', () => ({
|
|
105
|
-
createTransport: vitest_1.vi.fn(),
|
|
106
|
-
getBundlerClient: vitest_1.vi.fn(),
|
|
107
|
-
}));
|
|
108
|
-
vitest_1.vi.mock('../modules', () => ({
|
|
109
|
-
getIntentExecutor: vitest_1.vi.fn().mockReturnValue({
|
|
110
|
-
address: MOCK_EXECUTOR,
|
|
111
|
-
type: 7,
|
|
112
|
-
initData: '0x',
|
|
113
|
-
deInitData: '0x',
|
|
114
|
-
additionalContext: '0x',
|
|
115
|
-
}),
|
|
116
|
-
}));
|
|
117
|
-
vitest_1.vi.mock('../modules/validators', () => ({
|
|
118
|
-
isSessionEnabled: mockIsSessionEnabled,
|
|
119
|
-
getOwnerValidator: vitest_1.vi.fn().mockReturnValue({
|
|
120
|
-
address: MOCK_VALIDATOR,
|
|
121
|
-
type: 1,
|
|
122
|
-
initData: '0x',
|
|
123
|
-
deInitData: '0x',
|
|
124
|
-
additionalContext: '0x',
|
|
125
|
-
}),
|
|
126
|
-
buildMockSignature: vitest_1.vi.fn(),
|
|
127
|
-
getPermissionId: vitest_1.vi.fn().mockReturnValue(`0x${'cc'.repeat(32)}`),
|
|
128
|
-
getSmartSessionValidator: vitest_1.vi.fn().mockReturnValue({
|
|
129
|
-
address: MOCK_VALIDATOR,
|
|
130
|
-
type: 1,
|
|
131
|
-
initData: '0x',
|
|
132
|
-
deInitData: '0x',
|
|
133
|
-
additionalContext: '0x',
|
|
134
|
-
}),
|
|
135
|
-
}));
|
|
136
|
-
vitest_1.vi.mock('../modules/validators/core', () => ({
|
|
137
|
-
supportsEip712: vitest_1.vi.fn().mockReturnValue(false),
|
|
138
|
-
getMultiFactorValidator: vitest_1.vi.fn(),
|
|
139
|
-
getSocialRecoveryValidator: vitest_1.vi.fn(),
|
|
140
|
-
getWebAuthnValidator: vitest_1.vi.fn(),
|
|
141
|
-
}));
|
|
142
|
-
vitest_1.vi.mock('../orchestrator/registry', () => ({
|
|
143
|
-
getChainById: vitest_1.vi.fn().mockReturnValue(chains_1.base),
|
|
144
|
-
getTokenAddress: vitest_1.vi.fn(),
|
|
145
|
-
resolveTokenAddress: vitest_1.vi.fn(),
|
|
146
|
-
}));
|
|
147
|
-
vitest_1.vi.mock('./singleChainOps', () => ({
|
|
148
|
-
getTypedData: vitest_1.vi.fn().mockReturnValue(MOCK_TYPED_DATA),
|
|
149
|
-
}));
|
|
150
|
-
vitest_1.vi.mock('./compact', () => ({
|
|
151
|
-
getCompactTypedData: vitest_1.vi.fn().mockReturnValue(MOCK_TYPED_DATA),
|
|
152
|
-
}));
|
|
153
|
-
vitest_1.vi.mock('./error', () => ({
|
|
154
|
-
Eip7702InitSignatureRequiredError: class extends Error {
|
|
155
|
-
},
|
|
156
|
-
SignerNotSupportedError: class extends Error {
|
|
157
|
-
},
|
|
158
|
-
}));
|
|
159
|
-
vitest_1.vi.mock('./permit2', () => ({
|
|
160
|
-
getTypedData: vitest_1.vi.fn().mockReturnValue(MOCK_TYPED_DATA),
|
|
161
|
-
}));
|
|
162
|
-
// --- Helpers ---
|
|
163
|
-
const makeElement = (settlementLayer) => ({
|
|
164
|
-
mandate: {
|
|
165
|
-
destinationChainId: chains_1.base.id,
|
|
166
|
-
destinationOps: {
|
|
167
|
-
vt: `0x${'00'.repeat(32)}`,
|
|
168
|
-
ops: [],
|
|
169
|
-
},
|
|
170
|
-
preClaimOps: {
|
|
171
|
-
vt: `0x${'00'.repeat(32)}`,
|
|
172
|
-
ops: [],
|
|
173
|
-
},
|
|
174
|
-
qualifier: {
|
|
175
|
-
settlementContext: {
|
|
176
|
-
settlementLayer,
|
|
177
|
-
fundingMethod: 'NO_FUNDING',
|
|
178
|
-
using7579: true,
|
|
179
|
-
gasRefund: {
|
|
180
|
-
token: viem_1.zeroAddress,
|
|
181
|
-
exchangeRate: 0n,
|
|
182
|
-
overhead: 0n,
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
const makeIntentOp = (settlementLayer, targetExecutionNonce = '200') => {
|
|
189
|
-
const layers = Array.isArray(settlementLayer)
|
|
190
|
-
? settlementLayer
|
|
191
|
-
: [settlementLayer];
|
|
192
|
-
return {
|
|
193
|
-
sponsor: MOCK_ACCOUNT,
|
|
194
|
-
nonce: '100',
|
|
195
|
-
targetExecutionNonce,
|
|
196
|
-
expires: '9999999999',
|
|
197
|
-
elements: layers.map(makeElement),
|
|
198
|
-
serverSignature: '0x',
|
|
199
|
-
signedMetadata: { fees: {} },
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
// verifyExecutions auto-derived as true when session.actions is non-empty
|
|
203
|
-
const sessionWithActions = {
|
|
204
|
-
chain: chains_1.base,
|
|
205
|
-
owners: { type: 'ecdsa', accounts: [consts_1.accountA] },
|
|
206
|
-
actions: [{ policies: [{ type: 'usage-limit', limit: 1n }] }],
|
|
207
|
-
};
|
|
208
|
-
// verifyExecutions auto-derived as false when session.actions is absent
|
|
209
|
-
const sessionNoActions = {
|
|
210
|
-
chain: chains_1.base,
|
|
211
|
-
owners: { type: 'ecdsa', accounts: [consts_1.accountA] },
|
|
212
|
-
};
|
|
213
|
-
const config = {
|
|
214
|
-
apiKey: 'test',
|
|
215
|
-
owners: { type: 'ecdsa', accounts: [consts_1.accountA] },
|
|
216
|
-
};
|
|
217
|
-
const makeSessionSigners = (session) => ({
|
|
218
|
-
type: 'experimental_session',
|
|
219
|
-
session,
|
|
220
|
-
});
|
|
221
|
-
const ownerSigners = {
|
|
222
|
-
type: 'owner',
|
|
223
|
-
kind: 'ecdsa',
|
|
224
|
-
accounts: [consts_1.accountA],
|
|
225
|
-
};
|
|
226
|
-
// --- Tests ---
|
|
227
|
-
(0, vitest_1.beforeEach)(() => {
|
|
228
|
-
vitest_1.vi.clearAllMocks();
|
|
229
|
-
mockGetEmissarySignature.mockResolvedValue(MOCK_EMISSARY);
|
|
230
|
-
mockGetEip1271Signature.mockResolvedValue(MOCK_EIP1271);
|
|
231
|
-
mockIsSessionEnabled.mockResolvedValue(true);
|
|
232
|
-
});
|
|
233
|
-
(0, vitest_1.describe)('getTargetExecutionSignature', () => {
|
|
234
|
-
(0, vitest_1.test)('undefined signers returns undefined', async () => {
|
|
235
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
236
|
-
const result = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, undefined);
|
|
237
|
-
(0, vitest_1.expect)(result).toBeUndefined();
|
|
238
|
-
});
|
|
239
|
-
(0, vitest_1.test)('non-session signers returns undefined', async () => {
|
|
240
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
241
|
-
const result = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, ownerSigners);
|
|
242
|
-
(0, vitest_1.expect)(result).toBeUndefined();
|
|
243
|
-
});
|
|
244
|
-
(0, vitest_1.test)('SAME_CHAIN + verifyExecutions: true returns emissary sig', async () => {
|
|
245
|
-
const intentOp = makeIntentOp('SAME_CHAIN');
|
|
246
|
-
const signers = makeSessionSigners(sessionWithActions);
|
|
247
|
-
const result = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, signers);
|
|
248
|
-
(0, vitest_1.expect)(result).toBe(MOCK_EMISSARY);
|
|
249
|
-
});
|
|
250
|
-
(0, vitest_1.test)('INTENT_EXECUTOR + verifyExecutions: false (no actions) returns undefined', async () => {
|
|
251
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
252
|
-
const signers = makeSessionSigners(sessionNoActions);
|
|
253
|
-
const result = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, signers);
|
|
254
|
-
(0, vitest_1.expect)(result).toBeUndefined();
|
|
255
|
-
});
|
|
256
|
-
(0, vitest_1.test)('explicit verifyExecutions: false on signers overrides session with actions', async () => {
|
|
257
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
258
|
-
const signers = {
|
|
259
|
-
type: 'experimental_session',
|
|
260
|
-
session: sessionWithActions,
|
|
261
|
-
verifyExecutions: false,
|
|
262
|
-
};
|
|
263
|
-
const result = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, signers);
|
|
264
|
-
(0, vitest_1.expect)(result).toBeUndefined();
|
|
265
|
-
});
|
|
266
|
-
(0, vitest_1.test)('explicit verifyExecutions: true on signers overrides session without actions', async () => {
|
|
267
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
268
|
-
const signers = {
|
|
269
|
-
type: 'experimental_session',
|
|
270
|
-
session: sessionNoActions,
|
|
271
|
-
verifyExecutions: true,
|
|
272
|
-
};
|
|
273
|
-
const result = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, signers);
|
|
274
|
-
(0, vitest_1.expect)(result).toBe(MOCK_EMISSARY);
|
|
275
|
-
});
|
|
276
|
-
(0, vitest_1.test)('session not yet enabled still resolves verifyExecutions from actions', async () => {
|
|
277
|
-
mockIsSessionEnabled.mockResolvedValueOnce(false);
|
|
278
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
279
|
-
const signers = makeSessionSigners(sessionWithActions);
|
|
280
|
-
const result = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, signers);
|
|
281
|
-
(0, vitest_1.expect)(result).toBe(MOCK_EMISSARY);
|
|
282
|
-
});
|
|
283
|
-
(0, vitest_1.test)('mixed INTENT_EXECUTOR + SAME_CHAIN elements returns emissary sig', async () => {
|
|
284
|
-
const intentOp = makeIntentOp(['INTENT_EXECUTOR', 'SAME_CHAIN']);
|
|
285
|
-
const signers = makeSessionSigners(sessionWithActions);
|
|
286
|
-
const result = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, signers);
|
|
287
|
-
(0, vitest_1.expect)(result).toBe(MOCK_EMISSARY);
|
|
288
|
-
});
|
|
289
|
-
(0, vitest_1.test)('INTENT_EXECUTOR + verifyExecutions: true returns emissary sig', async () => {
|
|
290
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
291
|
-
const signers = makeSessionSigners(sessionWithActions);
|
|
292
|
-
const result = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, signers);
|
|
293
|
-
(0, vitest_1.expect)(result).toBe(MOCK_EMISSARY);
|
|
294
|
-
(0, vitest_1.expect)(mockGetEmissarySignature).toHaveBeenCalledTimes(1);
|
|
295
|
-
(0, vitest_1.expect)(mockGetEip1271Signature).not.toHaveBeenCalled();
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
(0, vitest_1.describe)('signIntent with owner signers', () => {
|
|
299
|
-
(0, vitest_1.test)('gives EIP-1271 destinationSignature, not emissary', async () => {
|
|
300
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
301
|
-
const { destinationSignature, originSignatures } = await (0, utils_1.signIntent)(config, intentOp, chains_1.base, ownerSigners);
|
|
302
|
-
(0, vitest_1.expect)(destinationSignature).toBe(MOCK_EIP1271);
|
|
303
|
-
(0, vitest_1.expect)(mockGetEip1271Signature).toHaveBeenCalled();
|
|
304
|
-
(0, vitest_1.expect)(mockGetEmissarySignature).not.toHaveBeenCalled();
|
|
305
|
-
(0, vitest_1.expect)(originSignatures).toHaveLength(1);
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
(0, vitest_1.describe)('signIntent destinationSignature', () => {
|
|
309
|
-
(0, vitest_1.test)('verifyExecutions: true + INTENT_EXECUTOR — emissary destinationSignature, both sigs generated', async () => {
|
|
310
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
311
|
-
const signers = makeSessionSigners(sessionWithActions);
|
|
312
|
-
const { destinationSignature, originSignatures } = await (0, utils_1.signIntent)(config, intentOp, chains_1.base, signers);
|
|
313
|
-
// destinationSignature picks preClaimSig (emissary format) from the { preClaimSig, notarizedClaimSig } pair
|
|
314
|
-
(0, vitest_1.expect)(destinationSignature).toBe(MOCK_EMISSARY);
|
|
315
|
-
// Both emissary and EIP-1271 are produced internally (preClaimSig + notarizedClaimSig)
|
|
316
|
-
(0, vitest_1.expect)(mockGetEmissarySignature).toHaveBeenCalled();
|
|
317
|
-
(0, vitest_1.expect)(mockGetEip1271Signature).toHaveBeenCalled();
|
|
318
|
-
(0, vitest_1.expect)(originSignatures).toHaveLength(1);
|
|
319
|
-
});
|
|
320
|
-
(0, vitest_1.test)('verifyExecutions: false + INTENT_EXECUTOR — EIP-1271 destinationSignature only', async () => {
|
|
321
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
322
|
-
const signers = makeSessionSigners(sessionNoActions);
|
|
323
|
-
const { destinationSignature, originSignatures } = await (0, utils_1.signIntent)(config, intentOp, chains_1.base, signers);
|
|
324
|
-
(0, vitest_1.expect)(destinationSignature).toBe(MOCK_EIP1271);
|
|
325
|
-
(0, vitest_1.expect)(mockGetEmissarySignature).not.toHaveBeenCalled();
|
|
326
|
-
(0, vitest_1.expect)(originSignatures).toHaveLength(1);
|
|
327
|
-
});
|
|
328
|
-
(0, vitest_1.test)('verifyExecutions: true + SAME_CHAIN — emissary destinationSignature', async () => {
|
|
329
|
-
const intentOp = makeIntentOp('SAME_CHAIN');
|
|
330
|
-
const signers = makeSessionSigners(sessionWithActions);
|
|
331
|
-
const { destinationSignature } = await (0, utils_1.signIntent)(config, intentOp, chains_1.base, signers);
|
|
332
|
-
(0, vitest_1.expect)(destinationSignature).toBe(MOCK_EMISSARY);
|
|
333
|
-
});
|
|
334
|
-
(0, vitest_1.test)('multi-element op produces one originSignature per element', async () => {
|
|
335
|
-
const intentOp = makeIntentOp(['INTENT_EXECUTOR', 'INTENT_EXECUTOR']);
|
|
336
|
-
const signers = makeSessionSigners(sessionWithActions);
|
|
337
|
-
const { originSignatures } = await (0, utils_1.signIntent)(config, intentOp, chains_1.base, signers);
|
|
338
|
-
(0, vitest_1.expect)(originSignatures).toHaveLength(2);
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
(0, vitest_1.describe)('signIntent + getTargetExecutionSignature routing', () => {
|
|
342
|
-
(0, vitest_1.test)('INTENT_EXECUTOR + verifyExecutions: true — EMISSARY for both', async () => {
|
|
343
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
344
|
-
const signers = makeSessionSigners(sessionWithActions);
|
|
345
|
-
const { destinationSignature } = await (0, utils_1.signIntent)(config, intentOp, chains_1.base, signers);
|
|
346
|
-
const targetExecutionSignature = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, signers);
|
|
347
|
-
(0, vitest_1.expect)(destinationSignature).toBe(MOCK_EMISSARY);
|
|
348
|
-
(0, vitest_1.expect)(targetExecutionSignature).toBe(MOCK_EMISSARY);
|
|
349
|
-
});
|
|
350
|
-
(0, vitest_1.test)('INTENT_EXECUTOR + verifyExecutions: false — EIP-1271 destination, undefined target', async () => {
|
|
351
|
-
const intentOp = makeIntentOp('INTENT_EXECUTOR');
|
|
352
|
-
const signers = makeSessionSigners(sessionNoActions);
|
|
353
|
-
const { destinationSignature } = await (0, utils_1.signIntent)(config, intentOp, chains_1.base, signers);
|
|
354
|
-
const targetExecutionSignature = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, signers);
|
|
355
|
-
(0, vitest_1.expect)(destinationSignature).toBe(MOCK_EIP1271);
|
|
356
|
-
(0, vitest_1.expect)(targetExecutionSignature).toBeUndefined();
|
|
357
|
-
});
|
|
358
|
-
(0, vitest_1.test)('SAME_CHAIN + verifyExecutions: true — EMISSARY for both destination and target', async () => {
|
|
359
|
-
const intentOp = makeIntentOp('SAME_CHAIN');
|
|
360
|
-
const signers = makeSessionSigners(sessionWithActions);
|
|
361
|
-
const { destinationSignature } = await (0, utils_1.signIntent)(config, intentOp, chains_1.base, signers);
|
|
362
|
-
const targetExecutionSignature = await (0, utils_1.getTargetExecutionSignature)(config, intentOp, chains_1.base, signers);
|
|
363
|
-
(0, vitest_1.expect)(destinationSignature).toBe(MOCK_EMISSARY);
|
|
364
|
-
(0, vitest_1.expect)(targetExecutionSignature).toBe(MOCK_EMISSARY);
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
// Permit2 typed data shape that triggers resolveClaimPolicyData
|
|
368
|
-
const MOCK_PERMIT2_TYPED_DATA = {
|
|
369
|
-
domain: { name: 'Permit2', chainId: 8453, verifyingContract: MOCK_EXECUTOR },
|
|
370
|
-
types: {
|
|
371
|
-
PermitBatchWitnessTransferFrom: [{ name: 'nonce', type: 'uint256' }],
|
|
372
|
-
},
|
|
373
|
-
primaryType: 'PermitBatchWitnessTransferFrom',
|
|
374
|
-
message: {
|
|
375
|
-
permitted: [
|
|
376
|
-
{ token: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', amount: 20000n },
|
|
377
|
-
],
|
|
378
|
-
spender: MOCK_EXECUTOR,
|
|
379
|
-
nonce: 1n,
|
|
380
|
-
deadline: 9999999999n,
|
|
381
|
-
mandate: {
|
|
382
|
-
target: {
|
|
383
|
-
recipient: MOCK_ACCOUNT,
|
|
384
|
-
tokenOut: [],
|
|
385
|
-
targetChain: 8453n,
|
|
386
|
-
fillExpiry: 9999999999n,
|
|
387
|
-
},
|
|
388
|
-
minGas: 0n,
|
|
389
|
-
originOps: { vt: `0x${'00'.repeat(32)}`, ops: [] },
|
|
390
|
-
destOps: { vt: `0x${'00'.repeat(32)}`, ops: [] },
|
|
391
|
-
q: `0x${'ab'.repeat(32)}`,
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
};
|
|
395
|
-
const makePermit2IntentOp = () => ({
|
|
396
|
-
sponsor: MOCK_ACCOUNT,
|
|
397
|
-
nonce: '100',
|
|
398
|
-
targetExecutionNonce: '200',
|
|
399
|
-
expires: '9999999999',
|
|
400
|
-
elements: [
|
|
401
|
-
{
|
|
402
|
-
mandate: {
|
|
403
|
-
destinationChainId: chains_1.base.id,
|
|
404
|
-
destinationOps: { vt: `0x${'00'.repeat(32)}`, ops: [] },
|
|
405
|
-
preClaimOps: { vt: `0x${'00'.repeat(32)}`, ops: [] },
|
|
406
|
-
qualifier: {
|
|
407
|
-
settlementContext: {
|
|
408
|
-
// SAME_CHAIN avoids the INTENT_EXECUTOR branch so the PERMIT2 funding path is taken
|
|
409
|
-
settlementLayer: 'SAME_CHAIN',
|
|
410
|
-
fundingMethod: 'PERMIT2',
|
|
411
|
-
using7579: true,
|
|
412
|
-
gasRefund: { token: viem_1.zeroAddress, exchangeRate: 0n, overhead: 0n },
|
|
413
|
-
},
|
|
414
|
-
},
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
],
|
|
418
|
-
});
|
|
419
|
-
const sessionWithClaimPolicy = {
|
|
420
|
-
chain: chains_1.base,
|
|
421
|
-
owners: { type: 'ecdsa', accounts: [consts_1.accountA] },
|
|
422
|
-
actions: [{ policies: [{ type: 'usage-limit', limit: 1n }] }],
|
|
423
|
-
claimPolicies: [{ type: 'permit2-claim' }],
|
|
424
|
-
};
|
|
425
|
-
(0, vitest_1.describe)('signIntent with permit2 claim policy', () => {
|
|
426
|
-
(0, vitest_1.test)('Permit2 typed data + claimPolicies → getEip1271Signature called with claimPolicyData', async () => {
|
|
427
|
-
const { getTypedData: mockPermit2GetTypedData } = await Promise.resolve().then(() => __importStar(require('./permit2')));
|
|
428
|
-
vitest_1.vi.mocked(mockPermit2GetTypedData).mockReturnValueOnce(MOCK_PERMIT2_TYPED_DATA);
|
|
429
|
-
const signers = {
|
|
430
|
-
type: 'experimental_session',
|
|
431
|
-
session: sessionWithClaimPolicy,
|
|
432
|
-
verifyExecutions: true,
|
|
433
|
-
};
|
|
434
|
-
await (0, utils_1.signIntent)(config, makePermit2IntentOp(), chains_1.base, signers);
|
|
435
|
-
(0, vitest_1.expect)(mockGetEip1271Signature).toHaveBeenCalled();
|
|
436
|
-
const sessionSignersArg = mockGetEip1271Signature.mock.calls[0][1];
|
|
437
|
-
(0, vitest_1.expect)(sessionSignersArg.claimPolicyData).toBeDefined();
|
|
438
|
-
(0, vitest_1.expect)(sessionSignersArg.claimPolicyData).not.toBe('0x');
|
|
439
|
-
});
|
|
440
|
-
(0, vitest_1.test)('non-Permit2 typed data + claimPolicies → getEip1271Signature called without claimPolicyData', async () => {
|
|
441
|
-
// Default mock returns MOCK_TYPED_DATA (primaryType: 'Test'), not Permit2
|
|
442
|
-
const signers = {
|
|
443
|
-
type: 'experimental_session',
|
|
444
|
-
session: sessionWithClaimPolicy,
|
|
445
|
-
verifyExecutions: true,
|
|
446
|
-
};
|
|
447
|
-
await (0, utils_1.signIntent)(config, makeIntentOp('INTENT_EXECUTOR'), chains_1.base, signers);
|
|
448
|
-
(0, vitest_1.expect)(mockGetEip1271Signature).toHaveBeenCalled();
|
|
449
|
-
const sessionSignersArg = mockGetEip1271Signature.mock.calls[0][1];
|
|
450
|
-
(0, vitest_1.expect)(sessionSignersArg.claimPolicyData).toBeUndefined();
|
|
451
|
-
});
|
|
452
|
-
(0, vitest_1.test)('Permit2 typed data without claimPolicies → getEip1271Signature called without claimPolicyData', async () => {
|
|
453
|
-
const { getTypedData: mockPermit2GetTypedData } = await Promise.resolve().then(() => __importStar(require('./permit2')));
|
|
454
|
-
vitest_1.vi.mocked(mockPermit2GetTypedData).mockReturnValueOnce(MOCK_PERMIT2_TYPED_DATA);
|
|
455
|
-
const signers = {
|
|
456
|
-
type: 'experimental_session',
|
|
457
|
-
session: sessionWithActions, // no claimPolicies
|
|
458
|
-
verifyExecutions: true,
|
|
459
|
-
};
|
|
460
|
-
await (0, utils_1.signIntent)(config, makePermit2IntentOp(), chains_1.base, signers);
|
|
461
|
-
(0, vitest_1.expect)(mockGetEip1271Signature).toHaveBeenCalled();
|
|
462
|
-
const sessionSignersArg = mockGetEip1271Signature.mock.calls[0][1];
|
|
463
|
-
(0, vitest_1.expect)(sessionSignersArg.claimPolicyData).toBeUndefined();
|
|
464
|
-
});
|
|
465
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../execution/utils.test.ts"],"names":[],"mappings":""}
|