@lumiapassport/core 1.12.0 → 1.13.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 +177 -0
- package/dist/index.cjs +473 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +460 -8
- package/dist/index.js.map +1 -1
- package/dist/internal/error-tracking.cjs +1 -1
- package/dist/internal/error-tracking.js +1 -1
- package/dist/utils/index.cjs +466 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +803 -1
- package/dist/utils/index.d.ts +803 -1
- package/dist/utils/index.js +453 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -170,6 +170,183 @@ wallets.forEach(w => {
|
|
|
170
170
|
|
|
171
171
|
**See [Server Wallets Documentation](../../docs/SERVER_WALLETS.md) for complete guide.**
|
|
172
172
|
|
|
173
|
+
### Smart Contract Interactions
|
|
174
|
+
|
|
175
|
+
The SDK provides utilities for encoding smart contract calls for use with `sendUserOperation()`.
|
|
176
|
+
|
|
177
|
+
#### ERC20 Token Transfer
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import {
|
|
181
|
+
createServerWalletManager,
|
|
182
|
+
MemoryKeyshareStorage,
|
|
183
|
+
encodeERC20Transfer,
|
|
184
|
+
} from '@lumiapassport/core';
|
|
185
|
+
|
|
186
|
+
const manager = createServerWalletManager({
|
|
187
|
+
apiKey: process.env.LUMIA_PASSPORT_API_KEY!,
|
|
188
|
+
storage: new MemoryKeyshareStorage(),
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const wallet = await manager.getWallet('treasury_main');
|
|
192
|
+
|
|
193
|
+
// Encode ERC20 transfer call
|
|
194
|
+
const callData = await encodeERC20Transfer(
|
|
195
|
+
'0xRecipientAddress...',
|
|
196
|
+
1000n * 10n ** 18n // 1000 tokens (18 decimals)
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
// Send the transaction
|
|
200
|
+
const userOpHash = await wallet.sendUserOperation(
|
|
201
|
+
'0xTokenContractAddress...', // to = token contract
|
|
202
|
+
'0', // value = 0 (no native token)
|
|
203
|
+
callData, // encoded transfer call
|
|
204
|
+
'standard'
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
// Wait for confirmation
|
|
208
|
+
const receipt = await manager.waitForUserOperationReceipt(userOpHash);
|
|
209
|
+
console.log('Transaction hash:', receipt.transactionHash);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
#### ERC20 Approve + TransferFrom Pattern
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import { encodeERC20Approve } from '@lumiapassport/core';
|
|
216
|
+
|
|
217
|
+
// Step 1: Approve DEX router to spend tokens
|
|
218
|
+
const approveData = await encodeERC20Approve(
|
|
219
|
+
'0xDEXRouterAddress...',
|
|
220
|
+
2n ** 256n - 1n // MaxUint256 for unlimited approval
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
await wallet.sendUserOperation(
|
|
224
|
+
'0xTokenContractAddress...',
|
|
225
|
+
'0',
|
|
226
|
+
approveData,
|
|
227
|
+
'standard'
|
|
228
|
+
);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### Arbitrary Contract Call
|
|
232
|
+
|
|
233
|
+
For any smart contract method, use `encodeContractCall()`:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
import { encodeContractCall } from '@lumiapassport/core';
|
|
237
|
+
|
|
238
|
+
// Define ABI for the function you want to call
|
|
239
|
+
const stakingAbi = [
|
|
240
|
+
{
|
|
241
|
+
type: 'function',
|
|
242
|
+
name: 'stake',
|
|
243
|
+
stateMutability: 'nonpayable',
|
|
244
|
+
inputs: [
|
|
245
|
+
{ name: 'amount', type: 'uint256' },
|
|
246
|
+
{ name: 'lockPeriod', type: 'uint256' },
|
|
247
|
+
],
|
|
248
|
+
outputs: [],
|
|
249
|
+
},
|
|
250
|
+
] as const;
|
|
251
|
+
|
|
252
|
+
// Encode the call
|
|
253
|
+
const callData = await encodeContractCall(
|
|
254
|
+
stakingAbi,
|
|
255
|
+
'stake',
|
|
256
|
+
[1000n * 10n ** 18n, 30n * 24n * 60n * 60n] // amount, lock period in seconds
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
// Send transaction
|
|
260
|
+
await wallet.sendUserOperation(
|
|
261
|
+
'0xStakingContractAddress...',
|
|
262
|
+
'0',
|
|
263
|
+
callData,
|
|
264
|
+
'standard'
|
|
265
|
+
);
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
#### Payable Functions (Sending Native Token + Data)
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
import { encodeContractCall } from '@lumiapassport/core';
|
|
272
|
+
|
|
273
|
+
// Example: Wrap ETH to WETH
|
|
274
|
+
const wethAbi = [
|
|
275
|
+
{
|
|
276
|
+
type: 'function',
|
|
277
|
+
name: 'deposit',
|
|
278
|
+
stateMutability: 'payable',
|
|
279
|
+
inputs: [],
|
|
280
|
+
outputs: [],
|
|
281
|
+
},
|
|
282
|
+
] as const;
|
|
283
|
+
|
|
284
|
+
const callData = await encodeContractCall(wethAbi, 'deposit', []);
|
|
285
|
+
|
|
286
|
+
await wallet.sendUserOperation(
|
|
287
|
+
'0xWETHContractAddress...',
|
|
288
|
+
'1000000000000000000', // 1 ETH in wei
|
|
289
|
+
callData,
|
|
290
|
+
'standard'
|
|
291
|
+
);
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### NFT Transfers (ERC721 / ERC1155)
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
import {
|
|
298
|
+
encodeERC721TransferFrom,
|
|
299
|
+
encodeERC721SafeTransferFrom,
|
|
300
|
+
encodeERC1155SafeTransferFrom,
|
|
301
|
+
} from '@lumiapassport/core';
|
|
302
|
+
|
|
303
|
+
// ERC721 transfer
|
|
304
|
+
const nftData = await encodeERC721TransferFrom(
|
|
305
|
+
wallet.smartAccountAddress, // from
|
|
306
|
+
'0xRecipientAddress...', // to
|
|
307
|
+
123n // tokenId
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
await wallet.sendUserOperation('0xNFTContract...', '0', nftData, 'standard');
|
|
311
|
+
|
|
312
|
+
// ERC1155 transfer
|
|
313
|
+
const multiTokenData = await encodeERC1155SafeTransferFrom(
|
|
314
|
+
wallet.smartAccountAddress,
|
|
315
|
+
'0xRecipientAddress...',
|
|
316
|
+
1n, // tokenId
|
|
317
|
+
100n, // amount
|
|
318
|
+
'0x' // data
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
await wallet.sendUserOperation('0xERC1155Contract...', '0', multiTokenData, 'standard');
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
#### Available Encoding Helpers
|
|
325
|
+
|
|
326
|
+
| Function | Description |
|
|
327
|
+
|----------|-------------|
|
|
328
|
+
| `encodeContractCall(abi, functionName, args)` | Generic encoder for any contract |
|
|
329
|
+
| `encodeERC20Transfer(to, amount)` | ERC20 transfer |
|
|
330
|
+
| `encodeERC20Approve(spender, amount)` | ERC20 approve |
|
|
331
|
+
| `encodeERC20TransferFrom(from, to, amount)` | ERC20 transferFrom |
|
|
332
|
+
| `encodeERC721TransferFrom(from, to, tokenId)` | ERC721 transfer |
|
|
333
|
+
| `encodeERC721SafeTransferFrom(from, to, tokenId, data?)` | ERC721 safe transfer |
|
|
334
|
+
| `encodeERC721Approve(to, tokenId)` | ERC721 approve |
|
|
335
|
+
| `encodeERC721SetApprovalForAll(operator, approved)` | ERC721 approval for all |
|
|
336
|
+
| `encodeERC1155SafeTransferFrom(from, to, id, amount, data)` | ERC1155 transfer |
|
|
337
|
+
| `encodeERC1155SafeBatchTransferFrom(from, to, ids, amounts, data)` | ERC1155 batch transfer |
|
|
338
|
+
| `encodeERC1155SetApprovalForAll(operator, approved)` | ERC1155 approval for all |
|
|
339
|
+
|
|
340
|
+
#### Standard ABIs
|
|
341
|
+
|
|
342
|
+
The SDK exports standard ABIs for common token standards:
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
import { ERC20_ABI, ERC721_ABI, ERC1155_ABI } from '@lumiapassport/core';
|
|
346
|
+
|
|
347
|
+
// Use with viem directly or with encodeContractCall
|
|
348
|
+
```
|
|
349
|
+
|
|
173
350
|
## API
|
|
174
351
|
|
|
175
352
|
### Modules
|
package/dist/index.cjs
CHANGED
|
@@ -1543,11 +1543,11 @@ var server_wallet_send_userop_exports = {};
|
|
|
1543
1543
|
__export(server_wallet_send_userop_exports, {
|
|
1544
1544
|
sendUserOperationForServerWallet: () => sendUserOperationForServerWallet
|
|
1545
1545
|
});
|
|
1546
|
-
async function
|
|
1547
|
-
if (!
|
|
1548
|
-
|
|
1546
|
+
async function loadViem2() {
|
|
1547
|
+
if (!viemModule2) {
|
|
1548
|
+
viemModule2 = await import('viem');
|
|
1549
1549
|
}
|
|
1550
|
-
return
|
|
1550
|
+
return viemModule2;
|
|
1551
1551
|
}
|
|
1552
1552
|
async function loadBundler() {
|
|
1553
1553
|
if (!bundlerModule) {
|
|
@@ -1571,7 +1571,7 @@ async function sendUserOperationForServerWallet(params) {
|
|
|
1571
1571
|
maxVerificationGasLimit,
|
|
1572
1572
|
debug = false
|
|
1573
1573
|
} = params;
|
|
1574
|
-
const viem = await
|
|
1574
|
+
const viem = await loadViem2();
|
|
1575
1575
|
const bundler = await loadBundler();
|
|
1576
1576
|
const { encodeFunctionData } = viem;
|
|
1577
1577
|
const {
|
|
@@ -1890,10 +1890,10 @@ function normalizeSignature(signature) {
|
|
|
1890
1890
|
const canonicalVHex = canonicalV.toString(16).padStart(2, "0");
|
|
1891
1891
|
return `0x${r}${canonicalSHex}${canonicalVHex}`;
|
|
1892
1892
|
}
|
|
1893
|
-
var
|
|
1893
|
+
var viemModule2, bundlerModule, DEFAULT_MAX_CALL_GAS_LIMIT, MAX_BUNDLER_VERIFICATION_GAS, PAYMASTER_VERIFICATION_GAS, executeAbi, factoryAbi;
|
|
1894
1894
|
var init_server_wallet_send_userop = __esm({
|
|
1895
1895
|
"src/clients/server-wallet-send-userop.ts"() {
|
|
1896
|
-
|
|
1896
|
+
viemModule2 = null;
|
|
1897
1897
|
bundlerModule = null;
|
|
1898
1898
|
DEFAULT_MAX_CALL_GAS_LIMIT = 0x4C4B40n;
|
|
1899
1899
|
MAX_BUNDLER_VERIFICATION_GAS = 5000000n;
|
|
@@ -1996,6 +1996,458 @@ init_project_id();
|
|
|
1996
1996
|
init_env();
|
|
1997
1997
|
init_helpers();
|
|
1998
1998
|
|
|
1999
|
+
// src/utils/abis.ts
|
|
2000
|
+
var ERC20_ABI = [
|
|
2001
|
+
// Read functions
|
|
2002
|
+
{
|
|
2003
|
+
type: "function",
|
|
2004
|
+
name: "name",
|
|
2005
|
+
stateMutability: "view",
|
|
2006
|
+
inputs: [],
|
|
2007
|
+
outputs: [{ name: "", type: "string" }]
|
|
2008
|
+
},
|
|
2009
|
+
{
|
|
2010
|
+
type: "function",
|
|
2011
|
+
name: "symbol",
|
|
2012
|
+
stateMutability: "view",
|
|
2013
|
+
inputs: [],
|
|
2014
|
+
outputs: [{ name: "", type: "string" }]
|
|
2015
|
+
},
|
|
2016
|
+
{
|
|
2017
|
+
type: "function",
|
|
2018
|
+
name: "decimals",
|
|
2019
|
+
stateMutability: "view",
|
|
2020
|
+
inputs: [],
|
|
2021
|
+
outputs: [{ name: "", type: "uint8" }]
|
|
2022
|
+
},
|
|
2023
|
+
{
|
|
2024
|
+
type: "function",
|
|
2025
|
+
name: "totalSupply",
|
|
2026
|
+
stateMutability: "view",
|
|
2027
|
+
inputs: [],
|
|
2028
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
2029
|
+
},
|
|
2030
|
+
{
|
|
2031
|
+
type: "function",
|
|
2032
|
+
name: "balanceOf",
|
|
2033
|
+
stateMutability: "view",
|
|
2034
|
+
inputs: [{ name: "account", type: "address" }],
|
|
2035
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
2036
|
+
},
|
|
2037
|
+
{
|
|
2038
|
+
type: "function",
|
|
2039
|
+
name: "allowance",
|
|
2040
|
+
stateMutability: "view",
|
|
2041
|
+
inputs: [
|
|
2042
|
+
{ name: "owner", type: "address" },
|
|
2043
|
+
{ name: "spender", type: "address" }
|
|
2044
|
+
],
|
|
2045
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
2046
|
+
},
|
|
2047
|
+
// Write functions
|
|
2048
|
+
{
|
|
2049
|
+
type: "function",
|
|
2050
|
+
name: "transfer",
|
|
2051
|
+
stateMutability: "nonpayable",
|
|
2052
|
+
inputs: [
|
|
2053
|
+
{ name: "to", type: "address" },
|
|
2054
|
+
{ name: "amount", type: "uint256" }
|
|
2055
|
+
],
|
|
2056
|
+
outputs: [{ name: "", type: "bool" }]
|
|
2057
|
+
},
|
|
2058
|
+
{
|
|
2059
|
+
type: "function",
|
|
2060
|
+
name: "approve",
|
|
2061
|
+
stateMutability: "nonpayable",
|
|
2062
|
+
inputs: [
|
|
2063
|
+
{ name: "spender", type: "address" },
|
|
2064
|
+
{ name: "amount", type: "uint256" }
|
|
2065
|
+
],
|
|
2066
|
+
outputs: [{ name: "", type: "bool" }]
|
|
2067
|
+
},
|
|
2068
|
+
{
|
|
2069
|
+
type: "function",
|
|
2070
|
+
name: "transferFrom",
|
|
2071
|
+
stateMutability: "nonpayable",
|
|
2072
|
+
inputs: [
|
|
2073
|
+
{ name: "from", type: "address" },
|
|
2074
|
+
{ name: "to", type: "address" },
|
|
2075
|
+
{ name: "amount", type: "uint256" }
|
|
2076
|
+
],
|
|
2077
|
+
outputs: [{ name: "", type: "bool" }]
|
|
2078
|
+
},
|
|
2079
|
+
// Events
|
|
2080
|
+
{
|
|
2081
|
+
type: "event",
|
|
2082
|
+
name: "Transfer",
|
|
2083
|
+
inputs: [
|
|
2084
|
+
{ name: "from", type: "address", indexed: true },
|
|
2085
|
+
{ name: "to", type: "address", indexed: true },
|
|
2086
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
2087
|
+
]
|
|
2088
|
+
},
|
|
2089
|
+
{
|
|
2090
|
+
type: "event",
|
|
2091
|
+
name: "Approval",
|
|
2092
|
+
inputs: [
|
|
2093
|
+
{ name: "owner", type: "address", indexed: true },
|
|
2094
|
+
{ name: "spender", type: "address", indexed: true },
|
|
2095
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
2096
|
+
]
|
|
2097
|
+
}
|
|
2098
|
+
];
|
|
2099
|
+
var ERC721_ABI = [
|
|
2100
|
+
// Read functions
|
|
2101
|
+
{
|
|
2102
|
+
type: "function",
|
|
2103
|
+
name: "name",
|
|
2104
|
+
stateMutability: "view",
|
|
2105
|
+
inputs: [],
|
|
2106
|
+
outputs: [{ name: "", type: "string" }]
|
|
2107
|
+
},
|
|
2108
|
+
{
|
|
2109
|
+
type: "function",
|
|
2110
|
+
name: "symbol",
|
|
2111
|
+
stateMutability: "view",
|
|
2112
|
+
inputs: [],
|
|
2113
|
+
outputs: [{ name: "", type: "string" }]
|
|
2114
|
+
},
|
|
2115
|
+
{
|
|
2116
|
+
type: "function",
|
|
2117
|
+
name: "tokenURI",
|
|
2118
|
+
stateMutability: "view",
|
|
2119
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
2120
|
+
outputs: [{ name: "", type: "string" }]
|
|
2121
|
+
},
|
|
2122
|
+
{
|
|
2123
|
+
type: "function",
|
|
2124
|
+
name: "balanceOf",
|
|
2125
|
+
stateMutability: "view",
|
|
2126
|
+
inputs: [{ name: "owner", type: "address" }],
|
|
2127
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
2128
|
+
},
|
|
2129
|
+
{
|
|
2130
|
+
type: "function",
|
|
2131
|
+
name: "ownerOf",
|
|
2132
|
+
stateMutability: "view",
|
|
2133
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
2134
|
+
outputs: [{ name: "", type: "address" }]
|
|
2135
|
+
},
|
|
2136
|
+
{
|
|
2137
|
+
type: "function",
|
|
2138
|
+
name: "getApproved",
|
|
2139
|
+
stateMutability: "view",
|
|
2140
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
2141
|
+
outputs: [{ name: "", type: "address" }]
|
|
2142
|
+
},
|
|
2143
|
+
{
|
|
2144
|
+
type: "function",
|
|
2145
|
+
name: "isApprovedForAll",
|
|
2146
|
+
stateMutability: "view",
|
|
2147
|
+
inputs: [
|
|
2148
|
+
{ name: "owner", type: "address" },
|
|
2149
|
+
{ name: "operator", type: "address" }
|
|
2150
|
+
],
|
|
2151
|
+
outputs: [{ name: "", type: "bool" }]
|
|
2152
|
+
},
|
|
2153
|
+
// Write functions
|
|
2154
|
+
{
|
|
2155
|
+
type: "function",
|
|
2156
|
+
name: "approve",
|
|
2157
|
+
stateMutability: "nonpayable",
|
|
2158
|
+
inputs: [
|
|
2159
|
+
{ name: "to", type: "address" },
|
|
2160
|
+
{ name: "tokenId", type: "uint256" }
|
|
2161
|
+
],
|
|
2162
|
+
outputs: []
|
|
2163
|
+
},
|
|
2164
|
+
{
|
|
2165
|
+
type: "function",
|
|
2166
|
+
name: "setApprovalForAll",
|
|
2167
|
+
stateMutability: "nonpayable",
|
|
2168
|
+
inputs: [
|
|
2169
|
+
{ name: "operator", type: "address" },
|
|
2170
|
+
{ name: "approved", type: "bool" }
|
|
2171
|
+
],
|
|
2172
|
+
outputs: []
|
|
2173
|
+
},
|
|
2174
|
+
{
|
|
2175
|
+
type: "function",
|
|
2176
|
+
name: "transferFrom",
|
|
2177
|
+
stateMutability: "nonpayable",
|
|
2178
|
+
inputs: [
|
|
2179
|
+
{ name: "from", type: "address" },
|
|
2180
|
+
{ name: "to", type: "address" },
|
|
2181
|
+
{ name: "tokenId", type: "uint256" }
|
|
2182
|
+
],
|
|
2183
|
+
outputs: []
|
|
2184
|
+
},
|
|
2185
|
+
{
|
|
2186
|
+
type: "function",
|
|
2187
|
+
name: "safeTransferFrom",
|
|
2188
|
+
stateMutability: "nonpayable",
|
|
2189
|
+
inputs: [
|
|
2190
|
+
{ name: "from", type: "address" },
|
|
2191
|
+
{ name: "to", type: "address" },
|
|
2192
|
+
{ name: "tokenId", type: "uint256" }
|
|
2193
|
+
],
|
|
2194
|
+
outputs: []
|
|
2195
|
+
},
|
|
2196
|
+
{
|
|
2197
|
+
type: "function",
|
|
2198
|
+
name: "safeTransferFrom",
|
|
2199
|
+
stateMutability: "nonpayable",
|
|
2200
|
+
inputs: [
|
|
2201
|
+
{ name: "from", type: "address" },
|
|
2202
|
+
{ name: "to", type: "address" },
|
|
2203
|
+
{ name: "tokenId", type: "uint256" },
|
|
2204
|
+
{ name: "data", type: "bytes" }
|
|
2205
|
+
],
|
|
2206
|
+
outputs: []
|
|
2207
|
+
},
|
|
2208
|
+
// Events
|
|
2209
|
+
{
|
|
2210
|
+
type: "event",
|
|
2211
|
+
name: "Transfer",
|
|
2212
|
+
inputs: [
|
|
2213
|
+
{ name: "from", type: "address", indexed: true },
|
|
2214
|
+
{ name: "to", type: "address", indexed: true },
|
|
2215
|
+
{ name: "tokenId", type: "uint256", indexed: true }
|
|
2216
|
+
]
|
|
2217
|
+
},
|
|
2218
|
+
{
|
|
2219
|
+
type: "event",
|
|
2220
|
+
name: "Approval",
|
|
2221
|
+
inputs: [
|
|
2222
|
+
{ name: "owner", type: "address", indexed: true },
|
|
2223
|
+
{ name: "approved", type: "address", indexed: true },
|
|
2224
|
+
{ name: "tokenId", type: "uint256", indexed: true }
|
|
2225
|
+
]
|
|
2226
|
+
},
|
|
2227
|
+
{
|
|
2228
|
+
type: "event",
|
|
2229
|
+
name: "ApprovalForAll",
|
|
2230
|
+
inputs: [
|
|
2231
|
+
{ name: "owner", type: "address", indexed: true },
|
|
2232
|
+
{ name: "operator", type: "address", indexed: true },
|
|
2233
|
+
{ name: "approved", type: "bool", indexed: false }
|
|
2234
|
+
]
|
|
2235
|
+
}
|
|
2236
|
+
];
|
|
2237
|
+
var ERC1155_ABI = [
|
|
2238
|
+
// Read functions
|
|
2239
|
+
{
|
|
2240
|
+
type: "function",
|
|
2241
|
+
name: "uri",
|
|
2242
|
+
stateMutability: "view",
|
|
2243
|
+
inputs: [{ name: "id", type: "uint256" }],
|
|
2244
|
+
outputs: [{ name: "", type: "string" }]
|
|
2245
|
+
},
|
|
2246
|
+
{
|
|
2247
|
+
type: "function",
|
|
2248
|
+
name: "balanceOf",
|
|
2249
|
+
stateMutability: "view",
|
|
2250
|
+
inputs: [
|
|
2251
|
+
{ name: "account", type: "address" },
|
|
2252
|
+
{ name: "id", type: "uint256" }
|
|
2253
|
+
],
|
|
2254
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
2255
|
+
},
|
|
2256
|
+
{
|
|
2257
|
+
type: "function",
|
|
2258
|
+
name: "balanceOfBatch",
|
|
2259
|
+
stateMutability: "view",
|
|
2260
|
+
inputs: [
|
|
2261
|
+
{ name: "accounts", type: "address[]" },
|
|
2262
|
+
{ name: "ids", type: "uint256[]" }
|
|
2263
|
+
],
|
|
2264
|
+
outputs: [{ name: "", type: "uint256[]" }]
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
type: "function",
|
|
2268
|
+
name: "isApprovedForAll",
|
|
2269
|
+
stateMutability: "view",
|
|
2270
|
+
inputs: [
|
|
2271
|
+
{ name: "account", type: "address" },
|
|
2272
|
+
{ name: "operator", type: "address" }
|
|
2273
|
+
],
|
|
2274
|
+
outputs: [{ name: "", type: "bool" }]
|
|
2275
|
+
},
|
|
2276
|
+
// Write functions
|
|
2277
|
+
{
|
|
2278
|
+
type: "function",
|
|
2279
|
+
name: "setApprovalForAll",
|
|
2280
|
+
stateMutability: "nonpayable",
|
|
2281
|
+
inputs: [
|
|
2282
|
+
{ name: "operator", type: "address" },
|
|
2283
|
+
{ name: "approved", type: "bool" }
|
|
2284
|
+
],
|
|
2285
|
+
outputs: []
|
|
2286
|
+
},
|
|
2287
|
+
{
|
|
2288
|
+
type: "function",
|
|
2289
|
+
name: "safeTransferFrom",
|
|
2290
|
+
stateMutability: "nonpayable",
|
|
2291
|
+
inputs: [
|
|
2292
|
+
{ name: "from", type: "address" },
|
|
2293
|
+
{ name: "to", type: "address" },
|
|
2294
|
+
{ name: "id", type: "uint256" },
|
|
2295
|
+
{ name: "amount", type: "uint256" },
|
|
2296
|
+
{ name: "data", type: "bytes" }
|
|
2297
|
+
],
|
|
2298
|
+
outputs: []
|
|
2299
|
+
},
|
|
2300
|
+
{
|
|
2301
|
+
type: "function",
|
|
2302
|
+
name: "safeBatchTransferFrom",
|
|
2303
|
+
stateMutability: "nonpayable",
|
|
2304
|
+
inputs: [
|
|
2305
|
+
{ name: "from", type: "address" },
|
|
2306
|
+
{ name: "to", type: "address" },
|
|
2307
|
+
{ name: "ids", type: "uint256[]" },
|
|
2308
|
+
{ name: "amounts", type: "uint256[]" },
|
|
2309
|
+
{ name: "data", type: "bytes" }
|
|
2310
|
+
],
|
|
2311
|
+
outputs: []
|
|
2312
|
+
},
|
|
2313
|
+
// Events
|
|
2314
|
+
{
|
|
2315
|
+
type: "event",
|
|
2316
|
+
name: "TransferSingle",
|
|
2317
|
+
inputs: [
|
|
2318
|
+
{ name: "operator", type: "address", indexed: true },
|
|
2319
|
+
{ name: "from", type: "address", indexed: true },
|
|
2320
|
+
{ name: "to", type: "address", indexed: true },
|
|
2321
|
+
{ name: "id", type: "uint256", indexed: false },
|
|
2322
|
+
{ name: "value", type: "uint256", indexed: false }
|
|
2323
|
+
]
|
|
2324
|
+
},
|
|
2325
|
+
{
|
|
2326
|
+
type: "event",
|
|
2327
|
+
name: "TransferBatch",
|
|
2328
|
+
inputs: [
|
|
2329
|
+
{ name: "operator", type: "address", indexed: true },
|
|
2330
|
+
{ name: "from", type: "address", indexed: true },
|
|
2331
|
+
{ name: "to", type: "address", indexed: true },
|
|
2332
|
+
{ name: "ids", type: "uint256[]", indexed: false },
|
|
2333
|
+
{ name: "values", type: "uint256[]", indexed: false }
|
|
2334
|
+
]
|
|
2335
|
+
},
|
|
2336
|
+
{
|
|
2337
|
+
type: "event",
|
|
2338
|
+
name: "ApprovalForAll",
|
|
2339
|
+
inputs: [
|
|
2340
|
+
{ name: "account", type: "address", indexed: true },
|
|
2341
|
+
{ name: "operator", type: "address", indexed: true },
|
|
2342
|
+
{ name: "approved", type: "bool", indexed: false }
|
|
2343
|
+
]
|
|
2344
|
+
}
|
|
2345
|
+
];
|
|
2346
|
+
|
|
2347
|
+
// src/utils/contract-encoding.ts
|
|
2348
|
+
var viemModule = null;
|
|
2349
|
+
async function loadViem() {
|
|
2350
|
+
if (!viemModule) {
|
|
2351
|
+
viemModule = await import('viem');
|
|
2352
|
+
}
|
|
2353
|
+
return viemModule;
|
|
2354
|
+
}
|
|
2355
|
+
async function encodeContractCall(abi, functionName, args) {
|
|
2356
|
+
const { encodeFunctionData } = await loadViem();
|
|
2357
|
+
return encodeFunctionData({
|
|
2358
|
+
abi,
|
|
2359
|
+
functionName,
|
|
2360
|
+
args
|
|
2361
|
+
});
|
|
2362
|
+
}
|
|
2363
|
+
async function encodeERC20Transfer(to, amount) {
|
|
2364
|
+
const { encodeFunctionData } = await loadViem();
|
|
2365
|
+
return encodeFunctionData({
|
|
2366
|
+
abi: ERC20_ABI,
|
|
2367
|
+
functionName: "transfer",
|
|
2368
|
+
args: [to, amount]
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
async function encodeERC20Approve(spender, amount) {
|
|
2372
|
+
const { encodeFunctionData } = await loadViem();
|
|
2373
|
+
return encodeFunctionData({
|
|
2374
|
+
abi: ERC20_ABI,
|
|
2375
|
+
functionName: "approve",
|
|
2376
|
+
args: [spender, amount]
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
async function encodeERC20TransferFrom(from, to, amount) {
|
|
2380
|
+
const { encodeFunctionData } = await loadViem();
|
|
2381
|
+
return encodeFunctionData({
|
|
2382
|
+
abi: ERC20_ABI,
|
|
2383
|
+
functionName: "transferFrom",
|
|
2384
|
+
args: [from, to, amount]
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
async function encodeERC721TransferFrom(from, to, tokenId) {
|
|
2388
|
+
const { encodeFunctionData } = await loadViem();
|
|
2389
|
+
return encodeFunctionData({
|
|
2390
|
+
abi: ERC721_ABI,
|
|
2391
|
+
functionName: "transferFrom",
|
|
2392
|
+
args: [from, to, tokenId]
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
async function encodeERC721SafeTransferFrom(from, to, tokenId, data) {
|
|
2396
|
+
const { encodeFunctionData } = await loadViem();
|
|
2397
|
+
if (data) {
|
|
2398
|
+
return encodeFunctionData({
|
|
2399
|
+
abi: ERC721_ABI,
|
|
2400
|
+
functionName: "safeTransferFrom",
|
|
2401
|
+
args: [from, to, tokenId, data]
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
return encodeFunctionData({
|
|
2405
|
+
abi: ERC721_ABI,
|
|
2406
|
+
functionName: "safeTransferFrom",
|
|
2407
|
+
args: [from, to, tokenId]
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
async function encodeERC721Approve(to, tokenId) {
|
|
2411
|
+
const { encodeFunctionData } = await loadViem();
|
|
2412
|
+
return encodeFunctionData({
|
|
2413
|
+
abi: ERC721_ABI,
|
|
2414
|
+
functionName: "approve",
|
|
2415
|
+
args: [to, tokenId]
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
async function encodeERC721SetApprovalForAll(operator, approved) {
|
|
2419
|
+
const { encodeFunctionData } = await loadViem();
|
|
2420
|
+
return encodeFunctionData({
|
|
2421
|
+
abi: ERC721_ABI,
|
|
2422
|
+
functionName: "setApprovalForAll",
|
|
2423
|
+
args: [operator, approved]
|
|
2424
|
+
});
|
|
2425
|
+
}
|
|
2426
|
+
async function encodeERC1155SafeTransferFrom(from, to, id, amount, data = "0x") {
|
|
2427
|
+
const { encodeFunctionData } = await loadViem();
|
|
2428
|
+
return encodeFunctionData({
|
|
2429
|
+
abi: ERC1155_ABI,
|
|
2430
|
+
functionName: "safeTransferFrom",
|
|
2431
|
+
args: [from, to, id, amount, data]
|
|
2432
|
+
});
|
|
2433
|
+
}
|
|
2434
|
+
async function encodeERC1155SafeBatchTransferFrom(from, to, ids, amounts, data = "0x") {
|
|
2435
|
+
const { encodeFunctionData } = await loadViem();
|
|
2436
|
+
return encodeFunctionData({
|
|
2437
|
+
abi: ERC1155_ABI,
|
|
2438
|
+
functionName: "safeBatchTransferFrom",
|
|
2439
|
+
args: [from, to, ids, amounts, data]
|
|
2440
|
+
});
|
|
2441
|
+
}
|
|
2442
|
+
async function encodeERC1155SetApprovalForAll(operator, approved) {
|
|
2443
|
+
const { encodeFunctionData } = await loadViem();
|
|
2444
|
+
return encodeFunctionData({
|
|
2445
|
+
abi: ERC1155_ABI,
|
|
2446
|
+
functionName: "setApprovalForAll",
|
|
2447
|
+
args: [operator, approved]
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
|
|
1999
2451
|
// src/index.ts
|
|
2000
2452
|
init_bundler();
|
|
2001
2453
|
|
|
@@ -3150,6 +3602,9 @@ var VERSION = "0.1.0";
|
|
|
3150
3602
|
|
|
3151
3603
|
exports.BlockscoutApiError = BlockscoutApiError;
|
|
3152
3604
|
exports.BlockscoutClient = BlockscoutClient;
|
|
3605
|
+
exports.ERC1155_ABI = ERC1155_ABI;
|
|
3606
|
+
exports.ERC20_ABI = ERC20_ABI;
|
|
3607
|
+
exports.ERC721_ABI = ERC721_ABI;
|
|
3153
3608
|
exports.MemoryKeyshareStorage = MemoryKeyshareStorage;
|
|
3154
3609
|
exports.ServerWalletClient = ServerWalletClient;
|
|
3155
3610
|
exports.ServerWalletManager = ServerWalletManager;
|
|
@@ -3178,6 +3633,17 @@ exports.createServerWalletClient = createServerWalletClient;
|
|
|
3178
3633
|
exports.createServerWalletManager = createServerWalletManager;
|
|
3179
3634
|
exports.createUserOperationV06WithDynamicFees = createUserOperationV06WithDynamicFees;
|
|
3180
3635
|
exports.createUserOperationWithDynamicFees = createUserOperationWithDynamicFees;
|
|
3636
|
+
exports.encodeContractCall = encodeContractCall;
|
|
3637
|
+
exports.encodeERC1155SafeBatchTransferFrom = encodeERC1155SafeBatchTransferFrom;
|
|
3638
|
+
exports.encodeERC1155SafeTransferFrom = encodeERC1155SafeTransferFrom;
|
|
3639
|
+
exports.encodeERC1155SetApprovalForAll = encodeERC1155SetApprovalForAll;
|
|
3640
|
+
exports.encodeERC20Approve = encodeERC20Approve;
|
|
3641
|
+
exports.encodeERC20Transfer = encodeERC20Transfer;
|
|
3642
|
+
exports.encodeERC20TransferFrom = encodeERC20TransferFrom;
|
|
3643
|
+
exports.encodeERC721Approve = encodeERC721Approve;
|
|
3644
|
+
exports.encodeERC721SafeTransferFrom = encodeERC721SafeTransferFrom;
|
|
3645
|
+
exports.encodeERC721SetApprovalForAll = encodeERC721SetApprovalForAll;
|
|
3646
|
+
exports.encodeERC721TransferFrom = encodeERC721TransferFrom;
|
|
3181
3647
|
exports.ensureValidToken = ensureValidToken;
|
|
3182
3648
|
exports.estimateUserOperationGas = estimateUserOperationGas;
|
|
3183
3649
|
exports.estimateUserOperationGasWithDynamicFees = estimateUserOperationGasWithDynamicFees;
|