starknet 6.9.0 → 6.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/LICENSE +1 -1
- package/README.md +5 -9
- package/dist/account/default.cjs +655 -0
- package/dist/account/default.d.ts +67 -0
- package/dist/account/default.mjs +652 -0
- package/dist/account/index.cjs +27 -0
- package/dist/account/index.d.ts +2 -0
- package/dist/account/index.mjs +2 -0
- package/dist/account/interface.cjs +9 -0
- package/dist/account/interface.d.ts +301 -0
- package/dist/account/interface.mjs +3 -0
- package/dist/channel/index.cjs +27 -0
- package/dist/channel/index.d.ts +3 -0
- package/dist/channel/index.mjs +3 -0
- package/dist/channel/rpc_0_6.cjs +607 -0
- package/dist/channel/rpc_0_6.d.ts +78 -0
- package/dist/channel/rpc_0_6.mjs +543 -0
- package/dist/channel/rpc_0_7.cjs +619 -0
- package/dist/channel/rpc_0_7.d.ts +81 -0
- package/dist/channel/rpc_0_7.mjs +561 -0
- package/dist/constants.cjs +76 -0
- package/dist/constants.d.ts +70 -0
- package/dist/constants.mjs +60 -0
- package/dist/contract/contractFactory.cjs +93 -0
- package/dist/contract/contractFactory.d.ts +46 -0
- package/dist/contract/contractFactory.mjs +83 -0
- package/dist/contract/default.cjs +269 -0
- package/dist/contract/default.d.ts +58 -0
- package/dist/contract/default.mjs +254 -0
- package/dist/contract/index.cjs +38 -0
- package/dist/contract/index.d.ts +3 -0
- package/dist/contract/index.mjs +3 -0
- package/dist/contract/interface.cjs +13 -0
- package/dist/contract/interface.d.ts +128 -0
- package/dist/contract/interface.mjs +6 -0
- package/dist/index.cjs +267 -0
- package/dist/index.d.ts +45 -5991
- package/dist/index.global.js +728 -609
- package/dist/index.global.js.map +1 -1
- package/dist/index.mjs +39 -7320
- package/dist/provider/errors.cjs +50 -0
- package/dist/provider/errors.d.ts +16 -0
- package/dist/provider/errors.mjs +35 -0
- package/dist/provider/extensions/default.cjs +11 -0
- package/dist/provider/extensions/default.d.ts +6 -0
- package/dist/provider/extensions/default.mjs +5 -0
- package/dist/provider/extensions/starknetId.cjs +174 -0
- package/dist/provider/extensions/starknetId.d.ts +10 -0
- package/dist/provider/extensions/starknetId.mjs +230 -0
- package/dist/provider/index.cjs +56 -0
- package/dist/provider/index.d.ts +6 -0
- package/dist/provider/index.mjs +6 -0
- package/dist/provider/interface.cjs +8 -0
- package/dist/provider/interface.d.ts +261 -0
- package/dist/provider/interface.mjs +2 -0
- package/dist/provider/rpc.cjs +301 -0
- package/dist/provider/rpc.d.ts +115 -0
- package/dist/provider/rpc.mjs +302 -0
- package/dist/service/types.cjs +1 -0
- package/dist/service/types.d.ts +5 -0
- package/dist/service/types.mjs +0 -0
- package/dist/signer/default.cjs +105 -0
- package/dist/signer/default.d.ts +12 -0
- package/dist/signer/default.mjs +102 -0
- package/dist/signer/ethSigner.cjs +123 -0
- package/dist/signer/ethSigner.d.ts +25 -0
- package/dist/signer/ethSigner.mjs +140 -0
- package/dist/signer/index.cjs +38 -0
- package/dist/signer/index.d.ts +3 -0
- package/dist/signer/index.mjs +3 -0
- package/dist/signer/interface.cjs +8 -0
- package/dist/signer/interface.d.ts +115 -0
- package/dist/signer/interface.mjs +2 -0
- package/dist/types/account.cjs +1 -0
- package/dist/types/account.d.ts +79 -0
- package/dist/types/account.mjs +0 -0
- package/dist/types/api/index.cjs +30 -0
- package/dist/types/api/index.d.ts +4 -0
- package/dist/types/api/index.mjs +4 -0
- package/dist/types/api/jsonrpc/index.cjs +1 -0
- package/dist/types/api/jsonrpc/index.d.ts +21 -0
- package/dist/types/api/jsonrpc/index.mjs +0 -0
- package/dist/types/api/rpcspec_0_6/components.cjs +1 -0
- package/dist/types/api/rpcspec_0_6/components.d.ts +541 -0
- package/dist/types/api/rpcspec_0_6/components.mjs +0 -0
- package/dist/types/api/rpcspec_0_6/contract.cjs +1 -0
- package/dist/types/api/rpcspec_0_6/contract.d.ts +85 -0
- package/dist/types/api/rpcspec_0_6/contract.mjs +0 -0
- package/dist/types/api/rpcspec_0_6/errors.cjs +1 -0
- package/dist/types/api/rpcspec_0_6/errors.d.ts +128 -0
- package/dist/types/api/rpcspec_0_6/errors.mjs +0 -0
- package/dist/types/api/rpcspec_0_6/index.cjs +45 -0
- package/dist/types/api/rpcspec_0_6/index.d.ts +8 -0
- package/dist/types/api/rpcspec_0_6/index.mjs +5 -0
- package/dist/types/api/rpcspec_0_6/methods.cjs +1 -0
- package/dist/types/api/rpcspec_0_6/methods.d.ts +207 -0
- package/dist/types/api/rpcspec_0_6/methods.mjs +0 -0
- package/dist/types/api/rpcspec_0_6/nonspec.cjs +65 -0
- package/dist/types/api/rpcspec_0_6/nonspec.d.ts +147 -0
- package/dist/types/api/rpcspec_0_6/nonspec.mjs +59 -0
- package/dist/types/cairoEnum.cjs +1 -0
- package/dist/types/cairoEnum.d.ts +2 -0
- package/dist/types/cairoEnum.mjs +0 -0
- package/dist/types/calldata.cjs +27 -0
- package/dist/types/calldata.d.ts +23 -0
- package/dist/types/calldata.mjs +21 -0
- package/dist/types/contract.cjs +1 -0
- package/dist/types/contract.d.ts +27 -0
- package/dist/types/contract.mjs +0 -0
- package/dist/types/helpers/valuesType.cjs +1 -0
- package/dist/types/helpers/valuesType.d.ts +1 -0
- package/dist/types/helpers/valuesType.mjs +0 -0
- package/dist/types/index.cjs +121 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.mjs +10 -0
- package/dist/types/lib/contract/abi.cjs +1 -0
- package/dist/types/lib/contract/abi.d.ts +71 -0
- package/dist/types/lib/contract/abi.mjs +0 -0
- package/dist/types/lib/contract/index.cjs +50 -0
- package/dist/types/lib/contract/index.d.ts +26 -0
- package/dist/types/lib/contract/index.mjs +8 -0
- package/dist/types/lib/contract/legacy.cjs +1 -0
- package/dist/types/lib/contract/legacy.d.ts +33 -0
- package/dist/types/lib/contract/legacy.mjs +0 -0
- package/dist/types/lib/contract/sierra.cjs +1 -0
- package/dist/types/lib/contract/sierra.d.ts +52 -0
- package/dist/types/lib/contract/sierra.mjs +0 -0
- package/dist/types/lib/index.cjs +61 -0
- package/dist/types/lib/index.d.ts +259 -0
- package/dist/types/lib/index.mjs +36 -0
- package/dist/types/provider/configuration.cjs +1 -0
- package/dist/types/provider/configuration.d.ts +20 -0
- package/dist/types/provider/configuration.mjs +0 -0
- package/dist/types/provider/index.cjs +27 -0
- package/dist/types/provider/index.d.ts +2 -0
- package/dist/types/provider/index.mjs +2 -0
- package/dist/types/provider/response.cjs +30 -0
- package/dist/types/provider/response.d.ts +98 -0
- package/dist/types/provider/response.mjs +1 -0
- package/dist/types/provider/spec.cjs +1 -0
- package/dist/types/provider/spec.d.ts +49 -0
- package/dist/types/provider/spec.mjs +0 -0
- package/dist/types/signer.cjs +1 -0
- package/dist/types/signer.d.ts +49 -0
- package/dist/types/signer.mjs +0 -0
- package/dist/types/transactionReceipt.cjs +1 -0
- package/dist/types/transactionReceipt.d.ts +23 -0
- package/dist/types/transactionReceipt.mjs +0 -0
- package/dist/types/typedData.cjs +12 -0
- package/dist/types/typedData.d.ts +1 -0
- package/dist/types/typedData.mjs +3 -0
- package/dist/utils/address.cjs +44 -0
- package/dist/utils/address.d.ts +55 -0
- package/dist/utils/address.mjs +35 -0
- package/dist/utils/assert.cjs +11 -0
- package/dist/utils/assert.d.ts +12 -0
- package/dist/utils/assert.mjs +5 -0
- package/dist/utils/cairoDataTypes/felt.cjs +31 -0
- package/dist/utils/cairoDataTypes/felt.d.ts +6 -0
- package/dist/utils/cairoDataTypes/felt.mjs +27 -0
- package/dist/utils/cairoDataTypes/uint256.cjs +113 -0
- package/dist/utils/cairoDataTypes/uint256.d.ts +72 -0
- package/dist/utils/cairoDataTypes/uint256.mjs +103 -0
- package/dist/utils/cairoDataTypes/uint512.cjs +125 -0
- package/dist/utils/cairoDataTypes/uint512.d.ts +76 -0
- package/dist/utils/cairoDataTypes/uint512.mjs +123 -0
- package/dist/utils/calldata/byteArray.cjs +27 -0
- package/dist/utils/calldata/byteArray.d.ts +32 -0
- package/dist/utils/calldata/byteArray.mjs +20 -0
- package/dist/utils/calldata/cairo.cjs +114 -0
- package/dist/utils/calldata/cairo.d.ts +196 -0
- package/dist/utils/calldata/cairo.mjs +68 -0
- package/dist/utils/calldata/enum/CairoCustomEnum.cjs +55 -0
- package/dist/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
- package/dist/utils/calldata/enum/CairoCustomEnum.mjs +50 -0
- package/dist/utils/calldata/enum/CairoOption.cjs +55 -0
- package/dist/utils/calldata/enum/CairoOption.d.ts +37 -0
- package/dist/utils/calldata/enum/CairoOption.mjs +50 -0
- package/dist/utils/calldata/enum/CairoResult.cjs +54 -0
- package/dist/utils/calldata/enum/CairoResult.d.ts +36 -0
- package/dist/utils/calldata/enum/CairoResult.mjs +47 -0
- package/dist/utils/calldata/enum/index.cjs +38 -0
- package/dist/utils/calldata/enum/index.d.ts +3 -0
- package/dist/utils/calldata/enum/index.mjs +3 -0
- package/dist/utils/calldata/formatter.cjs +55 -0
- package/dist/utils/calldata/formatter.d.ts +9 -0
- package/dist/utils/calldata/formatter.mjs +58 -0
- package/dist/utils/calldata/index.cjs +272 -0
- package/dist/utils/calldata/index.d.ts +90 -0
- package/dist/utils/calldata/index.mjs +276 -0
- package/dist/utils/calldata/parser/index.cjs +29 -0
- package/dist/utils/calldata/parser/index.d.ts +5 -0
- package/dist/utils/calldata/parser/index.mjs +21 -0
- package/dist/utils/calldata/parser/interface.cjs +8 -0
- package/dist/utils/calldata/parser/interface.d.ts +20 -0
- package/dist/utils/calldata/parser/interface.mjs +2 -0
- package/dist/utils/calldata/parser/parser-0-1.1.0.cjs +38 -0
- package/dist/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
- package/dist/utils/calldata/parser/parser-0-1.1.0.mjs +31 -0
- package/dist/utils/calldata/parser/parser-2.0.0.cjs +42 -0
- package/dist/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
- package/dist/utils/calldata/parser/parser-2.0.0.mjs +37 -0
- package/dist/utils/calldata/propertyOrder.cjs +159 -0
- package/dist/utils/calldata/propertyOrder.d.ts +2 -0
- package/dist/utils/calldata/propertyOrder.mjs +189 -0
- package/dist/utils/calldata/requestParser.cjs +204 -0
- package/dist/utils/calldata/requestParser.d.ts +11 -0
- package/dist/utils/calldata/requestParser.mjs +231 -0
- package/dist/utils/calldata/responseParser.cjs +200 -0
- package/dist/utils/calldata/responseParser.d.ts +11 -0
- package/dist/utils/calldata/responseParser.mjs +201 -0
- package/dist/utils/calldata/tuple.cjs +106 -0
- package/dist/utils/calldata/tuple.d.ts +6 -0
- package/dist/utils/calldata/tuple.mjs +88 -0
- package/dist/utils/calldata/validate.cjs +241 -0
- package/dist/utils/calldata/validate.d.ts +6 -0
- package/dist/utils/calldata/validate.mjs +315 -0
- package/dist/utils/contract.cjs +40 -0
- package/dist/utils/contract.d.ts +37 -0
- package/dist/utils/contract.mjs +31 -0
- package/dist/utils/ec.cjs +12 -0
- package/dist/utils/ec.d.ts +2 -0
- package/dist/utils/ec.mjs +2 -0
- package/dist/utils/encode.cjs +78 -0
- package/dist/utils/encode.d.ts +207 -0
- package/dist/utils/encode.mjs +56 -0
- package/dist/utils/eth.cjs +22 -0
- package/dist/utils/eth.d.ts +22 -0
- package/dist/utils/eth.mjs +14 -0
- package/dist/utils/events/index.cjs +144 -0
- package/dist/utils/events/index.d.ts +84 -0
- package/dist/utils/events/index.mjs +136 -0
- package/dist/utils/fetchPonyfill.cjs +14 -0
- package/dist/utils/fetchPonyfill.d.ts +2 -0
- package/dist/utils/fetchPonyfill.mjs +5 -0
- package/dist/utils/hash/classHash.cjs +151 -0
- package/dist/utils/hash/classHash.d.ts +120 -0
- package/dist/utils/hash/classHash.mjs +168 -0
- package/dist/utils/hash/index.cjs +49 -0
- package/dist/utils/hash/index.d.ts +7 -0
- package/dist/utils/hash/index.mjs +4 -0
- package/dist/utils/hash/selector.cjs +37 -0
- package/dist/utils/hash/selector.d.ts +57 -0
- package/dist/utils/hash/selector.mjs +28 -0
- package/dist/utils/hash/transactionHash/index.cjs +38 -0
- package/dist/utils/hash/transactionHash/index.d.ts +81 -0
- package/dist/utils/hash/transactionHash/index.mjs +102 -0
- package/dist/utils/hash/transactionHash/v2.cjs +31 -0
- package/dist/utils/hash/transactionHash/v2.d.ts +34 -0
- package/dist/utils/hash/transactionHash/v2.mjs +57 -0
- package/dist/utils/hash/transactionHash/v3.cjs +45 -0
- package/dist/utils/hash/transactionHash/v3.d.ts +24 -0
- package/dist/utils/hash/transactionHash/v3.mjs +80 -0
- package/dist/utils/json.cjs +21 -0
- package/dist/utils/json.d.ts +50 -0
- package/dist/utils/json.mjs +10 -0
- package/dist/utils/merkle.cjs +118 -0
- package/dist/utils/merkle.d.ts +87 -0
- package/dist/utils/merkle.mjs +114 -0
- package/dist/utils/num.cjs +109 -0
- package/dist/utils/num.d.ts +283 -0
- package/dist/utils/num.mjs +86 -0
- package/dist/utils/provider.cjs +182 -0
- package/dist/utils/provider.d.ts +217 -0
- package/dist/utils/provider.mjs +158 -0
- package/dist/utils/responseParser/index.cjs +27 -0
- package/dist/utils/responseParser/index.d.ts +2 -0
- package/dist/utils/responseParser/index.mjs +2 -0
- package/dist/utils/responseParser/interface.cjs +8 -0
- package/dist/utils/responseParser/interface.d.ts +13 -0
- package/dist/utils/responseParser/interface.mjs +2 -0
- package/dist/utils/responseParser/rpc.cjs +83 -0
- package/dist/utils/responseParser/rpc.d.ts +19 -0
- package/dist/utils/responseParser/rpc.mjs +77 -0
- package/dist/utils/shortString.cjs +56 -0
- package/dist/utils/shortString.d.ts +116 -0
- package/dist/utils/shortString.mjs +39 -0
- package/dist/utils/stark.cjs +137 -0
- package/dist/utils/stark.d.ts +224 -0
- package/dist/utils/stark.mjs +109 -0
- package/dist/utils/starknetId.cjs +196 -0
- package/dist/utils/starknetId.d.ts +182 -0
- package/dist/utils/starknetId.mjs +185 -0
- package/dist/utils/transaction.cjs +115 -0
- package/dist/utils/transaction.d.ts +185 -0
- package/dist/utils/transaction.mjs +98 -0
- package/dist/utils/transactionReceipt.cjs +54 -0
- package/dist/utils/transactionReceipt.d.ts +33 -0
- package/dist/utils/transactionReceipt.mjs +49 -0
- package/dist/utils/typedData.cjs +285 -0
- package/dist/utils/typedData.d.ts +54 -0
- package/dist/utils/typedData.mjs +286 -0
- package/dist/utils/uint256.cjs +30 -0
- package/dist/utils/uint256.d.ts +45 -0
- package/dist/utils/uint256.mjs +11 -0
- package/dist/utils/url.cjs +35 -0
- package/dist/utils/url.d.ts +29 -0
- package/dist/utils/url.mjs +27 -0
- package/dist/wallet/account.cjs +115 -0
- package/dist/wallet/account.d.ts +31 -0
- package/dist/wallet/account.mjs +112 -0
- package/dist/wallet/connect.cjs +90 -0
- package/dist/wallet/connect.d.ts +82 -0
- package/dist/wallet/connect.mjs +64 -0
- package/dist/wallet/index.cjs +16 -0
- package/dist/wallet/index.d.ts +1 -0
- package/dist/wallet/index.mjs +1 -0
- package/dist/wallet/types.cjs +1 -0
- package/dist/wallet/types.d.ts +4 -0
- package/dist/wallet/types.mjs +0 -0
- package/package.json +13 -13
- package/dist/index.js +0 -7426
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2
|
+
import { ETransactionVersion2, ETransactionVersion3 } from "../types/api/index.mjs";
|
|
3
|
+
import { CallData } from "../utils/calldata/index.mjs";
|
|
4
|
+
import { addHexPrefix, buf2hex, removeHexPrefix, sanitizeHex } from "../utils/encode.mjs";
|
|
5
|
+
import { ethRandomPrivateKey } from "../utils/eth.mjs";
|
|
6
|
+
import {
|
|
7
|
+
calculateDeclareTransactionHash,
|
|
8
|
+
calculateDeployAccountTransactionHash,
|
|
9
|
+
calculateInvokeTransactionHash
|
|
10
|
+
} from "../utils/hash/index.mjs";
|
|
11
|
+
import { toHex } from "../utils/num.mjs";
|
|
12
|
+
import { intDAM } from "../utils/stark.mjs";
|
|
13
|
+
import { getExecuteCalldata } from "../utils/transaction.mjs";
|
|
14
|
+
import { getMessageHash } from "../utils/typedData.mjs";
|
|
15
|
+
import { bnToUint256 } from "../utils/uint256.mjs";
|
|
16
|
+
export class EthSigner {
|
|
17
|
+
pk;
|
|
18
|
+
// hex string without 0x and with an odd number of characters
|
|
19
|
+
constructor(pk = ethRandomPrivateKey()) {
|
|
20
|
+
this.pk = pk instanceof Uint8Array ? buf2hex(pk).padStart(64, "0") : removeHexPrefix(toHex(pk)).padStart(64, "0");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* provides the Ethereum full public key (without parity prefix)
|
|
24
|
+
* @returns an hex string : 64 first characters are Point X coordinate. 64 last characters are Point Y coordinate.
|
|
25
|
+
*/
|
|
26
|
+
async getPubKey() {
|
|
27
|
+
return addHexPrefix(
|
|
28
|
+
buf2hex(secp256k1.getPublicKey(this.pk, false)).padStart(130, "0").slice(2)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
async signMessage(typedData, accountAddress) {
|
|
32
|
+
const msgHash = getMessageHash(typedData, accountAddress);
|
|
33
|
+
const signature = secp256k1.sign(
|
|
34
|
+
removeHexPrefix(sanitizeHex(msgHash)),
|
|
35
|
+
this.pk
|
|
36
|
+
);
|
|
37
|
+
return this.formatEthSignature(signature);
|
|
38
|
+
}
|
|
39
|
+
async signTransaction(transactions, details) {
|
|
40
|
+
const compiledCalldata = getExecuteCalldata(transactions, details.cairoVersion);
|
|
41
|
+
let msgHash;
|
|
42
|
+
if (Object.values(ETransactionVersion2).includes(details.version)) {
|
|
43
|
+
const det = details;
|
|
44
|
+
msgHash = calculateInvokeTransactionHash({
|
|
45
|
+
...det,
|
|
46
|
+
senderAddress: det.walletAddress,
|
|
47
|
+
compiledCalldata,
|
|
48
|
+
version: det.version
|
|
49
|
+
});
|
|
50
|
+
} else if (Object.values(ETransactionVersion3).includes(details.version)) {
|
|
51
|
+
const det = details;
|
|
52
|
+
msgHash = calculateInvokeTransactionHash({
|
|
53
|
+
...det,
|
|
54
|
+
senderAddress: det.walletAddress,
|
|
55
|
+
compiledCalldata,
|
|
56
|
+
version: det.version,
|
|
57
|
+
nonceDataAvailabilityMode: intDAM(det.nonceDataAvailabilityMode),
|
|
58
|
+
feeDataAvailabilityMode: intDAM(det.feeDataAvailabilityMode)
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
throw Error("unsupported signTransaction version");
|
|
62
|
+
}
|
|
63
|
+
const signature = secp256k1.sign(
|
|
64
|
+
removeHexPrefix(sanitizeHex(msgHash)),
|
|
65
|
+
this.pk
|
|
66
|
+
);
|
|
67
|
+
return this.formatEthSignature(signature);
|
|
68
|
+
}
|
|
69
|
+
async signDeployAccountTransaction(details) {
|
|
70
|
+
const compiledConstructorCalldata = CallData.compile(details.constructorCalldata);
|
|
71
|
+
let msgHash;
|
|
72
|
+
if (Object.values(ETransactionVersion2).includes(details.version)) {
|
|
73
|
+
const det = details;
|
|
74
|
+
msgHash = calculateDeployAccountTransactionHash({
|
|
75
|
+
...det,
|
|
76
|
+
salt: det.addressSalt,
|
|
77
|
+
constructorCalldata: compiledConstructorCalldata,
|
|
78
|
+
version: det.version
|
|
79
|
+
});
|
|
80
|
+
} else if (Object.values(ETransactionVersion3).includes(details.version)) {
|
|
81
|
+
const det = details;
|
|
82
|
+
msgHash = calculateDeployAccountTransactionHash({
|
|
83
|
+
...det,
|
|
84
|
+
salt: det.addressSalt,
|
|
85
|
+
compiledConstructorCalldata,
|
|
86
|
+
version: det.version,
|
|
87
|
+
nonceDataAvailabilityMode: intDAM(det.nonceDataAvailabilityMode),
|
|
88
|
+
feeDataAvailabilityMode: intDAM(det.feeDataAvailabilityMode)
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
throw Error("unsupported signDeployAccountTransaction version");
|
|
92
|
+
}
|
|
93
|
+
const signature = secp256k1.sign(
|
|
94
|
+
removeHexPrefix(sanitizeHex(msgHash)),
|
|
95
|
+
this.pk
|
|
96
|
+
);
|
|
97
|
+
return this.formatEthSignature(signature);
|
|
98
|
+
}
|
|
99
|
+
async signDeclareTransaction(details) {
|
|
100
|
+
let msgHash;
|
|
101
|
+
if (Object.values(ETransactionVersion2).includes(details.version)) {
|
|
102
|
+
const det = details;
|
|
103
|
+
msgHash = calculateDeclareTransactionHash({
|
|
104
|
+
...det,
|
|
105
|
+
version: det.version
|
|
106
|
+
});
|
|
107
|
+
} else if (Object.values(ETransactionVersion3).includes(details.version)) {
|
|
108
|
+
const det = details;
|
|
109
|
+
msgHash = calculateDeclareTransactionHash({
|
|
110
|
+
...det,
|
|
111
|
+
version: det.version,
|
|
112
|
+
nonceDataAvailabilityMode: intDAM(det.nonceDataAvailabilityMode),
|
|
113
|
+
feeDataAvailabilityMode: intDAM(det.feeDataAvailabilityMode)
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
throw Error("unsupported signDeclareTransaction version");
|
|
117
|
+
}
|
|
118
|
+
const signature = secp256k1.sign(
|
|
119
|
+
removeHexPrefix(sanitizeHex(msgHash)),
|
|
120
|
+
this.pk
|
|
121
|
+
);
|
|
122
|
+
return this.formatEthSignature(signature);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Serialize the signature in conformity with starknet::eth_signature::Signature
|
|
126
|
+
* @param ethSignature secp256k1 signature from Noble curves library
|
|
127
|
+
* @return an array of felts, representing a Cairo Eth Signature.
|
|
128
|
+
*/
|
|
129
|
+
formatEthSignature(ethSignature) {
|
|
130
|
+
const r = bnToUint256(ethSignature.r);
|
|
131
|
+
const s = bnToUint256(ethSignature.s);
|
|
132
|
+
return [
|
|
133
|
+
toHex(r.low),
|
|
134
|
+
toHex(r.high),
|
|
135
|
+
toHex(s.low),
|
|
136
|
+
toHex(s.high),
|
|
137
|
+
toHex(ethSignature.recovery)
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _interface = require("./interface.cjs");
|
|
7
|
+
Object.keys(_interface).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _interface[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _interface[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _default = require("./default.cjs");
|
|
18
|
+
Object.keys(_default).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _default[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _default[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _ethSigner = require("./ethSigner.cjs");
|
|
29
|
+
Object.keys(_ethSigner).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _ethSigner[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _ethSigner[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Call, DeclareSignerDetails, DeployAccountSignerDetails, InvocationsSignerDetails, Signature, TypedData } from '../types';
|
|
2
|
+
export declare abstract class SignerInterface {
|
|
3
|
+
/**
|
|
4
|
+
* Method to get the public key of the signer
|
|
5
|
+
*
|
|
6
|
+
* @returns {string} hex-string
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const mySigner = new Signer("0x123");
|
|
10
|
+
* const result = await mySigner.getPubKey();
|
|
11
|
+
* // result = "0x566d69d8c99f62bc71118399bab25c1f03719463eab8d6a444cd11ece131616"
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
abstract getPubKey(): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Signs a JSON object for off-chain usage with the private key and returns the signature.
|
|
17
|
+
* This adds a message prefix so it can't be interchanged with transactions
|
|
18
|
+
*
|
|
19
|
+
* @param {TypedData} typedData JSON object to be signed
|
|
20
|
+
* @param {string} accountAddress Hex string of the account's address
|
|
21
|
+
* @returns {Promise<Signature>} the signature of the message
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const mySigner = new Signer("0x123");
|
|
25
|
+
* const myTypedData: TypedData = {
|
|
26
|
+
* domain: {name: "Example DApp",
|
|
27
|
+
* chainId: constants.StarknetChainId.SN_SEPOLIA,
|
|
28
|
+
* version: "0.0.3"},
|
|
29
|
+
* types: {StarkNetDomain: [
|
|
30
|
+
* { name: "name", type: "string" },
|
|
31
|
+
* { name: "chainId", type: "felt" },
|
|
32
|
+
* { name: "version", type: "string" }],
|
|
33
|
+
* Message: [{ name: "message", type: "felt" }]},
|
|
34
|
+
* primaryType: "Message", message: {message: "1234"}};
|
|
35
|
+
* const result = await mySigner.signMessage(myTypedData,"0x5d08a4e9188429da4e993c9bf25aafe5cd491ee2b501505d4d059f0c938f82d");
|
|
36
|
+
* // result = Signature {r: 684915484701699003335398790608214855489903651271362390249153620883122231253n,
|
|
37
|
+
* // s: 1399150959912500412309102776989465580949387575375484933432871778355496929189n, recovery: 1}
|
|
38
|
+
* ```
|
|
39
|
+
|
|
40
|
+
*/
|
|
41
|
+
abstract signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
|
|
42
|
+
/**
|
|
43
|
+
* Signs transactions with the private key and returns the signature
|
|
44
|
+
*
|
|
45
|
+
* @param {Call[]} transactions array of Call objects
|
|
46
|
+
* @param {InvocationsSignerDetails} transactionsDetail InvocationsSignerDetails object
|
|
47
|
+
* @returns {Promise<Signature>} the signature of the transaction
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const mySigner = new Signer("0x123");
|
|
51
|
+
* const calls: Call[] = [{
|
|
52
|
+
* contractAddress: "0x1234567890123456789012345678901234567890",
|
|
53
|
+
* entrypoint: "functionName",
|
|
54
|
+
* calldata: [1, 2, 3]
|
|
55
|
+
* }];
|
|
56
|
+
* const transactionsDetail: InvocationsSignerDetails = {
|
|
57
|
+
* walletAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
|
|
58
|
+
* chainId: constants.StarknetChainId.SN_MAIN,
|
|
59
|
+
* cairoVersion: "1",
|
|
60
|
+
* maxFee: '0x1234567890abcdef',
|
|
61
|
+
* version: "0x0", nonce: 1};
|
|
62
|
+
* const result = await mySigner.signTransaction(calls, transactionsDetail);
|
|
63
|
+
* // result = Signature {r: 304910226421970384958146916800275294114105560641204815169249090836676768876n,
|
|
64
|
+
* // s: 1072798866000813654190523783606274062837012608648308896325315895472901074693n, recovery: 0}
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
abstract signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails): Promise<Signature>;
|
|
68
|
+
/**
|
|
69
|
+
* Signs a DEPLOY_ACCOUNT transaction with the private key and returns the signature
|
|
70
|
+
*
|
|
71
|
+
* @param {DeployAccountSignerDetails} transaction to deploy an account contract
|
|
72
|
+
* @returns {Promise<Signature>} the signature of the transaction to deploy an account
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const mySigner = new Signer("0x123");
|
|
76
|
+
* const myDeployAcc: DeployAccountSignerDetails = {
|
|
77
|
+
* contractAddress: "0x65a822fbee1ae79e898688b5a4282dc79e0042cbed12f6169937fddb4c26641",
|
|
78
|
+
* version: "0x2", chainId: constants.StarknetChainId.SN_SEPOLIA,
|
|
79
|
+
* classHash: "0x5f3614e8671257aff9ac38e929c74d65b02d460ae966cd826c9f04a7fa8e0d4",
|
|
80
|
+
* constructorCalldata: [1, 2],addressSalt: 1234,
|
|
81
|
+
* nonce: 45, maxFee: 10 ** 15, tip: 0, paymasterData: [],accountDeploymentData: [],
|
|
82
|
+
* nonceDataAvailabilityMode: RPC.EDataAvailabilityMode.L1,
|
|
83
|
+
* feeDataAvailabilityMode: RPC.EDataAvailabilityMode.L1,
|
|
84
|
+
* resourceBounds: stark.estimateFeeToBounds(constants.ZERO),
|
|
85
|
+
* }
|
|
86
|
+
* const result = await mySigner.signDeployAccountTransaction(myDeployAcc);
|
|
87
|
+
* // result = Signature {r: 2871311234341436528393212130310036951068553852419934781736214693308640202748n,
|
|
88
|
+
* // s: 1746271646048888422437132495446973163454853863041370993384284773665861377605n, recovery: 1}
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
abstract signDeployAccountTransaction(transaction: DeployAccountSignerDetails): Promise<Signature>;
|
|
92
|
+
/**
|
|
93
|
+
* Signs a DECLARE transaction with the private key and returns the signature
|
|
94
|
+
*
|
|
95
|
+
* @param {DeclareSignerDetails} transaction to declare a class
|
|
96
|
+
* @returns {Promise<Signature>} the signature of the transaction to declare a class
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const mySigner = new Signer("0x123");
|
|
100
|
+
* const myDeclare: DeclareSignerDetails = {
|
|
101
|
+
* version: "0x2", chainId: constants.StarknetChainId.SN_SEPOLIA,
|
|
102
|
+
* senderAddress: "0x65a822fbee1ae79e898688b5a4282dc79e0042cbed12f6169937fddb4c26641",
|
|
103
|
+
* classHash: "0x5f3614e8671257aff9ac38e929c74d65b02d460ae966cd826c9f04a7fa8e0d4",
|
|
104
|
+
* nonce: 45, maxFee: 10 ** 15, tip: 0, paymasterData: [], accountDeploymentData: [],
|
|
105
|
+
* nonceDataAvailabilityMode: RPC.EDataAvailabilityMode.L1,
|
|
106
|
+
* feeDataAvailabilityMode: RPC.EDataAvailabilityMode.L1,
|
|
107
|
+
* resourceBounds: stark.estimateFeeToBounds(constants.ZERO),
|
|
108
|
+
}
|
|
109
|
+
* const result = await mySigner.signDeclareTransaction(myDeclare);
|
|
110
|
+
* // result = Signature {r: 2432056944313955951711774394836075930010416436707488863728289188289211995670n,
|
|
111
|
+
* // s: 3407649393310177489888603098175002856596469926897298636282244411990343146307n, recovery: 1}
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
abstract signDeclareTransaction(transaction: DeclareSignerDetails): Promise<Signature>;
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { EDataAvailabilityMode, ETransactionVersion, ResourceBounds } from './api';
|
|
2
|
+
import { AllowArray, BigNumberish, BlockIdentifier, Call, DeclareContractPayload, DeployAccountContractPayload, TransactionType, UniversalDeployerContractPayload, V3TransactionDetails } from './lib';
|
|
3
|
+
import { DeclareTransactionReceiptResponse, EstimateFeeResponse } from './provider';
|
|
4
|
+
export interface EstimateFee extends EstimateFeeResponse {
|
|
5
|
+
}
|
|
6
|
+
export type EstimateFeeBulk = Array<EstimateFee>;
|
|
7
|
+
export type AccountInvocationsFactoryDetails = {
|
|
8
|
+
versions: Array<`${ETransactionVersion}`>;
|
|
9
|
+
nonce?: BigNumberish;
|
|
10
|
+
blockIdentifier?: BlockIdentifier;
|
|
11
|
+
skipValidate?: boolean;
|
|
12
|
+
} & Partial<V3TransactionDetails>;
|
|
13
|
+
export interface UniversalDetails {
|
|
14
|
+
nonce?: BigNumberish;
|
|
15
|
+
blockIdentifier?: BlockIdentifier;
|
|
16
|
+
maxFee?: BigNumberish;
|
|
17
|
+
tip?: BigNumberish;
|
|
18
|
+
paymasterData?: BigNumberish[];
|
|
19
|
+
accountDeploymentData?: BigNumberish[];
|
|
20
|
+
nonceDataAvailabilityMode?: EDataAvailabilityMode;
|
|
21
|
+
feeDataAvailabilityMode?: EDataAvailabilityMode;
|
|
22
|
+
version?: BigNumberish;
|
|
23
|
+
resourceBounds?: ResourceBounds;
|
|
24
|
+
skipValidate?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface EstimateFeeDetails extends UniversalDetails {
|
|
27
|
+
}
|
|
28
|
+
export interface DeployContractResponse {
|
|
29
|
+
contract_address: string;
|
|
30
|
+
transaction_hash: string;
|
|
31
|
+
}
|
|
32
|
+
export type MultiDeployContractResponse = {
|
|
33
|
+
contract_address: Array<string>;
|
|
34
|
+
transaction_hash: string;
|
|
35
|
+
};
|
|
36
|
+
export type DeployContractUDCResponse = {
|
|
37
|
+
contract_address: string;
|
|
38
|
+
transaction_hash: string;
|
|
39
|
+
address: string;
|
|
40
|
+
deployer: string;
|
|
41
|
+
unique: string;
|
|
42
|
+
classHash: string;
|
|
43
|
+
calldata_len: string;
|
|
44
|
+
calldata: Array<string>;
|
|
45
|
+
salt: string;
|
|
46
|
+
};
|
|
47
|
+
export type DeclareDeployUDCResponse = {
|
|
48
|
+
declare: {
|
|
49
|
+
class_hash: BigNumberish;
|
|
50
|
+
} & Partial<DeclareTransactionReceiptResponse>;
|
|
51
|
+
deploy: DeployContractUDCResponse;
|
|
52
|
+
};
|
|
53
|
+
export type SimulateTransactionDetails = {
|
|
54
|
+
nonce?: BigNumberish;
|
|
55
|
+
blockIdentifier?: BlockIdentifier;
|
|
56
|
+
skipValidate?: boolean;
|
|
57
|
+
skipExecute?: boolean;
|
|
58
|
+
} & Partial<V3TransactionDetails>;
|
|
59
|
+
export type EstimateFeeAction = {
|
|
60
|
+
type: typeof TransactionType.INVOKE;
|
|
61
|
+
payload: AllowArray<Call>;
|
|
62
|
+
} | {
|
|
63
|
+
type: typeof TransactionType.DECLARE;
|
|
64
|
+
payload: DeclareContractPayload;
|
|
65
|
+
} | {
|
|
66
|
+
type: typeof TransactionType.DEPLOY_ACCOUNT;
|
|
67
|
+
payload: DeployAccountContractPayload;
|
|
68
|
+
} | {
|
|
69
|
+
type: typeof TransactionType.DEPLOY;
|
|
70
|
+
payload: UniversalDeployerContractPayload;
|
|
71
|
+
};
|
|
72
|
+
export type StarkProfile = {
|
|
73
|
+
name?: string;
|
|
74
|
+
profilePicture?: string;
|
|
75
|
+
discord?: string;
|
|
76
|
+
twitter?: string;
|
|
77
|
+
github?: string;
|
|
78
|
+
proofOfPersonhood?: boolean;
|
|
79
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
JRPC: true,
|
|
8
|
+
RPCSPEC06: true,
|
|
9
|
+
RPCSPEC07: true
|
|
10
|
+
};
|
|
11
|
+
exports.RPCSPEC07 = exports.RPCSPEC06 = exports.JRPC = void 0;
|
|
12
|
+
var _JRPC = _interopRequireWildcard(require("./jsonrpc/index.cjs"));
|
|
13
|
+
exports.JRPC = _JRPC;
|
|
14
|
+
var _RPCSPEC = _interopRequireWildcard(require("./rpcspec_0_6/index.cjs"));
|
|
15
|
+
exports.RPCSPEC06 = _RPCSPEC;
|
|
16
|
+
var _RPCSPEC2 = _interopRequireWildcard(require("starknet-types-07"));
|
|
17
|
+
exports.RPCSPEC07 = _RPCSPEC2;
|
|
18
|
+
Object.keys(_RPCSPEC2).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
21
|
+
if (key in exports && exports[key] === _RPCSPEC2[key]) return;
|
|
22
|
+
Object.defineProperty(exports, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return _RPCSPEC2[key];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
30
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type RequestBody = {
|
|
2
|
+
id: number | string;
|
|
3
|
+
jsonrpc: '2.0';
|
|
4
|
+
method: string;
|
|
5
|
+
params?: {};
|
|
6
|
+
};
|
|
7
|
+
export type ResponseBody = {
|
|
8
|
+
id: number | string;
|
|
9
|
+
jsonrpc: '2.0';
|
|
10
|
+
} & (SuccessResponseBody | ErrorResponseBody);
|
|
11
|
+
export type SuccessResponseBody = {
|
|
12
|
+
result: unknown;
|
|
13
|
+
};
|
|
14
|
+
export type ErrorResponseBody = {
|
|
15
|
+
error: Error;
|
|
16
|
+
};
|
|
17
|
+
export type Error = {
|
|
18
|
+
code: number;
|
|
19
|
+
message: string;
|
|
20
|
+
data?: unknown;
|
|
21
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|