@onekeyfe/onekey-cardano-provider 2.0.0-alpha.9 → 2.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/dist/ProviderCardano.d.ts +6 -6
- package/dist/ProviderCardano.js +6 -6
- package/dist/cjs/ProviderCardano.js +6 -6
- package/dist/cjs/index.js +5 -1
- package/dist/type-utils.d.ts +2 -2
- package/dist/types.d.ts +18 -18
- package/package.json +6 -6
|
@@ -5,7 +5,7 @@ import { IJsonRpcRequest } from '@onekeyfe/cross-inpage-provider-types';
|
|
|
5
5
|
import { Cbor, Bytes, Cip30DataSignature, Cip30Wallet, NetworkId, Paginate, WalletApi } from './types';
|
|
6
6
|
import * as TypeUtils from './type-utils';
|
|
7
7
|
export declare const NAMI_TARGET = "nami-wallet";
|
|
8
|
-
export
|
|
8
|
+
export type CardanoRequest = WalletApi & {
|
|
9
9
|
connect: () => Promise<{
|
|
10
10
|
account: string;
|
|
11
11
|
}>;
|
|
@@ -22,7 +22,7 @@ export declare type CardanoRequest = WalletApi & {
|
|
|
22
22
|
payload: Bytes;
|
|
23
23
|
}) => Promise<Cip30DataSignature>;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export type JsBridgeRequest = {
|
|
26
26
|
[K in keyof CardanoRequest]: (params: Parameters<CardanoRequest[K]>[0]) => Promise<TypeUtils.WireStringified<TypeUtils.ResolvePromise<ReturnType<CardanoRequest[K]>>>>;
|
|
27
27
|
};
|
|
28
28
|
declare const PROVIDER_EVENTS: {
|
|
@@ -31,7 +31,7 @@ declare const PROVIDER_EVENTS: {
|
|
|
31
31
|
readonly accountChanged: "accountChanged";
|
|
32
32
|
readonly message_low_level: "message_low_level";
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
type CardanoProviderEventsMap = {
|
|
35
35
|
[PROVIDER_EVENTS.connect]: (account: string) => void;
|
|
36
36
|
[PROVIDER_EVENTS.disconnect]: () => void;
|
|
37
37
|
[PROVIDER_EVENTS.accountChanged]: (account: string | null) => void;
|
|
@@ -42,7 +42,7 @@ interface IProviderCardano extends ProviderBase {
|
|
|
42
42
|
onekey: Cip30Wallet;
|
|
43
43
|
getNetworkId(): Promise<NetworkId>;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
type OneKeyCardanoProviderProps = IInpageProviderConfig & {
|
|
46
46
|
timeout?: number;
|
|
47
47
|
};
|
|
48
48
|
declare class ProviderCardano extends ProviderCardanoBase implements IProviderCardano {
|
|
@@ -64,14 +64,14 @@ declare class ProviderCardano extends ProviderCardanoBase implements IProviderCa
|
|
|
64
64
|
walletInfo(): Cip30Wallet;
|
|
65
65
|
enable(): Promise<{
|
|
66
66
|
getNetworkId: () => Promise<NetworkId>;
|
|
67
|
-
getUtxos: (amount?:
|
|
67
|
+
getUtxos: (amount?: Cbor, paginate?: Paginate) => Promise<string[] | undefined>;
|
|
68
68
|
getCollateral: () => Promise<null>;
|
|
69
69
|
getBalance: () => Promise<string>;
|
|
70
70
|
getUsedAddresses: () => Promise<string[]>;
|
|
71
71
|
getUnusedAddresses: () => Promise<string[]>;
|
|
72
72
|
getChangeAddress: () => Promise<string>;
|
|
73
73
|
getRewardAddresses: () => Promise<string[]>;
|
|
74
|
-
signTx: (tx: Cbor, partialSign?: boolean
|
|
74
|
+
signTx: (tx: Cbor, partialSign?: boolean) => Promise<string>;
|
|
75
75
|
signData: (addr: Cbor, payload: Bytes) => Promise<{
|
|
76
76
|
key: string;
|
|
77
77
|
signature: string;
|
package/dist/ProviderCardano.js
CHANGED
|
@@ -20,6 +20,12 @@ const PROVIDER_EVENTS = {
|
|
|
20
20
|
'message_low_level': 'message_low_level',
|
|
21
21
|
};
|
|
22
22
|
class ProviderCardano extends ProviderCardanoBase {
|
|
23
|
+
get account() {
|
|
24
|
+
return this._account;
|
|
25
|
+
}
|
|
26
|
+
get isConnected() {
|
|
27
|
+
return this._account !== null;
|
|
28
|
+
}
|
|
23
29
|
constructor(props) {
|
|
24
30
|
super(Object.assign(Object.assign({}, props), { bridge: props.bridge || getOrCreateExtInjectedJsBridge({ timeout: props.timeout }) }));
|
|
25
31
|
this._account = null;
|
|
@@ -27,12 +33,6 @@ class ProviderCardano extends ProviderCardanoBase {
|
|
|
27
33
|
this.nami = Object.assign(Object.assign({}, this.walletInfo()), { name: 'Nami' });
|
|
28
34
|
this.onekey = Object.assign({}, this.walletInfo());
|
|
29
35
|
}
|
|
30
|
-
get account() {
|
|
31
|
-
return this._account;
|
|
32
|
-
}
|
|
33
|
-
get isConnected() {
|
|
34
|
-
return this._account !== null;
|
|
35
|
-
}
|
|
36
36
|
_registerEvents() {
|
|
37
37
|
window.addEventListener('onekey_bridge_disconnect', () => {
|
|
38
38
|
this._handleDisconnected();
|
|
@@ -23,6 +23,12 @@ const PROVIDER_EVENTS = {
|
|
|
23
23
|
'message_low_level': 'message_low_level',
|
|
24
24
|
};
|
|
25
25
|
class ProviderCardano extends ProviderCardanoBase_1.ProviderCardanoBase {
|
|
26
|
+
get account() {
|
|
27
|
+
return this._account;
|
|
28
|
+
}
|
|
29
|
+
get isConnected() {
|
|
30
|
+
return this._account !== null;
|
|
31
|
+
}
|
|
26
32
|
constructor(props) {
|
|
27
33
|
super(Object.assign(Object.assign({}, props), { bridge: props.bridge || (0, extension_bridge_injected_1.getOrCreateExtInjectedJsBridge)({ timeout: props.timeout }) }));
|
|
28
34
|
this._account = null;
|
|
@@ -30,12 +36,6 @@ class ProviderCardano extends ProviderCardanoBase_1.ProviderCardanoBase {
|
|
|
30
36
|
this.nami = Object.assign(Object.assign({}, this.walletInfo()), { name: 'Nami' });
|
|
31
37
|
this.onekey = Object.assign({}, this.walletInfo());
|
|
32
38
|
}
|
|
33
|
-
get account() {
|
|
34
|
-
return this._account;
|
|
35
|
-
}
|
|
36
|
-
get isConnected() {
|
|
37
|
-
return this._account !== null;
|
|
38
|
-
}
|
|
39
39
|
_registerEvents() {
|
|
40
40
|
window.addEventListener('onekey_bridge_disconnect', () => {
|
|
41
41
|
this._handleDisconnected();
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/type-utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type WireStringified<T> = T extends Array<infer P> ? Array<WireStringified<P>> : T extends object ? {
|
|
2
2
|
[K in keyof T]: WireStringified<T[K]>;
|
|
3
3
|
} : T;
|
|
4
|
-
export
|
|
4
|
+
export type ResolvePromise<T> = T extends Promise<infer P> ? P : T;
|
package/dist/types.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export declare enum NetworkId {
|
|
|
5
5
|
/**
|
|
6
6
|
* DataSignature type as described in CIP-0030.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
type CoseSign1CborHex = string;
|
|
9
|
+
type CoseKeyCborHex = string;
|
|
10
10
|
export interface Cip30DataSignature {
|
|
11
11
|
key: CoseKeyCborHex;
|
|
12
12
|
signature: CoseSign1CborHex;
|
|
@@ -14,19 +14,19 @@ export interface Cip30DataSignature {
|
|
|
14
14
|
/**
|
|
15
15
|
* A hex-encoded string of the corresponding bytes.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export type Bytes = string;
|
|
18
18
|
/**
|
|
19
19
|
* A hex-encoded string representing CBOR either inside
|
|
20
20
|
* of the Shelley Multi-asset binary spec or, if not present there,
|
|
21
21
|
* from the CIP-0008 signing spec.
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export type Cbor = string;
|
|
24
24
|
/**
|
|
25
25
|
* Used to specify optional pagination for some API calls.
|
|
26
26
|
* Limits results to {limit} each page, and uses a 0-indexing {page}
|
|
27
27
|
* to refer to which of those pages of {limit} items each.
|
|
28
28
|
*/
|
|
29
|
-
export
|
|
29
|
+
export type Paginate = {
|
|
30
30
|
page: number;
|
|
31
31
|
limit: number;
|
|
32
32
|
};
|
|
@@ -39,7 +39,7 @@ export declare type Paginate = {
|
|
|
39
39
|
*
|
|
40
40
|
* @throws ApiError
|
|
41
41
|
*/
|
|
42
|
-
export
|
|
42
|
+
export type GetNetworkId = () => Promise<NetworkId>;
|
|
43
43
|
/**
|
|
44
44
|
* If `amount` is `undefined`, this shall return a list of all UTxOs (unspent transaction outputs)
|
|
45
45
|
* controlled by the wallet.
|
|
@@ -53,7 +53,7 @@ export declare type GetNetworkId = () => Promise<NetworkId>;
|
|
|
53
53
|
* @throws ApiError
|
|
54
54
|
* @throws PaginateError
|
|
55
55
|
*/
|
|
56
|
-
export
|
|
56
|
+
export type GetUtxos = (amount?: Cbor, paginate?: Paginate) => Promise<Cbor[] | undefined>;
|
|
57
57
|
/**
|
|
58
58
|
* @returns a list of one or more UTxOs (unspent transaction outputs) controlled by the wallet
|
|
59
59
|
* that are required to reach AT LEAST the combined ADA value target specified in amount
|
|
@@ -61,7 +61,7 @@ export declare type GetUtxos = (amount?: Cbor, paginate?: Paginate) => Promise<C
|
|
|
61
61
|
* for transactions with plutus script inputs (pure ADA-only UTxOs).
|
|
62
62
|
* @throws ApiError
|
|
63
63
|
*/
|
|
64
|
-
export
|
|
64
|
+
export type GetCollateral = (params?: {
|
|
65
65
|
amount?: Cbor;
|
|
66
66
|
}) => Promise<Cbor[] | null>;
|
|
67
67
|
/**
|
|
@@ -73,7 +73,7 @@ export declare type GetCollateral = (params?: {
|
|
|
73
73
|
*
|
|
74
74
|
* @throws ApiError
|
|
75
75
|
*/
|
|
76
|
-
export
|
|
76
|
+
export type GetBalance = () => Promise<Cbor>;
|
|
77
77
|
/**
|
|
78
78
|
* Returns a list of all used (included in some on-chain transaction) addresses controlled by the wallet.
|
|
79
79
|
*
|
|
@@ -82,13 +82,13 @@ export declare type GetBalance = () => Promise<Cbor>;
|
|
|
82
82
|
* @throws ApiError
|
|
83
83
|
* @throws PaginateError
|
|
84
84
|
*/
|
|
85
|
-
export
|
|
85
|
+
export type GetUsedAddresses = (paginate?: Paginate) => Promise<Cbor[]>;
|
|
86
86
|
/**
|
|
87
87
|
* Returns a list of unused addresses controlled by the wallet.
|
|
88
88
|
*
|
|
89
89
|
* @throws ApiError
|
|
90
90
|
*/
|
|
91
|
-
export
|
|
91
|
+
export type GetUnusedAddresses = () => Promise<Cbor[]>;
|
|
92
92
|
/**
|
|
93
93
|
* Returns an address owned by the wallet that should be used as a change address to return
|
|
94
94
|
* leftover assets during transaction creation back to the connected wallet.
|
|
@@ -97,13 +97,13 @@ export declare type GetUnusedAddresses = () => Promise<Cbor[]>;
|
|
|
97
97
|
*
|
|
98
98
|
* @throws ApiError
|
|
99
99
|
*/
|
|
100
|
-
export
|
|
100
|
+
export type GetChangeAddress = () => Promise<Cbor>;
|
|
101
101
|
/**
|
|
102
102
|
* Returns the reward addresses owned by the wallet. This can return multiple addresses e.g. CIP-0018.
|
|
103
103
|
*
|
|
104
104
|
* @throws ApiError
|
|
105
105
|
*/
|
|
106
|
-
export
|
|
106
|
+
export type GetRewardAddresses = () => Promise<Cbor[]>;
|
|
107
107
|
/**
|
|
108
108
|
* Requests that a user sign the unsigned portions of the supplied transaction.
|
|
109
109
|
*
|
|
@@ -123,7 +123,7 @@ export declare type GetRewardAddresses = () => Promise<Cbor[]>;
|
|
|
123
123
|
* @throws ApiError
|
|
124
124
|
* @throws TxSignError
|
|
125
125
|
*/
|
|
126
|
-
export
|
|
126
|
+
export type SignTx = (tx: Cbor, partialSign?: boolean) => Promise<Cbor>;
|
|
127
127
|
/**
|
|
128
128
|
* This endpoint utilizes the CIP-0008 signing spec for standardization/safety reasons.
|
|
129
129
|
*
|
|
@@ -136,7 +136,7 @@ export declare type SignTx = (tx: Cbor, partialSign?: boolean) => Promise<Cbor>;
|
|
|
136
136
|
* @throws ApiError
|
|
137
137
|
* @throws DataSignError
|
|
138
138
|
*/
|
|
139
|
-
export
|
|
139
|
+
export type SignData = (addr: Cbor, payload: Bytes) => Promise<Cip30DataSignature>;
|
|
140
140
|
/**
|
|
141
141
|
* As wallets should already have this ability, we allow dApps to request that a transaction be sent through it.
|
|
142
142
|
*
|
|
@@ -148,7 +148,7 @@ export declare type SignData = (addr: Cbor, payload: Bytes) => Promise<Cip30Data
|
|
|
148
148
|
* @throws ApiError
|
|
149
149
|
* @throws TxSendError
|
|
150
150
|
*/
|
|
151
|
-
export
|
|
151
|
+
export type SubmitTx = (tx: Cbor) => Promise<string>;
|
|
152
152
|
export interface WalletApi {
|
|
153
153
|
getNetworkId: GetNetworkId;
|
|
154
154
|
getUtxos: GetUtxos;
|
|
@@ -162,8 +162,8 @@ export interface WalletApi {
|
|
|
162
162
|
signData: SignData;
|
|
163
163
|
submitTx: SubmitTx;
|
|
164
164
|
}
|
|
165
|
-
export
|
|
166
|
-
export
|
|
165
|
+
export type WalletMethod = keyof WalletApi;
|
|
166
|
+
export type Cip30Wallet = {
|
|
167
167
|
enable(): Promise<WalletApi>;
|
|
168
168
|
isEnabled(): Promise<boolean>;
|
|
169
169
|
apiVersion: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-cardano-provider",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider",
|
|
6
6
|
"cardano"
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"start": "tsc --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-core": "2.0.
|
|
33
|
-
"@onekeyfe/cross-inpage-provider-errors": "2.0.
|
|
34
|
-
"@onekeyfe/cross-inpage-provider-types": "2.0.
|
|
35
|
-
"@onekeyfe/extension-bridge-injected": "2.0.
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-core": "2.0.1",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-errors": "2.0.1",
|
|
34
|
+
"@onekeyfe/cross-inpage-provider-types": "2.0.1",
|
|
35
|
+
"@onekeyfe/extension-bridge-injected": "2.0.1"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "762c20dff522f3bdd67cedcb97a5c49a97c5e3fa"
|
|
38
38
|
}
|