Skip to content

Commit

Permalink
Merge pull request #713 from skip-mev/sync-main-with-staging
Browse files Browse the repository at this point in the history
Sync main with staging
  • Loading branch information
toddkao authored Jan 24, 2025
2 parents 2ad942b + 749eea4 commit 4fbd840
Show file tree
Hide file tree
Showing 78 changed files with 802 additions and 328 deletions.
6 changes: 6 additions & 0 deletions .changeset/clean-owls-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@skip-go/client": patch
"@skip-go/widget": patch
---

update registries
6 changes: 6 additions & 0 deletions .changeset/cuddly-planets-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@skip-go/widget": patch
---

Update theme colors to use background instead of background-color to support gradients

5 changes: 5 additions & 0 deletions .changeset/dry-lobsters-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/client": patch
---

Fix error with msgsDirect if smartRelay is false
5 changes: 5 additions & 0 deletions .changeset/gold-dots-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/widget": patch
---

Update mobile Asset/Chain selector modal to avoid word wrapping with small screen widths
5 changes: 5 additions & 0 deletions .changeset/gorgeous-zebras-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/widget": patch
---

Add enableSentrySessionReplays prop, add widget version as a tag
5 changes: 5 additions & 0 deletions .changeset/green-boxes-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/widget": patch
---

Simplify search to use substring search
5 changes: 5 additions & 0 deletions .changeset/large-bees-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/widget": patch
---

Turn on 100% session sample rate (if enableSentrySessionReplays = true)
5 changes: 5 additions & 0 deletions .changeset/lazy-adults-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/widget": patch
---

Fix bug with pulsing 0 input onload
5 changes: 5 additions & 0 deletions .changeset/nine-news-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/widget": patch
---

Fix infinite balance spinner if using tanstack/query v4
5 changes: 5 additions & 0 deletions .changeset/old-poets-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/widget": patch
---

enable mobile wallets for getting the address
5 changes: 5 additions & 0 deletions .changeset/quiet-cups-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/widget": patch
---

only single tx routes on mobile
5 changes: 5 additions & 0 deletions .changeset/red-dots-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/widget": patch
---

Fix disabled button text color
5 changes: 5 additions & 0 deletions .changeset/short-files-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/widget": patch
---

Add more data to tx callbacks
5 changes: 5 additions & 0 deletions .changeset/tiny-crews-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@skip-go/client": patch
---

add userAddresses validation before executeRoute
102 changes: 102 additions & 0 deletions docs/legal-and-privacy/privacy-policy.mdx

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions docs/legal-and-privacy/terms-of-service.mdx

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@
"support-requirements/swap-venue-requirements"
]
},
{
"group": "Legal and Privacy",
"pages": [
"legal-and-privacy/terms-of-service",
"legal-and-privacy/privacy-policy"
]
},
{
"group": "Prod Endpoints",
"pages": [
Expand Down
16 changes: 16 additions & 0 deletions docs/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,11 @@ paths:
allow_unsafe:
type: boolean
description: Toggles whether the api should return routes that fail price safety checks.
experimental_features:
type: array
description: Array of experimental features to enable
items:
type: string
bridges:
type: array
description: Array of bridges to use
Expand Down Expand Up @@ -1325,6 +1330,11 @@ paths:
allow_unsafe:
type: boolean
description: Toggles whether the api should return routes that fail price safety checks.
experimental_features:
type: array
description: Array of experimental features to enable
items:
type: string
bridges:
type: array
description: Array of bridges to use
Expand Down Expand Up @@ -2563,11 +2573,17 @@ components:
* `AXELAR` - Axelar Bridge
* `CCTP` - CCTP Bridge
* `HYPERLANE` - Hyperlane Bridge
* `OPINIT` - Opinit Bridge
* `GO_FAST` - Go Fast Bridge
* `STARGATE` - Stargate Bridge
enum:
- IBC
- AXELAR
- CCTP
- HYPERLANE
- OPINIT
- GO_FAST
- STARGATE
Chain:
properties:
chain_name:
Expand Down
18 changes: 16 additions & 2 deletions docs/widget/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,20 @@ endpointOptions?: {

String to override default Skip Go API proxied endpoints. Whitelisting required, reach out [here](https://skip.build/discord).

### `brandColor`

Customizes the main highlight color of the widget

### `theme`

Customize widget appearance.
Advanced widget appearance customization options

```tsx
theme? = {
brandColor: string;
primary: {
background: {
normal: string;
transparent: string;
};
text: {
normal: string;
Expand Down Expand Up @@ -207,11 +209,23 @@ onTransactionBroadcasted?: (params: {
txHash: string;
chainId: string;
explorerLink?: string;
sourceAddress: string;
destinationAddress: string;
sourceAssetDenom: string;
sourceAssetChainID: string;
destAssetDenom: string;
destAssetChainID: string;
}) => void;
onTransactionComplete?: (params: {
txHash: string;
chainId: string;
explorerLink?: string;
sourceAddress: string;
destinationAddress: string;
sourceAssetDenom: string;
sourceAssetChainID: string;
destAssetDenom: string;
destAssetChainID: string;
}) => void;
onTransactionFailed?: (params: { error: Error }) => void;
```
Expand Down
4 changes: 2 additions & 2 deletions docs/widget/web-component.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ Props are the same as [`WidgetProps`](./configuration), but passed as attributes

```tsx
<div style="width:100%; max-width:500px; padding:0 10px;">
<swap-widget
<skip-widget
theme='{
"brandColor": "#FF4FFF",
}'
default-route='{
"srcChainId": "osmosis-1",
"srcAssetDenom": "ibc/1480b8fd20ad5fcae81ea87584d269547dd4d436843c1d20f15e00eb64743ef4"
}'
></swap-widget>
></skip-widget>
</div>
```

Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@protobufs/gogoproto": "0.0.10",
"@protobufs/google": "0.0.10",
"@types/keccak": "3.0.4",
"chain-registry": "^1.69.95",
"chain-registry": "^1.69.102",
"minimatch": "^9.0.3",
"proxy-from-env": "^1.1.0",
"vitest": "^1.2.2"
Expand Down
55 changes: 51 additions & 4 deletions packages/client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable prefer-const */
import { makeSignDoc as makeSignDocAmino } from "@cosmjs/amino";
import { createWasmAminoConverters } from "@cosmjs/cosmwasm-stargate";
import { fromBase64 } from "@cosmjs/encoding";
import { fromBase64, fromBech32 } from "@cosmjs/encoding";
import { Int53 } from "@cosmjs/math";
import { Decimal } from "@cosmjs/math";
import { makePubkeyAnyFromAccount } from "./proto-signing/pubkey";
Expand Down Expand Up @@ -42,7 +42,7 @@ import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { MsgExecute } from "./codegen/initia/move/v1/tx";

import { maxUint256, publicActions, WalletClient } from "viem";
import { isAddress, maxUint256, publicActions, WalletClient } from "viem";

import { chains, findFirstWorkingEndpoint } from "./chains";
import {
Expand All @@ -69,7 +69,7 @@ import * as types from "./types";
import * as clientTypes from "./client-types";
import { msgsDirectRequestToJSON } from "./types/converters";
import { Adapter } from "@solana/wallet-adapter-base";
import { Connection, Transaction } from "@solana/web3.js";
import { Connection, PublicKey, Transaction } from "@solana/web3.js";
import { MsgInitiateTokenDeposit } from "./codegen/opinit/ophost/v1/tx";
import { createCachingMiddleware, CustomCache } from "./cache";

Expand Down Expand Up @@ -258,6 +258,13 @@ export class SkipClient {
raise("executeRoute error: invalid address list");
}

const isUserAddressesValid =
await this.validateUserAddresses(userAddresses);

if (!isUserAddressesValid) {
raise("executeRoute error: invalid user addresses");
}

const messages = await this.messages({
...route,
amountOut: route.estimatedAmountOut || "0",
Expand Down Expand Up @@ -541,7 +548,7 @@ export class SkipClient {
],
});

if (allowance > BigInt(requiredApproval.amount)) {
if (allowance >= BigInt(requiredApproval.amount)) {
continue;
}
onApproveAllowance?.({
Expand Down Expand Up @@ -1827,6 +1834,46 @@ export class SkipClient {
}
return feeUsed;
}

async validateUserAddresses(userAddresses: clientTypes.UserAddress[]) {
const chains = await this.chains({
includeEVM: true,
includeSVM: true,
});

const validations = userAddresses.map((userAddress) => {
const chain = chains.find(
(chain) => chain.chainID === userAddress.chainID,
);

switch (chain?.chainType) {
case types.ChainType.Cosmos:
try {
const { prefix } = fromBech32(userAddress.address);
return chain.bech32Prefix === prefix;
} catch (_error) {
return false;
}
case types.ChainType.EVM:
try {
return isAddress(userAddress.address);
} catch (_error) {
return false;
}
case types.ChainType.SVM:
try {
const publicKey = new PublicKey(userAddress.address);
return PublicKey.isOnCurve(publicKey);
} catch (_error) {
return false;
}
default:
return false;
}
});

return validations.every((validation) => validation);
}
}

function validateChainIDsToAffiliates(
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/codegen/chains.json

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions packages/client/src/types/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,9 @@ export function cctpTransferFromJSON(value: CCTPTransferJSON): CCTPTransfer {
denomIn: value.denom_in,
denomOut: value.denom_out,
smartRelay: value.smart_relay,
smartRelayFeeQuote: smartRelayFeeQuoteFromJSON(value.smart_relay_fee_quote),
smartRelayFeeQuote: value?.smart_relay_fee_quote
? smartRelayFeeQuoteFromJSON(value.smart_relay_fee_quote)
: undefined,
};
}

Expand All @@ -1661,7 +1663,9 @@ export function cctpTransferToJSON(value: CCTPTransfer): CCTPTransferJSON {
denom_in: value.denomIn,
denom_out: value.denomOut,
smart_relay: value.smartRelay,
smart_relay_fee_quote: smartRelayFeeQuoteToJSON(value.smartRelayFeeQuote),
smart_relay_fee_quote: value?.smartRelayFeeQuote
? smartRelayFeeQuoteToJSON(value.smartRelayFeeQuote)
: undefined,
};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/types/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export type CCTPTransferJSON = {
denom_in: string;
denom_out: string;
smart_relay: boolean;
smart_relay_fee_quote: SmartRelayFeeQuoteJSON;
smart_relay_fee_quote?: SmartRelayFeeQuoteJSON;
};

export type CCTPTransfer = {
Expand All @@ -304,7 +304,7 @@ export type CCTPTransfer = {
denomIn: string;
denomOut: string;
smartRelay: boolean;
smartRelayFeeQuote: SmartRelayFeeQuote;
smartRelayFeeQuote?: SmartRelayFeeQuote;
};

export type HyperlaneTransferJSON = {
Expand Down
3 changes: 1 addition & 2 deletions packages/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@typescript-eslint/parser": "^7.15.0",
"@vitejs/plugin-react": "^4.3.1",
"buffer": "^6.0.3",
"chain-registry": "^1.69.95",
"chain-registry": "^1.69.102",
"eslint": "^9.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
Expand Down Expand Up @@ -120,7 +120,6 @@
"jotai-effect": "^1.0.2",
"jotai-tanstack-query": "^0.8.6",
"lodash.debounce": "^4.0.8",
"match-sorter": "^6.3.4",
"pluralize": "^8.0.0",
"rc-virtual-list": "^3.14.5",
"react-error-boundary": "^4.0.13",
Expand Down
6 changes: 3 additions & 3 deletions packages/widget/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const GhostButton = styled(SmallText).attrs({
${({ alwaysShowBackground, theme, secondary }) => {
if (alwaysShowBackground) {
return css`
background-color: ${secondary
background: ${secondary
? theme.secondary.background.normal
: theme.primary.ghostButtonHover};
`;
Expand All @@ -29,7 +29,7 @@ export const GhostButton = styled(SmallText).attrs({
if (onClick && !disabled) {
return css`
&:hover {
background-color: ${secondary
background: ${secondary
? theme.secondary.background.normal
: theme.primary.ghostButtonHover};
color: ${theme.primary.text.normal};
Expand Down Expand Up @@ -68,7 +68,7 @@ export const PillButton = styled(Button)`
height: 28px;
border-radius: 30px;
box-sizing: border-box;
background-color: ${({ theme }) => theme.secondary.background.normal};
background: ${({ theme }) => theme.secondary.background.normal};
gap: 10px;
align-items: center;
justify-content: center;
Expand Down
Loading

0 comments on commit 4fbd840

Please sign in to comment.