Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deposit/Withdraw: IBC bridge provider #3273

Merged
merged 64 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
e59dce9
move logos out of bridge package
jonator May 15, 2024
9745297
provider IDs
jonator May 15, 2024
8f7042d
WIP add IBC provider
jonator May 15, 2024
75bb4f1
Merge branch 'stage' into jon/fe-448-create-ibc-bridge-provider
jonator May 16, 2024
b49ce44
Merge branch 'stage' into jon/fe-448-create-ibc-bridge-provider
jonator May 17, 2024
fc60ced
WIP tx and trpc packages
jonator May 17, 2024
7dd3748
lint
jonator May 17, 2024
d4cbbd5
fix tests
jonator May 17, 2024
20fe144
fix scripts
jonator May 17, 2024
aedc4e3
reduce redundant naming of router files
jonator May 17, 2024
ba0f09a
fix: circular dep router import
JoseRFelix May 17, 2024
0ceccca
fix: enable declaration
JoseRFelix May 17, 2024
5593181
move gas estimation to tx package
jonator May 20, 2024
29e9ebd
add type assertions to mock query functions
jonator May 20, 2024
f4ce63b
Merge branch 'stage' into jon/fe-448-create-ibc-bridge-provider
jonator May 22, 2024
479376e
Integrate /tx package into existing gas estimation
jonator May 22, 2024
2669ace
fix loading state
jonator May 22, 2024
a018c8d
remove base account store estimate gas
jonator May 22, 2024
8b2dc9c
Merge branch 'stage' into jon/fe-448-create-ibc-bridge-provider
jonator May 23, 2024
8b04b8d
add -f to clean
jonator May 23, 2024
4504613
Merge branch 'stage' into jon/fe-448-create-ibc-bridge-provider
jonator May 23, 2024
2ae49bc
update estimation params
jonator May 23, 2024
5cb2ab7
remove custom fee type
jonator May 23, 2024
f6ef210
loading state
jonator May 23, 2024
4b9ee80
prevent extra querying
jonator May 24, 2024
3997c56
WIP get spent coins from simulate tx events
jonator May 24, 2024
7e26909
pass coins spent
jonator May 24, 2024
9b02da5
pass tests
jonator May 24, 2024
4b7e119
remove send token from client logic, cleanup unused params
jonator May 24, 2024
5b2ebcb
add warning
jonator May 24, 2024
e86a37a
fix tests
jonator May 24, 2024
c5dbee8
expand tests
jonator May 24, 2024
65770cd
fix invalid gas query
jonator May 27, 2024
f98bd25
implement IBC provider
jonator May 28, 2024
d68e77a
get correct IBC channel info
jonator May 28, 2024
17822da
fix
jonator May 28, 2024
1261199
add ibc status source
jonator May 29, 2024
1e6e627
use block time in timout delay buffer
jonator May 29, 2024
8a4c4a6
comment
jonator May 29, 2024
8d1290d
fix tests
jonator May 29, 2024
75e3681
fix FE tests
jonator May 29, 2024
7d60c44
invalidate user queries
jonator May 30, 2024
876a867
review fixes and test improvements
jonator May 30, 2024
16660be
improve error handling
jonator May 30, 2024
9e19fe5
catch error
jonator May 30, 2024
afacbc0
Merge branch 'stage' into jon/fe-448-create-ibc-bridge-provider
jonator May 30, 2024
a913744
log
jonator May 30, 2024
c0fb283
show more specific error
jonator May 30, 2024
b67ae09
check if the balance is last in balance array
jonator May 31, 2024
5babed4
update logic with return statements
jonator May 31, 2024
5b8be98
match additional error
jonator May 31, 2024
056ada8
Fix including base fee denom
jonator May 31, 2024
2e7d85f
update tests
jonator May 31, 2024
ba8b626
check for unspent balances first
jonator May 31, 2024
8273e87
remove checks
jonator May 31, 2024
99c43da
prioritize lower spent fee amounts
jonator May 31, 2024
796296b
add test case
jonator May 31, 2024
ffab0b0
tweak swap tool loading UI
jonator May 31, 2024
77167c6
unify loading states in UI
jonator May 31, 2024
a1cfe02
unify isSendingTx state
jonator May 31, 2024
5eb316e
fix test
jonator May 31, 2024
eb1330b
fix wallet disconnected loading state
jonator May 31, 2024
ea8df8d
add caching to gas estimation
jonator May 31, 2024
54c7128
fix dep
jonator May 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ src/styles/index.scss
.turbo

lerna-debug.log
coverage

tsconfig.tsbuildinfo
16 changes: 11 additions & 5 deletions .vscode/osmosis-frontend.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,25 @@
"path": "../packages/proto-codecs/"
},
{
"path": "../packages/bridge/"
"path": "../packages/types/"
},
{
"path": "../packages/server/"
"path": "../packages/tx/"
},
{
"path": "../packages/stores/"
"path": "../packages/trpc/"
},
{
"path": "../packages/types/"
"path": "../packages/utils/"
},
{
"path": "../packages/utils/"
"path": "../packages/bridge/"
},
{
"path": "../packages/stores/"
},
{
"path": "../packages/server/"
},
{
"path": "../packages/web/"
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

![osmosis-banner-1200w](https://user-images.githubusercontent.com/4606373/167008669-fb3cafa8-e66e-4cdf-8599-3308039cc58c.png)

> Note: this codebase is currently undergoing a refactor from Keplr's architecture to a tRPC stack to improve performance, maintainability, and development speed. We appreciate your patience as we work through these changes.

## Overview 💻

Our [frontend](https://app.osmosis.zone) is built with the following tools:
Expand Down Expand Up @@ -63,7 +65,7 @@ To develop on the canonical public testnet, run:
yarn build:testnet && yarn start:testnet
```

To develop against a local testnet, such as [localosmosis](https://github.com/osmosis-labs/osmosis/blob/1eb6506297c88dd3acc7d9c0a5f7c4e34ecd1b4e/tests/localosmosis/README.md), modify the .env file:
To develop against a local testnet, such as [localosmosis](https://github.com/osmosis-labs/osmosis/blob/1eb6506297c88dd3acc7d9c0a5f7c4e34ecd1b4e/tests/localosmosis/README.md), set this in your .env.local file in web package root:

```bash
# Osmosis Chain Configuration Overwrite
Expand Down Expand Up @@ -97,6 +99,8 @@ Note: our currency registrar checks IBC hashes to see if they can be found via t

## Releases

> Note: releases are suspended until the refactor is complete. Please avoid importing packages from this repo until further notice.

Release tags are for the published [npm packages](https://www.npmjs.com/org/osmosis-labs), which are every package except for the web package. Updates to the app are released incrementally way via deployments from master branch.

To start the release process:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]
},
"scripts": {
"dev": "turbo dev --concurrency 12",
"dev": "turbo dev --concurrency 14",
"dev:testnet": "dotenv -v NEXT_PUBLIC_IS_TESTNET=true -- yarn dev",
"start": "turbo start",
"start:testnet": "dotenv -v NEXT_PUBLIC_IS_TESTNET=true -- yarn start",
Expand Down
12 changes: 5 additions & 7 deletions packages/bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,27 @@
],
"license": "Apache-2.0",
"scripts": {
"clean": "rm -rf node_modules; rm -rf build; rm tsconfig.tsbuildinfo",
"clean": "rm -rf node_modules; rm -rf build; rm -f tsconfig.tsbuildinfo",
"build": "tsc",
"dev": "tsc -w",
"test": "jest --passWithNoTests",
"test:e2e": "yarn with-env is-ci-cli test:e2e:ci test:e2e:dev",
"test:e2e:dev": "jest --testMatch '**/__tests_e2e__/?(*.)+(spec|test).[jt]s?(x)' --watch",
"test:e2e:ci": "jest --testMatch '**/__tests_e2e__/?(*.)+(spec|test).[jt]s?(x)' --ci",
"lint": "eslint \"src/**/*.+(js|ts|tsx|json)\" && prettier --check \"src/**/*.+(js|ts|tsx|json)\"",
"lint:fix": "eslint --fix \"src/**/*.+(js|ts|tsx|json)\" && prettier --write \"src/**/*.+(js|ts|tsx|json)\"",
"prepare": "yarn build",
"with-env": "dotenv -e ../web/.env -c --"
"prepare": "yarn build"
},
"dependencies": {
"@0xsquid/sdk": "^1.14.0",
"@axelar-network/axelarjs-sdk": "0.16.0",
"@cosmjs/encoding": "0.32.3",
"@cosmjs/proto-signing": "0.32.3",
"@keplr-wallet/unit": "0.10.24-ibc.go.v7.hot.fix",
"@osmosis-labs/proto-codecs": "^5.1.0",
"@osmosis-labs/server": "^1.0.0",
"@osmosis-labs/types": "^1.0.0",
"@osmosis-labs/tx": "^1.0.0",
"@osmosis-labs/utils": "^1.0.0",
"cachified": "^3.5.4",
"ethers": "^6.8.0",
"jest-util": "^29.7.0",
"long": "^5.2.3",
"lru-cache": "^10.0.1",
"web3-utils": "^1.7.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ describe("AxelarBridgeProvider", () => {
max: 500,
}),
assetLists: MockAssetLists,
// not used
chainList: [],
getTimeoutHeight: jest.fn().mockResolvedValue({
revisionNumber: "1",
revisionHeight: "1000",
Expand Down
24 changes: 12 additions & 12 deletions packages/bridge/src/axelar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ import {
CosmosChainIds_AxelarChainIds,
} from "./types";

export const axelarProviderId = "Axelar" as const;

export class AxelarBridgeProvider implements BridgeProvider {
readonly providerName = axelarProviderId;
static readonly ID = "Axelar";
readonly providerName = AxelarBridgeProvider.ID;

// initialized via dynamic import
protected _queryClient: AxelarQueryAPI | null = null;
Expand Down Expand Up @@ -72,7 +71,7 @@ export class AxelarBridgeProvider implements BridgeProvider {
return cachified({
cache: this.ctx.cache,
key: JSON.stringify({
id: axelarProviderId,
id: AxelarBridgeProvider.ID,
fromAmount,
fromAsset,
fromChain,
Expand Down Expand Up @@ -106,12 +105,15 @@ export class AxelarBridgeProvider implements BridgeProvider {
}

const queryClient = await this.getQueryClient();
const transferFeeRes = await queryClient.getTransferFee(
fromChainAxelarId,
toChainAxelarId,
fromAsset.sourceDenom,
amount as any
);
const [transferFeeRes, gasCost] = await Promise.all([
queryClient.getTransferFee(
fromChainAxelarId,
toChainAxelarId,
fromAsset.sourceDenom,
amount as any
),
this.estimateGasCost(params),
]);

let transferLimitAmount: string | undefined;
try {
Expand All @@ -125,8 +127,6 @@ export class AxelarBridgeProvider implements BridgeProvider {
console.warn("Failed to get transfer limit. reason: ", e);
}

const gasCost = await this.estimateGasCost(params);

if (!transferFeeRes.fee) {
throw new BridgeQuoteError([
{
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge/src/axelar/transfer-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import type {
TransferStatusProvider,
TransferStatusReceiver,
} from "../interface";
import { axelarProviderId } from ".";
import { AxelarBridgeProvider } from ".";
import { getTransferStatus } from "./queries";

/** Tracks (polls Axelar endpoint) and reports status updates on Axelar bridge transfers. */
export class AxelarTransferStatusProvider implements TransferStatusProvider {
readonly keyPrefix = axelarProviderId;
readonly keyPrefix = AxelarBridgeProvider.ID;
readonly sourceDisplayName = "Axelar Bridge";
public statusReceiverDelegate?: TransferStatusReceiver;

Expand Down
1 change: 0 additions & 1 deletion packages/bridge/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/** A collection of errors that is itself an error. */
export class Errors extends Error {
errors: Array<{
errorType: string;
Expand Down
Loading
Loading