@shapeshiftoss/unchained-client 10.6.0 → 10.8.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/dist/cosmossdk/osmosis/parser/index.d.ts +2 -0
- package/dist/cosmossdk/osmosis/parser/index.js +12 -0
- package/dist/cosmossdk/parser/index.d.ts +1 -0
- package/dist/cosmossdk/parser/index.js +11 -1
- package/dist/cosmossdk/parser/types.d.ts +1 -1
- package/dist/cosmossdk/parser/utils.js +4 -2
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Tx } from '../../../generated/osmosis';
|
|
2
2
|
import { BaseTransactionParser, BaseTransactionParserArgs } from '../../parser';
|
|
3
|
+
import { ParsedTx } from '../../parser/types';
|
|
3
4
|
export declare type TransactionParserArgs = BaseTransactionParserArgs;
|
|
4
5
|
export declare class TransactionParser extends BaseTransactionParser<Tx> {
|
|
5
6
|
constructor(args: TransactionParserArgs);
|
|
7
|
+
parse(tx: Tx, address: string): Promise<ParsedTx>;
|
|
6
8
|
}
|
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TransactionParser = void 0;
|
|
4
4
|
const caip_1 = require("@shapeshiftoss/caip");
|
|
5
|
+
const types_1 = require("../../../types");
|
|
5
6
|
const parser_1 = require("../../parser");
|
|
6
7
|
class TransactionParser extends parser_1.BaseTransactionParser {
|
|
7
8
|
constructor(args) {
|
|
8
9
|
super(args);
|
|
9
10
|
this.assetId = caip_1.osmosisAssetId;
|
|
10
11
|
}
|
|
12
|
+
async parse(tx, address) {
|
|
13
|
+
var _a;
|
|
14
|
+
const parsedTx = await super.parse(tx, address);
|
|
15
|
+
if (((_a = parsedTx.data) === null || _a === void 0 ? void 0 : _a.method) === 'swap_exact_amount_in') {
|
|
16
|
+
parsedTx.trade = {
|
|
17
|
+
dexName: types_1.Dex.Osmosis,
|
|
18
|
+
type: types_1.TradeType.Trade,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return parsedTx;
|
|
22
|
+
}
|
|
11
23
|
}
|
|
12
24
|
exports.TransactionParser = TransactionParser;
|
|
@@ -33,7 +33,7 @@ class BaseTransactionParser {
|
|
|
33
33
|
blockTime: (_b = tx.timestamp) !== null && _b !== void 0 ? _b : Math.floor(Date.now() / 1000),
|
|
34
34
|
chainId: this.chainId,
|
|
35
35
|
confirmations: tx.confirmations,
|
|
36
|
-
status: tx
|
|
36
|
+
status: this.getStatus(tx),
|
|
37
37
|
transfers: [],
|
|
38
38
|
txid: tx.txid,
|
|
39
39
|
};
|
|
@@ -63,5 +63,15 @@ class BaseTransactionParser {
|
|
|
63
63
|
});
|
|
64
64
|
return parsedTx;
|
|
65
65
|
}
|
|
66
|
+
getStatus(tx) {
|
|
67
|
+
var _a;
|
|
68
|
+
if ((_a = tx.events['0']) === null || _a === void 0 ? void 0 : _a.error)
|
|
69
|
+
return types_1.TxStatus.Failed;
|
|
70
|
+
if (tx.confirmations <= 0)
|
|
71
|
+
return types_1.TxStatus.Pending;
|
|
72
|
+
if (tx.confirmations > 0)
|
|
73
|
+
return types_1.TxStatus.Confirmed;
|
|
74
|
+
return types_1.TxStatus.Unknown;
|
|
75
|
+
}
|
|
66
76
|
}
|
|
67
77
|
exports.BaseTransactionParser = BaseTransactionParser;
|
|
@@ -97,8 +97,10 @@ const metaData = (msg, event, assetId) => {
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
case 'swap_exact_amount_in':
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
return {
|
|
101
|
+
parser: 'swap',
|
|
102
|
+
method: msg.type,
|
|
103
|
+
};
|
|
102
104
|
case 'send':
|
|
103
105
|
// known message types with no applicable metadata
|
|
104
106
|
return;
|