crustio / crust-api

This project is used to provide Restful API for Crust chain
GNU General Public License v3.0
17 stars 10 forks source link

Not able to use Cross Chain Pinning #84

Open rakshit087 opened 2 years ago

rakshit087 commented 2 years ago

First of great work on Crust! I was trying to pin some files using Cross Chain dStorage Solution, I have already added files to crust ipfs and have the cid.

I am doing something like this on my front end

const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const publicAddress = await signer.getAddress();
const privateKey = await signer.signMessage(publicAddress);
const authHeaderRaw = `eth-${publicAddress}:${privateKey}`;
const authHeader = Buffer.from(authHeaderRaw).toString("base64");

and trying to pin file using

const res = await axios.post(`${ipfsPinningService}/pins`, {
      headers: {
        'Authorization': `Basic ${authHeader}`,
      },
      json: {
        cid: cid.toV0().toString(),
        name: "test",
      }
    })
    console.log(res);

However I keep on getting error 401, am I missing something??

ljuanto commented 1 week ago

On

ljuanto commented 1 week ago

curl --request POST 'http://localhost:56666/api/v1/swork/workreport' \ --header 'Content-Type: application/json' \ --header 'password: 123456' \ --data-raw '{"pub_key":"6956c19f8914bbe14c7fb8dd4fc776cd3382e94be25679b2b6bf4fb075eb27ebc1cadc76dff0c76fe72acd4e83af80f18f1a893e7d179e8d7630085c0aa9223e", "pre_pub_key":"", "block_height":"16200", "block_hash":"0000000000000000000000000000000000000000000000000000000000000000", "reserved":4294967296, "files_size":5242835, "reserved_root":"1ba223d1494bc0e14777a7e63c24484ecbe14ae2004cad45e5f690829c840fd1", "files_root":"f7d385d8397d6fbb413a0a1bdaeabab43cf1af131efff42b3c538deec7aedf36", "added_files":[ {"hash":"e2f4b2f31c309e18dbe658d92b81c26bede6015b8da1464b38def2af7d55faef","size":1048567,"c_block_num":16200}, {"hash":"e2f4b2f31c309e18dbe658d92b81c26bede6015b8da1464b38def2af7d55faef","size":1048567,"c_block_num":16200}, {"hash":"e2f4b2f31c309e18dbe658d92b81c26bede6015b8da1464b38def2af7d55faef","size":1048567,"c_block_num":16200}, {"hash":"e2f4b2f31c309e18dbe658d92b81c26bede6015b8da1464b38def2af7d55faef","size":1048567,"c_block_num":16200}, {"hash":"e2f4b2f31c309e18dbe658d92b81c26bede6015b8da1464b38def2af7d55faef","size":1048567,"c_block_num":16200}], "deleted_files":[], "sig":"adcb292e5fa95de65457653f910c43dc80140583c63da430d1afe72f83768197ab3f73b9e52fe12aa1a75d5e02c6649253a3617e31f6e852cb40641b4a574cf2",

"backup":   "{\"address\":\"5FqazaU79hjpEMiWTWZx81VjsYFst15eBuSBKdQLgQibD7CX\",\"encoded\":\"0xc81537c9442bd1d3f4985531293d88f6d2a960969a88b1cf8413e7c9ec1d5f4955adf91d2d687d8493b70ef457532d505b9cee7a3d2b726a554242b75fb9bec7d4beab74da4bf65260e1d6f7a6b44af4505bf35aaae4cf95b1059ba0f03f1d63c5b7c3ccbacd6bd80577de71f35d0c4976b6e43fe0e1583530e773dfab3ab46c92ce3fa2168673ba52678407a3ef619b5e14155706d43bd329a5e72d36\",\"encoding\":{\"content\":[\"pkcs8\",\"sr25519\"],\"type\":\"xsalsa20-poly1305\",\"version\":\"2\"},\"meta\":{\"name\":\"Yang1\",\"tags\":[],\"whenCreated\":1580628430860}}"
}'