diff --git a/examples/get-address-book.js b/examples/get-address-book.js index 272ab55df..a3863a9f5 100644 --- a/examples/get-address-book.js +++ b/examples/get-address-book.js @@ -15,7 +15,7 @@ async function main() { if (process.env.HEDERA_NETWORK.toLowerCase() === "mainnet") { client - .setMirrorNetwork(["mainnet-public.mirrornode.hedera.com:5600"]) + .setMirrorNetwork(["mainnet-public.mirrornode.hedera.com:443"]) .setTransportSecurity(true); } diff --git a/packages/proto/src/proto b/packages/proto/src/proto index 984d75d06..717b96c1e 160000 --- a/packages/proto/src/proto +++ b/packages/proto/src/proto @@ -1 +1 @@ -Subproject commit 984d75d06219b0073faa20ef83a90b2aa6664448 +Subproject commit 717b96c1ecf3fe5f9f30fe2bcbc731cf02934aae diff --git a/scripts/update-address-books.js b/scripts/update-address-books.js index 85f72b23e..05aac6480 100644 --- a/scripts/update-address-books.js +++ b/scripts/update-address-books.js @@ -6,7 +6,7 @@ async function main() { const networks = [ { name: "previewnet" }, { name: "testnet" }, - { name: "mainnet", url: "mainnet-public.mirrornode.hedera.com:5600" }, + { name: "mainnet", url: "mainnet-public.mirrornode.hedera.com:443" }, ]; for (const network of networks) { diff --git a/src/account/AccountAllowanceAdjustTransaction.js b/src/account/AccountAllowanceAdjustTransaction.js index 2a7d33104..02a262a25 100644 --- a/src/account/AccountAllowanceAdjustTransaction.js +++ b/src/account/AccountAllowanceAdjustTransaction.js @@ -306,6 +306,7 @@ export default class AccountAllowanceAdjustTransaction extends Transaction { serialNumbers: [nftId.serial], ownerAccountId: owner, allSerials: false, + delegatingSpender: null, }) ); } @@ -438,6 +439,7 @@ export default class AccountAllowanceAdjustTransaction extends Transaction { : spenderAccountId, serialNumbers: null, allSerials, + delegatingSpender: null, }) ); diff --git a/src/account/AccountAllowanceApproveTransaction.js b/src/account/AccountAllowanceApproveTransaction.js index fdebb1733..09ca9e043 100644 --- a/src/account/AccountAllowanceApproveTransaction.js +++ b/src/account/AccountAllowanceApproveTransaction.js @@ -163,7 +163,7 @@ export default class AccountAllowanceApproveTransaction extends Transaction { } /** - * @deprecated + * @deprecated - Use `approveHbarAllowance()` instead * @param {AccountId | string} spenderAccountId * @param {number | string | Long | LongObject | BigNumber | Hbar} amount * @returns {AccountAllowanceApproveTransaction} @@ -227,7 +227,7 @@ export default class AccountAllowanceApproveTransaction extends Transaction { } /** - * @deprecated + * @deprecated - Use `approveTokenAllowance()` instead * @param {TokenId | string} tokenId * @param {AccountId | string} spenderAccountId * @param {Long | number} amount @@ -258,13 +258,18 @@ export default class AccountAllowanceApproveTransaction extends Transaction { } /** - * @deprecated + * @deprecated - Use `approveTokenNftAllowance()` instead * @param {NftId | string} nftId * @param {AccountId | string} spenderAccountId * @returns {AccountAllowanceApproveTransaction} */ addTokenNftAllowance(nftId, spenderAccountId) { - return this._approveTokenNftAllowance(nftId, null, spenderAccountId); + return this._approveTokenNftAllowance( + nftId, + null, + spenderAccountId, + null + ); } /** @@ -278,9 +283,15 @@ export default class AccountAllowanceApproveTransaction extends Transaction { * @param {NftId | string} nftId * @param {AccountId | string | null} ownerAccountId * @param {AccountId | string} spenderAccountId + * @param {AccountId | string | null} delegatingSpender * @returns {AccountAllowanceApproveTransaction} */ - _approveTokenNftAllowance(nftId, ownerAccountId, spenderAccountId) { + _approveTokenNftAllowance( + nftId, + ownerAccountId, + spenderAccountId, + delegatingSpender + ) { this._requireNotFrozen(); const id = typeof nftId === "string" ? NftId.fromString(nftId) : nftId; @@ -308,16 +319,17 @@ export default class AccountAllowanceApproveTransaction extends Transaction { this._nftApprovals.push( new TokenNftAllowance({ tokenId: id.tokenId, - spenderAccountId: - typeof spenderAccountId === "string" - ? AccountId.fromString(spenderAccountId) - : spenderAccountId, + spenderAccountId: spender, ownerAccountId: typeof ownerAccountId === "string" ? AccountId.fromString(ownerAccountId) : ownerAccountId, serialNumbers: [id.serial], allSerials: false, + delegatingSpender: + typeof delegatingSpender === "string" + ? AccountId.fromString(delegatingSpender) + : delegatingSpender, }) ); } @@ -335,7 +347,29 @@ export default class AccountAllowanceApproveTransaction extends Transaction { return this._approveTokenNftAllowance( nftId, ownerAccountId, - spenderAccountId + spenderAccountId, + null + ); + } + + /** + * @param {NftId | string} nftId + * @param {AccountId | string} ownerAccountId + * @param {AccountId | string} spenderAccountId + * @param {AccountId | string} delegatingSpender + * @returns {AccountAllowanceApproveTransaction} + */ + approveTokenNftAllowanceWithDelegatingSpender( + nftId, + ownerAccountId, + spenderAccountId, + delegatingSpender + ) { + return this._approveTokenNftAllowance( + nftId, + ownerAccountId, + spenderAccountId, + delegatingSpender ); } @@ -370,6 +404,7 @@ export default class AccountAllowanceApproveTransaction extends Transaction { : ownerAccountId, serialNumbers: null, allSerials, + delegatingSpender: null, }) ); @@ -377,7 +412,7 @@ export default class AccountAllowanceApproveTransaction extends Transaction { } /** - * @deprecated + * @deprecated - Use `approveTokenNftAllowanceAllSerials()` instead * @param {TokenId | string} tokenId * @param {AccountId | string} ownerAccountId * @param {AccountId | string} spenderAccountId @@ -411,6 +446,25 @@ export default class AccountAllowanceApproveTransaction extends Transaction { ); } + /** + * @param {TokenId | string} tokenId + * @param {AccountId | string} ownerAccountId + * @param {AccountId | string} spenderAccountId + * @returns {AccountAllowanceApproveTransaction} + */ + deleteTokenNftAllowanceAllSerials( + tokenId, + ownerAccountId, + spenderAccountId + ) { + return this._approveAllTokenNftAllowance( + tokenId, + ownerAccountId, + spenderAccountId, + false + ); + } + /** * @param {Client} client */ diff --git a/src/account/AccountAllowanceDeleteTransaction.js b/src/account/AccountAllowanceDeleteTransaction.js index c7ee3814a..44037ca77 100644 --- a/src/account/AccountAllowanceDeleteTransaction.js +++ b/src/account/AccountAllowanceDeleteTransaction.js @@ -114,6 +114,8 @@ export default class AccountAllowanceDeleteTransaction extends Transaction { } /** + * @description If you want to remove allowance for all serials of a NFT + * - use AccountAllowanceApproveTransaction().deleteTokenNftAllowanceAllSerials() * @param {NftId | string} nftId * @param {AccountId | string} ownerAccountId * @returns {AccountAllowanceDeleteTransaction} @@ -147,6 +149,7 @@ export default class AccountAllowanceDeleteTransaction extends Transaction { serialNumbers: [id.serial], ownerAccountId: owner, allSerials: false, + delegatingSpender: null, }) ); } diff --git a/src/account/TokenNftAllowance.js b/src/account/TokenNftAllowance.js index 17d152102..7e71303ab 100644 --- a/src/account/TokenNftAllowance.js +++ b/src/account/TokenNftAllowance.js @@ -44,6 +44,7 @@ export default class TokenNftAllowance { * @param {AccountId | null} props.ownerAccountId * @param {Long[] | null} props.serialNumbers * @param {boolean | null} props.allSerials + * @param {AccountId | null} props.delegatingSpender */ constructor(props) { /** @@ -81,6 +82,14 @@ export default class TokenNftAllowance { */ this.allSerials = props.allSerials; + /** + * The account ID of the spender who is granted approvedForAll allowance and granting + * approval on an NFT serial to another spender. + * + * @readonly + */ + this.delegatingSpender = props.delegatingSpender; + Object.freeze(this); } @@ -121,6 +130,14 @@ export default class TokenNftAllowance { ) : [], allSerials, + delegatingSpender: + allowance.delegatingSpender != null + ? AccountId._fromProtobuf( + /**@type {HashgraphProto.proto.IAccountID}*/ ( + allowance.delegatingSpender + ) + ) + : null, }); } @@ -143,6 +160,7 @@ export default class TokenNftAllowance { ownerAccountId, serialNumbers: [], allSerials: null, + delegatingSpender: null, }); } @@ -172,6 +190,7 @@ export default class TokenNftAllowance { ) : [], allSerials: null, + delegatingSpender: null, }); } @@ -193,6 +212,10 @@ export default class TokenNftAllowance { approvedForAll: this.serialNumbers == null ? { value: this.allSerials } : null, serialNumbers: this.serialNumbers, + delegatingSpender: + this.delegatingSpender != null + ? this.delegatingSpender._toProtobuf() + : null, }; } diff --git a/src/client/NodeClient.js b/src/client/NodeClient.js index 68b7c030f..cc0160b8c 100644 --- a/src/client/NodeClient.js +++ b/src/client/NodeClient.js @@ -68,8 +68,8 @@ export const MirrorNetwork = { }, MAINNET: ["mainnet-public.mirrornode.hedera.com:443"], - TESTNET: ["hcs.testnet.mirrornode.hedera.com:5600"], - PREVIEWNET: ["hcs.previewnet.mirrornode.hedera.com:5600"], + TESTNET: ["testnet.mirrornode.hedera.com:443"], + PREVIEWNET: ["previewnet.mirrornode.hedera.com:443"], LOCAL_NODE: ["127.0.0.1:5600"], }; diff --git a/test/unit/AccountAllowanceApproveTransaction.js b/test/unit/AccountAllowanceApproveTransaction.js index b69c6e39c..4924792ce 100644 --- a/test/unit/AccountAllowanceApproveTransaction.js +++ b/test/unit/AccountAllowanceApproveTransaction.js @@ -70,6 +70,7 @@ describe("AccountAllowanceApproveTransaction", function () { spender: spenderAccountId1._toProtobuf(), tokenId: tokenId2._toProtobuf(), approvedForAll: null, + delegatingSpender: null, }, { owner: ownerAccountId._toProtobuf(), @@ -77,6 +78,7 @@ describe("AccountAllowanceApproveTransaction", function () { spender: spenderAccountId2._toProtobuf(), tokenId: tokenId2._toProtobuf(), approvedForAll: null, + delegatingSpender: null, }, { owner: ownerAccountId._toProtobuf(), @@ -84,6 +86,7 @@ describe("AccountAllowanceApproveTransaction", function () { spender: spenderAccountId1._toProtobuf(), tokenId: tokenId1._toProtobuf(), approvedForAll: { value: true }, + delegatingSpender: null, }, ], tokenAllowances: [ diff --git a/test/unit/ManagedNodeAddress.js b/test/unit/ManagedNodeAddress.js index 6265753f0..44668461e 100644 --- a/test/unit/ManagedNodeAddress.js +++ b/test/unit/ManagedNodeAddress.js @@ -41,32 +41,32 @@ describe("ManagedNodeAddress", function () { ); const mirrorNodeAddress = ManagedNodeAddress.fromString( - "hcs.testnet.mirrornode.hedera.com:5600" + "testnet.mirrornode.hedera.com:443" ); expect(mirrorNodeAddress.address).to.be.equal( - "hcs.testnet.mirrornode.hedera.com" + "testnet.mirrornode.hedera.com" ); - expect(mirrorNodeAddress.port).to.be.equal(5600); + expect(mirrorNodeAddress.port).to.be.equal(443); expect(mirrorNodeAddress.toString()).to.be.equal( - "hcs.testnet.mirrornode.hedera.com:5600" + "testnet.mirrornode.hedera.com:443" ); const mirrorNodeAddressSecure = mirrorNodeAddress.toSecure(); expect(mirrorNodeAddressSecure.address).to.be.equal( - "hcs.testnet.mirrornode.hedera.com" + "testnet.mirrornode.hedera.com" ); expect(mirrorNodeAddressSecure.port).to.be.equal(443); expect(mirrorNodeAddressSecure.toString()).to.be.equal( - "hcs.testnet.mirrornode.hedera.com:443" + "testnet.mirrornode.hedera.com:443" ); const mirrorNodeAddressInsecure = mirrorNodeAddressSecure.toInsecure(); expect(mirrorNodeAddressInsecure.address).to.be.equal( - "hcs.testnet.mirrornode.hedera.com" + "testnet.mirrornode.hedera.com" ); expect(mirrorNodeAddressInsecure.port).to.be.equal(5600); expect(mirrorNodeAddressInsecure.toString()).to.be.equal( - "hcs.testnet.mirrornode.hedera.com:5600" + "testnet.mirrornode.hedera.com:5600" ); let err = false; diff --git a/test/unit/NodeClient.js b/test/unit/NodeClient.js index 2ff89ffe2..664a35e24 100644 --- a/test/unit/NodeClient.js +++ b/test/unit/NodeClient.js @@ -147,7 +147,7 @@ describe("Client", function () { }); it("should correctly construct and update mirror network", async function () { - let nodes = ["hcs.testnet.mirrornode.hedera.com:5600"]; + let nodes = ["testnet.mirrornode.hedera.com:443"]; const client = Client.forNetwork( {}, @@ -157,14 +157,14 @@ describe("Client", function () { let network = client.mirrorNetwork; expect(network.length).to.be.equal(1); - expect(network.includes("hcs.testnet.mirrornode.hedera.com:5600")).to.be + expect(network.includes("testnet.mirrornode.hedera.com:443")).to.be .true; client.setMirrorNetwork(nodes); network = client.mirrorNetwork; expect(network.length).to.be.equal(1); - expect(network.includes("hcs.testnet.mirrornode.hedera.com:5600")).to.be + expect(network.includes("testnet.mirrornode.hedera.com:443")).to.be .true; nodes.push("hcs.testnet1.mirrornode.hedera.com:5600"); @@ -173,7 +173,7 @@ describe("Client", function () { network = client.mirrorNetwork; expect(network.length).to.be.equal(2); - expect(network.includes("hcs.testnet.mirrornode.hedera.com:5600")).to.be + expect(network.includes("testnet.mirrornode.hedera.com:443")).to.be .true; expect(network.includes("hcs.testnet1.mirrornode.hedera.com:5600")).to .be.true; diff --git a/test/unit/TokenNftAllowance.js b/test/unit/TokenNftAllowance.js index cd89a550e..d0f1ff47c 100644 --- a/test/unit/TokenNftAllowance.js +++ b/test/unit/TokenNftAllowance.js @@ -16,6 +16,7 @@ describe("TokenNftAllowance", function () { spenderAccountId, serialNumbers: [serial], allSerials: false, + delegatingSpender: null, }); expect(allowance._toProtobuf()).to.deep.equal({ @@ -24,6 +25,7 @@ describe("TokenNftAllowance", function () { spender: spenderAccountId._toProtobuf(), serialNumbers: [serial], approvedForAll: null, + delegatingSpender: null, }); }); @@ -38,6 +40,7 @@ describe("TokenNftAllowance", function () { spenderAccountId, serialNumbers: null, allSerials: true, + delegatingSpender: null, }); expect(allowance._toProtobuf()).to.deep.equal({ @@ -46,6 +49,7 @@ describe("TokenNftAllowance", function () { spender: spenderAccountId._toProtobuf(), serialNumbers: null, approvedForAll: { value: true }, + delegatingSpender: null, }); }); });