From 4a910ab89566611305582672be287c1362a03ddc Mon Sep 17 00:00:00 2001 From: Mauro Piazza Date: Thu, 31 Oct 2024 18:54:58 +0100 Subject: [PATCH] chore: wip --- cpp/contracts/adapter.cpp | 3 +- cpp/contracts/pam.hpp | 19 +- cpp/package.json | 1 + cpp/test/adapter-local.test.js | 118 +++++++------ cpp/test/pam.test.js | 230 +++++++++++++++++++++++-- cpp/test/utils/errors.js | 20 +++ cpp/test/utils/get-metadata-sample.js | 10 +- cpp/test/utils/get-operation-sample.js | 2 +- cpp/test/utils/hex-to-pubkey.js | 3 +- yarn.lock | 1 + 10 files changed, 324 insertions(+), 83 deletions(-) diff --git a/cpp/contracts/adapter.cpp b/cpp/contracts/adapter.cpp index 1cf7fbf5..056875b6 100644 --- a/cpp/contracts/adapter.cpp +++ b/cpp/contracts/adapter.cpp @@ -200,8 +200,7 @@ void adapter::settle(const name& caller, const operation& operation, const metad auto search_token_bytes = idx_registry.find(operation.token); check(search_token_bytes != idx_registry.end(), "invalid token"); - checksum256 event_id = sha256((const char*)metadata.preimage.data(), metadata.preimage.size()); - + checksum256 event_id; // output pam::check_authorization(get_self(), operation, metadata, event_id); past_events _past_events(get_self(), get_self().value); diff --git a/cpp/contracts/pam.hpp b/cpp/contracts/pam.hpp index 0ed545b0..1d9f93e3 100644 --- a/cpp/contracts/pam.hpp +++ b/cpp/contracts/pam.hpp @@ -1,11 +1,11 @@ #pragma once -#include "metadata.hpp" -#include "operation.hpp" #include #include #include "utils.hpp" +#include "metadata.hpp" +#include "operation.hpp" namespace eosio { using bytes = std::vector; @@ -64,7 +64,7 @@ namespace eosio { return true; } - void check_authorization(name adapter, const operation& operation, const metadata& metadata, checksum256 event_id) { + void check_authorization(name adapter, const operation& operation, const metadata& metadata, checksum256& event_id) { check(context_checks(operation, metadata), "unexpected context"); tee_pubkey _tee_pubkey(adapter, adapter.value); @@ -78,6 +78,9 @@ namespace eosio { bytes exp_emitter = itr_mappings->emitter; bytes exp_topic_zero = itr_mappings->topic_zero; + event_id = sha256((const char*)metadata.preimage.data(), metadata.preimage.size()); + + signature sig = convert_bytes_to_signature(metadata.signature); public_key recovered_pubkey = recover_key(event_id, sig); check(recovered_pubkey == tee_key, "invalid signature"); @@ -85,11 +88,11 @@ namespace eosio { offset = 0; bytes event_payload(metadata.preimage.begin() + 98, metadata.preimage.end()); bytes emitter = extract_32bytes(event_payload, offset); - check(emitter == exp_emitter && !is_all_zeros(emitter), "unexpected Emitter"); + check(emitter == exp_emitter && !is_all_zeros(emitter), "unexpected emitter"); offset += 32; bytes topic_zero = extract_32bytes(event_payload, offset); - check(topic_zero == exp_topic_zero && !is_all_zeros(topic_zero), "unexpected topic Zero"); + check(topic_zero == exp_topic_zero && !is_all_zeros(topic_zero), "unexpected topic zero"); offset += 32 * 3; // skip other topics // check nonce @@ -101,12 +104,16 @@ namespace eosio { // check origin token bytes token = extract_32bytes(event_data, offset); + print("\ntoken\n"); + printhex(token.data(), token.size()); checksum256 token_hash = bytes32_to_checksum256(token); - check(operation.token == token_hash, "token adddress do not match"); + check(operation.token == token_hash, "token address do not match"); offset += 32; // check destination chain id bytes dest_chain_id = extract_32bytes(event_data, offset); + print("\ndest_chain_id\n"); + printhex(dest_chain_id.data(), dest_chain_id.size()); check(operation.destinationChainId == dest_chain_id, "destination chain id does not match with the expected one"); check(CHAIN_ID == dest_chain_id, "destination chain id does not match with the current chain"); offset += 32; diff --git a/cpp/package.json b/cpp/package.json index 33054072..94ad6797 100644 --- a/cpp/package.json +++ b/cpp/package.json @@ -14,6 +14,7 @@ }, "devDependencies": { "@eosnetwork/vert": "^1.0.0", + "@pnetwork/event-attestator": "workspace:^", "@types/ramda": "^0", "@wharfkit/antelope": "^1.0.12", "chai": "^4.3.10", diff --git a/cpp/test/adapter-local.test.js b/cpp/test/adapter-local.test.js index 70687384..d00de274 100644 --- a/cpp/test/adapter-local.test.js +++ b/cpp/test/adapter-local.test.js @@ -1,7 +1,6 @@ const { expect } = require('chai') -const { Blockchain, expectToThrow, mintTokens } = require('@eosnetwork/vert') +const { Blockchain, expectToThrow } = require('@eosnetwork/vert') const { deploy } = require('./utils/deploy') -const { Asset, Bytes, PublicKey } = require('@wharfkit/antelope') const R = require('ramda') const { active, @@ -9,17 +8,18 @@ const { getAccountCodeRaw, getSymbolCodeRaw, getSingletonInstance, - logExecutionTraces, prettyTrace, } = require('./utils/eos-ext') -const { getXbytesHex, hexToString, removeNullChars } = require('./utils/bytes-utils') +const { + getXbytesHex, + hexToString, + removeNullChars, +} = require('./utils/bytes-utils') const { getEventBytes } = require('./utils/get-event-bytes') -const { substract, no0x } = require('./utils/wharfkit-ext') +const { substract } = require('./utils/wharfkit-ext') const { getAccountsBalances } = require('./utils/get-token-balance') -const { getMetadataSample } = require('./utils/get-metadata-sample') -const { getOperationSample } = require('./utils/get-operation-sample') const errors = require('./utils/errors') - +const { no0x } = require('./utils') const ethers = require('ethers') const getSwapMemo = (sender, destinationChainId, recipient, data) => @@ -230,7 +230,7 @@ describe('Adapter EOS -> ETH testing', () => { await token.contract.actions .transfer([user, adapter.account, quantity, memo]) .send(active(user)) - + const after = getAccountsBalances( [user, lockbox.account, adapter.account, feemanager], [token, xerc20], @@ -286,7 +286,7 @@ describe('Adapter EOS -> ETH testing', () => { const eventBytes = getEventBytes(adapter.contract) const expectedEventBytes = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746b6e2e746f6b656e00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000008a88f6dc465640000000000000000000000000000000000000000000000000000000000075736572000000000000000000000000000000000000000000000000000000000000002a307836386262656436613437313934656666316366353134623530656139313839353539376663393165' - expect(eventBytes).to.be.equal(expectedEventBytes) + expect(eventBytes).to.be.equal(expectedEventBytes) offset = 0 const nonce = getXbytesHex(eventBytes, offset, 32) @@ -301,11 +301,15 @@ describe('Adapter EOS -> ETH testing', () => { offset += 32 const recipientLen = getXbytesHex(eventBytes, offset, 32) offset += 32 - const swapRecipient = getXbytesHex(eventBytes, offset, parseInt(recipientLen, 16)) + const swapRecipient = getXbytesHex( + eventBytes, + offset, + parseInt(recipientLen, 16), + ) offset += parseInt(recipientLen, 16) const userData = eventBytes.slice(offset * 2, eventBytes.length) - const expectedAmount = (parseInt(amount) - intFees) * (10 ** 18) + const expectedAmount = (parseInt(amount) - intFees) * 10 ** 18 expect(parseInt(nonce)).to.be.equal(before.storage.nonce) expect(removeNullChars(hexToString(swapToken))).to.be.equal(token.account) expect(destChainId).to.be.equal(destinationChainId.slice(2)) @@ -344,15 +348,15 @@ describe('Adapter EOS -> ETH testing', () => { // 'hex', // ), // ) - // const pubKey = PublicKey.from({ type: 'K1', compressed }) + // const pubKey = PublicKey.from({ type: 'K1', compressed }) // await adapter.contract.actions // .settee([pubKey, attestation]) // .send(active(adapter.account)) - - // const normalizedOriginChainId = hexStringToBytes('0000000000000000000000000000000000000000000000000000000000000001') + + // const normalizedOriginChainId = hexStringToBytes('0000000000000000000000000000000000000000000000000000000000000001') // const normalizedOriginAdapter = hexStringToBytes('000000000000000000000000cc9676b9bf25ce45a3a5f88205239afddecf1bc7') // const normalizeTopicZero = hexStringToBytes('9b706941b48091a1c675b439064f40b9d43c577d9c7134cce93179b9b0bf2a52') - + // await adapter.contract.actions // .setemitter([normalizedOriginChainId, normalizedOriginAdapter]) // .send(active(adapter.account)) @@ -407,46 +411,46 @@ describe('Adapter EOS -> ETH testing', () => { // ) // }) - // it('Should send userdata to a receiver contract', async () => { - // const quantity = `1.0000 ${token.symbol}` - // const normalizedAmount = ethers - // .parseUnits(Asset.from(quantity).units.toString(), 18) - // .toString() - - // const metadata = getMetadataSample() - // const operation = getOperationSample({ - // amount: normalizedAmount, - // data: 'c0ffeec0ffeec0ffee', - // recipient: receiver.account, - // }) - - // const before = getAccountsBalances([receiver.account], [token, xerc20]) - - // // Fill in some tokens as collateral - // await token.contract.actions - // .transfer([user, lockbox.account, quantity, '']) - // .send(active(user)) - - // await adapter.contract.actions - // .settle([user, operation, metadata]) - // .send(active(user)) - - // const after = getAccountsBalances([receiver.account], [token, xerc20]) - // const receiverResults = receiver.contract.tables - // .results(getAccountCodeRaw(receiver.account)) - // .getTableRow(0n) - - // expect( - // substract( - // after[receiver.account][token.symbol], - // before[receiver.account][token.symbol], - // ).toString(), - // ).to.be.equal(quantity) - - // expect(receiverResults).to.be.deep.equal({ - // id: 0, - // data: operation.data, - // }) - // }) + // it('Should send userdata to a receiver contract', async () => { + // const quantity = `1.0000 ${token.symbol}` + // const normalizedAmount = ethers + // .parseUnits(Asset.from(quantity).units.toString(), 18) + // .toString() + + // const metadata = getMetadataSample() + // const operation = getOperationSample({ + // amount: normalizedAmount, + // data: 'c0ffeec0ffeec0ffee', + // recipient: receiver.account, + // }) + + // const before = getAccountsBalances([receiver.account], [token, xerc20]) + + // // Fill in some tokens as collateral + // await token.contract.actions + // .transfer([user, lockbox.account, quantity, '']) + // .send(active(user)) + + // await adapter.contract.actions + // .settle([user, operation, metadata]) + // .send(active(user)) + + // const after = getAccountsBalances([receiver.account], [token, xerc20]) + // const receiverResults = receiver.contract.tables + // .results(getAccountCodeRaw(receiver.account)) + // .getTableRow(0n) + + // expect( + // substract( + // after[receiver.account][token.symbol], + // before[receiver.account][token.symbol], + // ).toString(), + // ).to.be.equal(quantity) + + // expect(receiverResults).to.be.deep.equal({ + // id: 0, + // data: operation.data, + // }) + // }) // }) }) diff --git a/cpp/test/pam.test.js b/cpp/test/pam.test.js index b6366b71..f8f2fab4 100644 --- a/cpp/test/pam.test.js +++ b/cpp/test/pam.test.js @@ -1,24 +1,230 @@ -const { deploy } = require('./utils/deploy') const { Blockchain, expectToThrow } = require('@eosnetwork/vert') -const { getMetadataSample } = require('./utils/get-metadata-sample') -const { getOperationSample } = require('./utils/get-operation-sample') -const { active } = require('./utils/eos-ext') +const ethers = require('ethers') +const { + Chains, + ProofcastEventAttestator, + Protocols, + Versions, +} = require('@pnetwork/event-attestator') +const { expect } = require('chai') +const { zeroPadValue } = require('ethers') + +const { + deploy, + errors, + getMetadataSample, + getOperationSample, + hexStringToBytes, + hexToPublicKey, + no0x, +} = require('./utils') +const { active, getSingletonInstance } = require('./utils/eos-ext') describe('PAM testing', () => { - let pam const user = 'user' - const name = 'pam' + + const pam = { + account: 'pam', + contract: null, + } + + const adapter = { + account: 'adapter', + contract: null, + } + + const privateKey = + 'dfcc79a57e91c42d7eea05f82a08bd1b7e77f30236bb7c56fe98d3366a1929c4' + + const ea = new ProofcastEventAttestator({ + version: Versions.V1, + protocolId: Protocols.Evm, + chainId: Chains(Protocols.Evm).Mainnet, + privateKey, + }) + + const publicKey = hexToPublicKey(ea.signingKey.compressedPublicKey) + + const evmEmitter = hexStringToBytes( + zeroPadValue('0x5623D0aF4bfb6F7B18d6618C166d518E4357ceE2', 32), + ) + const evmTopic0 = hexStringToBytes( + '0x66756e6473206172652073616675207361667520736166752073616675202e2e', + ) + + const attestation = [] const blockchain = new Blockchain() + const operation = getOperationSample() + const data = + '0x000000000000000000000000f2e246bb76df876cef8b38ae84130f4f55de395b0000000000000000000000000000000000000000000000000000000000007a6900000000000000000000000000000000000000000000000000000000000013800000000000000000000000006813eb9362372eef6200f3b1dbc3f819671cba69000000000000000000000000000000000000000000000000000000000000002a307836383133456239333632333732454546363230306633623164624333663831393637316342413639' + const event = { + blockHash: operation.blockId, + transactionHash: operation.txId, + address: evmEmitter, + topics: [evmTopic0, ethers.zeroPadValue('0x', 32)], + data, + } + + const signature = no0x(ea.formatEosSignature(ea.sign(event))) + const preimage = no0x(ea.getEventPreImage(event)) + const metadata = getMetadataSample({ signature, preimage }) + before(async () => { blockchain.createAccounts(user) - // pam = deploy(blockchain, name, 'contracts/build/test.pam') + pam.contract = deploy(blockchain, pam.account, 'contracts/build/test.pam') + adapter.contract = deploy( + blockchain, + adapter.account, + 'contracts/build/adapter', + ) }) - describe('pam::isauthorized', () => { - it('Should authorize the operation successfully', async () => { - const operation = getOperationSample() - const metadata = getMetadataSample() - // await pam.actions.isauthorized([operation, metadata]).send(active(user)) + describe('pam::check_authorization', () => { + it('Should set the adapter contract', async () => { + await pam.contract.actions + .setadapter([adapter.account]) + .send(active(pam.account)) + + expect(getSingletonInstance(pam.contract, 'adapter')).to.be.equal( + adapter.account, + ) + }) + + it('Should reject when the public key is not set', async () => { + const action = pam.contract.actions + .isauthorized([operation, metadata]) + .send(active(user)) + + await expectToThrow(action, errors.SINGLETON_NOT_EXISTING) + }) + + it('Should reject when the origin_chain_id is not set', async () => { + const anotherEventAttestator = new ProofcastEventAttestator() + const anotherPublicKey = hexToPublicKey( + anotherEventAttestator.signingKey.compressedPublicKey, + ) + await adapter.contract.actions + .settee([anotherPublicKey, attestation]) + .send(active(adapter.account)) + + const action = pam.contract.actions + .isauthorized([operation, metadata]) + .send(active(user)) + + await expectToThrow(action, errors.ORIGIN_CHAINID_NOT_REGISTERED) + }) + + it('Should reject if the signature is invalid', async () => { + // We will correct these later + const wrongEmitter = no0x(zeroPadValue('0x010203', 32)) + const wrongTopic0 = no0x(zeroPadValue('0x010203', 32)) + await adapter.contract.actions + .setorigin([operation.originChainId, wrongEmitter, wrongTopic0]) + .send(active(adapter.account)) + + // TODO: change private key and re-enable + const action = pam.contract.actions + .isauthorized([operation, metadata]) + .send(active(user)) + + await expectToThrow(action, errors.INVALID_SIGNATURE) + }) + + it('Should reject if the emitter is different', async () => { + // Should set the correct key that have signed the event + await adapter.contract.actions + .settee([publicKey, attestation]) + .send(active(adapter.account)) + + const action = pam.contract.actions + .isauthorized([operation, metadata]) + .send(active(user)) + + await expectToThrow(action, errors.UNEXPECTED_EMITTER) + }) + + it('Should reject if the topic zero is different', async () => { + // Should set the correct emitter + + const wrongTopic0 = no0x(zeroPadValue('0x010203', 32)) + + await adapter.contract.actions + .setorigin([operation.originChainId, evmEmitter, wrongTopic0]) + .send(active(adapter.account)) + + const action = pam.contract.actions + .isauthorized([operation, metadata]) + .send(active(user)) + + await expectToThrow(action, errors.UNEXPECTED_TOPIC_ZERO) + + // Should set the correct topic zero + await adapter.contract.actions + .setorigin([operation.originChainId, evmEmitter, evmTopic0]) + .send(active(adapter.account)) + }) + + describe('Operatiion variants', () => { + it('Should reject if nonce is different', async () => { + const wrongOperation = { + ...operation, + nonce: 1, + } + + const action = pam.contract.actions + .isauthorized([wrongOperation, metadata]) + .send(active(user)) + + await expectToThrow(action, errors.INVALID_NONCE) + }) + + it('Should reject if token address does not match', async () => { + const wrongOperation = { + ...operation, + token: no0x(zeroPadValue('0x01', 32)), + } + try { + const action = pam.contract.actions + .isauthorized([wrongOperation, metadata]) + .send(active(user)) + } finally { + console.log(pam.contract.bc.console) + } + + // await expectToThrow(action, errors.INVALID_TOKEN_ADDRESS) + }) + + it('Should reject if the destination chain id does not match', async () => { + const wrongOperation = { + ...operation, + destinationChainId: no0x(zeroPadValue('0x01', 32)), + } + + const action = pam.contract.actions + .isauthorized([wrongOperation, metadata]) + .send(active(user)) + + await expectToThrow(action, errors.INVALID_DESTINATION_CHAIN) + }) + + it('Should reject when the amount is different', async () => { + const wrongOperation = { + ...operation, + amount: 800000000000, + } + + try { + const action = pam.contract.actions + .isauthorized([wrongOperation, metadata]) + .send(active(user)) + } finally { + console.log(pam.contract.bc.console) + } + + await expectToThrow(action, errors.INVALID_AMOUNT) + }) + // TODO: implement + // it('Should reject if the operation chain id is different from the underlying chain one', async () => {}) }) }) }) diff --git a/cpp/test/utils/errors.js b/cpp/test/utils/errors.js index a3899e23..a19fe1b5 100644 --- a/cpp/test/utils/errors.js +++ b/cpp/test/utils/errors.js @@ -23,6 +23,20 @@ const ORIGIN_CHAINID_NOT_REGISTERED = eosio_assert( const INVALID_SIGNATURE = eosio_assert('invalid signature') +const UNEXPECTED_EMITTER = eosio_assert('unexpected emitter') + +const UNEXPECTED_TOPIC_ZERO = eosio_assert('unexpected topic zero') + +const INVALID_NONCE = eosio_assert('nonce do not match') + +const INVALID_TOKEN_ADDRESS = eosio_assert('token address do not match') + +const INVALID_DESTINATION_CHAIN = eosio_assert( + 'destination chain id does not match with the expected one', +) + +const INVALID_AMOUNT = eosio_assert('amount do not match') + module.exports = { AUTH_MISSING, SYMBOL_NOT_FOUND, @@ -36,4 +50,10 @@ module.exports = { SINGLETON_NOT_EXISTING, ORIGIN_CHAINID_NOT_REGISTERED, INVALID_SIGNATURE, + UNEXPECTED_EMITTER, + UNEXPECTED_TOPIC_ZERO, + INVALID_NONCE, + INVALID_TOKEN_ADDRESS, + INVALID_DESTINATION_CHAIN, + INVALID_AMOUNT, } diff --git a/cpp/test/utils/get-metadata-sample.js b/cpp/test/utils/get-metadata-sample.js index 47c8dd3f..d06c6470 100644 --- a/cpp/test/utils/get-metadata-sample.js +++ b/cpp/test/utils/get-metadata-sample.js @@ -1,11 +1,13 @@ const R = require('ramda') const getMetadataSample = _injectedMetadata => - R.mergeDeepRight(_injectedMetadata, { - preimage: '0101000000000000000000000000000000000000000000000000000000000000000121d41bf94358b9252115aee1eb250ef5a644e7fae776b3de508aacda5f4c26fc6be2de7375ad7c18fd5ca3ecc8b70e60c535750b042200070dc36f84175a16d6000000000000000000000000cc9676b9bf25ce45a3a5f88205239afddecf1bc79b706941b48091a1c675b439064f40b9d43c577d9c7134cce93179b9b0bf2a520000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000ce00000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ca5269b5c54d4c807ca0df7eeb2cb7a5327e77daca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e90600000000000000000000000000000000000000000000000051bc5435297fb000000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000000000000000000000000000000000000000000c64657374696e617469656f73000000000000000000000000000000000000', - signature: '1c6546663ecbecdae2cb802fc8bf5681dd38c1be86ccf03807c7353d98acdca37c3554231937b66a895e13b2a77371107f2a4e6613ff89e73b0b87ddc1c5783606', + R.mergeDeepLeft(_injectedMetadata, { + preimage: + '0101000000000000000000000000000000000000000000000000000000000000000121d41bf94358b9252115aee1eb250ef5a644e7fae776b3de508aacda5f4c26fc6be2de7375ad7c18fd5ca3ecc8b70e60c535750b042200070dc36f84175a16d6000000000000000000000000cc9676b9bf25ce45a3a5f88205239afddecf1bc79b706941b48091a1c675b439064f40b9d43c577d9c7134cce93179b9b0bf2a520000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000ce00000000000000000000000000000000000000000000000000000000000000000000000000000000000000003ca5269b5c54d4c807ca0df7eeb2cb7a5327e77daca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e90600000000000000000000000000000000000000000000000051bc5435297fb000000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000000000000000000000000000000000000000000c64657374696e617469656f73000000000000000000000000000000000000', + signature: + '1c6546663ecbecdae2cb802fc8bf5681dd38c1be86ccf03807c7353d98acdca37c3554231937b66a895e13b2a77371107f2a4e6613ff89e73b0b87ddc1c5783606', }) module.exports = { getMetadataSample, -} \ No newline at end of file +} diff --git a/cpp/test/utils/get-operation-sample.js b/cpp/test/utils/get-operation-sample.js index 44278b6d..14f5b565 100644 --- a/cpp/test/utils/get-operation-sample.js +++ b/cpp/test/utils/get-operation-sample.js @@ -3,7 +3,7 @@ const { toBeHex, zeroPadValue, parseUnits } = require('ethers') const { no0x } = require('./bytes-utils') const getOperationSample = _injectedOperation => - R.mergeDeepRight(_injectedOperation, { + R.mergeDeepLeft(_injectedOperation, { blockId: no0x( zeroPadValue( '0x21d41bf94358b9252115aee1eb250ef5a644e7fae776b3de508aacda5f4c26fc', diff --git a/cpp/test/utils/hex-to-pubkey.js b/cpp/test/utils/hex-to-pubkey.js index 86b692bf..630f314e 100644 --- a/cpp/test/utils/hex-to-pubkey.js +++ b/cpp/test/utils/hex-to-pubkey.js @@ -1,7 +1,8 @@ const { PublicKey } = require('@wharfkit/antelope') +const { no0x } = require('./bytes-utils') module.exports.hexToPublicKey = _hex => PublicKey.from({ type: 'K1', - compressed: Uint8Array.from(Buffer.from(_hex, 'hex')), + compressed: Uint8Array.from(Buffer.from(no0x(_hex), 'hex')), }) diff --git a/yarn.lock b/yarn.lock index fa9909ce..aec747cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2208,6 +2208,7 @@ __metadata: resolution: "@pnetwork/eos-xerc20@workspace:cpp" dependencies: "@eosnetwork/vert": "npm:^1.0.0" + "@pnetwork/event-attestator": "workspace:^" "@types/ramda": "npm:^0" "@wharfkit/antelope": "npm:^1.0.12" chai: "npm:^4.3.10"