Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunnini committed Jan 5, 2024
2 parents e918fbe + e15e76f commit 23023ba
Show file tree
Hide file tree
Showing 32 changed files with 325 additions and 242 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.12.57",
"version": "0.12.58-rc.2",
"useWorkspaces": true,
"npmClient": "yarn",
"command": {
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keplr-wallet/analytics",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"main": "build/index.js",
"author": "chainapsis",
"license": "Apache-2.0",
Expand Down
24 changes: 12 additions & 12 deletions packages/background/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keplr-wallet/background",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"main": "build/index.js",
"author": "chainapsis",
"license": "Apache-2.0",
Expand Down Expand Up @@ -28,17 +28,17 @@
"@ethersproject/hash": "^5.7.0",
"@ethersproject/transactions": "^5.7.0",
"@ethersproject/wallet": "^5.7.0",
"@keplr-wallet/chain-validator": "0.12.57",
"@keplr-wallet/common": "0.12.57",
"@keplr-wallet/cosmos": "0.12.57",
"@keplr-wallet/crypto": "0.12.57",
"@keplr-wallet/ledger-cosmos": "0.12.57",
"@keplr-wallet/popup": "0.12.57",
"@keplr-wallet/proto-types": "0.12.57",
"@keplr-wallet/router": "0.12.57",
"@keplr-wallet/simple-fetch": "0.12.57",
"@keplr-wallet/types": "0.12.57",
"@keplr-wallet/unit": "0.12.57",
"@keplr-wallet/chain-validator": "0.12.58-rc.2",
"@keplr-wallet/common": "0.12.58-rc.2",
"@keplr-wallet/cosmos": "0.12.58-rc.2",
"@keplr-wallet/crypto": "0.12.58-rc.2",
"@keplr-wallet/ledger-cosmos": "0.12.58-rc.2",
"@keplr-wallet/popup": "0.12.58-rc.2",
"@keplr-wallet/proto-types": "0.12.58-rc.2",
"@keplr-wallet/router": "0.12.58-rc.2",
"@keplr-wallet/simple-fetch": "0.12.58-rc.2",
"@keplr-wallet/types": "0.12.58-rc.2",
"@keplr-wallet/unit": "0.12.58-rc.2",
"@ledgerhq/hw-app-eth": "^6.29.3",
"@ledgerhq/hw-transport": "^6.20.0",
"@ledgerhq/hw-transport-webhid": "^6.20.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/chain-validator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keplr-wallet/chain-validator",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"main": "build/index.js",
"author": "chainapsis",
"license": "Apache-2.0",
Expand All @@ -16,9 +16,9 @@
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
},
"dependencies": {
"@keplr-wallet/cosmos": "0.12.57",
"@keplr-wallet/simple-fetch": "0.12.57",
"@keplr-wallet/types": "0.12.57",
"@keplr-wallet/cosmos": "0.12.58-rc.2",
"@keplr-wallet/simple-fetch": "0.12.58-rc.2",
"@keplr-wallet/types": "0.12.58-rc.2",
"joi": "^17.5.0",
"utility-types": "^3.10.0"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keplr-wallet/common",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"main": "build/index.js",
"author": "chainapsis",
"license": "Apache-2.0",
Expand All @@ -16,8 +16,8 @@
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
},
"dependencies": {
"@keplr-wallet/crypto": "0.12.57",
"@keplr-wallet/types": "0.12.57",
"@keplr-wallet/crypto": "0.12.58-rc.2",
"@keplr-wallet/types": "0.12.58-rc.2",
"buffer": "^6.0.3",
"delay": "^4.4.0",
"mobx": "^6.1.7"
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmjs-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cosmjs-test",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"author": "chainapsis",
"license": "Apache-2.0",
"private": true,
Expand All @@ -12,7 +12,7 @@
},
"devDependencies": {
"@cosmjs/stargate": "^0.29.3",
"@keplr-wallet/provider-mock": "0.12.57",
"@keplr-wallet/provider-mock": "0.12.58-rc.2",
"secretjs": "^1.6.0"
}
}
14 changes: 7 additions & 7 deletions packages/cosmos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keplr-wallet/cosmos",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"main": "build/index.js",
"author": "chainapsis",
"license": "Apache-2.0",
Expand All @@ -17,12 +17,12 @@
},
"dependencies": {
"@ethersproject/address": "^5.6.0",
"@keplr-wallet/common": "0.12.57",
"@keplr-wallet/crypto": "0.12.57",
"@keplr-wallet/proto-types": "0.12.57",
"@keplr-wallet/simple-fetch": "0.12.57",
"@keplr-wallet/types": "0.12.57",
"@keplr-wallet/unit": "0.12.57",
"@keplr-wallet/common": "0.12.58-rc.2",
"@keplr-wallet/crypto": "0.12.58-rc.2",
"@keplr-wallet/proto-types": "0.12.58-rc.2",
"@keplr-wallet/simple-fetch": "0.12.58-rc.2",
"@keplr-wallet/types": "0.12.58-rc.2",
"@keplr-wallet/unit": "0.12.58-rc.2",
"bech32": "^1.1.4",
"buffer": "^6.0.3",
"long": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keplr-wallet/crypto",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"main": "build/index.js",
"author": "chainapsis",
"license": "Apache-2.0",
Expand Down
40 changes: 20 additions & 20 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keplr-wallet/extension",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"author": "chainapsis",
"license": "Apache-2.0",
"private": true,
Expand All @@ -25,25 +25,25 @@
"@ethersproject/transactions": "^5.7.0",
"@floating-ui/react": "^0.23.0",
"@floating-ui/react-dom": "^1.3.0",
"@keplr-wallet/analytics": "0.12.57",
"@keplr-wallet/background": "0.12.57",
"@keplr-wallet/chain-validator": "0.12.57",
"@keplr-wallet/common": "0.12.57",
"@keplr-wallet/cosmos": "0.12.57",
"@keplr-wallet/crypto": "0.12.57",
"@keplr-wallet/hooks": "0.12.57",
"@keplr-wallet/ledger-cosmos": "0.12.57",
"@keplr-wallet/popup": "0.12.57",
"@keplr-wallet/proto-types": "0.12.57",
"@keplr-wallet/provider": "0.12.57",
"@keplr-wallet/router": "0.12.57",
"@keplr-wallet/router-extension": "0.12.57",
"@keplr-wallet/simple-fetch": "0.12.57",
"@keplr-wallet/stores": "0.12.57",
"@keplr-wallet/stores-core": "0.12.57",
"@keplr-wallet/stores-etc": "0.12.57",
"@keplr-wallet/types": "0.12.57",
"@keplr-wallet/unit": "0.12.57",
"@keplr-wallet/analytics": "0.12.58-rc.2",
"@keplr-wallet/background": "0.12.58-rc.2",
"@keplr-wallet/chain-validator": "0.12.58-rc.2",
"@keplr-wallet/common": "0.12.58-rc.2",
"@keplr-wallet/cosmos": "0.12.58-rc.2",
"@keplr-wallet/crypto": "0.12.58-rc.2",
"@keplr-wallet/hooks": "0.12.58-rc.2",
"@keplr-wallet/ledger-cosmos": "0.12.58-rc.2",
"@keplr-wallet/popup": "0.12.58-rc.2",
"@keplr-wallet/proto-types": "0.12.58-rc.2",
"@keplr-wallet/provider": "0.12.58-rc.2",
"@keplr-wallet/router": "0.12.58-rc.2",
"@keplr-wallet/router-extension": "0.12.58-rc.2",
"@keplr-wallet/simple-fetch": "0.12.58-rc.2",
"@keplr-wallet/stores": "0.12.58-rc.2",
"@keplr-wallet/stores-core": "0.12.58-rc.2",
"@keplr-wallet/stores-etc": "0.12.58-rc.2",
"@keplr-wallet/types": "0.12.58-rc.2",
"@keplr-wallet/unit": "0.12.58-rc.2",
"@keystonehq/animated-qr": "^0.8.6",
"@keystonehq/keystone-sdk": "^0.2.3",
"@ledgerhq/devices": "^6.20.0",
Expand Down
78 changes: 76 additions & 2 deletions packages/extension/src/hooks/ibc-swap/amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import {
} from "@keplr-wallet/stores";
import { useState } from "react";
import { action, makeObservable, observable, override } from "mobx";
import { SkipQueries } from "../../stores/skip";
import {
MsgsDirectResponse,
RouteResponse,
SkipQueries,
} from "../../stores/skip";
import { ObservableQueryIBCSwapInner } from "../../stores/skip/ibc-swap";

export class IBCSwapAmountConfig extends AmountConfig {
Expand Down Expand Up @@ -132,7 +136,8 @@ export class IBCSwapAmountConfig extends AmountConfig {

async getTx(
slippageTolerancePercent: number,
affiliateFeeReceiver: string
affiliateFeeReceiver: string,
swapRouterKey?: string
): Promise<MakeTxResponse> {
const queryIBCSwap = this.getQueryIBCSwap();
if (!queryIBCSwap) {
Expand Down Expand Up @@ -208,6 +213,31 @@ export class IBCSwapAmountConfig extends AmountConfig {
throw new Error("Tx is not ready");
}

if (swapRouterKey) {
const queryMsgsDirect = queryIBCSwap.getQueryMsgsDirect(
chainIdsToAddresses,
slippageTolerancePercent,
affiliateFeeReceiver
);
if (!queryMsgsDirect.response) {
throw new Error("Can't happen: queryMsgsDirect is not ready");
}

const key = this.createSwapRouteKeyFromMsgsDirectResponse(
queryMsgsDirect.response.data
);

console.log({
swapRouterKey,
key,
});
if (swapRouterKey !== key) {
throw new Error(
"Route and msgs_direct are not matched. Please try again."
);
}
}

return tx;
}

Expand Down Expand Up @@ -318,6 +348,50 @@ export class IBCSwapAmountConfig extends AmountConfig {
}
}

// /route query의 결과와 /msgs_direct query의 결과를 비교하기 위한 키를 생성한다.
createSwapRouteKeyFromRouteResponse(response: RouteResponse): string {
let key = "";

for (const operation of response.operations) {
if ("swap" in operation) {
for (const swapOperation of operation.swap.swap_in.swap_operations) {
key += `/${swapOperation.pool}/${swapOperation.denom_in}/${swapOperation.denom_out}`;
}
}
}

return key;
}

// /route query의 결과와 /msgs_direct query의 결과를 비교하기 위한 키를 생성한다.
createSwapRouteKeyFromMsgsDirectResponse(
response: MsgsDirectResponse
): string {
let key = "";

for (const msg of response.msgs) {
if (msg.msg_type_url === "/ibc.applications.transfer.v1.MsgTransfer") {
const memo = JSON.parse(msg.msg).memo;
if (memo) {
const obj = JSON.parse(memo);
for (const operation of obj.wasm.msg.swap_and_action.user_swap
.swap_exact_asset_in.operations) {
key += `/${operation.pool}/${operation.denom_in}/${operation.denom_out}`;
}
}
}
if (msg.msg_type_url === "/cosmwasm.wasm.v1.MsgExecuteContract") {
const obj = JSON.parse(msg.msg);
for (const operation of obj.msg.swap_and_action.user_swap
.swap_exact_asset_in.operations) {
key += `/${operation.pool}/${operation.denom_in}/${operation.denom_out}`;
}
}
}

return key;
}

@override
override get uiProperties(): UIProperties {
const prev = super.uiProperties;
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/manifest.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "Keplr",
"description": "Keplr is a browser extension wallet for the Inter blockchain ecosystem.",
"version": "0.12.57",
"version": "0.12.58",
"icons": {
"16": "assets/icon-16.png",
"48": "assets/icon-48.png",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/manifest.v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "Keplr",
"description": "Keplr is a browser extension wallet for the Inter blockchain ecosystem.",
"version": "0.12.57",
"version": "0.12.58",
"icons": {
"16": "assets/icon-16.png",
"48": "assets/icon-48.png",
Expand Down
11 changes: 10 additions & 1 deletion packages/extension/src/pages/ibc-swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,19 @@ export const IBCSwapPage: FunctionComponent = observer(() => {
const swapReceiver: string[] = [];

try {
let swapRouteKey = "";
if (queryRoute.response) {
swapRouteKey =
ibcSwapConfigs.amountConfig.createSwapRouteKeyFromRouteResponse(
queryRoute.response.data
);
}

const [_tx] = await Promise.all([
ibcSwapConfigs.amountConfig.getTx(
uiConfigStore.ibcSwapConfig.slippageNum,
SwapFeeBps.receiver
SwapFeeBps.receiver,
swapRouteKey
),
// queryRoute는 ibc history를 추적하기 위한 채널 정보 등을 얻기 위해서 사용된다.
// /msgs_direct로도 얻을 순 있지만 따로 데이터를 해석해야되기 때문에 좀 힘들다...
Expand Down
22 changes: 11 additions & 11 deletions packages/hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keplr-wallet/hooks",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"main": "build/index.js",
"author": "chainapsis",
"license": "Apache-2.0",
Expand All @@ -17,16 +17,16 @@
},
"dependencies": {
"@ethersproject/address": "^5.6.0",
"@keplr-wallet/background": "0.12.57",
"@keplr-wallet/common": "0.12.57",
"@keplr-wallet/cosmos": "0.12.57",
"@keplr-wallet/crypto": "0.12.57",
"@keplr-wallet/proto-types": "0.12.57",
"@keplr-wallet/simple-fetch": "0.12.57",
"@keplr-wallet/stores": "0.12.57",
"@keplr-wallet/stores-etc": "0.12.57",
"@keplr-wallet/types": "0.12.57",
"@keplr-wallet/unit": "0.12.57",
"@keplr-wallet/background": "0.12.58-rc.2",
"@keplr-wallet/common": "0.12.58-rc.2",
"@keplr-wallet/cosmos": "0.12.58-rc.2",
"@keplr-wallet/crypto": "0.12.58-rc.2",
"@keplr-wallet/proto-types": "0.12.58-rc.2",
"@keplr-wallet/simple-fetch": "0.12.58-rc.2",
"@keplr-wallet/stores": "0.12.58-rc.2",
"@keplr-wallet/stores-etc": "0.12.58-rc.2",
"@keplr-wallet/types": "0.12.58-rc.2",
"@keplr-wallet/unit": "0.12.58-rc.2",
"buffer": "^6.0.3",
"long": "^4.0.0",
"utility-types": "^3.10.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/ledger-cosmos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keplr-wallet/ledger-cosmos",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"main": "build/index.js",
"author": "chainapsis",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/popup/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keplr-wallet/popup",
"version": "0.12.57",
"version": "0.12.58-rc.2",
"main": "build/index.js",
"author": "chainapsis",
"license": "Apache-2.0",
Expand Down
Loading

0 comments on commit 23023ba

Please sign in to comment.