From e85701f58c0216f1c286931f629b139939c0eb8a Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 17 Sep 2021 18:22:18 +0800 Subject: [PATCH] add certik and update securite --- src/lang/locales/en.json | 1 + src/libs/data/proposal.js | 5 ++++- src/libs/fetch.js | 40 ++++++++++++++++++++++++++++++------ src/store/chains/certik.json | 8 ++++++++ src/store/chains/secret.json | 2 +- 5 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 src/store/chains/certik.json diff --git a/src/lang/locales/en.json b/src/lang/locales/en.json index ec9d6e76..08cca931 100644 --- a/src/lang/locales/en.json +++ b/src/lang/locales/en.json @@ -16,6 +16,7 @@ "secret": "Secret Network", "desmos": "Desmos", "juno": "Juno Hera", + "certik": "Certik", "staking": "Staking", "governance": "Governance", diff --git a/src/libs/data/proposal.js b/src/libs/data/proposal.js index 81654771..306ad077 100644 --- a/src/libs/data/proposal.js +++ b/src/libs/data/proposal.js @@ -47,7 +47,7 @@ export default class Proposal { versionFixed(ver) { if (compareVersions(ver, '0.40') >= 0) { // do nothing - } else if (compareVersions(ver, '0.37') >= 0) { + } else if (compareVersions(ver, '0.30') >= 0) { switch (this.element.proposal_status) { case 'Passed': this.status = 3 @@ -62,5 +62,8 @@ export default class Proposal { this.status = 1 } } + if (String(this.status).indexOf('PASSED') > -1) { + this.status = 3 + } } } diff --git a/src/libs/fetch.js b/src/libs/fetch.js index 58f36536..3cf022ba 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -163,10 +163,19 @@ const chainAPI = class ChainFetch { } async getGovernanceProposer(pid) { + if (this.config.chain_name === 'certik') { + return this.get(`/shentu/gov/v1alpha1/${pid}/proposer`).then(data => new Proposer().init(commonProcess(data))) + } return this.get(`/gov/proposals/${pid}/proposer`).then(data => new Proposer().init(commonProcess(data))) } async getGovernanceDeposits(pid) { + if (this.config.chain_name === 'certik') { + return this.get(`/shentu/gov/v1alpha1/proposals/${pid}/deposits`).then(data => { + const result = commonProcess(data) + return Array.isArray(result) ? result.reverse().map(d => new Deposit().init(d)) : result + }) + } return this.get(`/gov/proposals/${pid}/deposits`).then(data => { const result = commonProcess(data) return Array.isArray(result) ? result.reverse().map(d => new Deposit().init(d)) : result @@ -180,18 +189,27 @@ const chainAPI = class ChainFetch { pagination: {}, })) } + if (this.config.chain_name === 'certik') { + return this.get(`/shentu/gov/v1alpha1/proposals/${pid}/votes?pagination.key=${encodeURIComponent(next)}&pagination.limit=${limit}`) + } return this.get(`/cosmos/gov/v1beta1/proposals/${pid}/votes?pagination.key=${encodeURIComponent(next)}&pagination.limit=${limit}`) } async getGovernanceList() { return Promise.all([this.get('/gov/proposals'), this.get('/staking/pool')]).then(data => { const pool = new StakingPool().init(commonProcess(data[1])) + let proposals = commonProcess(data[0]) + if (Array.isArray(proposals.proposals)) { + proposals = proposals.proposals + } const ret = [] - commonProcess(data[0]).forEach(e => { - const g = new Proposal().init(e, pool.bondedToken) - g.versionFixed(this.config.sdk_version) - ret.push(g) - }) + if (proposals) { + proposals.forEach(e => { + const g = new Proposal().init(e, pool.bondedToken) + g.versionFixed(this.config.sdk_version) + ret.push(g) + }) + } return ret }) } @@ -210,7 +228,10 @@ const chainAPI = class ChainFetch { } async getAuthAccount(address, config = null) { - return this.get('/auth/accounts/'.concat(address), config).then(data => commonProcess(data)) + return this.get('/auth/accounts/'.concat(address), config).then(data => { + const result = commonProcess(data) + return result.value ? result : { value: result } + }) } async getBankAccountBalance(address) { @@ -245,6 +266,13 @@ const chainAPI = class ChainFetch { const h = hash.substring(hash.indexOf('/')) return this.get('/ibc/applications/transfer/v1beta1/denom_traces/'.concat(h), config).then(data => commonProcess(data)) } + + async getIBCChannels(key = null, config = null) { + if (key) { + return this.get('/ibc/core/channel/v1beta1/channels?pagination.key='.concat(key), config).then(data => commonProcess(data)) + } + return this.get('/ibc/core/channel/v1beta1/channels', config).then(data => commonProcess(data)) + } // /cosmos/staking/v1beta1/delegations/{delegator_addr} static async getBankBalance(baseurl, address) { diff --git a/src/store/chains/certik.json b/src/store/chains/certik.json new file mode 100644 index 00000000..6b119816 --- /dev/null +++ b/src/store/chains/certik.json @@ -0,0 +1,8 @@ + +{ + "chain_name": "certik", + "api":"https://azuredragon.noopsbycertik.com", + "sdk_version": "0.42.6", + "addr_prefix": "certik", + "logo": "https://dl.airtable.com/.attachments/78bc9a7352de8ecd09e167d406d68582/2dcea633/dED92akm_400x400.jpg" +} \ No newline at end of file diff --git a/src/store/chains/secret.json b/src/store/chains/secret.json index 6369a56a..7abf9e9a 100644 --- a/src/store/chains/secret.json +++ b/src/store/chains/secret.json @@ -1,6 +1,6 @@ { "chain_name": "secret", - "api": "https://figment-secret.api.ping.pub", + "api": "https://beta-api.scrt.network", "sdk_version": "0.33.8", "addr_prefix": "secret", "logo": "https://dl.airtable.com/.attachments/b95ce1905e5327924ffdcb6d57c55b66/7e2ad353/logo.png"