@reef-knot/ledger-connector 4.1.0 → 4.1.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 +13 -0
- package/dist/_virtual/_tslib.js +2 -0
- package/dist/hid/helpers.d.ts.map +1 -1
- package/dist/hid/provider.d.ts +0 -1
- package/dist/hid/provider.d.ts.map +1 -1
- package/dist/iframe/connector.d.ts +3 -2
- package/dist/iframe/connector.d.ts.map +1 -1
- package/dist/iframe/connector.js +7 -11
- package/dist/iframe/provider.d.ts +10 -0
- package/dist/iframe/provider.d.ts.map +1 -0
- package/dist/iframe/provider.js +12 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Ledger connectors for wagmi
|
|
2
|
+
|
|
3
|
+
## Ledger WebHID connector
|
|
4
|
+
|
|
5
|
+
A connector for [wagmi](https://wagmi.sh/) based on `@ledgerhq/hw-transport-webhid`
|
|
6
|
+
|
|
7
|
+
## Ledger Live iframe connector
|
|
8
|
+
|
|
9
|
+
A connector for [wagmi](https://wagmi.sh/) based on `@ledgerhq/iframe-provider`
|
|
10
|
+
|
|
11
|
+
### Arguments
|
|
12
|
+
|
|
13
|
+
The connector has the same options as [IFrameEthereumProvider](https://github.com/LedgerHQ/iframe-provider#usage).
|
package/dist/_virtual/_tslib.js
CHANGED
|
@@ -12,6 +12,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
14
|
***************************************************************************** */
|
|
15
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
16
|
+
|
|
15
17
|
|
|
16
18
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
17
19
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/hid/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEhF,eAAO,MAAM,cAAc,eAM1B,CAAC;AAEF,eAAO,MAAM,UAAU,OAAQ;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,oBAAoB,CAAC,EAAE,YAAY,CAAC;CACrC,YAIA,CAAC;AAEF,eAAO,MAAM,QAAQ,UACZ,YAAY,GAAG,SAAS,GAAG,IAAI,KACrC,MAAM,GAAG,SAEX,CAAC;AAEF,eAAO,MAAM,iBAAiB,OACxB,0BAA0B,KAC7B,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/hid/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEhF,eAAO,MAAM,cAAc,eAM1B,CAAC;AAEF,eAAO,MAAM,UAAU,OAAQ;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,oBAAoB,CAAC,EAAE,YAAY,CAAC;CACrC,YAIA,CAAC;AAEF,eAAO,MAAM,QAAQ,UACZ,YAAY,GAAG,SAAS,GAAG,IAAI,KACrC,MAAM,GAAG,SAEX,CAAC;AAEF,eAAO,MAAM,iBAAiB,OACxB,0BAA0B,KAC7B,OAAO,CAAC,yBAAyB,CAgCnC,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,GAAG,KAAG,KAmBvC,CAAC"}
|
package/dist/hid/provider.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/hid/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/hid/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,eAAe,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI1C,qBAAa,gBAAiB,SAAQ,oBAAoB;IACjD,MAAM,CAAC,EAAE,cAAc,CAAC;IAExB,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB,SAAS,CAAC,EAAE,OAAO,eAAe,CAAC;gBAE9B,GAAG,IAAI,EAAE,GAAG,EAAE;IAK1B,SAAS,IAAI,cAAc;IAI3B,YAAY,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAItC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAI3B,YAAY,IAAI,OAAO,CAAC,eAAe,CAAC;IAcxC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IA4BzB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAK7B,OAAO,CAAC,EACZ,MAAM,EACN,MAAM,GACP,EAAE;QACD,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;KACxB,GAAG,OAAO,CAAC,OAAO,CAAC;CA0BrB"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Chain } from 'wagmi/chains';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IFrameEthereumProviderOptions } from '@ledgerhq/iframe-provider';
|
|
3
|
+
import type { LedgerIFrameProvider } from './provider';
|
|
3
4
|
export declare const idLedgerLive = "ledgerLive";
|
|
4
5
|
export declare const name = "Ledger Live";
|
|
5
6
|
type LedgerLiveConnectorArgs = {
|
|
6
7
|
options?: IFrameEthereumProviderOptions;
|
|
7
8
|
defaultChain: Chain;
|
|
8
9
|
};
|
|
9
|
-
export declare function ledgerLiveConnector({ options, defaultChain, }: LedgerLiveConnectorArgs): import("wagmi").CreateConnectorFn<
|
|
10
|
+
export declare function ledgerLiveConnector({ options, defaultChain, }: LedgerLiveConnectorArgs): import("wagmi").CreateConnectorFn<LedgerIFrameProvider, Record<string, unknown>, Record<string, unknown>>;
|
|
10
11
|
export declare namespace ledgerLiveConnector {
|
|
11
12
|
var type: string;
|
|
12
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/iframe/connector.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/iframe/connector.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,YAAY,eAAe,CAAC;AACzC,eAAO,MAAM,IAAI,gBAAgB,CAAC;AAElC,KAAK,uBAAuB,GAAG;IAC7B,OAAO,CAAC,EAAE,6BAA6B,CAAC;IACxC,YAAY,EAAE,KAAK,CAAC;CACrB,CAAC;AAGF,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,YAAY,GACb,EAAE,uBAAuB,6GA0IzB;yBA7Ie,mBAAmB"}
|
package/dist/iframe/connector.js
CHANGED
|
@@ -28,9 +28,9 @@ function ledgerLiveConnector({
|
|
|
28
28
|
const chain = (_a = chains.find(x => x.id === chainId)) !== null && _a !== void 0 ? _a : defaultChain;
|
|
29
29
|
if (!providers[chain.id]) {
|
|
30
30
|
const {
|
|
31
|
-
|
|
32
|
-
} = yield import('
|
|
33
|
-
providers[chain.id] = new
|
|
31
|
+
LedgerIFrameProvider
|
|
32
|
+
} = yield import('./provider.js');
|
|
33
|
+
providers[chain.id] = new LedgerIFrameProvider(options);
|
|
34
34
|
}
|
|
35
35
|
return providers[chain.id];
|
|
36
36
|
});
|
|
@@ -41,6 +41,7 @@ function ledgerLiveConnector({
|
|
|
41
41
|
} = {}) {
|
|
42
42
|
try {
|
|
43
43
|
const provider = yield this.getProvider();
|
|
44
|
+
// works without bind because it's an obj created(scoped) in a function
|
|
44
45
|
provider.on('accountsChanged', this.onAccountsChanged);
|
|
45
46
|
provider.on('chainChanged', this.onChainChanged);
|
|
46
47
|
emitter.emit('message', {
|
|
@@ -144,16 +145,17 @@ function ledgerLiveConnector({
|
|
|
144
145
|
}
|
|
145
146
|
});
|
|
146
147
|
},
|
|
147
|
-
|
|
148
|
+
onAccountsChanged(accounts) {
|
|
148
149
|
if (accounts.length === 0 || !accounts[0]) {
|
|
149
150
|
emitter.emit('disconnect');
|
|
151
|
+
this.disconnect();
|
|
150
152
|
} else {
|
|
151
153
|
emitter.emit('change', {
|
|
152
154
|
accounts
|
|
153
155
|
});
|
|
154
156
|
}
|
|
155
157
|
},
|
|
156
|
-
|
|
158
|
+
onChainChanged(chainId) {
|
|
157
159
|
emitter.emit('change', {
|
|
158
160
|
chainId: Number(chainId)
|
|
159
161
|
});
|
|
@@ -167,12 +169,6 @@ function ledgerLiveConnector({
|
|
|
167
169
|
},
|
|
168
170
|
onDisconnect() {
|
|
169
171
|
emitter.emit('disconnect');
|
|
170
|
-
},
|
|
171
|
-
onAccountsChanged() {
|
|
172
|
-
// NOOP
|
|
173
|
-
},
|
|
174
|
-
onChainChanged() {
|
|
175
|
-
// NOOP
|
|
176
172
|
}
|
|
177
173
|
}));
|
|
178
174
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IFrameEthereumProvider } from '@ledgerhq/iframe-provider';
|
|
2
|
+
interface RequestArguments {
|
|
3
|
+
readonly method: string;
|
|
4
|
+
readonly params?: any[];
|
|
5
|
+
}
|
|
6
|
+
export declare class LedgerIFrameProvider extends IFrameEthereumProvider {
|
|
7
|
+
request({ method, params }: RequestArguments): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/iframe/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,UAAU,gBAAgB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;CACzB;AAED,qBAAa,oBAAqB,SAAQ,sBAAsB;IAC9D,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,gBAAgB;CAG7C"}
|