@rhinestone/sdk 2.2.0 → 2.2.2
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/actions/mfa.d.ts +0 -1
- package/dist/src/actions/mfa.d.ts.map +1 -1
- package/dist/src/actions/mfa.js +0 -1
- package/dist/src/actions/passkeys.d.ts +1 -2
- package/dist/src/actions/passkeys.d.ts.map +1 -1
- package/dist/src/actions/passkeys.js +1 -2
- package/dist/src/api/queries/portfolio.d.ts.map +1 -1
- package/dist/src/api/queries/portfolio.js +6 -15
- package/dist/src/api/sdk.d.ts +1 -1
- package/dist/src/api/sdk.js +1 -1
- package/dist/src/chains/caip2.d.ts +15 -0
- package/dist/src/chains/caip2.d.ts.map +1 -1
- package/dist/src/chains/caip2.js +34 -6
- package/dist/src/chains/catalog.js +2 -2
- package/dist/src/chains/non-evm.d.ts +4 -3
- package/dist/src/chains/non-evm.d.ts.map +1 -1
- package/dist/src/chains/non-evm.js +17 -4
- package/dist/src/clients/orchestrator/client.js +1 -1
- package/dist/src/clients/orchestrator/wire.gen.d.ts +46 -52
- package/dist/src/clients/orchestrator/wire.gen.d.ts.map +1 -1
- package/dist/src/config/account.d.ts +3 -3
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/modules/validators/smart-sessions/fast-lz.d.ts +4 -0
- package/dist/src/modules/validators/smart-sessions/fast-lz.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/fast-lz.js +148 -0
- package/dist/src/modules/validators/smart-sessions/signature.d.ts +5 -0
- package/dist/src/modules/validators/smart-sessions/signature.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions/signature.js +11 -4
- package/dist/src/modules/validators/webauthn.d.ts.map +1 -1
- package/dist/src/modules/validators/webauthn.js +41 -7
- package/dist/src/transactions/intents/prepare.d.ts.map +1 -1
- package/dist/src/transactions/intents/prepare.js +16 -3
- package/dist/src/transactions/intents/sessions.d.ts.map +1 -1
- package/dist/src/transactions/intents/sessions.js +12 -1
- package/package.json +1 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-lz.d.ts","sourceRoot":"","sources":["../../../../../modules/validators/smart-sessions/fast-lz.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAc,KAAK,GAAG,EAAc,MAAM,MAAM,CAAA;AAgEvD,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAwD7C;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CA+B/C"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Adapted from Solady's LibZip FastLZ implementation:
|
|
3
|
+
* https://github.com/Vectorized/solady/blob/main/js/solady.js
|
|
4
|
+
* Copyright (c) 2022-2025 Solady.
|
|
5
|
+
*
|
|
6
|
+
* MIT License
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
import { bytesToHex, hexToBytes } from 'viem';
|
|
27
|
+
const HASH_TABLE_SIZE = 8192;
|
|
28
|
+
const MAX_DISTANCE = 8192;
|
|
29
|
+
const MAX_LITERAL_LENGTH = 32;
|
|
30
|
+
const MAX_MATCH_EXTENSION = 262;
|
|
31
|
+
function readUint24(bytes, index) {
|
|
32
|
+
return bytes[index] | (bytes[index + 1] << 8) | (bytes[index + 2] << 16);
|
|
33
|
+
}
|
|
34
|
+
function hashUint24(value) {
|
|
35
|
+
// Keep Solady's number multiplication and signed shift semantics. Math.imul
|
|
36
|
+
// changes buckets for some inputs and therefore changes compressed bytes.
|
|
37
|
+
return ((2654435769 * value) >> 19) & (HASH_TABLE_SIZE - 1);
|
|
38
|
+
}
|
|
39
|
+
function writeLiterals(output, input, start, length) {
|
|
40
|
+
let cursor = start;
|
|
41
|
+
let remaining = length;
|
|
42
|
+
while (remaining >= MAX_LITERAL_LENGTH) {
|
|
43
|
+
output.push(MAX_LITERAL_LENGTH - 1);
|
|
44
|
+
for (let index = 0; index < MAX_LITERAL_LENGTH; index++) {
|
|
45
|
+
output.push(input[cursor++]);
|
|
46
|
+
}
|
|
47
|
+
remaining -= MAX_LITERAL_LENGTH;
|
|
48
|
+
}
|
|
49
|
+
if (remaining === 0)
|
|
50
|
+
return;
|
|
51
|
+
output.push(remaining - 1);
|
|
52
|
+
while (remaining-- > 0)
|
|
53
|
+
output.push(input[cursor++]);
|
|
54
|
+
}
|
|
55
|
+
function writeMatch(output, distance, extensionLength) {
|
|
56
|
+
const encodedDistance = distance - 1;
|
|
57
|
+
let remaining = extensionLength;
|
|
58
|
+
while (remaining > MAX_MATCH_EXTENSION) {
|
|
59
|
+
output.push(0xe0 + (encodedDistance >> 8), 253, encodedDistance & 0xff);
|
|
60
|
+
remaining -= MAX_MATCH_EXTENSION;
|
|
61
|
+
}
|
|
62
|
+
if (remaining < 7) {
|
|
63
|
+
output.push((remaining << 5) + (encodedDistance >> 8), encodedDistance & 0xff);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
output.push(0xe0 + (encodedDistance >> 8), remaining - 7, encodedDistance & 0xff);
|
|
67
|
+
}
|
|
68
|
+
export function fastLzCompress(data) {
|
|
69
|
+
const input = hexToBytes(data);
|
|
70
|
+
const inputBoundary = input.length - 4;
|
|
71
|
+
const hashTable = new Uint32Array(HASH_TABLE_SIZE);
|
|
72
|
+
const output = [];
|
|
73
|
+
let anchor = 0;
|
|
74
|
+
let cursor = 2;
|
|
75
|
+
while (cursor < inputBoundary - 9) {
|
|
76
|
+
let reference = 0;
|
|
77
|
+
let distance = 0;
|
|
78
|
+
let matched = false;
|
|
79
|
+
while (cursor < inputBoundary - 9) {
|
|
80
|
+
const sequence = readUint24(input, cursor);
|
|
81
|
+
const hash = hashUint24(sequence);
|
|
82
|
+
reference = hashTable[hash] || 0;
|
|
83
|
+
hashTable[hash] = cursor;
|
|
84
|
+
distance = cursor - reference;
|
|
85
|
+
const candidate = distance < MAX_DISTANCE ? readUint24(input, reference) : 0x1000000;
|
|
86
|
+
cursor++;
|
|
87
|
+
if (sequence === candidate) {
|
|
88
|
+
matched = true;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!matched || cursor >= inputBoundary - 9)
|
|
93
|
+
break;
|
|
94
|
+
cursor--;
|
|
95
|
+
if (cursor > anchor) {
|
|
96
|
+
writeLiterals(output, input, anchor, cursor - anchor);
|
|
97
|
+
}
|
|
98
|
+
const referenceStart = reference + 3;
|
|
99
|
+
const matchStart = cursor + 3;
|
|
100
|
+
const comparisonLength = inputBoundary - matchStart;
|
|
101
|
+
let extensionLength = 0;
|
|
102
|
+
while (extensionLength < comparisonLength) {
|
|
103
|
+
const matches = input[referenceStart + extensionLength] ===
|
|
104
|
+
input[matchStart + extensionLength];
|
|
105
|
+
extensionLength++;
|
|
106
|
+
if (!matches)
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
cursor += extensionLength;
|
|
110
|
+
writeMatch(output, distance, extensionLength);
|
|
111
|
+
hashTable[hashUint24(readUint24(input, cursor))] = cursor++;
|
|
112
|
+
hashTable[hashUint24(readUint24(input, cursor))] = cursor++;
|
|
113
|
+
anchor = cursor;
|
|
114
|
+
}
|
|
115
|
+
writeLiterals(output, input, anchor, input.length - anchor);
|
|
116
|
+
return bytesToHex(Uint8Array.from(output));
|
|
117
|
+
}
|
|
118
|
+
export function fastLzDecompress(data) {
|
|
119
|
+
const input = hexToBytes(data);
|
|
120
|
+
const output = [];
|
|
121
|
+
let cursor = 0;
|
|
122
|
+
while (cursor < input.length) {
|
|
123
|
+
const control = input[cursor];
|
|
124
|
+
const matchType = control >> 5;
|
|
125
|
+
if (matchType === 0) {
|
|
126
|
+
let literalLength = control + 1;
|
|
127
|
+
cursor++;
|
|
128
|
+
while (literalLength-- > 0)
|
|
129
|
+
output.push(input[cursor++]);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const shortMatch = matchType < 7;
|
|
133
|
+
const distance = 256 * (control & 31) + input[cursor + (shortMatch ? 1 : 2)];
|
|
134
|
+
let matchLength;
|
|
135
|
+
if (shortMatch) {
|
|
136
|
+
matchLength = matchType + 2;
|
|
137
|
+
cursor += 2;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
matchLength = input[cursor + 1] + 9;
|
|
141
|
+
cursor += 3;
|
|
142
|
+
}
|
|
143
|
+
let reference = output.length - distance - 1;
|
|
144
|
+
while (matchLength-- > 0)
|
|
145
|
+
output.push(output[reference++]);
|
|
146
|
+
}
|
|
147
|
+
return bytesToHex(Uint8Array.from(output));
|
|
148
|
+
}
|
|
@@ -11,4 +11,9 @@ export declare function encodeSmartSessionContribution(input: {
|
|
|
11
11
|
readonly claimPolicyData?: Hex;
|
|
12
12
|
readonly enableData?: SmartSessionEnableContributionData;
|
|
13
13
|
}): Hex;
|
|
14
|
+
export declare function encodeSmartSessionEnablePayload(input: {
|
|
15
|
+
readonly permissionId: Hex;
|
|
16
|
+
readonly signature: Hex;
|
|
17
|
+
readonly enableData: SmartSessionEnableContributionData;
|
|
18
|
+
}): Hex;
|
|
14
19
|
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../../../modules/validators/smart-sessions/signature.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../../../modules/validators/smart-sessions/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAAG,EAKT,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAA;AAG1F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAIvD,eAAO,MAAM,sBAAsB,EAAG,MAAe,CAAA;AACrD,eAAO,MAAM,yBAAyB,EAAG,MAAe,CAAA;AAExD,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,wBAAwB,EACjC,kBAAkB,EAAE,GAAG,GACtB,GAAG,CA4BL;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACpD,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,gBAAgB,GAAG,WAAW,GAAG,WAAW,CAAA;IACnE,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAA;IACvB,QAAQ,CAAC,eAAe,CAAC,EAAE,GAAG,CAAA;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,kCAAkC,CAAA;CACzD,GAAG,GAAG,CAiCN;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE;IACrD,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,kCAAkC,CAAA;CACxD,GAAG,GAAG,CAqHN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LibZip } from 'solady';
|
|
2
1
|
import { encodeAbiParameters, encodePacked, maxUint256, size, zeroAddress, zeroHash, } from 'viem';
|
|
3
2
|
import { getPermissionId, getSessionData } from './digest.js';
|
|
3
|
+
import { fastLzCompress } from './fast-lz.js';
|
|
4
4
|
const SCOPE_MULTICHAIN = 0;
|
|
5
5
|
const RESET_PERIOD_ONE_WEEK = 6;
|
|
6
6
|
export const SMART_SESSION_MODE_USE = '0x00';
|
|
@@ -50,7 +50,15 @@ export function encodeSmartSessionContribution(input) {
|
|
|
50
50
|
if (!input.enableData) {
|
|
51
51
|
throw new Error('Enable-and-use signatures require enable data');
|
|
52
52
|
}
|
|
53
|
-
const compressed =
|
|
53
|
+
const compressed = fastLzCompress(encodeSmartSessionEnablePayload({
|
|
54
|
+
permissionId: input.permissionId,
|
|
55
|
+
signature: input.signature,
|
|
56
|
+
enableData: input.enableData,
|
|
57
|
+
}));
|
|
58
|
+
return encodePacked(['bytes1', 'bytes'], [SMART_SESSION_MODE_ENABLE, compressed]);
|
|
59
|
+
}
|
|
60
|
+
export function encodeSmartSessionEnablePayload(input) {
|
|
61
|
+
return encodeAbiParameters([
|
|
54
62
|
{
|
|
55
63
|
type: 'tuple',
|
|
56
64
|
name: 'enableData',
|
|
@@ -162,6 +170,5 @@ export function encodeSmartSessionContribution(input) {
|
|
|
162
170
|
permissionId: input.permissionId,
|
|
163
171
|
},
|
|
164
172
|
input.signature,
|
|
165
|
-
])
|
|
166
|
-
return encodePacked(['bytes1', 'bytes'], [SMART_SESSION_MODE_ENABLE, compressed]);
|
|
173
|
+
]);
|
|
167
174
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webauthn.d.ts","sourceRoot":"","sources":["../../../../modules/validators/webauthn.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAGZ,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"webauthn.d.ts","sourceRoot":"","sources":["../../../../modules/validators/webauthn.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,40 @@
|
|
|
1
|
-
import { bytesToHex, encodeAbiParameters, hexToBytes, keccak256, } from 'viem';
|
|
1
|
+
import { bytesToHex, encodeAbiParameters, hexToBytes, keccak256, stringToBytes, } from 'viem';
|
|
2
2
|
export const WEBAUTHN_VALIDATOR_ADDRESS = '0x0000000000578c4cb0e472a5462da43c495c3f33';
|
|
3
3
|
export const WEBAUTHN_V0_VALIDATOR_ADDRESS = WEBAUTHN_VALIDATOR_ADDRESS;
|
|
4
4
|
export const WEBAUTHN_MOCK_SIGNATURE = '0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001b9b86eb98fda3ed4d797d9e690588dfadf17b329a76a47cec935bebf92d7ddc80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000019b2e9410bb6850f9f660a03d609d5a844fb96bcdc87a15139b03ee22c70f469100d2b865a215c3bf786387064effa8fcedcb1d625b5148f8a1236d5e3ff11acf000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763050000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22396a4546696a75684557724d34534f572d7443684a625545484550343456636a634a2d42716f3166544d38222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a38303830222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000';
|
|
5
|
+
const P256_CURVE_ORDER = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551n;
|
|
6
|
+
const P256_HALF_CURVE_ORDER = P256_CURVE_ORDER / 2n;
|
|
7
|
+
const WEBAUTHN_TYPE_LITERAL = stringToBytes('"type":"webauthn.get"');
|
|
8
|
+
const WEBAUTHN_CHALLENGE_LITERAL = stringToBytes('"challenge":"');
|
|
9
|
+
function findClientDataLiteral(clientData, literal, name) {
|
|
10
|
+
const lastStart = clientData.length - literal.length;
|
|
11
|
+
for (let start = 0; start <= lastStart; start++) {
|
|
12
|
+
if (literal.every((byte, offset) => clientData[start + offset] === byte)) {
|
|
13
|
+
return BigInt(start);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`WebAuthn clientDataJSON is missing the required ${name} field`);
|
|
17
|
+
}
|
|
18
|
+
function normalizeP256S(s) {
|
|
19
|
+
return s > P256_HALF_CURVE_ORDER ? P256_CURVE_ORDER - s : s;
|
|
20
|
+
}
|
|
21
|
+
function normalizeWebauthnSignature(signature) {
|
|
22
|
+
const clientData = stringToBytes(signature.clientDataJSON);
|
|
23
|
+
return {
|
|
24
|
+
...signature,
|
|
25
|
+
challengeIndex: findClientDataLiteral(clientData, WEBAUTHN_CHALLENGE_LITERAL, 'challenge'),
|
|
26
|
+
typeIndex: findClientDataLiteral(clientData, WEBAUTHN_TYPE_LITERAL, 'type'),
|
|
27
|
+
s: normalizeP256S(signature.s),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function normalizeWebauthnSignatureV0(signature) {
|
|
31
|
+
const clientData = stringToBytes(signature.clientDataJSON);
|
|
32
|
+
return {
|
|
33
|
+
...signature,
|
|
34
|
+
typeIndex: findClientDataLiteral(clientData, WEBAUTHN_TYPE_LITERAL, 'type'),
|
|
35
|
+
s: normalizeP256S(signature.s),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
5
38
|
export function parseWebauthnPublicKey(publicKey) {
|
|
6
39
|
const bytes = typeof publicKey === 'string' ? hexToBytes(publicKey) : publicKey;
|
|
7
40
|
const offset = bytes.length === 65 ? 1 : 0;
|
|
@@ -26,7 +59,7 @@ export function encodeWebauthnSignatures(credentialIds, usePrecompile, signature
|
|
|
26
59
|
const ordered = credentialIds
|
|
27
60
|
.map((credentialId, index) => ({
|
|
28
61
|
credentialId,
|
|
29
|
-
signature: signatures[index],
|
|
62
|
+
signature: normalizeWebauthnSignature(signatures[index]),
|
|
30
63
|
}))
|
|
31
64
|
.sort((left, right) => left.credentialId.localeCompare(right.credentialId));
|
|
32
65
|
return encodeAbiParameters([
|
|
@@ -51,6 +84,7 @@ export function encodeWebauthnSignatures(credentialIds, usePrecompile, signature
|
|
|
51
84
|
]);
|
|
52
85
|
}
|
|
53
86
|
export function encodeWebauthnSignatureV0(signature, usePrecompile) {
|
|
87
|
+
const normalized = normalizeWebauthnSignatureV0(signature);
|
|
54
88
|
return encodeAbiParameters([
|
|
55
89
|
{ type: 'bytes', name: 'authenticatorData' },
|
|
56
90
|
{ type: 'string', name: 'clientDataJSON' },
|
|
@@ -59,11 +93,11 @@ export function encodeWebauthnSignatureV0(signature, usePrecompile) {
|
|
|
59
93
|
{ type: 'uint256', name: 's' },
|
|
60
94
|
{ type: 'bool', name: 'usePrecompiled' },
|
|
61
95
|
], [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
96
|
+
normalized.authenticatorData,
|
|
97
|
+
normalized.clientDataJSON,
|
|
98
|
+
normalized.typeIndex,
|
|
99
|
+
normalized.r,
|
|
100
|
+
normalized.s,
|
|
67
101
|
usePrecompile,
|
|
68
102
|
]);
|
|
69
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../../transactions/intents/prepare.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../../transactions/intents/prepare.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAQ5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAI3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAO1E,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB,wBAAsB,aAAa,CAAC,mBAAmB,EACrD,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,EACnD,KAAK,EAAE,WAAW,CAAC,mBAAmB,CAAC,GACtC,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CA2D9C;AA8FD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,EAC9B,QAAQ,CAAC,EAAE,cAAc,CAAC,kBAAkB,CAAC,EAC7C,WAAW,CAAC,EAAE,iBAAiB,EAC/B,cAAc,CAAC,EAAE,OAAO,gCAAgC,EAAE,2BAA2B,EACrF,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,GACpC,kBAAkB,CA2IpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hashTypedData, keccak256, stringToHex } from 'viem';
|
|
2
2
|
import { resolveCalls } from '../../calls/resolve.js';
|
|
3
|
-
import { chainIdFromReference, toEvmChainReference } from '../../chains/caip2.js';
|
|
3
|
+
import { chainIdFromReference, isHyperCoreWireId, toEvmChainReference, } from '../../chains/caip2.js';
|
|
4
4
|
import { defineValidator } from '../../modules/validators/definition.js';
|
|
5
5
|
import { ecdsaSignerId } from '../../modules/validators/signer-id.js';
|
|
6
6
|
import { signingTopology } from '../../signing/plan.js';
|
|
@@ -59,12 +59,25 @@ export async function prepareIntent(context, input) {
|
|
|
59
59
|
: {}),
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
+
// The chain whose runtime hosts the account: identity, address derivation, and
|
|
63
|
+
// the RPC reads that follow. The destination serves when it is a real execution
|
|
64
|
+
// chain, and otherwise a source chain does.
|
|
65
|
+
//
|
|
66
|
+
// `kind === 'evm'` alone is not that test. HyperCore is EVM-ADDRESSED — hex
|
|
67
|
+
// recipients, EIP-712 — while being virtual: it has no RPC of its own and hosts
|
|
68
|
+
// no accounts, so materializing a runtime on it asks viem for a transport that
|
|
69
|
+
// cannot exist. That went unnoticed while HyperCore was chain 1337, because viem
|
|
70
|
+
// ships a `Localhost` chain with that exact id and quietly supplied
|
|
71
|
+
// `http://127.0.0.1:8545`; the venue ids have no viem chain, so the synthesised
|
|
72
|
+
// one has empty `rpcUrls` and the call fails with `UrlRequiredError` (RHI-5510).
|
|
62
73
|
function selectAccountChain(input) {
|
|
63
|
-
if (input.destination.kind === 'evm'
|
|
74
|
+
if (input.destination.kind === 'evm' &&
|
|
75
|
+
!isHyperCoreWireId(input.destination.id)) {
|
|
64
76
|
return input.destination;
|
|
77
|
+
}
|
|
65
78
|
const source = input.sourceChains?.at(-1);
|
|
66
79
|
if (!source) {
|
|
67
|
-
throw new Error(
|
|
80
|
+
throw new Error(`An intent to ${input.destination.caip2} requires at least one EVM source chain: the destination hosts no account runtime`);
|
|
68
81
|
}
|
|
69
82
|
return source;
|
|
70
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../../transactions/intents/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../../transactions/intents/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAQ7C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAA;AAC7F,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEjE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAA;IACpE,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;IACtD,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC,CAAA;CAClE;AAED,wBAAsB,qBAAqB,CAAC,mBAAmB,EAAE,KAAK,EAAE;IACtE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,mBAAmB,CAAC,CAAA;IACjD,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAA;IAChC,QAAQ,CAAC,OAAO,EAAE,IAAI,CACpB,qBAAqB,CAAC,mBAAmB,CAAC,EAC1C,aAAa,CACd,CAAA;CACF,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAmF9C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isHyperCoreWireId } from '../../chains/caip2.js';
|
|
1
2
|
import { buildSmartSessionMockSignature } from '../../modules/validators/smart-sessions/mock-signature.js';
|
|
2
3
|
import { DUMMY_PRECLAIMOP_SELECTOR, DUMMY_PRECLAIMOP_TARGET, } from '../../modules/validators/smart-sessions/resolve.js';
|
|
3
4
|
export async function prepareIntentSessions(input) {
|
|
@@ -76,9 +77,19 @@ export async function prepareIntentSessions(input) {
|
|
|
76
77
|
preClaimCalls,
|
|
77
78
|
};
|
|
78
79
|
}
|
|
80
|
+
// Chains a smart-session intent needs an enabled session on: every source, plus
|
|
81
|
+
// the destination when the user's own account executes there.
|
|
82
|
+
//
|
|
83
|
+
// A HyperCore venue is excluded for the same reason it cannot host the account
|
|
84
|
+
// runtime: it is EVM-ADDRESSED but virtual, so there is no account there to enable
|
|
85
|
+
// a session on, and requiring one would demand a session on chain 1337001/1337002
|
|
86
|
+
// that can never exist. Delivery is solver-mediated anyway — the orchestrator
|
|
87
|
+
// builds the `depositFor` credit and the recipient never executes — so there is no
|
|
88
|
+
// destination-side authorization for a session to grant (RHI-5510).
|
|
79
89
|
function sessionChains(intent) {
|
|
80
90
|
const chains = new Map((intent.sourceChains ?? []).map((chain) => [chain.id, chain]));
|
|
81
|
-
if (intent.destination.kind === 'evm'
|
|
91
|
+
if (intent.destination.kind === 'evm' &&
|
|
92
|
+
!isHyperCoreWireId(intent.destination.id)) {
|
|
82
93
|
chains.set(intent.destination.id, intent.destination);
|
|
83
94
|
}
|
|
84
95
|
return [...chains.values()];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhinestone/sdk",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "End-to-end chain abstraction and modularity toolkit",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Rhinestone",
|
|
@@ -78,9 +78,6 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
|
-
"dependencies": {
|
|
82
|
-
"solady": "^0.1.26"
|
|
83
|
-
},
|
|
84
81
|
"peerDependencies": {
|
|
85
82
|
"viem": "^2.55.0",
|
|
86
83
|
"jose": ">=5.0.0",
|