near-safe 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/lib/bundler.d.ts +12 -0
- package/dist/cjs/lib/near.d.ts +3 -0
- package/dist/cjs/lib/safe.d.ts +24 -0
- package/dist/cjs/tx-manager.d.ts +39 -0
- package/dist/cjs/types.d.ts +85 -0
- package/dist/cjs/util.d.ts +8 -0
- package/package.json +9 -1
@@ -0,0 +1,12 @@
|
|
1
|
+
import { ethers } from "ethers";
|
2
|
+
import { GasPrices, PaymasterData, UnsignedUserOperation, UserOperation, UserOperationReceipt } from "../types";
|
3
|
+
export declare class Erc4337Bundler {
|
4
|
+
provider: ethers.JsonRpcProvider;
|
5
|
+
entryPointAddress: string;
|
6
|
+
constructor(bundlerUrl: string, entryPointAddress: string);
|
7
|
+
getPaymasterData(rawUserOp: UnsignedUserOperation, usePaymaster: boolean, safeNotDeployed: boolean): Promise<PaymasterData>;
|
8
|
+
sendUserOperation(userOp: UserOperation): Promise<string>;
|
9
|
+
getGasPrice(): Promise<GasPrices>;
|
10
|
+
_getUserOpReceiptInner(userOpHash: string): Promise<UserOperationReceipt | null>;
|
11
|
+
getUserOpReceipt(userOpHash: string): Promise<UserOperationReceipt>;
|
12
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { ethers } from "ethers";
|
2
|
+
import { GasPrice, PaymasterData, UnsignedUserOperation, UserOperation } from "../types";
|
3
|
+
import { MetaTransaction } from "ethers-multisend";
|
4
|
+
/**
|
5
|
+
* All contracts used in account creation & execution
|
6
|
+
*/
|
7
|
+
export declare class ContractSuite {
|
8
|
+
provider: ethers.JsonRpcProvider;
|
9
|
+
singleton: ethers.Contract;
|
10
|
+
proxyFactory: ethers.Contract;
|
11
|
+
m4337: ethers.Contract;
|
12
|
+
moduleSetup: ethers.Contract;
|
13
|
+
entryPoint: ethers.Contract;
|
14
|
+
constructor(provider: ethers.JsonRpcProvider, singleton: ethers.Contract, proxyFactory: ethers.Contract, m4337: ethers.Contract, moduleSetup: ethers.Contract, entryPoint: ethers.Contract);
|
15
|
+
static init(provider: ethers.JsonRpcProvider): Promise<ContractSuite>;
|
16
|
+
addressForSetup(setup: ethers.BytesLike, saltNonce?: string): Promise<string>;
|
17
|
+
getSetup(owners: string[]): Promise<string>;
|
18
|
+
getOpHash(unsignedUserOp: UserOperation, paymasterData: PaymasterData): Promise<string>;
|
19
|
+
factoryDataForSetup(safeNotDeployed: boolean, setup: string, safeSaltNonce: string): {
|
20
|
+
factory?: ethers.AddressLike;
|
21
|
+
factoryData?: string;
|
22
|
+
};
|
23
|
+
buildUserOp(txData: MetaTransaction, safeAddress: ethers.AddressLike, feeData: GasPrice, setup: string, safeNotDeployed: boolean, safeSaltNonce: string): Promise<UnsignedUserOperation>;
|
24
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { ethers } from "ethers";
|
2
|
+
import { NearEthAdapter } from "near-ca";
|
3
|
+
import { Erc4337Bundler } from "./lib/bundler";
|
4
|
+
import { UserOperation, UserOperationReceipt, UserOptions } from "./types";
|
5
|
+
import { MetaTransaction } from "ethers-multisend";
|
6
|
+
import { ContractSuite } from "./lib/safe";
|
7
|
+
import { Account } from "near-api-js";
|
8
|
+
export declare class TransactionManager {
|
9
|
+
readonly provider: ethers.JsonRpcProvider;
|
10
|
+
readonly nearAdapter: NearEthAdapter;
|
11
|
+
private safePack;
|
12
|
+
private bundler;
|
13
|
+
private setup;
|
14
|
+
readonly safeAddress: string;
|
15
|
+
private safeSaltNonce;
|
16
|
+
private _safeNotDeployed;
|
17
|
+
constructor(provider: ethers.JsonRpcProvider, nearAdapter: NearEthAdapter, safePack: ContractSuite, bundler: Erc4337Bundler, setup: string, safeAddress: string, safeSaltNonce: string, safeNotDeployed: boolean);
|
18
|
+
static create(config: {
|
19
|
+
ethRpc: string;
|
20
|
+
erc4337BundlerUrl: string;
|
21
|
+
nearAccount: Account;
|
22
|
+
mpcContractId: string;
|
23
|
+
safeSaltNonce?: string;
|
24
|
+
}): Promise<TransactionManager>;
|
25
|
+
get safeNotDeployed(): boolean;
|
26
|
+
get nearEOA(): `0x${string}`;
|
27
|
+
getSafeBalance(): Promise<bigint>;
|
28
|
+
buildTransaction(args: {
|
29
|
+
transactions: MetaTransaction[];
|
30
|
+
options: UserOptions;
|
31
|
+
}): Promise<{
|
32
|
+
safeOpHash: string;
|
33
|
+
unsignedUserOp: UserOperation;
|
34
|
+
}>;
|
35
|
+
signTransaction(safeOpHash: string): Promise<string>;
|
36
|
+
executeTransaction(userOp: UserOperation): Promise<UserOperationReceipt>;
|
37
|
+
addOwnerTx(address: string): MetaTransaction;
|
38
|
+
safeSufficientlyFunded(transactions: MetaTransaction[], gasCost: bigint): Promise<boolean>;
|
39
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import { ethers } from "ethers";
|
2
|
+
export interface UnsignedUserOperation {
|
3
|
+
sender: ethers.AddressLike;
|
4
|
+
nonce: string;
|
5
|
+
factory?: ethers.AddressLike;
|
6
|
+
factoryData?: ethers.BytesLike;
|
7
|
+
callData: string;
|
8
|
+
maxPriorityFeePerGas: string;
|
9
|
+
maxFeePerGas: string;
|
10
|
+
}
|
11
|
+
/**
|
12
|
+
* Supported Representation of UserOperation for EntryPoint v0.7
|
13
|
+
*/
|
14
|
+
export interface UserOperation extends UnsignedUserOperation {
|
15
|
+
verificationGasLimit: string;
|
16
|
+
callGasLimit: string;
|
17
|
+
preVerificationGas: string;
|
18
|
+
signature?: string;
|
19
|
+
}
|
20
|
+
export interface PaymasterData {
|
21
|
+
paymaster?: string;
|
22
|
+
paymasterData?: string;
|
23
|
+
paymasterVerificationGasLimit?: string;
|
24
|
+
paymasterPostOpGasLimit?: string;
|
25
|
+
verificationGasLimit: string;
|
26
|
+
callGasLimit: string;
|
27
|
+
preVerificationGas: string;
|
28
|
+
}
|
29
|
+
export interface UserOptions {
|
30
|
+
usePaymaster: boolean;
|
31
|
+
safeSaltNonce: string;
|
32
|
+
mpcContractId: string;
|
33
|
+
recoveryAddress?: string;
|
34
|
+
}
|
35
|
+
export type TStatus = "success" | "reverted";
|
36
|
+
export type Address = ethers.AddressLike;
|
37
|
+
export type Hex = `0x${string}`;
|
38
|
+
export type Hash = `0x${string}`;
|
39
|
+
interface Log {
|
40
|
+
logIndex: string;
|
41
|
+
transactionIndex: string;
|
42
|
+
transactionHash: string;
|
43
|
+
blockHash: string;
|
44
|
+
blockNumber: string;
|
45
|
+
address: string;
|
46
|
+
data: string;
|
47
|
+
topics: string[];
|
48
|
+
}
|
49
|
+
interface Receipt {
|
50
|
+
transactionHash: Hex;
|
51
|
+
transactionIndex: bigint;
|
52
|
+
blockHash: Hash;
|
53
|
+
blockNumber: bigint;
|
54
|
+
from: Address;
|
55
|
+
to: Address | null;
|
56
|
+
cumulativeGasUsed: bigint;
|
57
|
+
status: TStatus;
|
58
|
+
gasUsed: bigint;
|
59
|
+
contractAddress: Address | null;
|
60
|
+
logsBloom: Hex;
|
61
|
+
effectiveGasPrice: bigint;
|
62
|
+
}
|
63
|
+
export type UserOperationReceipt = {
|
64
|
+
userOpHash: Hash;
|
65
|
+
entryPoint: Address;
|
66
|
+
sender: Address;
|
67
|
+
nonce: bigint;
|
68
|
+
paymaster?: Address;
|
69
|
+
actualGasUsed: bigint;
|
70
|
+
actualGasCost: bigint;
|
71
|
+
success: boolean;
|
72
|
+
reason?: string;
|
73
|
+
receipt: Receipt;
|
74
|
+
logs: Log[];
|
75
|
+
};
|
76
|
+
export interface GasPrices {
|
77
|
+
slow: GasPrice;
|
78
|
+
standard: GasPrice;
|
79
|
+
fast: GasPrice;
|
80
|
+
}
|
81
|
+
export interface GasPrice {
|
82
|
+
maxFeePerGas: Hex;
|
83
|
+
maxPriorityFeePerGas: Hex;
|
84
|
+
}
|
85
|
+
export {};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { ethers } from "ethers";
|
2
|
+
import { PaymasterData } from "./types";
|
3
|
+
import { MetaTransaction } from "ethers-multisend";
|
4
|
+
export declare const PLACEHOLDER_SIG: string;
|
5
|
+
export declare const packGas: (hi: ethers.BigNumberish, lo: ethers.BigNumberish) => string;
|
6
|
+
export declare function packSignature(signature: string, validFrom?: number, validTo?: number): string;
|
7
|
+
export declare function packPaymasterData(data: PaymasterData): string;
|
8
|
+
export declare function containsValue(transactions: MetaTransaction[]): boolean;
|
package/package.json
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "near-safe",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.1",
|
4
4
|
"license": "MIT",
|
5
|
+
"keywords": [
|
6
|
+
"near",
|
7
|
+
"ethereum",
|
8
|
+
"safe",
|
9
|
+
"account-abstraction",
|
10
|
+
"erc4337",
|
11
|
+
"chain-signatures"
|
12
|
+
],
|
5
13
|
"main": "dist/cjs/index.js",
|
6
14
|
"module": "dist/cjs/index.js",
|
7
15
|
"types": "dist/esm/index.d.ts",
|