@@ -9,7 +9,11 @@ import {
9
9
erc20Location ,
10
10
} from "./xcmBuilder"
11
11
import { IGatewayV1__factory as IGateway__factory } from "@snowbridge/contract-types"
12
- import { convertToXcmV3X1 , getMoonbeamLocationBalance , toMoonbeamXC20 } from "./parachains/moonbeam"
12
+ import {
13
+ convertToXcmV3X1 , getMoonbeamEvmAssetMetadata ,
14
+ getMoonbeamLocationBalance ,
15
+ toMoonbeamXC20
16
+ } from "./parachains/moonbeam"
13
17
import { MUSE_TOKEN_ID , MYTHOS_TOKEN_ID , getMythosLocationBalance } from "./parachains/mythos"
14
18
15
19
export type ERC20Metadata = {
@@ -879,41 +883,16 @@ async function indexParachainAssets(provider: ApiPromise, ethChainId: number, sp
879
883
}
880
884
case "moonriver" :
881
885
case "moonbeam" : {
882
- const entries = await provider . query . assetManager . assetIdType . entries ( )
883
- for ( const [ key , value ] of entries ) {
884
- const location = ( value . toJSON ( ) as any ) . xcm
885
-
886
- const assetId = BigInt ( key . args . at ( 0 ) ?. toPrimitive ( ) as any )
887
- const xc20 = toMoonbeamXC20 ( assetId )
888
-
889
- if ( location . parents === 1 && location . interior . here !== undefined ) {
890
- xcDOT = xc20
891
- }
892
- const token = getTokenFromLocation ( location , ethChainId )
893
- if ( ! token ) {
894
- continue
895
- }
896
-
897
- const asset : any = ( await provider . query . assets . asset ( assetId ) ) . toPrimitive ( )
898
- const metadata : any = ( await provider . query . assets . metadata ( assetId ) ) . toPrimitive ( )
899
-
900
- assets [ token ] = {
901
- token,
902
- name : String ( metadata . name ) ,
903
- minimumBalance : BigInt ( asset . minBalance ) ,
904
- symbol : String ( metadata . symbol ) ,
905
- decimals : Number ( metadata . decimals ) ,
906
- isSufficient : Boolean ( asset . isSufficient ) ,
907
- xc20,
908
- }
909
- }
910
886
const foreignEntries = await provider . query . evmForeignAssets . assetsById . entries ( )
911
887
for ( const [ key , value ] of foreignEntries ) {
912
888
const location = value . toJSON ( ) as any
913
889
914
890
const assetId = BigInt ( key . args . at ( 0 ) ?. toPrimitive ( ) as any )
915
891
const xc20 = toMoonbeamXC20 ( assetId )
916
892
893
+ if ( location . parents === 1 && location . interior . here !== undefined ) {
894
+ xcDOT = xc20
895
+ }
917
896
const token = getTokenFromLocation ( location , ethChainId )
918
897
if ( ! token ) {
919
898
continue
@@ -923,16 +902,17 @@ async function indexParachainAssets(provider: ApiPromise, ethChainId: number, sp
923
902
continue
924
903
}
925
904
926
- const asset : any = ( await provider . query . assets . asset ( assetId ) ) . toPrimitive ( )
927
- const metadata : any = ( await provider . query . assets . metadata ( assetId ) ) . toPrimitive ( )
905
+ const symbol = await getMoonbeamEvmAssetMetadata ( provider , "symbol" , xc20 )
906
+ const name = await getMoonbeamEvmAssetMetadata ( provider , "name" , xc20 )
907
+ const decimals = await getMoonbeamEvmAssetMetadata ( provider , "decimals" , xc20 )
928
908
929
909
assets [ token ] = {
930
910
token,
931
- name : String ( metadata . name ) ,
932
- minimumBalance : BigInt ( asset ?. minBalance ?? 1 ) ,
933
- symbol : String ( metadata . symbol ) ,
934
- decimals : Number ( metadata . decimals ) ,
935
- isSufficient : Boolean ( asset ?. isSufficient ?? false ) ,
911
+ name : String ( name ) ,
912
+ minimumBalance : 1n ,
913
+ symbol : String ( symbol ) ,
914
+ decimals : Number ( decimals ) ,
915
+ isSufficient : true ,
936
916
xc20,
937
917
}
938
918
}
@@ -1121,7 +1101,7 @@ async function indexEthChain(
1121
1101
)
1122
1102
}
1123
1103
if ( ! evmParachainChain . xcDOT ) {
1124
- throw Error ( `Could not DOT XC20 address for evm chain ${ networkChainId } .` )
1104
+ throw Error ( `Could not find DOT XC20 address for evm chain ${ networkChainId } .` )
1125
1105
}
1126
1106
const xc20DOTAsset : ERC20Metadata = await assetErc20Metadata (
1127
1107
provider ,
@@ -1380,7 +1360,7 @@ function defaultPathFilter(envName: string): (_: Path) => boolean {
1380
1360
if (
1381
1361
path . asset === MUSE_TOKEN_ID &&
1382
1362
(
1383
- ( path . destination !== 3369 && path . type === "ethereum" ) ||
1363
+ ( path . destination !== 3369 && path . type === "ethereum" ) ||
1384
1364
( path . source !== 3369 && path . type === "substrate" )
1385
1365
)
1386
1366
) {
@@ -1398,8 +1378,8 @@ function defaultPathFilter(envName: string): (_: Path) => boolean {
1398
1378
if (
1399
1379
path . asset === MYTHOS_TOKEN_ID &&
1400
1380
(
1401
- ( path . destination !== 3369 && path . type === "ethereum" ) ||
1402
- ( path . source !== 3369 && path . type === "substrate" )
1381
+ // TODO: Disable Mythos to Eth until mythos is ready to enable
1382
+ ( path . destination !== 3369 )
1403
1383
)
1404
1384
) {
1405
1385
return false
@@ -1595,5 +1575,5 @@ export async function getAssetHubConversationPalletSwap(assetHub: ApiPromise, as
1595
1575
if ( asset1Balance == null ) {
1596
1576
throw Error ( `No pool set up in asset conversion pallet for '${ JSON . stringify ( asset1 ) } ' and '${ JSON . stringify ( asset2 ) } '.` )
1597
1577
}
1598
- return BigInt ( asset1Balance )
1578
+ return BigInt ( asset1Balance )
1599
1579
}
0 commit comments