@injectivelabs/wallet-cosmos 0.0.2
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/README.md +108 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/strategy/strategy.d.ts +46 -0
- package/dist/cjs/strategy/strategy.d.ts.map +1 -0
- package/dist/cjs/strategy/strategy.js +231 -0
- package/dist/cjs/strategy/strategy.js.map +1 -0
- package/dist/cjs/wallet.d.ts +59 -0
- package/dist/cjs/wallet.d.ts.map +1 -0
- package/dist/cjs/wallet.js +293 -0
- package/dist/cjs/wallet.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/strategy/strategy.d.ts +46 -0
- package/dist/esm/strategy/strategy.d.ts.map +1 -0
- package/dist/esm/strategy/strategy.js +190 -0
- package/dist/esm/strategy/strategy.js.map +1 -0
- package/dist/esm/wallet.d.ts +59 -0
- package/dist/esm/wallet.d.ts.map +1 -0
- package/dist/esm/wallet.js +264 -0
- package/dist/esm/wallet.js.map +1 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# 🌟 Injective Protocol - Cosmos Wallet Strategy
|
|
2
|
+
|
|
3
|
+
<!-- TODO -->
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@injectivelabs/wallet-ts)
|
|
6
|
+
[](https://www.npmjs.com/package/@injectivelabs/wallet-ts)
|
|
7
|
+
[]()
|
|
8
|
+
|
|
9
|
+
_Package to use Cosmos Wallets on Injective via the wallet strategy._
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📚 Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @injectivelabs/wallet-cosmos
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 📖 Documentation
|
|
22
|
+
|
|
23
|
+
Injective's wallet packages are intended to make it easy for developers to choose exactly what wallets - and subsequent dependencies - they
|
|
24
|
+
want to include in their projects.
|
|
25
|
+
|
|
26
|
+
Regardless of which wallet package(s) you choose to use you must also have `@injectivelabs/wallet-core` and `@injectivelabs/wallet-base`
|
|
27
|
+
installed. These contain all of the types and core wallet functionality, with the separate wallet packages only providing the necessary
|
|
28
|
+
dependencies and implementations for their specific wallets.
|
|
29
|
+
|
|
30
|
+
Here's a brief example of how to use this package to send 1 INJ.:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { Wallet } from '@injectivelabs/wallet-base';
|
|
34
|
+
import { BaseWalletStrategy, MsgBroadcaster } from '@injectivelabs/wallet-core';
|
|
35
|
+
import { CosmosWalletStrategy } from '@injectivelabs/wallet-cosmos';
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const strategyArgs: WalletStrategyArguments = {
|
|
39
|
+
chainId: ChainId.Mainnet,
|
|
40
|
+
wallet: Wallet.Keplr,
|
|
41
|
+
strategies: {
|
|
42
|
+
[Wallet.Keplr]: new CosmosWalletStrategy({
|
|
43
|
+
chainId: ChainId.Mainnet
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
const walletStrategy = new BaseWalletStrategy(strategyArgs)
|
|
48
|
+
|
|
49
|
+
const msgBroadcaster = new MsgBroadcaster({
|
|
50
|
+
walletStrategy,
|
|
51
|
+
simulateTx: true,
|
|
52
|
+
network: Network.Mainnet,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const sendTX = async () => {
|
|
56
|
+
const injectiveAddress = 'someInjectiveAddress'
|
|
57
|
+
|
|
58
|
+
const message = MsgSend.fromJSON({
|
|
59
|
+
srcInjectiveAddress: injectiveAddress,
|
|
60
|
+
dstInjectiveAddress: injectiveAddress,
|
|
61
|
+
amount: {
|
|
62
|
+
amount: '1',
|
|
63
|
+
denom: 'inj',
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
return await msgBroadcaster.broadcast({ msgs: message })
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const result = await sendTX()
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Read more and find example usages on our [WalletStrategy Docs](https://docs.ts.injective.network/wallet/wallet-wallet-strategy)
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 📜 Contribution
|
|
78
|
+
|
|
79
|
+
**Contribution guides and practices will be available once there is a stable foundation of the whole package set within the `injective-ts` repo.**
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## ⛑ Support
|
|
84
|
+
|
|
85
|
+
Reach out to us at one of the following places!
|
|
86
|
+
|
|
87
|
+
- Website at <a href="https://injective.com" target="_blank">`injective.com`</a>
|
|
88
|
+
- Twitter at <a href="https://twitter.com/Injective_" target="_blank">`@Injective`</a>
|
|
89
|
+
- Discord at <a href="https://discord.com/invite/NK4qdbv" target="_blank">`Discord`</a>
|
|
90
|
+
- Telegram at <a href="https://t.me/joininjective" target="_blank">`Telegram`</a>
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 🔓 License
|
|
95
|
+
|
|
96
|
+
Copyright © 2021 - 2022 Injective Labs Inc. (https://injectivelabs.org/)
|
|
97
|
+
|
|
98
|
+
<a href="https://iili.io/mNneZN.md.png"><img src="https://iili.io/mNneZN.md.png" style="width: 300px; max-width: 100%; height: auto" />
|
|
99
|
+
|
|
100
|
+
Originally released by Injective Labs Inc. under: <br />
|
|
101
|
+
Apache License <br />
|
|
102
|
+
Version 2.0, January 2004 <br />
|
|
103
|
+
http://www.apache.org/licenses/
|
|
104
|
+
|
|
105
|
+
<p> </p>
|
|
106
|
+
<div align="center">
|
|
107
|
+
<sub><em>Powering the future of decentralized finance.</em></sub>
|
|
108
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CosmosWalletStrategy = exports.CosmosWallet = void 0;
|
|
4
|
+
var wallet_1 = require("./wallet");
|
|
5
|
+
Object.defineProperty(exports, "CosmosWallet", { enumerable: true, get: function () { return wallet_1.CosmosWallet; } });
|
|
6
|
+
var strategy_1 = require("./strategy/strategy");
|
|
7
|
+
Object.defineProperty(exports, "CosmosWalletStrategy", { enumerable: true, get: function () { return strategy_1.CosmosWalletStrategy; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAA9B,sGAAA,YAAY,OAAA;AACrB,gDAA0D;AAAjD,gHAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
|
|
2
|
+
import { ChainId, AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
|
|
3
|
+
import { Wallet, StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions } from '@injectivelabs/wallet-base';
|
|
4
|
+
import { CosmosWallet } from './../wallet';
|
|
5
|
+
export declare class CosmosWalletStrategy extends BaseConcreteStrategy implements ConcreteWalletStrategy {
|
|
6
|
+
wallet: Wallet;
|
|
7
|
+
private cosmosWallet;
|
|
8
|
+
constructor(args: {
|
|
9
|
+
chainId: ChainId;
|
|
10
|
+
endpoints?: {
|
|
11
|
+
rest: string;
|
|
12
|
+
rpc: string;
|
|
13
|
+
};
|
|
14
|
+
} & {
|
|
15
|
+
wallet: Wallet;
|
|
16
|
+
});
|
|
17
|
+
getWalletDeviceType(): Promise<WalletDeviceType>;
|
|
18
|
+
enable(): Promise<boolean>;
|
|
19
|
+
disconnect(): Promise<void>;
|
|
20
|
+
getAddresses(): Promise<string[]>;
|
|
21
|
+
getSessionOrConfirm(address: AccountAddress): Promise<string>;
|
|
22
|
+
sendEthereumTransaction(_transaction: unknown, _options: {
|
|
23
|
+
address: AccountAddress;
|
|
24
|
+
ethereumChainId: EthereumChainId;
|
|
25
|
+
}): Promise<string>;
|
|
26
|
+
sendTransaction(transaction: DirectSignResponse | TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
|
|
27
|
+
signAminoCosmosTransaction(transaction: {
|
|
28
|
+
address: string;
|
|
29
|
+
signDoc: StdSignDoc;
|
|
30
|
+
}): Promise<AminoSignResponse>;
|
|
31
|
+
signCosmosTransaction(transaction: {
|
|
32
|
+
txRaw: TxRaw;
|
|
33
|
+
accountNumber: number;
|
|
34
|
+
chainId: string;
|
|
35
|
+
address: AccountAddress;
|
|
36
|
+
}): Promise<DirectSignResponse>;
|
|
37
|
+
signEip712TypedData(_eip712TypedData: string, _address: AccountAddress): Promise<string>;
|
|
38
|
+
signArbitrary(signer: string, data: string | Uint8Array): Promise<string>;
|
|
39
|
+
getEthereumChainId(): Promise<string>;
|
|
40
|
+
getEthereumTransactionReceipt(_txHash: string): Promise<string>;
|
|
41
|
+
getPubKey(): Promise<string>;
|
|
42
|
+
onAccountChange(callback: (account: AccountAddress) => void): Promise<void>;
|
|
43
|
+
getCosmosWallet(chainId: ChainId): CosmosWallet;
|
|
44
|
+
private getCurrentCosmosWallet;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL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AC,UAAU,CAAC;IA4BhB,0BAA0B,CAAC,WAAW,EAAE;QAC5C,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,UAAU,CAAA;KACpB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAcxB,qBAAqB,CAAC,WAAW,EAAE;QACvC,KAAK,EAAE,KAAK,CAAA;QACZ,aAAa,EAAE,MAAM,CAAA;QACrB,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,cAAc,CAAA;KACxB;IAkBK,mBAAmB,CACvB,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC;IAUZ,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,UAAU,GACxB,OAAO,CAAC,MAAM,CAAC;IAeZ,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAYrC,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAY/D,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAO5B,eAAe,CACnB,QAAQ,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAC1C,OAAO,CAAC,IAAI,CAAC;IA0BT,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY;IAMtD,OAAO,CAAC,sBAAsB;CAgB/B"}
|
|
@@ -0,0 +1,231 @@
|
|
|
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.CosmosWalletStrategy = void 0;
|
|
13
|
+
/* eslint-disable class-methods-use-this */
|
|
14
|
+
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
15
|
+
const ts_types_1 = require("@injectivelabs/ts-types");
|
|
16
|
+
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
17
|
+
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
18
|
+
const wallet_1 = require("./../wallet");
|
|
19
|
+
const cosmosWallets = [wallet_base_1.Wallet.Leap, wallet_base_1.Wallet.Ninji, wallet_base_1.Wallet.Keplr, wallet_base_1.Wallet.OWallet];
|
|
20
|
+
class CosmosWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
21
|
+
constructor(args) {
|
|
22
|
+
super(args);
|
|
23
|
+
if (!cosmosWallets.includes(args.wallet)) {
|
|
24
|
+
throw new exceptions_1.CosmosWalletException(new Error(`Cosmos Wallet for ${args.wallet} is not supported.`));
|
|
25
|
+
}
|
|
26
|
+
this.wallet = args.wallet;
|
|
27
|
+
this.chainId = args.chainId || ts_types_1.CosmosChainId.Injective;
|
|
28
|
+
this.cosmosWallet = new wallet_1.CosmosWallet(args.chainId, args.wallet);
|
|
29
|
+
}
|
|
30
|
+
getWalletDeviceType() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const cosmosWallet = this.getCurrentCosmosWallet();
|
|
33
|
+
const key = yield cosmosWallet.getKey();
|
|
34
|
+
return key.isNanoLedger
|
|
35
|
+
? Promise.resolve(wallet_base_1.WalletDeviceType.Hardware)
|
|
36
|
+
: Promise.resolve(wallet_base_1.WalletDeviceType.Browser);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
enable() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const cosmosWallet = this.getCurrentCosmosWallet();
|
|
42
|
+
return yield cosmosWallet.checkChainIdSupport();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
disconnect() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const { wallet } = this;
|
|
48
|
+
if (this.listeners[wallet_base_1.WalletEventListener.AccountChange]) {
|
|
49
|
+
if (wallet === wallet_base_1.Wallet.Ninji) {
|
|
50
|
+
window.ninji.off('accountsChanged', this.listeners[wallet_base_1.WalletEventListener.AccountChange]);
|
|
51
|
+
}
|
|
52
|
+
if ([wallet_base_1.Wallet.Keplr, wallet_base_1.Wallet.OWallet].includes(wallet)) {
|
|
53
|
+
window.removeEventListener('keplr_keystorechange', this.listeners[wallet_base_1.WalletEventListener.AccountChange]);
|
|
54
|
+
}
|
|
55
|
+
if (wallet === wallet_base_1.Wallet.Leap) {
|
|
56
|
+
window.removeEventListener('leap_keystorechange', this.listeners[wallet_base_1.WalletEventListener.AccountChange]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
this.listeners = {};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
getAddresses() {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const cosmosWallet = this.getCurrentCosmosWallet();
|
|
65
|
+
try {
|
|
66
|
+
const accounts = yield cosmosWallet.getAccounts();
|
|
67
|
+
return accounts.map((account) => account.address);
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
throw new exceptions_1.CosmosWalletException(new Error(e.message), {
|
|
71
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
72
|
+
context: wallet_base_1.WalletAction.GetAccounts,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
getSessionOrConfirm(address) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
// eslint-disable-next-line class-methods-use-this
|
|
83
|
+
sendEthereumTransaction(_transaction, _options) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const { wallet } = this;
|
|
86
|
+
throw new exceptions_1.CosmosWalletException(new Error(`sendEthereumTransaction is not supported. ${wallet} only supports sending cosmos transactions`), {
|
|
87
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
88
|
+
context: wallet_base_1.WalletAction.SendEthereumTransaction,
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
sendTransaction(transaction, options) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const cosmosWallet = this.getCurrentCosmosWallet();
|
|
95
|
+
const txRaw = (0, sdk_ts_1.createTxRawFromSigResponse)(transaction);
|
|
96
|
+
if (!options.endpoints) {
|
|
97
|
+
throw new exceptions_1.CosmosWalletException(new Error('You have to pass endpoints within the options to broadcast transaction'));
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const txHash = yield cosmosWallet.broadcastTx(txRaw);
|
|
101
|
+
return yield (0, sdk_ts_1.waitTxBroadcasted)(txHash, options);
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
if (e instanceof exceptions_1.TransactionException) {
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
throw new exceptions_1.TransactionException(new Error(e.message), {
|
|
108
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
109
|
+
context: wallet_base_1.WalletAction.SendTransaction,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
signAminoCosmosTransaction(transaction) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
const cosmosWallet = this.getCurrentCosmosWallet();
|
|
117
|
+
const signer = yield cosmosWallet.getOfflineAminoSigner();
|
|
118
|
+
try {
|
|
119
|
+
return yield signer.signAmino(transaction.address, transaction.signDoc);
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
throw new exceptions_1.CosmosWalletException(new Error(e.message), {
|
|
123
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
124
|
+
context: wallet_base_1.WalletAction.SignTransaction,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
signCosmosTransaction(transaction) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const cosmosWallet = this.getCurrentCosmosWallet();
|
|
132
|
+
const signer = yield cosmosWallet.getOfflineSigner();
|
|
133
|
+
const signDoc = (0, sdk_ts_1.createSignDocFromTransaction)(transaction);
|
|
134
|
+
try {
|
|
135
|
+
return yield signer.signDirect(transaction.address, (0, wallet_base_1.createCosmosSignDocFromSignDoc)(signDoc));
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
throw new exceptions_1.CosmosWalletException(new Error(e.message), {
|
|
139
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
140
|
+
context: wallet_base_1.WalletAction.SendTransaction,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
signEip712TypedData(_eip712TypedData, _address) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
throw new exceptions_1.CosmosWalletException(new Error('This wallet does not support signing Ethereum transactions'), {
|
|
148
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
149
|
+
context: wallet_base_1.WalletAction.SendTransaction,
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
signArbitrary(signer, data) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const cosmosWallet = this.getCurrentCosmosWallet();
|
|
156
|
+
try {
|
|
157
|
+
const signature = yield cosmosWallet.signArbitrary({ data, signer });
|
|
158
|
+
return signature;
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
throw new exceptions_1.CosmosWalletException(new Error(e.message), {
|
|
162
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
163
|
+
context: wallet_base_1.WalletAction.SignArbitrary,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
getEthereumChainId() {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
const { wallet } = this;
|
|
171
|
+
throw new exceptions_1.CosmosWalletException(new Error(`getEthereumChainId is not supported on ${wallet}`), {
|
|
172
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
173
|
+
context: wallet_base_1.WalletAction.GetChainId,
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
getEthereumTransactionReceipt(_txHash) {
|
|
178
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
const { wallet } = this;
|
|
180
|
+
throw new exceptions_1.CosmosWalletException(new Error(`getEthereumTransactionReceipt is not supported on ${wallet}`), {
|
|
181
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
182
|
+
context: wallet_base_1.WalletAction.GetEthereumTransactionReceipt,
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
getPubKey() {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
const cosmosWallet = this.getCurrentCosmosWallet();
|
|
189
|
+
const key = yield cosmosWallet.getKey();
|
|
190
|
+
return Buffer.from(key.pubKey).toString('base64');
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
onAccountChange(callback) {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
const { wallet } = this;
|
|
196
|
+
const listener = () => __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
const [account] = yield this.getAddresses();
|
|
198
|
+
callback(account);
|
|
199
|
+
});
|
|
200
|
+
this.listeners = {
|
|
201
|
+
[wallet_base_1.WalletEventListener.AccountChange]: listener,
|
|
202
|
+
};
|
|
203
|
+
if (wallet === wallet_base_1.Wallet.Ninji) {
|
|
204
|
+
window.ninji.on('accountsChanged', listener);
|
|
205
|
+
}
|
|
206
|
+
if ([wallet_base_1.Wallet.Keplr, wallet_base_1.Wallet.OWallet].includes(wallet)) {
|
|
207
|
+
window.addEventListener('keplr_keystorechange', listener);
|
|
208
|
+
}
|
|
209
|
+
if (wallet === wallet_base_1.Wallet.Leap) {
|
|
210
|
+
window.addEventListener('leap_keystorechange', listener);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
getCosmosWallet(chainId) {
|
|
215
|
+
const { wallet, cosmosWallet } = this;
|
|
216
|
+
return !cosmosWallet ? new wallet_1.CosmosWallet(chainId, wallet) : cosmosWallet;
|
|
217
|
+
}
|
|
218
|
+
getCurrentCosmosWallet() {
|
|
219
|
+
const { wallet, cosmosWallet } = this;
|
|
220
|
+
if (!cosmosWallet) {
|
|
221
|
+
throw new exceptions_1.CosmosWalletException(new Error(`Please install the ${wallet} wallet extension`), {
|
|
222
|
+
code: exceptions_1.UnspecifiedErrorCode,
|
|
223
|
+
type: exceptions_1.ErrorType.WalletNotInstalledError,
|
|
224
|
+
context: wallet_base_1.WalletAction.SignTransaction,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return cosmosWallet;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
exports.CosmosWalletStrategy = CosmosWalletStrategy;
|
|
231
|
+
//# sourceMappingURL=strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../src/strategy/strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2C;AAC3C,kDAQ8B;AAC9B,sDAKgC;AAChC,0DAKkC;AAClC,4DAUmC;AACnC,wCAA0C;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QAErC,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,kCAAqB,CAC7B,IAAI,KAAK,CAAC,sBAAsB,MAAM,mBAAmB,CAAC,EAC1D;gBACE,IAAI,EAAE,iCAAoB;gBAC1B,IAAI,EAAE,sBAAS,CAAC,uBAAuB;gBACvC,OAAO,EAAE,0BAAY,CAAC,eAAe;aACtC,CACF,CAAA;QACH,CAAC;QAED,OAAO,YAA4B,CAAA;IACrC,CAAC;CACF;AAtSD,oDAsSC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Keplr, StdSignDoc, AminoSignResponse, OfflineAminoSigner } from '@keplr-wallet/types';
|
|
2
|
+
import { ChainId, CosmosChainId, TestnetCosmosChainId } from '@injectivelabs/ts-types';
|
|
3
|
+
import { Wallet } from '@injectivelabs/wallet-base';
|
|
4
|
+
import { CosmosTxV1Beta1Tx } from '@injectivelabs/sdk-ts';
|
|
5
|
+
import { StdFee } from '@cosmjs/stargate';
|
|
6
|
+
import type { EncodeObject, OfflineDirectSigner } from '@cosmjs/proto-signing';
|
|
7
|
+
export declare class CosmosWallet {
|
|
8
|
+
wallet: Wallet;
|
|
9
|
+
private chainId;
|
|
10
|
+
constructor(chainId: CosmosChainId | TestnetCosmosChainId | ChainId, wallet: Wallet);
|
|
11
|
+
isChainIdSupported(chainId: CosmosChainId): Promise<boolean>;
|
|
12
|
+
getCosmosWallet(): Promise<Keplr>;
|
|
13
|
+
chainNotSupported(): Promise<void>;
|
|
14
|
+
getAccounts(): Promise<readonly import("@keplr-wallet/types").AccountData[]>;
|
|
15
|
+
getKey(): Promise<{
|
|
16
|
+
name: string;
|
|
17
|
+
algo: string;
|
|
18
|
+
isNanoLedger: boolean;
|
|
19
|
+
pubKey: Uint8Array;
|
|
20
|
+
address: Uint8Array;
|
|
21
|
+
bech32Address: string;
|
|
22
|
+
}>;
|
|
23
|
+
getOfflineSigner(): Promise<OfflineDirectSigner>;
|
|
24
|
+
getOfflineAminoSigner(): Promise<OfflineAminoSigner>;
|
|
25
|
+
/**
|
|
26
|
+
* This method is used to broadcast a transaction to the network.
|
|
27
|
+
* Since it uses the `Sync` mode, it will not wait for the transaction to be included in a block,
|
|
28
|
+
* so we have to make sure the transaction is included in a block after its broadcasted
|
|
29
|
+
*
|
|
30
|
+
* @param txRaw - raw transaction to broadcast
|
|
31
|
+
* @returns tx hash
|
|
32
|
+
*/
|
|
33
|
+
broadcastTx(txRaw: CosmosTxV1Beta1Tx.TxRaw): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* This method is used to broadcast a transaction to the network.
|
|
36
|
+
* Since it uses the `Block` mode, and it will wait for the transaction to be included in a block,
|
|
37
|
+
*
|
|
38
|
+
* @param txRaw - raw transaction to broadcast
|
|
39
|
+
* @returns tx hash
|
|
40
|
+
*/
|
|
41
|
+
broadcastTxBlock(txRaw: CosmosTxV1Beta1Tx.TxRaw): Promise<string>;
|
|
42
|
+
signAndBroadcastAminoUsingCosmjs(messages: EncodeObject[], stdFee: StdFee, endpoints: {
|
|
43
|
+
rest: string;
|
|
44
|
+
rpc: string;
|
|
45
|
+
}): Promise<import("@cosmjs/stargate").DeliverTxResponse>;
|
|
46
|
+
signArbitrary({ data, signer, }: {
|
|
47
|
+
signer: string;
|
|
48
|
+
data: string | Uint8Array;
|
|
49
|
+
}): Promise<string>;
|
|
50
|
+
signEIP712CosmosTx({ eip712, signDoc, }: {
|
|
51
|
+
eip712: any;
|
|
52
|
+
signDoc: StdSignDoc;
|
|
53
|
+
}): Promise<AminoSignResponse>;
|
|
54
|
+
checkChainIdSupport(): Promise<boolean>;
|
|
55
|
+
private getCosmos;
|
|
56
|
+
disableGasCheck(): Promise<void>;
|
|
57
|
+
enableGasCheck(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/wallet.ts"],"names":[],"m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