Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ATTESTATION_URL=
API_KEY=
50 changes: 1 addition & 49 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,5 @@
import {
addressToName as addressToNameCST,
nameToAbi as nameToAbiCST,
nameToAddress as nameToAddressCST,
} from "./coston";
import {
addressToName as addressToNameCST2,
nameToAbi as nameToAbiCST2,
nameToAddress as nameToAddressCST2,
} from "./coston2";
import {
addressToName as addressToNameFLR,
nameToAbi as nameToAbiFLR,
nameToAddress as nameToAddressFLR,
} from "./flare";
import {
addressToName as addressToNameSGB,
nameToAbi as nameToAbiSGB,
nameToAddress as nameToAddressSGB,
} from "./songbird";

export const nameToAddress = (name: string, network: string): string => {
if (network.toLowerCase() == "flare") return nameToAddressFLR(name);
if (network.toLowerCase() == "songbird") return nameToAddressSGB(name);
if (network.toLowerCase() == "coston") return nameToAddressCST(name);
if (network.toLowerCase() == "coston2") return nameToAddressCST2(name);
return "";
};

export const addressToName = (address: string, network: string): string => {
if (network.toLowerCase() == "flare") return addressToNameFLR(address);
if (network.toLowerCase() == "songbird") return addressToNameSGB(address);
if (network.toLowerCase() == "coston") return addressToNameCST(address);
if (network.toLowerCase() == "coston2") return addressToNameCST2(address);
return "";
};

export const nameToAbi = (
name: string,
network: string,
): { data: any; status: string } => {
if (network.toLowerCase() == "flare") return nameToAbiFLR(name);
if (network.toLowerCase() == "songbird") return nameToAbiSGB(name);
if (network.toLowerCase() == "coston") return nameToAbiCST(name);
if (network.toLowerCase() == "coston2") return nameToAbiCST2(name);
return { data: [], status: "Please select a network" };
};

export * as coston from "./coston";
export * as coston2 from "./coston2";
export * as flare from "./flare";
export * as songbird from "./songbird";

export * from "./utils/utils";
157 changes: 157 additions & 0 deletions utils/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
interface AddressValidityRequestBody {
addressStr: string;
}

interface AddressValidityResponseBody {
isValid: boolean;
standardAddress: string;
standardAddressHash: string;
}

interface AddressValidityRequest {
attestationType: string;
sourceId: string;
messageIntegrityCode: string;
requestBody: AddressValidityRequestBody;
}

interface AddressValidityResponse {
attestationType: string;
sourceId: string;
votingRound: number;
lowestUsedTimestamp: number;
requestBody: AddressValidityRequestBody;
responseBody: AddressValidityResponseBody;
}

interface BalanceDecreasingTransactionRequestBody {
transactionId: string;
sourceAddressIndicator: string;
}

interface BalanceDecreasingTransactionResponseBody {
blockNumber: number;
blockTimestamp: number;
sourceAddressHash: string;
spentAmount: number;
standardPaymentReference: string;
}

interface BalanceDecreasingTransactionRequest {
attestationType: string;
sourceId: string;
messageIntegrityCode: string;
requestBody: BalanceDecreasingTransactionRequestBody;
}

interface BalanceDecreasingTransactionResponse {
attestationType: string;
sourceId: string;
votingRound: number;
lowestUsedTimestamp: number;
requestBody: BalanceDecreasingTransactionRequestBody;
responseBody: BalanceDecreasingTransactionResponseBody;
}

interface ConfirmedBlockHeightExistsRequestBody {
blockNumber: number;
queryWindow: number;
}

interface ConfirmedBlockHeightExistsResponseBody {
blockTimestamp: number;
numberOfConfirmations: number;
lowestQueryWindowBlockNumber: number;
lowestQueryWindowBlockTimestamp: number;
}

interface ConfirmedBlockHeightExistsRequest {
attestationType: string;
sourceId: string;
messageIntegrityCode: string;
requestBody: ConfirmedBlockHeightExistsRequestBody;
}

interface ConfirmedBlockHeightExistsResponse {
attestationType: string;
sourceId: string;
votingRound: number;
lowestUsedTimestamp: number;
requestBody: ConfirmedBlockHeightExistsRequestBody;
responseBody: ConfirmedBlockHeightExistsResponseBody;
}

interface EVMTransactionRequestBody {
transactionHash: string; // Use string for easier handling in TypeScript
requiredConfirmations: number;
provideInput: boolean;
listEvents: boolean;
logIndices: number[]; // Array of log indices
}

interface EVMTransactionResponseBody {
blockNumber: number;
timestamp: number;
sourceAddress: string;
isDeployment: boolean;
receivingAddress: string;
value: string; // Use string to handle large numbers (wei)
input: string; // Hex string of input data
status: number; // 1 for success, 0 for failure
events: Event[];
}

interface Event {
logIndex: number;
emitterAddress: string;
topics: string[]; // Array of hex strings
data: string; // Hex string of concatenated data
removed: boolean;
}

interface EVMTransactionRequest {
attestationType: string;
sourceId: string;
messageIntegrityCode: string;
requestBody: EVMTransactionRequestBody;
}

interface EVMTransactionResponse {
attestationType: string;
sourceId: string;
votingRound: number;
lowestUsedTimestamp: number;
requestBody: EVMTransactionRequestBody;
responseBody: EVMTransactionResponseBody;
}

interface ReferencedPaymentNonexistenceRequestBody {
minimalBlockNumber: number;
deadlineBlockNumber: number;
deadlineTimestamp: number;
destinationAddressHash: string; // Hexadecimal string representing the address hash
amount: string; // Use string for handling large amounts (in minimal units)
standardPaymentReference: string; // Hexadecimal string
}

interface ReferencedPaymentNonexistenceResponseBody {
minimalBlockTimestamp: number;
firstOverflowBlockNumber: number;
firstOverflowBlockTimestamp: number;
}

interface ReferencedPaymentNonexistenceRequest {
attestationType: string;
sourceId: string;
messageIntegrityCode: string;
requestBody: ReferencedPaymentNonexistenceRequestBody;
}

interface ReferencedPaymentNonexistenceResponse {
attestationType: string;
sourceId: string;
votingRound: number;
lowestUsedTimestamp: number;
requestBody: ReferencedPaymentNonexistenceRequestBody;
responseBody: ReferencedPaymentNonexistenceResponseBody;
}
3 changes: 3 additions & 0 deletions utils/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Utils

This is package for utility functions to make it easier to develop on Flare. The utils file includes functions for all the existing attestation types.
Loading