aftermath-ts-sdk 1.2.50 → 1.2.51-fee.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
CHANGED
|
@@ -38,9 +38,15 @@ export declare class TransactionsApiHelpers {
|
|
|
38
38
|
static serviceCoinDataFromCoinTxArg: (inputs: {
|
|
39
39
|
coinTxArg: TransactionObjectArgument | Argument | ObjectId;
|
|
40
40
|
}) => ServiceCoinData;
|
|
41
|
+
static serviceCoinDataV2FromCoinTxArg: (inputs: {
|
|
42
|
+
coinTxArg: TransactionObjectArgument | Argument;
|
|
43
|
+
}) => ServiceCoinDataV2;
|
|
41
44
|
static serviceCoinDataFromCoinTxArgV0: (inputs: {
|
|
42
45
|
coinTxArg: CoinTransactionObjectArgumentV0 | ObjectId;
|
|
43
46
|
}) => ServiceCoinData;
|
|
47
|
+
static serviceCoinDataV2FromCoinTxArgV0: (inputs: {
|
|
48
|
+
coinTxArg: CoinTransactionObjectArgumentV0 | ObjectId;
|
|
49
|
+
}) => ServiceCoinDataV2;
|
|
44
50
|
static coinTxArgFromServiceCoinData: (inputs: {
|
|
45
51
|
serviceCoinData: ServiceCoinData;
|
|
46
52
|
}) => TransactionObjectArgument;
|
|
@@ -50,6 +56,9 @@ export declare class TransactionsApiHelpers {
|
|
|
50
56
|
static coinTxArgFromServiceCoinDataV0: (inputs: {
|
|
51
57
|
serviceCoinData: ServiceCoinData;
|
|
52
58
|
}) => CoinTransactionObjectArgumentV0;
|
|
59
|
+
static coinTxArgFromServiceCoinDataV2V0: (inputs: {
|
|
60
|
+
serviceCoinDataV2: ServiceCoinDataV2;
|
|
61
|
+
}) => CoinTransactionObjectArgumentV0;
|
|
53
62
|
static transferTxMetadata: (inputs: {
|
|
54
63
|
initTx: Transaction;
|
|
55
64
|
newTx: Transaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionsApiHelpers.d.ts","sourceRoot":"","sources":["../../../src/general/api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X,MAAM,eACT,MAAM,gBACL,MAAM,KAClB,GAAG,MAAM,KAAK,MAAM,KAAK,MAAM,EAAE,CACkB;IAEtD,OAAc,iBAAiB,qCACJ,mBAAmB;uBAG7B,UAAU;+BAEtB,WAAW,CAkBd;WAEY,WAAW,CAAC,MAAM,EAAE;QACjC,EAAE,EAAE,WAAW,GAAG,gBAAgB,CAAC;QACnC,QAAQ,EAAE,QAAQ,CAAC;QAEnB,MAAM,EAAE,QAAQ,CAAC;QACjB,MAAM,EAAE,OAAO,CAAC;KAChB;IAiBD,OAAc,4BAA4B,WAAY;QACrD,SAAS,EAAE,yBAAyB,GAAG,QAAQ,GAAG,QAAQ,CAAC;KAC3D,KAAG,eAAe,CA8BjB;IAEF,OAAc,8BAA8B,WAAY;QACvD,SAAS,EAAE,+BAA+B,GAAG,QAAQ,CAAC;KACtD,KAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"transactionsApiHelpers.d.ts","sourceRoot":"","sources":["../../../src/general/apiHelpers/transactionsApiHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,WAAW,EACX,yBAAyB,EACzB,QAAQ,EAER,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,OAAO,EACP,+BAA+B,EAC/B,QAAQ,EACR,QAAQ,EACR,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EACN,gBAAgB,EAGhB,MAAM,6BAA6B,CAAC;AAErC,qBAAa,sBAAsB;IAKtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,YAAY;IAU5C,2BAA2B,WAAkB;QACnD,KAAK,EAAE,gCAAgC,CAAC;QACxC,MAAM,CAAC,EAAE,iBAAi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KACtD,KAAG,eAAe,CAkBjB;IAEF,OAAc,gCAAgC,WAAY;QACzD,SAAS,EAAE,+BAA+B,GAAG,QAAQ,CAAC;KACtD,KAAG,iBAAiB,CAkBnB;IAEF,OAAc,4BAA4B,WAAY;QACrD,eAAe,EAAE,eAAe,CAAC;KACjC,KAAG,yBAAyB,CA2B3B;IAEF,OAAc,8BAA8B,WAAY;QACvD,iBAAiB,EAAE,iBAAiB,CAAC;KACrC,KAAG,yBAAyB,CAmC3B;IAEF,OAAc,8BAA8B,WAAY;QACvD,eAAe,EAAE,eAAe,CAAC;KACjC,KAAG,+BAA+B,CAyBjC;IAEF,OAAc,gCAAgC,WAAY;QACzD,iBAAiB,EAAE,iBAAiB,CAAC;KACrC,KAAG,+BAA+B,CA2CjC;IAuCF,OAAc,kBAAkB,WAAY;QAC3C,MAAM,EAAE,WAAW,CAAC;QACpB,KAAK,EAAE,WAAW,CAAC;KACnB,UAoBC;IAEF,OAAc,oBAAoB,WAAY;QAC7C,MAAM,EAAE,gBAAgB,CAAC;QACzB,KAAK,EAAE,gBAAgB,CAAC;KACxB,UA+BC;CACF"}
|
|
@@ -148,8 +148,34 @@ TransactionsApiHelpers.serviceCoinDataFromCoinTxArg = (inputs) => {
|
|
|
148
148
|
// Input
|
|
149
149
|
return { [coinTxArg.$kind]: coinTxArg.Input };
|
|
150
150
|
};
|
|
151
|
+
TransactionsApiHelpers.serviceCoinDataV2FromCoinTxArg = (inputs) => {
|
|
152
|
+
const { coinTxArg } = inputs;
|
|
153
|
+
if (!("$kind" in coinTxArg)) {
|
|
154
|
+
if ("Result" in coinTxArg)
|
|
155
|
+
return { result: coinTxArg.Result };
|
|
156
|
+
if ("NestedResult" in coinTxArg)
|
|
157
|
+
return { result: coinTxArg.NestedResult };
|
|
158
|
+
if ("GasCoin" in coinTxArg)
|
|
159
|
+
return "gas";
|
|
160
|
+
if ("Input" in coinTxArg)
|
|
161
|
+
return { input: coinTxArg.Input };
|
|
162
|
+
// TODO: handle this case better
|
|
163
|
+
throw new Error(`coinTxArg in format ${coinTxArg} not supported`);
|
|
164
|
+
}
|
|
165
|
+
if (coinTxArg.$kind === "NestedResult")
|
|
166
|
+
return {
|
|
167
|
+
result: coinTxArg.NestedResult,
|
|
168
|
+
};
|
|
169
|
+
if (coinTxArg.$kind === "Result")
|
|
170
|
+
return { result: coinTxArg.Result };
|
|
171
|
+
if (coinTxArg.$kind === "GasCoin")
|
|
172
|
+
return "gas";
|
|
173
|
+
// Input
|
|
174
|
+
return { input: coinTxArg.Input };
|
|
175
|
+
};
|
|
151
176
|
TransactionsApiHelpers.serviceCoinDataFromCoinTxArgV0 = (inputs) => {
|
|
152
177
|
const { coinTxArg } = inputs;
|
|
178
|
+
// TODO: handle gas coin
|
|
153
179
|
if (typeof coinTxArg === "string")
|
|
154
180
|
return { Coin: utils_1.Helpers.addLeadingZeroesToType(coinTxArg) };
|
|
155
181
|
if (coinTxArg.kind === "NestedResult")
|
|
@@ -161,6 +187,21 @@ TransactionsApiHelpers.serviceCoinDataFromCoinTxArgV0 = (inputs) => {
|
|
|
161
187
|
// Input
|
|
162
188
|
return { [coinTxArg.kind]: coinTxArg.index };
|
|
163
189
|
};
|
|
190
|
+
TransactionsApiHelpers.serviceCoinDataV2FromCoinTxArgV0 = (inputs) => {
|
|
191
|
+
const { coinTxArg } = inputs;
|
|
192
|
+
// TODO: handle gas coin
|
|
193
|
+
if (typeof coinTxArg === "string")
|
|
194
|
+
// TODO: handle this case better
|
|
195
|
+
throw new Error(`coinTxArg in format ${coinTxArg} not supported`);
|
|
196
|
+
if (coinTxArg.kind === "NestedResult")
|
|
197
|
+
return {
|
|
198
|
+
result: [coinTxArg.index, coinTxArg.resultIndex],
|
|
199
|
+
};
|
|
200
|
+
if (coinTxArg.kind === "Result")
|
|
201
|
+
return { result: coinTxArg.index };
|
|
202
|
+
// Input
|
|
203
|
+
return { input: coinTxArg.index };
|
|
204
|
+
};
|
|
164
205
|
TransactionsApiHelpers.coinTxArgFromServiceCoinData = (inputs) => {
|
|
165
206
|
const { serviceCoinData } = inputs;
|
|
166
207
|
const key = Object.keys(serviceCoinData)[0];
|
|
@@ -229,6 +270,36 @@ TransactionsApiHelpers.coinTxArgFromServiceCoinDataV0 = (inputs) => {
|
|
|
229
270
|
index: Object.values(serviceCoinData)[0],
|
|
230
271
|
};
|
|
231
272
|
};
|
|
273
|
+
TransactionsApiHelpers.coinTxArgFromServiceCoinDataV2V0 = (inputs) => {
|
|
274
|
+
const { serviceCoinDataV2 } = inputs;
|
|
275
|
+
if (typeof serviceCoinDataV2 === "string") {
|
|
276
|
+
throw new Error(`serviceCoinDataV2 format ${JSON.stringify(serviceCoinDataV2)} not supported`);
|
|
277
|
+
}
|
|
278
|
+
const key = Object.keys(serviceCoinDataV2)[0];
|
|
279
|
+
const value = Object.values(serviceCoinDataV2)[0];
|
|
280
|
+
// TODO: handle this cleaner ?
|
|
281
|
+
const kind = key;
|
|
282
|
+
if (kind === "result") {
|
|
283
|
+
if (typeof value === "number") {
|
|
284
|
+
return {
|
|
285
|
+
kind: "Result",
|
|
286
|
+
index: value,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
kind: "NestedResult",
|
|
291
|
+
index: value[0],
|
|
292
|
+
resultIndex: value[1],
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
if (kind === "input" && typeof value === "number") {
|
|
296
|
+
return {
|
|
297
|
+
kind: "Input",
|
|
298
|
+
index: value,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
throw new Error(`serviceCoinDataV2 format ${JSON.stringify(serviceCoinDataV2)} not supported`);
|
|
302
|
+
};
|
|
232
303
|
// public static mergeCoinsTx(inputs: {
|
|
233
304
|
// tx: Transaction;
|
|
234
305
|
// coinType: CoinType;
|