@render-foundation/utils 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/dbTypes.js +3 -0
- package/lib/cjs/dbTypes.js.map +1 -0
- package/lib/cjs/index.js +19 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/pgClient.js +242 -0
- package/lib/cjs/pgClient.js.map +1 -0
- package/lib/cjs/wormhole.js +67 -0
- package/lib/cjs/wormhole.js.map +1 -0
- package/lib/esm/src/dbTypes.js +2 -0
- package/lib/esm/src/dbTypes.js.map +1 -0
- package/lib/esm/src/index.js +3 -0
- package/lib/esm/src/index.js.map +1 -0
- package/lib/esm/src/pgClient.js +218 -0
- package/lib/esm/src/pgClient.js.map +1 -0
- package/lib/esm/src/wormhole.js +31 -0
- package/lib/esm/src/wormhole.js.map +1 -0
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/lib/types/src/dbTypes.d.ts +47 -0
- package/lib/types/src/dbTypes.d.ts.map +1 -0
- package/lib/types/src/index.d.ts +3 -0
- package/lib/types/src/index.d.ts.map +1 -0
- package/lib/types/src/pgClient.d.ts +56 -0
- package/lib/types/src/pgClient.d.ts.map +1 -0
- package/lib/types/src/wormhole.d.ts +8 -0
- package/lib/types/src/wormhole.d.ts.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ColumnType } from "kysely";
|
|
2
|
+
export type Generated<T> = T extends ColumnType<infer S, infer I, infer U> ? ColumnType<S, I | undefined, U> : ColumnType<T, T | undefined, T>;
|
|
3
|
+
export type Int8 = ColumnType<string, bigint | number | string, bigint | number | string>;
|
|
4
|
+
export type Timestamp = ColumnType<Date, Date | string, Date | string>;
|
|
5
|
+
export type TransferType = "node_operator_rewards" | "open_compute_rewards" | "upgrade_rewards";
|
|
6
|
+
export type TxStatus = "created" | "executed" | "ready";
|
|
7
|
+
export interface NodeOperatorRewardsTransfer {
|
|
8
|
+
end_time: Timestamp | null;
|
|
9
|
+
epoch_id: Generated<Int8>;
|
|
10
|
+
start_time: Timestamp | null;
|
|
11
|
+
transfer_id: Generated<Int8>;
|
|
12
|
+
}
|
|
13
|
+
export interface OpenComputeRewardsTransfer {
|
|
14
|
+
device_id: string | null;
|
|
15
|
+
epoch_id: Generated<Int8>;
|
|
16
|
+
transfer_id: Generated<Int8>;
|
|
17
|
+
}
|
|
18
|
+
export interface SquadsTx {
|
|
19
|
+
id: Generated<Int8>;
|
|
20
|
+
sq_tx: string;
|
|
21
|
+
tx_status: TxStatus;
|
|
22
|
+
}
|
|
23
|
+
export interface Transfer {
|
|
24
|
+
amount_due: Int8;
|
|
25
|
+
amount_payed: Int8;
|
|
26
|
+
created_at: Generated<Timestamp>;
|
|
27
|
+
id: Generated<Int8>;
|
|
28
|
+
payed_at: Timestamp | null;
|
|
29
|
+
sol_key: string | null;
|
|
30
|
+
sol_tx: string | null;
|
|
31
|
+
sq_tx_id: Int8 | null;
|
|
32
|
+
transfer_type: TransferType;
|
|
33
|
+
}
|
|
34
|
+
export interface UpgradeRewardsTransfer {
|
|
35
|
+
epoch_id: Generated<Int8>;
|
|
36
|
+
epoch_start_time: Timestamp | null;
|
|
37
|
+
points: Int8 | null;
|
|
38
|
+
transfer_id: Generated<Int8>;
|
|
39
|
+
}
|
|
40
|
+
export interface DB {
|
|
41
|
+
node_operator_rewards_transfer: NodeOperatorRewardsTransfer;
|
|
42
|
+
open_compute_rewards_transfer: OpenComputeRewardsTransfer;
|
|
43
|
+
squads_tx: SquadsTx;
|
|
44
|
+
transfer: Transfer;
|
|
45
|
+
upgrade_rewards_transfer: UpgradeRewardsTransfer;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=dbTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbTypes.d.ts","sourceRoot":"","sources":["../../../src/dbTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,E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B,UAAU,EAAE,IAAI,CAAC;IACjB,YAAY,EAAE,IAAI,CAAC;IACnB,UAAU,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,aAAa,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1B,gBAAgB,EAAE,SAAS,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,EAAE;IACjB,8BAA8B,EAAE,2BAA2B,CAAC;IAC5D,6BAA6B,EAAE,0BAA0B,CAAC;IAC1D,SAAS,EAAE,QAAQ,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,wBAAwB,EAAE,sBAAsB,CAAC;CAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { TxStatus } from './dbTypes';
|
|
2
|
+
export type TransferType = 'open_compute_rewards' | 'node_operator_rewards' | 'upgrade_rewards';
|
|
3
|
+
export interface Transfer {
|
|
4
|
+
id?: bigint;
|
|
5
|
+
solKey?: string;
|
|
6
|
+
solTx?: string;
|
|
7
|
+
sqTx?: string;
|
|
8
|
+
txStatus?: TxStatus;
|
|
9
|
+
createdAt?: Date;
|
|
10
|
+
payedAt?: Date;
|
|
11
|
+
amountDue: bigint;
|
|
12
|
+
amountPayed?: bigint;
|
|
13
|
+
operatorRewards?: NodeOperatorRewardsTransfer;
|
|
14
|
+
computeClientRewards?: ComputeClientsRewardsTransfer;
|
|
15
|
+
upgradeRewards?: UpgradeRewardsTransfer;
|
|
16
|
+
}
|
|
17
|
+
export interface UpgradeRewardsTransfer {
|
|
18
|
+
epochId: number;
|
|
19
|
+
epochStartTime: Date;
|
|
20
|
+
points: bigint;
|
|
21
|
+
}
|
|
22
|
+
export interface NodeOperatorRewardsTransfer {
|
|
23
|
+
epochId: number;
|
|
24
|
+
startTime: Date;
|
|
25
|
+
endTime: Date;
|
|
26
|
+
}
|
|
27
|
+
export interface ComputeClientsRewardsTransfer {
|
|
28
|
+
epochId: number;
|
|
29
|
+
deviceId: string;
|
|
30
|
+
}
|
|
31
|
+
interface PgClient {
|
|
32
|
+
payoutTransfersSquads(ts: Record<string, bigint>, payedAt: Date, solTx: string, sqTx: string): Promise<void>;
|
|
33
|
+
updateSqTx(tx: string, status: TxStatus): Promise<void>;
|
|
34
|
+
setSqTx(transferIds: bigint[], sqTx: string): Promise<void>;
|
|
35
|
+
getOutstanding(f: {
|
|
36
|
+
typ: TransferType;
|
|
37
|
+
}): Promise<Record<string, bigint>>;
|
|
38
|
+
createTransfers(transfers: Transfer[]): Promise<void>;
|
|
39
|
+
fetchTransfers(f: {
|
|
40
|
+
epochId?: number;
|
|
41
|
+
payed?: boolean;
|
|
42
|
+
typ: TransferType;
|
|
43
|
+
status?: TxStatus | 'notx';
|
|
44
|
+
}): Promise<Transfer[]>;
|
|
45
|
+
payoutTransfer(id: bigint, payedAt: Date, solTx: string, amtPayed: bigint, sqTx: string): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export declare const pgClient: (config: {
|
|
48
|
+
database: string;
|
|
49
|
+
host: string;
|
|
50
|
+
user: string;
|
|
51
|
+
password: string;
|
|
52
|
+
port?: number;
|
|
53
|
+
max?: number;
|
|
54
|
+
}) => PgClient;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=pgClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pgClient.d.ts","sourceRoot":"","sources":["../../../src/pgClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmF,QAAQ,EAAC,MAAM,WAAW,CAAA;AAIpH,MAAM,MAAM,YAAY,GAAG,sBAAsB,GAAG,uBAAuB,GAAG,iBAAiB,CAAC;AAEhG,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,2BAA2B,CAAA;IAC7C,oBAAoB,CAAC,EAAE,6BAA6B,CAAA;IACpD,cAAc,CAAC,EAAE,sBAAsB,CAAA;CACxC;AA8BD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;CACf;AAED,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,QAAQ;IAChB,qBAAqB,CACnB,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1B,OAAO,EAAE,IAAI,EACb,KAAK,EA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4
|
+
from: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export declare const fetchEthInfo: (seq: number, wormEnv?: 'MAINNET' | 'TESTNET', ethChainId?: number, retries?: number) => Promise<[number, EthInfo]>;
|
|
8
|
+
//# sourceMappingURL=wormhole.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wormhole.d.ts","sourceRoot":"","sources":["../../../src/wormhole.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,OAAO,GAAG;IAAC,QAAQ,EAAE;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAA;CAAC,CAAA;AAEhE,eAAO,MAAM,YAAY,QAClB,MAAM,YACF,SAAS,GAAG,SAAS,eAClB,MAAM,uBAEjB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAqC3B,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@render-foundation/utils",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Utils shared across Render libs",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"registry": "https://registry.npmjs.org/"
|
|
8
|
+
},
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/rndr-network/render-program-library"
|
|
13
|
+
},
|
|
14
|
+
"main": "./lib/cjs/index.js",
|
|
15
|
+
"module": "./lib/esm/src/index.js",
|
|
16
|
+
"types": "./lib/types/src/index.d.ts",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"files": [
|
|
19
|
+
"lib"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
"import": "./lib/esm/src/index.js",
|
|
23
|
+
"require": "./lib/cjs/index.js",
|
|
24
|
+
"types": "./lib/types/src/index.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
28
|
+
"precommit": "npx git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' .",
|
|
29
|
+
"clean": "npx shx mkdir -p lib && npx shx rm -rf lib",
|
|
30
|
+
"package": "npx shx mkdir -p lib/cjs lib/esm",
|
|
31
|
+
"prebuild": "npm run clean && npm run package"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@certusone/wormhole-sdk": "^0.10.9",
|
|
35
|
+
"@coral-xyz/anchor": "0.26.0",
|
|
36
|
+
"@solana/web3.js": "^1.43.4",
|
|
37
|
+
"bn.js": "5.1.3",
|
|
38
|
+
"borsh": "^0.7.0",
|
|
39
|
+
"bs58": "^5.0.0",
|
|
40
|
+
"kysely": "^0.27.2",
|
|
41
|
+
"pg": "^8.11.3"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"git-format-staged": "^2.1.3",
|
|
45
|
+
"kysely-codegen": "^0.11.0",
|
|
46
|
+
"ts-loader": "^9.2.3",
|
|
47
|
+
"typescript": "^4.3.4",
|
|
48
|
+
"yarn": "^1.22.18"
|
|
49
|
+
}
|
|
50
|
+
}
|