@openocean.finance/wallet 0.4.50 → 0.4.52
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/lib/Wallets/KeplrWallet.d.ts +1 -1
- package/lib/Wallets/KeplrWallet.js +65 -13
- package/lib/types.d.ts +1 -2
- package/lib/types.js +1 -2
- package/package.json +2 -1
|
@@ -11,6 +11,6 @@ declare class KeplrWallet extends BaseWallet {
|
|
|
11
11
|
* connect metamask and get wallet address
|
|
12
12
|
* @param chainId specific chainId,throw error when not match
|
|
13
13
|
*/
|
|
14
|
-
requestCosmosConnect(
|
|
14
|
+
requestCosmosConnect(chainId: string): Promise<string>;
|
|
15
15
|
}
|
|
16
16
|
export default KeplrWallet;
|
|
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
17
28
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
29
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
30
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -50,6 +61,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
61
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
62
|
}
|
|
52
63
|
};
|
|
64
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
+
if (ar || !(i in from)) {
|
|
67
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
+
ar[i] = from[i];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
|
+
};
|
|
53
73
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
74
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
75
|
};
|
|
@@ -66,13 +86,42 @@ var types_1 = require("../types");
|
|
|
66
86
|
var BaseWallet_1 = __importDefault(require("./BaseWallet"));
|
|
67
87
|
var launchpad_1 = require("@cosmjs/launchpad");
|
|
68
88
|
var stargate_1 = require("@cosmjs/stargate");
|
|
89
|
+
var proto_signing_1 = require("@cosmjs/proto-signing");
|
|
90
|
+
var osmojs_1 = require("osmojs");
|
|
91
|
+
var protoRegistryBase = __spreadArray(__spreadArray(__spreadArray([], osmojs_1.cosmosProtoRegistry, true), osmojs_1.cosmwasmProtoRegistry, true), osmojs_1.ibcProtoRegistry, true);
|
|
92
|
+
var aminoConvertersBase = __assign(__assign(__assign({}, osmojs_1.cosmosAminoConverters), osmojs_1.cosmwasmAminoConverters), osmojs_1.ibcAminoConverters);
|
|
93
|
+
var chainObj = {
|
|
94
|
+
'cosmoshub-4': {
|
|
95
|
+
chainId: 'cosmoshub-4',
|
|
96
|
+
chainName: 'Cosmos',
|
|
97
|
+
rpcUrls: [
|
|
98
|
+
''
|
|
99
|
+
],
|
|
100
|
+
blockExplorerUrl: '',
|
|
101
|
+
apiUrl: '',
|
|
102
|
+
protoRegistry: new proto_signing_1.Registry(__spreadArray([], protoRegistryBase, true)),
|
|
103
|
+
aminoConverters: new stargate_1.AminoTypes(__assign({}, aminoConvertersBase))
|
|
104
|
+
},
|
|
105
|
+
'osmosis-1': {
|
|
106
|
+
chainId: 'osmosis-1',
|
|
107
|
+
chainName: 'Osmosis',
|
|
108
|
+
rpcUrls: [
|
|
109
|
+
'https://rpc.cosmos.directory/osmosis'
|
|
110
|
+
],
|
|
111
|
+
blockExplorerUrl: 'https://www.mintscan.io/osmosis/txs',
|
|
112
|
+
compiler: 'COSMOS',
|
|
113
|
+
apiUrl: '',
|
|
114
|
+
protoRegistry: __spreadArray(__spreadArray([], protoRegistryBase, true), osmojs_1.osmosisProtoRegistry, true),
|
|
115
|
+
aminoConverters: __assign(__assign({}, aminoConvertersBase), osmojs_1.osmosisAminoConverters)
|
|
116
|
+
}
|
|
117
|
+
};
|
|
69
118
|
var KeplrWallet = /** @class */ (function (_super) {
|
|
70
119
|
__extends(KeplrWallet, _super);
|
|
71
120
|
function KeplrWallet() {
|
|
72
121
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
73
122
|
_this.name = types_1.EnumWalletName.keplrWallet;
|
|
74
123
|
_this.icon = keplr_png_1.default;
|
|
75
|
-
_this.supportChains = [types_1.EnumChains.
|
|
124
|
+
_this.supportChains = [types_1.EnumChains.Cosmos];
|
|
76
125
|
_this.type = types_1.EnumWalletType.Web;
|
|
77
126
|
_this.sdk = null;
|
|
78
127
|
_this.installUrl = "https://chrome.google.com/webstore/detail/keplr/dmkamcknogkgcdfhhbddcghachkejeap";
|
|
@@ -82,33 +131,36 @@ var KeplrWallet = /** @class */ (function (_super) {
|
|
|
82
131
|
* connect metamask and get wallet address
|
|
83
132
|
* @param chainId specific chainId,throw error when not match
|
|
84
133
|
*/
|
|
85
|
-
KeplrWallet.prototype.requestCosmosConnect = function (
|
|
134
|
+
KeplrWallet.prototype.requestCosmosConnect = function (chainId) {
|
|
86
135
|
var _this = this;
|
|
87
136
|
return new Promise(function (res) { return __awaiter(_this, void 0, void 0, function () {
|
|
88
|
-
var wallet, offlineSigner, accounts, address,
|
|
89
|
-
return __generator(this, function (
|
|
90
|
-
switch (
|
|
137
|
+
var _a, rpcUrls, apiUrl, protoRegistry, aminoConverters, wallet, offlineSigner, accounts, address, _b;
|
|
138
|
+
return __generator(this, function (_c) {
|
|
139
|
+
switch (_c.label) {
|
|
91
140
|
case 0:
|
|
92
141
|
if (!window.keplr) {
|
|
93
142
|
throw new Error(types_1.EnumErrors.NoKeplr);
|
|
94
143
|
}
|
|
144
|
+
_a = chainObj[chainId], rpcUrls = _a.rpcUrls, apiUrl = _a.apiUrl, protoRegistry = _a.protoRegistry, aminoConverters = _a.aminoConverters;
|
|
95
145
|
wallet = window.keplr;
|
|
96
146
|
return [4 /*yield*/, wallet.enable(chainId)];
|
|
97
147
|
case 1:
|
|
98
|
-
|
|
148
|
+
_c.sent();
|
|
99
149
|
offlineSigner = wallet.getOfflineSigner(chainId);
|
|
100
150
|
return [4 /*yield*/, offlineSigner.getAccounts()];
|
|
101
151
|
case 2:
|
|
102
|
-
accounts =
|
|
152
|
+
accounts = _c.sent();
|
|
103
153
|
address = accounts[0].address;
|
|
104
|
-
|
|
105
|
-
return [4 /*yield*/, stargate_1.SigningStargateClient.connectWithSigner(
|
|
106
|
-
registry:
|
|
107
|
-
aminoTypes:
|
|
154
|
+
_b = this;
|
|
155
|
+
return [4 /*yield*/, stargate_1.SigningStargateClient.connectWithSigner(rpcUrls[0], offlineSigner, {
|
|
156
|
+
registry: protoRegistry,
|
|
157
|
+
aminoTypes: aminoConverters,
|
|
108
158
|
})];
|
|
109
159
|
case 3:
|
|
110
|
-
|
|
111
|
-
|
|
160
|
+
_b.sdk = _c.sent();
|
|
161
|
+
if (apiUrl) {
|
|
162
|
+
this.sdk.lcdClient = launchpad_1.LcdClient.withExtensions({ apiUrl: apiUrl }, launchpad_1.setupAuthExtension, launchpad_1.setupBankExtension, launchpad_1.setupDistributionExtension, launchpad_1.setupGovExtension, launchpad_1.setupMintExtension, launchpad_1.setupSlashingExtension, launchpad_1.setupStakingExtension, launchpad_1.setupSupplyExtension);
|
|
163
|
+
}
|
|
112
164
|
this.address = address;
|
|
113
165
|
this.chainId = chainId;
|
|
114
166
|
res(address);
|
package/lib/types.d.ts
CHANGED
package/lib/types.js
CHANGED
|
@@ -33,8 +33,7 @@ var EnumChains;
|
|
|
33
33
|
EnumChains["Aurora"] = "aurora";
|
|
34
34
|
EnumChains["Cronos"] = "cronos";
|
|
35
35
|
EnumChains["Harmony"] = "harmony";
|
|
36
|
-
EnumChains["
|
|
37
|
-
EnumChains["Sifchain"] = "sifchain";
|
|
36
|
+
EnumChains["Cosmos"] = "cosmos";
|
|
38
37
|
EnumChains["Flow"] = "flow";
|
|
39
38
|
EnumChains["Aptos"] = "aptos";
|
|
40
39
|
})(EnumChains = exports.EnumChains || (exports.EnumChains = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openocean.finance/wallet",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.52",
|
|
4
4
|
"description": "A multi-chain wallets manager",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"buffer": "^6.0.3",
|
|
55
55
|
"fs": "^0.0.1-security",
|
|
56
56
|
"near-api-js": "^0.44.2",
|
|
57
|
+
"osmojs": "^13.0.0-rc.7-i-alpha",
|
|
57
58
|
"path-browserify": "^1.0.1",
|
|
58
59
|
"web3": "^1.7.4"
|
|
59
60
|
},
|