-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: make imports explicit * feat: add optional arguments to prankFulfill, split test file * chore: fix CI * chore: fix CI * fix: incorrect feeData pass-through * fix: resolve tsc issue * feat: add comments * chore: add natspec * feat: simplifying test imports * feat: use cli binary * fix: minify executable * fix: build cli during workflow * fix: linux build sed command * feat: add mac testing * fix: run mac test on macos-14 * feat: use right binary based on platform * fix: macos tests * fix: remove diff checking for now * feat: save build files * feat: add linux build * feat: use bun instead of executable * fix: bun installation * fix: don't install bun in ci * try fixing ci * try to fix install sleep * run tests twice * try to get tests working * feat: use node to run cli * fix: ci * chore: remove unused fn * chore: remove bun from .gitignore --------- Co-authored-by: roshan <[email protected]>
- Loading branch information
Showing
16 changed files
with
1,863 additions
and
700 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ docs/ | |
node_modules/ | ||
.axiom | ||
|
||
dist | ||
dist |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
"use strict"; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __commonJS = (cb, mod) => function __require() { | ||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
}; | ||
|
||
// dist/utils.js | ||
var require_utils = __commonJS({ | ||
"dist/utils.js"(exports2) { | ||
"use strict"; | ||
Object.defineProperty(exports2, "__esModule", { value: true }); | ||
exports2.getSolidityType = void 0; | ||
var getSolidityType = (type) => { | ||
switch (type) { | ||
case "CircuitValue": | ||
return "uint256"; | ||
case "CircuitValue256": | ||
return "uint256"; | ||
case "CircuitValue[]": | ||
return "uint256[]"; | ||
case "CircuitValue256[]": | ||
return "uint256[]"; | ||
default: | ||
throw new Error(`Unknown type ${type}`); | ||
} | ||
}; | ||
exports2.getSolidityType = getSolidityType; | ||
} | ||
}); | ||
|
||
// dist/compile.js | ||
var require_compile = __commonJS({ | ||
"dist/compile.js"(exports2) { | ||
"use strict"; | ||
Object.defineProperty(exports2, "__esModule", { value: true }); | ||
exports2.compile = void 0; | ||
var js_12 = require("@axiom-crypto/circuit/js"); | ||
var utils_12 = require("@axiom-crypto/circuit/cliHandler/utils"); | ||
var viem_12 = require("viem"); | ||
var utils_22 = require_utils(); | ||
var compile = async (circuitPath, inputs2, providerUri2) => { | ||
let circuitFunction = "circuit"; | ||
const f = await (0, utils_12.getFunctionFromTs)(circuitPath, circuitFunction); | ||
const provider2 = (0, utils_12.getProvider)(providerUri2); | ||
const circuit2 = new js_12.AxiomBaseCircuit({ | ||
f: f.circuit, | ||
mock: true, | ||
provider: provider2, | ||
shouldTime: false, | ||
inputSchema: f.inputSchema | ||
}); | ||
let abi2 = []; | ||
let inputSchemaJson2 = JSON.parse(f.inputSchema); | ||
let keys2 = Object.keys(inputSchemaJson2); | ||
for (let i = 0; i < keys2.length; i++) { | ||
abi2.push({ "name": keys2[i], "type": (0, utils_22.getSolidityType)(inputSchemaJson2[keys2[i]]) }); | ||
} | ||
const rawInputs2 = (0, viem_12.decodeAbiParameters)(abi2, inputs2); | ||
const circuitInputs2 = {}; | ||
for (let i = 0; i < keys2.length; i++) { | ||
circuitInputs2[keys2[i]] = rawInputs2[i].toString(); | ||
} | ||
try { | ||
const res = await circuit2.mockCompile(circuitInputs2); | ||
const circuitFn = `const ${f.importName} = AXIOM_CLIENT_IMPORT | ||
${f.circuit.toString()}`; | ||
const encoder = new TextEncoder(); | ||
const circuitBuild = encoder.encode(circuitFn); | ||
const build = { | ||
...res, | ||
circuit: Buffer.from(circuitBuild).toString("base64") | ||
}; | ||
console.log(JSON.stringify(build)); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}; | ||
exports2.compile = compile; | ||
} | ||
}); | ||
|
||
// dist/prove.js | ||
var require_prove = __commonJS({ | ||
"dist/prove.js"(exports, module) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.prove = void 0; | ||
var js_1 = require("@axiom-crypto/circuit/js"); | ||
var utils_1 = require("@axiom-crypto/circuit/cliHandler/utils"); | ||
var utils_2 = require_utils(); | ||
var viem_1 = require("viem"); | ||
var core_1 = require("@axiom-crypto/core"); | ||
var client_1 = require("@axiom-crypto/client"); | ||
var utils_3 = require("@axiom-crypto/client/axiom/utils"); | ||
var prove = async (compiledJson, inputs, providerUri, sourceChainId, callbackTarget, callbackExtraData, refundAddress, maxFeePerGas, callbackGasLimit, caller) => { | ||
const decoder = new TextDecoder(); | ||
const provider = (0, utils_1.getProvider)(providerUri); | ||
let compiled = JSON.parse(compiledJson); | ||
const decodedArray = Buffer.from(compiled.circuit, "base64"); | ||
const raw = decoder.decode(decodedArray); | ||
const AXIOM_CLIENT_IMPORT = require("@axiom-crypto/client"); | ||
const circuit = new js_1.AxiomBaseCircuit({ | ||
f: eval(raw), | ||
mock: true, | ||
// chainId: options.sourceChainId, | ||
provider, | ||
shouldTime: false, | ||
inputSchema: compiled.inputSchema | ||
}); | ||
let abi = []; | ||
let decodedInputSchema = Buffer.from(compiled.inputSchema, "base64"); | ||
let inputSchemaJson = JSON.parse(decoder.decode(decodedInputSchema)); | ||
let keys = Object.keys(inputSchemaJson); | ||
for (let i = 0; i < keys.length; i++) { | ||
abi.push({ "name": keys[i], "type": (0, utils_2.getSolidityType)(inputSchemaJson[keys[i]]) }); | ||
} | ||
const rawInputs = (0, viem_1.decodeAbiParameters)(abi, inputs); | ||
const circuitInputs = {}; | ||
for (let i = 0; i < keys.length; i++) { | ||
circuitInputs[keys[i]] = rawInputs[i].toString(); | ||
} | ||
const axiom = new core_1.AxiomSdkCore({ | ||
providerUri: provider, | ||
chainId: sourceChainId, | ||
version: "v2" | ||
}); | ||
try { | ||
let computeQuery; | ||
circuit.loadSavedMock(compiled); | ||
computeQuery = await circuit.mockProve(circuitInputs); | ||
const computeResults = circuit.getComputeResults(); | ||
const dataQuery = circuit.getDataQuery(); | ||
const res = { | ||
sourceChainId: circuit.getChainId(), | ||
computeQuery, | ||
computeResults, | ||
dataQuery | ||
}; | ||
let build = await (0, client_1.buildSendQuery)({ | ||
axiom, | ||
dataQuery: res.dataQuery, | ||
computeQuery: res.computeQuery, | ||
callback: { | ||
target: callbackTarget, | ||
extraData: callbackExtraData | ||
}, | ||
options: { | ||
refundee: refundAddress, | ||
maxFeePerGas, | ||
callbackGasLimit: Number(callbackGasLimit) | ||
}, | ||
caller | ||
}); | ||
build.value = build.value.toString(); | ||
const query = { | ||
value: build.value, | ||
mock: build.mock, | ||
queryId: build.queryId, | ||
args: (0, utils_3.argsArrToObj)(build.args), | ||
calldata: build.calldata, | ||
computeResults | ||
}; | ||
console.log(JSON.stringify(query)); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}; | ||
exports.prove = prove; | ||
} | ||
}); | ||
|
||
// dist/axiom-std-cli.js | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var commander_1 = require("commander"); | ||
var compile_1 = require_compile(); | ||
var prove_1 = require_prove(); | ||
var program = new commander_1.Command("axiom-std"); | ||
program.name("axiom-std").usage("axiom-std CLI"); | ||
program.command("readCircuit").description("Read and compile a circuit").argument("<circuitPath>", "path to the typescript circuit file").argument("<inputs>", "inputs to the circuit").argument("<providerUri>", "provider to use").action(compile_1.compile); | ||
program.command("prove").description("Prove a circuit").argument("<compiledJson>", "compiled json string").argument("<inputs>", "inputs to the circuit").argument("<providerUri>", "provider to use").argument("<sourceChainId>", "source chain id").argument("<callbackTarget>", "callback target").argument("<callbackExtraData>", "callback extra data").argument("<refundAddress>", "refund address").argument("<maxFeePerGas>", "max fee per gas").argument("<callbackGasLimit>", "callback gas limit").argument("<caller>", "caller").action(prove_1.prove); | ||
program.parseAsync(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.