From 7ceb293fdea7685077d48df32bb85943b67a2363 Mon Sep 17 00:00:00 2001 From: liujun93 Date: Fri, 2 Dec 2022 17:54:06 +0800 Subject: [PATCH] use chain docs --- .gitignore | 3 ++- packages/core/src/types/wallet.ts | 2 +- packages/docs/pages/use-chain.mdx | 39 +++++++++++++++++++++++++++- packages/example/pages/chains/tx.tsx | 2 +- packages/example/pages/tx.tsx | 2 +- packages/react/src/modal/utils.tsx | 4 --- 6 files changed, 43 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 2a900c70f..cfa292fce 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ packages/**/module packages/example/pages/tmp.tsx packages/example/utils/tmp.ts .idea -/.yarnrc \ No newline at end of file +/.yarnrc +/.npmrc \ No newline at end of file diff --git a/packages/core/src/types/wallet.ts b/packages/core/src/types/wallet.ts index ae6bd6404..697d69104 100644 --- a/packages/core/src/types/wallet.ts +++ b/packages/core/src/types/wallet.ts @@ -185,7 +185,7 @@ export interface ChainContext { ) => Promise; sign: ( messages: EncodeObject[], - fee: StdFee, + fee?: StdFee, memo?: string, type?: CosmosClientType ) => Promise; diff --git a/packages/docs/pages/use-chain.mdx b/packages/docs/pages/use-chain.mdx index 3a547ff89..c97ebe4df 100644 --- a/packages/docs/pages/use-chain.mdx +++ b/packages/docs/pages/use-chain.mdx @@ -1 +1,38 @@ -TODO Soon... \ No newline at end of file +## Hook - useChain + +- required provider: [**ChainProvider**](https://docs.cosmoskit.com/chain-provider) + +- return type: [**ChainConext**](#type-chainconext) + +## Type - ChainConext + +### properties + +| Name | Description | Type | Default | +| ----------- | ----------- | -- | -- | +| **chain** | chain registry information | `Chain` | - | +| **assets** | chain assets information | `AssetList \| undefined` | `undefined` | +| **wallet** | current selected wallet registry information | `Wallet \| undefined` | `undefined` | +| **logoUrl** | chain logo url | `string \| undefined` | `undefined` | +| **address** | chain address from current selected wallet | `string \| undefined` | `undefined` | +| **username** | username from current selected wallet | `string \| undefined` | `undefined` | +| **message** | error/warn/info message | `string \| undefined` | `undefined` | +| **status** | wallet status | `WalletStatus` | `Disconnected` | + +### methods + +| Name | Description | Parameters | Return Type | Is Async | +| ----------- | ----------- | -- | -- | -- | +| **openView** | open modal | - | `void` | N | +| **connect** | connect wallet | **wallet**?: `WalletName` | `void` | Y | +| **disconnect** | disconnect current selected wallet | - | `void` | Y | +| **getRpcEndpoint** | test connection and return valid rpc endpoint | - | `string \| undefined` | Y | +| **getRestEndpoint** | test connection and return valid rest endpoint | - | `string \| undefined` | Y | +| **getStargateClient** | - | - | `StargateClient \| undefined` | Y | +| **getCosmWasmClient** | - | - | `CosmWasmClient \| undefined` | Y | +| **getSigningStargateClient** | - | - | `SigningStargateClient \| undefined` | Y | +| **getSigningCosmWasmClient** | - | - | `SigningCosmWasmClient \| undefined` | Y | +| **estimateFee** | if **type** is `undefined`, default using `SigningStargateClient` | **messages**: `EncodeObject[]`,
**type**?: `CosmosClientType`,
**memo**?: `string`,
**multiplier**?: `number` | `StdFee \| undefined` | Y | +| **sign** | if **type** is `undefined`, default using `SigningStargateClient` | **messages**: `EncodeObject[]`,
**fee**?: `StdFee`,
**memo**?: `string`,
**type**?: `CosmosClientType`, | `TxRaw \| undefined` | Y | +| **broadcast** | if **type** is `undefined`, default using `SigningStargateClient` | **signedMessages**: `TxRaw`,
**type**?: `CosmosClientType`, | `DeliverTxResponse \| undefined` | Y | +| **signAndBroadcast** | if **type** is `undefined`, default using `SigningStargateClient` | **messages**: `EncodeObject[]`,
**fee**?: `StdFee`,
**memo**?: `string`,
**type**?: `CosmosClientType`, | `DeliverTxResponse \| undefined` | Y | \ No newline at end of file diff --git a/packages/example/pages/chains/tx.tsx b/packages/example/pages/chains/tx.tsx index 149542340..0bced7de0 100644 --- a/packages/example/pages/chains/tx.tsx +++ b/packages/example/pages/chains/tx.tsx @@ -91,7 +91,7 @@ export default function Home() { let rpcEndpoint = await getRpcEndpoint(); if (!rpcEndpoint) { - console.log("no rpc endpoint — using a fallback"); + console.info("no rpc endpoint — using a fallback"); rpcEndpoint = `https://rpc.cosmos.directory/${chainName}`; } diff --git a/packages/example/pages/tx.tsx b/packages/example/pages/tx.tsx index f3eb892ff..3014bee32 100644 --- a/packages/example/pages/tx.tsx +++ b/packages/example/pages/tx.tsx @@ -91,7 +91,7 @@ export default function Home() { let rpcEndpoint = await getRpcEndpoint(); if (!rpcEndpoint) { - console.log("no rpc endpoint — using a fallback"); + console.info("no rpc endpoint — using a fallback"); rpcEndpoint = `https://rpc.cosmos.directory/${chainName}`; } diff --git a/packages/react/src/modal/utils.tsx b/packages/react/src/modal/utils.tsx index d0793fa40..2ed392171 100644 --- a/packages/react/src/modal/utils.tsx +++ b/packages/react/src/modal/utils.tsx @@ -171,15 +171,11 @@ export const getModalDetails = ( const { downloadInfo } = wallet; - // const appType = isMobile ? 'App' : 'Extension'; - async function handleDisconnect() { - console.info('Disconnecting'); await disconnect(); } async function handleConnect() { - console.log('Connecting'); await connect(); }