Skip to content
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

Update Deprecated Method Usage #1740

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/lib/mina/token/token-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export { TokenContract, TokenContractV2 };

/**
* @deprecated Use {@link TokenContractV2} instead, which has the right max account update limit.
*
*
* Base token contract which
* - implements the `Approvable` API, with the `approveBase()` method left to be defined by subclasses
* - implements the `Transferable` API as a wrapper around the `Approvable` API
Expand Down Expand Up @@ -99,15 +99,21 @@ abstract class TokenContract extends SmartContract {
);

// iterate through the forest and apply user-defined logic
for (let i = 0; i < (this.constructor as typeof TokenContract).MAX_ACCOUNT_UPDATES; i++) {
for (
let i = 0;
i < (this.constructor as typeof TokenContract).MAX_ACCOUNT_UPDATES;
i++
) {
let { accountUpdate, usesThisToken } = iterator.next();
callback(accountUpdate, usesThisToken);
}

// prove that we checked all updates
iterator.assertFinished(
`Number of account updates to approve exceed ` +
`the supported limit of ${(this.constructor as typeof TokenContract).MAX_ACCOUNT_UPDATES}.\n`
`the supported limit of ${
(this.constructor as typeof TokenContract).MAX_ACCOUNT_UPDATES
}.\n`
);

// skip hashing our child account updates in the method wrapper
Expand Down Expand Up @@ -164,12 +170,12 @@ abstract class TokenContract extends SmartContract {
// coerce the inputs to AccountUpdate and pass to `approveBase()`
let tokenId = this.deriveTokenId();
if (from instanceof PublicKey) {
from = AccountUpdate.defaultAccountUpdate(from, tokenId);
from = AccountUpdate.default(from, tokenId);
from.requireSignature();
from.label = `${this.constructor.name}.transfer() (from)`;
}
if (to instanceof PublicKey) {
to = AccountUpdate.defaultAccountUpdate(to, tokenId);
to = AccountUpdate.default(to, tokenId);
to.label = `${this.constructor.name}.transfer() (to)`;
}

Expand All @@ -182,7 +188,7 @@ abstract class TokenContract extends SmartContract {
}

/** Version of `TokenContract` with the precise number of `MAX_ACCOUNT_UPDATES`
*
*
* The value of 20 in `TokenContract` was a rough upper limit, the precise upper
* bound is 9.
*/
Expand Down