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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18 | __setModuleDefault(result, mod);
|
19 | return result;
|
20 | };
|
21 | Object.defineProperty(exports, "__esModule", { value: true });
|
22 | const utils = __importStar(require("./utils"));
|
23 | const common_1 = require("../common");
|
24 | function createPaymentChannelCreateTransaction(account, paymentChannel) {
|
25 | const txJSON = {
|
26 | Account: account,
|
27 | TransactionType: 'PaymentChannelCreate',
|
28 | Amount: common_1.xrpToDrops(paymentChannel.amount),
|
29 | Destination: paymentChannel.destination,
|
30 | SettleDelay: paymentChannel.settleDelay,
|
31 | PublicKey: paymentChannel.publicKey.toUpperCase()
|
32 | };
|
33 | if (paymentChannel.cancelAfter != null) {
|
34 | txJSON.CancelAfter = common_1.iso8601ToRippleTime(paymentChannel.cancelAfter);
|
35 | }
|
36 | if (paymentChannel.sourceTag != null) {
|
37 | txJSON.SourceTag = paymentChannel.sourceTag;
|
38 | }
|
39 | if (paymentChannel.destinationTag != null) {
|
40 | txJSON.DestinationTag = paymentChannel.destinationTag;
|
41 | }
|
42 | return txJSON;
|
43 | }
|
44 | function preparePaymentChannelCreate(address, paymentChannelCreate, instructions = {}) {
|
45 | try {
|
46 | common_1.validate.preparePaymentChannelCreate({
|
47 | address,
|
48 | paymentChannelCreate,
|
49 | instructions
|
50 | });
|
51 | const txJSON = createPaymentChannelCreateTransaction(address, paymentChannelCreate);
|
52 | return utils.prepareTransaction(txJSON, this, instructions);
|
53 | }
|
54 | catch (e) {
|
55 | return Promise.reject(e);
|
56 | }
|
57 | }
|
58 | exports.default = preparePaymentChannelCreate;
|
59 |
|
\ | No newline at end of file |