Skip to content

Commit

Permalink
[TS SDK] option to pass optional args to token client functions (apto…
Browse files Browse the repository at this point in the history
…s-labs#5839)

Co-authored-by: Eric Le <therealericle@gmail.com>
  • Loading branch information
2 people authored and areshand committed Dec 17, 2022
1 parent 69ad5d8 commit e577c04
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ecosystem/typescript/sdk/src/token_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,10 @@ export class TokenClient {
* @param optIn boolean value indicates user want to opt-in or out of direct transfer
* @returns The hash of the transaction submitted to the API
*/
async optInTokenTransfer(sender: AptosAccount, optIn: boolean): Promise<string> {
async optInTokenTransfer(sender: AptosAccount, optIn: boolean, extraArgs?: OptionalTransactionArgs): Promise<string> {
const payload = this.transactionBuilder.buildTransactionPayload("0x3::token::opt_in_direct_transfer", [], [optIn]);

return this.aptosClient.generateSignSubmitTransaction(sender, payload);
return this.aptosClient.generateSignSubmitTransaction(sender, payload, extraArgs);
}

/**
Expand All @@ -375,6 +375,7 @@ export class TokenClient {
propertyVersion: AnyNumber,
receiver: MaybeHexString,
amount: AnyNumber,
extraArgs?: OptionalTransactionArgs,
): Promise<string> {
// compile script to invoke public transfer function
const payload = new TransactionPayloadScript(
Expand All @@ -392,7 +393,7 @@ export class TokenClient {
),
);

return this.aptosClient.generateSignSubmitTransaction(sender, payload);
return this.aptosClient.generateSignSubmitTransaction(sender, payload, extraArgs);
}

/**
Expand All @@ -413,14 +414,15 @@ export class TokenClient {
name: String,
PropertyVersion: AnyNumber,
amount: AnyNumber,
extraArgs?: OptionalTransactionArgs,
): Promise<string> {
const payload = this.transactionBuilder.buildTransactionPayload(
"0x3::token::burn_by_creator",
[],
[ownerAddress, collection, name, PropertyVersion, amount],
);

return this.aptosClient.generateSignSubmitTransaction(creator, payload);
return this.aptosClient.generateSignSubmitTransaction(creator, payload, extraArgs);
}

/**
Expand All @@ -441,14 +443,15 @@ export class TokenClient {
name: String,
PropertyVersion: AnyNumber,
amount: AnyNumber,
extraArgs?: OptionalTransactionArgs,
): Promise<string> {
const payload = this.transactionBuilder.buildTransactionPayload(
"0x3::token::burn",
[],
[creatorAddress, collection, name, PropertyVersion, amount],
);

return this.aptosClient.generateSignSubmitTransaction(owner, payload);
return this.aptosClient.generateSignSubmitTransaction(owner, payload, extraArgs);
}

/**
Expand All @@ -475,14 +478,15 @@ export class TokenClient {
keys: Array<string>,
values: Array<Bytes>,
types: Array<string>,
extraArgs?: OptionalTransactionArgs,
): Promise<string> {
const payload = this.transactionBuilder.buildTransactionPayload(
"0x3::token::mutate_token_properties",
[],
[tokenOwner, creator, collection_name, tokenName, propertyVersion, amount, keys, values, types],
);

return this.aptosClient.generateSignSubmitTransaction(account, payload);
return this.aptosClient.generateSignSubmitTransaction(account, payload, extraArgs);
}

/**
Expand Down

0 comments on commit e577c04

Please sign in to comment.