@cardano-sdk/golden-test-generator 0.1.4 → 0.1.8

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.
Files changed (48) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/dist/AddressBalance/applyValue.d.ts +3 -0
  4. package/dist/AddressBalance/applyValue.d.ts.map +1 -0
  5. package/dist/AddressBalance/applyValue.js +30 -0
  6. package/dist/AddressBalance/applyValue.js.map +1 -0
  7. package/dist/AddressBalance/getOnChainAddressBalances.d.ts +17 -0
  8. package/dist/AddressBalance/getOnChainAddressBalances.d.ts.map +1 -0
  9. package/dist/AddressBalance/getOnChainAddressBalances.js +98 -0
  10. package/dist/AddressBalance/getOnChainAddressBalances.js.map +1 -0
  11. package/{src/AddressBalance/index.ts → dist/AddressBalance/index.d.ts} +1 -0
  12. package/dist/AddressBalance/index.d.ts.map +1 -0
  13. package/dist/AddressBalance/index.js +15 -0
  14. package/dist/AddressBalance/index.js.map +1 -0
  15. package/dist/Block/getBlocks.d.ts +14 -0
  16. package/dist/Block/getBlocks.d.ts.map +1 -0
  17. package/dist/Block/getBlocks.js +76 -0
  18. package/dist/Block/getBlocks.js.map +1 -0
  19. package/dist/Block/index.d.ts +2 -0
  20. package/dist/Block/index.d.ts.map +1 -0
  21. package/dist/Block/index.js +14 -0
  22. package/dist/Block/index.js.map +1 -0
  23. package/dist/Content.d.ts +23 -0
  24. package/dist/Content.d.ts.map +1 -0
  25. package/dist/Content.js +24 -0
  26. package/dist/Content.js.map +1 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +114 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/util.d.ts +9 -0
  32. package/dist/util.d.ts.map +1 -0
  33. package/dist/util.js +14 -0
  34. package/dist/util.js.map +1 -0
  35. package/package.json +11 -2
  36. package/jest.config.js +0 -1
  37. package/src/.eslintrc.js +0 -7
  38. package/src/AddressBalance/applyValue.ts +0 -31
  39. package/src/AddressBalance/getOnChainAddressBalances.ts +0 -137
  40. package/src/Block/getBlocks.ts +0 -101
  41. package/src/Block/index.ts +0 -1
  42. package/src/Content.ts +0 -43
  43. package/src/index.ts +0 -127
  44. package/src/tsconfig.json +0 -10
  45. package/src/util.ts +0 -15
  46. package/test/.eslintrc.js +0 -7
  47. package/test/AddressBalance.test.ts +0 -184
  48. package/test/tsconfig.json +0 -10
package/src/util.ts DELETED
@@ -1,15 +0,0 @@
1
- import { Schema } from '@cardano-ogmios/client';
2
- import { getLastCommit } from 'git-last-commit';
3
- // eslint-disable-next-line unicorn/prefer-node-protocol
4
- import { promisify } from 'util';
5
-
6
- // Todo: Hoist to @cardano-ogmios/client
7
- export const isByronStandardBlock = (block: Schema.Block): block is { byron: Schema.StandardBlock } =>
8
- (block as { byron: Schema.StandardBlock }).byron?.header.slot !== undefined;
9
-
10
- export const isByronEpochBoundaryBlock = (block: Schema.Block): block is { byron: Schema.EpochBoundaryBlock } => {
11
- const castBlock = block as { byron: Schema.EpochBoundaryBlock };
12
- return castBlock.byron?.hash !== undefined && castBlock.byron?.header.epoch !== undefined;
13
- };
14
-
15
- export const getLastCommitPromise = promisify(getLastCommit);
package/test/.eslintrc.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- "extends": ["../../../test/.eslintrc.js"],
3
- "parserOptions": {
4
- "project": "./tsconfig.json",
5
- "tsconfigRootDir": __dirname
6
- }
7
- }
@@ -1,184 +0,0 @@
1
- import { AddressBalances, applyValue } from '../src/AddressBalance';
2
-
3
- describe('AddressBalance', () => {
4
- describe('applyValueToBalance', () => {
5
- let balances: AddressBalances;
6
- beforeEach(() => {
7
- balances = {
8
- ab: {
9
- coins: 100
10
- },
11
- cd: {
12
- assets: {
13
- 12: 10n
14
- },
15
- coins: 400
16
- },
17
- ef: {
18
- assets: {
19
- 12: 10n,
20
- 34: 20n
21
- },
22
- coins: 500
23
- }
24
- };
25
- });
26
- describe('values containing only coins', () => {
27
- const address = 'ab';
28
- it('adds the coins balance', () => {
29
- expect(applyValue(balances[address], { coins: 50 })).toEqual({ coins: 150 });
30
- });
31
- it('subtracts the coins balance when spending', () => {
32
- expect(applyValue(balances[address], { coins: 50 }, true)).toEqual({ coins: 50 });
33
- });
34
- it('returns the same balance if coins is 0', () => {
35
- expect(applyValue(balances[address], { coins: 0 })).toEqual({ coins: 100 });
36
- });
37
- it('returns the same balance if coins is 0 when spending', () => {
38
- expect(applyValue(balances[address], { coins: 0 }, true)).toEqual({ coins: 100 });
39
- });
40
- });
41
- describe('values containing an asset', () => {
42
- const address = 'cd';
43
- it('adds the coins and asset balance', () => {
44
- expect(
45
- applyValue(balances[address], {
46
- assets: {
47
- 12: 10n
48
- },
49
- coins: 50
50
- })
51
- ).toEqual({ assets: { 12: 20n }, coins: 450 });
52
- });
53
- it('subtracts the coins and asset balance when spending', () => {
54
- expect(applyValue(balances[address], { assets: { 12: 9n }, coins: 50 }, true)).toEqual({
55
- assets: { 12: 1n },
56
- coins: 350
57
- });
58
- });
59
- it('returns the same balance if coins and asset is 0', () => {
60
- expect(applyValue(balances[address], { assets: { 12: 0n }, coins: 0 })).toEqual({
61
- assets: { 12: 10n },
62
- coins: 400
63
- });
64
- });
65
- it('returns the same balance if coins and asset is 0 when spending', () => {
66
- expect(applyValue(balances[address], { assets: { 12: 0n }, coins: 0 }, true)).toEqual({
67
- assets: { 12: 10n },
68
- coins: 400
69
- });
70
- });
71
- });
72
- describe('values containing multiple assets', () => {
73
- const address = 'ef';
74
- it('adds the coins and assets balance', () => {
75
- expect(
76
- applyValue(balances[address], {
77
- assets: {
78
- 12: 10n,
79
- 34: 55n
80
- },
81
- coins: 50
82
- })
83
- ).toEqual({
84
- assets: {
85
- 12: 20n,
86
- 34: 75n
87
- },
88
- coins: 550
89
- });
90
- });
91
- it('subtracts the coins and asset balances when spending', () => {
92
- expect(
93
- applyValue(
94
- balances[address],
95
- {
96
- assets: {
97
- 12: 9n,
98
- 34: 15n
99
- },
100
- coins: 50
101
- },
102
- true
103
- )
104
- ).toEqual({
105
- assets: {
106
- 12: 1n,
107
- 34: 5n
108
- },
109
- coins: 450
110
- });
111
- });
112
- it('adds new assets to the address balance', () => {
113
- expect(
114
- applyValue(balances[address], {
115
- assets: {
116
- new: 100n
117
- },
118
- coins: 1
119
- })
120
- ).toEqual({
121
- assets: {
122
- 12: 10n,
123
- 34: 20n,
124
- new: 100n
125
- },
126
- coins: 501
127
- });
128
- });
129
- });
130
- describe('balance containing multiple assets, value containing only coins', () => {
131
- const address = 'ef';
132
- it('adds the coins', () => {
133
- expect(
134
- applyValue(balances[address], {
135
- coins: 50
136
- })
137
- ).toEqual({
138
- assets: {
139
- 12: 10n,
140
- 34: 20n
141
- },
142
- coins: 550
143
- });
144
- });
145
- it('subtracts the coins', () => {
146
- expect(applyValue(balances[address], { coins: 50 }, true)).toEqual({
147
- assets: {
148
- 12: 10n,
149
- 34: 20n
150
- },
151
- coins: 450
152
- });
153
- });
154
- });
155
- describe('guarding against negative balances', () => {
156
- const address = 'cd';
157
- it('throws if the balance calculated for coins is less than 0', () => {
158
- expect(() =>
159
- applyValue(
160
- balances[address],
161
- {
162
- coins: 500
163
- },
164
- true
165
- )
166
- ).toThrow();
167
- });
168
- it('throws if the balance calculated for assets is less than 0', () => {
169
- expect(() =>
170
- applyValue(
171
- balances[address],
172
- {
173
- assets: {
174
- 12: 20n
175
- },
176
- coins: 1
177
- },
178
- true
179
- )
180
- ).toThrow();
181
- });
182
- });
183
- });
184
- });
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "paths": {
6
- "@src/*": ["../src/*"]
7
- }
8
- },
9
- "references": [{ "path": "../src" }]
10
- }