fix: isomorhpic randomUUID

This commit is contained in:
ppe
2022-09-20 13:51:14 +02:00
parent de8a3b04f8
commit f3f7889f9d
2 changed files with 14 additions and 2 deletions

View File

@@ -1,11 +1,14 @@
import { InteractionData } from './modules/impl/HandlerExecutorFactory';
import { InnerCallType } from '../contract/Contract';
import { isomorphicRandomUUID } from '../utils/utils';
export class ContractCallRecord {
readonly interactions: { [key: string]: InteractionCall } = {};
readonly id: string;
constructor(readonly contractTxId: string, readonly depth: number, readonly innerCallType: InnerCallType = null) {}
constructor(readonly contractTxId: string, readonly depth: number, readonly innerCallType: InnerCallType = null) {
this.id = isomorphicRandomUUID();
}
addInteractionData(interactionData: InteractionData<any>): InteractionCall {
const { interaction, interactionTx } = interactionData;

View File

@@ -1,7 +1,8 @@
/* eslint-disable */
import cloneDeep from 'lodash/cloneDeep';
import copy from 'fast-copy';
import { Buffer } from 'redstone-isomorphic';
import {Buffer} from 'redstone-isomorphic';
import {randomUUID} from "crypto";
export const sleep = (ms: number): Promise<void> => {
return new Promise((resolve) => setTimeout(resolve, ms));
@@ -75,3 +76,11 @@ export function bufToBn(buf: Buffer) {
return BigInt('0x' + hex.join(''));
}
export function isomorphicRandomUUID() {
if (self.crypto) {
return self.crypto.randomUUID();
} else {
return randomUUID();
}
}