@metamask-previews/client-utils 1.2.1-preview-6cd1bb2f5 → 1.3.0-preview-0b2e3c9b4

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +4 -0
  3. package/dist/index.cjs +3 -1
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +2 -0
  6. package/dist/index.d.cts.map +1 -1
  7. package/dist/index.d.mts +2 -0
  8. package/dist/index.d.mts.map +1 -1
  9. package/dist/index.mjs +1 -0
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/mappers/api-transaction-mapper.cjs +64 -74
  12. package/dist/mappers/api-transaction-mapper.cjs.map +1 -1
  13. package/dist/mappers/api-transaction-mapper.d.cts.map +1 -1
  14. package/dist/mappers/api-transaction-mapper.d.mts.map +1 -1
  15. package/dist/mappers/api-transaction-mapper.mjs +65 -75
  16. package/dist/mappers/api-transaction-mapper.mjs.map +1 -1
  17. package/dist/mappers/helpers/caip.cjs +5 -41
  18. package/dist/mappers/helpers/caip.cjs.map +1 -1
  19. package/dist/mappers/helpers/caip.d.cts +0 -14
  20. package/dist/mappers/helpers/caip.d.cts.map +1 -1
  21. package/dist/mappers/helpers/caip.d.mts +0 -14
  22. package/dist/mappers/helpers/caip.d.mts.map +1 -1
  23. package/dist/mappers/helpers/caip.mjs +4 -39
  24. package/dist/mappers/helpers/caip.mjs.map +1 -1
  25. package/dist/mappers/helpers/transactions.cjs +37 -27
  26. package/dist/mappers/helpers/transactions.cjs.map +1 -1
  27. package/dist/mappers/helpers/transactions.d.cts +1 -1
  28. package/dist/mappers/helpers/transactions.d.cts.map +1 -1
  29. package/dist/mappers/helpers/transactions.d.mts +1 -1
  30. package/dist/mappers/helpers/transactions.d.mts.map +1 -1
  31. package/dist/mappers/helpers/transactions.mjs +38 -28
  32. package/dist/mappers/helpers/transactions.mjs.map +1 -1
  33. package/dist/mappers/local-transaction-mapper.cjs +26 -12
  34. package/dist/mappers/local-transaction-mapper.cjs.map +1 -1
  35. package/dist/mappers/local-transaction-mapper.d.cts.map +1 -1
  36. package/dist/mappers/local-transaction-mapper.d.mts.map +1 -1
  37. package/dist/mappers/local-transaction-mapper.mjs +27 -13
  38. package/dist/mappers/local-transaction-mapper.mjs.map +1 -1
  39. package/dist/mappers/ramps-order-mapper.cjs +94 -0
  40. package/dist/mappers/ramps-order-mapper.cjs.map +1 -0
  41. package/dist/mappers/ramps-order-mapper.d.cts +48 -0
  42. package/dist/mappers/ramps-order-mapper.d.cts.map +1 -0
  43. package/dist/mappers/ramps-order-mapper.d.mts +48 -0
  44. package/dist/mappers/ramps-order-mapper.d.mts.map +1 -0
  45. package/dist/mappers/ramps-order-mapper.mjs +90 -0
  46. package/dist/mappers/ramps-order-mapper.mjs.map +1 -0
  47. package/dist/types.cjs.map +1 -1
  48. package/dist/types.d.cts +34 -4
  49. package/dist/types.d.cts.map +1 -1
  50. package/dist/types.d.mts +34 -4
  51. package/dist/types.d.mts.map +1 -1
  52. package/dist/types.mjs.map +1 -1
  53. package/package.json +2 -2
@@ -0,0 +1,90 @@
1
+ import { formatChainIdToCaip } from "./helpers/caip.mjs";
2
+ function mapStatus(status) {
3
+ switch (status) {
4
+ case 'COMPLETED':
5
+ return 'success';
6
+ case 'FAILED':
7
+ return 'failed';
8
+ case 'CANCELLED':
9
+ return 'cancelled';
10
+ default:
11
+ return 'pending';
12
+ }
13
+ }
14
+ // `UNKNOWN`, `ID_EXPIRED`, and `PRECREATED` represent background checkout
15
+ // attempts (e.g. precreated orders that never matched a real order, or whose
16
+ // id expired before the provider assigned one) that the user never knowingly
17
+ // initiated as a distinct order and shouldn't see in their history.
18
+ const HIDDEN_STATUSES = new Set([
19
+ 'UNKNOWN',
20
+ 'ID_EXPIRED',
21
+ 'PRECREATED',
22
+ ]);
23
+ /**
24
+ * Maps a ramps order into the shared activity item shape.
25
+ *
26
+ * @param order - The ramps order to map.
27
+ * @returns The normalized activity item, or `null` if the order's status
28
+ * should not be surfaced in the activity list.
29
+ */
30
+ export function mapRampsOrder(order) {
31
+ if (HIDDEN_STATUSES.has(order.status) || order.excludeFromPurchases) {
32
+ return null;
33
+ }
34
+ // The V2 API returns `orderType` uppercased (e.g. `'BUY'`); normalize since
35
+ // some call sites (e.g. locally-created stub orders) use lowercase. Transak
36
+ // deposits (`'DEPOSIT'`) are a buy variant, not a sell.
37
+ const normalizedOrderType = order.orderType.toUpperCase();
38
+ const isBuy = normalizedOrderType === 'BUY' || normalizedOrderType === 'DEPOSIT';
39
+ const direction = isBuy ? 'in' : 'out';
40
+ // `cryptoAmount`/`fiatAmount` are already human-formatted by the API, unlike
41
+ // `TokenAmount.decimals` elsewhere in this package, which signals a raw
42
+ // on-chain amount that still needs scaling. Omit `decimals` so clients don't
43
+ // wrongly re-scale an already-human amount.
44
+ const token = order.cryptoCurrency
45
+ ? {
46
+ amount: String(order.cryptoAmount),
47
+ symbol: order.cryptoCurrency.symbol,
48
+ assetId: order.cryptoCurrency.assetId,
49
+ direction,
50
+ }
51
+ : undefined;
52
+ const fiat = {
53
+ amount: String(order.fiatAmount),
54
+ currency: order.fiatCurrency?.symbol,
55
+ };
56
+ const fees = [
57
+ {
58
+ type: 'total',
59
+ amount: String(order.totalFeesFiat),
60
+ symbol: order.fiatCurrency?.symbol,
61
+ },
62
+ ];
63
+ // `network.chainId` may already be CAIP-2 (non-EVM orders), a bare
64
+ // numeric/hex reference (today's only observed EVM format), or empty (a
65
+ // precreated stub order awaiting provider assignment) — normalize without
66
+ // assuming a namespace.
67
+ const chainId = formatChainIdToCaip(order.network.chainId);
68
+ return {
69
+ type: isBuy ? 'rampBuy' : 'rampSell',
70
+ chainId,
71
+ status: mapStatus(order.status),
72
+ timestamp: order.createdAt,
73
+ hash: order.txHash || undefined,
74
+ id: order.id ?? order.providerOrderId,
75
+ data: {
76
+ from: order.walletAddress,
77
+ fiat,
78
+ token,
79
+ fees,
80
+ provider: {
81
+ id: order.provider?.id,
82
+ name: order.provider?.name,
83
+ orderLink: order.providerOrderLink,
84
+ },
85
+ statusDescription: order.statusDescription,
86
+ paymentDetails: order.paymentDetails,
87
+ },
88
+ };
89
+ }
90
+ //# sourceMappingURL=ramps-order-mapper.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ramps-order-mapper.mjs","sourceRoot":"","sources":["../../src/mappers/ramps-order-mapper.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,mBAAmB,EAAE,2BAA0B;AAsCxD,SAAS,SAAS,CAAC,MAA4B;IAC7C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,WAAW;YACd,OAAO,SAAS,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,WAAW;YACd,OAAO,WAAW,CAAC;QACrB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,oEAAoE;AACpE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAuB;IACpD,SAAS;IACT,YAAY;IACZ,YAAY;CACb,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAqB;IACjD,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oBAAoB,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4EAA4E;IAC5E,4EAA4E;IAC5E,wDAAwD;IACxD,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,KAAK,GACT,mBAAmB,KAAK,KAAK,IAAI,mBAAmB,KAAK,SAAS,CAAC;IACrE,MAAM,SAAS,GAA6B,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAEjE,6EAA6E;IAC7E,wEAAwE;IACxE,6EAA6E;IAC7E,4CAA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AAE,KAAK,CAAC,iBAAiB;aACnC;YACD,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,cAAc,EAAE,KAAK,CAAC,cAAc;SACrC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import 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 id?: string;\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 excludeFromPurchases?: boolean;\n paymentDetails?: RampOrderPaymentDetail[];\n};\n\nfunction mapStatus(status: RampsOrderStatusLike): Status {\n switch (status) {\n case 'COMPLETED':\n return 'success';\n case 'FAILED':\n return 'failed';\n case 'CANCELLED':\n return 'cancelled';\n default:\n return 'pending';\n }\n}\n\n// `UNKNOWN`, `ID_EXPIRED`, and `PRECREATED` represent background checkout\n// attempts (e.g. precreated orders that never matched a real order, or whose\n// id expired before the provider assigned one) that the user never knowingly\n// initiated as a distinct order and shouldn't see in their history.\nconst HIDDEN_STATUSES = new Set<RampsOrderStatusLike>([\n 'UNKNOWN',\n 'ID_EXPIRED',\n 'PRECREATED',\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, or `null` if the order's status\n * should not be surfaced in the activity list.\n */\nexport function mapRampsOrder(order: RampsOrderLike): ActivityItem | null {\n if (HIDDEN_STATUSES.has(order.status) || order.excludeFromPurchases) {\n return null;\n }\n\n // The V2 API returns `orderType` uppercased (e.g. `'BUY'`); normalize since\n // some call sites (e.g. locally-created stub orders) use lowercase. Transak\n // deposits (`'DEPOSIT'`) are a buy variant, not a sell.\n const normalizedOrderType = order.orderType.toUpperCase();\n const isBuy =\n normalizedOrderType === 'BUY' || normalizedOrderType === 'DEPOSIT';\n const direction: TokenAmount['direction'] = isBuy ? 'in' : 'out';\n\n // `cryptoAmount`/`fiatAmount` are already human-formatted by the API, unlike\n // `TokenAmount.decimals` elsewhere in this package, which signals a raw\n // on-chain amount that still needs scaling. Omit `decimals` so clients don't\n // wrongly re-scale an already-human amount.\n const token: TokenAmount | undefined = order.cryptoCurrency\n ? {\n amount: String(order.cryptoAmount),\n symbol: order.cryptoCurrency.symbol,\n assetId: order.cryptoCurrency.assetId,\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), a bare\n // numeric/hex reference (today's only observed EVM format), or empty (a\n // precreated stub order awaiting provider assignment) — normalize without\n // assuming a namespace.\n const chainId = formatChainIdToCaip(order.network.chainId);\n\n return {\n type: isBuy ? 'rampBuy' : 'rampSell',\n chainId,\n status: mapStatus(order.status),\n timestamp: order.createdAt,\n hash: order.txHash || undefined,\n id: order.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 +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';\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"]}
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 | 'rampBuy'\n | 'rampSell';\n\nexport type Status = 'pending' | 'success' | 'failed' | 'cancelled';\n\nexport type AssetType = 'native' | 'erc20' | 'erc721' | 'erc1155';\n\nexport type TokenAmount = {\n amount?: string;\n decimals?: number;\n symbol?: string;\n assetId?: string;\n assetType?: AssetType;\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 assetType?: AssetType;\n};\n\ntype ActivityData<Type extends ActivityKind, Data, ChainId = CaipChainId> = {\n type: Type;\n chainId: ChainId;\n status: Status;\n timestamp: number;\n hash?: string;\n data: Data;\n};\n\n/**\n * Bank transfer instruction fields attached to a ramp order by providers\n * that require manual payment (e.g. SEPA, wire transfer).\n */\nexport type RampOrderPaymentDetail = {\n fiatCurrency: string;\n paymentMethod: string;\n fields: { name: string; id: string; value: string }[];\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 | (ActivityData<\n 'rampBuy' | 'rampSell',\n {\n from?: string;\n fiat?: FiatAmount;\n token?: TokenAmount;\n fees?: Fee[];\n provider?: {\n id?: string;\n name?: string;\n orderLink?: string;\n };\n statusDescription?: string;\n paymentDetails?: RampOrderPaymentDetail[];\n },\n // Precreated stub orders (see `RampsController.addPrecreatedOrder`) may\n // not have an assigned network yet, so unlike every other activity\n // kind, a ramp order's chain id isn't guaranteed.\n CaipChainId | undefined\n > & {\n // Stable identifier for orders that may not have a hash yet (e.g. a\n // ramp order pending fiat settlement, where `hash` is empty until it\n // settles on-chain). Sits next to `hash` since, like `hash`, it's a\n // cross-kind identity concept — scoped to this union arm only, since no\n // other activity kind needs it today.\n id?: string;\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,12 +1,14 @@
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' | 'rampBuy' | 'rampSell';
4
4
  export type Status = 'pending' | 'success' | 'failed' | 'cancelled';
5
+ export type AssetType = 'native' | 'erc20' | 'erc721' | 'erc1155';
5
6
  export type TokenAmount = {
6
7
  amount?: string;
7
8
  decimals?: number;
8
9
  symbol?: string;
9
10
  assetId?: string;
11
+ assetType?: AssetType;
10
12
  direction: 'in' | 'out';
11
13
  };
12
14
  export type FiatAmount = {
@@ -19,15 +21,29 @@ export type Fee = {
19
21
  decimals?: number;
20
22
  symbol?: string;
21
23
  assetId?: string;
24
+ assetType?: AssetType;
22
25
  };
23
- type ActivityData<Type extends ActivityKind, Data> = {
26
+ type ActivityData<Type extends ActivityKind, Data, ChainId = CaipChainId> = {
24
27
  type: Type;
25
- chainId: CaipChainId;
28
+ chainId: ChainId;
26
29
  status: Status;
27
30
  timestamp: number;
28
31
  hash?: string;
29
32
  data: Data;
30
33
  };
34
+ /**
35
+ * Bank transfer instruction fields attached to a ramp order by providers
36
+ * that require manual payment (e.g. SEPA, wire transfer).
37
+ */
38
+ export type RampOrderPaymentDetail = {
39
+ fiatCurrency: string;
40
+ paymentMethod: string;
41
+ fields: {
42
+ name: string;
43
+ id: string;
44
+ value: string;
45
+ }[];
46
+ };
31
47
  export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap', {
32
48
  from?: string;
33
49
  token?: TokenAmount;
@@ -67,7 +83,21 @@ export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCa
67
83
  methodId?: string;
68
84
  transactionCategory?: string;
69
85
  transactionProtocol?: string;
70
- }>;
86
+ }> | (ActivityData<'rampBuy' | 'rampSell', {
87
+ from?: string;
88
+ fiat?: FiatAmount;
89
+ token?: TokenAmount;
90
+ fees?: Fee[];
91
+ provider?: {
92
+ id?: string;
93
+ name?: string;
94
+ orderLink?: string;
95
+ };
96
+ statusDescription?: string;
97
+ paymentDetails?: RampOrderPaymentDetail[];
98
+ }, CaipChainId | undefined> & {
99
+ id?: string;
100
+ });
71
101
  export type ValueTransfer = _ValueTransfer & {
72
102
  contractAddress: string;
73
103
  symbol: string;
@@ -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,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,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,GACD,CAAC,YAAY,CACX,SAAS,GAAG,UAAU,EACtB;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,QAAQ,CAAC,EAAE;QACT,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,sBAAsB,EAAE,CAAC;CAC3C,EAID,WAAW,GAAG,SAAS,CACxB,GAAG;IAMF,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC,CAAC;AAGP,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.d.mts CHANGED
@@ -1,12 +1,14 @@
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' | 'rampBuy' | 'rampSell';
4
4
  export type Status = 'pending' | 'success' | 'failed' | 'cancelled';
5
+ export type AssetType = 'native' | 'erc20' | 'erc721' | 'erc1155';
5
6
  export type TokenAmount = {
6
7
  amount?: string;
7
8
  decimals?: number;
8
9
  symbol?: string;
9
10
  assetId?: string;
11
+ assetType?: AssetType;
10
12
  direction: 'in' | 'out';
11
13
  };
12
14
  export type FiatAmount = {
@@ -19,15 +21,29 @@ export type Fee = {
19
21
  decimals?: number;
20
22
  symbol?: string;
21
23
  assetId?: string;
24
+ assetType?: AssetType;
22
25
  };
23
- type ActivityData<Type extends ActivityKind, Data> = {
26
+ type ActivityData<Type extends ActivityKind, Data, ChainId = CaipChainId> = {
24
27
  type: Type;
25
- chainId: CaipChainId;
28
+ chainId: ChainId;
26
29
  status: Status;
27
30
  timestamp: number;
28
31
  hash?: string;
29
32
  data: Data;
30
33
  };
34
+ /**
35
+ * Bank transfer instruction fields attached to a ramp order by providers
36
+ * that require manual payment (e.g. SEPA, wire transfer).
37
+ */
38
+ export type RampOrderPaymentDetail = {
39
+ fiatCurrency: string;
40
+ paymentMethod: string;
41
+ fields: {
42
+ name: string;
43
+ id: string;
44
+ value: string;
45
+ }[];
46
+ };
31
47
  export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap', {
32
48
  from?: string;
33
49
  token?: TokenAmount;
@@ -67,7 +83,21 @@ export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCa
67
83
  methodId?: string;
68
84
  transactionCategory?: string;
69
85
  transactionProtocol?: string;
70
- }>;
86
+ }> | (ActivityData<'rampBuy' | 'rampSell', {
87
+ from?: string;
88
+ fiat?: FiatAmount;
89
+ token?: TokenAmount;
90
+ fees?: Fee[];
91
+ provider?: {
92
+ id?: string;
93
+ name?: string;
94
+ orderLink?: string;
95
+ };
96
+ statusDescription?: string;
97
+ paymentDetails?: RampOrderPaymentDetail[];
98
+ }, CaipChainId | undefined> & {
99
+ id?: string;
100
+ });
71
101
  export type ValueTransfer = _ValueTransfer & {
72
102
  contractAddress: string;
73
103
  symbol: string;
@@ -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,CAAC;AAExB,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEpE,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC;CACzB,CAA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7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CACF,GACD,CAAC,YAAY,CACX,SAAS,GAAG,UAAU,EACtB;IACE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,QAAQ,CAAC,EAAE;QACT,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,sBAAsB,EAAE,CAAC;CAC3C,EAID,WAAW,GAAG,SAAS,CACxB,GAAG;IAMF,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC,CAAC;AAGP,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
@@ -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';\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"]}
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 | 'rampBuy'\n | 'rampSell';\n\nexport type Status = 'pending' | 'success' | 'failed' | 'cancelled';\n\nexport type AssetType = 'native' | 'erc20' | 'erc721' | 'erc1155';\n\nexport type TokenAmount = {\n amount?: string;\n decimals?: number;\n symbol?: string;\n assetId?: string;\n assetType?: AssetType;\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 assetType?: AssetType;\n};\n\ntype ActivityData<Type extends ActivityKind, Data, ChainId = CaipChainId> = {\n type: Type;\n chainId: ChainId;\n status: Status;\n timestamp: number;\n hash?: string;\n data: Data;\n};\n\n/**\n * Bank transfer instruction fields attached to a ramp order by providers\n * that require manual payment (e.g. SEPA, wire transfer).\n */\nexport type RampOrderPaymentDetail = {\n fiatCurrency: string;\n paymentMethod: string;\n fields: { name: string; id: string; value: string }[];\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 | (ActivityData<\n 'rampBuy' | 'rampSell',\n {\n from?: string;\n fiat?: FiatAmount;\n token?: TokenAmount;\n fees?: Fee[];\n provider?: {\n id?: string;\n name?: string;\n orderLink?: string;\n };\n statusDescription?: string;\n paymentDetails?: RampOrderPaymentDetail[];\n },\n // Precreated stub orders (see `RampsController.addPrecreatedOrder`) may\n // not have an assigned network yet, so unlike every other activity\n // kind, a ramp order's chain id isn't guaranteed.\n CaipChainId | undefined\n > & {\n // Stable identifier for orders that may not have a hash yet (e.g. a\n // ramp order pending fiat settlement, where `hash` is empty until it\n // settles on-chain). Sits next to `hash` since, like `hash`, it's a\n // cross-kind identity concept — scoped to this union arm only, since no\n // other activity kind needs it today.\n id?: string;\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,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/client-utils",
3
- "version": "1.2.1-preview-6cd1bb2f5",
3
+ "version": "1.3.0-preview-0b2e3c9b4",
4
4
  "description": "Shared functions and utilities used across MetaMask clients (extension and mobile)",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -58,7 +58,7 @@
58
58
  "@metamask/contract-metadata": "^2.4.0",
59
59
  "@metamask/controller-utils": "^12.3.0",
60
60
  "@metamask/core-backend": "^7.0.0",
61
- "@metamask/keyring-api": "^23.5.0",
61
+ "@metamask/keyring-api": "^23.7.0",
62
62
  "@metamask/transaction-controller": "^69.2.1",
63
63
  "@metamask/utils": "^11.11.0"
64
64
  },