starknet 3.12.2 → 3.13.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.
Files changed (78) hide show
  1. package/.github/workflows/pr.yml +3 -0
  2. package/.github/workflows/release.yml +4 -0
  3. package/CHANGELOG.md +38 -0
  4. package/__mocks__/Account.json +25468 -0
  5. package/__tests__/account.test.ts +102 -65
  6. package/__tests__/contract.test.ts +23 -65
  7. package/__tests__/fixtures.ts +21 -1
  8. package/__tests__/provider.test.ts +20 -1
  9. package/account/default.d.ts +2 -9
  10. package/account/index.js +10 -6
  11. package/account/interface.d.ts +5 -3
  12. package/contract/default.d.ts +1 -1
  13. package/contract/default.js +20 -21
  14. package/contract/index.js +10 -6
  15. package/dist/account/default.d.ts +2 -6
  16. package/dist/account/index.js +5 -1
  17. package/dist/account/interface.d.ts +3 -3
  18. package/dist/contract/default.d.ts +1 -1
  19. package/dist/contract/default.js +18 -18
  20. package/dist/contract/index.js +5 -1
  21. package/dist/index.js +5 -1
  22. package/dist/provider/default.d.ts +3 -3
  23. package/dist/provider/default.js +10 -8
  24. package/dist/provider/index.js +5 -1
  25. package/dist/provider/interface.d.ts +9 -1
  26. package/dist/provider/utils.js +5 -5
  27. package/dist/signer/index.js +5 -1
  28. package/dist/types/account.d.ts +6 -0
  29. package/dist/types/api.d.ts +1 -1
  30. package/dist/types/index.d.ts +1 -0
  31. package/dist/types/index.js +6 -1
  32. package/dist/utils/ellipticCurve.js +1 -1
  33. package/dist/utils/encode.js +1 -1
  34. package/dist/utils/hash.js +1 -1
  35. package/dist/utils/number.js +8 -4
  36. package/dist/utils/shortString.js +2 -2
  37. package/dist/utils/typedData/index.d.ts +2 -36
  38. package/dist/utils/typedData/index.js +8 -4
  39. package/dist/utils/typedData/types.d.ts +15 -70
  40. package/dist/utils/typedData/types.js +0 -45
  41. package/dist/utils/typedData/utils.d.ts +2 -18
  42. package/dist/utils/typedData/utils.js +4 -3
  43. package/index.js +10 -6
  44. package/package.json +30 -29
  45. package/provider/default.d.ts +3 -3
  46. package/provider/default.js +11 -12
  47. package/provider/index.js +10 -6
  48. package/provider/interface.d.ts +9 -1
  49. package/provider/utils.js +5 -5
  50. package/signer/index.js +10 -6
  51. package/src/account/default.ts +2 -6
  52. package/src/account/interface.ts +5 -3
  53. package/src/provider/default.ts +6 -5
  54. package/src/provider/interface.ts +9 -1
  55. package/src/types/account.ts +7 -0
  56. package/src/types/api.ts +1 -1
  57. package/src/types/index.ts +1 -0
  58. package/src/utils/typedData/types.ts +15 -68
  59. package/src/utils/typedData/utils.ts +7 -4
  60. package/types/account.d.ts +6 -0
  61. package/types/api.d.ts +1 -1
  62. package/types/index.d.ts +1 -0
  63. package/types/index.js +11 -6
  64. package/utils/ellipticCurve.js +1 -1
  65. package/utils/encode.js +1 -1
  66. package/utils/hash.js +1 -1
  67. package/utils/number.js +13 -9
  68. package/utils/shortString.js +2 -2
  69. package/utils/typedData/index.d.ts +2 -46
  70. package/utils/typedData/index.js +15 -13
  71. package/utils/typedData/types.d.ts +15 -91
  72. package/utils/typedData/types.js +0 -55
  73. package/utils/typedData/utils.d.ts +2 -21
  74. package/utils/typedData/utils.js +4 -3
  75. package/www/docs/API/provider.md +2 -2
  76. package/www/guides/account.md +21 -7
  77. package/www/guides/erc20.md +15 -27
  78. package/__tests__/accountContract.test.ts +0 -110
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -41,7 +45,7 @@ function toHex(number) {
41
45
  }
42
46
  exports.toHex = toHex;
43
47
  function hexToDecimalString(hex) {
44
- return toBN("0x" + hex.replace(/^0x/, '')).toString();
48
+ return toBN("0x".concat(hex.replace(/^0x/, ''))).toString();
45
49
  }
46
50
  exports.hexToDecimalString = hexToDecimalString;
47
51
  function toFelt(num) {
@@ -59,9 +63,9 @@ exports.toFelt = toFelt;
59
63
  */
60
64
  function assertInRange(input, lowerBound, upperBound, inputName) {
61
65
  if (inputName === void 0) { inputName = ''; }
62
- var messageSuffix = inputName === '' ? 'invalid length' : "invalid " + inputName + " length";
66
+ var messageSuffix = inputName === '' ? 'invalid length' : "invalid ".concat(inputName, " length");
63
67
  var inputBn = toBN(input);
64
- (0, minimalistic_assert_1.default)(inputBn.gte(toBN(lowerBound)) && inputBn.lt(toBN(upperBound)), "Message not signable, " + messageSuffix + ".");
68
+ (0, minimalistic_assert_1.default)(inputBn.gte(toBN(lowerBound)) && inputBn.lt(toBN(upperBound)), "Message not signable, ".concat(messageSuffix, "."));
65
69
  }
66
70
  exports.assertInRange = assertInRange;
67
71
  function bigNumberishArrayToDecimalStringArray(rawCalldata) {
@@ -14,9 +14,9 @@ function isShortString(str) {
14
14
  exports.isShortString = isShortString;
15
15
  function encodeShortString(str) {
16
16
  if (!isASCII(str))
17
- throw new Error(str + " is not an ASCII string");
17
+ throw new Error("".concat(str, " is not an ASCII string"));
18
18
  if (!isShortString(str))
19
- throw new Error(str + " is too long");
19
+ throw new Error("".concat(str, " is too long"));
20
20
  return (0, encode_1.addHexPrefix)(str.replace(/./g, function (char) { return char.charCodeAt(0).toString(16); }));
21
21
  }
22
22
  exports.encodeShortString = encodeShortString;
@@ -35,24 +35,7 @@ export declare const getTypeHash: (typedData: TypedData, type: string) => string
35
35
  * @param {string} type
36
36
  * @param {Record<string, any>} data
37
37
  */
38
- export declare const encodeData: <T extends {
39
- types: {
40
- StarkNetDomain: {
41
- type: string;
42
- name: string;
43
- }[];
44
- } & Record<string, {
45
- type: string;
46
- name: string;
47
- }[]>;
48
- primaryType: string;
49
- domain: {
50
- version?: string | undefined;
51
- chainId?: string | number | undefined;
52
- name?: string | undefined;
53
- };
54
- message: Record<string, unknown>;
55
- }>(typedData: T, type: string, data: T["message"]) => string[][];
38
+ export declare const encodeData: <T extends TypedData>(typedData: T, type: string, data: T["message"]) => string[][];
56
39
  /**
57
40
  * Get encoded data as a hash. The data should be a key -> value object with all the required values. All dependant
58
41
  * types are automatically encoded.
@@ -62,24 +45,7 @@ export declare const encodeData: <T extends {
62
45
  * @param {Record<string, any>} data
63
46
  * @return {Buffer}
64
47
  */
65
- export declare const getStructHash: <T extends {
66
- types: {
67
- StarkNetDomain: {
68
- type: string;
69
- name: string;
70
- }[];
71
- } & Record<string, {
72
- type: string;
73
- name: string;
74
- }[]>;
75
- primaryType: string;
76
- domain: {
77
- version?: string | undefined;
78
- chainId?: string | number | undefined;
79
- name?: string | undefined;
80
- };
81
- message: Record<string, unknown>;
82
- }>(typedData: T, type: string, data: T["message"]) => string;
48
+ export declare const getStructHash: <T extends TypedData>(typedData: T, type: string, data: T["message"]) => string;
83
49
  /**
84
50
  * Get the EIP-191 encoded message to sign, from the typedData object. If `hash` is enabled, the message will be hashed
85
51
  * with Keccak256.
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -49,7 +53,7 @@ function getHex(value) {
49
53
  if (typeof value === 'string') {
50
54
  return (0, number_1.toHex)((0, number_1.toBN)((0, shortString_1.encodeShortString)(value)));
51
55
  }
52
- throw new Error("Invalid BigNumberish: " + value);
56
+ throw new Error("Invalid BigNumberish: ".concat(value));
53
57
  }
54
58
  }
55
59
  /**
@@ -90,7 +94,7 @@ var encodeType = function (typedData, type) {
90
94
  var types = __spreadArray([primary], __read(dependencies.sort()), false);
91
95
  return types
92
96
  .map(function (dependency) {
93
- return dependency + "(" + typedData.types[dependency].map(function (t) { return t.name + ":" + t.type; }) + ")";
97
+ return "".concat(dependency, "(").concat(typedData.types[dependency].map(function (t) { return "".concat(t.name, ":").concat(t.type); }), ")");
94
98
  })
95
99
  .join('');
96
100
  };
@@ -137,7 +141,7 @@ var encodeData = function (typedData, type, data) {
137
141
  var _a = __read(typedData.types[type].reduce(function (_a, field) {
138
142
  var _b = __read(_a, 2), ts = _b[0], vs = _b[1];
139
143
  if (data[field.name] === undefined || data[field.name] === null) {
140
- throw new Error("Cannot encode data: missing data for '" + field.name + "'");
144
+ throw new Error("Cannot encode data: missing data for '".concat(field.name, "'"));
141
145
  }
142
146
  var value = data[field.name];
143
147
  var _c = __read(encodeValue(typedData, field.type, value), 2), t = _c[0], encodedValue = _c[1];
@@ -1,82 +1,27 @@
1
- import { Infer } from 'superstruct';
2
- export declare const ATOMIC_TYPES: string[];
3
- /**
4
- * Checks if a type is valid with the given `typedData`. The following types are valid:
5
- * - Atomic types: felt, felt*
6
- * - Reference types: struct type (e.g. SomeStruct)
7
- *
8
- * @param {Record<string, unknown>} types
9
- * @param {string} type
10
- * @return {boolean}
11
- */
12
- export declare const isValidType: (types: Record<string, unknown>, type: string) => boolean;
13
- export declare const STARKNET_TYPE: import("superstruct").Struct<{
14
- type: string;
15
- name: string;
16
- }, {
17
- name: import("superstruct").Struct<string, null>;
18
- type: import("superstruct").Struct<string, null>;
19
- }>;
20
1
  /**
21
2
  * A single type, as part of a struct. The `type` field can be any of the EIP-712 supported types.
22
3
  *
23
4
  * Note that the `uint` and `int` aliases like in Solidity, and fixed point numbers are not supported by the EIP-712
24
5
  * standard.
25
6
  */
26
- export declare type StarkNetType = Infer<typeof STARKNET_TYPE>;
27
- export declare const STARKNET_DOMAIN_TYPE: import("superstruct").Struct<{
28
- version?: string | undefined;
29
- chainId?: string | number | undefined;
30
- name?: string | undefined;
31
- }, {
32
- name: import("superstruct").Struct<string | undefined, null>;
33
- version: import("superstruct").Struct<string | undefined, null>;
34
- chainId: import("superstruct").Struct<string | number | undefined, null>;
35
- }>;
7
+ export interface StarkNetType {
8
+ name: string;
9
+ type: 'felt' | 'felt*' | string;
10
+ }
36
11
  /**
37
12
  * The EIP712 domain struct. Any of these fields are optional, but it must contain at least one field.
38
13
  */
39
- export declare type StarkNetDomain = Infer<typeof STARKNET_DOMAIN_TYPE>;
40
- export declare const STARKNET_TYPED_DATA_TYPE: import("superstruct").Struct<{
41
- types: {
42
- StarkNetDomain: {
43
- type: string;
44
- name: string;
45
- }[];
46
- } & Record<string, {
47
- type: string;
48
- name: string;
49
- }[]>;
50
- primaryType: string;
51
- domain: {
52
- version?: string | undefined;
53
- chainId?: string | number | undefined;
54
- name?: string | undefined;
55
- };
56
- message: Record<string, unknown>;
57
- }, {
58
- types: import("superstruct").Struct<{
59
- StarkNetDomain: {
60
- type: string;
61
- name: string;
62
- }[];
63
- } & Record<string, {
64
- type: string;
65
- name: string;
66
- }[]>, null>;
67
- primaryType: import("superstruct").Struct<string, null>;
68
- domain: import("superstruct").Struct<{
69
- version?: string | undefined;
70
- chainId?: string | number | undefined;
71
- name?: string | undefined;
72
- }, {
73
- name: import("superstruct").Struct<string | undefined, null>;
74
- version: import("superstruct").Struct<string | undefined, null>;
75
- chainId: import("superstruct").Struct<string | number | undefined, null>;
76
- }>;
77
- message: import("superstruct").Struct<Record<string, unknown>, null>;
78
- }>;
14
+ export interface StarkNetDomain extends Record<string, unknown> {
15
+ name?: string;
16
+ version?: string;
17
+ chainId?: string | number;
18
+ }
79
19
  /**
80
20
  * The complete typed data, with all the structs, domain data, primary type of the message, and the message itself.
81
21
  */
82
- export declare type TypedData = Infer<typeof STARKNET_TYPED_DATA_TYPE>;
22
+ export interface TypedData {
23
+ types: Record<string, StarkNetType[]>;
24
+ primaryType: string;
25
+ domain: StarkNetDomain;
26
+ message: Record<string, unknown>;
27
+ }
@@ -1,47 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STARKNET_TYPED_DATA_TYPE = exports.STARKNET_DOMAIN_TYPE = exports.STARKNET_TYPE = exports.isValidType = exports.ATOMIC_TYPES = void 0;
4
- var superstruct_1 = require("superstruct");
5
- exports.ATOMIC_TYPES = ['felt', 'felt*'];
6
- // Source: https://github.com/Mrtenz/eip-712/blob/master/src/eip-712.ts
7
- // and modified to support starknet types
8
- /**
9
- * Checks if a type is valid with the given `typedData`. The following types are valid:
10
- * - Atomic types: felt, felt*
11
- * - Reference types: struct type (e.g. SomeStruct)
12
- *
13
- * @param {Record<string, unknown>} types
14
- * @param {string} type
15
- * @return {boolean}
16
- */
17
- var isValidType = function (types, type) {
18
- if (exports.ATOMIC_TYPES.includes(type)) {
19
- return true;
20
- }
21
- if (types[type]) {
22
- return true;
23
- }
24
- return false;
25
- };
26
- exports.isValidType = isValidType;
27
- var TYPE = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'Type', function (type, context) {
28
- return (0, exports.isValidType)(context.branch[0].types, type);
29
- });
30
- exports.STARKNET_TYPE = (0, superstruct_1.object)({
31
- name: (0, superstruct_1.string)(),
32
- type: TYPE,
33
- });
34
- exports.STARKNET_DOMAIN_TYPE = (0, superstruct_1.object)({
35
- name: (0, superstruct_1.optional)((0, superstruct_1.string)()),
36
- version: (0, superstruct_1.optional)((0, superstruct_1.string)()),
37
- chainId: (0, superstruct_1.optional)((0, superstruct_1.union)([(0, superstruct_1.string)(), (0, superstruct_1.number)()])),
38
- });
39
- exports.STARKNET_TYPED_DATA_TYPE = (0, superstruct_1.object)({
40
- types: (0, superstruct_1.intersection)([
41
- (0, superstruct_1.type)({ StarkNetDomain: (0, superstruct_1.array)(exports.STARKNET_TYPE) }),
42
- (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.array)(exports.STARKNET_TYPE)),
43
- ]),
44
- primaryType: (0, superstruct_1.string)(),
45
- domain: exports.STARKNET_DOMAIN_TYPE,
46
- message: (0, superstruct_1.object)(),
47
- });
@@ -1,24 +1,8 @@
1
+ import { TypedData } from './types';
1
2
  /**
2
3
  * Validates that `data` matches the EIP-712 JSON schema.
3
4
  *
4
5
  * @param {any} data
5
6
  * @return {boolean}
6
7
  */
7
- export declare const validateTypedData: (data: unknown) => data is {
8
- types: {
9
- StarkNetDomain: {
10
- type: string;
11
- name: string;
12
- }[];
13
- } & Record<string, {
14
- type: string;
15
- name: string;
16
- }[]>;
17
- primaryType: string;
18
- domain: {
19
- version?: string | undefined;
20
- chainId?: string | number | undefined;
21
- name?: string | undefined;
22
- };
23
- message: Record<string, unknown>;
24
- };
8
+ export declare const validateTypedData: (data: unknown) => data is TypedData;
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateTypedData = void 0;
4
- var superstruct_1 = require("superstruct");
5
- var types_1 = require("./types");
6
4
  /**
7
5
  * Validates that `data` matches the EIP-712 JSON schema.
8
6
  *
@@ -10,6 +8,9 @@ var types_1 = require("./types");
10
8
  * @return {boolean}
11
9
  */
12
10
  var validateTypedData = function (data) {
13
- return (0, superstruct_1.is)(data, types_1.STARKNET_TYPED_DATA_TYPE);
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;
14
15
  };
15
16
  exports.validateTypedData = validateTypedData;
package/index.js CHANGED
@@ -4,12 +4,16 @@ var __createBinding =
4
4
  (Object.create
5
5
  ? function (o, m, k, k2) {
6
6
  if (k2 === undefined) k2 = k;
7
- Object.defineProperty(o, k2, {
8
- enumerable: true,
9
- get: function () {
10
- return m[k];
11
- },
12
- });
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);
13
17
  }
14
18
  : function (o, m, k, k2) {
15
19
  if (k2 === undefined) k2 = k;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starknet",
3
- "version": "3.12.2",
3
+ "version": "3.13.1",
4
4
  "description": "JavaScript library for StarkNet",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,51 +27,52 @@
27
27
  "author": "Sean Han",
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
- "@babel/preset-env": "^7.15.8",
31
- "@babel/preset-typescript": "^7.15.0",
32
- "@commitlint/cli": "^13.2.1",
33
- "@commitlint/config-conventional": "^13.2.0",
34
- "@semantic-release/changelog": "^6.0.0",
35
- "@semantic-release/commit-analyzer": "^9.0.1",
36
- "@semantic-release/git": "^10.0.0",
37
- "@semantic-release/npm": "^8.0.2",
38
- "@semantic-release/release-notes-generator": "^10.0.2",
39
- "@types/elliptic": "^6.4.13",
40
- "@types/jest": "^27.0.2",
30
+ "@babel/plugin-transform-modules-commonjs": "^7.18.2",
31
+ "@babel/preset-env": "^7.18.2",
32
+ "@babel/preset-typescript": "^7.17.12",
33
+ "@commitlint/cli": "^17.0.2",
34
+ "@commitlint/config-conventional": "^17.0.2",
35
+ "@semantic-release/changelog": "^6.0.1",
36
+ "@semantic-release/commit-analyzer": "^9.0.2",
37
+ "@semantic-release/git": "^10.0.1",
38
+ "@semantic-release/npm": "^9.0.1",
39
+ "@semantic-release/release-notes-generator": "^10.0.3",
40
+ "@types/elliptic": "^6.4.14",
41
+ "@types/jest": "^28.1.1",
41
42
  "@types/json-bigint": "^1.0.1",
42
43
  "@types/minimalistic-assert": "^1.0.1",
43
- "@types/pako": "^1.0.2",
44
+ "@types/pako": "^2.0.0",
44
45
  "@types/url-join": "^4.0.1",
45
- "@typescript-eslint/eslint-plugin": "^5.0.0",
46
- "@typescript-eslint/parser": "^5.0.0",
47
- "eslint": "^7.32.0",
48
- "eslint-config-airbnb-base": "^14.2.1",
49
- "eslint-config-airbnb-typescript": "^14.0.1",
50
- "eslint-config-prettier": "^8.3.0",
51
- "eslint-plugin-import": "^2.25.2",
46
+ "@typescript-eslint/eslint-plugin": "^5.28.0",
47
+ "@typescript-eslint/parser": "^5.28.0",
48
+ "eslint": "^8.17.0",
49
+ "eslint-config-airbnb-base": "^15.0.0",
50
+ "eslint-config-airbnb-typescript": "^17.0.0",
51
+ "eslint-config-prettier": "^8.5.0",
52
+ "eslint-plugin-import": "^2.26.0",
52
53
  "eslint-plugin-prettier": "^4.0.0",
53
- "husky": "^7.0.2",
54
+ "husky": "^8.0.1",
54
55
  "import-sort-style-module": "^6.0.0",
55
- "jest": "^27.3.0",
56
- "lint-staged": "^11.2.3",
57
- "prettier": "^2.4.1",
56
+ "jest": "^28.1.1",
57
+ "jest-environment-jsdom": "^28.1.1",
58
+ "lint-staged": "^13.0.1",
59
+ "prettier": "^2.7.0",
58
60
  "prettier-plugin-import-sort": "^0.0.7",
59
- "typedoc": "^0.22.6",
60
- "typescript": "^4.4.4",
61
+ "typedoc": "^0.22.17",
62
+ "typescript": "^4.7.3",
61
63
  "whatwg-fetch": "^3.6.2"
62
64
  },
63
65
  "dependencies": {
64
66
  "@ethersproject/bytes": "^5.6.1",
65
- "bn.js": "^5.2.0",
67
+ "bn.js": "^5.2.1",
66
68
  "cross-fetch": "^3.1.5",
67
69
  "elliptic": "^6.5.4",
68
- "ethereum-cryptography": "^0.2.0",
70
+ "ethereum-cryptography": "^1.0.3",
69
71
  "fetch-intercept": "^2.4.0",
70
72
  "hash.js": "^1.1.7",
71
73
  "json-bigint": "^1.0.0",
72
74
  "minimalistic-assert": "^1.0.1",
73
75
  "pako": "^2.0.4",
74
- "superstruct": "^0.15.3",
75
76
  "url-join": "^4.0.1"
76
77
  },
77
78
  "lint-staged": {
@@ -109,7 +109,7 @@ export declare class Provider implements ProviderInterface {
109
109
  */
110
110
  getStorageAt(
111
111
  contractAddress: string,
112
- key: number,
112
+ key: BigNumberish,
113
113
  blockIdentifier?: BlockIdentifier
114
114
  ): Promise<object>;
115
115
  /**
@@ -122,9 +122,9 @@ export declare class Provider implements ProviderInterface {
122
122
  */
123
123
  getTransactionStatus(txHash: BigNumberish): Promise<GetTransactionStatusResponse>;
124
124
  /**
125
- * Gets the transaction receipt from a tx hash or tx id.
125
+ * Gets the transaction receipt from a tx hash.
126
126
  *
127
- * [Reference] (https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L104-L111)
127
+ * [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
128
128
  *
129
129
  * @param txHash
130
130
  * @returns the transaction receipt object
@@ -184,7 +184,7 @@ var interface_1 = require('./interface');
184
184
  var utils_1 = require('./utils');
185
185
  function wait(delay) {
186
186
  return new Promise(function (res) {
187
- return setTimeout(res, delay);
187
+ setTimeout(res, delay);
188
188
  });
189
189
  }
190
190
  function isEmptyQueryObject(obj) {
@@ -242,7 +242,7 @@ var Provider = /** @class */ (function () {
242
242
  }
243
243
  } catch (_a) {
244
244
  // eslint-disable-next-line no-console
245
- console.error('Could not parse baseUrl: ' + baseUrl);
245
+ console.error('Could not parse baseUrl: '.concat(baseUrl));
246
246
  }
247
247
  return constants_1.StarknetChainId.TESTNET;
248
248
  };
@@ -264,12 +264,12 @@ var Provider = /** @class */ (function () {
264
264
  key = _b[0],
265
265
  value = _b[1];
266
266
  if (key === 'blockIdentifier') {
267
- return '' + (0, utils_1.getFormattedBlockIdentifier)(value);
267
+ return ''.concat((0, utils_1.getFormattedBlockIdentifier)(value));
268
268
  }
269
- return key + '=' + value;
269
+ return ''.concat(key, '=').concat(value);
270
270
  })
271
271
  .join('&');
272
- return '?' + queryString;
272
+ return '?'.concat(queryString);
273
273
  };
274
274
  Provider.prototype.getHeaders = function (method) {
275
275
  if (method === 'POST') {
@@ -478,9 +478,9 @@ var Provider = /** @class */ (function () {
478
478
  });
479
479
  };
480
480
  /**
481
- * Gets the transaction receipt from a tx hash or tx id.
481
+ * Gets the transaction receipt from a tx hash.
482
482
  *
483
- * [Reference] (https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L104-L111)
483
+ * [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
484
484
  *
485
485
  * @param txHash
486
486
  * @returns the transaction receipt object
@@ -609,11 +609,10 @@ var Provider = /** @class */ (function () {
609
609
  onchain = true;
610
610
  } else if (errorStates.includes(res.tx_status)) {
611
611
  message = res.tx_failure_reason
612
- ? res.tx_status +
613
- ': ' +
614
- res.tx_failure_reason.code +
615
- '\n' +
616
- res.tx_failure_reason.error_message
612
+ ? ''
613
+ .concat(res.tx_status, ': ')
614
+ .concat(res.tx_failure_reason.code, '\n')
615
+ .concat(res.tx_failure_reason.error_message)
617
616
  : res.tx_status;
618
617
  error = new Error(message);
619
618
  error.response = res;
package/provider/index.js CHANGED
@@ -4,12 +4,16 @@ var __createBinding =
4
4
  (Object.create
5
5
  ? function (o, m, k, k2) {
6
6
  if (k2 === undefined) k2 = k;
7
- Object.defineProperty(o, k2, {
8
- enumerable: true,
9
- get: function () {
10
- return m[k];
11
- },
12
- });
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);
13
17
  }
14
18
  : function (o, m, k, k2) {
15
19
  if (k2 === undefined) k2 = k;
@@ -75,7 +75,7 @@ export declare abstract class ProviderInterface {
75
75
  */
76
76
  abstract getStorageAt(
77
77
  contractAddress: string,
78
- key: number,
78
+ key: BigNumberish,
79
79
  blockIdentifier?: BlockIdentifier
80
80
  ): Promise<object>;
81
81
  /**
@@ -96,6 +96,14 @@ export declare abstract class ProviderInterface {
96
96
  * @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
97
97
  */
98
98
  abstract getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
99
+ /**
100
+ * Gets the transaction receipt from a tx hash.
101
+ *
102
+ * [Reference] (https://github.com/starkware-libs/cairo-lang/blob/167b28bcd940fd25ea3816204fa882a0b0a49603/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L183)
103
+ *
104
+ * @param txHash
105
+ * @returns the transaction receipt object
106
+ */
99
107
  abstract getTransactionReceipt(txHash: BigNumberish): Promise<TransactionReceiptResponse>;
100
108
  /**
101
109
  * Deploys a given compiled contract (json) to starknet
package/provider/utils.js CHANGED
@@ -26,10 +26,10 @@ exports.formatHash = formatHash;
26
26
  */
27
27
  function txIdentifier(txHash, txId) {
28
28
  if (!txHash) {
29
- return 'transactionId=' + JSON.stringify(txId);
29
+ return 'transactionId='.concat(JSON.stringify(txId));
30
30
  }
31
31
  var hashString = formatHash(txHash);
32
- return 'transactionHash=' + hashString;
32
+ return 'transactionHash='.concat(hashString);
33
33
  }
34
34
  exports.txIdentifier = txIdentifier;
35
35
  /**
@@ -55,7 +55,7 @@ function getBlockIdentifier(blockIdentifier) {
55
55
  return { type: 'BLOCK_NUMBER', data: parseInt(blockIdentifier, 10) };
56
56
  }
57
57
  if (typeof blockIdentifier === 'string') {
58
- throw new Error('Invalid block identifier: ' + blockIdentifier);
58
+ throw new Error('Invalid block identifier: '.concat(blockIdentifier));
59
59
  }
60
60
  return { type: 'BLOCK_HASH', data: blockIdentifier };
61
61
  }
@@ -77,8 +77,8 @@ function getFormattedBlockIdentifier(blockIdentifier) {
77
77
  return '';
78
78
  }
79
79
  if (blockIdentifierObject.type === 'BLOCK_NUMBER') {
80
- return 'blockNumber=' + blockIdentifierObject.data;
80
+ return 'blockNumber='.concat(blockIdentifierObject.data);
81
81
  }
82
- return 'blockHash=' + (0, number_1.toHex)((0, number_1.toBN)(blockIdentifierObject.data));
82
+ return 'blockHash='.concat((0, number_1.toHex)((0, number_1.toBN)(blockIdentifierObject.data)));
83
83
  }
84
84
  exports.getFormattedBlockIdentifier = getFormattedBlockIdentifier;
package/signer/index.js CHANGED
@@ -4,12 +4,16 @@ var __createBinding =
4
4
  (Object.create
5
5
  ? function (o, m, k, k2) {
6
6
  if (k2 === undefined) k2 = k;
7
- Object.defineProperty(o, k2, {
8
- enumerable: true,
9
- get: function () {
10
- return m[k];
11
- },
12
- });
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);
13
17
  }
14
18
  : function (o, m, k, k2) {
15
19
  if (k2 === undefined) k2 = k;