Skip to content

Commit

Permalink
Merge pull request #189 from stakeordie/issue/188
Browse files Browse the repository at this point in the history
Remove broadcastMode configuration
  • Loading branch information
luiseel authored May 10, 2022
2 parents e6ee535 + 362a84f commit 7723b94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
10 changes: 1 addition & 9 deletions src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Tx,
Coin,
MsgExecuteContractParams,
BroadcastMode,
MsgInstantiateContractParams,
QueryContractsByCodeResponse,
TxOptions,
Expand All @@ -18,9 +17,6 @@ import { emitEvent } from './events';
import { getWindow } from './utils';
import { QueryBalanceResponse } from 'secretjs/dist/protobuf_stuff/cosmos/bank/v1beta1/query';
import { StdFee } from 'secretjs/dist/wallet_amino';

export { BroadcastMode };

export interface DefaultFees {
upload?: number;
init?: number;
Expand All @@ -31,7 +27,6 @@ export interface DefaultFees {
export interface Config {
restUrl: string;
chainId?: string;
broadcastMode?: BroadcastMode;
defaultFees?: DefaultFees;
}

Expand Down Expand Up @@ -94,9 +89,8 @@ export async function gripApp(
if (!config) {
// Set the configuration.
if (typeof _config === 'string') {
config = { restUrl: _config, broadcastMode: BroadcastMode.Sync };
config = { restUrl: _config };
} else {
_config.broadcastMode = _config.broadcastMode ?? BroadcastMode.Sync;
config = _config;
}

Expand Down Expand Up @@ -228,7 +222,6 @@ export async function executeContract(
gasLimit: parseInt(
fee?.gas || config?.defaultFees?.exec?.toString() || '30000'
),
broadcastMode: config?.broadcastMode || BroadcastMode.Sync,
};

return await signingClient.tx.compute.executeContract(
Expand Down Expand Up @@ -315,7 +308,6 @@ export function instantiate(codeId: number, initMsg: object, label: string) {
};
const txOptions: TxOptions = {
gasLimit: parseInt(config?.defaultFees?.init?.toString() || '150000'),
broadcastMode: config?.broadcastMode || BroadcastMode.Sync,
};
return signingClient.tx.compute.instantiateContract(params, txOptions);
}
Expand Down
29 changes: 3 additions & 26 deletions src/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
BroadcastMode,
IMsg,
Msg,
MsgExecuteContractParams,
MsgParams,
Tx,
TxOptions,
} from 'secretjs';
import { MsgExecuteContractParams, Tx, TxOptions } from 'secretjs';
import {
queryContract,
executeContract,
Expand Down Expand Up @@ -183,23 +175,8 @@ export function createContract<T>(contract: ContractSpecification): T {
codeHash
);

const config = getConfig();
if (!config) throw new Error('No config available');
if (config.broadcastMode == BroadcastMode.Sync) {
const result = await handleResponse(response.transactionHash);
if (result.found && result.response) {
const { response: txResponse } = result;
return ContractTxResponseHandler.of(txResponse);
} else {
const { response: txResponse } = result;
throw new BaseError(
`Could not find TX: ${response.transactionHash}`,
{ cause: subtractErrorFromResponse(txResponse) }
);
}
} else {
return ContractTxResponseHandler.of(response);
}
return ContractTxResponseHandler.of(response);

} catch (e: any) {
const errorHandler = getErrorHandler(contract.id, e);
if (errorHandler) {
Expand Down

0 comments on commit 7723b94

Please sign in to comment.