Skip to content

Commit

Permalink
wes-asseet-hub and fix decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Jan 27, 2025
1 parent 7474f69 commit 6ccb836
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/ui/.papi/descriptors/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.1.0-autogenerated.5905160511643341821",
"version": "0.1.0-autogenerated.14219119828955582103",
"name": "@polkadot-api/descriptors",
"files": [
"dist"
Expand Down
Binary file modified packages/ui/.papi/metadata/bifrostDot.scale
Binary file not shown.
Binary file modified packages/ui/.papi/metadata/hydration.scale
Binary file not shown.
Binary file added packages/ui/.papi/metadata/wesAssetHub.scale
Binary file not shown.
16 changes: 10 additions & 6 deletions packages/ui/.papi/polkadot-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"metadata": ".papi/metadata/khala.scale"
},
"phala": {
"wsUrl": "wss://api.phala.network/ws",
"wsUrl": "wss://phala-rpc.dwellir.com",
"metadata": ".papi/metadata/phala.scale"
},
"paseo": {
Expand All @@ -50,10 +50,6 @@
"wsUrl": "wss://people-paseo.rpc.amforc.com",
"metadata": ".papi/metadata/pasPpl.scale"
},
"wesPpl": {
"wsUrl": "wss://westend-people-rpc.polkadot.io",
"metadata": ".papi/metadata/wesPpl.scale"
},
"dotAssetHub": {
"chain": "polkadot_asset_hub",
"metadata": ".papi/metadata/dotAssetHub.scale"
Expand All @@ -69,6 +65,14 @@
"westend": {
"chain": "westend2",
"metadata": ".papi/metadata/westend.scale"
},
"wesPpl": {
"chain": "westend2_people",
"metadata": ".papi/metadata/wesPpl.scale"
},
"wesAssetHub": {
"chain": "westend2_asset_hub",
"metadata": ".papi/metadata/wesAssetHub.scale"
}
}
}
}
56 changes: 29 additions & 27 deletions packages/ui/src/components/EasySetup/BalancesTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,42 +134,44 @@ const BalancesTransfer = ({ className, onSetExtrinsic, onSetErrorMessage, from }
setSelected(account)
}, [])

const onAmountChange = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
setAmountError('')
onSetErrorMessage('')
useEffect(() => {
if (!selectedAsset) return

if (!selectedAsset) return
const decimals = selectedAsset.decimals

const decimals = selectedAsset.decimals
if (!decimals) {
onSetErrorMessage('Invalid network decimals')
setAmount(0n)
return
}

if (!decimals) {
onSetErrorMessage('Invalid network decimals')
setAmount(0n)
return
}
if (!amountString.match('^[0-9]+([.][0-9]+)?$')) {
setAmountError('Only numbers and "." are accepted.')
onSetErrorMessage('Invalid amount')
setAmount(0n)
return
}

const stringInput = event.target.value.trim()
setAmountString(stringInput)
const bigintResult = inputToBigInt(decimals, amountString)

if (!stringInput.match('^[0-9]+([.][0-9]+)?$')) {
setAmountError('Only numbers and "." are accepted.')
onSetErrorMessage('Invalid amount')
setAmount(0n)
return
}
if (bigintResult > maxValue) {
setAmountError('Amount too large')
onSetErrorMessage('Amount too large')
return
}

const bigintResult = inputToBigInt(decimals, stringInput)
setAmount(bigintResult)
}, [amountString, maxValue, onSetErrorMessage, selectedAsset])

if (bigintResult > maxValue) {
setAmountError('Amount too large')
onSetErrorMessage('Amount too large')
return
}
const onAmountChange = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
setAmountError('')
onSetErrorMessage('')

setAmount(bigintResult)
const stringInput = event.target.value.trim()
setAmountString(stringInput)
},
[maxValue, onSetErrorMessage, selectedAsset]
[onSetErrorMessage]
)

const onInputChange = useCallback(
Expand Down
16 changes: 16 additions & 0 deletions packages/ui/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,21 @@ export const networkList: Record<string, NetworkInfo> = {
descriptor: 'westend',
pplChainDescriptor: 'wesPpl'
},
'asset-hub-westend': {
chainId: 'asset-hub-westend',
explorerNetworkName: 'assethub-westend',
rpcUrls: [
'wss://asset-hub-westend-rpc.dwellir.com',
'wss://sys.ibp.network/asset-hub-westend',
'wss://asset-hub-westend.dotters.network',
'wss://westend-asset-hub-rpc.polkadot.io'
],
pplChainRpcUrls: westendPplChains,
httpGraphqlUrl: HTTP_GRAPHQL_URL,
logo: nodesWestendColourSVG,
descriptor: 'wesAssetHub',
pplChainDescriptor: 'wesPpl'
},
paseo: {
chainId: 'paseo',
explorerNetworkName: 'paseo',
Expand Down Expand Up @@ -427,6 +442,7 @@ export const testChains: Partial<keyof typeof networkList>[] = [
'paseo',
// 'rhala testnet',
'westend',
'asset-hub-westend',
'local'
]

Expand Down
14 changes: 9 additions & 5 deletions packages/ui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ import {
phala,
polimec,
coretimeDot,
westend
westend,
wesAssetHub
} from '@polkadot-api/descriptors'

export const DESCRIPTORS = {
Expand All @@ -86,7 +87,8 @@ export const DESCRIPTORS = {
phala,
polimec,
coretimeDot,
westend
westend,
wesAssetHub
} as const

export const DESCRIPTORS_NOT_HYDRATION_1_3 = {
Expand All @@ -107,17 +109,19 @@ export const DESCRIPTORS_NOT_HYDRATION_3_3 = {
phala,
polimec,
coretimeDot,
westend
westend,
wesAssetHub
} as const

export const DESCRIPTORS_ASSET_HUBS = {
dotAssetHub,
ksmAssetHub
ksmAssetHub,
wesAssetHub
}

export const DESCRIPTORS_1_3 = { acala, bifrostDot, dot, dotAssetHub, hydration } as const
export const DESCRIPTORS_2_3 = { khala, ksm, ksmAssetHub, paseo, phala } as const
export const DESCRIPTORS_3_3 = { polimec, coretimeDot, westend } as const
export const DESCRIPTORS_3_3 = { polimec, coretimeDot, westend, wesAssetHub } as const

export type ApiDescriptors = keyof typeof DESCRIPTORS

Expand Down
6 changes: 6 additions & 0 deletions squid/assets/envs/.env.asset-hub-westend
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#asset-hub-westend
BLOCK_START=0
PREFIX=42
RPC_WS="wss://asset-hub-westend-rpc.dwellir.com"
# GATEWAY_URL="https://v2.archive.subsquid.io/network/asset-hub-kusama"
CHAIN_ID='asset-hub-westend'
10 changes: 10 additions & 0 deletions squid/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@
"dotenv_config_path=assets/envs/.env.asset-hub-kusama"
]
},
"start-asset-hub-westend": {
"description": "starts the indexer with asset-hub-westend",
"cmd": [
"node",
"-r",
"dotenv/config",
"lib/main",
"dotenv_config_path=assets/envs/.env.asset-hub-westend"
]
},
"start-hydration": {
"description": "starts the indexer with hydration",
"cmd": [
Expand Down
2 changes: 2 additions & 0 deletions squid/squid-manifests/large-squid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ deploy:
cmd: ['sqd', 'start-asset-hub-kusama']
- name: asset-hub-polkadot-processor
cmd: ['sqd', 'start-asset-hub-polkadot']
# - name: asset-hub-westend-processor
# cmd: ['sqd', 'start-asset-hub-westend']
# - name: rococo-processor
# cmd: ['sqd', 'start-rococo']
- name: kusama-processor
Expand Down

0 comments on commit 6ccb836

Please sign in to comment.