@ledgerhq/coin-hedera 1.15.0-nightly.20251126023856 → 1.15.0-nightly.20251126160702
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/CHANGELOG.md +10 -8
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +6 -2
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/broadcast.js +1 -1
- package/lib/bridge/broadcast.js.map +1 -1
- package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -1
- package/lib/bridge/buildOptimisticOperation.js +80 -15
- package/lib/bridge/buildOptimisticOperation.js.map +1 -1
- package/lib/bridge/estimateMaxSpendable.js +5 -2
- package/lib/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +70 -13
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/index.js +1 -1
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +40 -7
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +19 -2
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/synchronisation.d.ts +2 -0
- package/lib/bridge/synchronisation.d.ts.map +1 -1
- package/lib/bridge/synchronisation.js +101 -30
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/bridge/utils.d.ts +35 -2
- package/lib/bridge/utils.d.ts.map +1 -1
- package/lib/bridge/utils.js +215 -16
- package/lib/bridge/utils.js.map +1 -1
- package/lib/constants.d.ts +22 -2
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +42 -2
- package/lib/constants.js.map +1 -1
- package/lib/deviceTransactionConfig.d.ts +1 -1
- package/lib/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/deviceTransactionConfig.js +8 -0
- package/lib/deviceTransactionConfig.js.map +1 -1
- package/lib/errors.d.ts +3 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +2 -1
- package/lib/errors.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +4 -4
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +46 -5
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts +2 -4
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +45 -5
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +7 -3
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/utils.d.ts +24 -2
- package/lib/logic/utils.d.ts.map +1 -1
- package/lib/logic/utils.js +66 -13
- package/lib/logic/utils.js.map +1 -1
- package/lib/network/api.d.ts +12 -1
- package/lib/network/api.d.ts.map +1 -1
- package/lib/network/api.js +91 -19
- package/lib/network/api.js.map +1 -1
- package/lib/network/rpc.d.ts.map +1 -1
- package/lib/network/rpc.js +1 -0
- package/lib/network/rpc.js.map +1 -1
- package/lib/network/thirdweb.d.ts +21 -0
- package/lib/network/thirdweb.d.ts.map +1 -0
- package/lib/network/thirdweb.js +72 -0
- package/lib/network/thirdweb.js.map +1 -0
- package/lib/network/utils.d.ts +4 -1
- package/lib/network/utils.d.ts.map +1 -1
- package/lib/network/utils.js +53 -1
- package/lib/network/utils.js.map +1 -1
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib/test/bridgeDatasetTest.js +4 -4
- package/lib/test/bridgeDatasetTest.js.map +1 -1
- package/lib/test/fixtures/account.fixture.js +1 -1
- package/lib/test/fixtures/account.fixture.js.map +1 -1
- package/lib/test/fixtures/common.fixture.d.ts +12 -0
- package/lib/test/fixtures/common.fixture.d.ts.map +1 -0
- package/lib/test/fixtures/common.fixture.js +66 -0
- package/lib/test/fixtures/common.fixture.js.map +1 -0
- package/lib/test/fixtures/currency.fixture.d.ts +3 -1
- package/lib/test/fixtures/currency.fixture.d.ts.map +1 -1
- package/lib/test/fixtures/currency.fixture.js +63 -16
- package/lib/test/fixtures/currency.fixture.js.map +1 -1
- package/lib/test/fixtures/mirror.fixture.d.ts +3 -1
- package/lib/test/fixtures/mirror.fixture.d.ts.map +1 -1
- package/lib/test/fixtures/mirror.fixture.js +12 -1
- package/lib/test/fixtures/mirror.fixture.js.map +1 -1
- package/lib/test/fixtures/thirdweb.fixture.d.ts +3 -0
- package/lib/test/fixtures/thirdweb.fixture.d.ts.map +1 -0
- package/lib/test/fixtures/thirdweb.fixture.js +34 -0
- package/lib/test/fixtures/thirdweb.fixture.js.map +1 -0
- package/lib/transaction.d.ts.map +1 -1
- package/lib/transaction.js +2 -0
- package/lib/transaction.js.map +1 -1
- package/lib/types/alpaca.d.ts +5 -1
- package/lib/types/alpaca.d.ts.map +1 -1
- package/lib/types/bridge.d.ts +6 -1
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/logic.d.ts +39 -0
- package/lib/types/logic.d.ts.map +1 -0
- package/lib/types/logic.js +3 -0
- package/lib/types/logic.js.map +1 -0
- package/lib/types/mirror.d.ts +29 -0
- package/lib/types/mirror.d.ts.map +1 -1
- package/lib/types/thirdweb.d.ts +34 -0
- package/lib/types/thirdweb.d.ts.map +1 -0
- package/lib/types/thirdweb.js +3 -0
- package/lib/types/thirdweb.js.map +1 -0
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +7 -3
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/broadcast.js +2 -2
- package/lib-es/bridge/broadcast.js.map +1 -1
- package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -1
- package/lib-es/bridge/buildOptimisticOperation.js +83 -18
- package/lib-es/bridge/buildOptimisticOperation.js.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.js +5 -2
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +73 -16
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/index.js +2 -2
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +42 -9
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +21 -4
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/synchronisation.d.ts +2 -0
- package/lib-es/bridge/synchronisation.d.ts.map +1 -1
- package/lib-es/bridge/synchronisation.js +97 -27
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/bridge/utils.d.ts +35 -2
- package/lib-es/bridge/utils.d.ts.map +1 -1
- package/lib-es/bridge/utils.js +211 -16
- package/lib-es/bridge/utils.js.map +1 -1
- package/lib-es/constants.d.ts +22 -2
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +38 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/deviceTransactionConfig.d.ts +1 -1
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -1
- package/lib-es/deviceTransactionConfig.js +8 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -1
- package/lib-es/errors.d.ts +3 -0
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +1 -0
- package/lib-es/errors.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +4 -4
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +48 -7
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +2 -4
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +47 -7
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +7 -3
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/utils.d.ts +24 -2
- package/lib-es/logic/utils.d.ts.map +1 -1
- package/lib-es/logic/utils.js +63 -13
- package/lib-es/logic/utils.js.map +1 -1
- package/lib-es/network/api.d.ts +12 -1
- package/lib-es/network/api.d.ts.map +1 -1
- package/lib-es/network/api.js +91 -19
- package/lib-es/network/api.js.map +1 -1
- package/lib-es/network/rpc.d.ts.map +1 -1
- package/lib-es/network/rpc.js +1 -0
- package/lib-es/network/rpc.js.map +1 -1
- package/lib-es/network/thirdweb.d.ts +21 -0
- package/lib-es/network/thirdweb.d.ts.map +1 -0
- package/lib-es/network/thirdweb.js +66 -0
- package/lib-es/network/thirdweb.js.map +1 -0
- package/lib-es/network/utils.d.ts +4 -1
- package/lib-es/network/utils.d.ts.map +1 -1
- package/lib-es/network/utils.js +49 -0
- package/lib-es/network/utils.js.map +1 -1
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib-es/test/bridgeDatasetTest.js +4 -4
- package/lib-es/test/bridgeDatasetTest.js.map +1 -1
- package/lib-es/test/fixtures/account.fixture.js +2 -2
- package/lib-es/test/fixtures/account.fixture.js.map +1 -1
- package/lib-es/test/fixtures/common.fixture.d.ts +12 -0
- package/lib-es/test/fixtures/common.fixture.d.ts.map +1 -0
- package/lib-es/test/fixtures/common.fixture.js +57 -0
- package/lib-es/test/fixtures/common.fixture.js.map +1 -0
- package/lib-es/test/fixtures/currency.fixture.d.ts +3 -1
- package/lib-es/test/fixtures/currency.fixture.d.ts.map +1 -1
- package/lib-es/test/fixtures/currency.fixture.js +59 -14
- package/lib-es/test/fixtures/currency.fixture.js.map +1 -1
- package/lib-es/test/fixtures/mirror.fixture.d.ts +3 -1
- package/lib-es/test/fixtures/mirror.fixture.d.ts.map +1 -1
- package/lib-es/test/fixtures/mirror.fixture.js +9 -0
- package/lib-es/test/fixtures/mirror.fixture.js.map +1 -1
- package/lib-es/test/fixtures/thirdweb.fixture.d.ts +3 -0
- package/lib-es/test/fixtures/thirdweb.fixture.d.ts.map +1 -0
- package/lib-es/test/fixtures/thirdweb.fixture.js +30 -0
- package/lib-es/test/fixtures/thirdweb.fixture.js.map +1 -0
- package/lib-es/transaction.d.ts.map +1 -1
- package/lib-es/transaction.js +2 -0
- package/lib-es/transaction.js.map +1 -1
- package/lib-es/types/alpaca.d.ts +5 -1
- package/lib-es/types/alpaca.d.ts.map +1 -1
- package/lib-es/types/bridge.d.ts +6 -1
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/lib-es/types/index.d.ts +2 -0
- package/lib-es/types/index.d.ts.map +1 -1
- package/lib-es/types/index.js +2 -0
- package/lib-es/types/index.js.map +1 -1
- package/lib-es/types/logic.d.ts +39 -0
- package/lib-es/types/logic.d.ts.map +1 -0
- package/lib-es/types/logic.js +2 -0
- package/lib-es/types/logic.js.map +1 -0
- package/lib-es/types/mirror.d.ts +29 -0
- package/lib-es/types/mirror.d.ts.map +1 -1
- package/lib-es/types/thirdweb.d.ts +34 -0
- package/lib-es/types/thirdweb.d.ts.map +1 -0
- package/lib-es/types/thirdweb.js +2 -0
- package/lib-es/types/thirdweb.js.map +1 -0
- package/package.json +9 -8
- package/src/api/index.integ.test.ts +11 -8
- package/src/api/index.ts +10 -3
- package/src/bridge/broadcast.ts +2 -2
- package/src/bridge/buildOptimisticOperation.integration.test.ts +70 -19
- package/src/bridge/buildOptimisticOperation.ts +98 -20
- package/src/bridge/estimateMaxSpendable.ts +5 -5
- package/src/bridge/getTransactionStatus.test.ts +57 -12
- package/src/bridge/getTransactionStatus.ts +88 -15
- package/src/bridge/index.ts +2 -2
- package/src/bridge/js-estimateMaxSpendable.integration.test.ts +12 -9
- package/src/bridge/prepareTransaction.test.ts +3 -1
- package/src/bridge/prepareTransaction.ts +45 -10
- package/src/bridge/signOperation.ts +23 -5
- package/src/bridge/synchronisation.test.ts +67 -0
- package/src/bridge/synchronisation.ts +114 -34
- package/src/bridge/utils.integration.test.ts +486 -180
- package/src/bridge/utils.test.ts +404 -0
- package/src/bridge/utils.ts +330 -27
- package/src/constants.ts +47 -2
- package/src/deviceTransactionConfig.ts +10 -1
- package/src/errors.ts +3 -0
- package/src/logic/craftTransaction.test.ts +49 -9
- package/src/logic/craftTransaction.ts +76 -11
- package/src/logic/estimateFees.test.ts +180 -31
- package/src/logic/estimateFees.ts +68 -7
- package/src/logic/getAssetFromToken.test.ts +2 -2
- package/src/logic/getBalance.test.ts +18 -57
- package/src/logic/getTokenFromAsset.test.ts +2 -2
- package/src/logic/listOperations.ts +9 -5
- package/src/logic/utils.test.ts +157 -69
- package/src/logic/utils.ts +75 -13
- package/src/network/api.test.ts +211 -3
- package/src/network/api.ts +118 -24
- package/src/network/rpc.test.ts +1 -0
- package/src/network/rpc.ts +1 -0
- package/src/network/thirdweb.test.ts +188 -0
- package/src/network/thirdweb.ts +101 -0
- package/src/network/utils.test.ts +364 -164
- package/src/network/utils.ts +83 -1
- package/src/test/bridgeDatasetTest.ts +4 -5
- package/src/test/fixtures/account.fixture.ts +2 -2
- package/src/test/fixtures/common.fixture.ts +74 -0
- package/src/test/fixtures/currency.fixture.ts +66 -14
- package/src/test/fixtures/mirror.fixture.ts +23 -1
- package/src/test/fixtures/thirdweb.fixture.ts +33 -0
- package/src/transaction.ts +2 -0
- package/src/types/alpaca.ts +8 -1
- package/src/types/bridge.ts +6 -1
- package/src/types/index.ts +2 -0
- package/src/types/logic.ts +44 -0
- package/src/types/mirror.ts +35 -0
- package/src/types/thirdweb.ts +36 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mirror.d.ts","sourceRoot":"","sources":["../../src/types/mirror.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG,gBAAgB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE7D,KAAK,SAA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AAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,EAAE,SAAS,CAAC;CACpB;AAED,MAAM,WAAW,gCAAgC;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface HederaThirdwebDecodedTransferParams {
|
|
2
|
+
from: string;
|
|
3
|
+
to: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
export interface HederaThirdwebTransaction {
|
|
7
|
+
address: string;
|
|
8
|
+
blockHash: string;
|
|
9
|
+
blockNumber: number;
|
|
10
|
+
blockTimestamp: number;
|
|
11
|
+
chainId: string;
|
|
12
|
+
data: string;
|
|
13
|
+
decoded: {
|
|
14
|
+
name: string;
|
|
15
|
+
params: Record<string, unknown>;
|
|
16
|
+
signature: string;
|
|
17
|
+
};
|
|
18
|
+
logIndex: number;
|
|
19
|
+
topics: string[];
|
|
20
|
+
transactionHash: string;
|
|
21
|
+
transactionIndex: number;
|
|
22
|
+
}
|
|
23
|
+
export interface HederaThirdwebPagination {
|
|
24
|
+
limit: number;
|
|
25
|
+
page: number;
|
|
26
|
+
totalCount: number;
|
|
27
|
+
}
|
|
28
|
+
export interface HederaThirdwebContractEventsResponse {
|
|
29
|
+
result: {
|
|
30
|
+
events: HederaThirdwebTransaction[];
|
|
31
|
+
pagination: HederaThirdwebPagination;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=thirdweb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thirdweb.d.ts","sourceRoot":"","sources":["../../src/types/thirdweb.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mCAAmC;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oCAAoC;IACnD,MAAM,EAAE;QACN,MAAM,EAAE,yBAAyB,EAAE,CAAC;QACpC,UAAU,EAAE,wBAAwB,CAAC;KACtC,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thirdweb.js","sourceRoot":"","sources":["../../src/types/thirdweb.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-hedera",
|
|
3
|
-
"version": "1.15.0-nightly.
|
|
3
|
+
"version": "1.15.0-nightly.20251126160702",
|
|
4
4
|
"description": "Ledger Hedera Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -75,20 +75,21 @@
|
|
|
75
75
|
},
|
|
76
76
|
"license": "Apache-2.0",
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@hashgraph/sdk": "2.
|
|
78
|
+
"@hashgraph/sdk": "2.74.0",
|
|
79
79
|
"bignumber.js": "^9.1.2",
|
|
80
80
|
"expect": "^27.4.6",
|
|
81
81
|
"invariant": "^2.2.2",
|
|
82
82
|
"lodash": "^4.17.21",
|
|
83
83
|
"rxjs": "^7.8.1",
|
|
84
|
-
"
|
|
85
|
-
"@ledgerhq/
|
|
84
|
+
"viem": "^2.27.0",
|
|
85
|
+
"@ledgerhq/coin-framework": "^6.10.0-nightly.20251126160702",
|
|
86
|
+
"@ledgerhq/cryptoassets": "^13.34.0-nightly.20251126160702",
|
|
86
87
|
"@ledgerhq/devices": "8.7.0",
|
|
87
88
|
"@ledgerhq/errors": "^6.27.0",
|
|
88
|
-
"@ledgerhq/live-countervalues": "^0.10.1-nightly.
|
|
89
|
-
"@ledgerhq/live-env": "^2.
|
|
90
|
-
"@ledgerhq/live-network": "^2.1.2-nightly.
|
|
91
|
-
"@ledgerhq/types-live": "^6.90.0-nightly.
|
|
89
|
+
"@ledgerhq/live-countervalues": "^0.10.1-nightly.20251126160702",
|
|
90
|
+
"@ledgerhq/live-env": "^2.22.0-nightly.20251126160702",
|
|
91
|
+
"@ledgerhq/live-network": "^2.1.2-nightly.20251126160702",
|
|
92
|
+
"@ledgerhq/types-live": "^6.90.0-nightly.20251126160702"
|
|
92
93
|
},
|
|
93
94
|
"devDependencies": {
|
|
94
95
|
"@types/invariant": "^2.2.2",
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
AccountId,
|
|
5
5
|
Hbar,
|
|
6
6
|
HbarUnit,
|
|
7
|
+
Long,
|
|
7
8
|
TokenAssociateTransaction,
|
|
8
9
|
TransferTransaction,
|
|
9
10
|
} from "@hashgraph/sdk";
|
|
@@ -14,11 +15,12 @@ import { getSyntheticBlock } from "../logic/utils";
|
|
|
14
15
|
import { MAINNET_TEST_ACCOUNTS } from "../test/fixtures/account.fixture";
|
|
15
16
|
|
|
16
17
|
describe("createApi", () => {
|
|
18
|
+
const api = createApi({});
|
|
19
|
+
|
|
17
20
|
beforeAll(() => {
|
|
18
21
|
// Setup CAL client store (automatically set as global store)
|
|
19
22
|
setupCalClientStore();
|
|
20
23
|
});
|
|
21
|
-
const api = createApi({});
|
|
22
24
|
|
|
23
25
|
describe("craftTransaction", () => {
|
|
24
26
|
it("returns serialized native coin TransferTransaction", async () => {
|
|
@@ -81,10 +83,8 @@ describe("createApi", () => {
|
|
|
81
83
|
const senderTransfer = tokenTransfers?.get(MAINNET_TEST_ACCOUNTS.withoutTokens.accountId);
|
|
82
84
|
const recipientTransfer = tokenTransfers?.get(MAINNET_TEST_ACCOUNTS.withTokens.accountId);
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
expect(senderTransfer?.toString()).toEqual("-1");
|
|
87
|
-
expect(recipientTransfer?.toString()).toEqual("1");
|
|
86
|
+
expect(senderTransfer).toEqual(Long.fromNumber(-1));
|
|
87
|
+
expect(recipientTransfer).toEqual(Long.fromNumber(1));
|
|
88
88
|
expect(tokenTransfers).not.toBeNull();
|
|
89
89
|
expect(rawTx.transactionMemo).toBe("token transfer");
|
|
90
90
|
});
|
|
@@ -116,7 +116,7 @@ describe("createApi", () => {
|
|
|
116
116
|
AccountId.fromString(MAINNET_TEST_ACCOUNTS.withoutTokens.accountId),
|
|
117
117
|
);
|
|
118
118
|
// .toString() is used because sdk.TokenId.fromString() sets `_checksum` to undefined,
|
|
119
|
-
//
|
|
119
|
+
// where tokenIds elements from TokenAssociateTransaction.fromBytes have it set to null
|
|
120
120
|
expect(rawTx.tokenIds?.[0]?.toString()).toEqual("0.0.5022567");
|
|
121
121
|
expect(rawTx.transactionMemo).toBe("token association");
|
|
122
122
|
});
|
|
@@ -147,11 +147,11 @@ describe("createApi", () => {
|
|
|
147
147
|
);
|
|
148
148
|
|
|
149
149
|
const rawTx = TransferTransaction.fromBytes(Buffer.from(hex, "hex"));
|
|
150
|
+
const expectedMaxFee = Hbar.from(customFees.value.toString(), HbarUnit.Tinybar);
|
|
150
151
|
|
|
151
152
|
expect(rawTx).toBeInstanceOf(TransferTransaction);
|
|
152
153
|
invariant(rawTx instanceof TransferTransaction, "TransferTransaction type guard");
|
|
153
|
-
|
|
154
|
-
expect(rawTx.maxTransactionFee).toEqual(Hbar.from(customFees.value, HbarUnit.Tinybar));
|
|
154
|
+
expect(rawTx.maxTransactionFee).toEqual(expectedMaxFee);
|
|
155
155
|
});
|
|
156
156
|
});
|
|
157
157
|
|
|
@@ -365,6 +365,9 @@ describe("createApi", () => {
|
|
|
365
365
|
minHeight: 0,
|
|
366
366
|
limit: 10,
|
|
367
367
|
order,
|
|
368
|
+
...(order === "desc" && {
|
|
369
|
+
lastPagingToken: "1762168437.643463899",
|
|
370
|
+
}),
|
|
368
371
|
} satisfies Pagination;
|
|
369
372
|
|
|
370
373
|
const [page1, pagingToken1] = await api.listOperations(
|
package/src/api/index.ts
CHANGED
|
@@ -13,11 +13,12 @@ import type {
|
|
|
13
13
|
} from "@ledgerhq/coin-framework/api/index";
|
|
14
14
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
15
15
|
import coinConfig from "../config";
|
|
16
|
+
import { HEDERA_OPERATION_TYPES } from "../constants";
|
|
16
17
|
import {
|
|
17
18
|
broadcast as logicBroadcast,
|
|
18
19
|
combine,
|
|
19
20
|
craftTransaction,
|
|
20
|
-
estimateFees,
|
|
21
|
+
estimateFees as logicEstimateFees,
|
|
21
22
|
getBalance,
|
|
22
23
|
listOperations as logicListOperations,
|
|
23
24
|
getAssetFromToken,
|
|
@@ -35,6 +36,7 @@ export function createApi(config: Record<string, never>): Api<HederaMemo> {
|
|
|
35
36
|
return {
|
|
36
37
|
broadcast: async tx => {
|
|
37
38
|
const response = await logicBroadcast(tx);
|
|
39
|
+
|
|
38
40
|
return Buffer.from(response.transactionHash).toString("base64");
|
|
39
41
|
},
|
|
40
42
|
combine,
|
|
@@ -55,10 +57,15 @@ export function createApi(config: Record<string, never>): Api<HederaMemo> {
|
|
|
55
57
|
},
|
|
56
58
|
estimateFees: async transactionIntent => {
|
|
57
59
|
const operationType = mapIntentToSDKOperation(transactionIntent);
|
|
58
|
-
|
|
60
|
+
|
|
61
|
+
if (operationType === HEDERA_OPERATION_TYPES.ContractCall) {
|
|
62
|
+
throw new Error("hedera: estimateFees for ContractCall is not supported yet");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const estimatedFee = await logicEstimateFees({ currency, operationType });
|
|
59
66
|
|
|
60
67
|
return {
|
|
61
|
-
value: BigInt(estimatedFee.toString()),
|
|
68
|
+
value: BigInt(estimatedFee.tinybars.toString()),
|
|
62
69
|
};
|
|
63
70
|
},
|
|
64
71
|
getBalance: address => getBalance(currency, address),
|
package/src/bridge/broadcast.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountBridge, Operation } from "@ledgerhq/types-live";
|
|
2
2
|
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
3
3
|
import { broadcast as logicBroadcast } from "../logic/broadcast";
|
|
4
|
-
import { base64ToUrlSafeBase64, isValidExtra } from "../logic/utils";
|
|
4
|
+
import { base64ToUrlSafeBase64, isValidExtra, formatTransactionId } from "../logic/utils";
|
|
5
5
|
import type { HederaOperationExtra, Transaction } from "../types";
|
|
6
6
|
import { patchOperationWithExtra } from "./utils";
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ export const broadcast: AccountBridge<Transaction>["broadcast"] = async ({ signe
|
|
|
13
13
|
const base64HashUrlSafe = base64ToUrlSafeBase64(base64Hash);
|
|
14
14
|
const extra: HederaOperationExtra = {
|
|
15
15
|
...(isValidExtra(operation.extra) ? operation.extra : {}),
|
|
16
|
-
transactionId: response.transactionId
|
|
16
|
+
transactionId: formatTransactionId(response.transactionId),
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
let patchedOperation: Operation = operation;
|
|
@@ -3,25 +3,16 @@ import { buildOptimisticOperation } from "./buildOptimisticOperation";
|
|
|
3
3
|
import { HEDERA_OPERATION_TYPES, HEDERA_TRANSACTION_MODES } from "../constants";
|
|
4
4
|
import { estimateFees } from "../logic/estimateFees";
|
|
5
5
|
import { getMockedAccount, getMockedTokenAccount } from "../test/fixtures/account.fixture";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getMockedERC20TokenCurrency,
|
|
8
|
+
getMockedHTSTokenCurrency,
|
|
9
|
+
} from "../test/fixtures/currency.fixture";
|
|
7
10
|
import { getMockedTransaction } from "../test/fixtures/transaction.fixture";
|
|
8
11
|
|
|
9
12
|
describe("buildOptimisticOperation", () => {
|
|
10
|
-
let estimatedFees: Record<"crypto" | "associate", BigNumber>;
|
|
11
|
-
|
|
12
|
-
beforeAll(async () => {
|
|
13
|
-
const mockedAccount = getMockedAccount();
|
|
14
|
-
const [crypto, associate] = await Promise.all([
|
|
15
|
-
estimateFees(mockedAccount.currency, HEDERA_OPERATION_TYPES.CryptoTransfer),
|
|
16
|
-
estimateFees(mockedAccount.currency, HEDERA_OPERATION_TYPES.TokenAssociate),
|
|
17
|
-
]);
|
|
18
|
-
|
|
19
|
-
estimatedFees = { crypto, associate };
|
|
20
|
-
});
|
|
21
|
-
|
|
22
13
|
test("builds optimistic operation for token association", async () => {
|
|
23
14
|
const mockedAccount = getMockedAccount();
|
|
24
|
-
const mockedToken =
|
|
15
|
+
const mockedToken = getMockedHTSTokenCurrency();
|
|
25
16
|
const mockedTransaction = getMockedTransaction({
|
|
26
17
|
mode: HEDERA_TRANSACTION_MODES.TokenAssociate,
|
|
27
18
|
amount: new BigNumber(0),
|
|
@@ -31,6 +22,11 @@ describe("buildOptimisticOperation", () => {
|
|
|
31
22
|
},
|
|
32
23
|
});
|
|
33
24
|
|
|
25
|
+
const estimatedFee = await estimateFees({
|
|
26
|
+
currency: mockedAccount.currency,
|
|
27
|
+
operationType: HEDERA_OPERATION_TYPES.TokenAssociate,
|
|
28
|
+
});
|
|
29
|
+
|
|
34
30
|
const op = await buildOptimisticOperation({
|
|
35
31
|
account: mockedAccount,
|
|
36
32
|
transaction: mockedTransaction,
|
|
@@ -38,7 +34,7 @@ describe("buildOptimisticOperation", () => {
|
|
|
38
34
|
|
|
39
35
|
expect(op.type).toBe("ASSOCIATE_TOKEN");
|
|
40
36
|
expect(op.extra).toEqual({ associatedTokenId: mockedToken.contractAddress });
|
|
41
|
-
expect(op.fee).toEqual(
|
|
37
|
+
expect(op.fee).toEqual(estimatedFee.tinybars);
|
|
42
38
|
expect(op.senders).toContain(mockedAccount.freshAddress);
|
|
43
39
|
expect(op.recipients).toContain("0.0.1234");
|
|
44
40
|
});
|
|
@@ -50,20 +46,57 @@ describe("buildOptimisticOperation", () => {
|
|
|
50
46
|
recipient: "0.0.5678",
|
|
51
47
|
});
|
|
52
48
|
|
|
49
|
+
const estimatedFee = await estimateFees({
|
|
50
|
+
currency: mockedAccount.currency,
|
|
51
|
+
operationType: HEDERA_OPERATION_TYPES.CryptoTransfer,
|
|
52
|
+
});
|
|
53
|
+
|
|
53
54
|
const op = await buildOptimisticOperation({
|
|
54
55
|
account: mockedAccount,
|
|
55
56
|
transaction: mockedTransaction,
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
expect(op.type).toBe("OUT");
|
|
59
|
-
expect(op.fee).toEqual(
|
|
60
|
+
expect(op.fee).toEqual(estimatedFee.tinybars);
|
|
60
61
|
expect(op.value).toEqual(new BigNumber(123));
|
|
61
62
|
expect(op.senders).toContain(mockedAccount.freshAddress);
|
|
62
63
|
expect(op.recipients).toContain("0.0.5678");
|
|
63
64
|
});
|
|
64
65
|
|
|
65
|
-
test("builds optimistic operation for token", async () => {
|
|
66
|
-
const
|
|
66
|
+
test("builds optimistic operation for HTS token", async () => {
|
|
67
|
+
const mockedAccount = getMockedAccount();
|
|
68
|
+
const mockedTokenCurrency = getMockedHTSTokenCurrency();
|
|
69
|
+
const tokenAccount = getMockedTokenAccount(mockedTokenCurrency);
|
|
70
|
+
const parentAccount = getMockedAccount({ subAccounts: [tokenAccount] });
|
|
71
|
+
const mockedTransaction = getMockedTransaction({
|
|
72
|
+
subAccountId: tokenAccount.id,
|
|
73
|
+
amount: new BigNumber(123),
|
|
74
|
+
recipient: "0.0.9999",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const estimatedFee = await estimateFees({
|
|
78
|
+
currency: mockedAccount.currency,
|
|
79
|
+
operationType: HEDERA_OPERATION_TYPES.TokenTransfer,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const op = await buildOptimisticOperation({
|
|
83
|
+
account: parentAccount,
|
|
84
|
+
transaction: mockedTransaction,
|
|
85
|
+
});
|
|
86
|
+
const subOp = (op.subOperations ?? [])[0];
|
|
87
|
+
|
|
88
|
+
expect(op.type).toBe("FEES");
|
|
89
|
+
expect(op.value).toEqual(estimatedFee.tinybars);
|
|
90
|
+
expect(op.subOperations).toHaveLength(1);
|
|
91
|
+
expect(subOp.type).toBe("OUT");
|
|
92
|
+
expect(subOp.value).toEqual(new BigNumber(123));
|
|
93
|
+
expect(subOp.fee).toEqual(estimatedFee.tinybars);
|
|
94
|
+
expect(subOp.accountId).toBe(tokenAccount.id);
|
|
95
|
+
expect(subOp.recipients).toContain("0.0.9999");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("builds optimistic operation for ERC20 token", async () => {
|
|
99
|
+
const mockedTokenCurrency = getMockedERC20TokenCurrency();
|
|
67
100
|
const tokenAccount = getMockedTokenAccount(mockedTokenCurrency);
|
|
68
101
|
const parentAccount = getMockedAccount({ subAccounts: [tokenAccount] });
|
|
69
102
|
const mockedTransaction = getMockedTransaction({
|
|
@@ -72,16 +105,34 @@ describe("buildOptimisticOperation", () => {
|
|
|
72
105
|
recipient: "0.0.9999",
|
|
73
106
|
});
|
|
74
107
|
|
|
108
|
+
const estimatedFee = await estimateFees({
|
|
109
|
+
operationType: HEDERA_OPERATION_TYPES.ContractCall,
|
|
110
|
+
txIntent: {
|
|
111
|
+
intentType: "transaction",
|
|
112
|
+
type: HEDERA_TRANSACTION_MODES.Send,
|
|
113
|
+
asset: {
|
|
114
|
+
type: "erc20",
|
|
115
|
+
assetReference: tokenAccount.token.contractAddress,
|
|
116
|
+
assetOwner: parentAccount.freshAddress,
|
|
117
|
+
},
|
|
118
|
+
amount: BigInt(mockedTransaction.amount.toString()),
|
|
119
|
+
sender: parentAccount.freshAddress,
|
|
120
|
+
recipient: mockedTransaction.recipient,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
75
124
|
const op = await buildOptimisticOperation({
|
|
76
125
|
account: parentAccount,
|
|
77
126
|
transaction: mockedTransaction,
|
|
78
127
|
});
|
|
79
|
-
const subOp = op.subOperations
|
|
128
|
+
const subOp = (op.subOperations ?? [])[0];
|
|
80
129
|
|
|
81
130
|
expect(op.type).toBe("FEES");
|
|
131
|
+
expect(op.value).toEqual(estimatedFee.tinybars);
|
|
82
132
|
expect(op.subOperations).toHaveLength(1);
|
|
83
133
|
expect(subOp.type).toBe("OUT");
|
|
84
134
|
expect(subOp.value).toEqual(new BigNumber(123));
|
|
135
|
+
expect(subOp.fee).toEqual(estimatedFee.tinybars);
|
|
85
136
|
expect(subOp.accountId).toBe(tokenAccount.id);
|
|
86
137
|
expect(subOp.recipients).toContain("0.0.9999");
|
|
87
138
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
1
2
|
import invariant from "invariant";
|
|
2
3
|
import type { Account, Operation, OperationType, TokenAccount } from "@ledgerhq/types-live";
|
|
3
4
|
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
4
|
-
import { findSubAccountById
|
|
5
|
-
import { HEDERA_OPERATION_TYPES } from "../constants";
|
|
5
|
+
import { findSubAccountById } from "@ledgerhq/coin-framework/account/helpers";
|
|
6
|
+
import { HEDERA_OPERATION_TYPES, HEDERA_TRANSACTION_MODES } from "../constants";
|
|
6
7
|
import { estimateFees } from "../logic/estimateFees";
|
|
7
|
-
import {
|
|
8
|
+
import { safeParseAccountId, isTokenAssociateTransaction } from "../logic/utils";
|
|
8
9
|
import type { HederaOperationExtra, Transaction } from "../types";
|
|
9
10
|
|
|
10
11
|
const buildOptimisticTokenAssociateOperation = async ({
|
|
@@ -16,15 +17,18 @@ const buildOptimisticTokenAssociateOperation = async ({
|
|
|
16
17
|
}): Promise<Operation> => {
|
|
17
18
|
invariant(isTokenAssociateTransaction(transaction), "invalid transaction properties");
|
|
18
19
|
|
|
19
|
-
const estimatedFee = await estimateFees(
|
|
20
|
+
const estimatedFee = await estimateFees({
|
|
21
|
+
currency: account.currency,
|
|
22
|
+
operationType: HEDERA_OPERATION_TYPES.TokenAssociate,
|
|
23
|
+
});
|
|
20
24
|
const type: OperationType = "ASSOCIATE_TOKEN";
|
|
21
25
|
|
|
22
26
|
const operation: Operation = {
|
|
23
27
|
id: encodeOperationId(account.id, "", type),
|
|
24
28
|
hash: "",
|
|
25
29
|
type,
|
|
26
|
-
value: estimatedFee,
|
|
27
|
-
fee: estimatedFee,
|
|
30
|
+
value: estimatedFee.tinybars,
|
|
31
|
+
fee: estimatedFee.tinybars,
|
|
28
32
|
blockHash: null,
|
|
29
33
|
blockHeight: null,
|
|
30
34
|
senders: [account.freshAddress.toString()],
|
|
@@ -51,18 +55,22 @@ const buildOptimisticCoinOperation = async ({
|
|
|
51
55
|
const estimatedFee =
|
|
52
56
|
transactionType === "FEES"
|
|
53
57
|
? transaction.amount
|
|
54
|
-
: await estimateFees(
|
|
58
|
+
: await estimateFees({
|
|
59
|
+
currency: account.currency,
|
|
60
|
+
operationType: HEDERA_OPERATION_TYPES.CryptoTransfer,
|
|
61
|
+
});
|
|
55
62
|
const value = transaction.amount;
|
|
56
63
|
const type: OperationType = transactionType ?? "OUT";
|
|
57
64
|
const [_, recipientAddress] = safeParseAccountId(transaction.recipient);
|
|
58
65
|
const recipientWithoutChecksum = recipientAddress?.accountId ?? transaction.recipient;
|
|
66
|
+
const memo = transaction.memo;
|
|
59
67
|
|
|
60
68
|
const operation: Operation = {
|
|
61
69
|
id: encodeOperationId(account.id, "", type),
|
|
62
70
|
hash: "",
|
|
63
71
|
type,
|
|
64
72
|
value,
|
|
65
|
-
fee: estimatedFee,
|
|
73
|
+
fee: BigNumber.isBigNumber(estimatedFee) ? estimatedFee : estimatedFee.tinybars,
|
|
66
74
|
blockHash: null,
|
|
67
75
|
blockHeight: null,
|
|
68
76
|
senders: [account.freshAddress.toString()],
|
|
@@ -70,14 +78,14 @@ const buildOptimisticCoinOperation = async ({
|
|
|
70
78
|
accountId: account.id,
|
|
71
79
|
date: new Date(),
|
|
72
80
|
extra: {
|
|
73
|
-
...(
|
|
74
|
-
},
|
|
81
|
+
...(memo && { memo }),
|
|
82
|
+
} satisfies HederaOperationExtra,
|
|
75
83
|
};
|
|
76
84
|
|
|
77
85
|
return operation;
|
|
78
86
|
};
|
|
79
87
|
|
|
80
|
-
const
|
|
88
|
+
const buildOptimisticHTSTokenOperation = async ({
|
|
81
89
|
account,
|
|
82
90
|
tokenAccount,
|
|
83
91
|
transaction,
|
|
@@ -86,18 +94,21 @@ const buildOptimisticTokenOperation = async ({
|
|
|
86
94
|
tokenAccount: TokenAccount;
|
|
87
95
|
transaction: Transaction;
|
|
88
96
|
}): Promise<Operation> => {
|
|
89
|
-
const estimatedFee = await estimateFees(
|
|
97
|
+
const estimatedFee = await estimateFees({
|
|
98
|
+
currency: account.currency,
|
|
99
|
+
operationType: HEDERA_OPERATION_TYPES.TokenTransfer,
|
|
100
|
+
});
|
|
90
101
|
const value = transaction.amount;
|
|
91
102
|
const type: OperationType = "OUT";
|
|
92
103
|
const [_, recipientAddress] = safeParseAccountId(transaction.recipient);
|
|
93
104
|
const recipientWithoutChecksum = recipientAddress?.accountId ?? transaction.recipient;
|
|
105
|
+
const memo = transaction.memo;
|
|
94
106
|
|
|
95
107
|
const coinOperation = await buildOptimisticCoinOperation({
|
|
96
108
|
account,
|
|
97
109
|
transaction: {
|
|
98
110
|
...transaction,
|
|
99
|
-
|
|
100
|
-
amount: estimatedFee,
|
|
111
|
+
amount: estimatedFee.tinybars,
|
|
101
112
|
},
|
|
102
113
|
transactionType: "FEES",
|
|
103
114
|
});
|
|
@@ -110,7 +121,7 @@ const buildOptimisticTokenOperation = async ({
|
|
|
110
121
|
hash: "",
|
|
111
122
|
type,
|
|
112
123
|
value,
|
|
113
|
-
fee: estimatedFee,
|
|
124
|
+
fee: estimatedFee.tinybars,
|
|
114
125
|
blockHash: null,
|
|
115
126
|
blockHeight: null,
|
|
116
127
|
senders: [account.freshAddress.toString()],
|
|
@@ -118,8 +129,70 @@ const buildOptimisticTokenOperation = async ({
|
|
|
118
129
|
accountId: tokenAccount.id,
|
|
119
130
|
date: new Date(),
|
|
120
131
|
extra: {
|
|
121
|
-
...(
|
|
122
|
-
},
|
|
132
|
+
...(memo && { memo }),
|
|
133
|
+
} satisfies HederaOperationExtra,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return operation;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const buildOptimisticERC20TokenOperation = async ({
|
|
142
|
+
account,
|
|
143
|
+
tokenAccount,
|
|
144
|
+
transaction,
|
|
145
|
+
}: {
|
|
146
|
+
account: Account;
|
|
147
|
+
tokenAccount: TokenAccount;
|
|
148
|
+
transaction: Transaction;
|
|
149
|
+
}): Promise<Operation> => {
|
|
150
|
+
const estimatedFees = await estimateFees({
|
|
151
|
+
operationType: HEDERA_OPERATION_TYPES.ContractCall,
|
|
152
|
+
txIntent: {
|
|
153
|
+
intentType: "transaction",
|
|
154
|
+
type: HEDERA_TRANSACTION_MODES.Send,
|
|
155
|
+
asset: {
|
|
156
|
+
type: "erc20",
|
|
157
|
+
assetReference: tokenAccount.token.contractAddress,
|
|
158
|
+
assetOwner: account.freshAddress,
|
|
159
|
+
},
|
|
160
|
+
amount: BigInt(transaction.amount.toString()),
|
|
161
|
+
sender: account.freshAddress,
|
|
162
|
+
recipient: transaction.recipient,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
const value = transaction.amount;
|
|
166
|
+
const type: OperationType = "OUT";
|
|
167
|
+
const memo = transaction.memo;
|
|
168
|
+
|
|
169
|
+
const coinOperation = await buildOptimisticCoinOperation({
|
|
170
|
+
account,
|
|
171
|
+
transaction: {
|
|
172
|
+
...transaction,
|
|
173
|
+
amount: estimatedFees.tinybars,
|
|
174
|
+
},
|
|
175
|
+
transactionType: "FEES",
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const operation: Operation = {
|
|
179
|
+
...coinOperation,
|
|
180
|
+
subOperations: [
|
|
181
|
+
{
|
|
182
|
+
id: encodeOperationId(tokenAccount.id, "", type),
|
|
183
|
+
hash: "",
|
|
184
|
+
type,
|
|
185
|
+
value,
|
|
186
|
+
fee: estimatedFees.tinybars,
|
|
187
|
+
blockHash: null,
|
|
188
|
+
blockHeight: null,
|
|
189
|
+
senders: [account.freshAddress.toString()],
|
|
190
|
+
recipients: [transaction.recipient],
|
|
191
|
+
accountId: tokenAccount.id,
|
|
192
|
+
date: new Date(),
|
|
193
|
+
extra: {
|
|
194
|
+
...(memo && { memo }),
|
|
195
|
+
} satisfies HederaOperationExtra,
|
|
123
196
|
},
|
|
124
197
|
],
|
|
125
198
|
};
|
|
@@ -135,12 +208,17 @@ export const buildOptimisticOperation = async ({
|
|
|
135
208
|
transaction: Transaction;
|
|
136
209
|
}): Promise<Operation> => {
|
|
137
210
|
const subAccount = findSubAccountById(account, transaction.subAccountId || "");
|
|
138
|
-
const
|
|
211
|
+
const isHTSTokenTransaction =
|
|
212
|
+
transaction.mode === HEDERA_TRANSACTION_MODES.Send && subAccount?.token.tokenType === "hts";
|
|
213
|
+
const isERC20TokenTransaction =
|
|
214
|
+
transaction.mode === HEDERA_TRANSACTION_MODES.Send && subAccount?.token.tokenType === "erc20";
|
|
139
215
|
|
|
140
216
|
if (isTokenAssociateTransaction(transaction)) {
|
|
141
217
|
return buildOptimisticTokenAssociateOperation({ account, transaction });
|
|
142
|
-
} else if (
|
|
143
|
-
return
|
|
218
|
+
} else if (isHTSTokenTransaction) {
|
|
219
|
+
return buildOptimisticHTSTokenOperation({ account, tokenAccount: subAccount, transaction });
|
|
220
|
+
} else if (isERC20TokenTransaction) {
|
|
221
|
+
return buildOptimisticERC20TokenOperation({ account, tokenAccount: subAccount, transaction });
|
|
144
222
|
} else {
|
|
145
223
|
return buildOptimisticCoinOperation({ account, transaction });
|
|
146
224
|
}
|
|
@@ -18,11 +18,11 @@ export const estimateMaxSpendable: AccountBridge<Transaction>["estimateMaxSpenda
|
|
|
18
18
|
return Promise.resolve(balance);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const estimatedFees = await estimateFees(
|
|
22
|
-
mainAccount.currency,
|
|
23
|
-
HEDERA_OPERATION_TYPES.CryptoTransfer,
|
|
24
|
-
);
|
|
25
|
-
let maxSpendable = balance.minus(estimatedFees);
|
|
21
|
+
const estimatedFees = await estimateFees({
|
|
22
|
+
currency: mainAccount.currency,
|
|
23
|
+
operationType: HEDERA_OPERATION_TYPES.CryptoTransfer,
|
|
24
|
+
});
|
|
25
|
+
let maxSpendable = balance.minus(estimatedFees.tinybars);
|
|
26
26
|
|
|
27
27
|
// set max spendable to 0 if negative
|
|
28
28
|
// for cases where the user's account balance is smaller than the estimated fee
|