@bitgo-beta/sdk-coin-hbar 1.0.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/.eslintignore +5 -0
- package/.mocharc.yml +8 -0
- package/CHANGELOG.md +26 -0
- package/LICENSE +191 -0
- package/README.md +30 -0
- package/dist/src/hbar.d.ts +114 -0
- package/dist/src/hbar.d.ts.map +1 -0
- package/dist/src/hbar.js +301 -0
- package/dist/src/hbarToken.d.ts +18 -0
- package/dist/src/hbarToken.d.ts.map +1 -0
- package/dist/src/hbarToken.js +49 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +17 -0
- package/dist/src/lib/coinTransferBuilder.d.ts +47 -0
- package/dist/src/lib/coinTransferBuilder.d.ts.map +1 -0
- package/dist/src/lib/coinTransferBuilder.js +145 -0
- package/dist/src/lib/constants.d.ts +8 -0
- package/dist/src/lib/constants.d.ts.map +1 -0
- package/dist/src/lib/constants.js +12 -0
- package/dist/src/lib/iface.d.ts +50 -0
- package/dist/src/lib/iface.d.ts.map +1 -0
- package/dist/src/lib/iface.js +3 -0
- package/dist/src/lib/index.d.ts +10 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/index.js +39 -0
- package/dist/src/lib/keyPair.d.ts +23 -0
- package/dist/src/lib/keyPair.d.ts.map +1 -0
- package/dist/src/lib/keyPair.js +70 -0
- package/dist/src/lib/tokenAssociateBuilder.d.ts +38 -0
- package/dist/src/lib/tokenAssociateBuilder.d.ts.map +1 -0
- package/dist/src/lib/tokenAssociateBuilder.js +126 -0
- package/dist/src/lib/tokenTransferBuilder.d.ts +25 -0
- package/dist/src/lib/tokenTransferBuilder.d.ts.map +1 -0
- package/dist/src/lib/tokenTransferBuilder.js +116 -0
- package/dist/src/lib/transaction.d.ts +106 -0
- package/dist/src/lib/transaction.d.ts.map +1 -0
- package/dist/src/lib/transaction.js +317 -0
- package/dist/src/lib/transactionBuilder.d.ts +111 -0
- package/dist/src/lib/transactionBuilder.d.ts.map +1 -0
- package/dist/src/lib/transactionBuilder.js +270 -0
- package/dist/src/lib/transactionBuilderFactory.d.ts +47 -0
- package/dist/src/lib/transactionBuilderFactory.d.ts.map +1 -0
- package/dist/src/lib/transactionBuilderFactory.js +88 -0
- package/dist/src/lib/transferBuilder.d.ts +24 -0
- package/dist/src/lib/transferBuilder.d.ts.map +1 -0
- package/dist/src/lib/transferBuilder.js +74 -0
- package/dist/src/lib/utils.d.ts +193 -0
- package/dist/src/lib/utils.d.ts.map +1 -0
- package/dist/src/lib/utils.js +410 -0
- package/dist/src/lib/walletInitializationBuilder.d.ts +28 -0
- package/dist/src/lib/walletInitializationBuilder.d.ts.map +1 -0
- package/dist/src/lib/walletInitializationBuilder.js +110 -0
- package/dist/src/seedValidator.d.ts +31 -0
- package/dist/src/seedValidator.d.ts.map +1 -0
- package/dist/src/seedValidator.js +89 -0
- package/dist/src/thbar.d.ts +14 -0
- package/dist/src/thbar.d.ts.map +1 -0
- package/dist/src/thbar.js +17 -0
- package/package.json +61 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.TransferBuilder = void 0;
|
|
23
|
+
const proto = __importStar(require("@hashgraph/proto"));
|
|
24
|
+
const sdk_core_1 = require("@bitgo-beta/sdk-core");
|
|
25
|
+
const transactionBuilder_1 = require("./transactionBuilder");
|
|
26
|
+
const utils_1 = require("./utils");
|
|
27
|
+
const constants_1 = require("./constants");
|
|
28
|
+
class TransferBuilder extends transactionBuilder_1.TransactionBuilder {
|
|
29
|
+
constructor(_coinConfig) {
|
|
30
|
+
super(_coinConfig);
|
|
31
|
+
this._txBodyData = new proto.CryptoTransferTransactionBody();
|
|
32
|
+
this._txBody.cryptoTransfer = this._txBodyData;
|
|
33
|
+
this._recipients = [];
|
|
34
|
+
}
|
|
35
|
+
/** @inheritdoc */
|
|
36
|
+
async buildImplementation() {
|
|
37
|
+
this.transaction.setTransactionType(sdk_core_1.TransactionType.Send);
|
|
38
|
+
return await super.buildImplementation();
|
|
39
|
+
}
|
|
40
|
+
/** @inheritdoc */
|
|
41
|
+
signImplementation(key) {
|
|
42
|
+
if (this._multiSignerKeyPairs.length >= constants_1.DEFAULT_SIGNER_NUMBER) {
|
|
43
|
+
throw new sdk_core_1.SigningError('A maximum of ' + constants_1.DEFAULT_SIGNER_NUMBER + ' can sign the transaction.');
|
|
44
|
+
}
|
|
45
|
+
return super.signImplementation(key);
|
|
46
|
+
}
|
|
47
|
+
// region Transfer fields
|
|
48
|
+
/**
|
|
49
|
+
* Set the recipient to be transferred
|
|
50
|
+
*
|
|
51
|
+
* @param {Recipient} recipient - recipient to transfer consisting destination address and amount
|
|
52
|
+
* @returns {TransferBuilder} - The builder with the new parameter set
|
|
53
|
+
*/
|
|
54
|
+
send(recipient) {
|
|
55
|
+
if (!utils_1.isValidAddress(recipient.address)) {
|
|
56
|
+
throw new sdk_core_1.InvalidParameterValueError('Invalid address');
|
|
57
|
+
}
|
|
58
|
+
if (!utils_1.isValidAmount(recipient.amount)) {
|
|
59
|
+
throw new sdk_core_1.InvalidParameterValueError('Invalid amount');
|
|
60
|
+
}
|
|
61
|
+
this._recipients.push(recipient);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
// endregion
|
|
65
|
+
// region Validators
|
|
66
|
+
validateMandatoryFields() {
|
|
67
|
+
if (this._recipients.length === 0) {
|
|
68
|
+
throw new sdk_core_1.BuildTransactionError('Invalid transaction: missing recipients');
|
|
69
|
+
}
|
|
70
|
+
super.validateMandatoryFields();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.TransferBuilder = TransferBuilder;
|
|
74
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNmZXJCdWlsZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi90cmFuc2ZlckJ1aWxkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUNBLHdEQUEwQztBQUMxQyxtREFNOEI7QUFFOUIsNkRBQTBEO0FBRTFELG1DQUF3RDtBQUN4RCwyQ0FBb0Q7QUFFcEQsTUFBYSxlQUFnQixTQUFRLHVDQUFrQjtJQUlyRCxZQUFZLFdBQWlDO1FBQzNDLEtBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQztRQUNuQixJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksS0FBSyxDQUFDLDZCQUE2QixFQUFFLENBQUM7UUFDN0QsSUFBSSxDQUFDLE9BQU8sQ0FBQyxjQUFjLEdBQUcsSUFBSSxDQUFDLFdBQVcsQ0FBQztRQUMvQyxJQUFJLENBQUMsV0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52YWxpZGF0ZU1hbmRhdG9yeUZpZWxkcygpO1xuICB9XG4gIC8vIGVuZHJlZ2lvblxufVxuIl19
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { PrivateKey } from '@hashgraph/sdk';
|
|
2
|
+
import * as proto from '@hashgraph/proto';
|
|
3
|
+
import { AddressDetails } from './iface';
|
|
4
|
+
import { toHex, toUint8Array } from '@bitgo-beta/sdk-core';
|
|
5
|
+
import { BaseCoin } from '@bitgo-beta/statics';
|
|
6
|
+
export { toHex, toUint8Array };
|
|
7
|
+
/**
|
|
8
|
+
* Returns whether the string is a valid Hedera account address
|
|
9
|
+
*
|
|
10
|
+
* In any form, `shard` and `realm` are assumed to be 0 if not provided.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} address - The address to be validated
|
|
13
|
+
* @returns {boolean} - The validation result
|
|
14
|
+
*/
|
|
15
|
+
export declare function isValidAddress(address: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Returns whether the string is a valid Hedera transaction id
|
|
18
|
+
*
|
|
19
|
+
* @param {string} txId - The transaction id to be validated
|
|
20
|
+
* @returns {boolean} - The validation result
|
|
21
|
+
*/
|
|
22
|
+
export declare function isValidTransactionId(txId: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
Returns whether the string is a valid Hedera public key
|
|
25
|
+
*
|
|
26
|
+
* @param {string} key - The public key to be validated
|
|
27
|
+
* @returns {boolean} - The validation result
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidPublicKey(key: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Checks whether nodeJS.process exist and if a node version is defined to determine if this is an nodeJS environment
|
|
32
|
+
*
|
|
33
|
+
* @returns {boolean} - The validation result
|
|
34
|
+
*/
|
|
35
|
+
export declare function isNodeEnvironment(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Calculate the current time with nanoseconds precision
|
|
38
|
+
*
|
|
39
|
+
* @returns {string} - The current time in seconds
|
|
40
|
+
*/
|
|
41
|
+
export declare function getCurrentTime(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Returns whether the string is a valid timestamp
|
|
44
|
+
*
|
|
45
|
+
* Nanoseconds are optional and can be passed after a dot, for example: 1595374723.356981689
|
|
46
|
+
*
|
|
47
|
+
* @param {string} time - The timestamp to be validated
|
|
48
|
+
* @returns {boolean} - The validation result
|
|
49
|
+
*/
|
|
50
|
+
export declare function isValidTimeString(time: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Returns whether the string is a valid amount number
|
|
53
|
+
*
|
|
54
|
+
* @param {string} amount - The string to validate
|
|
55
|
+
* @returns {boolean} - The validation result
|
|
56
|
+
*/
|
|
57
|
+
export declare function isValidAmount(amount: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Returns whether the provided raw transaction accommodates to bitgo's preferred format
|
|
60
|
+
*
|
|
61
|
+
* @param {any} rawTransaction - The raw transaction to be checked
|
|
62
|
+
* @returns {boolean} - The validation result
|
|
63
|
+
*/
|
|
64
|
+
export declare function isValidRawTransactionFormat(rawTransaction: any): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Returns a string representation of an {proto.IAccountID} object
|
|
67
|
+
*
|
|
68
|
+
* @param {proto.IAccountID} accountId - Account id to be cast to string
|
|
69
|
+
* @returns {string} - The string representation of the {proto.IAccountID}
|
|
70
|
+
*/
|
|
71
|
+
export declare function stringifyAccountId({ shardNum, realmNum, accountNum }: proto.IAccountID): string;
|
|
72
|
+
/**
|
|
73
|
+
* Returns a string representation of an {proto.ITokenID} object
|
|
74
|
+
*
|
|
75
|
+
* @param {proto.ITokenID} - token id to be cast to string
|
|
76
|
+
* @returns {string} - the string representation of the {proto.ITokenID}
|
|
77
|
+
*/
|
|
78
|
+
export declare function stringifyTokenId({ shardNum, realmNum, tokenNum }: proto.ITokenID): string;
|
|
79
|
+
/**
|
|
80
|
+
* Returns a string representation of an {proto.ITimestamp} object
|
|
81
|
+
*
|
|
82
|
+
* @param {proto.ITimestamp} timestamp - Timestamp to be cast to string
|
|
83
|
+
* @returns {string} - The string representation of the {proto.ITimestamp}
|
|
84
|
+
*/
|
|
85
|
+
export declare function stringifyTxTime({ seconds, nanos }: proto.ITimestamp): string;
|
|
86
|
+
/**
|
|
87
|
+
* Remove the specified prefix from a string only if it starts with that prefix
|
|
88
|
+
*
|
|
89
|
+
* @param {string} prefix - The prefix to be removed
|
|
90
|
+
* @param {string} key - The original string, usually a private or public key
|
|
91
|
+
* @returns {string} - The string without prefix
|
|
92
|
+
*/
|
|
93
|
+
export declare function removePrefix(prefix: string, key: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Check if this is a valid memo
|
|
96
|
+
*
|
|
97
|
+
* @param {string} memo
|
|
98
|
+
* @returns {boolean}
|
|
99
|
+
*/
|
|
100
|
+
export declare function isValidMemo(memo: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Uses the native hashgraph SDK function to get a raw key.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} prv - Private key
|
|
105
|
+
* @returns {PrivateKey}
|
|
106
|
+
*/
|
|
107
|
+
export declare function createRawKey(prv: string): PrivateKey;
|
|
108
|
+
/**
|
|
109
|
+
* Converts a stellar public key to ed25519 hex format
|
|
110
|
+
*
|
|
111
|
+
* @param {string} stellarPub
|
|
112
|
+
* @returns {string}
|
|
113
|
+
*/
|
|
114
|
+
export declare function convertFromStellarPub(stellarPub: string): string;
|
|
115
|
+
/**
|
|
116
|
+
* Checks if two addresses have the same base address
|
|
117
|
+
*
|
|
118
|
+
* @param {String} address
|
|
119
|
+
* @param {String} baseAddress
|
|
120
|
+
* @returns {boolean}
|
|
121
|
+
*/
|
|
122
|
+
export declare function isSameBaseAddress(address: string, baseAddress: string): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Returns the base address portion of an address
|
|
125
|
+
*
|
|
126
|
+
* @param {String} address
|
|
127
|
+
* @returns {String} - the base address
|
|
128
|
+
*/
|
|
129
|
+
export declare function getBaseAddress(address: string): string;
|
|
130
|
+
/**
|
|
131
|
+
* Process address into address and memo id
|
|
132
|
+
*
|
|
133
|
+
* @param {string} rawAddress
|
|
134
|
+
* @returns {AddressDetails} - object containing address and memo id
|
|
135
|
+
*/
|
|
136
|
+
export declare function getAddressDetails(rawAddress: string): AddressDetails;
|
|
137
|
+
/**
|
|
138
|
+
* Validate and return address with appended memo id
|
|
139
|
+
*
|
|
140
|
+
* @param {AddressDetails} addressDetails - Address which to append memo id
|
|
141
|
+
* @returns {string} - Address with appended memo id
|
|
142
|
+
*/
|
|
143
|
+
export declare function normalizeAddress({ address, memoId }: AddressDetails): string;
|
|
144
|
+
/**
|
|
145
|
+
* Return boolean indicating whether input is a valid address with memo id
|
|
146
|
+
*
|
|
147
|
+
* @param {string} address - Address in the form <address>?memoId=<memoId>
|
|
148
|
+
* @returns {boolean} - True if input is a valid address
|
|
149
|
+
*/
|
|
150
|
+
export declare function isValidAddressWithPaymentId(address: string): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Build hedera {proto.TokenID} object from token ID string
|
|
153
|
+
*
|
|
154
|
+
* @param {string} tokenID - The token ID to build
|
|
155
|
+
* @returns {proto.TokenID} - The resulting proto TokenID object
|
|
156
|
+
*/
|
|
157
|
+
export declare function buildHederaTokenID(tokenID: string): proto.TokenID;
|
|
158
|
+
/**
|
|
159
|
+
* Build hedera {proto.AccountID} object from account ID string
|
|
160
|
+
*
|
|
161
|
+
* @param {string} accountID - The account ID to build
|
|
162
|
+
* @returns {proto} - The resulting proto AccountID object
|
|
163
|
+
*/
|
|
164
|
+
export declare function buildHederaAccountID(accountID: string): proto.AccountID;
|
|
165
|
+
/**
|
|
166
|
+
* Check if Hedera token ID is valid and supported
|
|
167
|
+
*
|
|
168
|
+
* @param {string} tokenId - The token ID to validate
|
|
169
|
+
* @returns {boolean} - True if tokenId is valid and supported
|
|
170
|
+
*/
|
|
171
|
+
export declare function isValidHederaTokenID(tokenId: string): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Get the associated hedera token ID from token name, if supported
|
|
174
|
+
*
|
|
175
|
+
* @param {string} tokenName - The hedera token name
|
|
176
|
+
* @returns {boolean} - The associated token ID or undefined if not supported
|
|
177
|
+
*/
|
|
178
|
+
export declare function getHederaTokenIdFromName(tokenName: string): string | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* Get the associated hedera token from token ID, if supported
|
|
181
|
+
*
|
|
182
|
+
* @param tokenId - The token address
|
|
183
|
+
* @returns {BaseCoin} - BaseCoin object for the matching token
|
|
184
|
+
*/
|
|
185
|
+
export declare function getHederaTokenNameFromId(tokenId: string): Readonly<BaseCoin> | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* Return boolean indicating whether input is a valid token transfer transaction
|
|
188
|
+
*
|
|
189
|
+
* @param {proto.ICryptoTransferTransactionBody | null} transferTxBody is a transfer transaction body
|
|
190
|
+
* @returns {boolean} true is input is a valid token transfer transaction
|
|
191
|
+
*/
|
|
192
|
+
export declare function isTokenTransfer(transferTxBody: proto.ICryptoTransferTransactionBody | null): boolean;
|
|
193
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAqC,MAAM,gBAAgB,CAAC;AAC1F,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAc,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAsB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;AAI/B;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAUvD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAa1D;A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