@hiero-ledger/sdk 2.80.0 → 2.81.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -7
- package/dist/umd.js +2213 -318
- package/dist/umd.js.map +1 -0
- package/dist/umd.min.js +6 -5
- package/dist/umd.min.js.map +1 -0
- package/lib/Executable.cjs +7 -4
- package/lib/Executable.js +1 -1
- package/lib/Executable.js.map +1 -1
- package/lib/PublicKey.cjs +45 -26
- package/lib/PublicKey.d.ts +12 -0
- package/lib/PublicKey.js +1 -1
- package/lib/PublicKey.js.map +1 -1
- package/lib/RequestType.cjs +19 -1
- package/lib/RequestType.d.ts +2 -0
- package/lib/RequestType.js +1 -1
- package/lib/RequestType.js.map +1 -1
- package/lib/Status.cjs +203 -252
- package/lib/Status.d.ts +8 -6
- package/lib/Status.js +1 -1
- package/lib/Status.js.map +1 -1
- package/lib/Transfer.cjs +25 -2
- package/lib/Transfer.d.ts +4 -0
- package/lib/Transfer.js +1 -1
- package/lib/Transfer.js.map +1 -1
- package/lib/account/AccountCreateTransaction.cjs +38 -0
- package/lib/account/AccountCreateTransaction.d.ts +21 -0
- package/lib/account/AccountCreateTransaction.js +1 -1
- package/lib/account/AccountCreateTransaction.js.map +1 -1
- package/lib/account/AccountUpdateTransaction.cjs +74 -1
- package/lib/account/AccountUpdateTransaction.d.ts +43 -0
- package/lib/account/AccountUpdateTransaction.js +1 -1
- package/lib/account/AccountUpdateTransaction.js.map +1 -1
- package/lib/account/TransferTransaction.cjs +57 -9
- package/lib/account/TransferTransaction.d.ts +31 -1
- package/lib/account/TransferTransaction.js +1 -1
- package/lib/account/TransferTransaction.js.map +1 -1
- package/lib/browser.js +1 -1
- package/lib/client/Client.cjs +38 -0
- package/lib/client/Client.d.ts +30 -0
- package/lib/client/Client.js +1 -1
- package/lib/client/Client.js.map +1 -1
- package/lib/client/addressbooks/mainnet.cjs +1 -1
- package/lib/client/addressbooks/mainnet.d.ts +1 -1
- package/lib/client/addressbooks/mainnet.js +1 -1
- package/lib/client/addressbooks/mainnet.js.map +1 -1
- package/lib/client/addressbooks/previewnet.cjs +1 -1
- package/lib/client/addressbooks/previewnet.d.ts +1 -1
- package/lib/client/addressbooks/previewnet.js +1 -1
- package/lib/client/addressbooks/previewnet.js.map +1 -1
- package/lib/client/addressbooks/testnet.cjs +1 -1
- package/lib/client/addressbooks/testnet.d.ts +1 -1
- package/lib/client/addressbooks/testnet.js +1 -1
- package/lib/client/addressbooks/testnet.js.map +1 -1
- package/lib/contract/ContractCreateTransaction.cjs +37 -1
- package/lib/contract/ContractCreateTransaction.d.ts +21 -0
- package/lib/contract/ContractCreateTransaction.js +1 -1
- package/lib/contract/ContractCreateTransaction.js.map +1 -1
- package/lib/contract/ContractUpdateTransaction.cjs +74 -1
- package/lib/contract/ContractUpdateTransaction.d.ts +43 -0
- package/lib/contract/ContractUpdateTransaction.js +1 -1
- package/lib/contract/ContractUpdateTransaction.js.map +1 -1
- package/lib/exports.cjs +103 -0
- package/lib/exports.d.ts +13 -0
- package/lib/exports.js +1 -1
- package/lib/exports.js.map +1 -1
- package/lib/hooks/EvmHook.cjs +84 -0
- package/lib/hooks/EvmHook.d.ts +51 -0
- package/lib/hooks/EvmHook.js +2 -0
- package/lib/hooks/EvmHook.js.map +1 -0
- package/lib/hooks/EvmHookCall.cjs +103 -0
- package/lib/hooks/EvmHookCall.d.ts +69 -0
- package/lib/hooks/EvmHookCall.js +2 -0
- package/lib/hooks/EvmHookCall.js.map +1 -0
- package/lib/hooks/EvmHookMappingEntry.cjs +135 -0
- package/lib/hooks/EvmHookMappingEntry.d.ts +84 -0
- package/lib/hooks/EvmHookMappingEntry.js +2 -0
- package/lib/hooks/EvmHookMappingEntry.js.map +1 -0
- package/lib/hooks/EvmHookStorageUpdate.cjs +238 -0
- package/lib/hooks/EvmHookStorageUpdate.d.ts +144 -0
- package/lib/hooks/EvmHookStorageUpdate.js +2 -0
- package/lib/hooks/EvmHookStorageUpdate.js.map +1 -0
- package/lib/hooks/FungibleHookCall.cjs +67 -0
- package/lib/hooks/FungibleHookCall.d.ts +50 -0
- package/lib/hooks/FungibleHookCall.js +2 -0
- package/lib/hooks/FungibleHookCall.js.map +1 -0
- package/lib/hooks/FungibleHookType.cjs +11 -0
- package/lib/hooks/FungibleHookType.d.ts +5 -0
- package/lib/hooks/FungibleHookType.js +2 -0
- package/lib/hooks/FungibleHookType.js.map +1 -0
- package/lib/hooks/HookCall.cjs +99 -0
- package/lib/hooks/HookCall.d.ts +64 -0
- package/lib/hooks/HookCall.js +2 -0
- package/lib/hooks/HookCall.js.map +1 -0
- package/lib/hooks/HookCreationDetails.cjs +149 -0
- package/lib/hooks/HookCreationDetails.d.ts +91 -0
- package/lib/hooks/HookCreationDetails.js +2 -0
- package/lib/hooks/HookCreationDetails.js.map +1 -0
- package/lib/hooks/HookEntityId.cjs +67 -0
- package/lib/hooks/HookEntityId.d.ts +41 -0
- package/lib/hooks/HookEntityId.js +2 -0
- package/lib/hooks/HookEntityId.js.map +1 -0
- package/lib/hooks/HookExtensionPoint.cjs +31 -0
- package/lib/hooks/HookExtensionPoint.d.ts +16 -0
- package/lib/hooks/HookExtensionPoint.js +2 -0
- package/lib/hooks/HookExtensionPoint.js.map +1 -0
- package/lib/hooks/HookId.cjs +101 -0
- package/lib/hooks/HookId.d.ts +63 -0
- package/lib/hooks/HookId.js +2 -0
- package/lib/hooks/HookId.js.map +1 -0
- package/lib/hooks/HookStoreTransaction.cjs +157 -0
- package/lib/hooks/HookStoreTransaction.d.ts +77 -0
- package/lib/hooks/HookStoreTransaction.js +2 -0
- package/lib/hooks/HookStoreTransaction.js.map +1 -0
- package/lib/hooks/NftHookCall.cjs +67 -0
- package/lib/hooks/NftHookCall.d.ts +50 -0
- package/lib/hooks/NftHookCall.js +2 -0
- package/lib/hooks/NftHookCall.js.map +1 -0
- package/lib/hooks/NftHookType.cjs +13 -0
- package/lib/hooks/NftHookType.d.ts +7 -0
- package/lib/hooks/NftHookType.js +2 -0
- package/lib/hooks/NftHookType.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/native.js +1 -1
- package/lib/token/AbstractTokenTransferTransaction.cjs +17 -5
- package/lib/token/AbstractTokenTransferTransaction.d.ts +13 -2
- package/lib/token/AbstractTokenTransferTransaction.js +1 -1
- package/lib/token/AbstractTokenTransferTransaction.js.map +1 -1
- package/lib/token/TokenAirdropTransaction.cjs +1 -1
- package/lib/token/TokenAirdropTransaction.js +1 -1
- package/lib/token/TokenAirdropTransaction.js.map +1 -1
- package/lib/token/TokenNftTransfer.cjs +51 -2
- package/lib/token/TokenNftTransfer.d.ts +7 -0
- package/lib/token/TokenNftTransfer.js +1 -1
- package/lib/token/TokenNftTransfer.js.map +1 -1
- package/lib/token/TokenTransfer.cjs +26 -2
- package/lib/token/TokenTransfer.d.ts +4 -0
- package/lib/token/TokenTransfer.js +1 -1
- package/lib/token/TokenTransfer.js.map +1 -1
- package/lib/transaction/Transaction.cjs +2 -1
- package/lib/transaction/Transaction.js +1 -1
- package/lib/transaction/Transaction.js.map +1 -1
- package/lib/transaction/TransactionResponse.cjs +82 -9
- package/lib/transaction/TransactionResponse.d.ts +33 -2
- package/lib/transaction/TransactionResponse.js +1 -1
- package/lib/transaction/TransactionResponse.js.map +1 -1
- package/lib/version.js +1 -1
- package/package.json +15 -13
- package/src/Executable.js +10 -7
- package/src/PublicKey.js +53 -36
- package/src/RequestType.js +18 -0
- package/src/Status.js +201 -252
- package/src/Transfer.js +33 -1
- package/src/account/AccountCreateTransaction.js +39 -0
- package/src/account/AccountUpdateTransaction.js +78 -0
- package/src/account/TransferTransaction.js +84 -8
- package/src/client/Client.js +38 -0
- package/src/client/addressbooks/mainnet.js +1 -1
- package/src/client/addressbooks/previewnet.js +1 -1
- package/src/client/addressbooks/testnet.js +1 -1
- package/src/contract/ContractCreateTransaction.js +37 -0
- package/src/contract/ContractUpdateTransaction.js +80 -0
- package/src/exports.js +17 -0
- package/src/hooks/EvmHook.js +83 -0
- package/src/hooks/EvmHookCall.js +100 -0
- package/src/hooks/EvmHookMappingEntry.js +140 -0
- package/src/hooks/EvmHookStorageUpdate.js +257 -0
- package/src/hooks/FungibleHookCall.js +65 -0
- package/src/hooks/FungibleHookType.js +6 -0
- package/src/hooks/HookCall.js +97 -0
- package/src/hooks/HookCreationDetails.js +155 -0
- package/src/hooks/HookEntityId.js +67 -0
- package/src/hooks/HookExtensionPoint.js +25 -0
- package/src/hooks/HookId.js +102 -0
- package/src/hooks/HookStoreTransaction.js +185 -0
- package/src/hooks/NftHookCall.js +64 -0
- package/src/hooks/NftHookType.js +8 -0
- package/src/token/AbstractTokenTransferTransaction.js +16 -1
- package/src/token/TokenAirdropTransaction.js +1 -0
- package/src/token/TokenNftTransfer.js +68 -1
- package/src/token/TokenTransfer.js +34 -1
- package/src/transaction/Transaction.js +3 -0
- package/src/transaction/TransactionResponse.js +98 -13
package/lib/Transfer.cjs
CHANGED
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _AccountId = _interopRequireDefault(require("./account/AccountId.cjs"));
|
|
8
8
|
var _Hbar = _interopRequireDefault(require("./Hbar.cjs"));
|
|
9
|
+
var _FungibleHookCall = _interopRequireDefault(require("./hooks/FungibleHookCall.cjs"));
|
|
10
|
+
var _FungibleHookType = _interopRequireDefault(require("./hooks/FungibleHookType.cjs"));
|
|
9
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
12
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
13
|
|
|
@@ -37,6 +39,7 @@ class Transfer {
|
|
|
37
39
|
* @param {AccountId | string} props.accountId
|
|
38
40
|
* @param {number | string | Long | BigNumber | Hbar} props.amount
|
|
39
41
|
* @param {boolean} props.isApproved
|
|
42
|
+
* @param {FungibleHookCall} [props.hookCall]
|
|
40
43
|
*/
|
|
41
44
|
constructor(props) {
|
|
42
45
|
/**
|
|
@@ -51,6 +54,7 @@ class Transfer {
|
|
|
51
54
|
*/
|
|
52
55
|
this.amount = props.amount instanceof _Hbar.default ? props.amount : new _Hbar.default(props.amount);
|
|
53
56
|
this.isApproved = props.isApproved;
|
|
57
|
+
this.hookCall = props.hookCall;
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
/**
|
|
@@ -61,11 +65,18 @@ class Transfer {
|
|
|
61
65
|
static _fromProtobuf(accountAmounts) {
|
|
62
66
|
const transfers = [];
|
|
63
67
|
for (const transfer of accountAmounts) {
|
|
68
|
+
let hookCall = undefined;
|
|
69
|
+
if (transfer.preTxAllowanceHook != null) {
|
|
70
|
+
hookCall = _FungibleHookCall.default._fromProtobufWithType(transfer.preTxAllowanceHook, _FungibleHookType.default.PRE_TX_ALLOWANCE_HOOK);
|
|
71
|
+
} else if (transfer.prePostTxAllowanceHook != null) {
|
|
72
|
+
hookCall = _FungibleHookCall.default._fromProtobufWithType(transfer.prePostTxAllowanceHook, _FungibleHookType.default.PRE_POST_TX_ALLOWANCE_HOOK);
|
|
73
|
+
}
|
|
64
74
|
transfers.push(new Transfer({
|
|
65
75
|
accountId: _AccountId.default._fromProtobuf(/** @type {HieroProto.proto.IAccountID} */
|
|
66
76
|
transfer.accountID),
|
|
67
77
|
amount: _Hbar.default.fromTinybars(transfer.amount != null ? transfer.amount : 0),
|
|
68
|
-
isApproved: (/** @type {boolean} */transfer.isApproval)
|
|
78
|
+
isApproved: (/** @type {boolean} */transfer.isApproval),
|
|
79
|
+
hookCall
|
|
69
80
|
}));
|
|
70
81
|
}
|
|
71
82
|
return transfers;
|
|
@@ -76,11 +87,23 @@ class Transfer {
|
|
|
76
87
|
* @returns {HieroProto.proto.IAccountAmount}
|
|
77
88
|
*/
|
|
78
89
|
_toProtobuf() {
|
|
79
|
-
|
|
90
|
+
/** @type {HieroProto.proto.IAccountAmount} */
|
|
91
|
+
const result = {
|
|
80
92
|
accountID: this.accountId._toProtobuf(),
|
|
81
93
|
amount: this.amount.toTinybars(),
|
|
82
94
|
isApproval: this.isApproved
|
|
83
95
|
};
|
|
96
|
+
if (this.hookCall != null) {
|
|
97
|
+
switch (this.hookCall.type) {
|
|
98
|
+
case _FungibleHookType.default.PRE_TX_ALLOWANCE_HOOK:
|
|
99
|
+
result.preTxAllowanceHook = this.hookCall._toProtobuf();
|
|
100
|
+
break;
|
|
101
|
+
case _FungibleHookType.default.PRE_POST_TX_ALLOWANCE_HOOK:
|
|
102
|
+
result.prePostTxAllowanceHook = this.hookCall._toProtobuf();
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
84
107
|
}
|
|
85
108
|
|
|
86
109
|
/**
|
package/lib/Transfer.d.ts
CHANGED
|
@@ -29,11 +29,13 @@ export default class Transfer {
|
|
|
29
29
|
* @param {AccountId | string} props.accountId
|
|
30
30
|
* @param {number | string | Long | BigNumber | Hbar} props.amount
|
|
31
31
|
* @param {boolean} props.isApproved
|
|
32
|
+
* @param {FungibleHookCall} [props.hookCall]
|
|
32
33
|
*/
|
|
33
34
|
constructor(props: {
|
|
34
35
|
accountId: AccountId | string;
|
|
35
36
|
amount: number | string | Long | BigNumber | Hbar;
|
|
36
37
|
isApproved: boolean;
|
|
38
|
+
hookCall?: FungibleHookCall | undefined;
|
|
37
39
|
});
|
|
38
40
|
/**
|
|
39
41
|
* The Account ID that sends or receives cryptocurrency.
|
|
@@ -46,6 +48,7 @@ export default class Transfer {
|
|
|
46
48
|
*/
|
|
47
49
|
amount: Hbar;
|
|
48
50
|
isApproved: boolean;
|
|
51
|
+
hookCall: FungibleHookCall | undefined;
|
|
49
52
|
/**
|
|
50
53
|
* @internal
|
|
51
54
|
* @returns {HieroProto.proto.IAccountAmount}
|
|
@@ -75,3 +78,4 @@ export type BigNumber = import("bignumber.js").default;
|
|
|
75
78
|
export type Long = import("long");
|
|
76
79
|
import AccountId from "./account/AccountId.js";
|
|
77
80
|
import Hbar from "./Hbar.js";
|
|
81
|
+
import FungibleHookCall from "./hooks/FungibleHookCall.js";
|
package/lib/Transfer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"./account/AccountId.js";import t from"./Hbar.js";import r from"./hooks/FungibleHookCall.js";import n from"./hooks/FungibleHookType.js";class a{constructor(r){this.accountId=r.accountId instanceof o?r.accountId:o.fromString(r.accountId),this.amount=r.amount instanceof t?r.amount:new t(r.amount),this.isApproved=r.isApproved,this.hookCall=r.hookCall}static _fromProtobuf(s){const i=[];for(const u of s){let s;null!=u.preTxAllowanceHook?s=r._fromProtobufWithType(u.preTxAllowanceHook,n.PRE_TX_ALLOWANCE_HOOK):null!=u.prePostTxAllowanceHook&&(s=r._fromProtobufWithType(u.prePostTxAllowanceHook,n.PRE_POST_TX_ALLOWANCE_HOOK)),i.push(new a({accountId:o._fromProtobuf(u.accountID),amount:t.fromTinybars(null!=u.amount?u.amount:0),isApproved:u.isApproval,hookCall:s}))}return i}_toProtobuf(){const o={accountID:this.accountId._toProtobuf(),amount:this.amount.toTinybars(),isApproval:this.isApproved};if(null!=this.hookCall)switch(this.hookCall.type){case n.PRE_TX_ALLOWANCE_HOOK:o.preTxAllowanceHook=this.hookCall._toProtobuf();break;case n.PRE_POST_TX_ALLOWANCE_HOOK:o.prePostTxAllowanceHook=this.hookCall._toProtobuf()}return o}toJSON(){return{accountId:this.accountId.toString(),amount:this.amount.toTinybars().toString(),isApproved:this.isApproved}}toString(){return JSON.stringify(this.toJSON())}}export{a as default};
|
|
2
2
|
//# sourceMappingURL=Transfer.js.map
|
package/lib/Transfer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transfer.js","sources":["../src/Transfer.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport AccountId from \"./account/AccountId.js\";\nimport Hbar from \"./Hbar.js\";\n\n/**\n * @typedef {object} TransferJSON\n * @property {string} accountId\n * @property {string} amount\n * @property {boolean} isApproved\n */\n\n/**\n * @namespace proto\n * @typedef {import(\"@hiero-ledger/proto\").proto.IAccountAmount} HieroProto.proto.IAccountAmount\n * @typedef {import(\"@hiero-ledger/proto\").proto.IAccountID} HieroProto.proto.IAccountID\n */\n\n/**\n * @typedef {import(\"bignumber.js\").default} BigNumber\n * @typedef {import(\"long\")} Long\n */\n\n/**\n * An account, and the amount that it sends or receives during a cryptocurrency transfer.\n */\nexport default class Transfer {\n /**\n * @internal\n * @param {object} props\n * @param {AccountId | string} props.accountId\n * @param {number | string | Long | BigNumber | Hbar} props.amount\n * @param {boolean} props.isApproved\n */\n constructor(props) {\n /**\n * The Account ID that sends or receives cryptocurrency.\n *\n * @readonly\n */\n this.accountId =\n props.accountId instanceof AccountId\n ? props.accountId\n : AccountId.fromString(props.accountId);\n\n /**\n * The amount of tinybars that the account sends(negative) or receives(positive).\n */\n this.amount =\n props.amount instanceof Hbar\n ? props.amount\n : new Hbar(props.amount);\n\n this.isApproved = props.isApproved;\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.IAccountAmount[]} accountAmounts\n * @returns {Transfer[]}\n */\n static _fromProtobuf(accountAmounts) {\n const transfers = [];\n\n for (const transfer of accountAmounts) {\n transfers.push(\n new Transfer({\n accountId: AccountId._fromProtobuf(\n /** @type {HieroProto.proto.IAccountID} */ (\n transfer.accountID\n ),\n ),\n amount: Hbar.fromTinybars(\n transfer.amount != null ? transfer.amount : 0,\n ),\n isApproved: /** @type {boolean} */ (transfer.isApproval),\n }),\n );\n }\n\n return transfers;\n }\n\n /**\n * @internal\n * @returns {HieroProto.proto.IAccountAmount}\n */\n _toProtobuf() {\n
|
|
1
|
+
{"version":3,"file":"Transfer.js","sources":["../src/Transfer.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport AccountId from \"./account/AccountId.js\";\nimport Hbar from \"./Hbar.js\";\nimport FungibleHookCall from \"./hooks/FungibleHookCall.js\";\nimport FungibleHookType from \"./hooks/FungibleHookType.js\";\n\n/**\n * @typedef {object} TransferJSON\n * @property {string} accountId\n * @property {string} amount\n * @property {boolean} isApproved\n */\n\n/**\n * @namespace proto\n * @typedef {import(\"@hiero-ledger/proto\").proto.IAccountAmount} HieroProto.proto.IAccountAmount\n * @typedef {import(\"@hiero-ledger/proto\").proto.IAccountID} HieroProto.proto.IAccountID\n */\n\n/**\n * @typedef {import(\"bignumber.js\").default} BigNumber\n * @typedef {import(\"long\")} Long\n */\n\n/**\n * An account, and the amount that it sends or receives during a cryptocurrency transfer.\n */\nexport default class Transfer {\n /**\n * @internal\n * @param {object} props\n * @param {AccountId | string} props.accountId\n * @param {number | string | Long | BigNumber | Hbar} props.amount\n * @param {boolean} props.isApproved\n * @param {FungibleHookCall} [props.hookCall]\n */\n constructor(props) {\n /**\n * The Account ID that sends or receives cryptocurrency.\n *\n * @readonly\n */\n this.accountId =\n props.accountId instanceof AccountId\n ? props.accountId\n : AccountId.fromString(props.accountId);\n\n /**\n * The amount of tinybars that the account sends(negative) or receives(positive).\n */\n this.amount =\n props.amount instanceof Hbar\n ? props.amount\n : new Hbar(props.amount);\n\n this.isApproved = props.isApproved;\n this.hookCall = props.hookCall;\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.IAccountAmount[]} accountAmounts\n * @returns {Transfer[]}\n */\n static _fromProtobuf(accountAmounts) {\n const transfers = [];\n\n for (const transfer of accountAmounts) {\n let hookCall = undefined;\n if (transfer.preTxAllowanceHook != null) {\n hookCall = FungibleHookCall._fromProtobufWithType(\n transfer.preTxAllowanceHook,\n FungibleHookType.PRE_TX_ALLOWANCE_HOOK,\n );\n } else if (transfer.prePostTxAllowanceHook != null) {\n hookCall = FungibleHookCall._fromProtobufWithType(\n transfer.prePostTxAllowanceHook,\n FungibleHookType.PRE_POST_TX_ALLOWANCE_HOOK,\n );\n }\n\n transfers.push(\n new Transfer({\n accountId: AccountId._fromProtobuf(\n /** @type {HieroProto.proto.IAccountID} */ (\n transfer.accountID\n ),\n ),\n amount: Hbar.fromTinybars(\n transfer.amount != null ? transfer.amount : 0,\n ),\n isApproved: /** @type {boolean} */ (transfer.isApproval),\n hookCall,\n }),\n );\n }\n\n return transfers;\n }\n\n /**\n * @internal\n * @returns {HieroProto.proto.IAccountAmount}\n */\n _toProtobuf() {\n /** @type {HieroProto.proto.IAccountAmount} */\n const result = {\n accountID: this.accountId._toProtobuf(),\n amount: this.amount.toTinybars(),\n isApproval: this.isApproved,\n };\n\n if (this.hookCall != null) {\n switch (this.hookCall.type) {\n case FungibleHookType.PRE_TX_ALLOWANCE_HOOK:\n result.preTxAllowanceHook = this.hookCall._toProtobuf();\n break;\n case FungibleHookType.PRE_POST_TX_ALLOWANCE_HOOK:\n result.prePostTxAllowanceHook = this.hookCall._toProtobuf();\n break;\n }\n }\n\n return result;\n }\n\n /**\n * @returns {TransferJSON}\n */\n toJSON() {\n return {\n accountId: this.accountId.toString(),\n amount: this.amount.toTinybars().toString(),\n isApproved: this.isApproved,\n };\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON());\n }\n}\n"],"names":["Transfer","constructor","props","this","accountId","AccountId","fromString","amount","Hbar","isApproved","hookCall","_fromProtobuf","accountAmounts","transfers","transfer","preTxAllowanceHook","FungibleHookCall","_fromProtobufWithType","FungibleHookType","PRE_TX_ALLOWANCE_HOOK","prePostTxAllowanceHook","PRE_POST_TX_ALLOWANCE_HOOK","push","fromTinybars","_toProtobuf","result","accountID","toTinybars","isApproval","type","toJSON","toString","JSON","stringify"],"mappings":"qJA4Be,MAAMA,EASjB,WAAAC,CAAYC,GAMRC,KAAKC,UACDF,EAAME,qBAAqBC,EACrBH,EAAME,UACNC,EAAUC,WAAWJ,EAAME,WAKrCD,KAAKI,OACDL,EAAMK,kBAAkBC,EAClBN,EAAMK,OACN,IAAIC,EAAKN,EAAMK,QAEzBJ,KAAKM,WAAaP,EAAMO,WACxBN,KAAKO,SAAWR,EAAMQ,QAC9B,CAOI,oBAAOC,CAAcC,GACjB,MAAMC,EAAY,GAElB,IAAK,MAAMC,KAAYF,EAAgB,CACnC,IAAIF,EAC+B,MAA/BI,EAASC,mBACTL,EAAWM,EAAiBC,sBACxBH,EAASC,mBACTG,EAAiBC,uBAEqB,MAAnCL,EAASM,yBAChBV,EAAWM,EAAiBC,sBACxBH,EAASM,uBACTF,EAAiBG,6BAIzBR,EAAUS,KACN,IAAItB,EAAS,CACTI,UAAWC,EAAUM,cAEbG,EAC5B,WAEoBP,OAAQC,EAAKe,aACU,MAAnBT,EAASP,OAAiBO,EAASP,OAAS,GAEhDE,WAAoCK,EAAmB,WACvDJ,aAGpB,CAEQ,OAAOG,CACf,CAMI,WAAAW,GAEI,MAAMC,EAAS,CACXC,UAAWvB,KAAKC,UAAUoB,cAC1BjB,OAAQJ,KAAKI,OAAOoB,aACpBC,WAAYzB,KAAKM,YAGrB,GAAqB,MAAjBN,KAAKO,SACL,OAAQP,KAAKO,SAASmB,MAClB,KAAKX,EAAiBC,sBAClBM,EAAOV,mBAAqBZ,KAAKO,SAASc,cAC1C,MACJ,KAAKN,EAAiBG,2BAClBI,EAAOL,uBAAyBjB,KAAKO,SAASc,cAK1D,OAAOC,CACf,CAKI,MAAAK,GACI,MAAO,CACH1B,UAAWD,KAAKC,UAAU2B,WAC1BxB,OAAQJ,KAAKI,OAAOoB,aAAaI,WACjCtB,WAAYN,KAAKM,WAE7B,CAKI,QAAAsB,GACI,OAAOC,KAAKC,UAAU9B,KAAK2B,SACnC"}
|
|
@@ -44,6 +44,7 @@ class AccountCreateTransaction extends _Transaction.default {
|
|
|
44
44
|
* @param {Long | number} [props.stakedNodeId]
|
|
45
45
|
* @param {boolean} [props.declineStakingReward]
|
|
46
46
|
* @param {EvmAddress} [props.alias]
|
|
47
|
+
* @param {import("../hooks/HookCreationDetails.js").default[]} [props.hooks]
|
|
47
48
|
*/
|
|
48
49
|
constructor(props = {}) {
|
|
49
50
|
super();
|
|
@@ -125,6 +126,17 @@ class AccountCreateTransaction extends _Transaction.default {
|
|
|
125
126
|
* @type {?EvmAddress}
|
|
126
127
|
*/
|
|
127
128
|
this._alias = null;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @private
|
|
132
|
+
* @type {import("../hooks/HookCreationDetails.js").default[]}
|
|
133
|
+
*/
|
|
134
|
+
this._hooks = [];
|
|
135
|
+
if (props.hooks != null) {
|
|
136
|
+
props.hooks.forEach(hook => {
|
|
137
|
+
this.addHook(hook);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
128
140
|
if (props.key != null) {
|
|
129
141
|
this.setKeyWithoutAlias(props.key);
|
|
130
142
|
}
|
|
@@ -546,10 +558,36 @@ class AccountCreateTransaction extends _Transaction.default {
|
|
|
546
558
|
stakedAccountId: this.stakedAccountId != null ? this.stakedAccountId._toProtobuf() : null,
|
|
547
559
|
stakedNodeId: this.stakedNodeId,
|
|
548
560
|
declineReward: this.declineStakingRewards,
|
|
561
|
+
hookCreationDetails: this._hooks.map(hook => hook._toProtobuf()),
|
|
549
562
|
alias
|
|
550
563
|
};
|
|
551
564
|
}
|
|
552
565
|
|
|
566
|
+
/**
|
|
567
|
+
* @param {import("../hooks/HookCreationDetails.js").default} hook
|
|
568
|
+
* @returns {this}
|
|
569
|
+
*/
|
|
570
|
+
addHook(hook) {
|
|
571
|
+
this._hooks.push(hook);
|
|
572
|
+
return this;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* @param {import("../hooks/HookCreationDetails.js").default[]} hooks
|
|
577
|
+
* @returns {this}
|
|
578
|
+
*/
|
|
579
|
+
setHooks(hooks) {
|
|
580
|
+
this._hooks = hooks;
|
|
581
|
+
return this;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* @returns {import("../hooks/HookCreationDetails.js").default[]}
|
|
586
|
+
*/
|
|
587
|
+
get hooks() {
|
|
588
|
+
return this._hooks;
|
|
589
|
+
}
|
|
590
|
+
|
|
553
591
|
/**
|
|
554
592
|
* @returns {string}
|
|
555
593
|
*/
|
|
@@ -32,6 +32,7 @@ export default class AccountCreateTransaction extends Transaction {
|
|
|
32
32
|
* @param {Long | number} [props.stakedNodeId]
|
|
33
33
|
* @param {boolean} [props.declineStakingReward]
|
|
34
34
|
* @param {EvmAddress} [props.alias]
|
|
35
|
+
* @param {import("../hooks/HookCreationDetails.js").default[]} [props.hooks]
|
|
35
36
|
*/
|
|
36
37
|
constructor(props?: {
|
|
37
38
|
key?: Key | undefined;
|
|
@@ -45,6 +46,7 @@ export default class AccountCreateTransaction extends Transaction {
|
|
|
45
46
|
stakedNodeId?: number | Long | undefined;
|
|
46
47
|
declineStakingReward?: boolean | undefined;
|
|
47
48
|
alias?: EvmAddress | undefined;
|
|
49
|
+
hooks?: import("../hooks/HookCreationDetails.js").default[] | undefined;
|
|
48
50
|
});
|
|
49
51
|
/**
|
|
50
52
|
* @private
|
|
@@ -111,6 +113,11 @@ export default class AccountCreateTransaction extends Transaction {
|
|
|
111
113
|
* @type {?EvmAddress}
|
|
112
114
|
*/
|
|
113
115
|
private _alias;
|
|
116
|
+
/**
|
|
117
|
+
* @private
|
|
118
|
+
* @type {import("../hooks/HookCreationDetails.js").default[]}
|
|
119
|
+
*/
|
|
120
|
+
private _hooks;
|
|
114
121
|
/**
|
|
115
122
|
* @returns {?Key}
|
|
116
123
|
*/
|
|
@@ -293,6 +300,20 @@ export default class AccountCreateTransaction extends Transaction {
|
|
|
293
300
|
* @returns {HieroProto.proto.ICryptoCreateTransactionBody}
|
|
294
301
|
*/
|
|
295
302
|
protected override _makeTransactionData(): HieroProto.proto.ICryptoCreateTransactionBody;
|
|
303
|
+
/**
|
|
304
|
+
* @param {import("../hooks/HookCreationDetails.js").default} hook
|
|
305
|
+
* @returns {this}
|
|
306
|
+
*/
|
|
307
|
+
addHook(hook: import("../hooks/HookCreationDetails.js").default): this;
|
|
308
|
+
/**
|
|
309
|
+
* @param {import("../hooks/HookCreationDetails.js").default[]} hooks
|
|
310
|
+
* @returns {this}
|
|
311
|
+
*/
|
|
312
|
+
setHooks(hooks: import("../hooks/HookCreationDetails.js").default[]): this;
|
|
313
|
+
/**
|
|
314
|
+
* @returns {import("../hooks/HookCreationDetails.js").default[]}
|
|
315
|
+
*/
|
|
316
|
+
get hooks(): import("../hooks/HookCreationDetails.js").default[];
|
|
296
317
|
}
|
|
297
318
|
export type BigNumber = import("bignumber.js").default;
|
|
298
319
|
export type Channel = import("../channel/Channel.js").default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"@hiero-ledger/proto";import e from"../Hbar.js";import t from"./AccountId.js";import i,{TRANSACTION_REGISTRY as o,DEFAULT_RECORD_THRESHOLD as
|
|
1
|
+
import"@hiero-ledger/proto";import e from"../Hbar.js";import t from"./AccountId.js";import i,{TRANSACTION_REGISTRY as o,DEFAULT_RECORD_THRESHOLD as s,DEFAULT_AUTO_RENEW_PERIOD as r}from"../transaction/Transaction.js";import n from"../Duration.js";import a from"long";import u from"../Key.js";import c from"../PrivateKey.js";import d from"../EvmAddress.js";import l from"../PublicKey.js";class h extends i{constructor(e={}){super(),this._key=null,this._initialBalance=null,this._sendRecordThreshold=s,this._receiveRecordThreshold=s,this._receiverSignatureRequired=!1,this._proxyAccountId=null,this._autoRenewPeriod=new n(r),this._accountMemo=null,this._maxAutomaticTokenAssociations=null,this._stakedAccountId=null,this._stakedNodeId=null,this._declineStakingReward=!1,this._alias=null,this._hooks=[],null!=e.hooks&&e.hooks.forEach(e=>{this.addHook(e)}),null!=e.key&&this.setKeyWithoutAlias(e.key),null!=e.receiverSignatureRequired&&this.setReceiverSignatureRequired(e.receiverSignatureRequired),null!=e.initialBalance&&this.setInitialBalance(e.initialBalance),null!=e.proxyAccountId&&this.setProxyAccountId(e.proxyAccountId),null!=e.autoRenewPeriod&&this.setAutoRenewPeriod(e.autoRenewPeriod),null!=e.accountMemo&&this.setAccountMemo(e.accountMemo),null!=e.maxAutomaticTokenAssociations&&this.setMaxAutomaticTokenAssociations(e.maxAutomaticTokenAssociations),null!=e.stakedAccountId&&this.setStakedAccountId(e.stakedAccountId),null!=e.stakedNodeId&&this.setStakedNodeId(e.stakedNodeId),null!=e.declineStakingReward&&this.setDeclineStakingReward(e.declineStakingReward),null!=e.alias&&this.setAlias(e.alias)}static _fromProtobuf(o,s,r,n,a){const c=a[0].cryptoCreateAccount;let l;return null!=c.alias&&c.alias.length>0&&20===c.alias.length&&(l=d.fromBytes(c.alias)),i._fromProtobufTransactions(new h({key:null!=c.key?u._fromProtobufKey(c.key):void 0,initialBalance:null!=c.initialBalance?e.fromTinybars(c.initialBalance):void 0,receiverSignatureRequired:null!=c.receiverSigRequired?c.receiverSigRequired:void 0,proxyAccountId:null!=c.proxyAccountID?t._fromProtobuf(c.proxyAccountID):void 0,autoRenewPeriod:null!=c.autoRenewPeriod&&null!=c.autoRenewPeriod.seconds?c.autoRenewPeriod.seconds:void 0,accountMemo:null!=c.memo?c.memo:void 0,maxAutomaticTokenAssociations:null!=c.maxAutomaticTokenAssociations?c.maxAutomaticTokenAssociations:void 0,stakedAccountId:null!=c.stakedAccountId?t._fromProtobuf(c.stakedAccountId):void 0,stakedNodeId:null!=c.stakedNodeId?c.stakedNodeId:void 0,declineStakingReward:1==c.declineReward,alias:l}),o,s,r,n,a)}get key(){return this._key}setKey(e){return this._requireNotFrozen(),this._key=e,this}setECDSAKeyWithAlias(e){this.setKeyWithoutAlias(e);const t=this._deriveECDSAKeyAlias(e);return this.setAlias(t),this}setKeyWithAlias(e,t){this.setKeyWithoutAlias(e);const i=this._deriveECDSAKeyAlias(t);return this.setAlias(i),this}setKeyWithoutAlias(e){return this._requireNotFrozen(),this._key=e,this}get initialBalance(){return this._initialBalance}setInitialBalance(t){return this._requireNotFrozen(),this._initialBalance=t instanceof e?t:new e(t),this}get receiverSignatureRequired(){return this._receiverSignatureRequired}setReceiverSignatureRequired(e){return this._requireNotFrozen(),this._receiverSignatureRequired=e,this}get proxyAccountId(){return this._proxyAccountId}setProxyAccountId(e){return this._requireNotFrozen(),this._proxyAccountId=e,this}get autoRenewPeriod(){return this._autoRenewPeriod}setAutoRenewPeriod(e){return this._requireNotFrozen(),this._autoRenewPeriod=e instanceof n?e:new n(e),this}get accountMemo(){return this._accountMemo}setAccountMemo(e){return this._requireNotFrozen(),this._accountMemo=e,this}get maxAutomaticTokenAssociations(){return this._maxAutomaticTokenAssociations}setMaxAutomaticTokenAssociations(e){return this._requireNotFrozen(),this._maxAutomaticTokenAssociations="number"==typeof e?a.fromNumber(e):e,this}get stakedAccountId(){return this._stakedAccountId}setStakedAccountId(e){return this._requireNotFrozen(),this._stakedAccountId="string"==typeof e?t.fromString(e):e,this}get stakedNodeId(){return this._stakedNodeId}setStakedNodeId(e){return this._requireNotFrozen(),this._stakedNodeId=a.fromValue(e),this}get declineStakingRewards(){return this._declineStakingReward}setDeclineStakingReward(e){return this._requireNotFrozen(),this._declineStakingReward=e,this}get alias(){return this._alias}setAlias(e){if("string"==typeof e){if(!(e.startsWith("0x")&&42==e.length||40==e.length))throw new Error('evmAddress must be a valid EVM address with or without "0x" prefix');this._alias=d.fromString(e)}else this._alias=e;return this}_validateChecksums(e){null!=this._proxyAccountId&&this._proxyAccountId.validateChecksum(e)}_deriveECDSAKeyAlias(e){const t=e instanceof c&&"secp256k1"===e.type,i=e instanceof l&&"secp256k1"===e.type;if(t)return e.publicKey.toEvmAddress();if(i)return e.toEvmAddress();throw new Error("Invalid key for alias derivation provided: expected an ECDSA (secp256k1) PrivateKey or PublicKey.")}_execute(e,t){return e.crypto.createAccount(t)}_getTransactionDataCase(){return"cryptoCreateAccount"}_makeTransactionData(){let e=null;return null!=this._alias&&(e=this._alias.toBytes()),{key:null!=this._key?this._key._toProtobufKey():null,initialBalance:null!=this._initialBalance?this._initialBalance.toTinybars():null,autoRenewPeriod:this._autoRenewPeriod._toProtobuf(),proxyAccountID:null!=this._proxyAccountId?this._proxyAccountId._toProtobuf():null,receiveRecordThreshold:this._receiveRecordThreshold.toTinybars(),sendRecordThreshold:this._sendRecordThreshold.toTinybars(),receiverSigRequired:this._receiverSignatureRequired,memo:this._accountMemo,maxAutomaticTokenAssociations:null!=this._maxAutomaticTokenAssociations?this._maxAutomaticTokenAssociations.toInt():null,stakedAccountId:null!=this.stakedAccountId?this.stakedAccountId._toProtobuf():null,stakedNodeId:this.stakedNodeId,declineReward:this.declineStakingRewards,hookCreationDetails:this._hooks.map(e=>e._toProtobuf()),alias:e}}addHook(e){return this._hooks.push(e),this}setHooks(e){return this._hooks=e,this}get hooks(){return this._hooks}_getLogId(){return`AccountCreateTransaction:${this._transactionIds.current.validStart.toString()}`}}o.set("cryptoCreateAccount",h._fromProtobuf);export{h as default};
|
|
2
2
|
//# sourceMappingURL=AccountCreateTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountCreateTransaction.js","sources":["../../src/account/AccountCreateTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport * as HieroProto from \"@hiero-ledger/proto\";\nimport Hbar from \"../Hbar.js\";\nimport AccountId from \"./AccountId.js\";\nimport Transaction, {\n DEFAULT_AUTO_RENEW_PERIOD,\n DEFAULT_RECORD_THRESHOLD,\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport Duration from \"../Duration.js\";\nimport Long from \"long\";\nimport Key from \"../Key.js\";\nimport PrivateKey from \"../PrivateKey.js\";\nimport EvmAddress from \"../EvmAddress.js\";\nimport PublicKey from \"../PublicKey.js\";\n/**\n * @typedef {import(\"bignumber.js\").default} BigNumber\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"../Timestamp.js\").default} Timestamp\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n */\n\n/**\n * Create a new Hedera™ crypto-currency account.\n */\nexport default class AccountCreateTransaction extends Transaction {\n /**\n * @param {object} [props]\n * @param {Key} [props.key]\n * @param {number | string | Long | BigNumber | Hbar} [props.initialBalance]\n * @param {boolean} [props.receiverSignatureRequired]\n * @param {AccountId} [props.proxyAccountId]\n * @param {Duration | Long | number} [props.autoRenewPeriod]\n * @param {string} [props.accountMemo]\n * @param {Long | number} [props.maxAutomaticTokenAssociations]\n * @param {AccountId | string} [props.stakedAccountId]\n * @param {Long | number} [props.stakedNodeId]\n * @param {boolean} [props.declineStakingReward]\n * @param {EvmAddress} [props.alias]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?Key}\n */\n this._key = null;\n\n /**\n * @private\n * @type {?Hbar}\n */\n this._initialBalance = null;\n\n /**\n * @private\n * @type {Hbar}\n */\n this._sendRecordThreshold = DEFAULT_RECORD_THRESHOLD;\n\n /**\n * @private\n * @type {Hbar}\n */\n this._receiveRecordThreshold = DEFAULT_RECORD_THRESHOLD;\n\n /**\n * @private\n * @type {boolean}\n */\n this._receiverSignatureRequired = false;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._proxyAccountId = null;\n\n /**\n * @private\n * @type {Duration}\n */\n this._autoRenewPeriod = new Duration(DEFAULT_AUTO_RENEW_PERIOD);\n\n /**\n * @private\n * @type {?string}\n */\n this._accountMemo = null;\n\n /**\n * @private\n * @type {?Long}\n */\n this._maxAutomaticTokenAssociations = null;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._stakedAccountId = null;\n\n /**\n * @private\n * @type {?Long}\n */\n this._stakedNodeId = null;\n\n /**\n * @private\n * @type {boolean}\n */\n this._declineStakingReward = false;\n\n /**\n * @private\n * @type {?EvmAddress}\n */\n this._alias = null;\n\n if (props.key != null) {\n this.setKeyWithoutAlias(props.key);\n }\n\n if (props.receiverSignatureRequired != null) {\n this.setReceiverSignatureRequired(props.receiverSignatureRequired);\n }\n\n if (props.initialBalance != null) {\n this.setInitialBalance(props.initialBalance);\n }\n\n if (props.proxyAccountId != null) {\n // eslint-disable-next-line deprecation/deprecation\n this.setProxyAccountId(props.proxyAccountId);\n }\n\n if (props.autoRenewPeriod != null) {\n this.setAutoRenewPeriod(props.autoRenewPeriod);\n }\n\n if (props.accountMemo != null) {\n this.setAccountMemo(props.accountMemo);\n }\n\n if (props.maxAutomaticTokenAssociations != null) {\n this.setMaxAutomaticTokenAssociations(\n props.maxAutomaticTokenAssociations,\n );\n }\n\n if (props.stakedAccountId != null) {\n this.setStakedAccountId(props.stakedAccountId);\n }\n\n if (props.stakedNodeId != null) {\n this.setStakedNodeId(props.stakedNodeId);\n }\n\n if (props.declineStakingReward != null) {\n this.setDeclineStakingReward(props.declineStakingReward);\n }\n\n if (props.alias != null) {\n this.setAlias(props.alias);\n }\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.ITransaction[]} transactions\n * @param {HieroProto.proto.ISignedTransaction[]} signedTransactions\n * @param {TransactionId[]} transactionIds\n * @param {AccountId[]} nodeIds\n * @param {HieroProto.proto.ITransactionBody[]} bodies\n * @returns {AccountCreateTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const create =\n /** @type {HieroProto.proto.ICryptoCreateTransactionBody} */ (\n body.cryptoCreateAccount\n );\n\n let alias = undefined;\n if (create.alias != null && create.alias.length > 0) {\n if (create.alias.length === 20) {\n alias = EvmAddress.fromBytes(create.alias);\n }\n }\n\n return Transaction._fromProtobufTransactions(\n new AccountCreateTransaction({\n key:\n create.key != null\n ? Key._fromProtobufKey(create.key)\n : undefined,\n initialBalance:\n create.initialBalance != null\n ? Hbar.fromTinybars(create.initialBalance)\n : undefined,\n receiverSignatureRequired:\n create.receiverSigRequired != null\n ? create.receiverSigRequired\n : undefined,\n proxyAccountId:\n create.proxyAccountID != null\n ? AccountId._fromProtobuf(\n /** @type {HieroProto.proto.IAccountID} */ (\n create.proxyAccountID\n ),\n )\n : undefined,\n autoRenewPeriod:\n create.autoRenewPeriod != null\n ? create.autoRenewPeriod.seconds != null\n ? create.autoRenewPeriod.seconds\n : undefined\n : undefined,\n accountMemo: create.memo != null ? create.memo : undefined,\n maxAutomaticTokenAssociations:\n create.maxAutomaticTokenAssociations != null\n ? create.maxAutomaticTokenAssociations\n : undefined,\n stakedAccountId:\n create.stakedAccountId != null\n ? AccountId._fromProtobuf(create.stakedAccountId)\n : undefined,\n stakedNodeId:\n create.stakedNodeId != null\n ? create.stakedNodeId\n : undefined,\n declineStakingReward: create.declineReward == true,\n alias,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?Key}\n */\n get key() {\n return this._key;\n }\n\n /**\n * Set the key for this account.\n *\n * This is the key that must sign each transfer out of the account.\n *\n * If `receiverSignatureRequired` is true, then the key must also sign\n * any transfer into the account.\n *\n * @deprecated Use `setKeyWithoutAlias` instead.\n * @param {Key} key\n * @returns {this}\n */\n setKey(key) {\n this._requireNotFrozen();\n this._key = key;\n\n return this;\n }\n\n /**\n * Sets an ECDSA key (private or public) and a derived alias from this key in the background.\n * @param {Key} key - An ECDSA key (private or public) used for signing transactions and alias derivation.\n * @returns {this}\n * @throws {Error} If the key is not an ECDSA key.\n */\n setECDSAKeyWithAlias(key) {\n this.setKeyWithoutAlias(key);\n\n const alias = this._deriveECDSAKeyAlias(key);\n\n this.setAlias(alias);\n return this;\n }\n\n /**\n * Sets an account key and an alias derived from a separate ECDSA key.\n * The transaction must be signed by both keys.\n * @param {Key} key - The primary account key used for signing transactions.\n * @param {Key} aliasKey - The ECDSA key (private or public) used to derive the EVM address.\n * @returns {this}\n * @throws {Error} If the aliasKey is not an ECDSA key.\n */\n setKeyWithAlias(key, aliasKey) {\n this.setKeyWithoutAlias(key);\n\n const alias = this._deriveECDSAKeyAlias(aliasKey);\n\n this.setAlias(alias);\n return this;\n }\n\n /**\n * Set the key for this account without an alias.\n *\n * This is the key that must sign each transfer out of the account.\n *\n * If `receiverSignatureRequired` is true, then the key must also sign\n * any transfer into the account.\n *\n *\n * @param {Key} key\n * @returns {this}\n */\n setKeyWithoutAlias(key) {\n this._requireNotFrozen();\n this._key = key;\n\n return this;\n }\n\n /**\n * @returns {?Hbar}\n */\n get initialBalance() {\n return this._initialBalance;\n }\n\n /**\n * Set the initial amount to transfer into this account.\n *\n * @param {number | string | Long | BigNumber | Hbar} initialBalance\n * @returns {this}\n */\n setInitialBalance(initialBalance) {\n this._requireNotFrozen();\n this._initialBalance =\n initialBalance instanceof Hbar\n ? initialBalance\n : new Hbar(initialBalance);\n\n return this;\n }\n\n /**\n * @returns {boolean}\n */\n get receiverSignatureRequired() {\n return this._receiverSignatureRequired;\n }\n\n /**\n * Set to true to require the key for this account to sign any transfer of\n * hbars to this account.\n *\n * @param {boolean} receiverSignatureRequired\n * @returns {this}\n */\n setReceiverSignatureRequired(receiverSignatureRequired) {\n this._requireNotFrozen();\n this._receiverSignatureRequired = receiverSignatureRequired;\n\n return this;\n }\n\n /**\n * @deprecated\n * @returns {?AccountId}\n */\n get proxyAccountId() {\n return this._proxyAccountId;\n }\n\n /**\n * @deprecated\n *\n * Set the ID of the account to which this account is proxy staked.\n * @param {AccountId} proxyAccountId\n * @returns {this}\n */\n setProxyAccountId(proxyAccountId) {\n this._requireNotFrozen();\n this._proxyAccountId = proxyAccountId;\n\n return this;\n }\n\n /**\n * @returns {Duration}\n */\n get autoRenewPeriod() {\n return this._autoRenewPeriod;\n }\n\n /**\n * Set the auto renew period for this account.\n *\n * @param {Duration | Long | number} autoRenewPeriod\n * @returns {this}\n */\n setAutoRenewPeriod(autoRenewPeriod) {\n this._requireNotFrozen();\n this._autoRenewPeriod =\n autoRenewPeriod instanceof Duration\n ? autoRenewPeriod\n : new Duration(autoRenewPeriod);\n\n return this;\n }\n\n /**\n * @returns {?string}\n */\n get accountMemo() {\n return this._accountMemo;\n }\n\n /**\n * @param {string} memo\n * @returns {this}\n */\n setAccountMemo(memo) {\n this._requireNotFrozen();\n this._accountMemo = memo;\n\n return this;\n }\n\n /**\n * @returns {?Long}\n */\n get maxAutomaticTokenAssociations() {\n return this._maxAutomaticTokenAssociations;\n }\n\n /**\n * @param {Long | number} maxAutomaticTokenAssociations\n * @returns {this}\n */\n setMaxAutomaticTokenAssociations(maxAutomaticTokenAssociations) {\n this._requireNotFrozen();\n this._maxAutomaticTokenAssociations =\n typeof maxAutomaticTokenAssociations === \"number\"\n ? Long.fromNumber(maxAutomaticTokenAssociations)\n : maxAutomaticTokenAssociations;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get stakedAccountId() {\n return this._stakedAccountId;\n }\n\n /**\n * @param {AccountId | string} stakedAccountId\n * @returns {this}\n */\n setStakedAccountId(stakedAccountId) {\n this._requireNotFrozen();\n this._stakedAccountId =\n typeof stakedAccountId === \"string\"\n ? AccountId.fromString(stakedAccountId)\n : stakedAccountId;\n\n return this;\n }\n\n /**\n * @returns {?Long}\n */\n get stakedNodeId() {\n return this._stakedNodeId;\n }\n\n /**\n * @param {Long | number} stakedNodeId\n * @returns {this}\n */\n setStakedNodeId(stakedNodeId) {\n this._requireNotFrozen();\n this._stakedNodeId = Long.fromValue(stakedNodeId);\n\n return this;\n }\n\n /**\n * @returns {boolean}\n */\n get declineStakingRewards() {\n return this._declineStakingReward;\n }\n\n /**\n * @param {boolean} declineStakingReward\n * @returns {this}\n */\n setDeclineStakingReward(declineStakingReward) {\n this._requireNotFrozen();\n this._declineStakingReward = declineStakingReward;\n\n return this;\n }\n\n /**\n * The bytes to be used as the account's alias.\n *\n * The bytes must be formatted as the calcluated last 20 bytes of the\n * keccak-256 of the ECDSA primitive key.\n *\n * All other types of keys, including but not limited to ED25519, ThresholdKey, KeyList, ContractID, and\n * delegatable_contract_id, are not supported.\n *\n * At most only one account can ever have a given alias on the network.\n *\n * @returns {?EvmAddress}\n */\n get alias() {\n return this._alias;\n }\n\n /**\n * The bytes to be used as the account's alias.\n *\n * The bytes must be formatted as the calcluated last 20 bytes of the\n * keccak-256 of the ECDSA primitive key.\n *\n * All other types of keys, including but not limited to ED25519, ThresholdKey, KeyList, ContractID, and\n * delegatable_contract_id, are not supported.\n *\n * At most only one account can ever have a given alias on the network.\n *\n * @param {string | EvmAddress} alias\n * @returns {this}\n */\n setAlias(alias) {\n if (typeof alias === \"string\") {\n if (\n (alias.startsWith(\"0x\") && alias.length == 42) ||\n alias.length == 40\n ) {\n this._alias = EvmAddress.fromString(alias);\n } else {\n throw new Error(\n 'evmAddress must be a valid EVM address with or without \"0x\" prefix',\n );\n }\n } else {\n this._alias = alias;\n }\n\n return this;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._proxyAccountId != null) {\n this._proxyAccountId.validateChecksum(client);\n }\n }\n\n /**\n * Derives an EVM alias from an ECDSA key.\n * @private\n * @internal\n * @param {Key} key\n * @returns {string}\n * @throws {Error} If the key is not a ECDSA (secp256k1) PrivateKey or PublicKey.\n */\n _deriveECDSAKeyAlias(key) {\n const isPrivateECDSAKey =\n key instanceof PrivateKey && key.type === \"secp256k1\";\n const isPublicECDSAKey =\n key instanceof PublicKey && key.type === \"secp256k1\";\n\n if (isPrivateECDSAKey) {\n return key.publicKey.toEvmAddress();\n } else if (isPublicECDSAKey) {\n return key.toEvmAddress();\n }\n\n throw new Error(\n \"Invalid key for alias derivation provided: expected an ECDSA (secp256k1) PrivateKey or PublicKey.\",\n );\n }\n\n /**\n * @override\n * @internal\n * @param {Channel} channel\n * @param {HieroProto.proto.ITransaction} request\n * @returns {Promise<HieroProto.proto.ITransactionResponse>}\n */\n _execute(channel, request) {\n return channel.crypto.createAccount(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"cryptoCreateAccount\";\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.ICryptoCreateTransactionBody}\n */\n _makeTransactionData() {\n let alias = null;\n if (this._alias != null) {\n alias = this._alias.toBytes();\n }\n\n return {\n key: this._key != null ? this._key._toProtobufKey() : null,\n initialBalance:\n this._initialBalance != null\n ? this._initialBalance.toTinybars()\n : null,\n autoRenewPeriod: this._autoRenewPeriod._toProtobuf(),\n proxyAccountID:\n this._proxyAccountId != null\n ? this._proxyAccountId._toProtobuf()\n : null,\n receiveRecordThreshold: this._receiveRecordThreshold.toTinybars(),\n sendRecordThreshold: this._sendRecordThreshold.toTinybars(),\n receiverSigRequired: this._receiverSignatureRequired,\n memo: this._accountMemo,\n maxAutomaticTokenAssociations:\n this._maxAutomaticTokenAssociations != null\n ? this._maxAutomaticTokenAssociations.toInt()\n : null,\n stakedAccountId:\n this.stakedAccountId != null\n ? this.stakedAccountId._toProtobuf()\n : null,\n stakedNodeId: this.stakedNodeId,\n declineReward: this.declineStakingRewards,\n alias,\n };\n }\n\n /**\n * @returns {string}\n */\n _getLogId() {\n const timestamp = /** @type {import(\"../Timestamp.js\").default} */ (\n this._transactionIds.current.validStart\n );\n return `AccountCreateTransaction:${timestamp.toString()}`;\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"cryptoCreateAccount\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n AccountCreateTransaction._fromProtobuf,\n);\n"],"names":["AccountCreateTransaction","Transaction","constructor","props","super","this","_key","_initialBalance","_sendRecordThreshold","DEFAULT_RECORD_THRESHOLD","_receiveRecordThreshold","_receiverSignatureRequired","_proxyAccountId","_autoRenewPeriod","Duration","DEFAULT_AUTO_RENEW_PERIOD","_accountMemo","_maxAutomaticTokenAssociations","_stakedAccountId","_stakedNodeId","_declineStakingReward","_alias","key","setKeyWithoutAlias","receiverSignatureRequired","setReceiverSignatureRequired","initialBalance","setInitialBalance","proxyAccountId","setProxyAccountId","autoRenewPeriod","setAutoRenewPeriod","accountMemo","setAccountMemo","maxAutomaticTokenAssociations","setMaxAutomaticTokenAssociations","stakedAccountId","setStakedAccountId","stakedNodeId","setStakedNodeId","declineStakingReward","setDeclineStakingReward","alias","setAlias","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","create","length","EvmAddress","fromBytes","_fromProtobufTransactions","Key","_fromProtobufKey","undefined","Hbar","fromTinybars","receiverSigRequired","proxyAccountID","AccountId","seconds","memo","declineReward","setKey","_requireNotFrozen","setECDSAKeyWithAlias","_deriveECDSAKeyAlias","setKeyWithAlias","aliasKey","Long","fromNumber","fromString","fromValue","declineStakingRewards","startsWith","Error","_validateChecksums","client","validateChecksum","isPrivateECDSAKey","PrivateKey","type","isPublicECDSAKey","PublicKey","publicKey","toEvmAddress","_execute","channel","request","crypto","createAccount","_getTransactionDataCase","_makeTransactionData","toBytes","_toProtobufKey","toTinybars","_toProtobuf","receiveRecordThreshold","sendRecordThreshold","toInt","_getLogId","_transactionIds","current","toString","TRANSACTION_REGISTRY","set"],"mappings":"mYA2Be,MAAMA,UAAiCC,EAelD,WAAAC,CAAYC,EAAQ,IAChBC,QAMAC,KAAKC,KAAO,KAMZD,KAAKE,gBAAkB,KAMvBF,KAAKG,qBAAuBC,EAM5BJ,KAAKK,wBAA0BD,EAM/BJ,KAAKM,4BAA6B,EAMlCN,KAAKO,gBAAkB,KAMvBP,KAAKQ,iBAAmB,IAAIC,EAASC,GAMrCV,KAAKW,aAAe,KAMpBX,KAAKY,+BAAiC,KAMtCZ,KAAKa,iBAAmB,KAMxBb,KAAKc,cAAgB,KAMrBd,KAAKe,uBAAwB,EAM7Bf,KAAKgB,OAAS,KAEG,MAAblB,EAAMmB,KACNjB,KAAKkB,mBAAmBpB,EAAMmB,KAGK,MAAnCnB,EAAMqB,2BACNnB,KAAKoB,6BAA6BtB,EAAMqB,2BAGhB,MAAxBrB,EAAMuB,gBACNrB,KAAKsB,kBAAkBxB,EAAMuB,gBAGL,MAAxBvB,EAAMyB,gBAENvB,KAAKwB,kBAAkB1B,EAAMyB,gBAGJ,MAAzBzB,EAAM2B,iBACNzB,KAAK0B,mBAAmB5B,EAAM2B,iBAGT,MAArB3B,EAAM6B,aACN3B,KAAK4B,eAAe9B,EAAM6B,aAGa,MAAvC7B,EAAM+B,+BACN7B,KAAK8B,iCACDhC,EAAM+B,+BAIe,MAAzB/B,EAAMiC,iBACN/B,KAAKgC,mBA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MAAfrC,KAAKgB,SACLqB,EAAQrC,KAAKgB,OAAO2E,WAGjB,CACH1E,IAAkB,MAAbjB,KAAKC,KAAeD,KAAKC,KAAK2F,iBAAmB,KACtDvE,eAC4B,MAAxBrB,KAAKE,gBACCF,KAAKE,gBAAgB2F,aACrB,KACVpE,gBAAiBzB,KAAKQ,iBAAiBsF,cACvCtC,eAC4B,MAAxBxD,KAAKO,gBACCP,KAAKO,gBAAgBuF,cACrB,KACVC,uBAAwB/F,KAAKK,wBAAwBwF,aACrDG,oBAAqBhG,KAAKG,qBAAqB0F,aAC/CtC,oBAAqBvD,KAAKM,2BAC1BqD,KAAM3D,KAAKW,aACXkB,8BAC2C,MAAvC7B,KAAKY,+BACCZ,KAAKY,+BAA+BqF,QACpC,KACVlE,gBAC4B,MAAxB/B,KAAK+B,gBACC/B,KAAK+B,gBAAgB+D,cACrB,KACV7D,aAAcjC,KAAKiC,aACnB2B,cAAe5D,KAAKuE,sBACpBlC,QAEZ,CAKI,SAAA6D,GAII,MAAO,4BAFHlG,KAAKmG,gBAAgBC,QACxB,WAC4CC,YACrD,EAGAC,EAAqBC,IACjB,sBAEA5G,EAAyB4C"}
|
|
1
|
+
{"version":3,"file":"AccountCreateTransaction.js","sources":["../../src/account/AccountCreateTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport * as HieroProto from \"@hiero-ledger/proto\";\nimport Hbar from \"../Hbar.js\";\nimport AccountId from \"./AccountId.js\";\nimport Transaction, {\n DEFAULT_AUTO_RENEW_PERIOD,\n DEFAULT_RECORD_THRESHOLD,\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport Duration from \"../Duration.js\";\nimport Long from \"long\";\nimport Key from \"../Key.js\";\nimport PrivateKey from \"../PrivateKey.js\";\nimport EvmAddress from \"../EvmAddress.js\";\nimport PublicKey from \"../PublicKey.js\";\n/**\n * @typedef {import(\"bignumber.js\").default} BigNumber\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"../Timestamp.js\").default} Timestamp\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n */\n\n/**\n * Create a new Hedera™ crypto-currency account.\n */\nexport default class AccountCreateTransaction extends Transaction {\n /**\n * @param {object} [props]\n * @param {Key} [props.key]\n * @param {number | string | Long | BigNumber | Hbar} [props.initialBalance]\n * @param {boolean} [props.receiverSignatureRequired]\n * @param {AccountId} [props.proxyAccountId]\n * @param {Duration | Long | number} [props.autoRenewPeriod]\n * @param {string} [props.accountMemo]\n * @param {Long | number} [props.maxAutomaticTokenAssociations]\n * @param {AccountId | string} [props.stakedAccountId]\n * @param {Long | number} [props.stakedNodeId]\n * @param {boolean} [props.declineStakingReward]\n * @param {EvmAddress} [props.alias]\n * @param {import(\"../hooks/HookCreationDetails.js\").default[]} [props.hooks]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?Key}\n */\n this._key = null;\n\n /**\n * @private\n * @type {?Hbar}\n */\n this._initialBalance = null;\n\n /**\n * @private\n * @type {Hbar}\n */\n this._sendRecordThreshold = DEFAULT_RECORD_THRESHOLD;\n\n /**\n * @private\n * @type {Hbar}\n */\n this._receiveRecordThreshold = DEFAULT_RECORD_THRESHOLD;\n\n /**\n * @private\n * @type {boolean}\n */\n this._receiverSignatureRequired = false;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._proxyAccountId = null;\n\n /**\n * @private\n * @type {Duration}\n */\n this._autoRenewPeriod = new Duration(DEFAULT_AUTO_RENEW_PERIOD);\n\n /**\n * @private\n * @type {?string}\n */\n this._accountMemo = null;\n\n /**\n * @private\n * @type {?Long}\n */\n this._maxAutomaticTokenAssociations = null;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._stakedAccountId = null;\n\n /**\n * @private\n * @type {?Long}\n */\n this._stakedNodeId = null;\n\n /**\n * @private\n * @type {boolean}\n */\n this._declineStakingReward = false;\n\n /**\n * @private\n * @type {?EvmAddress}\n */\n this._alias = null;\n\n /**\n * @private\n * @type {import(\"../hooks/HookCreationDetails.js\").default[]}\n */\n this._hooks = [];\n\n if (props.hooks != null) {\n props.hooks.forEach((hook) => {\n this.addHook(hook);\n });\n }\n\n if (props.key != null) {\n this.setKeyWithoutAlias(props.key);\n }\n\n if (props.receiverSignatureRequired != null) {\n this.setReceiverSignatureRequired(props.receiverSignatureRequired);\n }\n\n if (props.initialBalance != null) {\n this.setInitialBalance(props.initialBalance);\n }\n\n if (props.proxyAccountId != null) {\n // eslint-disable-next-line deprecation/deprecation\n this.setProxyAccountId(props.proxyAccountId);\n }\n\n if (props.autoRenewPeriod != null) {\n this.setAutoRenewPeriod(props.autoRenewPeriod);\n }\n\n if (props.accountMemo != null) {\n this.setAccountMemo(props.accountMemo);\n }\n\n if (props.maxAutomaticTokenAssociations != null) {\n this.setMaxAutomaticTokenAssociations(\n props.maxAutomaticTokenAssociations,\n );\n }\n\n if (props.stakedAccountId != null) {\n this.setStakedAccountId(props.stakedAccountId);\n }\n\n if (props.stakedNodeId != null) {\n this.setStakedNodeId(props.stakedNodeId);\n }\n\n if (props.declineStakingReward != null) {\n this.setDeclineStakingReward(props.declineStakingReward);\n }\n\n if (props.alias != null) {\n this.setAlias(props.alias);\n }\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.ITransaction[]} transactions\n * @param {HieroProto.proto.ISignedTransaction[]} signedTransactions\n * @param {TransactionId[]} transactionIds\n * @param {AccountId[]} nodeIds\n * @param {HieroProto.proto.ITransactionBody[]} bodies\n * @returns {AccountCreateTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const create =\n /** @type {HieroProto.proto.ICryptoCreateTransactionBody} */ (\n body.cryptoCreateAccount\n );\n\n let alias = undefined;\n if (create.alias != null && create.alias.length > 0) {\n if (create.alias.length === 20) {\n alias = EvmAddress.fromBytes(create.alias);\n }\n }\n\n return Transaction._fromProtobufTransactions(\n new AccountCreateTransaction({\n key:\n create.key != null\n ? Key._fromProtobufKey(create.key)\n : undefined,\n initialBalance:\n create.initialBalance != null\n ? Hbar.fromTinybars(create.initialBalance)\n : undefined,\n receiverSignatureRequired:\n create.receiverSigRequired != null\n ? create.receiverSigRequired\n : undefined,\n proxyAccountId:\n create.proxyAccountID != null\n ? AccountId._fromProtobuf(\n /** @type {HieroProto.proto.IAccountID} */ (\n create.proxyAccountID\n ),\n )\n : undefined,\n autoRenewPeriod:\n create.autoRenewPeriod != null\n ? create.autoRenewPeriod.seconds != null\n ? create.autoRenewPeriod.seconds\n : undefined\n : undefined,\n accountMemo: create.memo != null ? create.memo : undefined,\n maxAutomaticTokenAssociations:\n create.maxAutomaticTokenAssociations != null\n ? create.maxAutomaticTokenAssociations\n : undefined,\n stakedAccountId:\n create.stakedAccountId != null\n ? AccountId._fromProtobuf(create.stakedAccountId)\n : undefined,\n stakedNodeId:\n create.stakedNodeId != null\n ? create.stakedNodeId\n : undefined,\n declineStakingReward: create.declineReward == true,\n alias,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?Key}\n */\n get key() {\n return this._key;\n }\n\n /**\n * Set the key for this account.\n *\n * This is the key that must sign each transfer out of the account.\n *\n * If `receiverSignatureRequired` is true, then the key must also sign\n * any transfer into the account.\n *\n * @deprecated Use `setKeyWithoutAlias` instead.\n * @param {Key} key\n * @returns {this}\n */\n setKey(key) {\n this._requireNotFrozen();\n this._key = key;\n\n return this;\n }\n\n /**\n * Sets an ECDSA key (private or public) and a derived alias from this key in the background.\n * @param {Key} key - An ECDSA key (private or public) used for signing transactions and alias derivation.\n * @returns {this}\n * @throws {Error} If the key is not an ECDSA key.\n */\n setECDSAKeyWithAlias(key) {\n this.setKeyWithoutAlias(key);\n\n const alias = this._deriveECDSAKeyAlias(key);\n\n this.setAlias(alias);\n return this;\n }\n\n /**\n * Sets an account key and an alias derived from a separate ECDSA key.\n * The transaction must be signed by both keys.\n * @param {Key} key - The primary account key used for signing transactions.\n * @param {Key} aliasKey - The ECDSA key (private or public) used to derive the EVM address.\n * @returns {this}\n * @throws {Error} If the aliasKey is not an ECDSA key.\n */\n setKeyWithAlias(key, aliasKey) {\n this.setKeyWithoutAlias(key);\n\n const alias = this._deriveECDSAKeyAlias(aliasKey);\n\n this.setAlias(alias);\n return this;\n }\n\n /**\n * Set the key for this account without an alias.\n *\n * This is the key that must sign each transfer out of the account.\n *\n * If `receiverSignatureRequired` is true, then the key must also sign\n * any transfer into the account.\n *\n *\n * @param {Key} key\n * @returns {this}\n */\n setKeyWithoutAlias(key) {\n this._requireNotFrozen();\n this._key = key;\n\n return this;\n }\n\n /**\n * @returns {?Hbar}\n */\n get initialBalance() {\n return this._initialBalance;\n }\n\n /**\n * Set the initial amount to transfer into this account.\n *\n * @param {number | string | Long | BigNumber | Hbar} initialBalance\n * @returns {this}\n */\n setInitialBalance(initialBalance) {\n this._requireNotFrozen();\n this._initialBalance =\n initialBalance instanceof Hbar\n ? initialBalance\n : new Hbar(initialBalance);\n\n return this;\n }\n\n /**\n * @returns {boolean}\n */\n get receiverSignatureRequired() {\n return this._receiverSignatureRequired;\n }\n\n /**\n * Set to true to require the key for this account to sign any transfer of\n * hbars to this account.\n *\n * @param {boolean} receiverSignatureRequired\n * @returns {this}\n */\n setReceiverSignatureRequired(receiverSignatureRequired) {\n this._requireNotFrozen();\n this._receiverSignatureRequired = receiverSignatureRequired;\n\n return this;\n }\n\n /**\n * @deprecated\n * @returns {?AccountId}\n */\n get proxyAccountId() {\n return this._proxyAccountId;\n }\n\n /**\n * @deprecated\n *\n * Set the ID of the account to which this account is proxy staked.\n * @param {AccountId} proxyAccountId\n * @returns {this}\n */\n setProxyAccountId(proxyAccountId) {\n this._requireNotFrozen();\n this._proxyAccountId = proxyAccountId;\n\n return this;\n }\n\n /**\n * @returns {Duration}\n */\n get autoRenewPeriod() {\n return this._autoRenewPeriod;\n }\n\n /**\n * Set the auto renew period for this account.\n *\n * @param {Duration | Long | number} autoRenewPeriod\n * @returns {this}\n */\n setAutoRenewPeriod(autoRenewPeriod) {\n this._requireNotFrozen();\n this._autoRenewPeriod =\n autoRenewPeriod instanceof Duration\n ? autoRenewPeriod\n : new Duration(autoRenewPeriod);\n\n return this;\n }\n\n /**\n * @returns {?string}\n */\n get accountMemo() {\n return this._accountMemo;\n }\n\n /**\n * @param {string} memo\n * @returns {this}\n */\n setAccountMemo(memo) {\n this._requireNotFrozen();\n this._accountMemo = memo;\n\n return this;\n }\n\n /**\n * @returns {?Long}\n */\n get maxAutomaticTokenAssociations() {\n return this._maxAutomaticTokenAssociations;\n }\n\n /**\n * @param {Long | number} maxAutomaticTokenAssociations\n * @returns {this}\n */\n setMaxAutomaticTokenAssociations(maxAutomaticTokenAssociations) {\n this._requireNotFrozen();\n this._maxAutomaticTokenAssociations =\n typeof maxAutomaticTokenAssociations === \"number\"\n ? Long.fromNumber(maxAutomaticTokenAssociations)\n : maxAutomaticTokenAssociations;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get stakedAccountId() {\n return this._stakedAccountId;\n }\n\n /**\n * @param {AccountId | string} stakedAccountId\n * @returns {this}\n */\n setStakedAccountId(stakedAccountId) {\n this._requireNotFrozen();\n this._stakedAccountId =\n typeof stakedAccountId === \"string\"\n ? AccountId.fromString(stakedAccountId)\n : stakedAccountId;\n\n return this;\n }\n\n /**\n * @returns {?Long}\n */\n get stakedNodeId() {\n return this._stakedNodeId;\n }\n\n /**\n * @param {Long | number} stakedNodeId\n * @returns {this}\n */\n setStakedNodeId(stakedNodeId) {\n this._requireNotFrozen();\n this._stakedNodeId = Long.fromValue(stakedNodeId);\n\n return this;\n }\n\n /**\n * @returns {boolean}\n */\n get declineStakingRewards() {\n return this._declineStakingReward;\n }\n\n /**\n * @param {boolean} declineStakingReward\n * @returns {this}\n */\n setDeclineStakingReward(declineStakingReward) {\n this._requireNotFrozen();\n this._declineStakingReward = declineStakingReward;\n\n return this;\n }\n\n /**\n * The bytes to be used as the account's alias.\n *\n * The bytes must be formatted as the calcluated last 20 bytes of the\n * keccak-256 of the ECDSA primitive key.\n *\n * All other types of keys, including but not limited to ED25519, ThresholdKey, KeyList, ContractID, and\n * delegatable_contract_id, are not supported.\n *\n * At most only one account can ever have a given alias on the network.\n *\n * @returns {?EvmAddress}\n */\n get alias() {\n return this._alias;\n }\n\n /**\n * The bytes to be used as the account's alias.\n *\n * The bytes must be formatted as the calcluated last 20 bytes of the\n * keccak-256 of the ECDSA primitive key.\n *\n * All other types of keys, including but not limited to ED25519, ThresholdKey, KeyList, ContractID, and\n * delegatable_contract_id, are not supported.\n *\n * At most only one account can ever have a given alias on the network.\n *\n * @param {string | EvmAddress} alias\n * @returns {this}\n */\n setAlias(alias) {\n if (typeof alias === \"string\") {\n if (\n (alias.startsWith(\"0x\") && alias.length == 42) ||\n alias.length == 40\n ) {\n this._alias = EvmAddress.fromString(alias);\n } else {\n throw new Error(\n 'evmAddress must be a valid EVM address with or without \"0x\" prefix',\n );\n }\n } else {\n this._alias = alias;\n }\n\n return this;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._proxyAccountId != null) {\n this._proxyAccountId.validateChecksum(client);\n }\n }\n\n /**\n * Derives an EVM alias from an ECDSA key.\n * @private\n * @internal\n * @param {Key} key\n * @returns {string}\n * @throws {Error} If the key is not a ECDSA (secp256k1) PrivateKey or PublicKey.\n */\n _deriveECDSAKeyAlias(key) {\n const isPrivateECDSAKey =\n key instanceof PrivateKey && key.type === \"secp256k1\";\n const isPublicECDSAKey =\n key instanceof PublicKey && key.type === \"secp256k1\";\n\n if (isPrivateECDSAKey) {\n return key.publicKey.toEvmAddress();\n } else if (isPublicECDSAKey) {\n return key.toEvmAddress();\n }\n\n throw new Error(\n \"Invalid key for alias derivation provided: expected an ECDSA (secp256k1) PrivateKey or PublicKey.\",\n );\n }\n\n /**\n * @override\n * @internal\n * @param {Channel} channel\n * @param {HieroProto.proto.ITransaction} request\n * @returns {Promise<HieroProto.proto.ITransactionResponse>}\n */\n _execute(channel, request) {\n return channel.crypto.createAccount(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"cryptoCreateAccount\";\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.ICryptoCreateTransactionBody}\n */\n _makeTransactionData() {\n let alias = null;\n if (this._alias != null) {\n alias = this._alias.toBytes();\n }\n\n return {\n key: this._key != null ? this._key._toProtobufKey() : null,\n initialBalance:\n this._initialBalance != null\n ? this._initialBalance.toTinybars()\n : null,\n autoRenewPeriod: this._autoRenewPeriod._toProtobuf(),\n proxyAccountID:\n this._proxyAccountId != null\n ? this._proxyAccountId._toProtobuf()\n : null,\n receiveRecordThreshold: this._receiveRecordThreshold.toTinybars(),\n sendRecordThreshold: this._sendRecordThreshold.toTinybars(),\n receiverSigRequired: this._receiverSignatureRequired,\n memo: this._accountMemo,\n maxAutomaticTokenAssociations:\n this._maxAutomaticTokenAssociations != null\n ? this._maxAutomaticTokenAssociations.toInt()\n : null,\n stakedAccountId:\n this.stakedAccountId != null\n ? this.stakedAccountId._toProtobuf()\n : null,\n stakedNodeId: this.stakedNodeId,\n declineReward: this.declineStakingRewards,\n hookCreationDetails: this._hooks.map((hook) => hook._toProtobuf()),\n alias,\n };\n }\n\n /**\n * @param {import(\"../hooks/HookCreationDetails.js\").default} hook\n * @returns {this}\n */\n addHook(hook) {\n this._hooks.push(hook);\n return this;\n }\n\n /**\n * @param {import(\"../hooks/HookCreationDetails.js\").default[]} hooks\n * @returns {this}\n */\n setHooks(hooks) {\n this._hooks = hooks;\n return this;\n }\n\n /**\n * @returns {import(\"../hooks/HookCreationDetails.js\").default[]}\n */\n get hooks() {\n return this._hooks;\n }\n\n /**\n * @returns {string}\n */\n _getLogId() {\n const timestamp = /** @type {import(\"../Timestamp.js\").default} */ (\n this._transactionIds.current.validStart\n );\n return `AccountCreateTransaction:${timestamp.toString()}`;\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"cryptoCreateAccount\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n AccountCreateTransaction._fromProtobuf,\n);\n"],"names":["AccountCreateTransaction","Transaction","constructor","props","super","this","_key","_initialBalance","_sendRecordThreshold","DEFAULT_RECORD_THRESHOLD","_receiveRecordThreshold","_receiverSignatureRequired","_proxyAccountId","_autoRenewPeriod","Duration","DEFAULT_AUTO_RENEW_PERIOD","_accountMemo","_maxAutomaticTokenAssociations","_stakedAccountId","_stakedNodeId","_declineStakingReward","_alias","_hooks","hooks","forEach","hook","addHook","key","setKeyWithoutAlias","receiverSignatureRequired","setReceiverSignatureRequired","initialBalance","setInitialBalance","proxyAccountId","setProxyAccountId","autoRenewPeriod","setAutoRenewPeriod","accountMemo","setAccountMemo","maxAutomaticTokenAssociations","setMaxAutomaticTokenAssociations","stakedAccountId","setStakedAccountId","stakedNodeId","setStakedNodeId","declineStakingReward","setDeclineStakingReward","alias","setAlias","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","create","length","EvmAddress","fromBytes","_fromProtobufTransactions","Key","_fromProtobufKey","undefined","Hbar","fromTinybars","receiverSigRequired","proxyAccountID","AccountId","seconds","memo","declineReward","setKey","_requireNotFrozen","setECDSAKeyWithAlias","_deriveECDSAKeyAlias","setKeyWithAlias","aliasKey","Long","fromNumber","fromString","fromValue","declineStakingRewards","startsWith","Error","_validateChecksums","client","validateChecksum","isPrivateECDSAKey","PrivateKey","type","isPublicECDSAKey","PublicKey","publicKey","toEvmAddress","_execute","channel","request","crypto","createAccount","_getTransactionDataCase","_makeTransactionData","toBytes","_toProtobufKey","toTinybars","_toProtobuf","receiveRecordThreshold","sendRecordThreshold","toInt","hookCreationDetails","map","push","setHooks","_getLogId","_transactionIds","current","toString","TRANSACTION_REGISTRY","set"],"mappings":"mYA2Be,MAAMA,UAAiCC,EA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,KAAKK,wBAAwB6F,aACrDG,oBAAqBrG,KAAKG,qBAAqB+F,aAC/CtC,oBAAqB5D,KAAKM,2BAC1B0D,KAAMhE,KAAKW,aACXuB,8BAC2C,MAAvClC,KAAKY,+BACCZ,KAAKY,+BAA+B0F,QACpC,KACVlE,gBAC4B,MAAxBpC,KAAKoC,gBACCpC,KAAKoC,gBAAgB+D,cACrB,KACV7D,aAActC,KAAKsC,aACnB2B,cAAejE,KAAK4E,sBACpB2B,oBAAqBvG,KAAKiB,OAAOuF,IAAKpF,GAASA,EAAK+E,eACpDzD,QAEZ,CAMI,OAAArB,CAAQD,GAEJ,OADApB,KAAKiB,OAAOwF,KAAKrF,GACVpB,IACf,CAMI,QAAA0G,CAASxF,GAEL,OADAlB,KAAKiB,OAASC,EACPlB,IACf,CAKI,SAAIkB,GACA,OAAOlB,KAAKiB,MACpB,CAKI,SAAA0F,GAII,MAAO,4BAFH3G,KAAK4G,gBAAgBC,QACxB,WAC4CC,YACrD,EAGAC,EAAqBC,IACjB,sBAEArH,EAAyBiD"}
|
|
@@ -49,6 +49,8 @@ class AccountUpdateTransaction extends _Transaction.default {
|
|
|
49
49
|
* @param {AccountId | string} [props.stakedAccountId]
|
|
50
50
|
* @param {Long | number} [props.stakedNodeId]
|
|
51
51
|
* @param {?boolean} [props.declineStakingReward]
|
|
52
|
+
* @param {import("../hooks/HookCreationDetails.js").default[]} [props.hooksToBeCreated]
|
|
53
|
+
* @param {Long[]} [props.hooksToBeDeleted]
|
|
52
54
|
*/
|
|
53
55
|
constructor(props = {}) {
|
|
54
56
|
super();
|
|
@@ -124,6 +126,18 @@ class AccountUpdateTransaction extends _Transaction.default {
|
|
|
124
126
|
* @type {?boolean}
|
|
125
127
|
*/
|
|
126
128
|
this._declineStakingReward = null;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @private
|
|
132
|
+
* @type {import("../hooks/HookCreationDetails.js").default[]}
|
|
133
|
+
*/
|
|
134
|
+
this._hooksToBeCreated = [];
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @private
|
|
138
|
+
* @type {Long[]}
|
|
139
|
+
*/
|
|
140
|
+
this._hooksToBeDeleted = [];
|
|
127
141
|
if (props.accountId != null) {
|
|
128
142
|
this.setAccountId(props.accountId);
|
|
129
143
|
}
|
|
@@ -158,6 +172,12 @@ class AccountUpdateTransaction extends _Transaction.default {
|
|
|
158
172
|
if (props.declineStakingReward != null) {
|
|
159
173
|
this.setDeclineStakingReward(props.declineStakingReward);
|
|
160
174
|
}
|
|
175
|
+
if (props.hooksToBeCreated != null) {
|
|
176
|
+
this.setHooksToCreate(props.hooksToBeCreated);
|
|
177
|
+
}
|
|
178
|
+
if (props.hooksToBeDeleted != null) {
|
|
179
|
+
this.setHooksToDelete(props.hooksToBeDeleted);
|
|
180
|
+
}
|
|
161
181
|
}
|
|
162
182
|
|
|
163
183
|
/**
|
|
@@ -426,6 +446,57 @@ class AccountUpdateTransaction extends _Transaction.default {
|
|
|
426
446
|
return this;
|
|
427
447
|
}
|
|
428
448
|
|
|
449
|
+
/**
|
|
450
|
+
* @param {import("../hooks/HookCreationDetails.js").default} hook
|
|
451
|
+
* @returns {this}
|
|
452
|
+
*/
|
|
453
|
+
addHookToCreate(hook) {
|
|
454
|
+
this._hooksToBeCreated.push(hook);
|
|
455
|
+
return this;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* @param {import("../hooks/HookCreationDetails.js").default[]} hooks
|
|
460
|
+
* @returns {this}
|
|
461
|
+
*/
|
|
462
|
+
setHooksToCreate(hooks) {
|
|
463
|
+
this._hooksToBeCreated = hooks;
|
|
464
|
+
return this;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* @returns {import("../hooks/HookCreationDetails.js").default[]}
|
|
469
|
+
*/
|
|
470
|
+
get hooksToCreate() {
|
|
471
|
+
return this._hooksToBeCreated;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
*
|
|
476
|
+
* @param {Long} hook
|
|
477
|
+
* @returns {this}
|
|
478
|
+
*/
|
|
479
|
+
addHookToDelete(hook) {
|
|
480
|
+
this._hooksToBeDeleted.push(hook);
|
|
481
|
+
return this;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* @param {Long[]} hookIds
|
|
486
|
+
* @returns {this}
|
|
487
|
+
*/
|
|
488
|
+
setHooksToDelete(hookIds) {
|
|
489
|
+
this._hooksToBeDeleted = hookIds;
|
|
490
|
+
return this;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* @returns {Long[]}
|
|
495
|
+
*/
|
|
496
|
+
get hooksToDelete() {
|
|
497
|
+
return this._hooksToBeDeleted;
|
|
498
|
+
}
|
|
499
|
+
|
|
429
500
|
/**
|
|
430
501
|
* @param {Client} client
|
|
431
502
|
*/
|
|
@@ -483,7 +554,9 @@ class AccountUpdateTransaction extends _Transaction.default {
|
|
|
483
554
|
stakedNodeId: this.stakedNodeId,
|
|
484
555
|
declineReward: this.declineStakingRewards != null ? {
|
|
485
556
|
value: this.declineStakingRewards
|
|
486
|
-
} : null
|
|
557
|
+
} : null,
|
|
558
|
+
hookIdsToDelete: this._hooksToBeDeleted,
|
|
559
|
+
hookCreationDetails: this._hooksToBeCreated.map(hook => hook._toProtobuf())
|
|
487
560
|
};
|
|
488
561
|
}
|
|
489
562
|
|
|
@@ -41,6 +41,8 @@ export default class AccountUpdateTransaction extends Transaction {
|
|
|
41
41
|
* @param {AccountId | string} [props.stakedAccountId]
|
|
42
42
|
* @param {Long | number} [props.stakedNodeId]
|
|
43
43
|
* @param {?boolean} [props.declineStakingReward]
|
|
44
|
+
* @param {import("../hooks/HookCreationDetails.js").default[]} [props.hooksToBeCreated]
|
|
45
|
+
* @param {Long[]} [props.hooksToBeDeleted]
|
|
44
46
|
*/
|
|
45
47
|
constructor(props?: {
|
|
46
48
|
accountId?: AccountId | undefined;
|
|
@@ -55,6 +57,8 @@ export default class AccountUpdateTransaction extends Transaction {
|
|
|
55
57
|
stakedAccountId?: string | AccountId | undefined;
|
|
56
58
|
stakedNodeId?: number | Long | undefined;
|
|
57
59
|
declineStakingReward?: boolean | null | undefined;
|
|
60
|
+
hooksToBeCreated?: import("../hooks/HookCreationDetails.js").default[] | undefined;
|
|
61
|
+
hooksToBeDeleted?: Long[] | undefined;
|
|
58
62
|
});
|
|
59
63
|
/**
|
|
60
64
|
* @private
|
|
@@ -116,6 +120,16 @@ export default class AccountUpdateTransaction extends Transaction {
|
|
|
116
120
|
* @type {?boolean}
|
|
117
121
|
*/
|
|
118
122
|
private _declineStakingReward;
|
|
123
|
+
/**
|
|
124
|
+
* @private
|
|
125
|
+
* @type {import("../hooks/HookCreationDetails.js").default[]}
|
|
126
|
+
*/
|
|
127
|
+
private _hooksToBeCreated;
|
|
128
|
+
/**
|
|
129
|
+
* @private
|
|
130
|
+
* @type {Long[]}
|
|
131
|
+
*/
|
|
132
|
+
private _hooksToBeDeleted;
|
|
119
133
|
/**
|
|
120
134
|
* @returns {?AccountId}
|
|
121
135
|
*/
|
|
@@ -242,6 +256,35 @@ export default class AccountUpdateTransaction extends Transaction {
|
|
|
242
256
|
* @returns {this}
|
|
243
257
|
*/
|
|
244
258
|
setDeclineStakingReward(declineStakingReward: boolean): this;
|
|
259
|
+
/**
|
|
260
|
+
* @param {import("../hooks/HookCreationDetails.js").default} hook
|
|
261
|
+
* @returns {this}
|
|
262
|
+
*/
|
|
263
|
+
addHookToCreate(hook: import("../hooks/HookCreationDetails.js").default): this;
|
|
264
|
+
/**
|
|
265
|
+
* @param {import("../hooks/HookCreationDetails.js").default[]} hooks
|
|
266
|
+
* @returns {this}
|
|
267
|
+
*/
|
|
268
|
+
setHooksToCreate(hooks: import("../hooks/HookCreationDetails.js").default[]): this;
|
|
269
|
+
/**
|
|
270
|
+
* @returns {import("../hooks/HookCreationDetails.js").default[]}
|
|
271
|
+
*/
|
|
272
|
+
get hooksToCreate(): import("../hooks/HookCreationDetails.js").default[];
|
|
273
|
+
/**
|
|
274
|
+
*
|
|
275
|
+
* @param {Long} hook
|
|
276
|
+
* @returns {this}
|
|
277
|
+
*/
|
|
278
|
+
addHookToDelete(hook: Long): this;
|
|
279
|
+
/**
|
|
280
|
+
* @param {Long[]} hookIds
|
|
281
|
+
* @returns {this}
|
|
282
|
+
*/
|
|
283
|
+
setHooksToDelete(hookIds: Long[]): this;
|
|
284
|
+
/**
|
|
285
|
+
* @returns {Long[]}
|
|
286
|
+
*/
|
|
287
|
+
get hooksToDelete(): Long[];
|
|
245
288
|
/**
|
|
246
289
|
* @override
|
|
247
290
|
* @protected
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{TRANSACTION_REGISTRY as t}from"../transaction/Transaction.js";import o from"./AccountId.js";import i from"../Timestamp.js";import
|
|
1
|
+
import e,{TRANSACTION_REGISTRY as t}from"../transaction/Transaction.js";import o from"./AccountId.js";import i from"../Timestamp.js";import r from"../Duration.js";import n from"long";import s from"../Key.js";class u extends e{constructor(e={}){super(),this._accountId=null,this._key=null,this._receiverSignatureRequired=null,this._proxyAccountId=null,this._autoRenewPeriod=null,this._expirationTime=null,this._accountMemo=null,this._maxAutomaticTokenAssociations=null,this._aliasKey=null,this._stakedAccountId=null,this._stakedNodeId=null,this._declineStakingReward=null,this._hooksToBeCreated=[],this._hooksToBeDeleted=[],null!=e.accountId&&this.setAccountId(e.accountId),null!=e.key&&this.setKey(e.key),null!=e.receiverSignatureRequired&&this.setReceiverSignatureRequired(e.receiverSignatureRequired),null!=e.proxyAccountId&&this.setProxyAccountId(e.proxyAccountId),null!=e.autoRenewPeriod&&this.setAutoRenewPeriod(e.autoRenewPeriod),null!=e.expirationTime&&this.setExpirationTime(e.expirationTime),null!=e.accountMemo&&this.setAccountMemo(e.accountMemo),null!=e.maxAutomaticTokenAssociations&&this.setMaxAutomaticTokenAssociations(e.maxAutomaticTokenAssociations),null!=e.stakedAccountId&&this.setStakedAccountId(e.stakedAccountId),null!=e.stakedNodeId&&this.setStakedNodeId(e.stakedNodeId),null!=e.declineStakingReward&&this.setDeclineStakingReward(e.declineStakingReward),null!=e.hooksToBeCreated&&this.setHooksToCreate(e.hooksToBeCreated),null!=e.hooksToBeDeleted&&this.setHooksToDelete(e.hooksToBeDeleted)}static _fromProtobuf(t,r,a,c,d){const l=d[0].cryptoUpdateAccount;return e._fromProtobufTransactions(new u({accountId:null!=l.accountIDToUpdate?o._fromProtobuf(l.accountIDToUpdate):void 0,key:null!=l.key?s._fromProtobufKey(l.key):void 0,receiverSignatureRequired:null!=l.receiverSigRequiredWrapper&&Object.hasOwn(l.receiverSigRequiredWrapper,"value")?l.receiverSigRequiredWrapper.value:void 0,proxyAccountId:null!=l.proxyAccountID?o._fromProtobuf(l.proxyAccountID):void 0,autoRenewPeriod:null!=l.autoRenewPeriod&&null!=l.autoRenewPeriod.seconds?l.autoRenewPeriod.seconds:void 0,expirationTime:null!=l.expirationTime?i._fromProtobuf(l.expirationTime):void 0,accountMemo:null!=l.memo&&Object.hasOwn(l.memo,"value")?l.memo.value:void 0,maxAutomaticTokenAssociations:null!=l.maxAutomaticTokenAssociations&&null!=l.maxAutomaticTokenAssociations.value&&Object.hasOwn(l.maxAutomaticTokenAssociations,"value")?n.fromNumber(l.maxAutomaticTokenAssociations.value):void 0,stakedAccountId:null!=l.stakedAccountId?o._fromProtobuf(l.stakedAccountId):void 0,stakedNodeId:null!=l.stakedNodeId?l.stakedNodeId:void 0,declineStakingReward:null!=l.declineReward&&Object.hasOwn(l.declineReward,"value")?l.declineReward.value:void 0}),t,r,a,c,d)}get accountId(){return this._accountId}setAccountId(e){return this._requireNotFrozen(),this._accountId="string"==typeof e?o.fromString(e):e.clone(),this}get key(){return this._key}setKey(e){return this._requireNotFrozen(),this._key=e,this}get receiverSignatureRequired(){return this._receiverSignatureRequired}setReceiverSignatureRequired(e){return this._requireNotFrozen(),this._receiverSignatureRequired=e,this}get proxyAccountId(){return this._proxyAccountId}setProxyAccountId(e){return this._requireNotFrozen(),this._proxyAccountId=e,this}get autoRenewPeriod(){return this._autoRenewPeriod}setAutoRenewPeriod(e){return this._requireNotFrozen(),this._autoRenewPeriod=e instanceof r?e:new r(e),this}get expirationTime(){return this._expirationTime}setExpirationTime(e){return this._requireNotFrozen(),this._expirationTime=e instanceof Date?i.fromDate(e):e,this}get accountMemo(){return this._accountMemo}setAccountMemo(e){return this._requireNotFrozen(),this._accountMemo=e,this}clearAccountMemo(){return this._requireNotFrozen(),this._accountMemo=null,this}get maxAutomaticTokenAssociations(){return this._maxAutomaticTokenAssociations}setMaxAutomaticTokenAssociations(e){return this._requireNotFrozen(),this._maxAutomaticTokenAssociations="number"==typeof e?n.fromNumber(e):e,this}get aliasKey(){return null}setAliasKey(e){return this}get stakedAccountId(){return this._stakedAccountId}setStakedAccountId(e){return this._requireNotFrozen(),this._stakedAccountId="string"==typeof e?o.fromString(e):e,this}clearStakedAccountId(){return this._requireNotFrozen(),this._stakedAccountId=new o(0,0,0),this}get stakedNodeId(){return this._stakedNodeId}setStakedNodeId(e){return this._requireNotFrozen(),this._stakedNodeId=n.fromValue(e),this}clearStakedNodeId(){return this._requireNotFrozen(),this._stakedNodeId=n.fromNumber(-1),this}get declineStakingRewards(){return this._declineStakingReward}setDeclineStakingReward(e){return this._requireNotFrozen(),this._declineStakingReward=e,this}addHookToCreate(e){return this._hooksToBeCreated.push(e),this}setHooksToCreate(e){return this._hooksToBeCreated=e,this}get hooksToCreate(){return this._hooksToBeCreated}addHookToDelete(e){return this._hooksToBeDeleted.push(e),this}setHooksToDelete(e){return this._hooksToBeDeleted=e,this}get hooksToDelete(){return this._hooksToBeDeleted}_validateChecksums(e){null!=this._accountId&&this._accountId.validateChecksum(e),null!=this._proxyAccountId&&this._proxyAccountId.validateChecksum(e)}_execute(e,t){return e.crypto.updateAccount(t)}_getTransactionDataCase(){return"cryptoUpdateAccount"}_makeTransactionData(){return{accountIDToUpdate:null!=this._accountId?this._accountId._toProtobuf():null,key:null!=this._key?this._key._toProtobufKey():null,expirationTime:null!=this._expirationTime?this._expirationTime._toProtobuf():null,proxyAccountID:null!=this._proxyAccountId?this._proxyAccountId._toProtobuf():null,autoRenewPeriod:null!=this._autoRenewPeriod?this._autoRenewPeriod._toProtobuf():null,receiverSigRequiredWrapper:null==this._receiverSignatureRequired?null:{value:this._receiverSignatureRequired},memo:null!=this._accountMemo?{value:this._accountMemo}:null,maxAutomaticTokenAssociations:null!=this._maxAutomaticTokenAssociations?{value:this._maxAutomaticTokenAssociations.toInt()}:null,stakedAccountId:null!=this.stakedAccountId?this.stakedAccountId._toProtobuf():null,stakedNodeId:this.stakedNodeId,declineReward:null!=this.declineStakingRewards?{value:this.declineStakingRewards}:null,hookIdsToDelete:this._hooksToBeDeleted,hookCreationDetails:this._hooksToBeCreated.map(e=>e._toProtobuf())}}_getLogId(){return`AccountUpdateTransaction:${this._transactionIds.current.validStart.toString()}`}}t.set("cryptoUpdateAccount",u._fromProtobuf);export{u as default};
|
|
2
2
|
//# sourceMappingURL=AccountUpdateTransaction.js.map
|