From f4482056935e08fa1b82ab7ae762da69f6ed433a Mon Sep 17 00:00:00 2001 From: sleepy ramen Date: Wed, 3 Aug 2022 14:58:58 +0200 Subject: [PATCH] Deprecate create_multisig, proposal_multisig_message, create_pymtchan... etc (#689) --- docs/rs_native_api.md | 8 +-- docs/wasm_api.md | 8 +-- signer-npm/js/src/index.js | 106 ------------------------------------- signer/src/lib.rs | 35 ++++++++++-- 4 files changed, 40 insertions(+), 117 deletions(-) diff --git a/docs/rs_native_api.md b/docs/rs_native_api.md index 3b2289e6..87e5bfe5 100644 --- a/docs/rs_native_api.md +++ b/docs/rs_native_api.md @@ -333,7 +333,7 @@ println!("{}", result); ``` -## create_multisig +## [DEPRECATED] create_multisig Utilitary function to create a create multisig message. Return an unsigned message. @@ -366,7 +366,7 @@ println!("{}", result); ``` -## proposal_multisig_message +## [DEPRECATED] proposal_multisig_message Utilitary function to create a proposal multisig message. Return an unsigned message. @@ -404,7 +404,7 @@ println!("{}", result); ``` -## approve_multisig_message +## [DEPRECATED] approve_multisig_message Utilitary function to create an approve multisig message. Return an unsigned message. @@ -436,7 +436,7 @@ println!("{}", result); ``` -## cancel_multisig_message +## [DEPRECATED] cancel_multisig_message Utilitary function to create a cancel multisig message. Return an unsigned message. diff --git a/docs/wasm_api.md b/docs/wasm_api.md index 8f316e51..f24f4e96 100644 --- a/docs/wasm_api.md +++ b/docs/wasm_api.md @@ -283,7 +283,7 @@ const result = signer_wasm.verifySignature(signatureRSV, cbor_transaction); console.log(result); ``` -## createMultisig +## [DEPRECATED] createMultisig Return a create multisig transaction. @@ -310,7 +310,7 @@ let create_multisig_transaction = filecoin_signer.createMultisig(sender_address, console.log(create_multisig_transaction); ``` -## proposeMultisig +## [DEPRECATED] proposeMultisig Return a proposal multisig transaction. @@ -336,7 +336,7 @@ let propose_multisig_transaction = filecoin_signer.proposeMultisig("t01", to_add console.log(propose_multisig_transaction); ``` -## approveMultisig +## [DEPRECATED] approveMultisig Return an approval multisig transaction. @@ -365,7 +365,7 @@ let approve_multisig_transaction = filecoin_signer.approveMultisig("t01", 1234, console.log(approve_multisig_transaction); ``` -## cancelMultisig +## [DEPRECATED] cancelMultisig Return a cancel multisig transaction. diff --git a/signer-npm/js/src/index.js b/signer-npm/js/src/index.js index c83cb6eb..45d4aa28 100644 --- a/signer-npm/js/src/index.js +++ b/signer-npm/js/src/index.js @@ -3,7 +3,6 @@ const bip32 = require('bip32') const cbor = require('@ipld/dag-cbor') const secp256k1 = require('secp256k1') const BN = require('bn.js') -const { MethodInit, MethodPaych } = require('./methods') const ExtendedKey = require('./extendedkey') const { getDigest, getCoinTypeFromPath, addressAsBytes, bytesToAddress, tryToPrivateKeyBuffer } = require('./utils') @@ -197,111 +196,6 @@ function verifySignature(signature, message) { return secp256k1.ecdsaVerify(signature.slice(0, -1), messageDigest, publicKey) } -// eslint-disable-next-line no-unused-vars -function createPymtChan(from, to, amount, nonce) { - if (typeof from !== 'string') { - throw new Error('`From` address has to be a string.') - } - if (typeof to !== 'string') { - throw new Error('`To` address has to be a string.') - } - if (typeof amount !== 'string') { - throw new Error('`Value` address has to be a string.') - } - let constructorParams = [to, from] - let serializedConstructorParams = cbor.encode(constructorParams) - - let execParams = [ - { - 42: Buffer.from('000155001466696C2F312F7061796D656E746368616E6E656C', 'hex'), - }, - serializedConstructorParams, - ] - let serializedParams = cbor.encode(execParams) - let message = { - From: from, - To: 't01', - Nonce: nonce, - Value: new BN(amount).toString(10), - GasPrice: new BN('100').toString(10), - GasLimit: 200000000, - Method: MethodInit.Exec, - Params: serializedParams.toString('base64'), - } - - return message -} - -// eslint-disable-next-line no-unused-vars -function settlePymtChan(pch, from, nonce) { - if (typeof pch !== 'string') { - throw new Error('`pch` address has to be a string.') - } - if (typeof from !== 'string') { - throw new Error('`from` address has to be a string.') - } - let message = { - From: from, - To: pch, - Nonce: nonce, - Value: new BN('0'.toString('hex'), 16).toString(10), - GasPrice: new BN('100'.toString('hex'), 16).toString(10), - GasLimit: 200000000, - Method: MethodPaych.Settle, - Params: '', - } - return message -} - -// eslint-disable-next-line no-unused-vars -function collectPymtChan(pch, from, nonce) { - if (typeof pch !== 'string') { - throw new Error('`pch` address has to be a string.') - } - if (typeof from !== 'string') { - throw new Error('`from` address has to be a string.') - } - let message = { - From: from, - To: pch, - Nonce: nonce, - Value: new BN('0'.toString('hex'), 16).toString(10), - GasPrice: new BN('100'.toString('hex'), 16).toString(10), - GasLimit: 200000000, - Method: MethodPaych.Collect, - Params: '', - } - return message -} - -// eslint-disable-next-line no-unused-vars -function updatePymtChan(pch, from, signedVoucherBase64, nonce) { - if (typeof pch !== 'string') { - throw new Error('`pch` address has to be a string.') - } - if (typeof from !== 'string') { - throw new Error('`from` address has to be a string.') - } - if (typeof signedVoucherBase64 !== 'string') { - throw new Error('`signedVoucher` has to be a base64 string.') - } - let cborSignedVoucher = Buffer.from(signedVoucherBase64, 'base64') - let signedVoucher = cbor.decode(cborSignedVoucher) - let updateChannelStateParams = [signedVoucher, Buffer.alloc(0), Buffer.alloc(0)] - let serializedParams = cbor.encode(updateChannelStateParams) - let message = { - From: from, - To: pch, - Nonce: nonce, - Value: new BN('0'.toString('hex'), 16).toString(10), - GasPrice: new BN('100'.toString('hex'), 16).toString(10), - GasLimit: 200000000, - Method: MethodPaych.UpdateChannelState, - Params: serializedParams.toSTring('base64'), - } - return message -} - // eslint-disable-next-line no-unused-vars function signVoucher(unsignedVoucherBase64, privateKey) { if (typeof unsignedVoucherBase64 !== 'string') { diff --git a/signer/src/lib.rs b/signer/src/lib.rs index b6caa889..8b27c9cb 100644 --- a/signer/src/lib.rs +++ b/signer/src/lib.rs @@ -13,7 +13,6 @@ use num_traits::FromPrimitive; use rayon::prelude::*; use zx_bip44::BIP44Path; -use cid::multihash::Multihash; use cid::Cid; use fil_actor_init::{ExecParams, Method as MethodInit}; use fil_actor_multisig as multisig; @@ -40,8 +39,6 @@ pub mod extended_key; pub mod multisig_deprecated; pub mod utils; -const RAW: u64 = 0x55; - lazy_static! { static ref OLD_CODE_CID_INIT: Regex = Regex::new(r"fil/[0-7]/init").unwrap(); static ref OLD_CODE_CID_MULTISIG: Regex = Regex::new(r"fil/[2-7]/multisig").unwrap(); @@ -511,6 +508,10 @@ pub fn verify_aggregated_signature( /// * `duration` - Duration of the multisig /// #[allow(clippy::too_many_arguments)] +#[deprecated( + since = "1.1.0", + note = "use `serialize_params` instead and then create transaction" +)] pub fn create_multisig( sender_address: String, addresses: Vec, @@ -602,6 +603,10 @@ pub fn create_multisig( /// * `proposal_serialized_params` - The proposal parameters serialized /// #[allow(clippy::too_many_arguments)] +#[deprecated( + since = "1.1.0", + note = "use `serialize_params` instead and then create transaction" +)] pub fn proposal_multisig_message( multisig_address: String, to_address: String, @@ -704,6 +709,10 @@ fn approve_or_cancel_multisig_message( /// * `nonce` - Nonce of the message /// #[allow(clippy::too_many_arguments)] +#[deprecated( + since = "1.1.0", + note = "use `serialize_params` instead and then create transaction" +)] pub fn approve_multisig_message( multisig_address: String, message_id: i64, @@ -744,6 +753,10 @@ pub fn approve_multisig_message( /// * `nonce` - Nonce of the message /// #[allow(clippy::too_many_arguments)] +#[deprecated( + since = "1.1.0", + note = "use `serialize_params` instead and then create transaction" +)] pub fn cancel_multisig_message( multisig_address: String, message_id: i64, @@ -792,6 +805,10 @@ pub fn serialize_params(params: MessageParams) -> Result, SignerError> { /// * `value` - Amount to put in the payment channel initially /// * `nonce` - Nonce of the message; should be from_address's MpoolGetNonce() value /// +#[deprecated( + since = "1.1.0", + note = "use `serialize_params` instead and then create transaction" +)] pub fn create_pymtchan( from_address: String, to_address: String, @@ -851,6 +868,10 @@ pub fn create_pymtchan( /// * `signed_voucher` - A SignedVoucher to be associated with the payment channel /// * `nonce` - Nonce of the message; should be from_address's MpoolGetNonce() value /// +#[deprecated( + since = "1.1.0", + note = "use `serialize_params` instead and then create transaction" +)] pub fn update_pymtchan( pch_address: String, from_address: String, @@ -894,6 +915,10 @@ pub fn update_pymtchan( /// * `from_address` - A string address /// * `nonce` - Nonce of the message; should be from_address's MpoolGetNonce() value /// +#[deprecated( + since = "1.1.0", + note = "use `serialize_params` instead and then create transaction" +)] pub fn settle_pymtchan( pch_address: String, from_address: String, @@ -927,6 +952,10 @@ pub fn settle_pymtchan( /// * `from_address` - A string address /// * `nonce` - Nonce of the message; should be from_address's MpoolGetNonce() value /// +#[deprecated( + since = "1.1.0", + note = "use `serialize_params` instead and then create transaction" +)] pub fn collect_pymtchan( pch_address: String, from_address: String,