starknet 3.5.1 → 3.6.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/CHANGELOG.md +18 -0
- package/__tests__/account.test.ts +38 -20
- package/__tests__/accountContract.test.ts +0 -31
- package/__tests__/constancts.ts +2 -0
- package/__tests__/contract.test.ts +14 -21
- package/__tests__/provider.test.ts +8 -0
- package/account/default.d.ts +2 -0
- package/account/default.js +60 -12
- package/account/interface.d.ts +14 -0
- package/contract/default.d.ts +1 -1
- package/contract/default.js +27 -11
- package/dist/account/default.d.ts +2 -1
- package/dist/account/default.js +47 -9
- package/dist/account/interface.d.ts +13 -1
- package/dist/contract/default.d.ts +1 -1
- package/dist/contract/default.js +22 -10
- package/dist/provider/default.d.ts +9 -2
- package/dist/provider/default.js +16 -11
- package/dist/signer/index.d.ts +1 -0
- package/dist/signer/index.js +1 -0
- package/dist/signer/ledger.d.ts +12 -0
- package/dist/signer/ledger.js +138 -0
- package/dist/types/api.d.ts +57 -2
- package/package.json +5 -2
- package/provider/default.d.ts +9 -1
- package/provider/default.js +19 -15
- package/signer/index.d.ts +1 -0
- package/signer/index.js +1 -0
- package/signer/ledger.d.ts +15 -0
- package/signer/ledger.js +243 -0
- package/src/account/default.ts +25 -4
- package/src/account/interface.ts +15 -0
- package/src/contract/default.ts +23 -22
- package/src/provider/default.ts +13 -11
- package/src/signer/index.ts +1 -0
- package/src/signer/ledger.ts +81 -0
- package/src/types/api.ts +62 -3
- package/tsconfig.json +1 -10
- package/types/api.d.ts +57 -2
- package/www/README.md +41 -0
- package/www/babel.config.js +3 -0
- package/www/code-examples/account.js +62 -0
- package/www/code-examples/amm.js +49 -0
- package/www/code-examples/erc20.js +10 -0
- package/www/code-examples/package-lock.json +336 -0
- package/www/code-examples/package.json +15 -0
- package/www/docs/API/_category_.json +5 -0
- package/www/docs/API/account.md +11 -0
- package/www/docs/API/contract.md +14 -0
- package/www/docs/API/index.md +4 -0
- package/www/docs/API/provider.md +10 -0
- package/www/docs/API/signer.md +8 -0
- package/www/docusaurus.config.js +131 -0
- package/www/guides/account.md +60 -0
- package/www/guides/cra.md +3 -0
- package/www/guides/erc20.md +88 -0
- package/www/guides/intro.md +20 -0
- package/www/package-lock.json +22285 -0
- package/www/package.json +43 -0
- package/www/sidebars.js +31 -0
- package/www/src/components/HomepageFeatures/index.tsx +67 -0
- package/www/src/components/HomepageFeatures/styles.module.css +10 -0
- package/www/src/css/custom.css +39 -0
- package/www/src/pages/index.module.css +23 -0
- package/www/src/pages/index.tsx +40 -0
- package/www/src/pages/markdown-page.md +7 -0
- package/www/static/.nojekyll +0 -0
- package/www/static/img/docusaurus.png +0 -0
- package/www/static/img/favicon.ico +0 -0
- package/www/static/img/logo.svg +17 -0
- package/www/static/img/starknet-1.png +0 -0
- package/www/static/img/starknet-2.png +0 -0
- package/www/static/img/starknet-3.png +0 -0
- package/www/static/img/tutorial/docsVersionDropdown.png +0 -0
- package/www/static/img/tutorial/localeDropdown.png +0 -0
- package/www/tsconfig.json +8 -0
package/dist/contract/default.js
CHANGED
|
@@ -79,7 +79,6 @@ exports.Contract = void 0;
|
|
|
79
79
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
80
80
|
var minimalistic_assert_1 = __importDefault(require("minimalistic-assert"));
|
|
81
81
|
var provider_1 = require("../provider");
|
|
82
|
-
var hash_1 = require("../utils/hash");
|
|
83
82
|
var number_1 = require("../utils/number");
|
|
84
83
|
function parseFelt(candidate) {
|
|
85
84
|
try {
|
|
@@ -564,9 +563,9 @@ var Contract = /** @class */ (function () {
|
|
|
564
563
|
}
|
|
565
564
|
return acc;
|
|
566
565
|
}, 0);
|
|
567
|
-
var
|
|
566
|
+
var overrides = {};
|
|
568
567
|
if (args.length === inputsLength + 1 && Array.isArray(args[args.length - 1])) {
|
|
569
|
-
|
|
568
|
+
Object.assign(overrides, args.pop());
|
|
570
569
|
}
|
|
571
570
|
if (args.length !== inputsLength) {
|
|
572
571
|
throw Error("Invalid number of arguments, expected " + inputsLength + " arguments, but got " + args.length);
|
|
@@ -579,9 +578,12 @@ var Contract = /** @class */ (function () {
|
|
|
579
578
|
entrypoint: method,
|
|
580
579
|
};
|
|
581
580
|
if ('execute' in this.providerOrAccount) {
|
|
582
|
-
return this.providerOrAccount.execute(invocation
|
|
581
|
+
return this.providerOrAccount.execute(invocation, undefined, {
|
|
582
|
+
maxFee: overrides.maxFee,
|
|
583
|
+
nonce: overrides.nonce,
|
|
584
|
+
});
|
|
583
585
|
}
|
|
584
|
-
return this.providerOrAccount.invokeFunction(__assign(__assign({}, invocation), { signature: signature }));
|
|
586
|
+
return this.providerOrAccount.invokeFunction(__assign(__assign({}, invocation), { signature: overrides.signature || [] }));
|
|
585
587
|
};
|
|
586
588
|
Contract.prototype.call = function (method, args) {
|
|
587
589
|
if (args === void 0) { args = []; }
|
|
@@ -612,12 +614,22 @@ var Contract = /** @class */ (function () {
|
|
|
612
614
|
});
|
|
613
615
|
});
|
|
614
616
|
};
|
|
615
|
-
Contract.prototype.estimate = function (
|
|
616
|
-
if (
|
|
617
|
+
Contract.prototype.estimate = function (method, args) {
|
|
618
|
+
if (args === void 0) { args = []; }
|
|
617
619
|
return __awaiter(this, void 0, void 0, function () {
|
|
618
|
-
|
|
620
|
+
var invocation;
|
|
621
|
+
var _a;
|
|
622
|
+
return __generator(this, function (_b) {
|
|
619
623
|
// TODO; remove error as soon as estimate fees are supported
|
|
620
|
-
|
|
624
|
+
// ensure contract is connected
|
|
625
|
+
(0, minimalistic_assert_1.default)(this.address !== null, 'contract isnt connected to an address');
|
|
626
|
+
// validate method and args
|
|
627
|
+
this.validateMethodAndArgs('INVOKE', method, args);
|
|
628
|
+
invocation = (_a = this.populateTransaction)[method].apply(_a, __spreadArray([], __read(args), false));
|
|
629
|
+
if ('estimateFee' in this.providerOrAccount) {
|
|
630
|
+
return [2 /*return*/, this.providerOrAccount.estimateFee(invocation)];
|
|
631
|
+
}
|
|
632
|
+
throw Error('Contract must be connected to the account contract to estimate');
|
|
621
633
|
});
|
|
622
634
|
});
|
|
623
635
|
};
|
|
@@ -626,7 +638,7 @@ var Contract = /** @class */ (function () {
|
|
|
626
638
|
var inputs = this.abi.find(function (abi) { return abi.name === method; }).inputs;
|
|
627
639
|
return {
|
|
628
640
|
contractAddress: this.address,
|
|
629
|
-
entrypoint:
|
|
641
|
+
entrypoint: method,
|
|
630
642
|
calldata: this.compileCalldata(args, inputs),
|
|
631
643
|
signature: [],
|
|
632
644
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Abi, AddTransactionResponse, Call, CallContractResponse, DeployContractPayload, Endpoints, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionResponse, GetTransactionStatusResponse, Invocation, TransactionReceipt } from '../types';
|
|
1
|
+
import { Abi, AddTransactionResponse, Call, CallContractResponse, DeployContractPayload, Endpoints, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionResponse, GetTransactionStatusResponse, GetTransactionTraceResponse, Invocation, TransactionReceipt } from '../types';
|
|
2
2
|
import { BigNumberish } from '../utils/number';
|
|
3
3
|
import { ProviderInterface } from './interface';
|
|
4
4
|
import { BlockIdentifier } from './utils';
|
|
@@ -103,6 +103,14 @@ export declare class Provider implements ProviderInterface {
|
|
|
103
103
|
* @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
|
|
104
104
|
*/
|
|
105
105
|
getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
106
|
+
/**
|
|
107
|
+
* Gets the transaction trace from a tx id.
|
|
108
|
+
*
|
|
109
|
+
*
|
|
110
|
+
* @param txHash
|
|
111
|
+
* @returns the transaction trace
|
|
112
|
+
*/
|
|
113
|
+
getTransactionTrace(txHash: BigNumberish): Promise<GetTransactionTraceResponse>;
|
|
106
114
|
/**
|
|
107
115
|
* Deploys a given compiled contract (json) to starknet
|
|
108
116
|
*
|
|
@@ -120,7 +128,6 @@ export declare class Provider implements ProviderInterface {
|
|
|
120
128
|
* @returns response from addTransaction
|
|
121
129
|
*/
|
|
122
130
|
invokeFunction(invocation: Invocation, _abi?: Abi): Promise<AddTransactionResponse>;
|
|
123
|
-
estimateFee(invocation: Invocation): Promise<any>;
|
|
124
131
|
waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
|
|
125
132
|
/**
|
|
126
133
|
* @deprecated use `waitForTransaction` instead
|
package/dist/provider/default.js
CHANGED
|
@@ -345,6 +345,22 @@ var Provider = /** @class */ (function () {
|
|
|
345
345
|
});
|
|
346
346
|
});
|
|
347
347
|
};
|
|
348
|
+
/**
|
|
349
|
+
* Gets the transaction trace from a tx id.
|
|
350
|
+
*
|
|
351
|
+
*
|
|
352
|
+
* @param txHash
|
|
353
|
+
* @returns the transaction trace
|
|
354
|
+
*/
|
|
355
|
+
Provider.prototype.getTransactionTrace = function (txHash) {
|
|
356
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
357
|
+
var txHashHex;
|
|
358
|
+
return __generator(this, function (_a) {
|
|
359
|
+
txHashHex = (0, number_1.toHex)((0, number_1.toBN)(txHash));
|
|
360
|
+
return [2 /*return*/, this.fetchEndpoint('get_transaction_trace', { transactionHash: txHashHex })];
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
};
|
|
348
364
|
/**
|
|
349
365
|
* Deploys a given compiled contract (json) to starknet
|
|
350
366
|
*
|
|
@@ -383,17 +399,6 @@ var Provider = /** @class */ (function () {
|
|
|
383
399
|
signature: (0, number_1.bigNumberishArrayToDecimalStringArray)((_b = invocation.signature) !== null && _b !== void 0 ? _b : []),
|
|
384
400
|
});
|
|
385
401
|
};
|
|
386
|
-
Provider.prototype.estimateFee = function (invocation) {
|
|
387
|
-
var _a, _b;
|
|
388
|
-
return this.fetchEndpoint('estimate_fee', undefined, {
|
|
389
|
-
// TODO: change the TYPE of the call
|
|
390
|
-
type: 'INVOKE_FUNCTION',
|
|
391
|
-
contract_address: invocation.contractAddress,
|
|
392
|
-
entry_point_selector: (0, hash_1.getSelectorFromName)(invocation.entrypoint),
|
|
393
|
-
calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)((_a = invocation.calldata) !== null && _a !== void 0 ? _a : []),
|
|
394
|
-
signature: (0, number_1.bigNumberishArrayToDecimalStringArray)((_b = invocation.signature) !== null && _b !== void 0 ? _b : []),
|
|
395
|
-
});
|
|
396
|
-
};
|
|
397
402
|
Provider.prototype.waitForTransaction = function (txHash, retryInterval) {
|
|
398
403
|
if (retryInterval === void 0) { retryInterval = 8000; }
|
|
399
404
|
return __awaiter(this, void 0, void 0, function () {
|
package/dist/signer/index.d.ts
CHANGED
package/dist/signer/index.js
CHANGED
|
@@ -12,3 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./interface"), exports);
|
|
14
14
|
__exportStar(require("./default"), exports);
|
|
15
|
+
__exportStar(require("./ledger"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Invocation, InvocationsSignerDetails, Signature } from '../types';
|
|
2
|
+
import { TypedData } from '../utils/typedData';
|
|
3
|
+
import { SignerInterface } from './interface';
|
|
4
|
+
export declare class LedgerBlindSigner implements SignerInterface {
|
|
5
|
+
derivationPath: string;
|
|
6
|
+
private transport;
|
|
7
|
+
private getEthApp;
|
|
8
|
+
getPubKey(): Promise<string>;
|
|
9
|
+
signTransaction(transactions: Invocation[], transactionsDetail: InvocationsSignerDetails): Promise<Signature>;
|
|
10
|
+
signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
|
|
11
|
+
protected sign(msgHash: string): Promise<Signature>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.LedgerBlindSigner = void 0;
|
|
43
|
+
var hw_app_eth_1 = __importDefault(require("@ledgerhq/hw-app-eth"));
|
|
44
|
+
var hw_transport_webhid_1 = __importDefault(require("@ledgerhq/hw-transport-webhid"));
|
|
45
|
+
var encode_1 = require("../utils/encode");
|
|
46
|
+
var hash_1 = require("../utils/hash");
|
|
47
|
+
var typedData_1 = require("../utils/typedData");
|
|
48
|
+
function hexZeroPad(hash, length) {
|
|
49
|
+
var value = hash;
|
|
50
|
+
if (value.length > 2 * length + 2) {
|
|
51
|
+
throw new Error('value out of range');
|
|
52
|
+
}
|
|
53
|
+
while (value.length < 2 * length + 2) {
|
|
54
|
+
value = "0x0" + value.substring(2);
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
var LedgerBlindSigner = /** @class */ (function () {
|
|
59
|
+
function LedgerBlindSigner() {
|
|
60
|
+
this.derivationPath = "/2645'/579218131'/1148870696'/0'/0'/0";
|
|
61
|
+
}
|
|
62
|
+
LedgerBlindSigner.prototype.getEthApp = function () {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
return __generator(this, function (_c) {
|
|
66
|
+
switch (_c.label) {
|
|
67
|
+
case 0:
|
|
68
|
+
if (!!this.transport) return [3 /*break*/, 4];
|
|
69
|
+
_c.label = 1;
|
|
70
|
+
case 1:
|
|
71
|
+
_c.trys.push([1, 3, , 4]);
|
|
72
|
+
_a = this;
|
|
73
|
+
return [4 /*yield*/, hw_transport_webhid_1.default.create()];
|
|
74
|
+
case 2:
|
|
75
|
+
_a.transport = _c.sent();
|
|
76
|
+
return [3 /*break*/, 4];
|
|
77
|
+
case 3:
|
|
78
|
+
_b = _c.sent();
|
|
79
|
+
throw new Error('Device connection error');
|
|
80
|
+
case 4: return [2 /*return*/, new hw_app_eth_1.default(this.transport)];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
LedgerBlindSigner.prototype.getPubKey = function () {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var eth, response, starkPub;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0: return [4 /*yield*/, this.getEthApp()];
|
|
91
|
+
case 1:
|
|
92
|
+
eth = _a.sent();
|
|
93
|
+
return [4 /*yield*/, eth.starkGetPublicKey(this.derivationPath)];
|
|
94
|
+
case 2:
|
|
95
|
+
response = _a.sent();
|
|
96
|
+
starkPub = "0x" + response.slice(1, 1 + 32).toString('hex');
|
|
97
|
+
return [2 /*return*/, starkPub];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
LedgerBlindSigner.prototype.signTransaction = function (transactions, transactionsDetail) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
var msgHash;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
msgHash = (0, hash_1.hashMulticall)(transactionsDetail.walletAddress, transactions, transactionsDetail.nonce.toString(), transactionsDetail.maxFee.toString());
|
|
107
|
+
return [2 /*return*/, this.sign(msgHash)];
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
LedgerBlindSigner.prototype.signMessage = function (typedData, accountAddress) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
var msgHash;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
msgHash = (0, typedData_1.getMessageHash)(typedData, accountAddress);
|
|
116
|
+
return [2 /*return*/, this.sign(msgHash)];
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
LedgerBlindSigner.prototype.sign = function (msgHash) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var eth, _a, r, s;
|
|
123
|
+
return __generator(this, function (_b) {
|
|
124
|
+
switch (_b.label) {
|
|
125
|
+
case 0: return [4 /*yield*/, this.getEthApp()];
|
|
126
|
+
case 1:
|
|
127
|
+
eth = _b.sent();
|
|
128
|
+
return [4 /*yield*/, eth.starkUnsafeSign(this.derivationPath, hexZeroPad(msgHash, 32))];
|
|
129
|
+
case 2:
|
|
130
|
+
_a = (_b.sent()), r = _a.r, s = _a.s;
|
|
131
|
+
return [2 /*return*/, [(0, encode_1.addHexPrefix)(r), (0, encode_1.addHexPrefix)(s)]];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
return LedgerBlindSigner;
|
|
137
|
+
}());
|
|
138
|
+
exports.LedgerBlindSigner = LedgerBlindSigner;
|
package/dist/types/api.d.ts
CHANGED
|
@@ -26,6 +26,13 @@ export declare type Endpoints = {
|
|
|
26
26
|
REQUEST: never;
|
|
27
27
|
RESPONSE: GetTransactionStatusResponse;
|
|
28
28
|
};
|
|
29
|
+
get_transaction_trace: {
|
|
30
|
+
QUERY: {
|
|
31
|
+
transactionHash: string;
|
|
32
|
+
};
|
|
33
|
+
REQUEST: never;
|
|
34
|
+
RESPONSE: GetTransactionTraceResponse;
|
|
35
|
+
};
|
|
29
36
|
get_storage_at: {
|
|
30
37
|
QUERY: {
|
|
31
38
|
contractAddress: string;
|
|
@@ -59,7 +66,7 @@ export declare type Endpoints = {
|
|
|
59
66
|
};
|
|
60
67
|
estimate_fee: {
|
|
61
68
|
QUERY: never;
|
|
62
|
-
REQUEST:
|
|
69
|
+
REQUEST: CallContractTransaction;
|
|
63
70
|
RESPONSE: EstimateFeeResponse;
|
|
64
71
|
};
|
|
65
72
|
};
|
|
@@ -82,6 +89,31 @@ export declare type InvokeFunctionTransaction = {
|
|
|
82
89
|
entry_point_selector: string;
|
|
83
90
|
calldata?: RawCalldata;
|
|
84
91
|
nonce?: BigNumberish;
|
|
92
|
+
max_fee?: BigNumberish;
|
|
93
|
+
};
|
|
94
|
+
export declare type InvokeFunctionTrace = {
|
|
95
|
+
caller_address: string;
|
|
96
|
+
contract_address: string;
|
|
97
|
+
code_address: string;
|
|
98
|
+
selector: string;
|
|
99
|
+
calldata: RawCalldata;
|
|
100
|
+
result: Array<any>;
|
|
101
|
+
execution_resources: ExecutionResources;
|
|
102
|
+
internal_call: Array<InvokeFunctionTrace>;
|
|
103
|
+
events: Array<any>;
|
|
104
|
+
messages: Array<any>;
|
|
105
|
+
};
|
|
106
|
+
export declare type ExecutionResources = {
|
|
107
|
+
n_steps: number;
|
|
108
|
+
builtin_instance_counter: {
|
|
109
|
+
pedersen_builtin: number;
|
|
110
|
+
range_check_builtin: number;
|
|
111
|
+
bitwise_builtin: number;
|
|
112
|
+
output_builtin: number;
|
|
113
|
+
ecdsa_builtin: number;
|
|
114
|
+
ec_op_builtin: number;
|
|
115
|
+
};
|
|
116
|
+
n_memory_holes: number;
|
|
85
117
|
};
|
|
86
118
|
export declare type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'>;
|
|
87
119
|
export declare type Transaction = DeployTransaction | InvokeFunctionTransaction;
|
|
@@ -126,6 +158,21 @@ export declare type GetTransactionStatusResponse = {
|
|
|
126
158
|
error_message: string;
|
|
127
159
|
};
|
|
128
160
|
};
|
|
161
|
+
export declare type GetTransactionTraceResponse = {
|
|
162
|
+
function_invocation: {
|
|
163
|
+
caller_address: string;
|
|
164
|
+
contract_address: string;
|
|
165
|
+
code_address: string;
|
|
166
|
+
selector: string;
|
|
167
|
+
calldata: RawArgs;
|
|
168
|
+
result: Array<any>;
|
|
169
|
+
execution_resources: any;
|
|
170
|
+
internal_call: Array<any>;
|
|
171
|
+
events: Array<any>;
|
|
172
|
+
messages: Array<any>;
|
|
173
|
+
};
|
|
174
|
+
signature: Signature;
|
|
175
|
+
};
|
|
129
176
|
export declare type GetTransactionResponse = {
|
|
130
177
|
status: Status;
|
|
131
178
|
transaction: Transaction;
|
|
@@ -148,7 +195,10 @@ export declare type TransactionReceipt = {
|
|
|
148
195
|
l2_to_l1_messages: string[];
|
|
149
196
|
events: string[];
|
|
150
197
|
};
|
|
151
|
-
export declare type EstimateFeeResponse = {
|
|
198
|
+
export declare type EstimateFeeResponse = {
|
|
199
|
+
amount: number;
|
|
200
|
+
unit: string;
|
|
201
|
+
};
|
|
152
202
|
export declare type RawArgs = {
|
|
153
203
|
[inputName: string]: string | string[] | {
|
|
154
204
|
type: 'struct';
|
|
@@ -156,3 +206,8 @@ export declare type RawArgs = {
|
|
|
156
206
|
};
|
|
157
207
|
};
|
|
158
208
|
export declare type Calldata = string[];
|
|
209
|
+
export declare type Overrides = {
|
|
210
|
+
maxFee?: BigNumberish;
|
|
211
|
+
nonce?: BigNumberish;
|
|
212
|
+
signature?: Signature;
|
|
213
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starknet",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "JavaScript library for StarkNet",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"test": "jest",
|
|
12
12
|
"posttest": "npm run format",
|
|
13
13
|
"test:watch": "jest --watch",
|
|
14
|
-
"docs": "
|
|
14
|
+
"docs": "cd www && npm run start",
|
|
15
15
|
"format": "prettier --loglevel warn --write \"**/*.{ts,js,md,yml,json}\"",
|
|
16
16
|
"lint": "eslint . --cache --fix --ext .ts"
|
|
17
17
|
},
|
|
@@ -61,6 +61,9 @@
|
|
|
61
61
|
"typescript": "^4.4.4"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
+
"@ledgerhq/hw-app-eth": "^6.26.0",
|
|
65
|
+
"@ledgerhq/hw-transport": "^6.24.1",
|
|
66
|
+
"@ledgerhq/hw-transport-webhid": "^6.24.1",
|
|
64
67
|
"axios": "^0.23.0",
|
|
65
68
|
"bn.js": "^5.2.0",
|
|
66
69
|
"elliptic": "^6.5.4",
|
package/provider/default.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
GetContractAddressesResponse,
|
|
11
11
|
GetTransactionResponse,
|
|
12
12
|
GetTransactionStatusResponse,
|
|
13
|
+
GetTransactionTraceResponse,
|
|
13
14
|
Invocation,
|
|
14
15
|
TransactionReceipt,
|
|
15
16
|
} from '../types';
|
|
@@ -140,6 +141,14 @@ export declare class Provider implements ProviderInterface {
|
|
|
140
141
|
* @returns the transacton object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
|
|
141
142
|
*/
|
|
142
143
|
getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
144
|
+
/**
|
|
145
|
+
* Gets the transaction trace from a tx id.
|
|
146
|
+
*
|
|
147
|
+
*
|
|
148
|
+
* @param txHash
|
|
149
|
+
* @returns the transaction trace
|
|
150
|
+
*/
|
|
151
|
+
getTransactionTrace(txHash: BigNumberish): Promise<GetTransactionTraceResponse>;
|
|
143
152
|
/**
|
|
144
153
|
* Deploys a given compiled contract (json) to starknet
|
|
145
154
|
*
|
|
@@ -157,7 +166,6 @@ export declare class Provider implements ProviderInterface {
|
|
|
157
166
|
* @returns response from addTransaction
|
|
158
167
|
*/
|
|
159
168
|
invokeFunction(invocation: Invocation, _abi?: Abi): Promise<AddTransactionResponse>;
|
|
160
|
-
estimateFee(invocation: Invocation): Promise<any>;
|
|
161
169
|
waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
|
|
162
170
|
/**
|
|
163
171
|
* @deprecated use `waitForTransaction` instead
|
package/provider/default.js
CHANGED
|
@@ -516,6 +516,25 @@ var Provider = /** @class */ (function () {
|
|
|
516
516
|
});
|
|
517
517
|
});
|
|
518
518
|
};
|
|
519
|
+
/**
|
|
520
|
+
* Gets the transaction trace from a tx id.
|
|
521
|
+
*
|
|
522
|
+
*
|
|
523
|
+
* @param txHash
|
|
524
|
+
* @returns the transaction trace
|
|
525
|
+
*/
|
|
526
|
+
Provider.prototype.getTransactionTrace = function (txHash) {
|
|
527
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
528
|
+
var txHashHex;
|
|
529
|
+
return __generator(this, function (_a) {
|
|
530
|
+
txHashHex = (0, number_1.toHex)((0, number_1.toBN)(txHash));
|
|
531
|
+
return [
|
|
532
|
+
2 /*return*/,
|
|
533
|
+
this.fetchEndpoint('get_transaction_trace', { transactionHash: txHashHex }),
|
|
534
|
+
];
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
};
|
|
519
538
|
/**
|
|
520
539
|
* Deploys a given compiled contract (json) to starknet
|
|
521
540
|
*
|
|
@@ -562,21 +581,6 @@ var Provider = /** @class */ (function () {
|
|
|
562
581
|
),
|
|
563
582
|
});
|
|
564
583
|
};
|
|
565
|
-
Provider.prototype.estimateFee = function (invocation) {
|
|
566
|
-
var _a, _b;
|
|
567
|
-
return this.fetchEndpoint('estimate_fee', undefined, {
|
|
568
|
-
// TODO: change the TYPE of the call
|
|
569
|
-
type: 'INVOKE_FUNCTION',
|
|
570
|
-
contract_address: invocation.contractAddress,
|
|
571
|
-
entry_point_selector: (0, hash_1.getSelectorFromName)(invocation.entrypoint),
|
|
572
|
-
calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)(
|
|
573
|
-
(_a = invocation.calldata) !== null && _a !== void 0 ? _a : []
|
|
574
|
-
),
|
|
575
|
-
signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(
|
|
576
|
-
(_b = invocation.signature) !== null && _b !== void 0 ? _b : []
|
|
577
|
-
),
|
|
578
|
-
});
|
|
579
|
-
};
|
|
580
584
|
Provider.prototype.waitForTransaction = function (txHash, retryInterval) {
|
|
581
585
|
if (retryInterval === void 0) {
|
|
582
586
|
retryInterval = 8000;
|
package/signer/index.d.ts
CHANGED
package/signer/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Invocation, InvocationsSignerDetails, Signature } from '../types';
|
|
2
|
+
import { TypedData } from '../utils/typedData';
|
|
3
|
+
import { SignerInterface } from './interface';
|
|
4
|
+
export declare class LedgerBlindSigner implements SignerInterface {
|
|
5
|
+
derivationPath: string;
|
|
6
|
+
private transport;
|
|
7
|
+
private getEthApp;
|
|
8
|
+
getPubKey(): Promise<string>;
|
|
9
|
+
signTransaction(
|
|
10
|
+
transactions: Invocation[],
|
|
11
|
+
transactionsDetail: InvocationsSignerDetails
|
|
12
|
+
): Promise<Signature>;
|
|
13
|
+
signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
|
|
14
|
+
protected sign(msgHash: string): Promise<Signature>;
|
|
15
|
+
}
|