chore: apply prettier

This commit is contained in:
2025-05-05 22:51:21 -03:00
parent 290bebb112
commit 3f10aacb72
26 changed files with 2126 additions and 2051 deletions

View File

@ -4,4 +4,3 @@ export default {
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
testEnvironment: "node", testEnvironment: "node",
}; };

View File

@ -21,7 +21,6 @@ export async function task(roundNumber: number): Promise<void> {
// FORCE TO PAUSE 30 SECONDS // FORCE TO PAUSE 30 SECONDS
// No submission on Round 0 so no need to trigger fetch audit result before round 3 // No submission on Round 0 so no need to trigger fetch audit result before round 3
// Changed from 3 to 4 to have more time // Changed from 3 to 4 to have more time
// if (roundNumber >= 4) { // if (roundNumber >= 4) {
// const auditRound = roundNumber - 4; // const auditRound = roundNumber - 4;
// const response = await fetch(`${middleServerUrl}/summarizer/worker/update-audit-result`, { // const response = await fetch(`${middleServerUrl}/summarizer/worker/update-audit-result`, {

View File

@ -24,7 +24,7 @@ export async function submission(roundNumber: number): Promise<string | void> {
* The default implementation handles uploading the proofs to IPFS * The default implementation handles uploading the proofs to IPFS
* and returning the CID * and returning the CID
*/ */
if(!await preRunCheck(roundNumber.toString())){ if (!(await preRunCheck(roundNumber.toString()))) {
return; return;
} }
const stakingKeypair = await namespaceWrapper.getSubmitterAccount(); const stakingKeypair = await namespaceWrapper.getSubmitterAccount();
@ -51,7 +51,7 @@ export async function submission(roundNumber: number): Promise<string | void> {
roundNumber, roundNumber,
stakingKey, stakingKey,
publicKey: pubKey, publicKey: pubKey,
secretKey secretKey,
}); });
return cid || void 0; return cid || void 0;
@ -94,16 +94,19 @@ async function makeSubmission(params: SubmissionParams): Promise<string | void>
prUrl: submissionData.prUrl, prUrl: submissionData.prUrl,
stakingKey, stakingKey,
publicKey, publicKey,
secretKey secretKey,
}); });
const signature = await signSubmissionPayload({ const signature = await signSubmissionPayload(
{
taskId: TASK_ID, taskId: TASK_ID,
roundNumber, roundNumber,
stakingKey, stakingKey,
pubKey: publicKey, pubKey: publicKey,
...submissionData ...submissionData,
}, secretKey); },
secretKey,
);
const cid = await storeSubmissionOnIPFS(signature); const cid = await storeSubmissionOnIPFS(signature);
await cleanupSubmissionState(); await cleanupSubmissionState();
@ -120,9 +123,7 @@ async function fetchSubmissionData(orcaClient: any, swarmBountyId: string): Prom
return null; return null;
} }
const submission = typeof result.data === 'object' && 'data' in result.data const submission = typeof result.data === "object" && "data" in result.data ? result.data.data : result.data;
? result.data.data
: result.data;
if (!submission?.prUrl) { if (!submission?.prUrl) {
throw new Error("Submission is missing PR URL"); throw new Error("Submission is missing PR URL");

View File

@ -14,7 +14,6 @@ import { middleServerUrl, status } from "../utils/constant";
//Example route //Example route
export async function routes() { export async function routes() {
app.get("/value", async (_req, res) => { app.get("/value", async (_req, res) => {
const value = await namespaceWrapper.storeGet("value"); const value = await namespaceWrapper.storeGet("value");
console.log("value", value); console.log("value", value);
@ -128,7 +127,6 @@ export async function routes() {
}); });
} }
// TODO: To be completed // TODO: To be completed
app.post("/failed-task", async (req, res) => { app.post("/failed-task", async (req, res) => {
res.status(200).json({ result: "Successfully saved task result" }); res.status(200).json({ result: "Successfully saved task result" });

View File

@ -4,33 +4,32 @@ export function isValidAnthropicApiKey(key: string) {
} }
export async function checkAnthropicAPIKey(apiKey: string) { export async function checkAnthropicAPIKey(apiKey: string) {
const response = await fetch('https://api.anthropic.com/v1/messages', { const response = await fetch("https://api.anthropic.com/v1/messages", {
method: 'POST', method: "POST",
headers: { headers: {
'x-api-key': apiKey, "x-api-key": apiKey,
'anthropic-version': '2023-06-01', "anthropic-version": "2023-06-01",
'content-type': 'application/json', "content-type": "application/json",
}, },
body: JSON.stringify({ body: JSON.stringify({
model: 'claude-3-opus-20240229', // or a cheaper model model: "claude-3-opus-20240229", // or a cheaper model
max_tokens: 1, // minimal usage max_tokens: 1, // minimal usage
messages: [{ role: 'user', content: 'Hi' }], messages: [{ role: "user", content: "Hi" }],
}), }),
}); });
if (response.status === 200) { if (response.status === 200) {
console.log('✅ API key is valid and has credit.'); console.log("✅ API key is valid and has credit.");
return true; return true;
} else { } else {
const data = await response.json().catch(() => ({})); const data = await response.json().catch(() => ({}));
if (response.status === 401) { if (response.status === 401) {
console.log('❌ Invalid API key.'); console.log("❌ Invalid API key.");
} else if (response.status === 403 && data.error?.message?.includes('billing')) { } else if (response.status === 403 && data.error?.message?.includes("billing")) {
console.log('❌ API key has no credit or is not authorized.'); console.log("❌ API key has no credit or is not authorized.");
} else { } else {
console.log('⚠️ Unexpected error:', data); console.log("⚠️ Unexpected error:", data);
} }
return false; return false;
} }
} }

View File

@ -4,33 +4,33 @@ export async function checkGitHub(username: string, token: string) {
const isUsernameValid = userRes.status === 200; const isUsernameValid = userRes.status === 200;
// 2. Check token // 2. Check token
const tokenRes = await fetch('https://api.github.com/user', { const tokenRes = await fetch("https://api.github.com/user", {
headers: { headers: {
Authorization: `token ${token}`, Authorization: `token ${token}`,
}, },
}); });
const isTokenValid = tokenRes.status === 200; const isTokenValid = tokenRes.status === 200;
const isIdentityValid = await checkGitHubIdentity(username, token); const isIdentityValid = await checkGitHubIdentity(username, token);
return isIdentityValid&&isUsernameValid&&isTokenValid return isIdentityValid && isUsernameValid && isTokenValid;
} }
async function checkGitHubIdentity(username: string, token: string) { async function checkGitHubIdentity(username: string, token: string) {
const res = await fetch('https://api.github.com/user', { const res = await fetch("https://api.github.com/user", {
headers: { headers: {
Authorization: `token ${token}`, Authorization: `token ${token}`,
Accept: 'application/vnd.github.v3+json', Accept: "application/vnd.github.v3+json",
}, },
}); });
if (res.status !== 200) { if (res.status !== 200) {
return false return false;
} }
const data = await res.json(); const data = await res.json();
if (data.login.toLowerCase() !== username.toLowerCase()) { if (data.login.toLowerCase() !== username.toLowerCase()) {
return false return false;
} }
return true return true;
} }

View File

@ -28,7 +28,7 @@ export async function getExistingIssues(): Promise<BountyIssue[]> {
for (const line of bountyMarkdownFileLines) { for (const line of bountyMarkdownFileLines) {
// Skip empty lines // Skip empty lines
if (line.trim() === '') { if (line.trim() === "") {
// console.log('Skipping empty line'); // console.log('Skipping empty line');
continue; continue;
} }
@ -36,34 +36,37 @@ export async function getExistingIssues(): Promise<BountyIssue[]> {
// console.log('Processing line:', line); // console.log('Processing line:', line);
// Skip the title line starting with # // Skip the title line starting with #
if (line.startsWith('#')) { if (line.startsWith("#")) {
// console.log('Found title line:', line); // console.log('Found title line:', line);
continue; continue;
} }
// Skip the header and separator lines // Skip the header and separator lines
if (line.startsWith('|') && line.includes('GitHub URL')) { if (line.startsWith("|") && line.includes("GitHub URL")) {
//console.log('Found header line'); //console.log('Found header line');
continue; continue;
} }
if (line.startsWith('|') && line.includes('-----')) { if (line.startsWith("|") && line.includes("-----")) {
// console.log('Found separator line'); // console.log('Found separator line');
continue; continue;
} }
// Process table rows // Process table rows
if (line.startsWith('|')) { if (line.startsWith("|")) {
isTableStarted = true; isTableStarted = true;
// Remove first and last | and split by | // Remove first and last | and split by |
const cells = line.slice(1, -1).split('|').map(cell => cell.trim()); const cells = line
.slice(1, -1)
.split("|")
.map((cell) => cell.trim());
// console.log('Parsed cells:', cells); // console.log('Parsed cells:', cells);
// Extract GitHub URL and name from markdown link format [name](url) // Extract GitHub URL and name from markdown link format [name](url)
const githubUrlMatch = cells[0].match(/\[(.*?)\]\((.*?)\)/); const githubUrlMatch = cells[0].match(/\[(.*?)\]\((.*?)\)/);
// console.log('GitHub URL match:', githubUrlMatch); // console.log('GitHub URL match:', githubUrlMatch);
const projectName = githubUrlMatch ? githubUrlMatch[1] : ''; const projectName = githubUrlMatch ? githubUrlMatch[1] : "";
const githubUrl = githubUrlMatch ? githubUrlMatch[2] : ''; const githubUrl = githubUrlMatch ? githubUrlMatch[2] : "";
const issue: BountyIssue = { const issue: BountyIssue = {
githubUrl, githubUrl,
@ -73,7 +76,7 @@ export async function getExistingIssues(): Promise<BountyIssue[]> {
bountyAmount: cells[4], bountyAmount: cells[4],
bountyType: cells[5], bountyType: cells[5],
transactionHash: cells[6], transactionHash: cells[6],
status: cells[7] status: cells[7],
}; };
// console.log('Created issue object:', issue); // console.log('Created issue object:', issue);
@ -81,21 +84,18 @@ export async function getExistingIssues(): Promise<BountyIssue[]> {
} }
} }
// Filter all issues with status "Initialized" && Bounty Task is Document & Summarize // Filter all issues with status "Initialized" && Bounty Task is Document & Summarize
console.log('Final parsed issues number:', issues.length); console.log("Final parsed issues number:", issues.length);
return issues return issues;
} catch (error) { } catch (error) {
// console.error('Error processing markdown:', error); // console.error('Error processing markdown:', error);
throw error; throw error;
} }
} }
export async function getInitializedDocumentSummarizeIssues(issues: BountyIssue[]) { export async function getInitializedDocumentSummarizeIssues(issues: BountyIssue[]) {
return issues.filter((issue) => issue.status === "Initialized" && issue.bountyTask === "Document & Summarize");
return issues.filter(issue => issue.status === "Initialized" && issue.bountyTask === "Document & Summarize");
} }
// async function main(){ // async function main(){
// const existingIssues = await getExistingIssues(); // const existingIssues = await getExistingIssues();
// const transactionHashs = [ // const transactionHashs = [

View File

@ -3,14 +3,21 @@ import { getFile } from "./ipfs";
import { Submission } from "@_koii/namespace-wrapper/dist/types"; import { Submission } from "@_koii/namespace-wrapper/dist/types";
import { Submitter } from "@_koii/task-manager/dist/types/global"; import { Submitter } from "@_koii/task-manager/dist/types/global";
import { namespaceWrapper } from "@_koii/namespace-wrapper"; import { namespaceWrapper } from "@_koii/namespace-wrapper";
export async function submissionJSONSignatureDecode({submission_value, submitterPublicKey, roundNumber}: {submission_value: string, submitterPublicKey: string, roundNumber: number}) { export async function submissionJSONSignatureDecode({
submission_value,
submitterPublicKey,
roundNumber,
}: {
submission_value: string;
submitterPublicKey: string;
roundNumber: number;
}) {
let submissionString; let submissionString;
try { try {
console.log("Getting file from IPFS", submission_value); console.log("Getting file from IPFS", submission_value);
submissionString = await getFile(submission_value); submissionString = await getFile(submission_value);
console.log("submissionString", submissionString); console.log("submissionString", submissionString);
} catch (error) { } catch (error) {
console.log("error", error); console.log("error", error);
console.error("INVALID SIGNATURE DATA"); console.error("INVALID SIGNATURE DATA");
return null; return null;

View File

@ -16,7 +16,7 @@ export async function task(){
if (!orcaClient || !stakingKeypair || !pubKey) { if (!orcaClient || !stakingKeypair || !pubKey) {
await namespaceWrapper.logMessage(LogLevel.Error, errorMessage.NO_ORCA_CLIENT, actionMessage.NO_ORCA_CLIENT); await namespaceWrapper.logMessage(LogLevel.Error, errorMessage.NO_ORCA_CLIENT, actionMessage.NO_ORCA_CLIENT);
// Wait for 1 minute before retrying // Wait for 1 minute before retrying
await new Promise(resolve => setTimeout(resolve, 60000)); await new Promise((resolve) => setTimeout(resolve, 60000));
continue; continue;
} }
const stakingKey = stakingKeypair.publicKey.toBase58(); const stakingKey = stakingKeypair.publicKey.toBase58();
@ -49,8 +49,10 @@ export async function task(){
break; break;
} }
console.log(`[TASK] Server returned status ${requiredWorkResponse.status}, retrying in ${retryDelay/1000} seconds...`); console.log(
await new Promise(resolve => setTimeout(resolve, retryDelay)); `[TASK] Server returned status ${requiredWorkResponse.status}, retrying in ${retryDelay / 1000} seconds...`,
);
await new Promise((resolve) => setTimeout(resolve, retryDelay));
} }
// check if the response is 200 after all retries // check if the response is 200 after all retries
@ -100,10 +102,10 @@ export async function task(){
} catch (error) { } catch (error) {
console.error("[TASK] EXECUTE TASK ERROR:", error); console.error("[TASK] EXECUTE TASK ERROR:", error);
// Wait for 1 minute before retrying on error // Wait for 1 minute before retrying on error
await new Promise(resolve => setTimeout(resolve, 60000)); await new Promise((resolve) => setTimeout(resolve, 60000));
} }
// Wait for 1 minute before starting the next iteration // Wait for 1 minute before starting the next iteration
await new Promise(resolve => setTimeout(resolve, 60000)); await new Promise((resolve) => setTimeout(resolve, 60000));
} }
} }

View File

@ -19,11 +19,13 @@ tests/
## Prerequisites ## Prerequisites
1. Install the test framework: 1. Install the test framework:
```bash ```bash
pip install -e test-framework/ pip install -e test-framework/
``` ```
2. Set up environment variables in `.env`: 2. Set up environment variables in `.env`:
``` ```
ANTHROPIC_API_KEY=your_test_key ANTHROPIC_API_KEY=your_test_key
GITHUB_USERNAME=your_test_username GITHUB_USERNAME=your_test_username
@ -47,12 +49,15 @@ python -m tests.e2e --reset
## Test Flow ## Test Flow
1. API Key Validation 1. API Key Validation
- Validates Anthropic API key - Validates Anthropic API key
2. GitHub Validation 2. GitHub Validation
- Validates GitHub credentials - Validates GitHub credentials
3. Todo Management 3. Todo Management
- Fetches todos for each worker - Fetches todos for each worker
- Generates summaries - Generates summaries
- Submits results - Submits results

View File

@ -1,12 +1,8 @@
import "dotenv/config"; import "dotenv/config";
export const TASK_ID = export const TASK_ID = process.env.TASK_ID || "BXbYKFdXZhQgEaMFbeShaisQBYG1FD4MiSf9gg4n6mVn";
process.env.TASK_ID || "BXbYKFdXZhQgEaMFbeShaisQBYG1FD4MiSf9gg4n6mVn"; export const WEBPACKED_FILE_PATH = process.env.WEBPACKED_FILE_PATH || "../dist/main.js";
export const WEBPACKED_FILE_PATH =
process.env.WEBPACKED_FILE_PATH || "../dist/main.js";
const envKeywords = process.env.TEST_KEYWORDS ?? ""; const envKeywords = process.env.TEST_KEYWORDS ?? "";
export const TEST_KEYWORDS = envKeywords export const TEST_KEYWORDS = envKeywords ? envKeywords.split(",") : ["TEST", "EZ TESTING"];
? envKeywords.split(",")
: ["TEST", "EZ TESTING"];

View File

@ -1,9 +1,9 @@
let imports = {}; let imports = {};
imports['__wbindgen_placeholder__'] = module.exports; imports["__wbindgen_placeholder__"] = module.exports;
let wasm; let wasm;
const { TextDecoder, TextEncoder } = require(`util`); const { TextDecoder, TextEncoder } = require(`util`);
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); let cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode(); cachedTextDecoder.decode();
@ -36,7 +36,9 @@ function addHeapObject(obj) {
return idx; return idx;
} }
function getObject(idx) { return heap[idx]; } function getObject(idx) {
return heap[idx];
}
function dropObject(idx) { function dropObject(idx) {
if (idx < 132) return; if (idx < 132) return;
@ -74,9 +76,10 @@ function getInt32Memory0() {
let WASM_VECTOR_LEN = 0; let WASM_VECTOR_LEN = 0;
let cachedTextEncoder = new TextEncoder('utf-8'); let cachedTextEncoder = new TextEncoder("utf-8");
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' const encodeString =
typeof cachedTextEncoder.encodeInto === "function"
? function (arg, view) { ? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view); return cachedTextEncoder.encodeInto(arg, view);
} }
@ -85,16 +88,17 @@ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
view.set(buf); view.set(buf);
return { return {
read: arg.length, read: arg.length,
written: buf.length written: buf.length,
};
}; };
});
function passStringToWasm0(arg, malloc, realloc) { function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) { if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg); const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0; const ptr = malloc(buf.length, 1) >>> 0;
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); getUint8Memory0()
.subarray(ptr, ptr + buf.length)
.set(buf);
WASM_VECTOR_LEN = buf.length; WASM_VECTOR_LEN = buf.length;
return ptr; return ptr;
} }
@ -108,7 +112,7 @@ function passStringToWasm0(arg, malloc, realloc) {
for (; offset < len; offset++) { for (; offset < len; offset++) {
const code = arg.charCodeAt(offset); const code = arg.charCodeAt(offset);
if (code > 0x7F) break; if (code > 0x7f) break;
mem[ptr + offset] = code; mem[ptr + offset] = code;
} }
@ -116,7 +120,7 @@ function passStringToWasm0(arg, malloc, realloc) {
if (offset !== 0) { if (offset !== 0) {
arg = arg.slice(offset); arg = arg.slice(offset);
} }
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0;
const view = getUint8Memory0().subarray(ptr + offset, ptr + len); const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view); const ret = encodeString(arg, view);
@ -130,39 +134,39 @@ function passStringToWasm0(arg, malloc, realloc) {
function debugString(val) { function debugString(val) {
// primitive types // primitive types
const type = typeof val; const type = typeof val;
if (type == 'number' || type == 'boolean' || val == null) { if (type == "number" || type == "boolean" || val == null) {
return `${val}`; return `${val}`;
} }
if (type == 'string') { if (type == "string") {
return `"${val}"`; return `"${val}"`;
} }
if (type == 'symbol') { if (type == "symbol") {
const description = val.description; const description = val.description;
if (description == null) { if (description == null) {
return 'Symbol'; return "Symbol";
} else { } else {
return `Symbol(${description})`; return `Symbol(${description})`;
} }
} }
if (type == 'function') { if (type == "function") {
const name = val.name; const name = val.name;
if (typeof name == 'string' && name.length > 0) { if (typeof name == "string" && name.length > 0) {
return `Function(${name})`; return `Function(${name})`;
} else { } else {
return 'Function'; return "Function";
} }
} }
// objects // objects
if (Array.isArray(val)) { if (Array.isArray(val)) {
const length = val.length; const length = val.length;
let debug = '['; let debug = "[";
if (length > 0) { if (length > 0) {
debug += debugString(val[0]); debug += debugString(val[0]);
} }
for (let i = 1; i < length; i++) { for (let i = 1; i < length; i++) {
debug += ', ' + debugString(val[i]); debug += ", " + debugString(val[i]);
} }
debug += ']'; debug += "]";
return debug; return debug;
} }
// Test for built-in // Test for built-in
@ -174,14 +178,14 @@ function debugString(val) {
// Failed to match the standard '[object ClassName]' // Failed to match the standard '[object ClassName]'
return toString.call(val); return toString.call(val);
} }
if (className == 'Object') { if (className == "Object") {
// we're a user defined class or Object // we're a user defined class or Object
// JSON.stringify avoids problems with cycles, and is generally much // JSON.stringify avoids problems with cycles, and is generally much
// easier than looping through ownProperties of `val`. // easier than looping through ownProperties of `val`.
try { try {
return 'Object(' + JSON.stringify(val) + ')'; return "Object(" + JSON.stringify(val) + ")";
} catch (_) { } catch (_) {
return 'Object'; return "Object";
} }
} }
// errors // errors
@ -267,7 +271,6 @@ function handleError(f, args) {
* [`Message::hash`]: crate::message::Message::hash * [`Message::hash`]: crate::message::Message::hash
*/ */
class Hash { class Hash {
static __wrap(ptr) { static __wrap(ptr) {
ptr = ptr >>> 0; ptr = ptr >>> 0;
const obj = Object.create(Hash.prototype); const obj = Object.create(Hash.prototype);
@ -419,7 +422,6 @@ module.exports.Hash = Hash;
* program must still validate during execution that the account is a signer. * program must still validate during execution that the account is a signer.
*/ */
class Instruction { class Instruction {
static __wrap(ptr) { static __wrap(ptr) {
ptr = ptr >>> 0; ptr = ptr >>> 0;
const obj = Object.create(Instruction.prototype); const obj = Object.create(Instruction.prototype);
@ -444,7 +446,6 @@ module.exports.Instruction = Instruction;
/** /**
*/ */
class Instructions { class Instructions {
static __wrap(ptr) { static __wrap(ptr) {
ptr = ptr >>> 0; ptr = ptr >>> 0;
const obj = Object.create(Instructions.prototype); const obj = Object.create(Instructions.prototype);
@ -497,7 +498,6 @@ module.exports.Instructions = Instructions;
* redundantly specifying the fee-payer is not strictly required. * redundantly specifying the fee-payer is not strictly required.
*/ */
class Message { class Message {
__destroy_into_raw() { __destroy_into_raw() {
const ptr = this.__wbg_ptr; const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0; this.__wbg_ptr = 0;
@ -545,7 +545,6 @@ module.exports.Message = Message;
* [`Keypair`]: https://docs.rs/solana-sdk/latest/solana_sdk/signer/keypair/struct.Keypair.html * [`Keypair`]: https://docs.rs/solana-sdk/latest/solana_sdk/signer/keypair/struct.Keypair.html
*/ */
class Pubkey { class Pubkey {
static __wrap(ptr) { static __wrap(ptr) {
ptr = ptr >>> 0; ptr = ptr >>> 0;
const obj = Object.create(Pubkey.prototype); const obj = Object.create(Pubkey.prototype);
@ -722,7 +721,6 @@ class Pubkey {
module.exports.Pubkey = Pubkey; module.exports.Pubkey = Pubkey;
class SystemInstruction { class SystemInstruction {
__destroy_into_raw() { __destroy_into_raw() {
const ptr = this.__wbg_ptr; const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0; this.__wbg_ptr = 0;
@ -746,7 +744,13 @@ class SystemInstruction {
_assertClass(from_pubkey, Pubkey); _assertClass(from_pubkey, Pubkey);
_assertClass(to_pubkey, Pubkey); _assertClass(to_pubkey, Pubkey);
_assertClass(owner, Pubkey); _assertClass(owner, Pubkey);
const ret = wasm.systeminstruction_createAccount(from_pubkey.__wbg_ptr, to_pubkey.__wbg_ptr, lamports, space, owner.__wbg_ptr); const ret = wasm.systeminstruction_createAccount(
from_pubkey.__wbg_ptr,
to_pubkey.__wbg_ptr,
lamports,
space,
owner.__wbg_ptr,
);
return Instruction.__wrap(ret); return Instruction.__wrap(ret);
} }
/** /**
@ -766,7 +770,16 @@ class SystemInstruction {
const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN; const len0 = WASM_VECTOR_LEN;
_assertClass(owner, Pubkey); _assertClass(owner, Pubkey);
const ret = wasm.systeminstruction_createAccountWithSeed(from_pubkey.__wbg_ptr, to_pubkey.__wbg_ptr, base.__wbg_ptr, ptr0, len0, lamports, space, owner.__wbg_ptr); const ret = wasm.systeminstruction_createAccountWithSeed(
from_pubkey.__wbg_ptr,
to_pubkey.__wbg_ptr,
base.__wbg_ptr,
ptr0,
len0,
lamports,
space,
owner.__wbg_ptr,
);
return Instruction.__wrap(ret); return Instruction.__wrap(ret);
} }
/** /**
@ -824,7 +837,15 @@ class SystemInstruction {
const len0 = WASM_VECTOR_LEN; const len0 = WASM_VECTOR_LEN;
_assertClass(from_owner, Pubkey); _assertClass(from_owner, Pubkey);
_assertClass(to_pubkey, Pubkey); _assertClass(to_pubkey, Pubkey);
const ret = wasm.systeminstruction_transferWithSeed(from_pubkey.__wbg_ptr, from_base.__wbg_ptr, ptr0, len0, from_owner.__wbg_ptr, to_pubkey.__wbg_ptr, lamports); const ret = wasm.systeminstruction_transferWithSeed(
from_pubkey.__wbg_ptr,
from_base.__wbg_ptr,
ptr0,
len0,
from_owner.__wbg_ptr,
to_pubkey.__wbg_ptr,
lamports,
);
return Instruction.__wrap(ret); return Instruction.__wrap(ret);
} }
/** /**
@ -851,7 +872,14 @@ class SystemInstruction {
const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN; const len0 = WASM_VECTOR_LEN;
_assertClass(owner, Pubkey); _assertClass(owner, Pubkey);
const ret = wasm.systeminstruction_allocateWithSeed(address.__wbg_ptr, base.__wbg_ptr, ptr0, len0, space, owner.__wbg_ptr); const ret = wasm.systeminstruction_allocateWithSeed(
address.__wbg_ptr,
base.__wbg_ptr,
ptr0,
len0,
space,
owner.__wbg_ptr,
);
return Instruction.__wrap(ret); return Instruction.__wrap(ret);
} }
/** /**
@ -865,7 +893,12 @@ class SystemInstruction {
_assertClass(from_pubkey, Pubkey); _assertClass(from_pubkey, Pubkey);
_assertClass(nonce_pubkey, Pubkey); _assertClass(nonce_pubkey, Pubkey);
_assertClass(authority, Pubkey); _assertClass(authority, Pubkey);
const ret = wasm.systeminstruction_createNonceAccount(from_pubkey.__wbg_ptr, nonce_pubkey.__wbg_ptr, authority.__wbg_ptr, lamports); const ret = wasm.systeminstruction_createNonceAccount(
from_pubkey.__wbg_ptr,
nonce_pubkey.__wbg_ptr,
authority.__wbg_ptr,
lamports,
);
return takeObject(ret); return takeObject(ret);
} }
/** /**
@ -890,7 +923,12 @@ class SystemInstruction {
_assertClass(nonce_pubkey, Pubkey); _assertClass(nonce_pubkey, Pubkey);
_assertClass(authorized_pubkey, Pubkey); _assertClass(authorized_pubkey, Pubkey);
_assertClass(to_pubkey, Pubkey); _assertClass(to_pubkey, Pubkey);
const ret = wasm.systeminstruction_withdrawNonceAccount(nonce_pubkey.__wbg_ptr, authorized_pubkey.__wbg_ptr, to_pubkey.__wbg_ptr, lamports); const ret = wasm.systeminstruction_withdrawNonceAccount(
nonce_pubkey.__wbg_ptr,
authorized_pubkey.__wbg_ptr,
to_pubkey.__wbg_ptr,
lamports,
);
return Instruction.__wrap(ret); return Instruction.__wrap(ret);
} }
/** /**
@ -903,7 +941,11 @@ class SystemInstruction {
_assertClass(nonce_pubkey, Pubkey); _assertClass(nonce_pubkey, Pubkey);
_assertClass(authorized_pubkey, Pubkey); _assertClass(authorized_pubkey, Pubkey);
_assertClass(new_authority, Pubkey); _assertClass(new_authority, Pubkey);
const ret = wasm.systeminstruction_authorizeNonceAccount(nonce_pubkey.__wbg_ptr, authorized_pubkey.__wbg_ptr, new_authority.__wbg_ptr); const ret = wasm.systeminstruction_authorizeNonceAccount(
nonce_pubkey.__wbg_ptr,
authorized_pubkey.__wbg_ptr,
new_authority.__wbg_ptr,
);
return Instruction.__wrap(ret); return Instruction.__wrap(ret);
} }
} }
@ -944,7 +986,7 @@ module.exports.__wbindgen_object_clone_ref = function(arg0) {
module.exports.__wbindgen_is_object = function (arg0) { module.exports.__wbindgen_is_object = function (arg0) {
const val = getObject(arg0); const val = getObject(arg0);
const ret = typeof(val) === 'object' && val !== null; const ret = typeof val === "object" && val !== null;
return ret; return ret;
}; };
@ -955,20 +997,20 @@ module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
module.exports.__wbindgen_boolean_get = function (arg0) { module.exports.__wbindgen_boolean_get = function (arg0) {
const v = getObject(arg0); const v = getObject(arg0);
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; const ret = typeof v === "boolean" ? (v ? 1 : 0) : 2;
return ret; return ret;
}; };
module.exports.__wbindgen_number_get = function (arg0, arg1) { module.exports.__wbindgen_number_get = function (arg0, arg1) {
const obj = getObject(arg1); const obj = getObject(arg1);
const ret = typeof(obj) === 'number' ? obj : undefined; const ret = typeof obj === "number" ? obj : undefined;
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
}; };
module.exports.__wbindgen_string_get = function (arg0, arg1) { module.exports.__wbindgen_string_get = function (arg0, arg1) {
const obj = getObject(arg1); const obj = getObject(arg1);
const ret = typeof(obj) === 'string' ? obj : undefined; const ret = typeof obj === "string" ? obj : undefined;
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN; var len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1; getInt32Memory0()[arg0 / 4 + 1] = len1;
@ -1040,7 +1082,7 @@ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
}; };
module.exports.__wbindgen_is_string = function (arg0) { module.exports.__wbindgen_is_string = function (arg0) {
const ret = typeof(getObject(arg0)) === 'string'; const ret = typeof getObject(arg0) === "string";
return ret; return ret;
}; };
@ -1060,7 +1102,7 @@ module.exports.__wbg_new_898a68150f225f2e = function() {
}; };
module.exports.__wbindgen_is_function = function (arg0) { module.exports.__wbindgen_is_function = function (arg0) {
const ret = typeof(getObject(arg0)) === 'function'; const ret = typeof getObject(arg0) === "function";
return ret; return ret;
}; };
@ -1074,10 +1116,12 @@ module.exports.__wbg_next_526fc47e980da008 = function(arg0) {
return addHeapObject(ret); return addHeapObject(ret);
}; };
module.exports.__wbg_next_ddb3312ca1c4e32a = function() { return handleError(function (arg0) { module.exports.__wbg_next_ddb3312ca1c4e32a = function () {
return handleError(function (arg0) {
const ret = getObject(arg0).next(); const ret = getObject(arg0).next();
return addHeapObject(ret); return addHeapObject(ret);
}, arguments) }; }, arguments);
};
module.exports.__wbg_done_5c1f01fb660d73b5 = function (arg0) { module.exports.__wbg_done_5c1f01fb660d73b5 = function (arg0) {
const ret = getObject(arg0).done; const ret = getObject(arg0).done;
@ -1094,15 +1138,19 @@ module.exports.__wbg_iterator_97f0c81209c6c35a = function() {
return addHeapObject(ret); return addHeapObject(ret);
}; };
module.exports.__wbg_get_97b561fb56f034b5 = function() { return handleError(function (arg0, arg1) { module.exports.__wbg_get_97b561fb56f034b5 = function () {
return handleError(function (arg0, arg1) {
const ret = Reflect.get(getObject(arg0), getObject(arg1)); const ret = Reflect.get(getObject(arg0), getObject(arg1));
return addHeapObject(ret); return addHeapObject(ret);
}, arguments) }; }, arguments);
};
module.exports.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) { module.exports.__wbg_call_cb65541d95d71282 = function () {
return handleError(function (arg0, arg1) {
const ret = getObject(arg0).call(getObject(arg1)); const ret = getObject(arg0).call(getObject(arg1));
return addHeapObject(ret); return addHeapObject(ret);
}, arguments) }; }, arguments);
};
module.exports.__wbg_new_b51585de1b234aff = function () { module.exports.__wbg_new_b51585de1b234aff = function () {
const ret = new Object(); const ret = new Object();
@ -1201,11 +1249,10 @@ module.exports.__wbindgen_memory = function() {
return addHeapObject(ret); return addHeapObject(ret);
}; };
const path = require('path').join(__dirname, 'bincode_js_bg.wasm'); const path = require("path").join(__dirname, "bincode_js_bg.wasm");
const bytes = require('fs').readFileSync(path); const bytes = require("fs").readFileSync(path);
const wasmModule = new WebAssembly.Module(bytes); const wasmModule = new WebAssembly.Module(bytes);
const wasmInstance = new WebAssembly.Instance(wasmModule, imports); const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
wasm = wasmInstance.exports; wasm = wasmInstance.exports;
module.exports.__wasm = wasm; module.exports.__wasm = wasm;

View File

@ -8,13 +8,37 @@ export function __wbg_get_message_recent_blockhash(a: number): number;
export function __wbg_set_message_recent_blockhash(a: number, b: number): void; export function __wbg_set_message_recent_blockhash(a: number, b: number): void;
export function solana_program_init(): void; export function solana_program_init(): void;
export function systeminstruction_createAccount(a: number, b: number, c: number, d: number, e: number): number; export function systeminstruction_createAccount(a: number, b: number, c: number, d: number, e: number): number;
export function systeminstruction_createAccountWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; export function systeminstruction_createAccountWithSeed(
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
g: number,
h: number,
): number;
export function systeminstruction_assign(a: number, b: number): number; export function systeminstruction_assign(a: number, b: number): number;
export function systeminstruction_assignWithSeed(a: number, b: number, c: number, d: number, e: number): number; export function systeminstruction_assignWithSeed(a: number, b: number, c: number, d: number, e: number): number;
export function systeminstruction_transfer(a: number, b: number, c: number): number; export function systeminstruction_transfer(a: number, b: number, c: number): number;
export function systeminstruction_transferWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; export function systeminstruction_transferWithSeed(
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
g: number,
): number;
export function systeminstruction_allocate(a: number, b: number): number; export function systeminstruction_allocate(a: number, b: number): number;
export function systeminstruction_allocateWithSeed(a: number, b: number, c: number, d: number, e: number, f: number): number; export function systeminstruction_allocateWithSeed(
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
): number;
export function systeminstruction_createNonceAccount(a: number, b: number, c: number, d: number): number; export function systeminstruction_createNonceAccount(a: number, b: number, c: number, d: number): number;
export function systeminstruction_advanceNonceAccount(a: number, b: number): number; export function systeminstruction_advanceNonceAccount(a: number, b: number): number;
export function systeminstruction_withdrawNonceAccount(a: number, b: number, c: number, d: number): number; export function systeminstruction_withdrawNonceAccount(a: number, b: number, c: number, d: number): number;

View File

@ -1,5 +1,5 @@
import path from 'path' import path from "path";
import Dotenv from 'dotenv-webpack' import Dotenv from "dotenv-webpack";
import { fileURLToPath } from "url"; import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);

View File

@ -11,12 +11,12 @@ export default {
filename: "main.js", filename: "main.js",
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, "dist"),
libraryTarget: "commonjs2", libraryTarget: "commonjs2",
clean: true clean: true,
}, },
target: "node", target: "node",
resolve: { resolve: {
extensions: [".ts", ".js"] extensions: [".ts", ".js"],
}, },
module: { module: {
@ -26,16 +26,14 @@ export default {
use: { use: {
loader: "ts-loader", loader: "ts-loader",
options: { options: {
transpileOnly: true transpileOnly: true,
}
}, },
exclude: /node_modules/
}
]
}, },
exclude: /node_modules/,
plugins: [ },
], ],
},
plugins: [],
devtool: "source-map", devtool: "source-map",
}; };