@onekeyfe/onekey-aptos-provider 2.2.14 → 2.2.17
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.
|
@@ -94,9 +94,10 @@ class ProviderAptos extends ProviderAptosBase {
|
|
|
94
94
|
}
|
|
95
95
|
// trigger by bridge account change event
|
|
96
96
|
_handleAccountChange(payload) {
|
|
97
|
+
var _a;
|
|
97
98
|
const account = payload;
|
|
98
99
|
if (this.isAccountsChanged(account)) {
|
|
99
|
-
this.emit('accountChanged', (account === null || account === void 0 ? void 0 : account.address)
|
|
100
|
+
this.emit('accountChanged', (_a = account === null || account === void 0 ? void 0 : account.address) !== null && _a !== void 0 ? _a : null);
|
|
100
101
|
this.emit('accountChangedV2', account);
|
|
101
102
|
}
|
|
102
103
|
if (!account) {
|
|
@@ -44,7 +44,8 @@ declare class ProviderAptosMartian extends ProviderAptos {
|
|
|
44
44
|
constructor(props: OneKeyAptosProviderProps);
|
|
45
45
|
private _callMartianBridge;
|
|
46
46
|
signAndSubmitTransaction(transaction: string | Types.TransactionPayload): Promise<string | Types.Transaction>;
|
|
47
|
-
|
|
47
|
+
hasStandardV2SignTransaction(transaction: string | Types.TransactionPayload): boolean;
|
|
48
|
+
signTransaction(transaction: string | Types.TransactionPayload, asFeePayer?: boolean): Promise<string | Uint8Array>;
|
|
48
49
|
signGenericTransaction(transaction: {
|
|
49
50
|
func: string;
|
|
50
51
|
args: any[];
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { getOrCreateExtInjectedJsBridge } from '@onekeyfe/extension-bridge-injected';
|
|
11
11
|
import { ProviderAptos } from './OnekeyAptosProvider';
|
|
12
12
|
import { web3Errors } from '@onekeyfe/cross-inpage-provider-errors';
|
|
13
|
+
import { get } from 'lodash';
|
|
13
14
|
class ProviderAptosMartian extends ProviderAptos {
|
|
14
15
|
get publicKey() {
|
|
15
16
|
var _a, _b;
|
|
@@ -44,7 +45,17 @@ class ProviderAptosMartian extends ProviderAptos {
|
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
hasStandardV2SignTransaction(transaction) {
|
|
49
|
+
if (typeof transaction === 'object' &&
|
|
50
|
+
'bcsToHex' in transaction &&
|
|
51
|
+
'rawTransaction' in transaction) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
signTransaction(transaction,
|
|
57
|
+
// V2 sign transaction as fee payer
|
|
58
|
+
asFeePayer) {
|
|
48
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
60
|
if (typeof transaction === 'string') {
|
|
50
61
|
return this._callMartianBridge({
|
|
@@ -53,13 +64,35 @@ class ProviderAptosMartian extends ProviderAptos {
|
|
|
53
64
|
});
|
|
54
65
|
}
|
|
55
66
|
else {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
// aptos standard wallet v2
|
|
68
|
+
// adapter @aptos-labs/wallet-adapter-core 3.x
|
|
69
|
+
if (this.hasStandardV2SignTransaction(transaction)) {
|
|
70
|
+
let transactionType;
|
|
71
|
+
if (get(transaction, 'rawTransaction.secondarySignerAddresses')) {
|
|
72
|
+
transactionType = 'multi_agent';
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
transactionType = 'simple';
|
|
76
|
+
}
|
|
77
|
+
// @ts-expect-error
|
|
78
|
+
return this.signTransactionV2({
|
|
79
|
+
// @ts-expect-error
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
81
|
+
transaction: transaction.bcsToHex().toStringWithoutPrefix(),
|
|
82
|
+
transactionType,
|
|
83
|
+
asFeePayer,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// aptos V1 sign transaction
|
|
88
|
+
const res = yield this._callMartianBridge({
|
|
89
|
+
method: 'signTransaction',
|
|
90
|
+
params: transaction,
|
|
91
|
+
});
|
|
92
|
+
if (!res)
|
|
93
|
+
throw web3Errors.provider.unauthorized();
|
|
94
|
+
return new Uint8Array(Buffer.from(res, 'hex'));
|
|
95
|
+
}
|
|
63
96
|
}
|
|
64
97
|
});
|
|
65
98
|
}
|
|
@@ -97,9 +97,10 @@ class ProviderAptos extends ProviderAptosBase_1.ProviderAptosBase {
|
|
|
97
97
|
}
|
|
98
98
|
// trigger by bridge account change event
|
|
99
99
|
_handleAccountChange(payload) {
|
|
100
|
+
var _a;
|
|
100
101
|
const account = payload;
|
|
101
102
|
if (this.isAccountsChanged(account)) {
|
|
102
|
-
this.emit('accountChanged', (account === null || account === void 0 ? void 0 : account.address)
|
|
103
|
+
this.emit('accountChanged', (_a = account === null || account === void 0 ? void 0 : account.address) !== null && _a !== void 0 ? _a : null);
|
|
103
104
|
this.emit('accountChangedV2', account);
|
|
104
105
|
}
|
|
105
106
|
if (!account) {
|
|
@@ -13,6 +13,7 @@ exports.ProviderAptosMartian = void 0;
|
|
|
13
13
|
const extension_bridge_injected_1 = require("@onekeyfe/extension-bridge-injected");
|
|
14
14
|
const OnekeyAptosProvider_1 = require("./OnekeyAptosProvider");
|
|
15
15
|
const cross_inpage_provider_errors_1 = require("@onekeyfe/cross-inpage-provider-errors");
|
|
16
|
+
const lodash_1 = require("lodash");
|
|
16
17
|
class ProviderAptosMartian extends OnekeyAptosProvider_1.ProviderAptos {
|
|
17
18
|
get publicKey() {
|
|
18
19
|
var _a, _b;
|
|
@@ -47,7 +48,17 @@ class ProviderAptosMartian extends OnekeyAptosProvider_1.ProviderAptos {
|
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
+
hasStandardV2SignTransaction(transaction) {
|
|
52
|
+
if (typeof transaction === 'object' &&
|
|
53
|
+
'bcsToHex' in transaction &&
|
|
54
|
+
'rawTransaction' in transaction) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
signTransaction(transaction,
|
|
60
|
+
// V2 sign transaction as fee payer
|
|
61
|
+
asFeePayer) {
|
|
51
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
63
|
if (typeof transaction === 'string') {
|
|
53
64
|
return this._callMartianBridge({
|
|
@@ -56,13 +67,35 @@ class ProviderAptosMartian extends OnekeyAptosProvider_1.ProviderAptos {
|
|
|
56
67
|
});
|
|
57
68
|
}
|
|
58
69
|
else {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
// aptos standard wallet v2
|
|
71
|
+
// adapter @aptos-labs/wallet-adapter-core 3.x
|
|
72
|
+
if (this.hasStandardV2SignTransaction(transaction)) {
|
|
73
|
+
let transactionType;
|
|
74
|
+
if ((0, lodash_1.get)(transaction, 'rawTransaction.secondarySignerAddresses')) {
|
|
75
|
+
transactionType = 'multi_agent';
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
transactionType = 'simple';
|
|
79
|
+
}
|
|
80
|
+
// @ts-expect-error
|
|
81
|
+
return this.signTransactionV2({
|
|
82
|
+
// @ts-expect-error
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
84
|
+
transaction: transaction.bcsToHex().toStringWithoutPrefix(),
|
|
85
|
+
transactionType,
|
|
86
|
+
asFeePayer,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// aptos V1 sign transaction
|
|
91
|
+
const res = yield this._callMartianBridge({
|
|
92
|
+
method: 'signTransaction',
|
|
93
|
+
params: transaction,
|
|
94
|
+
});
|
|
95
|
+
if (!res)
|
|
96
|
+
throw cross_inpage_provider_errors_1.web3Errors.provider.unauthorized();
|
|
97
|
+
return new Uint8Array(Buffer.from(res, 'hex'));
|
|
98
|
+
}
|
|
66
99
|
}
|
|
67
100
|
});
|
|
68
101
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-aptos-provider",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.17",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@aptos-labs/wallet-standard": "^0.2.0",
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-core": "2.2.
|
|
33
|
-
"@onekeyfe/cross-inpage-provider-errors": "2.2.
|
|
34
|
-
"@onekeyfe/cross-inpage-provider-types": "2.2.
|
|
35
|
-
"@onekeyfe/extension-bridge-injected": "2.2.
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-core": "2.2.17",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-errors": "2.2.17",
|
|
34
|
+
"@onekeyfe/cross-inpage-provider-types": "2.2.17",
|
|
35
|
+
"@onekeyfe/extension-bridge-injected": "2.2.17",
|
|
36
36
|
"@wallet-standard/core": "1.0.3",
|
|
37
37
|
"eth-rpc-errors": "^4.0.3"
|
|
38
38
|
},
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"@aptos-labs/ts-sdk": "^1.30.0",
|
|
44
44
|
"aptos": "^1.3.17"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "398d84bed03f60876b6ea5760121f260eff5b82b"
|
|
47
47
|
}
|