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/account/default.js
DELETED
|
@@ -1,526 +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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
-
function step(op) {
|
|
42
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (_) try {
|
|
44
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
-
switch (op[0]) {
|
|
47
|
-
case 0: case 1: t = op; break;
|
|
48
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
-
default:
|
|
52
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
-
if (t[2]) _.ops.pop();
|
|
57
|
-
_.trys.pop(); continue;
|
|
58
|
-
}
|
|
59
|
-
op = body.call(thisArg, _);
|
|
60
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
65
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
66
|
-
if (!m) return o;
|
|
67
|
-
var i = m.call(o), r, ar = [], e;
|
|
68
|
-
try {
|
|
69
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
70
|
-
}
|
|
71
|
-
catch (error) { e = { error: error }; }
|
|
72
|
-
finally {
|
|
73
|
-
try {
|
|
74
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
75
|
-
}
|
|
76
|
-
finally { if (e) throw e.error; }
|
|
77
|
-
}
|
|
78
|
-
return ar;
|
|
79
|
-
};
|
|
80
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
81
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
82
|
-
if (ar || !(i in from)) {
|
|
83
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
84
|
-
ar[i] = from[i];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
88
|
-
};
|
|
89
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
90
|
-
exports.Account = void 0;
|
|
91
|
-
var constants_1 = require("../constants");
|
|
92
|
-
var default_1 = require("../provider/default");
|
|
93
|
-
var signer_1 = require("../signer");
|
|
94
|
-
var hash_1 = require("../utils/hash");
|
|
95
|
-
var number_1 = require("../utils/number");
|
|
96
|
-
var provider_1 = require("../utils/provider");
|
|
97
|
-
var stark_1 = require("../utils/stark");
|
|
98
|
-
var transaction_1 = require("../utils/transaction");
|
|
99
|
-
var typedData_1 = require("../utils/typedData");
|
|
100
|
-
var Account = /** @class */ (function (_super) {
|
|
101
|
-
__extends(Account, _super);
|
|
102
|
-
function Account(providerOrOptions, address, keyPairOrSigner) {
|
|
103
|
-
var _this = _super.call(this, providerOrOptions) || this;
|
|
104
|
-
_this.address = address.toLowerCase();
|
|
105
|
-
_this.signer =
|
|
106
|
-
'getPubKey' in keyPairOrSigner ? keyPairOrSigner : new signer_1.Signer(keyPairOrSigner);
|
|
107
|
-
return _this;
|
|
108
|
-
}
|
|
109
|
-
Account.prototype.getNonce = function (blockIdentifier) {
|
|
110
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
-
return __generator(this, function (_a) {
|
|
112
|
-
return [2 /*return*/, _super.prototype.getNonce.call(this, this.address, blockIdentifier)];
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
Account.prototype.estimateFee = function (calls, estimateFeeDetails) {
|
|
117
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
return __generator(this, function (_a) {
|
|
119
|
-
return [2 /*return*/, this.estimateInvokeFee(calls, estimateFeeDetails)];
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
Account.prototype.estimateInvokeFee = function (calls, _a) {
|
|
124
|
-
var _b = _a === void 0 ? {} : _a, providedNonce = _b.nonce, blockIdentifier = _b.blockIdentifier;
|
|
125
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
-
var transactions, nonce, _c, _d, version, chainId, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
127
|
-
return __generator(this, function (_e) {
|
|
128
|
-
switch (_e.label) {
|
|
129
|
-
case 0:
|
|
130
|
-
transactions = Array.isArray(calls) ? calls : [calls];
|
|
131
|
-
_c = number_1.toBN;
|
|
132
|
-
if (!(providedNonce !== null && providedNonce !== void 0)) return [3 /*break*/, 1];
|
|
133
|
-
_d = providedNonce;
|
|
134
|
-
return [3 /*break*/, 3];
|
|
135
|
-
case 1: return [4 /*yield*/, this.getNonce()];
|
|
136
|
-
case 2:
|
|
137
|
-
_d = (_e.sent());
|
|
138
|
-
_e.label = 3;
|
|
139
|
-
case 3:
|
|
140
|
-
nonce = _c.apply(void 0, [_d]);
|
|
141
|
-
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
142
|
-
return [4 /*yield*/, this.getChainId()];
|
|
143
|
-
case 4:
|
|
144
|
-
chainId = _e.sent();
|
|
145
|
-
signerDetails = {
|
|
146
|
-
walletAddress: this.address,
|
|
147
|
-
nonce: nonce,
|
|
148
|
-
maxFee: constants_1.ZERO,
|
|
149
|
-
version: version,
|
|
150
|
-
chainId: chainId,
|
|
151
|
-
};
|
|
152
|
-
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails)];
|
|
153
|
-
case 5:
|
|
154
|
-
signature = _e.sent();
|
|
155
|
-
calldata = (0, transaction_1.fromCallsToExecuteCalldata)(transactions);
|
|
156
|
-
return [4 /*yield*/, _super.prototype.getInvokeEstimateFee.call(this, { contractAddress: this.address, calldata: calldata, signature: signature }, { version: version, nonce: nonce }, blockIdentifier)];
|
|
157
|
-
case 6:
|
|
158
|
-
response = _e.sent();
|
|
159
|
-
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(response.overall_fee);
|
|
160
|
-
return [2 /*return*/, __assign(__assign({}, response), { suggestedMaxFee: suggestedMaxFee })];
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
Account.prototype.estimateDeclareFee = function (_a, _b) {
|
|
166
|
-
var classHash = _a.classHash, contract = _a.contract;
|
|
167
|
-
var _c = _b === void 0 ? {} : _b, blockIdentifier = _c.blockIdentifier, providedNonce = _c.nonce;
|
|
168
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
169
|
-
var nonce, _d, _e, version, chainId, contractDefinition, signature, response, suggestedMaxFee;
|
|
170
|
-
return __generator(this, function (_f) {
|
|
171
|
-
switch (_f.label) {
|
|
172
|
-
case 0:
|
|
173
|
-
_d = number_1.toBN;
|
|
174
|
-
if (!(providedNonce !== null && providedNonce !== void 0)) return [3 /*break*/, 1];
|
|
175
|
-
_e = providedNonce;
|
|
176
|
-
return [3 /*break*/, 3];
|
|
177
|
-
case 1: return [4 /*yield*/, this.getNonce()];
|
|
178
|
-
case 2:
|
|
179
|
-
_e = (_f.sent());
|
|
180
|
-
_f.label = 3;
|
|
181
|
-
case 3:
|
|
182
|
-
nonce = _d.apply(void 0, [_e]);
|
|
183
|
-
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
184
|
-
return [4 /*yield*/, this.getChainId()];
|
|
185
|
-
case 4:
|
|
186
|
-
chainId = _f.sent();
|
|
187
|
-
contractDefinition = (0, provider_1.parseContract)(contract);
|
|
188
|
-
return [4 /*yield*/, this.signer.signDeclareTransaction({
|
|
189
|
-
classHash: classHash,
|
|
190
|
-
senderAddress: this.address,
|
|
191
|
-
chainId: chainId,
|
|
192
|
-
maxFee: constants_1.ZERO,
|
|
193
|
-
version: version,
|
|
194
|
-
nonce: nonce,
|
|
195
|
-
})];
|
|
196
|
-
case 5:
|
|
197
|
-
signature = _f.sent();
|
|
198
|
-
return [4 /*yield*/, _super.prototype.getDeclareEstimateFee.call(this, { senderAddress: this.address, signature: signature, contractDefinition: contractDefinition }, { version: version, nonce: nonce }, blockIdentifier)];
|
|
199
|
-
case 6:
|
|
200
|
-
response = _f.sent();
|
|
201
|
-
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(response.overall_fee);
|
|
202
|
-
return [2 /*return*/, __assign(__assign({}, response), { suggestedMaxFee: suggestedMaxFee })];
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
Account.prototype.estimateAccountDeployFee = function (_a, _b) {
|
|
208
|
-
var classHash = _a.classHash, _c = _a.addressSalt, addressSalt = _c === void 0 ? 0 : _c, _d = _a.constructorCalldata, constructorCalldata = _d === void 0 ? [] : _d, providedContractAddress = _a.contractAddress;
|
|
209
|
-
var _e = _b === void 0 ? {} : _b, blockIdentifier = _e.blockIdentifier, providedNonce = _e.nonce;
|
|
210
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
-
var nonce, _f, _g, version, chainId, contractAddress, signature, response, suggestedMaxFee;
|
|
212
|
-
return __generator(this, function (_h) {
|
|
213
|
-
switch (_h.label) {
|
|
214
|
-
case 0:
|
|
215
|
-
_f = number_1.toBN;
|
|
216
|
-
if (!(providedNonce !== null && providedNonce !== void 0)) return [3 /*break*/, 1];
|
|
217
|
-
_g = providedNonce;
|
|
218
|
-
return [3 /*break*/, 3];
|
|
219
|
-
case 1: return [4 /*yield*/, this.getNonce()];
|
|
220
|
-
case 2:
|
|
221
|
-
_g = (_h.sent());
|
|
222
|
-
_h.label = 3;
|
|
223
|
-
case 3:
|
|
224
|
-
nonce = _f.apply(void 0, [_g]);
|
|
225
|
-
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
226
|
-
return [4 /*yield*/, this.getChainId()];
|
|
227
|
-
case 4:
|
|
228
|
-
chainId = _h.sent();
|
|
229
|
-
contractAddress = providedContractAddress !== null && providedContractAddress !== void 0 ? providedContractAddress : (0, hash_1.calculateContractAddressFromHash)(addressSalt, classHash, constructorCalldata, 0);
|
|
230
|
-
return [4 /*yield*/, this.signer.signDeployAccountTransaction({
|
|
231
|
-
classHash: classHash,
|
|
232
|
-
contractAddress: contractAddress,
|
|
233
|
-
chainId: chainId,
|
|
234
|
-
maxFee: constants_1.ZERO,
|
|
235
|
-
version: version,
|
|
236
|
-
nonce: nonce,
|
|
237
|
-
addressSalt: addressSalt,
|
|
238
|
-
constructorCalldata: constructorCalldata,
|
|
239
|
-
})];
|
|
240
|
-
case 5:
|
|
241
|
-
signature = _h.sent();
|
|
242
|
-
return [4 /*yield*/, _super.prototype.getDeployAccountEstimateFee.call(this, { classHash: classHash, addressSalt: addressSalt, constructorCalldata: constructorCalldata, signature: signature }, { version: version, nonce: nonce }, blockIdentifier)];
|
|
243
|
-
case 6:
|
|
244
|
-
response = _h.sent();
|
|
245
|
-
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(response.overall_fee);
|
|
246
|
-
return [2 /*return*/, __assign(__assign({}, response), { suggestedMaxFee: suggestedMaxFee })];
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
Account.prototype.execute = function (calls, abis, transactionsDetail) {
|
|
252
|
-
var _a, _b;
|
|
253
|
-
if (abis === void 0) { abis = undefined; }
|
|
254
|
-
if (transactionsDetail === void 0) { transactionsDetail = {}; }
|
|
255
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
-
var transactions, nonce, _c, _d, maxFee, _e, version, chainId, signerDetails, signature, calldata;
|
|
257
|
-
return __generator(this, function (_f) {
|
|
258
|
-
switch (_f.label) {
|
|
259
|
-
case 0:
|
|
260
|
-
transactions = Array.isArray(calls) ? calls : [calls];
|
|
261
|
-
_c = number_1.toBN;
|
|
262
|
-
if (!((_a = transactionsDetail.nonce) !== null && _a !== void 0)) return [3 /*break*/, 1];
|
|
263
|
-
_d = _a;
|
|
264
|
-
return [3 /*break*/, 3];
|
|
265
|
-
case 1: return [4 /*yield*/, this.getNonce()];
|
|
266
|
-
case 2:
|
|
267
|
-
_d = (_f.sent());
|
|
268
|
-
_f.label = 3;
|
|
269
|
-
case 3:
|
|
270
|
-
nonce = _c.apply(void 0, [_d]);
|
|
271
|
-
if (!((_b = transactionsDetail.maxFee) !== null && _b !== void 0)) return [3 /*break*/, 4];
|
|
272
|
-
_e = _b;
|
|
273
|
-
return [3 /*break*/, 6];
|
|
274
|
-
case 4: return [4 /*yield*/, this.getSuggestedMaxFee({ type: 'INVOKE', payload: calls }, transactionsDetail)];
|
|
275
|
-
case 5:
|
|
276
|
-
_e = (_f.sent());
|
|
277
|
-
_f.label = 6;
|
|
278
|
-
case 6:
|
|
279
|
-
maxFee = _e;
|
|
280
|
-
version = (0, number_1.toBN)(hash_1.transactionVersion);
|
|
281
|
-
return [4 /*yield*/, this.getChainId()];
|
|
282
|
-
case 7:
|
|
283
|
-
chainId = _f.sent();
|
|
284
|
-
signerDetails = {
|
|
285
|
-
walletAddress: this.address,
|
|
286
|
-
nonce: nonce,
|
|
287
|
-
maxFee: maxFee,
|
|
288
|
-
version: version,
|
|
289
|
-
chainId: chainId,
|
|
290
|
-
};
|
|
291
|
-
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails, abis)];
|
|
292
|
-
case 8:
|
|
293
|
-
signature = _f.sent();
|
|
294
|
-
calldata = (0, transaction_1.fromCallsToExecuteCalldata)(transactions);
|
|
295
|
-
return [2 /*return*/, this.invokeFunction({ contractAddress: this.address, calldata: calldata, signature: signature }, {
|
|
296
|
-
nonce: nonce,
|
|
297
|
-
maxFee: maxFee,
|
|
298
|
-
version: version,
|
|
299
|
-
})];
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
Account.prototype.declare = function (_a, transactionsDetail) {
|
|
305
|
-
var _b, _c;
|
|
306
|
-
var classHash = _a.classHash, contract = _a.contract;
|
|
307
|
-
if (transactionsDetail === void 0) { transactionsDetail = {}; }
|
|
308
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
309
|
-
var nonce, _d, _e, maxFee, _f, version, chainId, signature, contractDefinition;
|
|
310
|
-
return __generator(this, function (_g) {
|
|
311
|
-
switch (_g.label) {
|
|
312
|
-
case 0:
|
|
313
|
-
_d = number_1.toBN;
|
|
314
|
-
if (!((_b = transactionsDetail.nonce) !== null && _b !== void 0)) return [3 /*break*/, 1];
|
|
315
|
-
_e = _b;
|
|
316
|
-
return [3 /*break*/, 3];
|
|
317
|
-
case 1: return [4 /*yield*/, this.getNonce()];
|
|
318
|
-
case 2:
|
|
319
|
-
_e = (_g.sent());
|
|
320
|
-
_g.label = 3;
|
|
321
|
-
case 3:
|
|
322
|
-
nonce = _d.apply(void 0, [_e]);
|
|
323
|
-
if (!((_c = transactionsDetail.maxFee) !== null && _c !== void 0)) return [3 /*break*/, 4];
|
|
324
|
-
_f = _c;
|
|
325
|
-
return [3 /*break*/, 6];
|
|
326
|
-
case 4: return [4 /*yield*/, this.getSuggestedMaxFee({ type: 'DECLARE', payload: { classHash: classHash, contract: contract } }, transactionsDetail)];
|
|
327
|
-
case 5:
|
|
328
|
-
_f = (_g.sent());
|
|
329
|
-
_g.label = 6;
|
|
330
|
-
case 6:
|
|
331
|
-
maxFee = _f;
|
|
332
|
-
version = (0, number_1.toBN)(hash_1.transactionVersion);
|
|
333
|
-
return [4 /*yield*/, this.getChainId()];
|
|
334
|
-
case 7:
|
|
335
|
-
chainId = _g.sent();
|
|
336
|
-
return [4 /*yield*/, this.signer.signDeclareTransaction({
|
|
337
|
-
classHash: classHash,
|
|
338
|
-
senderAddress: this.address,
|
|
339
|
-
chainId: chainId,
|
|
340
|
-
maxFee: maxFee,
|
|
341
|
-
version: version,
|
|
342
|
-
nonce: nonce,
|
|
343
|
-
})];
|
|
344
|
-
case 8:
|
|
345
|
-
signature = _g.sent();
|
|
346
|
-
contractDefinition = (0, provider_1.parseContract)(contract);
|
|
347
|
-
return [2 /*return*/, this.declareContract({ contractDefinition: contractDefinition, senderAddress: this.address, signature: signature }, {
|
|
348
|
-
nonce: nonce,
|
|
349
|
-
maxFee: maxFee,
|
|
350
|
-
version: version,
|
|
351
|
-
})];
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
};
|
|
356
|
-
Account.prototype.deploy = function (_a, additionalCalls, // support multicall
|
|
357
|
-
transactionsDetail) {
|
|
358
|
-
var classHash = _a.classHash, salt = _a.salt, _b = _a.unique, unique = _b === void 0 ? true : _b, _c = _a.constructorCalldata, constructorCalldata = _c === void 0 ? [] : _c, _d = _a.isDevnet, isDevnet = _d === void 0 ? false : _d;
|
|
359
|
-
if (additionalCalls === void 0) { additionalCalls = []; }
|
|
360
|
-
if (transactionsDetail === void 0) { transactionsDetail = {}; }
|
|
361
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
362
|
-
var compiledConstructorCallData, callsArray;
|
|
363
|
-
return __generator(this, function (_e) {
|
|
364
|
-
compiledConstructorCallData = (0, stark_1.compileCalldata)(constructorCalldata);
|
|
365
|
-
callsArray = Array.isArray(additionalCalls) ? additionalCalls : [additionalCalls];
|
|
366
|
-
return [2 /*return*/, this.execute(__spreadArray([
|
|
367
|
-
{
|
|
368
|
-
contractAddress: isDevnet ? constants_1.UDC.ADDRESS_DEVNET : constants_1.UDC.ADDRESS,
|
|
369
|
-
entrypoint: constants_1.UDC.ENTRYPOINT,
|
|
370
|
-
calldata: __spreadArray([
|
|
371
|
-
classHash,
|
|
372
|
-
salt,
|
|
373
|
-
(0, number_1.toCairoBool)(unique),
|
|
374
|
-
compiledConstructorCallData.length
|
|
375
|
-
], __read(compiledConstructorCallData), false),
|
|
376
|
-
}
|
|
377
|
-
], __read(callsArray), false), undefined, transactionsDetail)];
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
};
|
|
381
|
-
Account.prototype.deployAccount = function (_a, transactionsDetail) {
|
|
382
|
-
var _b, _c;
|
|
383
|
-
var classHash = _a.classHash, _d = _a.constructorCalldata, constructorCalldata = _d === void 0 ? [] : _d, _e = _a.addressSalt, addressSalt = _e === void 0 ? 0 : _e, providedContractAddress = _a.contractAddress;
|
|
384
|
-
if (transactionsDetail === void 0) { transactionsDetail = {}; }
|
|
385
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
386
|
-
var nonce, _f, _g, version, chainId, contractAddress, maxFee, _h, signature;
|
|
387
|
-
return __generator(this, function (_j) {
|
|
388
|
-
switch (_j.label) {
|
|
389
|
-
case 0:
|
|
390
|
-
_f = number_1.toBN;
|
|
391
|
-
if (!((_b = transactionsDetail.nonce) !== null && _b !== void 0)) return [3 /*break*/, 1];
|
|
392
|
-
_g = _b;
|
|
393
|
-
return [3 /*break*/, 3];
|
|
394
|
-
case 1: return [4 /*yield*/, this.getNonce()];
|
|
395
|
-
case 2:
|
|
396
|
-
_g = (_j.sent());
|
|
397
|
-
_j.label = 3;
|
|
398
|
-
case 3:
|
|
399
|
-
nonce = _f.apply(void 0, [_g]);
|
|
400
|
-
version = (0, number_1.toBN)(hash_1.transactionVersion);
|
|
401
|
-
return [4 /*yield*/, this.getChainId()];
|
|
402
|
-
case 4:
|
|
403
|
-
chainId = _j.sent();
|
|
404
|
-
contractAddress = providedContractAddress !== null && providedContractAddress !== void 0 ? providedContractAddress : (0, hash_1.calculateContractAddressFromHash)(addressSalt, classHash, constructorCalldata, 0);
|
|
405
|
-
if (!((_c = transactionsDetail.maxFee) !== null && _c !== void 0)) return [3 /*break*/, 5];
|
|
406
|
-
_h = _c;
|
|
407
|
-
return [3 /*break*/, 7];
|
|
408
|
-
case 5: return [4 /*yield*/, this.getSuggestedMaxFee({
|
|
409
|
-
type: 'DEPLOY_ACCOUNT',
|
|
410
|
-
payload: { classHash: classHash, constructorCalldata: constructorCalldata, addressSalt: addressSalt, contractAddress: contractAddress },
|
|
411
|
-
}, transactionsDetail)];
|
|
412
|
-
case 6:
|
|
413
|
-
_h = (_j.sent());
|
|
414
|
-
_j.label = 7;
|
|
415
|
-
case 7:
|
|
416
|
-
maxFee = _h;
|
|
417
|
-
return [4 /*yield*/, this.signer.signDeployAccountTransaction({
|
|
418
|
-
classHash: classHash,
|
|
419
|
-
constructorCalldata: constructorCalldata,
|
|
420
|
-
contractAddress: contractAddress,
|
|
421
|
-
addressSalt: addressSalt,
|
|
422
|
-
chainId: chainId,
|
|
423
|
-
maxFee: maxFee,
|
|
424
|
-
version: version,
|
|
425
|
-
nonce: nonce,
|
|
426
|
-
})];
|
|
427
|
-
case 8:
|
|
428
|
-
signature = _j.sent();
|
|
429
|
-
return [2 /*return*/, this.deployAccountContract({ classHash: classHash, addressSalt: addressSalt, constructorCalldata: constructorCalldata, signature: signature }, {
|
|
430
|
-
nonce: nonce,
|
|
431
|
-
maxFee: maxFee,
|
|
432
|
-
version: version,
|
|
433
|
-
})];
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
};
|
|
438
|
-
Account.prototype.signMessage = function (typedData) {
|
|
439
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
440
|
-
return __generator(this, function (_a) {
|
|
441
|
-
return [2 /*return*/, this.signer.signMessage(typedData, this.address)];
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
};
|
|
445
|
-
Account.prototype.hashMessage = function (typedData) {
|
|
446
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
447
|
-
return __generator(this, function (_a) {
|
|
448
|
-
return [2 /*return*/, (0, typedData_1.getMessageHash)(typedData, this.address)];
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
};
|
|
452
|
-
Account.prototype.verifyMessageHash = function (hash, signature) {
|
|
453
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
454
|
-
var _a;
|
|
455
|
-
return __generator(this, function (_b) {
|
|
456
|
-
switch (_b.label) {
|
|
457
|
-
case 0:
|
|
458
|
-
_b.trys.push([0, 2, , 3]);
|
|
459
|
-
return [4 /*yield*/, this.callContract({
|
|
460
|
-
contractAddress: this.address,
|
|
461
|
-
entrypoint: 'isValidSignature',
|
|
462
|
-
calldata: (0, stark_1.compileCalldata)({
|
|
463
|
-
hash: (0, number_1.toBN)(hash).toString(),
|
|
464
|
-
signature: signature.map(function (x) { return (0, number_1.toBN)(x).toString(); }),
|
|
465
|
-
}),
|
|
466
|
-
})];
|
|
467
|
-
case 1:
|
|
468
|
-
_b.sent();
|
|
469
|
-
return [2 /*return*/, true];
|
|
470
|
-
case 2:
|
|
471
|
-
_a = _b.sent();
|
|
472
|
-
return [2 /*return*/, false];
|
|
473
|
-
case 3: return [2 /*return*/];
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
});
|
|
477
|
-
};
|
|
478
|
-
Account.prototype.verifyMessage = function (typedData, signature) {
|
|
479
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
480
|
-
var hash;
|
|
481
|
-
return __generator(this, function (_a) {
|
|
482
|
-
switch (_a.label) {
|
|
483
|
-
case 0: return [4 /*yield*/, this.hashMessage(typedData)];
|
|
484
|
-
case 1:
|
|
485
|
-
hash = _a.sent();
|
|
486
|
-
return [2 /*return*/, this.verifyMessageHash(hash, signature)];
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
});
|
|
490
|
-
};
|
|
491
|
-
Account.prototype.getSuggestedMaxFee = function (estimateFeeAction, details) {
|
|
492
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
493
|
-
var feeEstimate, _a;
|
|
494
|
-
return __generator(this, function (_b) {
|
|
495
|
-
switch (_b.label) {
|
|
496
|
-
case 0:
|
|
497
|
-
_a = estimateFeeAction.type;
|
|
498
|
-
switch (_a) {
|
|
499
|
-
case 'INVOKE': return [3 /*break*/, 1];
|
|
500
|
-
case 'DECLARE': return [3 /*break*/, 3];
|
|
501
|
-
case 'DEPLOY_ACCOUNT': return [3 /*break*/, 5];
|
|
502
|
-
}
|
|
503
|
-
return [3 /*break*/, 7];
|
|
504
|
-
case 1: return [4 /*yield*/, this.estimateInvokeFee(estimateFeeAction.payload, details)];
|
|
505
|
-
case 2:
|
|
506
|
-
feeEstimate = _b.sent();
|
|
507
|
-
return [3 /*break*/, 8];
|
|
508
|
-
case 3: return [4 /*yield*/, this.estimateDeclareFee(estimateFeeAction.payload, details)];
|
|
509
|
-
case 4:
|
|
510
|
-
feeEstimate = _b.sent();
|
|
511
|
-
return [3 /*break*/, 8];
|
|
512
|
-
case 5: return [4 /*yield*/, this.estimateAccountDeployFee(estimateFeeAction.payload, details)];
|
|
513
|
-
case 6:
|
|
514
|
-
feeEstimate = _b.sent();
|
|
515
|
-
return [3 /*break*/, 8];
|
|
516
|
-
case 7:
|
|
517
|
-
feeEstimate = { suggestedMaxFee: constants_1.ZERO, overall_fee: constants_1.ZERO };
|
|
518
|
-
return [3 /*break*/, 8];
|
|
519
|
-
case 8: return [2 /*return*/, feeEstimate.suggestedMaxFee.toString()];
|
|
520
|
-
}
|
|
521
|
-
});
|
|
522
|
-
});
|
|
523
|
-
};
|
|
524
|
-
return Account;
|
|
525
|
-
}(default_1.Provider));
|
|
526
|
-
exports.Account = Account;
|
package/account/index.d.ts
DELETED
package/account/index.js
DELETED
|
@@ -1,18 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./default"), exports);
|
|
18
|
-
__exportStar(require("./interface"), exports);
|