Skip to content

Commit

Permalink
fix sign
Browse files Browse the repository at this point in the history
  • Loading branch information
haunv3 committed Dec 12, 2024
1 parent 5d2fba6 commit 6f5d377
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 325 deletions.
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
"ctc": "all-contributors check"
},
"dependencies": {
"@cosmjs/cosmwasm-stargate": "^0.32.4",
"@cosmjs/math": "^0.32.4",
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@hookform/error-message": "0.0.5",
"@hookform/resolvers": "^1.2.0",
"@keplr-wallet/cosmos": "^0.9.12",
Expand Down Expand Up @@ -135,7 +131,13 @@
"extends": "react-app"
},
"resolutions": {
"@injectivelabs/sdk-ts": "1.12.1"
"@injectivelabs/sdk-ts": "1.12.1",
"@cosmjs/cosmwasm-stargate": "^0.32.4",
"@cosmjs/math": "^0.32.4",
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/tendermint-rpc": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"cosmjs-types": "0.9.0"
},
"browserslist": {
"production": [
Expand Down
56 changes: 28 additions & 28 deletions src/lib/config/networks.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { isTestnet } from "src/config";

export const NetworkKey = {
MAINNET: 'mainnet',
TESTNET: 'testnet'
}
MAINNET: "mainnet",
TESTNET: "testnet",
};

const networks = {
[NetworkKey.MAINNET]: {
chainId: 'Oraichain',
prefix: 'orai',
denom: 'orai',
coinType: 118,
lcd: 'https://lcd.orai.io',
rpc: 'https://rpc.orai.io',
id: NetworkKey.MAINNET,
fee: { gasPrice: '0', amount: '0', gas: '2000000' }, // 0.000500 ORAI
},
[NetworkKey.TESTNET]: {
chainId: 'Oraichain-testnet',
prefix: 'orai',
denom: 'orai',
coinType: 118,
lcd: 'https://testnet.lcd.orai.io',
rpc: 'https://testnet.rpc.orai.io',
id: NetworkKey.TESTNET,
fee: { gasPrice: '0', amount: '0', gas: '2000000' }, // 0.050000 ORAI
}
[NetworkKey.MAINNET]: {
chainId: "Oraichain",
prefix: "orai",
denom: "orai",
coinType: 118,
lcd: "https://lcd.orai.io",
rpc: "https://rpc.orai.io",
id: NetworkKey.MAINNET,
fee: { gasPrice: "0.00506", amount: "1518", gas: "2000000" },
},
[NetworkKey.TESTNET]: {
chainId: "Oraichain-testnet",
prefix: "orai",
denom: "orai",
coinType: 118,
lcd: "https://testnet.lcd.orai.io",
rpc: "https://testnet.rpc.orai.io",
id: NetworkKey.TESTNET,
fee: { gasPrice: "0.00506", amount: "1518", gas: "2000000" },
},
};

export default networks;

export const network =
// sure have value
isTestnet ? networks[NetworkKey.TESTNET] : networks[NetworkKey.MAINNET];
// sure have value
isTestnet ? networks[NetworkKey.TESTNET] : networks[NetworkKey.MAINNET];

export const mobileBlacklistNetworks = [
network.chainId
// 'cosmoshub-4',
// 'columbus-5'
network.chainId,
// 'cosmoshub-4',
// 'columbus-5'
];
14 changes: 8 additions & 6 deletions src/lib/walletStation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { createStakingAminoConverters } from "@cosmjs/stargate/build/modules/sta
import { createDistributionAminoConverters } from "@cosmjs/stargate/build/modules/distribution/aminomessages";
import { createBankAminoConverters } from "@cosmjs/stargate/build/modules/bank/aminomessages";
import { createGovAminoConverters } from "@cosmjs/stargate/build/modules/gov/aminomessages";
import { Tendermint37Client } from "@cosmjs/tendermint-rpc";

export const broadcastModeObj = {
BROADCAST_MODE_BLOCK: "BROADCAST_MODE_BLOCK",
Expand All @@ -46,18 +47,19 @@ export default class WalletStation {
...createWasmAminoConverters(),
...createGovAminoConverters(),
});
return await cosmwasm.SigningCosmWasmClient.connectWithSigner(network.rpc, wallet, {
gasPrice: new GasPrice(Decimal.fromUserInput("0", 6), network.denom),
prefix: network.denom,

const tmClient = await Tendermint37Client.connect(network.rpc);
return await cosmwasm.SigningCosmWasmClient.createWithSigner(tmClient, wallet, {
gasPrice: GasPrice.fromString(network.fee.gasPrice + network.denom),
broadcastPollIntervalMs: 600,
aminoTypes,
});
};

signAndBroadCast = async (address, messages, gas = "auto") => {
signAndBroadCast = async (address, messages, gas = 2) => {
try {
const wallet = await this.collectWallet();
const client = await this.signerClient(wallet);
console.log({ messages });
return await client.signAndBroadcast(address, messages, gas);
} catch (ex) {
console.log("signAndBroadcast msg error: ", ex);
Expand All @@ -68,7 +70,7 @@ export default class WalletStation {
signBroadcast = async props => {
const wallet = await this.collectWallet();
const client = await this.signerClient(wallet);
const { fromAddress, toAddress, contractAddress, msg, type = typeSign.SEND, gas = "auto", delegator_address, validator_address, amount } = props;
const { fromAddress, toAddress, contractAddress, msg, type = typeSign.SEND, gas = 2, delegator_address, validator_address, amount } = props;
try {
switch (type) {
case typeSign.SEND:
Expand Down
Loading

0 comments on commit 6f5d377

Please sign in to comment.