@injectivelabs/wallet-cosmostation 1.16.38-alpha.6 → 1.16.38
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/index.d.ts +3 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/package.json +2 -2
- package/dist/cjs/strategy/strategy.d.ts +43 -0
- package/dist/cjs/strategy/strategy.js +205 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +8 -0
- package/dist/cjs/wallet.d.ts +8 -0
- package/dist/cjs/wallet.js +44 -0
- package/dist/esm/index.d.ts +3 -64
- package/dist/esm/index.js +3 -263
- package/dist/esm/package.json +2 -2
- package/dist/esm/strategy/strategy.d.ts +43 -0
- package/dist/esm/strategy/strategy.js +201 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +4 -0
- package/dist/esm/wallet.d.ts +8 -0
- package/dist/esm/wallet.js +40 -0
- package/package.json +50 -42
- package/dist/cjs/index.cjs +0 -265
- package/dist/cjs/index.d.cts +0 -64
package/package.json
CHANGED
|
@@ -1,70 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-cosmostation",
|
|
3
|
-
"version": "1.16.38-alpha.6",
|
|
4
3
|
"description": "Cosmostation strategy for use with @injectivelabs/wallet-core.",
|
|
5
|
-
"
|
|
4
|
+
"version": "1.16.38",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"type": "module",
|
|
6
7
|
"author": {
|
|
7
8
|
"name": "InjectiveLabs",
|
|
8
9
|
"email": "admin@injectivelabs.org"
|
|
9
10
|
},
|
|
10
|
-
"
|
|
11
|
-
"
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"types": "dist/cjs/index.d.ts",
|
|
13
|
+
"main": "dist/cjs/index.js",
|
|
14
|
+
"module": "dist/esm/index.js",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"_moduleAliases": {
|
|
19
|
+
"~wallet-cosmostation": "dist"
|
|
20
|
+
},
|
|
12
21
|
"exports": {
|
|
13
22
|
".": {
|
|
14
23
|
"react-native": {
|
|
15
24
|
"import": "./dist/esm/index.js",
|
|
16
|
-
"require": "./dist/cjs/index.
|
|
17
|
-
"types": "./dist/cjs/index.d.
|
|
18
|
-
"default": "./dist/cjs/index.
|
|
25
|
+
"require": "./dist/cjs/index.js",
|
|
26
|
+
"types": "./dist/cjs/index.d.ts",
|
|
27
|
+
"default": "./dist/cjs/index.js"
|
|
19
28
|
},
|
|
20
29
|
"require": {
|
|
21
|
-
"types": "./dist/cjs/index.d.
|
|
22
|
-
"default": "./dist/cjs/index.
|
|
30
|
+
"types": "./dist/cjs/index.d.ts",
|
|
31
|
+
"default": "./dist/cjs/index.js"
|
|
23
32
|
},
|
|
24
33
|
"import": {
|
|
25
34
|
"types": "./dist/esm/index.d.ts",
|
|
26
35
|
"default": "./dist/esm/index.js"
|
|
27
36
|
},
|
|
28
37
|
"default": {
|
|
29
|
-
"types": "./dist/cjs/index.d.
|
|
30
|
-
"default": "./dist/cjs/index.
|
|
38
|
+
"types": "./dist/cjs/index.d.ts",
|
|
39
|
+
"default": "./dist/cjs/index.js"
|
|
31
40
|
}
|
|
32
41
|
}
|
|
33
42
|
},
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "pnpm build:cjs && pnpm build:esm && pnpm build:post",
|
|
45
|
+
"build:cjs": "tsc --build --force tsconfig.build.json",
|
|
46
|
+
"build:esm": "tsc --build --force tsconfig.build.esm.json",
|
|
47
|
+
"build:watch": "tsc --build -w tsconfig.build.json && tsc -w --build tsconfig.build.esm.json && pnpm build:post",
|
|
48
|
+
"build:post": "shx cp ../../../etc/stub/package.json.stub dist/cjs/package.json && shx cp ../../../etc/stub/package.esm.json.stub dist/esm/package.json",
|
|
49
|
+
"clean": "tsc --build tsconfig.build.json --clean && tsc --build tsconfig.build.esm.json --clean && shx rm -rf coverage *.log junit.xml dist && jest --clearCache && shx mkdir -p dist",
|
|
50
|
+
"test": "jest",
|
|
51
|
+
"test:watch": "jest --watch",
|
|
52
|
+
"test:ci": "jest --coverage --ci --reporters='jest-junit'",
|
|
53
|
+
"coverage": "jest --coverage",
|
|
54
|
+
"coverage:show": "live-server coverage",
|
|
55
|
+
"dev": "ts-node -r tsconfig-paths/register src/index.ts",
|
|
56
|
+
"start": "node dist/index.js"
|
|
57
|
+
},
|
|
40
58
|
"dependencies": {
|
|
41
|
-
"@cosmjs/proto-signing": "^0.
|
|
59
|
+
"@cosmjs/proto-signing": "^0.32.3",
|
|
42
60
|
"@cosmostation/cosmos-client": "^0.0.5",
|
|
43
61
|
"@cosmostation/extension-client": "^0.1.15",
|
|
44
|
-
"@injectivelabs/exceptions": "1.16.38
|
|
45
|
-
"@injectivelabs/ts
|
|
46
|
-
"@injectivelabs/
|
|
47
|
-
"@injectivelabs/
|
|
62
|
+
"@injectivelabs/exceptions": "1.16.38",
|
|
63
|
+
"@injectivelabs/sdk-ts": "1.16.38",
|
|
64
|
+
"@injectivelabs/ts-types": "1.16.38",
|
|
65
|
+
"@injectivelabs/utils": "1.16.38",
|
|
66
|
+
"@injectivelabs/wallet-base": "1.16.38",
|
|
67
|
+
"@walletconnect/ethereum-provider": "2.18.1"
|
|
48
68
|
},
|
|
49
|
-
"
|
|
50
|
-
"
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"shx": "^0.3.4"
|
|
51
71
|
},
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"build:fast": "tsdown",
|
|
58
|
-
"build:watch": "tsdown --watch",
|
|
59
|
-
"clean": "shx rm -rf dist coverage *.log junit.xml && shx mkdir -p dist",
|
|
60
|
-
"type-check": "tsc --noEmit",
|
|
61
|
-
"test": "vitest",
|
|
62
|
-
"test:watch": "vitest --watch",
|
|
63
|
-
"test:ci": "vitest run --coverage --reporter=verbose",
|
|
64
|
-
"coverage": "vitest run --coverage",
|
|
65
|
-
"coverage:show": "live-server coverage",
|
|
66
|
-
"dev": "ts-node -r tsconfig-paths/register src/index.ts",
|
|
67
|
-
"start": "node dist/index.js",
|
|
68
|
-
"lint": "eslint . --ext .ts,.js"
|
|
72
|
+
"gitHead": "c67633f9ba4c5efb2c969c3df815d54995459966",
|
|
73
|
+
"typedoc": {
|
|
74
|
+
"entryPoint": "./src/index.ts",
|
|
75
|
+
"readmeFile": "./README.md",
|
|
76
|
+
"displayName": "wallet-cosmostation API Documentation"
|
|
69
77
|
}
|
|
70
|
-
}
|
|
78
|
+
}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
let __cosmostation_extension_client = require("@cosmostation/extension-client");
|
|
2
|
-
let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
|
|
3
|
-
let __cosmjs_proto_signing = require("@cosmjs/proto-signing");
|
|
4
|
-
let __injectivelabs_ts_types = require("@injectivelabs/ts-types");
|
|
5
|
-
let __injectivelabs_sdk_ts = require("@injectivelabs/sdk-ts");
|
|
6
|
-
let __cosmostation_cosmos_client = require("@cosmostation/cosmos-client");
|
|
7
|
-
let __cosmostation_extension_client_cosmos_js = require("@cosmostation/extension-client/cosmos.js");
|
|
8
|
-
let __injectivelabs_sdk_ts_core_tx = require("@injectivelabs/sdk-ts/core/tx");
|
|
9
|
-
let __injectivelabs_sdk_ts_utils = require("@injectivelabs/sdk-ts/utils");
|
|
10
|
-
let __injectivelabs_wallet_base = require("@injectivelabs/wallet-base");
|
|
11
|
-
|
|
12
|
-
//#region src/utils/index.ts
|
|
13
|
-
const isCosmosStationWalletInstalled = () => {
|
|
14
|
-
return (typeof window !== "undefined" ? window : {}).cosmostation !== void 0;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region \0@oxc-project+runtime@0.98.0/helpers/typeof.js
|
|
19
|
-
function _typeof(o) {
|
|
20
|
-
"@babel/helpers - typeof";
|
|
21
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
22
|
-
return typeof o$1;
|
|
23
|
-
} : function(o$1) {
|
|
24
|
-
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
25
|
-
}, _typeof(o);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region \0@oxc-project+runtime@0.98.0/helpers/toPrimitive.js
|
|
30
|
-
function toPrimitive(t, r) {
|
|
31
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
32
|
-
var e = t[Symbol.toPrimitive];
|
|
33
|
-
if (void 0 !== e) {
|
|
34
|
-
var i = e.call(t, r || "default");
|
|
35
|
-
if ("object" != _typeof(i)) return i;
|
|
36
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
37
|
-
}
|
|
38
|
-
return ("string" === r ? String : Number)(t);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region \0@oxc-project+runtime@0.98.0/helpers/toPropertyKey.js
|
|
43
|
-
function toPropertyKey(t) {
|
|
44
|
-
var i = toPrimitive(t, "string");
|
|
45
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.98.0/helpers/defineProperty.js
|
|
50
|
-
function _defineProperty(e, r, t) {
|
|
51
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
52
|
-
value: t,
|
|
53
|
-
enumerable: !0,
|
|
54
|
-
configurable: !0,
|
|
55
|
-
writable: !0
|
|
56
|
-
}) : e[r] = t, e;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/wallet.ts
|
|
61
|
-
var CosmostationWallet = class CosmostationWallet {
|
|
62
|
-
constructor(chainId) {
|
|
63
|
-
_defineProperty(this, "chainId", void 0);
|
|
64
|
-
this.chainId = chainId;
|
|
65
|
-
}
|
|
66
|
-
static async isChainIdSupported(chainId) {
|
|
67
|
-
return new CosmostationWallet(chainId).checkChainIdSupport();
|
|
68
|
-
}
|
|
69
|
-
async checkChainIdSupport() {
|
|
70
|
-
const { chainId: actualChainId } = this;
|
|
71
|
-
const provider = await this.getCosmostationWallet();
|
|
72
|
-
const chainName = actualChainId.split("-");
|
|
73
|
-
try {
|
|
74
|
-
return !!(await provider.getSupportedChainIds()).official.find((chainId) => chainId === actualChainId);
|
|
75
|
-
} catch (_unused) {
|
|
76
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error(`Cosmostation doesn't support ${chainName[0] || actualChainId} network. Please use another Cosmos wallet`));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async getCosmostationWallet() {
|
|
80
|
-
try {
|
|
81
|
-
return await (0, __cosmostation_extension_client.cosmos)();
|
|
82
|
-
} catch (e) {
|
|
83
|
-
if (e instanceof __cosmostation_extension_client.InstallError) throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("Please install the Cosmostation extension"), {
|
|
84
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
85
|
-
type: __injectivelabs_exceptions.ErrorType.WalletNotInstalledError
|
|
86
|
-
});
|
|
87
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(new Error(e.message), { code: __injectivelabs_exceptions.UnspecifiedErrorCode });
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/strategy/strategy.ts
|
|
94
|
-
const getChainNameFromChainId = (chainId) => {
|
|
95
|
-
const [chainName] = chainId.split("-");
|
|
96
|
-
if (chainName.includes("cosmoshub")) return "cosmos";
|
|
97
|
-
if (chainName.includes("core")) return "persistence";
|
|
98
|
-
if (chainName.includes("evmos")) return "evmos";
|
|
99
|
-
if (chainId.includes("ssc") || chainId.includes("fetch")) return chainId;
|
|
100
|
-
return chainName;
|
|
101
|
-
};
|
|
102
|
-
var Cosmostation = class extends __injectivelabs_wallet_base.BaseConcreteStrategy {
|
|
103
|
-
constructor(args) {
|
|
104
|
-
super(args);
|
|
105
|
-
_defineProperty(this, "cosmostationWallet", void 0);
|
|
106
|
-
_defineProperty(this, "chainName", void 0);
|
|
107
|
-
this.chainId = args.chainId || __injectivelabs_ts_types.CosmosChainId.Injective;
|
|
108
|
-
this.chainName = getChainNameFromChainId(this.chainId);
|
|
109
|
-
}
|
|
110
|
-
async getWalletDeviceType() {
|
|
111
|
-
return Promise.resolve(__injectivelabs_wallet_base.WalletDeviceType.Browser);
|
|
112
|
-
}
|
|
113
|
-
async enable() {
|
|
114
|
-
return Promise.resolve(true);
|
|
115
|
-
}
|
|
116
|
-
async getAddresses() {
|
|
117
|
-
const cosmostationWallet = await this.getCosmostationWallet();
|
|
118
|
-
try {
|
|
119
|
-
return [(await cosmostationWallet.requestAccount(this.chainName)).address];
|
|
120
|
-
} catch (e) {
|
|
121
|
-
if (e.code === 4001) throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("The user rejected the request"), {
|
|
122
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
123
|
-
context: __injectivelabs_wallet_base.WalletAction.GetAccounts
|
|
124
|
-
});
|
|
125
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(new Error(e.message), {
|
|
126
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
127
|
-
context: __injectivelabs_wallet_base.WalletAction.GetAccounts
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
async getAddressesInfo() {
|
|
132
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("getAddressesInfo is not implemented"), {
|
|
133
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
134
|
-
context: __injectivelabs_wallet_base.WalletAction.GetAccounts
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
async getSessionOrConfirm(address) {
|
|
138
|
-
return Promise.resolve(`0x${(0, __injectivelabs_sdk_ts_utils.uint8ArrayToHex)((0, __injectivelabs_sdk_ts_utils.stringToUint8Array)(`Confirmation for ${address} at time: ${Date.now()}`))}`);
|
|
139
|
-
}
|
|
140
|
-
async sendEvmTransaction(_transaction, _options) {
|
|
141
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("sendEvmTransaction is not supported. Cosmostation only supports sending cosmos transactions"), {
|
|
142
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
143
|
-
context: __injectivelabs_wallet_base.WalletAction.SendEvmTransaction
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
async sendTransaction(transaction, _options) {
|
|
147
|
-
const cosmostationWallet = await this.getCosmostationWallet();
|
|
148
|
-
const txRaw = (0, __injectivelabs_sdk_ts_core_tx.createTxRawFromSigResponse)(transaction);
|
|
149
|
-
try {
|
|
150
|
-
const response = await cosmostationWallet.sendTransaction(this.chainName, __injectivelabs_sdk_ts.CosmosTxV1Beta1TxPb.TxRaw.toBinary(txRaw), __cosmostation_extension_client_cosmos_js.SEND_TRANSACTION_MODE.SYNC);
|
|
151
|
-
return {
|
|
152
|
-
...response.tx_response,
|
|
153
|
-
gasUsed: parseInt(response.tx_response.gas_used || "0", 10),
|
|
154
|
-
gasWanted: parseInt(response.tx_response.gas_wanted || "0", 10),
|
|
155
|
-
height: parseInt(response.tx_response.height || "0", 10),
|
|
156
|
-
txHash: response.tx_response.txhash,
|
|
157
|
-
rawLog: response.tx_response.raw_log
|
|
158
|
-
};
|
|
159
|
-
} catch (e) {
|
|
160
|
-
if (e instanceof __injectivelabs_exceptions.TransactionException) throw e;
|
|
161
|
-
throw new __injectivelabs_exceptions.TransactionException(new Error(e.message), {
|
|
162
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
163
|
-
context: __injectivelabs_wallet_base.WalletAction.SendTransaction
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
async signAminoCosmosTransaction(_transaction) {
|
|
168
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("This wallet does not support signing using amino"), {
|
|
169
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
170
|
-
context: __injectivelabs_wallet_base.WalletAction.SendTransaction
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
async signCosmosTransaction(transaction) {
|
|
174
|
-
const { chainId } = this;
|
|
175
|
-
const cosmostationWallet = await this.getCosmostationWallet();
|
|
176
|
-
const signDoc = (0, __injectivelabs_sdk_ts_core_tx.createSignDocFromTransaction)(transaction);
|
|
177
|
-
try {
|
|
178
|
-
const signDirectResponse = await cosmostationWallet.signDirect(this.chainName, {
|
|
179
|
-
chain_id: chainId,
|
|
180
|
-
body_bytes: signDoc.bodyBytes,
|
|
181
|
-
auth_info_bytes: signDoc.authInfoBytes,
|
|
182
|
-
account_number: signDoc.accountNumber.toString()
|
|
183
|
-
}, {
|
|
184
|
-
fee: true,
|
|
185
|
-
memo: true
|
|
186
|
-
});
|
|
187
|
-
return {
|
|
188
|
-
signed: (0, __cosmjs_proto_signing.makeSignDoc)(signDirectResponse.signed_doc.body_bytes, signDirectResponse.signed_doc.auth_info_bytes, signDirectResponse.signed_doc.chain_id, parseInt(signDirectResponse.signed_doc.account_number, 10)),
|
|
189
|
-
signature: { signature: signDirectResponse.signature }
|
|
190
|
-
};
|
|
191
|
-
} catch (e) {
|
|
192
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(new Error(e.message), {
|
|
193
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
194
|
-
context: __injectivelabs_wallet_base.WalletAction.SendTransaction
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
async getPubKey() {
|
|
199
|
-
const cosmostationWallet = await this.getCosmostationWallet();
|
|
200
|
-
try {
|
|
201
|
-
return (0, __injectivelabs_sdk_ts_utils.uint8ArrayToBase64)((await cosmostationWallet.requestAccount(this.chainName)).publicKey);
|
|
202
|
-
} catch (e) {
|
|
203
|
-
if (e.code === 4001) throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("The user rejected the request"), {
|
|
204
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
205
|
-
context: __injectivelabs_wallet_base.WalletAction.GetAccounts
|
|
206
|
-
});
|
|
207
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(new Error(e.message), {
|
|
208
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
209
|
-
context: __injectivelabs_wallet_base.WalletAction.GetAccounts
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
async signEip712TypedData(_eip712TypedData, _address) {
|
|
214
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("This wallet does not support signing Evm transactions"), {
|
|
215
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
216
|
-
context: __injectivelabs_wallet_base.WalletAction.SendTransaction
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
async signArbitrary(signer, data) {
|
|
220
|
-
try {
|
|
221
|
-
return (await (await this.getCosmostationWallet()).signMessage(this.chainName, signer, (0, __injectivelabs_sdk_ts_utils.toUtf8)(data))).signature;
|
|
222
|
-
} catch (e) {
|
|
223
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(new Error(e.message), {
|
|
224
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
225
|
-
context: __injectivelabs_wallet_base.WalletAction.SignArbitrary
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
async getEthereumChainId() {
|
|
230
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("getEthereumChainId is not supported on Cosmostation"), {
|
|
231
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
232
|
-
context: __injectivelabs_wallet_base.WalletAction.GetChainId
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
async getEvmTransactionReceipt(_txHash) {
|
|
236
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("getEvmTransactionReceipt is not supported on Cosmostation"), {
|
|
237
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
238
|
-
type: __injectivelabs_exceptions.ErrorType.WalletError,
|
|
239
|
-
context: __injectivelabs_wallet_base.WalletAction.GetEvmTransactionReceipt
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
async getOfflineSigner(chainId) {
|
|
243
|
-
return await (0, __cosmostation_cosmos_client.getOfflineSigner)(chainId);
|
|
244
|
-
}
|
|
245
|
-
async getCosmostationWallet() {
|
|
246
|
-
if (this.cosmostationWallet) return this.cosmostationWallet;
|
|
247
|
-
const cosmostationWallet = new CosmostationWallet(this.chainId);
|
|
248
|
-
try {
|
|
249
|
-
const provider = await cosmostationWallet.getCosmostationWallet();
|
|
250
|
-
this.cosmostationWallet = provider;
|
|
251
|
-
return provider;
|
|
252
|
-
} catch (e) {
|
|
253
|
-
if (e instanceof __cosmostation_extension_client.InstallError) throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("Please install the Cosmostation extension"), {
|
|
254
|
-
code: __injectivelabs_exceptions.UnspecifiedErrorCode,
|
|
255
|
-
type: __injectivelabs_exceptions.ErrorType.WalletNotInstalledError
|
|
256
|
-
});
|
|
257
|
-
throw new __injectivelabs_exceptions.CosmosWalletException(new Error(e.message), { code: __injectivelabs_exceptions.UnspecifiedErrorCode });
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
//#endregion
|
|
263
|
-
exports.CosmostationWallet = CosmostationWallet;
|
|
264
|
-
exports.CosmostationWalletStrategy = Cosmostation;
|
|
265
|
-
exports.isCosmosStationWalletInstalled = isCosmosStationWalletInstalled;
|
package/dist/cjs/index.d.cts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import * as _cosmostation_extension_client_cosmos0 from "@cosmostation/extension-client/cosmos";
|
|
2
|
-
import { AccountAddress, ChainId, CosmosChainId, EvmChainId, TestnetCosmosChainId } from "@injectivelabs/ts-types";
|
|
3
|
-
import { CosmosTxV1Beta1TxPb } from "@injectivelabs/sdk-ts";
|
|
4
|
-
import { BaseConcreteStrategy, ConcreteWalletStrategy, StdSignDoc, WalletDeviceType } from "@injectivelabs/wallet-base";
|
|
5
|
-
import { OfflineSigner } from "@cosmjs/proto-signing";
|
|
6
|
-
import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
|
|
7
|
-
import { AminoSignResponse, DirectSignResponse } from "@injectivelabs/sdk-ts/types";
|
|
8
|
-
|
|
9
|
-
//#region src/utils/index.d.ts
|
|
10
|
-
declare const isCosmosStationWalletInstalled: () => boolean;
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/wallet.d.ts
|
|
13
|
-
declare class CosmostationWallet {
|
|
14
|
-
private chainId;
|
|
15
|
-
constructor(chainId: CosmosChainId | TestnetCosmosChainId | ChainId);
|
|
16
|
-
static isChainIdSupported(chainId: CosmosChainId): Promise<boolean>;
|
|
17
|
-
checkChainIdSupport(): Promise<boolean>;
|
|
18
|
-
getCosmostationWallet(): Promise<typeof _cosmostation_extension_client_cosmos0>;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/strategy/strategy.d.ts
|
|
22
|
-
declare class Cosmostation extends BaseConcreteStrategy implements ConcreteWalletStrategy {
|
|
23
|
-
private cosmostationWallet?;
|
|
24
|
-
chainName: string;
|
|
25
|
-
constructor(args: {
|
|
26
|
-
chainId: ChainId | CosmosChainId;
|
|
27
|
-
});
|
|
28
|
-
getWalletDeviceType(): Promise<WalletDeviceType>;
|
|
29
|
-
enable(): Promise<boolean>;
|
|
30
|
-
getAddresses(): Promise<string[]>;
|
|
31
|
-
getAddressesInfo(): Promise<{
|
|
32
|
-
address: string;
|
|
33
|
-
derivationPath: string;
|
|
34
|
-
baseDerivationPath: string;
|
|
35
|
-
}[]>;
|
|
36
|
-
getSessionOrConfirm(address?: AccountAddress): Promise<string>;
|
|
37
|
-
sendEvmTransaction(_transaction: unknown, _options: {
|
|
38
|
-
address: AccountAddress;
|
|
39
|
-
evmChainId: EvmChainId;
|
|
40
|
-
}): Promise<string>;
|
|
41
|
-
sendTransaction(transaction: DirectSignResponse | CosmosTxV1Beta1TxPb.TxRaw, _options: {
|
|
42
|
-
address: AccountAddress;
|
|
43
|
-
chainId: ChainId;
|
|
44
|
-
}): Promise<TxResponse>;
|
|
45
|
-
signAminoCosmosTransaction(_transaction: {
|
|
46
|
-
address: string;
|
|
47
|
-
signDoc: StdSignDoc;
|
|
48
|
-
}): Promise<AminoSignResponse>;
|
|
49
|
-
signCosmosTransaction(transaction: {
|
|
50
|
-
txRaw: CosmosTxV1Beta1TxPb.TxRaw;
|
|
51
|
-
chainId: string;
|
|
52
|
-
address: string;
|
|
53
|
-
accountNumber: number;
|
|
54
|
-
}): Promise<DirectSignResponse>;
|
|
55
|
-
getPubKey(): Promise<string>;
|
|
56
|
-
signEip712TypedData(_eip712TypedData: string, _address: AccountAddress): Promise<string>;
|
|
57
|
-
signArbitrary(signer: string, data: string | Uint8Array): Promise<string>;
|
|
58
|
-
getEthereumChainId(): Promise<string>;
|
|
59
|
-
getEvmTransactionReceipt(_txHash: string): Promise<string>;
|
|
60
|
-
getOfflineSigner(chainId: string): Promise<OfflineSigner>;
|
|
61
|
-
private getCosmostationWallet;
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
export { CosmostationWallet, Cosmostation as CosmostationWalletStrategy, isCosmosStationWalletInstalled };
|