starknet 4.12.0 → 4.13.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.
- package/.eslintrc +1 -0
- package/CHANGELOG.md +14 -0
- package/__tests__/account.test.ts +0 -2
- package/dist/index.d.ts +2683 -24
- package/dist/index.global.js +22994 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +4713 -53
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4655 -0
- package/dist/index.mjs.map +1 -0
- package/index.d.ts +2683 -24
- package/index.global.js +22994 -0
- package/index.global.js.map +1 -0
- package/index.js +4713 -53
- package/index.js.map +1 -0
- package/index.mjs +4655 -0
- package/index.mjs.map +1 -0
- package/package.json +8 -2
- package/src/account/default.ts +43 -8
- package/src/account/interface.ts +25 -2
- package/src/constants.ts +0 -1
- package/src/provider/default.ts +3 -0
- package/src/provider/interface.ts +2 -0
- package/src/provider/rpc.ts +4 -4
- package/src/provider/sequencer.ts +4 -1
- package/src/types/lib.ts +1 -1
- package/src/types/provider.ts +5 -0
- package/src/utils/ellipticCurve.ts +3 -1
- package/src/utils/fetchPonyfill.ts +3 -2
- package/src/utils/hash.ts +3 -2
- package/src/utils/number.ts +2 -2
- package/tsup.config.ts +10 -0
- package/account/default.d.ts +0 -30
- package/account/default.js +0 -526
- package/account/index.d.ts +0 -2
- package/account/index.js +0 -18
- package/account/interface.d.ts +0 -161
- package/account/interface.js +0 -27
- package/constants.d.ts +0 -36
- package/constants.js +0 -2067
- package/contract/contractFactory.d.ts +0 -31
- package/contract/contractFactory.js +0 -102
- package/contract/default.d.ts +0 -108
- package/contract/default.js +0 -640
- package/contract/index.d.ts +0 -3
- package/contract/index.js +0 -19
- package/contract/interface.d.ts +0 -80
- package/contract/interface.js +0 -9
- package/dist/account/default.d.ts +0 -30
- package/dist/account/default.js +0 -526
- package/dist/account/index.d.ts +0 -2
- package/dist/account/index.js +0 -18
- package/dist/account/interface.d.ts +0 -161
- package/dist/account/interface.js +0 -27
- package/dist/constants.d.ts +0 -36
- package/dist/constants.js +0 -2067
- package/dist/contract/contractFactory.d.ts +0 -31
- package/dist/contract/contractFactory.js +0 -102
- package/dist/contract/default.d.ts +0 -108
- package/dist/contract/default.js +0 -640
- package/dist/contract/index.d.ts +0 -3
- package/dist/contract/index.js +0 -19
- package/dist/contract/interface.d.ts +0 -80
- package/dist/contract/interface.js +0 -9
- package/dist/provider/default.d.ts +0 -37
- package/dist/provider/default.js +0 -207
- package/dist/provider/errors.d.ts +0 -9
- package/dist/provider/errors.js +0 -40
- package/dist/provider/index.d.ts +0 -7
- package/dist/provider/index.js +0 -24
- package/dist/provider/interface.d.ts +0 -203
- package/dist/provider/interface.js +0 -9
- package/dist/provider/rpc.d.ts +0 -86
- package/dist/provider/rpc.js +0 -605
- package/dist/provider/sequencer.d.ts +0 -79
- package/dist/provider/sequencer.js +0 -575
- package/dist/provider/utils.d.ts +0 -30
- package/dist/provider/utils.js +0 -84
- package/dist/signer/default.d.ts +0 -13
- package/dist/signer/default.js +0 -102
- package/dist/signer/index.d.ts +0 -2
- package/dist/signer/index.js +0 -18
- package/dist/signer/interface.d.ts +0 -60
- package/dist/signer/interface.js +0 -9
- package/dist/types/account.d.ts +0 -11
- package/dist/types/account.js +0 -2
- package/dist/types/api/index.d.ts +0 -10
- package/dist/types/api/index.js +0 -18
- package/dist/types/api/openrpc.d.ts +0 -572
- package/dist/types/api/openrpc.js +0 -45
- package/dist/types/api/rpc.d.ts +0 -43
- package/dist/types/api/rpc.js +0 -2
- package/dist/types/api/sequencer.d.ts +0 -320
- package/dist/types/api/sequencer.js +0 -2
- package/dist/types/contract.d.ts +0 -5
- package/dist/types/contract.js +0 -2
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.js +0 -35
- package/dist/types/lib.d.ts +0 -120
- package/dist/types/lib.js +0 -8
- package/dist/types/provider.d.ts +0 -99
- package/dist/types/provider.js +0 -2
- package/dist/types/signer.d.ts +0 -19
- package/dist/types/signer.js +0 -2
- package/dist/utils/address.d.ts +0 -5
- package/dist/utils/address.js +0 -41
- package/dist/utils/ellipticCurve.d.ts +0 -29
- package/dist/utils/ellipticCurve.js +0 -132
- package/dist/utils/encode.d.ts +0 -15
- package/dist/utils/encode.js +0 -96
- package/dist/utils/fetchPonyfill.d.ts +0 -2
- package/dist/utils/fetchPonyfill.js +0 -6
- package/dist/utils/hash.d.ts +0 -37
- package/dist/utils/hash.js +0 -162
- package/dist/utils/json.d.ts +0 -16
- package/dist/utils/json.js +0 -19
- package/dist/utils/merkle.d.ts +0 -10
- package/dist/utils/merkle.js +0 -89
- package/dist/utils/number.d.ts +0 -16
- package/dist/utils/number.js +0 -112
- package/dist/utils/provider.d.ts +0 -4
- package/dist/utils/provider.js +0 -38
- package/dist/utils/responseParser/index.d.ts +0 -11
- package/dist/utils/responseParser/index.js +0 -9
- package/dist/utils/responseParser/rpc.d.ts +0 -20
- package/dist/utils/responseParser/rpc.js +0 -44
- package/dist/utils/responseParser/sequencer.d.ts +0 -17
- package/dist/utils/responseParser/sequencer.js +0 -99
- package/dist/utils/shortString.d.ts +0 -4
- package/dist/utils/shortString.js +0 -26
- package/dist/utils/stark.d.ts +0 -16
- package/dist/utils/stark.js +0 -91
- package/dist/utils/transaction.d.ts +0 -20
- package/dist/utils/transaction.js +0 -79
- package/dist/utils/typedData/index.d.ts +0 -72
- package/dist/utils/typedData/index.js +0 -239
- package/dist/utils/typedData/types.d.ts +0 -32
- package/dist/utils/typedData/types.js +0 -2
- package/dist/utils/typedData/utils.d.ts +0 -8
- package/dist/utils/typedData/utils.js +0 -16
- package/dist/utils/uint256.d.ts +0 -11
- package/dist/utils/uint256.js +0 -28
- package/dist/utils/url.d.ts +0 -7
- package/dist/utils/url.js +0 -49
- package/provider/default.d.ts +0 -37
- package/provider/default.js +0 -207
- package/provider/errors.d.ts +0 -9
- package/provider/errors.js +0 -40
- package/provider/index.d.ts +0 -7
- package/provider/index.js +0 -24
- package/provider/interface.d.ts +0 -203
- package/provider/interface.js +0 -9
- package/provider/rpc.d.ts +0 -86
- package/provider/rpc.js +0 -605
- package/provider/sequencer.d.ts +0 -79
- package/provider/sequencer.js +0 -575
- package/provider/utils.d.ts +0 -30
- package/provider/utils.js +0 -84
- package/signer/default.d.ts +0 -13
- package/signer/default.js +0 -102
- package/signer/index.d.ts +0 -2
- package/signer/index.js +0 -18
- package/signer/interface.d.ts +0 -60
- package/signer/interface.js +0 -9
- package/types/account.d.ts +0 -11
- package/types/account.js +0 -2
- package/types/api/index.d.ts +0 -10
- package/types/api/index.js +0 -18
- package/types/api/openrpc.d.ts +0 -572
- package/types/api/openrpc.js +0 -45
- package/types/api/rpc.d.ts +0 -43
- package/types/api/rpc.js +0 -2
- package/types/api/sequencer.d.ts +0 -320
- package/types/api/sequencer.js +0 -2
- package/types/contract.d.ts +0 -5
- package/types/contract.js +0 -2
- package/types/index.d.ts +0 -7
- package/types/index.js +0 -35
- package/types/lib.d.ts +0 -120
- package/types/lib.js +0 -8
- package/types/provider.d.ts +0 -99
- package/types/provider.js +0 -2
- package/types/signer.d.ts +0 -19
- package/types/signer.js +0 -2
- package/utils/address.d.ts +0 -5
- package/utils/address.js +0 -41
- package/utils/ellipticCurve.d.ts +0 -29
- package/utils/ellipticCurve.js +0 -132
- package/utils/encode.d.ts +0 -15
- package/utils/encode.js +0 -96
- package/utils/fetchPonyfill.d.ts +0 -2
- package/utils/fetchPonyfill.js +0 -6
- package/utils/hash.d.ts +0 -37
- package/utils/hash.js +0 -162
- package/utils/json.d.ts +0 -16
- package/utils/json.js +0 -19
- package/utils/merkle.d.ts +0 -10
- package/utils/merkle.js +0 -89
- package/utils/number.d.ts +0 -16
- package/utils/number.js +0 -112
- package/utils/provider.d.ts +0 -4
- package/utils/provider.js +0 -38
- package/utils/responseParser/index.d.ts +0 -11
- package/utils/responseParser/index.js +0 -9
- package/utils/responseParser/rpc.d.ts +0 -20
- package/utils/responseParser/rpc.js +0 -44
- package/utils/responseParser/sequencer.d.ts +0 -17
- package/utils/responseParser/sequencer.js +0 -99
- package/utils/shortString.d.ts +0 -4
- package/utils/shortString.js +0 -26
- package/utils/stark.d.ts +0 -16
- package/utils/stark.js +0 -91
- package/utils/transaction.d.ts +0 -20
- package/utils/transaction.js +0 -79
- package/utils/typedData/index.d.ts +0 -72
- package/utils/typedData/index.js +0 -239
- package/utils/typedData/types.d.ts +0 -32
- package/utils/typedData/types.js +0 -2
- package/utils/typedData/utils.d.ts +0 -8
- package/utils/typedData/utils.js +0 -16
- package/utils/uint256.d.ts +0 -11
- package/utils/uint256.js +0 -28
- package/utils/url.d.ts +0 -7
- package/utils/url.js +0 -49
package/utils/number.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.toCairoBool = exports.getHexStringArray = exports.getHexString = exports.getDecimalString = exports.toHexString = exports.isStringWholeNumber = exports.bigNumberishArrayToHexadecimalStringArray = exports.bigNumberishArrayToDecimalStringArray = exports.assertInRange = exports.toFelt = exports.hexToDecimalString = exports.toHex = exports.toBN = exports.isHex = void 0;
|
|
30
|
-
var bn_js_1 = __importStar(require("bn.js"));
|
|
31
|
-
var minimalistic_assert_1 = __importDefault(require("minimalistic-assert"));
|
|
32
|
-
var encode_1 = require("./encode");
|
|
33
|
-
function isHex(hex) {
|
|
34
|
-
return /^0x[0-9a-f]*$/i.test(hex);
|
|
35
|
-
}
|
|
36
|
-
exports.isHex = isHex;
|
|
37
|
-
function toBN(number, base) {
|
|
38
|
-
if (typeof number === 'string') {
|
|
39
|
-
// eslint-disable-next-line no-param-reassign
|
|
40
|
-
number = number.toLowerCase();
|
|
41
|
-
}
|
|
42
|
-
if (typeof number === 'string' && isHex(number) && !base)
|
|
43
|
-
return new bn_js_1.default((0, encode_1.removeHexPrefix)(number), 'hex');
|
|
44
|
-
return new bn_js_1.default(number, base);
|
|
45
|
-
}
|
|
46
|
-
exports.toBN = toBN;
|
|
47
|
-
function toHex(number) {
|
|
48
|
-
return (0, encode_1.addHexPrefix)(number.toString('hex'));
|
|
49
|
-
}
|
|
50
|
-
exports.toHex = toHex;
|
|
51
|
-
function hexToDecimalString(hex) {
|
|
52
|
-
return toBN("0x".concat(hex.replace(/^0x/, ''))).toString();
|
|
53
|
-
}
|
|
54
|
-
exports.hexToDecimalString = hexToDecimalString;
|
|
55
|
-
function toFelt(num) {
|
|
56
|
-
if ((0, bn_js_1.isBN)(num)) {
|
|
57
|
-
return num.toString();
|
|
58
|
-
}
|
|
59
|
-
return toBN(num).toString();
|
|
60
|
-
}
|
|
61
|
-
exports.toFelt = toFelt;
|
|
62
|
-
/*
|
|
63
|
-
Asserts input is equal to or greater then lowerBound and lower then upperBound.
|
|
64
|
-
Assert message specifies inputName.
|
|
65
|
-
input, lowerBound, and upperBound should be of type BN.
|
|
66
|
-
inputName should be a string.
|
|
67
|
-
*/
|
|
68
|
-
function assertInRange(input, lowerBound, upperBound, inputName) {
|
|
69
|
-
if (inputName === void 0) { inputName = ''; }
|
|
70
|
-
var messageSuffix = inputName === '' ? 'invalid length' : "invalid ".concat(inputName, " length");
|
|
71
|
-
var inputBn = toBN(input);
|
|
72
|
-
(0, minimalistic_assert_1.default)(inputBn.gte(toBN(lowerBound)) && inputBn.lt(toBN(upperBound)), "Message not signable, ".concat(messageSuffix, "."));
|
|
73
|
-
}
|
|
74
|
-
exports.assertInRange = assertInRange;
|
|
75
|
-
function bigNumberishArrayToDecimalStringArray(rawCalldata) {
|
|
76
|
-
return rawCalldata.map(function (x) { return toBN(x).toString(10); });
|
|
77
|
-
}
|
|
78
|
-
exports.bigNumberishArrayToDecimalStringArray = bigNumberishArrayToDecimalStringArray;
|
|
79
|
-
function bigNumberishArrayToHexadecimalStringArray(rawCalldata) {
|
|
80
|
-
return rawCalldata.map(function (x) { return toHex(toBN(x)); });
|
|
81
|
-
}
|
|
82
|
-
exports.bigNumberishArrayToHexadecimalStringArray = bigNumberishArrayToHexadecimalStringArray;
|
|
83
|
-
var isStringWholeNumber = function (value) { return /^\d+$/.test(value); };
|
|
84
|
-
exports.isStringWholeNumber = isStringWholeNumber;
|
|
85
|
-
var toHexString = function (value) { return toHex(toBN(value)); };
|
|
86
|
-
exports.toHexString = toHexString;
|
|
87
|
-
function getDecimalString(value) {
|
|
88
|
-
if (isHex(value)) {
|
|
89
|
-
return hexToDecimalString(value);
|
|
90
|
-
}
|
|
91
|
-
if ((0, exports.isStringWholeNumber)(value)) {
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
|
-
throw new Error("".concat(value, " need to be hex-string or whole-number-string"));
|
|
95
|
-
}
|
|
96
|
-
exports.getDecimalString = getDecimalString;
|
|
97
|
-
function getHexString(value) {
|
|
98
|
-
if (isHex(value)) {
|
|
99
|
-
return value;
|
|
100
|
-
}
|
|
101
|
-
if ((0, exports.isStringWholeNumber)(value)) {
|
|
102
|
-
return (0, exports.toHexString)(value);
|
|
103
|
-
}
|
|
104
|
-
throw new Error("".concat(value, " need to be hex-string or whole-number-string"));
|
|
105
|
-
}
|
|
106
|
-
exports.getHexString = getHexString;
|
|
107
|
-
function getHexStringArray(value) {
|
|
108
|
-
return value.map(function (el) { return getHexString(el); });
|
|
109
|
-
}
|
|
110
|
-
exports.getHexStringArray = getHexStringArray;
|
|
111
|
-
var toCairoBool = function (value) { return (+value).toString(); };
|
|
112
|
-
exports.toCairoBool = toCairoBool;
|
package/utils/provider.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { CompiledContract, ContractClass, RawCalldata } from '../types';
|
|
2
|
-
export declare function wait(delay: number): Promise<unknown>;
|
|
3
|
-
export declare function parseCalldata(calldata?: RawCalldata): string[];
|
|
4
|
-
export declare function parseContract(contract: CompiledContract | string): ContractClass;
|
package/utils/provider.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.parseContract = exports.parseCalldata = exports.wait = void 0;
|
|
15
|
-
var json_1 = require("./json");
|
|
16
|
-
var number_1 = require("./number");
|
|
17
|
-
var stark_1 = require("./stark");
|
|
18
|
-
function wait(delay) {
|
|
19
|
-
return new Promise(function (res) {
|
|
20
|
-
setTimeout(res, delay);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
exports.wait = wait;
|
|
24
|
-
function parseCalldata(calldata) {
|
|
25
|
-
if (calldata === void 0) { calldata = []; }
|
|
26
|
-
return calldata.map(function (data) {
|
|
27
|
-
if (typeof data === 'string' && (0, number_1.isHex)(data)) {
|
|
28
|
-
return data;
|
|
29
|
-
}
|
|
30
|
-
return (0, number_1.toHex)((0, number_1.toBN)(data));
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
exports.parseCalldata = parseCalldata;
|
|
34
|
-
function parseContract(contract) {
|
|
35
|
-
var parsedContract = typeof contract === 'string' ? (0, json_1.parse)(contract) : contract;
|
|
36
|
-
return __assign(__assign({}, parsedContract), { program: (0, stark_1.compressProgram)(parsedContract.program) });
|
|
37
|
-
}
|
|
38
|
-
exports.parseContract = parseContract;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CallContractResponse, DeclareContractResponse, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionReceiptResponse, GetTransactionResponse, InvokeFunctionResponse } from '../../types';
|
|
2
|
-
export declare abstract class ResponseParser {
|
|
3
|
-
abstract parseGetBlockResponse(res: any): GetBlockResponse;
|
|
4
|
-
abstract parseGetTransactionResponse(res: any): GetTransactionResponse;
|
|
5
|
-
abstract parseGetTransactionReceiptResponse(res: any): GetTransactionReceiptResponse;
|
|
6
|
-
abstract parseFeeEstimateResponse(res: any): EstimateFeeResponse;
|
|
7
|
-
abstract parseCallContractResponse(res: any): CallContractResponse;
|
|
8
|
-
abstract parseInvokeFunctionResponse(res: any): InvokeFunctionResponse;
|
|
9
|
-
abstract parseDeployContractResponse(res: any): DeployContractResponse;
|
|
10
|
-
abstract parseDeclareContractResponse(res: any): DeclareContractResponse;
|
|
11
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResponseParser = void 0;
|
|
4
|
-
var ResponseParser = /** @class */ (function () {
|
|
5
|
-
function ResponseParser() {
|
|
6
|
-
}
|
|
7
|
-
return ResponseParser;
|
|
8
|
-
}());
|
|
9
|
-
exports.ResponseParser = ResponseParser;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Map RPC Response to common interface response
|
|
3
|
-
* Intersection (sequencer response ∩ (∪ rpc responses))
|
|
4
|
-
*/
|
|
5
|
-
import { CallContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionResponse } from '../../types';
|
|
6
|
-
import { RPC } from '../../types/api';
|
|
7
|
-
import { ResponseParser } from '.';
|
|
8
|
-
declare type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
11
|
-
declare type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
|
-
export declare class RPCResponseParser implements Omit<ResponseParser, 'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse' | 'parseGetTransactionReceiptResponse'> {
|
|
15
|
-
parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse;
|
|
16
|
-
parseGetTransactionResponse(res: GetTransactionByHashResponse): GetTransactionResponse;
|
|
17
|
-
parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse;
|
|
18
|
-
parseCallContractResponse(res: Array<string>): CallContractResponse;
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RPCResponseParser = void 0;
|
|
4
|
-
var number_1 = require("../number");
|
|
5
|
-
var RPCResponseParser = /** @class */ (function () {
|
|
6
|
-
function RPCResponseParser() {
|
|
7
|
-
}
|
|
8
|
-
RPCResponseParser.prototype.parseGetBlockResponse = function (res) {
|
|
9
|
-
return {
|
|
10
|
-
timestamp: res.timestamp,
|
|
11
|
-
block_hash: res.block_hash,
|
|
12
|
-
block_number: res.block_number,
|
|
13
|
-
new_root: res.new_root,
|
|
14
|
-
parent_hash: res.parent_hash,
|
|
15
|
-
status: res.status,
|
|
16
|
-
transactions: res.transactions,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
RPCResponseParser.prototype.parseGetTransactionResponse = function (res) {
|
|
20
|
-
return {
|
|
21
|
-
calldata: res.calldata || [],
|
|
22
|
-
contract_address: res.contract_address,
|
|
23
|
-
max_fee: res.max_fee,
|
|
24
|
-
nonce: res.nonce,
|
|
25
|
-
signature: res.signature || [],
|
|
26
|
-
transaction_hash: res.transaction_hash,
|
|
27
|
-
version: res.version,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
RPCResponseParser.prototype.parseFeeEstimateResponse = function (res) {
|
|
31
|
-
return {
|
|
32
|
-
overall_fee: (0, number_1.toBN)(res.overall_fee),
|
|
33
|
-
gas_consumed: (0, number_1.toBN)(res.gas_consumed),
|
|
34
|
-
gas_price: (0, number_1.toBN)(res.gas_price),
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
RPCResponseParser.prototype.parseCallContractResponse = function (res) {
|
|
38
|
-
return {
|
|
39
|
-
result: res,
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
return RPCResponseParser;
|
|
43
|
-
}());
|
|
44
|
-
exports.RPCResponseParser = RPCResponseParser;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Map Sequencer Response to common interface response
|
|
3
|
-
* Intersection (sequencer response ∩ (∪ rpc responses))
|
|
4
|
-
*/
|
|
5
|
-
import { CallContractResponse, DeclareContractResponse, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionReceiptResponse, GetTransactionResponse, InvokeFunctionResponse } from '../../types';
|
|
6
|
-
import { Sequencer } from '../../types/api';
|
|
7
|
-
import { ResponseParser } from '.';
|
|
8
|
-
export declare class SequencerAPIResponseParser extends ResponseParser {
|
|
9
|
-
parseGetBlockResponse(res: Sequencer.GetBlockResponse): GetBlockResponse;
|
|
10
|
-
parseGetTransactionResponse(res: Sequencer.GetTransactionResponse): GetTransactionResponse;
|
|
11
|
-
parseGetTransactionReceiptResponse(res: Sequencer.TransactionReceiptResponse): GetTransactionReceiptResponse;
|
|
12
|
-
parseFeeEstimateResponse(res: Sequencer.EstimateFeeResponse): EstimateFeeResponse;
|
|
13
|
-
parseCallContractResponse(res: Sequencer.CallContractResponse): CallContractResponse;
|
|
14
|
-
parseInvokeFunctionResponse(res: Sequencer.AddTransactionResponse): InvokeFunctionResponse;
|
|
15
|
-
parseDeployContractResponse(res: Sequencer.AddTransactionResponse): DeployContractResponse;
|
|
16
|
-
parseDeclareContractResponse(res: Sequencer.AddTransactionResponse): DeclareContractResponse;
|
|
17
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.SequencerAPIResponseParser = void 0;
|
|
30
|
-
var number_1 = require("../number");
|
|
31
|
-
var _1 = require(".");
|
|
32
|
-
var SequencerAPIResponseParser = /** @class */ (function (_super) {
|
|
33
|
-
__extends(SequencerAPIResponseParser, _super);
|
|
34
|
-
function SequencerAPIResponseParser() {
|
|
35
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
36
|
-
}
|
|
37
|
-
SequencerAPIResponseParser.prototype.parseGetBlockResponse = function (res) {
|
|
38
|
-
return __assign(__assign({}, res), { new_root: res.state_root, parent_hash: res.parent_block_hash, transactions: Object.values(res.transactions)
|
|
39
|
-
.map(function (value) { return 'transaction_hash' in value && value.transaction_hash; })
|
|
40
|
-
.filter(Boolean) });
|
|
41
|
-
};
|
|
42
|
-
SequencerAPIResponseParser.prototype.parseGetTransactionResponse = function (res) {
|
|
43
|
-
return __assign(__assign({}, res), { calldata: 'calldata' in res.transaction ? res.transaction.calldata : [], contract_address: 'contract_address' in res.transaction ? res.transaction.contract_address : undefined, contract_class: 'contract_class' in res.transaction ? res.transaction.contract_class : undefined, entry_point_selector: 'entry_point_selector' in res.transaction
|
|
44
|
-
? res.transaction.entry_point_selector
|
|
45
|
-
: undefined, max_fee: 'max_fee' in res.transaction ? res.transaction.max_fee : undefined, nonce: res.transaction.nonce, sender_address: 'sender_address' in res.transaction
|
|
46
|
-
? res.transaction.sender_address
|
|
47
|
-
: undefined, signature: 'signature' in res.transaction ? res.transaction.signature : undefined, transaction_hash: 'transaction_hash' in res.transaction ? res.transaction.transaction_hash : undefined, version: 'version' in res.transaction ? res.transaction.version : undefined });
|
|
48
|
-
};
|
|
49
|
-
SequencerAPIResponseParser.prototype.parseGetTransactionReceiptResponse = function (res) {
|
|
50
|
-
return __assign(__assign(__assign(__assign(__assign(__assign(__assign({ transaction_hash: res.transaction_hash, status: res.status, messages_sent: res.l2_to_l1_messages, events: res.events }, ('block_hash' in res && { block_hash: res.block_hash })), ('block_number' in res && { block_number: res.block_number })), ('actual_fee' in res && { actual_fee: res.actual_fee })), ('transaction_index' in res && { transaction_index: res.transaction_index })), ('execution_resources' in res && { execution_resources: res.execution_resources })), ('l1_to_l2_consumed_message' in res && {
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
52
|
-
l1_to_l2_consumed_message: res['l1_to_l2_consumed_message'],
|
|
53
|
-
})), ('transaction_failure_reason' in res && {
|
|
54
|
-
transaction_failure_reason: res.transaction_failure_reason,
|
|
55
|
-
}));
|
|
56
|
-
};
|
|
57
|
-
SequencerAPIResponseParser.prototype.parseFeeEstimateResponse = function (res) {
|
|
58
|
-
if ('overall_fee' in res) {
|
|
59
|
-
var gasInfo = {};
|
|
60
|
-
try {
|
|
61
|
-
gasInfo = {
|
|
62
|
-
gas_consumed: (0, number_1.toBN)(res.gas_usage),
|
|
63
|
-
gas_price: (0, number_1.toBN)(res.gas_price),
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
catch (_a) {
|
|
67
|
-
// do nothing
|
|
68
|
-
}
|
|
69
|
-
return __assign({ overall_fee: (0, number_1.toBN)(res.overall_fee) }, gasInfo);
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
overall_fee: (0, number_1.toBN)(res.amount),
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
SequencerAPIResponseParser.prototype.parseCallContractResponse = function (res) {
|
|
76
|
-
return {
|
|
77
|
-
result: res.result,
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
SequencerAPIResponseParser.prototype.parseInvokeFunctionResponse = function (res) {
|
|
81
|
-
return {
|
|
82
|
-
transaction_hash: res.transaction_hash,
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
SequencerAPIResponseParser.prototype.parseDeployContractResponse = function (res) {
|
|
86
|
-
return {
|
|
87
|
-
transaction_hash: res.transaction_hash,
|
|
88
|
-
contract_address: res.address,
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
SequencerAPIResponseParser.prototype.parseDeclareContractResponse = function (res) {
|
|
92
|
-
return {
|
|
93
|
-
transaction_hash: res.transaction_hash,
|
|
94
|
-
class_hash: res.class_hash,
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
return SequencerAPIResponseParser;
|
|
98
|
-
}(_1.ResponseParser));
|
|
99
|
-
exports.SequencerAPIResponseParser = SequencerAPIResponseParser;
|
package/utils/shortString.d.ts
DELETED
package/utils/shortString.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeShortString = exports.encodeShortString = exports.isShortString = exports.isASCII = void 0;
|
|
4
|
-
var encode_1 = require("./encode");
|
|
5
|
-
function isASCII(str) {
|
|
6
|
-
// eslint-disable-next-line no-control-regex
|
|
7
|
-
return /^[\x00-\x7F]*$/.test(str);
|
|
8
|
-
}
|
|
9
|
-
exports.isASCII = isASCII;
|
|
10
|
-
// function to check if string has less or equal 31 characters
|
|
11
|
-
function isShortString(str) {
|
|
12
|
-
return str.length <= 31;
|
|
13
|
-
}
|
|
14
|
-
exports.isShortString = isShortString;
|
|
15
|
-
function encodeShortString(str) {
|
|
16
|
-
if (!isASCII(str))
|
|
17
|
-
throw new Error("".concat(str, " is not an ASCII string"));
|
|
18
|
-
if (!isShortString(str))
|
|
19
|
-
throw new Error("".concat(str, " is too long"));
|
|
20
|
-
return (0, encode_1.addHexPrefix)(str.replace(/./g, function (char) { return char.charCodeAt(0).toString(16); }));
|
|
21
|
-
}
|
|
22
|
-
exports.encodeShortString = encodeShortString;
|
|
23
|
-
function decodeShortString(str) {
|
|
24
|
-
return (0, encode_1.removeHexPrefix)(str).replace(/.{2}/g, function (hex) { return String.fromCharCode(parseInt(hex, 16)); });
|
|
25
|
-
}
|
|
26
|
-
exports.decodeShortString = decodeShortString;
|
package/utils/stark.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import BN from 'bn.js';
|
|
2
|
-
import { Calldata, CompressedProgram, Program, RawArgs, Signature } from '../types';
|
|
3
|
-
import { BigNumberish } from './number';
|
|
4
|
-
/**
|
|
5
|
-
* Function to compress compiled cairo program
|
|
6
|
-
*
|
|
7
|
-
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/services/api/gateway/transaction.py#L54-L58)
|
|
8
|
-
* @param jsonProgram - json file representing the compiled cairo program
|
|
9
|
-
* @returns Compressed cairo program
|
|
10
|
-
*/
|
|
11
|
-
export declare function compressProgram(jsonProgram: Program | string): CompressedProgram;
|
|
12
|
-
export declare function randomAddress(): string;
|
|
13
|
-
export declare function makeAddress(input: string): string;
|
|
14
|
-
export declare function formatSignature(sig?: Signature): string[];
|
|
15
|
-
export declare function compileCalldata(args: RawArgs): Calldata;
|
|
16
|
-
export declare function estimatedFeeToMaxFee(estimatedFee: BigNumberish, overhead?: number): BN;
|
package/utils/stark.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.estimatedFeeToMaxFee = exports.compileCalldata = exports.formatSignature = exports.makeAddress = exports.randomAddress = exports.compressProgram = void 0;
|
|
29
|
-
var pako_1 = require("pako");
|
|
30
|
-
var ellipticCurve_1 = require("./ellipticCurve");
|
|
31
|
-
var encode_1 = require("./encode");
|
|
32
|
-
var json_1 = require("./json");
|
|
33
|
-
var number_1 = require("./number");
|
|
34
|
-
/**
|
|
35
|
-
* Function to compress compiled cairo program
|
|
36
|
-
*
|
|
37
|
-
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/services/api/gateway/transaction.py#L54-L58)
|
|
38
|
-
* @param jsonProgram - json file representing the compiled cairo program
|
|
39
|
-
* @returns Compressed cairo program
|
|
40
|
-
*/
|
|
41
|
-
function compressProgram(jsonProgram) {
|
|
42
|
-
var stringified = typeof jsonProgram === 'string' ? jsonProgram : (0, json_1.stringify)(jsonProgram);
|
|
43
|
-
var compressedProgram = (0, pako_1.gzip)(stringified);
|
|
44
|
-
return (0, encode_1.btoaUniversal)(compressedProgram);
|
|
45
|
-
}
|
|
46
|
-
exports.compressProgram = compressProgram;
|
|
47
|
-
function randomAddress() {
|
|
48
|
-
var randomKeyPair = (0, ellipticCurve_1.genKeyPair)();
|
|
49
|
-
return (0, ellipticCurve_1.getStarkKey)(randomKeyPair);
|
|
50
|
-
}
|
|
51
|
-
exports.randomAddress = randomAddress;
|
|
52
|
-
function makeAddress(input) {
|
|
53
|
-
return (0, encode_1.addHexPrefix)(input).toLowerCase();
|
|
54
|
-
}
|
|
55
|
-
exports.makeAddress = makeAddress;
|
|
56
|
-
function formatSignature(sig) {
|
|
57
|
-
if (!sig)
|
|
58
|
-
return [];
|
|
59
|
-
try {
|
|
60
|
-
return sig.map(function (x) { return (0, number_1.toBN)(x); }).map(function (x) { return x.toString(); });
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.formatSignature = formatSignature;
|
|
67
|
-
function compileCalldata(args) {
|
|
68
|
-
return Object.values(args).flatMap(function (value) {
|
|
69
|
-
if (Array.isArray(value))
|
|
70
|
-
return __spreadArray([(0, number_1.toBN)(value.length).toString()], __read(value.map(function (x) { return (0, number_1.toBN)(x).toString(); })), false);
|
|
71
|
-
if (typeof value === 'object' && 'type' in value)
|
|
72
|
-
return Object.entries(value)
|
|
73
|
-
.filter(function (_a) {
|
|
74
|
-
var _b = __read(_a, 1), k = _b[0];
|
|
75
|
-
return k !== 'type';
|
|
76
|
-
})
|
|
77
|
-
.map(function (_a) {
|
|
78
|
-
var _b = __read(_a, 2), v = _b[1];
|
|
79
|
-
return (0, number_1.toBN)(v).toString();
|
|
80
|
-
});
|
|
81
|
-
return (0, number_1.toBN)(value).toString();
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
exports.compileCalldata = compileCalldata;
|
|
85
|
-
function estimatedFeeToMaxFee(estimatedFee, overhead) {
|
|
86
|
-
if (overhead === void 0) { overhead = 0.5; }
|
|
87
|
-
// BN can only handle Integers, so we need to do all calulations with integers
|
|
88
|
-
var overHeadPercent = Math.round((1 + overhead) * 100);
|
|
89
|
-
return (0, number_1.toBN)(estimatedFee).mul((0, number_1.toBN)(overHeadPercent)).div((0, number_1.toBN)(100));
|
|
90
|
-
}
|
|
91
|
-
exports.estimatedFeeToMaxFee = estimatedFeeToMaxFee;
|
package/utils/transaction.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Call, ParsedStruct } from '../types';
|
|
2
|
-
import { BigNumberish } from './number';
|
|
3
|
-
/**
|
|
4
|
-
* Transforms a list of Calls, each with their own calldata, into
|
|
5
|
-
* two arrays: one with the entrypoints, and one with the concatenated calldata.
|
|
6
|
-
* @param calls
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
export declare const transformCallsToMulticallArrays: (calls: Call[]) => {
|
|
10
|
-
callArray: ParsedStruct[];
|
|
11
|
-
calldata: string[];
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Transforms a list of calls in the full flattened calldata expected
|
|
15
|
-
* by the __execute__ protocol.
|
|
16
|
-
* @param calls
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
export declare const fromCallsToExecuteCalldata: (calls: Call[]) => string[];
|
|
20
|
-
export declare const fromCallsToExecuteCalldataWithNonce: (calls: Call[], nonce: BigNumberish) => string[];
|
package/utils/transaction.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.fromCallsToExecuteCalldataWithNonce = exports.fromCallsToExecuteCalldata = exports.transformCallsToMulticallArrays = void 0;
|
|
29
|
-
var hash_1 = require("./hash");
|
|
30
|
-
var number_1 = require("./number");
|
|
31
|
-
/**
|
|
32
|
-
* Transforms a list of Calls, each with their own calldata, into
|
|
33
|
-
* two arrays: one with the entrypoints, and one with the concatenated calldata.
|
|
34
|
-
* @param calls
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
var transformCallsToMulticallArrays = function (calls) {
|
|
38
|
-
var callArray = [];
|
|
39
|
-
var calldata = [];
|
|
40
|
-
calls.forEach(function (call) {
|
|
41
|
-
var data = call.calldata || [];
|
|
42
|
-
callArray.push({
|
|
43
|
-
to: (0, number_1.toBN)(call.contractAddress).toString(10),
|
|
44
|
-
selector: (0, number_1.toBN)((0, hash_1.getSelectorFromName)(call.entrypoint)).toString(10),
|
|
45
|
-
data_offset: calldata.length.toString(),
|
|
46
|
-
data_len: data.length.toString(),
|
|
47
|
-
});
|
|
48
|
-
calldata.push.apply(calldata, __spreadArray([], __read(data), false));
|
|
49
|
-
});
|
|
50
|
-
return {
|
|
51
|
-
callArray: callArray,
|
|
52
|
-
calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)(calldata),
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
exports.transformCallsToMulticallArrays = transformCallsToMulticallArrays;
|
|
56
|
-
/**
|
|
57
|
-
* Transforms a list of calls in the full flattened calldata expected
|
|
58
|
-
* by the __execute__ protocol.
|
|
59
|
-
* @param calls
|
|
60
|
-
* @returns
|
|
61
|
-
*/
|
|
62
|
-
var fromCallsToExecuteCalldata = function (calls) {
|
|
63
|
-
var _a = (0, exports.transformCallsToMulticallArrays)(calls), callArray = _a.callArray, calldata = _a.calldata;
|
|
64
|
-
return __spreadArray(__spreadArray(__spreadArray([
|
|
65
|
-
callArray.length.toString()
|
|
66
|
-
], __read(callArray
|
|
67
|
-
.map(function (_a) {
|
|
68
|
-
var to = _a.to, selector = _a.selector, data_offset = _a.data_offset, data_len = _a.data_len;
|
|
69
|
-
return [to, selector, data_offset, data_len];
|
|
70
|
-
})
|
|
71
|
-
.flat()), false), [
|
|
72
|
-
calldata.length.toString()
|
|
73
|
-
], false), __read(calldata), false);
|
|
74
|
-
};
|
|
75
|
-
exports.fromCallsToExecuteCalldata = fromCallsToExecuteCalldata;
|
|
76
|
-
var fromCallsToExecuteCalldataWithNonce = function (calls, nonce) {
|
|
77
|
-
return __spreadArray(__spreadArray([], __read((0, exports.fromCallsToExecuteCalldata)(calls)), false), [(0, number_1.toBN)(nonce).toString()], false);
|
|
78
|
-
};
|
|
79
|
-
exports.fromCallsToExecuteCalldataWithNonce = fromCallsToExecuteCalldataWithNonce;
|