From cf1d4787db2923a3c3b0670c0d9e7f4dc046be83 Mon Sep 17 00:00:00 2001 From: danielailie Date: Mon, 18 Nov 2024 12:08:59 +0200 Subject: [PATCH 1/4] Update input namings --- src/testutils/networkProviders.ts | 2 +- src/tokenManagement/resources.ts | 6 +++++- .../tokenManagementTransactionsFactory.ts | 14 +++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/testutils/networkProviders.ts b/src/testutils/networkProviders.ts index 6e3bebaf..7e5f49ea 100644 --- a/src/testutils/networkProviders.ts +++ b/src/testutils/networkProviders.ts @@ -33,7 +33,7 @@ export function createMainnetProvider(): INetworkProvider { export interface INetworkProvider { getNetworkConfig(): Promise; getAccount(address: IAddress): Promise; - getTransaction(txHash: string, withProcessStatus?: boolean): Promise; + getTransaction(txHash: string): Promise; getTransactionStatus(txHash: string): Promise; sendTransaction(tx: Transaction): Promise; simulateTransaction(tx: Transaction): Promise; diff --git a/src/tokenManagement/resources.ts b/src/tokenManagement/resources.ts index 32e4ce3c..a08a4ec0 100644 --- a/src/tokenManagement/resources.ts +++ b/src/tokenManagement/resources.ts @@ -50,6 +50,7 @@ export type MintInput = { uris: string[]; }; export type ManagementInput = { user: IAddress; tokenIdentifier: string }; +export type PausingInput = { tokenIdentifier: string }; export type LocalBurnInput = { tokenIdentifier: string; supplyToBurn: bigint }; export type LocalMintInput = { tokenIdentifier: string; supplyToMint: bigint }; @@ -59,6 +60,8 @@ export type UpdateQuantityInput = UpdateInput & { quantity: bigint }; export type UpdateInput = { tokenIdentifier: string; tokenNonce: bigint }; export type BurnRoleGloballyInput = { tokenIdentifier: string }; +export type UpdateTokenIDInput = { tokenIdentifier: string }; +export type ChangeTokenToDynamicInput = { tokenIdentifier: string }; export type RegisterRolesInput = { tokenName: string; @@ -81,12 +84,13 @@ export type RegisterMetaESDTInput = { }; export type ModifyRoyaltiesInput = BaseInput & { newRoyalties: bigint }; +export type ModifyCreatorInput = BaseInput; export type BaseInput = { tokenIdentifier: string; tokenNonce: bigint }; export type SetNewUriInput = BaseInput & { newUris: string[] }; -export type UpdateMetadataInput = { +export type ManageMetadataInput = { tokenIdentifier: string; tokenNonce: bigint; newTokenName?: string; diff --git a/src/tokenManagement/tokenManagementTransactionsFactory.ts b/src/tokenManagement/tokenManagementTransactionsFactory.ts index 2388a2df..26191204 100644 --- a/src/tokenManagement/tokenManagementTransactionsFactory.ts +++ b/src/tokenManagement/tokenManagementTransactionsFactory.ts @@ -370,7 +370,7 @@ export class TokenManagementTransactionsFactory { }).build(); } - createTransactionForPausing(sender: IAddress, options: resources.ManagementInput): Transaction { + createTransactionForPausing(sender: IAddress, options: resources.PausingInput): Transaction { const dataParts = ["pause", ...this.argSerializer.valuesToStrings([new StringValue(options.tokenIdentifier)])]; return new TransactionBuilder({ @@ -383,7 +383,7 @@ export class TokenManagementTransactionsFactory { }).build(); } - createTransactionForUnpausing(sender: IAddress, options: resources.ManagementInput): Transaction { + createTransactionForUnpausing(sender: IAddress, options: resources.PausingInput): Transaction { const dataParts = [ "unPause", ...this.argSerializer.valuesToStrings([new StringValue(options.tokenIdentifier)]), @@ -598,7 +598,7 @@ export class TokenManagementTransactionsFactory { }).build(); } - createTransactionForModifyingCreator(sender: IAddress, options: resources.BaseInput): Transaction { + createTransactionForModifyingCreator(sender: IAddress, options: resources.ModifyCreatorInput): Transaction { const dataParts = [ "ESDTModifyCreator", ...this.argSerializer.valuesToStrings([ @@ -617,7 +617,7 @@ export class TokenManagementTransactionsFactory { }).build(); } - createTransactionForUpdatingMetadata(sender: IAddress, options: resources.UpdateMetadataInput): Transaction { + createTransactionForUpdatingMetadata(sender: IAddress, options: resources.ManageMetadataInput): Transaction { const dataParts = [ "ESDTMetaDataUpdate", ...this.argSerializer.valuesToStrings([ @@ -641,7 +641,7 @@ export class TokenManagementTransactionsFactory { }).build(); } - createTransactionForMetadataRecreate(sender: IAddress, options: resources.UpdateMetadataInput): Transaction { + createTransactionForMetadataRecreate(sender: IAddress, options: resources.ManageMetadataInput): Transaction { const dataParts = [ "ESDTMetaDataRecreate", ...this.argSerializer.valuesToStrings([ @@ -667,7 +667,7 @@ export class TokenManagementTransactionsFactory { createTransactionForChangingTokenToDynamic( sender: IAddress, - options: resources.BurnRoleGloballyInput, + options: resources.ChangeTokenToDynamicInput, ): Transaction { const dataParts = [ "changeToDynamic", @@ -684,7 +684,7 @@ export class TokenManagementTransactionsFactory { }).build(); } - createTransactionForUpdatingTokenId(sender: IAddress, options: resources.BurnRoleGloballyInput): Transaction { + createTransactionForUpdatingTokenId(sender: IAddress, options: resources.UpdateTokenIDInput): Transaction { const dataParts = [ "updateTokenID", ...this.argSerializer.valuesToStrings([new StringValue(options.tokenIdentifier)]), From 4ab1934b5d2f42d198eb42ef5acfddff5fb7919f Mon Sep 17 00:00:00 2001 From: danielailie Date: Mon, 18 Nov 2024 12:15:37 +0200 Subject: [PATCH 2/4] Fix test --- src/testutils/contractController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testutils/contractController.ts b/src/testutils/contractController.ts index a053e443..b8643fcf 100644 --- a/src/testutils/contractController.ts +++ b/src/testutils/contractController.ts @@ -15,7 +15,7 @@ export class ContractController { this.provider = provider; this.transactionCompletionAwaiter = new TransactionWatcher({ getTransaction: async (hash: string) => { - return await provider.getTransaction(hash, true); + return await provider.getTransaction(hash); }, }); } From 50a09e18ae97cddf6dd430ebf4e90ced4a5b171c Mon Sep 17 00:00:00 2001 From: danielailie Date: Mon, 18 Nov 2024 12:27:18 +0200 Subject: [PATCH 3/4] Fix integration tests --- src/abi/interaction.local.net.spec.ts | 6 +++--- src/abi/smartContract.local.net.spec.ts | 2 +- src/abi/smartContractResults.local.net.spec.ts | 2 +- src/transaction.local.net.spec.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/abi/interaction.local.net.spec.ts b/src/abi/interaction.local.net.spec.ts index 2a248768..68d119c7 100644 --- a/src/abi/interaction.local.net.spec.ts +++ b/src/abi/interaction.local.net.spec.ts @@ -118,7 +118,7 @@ describe("test smart contract interactor", function () { const transactionCompletionAwaiter = new TransactionWatcher({ getTransaction: async (hash: string) => { - return await provider.getTransaction(hash, true); + return await provider.getTransaction(hash); }, }); @@ -406,7 +406,7 @@ describe("test smart contract interactor", function () { const transactionCompletionAwaiter = new TransactionWatcher({ getTransaction: async (hash: string) => { - return await provider.getTransaction(hash, true); + return await provider.getTransaction(hash); }, }); @@ -600,7 +600,7 @@ describe("test smart contract interactor", function () { const transactionCompletionAwaiter = new TransactionWatcher({ getTransaction: async (hash: string) => { - return await provider.getTransaction(hash, true); + return await provider.getTransaction(hash); }, }); diff --git a/src/abi/smartContract.local.net.spec.ts b/src/abi/smartContract.local.net.spec.ts index 818cc034..1bde9a61 100644 --- a/src/abi/smartContract.local.net.spec.ts +++ b/src/abi/smartContract.local.net.spec.ts @@ -35,7 +35,7 @@ describe("test on local testnet", function () { watcher = new TransactionWatcher({ getTransaction: async (hash: string) => { - return await provider.getTransaction(hash, true); + return await provider.getTransaction(hash); }, }); }); diff --git a/src/abi/smartContractResults.local.net.spec.ts b/src/abi/smartContractResults.local.net.spec.ts index 850bd9a3..5f74c680 100644 --- a/src/abi/smartContractResults.local.net.spec.ts +++ b/src/abi/smartContractResults.local.net.spec.ts @@ -21,7 +21,7 @@ describe("fetch transactions from local testnet", function () { ({ alice } = await loadTestWallets()); watcher = new TransactionWatcher({ getTransaction: async (hash: string) => { - return await provider.getTransaction(hash, true); + return await provider.getTransaction(hash); }, }); }); diff --git a/src/transaction.local.net.spec.ts b/src/transaction.local.net.spec.ts index 15082da7..ed8dd0ab 100644 --- a/src/transaction.local.net.spec.ts +++ b/src/transaction.local.net.spec.ts @@ -22,7 +22,7 @@ describe("test transaction", function () { return new TransactionWatcher( { getTransaction: async (hash: string) => { - return await provider.getTransaction(hash, true); + return await provider.getTransaction(hash); }, }, { timeoutMilliseconds: 100000 }, From 266fdb3eca8b6fddf7f86f96fa3b877871dacb15 Mon Sep 17 00:00:00 2001 From: danielailie Date: Mon, 18 Nov 2024 12:38:37 +0200 Subject: [PATCH 4/4] Update naming to match factory --- src/tokenManagement/tokenManagementController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tokenManagement/tokenManagementController.ts b/src/tokenManagement/tokenManagementController.ts index a552b895..9a36baf0 100644 --- a/src/tokenManagement/tokenManagementController.ts +++ b/src/tokenManagement/tokenManagementController.ts @@ -276,7 +276,7 @@ export class TokenManagementController { async createTransactionForPausing( sender: IAccount, nonce: bigint, - options: resources.ManagementInput, + options: resources.PausingInput, ): Promise { const transaction = this.factory.createTransactionForPausing(sender.address, options); @@ -298,7 +298,7 @@ export class TokenManagementController { async createTransactionForUnpausing( sender: IAccount, nonce: bigint, - options: resources.ManagementInput, + options: resources.PausingInput, ): Promise { const transaction = this.factory.createTransactionForUnpausing(sender.address, options);