Skip to content

Commit

Permalink
set originChainId as constructor property
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Jan 25, 2024
1 parent 6592ec5 commit e0fea26
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/AssetTransferApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class AssetTransferApi {
readonly _specName: string;
readonly _safeXcmVersion: number;
readonly _nativeRelayChainAsset: string;
readonly _originChainId: string;
private registryConfig: {
registryInitialized: boolean;
registryType: RegistryTypes;
Expand All @@ -110,6 +111,7 @@ export class AssetTransferApi {
registryType: opts.registryType ? opts.registryType : 'CDN',
};
this._nativeRelayChainAsset = this.registry.currentRelayRegistry[RELAY_CHAIN_IDS[0]].tokens[0];
this._originChainId = this.registry.lookupChainIdBySpecName(this._specName);
}

/**
Expand Down Expand Up @@ -177,12 +179,11 @@ export class AssetTransferApi {
*/
checkBaseInputTypes(destChainId, destAddr, assetIds, amounts);

const { _api, _specName, _safeXcmVersion, registry } = this;
const originChainId = registry.lookupChainIdBySpecName(_specName);
const { _api, _specName, _safeXcmVersion, _originChainId, registry } = this;
const isLiquidTokenTransfer = transferLiquidToken === true;
const chainOriginDestInfo = {
isOriginSystemParachain: SYSTEM_PARACHAINS_NAMES.includes(_specName.toLowerCase()),
isOriginParachain: isParachain(originChainId),
isOriginParachain: isParachain(_originChainId),
isDestRelayChain: destChainId === RELAY_CHAIN_IDS[0],
isDestSystemParachain: isSystemChain(destChainId),
isDestParachain: isParachain(destChainId),
Expand All @@ -194,7 +195,7 @@ export class AssetTransferApi {
*/
const addr = sanitizeAddress(destAddr);

const localTxChainType = this.establishLocalTxChainType(originChainId, destChainId, chainOriginDestInfo);
const localTxChainType = this.establishLocalTxChainType(_originChainId, destChainId, chainOriginDestInfo);
const isLocalTx = localTxChainType !== LocalTxChainType.None;
const xcmDirection = this.establishDirection(isLocalTx, chainOriginDestInfo);
const isForeignAssetsTransfer: boolean = this.checkIsForeignAssetTransfer(assetIds);
Expand Down Expand Up @@ -254,7 +255,7 @@ export class AssetTransferApi {

const assetType = this.fetchAssetType(xcmDirection, isForeignAssetsTransfer);
const assetCallType = this.fetchCallType(
originChainId,
_originChainId,
destChainId,
assetIds,
xcmDirection,
Expand Down

0 comments on commit e0fea26

Please sign in to comment.