@toruslabs/ethereum-controllers 8.7.1 → 8.8.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/ethereumControllers.umd.min.js.LICENSE.txt +9 -0
- package/dist/lib.cjs/AccountAbstraction/smartAccounts/MetamaskSmartAccount.js +7 -10
- package/dist/lib.cjs/Keyring/KeyringController.js +1 -1
- package/dist/lib.cjs/types/utils/interfaces.d.ts +2 -1
- package/dist/lib.cjs/utils/constants.js +1 -1
- package/dist/lib.esm/AccountAbstraction/smartAccounts/MetamaskSmartAccount.js +7 -10
- package/dist/lib.esm/Keyring/KeyringController.js +3 -3
- package/dist/lib.esm/utils/constants.js +2 -2
- package/package.json +8 -7
|
@@ -33,3 +33,12 @@
|
|
|
33
33
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
34
34
|
|
|
35
35
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @license
|
|
39
|
+
* Lodash <https://lodash.com/>
|
|
40
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
41
|
+
* Released under MIT license <https://lodash.com/license>
|
|
42
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
43
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
44
|
+
*/
|
|
@@ -5,9 +5,6 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
|
5
5
|
var delegationToolkit = require('@metamask/delegation-toolkit');
|
|
6
6
|
var constants = require('../../utils/constants.js');
|
|
7
7
|
|
|
8
|
-
function isImplementationHybrid(implementation) {
|
|
9
|
-
return implementation === delegationToolkit.Implementation.Hybrid;
|
|
10
|
-
}
|
|
11
8
|
class MetamaskSmartAccount {
|
|
12
9
|
constructor(options) {
|
|
13
10
|
_defineProperty(this, "name", constants.SMART_ACCOUNT.METAMASK);
|
|
@@ -23,9 +20,7 @@ class MetamaskSmartAccount {
|
|
|
23
20
|
};
|
|
24
21
|
const multiSigSignatory = [{
|
|
25
22
|
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) || [])
|
|
27
|
-
walletClient
|
|
28
|
-
}))];
|
|
23
|
+
}, ...(((_this$options3 = this.options) === null || _this$options3 === void 0 || (_this$options3 = _this$options3.multiSigParams) === null || _this$options3 === void 0 ? void 0 : _this$options3.additionalSignerWalletClients) || [])];
|
|
29
24
|
const [eoaAddress] = await input.walletClient.getAddresses();
|
|
30
25
|
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
26
|
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))];
|
|
@@ -34,20 +29,22 @@ class MetamaskSmartAccount {
|
|
|
34
29
|
deploySalt: (_this$options$deployS = (_this$options0 = this.options) === null || _this$options0 === void 0 ? void 0 : _this$options0.deploySalt) !== null && _this$options$deployS !== void 0 ? _this$options$deployS : "0x0"
|
|
35
30
|
};
|
|
36
31
|
const implementation = (_this$options$impleme = (_this$options1 = this.options) === null || _this$options1 === void 0 ? void 0 : _this$options1.implementation) !== null && _this$options$impleme !== void 0 ? _this$options$impleme : delegationToolkit.Implementation.Hybrid;
|
|
37
|
-
if (
|
|
32
|
+
if (implementation === delegationToolkit.Implementation.Hybrid) {
|
|
38
33
|
const params = _objectSpread(_objectSpread({}, baseParams), {}, {
|
|
39
34
|
implementation,
|
|
40
35
|
deployParams: hybridDeployParams,
|
|
41
|
-
|
|
36
|
+
signer: hybridSignatory
|
|
42
37
|
});
|
|
43
38
|
return delegationToolkit.toMetaMaskSmartAccount(params);
|
|
44
|
-
} else {
|
|
39
|
+
} else if (implementation === delegationToolkit.Implementation.MultiSig) {
|
|
45
40
|
const params = _objectSpread(_objectSpread({}, baseParams), {}, {
|
|
46
41
|
implementation,
|
|
47
42
|
deployParams: multiSigDeployParams,
|
|
48
|
-
|
|
43
|
+
signer: multiSigSignatory
|
|
49
44
|
});
|
|
50
45
|
return delegationToolkit.toMetaMaskSmartAccount(params);
|
|
46
|
+
} else {
|
|
47
|
+
throw new Error(`MetamaskSmartAccount - unsupported implementation: ${implementation}`);
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
50
|
}
|
|
@@ -62,7 +62,7 @@ class KeyringController extends baseControllers.BaseKeyringController {
|
|
|
62
62
|
async signMessage(data, address) {
|
|
63
63
|
const wallet = this._getWalletForAccount(address);
|
|
64
64
|
const privKey = this.getBufferPrivateKey(wallet.privateKey);
|
|
65
|
-
const messageSig =
|
|
65
|
+
const messageSig = baseControllers.ecsignature(Buffer.from(util.stripHexPrefix(data), "hex"), privKey);
|
|
66
66
|
const sig = baseControllers.concatSig(Buffer.from(util.bigIntToBytes(messageSig.v)), Buffer.from(messageSig.r), Buffer.from(messageSig.s));
|
|
67
67
|
return sig;
|
|
68
68
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Implementation,
|
|
1
|
+
import { Implementation, toMetaMaskSmartAccount } from "@metamask/delegation-toolkit";
|
|
2
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";
|
|
3
3
|
import { JRPCRequest, Json } from "@web3auth/auth";
|
|
4
4
|
import { MutexInterface } from "async-mutex";
|
|
@@ -435,6 +435,7 @@ export type PaymasterConfig = Omit<Parameters<typeof createPaymasterClient>[0],
|
|
|
435
435
|
export type BiconomySmartAccountConfig = Pick<ToBiconomySmartAccountParameters, "entryPoint" | "ecdsaModuleAddress" | "factoryAddress">;
|
|
436
436
|
export type KernelSmartAccountParameters = Parameters<typeof toEcdsaKernelSmartAccount>[0];
|
|
437
437
|
export type KernelSmartAccountConfig = Omit<KernelSmartAccountParameters, "owners" | "client" | "address" | "nonceKey" | "index">;
|
|
438
|
+
export type ToMetaMaskSmartAccountParameters<TImplementation extends Implementation> = Parameters<typeof toMetaMaskSmartAccount<TImplementation>>[0];
|
|
438
439
|
export type MetamaskSmartAccountConfig<TImplementation extends Implementation = Implementation.Hybrid> = Omit<ToMetaMaskSmartAccountParameters<TImplementation>, "client" | "signatory" | "deployParams" | "implementation"> & {
|
|
439
440
|
implementation?: TImplementation;
|
|
440
441
|
hybridParams?: {
|
|
@@ -29,7 +29,7 @@ const ARBITRUM_TESTNET_CHAIN_ID = "0x66eee";
|
|
|
29
29
|
const OPTIMISM_TESTNET_CHAIN_ID = "0xaa37dc";
|
|
30
30
|
const BASE_TESTNET_CHAIN_ID = "0x14a34";
|
|
31
31
|
const LINEA_SEPOLIA_CHAIN_ID = "0xe705";
|
|
32
|
-
const INFURA_KEY =
|
|
32
|
+
const INFURA_KEY = baseControllers.getEnvVariable("VITE_APP_INFURA_PROJECT_KEY");
|
|
33
33
|
const SUPPORTED_NETWORKS = {
|
|
34
34
|
[MAINNET_CHAIN_ID]: {
|
|
35
35
|
chainNamespace: baseControllers.CHAIN_NAMESPACES.EIP155,
|
|
@@ -3,9 +3,6 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
3
3
|
import { Implementation, toMetaMaskSmartAccount } from '@metamask/delegation-toolkit';
|
|
4
4
|
import { SMART_ACCOUNT } from '../../utils/constants.js';
|
|
5
5
|
|
|
6
|
-
function isImplementationHybrid(implementation) {
|
|
7
|
-
return implementation === Implementation.Hybrid;
|
|
8
|
-
}
|
|
9
6
|
class MetamaskSmartAccount {
|
|
10
7
|
constructor(options) {
|
|
11
8
|
_defineProperty(this, "name", SMART_ACCOUNT.METAMASK);
|
|
@@ -21,9 +18,7 @@ class MetamaskSmartAccount {
|
|
|
21
18
|
};
|
|
22
19
|
const multiSigSignatory = [{
|
|
23
20
|
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) || [])
|
|
25
|
-
walletClient
|
|
26
|
-
}))];
|
|
21
|
+
}, ...(((_this$options3 = this.options) === null || _this$options3 === void 0 || (_this$options3 = _this$options3.multiSigParams) === null || _this$options3 === void 0 ? void 0 : _this$options3.additionalSignerWalletClients) || [])];
|
|
27
22
|
const [eoaAddress] = await input.walletClient.getAddresses();
|
|
28
23
|
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
24
|
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,20 +27,22 @@ class MetamaskSmartAccount {
|
|
|
32
27
|
deploySalt: (_this$options$deployS = (_this$options0 = this.options) === null || _this$options0 === void 0 ? void 0 : _this$options0.deploySalt) !== null && _this$options$deployS !== void 0 ? _this$options$deployS : "0x0"
|
|
33
28
|
};
|
|
34
29
|
const implementation = (_this$options$impleme = (_this$options1 = this.options) === null || _this$options1 === void 0 ? void 0 : _this$options1.implementation) !== null && _this$options$impleme !== void 0 ? _this$options$impleme : Implementation.Hybrid;
|
|
35
|
-
if (
|
|
30
|
+
if (implementation === Implementation.Hybrid) {
|
|
36
31
|
const params = _objectSpread(_objectSpread({}, baseParams), {}, {
|
|
37
32
|
implementation,
|
|
38
33
|
deployParams: hybridDeployParams,
|
|
39
|
-
|
|
34
|
+
signer: hybridSignatory
|
|
40
35
|
});
|
|
41
36
|
return toMetaMaskSmartAccount(params);
|
|
42
|
-
} else {
|
|
37
|
+
} else if (implementation === Implementation.MultiSig) {
|
|
43
38
|
const params = _objectSpread(_objectSpread({}, baseParams), {}, {
|
|
44
39
|
implementation,
|
|
45
40
|
deployParams: multiSigDeployParams,
|
|
46
|
-
|
|
41
|
+
signer: multiSigSignatory
|
|
47
42
|
});
|
|
48
43
|
return toMetaMaskSmartAccount(params);
|
|
44
|
+
} else {
|
|
45
|
+
throw new Error(`MetamaskSmartAccount - unsupported implementation: ${implementation}`);
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { addHexPrefix, bytesToHex, privateToPublic, toChecksumAddress, privateToAddress, stripHexPrefix,
|
|
2
|
-
import { BaseKeyringController, concatSig } from '@toruslabs/base-controllers';
|
|
1
|
+
import { addHexPrefix, bytesToHex, privateToPublic, toChecksumAddress, privateToAddress, stripHexPrefix, bigIntToBytes, isHexString } from '@ethereumjs/util';
|
|
2
|
+
import { BaseKeyringController, ecsignature, concatSig } from '@toruslabs/base-controllers';
|
|
3
3
|
import { SigningKey, hashMessage, TypedDataEncoder } from 'ethers';
|
|
4
4
|
|
|
5
5
|
class KeyringController extends BaseKeyringController {
|
|
@@ -61,7 +61,7 @@ class KeyringController extends BaseKeyringController {
|
|
|
61
61
|
async signMessage(data, address) {
|
|
62
62
|
const wallet = this._getWalletForAccount(address);
|
|
63
63
|
const privKey = this.getBufferPrivateKey(wallet.privateKey);
|
|
64
|
-
const messageSig =
|
|
64
|
+
const messageSig = ecsignature(Buffer.from(stripHexPrefix(data), "hex"), privKey);
|
|
65
65
|
const sig = concatSig(Buffer.from(bigIntToBytes(messageSig.v)), Buffer.from(messageSig.r), Buffer.from(messageSig.s));
|
|
66
66
|
return sig;
|
|
67
67
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CHAIN_NAMESPACES } from '@toruslabs/base-controllers';
|
|
1
|
+
import { CHAIN_NAMESPACES, getEnvVariable } from '@toruslabs/base-controllers';
|
|
2
2
|
|
|
3
3
|
const LOCALHOST = "localhost";
|
|
4
4
|
const CONTRACT_TYPE_ETH = "eth";
|
|
@@ -27,7 +27,7 @@ const ARBITRUM_TESTNET_CHAIN_ID = "0x66eee";
|
|
|
27
27
|
const OPTIMISM_TESTNET_CHAIN_ID = "0xaa37dc";
|
|
28
28
|
const BASE_TESTNET_CHAIN_ID = "0x14a34";
|
|
29
29
|
const LINEA_SEPOLIA_CHAIN_ID = "0xe705";
|
|
30
|
-
const INFURA_KEY =
|
|
30
|
+
const INFURA_KEY = getEnvVariable("VITE_APP_INFURA_PROJECT_KEY");
|
|
31
31
|
const SUPPORTED_NETWORKS = {
|
|
32
32
|
[MAINNET_CHAIN_ID]: {
|
|
33
33
|
chainNamespace: CHAIN_NAMESPACES.EIP155,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toruslabs/ethereum-controllers",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.8.1",
|
|
4
4
|
"homepage": "https://github.com/torusresearch/controllers#readme",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -19,21 +19,22 @@
|
|
|
19
19
|
"test": "vitest run --config test/configs/browsers.config.mts --coverage"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@ethereumjs/util": "^
|
|
23
|
-
"@metamask/delegation-toolkit": "~0.
|
|
24
|
-
"@toruslabs/base-controllers": "^8.
|
|
22
|
+
"@ethereumjs/util": "^10.0.0",
|
|
23
|
+
"@metamask/delegation-toolkit": "~0.13.0",
|
|
24
|
+
"@toruslabs/base-controllers": "^8.8.1",
|
|
25
25
|
"@toruslabs/http-helpers": "^8.1.1",
|
|
26
|
-
"@web3auth/auth": "^10.
|
|
26
|
+
"@web3auth/auth": "^10.6.0",
|
|
27
27
|
"async-mutex": "^0.5.0",
|
|
28
28
|
"bignumber.js": "^9.3.1",
|
|
29
29
|
"bn.js": "^5.2.2",
|
|
30
30
|
"deepmerge": "^4.3.1",
|
|
31
|
+
"ethereum-cryptography": "^3.2.0",
|
|
31
32
|
"ethers": "^6.15.0",
|
|
32
33
|
"fast-json-patch": "^3.1.1",
|
|
33
34
|
"fast-safe-stringify": "^2.1.1",
|
|
34
35
|
"jsonschema": "^1.5.0",
|
|
35
36
|
"loglevel": "^1.9.2",
|
|
36
|
-
"permissionless": "^0.2.
|
|
37
|
+
"permissionless": "^0.2.57"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"@babel/runtime": "7.x",
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"publishConfig": {
|
|
64
65
|
"access": "public"
|
|
65
66
|
},
|
|
66
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "68e00670b533d44d1d14c559e9f1a0391186e598",
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@typechain/ethers-v6": "^0.5.1",
|
|
69
70
|
"typechain": "^8.3.2"
|