@ledgerhq/coin-canton 0.5.0-nightly.4 → 0.5.0-nightly.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +12 -0
- package/lib/api/getBalance.integ.test.js +1 -1
- package/lib/api/getBalance.integ.test.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +20 -28
- package/lib/api/index.js.map +1 -1
- package/lib/api/lastBlock.integ.test.js +1 -1
- package/lib/api/lastBlock.integ.test.js.map +1 -1
- package/lib/api/listOperations.integ.test.js +1 -1
- package/lib/api/listOperations.integ.test.js.map +1 -1
- package/lib/bridge/broadcast.d.ts.map +1 -1
- package/lib/bridge/broadcast.js +2 -2
- package/lib/bridge/broadcast.js.map +1 -1
- package/lib/bridge/broadcast.test.js +9 -0
- package/lib/bridge/broadcast.test.js.map +1 -1
- package/lib/bridge/createTransaction.js +1 -1
- package/lib/bridge/createTransaction.js.map +1 -1
- package/lib/bridge/getTransactionStatus.js +1 -1
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/onboard.d.ts +4 -3
- package/lib/bridge/onboard.d.ts.map +1 -1
- package/lib/bridge/onboard.integ.test.js +11 -8
- package/lib/bridge/onboard.integ.test.js.map +1 -1
- package/lib/bridge/onboard.js +24 -16
- package/lib/bridge/onboard.js.map +1 -1
- package/lib/bridge/prepareTransaction.js +1 -1
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +10 -5
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/sync.d.ts.map +1 -1
- package/lib/bridge/sync.js +17 -12
- package/lib/bridge/sync.js.map +1 -1
- package/lib/common-logic/account/getBalance.d.ts +2 -1
- package/lib/common-logic/account/getBalance.d.ts.map +1 -1
- package/lib/common-logic/account/getBalance.js +7 -7
- package/lib/common-logic/account/getBalance.js.map +1 -1
- package/lib/common-logic/account/getBalance.unit.test.js +6 -3
- package/lib/common-logic/account/getBalance.unit.test.js.map +1 -1
- package/lib/common-logic/history/lastBlock.d.ts +2 -1
- package/lib/common-logic/history/lastBlock.d.ts.map +1 -1
- package/lib/common-logic/history/lastBlock.js +3 -3
- package/lib/common-logic/history/lastBlock.js.map +1 -1
- package/lib/common-logic/history/lastBlock.test.js +5 -2
- package/lib/common-logic/history/lastBlock.test.js.map +1 -1
- package/lib/common-logic/history/listOperations.d.ts +2 -1
- package/lib/common-logic/history/listOperations.d.ts.map +1 -1
- package/lib/common-logic/history/listOperations.js +2 -2
- package/lib/common-logic/history/listOperations.js.map +1 -1
- package/lib/common-logic/transaction/broadcast.d.ts +2 -1
- package/lib/common-logic/transaction/broadcast.d.ts.map +1 -1
- package/lib/common-logic/transaction/broadcast.js +4 -4
- package/lib/common-logic/transaction/broadcast.js.map +1 -1
- package/lib/common-logic/transaction/broadcast.test.js +6 -3
- package/lib/common-logic/transaction/broadcast.test.js.map +1 -1
- package/lib/common-logic/transaction/craftTransaction.d.ts +3 -1
- package/lib/common-logic/transaction/craftTransaction.d.ts.map +1 -1
- package/lib/common-logic/transaction/craftTransaction.js +8 -4
- package/lib/common-logic/transaction/craftTransaction.js.map +1 -1
- package/lib/common-logic/transaction/estimateFees.d.ts +2 -1
- package/lib/common-logic/transaction/estimateFees.d.ts.map +1 -1
- package/lib/common-logic/transaction/estimateFees.js +3 -4
- package/lib/common-logic/transaction/estimateFees.js.map +1 -1
- package/lib/network/gateway.d.ts +24 -14
- package/lib/network/gateway.d.ts.map +1 -1
- package/lib/network/gateway.integ.test.js +17 -14
- package/lib/network/gateway.integ.test.js.map +1 -1
- package/lib/network/gateway.js +33 -33
- package/lib/network/gateway.js.map +1 -1
- package/lib/types/bridge.d.ts +5 -2
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib-es/api/getBalance.integ.test.js +1 -1
- package/lib-es/api/getBalance.integ.test.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +19 -27
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/lastBlock.integ.test.js +1 -1
- package/lib-es/api/lastBlock.integ.test.js.map +1 -1
- package/lib-es/api/listOperations.integ.test.js +1 -1
- package/lib-es/api/listOperations.integ.test.js.map +1 -1
- package/lib-es/bridge/broadcast.d.ts.map +1 -1
- package/lib-es/bridge/broadcast.js +2 -2
- package/lib-es/bridge/broadcast.js.map +1 -1
- package/lib-es/bridge/broadcast.test.js +9 -0
- package/lib-es/bridge/broadcast.test.js.map +1 -1
- package/lib-es/bridge/createTransaction.js +1 -1
- package/lib-es/bridge/createTransaction.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +1 -1
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/onboard.d.ts +4 -3
- package/lib-es/bridge/onboard.d.ts.map +1 -1
- package/lib-es/bridge/onboard.integ.test.js +11 -8
- package/lib-es/bridge/onboard.integ.test.js.map +1 -1
- package/lib-es/bridge/onboard.js +24 -16
- package/lib-es/bridge/onboard.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +1 -1
- 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 +10 -5
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/sync.d.ts.map +1 -1
- package/lib-es/bridge/sync.js +17 -12
- package/lib-es/bridge/sync.js.map +1 -1
- package/lib-es/common-logic/account/getBalance.d.ts +2 -1
- package/lib-es/common-logic/account/getBalance.d.ts.map +1 -1
- package/lib-es/common-logic/account/getBalance.js +7 -7
- package/lib-es/common-logic/account/getBalance.js.map +1 -1
- package/lib-es/common-logic/account/getBalance.unit.test.js +6 -3
- package/lib-es/common-logic/account/getBalance.unit.test.js.map +1 -1
- package/lib-es/common-logic/history/lastBlock.d.ts +2 -1
- package/lib-es/common-logic/history/lastBlock.d.ts.map +1 -1
- package/lib-es/common-logic/history/lastBlock.js +3 -3
- package/lib-es/common-logic/history/lastBlock.js.map +1 -1
- package/lib-es/common-logic/history/lastBlock.test.js +5 -2
- package/lib-es/common-logic/history/lastBlock.test.js.map +1 -1
- package/lib-es/common-logic/history/listOperations.d.ts +2 -1
- package/lib-es/common-logic/history/listOperations.d.ts.map +1 -1
- package/lib-es/common-logic/history/listOperations.js +2 -2
- package/lib-es/common-logic/history/listOperations.js.map +1 -1
- package/lib-es/common-logic/transaction/broadcast.d.ts +2 -1
- package/lib-es/common-logic/transaction/broadcast.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/broadcast.js +4 -4
- package/lib-es/common-logic/transaction/broadcast.js.map +1 -1
- package/lib-es/common-logic/transaction/broadcast.test.js +6 -3
- package/lib-es/common-logic/transaction/broadcast.test.js.map +1 -1
- package/lib-es/common-logic/transaction/craftTransaction.d.ts +3 -1
- package/lib-es/common-logic/transaction/craftTransaction.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/craftTransaction.js +9 -5
- package/lib-es/common-logic/transaction/craftTransaction.js.map +1 -1
- package/lib-es/common-logic/transaction/estimateFees.d.ts +2 -1
- package/lib-es/common-logic/transaction/estimateFees.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/estimateFees.js +3 -4
- package/lib-es/common-logic/transaction/estimateFees.js.map +1 -1
- package/lib-es/network/gateway.d.ts +24 -14
- package/lib-es/network/gateway.d.ts.map +1 -1
- package/lib-es/network/gateway.integ.test.js +17 -14
- package/lib-es/network/gateway.integ.test.js.map +1 -1
- package/lib-es/network/gateway.js +33 -33
- package/lib-es/network/gateway.js.map +1 -1
- package/lib-es/types/bridge.d.ts +5 -2
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/api/getBalance.integ.test.ts +1 -1
- package/src/api/index.ts +22 -51
- package/src/api/lastBlock.integ.test.ts +1 -1
- package/src/api/listOperations.integ.test.ts +1 -1
- package/src/bridge/broadcast.test.ts +11 -0
- package/src/bridge/broadcast.ts +5 -2
- package/src/bridge/createTransaction.ts +1 -1
- package/src/bridge/getTransactionStatus.ts +1 -1
- package/src/bridge/onboard.integ.test.ts +22 -10
- package/src/bridge/onboard.ts +32 -13
- package/src/bridge/prepareTransaction.ts +1 -1
- package/src/bridge/signOperation.ts +20 -7
- package/src/bridge/sync.ts +17 -14
- package/src/common-logic/account/getBalance.ts +12 -7
- package/src/common-logic/account/getBalance.unit.test.ts +8 -3
- package/src/common-logic/history/lastBlock.test.ts +7 -2
- package/src/common-logic/history/lastBlock.ts +5 -3
- package/src/common-logic/history/listOperations.ts +3 -2
- package/src/common-logic/transaction/broadcast.test.ts +8 -3
- package/src/common-logic/transaction/broadcast.ts +6 -3
- package/src/common-logic/transaction/craftTransaction.ts +22 -5
- package/src/common-logic/transaction/estimateFees.ts +4 -4
- package/src/network/gateway.integ.test.ts +29 -11
- package/src/network/gateway.ts +66 -35
- package/src/types/bridge.ts +5 -0
|
@@ -17,15 +17,20 @@ const buildSignOperation = (signerContext) => ({ account, deviceId, transaction
|
|
|
17
17
|
});
|
|
18
18
|
const signature = await signerContext(deviceId, async (signer) => {
|
|
19
19
|
const { freshAddressPath: derivationPath } = account;
|
|
20
|
-
const partyId = account
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}, {
|
|
20
|
+
const partyId = account
|
|
21
|
+
.cantonResources.partyId;
|
|
22
|
+
const params = {
|
|
24
23
|
recipient: transaction.recipient,
|
|
25
24
|
amount: transaction.amount,
|
|
26
25
|
expireInSeconds: 60 * 60,
|
|
27
26
|
tokenId: "Amulet",
|
|
28
|
-
}
|
|
27
|
+
};
|
|
28
|
+
if (transaction.memo) {
|
|
29
|
+
params.memo = transaction.memo;
|
|
30
|
+
}
|
|
31
|
+
const { hash, serializedTransaction } = await (0, common_logic_1.craftTransaction)(account.currency, {
|
|
32
|
+
address: partyId,
|
|
33
|
+
}, params);
|
|
29
34
|
const transactionSignature = await signer.signTransaction(derivationPath, hash);
|
|
30
35
|
return (0, common_logic_1.combine)(serializedTransaction, `${transactionSignature}__PARTY__${partyId}`);
|
|
31
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signOperation.js","sourceRoot":"","sources":["../../src/bridge/signOperation.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;
|
|
1
|
+
{"version":3,"file":"signOperation.js","sourceRoot":"","sources":["../../src/bridge/signOperation.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;AAElC,6CAAgD;AAGhD,kEAAuE;AACvE,kDAA4D;AAGrD,MAAM,kBAAkB,GAC7B,CAAC,aAA0C,EAA+C,EAAE,CAC5F,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,CACrC,IAAI,iBAAU,CAAC,CAAC,CAAC,EAAE;IACjB,KAAK,UAAU,IAAI;QACjB,MAAM,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC;QAC5B,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,qBAAY,EAAE,CAAC;QAEnC,IAAI,CAAC;YACH,8EAA8E;YAC9E,CAAC,CAAC,IAAI,CAAC;gBACL,IAAI,EAAE,4BAA4B;aACnC,CAAC,CAAC;YAEH,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE;gBAC7D,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;gBACrD,MAAM,OAAO,GAAI,OAA+D;qBAC7E,eAAe,CAAC,OAAO,CAAC;gBAC3B,MAAM,MAAM,GAMR;oBACF,SAAS,EAAE,WAAW,CAAC,SAAS;oBAChC,MAAM,EAAE,WAAW,CAAC,MAAM;oBAC1B,eAAe,EAAE,EAAE,GAAG,EAAE;oBACxB,OAAO,EAAE,QAAQ;iBAClB,CAAC;gBACF,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;oBACrB,MAAM,CAAC,IAAI,GAAG,WAAW,CAA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aAAa,CAC1E,CAAC;YACJ,CAAC;YAED,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IAED,IAAI,EAAE,CAAC,IAAI,CACT,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,EAClB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAChB,CAAC;AACJ,CAAC,CAAC,CAAC;AAzFM,QAAA,kBAAkB,sBAyFxB"}
|
package/lib/bridge/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAY,MAAM,2CAA2C,CAAC;AAGtF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAY,MAAM,2CAA2C,CAAC;AAGtF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAwDzC,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,aAAa,CAoE1D,CAAC"}
|
package/lib/bridge/sync.js
CHANGED
|
@@ -11,10 +11,17 @@ const operation_1 = require("@ledgerhq/coin-framework/operation");
|
|
|
11
11
|
const gateway_1 = require("../network/gateway");
|
|
12
12
|
const config_1 = __importDefault(require("../config"));
|
|
13
13
|
const txInfoToOperationAdapter = (accountId, partyId) => (txInfo) => {
|
|
14
|
-
const { transaction_hash, uid, block: { height, hash }, senders, recipients, transaction_timestamp, fee: { value: fee }, transfers: [{ value: transferValue }], } = txInfo;
|
|
15
|
-
|
|
14
|
+
const { transaction_hash, uid, block: { height, hash }, senders, recipients, transaction_timestamp, fee: { value: fee }, transfers: [{ value: transferValue, details }], } = txInfo;
|
|
15
|
+
let type = "UNKNOWN";
|
|
16
|
+
if (txInfo.type === "Send") {
|
|
17
|
+
type = senders.includes(partyId) ? "OUT" : "IN";
|
|
18
|
+
}
|
|
19
|
+
else if (txInfo.type === "Receive") {
|
|
20
|
+
type = "IN";
|
|
21
|
+
}
|
|
16
22
|
const value = new bignumber_js_1.default(transferValue);
|
|
17
23
|
const feeValue = new bignumber_js_1.default(fee);
|
|
24
|
+
const memo = details.metadata.reason;
|
|
18
25
|
const op = {
|
|
19
26
|
id: (0, operation_1.encodeOperationId)(accountId, transaction_hash, type),
|
|
20
27
|
hash: transaction_hash,
|
|
@@ -30,14 +37,13 @@ const txInfoToOperationAdapter = (accountId, partyId) => (txInfo) => {
|
|
|
30
37
|
transactionSequenceNumber: height,
|
|
31
38
|
extra: {
|
|
32
39
|
uid,
|
|
40
|
+
memo,
|
|
33
41
|
},
|
|
34
42
|
};
|
|
35
43
|
return op;
|
|
36
44
|
};
|
|
37
45
|
const filterOperations = (transactions, accountId, partyId) => {
|
|
38
|
-
return transactions
|
|
39
|
-
.filter(tx => tx.type === "Receive" || tx.type === "Send")
|
|
40
|
-
.map(txInfoToOperationAdapter(accountId, partyId));
|
|
46
|
+
return transactions.map(txInfoToOperationAdapter(accountId, partyId));
|
|
41
47
|
};
|
|
42
48
|
const getAccountShape = async (info) => {
|
|
43
49
|
const { address, initialAccount, currency, derivationMode, derivationPath, rest } = info;
|
|
@@ -53,28 +59,27 @@ const getAccountShape = async (info) => {
|
|
|
53
59
|
xpubOrAddress,
|
|
54
60
|
derivationMode,
|
|
55
61
|
});
|
|
56
|
-
// blockheight retrieval
|
|
57
|
-
const blockHeight = await (0, gateway_1.getLedgerEnd)();
|
|
58
62
|
// Account info retrieval + spendable balance calculation
|
|
59
63
|
// const accountInfo = await getAccountInfo(address);
|
|
60
|
-
const balances = await (0, gateway_1.getBalance)(partyId);
|
|
61
|
-
|
|
62
|
-
const balanceData = balances.find(balance => balance.instrument_id.includes("Amulet")) || {
|
|
64
|
+
const balances = await (0, gateway_1.getBalance)(currency, partyId);
|
|
65
|
+
const balanceData = balances.find(balance => balance.instrument_id === "Amulet") || {
|
|
63
66
|
instrument_id: "Amulet",
|
|
64
67
|
amount: 0,
|
|
65
68
|
locked: false,
|
|
66
69
|
};
|
|
67
70
|
const balance = new bignumber_js_1.default(balanceData.amount);
|
|
68
|
-
const reserveMin = config_1.default.getCoinConfig().minReserve || 0;
|
|
71
|
+
const reserveMin = config_1.default.getCoinConfig(currency).minReserve || 0;
|
|
69
72
|
const lockedAmount = balanceData.locked ? balance : new bignumber_js_1.default(0);
|
|
70
73
|
const spendableBalance = bignumber_js_1.default.max(0, balance.minus(lockedAmount).minus((0, bignumber_js_1.default)(reserveMin)));
|
|
71
74
|
// Tx history fetching
|
|
72
75
|
const oldOperations = initialAccount?.operations || [];
|
|
73
76
|
const startAt = oldOperations.length ? (oldOperations[0].blockHeight || 0) + 1 : 0;
|
|
74
|
-
const transactionData = await (0, gateway_1.getOperations)(partyId, {
|
|
77
|
+
const transactionData = await (0, gateway_1.getOperations)(currency, partyId, {
|
|
75
78
|
cursor: startAt,
|
|
76
79
|
limit: 100,
|
|
77
80
|
});
|
|
81
|
+
// blockheight retrieval
|
|
82
|
+
const blockHeight = await (0, gateway_1.getLedgerEnd)(currency);
|
|
78
83
|
const newOperations = filterOperations(transactionData.operations, accountId, partyId);
|
|
79
84
|
const operations = (0, jsHelpers_1.mergeOps)(oldOperations, newOperations);
|
|
80
85
|
// We return the new account shape
|
package/lib/bridge/sync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAErC,kEAA0F;AAC1F,yEAAsF;AACtF,kEAAuE;AACvE,gDAAiG;AAEjG,uDAAmC;AAEnC,MAAM,wBAAwB,GAC5B,CAAC,SAAiB,EAAE,OAAe,EAAE,EAAE,CACvC,CAAC,MAAqB,EAAa,EAAE;IACnC,MAAM,EACJ,gBAAgB,EAChB,GAAG,EAC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M,IAAA,sBAAY,EAAC,QAAQ,CAAC,CAAC;IAEjD,MAAM,aAAa,GAAG,gBAAgB,CAAC,eAAe,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACvF,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IAE1D,kCAAkC;IAClC,MAAM,KAAK,GAAG;QACZ,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,aAAa;QACnB,WAAW;QACX,OAAO;QACP,gBAAgB;QAChB,UAAU;QACV,eAAe,EAAE,UAAU,CAAC,MAAM;QAClC,YAAY,EAAE,OAAO;QACrB,gBAAgB,EAAE,cAAc;QAChC,eAAe,EAAE;YACf,OAAO;SACR;KACF,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AApEW,QAAA,eAAe,mBAoE1B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Balance } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
-
|
|
2
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
|
+
export declare function getBalance(currency: CryptoCurrency, partyId: string): Promise<Balance[]>;
|
|
3
4
|
//# sourceMappingURL=getBalance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../../src/common-logic/account/getBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../../src/common-logic/account/getBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAkB9D,wBAAsB,UAAU,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAM9F"}
|
|
@@ -6,20 +6,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getBalance = getBalance;
|
|
7
7
|
const gateway_1 = require("../../network/gateway");
|
|
8
8
|
const config_1 = __importDefault(require("../../config"));
|
|
9
|
-
const useGateway = () => config_1.default.getCoinConfig().useGateway === true;
|
|
10
|
-
const getNativeId = () => config_1.default.getCoinConfig().nativeInstrumentId;
|
|
11
|
-
function adaptInstrument(instrument) {
|
|
9
|
+
const useGateway = (currency) => config_1.default.getCoinConfig(currency).useGateway === true;
|
|
10
|
+
const getNativeId = (currency) => config_1.default.getCoinConfig(currency).nativeInstrumentId;
|
|
11
|
+
function adaptInstrument(currency, instrument) {
|
|
12
12
|
return {
|
|
13
13
|
value: BigInt(instrument.amount),
|
|
14
14
|
locked: instrument.locked === true ? BigInt(instrument.amount) : BigInt(0),
|
|
15
|
-
asset: getNativeId() === instrument.instrument_id
|
|
15
|
+
asset: getNativeId(currency) === instrument.instrument_id
|
|
16
16
|
? { type: "native" }
|
|
17
17
|
: { type: "token", assetReference: instrument.instrument_id },
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
async function getBalance(partyId) {
|
|
21
|
-
if (useGateway())
|
|
22
|
-
return (await (0, gateway_1.getBalance)(partyId)).map(instrument => adaptInstrument(instrument));
|
|
20
|
+
async function getBalance(currency, partyId) {
|
|
21
|
+
if (useGateway(currency))
|
|
22
|
+
return (await (0, gateway_1.getBalance)(currency, partyId)).map(instrument => adaptInstrument(currency, instrument));
|
|
23
23
|
else
|
|
24
24
|
throw new Error("Not implemented");
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../../src/common-logic/account/getBalance.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../../src/common-logic/account/getBalance.ts"],"names":[],"mappings":";;;;;AAqBA,gCAMC;AA1BD,mDAAgG;AAChG,0DAAsC;AAGtC,MAAM,UAAU,GAAG,CAAC,QAAwB,EAAE,EAAE,CAC9C,gBAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC;AACzD,MAAM,WAAW,GAAG,CAAC,QAAwB,EAAE,EAAE,CAC/C,gBAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,kBAAkB,CAAC;AAExD,SAAS,eAAe,CAAC,QAAwB,EAAE,UAA6B;IAC9E,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;QAChC,MAAM,EAAE,UAAU,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1E,KAAK,EACH,WAAW,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC,aAAa;YAChD,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE;YACpB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,CAAC,aAAa,EAAE;KAClE,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,QAAwB,EAAE,OAAe;IACxE,IAAI,UAAU,CAAC,QAAQ,CAAC;QACtB,OAAO,CAAC,MAAM,IAAA,oBAAiB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CACnE,eAAe,CAAC,QAAQ,EAAE,UAAU,CAAC,CACtC,CAAC;;QACC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -36,6 +36,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
const gateway_1 = require("../../network/gateway");
|
|
37
37
|
const coinConfigModule = __importStar(require("../../config"));
|
|
38
38
|
const getBalance_1 = require("./getBalance");
|
|
39
|
+
const mockCurrency = {
|
|
40
|
+
id: "canton_network",
|
|
41
|
+
};
|
|
39
42
|
jest.mock("../../network/gateway", () => ({
|
|
40
43
|
getBalance: jest.fn(),
|
|
41
44
|
}));
|
|
@@ -62,8 +65,8 @@ describe("getBalance", () => {
|
|
|
62
65
|
},
|
|
63
66
|
];
|
|
64
67
|
gateway_1.getBalance.mockResolvedValue(mockInstruments);
|
|
65
|
-
const result = await (0, getBalance_1.getBalance)("party-id");
|
|
66
|
-
expect(gateway_1.getBalance).toHaveBeenCalledWith("party-id");
|
|
68
|
+
const result = await (0, getBalance_1.getBalance)(mockCurrency, "party-id");
|
|
69
|
+
expect(gateway_1.getBalance).toHaveBeenCalledWith(mockCurrency, "party-id");
|
|
67
70
|
expect(result).toEqual([
|
|
68
71
|
{
|
|
69
72
|
value: BigInt(1000),
|
|
@@ -81,7 +84,7 @@ describe("getBalance", () => {
|
|
|
81
84
|
mockGetCoinConfig.mockReturnValue({
|
|
82
85
|
useGateway: false,
|
|
83
86
|
});
|
|
84
|
-
await expect((0, getBalance_1.getBalance)("party-id")).rejects.toThrow("Not implemented");
|
|
87
|
+
await expect((0, getBalance_1.getBalance)(mockCurrency, "party-id")).rejects.toThrow("Not implemented");
|
|
85
88
|
expect(gateway_1.getBalance).not.toHaveBeenCalled();
|
|
86
89
|
});
|
|
87
90
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.unit.test.js","sourceRoot":"","sources":["../../../src/common-logic/account/getBalance.unit.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA4E;AAC5E,+DAAiD;AACjD,6CAA0C;
|
|
1
|
+
{"version":3,"file":"getBalance.unit.test.js","sourceRoot":"","sources":["../../../src/common-logic/account/getBalance.unit.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA4E;AAC5E,+DAAiD;AACjD,6C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AM,CAAC,IAAI,CAAC;gBACnB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;gBACpB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE;aACtD;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4EAA4E,EAAE,KAAK,IAAI,EAAE;QAC1F,iBAAiB,CAAC,eAAe,CAAC;YAChC,UAAU,EAAE,KAAK;SACX,CAAC,CAAC;QAEV,MAAM,MAAM,CAAC,IAAA,uBAAU,EAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACtF,MAAM,CAAC,oBAAqB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { BlockInfo } from "@ledgerhq/coin-framework/api/index";
|
|
2
|
-
|
|
2
|
+
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
|
+
export declare function lastBlock(currency: CryptoCurrency): Promise<BlockInfo>;
|
|
3
4
|
//# sourceMappingURL=lastBlock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lastBlock.d.ts","sourceRoot":"","sources":["../../../src/common-logic/history/lastBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"lastBlock.d.ts","sourceRoot":"","sources":["../../../src/common-logic/history/lastBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAIpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKnE,wBAAsB,SAAS,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,CAAC,CAI5E"}
|
|
@@ -7,10 +7,10 @@ exports.lastBlock = lastBlock;
|
|
|
7
7
|
const node_1 = require("../../network/node");
|
|
8
8
|
const gateway_1 = require("../../network/gateway");
|
|
9
9
|
const config_1 = __importDefault(require("../../config"));
|
|
10
|
-
const useGateway = () => config_1.default.getCoinConfig().useGateway === true;
|
|
11
|
-
async function lastBlock() {
|
|
10
|
+
const useGateway = (currency) => config_1.default.getCoinConfig(currency).useGateway === true;
|
|
11
|
+
async function lastBlock(currency) {
|
|
12
12
|
return {
|
|
13
|
-
height: useGateway() ? await (0, gateway_1.getLedgerEnd)() : await (0, node_1.getLedgerEnd)(),
|
|
13
|
+
height: useGateway(currency) ? await (0, gateway_1.getLedgerEnd)(currency) : await (0, node_1.getLedgerEnd)(),
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=lastBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lastBlock.js","sourceRoot":"","sources":["../../../src/common-logic/history/lastBlock.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"lastBlock.js","sourceRoot":"","sources":["../../../src/common-logic/history/lastBlock.ts"],"names":[],"mappings":";;;;;AASA,8BAIC;AAZD,6CAAsE;AACtE,mDAAqD;AACrD,0DAAsC;AAGtC,MAAM,UAAU,GAAG,CAAC,QAAwB,EAAE,EAAE,CAC9C,gBAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC;AAElD,KAAK,UAAU,SAAS,CAAC,QAAwB;IACtD,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,sBAAY,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,mBAAgB,GAAE;KACvF,CAAC;AACJ,CAAC"}
|
|
@@ -19,6 +19,9 @@ jest.mock("../../config", () => ({
|
|
|
19
19
|
},
|
|
20
20
|
}));
|
|
21
21
|
const config_1 = __importDefault(require("../../config"));
|
|
22
|
+
const mockCurrency = {
|
|
23
|
+
id: "canton_network",
|
|
24
|
+
};
|
|
22
25
|
describe("lastBlock", () => {
|
|
23
26
|
beforeEach(() => {
|
|
24
27
|
jest.clearAllMocks();
|
|
@@ -26,7 +29,7 @@ describe("lastBlock", () => {
|
|
|
26
29
|
it("should use gateway.getLedgerEnd when useGateway is true", async () => {
|
|
27
30
|
config_1.default.getCoinConfig.mockReturnValue({ useGateway: true });
|
|
28
31
|
gateway_1.getLedgerEnd.mockResolvedValue(100);
|
|
29
|
-
const result = await (0, lastBlock_1.lastBlock)();
|
|
32
|
+
const result = await (0, lastBlock_1.lastBlock)(mockCurrency);
|
|
30
33
|
expect(result).toEqual({ height: 100 });
|
|
31
34
|
expect(gateway_1.getLedgerEnd).toHaveBeenCalledTimes(1);
|
|
32
35
|
expect(node_1.getLedgerEnd).not.toHaveBeenCalled();
|
|
@@ -34,7 +37,7 @@ describe("lastBlock", () => {
|
|
|
34
37
|
it("should use node.getLedgerEnd when useGateway is false", async () => {
|
|
35
38
|
config_1.default.getCoinConfig.mockReturnValue({ useGateway: false });
|
|
36
39
|
node_1.getLedgerEnd.mockResolvedValue(200);
|
|
37
|
-
const result = await (0, lastBlock_1.lastBlock)();
|
|
40
|
+
const result = await (0, lastBlock_1.lastBlock)(mockCurrency);
|
|
38
41
|
expect(result).toEqual({ height: 200 });
|
|
39
42
|
expect(node_1.getLedgerEnd).toHaveBeenCalledTimes(1);
|
|
40
43
|
expect(gateway_1.getLedgerEnd).not.toHaveBeenCalled();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lastBlock.test.js","sourceRoot":"","sources":["../../../src/common-logic/history/lastBlock.test.ts"],"names":[],"mappings":";;;;;AAAA,2CAAwC;AACxC,mDAA4E;AAC5E,6CAAsE;
|
|
1
|
+
{"version":3,"file":"lastBlock.test.js","sourceRoot":"","sources":["../../../src/common-logic/history/lastBlock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D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;QACpE,gBAAU,CAAC,aAA2B,CAAC,eAAe,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9E,mBAA8B,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAEvD,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAS,EAAC,YAAY,CAAC,CAAC;QAE7C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,mBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,sBAAmB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Operation, Pagination } from "@ledgerhq/coin-framework/api/index";
|
|
2
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
3
|
/**
|
|
3
4
|
* Returns list of operations associated to an account.
|
|
4
5
|
* @param partyId Account partyId
|
|
@@ -6,5 +7,5 @@ import type { Operation, Pagination } from "@ledgerhq/coin-framework/api/index";
|
|
|
6
7
|
* @returns Operations found and the next "id" or "index" to use for pagination (i.e. `start` property).\
|
|
7
8
|
* Impl to finalize when backend is ready
|
|
8
9
|
*/
|
|
9
|
-
export declare function listOperations(partyId: string, page: Pagination): Promise<[Operation[], string]>;
|
|
10
|
+
export declare function listOperations(currency: CryptoCurrency, partyId: string, page: Pagination): Promise<[Operation[], string]>;
|
|
10
11
|
//# sourceMappingURL=listOperations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC,CA6BhC"}
|
|
@@ -9,8 +9,8 @@ const gateway_1 = require("../../network/gateway");
|
|
|
9
9
|
* @returns Operations found and the next "id" or "index" to use for pagination (i.e. `start` property).\
|
|
10
10
|
* Impl to finalize when backend is ready
|
|
11
11
|
*/
|
|
12
|
-
async function listOperations(partyId, page) {
|
|
13
|
-
const { operations, next } = await (0, gateway_1.getOperations)(partyId, {
|
|
12
|
+
async function listOperations(currency, partyId, page) {
|
|
13
|
+
const { operations, next } = await (0, gateway_1.getOperations)(currency, partyId, {
|
|
14
14
|
cursor: page.pagingToken !== undefined ? parseInt(page.pagingToken) : undefined,
|
|
15
15
|
minOffset: page.minHeight,
|
|
16
16
|
limit: page.limit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.js","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":";;AAWA,
|
|
1
|
+
{"version":3,"file":"listOperations.js","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":";;AAWA,wCAiCC;AA3CD,mDAAsD;AAGtD;;;;;;GAMG;AACI,KAAK,UAAU,cAAc,CAClC,QAAwB,EACxB,OAAe,EACf,IAAgB;IAEhB,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,IAA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AC1B,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
export declare function broadcast(currency: CryptoCurrency, signedTx: string): Promise<string>;
|
|
2
3
|
//# sourceMappingURL=broadcast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/broadcast.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/broadcast.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKnE,wBAAsB,SAAS,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM3F"}
|
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.broadcast = broadcast;
|
|
7
7
|
const config_1 = __importDefault(require("../../config"));
|
|
8
8
|
const gateway_1 = require("../../network/gateway");
|
|
9
|
-
const useGateway = () => config_1.default.getCoinConfig().useGateway === true;
|
|
10
|
-
async function broadcast(signedTx) {
|
|
9
|
+
const useGateway = (currency) => config_1.default.getCoinConfig(currency).useGateway === true;
|
|
10
|
+
async function broadcast(currency, signedTx) {
|
|
11
11
|
const parsed = JSON.parse(signedTx);
|
|
12
12
|
const [sig, party] = parsed.signature.split("__PARTY__");
|
|
13
|
-
if (useGateway())
|
|
14
|
-
return (await (0, gateway_1.submit)(party, parsed.serialized, sig)).update_id;
|
|
13
|
+
if (useGateway(currency))
|
|
14
|
+
return (await (0, gateway_1.submit)(currency, party, parsed.serialized, sig)).update_id;
|
|
15
15
|
else
|
|
16
16
|
throw new Error("Not implemented");
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/broadcast.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/broadcast.ts"],"names":[],"mappings":";;;;;AAOA,8BAMC;AAbD,0DAAsC;AACtC,mDAA+C;AAG/C,MAAM,UAAU,GAAG,CAAC,QAAwB,EAAE,EAAE,CAC9C,gBAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC;AAElD,KAAK,UAAU,SAAS,CAAC,QAAwB,EAAE,QAAgB;IACxE,MAAM,MAAM,GAA8C,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/E,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACzD,IAAI,UAAU,CAAC,QAAQ,CAAC;QACtB,OAAO,CAAC,MAAM,IAAA,gBAAM,EAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;;QACtE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -43,6 +43,9 @@ const mockSerialized = JSON.stringify({
|
|
|
43
43
|
serialized: "serialized-tx",
|
|
44
44
|
signature: "signature__PARTY__alice:123",
|
|
45
45
|
});
|
|
46
|
+
const mockCurrency = {
|
|
47
|
+
id: "canton_network",
|
|
48
|
+
};
|
|
46
49
|
describe("broadcast", () => {
|
|
47
50
|
const mockGetCoinConfig = jest.spyOn(coinConfigModule.default, "getCoinConfig");
|
|
48
51
|
afterEach(() => {
|
|
@@ -53,15 +56,15 @@ describe("broadcast", () => {
|
|
|
53
56
|
useGateway: true,
|
|
54
57
|
});
|
|
55
58
|
gateway_1.submit.mockResolvedValue({ update_id: "my-update-id" });
|
|
56
|
-
const result = await (0, broadcast_1.broadcast)(mockSerialized);
|
|
57
|
-
expect(gateway_1.submit).toHaveBeenCalledWith("alice:123", "serialized-tx", "signature");
|
|
59
|
+
const result = await (0, broadcast_1.broadcast)(mockCurrency, mockSerialized);
|
|
60
|
+
expect(gateway_1.submit).toHaveBeenCalledWith(mockCurrency, "alice:123", "serialized-tx", "signature");
|
|
58
61
|
expect(result).toEqual("my-update-id");
|
|
59
62
|
});
|
|
60
63
|
it("should throw an error when useGateway is false (not implemented with node)", async () => {
|
|
61
64
|
mockGetCoinConfig.mockReturnValue({
|
|
62
65
|
useGateway: false,
|
|
63
66
|
});
|
|
64
|
-
await expect((0, broadcast_1.broadcast)(mockSerialized)).rejects.toThrow("Not implemented");
|
|
67
|
+
await expect((0, broadcast_1.broadcast)(mockCurrency, mockSerialized)).rejects.toThrow("Not implemented");
|
|
65
68
|
expect(gateway_1.submit).not.toHaveBeenCalled();
|
|
66
69
|
});
|
|
67
70
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.test.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/broadcast.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA+C;AAC/C,+DAAiD;AACjD,2CAAwC;
|
|
1
|
+
{"version":3,"file":"broadcast.test.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/broadcast.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA+C;AAC/C,+DAAiD;AACjD,2CAAwC;AAGxC,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE,CAAC,CAAC;IACxC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;CAClB,CAAC,CAAC,CAAC;AAEJ,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC;IACpC,UAAU,EAAE,eAAe;IAC3B,SAAS,EAAE,6BAA6B;CACzC,CAAC,CAAC;AAEH,M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
|
3
|
-
|
|
3
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
|
+
export declare function craftTransaction(currency: CryptoCurrency, account: {
|
|
4
5
|
address: string;
|
|
5
6
|
nextSequenceNumber?: number;
|
|
6
7
|
publicKey?: string;
|
|
@@ -9,6 +10,7 @@ export declare function craftTransaction(account: {
|
|
|
9
10
|
amount: BigNumber;
|
|
10
11
|
tokenId: string;
|
|
11
12
|
expireInSeconds: number;
|
|
13
|
+
memo?: string;
|
|
12
14
|
}): Promise<{
|
|
13
15
|
nativeTransaction: PrepareTransferResponse;
|
|
14
16
|
serializedTransaction: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"craftTransaction.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/craftTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"craftTransaction.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/craftTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAGL,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,EACD,WAAW,EAAE;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACA,OAAO,CAAC;IACT,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C,qBAAqB,EAAE,MAAM,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAwBD"}
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.craftTransaction = craftTransaction;
|
|
4
4
|
const gateway_1 = require("../../network/gateway");
|
|
5
|
-
async function craftTransaction(account, transaction) {
|
|
6
|
-
const
|
|
5
|
+
async function craftTransaction(currency, account, transaction) {
|
|
6
|
+
const params = {
|
|
7
7
|
recipient: transaction.recipient || "",
|
|
8
|
-
amount: transaction.amount.
|
|
8
|
+
amount: transaction.amount.toString(),
|
|
9
9
|
type: "token-transfer-request",
|
|
10
10
|
execute_before_secs: transaction.expireInSeconds,
|
|
11
11
|
instrument_id: transaction.tokenId,
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
|
+
if (transaction.memo) {
|
|
14
|
+
params.reason = transaction.memo;
|
|
15
|
+
}
|
|
16
|
+
const { serialized, json, hash } = await (0, gateway_1.prepareTransferRequest)(currency, account.address, params);
|
|
13
17
|
return {
|
|
14
18
|
nativeTransaction: json,
|
|
15
19
|
serializedTransaction: serialized,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"craftTransaction.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/craftTransaction.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"craftTransaction.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/craftTransaction.ts"],"names":[],"mappings":";;AAQA,4CA0CC;AAjDD,mDAI+B;AAGxB,KAAK,UAAU,gBAAgB,CACpC,QAAwB,EACxB,OAIC,EACD,WAMC;IAMD,MAAM,MAAM,GAA2B;QACrC,SAAS,EAAE,WAAW,CAAC,SAAS,IAAI,EAAE;QACtC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrC,IAAI,EAAE,wBAAiC;QACvC,mBAAmB,EAAE,WAAW,CAAC,eAAe;QAChD,aAAa,EAAE,WAAW,CAAC,OAAO;KACnC,CAAC;IAEF,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;QACrB,MAAM,CAAC,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC;IACnC,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,gCAAsB,EAC7D,QAAQ,EACR,OAAO,CAAC,OAAO,EACf,MAAM,CACP,CAAC;IAEF,OAAO;QACL,iBAAiB,EAAE,IAAI;QACvB,qBAAqB,EAAE,UAAU;QACjC,IAAI;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
|
+
export declare function estimateFees(currency: CryptoCurrency): Promise<bigint>;
|
|
2
3
|
//# sourceMappingURL=estimateFees.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateFees.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"estimateFees.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,wBAAsB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAE5E"}
|
|
@@ -5,9 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.estimateFees = estimateFees;
|
|
7
7
|
const config_1 = __importDefault(require("../../config"));
|
|
8
|
-
const feeValue = () => config_1.default.getCoinConfig().fee ??
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return Promise.resolve(BigInt(feeValue())); // TODO replace with real implementation
|
|
8
|
+
const feeValue = (currency) => config_1.default.getCoinConfig(currency).fee ?? 1;
|
|
9
|
+
async function estimateFees(currency) {
|
|
10
|
+
return Promise.resolve(BigInt(feeValue(currency)));
|
|
12
11
|
}
|
|
13
12
|
//# sourceMappingURL=estimateFees.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateFees.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":";;;;;AAKA,oCAEC;AAPD,0DAAsC;
|
|
1
|
+
{"version":3,"file":"estimateFees.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":";;;;;AAKA,oCAEC;AAPD,0DAAsC;AAGtC,MAAM,QAAQ,GAAG,CAAC,QAAwB,EAAE,EAAE,CAAC,gBAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAEpF,KAAK,UAAU,YAAY,CAAC,QAAwB;IACzD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
package/lib/network/gateway.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PrepareTransactionResponse, PreApprovalResult } from "../types/onboard";
|
|
2
|
+
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
3
|
type OnboardingPrepareResponse = {
|
|
3
4
|
party_id: string;
|
|
4
5
|
party_name: string;
|
|
@@ -33,7 +34,7 @@ export type PrepareTransferResponse = {
|
|
|
33
34
|
};
|
|
34
35
|
export type PrepareTransferRequest = {
|
|
35
36
|
type: "token-transfer-request";
|
|
36
|
-
amount:
|
|
37
|
+
amount: string;
|
|
37
38
|
recipient: string;
|
|
38
39
|
execute_before_secs: number;
|
|
39
40
|
instrument_id: string;
|
|
@@ -118,6 +119,9 @@ export type OperationInfo = {
|
|
|
118
119
|
asset: string;
|
|
119
120
|
details: {
|
|
120
121
|
type: "pre-approval";
|
|
122
|
+
metadata: {
|
|
123
|
+
reason?: string;
|
|
124
|
+
};
|
|
121
125
|
};
|
|
122
126
|
}
|
|
123
127
|
];
|
|
@@ -159,6 +163,9 @@ export type OperationInfo = {
|
|
|
159
163
|
asset: string;
|
|
160
164
|
details: {
|
|
161
165
|
type: "tap";
|
|
166
|
+
metadata: {
|
|
167
|
+
reason?: string;
|
|
168
|
+
};
|
|
162
169
|
};
|
|
163
170
|
}
|
|
164
171
|
];
|
|
@@ -200,6 +207,9 @@ export type OperationInfo = {
|
|
|
200
207
|
asset: string;
|
|
201
208
|
details: {
|
|
202
209
|
type: "transfer";
|
|
210
|
+
metadata: {
|
|
211
|
+
reason?: string;
|
|
212
|
+
};
|
|
203
213
|
};
|
|
204
214
|
}
|
|
205
215
|
];
|
|
@@ -226,13 +236,13 @@ export type OperationInfo = {
|
|
|
226
236
|
type: "transfer";
|
|
227
237
|
};
|
|
228
238
|
};
|
|
229
|
-
export declare function prepareOnboarding(pubKey: string, pubKeyType: string): Promise<OnboardingPrepareResponse>;
|
|
230
|
-
export declare function submitOnboarding(prepareRequest: OnboardingPrepareRequest, prepareResponse: OnboardingPrepareResponse, signature: string): Promise<OnboardingSubmitResponse>;
|
|
231
|
-
export declare function submit(partyId: string, serialized: string, signature: string): Promise<TransactionSubmitResponse>;
|
|
232
|
-
export declare function getBalance(partyId: string): Promise<InstrumentBalance[]>;
|
|
233
|
-
export declare function getPartyById(partyId: string): Promise<PartyInfo>;
|
|
234
|
-
export declare function getPartyByPubKey(pubKey: string): Promise<PartyInfo>;
|
|
235
|
-
export declare function getOperations(partyId: string, options?: {
|
|
239
|
+
export declare function prepareOnboarding(currency: CryptoCurrency, pubKey: string, pubKeyType: string): Promise<OnboardingPrepareResponse>;
|
|
240
|
+
export declare function submitOnboarding(currency: CryptoCurrency, prepareRequest: OnboardingPrepareRequest, prepareResponse: OnboardingPrepareResponse, signature: string): Promise<OnboardingSubmitResponse>;
|
|
241
|
+
export declare function submit(currency: CryptoCurrency, partyId: string, serialized: string, signature: string): Promise<TransactionSubmitResponse>;
|
|
242
|
+
export declare function getBalance(currency: CryptoCurrency, partyId: string): Promise<InstrumentBalance[]>;
|
|
243
|
+
export declare function getPartyById(currency: CryptoCurrency, partyId: string): Promise<PartyInfo>;
|
|
244
|
+
export declare function getPartyByPubKey(currency: CryptoCurrency, pubKey: string): Promise<PartyInfo>;
|
|
245
|
+
export declare function getOperations(currency: CryptoCurrency, partyId: string, options?: {
|
|
236
246
|
cursor?: number | undefined;
|
|
237
247
|
minOffset?: number | undefined;
|
|
238
248
|
maxOffset?: number | undefined;
|
|
@@ -250,7 +260,7 @@ type PrepareTapResponse = {
|
|
|
250
260
|
json: null;
|
|
251
261
|
hash: string;
|
|
252
262
|
};
|
|
253
|
-
export declare function prepareTapRequest({ partyId, amount
|
|
263
|
+
export declare function prepareTapRequest(currency: CryptoCurrency, { partyId, amount }: PrepareTapRequest): Promise<PrepareTapResponse>;
|
|
254
264
|
type SubmitTapRequestRequest = {
|
|
255
265
|
partyId: string;
|
|
256
266
|
serialized: string;
|
|
@@ -260,10 +270,10 @@ type SubmitTapRequestResponse = {
|
|
|
260
270
|
submission_id: string;
|
|
261
271
|
update_id: string;
|
|
262
272
|
};
|
|
263
|
-
export declare function submitTapRequest({ partyId, serialized, signature
|
|
264
|
-
export declare function prepareTransferRequest(partyId: string, params: PrepareTransferRequest): Promise<PrepareTransferResponse>;
|
|
265
|
-
export declare function getLedgerEnd(): Promise<number>;
|
|
266
|
-
export declare function preparePreApprovalTransaction(partyId: string): Promise<PrepareTransactionResponse>;
|
|
267
|
-
export declare function submitPreApprovalTransaction(partyId: string, { serialized }: PrepareTransactionResponse, signature: string): Promise<PreApprovalResult>;
|
|
273
|
+
export declare function submitTapRequest(currency: CryptoCurrency, { partyId, serialized, signature }: SubmitTapRequestRequest): Promise<SubmitTapRequestResponse>;
|
|
274
|
+
export declare function prepareTransferRequest(currency: CryptoCurrency, partyId: string, params: PrepareTransferRequest): Promise<PrepareTransferResponse>;
|
|
275
|
+
export declare function getLedgerEnd(currency: CryptoCurrency): Promise<number>;
|
|
276
|
+
export declare function preparePreApprovalTransaction(currency: CryptoCurrency, partyId: string): Promise<PrepareTransactionResponse>;
|
|
277
|
+
export declare function submitPreApprovalTransaction(currency: CryptoCurrency, partyId: string, { serialized }: PrepareTransactionResponse, signature: string): Promise<PreApprovalResult>;
|
|
268
278
|
export {};
|
|
269
279
|
//# sourceMappingURL=gateway.d.ts.map
|