@pufferfinance/puffer-sdk 1.31.0 → 1.31.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/api/puffer-client-helpers.cjs +1 -1
- package/dist/api/puffer-client-helpers.cjs.map +1 -1
- package/dist/api/puffer-client-helpers.js +42 -42
- package/dist/api/puffer-client-helpers.js.map +1 -1
- package/dist/api/puffer-client.cjs +1 -1
- package/dist/api/puffer-client.js +2 -2
- package/dist/ccip-DLz1DupU.cjs +2 -0
- package/dist/ccip-DLz1DupU.cjs.map +1 -0
- package/dist/ccip-oHxlHOaH.js +158 -0
- package/dist/ccip-oHxlHOaH.js.map +1 -0
- package/dist/chains/constants.cjs +1 -1
- package/dist/chains/constants.d.ts +2 -1
- package/dist/chains/constants.js +1 -1
- package/dist/constants-C-rrOSfg.js +3837 -0
- package/dist/constants-C-rrOSfg.js.map +1 -0
- package/dist/constants-PXB3A4Yl.cjs +38 -0
- package/dist/constants-PXB3A4Yl.cjs.map +1 -0
- package/dist/contracts/addresses.cjs +1 -1
- package/dist/contracts/addresses.js +1 -1
- package/dist/contracts/handlers/carrot-staking-handler.cjs +1 -1
- package/dist/contracts/handlers/carrot-staking-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/carrot-staking-handler.js +2 -2
- package/dist/contracts/handlers/carrot-vesting-handler.cjs +1 -1
- package/dist/contracts/handlers/carrot-vesting-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/carrot-vesting-handler.js +2 -2
- package/dist/contracts/handlers/concrete-vault-handler.cjs +1 -1
- package/dist/contracts/handlers/concrete-vault-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/concrete-vault-handler.js +2 -2
- package/dist/contracts/handlers/distributor-handler.cjs +1 -1
- package/dist/contracts/handlers/distributor-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/distributor-handler.js +2 -2
- package/dist/contracts/handlers/erc20-permit-handler.cjs +1 -1
- package/dist/contracts/handlers/erc20-permit-handler.cjs.map +1 -1
- package/dist/contracts/handlers/erc20-permit-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/erc20-permit-handler.js +3 -3
- package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -1
- package/dist/contracts/handlers/gauge-registry-handler.cjs +1 -1
- package/dist/contracts/handlers/gauge-registry-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/gauge-registry-handler.js +2 -2
- package/dist/contracts/handlers/guardian-module-handler.cjs +1 -1
- package/dist/contracts/handlers/guardian-module-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/guardian-module-handler.js +2 -2
- package/dist/contracts/handlers/institutional-access-manager-handler.cjs +1 -1
- package/dist/contracts/handlers/institutional-access-manager-handler.cjs.map +1 -1
- package/dist/contracts/handlers/institutional-access-manager-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/institutional-access-manager-handler.js +48 -49
- package/dist/contracts/handlers/institutional-access-manager-handler.js.map +1 -1
- package/dist/contracts/handlers/institutional-vault-handler.cjs +1 -1
- package/dist/contracts/handlers/institutional-vault-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/institutional-vault-handler.js +2 -2
- package/dist/contracts/handlers/l1-reward-manager-handler.cjs +1 -1
- package/dist/contracts/handlers/l1-reward-manager-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/l1-reward-manager-handler.js +2 -2
- package/dist/contracts/handlers/l2-reward-manager-handler.cjs +1 -1
- package/dist/contracts/handlers/l2-reward-manager-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/l2-reward-manager-handler.js +2 -2
- package/dist/contracts/handlers/lagoon-vault-handler.cjs +1 -1
- package/dist/contracts/handlers/lagoon-vault-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/lagoon-vault-handler.js +2 -2
- package/dist/contracts/handlers/mtw-carrot-handler.cjs +1 -1
- package/dist/contracts/handlers/mtw-carrot-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/mtw-carrot-handler.js +2 -2
- package/dist/contracts/handlers/non-restaking-withdrawal-credentials-handler.cjs +1 -1
- package/dist/contracts/handlers/non-restaking-withdrawal-credentials-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/non-restaking-withdrawal-credentials-handler.js +2 -2
- package/dist/contracts/handlers/nucleus-accountant-handler.cjs +1 -1
- package/dist/contracts/handlers/nucleus-accountant-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/nucleus-accountant-handler.js +1 -1
- package/dist/contracts/handlers/nucleus-atomic-queue-handler.cjs +1 -1
- package/dist/contracts/handlers/nucleus-atomic-queue-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/nucleus-atomic-queue-handler.js +2 -2
- package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs +1 -1
- package/dist/contracts/handlers/nucleus-boring-vault-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/nucleus-boring-vault-handler.js +2 -2
- package/dist/contracts/handlers/nucleus-teller-handler.cjs +1 -1
- package/dist/contracts/handlers/nucleus-teller-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/nucleus-teller-handler.js +2 -2
- package/dist/contracts/handlers/puf-locker-handler.cjs +1 -1
- package/dist/contracts/handlers/puf-locker-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/puf-locker-handler.js +2 -2
- package/dist/contracts/handlers/puffer-depositor-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-depositor-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/puffer-depositor-handler.js +2 -2
- package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-l2-depositor-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/puffer-l2-depositor-handler.js +2 -2
- package/dist/contracts/handlers/puffer-oracle-v2-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-oracle-v2-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/puffer-oracle-v2-handler.js +2 -2
- package/dist/contracts/handlers/puffer-protocol-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-protocol-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/puffer-protocol-handler.js +2 -2
- package/dist/contracts/handlers/puffer-vault-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-vault-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/puffer-vault-handler.js +2 -2
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs +1 -1
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js +2 -2
- package/dist/contracts/handlers/validator-ticket-handler.cjs +1 -1
- package/dist/contracts/handlers/validator-ticket-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/validator-ticket-handler.js +2 -2
- package/dist/contracts/handlers/vl-puffer-handler.cjs +1 -1
- package/dist/contracts/handlers/vl-puffer-handler.d.ts +1549 -5281
- package/dist/contracts/handlers/vl-puffer-handler.js +2 -2
- package/dist/contracts/tokens.cjs +1 -1
- package/dist/contracts/tokens.js +1 -1
- package/dist/contracts/vaults-addresses.cjs +1 -1
- package/dist/contracts/vaults-addresses.js +1 -1
- package/dist/{getContract-Cgkj3G1g.cjs → getContract-BL-M-dQc.cjs} +2 -2
- package/dist/{getContract-Cgkj3G1g.cjs.map → getContract-BL-M-dQc.cjs.map} +1 -1
- package/dist/{getContract-Dxh0At3n.js → getContract-BVdsHXdp.js} +11 -11
- package/dist/{getContract-Dxh0At3n.js.map → getContract-BVdsHXdp.js.map} +1 -1
- package/dist/http-BtVgpo6v.cjs +5 -0
- package/dist/http-BtVgpo6v.cjs.map +1 -0
- package/dist/{http-Clq2Hoy9.js → http-CJGQ2e7o.js} +1687 -1533
- package/dist/http-CJGQ2e7o.js.map +1 -0
- package/dist/{localBatchGatewayRequest-Dm7yXllz.js → localBatchGatewayRequest-BchhbxQ2.js} +18 -18
- package/dist/{localBatchGatewayRequest-Dm7yXllz.js.map → localBatchGatewayRequest-BchhbxQ2.js.map} +1 -1
- package/dist/{localBatchGatewayRequest-CuvkLo7E.cjs → localBatchGatewayRequest-Bz0YuhIJ.cjs} +2 -2
- package/dist/{localBatchGatewayRequest-CuvkLo7E.cjs.map → localBatchGatewayRequest-Bz0YuhIJ.cjs.map} +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +1 -1
- package/dist/{secp256k1-BbMQ_WWG.js → secp256k1-Bm3EstvG.js} +62 -62
- package/dist/{secp256k1-BbMQ_WWG.js.map → secp256k1-Bm3EstvG.js.map} +1 -1
- package/dist/{secp256k1-DrUar53F.cjs → secp256k1-cRXUqGNw.cjs} +2 -2
- package/dist/{secp256k1-DrUar53F.cjs.map → secp256k1-cRXUqGNw.cjs.map} +1 -1
- package/dist/utils/version.cjs +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/writeContract-D9xqoPDa.js +3527 -0
- package/dist/writeContract-D9xqoPDa.js.map +1 -0
- package/dist/writeContract-Gli_t0c1.cjs +6 -0
- package/dist/writeContract-Gli_t0c1.cjs.map +1 -0
- package/package.json +13 -13
- package/dist/ccip-BTVr5-VZ.js +0 -150
- package/dist/ccip-BTVr5-VZ.js.map +0 -1
- package/dist/ccip-DNgt9tzv.cjs +0 -2
- package/dist/ccip-DNgt9tzv.cjs.map +0 -1
- package/dist/constants-CUYeD71n.js +0 -2491
- package/dist/constants-CUYeD71n.js.map +0 -1
- package/dist/constants-Dhpa19or.cjs +0 -8
- package/dist/constants-Dhpa19or.cjs.map +0 -1
- package/dist/http-C-TIpf-V.cjs +0 -5
- package/dist/http-C-TIpf-V.cjs.map +0 -1
- package/dist/http-Clq2Hoy9.js.map +0 -1
- package/dist/writeContract-Bq8HaVjW.js +0 -4618
- package/dist/writeContract-Bq8HaVjW.js.map +0 -1
- package/dist/writeContract-PoCaxmyT.cjs +0 -36
- package/dist/writeContract-PoCaxmyT.cjs.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { InstitutionalAccessManager as o } from "../abis/mainnet/InstitutionalAccessManager.js";
|
|
2
|
-
import { V as c, s as l, b as d, h, t as u, a as g } from "../../constants-
|
|
3
|
-
import { InvalidContractAddressError as
|
|
4
|
-
import { g as
|
|
5
|
-
|
|
6
|
-
class v {
|
|
2
|
+
import { V as c, s as l, b as d, h, t as u, a as g, c as C } from "../../constants-C-rrOSfg.js";
|
|
3
|
+
import { InvalidContractAddressError as m } from "../../errors/validation-errors.js";
|
|
4
|
+
import { g as b } from "../../getContract-BVdsHXdp.js";
|
|
5
|
+
class x {
|
|
7
6
|
/**
|
|
8
7
|
* Create the handler for the Institutional `AccessManager` contract
|
|
9
8
|
* exposing methods to interact with the contract.
|
|
@@ -14,8 +13,8 @@ class v {
|
|
|
14
13
|
* @param publicClient The public client to use for public
|
|
15
14
|
* interactions.
|
|
16
15
|
*/
|
|
17
|
-
constructor(t, e,
|
|
18
|
-
this.walletClient = e, this.publicClient =
|
|
16
|
+
constructor(t, e, a) {
|
|
17
|
+
this.walletClient = e, this.publicClient = a, this.viemChain = c[t];
|
|
19
18
|
}
|
|
20
19
|
viemChain;
|
|
21
20
|
address;
|
|
@@ -59,14 +58,14 @@ class v {
|
|
|
59
58
|
*/
|
|
60
59
|
getContract() {
|
|
61
60
|
if (!this.address)
|
|
62
|
-
throw new
|
|
61
|
+
throw new m(
|
|
63
62
|
"No address specified for the contract",
|
|
64
63
|
{
|
|
65
64
|
fixMessage: "Set the contract address in the handler by using the setAddress method"
|
|
66
65
|
}
|
|
67
66
|
);
|
|
68
67
|
const t = o, e = { public: this.publicClient, wallet: this.walletClient };
|
|
69
|
-
return
|
|
68
|
+
return b({
|
|
70
69
|
address: this.address,
|
|
71
70
|
abi: t,
|
|
72
71
|
client: e
|
|
@@ -96,13 +95,13 @@ class v {
|
|
|
96
95
|
* @param selector The function selector.
|
|
97
96
|
* @returns Whether the caller can call the target immediately and the delay.
|
|
98
97
|
*/
|
|
99
|
-
async canCall(t, e,
|
|
100
|
-
const [
|
|
98
|
+
async canCall(t, e, a) {
|
|
99
|
+
const [r, s] = await this.getContract().read.canCall([
|
|
101
100
|
t,
|
|
102
101
|
e,
|
|
103
|
-
|
|
102
|
+
a
|
|
104
103
|
]);
|
|
105
|
-
return { canCall:
|
|
104
|
+
return { canCall: r, canCallDelay: s };
|
|
106
105
|
}
|
|
107
106
|
/**
|
|
108
107
|
* Cancel a scheduled operation.
|
|
@@ -112,8 +111,8 @@ class v {
|
|
|
112
111
|
* @param data The operation data.
|
|
113
112
|
* @returns The nonce.
|
|
114
113
|
*/
|
|
115
|
-
cancel(t, e,
|
|
116
|
-
return this.getContract().write.cancel([t, e,
|
|
114
|
+
cancel(t, e, a) {
|
|
115
|
+
return this.getContract().write.cancel([t, e, a], {
|
|
117
116
|
account: this.walletClient.account,
|
|
118
117
|
chain: this.viemChain
|
|
119
118
|
});
|
|
@@ -126,11 +125,11 @@ class v {
|
|
|
126
125
|
* @param value The value to send.
|
|
127
126
|
* @returns The nonce.
|
|
128
127
|
*/
|
|
129
|
-
execute(t, e,
|
|
128
|
+
execute(t, e, a) {
|
|
130
129
|
return this.getContract().write.execute([t, e], {
|
|
131
130
|
account: this.walletClient.account,
|
|
132
131
|
chain: this.viemChain,
|
|
133
|
-
value:
|
|
132
|
+
value: a
|
|
134
133
|
});
|
|
135
134
|
}
|
|
136
135
|
/**
|
|
@@ -142,8 +141,8 @@ class v {
|
|
|
142
141
|
* @returns The access information.
|
|
143
142
|
*/
|
|
144
143
|
async getAccess(t, e) {
|
|
145
|
-
const
|
|
146
|
-
return { since:
|
|
144
|
+
const a = this.processRoleIdOrLabel(t), [r, s, n, i] = await this.getContract().read.getAccess([a, e]);
|
|
145
|
+
return { since: r, currentDelay: s, pendingDelay: n, effect: i };
|
|
147
146
|
}
|
|
148
147
|
/**
|
|
149
148
|
* Get the nonce for an operation ID.
|
|
@@ -223,10 +222,10 @@ class v {
|
|
|
223
222
|
* @param account The account address.
|
|
224
223
|
* @param executionDelay The execution delay.
|
|
225
224
|
*/
|
|
226
|
-
grantRole(t, e,
|
|
227
|
-
const
|
|
225
|
+
grantRole(t, e, a) {
|
|
226
|
+
const r = this.processRoleIdOrLabel(t);
|
|
228
227
|
return this.getContract().write.grantRole(
|
|
229
|
-
[
|
|
228
|
+
[r, e, a],
|
|
230
229
|
{
|
|
231
230
|
account: this.walletClient.account,
|
|
232
231
|
chain: this.viemChain
|
|
@@ -242,11 +241,11 @@ class v {
|
|
|
242
241
|
* @returns Whether the account has the role and the execution delay.
|
|
243
242
|
*/
|
|
244
243
|
async hasRole(t, e) {
|
|
245
|
-
const
|
|
246
|
-
|
|
244
|
+
const a = this.processRoleIdOrLabel(t), [r, s] = await this.getContract().read.hasRole([
|
|
245
|
+
a,
|
|
247
246
|
e
|
|
248
247
|
]);
|
|
249
|
-
return { isMember:
|
|
248
|
+
return { isMember: r, executionDelay: s };
|
|
250
249
|
}
|
|
251
250
|
/**
|
|
252
251
|
* Hash an operation.
|
|
@@ -256,8 +255,8 @@ class v {
|
|
|
256
255
|
* @param data The operation data.
|
|
257
256
|
* @returns The operation hash.
|
|
258
257
|
*/
|
|
259
|
-
hashOperation(t, e,
|
|
260
|
-
return this.getContract().read.hashOperation([t, e,
|
|
258
|
+
hashOperation(t, e, a) {
|
|
259
|
+
return this.getContract().read.hashOperation([t, e, a]);
|
|
261
260
|
}
|
|
262
261
|
/**
|
|
263
262
|
* Check if a target is closed.
|
|
@@ -277,8 +276,8 @@ class v {
|
|
|
277
276
|
* @returns The transaction hash.
|
|
278
277
|
*/
|
|
279
278
|
labelRole(t, e) {
|
|
280
|
-
const
|
|
281
|
-
return this.getContract().write.labelRole([
|
|
279
|
+
const a = this.processRoleIdOrLabel(t);
|
|
280
|
+
return this.getContract().write.labelRole([a, e], {
|
|
282
281
|
account: this.walletClient.account,
|
|
283
282
|
chain: this.viemChain
|
|
284
283
|
});
|
|
@@ -311,8 +310,8 @@ class v {
|
|
|
311
310
|
* @param callerConfirmation The caller confirmation address.
|
|
312
311
|
*/
|
|
313
312
|
renounceRole(t, e) {
|
|
314
|
-
const
|
|
315
|
-
return this.getContract().write.renounceRole([
|
|
313
|
+
const a = this.processRoleIdOrLabel(t);
|
|
314
|
+
return this.getContract().write.renounceRole([a, e], {
|
|
316
315
|
account: this.walletClient.account,
|
|
317
316
|
chain: this.viemChain
|
|
318
317
|
});
|
|
@@ -325,8 +324,8 @@ class v {
|
|
|
325
324
|
* @param account The account address.
|
|
326
325
|
*/
|
|
327
326
|
revokeRole(t, e) {
|
|
328
|
-
const
|
|
329
|
-
return this.getContract().write.revokeRole([
|
|
327
|
+
const a = this.processRoleIdOrLabel(t);
|
|
328
|
+
return this.getContract().write.revokeRole([a, e], {
|
|
330
329
|
account: this.walletClient.account,
|
|
331
330
|
chain: this.viemChain
|
|
332
331
|
});
|
|
@@ -339,8 +338,8 @@ class v {
|
|
|
339
338
|
* @param when The execution time.
|
|
340
339
|
* @returns The operation ID and nonce.
|
|
341
340
|
*/
|
|
342
|
-
schedule(t, e,
|
|
343
|
-
return this.getContract().write.schedule([t, e,
|
|
341
|
+
schedule(t, e, a) {
|
|
342
|
+
return this.getContract().write.schedule([t, e, a], {
|
|
344
343
|
account: this.walletClient.account,
|
|
345
344
|
chain: this.viemChain
|
|
346
345
|
});
|
|
@@ -353,8 +352,8 @@ class v {
|
|
|
353
352
|
* @param newDelay The new delay.
|
|
354
353
|
*/
|
|
355
354
|
setGrantDelay(t, e) {
|
|
356
|
-
const
|
|
357
|
-
return this.getContract().write.setGrantDelay([
|
|
355
|
+
const a = this.processRoleIdOrLabel(t);
|
|
356
|
+
return this.getContract().write.setGrantDelay([a, e], {
|
|
358
357
|
account: this.walletClient.account,
|
|
359
358
|
chain: this.viemChain
|
|
360
359
|
});
|
|
@@ -367,8 +366,8 @@ class v {
|
|
|
367
366
|
* @param admin The admin role ID.
|
|
368
367
|
*/
|
|
369
368
|
setRoleAdmin(t, e) {
|
|
370
|
-
const
|
|
371
|
-
return this.getContract().write.setRoleAdmin([
|
|
369
|
+
const a = this.processRoleIdOrLabel(t);
|
|
370
|
+
return this.getContract().write.setRoleAdmin([a, e], {
|
|
372
371
|
account: this.walletClient.account,
|
|
373
372
|
chain: this.viemChain
|
|
374
373
|
});
|
|
@@ -381,8 +380,8 @@ class v {
|
|
|
381
380
|
* @param guardian The guardian role ID.
|
|
382
381
|
*/
|
|
383
382
|
setRoleGuardian(t, e) {
|
|
384
|
-
const
|
|
385
|
-
return this.getContract().write.setRoleGuardian([
|
|
383
|
+
const a = this.processRoleIdOrLabel(t);
|
|
384
|
+
return this.getContract().write.setRoleGuardian([a, e], {
|
|
386
385
|
account: this.walletClient.account,
|
|
387
386
|
chain: this.viemChain
|
|
388
387
|
});
|
|
@@ -419,10 +418,10 @@ class v {
|
|
|
419
418
|
* @param roleIdOrLabel The role ID or role label generated with
|
|
420
419
|
* `labelToRoleId`.
|
|
421
420
|
*/
|
|
422
|
-
setTargetFunctionRole(t, e,
|
|
423
|
-
const
|
|
421
|
+
setTargetFunctionRole(t, e, a) {
|
|
422
|
+
const r = this.processRoleIdOrLabel(a);
|
|
424
423
|
return this.getContract().write.setTargetFunctionRole(
|
|
425
|
-
[t, e,
|
|
424
|
+
[t, e, r],
|
|
426
425
|
{
|
|
427
426
|
account: this.walletClient.account,
|
|
428
427
|
chain: this.viemChain
|
|
@@ -453,8 +452,8 @@ class v {
|
|
|
453
452
|
* @returns The role ID.
|
|
454
453
|
*/
|
|
455
454
|
labelToRoleId(t) {
|
|
456
|
-
const
|
|
457
|
-
return h(
|
|
455
|
+
const a = l(t).reverse(), r = d(a);
|
|
456
|
+
return h(r);
|
|
458
457
|
}
|
|
459
458
|
/**
|
|
460
459
|
* Convert a role ID to a label. Only useful if the `roleId` was
|
|
@@ -464,8 +463,8 @@ class v {
|
|
|
464
463
|
* @returns The label.
|
|
465
464
|
*/
|
|
466
465
|
roleIdToLabel(t) {
|
|
467
|
-
const e = u(t),
|
|
468
|
-
return
|
|
466
|
+
const e = u(t), a = g(e).reverse();
|
|
467
|
+
return C(a);
|
|
469
468
|
}
|
|
470
469
|
/**
|
|
471
470
|
* Get the selector for a function name.
|
|
@@ -494,6 +493,6 @@ class v {
|
|
|
494
493
|
}
|
|
495
494
|
}
|
|
496
495
|
export {
|
|
497
|
-
|
|
496
|
+
x as InstitutionalAccessManagerHandler
|
|
498
497
|
};
|
|
499
498
|
//# sourceMappingURL=institutional-access-manager-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"institutional-access-manager-handler.js","sources":["../../../lib/contracts/handlers/institutional-access-manager-handler.ts"],"sourcesContent":["import {\n Chain as ViemChain,\n WalletClient,\n PublicClient,\n getContract,\n GetContractReturnType,\n Address,\n Hex,\n stringToBytes,\n bytesToHex,\n hexToBigInt,\n toHex,\n toBytes,\n bytesToString,\n} from 'viem';\nimport { InstitutionalAccessManager } from '../abis/mainnet/InstitutionalAccessManager';\nimport { Chain, VIEM_CHAINS } from '../../chains/constants';\nimport { InvalidContractAddressError } from '../../errors/validation-errors';\n\n/**\n * Handler for the `InstitutionalAccessManager` contract exposing methods to\n * interact with the contract.\n */\nexport class InstitutionalAccessManagerHandler {\n private viemChain: ViemChain;\n private address?: Address;\n private selectorsMap: Record<Hex, string> = {\n '0x6056b271':\n 'completeQueuedWithdrawals((address,address,address,uint256,uint32,address[],uint256[])[],bool[])',\n '0x29d85402': 'customExternalCall(address,bytes,uint256)',\n '0x6e553f65': 'deposit(uint256,address)',\n '0x2d2da806': 'depositETH(address)',\n '0xba087652': 'redeem(uint256,address,address)',\n '0xb460af94': 'withdraw(uint256,address,address)',\n '0xa9059cbb': 'transfer(address,uint256)',\n '0x23b872dd': 'transferFrom(address,address,uint256)',\n '0x94bf804d': 'mint(uint256,address)',\n '0x61c17990': 'startRestakingValidators(bytes[],bytes[],bytes32[])',\n '0x3e5e60c6': 'startNonRestakingValidators(bytes[],bytes[],bytes32[])',\n '0x852aa33d': 'queueWithdrawals(uint256)',\n '0xad0cdf3e': 'setValidatorsETH(uint128,uint128)',\n };\n\n /**\n * Create the handler for the Institutional `AccessManager` contract\n * exposing methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n }\n\n /**\n * Set the address of the contract for this handler.\n *\n * @param address The address of the contract.\n * @returns The handler.\n */\n public withAddress(address: Address) {\n this.address = address;\n\n return this;\n }\n\n /**\n * Get the address of the contract for this handler.\n *\n * @returns The address of the contract.\n */\n public getAddress() {\n return this.address;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n if (!this.address) {\n throw new InvalidContractAddressError(\n `No address specified for the contract`,\n {\n fixMessage: `Set the contract address in the handler by using the setAddress method`,\n },\n );\n }\n\n const abi = InstitutionalAccessManager;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({\n address: this.address,\n abi,\n client,\n }) as GetContractReturnType<typeof abi, typeof client, Address>;\n }\n\n /**\n * Get the admin role.\n *\n * @returns The admin role.\n */\n public getAdminRole() {\n return this.getContract().read.ADMIN_ROLE();\n }\n\n /**\n * Get the public role.\n *\n * @returns The public role.\n */\n public getPublicRole() {\n return this.getContract().read.PUBLIC_ROLE();\n }\n\n /**\n * Check if a caller can call a target with a specific selector.\n *\n * @param caller The caller address.\n * @param target The target contract address.\n * @param selector The function selector.\n * @returns Whether the caller can call the target immediately and the delay.\n */\n public async canCall(caller: Address, target: Address, selector: Hex) {\n const [immediate, delay] = await this.getContract().read.canCall([\n caller,\n target,\n selector,\n ]);\n\n return { canCall: immediate, canCallDelay: delay };\n }\n\n /**\n * Cancel a scheduled operation.\n *\n * @param caller The caller address.\n * @param target The target contract address.\n * @param data The operation data.\n * @returns The nonce.\n */\n public cancel(caller: Address, target: Address, data: Hex) {\n return this.getContract().write.cancel([caller, target, data], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Execute a target with data.\n *\n * @param target The target contract address.\n * @param data The data to execute.\n * @param value The value to send.\n * @returns The nonce.\n */\n public execute(target: Address, data: Hex, value?: bigint) {\n return this.getContract().write.execute([target, data], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n value,\n });\n }\n\n /**\n * Get access information for a role and account.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param account The account address.\n * @returns The access information.\n */\n public async getAccess(roleIdOrLabel: bigint | string, account: Address) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n const [since, currentDelay, pendingDelay, effect] =\n await this.getContract().read.getAccess([roleId, account]);\n\n return { since, currentDelay, pendingDelay, effect };\n }\n\n /**\n * Get the nonce for an operation ID.\n *\n * @param id The operation ID.\n * @returns The nonce.\n */\n public getNonce(id: Hex) {\n return this.getContract().read.getNonce([id]);\n }\n\n /**\n * Get the admin role for a role ID.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @returns The admin role ID.\n */\n public getRoleAdmin(roleIdOrLabel: bigint | string) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n return this.getContract().read.getRoleAdmin([roleId]);\n }\n\n /**\n * Get the grant delay for a role ID.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @returns The grant delay.\n */\n public getRoleGrantDelay(roleIdOrLabel: bigint | string) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n return this.getContract().read.getRoleGrantDelay([roleId]);\n }\n\n /**\n * Get the guardian role for a role ID.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @returns The guardian role ID.\n */\n public getRoleGuardian(roleIdOrLabel: bigint | string) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n return this.getContract().read.getRoleGuardian([roleId]);\n }\n\n /**\n * Get the schedule for an operation ID.\n *\n * @param id The operation ID.\n * @returns The schedule time.\n */\n public getSchedule(id: Hex) {\n return this.getContract().read.getSchedule([id]);\n }\n\n /**\n * Get the admin delay for a target.\n *\n * @param target The target contract address.\n * @returns The admin delay.\n */\n public getTargetAdminDelay(target: Address) {\n return this.getContract().read.getTargetAdminDelay([target]);\n }\n\n /**\n * Get the function role for a target and selector.\n *\n * @param target The target contract address.\n * @param selector The function selector.\n * @returns The role ID.\n */\n public getTargetFunctionRole(target: Address, selector: Hex) {\n return this.getContract().read.getTargetFunctionRole([target, selector]);\n }\n\n /**\n * Grant a role to an account.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param account The account address.\n * @param executionDelay The execution delay.\n */\n public grantRole(\n roleIdOrLabel: bigint | string,\n account: Address,\n executionDelay: number,\n ) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.grantRole(\n [roleId, account, executionDelay],\n {\n account: this.walletClient.account!,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Check if an account has a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param account The account address.\n * @returns Whether the account has the role and the execution delay.\n */\n public async hasRole(roleIdOrLabel: bigint | string, account: Address) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n const [isMember, executionDelay] = await this.getContract().read.hasRole([\n roleId,\n account,\n ]);\n\n return { isMember, executionDelay };\n }\n\n /**\n * Hash an operation.\n *\n * @param caller The caller address.\n * @param target The target address.\n * @param data The operation data.\n * @returns The operation hash.\n */\n public hashOperation(caller: Address, target: Address, data: Hex) {\n return this.getContract().read.hashOperation([caller, target, data]);\n }\n\n /**\n * Check if a target is closed.\n *\n * @param target The target contract address.\n * @returns Whether the target is closed.\n */\n public isTargetClosed(target: Address) {\n return this.getContract().read.isTargetClosed([target]);\n }\n\n /**\n * Label a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param label The label.\n * @returns The transaction hash.\n */\n public labelRole(roleIdOrLabel: bigint | string, label: string) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.labelRole([roleId, label], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get the minimum setback.\n *\n * @returns The minimum setback.\n */\n public getMinSetback() {\n return this.getContract().read.minSetback();\n }\n\n /**\n * Execute multiple calls.\n *\n * @param data Array of call data.\n * @returns Array of results.\n */\n public multicall(data: Hex[]) {\n return this.getContract().write.multicall([data], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Renounce a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param callerConfirmation The caller confirmation address.\n */\n public renounceRole(\n roleIdOrLabel: bigint | string,\n callerConfirmation: Address,\n ) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.renounceRole([roleId, callerConfirmation], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Revoke a role from an account.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param account The account address.\n */\n public revokeRole(roleIdOrLabel: bigint | string, account: Address) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.revokeRole([roleId, account], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Schedule an operation.\n *\n * @param target The target contract address.\n * @param data The operation data.\n * @param when The execution time.\n * @returns The operation ID and nonce.\n */\n public schedule(target: Address, data: Hex, when: number) {\n return this.getContract().write.schedule([target, data, when], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the grant delay for a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param newDelay The new delay.\n */\n public setGrantDelay(roleIdOrLabel: bigint | string, newDelay: number) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.setGrantDelay([roleId, newDelay], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the admin role for a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param admin The admin role ID.\n */\n public setRoleAdmin(roleIdOrLabel: bigint | string, admin: bigint) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.setRoleAdmin([roleId, admin], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the guardian role for a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param guardian The guardian role ID.\n */\n public setRoleGuardian(roleIdOrLabel: bigint | string, guardian: bigint) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.setRoleGuardian([roleId, guardian], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the admin delay for a target.\n *\n * @param target The target contract address.\n * @param newDelay The new delay.\n */\n public setTargetAdminDelay(target: Address, newDelay: number) {\n return this.getContract().write.setTargetAdminDelay([target, newDelay], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set whether a target is closed.\n *\n * @param target The target contract address.\n * @param closed Whether the target is closed.\n */\n public setTargetClosed(target: Address, closed: boolean) {\n return this.getContract().write.setTargetClosed([target, closed], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the function role for a target.\n *\n * @param target The target address.\n * @param selectors Array of function selectors.\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n */\n public setTargetFunctionRole(\n target: Address,\n selectors: Hex[],\n roleIdOrLabel: bigint | string,\n ) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.setTargetFunctionRole(\n [target, selectors, roleId],\n {\n account: this.walletClient.account!,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Update the authority for a target.\n *\n * @param target The target address.\n * @param newAuthority The new authority address.\n */\n public updateAuthority(target: Address, newAuthority: Address) {\n return this.getContract().write.updateAuthority([target, newAuthority], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**************************************************/\n /****************** Helper Methods ****************/\n /**************************************************/\n\n /**\n * Convert a label to a role ID. Useful if you want to create a roleId\n * from a label which can then be used to get the label back using\n * `roleIdToLabel`.\n *\n * @param label The label to convert.\n * @returns The role ID.\n */\n public labelToRoleId(label: string) {\n const bytes = stringToBytes(label);\n // Reverse the bytes to make it little-endian.\n const leBytes = bytes.reverse();\n const hex = bytesToHex(leBytes);\n\n return hexToBigInt(hex);\n }\n\n /**\n * Convert a role ID to a label. Only useful if the `roleId` was\n * created using `labelToRoleId`.\n *\n * @param roleId The role ID to convert.\n * @returns The label.\n */\n public roleIdToLabel(roleId: bigint) {\n const hex = toHex(roleId);\n // Reverse the bytes to make it little-endian.\n const leBytes = toBytes(hex).reverse();\n\n return bytesToString(leBytes);\n }\n\n /**\n * Get the selector for a function name.\n *\n * @param functionName The function name.\n * @returns The selector.\n */\n public getSelectorFromFunctionName(functionName: string) {\n return Object.entries(this.selectorsMap).find(([, value]) =>\n value.includes(functionName),\n )?.[0];\n }\n\n /**\n * Get the function name for a selector.\n *\n * @param selector The selector.\n * @returns The function name.\n */\n public getFunctionNameFromSelector(selector: Hex) {\n return Object.entries(this.selectorsMap).find(\n ([key]) => key === selector,\n )?.[1];\n }\n\n private processRoleIdOrLabel(roleIdOrLabel: bigint | string) {\n if (typeof roleIdOrLabel === 'string') {\n return this.labelToRoleId(roleIdOrLabel);\n }\n\n return roleIdOrLabel;\n }\n}\n"],"names":["InstitutionalAccessManagerHandler","chain","walletClient","publicClient","VIEM_CHAINS","address","InvalidContractAddressError","abi","InstitutionalAccessManager","client","getContract","caller","target","selector","immediate","delay","data","value","roleIdOrLabel","account","roleId","since","currentDelay","pendingDelay","effect","id","executionDelay","isMember","label","callerConfirmation","when","newDelay","admin","guardian","closed","selectors","newAuthority","leBytes","stringToBytes","hex","bytesToHex","hexToBigInt","toHex","toBytes","bytesToString","functionName","key"],"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AC3B,OAAO,KAAK;AAAA,IAAA,CACb;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcO,cAAcR,GAAe;AAGlC,UAAMS,IAFQC,EAAcV,CAAK,EAEX,QAAA,GAChBW,IAAMC,EAAWH,CAAO;AAE9B,WAAOI,EAAYF,CAAG;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,cAAcnB,GAAgB;AACnC,UAAMmB,IAAMG,EAAMtB,CAAM,GAElBiB,IAAUM,EAAQJ,CAAG,EAAE,QAAA;AAE7B,WAAOK,EAAcP,CAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,4BAA4BQ,GAAsB;AACvD,WAAO,OAAO,QAAQ,KAAK,YAAY,EAAE;AAAA,MAAK,CAAC,GAAG5B,CAAK,MACrDA,EAAM,SAAS4B,CAAY;AAAA,IAAA,IACzB,CAAC;AAAA,EACP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,4BAA4BhC,GAAe;AAChD,WAAO,OAAO,QAAQ,KAAK,YAAY,EAAE;AAAA,MACvC,CAAC,CAACiC,CAAG,MAAMA,MAAQjC;AAAA,IAAA,IACjB,CAAC;AAAA,EACP;AAAA,EAEQ,qBAAqBK,GAAgC;AAC3D,WAAI,OAAOA,KAAkB,WACpB,KAAK,cAAcA,CAAa,IAGlCA;AAAA,EACT;AACF;"}
|
|
1
|
+
{"version":3,"file":"institutional-access-manager-handler.js","sources":["../../../lib/contracts/handlers/institutional-access-manager-handler.ts"],"sourcesContent":["import {\n Chain as ViemChain,\n WalletClient,\n PublicClient,\n getContract,\n GetContractReturnType,\n Address,\n Hex,\n stringToBytes,\n bytesToHex,\n hexToBigInt,\n toHex,\n toBytes,\n bytesToString,\n} from 'viem';\nimport { InstitutionalAccessManager } from '../abis/mainnet/InstitutionalAccessManager';\nimport { Chain, VIEM_CHAINS } from '../../chains/constants';\nimport { InvalidContractAddressError } from '../../errors/validation-errors';\n\n/**\n * Handler for the `InstitutionalAccessManager` contract exposing methods to\n * interact with the contract.\n */\nexport class InstitutionalAccessManagerHandler {\n private viemChain: ViemChain;\n private address?: Address;\n private selectorsMap: Record<Hex, string> = {\n '0x6056b271':\n 'completeQueuedWithdrawals((address,address,address,uint256,uint32,address[],uint256[])[],bool[])',\n '0x29d85402': 'customExternalCall(address,bytes,uint256)',\n '0x6e553f65': 'deposit(uint256,address)',\n '0x2d2da806': 'depositETH(address)',\n '0xba087652': 'redeem(uint256,address,address)',\n '0xb460af94': 'withdraw(uint256,address,address)',\n '0xa9059cbb': 'transfer(address,uint256)',\n '0x23b872dd': 'transferFrom(address,address,uint256)',\n '0x94bf804d': 'mint(uint256,address)',\n '0x61c17990': 'startRestakingValidators(bytes[],bytes[],bytes32[])',\n '0x3e5e60c6': 'startNonRestakingValidators(bytes[],bytes[],bytes32[])',\n '0x852aa33d': 'queueWithdrawals(uint256)',\n '0xad0cdf3e': 'setValidatorsETH(uint128,uint128)',\n };\n\n /**\n * Create the handler for the Institutional `AccessManager` contract\n * exposing methods to interact with the contract.\n *\n * @param chain Chain to use for the client.\n * @param walletClient The wallet client to use for wallet\n * interactions.\n * @param publicClient The public client to use for public\n * interactions.\n */\n constructor(\n chain: Chain,\n private walletClient: WalletClient,\n private publicClient: PublicClient,\n ) {\n this.viemChain = VIEM_CHAINS[chain];\n }\n\n /**\n * Set the address of the contract for this handler.\n *\n * @param address The address of the contract.\n * @returns The handler.\n */\n public withAddress(address: Address) {\n this.address = address;\n\n return this;\n }\n\n /**\n * Get the address of the contract for this handler.\n *\n * @returns The address of the contract.\n */\n public getAddress() {\n return this.address;\n }\n\n /**\n * Get the contract. This is a method because the typings are complex\n * and lost when trying to make it a member.\n *\n * @returns The viem contract.\n */\n public getContract() {\n if (!this.address) {\n throw new InvalidContractAddressError(\n `No address specified for the contract`,\n {\n fixMessage: `Set the contract address in the handler by using the setAddress method`,\n },\n );\n }\n\n const abi = InstitutionalAccessManager;\n const client = { public: this.publicClient, wallet: this.walletClient };\n\n return getContract({\n address: this.address,\n abi,\n client,\n }) as GetContractReturnType<typeof abi, typeof client, Address>;\n }\n\n /**\n * Get the admin role.\n *\n * @returns The admin role.\n */\n public getAdminRole() {\n return this.getContract().read.ADMIN_ROLE();\n }\n\n /**\n * Get the public role.\n *\n * @returns The public role.\n */\n public getPublicRole() {\n return this.getContract().read.PUBLIC_ROLE();\n }\n\n /**\n * Check if a caller can call a target with a specific selector.\n *\n * @param caller The caller address.\n * @param target The target contract address.\n * @param selector The function selector.\n * @returns Whether the caller can call the target immediately and the delay.\n */\n public async canCall(caller: Address, target: Address, selector: Hex) {\n const [immediate, delay] = await this.getContract().read.canCall([\n caller,\n target,\n selector,\n ]);\n\n return { canCall: immediate, canCallDelay: delay };\n }\n\n /**\n * Cancel a scheduled operation.\n *\n * @param caller The caller address.\n * @param target The target contract address.\n * @param data The operation data.\n * @returns The nonce.\n */\n public cancel(caller: Address, target: Address, data: Hex) {\n return this.getContract().write.cancel([caller, target, data], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Execute a target with data.\n *\n * @param target The target contract address.\n * @param data The data to execute.\n * @param value The value to send.\n * @returns The nonce.\n */\n public execute(target: Address, data: Hex, value?: bigint) {\n return this.getContract().write.execute([target, data], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n value,\n });\n }\n\n /**\n * Get access information for a role and account.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param account The account address.\n * @returns The access information.\n */\n public async getAccess(roleIdOrLabel: bigint | string, account: Address) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n const [since, currentDelay, pendingDelay, effect] =\n await this.getContract().read.getAccess([roleId, account]);\n\n return { since, currentDelay, pendingDelay, effect };\n }\n\n /**\n * Get the nonce for an operation ID.\n *\n * @param id The operation ID.\n * @returns The nonce.\n */\n public getNonce(id: Hex) {\n return this.getContract().read.getNonce([id]);\n }\n\n /**\n * Get the admin role for a role ID.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @returns The admin role ID.\n */\n public getRoleAdmin(roleIdOrLabel: bigint | string) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n return this.getContract().read.getRoleAdmin([roleId]);\n }\n\n /**\n * Get the grant delay for a role ID.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @returns The grant delay.\n */\n public getRoleGrantDelay(roleIdOrLabel: bigint | string) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n return this.getContract().read.getRoleGrantDelay([roleId]);\n }\n\n /**\n * Get the guardian role for a role ID.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @returns The guardian role ID.\n */\n public getRoleGuardian(roleIdOrLabel: bigint | string) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n return this.getContract().read.getRoleGuardian([roleId]);\n }\n\n /**\n * Get the schedule for an operation ID.\n *\n * @param id The operation ID.\n * @returns The schedule time.\n */\n public getSchedule(id: Hex) {\n return this.getContract().read.getSchedule([id]);\n }\n\n /**\n * Get the admin delay for a target.\n *\n * @param target The target contract address.\n * @returns The admin delay.\n */\n public getTargetAdminDelay(target: Address) {\n return this.getContract().read.getTargetAdminDelay([target]);\n }\n\n /**\n * Get the function role for a target and selector.\n *\n * @param target The target contract address.\n * @param selector The function selector.\n * @returns The role ID.\n */\n public getTargetFunctionRole(target: Address, selector: Hex) {\n return this.getContract().read.getTargetFunctionRole([target, selector]);\n }\n\n /**\n * Grant a role to an account.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param account The account address.\n * @param executionDelay The execution delay.\n */\n public grantRole(\n roleIdOrLabel: bigint | string,\n account: Address,\n executionDelay: number,\n ) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.grantRole(\n [roleId, account, executionDelay],\n {\n account: this.walletClient.account!,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Check if an account has a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param account The account address.\n * @returns Whether the account has the role and the execution delay.\n */\n public async hasRole(roleIdOrLabel: bigint | string, account: Address) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n const [isMember, executionDelay] = await this.getContract().read.hasRole([\n roleId,\n account,\n ]);\n\n return { isMember, executionDelay };\n }\n\n /**\n * Hash an operation.\n *\n * @param caller The caller address.\n * @param target The target address.\n * @param data The operation data.\n * @returns The operation hash.\n */\n public hashOperation(caller: Address, target: Address, data: Hex) {\n return this.getContract().read.hashOperation([caller, target, data]);\n }\n\n /**\n * Check if a target is closed.\n *\n * @param target The target contract address.\n * @returns Whether the target is closed.\n */\n public isTargetClosed(target: Address) {\n return this.getContract().read.isTargetClosed([target]);\n }\n\n /**\n * Label a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param label The label.\n * @returns The transaction hash.\n */\n public labelRole(roleIdOrLabel: bigint | string, label: string) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.labelRole([roleId, label], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Get the minimum setback.\n *\n * @returns The minimum setback.\n */\n public getMinSetback() {\n return this.getContract().read.minSetback();\n }\n\n /**\n * Execute multiple calls.\n *\n * @param data Array of call data.\n * @returns Array of results.\n */\n public multicall(data: Hex[]) {\n return this.getContract().write.multicall([data], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Renounce a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param callerConfirmation The caller confirmation address.\n */\n public renounceRole(\n roleIdOrLabel: bigint | string,\n callerConfirmation: Address,\n ) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.renounceRole([roleId, callerConfirmation], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Revoke a role from an account.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param account The account address.\n */\n public revokeRole(roleIdOrLabel: bigint | string, account: Address) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.revokeRole([roleId, account], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Schedule an operation.\n *\n * @param target The target contract address.\n * @param data The operation data.\n * @param when The execution time.\n * @returns The operation ID and nonce.\n */\n public schedule(target: Address, data: Hex, when: number) {\n return this.getContract().write.schedule([target, data, when], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the grant delay for a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param newDelay The new delay.\n */\n public setGrantDelay(roleIdOrLabel: bigint | string, newDelay: number) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.setGrantDelay([roleId, newDelay], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the admin role for a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param admin The admin role ID.\n */\n public setRoleAdmin(roleIdOrLabel: bigint | string, admin: bigint) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.setRoleAdmin([roleId, admin], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the guardian role for a role.\n *\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n * @param guardian The guardian role ID.\n */\n public setRoleGuardian(roleIdOrLabel: bigint | string, guardian: bigint) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.setRoleGuardian([roleId, guardian], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the admin delay for a target.\n *\n * @param target The target contract address.\n * @param newDelay The new delay.\n */\n public setTargetAdminDelay(target: Address, newDelay: number) {\n return this.getContract().write.setTargetAdminDelay([target, newDelay], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set whether a target is closed.\n *\n * @param target The target contract address.\n * @param closed Whether the target is closed.\n */\n public setTargetClosed(target: Address, closed: boolean) {\n return this.getContract().write.setTargetClosed([target, closed], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**\n * Set the function role for a target.\n *\n * @param target The target address.\n * @param selectors Array of function selectors.\n * @param roleIdOrLabel The role ID or role label generated with\n * `labelToRoleId`.\n */\n public setTargetFunctionRole(\n target: Address,\n selectors: Hex[],\n roleIdOrLabel: bigint | string,\n ) {\n const roleId = this.processRoleIdOrLabel(roleIdOrLabel);\n\n return this.getContract().write.setTargetFunctionRole(\n [target, selectors, roleId],\n {\n account: this.walletClient.account!,\n chain: this.viemChain,\n },\n );\n }\n\n /**\n * Update the authority for a target.\n *\n * @param target The target address.\n * @param newAuthority The new authority address.\n */\n public updateAuthority(target: Address, newAuthority: Address) {\n return this.getContract().write.updateAuthority([target, newAuthority], {\n account: this.walletClient.account!,\n chain: this.viemChain,\n });\n }\n\n /**************************************************/\n /****************** Helper Methods ****************/\n /**************************************************/\n\n /**\n * Convert a label to a role ID. Useful if you want to create a roleId\n * from a label which can then be used to get the label back using\n * `roleIdToLabel`.\n *\n * @param label The label to convert.\n * @returns The role ID.\n */\n public labelToRoleId(label: string) {\n const bytes = stringToBytes(label);\n // Reverse the bytes to make it little-endian.\n const leBytes = bytes.reverse();\n const hex = bytesToHex(leBytes);\n\n return hexToBigInt(hex);\n }\n\n /**\n * Convert a role ID to a label. Only useful if the `roleId` was\n * created using `labelToRoleId`.\n *\n * @param roleId The role ID to convert.\n * @returns The label.\n */\n public roleIdToLabel(roleId: bigint) {\n const hex = toHex(roleId);\n // Reverse the bytes to make it little-endian.\n const leBytes = toBytes(hex).reverse();\n\n return bytesToString(leBytes);\n }\n\n /**\n * Get the selector for a function name.\n *\n * @param functionName The function name.\n * @returns The selector.\n */\n public getSelectorFromFunctionName(functionName: string) {\n return Object.entries(this.selectorsMap).find(([, value]) =>\n value.includes(functionName),\n )?.[0];\n }\n\n /**\n * Get the function name for a selector.\n *\n * @param selector The selector.\n * @returns The function name.\n */\n public getFunctionNameFromSelector(selector: Hex) {\n return Object.entries(this.selectorsMap).find(\n ([key]) => key === selector,\n )?.[1];\n }\n\n private processRoleIdOrLabel(roleIdOrLabel: bigint | string) {\n if (typeof roleIdOrLabel === 'string') {\n return this.labelToRoleId(roleIdOrLabel);\n }\n\n return roleIdOrLabel;\n }\n}\n"],"names":["InstitutionalAccessManagerHandler","chain","walletClient","publicClient","VIEM_CHAINS","address","InvalidContractAddressError","abi","InstitutionalAccessManager","client","getContract","caller","target","selector","immediate","delay","data","value","roleIdOrLabel","account","roleId","since","currentDelay","pendingDelay","effect","id","executionDelay","isMember","label","callerConfirmation","when","newDelay","admin","guardian","closed","selectors","newAuthority","leBytes","stringToBytes","hex","bytesToHex","hexToBigInt","toHex","toBytes","bytesToString","functionName","key"],"mappings":";;;;AAuBO,MAAMA,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8B7C,YACEC,GACQC,GACAC,GACR;AAFQ,SAAA,eAAAD,GACA,KAAA,eAAAC,GAER,KAAK,YAAYC,EAAYH,CAAK;AAAA,EACpC;AAAA,EAnCQ;AAAA,EACA;AAAA,EACA,eAAoC;AAAA,IAC1C,cACE;AAAA,IACF,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,EAAA;AAAA;AA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,GAAsB;AACvD,WAAO,OAAO,QAAQ,KAAK,YAAY,EAAE;AAAA,MAAK,CAAC,GAAG5B,CAAK,MACrDA,EAAM,SAAS4B,CAAY;AAAA,IAAA,IACzB,CAAC;AAAA,EACP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,4BAA4BhC,GAAe;AAChD,WAAO,OAAO,QAAQ,KAAK,YAAY,EAAE;AAAA,MACvC,CAAC,CAACiC,CAAG,MAAMA,MAAQjC;AAAA,IAAA,IACjB,CAAC;AAAA,EACP;AAAA,EAEQ,qBAAqBK,GAAgC;AAC3D,WAAI,OAAOA,KAAkB,WACpB,KAAK,cAAcA,CAAa,IAGlCA;AAAA,EACT;AACF;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../abis/mainnet/InstitutionalVault.cjs"),n=require("../../constants-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../abis/mainnet/InstitutionalVault.cjs"),n=require("../../constants-PXB3A4Yl.cjs"),s=require("../../errors/validation-errors.cjs"),o=require("../../getContract-BL-M-dQc.cjs");class c{constructor(t,e,a){this.walletClient=e,this.publicClient=a,this.viemChain=n.VIEM_CHAINS[t]}viemChain;address;withAddress(t){return this.address=t,this}getAddress(){return this.address}getContract(){if(!this.address)throw new s.InvalidContractAddressError("No address specified for the contract",{fixMessage:"Set the contract address in the handler by using the setAddress method"});const t=i.InstitutionalVault,e={public:this.publicClient,wallet:this.walletClient};return o.getContract({address:this.address,abi:t,client:e})}getBeaconDepositContract(){return this.getContract().read.BEACON_DEPOSIT_CONTRACT()}getNonRestakingWithdrawalCredentialsFactory(){return this.getContract().read.NON_RESTORAKING_WITHDRAWAL_CREDENTIALS_FACTORY()}getWeth(){return this.getContract().read.WETH()}getEigenDelegationManager(){return this.getContract().read.EIGEN_DELEGATION_MANAGER()}getEigenPodManager(){return this.getContract().read.EIGEN_POD_MANAGER()}getEigenPod(){return this.getContract().read.getEigenPod()}getEigenPodWithdrawalCredentials(){return this.getContract().read.getEigenPodWithdrawalCredentials()}getNoRestakingWithdrawalCredentials(){return this.getContract().read.getNoRestakingWithdrawalCredentials()}allowance(t,e){return this.getContract().read.allowance([t,e])}approve(t,e){return this.getContract().write.approve([t,e],{account:this.walletClient.account,chain:this.viemChain})}asset(){return this.getContract().read.asset()}authority(){return this.getContract().read.authority()}balanceOf(t){return this.getContract().read.balanceOf([t])}decimals(){return this.getContract().read.decimals()}completeQueuedWithdrawals(t,e){return this.getContract().write.completeQueuedWithdrawals([t,e],{account:this.walletClient.account,chain:this.viemChain})}convertToAssets(t){return this.getContract().read.convertToAssets([t])}convertToShares(t){return this.getContract().read.convertToShares([t])}deposit(t,e){return this.getContract().write.deposit([t,e],{account:this.walletClient.account,chain:this.viemChain})}depositETH(t,e){return this.getContract().write.depositETH([t],{account:this.walletClient.account,chain:this.viemChain,value:e})}getNonRestakedValidatorETH(){return this.getContract().read.getNonRestakedValidatorETH()}getRestakedValidatorETH(){return this.getContract().read.getRestakedValidatorETH()}getWithdrawalCredentials(){return this.getContract().read.getWithdrawalCredentials()}maxDeposit(t){return this.getContract().read.maxDeposit([t])}maxMint(t){return this.getContract().read.maxMint([t])}maxRedeem(t){return this.getContract().read.maxRedeem([t])}maxWithdraw(t){return this.getContract().read.maxWithdraw([t])}mint(t,e){return this.getContract().write.mint([t,e],{account:this.walletClient.account,chain:this.viemChain})}name(){return this.getContract().read.name()}previewDeposit(t){return this.getContract().read.previewDeposit([t])}previewMint(t){return this.getContract().read.previewMint([t])}previewRedeem(t){return this.getContract().read.previewRedeem([t])}previewWithdraw(t){return this.getContract().read.previewWithdraw([t])}queueWithdrawals(t){return this.getContract().write.queueWithdrawals([t],{account:this.walletClient.account,chain:this.viemChain})}requestWithdrawal(t,e){return this.getContract().write.requestWithdrawal([t],{account:this.walletClient.account,chain:this.viemChain,value:e})}redeem(t,e,a){return this.getContract().write.redeem([t,e,a],{account:this.walletClient.account,chain:this.viemChain})}setValidatorsETH(t,e){return this.getContract().write.setValidatorsETH([t,e],{account:this.walletClient.account,chain:this.viemChain})}startNonRestakingValidators(t,e,a,r){return this.getContract().write.startNonRestakingValidators([t,e,a,r],{account:this.walletClient.account,chain:this.viemChain})}startRestakingValidators(t,e,a,r){return this.getContract().write.startRestakingValidators([t,e,a,r],{account:this.walletClient.account,chain:this.viemChain})}withdraw(t,e,a){return this.getContract().write.withdraw([t,e,a],{account:this.walletClient.account,chain:this.viemChain})}symbol(){return this.getContract().read.symbol()}totalAssets(){return this.getContract().read.totalAssets()}totalSupply(){return this.getContract().read.totalSupply()}transfer(t,e){return this.getContract().write.transfer([t,e],{account:this.walletClient.account,chain:this.viemChain})}transferFrom(t,e,a){return this.getContract().write.transferFrom([t,e,a],{account:this.walletClient.account,chain:this.viemChain})}customExternalCall(t,e,a){return this.getContract().write.customExternalCall([t,e,a],{account:this.walletClient.account,chain:this.viemChain,value:a})}requestEigenPodConsolidation(t,e,a){return this.getContract().write.requestEigenPodConsolidation([t,e],{account:this.walletClient.account,chain:this.viemChain,value:a})}withdrawNonRestakedETH(){return this.getContract().write.withdrawNonRestakedETH({account:this.walletClient.account,chain:this.viemChain})}}exports.InstitutionalVaultHandler=c;
|
|
2
2
|
//# sourceMappingURL=institutional-vault-handler.cjs.map
|