@openocean.finance/wallet 0.4.51 → 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.
@@ -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(customRegistry: any, customAminoTypes: any, endpoint: string, apiUrl: string, chainId?: string): Promise<string>;
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,6 +86,35 @@ 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() {
@@ -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 (customRegistry, customAminoTypes, endpoint, apiUrl, chainId) {
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, _a;
89
- return __generator(this, function (_b) {
90
- switch (_b.label) {
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
- _b.sent();
148
+ _c.sent();
99
149
  offlineSigner = wallet.getOfflineSigner(chainId);
100
150
  return [4 /*yield*/, offlineSigner.getAccounts()];
101
151
  case 2:
102
- accounts = _b.sent();
152
+ accounts = _c.sent();
103
153
  address = accounts[0].address;
104
- _a = this;
105
- return [4 /*yield*/, stargate_1.SigningStargateClient.connectWithSigner(endpoint, offlineSigner, {
106
- registry: customRegistry,
107
- aminoTypes: customAminoTypes,
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
- _a.sdk = _b.sent();
111
- 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);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/wallet",
3
- "version": "0.4.51",
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
  },