@ledgerhq/coin-cardano 0.13.0-nightly.5 → 0.13.0-nightly.7
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 +20 -0
- package/package.json +7 -7
- package/lib/address.unit.test.d.ts +0 -2
- package/lib/address.unit.test.d.ts.map +0 -1
- package/lib/address.unit.test.js +0 -21
- package/lib/address.unit.test.js.map +0 -1
- package/lib/bridge.integration.test.d.ts +0 -4
- package/lib/bridge.integration.test.d.ts.map +0 -1
- package/lib/bridge.integration.test.js +0 -120
- package/lib/bridge.integration.test.js.map +0 -1
- package/lib/buildTransaction.test.d.ts +0 -2
- package/lib/buildTransaction.test.d.ts.map +0 -1
- package/lib/buildTransaction.test.js +0 -172
- package/lib/buildTransaction.test.js.map +0 -1
- package/lib/getTransactionStatus/getTransactionStatus.test.d.ts +0 -2
- package/lib/getTransactionStatus/getTransactionStatus.test.d.ts.map +0 -1
- package/lib/getTransactionStatus/getTransactionStatus.test.js +0 -149
- package/lib/getTransactionStatus/getTransactionStatus.test.js.map +0 -1
- package/lib/getTransactionStatus/handler.test.d.ts +0 -2
- package/lib/getTransactionStatus/handler.test.d.ts.map +0 -1
- package/lib/getTransactionStatus/handler.test.js +0 -51
- package/lib/getTransactionStatus/handler.test.js.map +0 -1
- package/lib/logic.unit.test.d.ts +0 -2
- package/lib/logic.unit.test.d.ts.map +0 -1
- package/lib/logic.unit.test.js +0 -55
- package/lib/logic.unit.test.js.map +0 -1
- package/lib/synchronisation.unit.test.d.ts +0 -2
- package/lib/synchronisation.unit.test.d.ts.map +0 -1
- package/lib/synchronisation.unit.test.js +0 -150
- package/lib/synchronisation.unit.test.js.map +0 -1
- package/lib-es/address.unit.test.d.ts +0 -2
- package/lib-es/address.unit.test.d.ts.map +0 -1
- package/lib-es/address.unit.test.js +0 -19
- package/lib-es/address.unit.test.js.map +0 -1
- package/lib-es/bridge.integration.test.d.ts +0 -4
- package/lib-es/bridge.integration.test.d.ts.map +0 -1
- package/lib-es/bridge.integration.test.js +0 -114
- package/lib-es/bridge.integration.test.js.map +0 -1
- package/lib-es/buildTransaction.test.d.ts +0 -2
- package/lib-es/buildTransaction.test.d.ts.map +0 -1
- package/lib-es/buildTransaction.test.js +0 -167
- package/lib-es/buildTransaction.test.js.map +0 -1
- package/lib-es/getTransactionStatus/getTransactionStatus.test.d.ts +0 -2
- package/lib-es/getTransactionStatus/getTransactionStatus.test.d.ts.map +0 -1
- package/lib-es/getTransactionStatus/getTransactionStatus.test.js +0 -121
- package/lib-es/getTransactionStatus/getTransactionStatus.test.js.map +0 -1
- package/lib-es/getTransactionStatus/handler.test.d.ts +0 -2
- package/lib-es/getTransactionStatus/handler.test.d.ts.map +0 -1
- package/lib-es/getTransactionStatus/handler.test.js +0 -26
- package/lib-es/getTransactionStatus/handler.test.js.map +0 -1
- package/lib-es/logic.unit.test.d.ts +0 -2
- package/lib-es/logic.unit.test.d.ts.map +0 -1
- package/lib-es/logic.unit.test.js +0 -50
- package/lib-es/logic.unit.test.js.map +0 -1
- package/lib-es/synchronisation.unit.test.d.ts +0 -2
- package/lib-es/synchronisation.unit.test.d.ts.map +0 -1
- package/lib-es/synchronisation.unit.test.js +0 -145
- package/lib-es/synchronisation.unit.test.js.map +0 -1
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint @typescript-eslint/consistent-type-assertions: 0 */
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
const delegate = __importStar(require("./delegate"));
|
|
28
|
-
const send = __importStar(require("./send"));
|
|
29
|
-
const handler_1 = require("./handler");
|
|
30
|
-
const undelegate = __importStar(require("./undelegate"));
|
|
31
|
-
jest.mock("./delegate");
|
|
32
|
-
jest.mock("./send");
|
|
33
|
-
jest.mock("./undelegate");
|
|
34
|
-
describe("getTransactionStatusByMode on Cardano", () => {
|
|
35
|
-
const sendMock = send.getSendTransactionStatus;
|
|
36
|
-
const delegateMock = delegate.getDelegateTransactionStatus;
|
|
37
|
-
const undelegateMock = undelegate.getUndelegateTransactionStatus;
|
|
38
|
-
describe("should redirect to the correct mode handler", () => {
|
|
39
|
-
test.each([
|
|
40
|
-
["send", sendMock],
|
|
41
|
-
["delegate", delegateMock],
|
|
42
|
-
["undelegate", undelegateMock],
|
|
43
|
-
])("for %s", async (mode, mock) => {
|
|
44
|
-
const account = {};
|
|
45
|
-
const transaction = { mode: mode };
|
|
46
|
-
await (0, handler_1.getTransactionStatusByTransactionMode)(account, transaction);
|
|
47
|
-
expect(mock).toHaveBeenCalledWith(account, transaction);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=handler.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.test.js","sourceRoot":"","sources":["../../src/getTransactionStatus/handler.test.ts"],"names":[],"mappings":";AAAA,6DAA6D;;;;;;;;;;;;;;;;;;;;;;;;;AAE7D,qDAAuC;AACvC,6CAA+B;AAC/B,uCAAkE;AAClE,yDAA2C;AAG3C,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACxB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACpB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAE1B,QAAQ,CAAC,uCAAuC,EAAE,GAAG,EAAE;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,wBAAqC,CAAC;IAC5D,MAAM,YAAY,GAAG,QAAQ,CAAC,4BAAyC,CAAC;IACxE,MAAM,cAAc,GAAG,UAAU,CAAC,8BAA2C,CAAC;IAE9E,QAAQ,CAAC,6CAA6C,EAAE,GAAG,EAAE;QAC3D,IAAI,CAAC,IAAI,CAAC;YACR,CAAC,MAAM,EAAE,QAAQ,CAAC;YAClB,CAAC,UAAU,EAAE,YAAY,CAAC;YAC1B,CAAC,YAAY,EAAE,cAAc,CAAC;SAC/B,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;YAChC,MAAM,OAAO,GAAG,EAA+B,CAAC;YAChD,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,IAAI,EAA4B,CAAC;YAE7D,MAAM,IAAA,+CAAqC,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAElE,MAAM,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/logic.unit.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic.unit.test.d.ts","sourceRoot":"","sources":["../src/logic.unit.test.ts"],"names":[],"mappings":""}
|
package/lib/logic.unit.test.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
7
|
-
const logic_1 = require("./logic");
|
|
8
|
-
describe("canStake", () => {
|
|
9
|
-
it("should return false when acc has no funds", () => {
|
|
10
|
-
const accWithNoFunds = {
|
|
11
|
-
balance: new bignumber_js_1.default(0),
|
|
12
|
-
};
|
|
13
|
-
expect((0, logic_1.canStake)(accWithNoFunds)).toEqual(false);
|
|
14
|
-
});
|
|
15
|
-
it("should return true when acc has funds", () => {
|
|
16
|
-
const accWithFunds = {
|
|
17
|
-
balance: new bignumber_js_1.default(1),
|
|
18
|
-
};
|
|
19
|
-
expect((0, logic_1.canStake)(accWithFunds)).toEqual(true);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
describe("isAlreadyStaking", () => {
|
|
23
|
-
it("should return false when acc isn't delegating", () => {
|
|
24
|
-
const noResourcesAcc = {};
|
|
25
|
-
expect((0, logic_1.isAlreadyStaking)(noResourcesAcc)).toEqual(false);
|
|
26
|
-
const noDelegationAcc = {
|
|
27
|
-
cardanoResources: {},
|
|
28
|
-
};
|
|
29
|
-
expect((0, logic_1.isAlreadyStaking)(noDelegationAcc)).toEqual(false);
|
|
30
|
-
const noPoolIdAcc = { cardanoResources: { delegation: {} } };
|
|
31
|
-
expect((0, logic_1.isAlreadyStaking)(noPoolIdAcc)).toEqual(false);
|
|
32
|
-
});
|
|
33
|
-
it("should return true when acc is delegating", () => {
|
|
34
|
-
const noResourcesAcc = {
|
|
35
|
-
cardanoResources: { delegation: { poolId: "itspoolid" } },
|
|
36
|
-
};
|
|
37
|
-
expect((0, logic_1.isAlreadyStaking)(noResourcesAcc)).toEqual(true);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe("isValidNumString", () => {
|
|
41
|
-
it("should return false for invalid number", () => {
|
|
42
|
-
expect((0, logic_1.isValidNumString)("")).toEqual(false);
|
|
43
|
-
expect((0, logic_1.isValidNumString)(undefined)).toEqual(false);
|
|
44
|
-
expect((0, logic_1.isValidNumString)(null)).toEqual(false);
|
|
45
|
-
expect((0, logic_1.isValidNumString)({})).toEqual(false);
|
|
46
|
-
expect((0, logic_1.isValidNumString)([])).toEqual(false);
|
|
47
|
-
});
|
|
48
|
-
it("should return true for valid number", () => {
|
|
49
|
-
expect((0, logic_1.isValidNumString)(123)).toEqual(true);
|
|
50
|
-
expect((0, logic_1.isValidNumString)(123.321)).toEqual(true);
|
|
51
|
-
expect((0, logic_1.isValidNumString)("123")).toEqual(true);
|
|
52
|
-
expect((0, logic_1.isValidNumString)("123.321")).toEqual(true);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
//# sourceMappingURL=logic.unit.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic.unit.test.js","sourceRoot":"","sources":["../src/logic.unit.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AACrC,mCAAuE;AAGvE,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,cAAc,GAAG;YACrB,OAAO,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC;SACR,CAAC;QACpB,MAAM,CAAC,IAAA,gBAAQ,EAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,YA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,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,CAAC,IAAA,wBAAgB,EAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnD,MAAM,CAAC,IAAA,wBAAgB,EAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,CAAC,IAAA,wBAAgB,EAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,CAAC,IAAA,wBAAgB,EAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAC,IAAA,wBAAgB,EAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,CAAC,IAAA,wBAAgB,EAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,CAAC,IAAA,wBAAgB,EAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,CAAC,IAAA,wBAAgB,EAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"synchronisation.unit.test.d.ts","sourceRoot":"","sources":["../src/synchronisation.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
7
|
-
const getDelegationInfo_1 = require("./api/getDelegationInfo");
|
|
8
|
-
const synchronisation_1 = require("./synchronisation");
|
|
9
|
-
const getTransactions_1 = require("./api/getTransactions");
|
|
10
|
-
const buildSubAccounts_1 = require("./buildSubAccounts");
|
|
11
|
-
const getNetworkInfo_1 = require("./api/getNetworkInfo");
|
|
12
|
-
jest.mock("./buildSubAccounts");
|
|
13
|
-
jest.mock("./api/getTransactions");
|
|
14
|
-
jest.mock("./api/getNetworkInfo");
|
|
15
|
-
jest.mock("./api/getDelegationInfo");
|
|
16
|
-
describe("makeGetAccountShape", () => {
|
|
17
|
-
let signerContext;
|
|
18
|
-
let shape;
|
|
19
|
-
let accountShapeInfo;
|
|
20
|
-
let getTransactionsMock;
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
const pubKeyMock = {
|
|
23
|
-
chainCodeHex: "chainCodeHex",
|
|
24
|
-
publicKeyHex: "publicKeyHex",
|
|
25
|
-
};
|
|
26
|
-
const fakeSigner = {
|
|
27
|
-
getAddress: jest.fn(),
|
|
28
|
-
sign: jest.fn(),
|
|
29
|
-
getPublicKey: jest.fn().mockResolvedValue(pubKeyMock),
|
|
30
|
-
};
|
|
31
|
-
signerContext = (_, fn) => fn(fakeSigner);
|
|
32
|
-
shape = (0, synchronisation_1.makeGetAccountShape)(signerContext);
|
|
33
|
-
accountShapeInfo = {
|
|
34
|
-
currency: { id: "cardano" },
|
|
35
|
-
address: "add",
|
|
36
|
-
index: 0,
|
|
37
|
-
initialAccount: {
|
|
38
|
-
cardanoResources: {
|
|
39
|
-
utxos: [
|
|
40
|
-
{
|
|
41
|
-
hash: "hash",
|
|
42
|
-
index: 0,
|
|
43
|
-
address: "addr",
|
|
44
|
-
amount: new bignumber_js_1.default(1),
|
|
45
|
-
tokens: [],
|
|
46
|
-
paymentCredential: {
|
|
47
|
-
key: "key",
|
|
48
|
-
path: {
|
|
49
|
-
purpose: 1852,
|
|
50
|
-
coin: 1815,
|
|
51
|
-
account: 0,
|
|
52
|
-
chain: 0,
|
|
53
|
-
index: 0,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
derivationPath: "",
|
|
61
|
-
derivationMode: "cardano",
|
|
62
|
-
deviceId: "id",
|
|
63
|
-
};
|
|
64
|
-
const buildSubAccountsMock = jest.mocked(buildSubAccounts_1.buildSubAccounts);
|
|
65
|
-
buildSubAccountsMock.mockReturnValue([]);
|
|
66
|
-
getTransactionsMock = jest.mocked(getTransactions_1.getTransactions);
|
|
67
|
-
const getNetworkInfoMock = jest.mocked(getNetworkInfo_1.fetchNetworkInfo);
|
|
68
|
-
getNetworkInfoMock.mockReturnValue(Promise.resolve({ protocolParams: { lovelacePerUtxoWord: "1" } }));
|
|
69
|
-
});
|
|
70
|
-
afterEach(() => {
|
|
71
|
-
jest.resetAllMocks();
|
|
72
|
-
});
|
|
73
|
-
describe("balance", () => {
|
|
74
|
-
it("should return 0 balance when there is no utxos", async () => {
|
|
75
|
-
getTransactionsMock.mockReturnValue(Promise.resolve({
|
|
76
|
-
transactions: [],
|
|
77
|
-
externalCredentials: [
|
|
78
|
-
{ path: { index: 0 }, networkId: "id", isUsed: false, key: "" },
|
|
79
|
-
],
|
|
80
|
-
internalCredentials: [],
|
|
81
|
-
blockHeight: 0,
|
|
82
|
-
}));
|
|
83
|
-
const result = await shape(accountShapeInfo, { paginationConfig: {} });
|
|
84
|
-
expect(result.balance).toEqual(new bignumber_js_1.default(0));
|
|
85
|
-
});
|
|
86
|
-
it("should return the sum of utxos with delegation reward value", async () => {
|
|
87
|
-
getTransactionsMock.mockReturnValue(Promise.resolve({
|
|
88
|
-
transactions: [],
|
|
89
|
-
externalCredentials: [
|
|
90
|
-
{ path: { index: 0 }, networkId: "id", isUsed: false, key: "" },
|
|
91
|
-
],
|
|
92
|
-
internalCredentials: [
|
|
93
|
-
{
|
|
94
|
-
isUsed: true,
|
|
95
|
-
key: "cred",
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
blockHeight: 0,
|
|
99
|
-
}));
|
|
100
|
-
const getDelegationInfoMock = jest.mocked(getDelegationInfo_1.getDelegationInfo);
|
|
101
|
-
getDelegationInfoMock.mockReturnValue(Promise.resolve({ rewards: new bignumber_js_1.default(42) }));
|
|
102
|
-
const result = await shape(accountShapeInfo, { paginationConfig: {} });
|
|
103
|
-
expect(result.balance).toEqual(new bignumber_js_1.default(42));
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
describe("spendableBalance", () => {
|
|
107
|
-
it("should return 0 spendable balance when there is no utxos", async () => {
|
|
108
|
-
const getTransactionsMock = jest.mocked(getTransactions_1.getTransactions);
|
|
109
|
-
getTransactionsMock.mockReturnValue(Promise.resolve({
|
|
110
|
-
transactions: [],
|
|
111
|
-
externalCredentials: [
|
|
112
|
-
{
|
|
113
|
-
isUsed: false,
|
|
114
|
-
key: "00000000000000000000000000000000000000000000000000000000",
|
|
115
|
-
path: {
|
|
116
|
-
purpose: 1852,
|
|
117
|
-
coin: 1815,
|
|
118
|
-
account: 0,
|
|
119
|
-
chain: 0,
|
|
120
|
-
index: 0,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
internalCredentials: [],
|
|
125
|
-
}));
|
|
126
|
-
const result = await shape(accountShapeInfo, { paginationConfig: {} });
|
|
127
|
-
expect(result.spendableBalance).toEqual(new bignumber_js_1.default(0));
|
|
128
|
-
});
|
|
129
|
-
// it("should return the sum of utxos minus ada minimum for tokens", async () => {});
|
|
130
|
-
});
|
|
131
|
-
describe("delegation", () => {
|
|
132
|
-
it("should check dRepHex and rewards are available", async () => {
|
|
133
|
-
getTransactionsMock.mockReturnValue(Promise.resolve({
|
|
134
|
-
blockHeight: 0,
|
|
135
|
-
transactions: [],
|
|
136
|
-
externalCredentials: [{ isUsed: false, key: "0", path: {} }],
|
|
137
|
-
internalCredentials: [],
|
|
138
|
-
}));
|
|
139
|
-
const getDelegationInfoMock = jest.mocked(getDelegationInfo_1.getDelegationInfo);
|
|
140
|
-
getDelegationInfoMock.mockReturnValue(Promise.resolve({
|
|
141
|
-
rewards: new bignumber_js_1.default(10),
|
|
142
|
-
dRepHex: "dRepHex",
|
|
143
|
-
}));
|
|
144
|
-
const result = await shape(accountShapeInfo, { paginationConfig: {} });
|
|
145
|
-
expect(result.cardanoResources?.delegation?.dRepHex).toEqual("dRepHex");
|
|
146
|
-
expect(result.cardanoResources?.delegation?.rewards).toEqual(new bignumber_js_1.default(10));
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
//# sourceMappingURL=synchronisation.unit.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"synchronisation.unit.test.js","sourceRoot":"","sources":["../src/synchronisation.unit.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AAIrC,+DAA4D;AAC5D,uDAAwD;AACxD,2DAAwD;AACxD,yDAAsD;AACtD,yDAAwD;AAIxD,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAChC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACnC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAClC,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AAErC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,IAAI,aAA2C,CAAC;IAChD,IAAI,KAAsC,CAAC;IAC3C,IAAI,gBAAkD,CAAC;IACvD,IAAI,mBAAiE,CAAC;IAEtE,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,UAAU,GAAG;YACjB,YAAY,EAAE,cAAc;YAC5B,YAAY,EAAE,cAAc;SAC7B,CAAC;QACF,MAAM,UAAU,GAAkB;YAChC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;YACrB,IAAI,EAAE,IAAI,CAAC,EAA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,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;YAC9D,mBAAmB,CAAC,eAAe,CACjC,OAAO,CAAC,OAAO,CAAC;gBACd,WAAW,EAAE,CAAC;gBACd,YAAY,EAAE,EAAE;gBAChB,mBAAmB,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAuB,CAAC;gBACjF,mBAAmB,EAAE,EAAE;aACxB,CAAC,CACH,CAAC;YACF,MAAM,qBAAqB,GAAG,IAAI,CAAC,MAAM,CAAC,qCAAiB,CAAC,CAAC;YAC7D,qBAAqB,CAAC,eAAe,CACnC,OAAO,CAAC,OAAO,CAAC;gBACd,OAAO,EAAE,IAAI,sBAAS,CAAC,EAAE,CAAC;gBAC1B,OAAO,EAAE,SAAS;aACE,CAAC,CACxB,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;YACvE,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACxE,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,sBAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"address.unit.test.d.ts","sourceRoot":"","sources":["../src/address.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isValidAddress } from "./logic";
|
|
2
|
-
import { NetworkId } from "./types";
|
|
3
|
-
describe("address validation", () => {
|
|
4
|
-
it("should check for invalid address", () => {
|
|
5
|
-
const isValid = isValidAddress("bnb136ns6lfw4zs5hg4n85vdthaad7hq5m4gtkgf23", NetworkId.mainnet);
|
|
6
|
-
expect(isValid).toEqual(false);
|
|
7
|
-
});
|
|
8
|
-
it("should check for valid byron address", () => {
|
|
9
|
-
const isValidByronAddress1 = isValidAddress("Ae2tdPwUPEZFBgKrLT9pn8JPJVbefcL4kuznpQxQpxKfTVuHJ9gLAmxKk4w", NetworkId.mainnet);
|
|
10
|
-
expect(isValidByronAddress1).toEqual(true);
|
|
11
|
-
const isValidByronAddress2 = isValidAddress("DdzFFzCqrhst6mdc3hmFeWu77FZdYNjV7tTGVtEBXQzE3iCqyZWn9SSWCBrjRbbhj94VHAyGU96khi8qGM1B29nGs1jZRZEWKg2MwbVb", NetworkId.mainnet);
|
|
12
|
-
expect(isValidByronAddress2).toEqual(true);
|
|
13
|
-
});
|
|
14
|
-
it("should check for valid shelley address", () => {
|
|
15
|
-
const isValidShelleyAddress = isValidAddress("addr1q8mgw8geggkl2hs0m6rq3pgt69uxttpqcgu6euxje5tt6plxjtjrnskhhtt03g6l3sr98p9t8mtlajr26vmwjzep77pqxn8cms", NetworkId.mainnet);
|
|
16
|
-
expect(isValidShelleyAddress).toEqual(true);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
//# sourceMappingURL=address.unit.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"address.unit.test.js","sourceRoot":"","sources":["../src/address.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,OAAO,GAAG,cAAc,CAAC,4CAA4C,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;QAChG,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,oBAAoB,GAAG,cAAc,CACzC,6DAA6D,EAC7D,SAAS,CAAC,OAAO,CAClB,CAAC;QACF,MAAM,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE3C,MAAM,oBAAoB,GAAG,cAAc,CACzC,0GAA0G,EAC1G,SAAS,CAAC,OAAO,CAClB,CAAC;QACF,MAAM,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,qBAAqB,GAAG,cAAc,CAC1C,yGAAyG,EACzG,SAAS,CAAC,OAAO,CAClB,CAAC;QAEF,MAAM,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.integration.test.d.ts","sourceRoot":"","sources":["../src/bridge.integration.test.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUxD,eAAO,MAAM,OAAO,EAAE,WAAW,CAAC,WAAW,CAkG5C,CAAC"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
|
-
import { cardanoRawAccount1 } from "./datasets/rawAccount.1";
|
|
3
|
-
import { cardanoScanAccounts } from "./datasets/scanAccounts";
|
|
4
|
-
import { CardanoInvalidPoolId, CardanoMinAmountError } from "./errors";
|
|
5
|
-
import { fromTransactionRaw } from "./transaction";
|
|
6
|
-
import { Buffer as OriginalBuffer } from "buffer";
|
|
7
|
-
// NOTE: overrides polyfill set here libs/ledger-live-common/jest.polyfills.js
|
|
8
|
-
Object.defineProperty(globalThis, "Buffer", {
|
|
9
|
-
value: OriginalBuffer,
|
|
10
|
-
writable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
});
|
|
13
|
-
export const dataset = {
|
|
14
|
-
implementations: ["js"],
|
|
15
|
-
currencies: {
|
|
16
|
-
cardano_testnet: {
|
|
17
|
-
scanAccounts: cardanoScanAccounts,
|
|
18
|
-
accounts: [
|
|
19
|
-
{
|
|
20
|
-
raw: cardanoRawAccount1,
|
|
21
|
-
transactions: [
|
|
22
|
-
{
|
|
23
|
-
name: "amount less then minimum",
|
|
24
|
-
transaction: fromTransactionRaw({
|
|
25
|
-
family: "cardano",
|
|
26
|
-
recipient: "addr_test1qpl90kc2jl5kr9tev0s7vays9yhwcdnq8nlylyk4dqsdq3g466elxnxwrzwq72pvp5akenj30t5s9et7frfvrxxx8xcsxrzs87",
|
|
27
|
-
amount: "0.1",
|
|
28
|
-
mode: "send",
|
|
29
|
-
poolId: undefined,
|
|
30
|
-
}),
|
|
31
|
-
expectedStatus: {
|
|
32
|
-
amount: new BigNumber("0.1"),
|
|
33
|
-
errors: {
|
|
34
|
-
amount: new CardanoMinAmountError(),
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
/* // FIXME broken test
|
|
39
|
-
{
|
|
40
|
-
name: "token amount more than balance",
|
|
41
|
-
transaction: fromTransactionRaw({
|
|
42
|
-
family: "cardano",
|
|
43
|
-
recipient:
|
|
44
|
-
"addr_test1qpl90kc2jl5kr9tev0s7vays9yhwcdnq8nlylyk4dqsdq3g466elxnxwrzwq72pvp5akenj30t5s9et7frfvrxxx8xcsxrzs87",
|
|
45
|
-
amount: "101",
|
|
46
|
-
subAccountId:
|
|
47
|
-
"js:2:cardano_testnet:806499588e0c4a58f4119f7e6e096bf42c3f774a528d2acec9e82ceebf87d1ceb3d4f3622dd2c77c65cc89c123f79337db22cf8a69f122e36dab1bf5083bf82d:cardano+cardano_testnet%2Fnative%2F47be64fcc8a7fe5321b976282ce4e43e4d29015f6613cfabcea28eab54657374",
|
|
48
|
-
mode: "send",
|
|
49
|
-
poolId: undefined,
|
|
50
|
-
}),
|
|
51
|
-
expectedStatus: {
|
|
52
|
-
amount: new BigNumber("101"),
|
|
53
|
-
errors: {
|
|
54
|
-
amount: new NotEnoughBalance(),
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: "send max token",
|
|
60
|
-
transaction: fromTransactionRaw({
|
|
61
|
-
family: "cardano",
|
|
62
|
-
recipient:
|
|
63
|
-
"addr_test1qpl90kc2jl5kr9tev0s7vays9yhwcdnq8nlylyk4dqsdq3g466elxnxwrzwq72pvp5akenj30t5s9et7frfvrxxx8xcsxrzs87",
|
|
64
|
-
amount: "0",
|
|
65
|
-
subAccountId:
|
|
66
|
-
"js:2:cardano_testnet:806499588e0c4a58f4119f7e6e096bf42c3f774a528d2acec9e82ceebf87d1ceb3d4f3622dd2c77c65cc89c123f79337db22cf8a69f122e36dab1bf5083bf82d:cardano+cardano_testnet%2Fnative%2F47be64fcc8a7fe5321b976282ce4e43e4d29015f6613cfabcea28eab54657374",
|
|
67
|
-
mode: "send",
|
|
68
|
-
useAllAmount: true,
|
|
69
|
-
poolId: undefined,
|
|
70
|
-
}),
|
|
71
|
-
expectedStatus: {
|
|
72
|
-
amount: new BigNumber("100"),
|
|
73
|
-
totalSpent: new BigNumber("100"),
|
|
74
|
-
errors: {},
|
|
75
|
-
warnings: {},
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
*/
|
|
79
|
-
{
|
|
80
|
-
name: "delegate to invalid poolId",
|
|
81
|
-
transaction: fromTransactionRaw({
|
|
82
|
-
family: "cardano",
|
|
83
|
-
recipient: "",
|
|
84
|
-
amount: "0",
|
|
85
|
-
mode: "delegate",
|
|
86
|
-
poolId: "efae72c07a26e4542ba55ef59d35ad45ffaaac312865e3a758ede",
|
|
87
|
-
}),
|
|
88
|
-
expectedStatus: {
|
|
89
|
-
errors: {
|
|
90
|
-
poolId: new CardanoInvalidPoolId(),
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: "delegate valid poolId",
|
|
96
|
-
transaction: fromTransactionRaw({
|
|
97
|
-
family: "cardano",
|
|
98
|
-
recipient: "",
|
|
99
|
-
amount: "0",
|
|
100
|
-
mode: "delegate",
|
|
101
|
-
poolId: "efae72c07a26e4542ba55ef59d35ad45ffaaac312865e3a758ede997",
|
|
102
|
-
}),
|
|
103
|
-
expectedStatus: {},
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
describe("Cardano bridge", () => {
|
|
112
|
-
test.todo("This is an empty test to make jest command pass. Remove it once there is a real test.");
|
|
113
|
-
});
|
|
114
|
-
//# sourceMappingURL=bridge.integration.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.integration.test.js","sourceRoot":"","sources":["../src/bridge.integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,QAAQ,CAAC;AAElD,8EAA8E;AAC9E,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,EAAE;IAC1C,KAAK,EAA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B;qBACF;iBACF;aACF;SACF;KACF;CACF,CAAC;AAEF,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,CAAC,IAAI,CACP,uFAAuF,CACxF,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildTransaction.test.d.ts","sourceRoot":"","sources":["../src/buildTransaction.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
|
-
import { getCardanoTestnetAccount } from "./fixtures/accounts";
|
|
3
|
-
import { buildTransaction } from "./buildTransaction";
|
|
4
|
-
import { types as TyphonTypes } from "@stricahq/typhonjs";
|
|
5
|
-
import { getProtocolParams } from "./fixtures/protocolParams";
|
|
6
|
-
describe("buildTransaction", () => {
|
|
7
|
-
const txPayload = {
|
|
8
|
-
family: "cardano",
|
|
9
|
-
recipient: "addr_test1qz7jw975stagnvs00wsjny6y6gpazn86yvwcm2vy02j3up7mt68vuzvz4nzgs00x0shrgywvy674v6r2zcs8fxvvq27qfjq8np",
|
|
10
|
-
amount: new BigNumber(2e6),
|
|
11
|
-
mode: "send",
|
|
12
|
-
poolId: undefined,
|
|
13
|
-
protocolParams: getProtocolParams(),
|
|
14
|
-
};
|
|
15
|
-
describe("certificates", () => {
|
|
16
|
-
it("should not add abstain when there is no delegation", async () => {
|
|
17
|
-
// account with no delegation
|
|
18
|
-
const account = getCardanoTestnetAccount({ delegation: undefined });
|
|
19
|
-
const transaction = await buildTransaction(account, txPayload);
|
|
20
|
-
const certificates = transaction.getCertificates();
|
|
21
|
-
expect(certificates).toEqual([]);
|
|
22
|
-
});
|
|
23
|
-
it("should not add abstain when there is no rewards", async () => {
|
|
24
|
-
const account = getCardanoTestnetAccount({
|
|
25
|
-
delegation: {
|
|
26
|
-
dRepHex: undefined,
|
|
27
|
-
rewards: new BigNumber(0), // no rewards
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
const transaction = await buildTransaction(account, txPayload);
|
|
31
|
-
const certificates = transaction.getCertificates();
|
|
32
|
-
expect(certificates).toEqual([]);
|
|
33
|
-
});
|
|
34
|
-
it("should not add abstain vote when dRepHex is present", async () => {
|
|
35
|
-
const account = getCardanoTestnetAccount({
|
|
36
|
-
delegation: {
|
|
37
|
-
dRepHex: "drepHex", // drepHex present
|
|
38
|
-
rewards: new BigNumber(10e6),
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
const transaction = await buildTransaction(account, txPayload);
|
|
42
|
-
const certificates = transaction.getCertificates();
|
|
43
|
-
expect(certificates).toEqual([]);
|
|
44
|
-
});
|
|
45
|
-
it("should add abstain when drepHex is absent and rewards is available", async () => {
|
|
46
|
-
const account = getCardanoTestnetAccount({
|
|
47
|
-
delegation: {
|
|
48
|
-
dRepHex: undefined, // drepHex absent
|
|
49
|
-
rewards: new BigNumber(10e6), // rewards available
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
const transaction = await buildTransaction(account, txPayload);
|
|
53
|
-
const certificates = transaction.getCertificates();
|
|
54
|
-
expect(certificates.some(c => c.type === TyphonTypes.CertificateType.VOTE_DELEGATION &&
|
|
55
|
-
c.cert.dRep.type === TyphonTypes.DRepType.ABSTAIN)).toBe(true);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
describe("withdrawals", () => {
|
|
59
|
-
it("should not add withdrawal when there is no delegation", async () => {
|
|
60
|
-
const account = getCardanoTestnetAccount({ delegation: undefined });
|
|
61
|
-
const transaction = await buildTransaction(account, txPayload);
|
|
62
|
-
const withdrawals = transaction.getWithdrawals();
|
|
63
|
-
expect(withdrawals.length).toBe(0);
|
|
64
|
-
});
|
|
65
|
-
it("should not add withdrawal if no rewards", async () => {
|
|
66
|
-
const account = getCardanoTestnetAccount({
|
|
67
|
-
delegation: {
|
|
68
|
-
rewards: new BigNumber(0), // no rewards
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
const transaction = await buildTransaction(account, txPayload);
|
|
72
|
-
const withdrawals = transaction.getWithdrawals();
|
|
73
|
-
expect(withdrawals.length).toBe(0);
|
|
74
|
-
});
|
|
75
|
-
it("should not add withdrawal when dRepHex is absent", async () => {
|
|
76
|
-
const account = getCardanoTestnetAccount({
|
|
77
|
-
delegation: {
|
|
78
|
-
dRepHex: undefined, // drepHex absent
|
|
79
|
-
rewards: new BigNumber(10e6), // rewards available
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
const transaction = await buildTransaction(account, txPayload);
|
|
83
|
-
const withdrawals = transaction.getWithdrawals();
|
|
84
|
-
expect(withdrawals.length).toBe(0);
|
|
85
|
-
});
|
|
86
|
-
it("should add withdrawal when dRepHex and rewards both are available", async () => {
|
|
87
|
-
const account = getCardanoTestnetAccount({
|
|
88
|
-
delegation: {
|
|
89
|
-
dRepHex: "drepHex", // drepHex present
|
|
90
|
-
rewards: new BigNumber(10e6), // rewards available
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
const transaction = await buildTransaction(account, txPayload);
|
|
94
|
-
const withdrawals = transaction.getWithdrawals();
|
|
95
|
-
expect(withdrawals.length).toBe(1);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe("undelegate transaction", () => {
|
|
99
|
-
it("should build a undelegate transaction with correct deposit", async () => {
|
|
100
|
-
const account = getCardanoTestnetAccount({
|
|
101
|
-
delegation: {
|
|
102
|
-
status: true,
|
|
103
|
-
deposit: (3e6).toString(),
|
|
104
|
-
rewards: new BigNumber(0),
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
const txPayloadUndelegate = {
|
|
108
|
-
family: "cardano",
|
|
109
|
-
recipient: "",
|
|
110
|
-
amount: new BigNumber(0),
|
|
111
|
-
mode: "undelegate",
|
|
112
|
-
poolId: undefined,
|
|
113
|
-
protocolParams: getProtocolParams(),
|
|
114
|
-
};
|
|
115
|
-
const transaction = await buildTransaction(account, txPayloadUndelegate);
|
|
116
|
-
const deregisterCertificate = transaction
|
|
117
|
-
.getCertificates()
|
|
118
|
-
.find(c => c.type === TyphonTypes.CertificateType.STAKE_KEY_DE_REGISTRATION);
|
|
119
|
-
expect(deregisterCertificate).toBeDefined();
|
|
120
|
-
expect(deregisterCertificate.cert.deposit.toString()).toBe(account.cardanoResources.delegation?.deposit);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
describe("delegate transaction", () => {
|
|
124
|
-
it("should build delegate transaction with stake key registration", async () => {
|
|
125
|
-
const account = getCardanoTestnetAccount({
|
|
126
|
-
delegation: undefined, // stake key not registered
|
|
127
|
-
});
|
|
128
|
-
const txPayloadDelegate = {
|
|
129
|
-
family: "cardano",
|
|
130
|
-
recipient: "",
|
|
131
|
-
amount: new BigNumber(0),
|
|
132
|
-
mode: "delegate",
|
|
133
|
-
poolId: "7df262feae9201d1b2e32d4c825ca91b29fbafb2b8e556f6efb7f549",
|
|
134
|
-
protocolParams: getProtocolParams(),
|
|
135
|
-
};
|
|
136
|
-
const transaction = await buildTransaction(account, txPayloadDelegate);
|
|
137
|
-
const registerCertificate = transaction
|
|
138
|
-
.getCertificates()
|
|
139
|
-
.find(c => c.type === TyphonTypes.CertificateType.STAKE_KEY_REGISTRATION);
|
|
140
|
-
expect(registerCertificate).toBeDefined();
|
|
141
|
-
expect(registerCertificate.cert.deposit.toString()).toBe(transaction.protocolParams.stakeKeyDeposit.toString());
|
|
142
|
-
});
|
|
143
|
-
it("should build delegate transaction without stake key registration", async () => {
|
|
144
|
-
const account = getCardanoTestnetAccount({
|
|
145
|
-
delegation: {
|
|
146
|
-
status: true, // stake key already registered
|
|
147
|
-
deposit: (2e6).toString(),
|
|
148
|
-
rewards: new BigNumber(0),
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
const txPayloadDelegate = {
|
|
152
|
-
family: "cardano",
|
|
153
|
-
recipient: "",
|
|
154
|
-
amount: new BigNumber(0),
|
|
155
|
-
mode: "delegate",
|
|
156
|
-
poolId: "7df262feae9201d1b2e32d4c825ca91b29fbafb2b8e556f6efb7f549",
|
|
157
|
-
protocolParams: getProtocolParams(),
|
|
158
|
-
};
|
|
159
|
-
const transaction = await buildTransaction(account, txPayloadDelegate);
|
|
160
|
-
const registerCertificate = transaction
|
|
161
|
-
.getCertificates()
|
|
162
|
-
.find(c => c.type === TyphonTypes.CertificateType.STAKE_KEY_REGISTRATION);
|
|
163
|
-
expect(registerCertificate).toBeUndefined();
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
//# sourceMappingURL=buildTransaction.test.js.map
|