Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
403314e
fix: starknet implementation
NeOMakinG Dec 22, 2025
20645a7
fix: bunch of things
NeOMakinG Dec 23, 2025
449a871
feat: normalize addresses using validateAndParseAddress for comparison
gomesalexandre Dec 24, 2025
fede72f
feat: deduplicate STRK token following Sui pattern
gomesalexandre Dec 24, 2025
eb45377
chore: remove debug console.logs from StarknetChainAdapter
gomesalexandre Dec 24, 2025
450dbfa
[skip ci] fix: replace 9 'as any' casts with proper type guards
gomesalexandre Dec 24, 2025
c2b7b91
[skip ci] fix: remove debug code and fix silent RPC error handling
gomesalexandre Dec 24, 2025
611cb00
[skip ci] chore: remove test files from repository
gomesalexandre Dec 24, 2025
3b2f3bb
[skip ci] fix: parseTx error handling and remove unused code
gomesalexandre Dec 24, 2025
9c403d7
[skip ci] chore: restore asset generation to regenerate all chains
gomesalexandre Dec 24, 2025
e5bc429
[skip ci] refactor: move types to types.ts and fix nonce handling
gomesalexandre Dec 24, 2025
df38f02
feat: add Starknet assets and dependencies
gomesalexandre Dec 24, 2025
3bbc359
[skip ci] style: lint formatting fix
gomesalexandre Dec 24, 2025
5a29f24
[skip ci] fix: remove unused StarknetTxDetails import
gomesalexandre Dec 24, 2025
4b1ec04
[skip ci] chore: revert config files and bump hdwallet packages to 1.…
gomesalexandre Dec 24, 2025
764418f
[skip ci] feat: add Starknet to popular assets for discoverability
gomesalexandre Dec 24, 2025
d419043
chore: update hdwallet packages and fix lint issues
gomesalexandre Dec 24, 2025
d8a0b1b
Merge origin/develop into starknet
gomesalexandre Dec 24, 2025
c306926
fix: types
gomesalexandre Dec 26, 2025
fd5ddee
feat: cleanup starknet implementation
gomesalexandre Dec 26, 2025
193a944
[skip ci] chore: add starknet.js v9 hashFeeFieldV3B3 reference comments
gomesalexandre Dec 26, 2025
23fd3c0
fix: review feedbacks
NeOMakinG Dec 29, 2025
6c00d2f
fix: remove modal and block flow
NeOMakinG Dec 29, 2025
d048189
Merge remote-tracking branch 'origin/develop' into starknet
NeOMakinG Dec 29, 2025
bf5e929
Merge remote-tracking branch 'origin/develop' into starknet
NeOMakinG Dec 30, 2025
9b4ddbf
Merge origin/develop into starknet - resolve conflicts by accepting d…
gomesalexandre Dec 30, 2025
fc09eaa
feat: regen and stuff
gomesalexandre Dec 30, 2025
c63a6e2
fix: fee estimation fix
NeOMakinG Dec 30, 2025
523e731
Merge branch 'develop' into starknet
NeOMakinG Dec 30, 2025
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
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ VITE_FEATURE_GNOSIS=true
VITE_FEATURE_ARBITRUM=true
VITE_FEATURE_ARBITRUM_NOVA=false
VITE_FEATURE_SOLANA=true
VITE_FEATURE_STARKNET=false
VITE_FEATURE_SUI=false
VITE_FEATURE_MAYACHAIN=true
VITE_FEATURE_BASE=true
Expand Down Expand Up @@ -158,6 +159,7 @@ VITE_PLASMA_NODE_URL=https://rpc.plasma.to
VITE_THORCHAIN_NODE_URL=https://api.thorchain.shapeshift.com/lcd
VITE_MAYACHAIN_NODE_URL=https://api.mayachain.shapeshift.com/lcd
VITE_SOLANA_NODE_URL=https://api.solana.shapeshift.com/api/v1/jsonrpc
VITE_STARKNET_NODE_URL=https://starknet.drpc.org
Comment thread
NeOMakinG marked this conversation as resolved.
Outdated
Comment thread
gomesalexandre marked this conversation as resolved.
Outdated
VITE_TRON_NODE_URL=https://api.trongrid.io
VITE_ALCHEMY_POLYGON_URL=https://polygon-mainnet.g.alchemy.com/v2/anoTMcIc2hbPUxri37h4DeuUwg2p5_xZ

Expand Down
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ VITE_HYPEREVM_NODE_URL=https://rpc.hyperliquid.xyz/evm
VITE_THORCHAIN_NODE_URL=https://dev-api.thorchain.shapeshift.com/lcd
VITE_MAYACHAIN_NODE_URL=https://dev-api.mayachain.shapeshift.com/lcd
VITE_SOLANA_NODE_URL=https://dev-api.solana.shapeshift.com/api/v1/jsonrpc
VITE_STARKNET_NODE_URL=https://rpc.starknet.lava.build
VITE_TRON_NODE_URL=https://api.trongrid.io

# midgard
Expand All @@ -82,6 +83,7 @@ VITE_FEATURE_MIXPANEL=true
VITE_FEATURE_TX_HISTORY_BYE_BYE=true
VITE_FEATURE_SWAPPER_FIAT_RAMPS=true
VITE_FEATURE_SUI=true
VITE_FEATURE_STARKNET=true

VITE_FEATURE_NOTIFICATIONS_WEBSERVICES=true
# Turn those on if you use local development instead of our railway instance
Expand Down
2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ nodeLinker: node-modules

npmAuthToken: "${NPM_AUTH-fallback}"

npmRegistryServer: "https://registry.npmjs.org"
npmRegistryServer: "http://127.0.0.1:4873"

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
Expand Down
136 changes: 136 additions & 0 deletions STARKNET_SWAP_SUPPORT.md
Comment thread
NeOMakinG marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Starknet Swap Support Implementation

## Overview
Starknet has been integrated as a second-class citizen chain with full NEAR Intents swap support (both buy and sell).

## Key Implementation Files

### 1. Trade Quote/Rate Input Builder
**File**: `src/components/MultiHopTrade/hooks/useGetTradeQuotes/getTradeQuoteOrRateInput.ts`

**Critical Implementation**: Lines 239-256
```typescript
case CHAIN_NAMESPACE.Starknet: {
const sellAssetChainAdapter = assertGetStarknetChainAdapter(sellAsset.chainId)

const sendAddress =
wallet && sellAccountNumber !== undefined
? await sellAssetChainAdapter.getAddress({
accountNumber: sellAccountNumber,
wallet,
pubKey,
})
: undefined

return {
...tradeQuoteInputCommonArgs,
chainId: sellAsset.chainId,
sendAddress,
} as GetTradeQuoteInput
}
```

**What This Does**: Enables the swap UI to build trade input objects for Starknet, allowing users to sell STRK and other Starknet tokens.

### 2. NEAR Intents Swapper Integration

#### Supported Chains
**File**: `packages/swapper/src/swappers/NearIntentsSwapper/types.ts`
- Starknet added to `nearIntentsSupportedChainIds` (line 24)
- Chain mapping: `starknetChainId` → `'starknet'` (line 45)

#### Asset ID Resolution
**File**: `packages/swapper/src/swappers/NearIntentsSwapper/utils/helpers/helpers.ts`
- Starknet added to `TOKEN_LOOKUP_CHAINS` (line 43)
- Uses API token lookup due to hashed asset ID format (lines 52-93)

#### Fee Estimation
**File**: `packages/swapper/src/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.ts`
- Starknet fee handling (lines 254-260)
- Uses hardcoded fees from chain adapter (no dynamic estimation)

#### Transaction Building
**File**: `packages/swapper/src/swappers/NearIntentsSwapper/endpoints.ts`
- `getUnsignedStarknetTransaction` implementation
- `getStarknetTransactionFees` implementation

#### Transaction Execution
**File**: `packages/swapper/src/utils.ts`
- `executeStarknetTransaction` utility function (lines 198-203)

**File**: `packages/swapper/src/swappers/NearIntentsSwapper/NearIntentsSwapper.ts`
- Wired up `executeStarknetTransaction` to swapper

### 3. Chain Adapter Utilities
**File**: `src/lib/utils/starknet.ts` (CREATED)
- `assertGetStarknetChainAdapter`: Type-safe accessor for Starknet chain adapter
- `isStarknetChainAdapter`: Type guard for Starknet adapter
- `getStarknetTransactionStatus`: Transaction status polling utility

### 4. Type Definitions
**File**: `packages/swapper/src/types.ts`
- `StarknetSwapperDeps` (lines 304-306)
- `StarknetTransactionExecutionProps` (lines 458-460)
- `StarknetTransactionExecutionInput` (lines 795-797)
- `GetUnsignedStarknetTransactionArgs` (lines 495-497)
- `executeStarknetTransaction` in Swapper interface (lines 715-718)
- `getUnsignedStarknetTransaction` in SwapperApi (lines 606-608)
- `getStarknetTransactionFees` in SwapperApi (line 616)

### 5. Swapper Dependencies Wiring
**File**: `src/state/apis/swapper/helpers/swapperApiHelpers.ts`
- Added `assertGetStarknetChainAdapter` to `createSwapperDeps`

**File**: `src/lib/tradeExecution.ts`
- Added `assertGetStarknetChainAdapter` to trade status checking

**File**: `src/pages/RFOX/components/Stake/Bridge/hooks/useRfoxBridge.ts`
- Added `assertGetStarknetChainAdapter` to swapper dependencies

### 6. Transaction Status Polling
**File**: `src/hooks/useActionCenterSubscribers/useSendActionSubscriber.tsx`
- Added Starknet case for transaction status polling (uses `getStarknetTransactionStatus`)

## Second-Class Citizen Status

Starknet is configured as a "second-class citizen" chain in `src/constants/chains.ts` (line 14).

**What This Means**:
- Special transaction handling and polling
- Initially supported only as receive-only (buy-side)
- **Now fully supports both buy AND sell** via NEAR Intents

**Important**: Second-class chains CAN be used as source chains for swaps via NEAR Intents. The "second-class" designation refers to transaction handling, not swap capability.

## Common Troubleshooting

### Issue: "Starknet swaps are not yet supported" Error
**Location**: `src/components/MultiHopTrade/hooks/useGetTradeQuotes/getTradeQuoteOrRateInput.ts`

**Solution**: Implement the `CHAIN_NAMESPACE.Starknet` case in the switch statement (lines 239-256) as shown above.

### Issue: No Quotes Appearing
**Potential Causes**:
1. Missing Starknet case in `getTradeQuoteOrRateInput.ts` (most common)
2. NEAR Intents API key not configured (`VITE_NEAR_INTENTS_API_KEY`)
3. Feature flag disabled (`VITE_FEATURE_NEAR_INTENTS_SWAP`)
4. Missing asset in NEAR Intents token list

### Issue: Token Not Found in NEAR Intents
**Check**: `assetToNearIntentsAsset` function in `helpers.ts` - Starknet uses API token lookup
**Debug**: Add console logs to see token matching results

## Testing

To test Starknet swap support:
1. Enable feature flag: `VITE_FEATURE_NEAR_INTENTS_SWAP=true`
2. Configure API key: `VITE_NEAR_INTENTS_API_KEY=<key>`
3. Select STRK (Starknet) or any Starknet token as sell asset
4. Select a destination asset on any supported chain
5. Enter amount and verify quotes appear from NEAR Intents

## References

- NEAR Intents Starknet Integration Announcement: December 2024
- NEAR Intents supports 20+ chains including Starknet
- Starknet uses hashed asset IDs requiring API token lookup
10 changes: 10 additions & 0 deletions headers/csps/chains/starknet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { loadEnv } from 'vite'

import type { Csp } from '../../types'

const mode = process.env.MODE ?? process.env.NODE_ENV ?? 'development'
const env = loadEnv(mode, process.cwd(), '')

export const csp: Csp = {
'connect-src': [env.VITE_STARKNET_NODE_URL],
}
4 changes: 4 additions & 0 deletions headers/csps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { csp as optimism } from './chains/optimism'
import { csp as plasma } from './chains/plasma'
import { csp as polygon } from './chains/polygon'
import { csp as solana } from './chains/solana'
import { csp as starknet } from './chains/starknet'
import { csp as sui } from './chains/sui'
import { csp as thorchain } from './chains/thorchain'
import { csp as tron } from './chains/tron'
Expand Down Expand Up @@ -48,6 +49,7 @@ import { csp as interFont } from './InterFont'
import { csp as jupiter } from './jupiter'
import { csp as ledger } from './ledger'
import { csp as coincap } from './marketService/coincap'
import { csp as coingecko } from './marketService/coingecko'
import { csp as exchangeRates } from './marketService/exchangeRates'
import { csp as mercle } from './mercle'
import { csp as mixPanel } from './mixPanel'
Expand Down Expand Up @@ -106,6 +108,7 @@ export const csps = [
optimism,
polygon,
solana,
starknet,
sui,
thorchain,
tron,
Expand All @@ -115,6 +118,7 @@ export const csps = [
plasma,
trustwallet,
coincap,
coingecko,
exchangeRates,
onRamper,
banxa,
Expand Down
5 changes: 5 additions & 0 deletions headers/csps/marketService/coingecko.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { Csp } from '../../types'

export const csp: Csp = {
'img-src': ['https://assets.coingecko.com/coins/images/'],
}
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,24 @@
"@shapeshiftoss/chain-adapters": "workspace:^",
"@shapeshiftoss/contracts": "workspace:^",
"@shapeshiftoss/errors": "workspace:^",
"@shapeshiftoss/hdwallet-coinbase": "1.62.31",
"@shapeshiftoss/hdwallet-core": "1.62.31",
"@shapeshiftoss/hdwallet-gridplus": "1.62.31",
"@shapeshiftoss/hdwallet-keepkey": "1.62.31",
"@shapeshiftoss/hdwallet-keepkey-webusb": "1.62.31",
"@shapeshiftoss/hdwallet-keplr": "1.62.31",
"@shapeshiftoss/hdwallet-ledger": "1.62.31",
"@shapeshiftoss/hdwallet-ledger-webhid": "1.62.31",
"@shapeshiftoss/hdwallet-ledger-webusb": "1.62.31",
"@shapeshiftoss/hdwallet-metamask-multichain": "1.62.31",
"@shapeshiftoss/hdwallet-native": "1.62.31",
"@shapeshiftoss/hdwallet-native-vault": "1.62.31",
"@shapeshiftoss/hdwallet-phantom": "1.62.31",
"@shapeshiftoss/hdwallet-trezor": "1.62.31",
"@shapeshiftoss/hdwallet-trezor-connect": "1.62.31",
"@shapeshiftoss/hdwallet-vultisig": "1.62.31",
"@shapeshiftoss/hdwallet-walletconnect": "1.62.31",
"@shapeshiftoss/hdwallet-walletconnectv2": "1.62.31",
"@shapeshiftoss/hdwallet-coinbase": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-core": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-gridplus": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-keepkey": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-keepkey-webusb": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-keplr": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-ledger": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-ledger-webhid": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-ledger-webusb": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-metamask-multichain": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-native": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-native-vault": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-phantom": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-trezor": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-trezor-connect": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-vultisig": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-walletconnect": "1.62.33-starknet.14",
"@shapeshiftoss/hdwallet-walletconnectv2": "1.62.33-starknet.14",
"@shapeshiftoss/swapper": "workspace:^",
"@shapeshiftoss/types": "workspace:^",
"@shapeshiftoss/unchained-client": "workspace:^",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"eip155:10/erc20:0x94b008aa00579c1307b0ef2c499ad98a8ce58e58":"tether","eip155:10/erc20:0x0b2c639c533813f4aa9d7837caf62653d097ff85":"usd-coin","eip155:10/erc20:0x1f32b1c2345538c0c6f582fcb022739c4a194ebb":"lido-finance-wsteth","eip155:10/erc20:0x68f180fcce6836688e9084f035309e29bf0a2095":"wrapped-bitcoin","eip155:10/erc20:0x4200000000000000000000000000000000000006":"weth","eip155:10/erc20:0x5a7facb970d094b6c7ff1df0ea68d99e6e73cbff":"wrapped-eeth","eip155:10/erc20:0x350a791bfc2c21f9ed5d10980dad2e2638ffa7f6":"chainlink","eip155:10/erc20:0x6fd9d7ad17242c41f7131d257212c54a0e816691":"uniswap","eip155:10/erc20:0x9bcef72be871e61ed4fbbc7630889bee758eb81d":"rocket-pool-eth","eip155:10/erc20:0xdc6ff44d5d932cbd77b52e5612ba0529dc6226f1":"worldcoin-org","eip155:10/erc20:0x4200000000000000000000000000000000000042":"optimism-ethereum","eip155:10/erc20:0x0994206dfe8de6ec6920ff4d779b0d950605fb53":"curve-dao-token","eip155:10/erc20:0x6985884c4392d348587b19cb9eaaf157f13271cd":"layerzero","eip155:10/erc20:0x2e3d870790dc77a83dd1d18184acc7439a53f475":"frax","eip155:10/erc20:0xb0ffa8000886e57f86dd5264b9582b2ad87b2b91":"wormhole","eip155:10/erc20:0x8700daec35af8ff88c16bdf0418774cb3d7599b4":"synthetix-network-token","eip155:10/erc20:0x3eaeb77b03dbc0f6321ae1b72b2e9adb0f60112b":"sushiswap","eip155:10/erc20:0xaeaeed23478c3a4b798e4ed40d8b7f41366ae861":"ankr","eip155:10/erc20:0xa00e3a3511aac35ca78530c85007afcd31753819":"kyber-network","eip155:10/erc20:0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9":"susd","eip155:10/erc20:0xec6adef5e1006bb305bb1975333e8fc4071295bf":"cartesi","eip155:10/erc20:0xe05a08226c49b636acf99c40da8dc6af83ce5bb3":"ankreth","eip155:10/erc20:0x5f8d72676e37197b5011afc64d8641af2fe41fdb":"measurable-data-token","eip155:10/erc20:0xaf9fe3b5ccdae78188b1f8b9a49da7ae9510f151":"dhedge-dao","eip155:10/erc20:0xc7edf7b7b3667a06992508e7b156eff794a9e1c8":"persistence","eip155:10/erc20:0xe453d6649643f1f460c371dc3d1da98f7922fe51":"fuse-network","eip155:10/erc20:0x1da650c3b2daa8aa9ff6f661d4156ce24d08a062":"dentacoin","eip155:10/erc20:0x6a661312938d22a2a0e27f585073e4406903990a":"mahadao","eip155:10/erc20:0x528cdc92eab044e1e39fe43b9514bfdab4412b98":"giveth"}
{"eip155:10/erc20:0x94b008aa00579c1307b0ef2c499ad98a8ce58e58":"tether","eip155:10/erc20:0x0b2c639c533813f4aa9d7837caf62653d097ff85":"usd-coin","eip155:10/erc20:0x1f32b1c2345538c0c6f582fcb022739c4a194ebb":"lido-finance-wsteth","eip155:10/erc20:0x68f180fcce6836688e9084f035309e29bf0a2095":"wrapped-bitcoin","eip155:10/erc20:0x4200000000000000000000000000000000000006":"weth","eip155:10/erc20:0x5a7facb970d094b6c7ff1df0ea68d99e6e73cbff":"wrapped-eeth","eip155:10/erc20:0x350a791bfc2c21f9ed5d10980dad2e2638ffa7f6":"chainlink","eip155:10/erc20:0x6fd9d7ad17242c41f7131d257212c54a0e816691":"uniswap","eip155:10/erc20:0x9bcef72be871e61ed4fbbc7630889bee758eb81d":"rocket-pool-eth","eip155:10/erc20:0xdc6ff44d5d932cbd77b52e5612ba0529dc6226f1":"worldcoin-org","eip155:10/erc20:0x0994206dfe8de6ec6920ff4d779b0d950605fb53":"curve-dao-token","eip155:10/erc20:0x4200000000000000000000000000000000000042":"optimism-ethereum","eip155:10/erc20:0x6985884c4392d348587b19cb9eaaf157f13271cd":"layerzero","eip155:10/erc20:0x2e3d870790dc77a83dd1d18184acc7439a53f475":"frax","eip155:10/erc20:0xb0ffa8000886e57f86dd5264b9582b2ad87b2b91":"wormhole","eip155:10/erc20:0x8700daec35af8ff88c16bdf0418774cb3d7599b4":"synthetix-network-token","eip155:10/erc20:0x3eaeb77b03dbc0f6321ae1b72b2e9adb0f60112b":"sushiswap","eip155:10/erc20:0xaeaeed23478c3a4b798e4ed40d8b7f41366ae861":"ankr","eip155:10/erc20:0xa00e3a3511aac35ca78530c85007afcd31753819":"kyber-network","eip155:10/erc20:0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9":"susd","eip155:10/erc20:0xec6adef5e1006bb305bb1975333e8fc4071295bf":"cartesi","eip155:10/erc20:0xe05a08226c49b636acf99c40da8dc6af83ce5bb3":"ankreth","eip155:10/erc20:0x5f8d72676e37197b5011afc64d8641af2fe41fdb":"measurable-data-token","eip155:10/erc20:0xaf9fe3b5ccdae78188b1f8b9a49da7ae9510f151":"dhedge-dao","eip155:10/erc20:0xe453d6649643f1f460c371dc3d1da98f7922fe51":"fuse-network","eip155:10/erc20:0xc7edf7b7b3667a06992508e7b156eff794a9e1c8":"persistence","eip155:10/erc20:0x1da650c3b2daa8aa9ff6f661d4156ce24d08a062":"dentacoin","eip155:10/erc20:0x528cdc92eab044e1e39fe43b9514bfdab4412b98":"giveth","eip155:10/erc20:0x6a661312938d22a2a0e27f585073e4406903990a":"mahadao"}
Loading