File tree Expand file tree Collapse file tree 2 files changed +31
-6
lines changed
src/permissionless/bindings Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change 11import type { Hex } from "viem" ;
22import { iLossPolicyV310Abi } from "../../../abi/310/generated.js" ;
3+ import { decodeFunctionWithNamedArgs } from "../../utils/abi-decoder.js" ;
4+ import { AccessMode } from "../types.js" ;
35import { AbstractFactory } from "./abstract-factory.js" ;
46
57const abi = iLossPolicyV310Abi ;
68
7- export enum AccessMode {
8- Permissionless = 0 ,
9- Permissioned = 1 ,
10- Forbidden = 2 ,
11- }
12-
139export class LossPolicyFactory extends AbstractFactory < typeof abi > {
1410 constructor ( ) {
1511 super ( abi ) ;
@@ -28,4 +24,27 @@ export class LossPolicyFactory extends AbstractFactory<typeof abi> {
2824 args : [ args . enabled ] ,
2925 } ) ;
3026 }
27+
28+ decodeConfig (
29+ calldata : Hex ,
30+ ) : { functionName : string ; args : Record < string , string > } | null {
31+ const decoded = decodeFunctionWithNamedArgs ( this . abi , calldata ) ;
32+ if ( ! decoded ) return null ;
33+
34+ if ( decoded . functionName === "setAccessMode" ) {
35+ const accessMode = Number ( decoded . args [ 0 ] ) ;
36+
37+ return {
38+ functionName : decoded . functionName ,
39+ args : {
40+ accessMode : AccessMode [ accessMode ] ?? accessMode . toString ( ) ,
41+ } ,
42+ } ;
43+ }
44+
45+ return {
46+ functionName : decoded . functionName ,
47+ args : decoded . args ,
48+ } ;
49+ }
3150}
Original file line number Diff line number Diff line change @@ -78,3 +78,9 @@ export interface PriceUpdate {
7878 priceFeed : Address ;
7979 data : Hex ;
8080}
81+
82+ export enum AccessMode {
83+ Permissionless = 0 ,
84+ Permissioned = 1 ,
85+ Forbidden = 2 ,
86+ }
You can’t perform that action at this time.
0 commit comments