Skip to content

Commit

Permalink
Add Test Community Migrations and Modify Chain Model (#1150)
Browse files Browse the repository at this point in the history
* add yearn and fei as chains
* modify chain model
* add migration
* add icons
  • Loading branch information
fstar1129 authored and dillchen committed Jul 14, 2021
1 parent 6ed57bf commit d753753
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 5 deletions.
11 changes: 6 additions & 5 deletions server/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ export const sequelize = new Sequelize(DATABASE_URI, {
operatorsAliases: false,
logging: (process.env.NODE_ENV === 'test') ? false : (msg) => { log.trace(msg); },
dialectOptions: (process.env.NODE_ENV !== 'production') ? {
// requestTimeout: 10000,
requestTimeout: 40000,
} : {
// requestTimeout: 10000,
ssl: { rejectUnauthorized: false }
requestTimeout: 40000,
ssl: true,
rejectUnauthorized: false,
},
pool: {
max: 10,
min: 0,
acquire: 30000,
idle: 10000,
acquire: 40000,
idle: 40000,
}
});

Expand Down
11 changes: 11 additions & 0 deletions server/migrations/20210426072646-add-snapshot-to-chain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.addColumn('Chains', 'snapshot', { type: Sequelize.STRING });
},

down: (queryInterface, Sequelize) => {
return queryInterface.removeColumn('Chains', 'snapshot');
}
};
70 changes: 70 additions & 0 deletions server/migrations/20210426074254-add_yearn_and_fei_chains.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction(async (t) => {
await queryInterface.bulkInsert('Chains', [{
id: 'yearn',
symbol: 'YFI',
name: 'Yearn',
icon_url: '/static/img/protocols/yearn.png',
type: 'token',
network: 'yearn',
active: true,
description: 'A general-purpose confidential smart contract platform for DApps and DeFi.',
telegram: 'https://t.me/yearnfinance',
website: 'https://yearn.finance',
discord: 'http://discord.yearn.finance',
github: 'https://github.com/iearn-finance',
collapsed_on_homepage: false,
base: 'ethereum',
snapshot: 'ybaby.eth'
}, {
id: 'fei',
symbol: 'FEI',
name: 'fei',
icon_url: '/static/img/protocols/fei.png',
type: 'token',
network: 'fei',
active: true,
description: 'The stablecoin for DeFi.',
telegram: 'https://t.me/feiprotocol',
website: 'https://fei.money/',
discord: 'https://discord.com/invite/2prhYdQ5jP',
github: 'https://github.com/fei-protocol/fei-protocol-core',
collapsed_on_homepage: false,
base: 'ethereum',
snapshot: 'fei.eth'
}
], { transaction: t });

await queryInterface.bulkInsert('ChainNodes', [{
chain: 'yearn',
url: 'wss://mainnet.infura.io/ws',
}, {
chain: 'fei',
url: 'wss://mainnet.infura.io/ws',
}], { transaction: t });
});
},

down: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction(async (t) => {
await queryInterface.bulkDelete('OffchainReactions', { chain: 'yearn' }, { transaction: t });
await queryInterface.bulkDelete('OffchainComments', { chain: 'yearn' }, { transaction: t });
await queryInterface.bulkDelete('OffchainThreads', { chain: 'yearn' }, { transaction: t });
await queryInterface.bulkDelete('Addresses', { chain: 'yearn' }, { transaction: t });
await queryInterface.bulkDelete('ChainEventTypes', { chain: 'yearn' }, { transaction: t });
await queryInterface.bulkDelete('ChainNodes', { chain: 'yearn' }, { transaction: t });
await queryInterface.bulkDelete('Chains', { id: ['yearn'] }, { transaction: t });

await queryInterface.bulkDelete('OffchainReactions', { chain: 'fei' }, { transaction: t });
await queryInterface.bulkDelete('OffchainComments', { chain: 'fei' }, { transaction: t });
await queryInterface.bulkDelete('OffchainThreads', { chain: 'fei' }, { transaction: t });
await queryInterface.bulkDelete('Addresses', { chain: 'fei' }, { transaction: t });
await queryInterface.bulkDelete('ChainEventTypes', { chain: 'fei' }, { transaction: t });
await queryInterface.bulkDelete('ChainNodes', { chain: 'fei' }, { transaction: t });
await queryInterface.bulkDelete('Chains', { id: ['fei'] }, { transaction: t });
});
}
};
2 changes: 2 additions & 0 deletions server/models/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface ChainAttributes {
customDomain: string;
type: string;
substrate_spec: RegisteredTypes;
snapshot: string;

// associations
ChainNodes?: ChainNodeAttributes[] | ChainNodeAttributes['id'][];
Expand Down Expand Up @@ -80,6 +81,7 @@ export default (
collapsed_on_homepage: { type: dataTypes.BOOLEAN, allowNull: false, defaultValue: true },
type: { type: dataTypes.STRING, allowNull: false },
substrate_spec: { type: dataTypes.JSONB, allowNull: true },
snapshot: { type: dataTypes.STRING, allowNull: true },
}, {
timestamps: false,
underscored: true,
Expand Down
Binary file added static/img/protocols/fei.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/protocols/yearn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d753753

Please sign in to comment.