@ledgerhq/coin-aptos 2.2.0-next.0 → 2.2.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +11 -0
- package/lib/__tests__/api/craftTransaction.unit.test.js +31 -16
- package/lib/__tests__/api/craftTransaction.unit.test.js.map +1 -1
- package/lib/__tests__/api/index.integ.test.js +7 -14
- package/lib/__tests__/api/index.integ.test.js.map +1 -1
- package/lib/__tests__/api/index.test.js.map +1 -1
- package/lib/__tests__/network/client.test.js +3 -6
- package/lib/__tests__/network/client.test.js.map +1 -1
- package/lib/api/index.d.ts +3 -3
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +2 -2
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +3 -3
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/network/client.d.ts +2 -2
- package/lib/network/client.d.ts.map +1 -1
- package/lib/network/client.js +2 -3
- package/lib/network/client.js.map +1 -1
- package/lib/types/assets.d.ts +4 -0
- package/lib/types/assets.d.ts.map +1 -1
- package/lib-es/__tests__/api/craftTransaction.unit.test.js +31 -16
- package/lib-es/__tests__/api/craftTransaction.unit.test.js.map +1 -1
- package/lib-es/__tests__/api/index.integ.test.js +7 -14
- package/lib-es/__tests__/api/index.integ.test.js.map +1 -1
- package/lib-es/__tests__/api/index.test.js.map +1 -1
- package/lib-es/__tests__/network/client.test.js +3 -6
- package/lib-es/__tests__/network/client.test.js.map +1 -1
- package/lib-es/api/index.d.ts +3 -3
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +2 -2
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +3 -3
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/network/client.d.ts +2 -2
- package/lib-es/network/client.d.ts.map +1 -1
- package/lib-es/network/client.js +2 -3
- package/lib-es/network/client.js.map +1 -1
- package/lib-es/types/assets.d.ts +4 -0
- package/lib-es/types/assets.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/api/craftTransaction.unit.test.ts +37 -22
- package/src/__tests__/api/index.integ.test.ts +11 -17
- package/src/__tests__/api/index.test.ts +6 -4
- package/src/__tests__/network/client.test.ts +10 -13
- package/src/api/index.ts +6 -4
- package/src/logic/craftTransaction.ts +8 -6
- package/src/network/client.ts +10 -5
- package/src/types/assets.ts +5 -0
|
@@ -9,15 +9,15 @@ export async function craftTransaction(aptosClient, transactionIntent) {
|
|
|
9
9
|
newTx.mode = transactionIntent.type;
|
|
10
10
|
newTx.useAllAmount = transactionIntent.amount === BigInt(0);
|
|
11
11
|
const account = {
|
|
12
|
-
freshAddress: transactionIntent.sender,
|
|
13
|
-
xpub: transactionIntent.
|
|
12
|
+
freshAddress: transactionIntent.sender.freshAddress,
|
|
13
|
+
xpub: transactionIntent.sender.xpub,
|
|
14
14
|
subAccounts: new Array(),
|
|
15
15
|
};
|
|
16
16
|
let tokenType;
|
|
17
17
|
const contractAddress = getContractAddress(transactionIntent);
|
|
18
18
|
let balance;
|
|
19
19
|
if (newTx.useAllAmount === true) {
|
|
20
|
-
const balances = await aptosClient.getBalances(transactionIntent.sender);
|
|
20
|
+
const balances = await aptosClient.getBalances(transactionIntent.sender.freshAddress);
|
|
21
21
|
balance = balances?.find(b => b.contractAddress.toLowerCase() === contractAddress?.toLowerCase());
|
|
22
22
|
if (balance !== undefined) {
|
|
23
23
|
newTx.amount = BigNumber(balance.amount.toString());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"craftTransaction.js","sourceRoot":"","sources":["../../src/logic/craftTransaction.ts"],"names":[],"mappings":"AAIA,OAAO,gBAAgB,EAAE,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,i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WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACtF,OAAO,GAAG,QAAQ,EAAE,IAAI,CACtB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,WAAW,EAAE,KAAK,eAAe,EAAE,WAAW,EAAE,CACxE,CAAC;QAEF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED,IAAI,iBAAiB,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC7C,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,QAAsB,CAAC;IAC7D,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,gBAAgB,CACpC,OAAO,EACP,KAAK,EACL,WAAW,EACX,eAAe,EACf,SAAS,IAAI,SAAS,CACvB,CAAC;IAEF,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACvC,CAAC;AAED,SAAS,kBAAkB,CACzB,QAAgE;IAEhE,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5E,OAAO,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC;IACxC,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -3,7 +3,7 @@ import BigNumber from "bignumber.js";
|
|
|
3
3
|
import type { AptosBalance, AptosTransaction, TransactionOptions } from "../types";
|
|
4
4
|
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
5
5
|
import { BlockInfo, FeeEstimation, Operation, Pagination, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
|
|
6
|
-
import { AptosAsset } from "../types/assets";
|
|
6
|
+
import { AptosAsset, AptosExtra, AptosFeeParameters, AptosSender } from "../types/assets";
|
|
7
7
|
export declare class AptosAPI {
|
|
8
8
|
private readonly aptosConfig;
|
|
9
9
|
private readonly aptosClient;
|
|
@@ -27,7 +27,7 @@ export declare class AptosAPI {
|
|
|
27
27
|
getLastBlock(): Promise<BlockInfo>;
|
|
28
28
|
getCoinBalance(address: string, contract_address: string): Promise<BigNumber>;
|
|
29
29
|
getFABalance(address: string, contract_address: string): Promise<BigNumber>;
|
|
30
|
-
estimateFees(transactionIntent: TransactionIntent<AptosAsset>): Promise<FeeEstimation
|
|
30
|
+
estimateFees(transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender>): Promise<FeeEstimation<AptosFeeParameters>>;
|
|
31
31
|
listOperations(rawAddress: string, pagination: Pagination): Promise<[Operation<AptosAsset>[], string]>;
|
|
32
32
|
private fetchTransactions;
|
|
33
33
|
private richItemByVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/network/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAGhB,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAG3B,KAAK,cAAc,EAGnB,KAAK,uBAAuB,EAE5B,KAAK,aAAa,EAInB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,SAAS,MAAM,cAAc,CAAC;AASrC,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAMnF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,SAAS,EACT,aAAa,EACb,SAAS,EACT,UAAU,EACV,iBAAiB,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/network/client.ts"],"names":[],"mappings":"A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AAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC;IAQrE,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC;IAUlC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAmB7E,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAmB3E,YAAY,CAChB,iBAAiB,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,CAAC,GACxE,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAsDvC,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAQ/B,iBAAiB;YA8BjB,iBAAiB;YAkBjB,SAAS;YAQT,QAAQ;IAQhB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAiB5D"}
|
package/lib-es/network/client.js
CHANGED
|
@@ -157,7 +157,7 @@ export class AptosAPI {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
async estimateFees(transactionIntent) {
|
|
160
|
-
const publicKeyEd = new Ed25519PublicKey(transactionIntent
|
|
160
|
+
const publicKeyEd = new Ed25519PublicKey(transactionIntent.sender.xpub);
|
|
161
161
|
const txPayload = {
|
|
162
162
|
function: "0x1::aptos_account::transfer_coins",
|
|
163
163
|
typeArguments: [APTOS_ASSET_ID],
|
|
@@ -183,7 +183,7 @@ export class AptosAPI {
|
|
|
183
183
|
maxGasAmount: DEFAULT_GAS.toString(),
|
|
184
184
|
gasUnitPrice: DEFAULT_GAS_PRICE.toString(),
|
|
185
185
|
};
|
|
186
|
-
const tx = await this.generateTransaction(transactionIntent.sender, txPayload, txOptions);
|
|
186
|
+
const tx = await this.generateTransaction(transactionIntent.sender.freshAddress, txPayload, txOptions);
|
|
187
187
|
const simulation = await this.simulateTransaction(publicKeyEd, tx);
|
|
188
188
|
const completedTx = simulation[0];
|
|
189
189
|
const gasLimit = new BigNumber(completedTx.gas_used).multipliedBy(ESTIMATE_GAS_MUL);
|
|
@@ -192,7 +192,6 @@ export class AptosAPI {
|
|
|
192
192
|
return {
|
|
193
193
|
value: BigInt(expectedGas.toString()),
|
|
194
194
|
parameters: {
|
|
195
|
-
storageLimit: BigInt(0),
|
|
196
195
|
gasLimit: BigInt(gasLimit.toString()),
|
|
197
196
|
gasPrice: BigInt(gasPrice.toString()),
|
|
198
197
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/network/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAEL,KAAK,EACL,WAAW,EACX,gBAAgB,EAIhB,QAAQ,EAOR,GAAG,EACH,iBAAiB,GAElB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAc7F,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE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;SAC5B,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
|
package/lib-es/types/assets.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export type AptosTokenInformation = {
|
|
|
5
5
|
contractAddress: string;
|
|
6
6
|
};
|
|
7
7
|
export type AptosExtra = Record<string, unknown>;
|
|
8
|
+
export type AptosSender = {
|
|
9
|
+
xpub: string;
|
|
10
|
+
freshAddress: string;
|
|
11
|
+
};
|
|
8
12
|
export type AptosFeeParameters = {
|
|
9
13
|
gasLimit: bigint;
|
|
10
14
|
gasPrice: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/types/assets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAEhE,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEtD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/types/assets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAEhE,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAEtD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-aptos",
|
|
3
|
-
"version": "2.2.0-next.
|
|
3
|
+
"version": "2.2.0-next.1",
|
|
4
4
|
"description": "Ledger Aptos Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"invariant": "^2.2.4",
|
|
91
91
|
"lodash": "^4.17.21",
|
|
92
92
|
"rxjs": "^7.8.1",
|
|
93
|
-
"@ledgerhq/coin-framework": "^5.3.0-next.
|
|
93
|
+
"@ledgerhq/coin-framework": "^5.3.0-next.1",
|
|
94
94
|
"@ledgerhq/cryptoassets": "^13.18.1-next.0",
|
|
95
95
|
"@ledgerhq/devices": "8.4.6",
|
|
96
96
|
"@ledgerhq/errors": "^6.21.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hex, RawTransaction, Deserializer } from "@aptos-labs/ts-sdk";
|
|
2
2
|
import type { TransactionIntent } from "@ledgerhq/coin-framework/lib/api/types";
|
|
3
3
|
import { createApi } from "../../api";
|
|
4
|
-
import type { AptosAsset } from "../../types/assets";
|
|
4
|
+
import type { AptosAsset, AptosExtra, AptosSender } from "../../types/assets";
|
|
5
5
|
import { AptosAPI } from "../../network";
|
|
6
6
|
import { APTOS_ASSET_ID } from "../../constants";
|
|
7
7
|
|
|
@@ -41,17 +41,20 @@ describe("craftTransaction", () => {
|
|
|
41
41
|
getBalances: mockGetBalances,
|
|
42
42
|
}));
|
|
43
43
|
|
|
44
|
+
const SENDER: AptosSender = {
|
|
45
|
+
xpub: "public-key",
|
|
46
|
+
freshAddress: SENDER_ADDR,
|
|
47
|
+
};
|
|
44
48
|
const api = createApi({
|
|
45
49
|
aptosSettings: {},
|
|
46
50
|
});
|
|
47
51
|
|
|
48
|
-
const txArg: TransactionIntent<AptosAsset> = {
|
|
52
|
+
const txArg: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
49
53
|
type: "send",
|
|
50
|
-
sender:
|
|
51
|
-
senderPublicKey: "public-key",
|
|
54
|
+
sender: SENDER,
|
|
52
55
|
recipient: RECIPIENT_ADDR,
|
|
53
56
|
amount: 10n,
|
|
54
|
-
asset: { type: "
|
|
57
|
+
asset: { type: "native" },
|
|
55
58
|
};
|
|
56
59
|
|
|
57
60
|
const tx = await api.craftTransaction(txArg);
|
|
@@ -62,10 +65,10 @@ describe("craftTransaction", () => {
|
|
|
62
65
|
expect(mockGenerateTransaction).toHaveBeenCalledTimes(1);
|
|
63
66
|
|
|
64
67
|
expect(mockGenerateTransaction).toHaveBeenCalledWith(
|
|
65
|
-
|
|
68
|
+
SENDER.freshAddress,
|
|
66
69
|
expect.objectContaining({
|
|
67
70
|
function: "0x1::aptos_account::transfer_coins",
|
|
68
|
-
typeArguments: [
|
|
71
|
+
typeArguments: [APTOS_ASSET_ID],
|
|
69
72
|
functionArguments: [RECIPIENT_ADDR, txArg.amount.toString()],
|
|
70
73
|
}),
|
|
71
74
|
expect.anything(),
|
|
@@ -82,14 +85,17 @@ describe("craftTransaction", () => {
|
|
|
82
85
|
getBalances: mockGetBalances,
|
|
83
86
|
}));
|
|
84
87
|
|
|
88
|
+
const SENDER: AptosSender = {
|
|
89
|
+
xpub: "public-key",
|
|
90
|
+
freshAddress: SENDER_ADDR,
|
|
91
|
+
};
|
|
85
92
|
const api = createApi({
|
|
86
93
|
aptosSettings: {},
|
|
87
94
|
});
|
|
88
95
|
|
|
89
|
-
const txArg: TransactionIntent<AptosAsset> = {
|
|
96
|
+
const txArg: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
90
97
|
type: "send",
|
|
91
|
-
sender:
|
|
92
|
-
senderPublicKey: "public-key",
|
|
98
|
+
sender: SENDER,
|
|
93
99
|
recipient: RECIPIENT_ADDR,
|
|
94
100
|
amount: 0n,
|
|
95
101
|
asset: { type: "native" },
|
|
@@ -103,7 +109,7 @@ describe("craftTransaction", () => {
|
|
|
103
109
|
expect(mockGenerateTransaction).toHaveBeenCalledTimes(1);
|
|
104
110
|
|
|
105
111
|
expect(mockGenerateTransaction).toHaveBeenCalledWith(
|
|
106
|
-
|
|
112
|
+
SENDER.freshAddress,
|
|
107
113
|
expect.objectContaining({
|
|
108
114
|
function: "0x1::aptos_account::transfer_coins",
|
|
109
115
|
typeArguments: [APTOS_ASSET_ID],
|
|
@@ -123,14 +129,17 @@ describe("craftTransaction", () => {
|
|
|
123
129
|
getBalances: mockGetBalances,
|
|
124
130
|
}));
|
|
125
131
|
|
|
132
|
+
const SENDER: AptosSender = {
|
|
133
|
+
xpub: "public-key",
|
|
134
|
+
freshAddress: SENDER_ADDR,
|
|
135
|
+
};
|
|
126
136
|
const api = createApi({
|
|
127
137
|
aptosSettings: {},
|
|
128
138
|
});
|
|
129
139
|
|
|
130
|
-
const txArg: TransactionIntent<AptosAsset> = {
|
|
140
|
+
const txArg: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
131
141
|
type: "send",
|
|
132
|
-
sender:
|
|
133
|
-
senderPublicKey: "public-key",
|
|
142
|
+
sender: SENDER,
|
|
134
143
|
recipient: RECIPIENT_ADDR,
|
|
135
144
|
amount: 10n,
|
|
136
145
|
asset: { type: "token", standard: "coin", contractAddress: "0x42::token::Token" },
|
|
@@ -144,7 +153,7 @@ describe("craftTransaction", () => {
|
|
|
144
153
|
expect(mockGenerateTransaction).toHaveBeenCalledTimes(1);
|
|
145
154
|
|
|
146
155
|
expect(mockGenerateTransaction).toHaveBeenCalledWith(
|
|
147
|
-
|
|
156
|
+
SENDER.freshAddress,
|
|
148
157
|
expect.objectContaining({
|
|
149
158
|
function: "0x1::aptos_account::transfer_coins",
|
|
150
159
|
typeArguments: ["0x42::token::Token"],
|
|
@@ -164,14 +173,17 @@ describe("craftTransaction", () => {
|
|
|
164
173
|
getBalances: mockGetBalances,
|
|
165
174
|
}));
|
|
166
175
|
|
|
176
|
+
const SENDER: AptosSender = {
|
|
177
|
+
xpub: "public-key",
|
|
178
|
+
freshAddress: SENDER_ADDR,
|
|
179
|
+
};
|
|
167
180
|
const api = createApi({
|
|
168
181
|
aptosSettings: {},
|
|
169
182
|
});
|
|
170
183
|
|
|
171
|
-
const txArg: TransactionIntent<AptosAsset> = {
|
|
184
|
+
const txArg: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
172
185
|
type: "send",
|
|
173
|
-
sender:
|
|
174
|
-
senderPublicKey: "public-key",
|
|
186
|
+
sender: SENDER,
|
|
175
187
|
recipient: RECIPIENT_ADDR,
|
|
176
188
|
amount: 0n,
|
|
177
189
|
asset: { type: "token", standard: "fungible_asset", contractAddress: "0x42" },
|
|
@@ -185,7 +197,7 @@ describe("craftTransaction", () => {
|
|
|
185
197
|
expect(mockGenerateTransaction).toHaveBeenCalledTimes(1);
|
|
186
198
|
|
|
187
199
|
expect(mockGenerateTransaction).toHaveBeenCalledWith(
|
|
188
|
-
|
|
200
|
+
SENDER.freshAddress,
|
|
189
201
|
expect.objectContaining({
|
|
190
202
|
function: "0x1::primary_fungible_store::transfer",
|
|
191
203
|
typeArguments: ["0x1::fungible_asset::Metadata"],
|
|
@@ -205,14 +217,17 @@ describe("craftTransaction", () => {
|
|
|
205
217
|
getBalances: mockGetBalances,
|
|
206
218
|
}));
|
|
207
219
|
|
|
220
|
+
const SENDER: AptosSender = {
|
|
221
|
+
xpub: "public-key",
|
|
222
|
+
freshAddress: SENDER_ADDR,
|
|
223
|
+
};
|
|
208
224
|
const api = createApi({
|
|
209
225
|
aptosSettings: {},
|
|
210
226
|
});
|
|
211
227
|
|
|
212
|
-
const txArg: TransactionIntent<AptosAsset> = {
|
|
228
|
+
const txArg: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
213
229
|
type: "send",
|
|
214
|
-
sender:
|
|
215
|
-
senderPublicKey: "public-key",
|
|
230
|
+
sender: SENDER,
|
|
216
231
|
recipient: RECIPIENT_ADDR,
|
|
217
232
|
amount: 10n,
|
|
218
233
|
asset: { type: "token", standard: "asset", contractAddress: "0x42::token::Token" },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Deserializer, Hex, Network, RawTransaction } from "@aptos-labs/ts-sdk";
|
|
2
2
|
import { createApi } from "../../api";
|
|
3
3
|
import { getEnv } from "@ledgerhq/live-env";
|
|
4
|
+
import type { AptosSender } from "../../types/assets";
|
|
4
5
|
import { DEFAULT_GAS, DEFAULT_GAS_PRICE } from "../../constants";
|
|
5
6
|
|
|
6
7
|
describe("createApi", () => {
|
|
@@ -12,17 +13,17 @@ describe("createApi", () => {
|
|
|
12
13
|
},
|
|
13
14
|
});
|
|
14
15
|
|
|
15
|
-
const sender = {
|
|
16
|
+
const sender: AptosSender = {
|
|
16
17
|
xpub: "0x934887885b27a0407bf8a5e0bbc6b6371254bea94de5510e948bcc92dc0a519b",
|
|
17
18
|
freshAddress: "0x0ef3b40f6ecd5583218d1985e0d54b54e8785ad2ec2d27ed1720ec16bb11686f",
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
const recipient = {
|
|
21
|
+
const recipient: AptosSender = {
|
|
21
22
|
xpub: "0x7fd6bfaac17c2c763f624b1f95cd4911e3646a5b777b03cc24f93ed0ac3f3e2b",
|
|
22
23
|
freshAddress: "0x4859a161dfe13081cf5a5eac409cd38f707c06176a21ddc875260c2ce63f3a28",
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
const tokenAccount = {
|
|
26
|
+
const tokenAccount: AptosSender = {
|
|
26
27
|
xpub: "0xeacada8192f15185637e475d7783e14486e232d8b9978ffa127383847ffc5318",
|
|
27
28
|
freshAddress: "0xb8922507317d85197d70c2bc1afc949c759fd0a62c8841a4300d1e2b63649bf6",
|
|
28
29
|
};
|
|
@@ -55,8 +56,7 @@ describe("createApi", () => {
|
|
|
55
56
|
type: "native",
|
|
56
57
|
},
|
|
57
58
|
type: "send",
|
|
58
|
-
sender
|
|
59
|
-
senderPublicKey: sender.xpub,
|
|
59
|
+
sender,
|
|
60
60
|
amount,
|
|
61
61
|
recipient: recipient.freshAddress,
|
|
62
62
|
});
|
|
@@ -75,8 +75,7 @@ describe("createApi", () => {
|
|
|
75
75
|
"0x50788befc1107c0cc4473848a92e5c783c635866ce3c98de71d2eeb7d2a34f85::usdc_coin::USDCoin",
|
|
76
76
|
},
|
|
77
77
|
type: "send",
|
|
78
|
-
sender
|
|
79
|
-
senderPublicKey: sender.xpub,
|
|
78
|
+
sender,
|
|
80
79
|
amount,
|
|
81
80
|
recipient: recipient.freshAddress,
|
|
82
81
|
});
|
|
@@ -94,8 +93,7 @@ describe("createApi", () => {
|
|
|
94
93
|
contractAddress: "0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b",
|
|
95
94
|
},
|
|
96
95
|
type: "send",
|
|
97
|
-
sender
|
|
98
|
-
senderPublicKey: sender.xpub,
|
|
96
|
+
sender,
|
|
99
97
|
amount,
|
|
100
98
|
recipient: recipient.freshAddress,
|
|
101
99
|
});
|
|
@@ -109,8 +107,7 @@ describe("createApi", () => {
|
|
|
109
107
|
const hex = await api.craftTransaction(
|
|
110
108
|
{
|
|
111
109
|
amount: 1n,
|
|
112
|
-
sender: sender
|
|
113
|
-
senderPublicKey: sender.xpub,
|
|
110
|
+
sender: sender,
|
|
114
111
|
recipient: recipient.freshAddress,
|
|
115
112
|
type: "send",
|
|
116
113
|
asset: { type: "native" },
|
|
@@ -131,8 +128,7 @@ describe("createApi", () => {
|
|
|
131
128
|
const hex = await api.craftTransaction(
|
|
132
129
|
{
|
|
133
130
|
amount: 1n,
|
|
134
|
-
sender: sender
|
|
135
|
-
senderPublicKey: sender.xpub,
|
|
131
|
+
sender: sender,
|
|
136
132
|
recipient: recipient.freshAddress,
|
|
137
133
|
type: "send",
|
|
138
134
|
asset: {
|
|
@@ -158,8 +154,7 @@ describe("createApi", () => {
|
|
|
158
154
|
const hex = await api.craftTransaction(
|
|
159
155
|
{
|
|
160
156
|
amount: 0n,
|
|
161
|
-
sender: sender
|
|
162
|
-
senderPublicKey: sender.xpub,
|
|
157
|
+
sender: sender,
|
|
163
158
|
recipient: recipient.freshAddress,
|
|
164
159
|
type: "send",
|
|
165
160
|
asset: {
|
|
@@ -187,8 +182,7 @@ describe("createApi", () => {
|
|
|
187
182
|
const hex = await api.craftTransaction(
|
|
188
183
|
{
|
|
189
184
|
amount: 0n,
|
|
190
|
-
sender: s
|
|
191
|
-
senderPublicKey: s.xpub,
|
|
185
|
+
sender: s,
|
|
192
186
|
recipient: r.freshAddress,
|
|
193
187
|
type: "send",
|
|
194
188
|
asset: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Aptos } from "@aptos-labs/ts-sdk";
|
|
2
|
-
import type {
|
|
3
|
-
import type { AptosAsset } from "../../types/assets";
|
|
2
|
+
import type { Api } from "@ledgerhq/coin-framework/api/types";
|
|
3
|
+
import type { AptosAsset, AptosExtra, AptosFeeParameters, AptosSender } from "../../types/assets";
|
|
4
4
|
import type { AptosConfig } from "../../config";
|
|
5
5
|
import { createApi } from "../../api";
|
|
6
6
|
import coinConfig from "../../config";
|
|
@@ -33,7 +33,8 @@ describe("createApi", () => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it("should return an API object with alpaca api methods", () => {
|
|
36
|
-
const api:
|
|
36
|
+
const api: Api<AptosAsset, AptosExtra, AptosSender, AptosFeeParameters> =
|
|
37
|
+
createApi(mockAptosConfig);
|
|
37
38
|
|
|
38
39
|
// Check that methods are set with what we expect
|
|
39
40
|
expect(api.broadcast).toBeDefined();
|
|
@@ -69,7 +70,8 @@ describe("lastBlock", () => {
|
|
|
69
70
|
}),
|
|
70
71
|
}));
|
|
71
72
|
|
|
72
|
-
const api:
|
|
73
|
+
const api: Api<AptosAsset, AptosExtra, AptosSender, AptosFeeParameters> =
|
|
74
|
+
createApi(mockAptosConfig);
|
|
73
75
|
|
|
74
76
|
expect(await api.lastBlock()).toStrictEqual({
|
|
75
77
|
height: 123,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import network from "@ledgerhq/live-network";
|
|
15
15
|
import BigNumber from "bignumber.js";
|
|
16
16
|
import { AptosAPI } from "../../network";
|
|
17
|
-
import { AptosAsset } from "../../types/assets";
|
|
17
|
+
import { AptosAsset, AptosExtra, AptosSender } from "../../types/assets";
|
|
18
18
|
import { Pagination, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
|
|
19
19
|
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
20
20
|
import { APTOS_ASSET_ID } from "../../constants";
|
|
@@ -612,20 +612,19 @@ describe("Aptos API", () => {
|
|
|
612
612
|
}));
|
|
613
613
|
|
|
614
614
|
const amount = BigInt(100);
|
|
615
|
-
const sender = {
|
|
615
|
+
const sender: AptosSender = {
|
|
616
616
|
xpub: "xpub",
|
|
617
617
|
freshAddress: "address1",
|
|
618
618
|
};
|
|
619
619
|
const recipient = "address2";
|
|
620
620
|
|
|
621
621
|
const api = new AptosAPI("aptos");
|
|
622
|
-
const transactionIntent: TransactionIntent<AptosAsset> = {
|
|
622
|
+
const transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
623
623
|
asset: {
|
|
624
624
|
type: "native",
|
|
625
625
|
},
|
|
626
626
|
type: "send",
|
|
627
|
-
sender
|
|
628
|
-
senderPublicKey: sender.xpub,
|
|
627
|
+
sender,
|
|
629
628
|
amount,
|
|
630
629
|
recipient,
|
|
631
630
|
};
|
|
@@ -677,22 +676,21 @@ describe("Aptos API", () => {
|
|
|
677
676
|
}));
|
|
678
677
|
|
|
679
678
|
const amount = BigInt(100);
|
|
680
|
-
const sender = {
|
|
679
|
+
const sender: AptosSender = {
|
|
681
680
|
xpub: "xpub",
|
|
682
681
|
freshAddress: "address1",
|
|
683
682
|
};
|
|
684
683
|
const recipient = "address2";
|
|
685
684
|
|
|
686
685
|
const api = new AptosAPI("aptos");
|
|
687
|
-
const transactionIntent: TransactionIntent<AptosAsset> = {
|
|
686
|
+
const transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
688
687
|
asset: {
|
|
689
688
|
type: "token",
|
|
690
689
|
standard: "coin",
|
|
691
690
|
contractAddress: "0x111",
|
|
692
691
|
},
|
|
693
692
|
type: "send",
|
|
694
|
-
sender
|
|
695
|
-
senderPublicKey: sender.xpub,
|
|
693
|
+
sender,
|
|
696
694
|
amount,
|
|
697
695
|
recipient,
|
|
698
696
|
};
|
|
@@ -743,22 +741,21 @@ describe("Aptos API", () => {
|
|
|
743
741
|
}));
|
|
744
742
|
|
|
745
743
|
const amount = BigInt(100);
|
|
746
|
-
const sender = {
|
|
744
|
+
const sender: AptosSender = {
|
|
747
745
|
xpub: "xpub",
|
|
748
746
|
freshAddress: "address1",
|
|
749
747
|
};
|
|
750
748
|
const recipient = "address2";
|
|
751
749
|
|
|
752
750
|
const api = new AptosAPI("aptos");
|
|
753
|
-
const transactionIntent: TransactionIntent<AptosAsset> = {
|
|
751
|
+
const transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
754
752
|
asset: {
|
|
755
753
|
type: "token",
|
|
756
754
|
standard: "fungible_asset",
|
|
757
755
|
contractAddress: "0x111",
|
|
758
756
|
},
|
|
759
757
|
type: "send",
|
|
760
|
-
sender
|
|
761
|
-
senderPublicKey: sender.xpub,
|
|
758
|
+
sender,
|
|
762
759
|
amount,
|
|
763
760
|
recipient,
|
|
764
761
|
};
|
package/src/api/index.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Api } from "@ledgerhq/coin-framework/api/index";
|
|
2
2
|
import type { AptosConfig as AptosConfigApi } from "../config";
|
|
3
3
|
import type { Balance, Pagination, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
|
|
4
4
|
import coinConfig from "../config";
|
|
5
|
-
import type { AptosAsset } from "../types/assets";
|
|
5
|
+
import type { AptosAsset, AptosExtra, AptosFeeParameters, AptosSender } from "../types/assets";
|
|
6
6
|
import { AptosAPI } from "../network";
|
|
7
7
|
import { combine } from "../logic/combine";
|
|
8
8
|
import { craftTransaction } from "../logic/craftTransaction";
|
|
9
9
|
import { getBalance } from "../logic/getBalance";
|
|
10
10
|
|
|
11
|
-
export function createApi(
|
|
11
|
+
export function createApi(
|
|
12
|
+
config: AptosConfigApi,
|
|
13
|
+
): Api<AptosAsset, AptosExtra, AptosSender, AptosFeeParameters> {
|
|
12
14
|
coinConfig.setCoinConfig(() => ({ ...config, status: { type: "active" } }));
|
|
13
15
|
|
|
14
16
|
const client = new AptosAPI(config.aptosSettings);
|
|
@@ -18,7 +20,7 @@ export function createApi(config: AptosConfigApi): AlpacaApi<AptosAsset> {
|
|
|
18
20
|
combine: (tx, signature, pubkey): string => combine(tx, signature, pubkey),
|
|
19
21
|
craftTransaction: (transactionIntent, _customFees): Promise<string> =>
|
|
20
22
|
craftTransaction(client, transactionIntent),
|
|
21
|
-
estimateFees: (transactionIntent: TransactionIntent<AptosAsset>) =>
|
|
23
|
+
estimateFees: (transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender>) =>
|
|
22
24
|
client.estimateFees(transactionIntent),
|
|
23
25
|
getBalance: (address): Promise<Balance<AptosAsset>[]> => getBalance(client, address),
|
|
24
26
|
lastBlock: () => client.getLastBlock(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TransactionIntent } from "@ledgerhq/coin-framework/lib/api/types";
|
|
2
|
-
import type { AptosAsset } from "../types/assets";
|
|
2
|
+
import type { AptosAsset, AptosExtra, AptosSender } from "../types/assets";
|
|
3
3
|
import type { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
4
4
|
import type { AptosAPI } from "../network";
|
|
5
5
|
import buildTransaction, { isTokenType } from "./buildTransaction";
|
|
@@ -10,7 +10,7 @@ import type { AptosBalance } from "../types";
|
|
|
10
10
|
|
|
11
11
|
export async function craftTransaction(
|
|
12
12
|
aptosClient: AptosAPI,
|
|
13
|
-
transactionIntent: TransactionIntent<AptosAsset>,
|
|
13
|
+
transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender>,
|
|
14
14
|
): Promise<string> {
|
|
15
15
|
const newTx = createTransaction();
|
|
16
16
|
newTx.amount = BigNumber(transactionIntent.amount.toString());
|
|
@@ -19,8 +19,8 @@ export async function craftTransaction(
|
|
|
19
19
|
newTx.useAllAmount = transactionIntent.amount === BigInt(0);
|
|
20
20
|
|
|
21
21
|
const account = {
|
|
22
|
-
freshAddress: transactionIntent.sender,
|
|
23
|
-
xpub: transactionIntent.
|
|
22
|
+
freshAddress: transactionIntent.sender.freshAddress,
|
|
23
|
+
xpub: transactionIntent.sender.xpub,
|
|
24
24
|
subAccounts: new Array<TokenAccount>(),
|
|
25
25
|
} as Account;
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ export async function craftTransaction(
|
|
|
29
29
|
let balance: AptosBalance | undefined;
|
|
30
30
|
|
|
31
31
|
if (newTx.useAllAmount === true) {
|
|
32
|
-
const balances = await aptosClient.getBalances(transactionIntent.sender);
|
|
32
|
+
const balances = await aptosClient.getBalances(transactionIntent.sender.freshAddress);
|
|
33
33
|
balance = balances?.find(
|
|
34
34
|
b => b.contractAddress.toLowerCase() === contractAddress?.toLowerCase(),
|
|
35
35
|
);
|
|
@@ -54,7 +54,9 @@ export async function craftTransaction(
|
|
|
54
54
|
return aptosTx.bcsToHex().toString();
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function getContractAddress(
|
|
57
|
+
function getContractAddress(
|
|
58
|
+
txIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender>,
|
|
59
|
+
): string {
|
|
58
60
|
if (txIntent.asset.type === "token" && isTokenType(txIntent.asset.standard)) {
|
|
59
61
|
return txIntent.asset.contractAddress;
|
|
60
62
|
}
|
package/src/network/client.ts
CHANGED
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
Pagination,
|
|
45
45
|
TransactionIntent,
|
|
46
46
|
} from "@ledgerhq/coin-framework/api/types";
|
|
47
|
-
import { AptosAsset } from "../types/assets";
|
|
47
|
+
import { AptosAsset, AptosExtra, AptosFeeParameters, AptosSender } from "../types/assets";
|
|
48
48
|
import { log } from "@ledgerhq/logs";
|
|
49
49
|
import { transactionsToOperations } from "../logic/transactionsToOperations";
|
|
50
50
|
import { isTestnet } from "../logic/isTestnet";
|
|
@@ -223,8 +223,10 @@ export class AptosAPI {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
async estimateFees(
|
|
227
|
-
|
|
226
|
+
async estimateFees(
|
|
227
|
+
transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender>,
|
|
228
|
+
): Promise<FeeEstimation<AptosFeeParameters>> {
|
|
229
|
+
const publicKeyEd = new Ed25519PublicKey(transactionIntent.sender.xpub);
|
|
228
230
|
|
|
229
231
|
const txPayload: InputEntryFunctionData = {
|
|
230
232
|
function: "0x1::aptos_account::transfer_coins",
|
|
@@ -254,7 +256,11 @@ export class AptosAPI {
|
|
|
254
256
|
gasUnitPrice: DEFAULT_GAS_PRICE.toString(),
|
|
255
257
|
};
|
|
256
258
|
|
|
257
|
-
const tx = await this.generateTransaction(
|
|
259
|
+
const tx = await this.generateTransaction(
|
|
260
|
+
transactionIntent.sender.freshAddress,
|
|
261
|
+
txPayload,
|
|
262
|
+
txOptions,
|
|
263
|
+
);
|
|
258
264
|
|
|
259
265
|
const simulation = await this.simulateTransaction(publicKeyEd, tx);
|
|
260
266
|
const completedTx = simulation[0];
|
|
@@ -267,7 +273,6 @@ export class AptosAPI {
|
|
|
267
273
|
return {
|
|
268
274
|
value: BigInt(expectedGas.toString()),
|
|
269
275
|
parameters: {
|
|
270
|
-
storageLimit: BigInt(0),
|
|
271
276
|
gasLimit: BigInt(gasLimit.toString()),
|
|
272
277
|
gasPrice: BigInt(gasPrice.toString()),
|
|
273
278
|
},
|