@rhinestone/sdk 1.5.0 → 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/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 +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 +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 +8 -8
- package/dist/src/execution/index.js +50 -65
- 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 +4 -4
- package/dist/src/execution/utils.js +133 -156
- package/dist/src/index.d.ts +9 -9
- package/dist/src/index.js +55 -66
- 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/client.d.ts +2 -2
- package/dist/src/orchestrator/client.js +46 -50
- 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 +7 -7
- 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.js +1 -17
- package/dist/src/orchestrator/utils.js +1 -3
- package/dist/src/types.d.ts +3 -3
- 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
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.installModule = installModule;
|
|
4
|
-
exports.uninstallModule = uninstallModule;
|
|
5
|
-
exports.deploy = deploy;
|
|
6
|
-
const accounts_1 = require("../accounts");
|
|
7
|
-
const common_1 = require("../modules/common");
|
|
1
|
+
import { getModuleInstallationCalls, getModuleUninstallationCalls, } from '../accounts/index.js';
|
|
2
|
+
import { toModuleTypeId } from '../modules/common.js';
|
|
8
3
|
/**
|
|
9
4
|
* Install a custom module
|
|
10
5
|
* @param module Module to install
|
|
@@ -14,7 +9,7 @@ function installModule(module) {
|
|
|
14
9
|
const moduleData = getModule(module);
|
|
15
10
|
return {
|
|
16
11
|
async resolve({ config }) {
|
|
17
|
-
return
|
|
12
|
+
return getModuleInstallationCalls(config, moduleData);
|
|
18
13
|
},
|
|
19
14
|
};
|
|
20
15
|
}
|
|
@@ -27,13 +22,13 @@ function uninstallModule(module) {
|
|
|
27
22
|
const moduleData = getModule(module);
|
|
28
23
|
return {
|
|
29
24
|
async resolve({ config }) {
|
|
30
|
-
return
|
|
25
|
+
return getModuleUninstallationCalls(config, moduleData);
|
|
31
26
|
},
|
|
32
27
|
};
|
|
33
28
|
}
|
|
34
29
|
function getModule(module) {
|
|
35
30
|
return {
|
|
36
|
-
type:
|
|
31
|
+
type: toModuleTypeId(module.type),
|
|
37
32
|
address: module.address,
|
|
38
33
|
initData: module.initData ?? '0x',
|
|
39
34
|
deInitData: module.deInitData ?? '0x',
|
|
@@ -51,3 +46,4 @@ function deploy(account) {
|
|
|
51
46
|
},
|
|
52
47
|
};
|
|
53
48
|
}
|
|
49
|
+
export { installModule, uninstallModule, deploy };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Hex } from 'viem';
|
|
2
|
-
import type { CalldataInput, LazyCallInput, OwnableValidatorConfig, WebauthnValidatorConfig } from '../types';
|
|
2
|
+
import type { CalldataInput, LazyCallInput, OwnableValidatorConfig, WebauthnValidatorConfig } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Enable multi-factor authentication
|
|
5
5
|
* @param validators List of validators to use
|
package/dist/src/actions/mfa.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.changeThreshold = changeThreshold;
|
|
5
|
-
exports.disable = disable;
|
|
6
|
-
exports.setSubValidator = setSubValidator;
|
|
7
|
-
exports.removeSubValidator = removeSubValidator;
|
|
8
|
-
const viem_1 = require("viem");
|
|
9
|
-
const accounts_1 = require("../accounts");
|
|
10
|
-
const core_1 = require("../modules/validators/core");
|
|
1
|
+
import { encodeFunctionData, padHex, toHex } from 'viem';
|
|
2
|
+
import { getModuleInstallationCalls, getModuleUninstallationCalls, } from '../accounts/index.js';
|
|
3
|
+
import { getMultiFactorValidator, getValidator, MULTI_FACTOR_VALIDATOR_ADDRESS, } from '../modules/validators/core.js';
|
|
11
4
|
/**
|
|
12
5
|
* Enable multi-factor authentication
|
|
13
6
|
* @param validators List of validators to use
|
|
@@ -15,10 +8,10 @@ const core_1 = require("../modules/validators/core");
|
|
|
15
8
|
* @returns Calls to enable multi-factor authentication
|
|
16
9
|
*/
|
|
17
10
|
function enable(validators, threshold = 1) {
|
|
18
|
-
const module =
|
|
11
|
+
const module = getMultiFactorValidator(threshold, validators);
|
|
19
12
|
return {
|
|
20
13
|
async resolve({ config }) {
|
|
21
|
-
return
|
|
14
|
+
return getModuleInstallationCalls(config, module);
|
|
22
15
|
},
|
|
23
16
|
};
|
|
24
17
|
}
|
|
@@ -29,9 +22,9 @@ function enable(validators, threshold = 1) {
|
|
|
29
22
|
*/
|
|
30
23
|
function changeThreshold(newThreshold) {
|
|
31
24
|
return {
|
|
32
|
-
to:
|
|
25
|
+
to: MULTI_FACTOR_VALIDATOR_ADDRESS,
|
|
33
26
|
value: 0n,
|
|
34
|
-
data:
|
|
27
|
+
data: encodeFunctionData({
|
|
35
28
|
abi: [
|
|
36
29
|
{
|
|
37
30
|
inputs: [{ internalType: 'uint8', name: 'threshold', type: 'uint8' }],
|
|
@@ -52,10 +45,10 @@ function changeThreshold(newThreshold) {
|
|
|
52
45
|
* @returns Calls to disable multi-factor authentication
|
|
53
46
|
*/
|
|
54
47
|
function disable() {
|
|
55
|
-
const module =
|
|
48
|
+
const module = getMultiFactorValidator(1, []);
|
|
56
49
|
return {
|
|
57
50
|
async resolve({ config }) {
|
|
58
|
-
return
|
|
51
|
+
return getModuleUninstallationCalls(config, module);
|
|
59
52
|
},
|
|
60
53
|
};
|
|
61
54
|
}
|
|
@@ -66,12 +59,12 @@ function disable() {
|
|
|
66
59
|
* @returns Call to set the sub-validator
|
|
67
60
|
*/
|
|
68
61
|
function setSubValidator(id, validator) {
|
|
69
|
-
const validatorId =
|
|
70
|
-
const validatorModule =
|
|
62
|
+
const validatorId = padHex(toHex(id), { size: 12 });
|
|
63
|
+
const validatorModule = getValidator(validator);
|
|
71
64
|
return {
|
|
72
|
-
to:
|
|
65
|
+
to: MULTI_FACTOR_VALIDATOR_ADDRESS,
|
|
73
66
|
value: 0n,
|
|
74
|
-
data:
|
|
67
|
+
data: encodeFunctionData({
|
|
75
68
|
abi: [
|
|
76
69
|
{
|
|
77
70
|
type: 'function',
|
|
@@ -104,12 +97,12 @@ function setSubValidator(id, validator) {
|
|
|
104
97
|
* @returns Call to remove the sub-validator
|
|
105
98
|
*/
|
|
106
99
|
function removeSubValidator(id, validator) {
|
|
107
|
-
const validatorId =
|
|
108
|
-
const validatorModule =
|
|
100
|
+
const validatorId = padHex(toHex(id), { size: 12 });
|
|
101
|
+
const validatorModule = getValidator(validator);
|
|
109
102
|
return {
|
|
110
|
-
to:
|
|
103
|
+
to: MULTI_FACTOR_VALIDATOR_ADDRESS,
|
|
111
104
|
value: 0n,
|
|
112
|
-
data:
|
|
105
|
+
data: encodeFunctionData({
|
|
113
106
|
abi: [
|
|
114
107
|
{
|
|
115
108
|
type: 'function',
|
|
@@ -131,3 +124,4 @@ function removeSubValidator(id, validator) {
|
|
|
131
124
|
}),
|
|
132
125
|
};
|
|
133
126
|
}
|
|
127
|
+
export { enable, changeThreshold, disable, setSubValidator, removeSubValidator };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type WebauthnCredential } from '../modules/validators/core';
|
|
2
|
-
import type { CalldataInput, LazyCallInput } from '../types';
|
|
1
|
+
import { type WebauthnCredential } from '../modules/validators/core.js';
|
|
2
|
+
import type { CalldataInput, LazyCallInput } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Enable passkeys authentication
|
|
5
5
|
* @param pubKey Public key for the passkey
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.removeOwner = removeOwner;
|
|
5
|
-
exports.changeThreshold = changeThreshold;
|
|
6
|
-
exports.disable = disable;
|
|
7
|
-
exports.enable = enable;
|
|
8
|
-
const viem_1 = require("viem");
|
|
9
|
-
const accounts_1 = require("../accounts");
|
|
10
|
-
const core_1 = require("../modules/validators/core");
|
|
1
|
+
import { encodeFunctionData } from 'viem';
|
|
2
|
+
import { getModuleInstallationCalls, getModuleUninstallationCalls, } from '../accounts/index.js';
|
|
3
|
+
import { getWebAuthnValidator, WEBAUTHN_VALIDATOR_ADDRESS, } from '../modules/validators/core.js';
|
|
11
4
|
/**
|
|
12
5
|
* Enable passkeys authentication
|
|
13
6
|
* @param pubKey Public key for the passkey
|
|
@@ -15,10 +8,10 @@ const core_1 = require("../modules/validators/core");
|
|
|
15
8
|
* @returns Calls to enable passkeys authentication
|
|
16
9
|
*/
|
|
17
10
|
function enable(credential) {
|
|
18
|
-
const module =
|
|
11
|
+
const module = getWebAuthnValidator(1, [credential]);
|
|
19
12
|
return {
|
|
20
13
|
async resolve({ config }) {
|
|
21
|
-
return
|
|
14
|
+
return getModuleInstallationCalls(config, module);
|
|
22
15
|
},
|
|
23
16
|
};
|
|
24
17
|
}
|
|
@@ -27,7 +20,7 @@ function enable(credential) {
|
|
|
27
20
|
* @returns Calls to disable passkeys authentication
|
|
28
21
|
*/
|
|
29
22
|
function disable() {
|
|
30
|
-
const module =
|
|
23
|
+
const module = getWebAuthnValidator(1, [
|
|
31
24
|
{
|
|
32
25
|
// Mocked values
|
|
33
26
|
pubKey: '0x580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1',
|
|
@@ -36,7 +29,7 @@ function disable() {
|
|
|
36
29
|
]);
|
|
37
30
|
return {
|
|
38
31
|
async resolve({ config }) {
|
|
39
|
-
return
|
|
32
|
+
return getModuleUninstallationCalls(config, module);
|
|
40
33
|
},
|
|
41
34
|
};
|
|
42
35
|
}
|
|
@@ -49,9 +42,9 @@ function disable() {
|
|
|
49
42
|
*/
|
|
50
43
|
function addOwner(pubKeyX, pubKeyY, requireUserVerification) {
|
|
51
44
|
return {
|
|
52
|
-
to:
|
|
45
|
+
to: WEBAUTHN_VALIDATOR_ADDRESS,
|
|
53
46
|
value: 0n,
|
|
54
|
-
data:
|
|
47
|
+
data: encodeFunctionData({
|
|
55
48
|
abi: [
|
|
56
49
|
{
|
|
57
50
|
inputs: [
|
|
@@ -81,9 +74,9 @@ function addOwner(pubKeyX, pubKeyY, requireUserVerification) {
|
|
|
81
74
|
*/
|
|
82
75
|
function removeOwner(pubKeyX, pubKeyY) {
|
|
83
76
|
return {
|
|
84
|
-
to:
|
|
77
|
+
to: WEBAUTHN_VALIDATOR_ADDRESS,
|
|
85
78
|
value: 0n,
|
|
86
|
-
data:
|
|
79
|
+
data: encodeFunctionData({
|
|
87
80
|
abi: [
|
|
88
81
|
{
|
|
89
82
|
inputs: [
|
|
@@ -108,9 +101,9 @@ function removeOwner(pubKeyX, pubKeyY) {
|
|
|
108
101
|
*/
|
|
109
102
|
function changeThreshold(newThreshold) {
|
|
110
103
|
return {
|
|
111
|
-
to:
|
|
104
|
+
to: WEBAUTHN_VALIDATOR_ADDRESS,
|
|
112
105
|
value: 0n,
|
|
113
|
-
data:
|
|
106
|
+
data: encodeFunctionData({
|
|
114
107
|
abi: [
|
|
115
108
|
{
|
|
116
109
|
inputs: [
|
|
@@ -127,3 +120,4 @@ function changeThreshold(newThreshold) {
|
|
|
127
120
|
}),
|
|
128
121
|
};
|
|
129
122
|
}
|
|
123
|
+
export { addOwner, removeOwner, changeThreshold, disable, enable };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Account, type Address, type Chain } from 'viem';
|
|
2
|
-
import type { CalldataInput, LazyCallInput, OwnableValidatorConfig, RhinestoneConfig, WebauthnValidatorConfig } from '../types';
|
|
2
|
+
import type { CalldataInput, LazyCallInput, OwnableValidatorConfig, RhinestoneConfig, WebauthnValidatorConfig } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Set up social recovery
|
|
5
5
|
* @param guardians Guardians to use for recovery
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const json_rpc_1 = require("../accounts/json-rpc");
|
|
9
|
-
const utils_1 = require("../execution/utils");
|
|
10
|
-
const core_1 = require("../modules/validators/core");
|
|
11
|
-
const ecdsa_1 = require("./ecdsa");
|
|
12
|
-
const passkeys_1 = require("./passkeys");
|
|
1
|
+
import { createPublicClient, } from 'viem';
|
|
2
|
+
import { getModuleInstallationCalls } from '../accounts/index.js';
|
|
3
|
+
import { createTransport } from '../accounts/json-rpc/index.js';
|
|
4
|
+
import { resolveCallInputs } from '../execution/utils.js';
|
|
5
|
+
import { getSocialRecoveryValidator, OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, } from '../modules/validators/core.js';
|
|
6
|
+
import { addOwner, changeThreshold, removeOwner } from './ecdsa.js';
|
|
7
|
+
import { addOwner as addPasskeyOwner, changeThreshold as changePasskeyThreshold, removeOwner as removePasskeyOwner, } from './passkeys.js';
|
|
13
8
|
/**
|
|
14
9
|
* Set up social recovery
|
|
15
10
|
* @param guardians Guardians to use for recovery
|
|
@@ -17,10 +12,10 @@ const passkeys_1 = require("./passkeys");
|
|
|
17
12
|
* @returns Calls to set up social recovery
|
|
18
13
|
*/
|
|
19
14
|
function enable(guardians, threshold = 1) {
|
|
20
|
-
const module =
|
|
15
|
+
const module = getSocialRecoveryValidator(guardians, threshold);
|
|
21
16
|
return {
|
|
22
17
|
async resolve({ config }) {
|
|
23
|
-
return
|
|
18
|
+
return getModuleInstallationCalls(config, module);
|
|
24
19
|
},
|
|
25
20
|
};
|
|
26
21
|
}
|
|
@@ -33,15 +28,15 @@ function enable(guardians, threshold = 1) {
|
|
|
33
28
|
* @returns Calls to recover ownership
|
|
34
29
|
*/
|
|
35
30
|
async function recoverEcdsaOwnership(address, newOwners, chain, config) {
|
|
36
|
-
const publicClient =
|
|
31
|
+
const publicClient = createPublicClient({
|
|
37
32
|
chain,
|
|
38
|
-
transport:
|
|
33
|
+
transport: createTransport(chain, config.provider),
|
|
39
34
|
});
|
|
40
35
|
// Read the existing config
|
|
41
36
|
const results = await publicClient.multicall({
|
|
42
37
|
contracts: [
|
|
43
38
|
{
|
|
44
|
-
address:
|
|
39
|
+
address: OWNABLE_VALIDATOR_ADDRESS,
|
|
45
40
|
abi: [
|
|
46
41
|
{
|
|
47
42
|
inputs: [
|
|
@@ -63,7 +58,7 @@ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
|
|
|
63
58
|
args: [address],
|
|
64
59
|
},
|
|
65
60
|
{
|
|
66
|
-
address:
|
|
61
|
+
address: OWNABLE_VALIDATOR_ADDRESS,
|
|
67
62
|
abi: [
|
|
68
63
|
{
|
|
69
64
|
inputs: [
|
|
@@ -96,7 +91,7 @@ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
|
|
|
96
91
|
const newThreshold = newOwners.threshold ?? 1;
|
|
97
92
|
// Check if threshold needs to be updated
|
|
98
93
|
if (Number(existingThreshold) !== newThreshold) {
|
|
99
|
-
callInputs.push(
|
|
94
|
+
callInputs.push(changeThreshold(newThreshold));
|
|
100
95
|
}
|
|
101
96
|
const ownersToAdd = newOwnerAddresses.filter((owner) => !normalizedExistingOwners.includes(owner));
|
|
102
97
|
const ownersToRemove = normalizedExistingOwners.filter((owner) => !newOwnerAddresses.includes(owner));
|
|
@@ -104,7 +99,7 @@ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
|
|
|
104
99
|
// Note: new owners are added to the START of the linked list
|
|
105
100
|
let currentOwners = [...normalizedExistingOwners];
|
|
106
101
|
for (const owner of ownersToAdd) {
|
|
107
|
-
callInputs.push(
|
|
102
|
+
callInputs.push(addOwner(owner));
|
|
108
103
|
currentOwners.unshift(owner);
|
|
109
104
|
}
|
|
110
105
|
for (const ownerToRemove of ownersToRemove) {
|
|
@@ -117,10 +112,10 @@ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
|
|
|
117
112
|
else {
|
|
118
113
|
prevOwner = currentOwners[ownerIndex - 1];
|
|
119
114
|
}
|
|
120
|
-
callInputs.push(
|
|
115
|
+
callInputs.push(removeOwner(prevOwner, ownerToRemove));
|
|
121
116
|
currentOwners = currentOwners.filter((owner) => owner !== ownerToRemove);
|
|
122
117
|
}
|
|
123
|
-
const calls = await
|
|
118
|
+
const calls = await resolveCallInputs(callInputs, config, chain, address);
|
|
124
119
|
return calls;
|
|
125
120
|
}
|
|
126
121
|
/**
|
|
@@ -133,12 +128,12 @@ async function recoverEcdsaOwnership(address, newOwners, chain, config) {
|
|
|
133
128
|
* @returns Calls to recover ownership
|
|
134
129
|
*/
|
|
135
130
|
async function recoverPasskeyOwnership(address, oldCredentials, newOwners, chain, config) {
|
|
136
|
-
const publicClient =
|
|
131
|
+
const publicClient = createPublicClient({
|
|
137
132
|
chain,
|
|
138
|
-
transport:
|
|
133
|
+
transport: createTransport(chain, config.provider),
|
|
139
134
|
});
|
|
140
135
|
const existingThreshold = await publicClient.readContract({
|
|
141
|
-
address:
|
|
136
|
+
address: WEBAUTHN_VALIDATOR_ADDRESS,
|
|
142
137
|
abi: [
|
|
143
138
|
{
|
|
144
139
|
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
|
@@ -171,7 +166,7 @@ async function recoverPasskeyOwnership(address, oldCredentials, newOwners, chain
|
|
|
171
166
|
const newThreshold = newOwners.threshold ?? 1;
|
|
172
167
|
// Check if threshold needs to be updated
|
|
173
168
|
if (Number(existingThreshold) !== newThreshold) {
|
|
174
|
-
callInputs.push((
|
|
169
|
+
callInputs.push(changePasskeyThreshold(newThreshold));
|
|
175
170
|
}
|
|
176
171
|
// Compare existing and new credentials to determine what to add/remove
|
|
177
172
|
const existingCredentialKeys = oldCredentials.map((cred) => `${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`);
|
|
@@ -182,12 +177,13 @@ async function recoverPasskeyOwnership(address, oldCredentials, newOwners, chain
|
|
|
182
177
|
const credentialsToRemove = oldCredentials.filter((cred) => !newCredentialKeys.includes(`${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`));
|
|
183
178
|
// Remove old credentials first (important for security in recovery scenarios)
|
|
184
179
|
for (const credential of credentialsToRemove) {
|
|
185
|
-
callInputs.push((
|
|
180
|
+
callInputs.push(removePasskeyOwner(credential.pubKeyX, credential.pubKeyY));
|
|
186
181
|
}
|
|
187
182
|
// Then add new credentials
|
|
188
183
|
for (const credential of credentialsToAdd) {
|
|
189
|
-
callInputs.push((
|
|
184
|
+
callInputs.push(addPasskeyOwner(credential.pubKeyX, credential.pubKeyY, credential.requireUV));
|
|
190
185
|
}
|
|
191
|
-
const calls = await
|
|
186
|
+
const calls = await resolveCallInputs(callInputs, config, chain, address);
|
|
192
187
|
return calls;
|
|
193
188
|
}
|
|
189
|
+
export { enable, recoverEcdsaOwnership, recoverPasskeyOwnership };
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.experimental_disable = experimental_disable;
|
|
4
|
-
exports.experimental_enable = experimental_enable;
|
|
5
|
-
exports.experimental_enableSession = experimental_enableSession;
|
|
6
|
-
const accounts_1 = require("../accounts");
|
|
7
|
-
const smart_sessions_1 = require("../modules/validators/smart-sessions");
|
|
1
|
+
import { getModuleInstallationCalls, getModuleUninstallationCalls, } from '../accounts/index.js';
|
|
2
|
+
import { getEnableSessionCall, getSmartSessionValidator, } from '../modules/validators/smart-sessions.js';
|
|
8
3
|
/**
|
|
9
4
|
* Enable smart sessions
|
|
10
5
|
* @returns Calls to enable smart sessions
|
|
@@ -12,11 +7,11 @@ const smart_sessions_1 = require("../modules/validators/smart-sessions");
|
|
|
12
7
|
function experimental_enable() {
|
|
13
8
|
return {
|
|
14
9
|
async resolve({ config }) {
|
|
15
|
-
const module =
|
|
10
|
+
const module = getSmartSessionValidator(config);
|
|
16
11
|
if (!module) {
|
|
17
12
|
return [];
|
|
18
13
|
}
|
|
19
|
-
return
|
|
14
|
+
return getModuleInstallationCalls(config, module);
|
|
20
15
|
},
|
|
21
16
|
};
|
|
22
17
|
}
|
|
@@ -27,11 +22,11 @@ function experimental_enable() {
|
|
|
27
22
|
function experimental_disable() {
|
|
28
23
|
return {
|
|
29
24
|
async resolve({ config }) {
|
|
30
|
-
const module =
|
|
25
|
+
const module = getSmartSessionValidator(config);
|
|
31
26
|
if (!module) {
|
|
32
27
|
return [];
|
|
33
28
|
}
|
|
34
|
-
return
|
|
29
|
+
return getModuleUninstallationCalls(config, module);
|
|
35
30
|
},
|
|
36
31
|
};
|
|
37
32
|
}
|
|
@@ -43,10 +38,11 @@ function experimental_disable() {
|
|
|
43
38
|
function experimental_enableSession(session, enableSessionSignature, hashesAndChainIds, sessionToEnableIndex) {
|
|
44
39
|
return {
|
|
45
40
|
async resolve({ accountAddress, chain, config }) {
|
|
46
|
-
return
|
|
41
|
+
return getEnableSessionCall(accountAddress, {
|
|
47
42
|
...session,
|
|
48
43
|
chain,
|
|
49
44
|
}, enableSessionSignature, hashesAndChainIds, sessionToEnableIndex, config.useDevContracts);
|
|
50
45
|
},
|
|
51
46
|
};
|
|
52
47
|
}
|
|
48
|
+
export { experimental_disable, experimental_enable, experimental_enableSession };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RhinestoneConfig, RhinestoneSDKConfig } from '../types';
|
|
1
|
+
import type { RhinestoneConfig, RhinestoneSDKConfig } from '../types.js';
|
|
2
2
|
export interface AuthProvider {
|
|
3
3
|
getHeaders(): Promise<Record<string, string>>;
|
|
4
4
|
getSubmitHeaders(intentInput: unknown, isSponsored: boolean): Promise<Record<string, string>>;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAuthProvider = createAuthProvider;
|
|
4
|
-
function createAuthProvider(config) {
|
|
1
|
+
export function createAuthProvider(config) {
|
|
5
2
|
const resolved = resolveAuth(config);
|
|
6
3
|
if (resolved.mode === 'apiKey') {
|
|
7
4
|
const headers = { 'x-api-key': resolved.apiKey };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AccountConfigurationNotSupportedError, AccountError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError } from '../accounts';
|
|
2
|
-
import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError } from '../execution';
|
|
3
|
-
import { AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, IntentNotFoundError, InternalServerError, InvalidApiKeyError, InvalidIntentSignatureError, isAuthError, isOrchestratorError, isRateLimited, isRetryable, isValidationError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, RateLimitedError, ResourceNotFoundError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, TokenNotSupportedError, UnauthorizedError, UnprocessableEntityError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError } from '../orchestrator';
|
|
1
|
+
import { AccountConfigurationNotSupportedError, AccountError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError } from '../accounts/index.js';
|
|
2
|
+
import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError } from '../execution/index.js';
|
|
3
|
+
import { AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, IntentNotFoundError, InternalServerError, InvalidApiKeyError, InvalidIntentSignatureError, isAuthError, isOrchestratorError, isRateLimited, isRetryable, isValidationError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, RateLimitedError, ResourceNotFoundError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, TokenNotSupportedError, UnauthorizedError, UnprocessableEntityError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError } from '../orchestrator/index.js';
|
|
4
4
|
export { isAccountError, AccountError, AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, Eip7702NotSupportedForAccountError, WalletClientNoConnectedAccountError, isExecutionError, ExecutionError, IntentFailedError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError, isOrchestratorError, isRetryable, isAuthError, isValidationError, isRateLimited, AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, InternalServerError, ResourceNotFoundError, RateLimitedError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, UnprocessableEntityError, UnauthorizedError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/errors/index.js
CHANGED
|
@@ -1,54 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, "ExistingEip7702AccountsNotSupportedError", { enumerable: true, get: function () { return accounts_1.ExistingEip7702AccountsNotSupportedError; } });
|
|
12
|
-
Object.defineProperty(exports, "FactoryArgsNotAvailableError", { enumerable: true, get: function () { return accounts_1.FactoryArgsNotAvailableError; } });
|
|
13
|
-
Object.defineProperty(exports, "isAccountError", { enumerable: true, get: function () { return accounts_1.isAccountError; } });
|
|
14
|
-
Object.defineProperty(exports, "SigningNotSupportedForAccountError", { enumerable: true, get: function () { return accounts_1.SigningNotSupportedForAccountError; } });
|
|
15
|
-
Object.defineProperty(exports, "SmartSessionsNotEnabledError", { enumerable: true, get: function () { return accounts_1.SmartSessionsNotEnabledError; } });
|
|
16
|
-
Object.defineProperty(exports, "WalletClientNoConnectedAccountError", { enumerable: true, get: function () { return accounts_1.WalletClientNoConnectedAccountError; } });
|
|
17
|
-
const execution_1 = require("../execution");
|
|
18
|
-
Object.defineProperty(exports, "ExecutionError", { enumerable: true, get: function () { return execution_1.ExecutionError; } });
|
|
19
|
-
Object.defineProperty(exports, "IntentFailedError", { enumerable: true, get: function () { return execution_1.IntentFailedError; } });
|
|
20
|
-
Object.defineProperty(exports, "isExecutionError", { enumerable: true, get: function () { return execution_1.isExecutionError; } });
|
|
21
|
-
Object.defineProperty(exports, "OrderPathRequiredForIntentsError", { enumerable: true, get: function () { return execution_1.OrderPathRequiredForIntentsError; } });
|
|
22
|
-
Object.defineProperty(exports, "SessionChainRequiredError", { enumerable: true, get: function () { return execution_1.SessionChainRequiredError; } });
|
|
23
|
-
Object.defineProperty(exports, "SignerNotSupportedError", { enumerable: true, get: function () { return execution_1.SignerNotSupportedError; } });
|
|
24
|
-
const orchestrator_1 = require("../orchestrator");
|
|
25
|
-
Object.defineProperty(exports, "AuthenticationRequiredError", { enumerable: true, get: function () { return orchestrator_1.AuthenticationRequiredError; } });
|
|
26
|
-
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return orchestrator_1.BadRequestError; } });
|
|
27
|
-
Object.defineProperty(exports, "BodyParserError", { enumerable: true, get: function () { return orchestrator_1.BodyParserError; } });
|
|
28
|
-
Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return orchestrator_1.ConflictError; } });
|
|
29
|
-
Object.defineProperty(exports, "ForbiddenError", { enumerable: true, get: function () { return orchestrator_1.ForbiddenError; } });
|
|
30
|
-
Object.defineProperty(exports, "InsufficientBalanceError", { enumerable: true, get: function () { return orchestrator_1.InsufficientBalanceError; } });
|
|
31
|
-
Object.defineProperty(exports, "InsufficientLiquidityError", { enumerable: true, get: function () { return orchestrator_1.InsufficientLiquidityError; } });
|
|
32
|
-
Object.defineProperty(exports, "IntentNotFoundError", { enumerable: true, get: function () { return orchestrator_1.IntentNotFoundError; } });
|
|
33
|
-
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return orchestrator_1.InternalServerError; } });
|
|
34
|
-
Object.defineProperty(exports, "InvalidApiKeyError", { enumerable: true, get: function () { return orchestrator_1.InvalidApiKeyError; } });
|
|
35
|
-
Object.defineProperty(exports, "InvalidIntentSignatureError", { enumerable: true, get: function () { return orchestrator_1.InvalidIntentSignatureError; } });
|
|
36
|
-
Object.defineProperty(exports, "isAuthError", { enumerable: true, get: function () { return orchestrator_1.isAuthError; } });
|
|
37
|
-
Object.defineProperty(exports, "isOrchestratorError", { enumerable: true, get: function () { return orchestrator_1.isOrchestratorError; } });
|
|
38
|
-
Object.defineProperty(exports, "isRateLimited", { enumerable: true, get: function () { return orchestrator_1.isRateLimited; } });
|
|
39
|
-
Object.defineProperty(exports, "isRetryable", { enumerable: true, get: function () { return orchestrator_1.isRetryable; } });
|
|
40
|
-
Object.defineProperty(exports, "isValidationError", { enumerable: true, get: function () { return orchestrator_1.isValidationError; } });
|
|
41
|
-
Object.defineProperty(exports, "NoPathFoundError", { enumerable: true, get: function () { return orchestrator_1.NoPathFoundError; } });
|
|
42
|
-
Object.defineProperty(exports, "OnlyOneTargetTokenAmountCanBeUnsetError", { enumerable: true, get: function () { return orchestrator_1.OnlyOneTargetTokenAmountCanBeUnsetError; } });
|
|
43
|
-
Object.defineProperty(exports, "OrchestratorError", { enumerable: true, get: function () { return orchestrator_1.OrchestratorError; } });
|
|
44
|
-
Object.defineProperty(exports, "RateLimitedError", { enumerable: true, get: function () { return orchestrator_1.RateLimitedError; } });
|
|
45
|
-
Object.defineProperty(exports, "ResourceNotFoundError", { enumerable: true, get: function () { return orchestrator_1.ResourceNotFoundError; } });
|
|
46
|
-
Object.defineProperty(exports, "SchemaValidationError", { enumerable: true, get: function () { return orchestrator_1.SchemaValidationError; } });
|
|
47
|
-
Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return orchestrator_1.ServiceUnavailableError; } });
|
|
48
|
-
Object.defineProperty(exports, "SimulationFailedError", { enumerable: true, get: function () { return orchestrator_1.SimulationFailedError; } });
|
|
49
|
-
Object.defineProperty(exports, "TokenNotSupportedError", { enumerable: true, get: function () { return orchestrator_1.TokenNotSupportedError; } });
|
|
50
|
-
Object.defineProperty(exports, "UnauthorizedError", { enumerable: true, get: function () { return orchestrator_1.UnauthorizedError; } });
|
|
51
|
-
Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, get: function () { return orchestrator_1.UnprocessableEntityError; } });
|
|
52
|
-
Object.defineProperty(exports, "UnsupportedChainError", { enumerable: true, get: function () { return orchestrator_1.UnsupportedChainError; } });
|
|
53
|
-
Object.defineProperty(exports, "UnsupportedChainIdError", { enumerable: true, get: function () { return orchestrator_1.UnsupportedChainIdError; } });
|
|
54
|
-
Object.defineProperty(exports, "UnsupportedTokenError", { enumerable: true, get: function () { return orchestrator_1.UnsupportedTokenError; } });
|
|
1
|
+
import { AccountConfigurationNotSupportedError, AccountError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError, } from '../accounts/index.js';
|
|
2
|
+
import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError, } from '../execution/index.js';
|
|
3
|
+
import { AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, IntentNotFoundError, InternalServerError, InvalidApiKeyError, InvalidIntentSignatureError, isAuthError, isOrchestratorError, isRateLimited, isRetryable, isValidationError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, RateLimitedError, ResourceNotFoundError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, TokenNotSupportedError, UnauthorizedError, UnprocessableEntityError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, } from '../orchestrator/index.js';
|
|
4
|
+
export {
|
|
5
|
+
// Account
|
|
6
|
+
isAccountError, AccountError, AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, Eip7702NotSupportedForAccountError, WalletClientNoConnectedAccountError,
|
|
7
|
+
// Execution
|
|
8
|
+
isExecutionError, ExecutionError, IntentFailedError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError,
|
|
9
|
+
// Orchestrator
|
|
10
|
+
isOrchestratorError, isRetryable, isAuthError, isValidationError, isRateLimited, AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, InternalServerError, ResourceNotFoundError, RateLimitedError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, UnprocessableEntityError, UnauthorizedError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Hex } from 'viem';
|
|
2
|
-
import type { IntentOp, IntentOpElement } from '../orchestrator/types';
|
|
2
|
+
import type { IntentOp, IntentOpElement } from '../orchestrator/types.js';
|
|
3
3
|
declare const SCOPE_MULTICHAIN = 0;
|
|
4
4
|
declare const RESET_PERIOD_ONE_WEEK = 6;
|
|
5
5
|
declare const COMPACT_ADDRESS = "0x00000000000000171ede64904551eeDF3C6C9788";
|
|
@@ -125,8 +125,8 @@ declare function getCompactTypedData(intentOp: IntentOp): {
|
|
|
125
125
|
fillExpiry: bigint;
|
|
126
126
|
};
|
|
127
127
|
minGas: bigint;
|
|
128
|
-
originOps: import("../orchestrator/types").Op;
|
|
129
|
-
destOps: import("../orchestrator/types").Op;
|
|
128
|
+
originOps: import("../orchestrator/types.js").Op;
|
|
129
|
+
destOps: import("../orchestrator/types.js").Op;
|
|
130
130
|
q: `0x${string}`;
|
|
131
131
|
};
|
|
132
132
|
}[];
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.COMPACT_ADDRESS = exports.RESET_PERIOD_ONE_WEEK = exports.SCOPE_MULTICHAIN = void 0;
|
|
4
|
-
exports.getCompactTypedData = getCompactTypedData;
|
|
5
|
-
exports.getCompactDigest = getCompactDigest;
|
|
6
|
-
exports.getPermit2Digest = getPermit2Digest;
|
|
7
|
-
const viem_1 = require("viem");
|
|
8
|
-
const permit2_1 = require("./permit2");
|
|
1
|
+
import { hashTypedData, keccak256, slice, toHex } from 'viem';
|
|
2
|
+
import { getTypedData as getPermit2TypedData } from './permit2.js';
|
|
9
3
|
const SCOPE_MULTICHAIN = 0;
|
|
10
|
-
exports.SCOPE_MULTICHAIN = SCOPE_MULTICHAIN;
|
|
11
4
|
const RESET_PERIOD_ONE_WEEK = 6;
|
|
12
|
-
exports.RESET_PERIOD_ONE_WEEK = RESET_PERIOD_ONE_WEEK;
|
|
13
5
|
const COMPACT_ADDRESS = '0x00000000000000171ede64904551eeDF3C6C9788';
|
|
14
|
-
exports.COMPACT_ADDRESS = COMPACT_ADDRESS;
|
|
15
6
|
// Define the typed data structure as const to preserve type safety
|
|
16
7
|
const COMPACT_TYPED_DATA_TYPES = {
|
|
17
8
|
MultichainCompact: [
|
|
@@ -76,15 +67,15 @@ function getCompactTypedData(intentOp) {
|
|
|
76
67
|
arbiter: element.arbiter,
|
|
77
68
|
chainId: BigInt(element.chainId),
|
|
78
69
|
commitments: element.idsAndAmounts.map((token) => ({
|
|
79
|
-
lockTag:
|
|
80
|
-
token:
|
|
70
|
+
lockTag: slice(toHex(BigInt(token[0])), 0, 12),
|
|
71
|
+
token: slice(toHex(BigInt(token[0])), 12, 32),
|
|
81
72
|
amount: BigInt(token[1]),
|
|
82
73
|
})),
|
|
83
74
|
mandate: {
|
|
84
75
|
target: {
|
|
85
76
|
recipient: element.mandate.recipient,
|
|
86
77
|
tokenOut: element.mandate.tokenOut.map((token) => ({
|
|
87
|
-
token:
|
|
78
|
+
token: slice(toHex(BigInt(token[0])), 12, 32),
|
|
88
79
|
amount: BigInt(token[1]),
|
|
89
80
|
})),
|
|
90
81
|
targetChain: BigInt(element.mandate.destinationChainId),
|
|
@@ -93,7 +84,7 @@ function getCompactTypedData(intentOp) {
|
|
|
93
84
|
minGas: BigInt(element.mandate.minGas),
|
|
94
85
|
originOps: element.mandate.preClaimOps,
|
|
95
86
|
destOps: element.mandate.destinationOps,
|
|
96
|
-
q:
|
|
87
|
+
q: keccak256(element.mandate.qualifier.encodedVal),
|
|
97
88
|
},
|
|
98
89
|
})),
|
|
99
90
|
},
|
|
@@ -107,7 +98,7 @@ function getCompactTypedData(intentOp) {
|
|
|
107
98
|
*/
|
|
108
99
|
function getCompactDigest(intentOp) {
|
|
109
100
|
const typedData = getCompactTypedData(intentOp);
|
|
110
|
-
return
|
|
101
|
+
return hashTypedData(typedData);
|
|
111
102
|
}
|
|
112
103
|
/**
|
|
113
104
|
* Get the Permit2 digest for signing
|
|
@@ -115,6 +106,7 @@ function getCompactDigest(intentOp) {
|
|
|
115
106
|
* @returns The digest hash
|
|
116
107
|
*/
|
|
117
108
|
function getPermit2Digest(element, nonce, expires) {
|
|
118
|
-
const typedData = (
|
|
119
|
-
return
|
|
109
|
+
const typedData = getPermit2TypedData(element, nonce, expires);
|
|
110
|
+
return hashTypedData(typedData);
|
|
120
111
|
}
|
|
112
|
+
export { SCOPE_MULTICHAIN, RESET_PERIOD_ONE_WEEK, COMPACT_ADDRESS, getCompactTypedData, getCompactDigest, getPermit2Digest, };
|