ccxt 4.3.70 → 4.3.71
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/README.md +6 -5
- package/dist/ccxt.browser.min.js +13 -10
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/abstract/paradex.js +9 -0
- package/dist/cjs/src/base/Exchange.js +49 -0
- package/dist/cjs/src/paradex.js +2075 -0
- package/dist/cjs/src/pro/bequant.js +4 -0
- package/dist/cjs/src/pro/paradex.js +365 -0
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/poseidon.js +100 -0
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/weierstrass.js +1 -0
- package/dist/cjs/src/static_dependencies/scure-starknet/index.js +284 -0
- package/dist/cjs/src/static_dependencies/starknet/constants.js +60 -0
- package/dist/cjs/src/static_dependencies/starknet/types/calldata.js +26 -0
- package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/abi.js +8 -0
- package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/index.js +13 -0
- package/dist/cjs/src/static_dependencies/starknet/types/lib/index.js +56 -0
- package/dist/cjs/src/static_dependencies/starknet/types/typedData.js +19 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/assert.js +15 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +44 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +122 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +137 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/byteArray.js +61 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/cairo.js +218 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +57 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +64 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +63 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/formatter.js +66 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/index.js +281 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/index.js +33 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +37 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +40 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +156 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/requestParser.js +250 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/responseParser.js +215 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/tuple.js +112 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/validate.js +206 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/encode.js +58 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/hash/classHash.js +57 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/merkle.js +76 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/num.js +92 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/selector.js +48 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/shortString.js +101 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/typedData.js +334 -0
- package/dist/cjs/src/woo.js +4 -2
- package/js/ccxt.d.ts +8 -2
- package/js/ccxt.js +6 -2
- package/js/src/abstract/paradex.d.ts +43 -0
- package/js/src/abstract/paradex.js +11 -0
- package/js/src/base/Exchange.d.ts +7 -0
- package/js/src/base/Exchange.js +45 -0
- package/js/src/paradex.d.ts +76 -0
- package/js/src/paradex.js +2075 -0
- package/js/src/pro/bequant.js +4 -0
- package/js/src/pro/paradex.d.ts +15 -0
- package/js/src/pro/paradex.js +366 -0
- package/js/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +24 -0
- package/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +1 -1
- package/js/src/static_dependencies/scure-starknet/index.d.ts +79 -0
- package/js/src/static_dependencies/scure-starknet/index.js +323 -0
- package/js/src/static_dependencies/starknet/constants.d.ts +61 -0
- package/js/src/static_dependencies/starknet/constants.js +67 -0
- package/js/src/static_dependencies/starknet/index.d.ts +7 -0
- package/js/src/static_dependencies/starknet/index.js +50 -0
- package/js/src/static_dependencies/starknet/types/cairoEnum.d.ts +2 -0
- package/js/src/static_dependencies/starknet/types/cairoEnum.js +7 -0
- package/js/src/static_dependencies/starknet/types/calldata.d.ts +19 -0
- package/js/src/static_dependencies/starknet/types/calldata.js +28 -0
- package/js/src/static_dependencies/starknet/types/index.d.ts +13 -0
- package/js/src/static_dependencies/starknet/types/index.js +16 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/abi.d.ts +71 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/abi.js +13 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/index.d.ts +24 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/index.js +16 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/legacy.d.ts +33 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/legacy.js +7 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/sierra.d.ts +52 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/sierra.js +7 -0
- package/js/src/static_dependencies/starknet/types/lib/index.d.ts +248 -0
- package/js/src/static_dependencies/starknet/types/lib/index.js +52 -0
- package/js/src/static_dependencies/starknet/types/typedData.d.ts +44 -0
- package/js/src/static_dependencies/starknet/types/typedData.js +19 -0
- package/js/src/static_dependencies/starknet/utils/address.d.ts +53 -0
- package/js/src/static_dependencies/starknet/utils/address.js +89 -0
- package/js/src/static_dependencies/starknet/utils/assert.d.ts +7 -0
- package/js/src/static_dependencies/starknet/utils/assert.js +17 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/felt.d.ts +6 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +43 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.d.ts +72 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +117 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.d.ts +76 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +136 -0
- package/js/src/static_dependencies/starknet/utils/calldata/byteArray.d.ts +32 -0
- package/js/src/static_dependencies/starknet/utils/calldata/byteArray.js +59 -0
- package/js/src/static_dependencies/starknet/utils/calldata/cairo.d.ts +183 -0
- package/js/src/static_dependencies/starknet/utils/calldata/cairo.js +229 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +57 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.d.ts +35 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +64 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.d.ts +34 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +63 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/index.d.ts +3 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/index.js +9 -0
- package/js/src/static_dependencies/starknet/utils/calldata/formatter.d.ts +9 -0
- package/js/src/static_dependencies/starknet/utils/calldata/formatter.js +67 -0
- package/js/src/static_dependencies/starknet/utils/calldata/index.d.ts +89 -0
- package/js/src/static_dependencies/starknet/utils/calldata/index.js +280 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +5 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.js +30 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/interface.d.ts +20 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/interface.js +8 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +36 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +40 -0
- package/js/src/static_dependencies/starknet/utils/calldata/propertyOrder.d.ts +2 -0
- package/js/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +155 -0
- package/js/src/static_dependencies/starknet/utils/calldata/requestParser.d.ts +11 -0
- package/js/src/static_dependencies/starknet/utils/calldata/requestParser.js +248 -0
- package/js/src/static_dependencies/starknet/utils/calldata/responseParser.d.ts +11 -0
- package/js/src/static_dependencies/starknet/utils/calldata/responseParser.js +214 -0
- package/js/src/static_dependencies/starknet/utils/calldata/tuple.d.ts +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/tuple.js +113 -0
- package/js/src/static_dependencies/starknet/utils/calldata/validate.d.ts +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/validate.js +208 -0
- package/js/src/static_dependencies/starknet/utils/encode.d.ts +207 -0
- package/js/src/static_dependencies/starknet/utils/encode.js +282 -0
- package/js/src/static_dependencies/starknet/utils/hash/classHash.d.ts +57 -0
- package/js/src/static_dependencies/starknet/utils/hash/classHash.js +224 -0
- package/js/src/static_dependencies/starknet/utils/hash/index.d.ts +6 -0
- package/js/src/static_dependencies/starknet/utils/hash/index.js +13 -0
- package/js/src/static_dependencies/starknet/utils/json.d.ts +24 -0
- package/js/src/static_dependencies/starknet/utils/json.js +43 -0
- package/js/src/static_dependencies/starknet/utils/merkle.d.ts +35 -0
- package/js/src/static_dependencies/starknet/utils/merkle.js +84 -0
- package/js/src/static_dependencies/starknet/utils/num.d.ts +182 -0
- package/js/src/static_dependencies/starknet/utils/num.js +244 -0
- package/js/src/static_dependencies/starknet/utils/selector.d.ts +48 -0
- package/js/src/static_dependencies/starknet/utils/selector.js +85 -0
- package/js/src/static_dependencies/starknet/utils/shortString.d.ts +57 -0
- package/js/src/static_dependencies/starknet/utils/shortString.js +96 -0
- package/js/src/static_dependencies/starknet/utils/starknetId.d.ts +113 -0
- package/js/src/static_dependencies/starknet/utils/starknetId.js +265 -0
- package/js/src/static_dependencies/starknet/utils/typedData.d.ts +54 -0
- package/js/src/static_dependencies/starknet/utils/typedData.js +321 -0
- package/js/src/static_dependencies/starknet/utils/uint256.d.ts +21 -0
- package/js/src/static_dependencies/starknet/utils/uint256.js +32 -0
- package/js/src/static_dependencies/starknet/utils/url.d.ts +29 -0
- package/js/src/static_dependencies/starknet/utils/url.js +70 -0
- package/js/src/woo.js +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
var FunctionAbiType;
|
|
8
|
+
(function (FunctionAbiType) {
|
|
9
|
+
FunctionAbiType[FunctionAbiType["function"] = 0] = "function";
|
|
10
|
+
FunctionAbiType[FunctionAbiType["l1_handler"] = 1] = "l1_handler";
|
|
11
|
+
FunctionAbiType[FunctionAbiType["constructor"] = 2] = "constructor";
|
|
12
|
+
})(FunctionAbiType || (FunctionAbiType = {}));
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LegacyCompiledContract, LegacyContractClass } from './legacy.js';
|
|
2
|
+
import { CompiledSierra, SierraContractClass } from './sierra.js';
|
|
3
|
+
/**
|
|
4
|
+
* format produced after compressing compiled contract
|
|
5
|
+
*
|
|
6
|
+
* CompressedCompiledContract
|
|
7
|
+
*/
|
|
8
|
+
export declare type ContractClass = LegacyContractClass | SierraContractClass;
|
|
9
|
+
/**
|
|
10
|
+
* format produced after compile .cairo to .json
|
|
11
|
+
*/
|
|
12
|
+
export declare type CompiledContract = LegacyCompiledContract | CompiledSierra;
|
|
13
|
+
/**
|
|
14
|
+
* Compressed or decompressed Cairo0 or Cairo1 Contract
|
|
15
|
+
*/
|
|
16
|
+
export declare type CairoContract = ContractClass | CompiledContract;
|
|
17
|
+
export declare enum EntryPointType {
|
|
18
|
+
EXTERNAL = "EXTERNAL",
|
|
19
|
+
L1_HANDLER = "L1_HANDLER",
|
|
20
|
+
CONSTRUCTOR = "CONSTRUCTOR"
|
|
21
|
+
}
|
|
22
|
+
export * from './abi.js';
|
|
23
|
+
export * from './legacy.js';
|
|
24
|
+
export * from './sierra.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
// Basic elements
|
|
8
|
+
export var EntryPointType;
|
|
9
|
+
(function (EntryPointType) {
|
|
10
|
+
EntryPointType["EXTERNAL"] = "EXTERNAL";
|
|
11
|
+
EntryPointType["L1_HANDLER"] = "L1_HANDLER";
|
|
12
|
+
EntryPointType["CONSTRUCTOR"] = "CONSTRUCTOR";
|
|
13
|
+
})(EntryPointType || (EntryPointType = {}));
|
|
14
|
+
export * from './abi.js';
|
|
15
|
+
export * from './legacy.js';
|
|
16
|
+
export * from './sierra.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Abi } from './abi.js';
|
|
2
|
+
/** LEGACY CONTRACT */
|
|
3
|
+
/**
|
|
4
|
+
* format produced after compressing 'program' property
|
|
5
|
+
*/
|
|
6
|
+
export declare type LegacyContractClass = {
|
|
7
|
+
program: CompressedProgram;
|
|
8
|
+
entry_points_by_type: EntryPointsByType;
|
|
9
|
+
abi: Abi;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* format produced after compiling .cairo to .json
|
|
13
|
+
*/
|
|
14
|
+
export declare type LegacyCompiledContract = Omit<LegacyContractClass, 'program'> & {
|
|
15
|
+
program: Program;
|
|
16
|
+
};
|
|
17
|
+
/** SUBTYPES */
|
|
18
|
+
export declare type Builtins = string[];
|
|
19
|
+
export declare type CompressedProgram = string;
|
|
20
|
+
export declare type EntryPointsByType = {
|
|
21
|
+
CONSTRUCTOR: ContractEntryPointFields[];
|
|
22
|
+
EXTERNAL: ContractEntryPointFields[];
|
|
23
|
+
L1_HANDLER: ContractEntryPointFields[];
|
|
24
|
+
};
|
|
25
|
+
export declare type ContractEntryPointFields = {
|
|
26
|
+
selector: string;
|
|
27
|
+
offset: string | number;
|
|
28
|
+
builtins?: Builtins;
|
|
29
|
+
};
|
|
30
|
+
export interface Program extends Record<string, any> {
|
|
31
|
+
builtins: string[];
|
|
32
|
+
data: string[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Abi } from './abi.js';
|
|
2
|
+
import { EntryPointsByType } from './legacy.js';
|
|
3
|
+
/** SYSTEM TYPES */
|
|
4
|
+
export declare type CairoAssembly = {
|
|
5
|
+
prime: string;
|
|
6
|
+
compiler_version: string;
|
|
7
|
+
bytecode: ByteCode;
|
|
8
|
+
hints: any[];
|
|
9
|
+
pythonic_hints?: PythonicHints;
|
|
10
|
+
bytecode_segment_lengths?: number[];
|
|
11
|
+
entry_points_by_type: EntryPointsByType;
|
|
12
|
+
};
|
|
13
|
+
/** COMPILED CONTRACT */
|
|
14
|
+
/**
|
|
15
|
+
* format produced after starknet-compile .cairo to .json
|
|
16
|
+
*
|
|
17
|
+
* sierra_program is hex array
|
|
18
|
+
*/
|
|
19
|
+
export declare type CompiledSierra = {
|
|
20
|
+
sierra_program: ByteCode;
|
|
21
|
+
sierra_program_debug_info?: SierraProgramDebugInfo;
|
|
22
|
+
contract_class_version: string;
|
|
23
|
+
entry_points_by_type: SierraEntryPointsByType;
|
|
24
|
+
abi: Abi;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* format produced after compressing 'sierra_program', stringifies 'abi' property and omit sierra_program_debug_info
|
|
28
|
+
*
|
|
29
|
+
* CompressedCompiledSierra
|
|
30
|
+
*/
|
|
31
|
+
export declare type SierraContractClass = Omit<CompiledSierra, 'abi' | 'sierra_program_debug_info'> & {
|
|
32
|
+
sierra_program: string;
|
|
33
|
+
abi: string;
|
|
34
|
+
};
|
|
35
|
+
export declare type CompiledSierraCasm = CairoAssembly;
|
|
36
|
+
/** SUBTYPES */
|
|
37
|
+
export declare type ByteCode = string[];
|
|
38
|
+
export declare type PythonicHints = [number, string[]][];
|
|
39
|
+
export declare type SierraProgramDebugInfo = {
|
|
40
|
+
type_names: [number, string][];
|
|
41
|
+
libfunc_names: [number, string][];
|
|
42
|
+
user_func_names: [number, string][];
|
|
43
|
+
};
|
|
44
|
+
export declare type SierraEntryPointsByType = {
|
|
45
|
+
CONSTRUCTOR: SierraContractEntryPointFields[];
|
|
46
|
+
EXTERNAL: SierraContractEntryPointFields[];
|
|
47
|
+
L1_HANDLER: SierraContractEntryPointFields[];
|
|
48
|
+
};
|
|
49
|
+
export declare type SierraContractEntryPointFields = {
|
|
50
|
+
selector: string;
|
|
51
|
+
function_idx: number;
|
|
52
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { StarknetChainId } from '../../constants.js';
|
|
2
|
+
import { SignatureType } from '../../../noble-curves/abstract/weierstrass.js';
|
|
3
|
+
import { CairoEnum } from '../cairoEnum.js';
|
|
4
|
+
import { CompiledContract, CompiledSierraCasm, ContractClass } from './contract/index.js';
|
|
5
|
+
export declare type WeierstrassSignatureType = SignatureType;
|
|
6
|
+
export declare type ArraySignatureType = string[];
|
|
7
|
+
export declare type Signature = ArraySignatureType | WeierstrassSignatureType;
|
|
8
|
+
export declare type BigNumberish = string | number | bigint;
|
|
9
|
+
export declare type ByteArray = {
|
|
10
|
+
data: BigNumberish[];
|
|
11
|
+
pending_word: BigNumberish;
|
|
12
|
+
pending_word_len: BigNumberish;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Compiled calldata ready to be sent
|
|
16
|
+
*
|
|
17
|
+
* decimal-string array
|
|
18
|
+
*/
|
|
19
|
+
export declare type Calldata = string[] & {
|
|
20
|
+
readonly __compiled__?: true;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Represents an integer in the range [0, 2^256)
|
|
24
|
+
*/
|
|
25
|
+
export interface Uint256 {
|
|
26
|
+
low: BigNumberish;
|
|
27
|
+
high: BigNumberish;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents an integer in the range [0, 2^256)
|
|
31
|
+
*/
|
|
32
|
+
export interface Uint512 {
|
|
33
|
+
limb0: BigNumberish;
|
|
34
|
+
limb1: BigNumberish;
|
|
35
|
+
limb2: BigNumberish;
|
|
36
|
+
limb3: BigNumberish;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* BigNumberish array
|
|
40
|
+
*
|
|
41
|
+
* use CallData.compile() to convert to Calldata
|
|
42
|
+
*/
|
|
43
|
+
export declare type RawCalldata = BigNumberish[];
|
|
44
|
+
/**
|
|
45
|
+
* Hexadecimal-string array
|
|
46
|
+
*/
|
|
47
|
+
export declare type HexCalldata = string[];
|
|
48
|
+
export declare type AllowArray<T> = T | T[];
|
|
49
|
+
export declare type OptionalPayload<T> = {
|
|
50
|
+
payload: T;
|
|
51
|
+
} | T;
|
|
52
|
+
export declare type RawArgs = RawArgsObject | RawArgsArray;
|
|
53
|
+
export declare type RawArgsObject = {
|
|
54
|
+
[inputName: string]: MultiType | MultiType[] | RawArgs;
|
|
55
|
+
};
|
|
56
|
+
export declare type RawArgsArray = Array<MultiType | MultiType[] | RawArgs>;
|
|
57
|
+
export declare type MultiType = BigNumberish | Uint256 | object | boolean | CairoEnum;
|
|
58
|
+
export declare type UniversalDeployerContractPayload = {
|
|
59
|
+
classHash: BigNumberish;
|
|
60
|
+
salt?: string;
|
|
61
|
+
unique?: boolean;
|
|
62
|
+
constructorCalldata?: RawArgs;
|
|
63
|
+
};
|
|
64
|
+
export declare type DeployAccountContractPayload = {
|
|
65
|
+
classHash: string;
|
|
66
|
+
constructorCalldata?: RawArgs;
|
|
67
|
+
addressSalt?: BigNumberish;
|
|
68
|
+
contractAddress?: string;
|
|
69
|
+
};
|
|
70
|
+
export declare type DeployAccountContractTransaction = Omit<DeployAccountContractPayload, 'contractAddress'> & {
|
|
71
|
+
signature?: Signature;
|
|
72
|
+
};
|
|
73
|
+
export declare type DeclareContractPayload = {
|
|
74
|
+
contract: CompiledContract | string;
|
|
75
|
+
classHash?: string;
|
|
76
|
+
casm?: CompiledSierraCasm;
|
|
77
|
+
compiledClassHash?: string;
|
|
78
|
+
};
|
|
79
|
+
export declare type CompleteDeclareContractPayload = {
|
|
80
|
+
contract: CompiledContract | string;
|
|
81
|
+
classHash: string;
|
|
82
|
+
casm?: CompiledSierraCasm;
|
|
83
|
+
compiledClassHash?: string;
|
|
84
|
+
};
|
|
85
|
+
export declare type DeclareAndDeployContractPayload = Omit<UniversalDeployerContractPayload, 'classHash'> & DeclareContractPayload;
|
|
86
|
+
export declare type DeclareContractTransaction = {
|
|
87
|
+
contract: ContractClass;
|
|
88
|
+
senderAddress: string;
|
|
89
|
+
signature?: Signature;
|
|
90
|
+
compiledClassHash?: string;
|
|
91
|
+
};
|
|
92
|
+
export declare type CallDetails = {
|
|
93
|
+
contractAddress: string;
|
|
94
|
+
calldata?: RawArgs | Calldata;
|
|
95
|
+
entrypoint?: string;
|
|
96
|
+
};
|
|
97
|
+
export declare type Invocation = CallDetails & {
|
|
98
|
+
signature?: Signature;
|
|
99
|
+
};
|
|
100
|
+
export declare type Call = CallDetails & {
|
|
101
|
+
entrypoint: string;
|
|
102
|
+
};
|
|
103
|
+
export declare type CairoVersion = '0' | '1' | undefined;
|
|
104
|
+
export declare type CompilerVersion = '0' | '1' | '2' | undefined;
|
|
105
|
+
export declare type InvocationsDetails = {
|
|
106
|
+
nonce?: BigNumberish;
|
|
107
|
+
maxFee?: BigNumberish;
|
|
108
|
+
version?: BigNumberish;
|
|
109
|
+
} & Partial<V3TransactionDetails>;
|
|
110
|
+
export declare type V3TransactionDetails = {
|
|
111
|
+
nonce: BigNumberish;
|
|
112
|
+
version: BigNumberish;
|
|
113
|
+
tip: BigNumberish;
|
|
114
|
+
paymasterData: BigNumberish[];
|
|
115
|
+
accountDeploymentData: BigNumberish[];
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Contain all additional details params
|
|
119
|
+
*/
|
|
120
|
+
export declare type Details = {
|
|
121
|
+
nonce: BigNumberish;
|
|
122
|
+
maxFee: BigNumberish;
|
|
123
|
+
version: BigNumberish;
|
|
124
|
+
chainId: StarknetChainId;
|
|
125
|
+
};
|
|
126
|
+
export declare type InvocationsDetailsWithNonce = (InvocationsDetails & {
|
|
127
|
+
nonce: BigNumberish;
|
|
128
|
+
}) | V3TransactionDetails;
|
|
129
|
+
export declare enum TransactionType {
|
|
130
|
+
DECLARE = "DECLARE",
|
|
131
|
+
DEPLOY = "DEPLOY",
|
|
132
|
+
DEPLOY_ACCOUNT = "DEPLOY_ACCOUNT",
|
|
133
|
+
INVOKE = "INVOKE_FUNCTION"
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* new statuses are defined by props: finality_status and execution_status
|
|
137
|
+
* to be #deprecated
|
|
138
|
+
*/
|
|
139
|
+
export declare enum TransactionStatus {
|
|
140
|
+
NOT_RECEIVED = "NOT_RECEIVED",
|
|
141
|
+
RECEIVED = "RECEIVED",
|
|
142
|
+
ACCEPTED_ON_L2 = "ACCEPTED_ON_L2",
|
|
143
|
+
ACCEPTED_ON_L1 = "ACCEPTED_ON_L1",
|
|
144
|
+
REJECTED = "REJECTED",
|
|
145
|
+
REVERTED = "REVERTED"
|
|
146
|
+
}
|
|
147
|
+
export declare enum TransactionFinalityStatus {
|
|
148
|
+
NOT_RECEIVED = "NOT_RECEIVED",
|
|
149
|
+
RECEIVED = "RECEIVED",
|
|
150
|
+
ACCEPTED_ON_L2 = "ACCEPTED_ON_L2",
|
|
151
|
+
ACCEPTED_ON_L1 = "ACCEPTED_ON_L1"
|
|
152
|
+
}
|
|
153
|
+
export declare enum TransactionExecutionStatus {
|
|
154
|
+
REJECTED = "REJECTED",
|
|
155
|
+
REVERTED = "REVERTED",
|
|
156
|
+
SUCCEEDED = "SUCCEEDED"
|
|
157
|
+
}
|
|
158
|
+
export declare enum BlockStatus {
|
|
159
|
+
PENDING = "PENDING",
|
|
160
|
+
ACCEPTED_ON_L1 = "ACCEPTED_ON_L1",
|
|
161
|
+
ACCEPTED_ON_L2 = "ACCEPTED_ON_L2",
|
|
162
|
+
REJECTED = "REJECTED"
|
|
163
|
+
}
|
|
164
|
+
export declare enum BlockTag {
|
|
165
|
+
pending = "pending",
|
|
166
|
+
latest = "latest"
|
|
167
|
+
}
|
|
168
|
+
export declare type BlockNumber = BlockTag | null | number;
|
|
169
|
+
/**
|
|
170
|
+
* hex string and BigInt are detected as block hashes
|
|
171
|
+
*
|
|
172
|
+
* decimal string and number are detected as block numbers
|
|
173
|
+
*
|
|
174
|
+
* text string are detected as block tag
|
|
175
|
+
*
|
|
176
|
+
* null return 'pending' block tag
|
|
177
|
+
*/
|
|
178
|
+
export declare type BlockIdentifier = BlockNumber | BigNumberish;
|
|
179
|
+
/**
|
|
180
|
+
* items used by AccountInvocations
|
|
181
|
+
*/
|
|
182
|
+
export declare type AccountInvocationItem = (({
|
|
183
|
+
type: TransactionType.DECLARE;
|
|
184
|
+
} & DeclareContractTransaction) | ({
|
|
185
|
+
type: TransactionType.DEPLOY_ACCOUNT;
|
|
186
|
+
} & DeployAccountContractTransaction) | ({
|
|
187
|
+
type: TransactionType.INVOKE;
|
|
188
|
+
} & Invocation)) & InvocationsDetailsWithNonce;
|
|
189
|
+
/**
|
|
190
|
+
* Complete invocations array with account details (internal type from account -> provider)
|
|
191
|
+
*/
|
|
192
|
+
export declare type AccountInvocations = AccountInvocationItem[];
|
|
193
|
+
/**
|
|
194
|
+
* Invocations array user provide to bulk method (simulate)
|
|
195
|
+
*/
|
|
196
|
+
export declare type Invocations = Array<({
|
|
197
|
+
type: TransactionType.DECLARE;
|
|
198
|
+
} & OptionalPayload<DeclareContractPayload>) | ({
|
|
199
|
+
type: TransactionType.DEPLOY;
|
|
200
|
+
} & OptionalPayload<AllowArray<UniversalDeployerContractPayload>>) | ({
|
|
201
|
+
type: TransactionType.DEPLOY_ACCOUNT;
|
|
202
|
+
} & OptionalPayload<DeployAccountContractPayload>) | ({
|
|
203
|
+
type: TransactionType.INVOKE;
|
|
204
|
+
} & OptionalPayload<AllowArray<Call>>)>;
|
|
205
|
+
export declare type Tupled = {
|
|
206
|
+
element: any;
|
|
207
|
+
type: string;
|
|
208
|
+
};
|
|
209
|
+
export declare type Args = {
|
|
210
|
+
[inputName: string]: BigNumberish | BigNumberish[] | ParsedStruct | ParsedStruct[];
|
|
211
|
+
};
|
|
212
|
+
export declare type ParsedStruct = {
|
|
213
|
+
[key: string]: BigNumberish | BigNumberish[] | ParsedStruct | Uint256;
|
|
214
|
+
};
|
|
215
|
+
export declare type waitForTransactionOptions = {
|
|
216
|
+
retryInterval?: number;
|
|
217
|
+
successStates?: Array<TransactionFinalityStatus | TransactionExecutionStatus>;
|
|
218
|
+
errorStates?: Array<TransactionFinalityStatus | TransactionExecutionStatus>;
|
|
219
|
+
};
|
|
220
|
+
export declare type getSimulateTransactionOptions = {
|
|
221
|
+
blockIdentifier?: BlockIdentifier;
|
|
222
|
+
skipValidate?: boolean;
|
|
223
|
+
skipExecute?: boolean;
|
|
224
|
+
skipFeeCharge?: boolean;
|
|
225
|
+
};
|
|
226
|
+
export declare type getContractVersionOptions = {
|
|
227
|
+
blockIdentifier?: BlockIdentifier;
|
|
228
|
+
compiler?: boolean;
|
|
229
|
+
};
|
|
230
|
+
export declare type getEstimateFeeBulkOptions = {
|
|
231
|
+
blockIdentifier?: BlockIdentifier;
|
|
232
|
+
skipValidate?: boolean;
|
|
233
|
+
};
|
|
234
|
+
export interface CallStruct {
|
|
235
|
+
to: string;
|
|
236
|
+
selector: string;
|
|
237
|
+
calldata: string[];
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Represent Contract version
|
|
241
|
+
*/
|
|
242
|
+
export declare type ContractVersion = {
|
|
243
|
+
/** version of the cairo language */
|
|
244
|
+
cairo: CairoVersion;
|
|
245
|
+
/** version of the cairo compiler used to compile the contract */
|
|
246
|
+
compiler: CompilerVersion;
|
|
247
|
+
};
|
|
248
|
+
export * from './contract/index.js';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
export var TransactionType;
|
|
8
|
+
(function (TransactionType) {
|
|
9
|
+
TransactionType["DECLARE"] = "DECLARE";
|
|
10
|
+
TransactionType["DEPLOY"] = "DEPLOY";
|
|
11
|
+
TransactionType["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
|
|
12
|
+
TransactionType["INVOKE"] = "INVOKE_FUNCTION";
|
|
13
|
+
})(TransactionType || (TransactionType = {}));
|
|
14
|
+
/**
|
|
15
|
+
* new statuses are defined by props: finality_status and execution_status
|
|
16
|
+
* to be #deprecated
|
|
17
|
+
*/
|
|
18
|
+
export var TransactionStatus;
|
|
19
|
+
(function (TransactionStatus) {
|
|
20
|
+
TransactionStatus["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
21
|
+
TransactionStatus["RECEIVED"] = "RECEIVED";
|
|
22
|
+
TransactionStatus["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
23
|
+
TransactionStatus["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
24
|
+
TransactionStatus["REJECTED"] = "REJECTED";
|
|
25
|
+
TransactionStatus["REVERTED"] = "REVERTED";
|
|
26
|
+
})(TransactionStatus || (TransactionStatus = {}));
|
|
27
|
+
export var TransactionFinalityStatus;
|
|
28
|
+
(function (TransactionFinalityStatus) {
|
|
29
|
+
TransactionFinalityStatus["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
30
|
+
TransactionFinalityStatus["RECEIVED"] = "RECEIVED";
|
|
31
|
+
TransactionFinalityStatus["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
32
|
+
TransactionFinalityStatus["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
33
|
+
})(TransactionFinalityStatus || (TransactionFinalityStatus = {}));
|
|
34
|
+
export var TransactionExecutionStatus;
|
|
35
|
+
(function (TransactionExecutionStatus) {
|
|
36
|
+
TransactionExecutionStatus["REJECTED"] = "REJECTED";
|
|
37
|
+
TransactionExecutionStatus["REVERTED"] = "REVERTED";
|
|
38
|
+
TransactionExecutionStatus["SUCCEEDED"] = "SUCCEEDED";
|
|
39
|
+
})(TransactionExecutionStatus || (TransactionExecutionStatus = {}));
|
|
40
|
+
export var BlockStatus;
|
|
41
|
+
(function (BlockStatus) {
|
|
42
|
+
BlockStatus["PENDING"] = "PENDING";
|
|
43
|
+
BlockStatus["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
44
|
+
BlockStatus["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
45
|
+
BlockStatus["REJECTED"] = "REJECTED";
|
|
46
|
+
})(BlockStatus || (BlockStatus = {}));
|
|
47
|
+
export var BlockTag;
|
|
48
|
+
(function (BlockTag) {
|
|
49
|
+
BlockTag["pending"] = "pending";
|
|
50
|
+
BlockTag["latest"] = "latest";
|
|
51
|
+
})(BlockTag || (BlockTag = {}));
|
|
52
|
+
export * from './contract/index.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const TypedDataRevision: {
|
|
2
|
+
readonly Active: "1";
|
|
3
|
+
readonly Legacy: "0";
|
|
4
|
+
};
|
|
5
|
+
export declare type TypedDataRevision = (typeof TypedDataRevision)[keyof typeof TypedDataRevision];
|
|
6
|
+
export declare type StarknetEnumType = {
|
|
7
|
+
name: string;
|
|
8
|
+
type: 'enum';
|
|
9
|
+
contains: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type StarknetMerkleType = {
|
|
12
|
+
name: string;
|
|
13
|
+
type: 'merkletree';
|
|
14
|
+
contains: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* SPEC: STARKNET_TYPE
|
|
18
|
+
* A single type, as part of a struct. The `type` field can be any of the EIP-712 supported types.
|
|
19
|
+
* Note that the `uint` and `int` aliases like in Solidity, and fixed point numbers are not supported by the EIP-712
|
|
20
|
+
* standard.
|
|
21
|
+
*/
|
|
22
|
+
export declare type StarknetType = {
|
|
23
|
+
name: string;
|
|
24
|
+
type: string;
|
|
25
|
+
} | StarknetEnumType | StarknetMerkleType;
|
|
26
|
+
/**
|
|
27
|
+
* The EIP712 domain struct. Any of these fields are optional, but it must contain at least one field.
|
|
28
|
+
*/
|
|
29
|
+
export interface StarknetDomain extends Record<string, unknown> {
|
|
30
|
+
name?: string;
|
|
31
|
+
version?: string;
|
|
32
|
+
chainId?: string | number;
|
|
33
|
+
revision?: string | number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* SPEC: TYPED_DATA
|
|
37
|
+
* The complete typed data, with all the structs, domain data, primary type of the message, and the message itself.
|
|
38
|
+
*/
|
|
39
|
+
export interface TypedData {
|
|
40
|
+
types: Record<string, StarknetType[]>;
|
|
41
|
+
primaryType: string;
|
|
42
|
+
domain: StarknetDomain;
|
|
43
|
+
message: object;
|
|
44
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
// Reexport types from package
|
|
8
|
+
// export {
|
|
9
|
+
// TypedDataRevision,
|
|
10
|
+
// type StarknetEnumType,
|
|
11
|
+
// type StarknetMerkleType,
|
|
12
|
+
// type StarknetType,
|
|
13
|
+
// type StarknetDomain,
|
|
14
|
+
// type TypedData,
|
|
15
|
+
// } from 'starknet-types-07';
|
|
16
|
+
export const TypedDataRevision = {
|
|
17
|
+
Active: '1',
|
|
18
|
+
Legacy: '0',
|
|
19
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BigNumberish } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Format a hex number to '0x' and 64 characters, adding leading zeros if necessary.
|
|
4
|
+
* @param {BigNumberish} address
|
|
5
|
+
* @returns {string} Hex string : 0x followed by 64 characters. No upper case characters in the response.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const address = "0x90591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf";
|
|
9
|
+
* const result = addAddressPadding(address);
|
|
10
|
+
* // result = "0x0000090591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf"
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function addAddressPadding(address: BigNumberish): string;
|
|
14
|
+
/**
|
|
15
|
+
* Check the validity of a Starknet address, and format it as a hex number : '0x' and 64 characters, adding leading zeros if necessary.
|
|
16
|
+
* @param {BigNumberish} address
|
|
17
|
+
* @returns {string} Hex string : 0x followed by 64 characters. No upper case characters in the response.
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const address = "0x90591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf";
|
|
21
|
+
* const result = validateAndParseAddress(address);
|
|
22
|
+
* // result = "0x0000090591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf"
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateAndParseAddress(address: BigNumberish): string;
|
|
26
|
+
/**
|
|
27
|
+
* Convert an address to her checksum representation which uses a specific pattern of uppercase and lowercase letters within
|
|
28
|
+
* a given address to reduce the risk of errors introduced from typing an address or cut and paste issues.
|
|
29
|
+
* @param {BigNumberish} address
|
|
30
|
+
* @returns {string} Hex string : 0x followed by 64 characters. Mix of uppercase and lowercase
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const address = "0x90591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf";
|
|
34
|
+
* const result = getChecksumAddress(address);
|
|
35
|
+
* // result = "0x0000090591D9fA3EfC87067d95a643f8455E0b8190eb8Cb7bFd39e4fb7571fDF"
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function getChecksumAddress(address: BigNumberish): string;
|
|
39
|
+
/**
|
|
40
|
+
* If the casing of an address is mixed, it is a Checksum Address, which uses a specific pattern of uppercase and lowercase letters within
|
|
41
|
+
* a given address to reduce the risk of errors introduced from typing an address or cut and paste issues.
|
|
42
|
+
*
|
|
43
|
+
* @param address string
|
|
44
|
+
*
|
|
45
|
+
* @returns true if the ChecksumAddress is valid
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const address = "0x0000090591D9fA3EfC87067d95a643f8455E0b8190eb8Cb7bFd39e4fb7571fDF";
|
|
49
|
+
* const result = validateChecksumAddress(address);
|
|
50
|
+
* // result = true
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function validateChecksumAddress(address: string): boolean;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
/* eslint-disable no-bitwise */
|
|
8
|
+
import { hexToBytes } from '../../noble-curves/abstract/utils';
|
|
9
|
+
import { ADDR_BOUND, ZERO } from '../constants.js';
|
|
10
|
+
import { addHexPrefix, removeHexPrefix } from './encode.js';
|
|
11
|
+
import { keccakBn } from './hash/index.js';
|
|
12
|
+
import { assertInRange, toHex } from './num.js';
|
|
13
|
+
/**
|
|
14
|
+
* Format a hex number to '0x' and 64 characters, adding leading zeros if necessary.
|
|
15
|
+
* @param {BigNumberish} address
|
|
16
|
+
* @returns {string} Hex string : 0x followed by 64 characters. No upper case characters in the response.
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const address = "0x90591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf";
|
|
20
|
+
* const result = addAddressPadding(address);
|
|
21
|
+
* // result = "0x0000090591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf"
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function addAddressPadding(address) {
|
|
25
|
+
return addHexPrefix(removeHexPrefix(toHex(address)).padStart(64, '0'));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check the validity of a Starknet address, and format it as a hex number : '0x' and 64 characters, adding leading zeros if necessary.
|
|
29
|
+
* @param {BigNumberish} address
|
|
30
|
+
* @returns {string} Hex string : 0x followed by 64 characters. No upper case characters in the response.
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const address = "0x90591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf";
|
|
34
|
+
* const result = validateAndParseAddress(address);
|
|
35
|
+
* // result = "0x0000090591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf"
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function validateAndParseAddress(address) {
|
|
39
|
+
assertInRange(address, ZERO, ADDR_BOUND - 1n, 'Starknet Address');
|
|
40
|
+
const result = addAddressPadding(address);
|
|
41
|
+
if (!result.match(/^(0x)?[0-9a-fA-F]{64}$/)) {
|
|
42
|
+
throw new Error('Invalid Address Format');
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Convert an address to her checksum representation which uses a specific pattern of uppercase and lowercase letters within
|
|
48
|
+
* a given address to reduce the risk of errors introduced from typing an address or cut and paste issues.
|
|
49
|
+
* @param {BigNumberish} address
|
|
50
|
+
* @returns {string} Hex string : 0x followed by 64 characters. Mix of uppercase and lowercase
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const address = "0x90591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf";
|
|
54
|
+
* const result = getChecksumAddress(address);
|
|
55
|
+
* // result = "0x0000090591D9fA3EfC87067d95a643f8455E0b8190eb8Cb7bFd39e4fb7571fDF"
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
// from https://github.com/ethers-io/ethers.js/blob/fc1e006575d59792fa97b4efb9ea2f8cca1944cf/packages/address/src.ts/index.ts#L12
|
|
59
|
+
export function getChecksumAddress(address) {
|
|
60
|
+
const chars = removeHexPrefix(validateAndParseAddress(address)).toLowerCase().split('');
|
|
61
|
+
const hex = removeHexPrefix(keccakBn(address));
|
|
62
|
+
const hashed = hexToBytes(hex.padStart(64, '0'));
|
|
63
|
+
for (let i = 0; i < chars.length; i += 2) {
|
|
64
|
+
if (hashed[i >> 1] >> 4 >= 8) {
|
|
65
|
+
chars[i] = chars[i].toUpperCase();
|
|
66
|
+
}
|
|
67
|
+
if ((hashed[i >> 1] & 0x0f) >= 8) {
|
|
68
|
+
chars[i + 1] = chars[i + 1].toUpperCase();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return addHexPrefix(chars.join(''));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* If the casing of an address is mixed, it is a Checksum Address, which uses a specific pattern of uppercase and lowercase letters within
|
|
75
|
+
* a given address to reduce the risk of errors introduced from typing an address or cut and paste issues.
|
|
76
|
+
*
|
|
77
|
+
* @param address string
|
|
78
|
+
*
|
|
79
|
+
* @returns true if the ChecksumAddress is valid
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const address = "0x0000090591D9fA3EfC87067d95a643f8455E0b8190eb8Cb7bFd39e4fb7571fDF";
|
|
83
|
+
* const result = validateChecksumAddress(address);
|
|
84
|
+
* // result = true
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function validateChecksumAddress(address) {
|
|
88
|
+
return getChecksumAddress(address) === address;
|
|
89
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asserts that the given condition is true, otherwise throws an error with an optional message.
|
|
3
|
+
* @param {any} condition - The condition to check.
|
|
4
|
+
* @param {string} [message] - The optional message to include in the error.
|
|
5
|
+
* @throws {Error} Throws an error if the condition is false.
|
|
6
|
+
*/
|
|
7
|
+
export default function assert(condition: boolean, message?: string): asserts condition;
|