@rhinestone/sdk 1.5.1 → 2.0.0-beta.1
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 +1 -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.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/providers.js +7 -9
- 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 +2 -2
- 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 +1 -1
- package/dist/src/auth/provider.js +1 -4
- package/dist/src/errors/index.d.ts +4 -4
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +12 -54
- package/dist/src/execution/compact.d.ts +1 -144
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +1 -117
- package/dist/src/execution/error.d.ts +10 -1
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +9 -11
- package/dist/src/execution/index.d.ts +10 -11
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +64 -75
- package/dist/src/execution/permit2.d.ts +2 -138
- package/dist/src/execution/permit2.d.ts.map +1 -1
- package/dist/src/execution/permit2.js +5 -239
- package/dist/src/execution/utils.d.ts +31 -15
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +283 -256
- package/dist/src/index.d.ts +15 -14
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +57 -68
- package/dist/src/jwt-server/digest.js +3 -6
- package/dist/src/jwt-server/express.d.ts +1 -1
- package/dist/src/jwt-server/express.d.ts.map +1 -1
- package/dist/src/jwt-server/express.js +6 -7
- package/dist/src/jwt-server/handlers.d.ts +1 -1
- package/dist/src/jwt-server/handlers.js +7 -11
- package/dist/src/jwt-server/index.d.ts +7 -7
- package/dist/src/jwt-server/index.js +6 -17
- package/dist/src/jwt-server/jcs.js +1 -4
- package/dist/src/jwt-server/signer.d.ts +1 -1
- package/dist/src/jwt-server/signer.js +10 -13
- package/dist/src/jwt-server/sponsorship.js +2 -7
- package/dist/src/jwt-server/web.d.ts +1 -1
- package/dist/src/jwt-server/web.js +5 -9
- 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 +3 -3
- package/dist/src/modules/validators/smart-sessions.js +65 -94
- package/dist/src/orchestrator/caip2.d.ts +7 -0
- package/dist/src/orchestrator/caip2.d.ts.map +1 -0
- package/dist/src/orchestrator/caip2.js +17 -0
- package/dist/src/orchestrator/client.d.ts +12 -12
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +199 -305
- package/dist/src/orchestrator/consts.d.ts +2 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +3 -9
- package/dist/src/orchestrator/error.d.ts +72 -217
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +117 -227
- package/dist/src/orchestrator/index.d.ts +9 -9
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +7 -56
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.js +19 -33
- package/dist/src/orchestrator/types.d.ts +97 -232
- 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 +5 -7
- 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 +15 -98
- package/dist/src/execution/singleChainOps.d.ts +0 -41
- package/dist/src/execution/singleChainOps.d.ts.map +0 -1
- package/dist/src/execution/singleChainOps.js +0 -44
- package/dist/src/execution/types.d.ts +0 -36
- package/dist/src/execution/types.d.ts.map +0 -1
- package/dist/src/execution/types.js +0 -2
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("./core");
|
|
5
|
-
Object.defineProperty(exports, "getMockSignature", { enumerable: true, get: function () { return core_1.getMockSignature; } });
|
|
6
|
-
Object.defineProperty(exports, "getOwnerValidator", { enumerable: true, get: function () { return core_1.getOwnerValidator; } });
|
|
7
|
-
Object.defineProperty(exports, "MULTI_FACTOR_VALIDATOR_ADDRESS", { enumerable: true, get: function () { return core_1.MULTI_FACTOR_VALIDATOR_ADDRESS; } });
|
|
8
|
-
Object.defineProperty(exports, "OWNABLE_VALIDATOR_ADDRESS", { enumerable: true, get: function () { return core_1.OWNABLE_VALIDATOR_ADDRESS; } });
|
|
9
|
-
Object.defineProperty(exports, "SMART_SESSION_EMISSARY_ADDRESS", { enumerable: true, get: function () { return core_1.SMART_SESSION_EMISSARY_ADDRESS; } });
|
|
10
|
-
Object.defineProperty(exports, "WEBAUTHN_VALIDATOR_ADDRESS", { enumerable: true, get: function () { return core_1.WEBAUTHN_VALIDATOR_ADDRESS; } });
|
|
11
|
-
const smart_sessions_1 = require("./smart-sessions");
|
|
12
|
-
Object.defineProperty(exports, "buildMockSignature", { enumerable: true, get: function () { return smart_sessions_1.buildMockSignature; } });
|
|
13
|
-
Object.defineProperty(exports, "DUMMY_PRECLAIMOP_SELECTOR", { enumerable: true, get: function () { return smart_sessions_1.DUMMY_PRECLAIMOP_SELECTOR; } });
|
|
14
|
-
Object.defineProperty(exports, "DUMMY_PRECLAIMOP_TARGET", { enumerable: true, get: function () { return smart_sessions_1.DUMMY_PRECLAIMOP_TARGET; } });
|
|
15
|
-
Object.defineProperty(exports, "getEnableSessionCall", { enumerable: true, get: function () { return smart_sessions_1.getEnableSessionCall; } });
|
|
16
|
-
Object.defineProperty(exports, "getPermissionId", { enumerable: true, get: function () { return smart_sessions_1.getPermissionId; } });
|
|
17
|
-
Object.defineProperty(exports, "getSmartSessionValidator", { enumerable: true, get: function () { return smart_sessions_1.getSmartSessionValidator; } });
|
|
18
|
-
Object.defineProperty(exports, "isSessionEnabled", { enumerable: true, get: function () { return smart_sessions_1.isSessionEnabled; } });
|
|
19
|
-
Object.defineProperty(exports, "packSignature", { enumerable: true, get: function () { return smart_sessions_1.packSignature; } });
|
|
1
|
+
import { getMockSignature, getOwnerValidator, MULTI_FACTOR_VALIDATOR_ADDRESS, OWNABLE_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, } from './core.js';
|
|
2
|
+
import { buildMockSignature, DUMMY_PRECLAIMOP_SELECTOR, DUMMY_PRECLAIMOP_TARGET, getEnableSessionCall, getPermissionId, getSmartSessionValidator, isSessionEnabled, packSignature, } from './smart-sessions.js';
|
|
3
|
+
export { OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, MULTI_FACTOR_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS, DUMMY_PRECLAIMOP_TARGET, DUMMY_PRECLAIMOP_SELECTOR, getOwnerValidator, getSmartSessionValidator, getEnableSessionCall, getPermissionId, getMockSignature, buildMockSignature, isSessionEnabled, packSignature, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Address, type Hex } from 'viem';
|
|
2
|
-
import type { Permit2ClaimPolicy } from '../../../../types';
|
|
2
|
+
import type { Permit2ClaimPolicy } from '../../../../types.js';
|
|
3
3
|
/** Typed representation of the Permit2 message fields used for calldata building */
|
|
4
4
|
export interface Permit2ClaimMessage {
|
|
5
5
|
permitted: readonly {
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.PERMIT2_CLAIM_POLICY_ADDRESS = void 0;
|
|
4
|
-
exports.buildPermit2ClaimPolicyCalldata = buildPermit2ClaimPolicyCalldata;
|
|
5
|
-
exports.encodePermit2ClaimPolicyInitData = encodePermit2ClaimPolicyInitData;
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
|
-
const types_1 = require("./types");
|
|
1
|
+
import { concat, encodeAbiParameters, encodePacked, hashStruct, keccak256, maxUint256, toHex, } from 'viem';
|
|
2
|
+
import { ANY_ADDRESS, FIELD_ARBITER, FIELD_EXPIRY, FIELD_FILL_EXPIRY, FIELD_RECIPIENT, FIELD_RECIPIENT_IS_SPONSOR, FIELD_TOKEN_IN, FIELD_TOKEN_OUT, MODE_CHECK_STORAGE, } from './types.js';
|
|
8
3
|
// EIP-712 type definitions for Permit2/Mandate struct encoding.
|
|
9
4
|
// Note: the token-out struct is named 'Token' in the Solidity contract (matching the
|
|
10
5
|
// signed Permit2 message types in execution/permit2.ts).
|
|
@@ -42,31 +37,31 @@ const PERMIT2_TYPES = {
|
|
|
42
37
|
};
|
|
43
38
|
// --- EIP-712 hash helpers ---
|
|
44
39
|
function hashArray(hashes) {
|
|
45
|
-
return
|
|
40
|
+
return keccak256(hashes.length > 0 ? concat(hashes) : '0x');
|
|
46
41
|
}
|
|
47
42
|
function hashTokenPermissionsArray(permitted) {
|
|
48
|
-
return hashArray(permitted.map(({ token, amount }) =>
|
|
43
|
+
return hashArray(permitted.map(({ token, amount }) => hashStruct({
|
|
49
44
|
primaryType: 'TokenPermissions',
|
|
50
45
|
types: PERMIT2_TYPES,
|
|
51
46
|
data: { token, amount },
|
|
52
47
|
})));
|
|
53
48
|
}
|
|
54
49
|
function hashTokenOutArray(tokenOut) {
|
|
55
|
-
return hashArray(tokenOut.map(({ token, amount }) =>
|
|
50
|
+
return hashArray(tokenOut.map(({ token, amount }) => hashStruct({
|
|
56
51
|
primaryType: 'Token',
|
|
57
52
|
types: PERMIT2_TYPES,
|
|
58
53
|
data: { token, amount },
|
|
59
54
|
})));
|
|
60
55
|
}
|
|
61
56
|
function hashOpStruct(op) {
|
|
62
|
-
return
|
|
57
|
+
return hashStruct({
|
|
63
58
|
primaryType: 'Op',
|
|
64
59
|
types: PERMIT2_TYPES,
|
|
65
60
|
data: { vt: op.vt, ops: Array.from(op.ops) },
|
|
66
61
|
});
|
|
67
62
|
}
|
|
68
63
|
function hashMandateStruct(mandate) {
|
|
69
|
-
return
|
|
64
|
+
return hashStruct({
|
|
70
65
|
primaryType: 'Mandate',
|
|
71
66
|
types: PERMIT2_TYPES,
|
|
72
67
|
data: {
|
|
@@ -89,7 +84,7 @@ function hashMandateStruct(mandate) {
|
|
|
89
84
|
// --- Token array encoding helpers ---
|
|
90
85
|
/** Encodes a token+amount pair as [token_as_uint256:32][amount:32] (64 bytes) */
|
|
91
86
|
function encodeTokenEntry(token, amount) {
|
|
92
|
-
return
|
|
87
|
+
return encodeAbiParameters([{ type: 'address' }, { type: 'uint256' }], [token, amount]);
|
|
93
88
|
}
|
|
94
89
|
/**
|
|
95
90
|
* Builds the policySpecificData calldata for a Permit2ClaimPolicy EIP-1271 check.
|
|
@@ -101,7 +96,7 @@ function encodeTokenEntry(token, amount) {
|
|
|
101
96
|
* else — pre-computed mandateHash [32]
|
|
102
97
|
*
|
|
103
98
|
*/
|
|
104
|
-
function buildPermit2ClaimPolicyCalldata(policy, message) {
|
|
99
|
+
export function buildPermit2ClaimPolicyCalldata(policy, message) {
|
|
105
100
|
const tokenInEnabled = !!policy.tokensIn?.length;
|
|
106
101
|
const recipientEnabled = !!policy.recipients?.length;
|
|
107
102
|
const fillExpiryEnabled = !!policy.fillExpiryBounds?.length;
|
|
@@ -114,13 +109,13 @@ function buildPermit2ClaimPolicyCalldata(policy, message) {
|
|
|
114
109
|
recipientIsSponsorEnabled;
|
|
115
110
|
const parts = [];
|
|
116
111
|
// Header: [spender:20][nonce:32][deadline:32] (spender == arbiter in Permit2 context)
|
|
117
|
-
parts.push(
|
|
112
|
+
parts.push(encodePacked(['address', 'uint256', 'uint256'], [message.spender, message.nonce, message.deadline]));
|
|
118
113
|
// TokenIn section
|
|
119
114
|
if (tokenInEnabled) {
|
|
120
115
|
// Expanded: [count:1][token_as_uint256:32][amount:32]...
|
|
121
116
|
if (message.permitted.length > 255)
|
|
122
117
|
throw new Error('permitted array exceeds max length of 255');
|
|
123
|
-
parts.push(
|
|
118
|
+
parts.push(toHex(message.permitted.length, { size: 1 }));
|
|
124
119
|
for (const { token, amount } of message.permitted) {
|
|
125
120
|
parts.push(encodeTokenEntry(token, amount));
|
|
126
121
|
}
|
|
@@ -137,12 +132,12 @@ function buildPermit2ClaimPolicyCalldata(policy, message) {
|
|
|
137
132
|
// Expanded mandate: target fields + minGas + ops hashes + q
|
|
138
133
|
const target = message.mandate.target;
|
|
139
134
|
// Target: [recipient:20][targetChain:32][fillExpiry:32]
|
|
140
|
-
parts.push(
|
|
135
|
+
parts.push(encodePacked(['address', 'uint256', 'uint256'], [target.recipient, target.targetChain, target.fillExpiry]));
|
|
141
136
|
// TokenOut (inside target)
|
|
142
137
|
if (tokenOutEnabled) {
|
|
143
138
|
if (target.tokenOut.length > 255)
|
|
144
139
|
throw new Error('tokenOut array exceeds max length of 255');
|
|
145
|
-
parts.push(
|
|
140
|
+
parts.push(toHex(target.tokenOut.length, { size: 1 }));
|
|
146
141
|
for (const { token, amount } of target.tokenOut) {
|
|
147
142
|
parts.push(encodeTokenEntry(token, amount));
|
|
148
143
|
}
|
|
@@ -151,65 +146,65 @@ function buildPermit2ClaimPolicyCalldata(policy, message) {
|
|
|
151
146
|
parts.push(hashTokenOutArray(target.tokenOut));
|
|
152
147
|
}
|
|
153
148
|
// minGas: uint128 = 16 bytes
|
|
154
|
-
parts.push(
|
|
149
|
+
parts.push(toHex(message.mandate.minGas, { size: 16 }));
|
|
155
150
|
// originOpsHash and destOpsHash: always 32-byte hashes (we don't support ops checks)
|
|
156
151
|
parts.push(hashOpStruct(message.mandate.originOps));
|
|
157
152
|
parts.push(hashOpStruct(message.mandate.destOps));
|
|
158
153
|
// qualificationHash: q is already keccak256(qualifier.encodedVal)
|
|
159
154
|
parts.push(message.mandate.q);
|
|
160
155
|
}
|
|
161
|
-
return
|
|
156
|
+
return concat(parts);
|
|
162
157
|
}
|
|
163
|
-
|
|
164
|
-
function encodePermit2ClaimPolicyInitData(policy) {
|
|
158
|
+
export const PERMIT2_CLAIM_POLICY_ADDRESS = '0x62E3588C6d861C9f986E82EC3757434EDF16ce91';
|
|
159
|
+
export function encodePermit2ClaimPolicyInitData(policy) {
|
|
165
160
|
let modeConfig = 0;
|
|
166
161
|
const setMode = (fieldId) => {
|
|
167
|
-
modeConfig |=
|
|
162
|
+
modeConfig |= MODE_CHECK_STORAGE << (fieldId * 2);
|
|
168
163
|
};
|
|
169
164
|
if (policy.arbiters?.length)
|
|
170
|
-
setMode(
|
|
165
|
+
setMode(FIELD_ARBITER);
|
|
171
166
|
if (policy.expiryBounds)
|
|
172
|
-
setMode(
|
|
167
|
+
setMode(FIELD_EXPIRY);
|
|
173
168
|
if (policy.tokensIn?.length)
|
|
174
|
-
setMode(
|
|
169
|
+
setMode(FIELD_TOKEN_IN);
|
|
175
170
|
if (policy.recipients?.length)
|
|
176
|
-
setMode(
|
|
171
|
+
setMode(FIELD_RECIPIENT);
|
|
177
172
|
if (policy.fillExpiryBounds?.length)
|
|
178
|
-
setMode(
|
|
173
|
+
setMode(FIELD_FILL_EXPIRY);
|
|
179
174
|
if (policy.tokensOut?.length)
|
|
180
|
-
setMode(
|
|
175
|
+
setMode(FIELD_TOKEN_OUT);
|
|
181
176
|
if (policy.recipientIsSponsor)
|
|
182
|
-
setMode(
|
|
183
|
-
const parts = [
|
|
177
|
+
setMode(FIELD_RECIPIENT_IS_SPONSOR);
|
|
178
|
+
const parts = [toHex(modeConfig, { size: 4 })];
|
|
184
179
|
// Arbiter: [count: 1][address: 20] each
|
|
185
180
|
if (policy.arbiters?.length) {
|
|
186
181
|
if (policy.arbiters.length > 255)
|
|
187
182
|
throw new Error('arbiters array exceeds max length of 255');
|
|
188
|
-
parts.push(
|
|
183
|
+
parts.push(encodePacked(['uint8', ...policy.arbiters.map(() => 'address')], [policy.arbiters.length, ...policy.arbiters]));
|
|
189
184
|
}
|
|
190
185
|
// Expiry: [maxExpiry: 16][minExpiry: 16] packed into uint256
|
|
191
186
|
if (policy.expiryBounds) {
|
|
192
187
|
const mask128 = (1n << 128n) - 1n;
|
|
193
188
|
const min = (policy.expiryBounds.min ?? 0n) & mask128;
|
|
194
|
-
const max = (policy.expiryBounds.max ??
|
|
195
|
-
parts.push(
|
|
189
|
+
const max = (policy.expiryBounds.max ?? maxUint256) & mask128;
|
|
190
|
+
parts.push(toHex((min & mask128) | (max << 128n), { size: 32 }));
|
|
196
191
|
}
|
|
197
192
|
// TokenIn: [count: 1][chainId: 32][token: 20] each
|
|
198
193
|
if (policy.tokensIn?.length) {
|
|
199
194
|
if (policy.tokensIn.length > 255)
|
|
200
195
|
throw new Error('tokensIn array exceeds max length of 255');
|
|
201
|
-
parts.push(
|
|
196
|
+
parts.push(toHex(policy.tokensIn.length, { size: 1 }));
|
|
202
197
|
for (const { chainId, token } of policy.tokensIn) {
|
|
203
|
-
parts.push(
|
|
198
|
+
parts.push(encodePacked(['uint256', 'address'], [BigInt(chainId), token]));
|
|
204
199
|
}
|
|
205
200
|
}
|
|
206
201
|
// Recipient: [count: 1][chainId: 32][recipient: 20] each
|
|
207
202
|
if (policy.recipients?.length) {
|
|
208
203
|
if (policy.recipients.length > 255)
|
|
209
204
|
throw new Error('recipients array exceeds max length of 255');
|
|
210
|
-
parts.push(
|
|
205
|
+
parts.push(toHex(policy.recipients.length, { size: 1 }));
|
|
211
206
|
for (const { chainId, recipient } of policy.recipients) {
|
|
212
|
-
parts.push(
|
|
207
|
+
parts.push(encodePacked(['uint256', 'address'], [BigInt(chainId), recipient === 'any' ? ANY_ADDRESS : recipient]));
|
|
213
208
|
}
|
|
214
209
|
}
|
|
215
210
|
// FillExpiry: [count: 1][chainId: 32][max<<128|min packed into uint256] each
|
|
@@ -217,23 +212,23 @@ function encodePermit2ClaimPolicyInitData(policy) {
|
|
|
217
212
|
if (policy.fillExpiryBounds.length > 255)
|
|
218
213
|
throw new Error('fillExpiryBounds array exceeds max length of 255');
|
|
219
214
|
const mask128 = (1n << 128n) - 1n;
|
|
220
|
-
parts.push(
|
|
215
|
+
parts.push(toHex(policy.fillExpiryBounds.length, { size: 1 }));
|
|
221
216
|
for (const { chainId, min: fMin, max: fMax } of policy.fillExpiryBounds) {
|
|
222
217
|
const minVal = (fMin ?? 0n) & mask128;
|
|
223
|
-
const maxVal = (fMax ??
|
|
218
|
+
const maxVal = (fMax ?? maxUint256) & mask128;
|
|
224
219
|
const packed = minVal | (maxVal << 128n);
|
|
225
|
-
parts.push(
|
|
220
|
+
parts.push(encodePacked(['uint256', 'uint256'], [BigInt(chainId), packed]));
|
|
226
221
|
}
|
|
227
222
|
}
|
|
228
223
|
// TokenOut: [count: 1][chainId: 32][token: 20] each
|
|
229
224
|
if (policy.tokensOut?.length) {
|
|
230
225
|
if (policy.tokensOut.length > 255)
|
|
231
226
|
throw new Error('tokensOut array exceeds max length of 255');
|
|
232
|
-
parts.push(
|
|
227
|
+
parts.push(toHex(policy.tokensOut.length, { size: 1 }));
|
|
233
228
|
for (const { chainId, token } of policy.tokensOut) {
|
|
234
|
-
parts.push(
|
|
229
|
+
parts.push(encodePacked(['uint256', 'address'], [BigInt(chainId), token]));
|
|
235
230
|
}
|
|
236
231
|
}
|
|
237
232
|
// RecipientIsSponsor has no data payload — mode bit alone enables it
|
|
238
|
-
return
|
|
233
|
+
return concat(parts);
|
|
239
234
|
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ANY_ADDRESS = exports.MODE_CHECK_STORAGE = exports.FIELD_RECIPIENT_IS_SPONSOR = exports.FIELD_DEST_OPS = exports.FIELD_ORIGIN_OPS = exports.FIELD_TOKEN_OUT = exports.FIELD_FILL_EXPIRY = exports.FIELD_RECIPIENT = exports.FIELD_TOKEN_IN = exports.FIELD_EXPIRY = exports.FIELD_ARBITER = void 0;
|
|
4
1
|
// Field IDs matching BaseDataTypes.sol
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
export const FIELD_ARBITER = 0;
|
|
3
|
+
export const FIELD_EXPIRY = 1;
|
|
4
|
+
export const FIELD_TOKEN_IN = 2;
|
|
5
|
+
export const FIELD_RECIPIENT = 3;
|
|
6
|
+
export const FIELD_FILL_EXPIRY = 4;
|
|
7
|
+
export const FIELD_TOKEN_OUT = 5;
|
|
8
|
+
export const FIELD_ORIGIN_OPS = 6;
|
|
9
|
+
export const FIELD_DEST_OPS = 7;
|
|
13
10
|
// Field 8 is reserved in BaseDataTypes.sol
|
|
14
|
-
|
|
11
|
+
export const FIELD_RECIPIENT_IS_SPONSOR = 9;
|
|
15
12
|
// Mode values
|
|
16
|
-
|
|
13
|
+
export const MODE_CHECK_STORAGE = 1;
|
|
17
14
|
// Sentinel: allows any recipient address
|
|
18
|
-
|
|
15
|
+
export const ANY_ADDRESS = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Address, type Hex, type TypedDataDefinition } from 'viem';
|
|
2
|
-
import type { Policy, ProviderConfig, RhinestoneAccountConfig, RhinestoneConfig, Session, SessionEnableData } from '../../types';
|
|
3
|
-
import { type Module } from '../common';
|
|
4
|
-
import { SMART_SESSION_EMISSARY_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS_DEV } from './core';
|
|
2
|
+
import type { Policy, ProviderConfig, RhinestoneAccountConfig, RhinestoneConfig, Session, SessionEnableData } from '../../types.js';
|
|
3
|
+
import { type Module } from '../common.js';
|
|
4
|
+
import { SMART_SESSION_EMISSARY_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS_DEV } from './core.js';
|
|
5
5
|
interface SessionData {
|
|
6
6
|
sessionValidator: Address;
|
|
7
7
|
sessionValidatorInitData: Hex;
|