-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add entrypoints #514
Add entrypoints #514
Conversation
src/account.ts
Outdated
@@ -15,18 +18,30 @@ export class Account { | |||
*/ | |||
nonce: INonce = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, we are using bigint
for nonce. Would it be a breaking change if we'd do that here?
src/account.ts
Outdated
return this.signer.sign(data); | ||
} | ||
|
||
static fromPem(path: string, hrp: string = LibraryConfig.DefaultAddressHrp): Account { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the specs, the static methods are prefixed with new...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new_from_mnemonic
is also missing.
@@ -1,11 +1,11 @@ | |||
import BigNumber from "bignumber.js"; | |||
import { ITransactionOnNetwork } from "./interfaceOfNetwork"; | |||
import { TransactionOnNetwork } from "./networkProviders"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we should use objects from networkProviders
in the core
package. Perhaps we should keep the interface or move the TransactionOnNetwork
in core
. Would that be breaking?
nonce: number; | ||
round: number; | ||
epoch: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use bigint
instead of number
.
function?: string; | ||
data: Buffer; | ||
signature: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and maybe have the signature as UInt8Array
@@ -376,6 +376,30 @@ export class DelegationTransactionsFactory { | |||
}).build(); | |||
} | |||
|
|||
createTransactionForWithdrawing(_options: { sender: IAddress; delegationContract: IAddress }): Transaction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps add some empty lines, but it's not a big deal.
src/controllers/accountController.ts
Outdated
@@ -0,0 +1,64 @@ | |||
import { IAddress } from "../interface"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the methods pubkey()
and bech32()
are deprecated in the Address
class, I think we can create locally a new interface that has toBech32()
and getPublicKey()
, given the fact that everybody will use that class.
return transaction; | ||
} | ||
|
||
async createTransactionForExecute(sender: IAccount, options: TransactionInput): Promise<Transaction> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could've implemented parseExecute
and awaitExecuteCompleted
.
|
||
parseIssueFungible(transactionOnNetwork: TransactionOnNetwork): IESDTIssueOutcome[] { | ||
return this.parser.parseIssueFungible(transactionOnNetwork); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't you implement all the methods that are present in TokenManagementTransactionsFactory
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 🌔
import { ProxyNetworkProvider, TransactionOnNetwork } from "../networkProviders"; | ||
import { INetworkProvider } from "../networkProviders/interface"; | ||
|
||
// This will be deleted in future version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can drop it now, in this PR, after applying the following change:
chainId: string; | ||
} | ||
|
||
export class TestnetEntrypointConfig implements EntrypointConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding localnet, as well?
class LocalnetEntrypointConfig:
network_provider_url = "http://localhost:7950"
network_provider_kind = "proxy"
chain_id = "localnet"
src/account.ts
Outdated
@@ -15,18 +18,30 @@ export class Account { | |||
*/ | |||
nonce: INonce = 0; | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good that we now have these deprecation markers.
src/account.ts
Outdated
/** | ||
* The signer of the account. | ||
*/ | ||
signer?: UserSigner; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, let's switch to private access modifier (so that we hide the current workaround of having a "frankenstein" Account).
src/account.ts
Outdated
return new Account(userSigner.getAddress(hrp), userSigner); | ||
} | ||
|
||
static fromWallet( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below (and in PY & specs), we use the term keystore. Perhaps this can also be named fromKeystoreObject
(parameters can also be renamed)?
private networkProvider: ApiNetworkProvider | ProxyNetworkProvider; | ||
private chainId: string; | ||
|
||
constructor(networkProviderUrl: string, networkProviderKind: string, chainId: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Options pattern?
private networkProvider: ApiNetworkProvider | ProxyNetworkProvider; | ||
private chainId: string; | ||
|
||
constructor(networkProviderUrl: string, networkProviderKind: string, chainId: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In TypeScript, we can have networkProviderKind
as an enum or have the type annotation as "proxy" | "api"
(can also stay as it is).
return new RelayedController(this.chainId); | ||
} | ||
|
||
createSmartContractController(abi?: AbiRegistry): SmartContractController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have an alias Abi
, for example:
class Abi extends AbiRegistry;
import { TransactionWatcher } from "../transactionWatcher"; | ||
import { IAccount } from "./interfaces"; | ||
|
||
export class TokenManagementController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems incomplete. But we can add remaining functionality in future PRs.
import { DevnetEntrypoint } from "./entrypoints"; | ||
|
||
describe("TestEntrypoint", () => { | ||
const entrypoint = new DevnetEntrypoint(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
this was done in smaller prs |
No description provided.