diff --git a/chains/mainnet/neutron.json b/chains/mainnet/neutron.json new file mode 100644 index 00000000..864e67f1 --- /dev/null +++ b/chains/mainnet/neutron.json @@ -0,0 +1,30 @@ +{ + "chain_name": "neutron", + "api": [ + {"provider": "Polkachu", "address": "https://neutron-api.polkachu.com"}, + {"provider": "NodeStake", "address": "https://api.neutron.nodestake.top"}, + {"provider": "Allnodes", "address": "https://neutron-rest.publicnode.com"} + ], + "rpc": [ + {"provider": "Polkachu", "address": "https://neutron-rpc.polkachu.com"}, + {"provider": "NodeStake", "address": "https://rpc.neutron.nodestake.top"}, + {"provider": "Allnodes", "address": "https://neutron-rpc.publicnode.com:443"} + ], + "provider_chain": { + "api": ["https://api-cosmoshub-ia.cosmosia.notional.ventures"] + }, + "features": ["dashboard", "blocks", "ibc", "cosmwasm", "uptime", "parameters", "state-sync", "consensus", "supply", "widget"], + "sdk_version": "0.45.1", + "coin_type": "118", + "min_tx_fee": "8000", + "assets": [{ + "base": "untrn", + "symbol": "NTRN", + "exponent": "6", + "coingecko_id": "neutron", + "logo": "/logos/neutron.svg" + }], + "addr_prefix": "neutron", + "theme_color": "#161723", + "logo": "/logos/neutron.svg" +} diff --git a/src/modules/[chain]/cosmwasm/WasmClient.ts b/src/modules/[chain]/cosmwasm/WasmClient.ts new file mode 100644 index 00000000..cf0ecabc --- /dev/null +++ b/src/modules/[chain]/cosmwasm/WasmClient.ts @@ -0,0 +1,119 @@ +import { BaseRestClient } from '@/libs/client'; +import { adapter, type AbstractRegistry, type Request } from '@/libs/registry'; +import { defineStore } from 'pinia'; +import type { + CodeInfo, + ContractInfo, + PaginabledCodeInfos, + PaginabledContractHistory, + PaginabledContracts, + PaginabledContractStates, + WasmParam, +} from './types'; +import { toBase64 } from '@cosmjs/encoding'; +import { useBlockchain } from '@/stores'; +import { PageRequest } from '@/types'; + +export interface WasmRequestRegistry extends AbstractRegistry { + cosmwasm_code: Request; + cosmwasm_code_id: Request; + cosmwasm_code_id_contracts: Request; + cosmwasm_param: Request; + cosmwasm_contract_address: Request<{ + address: string; + contract_info: ContractInfo; + }>; + cosmwasm_contract_address_history: Request; + cosmwasm_contract_address_raw_query_data: Request; + cosmwasm_contract_address_smart_query_data: Request; + cosmwasm_contract_address_state: Request; + cosmwasm_wasm_contracts_creator: Request; + } + + export const DEFAULT_VERSION: WasmRequestRegistry = { + cosmwasm_code: { url: '/cosmwasm/wasm/v1/code', adapter }, + cosmwasm_code_id: { url: '/cosmwasm/wasm/v1/code/{code_id}', adapter }, + cosmwasm_code_id_contracts: { + url: '/cosmwasm/wasm/v1/code/{code_id}/contracts', + adapter, + }, + cosmwasm_param: { url: '/cosmwasm/wasm/v1/codes/params', adapter }, + cosmwasm_contract_address: { + url: '/cosmwasm/wasm/v1/contract/{address}', + adapter, + }, + cosmwasm_contract_address_history: { + url: '/cosmwasm/wasm/v1/contract/{address}/history', + adapter, + }, + cosmwasm_contract_address_raw_query_data: { + url: '/cosmwasm/wasm/v1/contract/{address}/raw/{query_data}', + adapter, + }, + cosmwasm_contract_address_smart_query_data: { + url: '/cosmwasm/wasm/v1/contract/{address}/smart/{query_data}', + adapter, + }, + cosmwasm_contract_address_state: { + url: '/cosmwasm/wasm/v1/contract/{address}/state', + adapter, + }, + cosmwasm_wasm_contracts_creator: { + url: '/cosmwasm/wasm/v1/contracts/creator/{creator_address}', + adapter, + }, + }; + + export class WasmRestClient extends BaseRestClient { + getWasmCodeList(pr?: PageRequest) { + if(!pr) pr = new PageRequest() + const query = `?${pr.toQueryString()}` + return this.request(this.registry.cosmwasm_code, {}, query); + } + getWasmCodeById(code_id: string) { + return this.request(this.registry.cosmwasm_code, { code_id }); // `code_id` is a param in above url + } + getWasmCodeContracts(code_id: string, page?: PageRequest) { + if(!page) page = new PageRequest() + const query = `?${page.toQueryString()}` + return this.request(this.registry.cosmwasm_code_id_contracts, { code_id }, query); + } + getWasmParams() { + return this.request(this.registry.cosmwasm_param, {}); + } + getWasmContracts(address: string) { + return this.request(this.registry.cosmwasm_contract_address, { address }); + } + getWasmContractsByCreator(creator_address: string, page?: PageRequest) { + if(!page) page = new PageRequest() + const query = `?${page.toQueryString()}` + return this.request(this.registry.cosmwasm_wasm_contracts_creator, { creator_address }, query); + } + getWasmContractHistory(address: string) { + return this.request(this.registry.cosmwasm_contract_address_history, { + address, + }); + } + getWasmContractRawQuery(address: string, query: string) { + const query_data = toBase64(new TextEncoder().encode(query)); + return this.request( + this.registry.cosmwasm_contract_address_raw_query_data, + { address, query_data } + ); + } + getWasmContractSmartQuery(address: string, query: string) { + const query_data = toBase64(new TextEncoder().encode(query)); + return this.request( + this.registry.cosmwasm_contract_address_smart_query_data, + { address, query_data } + ); + } + getWasmContractStates(address: string, pr: PageRequest) { + if(!pr) pr = new PageRequest() + const query = `?${pr.toQueryString()}` + return this.request(this.registry.cosmwasm_contract_address_state, { + address, + }, query); + } + } + \ No newline at end of file diff --git a/src/modules/[chain]/cosmwasm/WasmStore.ts b/src/modules/[chain]/cosmwasm/WasmStore.ts index 74f0180a..74a2a43a 100644 --- a/src/modules/[chain]/cosmwasm/WasmStore.ts +++ b/src/modules/[chain]/cosmwasm/WasmStore.ts @@ -1,121 +1,7 @@ -import { BaseRestClient } from '@/libs/client'; -import { adapter, type AbstractRegistry, type Request } from '@/libs/registry'; import { defineStore } from 'pinia'; -import type { - CodeInfo, - ContractInfo, - PaginabledCodeInfos, - PaginabledContractHistory, - PaginabledContracts, - PaginabledContractStates, - WasmParam, -} from './types'; -import { toBase64 } from '@cosmjs/encoding'; import { useBlockchain } from '@/stores'; -import { PageRequest } from '@/types'; - -export interface WasmRequestRegistry extends AbstractRegistry { - cosmwasm_code: Request; - cosmwasm_code_id: Request; - cosmwasm_code_id_contracts: Request; - cosmwasm_param: Request; - cosmwasm_contract_address: Request<{ - address: string; - contract_info: ContractInfo; - }>; - cosmwasm_contract_address_history: Request; - cosmwasm_contract_address_raw_query_data: Request; - cosmwasm_contract_address_smart_query_data: Request; - cosmwasm_contract_address_state: Request; - cosmwasm_wasm_contracts_creator: Request; -} - -export const DEFAULT: WasmRequestRegistry = { - cosmwasm_code: { url: '/cosmwasm/wasm/v1/code', adapter }, - cosmwasm_code_id: { url: '/cosmwasm/wasm/v1/code/{code_id}', adapter }, - cosmwasm_code_id_contracts: { - url: '/cosmwasm/wasm/v1/code/{code_id}/contracts', - adapter, - }, - cosmwasm_param: { url: '/cosmwasm/wasm/v1/codes/params', adapter }, - cosmwasm_contract_address: { - url: '/cosmwasm/wasm/v1/contract/{address}', - adapter, - }, - cosmwasm_contract_address_history: { - url: '/cosmwasm/wasm/v1/contract/{address}/history', - adapter, - }, - cosmwasm_contract_address_raw_query_data: { - url: '/cosmwasm/wasm/v1/contract/{address}/raw/{query_data}', - adapter, - }, - cosmwasm_contract_address_smart_query_data: { - url: '/cosmwasm/wasm/v1/contract/{address}/smart/{query_data}', - adapter, - }, - cosmwasm_contract_address_state: { - url: '/cosmwasm/wasm/v1/contract/{address}/state', - adapter, - }, - cosmwasm_wasm_contracts_creator: { - url: '/cosmwasm/wasm/v1/contracts/creator/{creator_address}', - adapter, - }, -}; - -class WasmRestClient extends BaseRestClient { - getWasmCodeList(pr?: PageRequest) { - if(!pr) pr = new PageRequest() - const query = `?${pr.toQueryString()}` - return this.request(this.registry.cosmwasm_code, {}, query); - } - getWasmCodeById(code_id: string) { - return this.request(this.registry.cosmwasm_code, { code_id }); // `code_id` is a param in above url - } - getWasmCodeContracts(code_id: string, page?: PageRequest) { - if(!page) page = new PageRequest() - const query = `?${page.toQueryString()}` - return this.request(this.registry.cosmwasm_code_id_contracts, { code_id }, query); - } - getWasmParams() { - return this.request(this.registry.cosmwasm_param, {}); - } - getWasmContracts(address: string) { - return this.request(this.registry.cosmwasm_contract_address, { address }); - } - getWasmContractsByCreator(creator_address: string, page?: PageRequest) { - if(!page) page = new PageRequest() - const query = `?${page.toQueryString()}` - return this.request(this.registry.cosmwasm_wasm_contracts_creator, { creator_address }, query); - } - getWasmContractHistory(address: string) { - return this.request(this.registry.cosmwasm_contract_address_history, { - address, - }); - } - getWasmContractRawQuery(address: string, query: string) { - const query_data = toBase64(new TextEncoder().encode(query)); - return this.request( - this.registry.cosmwasm_contract_address_raw_query_data, - { address, query_data } - ); - } - getWasmContractSmartQuery(address: string, query: string) { - const query_data = toBase64(new TextEncoder().encode(query)); - return this.request( - this.registry.cosmwasm_contract_address_smart_query_data, - { address, query_data } - ); - } - getWasmContractStates(address: string, pr: PageRequest) { - if(!pr) pr = new PageRequest() - const query = `?${pr.toQueryString()}` - return this.request(this.registry.cosmwasm_contract_address_state, { - address, - }, query); - } -} +import { DEFAULT_VERSION, WasmRestClient } from './WasmClient'; +import { get, post } from '@/libs'; export const useWasmStore = defineStore('module-wasm', { state: () => { @@ -124,7 +10,15 @@ export const useWasmStore = defineStore('module-wasm', { getters: { wasmClient() { const blockchain = useBlockchain(); - return new WasmRestClient(blockchain.endpoint.address, DEFAULT); + return new WasmRestClient(blockchain.endpoint.address, DEFAULT_VERSION); }, + // fetchVerification() { + // get("https://prod.neutron.compiler.welldonestudio.io/neutron-deploy-histories/pion-1?contract=neutron1gesll6lepas7xzt22pg7r07v9vd652md82z8m2fqp5zt43rznu5sl42s74") + // }, + // requestVerification() { + // post("https://prod.neutron.compiler.welldonestudio.io/verification/neutron", {"contractAddress": address, "chainId": baseStore.latest?.block.header.chain_id}).then(res => { + // console.log("verification:", res) + // }) + // } }, }); diff --git a/src/modules/[chain]/cosmwasm/[code_id]/transactions.vue b/src/modules/[chain]/cosmwasm/[code_id]/transactions.vue index 25828f63..c5d04429 100644 --- a/src/modules/[chain]/cosmwasm/[code_id]/transactions.vue +++ b/src/modules/[chain]/cosmwasm/[code_id]/transactions.vue @@ -43,9 +43,7 @@ onMounted(() => { chainStore.rpc.getTxs("?order_by=2&events=execute._contract_address='{address}'", { address }, page.value).then(res => { txs.value = res }) - post("https://prod.neutron.compiler.welldonestudio.io/verification/neutron", {"contractAddress": address, "chainId": baseStore.latest?.block.header.chain_id}).then(res => { - console.log("verification:", res) - }) + }) function pageload(pageNum: number) {