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

add example: solana api example #62

Merged
merged 12 commits into from
May 27, 2024
Merged

add example: solana api example #62

merged 12 commits into from
May 27, 2024

Conversation

heyOnuoha
Copy link
Collaborator

@heyOnuoha heyOnuoha commented May 16, 2024

  • Examples: Refactor Solana API example to use both SDK + API: FIXES DX-55
  • Example: EVM <> Solana - API: FIXES DX-40

@heyOnuoha heyOnuoha self-assigned this May 16, 2024
Copy link

vercel bot commented May 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-directory ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 4:57pm
examples-swaps-sdk-nextjs-web3-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 4:57pm
swaps-api-nextjs-bitcoin ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 4:57pm
7 Ignored Deployments
Name Status Preview Comments Updated (UTC)
gas-widget-nextjs ⬜️ Ignored (Inspect) Visit Preview May 24, 2024 4:57pm
staking-sdk-nextjs ⬜️ Ignored (Inspect) Visit Preview May 24, 2024 4:57pm
staking-widget-nextjs ⬜️ Ignored (Inspect) Visit Preview May 24, 2024 4:57pm
swaps-sdk-nextjs ⬜️ Ignored (Inspect) Visit Preview May 24, 2024 4:57pm
swaps-sdk-nextjs-thirdweb-embedded-wallet ⬜️ Ignored (Inspect) Visit Preview May 24, 2024 4:57pm
swaps-widget-nextjs ⬜️ Ignored (Inspect) Visit Preview May 24, 2024 4:57pm
withdraw-widget-nextjs ⬜️ Ignored (Inspect) Visit Preview May 24, 2024 4:57pm

toChain: transferParams.toChain,
toTokenAddress: transferParams.toTokenAddress!,
toTokenSymbol: transferParams.toTokenSymbol!,
contractCall: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is contractCall true here? when it's false above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, that's a typo, will fix

};
```

## Sending a Token Approval Request for ERC20 Tokens (Optional)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this "Optional"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an optional step in the transfer flow if the source token is not an ERC20 token.

contractCall: true,
});

if (transferParams.fromChain !== "solana") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you checking if not solana? maybe add a comment why this is needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm checking the source chain to know whether I'm executing a SOL transaction or an Ethereum transaction. I'll add a comment there

Next, we will check if the user has a Solana-supported wallet installed. If the user does not have a supported wallet installed, we will prompt them to install one. If all is good, we will proceed to sign and send the transaction over to the network.

```typescript
try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you actually executed these steps yourself?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have


The `TransactionStatusParams` params contains the three properties, namely: `id`, `txHash` and `projectId`

URL: [https://swap.prod.swing.xyz/v0/transfer/status](https://developers.swing.xyz/reference/api/cross-chain/6b61efd1b798a-transfer-status)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing since you are fetching "/projects/{projectId}/transactions/{transactionId}" but are linking to https://swap.prod.swing.xyz/v0/transfer/status. that needs explanation or fixing or improving.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out, will fix that

@heyOnuoha heyOnuoha merged commit eec3c78 into main May 27, 2024
12 checks passed
@heyOnuoha heyOnuoha deleted the feat/solana-example branch May 27, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants