@metamask-previews/transaction-controller 39.1.0-preview-608079df → 40.0.0-preview-e6722625
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 +8 -1
- package/dist/TransactionController.cjs +6 -58
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +1 -3
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +1 -3
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +8 -60
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/errors.cjs +1 -8
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +0 -4
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +0 -4
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +0 -6
- package/dist/errors.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +2 -4
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +2 -4
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/validation.cjs +1 -13
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.cts +0 -7
- package/dist/utils/validation.d.cts.map +1 -1
- package/dist/utils/validation.d.mts +0 -7
- package/dist/utils/validation.d.mts.map +1 -1
- package/dist/utils/validation.mjs +0 -11
- package/dist/utils/validation.mjs.map +1 -1
- package/package.json +3 -4
- package/dist/api/accounts-api.cjs +0 -47
- package/dist/api/accounts-api.cjs.map +0 -1
- package/dist/api/accounts-api.d.cts +0 -43
- package/dist/api/accounts-api.d.cts.map +0 -1
- package/dist/api/accounts-api.d.mts +0 -43
- package/dist/api/accounts-api.d.mts.map +0 -1
- package/dist/api/accounts-api.mjs +0 -43
- package/dist/api/accounts-api.mjs.map +0 -1
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export type AccountAddressRelationshipResponse = {
|
|
2
|
-
chainId?: number;
|
|
3
|
-
count?: number;
|
|
4
|
-
data?: {
|
|
5
|
-
hash: string;
|
|
6
|
-
timestamp: string;
|
|
7
|
-
chainId: number;
|
|
8
|
-
blockNumber: string;
|
|
9
|
-
blockHash: string;
|
|
10
|
-
gas: number;
|
|
11
|
-
gasUsed: number;
|
|
12
|
-
gasPrice: string;
|
|
13
|
-
effectiveGasPrice: number;
|
|
14
|
-
nonce: number;
|
|
15
|
-
cumulativeGasUsed: number;
|
|
16
|
-
methodId: string;
|
|
17
|
-
value: string;
|
|
18
|
-
to: string;
|
|
19
|
-
from: string;
|
|
20
|
-
};
|
|
21
|
-
txHash?: string;
|
|
22
|
-
};
|
|
23
|
-
export type AccountAddressRelationshipResult = AccountAddressRelationshipResponse & {
|
|
24
|
-
error?: {
|
|
25
|
-
code: string;
|
|
26
|
-
message: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export type GetAccountAddressRelationshipRequest = {
|
|
30
|
-
/** Chain ID of account relationship to check. */
|
|
31
|
-
chainId: number;
|
|
32
|
-
/** Recipient of the transaction. */
|
|
33
|
-
to: string;
|
|
34
|
-
/** Sender of the transaction. */
|
|
35
|
-
from: string;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Fetch account address relationship from the accounts API.
|
|
39
|
-
* @param request - The request object.
|
|
40
|
-
* @returns The raw response object from the API.
|
|
41
|
-
*/
|
|
42
|
-
export declare function getAccountAddressRelationship(request: GetAccountAddressRelationshipRequest): Promise<AccountAddressRelationshipResult>;
|
|
43
|
-
//# sourceMappingURL=accounts-api.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accounts-api.d.mts","sourceRoot":"","sources":["../../src/api/accounts-api.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,kCAAkC,GAAG;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,KAAK,EAAE,MAAM,CAAC;QACd,iBAAiB,EAAE,MAAM,CAAC;QAC1B,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAC1C,kCAAkC,GAAG;IACnC,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEJ,MAAM,MAAM,oCAAoC,GAAG;IACjD,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAEhB,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IAEX,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAMF;;;;GAIG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,oCAAoC,GAC5C,OAAO,CAAC,gCAAgC,CAAC,CA8B3C"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { createModuleLogger } from "@metamask/utils";
|
|
2
|
-
import { FirstTimeInteractionError } from "../errors.mjs";
|
|
3
|
-
import { projectLogger } from "../logger.mjs";
|
|
4
|
-
const SUPPORTED_CHAIN_IDS_FOR_RELATIONSHIP_API = [
|
|
5
|
-
1,
|
|
6
|
-
10,
|
|
7
|
-
56,
|
|
8
|
-
137,
|
|
9
|
-
8453,
|
|
10
|
-
42161,
|
|
11
|
-
59144,
|
|
12
|
-
534352, // Scroll
|
|
13
|
-
];
|
|
14
|
-
const BASE_URL = `https://accounts.api.cx.metamask.io`;
|
|
15
|
-
const log = createModuleLogger(projectLogger, 'accounts-api');
|
|
16
|
-
/**
|
|
17
|
-
* Fetch account address relationship from the accounts API.
|
|
18
|
-
* @param request - The request object.
|
|
19
|
-
* @returns The raw response object from the API.
|
|
20
|
-
*/
|
|
21
|
-
export async function getAccountAddressRelationship(request) {
|
|
22
|
-
const { chainId, from, to } = request;
|
|
23
|
-
if (!SUPPORTED_CHAIN_IDS_FOR_RELATIONSHIP_API.includes(chainId)) {
|
|
24
|
-
log('Unsupported chain ID for account relationship API', chainId);
|
|
25
|
-
throw new FirstTimeInteractionError('Unsupported chain ID');
|
|
26
|
-
}
|
|
27
|
-
const url = `${BASE_URL}/v1/networks/${chainId}/accounts/${from}/relationships/${to}`;
|
|
28
|
-
log('Getting account address relationship', { request, url });
|
|
29
|
-
const response = await fetch(url);
|
|
30
|
-
if (response.status === 204) {
|
|
31
|
-
// The accounts API returns a 204 status code when there are no transactions with empty body
|
|
32
|
-
// imitating a count of 0
|
|
33
|
-
return { count: 0 };
|
|
34
|
-
}
|
|
35
|
-
const responseJson = await response.json();
|
|
36
|
-
log('Retrieved account address relationship', responseJson);
|
|
37
|
-
if (responseJson.error) {
|
|
38
|
-
const { code, message } = responseJson.error;
|
|
39
|
-
throw new FirstTimeInteractionError(message, code);
|
|
40
|
-
}
|
|
41
|
-
return responseJson;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=accounts-api.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accounts-api.mjs","sourceRoot":"","sources":["../../src/api/accounts-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAErD,OAAO,EAAE,yBAAyB,EAAE,sBAAkB;AACtD,OAAO,EAAE,aAAa,EAAE,sBAAkB;AAE1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AAY,CAAC;AACtB,CAAC","sourcesContent":["import { createModuleLogger } from '@metamask/utils';\n\nimport { FirstTimeInteractionError } from '../errors';\nimport { projectLogger } from '../logger';\n\nconst SUPPORTED_CHAIN_IDS_FOR_RELATIONSHIP_API = [\n 1, // Ethereum Mainnet\n 10, // Optimism\n 56, // BSC\n 137, // Polygon\n 8453, // Base\n 42161, // Arbitrum\n 59144, // Linea\n 534352, // Scroll\n];\n\nexport type AccountAddressRelationshipResponse = {\n chainId?: number;\n count?: number;\n data?: {\n hash: string;\n timestamp: string;\n chainId: number;\n blockNumber: string;\n blockHash: string;\n gas: number;\n gasUsed: number;\n gasPrice: string;\n effectiveGasPrice: number;\n nonce: number;\n cumulativeGasUsed: number;\n methodId: string;\n value: string;\n to: string;\n from: string;\n };\n txHash?: string;\n};\n\nexport type AccountAddressRelationshipResult =\n AccountAddressRelationshipResponse & {\n error?: {\n code: string;\n message: string;\n };\n };\n\nexport type GetAccountAddressRelationshipRequest = {\n /** Chain ID of account relationship to check. */\n chainId: number;\n\n /** Recipient of the transaction. */\n to: string;\n\n /** Sender of the transaction. */\n from: string;\n};\n\nconst BASE_URL = `https://accounts.api.cx.metamask.io`;\n\nconst log = createModuleLogger(projectLogger, 'accounts-api');\n\n/**\n * Fetch account address relationship from the accounts API.\n * @param request - The request object.\n * @returns The raw response object from the API.\n */\nexport async function getAccountAddressRelationship(\n request: GetAccountAddressRelationshipRequest,\n): Promise<AccountAddressRelationshipResult> {\n const { chainId, from, to } = request;\n\n if (!SUPPORTED_CHAIN_IDS_FOR_RELATIONSHIP_API.includes(chainId)) {\n log('Unsupported chain ID for account relationship API', chainId);\n throw new FirstTimeInteractionError('Unsupported chain ID');\n }\n\n const url = `${BASE_URL}/v1/networks/${chainId}/accounts/${from}/relationships/${to}`;\n\n log('Getting account address relationship', { request, url });\n\n const response = await fetch(url);\n\n if (response.status === 204) {\n // The accounts API returns a 204 status code when there are no transactions with empty body\n // imitating a count of 0\n return { count: 0 };\n }\n\n const responseJson: AccountAddressRelationshipResult = await response.json();\n\n log('Retrieved account address relationship', responseJson);\n\n if (responseJson.error) {\n const { code, message } = responseJson.error;\n throw new FirstTimeInteractionError(message, code);\n }\n\n return responseJson;\n}\n"]}
|