Skip to content

Commit 10fa512

Browse files
committed
devnet update
1 parent 3d6b5d7 commit 10fa512

12 files changed

+143
-114
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ edition = "2021"
99
itertools = "0.10.3"
1010
clap = { version = "3.1.8", features = ["derive"] }
1111

12-
move-core-types = { git = "https://github.com/move-language/move", rev = "a34266fc6c51bfc669d44f4c0faa337058e7833f" }
13-
move-compiler = { git = "https://github.com/move-language/move", rev = "a34266fc6c51bfc669d44f4c0faa337058e7833f" }
14-
move-ir-types = { git = "https://github.com/move-language/move", rev = "a34266fc6c51bfc669d44f4c0faa337058e7833f" }
15-
move-package = { git = "https://github.com/move-language/move", rev = "a34266fc6c51bfc669d44f4c0faa337058e7833f" }
16-
move-command-line-common = { git = "https://github.com/move-language/move", rev = "a34266fc6c51bfc669d44f4c0faa337058e7833f" }
12+
move-core-types = { git = "https://github.com/move-language/move", rev = "547c7f79d1c46dccfcb1024005d2a796be2480ec" }
13+
move-compiler = { git = "https://github.com/move-language/move", rev = "547c7f79d1c46dccfcb1024005d2a796be2480ec" }
14+
move-ir-types = { git = "https://github.com/move-language/move", rev = "547c7f79d1c46dccfcb1024005d2a796be2480ec" }
15+
move-package = { git = "https://github.com/move-language/move", rev = "547c7f79d1c46dccfcb1024005d2a796be2480ec" }
16+
move-command-line-common = { git = "https://github.com/move-language/move", rev = "547c7f79d1c46dccfcb1024005d2a796be2480ec" }
1717

1818
[features]
1919
default = ["move-core-types/address32"]

src/ast_exp.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ impl AstTsPrinter for Exp {
1616
use UnannotatedExp_ as E;
1717
match &exp.value {
1818
E::Unit { case: _ } => {
19-
unreachable!("Cannot output Unit as value");
20-
//derr!((exp.loc, "Cannot output Unit as value"))
19+
derr!((exp.loc, "Cannot output Unit as value"))
2120
}
2221
E::Value(v) => Ok(v.term(c)?),
2322
E::Move {

src/ast_to_ts.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,15 @@ pub fn handle_special_structs(
441441
match &ty.value {
442442
BaseType_::Apply(_, typename, _) => match &typename.value {
443443
TypeName_::ModuleType(_, _) => {
444-
w.writeln(format!("await this.{}.loadFullState(app);", name));
444+
w.writeln(format!("await this.{}.loadFullState(app);", rename(name)));
445445
}
446446
_ => {}
447447
},
448448
BaseType_::Param(_) => {
449449
w.writeln(format!(
450450
"if (this.{}.typeTag instanceof StructTag) {{await this.{}.loadFullState(app);}}",
451-
name,
452-
name
451+
rename(name),
452+
rename(name)
453453
));
454454
}
455455
_ => {}
@@ -1324,23 +1324,21 @@ impl AstTsPrinter for (FunctionName, &Function) {
13241324
w.writeln("const typeParamStrings = [] as string[];");
13251325
}
13261326
w.writeln("return $.buildPayload(");
1327-
// function_name
1328-
w.writeln(format!(
1329-
" \"{}::{}::{}\",",
1330-
address, mident.value.module, name
1331-
));
1327+
// address
1328+
w.writeln(format!(" new HexString(\"{}\"),", address));
1329+
// moduleName
1330+
w.writeln(format!(" \"{}\",", mident.value.module));
1331+
// funcName
1332+
w.writeln(format!(" \"{}\",", name));
13321333
// type arguments
13331334
w.writeln(" typeParamStrings,");
13341335
// arguments
13351336
if params_no_signers.is_empty() {
13361337
w.writeln(" []");
13371338
} else {
13381339
w.writeln(" [");
1339-
for (pname, ptype) in params_no_signers.iter() {
1340-
w.writeln(format!(
1341-
" {},",
1342-
get_ts_handler_for_script_function_param(pname, ptype)?,
1343-
));
1340+
for (pname, _) in params_no_signers.iter() {
1341+
w.writeln(format!(" {},", pname,));
13441342
}
13451343
w.writeln(" ]");
13461344
}

src/gen_cli.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ pub fn generate_cli(ctx: &Context) -> Result<(String, String), Diagnostics> {
532532
let filename = "cli.ts".to_string();
533533
let content = format!(
534534
r###"
535-
import {{ AptosParserRepo, getTypeTagFullname, StructTag, parseTypeTagOrThrow, u8, u64, u128, print, strToU8, u8str, DummyCache, ActualStringClass }} from "@manahippo/move-to-ts";
535+
import {{ AptosParserRepo, getTypeTagFullname, StructTag, parseTypeTagOrThrow, u8, u64, u128, print, strToU8, u8str, DummyCache, ActualStringClass, sendPayloadTx }} from "@manahippo/move-to-ts";
536536
import {{ AptosAccount, AptosClient, HexString, Types }} from "aptos";
537537
import {{ Command }} from "commander";
538538
import {{ getProjectRepo }} from "./";
@@ -566,20 +566,6 @@ export const readConfig = (program: Command) => {{
566566
return {{client, account}};
567567
}}
568568
569-
export async function sendPayloadTx(
570-
client: AptosClient,
571-
account: AptosAccount,
572-
payload: Types.TransactionPayload,
573-
max_gas=1000
574-
){{
575-
const txnRequest = await client.generateTransaction(account.address(), payload, {{max_gas_amount: `${{max_gas}}`}});
576-
const signedTxn = await client.signTransaction(account, txnRequest);
577-
const txnResult = await client.submitTransaction(signedTxn);
578-
await client.waitForTransaction(txnResult.hash);
579-
const txDetails = (await client.getTransactionByHash(txnResult.hash)) as Types.UserTransaction;
580-
console.log(txDetails);
581-
}}
582-
583569
const program = new Command();
584570
585571
program

src/main.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub mod utils;
99

1010
use crate::gen_cli::generate_cli;
1111
use crate::gen_ui::{gen_public_html, generate_ui};
12-
use crate::shared::is_same_package;
12+
use crate::shared::{format_address_hex, is_same_package};
1313
use crate::utils::{generate_index, generate_topmost_index};
1414
use clap::Parser;
1515
use move_command_line_common::address::NumericalAddress;
@@ -72,14 +72,17 @@ fn build(path: &Path, config: &MoveToTsOptions) {
7272
.filter_map(|(name, package)| {
7373
if name == &root_package.source_package.package.name {
7474
None
75-
} else if name.to_string().contains("AptosExperimental") {
76-
// TODO: AptosExperimental needs to be dropped
77-
None
7875
} else {
79-
let paths = format!("{}/sources", package.package_path.to_string_lossy());
76+
let pkg_name = package.package_path.to_string_lossy();
77+
let mut paths = vec![format!("{}/sources", pkg_name)];
78+
if config.test {
79+
if package.package_path.join("tests").is_dir() {
80+
paths.push(format!("{}/tests", pkg_name))
81+
}
82+
}
8083
let path = PackagePaths {
8184
name: Some(*name),
82-
paths: vec![paths],
85+
paths,
8386
named_address_map: named_address_mapping.clone(),
8487
};
8588
Some(path)
@@ -143,6 +146,14 @@ fn build(path: &Path, config: &MoveToTsOptions) {
143146
};
144147
let mut ctx = Context::new(config, hlir_program.clone());
145148
for (mident, mdef) in hlir_program.modules.key_cloned_iter() {
149+
// skip problematic modules under aptos_framework::aggregator*
150+
let mod_name = mident.value.module.to_string();
151+
if format_address_hex(mident.value.address) == "0x1"
152+
&& (mod_name.contains("aggregator") || mod_name.contains("secp256k1"))
153+
{
154+
continue;
155+
}
156+
146157
// 2
147158
let result = ast_to_ts::translate_module(mident, mdef, &mut ctx);
148159

src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ pub fn generate_package_json(package_name: String, cli: bool, ui: bool) -> (Stri
6565
"typescript": "^4.6.4"
6666
}},
6767
"dependencies": {{
68-
"aptos": "^1.3.6",
68+
"aptos": "^1.3.7",
6969
"big-integer": "^1.6.51",{}
70-
"@manahippo/move-to-ts": "^0.1.20"
70+
"@manahippo/move-to-ts": "^0.1.24"
7171
}}
7272
}}
7373
"###,

typescript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@manahippo/move-to-ts",
3-
"version": "0.1.20",
3+
"version": "0.1.24",
44
"license": "MIT",
55
"scripts": {
66
"build": "rm -rf dist; tsc -p tsconfig.json",
@@ -26,7 +26,7 @@
2626
"typescript": "^4.6.4"
2727
},
2828
"dependencies": {
29-
"aptos": "^1.3.6",
29+
"aptos": "^1.3.7",
3030
"big-integer": "^1.6.51",
3131
"elliptic": "^6.5.4",
3232
"json-stable-stringify": "^1.0.1",

typescript/src/bcs.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,39 @@ export function serializeMoveValue(serializer: BCS.Serializer, v: any, tag: Type
8989
}
9090
}
9191

92+
export function serializeMoveValueWithoutTag(serializer: BCS.Serializer, value: any) {
93+
if (value instanceof U8) {
94+
serializeMoveValue(serializer, value, AtomicTypeTag.U8);
95+
}
96+
else if (value instanceof U64) {
97+
serializeMoveValue(serializer, value, AtomicTypeTag.U64);
98+
}
99+
else if (value instanceof U128) {
100+
serializeMoveValue(serializer, value, AtomicTypeTag.U128);
101+
}
102+
else if (typeof value === 'boolean') {
103+
serializeMoveValue(serializer, value, AtomicTypeTag.Bool);
104+
}
105+
else if (value instanceof HexString) {
106+
serializeMoveValue(serializer, value, AtomicTypeTag.Address);
107+
}
108+
// struct
109+
else if ((value as unknown as any).typeTag instanceof StructTag) {
110+
const tag = (value as unknown as any).typeTag as StructTag;
111+
serializeStruct(serializer, value, tag);
112+
}
113+
// vector
114+
else if (value instanceof Array) {
115+
serializer.serializeU32AsUleb128(value.length);
116+
for(const element of value) {
117+
serializeMoveValueWithoutTag(serializer, element);
118+
}
119+
}
120+
else {
121+
throw new Error(`Unrecognized value type: ${value}`);
122+
}
123+
}
124+
92125

93126
/*
94127
BCS deserialization of Move values

typescript/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export * from "./nativeFuncs";
55
export * from "./jsonTypes";
66
export * from "./parserRepo";
77
export * from "./txSender";
8-
export * from "./typeTag";
8+
export * from "./typeTag";
9+
export * from "./bcs";

typescript/src/nativeFuncs.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function aptos_std_event_write_to_event_store(guid: U8[], count: U64, msg
5353
// NOP
5454
}
5555

56-
export function std_hash_sip_hash(v: any, $c: AptosDataCache, _tags: TypeTag[]): U64 {
56+
export function aptos_std_aptos_hash_sip_hash(bytes: U8[], $c: AptosDataCache): U64 {
5757
throw new Error("Not implemented");
5858
}
5959

@@ -347,7 +347,6 @@ export class UpgradePolicy
347347

348348
}
349349

350-
351350
export function aptos_framework_code_request_publish(owner: HexString, expected_modules: ActualStringClass[], bundle: U8[][], policy: U8, $c: AptosDataCache) {
352351
throw new Error("Not Implemented");
353352
}
@@ -356,42 +355,54 @@ function u8ArrayToKeyString(u8array: U8[]): string {
356355
return u8array.map(u => u.value.toJSNumber().toString(16)).join();
357356
}
358357

359-
export function aptos_std_signature_ed25519_validate_pubkey(pubkey: U8[], $c: AptosDataCache): boolean {
358+
export function aptos_std_bls12381_aggregate_pubkeys_internal(pubkeys: any, $c: AptosDataCache): [U8[], boolean] {
360359
throw new Error("Not implemented");
361360
}
362361

363-
export function aptos_std_signature_bls12381_validate_pubkey(pubkey: U8[], $c: AptosDataCache): boolean {
362+
export function aptos_std_bls12381_aggregate_signatures_internal(signatures: any, $c: AptosDataCache): [U8[], boolean] {
364363
throw new Error("Not implemented");
365364
}
366365

367-
export function aptos_std_signature_bls12381_verify_signature(signature: U8[], public_key: U8[], mesage: U8[], $c: AptosDataCache): boolean {
366+
export function aptos_std_bls12381_validate_pubkey_internal(pubkey: U8[], $c: AptosDataCache): boolean {
368367
throw new Error("Not implemented");
369368
}
370369

371-
export function aptos_std_signature_bls12381_verify_proof_of_possession(public_key: U8[], proof_of_posession: U8[], $c: AptosDataCache): boolean {
370+
export function aptos_std_bls12381_signature_subgroup_check_internal(signature: any, $c: AptosDataCache): boolean {
372371
throw new Error("Not implemented");
373372
}
374373

375-
interface IOption {
376-
vec: any[];
377-
typeTag: TypeTag;
378-
loadFullState(app: AppType): Promise<void>;
379-
__app: AppType | null;
374+
export function aptos_std_bls12381_verify_aggregate_signature_internal(a: any, b: any, c: any, $c: AptosDataCache): boolean {
375+
throw new Error("Not implemented");
380376
}
381377

382-
export function aptos_std_signature_bls12381_aggregate_pop_verified_pubkeys(public_keys: U8[][], $c: AptosDataCache): IOption {
378+
export function aptos_std_bls12381_verify_multisignature_internal(a: any, b: any, c: any, $c: AptosDataCache): boolean {
383379
throw new Error("Not implemented");
384380
}
385381

382+
export function aptos_std_bls12381_verify_normal_signature_internal(signature: U8[], public_key: U8[], mesage: U8[], $c: AptosDataCache): boolean {
383+
throw new Error("Not implemented");
384+
}
385+
386+
export function aptos_std_bls12381_verify_proof_of_possession_internal(public_key: U8[], proof_of_posession: U8[], $c: AptosDataCache): boolean {
387+
throw new Error("Not implemented");
388+
}
389+
390+
export function aptos_std_bls12381_verify_signature_share_internal(a: any, b: any, c: any, $c: AptosDataCache): boolean {
391+
throw new Error("Not implemented");
392+
}
393+
394+
export function aptos_std_ed25519_public_key_validate_internal(pubkey: U8[], $c: AptosDataCache): boolean {
395+
throw new Error("Not implemented");
396+
}
386397

387-
export function aptos_std_signature_ed25519_verify(signature: U8[], pubkey: U8[], message: U8[], $c: AptosDataCache): boolean {
398+
export function aptos_std_ed25519_signature_verify_strict_internal(signature: U8[], pubkey: U8[], message: U8[], $c: AptosDataCache): boolean {
388399
const ec = new elliptic.eddsa("ed25519");
389400
const keyString = u8ArrayToKeyString(pubkey);
390401
const key = ec.keyFromPublic(keyString);
391402
return key.verify(u8ArrayToKeyString(message), u8ArrayToKeyString(signature));
392403
}
393404

394-
export function aptos_std_signature_secp256k1_ecdsa_recover(message: U8[], recovery_id: U8, signature: U8[], $c: AptosDataCache): [U8[], boolean] {
405+
export function aptos_std_secp256k1_ecdsa_recover(message: U8[], recovery_id: U8, signature: U8[], $c: AptosDataCache): [U8[], boolean] {
395406
throw new Error("Not implemented");
396407
}
397408

0 commit comments

Comments
 (0)