= T extends T ? keyof T : never;
-export type Exact = P extends Builtin ? P
- : P & { [K in keyof P]: Exact
} & { [K in Exclude>]: never };
-
-function longToNumber(int64: { toString(): string }): number {
- const num = globalThis.Number(int64.toString());
- if (num > globalThis.Number.MAX_SAFE_INTEGER) {
- throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
- }
- if (num < globalThis.Number.MIN_SAFE_INTEGER) {
- throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
- }
- return num;
-}
-
-function isObject(value: any): boolean {
- return typeof value === "object" && value !== null;
-}
-
-function isSet(value: any): boolean {
- return value !== null && value !== undefined;
-}
-
-export interface MessageFns {
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
- decode(input: BinaryReader | Uint8Array, length?: number): T;
- fromJSON(object: any): T;
- toJSON(message: T): unknown;
- create, I>>(base?: I): T;
- fromPartial, I>>(object: I): T;
-}
diff --git a/packages/core/src/lib/generated/tx.ts b/packages/core/src/lib/generated/tx.ts
deleted file mode 100644
index 111dd540..00000000
--- a/packages/core/src/lib/generated/tx.ts
+++ /dev/null
@@ -1,278 +0,0 @@
-// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
-// versions:
-// protoc-gen-ts_proto v2.2.4
-// protoc v3.20.3
-// source: tx.proto
-
-/* eslint-disable */
-import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
-
-export const protobufPackage = "push";
-
-/** TODO: SEQUENCE */
-export interface Transaction {
- /** 0 for non-value, 1 for value */
- type: number;
- /** INIT_DID, INIT_SESSION_KEY, NOTIF, EMAIL */
- category: string;
- sender: string;
- recipients: string[];
- /** data is also a protobuf message, depending on tx_type */
- data: Uint8Array;
- salt: Uint8Array;
- /** f(apiToken) = v1 */
- apiToken: Uint8Array;
- signature: Uint8Array;
- /** we don't use this as of now, no native 256bits int support in protobuf */
- fee: string;
-}
-
-function createBaseTransaction(): Transaction {
- return {
- type: 0,
- category: "",
- sender: "",
- recipients: [],
- data: new Uint8Array(0),
- salt: new Uint8Array(0),
- apiToken: new Uint8Array(0),
- signature: new Uint8Array(0),
- fee: "",
- };
-}
-
-export const Transaction: MessageFns = {
- encode(message: Transaction, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.type !== 0) {
- writer.uint32(8).uint32(message.type);
- }
- if (message.category !== "") {
- writer.uint32(18).string(message.category);
- }
- if (message.sender !== "") {
- writer.uint32(26).string(message.sender);
- }
- for (const v of message.recipients) {
- writer.uint32(34).string(v!);
- }
- if (message.data.length !== 0) {
- writer.uint32(42).bytes(message.data);
- }
- if (message.salt.length !== 0) {
- writer.uint32(50).bytes(message.salt);
- }
- if (message.apiToken.length !== 0) {
- writer.uint32(58).bytes(message.apiToken);
- }
- if (message.signature.length !== 0) {
- writer.uint32(66).bytes(message.signature);
- }
- if (message.fee !== "") {
- writer.uint32(74).string(message.fee);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): Transaction {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseTransaction();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 8) {
- break;
- }
-
- message.type = reader.uint32();
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.category = reader.string();
- continue;
- }
- case 3: {
- if (tag !== 26) {
- break;
- }
-
- message.sender = reader.string();
- continue;
- }
- case 4: {
- if (tag !== 34) {
- break;
- }
-
- message.recipients.push(reader.string());
- continue;
- }
- case 5: {
- if (tag !== 42) {
- break;
- }
-
- message.data = reader.bytes();
- continue;
- }
- case 6: {
- if (tag !== 50) {
- break;
- }
-
- message.salt = reader.bytes();
- continue;
- }
- case 7: {
- if (tag !== 58) {
- break;
- }
-
- message.apiToken = reader.bytes();
- continue;
- }
- case 8: {
- if (tag !== 66) {
- break;
- }
-
- message.signature = reader.bytes();
- continue;
- }
- case 9: {
- if (tag !== 74) {
- break;
- }
-
- message.fee = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): Transaction {
- return {
- type: isSet(object.type) ? globalThis.Number(object.type) : 0,
- category: isSet(object.category) ? globalThis.String(object.category) : "",
- sender: isSet(object.sender) ? globalThis.String(object.sender) : "",
- recipients: globalThis.Array.isArray(object?.recipients)
- ? object.recipients.map((e: any) => globalThis.String(e))
- : [],
- data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0),
- salt: isSet(object.salt) ? bytesFromBase64(object.salt) : new Uint8Array(0),
- apiToken: isSet(object.apiToken) ? bytesFromBase64(object.apiToken) : new Uint8Array(0),
- signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),
- fee: isSet(object.fee) ? globalThis.String(object.fee) : "",
- };
- },
-
- toJSON(message: Transaction): unknown {
- const obj: any = {};
- if (message.type !== 0) {
- obj.type = Math.round(message.type);
- }
- if (message.category !== "") {
- obj.category = message.category;
- }
- if (message.sender !== "") {
- obj.sender = message.sender;
- }
- if (message.recipients?.length) {
- obj.recipients = message.recipients;
- }
- if (message.data.length !== 0) {
- obj.data = base64FromBytes(message.data);
- }
- if (message.salt.length !== 0) {
- obj.salt = base64FromBytes(message.salt);
- }
- if (message.apiToken.length !== 0) {
- obj.apiToken = base64FromBytes(message.apiToken);
- }
- if (message.signature.length !== 0) {
- obj.signature = base64FromBytes(message.signature);
- }
- if (message.fee !== "") {
- obj.fee = message.fee;
- }
- return obj;
- },
-
- create, I>>(base?: I): Transaction {
- return Transaction.fromPartial(base ?? ({} as any));
- },
- fromPartial, I>>(object: I): Transaction {
- const message = createBaseTransaction();
- message.type = object.type ?? 0;
- message.category = object.category ?? "";
- message.sender = object.sender ?? "";
- message.recipients = object.recipients?.map((e) => e) || [];
- message.data = object.data ?? new Uint8Array(0);
- message.salt = object.salt ?? new Uint8Array(0);
- message.apiToken = object.apiToken ?? new Uint8Array(0);
- message.signature = object.signature ?? new Uint8Array(0);
- message.fee = object.fee ?? "";
- return message;
- },
-};
-
-function bytesFromBase64(b64: string): Uint8Array {
- if ((globalThis as any).Buffer) {
- return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
- } else {
- const bin = globalThis.atob(b64);
- const arr = new Uint8Array(bin.length);
- for (let i = 0; i < bin.length; ++i) {
- arr[i] = bin.charCodeAt(i);
- }
- return arr;
- }
-}
-
-function base64FromBytes(arr: Uint8Array): string {
- if ((globalThis as any).Buffer) {
- return globalThis.Buffer.from(arr).toString("base64");
- } else {
- const bin: string[] = [];
- arr.forEach((byte) => {
- bin.push(globalThis.String.fromCharCode(byte));
- });
- return globalThis.btoa(bin.join(""));
- }
-}
-
-type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
-
-export type DeepPartial = T extends Builtin ? T
- : T extends globalThis.Array ? globalThis.Array>
- : T extends ReadonlyArray ? ReadonlyArray>
- : T extends {} ? { [K in keyof T]?: DeepPartial }
- : Partial;
-
-type KeysOfUnion = T extends T ? keyof T : never;
-export type Exact = P extends Builtin ? P
- : P & { [K in keyof P]: Exact
} & { [K in Exclude>]: never };
-
-function isSet(value: any): boolean {
- return value !== null && value !== undefined;
-}
-
-export interface MessageFns {
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
- decode(input: BinaryReader | Uint8Array, length?: number): T;
- fromJSON(object: any): T;
- toJSON(message: T): unknown;
- create, I>>(base?: I): T;
- fromPartial, I>>(object: I): T;
-}
diff --git a/packages/core/src/lib/generated/txData/init_did.ts b/packages/core/src/lib/generated/txData/init_did.ts
deleted file mode 100644
index 8fc3b339..00000000
--- a/packages/core/src/lib/generated/txData/init_did.ts
+++ /dev/null
@@ -1,508 +0,0 @@
-// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
-// versions:
-// protoc-gen-ts_proto v2.2.4
-// protoc v3.20.3
-// source: txData/init_did.proto
-
-/* eslint-disable */
-import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
-
-export const protobufPackage = "push";
-
-export interface EncryptedText {
- ciphertext: string;
- salt: string;
- nonce: string;
- version: string;
- preKey: string;
-}
-
-export interface WalletToEncDerivedKey {
- encDerivedPrivKey:
- | EncryptedText
- | undefined;
- /** Helps Vnode to proof that encryptedData is indeed signed by account */
- signature: Uint8Array;
-}
-
-export interface InitDid {
- masterPubKey: string;
- derivedKeyIndex: number;
- derivedPubKey: string;
- walletToEncDerivedKey: { [key: string]: WalletToEncDerivedKey };
-}
-
-export interface InitDid_WalletToEncDerivedKeyEntry {
- key: string;
- value: WalletToEncDerivedKey | undefined;
-}
-
-function createBaseEncryptedText(): EncryptedText {
- return { ciphertext: "", salt: "", nonce: "", version: "", preKey: "" };
-}
-
-export const EncryptedText: MessageFns = {
- encode(message: EncryptedText, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.ciphertext !== "") {
- writer.uint32(10).string(message.ciphertext);
- }
- if (message.salt !== "") {
- writer.uint32(18).string(message.salt);
- }
- if (message.nonce !== "") {
- writer.uint32(26).string(message.nonce);
- }
- if (message.version !== "") {
- writer.uint32(34).string(message.version);
- }
- if (message.preKey !== "") {
- writer.uint32(42).string(message.preKey);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): EncryptedText {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseEncryptedText();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.ciphertext = reader.string();
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.salt = reader.string();
- continue;
- }
- case 3: {
- if (tag !== 26) {
- break;
- }
-
- message.nonce = reader.string();
- continue;
- }
- case 4: {
- if (tag !== 34) {
- break;
- }
-
- message.version = reader.string();
- continue;
- }
- case 5: {
- if (tag !== 42) {
- break;
- }
-
- message.preKey = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): EncryptedText {
- return {
- ciphertext: isSet(object.ciphertext) ? globalThis.String(object.ciphertext) : "",
- salt: isSet(object.salt) ? globalThis.String(object.salt) : "",
- nonce: isSet(object.nonce) ? globalThis.String(object.nonce) : "",
- version: isSet(object.version) ? globalThis.String(object.version) : "",
- preKey: isSet(object.preKey) ? globalThis.String(object.preKey) : "",
- };
- },
-
- toJSON(message: EncryptedText): unknown {
- const obj: any = {};
- if (message.ciphertext !== "") {
- obj.ciphertext = message.ciphertext;
- }
- if (message.salt !== "") {
- obj.salt = message.salt;
- }
- if (message.nonce !== "") {
- obj.nonce = message.nonce;
- }
- if (message.version !== "") {
- obj.version = message.version;
- }
- if (message.preKey !== "") {
- obj.preKey = message.preKey;
- }
- return obj;
- },
-
- create, I>>(base?: I): EncryptedText {
- return EncryptedText.fromPartial(base ?? ({} as any));
- },
- fromPartial, I>>(object: I): EncryptedText {
- const message = createBaseEncryptedText();
- message.ciphertext = object.ciphertext ?? "";
- message.salt = object.salt ?? "";
- message.nonce = object.nonce ?? "";
- message.version = object.version ?? "";
- message.preKey = object.preKey ?? "";
- return message;
- },
-};
-
-function createBaseWalletToEncDerivedKey(): WalletToEncDerivedKey {
- return { encDerivedPrivKey: undefined, signature: new Uint8Array(0) };
-}
-
-export const WalletToEncDerivedKey: MessageFns = {
- encode(message: WalletToEncDerivedKey, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.encDerivedPrivKey !== undefined) {
- EncryptedText.encode(message.encDerivedPrivKey, writer.uint32(10).fork()).join();
- }
- if (message.signature.length !== 0) {
- writer.uint32(18).bytes(message.signature);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): WalletToEncDerivedKey {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseWalletToEncDerivedKey();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.encDerivedPrivKey = EncryptedText.decode(reader, reader.uint32());
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.signature = reader.bytes();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): WalletToEncDerivedKey {
- return {
- encDerivedPrivKey: isSet(object.encDerivedPrivKey) ? EncryptedText.fromJSON(object.encDerivedPrivKey) : undefined,
- signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),
- };
- },
-
- toJSON(message: WalletToEncDerivedKey): unknown {
- const obj: any = {};
- if (message.encDerivedPrivKey !== undefined) {
- obj.encDerivedPrivKey = EncryptedText.toJSON(message.encDerivedPrivKey);
- }
- if (message.signature.length !== 0) {
- obj.signature = base64FromBytes(message.signature);
- }
- return obj;
- },
-
- create, I>>(base?: I): WalletToEncDerivedKey {
- return WalletToEncDerivedKey.fromPartial(base ?? ({} as any));
- },
- fromPartial, I>>(object: I): WalletToEncDerivedKey {
- const message = createBaseWalletToEncDerivedKey();
- message.encDerivedPrivKey = (object.encDerivedPrivKey !== undefined && object.encDerivedPrivKey !== null)
- ? EncryptedText.fromPartial(object.encDerivedPrivKey)
- : undefined;
- message.signature = object.signature ?? new Uint8Array(0);
- return message;
- },
-};
-
-function createBaseInitDid(): InitDid {
- return { masterPubKey: "", derivedKeyIndex: 0, derivedPubKey: "", walletToEncDerivedKey: {} };
-}
-
-export const InitDid: MessageFns = {
- encode(message: InitDid, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.masterPubKey !== "") {
- writer.uint32(10).string(message.masterPubKey);
- }
- if (message.derivedKeyIndex !== 0) {
- writer.uint32(16).uint32(message.derivedKeyIndex);
- }
- if (message.derivedPubKey !== "") {
- writer.uint32(26).string(message.derivedPubKey);
- }
- Object.entries(message.walletToEncDerivedKey).forEach(([key, value]) => {
- InitDid_WalletToEncDerivedKeyEntry.encode({ key: key as any, value }, writer.uint32(34).fork()).join();
- });
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): InitDid {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseInitDid();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.masterPubKey = reader.string();
- continue;
- }
- case 2: {
- if (tag !== 16) {
- break;
- }
-
- message.derivedKeyIndex = reader.uint32();
- continue;
- }
- case 3: {
- if (tag !== 26) {
- break;
- }
-
- message.derivedPubKey = reader.string();
- continue;
- }
- case 4: {
- if (tag !== 34) {
- break;
- }
-
- const entry4 = InitDid_WalletToEncDerivedKeyEntry.decode(reader, reader.uint32());
- if (entry4.value !== undefined) {
- message.walletToEncDerivedKey[entry4.key] = entry4.value;
- }
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): InitDid {
- return {
- masterPubKey: isSet(object.masterPubKey) ? globalThis.String(object.masterPubKey) : "",
- derivedKeyIndex: isSet(object.derivedKeyIndex) ? globalThis.Number(object.derivedKeyIndex) : 0,
- derivedPubKey: isSet(object.derivedPubKey) ? globalThis.String(object.derivedPubKey) : "",
- walletToEncDerivedKey: isObject(object.walletToEncDerivedKey)
- ? Object.entries(object.walletToEncDerivedKey).reduce<{ [key: string]: WalletToEncDerivedKey }>(
- (acc, [key, value]) => {
- acc[key] = WalletToEncDerivedKey.fromJSON(value);
- return acc;
- },
- {},
- )
- : {},
- };
- },
-
- toJSON(message: InitDid): unknown {
- const obj: any = {};
- if (message.masterPubKey !== "") {
- obj.masterPubKey = message.masterPubKey;
- }
- if (message.derivedKeyIndex !== 0) {
- obj.derivedKeyIndex = Math.round(message.derivedKeyIndex);
- }
- if (message.derivedPubKey !== "") {
- obj.derivedPubKey = message.derivedPubKey;
- }
- if (message.walletToEncDerivedKey) {
- const entries = Object.entries(message.walletToEncDerivedKey);
- if (entries.length > 0) {
- obj.walletToEncDerivedKey = {};
- entries.forEach(([k, v]) => {
- obj.walletToEncDerivedKey[k] = WalletToEncDerivedKey.toJSON(v);
- });
- }
- }
- return obj;
- },
-
- create, I>>(base?: I): InitDid {
- return InitDid.fromPartial(base ?? ({} as any));
- },
- fromPartial, I>>(object: I): InitDid {
- const message = createBaseInitDid();
- message.masterPubKey = object.masterPubKey ?? "";
- message.derivedKeyIndex = object.derivedKeyIndex ?? 0;
- message.derivedPubKey = object.derivedPubKey ?? "";
- message.walletToEncDerivedKey = Object.entries(object.walletToEncDerivedKey ?? {}).reduce<
- { [key: string]: WalletToEncDerivedKey }
- >((acc, [key, value]) => {
- if (value !== undefined) {
- acc[key] = WalletToEncDerivedKey.fromPartial(value);
- }
- return acc;
- }, {});
- return message;
- },
-};
-
-function createBaseInitDid_WalletToEncDerivedKeyEntry(): InitDid_WalletToEncDerivedKeyEntry {
- return { key: "", value: undefined };
-}
-
-export const InitDid_WalletToEncDerivedKeyEntry: MessageFns = {
- encode(message: InitDid_WalletToEncDerivedKeyEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.key !== "") {
- writer.uint32(10).string(message.key);
- }
- if (message.value !== undefined) {
- WalletToEncDerivedKey.encode(message.value, writer.uint32(18).fork()).join();
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): InitDid_WalletToEncDerivedKeyEntry {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseInitDid_WalletToEncDerivedKeyEntry();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.key = reader.string();
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.value = WalletToEncDerivedKey.decode(reader, reader.uint32());
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): InitDid_WalletToEncDerivedKeyEntry {
- return {
- key: isSet(object.key) ? globalThis.String(object.key) : "",
- value: isSet(object.value) ? WalletToEncDerivedKey.fromJSON(object.value) : undefined,
- };
- },
-
- toJSON(message: InitDid_WalletToEncDerivedKeyEntry): unknown {
- const obj: any = {};
- if (message.key !== "") {
- obj.key = message.key;
- }
- if (message.value !== undefined) {
- obj.value = WalletToEncDerivedKey.toJSON(message.value);
- }
- return obj;
- },
-
- create, I>>(
- base?: I,
- ): InitDid_WalletToEncDerivedKeyEntry {
- return InitDid_WalletToEncDerivedKeyEntry.fromPartial(base ?? ({} as any));
- },
- fromPartial, I>>(
- object: I,
- ): InitDid_WalletToEncDerivedKeyEntry {
- const message = createBaseInitDid_WalletToEncDerivedKeyEntry();
- message.key = object.key ?? "";
- message.value = (object.value !== undefined && object.value !== null)
- ? WalletToEncDerivedKey.fromPartial(object.value)
- : undefined;
- return message;
- },
-};
-
-function bytesFromBase64(b64: string): Uint8Array {
- if ((globalThis as any).Buffer) {
- return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
- } else {
- const bin = globalThis.atob(b64);
- const arr = new Uint8Array(bin.length);
- for (let i = 0; i < bin.length; ++i) {
- arr[i] = bin.charCodeAt(i);
- }
- return arr;
- }
-}
-
-function base64FromBytes(arr: Uint8Array): string {
- if ((globalThis as any).Buffer) {
- return globalThis.Buffer.from(arr).toString("base64");
- } else {
- const bin: string[] = [];
- arr.forEach((byte) => {
- bin.push(globalThis.String.fromCharCode(byte));
- });
- return globalThis.btoa(bin.join(""));
- }
-}
-
-type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
-
-export type DeepPartial = T extends Builtin ? T
- : T extends globalThis.Array ? globalThis.Array>
- : T extends ReadonlyArray ? ReadonlyArray>
- : T extends {} ? { [K in keyof T]?: DeepPartial }
- : Partial;
-
-type KeysOfUnion = T extends T ? keyof T : never;
-export type Exact = P extends Builtin ? P
- : P & { [K in keyof P]: Exact
} & { [K in Exclude>]: never };
-
-function isObject(value: any): boolean {
- return typeof value === "object" && value !== null;
-}
-
-function isSet(value: any): boolean {
- return value !== null && value !== undefined;
-}
-
-export interface MessageFns {
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
- decode(input: BinaryReader | Uint8Array, length?: number): T;
- fromJSON(object: any): T;
- toJSON(message: T): unknown;
- create, I>>(base?: I): T;
- fromPartial, I>>(object: I): T;
-}
diff --git a/packages/core/src/lib/generated/txData/init_session_key.ts b/packages/core/src/lib/generated/txData/init_session_key.ts
deleted file mode 100644
index e778f163..00000000
--- a/packages/core/src/lib/generated/txData/init_session_key.ts
+++ /dev/null
@@ -1,166 +0,0 @@
-// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
-// versions:
-// protoc-gen-ts_proto v2.2.4
-// protoc v3.20.3
-// source: txData/init_session_key.proto
-
-/* eslint-disable */
-import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
-
-export const protobufPackage = "push";
-
-export enum KeyAction {
- PUBLISH_KEY = 0,
- REVOKE_KEY = 1,
- UNRECOGNIZED = -1,
-}
-
-export function keyActionFromJSON(object: any): KeyAction {
- switch (object) {
- case 0:
- case "PUBLISH_KEY":
- return KeyAction.PUBLISH_KEY;
- case 1:
- case "REVOKE_KEY":
- return KeyAction.REVOKE_KEY;
- case -1:
- case "UNRECOGNIZED":
- default:
- return KeyAction.UNRECOGNIZED;
- }
-}
-
-export function keyActionToJSON(object: KeyAction): string {
- switch (object) {
- case KeyAction.PUBLISH_KEY:
- return "PUBLISH_KEY";
- case KeyAction.REVOKE_KEY:
- return "REVOKE_KEY";
- case KeyAction.UNRECOGNIZED:
- default:
- return "UNRECOGNIZED";
- }
-}
-
-export interface InitSessionKey {
- keyIndex: number;
- keyAddress: string;
- action: KeyAction;
-}
-
-function createBaseInitSessionKey(): InitSessionKey {
- return { keyIndex: 0, keyAddress: "", action: 0 };
-}
-
-export const InitSessionKey: MessageFns = {
- encode(message: InitSessionKey, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.keyIndex !== 0) {
- writer.uint32(8).int32(message.keyIndex);
- }
- if (message.keyAddress !== "") {
- writer.uint32(18).string(message.keyAddress);
- }
- if (message.action !== 0) {
- writer.uint32(24).int32(message.action);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): InitSessionKey {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseInitSessionKey();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 8) {
- break;
- }
-
- message.keyIndex = reader.int32();
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.keyAddress = reader.string();
- continue;
- }
- case 3: {
- if (tag !== 24) {
- break;
- }
-
- message.action = reader.int32() as any;
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): InitSessionKey {
- return {
- keyIndex: isSet(object.keyIndex) ? globalThis.Number(object.keyIndex) : 0,
- keyAddress: isSet(object.keyAddress) ? globalThis.String(object.keyAddress) : "",
- action: isSet(object.action) ? keyActionFromJSON(object.action) : 0,
- };
- },
-
- toJSON(message: InitSessionKey): unknown {
- const obj: any = {};
- if (message.keyIndex !== 0) {
- obj.keyIndex = Math.round(message.keyIndex);
- }
- if (message.keyAddress !== "") {
- obj.keyAddress = message.keyAddress;
- }
- if (message.action !== 0) {
- obj.action = keyActionToJSON(message.action);
- }
- return obj;
- },
-
- create, I>>(base?: I): InitSessionKey {
- return InitSessionKey.fromPartial(base ?? ({} as any));
- },
- fromPartial, I>>(object: I): InitSessionKey {
- const message = createBaseInitSessionKey();
- message.keyIndex = object.keyIndex ?? 0;
- message.keyAddress = object.keyAddress ?? "";
- message.action = object.action ?? 0;
- return message;
- },
-};
-
-type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
-
-export type DeepPartial = T extends Builtin ? T
- : T extends globalThis.Array ? globalThis.Array>
- : T extends ReadonlyArray ? ReadonlyArray>
- : T extends {} ? { [K in keyof T]?: DeepPartial }
- : Partial;
-
-type KeysOfUnion = T extends T ? keyof T : never;
-export type Exact = P extends Builtin ? P
- : P & { [K in keyof P]: Exact
} & { [K in Exclude>]: never };
-
-function isSet(value: any): boolean {
- return value !== null && value !== undefined;
-}
-
-export interface MessageFns {
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
- decode(input: BinaryReader | Uint8Array, length?: number): T;
- fromJSON(object: any): T;
- toJSON(message: T): unknown;
- create, I>>(base?: I): T;
- fromPartial, I>>(object: I): T;
-}
diff --git a/packages/core/src/lib/index.ts b/packages/core/src/lib/index.ts
deleted file mode 100644
index 5850e833..00000000
--- a/packages/core/src/lib/index.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { PushNetwork } from './pushNetwork';
-import { Block } from './block/block';
-import { Tx } from './tx/tx';
-import { Validator } from './validator/validator';
-import { Address } from './address/address';
-import { CONSTANTS } from './constants';
-
-/**
- * FOR ADVANCE USECASES
- * serialization / deserialization capabilities for block & tx
- * Validator calls
- */
-export { CONSTANTS, Block, Tx, Validator, Address, PushNetwork };
diff --git a/packages/core/src/lib/pushNetwork.ts b/packages/core/src/lib/pushNetwork.ts
deleted file mode 100644
index 15edc439..00000000
--- a/packages/core/src/lib/pushNetwork.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Block } from './block/block';
-import { ENV } from './constants';
-import { Tx } from './tx/tx';
-import { Wallet } from './wallet/wallet';
-
-export class PushNetwork {
- private constructor(
- public block: Block,
- public tx: Tx,
- public wallet: Wallet
- ) {}
-
- static initialize = async (env: ENV = ENV.STAGING) => {
- const block = await Block.initialize(env);
- const tx = await Tx.initialize(env);
- const wallet = new Wallet(env);
- return new PushNetwork(block, tx, wallet);
- };
-}
diff --git a/packages/core/src/lib/tx/tx.ts b/packages/core/src/lib/tx/tx.ts
deleted file mode 100644
index b9ecc196..00000000
--- a/packages/core/src/lib/tx/tx.ts
+++ /dev/null
@@ -1,211 +0,0 @@
-import { v4 as uuidv4, parse } from 'uuid';
-import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
-import { ReplyGrouped, TxCategory } from './tx.types';
-import { Transaction } from '../generated/tx';
-import { InitDid } from '../generated/txData/init_did';
-import { InitSessionKey } from '../generated/txData/init_session_key';
-import { ENV } from '../constants';
-import { Validator } from '../validator/validator';
-import { TokenReply } from '../validator/validator.types';
-import { BlockResponse } from '../block/block.types';
-import { sha256 } from '@noble/hashes/sha256';
-import { toHex } from 'viem';
-export class Tx {
- private constructor(private validator: Validator, private env: ENV) {}
-
- static initialize = async (env: ENV) => {
- const validator = await Validator.initalize({ env });
- return new Tx(validator, env);
- };
-
- static serialize = (tx: Transaction): Uint8Array => {
- const transaction = Transaction.create(tx);
- return Transaction.encode(transaction).finish();
- };
-
- static deserialize = (tx: Uint8Array): Transaction => {
- return Transaction.decode(tx);
- };
-
- static serializeData = (
- txData: InitDid | InitSessionKey,
- category: TxCategory
- ): Uint8Array => {
- switch (category) {
- case TxCategory.INIT_DID: {
- const data = txData as InitDid;
- const initTxData = InitDid.create(data);
- return InitDid.encode(initTxData).finish();
- }
- case TxCategory.INIT_SESSION_KEY: {
- const data = txData as InitSessionKey;
- const initTxData = InitSessionKey.create(data);
- return InitSessionKey.encode(initTxData).finish();
- }
- default: {
- throw new Error('Serialization Not Supported for given TxCateory');
- }
- }
- };
-
- static deserializeData = (
- txData: Uint8Array,
- category: TxCategory
- ): InitDid | InitSessionKey => {
- switch (category) {
- case TxCategory.INIT_DID: {
- return InitDid.decode(txData);
- }
- case TxCategory.INIT_SESSION_KEY: {
- return InitSessionKey.decode(txData);
- }
- default: {
- throw new Error('Deserialization Not Supported for given TxCateory');
- }
- }
- };
-
- /**
- * Create an Unsigned Tx
- * @dev Unsigned Tx has empty sender & signature
- * @param category Tx category
- * @param recipients Tx recipients
- * @param data Tx payload data in serialized form
- * @returns Unsigned Tx
- */
- createUnsigned = (
- category: string,
- recipients: string[],
- data: Uint8Array
- ): Transaction => {
- return Transaction.create({
- type: 0, // Phase 0 only has non-value transfers
- category,
- recipients,
- data,
- salt: parse(uuidv4()),
- fee: '0', // Fee is 0 as of now
- });
- };
-
- /**
- * Get Transactions
- */
- get = async (
- startTime: number = Math.floor(Date.now()), // Current Local Time
- direction: 'ASC' | 'DESC' = 'DESC',
- pageSize = 30,
- page = 1,
- // caip10 address
- userAddress?: string,
- category?: string
- ) => {
- return userAddress === undefined
- ? await this.validator.call('push_getTransactions', [
- startTime,
- direction,
- pageSize,
- page,
- category,
- ])
- : await this.validator.call('push_getTransactionsByUser', [
- userAddress,
- startTime,
- direction,
- pageSize,
- page,
- category,
- ]);
- };
-
- /**
- * Get Transactions by Sender
- */
- getBySender = async (
- // caip10 address
- senderAddress: string,
- startTime: number = Math.floor(Date.now() / 1000), // Current Local Time
- direction: 'ASC' | 'DESC' = 'ASC',
- pageSize = 30,
- page = 1,
- category?: string
- ) => {
- return await this.validator.call(
- 'push_getTransactionsBySender',
- [senderAddress, startTime, direction, pageSize, page, category]
- );
- };
-
- /**
- * Get Transactions by Recipient
- */
- getByRecipient = async (
- // caip10 address
- recipientAddress: string,
- startTime: number = Math.floor(Date.now() / 1000), // Current Local Time
- direction: 'ASC' | 'DESC' = 'ASC',
- pageSize = 30,
- page = 1,
- category?: string
- ) => {
- return await this.validator.call(
- 'push_getTransactionsByRecipient',
- [recipientAddress, startTime, direction, pageSize, page, category]
- );
- };
-
- /**
- * Search Transaction with a given hash
- * @param txHash
- */
- search = async (txHash: string) => {
- return await this.validator.call(
- 'push_getTransactionByHash',
- [txHash]
- );
- };
-
- /**
- * Send Tx to Push Network
- * @param tx Unsigned Push Tx
- * @param signer Signer obj to sign the Tx
- * @returns Tx Hash
- */
- send = async (
- unsignedTx: Transaction,
- signer: {
- account: string;
- signMessage: (dataToBeSigned: Uint8Array) => Promise;
- }
- ): Promise => {
- const token = await this.validator.call('push_getApiToken');
- const serializedUnsignedTx = Tx.serialize({
- ...unsignedTx,
- sender: signer.account,
- signature: new Uint8Array(0),
- apiToken: utf8ToBytes(token.apiToken),
- });
-
- // Convert 32 byte data to 64 byte data ( UTF-8 encoded )
- const dataToBeSigned = new TextEncoder().encode(
- toHex(sha256(serializedUnsignedTx))
- );
- const signature = await signer.signMessage(dataToBeSigned);
- const serializedSignedTx = Tx.serialize({
- ...Tx.deserialize(serializedUnsignedTx),
- signature,
- });
- return await this.validator.call(
- 'push_sendTransaction',
- [bytesToHex(serializedSignedTx)],
- token.apiUrl
- );
- };
-
- /**
- * Get Transactions
- */
- async getTransactionsFromVNode(accountInCaip: string, category: string, ts: string = '' + Math.floor(Date.now()/1000), direction: 'ASC' | 'DESC' = 'DESC') {
- return await this.validator.callVNode('push_getTransactions', [accountInCaip, category, ts, direction]);
- }
-}
diff --git a/packages/core/src/lib/tx/tx.types.ts b/packages/core/src/lib/tx/tx.types.ts
deleted file mode 100644
index 798944a7..00000000
--- a/packages/core/src/lib/tx/tx.types.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-// TxCategory supported for Serealization / Deserealization by core
-export enum TxCategory {
- INIT_DID = 'INIT_DID',
- INIT_SESSION_KEY = 'INIT_SESSION_KEY',
-}
-
-export type TxResponse = {
- txnHash: string;
- ts: number;
- /**@dev - Null In case of rejected Tx */
- blockHash: string | null;
- category: string;
- sender: string;
- status: 'SUCCESS' | 'REJECTED';
- recipients: string[];
- txnData: string;
- sig: string;
-};
-
-
-export class ReplyGrouped {
- items: TxInfo[] = [];
- summary: ResultMeta = new ResultMeta();
-}
-
-export class ResultMeta {
- quorumResult!: QuorumResult;
- itemCount!: number;
- lastTs!: string;
- keysWithoutQuorumCount!: number;
- keysWithoutQuorum!: string[];
-}
-
-export enum QuorumResult {
- QUORUM_OK = 'QUORUM_OK',
- QUORUM_OK_PARTIAL = 'QUORUM_OK_PARTIAL',
- QUORUM_FAILED_NODE_REPLIES = 'QUORUM_FAILED_NODE_REPLIES',
- QUORUM_FAILED_BY_MIN_ITEMS = 'QUORUM_FAILED_BY_MIN_ITEMS',
-}
-
-export type TxInfo = {
- type: number;
- category: string;
- sender: string;
- recipients: string[];
- data: string;
- ts: string;
- salt: string;
-};
\ No newline at end of file
diff --git a/packages/core/src/lib/utils/index.ts b/packages/core/src/lib/utils/index.ts
deleted file mode 100644
index 60ab08a5..00000000
--- a/packages/core/src/lib/utils/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export const getRandomElement = (array: T[]): T => {
- if (array.length === 0) {
- throw new Error('Array cannot be empty');
- }
- const randomIndex = Math.floor(Math.random() * array.length);
- return array[randomIndex];
-};
diff --git a/packages/core/src/lib/validator/validator.ts b/packages/core/src/lib/validator/validator.ts
deleted file mode 100644
index 10fe8ddb..00000000
--- a/packages/core/src/lib/validator/validator.ts
+++ /dev/null
@@ -1,283 +0,0 @@
-import { getRandomElement } from '../utils';
-import {
- ActiveValidator,
- JsonRpcRequest,
- JsonRpcResponse,
- ValidatorContract,
-} from './validator.types';
-import axios from 'axios';
-import { createPublicClient, getContract, http } from 'viem';
-import config from '../config';
-import { ENV } from '../constants';
-
-/**
- * @description Push validator class is used for the following:
- * - Interact with validator.sol ( Only Read calls )
- * - Get token to interact with a random validator node
- * - Ping a random validator node to check if it is alive
- *
- *
- * todo rename to transport
- * we're talking to 3 very different entities
- * Validator.sol
- * anodes
- * vnodes
- * !
- * the 'validator' name does not represent the right thing here
- *
- */
-export class Validator {
- private static instance: Validator;
- private static idCounter = 0;
- private static printTraces = false;
-
- private constructor(
- /**
- * @dev - active validator URL ( Used for Get calls to a validator node )
- */
- private activeValidatorURL: string,
- private env: ENV,
- private validatorContractClient: ValidatorContract
- ) {
- if (this.env === ENV.DEV || this.env === ENV.LOCAL) {
- Validator.printTraces = true;
- }
- }
-
- static initalize = async (options?: { env?: ENV }): Promise => {
- const settings = {
- env: options?.env || ENV.STAGING,
- };
-
- /**
- * @dev - If instance is not created or env is different, create a new instance
- */
- if (!Validator.instance || Validator.instance.env !== settings.env) {
- const validatorContractClient = Validator.createValidatorContractClient(
- settings.env
- );
- const activeValidator = await Validator.getActiveValidator(
- validatorContractClient
- );
- Validator.instance = new Validator(
- activeValidator.nodeApiBaseUrl,
- settings.env,
- validatorContractClient
- );
- }
- return Validator.instance;
- };
-
- /**
- * @description Create validator contract client
- * @param env - Environment
- * @dev - Currently only supports public client
- * @returns Validator contract client
- */
- private static createValidatorContractClient = (
- env: ENV
- ): ValidatorContract => {
- const client = createPublicClient({
- chain: config.VALIDATOR[env].NETWORK,
- transport: http(
- 'https://proportionate-multi-sanctuary.ethereum-sepolia.quiknode.pro/fe3638bd884a34c0aa6c85ce2cd62ef54b0d8442/'
- ),
- });
- return getContract({
- abi: config.ABIS.VALIDATOR,
- address: config.VALIDATOR[env].VALIDATOR_CONTRACT as `0x${string}`,
- client: {
- // Viem type causes issue with some codebases
- public: client as never,
- },
- }) as unknown as ValidatorContract;
- };
-
- /**
- * @description - Send a JSON RPC Req
- */
- private static sendJsonRpcRequest = async (
- url: string,
- method: string,
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- params: any = []
- ): Promise => {
- const requestBody: JsonRpcRequest = {
- jsonrpc: '2.0',
- method,
- params,
- id: this.idCounter++,
- };
-
- try {
- if (this.printTraces) {
- console.log(
- `>> Calling RPC POST ${url} (req${requestBody.id}) with body %o`,
- requestBody
- );
- }
- const response = await axios.post>(url, requestBody, {
- timeout: 5000,
- headers: { 'Content-Type': 'application/json' },
- });
-
- if (response.data.error) {
- console.error('JSON-RPC Error:', response.data.error);
- throw Error(response.data.error.message);
- }
- if (this.printTraces) {
- console.log(
- `<< RPC Reply POST ${url} (req${requestBody.id}) code: ${response.status} with body: %o`,
- response?.data
- );
- }
- return response.data.result;
- } catch (error) {
- console.error('Error sending JSON-RPC request:', error);
- throw error;
- }
- };
-
- /**
- * @description Ping a validator
- * @param validatorUrl - Validator URL to ping
- */
- private static ping = async (validatorUrl: string): Promise => {
- return await this.sendJsonRpcRequest(
- Validator.vNodeUrlModifier(validatorUrl),
- 'push_listening'
- );
- };
-
- /**
- * @description Get active validator
- * @returns Active validator object
- */
- private static getActiveValidator = async (
- validatorContractClient: ValidatorContract
- ): Promise => {
- const activeValidators =
- await validatorContractClient.read.getActiveVNodes();
- const validator = getRandomElement(activeValidators);
- const isListening = await this.ping(validator.nodeApiBaseUrl);
- if (isListening) {
- return validator;
- } else {
- return await this.getActiveValidator(validatorContractClient);
- }
- };
-
- private static vNodeUrlModifier = (url: string) => {
- let modifiedUrl = url;
- if (url.includes('.local')) {
- modifiedUrl = url.replace('.local', '.localh');
- }
- return `${modifiedUrl}/api/v1/rpc`;
- };
-
- /**
- * @dev - This is a Temp Function which will be removed in the future
- */
- private ReqModifier = (url: string, fnName: string) => {
- let modifiedUrl = Validator.vNodeUrlModifier(url);
- let modifiedFnName = fnName;
- if (
- fnName === 'push_getBlocks' ||
- fnName === 'push_getBlockByHash' ||
- fnName === 'push_getTransactions' ||
- fnName === 'push_getTransactionByHash' ||
- fnName === 'push_getTransactionsByUser' ||
- fnName === 'push_getTransactionsBySender' ||
- fnName === 'push_getTransactionsByRecipient'
- ) {
- if (this.env === ENV.LOCAL) {
- modifiedUrl = 'http://localhost:5001/rpc';
- }
- if (this.env === ENV.DEV) {
- modifiedUrl = 'https://aa1.dev.push.org/rpc';
- }
- modifiedFnName = `RpcService.${fnName.replace('push_', '')}`;
-
- if (fnName === 'push_getTransactions') {
- modifiedFnName = 'RpcService.getTxs';
- }
- if (fnName === 'push_getTransactionsByUser') {
- modifiedFnName = 'RpcService.getTransactionsByUser';
- }
- if (fnName === 'push_getTransactionsBySender') {
- modifiedFnName = 'RpcService.getTxsBySender';
- }
- if (fnName === 'push_getTransactionsByRecipient') {
- modifiedFnName = 'RpcService.getTxsByRecipient';
- }
- if (fnName === 'push_getTransactionByHash') {
- modifiedFnName = 'RpcService.getTxByHash';
- }
- }
- return { url: modifiedUrl, fnName: modifiedFnName };
- };
-
- /**
- * @description Get calls to validator
- * @returns Reply of the call
- *
- * todo rename to callANode
- */
- public call = async (
- fnName: string,
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- params: any[] = [],
- url: string = this.activeValidatorURL
- ): Promise => {
- return await Validator.sendJsonRpcRequest(
- this.ReqModifier(url, fnName).url,
- this.ReqModifier(url, fnName).fnName,
- params
- );
- };
-
- /**
- * @description Get calls to validator without any modifications
- * @returns Reply of the call
- */
- public async callVNode(
- fnName: string,
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- params: any[] = [],
- vNodeUrl: string = this.activeValidatorURL
- ): Promise {
- // url = "https://vv1.dev.push.org/api/v1/rpc/"
- const apiUrl = Validator.fixVNodeUrl(vNodeUrl);
- return await Validator.sendJsonRpcRequest(apiUrl, fnName, params);
- }
-
- /**
- * Applies 4 rules to url
- * 1) .local -> replace everything with localhost
- * 2) http -> replace with https
- * 3) domain.com -> appends /api/v1/rpc path
- * 4) domain.com/api/ -> replace with domain.com/api
- *
- * @param url - url to fix
- */
- private static fixVNodeUrl(url: string) {
- if (url == null || url.length == 0) {
- return url;
- }
- const urlObj = new URL(url);
- const isLocal = urlObj.hostname.endsWith('.local');
- if (isLocal) {
- urlObj.hostname = 'localhost';
- urlObj.protocol = 'http:';
- } else {
- urlObj.protocol = 'https:';
- }
- if (urlObj.pathname.trim().length == 0 || urlObj.pathname.trim() === '/') {
- urlObj.pathname = '/api/v1/rpc';
- }
- if (urlObj.pathname.endsWith('/')) {
- urlObj.pathname = urlObj.pathname.slice(0, -1);
- }
- return urlObj.toString();
- }
-}
diff --git a/packages/core/src/lib/validator/validator.types.ts b/packages/core/src/lib/validator/validator.types.ts
deleted file mode 100644
index 7e8b65fa..00000000
--- a/packages/core/src/lib/validator/validator.types.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-export type TokenReply = { apiToken: string; apiUrl: string };
-
-export type PingReply = {
- nodeId: string;
- tsMillis: number;
- status: string;
-};
-
-export type ActiveValidator = {
- nodeWallet: string;
- nodeApiBaseUrl: string;
-};
-
-/**
- * @description Validator contract interface ( VIEM CLIENT )
- */
-export type ValidatorContract = {
- read: {
- getActiveVNodes(): Promise;
- nodeMap(address: string): Promise;
- };
-};
-
-export type JsonRpcRequest = {
- jsonrpc: string;
- method: string;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- params?: any;
- id: number;
-};
-
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export type JsonRpcResponse = {
- jsonrpc: string;
- result: T;
- id: number;
- error?: {
- code: number;
- message: string;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- data?: any;
- };
-};
-
-type NodeInfo = {
- ownerWallet: string;
- nodeWallet: string;
- nodeType: NodeType;
- nodeApiBaseUrl: string;
- status: NodeStatus;
-};
-
-enum NodeType {
- VNode = 0, // validator 0
- SNode = 1, // storage 1
- DNode = 2, // delivery 2
-}
-
-enum NodeStatus {
- OK,
- Reported,
- Slashed,
- BannedAndUnstaked,
- Unstaked,
-}
diff --git a/packages/core/src/lib/wallet/wallet.ts b/packages/core/src/lib/wallet/wallet.ts
deleted file mode 100644
index 201a7ec3..00000000
--- a/packages/core/src/lib/wallet/wallet.ts
+++ /dev/null
@@ -1,151 +0,0 @@
-import config from '../config';
-import { ENV } from '../constants';
-import { ACTION } from './wallet.types';
-
-export class Wallet {
- private walletWindow: Window | null = null;
-
- constructor(private env: ENV) {}
-
- /**
- * @returns The connected CAIP wallet address
- * @dev - Errors out if user is not logged in
- */
- connect = async () => {
- await this.openWalletWindow();
- return await this.requestWalletAddress();
- };
-
- /**
- * Request Signature from Push Wallet
- */
- sign = async (data: Uint8Array): Promise => {
- await this.openWalletWindow();
-
- const { isPending, isConnected } = await this.appConnectionStatus();
- if (!isConnected) {
- if (isPending) {
- throw Error(
- 'App Connection Request is Pending. Accept App Connection Request in Push Wallet to enable signing !!!'
- );
- } else {
- await this.requestAppConnection();
- throw Error(
- 'App not Connected. Accept App Connection Request in Push Wallet to enable signing !!!'
- );
- }
- }
-
- return new Promise((resolve, reject) => {
- // Listen for wallet response
- window.addEventListener('message', function listener(event) {
- if (event.data.action === ACTION.SIGNATURE) {
- window.removeEventListener('message', listener);
- resolve(event.data.signature); // Signature returned
- } else if (event.data.action === ACTION.ERROR) {
- window.removeEventListener('message', listener);
- reject(event.data.error); // Handle error
- }
- });
-
- // Request wallet to sign data
- (this.walletWindow as Window).postMessage(
- {
- action: ACTION.REQ_TO_SIGN,
- data,
- },
- config.WALLET_URL[this.env]
- );
- });
- };
-
- /**
- * Get Dapp connection status to Push Wallet
- */
- appConnectionStatus = (): Promise<{
- isConnected: boolean;
- isPending: boolean;
- }> => {
- return new Promise((resolve, reject) => {
- // Listen for wallet response
- window.addEventListener('message', function listener(event) {
- if (event.data.action === ACTION.CONNECTION_STATUS) {
- window.removeEventListener('message', listener);
- resolve(event.data);
- } else if (event.data.action === ACTION.ERROR) {
- window.removeEventListener('message', listener);
- reject(event.data.error); // Handle error
- }
- });
-
- // Request wallet to sign data
- this.walletWindow?.postMessage(
- {
- action: ACTION.IS_CONNECTED,
- },
- config.WALLET_URL[this.env]
- );
- });
- };
-
- /**
- * Request connection to Push Wallet
- */
- requestAppConnection = (): Promise<{
- isConnected: boolean;
- isPending: boolean;
- }> => {
- return new Promise((resolve, reject) => {
- // Listen for wallet response
- window.addEventListener('message', function listener(event) {
- if (event.data.action === ACTION.CONNECTION_STATUS) {
- window.removeEventListener('message', listener);
- resolve(event.data);
- } else if (event.data.action === ACTION.ERROR) {
- window.removeEventListener('message', listener);
- reject(event.data.error); // Handle error
- }
- });
- this.walletWindow?.postMessage(
- {
- action: ACTION.REQ_TO_CONNECT,
- },
- config.WALLET_URL[this.env]
- );
- });
- };
-
- private openWalletWindow = async () => {
- // Check if the wallet window is already open
- if (!this.walletWindow || this.walletWindow.closed) {
- this.walletWindow = window.open(config.WALLET_URL[this.env], '_blank');
- if (!this.walletWindow) {
- throw new Error('Failed to open wallet window');
- }
- // Time Given for tab to Load
- await new Promise((resolve) => setTimeout(resolve, 2000));
- }
- };
-
- /**
- * Request Logged In Address from Push Wallet
- */
- private requestWalletAddress = (): Promise => {
- return new Promise((resolve, reject) => {
- // Listen for wallet response
- window.addEventListener('message', function listener(event) {
- if (event.data.action === ACTION.WALLET_DETAILS) {
- window.removeEventListener('message', listener);
- resolve(event.data.address); // Wallet address returned
- } else if (event.data.action === ACTION.ERROR) {
- window.removeEventListener('message', listener);
- reject(event.data.error); // Handle error
- }
- });
- this.walletWindow?.postMessage(
- { action: ACTION.REQ_WALLET_DETAILS },
- config.WALLET_URL[this.env]
- );
- });
- };
-}
diff --git a/packages/core/src/lib/wallet/wallet.types.ts b/packages/core/src/lib/wallet/wallet.types.ts
deleted file mode 100644
index 36a1d34c..00000000
--- a/packages/core/src/lib/wallet/wallet.types.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export enum ACTION {
- IS_CONNECTED = 'isConnected',
- REQ_TO_CONNECT = 'reqToConnect',
- REQ_TO_SIGN = 'reqToSign',
- REQ_WALLET_DETAILS = 'reqWalletDetails',
-
- ERROR = 'error',
- CONNECTION_STATUS = 'connectionStatus',
- WALLET_DETAILS = 'walletDetails',
- SIGNATURE = 'signature',
-}
diff --git a/packages/core/tests/address/address.test.ts b/packages/core/tests/address/address.test.ts
deleted file mode 100644
index 0d9da9fe..00000000
--- a/packages/core/tests/address/address.test.ts
+++ /dev/null
@@ -1,94 +0,0 @@
-import { Address } from '../../src/lib/address/address'; // Adjust the import path accordingly
-import { ENV } from '../../src/lib/constants';
-
-describe('Address', () => {
- const evmAddress = '0x35B84d6848D16415177c64D64504663b998A6ab4';
- const pushAddress = 'push1xkuy66zg69jp29muvnty2prx8wvc5645f9y5ux';
- const customPushAddress = 'custom1xkuy66zg69jp29muvnty2prx8wvc5645hlgxkx';
- const solanaAddress = '69EUYJKr2NE8vHFphyRPSU2tqRbXhMu9gzNo96mjvFLv';
-
- describe('evmToPush', () => {
- it('should convert a valid EVM address to a Push address', () => {
- const result = Address.evmToPush(evmAddress);
- expect(result).toEqual(pushAddress);
- });
-
- it('should throw an error for invalid EVM addresses', () => {
- const invalidAddress = '0xinvalidaddress';
- expect(() => Address.evmToPush(invalidAddress)).toThrow();
- });
-
- it('should convert a valid EVM address to a Push address with a custom prefix', () => {
- const customPrefix = 'custom';
- const result = Address.evmToPush(evmAddress, customPrefix);
- expect(result).toEqual(customPushAddress);
- });
- });
-
- describe('pushToEvm', () => {
- it('should convert a valid Push address back to an EVM address', () => {
- const result = Address.pushToEvm(pushAddress);
- expect(result).toEqual(evmAddress);
- });
-
- it('should throw an error for invalid Push addresses', () => {
- const invalidPushAddress = 'pushinvalidaddress';
- expect(() => Address.pushToEvm(invalidPushAddress)).toThrow();
- });
- });
-
- describe('toPushCAIP', () => {
- it('should convert evm address to Push Devnet CAIP', () => {
- const result1 = Address.toPushCAIP(evmAddress, ENV.LOCAL);
- const result2 = Address.toPushCAIP(evmAddress, ENV.DEV);
- expect(result1).toEqual(result2);
- expect(result1).toEqual(`push:devnet:${pushAddress}`);
- });
- it('should convert evm address to Push Testnet CAIP', () => {
- const result = Address.toPushCAIP(evmAddress, ENV.STAGING);
- expect(result).toEqual(`push:testnet:${pushAddress}`);
- });
- it('should convert evm address to Push Mainnet CAIP', () => {
- const result = Address.toPushCAIP(evmAddress, ENV.PROD);
- expect(result).toEqual(`push:mainnet:${pushAddress}`);
- });
- it('should convert push address to Push Devnet CAIP', () => {
- const result = Address.toPushCAIP(pushAddress, ENV.DEV);
- expect(result).toEqual(`push:devnet:${pushAddress}`);
- });
- it('should convert evm address to Push Testnet CAIP', () => {
- const result = Address.toPushCAIP(pushAddress, ENV.STAGING);
- expect(result).toEqual(`push:testnet:${pushAddress}`);
- });
- it('should convert evm address to Push Mainnet CAIP', () => {
- const result = Address.toPushCAIP(pushAddress, ENV.PROD);
- expect(result).toEqual(`push:mainnet:${pushAddress}`);
- });
- });
-
- describe('toCAIP', () => {
- it('should convert evm address to CAIP', () => {
- const result1 = Address.toCAIP(evmAddress, 1);
- expect(result1).toEqual(`eip155:1:${evmAddress}`);
- });
- it('should convert push address to CAIP', () => {
- const result1 = Address.toCAIP(pushAddress, 'devnet');
- expect(result1).toEqual(`push:devnet:${pushAddress}`);
- });
- it('should convert solana address to CAIP', () => {
- const result = Address.toCAIP(solanaAddress, 'devnet');
- expect(result).toEqual(
- `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1:${solanaAddress}`
- );
- });
- it('should throw an error for invalid network for EIP155 address', () => {
- expect(() => Address.toCAIP(evmAddress, 'devnet')).toThrow();
- });
- it('should throw an error for invalid network for push address', () => {
- expect(() => Address.toCAIP(pushAddress, 1)).toThrow();
- });
- it('should throw an error for invalid network for solana address', () => {
- expect(() => Address.toCAIP(solanaAddress, 1)).toThrow();
- });
- });
-});
diff --git a/packages/core/tests/block/block.test.ts b/packages/core/tests/block/block.test.ts
deleted file mode 100644
index 8746c7d9..00000000
--- a/packages/core/tests/block/block.test.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import { Block } from '../../src';
-import { config } from '../config';
-import { Block as BlockType } from '../../src/lib/generated/block';
-import { BlockType as NodeBlockType } from '../../src/lib/block/block.types';
-
-describe('Block Class', () => {
- const env = config.ENV;
-
- const sampleBlock: BlockType = {
- ts: Date.now(),
- txObj: [],
- signers: [],
- attestToken: new Uint8Array([1, 2, 3, 4]),
- };
-
- const blockChecker = (block: NodeBlockType) => {
- expect(block).toHaveProperty('blockHash');
- expect(block).toHaveProperty('blockData');
- expect(block).toHaveProperty('blockDataAsJson');
- expect(block).toHaveProperty('blockSize');
- expect(block).toHaveProperty('ts');
- expect(block).toHaveProperty('transactions');
- expect(block).toHaveProperty('totalNumberOfTxns');
- };
-
- it('should initialize a Block instance', async () => {
- const blockInstance = await Block.initialize(env);
- expect(blockInstance).toBeInstanceOf(Block);
- });
-
- it('should serialize a BlockType object into a Uint8Array', () => {
- const serializedBlock = Block.serialize(sampleBlock);
- expect(serializedBlock).toBeInstanceOf(Uint8Array);
- expect(serializedBlock.length).toBeGreaterThan(0);
- });
-
- it('should deserialize a Uint8Array into a BlockType object', () => {
- const serializedBlock = Block.serialize(sampleBlock);
- const deserializedBlock = Block.deserialize(serializedBlock);
- expect(deserializedBlock).toEqual(sampleBlock);
- });
-
- it('should get blocks with default parameters', async () => {
- const blockInstance = await Block.initialize(env);
- const res = await blockInstance.get();
- expect(res.blocks).toBeInstanceOf(Array);
- res.blocks.forEach((block) => {
- blockChecker(block);
- });
- });
-
- it('should get blocks with custom parameters', async () => {
- const blockInstance = await Block.initialize(env);
- const res = await blockInstance.get(
- Math.floor(Date.now() / 1000),
- 'DESC',
- true,
- 10,
- 2
- );
- expect(res.blocks).toBeInstanceOf(Array);
- res.blocks.forEach((block) => {
- blockChecker(block);
- });
- });
-
- it('should search for a block by hash', async () => {
- const blockInstance = await Block.initialize(env);
- const res = await blockInstance.get();
- const blockHash = res.blocks[0].blockHash;
- const searchRes = await blockInstance.search(blockHash);
- expect(searchRes.blocks).toBeInstanceOf(Array);
- expect(searchRes.blocks.length).toEqual(1);
- res.blocks.forEach((block) => {
- blockChecker(block);
- });
- });
-});
diff --git a/packages/core/tests/config.ts b/packages/core/tests/config.ts
deleted file mode 100644
index 425d6fe9..00000000
--- a/packages/core/tests/config.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { CONSTANTS } from '../src';
-
-export const config = {
- ENV: CONSTANTS.ENV.DEV,
-};
diff --git a/packages/core/tests/data/index.ts b/packages/core/tests/data/index.ts
deleted file mode 100644
index 9f5ef570..00000000
--- a/packages/core/tests/data/index.ts
+++ /dev/null
@@ -1,2625 +0,0 @@
-// Attached wallet in walletToEncryptedDerivedKey - push:devnet:push13lssnm7ps9acuf05erf7tmw78jy29hpkwgs7jh
-
-/**
- * Attched Wallets in walletToEncryptedDerivedKey map -
- * push:devnet:push13lssnm7ps9acuf05erf7tmw78jy29hpkwgs7jh - WITH WRONG SIGNATURE
- */
-export const INIT_DID_TX = {
- // The Public Key of this private key is present in the Tx Data as master Public Key
- masterPrivateKey:
- '0x91c43c4b8c89092b3d7c061168c05aeef288bf79c50dc91e0d0e858ba06383a3',
- unsignedInitDIDTx: {
- type: 0,
- category: 'INIT_DID',
- sender: '',
- recipients: [],
- data: new Uint8Array(
- Object.values({
- '0': 10,
- '1': 66,
- '2': 48,
- '3': 51,
- '4': 51,
- '5': 49,
- '6': 55,
- '7': 50,
- '8': 102,
- '9': 54,
- '10': 53,
- '11': 57,
- '12': 51,
- '13': 102,
- '14': 57,
- '15': 57,
- '16': 51,
- '17': 54,
- '18': 101,
- '19': 48,
- '20': 49,
- '21': 56,
- '22': 50,
- '23': 49,
- '24': 100,
- '25': 50,
- '26': 100,
- '27': 51,
- '28': 97,
- '29': 52,
- '30': 49,
- '31': 55,
- '32': 102,
- '33': 100,
- '34': 102,
- '35': 53,
- '36': 98,
- '37': 102,
- '38': 55,
- '39': 49,
- '40': 50,
- '41': 53,
- '42': 100,
- '43': 54,
- '44': 49,
- '45': 55,
- '46': 57,
- '47': 98,
- '48': 102,
- '49': 56,
- '50': 102,
- '51': 56,
- '52': 100,
- '53': 100,
- '54': 100,
- '55': 48,
- '56': 100,
- '57': 99,
- '58': 97,
- '59': 54,
- '60': 100,
- '61': 98,
- '62': 98,
- '63': 57,
- '64': 101,
- '65': 53,
- '66': 101,
- '67': 101,
- '68': 16,
- '69': 128,
- '70': 128,
- '71': 128,
- '72': 128,
- '73': 8,
- '74': 26,
- '75': 66,
- '76': 48,
- '77': 51,
- '78': 56,
- '79': 51,
- '80': 101,
- '81': 53,
- '82': 56,
- '83': 101,
- '84': 97,
- '85': 49,
- '86': 53,
- '87': 53,
- '88': 48,
- '89': 98,
- '90': 55,
- '91': 100,
- '92': 98,
- '93': 51,
- '94': 51,
- '95': 51,
- '96': 101,
- '97': 101,
- '98': 98,
- '99': 101,
- '100': 49,
- '101': 49,
- '102': 99,
- '103': 100,
- '104': 48,
- '105': 57,
- '106': 98,
- '107': 101,
- '108': 98,
- '109': 99,
- '110': 97,
- '111': 48,
- '112': 101,
- '113': 99,
- '114': 55,
- '115': 97,
- '116': 48,
- '117': 56,
- '118': 97,
- '119': 100,
- '120': 101,
- '121': 97,
- '122': 48,
- '123': 56,
- '124': 53,
- '125': 100,
- '126': 55,
- '127': 48,
- '128': 53,
- '129': 52,
- '130': 100,
- '131': 57,
- '132': 97,
- '133': 101,
- '134': 50,
- '135': 56,
- '136': 51,
- '137': 56,
- '138': 52,
- '139': 52,
- '140': 56,
- '141': 48,
- '142': 34,
- '143': 170,
- '144': 4,
- '145': 10,
- '146': 55,
- '147': 112,
- '148': 117,
- '149': 115,
- '150': 104,
- '151': 58,
- '152': 100,
- '153': 101,
- '154': 118,
- '155': 110,
- '156': 101,
- '157': 116,
- '158': 58,
- '159': 112,
- '160': 117,
- '161': 115,
- '162': 104,
- '163': 49,
- '164': 51,
- '165': 108,
- '166': 115,
- '167': 115,
- '168': 110,
- '169': 109,
- '170': 55,
- '171': 112,
- '172': 115,
- '173': 57,
- '174': 97,
- '175': 99,
- '176': 117,
- '177': 102,
- '178': 48,
- '179': 53,
- '180': 101,
- '181': 114,
- '182': 102,
- '183': 55,
- '184': 116,
- '185': 109,
- '186': 119,
- '187': 55,
- '188': 56,
- '189': 106,
- '190': 121,
- '191': 50,
- '192': 57,
- '193': 104,
- '194': 112,
- '195': 107,
- '196': 119,
- '197': 103,
- '198': 115,
- '199': 55,
- '200': 106,
- '201': 104,
- '202': 18,
- '203': 238,
- '204': 3,
- '205': 10,
- '206': 168,
- '207': 3,
- '208': 10,
- '209': 254,
- '210': 1,
- '211': 53,
- '212': 51,
- '213': 49,
- '214': 100,
- '215': 102,
- '216': 102,
- '217': 51,
- '218': 55,
- '219': 48,
- '220': 101,
- '221': 53,
- '222': 97,
- '223': 97,
- '224': 55,
- '225': 57,
- '226': 97,
- '227': 52,
- '228': 102,
- '229': 99,
- '230': 50,
- '231': 54,
- '232': 57,
- '233': 98,
- '234': 52,
- '235': 99,
- '236': 49,
- '237': 49,
- '238': 54,
- '239': 54,
- '240': 97,
- '241': 56,
- '242': 49,
- '243': 101,
- '244': 102,
- '245': 54,
- '246': 54,
- '247': 57,
- '248': 52,
- '249': 53,
- '250': 100,
- '251': 57,
- '252': 99,
- '253': 53,
- '254': 53,
- '255': 53,
- '256': 98,
- '257': 57,
- '258': 56,
- '259': 51,
- '260': 98,
- '261': 51,
- '262': 51,
- '263': 56,
- '264': 53,
- '265': 56,
- '266': 53,
- '267': 55,
- '268': 97,
- '269': 48,
- '270': 48,
- '271': 56,
- '272': 98,
- '273': 56,
- '274': 102,
- '275': 52,
- '276': 55,
- '277': 49,
- '278': 55,
- '279': 56,
- '280': 50,
- '281': 102,
- '282': 102,
- '283': 51,
- '284': 52,
- '285': 52,
- '286': 53,
- '287': 102,
- '288': 101,
- '289': 51,
- '290': 98,
- '291': 102,
- '292': 51,
- '293': 56,
- '294': 53,
- '295': 56,
- '296': 97,
- '297': 102,
- '298': 48,
- '299': 51,
- '300': 101,
- '301': 50,
- '302': 48,
- '303': 50,
- '304': 49,
- '305': 101,
- '306': 53,
- '307': 56,
- '308': 52,
- '309': 56,
- '310': 102,
- '311': 54,
- '312': 48,
- '313': 51,
- '314': 54,
- '315': 49,
- '316': 51,
- '317': 54,
- '318': 101,
- '319': 54,
- '320': 55,
- '321': 49,
- '322': 56,
- '323': 98,
- '324': 48,
- '325': 53,
- '326': 98,
- '327': 50,
- '328': 100,
- '329': 101,
- '330': 57,
- '331': 51,
- '332': 97,
- '333': 100,
- '334': 99,
- '335': 55,
- '336': 97,
- '337': 48,
- '338': 56,
- '339': 56,
- '340': 98,
- '341': 98,
- '342': 54,
- '343': 56,
- '344': 99,
- '345': 99,
- '346': 98,
- '347': 50,
- '348': 101,
- '349': 101,
- '350': 49,
- '351': 53,
- '352': 97,
- '353': 48,
- '354': 55,
- '355': 99,
- '356': 98,
- '357': 49,
- '358': 52,
- '359': 52,
- '360': 55,
- '361': 101,
- '362': 53,
- '363': 101,
- '364': 51,
- '365': 101,
- '366': 48,
- '367': 57,
- '368': 52,
- '369': 55,
- '370': 54,
- '371': 56,
- '372': 54,
- '373': 55,
- '374': 54,
- '375': 55,
- '376': 97,
- '377': 100,
- '378': 48,
- '379': 101,
- '380': 53,
- '381': 98,
- '382': 101,
- '383': 57,
- '384': 50,
- '385': 100,
- '386': 48,
- '387': 50,
- '388': 50,
- '389': 101,
- '390': 50,
- '391': 101,
- '392': 48,
- '393': 52,
- '394': 99,
- '395': 51,
- '396': 53,
- '397': 99,
- '398': 99,
- '399': 53,
- '400': 48,
- '401': 99,
- '402': 54,
- '403': 51,
- '404': 97,
- '405': 54,
- '406': 56,
- '407': 49,
- '408': 49,
- '409': 99,
- '410': 50,
- '411': 52,
- '412': 100,
- '413': 56,
- '414': 49,
- '415': 54,
- '416': 50,
- '417': 102,
- '418': 57,
- '419': 102,
- '420': 49,
- '421': 98,
- '422': 54,
- '423': 101,
- '424': 55,
- '425': 54,
- '426': 100,
- '427': 97,
- '428': 102,
- '429': 57,
- '430': 99,
- '431': 50,
- '432': 55,
- '433': 98,
- '434': 57,
- '435': 102,
- '436': 53,
- '437': 55,
- '438': 102,
- '439': 99,
- '440': 54,
- '441': 56,
- '442': 48,
- '443': 54,
- '444': 51,
- '445': 100,
- '446': 97,
- '447': 102,
- '448': 100,
- '449': 51,
- '450': 102,
- '451': 98,
- '452': 97,
- '453': 50,
- '454': 97,
- '455': 50,
- '456': 102,
- '457': 102,
- '458': 48,
- '459': 49,
- '460': 57,
- '461': 51,
- '462': 57,
- '463': 53,
- '464': 102,
- '465': 18,
- '466': 64,
- '467': 48,
- '468': 49,
- '469': 51,
- '470': 55,
- '471': 102,
- '472': 102,
- '473': 51,
- '474': 101,
- '475': 51,
- '476': 49,
- '477': 57,
- '478': 49,
- '479': 100,
- '480': 97,
- '481': 52,
- '482': 57,
- '483': 53,
- '484': 100,
- '485': 55,
- '486': 100,
- '487': 56,
- '488': 101,
- '489': 102,
- '490': 48,
- '491': 51,
- '492': 98,
- '493': 51,
- '494': 100,
- '495': 100,
- '496': 53,
- '497': 54,
- '498': 98,
- '499': 55,
- '500': 98,
- '501': 49,
- '502': 98,
- '503': 54,
- '504': 50,
- '505': 50,
- '506': 50,
- '507': 57,
- '508': 49,
- '509': 49,
- '510': 52,
- '511': 57,
- '512': 99,
- '513': 56,
- '514': 100,
- '515': 55,
- '516': 54,
- '517': 98,
- '518': 50,
- '519': 56,
- '520': 100,
- '521': 102,
- '522': 55,
- '523': 98,
- '524': 102,
- '525': 98,
- '526': 49,
- '527': 100,
- '528': 100,
- '529': 98,
- '530': 50,
- '531': 26,
- '532': 24,
- '533': 54,
- '534': 100,
- '535': 52,
- '536': 51,
- '537': 99,
- '538': 102,
- '539': 56,
- '540': 57,
- '541': 48,
- '542': 48,
- '543': 55,
- '544': 56,
- '545': 49,
- '546': 102,
- '547': 98,
- '548': 50,
- '549': 101,
- '550': 56,
- '551': 100,
- '552': 48,
- '553': 57,
- '554': 97,
- '555': 99,
- '556': 99,
- '557': 34,
- '558': 7,
- '559': 112,
- '560': 117,
- '561': 115,
- '562': 104,
- '563': 58,
- '564': 118,
- '565': 53,
- '566': 42,
- '567': 64,
- '568': 50,
- '569': 48,
- '570': 102,
- '571': 100,
- '572': 100,
- '573': 98,
- '574': 52,
- '575': 100,
- '576': 101,
- '577': 49,
- '578': 54,
- '579': 49,
- '580': 55,
- '581': 57,
- '582': 51,
- '583': 50,
- '584': 51,
- '585': 102,
- '586': 102,
- '587': 56,
- '588': 52,
- '589': 52,
- '590': 54,
- '591': 100,
- '592': 100,
- '593': 55,
- '594': 55,
- '595': 55,
- '596': 51,
- '597': 97,
- '598': 50,
- '599': 52,
- '600': 97,
- '601': 98,
- '602': 53,
- '603': 53,
- '604': 51,
- '605': 51,
- '606': 97,
- '607': 49,
- '608': 51,
- '609': 51,
- '610': 50,
- '611': 54,
- '612': 102,
- '613': 54,
- '614': 57,
- '615': 51,
- '616': 100,
- '617': 54,
- '618': 101,
- '619': 55,
- '620': 51,
- '621': 101,
- '622': 99,
- '623': 100,
- '624': 53,
- '625': 56,
- '626': 55,
- '627': 57,
- '628': 57,
- '629': 101,
- '630': 50,
- '631': 97,
- '632': 18,
- '633': 65,
- '634': 110,
- '635': 225,
- '636': 207,
- '637': 137,
- '638': 172,
- '639': 14,
- '640': 86,
- '641': 162,
- '642': 47,
- '643': 7,
- '644': 178,
- '645': 58,
- '646': 59,
- '647': 74,
- '648': 154,
- '649': 32,
- '650': 74,
- '651': 131,
- '652': 220,
- '653': 132,
- '654': 120,
- '655': 138,
- '656': 53,
- '657': 8,
- '658': 8,
- '659': 88,
- '660': 62,
- '661': 155,
- '662': 71,
- '663': 97,
- '664': 169,
- '665': 143,
- '666': 28,
- '667': 157,
- '668': 14,
- '669': 60,
- '670': 37,
- '671': 111,
- '672': 84,
- '673': 253,
- '674': 208,
- '675': 127,
- '676': 130,
- '677': 148,
- '678': 197,
- '679': 135,
- '680': 241,
- '681': 110,
- '682': 184,
- '683': 115,
- '684': 187,
- '685': 235,
- '686': 2,
- '687': 39,
- '688': 31,
- '689': 72,
- '690': 79,
- '691': 228,
- '692': 50,
- '693': 146,
- '694': 215,
- '695': 22,
- '696': 15,
- '697': 244,
- '698': 27,
- })
- ),
- salt: new Uint8Array(
- Object.values({
- '0': 37,
- '1': 180,
- '2': 180,
- '3': 34,
- '4': 129,
- '5': 106,
- '6': 65,
- '7': 71,
- '8': 146,
- '9': 128,
- '10': 66,
- '11': 213,
- '12': 228,
- '13': 243,
- '14': 168,
- '15': 108,
- })
- ),
- apiToken: new Uint8Array(0),
- signature: new Uint8Array(0),
- fee: '0',
- },
-};
-
-/**
- * Attched Wallets in walletToEncryptedDerivedKey map -
- * push:devnet:push1rgf3na7kqk5nphvv0rqvpvrg9wt6rkuakeuat8
- * eip155:1:0x35B84d6848D16415177c64D64504663b998A6ab4
- * solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:69EUYJKr2NE8vHFphyRPSU2tqRbXhMu9gzNo96mjvFLv
- */
-export const INIT_DID_TX_2 = {
- // The Public Key of this private key is present in the Tx Data as master Public Key
- masterPrivateKey:
- '0x9dba3e1ef92725f938a3bfda2de157e1502162a3c7b0bf7f60d68fab6949f4fa',
- unsignedInitDIDTx: {
- type: 0,
- category: 'INIT_DID',
- sender: '',
- recipients: [],
- data: new Uint8Array(
- Object.values({
- '0': 10,
- '1': 66,
- '2': 48,
- '3': 50,
- '4': 102,
- '5': 52,
- '6': 56,
- '7': 55,
- '8': 102,
- '9': 100,
- '10': 52,
- '11': 54,
- '12': 51,
- '13': 101,
- '14': 52,
- '15': 98,
- '16': 54,
- '17': 51,
- '18': 55,
- '19': 50,
- '20': 48,
- '21': 55,
- '22': 54,
- '23': 99,
- '24': 98,
- '25': 54,
- '26': 49,
- '27': 53,
- '28': 48,
- '29': 56,
- '30': 101,
- '31': 56,
- '32': 48,
- '33': 97,
- '34': 55,
- '35': 99,
- '36': 97,
- '37': 50,
- '38': 56,
- '39': 51,
- '40': 54,
- '41': 100,
- '42': 97,
- '43': 52,
- '44': 98,
- '45': 56,
- '46': 54,
- '47': 52,
- '48': 98,
- '49': 53,
- '50': 55,
- '51': 56,
- '52': 53,
- '53': 100,
- '54': 54,
- '55': 53,
- '56': 99,
- '57': 56,
- '58': 57,
- '59': 48,
- '60': 99,
- '61': 53,
- '62': 54,
- '63': 51,
- '64': 97,
- '65': 54,
- '66': 98,
- '67': 57,
- '68': 16,
- '69': 128,
- '70': 128,
- '71': 128,
- '72': 128,
- '73': 8,
- '74': 26,
- '75': 66,
- '76': 48,
- '77': 50,
- '78': 54,
- '79': 102,
- '80': 55,
- '81': 101,
- '82': 54,
- '83': 99,
- '84': 52,
- '85': 55,
- '86': 48,
- '87': 51,
- '88': 100,
- '89': 100,
- '90': 49,
- '91': 102,
- '92': 98,
- '93': 51,
- '94': 98,
- '95': 52,
- '96': 97,
- '97': 50,
- '98': 97,
- '99': 55,
- '100': 51,
- '101': 100,
- '102': 102,
- '103': 102,
- '104': 57,
- '105': 52,
- '106': 49,
- '107': 56,
- '108': 53,
- '109': 50,
- '110': 99,
- '111': 48,
- '112': 99,
- '113': 57,
- '114': 51,
- '115': 49,
- '116': 48,
- '117': 98,
- '118': 57,
- '119': 54,
- '120': 56,
- '121': 56,
- '122': 102,
- '123': 56,
- '124': 55,
- '125': 49,
- '126': 51,
- '127': 101,
- '128': 101,
- '129': 49,
- '130': 52,
- '131': 98,
- '132': 57,
- '133': 56,
- '134': 48,
- '135': 100,
- '136': 51,
- '137': 54,
- '138': 50,
- '139': 100,
- '140': 98,
- '141': 100,
- '142': 34,
- '143': 170,
- '144': 4,
- '145': 10,
- '146': 55,
- '147': 112,
- '148': 117,
- '149': 115,
- '150': 104,
- '151': 58,
- '152': 100,
- '153': 101,
- '154': 118,
- '155': 110,
- '156': 101,
- '157': 116,
- '158': 58,
- '159': 112,
- '160': 117,
- '161': 115,
- '162': 104,
- '163': 49,
- '164': 114,
- '165': 103,
- '166': 102,
- '167': 51,
- '168': 110,
- '169': 97,
- '170': 55,
- '171': 107,
- '172': 113,
- '173': 107,
- '174': 53,
- '175': 110,
- '176': 112,
- '177': 104,
- '178': 118,
- '179': 118,
- '180': 48,
- '181': 114,
- '182': 113,
- '183': 118,
- '184': 112,
- '185': 118,
- '186': 114,
- '187': 103,
- '188': 57,
- '189': 119,
- '190': 116,
- '191': 54,
- '192': 114,
- '193': 107,
- '194': 117,
- '195': 97,
- '196': 107,
- '197': 101,
- '198': 117,
- '199': 97,
- '200': 116,
- '201': 56,
- '202': 18,
- '203': 238,
- '204': 3,
- '205': 10,
- '206': 168,
- '207': 3,
- '208': 10,
- '209': 254,
- '210': 1,
- '211': 56,
- '212': 50,
- '213': 101,
- '214': 48,
- '215': 101,
- '216': 52,
- '217': 55,
- '218': 97,
- '219': 53,
- '220': 53,
- '221': 56,
- '222': 50,
- '223': 98,
- '224': 57,
- '225': 48,
- '226': 100,
- '227': 97,
- '228': 52,
- '229': 50,
- '230': 53,
- '231': 99,
- '232': 48,
- '233': 48,
- '234': 98,
- '235': 102,
- '236': 50,
- '237': 57,
- '238': 50,
- '239': 55,
- '240': 51,
- '241': 49,
- '242': 56,
- '243': 55,
- '244': 53,
- '245': 100,
- '246': 55,
- '247': 102,
- '248': 57,
- '249': 53,
- '250': 50,
- '251': 56,
- '252': 49,
- '253': 99,
- '254': 51,
- '255': 102,
- '256': 100,
- '257': 56,
- '258': 54,
- '259': 98,
- '260': 55,
- '261': 101,
- '262': 52,
- '263': 98,
- '264': 55,
- '265': 97,
- '266': 99,
- '267': 57,
- '268': 49,
- '269': 49,
- '270': 101,
- '271': 54,
- '272': 49,
- '273': 50,
- '274': 52,
- '275': 55,
- '276': 99,
- '277': 48,
- '278': 56,
- '279': 51,
- '280': 51,
- '281': 49,
- '282': 52,
- '283': 57,
- '284': 99,
- '285': 50,
- '286': 57,
- '287': 97,
- '288': 51,
- '289': 102,
- '290': 54,
- '291': 101,
- '292': 53,
- '293': 97,
- '294': 100,
- '295': 102,
- '296': 49,
- '297': 52,
- '298': 48,
- '299': 54,
- '300': 57,
- '301': 50,
- '302': 49,
- '303': 99,
- '304': 53,
- '305': 56,
- '306': 56,
- '307': 100,
- '308': 101,
- '309': 53,
- '310': 50,
- '311': 52,
- '312': 49,
- '313': 49,
- '314': 48,
- '315': 98,
- '316': 99,
- '317': 99,
- '318': 53,
- '319': 55,
- '320': 57,
- '321': 50,
- '322': 101,
- '323': 57,
- '324': 98,
- '325': 57,
- '326': 48,
- '327': 53,
- '328': 54,
- '329': 99,
- '330': 50,
- '331': 52,
- '332': 52,
- '333': 101,
- '334': 55,
- '335': 57,
- '336': 98,
- '337': 98,
- '338': 57,
- '339': 100,
- '340': 49,
- '341': 102,
- '342': 98,
- '343': 50,
- '344': 54,
- '345': 52,
- '346': 55,
- '347': 100,
- '348': 56,
- '349': 102,
- '350': 48,
- '351': 98,
- '352': 54,
- '353': 52,
- '354': 50,
- '355': 57,
- '356': 50,
- '357': 53,
- '358': 99,
- '359': 97,
- '360': 57,
- '361': 99,
- '362': 55,
- '363': 49,
- '364': 54,
- '365': 48,
- '366': 56,
- '367': 102,
- '368': 102,
- '369': 97,
- '370': 54,
- '371': 97,
- '372': 99,
- '373': 56,
- '374': 51,
- '375': 48,
- '376': 50,
- '377': 52,
- '378': 97,
- '379': 50,
- '380': 49,
- '381': 102,
- '382': 56,
- '383': 55,
- '384': 100,
- '385': 56,
- '386': 52,
- '387': 102,
- '388': 53,
- '389': 56,
- '390': 57,
- '391': 56,
- '392': 97,
- '393': 102,
- '394': 53,
- '395': 98,
- '396': 57,
- '397': 98,
- '398': 57,
- '399': 48,
- '400': 51,
- '401': 97,
- '402': 55,
- '403': 98,
- '404': 48,
- '405': 98,
- '406': 53,
- '407': 52,
- '408': 97,
- '409': 50,
- '410': 102,
- '411': 51,
- '412': 55,
- '413': 100,
- '414': 53,
- '415': 98,
- '416': 97,
- '417': 50,
- '418': 53,
- '419': 53,
- '420': 101,
- '421': 54,
- '422': 99,
- '423': 56,
- '424': 49,
- '425': 99,
- '426': 53,
- '427': 57,
- '428': 56,
- '429': 56,
- '430': 101,
- '431': 98,
- '432': 52,
- '433': 55,
- '434': 55,
- '435': 101,
- '436': 100,
- '437': 56,
- '438': 55,
- '439': 51,
- '440': 51,
- '441': 51,
- '442': 97,
- '443': 53,
- '444': 52,
- '445': 54,
- '446': 102,
- '447': 99,
- '448': 48,
- '449': 56,
- '450': 99,
- '451': 55,
- '452': 55,
- '453': 50,
- '454': 50,
- '455': 56,
- '456': 54,
- '457': 56,
- '458': 99,
- '459': 97,
- '460': 99,
- '461': 97,
- '462': 102,
- '463': 53,
- '464': 100,
- '465': 18,
- '466': 64,
- '467': 54,
- '468': 51,
- '469': 51,
- '470': 101,
- '471': 55,
- '472': 51,
- '473': 53,
- '474': 55,
- '475': 49,
- '476': 48,
- '477': 56,
- '478': 55,
- '479': 54,
- '480': 101,
- '481': 97,
- '482': 51,
- '483': 99,
- '484': 48,
- '485': 101,
- '486': 53,
- '487': 51,
- '488': 54,
- '489': 100,
- '490': 97,
- '491': 102,
- '492': 102,
- '493': 97,
- '494': 101,
- '495': 97,
- '496': 57,
- '497': 99,
- '498': 51,
- '499': 52,
- '500': 50,
- '501': 56,
- '502': 56,
- '503': 50,
- '504': 49,
- '505': 102,
- '506': 55,
- '507': 55,
- '508': 100,
- '509': 97,
- '510': 56,
- '511': 102,
- '512': 54,
- '513': 53,
- '514': 49,
- '515': 50,
- '516': 48,
- '517': 54,
- '518': 57,
- '519': 56,
- '520': 49,
- '521': 97,
- '522': 49,
- '523': 52,
- '524': 55,
- '525': 52,
- '526': 52,
- '527': 97,
- '528': 101,
- '529': 55,
- '530': 100,
- '531': 26,
- '532': 24,
- '533': 102,
- '534': 99,
- '535': 48,
- '536': 100,
- '537': 55,
- '538': 101,
- '539': 56,
- '540': 53,
- '541': 49,
- '542': 98,
- '543': 57,
- '544': 54,
- '545': 101,
- '546': 99,
- '547': 55,
- '548': 49,
- '549': 99,
- '550': 101,
- '551': 100,
- '552': 56,
- '553': 102,
- '554': 52,
- '555': 55,
- '556': 98,
- '557': 34,
- '558': 7,
- '559': 112,
- '560': 117,
- '561': 115,
- '562': 104,
- '563': 58,
- '564': 118,
- '565': 53,
- '566': 42,
- '567': 64,
- '568': 99,
- '569': 102,
- '570': 54,
- '571': 57,
- '572': 51,
- '573': 49,
- '574': 102,
- '575': 100,
- '576': 97,
- '577': 49,
- '578': 97,
- '579': 53,
- '580': 100,
- '581': 48,
- '582': 101,
- '583': 56,
- '584': 99,
- '585': 52,
- '586': 101,
- '587': 51,
- '588': 101,
- '589': 56,
- '590': 54,
- '591': 48,
- '592': 54,
- '593': 97,
- '594': 57,
- '595': 102,
- '596': 99,
- '597': 53,
- '598': 98,
- '599': 49,
- '600': 101,
- '601': 97,
- '602': 52,
- '603': 56,
- '604': 97,
- '605': 52,
- '606': 54,
- '607': 48,
- '608': 97,
- '609': 56,
- '610': 49,
- '611': 55,
- '612': 55,
- '613': 55,
- '614': 102,
- '615': 55,
- '616': 49,
- '617': 99,
- '618': 57,
- '619': 49,
- '620': 102,
- '621': 98,
- '622': 53,
- '623': 57,
- '624': 49,
- '625': 50,
- '626': 51,
- '627': 52,
- '628': 99,
- '629': 98,
- '630': 101,
- '631': 99,
- '632': 18,
- '633': 65,
- '634': 47,
- '635': 101,
- '636': 4,
- '637': 240,
- '638': 159,
- '639': 233,
- '640': 205,
- '641': 245,
- '642': 93,
- '643': 146,
- '644': 4,
- '645': 137,
- '646': 152,
- '647': 138,
- '648': 241,
- '649': 67,
- '650': 182,
- '651': 36,
- '652': 58,
- '653': 150,
- '654': 237,
- '655': 133,
- '656': 100,
- '657': 229,
- '658': 252,
- '659': 2,
- '660': 182,
- '661': 115,
- '662': 250,
- '663': 126,
- '664': 8,
- '665': 78,
- '666': 7,
- '667': 165,
- '668': 0,
- '669': 69,
- '670': 156,
- '671': 177,
- '672': 112,
- '673': 120,
- '674': 150,
- '675': 128,
- '676': 248,
- '677': 8,
- '678': 121,
- '679': 193,
- '680': 15,
- '681': 182,
- '682': 83,
- '683': 140,
- '684': 22,
- '685': 26,
- '686': 216,
- '687': 54,
- '688': 200,
- '689': 196,
- '690': 23,
- '691': 57,
- '692': 63,
- '693': 214,
- '694': 131,
- '695': 164,
- '696': 239,
- '697': 19,
- '698': 27,
- '699': 34,
- '700': 166,
- '701': 4,
- '702': 10,
- '703': 51,
- '704': 101,
- '705': 105,
- '706': 112,
- '707': 49,
- '708': 53,
- '709': 53,
- '710': 58,
- '711': 49,
- '712': 58,
- '713': 48,
- '714': 120,
- '715': 51,
- '716': 53,
- '717': 66,
- '718': 56,
- '719': 52,
- '720': 100,
- '721': 54,
- '722': 56,
- '723': 52,
- '724': 56,
- '725': 68,
- '726': 49,
- '727': 54,
- '728': 52,
- '729': 49,
- '730': 53,
- '731': 49,
- '732': 55,
- '733': 55,
- '734': 99,
- '735': 54,
- '736': 52,
- '737': 68,
- '738': 54,
- '739': 52,
- '740': 53,
- '741': 48,
- '742': 52,
- '743': 54,
- '744': 54,
- '745': 51,
- '746': 98,
- '747': 57,
- '748': 57,
- '749': 56,
- '750': 65,
- '751': 54,
- '752': 97,
- '753': 98,
- '754': 52,
- '755': 18,
- '756': 238,
- '757': 3,
- '758': 10,
- '759': 168,
- '760': 3,
- '761': 10,
- '762': 254,
- '763': 1,
- '764': 56,
- '765': 99,
- '766': 48,
- '767': 54,
- '768': 56,
- '769': 102,
- '770': 101,
- '771': 50,
- '772': 97,
- '773': 53,
- '774': 56,
- '775': 102,
- '776': 48,
- '777': 55,
- '778': 98,
- '779': 52,
- '780': 52,
- '781': 98,
- '782': 55,
- '783': 99,
- '784': 98,
- '785': 98,
- '786': 50,
- '787': 49,
- '788': 97,
- '789': 55,
- '790': 97,
- '791': 101,
- '792': 50,
- '793': 53,
- '794': 51,
- '795': 54,
- '796': 99,
- '797': 102,
- '798': 98,
- '799': 50,
- '800': 100,
- '801': 99,
- '802': 98,
- '803': 57,
- '804': 97,
- '805': 56,
- '806': 100,
- '807': 53,
- '808': 55,
- '809': 99,
- '810': 98,
- '811': 53,
- '812': 55,
- '813': 50,
- '814': 48,
- '815': 57,
- '816': 102,
- '817': 56,
- '818': 48,
- '819': 54,
- '820': 97,
- '821': 99,
- '822': 97,
- '823': 57,
- '824': 51,
- '825': 102,
- '826': 98,
- '827': 55,
- '828': 100,
- '829': 97,
- '830': 52,
- '831': 48,
- '832': 99,
- '833': 57,
- '834': 55,
- '835': 54,
- '836': 50,
- '837': 49,
- '838': 49,
- '839': 97,
- '840': 101,
- '841': 52,
- '842': 97,
- '843': 99,
- '844': 97,
- '845': 54,
- '846': 55,
- '847': 49,
- '848': 51,
- '849': 57,
- '850': 101,
- '851': 49,
- '852': 101,
- '853': 51,
- '854': 56,
- '855': 48,
- '856': 98,
- '857': 100,
- '858': 56,
- '859': 57,
- '860': 101,
- '861': 100,
- '862': 101,
- '863': 54,
- '864': 99,
- '865': 100,
- '866': 100,
- '867': 100,
- '868': 98,
- '869': 54,
- '870': 101,
- '871': 98,
- '872': 98,
- '873': 52,
- '874': 97,
- '875': 99,
- '876': 102,
- '877': 100,
- '878': 49,
- '879': 100,
- '880': 51,
- '881': 55,
- '882': 57,
- '883': 48,
- '884': 99,
- '885': 56,
- '886': 49,
- '887': 100,
- '888': 50,
- '889': 100,
- '890': 100,
- '891': 99,
- '892': 56,
- '893': 97,
- '894': 97,
- '895': 49,
- '896': 101,
- '897': 56,
- '898': 50,
- '899': 99,
- '900': 99,
- '901': 55,
- '902': 99,
- '903': 53,
- '904': 56,
- '905': 56,
- '906': 57,
- '907': 99,
- '908': 98,
- '909': 101,
- '910': 101,
- '911': 49,
- '912': 49,
- '913': 50,
- '914': 54,
- '915': 56,
- '916': 52,
- '917': 50,
- '918': 102,
- '919': 98,
- '920': 52,
- '921': 56,
- '922': 57,
- '923': 53,
- '924': 56,
- '925': 56,
- '926': 57,
- '927': 57,
- '928': 54,
- '929': 102,
- '930': 98,
- '931': 57,
- '932': 57,
- '933': 57,
- '934': 97,
- '935': 98,
- '936': 51,
- '937': 57,
- '938': 101,
- '939': 48,
- '940': 49,
- '941': 102,
- '942': 55,
- '943': 100,
- '944': 52,
- '945': 55,
- '946': 101,
- '947': 51,
- '948': 98,
- '949': 100,
- '950': 49,
- '951': 56,
- '952': 99,
- '953': 53,
- '954': 49,
- '955': 54,
- '956': 48,
- '957': 55,
- '958': 102,
- '959': 49,
- '960': 101,
- '961': 51,
- '962': 55,
- '963': 52,
- '964': 53,
- '965': 98,
- '966': 97,
- '967': 102,
- '968': 102,
- '969': 50,
- '970': 51,
- '971': 51,
- '972': 57,
- '973': 55,
- '974': 57,
- '975': 98,
- '976': 97,
- '977': 101,
- '978': 53,
- '979': 101,
- '980': 97,
- '981': 102,
- '982': 98,
- '983': 97,
- '984': 100,
- '985': 97,
- '986': 52,
- '987': 99,
- '988': 54,
- '989': 53,
- '990': 57,
- '991': 49,
- '992': 50,
- '993': 98,
- '994': 50,
- '995': 52,
- '996': 56,
- '997': 48,
- '998': 57,
- '999': 57,
- '1000': 57,
- '1001': 52,
- '1002': 50,
- '1003': 54,
- '1004': 99,
- '1005': 51,
- '1006': 57,
- '1007': 48,
- '1008': 55,
- '1009': 99,
- '1010': 50,
- '1011': 101,
- '1012': 101,
- '1013': 52,
- '1014': 50,
- '1015': 56,
- '1016': 50,
- '1017': 50,
- '1018': 18,
- '1019': 64,
- '1020': 97,
- '1021': 49,
- '1022': 52,
- '1023': 53,
- '1024': 97,
- '1025': 101,
- '1026': 56,
- '1027': 102,
- '1028': 56,
- '1029': 101,
- '1030': 53,
- '1031': 102,
- '1032': 50,
- '1033': 54,
- '1034': 49,
- '1035': 52,
- '1036': 57,
- '1037': 53,
- '1038': 101,
- '1039': 99,
- '1040': 55,
- '1041': 51,
- '1042': 98,
- '1043': 52,
- '1044': 98,
- '1045': 97,
- '1046': 48,
- '1047': 54,
- '1048': 99,
- '1049': 53,
- '1050': 99,
- '1051': 57,
- '1052': 49,
- '1053': 53,
- '1054': 51,
- '1055': 54,
- '1056': 54,
- '1057': 57,
- '1058': 101,
- '1059': 97,
- '1060': 53,
- '1061': 97,
- '1062': 50,
- '1063': 50,
- '1064': 101,
- '1065': 100,
- '1066': 98,
- '1067': 50,
- '1068': 49,
- '1069': 53,
- '1070': 49,
- '1071': 99,
- '1072': 49,
- '1073': 51,
- '1074': 49,
- '1075': 52,
- '1076': 55,
- '1077': 57,
- '1078': 101,
- '1079': 53,
- '1080': 102,
- '1081': 50,
- '1082': 98,
- '1083': 52,
- '1084': 26,
- '1085': 24,
- '1086': 51,
- '1087': 100,
- '1088': 98,
- '1089': 54,
- '1090': 49,
- '1091': 53,
- '1092': 52,
- '1093': 55,
- '1094': 53,
- '1095': 56,
- '1096': 48,
- '1097': 57,
- '1098': 53,
- '1099': 98,
- '1100': 98,
- '1101': 100,
- '1102': 52,
- '1103': 101,
- '1104': 50,
- '1105': 56,
- '1106': 57,
- '1107': 52,
- '1108': 57,
- '1109': 101,
- '1110': 34,
- '1111': 7,
- '1112': 112,
- '1113': 117,
- '1114': 115,
- '1115': 104,
- '1116': 58,
- '1117': 118,
- '1118': 53,
- '1119': 42,
- '1120': 64,
- '1121': 99,
- '1122': 48,
- '1123': 102,
- '1124': 54,
- '1125': 100,
- '1126': 50,
- '1127': 102,
- '1128': 54,
- '1129': 97,
- '1130': 57,
- '1131': 56,
- '1132': 54,
- '1133': 56,
- '1134': 56,
- '1135': 99,
- '1136': 56,
- '1137': 52,
- '1138': 52,
- '1139': 50,
- '1140': 56,
- '1141': 53,
- '1142': 56,
- '1143': 101,
- '1144': 55,
- '1145': 48,
- '1146': 101,
- '1147': 53,
- '1148': 52,
- '1149': 100,
- '1150': 49,
- '1151': 97,
- '1152': 50,
- '1153': 51,
- '1154': 54,
- '1155': 50,
- '1156': 97,
- '1157': 100,
- '1158': 48,
- '1159': 101,
- '1160': 50,
- '1161': 50,
- '1162': 99,
- '1163': 49,
- '1164': 99,
- '1165': 55,
- '1166': 48,
- '1167': 48,
- '1168': 51,
- '1169': 51,
- '1170': 99,
- '1171': 52,
- '1172': 99,
- '1173': 52,
- '1174': 102,
- '1175': 48,
- '1176': 52,
- '1177': 102,
- '1178': 97,
- '1179': 98,
- '1180': 57,
- '1181': 97,
- '1182': 101,
- '1183': 57,
- '1184': 50,
- '1185': 18,
- '1186': 65,
- '1187': 255,
- '1188': 199,
- '1189': 43,
- '1190': 204,
- '1191': 45,
- '1192': 128,
- '1193': 190,
- '1194': 60,
- '1195': 35,
- '1196': 182,
- '1197': 229,
- '1198': 217,
- '1199': 245,
- '1200': 95,
- '1201': 6,
- '1202': 255,
- '1203': 194,
- '1204': 208,
- '1205': 99,
- '1206': 228,
- '1207': 195,
- '1208': 74,
- '1209': 172,
- '1210': 0,
- '1211': 87,
- '1212': 143,
- '1213': 33,
- '1214': 112,
- '1215': 41,
- '1216': 183,
- '1217': 71,
- '1218': 137,
- '1219': 118,
- '1220': 193,
- '1221': 30,
- '1222': 137,
- '1223': 130,
- '1224': 22,
- '1225': 82,
- '1226': 186,
- '1227': 38,
- '1228': 59,
- '1229': 18,
- '1230': 111,
- '1231': 50,
- '1232': 25,
- '1233': 35,
- '1234': 148,
- '1235': 17,
- '1236': 217,
- '1237': 103,
- '1238': 228,
- '1239': 27,
- '1240': 59,
- '1241': 109,
- '1242': 230,
- '1243': 239,
- '1244': 163,
- '1245': 83,
- '1246': 119,
- '1247': 124,
- '1248': 106,
- '1249': 236,
- '1250': 20,
- '1251': 27,
- '1252': 34,
- '1253': 198,
- '1254': 4,
- '1255': 10,
- '1256': 84,
- '1257': 115,
- '1258': 111,
- '1259': 108,
- '1260': 97,
- '1261': 110,
- '1262': 97,
- '1263': 58,
- '1264': 53,
- '1265': 101,
- '1266': 121,
- '1267': 107,
- '1268': 116,
- '1269': 52,
- '1270': 85,
- '1271': 115,
- '1272': 70,
- '1273': 118,
- '1274': 56,
- '1275': 80,
- '1276': 56,
- '1277': 78,
- '1278': 74,
- '1279': 100,
- '1280': 84,
- '1281': 82,
- '1282': 69,
- '1283': 112,
- '1284': 89,
- '1285': 49,
- '1286': 118,
- '1287': 122,
- '1288': 113,
- '1289': 75,
- '1290': 113,
- '1291': 90,
- '1292': 75,
- '1293': 118,
- '1294': 100,
- '1295': 112,
- '1296': 58,
- '1297': 54,
- '1298': 57,
- '1299': 69,
- '1300': 85,
- '1301': 89,
- '1302': 74,
- '1303': 75,
- '1304': 114,
- '1305': 50,
- '1306': 78,
- '1307': 69,
- '1308': 56,
- '1309': 118,
- '1310': 72,
- '1311': 70,
- '1312': 112,
- '1313': 104,
- '1314': 121,
- '1315': 82,
- '1316': 80,
- '1317': 83,
- '1318': 85,
- '1319': 50,
- '1320': 116,
- '1321': 113,
- '1322': 82,
- '1323': 98,
- '1324': 88,
- '1325': 104,
- '1326': 77,
- '1327': 117,
- '1328': 57,
- '1329': 103,
- '1330': 122,
- '1331': 78,
- '1332': 111,
- '1333': 57,
- '1334': 54,
- '1335': 109,
- '1336': 106,
- '1337': 118,
- '1338': 70,
- '1339': 76,
- '1340': 118,
- '1341': 18,
- '1342': 237,
- '1343': 3,
- '1344': 10,
- '1345': 168,
- '1346': 3,
- '1347': 10,
- '1348': 254,
- '1349': 1,
- '1350': 97,
- '1351': 100,
- '1352': 53,
- '1353': 57,
- '1354': 54,
- '1355': 53,
- '1356': 100,
- '1357': 55,
- '1358': 55,
- '1359': 102,
- '1360': 49,
- '1361': 49,
- '1362': 99,
- '1363': 100,
- '1364': 48,
- '1365': 99,
- '1366': 99,
- '1367': 49,
- '1368': 51,
- '1369': 99,
- '1370': 48,
- '1371': 97,
- '1372': 53,
- '1373': 102,
- '1374': 51,
- '1375': 100,
- '1376': 51,
- '1377': 51,
- '1378': 57,
- '1379': 53,
- '1380': 102,
- '1381': 102,
- '1382': 51,
- '1383': 54,
- '1384': 57,
- '1385': 50,
- '1386': 100,
- '1387': 57,
- '1388': 55,
- '1389': 98,
- '1390': 97,
- '1391': 53,
- '1392': 50,
- '1393': 56,
- '1394': 55,
- '1395': 49,
- '1396': 49,
- '1397': 56,
- '1398': 56,
- '1399': 56,
- '1400': 52,
- '1401': 57,
- '1402': 101,
- '1403': 53,
- '1404': 102,
- '1405': 53,
- '1406': 48,
- '1407': 100,
- '1408': 101,
- '1409': 97,
- '1410': 102,
- '1411': 55,
- '1412': 48,
- '1413': 98,
- '1414': 56,
- '1415': 99,
- '1416': 56,
- '1417': 53,
- '1418': 53,
- '1419': 98,
- '1420': 101,
- '1421': 52,
- '1422': 55,
- '1423': 102,
- '1424': 50,
- '1425': 56,
- '1426': 50,
- '1427': 48,
- '1428': 52,
- '1429': 56,
- '1430': 55,
- '1431': 99,
- '1432': 52,
- '1433': 99,
- '1434': 51,
- '1435': 101,
- '1436': 56,
- '1437': 51,
- '1438': 49,
- '1439': 48,
- '1440': 49,
- '1441': 55,
- '1442': 99,
- '1443': 53,
- '1444': 52,
- '1445': 48,
- '1446': 52,
- '1447': 57,
- '1448': 98,
- '1449': 52,
- '1450': 49,
- '1451': 101,
- '1452': 97,
- '1453': 53,
- '1454': 98,
- '1455': 57,
- '1456': 51,
- '1457': 55,
- '1458': 53,
- '1459': 51,
- '1460': 98,
- '1461': 56,
- '1462': 51,
- '1463': 100,
- '1464': 53,
- '1465': 99,
- '1466': 49,
- '1467': 56,
- '1468': 49,
- '1469': 56,
- '1470': 50,
- '1471': 48,
- '1472': 102,
- '1473': 98,
- '1474': 50,
- '1475': 54,
- '1476': 52,
- '1477': 52,
- '1478': 50,
- '1479': 55,
- '1480': 51,
- '1481': 52,
- '1482': 100,
- '1483': 99,
- '1484': 50,
- '1485': 99,
- '1486': 102,
- '1487': 53,
- '1488': 55,
- '1489': 57,
- '1490': 99,
- '1491': 97,
- '1492': 98,
- '1493': 51,
- '1494': 50,
- '1495': 99,
- '1496': 55,
- '1497': 57,
- '1498': 53,
- '1499': 54,
- '1500': 51,
- '1501': 50,
- '1502': 51,
- '1503': 100,
- '1504': 50,
- '1505': 98,
- '1506': 53,
- '1507': 48,
- '1508': 100,
- '1509': 102,
- '1510': 48,
- '1511': 100,
- '1512': 97,
- '1513': 102,
- '1514': 53,
- '1515': 53,
- '1516': 98,
- '1517': 50,
- '1518': 55,
- '1519': 51,
- '1520': 55,
- '1521': 53,
- '1522': 97,
- '1523': 98,
- '1524': 53,
- '1525': 57,
- '1526': 53,
- '1527': 54,
- '1528': 55,
- '1529': 48,
- '1530': 99,
- '1531': 100,
- '1532': 57,
- '1533': 102,
- '1534': 97,
- '1535': 49,
- '1536': 98,
- '1537': 56,
- '1538': 57,
- '1539': 52,
- '1540': 52,
- '1541': 97,
- '1542': 55,
- '1543': 50,
- '1544': 57,
- '1545': 102,
- '1546': 102,
- '1547': 101,
- '1548': 50,
- '1549': 56,
- '1550': 49,
- '1551': 50,
- '1552': 51,
- '1553': 48,
- '1554': 97,
- '1555': 102,
- '1556': 57,
- '1557': 56,
- '1558': 102,
- '1559': 48,
- '1560': 97,
- '1561': 52,
- '1562': 101,
- '1563': 53,
- '1564': 57,
- '1565': 52,
- '1566': 56,
- '1567': 49,
- '1568': 56,
- '1569': 48,
- '1570': 99,
- '1571': 51,
- '1572': 51,
- '1573': 55,
- '1574': 51,
- '1575': 56,
- '1576': 99,
- '1577': 53,
- '1578': 55,
- '1579': 100,
- '1580': 56,
- '1581': 102,
- '1582': 50,
- '1583': 53,
- '1584': 49,
- '1585': 51,
- '1586': 50,
- '1587': 97,
- '1588': 100,
- '1589': 57,
- '1590': 48,
- '1591': 55,
- '1592': 49,
- '1593': 51,
- '1594': 97,
- '1595': 52,
- '1596': 55,
- '1597': 99,
- '1598': 99,
- '1599': 98,
- '1600': 50,
- '1601': 52,
- '1602': 57,
- '1603': 100,
- '1604': 18,
- '1605': 64,
- '1606': 99,
- '1607': 101,
- '1608': 52,
- '1609': 100,
- '1610': 50,
- '1611': 50,
- '1612': 49,
- '1613': 49,
- '1614': 101,
- '1615': 98,
- '1616': 54,
- '1617': 101,
- '1618': 56,
- '1619': 48,
- '1620': 101,
- '1621': 97,
- '1622': 100,
- '1623': 49,
- '1624': 49,
- '1625': 53,
- '1626': 98,
- '1627': 56,
- '1628': 48,
- '1629': 49,
- '1630': 53,
- '1631': 49,
- '1632': 98,
- '1633': 102,
- '1634': 101,
- '1635': 100,
- '1636': 101,
- '1637': 102,
- '1638': 49,
- '1639': 100,
- '1640': 51,
- '1641': 56,
- '1642': 53,
- '1643': 98,
- '1644': 56,
- '1645': 51,
- '1646': 98,
- '1647': 54,
- '1648': 52,
- '1649': 102,
- '1650': 55,
- '1651': 50,
- '1652': 53,
- '1653': 57,
- '1654': 50,
- '1655': 100,
- '1656': 51,
- '1657': 102,
- '1658': 48,
- '1659': 51,
- '1660': 97,
- '1661': 56,
- '1662': 50,
- '1663': 50,
- '1664': 48,
- '1665': 98,
- '1666': 102,
- '1667': 53,
- '1668': 98,
- '1669': 102,
- '1670': 26,
- '1671': 24,
- '1672': 48,
- '1673': 99,
- '1674': 56,
- '1675': 54,
- '1676': 56,
- '1677': 53,
- '1678': 49,
- '1679': 54,
- '1680': 53,
- '1681': 102,
- '1682': 56,
- '1683': 102,
- '1684': 55,
- '1685': 55,
- '1686': 97,
- '1687': 54,
- '1688': 52,
- '1689': 54,
- '1690': 57,
- '1691': 50,
- '1692': 101,
- '1693': 51,
- '1694': 52,
- '1695': 98,
- '1696': 34,
- '1697': 7,
- '1698': 112,
- '1699': 117,
- '1700': 115,
- '1701': 104,
- '1702': 58,
- '1703': 118,
- '1704': 53,
- '1705': 42,
- '1706': 64,
- '1707': 97,
- '1708': 102,
- '1709': 49,
- '1710': 49,
- '1711': 52,
- '1712': 97,
- '1713': 52,
- '1714': 101,
- '1715': 101,
- '1716': 99,
- '1717': 49,
- '1718': 53,
- '1719': 56,
- '1720': 98,
- '1721': 52,
- '1722': 52,
- '1723': 50,
- '1724': 56,
- '1725': 53,
- '1726': 98,
- '1727': 101,
- '1728': 101,
- '1729': 99,
- '1730': 49,
- '1731': 100,
- '1732': 49,
- '1733': 56,
- '1734': 51,
- '1735': 48,
- '1736': 54,
- '1737': 99,
- '1738': 101,
- '1739': 52,
- '1740': 52,
- '1741': 54,
- '1742': 51,
- '1743': 57,
- '1744': 50,
- '1745': 54,
- '1746': 99,
- '1747': 101,
- '1748': 54,
- '1749': 52,
- '1750': 100,
- '1751': 57,
- '1752': 56,
- '1753': 98,
- '1754': 98,
- '1755': 49,
- '1756': 102,
- '1757': 56,
- '1758': 50,
- '1759': 97,
- '1760': 101,
- '1761': 101,
- '1762': 56,
- '1763': 98,
- '1764': 98,
- '1765': 99,
- '1766': 57,
- '1767': 99,
- '1768': 99,
- '1769': 54,
- '1770': 100,
- '1771': 18,
- '1772': 64,
- '1773': 43,
- '1774': 161,
- '1775': 247,
- '1776': 189,
- '1777': 110,
- '1778': 110,
- '1779': 37,
- '1780': 212,
- '1781': 45,
- '1782': 111,
- '1783': 12,
- '1784': 180,
- '1785': 79,
- '1786': 83,
- '1787': 204,
- '1788': 242,
- '1789': 171,
- '1790': 218,
- '1791': 216,
- '1792': 182,
- '1793': 65,
- '1794': 236,
- '1795': 116,
- '1796': 245,
- '1797': 30,
- '1798': 39,
- '1799': 130,
- '1800': 109,
- '1801': 161,
- '1802': 79,
- '1803': 75,
- '1804': 27,
- '1805': 121,
- '1806': 125,
- '1807': 151,
- '1808': 175,
- '1809': 203,
- '1810': 27,
- '1811': 23,
- '1812': 138,
- '1813': 248,
- '1814': 115,
- '1815': 153,
- '1816': 218,
- '1817': 176,
- '1818': 45,
- '1819': 159,
- '1820': 165,
- '1821': 205,
- '1822': 246,
- '1823': 112,
- '1824': 163,
- '1825': 147,
- '1826': 23,
- '1827': 171,
- '1828': 184,
- '1829': 62,
- '1830': 31,
- '1831': 34,
- '1832': 32,
- '1833': 128,
- '1834': 82,
- '1835': 7,
- '1836': 0,
- })
- ),
- salt: new Uint8Array(
- Object.values({
- '0': 151,
- '1': 155,
- '2': 2,
- '3': 33,
- '4': 165,
- '5': 248,
- '6': 79,
- '7': 149,
- '8': 146,
- '9': 170,
- '10': 76,
- '11': 131,
- '12': 62,
- '13': 71,
- '14': 112,
- '15': 175,
- })
- ),
- apiToken: new Uint8Array(0),
- signature: new Uint8Array(0),
- fee: '0',
- },
-};
diff --git a/packages/core/tests/tx/tx.test.ts b/packages/core/tests/tx/tx.test.ts
deleted file mode 100644
index 130719cc..00000000
--- a/packages/core/tests/tx/tx.test.ts
+++ /dev/null
@@ -1,451 +0,0 @@
-import { Address, Tx } from '../../src';
-import { TxCategory } from '../../src/lib/tx/tx.types';
-import { InitDid } from '../../src/lib/generated/txData/init_did';
-import { config } from '../config';
-import { TxResponse } from '../../src/lib/tx/tx.types';
-import {
- generatePrivateKey,
- privateKeyToAccount,
- privateKeyToAddress,
-} from 'viem/accounts';
-import { hexToBytes, toHex, verifyMessage } from 'viem';
-import { ENV } from '../../src/lib/constants';
-import { sha256 } from '@noble/hashes/sha256';
-import * as nacl from 'tweetnacl';
-import bs58 from 'bs58';
-import { INIT_DID_TX, INIT_DID_TX_2 } from '../data';
-
-const test_pk = generatePrivateKey();
-const test_account = privateKeyToAccount(test_pk);
-// Mock data for testing
-const mockInitDidTxData: InitDid = {
- masterPubKey: test_account.publicKey.slice(2), // remove 0x
- derivedKeyIndex: 0,
- derivedPubKey: '00000',
- walletToEncDerivedKey: {
- 'push:devnet:push1xkuy66zg69jp29muvnty2prx8wvc5645f9y5ux': {
- encDerivedPrivKey: {
- ciphertext: 'sample_ciphertext',
- salt: 'sample_salt',
- nonce: 'sample_nonce',
- version: 'push:v5',
- preKey: 'sample_prekey',
- },
- signature: new Uint8Array([1, 2, 3]),
- },
- },
-};
-const mockRecipients = [
- `eip155:1:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:137:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:97:${privateKeyToAddress(generatePrivateKey())}`,
-];
-
-describe('Tx', () => {
- const env = config.ENV;
- const txChecker = (tx: TxResponse) => {
- expect(tx).toHaveProperty('txnHash');
- expect(tx).toHaveProperty('ts');
- expect(tx).toHaveProperty('blockHash');
- expect(tx).toHaveProperty('category');
- expect(tx).toHaveProperty('sender');
- expect(tx).toHaveProperty('status');
- expect(tx).toHaveProperty('recipients');
- expect(tx).toHaveProperty('txnData');
- expect(tx).toHaveProperty('sig');
- };
- it('should create an unsigned transaction', async () => {
- const txInstance = await Tx.initialize(env);
- const tx = await txInstance.createUnsigned(
- TxCategory.INIT_DID,
- mockRecipients,
- Tx.serializeData(mockInitDidTxData, TxCategory.INIT_DID)
- );
- expect(tx).toEqual({
- type: 0,
- category: TxCategory.INIT_DID,
- sender: '',
- recipients: mockRecipients,
- data: Tx.serializeData(mockInitDidTxData, TxCategory.INIT_DID),
- salt: tx.salt,
- apiToken: tx.apiToken,
- signature: new Uint8Array(0),
- fee: '0',
- });
- });
- it('should serialize an unsigned transaction', async () => {
- const txInstance = await Tx.initialize(env);
- const unsignedTx = await txInstance.createUnsigned(
- TxCategory.INIT_DID,
- mockRecipients,
- Tx.serializeData(mockInitDidTxData, TxCategory.INIT_DID)
- );
- const serializedTx = Tx.serialize(unsignedTx);
- expect(serializedTx).toBeInstanceOf(Uint8Array);
- expect(unsignedTx).toEqual(Tx.deserialize(serializedTx));
- });
- it('should serialize a signed transaction', async () => {
- const txInstance = await Tx.initialize(env);
- const unsignedTx = await txInstance.createUnsigned(
- TxCategory.INIT_DID,
- mockRecipients,
- Tx.serializeData(mockInitDidTxData, TxCategory.INIT_DID)
- );
- const signedTx = {
- ...unsignedTx,
- signature: new Uint8Array([6, 7, 8, 9, 10]),
- sender: 'eip155:1:0xabcc',
- };
- const serializedTx = Tx.serialize(signedTx);
- expect(serializedTx).toBeInstanceOf(Uint8Array);
- expect(signedTx).toEqual(Tx.deserialize(serializedTx));
- });
- it('should serialize a Tx data into a Uint8Array', () => {
- const serializedTxData = Tx.serializeData(
- mockInitDidTxData,
- TxCategory.INIT_DID
- );
- expect(serializedTxData).toBeInstanceOf(Uint8Array);
- expect(serializedTxData.length).toBeGreaterThan(0);
- });
- it('should deserialize a Uint8Array into a Tx Data object', () => {
- const serializedTxData = Tx.serializeData(
- mockInitDidTxData,
- TxCategory.INIT_DID
- );
- const deserializedTxData = Tx.deserializeData(
- serializedTxData,
- TxCategory.INIT_DID
- );
- expect(deserializedTxData).toEqual(mockInitDidTxData);
- });
- it('should get transactions with default parameters', async () => {
- const txInstance = await Tx.initialize(env);
- const res = await txInstance.get();
- expect(res.blocks).toBeInstanceOf(Array);
- expect(res.blocks.length).toBeGreaterThan(0);
- res.blocks.forEach((block) => {
- block.transactions.forEach((tx) => txChecker(tx));
- });
- });
- it('should get transactions with custom parameters', async () => {
- const txInstance = await Tx.initialize(env);
- const res = await txInstance.get(
- Math.floor(Date.now() / 1000),
- 'DESC',
- 10,
- 2
- );
- expect(res.blocks).toBeInstanceOf(Array);
- res.blocks.forEach((block) => {
- block.transactions.forEach((tx) => txChecker(tx));
- });
- });
- it('should get transactions for a specific user', async () => {
- const txInstance = await Tx.initialize(env);
- const res = await txInstance.get(
- Math.floor(Date.now()),
- 'DESC',
- 10,
- 1,
- 'eip155:1:0x35B84d6848D16415177c64D64504663b998A6ab4'
- );
- expect(res.blocks).toBeInstanceOf(Array);
- expect(res.blocks.length).toBeGreaterThan(0);
- res.blocks.forEach((block) => {
- block.transactions.forEach((tx) => txChecker(tx));
- });
- });
- it('should get transactions with a specific Category', async () => {
- const txInstance = await Tx.initialize(env);
- const res = await txInstance.get(
- Math.floor(Date.now()),
- 'DESC',
- 10,
- 1,
- undefined,
- 'CUSTOM:PUSH_MAIL'
- );
- expect(res.blocks).toBeInstanceOf(Array);
- expect(res.blocks.length).toBeGreaterThan(0);
- res.blocks.forEach((block) => {
- block.transactions.forEach((tx) => txChecker(tx));
- });
- });
- it('should get transactions with a specific Sender', async () => {
- const txInstance = await Tx.initialize(env);
- const res = await txInstance.getBySender(
- 'eip155:1:0x35B84d6848D16415177c64D64504663b998A6ab4',
- Math.floor(Date.now()),
- 'DESC',
- 10,
- 1
- );
- expect(res.blocks).toBeInstanceOf(Array);
- expect(res.blocks.length).toBeGreaterThan(0);
- res.blocks.forEach((block) => {
- block.transactions.forEach((tx) => txChecker(tx));
- });
- });
- it('should get transactions with a specific Recipient', async () => {
- const txInstance = await Tx.initialize(env);
- const res = await txInstance.getByRecipient(
- 'eip155:1:0x76cfb79DA0f91b2C162cA2a23f7f0117bD8cDB2c',
- Math.floor(Date.now()),
- 'DESC',
- 10,
- 1
- );
- expect(res.blocks).toBeInstanceOf(Array);
- expect(res.blocks.length).toBeGreaterThan(0);
- res.blocks.forEach((block) => {
- block.transactions.forEach((tx) => txChecker(tx));
- });
- });
- it('should search for a tx by hash', async () => {
- const txInstance = await Tx.initialize(env);
- const txHash = '9f636ac0faa040a74ae49410528c5634';
- const res = await txInstance.search(txHash);
- if (res.blocks.length > 0) {
- expect(res.blocks.length).toEqual(1);
- expect(res.blocks[0].transactions.length).toEqual(1);
- }
- res.blocks.forEach((block) => {
- block.transactions.forEach((tx) => txChecker(tx));
- });
- });
- it('should send for a INIT_DID tx', async () => {
- const account = privateKeyToAccount(
- INIT_DID_TX_2.masterPrivateKey as `0x${string}`
- );
- const signer = {
- account: Address.toPushCAIP(account.address, ENV.DEV),
- signMessage: async (data: Uint8Array) => {
- const signature = await account.signMessage({
- message: { raw: data },
- });
- return hexToBytes(signature);
- },
- };
- const txInstance = await Tx.initialize(env);
- const res = await txInstance.send(INIT_DID_TX_2.unsignedInitDIDTx, signer);
- expect(typeof res).toEqual('string');
- });
- it('should reject for a INIT_DID tx with different signer', async () => {
- const account = privateKeyToAccount(
- INIT_DID_TX_2.masterPrivateKey as `0x${string}`
- );
- const randomPk = generatePrivateKey();
- const randomAccount = privateKeyToAccount(randomPk);
- // Account is correct but signer is different
- const signer = {
- account: Address.toPushCAIP(account.address, ENV.DEV),
-
- signMessage: async (data: Uint8Array) => {
- const signature = await randomAccount.signMessage({
- message: { raw: data },
- });
- return hexToBytes(signature);
- },
- };
- const txInstance = await Tx.initialize(env);
- await expect(
- txInstance.send(INIT_DID_TX_2.unsignedInitDIDTx, signer)
- ).rejects.toThrow();
- });
- it('should reject for a INIT_DID tx with different sender Address', async () => {
- const account = privateKeyToAccount(
- INIT_DID_TX_2.masterPrivateKey as `0x${string}`
- );
- const randomPk = generatePrivateKey();
- const randomAccount = privateKeyToAccount(randomPk);
- // Signer is correct but account is different
- const signer = {
- account: Address.toPushCAIP(randomAccount.address, ENV.DEV),
-
- signMessage: async (data: Uint8Array) => {
- const signature = await account.signMessage({
- message: { raw: data },
- });
- return hexToBytes(signature);
- },
- };
- const txInstance = await Tx.initialize(env);
- await expect(
- txInstance.send(INIT_DID_TX_2.unsignedInitDIDTx, signer)
- ).rejects.toThrow();
- });
- it('should reject for a INIT_DID tx with wrong signature in walletToEncDerivedKey', async () => {
- const account = privateKeyToAccount(
- INIT_DID_TX.masterPrivateKey as `0x${string}`
- );
- const randomPk = generatePrivateKey();
- const randomAccount = privateKeyToAccount(randomPk);
- // Signer is correct but account is different
- const signer = {
- account: Address.toPushCAIP(randomAccount.address, ENV.DEV),
-
- signMessage: async (data: Uint8Array) => {
- const signature = await account.signMessage({
- message: { raw: data },
- });
- return hexToBytes(signature);
- },
- };
- const txInstance = await Tx.initialize(env);
- await expect(
- txInstance.send(INIT_DID_TX.unsignedInitDIDTx, signer)
- ).rejects.toThrow();
- });
- it('should send for a custom tx', async () => {
- const txInstance = await Tx.initialize(env);
- const recipients = [
- `eip155:1:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:137:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:97:${privateKeyToAddress(generatePrivateKey())}`,
- ];
- const tx = txInstance.createUnsigned(
- 'CUSTOM:CORE_SDK',
- recipients,
- new Uint8Array([1, 2, 3, 4, 5])
- );
-
- const pk = generatePrivateKey();
- const account = privateKeyToAccount(pk);
- const signer = {
- account: Address.toPushCAIP(account.address, ENV.DEV),
- signMessage: async (data: Uint8Array) => {
- const signature = await account.signMessage({
- message: { raw: data },
- });
- return hexToBytes(signature);
- },
- };
- const res = await txInstance.send(tx, signer);
- expect(typeof res).toEqual('string');
- });
- it('should reject custom tx with wrong signer', async () => {
- const txInstance = await Tx.initialize(env);
- const recipients = [
- `eip155:1:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:137:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:97:${privateKeyToAddress(generatePrivateKey())}`,
- ];
- const tx = txInstance.createUnsigned(
- 'CUSTOM:CORE_SDK',
- recipients,
- new Uint8Array([1, 2, 3, 4, 5])
- );
-
- const pk = generatePrivateKey();
- const account = privateKeyToAccount(pk);
- const signer = {
- // Random signer address
- account: Address.toPushCAIP(privateKeyToAddress(generatePrivateKey())),
- signMessage: async (data: Uint8Array) => {
- const signature = await account.signMessage({
- message: { raw: data },
- });
- return hexToBytes(signature);
- },
- };
- await expect(txInstance.send(tx, signer)).rejects.toThrow();
- });
- it('should reject custom tx with wrong signature', async () => {
- const txInstance = await Tx.initialize(env);
- const recipients = [
- `eip155:1:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:137:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:97:${privateKeyToAddress(generatePrivateKey())}`,
- ];
- const tx = txInstance.createUnsigned(
- 'CUSTOM:CORE_SDK',
- recipients,
- new Uint8Array([1, 2, 3, 4, 5])
- );
-
- const pk = generatePrivateKey();
- const account = privateKeyToAccount(pk);
- const signer = {
- // Random signer address
- account: Address.toPushCAIP(privateKeyToAddress(generatePrivateKey())),
- signMessage: async (data: Uint8Array) => {
- const signature = '0x000';
- return hexToBytes(signature);
- },
- };
- await expect(txInstance.send(tx, signer)).rejects.toThrow();
- });
- it('should verify a tx sign by evm address', async () => {
- // signed by `eip155:1:0x35B84d6848D16415177c64D64504663b998A6ab4`
- const sentTx =
- '1210435553544f4d3a505553485f4d41494c1a336569703135353a313a30783335423834643638343844313634313531373763363444363435303436363362393938413661623422336569703135353a313a3078443836333443333942424664343033336330643332383943343531353237353130323432333638312a740a0e446576636f6e205469636b65747312500a4e4465617220557365720a436f6e67726174756c6174696f6e73206f6e206265696e672073656c656374656420666f722067657474696e67207469636b65747320746f20446576636f6e203230323422100a085072696f72697479120448696768321027d5c07d7d5b4e719db21915169efb573a9f0f56543165794a756232526c6379493657337369626d396b5a556c6b496a6f694d48686d524546465957593359575a44526d4a694e4755305a44453252454d324e6d4a454d6a417a4f575a6b4e6a41774e454e47593255344969776964484e4e6157787361584d694f6a45334d6a6b794e7a45794f4441774e544973496e4a68626d52766255686c65434936496a6b32596a63345a6a646d4e7a4e694d546733596a4d784e6a51794e3259314f47497a595755785a545a685a4745794d6d55304d5445694c434a776157356e556d567a645778306379493657337369626d396b5a556c6b496a6f694d4867345a5445795a4555784d6b4d7a4e575642516d597a4e5749314e6d49774e4555314d304d30525451324f4755304e6a63794e3055344969776964484e4e6157787361584d694f6a45334d6a6b794e7a45794e5441784f545573496e4e3059585231637949364d58307365794a756232526c535751694f69497765446b34526a6c454f5445775157566d4f55497a516a6c424e4455784d7a64685a6a4644515463324e7a566c52446b775954557a4e5455694c434a306330317062477870637949364d5463794f5449334d5449314d4445304e797769633352686448567a496a6f7866563073496e4e705a323568644856795a534936496a42345a546b7a4e54517a4e7a686d4f4759344d57566d4e6a6b32597a5a6d4e4451305a574532596a4d794e6d55774d6a4e685932566b597a46695a6a55774d6d52694d54526d596a4934596a45344d6a4e6d596a686b4d44566b5a546c6b597a51324e7a466a5a44526a4e6d4d7a596a67784e4751305a6a493259544e6d4e574d3459574931593256684f5449354e6a55345a5455324e544e694d5463314f544e695a4755305a5455344d54517859694a394c487369626d396b5a556c6b496a6f694d4867354f45593552446b784d45466c5a6a6c434d304935515451314d544d3359575978513045334e6a63315a5551354d4745314d7a55314969776964484e4e6157787361584d694f6a45334d6a6b794e7a45794f4441774e545973496e4a68626d52766255686c65434936496d55784d475268596a51784e546c695a4467304d6a67304e5463354e7a59354e6a55314e32566a4f446b334d5463304e7a466d4d544d694c434a776157356e556d567a645778306379493657337369626d396b5a556c6b496a6f694d4867345a5445795a4555784d6b4d7a4e575642516d597a4e5749314e6d49774e4555314d304d30525451324f4755304e6a63794e3055344969776964484e4e6157787361584d694f6a45334d6a6b794e7a45794e5441784e544973496e4e3059585231637949364d58307365794a756232526c535751694f69497765475a45515556685a6a64685a6b4e47596d49305a54526b4d545a45517a5932596b51794d444d355a6d51324d44413051305a6a5a5467694c434a306330317062477870637949364d5463794f5449334d5449314d44457a4d437769633352686448567a496a6f7866563073496e4e705a323568644856795a534936496a42344e6a426c4d546c6b5a54426d4e6d4d325a575a694f5449304d6a45354e5749344d446379597a6c695a5451314d7a45324d546b314d4455314e5452684e7a68694f444a6b4d5467354d7a566d4e57526b5a4455345a6a4a6b5a6d56685a4464685a6d59315a574a684f5441354e4751794e6a4a694e5446684e6a64684e6a4d344e7a4a6a4e6d59344e7a6b344e47557a4d6a67354d7a4d3359574d304e444e694e5467784e44646b4f44597859794a394c487369626d396b5a556c6b496a6f694d4867345a5445795a4555784d6b4d7a4e575642516d597a4e5749314e6d49774e4555314d304d30525451324f4755304e6a63794e3055344969776964484e4e6157787361584d694f6a45334d6a6b794e7a45794f4441774e6a5573496e4a68626d52766255686c65434936496d59314e474d324f5451314e4467325a4755354e6a4d78596a4e6c4e575a694e57526a4e5441304f47497a4e5749334d6a426d596d45694c434a776157356e556d567a645778306379493657337369626d396b5a556c6b496a6f694d48686d524546465957593359575a44526d4a694e4755305a44453252454d324e6d4a454d6a417a4f575a6b4e6a41774e454e47593255344969776964484e4e6157787361584d694f6a45334d6a6b794e7a45794e5441774f544573496e4e3059585231637949364d58307365794a756232526c535751694f69497765446b34526a6c454f5445775157566d4f55497a516a6c424e4455784d7a64685a6a4644515463324e7a566c52446b775954557a4e5455694c434a306330317062477870637949364d5463794f5449334d5449314d4445784d697769633352686448567a496a6f7866563073496e4e705a323568644856795a534936496a42345a6a59305a5464685a445978595451354d7a41344e44497a597a59794d6d49354d6a4a6b4d54566b5954526d597a63324d6a6b794d546c6d596a6c684e6a63324e44646d59574d775a6d5a695a6d4d775a6a4a6a4e4459304d6d457a4e6a4531597a45304f5745324e6a566c4f5455344f444934596d4a694f44597759574d334e6d59334f5441344d7a686a5a5441344f47457a597a4579597a45324d7a55345954637a4d7a4e6b5a47557859794a395858303d424152ffaa59451eb11fca4770f5d8f958603deb189359ab3fbb9cf30793095573b87dfb8ba4d979d0a69ed48bc6a145d58ea5783b59a40ba758168ffb8961fdde391b4a0130';
-
- const deserializedTx = Tx.deserialize(hexToBytes(`0x${sentTx}`));
-
- const serializedUnsignedTx = Tx.serialize({
- ...deserializedTx,
- signature: new Uint8Array(0),
- });
-
- const dataToBeSigned = new TextEncoder().encode(
- toHex(sha256(serializedUnsignedTx))
- );
-
- const sigVerification = await verifyMessage({
- address: '0x35B84d6848D16415177c64D64504663b998A6ab4',
- message: { raw: dataToBeSigned },
- signature: deserializedTx.signature,
- });
- expect(sigVerification).toBe(true);
- });
- it('should verify a tx signed by sol addeess', async () => {
- // signed by `69EUYJKr2NE8vHFphyRPSU2tqRbXhMu9gzNo96mjvFLv`
- const sentTx =
- '1210435553544f4d3a505553485f4d41494c1a54736f6c616e613a3565796b7434557346763850384e4a64545245705931767a714b715a4b7664703a36394555594a4b72324e453876484670687952505355327471526258684d7539677a4e6f39366d6a76464c7622336569703135353a313a3078443836333443333942424664343033336330643332383943343531353237353130323432333638312a6d0a0f57656c636f6d6520546f205075736812480a46436f6e67726174756c6174696f6e73206f6e206265696e672073656c656374656420666f722050757368204164766f636174650a0a52656761726473205465616d205075736822100a085072696f726974791204486967683210b51e8e7ac9ea40858c022304b38b6d723a9f0f56543165794a756232526c6379493657337369626d396b5a556c6b496a6f694d48686d524546465957593359575a44526d4a694e4755305a44453252454d324e6d4a454d6a417a4f575a6b4e6a41774e454e47593255344969776964484e4e6157787361584d694f6a45334d6a6b794e7a45304e6a41774f444173496e4a68626d52766255686c65434936496d593259544977593259785a6a4d314d44526d596d45784e7a4a6b593249794d4441324e6a55304d324d344f5449795a5449304d3245694c434a776157356e556d567a645778306379493657337369626d396b5a556c6b496a6f694d4867345a5445795a4555784d6b4d7a4e575642516d597a4e5749314e6d49774e4555314d304d30525451324f4755304e6a63794e3055344969776964484e4e6157787361584d694f6a45334d6a6b794e7a45304e6a41774e544973496e4e3059585231637949364d58307365794a756232526c535751694f69497765446b34526a6c454f5445775157566d4f55497a516a6c424e4455784d7a64685a6a4644515463324e7a566c52446b775954557a4e5455694c434a306330317062477870637949364d5463794f5449334d5451324d4441314f437769633352686448567a496a6f7866563073496e4e705a323568644856795a534936496a4234597a5131597a63775a574d79596d4d784f5459324d6a6c684d5463304d47466a4f474d784d44686b4d6d466b5a6d51314d6d493159545979595445795a6a6b35595755784d474d354d57497a4e4459314d4459785a444e694d325977596d557a4d6a4e684e7a41774e4751324d4449355a446b354d4456684e6d4a6a5a6a51325a47466b5a6a51334f5749324d6a4a6d4f5441304d3259334e7a42684e32566a4d3256694e324d325932517859794a394c487369626d396b5a556c6b496a6f694d4867354f45593552446b784d45466c5a6a6c434d304935515451314d544d3359575978513045334e6a63315a5551354d4745314d7a55314969776964484e4e6157787361584d694f6a45334d6a6b794e7a45304e6a41774e6a4173496e4a68626d52766255686c65434936496d4d794f54466a595745344f44597a4e444a6d593255784d57526d4e6a6b344f446331597a566a5a5755354d32497a4d546779596a63694c434a776157356e556d567a645778306379493657337369626d396b5a556c6b496a6f694d4867345a5445795a4555784d6b4d7a4e575642516d597a4e5749314e6d49774e4555314d304d30525451324f4755304e6a63794e3055344969776964484e4e6157787361584d694f6a45334d6a6b794e7a45304d7a41774e6a5973496e4e3059585231637949364d58307365794a756232526c535751694f69497765475a45515556685a6a64685a6b4e47596d49305a54526b4d545a45517a5932596b51794d444d355a6d51324d44413051305a6a5a5467694c434a306330317062477870637949364d5463794f5449334d54517a4d4441334f437769633352686448567a496a6f7866563073496e4e705a323568644856795a534936496a4234596a426b4d6a4e6c4d7a526b4e6a4d304d4445774e5441305a5449334d5749314e7a4d34596a6c695a6a566d59324d784d5463344d6d566a4d4445305a6d59334e6d5934593255334d7a55314e57526a5a6d49775a544d7a4e574a684f444135595756695a574d334d5459325a6a4d334d57526b4d446c6b4f4745344d544d334d7a59325a574d32597a6c6a4e7a67774e575930595751345a6d5a695a4751795a4759334f5449784d32597859794a394c487369626d396b5a556c6b496a6f694d4867345a5445795a4555784d6b4d7a4e575642516d597a4e5749314e6d49774e4555314d304d30525451324f4755304e6a63794e3055344969776964484e4e6157787361584d694f6a45334d6a6b794e7a45304e6a41774f445173496e4a68626d52766255686c65434936496d5a6a4f574d794d6d4a6d5a4759314d6a46684e446c6b4d5755314f474e6c5a5467334e6a63774e574a6b596a52684d6a6869596d4d694c434a776157356e556d567a645778306379493657337369626d396b5a556c6b496a6f694d48686d524546465957593359575a44526d4a694e4755305a44453252454d324e6d4a454d6a417a4f575a6b4e6a41774e454e47593255344969776964484e4e6157787361584d694f6a45334d6a6b794e7a45304e6a41774e7a6373496e4e3059585231637949364d58307365794a756232526c535751694f69497765446b34526a6c454f5445775157566d4f55497a516a6c424e4455784d7a64685a6a4644515463324e7a566c52446b775954557a4e5455694c434a306330317062477870637949364d5463794f5449334d5451324d4441334d437769633352686448567a496a6f7866563073496e4e705a323568644856795a534936496a42344d5755795a474e694e544a6a4e7a45325a544d345957526d5932457a595749794d7a55795a6d59794e444978595449314d446b324d44646a5a4467304e444a684f5467774e6a41335a444134596a6b344f475a684d6a4d355a544933596a49784d3245305a6d5a6d4d7a566a4f5755334d6a6c695a54413259324d795a44597a4e6a4e6b5a6a4d34596d5a6b4e4468684d7a526d595759784e5441324d4759774d7a55344d54526a4d47457859794a395858303d42408db49a8d88ea0b5a0cea8a0bf90fc51fdc870cf6a6eccc428150fbbff51a691b3a1fa19d29bc0f60bc061ad4768c5f73f602e245047629b320c96c08229ea3014a0130';
-
- const deserializedTx = Tx.deserialize(hexToBytes(`0x${sentTx}`));
-
- const serializedUnsignedTx = Tx.serialize({
- ...deserializedTx,
- signature: new Uint8Array(0),
- });
-
- const dataToBeSigned = new TextEncoder().encode(
- toHex(sha256(serializedUnsignedTx))
- );
-
- const sigVerification = nacl.sign.detached.verify(
- dataToBeSigned,
- deserializedTx.signature,
- bs58.decode('69EUYJKr2NE8vHFphyRPSU2tqRbXhMu9gzNo96mjvFLv')
- );
-
- expect(sigVerification).toBe(true);
- });
- it('should verify a tx sign by push address', async () => {
- // signed by `push:devnet:pushconsumer1ulpxwud78ctaar5zgeuhmju5k8gpz8najcvxkn`
- const sentTx =
- '1210435553544f4d3a505553485f4d41494c1a3f707573683a6465766e65743a70757368636f6e73756d657231756c707877756437386374616172357a676575686d6a75356b3867707a386e616a6376786b6e2a200a047465737412060a047465737422100a085072696f72697479120448696768321083f01bffe4ff45f6acb525a54dc7277e3a9f0f56543165794a756232526c6379493657337369626d396b5a556c6b496a6f694d4867345a5445795a4555784d6b4d7a4e575642516d597a4e5749314e6d49774e4555314d304d30525451324f4755304e6a63794e3055344969776964484e4e6157787361584d694f6a45334d6a6b324e7a45324d4441774e7a4173496e4a68626d52766255686c65434936496d45324d6a41324f5459314e7a51314d4445324e4449794e47526a4d444e6b4f545a6c5a5467774d4459304f54686b4d7a45304d6a45694c434a776157356e556d567a645778306379493657337369626d396b5a556c6b496a6f694d48686d524546465957593359575a44526d4a694e4755305a44453252454d324e6d4a454d6a417a4f575a6b4e6a41774e454e47593255344969776964484e4e6157787361584d694f6a45334d6a6b324e7a45314e7a41774f446773496e4e3059585231637949364d58307365794a756232526c535751694f69497765446b34526a6c454f5445775157566d4f55497a516a6c424e4455784d7a64685a6a4644515463324e7a566c52446b775954557a4e5455694c434a306330317062477870637949364d5463794f5459334d5455334d4441324e437769633352686448567a496a6f7866563073496e4e705a323568644856795a534936496a42345a57566d4f445a694d5759314d4759324f574d794e4445314f57457a5a4449794f474d795a6a4e6c4d324579597a417a4d4749784f5449785a544a6a4e6a426b5a6a5179595745334f5467775a6a4d355a4463354e6a517a4d32566a4e324e6a4e6d49344e57497a597a64684d6a51345a6d4d7a4e7a426b5a6a67784e6a646a4e4463774f5468694d7a517a4e4751324e4745784d6d5530596a526b595745355a4749344e6a55334f44677859794a394c487369626d396b5a556c6b496a6f694d48686d524546465957593359575a44526d4a694e4755305a44453252454d324e6d4a454d6a417a4f575a6b4e6a41774e454e47593255344969776964484e4e6157787361584d694f6a45334d6a6b324e7a45324d4441774e546373496e4a68626d52766255686c65434936496a6b794d5455334d5468684e324d7a4e6d49304d6d5a6d4e325530593259334e325977593256684e6d49344e7a526b4e6a49355a6d55694c434a776157356e556d567a645778306379493657337369626d396b5a556c6b496a6f694d4867345a5445795a4555784d6b4d7a4e575642516d597a4e5749314e6d49774e4555314d304d30525451324f4755304e6a63794e3055344969776964484e4e6157787361584d694f6a45334d6a6b324e7a45314e7a41774e6a4d73496e4e3059585231637949364d58307365794a756232526c535751694f69497765446b34526a6c454f5445775157566d4f55497a516a6c424e4455784d7a64685a6a4644515463324e7a566c52446b775954557a4e5455694c434a306330317062477870637949364d5463794f5459334d5455334d4441304e437769633352686448567a496a6f7866563073496e4e705a323568644856795a534936496a42344e545a6a4e7a466b5a44426c4d4751315a47466d4d54557a5a44686d596a686b596a646b4f5459325a6a4d355a44466c4f4467334f445a6a4e6a4178596d49794d446b785a44497759574a6c4f5755324d3246695a54426a5a44413359324a6a4e6d46694e57466a4e6d4d7a596d5a6a4d445534596a566a59324a6a4e6a67784e7a5977597a566b4d4749324e544e684f4442684d6a55304d54497a4e4746694f5751325a54517a597a557859794a394c487369626d396b5a556c6b496a6f694d4867354f45593552446b784d45466c5a6a6c434d304935515451314d544d3359575978513045334e6a63315a5551354d4745314d7a55314969776964484e4e6157787361584d694f6a45334d6a6b324e7a45324d4441774f446773496e4a68626d52766255686c65434936496a45314f474d31597a41325a4459334e5751304d44417a4e546b774f4445774e6a686a597a5130596a457a4d444e6c4d54566c4e6d51694c434a776157356e556d567a645778306379493657337369626d396b5a556c6b496a6f694d4867345a5445795a4555784d6b4d7a4e575642516d597a4e5749314e6d49774e4555314d304d30525451324f4755304e6a63794e3055344969776964484e4e6157787361584d694f6a45334d6a6b324e7a45314e7a41774e7a4173496e4e3059585231637949364d58307365794a756232526c535751694f69497765475a45515556685a6a64685a6b4e47596d49305a54526b4d545a45517a5932596b51794d444d355a6d51324d44413051305a6a5a5467694c434a306330317062477870637949364d5463794f5459334d5455334d4441314d797769633352686448567a496a6f7866563073496e4e705a323568644856795a534936496a42344e4455324d47526a4d5459774d7a5132597a457a4e54526a4f444d344f54686a4e7a63314d324a6a4d546378595459794d4455775a546379597a466a4d5456684f5455784d6a63785a6a56694d444d78596a426c597a5133596d59324e325a684e6a5577596a426c4d7a4a68596a4d774d6d5535597a6b344d546b775a444a6a597a55795a474a6b4e44566d5a4445324d3245335954646c4f574e6d596a6c6a59546b354d7a63345a47517859794a395858303d424129e393b87724b2d2b677d94a6b574f811b053b4033c3a81cac80f1f19cc9f1f723b0901d1327d2418c33a6b8647f80ee850f8c2ee477caaafb34e28c45ee13c01b4a0130';
-
- const deserializedTx = Tx.deserialize(hexToBytes(`0x${sentTx}`));
-
- const serializedUnsignedTx = Tx.serialize({
- ...deserializedTx,
- signature: new Uint8Array(0),
- });
-
- const dataToBeSigned = new TextEncoder().encode(
- toHex(sha256(serializedUnsignedTx))
- );
-
- const sigVerification = await verifyMessage({
- address: Address.pushToEvm(
- 'pushconsumer1ulpxwud78ctaar5zgeuhmju5k8gpz8najcvxkn'
- ) as `0x${string}`,
- message: { raw: dataToBeSigned },
- signature: deserializedTx.signature,
- });
- expect(sigVerification).toBe(true);
- });
-});
diff --git a/packages/core/tests/utils/utils.test.ts b/packages/core/tests/utils/utils.test.ts
deleted file mode 100644
index 17ffe9a1..00000000
--- a/packages/core/tests/utils/utils.test.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { getRandomElement } from '../../src/lib/utils';
-
-describe('getRandomElement', () => {
- it('should return a valid element (Small Array ~ 1k elements)', () => {
- const testArray = Array.from(
- { length: 1000 },
- (_, i) => `https://validator/${i}`
- );
- const element = getRandomElement(testArray);
- expect(testArray).toContain(element);
- });
-
- it('should return a valid element (Large Array ~ 10k elements)', () => {
- const testArray = Array.from(
- { length: 10000 },
- (_, i) => `https://validator/${i}`
- );
- const element = getRandomElement(testArray);
- expect(testArray).toContain(element);
- });
-
- it('should return a valid element (Large Array ~ 100k elements)', () => {
- const testArray = Array.from(
- { length: 100000 },
- (_, i) => `https://validator/${i}`
- );
- const element = getRandomElement(testArray);
- expect(testArray).toContain(element);
- });
-
- it('should throw an error if array length is 0', () => {
- expect(() => getRandomElement([])).toThrow('Array cannot be empty');
- });
-});
diff --git a/packages/core/tests/validator/backend-smoke-test.test.ts b/packages/core/tests/validator/backend-smoke-test.test.ts
deleted file mode 100644
index 2eb0ea0c..00000000
--- a/packages/core/tests/validator/backend-smoke-test.test.ts
+++ /dev/null
@@ -1,120 +0,0 @@
-import { Address, Tx } from '../../src';
-import { TxCategory } from '../../src/lib/tx/tx.types';
-import { InitDid } from '../../src/lib/generated/txData/init_did';
-import { config } from '../config';
-import { TxResponse } from '../../src/lib/tx/tx.types';
-import {
- generatePrivateKey,
- privateKeyToAccount,
- privateKeyToAddress,
-} from 'viem/accounts';
-import { hexToBytes, toHex, verifyMessage } from 'viem';
-import { ENV } from '../../src/lib/constants';
-import { sha256 } from '@noble/hashes/sha256';
-import * as nacl from 'tweetnacl';
-import bs58 from 'bs58';
-import { INIT_DID_TX, INIT_DID_TX_2 } from '../data';
-
-const test_pk = generatePrivateKey();
-const test_account = privateKeyToAccount(test_pk);
-// Mock data for testing
-const mockInitDidTxData: InitDid = {
- masterPubKey: test_account.publicKey.slice(2), // remove 0x
- derivedKeyIndex: 0,
- derivedPubKey: '00000',
- walletToEncDerivedKey: {
- 'push:devnet:push1xkuy66zg69jp29muvnty2prx8wvc5645f9y5ux': {
- encDerivedPrivKey: {
- ciphertext: 'sample_ciphertext',
- salt: 'sample_salt',
- nonce: 'sample_nonce',
- version: 'push:v5',
- preKey: 'sample_prekey',
- },
- signature: new Uint8Array([1, 2, 3]),
- },
- },
-};
-const mockRecipients = [
- `eip155:1:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:137:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:97:${privateKeyToAddress(generatePrivateKey())}`,
-];
-
-// add .skip if needed
-describe('validator smoke test', () => {
-
- // switch to ENV.LOCAL or ENV.DEV
- const env = config.ENV;
-
- it('write :: itx :: send INIT_DID tx', async () => {
- const account = privateKeyToAccount(
- INIT_DID_TX_2.masterPrivateKey as `0x${string}`
- );
- const signer = {
- account: Address.toPushCAIP(account.address, ENV.DEV),
- signMessage: async (data: Uint8Array) => {
- const signature = await account.signMessage({
- message: { raw: data },
- });
- return hexToBytes(signature);
- },
- };
- const txInstance = await Tx.initialize(env);
- const res = await txInstance.send(INIT_DID_TX_2.unsignedInitDIDTx, signer);
- expect(typeof res).toEqual('string');
- });
-
-
- it('write :: ctx :: write custom tx THEN read', async () => {
- const txInstance = await Tx.initialize(env);
- const recipients = [
- `eip155:1:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:137:${privateKeyToAddress(generatePrivateKey())}`,
- `eip155:97:${privateKeyToAddress(generatePrivateKey())}`,
- ];
- const sampleTx = txInstance.createUnsigned(
- 'CUSTOM:CORE_SDK',
- recipients,
- new Uint8Array([1, 2, 3, 4, 5])
- );
-
- const pk = generatePrivateKey();
- const account = privateKeyToAccount(pk);
- const signer = {
- account: Address.toPushCAIP(account.address, ENV.DEV),
- signMessage: async (data: Uint8Array) => {
- const signature = await account.signMessage({
- message: { raw: data },
- });
- return hexToBytes(signature);
- },
- };
- const res = await txInstance.send(sampleTx, signer);
- expect(typeof res).toEqual('string');
-
- // read
- for (const recipient of recipients) {
- const res = await txInstance.getTransactionsFromVNode(recipient, "CUSTOM:CORE_SDK");
- expect(res.items).toBeInstanceOf(Array);
- const item0 = res.items[0];
- expect(item0.sender).toEqual(signer.account);
- expect(item0.recipients).toEqual(sampleTx.recipients);
- const sampleDataBase16 = toHex(sampleTx.data).substring(2);
- expect(item0.data).toEqual(sampleDataBase16);
- console.log("OK %o", res);
- }
- });
-
-
- it('read :: should get transactions with custom parameters', async () => {
- const txInstance = await Tx.initialize(env);
- const res = await txInstance.getTransactionsFromVNode(
- "eip155:1:0x76cfb79DA0f91b2C162cA2a23f7f0117bD8cDB2c",
- "CUSTOM:CORE_SDK");
- expect(res.items).toBeInstanceOf(Array);
- console.log("%o", res);
- });
-
-
-});
diff --git a/packages/core/tests/validator/validator.test.ts b/packages/core/tests/validator/validator.test.ts
deleted file mode 100644
index b61449d9..00000000
--- a/packages/core/tests/validator/validator.test.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { Validator } from '../../src';
-import {
- PingReply,
- TokenReply,
- ActiveValidator,
-} from '../../src/lib/validator/validator.types';
-import { config } from '../config';
-
-describe('Validator Class', () => {
- const env = config.ENV;
-
- it('Initialize Validator', async () => {
- const validatorInstance = await Validator.initalize({ env });
- const activeValidators = (
- (await validatorInstance[
- 'validatorContractClient'
- ].read.getActiveVNodes()) as []
- ).map((each) => {
- return (each as ActiveValidator).nodeApiBaseUrl;
- });
- expect(activeValidators).toContain(validatorInstance['activeValidatorURL']);
- });
- it('Ping every active validator node', async () => {
- const validatorInstance = await Validator.initalize({ env });
-
- const activeValidators: ActiveValidator[] = await validatorInstance[
- 'validatorContractClient'
- ].read.getActiveVNodes();
-
- for (const each of activeValidators) {
- const pingReply = await validatorInstance.call<'true' | 'false'>(
- 'push_listening',
- [],
- each.nodeApiBaseUrl
- );
- expect(pingReply === 'true' || pingReply === 'false').toBe(true);
- // expect(pingReply).not.toBeNull();
- // expect(pingReply?.nodeId).toBe(each.nodeWallet);
- // expect(pingReply?.status).toBe(1);
- }
- });
- it('Ping active read validator node', async () => {
- const validatorInstance = await Validator.initalize({ env });
- // default active read validator
- const pingReply = await validatorInstance.call<'true' | 'false'>(
- 'push_listening'
- );
- expect(pingReply === 'true' || pingReply === 'false').toBe(true);
- // expect(pingReply).not.toBeNull();
- // expect(pingReply?.status).toBe(1);
- });
- it('Get token from random active validator node', async () => {
- const validatorInstance = await Validator.initalize({ env });
- const token = await validatorInstance.call('push_getApiToken');
- expect(token).not.toBeNull();
- expect(typeof token?.apiToken).toBe('string');
- expect(typeof token?.apiUrl).toBe('string');
- });
-});
diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json
deleted file mode 100644
index f5b85657..00000000
--- a/packages/core/tsconfig.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "extends": "../../tsconfig.base.json",
- "compilerOptions": {
- "module": "commonjs",
- "forceConsistentCasingInFileNames": true,
- "strict": true,
- "noImplicitOverride": true,
- "noPropertyAccessFromIndexSignature": true,
- "noImplicitReturns": true,
- "noFallthroughCasesInSwitch": true
- },
- "files": [],
- "include": [],
- "references": [
- {
- "path": "./tsconfig.lib.json"
- },
- {
- "path": "./tsconfig.spec.json"
- }
- ]
-}
diff --git a/packages/core/tsconfig.lib.json b/packages/core/tsconfig.lib.json
deleted file mode 100644
index 33eca2c2..00000000
--- a/packages/core/tsconfig.lib.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "extends": "./tsconfig.json",
- "compilerOptions": {
- "outDir": "../../dist/out-tsc",
- "declaration": true,
- "types": ["node"]
- },
- "include": ["src/**/*.ts"],
- "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
-}
diff --git a/packages/core/tsconfig.spec.json b/packages/core/tsconfig.spec.json
deleted file mode 100644
index 9b2a121d..00000000
--- a/packages/core/tsconfig.spec.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "extends": "./tsconfig.json",
- "compilerOptions": {
- "outDir": "../../dist/out-tsc",
- "module": "commonjs",
- "types": ["jest", "node"]
- },
- "include": [
- "jest.config.ts",
- "src/**/*.test.ts",
- "src/**/*.spec.ts",
- "src/**/*.d.ts"
- ]
-}
diff --git a/tsconfig.base.json b/tsconfig.base.json
deleted file mode 100644
index 1487ddad..00000000
--- a/tsconfig.base.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "compileOnSave": false,
- "compilerOptions": {
- "rootDir": ".",
- "sourceMap": true,
- "declaration": false,
- "moduleResolution": "node",
- "emitDecoratorMetadata": true,
- "experimentalDecorators": true,
- "importHelpers": true,
- "target": "es2015",
- "module": "esnext",
- "lib": ["es2020", "dom"],
- "skipLibCheck": true,
- "skipDefaultLibCheck": true,
- "baseUrl": ".",
- "paths": {
- "core": ["packages/core/src/index.ts"]
- }
- },
- "exclude": ["node_modules", "tmp"]
-}