-
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 #538
Add entrypoints #538
Conversation
src/entrypoints/config.ts
Outdated
chainId = "1"; | ||
} | ||
|
||
export class LocalnetEntrypointConfig 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.
🚀
src/entrypoints/entrypoints.ts
Outdated
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.
Maybe using the "options" pattern? 💭
return verifier.verify(txComputer.computeBytesForVerifying(transaction), transaction.signature); | ||
} | ||
|
||
async signMessage(message: Message, account: IAccount): Promise<void> { |
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 they will be soon moved to account: multiversx/mx-sdk-specs#94
src/entrypoints/config.ts
Outdated
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.
I think it would be easier to have constructors on these classes in case somebody wants to change one of the fields (e.g. networkProviderUrl
) without having to access the fields after the initialization.
src/entrypoints/entrypoints.spec.ts
Outdated
this.timeout(30000); | ||
const abi = await loadAbiRegistry("src/testdata/adder.abi.json"); | ||
const sender = Account.newFromPem(alicePem.pemFileText); | ||
const accountAddress = new Address(sender.address.bech32()); |
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 there's no need to convert the address to bech32 then back to Address
. Can simply be sender.address
.
|
||
const transaction = await controller.createTransactionForDeploy( | ||
sender, | ||
BigInt(sender.getNonceThenIncrement().valueOf()), |
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 should switch to bigint
for the nonce instead of INonce
. valueOf
also returns a number
which can lead to errors in the future. can be done in the next PR.
src/entrypoints/entrypoints.spec.ts
Outdated
}, | ||
); | ||
|
||
assert.equal((await relayedTransaction).chainID, "D"); |
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.
Maybe also assert on the data
and gasLimit
fields.
src/entrypoints/entrypoints.spec.ts
Outdated
assert.equal((await relayedTransaction).chainID, "D"); | ||
assert.equal(relayedTransaction.chainID, "D"); | ||
assert.deepEqual(transaction.data, Buffer.from("hello")); | ||
assert.equal(relayedTransaction.gasLimit, 0n); |
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.
The gasLimit
of the relayed transaction should not be 0, the issue is here.
And I meant to assert on the data field of the relayed transaction.
No description provided.