Skip to content

Commit

Permalink
compatible with [email protected] built from source
Browse files Browse the repository at this point in the history
  • Loading branch information
phn210 committed Mar 24, 2024
1 parent 712757c commit cb456d8
Show file tree
Hide file tree
Showing 8 changed files with 9,108 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# NodeJS
node_modules
build
pkg
coverage

# Editor
Expand Down
9,086 changes: 9,086 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
"typescript": "^4.7.2"
},
"dependencies": {
"o1js": "0.17.0"
"o1js": "./pkg/o1js-0.17.0.tgz"
}
}
2 changes: 1 addition & 1 deletion src/Bit255.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Bit255', () => {
reducer = Reducer({ actionType: Bit255 });

@method
xor(a: Bit255, b: Bit255, c: Bit255) {
async xor(a: Bit255, b: Bit255, c: Bit255) {
let res = Bit255.xor(a, b);
res.assertEquals(c);
res.assertEquals(
Expand Down
2 changes: 1 addition & 1 deletion src/DynamicArray.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('DynamicArray', () => {
reducer = Reducer({ actionType: Action });

@method
test(action: Action) {
async test(action: Action) {
this.reducer.dispatch(action);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/StaticArray.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('StaticArray', () => {
reducer = Reducer({ actionType: Action });

@method
test(action: Action) {
async test(action: Action) {
this.reducer.dispatch(action);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async function prove<T>(
async function proveAndSendTx(
contractName: string,
methodName: string,
functionCall: () => void,
functionCall: () => Promise<void>,
feePayer: FeePayer,
logger?: Logger,
profiler?: Profiler,
Expand Down Expand Up @@ -180,7 +180,7 @@ async function deployZkApps(
memo: feePayer.memo,
nonce: feePayer.nonce,
},
() => {
async () => {
AccountUpdate.fundNewAccount(
feePayer.sender.publicKey,
deployData.length
Expand Down
15 changes: 15 additions & 0 deletions src/utils/zkApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export {
updateActionState,
updateActionStateWithHash,
packNumberArray,
unpackNumberArray,
buildAssertMessage,
requireSignature,
requireCaller,
Expand All @@ -22,6 +23,20 @@ function packNumberArray(numbers: number[], maxSize: number): Field {
return Field.fromBits(numbers.map((e) => Field(e).toBits(maxSize)).flat());
}

function unpackNumberArray(packed: Field, maxSize: number): number[] {
let numbers: number[] = [];
for (let i = 0; i < 255 / maxSize; i++) {
numbers.push(
Number(
Field.fromBits(
packed.toBits().slice(i * maxSize, (i + 1) * maxSize)
)
)
);
}
return numbers;
}

function buildAssertMessage(
circuit: string,
method: string,
Expand Down

0 comments on commit cb456d8

Please sign in to comment.