@keplr-wallet/provider 0.9.4-rc.0 → 0.9.9-rc.0
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/build/core.d.ts +10 -4
- package/build/core.js +29 -16
- package/build/core.js.map +1 -1
- package/build/cosmjs.d.ts +2 -2
- package/build/cosmjs.js.map +1 -1
- package/build/index.d.ts +0 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/build/inject.d.ts +24 -5
- package/build/inject.js +76 -27
- package/build/inject.js.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.js +14 -0
- package/build/types/index.js.map +1 -0
- package/build/types/msgs.d.ts +133 -0
- package/build/types/msgs.js +340 -0
- package/build/types/msgs.js.map +1 -0
- package/package.json +6 -10
- package/src/core.ts +24 -5
- package/src/cosmjs.ts +2 -2
- package/src/index.ts +0 -1
- package/src/inject.ts +119 -27
- package/src/types/index.ts +1 -0
- package/src/types/msgs.ts +423 -0
- package/build/mock.d.ts +0 -43
- package/build/mock.js +0 -106
- package/build/mock.js.map +0 -1
- package/src/mock.ts +0 -161
package/build/mock.js
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.MockKeplr = void 0;
|
13
|
-
const launchpad_1 = require("@cosmjs/launchpad");
|
14
|
-
const cosmos_1 = require("@keplr-wallet/cosmos");
|
15
|
-
const cosmjs_1 = require("./cosmjs");
|
16
|
-
class MockKeplr {
|
17
|
-
constructor(sendTxFn, chainInfos, mnemonic) {
|
18
|
-
this.sendTxFn = sendTxFn;
|
19
|
-
this.chainInfos = chainInfos;
|
20
|
-
this.mnemonic = mnemonic;
|
21
|
-
this.version = "0.0.1";
|
22
|
-
this.defaultOptions = {};
|
23
|
-
this.walletMap = {};
|
24
|
-
}
|
25
|
-
getHdWallet(chainId) {
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
27
|
-
if (!this.walletMap[chainId]) {
|
28
|
-
const chainInfo = this.chainInfos.find((info) => info.chainId === chainId);
|
29
|
-
if (!chainInfo) {
|
30
|
-
throw new Error("Unknown chain");
|
31
|
-
}
|
32
|
-
this.walletMap[chainId] = yield launchpad_1.Secp256k1HdWallet.fromMnemonic(this.mnemonic, launchpad_1.makeCosmoshubPath(0), chainInfo.bech32Config.bech32PrefixAccAddr);
|
33
|
-
}
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
35
|
-
return this.walletMap[chainId];
|
36
|
-
});
|
37
|
-
}
|
38
|
-
enable() {
|
39
|
-
// noop.
|
40
|
-
return Promise.resolve(undefined);
|
41
|
-
}
|
42
|
-
enigmaDecrypt() {
|
43
|
-
throw new Error("Not implemented");
|
44
|
-
}
|
45
|
-
enigmaEncrypt() {
|
46
|
-
throw new Error("Not implemented");
|
47
|
-
}
|
48
|
-
experimentalSuggestChain() {
|
49
|
-
throw new Error("Not implemented");
|
50
|
-
}
|
51
|
-
getEnigmaPubKey() {
|
52
|
-
throw new Error("Not implemented");
|
53
|
-
}
|
54
|
-
getEnigmaUtils() {
|
55
|
-
throw new Error("Not implemented");
|
56
|
-
}
|
57
|
-
getKey(chainId) {
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
59
|
-
const cosmJsKeys = yield (yield this.getHdWallet(chainId)).getAccounts();
|
60
|
-
return {
|
61
|
-
name: "",
|
62
|
-
algo: "secp256k1",
|
63
|
-
pubKey: cosmJsKeys[0].pubkey,
|
64
|
-
address: cosmos_1.Bech32Address.fromBech32(cosmJsKeys[0].address).address,
|
65
|
-
bech32Address: cosmJsKeys[0].address,
|
66
|
-
isNanoLedger: false,
|
67
|
-
};
|
68
|
-
});
|
69
|
-
}
|
70
|
-
getOfflineSigner(chainId) {
|
71
|
-
return new cosmjs_1.CosmJSOfflineSigner(chainId, this);
|
72
|
-
}
|
73
|
-
getSecret20ViewingKey() {
|
74
|
-
throw new Error("Not implemented");
|
75
|
-
}
|
76
|
-
sendTx(chainId, stdTx, mode) {
|
77
|
-
return this.sendTxFn(chainId, stdTx, mode);
|
78
|
-
}
|
79
|
-
signAmino(chainId, signer, signDoc, _) {
|
80
|
-
return __awaiter(this, void 0, void 0, function* () {
|
81
|
-
const hdWallet = yield this.getHdWallet(chainId);
|
82
|
-
const keys = yield hdWallet.getAccounts();
|
83
|
-
if (keys[0].address !== signer) {
|
84
|
-
throw new Error("Unmatched signer");
|
85
|
-
}
|
86
|
-
return hdWallet.signAmino(signer, signDoc);
|
87
|
-
});
|
88
|
-
}
|
89
|
-
signDirect() {
|
90
|
-
throw new Error("Not implemented");
|
91
|
-
}
|
92
|
-
suggestToken() {
|
93
|
-
throw new Error("Not implemented");
|
94
|
-
}
|
95
|
-
getEnigmaTxEncryptionKey(_chainId, _nonce) {
|
96
|
-
throw new Error("Not implemented");
|
97
|
-
}
|
98
|
-
getOfflineSignerAuto(_chainId) {
|
99
|
-
throw new Error("Not implemented");
|
100
|
-
}
|
101
|
-
getOfflineSignerOnlyAmino(_chainId) {
|
102
|
-
throw new Error("Not implemented");
|
103
|
-
}
|
104
|
-
}
|
105
|
-
exports.MockKeplr = MockKeplr;
|
106
|
-
//# sourceMappingURL=mock.js.map
|
package/build/mock.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mock.js","sourceRoot":"","sources":["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K,CAAC,kBAAkB,CAAC,CAAC;aACrC;YAED,OAAO,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7C,CAAC;KAAA;IAED,UAAU;QACR,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,YAAY;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,wBAAwB,CACtB,QAAgB,EAChB,MAAkB;QAElB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,oBAAoB,CAClB,QAAgB;QAEhB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,yBAAyB,CAAC,QAAgB;QACxC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF;AA3ID,8BA2IC"}
|
package/src/mock.ts
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
Keplr,
|
3
|
-
KeplrIntereactionOptions,
|
4
|
-
KeplrSignOptions,
|
5
|
-
Key,
|
6
|
-
} from "@keplr-wallet/types";
|
7
|
-
import {
|
8
|
-
AminoSignResponse,
|
9
|
-
BroadcastMode,
|
10
|
-
makeCosmoshubPath,
|
11
|
-
OfflineSigner,
|
12
|
-
Secp256k1HdWallet,
|
13
|
-
StdSignDoc,
|
14
|
-
StdTx,
|
15
|
-
} from "@cosmjs/launchpad";
|
16
|
-
import { SecretUtils } from "secretjs/types/enigmautils";
|
17
|
-
import { Bech32Address } from "@keplr-wallet/cosmos";
|
18
|
-
import { OfflineDirectSigner } from "@cosmjs/proto-signing";
|
19
|
-
import { CosmJSOfflineSigner } from "./cosmjs";
|
20
|
-
import { DirectSignResponse } from "@cosmjs/proto-signing/build/signer";
|
21
|
-
|
22
|
-
export class MockKeplr implements Keplr {
|
23
|
-
readonly version: string = "0.0.1";
|
24
|
-
|
25
|
-
public defaultOptions: KeplrIntereactionOptions = {};
|
26
|
-
|
27
|
-
public readonly walletMap: {
|
28
|
-
[chainId: string]: Secp256k1HdWallet | undefined;
|
29
|
-
} = {};
|
30
|
-
|
31
|
-
async getHdWallet(chainId: string): Promise<Secp256k1HdWallet> {
|
32
|
-
if (!this.walletMap[chainId]) {
|
33
|
-
const chainInfo = this.chainInfos.find(
|
34
|
-
(info) => info.chainId === chainId
|
35
|
-
);
|
36
|
-
|
37
|
-
if (!chainInfo) {
|
38
|
-
throw new Error("Unknown chain");
|
39
|
-
}
|
40
|
-
|
41
|
-
this.walletMap[chainId] = await Secp256k1HdWallet.fromMnemonic(
|
42
|
-
this.mnemonic,
|
43
|
-
makeCosmoshubPath(0),
|
44
|
-
chainInfo.bech32Config.bech32PrefixAccAddr
|
45
|
-
);
|
46
|
-
}
|
47
|
-
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
49
|
-
return this.walletMap[chainId]!;
|
50
|
-
}
|
51
|
-
|
52
|
-
constructor(
|
53
|
-
public readonly sendTxFn: (
|
54
|
-
chainId: string,
|
55
|
-
stdTx: StdTx,
|
56
|
-
mode: BroadcastMode
|
57
|
-
) => Promise<Uint8Array>,
|
58
|
-
public readonly chainInfos: {
|
59
|
-
readonly chainId: string;
|
60
|
-
readonly bech32Config: {
|
61
|
-
readonly bech32PrefixAccAddr: string;
|
62
|
-
};
|
63
|
-
}[],
|
64
|
-
public readonly mnemonic: string
|
65
|
-
) {}
|
66
|
-
|
67
|
-
enable(): Promise<void> {
|
68
|
-
// noop.
|
69
|
-
return Promise.resolve(undefined);
|
70
|
-
}
|
71
|
-
|
72
|
-
enigmaDecrypt(): Promise<Uint8Array> {
|
73
|
-
throw new Error("Not implemented");
|
74
|
-
}
|
75
|
-
|
76
|
-
enigmaEncrypt(): Promise<Uint8Array> {
|
77
|
-
throw new Error("Not implemented");
|
78
|
-
}
|
79
|
-
|
80
|
-
experimentalSuggestChain(): Promise<void> {
|
81
|
-
throw new Error("Not implemented");
|
82
|
-
}
|
83
|
-
|
84
|
-
getEnigmaPubKey(): Promise<Uint8Array> {
|
85
|
-
throw new Error("Not implemented");
|
86
|
-
}
|
87
|
-
|
88
|
-
getEnigmaUtils(): SecretUtils {
|
89
|
-
throw new Error("Not implemented");
|
90
|
-
}
|
91
|
-
|
92
|
-
async getKey(chainId: string): Promise<Key> {
|
93
|
-
const cosmJsKeys = await (await this.getHdWallet(chainId)).getAccounts();
|
94
|
-
|
95
|
-
return {
|
96
|
-
name: "",
|
97
|
-
algo: "secp256k1",
|
98
|
-
pubKey: cosmJsKeys[0].pubkey,
|
99
|
-
address: Bech32Address.fromBech32(cosmJsKeys[0].address).address,
|
100
|
-
bech32Address: cosmJsKeys[0].address,
|
101
|
-
isNanoLedger: false,
|
102
|
-
};
|
103
|
-
}
|
104
|
-
|
105
|
-
getOfflineSigner(chainId: string): OfflineSigner & OfflineDirectSigner {
|
106
|
-
return new CosmJSOfflineSigner(chainId, this);
|
107
|
-
}
|
108
|
-
|
109
|
-
getSecret20ViewingKey(): Promise<string> {
|
110
|
-
throw new Error("Not implemented");
|
111
|
-
}
|
112
|
-
|
113
|
-
sendTx(
|
114
|
-
chainId: string,
|
115
|
-
stdTx: StdTx,
|
116
|
-
mode: BroadcastMode
|
117
|
-
): Promise<Uint8Array> {
|
118
|
-
return this.sendTxFn(chainId, stdTx, mode);
|
119
|
-
}
|
120
|
-
|
121
|
-
async signAmino(
|
122
|
-
chainId: string,
|
123
|
-
signer: string,
|
124
|
-
signDoc: StdSignDoc,
|
125
|
-
_?: KeplrSignOptions
|
126
|
-
): Promise<AminoSignResponse> {
|
127
|
-
const hdWallet = await this.getHdWallet(chainId);
|
128
|
-
|
129
|
-
const keys = await hdWallet.getAccounts();
|
130
|
-
if (keys[0].address !== signer) {
|
131
|
-
throw new Error("Unmatched signer");
|
132
|
-
}
|
133
|
-
|
134
|
-
return hdWallet.signAmino(signer, signDoc);
|
135
|
-
}
|
136
|
-
|
137
|
-
signDirect(): Promise<DirectSignResponse> {
|
138
|
-
throw new Error("Not implemented");
|
139
|
-
}
|
140
|
-
|
141
|
-
suggestToken(): Promise<void> {
|
142
|
-
throw new Error("Not implemented");
|
143
|
-
}
|
144
|
-
|
145
|
-
getEnigmaTxEncryptionKey(
|
146
|
-
_chainId: string,
|
147
|
-
_nonce: Uint8Array
|
148
|
-
): Promise<Uint8Array> {
|
149
|
-
throw new Error("Not implemented");
|
150
|
-
}
|
151
|
-
|
152
|
-
getOfflineSignerAuto(
|
153
|
-
_chainId: string
|
154
|
-
): Promise<OfflineSigner | OfflineDirectSigner> {
|
155
|
-
throw new Error("Not implemented");
|
156
|
-
}
|
157
|
-
|
158
|
-
getOfflineSignerOnlyAmino(_chainId: string): OfflineSigner {
|
159
|
-
throw new Error("Not implemented");
|
160
|
-
}
|
161
|
-
}
|