@arbius/aa-wallet
Version:
A secure and flexible Account Abstraction wallet implementation for Arbitrum One chain applications.
51 lines (50 loc) • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.initialState = void 0;
exports.walletReducer = walletReducer;
const walletActions_1 = require("./walletActions");
exports.initialState = {
isConnected: false,
address: null,
chainId: null,
transactions: []
};
function walletReducer(state, action) {
switch (action.type) {
case walletActions_1.WALLET_CONNECT:
return {
...state,
...action.payload
};
case walletActions_1.WALLET_DISCONNECT:
return {
...state,
isConnected: false,
address: null,
chainId: null
};
case walletActions_1.WALLET_SWITCH_CHAIN:
return {
...state,
chainId: action.payload,
};
case walletActions_1.WALLET_SET_CONFIG:
return state;
case walletActions_1.WALLET_SET_STATE:
return {
...action.payload,
};
case walletActions_1.TRANSACTION_ADD:
return {
...state,
transactions: [...state.transactions, action.payload],
};
case walletActions_1.TRANSACTION_UPDATE:
return {
...state,
transactions: state.transactions.map(tx => tx.id === action.payload.id ? action.payload : tx),
};
default:
return state;
}
}