Skip to content

Commit

Permalink
adding klaster sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
nampc1 committed Sep 4, 2024
1 parent f5a247f commit e028c32
Show file tree
Hide file tree
Showing 8 changed files with 279 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"@polkadot/types-support": "^12.0.2",
"@polkadot/util": "^12.6.2",
"@polkadot/util-crypto": "^12.6.2",
"@subwallet/chain-list": "0.2.82",
"@subwallet/chain-list": "0.2.85-beta.0",
"@subwallet/keyring": "^0.1.5",
"@subwallet/react-ui": "5.1.2-b79",
"@subwallet/ui-keyring": "^0.1.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/extension-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@reduxjs/toolkit": "^1.9.1",
"@sora-substrate/type-definitions": "^1.17.7",
"@substrate/connect": "^0.8.9",
"@subwallet/chain-list": "0.2.82",
"@subwallet/chain-list": "0.2.85-beta.0",
"@subwallet/extension-base": "^1.2.26-0",
"@subwallet/extension-chains": "^1.2.26-0",
"@subwallet/extension-dapp": "^1.2.26-0",
Expand Down Expand Up @@ -83,6 +83,7 @@
"i18next": "^21.9.2",
"is-buffer": "^2.0.5",
"json-rpc-engine": "^6.1.0",
"klaster-sdk": "^0.5.10",
"manta-extension-sdk": "^1.1.0",
"moment": "^2.29.4",
"protobufjs": "^7.2.4",
Expand Down
10 changes: 9 additions & 1 deletion packages/extension-base/src/services/chain-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-se
import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
import { _ChainApiStatus, _ChainConnectionStatus, _ChainState, _CUSTOM_PREFIX, _DataMap, _EvmApi, _NetworkUpsertParams, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS, _SmartContractTokenInfo, _SubstrateApi, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse } from '@subwallet/extension-base/services/chain-service/types';
import { _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, fetchPatchData, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
import { _getEvmChainId, _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, fetchPatchData, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
import { EventService } from '@subwallet/extension-base/services/event-service';
import { IChain, IMetadataItem } from '@subwallet/extension-base/services/storage-service/databases';
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
import { addLazy, calculateMetadataHash, fetchStaticData, filterAssetsByChainAndType, getShortMetadata, MODULE_SUPPORT } from '@subwallet/extension-base/utils';
import { buildMultichainReadonlyClient, buildRpcInfo } from 'klaster-sdk';
import { BehaviorSubject, Subject } from 'rxjs';
import Web3 from 'web3';

Expand Down Expand Up @@ -845,6 +846,13 @@ export class ChainService {
const chainInfoMap = this.getChainInfoMap();
const chainStateMap = this.getChainStateMap();

const klasterClient = buildMultichainReadonlyClient([
buildRpcInfo(_getEvmChainId(chainInfoMap.base_sepolia) as number, Object.values(chainInfoMap.base_sepolia.providers)[0]),
buildRpcInfo(_getEvmChainId(chainInfoMap.sepolia_ethereum) as number, Object.values(chainInfoMap.sepolia_ethereum.providers)[0])
]);

console.log(klasterClient);

await Promise.all(Object.entries(chainInfoMap)
.filter(([slug]) => chainStateMap[slug]?.active)
.map(([, chainInfo]) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-koni-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@polkadot/util-crypto": "^12.6.2",
"@ramonak/react-progress-bar": "^5.0.3",
"@reduxjs/toolkit": "^1.9.1",
"@subwallet/chain-list": "0.2.82",
"@subwallet/chain-list": "0.2.85-beta.0",
"@subwallet/extension-base": "^1.2.26-0",
"@subwallet/extension-chains": "^1.2.26-0",
"@subwallet/extension-dapp": "^1.2.26-0",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@polkadot/util-crypto": "^12.6.2",
"@ramonak/react-progress-bar": "^5.0.3",
"@reduxjs/toolkit": "^1.9.1",
"@subwallet/chain-list": "0.2.82",
"@subwallet/chain-list": "0.2.85-beta.0",
"@subwallet/extension-base": "^1.2.26-0",
"@subwallet/extension-chains": "^1.2.26-0",
"@subwallet/extension-dapp": "^1.2.26-0",
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4"
}
}
}
3 changes: 3 additions & 0 deletions packages/webapp/webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ const createConfig = (entry, alias = {}, useSplitChunk = false) => {
{
exclude: /(node_modules\/(?!(@equilab|@subwallet|@polkadot\/rpc-core)).*)/,
test: /\.(js|mjs|ts|tsx)$/,
resolve: {
fullySpecified: false
},
use: [
{
loader: require.resolve('babel-loader'),
Expand Down
Loading

0 comments on commit e028c32

Please sign in to comment.