From 60bf018b18467428fb599fb30461abc8d7fec2c8 Mon Sep 17 00:00:00 2001 From: janniks Date: Mon, 1 Jul 2024 20:59:40 +0200 Subject: [PATCH 1/2] feat: add non-sequential AddressHashMode for multi-sig --- index.ts | 4 +++ src/address/stacks_address.rs | 12 +++++-- src/stacks_tx/deserialize.rs | 8 +++++ tests/tx-decode-3.0.test.ts | 62 ++++++++++++++++++++++++++++++++++- 4 files changed, 83 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 42f9f76..699b61f 100644 --- a/index.ts +++ b/index.ts @@ -280,8 +280,12 @@ export enum TxSpendingConditionSingleSigHashMode { export enum TxSpendingConditionMultiSigHashMode { /** hash160(multisig-redeem-script), same as bitcoin's multisig p2sh */ P2SH = 0x01, + /** hash160(multisig-redeem-script), same as bitcoin's multisig p2sh (non-sequential signing) */ + P2SHNonSequential = 0x05, /** hash160(segwit-program-00(public-keys)), same as bitcoin's p2sh-p2wsh */ P2WSH = 0x03, + /** hash160(segwit-program-00(public-keys)), same as bitcoin's p2sh-p2wsh (non-sequential signing) */ + P2WSHNonSequential = 0x07, } export enum ClarityVersion { diff --git a/src/address/stacks_address.rs b/src/address/stacks_address.rs index 4bf817e..ffeb2e7 100644 --- a/src/address/stacks_address.rs +++ b/src/address/stacks_address.rs @@ -40,10 +40,12 @@ impl StacksAddress { pub enum AddressHashMode { // serialization modes for public keys to addresses. // We support four different modes due to legacy compatibility with Stacks v1 addresses: - SerializeP2PKH = 0x00, // hash160(public-key), same as bitcoin's p2pkh - SerializeP2SH = 0x01, // hash160(multisig-redeem-script), same as bitcoin's multisig p2sh + SerializeP2PKH = 0x00, // hash160(public-key), same as bitcoin's p2pkh + SerializeP2SH = 0x01, // hash160(multisig-redeem-script), same as bitcoin's multisig p2sh + SerializeP2SHNonSequential = 0x05, // hash160(multisig-redeem-script), same as bitcoin's multisig p2sh (non-sequential signing) SerializeP2WPKH = 0x02, // hash160(segwit-program-00(p2pkh)), same as bitcoin's p2sh-p2wpkh SerializeP2WSH = 0x03, // hash160(segwit-program-00(public-keys)), same as bitcoin's p2sh-p2wsh + SerializeP2WSHNonSequential = 0x07, // hash160(segwit-program-00(public-keys)), same as bitcoin's p2sh-p2wsh (non-sequential signing) } impl AddressHashMode { @@ -70,10 +72,16 @@ impl TryFrom for AddressHashMode { match value { x if x == AddressHashMode::SerializeP2PKH as u8 => Ok(AddressHashMode::SerializeP2PKH), x if x == AddressHashMode::SerializeP2SH as u8 => Ok(AddressHashMode::SerializeP2SH), + x if x == AddressHashMode::SerializeP2SHNonSequential as u8 => { + Ok(AddressHashMode::SerializeP2SHNonSequential) + } x if x == AddressHashMode::SerializeP2WPKH as u8 => { Ok(AddressHashMode::SerializeP2WPKH) } x if x == AddressHashMode::SerializeP2WSH as u8 => Ok(AddressHashMode::SerializeP2WSH), + x if x == AddressHashMode::SerializeP2WSHNonSequential as u8 => { + Ok(AddressHashMode::SerializeP2WSHNonSequential) + } _ => Err(format!("Invalid version {}", value)), } } diff --git a/src/stacks_tx/deserialize.rs b/src/stacks_tx/deserialize.rs index 0f302d6..acfdaf9 100644 --- a/src/stacks_tx/deserialize.rs +++ b/src/stacks_tx/deserialize.rs @@ -308,7 +308,13 @@ impl MultisigHashMode { pub fn from_u8(n: u8) -> Option { match n { x if x == MultisigHashMode::P2SH as u8 => Some(MultisigHashMode::P2SH), + x if x == MultisigHashMode::P2SHNonSequential as u8 => { + Some(MultisigHashMode::P2SHNonSequential) + } x if x == MultisigHashMode::P2WSH as u8 => Some(MultisigHashMode::P2WSH), + x if x == MultisigHashMode::P2WSHNonSequential as u8 => { + Some(MultisigHashMode::P2WSHNonSequential) + } _ => None, } } @@ -632,7 +638,9 @@ pub struct SinglesigSpendingCondition { #[derive(PartialEq, Copy, Clone)] pub enum MultisigHashMode { P2SH = 0x01, + P2SHNonSequential = 0x05, P2WSH = 0x03, + P2WSHNonSequential = 0x07, } #[repr(u8)] diff --git a/tests/tx-decode-3.0.test.ts b/tests/tx-decode-3.0.test.ts index 7cc10f2..d1cb7d5 100644 --- a/tests/tx-decode-3.0.test.ts +++ b/tests/tx-decode-3.0.test.ts @@ -6,9 +6,11 @@ import { PrincipalTypeID, TenureChangeCause, TransactionVersion, + TxAuthFieldTypeID, TxPayloadNakamotoCoinbase, TxPayloadTypeID, - TxPublicKeyEncoding + TxPublicKeyEncoding, + TxSpendingConditionMultiSigHashMode } from '../index.js'; test('stacks3.0 - decode tx - tenure change', () => { @@ -175,3 +177,61 @@ test('stacks3.0 - decode tx - nakamoto coinbase - no alt recipient (stacks-core expect(txType).toEqual(TxPayloadTypeID.NakamotoCoinbase); expect(payload.recipient).not.toBeNull(); }); + +test("stacks 3.0 - decode tx - non-sequential multi-sig", () => { + const tx = + "8080000000040535e2fdeee173024af6848ca6e335691b55498fc4000000000000000000000000000000640000000300028bd9dd96b66534e23cbcce4e69447b92bf1d738edb83182005cfb3b402666e42020158146dc95e76926e3add7289821e983e0dd2f2b0bf464c8e94bb082a213a91067ced1381a64bd03afa662992099b04d4c3f538cc6afa3d043ae081e25ebbde6f0300e30e7e744c6eef7c0a4d1a2dad6f0daa3c7655eb6e9fd6c34d1efa87b648d3e55cdd004ca4e8637cddad3316f3fbd6146665fad2e7ca26725ad09f58c4e43aa0000203020000000000051a70f696e2bda63701e044609eb7a7ce5876571905000000000000271000000000000000000000000000000000000000000000000000000000000000000000"; + const decoded = decodeTransaction(tx); + expect(decoded).toEqual({ + "tx_id": "0xf7f30ad912e9433743fb614b17842e8a366a04cc882e7fd94ff59fa9c2638674", + "version": TransactionVersion.Testnet, + "chain_id": 0x80000000, + "auth": { + "type_id": PostConditionAuthFlag.Standard, + "origin_condition": { + "tx_fee": "100", + "nonce": "0", + "fields": [ + { + "type_id": TxAuthFieldTypeID.PublicKeyCompressed, + "public_key": + "0x028bd9dd96b66534e23cbcce4e69447b92bf1d738edb83182005cfb3b402666e42", + }, + { + "type_id": TxAuthFieldTypeID.SignatureCompressed, + "signature": + "0x0158146dc95e76926e3add7289821e983e0dd2f2b0bf464c8e94bb082a213a91067ced1381a64bd03afa662992099b04d4c3f538cc6afa3d043ae081e25ebbde6f", + }, + { + "type_id": TxAuthFieldTypeID.SignatureUncompressed, + "signature": + "0x00e30e7e744c6eef7c0a4d1a2dad6f0daa3c7655eb6e9fd6c34d1efa87b648d3e55cdd004ca4e8637cddad3316f3fbd6146665fad2e7ca26725ad09f58c4e43aa0", + }, + ], + "hash_mode": TxSpendingConditionMultiSigHashMode.P2SHNonSequential, + "signatures_required": 2, + "signer": { + "address": "SNTY5ZFEW5SG4JQPGJ6ADRSND4DNAJCFRHVZBYR8", + "address_hash_bytes": "0x35e2fdeee173024af6848ca6e335691b55498fc4", + "address_version": 21, + }, + }, + }, + "anchor_mode": AnchorModeID.Any, + "post_condition_mode": PostConditionModeID.Deny, + "post_conditions": [], + "post_conditions_buffer": "0x0200000000", + "payload": { + "type_id": TxPayloadTypeID.TokenTransfer, + "amount": "10000", + "recipient": { + "type_id": PrincipalTypeID.Standard, + "address": "ST1RFD5Q2QPK3E0F08HG9XDX7SSC7CNRS0QR0SGEV", + "address_hash_bytes": "0x70f696e2bda63701e044609eb7a7ce5876571905", + "address_version": 26, + }, + "memo_hex": + "0x00000000000000000000000000000000000000000000000000000000000000000000", + }, + }); +}); From 84badb5e80f50a0e76f629d619e7d529254848c5 Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Tue, 2 Jul 2024 13:51:57 +0200 Subject: [PATCH 2/2] chore: dep updates (#19) * chore: dep updates * ci: speed up arm64-glibc test * Revert "ci: speed up arm64-glibc test" This reverts commit 644e817990aa0c531c3437ed54d5de7f63338c34. --- Cargo.lock | 186 +++++++++++++++++++----------- Cargo.toml | 2 +- package-lock.json | 14 +-- package.json | 2 +- src/clarity_value/mod.rs | 2 +- src/clarity_value/neon_encoder.rs | 2 +- src/neon_util.rs | 10 +- src/post_condition/mod.rs | 2 +- src/stacks_tx/neon_encoder.rs | 4 +- 9 files changed, 140 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1183207..1e187fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -399,7 +399,7 @@ dependencies = [ "proc-macro-hack", "proc-macro2", "quote", - "syn", + "syn 1.0.91", ] [[package]] @@ -513,12 +513,12 @@ checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" [[package]] name = "libloading" -version = "0.6.7" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" +checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if", - "winapi", + "windows-targets", ] [[package]] @@ -576,45 +576,29 @@ dependencies = [ [[package]] name = "neon" -version = "0.10.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "544694d02bbff81f78dba5ef7d29341cc6d256edcae4fbb2d684491d5755c748" +checksum = "7d75440242411c87dc39847b0e33e961ec1f10326a9d8ecf9c1ea64a3b3c13dc" dependencies = [ - "neon-build", + "libloading", "neon-macros", - "neon-runtime", - "semver 0.9.0", + "once_cell", + "semver", + "send_wrapper", "smallvec", ] -[[package]] -name = "neon-build" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd4ec682b1a7837c84d9866c342ac6ffe2ce9712e844e4015f31d01bdeb73608" - [[package]] name = "neon-macros" -version = "0.10.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "040746ef4e65edca7cd35597ad0ff7d8ad3b3f6018316d31a30b4afc23b0e548" +checksum = "c6813fde79b646e47e7ad75f480aa80ef76a5d9599e2717407961531169ee38b" dependencies = [ "quote", - "syn", + "syn 2.0.68", "syn-mid", ] -[[package]] -name = "neon-runtime" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4b1a7f8f569b4e43feff04931924cebe40a630fa258d2a28147525d247defe" -dependencies = [ - "cfg-if", - "libloading", - "smallvec", -] - [[package]] name = "nix" version = "0.24.1" @@ -672,9 +656,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.10.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -768,11 +752,11 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.37" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -786,9 +770,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.17" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -909,7 +893,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.7", + "semver", ] [[package]] @@ -935,24 +919,15 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" -version = "0.9.0" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] -name = "semver-parser" -version = "0.7.0" +name = "send_wrapper" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" @@ -978,7 +953,7 @@ checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.91", ] [[package]] @@ -1021,9 +996,9 @@ checksum = "df70fadc9b3167d59d7301bffe0eee7f0a353024d338e7d25d822c28450ae893" [[package]] name = "smallvec" -version = "1.8.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "stable_deref_trait" @@ -1090,15 +1065,26 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "syn" +version = "2.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn-mid" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9" +checksum = "b5dc35bb08dd1ca3dfb09dce91fd2d13294d6711c88897d9a9d60acf39bce049" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.68", ] [[package]] @@ -1141,7 +1127,7 @@ checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.91", ] [[package]] @@ -1160,6 +1146,12 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + [[package]] name = "unicode-segmentation" version = "1.9.0" @@ -1228,7 +1220,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn", + "syn 1.0.91", "wasm-bindgen-shared", ] @@ -1250,7 +1242,7 @@ checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.91", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1308,39 +1300,103 @@ version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5acdd78cb4ba54c0045ac14f62d8f94a03d10047904ae2a40afa1e99d8f70825" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.34.0", + "windows_i686_gnu 0.34.0", + "windows_i686_msvc 0.34.0", + "windows_x86_64_gnu 0.34.0", + "windows_x86_64_msvc 0.34.0", ] +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + [[package]] name = "windows_aarch64_msvc" version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + [[package]] name = "windows_i686_gnu" version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + [[package]] name = "windows_i686_msvc" version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + [[package]] name = "windows_x86_64_gnu" version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + [[package]] name = "windows_x86_64_msvc" version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/Cargo.toml b/Cargo.toml index 6776993..3c2ecbc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ sha2 = { version = "0.10", features = ["asm"] } sha2 = { version = "0.10" } [dependencies.neon] -version = "0.10.0" +version = "1.0.0" # git = "https://github.com/zone117x/neon" # rev = "bdb936a7fba8fb932fc61cbe529e06f65f75f9d9" default-features = false diff --git a/package-lock.json b/package-lock.json index 888b69e..f20981a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ }, "devDependencies": { "@types/jest": "^27.4.1", - "cargo-cp-artifact": "^0.1", + "cargo-cp-artifact": "^0.1.9", "jest": "^27.5.1", "ts-jest": "^27.1.4", "typescript": "^4.6.3" @@ -1348,9 +1348,9 @@ ] }, "node_modules/cargo-cp-artifact": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.6.tgz", - "integrity": "sha512-CQw0doK/aaF7j041666XzuilHxqMxaKkn+I5vmBsd8SAwS0cO5CqVEVp0xJwOKstyqWZ6WK4Ww3O6p26x/Goyg==", + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.9.tgz", + "integrity": "sha512-6F+UYzTaGB+awsTXg0uSJA1/b/B3DDJzpKVRu0UmyI7DmNeaAl2RFHuTGIN6fEgpadRxoXGb7gbC1xo4C3IdyA==", "dev": true, "bin": { "cargo-cp-artifact": "bin/cargo-cp-artifact.js" @@ -5143,9 +5143,9 @@ "dev": true }, "cargo-cp-artifact": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.6.tgz", - "integrity": "sha512-CQw0doK/aaF7j041666XzuilHxqMxaKkn+I5vmBsd8SAwS0cO5CqVEVp0xJwOKstyqWZ6WK4Ww3O6p26x/Goyg==", + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.9.tgz", + "integrity": "sha512-6F+UYzTaGB+awsTXg0uSJA1/b/B3DDJzpKVRu0UmyI7DmNeaAl2RFHuTGIN6fEgpadRxoXGb7gbC1xo4C3IdyA==", "dev": true }, "chalk": { diff --git a/package.json b/package.json index 4db54d1..4d7ec8e 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "devDependencies": { "@types/jest": "^27.4.1", - "cargo-cp-artifact": "^0.1", + "cargo-cp-artifact": "^0.1.9", "jest": "^27.5.1", "ts-jest": "^27.1.4", "typescript": "^4.6.3" diff --git a/src/clarity_value/mod.rs b/src/clarity_value/mod.rs index d99a1dd..526a47b 100644 --- a/src/clarity_value/mod.rs +++ b/src/clarity_value/mod.rs @@ -54,7 +54,7 @@ pub fn decode_clarity_value_array(mut cx: FunctionContext) -> JsResult 0 }; - let array_result = JsArray::new(&mut cx, result_length); + let array_result = JsArray::new(&mut cx, result_length as usize); let deep: bool = match cx.argument_opt(1) { Some(arg) => arg diff --git a/src/clarity_value/neon_encoder.rs b/src/clarity_value/neon_encoder.rs index bb32b7b..90c75fb 100644 --- a/src/clarity_value/neon_encoder.rs +++ b/src/clarity_value/neon_encoder.rs @@ -39,7 +39,7 @@ pub fn decode_clarity_val>( cur_obj.set(cx, "buffer", obj_buffer)?; } List(data) => { - let list_obj = JsArray::new(cx, data.len() as u32); + let list_obj = JsArray::new(cx, data.len()); for (i, x) in data.iter().enumerate() { let item_obj = cx.empty_object(); decode_clarity_val( diff --git a/src/neon_util.rs b/src/neon_util.rs index 1af73c3..b3ba108 100644 --- a/src/neon_util.rs +++ b/src/neon_util.rs @@ -25,7 +25,7 @@ pub fn eval<'a, 'b, C: Context<'a>>( #[allow(dead_code)] pub fn console_log<'a, C: Context<'a>, S: AsRef>(cx: &mut C, msg: S) -> NeonResult<()> { - let console_global: Handle = cx.global().get(cx, "console")?; + let console_global: Handle = cx.global::("console")?; let log_fn: Handle = console_global.get(cx, "log")?; log_fn .call_with(cx) @@ -36,7 +36,7 @@ pub fn console_log<'a, C: Context<'a>, S: AsRef>(cx: &mut C, msg: S) -> Neo #[allow(dead_code)] pub fn console_log_val(cx: &mut FunctionContext, msg: Handle) -> NeonResult<()> { - let console_global: Handle = cx.global().get(cx, "console")?; + let console_global: Handle = cx.global::("console")?; let log_fn: Handle = console_global.get(cx, "log")?; log_fn.call_with(cx).arg(msg).apply::(cx)?; Ok(()) @@ -47,14 +47,14 @@ pub fn json_parse<'a, C: Context<'a>, S: AsRef>( cx: &mut C, input: S, ) -> NeonResult> { - let json_global: Handle = cx.global().get(cx, "JSON")?; + let json_global: Handle = cx.global::("JSON")?; let json_parse: Handle = json_global.get(cx, "parse")?; let result: Handle = json_parse.call_with(cx).arg(cx.string(input)).apply(cx)?; Ok(result) } pub fn arg_as_bytes_copied(cx: &mut FunctionContext, arg_index: i32) -> NeonResult> { - let input_arg: Handle = cx.argument(arg_index)?; + let input_arg: Handle = cx.argument(arg_index as usize)?; if let Ok(handle) = input_arg.downcast::(cx) { let val_bytes = decode_hex(handle.value(cx)) .or_else(|e| cx.throw_error(format!("Hex parsing error: {}", e)))?; @@ -73,7 +73,7 @@ where F: Fn(&[u8]) -> Result, { let input_arg: Handle = cx - .argument(arg_index) + .argument(arg_index as usize) .or_else(|e| Err(format!("Error getting function arg {}: {}", arg_index, e)))?; if let Ok(handle) = input_arg.downcast::(cx) { let val_bytes = diff --git a/src/post_condition/mod.rs b/src/post_condition/mod.rs index 2672b88..b0873a7 100644 --- a/src/post_condition/mod.rs +++ b/src/post_condition/mod.rs @@ -26,7 +26,7 @@ pub fn decode_tx_post_conditions(mut cx: FunctionContext) -> JsResult e )) })?); - let array_result = JsArray::new(&mut cx, result_length); + let array_result = JsArray::new(&mut cx, result_length as usize); // next bytes are serialized post condition items let post_condition_bytes = &input_bytes[5..]; let post_condition_bytes_len = post_condition_bytes.len() as u64; diff --git a/src/stacks_tx/neon_encoder.rs b/src/stacks_tx/neon_encoder.rs index a916f20..6a95285 100644 --- a/src/stacks_tx/neon_encoder.rs +++ b/src/stacks_tx/neon_encoder.rs @@ -55,7 +55,7 @@ impl NeonJsSerialize for StacksTransaction { let post_condition_mode = cx.number(self.post_condition_mode as u8); obj.set(cx, "post_condition_mode", post_condition_mode)?; - let post_conditions = JsArray::new(cx, self.post_conditions.len() as u32); + let post_conditions = JsArray::new(cx, self.post_conditions.len()); for (i, x) in self.post_conditions.iter().enumerate() { let post_condition_obj = cx.empty_object(); x.neon_js_serialize(cx, &post_condition_obj)?; @@ -616,7 +616,7 @@ impl NeonJsSerialize for TransactionContractCall { obj.set(cx, "function_name", function_name)?; let mut function_args_raw = u32::to_be_bytes(self.function_args.len() as u32).to_vec(); - let function_args = JsArray::new(cx, self.function_args.len() as u32); + let function_args = JsArray::new(cx, self.function_args.len()); for (i, clarity_val) in self.function_args.iter().enumerate() { let val_obj = cx.empty_object(); function_args_raw.extend_from_slice(&clarity_val.serialized_bytes.as_ref().unwrap());