Skip to content

Commit

Permalink
Merge branch 'main' into noves
Browse files Browse the repository at this point in the history
  • Loading branch information
NahuelNoves committed Mar 3, 2024
2 parents b68a924 + 421e2a3 commit bac02c0
Show file tree
Hide file tree
Showing 66 changed files with 1,175 additions and 936 deletions.
7 changes: 4 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,15 @@
"options": [
"main",
"main.L2",
"poa_core",
"eth",
"eth_goerli",
"sepolia",
"eth",
"rootstock",
"polygon",
"zkevm",
"gnosis",
"rootstock",
"stability",
"poa_core",
"localhost",
],
"default": "main"
Expand Down
60 changes: 60 additions & 0 deletions configs/envs/.env.stability
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Set of ENVs for Ethereum network explorer
# https://eth.blockscout.com/

# app configuration
NEXT_PUBLIC_APP_PROTOCOL=http
NEXT_PUBLIC_APP_HOST=localhost
NEXT_PUBLIC_APP_PORT=3000

# blockchain parameters
NEXT_PUBLIC_NETWORK_NAME=Stability Testnet
NEXT_PUBLIC_NETWORK_SHORT_NAME=Stability
NEXT_PUBLIC_NETWORK_ID=20180427
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=FREE
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=FREE
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18
NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE=validation
NEXT_PUBLIC_NETWORK_RPC_URL=https://free.testnet.stabilityprotocol.com
NEXT_PUBLIC_IS_TESTNET=true

# api configuration
NEXT_PUBLIC_API_HOST=stability-testnet.blockscout.com
NEXT_PUBLIC_API_BASE_PATH=/

# ui config
## homepage
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs']
NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND="rgb(255, 145, 0)"
NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND="rgba(46, 51, 81, 1)"
NEXT_PUBLIC_HOMEPAGE_PLATE_TEXT_COLOR="rgba(122, 235, 246, 1)"
## sidebar
NEXT_PUBLIC_FEATURED_NETWORKS=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/featured-networks/rsk-testnet.json
NEXT_PUBLIC_NETWORK_LOGO=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-logos/stability.svg
NEXT_PUBLIC_NETWORK_LOGO_DARK=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-logos/stability-dark.svg
NEXT_PUBLIC_NETWORK_ICON=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/stability-short.svg
NEXT_PUBLIC_NETWORK_ICON_DARK=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/stability-short-dark.svg
## footer
## views
NEXT_PUBLIC_VIEWS_ADDRESS_HIDDEN_VIEWS="['top_accounts']"
NEXT_PUBLIC_VIEWS_TX_HIDDEN_FIELDS="['value','fee_currency','gas_price','gas_fees','burnt_fees']"
NEXT_PUBLIC_VIEWS_TX_ADDITIONAL_FIELDS="['fee_per_gas']"
NEXT_PUBLIC_VIEWS_BLOCK_HIDDEN_FIELDS="['burnt_fees','total_reward']"
## misc

# app features
NEXT_PUBLIC_APP_ENV=development
NEXT_PUBLIC_HAS_BEACON_CHAIN=false
NEXT_PUBLIC_STATS_API_HOST=https://stats-stability-testnet.k8s.blockscout.com
NEXT_PUBLIC_VISUALIZE_API_HOST=https://visualizer.services.blockscout.com
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=https://admin-rs.services.blockscout.com
NEXT_PUBLIC_CONTRACT_CODE_IDES="[{'title':'Remix IDE','url':'https://remix.blockscout.com/?address={hash}&blockscout={domain}','icon_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/ide-icons/remix.png'}]"
NEXT_PUBLIC_MARKETPLACE_ENABLED=true
NEXT_PUBLIC_MARKETPLACE_CATEGORIES_URL=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/marketplace-categories/default.json
NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM=https://airtable.com/shrqUAcjgGJ4jU88C
NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM=https://airtable.com/appiy5yijZpMMSKjT/pag3t82DUCyhGRZZO/form
NEXT_PUBLIC_CONTRACT_INFO_API_HOST=https://contracts-info.services.blockscout.com/
NEXT_PUBLIC_GAS_TRACKER_ENABLED=false
NEXT_PUBLIC_VALIDATORS_CHAIN_TYPE='stability'

#meta
NEXT_PUBLIC_OG_IMAGE_URL=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/og-images/stability.png
19 changes: 11 additions & 8 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ B. Pre-defined configuration:
1. Optionally, clone `.env.example` file into `configs/envs/.env.secrets`. Fill it with necessary secrets for integrating with [external services](./ENVS.md#external-services-configuration). Include only secrets your need.
2. Choose one of the predefined configurations located in the `/configs/envs` folder.
3. Start your local dev server using the `yarn dev:<config_name>` command.
3. Start your local dev server using the `yarn dev:preset <config_preset_name>` command.
4. Open your browser and navigate to the URL provided in the command line output (by default, it is `http://localhost:3000`).
Expand All @@ -79,26 +79,29 @@ These are the steps that you have to follow to make everything work:
2. Make sure that you have added a property to React app config (`configs/app/index.ts`) in appropriate section that is associated with this variable; do not use ENV variable values directly in the application code; decide where this variable belongs to and place it under the certain section:
- `app` - the front-end app itself
- `api` - the main API configuration
- `chain` - the Blockchain parameters
- `UI` - the app UI customization
- `meta` - SEO and meta-tags customization
- `features` - the particular feature of the app
- `services` - some 3rd party service integration which is not related to one particular feature
3. For local development purposes add the variable with its appropriate values to pre-defined ENV configs `configs/envs` where it is needed
4. Add the variable to CI configs where it is needed
- `services` - some 3rd party service integration which is not related to one particular feature
3. If a new variable is meant to store the URL of an external API service, remember to include its value in the Content-Security-Policy document header. Refer to `nextjs/csp/policies/app.ts` for details.
4. For local development purposes add the variable with its appropriate values to pre-defined ENV configs `configs/envs` where it is needed
5. Add the variable to CI configs where it is needed
- `deploy/values/review/values.yaml.gotmpl` - review development environment
- `deploy/values/main/values.yaml` - main development environment
- `deploy/values/review-l2/values.yaml.gotmpl` - review development environment for L2 networks
- `deploy/values/l2-optimism-goerli/values.yaml` - main development environment
5. If your variable is meant to receive a link to some external resource (image or JSON-config file), extend the array `ASSETS_ENVS` in `deploy/scripts/download_assets.sh` with your variable name
6. Add validation schema for the new variable into the file `deploy/tools/envs-validator/schema.ts`
7. Check if modified validation schema is valid by doing the following steps:
6. If your variable is meant to receive a link to some external resource (image or JSON-config file), extend the array `ASSETS_ENVS` in `deploy/scripts/download_assets.sh` with your variable name
7. Add validation schema for the new variable into the file `deploy/tools/envs-validator/schema.ts`
8. Check if modified validation schema is valid by doing the following steps:
- change your current directory to `deploy/tools/envs-validator`
- install deps with `yarn` command
- add your variable into `./test/.env.base` test preset or create a new test preset if needed
- if your variable contains a link to the external JSON config file:
- add example of file content into `./test/assets` directory; the file name should be constructed by stripping away prefix `NEXT_PUBLIC_` and postfix `_URL` if any, and converting the remaining string to lowercase (for example, `NEXT_PUBLIC_MARKETPLACE_CONFIG_URL` will become `marketplace_config.json`)
- in the main script `index.ts` extend array `envsWithJsonConfig` with your variable name
- run `yarn test` command to see the validation result
8. Don't forget to mention in the PR notes that new ENV variable was added
9. Don't forget to mention in the PR notes that new ENV variable was added
&nbsp;
Expand Down
2 changes: 1 addition & 1 deletion lib/api/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ export const RESOURCES = {
validators: {
path: '/api/v2/validators/:chainType',
pathParams: [ 'chainType' as const ],
filterFields: [ 'address_hash' as const, 'state' as const ],
filterFields: [ 'address_hash' as const, 'state_filter' as const ],
},
validators_counters: {
path: '/api/v2/validators/:chainType/counters',
Expand Down
2 changes: 1 addition & 1 deletion lib/metadata/templates/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TEMPLATE_MAP: Record<Route['pathname'], string> = {
'/address/[hash]/contract-verification': 'contract verification for %hash%',
'/tokens': 'tokens',
'/token/[hash]': '%symbol% token details',
'/token/[hash]/instance/[id]': 'token instance for %symbol%',
'/token/[hash]/instance/[id]': 'NFT instance',
'/apps': 'apps marketplace',
'/apps/[id]': '- %app_name%',
'/stats': 'statistics',
Expand Down
5 changes: 1 addition & 4 deletions lib/metadata/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import type { Route } from 'nextjs-routes';
import generate from './generate';

export default function update<R extends Route>(route: R, apiData: ApiData<R>) {
const { title, description, opengraph } = generate(route, apiData);
const { title, description } = generate(route, apiData);

window.document.title = title;
window.document.querySelector('meta[name="description"]')?.setAttribute('content', description);
window.document.querySelector('meta[property="og:title"]')?.setAttribute('content', opengraph.title);
opengraph.description &&
window.document.querySelector('meta[property="og:description"]')?.setAttribute('content', opengraph.description);
}
7 changes: 6 additions & 1 deletion lib/mixpanel/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export enum EventTypes {
PAGE_WIDGET = 'Page widget',
TX_INTERPRETATION_INTERACTION = 'Transaction interpratetion interaction',
EXPERIMENT_STARTED = 'Experiment started',
FILTERS = 'Filters'
FILTERS = 'Filters',
BUTTON_CLICK = 'Button click',
}

/* eslint-disable @typescript-eslint/indent */
Expand Down Expand Up @@ -107,5 +108,9 @@ Type extends EventTypes.FILTERS ? {
'Source': 'Marketplace';
'Filter name': string;
} :
Type extends EventTypes.BUTTON_CLICK ? {
'Content': 'Swap button';
'Source': string;
} :
undefined;
/* eslint-enable @typescript-eslint/indent */
6 changes: 6 additions & 0 deletions mocks/contract/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export const write: Array<SmartContractWriteMethod> = [
payable: false,
stateMutability: 'nonpayable',
type: 'function',
method_id: '0x01',
},
{
constant: false,
Expand All @@ -146,6 +147,7 @@ export const write: Array<SmartContractWriteMethod> = [
payable: true,
stateMutability: 'payable',
type: 'function',
method_id: '0x02',
},
{
stateMutability: 'payable',
Expand All @@ -159,6 +161,7 @@ export const write: Array<SmartContractWriteMethod> = [
payable: false,
stateMutability: 'nonpayable',
type: 'function',
method_id: '0x03',
},
{
constant: false,
Expand All @@ -173,6 +176,7 @@ export const write: Array<SmartContractWriteMethod> = [
payable: false,
stateMutability: 'nonpayable',
type: 'function',
method_id: '0x04',
},
{
constant: false,
Expand All @@ -190,6 +194,7 @@ export const write: Array<SmartContractWriteMethod> = [
payable: false,
stateMutability: 'nonpayable',
type: 'function',
method_id: '0x05',
},
{
constant: false,
Expand All @@ -208,5 +213,6 @@ export const write: Array<SmartContractWriteMethod> = [
payable: false,
stateMutability: 'nonpayable',
type: 'function',
method_id: '0x06',
},
];
3 changes: 3 additions & 0 deletions nextjs/csp/policies/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const getCspReportUrl = () => {
};

export function app(): CspDev.DirectiveDescriptor {
const marketplaceFeaturePayload = getFeaturePayload(config.features.marketplace);

return {
'default-src': [
// KEY_WORDS.NONE,
Expand All @@ -54,6 +56,7 @@ export function app(): CspDev.DirectiveDescriptor {
getFeaturePayload(config.features.verifiedTokens)?.api.endpoint,
getFeaturePayload(config.features.addressVerification)?.api.endpoint,
getFeaturePayload(config.features.nameService)?.api.endpoint,
marketplaceFeaturePayload && 'api' in marketplaceFeaturePayload ? marketplaceFeaturePayload.api.endpoint : '',

// chain RPC server
config.chain.rpcUrl,
Expand Down
7 changes: 3 additions & 4 deletions types/api/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ export interface SmartContractMethodBase {
type: 'function';
payable: boolean;
error?: string;
}

export interface SmartContractReadMethod extends SmartContractMethodBase {
method_id: string;
}

export type SmartContractReadMethod = SmartContractMethodBase;

export interface SmartContractWriteFallback {
payable?: true;
stateMutability: 'payable';
Expand All @@ -85,7 +84,7 @@ export type SmartContractWriteMethod = SmartContractMethodBase | SmartContractWr
export type SmartContractMethod = SmartContractReadMethod | SmartContractWriteMethod;

export interface SmartContractMethodInput {
internalType?: SmartContractMethodArgType;
internalType?: string; // there could be any string, e.g "enum MyEnum"
name: string;
type: SmartContractMethodArgType;
components?: Array<SmartContractMethodInput>;
Expand Down
Loading

0 comments on commit bac02c0

Please sign in to comment.