@ledgerhq/coin-aptos 2.6.1-nightly.0 → 2.7.0-nightly.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.
Files changed (93) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +22 -0
  3. package/lib/__tests__/api/craftTransaction.unit.test.js +4 -4
  4. package/lib/__tests__/api/craftTransaction.unit.test.js.map +1 -1
  5. package/lib/__tests__/api/getBalance.unit.test.js +3 -4
  6. package/lib/__tests__/api/getBalance.unit.test.js.map +1 -1
  7. package/lib/__tests__/api/index.integ.test.js +19 -28
  8. package/lib/__tests__/api/index.integ.test.js.map +1 -1
  9. package/lib/__tests__/api/index.test.js.map +1 -1
  10. package/lib/__tests__/logic/getBalances.test.js +3 -4
  11. package/lib/__tests__/logic/getBalances.test.js.map +1 -1
  12. package/lib/__tests__/network/client.test.js +4 -6
  13. package/lib/__tests__/network/client.test.js.map +1 -1
  14. package/lib/api/index.d.ts +1 -2
  15. package/lib/api/index.d.ts.map +1 -1
  16. package/lib/api/index.js.map +1 -1
  17. package/lib/logic/buildTransaction.d.ts.map +1 -1
  18. package/lib/logic/buildTransaction.js +1 -0
  19. package/lib/logic/buildTransaction.js.map +1 -1
  20. package/lib/logic/craftTransaction.d.ts +1 -2
  21. package/lib/logic/craftTransaction.d.ts.map +1 -1
  22. package/lib/logic/craftTransaction.js +6 -4
  23. package/lib/logic/craftTransaction.js.map +1 -1
  24. package/lib/logic/getBalances.d.ts +1 -2
  25. package/lib/logic/getBalances.d.ts.map +1 -1
  26. package/lib/logic/getBalances.js +2 -2
  27. package/lib/logic/getBalances.js.map +1 -1
  28. package/lib/logic/processRecipients.d.ts +1 -2
  29. package/lib/logic/processRecipients.d.ts.map +1 -1
  30. package/lib/logic/processRecipients.js.map +1 -1
  31. package/lib/logic/transactionsToOperations.d.ts +1 -2
  32. package/lib/logic/transactionsToOperations.d.ts.map +1 -1
  33. package/lib/logic/transactionsToOperations.js +3 -4
  34. package/lib/logic/transactionsToOperations.js.map +1 -1
  35. package/lib/network/client.d.ts +2 -3
  36. package/lib/network/client.d.ts.map +1 -1
  37. package/lib/network/client.js +7 -6
  38. package/lib/network/client.js.map +1 -1
  39. package/lib/types/assets.d.ts +0 -6
  40. package/lib/types/assets.d.ts.map +1 -1
  41. package/lib-es/__tests__/api/craftTransaction.unit.test.js +4 -4
  42. package/lib-es/__tests__/api/craftTransaction.unit.test.js.map +1 -1
  43. package/lib-es/__tests__/api/getBalance.unit.test.js +3 -4
  44. package/lib-es/__tests__/api/getBalance.unit.test.js.map +1 -1
  45. package/lib-es/__tests__/api/index.integ.test.js +19 -28
  46. package/lib-es/__tests__/api/index.integ.test.js.map +1 -1
  47. package/lib-es/__tests__/api/index.test.js.map +1 -1
  48. package/lib-es/__tests__/logic/getBalances.test.js +3 -4
  49. package/lib-es/__tests__/logic/getBalances.test.js.map +1 -1
  50. package/lib-es/__tests__/network/client.test.js +4 -6
  51. package/lib-es/__tests__/network/client.test.js.map +1 -1
  52. package/lib-es/api/index.d.ts +1 -2
  53. package/lib-es/api/index.d.ts.map +1 -1
  54. package/lib-es/api/index.js.map +1 -1
  55. package/lib-es/logic/buildTransaction.d.ts.map +1 -1
  56. package/lib-es/logic/buildTransaction.js +1 -0
  57. package/lib-es/logic/buildTransaction.js.map +1 -1
  58. package/lib-es/logic/craftTransaction.d.ts +1 -2
  59. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  60. package/lib-es/logic/craftTransaction.js +6 -4
  61. package/lib-es/logic/craftTransaction.js.map +1 -1
  62. package/lib-es/logic/getBalances.d.ts +1 -2
  63. package/lib-es/logic/getBalances.d.ts.map +1 -1
  64. package/lib-es/logic/getBalances.js +2 -2
  65. package/lib-es/logic/getBalances.js.map +1 -1
  66. package/lib-es/logic/processRecipients.d.ts +1 -2
  67. package/lib-es/logic/processRecipients.d.ts.map +1 -1
  68. package/lib-es/logic/processRecipients.js.map +1 -1
  69. package/lib-es/logic/transactionsToOperations.d.ts +1 -2
  70. package/lib-es/logic/transactionsToOperations.d.ts.map +1 -1
  71. package/lib-es/logic/transactionsToOperations.js +3 -4
  72. package/lib-es/logic/transactionsToOperations.js.map +1 -1
  73. package/lib-es/network/client.d.ts +2 -3
  74. package/lib-es/network/client.d.ts.map +1 -1
  75. package/lib-es/network/client.js +7 -6
  76. package/lib-es/network/client.js.map +1 -1
  77. package/lib-es/types/assets.d.ts +0 -6
  78. package/lib-es/types/assets.d.ts.map +1 -1
  79. package/package.json +5 -5
  80. package/src/__tests__/api/craftTransaction.unit.test.ts +9 -10
  81. package/src/__tests__/api/getBalance.unit.test.ts +3 -4
  82. package/src/__tests__/api/index.integ.test.ts +19 -28
  83. package/src/__tests__/api/index.test.ts +2 -3
  84. package/src/__tests__/logic/getBalances.test.ts +3 -4
  85. package/src/__tests__/network/client.test.ts +7 -10
  86. package/src/api/index.ts +4 -6
  87. package/src/logic/buildTransaction.ts +1 -0
  88. package/src/logic/craftTransaction.ts +10 -7
  89. package/src/logic/getBalances.ts +3 -4
  90. package/src/logic/processRecipients.ts +4 -8
  91. package/src/logic/transactionsToOperations.ts +6 -8
  92. package/src/network/client.ts +9 -12
  93. package/src/types/assets.ts +0 -9
@@ -1,7 +1,6 @@
1
1
  import { Hex, RawTransaction, Deserializer } from "@aptos-labs/ts-sdk";
2
2
  import type { TransactionIntent } from "@ledgerhq/coin-framework/api/types";
3
3
  import { createApi } from "../../api";
4
- import type { AptosAsset } from "../../types/assets";
5
4
  import { AptosAPI } from "../../network";
6
5
  import { APTOS_ASSET_ID } from "../../constants";
7
6
 
@@ -45,13 +44,13 @@ describe("craftTransaction", () => {
45
44
  aptosSettings: {},
46
45
  });
47
46
 
48
- const txArg: TransactionIntent<AptosAsset> = {
47
+ const txArg: TransactionIntent = {
49
48
  type: "send",
50
49
  sender: SENDER_ADDR,
51
50
  senderPublicKey: "public-key",
52
51
  recipient: RECIPIENT_ADDR,
53
52
  amount: 10n,
54
- asset: { type: "token", standard: "coin", contractAddress: "0x42::token::Token" },
53
+ asset: { type: "coin", assetReference: "0x42::token::Token" },
55
54
  };
56
55
 
57
56
  const tx = await api.craftTransaction(txArg);
@@ -86,7 +85,7 @@ describe("craftTransaction", () => {
86
85
  aptosSettings: {},
87
86
  });
88
87
 
89
- const txArg: TransactionIntent<AptosAsset> = {
88
+ const txArg: TransactionIntent = {
90
89
  type: "send",
91
90
  sender: SENDER_ADDR,
92
91
  senderPublicKey: "public-key",
@@ -127,13 +126,13 @@ describe("craftTransaction", () => {
127
126
  aptosSettings: {},
128
127
  });
129
128
 
130
- const txArg: TransactionIntent<AptosAsset> = {
129
+ const txArg: TransactionIntent = {
131
130
  type: "send",
132
131
  sender: SENDER_ADDR,
133
132
  senderPublicKey: "public-key",
134
133
  recipient: RECIPIENT_ADDR,
135
134
  amount: 10n,
136
- asset: { type: "token", standard: "coin", contractAddress: "0x42::token::Token" },
135
+ asset: { type: "coin", assetReference: "0x42::token::Token" },
137
136
  };
138
137
 
139
138
  const tx = await api.craftTransaction(txArg);
@@ -168,13 +167,13 @@ describe("craftTransaction", () => {
168
167
  aptosSettings: {},
169
168
  });
170
169
 
171
- const txArg: TransactionIntent<AptosAsset> = {
170
+ const txArg: TransactionIntent = {
172
171
  type: "send",
173
172
  sender: SENDER_ADDR,
174
173
  senderPublicKey: "public-key",
175
174
  recipient: RECIPIENT_ADDR,
176
175
  amount: 0n,
177
- asset: { type: "token", standard: "fungible_asset", contractAddress: "0x42" },
176
+ asset: { type: "fungible_asset", assetReference: "0x42" },
178
177
  };
179
178
 
180
179
  const tx = await api.craftTransaction(txArg);
@@ -209,13 +208,13 @@ describe("craftTransaction", () => {
209
208
  aptosSettings: {},
210
209
  });
211
210
 
212
- const txArg: TransactionIntent<AptosAsset> = {
211
+ const txArg: TransactionIntent = {
213
212
  type: "send",
214
213
  sender: SENDER_ADDR,
215
214
  senderPublicKey: "public-key",
216
215
  recipient: RECIPIENT_ADDR,
217
216
  amount: 10n,
218
- asset: { type: "token", standard: "asset", contractAddress: "0x42::token::Token" },
217
+ asset: { type: "asset", assetReference: "0x42::token::Token" },
219
218
  };
220
219
 
221
220
  expect(async () => await api.craftTransaction(txArg)).rejects.toThrow(
@@ -70,7 +70,7 @@ describe("getBalance", () => {
70
70
  expect(await api.getBalance(accountAddress)).toStrictEqual([
71
71
  {
72
72
  value: 25n,
73
- asset: { type: "token", contractAddress: TOKEN_ASSET_ID, standard: TOKEN_TYPE.COIN },
73
+ asset: { type: TOKEN_TYPE.COIN, assetReference: TOKEN_ASSET_ID },
74
74
  },
75
75
  ]);
76
76
  });
@@ -88,9 +88,8 @@ describe("getBalance", () => {
88
88
  {
89
89
  value: 25n,
90
90
  asset: {
91
- type: "token",
92
- contractAddress: TOKEN_ASSET_ID,
93
- standard: TOKEN_TYPE.FUNGIBLE_ASSET,
91
+ type: TOKEN_TYPE.FUNGIBLE_ASSET,
92
+ assetReference: TOKEN_ASSET_ID,
94
93
  },
95
94
  },
96
95
  ]);
@@ -71,9 +71,8 @@ describe("createApi", () => {
71
71
 
72
72
  const fees = await api.estimateFees({
73
73
  asset: {
74
- type: "token",
75
- standard: "coin",
76
- contractAddress:
74
+ type: "coin",
75
+ assetReference:
77
76
  "0x50788befc1107c0cc4473848a92e5c783c635866ce3c98de71d2eeb7d2a34f85::usdc_coin::USDCoin",
78
77
  },
79
78
  type: "send",
@@ -91,9 +90,8 @@ describe("createApi", () => {
91
90
 
92
91
  const fees = await api.estimateFees({
93
92
  asset: {
94
- type: "token",
95
- standard: "fungible_asset",
96
- contractAddress: "0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b",
93
+ type: "fungible_asset",
94
+ assetReference: "0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b",
97
95
  },
98
96
  type: "send",
99
97
  sender: sender.freshAddress,
@@ -138,9 +136,8 @@ describe("createApi", () => {
138
136
  recipient: recipient.freshAddress,
139
137
  type: "send",
140
138
  asset: {
141
- type: "token",
142
- standard: "coin",
143
- contractAddress:
139
+ type: "coin",
140
+ assetReference:
144
141
  "0x50788befc1107c0cc4473848a92e5c783c635866ce3c98de71d2eeb7d2a34f85::aptos_coin::AptosCoin",
145
142
  },
146
143
  },
@@ -165,9 +162,8 @@ describe("createApi", () => {
165
162
  recipient: recipient.freshAddress,
166
163
  type: "send",
167
164
  asset: {
168
- type: "token",
169
- standard: "coin",
170
- contractAddress:
165
+ type: "coin",
166
+ assetReference:
171
167
  "0x50788befc1107c0cc4473848a92e5c783c635866ce3c98de71d2eeb7d2a34f85::aptos_coin::AptosCoin",
172
168
  },
173
169
  },
@@ -194,9 +190,8 @@ describe("createApi", () => {
194
190
  recipient: r.freshAddress,
195
191
  type: "send",
196
192
  asset: {
197
- type: "token",
198
- standard: "fungible_asset",
199
- contractAddress: "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
193
+ type: "fungible_asset",
194
+ assetReference: "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
200
195
  },
201
196
  },
202
197
  0n,
@@ -225,7 +220,7 @@ describe("createApi", () => {
225
220
  const tokenBalances = balances.filter(
226
221
  b =>
227
222
  b.asset.type === assetTypeToken &&
228
- b.asset.contractAddress ===
223
+ b.asset.assetReference ===
229
224
  "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
230
225
  );
231
226
  expect(tokenBalances.length).toBeGreaterThan(0);
@@ -345,9 +340,8 @@ describe("createApi", () => {
345
340
  recipients: [tokenAccount.freshAddress],
346
341
  senders: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
347
342
  asset: {
348
- type: "token",
349
- standard: "coin",
350
- contractAddress:
343
+ type: "coin",
344
+ assetReference:
351
345
  "0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5::staked_coin::StakedAptos",
352
346
  },
353
347
  tx: {
@@ -364,9 +358,8 @@ describe("createApi", () => {
364
358
  recipients: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
365
359
  senders: [tokenAccount.freshAddress],
366
360
  asset: {
367
- type: "token",
368
- standard: "coin",
369
- contractAddress:
361
+ type: "coin",
362
+ assetReference:
370
363
  "0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5::staked_coin::StakedAptos",
371
364
  },
372
365
  tx: {
@@ -388,9 +381,8 @@ describe("createApi", () => {
388
381
  recipients: [tokenAccount.freshAddress],
389
382
  senders: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
390
383
  asset: {
391
- type: "token",
392
- standard: "fungible_asset",
393
- contractAddress: "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
384
+ type: "fungible_asset",
385
+ assetReference: "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
394
386
  },
395
387
  tx: {
396
388
  hash: "0x88856968603dee4f08579036bc30322b9a5f329561656888e3467ce27cc11ea7",
@@ -406,9 +398,8 @@ describe("createApi", () => {
406
398
  recipients: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
407
399
  senders: [tokenAccount.freshAddress],
408
400
  asset: {
409
- type: "token",
410
- standard: "fungible_asset",
411
- contractAddress: "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
401
+ type: "fungible_asset",
402
+ assetReference: "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
412
403
  },
413
404
  tx: {
414
405
  hash: "0x8aa9e980760fe8aeb6804f387350b3019a2471aa61a5506a260c32cd5d6db32c",
@@ -1,6 +1,5 @@
1
1
  import { Aptos } from "@aptos-labs/ts-sdk";
2
2
  import type { AlpacaApi } from "@ledgerhq/coin-framework/api/types";
3
- import type { AptosAsset } from "../../types/assets";
4
3
  import type { AptosConfig } from "../../config";
5
4
  import { createApi } from "../../api";
6
5
  import coinConfig from "../../config";
@@ -33,7 +32,7 @@ describe("createApi", () => {
33
32
  });
34
33
 
35
34
  it("should return an API object with alpaca api methods", () => {
36
- const api: AlpacaApi<AptosAsset> = createApi(mockAptosConfig);
35
+ const api: AlpacaApi = createApi(mockAptosConfig);
37
36
 
38
37
  // Check that methods are set with what we expect
39
38
  expect(api.broadcast).toBeDefined();
@@ -69,7 +68,7 @@ describe("lastBlock", () => {
69
68
  }),
70
69
  }));
71
70
 
72
- const api: AlpacaApi<AptosAsset> = createApi(mockAptosConfig);
71
+ const api: AlpacaApi = createApi(mockAptosConfig);
73
72
 
74
73
  expect(await api.lastBlock()).toStrictEqual({
75
74
  height: 123,
@@ -51,7 +51,7 @@ describe("getBalance", () => {
51
51
  expect(balances).toStrictEqual([
52
52
  {
53
53
  value: 25n,
54
- asset: { type: "token", contractAddress: TOKEN_ASSET_ID, standard: TOKEN_TYPE.COIN },
54
+ asset: { type: TOKEN_TYPE.COIN, assetReference: TOKEN_ASSET_ID },
55
55
  },
56
56
  ]);
57
57
  });
@@ -70,9 +70,8 @@ describe("getBalance", () => {
70
70
  {
71
71
  value: 25n,
72
72
  asset: {
73
- type: "token",
74
- contractAddress: TOKEN_ASSET_ID,
75
- standard: TOKEN_TYPE.FUNGIBLE_ASSET,
73
+ type: TOKEN_TYPE.FUNGIBLE_ASSET,
74
+ assetReference: TOKEN_ASSET_ID,
76
75
  },
77
76
  },
78
77
  ]);
@@ -14,7 +14,6 @@ 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";
18
17
  import { Pagination, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
19
18
  import { APTOS_ASSET_ID } from "../../constants";
20
19
  import { AptosBalance, AptosTransaction } from "../../types";
@@ -622,7 +621,7 @@ describe("Aptos API", () => {
622
621
  const recipient = "address2";
623
622
 
624
623
  const api = new AptosAPI("aptos");
625
- const transactionIntent: TransactionIntent<AptosAsset> = {
624
+ const transactionIntent: TransactionIntent = {
626
625
  asset: {
627
626
  type: "native",
628
627
  },
@@ -687,11 +686,10 @@ describe("Aptos API", () => {
687
686
  const recipient = "address2";
688
687
 
689
688
  const api = new AptosAPI("aptos");
690
- const transactionIntent: TransactionIntent<AptosAsset> = {
689
+ const transactionIntent: TransactionIntent = {
691
690
  asset: {
692
- type: "token",
693
- standard: "coin",
694
- contractAddress: "0x111",
691
+ type: "coin",
692
+ assetReference: "0x111",
695
693
  },
696
694
  type: "send",
697
695
  sender: sender.freshAddress,
@@ -753,11 +751,10 @@ describe("Aptos API", () => {
753
751
  const recipient = "address2";
754
752
 
755
753
  const api = new AptosAPI("aptos");
756
- const transactionIntent: TransactionIntent<AptosAsset> = {
754
+ const transactionIntent: TransactionIntent = {
757
755
  asset: {
758
- type: "token",
759
- standard: "fungible_asset",
760
- contractAddress: "0x111",
756
+ type: "fungible_asset",
757
+ assetReference: "0x111",
761
758
  },
762
759
  type: "send",
763
760
  sender: sender.freshAddress,
package/src/api/index.ts CHANGED
@@ -2,13 +2,12 @@ import type { AlpacaApi, Block, BlockInfo } from "@ledgerhq/coin-framework/api/i
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";
6
5
  import { AptosAPI } from "../network";
7
6
  import { combine } from "../logic/combine";
8
7
  import { craftTransaction } from "../logic/craftTransaction";
9
8
  import { getBalances } from "../logic/getBalances";
10
9
 
11
- export function createApi(config: AptosConfigApi): AlpacaApi<AptosAsset> {
10
+ export function createApi(config: AptosConfigApi): AlpacaApi {
12
11
  coinConfig.setCoinConfig(() => ({ ...config, status: { type: "active" } }));
13
12
 
14
13
  const client = new AptosAPI(config.aptosSettings);
@@ -18,13 +17,12 @@ export function createApi(config: AptosConfigApi): AlpacaApi<AptosAsset> {
18
17
  combine: (tx, signature, pubkey): string => combine(tx, signature, pubkey),
19
18
  craftTransaction: (transactionIntent, _customFees): Promise<string> =>
20
19
  craftTransaction(client, transactionIntent),
21
- estimateFees: (transactionIntent: TransactionIntent<AptosAsset>) =>
22
- client.estimateFees(transactionIntent),
23
- getBalance: (address): Promise<Balance<AptosAsset>[]> => getBalances(client, address),
20
+ estimateFees: (transactionIntent: TransactionIntent) => client.estimateFees(transactionIntent),
21
+ getBalance: (address): Promise<Balance[]> => getBalances(client, address),
24
22
  lastBlock: () => client.getLastBlock(),
25
23
  listOperations: (address: string, pagination: Pagination) =>
26
24
  client.listOperations(address, pagination),
27
- getBlock(_height): Promise<Block<AptosAsset>> {
25
+ getBlock(_height): Promise<Block> {
28
26
  throw new Error("getBlock is not supported");
29
27
  },
30
28
  getBlockInfo(_height: number): Promise<BlockInfo> {
@@ -88,6 +88,7 @@ const getPayload = ({
88
88
  };
89
89
  };
90
90
 
91
+ // FIXME: terminology overlop, using tokentype here when AssetInfo refers to `standard`
91
92
  export const isTokenType = (value: string): boolean => {
92
93
  return Object.values(TOKEN_TYPE).includes(value as TOKEN_TYPE);
93
94
  };
@@ -1,5 +1,4 @@
1
1
  import type { TransactionIntent } from "@ledgerhq/coin-framework/lib/api/types";
2
- import type { AptosAsset } from "../types/assets";
3
2
  import type { Account, TokenAccount } from "@ledgerhq/types-live";
4
3
  import type { AptosAPI } from "../network";
5
4
  import buildTransaction, { isTokenType } from "./buildTransaction";
@@ -10,7 +9,7 @@ import type { AptosBalance } from "../types";
10
9
 
11
10
  export async function craftTransaction(
12
11
  aptosClient: AptosAPI,
13
- transactionIntent: TransactionIntent<AptosAsset>,
12
+ transactionIntent: TransactionIntent,
14
13
  ): Promise<string> {
15
14
  const newTx = createTransaction();
16
15
  newTx.amount = BigNumber(transactionIntent.amount.toString());
@@ -39,8 +38,8 @@ export async function craftTransaction(
39
38
  }
40
39
  }
41
40
 
42
- if (transactionIntent.asset.type === "token") {
43
- tokenType = transactionIntent.asset.standard as TOKEN_TYPE;
41
+ if (transactionIntent.asset.type !== "native") {
42
+ tokenType = transactionIntent.asset.type as TOKEN_TYPE;
44
43
  }
45
44
 
46
45
  const aptosTx = await buildTransaction(
@@ -54,9 +53,13 @@ export async function craftTransaction(
54
53
  return aptosTx.bcsToHex().toString();
55
54
  }
56
55
 
57
- function getContractAddress(txIntent: TransactionIntent<AptosAsset>): string {
58
- if (txIntent.asset.type === "token" && isTokenType(txIntent.asset.standard)) {
59
- return txIntent.asset.contractAddress;
56
+ function getContractAddress(txIntent: TransactionIntent): string {
57
+ if (
58
+ txIntent.asset.type !== "native" &&
59
+ isTokenType(txIntent.asset.type as string) &&
60
+ "assetReference" in txIntent.asset
61
+ ) {
62
+ return txIntent.asset.assetReference as string;
60
63
  }
61
64
 
62
65
  return APTOS_ASSET_ID;
@@ -1,5 +1,4 @@
1
1
  import type { Balance } from "@ledgerhq/coin-framework/lib/api/types";
2
- import type { AptosAsset } from "../types/assets";
3
2
  import type { AptosAPI } from "../network";
4
3
  import { APTOS_ASSET_ID, TOKEN_TYPE } from "../constants";
5
4
 
@@ -7,12 +6,12 @@ export async function getBalances(
7
6
  aptosClient: AptosAPI,
8
7
  address: string,
9
8
  contract_address?: string,
10
- ): Promise<Balance<AptosAsset>[]> {
9
+ ): Promise<Balance[]> {
11
10
  const balances = await aptosClient.getBalances(address, contract_address);
12
11
 
13
12
  return balances.map(balance => {
14
13
  const isNative = balance.contractAddress === APTOS_ASSET_ID;
15
- const standard =
14
+ const type =
16
15
  balance.contractAddress.split("::").length === 3
17
16
  ? TOKEN_TYPE.COIN
18
17
  : TOKEN_TYPE.FUNGIBLE_ASSET;
@@ -21,7 +20,7 @@ export async function getBalances(
21
20
  value: BigInt(balance.amount.toString()),
22
21
  asset: isNative
23
22
  ? { type: "native" }
24
- : { type: "token", contractAddress: balance.contractAddress, standard: standard },
23
+ : { type: type, assetReference: balance.contractAddress },
25
24
  };
26
25
  });
27
26
  }
@@ -1,7 +1,6 @@
1
1
  import { InputEntryFunctionData } from "@aptos-labs/ts-sdk";
2
2
  import { Operation } from "@ledgerhq/types-live";
3
3
  import { Operation as APIOperation } from "@ledgerhq/coin-framework/api/types";
4
- import { AptosAsset } from "../types/assets";
5
4
  import {
6
5
  BATCH_TRANSFER_TYPES,
7
6
  COIN_TRANSFER_TYPES,
@@ -16,7 +15,7 @@ const transferLikeFunctions = (payload: InputEntryFunctionData) =>
16
15
  DELEGATION_POOL_TYPES.includes(payload.function);
17
16
 
18
17
  const addLikeFunctionsToRecipients = (
19
- op: Operation | APIOperation<AptosAsset>,
18
+ op: Operation | APIOperation,
20
19
  payload: InputEntryFunctionData,
21
20
  ) => {
22
21
  if (
@@ -28,10 +27,7 @@ const addLikeFunctionsToRecipients = (
28
27
  }
29
28
  };
30
29
 
31
- const addFungibleToRecipients = (
32
- op: Operation | APIOperation<AptosAsset>,
33
- payload: InputEntryFunctionData,
34
- ) => {
30
+ const addFungibleToRecipients = (op: Operation | APIOperation, payload: InputEntryFunctionData) => {
35
31
  if (
36
32
  payload.functionArguments &&
37
33
  payload.functionArguments.length > 1 &&
@@ -43,7 +39,7 @@ const addFungibleToRecipients = (
43
39
  };
44
40
 
45
41
  const addBatchedFunctions = (
46
- op: Operation | APIOperation<AptosAsset>,
42
+ op: Operation | APIOperation,
47
43
  payload: InputEntryFunctionData,
48
44
  address: string,
49
45
  ) => {
@@ -66,7 +62,7 @@ const addBatchedFunctions = (
66
62
  export function processRecipients(
67
63
  payload: InputEntryFunctionData,
68
64
  address: string,
69
- op: Operation | APIOperation<AptosAsset>,
65
+ op: Operation | APIOperation,
70
66
  function_address: string,
71
67
  ): void {
72
68
  // get recipients by 3 groups
@@ -1,6 +1,5 @@
1
1
  import { AptosTransaction } from "../types";
2
2
  import { Operation } from "@ledgerhq/coin-framework/api/types";
3
- import { AptosAsset } from "../types/assets";
4
3
  import BigNumber from "bignumber.js";
5
4
  import { EntryFunctionPayloadResponse, InputEntryFunctionData } from "@aptos-labs/ts-sdk";
6
5
  import { APTOS_ASSET_ID, OP_TYPE } from "../constants";
@@ -29,7 +28,7 @@ const detectType = (address: string, tx: AptosTransaction, value: BigNumber): OP
29
28
  return type;
30
29
  };
31
30
 
32
- const getTokenStandard = (coin_id: string): string => {
31
+ const getTokenType = (coin_id: string) => {
33
32
  const parts = coin_id.split("::");
34
33
  if (parts.length === 3) {
35
34
  return "coin";
@@ -40,8 +39,8 @@ const getTokenStandard = (coin_id: string): string => {
40
39
  export function transactionsToOperations(
41
40
  address: string,
42
41
  txs: (AptosTransaction | null)[],
43
- ): Operation<AptosAsset>[] {
44
- const operations: Operation<AptosAsset>[] = [];
42
+ ): Operation[] {
43
+ const operations: Operation[] = [];
45
44
 
46
45
  return txs.reduce((acc, tx) => {
47
46
  if (tx === null) {
@@ -62,7 +61,7 @@ export function transactionsToOperations(
62
61
  const value = calculateAmount(tx.sender, address, amount_in, amount_out);
63
62
  const type = detectType(address, tx, value);
64
63
 
65
- const op: Operation<AptosAsset> = {
64
+ const op: Operation = {
66
65
  id: tx.hash,
67
66
  type,
68
67
  senders: [],
@@ -94,9 +93,8 @@ export function transactionsToOperations(
94
93
  return acc;
95
94
  } else {
96
95
  op.asset = {
97
- type: "token",
98
- standard: getTokenStandard(coin_id),
99
- contractAddress: coin_id,
96
+ type: getTokenType(coin_id),
97
+ assetReference: coin_id,
100
98
  };
101
99
  acc.push(op);
102
100
  }
@@ -48,7 +48,6 @@ import {
48
48
  Pagination,
49
49
  TransactionIntent,
50
50
  } from "@ledgerhq/coin-framework/api/types";
51
- import { AptosAsset } from "../types/assets";
52
51
  import { log } from "@ledgerhq/logs";
53
52
  import { transactionsToOperations } from "../logic/transactionsToOperations";
54
53
  import { isTestnet } from "../logic/isTestnet";
@@ -181,7 +180,7 @@ export class AptosAPI {
181
180
  };
182
181
  }
183
182
 
184
- async estimateFees(transactionIntent: TransactionIntent<AptosAsset>): Promise<FeeEstimation> {
183
+ async estimateFees(transactionIntent: TransactionIntent): Promise<FeeEstimation> {
185
184
  const publicKeyEd = new Ed25519PublicKey(transactionIntent?.senderPublicKey ?? "");
186
185
 
187
186
  const txPayload: InputEntryFunctionData = {
@@ -190,20 +189,21 @@ export class AptosAPI {
190
189
  functionArguments: [transactionIntent.recipient, transactionIntent.amount],
191
190
  };
192
191
 
193
- if (transactionIntent.asset.type === "token") {
194
- const { standard } = transactionIntent.asset;
192
+ // TODO: this should be looked over again, might be more precise in terms of types..
193
+ if (transactionIntent.asset.type !== "native") {
194
+ const { type } = transactionIntent.asset;
195
195
 
196
- if (standard === TOKEN_TYPE.FUNGIBLE_ASSET) {
196
+ if (type === TOKEN_TYPE.FUNGIBLE_ASSET) {
197
197
  txPayload.function = "0x1::primary_fungible_store::transfer";
198
198
  txPayload.typeArguments = ["0x1::fungible_asset::Metadata"];
199
199
  txPayload.functionArguments = [
200
- transactionIntent.asset.contractAddress,
200
+ transactionIntent.asset.assetReference,
201
201
  transactionIntent.recipient,
202
202
  transactionIntent.amount,
203
203
  ];
204
- } else if (standard === TOKEN_TYPE.COIN) {
204
+ } else if (type === TOKEN_TYPE.COIN) {
205
205
  txPayload.function = "0x1::aptos_account::transfer_coins";
206
- txPayload.typeArguments = [transactionIntent.asset.contractAddress];
206
+ txPayload.typeArguments = [transactionIntent.asset.assetReference as string];
207
207
  }
208
208
  }
209
209
 
@@ -266,10 +266,7 @@ export class AptosAPI {
266
266
  }
267
267
  }
268
268
 
269
- async listOperations(
270
- rawAddress: string,
271
- pagination: Pagination,
272
- ): Promise<[Operation<AptosAsset>[], string]> {
269
+ async listOperations(rawAddress: string, pagination: Pagination): Promise<[Operation[], string]> {
273
270
  const address = normalizeAddress(rawAddress);
274
271
  const transactions = await this.getAccountInfo(address, pagination.minHeight.toString());
275
272
  const newOperations = transactionsToOperations(address, transactions.transactions);
@@ -1,12 +1,3 @@
1
- import type { Asset } from "@ledgerhq/coin-framework/api/types";
2
-
3
- export type AptosAsset = Asset<AptosTokenInformation>;
4
-
5
- export type AptosTokenInformation = {
6
- standard: string;
7
- contractAddress: string;
8
- };
9
-
10
1
  export type AptosExtra = Record<string, unknown>;
11
2
 
12
3
  export type AptosFeeParameters = {