• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ethereumjs-util.bufferToHex函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中ethereumjs-util.bufferToHex函数的典型用法代码示例。如果您正苦于以下问题:TypeScript bufferToHex函数的具体用法?TypeScript bufferToHex怎么用?TypeScript bufferToHex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了bufferToHex函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

 t.test('should not produce hash collsions for different senders', function(st) {
   st.plan(1)
   const txDataModFrom = Object.assign({}, txData, {
     from: '0x2222222222222222222222222222222222222222',
   })
   const tx = new FakeTransaction(txData)
   const txModFrom = new FakeTransaction(txDataModFrom)
   const hash = bufferToHex(tx.hash())
   const hashModFrom = bufferToHex(txModFrom.hash())
   st.notEqual(
     hash,
     hashModFrom,
     'FakeTransactions with different `from` addresses but otherwise identical data should have different hashes',
   )
 })
开发者ID:ethereumjs,项目名称:ethereumjs-tx,代码行数:15,代码来源:fake.ts


示例2: it

 it('signs a personal message', async () => {
     const data = ethUtils.bufferToHex(ethUtils.toBuffer('hello world'));
     const ecSignatureHex = await ledgerSubprovider.signPersonalMessageAsync(data);
     expect(ecSignatureHex).to.be.equal(
         '0xa6cc284bff14b42bdf5e9286730c152be91719d478605ec46b3bebcd0ae491480652a1a7b742ceb0213d1e744316e285f41f878d8af0b8e632cbca4c279132d001',
     );
 });
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:7,代码来源:ledger_subprovider_test.ts


示例3: reportCallbackErrors

 (async () => {
     const messageHex = ethUtils.bufferToHex(ethUtils.toBuffer('hello world'));
     const accounts = await ledgerSubprovider.getAccountsAsync();
     const signer = accounts[0];
     const payload = {
         jsonrpc: '2.0',
         method: 'personal_sign',
         params: [messageHex, signer],
         id: 1,
     };
     const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
         expect(err).to.be.a('null');
         expect(response.result.length).to.be.equal(132);
         expect(response.result.substr(0, 2)).to.be.equal('0x');
         done();
     });
     ledgerProvider.sendAsync(payload, callback);
 })().catch(done);
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:18,代码来源:ledger_subprovider_test.ts


示例4: BigNumber

                value: utils.bigNumberToBN(order.takerTokenAmount),
                type: SolidityTypes.Uint256,
            },
            {
                value: utils.bigNumberToBN(order.makerFee),
                type: SolidityTypes.Uint256,
            },
            {
                value: utils.bigNumberToBN(order.takerFee),
                type: SolidityTypes.Uint256,
            },
            {
                value: utils.bigNumberToBN(order.expirationUnixTimestampSec),
                type: SolidityTypes.Uint256,
            },
            { value: utils.bigNumberToBN(order.salt), type: SolidityTypes.Uint256 },
        ];
        const types = _.map(orderParts, o => o.type);
        const values = _.map(orderParts, o => o.value);
        const hashBuff = ethABI.soliditySHA3(types, values);
        const hashHex = ethUtil.bufferToHex(hashBuff);
        return hashHex;
    },
    getCurrentUnixTimestampSec(): BigNumber {
        return new BigNumber(Date.now() / 1000).round();
    },
    getCurrentUnixTimestampMs(): BigNumber {
        return new BigNumber(Date.now());
    },
};
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:30,代码来源:utils.ts


示例5: bufferToHex

 const pk = accountsKeys.filter((k) => bufferToHex(privateToAddress(k.secretKey)) === account)[0].secretKey;
开发者ID:AlphaX-IBS,项目名称:microraiden,代码行数:1,代码来源:microraiden.ts


示例6: isValidSignature

import { ECSignature } from '@0xproject/types';
import * as ethUtil from 'ethereumjs-util';

export const signatureUtils = {
    isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
        const dataBuff = ethUtil.toBuffer(data);
        const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff);
        try {
            const pubKey = ethUtil.ecrecover(
                msgHashBuff,
                signature.v,
                ethUtil.toBuffer(signature.r),
                ethUtil.toBuffer(signature.s),
            );
            const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
            return retrievedAddress === signerAddress;
        } catch (err) {
            return false;
        }
    },
    parseSignatureHexAsVRS(signatureHex: string): ECSignature {
        const signatureBuffer = ethUtil.toBuffer(signatureHex);
        let v = signatureBuffer[0];
        if (v < 27) {
            v += 27;
        }
        const r = signatureBuffer.slice(1, 33);
        const s = signatureBuffer.slice(33, 65);
        const ecSignature: ECSignature = {
            v,
            r: ethUtil.bufferToHex(r),
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:31,代码来源:signature_utils.ts


示例7: getTopicsForIndexedArgs

     return signature;
 },
 getTopicsForIndexedArgs(abi: EventAbi, indexFilterValues: IndexedFilterValues): Array<string | null> {
     const topics: Array<string | null> = [];
     for (const eventInput of abi.inputs) {
         if (!eventInput.indexed) {
             continue;
         }
         if (_.isUndefined(indexFilterValues[eventInput.name])) {
             // Null is a wildcard topic in a JSON-RPC call
             topics.push(null);
         } else {
             const value = indexFilterValues[eventInput.name] as string;
             const buffer = ethUtil.toBuffer(value);
             const paddedBuffer = ethUtil.setLengthLeft(buffer, TOPIC_LENGTH);
             const topic = ethUtil.bufferToHex(paddedBuffer);
             topics.push(topic);
         }
     }
     return topics;
 },
 matchesFilter(log: LogEntry, filter: FilterObject): boolean {
     if (!_.isUndefined(filter.address) && log.address !== filter.address) {
         return false;
     }
     if (!_.isUndefined(filter.topics)) {
         return filterUtils.matchesTopics(log.topics, filter.topics);
     }
     return true;
 },
 matchesTopics(logTopics: string[], filterTopics: Array<string[] | string | null>): boolean {
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:31,代码来源:filter_utils.ts



注:本文中的ethereumjs-util.bufferToHex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ethereumjs-util.toBuffer函数代码示例发布时间:2022-05-25
下一篇:
TypeScript etcd3.Namespace类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap