@metamask-previews/client-utils 1.3.0-preview-6316943cb → 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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ 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
+
10
14
  ## [1.3.0]
11
15
 
12
16
  ### Added
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapLocalTransaction = exports.mapKeyringTransaction = exports.mapApiTransaction = exports.createFormatters = void 0;
3
+ exports.mapRampsOrder = 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,4 +9,6 @@ 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; } });
12
14
  //# sourceMappingURL=index.cjs.map
@@ -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","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"]}
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;AAC5B,0EAAgE;AAAvD,sHAAA,aAAa,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';\nexport { mapRampsOrder } from './mappers/ramps-order-mapper.js';\nexport type { RampsOrderLike } from './mappers/ramps-order-mapper.js';\n\nexport type * from './types.js';\n"]}
package/dist/index.d.cts CHANGED
@@ -3,5 +3,7 @@ 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";
6
8
  export type * from "./types.cjs";
7
9
  //# sourceMappingURL=index.d.cts.map
@@ -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;AAE5E,iCAAgC"}
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;AAC5E,OAAO,EAAE,aAAa,EAAE,yCAAwC;AAChE,YAAY,EAAE,cAAc,EAAE,yCAAwC;AAEtE,iCAAgC"}
package/dist/index.d.mts CHANGED
@@ -3,5 +3,7 @@ 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";
6
8
  export type * from "./types.mjs";
7
9
  //# sourceMappingURL=index.d.mts.map
@@ -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;AAE5E,iCAAgC"}
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;AAC5E,OAAO,EAAE,aAAa,EAAE,yCAAwC;AAChE,YAAY,EAAE,cAAc,EAAE,yCAAwC;AAEtE,iCAAgC"}
package/dist/index.mjs CHANGED
@@ -2,4 +2,5 @@ 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";
5
6
  //# sourceMappingURL=index.mjs.map
@@ -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","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"]}
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;AAC5E,OAAO,EAAE,aAAa,EAAE,yCAAwC","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';\nexport { mapRampsOrder } from './mappers/ramps-order-mapper.js';\nexport type { RampsOrderLike } from './mappers/ramps-order-mapper.js';\n\nexport type * from './types.js';\n"]}
@@ -22,6 +22,9 @@ function formatChainIdToCaip(chainId) {
22
22
  const reference = Number.parseInt(chainId, 16);
23
23
  return Number.isNaN(reference) ? undefined : `eip155:${reference}`;
24
24
  }
25
+ if (!chainId) {
26
+ return undefined;
27
+ }
25
28
  const reference = Number(chainId);
26
29
  return Number.isNaN(reference) ? undefined : `eip155:${reference}`;
27
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"caip.cjs","sourceRoot":"","sources":["../../../src/mappers/helpers/caip.ts"],"names":[],"mappings":";;;AAAA,iEAAkE;AAElE,2CAKyB;AAEzB,mDAAqD;AAErD;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,OAAwB;IAExB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,UAAU,OAAO,E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B,GAAG,IAAA,uCAAoB,EAAC,OAAO,CAAC,CAAC;IAEzD,IAAI,CAAC,IAAA,yBAAiB,EAAC,kBAAkB,CAAC,EAAE,CAAC;QAC3C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAA,wBAAgB,EAAC,WAAW,CAAC,CAAC;IAE/D,OAAO,IAAA,uBAAe,EAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC5E,CAAC;AA3BD,wDA2BC","sourcesContent":["import { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type { CaipAssetType, CaipChainId, Hex } from '@metamask/utils';\nimport {\n isCaipAssetType,\n isStrictHexString,\n parseCaipChainId,\n toCaipAssetType,\n} from '@metamask/utils';\n\nimport { nativeTokenAddress } from '../constants.js';\n\n/**\n * Normalizes a hex, decimal, numeric, or CAIP chain id to its CAIP-2 form.\n * Only EVM (eip155) chains are normalized here; CAIP ids are returned as-is.\n *\n * @param chainId - Hex (`0x1`), numeric, decimal string, or CAIP chain id.\n * @returns The CAIP-2 chain id, or `undefined` when it can't be normalized.\n */\nexport function formatChainIdToCaip(\n chainId: string | number,\n): CaipChainId | undefined {\n if (typeof chainId === 'number') {\n return `eip155:${chainId}`;\n }\n\n if (chainId.includes(':')) {\n return chainId as CaipChainId;\n }\n\n if (chainId.startsWith('0x')) {\n const reference = Number.parseInt(chainId, 16);\n return Number.isNaN(reference) ? undefined : `eip155:${reference}`;\n }\n\n const reference = Number(chainId);\n return Number.isNaN(reference) ? undefined : `eip155:${reference}`;\n}\n\nfunction isNativeAddress(address: string): boolean {\n const normalized = address.toLowerCase();\n return (\n normalized === nativeTokenAddress ||\n normalized === '0x0' ||\n /^0x0+$/u.test(normalized)\n );\n}\n\n/**\n * Encodes an EVM token address + chain id into a CAIP-19 asset id.\n *\n * @param address - Hex contract address, native sentinel, or CAIP asset id.\n * @param chainId - CAIP-2 or hex chain id.\n * @returns The CAIP-19 asset id, or `undefined` when it can't be encoded.\n */\nexport function formatAddressToAssetId(\n address: Hex | CaipAssetType | string,\n chainId?: CaipChainId | Hex,\n): CaipAssetType | undefined {\n if (isCaipAssetType(address)) {\n return address;\n }\n\n const caipChainId = chainId ? formatChainIdToCaip(chainId) : undefined;\n\n if (!caipChainId) {\n return undefined;\n }\n\n if (isNativeAddress(address)) {\n return undefined;\n }\n\n const checksummedAddress = toChecksumHexAddress(address);\n\n if (!isStrictHexString(checksummedAddress)) {\n return undefined;\n }\n\n const { namespace, reference } = parseCaipChainId(caipChainId);\n\n return toCaipAssetType(namespace, reference, 'erc20', checksummedAddress);\n}\n"]}
1
+ {"version":3,"file":"caip.cjs","sourceRoot":"","sources":["../../../src/mappers/helpers/caip.ts"],"names":[],"mappings":";;;AAAA,iEAAkE;AAElE,2CAKyB;AAEzB,mDAAqD;AAErD;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,OAAwB;IAExB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,UAAU,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,OAAsB,CAAC;IAChC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,SAAS,EAAE,CAAC;IACrE,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,SAAS,EAAE,CAAC;AACrE,CAAC;AAtBD,kDAsBC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACzC,OAAO,CACL,UAAU,KAAK,iCAAkB;QACjC,UAAU,KAAK,KAAK;QACpB,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,sBAAsB,CACpC,OAAqC,EACrC,OAA2B;IAE3B,IAAI,IAAA,uBAAe,EAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEvE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,kBAAkB,GAAG,IAAA,uCAAoB,EAAC,OAAO,CAAC,CAAC;IAEzD,IAAI,CAAC,IAAA,yBAAiB,EAAC,kBAAkB,CAAC,EAAE,CAAC;QAC3C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAA,wBAAgB,EAAC,WAAW,CAAC,CAAC;IAE/D,OAAO,IAAA,uBAAe,EAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC5E,CAAC;AA3BD,wDA2BC","sourcesContent":["import { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type { CaipAssetType, CaipChainId, Hex } from '@metamask/utils';\nimport {\n isCaipAssetType,\n isStrictHexString,\n parseCaipChainId,\n toCaipAssetType,\n} from '@metamask/utils';\n\nimport { nativeTokenAddress } from '../constants.js';\n\n/**\n * Normalizes a hex, decimal, numeric, or CAIP chain id to its CAIP-2 form.\n * Only EVM (eip155) chains are normalized here; CAIP ids are returned as-is.\n *\n * @param chainId - Hex (`0x1`), numeric, decimal string, or CAIP chain id.\n * @returns The CAIP-2 chain id, or `undefined` when it can't be normalized.\n */\nexport function formatChainIdToCaip(\n chainId: string | number,\n): CaipChainId | undefined {\n if (typeof chainId === 'number') {\n return `eip155:${chainId}`;\n }\n\n if (chainId.includes(':')) {\n return chainId as CaipChainId;\n }\n\n if (chainId.startsWith('0x')) {\n const reference = Number.parseInt(chainId, 16);\n return Number.isNaN(reference) ? undefined : `eip155:${reference}`;\n }\n\n if (!chainId) {\n return undefined;\n }\n\n const reference = Number(chainId);\n return Number.isNaN(reference) ? undefined : `eip155:${reference}`;\n}\n\nfunction isNativeAddress(address: string): boolean {\n const normalized = address.toLowerCase();\n return (\n normalized === nativeTokenAddress ||\n normalized === '0x0' ||\n /^0x0+$/u.test(normalized)\n );\n}\n\n/**\n * Encodes an EVM token address + chain id into a CAIP-19 asset id.\n *\n * @param address - Hex contract address, native sentinel, or CAIP asset id.\n * @param chainId - CAIP-2 or hex chain id.\n * @returns The CAIP-19 asset id, or `undefined` when it can't be encoded.\n */\nexport function formatAddressToAssetId(\n address: Hex | CaipAssetType | string,\n chainId?: CaipChainId | Hex,\n): CaipAssetType | undefined {\n if (isCaipAssetType(address)) {\n return address;\n }\n\n const caipChainId = chainId ? formatChainIdToCaip(chainId) : undefined;\n\n if (!caipChainId) {\n return undefined;\n }\n\n if (isNativeAddress(address)) {\n return undefined;\n }\n\n const checksummedAddress = toChecksumHexAddress(address);\n\n if (!isStrictHexString(checksummedAddress)) {\n return undefined;\n }\n\n const { namespace, reference } = parseCaipChainId(caipChainId);\n\n return toCaipAssetType(namespace, reference, 'erc20', checksummedAddress);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"caip.d.cts","sourceRoot":"","sources":["../../../src/mappers/helpers/caip.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAUvE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,GAAG,MAAM,GACvB,WAAW,GAAG,SAAS,CAgBzB;AAWD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,GAAG,GAAG,aAAa,GAAG,MAAM,EACrC,OAAO,CAAC,EAAE,WAAW,GAAG,GAAG,GAC1B,aAAa,GAAG,SAAS,CAwB3B"}
1
+ {"version":3,"file":"caip.d.cts","sourceRoot":"","sources":["../../../src/mappers/helpers/caip.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAUvE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,GAAG,MAAM,GACvB,WAAW,GAAG,SAAS,CAoBzB;AAWD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,GAAG,GAAG,aAAa,GAAG,MAAM,EACrC,OAAO,CAAC,EAAE,WAAW,GAAG,GAAG,GAC1B,aAAa,GAAG,SAAS,CAwB3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"caip.d.mts","sourceRoot":"","sources":["../../../src/mappers/helpers/caip.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAUvE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,GAAG,MAAM,GACvB,WAAW,GAAG,SAAS,CAgBzB;AAWD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,GAAG,GAAG,aAAa,GAAG,MAAM,EACrC,OAAO,CAAC,EAAE,WAAW,GAAG,GAAG,GAC1B,aAAa,GAAG,SAAS,CAwB3B"}
1
+ {"version":3,"file":"caip.d.mts","sourceRoot":"","sources":["../../../src/mappers/helpers/caip.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAUvE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,GAAG,MAAM,GACvB,WAAW,GAAG,SAAS,CAoBzB;AAWD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,GAAG,GAAG,aAAa,GAAG,MAAM,EACrC,OAAO,CAAC,EAAE,WAAW,GAAG,GAAG,GAC1B,aAAa,GAAG,SAAS,CAwB3B"}
@@ -19,6 +19,9 @@ export function formatChainIdToCaip(chainId) {
19
19
  const reference = Number.parseInt(chainId, 16);
20
20
  return Number.isNaN(reference) ? undefined : `eip155:${reference}`;
21
21
  }
22
+ if (!chainId) {
23
+ return undefined;
24
+ }
22
25
  const reference = Number(chainId);
23
26
  return Number.isNaN(reference) ? undefined : `eip155:${reference}`;
24
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"caip.mjs","sourceRoot":"","sources":["../../../src/mappers/helpers/caip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,mCAAmC;AAElE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,wBAAwB;AAEzB,OAAO,EAAE,kBAAkB,EAAE,yBAAwB;AAErD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAwB;IAExB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,UAAU,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,OAAsB,CAAC;IAChC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAA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C,WAAW,CAAC,CAAC;IAE/D,OAAO,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type { CaipAssetType, CaipChainId, Hex } from '@metamask/utils';\nimport {\n isCaipAssetType,\n isStrictHexString,\n parseCaipChainId,\n toCaipAssetType,\n} from '@metamask/utils';\n\nimport { nativeTokenAddress } from '../constants.js';\n\n/**\n * Normalizes a hex, decimal, numeric, or CAIP chain id to its CAIP-2 form.\n * Only EVM (eip155) chains are normalized here; CAIP ids are returned as-is.\n *\n * @param chainId - Hex (`0x1`), numeric, decimal string, or CAIP chain id.\n * @returns The CAIP-2 chain id, or `undefined` when it can't be normalized.\n */\nexport function formatChainIdToCaip(\n chainId: string | number,\n): CaipChainId | undefined {\n if (typeof chainId === 'number') {\n return `eip155:${chainId}`;\n }\n\n if (chainId.includes(':')) {\n return chainId as CaipChainId;\n }\n\n if (chainId.startsWith('0x')) {\n const reference = Number.parseInt(chainId, 16);\n return Number.isNaN(reference) ? undefined : `eip155:${reference}`;\n }\n\n const reference = Number(chainId);\n return Number.isNaN(reference) ? undefined : `eip155:${reference}`;\n}\n\nfunction isNativeAddress(address: string): boolean {\n const normalized = address.toLowerCase();\n return (\n normalized === nativeTokenAddress ||\n normalized === '0x0' ||\n /^0x0+$/u.test(normalized)\n );\n}\n\n/**\n * Encodes an EVM token address + chain id into a CAIP-19 asset id.\n *\n * @param address - Hex contract address, native sentinel, or CAIP asset id.\n * @param chainId - CAIP-2 or hex chain id.\n * @returns The CAIP-19 asset id, or `undefined` when it can't be encoded.\n */\nexport function formatAddressToAssetId(\n address: Hex | CaipAssetType | string,\n chainId?: CaipChainId | Hex,\n): CaipAssetType | undefined {\n if (isCaipAssetType(address)) {\n return address;\n }\n\n const caipChainId = chainId ? formatChainIdToCaip(chainId) : undefined;\n\n if (!caipChainId) {\n return undefined;\n }\n\n if (isNativeAddress(address)) {\n return undefined;\n }\n\n const checksummedAddress = toChecksumHexAddress(address);\n\n if (!isStrictHexString(checksummedAddress)) {\n return undefined;\n }\n\n const { namespace, reference } = parseCaipChainId(caipChainId);\n\n return toCaipAssetType(namespace, reference, 'erc20', checksummedAddress);\n}\n"]}
1
+ {"version":3,"file":"caip.mjs","sourceRoot":"","sources":["../../../src/mappers/helpers/caip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,mCAAmC;AAElE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,wBAAwB;AAEzB,OAAO,EAAE,kBAAkB,EAAE,yBAAwB;AAErD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAwB;IAExB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,UAAU,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,OAAsB,CAAC;IAChC,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,SAAS,EAAE,CAAC;IACrE,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,SAAS,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACzC,OAAO,CACL,UAAU,KAAK,kBAAkB;QACjC,UAAU,KAAK,KAAK;QACpB,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAqC,EACrC,OAA2B;IAE3B,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEvE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAEzD,IAAI,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC3C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAE/D,OAAO,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import { toChecksumHexAddress } from '@metamask/controller-utils';\nimport type { CaipAssetType, CaipChainId, Hex } from '@metamask/utils';\nimport {\n isCaipAssetType,\n isStrictHexString,\n parseCaipChainId,\n toCaipAssetType,\n} from '@metamask/utils';\n\nimport { nativeTokenAddress } from '../constants.js';\n\n/**\n * Normalizes a hex, decimal, numeric, or CAIP chain id to its CAIP-2 form.\n * Only EVM (eip155) chains are normalized here; CAIP ids are returned as-is.\n *\n * @param chainId - Hex (`0x1`), numeric, decimal string, or CAIP chain id.\n * @returns The CAIP-2 chain id, or `undefined` when it can't be normalized.\n */\nexport function formatChainIdToCaip(\n chainId: string | number,\n): CaipChainId | undefined {\n if (typeof chainId === 'number') {\n return `eip155:${chainId}`;\n }\n\n if (chainId.includes(':')) {\n return chainId as CaipChainId;\n }\n\n if (chainId.startsWith('0x')) {\n const reference = Number.parseInt(chainId, 16);\n return Number.isNaN(reference) ? undefined : `eip155:${reference}`;\n }\n\n if (!chainId) {\n return undefined;\n }\n\n const reference = Number(chainId);\n return Number.isNaN(reference) ? undefined : `eip155:${reference}`;\n}\n\nfunction isNativeAddress(address: string): boolean {\n const normalized = address.toLowerCase();\n return (\n normalized === nativeTokenAddress ||\n normalized === '0x0' ||\n /^0x0+$/u.test(normalized)\n );\n}\n\n/**\n * Encodes an EVM token address + chain id into a CAIP-19 asset id.\n *\n * @param address - Hex contract address, native sentinel, or CAIP asset id.\n * @param chainId - CAIP-2 or hex chain id.\n * @returns The CAIP-19 asset id, or `undefined` when it can't be encoded.\n */\nexport function formatAddressToAssetId(\n address: Hex | CaipAssetType | string,\n chainId?: CaipChainId | Hex,\n): CaipAssetType | undefined {\n if (isCaipAssetType(address)) {\n return address;\n }\n\n const caipChainId = chainId ? formatChainIdToCaip(chainId) : undefined;\n\n if (!caipChainId) {\n return undefined;\n }\n\n if (isNativeAddress(address)) {\n return undefined;\n }\n\n const checksummedAddress = toChecksumHexAddress(address);\n\n if (!isStrictHexString(checksummedAddress)) {\n return undefined;\n }\n\n const { namespace, reference } = parseCaipChainId(caipChainId);\n\n return toCaipAssetType(namespace, reference, 'erc20', checksummedAddress);\n}\n"]}
@@ -0,0 +1,94 @@
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
+ return 'failed';
11
+ case 'CANCELLED':
12
+ return 'cancelled';
13
+ default:
14
+ return 'pending';
15
+ }
16
+ }
17
+ // `UNKNOWN`, `ID_EXPIRED`, and `PRECREATED` represent background checkout
18
+ // attempts (e.g. precreated orders that never matched a real order, or whose
19
+ // id expired before the provider assigned one) that the user never knowingly
20
+ // initiated as a distinct order and shouldn't see in their history.
21
+ const HIDDEN_STATUSES = new Set([
22
+ 'UNKNOWN',
23
+ 'ID_EXPIRED',
24
+ 'PRECREATED',
25
+ ]);
26
+ /**
27
+ * Maps a ramps order into the shared activity item shape.
28
+ *
29
+ * @param order - The ramps order to map.
30
+ * @returns The normalized activity item, or `null` if the order's status
31
+ * should not be surfaced in the activity list.
32
+ */
33
+ function mapRampsOrder(order) {
34
+ if (HIDDEN_STATUSES.has(order.status) || order.excludeFromPurchases) {
35
+ return null;
36
+ }
37
+ // The V2 API returns `orderType` uppercased (e.g. `'BUY'`); normalize since
38
+ // some call sites (e.g. locally-created stub orders) use lowercase. Transak
39
+ // deposits (`'DEPOSIT'`) are a buy variant, not a sell.
40
+ const normalizedOrderType = order.orderType.toUpperCase();
41
+ const isBuy = normalizedOrderType === 'BUY' || normalizedOrderType === 'DEPOSIT';
42
+ const direction = isBuy ? 'in' : 'out';
43
+ // `cryptoAmount`/`fiatAmount` are already human-formatted by the API, unlike
44
+ // `TokenAmount.decimals` elsewhere in this package, which signals a raw
45
+ // on-chain amount that still needs scaling. Omit `decimals` so clients don't
46
+ // wrongly re-scale an already-human amount.
47
+ const token = order.cryptoCurrency
48
+ ? {
49
+ amount: String(order.cryptoAmount),
50
+ symbol: order.cryptoCurrency.symbol,
51
+ assetId: order.cryptoCurrency.assetId,
52
+ direction,
53
+ }
54
+ : undefined;
55
+ const fiat = {
56
+ amount: String(order.fiatAmount),
57
+ currency: order.fiatCurrency?.symbol,
58
+ };
59
+ const fees = [
60
+ {
61
+ type: 'total',
62
+ amount: String(order.totalFeesFiat),
63
+ symbol: order.fiatCurrency?.symbol,
64
+ },
65
+ ];
66
+ // `network.chainId` may already be CAIP-2 (non-EVM orders), a bare
67
+ // numeric/hex reference (today's only observed EVM format), or empty (a
68
+ // precreated stub order awaiting provider assignment) — normalize without
69
+ // assuming a namespace.
70
+ const chainId = (0, caip_js_1.formatChainIdToCaip)(order.network.chainId);
71
+ return {
72
+ type: isBuy ? 'rampBuy' : 'rampSell',
73
+ chainId,
74
+ status: mapStatus(order.status),
75
+ timestamp: order.createdAt,
76
+ hash: order.txHash || undefined,
77
+ id: order.id ?? order.providerOrderId,
78
+ data: {
79
+ from: order.walletAddress,
80
+ fiat,
81
+ token,
82
+ fees,
83
+ provider: {
84
+ id: order.provider?.id,
85
+ name: order.provider?.name,
86
+ orderLink: order.providerOrderLink,
87
+ },
88
+ statusDescription: order.statusDescription,
89
+ paymentDetails: order.paymentDetails,
90
+ },
91
+ };
92
+ }
93
+ exports.mapRampsOrder = mapRampsOrder;
94
+ //# sourceMappingURL=ramps-order-mapper.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ramps-order-mapper.cjs","sourceRoot":"","sources":["../../src/mappers/ramps-order-mapper.ts"],"names":[],"mappings":";;;AAQA,gDAAwD;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,SAAgB,aAAa,CAAC,KAAqB;IACjD,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,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AAC,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,IAAI,KAAK,CAAC,eAAe;QACrC,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;AAlED,sCAkEC","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"]}
@@ -0,0 +1,48 @@
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
+ id?: string;
10
+ provider?: {
11
+ id?: string;
12
+ name?: string;
13
+ };
14
+ cryptoAmount: string | number;
15
+ fiatAmount: number;
16
+ cryptoCurrency?: {
17
+ assetId?: string;
18
+ symbol: string;
19
+ decimals?: number;
20
+ };
21
+ fiatCurrency?: {
22
+ symbol: string;
23
+ };
24
+ providerOrderId: string;
25
+ providerOrderLink: string;
26
+ createdAt: number;
27
+ totalFeesFiat: number;
28
+ txHash: string;
29
+ walletAddress: string;
30
+ status: RampsOrderStatusLike;
31
+ network: {
32
+ chainId: string;
33
+ };
34
+ statusDescription?: string;
35
+ orderType: string;
36
+ excludeFromPurchases?: boolean;
37
+ paymentDetails?: RampOrderPaymentDetail[];
38
+ };
39
+ /**
40
+ * Maps a ramps order into the shared activity item shape.
41
+ *
42
+ * @param order - The ramps order to map.
43
+ * @returns The normalized activity item, or `null` if the order's status
44
+ * should not be surfaced in the activity list.
45
+ */
46
+ export declare function mapRampsOrder(order: RampsOrderLike): ActivityItem | null;
47
+ export {};
48
+ //# sourceMappingURL=ramps-order-mapper.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ramps-order-mapper.d.cts","sourceRoot":"","sources":["../../src/mappers/ramps-order-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAGZ,sBAAsB,EAGvB,qBAAoB;AAGrB,KAAK,oBAAoB,GACrB,SAAS,GACT,YAAY,GACZ,SAAS,GACT,SAAS,GACT,QAAQ,GACR,WAAW,GACX,WAAW,GACX,YAAY,CAAC;AAEjB;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzE,YAAY,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,sBAAsB,EAAE,CAAC;CAC3C,CAAC;AAyBF;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,YAAY,GAAG,IAAI,CAkExE"}
@@ -0,0 +1,48 @@
1
+ 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
+ id?: string;
10
+ provider?: {
11
+ id?: string;
12
+ name?: string;
13
+ };
14
+ cryptoAmount: string | number;
15
+ fiatAmount: number;
16
+ cryptoCurrency?: {
17
+ assetId?: string;
18
+ symbol: string;
19
+ decimals?: number;
20
+ };
21
+ fiatCurrency?: {
22
+ symbol: string;
23
+ };
24
+ providerOrderId: string;
25
+ providerOrderLink: string;
26
+ createdAt: number;
27
+ totalFeesFiat: number;
28
+ txHash: string;
29
+ walletAddress: string;
30
+ status: RampsOrderStatusLike;
31
+ network: {
32
+ chainId: string;
33
+ };
34
+ statusDescription?: string;
35
+ orderType: string;
36
+ excludeFromPurchases?: boolean;
37
+ paymentDetails?: RampOrderPaymentDetail[];
38
+ };
39
+ /**
40
+ * Maps a ramps order into the shared activity item shape.
41
+ *
42
+ * @param order - The ramps order to map.
43
+ * @returns The normalized activity item, or `null` if the order's status
44
+ * should not be surfaced in the activity list.
45
+ */
46
+ export declare function mapRampsOrder(order: RampsOrderLike): ActivityItem | null;
47
+ export {};
48
+ //# sourceMappingURL=ramps-order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AMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,YAAY,GAAG,IAAI,CAkExE"}
@@ -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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IAC1E,wBAAwB;IACxB,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3D,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;QACpC,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,IAAI,KAAK,CAAC,eAAe;QACrC,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","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 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> = {\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,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' | 'rampBuy' | 'rampSell';
4
4
  export type Status = 'pending' | 'success' | 'failed' | 'cancelled';
5
5
  export type AssetType = 'native' | 'erc20' | 'erc721' | 'erc1155';
6
6
  export type TokenAmount = {
@@ -23,14 +23,27 @@ export type Fee = {
23
23
  assetId?: string;
24
24
  assetType?: AssetType;
25
25
  };
26
- type ActivityData<Type extends ActivityKind, Data> = {
26
+ type ActivityData<Type extends ActivityKind, Data, ChainId = CaipChainId> = {
27
27
  type: Type;
28
- chainId: CaipChainId;
28
+ chainId: ChainId;
29
29
  status: Status;
30
30
  timestamp: number;
31
31
  hash?: string;
32
32
  data: Data;
33
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
+ };
34
47
  export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap', {
35
48
  from?: string;
36
49
  token?: TokenAmount;
@@ -70,7 +83,21 @@ export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCa
70
83
  methodId?: string;
71
84
  transactionCategory?: string;
72
85
  transactionProtocol?: string;
73
- }>;
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
+ });
74
101
  export type ValueTransfer = _ValueTransfer & {
75
102
  contractAddress: string;
76
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,MAA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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,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' | 'rampBuy' | 'rampSell';
4
4
  export type Status = 'pending' | 'success' | 'failed' | 'cancelled';
5
5
  export type AssetType = 'native' | 'erc20' | 'erc721' | 'erc1155';
6
6
  export type TokenAmount = {
@@ -23,14 +23,27 @@ export type Fee = {
23
23
  assetId?: string;
24
24
  assetType?: AssetType;
25
25
  };
26
- type ActivityData<Type extends ActivityKind, Data> = {
26
+ type ActivityData<Type extends ActivityKind, Data, ChainId = CaipChainId> = {
27
27
  type: Type;
28
- chainId: CaipChainId;
28
+ chainId: ChainId;
29
29
  status: Status;
30
30
  timestamp: number;
31
31
  hash?: string;
32
32
  data: Data;
33
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
+ };
34
47
  export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCap' | 'increaseSpendingCap', {
35
48
  from?: string;
36
49
  token?: TokenAmount;
@@ -70,7 +83,21 @@ export type ActivityItem = ActivityData<'approveSpendingCap' | 'revokeSpendingCa
70
83
  methodId?: string;
71
84
  transactionCategory?: string;
72
85
  transactionProtocol?: string;
73
- }>;
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
+ });
74
101
  export type ValueTransfer = _ValueTransfer & {
75
102
  contractAddress: string;
76
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,GACh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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 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> = {\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.3.0-preview-6316943cb",
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",