1+ import { Coin } from '@injectivelabs/ts-types'
12import {
23 GoogleProtobufAny ,
34 CosmwasmWasmV1Authz ,
@@ -8,7 +9,8 @@ export declare namespace ContractExecutionAuthorization {
89 export interface Params {
910 contract : string
1011 limit ?: {
11- maxCalls : number
12+ maxCalls ?: number
13+ amounts ?: Coin [ ]
1214 }
1315 filter ?: {
1416 acceptedMessagesKeys : string [ ]
@@ -46,15 +48,38 @@ export default class ContractExecutionAuthorization extends BaseAuthorization<
4648 grant . contract = params . contract
4749
4850 if ( params . limit ) {
49- const limit = CosmwasmWasmV1Authz . MaxCallsLimit . create ( )
51+ if ( params . limit . maxCalls && params . limit . amounts ) {
52+ const limit = CosmwasmWasmV1Authz . CombinedLimit . create ( )
5053
51- limit . remaining = params . limit . maxCalls . toString ( )
54+ limit . callsRemaining = params . limit . maxCalls . toString ( )
55+ limit . amounts = params . limit . amounts
5256
53- const any = GoogleProtobufAny . Any . create ( )
54- any . typeUrl = '/cosmwasm.wasm.v1.MaxCallsLimit'
55- any . value = CosmwasmWasmV1Authz . MaxCallsLimit . encode ( limit ) . finish ( )
57+ const any = GoogleProtobufAny . Any . create ( )
58+ any . typeUrl = '/cosmwasm.wasm.v1.CombinedLimit'
59+ any . value = CosmwasmWasmV1Authz . CombinedLimit . encode ( limit ) . finish ( )
60+
61+ grant . limit = any
62+ } else if ( params . limit . maxCalls ) {
63+ const limit = CosmwasmWasmV1Authz . MaxCallsLimit . create ( )
64+
65+ limit . remaining = params . limit . maxCalls . toString ( )
66+
67+ const any = GoogleProtobufAny . Any . create ( )
68+ any . typeUrl = '/cosmwasm.wasm.v1.MaxCallsLimit'
69+ any . value = CosmwasmWasmV1Authz . MaxCallsLimit . encode ( limit ) . finish ( )
5670
57- grant . limit = any
71+ grant . limit = any
72+ } else if ( params . limit . amounts ) {
73+ const limit = CosmwasmWasmV1Authz . MaxFundsLimit . create ( )
74+
75+ limit . amounts = params . limit . amounts
76+
77+ const any = GoogleProtobufAny . Any . create ( )
78+ any . typeUrl = '/cosmwasm.wasm.v1.MaxFundsLimit'
79+ any . value = CosmwasmWasmV1Authz . MaxFundsLimit . encode ( limit ) . finish ( )
80+
81+ grant . limit = any
82+ }
5883 }
5984
6085 if ( params . filter ) {
@@ -99,9 +124,22 @@ export default class ContractExecutionAuthorization extends BaseAuthorization<
99124 grant . contract = params . contract
100125
101126 if ( params . limit ) {
102- grant . limit = {
103- type : 'wasm/MaxCallsLimit' ,
104- remaining : params . limit . maxCalls . toString ( ) ,
127+ if ( params . limit . maxCalls && params . limit . amounts ) {
128+ grant . limit = {
129+ type : 'wasm/CombinedLimit' ,
130+ calls_remaining : params . limit . maxCalls . toString ( ) ,
131+ amounts : params . limit . amounts ,
132+ }
133+ } else if ( params . limit . maxCalls ) {
134+ grant . limit = {
135+ type : 'wasm/MaxCallsLimit' ,
136+ remaining : params . limit . maxCalls . toString ( ) ,
137+ }
138+ } else if ( params . limit . amounts ) {
139+ grant . limit = {
140+ type : 'wasm/MaxFundsLimit' ,
141+ amounts : params . limit . amounts ,
142+ }
105143 }
106144 }
107145
@@ -126,9 +164,22 @@ export default class ContractExecutionAuthorization extends BaseAuthorization<
126164 grant . contract = params . contract
127165
128166 if ( params . limit ) {
129- grant . limit = {
130- '@type' : '/cosmwasm.wasm.v1.MaxCallsLimit' ,
131- remaining : params . limit . maxCalls . toString ( ) ,
167+ if ( params . limit . maxCalls && params . limit . amounts ) {
168+ grant . limit = {
169+ '@type' : '/cosmwasm.wasm.v1.CombinedLimit' ,
170+ calls_remaining : params . limit . maxCalls . toString ( ) ,
171+ amounts : params . limit . amounts ,
172+ }
173+ } else if ( params . limit . maxCalls ) {
174+ grant . limit = {
175+ '@type' : '/cosmwasm.wasm.v1.MaxCallsLimit' ,
176+ remaining : params . limit . maxCalls . toString ( ) ,
177+ }
178+ } else if ( params . limit . amounts ) {
179+ grant . limit = {
180+ '@type' : '/cosmwasm.wasm.v1.MaxFundsLimit' ,
181+ amounts : params . limit . amounts ,
182+ }
132183 }
133184 }
134185
0 commit comments