Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Deprecate create_multisig, proposal_multisig_message, create_pymtchan…
Browse files Browse the repository at this point in the history
…... etc (#689)
  • Loading branch information
rllola authored Aug 3, 2022
1 parent 4a6711d commit f448205
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 117 deletions.
8 changes: 4 additions & 4 deletions docs/rs_native_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ println!("{}", result);

```

## create_multisig
## [DEPRECATED] create_multisig

Utilitary function to create a create multisig message. Return an unsigned message.

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down
8 changes: 4 additions & 4 deletions docs/wasm_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ const result = signer_wasm.verifySignature(signatureRSV, cbor_transaction);
console.log(result);
```

## createMultisig
## [DEPRECATED] createMultisig

Return a create multisig transaction.

Expand All @@ -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.

Expand All @@ -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.

Expand Down Expand Up @@ -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.

Expand Down
106 changes: 0 additions & 106 deletions signer-npm/js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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') {
Expand Down
35 changes: 32 additions & 3 deletions signer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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<String>,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -792,6 +805,10 @@ pub fn serialize_params(params: MessageParams) -> Result<Vec<u8>, 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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f448205

Please sign in to comment.