-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: Replaced getNetworkConfig() with useNetworkConfig() hook to…
… force users use it as a hook.
- Loading branch information
Showing
7 changed files
with
61 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,3 @@ | ||
import { | ||
CONTRACT_PACKAGE_VARIABLE_NAME, | ||
DEVNET_CONTRACT_PACKAGE_ID, | ||
DEVNET_EXPLORER_URL, | ||
EXPLORER_URL_VARIABLE_NAME, | ||
LOCALNET_CONTRACT_PACKAGE_ID, | ||
LOCALNET_EXPLORER_URL, | ||
MAINNET_CONTRACT_PACKAGE_ID, | ||
MAINNET_EXPLORER_URL, | ||
TESTNET_CONTRACT_PACKAGE_ID, | ||
TESTNET_EXPLORER_URL, | ||
} from '@/config/networks' | ||
import { ENetwork } from '@/types/ENetwork' | ||
import { createNetworkConfig } from '@mysten/dapp-kit' | ||
import { getFullnodeUrl } from '@mysten/sui.js/client' | ||
|
||
export const getNetworkConfig = () => { | ||
return createNetworkConfig({ | ||
[ENetwork.LOCALNET]: { | ||
url: getFullnodeUrl(ENetwork.LOCALNET), | ||
variables: { | ||
[CONTRACT_PACKAGE_VARIABLE_NAME]: LOCALNET_CONTRACT_PACKAGE_ID, | ||
[EXPLORER_URL_VARIABLE_NAME]: LOCALNET_EXPLORER_URL, | ||
}, | ||
}, | ||
[ENetwork.DEVNET]: { | ||
url: getFullnodeUrl(ENetwork.DEVNET), | ||
variables: { | ||
[CONTRACT_PACKAGE_VARIABLE_NAME]: DEVNET_CONTRACT_PACKAGE_ID, | ||
[EXPLORER_URL_VARIABLE_NAME]: DEVNET_EXPLORER_URL, | ||
}, | ||
}, | ||
[ENetwork.TESTNET]: { | ||
url: getFullnodeUrl(ENetwork.TESTNET), | ||
variables: { | ||
[CONTRACT_PACKAGE_VARIABLE_NAME]: TESTNET_CONTRACT_PACKAGE_ID, | ||
[EXPLORER_URL_VARIABLE_NAME]: TESTNET_EXPLORER_URL, | ||
}, | ||
}, | ||
[ENetwork.MAINNET]: { | ||
url: getFullnodeUrl(ENetwork.MAINNET), | ||
variables: { | ||
[CONTRACT_PACKAGE_VARIABLE_NAME]: MAINNET_CONTRACT_PACKAGE_ID, | ||
[EXPLORER_URL_VARIABLE_NAME]: MAINNET_EXPLORER_URL, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
export const transactionUrl = (explorerUrl: string, txDigest: string) => { | ||
return `${explorerUrl}/txblock/${txDigest}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
CONTRACT_PACKAGE_VARIABLE_NAME, | ||
DEVNET_CONTRACT_PACKAGE_ID, | ||
DEVNET_EXPLORER_URL, | ||
EXPLORER_URL_VARIABLE_NAME, | ||
LOCALNET_CONTRACT_PACKAGE_ID, | ||
LOCALNET_EXPLORER_URL, | ||
MAINNET_CONTRACT_PACKAGE_ID, | ||
MAINNET_EXPLORER_URL, | ||
TESTNET_CONTRACT_PACKAGE_ID, | ||
TESTNET_EXPLORER_URL, | ||
} from '@/config/networks' | ||
import { ENetwork } from '@/types/ENetwork' | ||
import { createNetworkConfig } from '@mysten/dapp-kit' | ||
import { getFullnodeUrl } from '@mysten/sui.js/client' | ||
|
||
const useNetworkConfig = () => { | ||
return createNetworkConfig({ | ||
[ENetwork.LOCALNET]: { | ||
url: getFullnodeUrl(ENetwork.LOCALNET), | ||
variables: { | ||
[CONTRACT_PACKAGE_VARIABLE_NAME]: LOCALNET_CONTRACT_PACKAGE_ID, | ||
[EXPLORER_URL_VARIABLE_NAME]: LOCALNET_EXPLORER_URL, | ||
}, | ||
}, | ||
[ENetwork.DEVNET]: { | ||
url: getFullnodeUrl(ENetwork.DEVNET), | ||
variables: { | ||
[CONTRACT_PACKAGE_VARIABLE_NAME]: DEVNET_CONTRACT_PACKAGE_ID, | ||
[EXPLORER_URL_VARIABLE_NAME]: DEVNET_EXPLORER_URL, | ||
}, | ||
}, | ||
[ENetwork.TESTNET]: { | ||
url: getFullnodeUrl(ENetwork.TESTNET), | ||
variables: { | ||
[CONTRACT_PACKAGE_VARIABLE_NAME]: TESTNET_CONTRACT_PACKAGE_ID, | ||
[EXPLORER_URL_VARIABLE_NAME]: TESTNET_EXPLORER_URL, | ||
}, | ||
}, | ||
[ENetwork.MAINNET]: { | ||
url: getFullnodeUrl(ENetwork.MAINNET), | ||
variables: { | ||
[CONTRACT_PACKAGE_VARIABLE_NAME]: MAINNET_CONTRACT_PACKAGE_ID, | ||
[EXPLORER_URL_VARIABLE_NAME]: MAINNET_EXPLORER_URL, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
export default useNetworkConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters