dequanto 0.2.40 → 0.2.42

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 (33) hide show
  1. package/lib/cjs/contracts/deploy/Deployments.js +132 -0
  2. package/lib/cjs/contracts/deploy/Deployments.js.map +1 -1
  3. package/lib/cjs/contracts/deploy/storage/DeploymentsStorage.js +5 -1
  4. package/lib/cjs/contracts/deploy/storage/DeploymentsStorage.js.map +1 -1
  5. package/lib/cjs/txs/TxWriter.js +19 -0
  6. package/lib/cjs/txs/TxWriter.js.map +1 -1
  7. package/lib/cjs/txs/agents/BatchAgent.js +77 -2
  8. package/lib/cjs/txs/agents/BatchAgent.js.map +1 -1
  9. package/lib/cjs/utils/$address.js.map +1 -1
  10. package/lib/cjs/utils/$require.js.map +1 -1
  11. package/lib/esm/contracts/deploy/Deployments.js.map +1 -1
  12. package/lib/esm/contracts/deploy/Deployments.mjs +132 -0
  13. package/lib/esm/contracts/deploy/storage/DeploymentsStorage.js.map +1 -1
  14. package/lib/esm/contracts/deploy/storage/DeploymentsStorage.mjs +5 -1
  15. package/lib/esm/txs/TxWriter.js.map +1 -1
  16. package/lib/esm/txs/TxWriter.mjs +19 -0
  17. package/lib/esm/txs/agents/BatchAgent.js.map +1 -1
  18. package/lib/esm/txs/agents/BatchAgent.mjs +74 -2
  19. package/lib/esm/utils/$address.js.map +1 -1
  20. package/lib/esm/utils/$require.js.map +1 -1
  21. package/lib/types/contracts/deploy/Deployments.d.ts +9 -0
  22. package/lib/types/contracts/deploy/storage/DeploymentsStorage.d.ts +2 -0
  23. package/lib/types/txs/TxWriter.d.ts +1 -0
  24. package/lib/types/txs/agents/BatchAgent.d.ts +7 -2
  25. package/lib/types/utils/$address.d.ts +1 -1
  26. package/lib/types/utils/$require.d.ts +10 -9
  27. package/package.json +1 -1
  28. package/src/contracts/deploy/Deployments.ts +167 -16
  29. package/src/contracts/deploy/storage/DeploymentsStorage.ts +7 -1
  30. package/src/txs/TxWriter.ts +22 -0
  31. package/src/txs/agents/BatchAgent.ts +85 -6
  32. package/src/utils/$address.ts +1 -1
  33. package/src/utils/$require.ts +12 -11
@@ -2,10 +2,11 @@ import { IToken } from '@dequanto/models/IToken';
2
2
  import { TAddress } from '@dequanto/models/TAddress';
3
3
  import { $is } from './$is';
4
4
  import { $address } from './$address';
5
+ import { TEth } from '@dequanto/models/TEth';
5
6
 
6
7
  const $Array = Array;
7
8
  export namespace $require {
8
- export function Number <T> (val: T, message: string = '', opts?: { min?: T, max?: T}): T {
9
+ export function Number <T> (val: T, message: string = '', opts?: { min?: T, max?: T}): number {
9
10
  if (typeof val !== 'number') {
10
11
  throw new Error(`Expects number type, got ${typeof val} ${val}. ${message}`);
11
12
  }
@@ -20,7 +21,7 @@ export namespace $require {
20
21
  }
21
22
  return val;
22
23
  }
23
- export function BigInt<T> (val: T, message: string = '', opts?: { min?: T, max?: T}): T {
24
+ export function BigInt<T> (val: T, message: string = '', opts?: { min?: T, max?: T}): bigint {
24
25
  if (typeof val !== 'bigint') {
25
26
  throw new Error(`Expects bigint type, got ${typeof val} (${val}). ${message}`);
26
27
  }
@@ -32,35 +33,35 @@ export namespace $require {
32
33
  }
33
34
  return val;
34
35
  }
35
- export function Numeric<T>(val: T, message: string = '', opts?: { min?: T, max?: T}): T {
36
+ export function Numeric<T>(val: T, message: string = '', opts?: { min?: T, max?: T}): NonNullable<T> {
36
37
  if (typeof val === 'number') {
37
- return Number(val, message, opts);
38
+ return Number(val, message, opts) as any;
38
39
  }
39
40
  if (typeof val === 'bigint') {
40
- return BigInt(val, message, opts);
41
+ return BigInt(val, message, opts) as any;
41
42
  }
42
43
  throw new Error(`Expects numeric type, got ${typeof val}. ${message}`);
43
44
  }
44
45
 
45
- export function Function<T>(val: T, message: string): T {
46
+ export function Function<T>(val: T, message: string): NonNullable<T> {
46
47
  if (typeof val !== 'function') {
47
48
  throw new Error(`Value is not a function ${message}`);
48
49
  }
49
50
  return val;
50
51
  }
51
- export function Array<T>(val: T, message: string): T {
52
+ export function Array<T>(val: T, message: string): NonNullable<T> {
52
53
  if ($Array.isArray(val) === false) {
53
54
  throw new Error(`Value is not a function ${message}`);
54
55
  }
55
56
  return val;
56
57
  }
57
- export function String<T>(val: T, message: string): T {
58
+ export function String<T>(val: T, message: string): NonNullable<T> {
58
59
  if (typeof val !== 'string') {
59
60
  throw new Error(`Value ${val} is not a string ${message}`);
60
61
  }
61
62
  return val;
62
63
  }
63
- export function notNull<T> (val: T, message: string, ...logs): T {
64
+ export function notNull<T> (val: T, message: string, ...logs): NonNullable<T> {
64
65
  if (val == null) {
65
66
  logs?.forEach(log => console.error(log));
66
67
  throw new Error(`Value is undefined. ${message}`);
@@ -74,7 +75,7 @@ export namespace $require {
74
75
  }
75
76
  return val;
76
77
  }
77
- export function notEmpty<T extends string | Array<any> | { length: number }> (val: T, message: string): T {
78
+ export function notEmpty<T extends string | Array<any> | { length: number }> (val: T, message: string): NonNullable<T> {
78
79
  if (val == null) {
79
80
  throw new Error(`Value is undefined. ${message}`);
80
81
  }
@@ -170,7 +171,7 @@ export namespace $require {
170
171
  return val;
171
172
  }
172
173
 
173
- export function Hex (val: string, message: string = ''): string {
174
+ export function Hex (val: string, message: string = ''): TEth.Hex {
174
175
  if ($is.Hex(val) === false) {
175
176
  throw new Error(`Value ${val} is not a valid hex value. ${message}`);
176
177
  }