starknet 3.18.0 → 3.19.0

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 (163) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +1 -0
  3. package/__mocks__/typedDataStructArrayExample.json +44 -0
  4. package/__tests__/account.test.ts +11 -56
  5. package/__tests__/contract.test.ts +11 -49
  6. package/__tests__/defaultProvider.test.ts +321 -0
  7. package/__tests__/fixtures.ts +32 -11
  8. package/__tests__/rpcProvider.test.ts +17 -0
  9. package/__tests__/sequencerProvider.test.ts +45 -0
  10. package/__tests__/utils/typedData.test.ts +24 -0
  11. package/account/default.d.ts +54 -77
  12. package/account/default.js +271 -596
  13. package/account/index.js +18 -31
  14. package/account/interface.d.ts +66 -95
  15. package/account/interface.js +20 -30
  16. package/constants.d.ts +17 -19
  17. package/constants.js +2038 -2059
  18. package/contract/contractFactory.d.ts +25 -29
  19. package/contract/contractFactory.js +94 -210
  20. package/contract/default.d.ts +117 -146
  21. package/contract/default.js +582 -776
  22. package/contract/index.js +19 -32
  23. package/contract/interface.d.ts +72 -92
  24. package/contract/interface.js +6 -5
  25. package/dist/account/default.d.ts +5 -9
  26. package/dist/account/default.js +35 -169
  27. package/dist/account/interface.d.ts +3 -15
  28. package/dist/contract/contractFactory.js +4 -4
  29. package/dist/contract/default.d.ts +3 -3
  30. package/dist/contract/default.js +3 -2
  31. package/dist/contract/interface.d.ts +2 -2
  32. package/dist/provider/default.d.ts +18 -134
  33. package/dist/provider/default.js +47 -410
  34. package/dist/provider/index.d.ts +2 -0
  35. package/dist/provider/index.js +2 -0
  36. package/dist/provider/interface.d.ts +45 -50
  37. package/dist/provider/rpc.d.ts +57 -0
  38. package/dist/provider/rpc.js +364 -0
  39. package/dist/provider/sequencer.d.ts +66 -0
  40. package/dist/provider/sequencer.js +443 -0
  41. package/dist/types/account.d.ts +2 -3
  42. package/dist/types/api/index.d.ts +16 -0
  43. package/dist/types/api/index.js +18 -0
  44. package/dist/types/api/rpc.d.ts +221 -0
  45. package/dist/types/{api.js → api/rpc.js} +0 -0
  46. package/dist/types/api/sequencer.d.ts +289 -0
  47. package/dist/types/api/sequencer.js +2 -0
  48. package/dist/types/index.d.ts +3 -1
  49. package/dist/types/index.js +15 -1
  50. package/dist/types/lib.d.ts +3 -1
  51. package/dist/types/provider.d.ts +86 -0
  52. package/dist/types/provider.js +2 -0
  53. package/dist/utils/provider.d.ts +4 -0
  54. package/dist/utils/provider.js +38 -0
  55. package/dist/utils/responseParser/index.d.ts +11 -0
  56. package/dist/utils/responseParser/index.js +9 -0
  57. package/dist/utils/responseParser/rpc.d.ts +13 -0
  58. package/dist/utils/responseParser/rpc.js +96 -0
  59. package/dist/utils/responseParser/sequencer.d.ts +13 -0
  60. package/dist/utils/responseParser/sequencer.js +124 -0
  61. package/dist/utils/typedData/index.js +14 -0
  62. package/index.js +42 -75
  63. package/package.json +1 -1
  64. package/provider/default.d.ts +21 -175
  65. package/provider/default.js +139 -703
  66. package/provider/errors.d.ts +4 -4
  67. package/provider/errors.js +30 -40
  68. package/provider/index.d.ts +2 -0
  69. package/provider/index.js +22 -33
  70. package/provider/interface.d.ts +104 -131
  71. package/provider/interface.js +6 -5
  72. package/provider/rpc.d.ts +57 -0
  73. package/provider/rpc.js +364 -0
  74. package/provider/sequencer.d.ts +66 -0
  75. package/provider/sequencer.js +443 -0
  76. package/provider/utils.d.ts +7 -9
  77. package/provider/utils.js +39 -44
  78. package/signer/default.d.ts +5 -9
  79. package/signer/default.js +72 -177
  80. package/signer/index.js +18 -31
  81. package/signer/interface.d.ts +29 -33
  82. package/signer/interface.js +6 -5
  83. package/src/account/default.ts +26 -146
  84. package/src/account/interface.ts +5 -20
  85. package/src/contract/contractFactory.ts +3 -6
  86. package/src/contract/default.ts +6 -4
  87. package/src/contract/interface.ts +2 -2
  88. package/src/provider/default.ts +63 -394
  89. package/src/provider/index.ts +2 -0
  90. package/src/provider/interface.ts +68 -63
  91. package/src/provider/rpc.ts +300 -0
  92. package/src/provider/sequencer.ts +384 -0
  93. package/src/types/account.ts +2 -3
  94. package/src/types/api/index.ts +17 -0
  95. package/src/types/api/rpc.ts +247 -0
  96. package/src/types/api/sequencer.ts +331 -0
  97. package/src/types/index.ts +3 -1
  98. package/src/types/lib.ts +3 -1
  99. package/src/types/provider.ts +108 -0
  100. package/src/utils/provider.ts +28 -0
  101. package/src/utils/responseParser/index.ts +28 -0
  102. package/src/utils/responseParser/rpc.ts +93 -0
  103. package/src/utils/responseParser/sequencer.ts +127 -0
  104. package/src/utils/typedData/index.ts +18 -0
  105. package/types/account.d.ts +5 -7
  106. package/types/account.js +2 -2
  107. package/types/api/index.d.ts +16 -0
  108. package/types/api/index.js +18 -0
  109. package/types/api/rpc.d.ts +221 -0
  110. package/types/api/rpc.js +2 -0
  111. package/types/api/sequencer.d.ts +289 -0
  112. package/types/api/sequencer.js +2 -0
  113. package/types/contract.d.ts +1 -1
  114. package/types/contract.js +2 -2
  115. package/types/index.d.ts +3 -1
  116. package/types/index.js +35 -34
  117. package/types/lib.d.ts +36 -41
  118. package/types/lib.js +2 -2
  119. package/types/provider.d.ts +86 -0
  120. package/types/provider.js +2 -0
  121. package/types/signer.d.ts +2 -2
  122. package/types/signer.js +2 -2
  123. package/utils/address.js +26 -37
  124. package/utils/ellipticCurve.d.ts +1 -6
  125. package/utils/ellipticCurve.js +73 -137
  126. package/utils/encode.js +49 -85
  127. package/utils/hash.d.ts +4 -31
  128. package/utils/hash.js +76 -141
  129. package/utils/json.d.ts +13 -45
  130. package/utils/json.js +15 -22
  131. package/utils/number.d.ts +2 -9
  132. package/utils/number.js +47 -81
  133. package/utils/provider.d.ts +4 -0
  134. package/utils/provider.js +38 -0
  135. package/utils/responseParser/index.d.ts +11 -0
  136. package/utils/responseParser/index.js +9 -0
  137. package/utils/responseParser/rpc.d.ts +13 -0
  138. package/utils/responseParser/rpc.js +96 -0
  139. package/utils/responseParser/sequencer.d.ts +13 -0
  140. package/utils/responseParser/sequencer.js +124 -0
  141. package/utils/shortString.js +13 -21
  142. package/utils/stark.d.ts +0 -1
  143. package/utils/stark.js +59 -93
  144. package/utils/transaction.d.ts +3 -6
  145. package/utils/transaction.js +50 -81
  146. package/utils/typedData/index.d.ts +3 -15
  147. package/utils/typedData/index.js +109 -157
  148. package/utils/typedData/types.d.ts +9 -9
  149. package/utils/typedData/types.js +2 -2
  150. package/utils/typedData/utils.js +6 -6
  151. package/utils/uint256.d.ts +5 -5
  152. package/utils/uint256.js +16 -26
  153. package/www/docs/API/account.md +3 -4
  154. package/www/docs/API/contract.md +2 -2
  155. package/www/docs/API/contractFactory.md +2 -2
  156. package/www/docs/API/provider.md +185 -74
  157. package/www/guides/account.md +1 -8
  158. package/www/guides/erc20.md +3 -0
  159. package/__tests__/provider.test.ts +0 -168
  160. package/dist/types/api.d.ts +0 -261
  161. package/src/types/api.ts +0 -303
  162. package/types/api.d.ts +0 -287
  163. package/types/api.js +0 -2
@@ -10,11 +10,7 @@ export * from './types';
10
10
  * @param {string[]} [dependencies]
11
11
  * @return {string[]}
12
12
  */
13
- export declare const getDependencies: (
14
- typedData: TypedData,
15
- type: string,
16
- dependencies?: string[]
17
- ) => string[];
13
+ export declare const getDependencies: (typedData: TypedData, type: string, dependencies?: string[]) => string[];
18
14
  /**
19
15
  * Encode a type to a string. All dependant types are alphabetically sorted.
20
16
  *
@@ -39,11 +35,7 @@ export declare const getTypeHash: (typedData: TypedData, type: string) => string
39
35
  * @param {string} type
40
36
  * @param {Record<string, any>} data
41
37
  */
42
- export declare const encodeData: <T extends TypedData>(
43
- typedData: T,
44
- type: string,
45
- data: T['message']
46
- ) => string[][];
38
+ export declare const encodeData: <T extends TypedData>(typedData: T, type: string, data: T["message"]) => string[][];
47
39
  /**
48
40
  * Get encoded data as a hash. The data should be a key -> value object with all the required values. All dependant
49
41
  * types are automatically encoded.
@@ -53,11 +45,7 @@ export declare const encodeData: <T extends TypedData>(
53
45
  * @param {Record<string, any>} data
54
46
  * @return {Buffer}
55
47
  */
56
- export declare const getStructHash: <T extends TypedData>(
57
- typedData: T,
58
- type: string,
59
- data: T['message']
60
- ) => string;
48
+ export declare const getStructHash: <T extends TypedData>(typedData: T, type: string, data: T["message"]) => string;
61
49
  /**
62
50
  * Get the EIP-191 encoded message to sign, from the typedData object. If `hash` is enabled, the message will be hashed
63
51
  * with Keccak256.
@@ -1,87 +1,60 @@
1
- 'use strict';
2
- var __createBinding =
3
- (this && this.__createBinding) ||
4
- (Object.create
5
- ? function (o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = {
10
- enumerable: true,
11
- get: function () {
12
- return m[k];
13
- },
14
- };
15
- }
16
- Object.defineProperty(o, k2, desc);
17
- }
18
- : function (o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- });
22
- var __exportStar =
23
- (this && this.__exportStar) ||
24
- function (m, exports) {
25
- for (var p in m)
26
- if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p))
27
- __createBinding(exports, m, p);
28
- };
29
- var __read =
30
- (this && this.__read) ||
31
- function (o, n) {
32
- var m = typeof Symbol === 'function' && o[Symbol.iterator];
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __read = (this && this.__read) || function (o, n) {
17
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
33
18
  if (!m) return o;
34
- var i = m.call(o),
35
- r,
36
- ar = [],
37
- e;
19
+ var i = m.call(o), r, ar = [], e;
38
20
  try {
39
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
40
- } catch (error) {
41
- e = { error: error };
42
- } finally {
43
- try {
44
- if (r && !r.done && (m = i['return'])) m.call(i);
45
- } finally {
46
- if (e) throw e.error;
47
- }
21
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
22
+ }
23
+ catch (error) { e = { error: error }; }
24
+ finally {
25
+ try {
26
+ if (r && !r.done && (m = i["return"])) m.call(i);
27
+ }
28
+ finally { if (e) throw e.error; }
48
29
  }
49
30
  return ar;
50
- };
51
- var __spreadArray =
52
- (this && this.__spreadArray) ||
53
- function (to, from, pack) {
54
- if (pack || arguments.length === 2)
55
- for (var i = 0, l = from.length, ar; i < l; i++) {
31
+ };
32
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
33
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
34
  if (ar || !(i in from)) {
57
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
- ar[i] = from[i];
35
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
36
+ ar[i] = from[i];
59
37
  }
60
- }
38
+ }
61
39
  return to.concat(ar || Array.prototype.slice.call(from));
62
- };
63
- Object.defineProperty(exports, '__esModule', { value: true });
64
- exports.getMessageHash =
65
- exports.getStructHash =
66
- exports.encodeData =
67
- exports.getTypeHash =
68
- exports.encodeType =
69
- exports.getDependencies =
70
- void 0;
71
- var hash_1 = require('../hash');
72
- var number_1 = require('../number');
73
- var shortString_1 = require('../shortString');
74
- var utils_1 = require('./utils');
75
- __exportStar(require('./types'), exports);
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.getMessageHash = exports.getStructHash = exports.encodeData = exports.getTypeHash = exports.encodeType = exports.getDependencies = void 0;
43
+ var hash_1 = require("../hash");
44
+ var number_1 = require("../number");
45
+ var shortString_1 = require("../shortString");
46
+ var utils_1 = require("./utils");
47
+ __exportStar(require("./types"), exports);
76
48
  function getHex(value) {
77
- try {
78
- return (0, number_1.toHex)((0, number_1.toBN)(value));
79
- } catch (e) {
80
- if (typeof value === 'string') {
81
- return (0, number_1.toHex)((0, number_1.toBN)((0, shortString_1.encodeShortString)(value)));
49
+ try {
50
+ return (0, number_1.toHex)((0, number_1.toBN)(value));
51
+ }
52
+ catch (e) {
53
+ if (typeof value === 'string') {
54
+ return (0, number_1.toHex)((0, number_1.toBN)((0, shortString_1.encodeShortString)(value)));
55
+ }
56
+ throw new Error("Invalid BigNumberish: ".concat(value));
82
57
  }
83
- throw new Error('Invalid BigNumberish: '.concat(value));
84
- }
85
58
  }
86
59
  /**
87
60
  * Get the dependencies of a struct type. If a struct has the same dependency multiple times, it's only included once
@@ -93,36 +66,25 @@ function getHex(value) {
93
66
  * @return {string[]}
94
67
  */
95
68
  var getDependencies = function (typedData, type, dependencies) {
96
- if (dependencies === void 0) {
97
- dependencies = [];
98
- }
99
- // `getDependencies` is called by most other functions, so we validate the JSON schema here
100
- if (!(0, utils_1.validateTypedData)(typedData)) {
101
- throw new Error('Typed data does not match JSON schema');
102
- }
103
- if (dependencies.includes(type)) {
104
- return dependencies;
105
- }
106
- if (!typedData.types[type]) {
107
- return dependencies;
108
- }
109
- return __spreadArray(
110
- [type],
111
- __read(
112
- typedData.types[type].reduce(function (previous, t) {
113
- return __spreadArray(
114
- __spreadArray([], __read(previous), false),
115
- __read(
116
- (0, exports.getDependencies)(typedData, t.type, previous).filter(function (dependency) {
117
- return !previous.includes(dependency);
118
- })
119
- ),
120
- false
121
- );
122
- }, [])
123
- ),
124
- false
125
- );
69
+ if (dependencies === void 0) { dependencies = []; }
70
+ // `getDependencies` is called by most other functions, so we validate the JSON schema here
71
+ if (!(0, utils_1.validateTypedData)(typedData)) {
72
+ throw new Error('Typed data does not match JSON schema');
73
+ }
74
+ // Include pointers (struct arrays)
75
+ if (type[type.length - 1] === '*') {
76
+ // eslint-disable-next-line no-param-reassign
77
+ type = type.slice(0, -1);
78
+ }
79
+ if (dependencies.includes(type)) {
80
+ return dependencies;
81
+ }
82
+ if (!typedData.types[type]) {
83
+ return dependencies;
84
+ }
85
+ return __spreadArray([
86
+ type
87
+ ], __read(typedData.types[type].reduce(function (previous, t) { return __spreadArray(__spreadArray([], __read(previous), false), __read((0, exports.getDependencies)(typedData, t.type, previous).filter(function (dependency) { return !previous.includes(dependency); })), false); }, [])), false);
126
88
  };
127
89
  exports.getDependencies = getDependencies;
128
90
  /**
@@ -133,20 +95,13 @@ exports.getDependencies = getDependencies;
133
95
  * @return {string}
134
96
  */
135
97
  var encodeType = function (typedData, type) {
136
- var _a = __read((0, exports.getDependencies)(typedData, type)),
137
- primary = _a[0],
138
- dependencies = _a.slice(1);
139
- var types = __spreadArray([primary], __read(dependencies.sort()), false);
140
- return types
141
- .map(function (dependency) {
142
- return ''.concat(dependency, '(').concat(
143
- typedData.types[dependency].map(function (t) {
144
- return ''.concat(t.name, ':').concat(t.type);
145
- }),
146
- ')'
147
- );
98
+ var _a = __read((0, exports.getDependencies)(typedData, type)), primary = _a[0], dependencies = _a.slice(1);
99
+ var types = __spreadArray([primary], __read(dependencies.sort()), false);
100
+ return types
101
+ .map(function (dependency) {
102
+ return "".concat(dependency, "(").concat(typedData.types[dependency].map(function (t) { return "".concat(t.name, ":").concat(t.type); }), ")");
148
103
  })
149
- .join('');
104
+ .join('');
150
105
  };
151
106
  exports.encodeType = encodeType;
152
107
  /**
@@ -157,7 +112,7 @@ exports.encodeType = encodeType;
157
112
  * @return {string}
158
113
  */
159
114
  var getTypeHash = function (typedData, type) {
160
- return (0, hash_1.getSelectorFromName)((0, exports.encodeType)(typedData, type));
115
+ return (0, hash_1.getSelectorFromName)((0, exports.encodeType)(typedData, type));
161
116
  };
162
117
  exports.getTypeHash = getTypeHash;
163
118
  /**
@@ -170,14 +125,23 @@ exports.getTypeHash = getTypeHash;
170
125
  * @returns {[string, string]}
171
126
  */
172
127
  var encodeValue = function (typedData, type, data) {
173
- if (typedData.types[type]) {
174
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
175
- return [type, (0, exports.getStructHash)(typedData, type, data)];
176
- }
177
- if (type === 'felt*') {
178
- return ['felt*', (0, hash_1.computeHashOnElements)(data)];
179
- }
180
- return [type, getHex(data)];
128
+ if (typedData.types[type]) {
129
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
130
+ return [type, (0, exports.getStructHash)(typedData, type, data)];
131
+ }
132
+ if (Object.keys(typedData.types)
133
+ .map(function (x) { return "".concat(x, "*"); })
134
+ .includes(type)) {
135
+ var structHashes = data.map(function (struct) {
136
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
137
+ return (0, exports.getStructHash)(typedData, type.slice(0, -1), struct);
138
+ });
139
+ return [type, (0, hash_1.computeHashOnElements)(structHashes)];
140
+ }
141
+ if (type === 'felt*') {
142
+ return ['felt*', (0, hash_1.computeHashOnElements)(data)];
143
+ }
144
+ return [type, getHex(data)];
181
145
  };
182
146
  /**
183
147
  * Encode the data to an ABI encoded Buffer. The data should be a key -> value object with all the required values. All
@@ -188,31 +152,19 @@ var encodeValue = function (typedData, type, data) {
188
152
  * @param {Record<string, any>} data
189
153
  */
190
154
  var encodeData = function (typedData, type, data) {
191
- var _a = __read(
192
- typedData.types[type].reduce(
193
- function (_a, field) {
194
- var _b = __read(_a, 2),
195
- ts = _b[0],
196
- vs = _b[1];
197
- if (data[field.name] === undefined || data[field.name] === null) {
155
+ var _a = __read(typedData.types[type].reduce(function (_a, field) {
156
+ var _b = __read(_a, 2), ts = _b[0], vs = _b[1];
157
+ if (data[field.name] === undefined || data[field.name] === null) {
198
158
  throw new Error("Cannot encode data: missing data for '".concat(field.name, "'"));
199
- }
200
- var value = data[field.name];
201
- var _c = __read(encodeValue(typedData, field.type, value), 2),
202
- t = _c[0],
203
- encodedValue = _c[1];
204
- return [
159
+ }
160
+ var value = data[field.name];
161
+ var _c = __read(encodeValue(typedData, field.type, value), 2), t = _c[0], encodedValue = _c[1];
162
+ return [
205
163
  __spreadArray(__spreadArray([], __read(ts), false), [t], false),
206
164
  __spreadArray(__spreadArray([], __read(vs), false), [encodedValue], false),
207
- ];
208
- },
209
- [['felt'], [(0, exports.getTypeHash)(typedData, type)]]
210
- ),
211
- 2
212
- ),
213
- types = _a[0],
214
- values = _a[1];
215
- return [types, values];
165
+ ];
166
+ }, [['felt'], [(0, exports.getTypeHash)(typedData, type)]]), 2), types = _a[0], values = _a[1];
167
+ return [types, values];
216
168
  };
217
169
  exports.encodeData = encodeData;
218
170
  /**
@@ -225,7 +177,7 @@ exports.encodeData = encodeData;
225
177
  * @return {Buffer}
226
178
  */
227
179
  var getStructHash = function (typedData, type, data) {
228
- return (0, hash_1.computeHashOnElements)((0, exports.encodeData)(typedData, type, data)[1]);
180
+ return (0, hash_1.computeHashOnElements)((0, exports.encodeData)(typedData, type, data)[1]);
229
181
  };
230
182
  exports.getStructHash = getStructHash;
231
183
  /**
@@ -237,12 +189,12 @@ exports.getStructHash = getStructHash;
237
189
  * @return {string}
238
190
  */
239
191
  var getMessageHash = function (typedData, account) {
240
- var message = [
241
- (0, shortString_1.encodeShortString)('StarkNet Message'),
242
- (0, exports.getStructHash)(typedData, 'StarkNetDomain', typedData.domain),
243
- account,
244
- (0, exports.getStructHash)(typedData, typedData.primaryType, typedData.message),
245
- ];
246
- return (0, hash_1.computeHashOnElements)(message);
192
+ var message = [
193
+ (0, shortString_1.encodeShortString)('StarkNet Message'),
194
+ (0, exports.getStructHash)(typedData, 'StarkNetDomain', typedData.domain),
195
+ account,
196
+ (0, exports.getStructHash)(typedData, typedData.primaryType, typedData.message),
197
+ ];
198
+ return (0, hash_1.computeHashOnElements)(message);
247
199
  };
248
200
  exports.getMessageHash = getMessageHash;
@@ -5,23 +5,23 @@
5
5
  * standard.
6
6
  */
7
7
  export interface StarkNetType {
8
- name: string;
9
- type: 'felt' | 'felt*' | string;
8
+ name: string;
9
+ type: 'felt' | 'felt*' | string;
10
10
  }
11
11
  /**
12
12
  * The EIP712 domain struct. Any of these fields are optional, but it must contain at least one field.
13
13
  */
14
14
  export interface StarkNetDomain extends Record<string, unknown> {
15
- name?: string;
16
- version?: string;
17
- chainId?: string | number;
15
+ name?: string;
16
+ version?: string;
17
+ chainId?: string | number;
18
18
  }
19
19
  /**
20
20
  * The complete typed data, with all the structs, domain data, primary type of the message, and the message itself.
21
21
  */
22
22
  export interface TypedData {
23
- types: Record<string, StarkNetType[]>;
24
- primaryType: string;
25
- domain: StarkNetDomain;
26
- message: Record<string, unknown>;
23
+ types: Record<string, StarkNetType[]>;
24
+ primaryType: string;
25
+ domain: StarkNetDomain;
26
+ message: Record<string, unknown>;
27
27
  }
@@ -1,2 +1,2 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateTypedData = void 0;
4
4
  /**
5
5
  * Validates that `data` matches the EIP-712 JSON schema.
@@ -8,9 +8,9 @@ exports.validateTypedData = void 0;
8
8
  * @return {boolean}
9
9
  */
10
10
  var validateTypedData = function (data) {
11
- var typedData = data;
12
- // Validate that the data matches the EIP-712 JSON schema
13
- var valid = Boolean(typedData.types && typedData.primaryType && typedData.message);
14
- return valid;
11
+ var typedData = data;
12
+ // Validate that the data matches the EIP-712 JSON schema
13
+ var valid = Boolean(typedData.types && typedData.primaryType && typedData.message);
14
+ return valid;
15
15
  };
16
16
  exports.validateTypedData = validateTypedData;
@@ -1,11 +1,11 @@
1
1
  /// <reference types="bn.js" />
2
2
  import { BigNumberish } from './number';
3
3
  export interface Uint256 {
4
- low: BigNumberish;
5
- high: BigNumberish;
4
+ low: BigNumberish;
5
+ high: BigNumberish;
6
6
  }
7
- export declare function uint256ToBN(uint256: Uint256): import('bn.js');
8
- export declare const UINT_128_MAX: import('bn.js');
9
- export declare const UINT_256_MAX: import('bn.js');
7
+ export declare function uint256ToBN(uint256: Uint256): import("bn.js");
8
+ export declare const UINT_128_MAX: import("bn.js");
9
+ export declare const UINT_256_MAX: import("bn.js");
10
10
  export declare function isUint256(bn: BigNumberish): boolean;
11
11
  export declare function bnToUint256(bignumber: BigNumberish): Uint256;
package/utils/uint256.js CHANGED
@@ -1,38 +1,28 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.bnToUint256 =
4
- exports.isUint256 =
5
- exports.UINT_256_MAX =
6
- exports.UINT_128_MAX =
7
- exports.uint256ToBN =
8
- void 0;
9
- var encode_1 = require('./encode');
10
- var number_1 = require('./number');
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bnToUint256 = exports.isUint256 = exports.UINT_256_MAX = exports.UINT_128_MAX = exports.uint256ToBN = void 0;
4
+ var encode_1 = require("./encode");
5
+ var number_1 = require("./number");
11
6
  // function to convert Uint256 to BN
12
7
  function uint256ToBN(uint256) {
13
- return (0, number_1.toBN)(uint256.high)
14
- .shln(128)
15
- .add((0, number_1.toBN)(uint256.low));
8
+ return (0, number_1.toBN)(uint256.high).shln(128).add((0, number_1.toBN)(uint256.low));
16
9
  }
17
10
  exports.uint256ToBN = uint256ToBN;
18
- exports.UINT_128_MAX = (0, number_1.toBN)(1)
19
- .shln(128)
20
- .sub((0, number_1.toBN)(1));
21
- exports.UINT_256_MAX = (0, number_1.toBN)(1)
22
- .shln(256)
23
- .sub((0, number_1.toBN)(1));
11
+ exports.UINT_128_MAX = (0, number_1.toBN)(1).shln(128).sub((0, number_1.toBN)(1));
12
+ exports.UINT_256_MAX = (0, number_1.toBN)(1).shln(256).sub((0, number_1.toBN)(1));
24
13
  // function to check if BN is smaller or equal 2**256-1
25
14
  function isUint256(bn) {
26
- return (0, number_1.toBN)(bn).lte(exports.UINT_256_MAX);
15
+ return (0, number_1.toBN)(bn).lte(exports.UINT_256_MAX);
27
16
  }
28
17
  exports.isUint256 = isUint256;
29
18
  // function to convert BN to Uint256
30
19
  function bnToUint256(bignumber) {
31
- var bn = (0, number_1.toBN)(bignumber);
32
- if (!isUint256(bn)) throw new Error('Number is too large');
33
- return {
34
- low: (0, encode_1.addHexPrefix)(bn.maskn(128).toString(16)),
35
- high: (0, encode_1.addHexPrefix)(bn.shrn(128).toString(16)),
36
- };
20
+ var bn = (0, number_1.toBN)(bignumber);
21
+ if (!isUint256(bn))
22
+ throw new Error('Number is too large');
23
+ return {
24
+ low: (0, encode_1.addHexPrefix)(bn.maskn(128).toString(16)),
25
+ high: (0, encode_1.addHexPrefix)(bn.shrn(128).toString(16)),
26
+ };
37
27
  }
38
28
  exports.bnToUint256 = bnToUint256;
@@ -43,8 +43,9 @@ The _options_ object may include any of:
43
43
 
44
44
  ```
45
45
  {
46
- amount: number;
47
- unit: string;
46
+ overall_fee: BN;
47
+ gas_consumed?: BN;
48
+ gas_price?: BN;
48
49
  }
49
50
  ```
50
51
 
@@ -64,9 +65,7 @@ The _transactionsDetail_ object may include any of:
64
65
 
65
66
  ```
66
67
  {
67
- code: 'TRANSACTION_RECEIVED';
68
68
  transaction_hash: string;
69
- address?: string;
70
69
  };
71
70
  ```
72
71
 
@@ -22,9 +22,9 @@ contract.**address** => _string_
22
22
 
23
23
  The address the contract was constructed/connected with
24
24
 
25
- contract.**providerOrAcount** => _Provider | Account_
25
+ contract.**providerOrAcount** => ProviderInterface | AccountInterface_
26
26
 
27
- Provider or Account that are used to interact with the network
27
+ Provider or account that are used to interact with the network
28
28
 
29
29
  contract.**deployTransactionHash** => _string | null_
30
30
 
@@ -26,9 +26,9 @@ contractFactory.**compiledContract** => _CompiledContract_;
26
26
 
27
27
  The compiled contract the contractFactory was constructed with
28
28
 
29
- contractFactory.**providerOrAccount** => _Provider | Account_;
29
+ contractFactory.**providerOrAccount** => _ProviderInterface | AccountInterface_;
30
30
 
31
- Provider or Account that are used to interact with the network
31
+ Provider or account that are used to interact with the network
32
32
 
33
33
  ## Methods
34
34