@metamask/transaction-controller 11.0.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -4
- package/dist/EtherscanRemoteTransactionSource.d.ts +1 -1
- package/dist/EtherscanRemoteTransactionSource.d.ts.map +1 -1
- package/dist/EtherscanRemoteTransactionSource.js +11 -11
- package/dist/EtherscanRemoteTransactionSource.js.map +1 -1
- package/dist/IncomingTransactionHelper.d.ts.map +1 -1
- package/dist/IncomingTransactionHelper.js +2 -7
- package/dist/IncomingTransactionHelper.js.map +1 -1
- package/dist/TransactionController.d.ts +5 -2
- package/dist/TransactionController.d.ts.map +1 -1
- package/dist/TransactionController.js +25 -31
- package/dist/TransactionController.js.map +1 -1
- package/dist/constants.d.ts +3 -19
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +15 -20
- package/dist/constants.js.map +1 -1
- package/dist/transaction-type.d.ts +14 -0
- package/dist/transaction-type.d.ts.map +1 -0
- package/dist/transaction-type.js +114 -0
- package/dist/transaction-type.js.map +1 -0
- package/dist/types.d.ts +123 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +99 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +0 -11
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -20
- package/dist/utils.js.map +1 -1
- package/package.json +6 -4
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ETHERSCAN_SUPPORTED_NETWORKS = exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = exports.DEFAULT_ETHERSCAN_DOMAIN = exports.CHAIN_IDS = void 0;
|
|
3
|
+
exports.VALID_UNAPPROVED_TRANSACTION_TYPES = exports.SWAP_TRANSACTION_TYPES = exports.ETHERSCAN_SUPPORTED_NETWORKS = exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = exports.DEFAULT_ETHERSCAN_DOMAIN = exports.CHAIN_IDS = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
4
5
|
exports.CHAIN_IDS = {
|
|
5
6
|
MAINNET: '0x1',
|
|
6
7
|
GOERLI: '0x5',
|
|
@@ -28,97 +29,91 @@ exports.ETHERSCAN_SUPPORTED_NETWORKS = {
|
|
|
28
29
|
[exports.CHAIN_IDS.GOERLI]: {
|
|
29
30
|
domain: exports.DEFAULT_ETHERSCAN_DOMAIN,
|
|
30
31
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`,
|
|
31
|
-
networkId: parseInt(exports.CHAIN_IDS.GOERLI, 16).toString(),
|
|
32
32
|
},
|
|
33
33
|
[exports.CHAIN_IDS.MAINNET]: {
|
|
34
34
|
domain: exports.DEFAULT_ETHERSCAN_DOMAIN,
|
|
35
35
|
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
36
|
-
networkId: parseInt(exports.CHAIN_IDS.MAINNET, 16).toString(),
|
|
37
36
|
},
|
|
38
37
|
[exports.CHAIN_IDS.SEPOLIA]: {
|
|
39
38
|
domain: exports.DEFAULT_ETHERSCAN_DOMAIN,
|
|
40
39
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia`,
|
|
41
|
-
networkId: parseInt(exports.CHAIN_IDS.SEPOLIA, 16).toString(),
|
|
42
40
|
},
|
|
43
41
|
[exports.CHAIN_IDS.LINEA_GOERLI]: {
|
|
44
42
|
domain: 'lineascan.build',
|
|
45
43
|
subdomain: 'goerli',
|
|
46
|
-
networkId: parseInt(exports.CHAIN_IDS.LINEA_GOERLI, 16).toString(),
|
|
47
44
|
},
|
|
48
45
|
[exports.CHAIN_IDS.LINEA_MAINNET]: {
|
|
49
46
|
domain: 'lineascan.build',
|
|
50
47
|
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
51
|
-
networkId: parseInt(exports.CHAIN_IDS.LINEA_MAINNET, 16).toString(),
|
|
52
48
|
},
|
|
53
49
|
[exports.CHAIN_IDS.BSC]: {
|
|
54
50
|
domain: 'bscscan.com',
|
|
55
51
|
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
56
|
-
networkId: parseInt(exports.CHAIN_IDS.BSC, 16).toString(),
|
|
57
52
|
},
|
|
58
53
|
[exports.CHAIN_IDS.BSC_TESTNET]: {
|
|
59
54
|
domain: 'bscscan.com',
|
|
60
55
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,
|
|
61
|
-
networkId: parseInt(exports.CHAIN_IDS.BSC_TESTNET, 16).toString(),
|
|
62
56
|
},
|
|
63
57
|
[exports.CHAIN_IDS.OPTIMISM]: {
|
|
64
58
|
domain: exports.DEFAULT_ETHERSCAN_DOMAIN,
|
|
65
59
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`,
|
|
66
|
-
networkId: parseInt(exports.CHAIN_IDS.OPTIMISM, 16).toString(),
|
|
67
60
|
},
|
|
68
61
|
[exports.CHAIN_IDS.OPTIMISM_TESTNET]: {
|
|
69
62
|
domain: exports.DEFAULT_ETHERSCAN_DOMAIN,
|
|
70
63
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`,
|
|
71
|
-
networkId: parseInt(exports.CHAIN_IDS.OPTIMISM_TESTNET, 16).toString(),
|
|
72
64
|
},
|
|
73
65
|
[exports.CHAIN_IDS.POLYGON]: {
|
|
74
66
|
domain: 'polygonscan.com',
|
|
75
67
|
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
76
|
-
networkId: parseInt(exports.CHAIN_IDS.POLYGON, 16).toString(),
|
|
77
68
|
},
|
|
78
69
|
[exports.CHAIN_IDS.POLYGON_TESTNET]: {
|
|
79
70
|
domain: 'polygonscan.com',
|
|
80
71
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-mumbai`,
|
|
81
|
-
networkId: parseInt(exports.CHAIN_IDS.POLYGON_TESTNET, 16).toString(),
|
|
82
72
|
},
|
|
83
73
|
[exports.CHAIN_IDS.AVALANCHE]: {
|
|
84
74
|
domain: 'snowtrace.io',
|
|
85
75
|
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
86
|
-
networkId: parseInt(exports.CHAIN_IDS.AVALANCHE, 16).toString(),
|
|
87
76
|
},
|
|
88
77
|
[exports.CHAIN_IDS.AVALANCHE_TESTNET]: {
|
|
89
78
|
domain: 'snowtrace.io',
|
|
90
79
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,
|
|
91
|
-
networkId: parseInt(exports.CHAIN_IDS.AVALANCHE_TESTNET, 16).toString(),
|
|
92
80
|
},
|
|
93
81
|
[exports.CHAIN_IDS.FANTOM]: {
|
|
94
82
|
domain: 'ftmscan.com',
|
|
95
83
|
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
96
|
-
networkId: parseInt(exports.CHAIN_IDS.FANTOM, 16).toString(),
|
|
97
84
|
},
|
|
98
85
|
[exports.CHAIN_IDS.FANTOM_TESTNET]: {
|
|
99
86
|
domain: 'ftmscan.com',
|
|
100
87
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,
|
|
101
|
-
networkId: parseInt(exports.CHAIN_IDS.FANTOM_TESTNET, 16).toString(),
|
|
102
88
|
},
|
|
103
89
|
[exports.CHAIN_IDS.MOONBEAM]: {
|
|
104
90
|
domain: 'moonscan.io',
|
|
105
91
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbeam`,
|
|
106
|
-
networkId: parseInt(exports.CHAIN_IDS.MOONBEAM, 16).toString(),
|
|
107
92
|
},
|
|
108
93
|
[exports.CHAIN_IDS.MOONBEAM_TESTNET]: {
|
|
109
94
|
domain: 'moonscan.io',
|
|
110
95
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbase`,
|
|
111
|
-
networkId: parseInt(exports.CHAIN_IDS.MOONBEAM_TESTNET, 16).toString(),
|
|
112
96
|
},
|
|
113
97
|
[exports.CHAIN_IDS.MOONRIVER]: {
|
|
114
98
|
domain: 'moonscan.io',
|
|
115
99
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonriver`,
|
|
116
|
-
networkId: parseInt(exports.CHAIN_IDS.MOONRIVER, 16).toString(),
|
|
117
100
|
},
|
|
118
101
|
[exports.CHAIN_IDS.GNOSIS]: {
|
|
119
102
|
domain: 'gnosisscan.io',
|
|
120
103
|
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-gnosis`,
|
|
121
|
-
networkId: parseInt(exports.CHAIN_IDS.GNOSIS, 16).toString(),
|
|
122
104
|
},
|
|
123
105
|
};
|
|
106
|
+
exports.SWAP_TRANSACTION_TYPES = [
|
|
107
|
+
types_1.TransactionType.swap,
|
|
108
|
+
types_1.TransactionType.swapApproval,
|
|
109
|
+
];
|
|
110
|
+
// Only certain types of transactions should be allowed to be specified when
|
|
111
|
+
// adding a new unapproved transaction.
|
|
112
|
+
exports.VALID_UNAPPROVED_TRANSACTION_TYPES = [
|
|
113
|
+
...exports.SWAP_TRANSACTION_TYPES,
|
|
114
|
+
types_1.TransactionType.simpleSend,
|
|
115
|
+
types_1.TransactionType.tokenMethodTransfer,
|
|
116
|
+
types_1.TransactionType.tokenMethodTransferFrom,
|
|
117
|
+
types_1.TransactionType.contractInteraction,
|
|
118
|
+
];
|
|
124
119
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,mCAA0C;AAE7B,QAAA,SAAS,GAAG;IACvB,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,KAAK;IACb,GAAG,EAAE,MAAM;IACX,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,KAAK;IACf,gBAAgB,EAAE,OAAO;IACzB,OAAO,EAAE,MAAM;IACf,eAAe,EAAE,SAAS;IAC1B,SAAS,EAAE,QAAQ;IACnB,iBAAiB,EAAE,QAAQ;IAC3B,MAAM,EAAE,MAAM;IACd,cAAc,EAAE,OAAO;IACvB,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,QAAQ;IACtB,aAAa,EAAE,QAAQ;IACvB,QAAQ,EAAE,OAAO;IACjB,gBAAgB,EAAE,OAAO;IACzB,SAAS,EAAE,OAAO;IAClB,MAAM,EAAE,MAAM;CACN,CAAC;AAEE,QAAA,wBAAwB,GAAG,cAAc,CAAC;AAC1C,QAAA,kCAAkC,GAAG,KAAK,CAAC;AAE3C,QAAA,4BAA4B,GAAG;IAC1C,CAAC,iBAAS,CAAC,MAAM,CAAC,EAAE;QAClB,MAAM,EAAE,gCAAwB;QAChC,SAAS,EAAE,GAAG,0CAAkC,SAAS;KAC1D;IACD,CAAC,iBAAS,CAAC,OAAO,CAAC,EAAE;QACnB,MAAM,EAAE,gCAAwB;QAChC,SAAS,EAAE,0CAAkC;KAC9C;IACD,CAAC,iBAAS,CAAC,OAAO,CAAC,EAAE;QACnB,MAAM,EAAE,gCAAwB;QAChC,SAAS,EAAE,GAAG,0CAAkC,UAAU;KAC3D;IACD,CAAC,iBAAS,CAAC,YAAY,CAAC,EAAE;QACxB,MAAM,EAAE,iBAAiB;QACzB,SAAS,EAAE,QAAQ;KACpB;IACD,CAAC,iBAAS,CAAC,aAAa,CAAC,EAAE;QACzB,MAAM,EAAE,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,WAAW;KAC5D;IACD,CAAC,iBAAS,CAAC,gBAAgB,CAAC,EAAE;QAC5B,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,GAAG,0CAAkC,WAAW;KAC5D;IACD,CAAC,iBAAS,CAAC,SAAS,CAAC,EAAE;QACrB,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,GAAG,0CAAkC,YAAY;KAC7D;IACD,CAAC,iBAAS,CAAC,MAAM,CAAC,EAAE;QAClB,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,GAAG,0CAAkC,SAAS;KAC1D;CACF,CAAC;AAEW,QAAA,sBAAsB,GAAG;IACpC,uBAAe,CAAC,IAAI;IACpB,uBAAe,CAAC,YAAY;CAC7B,CAAC;AAEF,4EAA4E;AAC5E,uCAAuC;AAC1B,QAAA,kCAAkC,GAAG;IAChD,GAAG,8BAAsB;IACzB,uBAAe,CAAC,UAAU;IAC1B,uBAAe,CAAC,mBAAmB;IACnC,uBAAe,CAAC,uBAAuB;IACvC,uBAAe,CAAC,mBAAmB;CACpC,CAAC","sourcesContent":["import { TransactionType } from './types';\n\nexport const CHAIN_IDS = {\n MAINNET: '0x1',\n GOERLI: '0x5',\n BSC: '0x38',\n BSC_TESTNET: '0x61',\n OPTIMISM: '0xa',\n OPTIMISM_TESTNET: '0x1a4',\n POLYGON: '0x89',\n POLYGON_TESTNET: '0x13881',\n AVALANCHE: '0xa86a',\n AVALANCHE_TESTNET: '0xa869',\n FANTOM: '0xfa',\n FANTOM_TESTNET: '0xfa2',\n SEPOLIA: '0xaa36a7',\n LINEA_GOERLI: '0xe704',\n LINEA_MAINNET: '0xe708',\n MOONBEAM: '0x504',\n MOONBEAM_TESTNET: '0x507',\n MOONRIVER: '0x505',\n GNOSIS: '0x64',\n} as const;\n\nexport const DEFAULT_ETHERSCAN_DOMAIN = 'etherscan.io';\nexport const DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = 'api';\n\nexport const ETHERSCAN_SUPPORTED_NETWORKS = {\n [CHAIN_IDS.GOERLI]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`,\n },\n [CHAIN_IDS.MAINNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.SEPOLIA]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia`,\n },\n [CHAIN_IDS.LINEA_GOERLI]: {\n domain: 'lineascan.build',\n subdomain: 'goerli',\n },\n [CHAIN_IDS.LINEA_MAINNET]: {\n domain: 'lineascan.build',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.BSC]: {\n domain: 'bscscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.BSC_TESTNET]: {\n domain: 'bscscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.OPTIMISM]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`,\n },\n [CHAIN_IDS.OPTIMISM_TESTNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`,\n },\n [CHAIN_IDS.POLYGON]: {\n domain: 'polygonscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.POLYGON_TESTNET]: {\n domain: 'polygonscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-mumbai`,\n },\n [CHAIN_IDS.AVALANCHE]: {\n domain: 'snowtrace.io',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.AVALANCHE_TESTNET]: {\n domain: 'snowtrace.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.FANTOM]: {\n domain: 'ftmscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.FANTOM_TESTNET]: {\n domain: 'ftmscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.MOONBEAM]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbeam`,\n },\n [CHAIN_IDS.MOONBEAM_TESTNET]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbase`,\n },\n [CHAIN_IDS.MOONRIVER]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonriver`,\n },\n [CHAIN_IDS.GNOSIS]: {\n domain: 'gnosisscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-gnosis`,\n },\n};\n\nexport const SWAP_TRANSACTION_TYPES = [\n TransactionType.swap,\n TransactionType.swapApproval,\n];\n\n// Only certain types of transactions should be allowed to be specified when\n// adding a new unapproved transaction.\nexport const VALID_UNAPPROVED_TRANSACTION_TYPES = [\n ...SWAP_TRANSACTION_TYPES,\n TransactionType.simpleSend,\n TransactionType.tokenMethodTransfer,\n TransactionType.tokenMethodTransferFrom,\n TransactionType.contractInteraction,\n];\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type EthQuery from '@metamask/eth-query';
|
|
2
|
+
import type { InferTransactionTypeResult, TransactionParams } from './types';
|
|
3
|
+
export declare const ESTIMATE_GAS_ERROR = "eth_estimateGas rpc method error";
|
|
4
|
+
/**
|
|
5
|
+
* Determines the type of the transaction by analyzing the txParams.
|
|
6
|
+
* It will never return TRANSACTION_TYPE_CANCEL or TRANSACTION_TYPE_RETRY as these
|
|
7
|
+
* represent specific events that we specify manually at transaction creation.
|
|
8
|
+
*
|
|
9
|
+
* @param txParams - Parameters for the transaction.
|
|
10
|
+
* @param ethQuery - EthQuery instance.
|
|
11
|
+
* @returns A object with the transaction type and the contract code response in Hex.
|
|
12
|
+
*/
|
|
13
|
+
export declare function determineTransactionType(txParams: TransactionParams, ethQuery: EthQuery): Promise<InferTransactionTypeResult>;
|
|
14
|
+
//# sourceMappingURL=transaction-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-type.d.ts","sourceRoot":"","sources":["../src/transaction-type.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAGhD,OAAO,KAAK,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG7E,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAMrE;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,0BAA0B,CAAC,CAiCrC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.determineTransactionType = exports.ESTIMATE_GAS_ERROR = void 0;
|
|
13
|
+
const abi_1 = require("@ethersproject/abi");
|
|
14
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
15
|
+
const metamask_eth_abis_1 = require("@metamask/metamask-eth-abis");
|
|
16
|
+
const types_1 = require("./types");
|
|
17
|
+
exports.ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error';
|
|
18
|
+
const ERC20Interface = new abi_1.Interface(metamask_eth_abis_1.abiERC20);
|
|
19
|
+
const ERC721Interface = new abi_1.Interface(metamask_eth_abis_1.abiERC721);
|
|
20
|
+
const ERC1155Interface = new abi_1.Interface(metamask_eth_abis_1.abiERC1155);
|
|
21
|
+
/**
|
|
22
|
+
* Determines the type of the transaction by analyzing the txParams.
|
|
23
|
+
* It will never return TRANSACTION_TYPE_CANCEL or TRANSACTION_TYPE_RETRY as these
|
|
24
|
+
* represent specific events that we specify manually at transaction creation.
|
|
25
|
+
*
|
|
26
|
+
* @param txParams - Parameters for the transaction.
|
|
27
|
+
* @param ethQuery - EthQuery instance.
|
|
28
|
+
* @returns A object with the transaction type and the contract code response in Hex.
|
|
29
|
+
*/
|
|
30
|
+
function determineTransactionType(txParams, ethQuery) {
|
|
31
|
+
var _a;
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const { data, to } = txParams;
|
|
34
|
+
const name = (_a = parseStandardTokenTransactionData(data)) === null || _a === void 0 ? void 0 : _a.name;
|
|
35
|
+
if (data && !to) {
|
|
36
|
+
return { type: types_1.TransactionType.deployContract, getCodeResponse: undefined };
|
|
37
|
+
}
|
|
38
|
+
const { contractCode: resultCode, isContractAddress } = yield readAddressAsContract(ethQuery, to);
|
|
39
|
+
if (!isContractAddress) {
|
|
40
|
+
return { type: types_1.TransactionType.simpleSend, getCodeResponse: resultCode };
|
|
41
|
+
}
|
|
42
|
+
const hasValue = txParams.value && Number(txParams.value) !== 0;
|
|
43
|
+
const tokenMethodName = [
|
|
44
|
+
types_1.TransactionType.tokenMethodApprove,
|
|
45
|
+
types_1.TransactionType.tokenMethodSetApprovalForAll,
|
|
46
|
+
types_1.TransactionType.tokenMethodTransfer,
|
|
47
|
+
types_1.TransactionType.tokenMethodTransferFrom,
|
|
48
|
+
types_1.TransactionType.tokenMethodSafeTransferFrom,
|
|
49
|
+
].find((methodName) => methodName.toLowerCase() === (name === null || name === void 0 ? void 0 : name.toLowerCase()));
|
|
50
|
+
if (data && tokenMethodName && !hasValue) {
|
|
51
|
+
return { type: tokenMethodName, getCodeResponse: resultCode };
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
type: types_1.TransactionType.contractInteraction,
|
|
55
|
+
getCodeResponse: resultCode,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.determineTransactionType = determineTransactionType;
|
|
60
|
+
/**
|
|
61
|
+
* Attempts to decode transaction data using ABIs for three different token standards: ERC20, ERC721, ERC1155.
|
|
62
|
+
* The data will decode correctly if the transaction is an interaction with a contract that matches one of these
|
|
63
|
+
* contract standards
|
|
64
|
+
*
|
|
65
|
+
* @param data - Encoded transaction data.
|
|
66
|
+
* @returns A representation of an ethereum contract call.
|
|
67
|
+
*/
|
|
68
|
+
function parseStandardTokenTransactionData(data) {
|
|
69
|
+
if (!data) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return ERC20Interface.parseTransaction({ data });
|
|
74
|
+
}
|
|
75
|
+
catch (_a) {
|
|
76
|
+
// ignore and next try to parse with erc721 ABI
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
return ERC721Interface.parseTransaction({ data });
|
|
80
|
+
}
|
|
81
|
+
catch (_b) {
|
|
82
|
+
// ignore and next try to parse with erc1155 ABI
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
return ERC1155Interface.parseTransaction({ data });
|
|
86
|
+
}
|
|
87
|
+
catch (_c) {
|
|
88
|
+
// ignore and return undefined
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Reads an Ethereum address and determines if it is a contract address.
|
|
94
|
+
*
|
|
95
|
+
* @param ethQuery - The Ethereum query object used to interact with the Ethereum blockchain.
|
|
96
|
+
* @param address - The Ethereum address.
|
|
97
|
+
* @returns An object containing the contract code and a boolean indicating if it is a contract address.
|
|
98
|
+
*/
|
|
99
|
+
function readAddressAsContract(ethQuery, address) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
let contractCode;
|
|
102
|
+
try {
|
|
103
|
+
contractCode = yield (0, controller_utils_1.query)(ethQuery, 'getCode', [address]);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
contractCode = null;
|
|
107
|
+
}
|
|
108
|
+
const isContractAddress = contractCode
|
|
109
|
+
? contractCode !== '0x' && contractCode !== '0x0'
|
|
110
|
+
: false;
|
|
111
|
+
return { contractCode, isContractAddress };
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=transaction-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-type.js","sourceRoot":"","sources":["../src/transaction-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,4CAA+C;AAC/C,iEAAmD;AAEnD,mEAA8E;AAG9E,mCAA0C;AAE7B,QAAA,kBAAkB,GAAG,kCAAkC,CAAC;AAErE,MAAM,cAAc,GAAG,IAAI,eAAS,CAAC,4BAAQ,CAAC,CAAC;AAC/C,MAAM,eAAe,GAAG,IAAI,eAAS,CAAC,6BAAS,CAAC,CAAC;AACjD,MAAM,gBAAgB,GAAG,IAAI,eAAS,CAAC,8BAAU,CAAC,CAAC;AAEnD;;;;;;;;GAQG;AACH,SAAsB,wBAAwB,CAC5C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S,iCAAiC,CACxC,IAAa;IAEb,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,SAAS,CAAC;KAClB;IAED,IAAI;QACF,OAAO,cAAc,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KAClD;IAAC,WAAM;QACN,+CAA+C;KAChD;IAED,IAAI;QACF,OAAO,eAAe,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACnD;IAAC,WAAM;QACN,gDAAgD;KACjD;IAED,IAAI;QACF,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACpD;IAAC,WAAM;QACN,8BAA8B;KAC/B;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,SAAe,qBAAqB,CAClC,QAAkB,EAClB,OAAgB;;QAKhB,IAAI,YAAY,CAAC;QACjB,IAAI;YACF,YAAY,GAAG,MAAM,IAAA,wBAAK,EAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;SAC5D;QAAC,OAAO,CAAC,EAAE;YACV,YAAY,GAAG,IAAI,CAAC;SACrB;QAED,MAAM,iBAAiB,GAAG,YAAY;YACpC,CAAC,CAAC,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,KAAK;YACjD,CAAC,CAAC,KAAK,CAAC;QACV,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAC7C,CAAC;CAAA","sourcesContent":["import type { TransactionDescription } from '@ethersproject/abi';\nimport { Interface } from '@ethersproject/abi';\nimport { query } from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport { abiERC721, abiERC20, abiERC1155 } from '@metamask/metamask-eth-abis';\n\nimport type { InferTransactionTypeResult, TransactionParams } from './types';\nimport { TransactionType } from './types';\n\nexport const ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error';\n\nconst ERC20Interface = new Interface(abiERC20);\nconst ERC721Interface = new Interface(abiERC721);\nconst ERC1155Interface = new Interface(abiERC1155);\n\n/**\n * Determines the type of the transaction by analyzing the txParams.\n * It will never return TRANSACTION_TYPE_CANCEL or TRANSACTION_TYPE_RETRY as these\n * represent specific events that we specify manually at transaction creation.\n *\n * @param txParams - Parameters for the transaction.\n * @param ethQuery - EthQuery instance.\n * @returns A object with the transaction type and the contract code response in Hex.\n */\nexport async function determineTransactionType(\n txParams: TransactionParams,\n ethQuery: EthQuery,\n): Promise<InferTransactionTypeResult> {\n const { data, to } = txParams;\n const name = parseStandardTokenTransactionData(data)?.name;\n\n if (data && !to) {\n return { type: TransactionType.deployContract, getCodeResponse: undefined };\n }\n\n const { contractCode: resultCode, isContractAddress } =\n await readAddressAsContract(ethQuery, to);\n\n if (!isContractAddress) {\n return { type: TransactionType.simpleSend, getCodeResponse: resultCode };\n }\n\n const hasValue = txParams.value && Number(txParams.value) !== 0;\n\n const tokenMethodName = [\n TransactionType.tokenMethodApprove,\n TransactionType.tokenMethodSetApprovalForAll,\n TransactionType.tokenMethodTransfer,\n TransactionType.tokenMethodTransferFrom,\n TransactionType.tokenMethodSafeTransferFrom,\n ].find((methodName) => methodName.toLowerCase() === name?.toLowerCase());\n\n if (data && tokenMethodName && !hasValue) {\n return { type: tokenMethodName, getCodeResponse: resultCode };\n }\n\n return {\n type: TransactionType.contractInteraction,\n getCodeResponse: resultCode,\n };\n}\n\n/**\n * Attempts to decode transaction data using ABIs for three different token standards: ERC20, ERC721, ERC1155.\n * The data will decode correctly if the transaction is an interaction with a contract that matches one of these\n * contract standards\n *\n * @param data - Encoded transaction data.\n * @returns A representation of an ethereum contract call.\n */\nfunction parseStandardTokenTransactionData(\n data?: string,\n): TransactionDescription | undefined {\n if (!data) {\n return undefined;\n }\n\n try {\n return ERC20Interface.parseTransaction({ data });\n } catch {\n // ignore and next try to parse with erc721 ABI\n }\n\n try {\n return ERC721Interface.parseTransaction({ data });\n } catch {\n // ignore and next try to parse with erc1155 ABI\n }\n\n try {\n return ERC1155Interface.parseTransaction({ data });\n } catch {\n // ignore and return undefined\n }\n\n return undefined;\n}\n\n/**\n * Reads an Ethereum address and determines if it is a contract address.\n *\n * @param ethQuery - The Ethereum query object used to interact with the Ethereum blockchain.\n * @param address - The Ethereum address.\n * @returns An object containing the contract code and a boolean indicating if it is a contract address.\n */\nasync function readAddressAsContract(\n ethQuery: EthQuery,\n address?: string,\n): Promise<{\n contractCode: string | null;\n isContractAddress: boolean;\n}> {\n let contractCode;\n try {\n contractCode = await query(ethQuery, 'getCode', [address]);\n } catch (e) {\n contractCode = null;\n }\n\n const isContractAddress = contractCode\n ? contractCode !== '0x' && contractCode !== '0x0'\n : false;\n return { contractCode, isContractAddress };\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ declare type TransactionMetaBase = {
|
|
|
32
32
|
/**
|
|
33
33
|
* Network code as per EIP-155 for this transaction.
|
|
34
34
|
*/
|
|
35
|
-
chainId
|
|
35
|
+
chainId: Hex;
|
|
36
36
|
/**
|
|
37
37
|
* Gas values provided by the dApp.
|
|
38
38
|
*/
|
|
@@ -74,9 +74,11 @@ declare type TransactionMetaBase = {
|
|
|
74
74
|
*/
|
|
75
75
|
isTransfer?: boolean;
|
|
76
76
|
/**
|
|
77
|
-
* Network code as per EIP-155 for this transaction
|
|
77
|
+
* Network code as per EIP-155 for this transaction
|
|
78
|
+
*
|
|
79
|
+
* @deprecated Use `chainId` instead.
|
|
78
80
|
*/
|
|
79
|
-
networkID?: string;
|
|
81
|
+
readonly networkID?: string;
|
|
80
82
|
/**
|
|
81
83
|
* Origin this transaction was sent from.
|
|
82
84
|
*/
|
|
@@ -143,9 +145,9 @@ declare type TransactionMetaBase = {
|
|
|
143
145
|
*/
|
|
144
146
|
txReceipt?: TransactionReceipt;
|
|
145
147
|
/**
|
|
146
|
-
* The transaction
|
|
148
|
+
* The type of transaction such as `cancel` or `swap`.
|
|
147
149
|
*/
|
|
148
|
-
|
|
150
|
+
type?: TransactionType;
|
|
149
151
|
/**
|
|
150
152
|
* The gas limit supplied by user.
|
|
151
153
|
*/
|
|
@@ -154,6 +156,10 @@ declare type TransactionMetaBase = {
|
|
|
154
156
|
* Estimate level user selected.
|
|
155
157
|
*/
|
|
156
158
|
userFeeLevel?: string;
|
|
159
|
+
/**
|
|
160
|
+
* The transaction's 'v' value as a hex string.
|
|
161
|
+
*/
|
|
162
|
+
v?: string;
|
|
157
163
|
/**
|
|
158
164
|
* Whether the transaction is verified on the blockchain.
|
|
159
165
|
*/
|
|
@@ -193,6 +199,103 @@ export declare enum WalletDevice {
|
|
|
193
199
|
MM_EXTENSION = "metamask_extension",
|
|
194
200
|
OTHER = "other_device"
|
|
195
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* The type of the transaction.
|
|
204
|
+
*/
|
|
205
|
+
export declare enum TransactionType {
|
|
206
|
+
/**
|
|
207
|
+
* A transaction sending a network's native asset to a recipient.
|
|
208
|
+
*/
|
|
209
|
+
cancel = "cancel",
|
|
210
|
+
/**
|
|
211
|
+
* A transaction that is interacting with a smart contract's methods that we
|
|
212
|
+
* have not treated as a special case, such as approve, transfer, and
|
|
213
|
+
* transferfrom.
|
|
214
|
+
*/
|
|
215
|
+
contractInteraction = "contractInteraction",
|
|
216
|
+
/**
|
|
217
|
+
* A transaction that deployed a smart contract.
|
|
218
|
+
*/
|
|
219
|
+
deployContract = "contractDeployment",
|
|
220
|
+
/**
|
|
221
|
+
* A transaction for Ethereum decryption.
|
|
222
|
+
*/
|
|
223
|
+
ethDecrypt = "eth_decrypt",
|
|
224
|
+
/**
|
|
225
|
+
* A transaction for getting an encryption public key.
|
|
226
|
+
*/
|
|
227
|
+
ethGetEncryptionPublicKey = "eth_getEncryptionPublicKey",
|
|
228
|
+
/**
|
|
229
|
+
* An incoming (deposit) transaction.
|
|
230
|
+
*/
|
|
231
|
+
incoming = "incoming",
|
|
232
|
+
/**
|
|
233
|
+
* A transaction for personal sign.
|
|
234
|
+
*/
|
|
235
|
+
personalSign = "personal_sign",
|
|
236
|
+
/**
|
|
237
|
+
* When a transaction is failed it can be retried by
|
|
238
|
+
* resubmitting the same transaction with a higher gas fee. This type is also used
|
|
239
|
+
* to speed up pending transactions. This is accomplished by creating a new tx with
|
|
240
|
+
* the same nonce and higher gas fees.
|
|
241
|
+
*/
|
|
242
|
+
retry = "retry",
|
|
243
|
+
/**
|
|
244
|
+
* A transaction sending a network's native asset to a recipient.
|
|
245
|
+
*/
|
|
246
|
+
simpleSend = "simpleSend",
|
|
247
|
+
/**
|
|
248
|
+
* A transaction that is signing a message.
|
|
249
|
+
*/
|
|
250
|
+
sign = "eth_sign",
|
|
251
|
+
/**
|
|
252
|
+
* A transaction that is signing typed data.
|
|
253
|
+
*/
|
|
254
|
+
signTypedData = "eth_signTypedData",
|
|
255
|
+
/**
|
|
256
|
+
* A transaction sending a network's native asset to a recipient.
|
|
257
|
+
*/
|
|
258
|
+
smart = "smart",
|
|
259
|
+
/**
|
|
260
|
+
* A transaction swapping one token for another through MetaMask Swaps.
|
|
261
|
+
*/
|
|
262
|
+
swap = "swap",
|
|
263
|
+
/**
|
|
264
|
+
* Similar to the approve type, a swap approval is a special case of ERC20
|
|
265
|
+
* approve method that requests an allowance of the token to spend on behalf
|
|
266
|
+
* of the user for the MetaMask Swaps contract. The first swap for any token
|
|
267
|
+
* will have an accompanying swapApproval transaction.
|
|
268
|
+
*/
|
|
269
|
+
swapApproval = "swapApproval",
|
|
270
|
+
/**
|
|
271
|
+
* A token transaction requesting an allowance of the token to spend on
|
|
272
|
+
* behalf of the user.
|
|
273
|
+
*/
|
|
274
|
+
tokenMethodApprove = "approve",
|
|
275
|
+
/**
|
|
276
|
+
* A token transaction transferring tokens from an account that the sender
|
|
277
|
+
* has an allowance of. The method is prefixed with safe because when calling
|
|
278
|
+
* this method the contract checks to ensure that the receiver is an address
|
|
279
|
+
* capable of handling the token being sent.
|
|
280
|
+
*/
|
|
281
|
+
tokenMethodSafeTransferFrom = "safetransferfrom",
|
|
282
|
+
/**
|
|
283
|
+
* A token transaction where the user is sending tokens that they own to
|
|
284
|
+
* another address.
|
|
285
|
+
*/
|
|
286
|
+
tokenMethodTransfer = "transfer",
|
|
287
|
+
/**
|
|
288
|
+
* A token transaction transferring tokens from an account that the sender
|
|
289
|
+
* has an allowance of. For more information on allowances, see the approve
|
|
290
|
+
* type.
|
|
291
|
+
*/
|
|
292
|
+
tokenMethodTransferFrom = "transferfrom",
|
|
293
|
+
/**
|
|
294
|
+
* A token transaction requesting an allowance of all of a user's tokens to
|
|
295
|
+
* spend on behalf of the user.
|
|
296
|
+
*/
|
|
297
|
+
tokenMethodSetApprovalForAll = "setapprovalforall"
|
|
298
|
+
}
|
|
196
299
|
/**
|
|
197
300
|
* Standard data concerning a transaction to be processed by the blockchain.
|
|
198
301
|
*/
|
|
@@ -317,10 +420,6 @@ export interface RemoteTransactionSourceRequest {
|
|
|
317
420
|
* The chainId of the current network.
|
|
318
421
|
*/
|
|
319
422
|
currentChainId: Hex;
|
|
320
|
-
/**
|
|
321
|
-
* The networkId of the current network.
|
|
322
|
-
*/
|
|
323
|
-
currentNetworkId: string;
|
|
324
423
|
/**
|
|
325
424
|
* Block number to start fetching transactions from.
|
|
326
425
|
*/
|
|
@@ -337,10 +436,9 @@ export interface RemoteTransactionSourceRequest {
|
|
|
337
436
|
export interface RemoteTransactionSource {
|
|
338
437
|
/**
|
|
339
438
|
* @param chainId - The chainId of the current network.
|
|
340
|
-
* @param networkId - The networkId of the current network.
|
|
341
439
|
* @returns Whether the remote transaction source supports the specified network.
|
|
342
440
|
*/
|
|
343
|
-
isSupportedNetwork: (chainId: Hex
|
|
441
|
+
isSupportedNetwork: (chainId: Hex) => boolean;
|
|
344
442
|
/**
|
|
345
443
|
* @returns An array of additional keys to use when caching the last fetched block number.
|
|
346
444
|
*/
|
|
@@ -382,5 +480,19 @@ export declare type TransactionHistory = [
|
|
|
382
480
|
TransactionMeta,
|
|
383
481
|
...TransactionHistoryEntry[]
|
|
384
482
|
];
|
|
483
|
+
/**
|
|
484
|
+
* Result of inferring the transaction type.
|
|
485
|
+
*/
|
|
486
|
+
export declare type InferTransactionTypeResult = {
|
|
487
|
+
/**
|
|
488
|
+
* The contract code, in hex format if it exists. '0x0' or
|
|
489
|
+
* '0x' are also indicators of non-existent contract code.
|
|
490
|
+
*/
|
|
491
|
+
getCodeResponse?: string | null;
|
|
492
|
+
/**
|
|
493
|
+
* The type of transaction
|
|
494
|
+
*/
|
|
495
|
+
type: TransactionType;
|
|
496
|
+
};
|
|
385
497
|
export {};
|
|
386
498
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;GAEG;AACH,oBAAY,eAAe,GACvB,CAAC;IACC,MAAM,EAAE,OAAO,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;CAC9D,GAAG,mBAAmB,CAAC,GACxB,CAAC;IAAE,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,mBAAmB,CAAC,CAAC;AAE/E;;GAEG;AACH,aAAK,mBAAmB,GAAG;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,aAAa,CAAC,EAAE,GAAG,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG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;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,kBAAkB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC;IAE9C;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,MAAM,EAAE,CAAC;IAExC;;;OAGG;IACH,iBAAiB,EAAE,CACjB,OAAO,EAAE,8BAA8B,KACpC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,aAAK,wBAAwB,GAAG,SAAS,GAAG;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,oBAAY,uBAAuB,GAAG;IACpC,wBAAwB;IACxB,GAAG,SAAS,EAAE;CACf,CAAC;AAEF;;;GAGG;AACH,oBAAY,kBAAkB,GAAG;IAC/B,eAAe;IACf,GAAG,uBAAuB,EAAE;CAC7B,CAAC;AAEF;;GAEG;AACH,oBAAY,0BAA0B,GAAG;IACvC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC;;OAEG;IACH,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WalletDevice = exports.TransactionStatus = void 0;
|
|
3
|
+
exports.TransactionType = exports.WalletDevice = exports.TransactionStatus = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* The status of the transaction. Each status represents the state of the transaction internally
|
|
6
6
|
* in the wallet. Some of these correspond with the state of the transaction on the network, but
|
|
@@ -27,4 +27,102 @@ var WalletDevice;
|
|
|
27
27
|
WalletDevice["MM_EXTENSION"] = "metamask_extension";
|
|
28
28
|
WalletDevice["OTHER"] = "other_device";
|
|
29
29
|
})(WalletDevice = exports.WalletDevice || (exports.WalletDevice = {}));
|
|
30
|
+
/**
|
|
31
|
+
* The type of the transaction.
|
|
32
|
+
*/
|
|
33
|
+
var TransactionType;
|
|
34
|
+
(function (TransactionType) {
|
|
35
|
+
/**
|
|
36
|
+
* A transaction sending a network's native asset to a recipient.
|
|
37
|
+
*/
|
|
38
|
+
TransactionType["cancel"] = "cancel";
|
|
39
|
+
/**
|
|
40
|
+
* A transaction that is interacting with a smart contract's methods that we
|
|
41
|
+
* have not treated as a special case, such as approve, transfer, and
|
|
42
|
+
* transferfrom.
|
|
43
|
+
*/
|
|
44
|
+
TransactionType["contractInteraction"] = "contractInteraction";
|
|
45
|
+
/**
|
|
46
|
+
* A transaction that deployed a smart contract.
|
|
47
|
+
*/
|
|
48
|
+
TransactionType["deployContract"] = "contractDeployment";
|
|
49
|
+
/**
|
|
50
|
+
* A transaction for Ethereum decryption.
|
|
51
|
+
*/
|
|
52
|
+
TransactionType["ethDecrypt"] = "eth_decrypt";
|
|
53
|
+
/**
|
|
54
|
+
* A transaction for getting an encryption public key.
|
|
55
|
+
*/
|
|
56
|
+
TransactionType["ethGetEncryptionPublicKey"] = "eth_getEncryptionPublicKey";
|
|
57
|
+
/**
|
|
58
|
+
* An incoming (deposit) transaction.
|
|
59
|
+
*/
|
|
60
|
+
TransactionType["incoming"] = "incoming";
|
|
61
|
+
/**
|
|
62
|
+
* A transaction for personal sign.
|
|
63
|
+
*/
|
|
64
|
+
TransactionType["personalSign"] = "personal_sign";
|
|
65
|
+
/**
|
|
66
|
+
* When a transaction is failed it can be retried by
|
|
67
|
+
* resubmitting the same transaction with a higher gas fee. This type is also used
|
|
68
|
+
* to speed up pending transactions. This is accomplished by creating a new tx with
|
|
69
|
+
* the same nonce and higher gas fees.
|
|
70
|
+
*/
|
|
71
|
+
TransactionType["retry"] = "retry";
|
|
72
|
+
/**
|
|
73
|
+
* A transaction sending a network's native asset to a recipient.
|
|
74
|
+
*/
|
|
75
|
+
TransactionType["simpleSend"] = "simpleSend";
|
|
76
|
+
/**
|
|
77
|
+
* A transaction that is signing a message.
|
|
78
|
+
*/
|
|
79
|
+
TransactionType["sign"] = "eth_sign";
|
|
80
|
+
/**
|
|
81
|
+
* A transaction that is signing typed data.
|
|
82
|
+
*/
|
|
83
|
+
TransactionType["signTypedData"] = "eth_signTypedData";
|
|
84
|
+
/**
|
|
85
|
+
* A transaction sending a network's native asset to a recipient.
|
|
86
|
+
*/
|
|
87
|
+
TransactionType["smart"] = "smart";
|
|
88
|
+
/**
|
|
89
|
+
* A transaction swapping one token for another through MetaMask Swaps.
|
|
90
|
+
*/
|
|
91
|
+
TransactionType["swap"] = "swap";
|
|
92
|
+
/**
|
|
93
|
+
* Similar to the approve type, a swap approval is a special case of ERC20
|
|
94
|
+
* approve method that requests an allowance of the token to spend on behalf
|
|
95
|
+
* of the user for the MetaMask Swaps contract. The first swap for any token
|
|
96
|
+
* will have an accompanying swapApproval transaction.
|
|
97
|
+
*/
|
|
98
|
+
TransactionType["swapApproval"] = "swapApproval";
|
|
99
|
+
/**
|
|
100
|
+
* A token transaction requesting an allowance of the token to spend on
|
|
101
|
+
* behalf of the user.
|
|
102
|
+
*/
|
|
103
|
+
TransactionType["tokenMethodApprove"] = "approve";
|
|
104
|
+
/**
|
|
105
|
+
* A token transaction transferring tokens from an account that the sender
|
|
106
|
+
* has an allowance of. The method is prefixed with safe because when calling
|
|
107
|
+
* this method the contract checks to ensure that the receiver is an address
|
|
108
|
+
* capable of handling the token being sent.
|
|
109
|
+
*/
|
|
110
|
+
TransactionType["tokenMethodSafeTransferFrom"] = "safetransferfrom";
|
|
111
|
+
/**
|
|
112
|
+
* A token transaction where the user is sending tokens that they own to
|
|
113
|
+
* another address.
|
|
114
|
+
*/
|
|
115
|
+
TransactionType["tokenMethodTransfer"] = "transfer";
|
|
116
|
+
/**
|
|
117
|
+
* A token transaction transferring tokens from an account that the sender
|
|
118
|
+
* has an allowance of. For more information on allowances, see the approve
|
|
119
|
+
* type.
|
|
120
|
+
*/
|
|
121
|
+
TransactionType["tokenMethodTransferFrom"] = "transferfrom";
|
|
122
|
+
/**
|
|
123
|
+
* A token transaction requesting an allowance of all of a user's tokens to
|
|
124
|
+
* spend on behalf of the user.
|
|
125
|
+
*/
|
|
126
|
+
TransactionType["tokenMethodSetApprovalForAll"] = "setapprovalforall";
|
|
127
|
+
})(TransactionType = exports.TransactionType || (exports.TransactionType = {}));
|
|
30
128
|
//# sourceMappingURL=types.js.map
|