Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 0 additions & 6 deletions .changeset/dark-nights-unite.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/fluffy-streets-smoke.md

This file was deleted.

6 changes: 6 additions & 0 deletions apps/pay-test-exchange/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# pay-test-exchange

## 0.1.7

### Patch Changes

- [#4923](https://github.com/reown-com/appkit/pull/4923) [`b6adfdc`](https://github.com/reown-com/appkit/commit/b6adfdc1713daefb63393d9fa3a2cb2e31ba00e2) Thanks [@github-actions](https://github.com/apps/github-actions)! - Fixed an issue where Solana token-2022 token transfers failed because the send flow used legacy transfer instructions

## 0.1.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/pay-test-exchange/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pay-test-exchange",
"version": "0.1.6",
"version": "0.1.7",
"private": true,
"scripts": {
"dev": "next dev --turbopack --port 4001",
Expand Down
13 changes: 13 additions & 0 deletions packages/adapters/bitcoin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @reown/appkit-adapter-bitcoin

## 1.8.2

### Patch Changes

- [#4923](https://github.com/reown-com/appkit/pull/4923) [`b6adfdc`](https://github.com/reown-com/appkit/commit/b6adfdc1713daefb63393d9fa3a2cb2e31ba00e2) Thanks [@github-actions](https://github.com/apps/github-actions)! - Fixed an issue where Solana token-2022 token transfers failed because the send flow used legacy transfer instructions

- Updated dependencies [[`d412fdb`](https://github.com/reown-com/appkit/commit/d412fdbe4a10583844fc19fa5dae364a7e92a9ca), [`b6adfdc`](https://github.com/reown-com/appkit/commit/b6adfdc1713daefb63393d9fa3a2cb2e31ba00e2)]:
- @reown/appkit-controllers@1.8.2
- @reown/appkit@1.8.2
- @reown/appkit-utils@1.8.2
- @reown/appkit-common@1.8.2
- @reown/appkit-polyfills@1.8.2

## 1.8.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/bitcoin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reown/appkit-adapter-bitcoin",
"version": "1.8.1",
"version": "1.8.2",
"sideEffects": false,
"type": "module",
"main": "./dist/esm/exports/index.js",
Expand Down
15 changes: 15 additions & 0 deletions packages/adapters/ethers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @reown/appkit-adapter-ethers

## 1.8.2

### Patch Changes

- [#4923](https://github.com/reown-com/appkit/pull/4923) [`b6adfdc`](https://github.com/reown-com/appkit/commit/b6adfdc1713daefb63393d9fa3a2cb2e31ba00e2) Thanks [@github-actions](https://github.com/apps/github-actions)! - Fixed an issue where Solana token-2022 token transfers failed because the send flow used legacy transfer instructions

- Updated dependencies [[`2f67cb8`](https://github.com/reown-com/appkit/commit/2f67cb800e99c09a85e89ba7f6dc38486305120a), [`d412fdb`](https://github.com/reown-com/appkit/commit/d412fdbe4a10583844fc19fa5dae364a7e92a9ca), [`b6adfdc`](https://github.com/reown-com/appkit/commit/b6adfdc1713daefb63393d9fa3a2cb2e31ba00e2), [`7fab812`](https://github.com/reown-com/appkit/commit/7fab812a0e796d52332fc38cdbd57ea020d46713)]:
- @reown/appkit-scaffold-ui@1.8.2
- @reown/appkit-controllers@1.8.2
- @reown/appkit@1.8.2
- @reown/appkit-utils@1.8.2
- @reown/appkit-common@1.8.2
- @reown/appkit-polyfills@1.8.2
- @reown/appkit-wallet@1.8.2

## 1.8.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reown/appkit-adapter-ethers",
"version": "1.8.1",
"version": "1.8.2",
"sideEffects": false,
"type": "module",
"main": "./dist/esm/src/index.js",
Expand Down
15 changes: 15 additions & 0 deletions packages/adapters/ethers5/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @reown/appkit-adapter-ethers5

## 1.8.2

### Patch Changes

- [#4923](https://github.com/reown-com/appkit/pull/4923) [`b6adfdc`](https://github.com/reown-com/appkit/commit/b6adfdc1713daefb63393d9fa3a2cb2e31ba00e2) Thanks [@github-actions](https://github.com/apps/github-actions)! - Fixed an issue where Solana token-2022 token transfers failed because the send flow used legacy transfer instructions

- Updated dependencies [[`2f67cb8`](https://github.com/reown-com/appkit/commit/2f67cb800e99c09a85e89ba7f6dc38486305120a), [`d412fdb`](https://github.com/reown-com/appkit/commit/d412fdbe4a10583844fc19fa5dae364a7e92a9ca), [`b6adfdc`](https://github.com/reown-com/appkit/commit/b6adfdc1713daefb63393d9fa3a2cb2e31ba00e2), [`7fab812`](https://github.com/reown-com/appkit/commit/7fab812a0e796d52332fc38cdbd57ea020d46713)]:
- @reown/appkit-scaffold-ui@1.8.2
- @reown/appkit-controllers@1.8.2
- @reown/appkit@1.8.2
- @reown/appkit-utils@1.8.2
- @reown/appkit-common@1.8.2
- @reown/appkit-polyfills@1.8.2
- @reown/appkit-wallet@1.8.2

## 1.8.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/ethers5/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reown/appkit-adapter-ethers5",
"version": "1.8.1",
"version": "1.8.2",
"sideEffects": false,
"type": "module",
"main": "./dist/esm/src/index.js",
Expand Down
14 changes: 14 additions & 0 deletions packages/adapters/solana/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @reown/appkit-adapter-solana

## 1.8.2

### Patch Changes

- [#4923](https://github.com/reown-com/appkit/pull/4923) [`b6adfdc`](https://github.com/reown-com/appkit/commit/b6adfdc1713daefb63393d9fa3a2cb2e31ba00e2) Thanks [@github-actions](https://github.com/apps/github-actions)! - Fixed an issue where Solana token-2022 token transfers failed because the send flow used legacy transfer instructions

- Updated dependencies [[`d412fdb`](https://github.com/reown-com/appkit/commit/d412fdbe4a10583844fc19fa5dae364a7e92a9ca), [`b6adfdc`](https://github.com/reown-com/appkit/commit/b6adfdc1713daefb63393d9fa3a2cb2e31ba00e2)]:
- @reown/appkit-controllers@1.8.2
- @reown/appkit@1.8.2
- @reown/appkit-utils@1.8.2
- @reown/appkit-common@1.8.2
- @reown/appkit-polyfills@1.8.2
- @reown/appkit-wallet@1.8.2

## 1.8.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/solana/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reown/appkit-adapter-solana",
"version": "1.8.1",
"version": "1.8.2",
"sideEffects": false,
"type": "module",
"main": "./dist/esm/src/index.js",
Expand Down
27 changes: 25 additions & 2 deletions packages/adapters/solana/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { BaseWalletAdapter } from '@solana/wallet-adapter-base'
import type { Commitment, ConnectionConfig } from '@solana/web3.js'
import { PublicKey, Connection as SolanaConnection } from '@solana/web3.js'
import { PublicKey, SendTransactionError, Connection as SolanaConnection } from '@solana/web3.js'
import UniversalProvider from '@walletconnect/universal-provider'
import bs58 from 'bs58'

Expand Down Expand Up @@ -49,6 +49,17 @@ const IGNORED_CONNECTIONS_IDS: string[] = [
CommonConstantsUtil.CONNECTOR_ID.WALLET_CONNECT
]

const TRANSACTION_ERROR_MAP = [
{
pattern: /Attempt to debit an account but found no record of a prior credit/iu,
message: 'Not enough SOL to cover fees or rent'
},
{
pattern: /Insufficient funds for fee/iu,
message: 'Not enough SOL to cover fees or rent'
}
]

export class SolanaAdapter extends AdapterBlueprint<SolanaProvider> {
private connectionSettings: Commitment | ConnectionConfig
public wallets?: BaseWalletAdapter[]
Expand Down Expand Up @@ -216,7 +227,19 @@ export class SolanaAdapter extends AdapterBlueprint<SolanaProvider> {
value: Number.isNaN(Number(params.value)) ? 0 : Number(params.value)
})

const result = await provider.sendTransaction(transaction, connection)
const result = await provider.sendTransaction(transaction, connection).catch(error => {
if (error instanceof SendTransactionError) {
const errMessage = error?.transactionError?.message ?? error?.message ?? ''

for (const { pattern, message } of TRANSACTION_ERROR_MAP) {
if (pattern.test(errMessage)) {
throw new Error(message)
}
}
}

throw error
})

await new Promise<void>(resolve => {
const interval = setInterval(async () => {
Expand Down
134 changes: 134 additions & 0 deletions packages/adapters/solana/src/tests/createSPLTokenTransaction.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { PublicKey } from '@solana/web3.js'
import { beforeEach, describe, expect, it } from 'vitest'

import type { Provider } from '@reown/appkit-utils/solana'

import { createSPLTokenTransaction } from '../utils/createSPLTokenTransaction'
import { mockConnection } from './mocks/Connection'
import { TestConstants } from './util/TestConstants'

const mockProvider = () => {
return {
publicKey: new PublicKey(TestConstants.accounts[0].address)
} as unknown as Provider
}

const mockTokenMint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // USDC mint

let provider = mockProvider()
let connection = mockConnection()

describe('createSPLTokenTransaction', () => {
beforeEach(() => {
provider = mockProvider()
connection = mockConnection()
})

it('should throw error when provider has no public key', async () => {
const providerWithoutKey = { publicKey: null } as unknown as Provider

await expect(
createSPLTokenTransaction({
provider: providerWithoutKey,
connection,
to: TestConstants.accounts[1].address,
amount: 10,
tokenMint: mockTokenMint
})
).rejects.toThrow('No public key found')
})

it('should throw error when amount is zero or negative', async () => {
await expect(
createSPLTokenTransaction({
provider,
connection,
to: TestConstants.accounts[1].address,
amount: 0,
tokenMint: mockTokenMint
})
).rejects.toThrow('Amount must be greater than 0')

await expect(
createSPLTokenTransaction({
provider,
connection,
to: TestConstants.accounts[1].address,
amount: -5,
tokenMint: mockTokenMint
})
).rejects.toThrow('Amount must be greater than 0')
})

it('should throw error for invalid recipient address format', async () => {
await expect(
createSPLTokenTransaction({
provider,
connection,
to: 'invalid-address',
amount: 10,
tokenMint: mockTokenMint
})
).rejects.toThrow('Failed to create SPL token transaction')
})

it('should throw error for invalid token mint format', async () => {
await expect(
createSPLTokenTransaction({
provider,
connection,
to: TestConstants.accounts[1].address,
amount: 10,
tokenMint: 'invalid-mint'
})
).rejects.toThrow('Failed to create SPL token transaction')
})

it('should throw error for empty recipient address', async () => {
await expect(
createSPLTokenTransaction({
provider,
connection,
to: '',
amount: 10,
tokenMint: mockTokenMint
})
).rejects.toThrow('Invalid public key input')
})

it('should throw error for null recipient address', async () => {
await expect(
createSPLTokenTransaction({
provider,
connection,
to: null as any,
amount: 10,
tokenMint: mockTokenMint
})
).rejects.toThrow('Failed to create SPL token transaction')
})

it('should throw error for empty token mint', async () => {
await expect(
createSPLTokenTransaction({
provider,
connection,
to: TestConstants.accounts[1].address,
amount: 10,
tokenMint: ''
})
).rejects.toThrow('Invalid public key input')
})

it('should throw error for null token mint', async () => {
await expect(
createSPLTokenTransaction({
provider,
connection,
to: TestConstants.accounts[1].address,
amount: 10,
tokenMint: null as any
})
).rejects.toThrow('Failed to create SPL token transaction')
})
})
Loading
Loading