@metamask-previews/client-utils 1.2.1-preview-5ae42f53d → 1.2.1-preview-a3ea429
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/CHANGELOG.md +0 -5
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -27
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +1 -27
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/mappers/ramps-order-mapper.cjs +0 -73
- package/dist/mappers/ramps-order-mapper.cjs.map +0 -1
- package/dist/mappers/ramps-order-mapper.d.cts +0 -45
- package/dist/mappers/ramps-order-mapper.d.cts.map +0 -1
- package/dist/mappers/ramps-order-mapper.d.mts +0 -45
- package/dist/mappers/ramps-order-mapper.d.mts.map +0 -1
- package/dist/mappers/ramps-order-mapper.mjs +0 -69
- package/dist/mappers/ramps-order-mapper.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,11 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- Add `mapRampsOrder` for mapping ramps buy/sell orders into the shared activity item shape, and add `rampBuy`/`rampSell` to `ActivityKind` and `ActivityItem` ([#9650](https://github.com/MetaMask/core/pull/9650))
|
|
13
|
-
- Add an optional `id` field to activity items for items (like pending ramp orders) that may not yet have an on-chain `hash`.
|
|
14
|
-
|
|
15
10
|
## [1.2.1]
|
|
16
11
|
|
|
17
12
|
### Changed
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.mapLocalTransaction = exports.mapKeyringTransaction = exports.mapApiTransaction = exports.createFormatters = void 0;
|
|
4
4
|
var create_formatters_js_1 = require("./formatters/create-formatters.cjs");
|
|
5
5
|
Object.defineProperty(exports, "createFormatters", { enumerable: true, get: function () { return create_formatters_js_1.createFormatters; } });
|
|
6
6
|
var api_transaction_mapper_js_1 = require("./mappers/api-transaction-mapper.cjs");
|
|
@@ -9,6 +9,4 @@ var keyring_transaction_mapper_js_1 = require("./mappers/keyring-transaction-map
|
|
|
9
9
|
Object.defineProperty(exports, "mapKeyringTransaction", { enumerable: true, get: function () { return keyring_transaction_mapper_js_1.mapKeyringTransaction; } });
|
|
10
10
|
var local_transaction_mapper_js_1 = require("./mappers/local-transaction-mapper.cjs");
|
|
11
11
|
Object.defineProperty(exports, "mapLocalTransaction", { enumerable: true, get: function () { return local_transaction_mapper_js_1.mapLocalTransaction; } });
|
|
12
|
-
var ramps_order_mapper_js_1 = require("./mappers/ramps-order-mapper.cjs");
|
|
13
|
-
Object.defineProperty(exports, "mapRampsOrder", { enumerable: true, get: function () { return ramps_order_mapper_js_1.mapRampsOrder; } });
|
|
14
12
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2EAAqE;AAA5D,wHAAA,gBAAgB,OAAA;AAGzB,kFAAwE;AAA/D,8HAAA,iBAAiB,OAAA;AAC1B,0FAAgF;AAAvE,sIAAA,qBAAqB,OAAA;AAC9B,sFAA4E;AAAnE,kIAAA,mBAAmB,OAAA
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2EAAqE;AAA5D,wHAAA,gBAAgB,OAAA;AAGzB,kFAAwE;AAA/D,8HAAA,iBAAiB,OAAA;AAC1B,0FAAgF;AAAvE,sIAAA,qBAAqB,OAAA;AAC9B,sFAA4E;AAAnE,kIAAA,mBAAmB,OAAA","sourcesContent":["export { createFormatters } from './formatters/create-formatters.js';\nexport type { Formatters } from './formatters/create-formatters.js';\n\nexport { mapApiTransaction } from './mappers/api-transaction-mapper.js';\nexport { mapKeyringTransaction } from './mappers/keyring-transaction-mapper.js';\nexport { mapLocalTransaction } from './mappers/local-transaction-mapper.js';\n\nexport type * from './types.js';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,5 @@ export type { Formatters } from "./formatters/create-formatters.cjs";
|
|
|
3
3
|
export { mapApiTransaction } from "./mappers/api-transaction-mapper.cjs";
|
|
4
4
|
export { mapKeyringTransaction } from "./mappers/keyring-transaction-mapper.cjs";
|
|
5
5
|
export { mapLocalTransaction } from "./mappers/local-transaction-mapper.cjs";
|
|
6
|
-
export { mapRampsOrder } from "./mappers/ramps-order-mapper.cjs";
|
|
7
|
-
export type { RampsOrderLike } from "./mappers/ramps-order-mapper.cjs";
|
|
8
6
|
export type * from "./types.cjs";
|
|
9
7
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,2CAA0C;AACrE,YAAY,EAAE,UAAU,EAAE,2CAA0C;AAEpE,OAAO,EAAE,iBAAiB,EAAE,6CAA4C;AACxE,OAAO,EAAE,qBAAqB,EAAE,iDAAgD;AAChF,OAAO,EAAE,mBAAmB,EAAE,+CAA8C;
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,2CAA0C;AACrE,YAAY,EAAE,UAAU,EAAE,2CAA0C;AAEpE,OAAO,EAAE,iBAAiB,EAAE,6CAA4C;AACxE,OAAO,EAAE,qBAAqB,EAAE,iDAAgD;AAChF,OAAO,EAAE,mBAAmB,EAAE,+CAA8C;AAE5E,iCAAgC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,5 @@ export type { Formatters } from "./formatters/create-formatters.mjs";
|
|
|
3
3
|
export { mapApiTransaction } from "./mappers/api-transaction-mapper.mjs";
|
|
4
4
|
export { mapKeyringTransaction } from "./mappers/keyring-transaction-mapper.mjs";
|
|
5
5
|
export { mapLocalTransaction } from "./mappers/local-transaction-mapper.mjs";
|
|
6
|
-
export { mapRampsOrder } from "./mappers/ramps-order-mapper.mjs";
|
|
7
|
-
export type { RampsOrderLike } from "./mappers/ramps-order-mapper.mjs";
|
|
8
6
|
export type * from "./types.mjs";
|
|
9
7
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,2CAA0C;AACrE,YAAY,EAAE,UAAU,EAAE,2CAA0C;AAEpE,OAAO,EAAE,iBAAiB,EAAE,6CAA4C;AACxE,OAAO,EAAE,qBAAqB,EAAE,iDAAgD;AAChF,OAAO,EAAE,mBAAmB,EAAE,+CAA8C;
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,2CAA0C;AACrE,YAAY,EAAE,UAAU,EAAE,2CAA0C;AAEpE,OAAO,EAAE,iBAAiB,EAAE,6CAA4C;AACxE,OAAO,EAAE,qBAAqB,EAAE,iDAAgD;AAChF,OAAO,EAAE,mBAAmB,EAAE,+CAA8C;AAE5E,iCAAgC"}
|
package/dist/index.mjs
CHANGED
|
@@ -2,5 +2,4 @@ export { createFormatters } from "./formatters/create-formatters.mjs";
|
|
|
2
2
|
export { mapApiTransaction } from "./mappers/api-transaction-mapper.mjs";
|
|
3
3
|
export { mapKeyringTransaction } from "./mappers/keyring-transaction-mapper.mjs";
|
|
4
4
|
export { mapLocalTransaction } from "./mappers/local-transaction-mapper.mjs";
|
|
5
|
-
export { mapRampsOrder } from "./mappers/ramps-order-mapper.mjs";
|
|
6
5
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,2CAA0C;AAGrE,OAAO,EAAE,iBAAiB,EAAE,6CAA4C;AACxE,OAAO,EAAE,qBAAqB,EAAE,iDAAgD;AAChF,OAAO,EAAE,mBAAmB,EAAE,+CAA8C
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,2CAA0C;AAGrE,OAAO,EAAE,iBAAiB,EAAE,6CAA4C;AACxE,OAAO,EAAE,qBAAqB,EAAE,iDAAgD;AAChF,OAAO,EAAE,mBAAmB,EAAE,+CAA8C","sourcesContent":["export { createFormatters } from './formatters/create-formatters.js';\nexport type { Formatters } from './formatters/create-formatters.js';\n\nexport { mapApiTransaction } from './mappers/api-transaction-mapper.js';\nexport { mapKeyringTransaction } from './mappers/keyring-transaction-mapper.js';\nexport { mapLocalTransaction } from './mappers/local-transaction-mapper.js';\n\nexport type * from './types.js';\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueTransfer as _ValueTransfer } from '@metamask/core-backend';\nimport type { CaipChainId } from '@metamask/utils';\n\nexport type ActivityKind =\n | 'receive'\n | 'sell'\n | 'buy'\n | 'deposit'\n | 'swap'\n | 'claim'\n | 'claimMusdBonus'\n | 'send'\n | 'wrap'\n | 'unwrap'\n | 'approveSpendingCap'\n | 'revokeSpendingCap'\n | 'increaseSpendingCap'\n | 'contractInteraction'\n | 'contractDeployment'\n | 'bridge'\n | 'convert'\n | 'nftBuy'\n | 'nftMint'\n | 'nftSell'\n | 'smartAccountUpgrade'\n | 'lendingDeposit'\n | 'lendingWithdrawal'\n | 'predictionsAddFunds'\n | 'predictionsWithdrawFunds'\n | 'predictionClaimWinnings'\n | 'predictionCashedOut'\n | 'predictionPlaced'\n | 'perpsAddFunds'\n | 'perpsWithdraw'\n | 'perpsOpenLong'\n | 'perpsCloseLong'\n | 'perpsCloseLongLiquidated'\n | 'perpsCloseLongStopLoss'\n | 'perpsOpenShort'\n | 'perpsCloseShort'\n | 'perpsCloseShortLiquidated'\n | 'perpsCloseShortStopLoss'\n | 'perpsPaidFundingFees'\n | 'perpsReceivedFundingFees'\n | 'perpsCloseShortTakeProfit'\n | 'perpsCloseLongTakeProfit'\n | 'marketShort'\n | 'stopMarketCloseShort'\n | 'marketCloseShort'\n | 'assetActivation'\n | 'assetDeactivation'
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueTransfer as _ValueTransfer } from '@metamask/core-backend';\nimport type { CaipChainId } from '@metamask/utils';\n\nexport type ActivityKind =\n | 'receive'\n | 'sell'\n | 'buy'\n | 'deposit'\n | 'swap'\n | 'claim'\n | 'claimMusdBonus'\n | 'send'\n | 'wrap'\n | 'unwrap'\n | 'approveSpendingCap'\n | 'revokeSpendingCap'\n | 'increaseSpendingCap'\n | 'contractInteraction'\n | 'contractDeployment'\n | 'bridge'\n | 'convert'\n | 'nftBuy'\n | 'nftMint'\n | 'nftSell'\n | 'smartAccountUpgrade'\n | 'lendingDeposit'\n | 'lendingWithdrawal'\n | 'predictionsAddFunds'\n | 'predictionsWithdrawFunds'\n | 'predictionClaimWinnings'\n | 'predictionCashedOut'\n | 'predictionPlaced'\n | 'perpsAddFunds'\n | 'perpsWithdraw'\n | 'perpsOpenLong'\n | 'perpsCloseLong'\n | 'perpsCloseLongLiquidated'\n | 'perpsCloseLongStopLoss'\n | 'perpsOpenShort'\n | 'perpsCloseShort'\n | 'perpsCloseShortLiquidated'\n | 'perpsCloseShortStopLoss'\n | 'perpsPaidFundingFees'\n | 'perpsReceivedFundingFees'\n | 'perpsCloseShortTakeProfit'\n | 'perpsCloseLongTakeProfit'\n | 'marketShort'\n | 'stopMarketCloseShort'\n | 'marketCloseShort'\n | 'assetActivation'\n | 'assetDeactivation';\n\nexport type Status = 'pending' | 'success' | 'failed' | 'cancelled';\n\nexport type TokenAmount = {\n amount?: string;\n decimals?: number;\n symbol?: string;\n assetId?: string;\n direction: 'in' | 'out';\n};\n\nexport type FiatAmount = {\n amount: string;\n currency?: string;\n};\n\nexport type Fee = {\n type: string;\n amount?: string;\n decimals?: number;\n symbol?: string;\n assetId?: string;\n};\n\ntype ActivityData<Type extends ActivityKind, Data> = {\n type: Type;\n chainId: CaipChainId;\n status: Status;\n timestamp: number;\n hash?: string;\n data: Data;\n};\n\nexport type ActivityItem =\n | ActivityData<\n 'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap',\n {\n from?: string;\n token?: TokenAmount;\n fees?: Fee[];\n }\n >\n | ActivityData<\n 'assetActivation' | 'assetDeactivation',\n {\n from?: string;\n token?: TokenAmount;\n fees?: Fee[];\n }\n >\n | ActivityData<\n 'send' | 'receive',\n {\n from: string;\n to: string;\n token?: TokenAmount;\n fees?: Fee[];\n }\n >\n | ActivityData<\n 'nftBuy' | 'nftMint' | 'nftSell',\n {\n from?: string;\n to?: string;\n token?: TokenAmount;\n paymentToken?: TokenAmount;\n }\n >\n | ActivityData<\n | 'swap'\n | 'bridge'\n | 'convert'\n | 'lendingDeposit'\n | 'lendingWithdrawal'\n | 'wrap'\n | 'unwrap',\n {\n from?: string;\n sourceToken?: TokenAmount;\n destinationToken?: TokenAmount;\n fees?: Fee[];\n }\n >\n | ActivityData<\n 'buy' | 'claim' | 'deposit' | 'claimMusdBonus',\n {\n from?: string;\n token?: TokenAmount;\n }\n >\n | ActivityData<\n 'perpsAddFunds' | 'perpsWithdraw',\n {\n from?: string;\n fiat?: FiatAmount;\n networkFee?: FiatAmount;\n token?: TokenAmount;\n }\n >\n | ActivityData<\n 'contractInteraction',\n {\n from: string;\n to: string;\n token?: TokenAmount;\n fees?: Fee[];\n methodId?: string;\n transactionCategory?: string;\n transactionProtocol?: string;\n }\n >;\n\n// Note: Update core-backend\nexport type ValueTransfer = _ValueTransfer & {\n contractAddress: string;\n symbol: string;\n name: string;\n};\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ValueTransfer as _ValueTransfer } from "@metamask/core-backend";
|
|
2
2
|
import type { CaipChainId } from "@metamask/utils";
|
|
3
|
-
export type ActivityKind = 'receive' | 'sell' | 'buy' | 'deposit' | 'swap' | 'claim' | 'claimMusdBonus' | 'send' | 'wrap' | 'unwrap' | 'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap' | 'contractInteraction' | 'contractDeployment' | 'bridge' | 'convert' | 'nftBuy' | 'nftMint' | 'nftSell' | 'smartAccountUpgrade' | 'lendingDeposit' | 'lendingWithdrawal' | 'predictionsAddFunds' | 'predictionsWithdrawFunds' | 'predictionClaimWinnings' | 'predictionCashedOut' | 'predictionPlaced' | 'perpsAddFunds' | 'perpsWithdraw' | 'perpsOpenLong' | 'perpsCloseLong' | 'perpsCloseLongLiquidated' | 'perpsCloseLongStopLoss' | 'perpsOpenShort' | 'perpsCloseShort' | 'perpsCloseShortLiquidated' | 'perpsCloseShortStopLoss' | 'perpsPaidFundingFees' | 'perpsReceivedFundingFees' | 'perpsCloseShortTakeProfit' | 'perpsCloseLongTakeProfit' | 'marketShort' | 'stopMarketCloseShort' | 'marketCloseShort' | 'assetActivation' | 'assetDeactivation'
|
|
3
|
+
export type ActivityKind = 'receive' | 'sell' | 'buy' | 'deposit' | 'swap' | 'claim' | 'claimMusdBonus' | 'send' | 'wrap' | 'unwrap' | 'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap' | 'contractInteraction' | 'contractDeployment' | 'bridge' | 'convert' | 'nftBuy' | 'nftMint' | 'nftSell' | 'smartAccountUpgrade' | 'lendingDeposit' | 'lendingWithdrawal' | 'predictionsAddFunds' | 'predictionsWithdrawFunds' | 'predictionClaimWinnings' | 'predictionCashedOut' | 'predictionPlaced' | 'perpsAddFunds' | 'perpsWithdraw' | 'perpsOpenLong' | 'perpsCloseLong' | 'perpsCloseLongLiquidated' | 'perpsCloseLongStopLoss' | 'perpsOpenShort' | 'perpsCloseShort' | 'perpsCloseShortLiquidated' | 'perpsCloseShortStopLoss' | 'perpsPaidFundingFees' | 'perpsReceivedFundingFees' | 'perpsCloseShortTakeProfit' | 'perpsCloseLongTakeProfit' | 'marketShort' | 'stopMarketCloseShort' | 'marketCloseShort' | 'assetActivation' | 'assetDeactivation';
|
|
4
4
|
export type Status = 'pending' | 'success' | 'failed' | 'cancelled';
|
|
5
5
|
export type TokenAmount = {
|
|
6
6
|
amount?: string;
|
|
@@ -26,22 +26,8 @@ type ActivityData<Type extends ActivityKind, Data> = {
|
|
|
26
26
|
status: Status;
|
|
27
27
|
timestamp: number;
|
|
28
28
|
hash?: string;
|
|
29
|
-
id?: string;
|
|
30
29
|
data: Data;
|
|
31
30
|
};
|
|
32
|
-
/**
|
|
33
|
-
* Bank transfer instruction fields attached to a ramp order by providers
|
|
34
|
-
* that require manual payment (e.g. SEPA, wire transfer).
|
|
35
|
-
*/
|
|
36
|
-
export type RampOrderPaymentDetail = {
|
|
37
|
-
fiatCurrency: string;
|
|
38
|
-
paymentMethod: string;
|
|
39
|
-
fields: {
|
|
40
|
-
name: string;
|
|
41
|
-
id: string;
|
|
42
|
-
value: string;
|
|
43
|
-
}[];
|
|
44
|
-
};
|
|
45
31
|
export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap', {
|
|
46
32
|
from?: string;
|
|
47
33
|
token?: TokenAmount;
|
|
@@ -81,18 +67,6 @@ export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCa
|
|
|
81
67
|
methodId?: string;
|
|
82
68
|
transactionCategory?: string;
|
|
83
69
|
transactionProtocol?: string;
|
|
84
|
-
}> | ActivityData<'rampBuy' | 'rampSell', {
|
|
85
|
-
from?: string;
|
|
86
|
-
fiat?: FiatAmount;
|
|
87
|
-
token?: TokenAmount;
|
|
88
|
-
fees?: Fee[];
|
|
89
|
-
provider?: {
|
|
90
|
-
id?: string;
|
|
91
|
-
name?: string;
|
|
92
|
-
orderLink?: string;
|
|
93
|
-
};
|
|
94
|
-
statusDescription?: string;
|
|
95
|
-
paymentDetails?: RampOrderPaymentDetail[];
|
|
96
70
|
}>;
|
|
97
71
|
export type ValueTransfer = _ValueTransfer & {
|
|
98
72
|
contractAddress: string;
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,cAAc,EAAE,+BAA+B;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB;AAEnD,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,MAAM,GACN,KAAK,GACL,SAAS,GACT,MAAM,GACN,OAAO,GACP,gBAAgB,GAChB,MAAM,GACN,MAAM,GACN,QAAQ,GACR,oBAAoB,GACpB,mBAAmB,GACnB,qBAAqB,GACrB,qBAAqB,GACrB,oBAAoB,GACpB,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,GACT,qBAAqB,GACrB,gBAAgB,GAChB,mBAAmB,GACnB,qBAAqB,GACrB,0BAA0B,GAC1B,yBAAyB,GACzB,qBAAqB,GACrB,kBAAkB,GAClB,eAAe,GACf,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,0BAA0B,GAC1B,wBAAwB,GACxB,gBAAgB,GAChB,iBAAiB,GACjB,2BAA2B,GAC3B,yBAAyB,GACzB,sBAAsB,GACtB,0BAA0B,GAC1B,2BAA2B,GAC3B,0BAA0B,GAC1B,aAAa,GACb,sBAAsB,GACtB,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,cAAc,EAAE,+BAA+B;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB;AAEnD,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,MAAM,GACN,KAAK,GACL,SAAS,GACT,MAAM,GACN,OAAO,GACP,gBAAgB,GAChB,MAAM,GACN,MAAM,GACN,QAAQ,GACR,oBAAoB,GACpB,mBAAmB,GACnB,qBAAqB,GACrB,qBAAqB,GACrB,oBAAoB,GACpB,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,GACT,qBAAqB,GACrB,gBAAgB,GAChB,mBAAmB,GACnB,qBAAqB,GACrB,0BAA0B,GAC1B,yBAAyB,GACzB,qBAAqB,GACrB,kBAAkB,GAClB,eAAe,GACf,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,0BAA0B,GAC1B,wBAAwB,GACxB,gBAAgB,GAChB,iBAAiB,GACjB,2BAA2B,GAC3B,yBAAyB,GACzB,sBAAsB,GACtB,0BAA0B,GAC1B,2BAA2B,GAC3B,0BAA0B,GAC1B,aAAa,GACb,sBAAsB,GACtB,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,CAAC;AAExB,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEpE,MAAM,MAAM,WA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,MAAM,aAAa,GAAG,cAAc,GAAG;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ValueTransfer as _ValueTransfer } from "@metamask/core-backend";
|
|
2
2
|
import type { CaipChainId } from "@metamask/utils";
|
|
3
|
-
export type ActivityKind = 'receive' | 'sell' | 'buy' | 'deposit' | 'swap' | 'claim' | 'claimMusdBonus' | 'send' | 'wrap' | 'unwrap' | 'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap' | 'contractInteraction' | 'contractDeployment' | 'bridge' | 'convert' | 'nftBuy' | 'nftMint' | 'nftSell' | 'smartAccountUpgrade' | 'lendingDeposit' | 'lendingWithdrawal' | 'predictionsAddFunds' | 'predictionsWithdrawFunds' | 'predictionClaimWinnings' | 'predictionCashedOut' | 'predictionPlaced' | 'perpsAddFunds' | 'perpsWithdraw' | 'perpsOpenLong' | 'perpsCloseLong' | 'perpsCloseLongLiquidated' | 'perpsCloseLongStopLoss' | 'perpsOpenShort' | 'perpsCloseShort' | 'perpsCloseShortLiquidated' | 'perpsCloseShortStopLoss' | 'perpsPaidFundingFees' | 'perpsReceivedFundingFees' | 'perpsCloseShortTakeProfit' | 'perpsCloseLongTakeProfit' | 'marketShort' | 'stopMarketCloseShort' | 'marketCloseShort' | 'assetActivation' | 'assetDeactivation'
|
|
3
|
+
export type ActivityKind = 'receive' | 'sell' | 'buy' | 'deposit' | 'swap' | 'claim' | 'claimMusdBonus' | 'send' | 'wrap' | 'unwrap' | 'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap' | 'contractInteraction' | 'contractDeployment' | 'bridge' | 'convert' | 'nftBuy' | 'nftMint' | 'nftSell' | 'smartAccountUpgrade' | 'lendingDeposit' | 'lendingWithdrawal' | 'predictionsAddFunds' | 'predictionsWithdrawFunds' | 'predictionClaimWinnings' | 'predictionCashedOut' | 'predictionPlaced' | 'perpsAddFunds' | 'perpsWithdraw' | 'perpsOpenLong' | 'perpsCloseLong' | 'perpsCloseLongLiquidated' | 'perpsCloseLongStopLoss' | 'perpsOpenShort' | 'perpsCloseShort' | 'perpsCloseShortLiquidated' | 'perpsCloseShortStopLoss' | 'perpsPaidFundingFees' | 'perpsReceivedFundingFees' | 'perpsCloseShortTakeProfit' | 'perpsCloseLongTakeProfit' | 'marketShort' | 'stopMarketCloseShort' | 'marketCloseShort' | 'assetActivation' | 'assetDeactivation';
|
|
4
4
|
export type Status = 'pending' | 'success' | 'failed' | 'cancelled';
|
|
5
5
|
export type TokenAmount = {
|
|
6
6
|
amount?: string;
|
|
@@ -26,22 +26,8 @@ type ActivityData<Type extends ActivityKind, Data> = {
|
|
|
26
26
|
status: Status;
|
|
27
27
|
timestamp: number;
|
|
28
28
|
hash?: string;
|
|
29
|
-
id?: string;
|
|
30
29
|
data: Data;
|
|
31
30
|
};
|
|
32
|
-
/**
|
|
33
|
-
* Bank transfer instruction fields attached to a ramp order by providers
|
|
34
|
-
* that require manual payment (e.g. SEPA, wire transfer).
|
|
35
|
-
*/
|
|
36
|
-
export type RampOrderPaymentDetail = {
|
|
37
|
-
fiatCurrency: string;
|
|
38
|
-
paymentMethod: string;
|
|
39
|
-
fields: {
|
|
40
|
-
name: string;
|
|
41
|
-
id: string;
|
|
42
|
-
value: string;
|
|
43
|
-
}[];
|
|
44
|
-
};
|
|
45
31
|
export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap', {
|
|
46
32
|
from?: string;
|
|
47
33
|
token?: TokenAmount;
|
|
@@ -81,18 +67,6 @@ export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCa
|
|
|
81
67
|
methodId?: string;
|
|
82
68
|
transactionCategory?: string;
|
|
83
69
|
transactionProtocol?: string;
|
|
84
|
-
}> | ActivityData<'rampBuy' | 'rampSell', {
|
|
85
|
-
from?: string;
|
|
86
|
-
fiat?: FiatAmount;
|
|
87
|
-
token?: TokenAmount;
|
|
88
|
-
fees?: Fee[];
|
|
89
|
-
provider?: {
|
|
90
|
-
id?: string;
|
|
91
|
-
name?: string;
|
|
92
|
-
orderLink?: string;
|
|
93
|
-
};
|
|
94
|
-
statusDescription?: string;
|
|
95
|
-
paymentDetails?: RampOrderPaymentDetail[];
|
|
96
70
|
}>;
|
|
97
71
|
export type ValueTransfer = _ValueTransfer & {
|
|
98
72
|
contractAddress: string;
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,cAAc,EAAE,+BAA+B;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB;AAEnD,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,MAAM,GACN,KAAK,GACL,SAAS,GACT,MAAM,GACN,OAAO,GACP,gBAAgB,GAChB,MAAM,GACN,MAAM,GACN,QAAQ,GACR,oBAAoB,GACpB,mBAAmB,GACnB,qBAAqB,GACrB,qBAAqB,GACrB,oBAAoB,GACpB,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,GACT,qBAAqB,GACrB,gBAAgB,GAChB,mBAAmB,GACnB,qBAAqB,GACrB,0BAA0B,GAC1B,yBAAyB,GACzB,qBAAqB,GACrB,kBAAkB,GAClB,eAAe,GACf,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,0BAA0B,GAC1B,wBAAwB,GACxB,gBAAgB,GAChB,iBAAiB,GACjB,2BAA2B,GAC3B,yBAAyB,GACzB,sBAAsB,GACtB,0BAA0B,GAC1B,2BAA2B,GAC3B,0BAA0B,GAC1B,aAAa,GACb,sBAAsB,GACtB,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"types.d.mts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ACR,MAAM,GACN,QAAQ,GACR,SAAS,GACT,gBAAgB,GAChB,mBAAmB,GACnB,MAAM,GACN,QAAQ,EACV;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAC/B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;CACd,CACF,GACD,YAAY,CACV,KAAK,GAAG,OAAO,GAAG,SAAS,GAAG,gBAAgB,EAC9C;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CACF,GACD,YAAY,CACV,eAAe,GAAG,eAAe,EACjC;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CACF,GACD,YAAY,CACV,qBAAqB,EACrB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CACF,CAAC;AAGN,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueTransfer as _ValueTransfer } from '@metamask/core-backend';\nimport type { CaipChainId } from '@metamask/utils';\n\nexport type ActivityKind =\n | 'receive'\n | 'sell'\n | 'buy'\n | 'deposit'\n | 'swap'\n | 'claim'\n | 'claimMusdBonus'\n | 'send'\n | 'wrap'\n | 'unwrap'\n | 'approveSpendingCap'\n | 'revokeSpendingCap'\n | 'increaseSpendingCap'\n | 'contractInteraction'\n | 'contractDeployment'\n | 'bridge'\n | 'convert'\n | 'nftBuy'\n | 'nftMint'\n | 'nftSell'\n | 'smartAccountUpgrade'\n | 'lendingDeposit'\n | 'lendingWithdrawal'\n | 'predictionsAddFunds'\n | 'predictionsWithdrawFunds'\n | 'predictionClaimWinnings'\n | 'predictionCashedOut'\n | 'predictionPlaced'\n | 'perpsAddFunds'\n | 'perpsWithdraw'\n | 'perpsOpenLong'\n | 'perpsCloseLong'\n | 'perpsCloseLongLiquidated'\n | 'perpsCloseLongStopLoss'\n | 'perpsOpenShort'\n | 'perpsCloseShort'\n | 'perpsCloseShortLiquidated'\n | 'perpsCloseShortStopLoss'\n | 'perpsPaidFundingFees'\n | 'perpsReceivedFundingFees'\n | 'perpsCloseShortTakeProfit'\n | 'perpsCloseLongTakeProfit'\n | 'marketShort'\n | 'stopMarketCloseShort'\n | 'marketCloseShort'\n | 'assetActivation'\n | 'assetDeactivation'
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueTransfer as _ValueTransfer } from '@metamask/core-backend';\nimport type { CaipChainId } from '@metamask/utils';\n\nexport type ActivityKind =\n | 'receive'\n | 'sell'\n | 'buy'\n | 'deposit'\n | 'swap'\n | 'claim'\n | 'claimMusdBonus'\n | 'send'\n | 'wrap'\n | 'unwrap'\n | 'approveSpendingCap'\n | 'revokeSpendingCap'\n | 'increaseSpendingCap'\n | 'contractInteraction'\n | 'contractDeployment'\n | 'bridge'\n | 'convert'\n | 'nftBuy'\n | 'nftMint'\n | 'nftSell'\n | 'smartAccountUpgrade'\n | 'lendingDeposit'\n | 'lendingWithdrawal'\n | 'predictionsAddFunds'\n | 'predictionsWithdrawFunds'\n | 'predictionClaimWinnings'\n | 'predictionCashedOut'\n | 'predictionPlaced'\n | 'perpsAddFunds'\n | 'perpsWithdraw'\n | 'perpsOpenLong'\n | 'perpsCloseLong'\n | 'perpsCloseLongLiquidated'\n | 'perpsCloseLongStopLoss'\n | 'perpsOpenShort'\n | 'perpsCloseShort'\n | 'perpsCloseShortLiquidated'\n | 'perpsCloseShortStopLoss'\n | 'perpsPaidFundingFees'\n | 'perpsReceivedFundingFees'\n | 'perpsCloseShortTakeProfit'\n | 'perpsCloseLongTakeProfit'\n | 'marketShort'\n | 'stopMarketCloseShort'\n | 'marketCloseShort'\n | 'assetActivation'\n | 'assetDeactivation';\n\nexport type Status = 'pending' | 'success' | 'failed' | 'cancelled';\n\nexport type TokenAmount = {\n amount?: string;\n decimals?: number;\n symbol?: string;\n assetId?: string;\n direction: 'in' | 'out';\n};\n\nexport type FiatAmount = {\n amount: string;\n currency?: string;\n};\n\nexport type Fee = {\n type: string;\n amount?: string;\n decimals?: number;\n symbol?: string;\n assetId?: string;\n};\n\ntype ActivityData<Type extends ActivityKind, Data> = {\n type: Type;\n chainId: CaipChainId;\n status: Status;\n timestamp: number;\n hash?: string;\n data: Data;\n};\n\nexport type ActivityItem =\n | ActivityData<\n 'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap',\n {\n from?: string;\n token?: TokenAmount;\n fees?: Fee[];\n }\n >\n | ActivityData<\n 'assetActivation' | 'assetDeactivation',\n {\n from?: string;\n token?: TokenAmount;\n fees?: Fee[];\n }\n >\n | ActivityData<\n 'send' | 'receive',\n {\n from: string;\n to: string;\n token?: TokenAmount;\n fees?: Fee[];\n }\n >\n | ActivityData<\n 'nftBuy' | 'nftMint' | 'nftSell',\n {\n from?: string;\n to?: string;\n token?: TokenAmount;\n paymentToken?: TokenAmount;\n }\n >\n | ActivityData<\n | 'swap'\n | 'bridge'\n | 'convert'\n | 'lendingDeposit'\n | 'lendingWithdrawal'\n | 'wrap'\n | 'unwrap',\n {\n from?: string;\n sourceToken?: TokenAmount;\n destinationToken?: TokenAmount;\n fees?: Fee[];\n }\n >\n | ActivityData<\n 'buy' | 'claim' | 'deposit' | 'claimMusdBonus',\n {\n from?: string;\n token?: TokenAmount;\n }\n >\n | ActivityData<\n 'perpsAddFunds' | 'perpsWithdraw',\n {\n from?: string;\n fiat?: FiatAmount;\n networkFee?: FiatAmount;\n token?: TokenAmount;\n }\n >\n | ActivityData<\n 'contractInteraction',\n {\n from: string;\n to: string;\n token?: TokenAmount;\n fees?: Fee[];\n methodId?: string;\n transactionCategory?: string;\n transactionProtocol?: string;\n }\n >;\n\n// Note: Update core-backend\nexport type ValueTransfer = _ValueTransfer & {\n contractAddress: string;\n symbol: string;\n name: string;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapRampsOrder = void 0;
|
|
4
|
-
const caip_js_1 = require("./helpers/caip.cjs");
|
|
5
|
-
function mapStatus(status) {
|
|
6
|
-
switch (status) {
|
|
7
|
-
case 'COMPLETED':
|
|
8
|
-
return 'success';
|
|
9
|
-
case 'FAILED':
|
|
10
|
-
case 'ID_EXPIRED':
|
|
11
|
-
return 'failed';
|
|
12
|
-
case 'CANCELLED':
|
|
13
|
-
return 'cancelled';
|
|
14
|
-
default:
|
|
15
|
-
return 'pending';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Maps a ramps order into the shared activity item shape.
|
|
20
|
-
*
|
|
21
|
-
* @param order - The ramps order to map.
|
|
22
|
-
* @returns The normalized activity item.
|
|
23
|
-
*/
|
|
24
|
-
function mapRampsOrder(order) {
|
|
25
|
-
const direction = order.orderType === 'buy' ? 'in' : 'out';
|
|
26
|
-
const token = order.cryptoCurrency
|
|
27
|
-
? {
|
|
28
|
-
amount: String(order.cryptoAmount),
|
|
29
|
-
symbol: order.cryptoCurrency.symbol,
|
|
30
|
-
assetId: order.cryptoCurrency.assetId,
|
|
31
|
-
decimals: order.cryptoCurrency.decimals,
|
|
32
|
-
direction,
|
|
33
|
-
}
|
|
34
|
-
: undefined;
|
|
35
|
-
const fiat = {
|
|
36
|
-
amount: String(order.fiatAmount),
|
|
37
|
-
currency: order.fiatCurrency?.symbol,
|
|
38
|
-
};
|
|
39
|
-
const fees = [
|
|
40
|
-
{
|
|
41
|
-
type: 'total',
|
|
42
|
-
amount: String(order.totalFeesFiat),
|
|
43
|
-
symbol: order.fiatCurrency?.symbol,
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
// `network.chainId` may already be CAIP-2 (non-EVM orders) or a bare
|
|
47
|
-
// numeric/hex reference (today's only observed EVM format) — normalize
|
|
48
|
-
// without assuming a namespace.
|
|
49
|
-
const chainId = (0, caip_js_1.formatChainIdToCaip)(order.network.chainId);
|
|
50
|
-
return {
|
|
51
|
-
type: order.orderType === 'buy' ? 'rampBuy' : 'rampSell',
|
|
52
|
-
chainId,
|
|
53
|
-
status: mapStatus(order.status),
|
|
54
|
-
timestamp: order.createdAt,
|
|
55
|
-
hash: order.txHash || undefined,
|
|
56
|
-
id: order.providerOrderId,
|
|
57
|
-
data: {
|
|
58
|
-
from: order.walletAddress,
|
|
59
|
-
fiat,
|
|
60
|
-
token,
|
|
61
|
-
fees,
|
|
62
|
-
provider: {
|
|
63
|
-
id: order.provider?.id,
|
|
64
|
-
name: order.provider?.name,
|
|
65
|
-
orderLink: order.providerOrderLink,
|
|
66
|
-
},
|
|
67
|
-
statusDescription: order.statusDescription,
|
|
68
|
-
paymentDetails: order.paymentDetails,
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
exports.mapRampsOrder = mapRampsOrder;
|
|
73
|
-
//# sourceMappingURL=ramps-order-mapper.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ramps-order-mapper.c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AAgB,CAAC;IAE1E,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;QACxD,OAAO;QACP,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;QAC/B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,IAAI,EAAE,KAAK,CAAC,MAAM,IAAI,SAAS;QAC/B,EAAE,EAAE,KAAK,CAAC,eAAe;QACzB,IAAI,EAAE;YACJ,IAAI,EAAE,KAAK,CAAC,aAAa;YACzB,IAAI;YACJ,KAAK;YACL,IAAI;YACJ,QAAQ,EAAE;gBACR,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE;gBACtB,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI;gBAC1B,SAAS,EAAE,KAAK,CAAC,iBAAiB;aACnC;YACD,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,cAAc,EAAE,KAAK,CAAC,cAAc;SACrC;KACF,CAAC;AACJ,CAAC;AArDD,sCAqDC","sourcesContent":["import type { CaipChainId } from '@metamask/utils';\n\nimport type {\n ActivityItem,\n Fee,\n FiatAmount,\n RampOrderPaymentDetail,\n Status,\n TokenAmount,\n} from '../types.js';\nimport { formatChainIdToCaip } from './helpers/caip.js';\n\ntype RampsOrderStatusLike =\n | 'UNKNOWN'\n | 'PRECREATED'\n | 'CREATED'\n | 'PENDING'\n | 'FAILED'\n | 'COMPLETED'\n | 'CANCELLED'\n | 'ID_EXPIRED';\n\n/**\n * The subset of `RampsOrder` (from `@metamask/ramps-controller`) that this\n * mapper depends on. Redeclared locally rather than imported to keep\n * `client-utils` free of a dependency on `ramps-controller`.\n */\nexport type RampsOrderLike = {\n provider?: { id?: string; name?: string };\n cryptoAmount: string | number;\n fiatAmount: number;\n cryptoCurrency?: { assetId?: string; symbol: string; decimals?: number };\n fiatCurrency?: { symbol: string };\n providerOrderId: string;\n providerOrderLink: string;\n createdAt: number;\n totalFeesFiat: number;\n txHash: string;\n walletAddress: string;\n status: RampsOrderStatusLike;\n network: { chainId: string };\n statusDescription?: string;\n orderType: string;\n paymentDetails?: RampOrderPaymentDetail[];\n};\n\nfunction mapStatus(status: RampsOrderStatusLike): Status {\n switch (status) {\n case 'COMPLETED':\n return 'success';\n case 'FAILED':\n case 'ID_EXPIRED':\n return 'failed';\n case 'CANCELLED':\n return 'cancelled';\n default:\n return 'pending';\n }\n}\n\n/**\n * Maps a ramps order into the shared activity item shape.\n *\n * @param order - The ramps order to map.\n * @returns The normalized activity item.\n */\nexport function mapRampsOrder(order: RampsOrderLike): ActivityItem {\n const direction: TokenAmount['direction'] =\n order.orderType === 'buy' ? 'in' : 'out';\n\n const token: TokenAmount | undefined = order.cryptoCurrency\n ? {\n amount: String(order.cryptoAmount),\n symbol: order.cryptoCurrency.symbol,\n assetId: order.cryptoCurrency.assetId,\n decimals: order.cryptoCurrency.decimals,\n direction,\n }\n : undefined;\n\n const fiat: FiatAmount = {\n amount: String(order.fiatAmount),\n currency: order.fiatCurrency?.symbol,\n };\n\n const fees: Fee[] = [\n {\n type: 'total',\n amount: String(order.totalFeesFiat),\n symbol: order.fiatCurrency?.symbol,\n },\n ];\n\n // `network.chainId` may already be CAIP-2 (non-EVM orders) or a bare\n // numeric/hex reference (today's only observed EVM format) — normalize\n // without assuming a namespace.\n const chainId = formatChainIdToCaip(order.network.chainId) as CaipChainId;\n\n return {\n type: order.orderType === 'buy' ? 'rampBuy' : 'rampSell',\n chainId,\n status: mapStatus(order.status),\n timestamp: order.createdAt,\n hash: order.txHash || undefined,\n id: order.providerOrderId,\n data: {\n from: order.walletAddress,\n fiat,\n token,\n fees,\n provider: {\n id: order.provider?.id,\n name: order.provider?.name,\n orderLink: order.providerOrderLink,\n },\n statusDescription: order.statusDescription,\n paymentDetails: order.paymentDetails,\n },\n };\n}\n"]}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { ActivityItem, RampOrderPaymentDetail } from "../types.cjs";
|
|
2
|
-
type RampsOrderStatusLike = 'UNKNOWN' | 'PRECREATED' | 'CREATED' | 'PENDING' | 'FAILED' | 'COMPLETED' | 'CANCELLED' | 'ID_EXPIRED';
|
|
3
|
-
/**
|
|
4
|
-
* The subset of `RampsOrder` (from `@metamask/ramps-controller`) that this
|
|
5
|
-
* mapper depends on. Redeclared locally rather than imported to keep
|
|
6
|
-
* `client-utils` free of a dependency on `ramps-controller`.
|
|
7
|
-
*/
|
|
8
|
-
export type RampsOrderLike = {
|
|
9
|
-
provider?: {
|
|
10
|
-
id?: string;
|
|
11
|
-
name?: string;
|
|
12
|
-
};
|
|
13
|
-
cryptoAmount: string | number;
|
|
14
|
-
fiatAmount: number;
|
|
15
|
-
cryptoCurrency?: {
|
|
16
|
-
assetId?: string;
|
|
17
|
-
symbol: string;
|
|
18
|
-
decimals?: number;
|
|
19
|
-
};
|
|
20
|
-
fiatCurrency?: {
|
|
21
|
-
symbol: string;
|
|
22
|
-
};
|
|
23
|
-
providerOrderId: string;
|
|
24
|
-
providerOrderLink: string;
|
|
25
|
-
createdAt: number;
|
|
26
|
-
totalFeesFiat: number;
|
|
27
|
-
txHash: string;
|
|
28
|
-
walletAddress: string;
|
|
29
|
-
status: RampsOrderStatusLike;
|
|
30
|
-
network: {
|
|
31
|
-
chainId: string;
|
|
32
|
-
};
|
|
33
|
-
statusDescription?: string;
|
|
34
|
-
orderType: string;
|
|
35
|
-
paymentDetails?: RampOrderPaymentDetail[];
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Maps a ramps order into the shared activity item shape.
|
|
39
|
-
*
|
|
40
|
-
* @param order - The ramps order to map.
|
|
41
|
-
* @returns The normalized activity item.
|
|
42
|
-
*/
|
|
43
|
-
export declare function mapRampsOrder(order: RampsOrderLike): ActivityItem;
|
|
44
|
-
export {};
|
|
45
|
-
//# sourceMappingURL=ramps-order-mapper.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|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import type { ActivityItem, RampOrderPaymentDetail } from "../types.mjs";
|
|
2
|
-
type RampsOrderStatusLike = 'UNKNOWN' | 'PRECREATED' | 'CREATED' | 'PENDING' | 'FAILED' | 'COMPLETED' | 'CANCELLED' | 'ID_EXPIRED';
|
|
3
|
-
/**
|
|
4
|
-
* The subset of `RampsOrder` (from `@metamask/ramps-controller`) that this
|
|
5
|
-
* mapper depends on. Redeclared locally rather than imported to keep
|
|
6
|
-
* `client-utils` free of a dependency on `ramps-controller`.
|
|
7
|
-
*/
|
|
8
|
-
export type RampsOrderLike = {
|
|
9
|
-
provider?: {
|
|
10
|
-
id?: string;
|
|
11
|
-
name?: string;
|
|
12
|
-
};
|
|
13
|
-
cryptoAmount: string | number;
|
|
14
|
-
fiatAmount: number;
|
|
15
|
-
cryptoCurrency?: {
|
|
16
|
-
assetId?: string;
|
|
17
|
-
symbol: string;
|
|
18
|
-
decimals?: number;
|
|
19
|
-
};
|
|
20
|
-
fiatCurrency?: {
|
|
21
|
-
symbol: string;
|
|
22
|
-
};
|
|
23
|
-
providerOrderId: string;
|
|
24
|
-
providerOrderLink: string;
|
|
25
|
-
createdAt: number;
|
|
26
|
-
totalFeesFiat: number;
|
|
27
|
-
txHash: string;
|
|
28
|
-
walletAddress: string;
|
|
29
|
-
status: RampsOrderStatusLike;
|
|
30
|
-
network: {
|
|
31
|
-
chainId: string;
|
|
32
|
-
};
|
|
33
|
-
statusDescription?: string;
|
|
34
|
-
orderType: string;
|
|
35
|
-
paymentDetails?: RampOrderPaymentDetail[];
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Maps a ramps order into the shared activity item shape.
|
|
39
|
-
*
|
|
40
|
-
* @param order - The ramps order to map.
|
|
41
|
-
* @returns The normalized activity item.
|
|
42
|
-
*/
|
|
43
|
-
export declare function mapRampsOrder(order: RampsOrderLike): ActivityItem;
|
|
44
|
-
export {};
|
|
45
|
-
//# sourceMappingURL=ramps-order-mapper.d.mts.map
|
|
@@ -1 +0,0 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|
|
|
1
|
-
import { formatChainIdToCaip } from "./helpers/caip.mjs";
|
|
2
|
-
function mapStatus(status) {
|
|
3
|
-
switch (status) {
|
|
4
|
-
case 'COMPLETED':
|
|
5
|
-
return 'success';
|
|
6
|
-
case 'FAILED':
|
|
7
|
-
case 'ID_EXPIRED':
|
|
8
|
-
return 'failed';
|
|
9
|
-
case 'CANCELLED':
|
|
10
|
-
return 'cancelled';
|
|
11
|
-
default:
|
|
12
|
-
return 'pending';
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Maps a ramps order into the shared activity item shape.
|
|
17
|
-
*
|
|
18
|
-
* @param order - The ramps order to map.
|
|
19
|
-
* @returns The normalized activity item.
|
|
20
|
-
*/
|
|
21
|
-
export function mapRampsOrder(order) {
|
|
22
|
-
const direction = order.orderType === 'buy' ? 'in' : 'out';
|
|
23
|
-
const token = order.cryptoCurrency
|
|
24
|
-
? {
|
|
25
|
-
amount: String(order.cryptoAmount),
|
|
26
|
-
symbol: order.cryptoCurrency.symbol,
|
|
27
|
-
assetId: order.cryptoCurrency.assetId,
|
|
28
|
-
decimals: order.cryptoCurrency.decimals,
|
|
29
|
-
direction,
|
|
30
|
-
}
|
|
31
|
-
: undefined;
|
|
32
|
-
const fiat = {
|
|
33
|
-
amount: String(order.fiatAmount),
|
|
34
|
-
currency: order.fiatCurrency?.symbol,
|
|
35
|
-
};
|
|
36
|
-
const fees = [
|
|
37
|
-
{
|
|
38
|
-
type: 'total',
|
|
39
|
-
amount: String(order.totalFeesFiat),
|
|
40
|
-
symbol: order.fiatCurrency?.symbol,
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
// `network.chainId` may already be CAIP-2 (non-EVM orders) or a bare
|
|
44
|
-
// numeric/hex reference (today's only observed EVM format) — normalize
|
|
45
|
-
// without assuming a namespace.
|
|
46
|
-
const chainId = formatChainIdToCaip(order.network.chainId);
|
|
47
|
-
return {
|
|
48
|
-
type: order.orderType === 'buy' ? 'rampBuy' : 'rampSell',
|
|
49
|
-
chainId,
|
|
50
|
-
status: mapStatus(order.status),
|
|
51
|
-
timestamp: order.createdAt,
|
|
52
|
-
hash: order.txHash || undefined,
|
|
53
|
-
id: order.providerOrderId,
|
|
54
|
-
data: {
|
|
55
|
-
from: order.walletAddress,
|
|
56
|
-
fiat,
|
|
57
|
-
token,
|
|
58
|
-
fees,
|
|
59
|
-
provider: {
|
|
60
|
-
id: order.provider?.id,
|
|
61
|
-
name: order.provider?.name,
|
|
62
|
-
orderLink: order.providerOrderLink,
|
|
63
|
-
},
|
|
64
|
-
statusDescription: order.statusDescription,
|
|
65
|
-
paymentDetails: order.paymentDetails,
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=ramps-order-mapper.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ramps-order-mapper.mjs","sourceRoot":"","sources":["../../src/mappers/ramps-order-mapper.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,mBAAmB,EAAE,2BAA0B;AAoCxD,SAAS,SAAS,CAAC,MAA4B;IAC7C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,WAAW;YACd,OAAO,SAAS,CAAC;QACnB,KAAK,QAAQ,CAAC;QACd,KAAK,YAAY;YACf,OAAO,QAAQ,CAAC;QAClB,KAAK,WAAW;YACd,OAAO,WAAW,CAAC;QACrB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAqB;IACjD,MAAM,SAAS,GACb,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAE3C,MAAM,KAAK,GAA4B,KAAK,CAAC,cAAc;QACzD,CAAC,CAAC;YACE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;YAClC,MAAM,EAAE,KAAK,CAAC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C;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { CaipChainId } from '@metamask/utils';\n\nimport type {\n ActivityItem,\n Fee,\n FiatAmount,\n RampOrderPaymentDetail,\n Status,\n TokenAmount,\n} from '../types.js';\nimport { formatChainIdToCaip } from './helpers/caip.js';\n\ntype RampsOrderStatusLike =\n | 'UNKNOWN'\n | 'PRECREATED'\n | 'CREATED'\n | 'PENDING'\n | 'FAILED'\n | 'COMPLETED'\n | 'CANCELLED'\n | 'ID_EXPIRED';\n\n/**\n * The subset of `RampsOrder` (from `@metamask/ramps-controller`) that this\n * mapper depends on. Redeclared locally rather than imported to keep\n * `client-utils` free of a dependency on `ramps-controller`.\n */\nexport type RampsOrderLike = {\n provider?: { id?: string; name?: string };\n cryptoAmount: string | number;\n fiatAmount: number;\n cryptoCurrency?: { assetId?: string; symbol: string; decimals?: number };\n fiatCurrency?: { symbol: string };\n providerOrderId: string;\n providerOrderLink: string;\n createdAt: number;\n totalFeesFiat: number;\n txHash: string;\n walletAddress: string;\n status: RampsOrderStatusLike;\n network: { chainId: string };\n statusDescription?: string;\n orderType: string;\n paymentDetails?: RampOrderPaymentDetail[];\n};\n\nfunction mapStatus(status: RampsOrderStatusLike): Status {\n switch (status) {\n case 'COMPLETED':\n return 'success';\n case 'FAILED':\n case 'ID_EXPIRED':\n return 'failed';\n case 'CANCELLED':\n return 'cancelled';\n default:\n return 'pending';\n }\n}\n\n/**\n * Maps a ramps order into the shared activity item shape.\n *\n * @param order - The ramps order to map.\n * @returns The normalized activity item.\n */\nexport function mapRampsOrder(order: RampsOrderLike): ActivityItem {\n const direction: TokenAmount['direction'] =\n order.orderType === 'buy' ? 'in' : 'out';\n\n const token: TokenAmount | undefined = order.cryptoCurrency\n ? {\n amount: String(order.cryptoAmount),\n symbol: order.cryptoCurrency.symbol,\n assetId: order.cryptoCurrency.assetId,\n decimals: order.cryptoCurrency.decimals,\n direction,\n }\n : undefined;\n\n const fiat: FiatAmount = {\n amount: String(order.fiatAmount),\n currency: order.fiatCurrency?.symbol,\n };\n\n const fees: Fee[] = [\n {\n type: 'total',\n amount: String(order.totalFeesFiat),\n symbol: order.fiatCurrency?.symbol,\n },\n ];\n\n // `network.chainId` may already be CAIP-2 (non-EVM orders) or a bare\n // numeric/hex reference (today's only observed EVM format) — normalize\n // without assuming a namespace.\n const chainId = formatChainIdToCaip(order.network.chainId) as CaipChainId;\n\n return {\n type: order.orderType === 'buy' ? 'rampBuy' : 'rampSell',\n chainId,\n status: mapStatus(order.status),\n timestamp: order.createdAt,\n hash: order.txHash || undefined,\n id: order.providerOrderId,\n data: {\n from: order.walletAddress,\n fiat,\n token,\n fees,\n provider: {\n id: order.provider?.id,\n name: order.provider?.name,\n orderLink: order.providerOrderLink,\n },\n statusDescription: order.statusDescription,\n paymentDetails: order.paymentDetails,\n },\n };\n}\n"]}
|