@puzzlehq/aleo-wasm-web 0.6.4 → 0.6.6
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/aleo_wasm.d.ts +144 -144
- package/aleo_wasm.js +195 -193
- package/aleo_wasm_bg.wasm +0 -0
- package/package.json +4 -3
- package/snippets/aleo-wasm-91297d530eb26bda/inline0.js +27 -0
package/aleo_wasm.d.ts
CHANGED
|
@@ -10,10 +10,6 @@ export function init_panic_hook(): void;
|
|
|
10
10
|
*/
|
|
11
11
|
export function initThreadPool(url: URL, num_threads: number): Promise<void>;
|
|
12
12
|
/**
|
|
13
|
-
* @param {number} receiver
|
|
14
|
-
*/
|
|
15
|
-
export function runRayonThread(receiver: number): void;
|
|
16
|
-
/**
|
|
17
13
|
* Verify an execution with a single function and a single transition. Executions with multiple
|
|
18
14
|
* transitions or functions will fail to verify. Also, this does not verify that the state root of
|
|
19
15
|
* the execution is included in the Aleo Network ledger.
|
|
@@ -31,6 +27,10 @@ export function runRayonThread(receiver: number): void;
|
|
|
31
27
|
*/
|
|
32
28
|
export function verifyFunctionExecution(execution: Execution, verifying_key: VerifyingKey, program: Program, function_id: string): boolean;
|
|
33
29
|
/**
|
|
30
|
+
* @param {number} receiver
|
|
31
|
+
*/
|
|
32
|
+
export function runRayonThread(receiver: number): void;
|
|
33
|
+
/**
|
|
34
34
|
* Public address of an Aleo account
|
|
35
35
|
*/
|
|
36
36
|
export class Address {
|
|
@@ -579,6 +579,34 @@ export class Program {
|
|
|
579
579
|
export class ProgramManager {
|
|
580
580
|
free(): void;
|
|
581
581
|
/**
|
|
582
|
+
* Join two records together to create a new record with an amount of credits equal to the sum
|
|
583
|
+
* of the credits of the two original records
|
|
584
|
+
*
|
|
585
|
+
* @param private_key The private key of the sender
|
|
586
|
+
* @param record_1 The first record to combine
|
|
587
|
+
* @param record_2 The second record to combine
|
|
588
|
+
* @param fee_credits The amount of credits to pay as a fee
|
|
589
|
+
* @param fee_record The record to spend the fee from
|
|
590
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
591
|
+
* @param join_proving_key (optional) Provide a proving key to use for the join function
|
|
592
|
+
* @param join_verifying_key (optional) Provide a verifying key to use for the join function
|
|
593
|
+
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
594
|
+
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
595
|
+
* @returns {Transaction | Error} Transaction object
|
|
596
|
+
* @param {PrivateKey} private_key
|
|
597
|
+
* @param {RecordPlaintext} record_1
|
|
598
|
+
* @param {RecordPlaintext} record_2
|
|
599
|
+
* @param {number} fee_credits
|
|
600
|
+
* @param {RecordPlaintext | undefined} fee_record
|
|
601
|
+
* @param {string} url
|
|
602
|
+
* @param {ProvingKey | undefined} join_proving_key
|
|
603
|
+
* @param {VerifyingKey | undefined} join_verifying_key
|
|
604
|
+
* @param {ProvingKey | undefined} fee_proving_key
|
|
605
|
+
* @param {VerifyingKey | undefined} fee_verifying_key
|
|
606
|
+
* @returns {Promise<Transaction>}
|
|
607
|
+
*/
|
|
608
|
+
static buildJoinTransaction(private_key: PrivateKey, record_1: RecordPlaintext, record_2: RecordPlaintext, fee_credits: number, fee_record: RecordPlaintext | undefined, url: string, join_proving_key?: ProvingKey, join_verifying_key?: VerifyingKey, fee_proving_key?: ProvingKey, fee_verifying_key?: VerifyingKey): Promise<Transaction>;
|
|
609
|
+
/**
|
|
582
610
|
* Split an Aleo credits record into two separate records. This function does not require a fee.
|
|
583
611
|
*
|
|
584
612
|
* @param private_key The private key of the sender
|
|
@@ -599,13 +627,70 @@ export class ProgramManager {
|
|
|
599
627
|
*/
|
|
600
628
|
static buildSplitTransaction(private_key: PrivateKey, split_amount: number, amount_record: RecordPlaintext, url: string, split_proving_key?: ProvingKey, split_verifying_key?: VerifyingKey): Promise<Transaction>;
|
|
601
629
|
/**
|
|
630
|
+
* Deploy an Aleo program
|
|
631
|
+
*
|
|
632
|
+
* @param private_key The private key of the sender
|
|
633
|
+
* @param program The source code of the program being deployed
|
|
634
|
+
* @param imports A javascript object holding the source code of any imported programs in the
|
|
635
|
+
* form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
|
|
636
|
+
* Note that all imported programs must be deployed on chain before the main program in order
|
|
637
|
+
* for the deployment to succeed
|
|
638
|
+
* @param fee_credits The amount of credits to pay as a fee
|
|
639
|
+
* @param fee_record The record to spend the fee from
|
|
640
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
641
|
+
* @param imports (optional) Provide a list of imports to use for the program deployment in the
|
|
642
|
+
* form of a javascript object where the keys are a string of the program name and the values
|
|
643
|
+
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
644
|
+
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
645
|
+
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
646
|
+
* @returns {Transaction | Error}
|
|
647
|
+
* @param {PrivateKey} private_key
|
|
648
|
+
* @param {string} program
|
|
649
|
+
* @param {number} fee_credits
|
|
650
|
+
* @param {RecordPlaintext | undefined} fee_record
|
|
651
|
+
* @param {string} url
|
|
652
|
+
* @param {object | undefined} imports
|
|
653
|
+
* @param {ProvingKey | undefined} fee_proving_key
|
|
654
|
+
* @param {VerifyingKey | undefined} fee_verifying_key
|
|
655
|
+
* @returns {Promise<Transaction>}
|
|
656
|
+
*/
|
|
657
|
+
static buildDeploymentTransaction(private_key: PrivateKey, program: string, fee_credits: number, fee_record: RecordPlaintext | undefined, url: string, imports?: object, fee_proving_key?: ProvingKey, fee_verifying_key?: VerifyingKey): Promise<Transaction>;
|
|
658
|
+
/**
|
|
659
|
+
* Estimate the fee for a program deployment
|
|
660
|
+
*
|
|
661
|
+
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
662
|
+
*
|
|
663
|
+
* @param program The source code of the program being deployed
|
|
664
|
+
* @param imports (optional) Provide a list of imports to use for the deployment fee estimation
|
|
665
|
+
* in the form of a javascript object where the keys are a string of the program name and the values
|
|
666
|
+
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
667
|
+
* @returns {u64 | Error}
|
|
668
|
+
* @param {string} program
|
|
669
|
+
* @param {object | undefined} imports
|
|
670
|
+
* @returns {Promise<bigint>}
|
|
671
|
+
*/
|
|
672
|
+
static estimateDeploymentFee(program: string, imports?: object): Promise<bigint>;
|
|
673
|
+
/**
|
|
674
|
+
* Estimate the component of the deployment cost which comes from the fee for the program name.
|
|
675
|
+
* Note that this cost does not represent the entire cost of deployment. It is additional to
|
|
676
|
+
* the cost of the size (in bytes) of the deployment.
|
|
677
|
+
*
|
|
678
|
+
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
679
|
+
*
|
|
680
|
+
* @param name The name of the program to be deployed
|
|
681
|
+
* @returns {u64 | Error}
|
|
682
|
+
* @param {string} name
|
|
683
|
+
* @returns {bigint}
|
|
684
|
+
*/
|
|
685
|
+
static estimateProgramNameCost(name: string): bigint;
|
|
686
|
+
/**
|
|
602
687
|
* @param {string} program_id
|
|
603
688
|
* @param {string} function_id
|
|
604
689
|
* @param {Array<any>} inputs_str
|
|
605
|
-
* @param {
|
|
690
|
+
* @param {string} private_key
|
|
606
691
|
* @returns {Promise<string>}
|
|
607
692
|
*/
|
|
608
|
-
authExecute(program_id: string, function_id: string, inputs_str: Array<any>, private_key:
|
|
693
|
+
static authExecute(program_id: string, function_id: string, inputs_str: Array<any>, private_key: string): Promise<string>;
|
|
609
694
|
/**
|
|
610
695
|
* Execute an arbitrary function locally
|
|
611
696
|
*
|
|
@@ -719,63 +804,6 @@ export class ProgramManager {
|
|
|
719
804
|
*/
|
|
720
805
|
static estimateFinalizeFee(program: string, _function: string): bigint;
|
|
721
806
|
/**
|
|
722
|
-
* Deploy an Aleo program
|
|
723
|
-
*
|
|
724
|
-
* @param private_key The private key of the sender
|
|
725
|
-
* @param program The source code of the program being deployed
|
|
726
|
-
* @param imports A javascript object holding the source code of any imported programs in the
|
|
727
|
-
* form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
|
|
728
|
-
* Note that all imported programs must be deployed on chain before the main program in order
|
|
729
|
-
* for the deployment to succeed
|
|
730
|
-
* @param fee_credits The amount of credits to pay as a fee
|
|
731
|
-
* @param fee_record The record to spend the fee from
|
|
732
|
-
* @param url The url of the Aleo network node to send the transaction to
|
|
733
|
-
* @param imports (optional) Provide a list of imports to use for the program deployment in the
|
|
734
|
-
* form of a javascript object where the keys are a string of the program name and the values
|
|
735
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
736
|
-
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
737
|
-
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
738
|
-
* @returns {Transaction | Error}
|
|
739
|
-
* @param {PrivateKey} private_key
|
|
740
|
-
* @param {string} program
|
|
741
|
-
* @param {number} fee_credits
|
|
742
|
-
* @param {RecordPlaintext | undefined} fee_record
|
|
743
|
-
* @param {string} url
|
|
744
|
-
* @param {object | undefined} imports
|
|
745
|
-
* @param {ProvingKey | undefined} fee_proving_key
|
|
746
|
-
* @param {VerifyingKey | undefined} fee_verifying_key
|
|
747
|
-
* @returns {Promise<Transaction>}
|
|
748
|
-
*/
|
|
749
|
-
static buildDeploymentTransaction(private_key: PrivateKey, program: string, fee_credits: number, fee_record: RecordPlaintext | undefined, url: string, imports?: object, fee_proving_key?: ProvingKey, fee_verifying_key?: VerifyingKey): Promise<Transaction>;
|
|
750
|
-
/**
|
|
751
|
-
* Estimate the fee for a program deployment
|
|
752
|
-
*
|
|
753
|
-
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
754
|
-
*
|
|
755
|
-
* @param program The source code of the program being deployed
|
|
756
|
-
* @param imports (optional) Provide a list of imports to use for the deployment fee estimation
|
|
757
|
-
* in the form of a javascript object where the keys are a string of the program name and the values
|
|
758
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
759
|
-
* @returns {u64 | Error}
|
|
760
|
-
* @param {string} program
|
|
761
|
-
* @param {object | undefined} imports
|
|
762
|
-
* @returns {Promise<bigint>}
|
|
763
|
-
*/
|
|
764
|
-
static estimateDeploymentFee(program: string, imports?: object): Promise<bigint>;
|
|
765
|
-
/**
|
|
766
|
-
* Estimate the component of the deployment cost which comes from the fee for the program name.
|
|
767
|
-
* Note that this cost does not represent the entire cost of deployment. It is additional to
|
|
768
|
-
* the cost of the size (in bytes) of the deployment.
|
|
769
|
-
*
|
|
770
|
-
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
771
|
-
*
|
|
772
|
-
* @param name The name of the program to be deployed
|
|
773
|
-
* @returns {u64 | Error}
|
|
774
|
-
* @param {string} name
|
|
775
|
-
* @returns {bigint}
|
|
776
|
-
*/
|
|
777
|
-
static estimateProgramNameCost(name: string): bigint;
|
|
778
|
-
/**
|
|
779
807
|
* Send credits from one Aleo account to another
|
|
780
808
|
*
|
|
781
809
|
* @param private_key The private key of the sender
|
|
@@ -821,34 +849,6 @@ export class ProgramManager {
|
|
|
821
849
|
* @returns {Promise<KeyPair>}
|
|
822
850
|
*/
|
|
823
851
|
static synthesizeKeyPair(private_key: PrivateKey, program: string, function_id: string, inputs: Array<any>, imports?: object): Promise<KeyPair>;
|
|
824
|
-
/**
|
|
825
|
-
* Join two records together to create a new record with an amount of credits equal to the sum
|
|
826
|
-
* of the credits of the two original records
|
|
827
|
-
*
|
|
828
|
-
* @param private_key The private key of the sender
|
|
829
|
-
* @param record_1 The first record to combine
|
|
830
|
-
* @param record_2 The second record to combine
|
|
831
|
-
* @param fee_credits The amount of credits to pay as a fee
|
|
832
|
-
* @param fee_record The record to spend the fee from
|
|
833
|
-
* @param url The url of the Aleo network node to send the transaction to
|
|
834
|
-
* @param join_proving_key (optional) Provide a proving key to use for the join function
|
|
835
|
-
* @param join_verifying_key (optional) Provide a verifying key to use for the join function
|
|
836
|
-
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
837
|
-
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
838
|
-
* @returns {Transaction | Error} Transaction object
|
|
839
|
-
* @param {PrivateKey} private_key
|
|
840
|
-
* @param {RecordPlaintext} record_1
|
|
841
|
-
* @param {RecordPlaintext} record_2
|
|
842
|
-
* @param {number} fee_credits
|
|
843
|
-
* @param {RecordPlaintext | undefined} fee_record
|
|
844
|
-
* @param {string} url
|
|
845
|
-
* @param {ProvingKey | undefined} join_proving_key
|
|
846
|
-
* @param {VerifyingKey | undefined} join_verifying_key
|
|
847
|
-
* @param {ProvingKey | undefined} fee_proving_key
|
|
848
|
-
* @param {VerifyingKey | undefined} fee_verifying_key
|
|
849
|
-
* @returns {Promise<Transaction>}
|
|
850
|
-
*/
|
|
851
|
-
static buildJoinTransaction(private_key: PrivateKey, record_1: RecordPlaintext, record_2: RecordPlaintext, fee_credits: number, fee_record: RecordPlaintext | undefined, url: string, join_proving_key?: ProvingKey, join_verifying_key?: VerifyingKey, fee_proving_key?: ProvingKey, fee_verifying_key?: VerifyingKey): Promise<Transaction>;
|
|
852
852
|
}
|
|
853
853
|
/**
|
|
854
854
|
* Proving key for a function within an Aleo program
|
|
@@ -1174,6 +1174,38 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
1174
1174
|
|
|
1175
1175
|
export interface InitOutput {
|
|
1176
1176
|
readonly memory: WebAssembly.Memory;
|
|
1177
|
+
readonly __wbg_address_free: (a: number) => void;
|
|
1178
|
+
readonly address_from_private_key: (a: number) => number;
|
|
1179
|
+
readonly address_from_view_key: (a: number) => number;
|
|
1180
|
+
readonly address_from_string: (a: number, b: number) => number;
|
|
1181
|
+
readonly address_to_string: (a: number, b: number) => void;
|
|
1182
|
+
readonly address_verify: (a: number, b: number, c: number, d: number) => number;
|
|
1183
|
+
readonly __wbg_privatekey_free: (a: number) => void;
|
|
1184
|
+
readonly privatekey_new: () => number;
|
|
1185
|
+
readonly privatekey_from_seed_unchecked: (a: number, b: number) => number;
|
|
1186
|
+
readonly privatekey_from_string: (a: number, b: number, c: number) => void;
|
|
1187
|
+
readonly privatekey_to_string: (a: number, b: number) => void;
|
|
1188
|
+
readonly privatekey_to_seed: (a: number, b: number) => void;
|
|
1189
|
+
readonly privatekey_to_view_key: (a: number) => number;
|
|
1190
|
+
readonly privatekey_sign: (a: number, b: number, c: number) => number;
|
|
1191
|
+
readonly privatekey_newEncrypted: (a: number, b: number, c: number) => void;
|
|
1192
|
+
readonly privatekey_toCiphertext: (a: number, b: number, c: number, d: number) => void;
|
|
1193
|
+
readonly privatekey_fromPrivateKeyCiphertext: (a: number, b: number, c: number, d: number) => void;
|
|
1194
|
+
readonly __wbg_viewkey_free: (a: number) => void;
|
|
1195
|
+
readonly viewkey_from_string: (a: number, b: number) => number;
|
|
1196
|
+
readonly viewkey_to_string: (a: number, b: number) => void;
|
|
1197
|
+
readonly viewkey_decrypt: (a: number, b: number, c: number, d: number) => void;
|
|
1198
|
+
readonly viewkey_decrypt_ciphertext: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
1199
|
+
readonly programmanager_buildJoinTransaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
|
|
1200
|
+
readonly __wbg_verifyingkey_free: (a: number) => void;
|
|
1201
|
+
readonly verifyingkey_fromBytes: (a: number, b: number, c: number) => void;
|
|
1202
|
+
readonly verifyingkey_toBytes: (a: number, b: number) => void;
|
|
1203
|
+
readonly verifyingkey_fromString: (a: number, b: number, c: number) => void;
|
|
1204
|
+
readonly verifyingkey_toString: (a: number, b: number) => void;
|
|
1205
|
+
readonly verifyingkey_copy: (a: number) => number;
|
|
1206
|
+
readonly viewkey_from_private_key: (a: number) => number;
|
|
1207
|
+
readonly viewkey_to_address: (a: number) => number;
|
|
1208
|
+
readonly privatekey_to_address: (a: number) => number;
|
|
1177
1209
|
readonly __wbg_recordciphertext_free: (a: number) => void;
|
|
1178
1210
|
readonly recordciphertext_fromString: (a: number, b: number, c: number) => void;
|
|
1179
1211
|
readonly recordciphertext_toString: (a: number, b: number) => void;
|
|
@@ -1189,10 +1221,14 @@ export interface InitOutput {
|
|
|
1189
1221
|
readonly jsfield_generate_message_leo: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
1190
1222
|
readonly jsfield_generate_message_clients: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
1191
1223
|
readonly programmanager_buildSplitTransaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
1192
|
-
readonly
|
|
1193
|
-
readonly
|
|
1194
|
-
readonly
|
|
1195
|
-
readonly
|
|
1224
|
+
readonly __wbg_privatekeyciphertext_free: (a: number) => void;
|
|
1225
|
+
readonly privatekeyciphertext_encryptPrivateKey: (a: number, b: number, c: number, d: number) => void;
|
|
1226
|
+
readonly privatekeyciphertext_decryptToPrivateKey: (a: number, b: number, c: number, d: number) => void;
|
|
1227
|
+
readonly privatekeyciphertext_toString: (a: number, b: number) => void;
|
|
1228
|
+
readonly privatekeyciphertext_fromString: (a: number, b: number, c: number) => void;
|
|
1229
|
+
readonly programmanager_buildDeploymentTransaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
|
|
1230
|
+
readonly programmanager_estimateDeploymentFee: (a: number, b: number, c: number) => number;
|
|
1231
|
+
readonly programmanager_estimateProgramNameCost: (a: number, b: number, c: number) => void;
|
|
1196
1232
|
readonly programmanager_authExecute: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
1197
1233
|
readonly programmanager_executeFunctionOffline: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
|
|
1198
1234
|
readonly programmanager_buildExecutionTransaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => number;
|
|
@@ -1211,6 +1247,14 @@ export interface InitOutput {
|
|
|
1211
1247
|
readonly program_id: (a: number, b: number) => void;
|
|
1212
1248
|
readonly program_isEqual: (a: number, b: number) => number;
|
|
1213
1249
|
readonly program_getImports: (a: number) => number;
|
|
1250
|
+
readonly __wbg_execution_free: (a: number) => void;
|
|
1251
|
+
readonly execution_toString: (a: number, b: number) => void;
|
|
1252
|
+
readonly execution_fromString: (a: number, b: number, c: number) => void;
|
|
1253
|
+
readonly verifyFunctionExecution: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
1254
|
+
readonly __wbg_provingkey_free: (a: number) => void;
|
|
1255
|
+
readonly provingkey_fromBytes: (a: number, b: number, c: number) => void;
|
|
1256
|
+
readonly provingkey_toBytes: (a: number, b: number) => void;
|
|
1257
|
+
readonly provingkey_copy: (a: number) => number;
|
|
1214
1258
|
readonly __wbg_recordplaintext_free: (a: number) => void;
|
|
1215
1259
|
readonly recordplaintext_fromString: (a: number, b: number, c: number) => void;
|
|
1216
1260
|
readonly recordplaintext_toString: (a: number, b: number) => void;
|
|
@@ -1218,68 +1262,24 @@ export interface InitOutput {
|
|
|
1218
1262
|
readonly recordplaintext_nonce: (a: number, b: number) => void;
|
|
1219
1263
|
readonly recordplaintext_serialNumberString: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
1220
1264
|
readonly runRayonThread: (a: number) => void;
|
|
1221
|
-
readonly __wbg_privatekeyciphertext_free: (a: number) => void;
|
|
1222
|
-
readonly privatekeyciphertext_encryptPrivateKey: (a: number, b: number, c: number, d: number) => void;
|
|
1223
|
-
readonly privatekeyciphertext_decryptToPrivateKey: (a: number, b: number, c: number, d: number) => void;
|
|
1224
|
-
readonly privatekeyciphertext_toString: (a: number, b: number) => void;
|
|
1225
|
-
readonly privatekeyciphertext_fromString: (a: number, b: number, c: number) => void;
|
|
1226
|
-
readonly programmanager_buildDeploymentTransaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
|
|
1227
|
-
readonly programmanager_estimateDeploymentFee: (a: number, b: number, c: number) => number;
|
|
1228
|
-
readonly programmanager_estimateProgramNameCost: (a: number, b: number, c: number) => void;
|
|
1229
|
-
readonly __wbg_execution_free: (a: number) => void;
|
|
1230
|
-
readonly execution_toString: (a: number, b: number) => void;
|
|
1231
|
-
readonly execution_fromString: (a: number, b: number, c: number) => void;
|
|
1232
|
-
readonly verifyFunctionExecution: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
1233
1265
|
readonly programmanager_buildTransferTransaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => number;
|
|
1234
1266
|
readonly programmanager_synthesizeKeyPair: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
1235
|
-
readonly __wbg_executionresponse_free: (a: number) => void;
|
|
1236
|
-
readonly executionresponse_getOutputs: (a: number) => number;
|
|
1237
|
-
readonly executionresponse_getExecution: (a: number) => number;
|
|
1238
|
-
readonly executionresponse_getKeys: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
1239
1267
|
readonly __wbg_transaction_free: (a: number) => void;
|
|
1240
1268
|
readonly transaction_fromString: (a: number, b: number, c: number) => void;
|
|
1241
1269
|
readonly transaction_toString: (a: number, b: number) => void;
|
|
1242
1270
|
readonly transaction_transactionId: (a: number, b: number) => void;
|
|
1243
1271
|
readonly transaction_transactionType: (a: number, b: number) => void;
|
|
1244
1272
|
readonly __wbg_programmanager_free: (a: number) => void;
|
|
1245
|
-
readonly
|
|
1246
|
-
readonly
|
|
1247
|
-
readonly
|
|
1248
|
-
readonly
|
|
1249
|
-
readonly privatekey_to_string: (a: number, b: number) => void;
|
|
1250
|
-
readonly privatekey_to_seed: (a: number, b: number) => void;
|
|
1251
|
-
readonly privatekey_to_view_key: (a: number) => number;
|
|
1252
|
-
readonly privatekey_to_address: (a: number) => number;
|
|
1253
|
-
readonly privatekey_sign: (a: number, b: number, c: number) => number;
|
|
1254
|
-
readonly privatekey_newEncrypted: (a: number, b: number, c: number) => void;
|
|
1255
|
-
readonly privatekey_toCiphertext: (a: number, b: number, c: number, d: number) => void;
|
|
1256
|
-
readonly privatekey_fromPrivateKeyCiphertext: (a: number, b: number, c: number, d: number) => void;
|
|
1273
|
+
readonly __wbg_executionresponse_free: (a: number) => void;
|
|
1274
|
+
readonly executionresponse_getOutputs: (a: number) => number;
|
|
1275
|
+
readonly executionresponse_getExecution: (a: number) => number;
|
|
1276
|
+
readonly executionresponse_getKeys: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
1257
1277
|
readonly __wbg_signature_free: (a: number) => void;
|
|
1278
|
+
readonly signature_sign: (a: number, b: number, c: number) => number;
|
|
1258
1279
|
readonly signature_sign_message: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
1259
1280
|
readonly signature_verify: (a: number, b: number, c: number, d: number) => number;
|
|
1260
1281
|
readonly signature_from_string: (a: number, b: number) => number;
|
|
1261
1282
|
readonly signature_to_string: (a: number, b: number) => void;
|
|
1262
|
-
readonly programmanager_buildJoinTransaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
|
|
1263
|
-
readonly __wbg_verifyingkey_free: (a: number) => void;
|
|
1264
|
-
readonly verifyingkey_fromBytes: (a: number, b: number, c: number) => void;
|
|
1265
|
-
readonly verifyingkey_toBytes: (a: number, b: number) => void;
|
|
1266
|
-
readonly verifyingkey_fromString: (a: number, b: number, c: number) => void;
|
|
1267
|
-
readonly verifyingkey_toString: (a: number, b: number) => void;
|
|
1268
|
-
readonly verifyingkey_copy: (a: number) => number;
|
|
1269
|
-
readonly signature_sign: (a: number, b: number, c: number) => number;
|
|
1270
|
-
readonly __wbg_address_free: (a: number) => void;
|
|
1271
|
-
readonly address_from_private_key: (a: number) => number;
|
|
1272
|
-
readonly address_from_view_key: (a: number) => number;
|
|
1273
|
-
readonly address_from_string: (a: number, b: number) => number;
|
|
1274
|
-
readonly address_to_string: (a: number, b: number) => void;
|
|
1275
|
-
readonly address_verify: (a: number, b: number, c: number, d: number) => number;
|
|
1276
|
-
readonly __wbg_viewkey_free: (a: number) => void;
|
|
1277
|
-
readonly viewkey_from_private_key: (a: number) => number;
|
|
1278
|
-
readonly viewkey_from_string: (a: number, b: number) => number;
|
|
1279
|
-
readonly viewkey_to_string: (a: number, b: number) => void;
|
|
1280
|
-
readonly viewkey_decrypt: (a: number, b: number, c: number, d: number) => void;
|
|
1281
|
-
readonly viewkey_decrypt_ciphertext: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
1282
|
-
readonly viewkey_to_address: (a: number) => number;
|
|
1283
1283
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
1284
1284
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
1285
1285
|
readonly __wbindgen_export_2: WebAssembly.Table;
|
package/aleo_wasm.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { spawnWorker } from './snippets/aleo-wasm-91297d530eb26bda/inline0.js';
|
|
2
|
+
|
|
1
3
|
let wasm;
|
|
2
4
|
|
|
3
5
|
const heap = new Array(128).fill(undefined);
|
|
@@ -214,6 +216,18 @@ function _assertClass(instance, klass) {
|
|
|
214
216
|
}
|
|
215
217
|
return instance.ptr;
|
|
216
218
|
}
|
|
219
|
+
|
|
220
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
221
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
222
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
223
|
+
WASM_VECTOR_LEN = arg.length;
|
|
224
|
+
return ptr;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
228
|
+
ptr = ptr >>> 0;
|
|
229
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
230
|
+
}
|
|
217
231
|
/**
|
|
218
232
|
*/
|
|
219
233
|
export function init_panic_hook() {
|
|
@@ -230,18 +244,6 @@ export function initThreadPool(url, num_threads) {
|
|
|
230
244
|
return takeObject(ret);
|
|
231
245
|
}
|
|
232
246
|
|
|
233
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
234
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
235
|
-
getUint8Memory0().set(arg, ptr / 1);
|
|
236
|
-
WASM_VECTOR_LEN = arg.length;
|
|
237
|
-
return ptr;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
241
|
-
ptr = ptr >>> 0;
|
|
242
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
247
|
let cachedBigInt64Memory0 = null;
|
|
246
248
|
|
|
247
249
|
function getBigInt64Memory0() {
|
|
@@ -250,13 +252,6 @@ function getBigInt64Memory0() {
|
|
|
250
252
|
}
|
|
251
253
|
return cachedBigInt64Memory0;
|
|
252
254
|
}
|
|
253
|
-
/**
|
|
254
|
-
* @param {number} receiver
|
|
255
|
-
*/
|
|
256
|
-
export function runRayonThread(receiver) {
|
|
257
|
-
wasm.runRayonThread(receiver);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
255
|
/**
|
|
261
256
|
* Verify an execution with a single function and a single transition. Executions with multiple
|
|
262
257
|
* transitions or functions will fail to verify. Also, this does not verify that the state root of
|
|
@@ -294,6 +289,13 @@ export function verifyFunctionExecution(execution, verifying_key, program, funct
|
|
|
294
289
|
}
|
|
295
290
|
}
|
|
296
291
|
|
|
292
|
+
/**
|
|
293
|
+
* @param {number} receiver
|
|
294
|
+
*/
|
|
295
|
+
export function runRayonThread(receiver) {
|
|
296
|
+
wasm.runRayonThread(receiver);
|
|
297
|
+
}
|
|
298
|
+
|
|
297
299
|
function handleError(f, args) {
|
|
298
300
|
try {
|
|
299
301
|
return f.apply(this, args);
|
|
@@ -839,7 +841,7 @@ export class PrivateKey {
|
|
|
839
841
|
* @returns {Address}
|
|
840
842
|
*/
|
|
841
843
|
to_address() {
|
|
842
|
-
const ret = wasm.
|
|
844
|
+
const ret = wasm.address_from_private_key(this.__wbg_ptr);
|
|
843
845
|
return Address.__wrap(ret);
|
|
844
846
|
}
|
|
845
847
|
/**
|
|
@@ -1477,6 +1479,69 @@ export class ProgramManager {
|
|
|
1477
1479
|
wasm.__wbg_programmanager_free(ptr);
|
|
1478
1480
|
}
|
|
1479
1481
|
/**
|
|
1482
|
+
* Join two records together to create a new record with an amount of credits equal to the sum
|
|
1483
|
+
* of the credits of the two original records
|
|
1484
|
+
*
|
|
1485
|
+
* @param private_key The private key of the sender
|
|
1486
|
+
* @param record_1 The first record to combine
|
|
1487
|
+
* @param record_2 The second record to combine
|
|
1488
|
+
* @param fee_credits The amount of credits to pay as a fee
|
|
1489
|
+
* @param fee_record The record to spend the fee from
|
|
1490
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
1491
|
+
* @param join_proving_key (optional) Provide a proving key to use for the join function
|
|
1492
|
+
* @param join_verifying_key (optional) Provide a verifying key to use for the join function
|
|
1493
|
+
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
1494
|
+
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
1495
|
+
* @returns {Transaction | Error} Transaction object
|
|
1496
|
+
* @param {PrivateKey} private_key
|
|
1497
|
+
* @param {RecordPlaintext} record_1
|
|
1498
|
+
* @param {RecordPlaintext} record_2
|
|
1499
|
+
* @param {number} fee_credits
|
|
1500
|
+
* @param {RecordPlaintext | undefined} fee_record
|
|
1501
|
+
* @param {string} url
|
|
1502
|
+
* @param {ProvingKey | undefined} join_proving_key
|
|
1503
|
+
* @param {VerifyingKey | undefined} join_verifying_key
|
|
1504
|
+
* @param {ProvingKey | undefined} fee_proving_key
|
|
1505
|
+
* @param {VerifyingKey | undefined} fee_verifying_key
|
|
1506
|
+
* @returns {Promise<Transaction>}
|
|
1507
|
+
*/
|
|
1508
|
+
static buildJoinTransaction(private_key, record_1, record_2, fee_credits, fee_record, url, join_proving_key, join_verifying_key, fee_proving_key, fee_verifying_key) {
|
|
1509
|
+
_assertClass(private_key, PrivateKey);
|
|
1510
|
+
_assertClass(record_1, RecordPlaintext);
|
|
1511
|
+
var ptr0 = record_1.__destroy_into_raw();
|
|
1512
|
+
_assertClass(record_2, RecordPlaintext);
|
|
1513
|
+
var ptr1 = record_2.__destroy_into_raw();
|
|
1514
|
+
let ptr2 = 0;
|
|
1515
|
+
if (!isLikeNone(fee_record)) {
|
|
1516
|
+
_assertClass(fee_record, RecordPlaintext);
|
|
1517
|
+
ptr2 = fee_record.__destroy_into_raw();
|
|
1518
|
+
}
|
|
1519
|
+
const ptr3 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1520
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1521
|
+
let ptr4 = 0;
|
|
1522
|
+
if (!isLikeNone(join_proving_key)) {
|
|
1523
|
+
_assertClass(join_proving_key, ProvingKey);
|
|
1524
|
+
ptr4 = join_proving_key.__destroy_into_raw();
|
|
1525
|
+
}
|
|
1526
|
+
let ptr5 = 0;
|
|
1527
|
+
if (!isLikeNone(join_verifying_key)) {
|
|
1528
|
+
_assertClass(join_verifying_key, VerifyingKey);
|
|
1529
|
+
ptr5 = join_verifying_key.__destroy_into_raw();
|
|
1530
|
+
}
|
|
1531
|
+
let ptr6 = 0;
|
|
1532
|
+
if (!isLikeNone(fee_proving_key)) {
|
|
1533
|
+
_assertClass(fee_proving_key, ProvingKey);
|
|
1534
|
+
ptr6 = fee_proving_key.__destroy_into_raw();
|
|
1535
|
+
}
|
|
1536
|
+
let ptr7 = 0;
|
|
1537
|
+
if (!isLikeNone(fee_verifying_key)) {
|
|
1538
|
+
_assertClass(fee_verifying_key, VerifyingKey);
|
|
1539
|
+
ptr7 = fee_verifying_key.__destroy_into_raw();
|
|
1540
|
+
}
|
|
1541
|
+
const ret = wasm.programmanager_buildJoinTransaction(private_key.__wbg_ptr, ptr0, ptr1, fee_credits, ptr2, ptr3, len3, ptr4, ptr5, ptr6, ptr7);
|
|
1542
|
+
return takeObject(ret);
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1480
1545
|
* Split an Aleo credits record into two separate records. This function does not require a fee.
|
|
1481
1546
|
*
|
|
1482
1547
|
* @param private_key The private key of the sender
|
|
@@ -1515,20 +1580,121 @@ export class ProgramManager {
|
|
|
1515
1580
|
return takeObject(ret);
|
|
1516
1581
|
}
|
|
1517
1582
|
/**
|
|
1583
|
+
* Deploy an Aleo program
|
|
1584
|
+
*
|
|
1585
|
+
* @param private_key The private key of the sender
|
|
1586
|
+
* @param program The source code of the program being deployed
|
|
1587
|
+
* @param imports A javascript object holding the source code of any imported programs in the
|
|
1588
|
+
* form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
|
|
1589
|
+
* Note that all imported programs must be deployed on chain before the main program in order
|
|
1590
|
+
* for the deployment to succeed
|
|
1591
|
+
* @param fee_credits The amount of credits to pay as a fee
|
|
1592
|
+
* @param fee_record The record to spend the fee from
|
|
1593
|
+
* @param url The url of the Aleo network node to send the transaction to
|
|
1594
|
+
* @param imports (optional) Provide a list of imports to use for the program deployment in the
|
|
1595
|
+
* form of a javascript object where the keys are a string of the program name and the values
|
|
1596
|
+
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
1597
|
+
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
1598
|
+
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
1599
|
+
* @returns {Transaction | Error}
|
|
1600
|
+
* @param {PrivateKey} private_key
|
|
1601
|
+
* @param {string} program
|
|
1602
|
+
* @param {number} fee_credits
|
|
1603
|
+
* @param {RecordPlaintext | undefined} fee_record
|
|
1604
|
+
* @param {string} url
|
|
1605
|
+
* @param {object | undefined} imports
|
|
1606
|
+
* @param {ProvingKey | undefined} fee_proving_key
|
|
1607
|
+
* @param {VerifyingKey | undefined} fee_verifying_key
|
|
1608
|
+
* @returns {Promise<Transaction>}
|
|
1609
|
+
*/
|
|
1610
|
+
static buildDeploymentTransaction(private_key, program, fee_credits, fee_record, url, imports, fee_proving_key, fee_verifying_key) {
|
|
1611
|
+
_assertClass(private_key, PrivateKey);
|
|
1612
|
+
const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1613
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1614
|
+
let ptr1 = 0;
|
|
1615
|
+
if (!isLikeNone(fee_record)) {
|
|
1616
|
+
_assertClass(fee_record, RecordPlaintext);
|
|
1617
|
+
ptr1 = fee_record.__destroy_into_raw();
|
|
1618
|
+
}
|
|
1619
|
+
const ptr2 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1620
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1621
|
+
let ptr3 = 0;
|
|
1622
|
+
if (!isLikeNone(fee_proving_key)) {
|
|
1623
|
+
_assertClass(fee_proving_key, ProvingKey);
|
|
1624
|
+
ptr3 = fee_proving_key.__destroy_into_raw();
|
|
1625
|
+
}
|
|
1626
|
+
let ptr4 = 0;
|
|
1627
|
+
if (!isLikeNone(fee_verifying_key)) {
|
|
1628
|
+
_assertClass(fee_verifying_key, VerifyingKey);
|
|
1629
|
+
ptr4 = fee_verifying_key.__destroy_into_raw();
|
|
1630
|
+
}
|
|
1631
|
+
const ret = wasm.programmanager_buildDeploymentTransaction(private_key.__wbg_ptr, ptr0, len0, fee_credits, ptr1, ptr2, len2, isLikeNone(imports) ? 0 : addHeapObject(imports), ptr3, ptr4);
|
|
1632
|
+
return takeObject(ret);
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Estimate the fee for a program deployment
|
|
1636
|
+
*
|
|
1637
|
+
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
1638
|
+
*
|
|
1639
|
+
* @param program The source code of the program being deployed
|
|
1640
|
+
* @param imports (optional) Provide a list of imports to use for the deployment fee estimation
|
|
1641
|
+
* in the form of a javascript object where the keys are a string of the program name and the values
|
|
1642
|
+
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
1643
|
+
* @returns {u64 | Error}
|
|
1644
|
+
* @param {string} program
|
|
1645
|
+
* @param {object | undefined} imports
|
|
1646
|
+
* @returns {Promise<bigint>}
|
|
1647
|
+
*/
|
|
1648
|
+
static estimateDeploymentFee(program, imports) {
|
|
1649
|
+
const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1650
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1651
|
+
const ret = wasm.programmanager_estimateDeploymentFee(ptr0, len0, isLikeNone(imports) ? 0 : addHeapObject(imports));
|
|
1652
|
+
return takeObject(ret);
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Estimate the component of the deployment cost which comes from the fee for the program name.
|
|
1656
|
+
* Note that this cost does not represent the entire cost of deployment. It is additional to
|
|
1657
|
+
* the cost of the size (in bytes) of the deployment.
|
|
1658
|
+
*
|
|
1659
|
+
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
1660
|
+
*
|
|
1661
|
+
* @param name The name of the program to be deployed
|
|
1662
|
+
* @returns {u64 | Error}
|
|
1663
|
+
* @param {string} name
|
|
1664
|
+
* @returns {bigint}
|
|
1665
|
+
*/
|
|
1666
|
+
static estimateProgramNameCost(name) {
|
|
1667
|
+
try {
|
|
1668
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1669
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1670
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1671
|
+
wasm.programmanager_estimateProgramNameCost(retptr, ptr0, len0);
|
|
1672
|
+
var r0 = getBigInt64Memory0()[retptr / 8 + 0];
|
|
1673
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
1674
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
1675
|
+
if (r3) {
|
|
1676
|
+
throw takeObject(r2);
|
|
1677
|
+
}
|
|
1678
|
+
return BigInt.asUintN(64, r0);
|
|
1679
|
+
} finally {
|
|
1680
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1518
1684
|
* @param {string} program_id
|
|
1519
1685
|
* @param {string} function_id
|
|
1520
1686
|
* @param {Array<any>} inputs_str
|
|
1521
|
-
* @param {
|
|
1687
|
+
* @param {string} private_key
|
|
1522
1688
|
* @returns {Promise<string>}
|
|
1523
1689
|
*/
|
|
1524
|
-
authExecute(program_id, function_id, inputs_str, private_key) {
|
|
1525
|
-
const ptr = this.__destroy_into_raw();
|
|
1690
|
+
static authExecute(program_id, function_id, inputs_str, private_key) {
|
|
1526
1691
|
const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1527
1692
|
const len0 = WASM_VECTOR_LEN;
|
|
1528
1693
|
const ptr1 = passStringToWasm0(function_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1529
1694
|
const len1 = WASM_VECTOR_LEN;
|
|
1530
|
-
|
|
1531
|
-
const
|
|
1695
|
+
const ptr2 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1696
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1697
|
+
const ret = wasm.programmanager_authExecute(ptr0, len0, ptr1, len1, addHeapObject(inputs_str), ptr2, len2);
|
|
1532
1698
|
return takeObject(ret);
|
|
1533
1699
|
}
|
|
1534
1700
|
/**
|
|
@@ -1735,107 +1901,6 @@ export class ProgramManager {
|
|
|
1735
1901
|
}
|
|
1736
1902
|
}
|
|
1737
1903
|
/**
|
|
1738
|
-
* Deploy an Aleo program
|
|
1739
|
-
*
|
|
1740
|
-
* @param private_key The private key of the sender
|
|
1741
|
-
* @param program The source code of the program being deployed
|
|
1742
|
-
* @param imports A javascript object holding the source code of any imported programs in the
|
|
1743
|
-
* form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
|
|
1744
|
-
* Note that all imported programs must be deployed on chain before the main program in order
|
|
1745
|
-
* for the deployment to succeed
|
|
1746
|
-
* @param fee_credits The amount of credits to pay as a fee
|
|
1747
|
-
* @param fee_record The record to spend the fee from
|
|
1748
|
-
* @param url The url of the Aleo network node to send the transaction to
|
|
1749
|
-
* @param imports (optional) Provide a list of imports to use for the program deployment in the
|
|
1750
|
-
* form of a javascript object where the keys are a string of the program name and the values
|
|
1751
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
1752
|
-
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
1753
|
-
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
1754
|
-
* @returns {Transaction | Error}
|
|
1755
|
-
* @param {PrivateKey} private_key
|
|
1756
|
-
* @param {string} program
|
|
1757
|
-
* @param {number} fee_credits
|
|
1758
|
-
* @param {RecordPlaintext | undefined} fee_record
|
|
1759
|
-
* @param {string} url
|
|
1760
|
-
* @param {object | undefined} imports
|
|
1761
|
-
* @param {ProvingKey | undefined} fee_proving_key
|
|
1762
|
-
* @param {VerifyingKey | undefined} fee_verifying_key
|
|
1763
|
-
* @returns {Promise<Transaction>}
|
|
1764
|
-
*/
|
|
1765
|
-
static buildDeploymentTransaction(private_key, program, fee_credits, fee_record, url, imports, fee_proving_key, fee_verifying_key) {
|
|
1766
|
-
_assertClass(private_key, PrivateKey);
|
|
1767
|
-
const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1768
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1769
|
-
let ptr1 = 0;
|
|
1770
|
-
if (!isLikeNone(fee_record)) {
|
|
1771
|
-
_assertClass(fee_record, RecordPlaintext);
|
|
1772
|
-
ptr1 = fee_record.__destroy_into_raw();
|
|
1773
|
-
}
|
|
1774
|
-
const ptr2 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1775
|
-
const len2 = WASM_VECTOR_LEN;
|
|
1776
|
-
let ptr3 = 0;
|
|
1777
|
-
if (!isLikeNone(fee_proving_key)) {
|
|
1778
|
-
_assertClass(fee_proving_key, ProvingKey);
|
|
1779
|
-
ptr3 = fee_proving_key.__destroy_into_raw();
|
|
1780
|
-
}
|
|
1781
|
-
let ptr4 = 0;
|
|
1782
|
-
if (!isLikeNone(fee_verifying_key)) {
|
|
1783
|
-
_assertClass(fee_verifying_key, VerifyingKey);
|
|
1784
|
-
ptr4 = fee_verifying_key.__destroy_into_raw();
|
|
1785
|
-
}
|
|
1786
|
-
const ret = wasm.programmanager_buildDeploymentTransaction(private_key.__wbg_ptr, ptr0, len0, fee_credits, ptr1, ptr2, len2, isLikeNone(imports) ? 0 : addHeapObject(imports), ptr3, ptr4);
|
|
1787
|
-
return takeObject(ret);
|
|
1788
|
-
}
|
|
1789
|
-
/**
|
|
1790
|
-
* Estimate the fee for a program deployment
|
|
1791
|
-
*
|
|
1792
|
-
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
1793
|
-
*
|
|
1794
|
-
* @param program The source code of the program being deployed
|
|
1795
|
-
* @param imports (optional) Provide a list of imports to use for the deployment fee estimation
|
|
1796
|
-
* in the form of a javascript object where the keys are a string of the program name and the values
|
|
1797
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
1798
|
-
* @returns {u64 | Error}
|
|
1799
|
-
* @param {string} program
|
|
1800
|
-
* @param {object | undefined} imports
|
|
1801
|
-
* @returns {Promise<bigint>}
|
|
1802
|
-
*/
|
|
1803
|
-
static estimateDeploymentFee(program, imports) {
|
|
1804
|
-
const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1805
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1806
|
-
const ret = wasm.programmanager_estimateDeploymentFee(ptr0, len0, isLikeNone(imports) ? 0 : addHeapObject(imports));
|
|
1807
|
-
return takeObject(ret);
|
|
1808
|
-
}
|
|
1809
|
-
/**
|
|
1810
|
-
* Estimate the component of the deployment cost which comes from the fee for the program name.
|
|
1811
|
-
* Note that this cost does not represent the entire cost of deployment. It is additional to
|
|
1812
|
-
* the cost of the size (in bytes) of the deployment.
|
|
1813
|
-
*
|
|
1814
|
-
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
1815
|
-
*
|
|
1816
|
-
* @param name The name of the program to be deployed
|
|
1817
|
-
* @returns {u64 | Error}
|
|
1818
|
-
* @param {string} name
|
|
1819
|
-
* @returns {bigint}
|
|
1820
|
-
*/
|
|
1821
|
-
static estimateProgramNameCost(name) {
|
|
1822
|
-
try {
|
|
1823
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1824
|
-
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1825
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1826
|
-
wasm.programmanager_estimateProgramNameCost(retptr, ptr0, len0);
|
|
1827
|
-
var r0 = getBigInt64Memory0()[retptr / 8 + 0];
|
|
1828
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
1829
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
1830
|
-
if (r3) {
|
|
1831
|
-
throw takeObject(r2);
|
|
1832
|
-
}
|
|
1833
|
-
return BigInt.asUintN(64, r0);
|
|
1834
|
-
} finally {
|
|
1835
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
/**
|
|
1839
1904
|
* Send credits from one Aleo account to another
|
|
1840
1905
|
*
|
|
1841
1906
|
* @param private_key The private key of the sender
|
|
@@ -1929,69 +1994,6 @@ export class ProgramManager {
|
|
|
1929
1994
|
const ret = wasm.programmanager_synthesizeKeyPair(private_key.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(inputs), isLikeNone(imports) ? 0 : addHeapObject(imports));
|
|
1930
1995
|
return takeObject(ret);
|
|
1931
1996
|
}
|
|
1932
|
-
/**
|
|
1933
|
-
* Join two records together to create a new record with an amount of credits equal to the sum
|
|
1934
|
-
* of the credits of the two original records
|
|
1935
|
-
*
|
|
1936
|
-
* @param private_key The private key of the sender
|
|
1937
|
-
* @param record_1 The first record to combine
|
|
1938
|
-
* @param record_2 The second record to combine
|
|
1939
|
-
* @param fee_credits The amount of credits to pay as a fee
|
|
1940
|
-
* @param fee_record The record to spend the fee from
|
|
1941
|
-
* @param url The url of the Aleo network node to send the transaction to
|
|
1942
|
-
* @param join_proving_key (optional) Provide a proving key to use for the join function
|
|
1943
|
-
* @param join_verifying_key (optional) Provide a verifying key to use for the join function
|
|
1944
|
-
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
1945
|
-
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
1946
|
-
* @returns {Transaction | Error} Transaction object
|
|
1947
|
-
* @param {PrivateKey} private_key
|
|
1948
|
-
* @param {RecordPlaintext} record_1
|
|
1949
|
-
* @param {RecordPlaintext} record_2
|
|
1950
|
-
* @param {number} fee_credits
|
|
1951
|
-
* @param {RecordPlaintext | undefined} fee_record
|
|
1952
|
-
* @param {string} url
|
|
1953
|
-
* @param {ProvingKey | undefined} join_proving_key
|
|
1954
|
-
* @param {VerifyingKey | undefined} join_verifying_key
|
|
1955
|
-
* @param {ProvingKey | undefined} fee_proving_key
|
|
1956
|
-
* @param {VerifyingKey | undefined} fee_verifying_key
|
|
1957
|
-
* @returns {Promise<Transaction>}
|
|
1958
|
-
*/
|
|
1959
|
-
static buildJoinTransaction(private_key, record_1, record_2, fee_credits, fee_record, url, join_proving_key, join_verifying_key, fee_proving_key, fee_verifying_key) {
|
|
1960
|
-
_assertClass(private_key, PrivateKey);
|
|
1961
|
-
_assertClass(record_1, RecordPlaintext);
|
|
1962
|
-
var ptr0 = record_1.__destroy_into_raw();
|
|
1963
|
-
_assertClass(record_2, RecordPlaintext);
|
|
1964
|
-
var ptr1 = record_2.__destroy_into_raw();
|
|
1965
|
-
let ptr2 = 0;
|
|
1966
|
-
if (!isLikeNone(fee_record)) {
|
|
1967
|
-
_assertClass(fee_record, RecordPlaintext);
|
|
1968
|
-
ptr2 = fee_record.__destroy_into_raw();
|
|
1969
|
-
}
|
|
1970
|
-
const ptr3 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1971
|
-
const len3 = WASM_VECTOR_LEN;
|
|
1972
|
-
let ptr4 = 0;
|
|
1973
|
-
if (!isLikeNone(join_proving_key)) {
|
|
1974
|
-
_assertClass(join_proving_key, ProvingKey);
|
|
1975
|
-
ptr4 = join_proving_key.__destroy_into_raw();
|
|
1976
|
-
}
|
|
1977
|
-
let ptr5 = 0;
|
|
1978
|
-
if (!isLikeNone(join_verifying_key)) {
|
|
1979
|
-
_assertClass(join_verifying_key, VerifyingKey);
|
|
1980
|
-
ptr5 = join_verifying_key.__destroy_into_raw();
|
|
1981
|
-
}
|
|
1982
|
-
let ptr6 = 0;
|
|
1983
|
-
if (!isLikeNone(fee_proving_key)) {
|
|
1984
|
-
_assertClass(fee_proving_key, ProvingKey);
|
|
1985
|
-
ptr6 = fee_proving_key.__destroy_into_raw();
|
|
1986
|
-
}
|
|
1987
|
-
let ptr7 = 0;
|
|
1988
|
-
if (!isLikeNone(fee_verifying_key)) {
|
|
1989
|
-
_assertClass(fee_verifying_key, VerifyingKey);
|
|
1990
|
-
ptr7 = fee_verifying_key.__destroy_into_raw();
|
|
1991
|
-
}
|
|
1992
|
-
const ret = wasm.programmanager_buildJoinTransaction(private_key.__wbg_ptr, ptr0, ptr1, fee_credits, ptr2, ptr3, len3, ptr4, ptr5, ptr6, ptr7);
|
|
1993
|
-
return takeObject(ret);
|
|
1994
|
-
}
|
|
1995
1997
|
}
|
|
1996
1998
|
/**
|
|
1997
1999
|
* Proving key for a function within an Aleo program
|
|
@@ -2370,7 +2372,7 @@ export class Signature {
|
|
|
2370
2372
|
_assertClass(private_key, PrivateKey);
|
|
2371
2373
|
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
2372
2374
|
const len0 = WASM_VECTOR_LEN;
|
|
2373
|
-
const ret = wasm.
|
|
2375
|
+
const ret = wasm.signature_sign(private_key.__wbg_ptr, ptr0, len0);
|
|
2374
2376
|
return Signature.__wrap(ret);
|
|
2375
2377
|
}
|
|
2376
2378
|
/**
|
|
@@ -2735,7 +2737,7 @@ export class ViewKey {
|
|
|
2735
2737
|
*/
|
|
2736
2738
|
static from_private_key(private_key) {
|
|
2737
2739
|
_assertClass(private_key, PrivateKey);
|
|
2738
|
-
const ret = wasm.
|
|
2740
|
+
const ret = wasm.privatekey_to_view_key(private_key.__wbg_ptr);
|
|
2739
2741
|
return ViewKey.__wrap(ret);
|
|
2740
2742
|
}
|
|
2741
2743
|
/**
|
|
@@ -3279,8 +3281,8 @@ function __wbg_get_imports() {
|
|
|
3279
3281
|
const ret = wasm.memory;
|
|
3280
3282
|
return addHeapObject(ret);
|
|
3281
3283
|
};
|
|
3282
|
-
imports.wbg.
|
|
3283
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
3284
|
+
imports.wbg.__wbindgen_closure_wrapper6539 = function(arg0, arg1, arg2) {
|
|
3285
|
+
const ret = makeMutClosure(arg0, arg1, 879, __wbg_adapter_32);
|
|
3284
3286
|
return addHeapObject(ret);
|
|
3285
3287
|
};
|
|
3286
3288
|
|
package/aleo_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"The Aleo Team <hello@aleo.org>"
|
|
5
5
|
],
|
|
6
6
|
"description": "WebAssembly based toolkit for developing zero knowledge applications with Aleo",
|
|
7
|
-
"version": "0.6.
|
|
7
|
+
"version": "0.6.6",
|
|
8
8
|
"license": "GPL-3.0",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"aleo_wasm_bg.wasm",
|
|
15
15
|
"aleo_wasm.js",
|
|
16
|
-
"aleo_wasm.d.ts"
|
|
16
|
+
"aleo_wasm.d.ts",
|
|
17
|
+
"snippets/"
|
|
17
18
|
],
|
|
18
19
|
"module": "aleo_wasm.js",
|
|
19
20
|
"homepage": "https://aleo.org",
|
|
@@ -28,4 +29,4 @@
|
|
|
28
29
|
"decentralized",
|
|
29
30
|
"zero-knowledge"
|
|
30
31
|
]
|
|
31
|
-
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
export function spawnWorker(url, module, memory, address) {
|
|
3
|
+
return new Promise((resolve) => {
|
|
4
|
+
const worker = new Worker(url, {
|
|
5
|
+
type: "module",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
worker.addEventListener("message", (event) => {
|
|
9
|
+
// When running in Node, this allows the process to exit
|
|
10
|
+
// even though the Worker is still running.
|
|
11
|
+
if (worker.unref) {
|
|
12
|
+
worker.unref();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
resolve(worker);
|
|
16
|
+
}, {
|
|
17
|
+
capture: true,
|
|
18
|
+
once: true,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
worker.postMessage({
|
|
22
|
+
module,
|
|
23
|
+
memory,
|
|
24
|
+
address,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|