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

Release 23 Dec #611

Merged
merged 25 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f4d6c42
sync: main to staging (#575)
github-actions[bot] Dec 13, 2024
05c6885
[FRE-1327] fix/refactor: balance loading state (#572)
ericHgorski Dec 13, 2024
73e7081
feat: widget callbacks (#558)
toddkao Dec 17, 2024
0d6759f
[FRE-1330] Don't auto focus / pop up keyboard on asset selection on m…
toddkao Dec 17, 2024
666ea9f
feat: inject wallet (#586)
codingki Dec 17, 2024
d33addb
[FRE-1308] Mobile evm wallet (#581)
codingki Dec 17, 2024
6cd3ad5
[FRE-1332, FRE-1331] docs: enhance widget documentation with connecte…
ericHgorski Dec 17, 2024
a1a3c12
Sync main to staging 18 dec (#587)
codingki Dec 17, 2024
99c9744
fix: initialize query params state to undefined instead of an empty o…
ericHgorski Dec 17, 2024
0398899
[FRE-1151] feat: add asset and chain filtering for excluded token com…
ericHgorski Dec 17, 2024
b46bd1f
clean example logs (#591)
ericHgorski Dec 17, 2024
7ec222e
improve injected wallet example (#592)
ericHgorski Dec 18, 2024
a7e451e
[FRE-1345] feat: add daodao iframe options (#593)
codingki Dec 18, 2024
d324521
fix: handle undefined assets and chains in balance fetching logic (#594)
ericHgorski Dec 18, 2024
e2c673e
fix: improve loading state handling in source balance hook (#595)
ericHgorski Dec 18, 2024
608f08b
Merge branch 'main' into staging
ericHgorski Dec 19, 2024
3747467
fix: add missing transaction and wallet event handlers in widget init…
ericHgorski Dec 19, 2024
090655d
[FRE-1341] add types for Stargate operations (#577)
thal0x Dec 19, 2024
38b19cb
sync staging to main 19 dec (#601)
codingki Dec 19, 2024
ea59c36
[FRE-1360] fix: update button label and remove unused hook in SwapExe…
ericHgorski Dec 23, 2024
40a9229
[FRE-1357] fix: update SetAddressModal to use theme from useTheme and…
ericHgorski Dec 23, 2024
fa9b9c9
add error message field to GoFastTransferInfo (#606)
thal0x Dec 23, 2024
9628165
Update registries 23 dec 2024 (#609)
codingki Dec 23, 2024
2cff22b
Remove evm walletconnect (#610)
codingki Dec 23, 2024
7caf0cb
[FRE-1314] fix: filter available wallets in RenderWalletList componen…
ericHgorski Dec 23, 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
5 changes: 5 additions & 0 deletions .changeset/beige-terms-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@skip-go/widget': patch
---

show warning if ends in ibc transfer
5 changes: 5 additions & 0 deletions .changeset/gentle-suns-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@skip-go/widget': patch
---

Update post tx button to Go again
5 changes: 5 additions & 0 deletions .changeset/modern-ravens-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@skip-go/client': patch
---

add error message field on GoFastTransferInfo
5 changes: 5 additions & 0 deletions .changeset/moody-beers-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@skip-go/widget': patch
---

filter cosmos wallets for is available items
5 changes: 5 additions & 0 deletions .changeset/pretty-radios-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@skip-go/widget': patch
---

remove evm wallet connect
6 changes: 6 additions & 0 deletions .changeset/red-olives-do.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
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The `transfer_sequence` array consists of `TransferEvent` objects, which give de
* `AxelarTransferInfo`
* `HyperlaneTransferInfo`
* `GoFastTransferInfo`
* `StargateTransferInfo`

Each one contains slightly different data and statuses corresponding to the details of their bridge, but they all contain some standard info:
* `from_chain_id`
Expand Down Expand Up @@ -174,24 +175,47 @@ When one of the transfers is a `GoFastTransfer`, the `transfer_sequence` array w

Below are detailed explanations of the different fields and their purposes:

* `fromChainID`: The chain ID where the transfer originates (source chain).
* `toChainID`: The chain ID where the assets are being sent (destination chain).
* `from_chain_id`: The chain ID where the transfer originates (source chain).
* `to_chain_id`: The chain ID where the assets are being sent (destination chain).
* `state`: Indicates the current status of the transfer. Possible values are:
* `GO_FAST_TRANSFER_UNKNOWN`: An unknown error has occurred.
* `GO_FAST_TRANSFER_SENT`: The user's intent has been successfully submitted on the source chain.
* `GO_FAST_POST_ACTION_FAILED`: The transfer failed after the initial intent submission.
* `GO_FAST_POST_ACTION_FAILED`: The transfer's post-intent action failed. For example a swap on the destination chain failed due to slippage.
* `GO_FAST_TRANSFER_TIMEOUT`: The transfer did not complete within the expected time frame.
* `GO_FAST_TRANSFER_FILLED`: The transfer was successfully fulfilled on the destination chain.
* `GO_FAST_TRANSFER_REFUNDED`: The user's assets have been refunded on the source chain.
* `txs`: Contains transaction details related to the GoFast transfer:
* `orderSubmittedTx`: The transaction where the user called initiateIntent on the source chain.
* `orderFilledTx`: The transaction where the solver called fulfill on the destination chain.
* `orderRefundedTx`: The transaction where the user received a refund on the source chain, if applicable.
* `orderTimeoutTx`: The transaction indicating a timeout occurred in the transfer process.
* `order_submitted_tx`: The transaction where the user called initiateIntent on the source chain.
* `order_filled_tx`: The transaction where the solver called fulfill on the destination chain.
* `order_refunded_tx`: The transaction where the user received a refund on the source chain, if applicable.
* `order_timeout_tx`: The transaction indicating a timeout occurred in the transfer process.
* `error_message`: A message describing the error that occurred during the transfer, if applicable.


When tracking a Go Fast transfer, you can use the `GoFastTransferInfo` to monitor the progress and status of your asset transfer between chains. For instance, if the state is `GO_FAST_TRANSFER_FILLED`, you know that the transfer was successful and your assets should be available on the destination chain. If the state is `GO_FAST_TRANSFER_TIMEOUT`, you can check the `orderTimeoutTx` for details on the timeout event.

### Stargate Transfer Data

When one of the transfers is a `StargateTransfer`, the `transfer_sequence` array will include a `stargate_transfer` (`StargateTransferInfo`). This provides detailed information about a cross-chain asset transfer powered by Stargate, a popular cross-chain bridging protocol.

Below are detailed explanations of the fields and their purposes:

* `from_chain_id`: The chain ID where the transfer originates (source chain).
* `to_chain_id`: The chain ID where the assets are being sent (destination chain).

* `state`: Indicates the current status of the Stargate transfer. Possible values are:
* `STARGATE_TRANSFER_UNKNOWN`: An unknown error has occurred or the state cannot be determined.
* `STARGATE_TRANSFER_SENT`: The transfer has been successfully initiated on the source chain (i.e., the assets have left the source chain and are in transit).
* `STARGATE_TRANSFER_RECEIVED`: The transfer has been successfully completed on the destination chain (i.e., the assets are now available at the recipient address on the destination chain).
* `STARGATE_TRANSFER_FAILED`: The transfer encountered an error during bridging and did not complete as intended.

* `txs`: Contains transaction details related to the Stargate transfer.
* `send_tx`: The transaction on the source chain that initiated the Stargate transfer.
* `receive_tx`: The transaction on the destination chain where the assets were received.
* `error_tx`: A transaction (if any) related to the failure of the transfer.

When monitoring a Stargate transfer, you can use `StargateTransferInfo` to confirm that your assets have safely bridged between chains or identify if and where a problem has occurred.

<Info>
The Go Fast Protocol involves interactions with solvers who fulfill transfer intents. The additional transaction fields help provide transparency and traceability throughout the transfer process, ensuring users can track each step and identify any issues that may arise.
</Info>
Expand Down
88 changes: 57 additions & 31 deletions docs/widget/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -187,53 +187,79 @@ chainIdsToAffiliates: {
}
```

## Coming Soon

The following props are in development and will be available soon.

### `callbacks`

Event handling functions.

```ts
onWalletConnected?: ({ walletName: string, chainId: string, address?: string }) => void;
onWalletDisconnected?: ({ chainType?: string }) => void;
onTransactionBroadcasted?: ({ txHash: string, chainId: string, explorerLink: string }) => void;
onTransactionComplete?: ({ txHash: string, chainId: string, explorerLink: string }) => void;
onTransactionFailed?: ({ error: string }) => void;
onValidateGasBalance?: (value: {
chainID?: string;
txIndex?: number;
status: "success" | "error" | "pending" | "completed"
}) => Promise<void>;
onWalletConnected?: (params: {
walletName?: string;
chainIdToAddressMap: Record<string, string>;
address?: string;
}) => void;

onWalletDisconnected?: (params: {
walletName?: string;
chainType?: string;
}) => void;

onTransactionBroadcasted?: (params: {
txHash: string;
chainId: string;
explorerLink?: string;
}) => void;
onTransactionComplete?: (params: {
txHash: string;
chainId: string;
explorerLink?: string;
}) => void;
onTransactionFailed?: (params: { error: Error }) => void;
```

- `onWalletConnected`: Called when a wallet is connected.
- `onWalletDisconnected`: Called when a wallet is disconnected.
- `onTransactionBroadcasted`: Called when a transaction is broadcasted. This is called multiple times for multi-transaction routes.
- `onTransactionComplete`: Triggered when a transaction is completed.
- `onTransactionFailed`: Triggered when a transaction fails.
- `onValidateGasBalance`: Triggered when validating gas balance.

### `connectedWallet`
### `connectedAddresses` & `signers`

If your application has already connected to a user's wallet (e.g., via MetaMask for EVM networks, Phantom for Solana, or Keplr for Cosmos), you **must provide both** the `connectedAddresses` and corresponding signer functions in order to enable the widget’s injected wallet functionality.
See an implementation example [here](https://github.com/skip-mev/skip-go/tree/staging/examples/nextjs/src/app/injected/page.tsx).

Inject your own wallet provider into the `Widget`. See an implementation example [here](https://github.com/skip-mev/skip-go/blob/3a7dcadde0eb0604c795b6a3bc857e6d2209b7a7/examples/nextjs/pages/inject-wallet.tsx#L73).
`WalletClient` comes from the [`viem` package](https://viem.sh/docs/clients/wallet.html). `Adapter` comes from the [`@solana/wallet-adapter-base` package](https://solana.com/developers/cookbook/wallets/connect-wallet-react). And `OfflineSigner` comes from the [`@cosmjs` package](https://docs.keplr.app/api/cosmjs.html).

```ts
connectedWallet?: {
cosmos?: {
getAddress: (chainID: string) => Promise<string>;
getSigner: (chainID: string) => Promise<OfflineSigner>
};
evm?: {
getAddress: (chainID: string) => Promise<string>;
getSigner: (chainID: string) => Promise<WalletClient>;
};
svm?: {
getAddress: (chainID: string) => Promise<string>;
getSigner: () => Promise<Adapter>;
};
- **Type:** `Record<ChainId, Address>`

**Example:**
```typescript
const connectedAddresses: Record<string, string> = {
"1": "0x123...abc", // Ethereum mainnet address
"cosmoshub-4": "cosmos1...", // Cosmos Hub address
"solana": "3n9...xyz", // Solana address
// ... add more chain IDs and addresses as needed
};
```

### Signer Functions

Each signer function below must be implemented to fully leverage the injected wallet capabilities:

- **`getCosmosSigner(): Promise<OfflineSigner>`**
Returns a Cosmos-compatible signer.

- **`getEVMSigner(): Promise<WalletClient>`**
Returns an EVM-compatible signer (e.g., from `viem`).

- **`getSVMSigner(): Promise<PhantomWalletAdapter>`**
Returns a Solana-compatible signer, such as a `PhantomWalletAdapter`.

**Complete Example for injected wallet functionality:**
```jsx
<Widget
connectedAddresses={connectedAddresses}
getCosmosSigner={getCosmosSigner}
getEVMSigner={getEVMSigner}
getSVMSigner={getSVMSigner}
/>
```
43 changes: 43 additions & 0 deletions docs/widget/connected-wallet.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: 'Connected Wallet'

---

## Overview

If your application has already connected to a user's wallet (e.g., via MetaMask for EVM networks, Phantom for Solana, or Keplr for Cosmos), you can provide this information directly to the Widget. By doing so, the Widget will:

- Display and query balances for the user's already-connected wallet addresses for supported chains.
- Use the signer functions you provide to facilitate transactions, token swaps, or any operation that requires the user's signature.

This eliminates the need for the user to perform a separate connection flow within the widget itself, improving their overall experience and reducing friction.

<Info>
See a full code example [here](https://github.com/skip-mev/skip-go/tree/staging/examples/nextjs/src/app/injected/page.tsx).
</Info>

## Key Props and Concepts

### `connectedAddresses`

The `connectedAddresses` prop is a map from chain IDs to addresses. This map tells the widget which addresses are currently connected and should be used for transactions.

- **Type:** `Record<ChainId, Address>`
- **Example:**
```typescript
const accountMap: Record<string, string> = {
"1": "0x123...abc", // Ethereum mainnet address
"solana": "3n9...xyz", // Solana address
"cosmoshub-4": "cosmos1...", // Cosmos Hub address
...
};

### Signer Functions

In addition to passing in `connectedAddresses`, you must also provide the widget with signer functions so it can sign and send transactions on behalf of the user. These functions vary by chain type and are provided as separate props:

- `getCosmosSigner() => Promise<OfflineSigner>`
- `getEVMSigner() => Promise<WalletClient>`
- `getSVMSigner() => Promise<PhantomWalletAdapter>`

Each of these functions should return a signer (or signer-like interface) that the widget can use to create and broadcast transactions.
14 changes: 14 additions & 0 deletions examples/nextjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# nextjs

## 0.1.28

### Patch Changes

- dacf973: fix example default route and client asset search
- Updated dependencies [dacf973]
- Updated dependencies [dacf973]
- Updated dependencies [dacf973]
- Updated dependencies [dacf973]
- Updated dependencies [dacf973]
- Updated dependencies [dacf973]
- Updated dependencies [dacf973]
- @skip-go/[email protected]

## 0.1.27

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nextjs",
"version": "0.1.27",
"version": "0.1.28",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
Loading
Loading