@wormhole-labs/wallet-aggregator-core 0.0.1
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 +45 -0
- package/dist/cjs/constants.js +197 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/wallet.js +81 -0
- package/dist/cjs/wallet.js.map +1 -0
- package/dist/esm/constants.js +185 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/wallet.js +72 -0
- package/dist/esm/wallet.js.map +1 -0
- package/dist/types/constants.d.ts +134 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/wallet.d.ts +181 -0
- package/dist/types/wallet.d.ts.map +1 -0
- package/package.json +34 -0
- package/src/constants.ts +209 -0
- package/src/index.ts +2 -0
- package/src/wallet.ts +241 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
## Wallet Aggregator - Core
|
|
2
|
+
|
|
3
|
+
Basic Wallet abstractions to interact with blockchains.
|
|
4
|
+
|
|
5
|
+
In order to implement a wallet for a given chain through the sdk, simply import the `Wallet` class and extend from it. The abstraction defines a set of generic arguments to define the types the methods it will expect and interact with (e.g. a transaction request type, a message to sign, the result of submitting a tx to network, etc).
|
|
6
|
+
|
|
7
|
+
The `Wallet` class implements the `EventEmitter` interface, letting the client subscribe to the following events:
|
|
8
|
+
|
|
9
|
+
| Event | Description |
|
|
10
|
+
| ---------------- | ------------------------------------------------------------------------------------------ |
|
|
11
|
+
| `connect` | Signals the wallet has succesfully connected |
|
|
12
|
+
| `disconnect` | Signals the wallet has succesfully disconnected |
|
|
13
|
+
| `networkChanged` | Signals whether a change in the network was detected. Useful for working with EVM wallets. |
|
|
14
|
+
|
|
15
|
+
New events can be added by extending the `WalletEvents` class.
|
|
16
|
+
|
|
17
|
+
Example:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { Wallet, WalletEvents } from "@wormhole-labs/wallet-aggregator-core";
|
|
21
|
+
|
|
22
|
+
// define types
|
|
23
|
+
type MyUnsignedTransactionType = // ...
|
|
24
|
+
// ...
|
|
25
|
+
interface MyEventsType extends WalletEvents {
|
|
26
|
+
// ...
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class MyBlockchainWallet extends Wallet<
|
|
30
|
+
MyUnsignedTransactionType,
|
|
31
|
+
MySignedTransactionType,
|
|
32
|
+
MySignedTransactionType,
|
|
33
|
+
MySubmitTransactionResultType,
|
|
34
|
+
MyNetworkInfoType,
|
|
35
|
+
MyMessageType,
|
|
36
|
+
MyMessageResultType,
|
|
37
|
+
MyEventsType
|
|
38
|
+
> {
|
|
39
|
+
// code...
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The blockchain IDs follow those of Wormhole. A [constants file](./src/constants.ts) is provided with said chain ids.
|
|
44
|
+
|
|
45
|
+
Refer to the Wormhole [documentation](https://docs.wormhole.com/wormhole/overview) if you wish to know more about the project.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CHAIN_ID_SEDA = exports.CHAIN_ID_STARGAZE = exports.CHAIN_ID_CELESTIA = exports.CHAIN_ID_NEUTRON = exports.CHAIN_ID_KUJIRA = exports.CHAIN_ID_EVMOS = exports.CHAIN_ID_COSMOSHUB = exports.CHAIN_ID_WORMCHAIN = exports.CHAIN_ID_SEIEVM = exports.CHAIN_ID_BERACHAIN = exports.CHAIN_ID_LINEA = exports.CHAIN_ID_WORLDCHAIN = exports.CHAIN_ID_XLAYER = exports.CHAIN_ID_BLAST = exports.CHAIN_ID_MANTLE = exports.CHAIN_ID_SCROLL = exports.CHAIN_ID_ROOTSTOCK = exports.CHAIN_ID_SEI = exports.CHAIN_ID_BASE = exports.CHAIN_ID_BTC = exports.CHAIN_ID_XPLA = exports.CHAIN_ID_PYTHNET = exports.CHAIN_ID_GNOSIS = exports.CHAIN_ID_OPTIMISM = exports.CHAIN_ID_ARBITRUM = exports.CHAIN_ID_APTOS = exports.CHAIN_ID_SUI = exports.CHAIN_ID_OSMOSIS = exports.CHAIN_ID_INJECTIVE = exports.CHAIN_ID_TERRA2 = exports.CHAIN_ID_NEON = exports.CHAIN_ID_MOONBEAM = exports.CHAIN_ID_NEAR = exports.CHAIN_ID_CELO = exports.CHAIN_ID_KLAYTN = exports.CHAIN_ID_ACALA = exports.CHAIN_ID_KARURA = exports.CHAIN_ID_FANTOM = exports.CHAIN_ID_AURORA = exports.CHAIN_ID_ALGORAND = exports.CHAIN_ID_OASIS = exports.CHAIN_ID_AVAX = exports.CHAIN_ID_POLYGON = exports.CHAIN_ID_BSC = exports.CHAIN_ID_TERRA = exports.CHAIN_ID_ETH = exports.CHAIN_ID_SOLANA = exports.CHAIN_ID_UNSET = exports.CHAIN_ID_TO_NAME = exports.CHAINS = void 0;
|
|
4
|
+
exports.isTerraChain = exports.isCosmWasmChain = exports.isEVMChain = exports.coalesceChainName = exports.coalesceChainId = exports.toChainName = exports.toChainId = exports.isChain = exports.CHAIN_ID_MONAD = exports.CHAIN_ID_UNICHAIN = exports.CHAIN_ID_POLYGON_SEPOLIA = exports.CHAIN_ID_HOLESKY = exports.CHAIN_ID_OPTIMISM_SEPOLIA = exports.CHAIN_ID_BASE_SEPOLIA = exports.CHAIN_ID_ARBITRUM_SEPOLIA = exports.CHAIN_ID_SEPOLIA = exports.CHAIN_ID_PROVENANCE = exports.CHAIN_ID_DYMENSION = void 0;
|
|
5
|
+
// From: https://github.com/wormhole-foundation/wormhole/blob/dev.v2/sdk/js/src/utils/consts.ts#L1
|
|
6
|
+
exports.CHAINS = {
|
|
7
|
+
unset: 0,
|
|
8
|
+
solana: 1,
|
|
9
|
+
ethereum: 2,
|
|
10
|
+
terra: 3,
|
|
11
|
+
bsc: 4,
|
|
12
|
+
polygon: 5,
|
|
13
|
+
avalanche: 6,
|
|
14
|
+
oasis: 7,
|
|
15
|
+
algorand: 8,
|
|
16
|
+
aurora: 9,
|
|
17
|
+
fantom: 10,
|
|
18
|
+
karura: 11,
|
|
19
|
+
acala: 12,
|
|
20
|
+
klaytn: 13,
|
|
21
|
+
celo: 14,
|
|
22
|
+
near: 15,
|
|
23
|
+
moonbeam: 16,
|
|
24
|
+
neon: 17,
|
|
25
|
+
terra2: 18,
|
|
26
|
+
injective: 19,
|
|
27
|
+
osmosis: 20,
|
|
28
|
+
sui: 21,
|
|
29
|
+
aptos: 22,
|
|
30
|
+
arbitrum: 23,
|
|
31
|
+
optimism: 24,
|
|
32
|
+
gnosis: 25,
|
|
33
|
+
pythnet: 26,
|
|
34
|
+
xpla: 28,
|
|
35
|
+
btc: 29,
|
|
36
|
+
base: 30,
|
|
37
|
+
sei: 32,
|
|
38
|
+
rootstock: 33, //
|
|
39
|
+
scroll: 34,
|
|
40
|
+
mantle: 35,
|
|
41
|
+
blast: 36,
|
|
42
|
+
xlayer: 37,
|
|
43
|
+
linea: 38,
|
|
44
|
+
berachain: 39,
|
|
45
|
+
seievm: 40,
|
|
46
|
+
unichain: 44,
|
|
47
|
+
worldchain: 45,
|
|
48
|
+
monad: 48,
|
|
49
|
+
wormchain: 3104,
|
|
50
|
+
cosmoshub: 4000,
|
|
51
|
+
evmos: 4001,
|
|
52
|
+
kujira: 4002,
|
|
53
|
+
neutron: 4003,
|
|
54
|
+
celestia: 4004,
|
|
55
|
+
stargaze: 4005,
|
|
56
|
+
seda: 4006,
|
|
57
|
+
dymension: 4007,
|
|
58
|
+
provenance: 4008,
|
|
59
|
+
sepolia: 10002,
|
|
60
|
+
arbitrum_sepolia: 10003,
|
|
61
|
+
base_sepolia: 10004,
|
|
62
|
+
optimism_sepolia: 10005,
|
|
63
|
+
holesky: 10006,
|
|
64
|
+
polygon_sepolia: 10007,
|
|
65
|
+
};
|
|
66
|
+
exports.CHAIN_ID_TO_NAME = Object.entries(exports.CHAINS).reduce((obj, [name, id]) => {
|
|
67
|
+
obj[id] = name; // eslint-disable-line
|
|
68
|
+
return obj; // eslint-disable-line
|
|
69
|
+
}, {} // eslint-disable-line
|
|
70
|
+
);
|
|
71
|
+
exports.CHAIN_ID_UNSET = exports.CHAINS["unset"];
|
|
72
|
+
exports.CHAIN_ID_SOLANA = exports.CHAINS["solana"];
|
|
73
|
+
exports.CHAIN_ID_ETH = exports.CHAINS["ethereum"];
|
|
74
|
+
exports.CHAIN_ID_TERRA = exports.CHAINS["terra"];
|
|
75
|
+
exports.CHAIN_ID_BSC = exports.CHAINS["bsc"];
|
|
76
|
+
exports.CHAIN_ID_POLYGON = exports.CHAINS["polygon"];
|
|
77
|
+
exports.CHAIN_ID_AVAX = exports.CHAINS["avalanche"];
|
|
78
|
+
exports.CHAIN_ID_OASIS = exports.CHAINS["oasis"];
|
|
79
|
+
exports.CHAIN_ID_ALGORAND = exports.CHAINS["algorand"];
|
|
80
|
+
exports.CHAIN_ID_AURORA = exports.CHAINS["aurora"];
|
|
81
|
+
exports.CHAIN_ID_FANTOM = exports.CHAINS["fantom"];
|
|
82
|
+
exports.CHAIN_ID_KARURA = exports.CHAINS["karura"];
|
|
83
|
+
exports.CHAIN_ID_ACALA = exports.CHAINS["acala"];
|
|
84
|
+
exports.CHAIN_ID_KLAYTN = exports.CHAINS["klaytn"];
|
|
85
|
+
exports.CHAIN_ID_CELO = exports.CHAINS["celo"];
|
|
86
|
+
exports.CHAIN_ID_NEAR = exports.CHAINS["near"];
|
|
87
|
+
exports.CHAIN_ID_MOONBEAM = exports.CHAINS["moonbeam"];
|
|
88
|
+
exports.CHAIN_ID_NEON = exports.CHAINS["neon"];
|
|
89
|
+
exports.CHAIN_ID_TERRA2 = exports.CHAINS["terra2"];
|
|
90
|
+
exports.CHAIN_ID_INJECTIVE = exports.CHAINS["injective"];
|
|
91
|
+
exports.CHAIN_ID_OSMOSIS = exports.CHAINS["osmosis"];
|
|
92
|
+
exports.CHAIN_ID_SUI = exports.CHAINS["sui"];
|
|
93
|
+
exports.CHAIN_ID_APTOS = exports.CHAINS["aptos"];
|
|
94
|
+
exports.CHAIN_ID_ARBITRUM = exports.CHAINS["arbitrum"];
|
|
95
|
+
exports.CHAIN_ID_OPTIMISM = exports.CHAINS["optimism"];
|
|
96
|
+
exports.CHAIN_ID_GNOSIS = exports.CHAINS["gnosis"];
|
|
97
|
+
exports.CHAIN_ID_PYTHNET = exports.CHAINS["pythnet"];
|
|
98
|
+
exports.CHAIN_ID_XPLA = exports.CHAINS["xpla"];
|
|
99
|
+
exports.CHAIN_ID_BTC = exports.CHAINS["btc"];
|
|
100
|
+
exports.CHAIN_ID_BASE = exports.CHAINS["base"];
|
|
101
|
+
exports.CHAIN_ID_SEI = exports.CHAINS["sei"];
|
|
102
|
+
exports.CHAIN_ID_ROOTSTOCK = exports.CHAINS["rootstock"];
|
|
103
|
+
exports.CHAIN_ID_SCROLL = exports.CHAINS["scroll"];
|
|
104
|
+
exports.CHAIN_ID_MANTLE = exports.CHAINS["mantle"];
|
|
105
|
+
exports.CHAIN_ID_BLAST = exports.CHAINS["blast"];
|
|
106
|
+
exports.CHAIN_ID_XLAYER = exports.CHAINS["xlayer"];
|
|
107
|
+
exports.CHAIN_ID_WORLDCHAIN = exports.CHAINS["worldchain"];
|
|
108
|
+
exports.CHAIN_ID_LINEA = exports.CHAINS["linea"];
|
|
109
|
+
exports.CHAIN_ID_BERACHAIN = exports.CHAINS["berachain"];
|
|
110
|
+
exports.CHAIN_ID_SEIEVM = exports.CHAINS["seievm"];
|
|
111
|
+
exports.CHAIN_ID_WORMCHAIN = exports.CHAINS["wormchain"];
|
|
112
|
+
exports.CHAIN_ID_COSMOSHUB = exports.CHAINS["cosmoshub"];
|
|
113
|
+
exports.CHAIN_ID_EVMOS = exports.CHAINS["evmos"];
|
|
114
|
+
exports.CHAIN_ID_KUJIRA = exports.CHAINS["kujira"];
|
|
115
|
+
exports.CHAIN_ID_NEUTRON = exports.CHAINS["neutron"];
|
|
116
|
+
exports.CHAIN_ID_CELESTIA = exports.CHAINS["celestia"];
|
|
117
|
+
exports.CHAIN_ID_STARGAZE = exports.CHAINS["stargaze"];
|
|
118
|
+
exports.CHAIN_ID_SEDA = exports.CHAINS["seda"];
|
|
119
|
+
exports.CHAIN_ID_DYMENSION = exports.CHAINS["dymension"];
|
|
120
|
+
exports.CHAIN_ID_PROVENANCE = exports.CHAINS["provenance"];
|
|
121
|
+
exports.CHAIN_ID_SEPOLIA = exports.CHAINS["sepolia"];
|
|
122
|
+
exports.CHAIN_ID_ARBITRUM_SEPOLIA = exports.CHAINS["arbitrum_sepolia"];
|
|
123
|
+
exports.CHAIN_ID_BASE_SEPOLIA = exports.CHAINS["base_sepolia"];
|
|
124
|
+
exports.CHAIN_ID_OPTIMISM_SEPOLIA = exports.CHAINS["optimism_sepolia"];
|
|
125
|
+
exports.CHAIN_ID_HOLESKY = exports.CHAINS["holesky"];
|
|
126
|
+
exports.CHAIN_ID_POLYGON_SEPOLIA = exports.CHAINS["polygon_sepolia"];
|
|
127
|
+
exports.CHAIN_ID_UNICHAIN = exports.CHAINS["unichain"];
|
|
128
|
+
exports.CHAIN_ID_MONAD = exports.CHAINS["monad"];
|
|
129
|
+
function isChain(chain) {
|
|
130
|
+
if (typeof chain === "number") {
|
|
131
|
+
return chain in exports.CHAIN_ID_TO_NAME;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return chain in exports.CHAINS;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.isChain = isChain;
|
|
138
|
+
function toChainId(chainName) {
|
|
139
|
+
return exports.CHAINS[chainName];
|
|
140
|
+
}
|
|
141
|
+
exports.toChainId = toChainId;
|
|
142
|
+
function toChainName(chainId) {
|
|
143
|
+
return exports.CHAIN_ID_TO_NAME[chainId];
|
|
144
|
+
}
|
|
145
|
+
exports.toChainName = toChainName;
|
|
146
|
+
function coalesceChainId(chain) {
|
|
147
|
+
return typeof chain === "number" && isChain(chain) ? chain : toChainId(chain);
|
|
148
|
+
}
|
|
149
|
+
exports.coalesceChainId = coalesceChainId;
|
|
150
|
+
function coalesceChainName(chain) {
|
|
151
|
+
return toChainName(coalesceChainId(chain));
|
|
152
|
+
}
|
|
153
|
+
exports.coalesceChainName = coalesceChainName;
|
|
154
|
+
function isEVMChain(chainId) {
|
|
155
|
+
return (chainId === exports.CHAIN_ID_ETH ||
|
|
156
|
+
chainId === exports.CHAIN_ID_BSC ||
|
|
157
|
+
chainId === exports.CHAIN_ID_AVAX ||
|
|
158
|
+
chainId === exports.CHAIN_ID_POLYGON ||
|
|
159
|
+
chainId === exports.CHAIN_ID_OASIS ||
|
|
160
|
+
chainId === exports.CHAIN_ID_AURORA ||
|
|
161
|
+
chainId === exports.CHAIN_ID_FANTOM ||
|
|
162
|
+
chainId === exports.CHAIN_ID_KARURA ||
|
|
163
|
+
chainId === exports.CHAIN_ID_ACALA ||
|
|
164
|
+
chainId === exports.CHAIN_ID_KLAYTN ||
|
|
165
|
+
chainId === exports.CHAIN_ID_CELO ||
|
|
166
|
+
chainId === exports.CHAIN_ID_MOONBEAM ||
|
|
167
|
+
chainId === exports.CHAIN_ID_NEON ||
|
|
168
|
+
chainId === exports.CHAIN_ID_ARBITRUM ||
|
|
169
|
+
chainId === exports.CHAIN_ID_OPTIMISM ||
|
|
170
|
+
chainId === exports.CHAIN_ID_GNOSIS ||
|
|
171
|
+
chainId === exports.CHAIN_ID_BASE ||
|
|
172
|
+
chainId === exports.CHAIN_ID_SCROLL ||
|
|
173
|
+
chainId === exports.CHAIN_ID_WORLDCHAIN ||
|
|
174
|
+
chainId === exports.CHAIN_ID_BLAST ||
|
|
175
|
+
chainId === exports.CHAIN_ID_XLAYER ||
|
|
176
|
+
chainId === exports.CHAIN_ID_MANTLE ||
|
|
177
|
+
chainId === exports.CHAIN_ID_UNICHAIN ||
|
|
178
|
+
chainId === exports.CHAIN_ID_MONAD);
|
|
179
|
+
}
|
|
180
|
+
exports.isEVMChain = isEVMChain;
|
|
181
|
+
function isCosmWasmChain(chainId) {
|
|
182
|
+
return (chainId === exports.CHAIN_ID_TERRA ||
|
|
183
|
+
chainId === exports.CHAIN_ID_TERRA2 ||
|
|
184
|
+
chainId === exports.CHAIN_ID_INJECTIVE ||
|
|
185
|
+
chainId === exports.CHAIN_ID_XPLA ||
|
|
186
|
+
chainId === exports.CHAIN_ID_SEI ||
|
|
187
|
+
chainId === exports.CHAIN_ID_WORMCHAIN ||
|
|
188
|
+
chainId === exports.CHAIN_ID_COSMOSHUB ||
|
|
189
|
+
chainId === exports.CHAIN_ID_EVMOS ||
|
|
190
|
+
chainId === exports.CHAIN_ID_KUJIRA);
|
|
191
|
+
}
|
|
192
|
+
exports.isCosmWasmChain = isCosmWasmChain;
|
|
193
|
+
function isTerraChain(chainId) {
|
|
194
|
+
return chainId === exports.CHAIN_ID_TERRA || chainId === exports.CHAIN_ID_TERRA2;
|
|
195
|
+
}
|
|
196
|
+
exports.isTerraChain = isTerraChain;
|
|
197
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;;AAAA,kGAAkG;AACrF,QAAA,MAAM,GAAG;IACpB,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,CAAC;IACZ,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,Q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Y;QACxB,OAAO,KAAK,0BAAkB;QAC9B,OAAO,KAAK,0BAAkB;QAC9B,OAAO,KAAK,sBAAc;QAC1B,OAAO,KAAK,uBAAe,CAC5B,CAAC;AACJ,CAAC;AAZD,0CAYC;AAED,SAAgB,YAAY,CAAC,OAAgB;IAC3C,OAAO,OAAO,KAAK,sBAAc,IAAI,OAAO,KAAK,uBAAe,CAAC;AACnE,CAAC;AAFD,oCAEC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./wallet"), exports);
|
|
18
|
+
__exportStar(require("./constants"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Wallet = exports.WalletState = exports.BaseFeatures = exports.NotConnected = exports.NotSupported = void 0;
|
|
7
|
+
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
8
|
+
class NotSupported extends Error {
|
|
9
|
+
constructor() {
|
|
10
|
+
super("Not supported");
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.NotSupported = NotSupported;
|
|
14
|
+
class NotConnected extends Error {
|
|
15
|
+
constructor() {
|
|
16
|
+
super("Not connected");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.NotConnected = NotConnected;
|
|
20
|
+
var BaseFeatures;
|
|
21
|
+
(function (BaseFeatures) {
|
|
22
|
+
BaseFeatures["SignTransaction"] = "SignTransaction";
|
|
23
|
+
BaseFeatures["SendTransaction"] = "SendTransaction";
|
|
24
|
+
BaseFeatures["SignAndSendTransaction"] = "SignAndSendTransaction";
|
|
25
|
+
BaseFeatures["SignMessage"] = "SignMessage";
|
|
26
|
+
})(BaseFeatures || (exports.BaseFeatures = BaseFeatures = {}));
|
|
27
|
+
var WalletState;
|
|
28
|
+
(function (WalletState) {
|
|
29
|
+
WalletState["Installed"] = "Installed";
|
|
30
|
+
WalletState["NotDetected"] = "NotDetected";
|
|
31
|
+
WalletState["Loadable"] = "Loadable";
|
|
32
|
+
WalletState["Unsupported"] = "Unsupported";
|
|
33
|
+
})(WalletState || (exports.WalletState = WalletState = {}));
|
|
34
|
+
/**
|
|
35
|
+
* Base Wallet abstraction.
|
|
36
|
+
*
|
|
37
|
+
* Generic arguments (all of them `any` by default):
|
|
38
|
+
* * `ChainId` - The Wormhole chain id for the network
|
|
39
|
+
* * `ConnectOptions` - Options to pass to the `connect` method
|
|
40
|
+
* * `SignTransactionInput` - Transaction object to sign
|
|
41
|
+
* * `SignTransactionResult` - Result of the `signTransaction` method
|
|
42
|
+
* * `SendTransactionInput` - Transaction object to send. Might be signed or not, depending on the wallet implementation
|
|
43
|
+
* * `SendTransactionResultData` - Result of the `sendTransaction` method
|
|
44
|
+
* * `SignAndSendTransactionInput` - Transaction object to sign and send
|
|
45
|
+
* * `SignAndSendTransactionResultData` - Result of the `signAndSendTransaction` method
|
|
46
|
+
* * `SignMessageInput` - Message to sign
|
|
47
|
+
* * `SignMessageResult` - Result of the `signMessage` method
|
|
48
|
+
* * `NetworkInfo` - Object type that describes the blockchain's network information or state
|
|
49
|
+
* * `WalletFeatures` - Object type which describes the features the wallet implements
|
|
50
|
+
* * `WalletEvents` - Object type which describes the events the wallet can be listened on
|
|
51
|
+
*/
|
|
52
|
+
class Wallet extends eventemitter3_1.default {
|
|
53
|
+
/**
|
|
54
|
+
* Retrieve the wallet's current state
|
|
55
|
+
*
|
|
56
|
+
* The possible states are as those used by the {@link https://github.com/solana-labs/wallet-adapter solana} and {@link https://github.com/aptos-labs/aptos-wallet-adapter aptos} libraries, summarized as follows:
|
|
57
|
+
* * `Installed`: the wallet was detected through the global scope or any other mechanism and can be interacted with. Example: `window.ethereum` for Metamask or `window.phantom` for Phantom wallet)
|
|
58
|
+
* * `NotDetected`: as opposed to `Installed`, no point of interaction with the wallet was found, and thus it is not available. Users can be redirected to the project url offered by `getUrl`
|
|
59
|
+
* * `Loadable`: the wallet might not require installation, and thus can be interacted with after being loaded
|
|
60
|
+
* * `Unsupported`: the wallet is not supported by the environment
|
|
61
|
+
*
|
|
62
|
+
* @returns The wallet's state. Defaults to Installed.
|
|
63
|
+
*/
|
|
64
|
+
getWalletState() {
|
|
65
|
+
// default
|
|
66
|
+
return WalletState.Installed;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Query whether a feature or set of features is supported by the wallet.
|
|
70
|
+
* For a list of features see {@link BaseFeatures}.
|
|
71
|
+
* Some chains might add additional features of their own.
|
|
72
|
+
*/
|
|
73
|
+
supportsFeature(feature) {
|
|
74
|
+
const features = this.getFeatures();
|
|
75
|
+
return Array.isArray(feature)
|
|
76
|
+
? feature.every((f) => features.includes(f))
|
|
77
|
+
: features.includes(feature);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.Wallet = Wallet;
|
|
81
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/wallet.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAyC;AAGzC,MAAa,YAAa,SAAQ,KAAK;IACrC;QACE,KAAK,CAAC,eAAe,CAAC,CAAC;IACzB,CAAC;CACF;AAJD,oCAIC;AAED,MAAa,YAAa,SAAQ,KAAK;IACrC;QACE,KAAK,CAAC,eAAe,CAAC,CAAC;IACzB,CAAC;CACF;AAJD,oCAIC;AAED,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,mDAAmC,CAAA;IACnC,mDAAmC,CAAA;IACnC,iEAAiD,CAAA;IACjD,2CAA2B,CAAA;AAC7B,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAWD,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,0CAA2B,CAAA;IAC3B,oCAAqB,CAAA;IACrB,0CAA2B,CAAA;AAC7B,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAmBD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAsB,MAcpB,SAAQ,uBAAe;IAqHvB;;;;;;;;;;OAUG;IACH,cAAc;QACZ,UAAU;QACV,OAAO,WAAW,CAAC,SAAS,CAAC;IAC/B,CAAC;IAID;;;;OAIG;IACI,eAAe,CAAC,OAA0C;QAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEpC,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAC3B,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5C,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CAOF;AAvKD,wBAuKC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// From: https://github.com/wormhole-foundation/wormhole/blob/dev.v2/sdk/js/src/utils/consts.ts#L1
|
|
2
|
+
export const CHAINS = {
|
|
3
|
+
unset: 0,
|
|
4
|
+
solana: 1,
|
|
5
|
+
ethereum: 2,
|
|
6
|
+
terra: 3,
|
|
7
|
+
bsc: 4,
|
|
8
|
+
polygon: 5,
|
|
9
|
+
avalanche: 6,
|
|
10
|
+
oasis: 7,
|
|
11
|
+
algorand: 8,
|
|
12
|
+
aurora: 9,
|
|
13
|
+
fantom: 10,
|
|
14
|
+
karura: 11,
|
|
15
|
+
acala: 12,
|
|
16
|
+
klaytn: 13,
|
|
17
|
+
celo: 14,
|
|
18
|
+
near: 15,
|
|
19
|
+
moonbeam: 16,
|
|
20
|
+
neon: 17,
|
|
21
|
+
terra2: 18,
|
|
22
|
+
injective: 19,
|
|
23
|
+
osmosis: 20,
|
|
24
|
+
sui: 21,
|
|
25
|
+
aptos: 22,
|
|
26
|
+
arbitrum: 23,
|
|
27
|
+
optimism: 24,
|
|
28
|
+
gnosis: 25,
|
|
29
|
+
pythnet: 26,
|
|
30
|
+
xpla: 28,
|
|
31
|
+
btc: 29,
|
|
32
|
+
base: 30,
|
|
33
|
+
sei: 32,
|
|
34
|
+
rootstock: 33, //
|
|
35
|
+
scroll: 34,
|
|
36
|
+
mantle: 35,
|
|
37
|
+
blast: 36,
|
|
38
|
+
xlayer: 37,
|
|
39
|
+
linea: 38,
|
|
40
|
+
berachain: 39,
|
|
41
|
+
seievm: 40,
|
|
42
|
+
unichain: 44,
|
|
43
|
+
worldchain: 45,
|
|
44
|
+
monad: 48,
|
|
45
|
+
wormchain: 3104,
|
|
46
|
+
cosmoshub: 4000,
|
|
47
|
+
evmos: 4001,
|
|
48
|
+
kujira: 4002,
|
|
49
|
+
neutron: 4003,
|
|
50
|
+
celestia: 4004,
|
|
51
|
+
stargaze: 4005,
|
|
52
|
+
seda: 4006,
|
|
53
|
+
dymension: 4007,
|
|
54
|
+
provenance: 4008,
|
|
55
|
+
sepolia: 10002,
|
|
56
|
+
arbitrum_sepolia: 10003,
|
|
57
|
+
base_sepolia: 10004,
|
|
58
|
+
optimism_sepolia: 10005,
|
|
59
|
+
holesky: 10006,
|
|
60
|
+
polygon_sepolia: 10007,
|
|
61
|
+
};
|
|
62
|
+
export const CHAIN_ID_TO_NAME = Object.entries(CHAINS).reduce((obj, [name, id]) => {
|
|
63
|
+
obj[id] = name; // eslint-disable-line
|
|
64
|
+
return obj; // eslint-disable-line
|
|
65
|
+
}, {} // eslint-disable-line
|
|
66
|
+
);
|
|
67
|
+
export const CHAIN_ID_UNSET = CHAINS["unset"];
|
|
68
|
+
export const CHAIN_ID_SOLANA = CHAINS["solana"];
|
|
69
|
+
export const CHAIN_ID_ETH = CHAINS["ethereum"];
|
|
70
|
+
export const CHAIN_ID_TERRA = CHAINS["terra"];
|
|
71
|
+
export const CHAIN_ID_BSC = CHAINS["bsc"];
|
|
72
|
+
export const CHAIN_ID_POLYGON = CHAINS["polygon"];
|
|
73
|
+
export const CHAIN_ID_AVAX = CHAINS["avalanche"];
|
|
74
|
+
export const CHAIN_ID_OASIS = CHAINS["oasis"];
|
|
75
|
+
export const CHAIN_ID_ALGORAND = CHAINS["algorand"];
|
|
76
|
+
export const CHAIN_ID_AURORA = CHAINS["aurora"];
|
|
77
|
+
export const CHAIN_ID_FANTOM = CHAINS["fantom"];
|
|
78
|
+
export const CHAIN_ID_KARURA = CHAINS["karura"];
|
|
79
|
+
export const CHAIN_ID_ACALA = CHAINS["acala"];
|
|
80
|
+
export const CHAIN_ID_KLAYTN = CHAINS["klaytn"];
|
|
81
|
+
export const CHAIN_ID_CELO = CHAINS["celo"];
|
|
82
|
+
export const CHAIN_ID_NEAR = CHAINS["near"];
|
|
83
|
+
export const CHAIN_ID_MOONBEAM = CHAINS["moonbeam"];
|
|
84
|
+
export const CHAIN_ID_NEON = CHAINS["neon"];
|
|
85
|
+
export const CHAIN_ID_TERRA2 = CHAINS["terra2"];
|
|
86
|
+
export const CHAIN_ID_INJECTIVE = CHAINS["injective"];
|
|
87
|
+
export const CHAIN_ID_OSMOSIS = CHAINS["osmosis"];
|
|
88
|
+
export const CHAIN_ID_SUI = CHAINS["sui"];
|
|
89
|
+
export const CHAIN_ID_APTOS = CHAINS["aptos"];
|
|
90
|
+
export const CHAIN_ID_ARBITRUM = CHAINS["arbitrum"];
|
|
91
|
+
export const CHAIN_ID_OPTIMISM = CHAINS["optimism"];
|
|
92
|
+
export const CHAIN_ID_GNOSIS = CHAINS["gnosis"];
|
|
93
|
+
export const CHAIN_ID_PYTHNET = CHAINS["pythnet"];
|
|
94
|
+
export const CHAIN_ID_XPLA = CHAINS["xpla"];
|
|
95
|
+
export const CHAIN_ID_BTC = CHAINS["btc"];
|
|
96
|
+
export const CHAIN_ID_BASE = CHAINS["base"];
|
|
97
|
+
export const CHAIN_ID_SEI = CHAINS["sei"];
|
|
98
|
+
export const CHAIN_ID_ROOTSTOCK = CHAINS["rootstock"];
|
|
99
|
+
export const CHAIN_ID_SCROLL = CHAINS["scroll"];
|
|
100
|
+
export const CHAIN_ID_MANTLE = CHAINS["mantle"];
|
|
101
|
+
export const CHAIN_ID_BLAST = CHAINS["blast"];
|
|
102
|
+
export const CHAIN_ID_XLAYER = CHAINS["xlayer"];
|
|
103
|
+
export const CHAIN_ID_WORLDCHAIN = CHAINS["worldchain"];
|
|
104
|
+
export const CHAIN_ID_LINEA = CHAINS["linea"];
|
|
105
|
+
export const CHAIN_ID_BERACHAIN = CHAINS["berachain"];
|
|
106
|
+
export const CHAIN_ID_SEIEVM = CHAINS["seievm"];
|
|
107
|
+
export const CHAIN_ID_WORMCHAIN = CHAINS["wormchain"];
|
|
108
|
+
export const CHAIN_ID_COSMOSHUB = CHAINS["cosmoshub"];
|
|
109
|
+
export const CHAIN_ID_EVMOS = CHAINS["evmos"];
|
|
110
|
+
export const CHAIN_ID_KUJIRA = CHAINS["kujira"];
|
|
111
|
+
export const CHAIN_ID_NEUTRON = CHAINS["neutron"];
|
|
112
|
+
export const CHAIN_ID_CELESTIA = CHAINS["celestia"];
|
|
113
|
+
export const CHAIN_ID_STARGAZE = CHAINS["stargaze"];
|
|
114
|
+
export const CHAIN_ID_SEDA = CHAINS["seda"];
|
|
115
|
+
export const CHAIN_ID_DYMENSION = CHAINS["dymension"];
|
|
116
|
+
export const CHAIN_ID_PROVENANCE = CHAINS["provenance"];
|
|
117
|
+
export const CHAIN_ID_SEPOLIA = CHAINS["sepolia"];
|
|
118
|
+
export const CHAIN_ID_ARBITRUM_SEPOLIA = CHAINS["arbitrum_sepolia"];
|
|
119
|
+
export const CHAIN_ID_BASE_SEPOLIA = CHAINS["base_sepolia"];
|
|
120
|
+
export const CHAIN_ID_OPTIMISM_SEPOLIA = CHAINS["optimism_sepolia"];
|
|
121
|
+
export const CHAIN_ID_HOLESKY = CHAINS["holesky"];
|
|
122
|
+
export const CHAIN_ID_POLYGON_SEPOLIA = CHAINS["polygon_sepolia"];
|
|
123
|
+
export const CHAIN_ID_UNICHAIN = CHAINS["unichain"];
|
|
124
|
+
export const CHAIN_ID_MONAD = CHAINS["monad"];
|
|
125
|
+
export function isChain(chain) {
|
|
126
|
+
if (typeof chain === "number") {
|
|
127
|
+
return chain in CHAIN_ID_TO_NAME;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return chain in CHAINS;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export function toChainId(chainName) {
|
|
134
|
+
return CHAINS[chainName];
|
|
135
|
+
}
|
|
136
|
+
export function toChainName(chainId) {
|
|
137
|
+
return CHAIN_ID_TO_NAME[chainId];
|
|
138
|
+
}
|
|
139
|
+
export function coalesceChainId(chain) {
|
|
140
|
+
return typeof chain === "number" && isChain(chain) ? chain : toChainId(chain);
|
|
141
|
+
}
|
|
142
|
+
export function coalesceChainName(chain) {
|
|
143
|
+
return toChainName(coalesceChainId(chain));
|
|
144
|
+
}
|
|
145
|
+
export function isEVMChain(chainId) {
|
|
146
|
+
return (chainId === CHAIN_ID_ETH ||
|
|
147
|
+
chainId === CHAIN_ID_BSC ||
|
|
148
|
+
chainId === CHAIN_ID_AVAX ||
|
|
149
|
+
chainId === CHAIN_ID_POLYGON ||
|
|
150
|
+
chainId === CHAIN_ID_OASIS ||
|
|
151
|
+
chainId === CHAIN_ID_AURORA ||
|
|
152
|
+
chainId === CHAIN_ID_FANTOM ||
|
|
153
|
+
chainId === CHAIN_ID_KARURA ||
|
|
154
|
+
chainId === CHAIN_ID_ACALA ||
|
|
155
|
+
chainId === CHAIN_ID_KLAYTN ||
|
|
156
|
+
chainId === CHAIN_ID_CELO ||
|
|
157
|
+
chainId === CHAIN_ID_MOONBEAM ||
|
|
158
|
+
chainId === CHAIN_ID_NEON ||
|
|
159
|
+
chainId === CHAIN_ID_ARBITRUM ||
|
|
160
|
+
chainId === CHAIN_ID_OPTIMISM ||
|
|
161
|
+
chainId === CHAIN_ID_GNOSIS ||
|
|
162
|
+
chainId === CHAIN_ID_BASE ||
|
|
163
|
+
chainId === CHAIN_ID_SCROLL ||
|
|
164
|
+
chainId === CHAIN_ID_WORLDCHAIN ||
|
|
165
|
+
chainId === CHAIN_ID_BLAST ||
|
|
166
|
+
chainId === CHAIN_ID_XLAYER ||
|
|
167
|
+
chainId === CHAIN_ID_MANTLE ||
|
|
168
|
+
chainId === CHAIN_ID_UNICHAIN ||
|
|
169
|
+
chainId === CHAIN_ID_MONAD);
|
|
170
|
+
}
|
|
171
|
+
export function isCosmWasmChain(chainId) {
|
|
172
|
+
return (chainId === CHAIN_ID_TERRA ||
|
|
173
|
+
chainId === CHAIN_ID_TERRA2 ||
|
|
174
|
+
chainId === CHAIN_ID_INJECTIVE ||
|
|
175
|
+
chainId === CHAIN_ID_XPLA ||
|
|
176
|
+
chainId === CHAIN_ID_SEI ||
|
|
177
|
+
chainId === CHAIN_ID_WORMCHAIN ||
|
|
178
|
+
chainId === CHAIN_ID_COSMOSHUB ||
|
|
179
|
+
chainId === CHAIN_ID_EVMOS ||
|
|
180
|
+
chainId === CHAIN_ID_KUJIRA);
|
|
181
|
+
}
|
|
182
|
+
export function isTerraChain(chainId) {
|
|
183
|
+
return chainId === CHAIN_ID_TERRA || chainId === CHAIN_ID_TERRA2;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,CAAC;IACZ,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;IACX,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,EAAE;IACP,SAAS,EAAE,EAA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eAAe;QAC3B,OAAO,KAAK,eAAe;QAC3B,OAAO,KAAK,iBAAiB;QAC7B,OAAO,KAAK,cAAc,CAC3B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,OAAO,CACL,OAAO,KAAK,cAAc;QAC1B,OAAO,KAAK,eAAe;QAC3B,OAAO,KAAK,kBAAkB;QAC9B,OAAO,KAAK,aAAa;QACzB,OAAO,KAAK,YAAY;QACxB,OAAO,KAAK,kBAAkB;QAC9B,OAAO,KAAK,kBAAkB;QAC9B,OAAO,KAAK,cAAc;QAC1B,OAAO,KAAK,eAAe,CAC5B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,OAAO,OAAO,KAAK,cAAc,IAAI,OAAO,KAAK,eAAe,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import EventEmitter from "eventemitter3";
|
|
2
|
+
export class NotSupported extends Error {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("Not supported");
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export class NotConnected extends Error {
|
|
8
|
+
constructor() {
|
|
9
|
+
super("Not connected");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export var BaseFeatures;
|
|
13
|
+
(function (BaseFeatures) {
|
|
14
|
+
BaseFeatures["SignTransaction"] = "SignTransaction";
|
|
15
|
+
BaseFeatures["SendTransaction"] = "SendTransaction";
|
|
16
|
+
BaseFeatures["SignAndSendTransaction"] = "SignAndSendTransaction";
|
|
17
|
+
BaseFeatures["SignMessage"] = "SignMessage";
|
|
18
|
+
})(BaseFeatures || (BaseFeatures = {}));
|
|
19
|
+
export var WalletState;
|
|
20
|
+
(function (WalletState) {
|
|
21
|
+
WalletState["Installed"] = "Installed";
|
|
22
|
+
WalletState["NotDetected"] = "NotDetected";
|
|
23
|
+
WalletState["Loadable"] = "Loadable";
|
|
24
|
+
WalletState["Unsupported"] = "Unsupported";
|
|
25
|
+
})(WalletState || (WalletState = {}));
|
|
26
|
+
/**
|
|
27
|
+
* Base Wallet abstraction.
|
|
28
|
+
*
|
|
29
|
+
* Generic arguments (all of them `any` by default):
|
|
30
|
+
* * `ChainId` - The Wormhole chain id for the network
|
|
31
|
+
* * `ConnectOptions` - Options to pass to the `connect` method
|
|
32
|
+
* * `SignTransactionInput` - Transaction object to sign
|
|
33
|
+
* * `SignTransactionResult` - Result of the `signTransaction` method
|
|
34
|
+
* * `SendTransactionInput` - Transaction object to send. Might be signed or not, depending on the wallet implementation
|
|
35
|
+
* * `SendTransactionResultData` - Result of the `sendTransaction` method
|
|
36
|
+
* * `SignAndSendTransactionInput` - Transaction object to sign and send
|
|
37
|
+
* * `SignAndSendTransactionResultData` - Result of the `signAndSendTransaction` method
|
|
38
|
+
* * `SignMessageInput` - Message to sign
|
|
39
|
+
* * `SignMessageResult` - Result of the `signMessage` method
|
|
40
|
+
* * `NetworkInfo` - Object type that describes the blockchain's network information or state
|
|
41
|
+
* * `WalletFeatures` - Object type which describes the features the wallet implements
|
|
42
|
+
* * `WalletEvents` - Object type which describes the events the wallet can be listened on
|
|
43
|
+
*/
|
|
44
|
+
export class Wallet extends EventEmitter {
|
|
45
|
+
/**
|
|
46
|
+
* Retrieve the wallet's current state
|
|
47
|
+
*
|
|
48
|
+
* The possible states are as those used by the {@link https://github.com/solana-labs/wallet-adapter solana} and {@link https://github.com/aptos-labs/aptos-wallet-adapter aptos} libraries, summarized as follows:
|
|
49
|
+
* * `Installed`: the wallet was detected through the global scope or any other mechanism and can be interacted with. Example: `window.ethereum` for Metamask or `window.phantom` for Phantom wallet)
|
|
50
|
+
* * `NotDetected`: as opposed to `Installed`, no point of interaction with the wallet was found, and thus it is not available. Users can be redirected to the project url offered by `getUrl`
|
|
51
|
+
* * `Loadable`: the wallet might not require installation, and thus can be interacted with after being loaded
|
|
52
|
+
* * `Unsupported`: the wallet is not supported by the environment
|
|
53
|
+
*
|
|
54
|
+
* @returns The wallet's state. Defaults to Installed.
|
|
55
|
+
*/
|
|
56
|
+
getWalletState() {
|
|
57
|
+
// default
|
|
58
|
+
return WalletState.Installed;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Query whether a feature or set of features is supported by the wallet.
|
|
62
|
+
* For a list of features see {@link BaseFeatures}.
|
|
63
|
+
* Some chains might add additional features of their own.
|
|
64
|
+
*/
|
|
65
|
+
supportsFeature(feature) {
|
|
66
|
+
const features = this.getFeatures();
|
|
67
|
+
return Array.isArray(feature)
|
|
68
|
+
? feature.every((f) => features.includes(f))
|
|
69
|
+
: features.includes(feature);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AAGzC,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC;QACE,KAAK,CAAC,eAAe,CAAC,CAAC;IACzB,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC;QACE,KAAK,CAAC,eAAe,CAAC,CAAC;IACzB,CAAC;CACF;AAED,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,mDAAmC,CAAA;IACnC,mDAAmC,CAAA;IACnC,iEAAiD,CAAA;IACjD,2CAA2B,CAAA;AAC7B,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAWD,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,0CAA2B,CAAA;IAC3B,oCAAqB,CAAA;IACrB,0CAA2B,CAAA;AAC7B,C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