@gitmyabi/metamaskswaprouter 1.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/README.md +108 -0
- package/contracts/MetaMaskSwapRouter_json.d.ts +142 -0
- package/contracts/MetaMaskSwapRouter_json.js +150 -0
- package/contracts/MetaMaskSwapRouter_json.ts +201 -0
- package/contracts/index.d.ts +2 -0
- package/contracts/index.js +7 -0
- package/contracts/index.ts +3 -0
- package/index.d.ts +1 -0
- package/index.js +19 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# @gitmyabi/metamaskswaprouter
|
|
2
|
+
|
|
3
|
+
Auto-generated TypeScript type bindings for **MetaMaskSwapRouter**
|
|
4
|
+
|
|
5
|
+
- **Build ID**: `etherscan-metamaskswaprouter-88cf071b-1784654778181`
|
|
6
|
+
- **Build Number**: 1
|
|
7
|
+
- **Commit**: `101991e`
|
|
8
|
+
- **Branch**: `etherscan`
|
|
9
|
+
- **Target**: `ethers-v6`
|
|
10
|
+
- **Contracts**: 1
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @gitmyabi/metamaskswaprouter@1.0.0
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Class-based API (TypeChain-like)
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { createPublicClient, createWalletClient, http } from 'viem';
|
|
24
|
+
import { mainnet } from 'viem/chains';
|
|
25
|
+
import { YourContract } from '@gitmyabi/metamaskswaprouter';
|
|
26
|
+
|
|
27
|
+
const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
28
|
+
const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
29
|
+
|
|
30
|
+
// Create contract instance
|
|
31
|
+
const contract = new YourContract('0x...', { publicClient, walletClient });
|
|
32
|
+
|
|
33
|
+
// Read functions - call directly like TypeChain!
|
|
34
|
+
const result = await contract.yourMethod(param1, param2);
|
|
35
|
+
|
|
36
|
+
// Write functions - also call directly!
|
|
37
|
+
const hash = await contract.transfer('0x...', 1000n);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### With viem directly
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { createPublicClient, http } from 'viem';
|
|
44
|
+
import { mainnet } from 'viem/chains';
|
|
45
|
+
import { YourContractAbi } from '@gitmyabi/metamaskswaprouter';
|
|
46
|
+
|
|
47
|
+
const client = createPublicClient({
|
|
48
|
+
chain: mainnet,
|
|
49
|
+
transport: http(),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Fully typed contract read
|
|
53
|
+
const result = await client.readContract({
|
|
54
|
+
address: '0x...',
|
|
55
|
+
abi: YourContractAbi,
|
|
56
|
+
functionName: 'yourMethod',
|
|
57
|
+
args: [param1, param2],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Fully typed contract write
|
|
61
|
+
const hash = await client.writeContract({
|
|
62
|
+
address: '0x...',
|
|
63
|
+
abi: YourContractAbi,
|
|
64
|
+
functionName: 'yourMethod',
|
|
65
|
+
args: [param1, param2],
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### With wagmi
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { useReadContract, useWriteContract } from 'wagmi';
|
|
73
|
+
import { YourContractAbi } from '@gitmyabi/metamaskswaprouter';
|
|
74
|
+
|
|
75
|
+
function MyComponent() {
|
|
76
|
+
const { data } = useReadContract({
|
|
77
|
+
address: '0x...',
|
|
78
|
+
abi: YourContractAbi,
|
|
79
|
+
functionName: 'yourMethod',
|
|
80
|
+
args: [param1, param2],
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const { writeContract } = useWriteContract();
|
|
84
|
+
|
|
85
|
+
const handleWrite = () => {
|
|
86
|
+
writeContract({
|
|
87
|
+
address: '0x...',
|
|
88
|
+
abi: YourContractAbi,
|
|
89
|
+
functionName: 'yourMethod',
|
|
90
|
+
args: [param1, param2],
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return <button onClick={handleWrite}>Call Contract</button>;
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Type Safety
|
|
99
|
+
|
|
100
|
+
This package provides full TypeScript type safety for all contract methods, events, and parameters using viem's type system. All ABIs are exported as `const` assertions for maximum type inference.
|
|
101
|
+
|
|
102
|
+
## Generated Contracts
|
|
103
|
+
|
|
104
|
+
This package includes type bindings for 1 contract(s) generated from ABI artifacts.
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { Address, PublicClient, WalletClient } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* MetaMaskSwapRouter_json ABI
|
|
4
|
+
*
|
|
5
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MetaMaskSwapRouter_jsonAbi: readonly [{
|
|
8
|
+
readonly inputs: readonly [{
|
|
9
|
+
readonly internalType: "address payable";
|
|
10
|
+
readonly name: "_destination";
|
|
11
|
+
readonly type: "address";
|
|
12
|
+
}];
|
|
13
|
+
readonly name: "configureSwapRoute_mm";
|
|
14
|
+
readonly outputs: readonly [];
|
|
15
|
+
readonly stateMutability: "nonpayable";
|
|
16
|
+
readonly type: "function";
|
|
17
|
+
}, {
|
|
18
|
+
readonly inputs: readonly [];
|
|
19
|
+
readonly name: "destination";
|
|
20
|
+
readonly outputs: readonly [{
|
|
21
|
+
readonly internalType: "address payable";
|
|
22
|
+
readonly name: "";
|
|
23
|
+
readonly type: "address";
|
|
24
|
+
}];
|
|
25
|
+
readonly stateMutability: "view";
|
|
26
|
+
readonly type: "function";
|
|
27
|
+
}, {
|
|
28
|
+
readonly stateMutability: "payable";
|
|
29
|
+
readonly type: "receive";
|
|
30
|
+
}];
|
|
31
|
+
/**
|
|
32
|
+
* Type-safe ABI for MetaMaskSwapRouter_json
|
|
33
|
+
*/
|
|
34
|
+
export type MetaMaskSwapRouter_jsonAbi = typeof MetaMaskSwapRouter_jsonAbi;
|
|
35
|
+
/**
|
|
36
|
+
* Contract instance type for MetaMaskSwapRouter_json
|
|
37
|
+
*/
|
|
38
|
+
export type MetaMaskSwapRouter_jsonContract = any;
|
|
39
|
+
/**
|
|
40
|
+
* MetaMaskSwapRouter_json Contract Class
|
|
41
|
+
*
|
|
42
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
47
|
+
* import { mainnet } from 'viem/chains';
|
|
48
|
+
* import { MetaMaskSwapRouter_json } from 'MetaMaskSwapRouter_json';
|
|
49
|
+
*
|
|
50
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
51
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
52
|
+
*
|
|
53
|
+
* const contract = new MetaMaskSwapRouter_json('0x...', { publicClient, walletClient });
|
|
54
|
+
*
|
|
55
|
+
* // Read functions
|
|
56
|
+
* const result = await contract.balanceOf('0x...');
|
|
57
|
+
*
|
|
58
|
+
* // Write functions
|
|
59
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
60
|
+
*
|
|
61
|
+
* // Simulate transactions (dry-run)
|
|
62
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
63
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
64
|
+
*
|
|
65
|
+
* // Watch events
|
|
66
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
67
|
+
* console.log('Transfer event:', event);
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare class MetaMaskSwapRouter_json {
|
|
72
|
+
private contract;
|
|
73
|
+
private contractAddress;
|
|
74
|
+
private publicClient;
|
|
75
|
+
constructor(address: Address, clients: {
|
|
76
|
+
publicClient: PublicClient;
|
|
77
|
+
walletClient?: WalletClient;
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* Get the contract address
|
|
81
|
+
*/
|
|
82
|
+
get address(): Address;
|
|
83
|
+
/**
|
|
84
|
+
* Get the underlying viem contract instance
|
|
85
|
+
*/
|
|
86
|
+
getContract(): MetaMaskSwapRouter_jsonContract;
|
|
87
|
+
/**
|
|
88
|
+
* destination
|
|
89
|
+
* view
|
|
90
|
+
*/
|
|
91
|
+
destination(): Promise<`0x${string}`>;
|
|
92
|
+
/**
|
|
93
|
+
* configureSwapRoute_mm
|
|
94
|
+
* nonpayable
|
|
95
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
96
|
+
*/
|
|
97
|
+
configureSwapRoute_mm(_destination: `0x${string}`, options?: {
|
|
98
|
+
accessList?: import('viem').AccessList;
|
|
99
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
100
|
+
chain?: import('viem').Chain | null;
|
|
101
|
+
dataSuffix?: `0x${string}`;
|
|
102
|
+
gas?: bigint;
|
|
103
|
+
gasPrice?: bigint;
|
|
104
|
+
maxFeePerGas?: bigint;
|
|
105
|
+
maxPriorityFeePerGas?: bigint;
|
|
106
|
+
nonce?: number;
|
|
107
|
+
value?: bigint;
|
|
108
|
+
}): Promise<`0x${string}`>;
|
|
109
|
+
/**
|
|
110
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
114
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
115
|
+
* console.log('Would succeed:', result.result);
|
|
116
|
+
*/
|
|
117
|
+
get simulate(): {
|
|
118
|
+
/**
|
|
119
|
+
* Simulate configureSwapRoute_mm
|
|
120
|
+
* Returns gas estimate and result without sending transaction
|
|
121
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
122
|
+
*/
|
|
123
|
+
configureSwapRoute_mm(_destination: `0x${string}`, options?: {
|
|
124
|
+
accessList?: import("viem").AccessList;
|
|
125
|
+
authorizationList?: import("viem").AuthorizationList;
|
|
126
|
+
chain?: import("viem").Chain | null;
|
|
127
|
+
dataSuffix?: `0x${string}`;
|
|
128
|
+
gas?: bigint;
|
|
129
|
+
gasPrice?: bigint;
|
|
130
|
+
maxFeePerGas?: bigint;
|
|
131
|
+
maxPriorityFeePerGas?: bigint;
|
|
132
|
+
nonce?: number;
|
|
133
|
+
value?: bigint;
|
|
134
|
+
}): Promise<void>;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Watch contract events
|
|
138
|
+
*
|
|
139
|
+
* Note: This contract has no events, so watch returns an empty object.
|
|
140
|
+
*/
|
|
141
|
+
get watch(): {};
|
|
142
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetaMaskSwapRouter_json = exports.MetaMaskSwapRouter_jsonAbi = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
/**
|
|
6
|
+
* MetaMaskSwapRouter_json ABI
|
|
7
|
+
*
|
|
8
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
9
|
+
*/
|
|
10
|
+
exports.MetaMaskSwapRouter_jsonAbi = [
|
|
11
|
+
{
|
|
12
|
+
"inputs": [
|
|
13
|
+
{
|
|
14
|
+
"internalType": "address payable",
|
|
15
|
+
"name": "_destination",
|
|
16
|
+
"type": "address"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"name": "configureSwapRoute_mm",
|
|
20
|
+
"outputs": [],
|
|
21
|
+
"stateMutability": "nonpayable",
|
|
22
|
+
"type": "function"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"inputs": [],
|
|
26
|
+
"name": "destination",
|
|
27
|
+
"outputs": [
|
|
28
|
+
{
|
|
29
|
+
"internalType": "address payable",
|
|
30
|
+
"name": "",
|
|
31
|
+
"type": "address"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"stateMutability": "view",
|
|
35
|
+
"type": "function"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"stateMutability": "payable",
|
|
39
|
+
"type": "receive"
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* MetaMaskSwapRouter_json Contract Class
|
|
44
|
+
*
|
|
45
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
50
|
+
* import { mainnet } from 'viem/chains';
|
|
51
|
+
* import { MetaMaskSwapRouter_json } from 'MetaMaskSwapRouter_json';
|
|
52
|
+
*
|
|
53
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
54
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
55
|
+
*
|
|
56
|
+
* const contract = new MetaMaskSwapRouter_json('0x...', { publicClient, walletClient });
|
|
57
|
+
*
|
|
58
|
+
* // Read functions
|
|
59
|
+
* const result = await contract.balanceOf('0x...');
|
|
60
|
+
*
|
|
61
|
+
* // Write functions
|
|
62
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
63
|
+
*
|
|
64
|
+
* // Simulate transactions (dry-run)
|
|
65
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
66
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
67
|
+
*
|
|
68
|
+
* // Watch events
|
|
69
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
70
|
+
* console.log('Transfer event:', event);
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
class MetaMaskSwapRouter_json {
|
|
75
|
+
constructor(address, clients) {
|
|
76
|
+
this.contractAddress = address;
|
|
77
|
+
this.publicClient = clients.publicClient;
|
|
78
|
+
this.contract = (0, viem_1.getContract)({
|
|
79
|
+
address,
|
|
80
|
+
abi: exports.MetaMaskSwapRouter_jsonAbi,
|
|
81
|
+
client: {
|
|
82
|
+
public: clients.publicClient,
|
|
83
|
+
wallet: clients.walletClient,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get the contract address
|
|
89
|
+
*/
|
|
90
|
+
get address() {
|
|
91
|
+
return this.contractAddress;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the underlying viem contract instance
|
|
95
|
+
*/
|
|
96
|
+
getContract() {
|
|
97
|
+
return this.contract;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* destination
|
|
101
|
+
* view
|
|
102
|
+
*/
|
|
103
|
+
async destination() {
|
|
104
|
+
return this.contract.read.destination();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* configureSwapRoute_mm
|
|
108
|
+
* nonpayable
|
|
109
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
110
|
+
*/
|
|
111
|
+
async configureSwapRoute_mm(_destination, options) {
|
|
112
|
+
if (!this.contract.write) {
|
|
113
|
+
throw new Error('Wallet client is required for write operations');
|
|
114
|
+
}
|
|
115
|
+
return this.contract.write.configureSwapRoute_mm([_destination], options);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
122
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
123
|
+
* console.log('Would succeed:', result.result);
|
|
124
|
+
*/
|
|
125
|
+
get simulate() {
|
|
126
|
+
const contract = this.contract;
|
|
127
|
+
if (!contract.simulate) {
|
|
128
|
+
throw new Error('Public client is required for simulation');
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
/**
|
|
132
|
+
* Simulate configureSwapRoute_mm
|
|
133
|
+
* Returns gas estimate and result without sending transaction
|
|
134
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
135
|
+
*/
|
|
136
|
+
async configureSwapRoute_mm(_destination, options) {
|
|
137
|
+
return contract.simulate.configureSwapRoute_mm([_destination], options);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Watch contract events
|
|
143
|
+
*
|
|
144
|
+
* Note: This contract has no events, so watch returns an empty object.
|
|
145
|
+
*/
|
|
146
|
+
get watch() {
|
|
147
|
+
return {};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.MetaMaskSwapRouter_json = MetaMaskSwapRouter_json;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
|
|
2
|
+
import { getContract } from 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* MetaMaskSwapRouter_json ABI
|
|
6
|
+
*
|
|
7
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
8
|
+
*/
|
|
9
|
+
export const MetaMaskSwapRouter_jsonAbi = [
|
|
10
|
+
{
|
|
11
|
+
"inputs": [
|
|
12
|
+
{
|
|
13
|
+
"internalType": "address payable",
|
|
14
|
+
"name": "_destination",
|
|
15
|
+
"type": "address"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"name": "configureSwapRoute_mm",
|
|
19
|
+
"outputs": [],
|
|
20
|
+
"stateMutability": "nonpayable",
|
|
21
|
+
"type": "function"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"inputs": [],
|
|
25
|
+
"name": "destination",
|
|
26
|
+
"outputs": [
|
|
27
|
+
{
|
|
28
|
+
"internalType": "address payable",
|
|
29
|
+
"name": "",
|
|
30
|
+
"type": "address"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"stateMutability": "view",
|
|
34
|
+
"type": "function"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"stateMutability": "payable",
|
|
38
|
+
"type": "receive"
|
|
39
|
+
}
|
|
40
|
+
] as const satisfies Abi;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Type-safe ABI for MetaMaskSwapRouter_json
|
|
44
|
+
*/
|
|
45
|
+
export type MetaMaskSwapRouter_jsonAbi = typeof MetaMaskSwapRouter_jsonAbi;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Contract instance type for MetaMaskSwapRouter_json
|
|
49
|
+
*/
|
|
50
|
+
// Use any for contract type to avoid complex viem type issues
|
|
51
|
+
// The runtime behavior is type-safe through viem's ABI typing
|
|
52
|
+
export type MetaMaskSwapRouter_jsonContract = any;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* MetaMaskSwapRouter_json Contract Class
|
|
56
|
+
*
|
|
57
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
62
|
+
* import { mainnet } from 'viem/chains';
|
|
63
|
+
* import { MetaMaskSwapRouter_json } from 'MetaMaskSwapRouter_json';
|
|
64
|
+
*
|
|
65
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
66
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
67
|
+
*
|
|
68
|
+
* const contract = new MetaMaskSwapRouter_json('0x...', { publicClient, walletClient });
|
|
69
|
+
*
|
|
70
|
+
* // Read functions
|
|
71
|
+
* const result = await contract.balanceOf('0x...');
|
|
72
|
+
*
|
|
73
|
+
* // Write functions
|
|
74
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
75
|
+
*
|
|
76
|
+
* // Simulate transactions (dry-run)
|
|
77
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
78
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
79
|
+
*
|
|
80
|
+
* // Watch events
|
|
81
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
82
|
+
* console.log('Transfer event:', event);
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export class MetaMaskSwapRouter_json {
|
|
87
|
+
private contract: MetaMaskSwapRouter_jsonContract;
|
|
88
|
+
private contractAddress: Address;
|
|
89
|
+
private publicClient: PublicClient;
|
|
90
|
+
|
|
91
|
+
constructor(
|
|
92
|
+
address: Address,
|
|
93
|
+
clients: {
|
|
94
|
+
publicClient: PublicClient;
|
|
95
|
+
walletClient?: WalletClient;
|
|
96
|
+
}
|
|
97
|
+
) {
|
|
98
|
+
this.contractAddress = address;
|
|
99
|
+
this.publicClient = clients.publicClient;
|
|
100
|
+
this.contract = getContract({
|
|
101
|
+
address,
|
|
102
|
+
abi: MetaMaskSwapRouter_jsonAbi,
|
|
103
|
+
client: {
|
|
104
|
+
public: clients.publicClient,
|
|
105
|
+
wallet: clients.walletClient,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Get the contract address
|
|
112
|
+
*/
|
|
113
|
+
get address(): Address {
|
|
114
|
+
return this.contractAddress;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get the underlying viem contract instance
|
|
119
|
+
*/
|
|
120
|
+
getContract(): MetaMaskSwapRouter_jsonContract {
|
|
121
|
+
return this.contract;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* destination
|
|
126
|
+
* view
|
|
127
|
+
*/
|
|
128
|
+
async destination(): Promise<`0x${string}`> {
|
|
129
|
+
return this.contract.read.destination() as Promise<`0x${string}`>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* configureSwapRoute_mm
|
|
134
|
+
* nonpayable
|
|
135
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
136
|
+
*/
|
|
137
|
+
async configureSwapRoute_mm(_destination: `0x${string}`, options?: {
|
|
138
|
+
accessList?: import('viem').AccessList;
|
|
139
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
140
|
+
chain?: import('viem').Chain | null;
|
|
141
|
+
dataSuffix?: `0x${string}`;
|
|
142
|
+
gas?: bigint;
|
|
143
|
+
gasPrice?: bigint;
|
|
144
|
+
maxFeePerGas?: bigint;
|
|
145
|
+
maxPriorityFeePerGas?: bigint;
|
|
146
|
+
nonce?: number;
|
|
147
|
+
value?: bigint;
|
|
148
|
+
}): Promise<`0x${string}`> {
|
|
149
|
+
if (!this.contract.write) {
|
|
150
|
+
throw new Error('Wallet client is required for write operations');
|
|
151
|
+
}
|
|
152
|
+
return this.contract.write.configureSwapRoute_mm([_destination] as const, options) as Promise<`0x${string}`>;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
162
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
163
|
+
* console.log('Would succeed:', result.result);
|
|
164
|
+
*/
|
|
165
|
+
get simulate() {
|
|
166
|
+
const contract = this.contract;
|
|
167
|
+
if (!contract.simulate) {
|
|
168
|
+
throw new Error('Public client is required for simulation');
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
/**
|
|
172
|
+
* Simulate configureSwapRoute_mm
|
|
173
|
+
* Returns gas estimate and result without sending transaction
|
|
174
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
175
|
+
*/
|
|
176
|
+
async configureSwapRoute_mm(_destination: `0x${string}`, options?: {
|
|
177
|
+
accessList?: import('viem').AccessList;
|
|
178
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
179
|
+
chain?: import('viem').Chain | null;
|
|
180
|
+
dataSuffix?: `0x${string}`;
|
|
181
|
+
gas?: bigint;
|
|
182
|
+
gasPrice?: bigint;
|
|
183
|
+
maxFeePerGas?: bigint;
|
|
184
|
+
maxPriorityFeePerGas?: bigint;
|
|
185
|
+
nonce?: number;
|
|
186
|
+
value?: bigint;
|
|
187
|
+
}): Promise<void> {
|
|
188
|
+
return contract.simulate.configureSwapRoute_mm([_destination] as const, options) as Promise<void>;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Watch contract events
|
|
195
|
+
*
|
|
196
|
+
* Note: This contract has no events, so watch returns an empty object.
|
|
197
|
+
*/
|
|
198
|
+
get watch() {
|
|
199
|
+
return {};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetaMaskSwapRouter_json = exports.MetaMaskSwapRouter_jsonAbi = void 0;
|
|
4
|
+
// Auto-generated exports for all contracts
|
|
5
|
+
var MetaMaskSwapRouter_json_1 = require("./MetaMaskSwapRouter_json");
|
|
6
|
+
Object.defineProperty(exports, "MetaMaskSwapRouter_jsonAbi", { enumerable: true, get: function () { return MetaMaskSwapRouter_json_1.MetaMaskSwapRouter_jsonAbi; } });
|
|
7
|
+
Object.defineProperty(exports, "MetaMaskSwapRouter_json", { enumerable: true, get: function () { return MetaMaskSwapRouter_json_1.MetaMaskSwapRouter_json; } });
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Auto-generated exports for all contracts
|
|
2
|
+
export { MetaMaskSwapRouter_jsonAbi, MetaMaskSwapRouter_json } from './MetaMaskSwapRouter_json';
|
|
3
|
+
export type { MetaMaskSwapRouter_jsonAbi as MetaMaskSwapRouter_jsonAbiType, MetaMaskSwapRouter_jsonContract } from './MetaMaskSwapRouter_json';
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './contracts';
|
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Auto-generated TypeScript type bindings
|
|
3
|
+
// This file exports all generated contract types
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./contracts"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gitmyabi/metamaskswaprouter",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Auto-generated TypeScript type bindings for MetaMaskSwapRouter (build etherscan-metamaskswaprouter-88cf071b-1784654778181, commit 101991e, branch etherscan)",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./index.js",
|
|
10
|
+
"require": "./index.js",
|
|
11
|
+
"types": "./index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./contracts": {
|
|
14
|
+
"import": "./contracts/index.js",
|
|
15
|
+
"require": "./contracts/index.js",
|
|
16
|
+
"types": "./contracts/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"index.js",
|
|
21
|
+
"index.d.ts",
|
|
22
|
+
"contracts"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"ethereum",
|
|
26
|
+
"smart-contracts",
|
|
27
|
+
"viem",
|
|
28
|
+
"wagmi",
|
|
29
|
+
"typescript",
|
|
30
|
+
"abi",
|
|
31
|
+
"ethers-v6"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"viem": "^2.0.0"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/etherscan/metamaskswaprouter"
|
|
40
|
+
},
|
|
41
|
+
"branch": "etherscan",
|
|
42
|
+
"shortHash": "101991e"
|
|
43
|
+
}
|