@onekeyfe/blockchain-libs
Version:
OneKey Blockchain Libs
97 lines • 5.01 kB
JavaScript
;
/* Copyright (c) 2019 Algorand, llc */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeAssetTransferTxnWithSuggestedParams = exports.makePaymentTxnWithSuggestedParams = void 0;
const txnBuilder = __importStar(require("./transaction"));
const types_1 = require("./types");
/**
* makePaymentTxnWithSuggestedParams takes payment arguments and returns a Transaction object
* @param from - string representation of Algorand address of sender
* @param to - string representation of Algorand address of recipient
* @param amount - integer amount to send, in microAlgos
* @param closeRemainderTo - optionally close out remaining account balance to this account, represented as string rep of Algorand address
* @param note - uint8array of arbitrary data for sender to store
* @param suggestedParams - a dict holding common-to-all-txns args:
* fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true
* flatFee - bool optionally set this to true to specify fee as microalgos-per-txn
* If true, txn fee may fall below the ALGORAND_MIN_TX_FEE
* firstRound - integer first protocol round on which this txn is valid
* lastRound - integer last protocol round on which this txn is valid
* genesisHash - string specifies hash genesis block of network in use
* genesisID - string specifies genesis ID of network in use
* @param rekeyTo - rekeyTo address, optional
*/
function makePaymentTxnWithSuggestedParams(from, to, amount, closeRemainderTo, note, suggestedParams, rekeyTo) {
const o = {
from,
to,
amount,
closeRemainderTo,
note,
suggestedParams,
type: types_1.TransactionType.pay,
reKeyTo: rekeyTo,
};
return new txnBuilder.Transaction(o);
}
exports.makePaymentTxnWithSuggestedParams = makePaymentTxnWithSuggestedParams;
/** makeAssetTransferTxnWithSuggestedParams allows for the creation of an asset transfer transaction.
* Special case: to begin accepting assets, set amount=0 and from=to.
*
* @param from - string representation of Algorand address of sender
* @param to - string representation of Algorand address of asset recipient
* @param closeRemainderTo - optional - string representation of Algorand address - if provided,
* send all remaining assets after transfer to the "closeRemainderTo" address and close "from"'s asset holdings
* @param revocationTarget - optional - string representation of Algorand address - if provided,
* and if "from" is the asset's revocation manager, then deduct from "revocationTarget" rather than "from"
* @param amount - integer amount of assets to send
* @param note - uint8array of arbitrary data for sender to store
* @param assetIndex - int asset index uniquely specifying the asset
* @param suggestedParams - a dict holding common-to-all-txns args:
* fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true
* flatFee - bool optionally set this to true to specify fee as microalgos-per-txn
* If true, txn fee may fall below the ALGORAND_MIN_TX_FEE
* * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn
* If true, txn fee may fall below the ALGORAND_MIN_TX_FEE
* firstRound - integer first protocol round on which this txn is valid
* lastRound - integer last protocol round on which this txn is valid
* genesisHash - string specifies hash genesis block of network in use
* genesisID - string specifies genesis ID of network in use
* @param rekeyTo - rekeyTo address, optional
*/
function makeAssetTransferTxnWithSuggestedParams(from, to, closeRemainderTo, revocationTarget, amount, note, assetIndex, suggestedParams, rekeyTo) {
const o = {
type: types_1.TransactionType.axfer,
from,
to,
amount,
suggestedParams,
assetIndex,
note,
assetRevocationTarget: revocationTarget,
closeRemainderTo,
reKeyTo: rekeyTo,
};
return new txnBuilder.Transaction(o);
}
exports.makeAssetTransferTxnWithSuggestedParams = makeAssetTransferTxnWithSuggestedParams;
//# sourceMappingURL=makeTxn.js.map