Skip to content

Commit

Permalink
chore: update viem (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
jagnani73 authored Jul 18, 2024
1 parent afad243 commit db43843
Show file tree
Hide file tree
Showing 83 changed files with 32,057 additions and 33,368 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"enquirer": "^2.4.1",
"express": "^4.19.2",
"tsc-watch": "^6.0.4",
"viem": "^1.16.6",
"viem": "^2.17.4",
"yup": "^1.3.2"
},
"devDependencies": {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export const approvalForAllABI = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "owner",
type: "address",
},
{
indexed: true,
internalType: "address",
name: "operator",
type: "address",
},
{
indexed: false,
internalType: "bool",
name: "approved",
type: "bool",
},
],
name: "ApprovalForAll",
type: "event",
},
] as const;
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { decodeEventLog, type Abi } from "viem";
import { GoldRushDecoder } from "../../decoder";
import { type EventType } from "../../decoder.types";
import {
DECODED_ACTION,
DECODED_EVENT_CATEGORY,
} from "../../decoder.constants";
import { decodeEventLog, type Abi } from "viem";
import ABI from "./abis/approval-for-all.abi.json";
import { type EventType } from "../../decoder.types";
import { approvalForAllABI } from "./abis/approval-for-all.abi";

GoldRushDecoder.fallback(
"ApprovalForAll",
ABI as Abi,
approvalForAllABI as Abi,
async (
log_event,
tx,
Expand All @@ -21,18 +21,11 @@ GoldRushDecoder.fallback(
log_event;

const { args: decoded } = decodeEventLog({
abi: ABI,
abi: approvalForAllABI,
topics: raw_log_topics as [],
data: raw_log_data as `0x${string}`,
eventName: "ApprovalForAll",
}) as {
eventName: "ApprovalForAll";
args: {
owner: string;
operator: string;
approved: boolean;
};
};
});

return {
action: DECODED_ACTION.APPROVAL,
Expand Down
24 changes: 0 additions & 24 deletions services/decoder/fallbacks/approval/abis/approval-erc20.abi.json

This file was deleted.

24 changes: 24 additions & 0 deletions services/decoder/fallbacks/approval/abis/approval-erc20.abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const approvalERC20ABI = [
{
anonymous: false,
inputs: [
{
indexed: true,
name: "owner",
type: "address",
},
{
indexed: true,
name: "spender",
type: "address",
},
{
indexed: false,
name: "value",
type: "uint256",
},
],
name: "Approval",
type: "event",
},
] as const;
24 changes: 0 additions & 24 deletions services/decoder/fallbacks/approval/abis/approval-erc721.abi.json

This file was deleted.

24 changes: 24 additions & 0 deletions services/decoder/fallbacks/approval/abis/approval-erc721.abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const approvalERC721ABI = [
{
anonymous: false,
inputs: [
{
indexed: true,
name: "owner",
type: "address",
},
{
indexed: true,
name: "spender",
type: "address",
},
{
indexed: true,
name: "tokenId",
type: "uint256",
},
],
name: "Approval",
type: "event",
},
] as const;
36 changes: 11 additions & 25 deletions services/decoder/fallbacks/approval/approval.fallback.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { prettifyCurrency } from "@covalenthq/client-sdk";
import { decodeEventLog, type Abi } from "viem";
import { currencyToNumber, timestampParser } from "../../../../utils/functions";
import { GoldRushDecoder } from "../../decoder";
import { type EventDetails, type EventType } from "../../decoder.types";
import {
DECODED_ACTION,
DECODED_EVENT_CATEGORY,
} from "../../decoder.constants";
import { decodeEventLog, type Abi } from "viem";
import ERC20ABI from "./abis/approval-erc20.abi.json";
import ERC721ABI from "./abis/approval-erc721.abi.json";
import { currencyToNumber, timestampParser } from "../../../../utils/functions";
import { prettifyCurrency } from "@covalenthq/client-sdk";
import { type EventDetails, type EventType } from "../../decoder.types";
import { approvalERC20ABI } from "./abis/approval-erc20.abi";
import { approvalERC721ABI } from "./abis/approval-erc721.abi";

GoldRushDecoder.fallback(
"Approval",
ERC20ABI as Abi,
approvalERC20ABI as Abi,
async (
log_event,
tx,
Expand Down Expand Up @@ -47,33 +47,19 @@ GoldRushDecoder.fallback(

try {
const { args } = decodeEventLog({
abi: ERC20ABI,
abi: approvalERC20ABI,
topics: raw_log_topics as [],
data: raw_log_data as `0x${string}`,
eventName: "Approval",
}) as {
eventName: "Approval";
args: {
owner: string;
spender: string;
value: bigint;
};
};
});
decoded = args;
} catch (error) {
const { args } = decodeEventLog({
abi: ERC721ABI,
abi: approvalERC721ABI,
topics: raw_log_topics as [],
data: raw_log_data as `0x${string}`,
eventName: "Approval",
}) as {
eventName: "Approval";
args: {
owner: string;
spender: string;
tokenId: bigint;
};
};
});
decoded = args;
}

Expand Down
27 changes: 0 additions & 27 deletions services/decoder/fallbacks/transfer/abis/transfer-erc20.abi.json

This file was deleted.

27 changes: 27 additions & 0 deletions services/decoder/fallbacks/transfer/abis/transfer-erc20.abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export const transferERC20ABI = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "from",
type: "address",
},
{
indexed: true,
internalType: "address",
name: "to",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "value",
type: "uint256",
},
],
name: "Transfer",
type: "event",
},
] as const;
27 changes: 0 additions & 27 deletions services/decoder/fallbacks/transfer/abis/transfer-erc721.abi.json

This file was deleted.

27 changes: 27 additions & 0 deletions services/decoder/fallbacks/transfer/abis/transfer-erc721.abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export const transferERC721ABI = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "from",
type: "address",
},
{
indexed: true,
internalType: "address",
name: "to",
type: "address",
},
{
indexed: true,
internalType: "uint256",
name: "tokenId",
type: "uint256",
},
],
name: "Transfer",
type: "event",
},
] as const;
Loading

0 comments on commit db43843

Please sign in to comment.