@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":"signOperation.d.ts","sourceRoot":"","sources":["../../src/bridge/signOperation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAYhE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"signOperation.d.ts","sourceRoot":"","sources":["../../src/bridge/signOperation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAYhE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AAExE,eAAO,MAAM,kBAAkB,kBAEZ,cAAc,YAAY,CAAC,KACzC,cAAc,WAAW,EAAE,OAAO,CAAC,CAAC,eAAe,CA4GlD,CAAC"}
|
|
@@ -16,10 +16,14 @@ const buildSignOperation = (signerContext) => ({ account, transaction, deviceId
|
|
|
16
16
|
});
|
|
17
17
|
let type;
|
|
18
18
|
let asset;
|
|
19
|
+
let data;
|
|
19
20
|
const accountAddress = account.freshAddress;
|
|
20
21
|
const accountPublicKey = account.seedIdentifier;
|
|
21
22
|
const subAccount = (0, helpers_1.findSubAccountById)(account, transaction.subAccountId || "");
|
|
22
|
-
const
|
|
23
|
+
const isHTSTokenTransaction = transaction.mode === constants_1.HEDERA_TRANSACTION_MODES.Send &&
|
|
24
|
+
subAccount?.token.tokenType === "hts";
|
|
25
|
+
const isERC20TokenTransaction = transaction.mode === constants_1.HEDERA_TRANSACTION_MODES.Send &&
|
|
26
|
+
subAccount?.token.tokenType === "erc20";
|
|
23
27
|
if ((0, utils_1.isTokenAssociateTransaction)(transaction)) {
|
|
24
28
|
type = constants_1.HEDERA_TRANSACTION_MODES.TokenAssociate;
|
|
25
29
|
asset = {
|
|
@@ -27,7 +31,7 @@ const buildSignOperation = (signerContext) => ({ account, transaction, deviceId
|
|
|
27
31
|
assetReference: transaction.properties.token.contractAddress,
|
|
28
32
|
};
|
|
29
33
|
}
|
|
30
|
-
else if (
|
|
34
|
+
else if (isHTSTokenTransaction) {
|
|
31
35
|
type = constants_1.HEDERA_TRANSACTION_MODES.Send;
|
|
32
36
|
asset = {
|
|
33
37
|
type: subAccount.token.tokenType,
|
|
@@ -35,6 +39,18 @@ const buildSignOperation = (signerContext) => ({ account, transaction, deviceId
|
|
|
35
39
|
assetOwner: accountAddress,
|
|
36
40
|
};
|
|
37
41
|
}
|
|
42
|
+
else if (isERC20TokenTransaction) {
|
|
43
|
+
type = constants_1.HEDERA_TRANSACTION_MODES.Send;
|
|
44
|
+
asset = {
|
|
45
|
+
type: subAccount.token.tokenType,
|
|
46
|
+
assetReference: subAccount.token.contractAddress,
|
|
47
|
+
assetOwner: accountAddress,
|
|
48
|
+
};
|
|
49
|
+
data = {
|
|
50
|
+
type: "erc20",
|
|
51
|
+
gasLimit: BigInt((transaction.gasLimit ?? constants_1.DEFAULT_GAS_LIMIT).toString()),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
38
54
|
else {
|
|
39
55
|
type = constants_1.HEDERA_TRANSACTION_MODES.Send;
|
|
40
56
|
asset = {
|
|
@@ -57,6 +73,7 @@ const buildSignOperation = (signerContext) => ({ account, transaction, deviceId
|
|
|
57
73
|
type: "string",
|
|
58
74
|
value: transaction.memo ?? "",
|
|
59
75
|
},
|
|
76
|
+
...(data && { data }),
|
|
60
77
|
}, customFees);
|
|
61
78
|
const txBodyBytes = (0, utils_1.getHederaTransactionBodyBytes)(tx);
|
|
62
79
|
const signatureBytes = await signer.signTransaction(txBodyBytes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signOperation.js","sourceRoot":"","sources":["../../src/bridge/signOperation.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;AAIlC,
|
|
1
|
+
{"version":3,"file":"signOperation.js","sourceRoot":"","sources":["../../src/bridge/signOperation.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;AAIlC,sEAA8E;AAC9E,yEAAsE;AACtE,4CAA2E;AAC3E,8CAA2C;AAC3C,gEAA6D;AAC7D,0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,EAAE,WAAW,CAAC,IAAI,IAAI,EAAE;qBAC9B;oBACD,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC;iBACtB,EACD,UAAU,CACX,CAAC;gBAEF,MAAM,WAAW,GAAG,IAAA,qCAA6B,EAAC,EAAE,CAAC,CAAC;gBACtD,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;gBAEjE,OAAO,IAAA,iBAAO,EACZ,IAAA,4BAAoB,EAAC,EAAE,CAAC,EACxB,IAAA,0BAAkB,EAAC,cAAc,CAAC,EAClC,gBAAgB,CACjB,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,CAAC,CAAC,IAAI,CAAC;gBACL,IAAI,EAAE,0BAA0B;aACjC,CAAC,CAAC;YAEH,MAAM,SAAS,GAAG,MAAM,IAAA,mDAAwB,EAAC;gBAC/C,OAAO;gBACP,WAAW;aACZ,CAAC,CAAC;YAEH,CAAC,CAAC,IAAI,CAAC;gBACL,IAAI,EAAE,QAAQ;gBACd,eAAe,EAAE;oBACf,SAAS;oBACT,SAAS,EAAE,QAAQ;iBACpB;aACF,CAAC,CAAC;YAEH,CAAC,CAAC,QAAQ,EAAE,CAAC;QACf,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC,CAAC,CAAC;AA/GM,QAAA,kBAAkB,sBA+GxB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { GetAccountShape, IterateResultBuilder } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
2
|
+
import type { Account } from "@ledgerhq/types-live";
|
|
2
3
|
import type { HederaAccount } from "../types";
|
|
3
4
|
export declare const getAccountShape: GetAccountShape<HederaAccount>;
|
|
4
5
|
export declare const buildIterateResult: IterateResultBuilder;
|
|
6
|
+
export declare const postSync: (_initial: Account, synced: Account) => Account;
|
|
5
7
|
//# sourceMappingURL=synchronisation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronisation.d.ts","sourceRoot":"","sources":["../../src/bridge/synchronisation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"synchronisation.d.ts","sourceRoot":"","sources":["../../src/bridge/synchronisation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,2CAA2C,CAAC;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,sBAAsB,CAAC;AAM/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAS9C,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,aAAa,CA0I1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,oBAqBhC,CAAC;AAGF,eAAO,MAAM,QAAQ,aAAc,OAAO,UAAU,OAAO,KAAG,OAgB7D,CAAC"}
|
|
@@ -3,18 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.buildIterateResult = exports.getAccountShape = void 0;
|
|
6
|
+
exports.postSync = exports.buildIterateResult = exports.getAccountShape = void 0;
|
|
7
7
|
const bignumber_js_1 = require("bignumber.js");
|
|
8
8
|
const invariant_1 = __importDefault(require("invariant"));
|
|
9
9
|
const derivation_1 = require("@ledgerhq/coin-framework/derivation");
|
|
10
10
|
const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
|
|
11
11
|
const account_1 = require("@ledgerhq/coin-framework/account");
|
|
12
|
-
const
|
|
12
|
+
const utils_1 = require("../logic/utils");
|
|
13
|
+
const logic_1 = require("../logic");
|
|
13
14
|
const api_1 = require("../network/api");
|
|
14
|
-
const
|
|
15
|
+
const thirdweb_1 = require("../network/thirdweb");
|
|
16
|
+
const utils_2 = require("../network/utils");
|
|
17
|
+
const utils_3 = require("./utils");
|
|
15
18
|
const getAccountShape = async (info, { blacklistedTokenIds }) => {
|
|
16
19
|
const { currency, derivationMode, address, initialAccount } = info;
|
|
17
|
-
(0, invariant_1.default)(address, "
|
|
20
|
+
(0, invariant_1.default)(address, "hedera: address is expected");
|
|
21
|
+
const evmAddress = (0, utils_1.toEVMAddress)(address);
|
|
22
|
+
(0, invariant_1.default)(evmAddress, "hedera: evm address is missing");
|
|
18
23
|
const liveAccountId = (0, account_1.encodeAccountId)({
|
|
19
24
|
type: "js",
|
|
20
25
|
version: "2",
|
|
@@ -25,41 +30,90 @@ const getAccountShape = async (info, { blacklistedTokenIds }) => {
|
|
|
25
30
|
// get current account balance and tokens
|
|
26
31
|
// tokens are fetched with separate requests to get "created_timestamp" for each token
|
|
27
32
|
// based on this, ASSOCIATE_TOKEN operations can be connected with tokens
|
|
28
|
-
const [mirrorAccount, mirrorTokens] = await Promise.all([
|
|
33
|
+
const [mirrorAccount, mirrorTokens, erc20TokenBalances] = await Promise.all([
|
|
29
34
|
api_1.apiClient.getAccount(address),
|
|
30
35
|
api_1.apiClient.getAccountTokens(address),
|
|
36
|
+
(0, utils_2.getERC20BalancesForAccount)(evmAddress),
|
|
31
37
|
]);
|
|
32
38
|
const accountBalance = new bignumber_js_1.BigNumber(mirrorAccount.balance.balance);
|
|
33
39
|
// we should sync again when new tokens are added or blacklist changes
|
|
34
40
|
const syncHash = await (0, account_1.getSyncHash)(currency.id, blacklistedTokenIds);
|
|
35
41
|
const shouldSyncFromScratch = !initialAccount || syncHash !== initialAccount?.syncHash;
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
42
|
+
const pendingOperations = shouldSyncFromScratch ? [] : initialAccount?.pendingOperations ?? [];
|
|
43
|
+
const oldOperations = shouldSyncFromScratch ? [] : initialAccount?.operations ?? [];
|
|
44
|
+
const oldERC20Operations = oldOperations.filter(item => item.standard === "erc20");
|
|
39
45
|
const latestOperation = oldOperations[0];
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
const erc20LatestOperation = oldERC20Operations[0];
|
|
47
|
+
const pendingOperationHashes = new Set(pendingOperations.map(op => op.hash));
|
|
48
|
+
const erc20OperationHashes = new Set(oldERC20Operations.map(op => op.hash));
|
|
49
|
+
// grab latest operation timestamps for incremental sync
|
|
50
|
+
let latestOperationTimestamp = null;
|
|
51
|
+
let erc20LatestOperationTimestamp = null;
|
|
52
|
+
if (!shouldSyncFromScratch && latestOperation) {
|
|
53
|
+
const timestamp = Math.floor(latestOperation.date.getTime() / 1000);
|
|
54
|
+
latestOperationTimestamp = new bignumber_js_1.BigNumber(timestamp).toString();
|
|
55
|
+
}
|
|
56
|
+
if (!shouldSyncFromScratch && erc20LatestOperation) {
|
|
57
|
+
const timestamp = Math.floor(erc20LatestOperation.date.getTime() / 1000);
|
|
58
|
+
erc20LatestOperationTimestamp = new bignumber_js_1.BigNumber(timestamp).toString();
|
|
59
|
+
}
|
|
60
|
+
const [latestAccountOperations, erc20Transactions] = await Promise.all([
|
|
61
|
+
(0, logic_1.listOperations)({
|
|
62
|
+
currency,
|
|
63
|
+
address,
|
|
64
|
+
mirrorTokens,
|
|
65
|
+
pagination: {
|
|
66
|
+
minHeight: 0,
|
|
67
|
+
...(latestOperationTimestamp && { lastPagingToken: latestOperationTimestamp.toString() }),
|
|
68
|
+
},
|
|
69
|
+
fetchAllPages: true,
|
|
70
|
+
skipFeesForTokenOperations: false,
|
|
71
|
+
useEncodedHash: true,
|
|
72
|
+
useSyntheticBlocks: false,
|
|
73
|
+
}),
|
|
74
|
+
thirdweb_1.thirdwebClient.getERC20TransactionsForAccount({
|
|
75
|
+
address,
|
|
76
|
+
contractAddresses: erc20TokenBalances.map(token => token.token.contractAddress),
|
|
77
|
+
since: erc20LatestOperationTimestamp,
|
|
78
|
+
}),
|
|
79
|
+
]);
|
|
80
|
+
const newOperations = await (0, utils_3.prepareOperations)(latestAccountOperations.coinOperations, latestAccountOperations.tokenOperations);
|
|
81
|
+
const enrichedNewOperations = (0, utils_3.applyPendingExtras)(newOperations, pendingOperations);
|
|
60
82
|
const operations = shouldSyncFromScratch
|
|
61
83
|
? enrichedNewOperations
|
|
62
84
|
: (0, jsHelpers_1.mergeOps)(oldOperations, enrichedNewOperations);
|
|
85
|
+
// how ERC20 operations are handled:
|
|
86
|
+
// - mirror node doesn't include "IN" erc20 token transactions
|
|
87
|
+
// - mirror node returns "CONTRACT_CALL" (OUT) erc20 token transactions made from given account address
|
|
88
|
+
// - mirror node doesn't return "CONTRACT_CALL" (OUT) erc20 token transactions made from 3rd party with allowance
|
|
89
|
+
//
|
|
90
|
+
// 1. mirror node transactions are already transformed into operations at this point + we have raw erc20 transactions fetched from thirdweb
|
|
91
|
+
// 2. related mirror node transaction must be fetched for each erc20 transaction (to get fee and consensus timestamp)
|
|
92
|
+
// 3. CONTRACTCALL operations must be removed if existing operations already include erc20 operation with the same tx.hash
|
|
93
|
+
// 4. ERC20 transactions must be classified into two groups: patchList and addList
|
|
94
|
+
// - patchList: transactions which are already present in mirror operations (we can have CONTRACT_CALL from mirror node that we can transform into "FEES")
|
|
95
|
+
// - addList should include transactions which are missing in mirror operations (e.g. "IN" erc20 token transaction and "OUT" made by 3rd party with allowance)
|
|
96
|
+
// 5. list of all operations must be updated based on prepared `patchList` and `addList`
|
|
97
|
+
// 6. sub accounts must get erc20 tokens and erc20 operations in addition to hts tokens and hts operations
|
|
98
|
+
// 7. postSync must remove pending operations that are already confirmed as erc20 operations
|
|
99
|
+
const { updatedOperations, newERC20TokenOperations } = await (0, utils_3.integrateERC20Operations)({
|
|
100
|
+
ledgerAccountId: liveAccountId,
|
|
101
|
+
address,
|
|
102
|
+
allOperations: operations,
|
|
103
|
+
latestERC20Transactions: erc20Transactions,
|
|
104
|
+
pendingOperationHashes,
|
|
105
|
+
erc20OperationHashes,
|
|
106
|
+
});
|
|
107
|
+
const newSubAccounts = await (0, utils_3.getSubAccounts)({
|
|
108
|
+
ledgerAccountId: liveAccountId,
|
|
109
|
+
latestHTSTokenOperations: latestAccountOperations.tokenOperations,
|
|
110
|
+
latestERC20TokenOperations: newERC20TokenOperations,
|
|
111
|
+
mirrorTokens,
|
|
112
|
+
erc20Tokens: erc20TokenBalances,
|
|
113
|
+
});
|
|
114
|
+
const subAccounts = shouldSyncFromScratch
|
|
115
|
+
? newSubAccounts
|
|
116
|
+
: (0, utils_3.mergeSubAccounts)(initialAccount, newSubAccounts);
|
|
63
117
|
return {
|
|
64
118
|
id: liveAccountId,
|
|
65
119
|
freshAddress: address,
|
|
@@ -67,8 +121,8 @@ const getAccountShape = async (info, { blacklistedTokenIds }) => {
|
|
|
67
121
|
lastSyncDate: new Date(),
|
|
68
122
|
balance: accountBalance,
|
|
69
123
|
spendableBalance: accountBalance,
|
|
70
|
-
operations,
|
|
71
|
-
operationsCount:
|
|
124
|
+
operations: updatedOperations,
|
|
125
|
+
operationsCount: updatedOperations.length,
|
|
72
126
|
// NOTE: there are no "blocks" in hedera
|
|
73
127
|
// Set a value just so that operations are considered confirmed according to isConfirmedOperation
|
|
74
128
|
blockHeight: 10,
|
|
@@ -101,4 +155,21 @@ const buildIterateResult = async ({ result: rootResult }) => {
|
|
|
101
155
|
};
|
|
102
156
|
};
|
|
103
157
|
exports.buildIterateResult = buildIterateResult;
|
|
158
|
+
// it might be necessary to remove pending operations after ERC20 patching done by `integrateERC20Operations`
|
|
159
|
+
const postSync = (_initial, synced) => {
|
|
160
|
+
const erc20Operations = synced.operations.filter(op => op.standard === "erc20");
|
|
161
|
+
const erc20Hashes = new Set(erc20Operations.map(op => op.hash));
|
|
162
|
+
const excludeConfirmedERC20Operations = (o) => !erc20Hashes.has(o.hash);
|
|
163
|
+
return {
|
|
164
|
+
...synced,
|
|
165
|
+
pendingOperations: synced.pendingOperations.filter(excludeConfirmedERC20Operations),
|
|
166
|
+
subAccounts: (synced.subAccounts ?? []).map(subAccount => {
|
|
167
|
+
return {
|
|
168
|
+
...subAccount,
|
|
169
|
+
pendingOperations: subAccount.pendingOperations.filter(excludeConfirmedERC20Operations),
|
|
170
|
+
};
|
|
171
|
+
}),
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
exports.postSync = postSync;
|
|
104
175
|
//# sourceMappingURL=synchronisation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronisation.js","sourceRoot":"","sources":["../../src/bridge/synchronisation.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAyC;AACzC,0DAAkC;AAElC,oEAA+F;AAK/F,yEAAqE;AACrE,8DAAgF;
|
|
1
|
+
{"version":3,"file":"synchronisation.js","sourceRoot":"","sources":["../../src/bridge/synchronisation.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAyC;AACzC,0DAAkC;AAElC,oEAA+F;AAK/F,yEAAqE;AACrE,8DAAgF;AAEhF,0CAA8C;AAC9C,oCAA0C;AAC1C,wCAA2C;AAC3C,kDAAqD;AACrD,4CAA8D;AAE9D,mCAMiB;AAEV,MAAM,eAAe,GAAmC,KAAK,EAClE,IAAI,EACJ,EAAE,mBAAmB,EAAE,EACU,EAAE;IACnC,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACnE,IAAA,mBAAS,EAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,IAAA,oBAAY,EAAC,OAAO,CAAC,CAAC;IACzC,IAAA,m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CAAC,KAAK,CAAC;gBAC3B,IAAI,EAAE,gBAAgB;aACN,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC;IACX,CAAC,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,kBAAkB,sBAqB7B;AAEF,6GAA6G;AACtG,MAAM,QAAQ,GAAG,CAAC,QAAiB,EAAE,MAAe,EAAW,EAAE;IACtE,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IAChF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhE,MAAM,+BAA+B,GAAG,CAAC,CAAY,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEnF,OAAO;QACL,GAAG,MAAM;QACT,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,+BAA+B,CAAC;QACnF,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YACvD,OAAO;gBACL,GAAG,UAAU;gBACb,iBAAiB,EAAE,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,+BAA+B,CAAC;aACxF,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,QAAQ,YAgBnB"}
|
package/lib/bridge/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
2
|
import type { Account, Operation, TokenAccount } from "@ledgerhq/types-live";
|
|
3
|
-
import type { HederaOperationExtra, Transaction, HederaMirrorToken } from "../types";
|
|
3
|
+
import type { HederaOperationExtra, Transaction, OperationERC20, HederaMirrorToken, HederaERC20TokenBalance, HederaThirdwebTransaction, ERC20OperationFields } from "../types";
|
|
4
4
|
interface CalculateAmountResult {
|
|
5
5
|
amount: BigNumber;
|
|
6
6
|
totalSpent: BigNumber;
|
|
@@ -9,7 +9,13 @@ export declare const calculateAmount: ({ account, transaction, }: {
|
|
|
9
9
|
account: Account;
|
|
10
10
|
transaction: Transaction;
|
|
11
11
|
}) => Promise<CalculateAmountResult>;
|
|
12
|
-
export declare const getSubAccounts: (
|
|
12
|
+
export declare const getSubAccounts: ({ ledgerAccountId, latestHTSTokenOperations, latestERC20TokenOperations, mirrorTokens, erc20Tokens, }: {
|
|
13
|
+
ledgerAccountId: string;
|
|
14
|
+
latestHTSTokenOperations: Operation[];
|
|
15
|
+
latestERC20TokenOperations: Operation[];
|
|
16
|
+
mirrorTokens: HederaMirrorToken[];
|
|
17
|
+
erc20Tokens: HederaERC20TokenBalance[];
|
|
18
|
+
}) => Promise<TokenAccount[]>;
|
|
13
19
|
export declare const prepareOperations: (coinOperations: Operation<HederaOperationExtra>[], tokenOperations: Operation<HederaOperationExtra>[]) => Promise<Operation<HederaOperationExtra>[]>;
|
|
14
20
|
/**
|
|
15
21
|
* In charge of smartly merging sub accounts while maintaining references as much as possible
|
|
@@ -17,5 +23,32 @@ export declare const prepareOperations: (coinOperations: Operation<HederaOperati
|
|
|
17
23
|
export declare const mergeSubAccounts: (initialAccount: Account | undefined, newSubAccounts: TokenAccount[]) => Array<TokenAccount>;
|
|
18
24
|
export declare const applyPendingExtras: (existing: Operation[], pending: Operation[]) => Operation[];
|
|
19
25
|
export declare function patchOperationWithExtra(operation: Operation, extra: HederaOperationExtra): Operation;
|
|
26
|
+
export declare const removeDuplicatedContractCallOperations: (operations: Operation[], pendingOperationHashes: Set<string>, erc20OperationHashes: Set<string>) => Operation[];
|
|
27
|
+
export declare const classifyERC20Operations: ({ latestERC20Operations, operationsByHash, evmAccountAddress, }: {
|
|
28
|
+
latestERC20Operations: OperationERC20[];
|
|
29
|
+
operationsByHash: Map<string, Operation>;
|
|
30
|
+
evmAccountAddress: string | null;
|
|
31
|
+
}) => {
|
|
32
|
+
erc20OperationsToPatch: Map<string, OperationERC20>;
|
|
33
|
+
erc20OperationsToAdd: Map<string, OperationERC20>;
|
|
34
|
+
};
|
|
35
|
+
export declare const patchContractCallOperation: ({ relatedExistingOperation, ledgerAccountId, hash, erc20Fields, tokenOperation, }: {
|
|
36
|
+
relatedExistingOperation: Operation;
|
|
37
|
+
ledgerAccountId: string;
|
|
38
|
+
hash: string;
|
|
39
|
+
erc20Fields: ERC20OperationFields;
|
|
40
|
+
tokenOperation: Operation;
|
|
41
|
+
}) => void;
|
|
42
|
+
export declare const integrateERC20Operations: ({ ledgerAccountId, address, allOperations, latestERC20Transactions, pendingOperationHashes, erc20OperationHashes, }: {
|
|
43
|
+
ledgerAccountId: string;
|
|
44
|
+
address: string;
|
|
45
|
+
allOperations: Operation[];
|
|
46
|
+
latestERC20Transactions: HederaThirdwebTransaction[];
|
|
47
|
+
pendingOperationHashes: Set<string>;
|
|
48
|
+
erc20OperationHashes: Set<string>;
|
|
49
|
+
}) => Promise<{
|
|
50
|
+
updatedOperations: Operation[];
|
|
51
|
+
newERC20TokenOperations: Operation[];
|
|
52
|
+
}>;
|
|
20
53
|
export {};
|
|
21
54
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/bridge/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/bridge/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAiB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAwB5F,OAAO,KAAK,E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