@keplr-wallet/types 0.12.0-alpha.0 → 0.12.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -2
- package/build/chain-info.d.ts +7 -13
- package/build/cosmjs.d.ts +120 -0
- package/build/cosmjs.js +3 -0
- package/build/cosmjs.js.map +1 -0
- package/build/currency.d.ts +3 -3
- package/build/ethereum.d.ts +1 -1
- package/build/ethereum.js +1 -1
- package/build/ethereum.js.map +1 -1
- package/build/index.d.ts +3 -0
- package/build/index.js +8 -1
- package/build/index.js.map +1 -1
- package/build/secretjs.d.ts +6 -0
- package/build/secretjs.js +3 -0
- package/build/secretjs.js.map +1 -0
- package/build/settled.d.ts +8 -0
- package/build/settled.js +3 -0
- package/build/settled.js.map +1 -0
- package/build/wallet/index.js +5 -1
- package/build/wallet/index.js.map +1 -1
- package/build/wallet/keplr.d.ts +55 -8
- package/build/window.d.ts +5 -6
- package/package.json +3 -8
- package/src/chain-info.ts +12 -13
- package/src/cosmjs.ts +143 -0
- package/src/ethereum.ts +1 -1
- package/src/index.ts +3 -0
- package/src/secretjs.ts +10 -0
- package/src/settled.ts +11 -0
- package/src/wallet/keplr.ts +72 -8
- package/src/window.ts +7 -6
package/LICENSE
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
License: Apache2.0
|
1
|
+
License: Apache2.0 (Extension) / All rights reserved (Mobile)
|
2
|
+
|
3
|
+
## Keplr Extension License:
|
2
4
|
|
3
5
|
Apache License
|
4
6
|
Version 2.0, January 2004
|
@@ -200,4 +202,8 @@ License: Apache2.0
|
|
200
202
|
distributed under the License is distributed on an "AS IS" BASIS,
|
201
203
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
202
204
|
See the License for the specific language governing permissions and
|
203
|
-
limitations under the License.
|
205
|
+
limitations under the License.
|
206
|
+
|
207
|
+
## Keplr Mobile License
|
208
|
+
|
209
|
+
Copyright (c) 2021 Chainapsis Inc. All rights reserved.
|
package/build/chain-info.d.ts
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
import { Currency, AppCurrency, FeeCurrency } from "./currency";
|
2
2
|
import { BIP44 } from "./bip44";
|
3
|
-
import { AxiosRequestConfig } from "axios";
|
4
3
|
import { Bech32Config } from "./bech32";
|
5
4
|
export interface ChainInfo {
|
6
5
|
readonly rpc: string;
|
7
|
-
readonly rpcConfig?: AxiosRequestConfig;
|
8
6
|
readonly rest: string;
|
9
|
-
readonly
|
7
|
+
readonly nodeProvider?: {
|
8
|
+
readonly name: string;
|
9
|
+
readonly email: string;
|
10
|
+
readonly website?: string;
|
11
|
+
};
|
10
12
|
readonly chainId: string;
|
11
13
|
readonly chainName: string;
|
12
14
|
/**
|
@@ -25,15 +27,6 @@ export interface ChainInfo {
|
|
25
27
|
* You can get actual currency information from Currencies.
|
26
28
|
*/
|
27
29
|
readonly feeCurrencies: FeeCurrency[];
|
28
|
-
/**
|
29
|
-
* This is the coin type in slip-044.
|
30
|
-
* This is used for fetching address from ENS if this field is set.
|
31
|
-
*
|
32
|
-
* ** Use the `bip44.coinType` field to set the coin type to generate the address. **
|
33
|
-
*
|
34
|
-
* @deprecated This field is likely to be changed. ENS will continue to be supported, but will change in the future to use other methods than this field. Because of the low usage of the ENS feature, the change is a low priority and it is not yet clear how it will change.
|
35
|
-
*/
|
36
|
-
readonly coinType?: number;
|
37
30
|
/**
|
38
31
|
* Indicate the features supported by this chain. Ex) cosmwasm, secretwasm ...
|
39
32
|
*/
|
@@ -44,5 +37,6 @@ export interface ChainInfo {
|
|
44
37
|
* If the blockchain is in an early stage, please set it as beta.
|
45
38
|
*/
|
46
39
|
readonly beta?: boolean;
|
47
|
-
readonly
|
40
|
+
readonly chainSymbolImageUrl?: string;
|
48
41
|
}
|
42
|
+
export type ChainInfoWithoutEndpoints = Omit<ChainInfo, "rest" | "rpc" | "nodeProvider">;
|
@@ -0,0 +1,120 @@
|
|
1
|
+
import Long from "long";
|
2
|
+
export declare enum BroadcastMode {
|
3
|
+
/** Return after tx commit */
|
4
|
+
Block = "block",
|
5
|
+
/** Return after CheckTx */
|
6
|
+
Sync = "sync",
|
7
|
+
/** Return right away */
|
8
|
+
Async = "async"
|
9
|
+
}
|
10
|
+
export interface Coin {
|
11
|
+
readonly denom: string;
|
12
|
+
readonly amount: string;
|
13
|
+
}
|
14
|
+
export interface StdFee {
|
15
|
+
readonly amount: readonly Coin[];
|
16
|
+
readonly gas: string;
|
17
|
+
readonly payer?: string;
|
18
|
+
readonly granter?: string;
|
19
|
+
readonly feePayer?: string;
|
20
|
+
}
|
21
|
+
export interface Msg {
|
22
|
+
readonly type: string;
|
23
|
+
readonly value: any;
|
24
|
+
}
|
25
|
+
export interface StdSignDoc {
|
26
|
+
readonly chain_id: string;
|
27
|
+
readonly account_number: string;
|
28
|
+
readonly sequence: string;
|
29
|
+
readonly timeout_height?: string;
|
30
|
+
readonly fee: StdFee;
|
31
|
+
readonly msgs: readonly Msg[];
|
32
|
+
readonly memo: string;
|
33
|
+
}
|
34
|
+
export interface PubKey {
|
35
|
+
readonly type: string;
|
36
|
+
readonly value: string;
|
37
|
+
}
|
38
|
+
export interface StdSignature {
|
39
|
+
readonly pub_key: PubKey;
|
40
|
+
readonly signature: string;
|
41
|
+
}
|
42
|
+
export interface StdTx {
|
43
|
+
readonly msg: readonly Msg[];
|
44
|
+
readonly fee: StdFee;
|
45
|
+
readonly signatures: readonly StdSignature[];
|
46
|
+
readonly memo: string | undefined;
|
47
|
+
}
|
48
|
+
export interface AminoSignResponse {
|
49
|
+
readonly signed: StdSignDoc;
|
50
|
+
readonly signature: StdSignature;
|
51
|
+
}
|
52
|
+
export interface SignDoc {
|
53
|
+
/**
|
54
|
+
* body_bytes is protobuf serialization of a TxBody that matches the
|
55
|
+
* representation in TxRaw.
|
56
|
+
*/
|
57
|
+
bodyBytes: Uint8Array;
|
58
|
+
/**
|
59
|
+
* auth_info_bytes is a protobuf serialization of an AuthInfo that matches the
|
60
|
+
* representation in TxRaw.
|
61
|
+
*/
|
62
|
+
authInfoBytes: Uint8Array;
|
63
|
+
/**
|
64
|
+
* chain_id is the unique identifier of the chain this transaction targets.
|
65
|
+
* It prevents signed transactions from being used on another chain by an
|
66
|
+
* attacker
|
67
|
+
*/
|
68
|
+
chainId: string;
|
69
|
+
/** account_number is the account number of the account in state */
|
70
|
+
accountNumber: Long;
|
71
|
+
}
|
72
|
+
export interface DirectSignResponse {
|
73
|
+
/**
|
74
|
+
* The sign doc that was signed.
|
75
|
+
* This may be different from the input signDoc when the signer modifies it as part of the signing process.
|
76
|
+
*/
|
77
|
+
readonly signed: SignDoc;
|
78
|
+
readonly signature: StdSignature;
|
79
|
+
}
|
80
|
+
/**
|
81
|
+
* This is the same as Algo from @cosmjs/launchpad but those might diverge in the future.
|
82
|
+
*/
|
83
|
+
export declare type Algo = "secp256k1" | "ed25519" | "sr25519";
|
84
|
+
/**
|
85
|
+
* This is the same as AccountData from @cosmjs/launchpad but those might diverge in the future.
|
86
|
+
*/
|
87
|
+
export interface AccountData {
|
88
|
+
/** A printable address (typically bech32 encoded) */
|
89
|
+
readonly address: string;
|
90
|
+
readonly algo: Algo;
|
91
|
+
readonly pubkey: Uint8Array;
|
92
|
+
}
|
93
|
+
export interface DirectSignResponse {
|
94
|
+
/**
|
95
|
+
* The sign doc that was signed.
|
96
|
+
* This may be different from the input signDoc when the signer modifies it as part of the signing process.
|
97
|
+
*/
|
98
|
+
readonly signed: SignDoc;
|
99
|
+
readonly signature: StdSignature;
|
100
|
+
}
|
101
|
+
export interface OfflineDirectSigner {
|
102
|
+
readonly getAccounts: () => Promise<readonly AccountData[]>;
|
103
|
+
readonly signDirect: (signerAddress: string, signDoc: SignDoc) => Promise<DirectSignResponse>;
|
104
|
+
}
|
105
|
+
export interface OfflineAminoSigner {
|
106
|
+
/**
|
107
|
+
* Get AccountData array from wallet. Rejects if not enabled.
|
108
|
+
*/
|
109
|
+
readonly getAccounts: () => Promise<readonly AccountData[]>;
|
110
|
+
/**
|
111
|
+
* Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled.
|
112
|
+
*
|
113
|
+
* The signer implementation may offer the user the ability to override parts of the signDoc. It must
|
114
|
+
* return the doc that was signed in the response.
|
115
|
+
*
|
116
|
+
* @param signerAddress The address of the account that should sign the transaction
|
117
|
+
* @param signDoc The content that should be signed
|
118
|
+
*/
|
119
|
+
readonly signAmino: (signerAddress: string, signDoc: StdSignDoc) => Promise<AminoSignResponse>;
|
120
|
+
}
|
package/build/cosmjs.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cosmjs.js","sourceRoot":"","sources":["../src/cosmjs.ts"],"names":[],"mappings":""}
|
package/build/currency.d.ts
CHANGED
@@ -46,14 +46,14 @@ export interface IBCCurrency extends Currency {
|
|
46
46
|
/**
|
47
47
|
* Any type of currency that Kepler applications can support.
|
48
48
|
*/
|
49
|
-
export
|
49
|
+
export type AppCurrency = Currency | CW20Currency | Secret20Currency | IBCCurrency;
|
50
50
|
export interface FiatCurrency {
|
51
51
|
readonly currency: string;
|
52
52
|
readonly symbol: string;
|
53
53
|
readonly maxDecimals: number;
|
54
54
|
readonly locale: string;
|
55
55
|
}
|
56
|
-
export
|
56
|
+
export type WithGasPriceStep<T> = T & {
|
57
57
|
/**
|
58
58
|
* This is used to set the fee of the transaction.
|
59
59
|
* If this field is empty, it just use the default gas price step (low: 0.01, average: 0.025, high: 0.04).
|
@@ -64,4 +64,4 @@ export declare type WithGasPriceStep<T> = T & {
|
|
64
64
|
readonly high: number;
|
65
65
|
};
|
66
66
|
};
|
67
|
-
export
|
67
|
+
export type FeeCurrency = WithGasPriceStep<AppCurrency>;
|
package/build/ethereum.d.ts
CHANGED
package/build/ethereum.js
CHANGED
@@ -5,6 +5,6 @@ var EthSignType;
|
|
5
5
|
(function (EthSignType) {
|
6
6
|
EthSignType["MESSAGE"] = "message";
|
7
7
|
EthSignType["TRANSACTION"] = "transaction";
|
8
|
-
EthSignType["
|
8
|
+
EthSignType["EIP712"] = "eip-712";
|
9
9
|
})(EthSignType = exports.EthSignType || (exports.EthSignType = {}));
|
10
10
|
//# sourceMappingURL=ethereum.js.map
|
package/build/ethereum.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../src/ethereum.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,0CAA2B,CAAA;IAC3B,
|
1
|
+
{"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../src/ethereum.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,0CAA2B,CAAA;IAC3B,iCAAkB,CAAA;AACpB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB"}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -17,4 +21,7 @@ __exportStar(require("./chain-info"), exports);
|
|
17
21
|
__exportStar(require("./wallet"), exports);
|
18
22
|
__exportStar(require("./window"), exports);
|
19
23
|
__exportStar(require("./ethereum"), exports);
|
24
|
+
__exportStar(require("./cosmjs"), exports);
|
25
|
+
__exportStar(require("./secretjs"), exports);
|
26
|
+
__exportStar(require("./settled"), exports);
|
20
27
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB;AACxB,+CAA6B;AAC7B,2CAAyB;AACzB,2CAAyB;AACzB,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B;AAC3B,4CAA0B"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export interface SecretUtils {
|
2
|
+
getPubkey: () => Promise<Uint8Array>;
|
3
|
+
decrypt: (ciphertext: Uint8Array, nonce: Uint8Array) => Promise<Uint8Array>;
|
4
|
+
encrypt: (contractCodeHash: string, msg: object) => Promise<Uint8Array>;
|
5
|
+
getTxEncryptionKey: (nonce: Uint8Array) => Promise<Uint8Array>;
|
6
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"secretjs.js","sourceRoot":"","sources":["../src/secretjs.ts"],"names":[],"mappings":""}
|
package/build/settled.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"settled.js","sourceRoot":"","sources":["../src/settled.ts"],"names":[],"mappings":""}
|
package/build/wallet/index.js
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
3
|
if (k2 === undefined) k2 = k;
|
4
|
-
Object.
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
5
9
|
}) : (function(o, m, k, k2) {
|
6
10
|
if (k2 === undefined) k2 = k;
|
7
11
|
o[k2] = m[k];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wallet/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
package/build/wallet/keplr.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { ChainInfo } from "../chain-info";
|
1
|
+
import { ChainInfo, ChainInfoWithoutEndpoints } from "../chain-info";
|
2
2
|
import { EthSignType } from "../ethereum";
|
3
|
-
import { BroadcastMode, AminoSignResponse, StdSignDoc,
|
4
|
-
import {
|
5
|
-
import { SecretUtils } from "secretjs/types/enigmautils";
|
3
|
+
import { BroadcastMode, AminoSignResponse, StdSignDoc, OfflineAminoSigner, StdSignature, DirectSignResponse, OfflineDirectSigner } from "../cosmjs";
|
4
|
+
import { SecretUtils } from "../secretjs";
|
6
5
|
import Long from "long";
|
6
|
+
import { SettledResponses } from "../settled";
|
7
7
|
export interface Key {
|
8
8
|
readonly name: string;
|
9
9
|
readonly algo: string;
|
@@ -11,8 +11,18 @@ export interface Key {
|
|
11
11
|
readonly address: Uint8Array;
|
12
12
|
readonly bech32Address: string;
|
13
13
|
readonly isNanoLedger: boolean;
|
14
|
+
readonly isKeystone: boolean;
|
14
15
|
}
|
15
|
-
export
|
16
|
+
export type ICNSAdr36Signatures = {
|
17
|
+
chainId: string;
|
18
|
+
bech32Prefix: string;
|
19
|
+
bech32Address: string;
|
20
|
+
addressHash: "cosmos" | "ethereum";
|
21
|
+
pubKey: Uint8Array;
|
22
|
+
signatureSalt: number;
|
23
|
+
signature: Uint8Array;
|
24
|
+
}[];
|
25
|
+
export type KeplrMode = "core" | "extension" | "mobile-web" | "walletconnect";
|
16
26
|
export interface KeplrIntereactionOptions {
|
17
27
|
readonly sign?: KeplrSignOptions;
|
18
28
|
}
|
@@ -32,7 +42,16 @@ export interface Keplr {
|
|
32
42
|
defaultOptions: KeplrIntereactionOptions;
|
33
43
|
experimentalSuggestChain(chainInfo: ChainInfo): Promise<void>;
|
34
44
|
enable(chainIds: string | string[]): Promise<void>;
|
45
|
+
/**
|
46
|
+
* Delete permissions granted to origin.
|
47
|
+
* If chain ids are specified, only the permissions granted to each chain id are deleted (In this case, permissions such as getChainInfosWithoutEndpoints() are not deleted).
|
48
|
+
* Else, remove all permissions granted to origin (In this case, permissions that are not assigned to each chain, such as getChainInfosWithoutEndpoints(), are also deleted).
|
49
|
+
*
|
50
|
+
* @param chainIds disable(Remove approve domain(s)) target chain ID(s).
|
51
|
+
*/
|
52
|
+
disable(chainIds?: string | string[]): Promise<void>;
|
35
53
|
getKey(chainId: string): Promise<Key>;
|
54
|
+
getKeysSettled(chainIds: string[]): Promise<SettledResponses<Key>>;
|
36
55
|
signAmino(chainId: string, signer: string, signDoc: StdSignDoc, signOptions?: KeplrSignOptions): Promise<AminoSignResponse>;
|
37
56
|
signDirect(chainId: string, signer: string, signDoc: {
|
38
57
|
/** SignDoc bodyBytes */
|
@@ -45,12 +64,13 @@ export interface Keplr {
|
|
45
64
|
accountNumber?: Long | null;
|
46
65
|
}, signOptions?: KeplrSignOptions): Promise<DirectSignResponse>;
|
47
66
|
sendTx(chainId: string, tx: Uint8Array, mode: BroadcastMode): Promise<Uint8Array>;
|
67
|
+
signICNSAdr36(chainId: string, contractAddress: string, owner: string, username: string, addressChainIds: string[]): Promise<ICNSAdr36Signatures>;
|
48
68
|
signArbitrary(chainId: string, signer: string, data: string | Uint8Array): Promise<StdSignature>;
|
49
69
|
verifyArbitrary(chainId: string, signer: string, data: string | Uint8Array, signature: StdSignature): Promise<boolean>;
|
50
70
|
signEthereum(chainId: string, signer: string, data: string | Uint8Array, type: EthSignType): Promise<Uint8Array>;
|
51
|
-
getOfflineSigner(chainId: string):
|
52
|
-
getOfflineSignerOnlyAmino(chainId: string):
|
53
|
-
getOfflineSignerAuto(chainId: string): Promise<
|
71
|
+
getOfflineSigner(chainId: string): OfflineAminoSigner & OfflineDirectSigner;
|
72
|
+
getOfflineSignerOnlyAmino(chainId: string): OfflineAminoSigner;
|
73
|
+
getOfflineSignerAuto(chainId: string): Promise<OfflineAminoSigner | OfflineDirectSigner>;
|
54
74
|
suggestToken(chainId: string, contractAddress: string, viewingKey?: string): Promise<void>;
|
55
75
|
getSecret20ViewingKey(chainId: string, contractAddress: string): Promise<string>;
|
56
76
|
getEnigmaUtils(chainId: string): SecretUtils;
|
@@ -58,4 +78,31 @@ export interface Keplr {
|
|
58
78
|
getEnigmaTxEncryptionKey(chainId: string, nonce: Uint8Array): Promise<Uint8Array>;
|
59
79
|
enigmaEncrypt(chainId: string, contractCodeHash: string, msg: object): Promise<Uint8Array>;
|
60
80
|
enigmaDecrypt(chainId: string, ciphertext: Uint8Array, nonce: Uint8Array): Promise<Uint8Array>;
|
81
|
+
/**
|
82
|
+
* Sign the sign doc with ethermint's EIP-712 format.
|
83
|
+
* The difference from signEthereum(..., EthSignType.EIP712) is that this api returns a new sign doc changed by the user's fee setting and the signature for that sign doc.
|
84
|
+
* Encoding tx to EIP-712 format should be done on the side using this api.
|
85
|
+
* Not compatible with cosmjs.
|
86
|
+
* The returned signature is (r | s | v) format which used in ethereum.
|
87
|
+
* v should be 27 or 28 which is used in the ethereum mainnet regardless of chain.
|
88
|
+
* @param chainId
|
89
|
+
* @param signer
|
90
|
+
* @param eip712
|
91
|
+
* @param signDoc
|
92
|
+
* @param signOptions
|
93
|
+
*/
|
94
|
+
experimentalSignEIP712CosmosTx_v0(chainId: string, signer: string, eip712: {
|
95
|
+
types: Record<string, {
|
96
|
+
name: string;
|
97
|
+
type: string;
|
98
|
+
}[] | undefined>;
|
99
|
+
domain: Record<string, any>;
|
100
|
+
primaryType: string;
|
101
|
+
}, signDoc: StdSignDoc, signOptions?: KeplrSignOptions): Promise<AminoSignResponse>;
|
102
|
+
getChainInfosWithoutEndpoints(): Promise<ChainInfoWithoutEndpoints[]>;
|
103
|
+
/** Change wallet extension user name **/
|
104
|
+
changeKeyRingName(opts: {
|
105
|
+
defaultName: string;
|
106
|
+
editable?: boolean;
|
107
|
+
}): Promise<string>;
|
61
108
|
}
|
package/build/window.d.ts
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
import { Keplr } from "./wallet";
|
2
|
-
import {
|
3
|
-
import { SecretUtils } from "secretjs
|
4
|
-
import { OfflineDirectSigner } from "@cosmjs/proto-signing";
|
2
|
+
import { OfflineAminoSigner, OfflineDirectSigner } from "./cosmjs";
|
3
|
+
import { SecretUtils } from "./secretjs";
|
5
4
|
export interface Window {
|
6
5
|
keplr?: Keplr;
|
7
|
-
getOfflineSigner?: (chainId: string) =>
|
8
|
-
getOfflineSignerOnlyAmino?: (chainId: string) =>
|
9
|
-
getOfflineSignerAuto?: (chainId: string) => Promise<
|
6
|
+
getOfflineSigner?: (chainId: string) => OfflineAminoSigner & OfflineDirectSigner;
|
7
|
+
getOfflineSignerOnlyAmino?: (chainId: string) => OfflineAminoSigner;
|
8
|
+
getOfflineSignerAuto?: (chainId: string) => Promise<OfflineAminoSigner | OfflineDirectSigner>;
|
10
9
|
getEnigmaUtils?: (chainId: string) => SecretUtils;
|
11
10
|
}
|
package/package.json
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "@keplr-wallet/types",
|
3
|
-
"version": "0.12.0-alpha.
|
3
|
+
"version": "0.12.0-alpha.3",
|
4
4
|
"main": "build/index.js",
|
5
5
|
"author": "chainapsis",
|
6
6
|
"license": "Apache-2.0",
|
7
|
-
"private": false,
|
8
7
|
"publishConfig": {
|
9
8
|
"access": "public"
|
10
9
|
},
|
@@ -17,11 +16,7 @@
|
|
17
16
|
"lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
|
18
17
|
},
|
19
18
|
"dependencies": {
|
20
|
-
"
|
21
|
-
"@cosmjs/proto-signing": "^0.24.0-alpha.25",
|
22
|
-
"axios": "^0.27.2",
|
23
|
-
"long": "^4.0.0",
|
24
|
-
"secretjs": "0.17.7"
|
19
|
+
"long": "^4.0.0"
|
25
20
|
},
|
26
|
-
"gitHead": "
|
21
|
+
"gitHead": "1ee89644b711dd1dbbebc8eb86ed29d407088834"
|
27
22
|
}
|
package/src/chain-info.ts
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
import { Currency, AppCurrency, FeeCurrency } from "./currency";
|
2
2
|
import { BIP44 } from "./bip44";
|
3
|
-
import { AxiosRequestConfig } from "axios";
|
4
3
|
import { Bech32Config } from "./bech32";
|
5
4
|
|
6
5
|
export interface ChainInfo {
|
7
6
|
readonly rpc: string;
|
8
|
-
readonly rpcConfig?: AxiosRequestConfig;
|
9
7
|
readonly rest: string;
|
10
|
-
readonly
|
8
|
+
readonly nodeProvider?: {
|
9
|
+
readonly name: string;
|
10
|
+
readonly email: string;
|
11
|
+
readonly website?: string;
|
12
|
+
};
|
11
13
|
readonly chainId: string;
|
12
14
|
readonly chainName: string;
|
13
15
|
/**
|
@@ -27,15 +29,6 @@ export interface ChainInfo {
|
|
27
29
|
* You can get actual currency information from Currencies.
|
28
30
|
*/
|
29
31
|
readonly feeCurrencies: FeeCurrency[];
|
30
|
-
/**
|
31
|
-
* This is the coin type in slip-044.
|
32
|
-
* This is used for fetching address from ENS if this field is set.
|
33
|
-
*
|
34
|
-
* ** Use the `bip44.coinType` field to set the coin type to generate the address. **
|
35
|
-
*
|
36
|
-
* @deprecated This field is likely to be changed. ENS will continue to be supported, but will change in the future to use other methods than this field. Because of the low usage of the ENS feature, the change is a low priority and it is not yet clear how it will change.
|
37
|
-
*/
|
38
|
-
readonly coinType?: number;
|
39
32
|
|
40
33
|
/**
|
41
34
|
* Indicate the features supported by this chain. Ex) cosmwasm, secretwasm ...
|
@@ -48,5 +41,11 @@ export interface ChainInfo {
|
|
48
41
|
* If the blockchain is in an early stage, please set it as beta.
|
49
42
|
*/
|
50
43
|
readonly beta?: boolean;
|
51
|
-
|
44
|
+
|
45
|
+
readonly chainSymbolImageUrl?: string;
|
52
46
|
}
|
47
|
+
|
48
|
+
export type ChainInfoWithoutEndpoints = Omit<
|
49
|
+
ChainInfo,
|
50
|
+
"rest" | "rpc" | "nodeProvider"
|
51
|
+
>;
|
package/src/cosmjs.ts
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
import Long from "long";
|
2
|
+
|
3
|
+
export declare enum BroadcastMode {
|
4
|
+
/** Return after tx commit */
|
5
|
+
Block = "block",
|
6
|
+
/** Return after CheckTx */
|
7
|
+
Sync = "sync",
|
8
|
+
/** Return right away */
|
9
|
+
Async = "async",
|
10
|
+
}
|
11
|
+
|
12
|
+
export interface Coin {
|
13
|
+
readonly denom: string;
|
14
|
+
readonly amount: string;
|
15
|
+
}
|
16
|
+
|
17
|
+
export interface StdFee {
|
18
|
+
readonly amount: readonly Coin[];
|
19
|
+
readonly gas: string;
|
20
|
+
readonly payer?: string;
|
21
|
+
readonly granter?: string;
|
22
|
+
|
23
|
+
// XXX: "feePayer" should be "payer". But, it maybe from ethermint team's mistake.
|
24
|
+
// That means this part is not standard.
|
25
|
+
readonly feePayer?: string;
|
26
|
+
}
|
27
|
+
|
28
|
+
export interface Msg {
|
29
|
+
readonly type: string;
|
30
|
+
readonly value: any;
|
31
|
+
}
|
32
|
+
|
33
|
+
export interface StdSignDoc {
|
34
|
+
readonly chain_id: string;
|
35
|
+
readonly account_number: string;
|
36
|
+
readonly sequence: string;
|
37
|
+
// Should be nullable
|
38
|
+
readonly timeout_height?: string;
|
39
|
+
readonly fee: StdFee;
|
40
|
+
readonly msgs: readonly Msg[];
|
41
|
+
readonly memo: string;
|
42
|
+
}
|
43
|
+
|
44
|
+
export interface PubKey {
|
45
|
+
readonly type: string;
|
46
|
+
readonly value: string;
|
47
|
+
}
|
48
|
+
|
49
|
+
export interface StdSignature {
|
50
|
+
readonly pub_key: PubKey;
|
51
|
+
readonly signature: string;
|
52
|
+
}
|
53
|
+
|
54
|
+
export interface StdTx {
|
55
|
+
readonly msg: readonly Msg[];
|
56
|
+
readonly fee: StdFee;
|
57
|
+
readonly signatures: readonly StdSignature[];
|
58
|
+
readonly memo: string | undefined;
|
59
|
+
}
|
60
|
+
|
61
|
+
export interface AminoSignResponse {
|
62
|
+
readonly signed: StdSignDoc;
|
63
|
+
readonly signature: StdSignature;
|
64
|
+
}
|
65
|
+
|
66
|
+
export interface SignDoc {
|
67
|
+
/**
|
68
|
+
* body_bytes is protobuf serialization of a TxBody that matches the
|
69
|
+
* representation in TxRaw.
|
70
|
+
*/
|
71
|
+
bodyBytes: Uint8Array;
|
72
|
+
/**
|
73
|
+
* auth_info_bytes is a protobuf serialization of an AuthInfo that matches the
|
74
|
+
* representation in TxRaw.
|
75
|
+
*/
|
76
|
+
authInfoBytes: Uint8Array;
|
77
|
+
/**
|
78
|
+
* chain_id is the unique identifier of the chain this transaction targets.
|
79
|
+
* It prevents signed transactions from being used on another chain by an
|
80
|
+
* attacker
|
81
|
+
*/
|
82
|
+
chainId: string;
|
83
|
+
/** account_number is the account number of the account in state */
|
84
|
+
accountNumber: Long;
|
85
|
+
}
|
86
|
+
|
87
|
+
export interface DirectSignResponse {
|
88
|
+
/**
|
89
|
+
* The sign doc that was signed.
|
90
|
+
* This may be different from the input signDoc when the signer modifies it as part of the signing process.
|
91
|
+
*/
|
92
|
+
readonly signed: SignDoc;
|
93
|
+
readonly signature: StdSignature;
|
94
|
+
}
|
95
|
+
|
96
|
+
/**
|
97
|
+
* This is the same as Algo from @cosmjs/launchpad but those might diverge in the future.
|
98
|
+
*/
|
99
|
+
export declare type Algo = "secp256k1" | "ed25519" | "sr25519";
|
100
|
+
/**
|
101
|
+
* This is the same as AccountData from @cosmjs/launchpad but those might diverge in the future.
|
102
|
+
*/
|
103
|
+
export interface AccountData {
|
104
|
+
/** A printable address (typically bech32 encoded) */
|
105
|
+
readonly address: string;
|
106
|
+
readonly algo: Algo;
|
107
|
+
readonly pubkey: Uint8Array;
|
108
|
+
}
|
109
|
+
export interface DirectSignResponse {
|
110
|
+
/**
|
111
|
+
* The sign doc that was signed.
|
112
|
+
* This may be different from the input signDoc when the signer modifies it as part of the signing process.
|
113
|
+
*/
|
114
|
+
readonly signed: SignDoc;
|
115
|
+
readonly signature: StdSignature;
|
116
|
+
}
|
117
|
+
export interface OfflineDirectSigner {
|
118
|
+
readonly getAccounts: () => Promise<readonly AccountData[]>;
|
119
|
+
readonly signDirect: (
|
120
|
+
signerAddress: string,
|
121
|
+
signDoc: SignDoc
|
122
|
+
) => Promise<DirectSignResponse>;
|
123
|
+
}
|
124
|
+
|
125
|
+
export interface OfflineAminoSigner {
|
126
|
+
/**
|
127
|
+
* Get AccountData array from wallet. Rejects if not enabled.
|
128
|
+
*/
|
129
|
+
readonly getAccounts: () => Promise<readonly AccountData[]>;
|
130
|
+
/**
|
131
|
+
* Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled.
|
132
|
+
*
|
133
|
+
* The signer implementation may offer the user the ability to override parts of the signDoc. It must
|
134
|
+
* return the doc that was signed in the response.
|
135
|
+
*
|
136
|
+
* @param signerAddress The address of the account that should sign the transaction
|
137
|
+
* @param signDoc The content that should be signed
|
138
|
+
*/
|
139
|
+
readonly signAmino: (
|
140
|
+
signerAddress: string,
|
141
|
+
signDoc: StdSignDoc
|
142
|
+
) => Promise<AminoSignResponse>;
|
143
|
+
}
|
package/src/ethereum.ts
CHANGED
package/src/index.ts
CHANGED
package/src/secretjs.ts
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
export interface SecretUtils {
|
2
|
+
getPubkey: () => Promise<Uint8Array>;
|
3
|
+
decrypt: (ciphertext: Uint8Array, nonce: Uint8Array) => Promise<Uint8Array>;
|
4
|
+
encrypt: (
|
5
|
+
contractCodeHash: string,
|
6
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
7
|
+
msg: object
|
8
|
+
) => Promise<Uint8Array>;
|
9
|
+
getTxEncryptionKey: (nonce: Uint8Array) => Promise<Uint8Array>;
|
10
|
+
}
|
package/src/settled.ts
ADDED
package/src/wallet/keplr.ts
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
import { ChainInfo } from "../chain-info";
|
1
|
+
import { ChainInfo, ChainInfoWithoutEndpoints } from "../chain-info";
|
2
2
|
import { EthSignType } from "../ethereum";
|
3
3
|
import {
|
4
4
|
BroadcastMode,
|
5
5
|
AminoSignResponse,
|
6
6
|
StdSignDoc,
|
7
|
-
|
7
|
+
OfflineAminoSigner,
|
8
8
|
StdSignature,
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
DirectSignResponse,
|
10
|
+
OfflineDirectSigner,
|
11
|
+
} from "../cosmjs";
|
12
|
+
import { SecretUtils } from "../secretjs";
|
12
13
|
import Long from "long";
|
14
|
+
import { SettledResponses } from "../settled";
|
13
15
|
|
14
16
|
export interface Key {
|
15
17
|
// Name of the selected key store.
|
@@ -22,8 +24,19 @@ export interface Key {
|
|
22
24
|
// Because current cosmos app in the nano ledger doesn't support the direct (proto) format msgs,
|
23
25
|
// this can be used to select the amino or direct signer.
|
24
26
|
readonly isNanoLedger: boolean;
|
27
|
+
readonly isKeystone: boolean;
|
25
28
|
}
|
26
29
|
|
30
|
+
export type ICNSAdr36Signatures = {
|
31
|
+
chainId: string;
|
32
|
+
bech32Prefix: string;
|
33
|
+
bech32Address: string;
|
34
|
+
addressHash: "cosmos" | "ethereum";
|
35
|
+
pubKey: Uint8Array;
|
36
|
+
signatureSalt: number;
|
37
|
+
signature: Uint8Array;
|
38
|
+
}[];
|
39
|
+
|
27
40
|
export type KeplrMode = "core" | "extension" | "mobile-web" | "walletconnect";
|
28
41
|
|
29
42
|
export interface KeplrIntereactionOptions {
|
@@ -49,7 +62,17 @@ export interface Keplr {
|
|
49
62
|
|
50
63
|
experimentalSuggestChain(chainInfo: ChainInfo): Promise<void>;
|
51
64
|
enable(chainIds: string | string[]): Promise<void>;
|
65
|
+
/**
|
66
|
+
* Delete permissions granted to origin.
|
67
|
+
* If chain ids are specified, only the permissions granted to each chain id are deleted (In this case, permissions such as getChainInfosWithoutEndpoints() are not deleted).
|
68
|
+
* Else, remove all permissions granted to origin (In this case, permissions that are not assigned to each chain, such as getChainInfosWithoutEndpoints(), are also deleted).
|
69
|
+
*
|
70
|
+
* @param chainIds disable(Remove approve domain(s)) target chain ID(s).
|
71
|
+
*/
|
72
|
+
disable(chainIds?: string | string[]): Promise<void>;
|
73
|
+
|
52
74
|
getKey(chainId: string): Promise<Key>;
|
75
|
+
getKeysSettled(chainIds: string[]): Promise<SettledResponses<Key>>;
|
53
76
|
signAmino(
|
54
77
|
chainId: string,
|
55
78
|
signer: string,
|
@@ -80,6 +103,14 @@ export interface Keplr {
|
|
80
103
|
mode: BroadcastMode
|
81
104
|
): Promise<Uint8Array>;
|
82
105
|
|
106
|
+
signICNSAdr36(
|
107
|
+
chainId: string,
|
108
|
+
contractAddress: string,
|
109
|
+
owner: string,
|
110
|
+
username: string,
|
111
|
+
addressChainIds: string[]
|
112
|
+
): Promise<ICNSAdr36Signatures>;
|
113
|
+
|
83
114
|
signArbitrary(
|
84
115
|
chainId: string,
|
85
116
|
signer: string,
|
@@ -99,11 +130,11 @@ export interface Keplr {
|
|
99
130
|
type: EthSignType
|
100
131
|
): Promise<Uint8Array>;
|
101
132
|
|
102
|
-
getOfflineSigner(chainId: string):
|
103
|
-
getOfflineSignerOnlyAmino(chainId: string):
|
133
|
+
getOfflineSigner(chainId: string): OfflineAminoSigner & OfflineDirectSigner;
|
134
|
+
getOfflineSignerOnlyAmino(chainId: string): OfflineAminoSigner;
|
104
135
|
getOfflineSignerAuto(
|
105
136
|
chainId: string
|
106
|
-
): Promise<
|
137
|
+
): Promise<OfflineAminoSigner | OfflineDirectSigner>;
|
107
138
|
|
108
139
|
suggestToken(
|
109
140
|
chainId: string,
|
@@ -134,4 +165,37 @@ export interface Keplr {
|
|
134
165
|
ciphertext: Uint8Array,
|
135
166
|
nonce: Uint8Array
|
136
167
|
): Promise<Uint8Array>;
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Sign the sign doc with ethermint's EIP-712 format.
|
171
|
+
* The difference from signEthereum(..., EthSignType.EIP712) is that this api returns a new sign doc changed by the user's fee setting and the signature for that sign doc.
|
172
|
+
* Encoding tx to EIP-712 format should be done on the side using this api.
|
173
|
+
* Not compatible with cosmjs.
|
174
|
+
* The returned signature is (r | s | v) format which used in ethereum.
|
175
|
+
* v should be 27 or 28 which is used in the ethereum mainnet regardless of chain.
|
176
|
+
* @param chainId
|
177
|
+
* @param signer
|
178
|
+
* @param eip712
|
179
|
+
* @param signDoc
|
180
|
+
* @param signOptions
|
181
|
+
*/
|
182
|
+
experimentalSignEIP712CosmosTx_v0(
|
183
|
+
chainId: string,
|
184
|
+
signer: string,
|
185
|
+
eip712: {
|
186
|
+
types: Record<string, { name: string; type: string }[] | undefined>;
|
187
|
+
domain: Record<string, any>;
|
188
|
+
primaryType: string;
|
189
|
+
},
|
190
|
+
signDoc: StdSignDoc,
|
191
|
+
signOptions?: KeplrSignOptions
|
192
|
+
): Promise<AminoSignResponse>;
|
193
|
+
|
194
|
+
getChainInfosWithoutEndpoints(): Promise<ChainInfoWithoutEndpoints[]>;
|
195
|
+
|
196
|
+
/** Change wallet extension user name **/
|
197
|
+
changeKeyRingName(opts: {
|
198
|
+
defaultName: string;
|
199
|
+
editable?: boolean;
|
200
|
+
}): Promise<string>;
|
137
201
|
}
|
package/src/window.ts
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
import { Keplr } from "./wallet";
|
2
|
-
import {
|
3
|
-
import { SecretUtils } from "secretjs
|
4
|
-
import { OfflineDirectSigner } from "@cosmjs/proto-signing";
|
2
|
+
import { OfflineAminoSigner, OfflineDirectSigner } from "./cosmjs";
|
3
|
+
import { SecretUtils } from "./secretjs";
|
5
4
|
|
6
5
|
export interface Window {
|
7
6
|
keplr?: Keplr;
|
8
|
-
getOfflineSigner?: (
|
9
|
-
|
7
|
+
getOfflineSigner?: (
|
8
|
+
chainId: string
|
9
|
+
) => OfflineAminoSigner & OfflineDirectSigner;
|
10
|
+
getOfflineSignerOnlyAmino?: (chainId: string) => OfflineAminoSigner;
|
10
11
|
getOfflineSignerAuto?: (
|
11
12
|
chainId: string
|
12
|
-
) => Promise<
|
13
|
+
) => Promise<OfflineAminoSigner | OfflineDirectSigner>;
|
13
14
|
getEnigmaUtils?: (chainId: string) => SecretUtils;
|
14
15
|
}
|