diff --git a/package.json b/package.json index 2ee41b2..7a73e26 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@keyko-io/filecoin-verifier-tools", - "version": "2.2.2", + "version": "2.2.3", "description": "Javascript implementation of a HAMT using ipld", "main": "lib/index.js", "repository": { diff --git a/src/api/api.ts b/src/api/api.ts index e7dabc6..c188504 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -8,6 +8,7 @@ import { decode } from 'cbor' const cacheAddress = {} const cacheKey = {} +const SignatureDomainSeparation_RemoveDataCap = "fil_removedatacap:" export class VerifyAPI { constructor(lotusClient, walletContext, testnet = true) { @@ -67,17 +68,28 @@ export class VerifyAPI { return res['/'] } - encodeRemoveDataCapParameters(message: [address: string, datacap: string, id: number[]]) { - return this.methods.encode(this.methods.RemoveDataCapProposal,message) + // encodeRemoveDataCapParameters_old(message: [address: string, datacap: string, id: number[]]) { + // return this.methods.encode( + // this.methods.RemoveDataCapProposal, message + // ) + // } + + encodeRemoveDataCapParameters(message: {verifiedClient: string, dataCapAmount: string, removalProposalID: number[]}) { + const orderedProposalParams = [SignatureDomainSeparation_RemoveDataCap, message.verifiedClient, message.dataCapAmount, message.removalProposalID] + return this.methods.encode(this.methods.RemoveDataCapProposal, orderedProposalParams) } - async proposeRemoveDataCap(clientToRemoveDcFrom, datacap, verifier1, signature1, verifier2, signature2, indexAccount, wallet, { gas } = { gas: 0 }) { - const removeDatacapProposal = this.methods.verifreg.removeVerifiedClientDataCap( + async proposeRemoveDataCap( + clientToRemoveDcFrom, datacap, + verifier1, signature1, verifier2, signature2, + indexAccount, wallet, { gas } = { gas: 0 }) { + + const removeDatacapRequest = this.methods.verifreg.removeVerifiedClientDataCap( clientToRemoveDcFrom, datacap, { verifier: verifier1, signature: signature1 }, { verifier: verifier2, signature: signature2 }, ) - const tx = this.methods.rootkey.propose(removeDatacapProposal) + const tx = this.methods.rootkey.propose(removeDatacapRequest) const res = await this.methods.sendTx(this.client, indexAccount, this.checkWallet(wallet), { ...tx, gas }) return res['/'] } diff --git a/src/filecoin/methods.ts b/src/filecoin/methods.ts index 8e234d6..69c885b 100644 --- a/src/filecoin/methods.ts +++ b/src/filecoin/methods.ts @@ -4,9 +4,7 @@ import cbor from "cbor"; import * as hamt from "../hamt/hamt-2"; import blake from "blakejs"; import * as address from "@glif/filecoin-address"; -// const { CID } = require("multiformats/cid"); import { CID } from "multiformats/cid"; -import multihashes from "multihashes"; import { identity } from "multiformats/hashes/identity"; import * as rawFormat from "multiformats/codecs/raw"; @@ -731,11 +729,18 @@ function make(testnet) { const REMOVE_DATACAP_PROPOSAL = [ "cbor", - { - verifiedClient: 'address', - datacapAmount: 'bigint', - removalProposalID: ["list", "int"] - }, + [ + 'string', // sigDomainSeparationString + 'address', // verifiedClient + 'bigint', // dataCapAmount + ["list", "int"] // removalProposalID + ] + // { + // sigDomainSeparationString: 'string', + // verifiedClient: 'address', + // dataCapAmount: 'bigint', + // removalProposalID: ["list", "int"] + // } ]; const reg = { diff --git a/src/samples/api/encodeRemoveParams.js b/src/samples/api/encodeRemoveParams.js index 8efed9a..0a62f14 100644 --- a/src/samples/api/encodeRemoveParams.js +++ b/src/samples/api/encodeRemoveParams.js @@ -17,15 +17,13 @@ const api = new VerifyAPI.VerifyAPI(VerifyAPI.VerifyAPI.standAloneProvider(endpo async function removeDatacap() { try { - - const encoded = api.encodeRemoveDataCapParameters(["t01004",158856254,[1256]]) + const encoded = api.encodeRemoveDataCapParameters(['t01004', 158856254, [1256]]) console.log(encoded) console.log(encoded.toString('hex')) // console.log('encoded:', encoded[0].toString('hex'), encoded[1].toString('hex'), encoded[2].toString('hex')) - //datacap 000977f43e ok!!! - //address 00ec07 - //id 0004e8 - + // datacap 000977f43e ok!!! + // address 00ec07 + // id 0004e8 console.log('834300ec0745000977f43e811904e8') console.log(encoded.toString('hex') === '834300ec0745000977f43e811904e8')