@onekeyfe/onekey-aptos-provider 1.0.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # cross-inpage-provider
@@ -0,0 +1,88 @@
1
+ import { IInpageProviderConfig } from '@onekeyfe/cross-inpage-provider-core';
2
+ import { ProviderAptosBase } from './ProviderAptosBase';
3
+ import { AptosAccountInfo, SignMessagePayload, SignMessageResponse } from './types';
4
+ import { IJsonRpcRequest } from '@onekeyfe/cross-inpage-provider-types';
5
+ import { Types } from 'aptos';
6
+ declare const PROVIDER_EVENTS: {
7
+ readonly connect: "connect";
8
+ readonly disconnect: "disconnect";
9
+ readonly accountChanged: "accountChanged";
10
+ readonly networkChange: "networkChange";
11
+ readonly message_low_level: "message_low_level";
12
+ };
13
+ declare type AptosProviderEventsMap = {
14
+ [PROVIDER_EVENTS.connect]: (account: string) => void;
15
+ [PROVIDER_EVENTS.disconnect]: () => void;
16
+ [PROVIDER_EVENTS.accountChanged]: (account: string | null) => void;
17
+ [PROVIDER_EVENTS.networkChange]: (name: string | null) => void;
18
+ [PROVIDER_EVENTS.message_low_level]: (payload: IJsonRpcRequest) => void;
19
+ };
20
+ export declare type AptosRequest = {
21
+ 'connect': () => Promise<AptosAccountInfo>;
22
+ 'disconnect': () => Promise<void>;
23
+ 'account': () => Promise<AptosAccountInfo>;
24
+ 'network': () => Promise<string>;
25
+ 'getNetworkURL': () => Promise<string>;
26
+ 'signMessage': (payload: SignMessagePayload) => Promise<SignMessageResponse>;
27
+ 'signAndSubmitTransaction': (transactions: Types.TransactionPayload) => Promise<string>;
28
+ 'signTransaction': (transactions: Types.TransactionPayload) => Promise<string>;
29
+ };
30
+ export declare type PROVIDER_EVENTS_STRINGS = keyof typeof PROVIDER_EVENTS;
31
+ export interface IProviderAptos extends ProviderAptosBase {
32
+ publicKey: string | null;
33
+ /**
34
+ * Connect wallet, and get wallet info
35
+ * @emits `connect` on success
36
+ */
37
+ connect(): Promise<AptosAccountInfo>;
38
+ isConnected(): boolean;
39
+ /**
40
+ * Disconnect wallet
41
+ */
42
+ disconnect(): Promise<void>;
43
+ /**
44
+ * Connect wallet, and get wallet info
45
+ */
46
+ account(): Promise<AptosAccountInfo>;
47
+ /**
48
+ * Sign and submit transactions
49
+ * @returns Transaction
50
+ */
51
+ signAndSubmitTransaction(transactions: any): Promise<any>;
52
+ signTransaction(transactions: any): Promise<any>;
53
+ /**
54
+ * Sign message
55
+ * @returns Transaction
56
+ */
57
+ signMessage(payload: SignMessagePayload): Promise<SignMessageResponse>;
58
+ network(): Promise<string>;
59
+ getNetworkURL(): Promise<string>;
60
+ }
61
+ declare type OneKeyAptosProviderProps = IInpageProviderConfig & {
62
+ timeout?: number;
63
+ };
64
+ declare class ProviderAptos extends ProviderAptosBase implements IProviderAptos {
65
+ protected _account: AptosAccountInfo | null;
66
+ get publicKey(): string | null;
67
+ constructor(props: OneKeyAptosProviderProps);
68
+ private _registerEvents;
69
+ private _callBridge;
70
+ private _handleConnected;
71
+ private _handleDisconnected;
72
+ private _handleAccountChange;
73
+ private _handleNetworkChange;
74
+ connect(): Promise<AptosAccountInfo>;
75
+ isConnected(): boolean;
76
+ account(): Promise<AptosAccountInfo>;
77
+ signAndSubmitTransaction(transactions: any): Promise<any>;
78
+ signTransaction(transactions: any): Promise<any>;
79
+ signMessage(payload: SignMessagePayload): Promise<SignMessageResponse>;
80
+ network(): Promise<string>;
81
+ getNetworkURL(): Promise<string>;
82
+ disconnect(): Promise<void>;
83
+ onNetworkChange(listener: AptosProviderEventsMap['networkChange']): this;
84
+ onAccountChange(listener: AptosProviderEventsMap['accountChanged']): this;
85
+ on<E extends keyof AptosProviderEventsMap>(event: E, listener: AptosProviderEventsMap[E]): this;
86
+ emit<E extends keyof AptosProviderEventsMap>(event: E, ...args: Parameters<AptosProviderEventsMap[E]>): boolean;
87
+ }
88
+ export { ProviderAptos };
@@ -0,0 +1,166 @@
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 '../../../extension/extension-bridge-injected/dist';
11
+ import { ProviderAptosBase } from './ProviderAptosBase';
12
+ import { web3Errors } from '@onekeyfe/cross-inpage-provider-errors';
13
+ const PROVIDER_EVENTS = {
14
+ 'connect': 'connect',
15
+ 'disconnect': 'disconnect',
16
+ 'accountChanged': 'accountChanged',
17
+ 'networkChange': 'networkChange',
18
+ 'message_low_level': 'message_low_level',
19
+ };
20
+ function isWalletEventMethodMatch({ method, name }) {
21
+ return method === `wallet_events_${name}`;
22
+ }
23
+ class ProviderAptos extends ProviderAptosBase {
24
+ constructor(props) {
25
+ super(Object.assign(Object.assign({}, props), { bridge: props.bridge || getOrCreateExtInjectedJsBridge({ timeout: props.timeout }) }));
26
+ this._account = null;
27
+ this._registerEvents();
28
+ }
29
+ get publicKey() {
30
+ var _a, _b;
31
+ return (_b = (_a = this._account) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : null;
32
+ }
33
+ _registerEvents() {
34
+ window.addEventListener('onekey_bridge_disconnect', () => {
35
+ this._handleDisconnected();
36
+ });
37
+ this.on(PROVIDER_EVENTS.message_low_level, (payload) => {
38
+ const { method, params } = payload;
39
+ if (isWalletEventMethodMatch({ method, name: PROVIDER_EVENTS.accountChanged })) {
40
+ this._handleAccountChange(params);
41
+ }
42
+ if (isWalletEventMethodMatch({ method, name: PROVIDER_EVENTS.networkChange })) {
43
+ this._handleNetworkChange(params);
44
+ }
45
+ });
46
+ }
47
+ _callBridge(params) {
48
+ return this.bridgeRequest(params);
49
+ }
50
+ _handleConnected(account, options = { emit: true }) {
51
+ var _a;
52
+ this._account = account;
53
+ options.emit && this.emit('connect', (_a = account === null || account === void 0 ? void 0 : account.address) !== null && _a !== void 0 ? _a : null);
54
+ }
55
+ _handleDisconnected(options = { emit: true }) {
56
+ this._account = null;
57
+ options.emit && this.emit('disconnect');
58
+ }
59
+ // trigger by bridge account change event
60
+ _handleAccountChange(payload) {
61
+ var _a;
62
+ const account = payload;
63
+ if (!account) {
64
+ this._handleDisconnected();
65
+ return this.emit('accountChanged', null);
66
+ }
67
+ this._handleConnected(account, { emit: false });
68
+ this.emit('accountChanged', (_a = account === null || account === void 0 ? void 0 : account.address) !== null && _a !== void 0 ? _a : null);
69
+ }
70
+ _handleNetworkChange(payload) {
71
+ const network = payload;
72
+ this.emit('networkChange', network !== null && network !== void 0 ? network : null);
73
+ }
74
+ connect() {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ if (this._account) {
77
+ return Promise.resolve(this._account);
78
+ }
79
+ const result = yield this._callBridge({
80
+ method: 'connect',
81
+ params: undefined,
82
+ });
83
+ if (!result)
84
+ throw web3Errors.provider.unauthorized();
85
+ this._handleConnected(result, { emit: true });
86
+ return result;
87
+ });
88
+ }
89
+ isConnected() {
90
+ return this._account !== null;
91
+ }
92
+ account() {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const res = yield this._callBridge({
95
+ method: 'account',
96
+ params: undefined,
97
+ });
98
+ if (!res)
99
+ throw web3Errors.provider.unauthorized();
100
+ return Promise.resolve(res);
101
+ });
102
+ }
103
+ signAndSubmitTransaction(transactions) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ const res = yield this._callBridge({
106
+ method: 'signAndSubmitTransaction',
107
+ params: transactions,
108
+ });
109
+ if (!res)
110
+ throw web3Errors.provider.unauthorized();
111
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
112
+ return JSON.parse(res);
113
+ });
114
+ }
115
+ signTransaction(transactions) {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ const res = yield this._callBridge({
118
+ method: 'signTransaction',
119
+ params: transactions,
120
+ });
121
+ if (!res)
122
+ throw web3Errors.provider.unauthorized();
123
+ return new Uint8Array(Buffer.from(res, 'hex'));
124
+ });
125
+ }
126
+ signMessage(payload) {
127
+ return this._callBridge({
128
+ method: 'signMessage',
129
+ params: payload,
130
+ });
131
+ }
132
+ network() {
133
+ return this._callBridge({
134
+ method: 'network',
135
+ params: undefined,
136
+ });
137
+ }
138
+ getNetworkURL() {
139
+ return this._callBridge({
140
+ method: 'getNetworkURL',
141
+ params: undefined,
142
+ });
143
+ }
144
+ disconnect() {
145
+ return __awaiter(this, void 0, void 0, function* () {
146
+ yield this._callBridge({
147
+ method: 'disconnect',
148
+ params: void 0,
149
+ });
150
+ this._handleDisconnected();
151
+ });
152
+ }
153
+ onNetworkChange(listener) {
154
+ return super.on(PROVIDER_EVENTS.networkChange, listener);
155
+ }
156
+ onAccountChange(listener) {
157
+ return super.on(PROVIDER_EVENTS.accountChanged, listener);
158
+ }
159
+ on(event, listener) {
160
+ return super.on(event, listener);
161
+ }
162
+ emit(event, ...args) {
163
+ return super.emit(event, ...args);
164
+ }
165
+ }
166
+ export { ProviderAptos };
@@ -0,0 +1,56 @@
1
+ import { IInpageProviderConfig } from '@onekeyfe/cross-inpage-provider-core';
2
+ import { Types, MaybeHexString } from 'aptos';
3
+ import { TxnPayload, TxnOptions } from './types';
4
+ import { ProviderAptos } from './OnekeyAptosProvider';
5
+ export declare type AptosRequestMartian = {
6
+ 'martianSignAndSubmitTransaction': (transactions: string) => Promise<string>;
7
+ 'martianSignTransaction': (transactions: string) => Promise<string>;
8
+ 'signAndSubmitTransaction': (transactions: Types.TransactionPayload) => Promise<string>;
9
+ 'signTransaction': (transactions: Types.TransactionPayload) => Promise<string>;
10
+ 'signGenericTransaction': (transaction: {
11
+ func: string;
12
+ args: any[];
13
+ type_args: any[];
14
+ }) => Promise<string>;
15
+ 'createCollection': (name: string, description: string, uri: string, maxAmount: string) => Promise<string>;
16
+ 'createToken': (collectionName: string, name: string, description: string, supply: number, uri: string, max: string, royalty_payee_address: string, royalty_points_denominator: number, royalty_points_numerator: number, property_keys: Array<string>, property_values: Array<string>, property_types: Array<string>) => Promise<string>;
17
+ };
18
+ declare type OneKeyAptosProviderProps = IInpageProviderConfig & {
19
+ timeout?: number;
20
+ };
21
+ declare class ProviderAptosMartian extends ProviderAptos {
22
+ readonly isMartian = true;
23
+ get publicKey(): string | null;
24
+ constructor(props: OneKeyAptosProviderProps);
25
+ private getClient;
26
+ private _callMartianBridge;
27
+ signAndSubmitTransaction(transaction: string | Types.TransactionPayload): Promise<string | Types.Transaction>;
28
+ signTransaction(transaction: string | Types.TransactionPayload): Promise<string | Uint8Array>;
29
+ signGenericTransaction(transaction: {
30
+ func: string;
31
+ args: any[];
32
+ type_args: any[];
33
+ }): Promise<string>;
34
+ generateSignAndSubmitTransaction(sender: string, payload: TxnPayload, options?: TxnOptions): Promise<string>;
35
+ createCollection(name: string, description: string, uri: string): Promise<string>;
36
+ createToken(collectionName: string, name: string, description: string, supply: number, uri: string, max?: number | bigint, royalty_payee_address?: string, royalty_points_denominator?: number, royalty_points_numerator?: number, property_keys?: Array<string>, property_values?: Array<string>, property_types?: Array<string>): Promise<string>;
37
+ generateTransaction(sender: string, payload: TxnPayload, options?: TxnOptions): Promise<string>;
38
+ private _convertStringToUint8Array;
39
+ submitTransaction(transaction: Uint8Array | string): Promise<string>;
40
+ getTransactions(query?: {
41
+ start?: BigInt | number;
42
+ limit?: number;
43
+ }): Promise<Types.Transaction[]>;
44
+ getTransaction(txnHash: string): Promise<Types.Transaction>;
45
+ getAccountTransactions(accountAddress: MaybeHexString, query?: {
46
+ start?: BigInt | number;
47
+ limit?: number;
48
+ }): Promise<Types.Transaction[]>;
49
+ getAccountResources(accountAddress: MaybeHexString, query?: {
50
+ ledgerVersion?: BigInt | number;
51
+ }): Promise<Types.MoveResource[]>;
52
+ getAccount(accountAddress: MaybeHexString): Promise<Types.AccountData>;
53
+ getChainId(): Promise<number>;
54
+ getLedgerInfo(): Promise<Types.IndexResponse>;
55
+ }
56
+ export { ProviderAptosMartian };
@@ -0,0 +1,189 @@
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 '../../../extension/extension-bridge-injected/dist';
11
+ import { AptosClient, BCS } from 'aptos';
12
+ import { ProviderAptos } from './OnekeyAptosProvider';
13
+ import { web3Errors } from '@onekeyfe/cross-inpage-provider-errors';
14
+ class ProviderAptosMartian extends ProviderAptos {
15
+ constructor(props) {
16
+ super(Object.assign(Object.assign({}, props), { bridge: props.bridge || getOrCreateExtInjectedJsBridge({ timeout: props.timeout }) }));
17
+ this.isMartian = true;
18
+ window.dispatchEvent(new Event('martian#initialized'));
19
+ }
20
+ get publicKey() {
21
+ var _a, _b;
22
+ return (_b = (_a = this._account) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : null;
23
+ }
24
+ getClient() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return new AptosClient(yield this.getNetworkURL());
27
+ });
28
+ }
29
+ _callMartianBridge(params) {
30
+ return this.bridgeRequest(params);
31
+ }
32
+ signAndSubmitTransaction(transaction) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ if (typeof transaction === 'string') {
35
+ return yield this._callMartianBridge({
36
+ method: 'martianSignAndSubmitTransaction',
37
+ params: transaction,
38
+ });
39
+ }
40
+ else {
41
+ const res = yield this._callMartianBridge({
42
+ method: 'signAndSubmitTransaction',
43
+ params: transaction,
44
+ });
45
+ if (!res)
46
+ throw web3Errors.provider.unauthorized();
47
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
48
+ return JSON.parse(res);
49
+ }
50
+ });
51
+ }
52
+ signTransaction(transaction) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ if (typeof transaction === 'string') {
55
+ return this._callMartianBridge({
56
+ method: 'martianSignTransaction',
57
+ params: transaction,
58
+ });
59
+ }
60
+ else {
61
+ const res = yield this._callMartianBridge({
62
+ method: 'signTransaction',
63
+ params: transaction,
64
+ });
65
+ if (!res)
66
+ throw web3Errors.provider.unauthorized();
67
+ return new Uint8Array(Buffer.from(res, 'hex'));
68
+ }
69
+ });
70
+ }
71
+ signGenericTransaction(transaction) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ return this._callMartianBridge({
74
+ method: 'signGenericTransaction',
75
+ params: {
76
+ func: transaction.func,
77
+ args: transaction.args,
78
+ type_args: transaction.type_args,
79
+ },
80
+ });
81
+ });
82
+ }
83
+ generateSignAndSubmitTransaction(sender, payload, options) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ const txn = yield this.generateTransaction(sender, payload, options);
86
+ const txnHash = yield this.signAndSubmitTransaction(txn);
87
+ return txnHash;
88
+ });
89
+ }
90
+ createCollection(name, description, uri) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ return this._callMartianBridge({
93
+ method: 'createCollection',
94
+ // @ts-expect-error
95
+ params: {
96
+ name,
97
+ description,
98
+ uri,
99
+ },
100
+ });
101
+ });
102
+ }
103
+ createToken(collectionName, name, description, supply, uri, max, royalty_payee_address, royalty_points_denominator, royalty_points_numerator, property_keys, property_values, property_types) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ return this._callMartianBridge({
106
+ method: 'createToken',
107
+ // @ts-expect-error
108
+ params: {
109
+ collectionName,
110
+ name,
111
+ description,
112
+ supply,
113
+ uri,
114
+ max,
115
+ royalty_payee_address,
116
+ royalty_points_denominator,
117
+ royalty_points_numerator,
118
+ property_keys,
119
+ property_values,
120
+ property_types,
121
+ },
122
+ });
123
+ });
124
+ }
125
+ // rpc
126
+ generateTransaction(sender, payload, options) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ const client = yield this.getClient();
129
+ const rawTx = yield client.generateTransaction(sender, payload, options);
130
+ const serializer = new BCS.Serializer();
131
+ rawTx.serialize(serializer);
132
+ return serializer.getBytes().toString();
133
+ });
134
+ }
135
+ _convertStringToUint8Array(array) {
136
+ return new Uint8Array(array.split(',').map((item) => parseInt(item, 10)));
137
+ }
138
+ submitTransaction(transaction) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ const signedTxn = typeof transaction === 'string' ? this._convertStringToUint8Array(transaction) : transaction;
141
+ const client = yield this.getClient();
142
+ const res = yield client.submitTransaction(signedTxn);
143
+ return res.hash;
144
+ });
145
+ }
146
+ getTransactions(query) {
147
+ return __awaiter(this, void 0, void 0, function* () {
148
+ const client = yield this.getClient();
149
+ return client.getTransactions(query);
150
+ });
151
+ }
152
+ getTransaction(txnHash) {
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ const client = yield this.getClient();
155
+ return client.getTransactionByHash(txnHash);
156
+ });
157
+ }
158
+ getAccountTransactions(accountAddress, query) {
159
+ return __awaiter(this, void 0, void 0, function* () {
160
+ const client = yield this.getClient();
161
+ return client.getAccountTransactions(accountAddress, query);
162
+ });
163
+ }
164
+ getAccountResources(accountAddress, query) {
165
+ return __awaiter(this, void 0, void 0, function* () {
166
+ const client = yield this.getClient();
167
+ return client.getAccountResources(accountAddress, query);
168
+ });
169
+ }
170
+ getAccount(accountAddress) {
171
+ return __awaiter(this, void 0, void 0, function* () {
172
+ const client = yield this.getClient();
173
+ return client.getAccount(accountAddress);
174
+ });
175
+ }
176
+ getChainId() {
177
+ return __awaiter(this, void 0, void 0, function* () {
178
+ const client = yield this.getClient();
179
+ return client.getChainId();
180
+ });
181
+ }
182
+ getLedgerInfo() {
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ const client = yield this.getClient();
185
+ return client.getLedgerInfo();
186
+ });
187
+ }
188
+ }
189
+ export { ProviderAptosMartian };
@@ -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 ProviderAptosBase extends ProviderBase {
4
+ constructor(props: IInpageProviderConfig);
5
+ protected providerName: IInjectedProviderNames;
6
+ request(data: unknown): Promise<unknown>;
7
+ }
8
+ export { ProviderAptosBase };
@@ -0,0 +1,12 @@
1
+ import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types';
2
+ import { ProviderBase } from '@onekeyfe/cross-inpage-provider-core';
3
+ class ProviderAptosBase extends ProviderBase {
4
+ constructor(props) {
5
+ super(props);
6
+ this.providerName = IInjectedProviderNames.aptos;
7
+ }
8
+ request(data) {
9
+ return this.bridgeRequest(data);
10
+ }
11
+ }
12
+ export { ProviderAptosBase };
@@ -0,0 +1,169 @@
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.ProviderAptos = void 0;
13
+ const dist_1 = require("../../../extension/extension-bridge-injected/dist");
14
+ const ProviderAptosBase_1 = require("./ProviderAptosBase");
15
+ const cross_inpage_provider_errors_1 = require("@onekeyfe/cross-inpage-provider-errors");
16
+ const PROVIDER_EVENTS = {
17
+ 'connect': 'connect',
18
+ 'disconnect': 'disconnect',
19
+ 'accountChanged': 'accountChanged',
20
+ 'networkChange': 'networkChange',
21
+ 'message_low_level': 'message_low_level',
22
+ };
23
+ function isWalletEventMethodMatch({ method, name }) {
24
+ return method === `wallet_events_${name}`;
25
+ }
26
+ class ProviderAptos extends ProviderAptosBase_1.ProviderAptosBase {
27
+ constructor(props) {
28
+ super(Object.assign(Object.assign({}, props), { bridge: props.bridge || (0, dist_1.getOrCreateExtInjectedJsBridge)({ timeout: props.timeout }) }));
29
+ this._account = null;
30
+ this._registerEvents();
31
+ }
32
+ get publicKey() {
33
+ var _a, _b;
34
+ return (_b = (_a = this._account) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : null;
35
+ }
36
+ _registerEvents() {
37
+ window.addEventListener('onekey_bridge_disconnect', () => {
38
+ this._handleDisconnected();
39
+ });
40
+ this.on(PROVIDER_EVENTS.message_low_level, (payload) => {
41
+ const { method, params } = payload;
42
+ if (isWalletEventMethodMatch({ method, name: PROVIDER_EVENTS.accountChanged })) {
43
+ this._handleAccountChange(params);
44
+ }
45
+ if (isWalletEventMethodMatch({ method, name: PROVIDER_EVENTS.networkChange })) {
46
+ this._handleNetworkChange(params);
47
+ }
48
+ });
49
+ }
50
+ _callBridge(params) {
51
+ return this.bridgeRequest(params);
52
+ }
53
+ _handleConnected(account, options = { emit: true }) {
54
+ var _a;
55
+ this._account = account;
56
+ options.emit && this.emit('connect', (_a = account === null || account === void 0 ? void 0 : account.address) !== null && _a !== void 0 ? _a : null);
57
+ }
58
+ _handleDisconnected(options = { emit: true }) {
59
+ this._account = null;
60
+ options.emit && this.emit('disconnect');
61
+ }
62
+ // trigger by bridge account change event
63
+ _handleAccountChange(payload) {
64
+ var _a;
65
+ const account = payload;
66
+ if (!account) {
67
+ this._handleDisconnected();
68
+ return this.emit('accountChanged', null);
69
+ }
70
+ this._handleConnected(account, { emit: false });
71
+ this.emit('accountChanged', (_a = account === null || account === void 0 ? void 0 : account.address) !== null && _a !== void 0 ? _a : null);
72
+ }
73
+ _handleNetworkChange(payload) {
74
+ const network = payload;
75
+ this.emit('networkChange', network !== null && network !== void 0 ? network : null);
76
+ }
77
+ connect() {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ if (this._account) {
80
+ return Promise.resolve(this._account);
81
+ }
82
+ const result = yield this._callBridge({
83
+ method: 'connect',
84
+ params: undefined,
85
+ });
86
+ if (!result)
87
+ throw cross_inpage_provider_errors_1.web3Errors.provider.unauthorized();
88
+ this._handleConnected(result, { emit: true });
89
+ return result;
90
+ });
91
+ }
92
+ isConnected() {
93
+ return this._account !== null;
94
+ }
95
+ account() {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const res = yield this._callBridge({
98
+ method: 'account',
99
+ params: undefined,
100
+ });
101
+ if (!res)
102
+ throw cross_inpage_provider_errors_1.web3Errors.provider.unauthorized();
103
+ return Promise.resolve(res);
104
+ });
105
+ }
106
+ signAndSubmitTransaction(transactions) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ const res = yield this._callBridge({
109
+ method: 'signAndSubmitTransaction',
110
+ params: transactions,
111
+ });
112
+ if (!res)
113
+ throw cross_inpage_provider_errors_1.web3Errors.provider.unauthorized();
114
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
115
+ return JSON.parse(res);
116
+ });
117
+ }
118
+ signTransaction(transactions) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ const res = yield this._callBridge({
121
+ method: 'signTransaction',
122
+ params: transactions,
123
+ });
124
+ if (!res)
125
+ throw cross_inpage_provider_errors_1.web3Errors.provider.unauthorized();
126
+ return new Uint8Array(Buffer.from(res, 'hex'));
127
+ });
128
+ }
129
+ signMessage(payload) {
130
+ return this._callBridge({
131
+ method: 'signMessage',
132
+ params: payload,
133
+ });
134
+ }
135
+ network() {
136
+ return this._callBridge({
137
+ method: 'network',
138
+ params: undefined,
139
+ });
140
+ }
141
+ getNetworkURL() {
142
+ return this._callBridge({
143
+ method: 'getNetworkURL',
144
+ params: undefined,
145
+ });
146
+ }
147
+ disconnect() {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ yield this._callBridge({
150
+ method: 'disconnect',
151
+ params: void 0,
152
+ });
153
+ this._handleDisconnected();
154
+ });
155
+ }
156
+ onNetworkChange(listener) {
157
+ return super.on(PROVIDER_EVENTS.networkChange, listener);
158
+ }
159
+ onAccountChange(listener) {
160
+ return super.on(PROVIDER_EVENTS.accountChanged, listener);
161
+ }
162
+ on(event, listener) {
163
+ return super.on(event, listener);
164
+ }
165
+ emit(event, ...args) {
166
+ return super.emit(event, ...args);
167
+ }
168
+ }
169
+ exports.ProviderAptos = ProviderAptos;
@@ -0,0 +1,192 @@
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.ProviderAptosMartian = void 0;
13
+ const dist_1 = require("../../../extension/extension-bridge-injected/dist");
14
+ const aptos_1 = require("aptos");
15
+ const OnekeyAptosProvider_1 = require("./OnekeyAptosProvider");
16
+ const cross_inpage_provider_errors_1 = require("@onekeyfe/cross-inpage-provider-errors");
17
+ class ProviderAptosMartian extends OnekeyAptosProvider_1.ProviderAptos {
18
+ constructor(props) {
19
+ super(Object.assign(Object.assign({}, props), { bridge: props.bridge || (0, dist_1.getOrCreateExtInjectedJsBridge)({ timeout: props.timeout }) }));
20
+ this.isMartian = true;
21
+ window.dispatchEvent(new Event('martian#initialized'));
22
+ }
23
+ get publicKey() {
24
+ var _a, _b;
25
+ return (_b = (_a = this._account) === null || _a === void 0 ? void 0 : _a.publicKey) !== null && _b !== void 0 ? _b : null;
26
+ }
27
+ getClient() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return new aptos_1.AptosClient(yield this.getNetworkURL());
30
+ });
31
+ }
32
+ _callMartianBridge(params) {
33
+ return this.bridgeRequest(params);
34
+ }
35
+ signAndSubmitTransaction(transaction) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ if (typeof transaction === 'string') {
38
+ return yield this._callMartianBridge({
39
+ method: 'martianSignAndSubmitTransaction',
40
+ params: transaction,
41
+ });
42
+ }
43
+ else {
44
+ const res = yield this._callMartianBridge({
45
+ method: 'signAndSubmitTransaction',
46
+ params: transaction,
47
+ });
48
+ if (!res)
49
+ throw cross_inpage_provider_errors_1.web3Errors.provider.unauthorized();
50
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
51
+ return JSON.parse(res);
52
+ }
53
+ });
54
+ }
55
+ signTransaction(transaction) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ if (typeof transaction === 'string') {
58
+ return this._callMartianBridge({
59
+ method: 'martianSignTransaction',
60
+ params: transaction,
61
+ });
62
+ }
63
+ else {
64
+ const res = yield this._callMartianBridge({
65
+ method: 'signTransaction',
66
+ params: transaction,
67
+ });
68
+ if (!res)
69
+ throw cross_inpage_provider_errors_1.web3Errors.provider.unauthorized();
70
+ return new Uint8Array(Buffer.from(res, 'hex'));
71
+ }
72
+ });
73
+ }
74
+ signGenericTransaction(transaction) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ return this._callMartianBridge({
77
+ method: 'signGenericTransaction',
78
+ params: {
79
+ func: transaction.func,
80
+ args: transaction.args,
81
+ type_args: transaction.type_args,
82
+ },
83
+ });
84
+ });
85
+ }
86
+ generateSignAndSubmitTransaction(sender, payload, options) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const txn = yield this.generateTransaction(sender, payload, options);
89
+ const txnHash = yield this.signAndSubmitTransaction(txn);
90
+ return txnHash;
91
+ });
92
+ }
93
+ createCollection(name, description, uri) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ return this._callMartianBridge({
96
+ method: 'createCollection',
97
+ // @ts-expect-error
98
+ params: {
99
+ name,
100
+ description,
101
+ uri,
102
+ },
103
+ });
104
+ });
105
+ }
106
+ createToken(collectionName, name, description, supply, uri, max, royalty_payee_address, royalty_points_denominator, royalty_points_numerator, property_keys, property_values, property_types) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ return this._callMartianBridge({
109
+ method: 'createToken',
110
+ // @ts-expect-error
111
+ params: {
112
+ collectionName,
113
+ name,
114
+ description,
115
+ supply,
116
+ uri,
117
+ max,
118
+ royalty_payee_address,
119
+ royalty_points_denominator,
120
+ royalty_points_numerator,
121
+ property_keys,
122
+ property_values,
123
+ property_types,
124
+ },
125
+ });
126
+ });
127
+ }
128
+ // rpc
129
+ generateTransaction(sender, payload, options) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const client = yield this.getClient();
132
+ const rawTx = yield client.generateTransaction(sender, payload, options);
133
+ const serializer = new aptos_1.BCS.Serializer();
134
+ rawTx.serialize(serializer);
135
+ return serializer.getBytes().toString();
136
+ });
137
+ }
138
+ _convertStringToUint8Array(array) {
139
+ return new Uint8Array(array.split(',').map((item) => parseInt(item, 10)));
140
+ }
141
+ submitTransaction(transaction) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ const signedTxn = typeof transaction === 'string' ? this._convertStringToUint8Array(transaction) : transaction;
144
+ const client = yield this.getClient();
145
+ const res = yield client.submitTransaction(signedTxn);
146
+ return res.hash;
147
+ });
148
+ }
149
+ getTransactions(query) {
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ const client = yield this.getClient();
152
+ return client.getTransactions(query);
153
+ });
154
+ }
155
+ getTransaction(txnHash) {
156
+ return __awaiter(this, void 0, void 0, function* () {
157
+ const client = yield this.getClient();
158
+ return client.getTransactionByHash(txnHash);
159
+ });
160
+ }
161
+ getAccountTransactions(accountAddress, query) {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ const client = yield this.getClient();
164
+ return client.getAccountTransactions(accountAddress, query);
165
+ });
166
+ }
167
+ getAccountResources(accountAddress, query) {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ const client = yield this.getClient();
170
+ return client.getAccountResources(accountAddress, query);
171
+ });
172
+ }
173
+ getAccount(accountAddress) {
174
+ return __awaiter(this, void 0, void 0, function* () {
175
+ const client = yield this.getClient();
176
+ return client.getAccount(accountAddress);
177
+ });
178
+ }
179
+ getChainId() {
180
+ return __awaiter(this, void 0, void 0, function* () {
181
+ const client = yield this.getClient();
182
+ return client.getChainId();
183
+ });
184
+ }
185
+ getLedgerInfo() {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ const client = yield this.getClient();
188
+ return client.getLedgerInfo();
189
+ });
190
+ }
191
+ }
192
+ exports.ProviderAptosMartian = ProviderAptosMartian;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProviderAptosBase = 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 ProviderAptosBase extends cross_inpage_provider_core_1.ProviderBase {
7
+ constructor(props) {
8
+ super(props);
9
+ this.providerName = cross_inpage_provider_types_1.IInjectedProviderNames.aptos;
10
+ }
11
+ request(data) {
12
+ return this.bridgeRequest(data);
13
+ }
14
+ }
15
+ exports.ProviderAptosBase = ProviderAptosBase;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./OnekeyAptosProvider"), exports);
14
+ __exportStar(require("./OnekeyMartianAptosProvider"), exports);
15
+ __exportStar(require("./ProviderAptosBase"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from './OnekeyAptosProvider';
2
+ export * from './OnekeyMartianAptosProvider';
3
+ export * from './ProviderAptosBase';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './OnekeyAptosProvider';
2
+ export * from './OnekeyMartianAptosProvider';
3
+ export * from './ProviderAptosBase';
@@ -0,0 +1,4 @@
1
+ export declare type WireStringified<T> = T extends Array<infer P> ? Array<WireStringified<P>> : T extends object ? {
2
+ [K in keyof T]: WireStringified<T[K]>;
3
+ } : T;
4
+ export declare type ResolvePromise<T> = T extends Promise<infer P> ? P : T;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ export declare type AptosAccountInfo = {
2
+ publicKey: string;
3
+ address: string;
4
+ };
5
+ export declare type TxnOptions = {
6
+ sender?: string;
7
+ sequence_number?: string;
8
+ max_gas_amount?: string;
9
+ gas_unit_price?: string;
10
+ gas_currency_code?: string;
11
+ expiration_timestamp_secs?: string;
12
+ };
13
+ export declare type TxnPayload = {
14
+ function: string;
15
+ type_arguments: any[];
16
+ arguments: any[];
17
+ };
18
+ export interface SignMessagePayload {
19
+ address?: boolean;
20
+ application?: boolean;
21
+ chainId?: boolean;
22
+ message: string;
23
+ nonce: number;
24
+ }
25
+ export interface SignMessageResponse {
26
+ address?: string;
27
+ application?: string;
28
+ chainId?: number;
29
+ fullMessage: string;
30
+ message: string;
31
+ nonce: number;
32
+ prefix: string;
33
+ signature: string;
34
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@onekeyfe/onekey-aptos-provider",
3
+ "version": "1.0.2",
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
+ "@onekeyfe/cross-inpage-provider-core": "1.0.2",
32
+ "@onekeyfe/cross-inpage-provider-errors": "1.0.2",
33
+ "@onekeyfe/cross-inpage-provider-types": "1.0.2",
34
+ "@onekeyfe/extension-bridge-injected": "1.0.2",
35
+ "aptos": "^1.3.13",
36
+ "eth-rpc-errors": "^4.0.3"
37
+ },
38
+ "gitHead": "3d3af2ad5ed8ad82a22f6a80b162b26a85896fa0"
39
+ }