@rabby-wallet/eth-simple-keyring 5.1.0-beta.0 → 5.1.0-beta.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/index.js +18 -30
- package/package.json +4 -3
package/index.js
CHANGED
|
@@ -35,34 +35,18 @@ class SimpleKeyring extends EventEmitter {
|
|
|
35
35
|
super();
|
|
36
36
|
this.type = type;
|
|
37
37
|
this.wallets = [];
|
|
38
|
-
this.accounts = [];
|
|
39
38
|
this.deserialize(opts);
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
serialize() {
|
|
43
|
-
return Promise.resolve(
|
|
44
|
-
|
|
42
|
+
return Promise.resolve(
|
|
43
|
+
this.wallets.map((w) =>
|
|
45
44
|
ethUtil.stripHexPrefix(ethUtil.bytesToHex(w.privateKey)),
|
|
46
45
|
),
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
deserialize(options = []) {
|
|
52
|
-
// legacy private key import
|
|
53
|
-
if (Array.isArray(options)) {
|
|
54
|
-
this.deserializePrivateKeys(options);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const { privateKeys, accounts } = options;
|
|
59
|
-
if (privateKeys) {
|
|
60
|
-
this.deserializePrivateKeys(privateKeys);
|
|
61
|
-
}
|
|
62
|
-
this.accounts = accounts || [];
|
|
46
|
+
);
|
|
63
47
|
}
|
|
64
48
|
|
|
65
|
-
|
|
49
|
+
deserialize(privateKeys = []) {
|
|
66
50
|
return new Promise((resolve, reject) => {
|
|
67
51
|
try {
|
|
68
52
|
this.wallets = privateKeys.map((hexPrivateKey) => {
|
|
@@ -75,7 +59,7 @@ class SimpleKeyring extends EventEmitter {
|
|
|
75
59
|
return { privateKey, publicKey };
|
|
76
60
|
});
|
|
77
61
|
} catch (e) {
|
|
78
|
-
reject(
|
|
62
|
+
reject(new Error('invalid private key'));
|
|
79
63
|
}
|
|
80
64
|
resolve();
|
|
81
65
|
});
|
|
@@ -94,21 +78,25 @@ class SimpleKeyring extends EventEmitter {
|
|
|
94
78
|
const hexWallets = newWallets.map(({ publicKey }) =>
|
|
95
79
|
add0x(ethUtil.bytesToHex(ethUtil.publicToAddress(publicKey))),
|
|
96
80
|
);
|
|
97
|
-
this.accounts = this.accounts.concat(hexWallets);
|
|
98
81
|
return Promise.resolve(hexWallets);
|
|
99
82
|
}
|
|
100
83
|
|
|
101
84
|
getAccounts() {
|
|
102
|
-
|
|
103
|
-
|
|
85
|
+
return Promise.resolve(
|
|
86
|
+
this.wallets.map(({ publicKey }) => {
|
|
104
87
|
return add0x(ethUtil.bytesToHex(ethUtil.publicToAddress(publicKey)));
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return Promise.resolve(accounts);
|
|
109
|
-
}
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
110
91
|
|
|
111
|
-
|
|
92
|
+
signEip7702Authorization(address, authorization, opts = {}) {
|
|
93
|
+
const privKey = ethUtil.addHexPrefix(this.getPrivateKeyFor(address, opts));
|
|
94
|
+
return Promise.resolve(
|
|
95
|
+
sigUtil.signEIP7702Authorization({
|
|
96
|
+
privateKey: privKey,
|
|
97
|
+
authorization,
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
112
100
|
}
|
|
113
101
|
|
|
114
102
|
// tx is an instance of the ethereumjs-transaction class.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rabby-wallet/eth-simple-keyring",
|
|
3
|
-
"version": "5.1.0-beta.
|
|
3
|
+
"version": "5.1.0-beta.1",
|
|
4
4
|
"description": "A simple standard interface for a series of Ethereum private keys.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ethereum",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@ethereumjs/util": "^9.0.0",
|
|
34
|
-
"@metamask/eth-sig-util": "
|
|
34
|
+
"@metamask/eth-sig-util": "8.2.0",
|
|
35
35
|
"@metamask/utils": "^8.1.0",
|
|
36
36
|
"chai": "^4.3.4",
|
|
37
37
|
"eth-sig-util": "^3.0.1",
|
|
@@ -68,5 +68,6 @@
|
|
|
68
68
|
"secp256k1": true,
|
|
69
69
|
"@lavamoat/preinstall-always-fail": false
|
|
70
70
|
}
|
|
71
|
-
}
|
|
71
|
+
},
|
|
72
|
+
"packageManager": "yarn@1.22.22"
|
|
72
73
|
}
|