@onekeyfe/onekey-aptos-provider 2.2.26 → 2.2.28
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/OnekeyAptosProvider.d.ts +1 -1
- package/dist/StandardProvider.js +1 -2
- package/dist/__tests__/fixtures/payloadSerializer.test.js +1 -1
- package/dist/__tests__/fixtures/serializer.test.js +1 -1
- package/dist/cjs/StandardProvider.js +3 -4
- package/dist/cjs/__tests__/fixtures/payloadSerializer.test.js +4 -4
- package/dist/cjs/__tests__/fixtures/serializer.test.js +8 -8
- package/dist/cjs/serializer.js +6 -6
- package/dist/serializer.js +1 -1
- package/package.json +6 -6
- package/dist/cjs/utils.js +0 -10
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IInpageProviderConfig } from '@onekeyfe/cross-inpage-provider-core';
|
|
2
2
|
import { ProviderAptosBase } from './ProviderAptosBase';
|
|
3
|
-
import { AptosAccountInfo, ProviderState, SignMessagePayload, SignMessagePayloadCompatible, SignMessageResponse, SignMessageResponseCompatible } from './types';
|
|
3
|
+
import type { AptosAccountInfo, ProviderState, SignMessagePayload, SignMessagePayloadCompatible, SignMessageResponse, SignMessageResponseCompatible } from './types';
|
|
4
4
|
import { IJsonRpcRequest } from '@onekeyfe/cross-inpage-provider-types';
|
|
5
5
|
import type { Types } from 'aptos';
|
|
6
6
|
import type { AccountAuthenticator, PendingTransactionResponse } from '@aptos-labs/ts-sdk';
|
package/dist/StandardProvider.js
CHANGED
|
@@ -9,8 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { Ed25519Signature, Ed25519PublicKey, Network, AccountAddress, Serializer, } from '@aptos-labs/ts-sdk';
|
|
11
11
|
import { APTOS_CHAINS, AccountInfo, registerWallet, UserResponseStatus, } from '@aptos-labs/wallet-standard';
|
|
12
|
-
import { bytesToHex } from '@
|
|
13
|
-
import { stripHexPrefix } from './utils';
|
|
12
|
+
import { stripHexPrefix, bytesToHex } from '@onekeyfe/cross-inpage-provider-core';
|
|
14
13
|
export class WalletAccount {
|
|
15
14
|
constructor(account) {
|
|
16
15
|
this.chains = APTOS_CHAINS;
|
|
@@ -4,7 +4,7 @@ global.TextEncoder = TextEncoder;
|
|
|
4
4
|
global.TextDecoder = TextDecoder;
|
|
5
5
|
import { Bool, U8, U16, U32, U64, U128, U256, AccountAddress, MoveVector, MoveOption, MoveString, } from '@aptos-labs/ts-sdk';
|
|
6
6
|
import { serializeTransactionPayload, deserializeTransactionPayload } from '../../serializer';
|
|
7
|
-
import { hexToBytes } from '@
|
|
7
|
+
import { hexToBytes } from '@onekeyfe/cross-inpage-provider-core';
|
|
8
8
|
import { TxnBuilderTypes } from 'aptos';
|
|
9
9
|
import { get } from 'lodash';
|
|
10
10
|
describe('TransactionPayloadSerializer', () => {
|
|
@@ -4,7 +4,7 @@ global.TextEncoder = TextEncoder;
|
|
|
4
4
|
global.TextDecoder = TextDecoder;
|
|
5
5
|
import { Bool, U8, U16, U32, U64, U128, U256, AccountAddress, MoveVector, MoveOption, MoveString, FixedBytes, } from '@aptos-labs/ts-sdk';
|
|
6
6
|
import { serializeArguments, deserializeArguments } from '../../serializer';
|
|
7
|
-
import { hexToBytes } from '@
|
|
7
|
+
import { hexToBytes } from '@onekeyfe/cross-inpage-provider-core';
|
|
8
8
|
function deepCompare(input, output) {
|
|
9
9
|
if (input instanceof MoveVector && output instanceof MoveVector) {
|
|
10
10
|
if (input.values.length !== output.values.length) {
|
|
@@ -13,8 +13,7 @@ exports.AptosStandardProvider = exports.WalletAccount = void 0;
|
|
|
13
13
|
exports.registerAptosWallet = registerAptosWallet;
|
|
14
14
|
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
|
|
15
15
|
const wallet_standard_1 = require("@aptos-labs/wallet-standard");
|
|
16
|
-
const
|
|
17
|
-
const utils_2 = require("./utils");
|
|
16
|
+
const cross_inpage_provider_core_1 = require("@onekeyfe/cross-inpage-provider-core");
|
|
18
17
|
class WalletAccount {
|
|
19
18
|
constructor(account) {
|
|
20
19
|
this.chains = wallet_standard_1.APTOS_CHAINS;
|
|
@@ -116,7 +115,7 @@ class AptosStandardProvider {
|
|
|
116
115
|
const serializer = new ts_sdk_1.Serializer();
|
|
117
116
|
input.serialize(serializer);
|
|
118
117
|
const payload = serializer.toUint8Array();
|
|
119
|
-
const result = yield this.provider.signAndSubmitTransactionStandardV1((0,
|
|
118
|
+
const result = yield this.provider.signAndSubmitTransactionStandardV1((0, cross_inpage_provider_core_1.bytesToHex)(payload));
|
|
120
119
|
return {
|
|
121
120
|
status: wallet_standard_1.UserResponseStatus.APPROVED,
|
|
122
121
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
@@ -163,7 +162,7 @@ class AptosStandardProvider {
|
|
|
163
162
|
this.onAccountChange = (input) => __awaiter(this, void 0, void 0, function* () {
|
|
164
163
|
this.provider.onAccountChangeStandardV2((account) => {
|
|
165
164
|
var _a, _b;
|
|
166
|
-
const address = (0,
|
|
165
|
+
const address = (0, cross_inpage_provider_core_1.stripHexPrefix)((_a = account === null || account === void 0 ? void 0 : account.address) !== null && _a !== void 0 ? _a : '');
|
|
167
166
|
if (account && address.length === 64) {
|
|
168
167
|
input(new wallet_standard_1.AccountInfo({
|
|
169
168
|
address: new ts_sdk_1.AccountAddress(Buffer.from(address, 'hex')),
|
|
@@ -6,7 +6,7 @@ global.TextEncoder = util_1.TextEncoder;
|
|
|
6
6
|
global.TextDecoder = util_1.TextDecoder;
|
|
7
7
|
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
|
|
8
8
|
const serializer_1 = require("../../serializer");
|
|
9
|
-
const
|
|
9
|
+
const cross_inpage_provider_core_1 = require("@onekeyfe/cross-inpage-provider-core");
|
|
10
10
|
const aptos_1 = require("aptos");
|
|
11
11
|
const lodash_1 = require("lodash");
|
|
12
12
|
describe('TransactionPayloadSerializer', () => {
|
|
@@ -39,13 +39,13 @@ describe('TransactionPayloadSerializer', () => {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
it('serialize v1 wormhole payload', () => {
|
|
42
|
-
const script = new aptos_1.TxnBuilderTypes.Script((0,
|
|
42
|
+
const script = new aptos_1.TxnBuilderTypes.Script((0, cross_inpage_provider_core_1.hexToBytes)('0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20'), [], [
|
|
43
43
|
new aptos_1.TxnBuilderTypes.TransactionArgumentU8(1),
|
|
44
44
|
new aptos_1.TxnBuilderTypes.TransactionArgumentU64(BigInt('18446744073709551615')),
|
|
45
45
|
new aptos_1.TxnBuilderTypes.TransactionArgumentU128(BigInt('340282366920938463463374607431768211455')),
|
|
46
46
|
new aptos_1.TxnBuilderTypes.TransactionArgumentBool(true),
|
|
47
|
-
new aptos_1.TxnBuilderTypes.TransactionArgumentAddress(new aptos_1.TxnBuilderTypes.AccountAddress((0,
|
|
48
|
-
new aptos_1.TxnBuilderTypes.TransactionArgumentU8Vector((0,
|
|
47
|
+
new aptos_1.TxnBuilderTypes.TransactionArgumentAddress(new aptos_1.TxnBuilderTypes.AccountAddress((0, cross_inpage_provider_core_1.hexToBytes)('1'.repeat(64)))),
|
|
48
|
+
new aptos_1.TxnBuilderTypes.TransactionArgumentU8Vector((0, cross_inpage_provider_core_1.hexToBytes)('0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20')),
|
|
49
49
|
]);
|
|
50
50
|
const payload = new aptos_1.TxnBuilderTypes.TransactionPayloadScript(script);
|
|
51
51
|
// @ts-expect-error
|
|
@@ -6,7 +6,7 @@ global.TextEncoder = util_1.TextEncoder;
|
|
|
6
6
|
global.TextDecoder = util_1.TextDecoder;
|
|
7
7
|
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
|
|
8
8
|
const serializer_1 = require("../../serializer");
|
|
9
|
-
const
|
|
9
|
+
const cross_inpage_provider_core_1 = require("@onekeyfe/cross-inpage-provider-core");
|
|
10
10
|
function deepCompare(input, output) {
|
|
11
11
|
if (input instanceof ts_sdk_1.MoveVector && output instanceof ts_sdk_1.MoveVector) {
|
|
12
12
|
if (input.values.length !== output.values.length) {
|
|
@@ -79,9 +79,9 @@ describe('Serializer', () => {
|
|
|
79
79
|
new ts_sdk_1.U64(BigInt('18446744073709551615')),
|
|
80
80
|
new ts_sdk_1.U128(BigInt('340282366920938463463374607431768211455')),
|
|
81
81
|
new ts_sdk_1.U256(BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff')),
|
|
82
|
-
new ts_sdk_1.AccountAddress((0,
|
|
82
|
+
new ts_sdk_1.AccountAddress((0, cross_inpage_provider_core_1.hexToBytes)('1'.repeat(64))),
|
|
83
83
|
new ts_sdk_1.MoveString('SDK'),
|
|
84
|
-
new ts_sdk_1.FixedBytes((0,
|
|
84
|
+
new ts_sdk_1.FixedBytes((0, cross_inpage_provider_core_1.hexToBytes)('010203')),
|
|
85
85
|
];
|
|
86
86
|
const serialized = (0, serializer_1.serializeArguments)(inputs);
|
|
87
87
|
const deserialized = (0, serializer_1.deserializeArguments)(serialized);
|
|
@@ -92,8 +92,8 @@ describe('Serializer', () => {
|
|
|
92
92
|
new ts_sdk_1.MoveVector([new ts_sdk_1.U8(1), new ts_sdk_1.U8(2), new ts_sdk_1.U8(3)]),
|
|
93
93
|
new ts_sdk_1.MoveVector([new ts_sdk_1.Bool(true), new ts_sdk_1.Bool(false)]),
|
|
94
94
|
new ts_sdk_1.MoveVector([
|
|
95
|
-
new ts_sdk_1.AccountAddress((0,
|
|
96
|
-
new ts_sdk_1.AccountAddress((0,
|
|
95
|
+
new ts_sdk_1.AccountAddress((0, cross_inpage_provider_core_1.hexToBytes)('1'.repeat(64))),
|
|
96
|
+
new ts_sdk_1.AccountAddress((0, cross_inpage_provider_core_1.hexToBytes)('2'.repeat(64))),
|
|
97
97
|
]),
|
|
98
98
|
new ts_sdk_1.MoveVector([
|
|
99
99
|
new ts_sdk_1.MoveString('SDK'),
|
|
@@ -170,7 +170,7 @@ describe('Serializer', () => {
|
|
|
170
170
|
new ts_sdk_1.MoveString('hello'),
|
|
171
171
|
[1, 2, new ts_sdk_1.U8(3)],
|
|
172
172
|
new ts_sdk_1.MoveVector([new ts_sdk_1.U8(1), new ts_sdk_1.U8(2)]),
|
|
173
|
-
new ts_sdk_1.MoveOption(new ts_sdk_1.FixedBytes((0,
|
|
173
|
+
new ts_sdk_1.MoveOption(new ts_sdk_1.FixedBytes((0, cross_inpage_provider_core_1.hexToBytes)('010203'))),
|
|
174
174
|
[
|
|
175
175
|
new ts_sdk_1.MoveOption(new ts_sdk_1.U64(BigInt(42))),
|
|
176
176
|
new ts_sdk_1.MoveVector([new ts_sdk_1.Bool(true), new ts_sdk_1.Bool(false)]),
|
|
@@ -201,7 +201,7 @@ describe('Serializer', () => {
|
|
|
201
201
|
expect(deserialized[6].isSome()).toBe(true);
|
|
202
202
|
const fixedBytes = deserialized[6].value;
|
|
203
203
|
expect(fixedBytes).toBeInstanceOf(ts_sdk_1.FixedBytes);
|
|
204
|
-
expect(fixedBytes === null || fixedBytes === void 0 ? void 0 : fixedBytes.toString()).toEqual(new ts_sdk_1.FixedBytes((0,
|
|
204
|
+
expect(fixedBytes === null || fixedBytes === void 0 ? void 0 : fixedBytes.toString()).toEqual(new ts_sdk_1.FixedBytes((0, cross_inpage_provider_core_1.hexToBytes)('010203')).toString());
|
|
205
205
|
// 验证复杂嵌套结构
|
|
206
206
|
const complexArray = deserialized[7];
|
|
207
207
|
expect(complexArray[0]).toBeInstanceOf(ts_sdk_1.MoveOption);
|
|
@@ -229,7 +229,7 @@ describe('Serializer', () => {
|
|
|
229
229
|
new ts_sdk_1.MoveOption(),
|
|
230
230
|
]),
|
|
231
231
|
[
|
|
232
|
-
new ts_sdk_1.AccountAddress((0,
|
|
232
|
+
new ts_sdk_1.AccountAddress((0, cross_inpage_provider_core_1.hexToBytes)('1'.repeat(64))),
|
|
233
233
|
123,
|
|
234
234
|
new ts_sdk_1.MoveVector([new ts_sdk_1.Bool(true), new ts_sdk_1.Bool(false)]),
|
|
235
235
|
[new ts_sdk_1.MoveOption(new ts_sdk_1.MoveVector([new ts_sdk_1.U8(1), new ts_sdk_1.U8(2)])), 'nested string', BigInt(456)],
|
package/dist/cjs/serializer.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.deserializeArgument = deserializeArgument;
|
|
|
8
8
|
exports.deserializeArguments = deserializeArguments;
|
|
9
9
|
exports.serializeArguments = serializeArguments;
|
|
10
10
|
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
|
|
11
|
-
const
|
|
11
|
+
const cross_inpage_provider_core_1 = require("@onekeyfe/cross-inpage-provider-core");
|
|
12
12
|
var TransactionPayloadType;
|
|
13
13
|
(function (TransactionPayloadType) {
|
|
14
14
|
TransactionPayloadType[TransactionPayloadType["SCRIPT"] = 0] = "SCRIPT";
|
|
@@ -83,10 +83,10 @@ function serializeTransactionPayload(args) {
|
|
|
83
83
|
else {
|
|
84
84
|
throw new Error('Invalid transaction payload type');
|
|
85
85
|
}
|
|
86
|
-
return (0,
|
|
86
|
+
return (0, cross_inpage_provider_core_1.bytesToHex)(serializer.toUint8Array());
|
|
87
87
|
}
|
|
88
88
|
function deserializeTransactionPayload(hex) {
|
|
89
|
-
const deserializer = new ts_sdk_1.Deserializer((0,
|
|
89
|
+
const deserializer = new ts_sdk_1.Deserializer((0, cross_inpage_provider_core_1.hexToBytes)(hex));
|
|
90
90
|
const type = deserializer.deserializeUleb128AsU32();
|
|
91
91
|
if (type === TransactionPayloadType.ENTRY_FUNCTION) {
|
|
92
92
|
return deserializeTransactionPayloadEntryFunction(deserializer);
|
|
@@ -303,7 +303,7 @@ function deserializeArgument(deserializer) {
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
function deserializeArguments(bytes) {
|
|
306
|
-
const deserializer = new ts_sdk_1.Deserializer((0,
|
|
306
|
+
const deserializer = new ts_sdk_1.Deserializer((0, cross_inpage_provider_core_1.hexToBytes)(bytes));
|
|
307
307
|
const length = deserializer.deserializeU32();
|
|
308
308
|
const args = [];
|
|
309
309
|
for (let i = 0; i < length; i++) {
|
|
@@ -315,12 +315,12 @@ function serializeArguments(args) {
|
|
|
315
315
|
const serializer = new ts_sdk_1.Serializer();
|
|
316
316
|
serializer.serializeU32(args.length);
|
|
317
317
|
args.forEach((arg) => serializeArgument(serializer, arg));
|
|
318
|
-
return (0,
|
|
318
|
+
return (0, cross_inpage_provider_core_1.bytesToHex)(serializer.toUint8Array());
|
|
319
319
|
}
|
|
320
320
|
function serializeTransactionPayloadScript(args, serializer) {
|
|
321
321
|
const { bytecode, typeArguments, functionArguments } = args;
|
|
322
322
|
serializer.serializeU32AsUleb128(TransactionPayloadType.SCRIPT);
|
|
323
|
-
const bytecodeBytes = typeof bytecode === 'string' ? bytecode : (0,
|
|
323
|
+
const bytecodeBytes = typeof bytecode === 'string' ? bytecode : (0, cross_inpage_provider_core_1.bytesToHex)(bytecode);
|
|
324
324
|
serializer.serializeOption(bytecodeBytes);
|
|
325
325
|
serializer.serializeVector((0, ts_sdk_1.standardizeTypeTags)(typeArguments));
|
|
326
326
|
const hex = serializeArguments(functionArguments);
|
package/dist/serializer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Serializer, Deserializer, MoveVector, MoveOption, U8, U64, U128, AccountAddress, Bool, U16, U32, U256, Serialized, MoveString, FixedBytes, TypeTag, standardizeTypeTags, } from '@aptos-labs/ts-sdk';
|
|
2
|
-
import { hexToBytes, bytesToHex } from '@
|
|
2
|
+
import { hexToBytes, bytesToHex } from '@onekeyfe/cross-inpage-provider-core';
|
|
3
3
|
export var TransactionPayloadType;
|
|
4
4
|
(function (TransactionPayloadType) {
|
|
5
5
|
TransactionPayloadType[TransactionPayloadType["SCRIPT"] = 0] = "SCRIPT";
|
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.28",
|
|
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.28",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-errors": "2.2.28",
|
|
34
|
+
"@onekeyfe/cross-inpage-provider-types": "2.2.28",
|
|
35
|
+
"@onekeyfe/extension-bridge-injected": "2.2.28",
|
|
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": "473ece52d08eeb9eed490a3172fad5f954338800"
|
|
47
47
|
}
|
package/dist/cjs/utils.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasHexPrefix = hasHexPrefix;
|
|
4
|
-
exports.stripHexPrefix = stripHexPrefix;
|
|
5
|
-
function hasHexPrefix(data) {
|
|
6
|
-
return data.startsWith('0x');
|
|
7
|
-
}
|
|
8
|
-
function stripHexPrefix(hex) {
|
|
9
|
-
return hasHexPrefix(hex) ? hex.slice(2) : hex;
|
|
10
|
-
}
|
package/dist/utils.d.ts
DELETED