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.
- package/.github/workflows/pr.yml +3 -0
- package/.github/workflows/release.yml +4 -0
- package/CHANGELOG.md +38 -0
- package/__mocks__/Account.json +25468 -0
- package/__tests__/account.test.ts +102 -65
- package/__tests__/contract.test.ts +23 -65
- package/__tests__/fixtures.ts +21 -1
- package/__tests__/provider.test.ts +20 -1
- package/account/default.d.ts +2 -9
- package/account/index.js +10 -6
- package/account/interface.d.ts +5 -3
- package/contract/default.d.ts +1 -1
- package/contract/default.js +20 -21
- package/contract/index.js +10 -6
- package/dist/account/default.d.ts +2 -6
- package/dist/account/index.js +5 -1
- package/dist/account/interface.d.ts +3 -3
- package/dist/contract/default.d.ts +1 -1
- package/dist/contract/default.js +18 -18
- package/dist/contract/index.js +5 -1
- package/dist/index.js +5 -1
- package/dist/provider/default.d.ts +3 -3
- package/dist/provider/default.js +10 -8
- package/dist/provider/index.js +5 -1
- package/dist/provider/interface.d.ts +9 -1
- package/dist/provider/utils.js +5 -5
- package/dist/signer/index.js +5 -1
- package/dist/types/account.d.ts +6 -0
- package/dist/types/api.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +6 -1
- package/dist/utils/ellipticCurve.js +1 -1
- package/dist/utils/encode.js +1 -1
- package/dist/utils/hash.js +1 -1
- package/dist/utils/number.js +8 -4
- package/dist/utils/shortString.js +2 -2
- package/dist/utils/typedData/index.d.ts +2 -36
- package/dist/utils/typedData/index.js +8 -4
- package/dist/utils/typedData/types.d.ts +15 -70
- package/dist/utils/typedData/types.js +0 -45
- package/dist/utils/typedData/utils.d.ts +2 -18
- package/dist/utils/typedData/utils.js +4 -3
- package/index.js +10 -6
- package/package.json +30 -29
- package/provider/default.d.ts +3 -3
- package/provider/default.js +11 -12
- package/provider/index.js +10 -6
- package/provider/interface.d.ts +9 -1
- package/provider/utils.js +5 -5
- package/signer/index.js +10 -6
- package/src/account/default.ts +2 -6
- package/src/account/interface.ts +5 -3
- package/src/provider/default.ts +6 -5
- package/src/provider/interface.ts +9 -1
- package/src/types/account.ts +7 -0
- package/src/types/api.ts +1 -1
- package/src/types/index.ts +1 -0
- package/src/utils/typedData/types.ts +15 -68
- package/src/utils/typedData/utils.ts +7 -4
- package/types/account.d.ts +6 -0
- package/types/api.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.js +11 -6
- package/utils/ellipticCurve.js +1 -1
- package/utils/encode.js +1 -1
- package/utils/hash.js +1 -1
- package/utils/number.js +13 -9
- package/utils/shortString.js +2 -2
- package/utils/typedData/index.d.ts +2 -46
- package/utils/typedData/index.js +15 -13
- package/utils/typedData/types.d.ts +15 -91
- package/utils/typedData/types.js +0 -55
- package/utils/typedData/utils.d.ts +2 -21
- package/utils/typedData/utils.js +4 -3
- package/www/docs/API/provider.md +2 -2
- package/www/guides/account.md +21 -7
- package/www/guides/erc20.md +15 -27
- package/__tests__/accountContract.test.ts +0 -110
package/dist/utils/number.js
CHANGED
|
@@ -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.
|
|
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"
|
|
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 "
|
|
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, "
|
|
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
|
|
17
|
+
throw new Error("".concat(str, " is not an ASCII string"));
|
|
18
18
|
if (!isShortString(str))
|
|
19
|
-
throw new Error(str
|
|
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.
|
|
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: "
|
|
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
|
|
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 '"
|
|
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
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
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
|
-
|
|
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.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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.
|
|
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/
|
|
31
|
-
"@babel/preset-
|
|
32
|
-
"@
|
|
33
|
-
"@commitlint/
|
|
34
|
-
"@
|
|
35
|
-
"@semantic-release/
|
|
36
|
-
"@semantic-release/
|
|
37
|
-
"@semantic-release/
|
|
38
|
-
"@semantic-release/
|
|
39
|
-
"@
|
|
40
|
-
"@types/
|
|
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": "^
|
|
44
|
+
"@types/pako": "^2.0.0",
|
|
44
45
|
"@types/url-join": "^4.0.1",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
46
|
-
"@typescript-eslint/parser": "^5.
|
|
47
|
-
"eslint": "^
|
|
48
|
-
"eslint-config-airbnb-base": "^
|
|
49
|
-
"eslint-config-airbnb-typescript": "^
|
|
50
|
-
"eslint-config-prettier": "^8.
|
|
51
|
-
"eslint-plugin-import": "^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": "^
|
|
54
|
+
"husky": "^8.0.1",
|
|
54
55
|
"import-sort-style-module": "^6.0.0",
|
|
55
|
-
"jest": "^
|
|
56
|
-
"
|
|
57
|
-
"
|
|
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.
|
|
60
|
-
"typescript": "^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.
|
|
67
|
+
"bn.js": "^5.2.1",
|
|
66
68
|
"cross-fetch": "^3.1.5",
|
|
67
69
|
"elliptic": "^6.5.4",
|
|
68
|
-
"ethereum-cryptography": "^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": {
|
package/provider/default.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ export declare class Provider implements ProviderInterface {
|
|
|
109
109
|
*/
|
|
110
110
|
getStorageAt(
|
|
111
111
|
contractAddress: string,
|
|
112
|
-
key:
|
|
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
|
|
125
|
+
* Gets the transaction receipt from a tx hash.
|
|
126
126
|
*
|
|
127
|
-
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/
|
|
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
|
package/provider/default.js
CHANGED
|
@@ -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
|
-
|
|
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: '
|
|
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 ''
|
|
267
|
+
return ''.concat((0, utils_1.getFormattedBlockIdentifier)(value));
|
|
268
268
|
}
|
|
269
|
-
return key
|
|
269
|
+
return ''.concat(key, '=').concat(value);
|
|
270
270
|
})
|
|
271
271
|
.join('&');
|
|
272
|
-
return '?'
|
|
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
|
|
481
|
+
* Gets the transaction receipt from a tx hash.
|
|
482
482
|
*
|
|
483
|
-
* [Reference] (https://github.com/starkware-libs/cairo-lang/blob/
|
|
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
|
-
?
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
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.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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/provider/interface.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export declare abstract class ProviderInterface {
|
|
|
75
75
|
*/
|
|
76
76
|
abstract getStorageAt(
|
|
77
77
|
contractAddress: string,
|
|
78
|
-
key:
|
|
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='
|
|
29
|
+
return 'transactionId='.concat(JSON.stringify(txId));
|
|
30
30
|
}
|
|
31
31
|
var hashString = formatHash(txHash);
|
|
32
|
-
return 'transactionHash='
|
|
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: '
|
|
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='
|
|
80
|
+
return 'blockNumber='.concat(blockIdentifierObject.data);
|
|
81
81
|
}
|
|
82
|
-
return 'blockHash='
|
|
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.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|