Skip to content

Commit

Permalink
updated implementation to get chain Info using chainOverrides (#297)
Browse files Browse the repository at this point in the history
* updated implementation to get chainData using chainOverrides

* updated getLocalWallet() to support chainOverride & updated the type
  • Loading branch information
farhanW3 authored Nov 9, 2023
1 parent 9d878d1 commit bf5859b
Show file tree
Hide file tree
Showing 137 changed files with 210 additions and 141 deletions.
2 changes: 1 addition & 1 deletion src/server/routes/backend-wallet/getBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function getBalance(fastify: FastifyInstance) {
},
handler: async (request, reply) => {
const { chain, walletAddress } = request.params;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const sdk = await getSdk({ chainId });

let balanceData = await sdk.getBalance(walletAddress);
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/backend-wallet/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function sendTransaction(fastify: FastifyInstance) {
const { chain } = request.params;
const { toAddress, data, value } = request.body;
const fromAddress = request.headers["x-backend-wallet-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

// TODO: At some point we should simulate this first
// For now, it's okay not to since its a raw transaction
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/backend-wallet/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function transfer(fastify: FastifyInstance) {
// TODO: Bring Smart Wallet back
// const accountAddress = request.headers["x-account-address"] as string;

const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const sdk = await getSdk({ chainId, walletAddress });

const normalizedValue = await normalizePriceValue(
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/contract/events/getAllEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export async function getAllEvents(fastify: FastifyInstance) {
const { chain, contractAddress } = request.params;
const { fromBlock, toBlock, order } = request.query;

const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/contract/events/getEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export async function getEvents(fastify: FastifyInstance) {
const { chain, contractAddress } = request.params;
const { fromBlock, toBlock, order, eventName, filters } = request.body;

const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getAllAdmins = async (fastify: FastifyInstance) => {
},
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getAllSessions = async (fastify: FastifyInstance) => {
},
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const grantAdmin = async (fastify: FastifyInstance) => {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const grantSession = async (fastify: FastifyInstance) => {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const revokeAdmin = async (fastify: FastifyInstance) => {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const revokeSession = async (fastify: FastifyInstance) => {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const updateSession = async (fastify: FastifyInstance) => {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getAllAccounts = async (fastify: FastifyInstance) => {
},
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const getAssociatedAccounts = async (fastify: FastifyInstance) => {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { signerAddress } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const isAccountDeployed = async (fastify: FastifyInstance) => {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { adminAddress, extraData } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const predictAccountAddress = async (fastify: FastifyInstance) => {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { adminAddress, extraData } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const createAccount = async (fastify: FastifyInstance) => {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);

const contract = await getContract({
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function erc1155BalanceOf(fastify: FastifyInstance) {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { walletAddress, tokenId } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/contract/extensions/erc1155/read/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function erc1155Get(fastify: FastifyInstance) {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { tokenId } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function erc1155GetAll(fastify: FastifyInstance) {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { start, count } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function erc1155GetOwned(fastify: FastifyInstance) {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { walletAddress } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function erc1155IsApproved(fastify: FastifyInstance) {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { ownerWallet, operator } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function erc1155SignatureGenerate(fastify: FastifyInstance) {
royaltyRecipient,
uid,
} = request.body;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function erc1155TotalCount(fastify: FastifyInstance) {
},
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function erc1155TotalSupply(fastify: FastifyInstance) {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { tokenId } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function erc1155airdrop(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function erc1155burn(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function erc1155burnBatch(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function erc1155claimTo(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function erc1155lazyMint(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function erc1155mintAdditionalSupplyTo(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function erc1155mintBatchTo(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function erc1155mintTo(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function erc1155SetApprovalForAll(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function erc1155SignatureMint(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function erc1155transfer(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function erc1155transferFrom(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function erc20AllowanceOf(fastify: FastifyInstance) {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { spenderWallet, ownerWallet } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export async function erc20BalanceOf(fastify: FastifyInstance) {
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const { wallet_address } = request.query;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/contract/extensions/erc20/read/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function erc20GetMetadata(fastify: FastifyInstance) {
},
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function erc20SignatureGenerate(fastify: FastifyInstance) {
const walletAddress = request.headers[
"x-backend-wallet-address"
] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function erc20TotalSupply(fastify: FastifyInstance) {
},
handler: async (request, reply) => {
const { chain, contractAddress } = request.params;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/contract/extensions/erc20/write/burn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function erc20burn(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export async function erc20burnFrom(fastify: FastifyInstance) {
"x-backend-wallet-address"
] as string;
const accountAddress = request.headers["x-account-address"] as string;
const chainId = getChainIdFromChain(chain);
const chainId = await getChainIdFromChain(chain);
const contract = await getContract({
chainId,
contractAddress,
Expand Down
Loading

0 comments on commit bf5859b

Please sign in to comment.