-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from multiversx/facades-01
Sketch a simple facade: the entrypoint
- Loading branch information
Showing
11 changed files
with
478 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## AccountManagementController | ||
|
||
Promotes all the functionality of `AccountManagementTransactionsFactory` and `AccountManagementTransactionsOutcomeParser`. | ||
|
||
``` | ||
class AccountManagementController: | ||
... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## DelegationController | ||
|
||
Promotes all the functionality of `DelegationTransactionsFactory` and `DelegationTransactionsOutcomeParser`. | ||
|
||
``` | ||
class DelegationController: | ||
// The constructor is not captured by the specs; it's up to the implementing library to define it. | ||
// Suggestions: | ||
constructor(network_provider: INetworkProvider); | ||
create_transaction_for_new_delegation_contract({ | ||
sender: IAccount; | ||
nonce: int; | ||
totalDelegationCap: Amount; | ||
service_fee: number; | ||
amount: Amount; | ||
}): Transaction; | ||
parse_create_new_delegation_contract(transaction_on_network: TransactionOnNetwork): { | ||
contract_address: string; | ||
}[]; | ||
await_completed_create_new_delegation_contract(transaction_on_network: TransactionOnNetwork): { | ||
contract_address: string; | ||
}[]; | ||
// ... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## RelayedController | ||
|
||
Promotes all the functionality of `RelayedTransactionsFactory` and `RelayedTransactionsOutcomeParser`. | ||
|
||
``` | ||
class RelayedController: | ||
... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
## SmartContractController | ||
|
||
Promotes all the functionality of `SmartContractTransactionsFactory`, `SmartContractTransactionsOutcomeParser` and `SmartContractQueriesController`. | ||
|
||
``` | ||
class SmartContractController: | ||
// The constructor is not captured by the specs; it's up to the implementing library to define it. | ||
// Suggestions: | ||
constructor(network_provider: INetworkProvider, abi: Optional[Abi]); | ||
create_transaction_for_deploy({ | ||
sender: IAccount; | ||
nonce: Optional[int]; | ||
bytecode: bytes OR bytecodePath: Path; | ||
arguments: List[object] = []; | ||
native_transfer_amount: Amount = 0; | ||
is_upgradeable: bool = True; | ||
is_readable: bool = True; | ||
is_payable: bool = False; | ||
is_payable_by_contract: bool = True; | ||
gas_limit: uint32; | ||
}): Transaction; | ||
parse_deploy(transaction_on_network: TransactionOnNetwork): { | ||
return_code: string; | ||
return_message: string; | ||
contracts: List[{ | ||
address: string; | ||
ownerAddress: string; | ||
codeHash: bytes; | ||
}]; | ||
}; | ||
// Does "await_completed_transaction" and "parse_deploy" in one go. | ||
await_completed_deploy(transaction_hash: string): { | ||
return_code: string; | ||
return_message: string; | ||
contracts: List[{ | ||
address: string; | ||
ownerAddress: string; | ||
codeHash: bytes; | ||
}]; | ||
}; | ||
create_transaction_for_upgrade({ | ||
sender: IAccount; | ||
nonce: Optional[int]; | ||
contract: IAddress; | ||
bytecode: bytes OR bytecodePath: Path; | ||
arguments: List[object] = []; | ||
native_transfer_amount: Amount = 0; | ||
is_upgradeable: bool = True; | ||
is_readable: bool = True; | ||
is_payable: bool = False; | ||
is_payable_by_contract: bool = True; | ||
gas_limit: uint32; | ||
}): Transaction; | ||
// This method is less important (supports an exotic flow). | ||
parse_upgrade(transaction_on_network: TransactionOnNetwork): { | ||
return_code: string; | ||
return_message: string; | ||
contracts: List[{ | ||
address: string; | ||
codeHash: bytes; | ||
}]; | ||
}; | ||
// Specialized function to await and parse a contract upgrade transaction. | ||
// Does "await_completed_transaction" and "parse_upgrade" in one go. | ||
await_completed_upgrade(transaction_hash: string): { | ||
return_code: string; | ||
return_message: string; | ||
contracts: List[{ | ||
address: string; | ||
codeHash: bytes; | ||
}]; | ||
}; | ||
create_transaction_for_execute({ | ||
sender: IAccount; | ||
nonce: Optional[int]; | ||
contract: IAddress; | ||
// If "function" is a reserved word in the implementing language, it should be replaced with a different name (e.g. "func" or "functionName"). | ||
function: string; | ||
arguments: List[object] = []; | ||
native_transfer_amount: Amount = 0; | ||
token_transfers: List[TokenTransfer] = []; | ||
gas_limit: uint32; | ||
}): Transaction; | ||
parse_execute({ | ||
transaction_on_network: TransactionOnNetwork, | ||
function?: string | ||
}): { | ||
values: List[any]; | ||
return_code: string; | ||
return_message: string; | ||
}; | ||
// Does "await_completed_transaction" and "parse_execute" in one go. | ||
await_completed_execute({ | ||
transaction_hash: string; | ||
}): { | ||
values: List[any]; | ||
return_code: string; | ||
return_message: string; | ||
}; | ||
query_contract({ | ||
contract: IAddress; | ||
caller?: IAddress; | ||
value?: Amount; | ||
function: string; | ||
arguments: List[object]; | ||
}): List[any]; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## TokenManagementController | ||
|
||
Promotes all the functionality of `TokenManagementTransactionsFactory` and `TokenManagementTransactionsOutcomeParser`. | ||
|
||
``` | ||
class TokenManagementController: | ||
... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## TransfersController | ||
|
||
Promotes all the functionality of `TransferTransactionsFactory` and `TransferTransactionsOutcomeParser`. | ||
|
||
``` | ||
class TransfersController: | ||
// The constructor is not captured by the specs; it's up to the implementing library to define it. | ||
// Suggestions: | ||
constructor(network_provider: INetworkProvider); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## Account | ||
|
||
``` | ||
class Account: | ||
// The constructor is not captured by the specs; it's up to the implementing library to define it. | ||
// Suggestions: | ||
constructor(secret_key: bytes, hrp: Optional[str]); | ||
constructor(user_signer: IUserSigner, hrp: Optional[str]); | ||
address: IAddress; | ||
// Local copy of the account nonce. | ||
// Must be explicitly managed by client code. | ||
nonce: uint64; | ||
sign(data: bytes): bytes; | ||
// Gets the nonce (the one from the object's state) and increments it. | ||
get_nonce_then_increment(): uint64; | ||
// Named constructor | ||
// Loads a secret key from a PEM file. PEM files may contain multiple accounts - thus, an (optional) "index" is used to select the desired secret key. | ||
// Returns an Account object, initialized with the secret key. | ||
static new_from_pem(path: Path, index: Optional[int], hrp: Optional[str]): Account; | ||
// Named constructor | ||
// Loads a secret key from an encrypted keystore file. Handles both keystores that hold a mnemonic and ones that hold a secret key (legacy). | ||
// For keystores that hold an encrypted mnemonic, the optional "address_index" parameter is used to derive the desired secret key. | ||
// Returns an Account object, initialized with the secret key. | ||
static new_from_keystore(path: Path, password: str, address_index: Optional[int], hrp: Optional[str]): Account; | ||
// Named constructor | ||
// Loads (derives) a secret key from a mnemonic. The optional "address_index" parameter is used to guide the derivation. | ||
// Returns an Account object, initialized with the secret key. | ||
static new_from_mnemonic(mnemonic: str, address_index: Optional[int], hrp: Optional[str]): Account; | ||
``` |
Oops, something went wrong.