@gearbox-protocol/sdk 8.1.1 → 8.1.3
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.
|
@@ -18,7 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var AccountOpener_exports = {};
|
|
20
20
|
__export(AccountOpener_exports, {
|
|
21
|
-
AccountOpener: () => AccountOpener
|
|
21
|
+
AccountOpener: () => AccountOpener,
|
|
22
|
+
OpenTxRevertedError: () => OpenTxRevertedError
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(AccountOpener_exports);
|
|
24
25
|
var import_viem = require("viem");
|
|
@@ -28,6 +29,13 @@ var import_v300 = require("../abi/v300.js");
|
|
|
28
29
|
var import_sdk = require("../sdk/index.js");
|
|
29
30
|
var import_abi = require("./abi.js");
|
|
30
31
|
var import_createAnvilClient = require("./createAnvilClient.js");
|
|
32
|
+
class OpenTxRevertedError extends import_viem.BaseError {
|
|
33
|
+
txHash;
|
|
34
|
+
constructor(txHash) {
|
|
35
|
+
super("open credit account tx reverted");
|
|
36
|
+
this.txHash = txHash;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
31
39
|
class AccountOpener extends import_sdk.SDKConstruct {
|
|
32
40
|
#service;
|
|
33
41
|
#anvil;
|
|
@@ -92,10 +100,18 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
92
100
|
const result = await this.#openAccount(target, i + 1, targets.length);
|
|
93
101
|
results.push(result);
|
|
94
102
|
success += result.account ? 1 : 0;
|
|
103
|
+
if (result.error) {
|
|
104
|
+
this.#logger?.error(
|
|
105
|
+
`failed to open account #${i + 1}/${targets.length}: ${result.error}`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
95
108
|
} catch (e) {
|
|
109
|
+
this.#logger?.error(
|
|
110
|
+
`failed to open account #${i + 1}/${targets.length}: ${e}`
|
|
111
|
+
);
|
|
96
112
|
results.push({
|
|
97
113
|
input: target,
|
|
98
|
-
error:
|
|
114
|
+
error: e
|
|
99
115
|
});
|
|
100
116
|
}
|
|
101
117
|
}
|
|
@@ -123,7 +139,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
123
139
|
} catch (e) {
|
|
124
140
|
return {
|
|
125
141
|
input,
|
|
126
|
-
error:
|
|
142
|
+
error: e,
|
|
127
143
|
rawTx: tx
|
|
128
144
|
};
|
|
129
145
|
}
|
|
@@ -131,7 +147,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
131
147
|
if (receipt.status === "reverted") {
|
|
132
148
|
return {
|
|
133
149
|
input,
|
|
134
|
-
error:
|
|
150
|
+
error: new OpenTxRevertedError(hash),
|
|
135
151
|
txHash: hash,
|
|
136
152
|
rawTx: tx
|
|
137
153
|
};
|
|
@@ -590,5 +606,6 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
590
606
|
}
|
|
591
607
|
// Annotate the CommonJS export names for ESM import in node:
|
|
592
608
|
0 && (module.exports = {
|
|
593
|
-
AccountOpener
|
|
609
|
+
AccountOpener,
|
|
610
|
+
OpenTxRevertedError
|
|
594
611
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAddress, parseEther, parseEventLogs } from "viem";
|
|
1
|
+
import { BaseError, isAddress, parseEther, parseEventLogs } from "viem";
|
|
2
2
|
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
|
|
3
3
|
import { ierc20Abi } from "../abi/iERC20.js";
|
|
4
4
|
import { iCreditFacadeV300Abi, iPoolV300Abi } from "../abi/v300.js";
|
|
@@ -14,6 +14,13 @@ import {
|
|
|
14
14
|
} from "../sdk/index.js";
|
|
15
15
|
import { iDegenNftv2Abi } from "./abi.js";
|
|
16
16
|
import { createAnvilClient } from "./createAnvilClient.js";
|
|
17
|
+
class OpenTxRevertedError extends BaseError {
|
|
18
|
+
txHash;
|
|
19
|
+
constructor(txHash) {
|
|
20
|
+
super("open credit account tx reverted");
|
|
21
|
+
this.txHash = txHash;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
17
24
|
class AccountOpener extends SDKConstruct {
|
|
18
25
|
#service;
|
|
19
26
|
#anvil;
|
|
@@ -78,10 +85,18 @@ class AccountOpener extends SDKConstruct {
|
|
|
78
85
|
const result = await this.#openAccount(target, i + 1, targets.length);
|
|
79
86
|
results.push(result);
|
|
80
87
|
success += result.account ? 1 : 0;
|
|
88
|
+
if (result.error) {
|
|
89
|
+
this.#logger?.error(
|
|
90
|
+
`failed to open account #${i + 1}/${targets.length}: ${result.error}`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
81
93
|
} catch (e) {
|
|
94
|
+
this.#logger?.error(
|
|
95
|
+
`failed to open account #${i + 1}/${targets.length}: ${e}`
|
|
96
|
+
);
|
|
82
97
|
results.push({
|
|
83
98
|
input: target,
|
|
84
|
-
error:
|
|
99
|
+
error: e
|
|
85
100
|
});
|
|
86
101
|
}
|
|
87
102
|
}
|
|
@@ -109,7 +124,7 @@ class AccountOpener extends SDKConstruct {
|
|
|
109
124
|
} catch (e) {
|
|
110
125
|
return {
|
|
111
126
|
input,
|
|
112
|
-
error:
|
|
127
|
+
error: e,
|
|
113
128
|
rawTx: tx
|
|
114
129
|
};
|
|
115
130
|
}
|
|
@@ -117,7 +132,7 @@ class AccountOpener extends SDKConstruct {
|
|
|
117
132
|
if (receipt.status === "reverted") {
|
|
118
133
|
return {
|
|
119
134
|
input,
|
|
120
|
-
error:
|
|
135
|
+
error: new OpenTxRevertedError(hash),
|
|
121
136
|
txHash: hash,
|
|
122
137
|
rawTx: tx
|
|
123
138
|
};
|
|
@@ -575,5 +590,6 @@ class AccountOpener extends SDKConstruct {
|
|
|
575
590
|
}
|
|
576
591
|
}
|
|
577
592
|
export {
|
|
578
|
-
AccountOpener
|
|
593
|
+
AccountOpener,
|
|
594
|
+
OpenTxRevertedError
|
|
579
595
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type { Address, PrivateKeyAccount } from "viem";
|
|
1
|
+
import type { Address, Hash, PrivateKeyAccount } from "viem";
|
|
2
|
+
import { BaseError } from "viem";
|
|
2
3
|
import type { CreditAccountData, CreditAccountsService, RawTx } from "../sdk/index.js";
|
|
3
4
|
import { SDKConstruct } from "../sdk/index.js";
|
|
5
|
+
export declare class OpenTxRevertedError extends BaseError {
|
|
6
|
+
readonly txHash: Hash;
|
|
7
|
+
constructor(txHash: Hash);
|
|
8
|
+
}
|
|
4
9
|
export interface AccountOpenerOptions {
|
|
5
10
|
faucet?: Address;
|
|
6
11
|
borrower?: PrivateKeyAccount;
|
|
@@ -25,7 +30,7 @@ export interface TargetAccount {
|
|
|
25
30
|
}
|
|
26
31
|
export interface OpenAccountResult {
|
|
27
32
|
input: TargetAccount;
|
|
28
|
-
error?:
|
|
33
|
+
error?: Error;
|
|
29
34
|
txHash?: string;
|
|
30
35
|
rawTx?: RawTx;
|
|
31
36
|
account?: CreditAccountData;
|