@ledgerhq/coin-tezos 6.7.0 → 6.8.0-nightly.1
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/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +3 -0
- package/lib/api/index.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +3 -0
- package/lib-es/api/index.js.map +1 -1
- package/package.json +6 -6
- package/src/api/index.ts +4 -0
- package/lib/api/index.integ.test.d.ts +0 -2
- package/lib/api/index.integ.test.d.ts.map +0 -1
- package/lib/api/index.integ.test.js +0 -201
- package/lib/api/index.integ.test.js.map +0 -1
- package/lib/api/index.test.d.ts +0 -2
- package/lib/api/index.test.d.ts.map +0 -1
- package/lib/api/index.test.js +0 -203
- package/lib/api/index.test.js.map +0 -1
- package/lib/logic/craftTransaction.integ.test.d.ts +0 -2
- package/lib/logic/craftTransaction.integ.test.d.ts.map +0 -1
- package/lib/logic/craftTransaction.integ.test.js +0 -86
- package/lib/logic/craftTransaction.integ.test.js.map +0 -1
- package/lib/logic/craftTransaction.test.d.ts +0 -2
- package/lib/logic/craftTransaction.test.d.ts.map +0 -1
- package/lib/logic/craftTransaction.test.js +0 -153
- package/lib/logic/craftTransaction.test.js.map +0 -1
- package/lib/logic/estimateFees.integ.test.d.ts +0 -2
- package/lib/logic/estimateFees.integ.test.d.ts.map +0 -1
- package/lib/logic/estimateFees.integ.test.js +0 -71
- package/lib/logic/estimateFees.integ.test.js.map +0 -1
- package/lib/logic/getBalance.test.d.ts +0 -2
- package/lib/logic/getBalance.test.d.ts.map +0 -1
- package/lib/logic/getBalance.test.js +0 -23
- package/lib/logic/getBalance.test.js.map +0 -1
- package/lib/logic/getStakes.test.d.ts +0 -2
- package/lib/logic/getStakes.test.d.ts.map +0 -1
- package/lib/logic/getStakes.test.js +0 -133
- package/lib/logic/getStakes.test.js.map +0 -1
- package/lib/logic/listOperations.test.d.ts +0 -2
- package/lib/logic/listOperations.test.d.ts.map +0 -1
- package/lib/logic/listOperations.test.js +0 -196
- package/lib/logic/listOperations.test.js.map +0 -1
- package/lib/logic/validateIntent.test.d.ts +0 -2
- package/lib/logic/validateIntent.test.d.ts.map +0 -1
- package/lib/logic/validateIntent.test.js +0 -279
- package/lib/logic/validateIntent.test.js.map +0 -1
- package/lib/network/bakers.integration.test.d.ts +0 -2
- package/lib/network/bakers.integration.test.d.ts.map +0 -1
- package/lib/network/bakers.integration.test.js +0 -57
- package/lib/network/bakers.integration.test.js.map +0 -1
- package/lib/network/bakers.test.d.ts +0 -2
- package/lib/network/bakers.test.d.ts.map +0 -1
- package/lib/network/bakers.test.js +0 -209
- package/lib/network/bakers.test.js.map +0 -1
- package/lib-es/api/index.integ.test.d.ts +0 -2
- package/lib-es/api/index.integ.test.d.ts.map +0 -1
- package/lib-es/api/index.integ.test.js +0 -199
- package/lib-es/api/index.integ.test.js.map +0 -1
- package/lib-es/api/index.test.d.ts +0 -2
- package/lib-es/api/index.test.d.ts.map +0 -1
- package/lib-es/api/index.test.js +0 -198
- package/lib-es/api/index.test.js.map +0 -1
- package/lib-es/logic/craftTransaction.integ.test.d.ts +0 -2
- package/lib-es/logic/craftTransaction.integ.test.d.ts.map +0 -1
- package/lib-es/logic/craftTransaction.integ.test.js +0 -81
- package/lib-es/logic/craftTransaction.integ.test.js.map +0 -1
- package/lib-es/logic/craftTransaction.test.d.ts +0 -2
- package/lib-es/logic/craftTransaction.test.d.ts.map +0 -1
- package/lib-es/logic/craftTransaction.test.js +0 -148
- package/lib-es/logic/craftTransaction.test.js.map +0 -1
- package/lib-es/logic/estimateFees.integ.test.d.ts +0 -2
- package/lib-es/logic/estimateFees.integ.test.d.ts.map +0 -1
- package/lib-es/logic/estimateFees.integ.test.js +0 -66
- package/lib-es/logic/estimateFees.integ.test.js.map +0 -1
- package/lib-es/logic/getBalance.test.d.ts +0 -2
- package/lib-es/logic/getBalance.test.d.ts.map +0 -1
- package/lib-es/logic/getBalance.test.js +0 -18
- package/lib-es/logic/getBalance.test.js.map +0 -1
- package/lib-es/logic/getStakes.test.d.ts +0 -2
- package/lib-es/logic/getStakes.test.d.ts.map +0 -1
- package/lib-es/logic/getStakes.test.js +0 -128
- package/lib-es/logic/getStakes.test.js.map +0 -1
- package/lib-es/logic/listOperations.test.d.ts +0 -2
- package/lib-es/logic/listOperations.test.d.ts.map +0 -1
- package/lib-es/logic/listOperations.test.js +0 -194
- package/lib-es/logic/listOperations.test.js.map +0 -1
- package/lib-es/logic/validateIntent.test.d.ts +0 -2
- package/lib-es/logic/validateIntent.test.d.ts.map +0 -1
- package/lib-es/logic/validateIntent.test.js +0 -251
- package/lib-es/logic/validateIntent.test.js.map +0 -1
- package/lib-es/network/bakers.integration.test.d.ts +0 -2
- package/lib-es/network/bakers.integration.test.d.ts.map +0 -1
- package/lib-es/network/bakers.integration.test.js +0 -52
- package/lib-es/network/bakers.integration.test.js.map +0 -1
- package/lib-es/network/bakers.test.d.ts +0 -2
- package/lib-es/network/bakers.test.d.ts.map +0 -1
- package/lib-es/network/bakers.test.js +0 -204
- package/lib-es/network/bakers.test.js.map +0 -1
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { OpKind } from "@taquito/rpc";
|
|
2
|
-
import { craftTransaction } from ".";
|
|
3
|
-
import coinConfig from "../config";
|
|
4
|
-
import { mockConfig } from "../test/config";
|
|
5
|
-
/**
|
|
6
|
-
* https://teztnets.com/ghostnet-about
|
|
7
|
-
* https://api.tzkt.io/#section/Get-Started/Free-TzKT-API
|
|
8
|
-
*/
|
|
9
|
-
describe("Tezos Api", () => {
|
|
10
|
-
const address = "tz1heMGVHQnx7ALDcDKqez8fan64Eyicw4DJ";
|
|
11
|
-
beforeAll(() => {
|
|
12
|
-
coinConfig.setCoinConfig(() => mockConfig);
|
|
13
|
-
});
|
|
14
|
-
it("should craft a send transaction", async () => {
|
|
15
|
-
// When
|
|
16
|
-
const result = await craftTransaction({ address }, {
|
|
17
|
-
type: "send",
|
|
18
|
-
recipient: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9", // spell-checker: disable-line
|
|
19
|
-
amount: BigInt(10),
|
|
20
|
-
fee: { fees: BigInt(1).toString() },
|
|
21
|
-
});
|
|
22
|
-
// Then
|
|
23
|
-
expect(result.type).toBe("OUT");
|
|
24
|
-
expect(result.contents).toEqual(expect.objectContaining([
|
|
25
|
-
{
|
|
26
|
-
kind: OpKind.TRANSACTION,
|
|
27
|
-
amount: "10",
|
|
28
|
-
destination: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
|
|
29
|
-
source: address,
|
|
30
|
-
counter: expect.any(String),
|
|
31
|
-
fee: "1",
|
|
32
|
-
gas_limit: "0",
|
|
33
|
-
storage_limit: "0",
|
|
34
|
-
},
|
|
35
|
-
]));
|
|
36
|
-
});
|
|
37
|
-
it("should craft a delegate transaction", async () => {
|
|
38
|
-
// When
|
|
39
|
-
const result = await craftTransaction({ address }, {
|
|
40
|
-
type: "delegate",
|
|
41
|
-
recipient: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9", // spell-checker: disable-line
|
|
42
|
-
amount: BigInt(10),
|
|
43
|
-
fee: { fees: BigInt(1).toString(), gasLimit: "200", storageLimit: "300" },
|
|
44
|
-
});
|
|
45
|
-
// Then
|
|
46
|
-
expect(result.type).toBe("DELEGATE");
|
|
47
|
-
expect(result.contents).toEqual(expect.objectContaining([
|
|
48
|
-
{
|
|
49
|
-
kind: OpKind.DELEGATION,
|
|
50
|
-
source: address,
|
|
51
|
-
counter: expect.any(String),
|
|
52
|
-
delegate: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
|
|
53
|
-
fee: "1",
|
|
54
|
-
gas_limit: "200",
|
|
55
|
-
storage_limit: "300",
|
|
56
|
-
},
|
|
57
|
-
]));
|
|
58
|
-
});
|
|
59
|
-
it("should craft a undelegate transaction", async () => {
|
|
60
|
-
// When
|
|
61
|
-
const result = await craftTransaction({ address }, {
|
|
62
|
-
type: "undelegate",
|
|
63
|
-
recipient: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9", // spell-checker: disable-line
|
|
64
|
-
amount: BigInt(10),
|
|
65
|
-
fee: { fees: BigInt(1).toString(), gasLimit: "200", storageLimit: "300" },
|
|
66
|
-
});
|
|
67
|
-
// Then
|
|
68
|
-
expect(result.type).toBe("UNDELEGATE");
|
|
69
|
-
expect(result.contents).toEqual(expect.objectContaining([
|
|
70
|
-
{
|
|
71
|
-
kind: OpKind.DELEGATION,
|
|
72
|
-
source: address,
|
|
73
|
-
counter: expect.any(String),
|
|
74
|
-
fee: "1",
|
|
75
|
-
gas_limit: "200",
|
|
76
|
-
storage_limit: "300",
|
|
77
|
-
},
|
|
78
|
-
]));
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
//# sourceMappingURL=craftTransaction.integ.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"craftTransaction.integ.test.js","sourceRoot":"","sources":["../../src/logic/craftTransaction.integ.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,GAAG,CAAC;AACrC,OAAO,UAA+B,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,MAAM,OAAO,GAAG,sCAAsC,CAAC;IACvD,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,aAAa,CAAC,GAAoB,EAAE,CAAC,UAA6B,CAAC,CAAC;IACjF,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC/C,OAAO;QACP,MAAM,MAAM,GAAG,MAAM,gBAAgB,CACnC,EAAE,OA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":["../../src/logic/craftTransaction.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { craftTransaction, rawEncode } from "./craftTransaction";
|
|
2
|
-
import { getTezosToolkit } from "./tezosToolkit";
|
|
3
|
-
import coinConfig from "../config";
|
|
4
|
-
import { OpKind } from "@taquito/rpc";
|
|
5
|
-
import { getRevealFee } from "@taquito/taquito";
|
|
6
|
-
jest.mock("./tezosToolkit");
|
|
7
|
-
jest.mock("../config", () => ({
|
|
8
|
-
getCoinConfig: jest.fn(),
|
|
9
|
-
}));
|
|
10
|
-
describe("craftTransaction", () => {
|
|
11
|
-
const mockTezosToolkit = {
|
|
12
|
-
rpc: {
|
|
13
|
-
getContract: jest.fn(),
|
|
14
|
-
getBlock: jest.fn(),
|
|
15
|
-
forgeOperations: jest.fn(),
|
|
16
|
-
},
|
|
17
|
-
estimate: {
|
|
18
|
-
reveal: jest.fn(),
|
|
19
|
-
},
|
|
20
|
-
setProvider: jest.fn(),
|
|
21
|
-
};
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
jest.clearAllMocks();
|
|
24
|
-
getTezosToolkit.mockReturnValue(mockTezosToolkit);
|
|
25
|
-
});
|
|
26
|
-
it("should craft a send transaction", async () => {
|
|
27
|
-
mockTezosToolkit.rpc.getContract.mockResolvedValue({ counter: "1" });
|
|
28
|
-
const account = { address: "tz1..." };
|
|
29
|
-
const transaction = {
|
|
30
|
-
type: "send",
|
|
31
|
-
recipient: "tz2...",
|
|
32
|
-
amount: BigInt(1000),
|
|
33
|
-
fee: { fees: "100", gasLimit: "200", storageLimit: "300" },
|
|
34
|
-
};
|
|
35
|
-
const result = await craftTransaction(account, transaction);
|
|
36
|
-
expect(result.type).toBe("OUT");
|
|
37
|
-
expect(result.contents).toEqual([
|
|
38
|
-
{
|
|
39
|
-
kind: OpKind.TRANSACTION,
|
|
40
|
-
amount: "1000",
|
|
41
|
-
destination: transaction.recipient,
|
|
42
|
-
source: account.address,
|
|
43
|
-
counter: "2",
|
|
44
|
-
fee: "100",
|
|
45
|
-
gas_limit: "200",
|
|
46
|
-
storage_limit: "300",
|
|
47
|
-
},
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
it("should craft a delegate transaction", async () => {
|
|
51
|
-
mockTezosToolkit.rpc.getContract.mockResolvedValue({ counter: "1" });
|
|
52
|
-
const account = { address: "tz1..." };
|
|
53
|
-
const transaction = {
|
|
54
|
-
type: "delegate",
|
|
55
|
-
recipient: "tz2...",
|
|
56
|
-
amount: BigInt(0),
|
|
57
|
-
fee: { fees: "100", gasLimit: "200", storageLimit: "300" },
|
|
58
|
-
};
|
|
59
|
-
const result = await craftTransaction(account, transaction);
|
|
60
|
-
expect(result.type).toBe("DELEGATE");
|
|
61
|
-
expect(result.contents).toEqual([
|
|
62
|
-
{
|
|
63
|
-
kind: OpKind.DELEGATION,
|
|
64
|
-
source: account.address,
|
|
65
|
-
counter: "2",
|
|
66
|
-
delegate: transaction.recipient,
|
|
67
|
-
fee: "100",
|
|
68
|
-
gas_limit: "200",
|
|
69
|
-
storage_limit: "300",
|
|
70
|
-
},
|
|
71
|
-
]);
|
|
72
|
-
});
|
|
73
|
-
it("should craft an undelegate transaction", async () => {
|
|
74
|
-
mockTezosToolkit.rpc.getContract.mockResolvedValue({ counter: "1" });
|
|
75
|
-
const account = { address: "tz1..." };
|
|
76
|
-
const transaction = {
|
|
77
|
-
type: "undelegate",
|
|
78
|
-
recipient: "",
|
|
79
|
-
amount: BigInt(0),
|
|
80
|
-
fee: { fees: "100", gasLimit: "200", storageLimit: "300" },
|
|
81
|
-
};
|
|
82
|
-
const result = await craftTransaction(account, transaction);
|
|
83
|
-
expect(result.type).toBe("UNDELEGATE");
|
|
84
|
-
expect(result.contents).toEqual([
|
|
85
|
-
{
|
|
86
|
-
kind: OpKind.DELEGATION,
|
|
87
|
-
source: account.address,
|
|
88
|
-
counter: "2",
|
|
89
|
-
fee: "100",
|
|
90
|
-
gas_limit: "200",
|
|
91
|
-
storage_limit: "300",
|
|
92
|
-
},
|
|
93
|
-
]);
|
|
94
|
-
});
|
|
95
|
-
it("should craft a transaction with reveal operation", async () => {
|
|
96
|
-
mockTezosToolkit.rpc.getContract.mockResolvedValue({ counter: "1" });
|
|
97
|
-
mockTezosToolkit.estimate.reveal.mockResolvedValue({ gasLimit: 100, storageLimit: 0 });
|
|
98
|
-
coinConfig.getCoinConfig.mockReturnValue({ fees: { minRevealGasLimit: 100 } });
|
|
99
|
-
const account = { address: "tz1..." };
|
|
100
|
-
const transaction = {
|
|
101
|
-
type: "send",
|
|
102
|
-
recipient: "tz2...",
|
|
103
|
-
amount: BigInt(1000),
|
|
104
|
-
fee: { fees: "100", gasLimit: "200", storageLimit: "300" },
|
|
105
|
-
};
|
|
106
|
-
const publicKey = { publicKey: "publicKey", publicKeyHash: "publicKeyHash" };
|
|
107
|
-
const result = await craftTransaction(account, transaction, publicKey);
|
|
108
|
-
expect(result.contents).toEqual([
|
|
109
|
-
{
|
|
110
|
-
kind: OpKind.REVEAL,
|
|
111
|
-
fee: getRevealFee(account.address).toString(),
|
|
112
|
-
gas_limit: "100",
|
|
113
|
-
storage_limit: "0",
|
|
114
|
-
source: publicKey.publicKeyHash,
|
|
115
|
-
counter: "2",
|
|
116
|
-
public_key: publicKey.publicKey,
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
kind: OpKind.TRANSACTION,
|
|
120
|
-
amount: "1000",
|
|
121
|
-
destination: transaction.recipient,
|
|
122
|
-
source: account.address,
|
|
123
|
-
counter: "3",
|
|
124
|
-
fee: "100",
|
|
125
|
-
gas_limit: "200",
|
|
126
|
-
storage_limit: "300",
|
|
127
|
-
},
|
|
128
|
-
]);
|
|
129
|
-
});
|
|
130
|
-
it("should throw an error for unsupported transaction type", async () => {
|
|
131
|
-
const account = { address: "tz1..." };
|
|
132
|
-
const transaction = {
|
|
133
|
-
type: "invalid",
|
|
134
|
-
recipient: "tz2...",
|
|
135
|
-
amount: BigInt(1000),
|
|
136
|
-
fee: { fees: "100", gasLimit: "200", storageLimit: "300" },
|
|
137
|
-
};
|
|
138
|
-
await expect(craftTransaction(account, transaction)).rejects.toThrow("unsupported mode");
|
|
139
|
-
});
|
|
140
|
-
it("should include leading watermark byte when using rawEncode", async () => {
|
|
141
|
-
mockTezosToolkit.rpc.getBlock.mockResolvedValue({ hash: "aaaa" });
|
|
142
|
-
mockTezosToolkit.rpc.forgeOperations.mockResolvedValue("deadcafe");
|
|
143
|
-
const rawTx = await rawEncode([]);
|
|
144
|
-
// 0x03 is a conventional prefix (aka a watermark) for tezos transactions
|
|
145
|
-
expect(rawTx).toEqual("03deadcafe");
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
//# sourceMappingURL=craftTransaction.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"craftTransaction.test.js","sourceRoot":"","sources":["../../src/logic/craftTransaction.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,UAAU,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAC5B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5B,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;CACzB,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,gBAAgB,GAAG;QACvB,GAAG,EAAE;YACH,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;YACtB,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;YACnB,eAAe,EAAE,IAAI,CAAC,EA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AO,CAAC,kBAAkB,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;QAC1E,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAClE,gBAAgB,CAAC,GAAG,CAAC,eAAe,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAEnE,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,EAAE,CAAC,CAAC;QAElC,yEAAyE;QACzE,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estimateFees.integ.test.d.ts","sourceRoot":"","sources":["../../src/logic/estimateFees.integ.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { estimateFees } from "./estimateFees";
|
|
2
|
-
import coinConfig from "../config";
|
|
3
|
-
import { mockConfig } from "../test/config";
|
|
4
|
-
describe("estimateFees", () => {
|
|
5
|
-
beforeAll(() => {
|
|
6
|
-
coinConfig.setCoinConfig(() => mockConfig);
|
|
7
|
-
});
|
|
8
|
-
const accounts = [
|
|
9
|
-
{
|
|
10
|
-
xpub: "02389ffd73423626894cb151416e51c72ec285376673daf83545eb5edb45b261ce",
|
|
11
|
-
address: "tz1UHux4ijk2Qu6Ee3dDpka4vnAiEhiDLZMa",
|
|
12
|
-
balance: BigInt("2000000"),
|
|
13
|
-
revealed: false,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
// No xpub provided
|
|
17
|
-
address: "tz1UHux4ijk2Qu6Ee3dDpka4vnAiEhiDLZMa",
|
|
18
|
-
balance: BigInt("2000000"),
|
|
19
|
-
revealed: false,
|
|
20
|
-
},
|
|
21
|
-
];
|
|
22
|
-
it.each([
|
|
23
|
-
[accounts[0], "with xpub"],
|
|
24
|
-
[accounts[1], "without xpub"],
|
|
25
|
-
])("returns correct value %s", async (account, _description) => {
|
|
26
|
-
// Given
|
|
27
|
-
const transaction = {
|
|
28
|
-
mode: "send",
|
|
29
|
-
recipient: "tz1PWFt4Ym6HedY78MgUP2kVDtSampGwprs5",
|
|
30
|
-
amount: BigInt(1_000_000),
|
|
31
|
-
};
|
|
32
|
-
// When
|
|
33
|
-
const result = await estimateFees({ account, transaction });
|
|
34
|
-
// Then
|
|
35
|
-
expect(result).toEqual({
|
|
36
|
-
estimatedFees: BigInt("825"),
|
|
37
|
-
fees: BigInt("491"),
|
|
38
|
-
gasLimit: BigInt("2169"),
|
|
39
|
-
storageLimit: BigInt("277"),
|
|
40
|
-
amount: BigInt("1000000"),
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
it.each([
|
|
44
|
-
[accounts[0], "with xpub"],
|
|
45
|
-
[accounts[1], "without xpub"],
|
|
46
|
-
])("returns correct value when useAllAmount %s", async (account, _description) => {
|
|
47
|
-
// Given
|
|
48
|
-
const transaction = {
|
|
49
|
-
mode: "send",
|
|
50
|
-
recipient: "tz1PWFt4Ym6HedY78MgUP2kVDtSampGwprs5",
|
|
51
|
-
amount: BigInt(1_000_000),
|
|
52
|
-
useAllAmount: true,
|
|
53
|
-
};
|
|
54
|
-
// When
|
|
55
|
-
const result = await estimateFees({ account, transaction });
|
|
56
|
-
// Then
|
|
57
|
-
expect(result).toEqual({
|
|
58
|
-
estimatedFees: BigInt("823"),
|
|
59
|
-
fees: BigInt("489"),
|
|
60
|
-
gasLimit: BigInt("2169"),
|
|
61
|
-
storageLimit: BigInt("277"),
|
|
62
|
-
amount: BigInt("1934629"),
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=estimateFees.integ.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estimateFees.integ.test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AAM,CAAC,KAAK,CAAC;YACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;YACxB,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC;YAC3B,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,IAAI,CAAC;QACN,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC;QAC1B,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC;KAC9B,CAAC,CAAC,4CAA4C,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;QAC/E,QAAQ;QACR,MAAM,WAAW,GAAG;YAClB,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,sCAAsC;YACjD,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC;YACzB,YAAY,EAAE,IAAI;SACW,CAAC;QAEhC,OAAO;QACP,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;QAE5D,OAAO;QACP,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC;YAC5B,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC;YACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;YACxB,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC;YAC3B,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.test.d.ts","sourceRoot":"","sources":["../../src/logic/getBalance.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { getBalance } from "./getBalance";
|
|
2
|
-
import { setupServer } from "msw/node";
|
|
3
|
-
import coinConfig from "../config";
|
|
4
|
-
import { HttpResponse, http } from "msw";
|
|
5
|
-
describe("getBalance", () => {
|
|
6
|
-
const mockServer = setupServer();
|
|
7
|
-
coinConfig.setCoinConfig(() => ({
|
|
8
|
-
status: { type: "active" },
|
|
9
|
-
explorer: { url: "http://tezos.explorer.com" },
|
|
10
|
-
}));
|
|
11
|
-
it("gets the balance of a Tezos account", async () => {
|
|
12
|
-
mockServer.listen({ onUnhandledRequest: "error" });
|
|
13
|
-
mockServer.use(http.get("http://tezos.explorer.com/v1/accounts/tz1WvvbEGpBXGeTVbLiR6DYBe1izmgiYuZbq", () => HttpResponse.json({ type: "empty" })), http.get("http://tezos.explorer.com/v1/accounts/tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8", () => HttpResponse.json({ type: "user", balance: 25 })));
|
|
14
|
-
expect(await getBalance("tz1WvvbEGpBXGeTVbLiR6DYBe1izmgiYuZbq")).toEqual(BigInt(-1));
|
|
15
|
-
expect(await getBalance("tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8")).toEqual(BigInt(25));
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
//# sourceMappingURL=getBalance.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.test.js","sourceRoot":"","sources":["../../src/logic/getBalance.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,UAA+B,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEzC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,MAAM,UAAU,GAAG,WAAW,EAAE,CAAC;IACjC,UAAU,CAAC,aAAa,CACtB,GAAG,EAAE,CACH,CAAC;QACC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,QAAQ,EAAE,EAAE,GAAG,EAAE,2BAA2B,EAAE;KAC/C,CAA+B,CACnC,CAAC;IACF,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,UAAU,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;QACnD,UAAU,CAAC,GAAG,CACZ,IAAI,CAAC,GAAG,CAAC,4EAA4E,EAAE,GAAG,EAAE,CAC1F,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CACrC,EACD,IAAI,CAAC,GAAG,CAAC,4EAA4E,EAAE,GAAG,EAAE,CAC1F,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CACjD,CACF,CAAC;QAEF,MAAM,CAAC,MAAM,UAAU,CAAC,sCAAsC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrF,MAAM,CAAC,MAAM,UAAU,CAAC,sCAAsC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getStakes.test.d.ts","sourceRoot":"","sources":["../../src/logic/getStakes.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { createApi } from "../api/index";
|
|
2
|
-
import tzktApi from "../network/tzkt";
|
|
3
|
-
import coinConfig from "../config";
|
|
4
|
-
describe("getStakes", () => {
|
|
5
|
-
const api = createApi({
|
|
6
|
-
baker: { url: "http://baker.example.com" },
|
|
7
|
-
explorer: { url: "http://tezos.explorer.com", maxTxQuery: 100 },
|
|
8
|
-
node: { url: "http://tezos.node.com" },
|
|
9
|
-
fees: {
|
|
10
|
-
minGasLimit: 600,
|
|
11
|
-
minRevealGasLimit: 300,
|
|
12
|
-
minStorageLimit: 0,
|
|
13
|
-
minFees: 500,
|
|
14
|
-
minEstimatedFees: 500,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
const mockGetAccountByAddress = jest.spyOn(tzktApi, "getAccountByAddress");
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
jest.clearAllMocks();
|
|
20
|
-
coinConfig.setCoinConfig(() => ({
|
|
21
|
-
status: { type: "active" },
|
|
22
|
-
baker: { url: "http://baker.example.com" },
|
|
23
|
-
explorer: { url: "http://tezos.explorer.com", maxTxQuery: 100 },
|
|
24
|
-
node: { url: "http://tezos.node.com" },
|
|
25
|
-
fees: {
|
|
26
|
-
minGasLimit: 600,
|
|
27
|
-
minRevealGasLimit: 300,
|
|
28
|
-
minStorageLimit: 0,
|
|
29
|
-
minFees: 500,
|
|
30
|
-
minEstimatedFees: 500,
|
|
31
|
-
},
|
|
32
|
-
}));
|
|
33
|
-
});
|
|
34
|
-
describe("account types", () => {
|
|
35
|
-
it("should return empty stakes for non-delegated account", async () => {
|
|
36
|
-
mockGetAccountByAddress.mockResolvedValue({
|
|
37
|
-
type: "user",
|
|
38
|
-
address: "tz1WvvbEGpBXGeTVbLiR6DYBe1izmgiYuZbq",
|
|
39
|
-
publicKey: "edpk...",
|
|
40
|
-
balance: 1000000,
|
|
41
|
-
revealed: true,
|
|
42
|
-
counter: 0,
|
|
43
|
-
delegationLevel: 0,
|
|
44
|
-
delegationTime: "2021-01-01T00:00:00Z",
|
|
45
|
-
numTransactions: 0,
|
|
46
|
-
firstActivityTime: "2021-01-01T00:00:00Z",
|
|
47
|
-
});
|
|
48
|
-
const result = await api.getStakes("tz1WvvbEGpBXGeTVbLiR6DYBe1izmgiYuZbq");
|
|
49
|
-
expect(result.items).toEqual([]);
|
|
50
|
-
});
|
|
51
|
-
it("should return empty stakes for non user account", async () => {
|
|
52
|
-
mockGetAccountByAddress.mockResolvedValue({
|
|
53
|
-
type: "empty",
|
|
54
|
-
address: "tz1EmptyAccount",
|
|
55
|
-
counter: 0,
|
|
56
|
-
});
|
|
57
|
-
const result = await api.getStakes("tz1EmptyAccount");
|
|
58
|
-
expect(result.items).toEqual([]);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe("delegated accounts", () => {
|
|
62
|
-
it("should return stake for delegated account", async () => {
|
|
63
|
-
const address = "tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8";
|
|
64
|
-
const delegateAddress = "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx";
|
|
65
|
-
const balance = 5000000;
|
|
66
|
-
mockGetAccountByAddress.mockResolvedValue({
|
|
67
|
-
type: "user",
|
|
68
|
-
address,
|
|
69
|
-
publicKey: "edpk...",
|
|
70
|
-
balance,
|
|
71
|
-
revealed: true,
|
|
72
|
-
counter: 0,
|
|
73
|
-
delegate: {
|
|
74
|
-
alias: "Test Delegate",
|
|
75
|
-
address: delegateAddress,
|
|
76
|
-
active: true,
|
|
77
|
-
},
|
|
78
|
-
delegationLevel: 100,
|
|
79
|
-
delegationTime: "2021-01-01T00:00:00Z",
|
|
80
|
-
numTransactions: 10,
|
|
81
|
-
firstActivityTime: "2021-01-01T00:00:00Z",
|
|
82
|
-
});
|
|
83
|
-
const result = await api.getStakes(address);
|
|
84
|
-
expect(result.items).toEqual([
|
|
85
|
-
expect.objectContaining({
|
|
86
|
-
uid: address,
|
|
87
|
-
address,
|
|
88
|
-
delegate: delegateAddress,
|
|
89
|
-
state: "active",
|
|
90
|
-
asset: { type: "native" },
|
|
91
|
-
amount: BigInt(balance),
|
|
92
|
-
}),
|
|
93
|
-
]);
|
|
94
|
-
});
|
|
95
|
-
it("should handle account with zero balance but delegation", async () => {
|
|
96
|
-
const address = "tz1ZeroBalanceAccount";
|
|
97
|
-
const delegateAddress = "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx";
|
|
98
|
-
mockGetAccountByAddress.mockResolvedValue({
|
|
99
|
-
type: "user",
|
|
100
|
-
address,
|
|
101
|
-
publicKey: "edpk...",
|
|
102
|
-
balance: 0,
|
|
103
|
-
revealed: true,
|
|
104
|
-
counter: 0,
|
|
105
|
-
delegate: {
|
|
106
|
-
alias: "Test Delegate",
|
|
107
|
-
address: delegateAddress,
|
|
108
|
-
active: true,
|
|
109
|
-
},
|
|
110
|
-
delegationLevel: 100,
|
|
111
|
-
delegationTime: "2021-01-01T00:00:00Z",
|
|
112
|
-
numTransactions: 0,
|
|
113
|
-
firstActivityTime: "2021-01-01T00:00:00Z",
|
|
114
|
-
});
|
|
115
|
-
const result = await api.getStakes(address);
|
|
116
|
-
expect(result.items).toHaveLength(1);
|
|
117
|
-
expect(result.items[0]).toMatchObject({
|
|
118
|
-
uid: address,
|
|
119
|
-
address,
|
|
120
|
-
delegate: delegateAddress,
|
|
121
|
-
state: "active",
|
|
122
|
-
asset: { type: "native" },
|
|
123
|
-
amount: BigInt(0),
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
//# sourceMappingURL=getStakes.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getStakes.test.js","sourceRoot":"","sources":["../../src/logic/getStakes.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,UAAU,MAAM,WAAW,CAAC;AAEnC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,MAAM,GAAG,GAAG,SAAS,CAAC;QACpB,KAAK,EAAE,EAAE,GAAG,EAAE,0BAA0B,EAAE;QAC1C,QAAQ,EAAE,EAAE,GAAG,EAAE,2BAA2B,EAAE,UAAU,EAAE,GAAG,EAAE;QAC/D,IAAI,EAAE,EAAE,GAAG,EAAE,uBAAuB,EAAE;QACtC,IAAI,EAAE;YACJ,WAAW,EAAE,G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