@rhinestone/sdk 1.0.40 → 1.0.41-alpha.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/package.json +1 -1
- package/dist/src/accounts/error.d.ts +0 -114
- package/dist/src/accounts/error.d.ts.map +0 -1
- package/dist/src/accounts/error.js +0 -174
- package/dist/src/accounts/index.d.ts +0 -50
- package/dist/src/accounts/index.d.ts.map +0 -1
- package/dist/src/accounts/index.js +0 -669
- 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.d.ts +0 -5
- package/dist/src/accounts/json-rpc/index.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/index.js +0 -20
- 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 -33
- package/dist/src/accounts/json-rpc/providers.d.ts +0 -5
- package/dist/src/accounts/json-rpc/providers.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/providers.js +0 -22
- 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.d.ts +0 -29
- package/dist/src/accounts/kernel.d.ts.map +0 -1
- package/dist/src/accounts/kernel.js +0 -297
- 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.d.ts +0 -35
- package/dist/src/accounts/nexus.d.ts.map +0 -1
- package/dist/src/accounts/nexus.js +0 -471
- 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/passport.d.ts +0 -12
- package/dist/src/accounts/passport.d.ts.map +0 -1
- package/dist/src/accounts/passport.js +0 -173
- package/dist/src/accounts/safe.d.ts +0 -35
- package/dist/src/accounts/safe.d.ts.map +0 -1
- package/dist/src/accounts/safe.js +0 -365
- 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 -118
- package/dist/src/accounts/signing/common.d.ts +0 -27
- package/dist/src/accounts/signing/common.d.ts.map +0 -1
- package/dist/src/accounts/signing/common.js +0 -183
- package/dist/src/accounts/signing/message.d.ts +0 -5
- package/dist/src/accounts/signing/message.d.ts.map +0 -1
- package/dist/src/accounts/signing/message.js +0 -47
- package/dist/src/accounts/signing/passkeys.d.ts +0 -36
- package/dist/src/accounts/signing/passkeys.d.ts.map +0 -1
- package/dist/src/accounts/signing/passkeys.js +0 -125
- 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/signing/typedData.d.ts +0 -5
- package/dist/src/accounts/signing/typedData.d.ts.map +0 -1
- package/dist/src/accounts/signing/typedData.js +0 -35
- package/dist/src/accounts/startale.d.ts +0 -27
- package/dist/src/accounts/startale.d.ts.map +0 -1
- package/dist/src/accounts/startale.js +0 -116
- 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 -92
- package/dist/src/accounts/utils.d.ts +0 -33
- package/dist/src/accounts/utils.d.ts.map +0 -1
- package/dist/src/accounts/utils.js +0 -201
- 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/accounts/walletClient.d.ts +0 -34
- package/dist/src/accounts/walletClient.d.ts.map +0 -1
- package/dist/src/accounts/walletClient.js +0 -121
- package/dist/src/actions/compact.d.ts +0 -13
- package/dist/src/actions/compact.d.ts.map +0 -1
- package/dist/src/actions/compact.js +0 -210
- package/dist/src/actions/deployment.d.ts +0 -19
- package/dist/src/actions/deployment.d.ts.map +0 -1
- package/dist/src/actions/deployment.js +0 -78
- package/dist/src/actions/ecdsa.d.ts +0 -35
- package/dist/src/actions/ecdsa.d.ts.map +0 -1
- package/dist/src/actions/ecdsa.js +0 -114
- 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/index.d.ts +0 -17
- package/dist/src/actions/index.d.ts.map +0 -1
- package/dist/src/actions/index.js +0 -53
- package/dist/src/actions/mfa.d.ts +0 -37
- package/dist/src/actions/mfa.d.ts.map +0 -1
- package/dist/src/actions/mfa.js +0 -133
- package/dist/src/actions/passkeys.d.ts +0 -37
- package/dist/src/actions/passkeys.d.ts.map +0 -1
- package/dist/src/actions/passkeys.js +0 -129
- 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.d.ts +0 -33
- package/dist/src/actions/recovery.d.ts.map +0 -1
- package/dist/src/actions/recovery.js +0 -193
- 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/actions/smart-sessions.d.ts +0 -14
- package/dist/src/actions/smart-sessions.d.ts.map +0 -1
- package/dist/src/actions/smart-sessions.js +0 -16
- package/dist/src/errors/index.d.ts +0 -5
- package/dist/src/errors/index.d.ts.map +0 -1
- package/dist/src/errors/index.js +0 -53
- package/dist/src/execution/compact.d.ts +0 -151
- package/dist/src/execution/compact.d.ts.map +0 -1
- package/dist/src/execution/compact.js +0 -122
- package/dist/src/execution/error.d.ts +0 -61
- package/dist/src/execution/error.d.ts.map +0 -1
- package/dist/src/execution/error.js +0 -87
- package/dist/src/execution/index.d.ts +0 -41
- package/dist/src/execution/index.d.ts.map +0 -1
- package/dist/src/execution/index.js +0 -233
- package/dist/src/execution/permit2.d.ts +0 -148
- package/dist/src/execution/permit2.d.ts.map +0 -1
- package/dist/src/execution/permit2.js +0 -291
- package/dist/src/execution/singleChainOps.d.ts +0 -28
- package/dist/src/execution/singleChainOps.d.ts.map +0 -1
- package/dist/src/execution/singleChainOps.js +0 -32
- package/dist/src/execution/smart-session.d.ts +0 -13
- package/dist/src/execution/smart-session.d.ts.map +0 -1
- package/dist/src/execution/smart-session.js +0 -178
- 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
- package/dist/src/execution/utils.d.ts +0 -83
- package/dist/src/execution/utils.d.ts.map +0 -1
- package/dist/src/execution/utils.js +0 -705
- package/dist/src/index.d.ts +0 -74
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -317
- package/dist/src/modules/abi/smart-sessions.d.ts +0 -104
- package/dist/src/modules/abi/smart-sessions.d.ts.map +0 -1
- package/dist/src/modules/abi/smart-sessions.js +0 -131
- package/dist/src/modules/chain-abstraction.d.ts +0 -5
- package/dist/src/modules/chain-abstraction.d.ts.map +0 -1
- package/dist/src/modules/chain-abstraction.js +0 -7
- package/dist/src/modules/common.d.ts +0 -30
- package/dist/src/modules/common.d.ts.map +0 -1
- package/dist/src/modules/common.js +0 -42
- package/dist/src/modules/index.d.ts +0 -10
- package/dist/src/modules/index.d.ts.map +0 -1
- package/dist/src/modules/index.js +0 -94
- 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/legacy.d.ts +0 -10
- package/dist/src/modules/legacy.d.ts.map +0 -1
- package/dist/src/modules/legacy.js +0 -65
- package/dist/src/modules/read.d.ts +0 -9
- package/dist/src/modules/read.d.ts.map +0 -1
- package/dist/src/modules/read.js +0 -125
- package/dist/src/modules/validators/core.d.ts +0 -29
- package/dist/src/modules/validators/core.d.ts.map +0 -1
- package/dist/src/modules/validators/core.js +0 -278
- 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/index.d.ts +0 -4
- package/dist/src/modules/validators/index.d.ts.map +0 -1
- package/dist/src/modules/validators/index.js +0 -15
- package/dist/src/modules/validators/smart-sessions.d.ts +0 -96
- package/dist/src/modules/validators/smart-sessions.d.ts.map +0 -1
- package/dist/src/modules/validators/smart-sessions.js +0 -497
- 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 -219
- package/dist/src/orchestrator/client.d.ts +0 -27
- package/dist/src/orchestrator/client.d.ts.map +0 -1
- package/dist/src/orchestrator/client.js +0 -354
- package/dist/src/orchestrator/consts.d.ts +0 -5
- package/dist/src/orchestrator/consts.d.ts.map +0 -1
- package/dist/src/orchestrator/consts.js +0 -9
- package/dist/src/orchestrator/error.d.ts +0 -232
- package/dist/src/orchestrator/error.d.ts.map +0 -1
- package/dist/src/orchestrator/error.js +0 -268
- package/dist/src/orchestrator/index.d.ts +0 -10
- package/dist/src/orchestrator/index.d.ts.map +0 -1
- package/dist/src/orchestrator/index.js +0 -57
- package/dist/src/orchestrator/registry.d.ts +0 -22
- package/dist/src/orchestrator/registry.d.ts.map +0 -1
- package/dist/src/orchestrator/registry.js +0 -121
- 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 -150
- package/dist/src/orchestrator/types.d.ts +0 -295
- package/dist/src/orchestrator/types.d.ts.map +0 -1
- package/dist/src/orchestrator/types.js +0 -17
- package/dist/src/orchestrator/utils.d.ts +0 -3
- package/dist/src/orchestrator/utils.d.ts.map +0 -1
- package/dist/src/orchestrator/utils.js +0 -24
- package/dist/src/types.d.ts +0 -278
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -2
- package/dist/src/utils/index.d.ts +0 -26
- package/dist/src/utils/index.d.ts.map +0 -1
- package/dist/src/utils/index.js +0 -63
- 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,669 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WalletClientNoConnectedAccountError = exports.SmartSessionsNotEnabledError = exports.SigningNotSupportedForAccountError = exports.OwnersFieldRequiredError = exports.ModuleInstallationNotSupportedError = exports.FactoryArgsNotAvailableError = exports.ExistingEip7702AccountsNotSupportedError = exports.EoaSigningNotSupportedError = exports.EoaSigningMethodNotConfiguredError = exports.EoaAccountMustHaveAccountError = exports.Eip7702NotSupportedForAccountError = exports.Eip7702AccountMustHaveEoaError = exports.Eip712DomainNotAvailableError = exports.AccountConfigurationNotSupportedError = exports.AccountError = exports.isAccountError = void 0;
|
|
4
|
-
exports.getEip712Domain = getEip712Domain;
|
|
5
|
-
exports.getModuleInstallationCalls = getModuleInstallationCalls;
|
|
6
|
-
exports.getModuleUninstallationCalls = getModuleUninstallationCalls;
|
|
7
|
-
exports.getAddress = getAddress;
|
|
8
|
-
exports.checkAddress = checkAddress;
|
|
9
|
-
exports.getAccountProvider = getAccountProvider;
|
|
10
|
-
exports.getInitCode = getInitCode;
|
|
11
|
-
exports.getV0InitCode = getV0InitCode;
|
|
12
|
-
exports.signEip7702InitData = signEip7702InitData;
|
|
13
|
-
exports.getEip7702InitCall = getEip7702InitCall;
|
|
14
|
-
exports.is7702 = is7702;
|
|
15
|
-
exports.isDeployed = isDeployed;
|
|
16
|
-
exports.deploy = deploy;
|
|
17
|
-
exports.setup = setup;
|
|
18
|
-
exports.toErc6492Signature = toErc6492Signature;
|
|
19
|
-
exports.getSmartAccount = getSmartAccount;
|
|
20
|
-
exports.getSmartSessionSmartAccount = getSmartSessionSmartAccount;
|
|
21
|
-
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
22
|
-
exports.getPackedSignature = getPackedSignature;
|
|
23
|
-
exports.getTypedDataPackedSignature = getTypedDataPackedSignature;
|
|
24
|
-
const viem_1 = require("viem");
|
|
25
|
-
const execution_1 = require("../execution");
|
|
26
|
-
const smart_session_1 = require("../execution/smart-session");
|
|
27
|
-
const modules_1 = require("../modules");
|
|
28
|
-
const validators_1 = require("../modules/validators");
|
|
29
|
-
const core_1 = require("../modules/validators/core");
|
|
30
|
-
const error_1 = require("./error");
|
|
31
|
-
Object.defineProperty(exports, "AccountConfigurationNotSupportedError", { enumerable: true, get: function () { return error_1.AccountConfigurationNotSupportedError; } });
|
|
32
|
-
Object.defineProperty(exports, "AccountError", { enumerable: true, get: function () { return error_1.AccountError; } });
|
|
33
|
-
Object.defineProperty(exports, "Eip712DomainNotAvailableError", { enumerable: true, get: function () { return error_1.Eip712DomainNotAvailableError; } });
|
|
34
|
-
Object.defineProperty(exports, "Eip7702AccountMustHaveEoaError", { enumerable: true, get: function () { return error_1.Eip7702AccountMustHaveEoaError; } });
|
|
35
|
-
Object.defineProperty(exports, "Eip7702NotSupportedForAccountError", { enumerable: true, get: function () { return error_1.Eip7702NotSupportedForAccountError; } });
|
|
36
|
-
Object.defineProperty(exports, "EoaAccountMustHaveAccountError", { enumerable: true, get: function () { return error_1.EoaAccountMustHaveAccountError; } });
|
|
37
|
-
Object.defineProperty(exports, "EoaSigningMethodNotConfiguredError", { enumerable: true, get: function () { return error_1.EoaSigningMethodNotConfiguredError; } });
|
|
38
|
-
Object.defineProperty(exports, "EoaSigningNotSupportedError", { enumerable: true, get: function () { return error_1.EoaSigningNotSupportedError; } });
|
|
39
|
-
Object.defineProperty(exports, "ExistingEip7702AccountsNotSupportedError", { enumerable: true, get: function () { return error_1.ExistingEip7702AccountsNotSupportedError; } });
|
|
40
|
-
Object.defineProperty(exports, "FactoryArgsNotAvailableError", { enumerable: true, get: function () { return error_1.FactoryArgsNotAvailableError; } });
|
|
41
|
-
Object.defineProperty(exports, "isAccountError", { enumerable: true, get: function () { return error_1.isAccountError; } });
|
|
42
|
-
Object.defineProperty(exports, "ModuleInstallationNotSupportedError", { enumerable: true, get: function () { return error_1.ModuleInstallationNotSupportedError; } });
|
|
43
|
-
Object.defineProperty(exports, "OwnersFieldRequiredError", { enumerable: true, get: function () { return error_1.OwnersFieldRequiredError; } });
|
|
44
|
-
Object.defineProperty(exports, "SigningNotSupportedForAccountError", { enumerable: true, get: function () { return error_1.SigningNotSupportedForAccountError; } });
|
|
45
|
-
Object.defineProperty(exports, "SmartSessionsNotEnabledError", { enumerable: true, get: function () { return error_1.SmartSessionsNotEnabledError; } });
|
|
46
|
-
Object.defineProperty(exports, "WalletClientNoConnectedAccountError", { enumerable: true, get: function () { return error_1.WalletClientNoConnectedAccountError; } });
|
|
47
|
-
const kernel_1 = require("./kernel");
|
|
48
|
-
const nexus_1 = require("./nexus");
|
|
49
|
-
const passport_1 = require("./passport");
|
|
50
|
-
const safe_1 = require("./safe");
|
|
51
|
-
const common_1 = require("./signing/common");
|
|
52
|
-
const message_1 = require("./signing/message");
|
|
53
|
-
const typedData_1 = require("./signing/typedData");
|
|
54
|
-
const startale_1 = require("./startale");
|
|
55
|
-
const utils_1 = require("./utils");
|
|
56
|
-
function getDeployArgs(config) {
|
|
57
|
-
const account = getAccountProvider(config);
|
|
58
|
-
switch (account.type) {
|
|
59
|
-
case 'safe': {
|
|
60
|
-
return (0, safe_1.getDeployArgs)(config);
|
|
61
|
-
}
|
|
62
|
-
case 'nexus': {
|
|
63
|
-
return (0, nexus_1.getDeployArgs)(config);
|
|
64
|
-
}
|
|
65
|
-
case 'kernel': {
|
|
66
|
-
return (0, kernel_1.getDeployArgs)(config);
|
|
67
|
-
}
|
|
68
|
-
case 'startale': {
|
|
69
|
-
return (0, startale_1.getDeployArgs)(config);
|
|
70
|
-
}
|
|
71
|
-
case 'passport': {
|
|
72
|
-
// Mocked data; will be overridden by the actual deploy args
|
|
73
|
-
return {
|
|
74
|
-
factory: viem_1.zeroAddress,
|
|
75
|
-
factoryData: viem_1.zeroHash,
|
|
76
|
-
salt: viem_1.zeroHash,
|
|
77
|
-
implementation: viem_1.zeroAddress,
|
|
78
|
-
initializationCallData: '0x',
|
|
79
|
-
initData: '0x',
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
case 'eoa': {
|
|
83
|
-
throw new Error('EOA accounts do not have deploy args');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function getV0DeployArgs(config) {
|
|
88
|
-
const account = getAccountProvider(config);
|
|
89
|
-
switch (account.type) {
|
|
90
|
-
case 'safe': {
|
|
91
|
-
return (0, safe_1.getV0DeployArgs)(config);
|
|
92
|
-
}
|
|
93
|
-
default: {
|
|
94
|
-
throw new Error(`Unsupported account type: ${account.type}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function getInitCode(config) {
|
|
99
|
-
if (is7702(config)) {
|
|
100
|
-
return undefined;
|
|
101
|
-
}
|
|
102
|
-
else if (config.account?.type === 'eoa') {
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
else if (config.initData) {
|
|
106
|
-
return config.initData;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
const deployArgs = getDeployArgs(config);
|
|
110
|
-
if (!deployArgs) {
|
|
111
|
-
throw new error_1.FactoryArgsNotAvailableError();
|
|
112
|
-
}
|
|
113
|
-
const { factory, factoryData } = deployArgs;
|
|
114
|
-
return {
|
|
115
|
-
factory,
|
|
116
|
-
factoryData,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function getV0InitCode(config) {
|
|
121
|
-
if (is7702(config)) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
else if (config.account?.type === 'eoa') {
|
|
125
|
-
return undefined;
|
|
126
|
-
}
|
|
127
|
-
else if (config.initData) {
|
|
128
|
-
return config.initData;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
const deployArgs = getV0DeployArgs(config);
|
|
132
|
-
if (!deployArgs) {
|
|
133
|
-
throw new error_1.FactoryArgsNotAvailableError();
|
|
134
|
-
}
|
|
135
|
-
const { factory, factoryData } = deployArgs;
|
|
136
|
-
return {
|
|
137
|
-
factory,
|
|
138
|
-
factoryData,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
async function signEip7702InitData(config) {
|
|
143
|
-
const eoa = config.eoa;
|
|
144
|
-
if (!eoa) {
|
|
145
|
-
throw new error_1.Eip7702AccountMustHaveEoaError();
|
|
146
|
-
}
|
|
147
|
-
const account = getAccountProvider(config);
|
|
148
|
-
switch (account.type) {
|
|
149
|
-
case 'nexus': {
|
|
150
|
-
return await (0, nexus_1.signEip7702InitData)(config, eoa);
|
|
151
|
-
}
|
|
152
|
-
case 'eoa': {
|
|
153
|
-
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
154
|
-
}
|
|
155
|
-
case 'safe':
|
|
156
|
-
case 'kernel':
|
|
157
|
-
case 'startale': {
|
|
158
|
-
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
159
|
-
}
|
|
160
|
-
default: {
|
|
161
|
-
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function getEip7702InitCall(config, signature) {
|
|
166
|
-
const account = getAccountProvider(config);
|
|
167
|
-
switch (account.type) {
|
|
168
|
-
case 'nexus': {
|
|
169
|
-
return (0, nexus_1.getEip7702InitCall)(config, signature);
|
|
170
|
-
}
|
|
171
|
-
case 'safe':
|
|
172
|
-
case 'kernel':
|
|
173
|
-
case 'startale': {
|
|
174
|
-
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
175
|
-
}
|
|
176
|
-
default: {
|
|
177
|
-
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
function getEip712Domain(config, chain) {
|
|
182
|
-
const account = getAccountProvider(config);
|
|
183
|
-
switch (account.type) {
|
|
184
|
-
case 'nexus': {
|
|
185
|
-
return (0, nexus_1.getEip712Domain)(config, chain);
|
|
186
|
-
}
|
|
187
|
-
case 'safe': {
|
|
188
|
-
return (0, safe_1.getEip712Domain)(config, chain);
|
|
189
|
-
}
|
|
190
|
-
case 'kernel': {
|
|
191
|
-
return (0, kernel_1.getEip712Domain)(config, chain);
|
|
192
|
-
}
|
|
193
|
-
case 'startale': {
|
|
194
|
-
return (0, startale_1.getEip712Domain)(config, chain);
|
|
195
|
-
}
|
|
196
|
-
case 'eoa': {
|
|
197
|
-
throw new error_1.Eip712DomainNotAvailableError('EOA accounts do not have an EIP-712 domain');
|
|
198
|
-
}
|
|
199
|
-
default: {
|
|
200
|
-
throw new error_1.Eip712DomainNotAvailableError(`Account type ${account.type} not yet supported`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
function getModuleInstallationCalls(config, module) {
|
|
205
|
-
const address = getAddress(config);
|
|
206
|
-
function getInstallData() {
|
|
207
|
-
const account = getAccountProvider(config);
|
|
208
|
-
switch (account.type) {
|
|
209
|
-
case 'safe': {
|
|
210
|
-
return [(0, safe_1.getInstallData)(module)];
|
|
211
|
-
}
|
|
212
|
-
case 'nexus': {
|
|
213
|
-
return [(0, nexus_1.getInstallData)(module)];
|
|
214
|
-
}
|
|
215
|
-
case 'kernel': {
|
|
216
|
-
return (0, kernel_1.getInstallData)(module);
|
|
217
|
-
}
|
|
218
|
-
case 'startale': {
|
|
219
|
-
return [(0, startale_1.getInstallData)(module)];
|
|
220
|
-
}
|
|
221
|
-
case 'passport': {
|
|
222
|
-
return [(0, passport_1.getInstallData)(module)];
|
|
223
|
-
}
|
|
224
|
-
case 'eoa': {
|
|
225
|
-
throw new error_1.ModuleInstallationNotSupportedError(account.type);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
const installData = getInstallData();
|
|
230
|
-
return installData.map((data) => ({
|
|
231
|
-
to: address,
|
|
232
|
-
value: 0n,
|
|
233
|
-
data,
|
|
234
|
-
}));
|
|
235
|
-
}
|
|
236
|
-
function getModuleUninstallationCalls(config, module) {
|
|
237
|
-
const address = getAddress(config);
|
|
238
|
-
const data = (0, viem_1.encodeFunctionData)({
|
|
239
|
-
abi: [
|
|
240
|
-
{
|
|
241
|
-
type: 'function',
|
|
242
|
-
name: 'uninstallModule',
|
|
243
|
-
inputs: [
|
|
244
|
-
{
|
|
245
|
-
type: 'uint256',
|
|
246
|
-
name: 'moduleTypeId',
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
type: 'address',
|
|
250
|
-
name: 'module',
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
type: 'bytes',
|
|
254
|
-
name: 'deInitData',
|
|
255
|
-
},
|
|
256
|
-
],
|
|
257
|
-
outputs: [],
|
|
258
|
-
stateMutability: 'nonpayable',
|
|
259
|
-
},
|
|
260
|
-
],
|
|
261
|
-
functionName: 'uninstallModule',
|
|
262
|
-
args: [module.type, module.address, module.deInitData],
|
|
263
|
-
});
|
|
264
|
-
return [{ to: address, data, value: 0n }];
|
|
265
|
-
}
|
|
266
|
-
function getAddress(config) {
|
|
267
|
-
if (is7702(config)) {
|
|
268
|
-
if (!config.eoa) {
|
|
269
|
-
throw new error_1.Eip7702AccountMustHaveEoaError();
|
|
270
|
-
}
|
|
271
|
-
return config.eoa.address;
|
|
272
|
-
}
|
|
273
|
-
const account = getAccountProvider(config);
|
|
274
|
-
switch (account.type) {
|
|
275
|
-
case 'safe': {
|
|
276
|
-
return (0, safe_1.getAddress)(config);
|
|
277
|
-
}
|
|
278
|
-
case 'nexus': {
|
|
279
|
-
return (0, nexus_1.getAddress)(config);
|
|
280
|
-
}
|
|
281
|
-
case 'kernel': {
|
|
282
|
-
return (0, kernel_1.getAddress)(config);
|
|
283
|
-
}
|
|
284
|
-
case 'startale': {
|
|
285
|
-
return (0, startale_1.getAddress)(config);
|
|
286
|
-
}
|
|
287
|
-
case 'passport': {
|
|
288
|
-
return (0, passport_1.getAddress)(config);
|
|
289
|
-
}
|
|
290
|
-
case 'eoa': {
|
|
291
|
-
if (!config.eoa) {
|
|
292
|
-
throw new error_1.AccountError({
|
|
293
|
-
message: 'EOA account must have an EOA configured',
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
return config.eoa.address;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function checkAddress(config) {
|
|
301
|
-
if (!config.initData) {
|
|
302
|
-
return true;
|
|
303
|
-
}
|
|
304
|
-
return (config.initData.address.toLowerCase() === getAddress(config).toLowerCase());
|
|
305
|
-
}
|
|
306
|
-
// Signs and packs a signature to be EIP-1271 compatible
|
|
307
|
-
async function getPackedSignature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
308
|
-
if (config.account?.type === 'eoa') {
|
|
309
|
-
throw new error_1.EoaSigningNotSupportedError('packed signatures');
|
|
310
|
-
}
|
|
311
|
-
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
312
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, false);
|
|
313
|
-
const account = getAccountProvider(config);
|
|
314
|
-
const address = getAddress(config);
|
|
315
|
-
switch (account.type) {
|
|
316
|
-
case 'safe': {
|
|
317
|
-
const signature = await signFn(hash);
|
|
318
|
-
return (0, safe_1.packSignature)(signature, validator, transformSignature);
|
|
319
|
-
}
|
|
320
|
-
case 'nexus': {
|
|
321
|
-
const signature = await signFn(hash);
|
|
322
|
-
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
323
|
-
return (0, nexus_1.packSignature)(signature, validator, transformSignature, defaultValidatorAddress);
|
|
324
|
-
}
|
|
325
|
-
case 'passport': {
|
|
326
|
-
const signature = await signFn(hash);
|
|
327
|
-
return (0, passport_1.packSignature)(signature, validator, transformSignature);
|
|
328
|
-
}
|
|
329
|
-
case 'kernel': {
|
|
330
|
-
const signature = await signFn((0, kernel_1.wrapMessageHash)(hash, address));
|
|
331
|
-
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
332
|
-
}
|
|
333
|
-
case 'startale': {
|
|
334
|
-
const signature = await signFn(hash);
|
|
335
|
-
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
336
|
-
}
|
|
337
|
-
default: {
|
|
338
|
-
throw new Error(`Unsupported account type: ${account.type}`);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
// Signs and packs a signature to be EIP-1271 compatible
|
|
343
|
-
async function getTypedDataPackedSignature(config, signers, chain, validator, parameters, transformSignature = (signature) => signature) {
|
|
344
|
-
if (config.account?.type === 'eoa') {
|
|
345
|
-
throw new error_1.EoaSigningNotSupportedError('packed signatures');
|
|
346
|
-
}
|
|
347
|
-
const address = getAddress(config);
|
|
348
|
-
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
349
|
-
const signFn = (parameters) => (0, typedData_1.sign)(signers, chain, address, parameters);
|
|
350
|
-
const account = getAccountProvider(config);
|
|
351
|
-
switch (account.type) {
|
|
352
|
-
case 'safe': {
|
|
353
|
-
const signature = await signFn(parameters);
|
|
354
|
-
return (0, safe_1.packSignature)(signature, validator, transformSignature);
|
|
355
|
-
}
|
|
356
|
-
case 'nexus': {
|
|
357
|
-
const signature = await signFn(parameters);
|
|
358
|
-
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
359
|
-
return (0, nexus_1.packSignature)(signature, validator, transformSignature, defaultValidatorAddress);
|
|
360
|
-
}
|
|
361
|
-
case 'passport': {
|
|
362
|
-
const signature = await signFn(parameters);
|
|
363
|
-
return (0, passport_1.packSignature)(signature, validator, transformSignature);
|
|
364
|
-
}
|
|
365
|
-
case 'kernel': {
|
|
366
|
-
const address = getAddress(config);
|
|
367
|
-
const signMessageFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, false);
|
|
368
|
-
const signature = await signMessageFn((0, kernel_1.wrapMessageHash)((0, viem_1.hashTypedData)(parameters), address));
|
|
369
|
-
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
370
|
-
}
|
|
371
|
-
case 'startale': {
|
|
372
|
-
const signature = await signFn(parameters);
|
|
373
|
-
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
374
|
-
}
|
|
375
|
-
default: {
|
|
376
|
-
throw new Error(`Unsupported account type: ${account.type}`);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
async function isDeployed(config, chain) {
|
|
381
|
-
const account = getAccountProvider(config);
|
|
382
|
-
if (account.type === 'eoa') {
|
|
383
|
-
return true;
|
|
384
|
-
}
|
|
385
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
386
|
-
chain: chain,
|
|
387
|
-
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
388
|
-
});
|
|
389
|
-
const address = getAddress(config);
|
|
390
|
-
const code = await publicClient.getCode({
|
|
391
|
-
address,
|
|
392
|
-
});
|
|
393
|
-
if (!code) {
|
|
394
|
-
return false;
|
|
395
|
-
}
|
|
396
|
-
if (code.startsWith('0xef0100') && code.length === 48) {
|
|
397
|
-
// Defensive check to ensure there's no storage conflict; can be lifted in the future
|
|
398
|
-
throw new error_1.ExistingEip7702AccountsNotSupportedError();
|
|
399
|
-
}
|
|
400
|
-
return (0, viem_1.size)(code) > 0;
|
|
401
|
-
}
|
|
402
|
-
async function deploy(config, chain, params) {
|
|
403
|
-
const account = getAccountProvider(config);
|
|
404
|
-
const deployArgs = getDeployArgs(config);
|
|
405
|
-
if (!deployArgs) {
|
|
406
|
-
throw new error_1.FactoryArgsNotAvailableError();
|
|
407
|
-
}
|
|
408
|
-
if (account.type === 'eoa') {
|
|
409
|
-
return false;
|
|
410
|
-
}
|
|
411
|
-
const deployed = await isDeployed(config, chain);
|
|
412
|
-
if (deployed) {
|
|
413
|
-
return false;
|
|
414
|
-
}
|
|
415
|
-
const intentExecutorInstalled = 'intentExecutorInstalled' in deployArgs
|
|
416
|
-
? deployArgs.intentExecutorInstalled
|
|
417
|
-
: false;
|
|
418
|
-
const asUserOp = config.initData && !intentExecutorInstalled;
|
|
419
|
-
if (asUserOp) {
|
|
420
|
-
await deployWithBundler(chain, config);
|
|
421
|
-
}
|
|
422
|
-
else {
|
|
423
|
-
await deployWithIntent(chain, config, params?.sponsored ?? false);
|
|
424
|
-
}
|
|
425
|
-
if (params?.session) {
|
|
426
|
-
await (0, smart_session_1.enableSmartSession)(chain, config, params.session);
|
|
427
|
-
}
|
|
428
|
-
return true;
|
|
429
|
-
}
|
|
430
|
-
// Installs the missing modules
|
|
431
|
-
// Checks if the provided modules are already installed
|
|
432
|
-
// Useful for existing (already deployed) accounts
|
|
433
|
-
async function setup(config, chain) {
|
|
434
|
-
const account = getAccountProvider(config);
|
|
435
|
-
if (account.type === 'eoa') {
|
|
436
|
-
return false;
|
|
437
|
-
}
|
|
438
|
-
const modules = (0, modules_1.getSetup)(config);
|
|
439
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
440
|
-
chain,
|
|
441
|
-
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
442
|
-
});
|
|
443
|
-
const address = getAddress(config);
|
|
444
|
-
const allModules = [
|
|
445
|
-
...modules.validators,
|
|
446
|
-
...modules.executors,
|
|
447
|
-
...modules.fallbacks,
|
|
448
|
-
...modules.hooks,
|
|
449
|
-
];
|
|
450
|
-
// Check if the modules are already installed
|
|
451
|
-
const installedResults = await publicClient.multicall({
|
|
452
|
-
contracts: allModules.map((module) => ({
|
|
453
|
-
address: address,
|
|
454
|
-
abi: [
|
|
455
|
-
{
|
|
456
|
-
type: 'function',
|
|
457
|
-
name: 'isModuleInstalled',
|
|
458
|
-
inputs: [
|
|
459
|
-
{ type: 'uint256', name: 'moduleTypeId' },
|
|
460
|
-
{ type: 'address', name: 'module' },
|
|
461
|
-
{ type: 'bytes', name: 'additionalContext' },
|
|
462
|
-
],
|
|
463
|
-
outputs: [{ type: 'bool', name: 'isInstalled' }],
|
|
464
|
-
stateMutability: 'view',
|
|
465
|
-
},
|
|
466
|
-
],
|
|
467
|
-
functionName: 'isModuleInstalled',
|
|
468
|
-
args: [module.type, module.address, module.additionalContext],
|
|
469
|
-
})),
|
|
470
|
-
});
|
|
471
|
-
const isInstalled = installedResults.map((result) => result.result);
|
|
472
|
-
const modulesToInstall = allModules.filter((_, index) => !isInstalled[index]);
|
|
473
|
-
if (modulesToInstall.length === 0) {
|
|
474
|
-
// Nothing to install
|
|
475
|
-
return false;
|
|
476
|
-
}
|
|
477
|
-
const calls = [];
|
|
478
|
-
for (const module of modulesToInstall) {
|
|
479
|
-
calls.push(...getModuleInstallationCalls(config, module));
|
|
480
|
-
}
|
|
481
|
-
// Select the transaction infra layer based on the intent executor status
|
|
482
|
-
const intentExecutor = (0, modules_1.getIntentExecutor)(config);
|
|
483
|
-
const hasIntentExecutor = modulesToInstall.every((module) => module.address !== intentExecutor.address);
|
|
484
|
-
let result;
|
|
485
|
-
if (hasIntentExecutor) {
|
|
486
|
-
result = await (0, execution_1.sendTransactionInternal)(config, [chain], chain, {
|
|
487
|
-
callInputs: calls,
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
else {
|
|
491
|
-
result = await (0, execution_1.sendUserOperationInternal)(config, chain, calls);
|
|
492
|
-
}
|
|
493
|
-
await (0, execution_1.waitForExecution)(config, result, true);
|
|
494
|
-
return true;
|
|
495
|
-
}
|
|
496
|
-
async function deployWithIntent(chain, config, sponsored) {
|
|
497
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
498
|
-
chain,
|
|
499
|
-
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
500
|
-
});
|
|
501
|
-
const address = getAddress(config);
|
|
502
|
-
const code = await publicClient.getCode({ address });
|
|
503
|
-
if (code) {
|
|
504
|
-
// Already deployed
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
const result = await (0, execution_1.sendTransaction)(config, {
|
|
508
|
-
sourceChains: [chain],
|
|
509
|
-
targetChain: chain,
|
|
510
|
-
calls: [],
|
|
511
|
-
sponsored,
|
|
512
|
-
});
|
|
513
|
-
await (0, execution_1.waitForExecution)(config, result, true);
|
|
514
|
-
}
|
|
515
|
-
async function deployWithBundler(chain, config) {
|
|
516
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
517
|
-
chain,
|
|
518
|
-
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
519
|
-
});
|
|
520
|
-
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
521
|
-
const smartAccount = await getSmartAccount(config, publicClient, chain);
|
|
522
|
-
const deployArgs = getDeployArgs(config);
|
|
523
|
-
if (!deployArgs) {
|
|
524
|
-
throw new error_1.FactoryArgsNotAvailableError();
|
|
525
|
-
}
|
|
526
|
-
const { factory, factoryData } = deployArgs;
|
|
527
|
-
const opHash = await bundlerClient.sendUserOperation({
|
|
528
|
-
account: smartAccount,
|
|
529
|
-
factory,
|
|
530
|
-
factoryData,
|
|
531
|
-
calls: [
|
|
532
|
-
{
|
|
533
|
-
to: viem_1.zeroAddress,
|
|
534
|
-
value: 0n,
|
|
535
|
-
data: '0x',
|
|
536
|
-
},
|
|
537
|
-
],
|
|
538
|
-
});
|
|
539
|
-
await bundlerClient.waitForUserOperationReceipt({
|
|
540
|
-
hash: opHash,
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
async function toErc6492Signature(config, signature, chain) {
|
|
544
|
-
const deployed = await isDeployed(config, chain);
|
|
545
|
-
if (deployed) {
|
|
546
|
-
return signature;
|
|
547
|
-
}
|
|
548
|
-
// Account is not deployed, use ERC-6492
|
|
549
|
-
const initCode = getInitCode(config);
|
|
550
|
-
if (!initCode) {
|
|
551
|
-
throw new error_1.FactoryArgsNotAvailableError();
|
|
552
|
-
}
|
|
553
|
-
const deployArgs = getDeployArgs(config);
|
|
554
|
-
if (!deployArgs) {
|
|
555
|
-
throw new error_1.FactoryArgsNotAvailableError();
|
|
556
|
-
}
|
|
557
|
-
const { factory, factoryData } = deployArgs;
|
|
558
|
-
const magicBytes = '0x6492649264926492649264926492649264926492649264926492649264926492';
|
|
559
|
-
return (0, viem_1.concat)([
|
|
560
|
-
(0, viem_1.encodeAbiParameters)([
|
|
561
|
-
{ name: 'create2Factory', type: 'address' },
|
|
562
|
-
{ name: 'factoryCalldata', type: 'bytes' },
|
|
563
|
-
{ name: 'originalERC1271Signature', type: 'bytes' },
|
|
564
|
-
], [factory, factoryData, signature]),
|
|
565
|
-
magicBytes,
|
|
566
|
-
]);
|
|
567
|
-
}
|
|
568
|
-
async function getSmartAccount(config, client, chain) {
|
|
569
|
-
// EOA accounts don't need smart account functionality
|
|
570
|
-
if (config.account?.type === 'eoa') {
|
|
571
|
-
throw new Error('getSmartAccount is not supported for EOA accounts');
|
|
572
|
-
}
|
|
573
|
-
if (!config.owners) {
|
|
574
|
-
throw new error_1.OwnersFieldRequiredError();
|
|
575
|
-
}
|
|
576
|
-
const account = getAccountProvider(config);
|
|
577
|
-
const address = getAddress(config);
|
|
578
|
-
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
579
|
-
const signers = (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
580
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
581
|
-
switch (account.type) {
|
|
582
|
-
case 'safe': {
|
|
583
|
-
return (0, safe_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
584
|
-
}
|
|
585
|
-
case 'nexus': {
|
|
586
|
-
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
587
|
-
return (0, nexus_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn, defaultValidatorAddress);
|
|
588
|
-
}
|
|
589
|
-
case 'kernel': {
|
|
590
|
-
return (0, kernel_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
591
|
-
}
|
|
592
|
-
case 'startale': {
|
|
593
|
-
return (0, startale_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
async function getSmartSessionSmartAccount(config, client, chain, session, enableData) {
|
|
598
|
-
const address = getAddress(config);
|
|
599
|
-
const smartSessionValidator = (0, validators_1.getSmartSessionValidator)(config);
|
|
600
|
-
if (!smartSessionValidator) {
|
|
601
|
-
throw new error_1.SmartSessionsNotEnabledError();
|
|
602
|
-
}
|
|
603
|
-
const signers = {
|
|
604
|
-
type: 'session',
|
|
605
|
-
session,
|
|
606
|
-
enableData: enableData || undefined,
|
|
607
|
-
};
|
|
608
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
609
|
-
const account = getAccountProvider(config);
|
|
610
|
-
switch (account.type) {
|
|
611
|
-
case 'safe': {
|
|
612
|
-
return (0, safe_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
613
|
-
}
|
|
614
|
-
case 'nexus': {
|
|
615
|
-
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
616
|
-
return (0, nexus_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn, defaultValidatorAddress);
|
|
617
|
-
}
|
|
618
|
-
case 'kernel': {
|
|
619
|
-
return (0, kernel_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
620
|
-
}
|
|
621
|
-
case 'passport': {
|
|
622
|
-
return (0, passport_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
623
|
-
}
|
|
624
|
-
case 'startale': {
|
|
625
|
-
return (0, startale_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
630
|
-
const address = getAddress(config);
|
|
631
|
-
const accounts = guardians.type === 'ecdsa' ? guardians.accounts : [];
|
|
632
|
-
const socialRecoveryValidator = (0, core_1.getSocialRecoveryValidator)(accounts);
|
|
633
|
-
if (!socialRecoveryValidator) {
|
|
634
|
-
throw new Error('Social recovery is not available');
|
|
635
|
-
}
|
|
636
|
-
const signers = {
|
|
637
|
-
type: 'guardians',
|
|
638
|
-
guardians: accounts,
|
|
639
|
-
};
|
|
640
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
641
|
-
const account = getAccountProvider(config);
|
|
642
|
-
switch (account.type) {
|
|
643
|
-
case 'safe': {
|
|
644
|
-
return (0, safe_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
645
|
-
}
|
|
646
|
-
case 'nexus': {
|
|
647
|
-
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
648
|
-
return (0, nexus_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn, defaultValidatorAddress);
|
|
649
|
-
}
|
|
650
|
-
case 'kernel': {
|
|
651
|
-
return (0, kernel_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
652
|
-
}
|
|
653
|
-
case 'startale': {
|
|
654
|
-
return (0, startale_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
function is7702(config) {
|
|
659
|
-
const account = getAccountProvider(config);
|
|
660
|
-
return account.type !== 'eoa' && config.eoa !== undefined;
|
|
661
|
-
}
|
|
662
|
-
function getAccountProvider(config) {
|
|
663
|
-
if (config.account) {
|
|
664
|
-
return config.account;
|
|
665
|
-
}
|
|
666
|
-
return {
|
|
667
|
-
type: 'nexus',
|
|
668
|
-
};
|
|
669
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../accounts/index.test.ts"],"names":[],"mappings":""}
|