/**
The OffsetHelper's purpose is to simplify the carbon offsetting process.
Copyright (C) 2022 Toucan Labs
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
import { BigNumber } from "ethers";
import {
BatchCommentSchema,
BatchTokenSchema,
PooledTCO2TokenSchema,
ProjectSchema,
ProjectVintageSchema,
RedeemSchema,
RetirementCertificateSchema,
RetirementSchema,
TCO2BalanceSchema,
TCO2TokenSchema,
UserSchema,
} from "./schemas";
// --------------------------------------------------------------------------------
// Contract Interactions Responses
// --------------------------------------------------------------------------------
export type RedeemAutoResponse = Array<{ address: string; amount: BigNumber }>;
/**
* I have decided to separated the types for the subgraph methods here as using Pick to separate
* the needed properties from the schemas can become verbose as you will see below.
*
* See types/schemas.ts for more information on why I decided to use Pick in the first place.
*/
// --------------------------------------------------------------------------------
// Batches Subgraph Responses
// --------------------------------------------------------------------------------
export type UserBatchesResponse = Array<
Pick<
BatchTokenSchema,
"id" | "tx" | "serialNumber" | "quantity" | "confirmationStatus"
> & {
comments: Array<
Pick & {
sender: Pick;
}
>;
creator: Pick;
}
>;
// --------------------------------------------------------------------------------
// TCO2Tokens Subgraph Responses
// --------------------------------------------------------------------------------
export type TCO2TokenResponse = Pick<
TCO2TokenSchema,
"id" | "name" | "symbol" | "address"
> & {
projectVintage: Pick & {
project: Pick;
};
};
// --------------------------------------------------------------------------------
// BatchTokens Subgraph Responses
// --------------------------------------------------------------------------------
export type BridgedBatchTokensResponse = Pick<
BatchTokenSchema,
"id" | "serialNumber" | "quantity" | "timestamp" | "tx"
> & { creator: Pick };
// --------------------------------------------------------------------------------
// Retirements Subgraph Responses
// --------------------------------------------------------------------------------
export type UserRetirementsResponse = Pick<
RetirementSchema,
"id" | "creationTx" | "amount" | "timestamp"
> & {
token: Pick & {
projectVintage: Pick & {
project: Pick;
};
};
certificate: Pick<
RetirementCertificateSchema,
| "id"
| "retiringEntityString"
| "beneficiaryString"
| "retirementMessage"
| "createdAt"
> & {
retiringEntity: Pick;
beneficiary: Pick;
};
};
// --------------------------------------------------------------------------------
// Redeems Subgraph Responses
// --------------------------------------------------------------------------------
export type RedeemsResponse = Pick<
RedeemSchema,
"id" | "amount" | "timestamp"
> & {
creator: Pick;
token: Pick & {
projectVintage: Pick & {
project: Pick;
};
};
};
// --------------------------------------------------------------------------------
// PooledTCO2Tokens Subgraph Responses
// --------------------------------------------------------------------------------
export type PoolContentsResponse = Pick & {
token: Pick & {
projectVintage: Pick & {
project: Pick;
};
};
};
// --------------------------------------------------------------------------------
// Projects Subgraph Responses
// --------------------------------------------------------------------------------
export type ProjectResponse = Pick<
ProjectSchema,
"projectId" | "region" | "standard" | "methodology"
> & { vintages: Pick };
// --------------------------------------------------------------------------------
// TCO2Balances Subgraph Responses
// --------------------------------------------------------------------------------
export type BalanceResponse = Pick & {
token: Pick;
};