@getpara/graz-connector 2.0.0-dev.12 → 2.0.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/dist/cjs/connector.js +348 -0
- package/dist/cjs/index.js +30 -0
- package/dist/cjs/package.json +3 -0
- package/dist/{connector.js → esm/connector.js} +2 -6
- package/dist/{connector.d.ts → types/connector.d.ts} +2 -12
- package/package.json +24 -13
- package/__tests__/connector.test.tsx +0 -491
- package/__tests__/connectorModal.test.tsx +0 -148
- package/scripts/build.mjs +0 -36
- package/src/connector.ts +0 -355
- package/src/index.ts +0 -2
- package/tsconfig.json +0 -13
- package/vitest.config.js +0 -22
- /package/dist/{chunk-M66XENHI.js → esm/chunk-M66XENHI.js} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{package.json → esm/package.json} +0 -0
- /package/dist/{index.d.ts → types/index.d.ts} +0 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __async = (__this, __arguments, generator) => {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
var fulfilled = (value) => {
|
|
22
|
+
try {
|
|
23
|
+
step(generator.next(value));
|
|
24
|
+
} catch (e) {
|
|
25
|
+
reject(e);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var rejected = (value) => {
|
|
29
|
+
try {
|
|
30
|
+
step(generator.throw(value));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
reject(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
36
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var connector_exports = {};
|
|
40
|
+
__export(connector_exports, {
|
|
41
|
+
ParaGrazConnector: () => ParaGrazConnector,
|
|
42
|
+
toArray: () => toArray
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(connector_exports);
|
|
45
|
+
var import_encoding = require("@cosmjs/encoding");
|
|
46
|
+
var import_cosmjs_v0_integration = require("@getpara/cosmjs-v0-integration");
|
|
47
|
+
function toArray(v) {
|
|
48
|
+
return Array.isArray(v) ? v : [v];
|
|
49
|
+
}
|
|
50
|
+
class ParaOfflineSigner {
|
|
51
|
+
constructor(chainId, connector) {
|
|
52
|
+
this.chainId = chainId;
|
|
53
|
+
this.connector = connector;
|
|
54
|
+
}
|
|
55
|
+
get para() {
|
|
56
|
+
return this.connector.getParaWebClient();
|
|
57
|
+
}
|
|
58
|
+
get prefix() {
|
|
59
|
+
return this.connector.getBech32Prefix(this.chainId);
|
|
60
|
+
}
|
|
61
|
+
wallet() {
|
|
62
|
+
return __async(this, null, function* () {
|
|
63
|
+
return this.connector.getFirstWallet();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
getAccounts() {
|
|
67
|
+
return __async(this, null, function* () {
|
|
68
|
+
const key = yield this.connector.getKey(this.chainId);
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
address: key.bech32Address,
|
|
72
|
+
algo: key.algo,
|
|
73
|
+
pubkey: key.pubKey
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
signDirect(signerAddress, signDoc) {
|
|
79
|
+
return __async(this, null, function* () {
|
|
80
|
+
if (this.chainId !== signDoc.chainId) {
|
|
81
|
+
throw new Error(`Chain ID mismatch: expected ${this.chainId}, got ${signDoc.chainId}`);
|
|
82
|
+
}
|
|
83
|
+
const accounts = yield this.getAccounts();
|
|
84
|
+
if (accounts.every((a) => a.address !== signerAddress)) {
|
|
85
|
+
throw new Error(`Signer address ${signerAddress} not found in wallet`);
|
|
86
|
+
}
|
|
87
|
+
const signer = new import_cosmjs_v0_integration.ParaProtoSigner(this.para, this.prefix, (yield this.wallet()).id);
|
|
88
|
+
try {
|
|
89
|
+
const result = yield signer.signDirect(signerAddress, signDoc);
|
|
90
|
+
return {
|
|
91
|
+
signed: {
|
|
92
|
+
bodyBytes: result.signed.bodyBytes,
|
|
93
|
+
authInfoBytes: result.signed.authInfoBytes,
|
|
94
|
+
chainId: result.signed.chainId,
|
|
95
|
+
accountNumber: result.signed.accountNumber
|
|
96
|
+
},
|
|
97
|
+
signature: result.signature
|
|
98
|
+
};
|
|
99
|
+
} catch (err) {
|
|
100
|
+
throw new Error(`Direct signing failed: ${err instanceof Error ? err.message : "Unknown error"}`);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
class ParaGrazConnector {
|
|
106
|
+
constructor(config, chains = null) {
|
|
107
|
+
this.config = config;
|
|
108
|
+
this.chains = chains;
|
|
109
|
+
this.enabledChainIds = /* @__PURE__ */ new Set();
|
|
110
|
+
if (!(config == null ? void 0 : config.paraWeb)) {
|
|
111
|
+
throw new Error("ParaWeb instance required in config");
|
|
112
|
+
}
|
|
113
|
+
this.events = config.events;
|
|
114
|
+
this.paraWebClient = config.paraWeb;
|
|
115
|
+
}
|
|
116
|
+
ensureChainEnabled(chainId) {
|
|
117
|
+
return __async(this, null, function* () {
|
|
118
|
+
if (!this.enabledChainIds.has(chainId)) {
|
|
119
|
+
throw new Error(`Chain ${chainId} not enabled. Call enable() first`);
|
|
120
|
+
}
|
|
121
|
+
if (!(yield this.paraWebClient.isFullyLoggedIn())) {
|
|
122
|
+
throw new Error("Para wallet not authenticated");
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
waitForLogin(timeoutMs = 6e4) {
|
|
127
|
+
return __async(this, null, function* () {
|
|
128
|
+
const deadline = Date.now() + timeoutMs;
|
|
129
|
+
let delay = 500;
|
|
130
|
+
const MAX_DELAY = 5e3;
|
|
131
|
+
while (true) {
|
|
132
|
+
if (yield this.paraWebClient.isFullyLoggedIn()) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (Date.now() >= deadline) {
|
|
136
|
+
throw new Error(`Login timeout after ${timeoutMs / 1e3}s`);
|
|
137
|
+
}
|
|
138
|
+
yield new Promise((r) => setTimeout(r, delay));
|
|
139
|
+
delay = Math.min(delay * 1.5, MAX_DELAY);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
waitForAccounts(timeoutMs = 5e3) {
|
|
144
|
+
return __async(this, null, function* () {
|
|
145
|
+
const deadline = Date.now() + timeoutMs;
|
|
146
|
+
let delay = 250;
|
|
147
|
+
const MAX_DELAY = 1e3;
|
|
148
|
+
while (true) {
|
|
149
|
+
const wallets = this.paraWebClient.getWalletsByType("COSMOS");
|
|
150
|
+
if (wallets.length) {
|
|
151
|
+
return wallets;
|
|
152
|
+
}
|
|
153
|
+
if (Date.now() >= deadline) {
|
|
154
|
+
throw new Error("No Cosmos wallets found");
|
|
155
|
+
}
|
|
156
|
+
yield new Promise((r) => setTimeout(r, delay));
|
|
157
|
+
delay = Math.min(delay * 1.5, MAX_DELAY);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
hasCosmosWallet() {
|
|
162
|
+
return __async(this, null, function* () {
|
|
163
|
+
const isLoggedIn = yield this.paraWebClient.isFullyLoggedIn();
|
|
164
|
+
const wallets = this.paraWebClient.getWalletsByType("COSMOS");
|
|
165
|
+
return isLoggedIn && wallets.length > 0;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
enable(chainIdsInput) {
|
|
169
|
+
return __async(this, null, function* () {
|
|
170
|
+
var _a, _b, _c, _d;
|
|
171
|
+
const chainIds = toArray(chainIdsInput);
|
|
172
|
+
const previousEnabled = new Set(this.enabledChainIds);
|
|
173
|
+
try {
|
|
174
|
+
chainIds.forEach((id) => this.enabledChainIds.add(id));
|
|
175
|
+
if (yield this.hasCosmosWallet()) {
|
|
176
|
+
(_b = (_a = this.events) == null ? void 0 : _a.onEnabled) == null ? void 0 : _b.call(_a, chainIds, this);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
yield this.waitForLogin();
|
|
180
|
+
yield this.waitForAccounts();
|
|
181
|
+
(_d = (_c = this.events) == null ? void 0 : _c.onEnabled) == null ? void 0 : _d.call(_c, chainIds, this);
|
|
182
|
+
} catch (err) {
|
|
183
|
+
this.enabledChainIds = previousEnabled;
|
|
184
|
+
if (err instanceof Error) {
|
|
185
|
+
throw err;
|
|
186
|
+
}
|
|
187
|
+
throw new Error("Failed to enable Para wallet");
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
disconnect() {
|
|
192
|
+
return __async(this, null, function* () {
|
|
193
|
+
try {
|
|
194
|
+
yield this.paraWebClient.logout();
|
|
195
|
+
} catch (e) {
|
|
196
|
+
throw new Error("Disconnect failed");
|
|
197
|
+
} finally {
|
|
198
|
+
this.enabledChainIds.clear();
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
getFirstWallet() {
|
|
203
|
+
return __async(this, null, function* () {
|
|
204
|
+
try {
|
|
205
|
+
const [wallet] = yield this.waitForAccounts();
|
|
206
|
+
return wallet;
|
|
207
|
+
} catch (e) {
|
|
208
|
+
throw new Error("No Para wallet available");
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
getBech32Prefix(chainId) {
|
|
213
|
+
var _a, _b, _c;
|
|
214
|
+
const prefix = ((_c = (_b = (_a = this.chains) == null ? void 0 : _a.find((c) => c.chainId === chainId)) == null ? void 0 : _b.bech32Config) == null ? void 0 : _c.bech32PrefixAccAddr) || "cosmos";
|
|
215
|
+
return prefix;
|
|
216
|
+
}
|
|
217
|
+
getParaWebClient() {
|
|
218
|
+
return this.paraWebClient;
|
|
219
|
+
}
|
|
220
|
+
getConfig() {
|
|
221
|
+
return this.config;
|
|
222
|
+
}
|
|
223
|
+
buildHybridSigner(chainId) {
|
|
224
|
+
const aminoSigner = this.getOfflineSignerOnlyAmino(chainId);
|
|
225
|
+
const directSigner = new ParaOfflineSigner(chainId, this);
|
|
226
|
+
return {
|
|
227
|
+
getAccounts: () => directSigner.getAccounts(),
|
|
228
|
+
signAmino: (signer, signDoc) => aminoSigner.signAmino(signer, signDoc),
|
|
229
|
+
signDirect: (signer, signDoc) => directSigner.signDirect(signer, signDoc)
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
getKey(chainId) {
|
|
233
|
+
return __async(this, null, function* () {
|
|
234
|
+
try {
|
|
235
|
+
yield this.ensureChainEnabled(chainId);
|
|
236
|
+
const wallet = yield this.getFirstWallet();
|
|
237
|
+
const signer = new import_cosmjs_v0_integration.ParaProtoSigner(this.paraWebClient, this.getBech32Prefix(chainId), wallet.id);
|
|
238
|
+
const [account] = yield signer.getAccounts();
|
|
239
|
+
if (!account) {
|
|
240
|
+
throw new Error(`No Cosmos accounts for chain ${chainId}`);
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
name: "Para Wallet",
|
|
244
|
+
algo: account.algo,
|
|
245
|
+
pubKey: account.pubkey,
|
|
246
|
+
address: (0, import_encoding.fromBech32)(account.address).data,
|
|
247
|
+
bech32Address: account.address,
|
|
248
|
+
isKeystone: false,
|
|
249
|
+
isNanoLedger: false
|
|
250
|
+
};
|
|
251
|
+
} catch (err) {
|
|
252
|
+
if (err instanceof Error) {
|
|
253
|
+
throw err;
|
|
254
|
+
}
|
|
255
|
+
throw new Error(`Failed to get key for chain ${chainId}`);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
getOfflineSignerOnlyAmino(chainId) {
|
|
260
|
+
void this.ensureChainEnabled(chainId);
|
|
261
|
+
const wallet = this.paraWebClient.getWalletsByType("COSMOS")[0];
|
|
262
|
+
if (!wallet) {
|
|
263
|
+
throw new Error("No Cosmos wallet for Amino signing");
|
|
264
|
+
}
|
|
265
|
+
return new import_cosmjs_v0_integration.ParaAminoSigner(this.paraWebClient, this.getBech32Prefix(chainId), wallet.id);
|
|
266
|
+
}
|
|
267
|
+
getOfflineSigner(chainId) {
|
|
268
|
+
void this.ensureChainEnabled(chainId);
|
|
269
|
+
return this.buildHybridSigner(chainId);
|
|
270
|
+
}
|
|
271
|
+
getOfflineSignerAuto(chainId) {
|
|
272
|
+
return __async(this, null, function* () {
|
|
273
|
+
void this.ensureChainEnabled(chainId);
|
|
274
|
+
return this.buildHybridSigner(chainId);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
signAmino(chainId, signer, signDoc, _signOptions) {
|
|
278
|
+
return __async(this, null, function* () {
|
|
279
|
+
yield this.ensureChainEnabled(chainId);
|
|
280
|
+
try {
|
|
281
|
+
const wallet = yield this.getFirstWallet();
|
|
282
|
+
const signerImpl = new import_cosmjs_v0_integration.ParaAminoSigner(this.paraWebClient, this.getBech32Prefix(chainId), wallet.id);
|
|
283
|
+
const response = yield signerImpl.signAmino(signer, signDoc);
|
|
284
|
+
return response;
|
|
285
|
+
} catch (err) {
|
|
286
|
+
throw new Error(`Amino signing failed: ${err instanceof Error ? err.message : "Unknown error"}`);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
signDirect(chainId, signer, signDoc, _signOptions) {
|
|
291
|
+
return __async(this, null, function* () {
|
|
292
|
+
var _a, _b;
|
|
293
|
+
yield this.ensureChainEnabled(chainId);
|
|
294
|
+
try {
|
|
295
|
+
const wallet = yield this.getFirstWallet();
|
|
296
|
+
const signerImpl = new import_cosmjs_v0_integration.ParaProtoSigner(this.paraWebClient, this.getBech32Prefix(chainId), wallet.id);
|
|
297
|
+
const convertedSignDoc = {
|
|
298
|
+
bodyBytes: (_a = signDoc.bodyBytes) != null ? _a : new Uint8Array(),
|
|
299
|
+
authInfoBytes: (_b = signDoc.authInfoBytes) != null ? _b : new Uint8Array(),
|
|
300
|
+
chainId: signDoc.chainId,
|
|
301
|
+
accountNumber: typeof signDoc.accountNumber === "bigint" ? signDoc.accountNumber : BigInt(signDoc.accountNumber)
|
|
302
|
+
};
|
|
303
|
+
const result = yield signerImpl.signDirect(signer, convertedSignDoc);
|
|
304
|
+
return {
|
|
305
|
+
signed: {
|
|
306
|
+
bodyBytes: result.signed.bodyBytes,
|
|
307
|
+
authInfoBytes: result.signed.authInfoBytes,
|
|
308
|
+
chainId: result.signed.chainId,
|
|
309
|
+
accountNumber: result.signed.accountNumber
|
|
310
|
+
},
|
|
311
|
+
signature: result.signature
|
|
312
|
+
};
|
|
313
|
+
} catch (err) {
|
|
314
|
+
throw new Error(`Direct signing failed: ${err instanceof Error ? err.message : "Unknown error"}`);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
signArbitrary(chainId, signer, data) {
|
|
319
|
+
return __async(this, null, function* () {
|
|
320
|
+
yield this.ensureChainEnabled(chainId);
|
|
321
|
+
const encodedData = typeof data === "string" ? Buffer.from(data, "utf-8").toString("base64") : Buffer.from(data).toString("base64");
|
|
322
|
+
const signDoc = {
|
|
323
|
+
chain_id: "",
|
|
324
|
+
account_number: "0",
|
|
325
|
+
sequence: "0",
|
|
326
|
+
fee: { gas: "0", amount: [] },
|
|
327
|
+
msgs: [
|
|
328
|
+
{
|
|
329
|
+
type: "sign/MsgSignData",
|
|
330
|
+
value: { signer, data: encodedData }
|
|
331
|
+
}
|
|
332
|
+
],
|
|
333
|
+
memo: ""
|
|
334
|
+
};
|
|
335
|
+
try {
|
|
336
|
+
const response = yield this.signAmino(chainId, signer, signDoc);
|
|
337
|
+
return response.signature;
|
|
338
|
+
} catch (err) {
|
|
339
|
+
throw new Error(`Arbitrary signing failed: ${err instanceof Error ? err.message : "Unknown error"}`);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
345
|
+
0 && (module.exports = {
|
|
346
|
+
ParaGrazConnector,
|
|
347
|
+
toArray
|
|
348
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var src_exports = {};
|
|
20
|
+
__export(src_exports, {
|
|
21
|
+
ParaGrazConnector: () => import_connector.ParaGrazConnector,
|
|
22
|
+
toArray: () => import_connector.toArray
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(src_exports);
|
|
25
|
+
var import_connector = require("./connector.js");
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
ParaGrazConnector,
|
|
29
|
+
toArray
|
|
30
|
+
});
|
|
@@ -72,7 +72,6 @@ class ParaGrazConnector {
|
|
|
72
72
|
}
|
|
73
73
|
this.events = config.events;
|
|
74
74
|
this.paraWebClient = config.paraWeb;
|
|
75
|
-
this.noModal = config.noModal;
|
|
76
75
|
}
|
|
77
76
|
ensureChainEnabled(chainId) {
|
|
78
77
|
return __async(this, null, function* () {
|
|
@@ -137,9 +136,6 @@ class ParaGrazConnector {
|
|
|
137
136
|
(_b = (_a = this.events) == null ? void 0 : _a.onEnabled) == null ? void 0 : _b.call(_a, chainIds, this);
|
|
138
137
|
return;
|
|
139
138
|
}
|
|
140
|
-
if (!this.noModal) {
|
|
141
|
-
throw new Error("Modal not supported. Use @getpara/graz-integration or set noModal: true");
|
|
142
|
-
}
|
|
143
139
|
yield this.waitForLogin();
|
|
144
140
|
yield this.waitForAccounts();
|
|
145
141
|
(_d = (_c = this.events) == null ? void 0 : _c.onEnabled) == null ? void 0 : _d.call(_c, chainIds, this);
|
|
@@ -156,7 +152,7 @@ class ParaGrazConnector {
|
|
|
156
152
|
return __async(this, null, function* () {
|
|
157
153
|
try {
|
|
158
154
|
yield this.paraWebClient.logout();
|
|
159
|
-
} catch (
|
|
155
|
+
} catch (e) {
|
|
160
156
|
throw new Error("Disconnect failed");
|
|
161
157
|
} finally {
|
|
162
158
|
this.enabledChainIds.clear();
|
|
@@ -168,7 +164,7 @@ class ParaGrazConnector {
|
|
|
168
164
|
try {
|
|
169
165
|
const [wallet] = yield this.waitForAccounts();
|
|
170
166
|
return wallet;
|
|
171
|
-
} catch (
|
|
167
|
+
} catch (e) {
|
|
172
168
|
throw new Error("No Para wallet available");
|
|
173
169
|
}
|
|
174
170
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Wallet, SignDoc as GrazSignDoc } from 'graz';
|
|
1
|
+
import { Wallet, SignDoc as GrazSignDoc, Key } from 'graz';
|
|
2
2
|
import { ParaWeb, Wallet as ParaWallet } from '@getpara/web-sdk';
|
|
3
3
|
import { DirectSignResponse, OfflineDirectSigner } from '@cosmjs/proto-signing';
|
|
4
4
|
import { AminoSignResponse, OfflineAminoSigner, StdSignature, StdSignDoc } from '@cosmjs/amino';
|
|
@@ -9,7 +9,6 @@ export type ParaGrazConnectorEvents = {
|
|
|
9
9
|
export interface ParaGrazConfig {
|
|
10
10
|
paraWeb: ParaWeb;
|
|
11
11
|
events?: ParaGrazConnectorEvents;
|
|
12
|
-
noModal?: boolean;
|
|
13
12
|
}
|
|
14
13
|
export declare function toArray<T>(v: T | T[]): T[];
|
|
15
14
|
export declare class ParaGrazConnector implements Omit<Wallet, 'experimentalSuggestChain'> {
|
|
@@ -18,7 +17,6 @@ export declare class ParaGrazConnector implements Omit<Wallet, 'experimentalSugg
|
|
|
18
17
|
protected paraWebClient: ParaWeb;
|
|
19
18
|
protected enabledChainIds: Set<string>;
|
|
20
19
|
protected readonly events?: ParaGrazConnectorEvents;
|
|
21
|
-
protected noModal?: boolean;
|
|
22
20
|
constructor(config: ParaGrazConfig, chains?: ChainInfo[] | null);
|
|
23
21
|
protected ensureChainEnabled(chainId: string): Promise<void>;
|
|
24
22
|
protected waitForLogin(timeoutMs?: number): Promise<void>;
|
|
@@ -31,15 +29,7 @@ export declare class ParaGrazConnector implements Omit<Wallet, 'experimentalSugg
|
|
|
31
29
|
getParaWebClient(): ParaWeb;
|
|
32
30
|
getConfig(): ParaGrazConfig;
|
|
33
31
|
protected buildHybridSigner(chainId: string): OfflineAminoSigner & OfflineDirectSigner;
|
|
34
|
-
getKey(chainId: string): Promise<
|
|
35
|
-
name: string;
|
|
36
|
-
algo: import("@cosmjs/amino").Algo;
|
|
37
|
-
pubKey: Uint8Array;
|
|
38
|
-
address: Uint8Array;
|
|
39
|
-
bech32Address: string;
|
|
40
|
-
isKeystone: boolean;
|
|
41
|
-
isNanoLedger: boolean;
|
|
42
|
-
}>;
|
|
32
|
+
getKey(chainId: string): Promise<Key>;
|
|
43
33
|
getOfflineSignerOnlyAmino(chainId: string): OfflineAminoSigner;
|
|
44
34
|
getOfflineSigner(chainId: string): OfflineAminoSigner & OfflineDirectSigner;
|
|
45
35
|
getOfflineSignerAuto(chainId: string): Promise<OfflineAminoSigner | OfflineDirectSigner>;
|
package/package.json
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/graz-connector",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"main": "dist/esm/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/types/index.d.ts",
|
|
10
|
+
"import": "./dist/esm/index.js",
|
|
11
|
+
"default": "./dist/esm/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
8
17
|
"scripts": {
|
|
9
|
-
"build": "rm -rf dist &&
|
|
10
|
-
"
|
|
11
|
-
"typegen": "tsc --emitDeclarationOnly"
|
|
18
|
+
"build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
|
|
19
|
+
"build:types": "rm -rf dist/types && tsc --module esnext --declarationDir dist/types --emitDeclarationOnly --declaration"
|
|
12
20
|
},
|
|
13
21
|
"dependencies": {
|
|
14
|
-
"@getpara/cosmjs-v0-integration": "
|
|
15
|
-
"@getpara/web-sdk": "
|
|
22
|
+
"@getpara/cosmjs-v0-integration": "2.0.0",
|
|
23
|
+
"@getpara/web-sdk": "2.0.0"
|
|
16
24
|
},
|
|
17
25
|
"devDependencies": {
|
|
18
26
|
"@cosmjs/amino": "^0.32.4",
|
|
19
27
|
"@cosmjs/encoding": "^0.32.4",
|
|
20
28
|
"@cosmjs/proto-signing": "^0.32.4",
|
|
29
|
+
"@cosmjs/stargate": "^0.32.4",
|
|
30
|
+
"@cosmjs/tendermint-rpc": "^0.32.4",
|
|
21
31
|
"@keplr-wallet/types": "^0.12.156",
|
|
22
32
|
"cosmjs-types": "^0.9.0",
|
|
23
|
-
"graz": "^0.
|
|
33
|
+
"graz": "^0.4.1",
|
|
24
34
|
"typescript": "5.1.6"
|
|
25
35
|
},
|
|
26
36
|
"peerDependencies": {
|
|
@@ -30,7 +40,8 @@
|
|
|
30
40
|
"@cosmjs/stargate": ">=0.32.4",
|
|
31
41
|
"@cosmjs/tendermint-rpc": ">=0.32.4",
|
|
32
42
|
"@keplr-wallet/types": ">=0.12.156",
|
|
33
|
-
"cosmjs-types": ">=0.
|
|
34
|
-
"graz": ">=0.
|
|
35
|
-
}
|
|
43
|
+
"cosmjs-types": ">=0.8.0",
|
|
44
|
+
"graz": ">=0.4.1"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "a64b6aa9b3c481a2d955022f621e495fb55e549e"
|
|
36
47
|
}
|