@toruslabs/ethereum-controllers 8.2.0 → 8.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ethereumControllers.umd.min.js +1 -1
- package/dist/lib.cjs/AccountAbstraction/AccountAbstractionController.js +8 -1
- package/dist/lib.cjs/AccountAbstraction/smartAccounts/BiconomySmartAccount.js +1 -1
- package/dist/lib.cjs/AccountAbstraction/smartAccounts/KernelSmartAccount.js +1 -1
- package/dist/lib.cjs/AccountAbstraction/smartAccounts/MetamaskSmartAccount.js +54 -0
- package/dist/lib.cjs/AccountAbstraction/smartAccounts/NexusSmartAccount.js +1 -1
- package/dist/lib.cjs/AccountAbstraction/smartAccounts/SafeSmartAccount.js +1 -1
- package/dist/lib.cjs/AccountAbstraction/smartAccounts/TrustSmartAccount.js +1 -1
- package/dist/lib.cjs/index.js +2 -0
- package/dist/lib.cjs/types/AccountAbstraction/smartAccounts/BiconomySmartAccount.d.ts +2 -2
- package/dist/lib.cjs/types/AccountAbstraction/smartAccounts/KernelSmartAccount.d.ts +2 -2
- package/dist/lib.cjs/types/AccountAbstraction/smartAccounts/LightSmartAccount.d.ts +2 -2
- package/dist/lib.cjs/types/AccountAbstraction/smartAccounts/MetamaskSmartAccount.d.ts +13 -0
- package/dist/lib.cjs/types/AccountAbstraction/smartAccounts/NexusSmartAccount.d.ts +2 -2
- package/dist/lib.cjs/types/AccountAbstraction/smartAccounts/SafeSmartAccount.d.ts +2 -2
- package/dist/lib.cjs/types/AccountAbstraction/smartAccounts/SimpleSmartAccount.d.ts +2 -2
- package/dist/lib.cjs/types/AccountAbstraction/smartAccounts/TrustSmartAccount.d.ts +2 -2
- package/dist/lib.cjs/types/AccountAbstraction/smartAccounts/index.d.ts +1 -0
- package/dist/lib.cjs/types/utils/constants.d.ts +1 -0
- package/dist/lib.cjs/types/utils/helpers.d.ts +1 -1
- package/dist/lib.cjs/types/utils/interfaces.d.ts +19 -4
- package/dist/lib.cjs/utils/constants.js +2 -1
- package/dist/lib.esm/AccountAbstraction/AccountAbstractionController.js +10 -2
- package/dist/lib.esm/AccountAbstraction/smartAccounts/BiconomySmartAccount.js +1 -1
- package/dist/lib.esm/AccountAbstraction/smartAccounts/KernelSmartAccount.js +1 -1
- package/dist/lib.esm/AccountAbstraction/smartAccounts/MetamaskSmartAccount.js +52 -0
- package/dist/lib.esm/AccountAbstraction/smartAccounts/NexusSmartAccount.js +1 -1
- package/dist/lib.esm/AccountAbstraction/smartAccounts/SafeSmartAccount.js +1 -1
- package/dist/lib.esm/AccountAbstraction/smartAccounts/TrustSmartAccount.js +1 -1
- package/dist/lib.esm/index.js +1 -0
- package/dist/lib.esm/utils/constants.js +2 -1
- package/package.json +8 -7
|
@@ -98,12 +98,19 @@ class AccountAbstractionController extends baseControllers.BaseController {
|
|
|
98
98
|
chain,
|
|
99
99
|
transport: viem.http(providerConfig.rpcTarget)
|
|
100
100
|
});
|
|
101
|
+
// viem wallet client using json-rpc account from eoaProvider
|
|
101
102
|
const aaEngine = new auth.JRPCEngine();
|
|
102
103
|
aaEngine.push(eoaInterceptorMiddleware(eoaAddress));
|
|
103
104
|
aaEngine.push(eoaProviderAsMiddleware(eoaProvider));
|
|
104
105
|
const provider = auth.providerFromEngine(aaEngine);
|
|
106
|
+
// need to hoist the account address https://viem.sh/docs/clients/wallet#optional-hoist-the-account
|
|
107
|
+
const eoaWalletClient = viem.createWalletClient({
|
|
108
|
+
account: eoaAddress,
|
|
109
|
+
chain,
|
|
110
|
+
transport: viem.custom(provider)
|
|
111
|
+
});
|
|
105
112
|
this._smartAccount = await this.config.smartAccountInit.getSmartAccount({
|
|
106
|
-
|
|
113
|
+
walletClient: eoaWalletClient,
|
|
107
114
|
client: this._publicClient
|
|
108
115
|
});
|
|
109
116
|
if (this.config.paymasterConfig) {
|
|
@@ -20,7 +20,7 @@ class BiconomySmartAccount {
|
|
|
20
20
|
version: ((_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2 = _this$options2.entryPoint) === null || _this$options2 === void 0 ? void 0 : _this$options2.version) || "0.6"
|
|
21
21
|
}
|
|
22
22
|
}, params), {}, {
|
|
23
|
-
owners: [params.
|
|
23
|
+
owners: [params.walletClient],
|
|
24
24
|
client: params.client
|
|
25
25
|
}));
|
|
26
26
|
}
|
|
@@ -13,7 +13,7 @@ class KernelSmartAccount {
|
|
|
13
13
|
}
|
|
14
14
|
async getSmartAccount(params) {
|
|
15
15
|
return accounts.toEcdsaKernelSmartAccount(_objectSpread(_objectSpread(_objectSpread({}, this.options || {}), params), {}, {
|
|
16
|
-
owners: [params.
|
|
16
|
+
owners: [params.walletClient],
|
|
17
17
|
client: params.client
|
|
18
18
|
}));
|
|
19
19
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
|
+
var delegationToolkit = require('@metamask/delegation-toolkit');
|
|
6
|
+
var constants = require('../../utils/constants.js');
|
|
7
|
+
|
|
8
|
+
function isImplementationHybrid(implementation) {
|
|
9
|
+
return implementation === delegationToolkit.Implementation.Hybrid;
|
|
10
|
+
}
|
|
11
|
+
class MetamaskSmartAccount {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
_defineProperty(this, "name", constants.SMART_ACCOUNT.METAMASK);
|
|
14
|
+
_defineProperty(this, "options", void 0);
|
|
15
|
+
this.options = options;
|
|
16
|
+
}
|
|
17
|
+
async getSmartAccount(input) {
|
|
18
|
+
var _this$options, _this$options2, _this$options3, _this$options4, _this$options5, _this$options6, _this$options7, _this$options$multiSi, _this$options8, _this$options9, _this$options$deployS;
|
|
19
|
+
const hybridSignatory = {
|
|
20
|
+
walletClient: input.walletClient,
|
|
21
|
+
webAuthnAccount: (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.hybridParams) === null || _this$options === void 0 ? void 0 : _this$options.webAuthnAccount,
|
|
22
|
+
keyId: (_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2 = _this$options2.hybridParams) === null || _this$options2 === void 0 ? void 0 : _this$options2.keyId
|
|
23
|
+
};
|
|
24
|
+
const multiSigSignatory = [{
|
|
25
|
+
walletClient: input.walletClient
|
|
26
|
+
}, ...(((_this$options3 = this.options) === null || _this$options3 === void 0 || (_this$options3 = _this$options3.multiSigParams) === null || _this$options3 === void 0 ? void 0 : _this$options3.additionalSignerWalletClients) || []).map(walletClient => ({
|
|
27
|
+
walletClient
|
|
28
|
+
}))];
|
|
29
|
+
const [eoaAddress] = await input.walletClient.getAddresses();
|
|
30
|
+
const hybridDeployParams = [eoaAddress, [...(((_this$options4 = this.options) === null || _this$options4 === void 0 || (_this$options4 = _this$options4.hybridParams) === null || _this$options4 === void 0 ? void 0 : _this$options4.p256KeyIds) || [])], [...(((_this$options5 = this.options) === null || _this$options5 === void 0 || (_this$options5 = _this$options5.hybridParams) === null || _this$options5 === void 0 ? void 0 : _this$options5.p256XValues) || [])], [...(((_this$options6 = this.options) === null || _this$options6 === void 0 || (_this$options6 = _this$options6.hybridParams) === null || _this$options6 === void 0 ? void 0 : _this$options6.p256YValues) || [])]];
|
|
31
|
+
const multiSigDeployParams = [[eoaAddress, ...(((_this$options7 = this.options) === null || _this$options7 === void 0 || (_this$options7 = _this$options7.multiSigParams) === null || _this$options7 === void 0 ? void 0 : _this$options7.additionalSignerAddresses) || [])], (_this$options$multiSi = (_this$options8 = this.options) === null || _this$options8 === void 0 || (_this$options8 = _this$options8.multiSigParams) === null || _this$options8 === void 0 ? void 0 : _this$options8.threshold) !== null && _this$options$multiSi !== void 0 ? _this$options$multiSi : BigInt(1 + (((_this$options9 = this.options) === null || _this$options9 === void 0 || (_this$options9 = _this$options9.multiSigParams) === null || _this$options9 === void 0 || (_this$options9 = _this$options9.additionalSignerWalletClients) === null || _this$options9 === void 0 ? void 0 : _this$options9.length) || 0))];
|
|
32
|
+
const baseParams = {
|
|
33
|
+
client: input.client,
|
|
34
|
+
deploySalt: (_this$options$deployS = this.options.deploySalt) !== null && _this$options$deployS !== void 0 ? _this$options$deployS : "0x0"
|
|
35
|
+
};
|
|
36
|
+
if (isImplementationHybrid(this.options.implementation)) {
|
|
37
|
+
const params = _objectSpread(_objectSpread({}, baseParams), {}, {
|
|
38
|
+
implementation: this.options.implementation,
|
|
39
|
+
deployParams: hybridDeployParams,
|
|
40
|
+
signatory: hybridSignatory
|
|
41
|
+
});
|
|
42
|
+
return delegationToolkit.toMetaMaskSmartAccount(params);
|
|
43
|
+
} else {
|
|
44
|
+
const params = _objectSpread(_objectSpread({}, baseParams), {}, {
|
|
45
|
+
implementation: this.options.implementation,
|
|
46
|
+
deployParams: multiSigDeployParams,
|
|
47
|
+
signatory: multiSigSignatory
|
|
48
|
+
});
|
|
49
|
+
return delegationToolkit.toMetaMaskSmartAccount(params);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.MetamaskSmartAccount = MetamaskSmartAccount;
|
|
@@ -21,7 +21,7 @@ class NexusSmartAccount {
|
|
|
21
21
|
},
|
|
22
22
|
version: ((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.version) || "1.0.0"
|
|
23
23
|
}, params), {}, {
|
|
24
|
-
owners: [params.
|
|
24
|
+
owners: [params.walletClient],
|
|
25
25
|
client: params.client
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
@@ -21,7 +21,7 @@ class SafeSmartAccount {
|
|
|
21
21
|
},
|
|
22
22
|
version: ((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.version) || "1.4.1"
|
|
23
23
|
}, params), {}, {
|
|
24
|
-
owners: [params.
|
|
24
|
+
owners: [params.walletClient],
|
|
25
25
|
client: params.client
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
@@ -20,7 +20,7 @@ class TrustSmartAccount {
|
|
|
20
20
|
version: ((_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2 = _this$options2.entryPoint) === null || _this$options2 === void 0 ? void 0 : _this$options2.version) || "0.6"
|
|
21
21
|
}
|
|
22
22
|
}, params), {}, {
|
|
23
|
-
owner: params.
|
|
23
|
+
owner: params.walletClient,
|
|
24
24
|
client: params.client
|
|
25
25
|
}));
|
|
26
26
|
}
|
package/dist/lib.cjs/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var AccountTrackerController = require('./Account/AccountTrackerController.js');
|
|
|
4
4
|
var AccountAbstractionController = require('./AccountAbstraction/AccountAbstractionController.js');
|
|
5
5
|
var BiconomySmartAccount = require('./AccountAbstraction/smartAccounts/BiconomySmartAccount.js');
|
|
6
6
|
var KernelSmartAccount = require('./AccountAbstraction/smartAccounts/KernelSmartAccount.js');
|
|
7
|
+
var MetamaskSmartAccount = require('./AccountAbstraction/smartAccounts/MetamaskSmartAccount.js');
|
|
7
8
|
var NexusSmartAccount = require('./AccountAbstraction/smartAccounts/NexusSmartAccount.js');
|
|
8
9
|
var SafeSmartAccount = require('./AccountAbstraction/smartAccounts/SafeSmartAccount.js');
|
|
9
10
|
var TrustSmartAccount = require('./AccountAbstraction/smartAccounts/TrustSmartAccount.js');
|
|
@@ -46,6 +47,7 @@ exports.eoaInterceptorMiddleware = AccountAbstractionController.eoaInterceptorMi
|
|
|
46
47
|
exports.eoaProviderAsMiddleware = AccountAbstractionController.eoaProviderAsMiddleware;
|
|
47
48
|
exports.BiconomySmartAccount = BiconomySmartAccount.BiconomySmartAccount;
|
|
48
49
|
exports.KernelSmartAccount = KernelSmartAccount.KernelSmartAccount;
|
|
50
|
+
exports.MetamaskSmartAccount = MetamaskSmartAccount.MetamaskSmartAccount;
|
|
49
51
|
exports.NexusSmartAccount = NexusSmartAccount.NexusSmartAccount;
|
|
50
52
|
exports.SafeSmartAccount = SafeSmartAccount.SafeSmartAccount;
|
|
51
53
|
exports.TrustSmartAccount = TrustSmartAccount.TrustSmartAccount;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToBiconomySmartAccountParameters } from "permissionless/accounts";
|
|
2
|
-
import { Client,
|
|
2
|
+
import { Client, WalletClient } from "viem";
|
|
3
3
|
import { SmartAccount } from "viem/account-abstraction";
|
|
4
4
|
import { BiconomySmartAccountConfig, ISmartAccount } from "../../utils/interfaces";
|
|
5
5
|
export declare class BiconomySmartAccount implements ISmartAccount {
|
|
@@ -7,7 +7,7 @@ export declare class BiconomySmartAccount implements ISmartAccount {
|
|
|
7
7
|
private options;
|
|
8
8
|
constructor(options?: BiconomySmartAccountConfig);
|
|
9
9
|
getSmartAccount(params: {
|
|
10
|
-
|
|
10
|
+
walletClient: WalletClient;
|
|
11
11
|
client: Client;
|
|
12
12
|
} & Pick<ToBiconomySmartAccountParameters, "index" | "nonceKey" | "address">): Promise<SmartAccount>;
|
|
13
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client,
|
|
1
|
+
import { Client, WalletClient } from "viem";
|
|
2
2
|
import { SmartAccount } from "viem/account-abstraction";
|
|
3
3
|
import { ISmartAccount, KernelSmartAccountConfig, KernelSmartAccountParameters } from "../../utils/interfaces";
|
|
4
4
|
export declare class KernelSmartAccount implements ISmartAccount {
|
|
@@ -6,7 +6,7 @@ export declare class KernelSmartAccount implements ISmartAccount {
|
|
|
6
6
|
private options;
|
|
7
7
|
constructor(options?: KernelSmartAccountConfig);
|
|
8
8
|
getSmartAccount(params: {
|
|
9
|
-
|
|
9
|
+
walletClient: WalletClient;
|
|
10
10
|
client: Client;
|
|
11
11
|
} & Pick<KernelSmartAccountParameters, "address" | "nonceKey" | "index">): Promise<SmartAccount>;
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToLightSmartAccountParameters } from "permissionless/accounts";
|
|
2
|
-
import { Client,
|
|
2
|
+
import { Client, WalletClient } from "viem";
|
|
3
3
|
import { SmartAccount } from "viem/account-abstraction";
|
|
4
4
|
import { ISmartAccount, LightSmartAccountConfig } from "../../utils/interfaces";
|
|
5
5
|
export declare class LightSmartAccount implements ISmartAccount {
|
|
@@ -7,7 +7,7 @@ export declare class LightSmartAccount implements ISmartAccount {
|
|
|
7
7
|
private options;
|
|
8
8
|
constructor(options?: LightSmartAccountConfig);
|
|
9
9
|
getSmartAccount(params: {
|
|
10
|
-
|
|
10
|
+
walletClient: WalletClient;
|
|
11
11
|
client: Client;
|
|
12
12
|
} & Pick<ToLightSmartAccountParameters, "address" | "index" | "nonceKey">): Promise<SmartAccount>;
|
|
13
13
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Implementation } from "@metamask/delegation-toolkit";
|
|
2
|
+
import { Client, WalletClient } from "viem";
|
|
3
|
+
import { SmartAccount } from "viem/account-abstraction";
|
|
4
|
+
import { ISmartAccount, MetamaskSmartAccountConfig } from "../../utils/interfaces";
|
|
5
|
+
export declare class MetamaskSmartAccount<TImplementation extends Implementation> implements ISmartAccount {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
private options;
|
|
8
|
+
constructor(options?: MetamaskSmartAccountConfig<TImplementation>);
|
|
9
|
+
getSmartAccount(input: {
|
|
10
|
+
walletClient: WalletClient;
|
|
11
|
+
client: Client;
|
|
12
|
+
}): Promise<SmartAccount>;
|
|
13
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToNexusSmartAccountParameters } from "permissionless/accounts";
|
|
2
|
-
import { Client,
|
|
2
|
+
import { Client, WalletClient } from "viem";
|
|
3
3
|
import { SmartAccount } from "viem/account-abstraction";
|
|
4
4
|
import { ISmartAccount, NexusSmartAccountConfig } from "../../utils/interfaces";
|
|
5
5
|
export declare class NexusSmartAccount implements ISmartAccount {
|
|
@@ -7,7 +7,7 @@ export declare class NexusSmartAccount implements ISmartAccount {
|
|
|
7
7
|
private options;
|
|
8
8
|
constructor(options?: NexusSmartAccountConfig);
|
|
9
9
|
getSmartAccount(params: {
|
|
10
|
-
|
|
10
|
+
walletClient: WalletClient;
|
|
11
11
|
client: Client;
|
|
12
12
|
} & Pick<ToNexusSmartAccountParameters, "index" | "address">): Promise<SmartAccount>;
|
|
13
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client,
|
|
1
|
+
import { Client, WalletClient } from "viem";
|
|
2
2
|
import { SmartAccount } from "viem/account-abstraction";
|
|
3
3
|
import { ISmartAccount, SafeSmartAccountConfig, SafeSmartAccountParameters } from "../../utils/interfaces";
|
|
4
4
|
export declare class SafeSmartAccount implements ISmartAccount {
|
|
@@ -6,7 +6,7 @@ export declare class SafeSmartAccount implements ISmartAccount {
|
|
|
6
6
|
private options;
|
|
7
7
|
constructor(options?: SafeSmartAccountConfig);
|
|
8
8
|
getSmartAccount(params: {
|
|
9
|
-
|
|
9
|
+
walletClient: WalletClient;
|
|
10
10
|
client: Client;
|
|
11
11
|
} & Pick<SafeSmartAccountParameters, "address" | "nonceKey" | "saltNonce" | "validUntil" | "validAfter">): Promise<SmartAccount>;
|
|
12
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client,
|
|
1
|
+
import { Client, WalletClient } from "viem";
|
|
2
2
|
import { SmartAccount } from "viem/account-abstraction";
|
|
3
3
|
import { ISmartAccount, SimpleSmartAccountConfig } from "../../utils/interfaces";
|
|
4
4
|
export declare class SimpleSmartAccount implements ISmartAccount {
|
|
@@ -6,7 +6,7 @@ export declare class SimpleSmartAccount implements ISmartAccount {
|
|
|
6
6
|
private options;
|
|
7
7
|
constructor(options?: SimpleSmartAccountConfig);
|
|
8
8
|
getSmartAccount(params: {
|
|
9
|
-
|
|
9
|
+
walletClient: WalletClient;
|
|
10
10
|
client: Client;
|
|
11
11
|
}): Promise<SmartAccount>;
|
|
12
12
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client,
|
|
1
|
+
import { Client, WalletClient } from "viem";
|
|
2
2
|
import { SmartAccount } from "viem/account-abstraction";
|
|
3
3
|
import { ISmartAccount, TrustSmartAccountConfig, TrustSmartAccountParameters } from "../../utils/interfaces";
|
|
4
4
|
export declare class TrustSmartAccount implements ISmartAccount {
|
|
@@ -6,7 +6,7 @@ export declare class TrustSmartAccount implements ISmartAccount {
|
|
|
6
6
|
private options;
|
|
7
7
|
constructor(options?: TrustSmartAccountConfig);
|
|
8
8
|
getSmartAccount(params: {
|
|
9
|
-
|
|
9
|
+
walletClient: WalletClient;
|
|
10
10
|
client: Client;
|
|
11
11
|
} & Pick<TrustSmartAccountParameters, "address" | "nonceKey" | "index">): Promise<SmartAccount>;
|
|
12
12
|
}
|
|
@@ -25,7 +25,7 @@ export declare const GAS_LIMITS: {
|
|
|
25
25
|
export declare function bnLessThan(a: string | number, b: string | number): boolean;
|
|
26
26
|
export declare const getIpfsEndpoint: (path: string) => string;
|
|
27
27
|
export declare function sanitizeNftMetdataUrl(url: string): string;
|
|
28
|
-
export declare function getChainType(chainId: string): "
|
|
28
|
+
export declare function getChainType(chainId: string): "custom" | "mainnet" | "testnet";
|
|
29
29
|
export declare const addEtherscanTransactions: (params: {
|
|
30
30
|
txn: EtherscanTransaction[];
|
|
31
31
|
lowerCaseSelectedAddress: string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Implementation, ToMetaMaskSmartAccountParameters } from "@metamask/delegation-toolkit";
|
|
1
2
|
import { BASE_TX_EVENT_TYPE, BaseBlockTrackerState, BaseControllerEvents, BaseFormattedTransactionActivity, BaseTokenInfo, BaseTransactionEvents, MESSAGE_EVENTS, MessageStatus, NetworkConfig, NetworkState, PaymentTransaction, PollingBlockTrackerConfig, PopupWhitelabelData, ProviderConfig, TRANSACTION_TYPE, TransactionMeta, TransactionState, TransactionStatus, TX_CONFIRMED_EVENT_TYPE, TX_DROPPED_EVENT_TYPE, TX_EVENTS, TX_FAILED_EVENT_TYPE, TX_WARNING_EVENT_TYPE, User } from "@toruslabs/base-controllers";
|
|
2
3
|
import { JRPCRequest, Json } from "@web3auth/auth";
|
|
3
4
|
import { MutexInterface } from "async-mutex";
|
|
4
5
|
import { AccessList, TypedDataDomain, TypedDataField } from "ethers";
|
|
5
6
|
import { ToBiconomySmartAccountParameters, toEcdsaKernelSmartAccount, ToLightSmartAccountParameters, ToNexusSmartAccountParameters, toSafeSmartAccount, toSimpleSmartAccount, toTrustSmartAccount } from "permissionless/accounts";
|
|
6
|
-
import { Client,
|
|
7
|
-
import { createBundlerClient, createPaymasterClient, SmartAccount, UserOperationReceipt } from "viem/account-abstraction";
|
|
7
|
+
import { Client, Hex, WalletClient } from "viem";
|
|
8
|
+
import { createBundlerClient, createPaymasterClient, SmartAccount, UserOperationReceipt, WebAuthnAccount } from "viem/account-abstraction";
|
|
8
9
|
import { METHOD_TYPES, SMART_ACCOUNT, TRANSACTION_ENVELOPE_TYPES } from "./constants";
|
|
9
10
|
export type CustomTokenInfo = BaseTokenInfo & {
|
|
10
11
|
erc20: boolean;
|
|
@@ -434,6 +435,20 @@ export type PaymasterConfig = Omit<Parameters<typeof createPaymasterClient>[0],
|
|
|
434
435
|
export type BiconomySmartAccountConfig = Pick<ToBiconomySmartAccountParameters, "entryPoint" | "ecdsaModuleAddress" | "factoryAddress">;
|
|
435
436
|
export type KernelSmartAccountParameters = Parameters<typeof toEcdsaKernelSmartAccount>[0];
|
|
436
437
|
export type KernelSmartAccountConfig = Omit<KernelSmartAccountParameters, "owners" | "client" | "address" | "nonceKey" | "index">;
|
|
438
|
+
export type MetamaskSmartAccountConfig<TImplementation extends Implementation> = Omit<ToMetaMaskSmartAccountParameters<TImplementation>, "client" | "signatory" | "deployParams"> & {
|
|
439
|
+
hybridParams?: {
|
|
440
|
+
p256KeyIds?: string[];
|
|
441
|
+
p256XValues?: bigint[];
|
|
442
|
+
p256YValues?: bigint[];
|
|
443
|
+
webAuthnAccount?: WebAuthnAccount;
|
|
444
|
+
keyId?: Hex;
|
|
445
|
+
};
|
|
446
|
+
multiSigParams?: {
|
|
447
|
+
additionalSignerAddresses: Hex[];
|
|
448
|
+
additionalSignerWalletClients: WalletClient[];
|
|
449
|
+
threshold: bigint;
|
|
450
|
+
};
|
|
451
|
+
};
|
|
437
452
|
export type LightSmartAccountConfig = Omit<ToLightSmartAccountParameters, "owner" | "client" | "index" | "address" | "nonceKey">;
|
|
438
453
|
export type NexusSmartAccountConfig = Omit<ToNexusSmartAccountParameters, "owners" | "client" | "index" | "address">;
|
|
439
454
|
export type SafeSmartAccountParameters = Parameters<typeof toSafeSmartAccount>[0];
|
|
@@ -444,12 +459,12 @@ export type TrustSmartAccountParameters = Parameters<typeof toTrustSmartAccount>
|
|
|
444
459
|
export type TrustSmartAccountConfig = Omit<TrustSmartAccountParameters, "owner" | "client" | "address" | "nonceKey" | "index">;
|
|
445
460
|
export interface ISmartAccount {
|
|
446
461
|
getSmartAccount(params: {
|
|
447
|
-
|
|
462
|
+
walletClient: WalletClient;
|
|
448
463
|
client: Client;
|
|
449
464
|
}): Promise<SmartAccount>;
|
|
450
465
|
}
|
|
451
466
|
export type SmartAccountType = (typeof SMART_ACCOUNT)[keyof typeof SMART_ACCOUNT];
|
|
452
|
-
export type SmartAccountConfig = BiconomySmartAccountConfig | KernelSmartAccountConfig | NexusSmartAccountConfig | SafeSmartAccountConfig | TrustSmartAccountConfig
|
|
467
|
+
export type SmartAccountConfig = BiconomySmartAccountConfig | KernelSmartAccountConfig | NexusSmartAccountConfig | SafeSmartAccountConfig | TrustSmartAccountConfig | MetamaskSmartAccountConfig<Implementation>;
|
|
453
468
|
/**
|
|
454
469
|
* @deprecated Use MultiChainAccountAbstractionConfig instead, will be deprecated in v8
|
|
455
470
|
*/
|
|
@@ -334,7 +334,8 @@ const SMART_ACCOUNT = {
|
|
|
334
334
|
// TODO: disabled because of pimlico issues
|
|
335
335
|
LIGHT: "light",
|
|
336
336
|
SIMPLE: "simple",
|
|
337
|
-
NEXUS: "nexus"
|
|
337
|
+
NEXUS: "nexus",
|
|
338
|
+
METAMASK: "metamask"
|
|
338
339
|
};
|
|
339
340
|
|
|
340
341
|
exports.ARBITRUM_MAINNET_CHAIN_ID = ARBITRUM_MAINNET_CHAIN_ID;
|
|
@@ -5,7 +5,7 @@ import { BaseController, TransactionStatus } from '@toruslabs/base-controllers';
|
|
|
5
5
|
import { JRPCEngine, providerFromEngine } from '@web3auth/auth';
|
|
6
6
|
import { isHexString } from 'ethers';
|
|
7
7
|
import log from 'loglevel';
|
|
8
|
-
import { defineChain, createPublicClient, http, createWalletClient, parseEther, toHex } from 'viem';
|
|
8
|
+
import { defineChain, createPublicClient, http, createWalletClient, custom, parseEther, toHex } from 'viem';
|
|
9
9
|
import { createPaymasterClient, createBundlerClient } from 'viem/account-abstraction';
|
|
10
10
|
|
|
11
11
|
const eoaInterceptorMiddleware = eoaAddress => (req, res, next, end) => {
|
|
@@ -96,12 +96,20 @@ class AccountAbstractionController extends BaseController {
|
|
|
96
96
|
chain,
|
|
97
97
|
transport: http(providerConfig.rpcTarget)
|
|
98
98
|
});
|
|
99
|
+
|
|
100
|
+
// viem wallet client using json-rpc account from eoaProvider
|
|
99
101
|
const aaEngine = new JRPCEngine();
|
|
100
102
|
aaEngine.push(eoaInterceptorMiddleware(eoaAddress));
|
|
101
103
|
aaEngine.push(eoaProviderAsMiddleware(eoaProvider));
|
|
102
104
|
const provider = providerFromEngine(aaEngine);
|
|
105
|
+
// need to hoist the account address https://viem.sh/docs/clients/wallet#optional-hoist-the-account
|
|
106
|
+
const eoaWalletClient = createWalletClient({
|
|
107
|
+
account: eoaAddress,
|
|
108
|
+
chain,
|
|
109
|
+
transport: custom(provider)
|
|
110
|
+
});
|
|
103
111
|
this._smartAccount = await this.config.smartAccountInit.getSmartAccount({
|
|
104
|
-
|
|
112
|
+
walletClient: eoaWalletClient,
|
|
105
113
|
client: this._publicClient
|
|
106
114
|
});
|
|
107
115
|
if (this.config.paymasterConfig) {
|
|
@@ -18,7 +18,7 @@ class BiconomySmartAccount {
|
|
|
18
18
|
version: ((_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2 = _this$options2.entryPoint) === null || _this$options2 === void 0 ? void 0 : _this$options2.version) || "0.6"
|
|
19
19
|
}
|
|
20
20
|
}, params), {}, {
|
|
21
|
-
owners: [params.
|
|
21
|
+
owners: [params.walletClient],
|
|
22
22
|
client: params.client
|
|
23
23
|
}));
|
|
24
24
|
}
|
|
@@ -11,7 +11,7 @@ class KernelSmartAccount {
|
|
|
11
11
|
}
|
|
12
12
|
async getSmartAccount(params) {
|
|
13
13
|
return toEcdsaKernelSmartAccount(_objectSpread(_objectSpread(_objectSpread({}, this.options || {}), params), {}, {
|
|
14
|
-
owners: [params.
|
|
14
|
+
owners: [params.walletClient],
|
|
15
15
|
client: params.client
|
|
16
16
|
}));
|
|
17
17
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
+
import { toMetaMaskSmartAccount, Implementation } from '@metamask/delegation-toolkit';
|
|
4
|
+
import { SMART_ACCOUNT } from '../../utils/constants.js';
|
|
5
|
+
|
|
6
|
+
function isImplementationHybrid(implementation) {
|
|
7
|
+
return implementation === Implementation.Hybrid;
|
|
8
|
+
}
|
|
9
|
+
class MetamaskSmartAccount {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
_defineProperty(this, "name", SMART_ACCOUNT.METAMASK);
|
|
12
|
+
_defineProperty(this, "options", void 0);
|
|
13
|
+
this.options = options;
|
|
14
|
+
}
|
|
15
|
+
async getSmartAccount(input) {
|
|
16
|
+
var _this$options, _this$options2, _this$options3, _this$options4, _this$options5, _this$options6, _this$options7, _this$options$multiSi, _this$options8, _this$options9, _this$options$deployS;
|
|
17
|
+
const hybridSignatory = {
|
|
18
|
+
walletClient: input.walletClient,
|
|
19
|
+
webAuthnAccount: (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.hybridParams) === null || _this$options === void 0 ? void 0 : _this$options.webAuthnAccount,
|
|
20
|
+
keyId: (_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2 = _this$options2.hybridParams) === null || _this$options2 === void 0 ? void 0 : _this$options2.keyId
|
|
21
|
+
};
|
|
22
|
+
const multiSigSignatory = [{
|
|
23
|
+
walletClient: input.walletClient
|
|
24
|
+
}, ...(((_this$options3 = this.options) === null || _this$options3 === void 0 || (_this$options3 = _this$options3.multiSigParams) === null || _this$options3 === void 0 ? void 0 : _this$options3.additionalSignerWalletClients) || []).map(walletClient => ({
|
|
25
|
+
walletClient
|
|
26
|
+
}))];
|
|
27
|
+
const [eoaAddress] = await input.walletClient.getAddresses();
|
|
28
|
+
const hybridDeployParams = [eoaAddress, [...(((_this$options4 = this.options) === null || _this$options4 === void 0 || (_this$options4 = _this$options4.hybridParams) === null || _this$options4 === void 0 ? void 0 : _this$options4.p256KeyIds) || [])], [...(((_this$options5 = this.options) === null || _this$options5 === void 0 || (_this$options5 = _this$options5.hybridParams) === null || _this$options5 === void 0 ? void 0 : _this$options5.p256XValues) || [])], [...(((_this$options6 = this.options) === null || _this$options6 === void 0 || (_this$options6 = _this$options6.hybridParams) === null || _this$options6 === void 0 ? void 0 : _this$options6.p256YValues) || [])]];
|
|
29
|
+
const multiSigDeployParams = [[eoaAddress, ...(((_this$options7 = this.options) === null || _this$options7 === void 0 || (_this$options7 = _this$options7.multiSigParams) === null || _this$options7 === void 0 ? void 0 : _this$options7.additionalSignerAddresses) || [])], (_this$options$multiSi = (_this$options8 = this.options) === null || _this$options8 === void 0 || (_this$options8 = _this$options8.multiSigParams) === null || _this$options8 === void 0 ? void 0 : _this$options8.threshold) !== null && _this$options$multiSi !== void 0 ? _this$options$multiSi : BigInt(1 + (((_this$options9 = this.options) === null || _this$options9 === void 0 || (_this$options9 = _this$options9.multiSigParams) === null || _this$options9 === void 0 || (_this$options9 = _this$options9.additionalSignerWalletClients) === null || _this$options9 === void 0 ? void 0 : _this$options9.length) || 0))];
|
|
30
|
+
const baseParams = {
|
|
31
|
+
client: input.client,
|
|
32
|
+
deploySalt: (_this$options$deployS = this.options.deploySalt) !== null && _this$options$deployS !== void 0 ? _this$options$deployS : "0x0"
|
|
33
|
+
};
|
|
34
|
+
if (isImplementationHybrid(this.options.implementation)) {
|
|
35
|
+
const params = _objectSpread(_objectSpread({}, baseParams), {}, {
|
|
36
|
+
implementation: this.options.implementation,
|
|
37
|
+
deployParams: hybridDeployParams,
|
|
38
|
+
signatory: hybridSignatory
|
|
39
|
+
});
|
|
40
|
+
return toMetaMaskSmartAccount(params);
|
|
41
|
+
} else {
|
|
42
|
+
const params = _objectSpread(_objectSpread({}, baseParams), {}, {
|
|
43
|
+
implementation: this.options.implementation,
|
|
44
|
+
deployParams: multiSigDeployParams,
|
|
45
|
+
signatory: multiSigSignatory
|
|
46
|
+
});
|
|
47
|
+
return toMetaMaskSmartAccount(params);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { MetamaskSmartAccount };
|
|
@@ -19,7 +19,7 @@ class NexusSmartAccount {
|
|
|
19
19
|
},
|
|
20
20
|
version: ((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.version) || "1.0.0"
|
|
21
21
|
}, params), {}, {
|
|
22
|
-
owners: [params.
|
|
22
|
+
owners: [params.walletClient],
|
|
23
23
|
client: params.client
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
@@ -19,7 +19,7 @@ class SafeSmartAccount {
|
|
|
19
19
|
},
|
|
20
20
|
version: ((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.version) || "1.4.1"
|
|
21
21
|
}, params), {}, {
|
|
22
|
-
owners: [params.
|
|
22
|
+
owners: [params.walletClient],
|
|
23
23
|
client: params.client
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
@@ -18,7 +18,7 @@ class TrustSmartAccount {
|
|
|
18
18
|
version: ((_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2 = _this$options2.entryPoint) === null || _this$options2 === void 0 ? void 0 : _this$options2.version) || "0.6"
|
|
19
19
|
}
|
|
20
20
|
}, params), {}, {
|
|
21
|
-
owner: params.
|
|
21
|
+
owner: params.walletClient,
|
|
22
22
|
client: params.client
|
|
23
23
|
}));
|
|
24
24
|
}
|
package/dist/lib.esm/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export { addCurrencies, conversionGTE, conversionGreaterThan, conversionLTE, con
|
|
|
32
32
|
export { BNToHex, GAS_LIMITS, addEtherscanTransactions, bnLessThan, formatDate, formatPastTx, formatTime, getChainType, getEthTxStatus, getEtherScanHashLink, getIpfsEndpoint, hexToBn, isAddressByChainId, sanitizeNftMetdataUrl, toChecksumAddressByChainId } from './utils/helpers.js';
|
|
33
33
|
export { BiconomySmartAccount } from './AccountAbstraction/smartAccounts/BiconomySmartAccount.js';
|
|
34
34
|
export { KernelSmartAccount } from './AccountAbstraction/smartAccounts/KernelSmartAccount.js';
|
|
35
|
+
export { MetamaskSmartAccount } from './AccountAbstraction/smartAccounts/MetamaskSmartAccount.js';
|
|
35
36
|
export { NexusSmartAccount } from './AccountAbstraction/smartAccounts/NexusSmartAccount.js';
|
|
36
37
|
export { SafeSmartAccount } from './AccountAbstraction/smartAccounts/SafeSmartAccount.js';
|
|
37
38
|
export { TrustSmartAccount } from './AccountAbstraction/smartAccounts/TrustSmartAccount.js';
|
|
@@ -333,7 +333,8 @@ const SMART_ACCOUNT = {
|
|
|
333
333
|
// TODO: disabled because of pimlico issues
|
|
334
334
|
LIGHT: "light",
|
|
335
335
|
SIMPLE: "simple",
|
|
336
|
-
NEXUS: "nexus"
|
|
336
|
+
NEXUS: "nexus",
|
|
337
|
+
METAMASK: "metamask"
|
|
337
338
|
};
|
|
338
339
|
|
|
339
340
|
export { ARBITRUM_MAINNET_CHAIN_ID, ARBITRUM_TESTNET_CHAIN_ID, AVALANCHE_MAINNET_CHAIN_ID, AVALANCHE_TESTNET_CHAIN_ID, BASE_CHAIN_ID, BASE_TESTNET_CHAIN_ID, BSC_MAINNET_CHAIN_ID, BSC_TESTNET_CHAIN_ID, CELO_MAINNET_CHAIN_ID, CHAIN_ID_TO_GAS_LIMIT_BUFFER_MAP, COINGECKO_PLATFORMS_CHAIN_CODE_MAP, COINGECKO_SUPPORTED_CURRENCIES, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC20, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ETH, ERC1155_INTERFACE_ID, ERC721_ENUMERABLE_INTERFACE_ID, ERC721_INTERFACE_ID, ERC721_METADATA_INTERFACE_ID, GAS_ESTIMATE_TYPES, LINEA_CHAIN_ID, LINEA_SEPOLIA_CHAIN_ID, LOCALHOST, MAINNET_CHAIN_ID, METHOD_TYPES, MM_NFT_API_SUPPORTED_CHAINS, MM_TOKEN_API_SUPPORTED_CHAINS, OLD_ERC721_LIST, OPTIMISM_MAINNET_CHAIN_ID, OPTIMISM_TESTNET_CHAIN_ID, POLYGON_AMOY_CHAIN_ID, POLYGON_CHAIN_ID, SEPOLIA_CHAIN_ID, SMART_ACCOUNT, SUPPORTED_NETWORKS, TEST_CHAINS, TRANSACTION_ENVELOPE_TYPES, XDAI_CHAIN_ID };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toruslabs/ethereum-controllers",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.1",
|
|
4
4
|
"homepage": "https://github.com/torusresearch/controllers#readme",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@ethereumjs/util": "^9.1.0",
|
|
23
|
-
"@
|
|
23
|
+
"@metamask/delegation-toolkit": "^0.9.0",
|
|
24
|
+
"@toruslabs/base-controllers": "^8.3.1",
|
|
24
25
|
"@toruslabs/http-helpers": "^8.1.1",
|
|
25
|
-
"@web3auth/auth": "^10.
|
|
26
|
+
"@web3auth/auth": "^10.4.0",
|
|
26
27
|
"async-mutex": "^0.5.0",
|
|
27
|
-
"bignumber.js": "^9.1
|
|
28
|
+
"bignumber.js": "^9.2.1",
|
|
28
29
|
"bn.js": "^5.2.1",
|
|
29
30
|
"deepmerge": "^4.3.1",
|
|
30
31
|
"ethers": "^6.13.5",
|
|
@@ -32,8 +33,8 @@
|
|
|
32
33
|
"fast-safe-stringify": "^2.1.1",
|
|
33
34
|
"jsonschema": "^1.5.0",
|
|
34
35
|
"loglevel": "^1.9.2",
|
|
35
|
-
"permissionless": "^0.2.
|
|
36
|
-
"viem": "^2.
|
|
36
|
+
"permissionless": "^0.2.41",
|
|
37
|
+
"viem": "^2.26.5"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"@babel/runtime": "7.x"
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
"publishConfig": {
|
|
63
64
|
"access": "public"
|
|
64
65
|
},
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "b07835e1ad17e72684cefd4a007d3f845f14e67b",
|
|
66
67
|
"devDependencies": {
|
|
67
68
|
"@typechain/ethers-v6": "^0.5.1",
|
|
68
69
|
"typechain": "^8.3.2"
|