@dfns/lib-ethersjs6 0.1.0 → 0.1.2-rc.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 +3 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -6,24 +6,22 @@ const ethers_1 = require("ethers");
|
|
|
6
6
|
const sleep = (interval = 0) => new Promise((resolve) => setTimeout(resolve, interval));
|
|
7
7
|
class DfnsWallet extends ethers_1.AbstractSigner {
|
|
8
8
|
constructor(options, provider) {
|
|
9
|
-
var _a, _b;
|
|
10
9
|
super(provider);
|
|
11
10
|
this.options = {
|
|
12
11
|
...options,
|
|
13
|
-
maxRetries:
|
|
14
|
-
retryInterval:
|
|
12
|
+
maxRetries: options.maxRetries ?? 3,
|
|
13
|
+
retryInterval: options.retryInterval ?? 1000,
|
|
15
14
|
};
|
|
16
15
|
}
|
|
17
16
|
connect(provider) {
|
|
18
17
|
return new DfnsWallet(this.options, provider);
|
|
19
18
|
}
|
|
20
19
|
async getAddress() {
|
|
21
|
-
var _a, _b;
|
|
22
20
|
if (!this.address) {
|
|
23
21
|
const { walletId, dfnsClient } = this.options;
|
|
24
22
|
const res = await dfnsClient.wallets.getWallet({ walletId });
|
|
25
23
|
if (!res.signingKey || res.signingKey.scheme !== Wallets_1.KeyScheme.ECDSA || res.signingKey.curve !== Wallets_1.KeyCurve.secp256k1) {
|
|
26
|
-
throw new Error(`wallet ${walletId} has incompatible scheme (${
|
|
24
|
+
throw new Error(`wallet ${walletId} has incompatible scheme (${res.signingKey?.scheme}) or curve (${res.signingKey?.curve})`);
|
|
27
25
|
}
|
|
28
26
|
if (res.address) {
|
|
29
27
|
this.address = (0, ethers_1.getAddress)(res.address);
|