Skip to content

Commit

Permalink
style(portfolio): merge with stage
Browse files Browse the repository at this point in the history
  • Loading branch information
mattupham committed Oct 25, 2024
2 parents a711be6 + b663a85 commit b0ced03
Show file tree
Hide file tree
Showing 116 changed files with 5,604 additions and 1,732 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"publish:libs": "lerna publish",
"machine-translate": "inlang machine translate -f --project ./project.inlang && yarn lint:fix",
"lint:workspace": "npx sherif@latest --ignore-package ./packages/keplr-hooks --ignore-package ./packages/keplr-stores",
"lint:workspace:fix": "yarn lint:workspace -f",
"postinstall": "yarn lint:workspace"
},
"pre-commit": [
Expand Down
2 changes: 2 additions & 0 deletions packages/bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
"@osmosis-labs/utils": "^1.0.0",
"base-x": "^5.0.0",
"cachified": "^3.5.4",
"launchdarkly-node-client-sdk": "^3.3.0",
"long": "^5.2.3",
"lru-cache": "^10.0.1",
"nomic-bitcoin": "^4.2.0",
"viem": "^2.21.19",
"zod": "^3.22.4"
},
Expand Down
45 changes: 27 additions & 18 deletions packages/bridge/src/axelar/__tests__/axelar-bridge-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe("AxelarBridgeProvider", () => {
.spyOn(provider, "getAssetTransferClient")
.mockResolvedValue(mockDepositClient as unknown as AxelarAssetTransfer);

const depositAddress = await provider.getDepositAddress({
const depositAddress = await provider.getAxelarDepositAddress({
fromChain: { chainId: 1, chainName: "Ethereum", chainType: "evm" },
toChain: {
chainId: "osmosis-1",
Expand All @@ -122,7 +122,7 @@ describe("AxelarBridgeProvider", () => {

it("should throw an error for unsupported chains", async () => {
await expect(
provider.getDepositAddress({
provider.getAxelarDepositAddress({
fromChain: {
chainId: 989898989898,
chainName: "Unsupported",
Expand Down Expand Up @@ -336,23 +336,27 @@ describe("AxelarBridgeProvider", () => {

expect(transaction).toEqual({
type: "cosmos",
msgTypeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
msg: {
receiver: "0x1234567890abcdef1234567890abcdef12345678",
sender: "cosmos1...",
sourceChannel: "channel-208",
sourcePort: "transfer",
timeoutHeight: {
revisionHeight: "1000",
revisionNumber: "1",
},
timeoutTimestamp: "0",
token: {
amount: "1000000",
denom:
"ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858",
msgs: [
{
typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
value: {
receiver: "0x1234567890abcdef1234567890abcdef12345678",
sender: "cosmos1...",
sourceChannel: "channel-208",
sourcePort: "transfer",
timeoutHeight: {
revisionHeight: "1000",
revisionNumber: "1",
},
timeoutTimestamp: "0",
token: {
amount: "1000000",
denom:
"ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858",
},
},
},
},
],
});
});

Expand Down Expand Up @@ -515,6 +519,7 @@ describe("AxelarBridgeProvider", () => {
"ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858",
decimals: 6,
},
direction: "deposit",
});

expect(sourceVariants).toEqual([
Expand All @@ -526,6 +531,7 @@ describe("AxelarBridgeProvider", () => {
coinGeckoId: "usd-coin",
decimals: 6,
denom: "USDC",
transferTypes: ["quote"],
},
]);
});
Expand All @@ -542,6 +548,7 @@ describe("AxelarBridgeProvider", () => {
"ibc/EA1D43981D5C9A1C4AAEA9C23BB1D4FA126BA9BC7020A25E0AE4AA841EA25DC5",
decimals: 6,
},
direction: "deposit",
});

expect(sourceVariants).toEqual([
Expand All @@ -553,6 +560,7 @@ describe("AxelarBridgeProvider", () => {
coinGeckoId: "weth",
decimals: 18,
denom: "WETH",
transferTypes: ["quote"],
},
{
// this is the denom accepted by Axelar APIs
Expand All @@ -563,6 +571,7 @@ describe("AxelarBridgeProvider", () => {
coinGeckoId: "weth",
decimals: 18,
denom: "ETH",
transferTypes: ["quote"],
},
]);
});
Expand Down
40 changes: 21 additions & 19 deletions packages/bridge/src/axelar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import {
BridgeAsset,
BridgeChain,
BridgeCoin,
BridgeDepositAddress,
BridgeExternalUrl,
BridgeProvider,
BridgeProviderContext,
BridgeQuote,
BridgeSupportedAsset,
BridgeTransactionRequest,
CosmosBridgeTransactionRequest,
EvmBridgeTransactionRequest,
Expand All @@ -39,7 +39,7 @@ import {
GetBridgeSupportedAssetsParams,
GetDepositAddressParams,
} from "../interface";
import { BridgeAssetMap } from "../utils";
import { BridgeAssetMap } from "../utils/asset";
import { getAxelarAssets, getAxelarChains } from "./queries";

export class AxelarBridgeProvider implements BridgeProvider {
Expand Down Expand Up @@ -227,7 +227,9 @@ export class AxelarBridgeProvider implements BridgeProvider {
async getSupportedAssets({
chain,
asset,
}: GetBridgeSupportedAssetsParams): Promise<(BridgeChain & BridgeAsset)[]> {
}: GetBridgeSupportedAssetsParams): Promise<
(BridgeChain & BridgeSupportedAsset)[]
> {
try {
// get origin axelar asset info from given toAsset
const [axelarAssets, axelarChains] = await Promise.all([
Expand Down Expand Up @@ -272,7 +274,9 @@ export class AxelarBridgeProvider implements BridgeProvider {
axelarChainId
);

const foundVariants = new BridgeAssetMap<BridgeChain & BridgeAsset>();
const foundVariants = new BridgeAssetMap<
BridgeChain & BridgeSupportedAsset
>();

// return just origin asset and the unwrapped version for now, but
// can return other axl-versions later if wanted
Expand Down Expand Up @@ -320,6 +324,7 @@ export class AxelarBridgeProvider implements BridgeProvider {
axelarSourceAsset.denom,
{
...chainInfo,
transferTypes: ["quote"],
chainName: axelarChain.name,
denom: addressAsset.symbol,
address: assetAddress,
Expand Down Expand Up @@ -350,6 +355,7 @@ export class AxelarBridgeProvider implements BridgeProvider {
address: NativeEVMTokenConstantAddress,
decimals: axelarChain.native_token.decimals,
coinGeckoId: axelarSourceAsset.coingecko_id,
transferTypes: ["quote"],
}
);
}
Expand Down Expand Up @@ -418,14 +424,11 @@ export class AxelarBridgeProvider implements BridgeProvider {
chainId: params.fromChain.chainId.toString(),
chainList: this.ctx.chainList,
body: {
messages: [
(
await this.getProtoRegistry()
).encodeAsAny({
typeUrl: transactionData.msgTypeUrl,
value: transactionData.msg,
}),
],
messages: await Promise.all(
transactionData.msgs.map(async (msg) =>
(await this.getProtoRegistry()).encodeAsAny(msg)
)
),
},
bech32Address: params.fromAddress,
fallbackGasLimit: makeIBCTransferMsg.gas,
Expand Down Expand Up @@ -521,7 +524,7 @@ export class AxelarBridgeProvider implements BridgeProvider {
}): Promise<EvmBridgeTransactionRequest> {
const { depositAddress } = simulated
? { depositAddress: fromAddress }
: await this.getDepositAddress({
: await this.getAxelarDepositAddress({
fromChain,
toChain,
fromAsset,
Expand Down Expand Up @@ -563,7 +566,7 @@ export class AxelarBridgeProvider implements BridgeProvider {
try {
const { depositAddress } = simulated
? { depositAddress: fromAddress }
: await this.getDepositAddress({
: await this.getAxelarDepositAddress({
fromChain,
toChain,
fromAsset,
Expand Down Expand Up @@ -611,8 +614,7 @@ export class AxelarBridgeProvider implements BridgeProvider {

return {
type: "cosmos",
msgTypeUrl: typeUrl,
msg,
msgs: [{ typeUrl, value: msg }],
};
} catch (e) {
const error = e as Error | BridgeQuoteError;
Expand All @@ -629,13 +631,13 @@ export class AxelarBridgeProvider implements BridgeProvider {
}
}

async getDepositAddress({
async getAxelarDepositAddress({
fromChain,
toChain,
fromAsset,
toAsset,
toAddress,
}: GetDepositAddressParams): Promise<BridgeDepositAddress> {
}: GetDepositAddressParams) {
const fromChainAxelarId = await this.getAxelarChainId(fromChain);
const toChainAxelarId = await this.getAxelarChainId(toChain);
const autoUnwrapIntoNative =
Expand All @@ -649,7 +651,7 @@ export class AxelarBridgeProvider implements BridgeProvider {
fromAsset.address
}/${Boolean(autoUnwrapIntoNative)}`,
ttl: process.env.NODE_ENV === "test" ? -1 : 30 * 60 * 1000, // 30 minutes
getFreshValue: async (): Promise<BridgeDepositAddress> => {
getFreshValue: async () => {
const [depositClient, toAssetAxelarId] = await Promise.all([
this.getAssetTransferClient(),
this.getAxelarAssetId(fromChain, fromAsset),
Expand Down
2 changes: 2 additions & 0 deletions packages/bridge/src/ibc/__tests__/ibc-bridge-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ describe("IbcBridgeProvider", () => {
"ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",
decimals: 6,
},
direction: "deposit",
});

expect(supportedAssets).toEqual([
Expand All @@ -280,6 +281,7 @@ describe("IbcBridgeProvider", () => {
denom: "ATOM",
address: "uatom",
decimals: 6,
transferTypes: ["quote"],
},
]);
});
Expand Down
Loading

0 comments on commit b0ced03

Please sign in to comment.