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,45 @@
|
|
|
1
|
+
import { BigNumberish, Uint256 } from '../types';
|
|
2
|
+
import { UINT_128_MAX, UINT_256_MAX } from './cairoDataTypes/uint256';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Legacy support Export
|
|
5
|
+
*/
|
|
6
|
+
export { UINT_128_MAX, UINT_256_MAX };
|
|
7
|
+
/**
|
|
8
|
+
* Convert Uint256 to bigint
|
|
9
|
+
* Legacy support Export
|
|
10
|
+
* @param {Uint256} uint256 Uint256 value to convert to bigint
|
|
11
|
+
* @returns {bigint} BigInt representation of the input Uint256
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const uint256Value: Uint256 = {low: 1234567890, high: 1};
|
|
15
|
+
* const result = uint256.uint256ToBN(uint256Value);
|
|
16
|
+
* // result = 340282366920938463463374607433002779346n
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function uint256ToBN(uint256: Uint256): bigint;
|
|
20
|
+
/**
|
|
21
|
+
* Test BigNumberish is in the range[0, 2**256-1]
|
|
22
|
+
* Legacy support Export
|
|
23
|
+
* @param {BigNumberish} bn value to test
|
|
24
|
+
* @returns {boolean} True if the input value is in the range[0, 2**256-1], false otherwise
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const result = uint256.isUint256(12345n);
|
|
28
|
+
* // result = true
|
|
29
|
+
* const result1 = uint256.isUint256(-1);
|
|
30
|
+
* // result1 = false
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function isUint256(bn: BigNumberish): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Convert BigNumberish (string | number | bigint) to Uint256
|
|
36
|
+
* Legacy support Export
|
|
37
|
+
* @param {BigNumberish} bn value to convert to Uint256
|
|
38
|
+
* @returns {Uint256} Uint256 object representing the BigNumberish value
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const result = uint256.bnToUint256(1000000000n);
|
|
42
|
+
* // result = {"low": "0x3b9aca00", "high": "0x0"}
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function bnToUint256(bn: BigNumberish): Uint256;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CairoUint256, UINT_128_MAX, UINT_256_MAX } from "./cairoDataTypes/uint256.mjs";
|
|
2
|
+
export { UINT_128_MAX, UINT_256_MAX };
|
|
3
|
+
export function uint256ToBN(uint256) {
|
|
4
|
+
return new CairoUint256(uint256).toBigInt();
|
|
5
|
+
}
|
|
6
|
+
export function isUint256(bn) {
|
|
7
|
+
return CairoUint256.is(bn);
|
|
8
|
+
}
|
|
9
|
+
export function bnToUint256(bn) {
|
|
10
|
+
return new CairoUint256(bn).toUint256HexString();
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildUrl = buildUrl;
|
|
7
|
+
exports.isUrl = isUrl;
|
|
8
|
+
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
|
|
11
|
+
const localhostDomainRE = /^localhost[:?\d]*(?:[^:?\d]\S*)?$/;
|
|
12
|
+
const nonLocalhostDomainRE = /^[^\s.]+\.\S{2,}$/;
|
|
13
|
+
function isUrl(s) {
|
|
14
|
+
if (!s) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (typeof s !== "string") {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const match = s.match(protocolAndDomainRE);
|
|
21
|
+
if (!match) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const everythingAfterProtocol = match[1];
|
|
25
|
+
if (!everythingAfterProtocol) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
function buildUrl(baseUrl, defaultPath, urlOrPath) {
|
|
34
|
+
return isUrl(urlOrPath) ? urlOrPath : (0, _urlJoin.default)(baseUrl, urlOrPath ?? defaultPath);
|
|
35
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loosely validate a URL `string`.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} s - The URL to check for
|
|
5
|
+
* @return {boolean} `true` if url is valid, `false` otherwise
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const s = "https://starknetjs.com/docs";
|
|
9
|
+
* const result = isUrl(s);
|
|
10
|
+
* // result == true
|
|
11
|
+
*/
|
|
12
|
+
export declare function isUrl(s?: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Builds a URL using the provided base URL, default path, and optional URL or path.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} baseUrl - The base URL of the URL being built.
|
|
17
|
+
* @param {string} defaultPath - The default path to use if no URL or path is provided.
|
|
18
|
+
* @param {string} [urlOrPath] - The optional URL or path to append to the base URL.
|
|
19
|
+
* @return {string} The built URL.
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const baseUrl = "https://starknetjs.com";
|
|
23
|
+
* const defaultPath = "/";
|
|
24
|
+
* const urlOrPath = "/docs";
|
|
25
|
+
* const result = buildUrl(baseUrl, defaultPath, urlOrPath);
|
|
26
|
+
*
|
|
27
|
+
* result = "https://starknetjs.com/docs"
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): any;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import urljoin from "url-join";
|
|
2
|
+
const protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
|
|
3
|
+
const localhostDomainRE = /^localhost[:?\d]*(?:[^:?\d]\S*)?$/;
|
|
4
|
+
const nonLocalhostDomainRE = /^[^\s.]+\.\S{2,}$/;
|
|
5
|
+
export function isUrl(s) {
|
|
6
|
+
if (!s) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (typeof s !== "string") {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const match = s.match(protocolAndDomainRE);
|
|
13
|
+
if (!match) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const everythingAfterProtocol = match[1];
|
|
17
|
+
if (!everythingAfterProtocol) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
export function buildUrl(baseUrl, defaultPath, urlOrPath) {
|
|
26
|
+
return isUrl(urlOrPath) ? urlOrPath : urljoin(baseUrl, urlOrPath ?? defaultPath);
|
|
27
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WalletAccount = void 0;
|
|
7
|
+
var _account = require("../account/index.cjs");
|
|
8
|
+
var _contract = require("../utils/contract.cjs");
|
|
9
|
+
var _json = require("../utils/json.cjs");
|
|
10
|
+
var _transaction = require("../utils/transaction.cjs");
|
|
11
|
+
var _connect = require("./connect.cjs");
|
|
12
|
+
class WalletAccount extends _account.Account {
|
|
13
|
+
address = "";
|
|
14
|
+
walletProvider;
|
|
15
|
+
constructor(providerOrOptions, walletProvider, cairoVersion) {
|
|
16
|
+
super(providerOrOptions, "", "", cairoVersion);
|
|
17
|
+
this.walletProvider = walletProvider;
|
|
18
|
+
this.walletProvider.on("accountsChanged", res => {
|
|
19
|
+
if (!res) return;
|
|
20
|
+
this.address = res[0].toLowerCase();
|
|
21
|
+
});
|
|
22
|
+
this.walletProvider.on("networkChanged", res => {
|
|
23
|
+
if (!res) return;
|
|
24
|
+
this.channel.setChainId(res);
|
|
25
|
+
});
|
|
26
|
+
walletProvider.request({
|
|
27
|
+
type: "wallet_requestAccounts",
|
|
28
|
+
params: {
|
|
29
|
+
silent_mode: false
|
|
30
|
+
}
|
|
31
|
+
}).then(res => {
|
|
32
|
+
this.address = res[0].toLowerCase();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* WALLET EVENTS
|
|
37
|
+
*/
|
|
38
|
+
onAccountChange(callback) {
|
|
39
|
+
(0, _connect.onAccountChange)(this.walletProvider, callback);
|
|
40
|
+
}
|
|
41
|
+
onNetworkChanged(callback) {
|
|
42
|
+
(0, _connect.onNetworkChanged)(this.walletProvider, callback);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* WALLET SPECIFIC METHODS
|
|
46
|
+
*/
|
|
47
|
+
requestAccounts(silentMode = false) {
|
|
48
|
+
return (0, _connect.requestAccounts)(this.walletProvider, silentMode);
|
|
49
|
+
}
|
|
50
|
+
getPermissions() {
|
|
51
|
+
return (0, _connect.getPermissions)(this.walletProvider);
|
|
52
|
+
}
|
|
53
|
+
switchStarknetChain(chainId) {
|
|
54
|
+
return (0, _connect.switchStarknetChain)(this.walletProvider, chainId);
|
|
55
|
+
}
|
|
56
|
+
watchAsset(asset) {
|
|
57
|
+
return (0, _connect.watchAsset)(this.walletProvider, asset);
|
|
58
|
+
}
|
|
59
|
+
addStarknetChain(chain) {
|
|
60
|
+
return (0, _connect.addStarknetChain)(this.walletProvider, chain);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* ACCOUNT METHODS
|
|
64
|
+
*/
|
|
65
|
+
execute(calls) {
|
|
66
|
+
const txCalls = [].concat(calls).map(it => {
|
|
67
|
+
const {
|
|
68
|
+
contractAddress,
|
|
69
|
+
entrypoint,
|
|
70
|
+
calldata
|
|
71
|
+
} = it;
|
|
72
|
+
return {
|
|
73
|
+
contract_address: contractAddress,
|
|
74
|
+
entry_point: entrypoint,
|
|
75
|
+
calldata
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
const params = {
|
|
79
|
+
calls: txCalls
|
|
80
|
+
};
|
|
81
|
+
return (0, _connect.addInvokeTransaction)(this.walletProvider, params);
|
|
82
|
+
}
|
|
83
|
+
declare(payload) {
|
|
84
|
+
const declareContractPayload = (0, _contract.extractContractHashes)(payload);
|
|
85
|
+
const pContract = payload.contract;
|
|
86
|
+
const cairo1Contract = {
|
|
87
|
+
...pContract,
|
|
88
|
+
abi: (0, _json.stringify)(pContract.abi)
|
|
89
|
+
};
|
|
90
|
+
if (!declareContractPayload.compiledClassHash) {
|
|
91
|
+
throw Error("compiledClassHash is required");
|
|
92
|
+
}
|
|
93
|
+
const params = {
|
|
94
|
+
compiled_class_hash: declareContractPayload.compiledClassHash,
|
|
95
|
+
contract_class: cairo1Contract
|
|
96
|
+
};
|
|
97
|
+
return (0, _connect.addDeclareTransaction)(this.walletProvider, params);
|
|
98
|
+
}
|
|
99
|
+
async deploy(payload) {
|
|
100
|
+
const {
|
|
101
|
+
calls,
|
|
102
|
+
addresses
|
|
103
|
+
} = (0, _transaction.buildUDCCall)(payload, this.address);
|
|
104
|
+
const invokeResponse = await this.execute(calls);
|
|
105
|
+
return {
|
|
106
|
+
...invokeResponse,
|
|
107
|
+
contract_address: addresses
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
signMessage(typedData) {
|
|
111
|
+
return (0, _connect.signMessage)(this.walletProvider, typedData);
|
|
112
|
+
}
|
|
113
|
+
// TODO: MISSING ESTIMATES
|
|
114
|
+
}
|
|
115
|
+
exports.WalletAccount = WalletAccount;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type AccountChangeEventHandler, type AddStarknetChainParameters, type NetworkChangeEventHandler, type WatchAssetParameters, type SPEC } from 'starknet-types-07';
|
|
2
|
+
import { Account, AccountInterface } from '../account';
|
|
3
|
+
import { ProviderInterface } from '../provider';
|
|
4
|
+
import { AllowArray, CairoVersion, Call, DeclareContractPayload, MultiDeployContractResponse, ProviderOptions, TypedData, UniversalDeployerContractPayload } from '../types';
|
|
5
|
+
import { StarknetWalletProvider } from './types';
|
|
6
|
+
import { StarknetChainId } from '../constants';
|
|
7
|
+
export declare class WalletAccount extends Account implements AccountInterface {
|
|
8
|
+
address: string;
|
|
9
|
+
walletProvider: StarknetWalletProvider;
|
|
10
|
+
constructor(providerOrOptions: ProviderOptions | ProviderInterface, walletProvider: StarknetWalletProvider, cairoVersion?: CairoVersion);
|
|
11
|
+
/**
|
|
12
|
+
* WALLET EVENTS
|
|
13
|
+
*/
|
|
14
|
+
onAccountChange(callback: AccountChangeEventHandler): void;
|
|
15
|
+
onNetworkChanged(callback: NetworkChangeEventHandler): void;
|
|
16
|
+
/**
|
|
17
|
+
* WALLET SPECIFIC METHODS
|
|
18
|
+
*/
|
|
19
|
+
requestAccounts(silentMode?: boolean): Promise<string[]>;
|
|
20
|
+
getPermissions(): Promise<[] | "accounts"[]>;
|
|
21
|
+
switchStarknetChain(chainId: StarknetChainId): Promise<boolean>;
|
|
22
|
+
watchAsset(asset: WatchAssetParameters): Promise<boolean>;
|
|
23
|
+
addStarknetChain(chain: AddStarknetChainParameters): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* ACCOUNT METHODS
|
|
26
|
+
*/
|
|
27
|
+
execute(calls: AllowArray<Call>): Promise<import("starknet-types-07").AddInvokeTransactionResult>;
|
|
28
|
+
declare(payload: DeclareContractPayload): Promise<import("starknet-types-07").AddDeclareTransactionResult>;
|
|
29
|
+
deploy(payload: UniversalDeployerContractPayload | UniversalDeployerContractPayload[]): Promise<MultiDeployContractResponse>;
|
|
30
|
+
signMessage(typedData: TypedData): Promise<SPEC.SIGNATURE>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Account } from "../account/index.mjs";
|
|
2
|
+
import { extractContractHashes } from "../utils/contract.mjs";
|
|
3
|
+
import { stringify } from "../utils/json.mjs";
|
|
4
|
+
import { buildUDCCall } from "../utils/transaction.mjs";
|
|
5
|
+
import {
|
|
6
|
+
addDeclareTransaction,
|
|
7
|
+
addInvokeTransaction,
|
|
8
|
+
addStarknetChain,
|
|
9
|
+
getPermissions,
|
|
10
|
+
onAccountChange,
|
|
11
|
+
onNetworkChanged,
|
|
12
|
+
requestAccounts,
|
|
13
|
+
signMessage,
|
|
14
|
+
switchStarknetChain,
|
|
15
|
+
watchAsset
|
|
16
|
+
} from "./connect.mjs";
|
|
17
|
+
export class WalletAccount extends Account {
|
|
18
|
+
address = "";
|
|
19
|
+
walletProvider;
|
|
20
|
+
constructor(providerOrOptions, walletProvider, cairoVersion) {
|
|
21
|
+
super(providerOrOptions, "", "", cairoVersion);
|
|
22
|
+
this.walletProvider = walletProvider;
|
|
23
|
+
this.walletProvider.on("accountsChanged", (res) => {
|
|
24
|
+
if (!res) return;
|
|
25
|
+
this.address = res[0].toLowerCase();
|
|
26
|
+
});
|
|
27
|
+
this.walletProvider.on("networkChanged", (res) => {
|
|
28
|
+
if (!res) return;
|
|
29
|
+
this.channel.setChainId(res);
|
|
30
|
+
});
|
|
31
|
+
walletProvider.request({
|
|
32
|
+
type: "wallet_requestAccounts",
|
|
33
|
+
params: {
|
|
34
|
+
silent_mode: false
|
|
35
|
+
}
|
|
36
|
+
}).then((res) => {
|
|
37
|
+
this.address = res[0].toLowerCase();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* WALLET EVENTS
|
|
42
|
+
*/
|
|
43
|
+
onAccountChange(callback) {
|
|
44
|
+
onAccountChange(this.walletProvider, callback);
|
|
45
|
+
}
|
|
46
|
+
onNetworkChanged(callback) {
|
|
47
|
+
onNetworkChanged(this.walletProvider, callback);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* WALLET SPECIFIC METHODS
|
|
51
|
+
*/
|
|
52
|
+
requestAccounts(silentMode = false) {
|
|
53
|
+
return requestAccounts(this.walletProvider, silentMode);
|
|
54
|
+
}
|
|
55
|
+
getPermissions() {
|
|
56
|
+
return getPermissions(this.walletProvider);
|
|
57
|
+
}
|
|
58
|
+
switchStarknetChain(chainId) {
|
|
59
|
+
return switchStarknetChain(this.walletProvider, chainId);
|
|
60
|
+
}
|
|
61
|
+
watchAsset(asset) {
|
|
62
|
+
return watchAsset(this.walletProvider, asset);
|
|
63
|
+
}
|
|
64
|
+
addStarknetChain(chain) {
|
|
65
|
+
return addStarknetChain(this.walletProvider, chain);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* ACCOUNT METHODS
|
|
69
|
+
*/
|
|
70
|
+
execute(calls) {
|
|
71
|
+
const txCalls = [].concat(calls).map((it) => {
|
|
72
|
+
const { contractAddress, entrypoint, calldata } = it;
|
|
73
|
+
return {
|
|
74
|
+
contract_address: contractAddress,
|
|
75
|
+
entry_point: entrypoint,
|
|
76
|
+
calldata
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
const params = {
|
|
80
|
+
calls: txCalls
|
|
81
|
+
};
|
|
82
|
+
return addInvokeTransaction(this.walletProvider, params);
|
|
83
|
+
}
|
|
84
|
+
declare(payload) {
|
|
85
|
+
const declareContractPayload = extractContractHashes(payload);
|
|
86
|
+
const pContract = payload.contract;
|
|
87
|
+
const cairo1Contract = {
|
|
88
|
+
...pContract,
|
|
89
|
+
abi: stringify(pContract.abi)
|
|
90
|
+
};
|
|
91
|
+
if (!declareContractPayload.compiledClassHash) {
|
|
92
|
+
throw Error("compiledClassHash is required");
|
|
93
|
+
}
|
|
94
|
+
const params = {
|
|
95
|
+
compiled_class_hash: declareContractPayload.compiledClassHash,
|
|
96
|
+
contract_class: cairo1Contract
|
|
97
|
+
};
|
|
98
|
+
return addDeclareTransaction(this.walletProvider, params);
|
|
99
|
+
}
|
|
100
|
+
async deploy(payload) {
|
|
101
|
+
const { calls, addresses } = buildUDCCall(payload, this.address);
|
|
102
|
+
const invokeResponse = await this.execute(calls);
|
|
103
|
+
return {
|
|
104
|
+
...invokeResponse,
|
|
105
|
+
contract_address: addresses
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
signMessage(typedData) {
|
|
109
|
+
return signMessage(this.walletProvider, typedData);
|
|
110
|
+
}
|
|
111
|
+
// TODO: MISSING ESTIMATES
|
|
112
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.addDeclareTransaction = addDeclareTransaction;
|
|
7
|
+
exports.addInvokeTransaction = addInvokeTransaction;
|
|
8
|
+
exports.addStarknetChain = addStarknetChain;
|
|
9
|
+
exports.deploymentData = deploymentData;
|
|
10
|
+
exports.getPermissions = getPermissions;
|
|
11
|
+
exports.onAccountChange = onAccountChange;
|
|
12
|
+
exports.onNetworkChanged = onNetworkChanged;
|
|
13
|
+
exports.requestAccounts = requestAccounts;
|
|
14
|
+
exports.requestChainId = requestChainId;
|
|
15
|
+
exports.signMessage = signMessage;
|
|
16
|
+
exports.supportedSpecs = supportedSpecs;
|
|
17
|
+
exports.switchStarknetChain = switchStarknetChain;
|
|
18
|
+
exports.watchAsset = watchAsset;
|
|
19
|
+
function requestAccounts(swo, silent_mode = false) {
|
|
20
|
+
return swo.request({
|
|
21
|
+
type: "wallet_requestAccounts",
|
|
22
|
+
params: {
|
|
23
|
+
silent_mode
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function getPermissions(swo) {
|
|
28
|
+
return swo.request({
|
|
29
|
+
type: "wallet_getPermissions"
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function watchAsset(swo, asset) {
|
|
33
|
+
return swo.request({
|
|
34
|
+
type: "wallet_watchAsset",
|
|
35
|
+
params: asset
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function addStarknetChain(swo, chain) {
|
|
39
|
+
return swo.request({
|
|
40
|
+
type: "wallet_addStarknetChain",
|
|
41
|
+
params: chain
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function switchStarknetChain(swo, chainId) {
|
|
45
|
+
return swo.request({
|
|
46
|
+
type: "wallet_switchStarknetChain",
|
|
47
|
+
params: {
|
|
48
|
+
chainId
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function requestChainId(swo) {
|
|
53
|
+
return swo.request({
|
|
54
|
+
type: "wallet_requestChainId"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function deploymentData(swo) {
|
|
58
|
+
return swo.request({
|
|
59
|
+
type: "wallet_deploymentData"
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function addInvokeTransaction(swo, params) {
|
|
63
|
+
return swo.request({
|
|
64
|
+
type: "wallet_addInvokeTransaction",
|
|
65
|
+
params
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function addDeclareTransaction(swo, params) {
|
|
69
|
+
return swo.request({
|
|
70
|
+
type: "wallet_addDeclareTransaction",
|
|
71
|
+
params
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function signMessage(swo, typedData) {
|
|
75
|
+
return swo.request({
|
|
76
|
+
type: "wallet_signTypedData",
|
|
77
|
+
params: typedData
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function supportedSpecs(swo) {
|
|
81
|
+
return swo.request({
|
|
82
|
+
type: "wallet_supportedSpecs"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function onAccountChange(swo, callback) {
|
|
86
|
+
swo.on("accountsChanged", callback);
|
|
87
|
+
}
|
|
88
|
+
function onNetworkChanged(swo, callback) {
|
|
89
|
+
swo.on("networkChanged", callback);
|
|
90
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type WatchAssetParameters, type AccountChangeEventHandler, type AddDeclareTransactionParameters, type AddInvokeTransactionParameters, type AddStarknetChainParameters, type NetworkChangeEventHandler, type ChainId, type StarknetWindowObject, type TypedData, type SPEC } from 'starknet-types-07';
|
|
2
|
+
/**
|
|
3
|
+
* Request Permission for wallet account, return addresses that are allowed by user
|
|
4
|
+
* @param {boolean} [silent_mode=false] false: request user interaction allowance. true: return only pre-allowed
|
|
5
|
+
* @returns allowed accounts addresses
|
|
6
|
+
*/
|
|
7
|
+
export declare function requestAccounts(swo: StarknetWindowObject, silent_mode?: boolean): Promise<string[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Request Permission for wallet account
|
|
10
|
+
* @returns allowed accounts addresses
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPermissions(swo: StarknetWindowObject): Promise<[] | "accounts"[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Request adding ERC20 Token to Wallet List
|
|
15
|
+
* @param asset WatchAssetParameters
|
|
16
|
+
* @returns boolean
|
|
17
|
+
*/
|
|
18
|
+
export declare function watchAsset(swo: StarknetWindowObject, asset: WatchAssetParameters): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Request adding custom Starknet chain
|
|
21
|
+
* @param chain AddStarknetChainParameters
|
|
22
|
+
* @returns boolean
|
|
23
|
+
*/
|
|
24
|
+
export declare function addStarknetChain(swo: StarknetWindowObject, chain: AddStarknetChainParameters): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Request Wallet Network change
|
|
27
|
+
* @param chainId StarknetChainId
|
|
28
|
+
* @returns boolean
|
|
29
|
+
*/
|
|
30
|
+
export declare function switchStarknetChain(swo: StarknetWindowObject, chainId: ChainId): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Request the current chain ID from the wallet.
|
|
33
|
+
* @returns The current Starknet chain ID.
|
|
34
|
+
*/
|
|
35
|
+
export declare function requestChainId(swo: StarknetWindowObject): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Get deployment data for a contract.
|
|
38
|
+
* @returns The deployment data result.
|
|
39
|
+
*/
|
|
40
|
+
export declare function deploymentData(swo: StarknetWindowObject): Promise<import("starknet-types-07").AccountDeploymentData>;
|
|
41
|
+
/**
|
|
42
|
+
* Add an invoke transaction to the wallet.
|
|
43
|
+
* @param params The parameters required for the invoke transaction.
|
|
44
|
+
* @returns The result of adding the invoke transaction.
|
|
45
|
+
*/
|
|
46
|
+
export declare function addInvokeTransaction(swo: StarknetWindowObject, params: AddInvokeTransactionParameters): Promise<import("starknet-types-07").AddInvokeTransactionResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Add a declare transaction to the wallet.
|
|
49
|
+
* @param params The parameters required for the declare transaction.
|
|
50
|
+
* @returns The result of adding the declare transaction.
|
|
51
|
+
*/
|
|
52
|
+
export declare function addDeclareTransaction(swo: StarknetWindowObject, params: AddDeclareTransactionParameters): Promise<import("starknet-types-07").AddDeclareTransactionResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Sign typed data using the wallet.
|
|
55
|
+
* @param swo the starknet (wallet) window object to request the signature.
|
|
56
|
+
* @param typedData The typed data to sign.
|
|
57
|
+
* @returns An array of signatures as strings.
|
|
58
|
+
*/
|
|
59
|
+
export declare function signMessage(swo: StarknetWindowObject, typedData: TypedData): Promise<SPEC.SIGNATURE>;
|
|
60
|
+
/**
|
|
61
|
+
* Get the list of supported specifications.
|
|
62
|
+
* @returns An array of supported specification strings.
|
|
63
|
+
*/
|
|
64
|
+
export declare function supportedSpecs(swo: StarknetWindowObject): Promise<string[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Attaches an event handler function to the "accountsChanged" event of a StarknetWindowObject.
|
|
67
|
+
* When the accounts are changed, the specified callback function will be called.
|
|
68
|
+
*
|
|
69
|
+
* @param {StarknetWindowObject} swo - The StarknetWindowObject to attach the event handler to.
|
|
70
|
+
* @param {AccountChangeEventHandler} callback - The function to be called when the accounts are changed.
|
|
71
|
+
* It will receive the changed accounts as a parameter.
|
|
72
|
+
* @returns {void}
|
|
73
|
+
*/
|
|
74
|
+
export declare function onAccountChange(swo: StarknetWindowObject, callback: AccountChangeEventHandler): void;
|
|
75
|
+
/**
|
|
76
|
+
* Register a callback function to be called when the network is changed.
|
|
77
|
+
*
|
|
78
|
+
* @param {StarknetWindowObject} swo - The StarknetWindowObject instance.
|
|
79
|
+
* @param {NetworkChangeEventHandler} callback - The callback function to be called when the network is changed.
|
|
80
|
+
* @return {void}
|
|
81
|
+
*/
|
|
82
|
+
export declare function onNetworkChanged(swo: StarknetWindowObject, callback: NetworkChangeEventHandler): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export function requestAccounts(swo, silent_mode = false) {
|
|
2
|
+
return swo.request({
|
|
3
|
+
type: "wallet_requestAccounts",
|
|
4
|
+
params: {
|
|
5
|
+
silent_mode
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export function getPermissions(swo) {
|
|
10
|
+
return swo.request({ type: "wallet_getPermissions" });
|
|
11
|
+
}
|
|
12
|
+
export function watchAsset(swo, asset) {
|
|
13
|
+
return swo.request({
|
|
14
|
+
type: "wallet_watchAsset",
|
|
15
|
+
params: asset
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function addStarknetChain(swo, chain) {
|
|
19
|
+
return swo.request({
|
|
20
|
+
type: "wallet_addStarknetChain",
|
|
21
|
+
params: chain
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function switchStarknetChain(swo, chainId) {
|
|
25
|
+
return swo.request({
|
|
26
|
+
type: "wallet_switchStarknetChain",
|
|
27
|
+
params: {
|
|
28
|
+
chainId
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function requestChainId(swo) {
|
|
33
|
+
return swo.request({ type: "wallet_requestChainId" });
|
|
34
|
+
}
|
|
35
|
+
export function deploymentData(swo) {
|
|
36
|
+
return swo.request({ type: "wallet_deploymentData" });
|
|
37
|
+
}
|
|
38
|
+
export function addInvokeTransaction(swo, params) {
|
|
39
|
+
return swo.request({
|
|
40
|
+
type: "wallet_addInvokeTransaction",
|
|
41
|
+
params
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function addDeclareTransaction(swo, params) {
|
|
45
|
+
return swo.request({
|
|
46
|
+
type: "wallet_addDeclareTransaction",
|
|
47
|
+
params
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export function signMessage(swo, typedData) {
|
|
51
|
+
return swo.request({
|
|
52
|
+
type: "wallet_signTypedData",
|
|
53
|
+
params: typedData
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export function supportedSpecs(swo) {
|
|
57
|
+
return swo.request({ type: "wallet_supportedSpecs" });
|
|
58
|
+
}
|
|
59
|
+
export function onAccountChange(swo, callback) {
|
|
60
|
+
swo.on("accountsChanged", callback);
|
|
61
|
+
}
|
|
62
|
+
export function onNetworkChanged(swo, callback) {
|
|
63
|
+
swo.on("networkChanged", callback);
|
|
64
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _account = require("./account.cjs");
|
|
7
|
+
Object.keys(_account).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _account[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _account[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './account';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./account.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|