Skip to content

Commit

Permalink
Merge branch 'refs/heads/subwallet-dev' into web-runner-cron
Browse files Browse the repository at this point in the history
  • Loading branch information
bluezdot committed Feb 6, 2025
2 parents daf1161 + ebef6e8 commit e5b1b8a
Show file tree
Hide file tree
Showing 33 changed files with 228 additions and 155 deletions.
3 changes: 2 additions & 1 deletion .123trigger
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,5 @@
1.3.10
1.3.11
1.3.12
1.3.13
1.3.13
1.3.14
18 changes: 11 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ COINBASE_PAY_ID=1dbd2a0b94
NFT_MINTING_HOST=http://...
CHAINFLIP_BROKER_API=93c2bff017e243f29ffb14e42dccbec8
BRANCH_NAME=master
BITTENSOR_API_KEY_1=abavbav
BITTENSOR_API_KEY_2=abafdbad
BITTENSOR_API_KEY_3=abafdbad3
BITTENSOR_API_KEY_4=abafdbad4
BITTENSOR_API_KEY_5=abafdbad5
BITTENSOR_API_KEY_6=abafdbad6
SIMPLE_SWAP_API_KEY=abacasdf
BITTENSOR_API_KEY_1=tao-abafdbad1
BITTENSOR_API_KEY_2=tao-abafdbad2
BITTENSOR_API_KEY_3=tao-abafdbad3
BITTENSOR_API_KEY_4=tao-abafdbad4
BITTENSOR_API_KEY_5=tao-abafdbad5
BITTENSOR_API_KEY_6=tao-abafdbad6
BITTENSOR_API_KEY_7=tao-abafdbad7
BITTENSOR_API_KEY_8=tao-abafdbad8
BITTENSOR_API_KEY_9=tao-abafdbad9
BITTENSOR_API_KEY_10=tao-abafdbad10
SIMPLE_SWAP_API_KEY=26c8c21
4 changes: 4 additions & 0 deletions .github/workflows/push-koni-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ jobs:
BITTENSOR_API_KEY_4: ${{ secrets.BITTENSOR_API_KEY_4 }}
BITTENSOR_API_KEY_5: ${{ secrets.BITTENSOR_API_KEY_5 }}
BITTENSOR_API_KEY_6: ${{ secrets.BITTENSOR_API_KEY_6 }}
BITTENSOR_API_KEY_7: ${{ secrets.BITTENSOR_API_KEY_7 }}
BITTENSOR_API_KEY_8: ${{ secrets.BITTENSOR_API_KEY_8 }}
BITTENSOR_API_KEY_9: ${{ secrets.BITTENSOR_API_KEY_9 }}
BITTENSOR_API_KEY_10: ${{ secrets.BITTENSOR_API_KEY_10 }}
SIMPLE_SWAP_API_KEY: ${{ secrets.SIMPLE_SWAP_API_KEY }}
GH_RELEASE_FILES: master-build.zip,master-src.zip
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ jobs:
BITTENSOR_API_KEY_4: ${{ secrets.BITTENSOR_API_KEY_4 }}
BITTENSOR_API_KEY_5: ${{ secrets.BITTENSOR_API_KEY_5 }}
BITTENSOR_API_KEY_6: ${{ secrets.BITTENSOR_API_KEY_6 }}
BITTENSOR_API_KEY_7: ${{ secrets.BITTENSOR_API_KEY_7 }}
BITTENSOR_API_KEY_8: ${{ secrets.BITTENSOR_API_KEY_8 }}
BITTENSOR_API_KEY_9: ${{ secrets.BITTENSOR_API_KEY_9 }}
BITTENSOR_API_KEY_10: ${{ secrets.BITTENSOR_API_KEY_10 }}
SIMPLE_SWAP_API_KEY: ${{ secrets.SIMPLE_SWAP_API_KEY }}
BRANCH_NAME: ${{ github.ref_name }}
run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/push-web-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
BITTENSOR_API_KEY_4: ${{ secrets.BITTENSOR_API_KEY_4 }}
BITTENSOR_API_KEY_5: ${{ secrets.BITTENSOR_API_KEY_5 }}
BITTENSOR_API_KEY_6: ${{ secrets.BITTENSOR_API_KEY_6 }}
BITTENSOR_API_KEY_7: ${{ secrets.BITTENSOR_API_KEY_7 }}
BITTENSOR_API_KEY_8: ${{ secrets.BITTENSOR_API_KEY_8 }}
BITTENSOR_API_KEY_9: ${{ secrets.BITTENSOR_API_KEY_9 }}
BITTENSOR_API_KEY_10: ${{ secrets.BITTENSOR_API_KEY_10 }}
SIMPLE_SWAP_API_KEY: ${{ secrets.SIMPLE_SWAP_API_KEY }}
BRANCH_NAME: master
run: |
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/push-webapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ jobs:
CHAINFLIP_BROKER_API: ${{ secrets.CHAINFLIP_BROKER_API }}
BITTENSOR_API_KEY_1: ${{ secrets.BITTENSOR_API_KEY_1 }}
BITTENSOR_API_KEY_2: ${{ secrets.BITTENSOR_API_KEY_2 }}
BITTENSOR_API_KEY_3: ${{ secrets.BITTENSOR_API_KEY_3 }}
BITTENSOR_API_KEY_4: ${{ secrets.BITTENSOR_API_KEY_4 }}
BITTENSOR_API_KEY_5: ${{ secrets.BITTENSOR_API_KEY_5 }}
BITTENSOR_API_KEY_6: ${{ secrets.BITTENSOR_API_KEY_6 }}
BITTENSOR_API_KEY_7: ${{ secrets.BITTENSOR_API_KEY_7 }}
BITTENSOR_API_KEY_8: ${{ secrets.BITTENSOR_API_KEY_8 }}
BITTENSOR_API_KEY_9: ${{ secrets.BITTENSOR_API_KEY_9 }}
BITTENSOR_API_KEY_10: ${{ secrets.BITTENSOR_API_KEY_10 }}
SIMPLE_SWAP_API_KEY: ${{ secrets.SIMPLE_SWAP_API_KEY }}
BRANCH_NAME: ${{ github.ref_name }}
run: |
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## 1.3.14
Build date: Jan 24, 2025.

Features & Update:
- Update chain-list stable (#3974)
- Add staking support for CERE (#360)


## 1.3.13
Build date: Jan 21, 2025.

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
2929 AnhMTV
2931 AnhMTV Release version 1.3.14
2552 Nam Phạm [Issue 3855] test: add log
2390 S2kael
2391 S2kael [CERE] Active nomination pool
869 lw-cdm [MasterAccount] Update logic to reorder account on select account modal
568 nguyentiendung [Issue-3553] [Issue-3553] Refactor code and add recipient to swap history.
492 bluezdot
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "https://github.com/Koniverse/Subwallet-V2.git"
},
"sideEffects": false,
"version": "1.3.14-0",
"version": "1.3.14",
"workspaces": [
"packages/*"
],
Expand Down
12 changes: 6 additions & 6 deletions packages/extension-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "1.3.14-0",
"version": "1.3.14-2",
"main": "index.js",
"dependencies": {
"@acala-network/api": "^5.0.2",
Expand Down Expand Up @@ -56,10 +56,10 @@
"@sora-substrate/type-definitions": "^1.17.7",
"@substrate/connect": "^0.8.9",
"@subwallet/chain-list": "0.2.98",
"@subwallet/extension-base": "^1.3.14-0",
"@subwallet/extension-chains": "^1.3.14-0",
"@subwallet/extension-dapp": "^1.3.14-0",
"@subwallet/extension-inject": "^1.3.14-0",
"@subwallet/extension-base": "^1.3.14-2",
"@subwallet/extension-chains": "^1.3.14-2",
"@subwallet/extension-dapp": "^1.3.14-2",
"@subwallet/extension-inject": "^1.3.14-2",
"@subwallet/keyring": "^0.1.8-beta.0",
"@subwallet/ui-keyring": "^0.1.8-beta.0",
"@ton/core": "^0.56.3",
Expand Down Expand Up @@ -105,7 +105,7 @@
"web3-utils": "^1.10.0"
},
"devDependencies": {
"@subwallet/extension-mocks": "^1.3.14-0",
"@subwallet/extension-mocks": "^1.3.14-2",
"@types/uuid": "^9.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/extension-base/src/packageInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

// Do not edit, auto-generated by @polkadot/dev

export const packageInfo = { name: '@subwallet/extension-base', path: 'auto', type: 'auto', version: '1.3.14-0' };
export const packageInfo = { name: '@subwallet/extension-base', path: 'auto', type: 'auto', version: '1.3.14-2' };
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ export class ChainOnlineService {
return true;
}

mergeChainList (oldChainInfoMap: Record<string, _ChainInfo>, latestChainInfo: Record<string, _ChainInfo>) {
const rs: Record<string, _ChainInfo> = structuredClone(oldChainInfoMap);

for (const [slug, _info] of Object.entries(latestChainInfo)) {
const { providers: _providers, ...info } = _info;
const providers = Object.assign(rs[slug]?.providers || {}, _providers);

rs[slug] = {
...info,
providers
};
}

return rs;
}

async handleLatestPatch (latestPatch: PatchInfo) {
try {
// 1. validate fetch data with its hash
Expand All @@ -95,7 +111,7 @@ export class ChainOnlineService {

// 2. merge data map
if (latestChainInfo && Object.keys(latestChainInfo).length > 0) {
chainInfoMap = Object.assign({}, oldChainInfoMap, latestChainInfo);
chainInfoMap = this.mergeChainList(oldChainInfoMap, latestChainInfo);

const [currentChainStateKey, newChainKey] = [Object.keys(currentChainStateMap), Object.keys(chainInfoMap)];

Expand Down
112 changes: 56 additions & 56 deletions packages/extension-base/src/services/chain-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ export class ChainService {
/**
* Disable chain if not found provider
* */
if (!endpoint && !providerName) {
if (!endpoint || !providerName) {
this.disableChain(chainInfo.slug);

return;
Expand Down Expand Up @@ -859,7 +859,8 @@ export class ChainService {
body: JSON.stringify(requestBody)
})
// eslint-disable-next-line @typescript-eslint/no-empty-function
.then(() => {})
.then(() => {
})
.catch((error) => console.error('Error connecting to the report API:', error));
}

Expand Down Expand Up @@ -1126,6 +1127,34 @@ export class ChainService {
} else {
const mergedChainInfoMap: Record<string, _ChainInfo> = defaultChainInfoMap;

// Reselect provider for chain
const updateCurrentProvider = (providers: Record<string, string>, storedChainInfo: IChain, storeSlug: string, active: boolean, forceFistProvider = false): string => {
const manualTurnOff = !!storedChainInfo.manualTurnOff;
// For case only custom providers in list, randomize function will infinite loop, so force select first provider
const { providerKey } = forceFistProvider ? { providerKey: Object.keys(providers)[0] } : randomizeProvider(providers);
let selectedProvider = providerKey;

const storedProviderKey = storedChainInfo.currentProvider;
const storedProviderValue = storedChainInfo.providers[storedProviderKey] || '';

if (storedProviderValue?.startsWith('light') || storedProviderKey?.startsWith(_CUSTOM_PREFIX)) {
const savedProviderKey = Object.keys(providers).find((key) => providers[key] === storedProviderValue);

if (savedProviderKey) {
selectedProvider = savedProviderKey;
}
}

newStorageData.push({
...mergedChainInfoMap[storeSlug],
active,
currentProvider: selectedProvider,
manualTurnOff
});

return selectedProvider;
};

for (const [storedSlug, storedChainInfo] of Object.entries(storedChainSettingMap)) {
const chainInfo = defaultChainInfoMap[storedSlug];
const manualTurnOff = !!storedChainInfo.manualTurnOff;
Expand All @@ -1146,26 +1175,13 @@ export class ChainService {

mergedChainInfoMap[storedSlug].providers = providers;

const { providerKey } = randomizeProvider(providers);
let selectedProvider = providerKey;

const storedProviderKey = storedChainInfo.currentProvider;
const storedProviderValue = storedChainInfo.providers[storedProviderKey] || '';

if (storedProviderValue?.startsWith('light') || storedProviderKey?.startsWith(_CUSTOM_PREFIX)) {
const savedProviderKey = Object.keys(providers).find((key) => providers[key] === storedProviderValue);

if (savedProviderKey) {
selectedProvider = savedProviderKey;
}
}

// Merge current provider
// let currentProvider = storedChainInfo.currentProvider;
// const providerValue = storedChainInfo.providers[selectedProvider] || '';

const hasProvider = Object.values(providers).length > 0;
const canActive = hasProvider && chainInfo.chainStatus === _ChainStatus.ACTIVE;
const selectedProvider = updateCurrentProvider(providers, storedChainInfo, storedSlug, canActive && storedChainInfo.active);

this.dataMap.chainStateMap[storedSlug] = {
currentProvider: selectedProvider,
Expand All @@ -1175,36 +1191,26 @@ export class ChainService {
};

this.updateChainConnectionStatus(storedSlug, _ChainConnectionStatus.DISCONNECTED);

newStorageData.push({
...mergedChainInfoMap[storedSlug],
active: canActive && storedChainInfo.active,
currentProvider: selectedProvider,
manualTurnOff
});
} else if (_isCustomChain(storedSlug)) {
// only custom chains are left
// check custom chain duplicated with predefined chain => merge into predefined chain
const duplicatedDefaultSlug = this.checkExistedPredefinedChain(defaultChainInfoMap, storedChainInfo.substrateInfo?.genesisHash, storedChainInfo.evmInfo?.evmChainId);

if (duplicatedDefaultSlug.length > 0) { // merge custom chain with existed chain
mergedChainInfoMap[duplicatedDefaultSlug].providers = { ...storedChainInfo.providers, ...mergedChainInfoMap[duplicatedDefaultSlug].providers };
const providers = { ...storedChainInfo.providers, ...mergedChainInfoMap[duplicatedDefaultSlug].providers };

mergedChainInfoMap[duplicatedDefaultSlug].providers = providers;
const selectedProvider = updateCurrentProvider(providers, storedChainInfo, duplicatedDefaultSlug, storedChainInfo.active);

this.dataMap.chainStateMap[duplicatedDefaultSlug] = {
currentProvider: storedChainInfo.currentProvider,
currentProvider: selectedProvider,
slug: duplicatedDefaultSlug,
active: storedChainInfo.active,
manualTurnOff
};

this.updateChainConnectionStatus(duplicatedDefaultSlug, _ChainConnectionStatus.DISCONNECTED);

newStorageData.push({
...mergedChainInfoMap[duplicatedDefaultSlug],
active: storedChainInfo.active,
currentProvider: storedChainInfo.currentProvider,
manualTurnOff
});

deprecatedChainMap[storedSlug] = duplicatedDefaultSlug;

deprecatedChains.push(storedSlug);
Expand All @@ -1222,39 +1228,21 @@ export class ChainService {
icon: storedChainInfo.icon,
extraInfo: storedChainInfo.extraInfo
};

const providers = storedChainInfo.providers;
// This case, providers are all custom providers, need force select first provider
const selectedProvider = updateCurrentProvider(providers, storedChainInfo, storedSlug, storedChainInfo.active, true);

this.dataMap.chainStateMap[storedSlug] = {
currentProvider: storedChainInfo.currentProvider, // TODO: review
currentProvider: selectedProvider, // TODO: review
slug: storedSlug,
active: storedChainInfo.active,
manualTurnOff
};

this.updateChainConnectionStatus(storedSlug, _ChainConnectionStatus.DISCONNECTED);

newStorageData.push({
...mergedChainInfoMap[storedSlug],
active: storedChainInfo.active,
currentProvider: storedChainInfo.currentProvider, // TODO: review
manualTurnOff
});
}
} else { // added chain from patch
this.dataMap.chainStateMap[storedSlug] = {
currentProvider: storedChainInfo.currentProvider,
slug: storedSlug,
active: storedChainInfo.active,
manualTurnOff
};

this.updateChainConnectionStatus(storedSlug, _ChainConnectionStatus.DISCONNECTED);

newStorageData.push({
...storedChainSettingMap[storedSlug],
active: storedChainInfo.active,
currentProvider: storedChainInfo.currentProvider,
manualTurnOff
});

mergedChainInfoMap[storedSlug] = {
slug: storedSlug,
name: storedChainInfo.name,
Expand All @@ -1269,6 +1257,18 @@ export class ChainService {
extraInfo: storedChainInfo.extraInfo
};

const providers = storedChainInfo.providers;
const selectedProvider = updateCurrentProvider(providers, storedChainInfo, storedSlug, storedChainInfo.active);

this.dataMap.chainStateMap[storedSlug] = {
currentProvider: selectedProvider,
slug: storedSlug,
active: storedChainInfo.active,
manualTurnOff
};

this.updateChainConnectionStatus(storedSlug, _ChainConnectionStatus.DISCONNECTED);

deprecatedChainMap[storedSlug] = storedSlug; // todo: set a better name
}
}
Expand Down
Loading

0 comments on commit e5b1b8a

Please sign in to comment.