Skip to content

Commit

Permalink
types update and backend functions
Browse files Browse the repository at this point in the history
  • Loading branch information
talha committed Oct 3, 2022
1 parent 5f6197a commit 283e14a
Show file tree
Hide file tree
Showing 34 changed files with 11,863 additions and 13,790 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.17.0
8,864 changes: 0 additions & 8,864 deletions package-lock.json

This file was deleted.

6 changes: 3 additions & 3 deletions packages/core-types/src/contracts/EntryPointContract.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { UserOperation } from '../types'
import { TransactionResult } from '../transaction.types'
import { ITransactionResult } from '../transaction.types'
import { Contract } from '@ethersproject/contracts'

export interface EntryPointContract {
getContract(): Contract
handleOps(userOperations: UserOperation[], beneficiary: string): Promise<TransactionResult>
simulateValidation(userOperation: UserOperation, offChainSigCheck: boolean): Promise<TransactionResult>
handleOps(userOperations: UserOperation[], beneficiary: string): Promise<ITransactionResult>
simulateValidation(userOperation: UserOperation, offChainSigCheck: boolean): Promise<ITransactionResult>
getRequestId(userOperation: UserOperation): Promise<string>
}
8 changes: 4 additions & 4 deletions packages/core-types/src/contracts/SmartWalletContract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletTransaction, ExecTransaction, FeeRefundV1_0_0, FeeRefundV1_0_1 } from '../transaction.types'
import { IWalletTransaction, ExecTransaction, IFeeRefundV1_0_0, IFeeRefundV1_0_1 } from '../transaction.types'
import { SmartAccountVersion } from '../types'
import { BigNumber } from '@ethersproject/bignumber'
import { Interface } from '@ethersproject/abi'
Expand All @@ -14,17 +14,17 @@ export interface SmartWalletContract {
getOwner(): Promise<string>
getVersion(): Promise<SmartAccountVersion>
getNonce(batchId: number): Promise<BigNumber>
getTransactionHash(smartAccountTrxData: WalletTransaction): Promise<string>
getTransactionHash(smartAccountTrxData: IWalletTransaction): Promise<string>
execTransaction(
transaction: ExecTransaction,
batchId: number,
feeRefundData: FeeRefundV1_0_0,
feeRefundData: IFeeRefundV1_0_0,
signatures: string
): any
execTransaction(
transaction: ExecTransaction,
batchId: number,
feeRefundData: FeeRefundV1_0_1,
feeRefundData: IFeeRefundV1_0_1,
signatures: string
): any
encode(methodName: string, params: any): string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TransactionResult } from '../transaction.types'
import { ITransactionResult } from '../transaction.types'
import { Interface } from '@ethersproject/abi'
import { Contract } from '@ethersproject/contracts'
export interface SmartWalletFactoryContract {
Expand All @@ -11,7 +11,7 @@ export interface SmartWalletFactoryContract {
entryPoint: string,
handler: string,
index: number
): Promise<TransactionResult>
deployWallet(owner: string, entryPoint: string, handler: string): Promise<TransactionResult>
): Promise<ITransactionResult>
deployWallet(owner: string, entryPoint: string, handler: string): Promise<ITransactionResult>
getAddressForCounterfactualWallet(owner: string, index: number): Promise<string>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MultiSendCallOnlyContract } from '../contracts/MultiSendCallOnlyContrac
import { SmartWalletFactoryContract } from '../contracts/SmartWalletFactoryContract'
import { Eip3770Address, SmartAccountVersion } from '../types'

export interface EthAdapterTransaction {
export interface IEvmNetworkManagerTransaction {
to: string
from: string
data: string
Expand All @@ -14,7 +14,7 @@ export interface EthAdapterTransaction {
gasLimit?: number
}

export interface EthAdapter {
export interface IEvmNetworkManager {
getEip3770Address(fullAddress: string): Promise<Eip3770Address>
getBalance(address: string): Promise<BigNumber>
getChainId(): Promise<number>
Expand All @@ -37,8 +37,8 @@ export interface EthAdapter {
getSignerAddress(): Promise<string>
signMessage(message: string): Promise<string>
estimateGas(
transaction: EthAdapterTransaction,
transaction: IEvmNetworkManagerTransaction,
callback?: (error: Error, gas: number) => void
): Promise<number>
call(transaction: EthAdapterTransaction): Promise<string>
call(transaction: IEvmNetworkManagerTransaction): Promise<string>
}
2 changes: 1 addition & 1 deletion packages/core-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export * from './contracts/MultiSendContract'
export * from './contracts/MultiSendCallOnlyContract'
export * from './contracts/SmartWalletFactoryContract'
export * from './contracts/EntryPointContract'
export * from './ethereumLibs/EthAdapter'
export * from './evm-manager/EvmNetworkManager'
export * from './types'
export * from './chains.types'
export * from './transaction.types'
Expand Down
12 changes: 6 additions & 6 deletions packages/core-types/src/smart-account.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Smart Account Detail Param Types

import { ChainId } from './chains.types'
import { WalletTransaction, Transaction } from './transaction.types'
import { IWalletTransaction, Transaction } from './transaction.types'
import { FeeQuote } from './types'
import { SmartWalletFactoryContract } from './contracts/SmartWalletFactoryContract'
import { MultiSendContract } from './contracts/MultiSendContract'
Expand All @@ -11,7 +11,7 @@ import { GasLimit } from './transaction.types'
import { JsonRpcSigner } from '@ethersproject/providers'


export interface SmartAccountConfig {
export type SmartAccountConfig = {
owner: string
version: string
activeNetworkId: ChainId // same
Expand All @@ -20,7 +20,7 @@ export interface SmartAccountConfig {
relayer_url: string
}

export interface SmartAccountContext {
export type SmartAccountContext = {
baseWallet: SmartWalletContract
walletFactory: SmartWalletFactoryContract
multiSend: MultiSendContract
Expand All @@ -36,7 +36,7 @@ export type EstimateSmartAccountDeploymentDto = {
fallbackHandlerAddress: string
}

export interface SmartAccountState {
export type SmartAccountState = {
address: string // multichain (EVM)
owner: string // multichain (EVM)
isDeployed: boolean // chain specific
Expand All @@ -52,13 +52,13 @@ export type AddressForCounterFactualWalletDto = {

export type SignTransactionDto = {
version: string
tx: WalletTransaction
tx: IWalletTransaction
chainId: ChainId
signer: JsonRpcSigner
}

export type SendTransactionDto = {
tx: WalletTransaction
tx: IWalletTransaction
batchId?: number
chainId?: ChainId
gasLimit?: GasLimit
Expand Down
38 changes: 19 additions & 19 deletions packages/core-types/src/transaction.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SmartAccountContext, SmartAccountState } from './smart-account.types'
import { PromiEvent, TransactionReceipt } from 'web3-core/types'
import { ContractTransaction } from '@ethersproject/contracts'

export interface RawTransactionType {
export type RawTransactionType = {
from?: string
gasPrice?: string | BigNumber
maxFeePerGas?: string | BigNumber
Expand All @@ -19,7 +19,7 @@ export interface RawTransactionType {
type?: number
}

export interface Transaction {
export type Transaction = {
to: string
value?: BigNumberish
data?: string
Expand All @@ -28,55 +28,55 @@ export interface Transaction {
// delegateCall?: boolean
// revertOnError?: boolean
}
export interface SignedTransaction {
export type SignedTransaction = {
rawTx: RawTransactionType
tx: WalletTransaction
tx: IWalletTransaction
}

export interface ExecTransaction {
export type ExecTransaction = {
to: string
value: BigNumberish
data: string
operation: number
targetTxGas: string | number
}

export interface SmartAccountSignature {
export type SmartAccountSignature = {
signer: string
data: string
}

export interface FeeRefundV1_0_0 {
export interface IFeeRefundV1_0_0 {
// gasUsed: string | number
baseGas: string | number
gasPrice: string | number
gasToken: string
refundReceiver: string
}
export interface FeeRefundV1_0_1 extends FeeRefundV1_0_0{
export interface IFeeRefundV1_0_1 extends IFeeRefundV1_0_0{
tokenGasPriceFactor: string | number
}


// extended from FeeRefund as we need this for handlePayment Estimate
export interface FeeRefundHandlePayment extends FeeRefundV1_0_1 {
export interface IFeeRefundHandlePayment extends IFeeRefundV1_0_1 {
gasUsed: string | number
}

export interface MetaTransactionData {
export type MetaTransactionData = {
readonly to: string
readonly value: BigNumberish
readonly data: string
readonly operation?: OperationType
}
export interface MetaTransaction {
export interface IMetaTransaction {
to: string
value: BigNumberish
data: string
operation: number
}

export interface WalletTransaction extends MetaTransaction {
export interface IWalletTransaction extends IMetaTransaction {
targetTxGas: string | number
baseGas: string | number
gasPrice: string | number
Expand All @@ -86,43 +86,43 @@ export interface WalletTransaction extends MetaTransaction {
nonce: number
}

export interface Signature {
export type Signature = {
readonly signer: string
readonly data: string
staticPart(): string
dynamicPart(): string
}

export interface TransactionOptions {
export type TransactionOptions = {
from?: string
gas?: number | string
gasLimit?: number | string
gasPrice?: number | string
}

export interface BaseTransactionResult {
export interface IBaseTransactionResult {
hash: string
}

export interface TransactionResult extends BaseTransactionResult {
export interface ITransactionResult extends IBaseTransactionResult {
promiEvent?: PromiEvent<TransactionReceipt>
transactionResponse?: ContractTransaction
options?: TransactionOptions
}

export interface RelayTransaction {
export type RelayTransaction = {
signedTx: SignedTransaction
config: SmartAccountState
context: SmartAccountContext
gasLimit?: GasLimit
}

export interface GasLimit {
export type GasLimit = {
hex: string
type: string
}

export interface DeployWallet {
export type DeployWallet = {
config: SmartAccountState
context: SmartAccountContext
index: number
Expand Down
16 changes: 8 additions & 8 deletions packages/core-types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ export enum OperationType {
}


export interface Eip3770Address {
export type Eip3770Address = {
prefix: string
address: string
}

export interface RelayResponse {
export type RelayResponse = {
code?: number
message?: string
transactionId?: string
hash: string
error?: string
connectionUrl?: string
}
export interface UserOperation {
export type UserOperation = {
sender: string
nonce: number
initCode: string
Expand All @@ -45,11 +45,11 @@ export const GAS_USAGE_OFFSET = 4928 + 2360

export const FAKE_SIGNATURE = "0x39f5032f1cd30005aa1e35f04394cabfe7de3b6ae6d95b27edd8556064c287bf61f321fead0cf48ca4405d497cc8fc47fc7ff0b7f5c45baa14090a44f2307d8230"

export interface RestRelayerOptions {
export type RestRelayerOptions = {
url: string
}

export interface TokenData {
export type TokenData = {
tokenGasPrice: number // review
offset?: number // review
symbol: string
Expand All @@ -60,7 +60,7 @@ export interface TokenData {
refundReceiver?: string
}

export interface FeeQuote {
export type FeeQuote = {
symbol: string,
address: string,
decimal: number,
Expand All @@ -71,14 +71,14 @@ export interface FeeQuote {
refundReceiver?: string;
}

export interface FeeOptionsResponse {
export type FeeOptionsResponse = {
msg: string
data: {
chainId: number
response: Array<TokenData>
}
}
export interface FeeOption {
export type FeeOption = {
feeToken: string
tokenGasPrice: number | string //review
offset: number | string // review
Expand Down
12 changes: 6 additions & 6 deletions packages/ethers-lib/src/EthersAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { BigNumber } from '@ethersproject/bignumber'
import { Provider, JsonRpcProvider } from '@ethersproject/providers'
import {
Eip3770Address,
EthAdapter,
EthAdapterTransaction,
IEvmNetworkManager,
IEvmNetworkManagerTransaction,
SmartAccountVersion,
SmartWalletContract
} from '@biconomy-sdk/core-types'
Expand All @@ -28,7 +28,7 @@ export interface EthersAdapterConfig {
provider: JsonRpcProvider
}

class EthersAdapter implements EthAdapter {
class EvmNetworkManager implements IEvmNetworkManager {
#ethers: Ethers
#signer: Signer
#provider: JsonRpcProvider
Expand Down Expand Up @@ -121,13 +121,13 @@ class EthersAdapter implements EthAdapter {
}

// Review
async estimateGas(transaction: EthAdapterTransaction): Promise<number> {
async estimateGas(transaction: IEvmNetworkManagerTransaction): Promise<number> {
return (await this.#provider.estimateGas(transaction)).toNumber()
}

call(transaction: EthAdapterTransaction): Promise<string> {
call(transaction: IEvmNetworkManagerTransaction): Promise<string> {
return this.#provider.call(transaction)
}
}

export default EthersAdapter
export default EvmNetworkManager
Loading

0 comments on commit 283e14a

Please sign in to comment.