@0xknwn/starknet-test-helpers / Exports
@0xknwn/starknet-test-helpers
Table of contents
Classes
Type Aliases
Variables
Functions
- ETH
- STRK
- accountAddress
- classHash
- config
- counterAddress
- declareClass
- deployAccount
- deployCounter
- deploySimpleAccount
- deploySwapRouter
- deployTokenA
- deployTokenB
- simpleAccountAddress
- swapRouterAddress
- testAccounts
- tokenAAddress
- tokenBAddress
Type Aliases
AccountConfig
Ƭ AccountConfig: Object
Represents the configuration of an account.
Type declaration
Name | Type |
---|---|
address | string |
classHash? | string |
privateKey | string |
publicKey | string |
Defined in
sdks/tests/helpers/src/utils.ts:7
Config
Ƭ Config: Object
Represents the configuration for the test helpers.
Type declaration
Name | Type |
---|---|
accounts | AccountConfig [] |
providerURL | string |
Defined in
sdks/tests/helpers/src/utils.ts:21
Variables
CounterABI
• Const
CounterABI: readonly [{ interface_name
: "smartr::helpers::counter::ICounter"
= "smartr::helpers::counter::ICounter"; name
: "CounterImpl"
= "CounterImpl"; type
: "impl"
= "impl" }, { items
: readonly [{ inputs
: readonly [] = []; name
: "increment"
= "increment"; outputs
: readonly [] = []; state_mutability
: "external"
= "external"; type
: "function"
= "function" }, { inputs
: readonly [{ name
: "args"
= "args"; type
: "core::array::Array::<core::felt252>"
= "core::array::Array::<core::felt252>" }] ; name
: "increment_by_array"
= "increment_by_array"; outputs
: readonly [] = []; state_mutability
: "external"
= "external"; type
: "function"
= "function" }, { inputs
: readonly [{ name
: "value"
= "value"; type
: "core::integer::u64"
= "core::integer::u64" }] ; name
: "increment_by"
= "increment_by"; outputs
: readonly [] = []; state_mutability
: "external"
= "external"; type
: "function"
= "function" }, { inputs
: readonly [] = []; name
: "get"
= "get"; outputs
: readonly [{ type
: "core::integer::u64"
= "core::integer::u64" }] ; state_mutability
: "view"
= "view"; type
: "function"
= "function" }, { inputs
: readonly [] = []; name
: "reset"
= "reset"; outputs
: readonly [] = []; state_mutability
: "external"
= "external"; type
: "function"
= "function" }] ; name
: "smartr::helpers::counter::ICounter"
= "smartr::helpers::counter::ICounter"; type
: "interface"
= "interface" }, { interface_name
: "openzeppelin::upgrades::interface::IUpgradeable"
= "openzeppelin::upgrades::interface::IUpgradeable"; name
: "UpgradeableImpl"
= "UpgradeableImpl"; type
: "impl"
= "impl" }, { items
: readonly [{ inputs
: readonly [{ name
: "new_class_hash"
= "new_class_hash"; type
: "core::starknet::class_hash::ClassHash"
= "core::starknet::class_hash::ClassHash" }] ; name
: "upgrade"
= "upgrade"; outputs
: readonly [] = []; state_mutability
: "external"
= "external"; type
: "function"
= "function" }] ; name
: "openzeppelin::upgrades::interface::IUpgradeable"
= "openzeppelin::upgrades::interface::IUpgradeable"; type
: "interface"
= "interface" }, { interface_name
: "openzeppelin::access::ownable::interface::IOwnable"
= "openzeppelin::access::ownable::interface::IOwnable"; name
: "OwnableImpl"
= "OwnableImpl"; type
: "impl"
= "impl" }, { items
: readonly [{ inputs
: readonly [] = []; name
: "owner"
= "owner"; outputs
: readonly [{ type
: "core::starknet::contract_address::ContractAddress"
= "core::starknet::contract_address::ContractAddress" }] ; state_mutability
: "view"
= "view"; type
: "function"
= "function" }, { inputs
: readonly [{ name
: "new_owner"
= "new_owner"; type
: "core::starknet::contract_address::ContractAddress"
= "core::starknet::contract_address::ContractAddress" }] ; name
: "transfer_ownership"
= "transfer_ownership"; outputs
: readonly [] = []; state_mutability
: "external"
= "external"; type
: "function"
= "function" }, { inputs
: readonly [] = []; name
: "renounce_ownership"
= "renounce_ownership"; outputs
: readonly [] = []; state_mutability
: "external"
= "external"; type
: "function"
= "function" }] ; name
: "openzeppelin::access::ownable::interface::IOwnable"
= "openzeppelin::access::ownable::interface::IOwnable"; type
: "interface"
= "interface" }, { inputs
: readonly [{ name
: "owner"
= "owner"; type
: "core::starknet::contract_address::ContractAddress"
= "core::starknet::contract_address::ContractAddress" }] ; name
: "constructor"
= "constructor"; type
: "constructor"
= "constructor" }, { kind
: "struct"
= "struct"; members
: readonly [{ kind
: "key"
= "key"; name
: "previous_owner"
= "previous_owner"; type
: "core::starknet::contract_address::ContractAddress"
= "core::starknet::contract_address::ContractAddress" }, { kind
: "key"
= "key"; name
: "new_owner"
= "new_owner"; type
: "core::starknet::contract_address::ContractAddress"
= "core::starknet::contract_address::ContractAddress" }] ; name
: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred"
= "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred"; type
: "event"
= "event" }, { kind
: "struct"
= "struct"; members
: readonly [{ kind
: "key"
= "key"; name
: "previous_owner"
= "previous_owner"; type
: "core::starknet::contract_address::ContractAddress"
= "core::starknet::contract_address::ContractAddress" }, { kind
: "key"
= "key"; name
: "new_owner"
= "new_owner"; type
: "core::starknet::contract_address::ContractAddress"
= "core::starknet::contract_address::ContractAddress" }] ; name
: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted"
= "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted"; type
: "event"
= "event" }, { kind
: "enum"
= "enum"; name
: "openzeppelin::access::ownable::ownable::OwnableComponent::Event"
= "openzeppelin::access::ownable::ownable::OwnableComponent::Event"; type
: "event"
= "event"; variants
: readonly [{ kind
: "nested"
= "nested"; name
: "OwnershipTransferred"
= "OwnershipTransferred"; type
: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred"
= "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferred" }, { kind
: "nested"
= "nested"; name
: "OwnershipTransferStarted"
= "OwnershipTransferStarted"; type
: "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted"
= "openzeppelin::access::ownable::ownable::OwnableComponent::OwnershipTransferStarted" }] }, { kind
: "struct"
= "struct"; members
: readonly [{ kind
: "data"
= "data"; name
: "class_hash"
= "class_hash"; type
: "core::starknet::class_hash::ClassHash"
= "core::starknet::class_hash::ClassHash" }] ; name
: "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Upgraded"
= "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Upgraded"; type
: "event"
= "event" }, { kind
: "enum"
= "enum"; name
: "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Event"
= "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Event"; type
: "event"
= "event"; variants
: readonly [{ kind
: "nested"
= "nested"; name
: "Upgraded"
= "Upgraded"; type
: "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Upgraded"
= "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Upgraded" }] }, { kind
: "enum"
= "enum"; name
: "smartr::helpers::counter::Counter::Event"
= "smartr::helpers::counter::Counter::Event"; type
: "event"
= "event"; variants
: readonly [{ kind
: "flat"
= "flat"; name
: "OwnableEvent"
= "OwnableEvent"; type
: "openzeppelin::access::ownable::ownable::OwnableComponent::Event"
= "openzeppelin::access::ownable::ownable::OwnableComponent::Event" }, { kind
: "flat"
= "flat"; name
: "UpgradeableEvent"
= "UpgradeableEvent"; type
: "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Event"
= "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Event" }] }]
Defined in
sdks/tests/helpers/src/abi/Counter.ts:1
SimpleAccountABI
• Const
SimpleAccountABI: readonly [{ interface_name
: "smartr::helpers::simple_account::IDeployable"
= "smartr::helpers::simple_account::IDeployable"; name
: "DeployableImpl"
= "DeployableImpl"; type
: "impl"
= "impl" }, { items
: readonly [{ inputs
: readonly [{ name
: "class_hash"
= "class_hash"; type
: "core::felt252"
= "core::felt252" }, { name
: "contract_address_salt"
= "contract_address_salt"; type
: "core::felt252"
= "core::felt252" }, { name
: "public_key"
= "public_key"; type
: "core::felt252"
= "core::felt252" }, { name
: "more"
= "more"; type
: "core::felt252"
= "core::felt252" }] ; name
: "__validate_deploy__"
= "__validate_deploy__"; outputs
: readonly [{ type
: "core::felt252"
= "core::felt252" }] ; state_mutability
: "view"
= "view"; type
: "function"
= "function" }] ; name
: "smartr::helpers::simple_account::IDeployable"
= "smartr::helpers::simple_account::IDeployable"; type
: "interface"
= "interface" }, { interface_name
: "openzeppelin::upgrades::interface::IUpgradeable"
= "openzeppelin::upgrades::interface::IUpgradeable"; name
: "UpgradeableImpl"
= "UpgradeableImpl"; type
: "impl"
= "impl" }, { items
: readonly [{ inputs
: readonly [{ name
: "new_class_hash"
= "new_class_hash"; type
: "core::starknet::class_hash::ClassHash"
= "core::starknet::class_hash::ClassHash" }] ; name
: "upgrade"
= "upgrade"; outputs
: readonly [] = []; state_mutability
: "external"
= "external"; type
: "function"
= "function" }] ; name
: "openzeppelin::upgrades::interface::IUpgradeable"
= "openzeppelin::upgrades::interface::IUpgradeable"; type
: "interface"
= "interface" }, { interface_name
: "openzeppelin::account::interface::ISRC6"
= "openzeppelin::account::interface::ISRC6"; name
: "SRC6Impl"
= "SRC6Impl"; type
: "impl"
= "impl" }, { members
: readonly [{ name
: "snapshot"
= "snapshot"; type
: "@core::array::Array::<core::felt252>"
= "@core::array::Array::<core::felt252>" }] ; name
: "core::array::Span::<core::felt252>"
= "core::array::Span::<core::felt252>"; type
: "struct"
= "struct" }, { members
: readonly [{ name
: "to"
= "to"; type
: "core::starknet::contract_address::ContractAddress"
= "core::starknet::contract_address::ContractAddress" }, { name
: "selector"
= "selector"; type
: "core::felt252"
= "core::felt252" }, { name
: "calldata"
= "calldata"; type
: "core::array::Span::<core::felt252>"
= "core::array::Span::<core::felt252>" }] ; name
: "core::starknet::account::Call"
= "core::starknet::account::Call"; type
: "struct"
= "struct" }, { items
: readonly [{ inputs
: readonly [{ name
: "calls"
= "calls"; type
: "core::array::Array::<core::starknet::account::Call>"
= "core::array::Array::<core::starknet::account::Call>" }] ; name
: "__execute__"
= "__execute__"; outputs
: readonly [{ type
: "core::array::Array::<core::array::Span::<core::felt252>>"
= "core::array::Array::<core::array::Span::<core::felt252>>" }] ; state_mutability
: "view"
= "view"; type
: "function"
= "function" }, { inputs
: readonly [{ name
: "calls"
= "calls"; type
: "core::array::Array::<core::starknet::account::Call>"
= "core::array::Array::<core::starknet::account::Call>" }] ; name
: "__validate__"
= "__validate__"; outputs
: readonly [{ type
: "core::felt252"
= "core::felt252" }] ; state_mutability
: "view"
= "view"; type
: "function"
= "function" }, { inputs
: readonly [{ name
: "hash"
= "hash"; type
: "core::felt252"
= "core::felt252" }, { name
: "signature"
= "signature"; type
: "core::array::Array::<core::felt252>"
= "core::array::Array::<core::felt252>" }] ; name
: "is_valid_signature"
= "is_valid_signature"; outputs
: readonly [{ type
: "core::felt252"
= "core::felt252" }] ; state_mutability
: "view"
= "view"; type
: "function"
= "function" }] ; name
: "openzeppelin::account::interface::ISRC6"
= "openzeppelin::account::interface::ISRC6"; type
: "interface"
= "interface" }, { interface_name
: "openzeppelin::account::interface::IDeclarer"
= "openzeppelin::account::interface::IDeclarer"; name
: "DeclarerImpl"
= "DeclarerImpl"; type
: "impl"
= "impl" }, { items
: readonly [{ inputs
: readonly [{ name
: "class_hash"
= "class_hash"; type
: "core::felt252"
= "core::felt252" }] ; name
: "__validate_declare__"
= "__validate_declare__"; outputs
: readonly [{ type
: "core::felt252"
= "core::felt252" }] ; state_mutability
: "view"
= "view"; type
: "function"
= "function" }] ; name
: "openzeppelin::account::interface::IDeclarer"
= "openzeppelin::account::interface::IDeclarer"; type
: "interface"
= "interface" }, { interface_name
: "openzeppelin::account::interface::IPublicKey"
= "openzeppelin::account::interface::IPublicKey"; name
: "PublicKeyImpl"
= "PublicKeyImpl"; type
: "impl"
= "impl" }, { items
: readonly [{ inputs
: readonly [] = []; name
: "get_public_key"
= "get_public_key"; outputs
: readonly [{ type
: "core::felt252"
= "core::felt252" }] ; state_mutability
: "view"
= "view"; type
: "function"
= "function" }, { inputs
: readonly [{ name
: "new_public_key"
= "new_public_key"; type
: "core::felt252"
= "core::felt252" }] ; name
: "set_public_key"
= "set_public_key"; outputs
: readonly [] = []; state_mutability
: "external"
= "external"; type
: "function"
= "function" }] ; name
: "openzeppelin::account::interface::IPublicKey"
= "openzeppelin::account::interface::IPublicKey"; type
: "interface"
= "interface" }, { inputs
: readonly [{ name
: "public_key"
= "public_key"; type
: "core::felt252"
= "core::felt252" }, { name
: "more"
= "more"; type
: "core::felt252"
= "core::felt252" }] ; name
: "constructor"
= "constructor"; type
: "constructor"
= "constructor" }, { kind
: "struct"
= "struct"; members
: readonly [{ kind
: "key"
= "key"; name
: "new_owner_guid"
= "new_owner_guid"; type
: "core::felt252"
= "core::felt252" }] ; name
: "openzeppelin::account::account::AccountComponent::OwnerAdded"
= "openzeppelin::account::account::AccountComponent::OwnerAdded"; type
: "event"
= "event" }, { kind
: "struct"
= "struct"; members
: readonly [{ kind
: "key"
= "key"; name
: "removed_owner_guid"
= "removed_owner_guid"; type
: "core::felt252"
= "core::felt252" }] ; name
: "openzeppelin::account::account::AccountComponent::OwnerRemoved"
= "openzeppelin::account::account::AccountComponent::OwnerRemoved"; type
: "event"
= "event" }, { kind
: "enum"
= "enum"; name
: "openzeppelin::account::account::AccountComponent::Event"
= "openzeppelin::account::account::AccountComponent::Event"; type
: "event"
= "event"; variants
: readonly [{ kind
: "nested"
= "nested"; name
: "OwnerAdded"
= "OwnerAdded"; type
: "openzeppelin::account::account::AccountComponent::OwnerAdded"
= "openzeppelin::account::account::AccountComponent::OwnerAdded" }, { kind
: "nested"
= "nested"; name
: "OwnerRemoved"
= "OwnerRemoved"; type
: "openzeppelin::account::account::AccountComponent::OwnerRemoved"
= "openzeppelin::account::account::AccountComponent::OwnerRemoved" }] }, { kind
: "enum"
= "enum"; name
: "openzeppelin::introspection::src5::SRC5Component::Event"
= "openzeppelin::introspection::src5::SRC5Component::Event"; type
: "event"
= "event"; variants
: readonly [] = [] }, { kind
: "struct"
= "struct"; members
: readonly [{ kind
: "data"
= "data"; name
: "class_hash"
= "class_hash"; type
: "core::starknet::class_hash::ClassHash"
= "core::starknet::class_hash::ClassHash" }] ; name
: "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Upgraded"
= "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Upgraded"; type
: "event"
= "event" }, { kind
: "enum"
= "enum"; name
: "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Event"
= "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Event"; type
: "event"
= "event"; variants
: readonly [{ kind
: "nested"
= "nested"; name
: "Upgraded"
= "Upgraded"; type
: "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Upgraded"
= "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Upgraded" }] }, { kind
: "enum"
= "enum"; name
: "smartr::helpers::simple_account::SimpleAccount::Event"
= "smartr::helpers::simple_account::SimpleAccount::Event"; type
: "event"
= "event"; variants
: readonly [{ kind
: "flat"
= "flat"; name
: "AccountEvent"
= "AccountEvent"; type
: "openzeppelin::account::account::AccountComponent::Event"
= "openzeppelin::account::account::AccountComponent::Event" }, { kind
: "flat"
= "flat"; name
: "SRC5Event"
= "SRC5Event"; type
: "openzeppelin::introspection::src5::SRC5Component::Event"
= "openzeppelin::introspection::src5::SRC5Component::Event" }, { kind
: "flat"
= "flat"; name
: "UpgradeableEvent"
= "UpgradeableEvent"; type
: "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Event"
= "openzeppelin::upgrades::upgradeable::UpgradeableComponent::Event" }] }]
Defined in
sdks/tests/helpers/src/abi/SimpleAccount.ts:1
default_timeout
• Const
default_timeout: 120000
Defined in
sdks/tests/helpers/src/parameters.ts:3
initial_EthTransfer
• Const
initial_EthTransfer: Uint256
Defined in
sdks/tests/helpers/src/parameters.ts:4
udcAddress
• Const
udcAddress: bigint
The address of the UDC (Universal Deployer Contract) in the StarkNet network.
Defined in
sdks/tests/helpers/src/natives.ts:13
Functions
ETH
▸ ETH(provider
): Contract
/**
- Represents an instance of the ETH contract.
Parameters
Name | Type |
---|---|
provider | Account | RpcProvider |
Returns
Contract
Defined in
sdks/tests/helpers/src/natives.ts:30
STRK
▸ STRK(provider
): Contract
Creates an instance of the STARK contract.
Parameters
Name | Type | Description |
---|---|---|
provider | Account | RpcProvider | The RpcProvider or Account used to interact with the token |
Returns
Contract
An instance of the STARK contract.
Defined in
sdks/tests/helpers/src/natives.ts:23
accountAddress
▸ accountAddress(accountName
, publicKey
, constructorCallData
): string
Calculates the account address for a given account name, public key, and constructor call data.
Parameters
Name | Type | Description |
---|---|---|
accountName | "SimpleAccount" | The name of the account used in this project. |
publicKey | string | The public key associated with the account. |
constructorCallData | string [] | The constructor call data for the account. |
Returns
string
The calculated account address.
Remarks
This function requires the cairo account to be compiled with the
scarb build
command at the root of the project.
Defined in
sdks/tests/helpers/src/contract.ts:40
classHash
▸ classHash(className?
): string
Computes the hash of the requested class that is part of the 0xknwn/starknet-modular-account project.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
className | "Counter" | "SimpleAccount" | "SwapRouter" | "TokenA" | "TokenB" | "Counter" | The name of the contract class. |
Returns
string
The hash of the contract class.
Remarks
This function requires the cairo contract to be compiled with the
scarb build
command at the root of the project.
Defined in
sdks/tests/helpers/src/class.ts:22
config
▸ config(env?
): Config
Retrieves the configuration based on the specified environment.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
env | string | "devnet" | The environment for which to retrieve the configuration. Defaults to "devnet". |
Returns
The configuration object.
Defined in
sdks/tests/helpers/src/utils.ts:33
counterAddress
▸ counterAddress(deployerAddress
, ownerAddress
): Promise
<string
>
Retrieves the address of the Counter contract.
Parameters
Name | Type | Description |
---|---|---|
deployerAddress | string | The address of the deployer. |
ownerAddress | string | The address of the owner. |
Returns
Promise
<string
>
The address of the Counter contract.
Defined in
sdks/tests/helpers/src/counter.ts:11
declareClass
▸ declareClass(account
, className?
): Promise
<{ classHash
: string
= HelperClassHash } | { actual_fee
: { amount
: string
; unit
: "WEI"
| "FRI"
} ; block_hash
: string
; block_number
: number
; classHash
: string
= declare.class_hash; events
: { data
: string
[] ; from_address
: string
; keys
: string
[] }[] ; execution_resources
: { bitwise_builtin_applications
: undefined
| number
; data_availability
: undefined
| { l1_data_gas
: number
; l1_gas
: number
} ; ec_op_builtin_applications
: undefined
| number
; ecdsa_builtin_applications
: undefined
| number
; keccak_builtin_applications
: undefined
| number
; memory_holes
: undefined
| number
; pedersen_builtin_applications
: undefined
| number
; poseidon_builtin_applications
: undefined
| number
; range_check_builtin_applications
: undefined
| number
; segment_arena_builtin
: undefined
| number
; steps
: number
} ; execution_status
: "SUCCEEDED"
| "REVERTED"
; finality_status
: "ACCEPTED_ON_L2"
| "ACCEPTED_ON_L1"
; messages_sent
: { from_address
: string
; payload
: string
[] ; to_address
: string
}[] ; revert_reason
: undefined
| string
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_hash
: string
; type
: "INVOKE"
; value
: TransactionReceiptValue
} | { actual_fee
: { amount
: string
; unit
: "WEI"
| "FRI"
} ; classHash
: string
= declare.class_hash; events
: { data
: string
[] ; from_address
: string
; keys
: string
[] }[] ; execution_resources
: { bitwise_builtin_applications
: undefined
| number
; data_availability
: undefined
| { l1_data_gas
: number
; l1_gas
: number
} ; ec_op_builtin_applications
: undefined
| number
; ecdsa_builtin_applications
: undefined
| number
; keccak_builtin_applications
: undefined
| number
; memory_holes
: undefined
| number
; pedersen_builtin_applications
: undefined
| number
; poseidon_builtin_applications
: undefined
| number
; range_check_builtin_applications
: undefined
| number
; segment_arena_builtin
: undefined
| number
; steps
: number
} ; execution_status
: "SUCCEEDED"
| "REVERTED"
; finality_status
: "ACCEPTED_ON_L2"
| "ACCEPTED_ON_L1"
; messages_sent
: { from_address
: string
; payload
: string
[] ; to_address
: string
}[] ; revert_reason
: undefined
| string
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_hash
: string
; type
: "INVOKE"
; value
: TransactionReceiptValue
} | { actual_fee
: { amount
: string
; unit
: "WEI"
| "FRI"
} ; block_hash
: string
; block_number
: number
; classHash
: string
= declare.class_hash; events
: { data
: string
[] ; from_address
: string
; keys
: string
[] }[] ; execution_resources
: { bitwise_builtin_applications
: undefined
| number
; data_availability
: undefined
| { l1_data_gas
: number
; l1_gas
: number
} ; ec_op_builtin_applications
: undefined
| number
; ecdsa_builtin_applications
: undefined
| number
; keccak_builtin_applications
: undefined
| number
; memory_holes
: undefined
| number
; pedersen_builtin_applications
: undefined
| number
; poseidon_builtin_applications
: undefined
| number
; range_check_builtin_applications
: undefined
| number
; segment_arena_builtin
: undefined
| number
; steps
: number
} ; execution_status
: "SUCCEEDED"
| "REVERTED"
; finality_status
: "ACCEPTED_ON_L2"
| "ACCEPTED_ON_L1"
; messages_sent
: { from_address
: string
; payload
: string
[] ; to_address
: string
}[] ; revert_reason
: undefined
| string
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_hash
: string
; type
: "DECLARE"
; value
: TransactionReceiptValue
} | { actual_fee
: { amount
: string
; unit
: "WEI"
| "FRI"
} ; classHash
: string
= declare.class_hash; events
: { data
: string
[] ; from_address
: string
; keys
: string
[] }[] ; execution_resources
: { bitwise_builtin_applications
: undefined
| number
; data_availability
: undefined
| { l1_data_gas
: number
; l1_gas
: number
} ; ec_op_builtin_applications
: undefined
| number
; ecdsa_builtin_applications
: undefined
| number
; keccak_builtin_applications
: undefined
| number
; memory_holes
: undefined
| number
; pedersen_builtin_applications
: undefined
| number
; poseidon_builtin_applications
: undefined
| number
; range_check_builtin_applications
: undefined
| number
; segment_arena_builtin
: undefined
| number
; steps
: number
} ; execution_status
: "SUCCEEDED"
| "REVERTED"
; finality_status
: "ACCEPTED_ON_L2"
| "ACCEPTED_ON_L1"
; messages_sent
: { from_address
: string
; payload
: string
[] ; to_address
: string
}[] ; revert_reason
: undefined
| string
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_hash
: string
; type
: "DECLARE"
; value
: TransactionReceiptValue
} | { actual_fee
: string
; block_hash?
: string
; block_number?
: BlockNumber
; classHash
: string
= declare.class_hash; events
: any
[] ; execution_status
: any
; finality_status
: any
; messages_sent
: MessageToL1
[] ; revert_reason?
: string
; status?
: TransactionStatus
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_hash
: string
; transaction_index?
: number
; type?
: any
; value
: TransactionReceiptValue
} | { classHash
: string
= declare.class_hash; status
: "REJECTED"
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_failure_reason
: { code
: string
; error_message
: string
} ; value
: TransactionReceiptValue
}>
If not already declared, declare the requested class from the 0xknwn/starknet-modular-account project to the Starknet network used by the provided account.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
account | Account | undefined | The starknet.js account used to declare the class. |
className | "Counter" | "SimpleAccount" | "SwapRouter" | "TokenA" | "TokenB" | "Counter" | The name of the class to declare. Defaults to "SmartrAccount". |
Returns
Promise
<{ classHash
: string
= HelperClassHash } | { actual_fee
: { amount
: string
; unit
: "WEI"
| "FRI"
} ; block_hash
: string
; block_number
: number
; classHash
: string
= declare.class_hash; events
: { data
: string
[] ; from_address
: string
; keys
: string
[] }[] ; execution_resources
: { bitwise_builtin_applications
: undefined
| number
; data_availability
: undefined
| { l1_data_gas
: number
; l1_gas
: number
} ; ec_op_builtin_applications
: undefined
| number
; ecdsa_builtin_applications
: undefined
| number
; keccak_builtin_applications
: undefined
| number
; memory_holes
: undefined
| number
; pedersen_builtin_applications
: undefined
| number
; poseidon_builtin_applications
: undefined
| number
; range_check_builtin_applications
: undefined
| number
; segment_arena_builtin
: undefined
| number
; steps
: number
} ; execution_status
: "SUCCEEDED"
| "REVERTED"
; finality_status
: "ACCEPTED_ON_L2"
| "ACCEPTED_ON_L1"
; messages_sent
: { from_address
: string
; payload
: string
[] ; to_address
: string
}[] ; revert_reason
: undefined
| string
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_hash
: string
; type
: "INVOKE"
; value
: TransactionReceiptValue
} | { actual_fee
: { amount
: string
; unit
: "WEI"
| "FRI"
} ; classHash
: string
= declare.class_hash; events
: { data
: string
[] ; from_address
: string
; keys
: string
[] }[] ; execution_resources
: { bitwise_builtin_applications
: undefined
| number
; data_availability
: undefined
| { l1_data_gas
: number
; l1_gas
: number
} ; ec_op_builtin_applications
: undefined
| number
; ecdsa_builtin_applications
: undefined
| number
; keccak_builtin_applications
: undefined
| number
; memory_holes
: undefined
| number
; pedersen_builtin_applications
: undefined
| number
; poseidon_builtin_applications
: undefined
| number
; range_check_builtin_applications
: undefined
| number
; segment_arena_builtin
: undefined
| number
; steps
: number
} ; execution_status
: "SUCCEEDED"
| "REVERTED"
; finality_status
: "ACCEPTED_ON_L2"
| "ACCEPTED_ON_L1"
; messages_sent
: { from_address
: string
; payload
: string
[] ; to_address
: string
}[] ; revert_reason
: undefined
| string
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_hash
: string
; type
: "INVOKE"
; value
: TransactionReceiptValue
} | { actual_fee
: { amount
: string
; unit
: "WEI"
| "FRI"
} ; block_hash
: string
; block_number
: number
; classHash
: string
= declare.class_hash; events
: { data
: string
[] ; from_address
: string
; keys
: string
[] }[] ; execution_resources
: { bitwise_builtin_applications
: undefined
| number
; data_availability
: undefined
| { l1_data_gas
: number
; l1_gas
: number
} ; ec_op_builtin_applications
: undefined
| number
; ecdsa_builtin_applications
: undefined
| number
; keccak_builtin_applications
: undefined
| number
; memory_holes
: undefined
| number
; pedersen_builtin_applications
: undefined
| number
; poseidon_builtin_applications
: undefined
| number
; range_check_builtin_applications
: undefined
| number
; segment_arena_builtin
: undefined
| number
; steps
: number
} ; execution_status
: "SUCCEEDED"
| "REVERTED"
; finality_status
: "ACCEPTED_ON_L2"
| "ACCEPTED_ON_L1"
; messages_sent
: { from_address
: string
; payload
: string
[] ; to_address
: string
}[] ; revert_reason
: undefined
| string
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_hash
: string
; type
: "DECLARE"
; value
: TransactionReceiptValue
} | { actual_fee
: { amount
: string
; unit
: "WEI"
| "FRI"
} ; classHash
: string
= declare.class_hash; events
: { data
: string
[] ; from_address
: string
; keys
: string
[] }[] ; execution_resources
: { bitwise_builtin_applications
: undefined
| number
; data_availability
: undefined
| { l1_data_gas
: number
; l1_gas
: number
} ; ec_op_builtin_applications
: undefined
| number
; ecdsa_builtin_applications
: undefined
| number
; keccak_builtin_applications
: undefined
| number
; memory_holes
: undefined
| number
; pedersen_builtin_applications
: undefined
| number
; poseidon_builtin_applications
: undefined
| number
; range_check_builtin_applications
: undefined
| number
; segment_arena_builtin
: undefined
| number
; steps
: number
} ; execution_status
: "SUCCEEDED"
| "REVERTED"
; finality_status
: "ACCEPTED_ON_L2"
| "ACCEPTED_ON_L1"
; messages_sent
: { from_address
: string
; payload
: string
[] ; to_address
: string
}[] ; revert_reason
: undefined
| string
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_hash
: string
; type
: "DECLARE"
; value
: TransactionReceiptValue
} | { actual_fee
: string
; block_hash?
: string
; block_number?
: BlockNumber
; classHash
: string
= declare.class_hash; events
: any
[] ; execution_status
: any
; finality_status
: any
; messages_sent
: MessageToL1
[] ; revert_reason?
: string
; status?
: TransactionStatus
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_hash
: string
; transaction_index?
: number
; type?
: any
; value
: TransactionReceiptValue
} | { classHash
: string
= declare.class_hash; status
: "REJECTED"
; statusReceipt
: keyof TransactionStatusReceiptSets
; transaction_failure_reason
: { code
: string
; error_message
: string
} ; value
: TransactionReceiptValue
}>
An object containing the declared class hash and the transaction receipt if the class was not already declared.
Throws
An error if the class deployment fails.
Remarks
This function requires the cairo contract to be compiled with the
scarb build
command at the root of the project. It also requires the
account to have enough funds to declare the class to the Starknet network.
Defined in
sdks/tests/helpers/src/class.ts:72
deployAccount
▸ deployAccount(deployerAccount
, accountName
, publicKey
, constructorCalldata
): Promise
<string
>
Deploys an account on the StarkNet network.
Parameters
Name | Type | Description |
---|---|---|
deployerAccount | Account | The account used to deploy the new account. |
accountName | "SimpleAccount" | The name of the account to be deployed. |
publicKey | string | The public key associated with the account. |
constructorCalldata | any [] | The constructor calldata required for deploying the account. |
Returns
Promise
<string
>
The address of the deployed account.
Throws
Error if the deployment fails.
Defined in
sdks/tests/helpers/src/contract.ts:102
deployCounter
▸ deployCounter(deployerAccount
, ownerAddress
): Promise
<Contract
>
Deploys a Counter contract.
Parameters
Name | Type | Description |
---|---|---|
deployerAccount | Account | The account used to deploy the contract. |
ownerAddress | string | The owner's address. |
Returns
Promise
<Contract
>
A Promise that resolves to the deployed Counter contract.
Defined in
sdks/tests/helpers/src/counter.ts:28
deploySimpleAccount
▸ deploySimpleAccount(deployerAccount
, publicKey
, more
): Promise
<string
>
Deploys a simple account on the StarkNet network.
Parameters
Name | Type | Description |
---|---|---|
deployerAccount | Account | The account used to deploy the simple account. |
publicKey | string | The public key associated with the simple account. |
more | string | Additional information for the simple account. |
Returns
Promise
<string
>
A promise that resolves to the deployed simple account.
Defined in
sdks/tests/helpers/src/simple_account.ts:32
deploySwapRouter
▸ deploySwapRouter(deployerAccount
, ownerAddress
): Promise
<Contract
>
Deploys the SwapRouter contract.
Parameters
Name | Type | Description |
---|---|---|
deployerAccount | Account | The deployer account. |
ownerAddress | string | The owner address. |
Returns
Promise
<Contract
>
A Promise that resolves to the deployed Counter contract.
Defined in
sdks/tests/helpers/src/swap_router.ts:30
deployTokenA
▸ deployTokenA(deployerAccount
, recipientAddress
, ownerAddress
): Promise
<Contract
>
Deploys the TokenA contract.
Parameters
Name | Type | Description |
---|---|---|
deployerAccount | Account | The deployer account. |
recipientAddress | string | - |
ownerAddress | string | The owner address. |
Returns
Promise
<Contract
>
A Promise that resolves to the deployed Counter contract.
Defined in
sdks/tests/helpers/src/tokens.ts:29
deployTokenB
▸ deployTokenB(deployerAccount
, recipientAddress
, ownerAddress
): Promise
<Contract
>
Deploys the TokenB contract.
Parameters
Name | Type | Description |
---|---|---|
deployerAccount | Account | The deployer account. |
recipientAddress | string | - |
ownerAddress | string | The owner address. |
Returns
Promise
<Contract
>
A Promise that resolves to the deployed Counter contract.
Defined in
sdks/tests/helpers/src/tokens.ts:63
simpleAccountAddress
▸ simpleAccountAddress(publicKey
, more
): string
Generates a simple account address based on the provided public key and additional data.
Parameters
Name | Type | Description |
---|---|---|
publicKey | string | The public key associated with the account. |
more | string | Additional data for the account. |
Returns
string
The generated account address.
Defined in
sdks/tests/helpers/src/simple_account.ts:13
swapRouterAddress
▸ swapRouterAddress(deployerAddress
, ownerAddress
): Promise
<string
>
Retrieves the swap router address from its deployer and owner.
Parameters
Name | Type | Description |
---|---|---|
deployerAddress | string | The address of the deployer. |
ownerAddress | string | The address of the owner. |
Returns
Promise
<string
>
The address of the swap router contract.
Defined in
sdks/tests/helpers/src/swap_router.ts:13
testAccounts
▸ testAccounts(config
): Account
[]
Retrieves the Accounts from the configuration.
Parameters
Name | Type | Description |
---|---|---|
config | Config | The configuration object containing the provider URL and account details. |
Returns
Account
[]
An array of Accounts.
Defined in
sdks/tests/helpers/src/utils.ts:54
tokenAAddress
▸ tokenAAddress(deployerAddress
, recipientAddress
, ownerAddress
): Promise
<string
>
Retrieves the token A address.
Parameters
Name | Type | Description |
---|---|---|
deployerAddress | string | The address of the deployer. |
recipientAddress | string | The address of the recipient. |
ownerAddress | string | The address of the owner. |
Returns
Promise
<string
>
The token A address.
Defined in
sdks/tests/helpers/src/tokens.ts:16
tokenBAddress
▸ tokenBAddress(deployerAddress
, recipientAddress
, ownerAddress
): Promise
<string
>
Retrieves the token B address.
Parameters
Name | Type | Description |
---|---|---|
deployerAddress | string | The address of the deployer. |
recipientAddress | string | The address of the recipient. |
ownerAddress | string | The address of the owner. |
Returns
Promise
<string
>
The token B address.