6
6
7
7
import { CamelCasedProperties } from "type-fest" ;
8
8
import { SigningCosmWasmClient , ExecuteResult } from "@cosmjs/cosmwasm-stargate" ;
9
- import { AbstractQueryClient , AbstractAccountQueryClient , AbstractAccountClient , AppExecuteMsg , AppExecuteMsgFactory , AdapterExecuteMsg , AdapterExecuteMsgFactory , AbstractClient , AbstractAccountId } from "@abstract-money/abstract.js " ;
9
+ import { AccountPublicClient , AccountWalletClient , AppExecuteMsg , AppExecuteMsgFactory , AdapterExecuteMsg , AdapterExecuteMsgFactory } from "@abstract-money/core " ;
10
10
import { StdFee , Coin } from "@cosmjs/amino" ;
11
11
import { Decimal , AssetEntry , BondingPeriodSelector , Duration , InstantiateMsg , ExecuteMsg , Uint128 , AnsAsset , QueryMsg , MigrateMsg , Expiration , Timestamp , Uint64 , ArrayOfTupleOfStringAndArrayOfClaim , Claim , ArrayOfClaim , Addr , PoolAddressBaseForAddr , AssetInfoBaseForAddr , PoolType , Config , PoolMetadata } from "./Autocompounder.types" ;
12
12
import { AutocompounderQueryMsgBuilder , AutocompounderExecuteMsgBuilder } from "./Autocompounder.message-builder" ;
13
13
export interface IAutocompounderAppQueryClient {
14
14
moduleId : string ;
15
- accountQueryClient : AbstractAccountQueryClient ;
15
+ accountPublicClient : AccountPublicClient ;
16
16
_moduleAddress : string | undefined ;
17
17
config : ( ) => Promise < Config > ;
18
18
pendingClaims : ( params : CamelCasedProperties < Extract < QueryMsg , {
@@ -29,33 +29,21 @@ export interface IAutocompounderAppQueryClient {
29
29
balance : ( params : CamelCasedProperties < Extract < QueryMsg , {
30
30
balance : unknown ;
31
31
} > [ "balance" ] > ) => Promise < Uint128 > ;
32
- connectSigningClient : ( signingClient : SigningCosmWasmClient , address : string ) => AutocompounderAppClient ;
33
32
getAddress : ( ) => Promise < string > ;
34
33
}
35
34
export class AutocompounderAppQueryClient implements IAutocompounderAppQueryClient {
36
- accountQueryClient : AbstractAccountQueryClient ;
35
+ accountPublicClient : AccountPublicClient ;
37
36
moduleId : string ;
38
37
_moduleAddress : string | undefined ;
39
38
40
39
constructor ( {
41
- abstractQueryClient,
42
- accountId,
43
- managerAddress,
44
- proxyAddress,
40
+ accountPublicClient,
45
41
moduleId
46
42
} : {
47
- abstractQueryClient : AbstractQueryClient ;
48
- accountId : AbstractAccountId ;
49
- managerAddress : string ;
50
- proxyAddress : string ;
43
+ accountPublicClient : AccountPublicClient ;
51
44
moduleId : string ;
52
45
} ) {
53
- this . accountQueryClient = new AbstractAccountQueryClient ( {
54
- abstract : abstractQueryClient ,
55
- accountId,
56
- managerAddress,
57
- proxyAddress
58
- } ) ;
46
+ this . accountPublicClient = accountPublicClient ;
59
47
this . moduleId = moduleId ;
60
48
this . config = this . config . bind ( this ) ;
61
49
this . pendingClaims = this . pendingClaims . bind ( this ) ;
@@ -97,7 +85,9 @@ export class AutocompounderAppQueryClient implements IAutocompounderAppQueryClie
97
85
} ;
98
86
getAddress = async ( ) : Promise < string > => {
99
87
if ( ! this . _moduleAddress ) {
100
- const address = await this . accountQueryClient . getModuleAddress ( this . moduleId ) ;
88
+ const address = await this . accountPublicClient . getModuleAddress ( {
89
+ id : this . moduleId
90
+ } ) ;
101
91
102
92
if ( address === null ) {
103
93
throw new Error ( `Module ${ this . moduleId } not installed` ) ;
@@ -108,59 +98,43 @@ export class AutocompounderAppQueryClient implements IAutocompounderAppQueryClie
108
98
109
99
return this . _moduleAddress ! ;
110
100
} ;
111
- connectSigningClient = ( signingClient : SigningCosmWasmClient , address : string ) : AutocompounderAppClient => {
112
- return new AutocompounderAppClient ( {
113
- accountId : this . accountQueryClient . accountId ,
114
- managerAddress : this . accountQueryClient . managerAddress ,
115
- proxyAddress : this . accountQueryClient . proxyAddress ,
116
- moduleId : this . moduleId ,
117
- abstractClient : this . accountQueryClient . abstract . connectSigningClient ( signingClient , address )
118
- } ) ;
119
- } ;
120
101
_query = async ( queryMsg : QueryMsg ) : Promise < any > => {
121
- return this . accountQueryClient . queryModule ( {
102
+ return this . accountPublicClient . queryModule ( {
122
103
moduleId : this . moduleId ,
123
104
moduleType : "app" ,
124
105
queryMsg
125
106
} ) ;
126
107
} ;
127
108
}
128
109
export interface IAutocompounderAppClient extends IAutocompounderAppQueryClient {
129
- accountClient : AbstractAccountClient ;
110
+ accountWalletClient : AccountWalletClient ;
130
111
updateFeeConfig : ( params : CamelCasedProperties < Extract < ExecuteMsg , {
131
112
update_fee_config : unknown ;
132
- } > [ "update_fee_config" ] > , fee ?: number | StdFee | "auto" , memo ?: string , _funds ?: Coin [ ] ) => Promise < ExecuteResult > ;
113
+ } > [ "update_fee_config" ] > , fee_ ?: number | StdFee | "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) => Promise < ExecuteResult > ;
133
114
deposit : ( params : CamelCasedProperties < Extract < ExecuteMsg , {
134
115
deposit : unknown ;
135
- } > [ "deposit" ] > , fee ?: number | StdFee | "auto" , memo ?: string , _funds ?: Coin [ ] ) => Promise < ExecuteResult > ;
136
- withdraw : ( fee ?: number | StdFee | "auto" , memo ?: string , _funds ?: Coin [ ] ) => Promise < ExecuteResult > ;
137
- compound : ( fee ?: number | StdFee | "auto" , memo ?: string , _funds ?: Coin [ ] ) => Promise < ExecuteResult > ;
138
- batchUnbond : ( fee ?: number | StdFee | "auto" , memo ?: string , _funds ?: Coin [ ] ) => Promise < ExecuteResult > ;
116
+ } > [ "deposit" ] > , fee_ ?: number | StdFee | "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) => Promise < ExecuteResult > ;
117
+ withdraw : ( fee_ ?: number | StdFee | "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) => Promise < ExecuteResult > ;
118
+ compound : ( fee_ ?: number | StdFee | "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) => Promise < ExecuteResult > ;
119
+ batchUnbond : ( fee_ ?: number | StdFee | "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) => Promise < ExecuteResult > ;
139
120
}
140
121
export class AutocompounderAppClient extends AutocompounderAppQueryClient implements IAutocompounderAppClient {
141
- accountClient : AbstractAccountClient ;
122
+ accountWalletClient : AccountWalletClient ;
142
123
143
124
constructor ( {
144
- abstractClient,
145
- accountId,
146
- managerAddress,
147
- proxyAddress,
125
+ accountPublicClient,
126
+ accountWalletClient,
148
127
moduleId
149
128
} : {
150
- abstractClient : AbstractClient ;
151
- accountId : AbstractAccountId ;
152
- managerAddress : string ;
153
- proxyAddress : string ;
129
+ accountPublicClient : AccountPublicClient ;
130
+ accountWalletClient : AccountWalletClient ;
154
131
moduleId : string ;
155
132
} ) {
156
133
super ( {
157
- abstractQueryClient : abstractClient ,
158
- accountId,
159
- managerAddress,
160
- proxyAddress,
134
+ accountPublicClient,
161
135
moduleId
162
136
} ) ;
163
- this . accountClient = AbstractAccountClient . fromQueryClient ( this . accountQueryClient , abstractClient ) ;
137
+ this . accountWalletClient = accountWalletClient ;
164
138
this . updateFeeConfig = this . updateFeeConfig . bind ( this ) ;
165
139
this . deposit = this . deposit . bind ( this ) ;
166
140
this . withdraw = this . withdraw . bind ( this ) ;
@@ -170,25 +144,27 @@ export class AutocompounderAppClient extends AutocompounderAppQueryClient implem
170
144
171
145
updateFeeConfig = async ( params : CamelCasedProperties < Extract < ExecuteMsg , {
172
146
update_fee_config : unknown ;
173
- } > [ "update_fee_config" ] > , fee : number | StdFee | "auto" = "auto" , memo ?: string , _funds ?: Coin [ ] ) : Promise < ExecuteResult > => {
174
- return this . _execute ( AutocompounderExecuteMsgBuilder . updateFeeConfig ( params ) , fee , memo , _funds ) ;
147
+ } > [ "update_fee_config" ] > , fee_ : number | StdFee | "auto" = "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) : Promise < ExecuteResult > => {
148
+ return this . _execute ( AutocompounderExecuteMsgBuilder . updateFeeConfig ( params ) , fee_ , memo_ , funds_ ) ;
175
149
} ;
176
150
deposit = async ( params : CamelCasedProperties < Extract < ExecuteMsg , {
177
151
deposit : unknown ;
178
- } > [ "deposit" ] > , fee : number | StdFee | "auto" = "auto" , memo ?: string , _funds ?: Coin [ ] ) : Promise < ExecuteResult > => {
179
- return this . _execute ( AutocompounderExecuteMsgBuilder . deposit ( params ) , fee , memo , _funds ) ;
152
+ } > [ "deposit" ] > , fee_ : number | StdFee | "auto" = "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) : Promise < ExecuteResult > => {
153
+ return this . _execute ( AutocompounderExecuteMsgBuilder . deposit ( params ) , fee_ , memo_ , funds_ ) ;
180
154
} ;
181
- withdraw = async ( fee : number | StdFee | "auto" = "auto" , memo ?: string , _funds ?: Coin [ ] ) : Promise < ExecuteResult > => {
182
- return this . _execute ( AutocompounderExecuteMsgBuilder . withdraw ( ) , fee , memo , _funds ) ;
155
+ withdraw = async ( fee_ : number | StdFee | "auto" = "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) : Promise < ExecuteResult > => {
156
+ return this . _execute ( AutocompounderExecuteMsgBuilder . withdraw ( ) , fee_ , memo_ , funds_ ) ;
183
157
} ;
184
- compound = async ( fee : number | StdFee | "auto" = "auto" , memo ?: string , _funds ?: Coin [ ] ) : Promise < ExecuteResult > => {
185
- return this . _execute ( AutocompounderExecuteMsgBuilder . compound ( ) , fee , memo , _funds ) ;
158
+ compound = async ( fee_ : number | StdFee | "auto" = "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) : Promise < ExecuteResult > => {
159
+ return this . _execute ( AutocompounderExecuteMsgBuilder . compound ( ) , fee_ , memo_ , funds_ ) ;
186
160
} ;
187
- batchUnbond = async ( fee : number | StdFee | "auto" = "auto" , memo ?: string , _funds ?: Coin [ ] ) : Promise < ExecuteResult > => {
188
- return this . _execute ( AutocompounderExecuteMsgBuilder . batchUnbond ( ) , fee , memo , _funds ) ;
161
+ batchUnbond = async ( fee_ : number | StdFee | "auto" = "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) : Promise < ExecuteResult > => {
162
+ return this . _execute ( AutocompounderExecuteMsgBuilder . batchUnbond ( ) , fee_ , memo_ , funds_ ) ;
189
163
} ;
190
- _execute = async ( msg : ExecuteMsg , fee : number | StdFee | "auto" = "auto" , memo ?: string , _funds ?: Coin [ ] ) : Promise < ExecuteResult > => {
164
+ _execute = async ( msg : ExecuteMsg , fee_ : number | StdFee | "auto" = "auto" , memo_ ?: string , funds_ ?: Coin [ ] ) : Promise < ExecuteResult > => {
165
+ const signingCwClient = await this . accountWalletClient . getSigningCosmWasmClient ( ) ;
166
+ const sender = await this . accountWalletClient . getSenderAddress ( ) ;
191
167
const moduleMsg : AppExecuteMsg < ExecuteMsg > = AppExecuteMsgFactory . executeApp ( msg ) ;
192
- return await this . accountClient . abstract . client . execute ( this . accountClient . sender , await this . getAddress ( ) , moduleMsg , fee , memo , _funds ) ;
168
+ return await signingCwClient . execute ( sender , await this . getAddress ( ) , moduleMsg , fee_ , memo_ , funds_ ) ;
193
169
} ;
194
170
}
0 commit comments