ethers/lib/utils#concat TypeScript Examples

The following examples show how to use ethers/lib/utils#concat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: transfer.ts    From hubble-contracts with MIT License 6 votes vote down vote up
serialize(): string {
        const concated = concat([
            hexZeroPad(hexlify(this.fromIndex), StateIDLen),
            hexZeroPad(hexlify(this.toIndex), StateIDLen),
            float16.compress(this.amount),
            float16.compress(this.fee)
        ]);
        return hexlify(concated);
    }
Example #2
Source File: transfer.ts    From hubble-contracts with MIT License 6 votes vote down vote up
serialize(): string {
        if (!this.signature) throw new Error("Signature must be assigned");
        const concated = concat([
            hexZeroPad(hexlify(this.fromIndex), StateIDLen),
            hexZeroPad(hexlify(this.toIndex), StateIDLen),
            float16.compress(this.amount),
            float16.compress(this.fee),
            hexZeroPad(hexlify(this.nonce), StateIDLen),
            dumpG1(this.signature?.sol)
        ]);
        return hexlify(concated);
    }
Example #3
Source File: tx.ts    From hubble-contracts with MIT License 6 votes vote down vote up
public encode(): string {
        const concated = concat([
            hexZeroPad(hexlify(this.fromIndex), stateIDLen),
            hexZeroPad(hexlify(this.toIndex), stateIDLen),
            float16.compress(this.amount),
            float16.compress(this.fee)
        ]);
        return hexlify(concated);
    }
Example #4
Source File: tx.ts    From hubble-contracts with MIT License 6 votes vote down vote up
public encode(): string {
        const concated = concat([
            hexZeroPad(hexlify(this.fromIndex), stateIDLen),
            hexZeroPad(hexlify(this.toIndex), stateIDLen),
            hexZeroPad(hexlify(this.toPubkeyID), stateIDLen),
            float16.compress(this.amount),
            float16.compress(this.fee)
        ]);
        return hexlify(concated);
    }
Example #5
Source File: transfer.ts    From hubble-contracts with MIT License 5 votes vote down vote up
export function compress(txs: OffchainTx[]): string {
    return hexlify(concat(txs.map(tx => tx.toCompressed().serialize())));
}
Example #6
Source File: tx.ts    From hubble-contracts with MIT License 5 votes vote down vote up
public encode(): string {
        const concated = concat([
            hexZeroPad(hexlify(this.fromIndex), stateIDLen),
            float16.compress(this.amount),
            float16.compress(this.fee)
        ]);
        return hexlify(concated);
    }
Example #7
Source File: tx.ts    From hubble-contracts with MIT License 5 votes vote down vote up
export function serialize(txs: Tx[]): string {
    return hexlify(concat(txs.map(tx => tx.encode())));
}