@onekeyfe/onekey-alph-provider 2.1.5
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/LICENSE.md +51 -0
- package/README.md +1 -0
- package/dist/OnekeyAlphProvider.d.ts +42 -0
- package/dist/OnekeyAlphProvider.js +162 -0
- package/dist/ProviderAlphBase.d.ts +8 -0
- package/dist/ProviderAlphBase.js +12 -0
- package/dist/cjs/OnekeyAlphProvider.js +166 -0
- package/dist/cjs/ProviderAlphBase.js +15 -0
- package/dist/cjs/index.js +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +40 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# ONEKEY STANDARD SOURCE LICENSE (O-SSL)
|
|
2
|
+
|
|
3
|
+
This license governs use of the accompanying software. If you use the software,
|
|
4
|
+
you accept this license. If you do not accept the license, do not use the
|
|
5
|
+
software.
|
|
6
|
+
|
|
7
|
+
## 1. Definitions
|
|
8
|
+
|
|
9
|
+
The terms "reproduce," "reproduction" and "distribution" have the same meaning
|
|
10
|
+
here as under Hong Kong copyright law.
|
|
11
|
+
|
|
12
|
+
"You" means the licensee of the software.
|
|
13
|
+
|
|
14
|
+
"Your company" means the company you worked for when you downloaded the
|
|
15
|
+
software.
|
|
16
|
+
|
|
17
|
+
"Reference use" means use of the software within your company as a reference,
|
|
18
|
+
in read only form, for the sole purposes of debugging your products,
|
|
19
|
+
maintaining your products, or enhancing the interoperability of your products
|
|
20
|
+
with the software, and specifically excludes the right to distribute the
|
|
21
|
+
software outside of your company.
|
|
22
|
+
|
|
23
|
+
"Licensed patents" means any Licensor patent claims which read directly on the
|
|
24
|
+
software as distributed by the Licensor under this license.
|
|
25
|
+
|
|
26
|
+
## 2. Grant of Rights
|
|
27
|
+
|
|
28
|
+
(A) Copyright Grant - Subject to the terms of this license, the Licensor grants
|
|
29
|
+
you a non-transferable, non-exclusive, worldwide, royalty-free copyright
|
|
30
|
+
license to reproduce the software for reference use.
|
|
31
|
+
|
|
32
|
+
(B) Patent Grant - Subject to the terms of this license, the Licensor grants
|
|
33
|
+
you a non-transferable, non-exclusive, worldwide, royalty-free patent license
|
|
34
|
+
under licensed patents for reference use.
|
|
35
|
+
|
|
36
|
+
## 3. Limitations
|
|
37
|
+
|
|
38
|
+
(A) No Trademark License - This license does not grant you any rights to use
|
|
39
|
+
the Licensor's name, logo, or trademarks.
|
|
40
|
+
|
|
41
|
+
(B) If you begin patent litigation against the Licensor over patents that you
|
|
42
|
+
think may apply to the software (including a cross-claim or counterclaim in
|
|
43
|
+
a lawsuit), your license to the software ends automatically.
|
|
44
|
+
|
|
45
|
+
(C) The software is licensed "as-is." You bear the risk of using it. The
|
|
46
|
+
Licensor gives no express warranties, guarantees or conditions. You may have
|
|
47
|
+
additional consumer rights under your local laws which this license cannot
|
|
48
|
+
change. To the extent permitted under your local laws, the Licensor excludes
|
|
49
|
+
the implied warranties of merchantability, fitness for a particular purpose and
|
|
50
|
+
non-infringement.This license agreement is governed by the laws of Hong Kong,
|
|
51
|
+
and any disputes related to this license agreement shall be resolved in accordance with Hong Kong law.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# cross-inpage-provider
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IInpageProviderConfig } from '@onekeyfe/cross-inpage-provider-core';
|
|
2
|
+
import { AlephiumWindowObject, EnableOptions, RequestMessage } from '@alephium/get-extension-wallet';
|
|
3
|
+
import { EnableOptionsBase, Account, NodeProvider, ExplorerProvider, SignDeployContractTxParams, SignDeployContractTxResult, SignExecuteScriptTxParams, SignExecuteScriptTxResult, SignTransferTxParams, SignTransferTxResult, SignUnsignedTxParams, SignUnsignedTxResult, SignMessageParams, SignMessageResult, InteractiveSignerProvider } from '@alephium/web3';
|
|
4
|
+
import { ProviderAlphBase } from './ProviderAlphBase';
|
|
5
|
+
type OneKeyTonProviderProps = IInpageProviderConfig & {
|
|
6
|
+
timeout?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare class ProviderAlph extends InteractiveSignerProvider implements AlephiumWindowObject {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
icon: string;
|
|
12
|
+
version: string;
|
|
13
|
+
_accountInfo: Account | undefined;
|
|
14
|
+
_base: ProviderAlphBase;
|
|
15
|
+
constructor(props: OneKeyTonProviderProps);
|
|
16
|
+
private bridgeRequest;
|
|
17
|
+
on(eventName: string | symbol, listener: (...args: unknown[]) => void): void;
|
|
18
|
+
off(eventName: string | symbol, listener: (...args: unknown[]) => void): void;
|
|
19
|
+
emit(eventName: string, ...args: unknown[]): boolean;
|
|
20
|
+
private _registerEvents;
|
|
21
|
+
private _handleConnected;
|
|
22
|
+
private _handleDisconnected;
|
|
23
|
+
private _isAccountsChanged;
|
|
24
|
+
private _handleAccountChange;
|
|
25
|
+
disconnect(): Promise<void>;
|
|
26
|
+
isPreauthorized(options: EnableOptions): Promise<boolean>;
|
|
27
|
+
enableIfConnected(options: EnableOptions): Promise<Account | undefined>;
|
|
28
|
+
get connectedAccount(): Account | undefined;
|
|
29
|
+
get connectedNetworkId(): "mainnet" | "testnet" | "devnet" | undefined;
|
|
30
|
+
unsafeEnable(opt?: EnableOptionsBase | undefined): Promise<Account>;
|
|
31
|
+
get nodeProvider(): NodeProvider | undefined;
|
|
32
|
+
get explorerProvider(): ExplorerProvider | undefined;
|
|
33
|
+
unsafeGetSelectedAccount(): Promise<Account>;
|
|
34
|
+
signAndSubmitDeployContractTx(params: SignDeployContractTxParams): Promise<SignDeployContractTxResult>;
|
|
35
|
+
signAndSubmitExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<SignExecuteScriptTxResult>;
|
|
36
|
+
signAndSubmitTransferTx(params: SignTransferTxParams): Promise<SignTransferTxResult>;
|
|
37
|
+
signAndSubmitUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
|
|
38
|
+
signUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
|
|
39
|
+
signMessage(params: SignMessageParams): Promise<SignMessageResult>;
|
|
40
|
+
request(message: RequestMessage): Promise<boolean>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { getOrCreateExtInjectedJsBridge } from '@onekeyfe/extension-bridge-injected';
|
|
11
|
+
import { InteractiveSignerProvider } from '@alephium/web3';
|
|
12
|
+
import { ProviderAlphBase } from './ProviderAlphBase';
|
|
13
|
+
const PROVIDER_EVENTS = {
|
|
14
|
+
'disconnect': 'disconnect',
|
|
15
|
+
'accountChanged': 'accountChanged',
|
|
16
|
+
'message_low_level': 'message_low_level',
|
|
17
|
+
};
|
|
18
|
+
function isWalletEventMethodMatch({ method, name }) {
|
|
19
|
+
return method === `wallet_events_${name}`;
|
|
20
|
+
}
|
|
21
|
+
export class ProviderAlph extends InteractiveSignerProvider {
|
|
22
|
+
constructor(props) {
|
|
23
|
+
super();
|
|
24
|
+
this.id = 'alephium';
|
|
25
|
+
this.name = 'Alephium';
|
|
26
|
+
this.icon = 'https://uni.onekey-asset.com/static/logo/onekey.png';
|
|
27
|
+
this.version = '0.0.0';
|
|
28
|
+
this._base = new ProviderAlphBase(Object.assign(Object.assign({}, props), { bridge: props.bridge || getOrCreateExtInjectedJsBridge({ timeout: props.timeout }) }));
|
|
29
|
+
this._registerEvents();
|
|
30
|
+
}
|
|
31
|
+
bridgeRequest(data) {
|
|
32
|
+
return this._base.request(data);
|
|
33
|
+
}
|
|
34
|
+
on(eventName, listener) {
|
|
35
|
+
this._base.on(eventName, listener);
|
|
36
|
+
}
|
|
37
|
+
off(eventName, listener) {
|
|
38
|
+
this._base.off(eventName, listener);
|
|
39
|
+
}
|
|
40
|
+
emit(eventName, ...args) {
|
|
41
|
+
return this._base.emit(eventName, ...args);
|
|
42
|
+
}
|
|
43
|
+
_registerEvents() {
|
|
44
|
+
window.addEventListener('onekey_bridge_disconnect', () => {
|
|
45
|
+
this._handleDisconnected();
|
|
46
|
+
});
|
|
47
|
+
this.on(PROVIDER_EVENTS.message_low_level, (payload) => {
|
|
48
|
+
if (!payload)
|
|
49
|
+
return;
|
|
50
|
+
const { method, params } = payload;
|
|
51
|
+
if (isWalletEventMethodMatch({ method, name: PROVIDER_EVENTS.accountChanged })) {
|
|
52
|
+
this._handleAccountChange(params);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
_handleConnected(accountInfo, options = { emit: true }) {
|
|
57
|
+
var _a;
|
|
58
|
+
this._accountInfo = accountInfo;
|
|
59
|
+
if (options.emit && this._base.isConnectionStatusChanged('connected')) {
|
|
60
|
+
this._base.connectionStatus = 'connected';
|
|
61
|
+
const address = (_a = accountInfo.address) !== null && _a !== void 0 ? _a : null;
|
|
62
|
+
this.emit('accountChanged', address);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
_handleDisconnected(options = { emit: true }) {
|
|
66
|
+
this._accountInfo = undefined;
|
|
67
|
+
if (options.emit && this._base.isConnectionStatusChanged('disconnected')) {
|
|
68
|
+
this._base.connectionStatus = 'disconnected';
|
|
69
|
+
this.emit('accountChanged', null);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
_isAccountsChanged(accountInfo) {
|
|
73
|
+
var _a;
|
|
74
|
+
return (accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.address) !== ((_a = this._accountInfo) === null || _a === void 0 ? void 0 : _a.address);
|
|
75
|
+
}
|
|
76
|
+
// trigger by bridge account change event
|
|
77
|
+
_handleAccountChange(payload) {
|
|
78
|
+
const accountInfo = payload;
|
|
79
|
+
if (this._isAccountsChanged(accountInfo)) {
|
|
80
|
+
this.emit('accountChanged', (accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.address) || null);
|
|
81
|
+
}
|
|
82
|
+
if (!accountInfo) {
|
|
83
|
+
this._handleDisconnected();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this._handleConnected(accountInfo, { emit: false });
|
|
87
|
+
}
|
|
88
|
+
disconnect() {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
yield this.bridgeRequest({
|
|
91
|
+
method: 'disconnect',
|
|
92
|
+
params: [],
|
|
93
|
+
});
|
|
94
|
+
this._handleDisconnected();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
isPreauthorized(options) {
|
|
98
|
+
return this.bridgeRequest({
|
|
99
|
+
method: 'isPreauthorized',
|
|
100
|
+
params: options,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
enableIfConnected(options) {
|
|
104
|
+
return this.bridgeRequest({
|
|
105
|
+
method: 'enableIfConnected',
|
|
106
|
+
params: options,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
get connectedAccount() {
|
|
110
|
+
return this._accountInfo;
|
|
111
|
+
}
|
|
112
|
+
get connectedNetworkId() {
|
|
113
|
+
return "mainnet";
|
|
114
|
+
}
|
|
115
|
+
unsafeEnable(opt) {
|
|
116
|
+
let params = {};
|
|
117
|
+
if (opt) {
|
|
118
|
+
if (opt.onDisconnected) {
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
120
|
+
this.on(PROVIDER_EVENTS.disconnect, opt.onDisconnected);
|
|
121
|
+
}
|
|
122
|
+
params = {};
|
|
123
|
+
Object.keys(opt).forEach((key) => {
|
|
124
|
+
if (opt[key] instanceof Function) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
params[key] = opt[key];
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return this.bridgeRequest({ method: 'unsafeEnable', params });
|
|
131
|
+
}
|
|
132
|
+
get nodeProvider() {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
get explorerProvider() {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
unsafeGetSelectedAccount() {
|
|
139
|
+
return this.bridgeRequest({ method: 'unsafeGetSelectedAccount' });
|
|
140
|
+
}
|
|
141
|
+
signAndSubmitDeployContractTx(params) {
|
|
142
|
+
return this.bridgeRequest({ method: 'signAndSubmitDeployContractTx', params });
|
|
143
|
+
}
|
|
144
|
+
signAndSubmitExecuteScriptTx(params) {
|
|
145
|
+
return this.bridgeRequest({ method: 'signAndSubmitExecuteScriptTx', params });
|
|
146
|
+
}
|
|
147
|
+
signAndSubmitTransferTx(params) {
|
|
148
|
+
return this.bridgeRequest({ method: 'signAndSubmitTransferTx', params });
|
|
149
|
+
}
|
|
150
|
+
signAndSubmitUnsignedTx(params) {
|
|
151
|
+
return this.bridgeRequest({ method: 'signAndSubmitUnsignedTx', params });
|
|
152
|
+
}
|
|
153
|
+
signUnsignedTx(params) {
|
|
154
|
+
return this.bridgeRequest({ method: 'signUnsignedTx', params });
|
|
155
|
+
}
|
|
156
|
+
signMessage(params) {
|
|
157
|
+
return this.bridgeRequest({ method: 'signMessage', params });
|
|
158
|
+
}
|
|
159
|
+
request(message) {
|
|
160
|
+
return this.bridgeRequest({ method: 'addNewToken', params: message.params });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types';
|
|
2
|
+
import { ProviderBase, IInpageProviderConfig } from '@onekeyfe/cross-inpage-provider-core';
|
|
3
|
+
declare class ProviderAlphBase extends ProviderBase {
|
|
4
|
+
constructor(props: IInpageProviderConfig);
|
|
5
|
+
protected providerName: IInjectedProviderNames;
|
|
6
|
+
request(data: unknown): Promise<unknown>;
|
|
7
|
+
}
|
|
8
|
+
export { ProviderAlphBase };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types';
|
|
2
|
+
import { ProviderBase } from '@onekeyfe/cross-inpage-provider-core';
|
|
3
|
+
class ProviderAlphBase extends ProviderBase {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.providerName = IInjectedProviderNames.alephium;
|
|
7
|
+
}
|
|
8
|
+
request(data) {
|
|
9
|
+
return this.bridgeRequest(data);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export { ProviderAlphBase };
|
|
@@ -0,0 +1,166 @@
|
|
|
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.ProviderAlph = void 0;
|
|
13
|
+
const extension_bridge_injected_1 = require("@onekeyfe/extension-bridge-injected");
|
|
14
|
+
const web3_1 = require("@alephium/web3");
|
|
15
|
+
const ProviderAlphBase_1 = require("./ProviderAlphBase");
|
|
16
|
+
const PROVIDER_EVENTS = {
|
|
17
|
+
'disconnect': 'disconnect',
|
|
18
|
+
'accountChanged': 'accountChanged',
|
|
19
|
+
'message_low_level': 'message_low_level',
|
|
20
|
+
};
|
|
21
|
+
function isWalletEventMethodMatch({ method, name }) {
|
|
22
|
+
return method === `wallet_events_${name}`;
|
|
23
|
+
}
|
|
24
|
+
class ProviderAlph extends web3_1.InteractiveSignerProvider {
|
|
25
|
+
constructor(props) {
|
|
26
|
+
super();
|
|
27
|
+
this.id = 'alephium';
|
|
28
|
+
this.name = 'Alephium';
|
|
29
|
+
this.icon = 'https://uni.onekey-asset.com/static/logo/onekey.png';
|
|
30
|
+
this.version = '0.0.0';
|
|
31
|
+
this._base = new ProviderAlphBase_1.ProviderAlphBase(Object.assign(Object.assign({}, props), { bridge: props.bridge || (0, extension_bridge_injected_1.getOrCreateExtInjectedJsBridge)({ timeout: props.timeout }) }));
|
|
32
|
+
this._registerEvents();
|
|
33
|
+
}
|
|
34
|
+
bridgeRequest(data) {
|
|
35
|
+
return this._base.request(data);
|
|
36
|
+
}
|
|
37
|
+
on(eventName, listener) {
|
|
38
|
+
this._base.on(eventName, listener);
|
|
39
|
+
}
|
|
40
|
+
off(eventName, listener) {
|
|
41
|
+
this._base.off(eventName, listener);
|
|
42
|
+
}
|
|
43
|
+
emit(eventName, ...args) {
|
|
44
|
+
return this._base.emit(eventName, ...args);
|
|
45
|
+
}
|
|
46
|
+
_registerEvents() {
|
|
47
|
+
window.addEventListener('onekey_bridge_disconnect', () => {
|
|
48
|
+
this._handleDisconnected();
|
|
49
|
+
});
|
|
50
|
+
this.on(PROVIDER_EVENTS.message_low_level, (payload) => {
|
|
51
|
+
if (!payload)
|
|
52
|
+
return;
|
|
53
|
+
const { method, params } = payload;
|
|
54
|
+
if (isWalletEventMethodMatch({ method, name: PROVIDER_EVENTS.accountChanged })) {
|
|
55
|
+
this._handleAccountChange(params);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
_handleConnected(accountInfo, options = { emit: true }) {
|
|
60
|
+
var _a;
|
|
61
|
+
this._accountInfo = accountInfo;
|
|
62
|
+
if (options.emit && this._base.isConnectionStatusChanged('connected')) {
|
|
63
|
+
this._base.connectionStatus = 'connected';
|
|
64
|
+
const address = (_a = accountInfo.address) !== null && _a !== void 0 ? _a : null;
|
|
65
|
+
this.emit('accountChanged', address);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
_handleDisconnected(options = { emit: true }) {
|
|
69
|
+
this._accountInfo = undefined;
|
|
70
|
+
if (options.emit && this._base.isConnectionStatusChanged('disconnected')) {
|
|
71
|
+
this._base.connectionStatus = 'disconnected';
|
|
72
|
+
this.emit('accountChanged', null);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
_isAccountsChanged(accountInfo) {
|
|
76
|
+
var _a;
|
|
77
|
+
return (accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.address) !== ((_a = this._accountInfo) === null || _a === void 0 ? void 0 : _a.address);
|
|
78
|
+
}
|
|
79
|
+
// trigger by bridge account change event
|
|
80
|
+
_handleAccountChange(payload) {
|
|
81
|
+
const accountInfo = payload;
|
|
82
|
+
if (this._isAccountsChanged(accountInfo)) {
|
|
83
|
+
this.emit('accountChanged', (accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.address) || null);
|
|
84
|
+
}
|
|
85
|
+
if (!accountInfo) {
|
|
86
|
+
this._handleDisconnected();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this._handleConnected(accountInfo, { emit: false });
|
|
90
|
+
}
|
|
91
|
+
disconnect() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
yield this.bridgeRequest({
|
|
94
|
+
method: 'disconnect',
|
|
95
|
+
params: [],
|
|
96
|
+
});
|
|
97
|
+
this._handleDisconnected();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
isPreauthorized(options) {
|
|
101
|
+
return this.bridgeRequest({
|
|
102
|
+
method: 'isPreauthorized',
|
|
103
|
+
params: options,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
enableIfConnected(options) {
|
|
107
|
+
return this.bridgeRequest({
|
|
108
|
+
method: 'enableIfConnected',
|
|
109
|
+
params: options,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
get connectedAccount() {
|
|
113
|
+
return this._accountInfo;
|
|
114
|
+
}
|
|
115
|
+
get connectedNetworkId() {
|
|
116
|
+
return "mainnet";
|
|
117
|
+
}
|
|
118
|
+
unsafeEnable(opt) {
|
|
119
|
+
let params = {};
|
|
120
|
+
if (opt) {
|
|
121
|
+
if (opt.onDisconnected) {
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
123
|
+
this.on(PROVIDER_EVENTS.disconnect, opt.onDisconnected);
|
|
124
|
+
}
|
|
125
|
+
params = {};
|
|
126
|
+
Object.keys(opt).forEach((key) => {
|
|
127
|
+
if (opt[key] instanceof Function) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
params[key] = opt[key];
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return this.bridgeRequest({ method: 'unsafeEnable', params });
|
|
134
|
+
}
|
|
135
|
+
get nodeProvider() {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
get explorerProvider() {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
unsafeGetSelectedAccount() {
|
|
142
|
+
return this.bridgeRequest({ method: 'unsafeGetSelectedAccount' });
|
|
143
|
+
}
|
|
144
|
+
signAndSubmitDeployContractTx(params) {
|
|
145
|
+
return this.bridgeRequest({ method: 'signAndSubmitDeployContractTx', params });
|
|
146
|
+
}
|
|
147
|
+
signAndSubmitExecuteScriptTx(params) {
|
|
148
|
+
return this.bridgeRequest({ method: 'signAndSubmitExecuteScriptTx', params });
|
|
149
|
+
}
|
|
150
|
+
signAndSubmitTransferTx(params) {
|
|
151
|
+
return this.bridgeRequest({ method: 'signAndSubmitTransferTx', params });
|
|
152
|
+
}
|
|
153
|
+
signAndSubmitUnsignedTx(params) {
|
|
154
|
+
return this.bridgeRequest({ method: 'signAndSubmitUnsignedTx', params });
|
|
155
|
+
}
|
|
156
|
+
signUnsignedTx(params) {
|
|
157
|
+
return this.bridgeRequest({ method: 'signUnsignedTx', params });
|
|
158
|
+
}
|
|
159
|
+
signMessage(params) {
|
|
160
|
+
return this.bridgeRequest({ method: 'signMessage', params });
|
|
161
|
+
}
|
|
162
|
+
request(message) {
|
|
163
|
+
return this.bridgeRequest({ method: 'addNewToken', params: message.params });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.ProviderAlph = ProviderAlph;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProviderAlphBase = void 0;
|
|
4
|
+
const cross_inpage_provider_types_1 = require("@onekeyfe/cross-inpage-provider-types");
|
|
5
|
+
const cross_inpage_provider_core_1 = require("@onekeyfe/cross-inpage-provider-core");
|
|
6
|
+
class ProviderAlphBase extends cross_inpage_provider_core_1.ProviderBase {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.providerName = cross_inpage_provider_types_1.IInjectedProviderNames.alephium;
|
|
10
|
+
}
|
|
11
|
+
request(data) {
|
|
12
|
+
return this.bridgeRequest(data);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ProviderAlphBase = ProviderAlphBase;
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./OnekeyAlphProvider"), exports);
|
|
18
|
+
__exportStar(require("./ProviderAlphBase"), exports);
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onekeyfe/onekey-alph-provider",
|
|
3
|
+
"version": "2.1.5",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"cross-inpage-provider"
|
|
6
|
+
],
|
|
7
|
+
"author": "dev-fe@onekey.so",
|
|
8
|
+
"repository": "https://github.com/OneKeyHQ/cross-inpage-provider",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/*"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/cjs/index.js"
|
|
21
|
+
},
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"module": "./dist/index.js",
|
|
24
|
+
"main": "./dist/cjs/index.js",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prebuild": "rm -rf dist",
|
|
27
|
+
"build": "tsc && tsc --project tsconfig.cjs.json",
|
|
28
|
+
"start": "tsc --watch"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@alephium/get-extension-wallet": "^1.5.2",
|
|
32
|
+
"@alephium/walletconnect-provider": "^1.5.2",
|
|
33
|
+
"@alephium/web3": "^1.5.2",
|
|
34
|
+
"@onekeyfe/cross-inpage-provider-core": "2.1.5",
|
|
35
|
+
"@onekeyfe/cross-inpage-provider-errors": "2.1.5",
|
|
36
|
+
"@onekeyfe/cross-inpage-provider-types": "2.1.5",
|
|
37
|
+
"@onekeyfe/extension-bridge-injected": "2.1.5"
|
|
38
|
+
},
|
|
39
|
+
"gitHead": "2946cc1c3888443baa6551ca6735a9e02ea4c123"
|
|
40
|
+
}
|