You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -9,11 +9,11 @@ This repository is still under development
9
9
This repository containts submodules that are not open sourced and are only available through the Chainapsis’ official Keplr Extension release. However, all primary features of the extension will work without the closed sourced submodules.
10
10
11
11
## Dev
12
-
Keplr extension repo uses git-secret to encrypt the endpoints and the api keys. So, you can't build this without creating your own config file. You should create your own `config.var.ts` file inside the `src` folder. Refer to the `config.var.example.ts`sample file to create your own configuration.
12
+
Keplr extension repo uses git-secret to encrypt the endpoints and the api keys. So, you can't build this without creating your own config file. You should create your own `config.var.ts`, `config.ui.var.ts` files inside the `packages/extension/src` folder. Refer to the `config.var.example.ts`, ``config.ui.var.example.ts``sample files to create your own configuration.
13
13
```sh
14
-
npm run dev
14
+
yarn dev
15
15
```
16
-
Extension's build output is placed in `/dist`, and you can check out [this page](https://developer.chrome.com/extensions/getstarted) for installing the developing extension.
16
+
Extension's build output is placed in `packages/extension/dist`, and you can check out [this page](https://developer.chrome.com/extensions/getstarted) for installing the developing extension.
17
17
18
18
You can add your chain by adding the chain infomation into `chain-info.ts`.
Copy file name to clipboardExpand all lines: docs/api/README.md
+35-3
Original file line number
Diff line number
Diff line change
@@ -97,10 +97,12 @@ Then, you can add the `@keplr-wallet/types` window to a global window object and
97
97
### Enable Connection
98
98
99
99
```javascript
100
-
enable(chainId: string):Promise<void>
100
+
enable(chainIds: string| string[]):Promise<void>
101
101
```
102
102
103
-
The `window.keplr.enable(chainId)` method requests the extension to be unlocked if it's currently locked. If the user hasn't given permission to the webpage, it will ask the user to give permission for the webpage to access Keplr.
103
+
The `window.keplr.enable(chainIds)` method requests the extension to be unlocked if it's currently locked. If the user hasn't given permission to the webpage, it will ask the user to give permission for the webpage to access Keplr.
104
+
105
+
`enable` method can receive one or more chain-id as an array. When the array of chain-id is passed, you can request permissions for all chains that have not yet been authorized at once.
104
106
105
107
If the user cancels the unlock or rejects the permission, an error will be thrown.
106
108
@@ -127,10 +129,12 @@ If the webpage has permission and Keplr is unlocked, this function will return t
127
129
pubKey:Uint8Array;
128
130
address:Uint8Array;
129
131
bech32Address: string;
132
+
isNanoLedger: boolean;
130
133
}
131
134
```
132
135
133
-
It also returns the nickname for the key store currently selected, which should allow the webpage to display the current key store selected to the user in a more convenient mane.
136
+
It also returns the nickname for the key store currently selected, which should allow the webpage to display the current key store selected to the user in a more convenient mane.
137
+
`isNanoLedger` field in the return type is used to indicate whether the selected account is from the Ledger Nano. Because current Cosmos app in the Ledger Nano doesn't support the direct (protobuf) format msgs, this field can be used to select the amino or direct signer. [Ref](./cosmjs.md#types-of-offline-signers)
134
138
135
139
### Sign Amino
136
140
@@ -174,6 +178,34 @@ This function requests Keplr to delegates the broadcasting of the transaction to
174
178
This method returns the transaction hash if it succeeds to broadcast, if else the method will throw an error.
175
179
When Keplr broadcasts the transaction, Keplr will send the notification on the transaction's progress.
176
180
181
+
### Interaction Options
182
+
183
+
```javascript
184
+
exportinterfaceKeplrIntereactionOptions {
185
+
readonlysign?: KeplrSignOptions;
186
+
}
187
+
188
+
exportinterfaceKeplrSignOptions {
189
+
readonlypreferNoSetFee?: boolean;
190
+
readonlypreferNoSetMemo?: boolean;
191
+
}
192
+
```
193
+
Keplr v0.8.11+ offers additional options to customize interactions between the frontend website and Keplr extension.
194
+
195
+
If `preferNoSetFee` is set to true, Keplr will prioritize the frontend-suggested fee rather than overriding the tx fee setting of the signing page.
196
+
197
+
If `preferNoSetMemo` is set to true, Keplr will not override the memo and set fix memo as the front-end set memo.
Copy file name to clipboardExpand all lines: docs/api/cosmjs.md
+15
Original file line number
Diff line number
Diff line change
@@ -45,12 +45,27 @@ If the extension is already unlocked and the website has permission to connect,
45
45
46
46
`window.keplr.enable(chainId)` is not mandatory. Even if the method wasn't called, if an API that requests access to Keplr is called the flow above will automatically run. However, it is recommended that `window.keplr.enable(chainId)` is first run.
47
47
48
+
## Types of Offline Signers
49
+
50
+
In CosmJS, there are two types of Signers: OfflineSigner and OfflineDirectSigner. OfflineSigner is used to sign SignDoc serialized with Amino in Cosmos SDK Launchpad (Cosmos SDK v0.39.x or below). OfflineDirectSigner is used to sign Protobuf encoded SignDoc.
51
+
52
+
Keplr supports both types of Signers. Keplr’s `keplr.getOfflineSigner(chainId)` or `window.getOfflineSigner(chainId)` returns a Signer that satiesfies both the OfflineSigner and OfflineDirectSigner. Therefore, when using CosmJS with this Signer, Amino is used for Launchpad chains and Protobuf is used for Stargate chains.
53
+
54
+
However, if the msg to be sent is able to be serialized/deserialized using Amino codec you can use a signer for Amino. Also, as there are some limitations to protobuf type sign doc, there may be cases when Amino is necessary. For example, Protobuf formatted sign doc is currently not supprted by Ledger Nano’s Cosmos app. Also, because protobuf sign doc is binary formatted, msgs not natively supported by Keplr may not be human readable.
55
+
56
+
If you’d like to enforce the use of Amino, you can use the following APIs: `keplr.getOfflineSignerOnlyAmino(chainId)` or `window.getOfflineSignerOnlyAmino(chainId: string)`. Because this will always return an Amino compatible signer, any CosmJS requested msg that is Amino compatible will request a Amino SignDoc to Keplr.
57
+
58
+
Also, `window.getOfflineSignerAuto(chainId: string): Promise<OfflineSigner | OfflineDirectSigner>` or `window.getOfflineSignerAuto(chainId: string): Promise<OfflineSigner | OfflineDirectSigner>` API is supported. Please note that the value returned is async. This API automatically returns a signer that only supports Amino if the account is a Ledger-based account, and returns a signer that is compatible for both Amino and Protobuf if the account is a mnemonic/private key-based account. Because this API is affected by the type of the connected Keplr account, if [keplr_keystorechange](./README.md#change-key-store-event) event is used to detect account changes the signer must be changed using the API when this event has been triggered.
59
+
48
60
## Use with Stargate
49
61
50
62
Keplr's `OfflineSigner` implements the `OfflineDirectSigner` interface. Use `SigningStargateClient` with Keplr's `OfflineSigner`, and Keplr will sign the transaction in Proto sign doc format.
51
63
52
64
### Example
53
65
Refer to the [keplr-example](https://github.com/chainapsis/keplr-example/blob/master/src/main.js) repository for example code on how to integrate Keplr with CosmJS.
54
66
67
+
### Interaction Options
68
+
You can use Keplr native API’s to set interaction options even when using CosmJS. Please refer to [this section](./#interaction-options).
69
+
55
70
### Adding a custom blockchain to Keplr
56
71
If Keplr doesn't natively support your blockchain within the extension, please refer to the [Suggest chain](./suggest-chain) section.
Copy file name to clipboardExpand all lines: docs/api/suggest-chain.md
+74-10
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,15 @@ order: 4
4
4
---
5
5
6
6
### Suggest Chain
7
+
8
+
*Warning: This is an experimental feature.*
9
+
10
+
Keplr's 'suggest chain' feature allows front-ends to request adding new Cosmos-SDK based blockchains that isn't natively integrated to Keplr extension.
11
+
If the same chain is already added to Keplr, nothing will happen. If the user rejects the request, an error will be thrown.
12
+
13
+
This allows all Cosmos-SDK blockchains to have permissionless, instant wallet and transaction signing support for front-ends.
|`rpc`|http://123.456.789.012:26657| Address of RPC endpoint of the chain. Default port is 26657 |
68
+
|`rest`|http://123.456.789.012:1317| Address of REST/API endpoint of the chain. Default port is 1317. Must be enabled in `app.toml`|
69
+
|`chainId`| mychain-1 | Keplr has a feature which automatically detects when the chain-id has changed, and automatically update to support new chain. However, it should be noted that this functionality will only work when the chain-id follows the {identifier}-{version}(ex.cosmoshub-4) format. Therefore, it is recommended that the chain follows the chain-id format. |
70
+
|`stakeCurrency`|```{ coinDenom: "ATOM", coinMinimalDenom: "uatom", coinDecimals: 6, coinGeckoId: "cosmos", }```| Information on the staking token of the chain |
71
+
|`walletUrlForStaking`|https://wallet.keplr.app/#/cosmoshub/stake| The URL for the staking interface frontend for the chain. If you don't have a staking interface built, you can use [Lunie Light](https://github.com/luniehq/lunie-light) which supports Keplr. |
72
+
|`bip44.coinType`| 118 | BIP44 coin type for address derivation. We recommend using `118`(Cosmos Hub) as this would provide good Ledger hardware wallet compatibility by utilizing the Cosmos Ledger app. |
73
+
|`bech32Config`|```{ bech32PrefixAccAddr: "cosmos", bech32PrefixAccPub: "cosmos" + "pub", bech32PrefixValAddr: "cosmos" + "valoper", bech32PrefixValPub: "cosmos" + "valoperpub", bech32PrefixConsAddr: "cosmos" + "valcons", bech32PrefixConsPub: "cosmos" + "valconspub"}```| Bech32 config using the address prefix of the chain |
|`feeCurrencies`|```[ { coinDenom: "ATOM", coinMinimalDenom: "uatom", coinDecimals: 6, coinGeckoId: "cosmos", }, ]```| List of fee tokens accepted by the chain's validator. |
76
+
|`gasPriceStep`|```{ low: 0.01, average: 0.025, high: 0.03, }```| Three `gasPrice` values (low, average, high) to estimate transaction fee. |
77
+
|`features`|[stargate]|`secretwasm` - Secret Network WASM smart contract transaction support `stargate` - For Cosmos SDK blockchains using cosmos-sdk v0.4+. (However, even if the `stargate` isn't set, Keplr will query "/cosmos/base/tendermint/v1beta1/node_info" to check if it succeeds. If successful, Keplr will assume that a gRPC HTTP gateway available and automatically set it as Stargate) `ibc-transfer` - For IBC transfers (ICS 20) enabled chains. For Stargate (cosmos-sdk v0.40+) chains, Keplr will check the on-chain params and automatically enable IBC transfers if it’s available) `cosmwasm` - For CosmWasm smart contract support (currently broken, in the process of being fixed) |
78
+
:::
54
79
55
-
It allows a blockchain that isn't natively integrated by Keplr to be added to Keplr extension.
56
-
If the same chain is already added to Keplr, nothing will happen. If the user rejects the request, an error will be thrown.
57
-
58
-
For Stargate Cosmos-SDK chains, it is recommended to put the `features` value as `stargate`.
59
-
(However, even if the `stargate` isn't set, Keplr will query "/cosmos/base/tendermint/v1beta1/node_info" to check if it succeeds. If successful, Keplr will assume that a gRPC HTTP gateway available and automatically set it as Stargate).
80
+
Copy and paste example:
81
+
```javascript
82
+
awaitwindow.keplr.experimentalSuggestChain({
83
+
chainId:"mychain-1",
84
+
chainName:"my new chain",
85
+
rpc:"http://123.456.789.012:26657",
86
+
rest:"http://123.456.789.012:1317",
87
+
bip44: {
88
+
coinType:118,
89
+
},
90
+
bech32Config: {
91
+
bech32PrefixAccAddr:"cosmos",
92
+
bech32PrefixAccPub:"cosmos"+"pub",
93
+
bech32PrefixValAddr:"cosmos"+"valoper",
94
+
bech32PrefixValPub:"cosmos"+"valoperpub",
95
+
bech32PrefixConsAddr:"cosmos"+"valcons",
96
+
bech32PrefixConsPub:"cosmos"+"valconspub",
97
+
},
98
+
currencies: [
99
+
{
100
+
coinDenom:"ATOM",
101
+
coinMinimalDenom:"uatom",
102
+
coinDecimals:6,
103
+
coinGeckoId:"cosmos",
104
+
},
105
+
],
106
+
feeCurrencies: [
107
+
{
108
+
coinDenom:"ATOM",
109
+
coinMinimalDenom:"uatom",
110
+
coinDecimals:6,
111
+
coinGeckoId:"cosmos",
112
+
},
113
+
],
114
+
stakeCurrency: {
115
+
coinDenom:"ATOM",
116
+
coinMinimalDenom:"uatom",
117
+
coinDecimals:6,
118
+
coinGeckoId:"cosmos",
119
+
},
120
+
coinType:118,
121
+
gasPriceStep: {
122
+
low:0.01,
123
+
average:0.025,
124
+
high:0.03,
125
+
},
126
+
});
127
+
```
60
128
61
-
Keplr has a feature which automatically detects when the chain-id has changed, and automatically update to support new chain. However, it should be noted that this functionality will only work when the chain-id follows the `{identifier}-{version}` (ex. `cosmoshub-4`) format. Therefore, it is recommended that the chain follows the chain-id format.
62
-
63
-
If the chain supports Secret WASM contracts, you may input `secretwasm` as a value for `features` to enable Secret WASM support.
64
-
65
129
Keplr supports the basic the `x/bank` module's send feature and balance query. Also, it is able to show the staking reward percentage from the `supply` and `mint` module. (For Stargate chains, Keplr will find the supply through the `bank` module).
This directory isn’t actually used, and would be preferred to not be added. But it is needed to explicitly ignore specific libraries used by the dependency. Specifically, libsodium isn’t actually used and WebAssembly can’t be used in the extension’s sandbox environment but creates various errors so the directory exists to ignore libsodium.
0 commit comments