Trying to post a transaction. Using mobile connection for keplr through wallet connect library.
Keplr client and offlineSigner is ok but when i'm trying to execute txApprove in keplr it fails.
getClient = async (chainId: string) => {
try {
const offlineSigner = this.keplr?.getOfflineSigner(chainId)
return await SigningCosmWasmClient.connectWithSigner(
process.env.REACT_APP_WEB3_JUNO_RPC,
offlineSigner,
{
gasPrice: GasPrice.fromString('0.025ujuno') as any
}
)
} catch (e) {
console.log(e)
}
}
This logic work with window.keplr and also keplr objet from wc library
try {
const client = await this.getClient('juno-1')
console.log({client})
let routes = []
let offer_asset = {};
let ask_asset = {};
for (let j = 0; j < routeArgs.length; j++) {
let operations = []
for (let i = 0; i < routeArgs[j].operations.length; i++) {
if (!routeArgs[j].operations[i].offer_token.startsWith('juno1')) {
offer_asset = {
"native_token": {
"denom": routeArgs[j].operations[i].offer_token
}
}
} else {
offer_asset = {
"token": {
"contract_addr": routeArgs[j].operations[i].offer_token
}
}
}
if (!routeArgs[j].operations[i].ask_token.startsWith('juno1')) {
ask_asset = {
"native_token": {
"denom": routeArgs[j].operations[i].ask_token
}
}
} else {
ask_asset = {
"token": {
"contract_addr": routeArgs[j].operations[i].ask_token
}
}
}
let temp_msg =
{
"t_f_m_swap": {
"ask_asset_info": ask_asset,
"pair_contract": routeArgs[j].operations[i].contract_addr,
"factory_name": routeArgs[j].operations[i].exchange,
"offer_asset_info": offer_asset
}
}
operations.push(temp_msg)
}
routes.push(
{
offer_amount: (routeArgs[j].input_amount * (10 ** this.tokensDictionary[routeArgs[j].operations[0].offer_token].decimals)).toFixed(0).toString(),
operations: operations
}
)
}
const swapMessage = {
execute_swap_operations: {
max_spread: "0.50",
offer_amount: `${tokenAmount.toString()}`,
minimum_receive: `${(parseFloat(minReceived) * (10 ** this.tokensDictionary[tokenB.token_address].decimals)).toFixed()}`,
routes: routes,
}
}
if (routeArgs[0].operations[0].offer_token.startsWith('juno1')) {
console.log(tokenAmount)
const sendmessage = {
send: {
amount: `${tokenAmount.toString()}`,
contract: "juno14237hj4uvjruu4ucfzz0kpc8lxauwjhuzr3y8wqxlwcw9vhwkw9s9hxtw8",
msg: btoa(JSON.stringify(swapMessage)),
}
}
return await client.execute(
senderAddress,
routeArgs[0].operations[0].offer_token.toString(),
sendmessage,
'auto',
undefined,
[]
)
}
return await client.execute(
senderAddress,
"juno14237hj4uvjruu4ucfzz0kpc8lxauwjhuzr3y8wqxlwcw9vhwkw9s9hxtw8",
swapMessage,
'auto',
undefined,
[coin(tokenAmount.toString(), routeArgs[0].operations[0].offer_token.toString())]
)
} catch (e) {
console.log(e)
}
}
As a result of this function call i get an error like
Error: Not yet implemented
at KeplrWalletConnectV1.signDirect (index.ts:476:1)
at CosmJSOfflineSigner.<anonymous> (cosmjs.ts:81:1)
at Generator.next (<anonymous>)
at fulfilled (core.ts:44:1)