algosdk 1.24.1 → 2.0.0
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 +4 -4
- package/dist/browser/algosdk.min.js +1 -1
- package/dist/browser/algosdk.min.js.LICENSE.txt +0 -18
- package/dist/browser/algosdk.min.js.map +1 -1
- package/dist/cjs/client/v2/algod/algod.js +1 -1
- package/dist/cjs/client/v2/algod/algod.js.map +1 -1
- package/dist/cjs/client/v2/algod/models/types.js +161 -123
- package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupAssetTransactions.js +0 -7
- package/dist/cjs/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
- package/dist/cjs/dryrun.js +16 -7
- package/dist/cjs/dryrun.js.map +1 -1
- package/dist/cjs/logicsig.js +3 -14
- package/dist/cjs/logicsig.js.map +1 -1
- package/dist/cjs/main.js +3 -6
- package/dist/cjs/main.js.map +1 -1
- package/dist/cjs/makeTxn.js +1 -193
- package/dist/cjs/makeTxn.js.map +1 -1
- package/dist/esm/client/v2/algod/algod.js +1 -1
- package/dist/esm/client/v2/algod/algod.js.map +1 -1
- package/dist/esm/client/v2/algod/models/types.js +160 -120
- package/dist/esm/client/v2/algod/models/types.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupAssetTransactions.js +0 -7
- package/dist/esm/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
- package/dist/esm/dryrun.js +16 -7
- package/dist/esm/dryrun.js.map +1 -1
- package/dist/esm/logicsig.js +2 -12
- package/dist/esm/logicsig.js.map +1 -1
- package/dist/esm/main.js +1 -4
- package/dist/esm/main.js.map +1 -1
- package/dist/esm/makeTxn.js +0 -185
- package/dist/esm/makeTxn.js.map +1 -1
- package/dist/types/client/v2/algod/algod.d.ts +1 -1
- package/dist/types/client/v2/algod/models/types.d.ts +122 -67
- package/dist/types/client/v2/indexer/lookupAssetTransactions.d.ts +0 -4
- package/dist/types/logicsig.d.ts +2 -10
- package/dist/types/main.d.ts +1 -3
- package/dist/types/makeTxn.d.ts +1 -147
- package/dist/types/types/transactions/encoded.d.ts +0 -15
- package/package.json +1 -1
- package/src/client/v2/algod/algod.ts +2 -2
- package/src/client/v2/algod/models/types.ts +318 -249
- package/src/client/v2/indexer/lookupAssetTransactions.ts +0 -8
- package/src/dryrun.ts +13 -13
- package/src/logicsig.ts +2 -13
- package/src/main.ts +1 -5
- package/src/makeTxn.ts +0 -421
- package/src/types/transactions/encoded.ts +0 -17
- package/dist/cjs/client/algod.js +0 -295
- package/dist/cjs/client/algod.js.map +0 -1
- package/dist/cjs/logic/langspec.json +0 -2014
- package/dist/cjs/logic/logic.js +0 -262
- package/dist/cjs/logic/logic.js.map +0 -1
- package/dist/cjs/logicTemplates/dynamicfee.js +0 -192
- package/dist/cjs/logicTemplates/dynamicfee.js.map +0 -1
- package/dist/cjs/logicTemplates/htlc.js +0 -145
- package/dist/cjs/logicTemplates/htlc.js.map +0 -1
- package/dist/cjs/logicTemplates/index.js +0 -19
- package/dist/cjs/logicTemplates/index.js.map +0 -1
- package/dist/cjs/logicTemplates/limitorder.js +0 -167
- package/dist/cjs/logicTemplates/limitorder.js.map +0 -1
- package/dist/cjs/logicTemplates/periodicpayment.js +0 -163
- package/dist/cjs/logicTemplates/periodicpayment.js.map +0 -1
- package/dist/cjs/logicTemplates/split.js +0 -154
- package/dist/cjs/logicTemplates/split.js.map +0 -1
- package/dist/cjs/logicTemplates/templates.js +0 -67
- package/dist/cjs/logicTemplates/templates.js.map +0 -1
- package/dist/esm/client/algod.js +0 -295
- package/dist/esm/client/algod.js.map +0 -1
- package/dist/esm/logic/langspec.json +0 -2014
- package/dist/esm/logic/logic.js +0 -249
- package/dist/esm/logic/logic.js.map +0 -1
- package/dist/esm/logicTemplates/dynamicfee.js +0 -192
- package/dist/esm/logicTemplates/dynamicfee.js.map +0 -1
- package/dist/esm/logicTemplates/htlc.js +0 -145
- package/dist/esm/logicTemplates/htlc.js.map +0 -1
- package/dist/esm/logicTemplates/index.js +0 -19
- package/dist/esm/logicTemplates/index.js.map +0 -1
- package/dist/esm/logicTemplates/limitorder.js +0 -167
- package/dist/esm/logicTemplates/limitorder.js.map +0 -1
- package/dist/esm/logicTemplates/periodicpayment.js +0 -163
- package/dist/esm/logicTemplates/periodicpayment.js.map +0 -1
- package/dist/esm/logicTemplates/split.js +0 -154
- package/dist/esm/logicTemplates/split.js.map +0 -1
- package/dist/esm/logicTemplates/templates.js +0 -67
- package/dist/esm/logicTemplates/templates.js.map +0 -1
- package/dist/types/client/algod.d.ts +0 -162
- package/dist/types/logic/logic.d.ts +0 -45
- package/dist/types/logicTemplates/dynamicfee.d.ts +0 -59
- package/dist/types/logicTemplates/htlc.d.ts +0 -51
- package/dist/types/logicTemplates/index.d.ts +0 -16
- package/dist/types/logicTemplates/limitorder.d.ts +0 -70
- package/dist/types/logicTemplates/periodicpayment.d.ts +0 -58
- package/dist/types/logicTemplates/split.d.ts +0 -57
- package/dist/types/logicTemplates/templates.d.ts +0 -6
- package/src/client/algod.js +0 -365
- package/src/logic/langspec.json +0 -2014
- package/src/logic/logic.ts +0 -316
- package/src/logicTemplates/dynamicfee.js +0 -219
- package/src/logicTemplates/htlc.js +0 -165
- package/src/logicTemplates/index.js +0 -20
- package/src/logicTemplates/limitorder.js +0 -227
- package/src/logicTemplates/periodicpayment.js +0 -208
- package/src/logicTemplates/split.js +0 -208
- package/src/logicTemplates/templates.js +0 -78
package/dist/esm/logic/logic.js
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-bitwise */
|
|
2
|
-
/**
|
|
3
|
-
* Utilities for working with program bytes.
|
|
4
|
-
*/
|
|
5
|
-
/** @deprecated langspec.json is deprecated aross all SDKs */
|
|
6
|
-
import langspec from './langspec.json';
|
|
7
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
8
|
-
let opcodes;
|
|
9
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
10
|
-
const maxCost = 20000;
|
|
11
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
12
|
-
const maxLength = 1000;
|
|
13
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
14
|
-
export function parseUvarint(array) {
|
|
15
|
-
let x = 0;
|
|
16
|
-
let s = 0;
|
|
17
|
-
for (let i = 0; i < array.length; i++) {
|
|
18
|
-
const b = array[i];
|
|
19
|
-
if (b < 0x80) {
|
|
20
|
-
if (i > 9 || (i === 9 && b > 1)) {
|
|
21
|
-
return [0, -(i + 1)];
|
|
22
|
-
}
|
|
23
|
-
return [x | (b << s), i + 1];
|
|
24
|
-
}
|
|
25
|
-
x += (b & 0x7f) << s;
|
|
26
|
-
s += 7;
|
|
27
|
-
}
|
|
28
|
-
return [0, 0];
|
|
29
|
-
}
|
|
30
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
31
|
-
function readIntConstBlock(program, pc) {
|
|
32
|
-
let size = 1;
|
|
33
|
-
const parsed = parseUvarint(program.slice(pc + size));
|
|
34
|
-
const numInts = parsed[0];
|
|
35
|
-
let bytesUsed = parsed[1];
|
|
36
|
-
if (bytesUsed <= 0) {
|
|
37
|
-
throw new Error(`could not decode int const block size at pc=${pc + size}`);
|
|
38
|
-
}
|
|
39
|
-
const ints = [];
|
|
40
|
-
size += bytesUsed;
|
|
41
|
-
for (let i = 0; i < numInts; i++) {
|
|
42
|
-
if (pc + size >= program.length) {
|
|
43
|
-
throw new Error('intcblock ran past end of program');
|
|
44
|
-
}
|
|
45
|
-
let numberFound;
|
|
46
|
-
[numberFound, bytesUsed] = parseUvarint(program.slice(pc + size));
|
|
47
|
-
if (bytesUsed <= 0) {
|
|
48
|
-
throw new Error(`could not decode int const[${i}] block size at pc=${pc + size}`);
|
|
49
|
-
}
|
|
50
|
-
ints.push(numberFound);
|
|
51
|
-
size += bytesUsed;
|
|
52
|
-
}
|
|
53
|
-
return [size, ints];
|
|
54
|
-
}
|
|
55
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
56
|
-
function readByteConstBlock(program, pc) {
|
|
57
|
-
let size = 1;
|
|
58
|
-
const parsed = parseUvarint(program.slice(pc + size));
|
|
59
|
-
const numInts = parsed[0];
|
|
60
|
-
let bytesUsed = parsed[1];
|
|
61
|
-
if (bytesUsed <= 0) {
|
|
62
|
-
throw new Error(`could not decode []byte const block size at pc=${pc + size}`);
|
|
63
|
-
}
|
|
64
|
-
const byteArrays = [];
|
|
65
|
-
size += bytesUsed;
|
|
66
|
-
for (let i = 0; i < numInts; i++) {
|
|
67
|
-
if (pc + size >= program.length) {
|
|
68
|
-
throw new Error('bytecblock ran past end of program');
|
|
69
|
-
}
|
|
70
|
-
let itemLen;
|
|
71
|
-
[itemLen, bytesUsed] = parseUvarint(program.slice(pc + size));
|
|
72
|
-
if (bytesUsed <= 0) {
|
|
73
|
-
throw new Error(`could not decode []byte] const[${i}] block size at pc=${pc + size}`);
|
|
74
|
-
}
|
|
75
|
-
size += bytesUsed;
|
|
76
|
-
if (pc + size + itemLen > program.length) {
|
|
77
|
-
throw new Error('bytecblock ran past end of program');
|
|
78
|
-
}
|
|
79
|
-
const byteArray = program.slice(pc + size, pc + size + itemLen);
|
|
80
|
-
byteArrays.push(byteArray);
|
|
81
|
-
size += itemLen;
|
|
82
|
-
}
|
|
83
|
-
return [size, byteArrays];
|
|
84
|
-
}
|
|
85
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
86
|
-
function readPushIntOp(program, pc) {
|
|
87
|
-
let size = 1;
|
|
88
|
-
const [numberFound, bytesUsed] = parseUvarint(program.slice(pc + size));
|
|
89
|
-
if (bytesUsed <= 0) {
|
|
90
|
-
throw new Error(`could not decode push int const at pc=${pc + size}`);
|
|
91
|
-
}
|
|
92
|
-
size += bytesUsed;
|
|
93
|
-
return [size, numberFound];
|
|
94
|
-
}
|
|
95
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
96
|
-
function readPushByteOp(program, pc) {
|
|
97
|
-
let size = 1;
|
|
98
|
-
const [itemLen, bytesUsed] = parseUvarint(program.slice(pc + size));
|
|
99
|
-
if (bytesUsed <= 0) {
|
|
100
|
-
throw new Error(`could not decode push []byte const size at pc=${pc + size}`);
|
|
101
|
-
}
|
|
102
|
-
size += bytesUsed;
|
|
103
|
-
if (pc + size + itemLen > program.length) {
|
|
104
|
-
throw new Error('pushbytes ran past end of program');
|
|
105
|
-
}
|
|
106
|
-
const byteArray = program.slice(pc + size, pc + size + itemLen);
|
|
107
|
-
size += itemLen;
|
|
108
|
-
return [size, byteArray];
|
|
109
|
-
}
|
|
110
|
-
/** readProgram validates program for length and running cost,
|
|
111
|
-
* and additionally provides the found int variables and byte blocks
|
|
112
|
-
*
|
|
113
|
-
* @deprecated Validation relies on metadata (`langspec.json`) that
|
|
114
|
-
* does not accurately represent opcode behavior across program versions.
|
|
115
|
-
* The behavior of `readProgram` relies on `langspec.json`.
|
|
116
|
-
* Thus, this method is being deprecated.
|
|
117
|
-
*
|
|
118
|
-
* @param program - Program to check
|
|
119
|
-
* @param args - Program arguments as array of Uint8Array arrays
|
|
120
|
-
* @throws
|
|
121
|
-
* @returns
|
|
122
|
-
*/
|
|
123
|
-
export function readProgram(program, args) {
|
|
124
|
-
const intcblockOpcode = 32;
|
|
125
|
-
const bytecblockOpcode = 38;
|
|
126
|
-
const pushbytesOpcode = 128;
|
|
127
|
-
const pushintOpcode = 129;
|
|
128
|
-
if (!program) {
|
|
129
|
-
throw new Error('empty program');
|
|
130
|
-
}
|
|
131
|
-
if (typeof args === 'undefined') {
|
|
132
|
-
// eslint-disable-next-line no-param-reassign
|
|
133
|
-
args = [];
|
|
134
|
-
}
|
|
135
|
-
if (!Array.isArray(args)) {
|
|
136
|
-
throw new Error('invalid arguments');
|
|
137
|
-
}
|
|
138
|
-
const [version, vlen] = parseUvarint(program);
|
|
139
|
-
if (vlen <= 0) {
|
|
140
|
-
throw new Error('version parsing error');
|
|
141
|
-
}
|
|
142
|
-
if (version > langspec.EvalMaxVersion) {
|
|
143
|
-
throw new Error('unsupported version');
|
|
144
|
-
}
|
|
145
|
-
let cost = 0;
|
|
146
|
-
let { length } = program;
|
|
147
|
-
for (const arg of args) {
|
|
148
|
-
length += arg.length;
|
|
149
|
-
}
|
|
150
|
-
if (length > maxLength) {
|
|
151
|
-
throw new Error('program too long');
|
|
152
|
-
}
|
|
153
|
-
if (!opcodes) {
|
|
154
|
-
opcodes = {};
|
|
155
|
-
for (const op of langspec.Ops) {
|
|
156
|
-
opcodes[op.Opcode] = op;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
let pc = vlen;
|
|
160
|
-
let ints = [];
|
|
161
|
-
let byteArrays = [];
|
|
162
|
-
while (pc < program.length) {
|
|
163
|
-
const op = opcodes[program[pc]];
|
|
164
|
-
if (op === undefined) {
|
|
165
|
-
throw new Error('invalid instruction');
|
|
166
|
-
}
|
|
167
|
-
cost += op.Cost;
|
|
168
|
-
let size = op.Size;
|
|
169
|
-
if (size === 0) {
|
|
170
|
-
switch (op.Opcode) {
|
|
171
|
-
case intcblockOpcode: {
|
|
172
|
-
let foundInts;
|
|
173
|
-
[size, foundInts] = readIntConstBlock(program, pc);
|
|
174
|
-
ints = ints.concat(foundInts);
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
case bytecblockOpcode: {
|
|
178
|
-
let foundByteArrays;
|
|
179
|
-
[size, foundByteArrays] = readByteConstBlock(program, pc);
|
|
180
|
-
byteArrays = byteArrays.concat(foundByteArrays);
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
case pushintOpcode: {
|
|
184
|
-
let foundInt;
|
|
185
|
-
[size, foundInt] = readPushIntOp(program, pc);
|
|
186
|
-
ints.push(foundInt);
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
case pushbytesOpcode: {
|
|
190
|
-
let foundByteArray;
|
|
191
|
-
[size, foundByteArray] = readPushByteOp(program, pc);
|
|
192
|
-
byteArrays.push(foundByteArray);
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
default: {
|
|
196
|
-
throw new Error('invalid instruction');
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
pc += size;
|
|
201
|
-
}
|
|
202
|
-
// costs calculated dynamically starting in v4
|
|
203
|
-
if (version < 4 && cost > maxCost) {
|
|
204
|
-
throw new Error('program too costly for version < 4. consider using v4.');
|
|
205
|
-
}
|
|
206
|
-
return [ints, byteArrays, true];
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* checkProgram validates program for length and running cost
|
|
210
|
-
*
|
|
211
|
-
* @deprecated Validation relies on metadata (`langspec.json`) that
|
|
212
|
-
* does not accurately represent opcode behavior across program versions.
|
|
213
|
-
* The behavior of `checkProgram` relies on `langspec.json`.
|
|
214
|
-
* Thus, this method is being deprecated.
|
|
215
|
-
*
|
|
216
|
-
* @param program - Program to check
|
|
217
|
-
* @param args - Program arguments as array of Uint8Array arrays
|
|
218
|
-
* @throws
|
|
219
|
-
* @returns true if success
|
|
220
|
-
*/
|
|
221
|
-
export function checkProgram(program, args) {
|
|
222
|
-
const [, , success] = readProgram(program, args);
|
|
223
|
-
return success;
|
|
224
|
-
}
|
|
225
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
226
|
-
export function checkIntConstBlock(program, pc) {
|
|
227
|
-
const [size] = readIntConstBlock(program, pc);
|
|
228
|
-
return size;
|
|
229
|
-
}
|
|
230
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
231
|
-
export function checkByteConstBlock(program, pc) {
|
|
232
|
-
const [size] = readByteConstBlock(program, pc);
|
|
233
|
-
return size;
|
|
234
|
-
}
|
|
235
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
236
|
-
export function checkPushIntOp(program, pc) {
|
|
237
|
-
const [size] = readPushIntOp(program, pc);
|
|
238
|
-
return size;
|
|
239
|
-
}
|
|
240
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
241
|
-
export function checkPushByteOp(program, pc) {
|
|
242
|
-
const [size] = readPushByteOp(program, pc);
|
|
243
|
-
return size;
|
|
244
|
-
}
|
|
245
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
246
|
-
export const langspecEvalMaxVersion = langspec.EvalMaxVersion;
|
|
247
|
-
/** @deprecated for langspec.json is deprecated aross all SDKs */
|
|
248
|
-
export const langspecLogicSigVersion = langspec.LogicSigVersion;
|
|
249
|
-
//# sourceMappingURL=logic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic.js","sourceRoot":"","sources":["../../../src/logic/logic.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;GAEG;AAEH,6DAA6D;AAC7D,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAqBvC,iEAAiE;AACjE,IAAI,OAEH,CAAC;AAEF,iEAAiE;AACjE,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,iEAAiE;AACjE,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB,iEAAiE;AACjE,MAAM,UAAU,YAAY,CAC1B,KAAiB;IAEjB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,IAAI,CAAC,GAAG,IAAI,EAAE;YACZ,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC/B,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aACtB;YACD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,C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C,CAAC;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,eAAe,CAAC,OAAmB,EAAE,EAAU;IAC7D,MAAM,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC3C,OAAO,IAAI,CAAC;AACd,CAAC;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,cAAc,CAAC;AAC9D,iEAAiE;AACjE,MAAM,CAAC,MAAM,uBAAuB,GAAG,QAAQ,CAAC,eAAe,CAAC"}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
const address = require('../encoding/address');
|
|
2
|
-
const encoding = require('../encoding/encoding');
|
|
3
|
-
const group = require('../group');
|
|
4
|
-
const logic = require('../logic/logic');
|
|
5
|
-
const logicSig = require('../logicsig');
|
|
6
|
-
const nacl = require('../nacl/naclWrappers');
|
|
7
|
-
const templates = require('./templates');
|
|
8
|
-
const transaction = require('../transaction');
|
|
9
|
-
class DynamicFee {
|
|
10
|
-
/**
|
|
11
|
-
* DynamicFee contract allows you to create a transaction without
|
|
12
|
-
* specifying the fee. The fee will be determined at the moment of
|
|
13
|
-
* transfer.
|
|
14
|
-
*
|
|
15
|
-
* @deprecated This feature will be removed in v2.
|
|
16
|
-
*
|
|
17
|
-
* Constructor Parameters:
|
|
18
|
-
* @param {string} receiver: address to receive the assets
|
|
19
|
-
* @param {int} amount: amount of assets to transfer
|
|
20
|
-
* @param {int} firstValid: first valid round for the transaction
|
|
21
|
-
* @param {int} lastValid: last valid round for the transaction
|
|
22
|
-
* @param {string} closeRemainder: if you would like to close the account after the transfer, specify the address that would recieve the remainder, else leave undefined
|
|
23
|
-
* @param {string} lease: leave undefined to generate a random lease, or supply a lease as base64
|
|
24
|
-
* @returns {DynamicFee}
|
|
25
|
-
*/
|
|
26
|
-
constructor(receiver, amount, firstValid, lastValid, closeRemainder, lease) {
|
|
27
|
-
// don't need to validate receiver, closeremainderto - insert will handle that
|
|
28
|
-
if (!Number.isSafeInteger(amount) || amount < 0)
|
|
29
|
-
throw Error('amount must be a positive number and smaller than 2^53-1');
|
|
30
|
-
if (!Number.isSafeInteger(firstValid) || firstValid < 0)
|
|
31
|
-
throw Error('firstValid must be a positive number and smaller than 2^53-1');
|
|
32
|
-
if (!Number.isSafeInteger(lastValid) || lastValid < 0)
|
|
33
|
-
throw Error('lastValid must be a positive number and smaller than 2^53-1');
|
|
34
|
-
if (typeof closeRemainder === 'undefined') {
|
|
35
|
-
// eslint-disable-next-line no-param-reassign
|
|
36
|
-
closeRemainder = address.ALGORAND_ZERO_ADDRESS_STRING;
|
|
37
|
-
}
|
|
38
|
-
if (typeof lease === 'undefined') {
|
|
39
|
-
const leaseBytes = nacl.randomBytes(32);
|
|
40
|
-
// eslint-disable-next-line no-param-reassign
|
|
41
|
-
lease = Buffer.from(leaseBytes).toString('base64');
|
|
42
|
-
}
|
|
43
|
-
const referenceProgramB64 = 'ASAFAgEHBgUmAyD+vKC7FEpaTqe0OKRoGsgObKEFvLYH/FZTJclWlfaiEyDmmpYeby1feshmB5JlUr6YI17TM2PKiJGLuck4qRW2+SB/g7Flf/H8U7ktwYFIodZd/C1LH6PWdyhK3dIAEm2QaTIEIhIzABAjEhAzAAcxABIQMwAIMQESEDEWIxIQMRAjEhAxBygSEDEJKRIQMQgkEhAxAiUSEDEEIQQSEDEGKhIQ';
|
|
44
|
-
const referenceProgramBytes = Buffer.from(referenceProgramB64, 'base64');
|
|
45
|
-
const referenceOffsets = [
|
|
46
|
-
5 /* firstValid */,
|
|
47
|
-
6 /* lastValid */,
|
|
48
|
-
7 /* receiver */,
|
|
49
|
-
11 /* closeRemainder */,
|
|
50
|
-
44 /* lease */,
|
|
51
|
-
76,
|
|
52
|
-
];
|
|
53
|
-
const injectionVector = [
|
|
54
|
-
amount,
|
|
55
|
-
firstValid,
|
|
56
|
-
lastValid,
|
|
57
|
-
receiver,
|
|
58
|
-
closeRemainder,
|
|
59
|
-
lease,
|
|
60
|
-
];
|
|
61
|
-
const injectionTypes = [
|
|
62
|
-
templates.valTypes.INT,
|
|
63
|
-
templates.valTypes.INT,
|
|
64
|
-
templates.valTypes.INT,
|
|
65
|
-
templates.valTypes.ADDRESS,
|
|
66
|
-
templates.valTypes.ADDRESS,
|
|
67
|
-
templates.valTypes.BASE64,
|
|
68
|
-
];
|
|
69
|
-
const injectedBytes = templates.inject(referenceProgramBytes, referenceOffsets, injectionVector, injectionTypes);
|
|
70
|
-
this.programBytes = injectedBytes;
|
|
71
|
-
const lsig = new logicSig.LogicSig(injectedBytes, undefined);
|
|
72
|
-
this.address = lsig.address();
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* returns the program bytes
|
|
76
|
-
* @returns {Uint8Array}
|
|
77
|
-
*/
|
|
78
|
-
getProgram() {
|
|
79
|
-
return this.programBytes;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* returns the string address of the contract
|
|
83
|
-
* @returns {string}
|
|
84
|
-
*/
|
|
85
|
-
getAddress() {
|
|
86
|
-
return this.address;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* signDynamicFee returns the main transaction and signed logic needed to complete the transfer.
|
|
91
|
-
* These should be sent to the fee payer, who can use GetDynamicFeeTransactions
|
|
92
|
-
*
|
|
93
|
-
* @deprecated This feature will be removed in v2.
|
|
94
|
-
*
|
|
95
|
-
* @param {Uint8Array} contract: the bytearray representing the contract
|
|
96
|
-
* @param {Uint8Array} secretKey: the secret key for building the logic sig
|
|
97
|
-
* @param {string} genesisHash: the genesisHash to use for the txn
|
|
98
|
-
* @returns {Object} object containing json of txnbuilder constructor arguments under "txn" and signed logicsig under "lsig"
|
|
99
|
-
*/
|
|
100
|
-
function signDynamicFee(contract, secretKey, genesisHash) {
|
|
101
|
-
const programOutputs = logic.readProgram(contract, undefined);
|
|
102
|
-
const ints = programOutputs[0];
|
|
103
|
-
const byteArrays = programOutputs[1];
|
|
104
|
-
const keys = nacl.keyPairFromSecretKey(secretKey);
|
|
105
|
-
const from = address.encodeAddress(keys.publicKey);
|
|
106
|
-
const to = address.encodeAddress(byteArrays[0]);
|
|
107
|
-
const fee = 0;
|
|
108
|
-
const amount = ints[2];
|
|
109
|
-
const closeRemainderTo = address.encodeAddress(byteArrays[1]);
|
|
110
|
-
const firstRound = ints[3];
|
|
111
|
-
const lastRound = ints[4];
|
|
112
|
-
const lease = new Uint8Array(byteArrays[2]);
|
|
113
|
-
const txn = {
|
|
114
|
-
from,
|
|
115
|
-
to,
|
|
116
|
-
fee,
|
|
117
|
-
amount,
|
|
118
|
-
closeRemainderTo,
|
|
119
|
-
firstRound,
|
|
120
|
-
lastRound,
|
|
121
|
-
genesisHash,
|
|
122
|
-
type: 'pay',
|
|
123
|
-
lease,
|
|
124
|
-
};
|
|
125
|
-
const lsig = new logicSig.LogicSig(contract, undefined);
|
|
126
|
-
lsig.sign(secretKey);
|
|
127
|
-
return { txn, lsig };
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* getDynamicFeeTransactions creates and signs the secondary dynamic fee transaction, updates
|
|
131
|
-
* transaction fields, and signs as the fee payer; it returns both
|
|
132
|
-
* transactions as bytes suitable for sendRaw.
|
|
133
|
-
*
|
|
134
|
-
* @deprecated This feature will be removed in v2.
|
|
135
|
-
*
|
|
136
|
-
* Parameters:
|
|
137
|
-
* @param {dict} txn - main transaction from payer's signDynamicFee output (a dict of constructor arguments, NOT a transaction.Transaction)
|
|
138
|
-
* @param {LogicSig} lsig - the signed logic received from the payer's signDynamicFee output
|
|
139
|
-
* @param {Uint8Array} privateKey - the private key for the account that pays the fee
|
|
140
|
-
* @param {int} fee - fee per byte for both transactions
|
|
141
|
-
*
|
|
142
|
-
* @throws on invalid lsig
|
|
143
|
-
*/
|
|
144
|
-
/* eslint-disable no-param-reassign */
|
|
145
|
-
function getDynamicFeeTransactions(txn, lsig, privateKey, fee) {
|
|
146
|
-
if (!lsig.verify(address.decodeAddress(txn.from).publicKey)) {
|
|
147
|
-
throw new Error('invalid signature');
|
|
148
|
-
}
|
|
149
|
-
txn.fee = fee;
|
|
150
|
-
if (txn.fee < transaction.ALGORAND_MIN_TX_FEE) {
|
|
151
|
-
txn.fee = transaction.ALGORAND_MIN_TX_FEE;
|
|
152
|
-
}
|
|
153
|
-
const keys = nacl.keyPairFromSecretKey(privateKey);
|
|
154
|
-
const from = address.encodeAddress(keys.publicKey);
|
|
155
|
-
// must remove lease and re-add using addLease so that fee calculation will match other SDKs
|
|
156
|
-
const { lease } = txn;
|
|
157
|
-
delete txn.lease;
|
|
158
|
-
const txnObj = new transaction.Transaction(txn);
|
|
159
|
-
txnObj.addLease(lease, fee);
|
|
160
|
-
const feePayTxn = {
|
|
161
|
-
from,
|
|
162
|
-
to: txn.from,
|
|
163
|
-
fee,
|
|
164
|
-
amount: txnObj.fee,
|
|
165
|
-
firstRound: txn.firstRound,
|
|
166
|
-
lastRound: txn.lastRound,
|
|
167
|
-
genesisHash: txn.genesisHash,
|
|
168
|
-
type: 'pay',
|
|
169
|
-
};
|
|
170
|
-
const feePayTxnObj = new transaction.Transaction(feePayTxn);
|
|
171
|
-
feePayTxnObj.addLease(lease, fee);
|
|
172
|
-
const txnGroup = group.assignGroupID([feePayTxnObj, txnObj], undefined);
|
|
173
|
-
const feePayTxnWithGroup = txnGroup[0];
|
|
174
|
-
const txnObjWithGroup = txnGroup[1];
|
|
175
|
-
const lstx = {
|
|
176
|
-
lsig: lsig.get_obj_for_encoding(),
|
|
177
|
-
txn: txnObjWithGroup.get_obj_for_encoding(),
|
|
178
|
-
};
|
|
179
|
-
const stx1 = feePayTxnWithGroup.signTxn(privateKey);
|
|
180
|
-
const stx2 = encoding.encode(lstx);
|
|
181
|
-
const concatStx = new Uint8Array(stx1.length + stx2.length);
|
|
182
|
-
concatStx.set(stx1);
|
|
183
|
-
concatStx.set(stx2, stx1.length);
|
|
184
|
-
return concatStx;
|
|
185
|
-
}
|
|
186
|
-
/* eslint-enable no-param-reassign */
|
|
187
|
-
module.exports = {
|
|
188
|
-
DynamicFee,
|
|
189
|
-
getDynamicFeeTransactions,
|
|
190
|
-
signDynamicFee,
|
|
191
|
-
};
|
|
192
|
-
//# sourceMappingURL=dynamicfee.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dynamicfee.js","sourceRoot":"","sources":["../../../src/logicTemplates/dynamicfee.js"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACjD,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAClC,MAAM,KAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACxC,MAAM,IAAI,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC7C,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACzC,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE9C,MAAM,UAAU;IACd;;;;;;;;;;;;;;;OAeG;IACH,YAAY,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK;QACxE,8EAA8E;QAC9E,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;YAC7C,MAAM,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC1E,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC;YACrD,MAAM,KAAK,CACT,8DAA8D,CAC/D,CAAC;QACJ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC;YACnD,MAAM,KAAK,C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GAAG,CAAC,SAAS;QACxB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,IAAI,EAAE,KAAK;KACZ,CAAC;IACF,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC5D,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAElC,MAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;IACxE,MAAM,kBAAkB,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACvC,MAAM,eAAe,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEpC,MAAM,IAAI,GAAG;QACX,IAAI,EAAE,IAAI,CAAC,oBAAoB,EAAE;QACjC,GAAG,EAAE,eAAe,CAAC,oBAAoB,EAAE;KAC5C,CAAC;IAEF,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEnC,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5D,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAEjC,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,qCAAqC;AAErC,MAAM,CAAC,OAAO,GAAG;IACf,UAAU;IACV,yBAAyB;IACzB,cAAc;CACf,CAAC"}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
const sha256 = require('js-sha256');
|
|
2
|
-
const { keccak256 } = require('js-sha3');
|
|
3
|
-
const logic = require('../logic/logic');
|
|
4
|
-
const logicSig = require('../logicsig');
|
|
5
|
-
const templates = require('./templates');
|
|
6
|
-
const transaction = require('../transaction');
|
|
7
|
-
class HTLC {
|
|
8
|
-
/**
|
|
9
|
-
* HTLC allows a user to receive the Algo prior to a deadline (in terms of a round) by proving a knowledge
|
|
10
|
-
* of a special value or to forfeit the ability to claim, returning it to the payer.
|
|
11
|
-
* This contract is usually used to perform cross-chained atomic swaps
|
|
12
|
-
*
|
|
13
|
-
* More formally -
|
|
14
|
-
* Algos can be transferred under only two circumstances:
|
|
15
|
-
* 1. To receiver if hash_function(arg_0) = hash_value
|
|
16
|
-
* 2. To owner if txn.FirstValid > expiry_round
|
|
17
|
-
* ...
|
|
18
|
-
*
|
|
19
|
-
* @deprecated This feature will be removed in v2.
|
|
20
|
-
*
|
|
21
|
-
*Parameters
|
|
22
|
-
*----------
|
|
23
|
-
* @param {string} owner: an address that can receive the asset after the expiry round
|
|
24
|
-
* @param {string} receiver: address to receive Algos
|
|
25
|
-
* @param {string} hashFunction: the hash function to be used (must be either sha256 or keccak256)
|
|
26
|
-
* @param {string} hashImage: the hash image in base64
|
|
27
|
-
* @param {int} expiryRound: the round on which the assets can be transferred back to owner
|
|
28
|
-
* @param {int} maxFee: the maximum fee that can be paid to the network by the account
|
|
29
|
-
* @returns {HTLC}
|
|
30
|
-
*/
|
|
31
|
-
constructor(owner, receiver, hashFunction, hashImage, expiryRound, maxFee) {
|
|
32
|
-
// don't need to validate owner, receiver - they'll be validated by template.insert
|
|
33
|
-
if (!Number.isSafeInteger(expiryRound) || expiryRound < 0)
|
|
34
|
-
throw Error('expiryRound must be a positive number and smaller than 2^53-1');
|
|
35
|
-
if (!Number.isSafeInteger(maxFee) || maxFee < 0)
|
|
36
|
-
throw Error('maxFee must be a positive number and smaller than 2^53-1');
|
|
37
|
-
let referenceProgramB64 = '';
|
|
38
|
-
if (hashFunction === 'sha256') {
|
|
39
|
-
referenceProgramB64 =
|
|
40
|
-
'ASAECAEACSYDIOaalh5vLV96yGYHkmVSvpgjXtMzY8qIkYu5yTipFbb5IH+DsWV/8fxTuS3BgUih1l38LUsfo9Z3KErd0gASbZBpIP68oLsUSlpOp7Q4pGgayA5soQW8tgf8VlMlyVaV9qITMQEiDjEQIxIQMQcyAxIQMQgkEhAxCSgSLQEpEhAxCSoSMQIlDRAREA==';
|
|
41
|
-
}
|
|
42
|
-
else if (hashFunction === 'keccak256') {
|
|
43
|
-
referenceProgramB64 =
|
|
44
|
-
'ASAECAEACSYDIOaalh5vLV96yGYHkmVSvpgjXtMzY8qIkYu5yTipFbb5IH+DsWV/8fxTuS3BgUih1l38LUsfo9Z3KErd0gASbZBpIP68oLsUSlpOp7Q4pGgayA5soQW8tgf8VlMlyVaV9qITMQEiDjEQIxIQMQcyAxIQMQgkEhAxCSgSLQIpEhAxCSoSMQIlDRAREA==';
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
throw Error('hash function unrecognized');
|
|
48
|
-
}
|
|
49
|
-
// validate hashImage length
|
|
50
|
-
const hashImageBytes = Buffer.from(hashImage, 'base64');
|
|
51
|
-
if (hashImageBytes.length !== 32)
|
|
52
|
-
throw Error('hash image must be 32 bytes');
|
|
53
|
-
const referenceProgramBytes = Buffer.from(referenceProgramB64, 'base64');
|
|
54
|
-
const referenceOffsets = [
|
|
55
|
-
3 /* expiryRound */,
|
|
56
|
-
6 /* receiver */,
|
|
57
|
-
10 /* hashImage */,
|
|
58
|
-
42 /* owner */,
|
|
59
|
-
76,
|
|
60
|
-
];
|
|
61
|
-
const injectionVector = [maxFee, expiryRound, receiver, hashImage, owner];
|
|
62
|
-
const injectionTypes = [
|
|
63
|
-
templates.valTypes.INT,
|
|
64
|
-
templates.valTypes.INT,
|
|
65
|
-
templates.valTypes.ADDRESS,
|
|
66
|
-
templates.valTypes.BASE64,
|
|
67
|
-
templates.valTypes.ADDRESS,
|
|
68
|
-
];
|
|
69
|
-
const injectedBytes = templates.inject(referenceProgramBytes, referenceOffsets, injectionVector, injectionTypes);
|
|
70
|
-
this.programBytes = injectedBytes;
|
|
71
|
-
const lsig = new logicSig.LogicSig(injectedBytes, undefined);
|
|
72
|
-
this.address = lsig.address();
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* returns the program bytes
|
|
76
|
-
* @returns {Uint8Array}
|
|
77
|
-
*/
|
|
78
|
-
getProgram() {
|
|
79
|
-
return this.programBytes;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* returns the string address of the contract
|
|
83
|
-
* @returns {string}
|
|
84
|
-
*/
|
|
85
|
-
getAddress() {
|
|
86
|
-
return this.address;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* signTransactionWithHTLCUnlock accepts a transaction, such as a payment, and builds the HTLC-unlocking signature around that transaction
|
|
91
|
-
*
|
|
92
|
-
* @deprecated This feature will be removed in v2.
|
|
93
|
-
*
|
|
94
|
-
* @param {Uint8Array} contract : byte representation of the HTLC
|
|
95
|
-
* @param {Object} txn dictionary containing constructor arguments for a transaction
|
|
96
|
-
* @param {string} preImageAsBase64 : preimage of the hash as base64 string
|
|
97
|
-
*
|
|
98
|
-
* @returns {Object} Object containing txID and blob representing signed transaction.
|
|
99
|
-
* @throws error on validation failure
|
|
100
|
-
*/
|
|
101
|
-
function signTransactionWithHTLCUnlock(contract, txn, preImageAsBase64) {
|
|
102
|
-
const preImageBytes = Buffer.from(preImageAsBase64, 'base64');
|
|
103
|
-
// hash validation
|
|
104
|
-
const readResult = logic.readProgram(contract, undefined);
|
|
105
|
-
const ints = readResult[0];
|
|
106
|
-
const byteArrays = readResult[1];
|
|
107
|
-
const expectedHashedOutput = byteArrays[1];
|
|
108
|
-
const hashFunction = contract[contract.length - 15];
|
|
109
|
-
if (hashFunction === 1) {
|
|
110
|
-
const hash = sha256.create();
|
|
111
|
-
hash.update(preImageBytes);
|
|
112
|
-
const actualHashedOutput = Buffer.from(hash.hex(), 'hex');
|
|
113
|
-
if (!actualHashedOutput.equals(expectedHashedOutput)) {
|
|
114
|
-
throw new Error('sha256 hash of preimage did not match stored contract hash');
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else if (hashFunction === 2) {
|
|
118
|
-
const hash = keccak256.create();
|
|
119
|
-
hash.update(preImageBytes);
|
|
120
|
-
const actualHashedOutput = Buffer.from(hash.hex(), 'hex');
|
|
121
|
-
if (!actualHashedOutput.equals(expectedHashedOutput)) {
|
|
122
|
-
throw new Error('keccak256 hash of preimage did not match stored contract hash');
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
throw new Error('hash function in contract unrecognized');
|
|
127
|
-
}
|
|
128
|
-
const args = [preImageBytes]; // array of one element, the Uint8Array preimage
|
|
129
|
-
const lsig = new logicSig.LogicSig(contract, args);
|
|
130
|
-
// clear out receiver just in case
|
|
131
|
-
// eslint-disable-next-line no-param-reassign
|
|
132
|
-
delete txn.to;
|
|
133
|
-
const maxFee = ints[0];
|
|
134
|
-
// check fee
|
|
135
|
-
const tempTxn = new transaction.Transaction(txn);
|
|
136
|
-
if (tempTxn.fee > maxFee) {
|
|
137
|
-
throw new Error(`final fee of payment transaction${tempTxn.fee.toString()}greater than transaction max fee${maxFee.toString()}`);
|
|
138
|
-
}
|
|
139
|
-
return logicSig.signLogicSigTransaction(txn, lsig);
|
|
140
|
-
}
|
|
141
|
-
module.exports = {
|
|
142
|
-
HTLC,
|
|
143
|
-
signTransactionWithHTLCUnlock,
|
|
144
|
-
};
|
|
145
|
-
//# sourceMappingURL=htlc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"htlc.js","sourceRoot":"","sources":["../../../src/logicTemplates/htlc.js"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACpC,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACzC,MAAM,KAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,CA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,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,mCAAmC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAChH,CAAC;KACH;IAED,OAAO,QAAQ,CAAC,uBAAuB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,OAAO,GAAG;IACf,IAAI;IACJ,6BAA6B;CAC9B,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const dynamicFeeTemplate = require('./dynamicfee');
|
|
2
|
-
const htlcTemplate = require('./htlc');
|
|
3
|
-
const limitOrderTemplate = require('./limitorder');
|
|
4
|
-
const splitTemplate = require('./split');
|
|
5
|
-
const periodicPayTemplate = require('./periodicpayment');
|
|
6
|
-
module.exports = {
|
|
7
|
-
DynamicFee: dynamicFeeTemplate.DynamicFee,
|
|
8
|
-
getDynamicFeeTransactions: dynamicFeeTemplate.getDynamicFeeTransactions,
|
|
9
|
-
signDynamicFee: dynamicFeeTemplate.signDynamicFee,
|
|
10
|
-
HTLC: htlcTemplate.HTLC,
|
|
11
|
-
signTransactionWithHTLCUnlock: htlcTemplate.signTransactionWithHTLCUnlock,
|
|
12
|
-
LimitOrder: limitOrderTemplate.LimitOrder,
|
|
13
|
-
getSwapAssetsTransaction: limitOrderTemplate.getSwapAssetsTransaction,
|
|
14
|
-
Split: splitTemplate.Split,
|
|
15
|
-
getSplitFundsTransaction: splitTemplate.getSplitFundsTransaction,
|
|
16
|
-
PeriodicPayment: periodicPayTemplate.PeriodicPayment,
|
|
17
|
-
getPeriodicPaymentWithdrawalTransaction: periodicPayTemplate.getPeriodicPaymentWithdrawalTransaction,
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/logicTemplates/index.js"],"names":[],"mappings":"AAAA,MAAM,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AACnD,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACvC,MAAM,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AACnD,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACzC,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEzD,MAAM,CAAC,OAAO,GAAG;IACf,UAAU,EAAE,kBAAkB,CAAC,UAAU;IACzC,yBAAyB,EAAE,kBAAkB,CAAC,yBAAyB;IACvE,cAAc,EAAE,kBAAkB,CAAC,cAAc;IACjD,IAAI,EAAE,YAAY,CAAC,IAAI;IACvB,6BAA6B,EAAE,YAAY,CAAC,6BAA6B;IACzE,UAAU,EAAE,kBAAkB,CAAC,UAAU;IACzC,wBAAwB,EAAE,kBAAkB,CAAC,wBAAwB;IACrE,KAAK,EAAE,aAAa,CAAC,KAAK;IAC1B,wBAAwB,EAAE,aAAa,CAAC,wBAAwB;IAChE,eAAe,EAAE,mBAAmB,CAAC,eAAe;IACpD,uCAAuC,EACrC,mBAAmB,CAAC,uCAAuC;CAC9D,CAAC"}
|